Beispiel #1
0
 def setRecord(self, record):
     self.cmbResult.setTable('rbResult', True)
     CEventEditDialog.setRecord(self, record)
     setLineEditValue(self.edtNumber, record, 'externalId')
     setDatetimeEditValue(self.edtEndDate, self.edtEndTime, record,
                          'setDate')
     setRBComboBoxValue(self.cmbPerson, record, 'execPerson_id')
     setDatetimeEditValue(self.edtBegDate, self.edtBegTime, record,
                          'execDate')
     setRBComboBoxValue(self.cmbPerson2, record, 'setPerson_id')
     self.chkAutopsy.setChecked(forceInt(record.value('isPrimary')) == 1)
     self.setPersonId(self.cmbPerson.value())
     self.setContract()
     setRBComboBoxValue(self.cmbResult, record, 'result_id')
     setRBComboBoxValue(self.cmbContract, record, 'contract_id')
     setTextEditValue(self.edtNote, record, 'note')
     self.loadDiagnostics(self.modelPreliminaryDiagnostics)
     self.loadDiagnostics(self.modelFinalDiagnostics)
     self.loadActions()
     self.tabCash.load(self.itemId())
     self.tabNotes.setNotes(record)
     self.tabNotes.setEventEditor(self)
     self.tabNotes.updateReferralPeriod(self.edtBegDate.date())
     self.initFocus()
     self.setIsDirty(False)
     self.blankMovingIdList = []
     self.setEditable(self.getEditable())
     setOrgStructureIdToCmbPerson(self.cmbPerson)
Beispiel #2
0
    def actionSelected(self, action):
        # toggle widgets enabled state
        self.attrsAP.setEnabled(True)
        self.tblAPProps.setEnabled(True)

        # set action to props model
        self.modelAPProps.setAction(action, self.eventEditor.clientId,
                                    self.eventEditor.clientSex,
                                    self.eventEditor.clientAge)
        self.tblAPProps.init()
        self.tblAPProps.resizeRowsToContents()
        setActionPropertiesColumnVisible(action.getType(), self.tblAPProps)

        # set values to top widgets
        setDatetimeEditValue(self.edtAPBegDate, self.edtAPBegTime,
                             action.getRecord(), 'begDate')
        setDatetimeEditValue(self.edtAPEndDate, self.edtAPEndTime,
                             action.getRecord(), 'endDate')
        if not forceDate(action.getRecord().value('endDate')).isNull() and \
                not (forceInt(action.getRecord().value('status')) in CActionType.retranslateClass(False).ignoreStatus) and \
                forceRef(action.getRecord().value('status')) is not None:
            self.cmbAPStatus.setCurrentIndex(2)
        else:
            self.cmbAPStatus.setCurrentIndex(
                forceInt(action.getRecord().value('status')))
        setPerson = forceRef(action.getRecord().value('setPerson_id'))
        if not setPerson:
            if u'moving' in action.getType().flatCode.lower(
            ) and self.eventEditor.prevEventId:
                setPerson = self.presetPerson
            else:
                setPerson = None
        self.cmbAPSetPerson.setValue(setPerson)
        personId = forceRef(action.getRecord().value('person_id'))
        if not personId:
            if u'moving' in action.getType().flatCode.lower(
            ) and self.eventEditor.prevEventId:
                personId = self.presetPerson
            else:
                personId = None
        self.cmbAPPerson.setValue(personId)
        self.cmbMKB.setText(forceString(action.getRecord().value('MKB')))
        self.recalculateUET()

        # setup template buttons
        if QtGui.qApp.userHasRight(urLoadActionTemplate) and action:
            self.btnAPLoadTemplate.setEnabled(True)
        else:
            self.btnAPLoadTemplate.setEnabled(False)
        self.btnAPSaveAsTemplate.setEnabled(
            QtGui.qApp.userHasRight(urSaveActionTemplate))
        self.btnAPLoadPrevAction.setEnabled(
            QtGui.qApp.userHasRight(urCopyPrevAction) and bool(action))
        self.updatePrintButton(action.getType())
 def setRecord(self, record):
     CItemEditorBaseDialog.setRecord(self, record)
     setDateEditValue(self.edtDate, record, 'date')
     setDatetimeEditValue(self.edtDeadlineDate, self.edtDeadlineTime,
                          record, 'deadline')
     setCheckBoxValue(self.chkRevoked, record, 'revoked')
     setRBComboBoxValue(self.cmbSupplier, record, 'supplier_id')
     setRBComboBoxValue(self.cmbRecipient, record, 'recipient_id')
     setLineEditValue(self.edtNote, record, 'note')
     self.modelItems.loadItems(self.itemId())
     self.setIsDirty(False)
Beispiel #4
0
 def setRecord(self, record):
     CEventEditDialog.setRecord(self, record)
     setLineEditValue(self.edtCardNo, record, 'externalId')
     setDatetimeEditValue(self.edtBegDate, self.edtBegTime, record,
                          'setDate')
     setDatetimeEditValue(self.edtEndDate, self.edtEndTime, record,
                          'execDate')
     setRBComboBoxValue(self.cmbPerson, record, 'execPerson_id')
     setRBComboBoxValue(self.cmbResult, record, 'result_id')
     # setComboBoxValue(self.cmbOrder,         record, 'order')
     self.cmbOrder.setCode(forceString(record.value('order')))
     setCheckBoxValue(self.chkLock, record, 'locked')
     self.setPersonId(self.cmbPerson.value())
     self.loadDiagnostics()
     self.initFocus()
     self.setIsDirty(False)
     self.setEditable(self.getEditable())
Beispiel #5
0
    def setRecord(self, record):
        CItemEditorBaseDialog.setRecord(self, record)

        self.setJobInfo(forceRef(record.value('master_id')))

        dateTime = forceDateTime(record.value('datetime'))
        begDateTime = forceDateTime(record.value('begDateTime'))

        self.lblDatetimeValue.setText(forceString(dateTime))
        setDatetimeEditValue(self.edtBegDate, self.edtBegTime, record, 'begDateTime')
        setDatetimeEditValue(self.edtEndDate, self.edtEndTime, record, 'endDateTime')
        setComboBoxValue(self.cmbStatus, record, 'status')

        if self.cmbStatus.currentIndex() == 2:
            self.modelJobTicketProbe.setEditable(False)
            self.edtBegDate.setEnabled(False)
            self.edtBegTime.setEnabled(False)
            self.edtEndDate.setEnabled(False)
            self.edtEndTime.setEnabled(False)
            self.btnSetBegDateTime.setEnabled(False)
            self.btnSetEndDateTime.setEnabled(False)
            self.cmbStatus.setEnabled(False)

        self.date = dateTime.date()
        self.datetime = begDateTime if begDateTime.date().isValid() else dateTime

        clients, actions = self.getActions()
        self.modelJobTicketProbe.setActionIdList(actions)

        self.cmbStatus.setCurrentIndex(max(self.jobStatusModifier, self.cmbStatus.currentIndex()))

        if clients:
            self.setClientId(clients[0])

            self.setIsDirty(False)
        self.isPostUISet = True
Beispiel #6
0
 def setRecord(self, record):
     CItemEditorBaseDialog.setRecord(self, record)
     setDatetimeEditValue(self.edtDate, self.edtTime, record, 'date')
     setRBComboBoxValue(self.cmbSupplier, record, 'supplier_id')
     setRBComboBoxValue(self.cmbSupplierPerson, record, 'supplierPerson_id')
     setLineEditValue(self.edtNote, record, 'note')
Beispiel #7
0
    def _initByAction(self, action):
        self.action = action

        record = action.getRecord()
        CItemEditorBaseDialog.setRecord(self, record)
        self.eventId = forceRef(record.value('event_id'))
        self.eventTypeId = forceRef(QtGui.qApp.db.translate('Event', 'id', self.eventId, 'eventType_id'))
        self.idx = forceInt(record.value('idx'))
        self.clientId = self.getClientId(self.eventId)
        actionType = self.action.getType()
        setActionPropertiesColumnVisible(actionType, self.tblProps)
        showTime = actionType.showTime
        self.edtDirectionTime.setVisible(showTime)
        self.edtPlannedEndTime.setVisible(showTime)
        self.edtCoordTime.setVisible(showTime)
        self.edtBegTime.setVisible(showTime)
        self.edtEndTime.setVisible(showTime)
        self.lblAssistant.setVisible(actionType.hasAssistant)
        self.cmbAssistant.setVisible(actionType.hasAssistant)
        self.setWindowTitle(actionType.code + '|' + actionType.name)
        setCheckBoxValue(self.chkIsUrgent, record, 'isUrgent')
        setDatetimeEditValue(self.edtDirectionDate, self.edtDirectionTime, record, 'directionDate')
        setDatetimeEditValue(self.edtPlannedEndDate, self.edtPlannedEndTime, record, 'plannedEndDate')
        setDatetimeEditValue(self.edtCoordDate, self.edtCoordTime, record, 'coordDate')
        setLabelText(self.lblCoordText, record, 'coordText')
        setDatetimeEditValue(self.edtBegDate, self.edtBegTime, record, 'begDate')
        setDatetimeEditValue(self.edtEndDate, self.edtEndTime, record, 'endDate')
        setComboBoxValue(self.cmbStatus, record, 'status')
        setDoubleBoxValue(self.edtAmount, record, 'amount')
        setDoubleBoxValue(self.edtUet, record, 'uet')
        setRBComboBoxValue(self.cmbPerson, record, 'person_id')
        setRBComboBoxValue(self.cmbSetPerson, record, 'setPerson_id')
        setLineEditValue(self.edtOffice, record, 'office')
        self.cmbAssistant.setValue(self.action.getAssistantId('assistant'))
        setLineEditValue(self.edtNote, record, 'note')
        self.edtDuration.setValue(forceInt(record.value('duration')))
        self.edtPeriodicity.setValue(forceInt(record.value('periodicity')))
        self.edtAliquoticity.setValue(forceInt(record.value('aliquoticity')))

        mkbVisible = bool(actionType.defaultMKB)
        mkbEnabled = actionType.defaultMKB in [1, 2, 5]
        self.cmbMKB.setVisible(mkbVisible)
        self.lblMKB.setVisible(mkbVisible)
        self.cmbMKB.setEnabled(mkbEnabled)
        self.cmbMKB.setText(forceString(record.value('MKB')))

        morphologyMKBVisible = bool(actionType.defaultMorphology) and QtGui.qApp.defaultMorphologyMKBIsVisible()
        morphologyEnabled = actionType.defaultMorphology in [1, 2, 5]
        self.cmbMorphologyMKB.setVisible(morphologyMKBVisible)
        self.lblMorphologyMKB.setVisible(morphologyMKBVisible)
        self.cmbMorphologyMKB.setEnabled(morphologyEnabled)
        self.cmbMorphologyMKB.setText(forceString(record.value('morphologyMKB')))

        self.cmbOrg.setValue(forceRef(record.value('org_id')))
        if (self.cmbPerson.value() is None
            and actionType.defaultPersonInEditor in (CActionType.dpUndefined, CActionType.dpCurrentUser)
            and QtGui.qApp.userSpecialityId):
            self.cmbPerson.setValue(QtGui.qApp.userId)

        self.setPersonId(self.cmbPerson.value())
        self.updateClientInfo()
        self.edtAmount.setEnabled(actionType.amountEvaluation == 0)

        self.modelActionProperties.setAction(self.action, self.clientId, self.clientSex, self.clientAge)
        self.modelActionProperties.reset()
        self.tblProps.init()
        self.tblProps.resizeRowsToContents()

        context = actionType.context if actionType else ''
        customizePrintButton(self.btnPrint, context)

        if QtGui.qApp.userHasRight(urLoadActionTemplate):
            personId = forceRef(record.value('person_id'))
            actionTemplateTreeModel = self.actionTemplateCache.getModel(actionType.id,
                                                                        personId if personId else forceRef(
                                                                            record.value('setPerson_id')))
            self.btnLoadTemplate.setModel(actionTemplateTreeModel)
        else:
            self.btnLoadTemplate.setEnabled(False)
        self.btnSaveAsTemplate.setEnabled(QtGui.qApp.userHasRight(urSaveActionTemplate))
        self.edtDuration.setEnabled(
            QtGui.qApp.userHasRight(urCopyPrevAction) and bool(QtGui.qApp.userId == self.cmbSetPerson.value()) and bool(
                not self.action.getExecutionPlan()) and bool(self.cmbStatus.currentIndex() in [0, 5]) and bool(
                not self.edtEndDate.date()))
        self.edtPeriodicity.setEnabled(
            QtGui.qApp.userHasRight(urCopyPrevAction) and bool(QtGui.qApp.userId == self.cmbSetPerson.value()) and bool(
                not self.action.getExecutionPlan()) and bool(self.cmbStatus.currentIndex() in [0, 5]) and bool(
                not self.edtEndDate.date()))
        self.edtAliquoticity.setEnabled(
            QtGui.qApp.userHasRight(urCopyPrevAction) and bool(QtGui.qApp.userId == self.cmbSetPerson.value()) and bool(
                not self.action.getExecutionPlan()) and bool(self.cmbStatus.currentIndex() in [0, 5]) and bool(
                not self.edtEndDate.date()))

        canEdit = not self.action.isLocked() if self.action else True
        for widget in [self.edtPlannedEndDate, self.edtPlannedEndTime,
                       self.cmbStatus, self.edtBegDate, self.edtBegTime,
                       self.edtEndDate, self.edtEndTime,
                       self.cmbPerson, self.edtOffice,
                       self.cmbAssistant,
                       self.edtAmount, self.edtUet,
                       self.edtNote, self.cmbOrg,
                       self.buttonBox.button(QtGui.QDialogButtonBox.Ok)
                       ]:
            widget.setEnabled(canEdit)
        if not canEdit:
            self.btnLoadTemplate.setEnabled(False)

        canEditPlannedEndDate = canEdit and actionType.defaultPlannedEndDate not in [CActionType.dpedBegDatePlusAmount,
                                                                                     CActionType.dpedBegDatePlusDuration]
        self.edtPlannedEndDate.setEnabled(canEditPlannedEndDate)
        self.edtPlannedEndTime.setEnabled(canEditPlannedEndDate)
        if self.edtDuration.value() > 0 and not self.edtEndDate.date():
            self.btnNextAction.setEnabled(True)
        else:
            self.btnNextAction.setEnabled(False)
        if self.edtDuration.value() > 0:
            self.btnPlanNextAction.setEnabled(True)
        else:
            self.btnPlanNextAction.setEnabled(False)
        self.on_edtDuration_valueChanged(forceInt(record.value('duration')))
Beispiel #8
0
    def onCurrentActionChanged(self):
        model = self.modelAccActions
        items = model.items()
        row = self.tblAccActions.currentIndex().row()
        editWidgets = [
            self.edtAPCoordDate, self.edtAPCoordTime, self.edtAPCoordAgent,
            self.edtAPCoordInspector, self.edtAPCoordText
        ]

        if 0 <= row < len(items):
            record = items[row]
            canEdit = True
            for widget in editWidgets:
                widget.setEnabled(canEdit)
            try:
                for widget in editWidgets:
                    widget.blockSignals(True)
                actionTypeId = forceRef(
                    record.value('actionType_id')) if record else None
                actionType = CActionTypeCache.getById(
                    actionTypeId) if actionTypeId else None
                showTime = actionType.showTime if actionType else False
                self.edtAPDirectionTime.setVisible(showTime)
                self.edtAPPlannedEndTime.setVisible(showTime)
                self.edtAPCoordTime.setVisible(showTime)
                self.edtAPBegTime.setVisible(showTime)
                self.edtAPEndTime.setVisible(showTime)
                setDatetimeEditValue(self.edtAPDirectionDate,
                                     self.edtAPDirectionTime, record,
                                     'directionDate')
                setDatetimeEditValue(self.edtAPPlannedEndDate,
                                     self.edtAPPlannedEndTime, record,
                                     'plannedEndDate')
                setDatetimeEditValue(self.edtAPCoordDate, self.edtAPCoordTime,
                                     record, 'coordDate')
                self.edtAPCoordAgent.setText(
                    forceString(record.value('coordAgent')))
                self.edtAPCoordInspector.setText(
                    forceString(record.value('coordInspector')))
                self.edtAPCoordText.setText(
                    forceString(record.value('coordText')))
                setDatetimeEditValue(self.edtAPBegDate, self.edtAPBegTime,
                                     record, 'begDate')
                setDatetimeEditValue(self.edtAPEndDate, self.edtAPEndTime,
                                     record, 'endDate')
                self.cmbAPSetPerson.setValue(
                    forceRef(record.value('setPerson_id')))
                self.cmbAPStatus.setCurrentIndex(
                    forceInt(record.value('status')))
                self.edtAPOffice.setText(forceString(record.value('office')))
                self.cmbAPPerson.setValue(forceRef(record.value('person_id')))
                self.edtAPNote.setText(forceString(record.value('note')))
            finally:
                for widget in editWidgets:
                    widget.blockSignals(False)
        else:
            for widget in editWidgets:
                widget.setEnabled(False)
            self.edtAPDirectionTime.setVisible(False)
            self.edtAPPlannedEndTime.setVisible(False)
            self.edtAPCoordTime.setVisible(False)
            self.edtAPBegTime.setVisible(False)
            self.edtAPEndTime.setVisible(False)