예제 #1
0
 def deletePeriod(self):
     Item = self.ui.period_listWidget.currentItem()
     if not Item:
         showMessage('Debe seleccionar un periodo')
         return
     ItemText = Item.text()
     currentPeriod = getIDCurrentPeriod(self.connection)
     Anio = getAnioPeriod(self.connection, currentPeriod)
     if ItemText == str(Anio):
         showMessage('El periodo a eliminar no puede ser el actual')
         return
     msg = '¿Desea eliminar el periodo ' + str(
         ItemText
     ) + '? Considere que todas las solicitudes y notificaciones serán también eliminadas'
     Rta = showMessage(msg, 4,
                       QtWidgets.QMessageBox.Yes | QtWidgets.QMessageBox.No)
     if Rta == QtWidgets.QMessageBox.Yes:
         currentPeriod = getIDCurrentPeriod(self.connection)
         Anio = getAnioPeriod(self.connection, currentPeriod)
         if Anio == ItemText:
             showMessage('No puede eliminar el periodo actual')
             return
         rows = deletePeriodByYear(self.connection, ItemText)
         if rows == 1:
             QtWidgets.QMessageBox.information(self, 'Exito',
                                               'Operación realizada')
             self.showPeriods()
         else:
             showMessage('El periodo no pudo ser eliminado')
     return
예제 #2
0
 def resetCalendar(self):
     format_normal = QtGui.QTextCharFormat()
     format_normal.setBackground(QtCore.Qt.white)
     AllUsersIDs = searchAllUsersID(self.connection)
     IDCurrentPeriod = getIDCurrentPeriod(self.connection)
     # reseteo dias de empleados
     for idemployee in AllUsersIDs:
         Days = searchDaysAcceptedByID(idemployee[0], self.connection,
                                       IDCurrentPeriod)
         for iday in Days:
             if iday[1] != None:
                 currDay = iday[0]
                 maxDay = iday[1]
                 while currDay <= maxDay:
                     day = QtCore.QDate(currDay.year, currDay.month,
                                        currDay.day)
                     self.ui.employeecalendarWidget.setDateTextFormat(
                         day, format_normal)
                     currDay += datetime.timedelta(1)
             else:
                 day = QtCore.QDate(iday[0].year, iday[0].month,
                                    iday[0].day)
                 self.ui.employeecalendarWidget.setDateTextFormat(
                     day, format_normal)
     # reseteo feriados
     Feriados = getFeriados(self.connection, IDCurrentPeriod)
     for iFeriados in Feriados:
         self.ui.employeecalendarWidget.setDateTextFormat(
             iFeriados[0], format_normal)
     return
예제 #3
0
    def loadData(self):
        if (self.currentUserID < 0):
            showMessage(
                'Ha ocurrido un error. Por favor comuníquese con el administrador'
            )
            sys.exit(1)

        UserTuple = searchUserByID(self.currentUserID, self.connection)
        if (len(UserTuple) > 1):
            showMessage(
                'Ha ocurrido un error. Por favor comuníquese con el administrador'
            )
            sys.exit(1)

        self.currentUserName = UserTuple[0][1]
        self.currentUserMail = UserTuple[0][5]

        self.changeView()

        IDCurrentPeriod = getIDCurrentPeriod(self.connection)
        RestOfDays = self.calculateRemainingDays(IDCurrentPeriod)
        end_date = getEndDatePeriod(self.connection, IDCurrentPeriod)
        current_date = datetime.date.today()
        remaining_days = abs((current_date - end_date).days)
        if RestOfDays > 0 and remaining_days < 20:
            showMessage(
                "Quedan %s días para que finalize el período. Por favor, solicite sus días antes de que éstos expiren"
                % remaining_days, 1)
        return
예제 #4
0
    def showAllNotifications(self):
        self.ui.notifications_tableWidget.clearContents()
        self.ui.notifications_tableWidget.setRowCount(0)
        IDCurrentPeriod = getIDCurrentPeriod(self.connection)
        AllNotifications = searchAllNotifications(self.connection,
                                                  IDCurrentPeriod)
        for iNotification in AllNotifications:
            currentRow = self.ui.notifications_tableWidget.rowCount()
            self.ui.notifications_tableWidget.setRowCount(currentRow + 1)
            it0 = QtWidgets.QTableWidgetItem(str(iNotification[0]))
            it0.setFlags(QtCore.Qt.ItemIsEnabled)
            self.ui.notifications_tableWidget.setItem(currentRow, 0, it0)

            EmployeeName = searchNameForUserByID(self.connection,
                                                 iNotification[2])
            AdminName = searchNameForUserByID(self.connection,
                                              iNotification[5])
            aux = 'descontado ' if iNotification[4] == 0 else 'agregado '
            msj = AdminName[0][0] + ' ' + AdminName[0][1] + ' ha ' + aux + str(
                iNotification[3]) + ' días al empleado ' + str(
                    EmployeeName[0][0]) + ' ' + str(EmployeeName[0][1])
            msj = msj + ' por la razón: ' + str(iNotification[1])

            it1 = QtWidgets.QTableWidgetItem(str(msj))
            it1.setFlags(QtCore.Qt.ItemIsEnabled)
            self.ui.notifications_tableWidget.setItem(currentRow, 1, it1)
        return
예제 #5
0
    def agregarFeriados(self):
        dialog = QtWidgets.QDialog()
        dialog.setFixedSize(190, 145)
        mfDialog = Ui_ModificarFeriadosDialog()
        mfDialog.setupUi(dialog)
        mfDialog.fecha_feriado.setDate(datetime.datetime.now())
        Result = dialog.exec_()

        if Result:
            Fecha = mfDialog.fecha_feriado.date()
            Razon = mfDialog.razon_feriado.toPlainText()
            msg = '¿Desea agregar el día ' + str(
                Fecha.toString('dd/MM/yyyy')) + ' como feriado ?'
            Rta = showMessage(
                msg, 4, QtWidgets.QMessageBox.Yes | QtWidgets.QMessageBox.No)
            if Rta == QtWidgets.QMessageBox.Yes:
                IDCurrentPeriod = getIDCurrentPeriod(self.connection)
                Result = addFeriados(self.connection, IDCurrentPeriod, Fecha,
                                     Razon)
                if Result == 0:
                    QtWidgets.QMessageBox.information(self, 'Exito',
                                                      'Operación realizada')
                    self.showFeriados()
                    self.parent.colourFeriados()
                elif Result == 23505:
                    showMessage('Usted ya seleccionó este día como feriado')
                else:
                    showMessage('No se pudo realizar la operación solicitada')
            else:
                QtWidgets.QMessageBox.information(self, 'Cancelada',
                                                  'Solicitud cancelada')

        return
예제 #6
0
    def eliminarFeriados(self):
        dialog = QtWidgets.QDialog()
        dialog.setFixedSize(190, 145)
        mfDialog = Ui_ModificarFeriadosDialog()
        mfDialog.setupUi(dialog)
        mfDialog.fecha_feriado.setDate(datetime.datetime.now())
        mfDialog.razon_feriado.setEnabled(False)
        Result = dialog.exec_()

        if Result:
            Fecha = mfDialog.fecha_feriado.date()
            msg = '¿Desea eliminar el día ' + str(
                Fecha.toString('dd/MM/yyyy')) + ' como feriado?'
            Rta = showMessage(
                msg, 4, QtWidgets.QMessageBox.Yes | QtWidgets.QMessageBox.No)
            if Rta == QtWidgets.QMessageBox.Yes:
                IDCurrentPeriod = getIDCurrentPeriod(self.connection)
                Result = deleteFeriados(self.connection, IDCurrentPeriod,
                                        Fecha)
                if Result == 1:
                    QtWidgets.QMessageBox.information(self, 'Exito',
                                                      'Operación realizada')
                elif Result == 0:
                    showMessage('No existe ningún feriado en esa fecha')
                else:
                    showMessage('No se pudo realizar la operación solicitada')
                self.showFeriados()
                self.parent.colourFeriados()
            else:
                QtWidgets.QMessageBox.information(self, 'Cancelada',
                                                  'Solicitud cancelada')
예제 #7
0
 def selectPeriod(self, item):
     newAnio = str(item.text())
     msg = '¿Desea utilizar el periodo ' + newAnio + ' como activo?'
     Rta = showMessage(msg, 4,
                       QtWidgets.QMessageBox.Yes | QtWidgets.QMessageBox.No)
     if Rta == QtWidgets.QMessageBox.Yes:
         currentPeriod = getIDCurrentPeriod(self.connection)
         # reseteo calendario antes de que se cambie el periodo activo
         self.parent.resetCalendar()
         Anio = getAnioPeriod(self.connection, currentPeriod)
         Ret = activate_deactivatePeriod(self.connection, Anio, False)
         if Ret != 0:
             showMessage('La operación no pudo realizarse')
             return
         Ret = activate_deactivatePeriod(self.connection, newAnio, True)
         if Ret != 0:
             showMessage('La operación no pudo realizarse')
             return
         # cambio de periodo activo (en la ventana)
         self.setActive(Anio)
         # vuelvo a cargar las nuevas variables
         self.parent.showEmployeeStatus()
         self.parent.colourRequestedDays()
         self.parent.colourFeriados()
         QtWidgets.QMessageBox.information(self, 'Exito',
                                           'Operación realizada')
     return
예제 #8
0
 def setActive(self, oldYear=None):
     currentPeriod = getIDCurrentPeriod(self.connection)
     Anio = getAnioPeriod(self.connection, currentPeriod)
     item = self.ui.period_listWidget.findItems(str(Anio),
                                                QtCore.Qt.MatchExactly)
     my_assert(
         self,
         len(item) == 1,
         'El periodo actual sólo puede ser uno. Contacte al administrador.')
     item[0].setFlags(item[0].flags() ^ QtCore.Qt.ItemIsEnabled)
     item_index = self.ui.period_listWidget.row(item[0])
     item_date = self.ui.endDateListWidget.item(item_index)
     item_date.setFlags(item_date.flags() ^ QtCore.Qt.ItemIsEnabled)
     if oldYear:
         item = self.ui.period_listWidget.findItems(str(oldYear),
                                                    QtCore.Qt.MatchExactly)
         my_assert(
             self,
             len(item) == 1,
             'El periodo a desactivar sólo puede ser uno. Contacte al administrador.'
         )
         item[0].setFlags(QtCore.Qt.ItemIsEnabled)
         item_index = self.ui.period_listWidget.row(item[0])
         item_date = self.ui.endDateListWidget.item(item_index)
         item_date.setFlags(QtCore.Qt.ItemIsEnabled)
     return
예제 #9
0
 def setLabels(self):
     self.ui.label_presentacion.setText('Hola, %s' % self.currentUserName)
     IDCurrentPeriod = getIDCurrentPeriod(self.connection)
     RestOfDays = self.calculateRemainingDays(IDCurrentPeriod)
     self.ui.label_dias.setText('Días restantes: %s' % RestOfDays)
     Anio = getAnioPeriod(self.connection, IDCurrentPeriod)
     self.ui.label_periodo.setText('Período: %s' % Anio)
     return
예제 #10
0
 def colourFeriados(self):
     format_feriados = QtGui.QTextCharFormat()
     format_feriados.setBackground(QtCore.Qt.blue)
     IDCurrentPeriod = getIDCurrentPeriod(self.connection)
     Feriados = getFeriados(self.connection, IDCurrentPeriod)
     for iFeriados in Feriados:
         self.ui.employeecalendarWidget.setDateTextFormat(
             iFeriados[0], format_feriados)
     return
예제 #11
0
    def giveDays(self):
        senderButton = self.sender().objectName()
        dialog = QtWidgets.QDialog()
        dialog.setFixedSize(362, 280)
        admDialog = Ui_AdmDaysDialog()
        admDialog.setupUi(dialog)
        AllUsersIDs = searchAllUsersID(self.connection)

        for UserID in AllUsersIDs:
            Nombre = searchNameForUserByID(self.connection, UserID[0])
            admDialog.employee_comboBox.addItem(Nombre[0][0] + ' ' +
                                                Nombre[0][1])

        result = dialog.exec_()

        if result:
            dias = admDialog.days_doubleSpinBox.value()
            if (dias % .5 != 0):
                showMessage('El número ingresado no es válido')
                return

            empleado = admDialog.employee_comboBox.currentText()
            txt = 'agregar ' if senderButton == 'giveDays_pushButton' else 'descontar '
            msg = '¿Desea ' + str(txt) + str(
                dias) + ' días al empleado ' + str(empleado) + '?'
            Rta = showMessage(
                msg, 4, QtWidgets.QMessageBox.Yes | QtWidgets.QMessageBox.No)
            if Rta == QtWidgets.QMessageBox.Yes:
                empleado = empleado.split(' ')
                ID_Usuario = getUserID(self.connection, empleado[0],
                                       empleado[1])
                IDCurrentPeriod = getIDCurrentPeriod(self.connection)
                DiasOriginal = searchDaysByUserID(self.connection, ID_Usuario,
                                                  IDCurrentPeriod)
                DiasTotal = DiasOriginal + dias if senderButton == 'giveDays_pushButton' else DiasOriginal - dias
                ID_Usuario = getUserID(self.connection, empleado[0],
                                       empleado[1])
                Result = AddDaysToUser(self.connection, DiasTotal, ID_Usuario,
                                       IDCurrentPeriod)
                if Result == 0:
                    QtWidgets.QMessageBox.information(self, 'Exito',
                                                      'Operación realizada')
                    #                    IDCurrentPeriod=getIDCurrentPeriod(self.connection)
                    Razon = str(admDialog.razon_plainTextEdit.toPlainText()
                                ) if admDialog.razon_plainTextEdit.toPlainText(
                                ) != '' else '-'
                    AltaBaja = 1 if senderButton == 'giveDays_pushButton' else 0
                    IDUsuario = getUserID(self.connection, empleado[0],
                                          empleado[1])
                    AddNotification(self.connection, Razon, str(dias),
                                    AltaBaja, IDUsuario, IDCurrentPeriod,
                                    self.currentUserID)
                    self.showEmployeeStatus()
                else:
                    showMessage('No se pudo realizar la operación solicitada')
        return
예제 #12
0
 def showFeriados(self):
     IDCurrentPeriod = getIDCurrentPeriod(self.connection)
     Feriados = getFeriados(self.connection, IDCurrentPeriod)
     self.ui.table_feriados.clearContents()
     self.ui.table_feriados.setRowCount(0)
     for iFeriados in Feriados:
         currentRow = self.ui.table_feriados.rowCount()
         self.ui.table_feriados.setRowCount(currentRow + 1)
         it0 = QtWidgets.QTableWidgetItem(str(iFeriados[0]))
         it0.setFlags(QtCore.Qt.ItemIsEnabled)
         self.ui.table_feriados.setItem(currentRow, 0, it0)
         it1 = QtWidgets.QTableWidgetItem(str(iFeriados[1]))
         it1.setFlags(QtCore.Qt.ItemIsEnabled)
         self.ui.table_feriados.setItem(currentRow, 1, it1)
예제 #13
0
 def colourRequestedDays(self):
     format_reqday_one = QtGui.QTextCharFormat()
     format_reqday_one.setBackground(YELLOW)
     format_reqday_two = QtGui.QTextCharFormat()
     format_reqday_two.setBackground(GREEN)
     AllUsersIDs = searchAllUsersID(self.connection)
     IDCurrentPeriod = getIDCurrentPeriod(self.connection)
     daysEmployeeDict = [
     ]  #Lista que me indica todos los dias que fueron pedidos
     self.daysForEmployee.clear(
     )  #Diccionario con key=dia_mediodia y value una lista con los id de los empleados
     for idemployee in AllUsersIDs:
         Days = searchDaysAcceptedByID(idemployee[0], self.connection,
                                       IDCurrentPeriod)
         for iday in Days:
             if iday[1] != None:
                 currDay = iday[0]
                 maxDay = iday[1]
                 while currDay <= maxDay:
                     day = QtCore.QDate(currDay.year, currDay.month,
                                        currDay.day)
                     color = format_reqday_one if day not in daysEmployeeDict else format_reqday_two
                     self.ui.employeecalendarWidget.setDateTextFormat(
                         day, color)
                     daysEmployeeDict.append(day)
                     key = day.toString() + '_' + str(
                         iday[2]) if iday[2] != None else day.toString()
                     if key in self.daysForEmployee:
                         self.daysForEmployee[key].append(idemployee[0])
                     else:
                         self.daysForEmployee[key] = [idemployee[0]]
                     currDay += datetime.timedelta(1)
             else:
                 day = QtCore.QDate(iday[0].year, iday[0].month,
                                    iday[0].day)
                 color = format_reqday_one if day not in daysEmployeeDict else format_reqday_two
                 self.ui.employeecalendarWidget.setDateTextFormat(
                     day, color)
                 daysEmployeeDict.append(day)
                 key = day.toString() + '_' + str(
                     iday[2]) if iday[2] != None else day.toString()
                 if key in self.daysForEmployee:
                     self.daysForEmployee[key].append(idemployee[0])
                 else:
                     self.daysForEmployee[key] = [idemployee[0]]
     return
예제 #14
0
 def showRequestsAdm(self):
     currentIDPeriod = getIDCurrentPeriod(self.connection)
     Requests = searchAllRequests(self.connection,currentIDPeriod)
     self.ui.tableAdmSolicitudes.clearContents()
     self.ui.tableAdmSolicitudes.setRowCount(0)
     for irequest in Requests:
         currentRow=self.ui.tableAdmSolicitudes.rowCount()
         self.ui.tableAdmSolicitudes.setRowCount(currentRow+1)
         it0=QtWidgets.QTableWidgetItem(str(irequest[0]))
         it0.setFlags(QtCore.Qt.ItemIsEnabled|QtCore.Qt.ItemIsSelectable)
         self.ui.tableAdmSolicitudes.setItem(currentRow,0,it0)
         Tuple=searchNameByRequest(irequest[0],False,self.connection)
         it1=QtWidgets.QTableWidgetItem(str(Tuple[0][0]+' '+Tuple[0][1]))
         it1.setFlags(QtCore.Qt.ItemIsEnabled|QtCore.Qt.ItemIsSelectable)
         self.ui.tableAdmSolicitudes.setItem(currentRow,1,it1)
         it2=QtWidgets.QTableWidgetItem(str(irequest[3].day)+'/'+str(irequest[3].month)+'/'+str(irequest[3].year))
         it2.setFlags(QtCore.Qt.ItemIsEnabled|QtCore.Qt.ItemIsSelectable)
         self.ui.tableAdmSolicitudes.setItem(currentRow,2,it2)
         it3=QtWidgets.QTableWidgetItem(str(irequest[4].day)+'/'+str(irequest[4].month)+'/'+str(irequest[4].year) if irequest[4] is not None else '-')
         it3.setFlags(QtCore.Qt.ItemIsEnabled|QtCore.Qt.ItemIsSelectable)
         self.ui.tableAdmSolicitudes.setItem(currentRow,3,it3)
         it4=QtWidgets.QTableWidgetItem(str('Día completo') if irequest[7]==0 else str('Medio día (mañana)') if irequest[7]==1 else str('Medio día (tarde)') if irequest[7]==2 else str('-'))
         it4.setFlags(QtCore.Qt.ItemIsEnabled|QtCore.Qt.ItemIsSelectable)
         self.ui.tableAdmSolicitudes.setItem(currentRow,4,it4)
         it5=QtWidgets.QTableWidgetItem(str('Licencia') if irequest[8]==0 else str('Ausencia'))
         it5.setFlags(QtCore.Qt.ItemIsEnabled|QtCore.Qt.ItemIsSelectable)
         color = QtCore.Qt.darkYellow if irequest[8]==0 else QtCore.Qt.darkGreen
         it5.setBackground(color)
         self.ui.tableAdmSolicitudes.setItem(currentRow,5,it5)
         it6=QtWidgets.QTableWidgetItem(str(irequest[5]) if irequest[5]!=None and irequest[5]!='NULL' else str('-'))
         it6.setFlags(QtCore.Qt.ItemIsEnabled|QtCore.Qt.ItemIsSelectable)
         self.ui.tableAdmSolicitudes.setItem(currentRow,6,it6)
         it7=QtWidgets.QTableWidgetItem(str('Pendiente') if irequest[6]=='P' else str('Aprobada') if irequest[6]=='A' else str('Rechazada'))
         it7.setFlags(QtCore.Qt.ItemIsEnabled|QtCore.Qt.ItemIsSelectable)
         color = RED if irequest[6]=='R' else YELLOW if irequest[6]=='P' else GREEN
         it7.setBackground(color)
         self.ui.tableAdmSolicitudes.setItem(currentRow,7,it7)
         Tuple=searchNameByRequest(irequest[0],True,self.connection)
         if Tuple:
             it8=QtWidgets.QTableWidgetItem(str(Tuple[0][0]+' '+Tuple[0][1]))
         else:
             it8=QtWidgets.QTableWidgetItem(str('-'))
         it8.setFlags(QtCore.Qt.ItemIsEnabled|QtCore.Qt.ItemIsSelectable)
         self.ui.tableAdmSolicitudes.setItem(currentRow,8,it8)
     return
예제 #15
0
    def showNotifications(self):
        self.ui.table_notificaciones.clearContents()
        self.ui.table_notificaciones.setRowCount(0)
        IDCurrentPeriod = getIDCurrentPeriod(self.connection)
        UserNotifications = searchNotificationsByID(self.connection,
                                                    IDCurrentPeriod,
                                                    self.currentUserID)
        for iNotification in UserNotifications:
            currentRow = self.ui.table_notificaciones.rowCount()
            self.ui.table_notificaciones.setRowCount(currentRow + 1)
            it0 = QtWidgets.QTableWidgetItem(str(iNotification[0]))
            it0.setFlags(QtCore.Qt.ItemIsEnabled)
            self.ui.table_notificaciones.setItem(currentRow, 0, it0)

            aux = 'descontado ' if iNotification[3] == 0 else 'agregado '
            msj = 'Se le han ' + aux + str(
                iNotification[2]) + ' días por la razón: ' + str(
                    iNotification[1])
            it1 = QtWidgets.QTableWidgetItem(str(msj))
            it1.setFlags(QtCore.Qt.ItemIsEnabled)
            self.ui.table_notificaciones.setItem(currentRow, 1, it1)
예제 #16
0
 def showEmployeeStatus(self):
     self.ui.employeeStatustableWidget.clearContents()
     self.ui.employeeStatustableWidget.setRowCount(0)
     IDCurrentPeriod = getIDCurrentPeriod(self.connection)
     AllUsersIDs = searchAllUsersID(self.connection)
     Feriados = getFeriados(self.connection, IDCurrentPeriod)
     for UserID in AllUsersIDs:
         Dias = searchDaysForUserByID(self.connection, UserID[0],
                                      IDCurrentPeriod)
         Nombre = searchNameForUserByID(self.connection, UserID[0])
         currentRow = self.ui.employeeStatustableWidget.rowCount()
         self.ui.employeeStatustableWidget.setRowCount(currentRow + 1)
         it0 = QtWidgets.QTableWidgetItem(
             str(Nombre[0][0] + ' ' + Nombre[0][1]))
         it0.setFlags(QtCore.Qt.ItemIsEnabled | QtCore.Qt.ItemIsSelectable)
         self.ui.employeeStatustableWidget.setItem(currentRow, 0, it0)
         DaysTotal = Dias[0][0]
         it1 = QtWidgets.QTableWidgetItem(str(DaysTotal))
         it1.setFlags(QtCore.Qt.ItemIsEnabled | QtCore.Qt.ItemIsSelectable)
         self.ui.employeeStatustableWidget.setItem(currentRow, 1, it1)
         Absences = searchforAbsenceOrLicenseByUserID(
             self.connection, UserID[0], IDCurrentPeriod, True)
         DaysAbsences = calculateDays(Absences, Feriados)
         it2 = QtWidgets.QTableWidgetItem(str(DaysAbsences))
         it2.setFlags(QtCore.Qt.ItemIsEnabled | QtCore.Qt.ItemIsSelectable)
         self.ui.employeeStatustableWidget.setItem(currentRow, 2, it2)
         Licenses = searchforAbsenceOrLicenseByUserID(
             self.connection, UserID[0], IDCurrentPeriod, False)
         DaysLicenses = calculateDays(Licenses, Feriados)
         it3 = QtWidgets.QTableWidgetItem(str(DaysLicenses))
         it3.setFlags(QtCore.Qt.ItemIsEnabled | QtCore.Qt.ItemIsSelectable)
         self.ui.employeeStatustableWidget.setItem(currentRow, 3, it3)
         RestOfDays = DaysTotal - DaysAbsences - DaysLicenses
         it4 = QtWidgets.QTableWidgetItem(str(RestOfDays))
         it4.setFlags(QtCore.Qt.ItemIsEnabled | QtCore.Qt.ItemIsSelectable)
         self.ui.employeeStatustableWidget.setItem(currentRow, 4, it4)
         color = GREEN if RestOfDays == 0 else YELLOW if RestOfDays > 0 else RED
         it0.setBackground(color)
     return
예제 #17
0
 def showRequests(self):
     IDCurrentPeriod = getIDCurrentPeriod(self.connection)
     Requests = searchRequestsByUserID(self.currentUserID, IDCurrentPeriod,
                                       self.connection, False)
     self.ui.table_solicitudes.clearContents()
     self.ui.table_solicitudes.setRowCount(0)
     for irequest in Requests:
         currentRow = self.ui.table_solicitudes.rowCount()
         self.ui.table_solicitudes.setRowCount(currentRow + 1)
         it0 = QtWidgets.QTableWidgetItem(str(irequest[0]))
         it0.setFlags(QtCore.Qt.ItemIsEnabled)
         self.ui.table_solicitudes.setItem(currentRow, 0, it0)
         it1 = QtWidgets.QTableWidgetItem(
             str(irequest[1].day) + '/' + str(irequest[1].month) + '/' +
             str(irequest[1].year))
         it1.setFlags(QtCore.Qt.ItemIsEnabled)
         self.ui.table_solicitudes.setItem(currentRow, 1, it1)
         it2 = QtWidgets.QTableWidgetItem(
             str(irequest[2].day) + '/' + str(irequest[2].month) + '/' +
             str(irequest[2].year) if irequest[2] is not None else '-')
         it2.setFlags(QtCore.Qt.ItemIsEnabled)
         self.ui.table_solicitudes.setItem(currentRow, 2, it2)
         it3 = QtWidgets.QTableWidgetItem(
             str('Día completo') if irequest[3] ==
             0 else str('Medio día (mañana)') if irequest[3] == 1 else
             str('Medio día (tarde)') if irequest[3] == 2 else str('-'))
         it3.setFlags(QtCore.Qt.ItemIsEnabled)
         self.ui.table_solicitudes.setItem(currentRow, 3, it3)
         it4 = QtWidgets.QTableWidgetItem(
             str('Licencia') if irequest[4] == 0 else str('Ausencia'))
         it4.setFlags(QtCore.Qt.ItemIsEnabled)
         self.ui.table_solicitudes.setItem(currentRow, 4, it4)
         it5 = QtWidgets.QTableWidgetItem(
             str('Pendiente') if irequest[5] == 'P' else
             str('Aprobada') if irequest[5] == 'A' else str('Rechazada'))
         it5.setFlags(QtCore.Qt.ItemIsEnabled)
         self.ui.table_solicitudes.setItem(currentRow, 5, it5)
     return
예제 #18
0
    def verifyRestriccion(self,RequestNumber):
        Request = getRequestByIDs(self.connection,RequestNumber)
        RequestAux = [(Request[3],Request[4],Request[7])]
        UserID = Request[1]
        UserRestricciones = getRestriccionesFromUser(self.connection,UserID)
        IDCurrentPeriod=getIDCurrentPeriod(self.connection)
#        AusenciasUser = searchforAbsenceOrLicenseByUserID(self.connection,UserID,IDCurrentPeriod,True)
#        LicenciasUser = searchforAbsenceOrLicenseByUserID(self.connection,UserID,IDCurrentPeriod,False)
        VecRes = []
        for iUserRestricciones in UserRestricciones:
            iUserRestricciones = iUserRestricciones[0]
            for ijUserRestricciones in iUserRestricciones:
                if ijUserRestricciones==UserID:
                    continue
                AusenciasUserRes = searchforAbsenceOrLicenseByUserID(self.connection,ijUserRestricciones,IDCurrentPeriod,True)
                LicenciasUserRes = searchforAbsenceOrLicenseByUserID(self.connection,ijUserRestricciones,IDCurrentPeriod,False)
                if self.checkCollisionsOnRestricciones(LicenciasUserRes,RequestAux):
                    VecRes.append(iUserRestricciones)
                    break
                if self.checkCollisionsOnRestricciones(AusenciasUserRes,RequestAux):
                    VecRes.append(iUserRestricciones)
                    break
        return VecRes
예제 #19
0
 def colourRequestedDays(self):
     format_reqday_complete = QtGui.QTextCharFormat()
     format_reqday_complete.setBackground(YELLOW)
     format_reqday_half = QtGui.QTextCharFormat()
     format_reqday_half.setBackground(GREEN)
     IDCurrentPeriod = getIDCurrentPeriod(self.connection)
     Days = searchDaysAcceptedByID(self.currentUserID, self.connection,
                                   IDCurrentPeriod)
     for iday in Days:
         if iday[1] != None:
             currDay = iday[0]
             maxDay = iday[1]
             while currDay <= maxDay:
                 day = QtCore.QDate(currDay.year, currDay.month,
                                    currDay.day)
                 self.ui.calendario.setDateTextFormat(
                     day, format_reqday_complete)
                 currDay += datetime.timedelta(1)
         else:
             day = QtCore.QDate(iday[0].year, iday[0].month, iday[0].day)
             self.ui.calendario.setDateTextFormat(
                 day, format_reqday_complete
                 if iday[2] == 0 else format_reqday_half)
예제 #20
0
    def requestDays(self, userID, conn):
        IDCurrentPeriod = getIDCurrentPeriod(conn)
        fechaDesde = self.ui.fechaDesde.date()
        fechaHasta = self.ui.fechaHasta.date() if self.ui.fechaHasta.isEnabled(
        ) else None
        Razon = self.ui.razon.toPlainText(
        ) if self.ui.razon.toPlainText() != '' else None
        MedioDia = self.ui.diaUnicoComboBox.currentIndex(
        ) if self.ui.diaUnico.isChecked() else None
        Tipo = self.ui.tipo.currentIndex()

        Requests = searchRequestsByUserID(userID, IDCurrentPeriod, conn, True)
        for irequest in Requests:
            ReqFechaDesde = datetime.date(irequest[1].year, irequest[1].month,
                                          irequest[1].day)
            ReqFechaHasta = datetime.date(
                irequest[2].year, irequest[2].month,
                irequest[2].day) if irequest[2] is not None else None
            currFechaDesde = datetime.date(fechaDesde.year(),
                                           fechaDesde.month(),
                                           fechaDesde.day())
            currFechaHasta = datetime.date(
                fechaHasta.year(), fechaHasta.month(),
                fechaHasta.day()) if fechaHasta is not None else None
            if ReqFechaHasta:
                if ReqFechaDesde <= currFechaDesde <= ReqFechaHasta:
                    showMessage(
                        'Usted ya ha pedido ese día o alguno de esos días anteriormente. Por favor cancele la solicitud para volver a efectuarla'
                    )
                    return -1
            if currFechaHasta:
                if currFechaDesde <= ReqFechaDesde <= currFechaHasta:
                    showMessage(
                        'Usted ya ha pedido ese día o alguno de esos días anteriormente. Por favor cancele la solicitud para volver a efectuarla'
                    )
                    return -1
            if ReqFechaDesde == currFechaDesde:
                showMessage(
                    'Usted ya ha pedido ese día o alguno de esos días anteriormente. Por favor cancele la solicitud para volver a efectuarla'
                )
                return -1

        msg = '¿Está seguro que desea solicitar los días %s a %s?' % (
            str(fechaDesde.toString('dd/MM/yyyy')),
            str(fechaHasta.toString('dd/MM/yyyy'))
        ) if fechaHasta is not None else '¿Está seguro que desea solicitar el día %s?' % str(
            fechaDesde.toString('dd/MM/yyyy'))
        Rta = showMessage(msg, 4,
                          QtWidgets.QMessageBox.Yes | QtWidgets.QMessageBox.No)
        if Rta == QtWidgets.QMessageBox.Yes:
            Return = doRequestByID(userID, conn, self.ui.fechaDesde.date(),
                                   Tipo, IDCurrentPeriod, fechaHasta, Razon,
                                   MedioDia)
            if Return == 23505:  #unique violation
                showMessage(
                    'Usted ya ha pedido ese día o alguno de esos días anteriormente. Por favor cancele la solicitud para volver a efectuarla'
                )
            elif Return == 23514:  #check violation
                showMessage('La fecha hasta debe ser mayor a la fecha desde')
            elif Return == 0:  #exito
                QtWidgets.QMessageBox.information(
                    self, 'Exito', 'Solicitud enviada correctamente')
            return Return
        else:
            QtWidgets.QMessageBox.information(self, 'Cancelada',
                                              'Solicitud cancelada')
            return -1