def searchCustomer(self):
        mob_num = self.searchled.text()
        if mob_num == '':
            self.statuslbl.setText('Must enter mobilephone to start search')
        elif select_customer_by_mob_num(mob_num):
            selectedCust = select_customer_by_mob_num(mob_num)
            self.renamelbl.setText(selectedCust.name)
            self.remobilenumlbl.setText(selectedCust.mobile_number)
            self.remobilenumlbl1.setText(selectedCust.mobile_number_1)
            self.remobilenumlbl2.setText(selectedCust.mobile_number_2)
            self.remobilenumlbl3.setText(selectedCust.mobile_number_3)
            self.remobilenumlbl4.setText(selectedCust.mobile_number_4)
            city_name = select_city_by_id(selectedCust.city_id).name
            self.recitylbl.setText(city_name)
            self.reagelbl.setText(str(selectedCust.age))
            self.regenderlbl.setText(selectedCust.gender.capitalize())
            self.statuslbl.setText('')
            self.detailsbtn.setEnabled(True)
            # role handel
            role = getLoginDataPKL()['role']
            if int(role) == 1 or int(role) == 2 or int(role) == 3:
                self.updatebtn.setEnabled(False)
            else:
                self.updatebtn.setEnabled(True)

            if select_maintenance_customer(selectedCust.id):
                self.statuslbl.setText(
                    "Can't delete, this customer have maintenance")
            else:
                return False
        else:
            self.statuslbl.setText("Can't found customer")
 def searchCustomer(self):
     mob_num = self.searchled.text()
     if mob_num == '':
         self.statuslbl.setText('Must enter mobilephone to start search')
     elif select_customer_by_mob_num(mob_num):
         selectedCust = select_customer_by_mob_num(mob_num)
         self.renamelbl.setText(selectedCust.name)
         self.custnameled.setText(selectedCust.name)
         self.remobilenumlbl.setText(selectedCust.mobile_number)
         self.remobilenumlbl91.setText(selectedCust.mobile_number_1)
         self.remobilenumlbl92.setText(selectedCust.mobile_number_2)
         self.remobilenumlbl93.setText(selectedCust.mobile_number_3)
         self.remobilenumlbl94.setText(selectedCust.mobile_number_4)
         self.mobcustled.setText(selectedCust.mobile_number)
         self.mobcustled91.setText(selectedCust.mobile_number_1)
         self.mobcustled92.setText(selectedCust.mobile_number_2)
         self.mobcustled93.setText(selectedCust.mobile_number_3)
         self.mobcustled94.setText(selectedCust.mobile_number_4)
         city = select_city_by_id(selectedCust.city_id)
         self.recitylbl.setText(city.name)
         self.citycmbx.setCurrentText(city.name)
         self.reagelbl.setText(str(selectedCust.age))
         self.agespin.setValue(selectedCust.age)
         self.regenderlbl.setText(selectedCust.gender.capitalize())
         if selectedCust.gender == 'male':
             self.malebtn.setChecked(True)
         else:
             self.femalerbtn.setChecked(True)
         self.statuslbl.setText('')
     else:
         self.statuslbl.setText("Can't found customer")
 def Clicked(self, item):
     indexes = self.tableView.selectionModel().selectedRows(1)
     for ind in sorted(indexes):
         cst = select_customer_by_mob_num(ind.data())
         self.customerNamelbl.setText(cst.name)
         self.customerMobilelbl.setText(cst.mobile_number)
         self.customerAgelbl.setText(str(cst.age))
         cty = select_city_by_id(cst.city_id)
         self.customerCitylbl.setText(cty.name)
         self.createbtn.setEnabled(True)
Exemplo n.º 4
0
    def setData(self, obj):
        self.nameled.setText(obj.name)
        self.ageled.setText(str(obj.age))
        self.mobnumled.setText(obj.mobile_number)
        if self.reqTypecomboBox.currentIndex() == 1:
            self.jobled.setText(obj.job_title)
            self.citylbl.setText('Country :')

            self.reqTypecomboBox.model().item(2).setEnabled(False)
            city = obj.nationality
        elif self.reqTypecomboBox.currentIndex() == 2:
            self.reqTypecomboBox.model().item(1).setEnabled(False)

            self.citylbl.setText('City :')
            city = select_city_by_id(obj.city_id).name
        self.cityled.setText(city)
Exemplo n.º 5
0
    def create_pdf(self):
        """
		Create a pdf
		"""
        story = []

        doc = SimpleDocTemplate(self.refile, pagesize=A4)
        styles = getSampleStyleSheet()

        spacer = Spacer(0, 0.07 * inch)
        story.append(spacer)
        story.append(spacer)

        line = MCLine(-30, 470)
        story.append(line)
        story.append(spacer)

        text_data = [
            "#", "Cust. Name", "Cust. Mobile #", "Cust. Age", "Cust. City"
        ]
        d = []
        font_size = 8
        centered = ParagraphStyle(name="centered", alignment=TA_CENTER)
        for text in text_data:
            ptext = "<font size=%s><b>%s</b></font>" % (font_size, text)
            p = Paragraph(ptext, centered)
            d.append(p)

        data = [d]

        line_num = 1

        formatted_line_data = []

        for val in select_all_customers():
            cityName = select_city_by_id(val.city_id)
            line_data = [
                str(line_num), val.name, val.mobile_number, val.age,
                select_city_by_id(val.city_id).name
            ]

            for item in line_data:
                ptext = "<font size=%s>%s</font>" % (font_size - 1, item)
                p = Paragraph(ptext, centered)
                formatted_line_data.append(p)
            data.append(formatted_line_data)
            formatted_line_data = []
            line_num += 1

        table = Table(data,
                      colWidths=[20, 180, 100, 70, 120],
                      rowHeights=20,
                      style=[('GRID', (0, 0), (-1, -1), 0.5, colors.black)])
        story.append(table)
        story.append(spacer)

        #
        # #########################################################################################

        matxtnum = '<font size=11><p><u>Manager</u><br/>Mohamed Althubiti</p></font>'
        pmatxtnum = Paragraph(matxtnum, centered)
        data = [['', '', '', '', pmatxtnum]]
        t = Table(data, colWidths=[150, 5, 250, 5, 150])
        t.setStyle(
            TableStyle([('LINEABOVE', (3, 2), (-1, -1), 0.25, colors.black)]))
        story.append(t)
        #########################################################################################

        story.append(spacer)

        doc.build(story,
                  onFirstPage=self.createDocument,
                  onLaterPages=self.createDocument)

        subprocess.Popen([self.refile], shell=True)
Exemplo n.º 6
0
    def setupUi(self, historyDialog):
        self.setWindowFlags(self.windowFlags()
                            & ~QtCore.Qt.WindowCloseButtonHint)

        historyDialog.setObjectName("historyDialog")
        historyDialog.resize(348, 569)
        self.label = QtWidgets.QLabel(historyDialog)
        self.label.setGeometry(QtCore.QRect(10, 10, 90, 13))
        self.label.setObjectName("label")
        self.label_2 = QtWidgets.QLabel(historyDialog)
        self.label_2.setGeometry(QtCore.QRect(9, 37, 130, 13))
        self.label_2.setObjectName("label_2")
        self.label_3 = QtWidgets.QLabel(historyDialog)
        self.label_3.setGeometry(QtCore.QRect(11, 63, 90, 13))
        self.label_3.setObjectName("label_3")
        self.label_4 = QtWidgets.QLabel(historyDialog)
        self.label_4.setGeometry(QtCore.QRect(167, 63, 80, 13))
        self.label_4.setObjectName("label_4")
        self.customerNamelbl = QtWidgets.QLineEdit(historyDialog)
        self.customerNamelbl.setEnabled(False)
        self.customerNamelbl.setGeometry(QtCore.QRect(95, 8, 241, 20))
        font = QtGui.QFont()
        font.setPointSize(9)
        font.setBold(True)
        font.setWeight(75)
        self.customerNamelbl.setFont(font)
        self.customerNamelbl.setStyleSheet("color: rgb(255, 0, 0);")
        self.customerNamelbl.setObjectName("customerNamelbl")
        self.customerAgelbl = QtWidgets.QLineEdit(historyDialog)
        self.customerAgelbl.setEnabled(False)
        self.customerAgelbl.setGeometry(QtCore.QRect(88, 60, 70, 20))
        font = QtGui.QFont()
        font.setPointSize(9)
        font.setBold(True)
        font.setWeight(75)
        self.customerAgelbl.setFont(font)
        self.customerAgelbl.setStyleSheet("color: rgb(255, 0, 0);")
        self.customerAgelbl.setObjectName("customerAgelbl")
        self.CustomerCitylbl = QtWidgets.QLineEdit(historyDialog)
        self.CustomerCitylbl.setEnabled(False)
        self.CustomerCitylbl.setGeometry(QtCore.QRect(244, 60, 90, 20))
        font = QtGui.QFont()
        font.setPointSize(9)
        font.setBold(True)
        font.setWeight(75)
        self.CustomerCitylbl.setFont(font)
        self.CustomerCitylbl.setStyleSheet("color: rgb(255, 0, 0);")
        self.CustomerCitylbl.setObjectName("CustomerCitylbl")
        self.customerMobilelbl = QtWidgets.QLineEdit(historyDialog)
        self.customerMobilelbl.setEnabled(False)
        self.customerMobilelbl.setGeometry(QtCore.QRect(135, 34, 200, 20))
        font = QtGui.QFont()
        font.setPointSize(9)
        font.setBold(True)
        font.setWeight(75)
        self.customerMobilelbl.setFont(font)
        self.customerMobilelbl.setStyleSheet("color: rgb(255, 0, 0);")
        self.customerMobilelbl.setObjectName("customerMobilelbl")
        self.line = QtWidgets.QFrame(historyDialog)
        self.line.setGeometry(QtCore.QRect(3, 87, 340, 3))
        self.line.setFrameShape(QtWidgets.QFrame.HLine)
        self.line.setFrameShadow(QtWidgets.QFrame.Sunken)
        self.line.setObjectName("line")
        self.tableView = QtWidgets.QTableView(historyDialog)
        self.tableView.setGeometry(QtCore.QRect(8, 109, 330, 311))
        self.tableView.setObjectName("tableView")
        self.tableView.setEditTriggers(
            QtWidgets.QAbstractItemView.NoEditTriggers)
        self.tableView.setTabKeyNavigation(False)
        self.tableView.setProperty("showDropIndicator", False)
        self.tableView.setDragDropOverwriteMode(False)
        self.tableView.setSelectionMode(
            QtWidgets.QAbstractItemView.SingleSelection)
        self.tableView.setSelectionBehavior(
            QtWidgets.QAbstractItemView.SelectRows)
        self.tableView.horizontalHeader().setCascadingSectionResizes(True)
        self.label_5 = QtWidgets.QLabel(historyDialog)
        self.label_5.setGeometry(QtCore.QRect(12, 92, 140, 13))
        self.label_5.setObjectName("label_5")
        self.line_2 = QtWidgets.QFrame(historyDialog)
        self.line_2.setGeometry(QtCore.QRect(4, 426, 340, 3))
        self.line_2.setFrameShape(QtWidgets.QFrame.HLine)
        self.line_2.setFrameShadow(QtWidgets.QFrame.Sunken)
        self.line_2.setObjectName("line_2")
        self.detailsbtn = QtWidgets.QPushButton(historyDialog)
        self.detailsbtn.setGeometry(QtCore.QRect(20, 524, 75, 40))
        self.detailsbtn.setObjectName("detailsbtn")
        self.detailsbtn.setEnabled(False)
        self.closebtn = QtWidgets.QPushButton(historyDialog)
        self.closebtn.setGeometry(QtCore.QRect(250, 524, 75, 40))
        self.closebtn.setObjectName("closebtn")
        self.line_3 = QtWidgets.QFrame(historyDialog)
        self.line_3.setGeometry(QtCore.QRect(3, 520, 340, 3))
        self.line_3.setFrameShape(QtWidgets.QFrame.HLine)
        self.line_3.setFrameShadow(QtWidgets.QFrame.Sunken)
        self.line_3.setObjectName("line_3")
        self.label_6 = QtWidgets.QLabel(historyDialog)
        self.label_6.setGeometry(QtCore.QRect(6, 433, 100, 13))
        self.label_6.setObjectName("label_6")
        self.mainteCode = QtWidgets.QLineEdit(historyDialog)
        self.mainteCode.setEnabled(False)
        self.mainteCode.setGeometry(QtCore.QRect(105, 431, 120, 20))
        font = QtGui.QFont()
        font.setPointSize(9)
        font.setBold(True)
        font.setWeight(75)
        self.mainteCode.setFont(font)
        self.mainteCode.setStyleSheet("color: rgb(255, 0, 0);")
        self.mainteCode.setObjectName("mainteCode")
        self.label_7 = QtWidgets.QLabel(historyDialog)
        self.label_7.setGeometry(QtCore.QRect(6, 459, 110, 13))
        self.label_7.setObjectName("label_7")
        self.mainteProductlbl = QtWidgets.QLineEdit(historyDialog)
        self.mainteProductlbl.setEnabled(False)
        self.mainteProductlbl.setGeometry(QtCore.QRect(116, 457, 220, 20))
        font = QtGui.QFont()
        font.setPointSize(9)
        font.setBold(True)
        font.setWeight(75)
        self.mainteProductlbl.setFont(font)
        self.mainteProductlbl.setStyleSheet("color: rgb(255, 0, 0);")
        self.mainteProductlbl.setObjectName("mainteProductlbl")
        self.mainteStatuslbl = QtWidgets.QLineEdit(historyDialog)
        self.mainteStatuslbl.setEnabled(False)
        self.mainteStatuslbl.setGeometry(QtCore.QRect(109, 483, 230, 20))
        font = QtGui.QFont()
        font.setPointSize(9)
        font.setBold(True)
        font.setWeight(75)
        self.mainteStatuslbl.setFont(font)
        self.mainteStatuslbl.setStyleSheet("color: rgb(255, 0, 0);")
        self.mainteStatuslbl.setObjectName("mainteStatuslbl")
        self.label_8 = QtWidgets.QLabel(historyDialog)
        self.label_8.setGeometry(QtCore.QRect(6, 485, 110, 13))
        self.label_8.setObjectName("label_8")
        self.retranslateUi(historyDialog)
        QtCore.QMetaObject.connectSlotsByName(historyDialog)
        # self.customer = select_customer_by_id(21)
        self.customerNamelbl.setText(self.customer.name)
        self.customerMobilelbl.setText(self.customer.mobile_number)
        self.customerAgelbl.setText(str(self.customer.age))
        city = select_city_by_id(self.customer.city_id)
        self.CustomerCitylbl.setText(city.name)
        self.tableData = CustomerMaintenanceTableModel()
        self.tableView.setModel(self.tableData)
        for idx, val in enumerate(getMaintenanceForCustomer(self.customer)):
            self.tableData.addMaintenance(
                Maintenance(
                    getMaintenanceForCustomer(self.customer)[idx].m_code, None,
                    None, None, None, None, None, None,
                    getMaintenanceForCustomer(
                        self.customer)[idx].product_of_maintenance, None, None,
                    None, None))
        self.tableView.setColumnWidth(0, 102)
        self.tableView.setColumnWidth(1, 210)
        self.tableView.clicked.connect(self.Clicked)
        self.detailsbtn.clicked.connect(self.detailsDia)
        self.closebtn.clicked.connect(self.close)