Esempio n. 1
0
 def populate(self, table, first=False):
     if first:
         if not table:
             logTC("Table contains no information")
     if first:
         self.wholeTable = table
     self.currentTable = table
     self.idLB.delete(0, tk.END)
     self.fnameLB.delete(0, tk.END)
     self.mnameLB.delete(0, tk.END)
     self.lnameLB.delete(0, tk.END)
     self.muniLB.delete(0, tk.END)
     self.stateLB.delete(0, tk.END)
     self.cardTimesLB.delete(0, tk.END)
     self.statusLB.delete(0, tk.END)
     if not table:
         pass
     else:
         for record in table:
             self.idLB.insert(tk.END, record[0])
             self.fnameLB.insert(tk.END, record[1])
             self.mnameLB.insert(tk.END, record[2])
             self.lnameLB.insert(tk.END, record[3])
             self.muniLB.insert(tk.END, record[4])
             self.stateLB.insert(tk.END, record[5])
             dates = multiParse(record[6])
             times = len(dates)
             self.cardTimesLB.insert(tk.END, times)
             if not record[7]:
                 self.statusLB.insert(tk.END, ' ')
             else:
                 self.statusLB.insert(tk.END, record[7])
Esempio n. 2
0
    def populate(self):
        logTC("Populating fields...")
        self.idText.insert(0, self.dat[0])
        self.fnameText.insert(0, self.dat[1])
        self.mnameText.insert(0, self.dat[2])
        self.lnameText.insert(0, self.dat[3])
        self.muniText.insert(0, self.dat[4])
        self.stateOptionsVar.set(self.dat[5])
        self.cardTimesText.insert(0, len(multiParse(self.dat[6])))
        self.statusOptionsVar.set(self.dictStatusOptions[self.dat[7]])
        if self.dat[7] is not 0:
            if not self.dat[8]:
                self.bandateText.insert(0, "")
            else:
                self.bandateText.insert(0, self.dat[8])
            if not self.dat[9]:
                self.expdateText.insert(0, "")
            else:
                self.expdateText.insert(0, self.dat[9])
            if not self.dat[10]:
                self.barcodeText.insert(0, "")
            else:
                self.barcodeText.insert(0, self.dat[10])
            if not self.dat[11]:
                self.reasonText.insert(1.0, "")
            else:
                self.reasonText.insert(1.0, self.dat[11])
        else:
            self.statusOptionsVar.set(self.statusOptions[0])
        if not self.dat[12]:
            self.aiText.insert(1.0, "")
        else:
            self.aiText.insert(1.0, self.dat[12])
        

        self.idText.configure(state=tk.DISABLED)
        self.fnameText.configure(state=tk.DISABLED)
        self.mnameText.configure(state=tk.DISABLED)
        self.lnameText.configure(state=tk.DISABLED)
        self.muniText.configure(state=tk.DISABLED)
        self.stateOptionsMenu.configure(state=tk.DISABLED)
        self.cardTimesText.configure(state=tk.DISABLED)
        self.statusOptionsMenu.configure(state=tk.DISABLED)
        self.bandateText.configure(state=tk.DISABLED)
        self.expdateText.configure(state=tk.DISABLED)
        self.barcodeText.configure(state=tk.DISABLED)
        self.reasonText.configure(state=tk.DISABLED)
        self.aiText.configure(state=tk.DISABLED)
Esempio n. 3
0
    def __init__(self, AdvSearchWin):
        self.fulltable = getAll("patrons")
        self.searchedtable = []

        self.posdict = {
            "ID Number": 0,
            "First Name": 1,
            "Middle Name": 2,
            "Last Name": 3,
            "Any part of the Name": -1,
            "Municipality": 4,
            "State": 5,
            "Number of Visitor Cards": 6,
            "Status": 7,
        }
        for record in self.fulltable:

            if AdvSearchWin.numberSelectorVar.get() == "Is Equal To":
                if AdvSearchWin.numberOptionVar.get() == "Number of Visitor Cards":
                    if len(multiParse(record[self.posdict[AdvSearchWin.numberOptionVar.get()]])) == int(
                        AdvSearchWin.numberEntryVar.get()
                    ):
                        self.searchedtable.append(record)
                else:
                    if record[self.posdict[AdvSearchWin.numberOptionVar.get()]] == int(
                        AdvSearchWin.numberEntryVar.get()
                    ):
                        self.searchedtable.append(record)

            if AdvSearchWin.numberSelectorVar.get() == "Is Greater Than":
                if AdvSearchWin.numberOptionVar.get() == "Number of Visitor Cards":
                    if len(multiParse(record[self.posdict[AdvSearchWin.numberOptionVar.get()]])) > int(
                        AdvSearchWin.numberEntryVar.get()
                    ):
                        self.searchedtable.append(record)
                else:
                    if record[self.posdict[AdvSearchWin.numberOptionVar.get()]] > int(
                        AdvSearchWin.numberEntryVar.get()
                    ):
                        self.searchedtable.append(record)

            if AdvSearchWin.numberSelectorVar.get() == "Is Less Than":
                if AdvSearchWin.numberOptionVar.get() == "Number of Visitor Cards":
                    if len(multiParse(record[self.posdict[AdvSearchWin.numberOptionVar.get()]])) < int(
                        AdvSearchWin.numberEntryVar.get()
                    ):
                        self.searchedtable.append(record)
                else:
                    if record[self.posdict[AdvSearchWin.numberOptionVar.get()]] < int(
                        AdvSearchWin.numberEntryVar.get()
                    ):
                        self.searchedtable.append(record)

            if AdvSearchWin.numberSelectorVar.get() == "Is Greater Than Or Equal To":
                if AdvSearchWin.numberOptionVar.get() == "Number of Visitor Cards":
                    if len(multiParse(record[self.posdict[AdvSearchWin.numberOptionVar.get()]])) >= int(
                        AdvSearchWin.numberEntryVar.get()
                    ):
                        self.searchedtable.append(record)
                else:
                    if record[self.posdict[AdvSearchWin.numberOptionVar.get()]] >= int(
                        AdvSearchWin.numberEntryVar.get()
                    ):
                        self.searchedtable.append(record)

            if AdvSearchWin.numberSelectorVar.get() == "Is Less Than Or Equal To":
                if AdvSearchWin.numberOptionVar.get() == "Number of Visitor Cards":
                    if len(multiParse(record[self.posdict[AdvSearchWin.numberOptionVar.get()]])) <= int(
                        AdvSearchWin.numberEntryVar.get()
                    ):
                        self.searchedtable.append(record)
                else:
                    if record[self.posdict[AdvSearchWin.numberOptionVar.get()]] <= int(
                        AdvSearchWin.numberEntryVar.get()
                    ):
                        self.searchedtable.append(record)

            if AdvSearchWin.nameOptionBoxVar.get():
                pass

            if AdvSearchWin.statusOptionBoxVar.get():
                pass

        print self.searchedtable
Esempio n. 4
0
    def __init__(self, primary, sub, geo="440x400"):
        self.primary = primary
        self.ew = tk.Toplevel(sub)
        self.ew.protocol("WM_DELETE_WINDOW", self.terminate)
        self.ew.geometry(geo)
        self.ew.wm_title("Issue Visitor Pass?")
        self.ew.focus_set()
        self.ew.grab_set()
        self.dates = []
        
        if self.primary.arr[7] in ("BLOCKED", "BARRED"):
            line1 = self.primary.fnameVar.get() + " " + self.primary.lnameVar.get() + " is " + self.primary.arr[7] + " and should NOT get a visitor pass."

            line2 = "Do you still want to issue a visitor pass for " + getNow() + "?"

            line3 = ""
        elif not self.primary.arr[7]:
            self.dates = multiParse(self.primary.arr[6])
            oneperiodago = Date(getNow()).dateobj - datetime.timedelta(days=Config.visitorcardperiod)
            oneperiodago = Date(str(oneperiodago.month) + '-' + str(oneperiodago.day) + '-' + str(oneperiodago.year))
            relevantdates = []
            for date in self.dates:
                if not date.isPast(date=oneperiodago):
                    relevantdates.append(date)
            numcards = len(relevantdates)
            if numcards >= 3:
                line1 = self.primary.fnameVar.get() + " " + self.primary.lnameVar.get() + " has gotten " + str(numcards) + " visitor cards"

                line2 = "within a " + str(Config.visitorcardperiod) + " day period of today, and should not get any more."
                
                line3 = "Do you still want to issue a visitor pass for " + getNow() + "?"
            elif numcards > 0:
                line1 = self.primary.fnameVar.get() + " " + self.primary.lnameVar.get() + " has gotten " + str(numcards) + " visitor card"
                if numcards is not 1:
                    line1 += "s"

                line2 = "within a " + str(Config.visitorcardperiod) + " day period of today. Do you want to issue a pass for " + getNow() + "?"

                line3 = ""
            else:
                line1 = "Visitor pass will be issued to " + self.primary.fnameVar.get() + " " + self.primary.lnameVar.get() + " for the date " + getNow()

                line2 = "Is this OK?"

                line3 = ""
        else:
            logTC("Invalid data in status field!", "ERROR")
            e = ErrorWindow(self.ew, "Invalid data in status field! (Please see and administrator)")
           
        self.msg1 = tk.Label(self.ew, text=line1)
        self.msg1.grid(row=1, column=1, columnspan=2, padx=PADX)

        self.msg2 = tk.Label(self.ew, text=line2)
        self.msg2.grid(row=2, column=1, columnspan=2, padx=PADX)

        self.msg3 = tk.Label(self.ew, text=line3)
        self.msg3.grid(row=3, column=1, columnspan=2, padx=PADX)

        self.datesLabel = tk.Label(self.ew, text="Dates Issued:")
        self.datesLabel.grid(row=4, column=1, columnspan=2, padx=PADX, pady=PADY)

        self.scrollbar = tk.Scrollbar(self.ew, orient="vertical", command=self.onScroll)
        self.scrollbar.grid(row=5, column=2, sticky='ns')
        
        self.datesLB = tk.Listbox(self.ew, yscrollcommand=self.scrollbar.set, width=25, height=10)
        self.datesLB.grid(row=5, column=1, columnspan=2)
        self.datesLB.bind("<MouseWheel>", self.onMouseWheel)
        
        self.affirmativeButton = tk.Button(self.ew, text="Yes", width=15, command=self.yes)
        self.affirmativeButton.grid(row=6, column=1, padx=PADX, pady=(10, 0))

        self.negativeButton = tk.Button(self.ew, text="No", width=15, command=self.terminate)
        self.negativeButton.grid(row=6, column=2, padx=PADX, pady=(10, 0))

        self.popDates()
Esempio n. 5
0
def customFunction(obj):
    currentdate = Date(getNow())

    #Calculate total visitor cards issued
    res = 0
    for record in obj.data:
        try:
            for vcdate in multiParse(record[6]):
                res += 1
        except TypeError:
            pass
    obj.output("Total Visitor Cards issued: " + str(res) + "\n\n")
    
    #Calculate Visitor Cards YTD
    #set up the variable to hold the results
    res = 0
    #iterate through every record in the data
    for record in obj.data:
        try:
            #iterate through every date in the record
            for vcdate in multiParse(record[6]):
                #check to see if the year of the record is equal to the
                #current year
                if vcdate.year == currentdate.year:
                    #if it is, raise the result variable by 1
                    res += 1
        except TypeError:
            #if the date field is empty, do nothing.
            pass
    #output the result to the metrics window
    obj.output("Visitor cards issued YTD: " + str(res) + "\n\n")

    #Calculate Visitor Cards MTD
    res = 0
    for record in obj.data:
        try:
            for vcdate in multiParse(record[6]):
                if vcdate.year == currentdate.year:
                    if vcdate.month == currentdate.month:
                        res += 1
        except TypeError:
            pass
    obj.output("Visitor cards issued MTD: " + str(res) + "\n\n")

    #Calculate Average per day
    avg = 0
    earliest = None
    for record in obj.data:
        try:
            for vcdate in multiParse(record[6]):
                if not earliest:
                    earliest = vcdate
                else:
                    if vcdate.year < earliest.year:
                        earliest = vcdate
                    else:
                        if vcdate.month < earliest.month:
                            earliest = vcdate
                        else:
                            if vcdate.day < earliest.day:
                                earliest = vcdate
                            else:
                                pass
                avg += 1  
        except TypeError:
            pass
    elapsedtime = currentdate.dateobj - earliest.dateobj
    avg = avg / 1.0
    try:
        avg = avg / (elapsedtime.days + 1)
    except ZeroDivisionError:
        pass
    obj.output("Average Visitor Cards per Day: " + str(avg) + "\n\n")