Пример #1
0
 def allowEdit(self, allow=True):
     if allow:
         logTC("Editing has been enabled!")
         self.fnameText.configure(state=tk.NORMAL)
         self.mnameText.configure(state=tk.NORMAL)
         self.lnameText.configure(state=tk.NORMAL)
         self.muniText.configure(state=tk.NORMAL)
         self.stateOptionsMenu.configure(state=tk.NORMAL)
         self.cardTimesText.configure(state=tk.NORMAL)
         self.statusOptionsMenu.configure(state=tk.NORMAL)
         if self.dat[7] in ('BLOCKED', 'BARRED'):
             self.bandateText.configure(state=tk.NORMAL)
             self.expdateText.configure(state=tk.NORMAL)
             self.barcodeText.configure(state=tk.NORMAL)
             self.reasonText.configure(state=tk.NORMAL)
         self.aiText.configure(state=tk.NORMAL)
         self.editButton.configure(state=tk.DISABLED)
         self.commitButton.configure(state=tk.NORMAL)
     else:
         logTC("Editing has been disabled!")
         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)
Пример #2
0
    def __init__(self, primary, window, top=False):
        logTC("Creating AuthWindow from authwindow.py")
        self.top = top
        self.window = window
        if not authPresent:
            error = ErrorWindow(primary, "Authfile not found! Please see an administrator.", "400x100")
        else:
            self.primary = primary
            self.authWin = tk.Toplevel(primary)
            self.authWin.protocol("WM_DELETE_WINDOW", self.close0)
            self.authWin.geometry("300x115")
            self.authWin.wm_title("Enter Password")
            self.authWin.focus_set()

            self.authWin.grab_set()

            self.pwEntryVar = tk.StringVar(self.authWin)
            self.pwEntry = tk.Entry(self.authWin, show="*", textvariable=self.pwEntryVar, width=30)
            self.pwEntry.bind("<Return>", lambda _: self.validate())
            self.pwEntry.pack(padx=PADX, pady=PADY)
            self.pwEntry.focus_set()
            self.pwEntryVar.trace("w", self.detectEmpty)

            self.incorrectLabel = tk.Label(self.authWin, text="")
            self.incorrectLabel.pack()

            self.enterButton = tk.Button(self.authWin, text="Enter", width=15, command=self.validate)
            self.authWin.bind("<Return>", self.validate)
            self.enterButton.pack(padx=PADX, pady=PADY)
Пример #3
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])
Пример #4
0
    def __init__(self, primary, sub, record, vp=False, geo="425x275"):
        logTC("Creating CDWindow from confirmduplicate.py")
        self.primary = primary
        self.sub = sub
        self.record = record
        self.issuePass = vp
        self.ew = tk.Toplevel(self.sub)
        self.ew.protocol("WM_DELETE_WINDOW", self.terminate)
        self.ew.geometry(geo)
        self.ew.wm_title("Warning! Possible Duplicate Record!")
        self.ew.focus_set()

        self.ew.grab_set()
        
        self.msg1 = tk.Label(self.ew, text="You are attempting to commit data which may already be in the database.")
        self.msg1.grid(row=1, column=1, columnspan=2, padx=PADX, pady=PADY)

        self.msg2 = tk.Label(self.ew, text="A possible match was found with the following record:")
        self.msg2.grid(row=2, column=1, columnspan=2, padx=PADX, pady=PADY)

        self.msg3 = tk.Label(self.ew, text=self.record[1] + " " + self.record[2] + " " + self.record[3])
        self.msg3.grid(row=3, column=1, columnspan=2, padx=PADX, pady=PADY)

        self.msg4 = tk.Label(self.ew, text="ID: " + str(self.record[0]) + ", " + self.record[4] + ", " + self.record[5])
        self.msg4.grid(row=4, column=1, columnspan=2, padx=PADX, pady=PADY)

        self.msg5 = tk.Label(self.ew, text="Are you sure you want to commit this record?")
        self.msg5.grid(row=5, column=1, columnspan=2, padx=PADX, pady=PADY)
        
        self.affirmativeButton = tk.Button(self.ew, text="Yes", width=15, command=self.yes)
        self.affirmativeButton.grid(row=6, column=1, padx=PADX, pady=PADY)

        self.negativeButton = tk.Button(self.ew, text="No", width=15, command=self.terminate)
        self.negativeButton.grid(row=6, column=2, padx=PADX, pady=PADY)
Пример #5
0
def validateConfig():
    try:
        from cfg import Config
        Config = Config()
        test = Config.geo
        test = Config.lockgeo
        test = Config.dbfn
        test = Config.overrideBans
        test = Config.dispSAM
        test = Config.allowedNameChars
        test = Config.allowedMuniChars
        test = Config.states
        test = Config.defaultsort
        test = Config.defaultsortorder
        test = Config.visitorcardperiod
        test = Config.loggingDir
        test = Config.useDDrive
        test = Config.doLogPurge
        test = Config.logPurgePeriod
        test = Config.PeriodDependentMunis
        test = Config.CardsPerPeriod
        return True
    except Exception as e:
        logTC(str(e), outputType="EXCEPTION")
        return False
Пример #6
0
    def __init__(self, primary, geo="400x175"):
        logTC("Creating RCWindow from confirmconfig.py")
        self.primary = primary
        self.ew = tk.Toplevel(self.primary)
        self.ew.protocol("WM_DELETE_WINDOW", self.terminate)
        self.ew.geometry(geo)
        self.ew.wm_title("Reset Configuration?")
        self.ew.focus_set()

        self.ew.grab_set()
        
        self.msg1 = tk.Label(self.ew, text="Are your sure you want to reset the configuration file?")
        self.msg1.grid(row=1, column=1, columnspan=2, padx=PADX, pady=PADY)

        self.msg2 = tk.Label(self.ew, text="In addition to PERMANENTLY ERASING your old configuration settings,")
        self.msg2.grid(row=2, column=1, columnspan=2, padx=PADX, pady=PADY)

        self.msg3 = tk.Label(self.ew, text="you must restart the program to do this.")
        self.msg3.grid(row=3, column=1, columnspan=2, padx=PADX, pady=PADY)
        
        self.affirmativeButton = tk.Button(self.ew, text="Yes", width=15, command=self.yes)
        self.affirmativeButton.grid(row=4, column=1, padx=PADX, pady=PADY)

        self.negativeButton = tk.Button(self.ew, text="No", width=15, command=self.terminate)
        self.negativeButton.grid(row=4, column=2, padx=PADX, pady=PADY)
Пример #7
0
 def lookup(self, *args):
     self.getInfoButton.configure(state=tk.DISABLED)
     sterm = self.searchBoxVar.get()
     option = self.searchOptionVar.get()
     if not sterm:
         logTC("Nothing entered into search box.", "ERROR")
         e = ErrorWindow(self, "Nothing entered into search box.")
         return False
     if option == 'Last,First':
         sterm = nameVAndF(sterm)
         if not sterm:
             logTC("Entered name not in correct format.", "ERROR")
             e = ErrorWindow(self, "Entered name not in correct format.")
         elif not sterm[1]:
             ln = sterm[0]
             results = filt('patrons', lname=ln)
         elif not sterm[0]:
             fn = sterm[1]
             results = filt('patrons', fname=fn)
         else:
             ln = sterm[0]
             fn = sterm[1]
             results = filt('patrons', fname=fn, lname=ln)
     if option == 'Municipality':
         results = filt('patrons', muni=sterm)
     if option == 'State':
         results = filt('patrons', state=sterm)
         
     self.populate(results)
Пример #8
0
 def revdir(self, sorttype):
     direction = self.directions[sorttype]
     if direction == 'up':
         self.directions[sorttype] = 'down'
     elif direction == 'down':
         self.directions[sorttype] = 'up'
     else:
         logTC('Direction is not currently set, or is set improperly.', 'ERROR')
         return -1
Пример #9
0
def lookupByID(idNum):
    conn = sqlite3.connect(Config.dbfn)
    c = conn.cursor()
    c.execute('SELECT * FROM patrons WHERE id=?', (idNum))
    res = c.fetchall()
    conn.close()
    if len(res) > 1:
        logTC("More than one matching ID number found!", "ERROR")
        logTC("Please check the database!", "ERROR")
        return False
    return res[0]
Пример #10
0
 def __init__(self):
     logTC("Creating Main object.")
     logPurge()
     self.root = tk.Tk()
     f = open(getLFilePath(), "a")
     sys.stderr = f
     tk.CallWrapper = Catcher
     self.root.bind_class("Text", "<Control-a>", self.selectallText)
     self.root.bind_class("Entry", "<Control-a>", self.selectallEntry)
     self.root.geometry(Config.geo)
     self.root.resizable(width=Config.lockgeo, height=Config.lockgeo)
     self.root.title("Visitor Card Lookup")
     MainApp(self.root).pack(side="top", fill="both", expand=True)
     self.root.after(100, lambda: self.root.focus_force())
     self.root.mainloop()
Пример #11
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)
Пример #12
0
    def __init__(self, primary, message, geo="400x100"):
        logTC("Creating ErrorWindow from errorwin.py")
        self.primary = primary
        self.ew = tk.Toplevel(primary)
        self.ew.protocol("WM_DELETE_WINDOW", self.ok)
        self.ew.geometry(geo)
        self.ew.wm_title("Error!")
        self.ew.focus_set()

        self.ew.grab_set()

        self.msg = tk.Label(self.ew, text=message)
        self.msg.pack(padx=PADX, pady=PADY)

        self.okButton = tk.Button(self.ew, text="Ok", width=15, command=self.ok)
        self.ew.bind("<Return>", self.ok)
        self.okButton.pack(padx=PADX, pady=PADY)
Пример #13
0
    def __init__(self, primary):
        logTC("Creating MetricsWindow from metrics.py")
        self.primary = primary

        self.mwin = tk.Toplevel(primary)
        self.mwin.protocol("WM_DELETE_WINDOW", self.close)
        self.mwin.geometry("750x600")
        self.mwin.wm_title("Metrics Generator")
        self.mwin.focus_set()
        self.mwin.grab_set()

        self.data = getAll('patrons')

        self.outputLB = tk.Text(self.mwin, height=35, width=100)
        self.outputLB.grid(column=1, row=1)

        self.test()
Пример #14
0
    def __init__(self, primary, message, title, function, geo="400x100"):
        logTC("Creating VerifyWindow from verifywindow.py")
        self.primary = primary
        self.function = function
        self.ew = tk.Toplevel(primary)
        self.ew.protocol("WM_DELETE_WINDOW", self.terminate)
        self.ew.geometry(geo)
        self.ew.wm_title(title)
        self.ew.focus_set()

        self.ew.grab_set()

        self.msg = tk.Label(self.ew, text=message)
        self.msg.grid(row=1, column=1, columnspan=2, padx=PADX, pady=PADY)

        self.affirmativeButton = tk.Button(self.ew, text="Yes", width=15, command=self.doFunction)
        self.affirmativeButton.grid(row=2, column=1, padx=PADX, pady=PADY)

        self.negativeButton = tk.Button(self.ew, text="No", width=15, command=self.terminate)
        self.negativeButton.grid(row=2, column=2, padx=PADX, pady=PADY)
Пример #15
0
        def __init__(self, parent, *args, **kwargs):
            if not True:
                #old code: to be removed
                logTC("Authfile not found!", "FATAL")
                error = ErrorWindow(self, "Authfile not found!", "400x100")
            else:
                tk.Frame.__init__(self, parent, *args, **kwargs)
                self.parent = parent

                self.logo = tk.PhotoImage(data=logo)
                self.logoLabel = tk.Label(image=self.logo)
                self.logoLabel.pack()

                self.titleLabel = tk.Label(text="Digital Visitor Card Log",
                                           font=("Arial", 16, "bold"))
                self.titleLabel.pack()

                if Config.dispSAM:
                    self.subtitleLabel = tk.Label(text="\"Still better than SAM.\"",
                                                  font=("Arial", 10))
                    self.subtitleLabel.pack(pady=PADY)

                self.pwINSLabel = tk.Label(text="Enter Password:"******"*", textvariable=self.pwEntryVar, width=30)
                self.pwEntry.bind("<Return>", lambda _: self.validate())
                self.pwEntry.pack(padx=PADX, pady=PADY)
                self.pwEntry.focus_set()
                self.pwEntryVar.trace("w", self.detectEmpty)

                self.incorrectLabel = tk.Label(self, text="")
                self.incorrectLabel.pack()

                self.enterButton = tk.Button(self, text="Enter", width=15, command=self.validate)
                self.bind("<Return>", self.validate)
                self.enterButton.pack(padx=PADX, pady=PADY)

                if not os.path.isfile('auth.pyc'):
                    error = ErrorWindow(self, "Auth file not present. Please see an administrator.")
Пример #16
0
def addBannedPatron(fn, ln, bd, ed, barcode, muni, reason, additional_info):
    current_table = getAll('banned_patrons')
    if not current_table:
        logTC("First record created")
        idnum = 1
    else:
        highest = current_table[0][0]
        for record in current_table:
            if record[0] > highest:
                highest = record[0]
            else:
                pass
        idnum = highest + 1
    conn = sqlite3.connect(Config.getDBFileName())
    c = conn.cursor()
    fn = fn.upper()
    ln = ln.upper()
    muni = muni.upper()
    record = (idnum, fn, ln, bd, ed, barcode, muni, reason, additional_info)
    c.execute('INSERT INTO banned_patrons VALUES (?,?,?,?,?,?,?,?,?)', record)
    conn.commit()
    conn.close()
Пример #17
0
    def __init__(self, primary):
        logTC("Creating about window from about.py", "INFO")
        self.primary = primary
        self.aw = tk.Toplevel(primary)
        self.aw.protocol("WM_DELETE_WINDOW", self.ok)
        self.aw.geometry("450x325")
        self.aw.wm_title('About')
        self.aw.focus_set()
        self.aw.grab_set()

        self.logo = tk.PhotoImage(data=logo)
        self.logoLabel=tk.Label(self.aw, image=self.logo)
        self.logoLabel.pack()
        
        self.titleLabel = tk.Label(self.aw, text="Digital Visitor Card Log",
                                   font=("Arial", 16, "bold"))
        self.titleLabel.pack()

        verstr = "Version: " + STAGE + " " + VERSION
        if REVISION is not "0":
            verstr += " R" + REVISION
        self.ver = tk.Label(self.aw, text=verstr,
                            font=("Arial", 14))
        self.ver.pack(padx=PADX, pady=PADY)

        self.info1 = tk.Label(self.aw, text="Coder: Tyler D. Vitale")
        self.info1.pack()

        self.info2 = tk.Label(self.aw, text="Licensed under the Creative Commons Zero 1.0 License")
        self.info2.pack()

        self.info3 = tk.Label(self.aw, text="No Rights Reserved")
        self.info3.pack()

        self.okButton = tk.Button(self.aw, text="Ok", width=15, command=self.ok)
        self.aw.bind("<Return>", self.ok)
        self.okButton.pack(padx=PADX, pady=PADY)
Пример #18
0
 def validate(self, *args):
     if not os.path.isfile('auth.pyc'):
         error = ErrorWindow(self, "Auth file not present. Please see an administrator.")
     else:
         inpt = self.pwEntryVar.get()
         inpt = base64.b64encode(inpt)
         if inpt == getOPW():
             logTC("Password authentication successful.")
             self.close1()
         elif inpt == "":
             self.incorrectLabel.configure(text="Password field blank")
             logTC("Authentication failed.")
         else:
             self.incorrectLabel.configure(text="Incorrect password")
             logTC("Authentication failed.")
Пример #19
0
 def terminate(self, *args):
     logTC("Destroying CDWindow from confirmduplicate.py")
     self.ew.grab_release()
     self.ew.destroy()
Пример #20
0
 def terminate(self, *args):
     logTC("Destroying VerifyWindow from verifywindow.py")
     self.ew.grab_release()
     self.primary.focus_set()
     self.primary.refresh()
     self.ew.destroy()
Пример #21
0
from cfgparser import validateConfig
from cfg import Config

Config = Config()
from log import logTC
from log import logStart

logStart()
logTC("Program started.")
logTC("Beginning authentication procedure...")

from authmain import auth

auth()
Пример #22
0
import Tkinter as tk
import sys
from primaryGUI import MainApp
from ehandler import Catcher
from log import logTC
from log import getLFilePath
from logpurger import logPurge
from cfgparser import validateConfig

if validateConfig():
    logTC("Valid configuration file found.")
    from cfg import Config

    Config = Config()
else:
    logTC("Invalid configuration file!", "FATAL ERROR")
    logTC("Please see an administrator if you are seeing this message.", "FATAL ERROR")
    exit(-1)


def runMain():
    class Main:
        def __init__(self):
            logTC("Creating Main object.")
            logPurge()
            self.root = tk.Tk()
            f = open(getLFilePath(), "a")
            sys.stderr = f
            tk.CallWrapper = Catcher
            self.root.bind_class("Text", "<Control-a>", self.selectallText)
            self.root.bind_class("Entry", "<Control-a>", self.selectallEntry)
Пример #23
0
 def commitToDB(self):
     self.commitButton.configure(state=tk.DISABLED)
     logTC("Committing the following new record to database:")
     logArrTC(self.arr, dbArr=True)
     addRecord("patrons", self.arr)
     self.close()
Пример #24
0
 def close(self, *args):
     logTC("Destroying PatronInfo from dispinfo.py")
     self.piwin.grab_release()
     self.primary.focus_set()
     self.primary.refresh()
     self.piwin.destroy()
Пример #25
0
import sqlite3
import datetime
import os

from smfunctions import clr
from smfunctions import cont

from cfgparser import validateConfig

from log import logTC

if validateConfig():
    from cfg import Config
    Config = Config()
else:
    logTC("Invalid configuration file!", "FATAL ERROR")
    logTC("Please create a new one by deleting the cfg.py and cfg.pyc files.", "FATAL ERROR")
    logTC("Then simply restart the program and it will create new ones.")
    cont()
    exit(-1)

#Little function that returns the date as a string in the format mm-dd-yyyy
def getAmerDate():
    d = datetime.date.today()
    return str(d.month) + "-" + str(d.day) + "-" + str(d.year)

#Little function that prints the results of a query in a nice format
def packres(res):
    i = 1
    resarr = []
    for row in res:
Пример #26
0
 def commitToDB(self):
     logTC("Committing changes to database...")
     editQuery("patrons", self.arr)
     self.editButton.configure(state=tk.NORMAL)
     self.commitButton.configure(state=tk.DISABLED)
Пример #27
0
    def __init__(self, primary, patronArr):
        logTC("Creating PatronInfo from dispinfo.py")
        self.primary = primary
        self.dat = patronArr

        self.piwin = tk.Toplevel(primary)
        self.piwin.protocol("WM_DELETE_WINDOW", self.close)
        self.piwin.geometry("450x475")
        self.piwin.wm_title("Patron Info")
        self.piwin.focus_set()
        self.piwin.grab_set()

        self.idTLabel = tk.Label(self.piwin, text="ID Number:",
                                 font="Courier 10 bold")
        self.idTLabel.grid(column=1, row=1, sticky="W", padx=PADX)
        self.idVar = tk.StringVar()
        self.idText = tk.Entry(self.piwin, textvariable=self.idVar, width=25)
        self.idText.grid(column=2, row=1)

        self.fnameTLabel = tk.Label(self.piwin, text="First Name:",
                                   font="Courier 10 bold")
        self.fnameTLabel.grid(column=1, row=2, sticky="W", padx=PADX)
        self.fnameVar = tk.StringVar()
        self.fnameText = tk.Entry(self.piwin, textvariable=self.fnameVar, width=25)
        self.fnameText.grid(column=2, row=2)
        self.fnameText.bind("<KeyRelease>", lambda _: self.caps(self.fnameVar))

        self.mnameTLabel = tk.Label(self.piwin, text="Middle Name:",
                                   font="Courier 10 bold")
        self.mnameTLabel.grid(column=1, row=3, sticky="W", padx=PADX)
        self.mnameVar = tk.StringVar()
        self.mnameText = tk.Entry(self.piwin, textvariable=self.mnameVar, width=25)
        self.mnameText.grid(column=2, row=3)
        self.mnameText.bind("<KeyRelease>", lambda _: self.caps(self.mnameVar))

        self.lnameTLabel = tk.Label(self.piwin, text="Last Name:",
                                   font="Courier 10 bold")
        self.lnameTLabel.grid(column=1, row=4, sticky="W", padx=PADX)
        self.lnameVar = tk.StringVar()
        self.lnameText = tk.Entry(self.piwin, textvariable=self.lnameVar, width=25)
        self.lnameText.grid(column=2, row=4)
        self.lnameText.bind("<KeyRelease>", lambda _: self.caps(self.lnameVar))

        self.muniTLabel = tk.Label(self.piwin, text="Location:",
                                   font="Courier 10 bold")
        self.muniTLabel.grid(column=1, row=5, sticky="W", padx=PADX)
        self.muniVar = tk.StringVar()
        self.muniText = tk.Entry(self.piwin, textvariable=self.muniVar, width=25)
        self.muniText.grid(column=2, row=5)
        self.muniText.bind("<KeyRelease>", lambda _: self.caps(self.muniVar))

        self.stateTLabel = tk.Label(self.piwin, text="State:",
                                   font="Courier 10 bold")
        self.stateTLabel.grid(column=1, row=6, sticky="W", padx=PADX)
        self.stateOptionsVar = tk.StringVar()
        self.stateOptions = Config.states
        self.stateOptionsVar.set(self.stateOptions[0])
        self.stateOptionsMenu = tk.OptionMenu(self.piwin, self.stateOptionsVar, *self.stateOptions)
        self.stateOptionsMenu.grid(column=2, row=6)
        
        self.cardTimesTLabel = tk.Label(self.piwin, text="# of Visitor Cards:",
                                   font="Courier 10 bold")
        self.cardTimesTLabel.grid(column=1, row=7, sticky="W", padx=PADX)
        self.cardTimesVar = tk.StringVar()
        self.cardTimesText = tk.Entry(self.piwin, textvariable=self.cardTimesVar, width=25)
        self.cardTimesText.grid(column=2, row=7)

        self.statusTLabel = tk.Label(self.piwin, text="Status:",
                                   font="Courier 10 bold")
        self.statusTLabel.grid(column=1, row=8, sticky="W", padx=PADX)
        self.dictStatusOptions = {
            None: 'OK',
            'BLOCKED': 'BLOCKED',
            'BARRED': 'BARRED'
            }
        self.statusOptions = ("OK", "BLOCKED", "BARRED")
        self.statusOptionsVar = tk.StringVar()
        if not self.dat[7]:
            self.statusOptionsVar.set(self.statusOptions[0])
        elif self.dat[7] == 'BLOCKED':
            self.statusOptionsVar.set(self.statusOptions[1])
        elif self.dat[7] == 'BARRED':
            self.statusOptionsVar.set(self.statusOptions[2])
        else:
            raise InvalidFieldException("status", self.arr[7])
        self.statusOptionsMenu = tk.OptionMenu(self.piwin, self.statusOptionsVar, *self.statusOptions)
        self.statusOptionsMenu.grid(column=2, row=8)
        self.statusOptionsVar.trace('w', self.updateBoxes)

        self.bandateTLabel = tk.Label(self.piwin, text="Ban Date:",
                                    font="Courier 10 bold")
        self.bandateTLabel.grid(column=1, row=9, sticky="W", padx=PADX)
        self.bandateVar = tk.StringVar()
        self.bandateText = tk.Entry(self.piwin, textvariable=self.bandateVar, width=25)
        self.bandateText.grid(column=2, row=9)

        self.expdateTLabel = tk.Label(self.piwin, text="Ban Expiration Date:",
                                    font="Courier 10 bold")
        self.expdateTLabel.grid(column=1, row=10, sticky="W", padx=PADX)
        self.expdateVar = tk.StringVar()
        self.expdateText = tk.Entry(self.piwin, textvariable=self.expdateVar, width=25)
        self.expdateText.grid(column=2, row=10)

        self.barcodeTLabel = tk.Label(self.piwin, text="Barcode:",
                                        font="Courier 10 bold")
        self.barcodeTLabel.grid(column=1, row=11, sticky="W", padx=PADX)
        self.barcodeVar = tk.StringVar()
        self.barcodeText = tk.Entry(self.piwin, textvariable=self.barcodeVar, width=25)
        self.barcodeText.grid(column=2, row=11)

        self.reasonTLabel = tk.Label(self.piwin, text="Ban Reason:",
                                        font="Courier 10 bold")
        self.reasonTLabel.grid(column=1, row=12, sticky="W", padx=PADX)
        self.reasonText = tk.Text(self.piwin, wrap=tk.WORD, height=4, width=30)
        self.reasonText.grid(column=2, row=12)

        self.aiTLabel = tk.Label(self.piwin, text="Additional Info:",
                                    font="Courier 10 bold")
        self.aiTLabel.grid(column=1, row=13, sticky="W", padx=PADX)
        self.aiText = tk.Text(self.piwin, wrap=tk.WORD, height=4, width=30)
        self.aiText.grid(column=2, row=13)

        self.issuePassButton = tk.Button(self.piwin, width=15, text="Issue Visitor Pass", command=lambda: self.validate(issuePass=True))
        self.issuePassButton.grid(column=1, row=14)

        self.closeButton = tk.Button(self.piwin, width=15, text="Close", command=self.close)
        self.closeButton.grid(column=1, row=15)

        self.editButton = tk.Button(self.piwin, width=15, text="Edit", command=self.allowEdit)
        self.editButton.grid(column=2, row=14)

        self.commitButton = tk.Button(self.piwin, width=15, text="Commit", command=self.validate, state=tk.DISABLED)
        self.commitButton.grid(column=2, row=15)

        self.populate()
Пример #28
0
 def validate(self, issuePass=False):
     self.arr = []
     self.arr.append(self.idVar.get())
     if not self.fnameVar.get():
         logTC("First name field may not be empty", "ERROR")
         e = ErrorWindow(self.piwin, "First name field may not be empty.")
         return -1
     valid = validateName(self.fnameVar.get())
     if not valid[0]:
         logTC("Invalid character in first name field: '" + valid[1] + "'", "ERROR")
         e = ErrorWindow(self.piwin, "Invalid character in first name field: '" + valid[1] + "'")
         return -1
     self.arr.append(self.fnameVar.get().upper())
     if not self.mnameVar.get():
         logTC("Middle name field may not be empty", "ERROR")
         e = ErrorWindow(self.piwin, "Middle name field may not be empty.")
         return -1
     valid = validateName(self.mnameVar.get())
     if not valid[0]:
         logTC("Invalid character in middle name field: '" + valid[1] + "'", "ERROR")
         e = ErrorWindow(self.piwin, "Invalid character in middle name field: '" + valid[1] + "'")
         return -1
     self.arr.append(self.mnameVar.get().upper())
     if not self.lnameVar.get():
         logTC("Last name field may not be empty", "ERROR")
         e = ErrorWindow(self.piwin, "Last name field may not be empty.")
         return -1
     valid = validateName(self.lnameVar.get())
     if not valid[0]:
         logTC("Invalid character in last name field: '" + valid[1] + "'", "ERROR")
         e = ErrorWindow(self.piwin, "Invalid character in last name field: '" + valid[1] + "'")
         return -1
     self.arr.append(self.lnameVar.get().upper())
     if not self.muniVar.get():
         logTC("Location field may not be empty", "ERROR")
         e = ErrorWindow(self.piwin, "Location field may not be empty.")
         return -1
     valid = validateMuni(self.muniVar.get().upper())
     if not valid[0]:
         logTC("Invalid character in the location field: '" + valid[1] + "'", "ERROR")
         e = ErrorWindow(self.piwin, "Invalid character in the location field: '" + valid[1] + "'")
         return -1
     self.arr.append(self.muniVar.get().upper())
     self.arr.append(self.stateOptionsVar.get())
     self.arr.append(self.dat[6])
     if self.statusOptionsVar.get() == 'OK':
         self.arr.append(None)
     elif self.statusOptionsVar.get() == 'BLOCKED':
         self.arr.append('BLOCKED')
     elif self.statusOptionsVar.get() == 'BARRED':
         self.arr.append('BARRED')
     else:
         self.arr.append(None)
     if self.bandateVar.get():
         if self.bandateVar.get() in ("NEVER", "CONDITIONAL"):
             logTC("Invalid argument in bandate field!", "ERROR")
             e = ErrorWindow(self.piwin, "You cannot use NEVER or CONDITIONAL in the ban date field.", "425x100")
             return -1
         try:
             sd = Date(self.bandateVar.get())
             self.arr.append(self.bandateVar.get())
         except Exception as e:
             logTC("Invalid ban date entered!", "ERROR")
             e = ErrorWindow(self.piwin, "Invalid ban date entered!")
             return -1
     else:
         self.arr.append(None)
     if self.expdateVar.get():
         try:
             sd = Date(self.expdateVar.get())
             self.arr.append(self.expdateVar.get())
         except Exception as e:
             logTC("Invalid expiration date entered!", "ERROR")
             e = ErrorWindow(self.piwin, "Invalid expiration date entered!")
             return -1
     else:
         self.arr.append(None)
     if self.barcodeVar.get():
         barcode = self.barcodeVar.get()
         if not validateBarcode(barcode):
             logTC("Invalid barcode!", "ERROR")
             e = ErrorWindow(self.piwin, "Invalid barcode entered!")
         else:
             self.arr.append(self.barcodeVar.get())
     else:
         self.arr.append(None)
     if any(letter.isalpha() for letter in self.reasonText.get("1.0", tk.END)):
         self.arr.append(self.reasonText.get("1.0", tk.END))
     else:
         self.arr.append(None)
     self.arr.append(self.aiText.get("1.0", tk.END))
     if self.arr[7] in ("BLOCKED", "BARRED"):
         if not self.arr[8]:
             logTC("Patron with isBanned == BLOCKED or BARRED cannot have NULL Ban Date field.", "ERROR")
             e = ErrorWindow(self.piwin, "A BLOCKED or BARRED patron may not have their Ban Date field be blank.", "425x100")
             return -1
         if not self.arr[11]:
             logTC("Patron with isBanned == BLOCKED or BARRED cannot have NULL reason field.", "ERROR")
             e = ErrorWindow(self.piwin, "A BLOCKED or BARRED patron may not have their reason field be blank.", "425x100")
             return -1
     logArrTC(self.arr, dbArr=True)
     self.allowEdit(False)
     if issuePass:
         self.issuePass()
     else:
         self.commitToDB()
Пример #29
0
 def close(self, *args):
     logTC("Destroying addrecord window from addrecord.py")
     self.arwin.grab_release()
     self.primary.focus_set()
     self.primary.refresh()
     self.arwin.destroy()
Пример #30
0
    def __init__(self, primary):
        logTC("Creating addrecord window from addrecord.py")
        self.primary = primary

        self.arwin = tk.Toplevel(primary)
        self.arwin.protocol("WM_DELETE_WINDOW", self.close)
        self.arwin.geometry("450x475")
        self.arwin.wm_title("Add Record")
        self.arwin.focus_set()
        self.arwin.grab_set()

        self.arr = []

        self.idTLabel = tk.Label(self.arwin, text="ID Number:", font="Courier 10 bold")
        self.idTLabel.grid(column=1, row=1, sticky="W", padx=PADX)
        self.idVar = tk.StringVar()
        self.idText = tk.Entry(self.arwin, textvariable=self.idVar, width=25)
        self.idText.grid(column=2, row=1)
        self.idText.insert(0, getNID())
        self.idText.configure(state=tk.DISABLED)

        self.fnameTLabel = tk.Label(self.arwin, text="First Name:", font="Courier 10 bold")
        self.fnameTLabel.grid(column=1, row=2, sticky="W", padx=PADX)
        self.fnameVar = tk.StringVar()
        self.fnameText = tk.Entry(self.arwin, textvariable=self.fnameVar, width=25)
        self.fnameText.grid(column=2, row=2)
        self.fnameText.bind("<KeyRelease>", lambda _: self.caps(self.fnameVar))

        self.mnameTLabel = tk.Label(self.arwin, text="Middle Name:", font="Courier 10 bold")
        self.mnameTLabel.grid(column=1, row=3, sticky="W", padx=PADX)
        self.mnameVar = tk.StringVar()
        self.mnameText = tk.Entry(self.arwin, textvariable=self.mnameVar, width=25)
        self.mnameText.grid(column=2, row=3)
        self.mnameText.bind("<KeyRelease>", lambda _: self.caps(self.mnameVar))

        self.lnameTLabel = tk.Label(self.arwin, text="Last Name:", font="Courier 10 bold")
        self.lnameTLabel.grid(column=1, row=4, sticky="W", padx=PADX)
        self.lnameVar = tk.StringVar()
        self.lnameText = tk.Entry(self.arwin, textvariable=self.lnameVar, width=25)
        self.lnameText.grid(column=2, row=4)
        self.lnameText.bind("<KeyRelease>", lambda _: self.caps(self.lnameVar))

        self.muniTLabel = tk.Label(self.arwin, text="Location:", font="Courier 10 bold")
        self.muniTLabel.grid(column=1, row=5, sticky="W", padx=PADX)
        self.muniVar = tk.StringVar()
        self.muniText = tk.Entry(self.arwin, textvariable=self.muniVar, width=25)
        self.muniText.grid(column=2, row=5)
        self.muniText.bind("<KeyRelease>", lambda _: self.caps(self.muniVar))

        self.stateTLabel = tk.Label(self.arwin, text="State:", font="Courier 10 bold")
        self.stateTLabel.grid(column=1, row=6, sticky="W", padx=PADX)
        self.stateOptionsVar = tk.StringVar()
        self.stateOptions = Config.states
        self.stateOptionsVar.set(self.stateOptions[0])
        self.stateOptionsMenu = tk.OptionMenu(self.arwin, self.stateOptionsVar, *self.stateOptions)
        self.stateOptionsMenu.grid(column=2, row=6)

        self.statusTLabel = tk.Label(self.arwin, text="Status:", font="Courier 10 bold")
        self.statusTLabel.grid(column=1, row=8, sticky="W", padx=PADX)
        self.statusOptions = ("OK", "BLOCKED", "BARRED")
        self.statusOptionsVar = tk.StringVar()
        self.statusOptionsVar.set(self.statusOptions[0])

        self.statusOptionsMenu = tk.OptionMenu(self.arwin, self.statusOptionsVar, *self.statusOptions)
        self.statusOptionsMenu.grid(column=2, row=8)
        self.statusOptionsVar.trace("w", self.updateBoxes)

        self.bandateTLabel = tk.Label(self.arwin, text="Ban Date:", font="Courier 10 bold")
        self.bandateTLabel.grid(column=1, row=9, sticky="W", padx=PADX)
        self.bandateVar = tk.StringVar()
        self.bandateText = tk.Entry(self.arwin, textvariable=self.bandateVar, width=25)
        self.bandateText.grid(column=2, row=9)
        self.bandateText.bind("<KeyRelease>", lambda _: self.caps(self.bandateVar))

        self.expdateTLabel = tk.Label(self.arwin, text="Ban Expiration Date:", font="Courier 10 bold")
        self.expdateTLabel.grid(column=1, row=10, sticky="W", padx=PADX)
        self.expdateVar = tk.StringVar()
        self.expdateText = tk.Entry(self.arwin, textvariable=self.expdateVar, width=25)
        self.expdateText.grid(column=2, row=10)
        self.expdateText.bind("<KeyRelease>", lambda _: self.caps(self.expdateVar))

        self.barcodeTLabel = tk.Label(self.arwin, text="Barcode:", font="Courier 10 bold")
        self.barcodeTLabel.grid(column=1, row=11, sticky="W", padx=PADX)
        self.barcodeVar = tk.StringVar()
        self.barcodeText = tk.Entry(self.arwin, textvariable=self.barcodeVar, width=25)
        self.barcodeText.grid(column=2, row=11)
        self.barcodeVar.trace("w", lambda s, e, i: self.barcodeCaps())

        self.reasonTLabel = tk.Label(self.arwin, text="Ban Reason:", font="Courier 10 bold")
        self.reasonTLabel.grid(column=1, row=12, sticky="W", padx=PADX)
        self.reasonText = tk.Text(self.arwin, wrap=tk.WORD, height=4, width=30)
        self.reasonText.grid(column=2, row=12)

        self.aiTLabel = tk.Label(self.arwin, text="Additional Info:", font="Courier 10 bold")
        self.aiTLabel.grid(column=1, row=13, sticky="W", padx=PADX)
        self.aiText = tk.Text(self.arwin, wrap=tk.WORD, height=4, width=30)
        self.aiText.grid(column=2, row=13)

        self.commitButton = tk.Button(self.arwin, width=25, text="Commit", command=self.validate)
        self.commitButton.grid(column=1, row=15, padx=PADX)

        self.CaIPButton = tk.Button(
            self.arwin, width=25, text="Commit and Issue Visitor Pass", command=lambda: self.validate(issuePass=True)
        )
        self.CaIPButton.grid(column=1, row=16, padx=PADX)

        self.closeButton = tk.Button(self.arwin, width=25, text="Close", command=self.close)
        self.closeButton.grid(column=1, row=17, padx=PADX)

        self.updateBoxes()