Example #1
0
	def validate(self, event=None):
		#Dictionary for list of users (username : password)
		userid = {}
		users = {}
		role = {}
		keys = CRUD.retrieve_employee()

		#Saves the input for username and pasword
		username = self.userName.get()
		Pass = self.password.get()

		for key in keys:
			if (username == key[1]):
				if (Pass == key[2]):
					self.promptWindow.destroy()

					hid = util.history()
					print(hid)
					_time = datetime.now().strftime("%H:%M:%S")
					_date = date.today().strftime("%m/%d/%y")
					_date = util.date_split(_date)


					CRUD.add_history(str(hid), 'sign', key[0], 'logged in ' + str(username), _date, _time)
					home = window(key)
					home.root.mainloop()
				else:
					self.label3.configure(text="Incorrect Password")		# Displays error if incorrect password
					self.label3.grid(column=0, row=6)
		try:	
			self.label3.configure(text="Username does not exist")		# Displays error nonexistent username
			self.label3.grid(column=0, row=6)		
		except TclError:
			pass
Example #2
0
    def sign_out(self):
        hid = util.history()

        _time = datetime.now().strftime("%H:%M:%S")
        _date = date.today().strftime("%m/%d/%y")
        _date = util.date_split(_date)

        CRUD.add_history(str(hid), 'sign', self.Page_tracker.user[0],
                         'logged out ' + str(self.Page_tracker.user[1]), _date,
                         _time)
Example #3
0
    def OnDoubleClick(self, event):

        region = self.Table_.tree.identify("region", event.x, event.y)
        if region == "heading":
            columns = ('Order ID', 'Customer', 'Items', 'Amount', 'Date',
                       'Time')
            try:
                for col in columns:
                    self.Table_.tree.heading(col, text=col, command=lambda _col=col: \
                                self.treeview_sort_column(self.Table_.tree, _col, False))
            except TclError:
                columns = ('historyID', 'Action Type', 'User ID', 'Action',
                           'Date', 'Time')
                for col in columns:
                    self.Table_.tree.heading(col, text=col, command=lambda _col=col: \
                                self.treeview_sort_column(self.Table_.tree, _col, False))
                return

        selected_item = self.Table_.tree.selection()  ## get selected item
        info = self.Table_.tree.item(selected_item)['values']

        name = ''
        index = 0

        if info[1] == 'order' or info[1] == 'sign' or info[
                1] == 'inventory' or info[1] == 'customer' or info[1] == 'void':
            messagebox.showinfo("message", str(info[3]))
            return
        for i in range(0, len(self.list_or)):
            if (int(info[0]) == int(self.list_or[i][0])):
                name = self.list_or[i][7]
                index = i
                break

        row = self.Table_.tree.item(selected_item)['values'][0]

        if messagebox.askyesno("message", "Void order of\n" + name + "?"):
            if (self.tracker.bin[8] == '0'):
                messagebox.showwarning(
                    "showwarning", "Your account doesn't have this privilege")
                return
            if messagebox.askyesno("message", "Are you sure?"):

                util.void_order(str(self.list_or[index][0]))
                util.delete_history_entry(str(self.list_or[index][6]))
                self.list_or.pop(index)
                _time = datetime.now().strftime("%H:%M:%S")
                _date = date.today().strftime("%m/%d/%y")
                _date = util.date_split(_date)
                hid = util.history()

                CRUD.add_history(str(hid), 'void', 1, 'VOIDED order' + name,
                                 _date, _time)
                self.Table_.tree.delete(selected_item)
Example #4
0
    def confirm(self, type):
        if(self.tracker.bin[1] == '0'):
            messagebox.showwarning("showwarning", "Your account doesn't have this privilege")
            return
        pid=self.id_e.get()
        name=self.itemname_e.get()
        itemcat=self.item_cate.get()
        price=self.enter_prce.get()
        wsprice=self.enter_WSprce.get()
        minws=self.enter_minWSe.get()
        stock=self.current_ste.get()  

        hid = util.history()
        _time = datetime.now().strftime("%H:%M:%S")
        _date = date.today().strftime("%m/%d/%y")
        _date = util.date_split(_date)
        jelly =  "ID " + str(pid) + "\n " + str(name) + "\n " +str(itemcat) + "\nReg price: P" + str(price) +"\nWholesale price: P" + str(wsprice) + "\nMinimum wholesale: "+ str(minws) + "\nStock : " + str(stock)
        
        if (type == 1):
            #self.prompt_ = confirm_inv(1, self.body, self.labels, self.root)
            #if (self.prompt_.confirm_bool==TRUE):
            if messagebox.askyesno("message", "Add Product?"):
                try:
                    CRUD.add_product(pid, name, itemcat, price, wsprice,
                                    minws, stock)
                except sqlite3.IntegrityError:
                    messagebox.showwarning("showwarning", "Can't add, Product ID already exist")
                    return
                #insert = [pid, name, itemcat, price, wsprice, minws, stock]
                self.Table_.tree.insert('', '0', values=(pid, name, itemcat, price, wsprice, minws, stock))
                jelly = "Added product\n" +jelly
                CRUD.add_history(str(hid), 'inventory', self.tracker.user[0], jelly, _date, _time)
                # self._list_inv.append(insert)
                # self.invtable.set(self._list_inv)
            else:
                pass
        else:
            if messagebox.askyesno("message", "Confirm change?"):
                entryIndex = self.Table_.tree.index(self.Table_.tree.focus())
                CRUD.update_product(pid, name, itemcat, price, wsprice,
                            minws, stock)
                self.Table_.tree.delete(self.Table_.tree.selection())
                jelly = "Updated product\n" + jelly
                CRUD.add_history(str(hid), 'inventory', self.tracker.user[0], jelly, _date, _time)
                self.Table_.tree.insert('', entryIndex, values=(pid, name, itemcat, price, wsprice, minws, stock))
            else:
                pass
            pass
Example #5
0
    def delete(self):
        if(self.tracker.bin[1] == '0'):
            messagebox.showwarning("showwarning", "Your account doesn't have this privilege")
            return
        selected_item = self.Table_.tree.selection() ## get selected item
        print(selected_item)
        row=self.Table_.tree.item(selected_item)['values']
        if messagebox.askyesno("message", "Delete Product?"):
            CRUD.delete_product(str(row[0]))
            self.Table_.tree.delete(selected_item)

            _time = datetime.now().strftime("%H:%M:%S")
            _date = date.today().strftime("%m/%d/%y")
            _date = util.date_split(_date)

            hid = util.history()
            jelly = " Deleted Product\n" + "ID " + str(row[0]) + "\n " + str(row[1]) + "\n " +str(row[2])+"\nReg price: P" +str(row[3]) +"\nWholesale price: P" + str(row[4]) +"\nMinimum wholesale: "+ str(row[5]) + "\nStock : " + str(row[6])
            CRUD.add_history(str(hid), 'inventory', self.tracker.user[0], jelly, _date, _time)
        else:
            pass
Example #6
0
    def place_order(self, Page_tracker):
        if not self.order_list:
            messagebox.showwarning("showwarning", "No Item listed") 
            print("No item")
            return

        _time = datetime.now().strftime("%H:%M:%S")
        _date = date.today().strftime("%m/%d/%y")
        _date = util.date_split(_date)
        sdetails={"id": self.csid, "date": _date, "time": _time}

        jelly_items=''
        for item in self.order_list:
            jelly_items=jelly_items+item+', '    

        history_text = []
        total = 0

        self.Tracker=quantity_change(False, 0, 0)
        #place_order(1, self.root, self.body, self.Tracker)

        if messagebox.askyesno("message", "Confirm order?"):
            try:
                for i in range(0, len(self.order_list)):
                    self.ids[0] = self.ids[0] + 1
                    util.focus_item(0, self.Table_)
                    row=self.Table_.tree.item(self.Table_.tree.selection())['values']
                    pn = self.order_list.pop(0)

                    history_text.append(pn + ' (' + str(row[1]) + ') - P' + str(row[3]))
                    total = total + int(row[3])
                    _order_cred = order_cred(self.ids, row, pn, sdetails, self._userID)
                    util.update_order(_order_cred)
                    self.Table_.tree.delete(self.Table_.tree.selection())
    
                jelly=''
                
                for item in history_text:
                    jelly=(jelly + item + '\n')

                if sdetails['id'] != -1:
                    jelly = (self.c_details['customerFirst'] + ' ' + 
                            self.c_details['customerLast'] + '\n' + jelly)
                else:
                     jelly = ('Short Order \n'+ jelly )

                
                
                jelly = ( str(self.ids[1]) + '\n' + jelly + jelly_items[:-2]  +'\n' + str(total) )
                hid = util.history()
                CRUD.add_history(str(hid), 'order', self._userID, jelly, _date, _time)


                for widget in self.body.winfo_children():
                    widget.destroy()
                from Home import home_page
                Page_tracker.pages=[]
                Page_tracker.pages.append(-1)
                self.home_ = home_page(self.root, self.body, 'Home', Page_tracker)
            except IndexError:
                print("No item")