def verify(self):
        chk = valid.validMobile(self.custid.get())
        chk2 = False
        if chk:
            self.cur.execute("select mobile from customers")
            res = self.cur.fetchall()
            for i in res:
                if str(i[0]) == self.custid.get():
                    self.controller.custid = self.custid.get()
                    chk2 = True
                    break
            if chk2:
                self.controller.show_frame(ProcessOrder)
                self.cur.execute("select name from customers where mobile=:1",
                                 (self.controller.custid, ))
                res = self.cur.fetchall()
                name = "WELCOME CUSTOMER : " + res[0][0]
                x = self.controller.frames[ProcessOrder].disp
                x.configure(state=NORMAL)
                x.delete("1.0", tk.END)
                x.insert("1.0", name)
                x.configure(state=DISABLED)
            else:
                tk.messagebox.showerror(title="INVALID ID",
                                        message="CUSTOMER DOES NOT EXIST !")

        else:
            tk.messagebox.showerror(title="INVALID INPUT",
                                    message="INVALID MOBILE NUMBER")
Beispiel #2
0
 def viewOrdersCustomer(self):
     cur = self._cur
     cur.execute("select mobile from customers")
     res = cur.fetchall()
     locust = []
     for i in res:
         locust.append(str(i[0]))
     while (True):
         mob = input("ENTER CUSTOMER MOBILE NUMBER : ")
         chk = valid.validMobile(mob)
         if chk:
             if mob in locust:
                 view.viewOrdersCustomer(mob, cur)
             else:
                 print("CUSTOMER DOES NOT EXIST ! PLEASE TRY AGAIN !! ")
         else:
             print("INVALID MOBILE NUMBER ! PLEASE TRY AGAIN !!")
         msg = """
         CUSTOMER ORDERS
         press : 
         r =======> RETRY
         q =======> GO BACK
         m =======> GO TO MAIN MENU
         
             
         """
         opt = input(msg)
         opt = opt.lower()
         if opt in ['q', 'm']:
             return opt
         elif opt == 'r':
             print("RETRY....")
         else:
             print("INVALID INPUT ! PLEASE TRY AGAIN !!")
    def create(self):
        chkname_empty = False
        chkmob_empty = False
        if len(self.name.get()) == 0:
            chkname_empty = True
        if len(self.mobile.get()) == 0:
            chkmob_empty = True

        chk_name = valid.validName(self.name.get())
        chk_mob = valid.validMobile(self.mobile.get())

        if chkname_empty:
            tk.messagebox.showerror(title="INVALID NAME",
                                    message="NAME CANNOT BE EMPTY !")
        else:
            if chkmob_empty:
                tk.messagebox.showerror(title="INVALID MOBILE",
                                        message="MOBILE CANNOT BE EMPTY !")
            else:
                if not chk_name:
                    tk.messagebox.showerror(
                        title="INVALID NAME",
                        message="NAME SHOULD CONTAIN LETTERS ONLY !")
                else:
                    if not chk_mob:
                        tk.messagebox.showerror(
                            title="INVALID MOBILE",
                            message=
                            "MOBILE SHOULD BE NUMERIC !\n MOBILE SHOULD BE OF 10 DIGITS ONLY !!"
                        )

                    else:
                        self.cur.execute(
                            "select * from customers where mobile=:1",
                            (int(self.mobile.get()), ))
                        res = self.cur.fetchall()
                        if len(res) == 0:

                            self.cur.execute(
                                'insert into customers(name,mobile,gender) values(:1,:2,:3)',
                                (self.name.get(), int(
                                    self.mobile.get()), self.gender.get()))
                            self.cur.execute('commit')
                            tk.messagebox.showinfo(
                                title="SUCCESSFUL",
                                message="CUSTOMER CREATED SECCESSFULLY !")
                        else:
                            tk.messagebox.showerror(
                                title="INVALID CUSTOMER",
                                message="CUSTOMER ALREADY EXIST !")
 def displayOrder(self):
     self.cur.execute('select mobile from customers')
     res = self.cur.fetchall()
     chk = valid.validMobile(self.custid.get())
     if chk:
         chk2 = False
         for i in res:
             if str(i[0]) == self.custid.get():
                 chk2 = True
                 break
         if chk2:
             self.controller.destroy()
             show.CustomerDetailsOrder(self.empid, self.custid.get(), self.cur).mainloop()
         else:
             tk.messagebox.showerror(title = "INVALID MOBILE NUMBER", message = "CUSTOMER DOES NOT EXIST ! PLEASE TRY AGAIN !!")
     else:
         tk.messagebox.showerror(title = "INVALID INPUT", message = "INVALID MOBILE NUMBER ! PLEASE TRY AGAIN !!")
Beispiel #5
0
 def verify(self):
     chk = valid.validMobile(self.mobile.get())
     if chk:
         self.cur.execute("select * from customers where mobile=:1",
                          ((int(self.mobile.get())), ))
         res = self.cur.fetchall()
         if len(res) == 0:
             tk.messagebox.showerror(
                 title="INVALID MOBILE NUMBER",
                 message="CUSTOMER DOES NOT EXIST ! \n PLEASE TRY AGAIN !!")
         else:
             self.customerlogin()
     else:
         tk.messagebox.showerror(
             title="INVALID MOBILE",
             message=
             "MOBILE NUMBER SHOULD BE NUMERIC AND OF 10 DIGITS ONLY !")
def createCustomerAccount(cur):#TESTED
    #CREATES CUSTOMER ACCOUNT AND RETURN CUSTOMER-ID
    name, mob, gender = '','',''
    
    while(True):
        name = input("ENTER YOUR NAME : ")
        chk = valid.validName(name)
        if chk:
            break
        else:
            print("INVALID NAME ! PLEASE TRY AGAIN !!")
    
    cur.execute('select mobile from customers')
    res = cur.fetchall()
    lmob = []
    for tup in res:
        lmob.append(str(tup[0]))
    while(True):
        mob = input("ENTER MOBILE NUMBER : ")
        chk = valid.validMobile(mob)
        if chk:
            if mob in lmob :
                print("MOBILE NUMBER ALREADY EXISTS !!")
            else:
                break
        else:
            print("INVALID MOBILE NUMBER ! PLEASE TRY AGAIN !!")
    while(True):
        gender = input("ENTER GENDER AS MALE/FEMALE/OTHER or M/F/O : ")
        gender = gender.upper()
        if gender in ['MALE','FEMALE','OTHER','M','F','O']:
            if gender == 'M':
                gender = 'MALE'
            if gender == 'F':
                gender = 'FEMALE'
            if gender == 'O':
                gender = 'OTHER'
            break
        else:
            print("INVALID GENDER ! PLEASE TRY AGAIN !! ")
    cur.execute('insert into customers(name,mobile,gender) values(:1,:2,:3)',(name,mob,gender))
    cur.execute('commit')
    print("CUSTOMER ACCOUNT CREATED SUCCESSFULLY")
    return mob
 def verify(self, mobile, address, gender, oldmobile):
    
     chk1 = valid.validMobile(mobile)
     chk2 = True
     if chk1:
         
         self.cur.execute("select mobile from employees")
         res = self.cur.fetchall()
         if oldmobile == mobile:
             chk2 = True
         else:
             for i in res:
                 if str(i[0]) == mobile:
                     chk2 = False
                     break
         if chk2:
             self.cur.execute("update employees set mobile = :1,address = :2, gender = :3 where empid = :4",(mobile,address,gender,self.empid))
             self.cur.execute("commit")
             tk.messagebox.showinfo(title = "SUCCESS", message = "PROFILE UPDATED !")
         else:
             tk.messagebox.showerror(title = "FAILED", message = "MOBILE NUMBER ALREADY EXISTS !")
     else:
         tk.messagebox.showerror(title = "FAILED", message = "INVALID MOBILE NUMER !")
    def create(self):
        name = self.name.get()
        mobile = self.mobile.get()
        dob = self.dob.get()
        doj = self.doj.get()
        gender = self.gender.get()
        address = self.address.get()
        sal = self.salary.get()
        chk_sal = valid.validNumber(sal)
        passd = self.password.get()
        chk_pass = valid.validPassword(passd)

        chk_name = valid.validName(name)
        chk_dob = valid.validDate(dob)
        chk_doj = valid.validDate(doj)
        chk_mobile = valid.validMobile(mobile)

        empty_name = False
        empty_add = False
        empty_salary = False
        if len(name) == 0:
            empty_name = True
        if len(address) == 0:
            empty_add = True
        if len(sal) == 0:
            empty_salary = True
        if empty_name:
            tk.messagebox.showerror(title="INVALID NAME",
                                    message="NAME CANNOT BE EMPTY !")

        else:
            if empty_add:
                tk.messagebox.showerror(title="INVALID ADDRESS",
                                        message="ADDRESS CANNOT BE EMPTY !")
            else:
                if empty_salary:
                    tk.messagebox.showerror(title="INVALID SALARY",
                                            message="SALARY CANNOT BE EMPTY !")
                else:

                    if chk_name:
                        if chk_dob and chk_doj:
                            mon = [
                                '', 'January', 'February', 'March', 'April',
                                'May', 'June', 'July', 'August', 'September',
                                'October', 'November', 'December'
                            ]

                            a, b, c = dob.split('/')
                            dob = a + "-" + mon[int(b)] + "-" + c
                            a, b, c = doj.split('/')
                            doj = a + "-" + mon[int(b)] + "-" + c

                            if chk_mobile:
                                chk2 = False
                                self.cur.execute(
                                    "select mobile from employees")
                                res = self.cur.fetchall()

                                for i in res:
                                    if str(i[0]) == mobile:
                                        chk2 = False
                                        break
                                    chk2 = True

                                if chk2:
                                    if chk_sal:
                                        if chk_pass:
                                            self.cur.execute(
                                                "select max(empid) from employees"
                                            )
                                            res = self.cur.fetchall()
                                            employeeid = res[0][0] + 1
                                            self.cur.execute(
                                                "insert into employees(mobile,address,gender,dob,doj,name,password,salary,designation,empid,status) values(:1,:2,:3,:4,:5,:6,:7,:8,:9,:10,:11)",
                                                (int(mobile), address,
                                                 gender, dob, doj, name, passd,
                                                 int(sal),
                                                 self.designation.get(),
                                                 employeeid, "ACTIVE"))
                                            self.cur.execute("commit")
                                            st = "EMPLOYEE CREATED!\n ID : " + str(
                                                employeeid
                                            ) + " \nPASWORD : " + passd
                                            tk.messagebox.showinfo(
                                                title="SUCCESS", message=st)
                                        else:
                                            tk.messagebox.showerror(
                                                title="INVALID PASSWORD",
                                                message=
                                                "PASSSWORD MUST BE OF ATLEAST 8 CHARACTERS !\n MUST CONTAIN ATLEAST 1 DIGIT!! \n MUST CONTAIN ATLEAST 1 SPECIAL CHARACTER!!! \n MUST CONTAIN ATLEAST 1 ALPHABET!!!! \n"
                                            )
                                    else:
                                        tk.messagebox.showerror(
                                            title="INVALID SALARY",
                                            message=
                                            "SALARY SHOULD BE NUMERIC ONLY !")
                                else:
                                    tk.messagebox.showerror(
                                        title="INVALID MOBILE",
                                        message="MOBILE NUMBER ALREADY EXISTS !"
                                    )

                            else:
                                tk.messagebox.showerror(
                                    title="INVALID MOBILE",
                                    message=
                                    "MOBILE SHOULD BE NUMERIC AND OF 10 DIGITS ONLY !"
                                )

                        else:
                            tk.messagebox.showerror(
                                title="INVALID DATE",
                                message=
                                "DATE SHOULD BE VALID AND FORMAT - dd/mm/yyyy !"
                            )

                    else:
                        tk.messagebox.showerror(
                            title="INVALID NAME",
                            message="NAME SHOULD BE ONLY OF CHARACTERS !")
def takeOrder(empid, cur):  #TESTED
    #INTERFACE TO WORK WITH OTHER FUNCTIONS
    global orders, cust
    msg = """
    ENTER : vm     =======> VIEW MENU
            vo     =======> VIEW ORDER
            create =======> CREATE CUSTOMER ACCOUNT
            cancel =======> CANCEL ORDER
            last   =======> REMOVE LAST PRODUCT IN OPTION
            done   =======> DONE ORDER
            print  =======> PRINT RECEIPT
            next   =======> NEXT ORDER
            q      =======> GO BACK
            m      =======> MAIN MENU
    
    """
    print(msg)
    print(
        "NOTE : YOU COULD TYPE THESE COMMANDS ANYWHERE/ANYTIME WHILE TAKING ORDER"
    )

    #print("HERE IS THE TODAY'S MENU")
    #view.viewMenuAll('ALL', cur)needs to be changed

    id = ''
    while (True):  # GET CUSTOMER ID
        print("ENTER CUSTOMER ID : ")
        getCustomers(cur)
        id = input()
        id = id.lower()
        if id not in [
                'vm', 'vo', 'create', 'cancel', 'last', 'done', 'print',
                'next', 'q', 'm'
        ]:
            if valid.validMobile(id):
                if id in cust:
                    break
                else:
                    print("CUSTOMER DOESN'T EXISTS !")
                    print(
                        "EITHER CREATE ACCOUNT OR RE-ENTER THE CORRECT ID !!")
                    print("\n\n")
            else:
                print("NOT A VALID MOBILE NUMBER ! ")
                print("PLEASE ENTER A VALID MOBILE NUMBER !!")
                print("\n\n")
        else:
            if id == 'vm':
                showHalfMenu(cur)
            elif id in ['vo', 'last', 'done', 'print', 'next']:
                print("NO CURRENT ORDER TO PERFORM ACTION!")
                print("\n\n")
            elif id == 'create':
                create.createCustomerAccount(cur)
                print("\n\n")
            elif id == 'cancel':
                print("ORDER CANCELLED ! PLAESE START AGAIN !!")
                print("\n\n")
                return 'cancel'
            else:
                return id
    print("\n\n")
    print("ENTER ORDER AS : ")
    print("PRODUCT_ID/NAME/SHORTCUT  SIZE(S/M/L) QUANTITY ")
    cur.execute('select prid,name,shortcut from menu')
    res = cur.fetchall()
    lotup = []  #LOTUP TO CHECK FOR NAME INPRID,SHORTCUT,NAME
    for tup in res:
        a, b, c = tup[0], tup[1], tup[2]
        lotup.append((str(a), str(b).upper(), str(c)))

    print("ENTER 'done' to complete ORDER")
    while (True):  #TAKE ORDERS
        prod = input()
        prod = prod.lower()
        if prod not in [
                'vm', 'vo', 'create', 'cancel', 'last', 'done', 'print',
                'next', 'q', 'm'
        ]:
            prod = prod.split()
            if len(prod) < 3:
                print("ORDER SHOULD BE ATLEAST 3 PARAMETERS ")
            else:
                if len(prod) > 3:
                    namelist = prod[:-2]
                    size = prod[-2]
                    quan = prod[-1]
                    name = ' '.join(namelist)
                    name = name.upper()
                else:
                    name, size, quan = prod
                    name = name.upper()
                chk = False
                pizzaname = ''
                for i in lotup:
                    #print(i)
                    if name in i:

                        chk = True
                        pizzaname = i[1]

                        break
                if not chk:
                    print("NO SUCH PRODUCT_ID/NAME/SHORTCUT EXISTS !")
                    print("PLEASE TRY AGAIN !!")
                    print("\n\n")
                else:
                    if size in ['s', 'm', 'l']:
                        if valid.validNumber(quan):
                            tup = (pizzaname, size, quan)
                            orders.append(tup)

                        else:
                            print("QUANTITY SHOULD BE A NUMBER !")
                            print("PLEASE TRY AGAIN !!")
                            print("\n\n")

                    else:
                        print("NOT A VALID SIZE !")
                        print("PLEASE TRY AGAIN !!")
                        print("\n\n")
        else:
            if prod == 'vm':
                showHalfMenu(cur)
                print("\n\n")
            elif prod == 'vo':
                viewOrder()
                print("\n\n")
            elif prod == 'create':
                print("CUSTOMER CANOT BE CREATED IN BETWEEN ORDER !!")
                print("\n\n")

            elif prod == 'last':
                removeLast()

            elif prod == 'done':
                if len(orders) > 0:
                    break
                else:
                    print("NO ORDER ! TRY AGAIN !!")
                    print()

            elif prod == 'print':
                print("FIRST CONFIRM THE ORDER !")
                print("\n\n")
            elif prod == 'next':
                print("EITHER CONFIRM OR CANCEL ORDER TO GO TO NEXT !")
                print("\n\n")
            elif prod == 'cancel':
                print("ORDER CANCELLED ! PLAESE START AGAIN !!")
                print("\n\n")
                return prod
            else:
                return prod

    while (True):  # FOR ORDER CONFIRMATION
        print("ORDER IS : ")
        viewOrder()
        print("ENTER 'done' to CONFIRM ")
        print("NOTE : ONCE CONFIRMED ORDER CANNOT BE CANCELLED ")
        ch = input()
        ch = ch.lower()
        if ch in [
                'vm', 'vo', 'create', 'cancel', 'last', 'done', 'print',
                'next', 'q', 'm'
        ]:
            if ch == 'vm':
                showHalfMenu(cur)
                print("\n\n")
            elif ch == 'vo':
                viewOrder()
                print("\n\n")
            elif ch == 'create':
                print("CUSTOMER CANNOT BE CREATED IN BETWEEN ORDER !!")
                print("\n\n")

            elif ch == 'last':
                removeLast()

            elif ch == 'done':
                break

            elif ch == 'print':
                print("FIRST CONFIRM THE ORDER !")
                print("\n\n")
            elif ch == 'next':
                print("EITHER CONFIRM OR CANCEL ORDER TO GO TO NEXT !")
                print("\n\n")
            elif ch == 'cancel':
                print("ORDER CANCELLED ! PLEASE START AGAIN !!")
                print("\n\n")
                return ch
            else:
                return ch
        else:
            print("INVALID INPUT ! PLEASE TRY AGAIN !!")
    cur.execute('select points from customers where mobile=:1', (int(id), ))
    res = cur.fetchall()
    points = res[0][0]
    pointsredeem = False
    if points > 0:
        while (True):
            print("CUSTOMER HAVE : ", points, " POINTS")
            print("ENTER 'done' or 'yes/y' to REDEEM ")
            print("ENTER 'no/n' to NOT REDEEM")

            ch = input()
            ch = ch.lower()
            if ch in [
                    'vm', 'vo', 'create', 'cancel', 'last', 'done', 'print',
                    'next', 'yes', 'no', 'y', 'n', 'q', 'm'
            ]:
                if ch == 'vm':
                    view.viewMenuAll('ALL', cur)
                    print("\n\n")
                elif ch == 'vo':
                    viewOrder()
                    print("\n\n")
                elif ch == 'create':
                    print("CUSTOMER CANNOT BE CREATED IN BETWEEN ORDER !!")
                    print("\n\n")

                elif ch == 'last':
                    print("CONFIRMED ORDER CANNOT BE CHANGED !!")

                elif ch in ['done', 'yes', 'y']:
                    pointsredeem = True
                    break
                elif ch in ['no', 'n']:
                    break

                elif ch == 'print':
                    print("FIRST COMPLETE THE ORDER !")
                    print("\n\n")
                elif ch == 'next':
                    print(" FIRST COMPLETE THE ORDER !")
                    print("\n\n")
                elif ch == 'cancel':
                    print("ORDER CANNOT BE CANCELLED !!")
                    print("\n\n")

                else:
                    print("YOU CANNOT GO BACK ! UNTIL ORDER IS COMPLETED !!")
                    print("\n\n")
            else:
                print("INVALID INPUT ! PLEASE TRY AGAIN !!")

    bill = generateBillandSave(int(id), empid, pointsredeem, cur)
    print("BILL IS :")
    print(bill)
    print("\n")
    while (True):  #PRINTING ORDER
        print(
            "ENTER 'print' to PRINT THE ORDER , 'next'/'done' to COMPLETE THE ORDER"
        )
        ch = input()
        ch = ch.lower()
        if ch in [
                'vm', 'vo', 'create', 'cancel', 'last', 'done', 'print',
                'next', 'q', 'm'
        ]:
            if ch == 'vm':
                showHalfMenu(cur)
            elif ch == 'vo':
                viewOrder()
            elif ch == 'create':
                create.createCustomerAccount(cur)
                print("\n\n")
            elif ch == 'last':
                print("ORDER CONFIRMED ! CANNOT BE CHANGED !!")
                print("\n\n")
            elif ch == 'done':
                break
            elif ch == 'cancel':
                print("ORDER COMPLETED SUCCESSFULLY !!")
                print("ORDER CANNOT BE CANCELLED ! RETURN BACK !!")
                return ch
            elif ch == 'next':
                print("ORDER COMPLETED SUCCESSFULLY !!")
                return ch
            elif ch == 'print':
                printBill(bill)
                print()
                break
            else:
                return ch
        else:
            print("ORDER COMPLETED SUCCESSFULLY !!")
            print("INVALID INPUT ! PLEASE TRY AGAIN !!")
    while (True):  #GOING NEXT
        m = """
    ENTER : 
            next   =======> NEXT ORDER
            
            q      =======> GO BACK
            m      =======> MAIN MENU
    
    """
        print(m)
        ch = input()
        ch = ch.lower()
        if ch in [
                'vm', 'vo', 'create', 'cancel', 'last', 'done', 'print',
                'next', 'q', 'm'
        ]:
            if ch == 'vm':
                showHalfMenu(cur)
            elif ch == 'vo':
                viewOrder()
            elif ch == 'create':
                create.createCustomerAccount(cur)
                print("\n\n")
            elif ch == 'last':
                print("ORDER CONFIRMED ! CANNOT BE CHANGED !!")
                print("\n\n")
            elif ch == 'done':
                return 'q'
            elif ch == 'cancel':

                return 'q'
            elif ch == 'next':
                return ch
            else:
                return ch
        else:
            print("INVALID INPUT ! PLEASE TRY AGAIN !!")
def createEmployeeAccount(cur):#TESTED
    #CREATES EMPLOYEE ACCOUNT BY ADMIN 
    while(True):
        doj = datetime.datetime.now().date()
        mon = ['','January','February','March','April','May','June','July','August','September','October','November','December']
        a,b,c = re.split("[./-]",str(doj))
        doj = c+"/"+mon[int(b)]+"/"+a
        #print(doj)
        empid, name, mob, address, dob, password, salary, designation = '','','','','','','',''
        status = 'ACTIVE'
        cur.execute('select max(empid) from employees')
        res = cur.fetchall()
        empid = res[0][0] + 1
        while(True):
            name = input("ENTER EMPLOYEE NAME : ")
            chk = valid.validName(name)
            if chk:
                break
            else:
                print("INVALID NAME ! PLEASE TRY AGAIN !!")
        
        cur.execute('select mobile from employees')
        res = cur.fetchall()
        lmob = []
        for tup in res:
            lmob.append(str(tup[0]))
        while(True):
            mob = input("ENTER MOBILE NUMBER : ")
            chk = valid.validMobile(mob)
            if chk:
                if mob in lmob :
                    print("MOBILE NUMBER ALREADY EXISTS !!")
                else:
                    mob = int(mob)
                    break
            else:
                print("INVALID MOBILE NUMBER ! PLEASE TRY AGAIN !!")
        while(True):
            gender = input("ENTER GENDER AS MALE/FEMALE/OTHER or M/F/O : ")
            gender = gender.upper()
            if gender in ['MALE','FEMALE','OTHER','M','F','O']:
                if gender == 'M':
                    gender = 'MALE'
                if gender == 'F':
                    gender = 'FEMALE'
                if gender == 'O':
                    gender = 'OTHER'
                break
            else:
                print("INVALID GENDER ! PLEASE TRY AGAIN !! ")
        while(True):
            address = input("ENTER ADDRESS : ")
            if len(address)!=0:
                break
            else:
                print("ADDRESS CANNOT BE EMPTY ! PLEASE TRY AGAIN !!")
        while(True):
            dob = input("ENTER DATE OF BIRTH dd/mm/yyyy : ")
            chk = valid.validDate(dob)
            if chk:
                mon = ['','January','February','March','April','May','June','July','August','September','October','November','December']
                a,b,c = re.split("[./-]",dob)
                dob = a+"/"+mon[int(b)]+"/"+c
                break
            else:
                print("INVALID DATE OF BIRTH ! PLEASE TRY AGAIN !!")
        while(True):
            salary = input("ENTER SALARY : ")
            chk = valid.validSalary(salary)
            if chk:
                salary = int(salary)
                break
            else:
                
                print("INVALID SALARY ! PLEASE TRY AGAIN !!")
        while(True):
            password = input("ENTER PASSWORD : or PRESS 'd' for DEFAULT PASSWORD GENERATION :: ")
            if password in ['d','D']:
                password = name + "1234" + "!@#$"
                break
            else:
                chk = valid.validPassword(password)
                if chk:
                    break
                else:
                    print("INVALID PASSWORD ! PLEASE TRY AGAIN !!")
        while(True):
            designation = input("ENTER DESIGNATION 'ADMIN/MANAGER/CASHIER' or 'A/M/C' or '1/2/3' ")
            designation = designation.upper()
            if designation in ['ADMIN','MANAGER','CASHIER','A','M','C','1','2','3']:
                if designation in ['A','1']:
                    designation = 'ADMIN'
                if designation in ['M','2']:
                    designation = 'MANAGER'
                if designation in ['C','3']:
                    designation = 'CASHIER'
                break
            else:
                print("INVALID INPUT ! PLEASE TRY AGAIN !!")
    
        cur.execute('insert into employees(empid,name,mobile,address,gender,dob,status,password,salary,designation,doj) values(:1,:2,:3,:4,:5,:6,:7,:8,:9,:10,:11)',(empid,name,mob,address,gender,dob,status,password,salary,designation,doj))
        cur.execute('commit')
        print("EMPLOYEE CREATED SUCCESSFULLY ")
        msgoption = """
                ENTER : 
                r =======> RETRY
                d =======> DISPLAY
                q =======> GO BACK
                m =======> GO TO MAIN MENU
                """
        while(True):
                ch = input(msgoption)
                ch = ch.lower()
                if ch in ['r','d','q','m']:
                    if ch == 'd':
                        view.viewDetailsEmployee(empid, cur)
                        while(True):
                            msg = """
                                ENTER : 
                                r =======> RETRY
                                q =======> GO BACK
                                m =======> GO TO MAIN MENU
                                """
                            c = input(msg)
                            c = c.lower()
                            if c in ['q','m']:
                                return c
                            elif c == 'r':
                                ch = 'r'
                                break
                            else:
                                print("INVALID INPUT ! PLEASE TRY AGAIN !!")
                    if ch == 'r':
                        break
                    if ch in ['q','m']:
                        return ch
                else:
                    print("INAVLID INPUT ! PLEASE TRY AGAIN !!")
Beispiel #11
0
def custLogin(cur):
    global welcome, thankyou
    while (True):
        print(welcome)
        print("WELCOME CUSTOMER")
        mob = input("PLEASE ENTER YOUR REGISTERED MOBILE NUMBER : ")
        chk = valid.validMobile(mob)
        if chk:
            cur.execute("select * from customers where mobile=:1", (mob, ))
            res = cur.fetchall()
            if len(res) == 0:
                print(
                    "CUSTOMER MOBILE NUMBER NOT REGISTERED ! PLEASE TRY AGAIN !!"
                )
            else:
                res = res[0]
                while (True):
                    print("WELCOME ", res[0])
                    msg = """
                    CUSTOMER ACCOUNT
                    press : 
                    1 =======> VIEW MENU
                    2 =======> VIEW YOUR LAST ORDER
                    3 =======> VIEW YOUR ORDER HISTORY
                    4 =======> VIEW YOUR POINTS
                    5 =======> VIEW YOUR ACCOUNT DETAILS
                    
                    x =======> LOG OUT
                    """
                    msg2 = """
                    press : 
                   
                    q =======> GO BACK 
                    x =======> LOG OUT
                    """
                    ch = input(msg)
                    ch = ch.lower()
                    if ch in ['1', '2', '3', '4', '5', 'x']:
                        if ch == '1':
                            order.showHalfMenu(cur)
                            while (True):
                                choice = input(msg2)
                                choice = choice.lower()
                                if choice == 'q':
                                    break
                                elif choice == 'x':
                                    return choice
                                else:
                                    print(
                                        "INVALID INPUT ! PLEASE TRY AGAIN !!")

                        elif ch == '2':
                            view.viewOrdersCustomerLatest(mob, cur)
                            while (True):
                                choice = input(msg2)
                                choice = choice.lower()
                                if choice == 'q':
                                    break
                                elif choice == 'x':
                                    return choice
                                else:
                                    print(
                                        "INVALID INPUT ! PLEASE TRY AGAIN !!")
                        elif ch == '3':
                            view.viewOrdersCustomer(mob, cur)
                            while (True):
                                choice = input(msg2)
                                choice = choice.lower()
                                if choice == 'q':
                                    break
                                elif choice == 'x':
                                    return choice
                                else:
                                    print(
                                        "INVALID INPUT ! PLEASE TRY AGAIN !!")
                        elif ch == '4':
                            view.viewPoints(mob, cur)
                            while (True):
                                choice = input(msg2)
                                choice = choice.lower()
                                if choice == 'q':
                                    break
                                elif choice == 'x':
                                    return choice
                                else:
                                    print(
                                        "INVALID INPUT ! PLEASE TRY AGAIN !!")
                        elif ch == '5':
                            view.viewDetailsCustomer(mob, cur)
                            while (True):
                                choice = input(msg2)
                                choice = choice.lower()
                                if choice == 'q':
                                    break
                                elif choice == 'x':
                                    return choice
                                else:
                                    print(
                                        "INVALID INPUT ! PLEASE TRY AGAIN !!")
                        else:
                            return ch

                    else:
                        print("INVALID INPUT ! PLEASE TRY AGAIN !!")
                    print("\n", line, "\n")

        else:
            print("INVALID MOBILE NUMBER ! PLEASE TRY AGAIN !!")
        while (True):
            msg = """
            
    press : 
    r =======> RETRY
    x =======> EXIT
            
            """
            ch = input(msg)
            ch = ch.lower()
            if ch == 'r':
                break
            elif ch == 'x':
                return ch
            else:
                print("INVALID INPUT ! PLEASE TRY AGAIN !!")