import PySimpleGUI as sg import pandas as pd import substitutionApprovalWindow as SWin import helperFunctions as HF import scheduledPayrollWindow as PWin import os #TODO make development branch for code testing withotu altering "real" databases #TODO remove blankArchivedSubRequests.csv by instead using the method used on substitutionRequestForm.csv in reset.py #TODO do error checking within while loop (update text color / valid status) # IMPOSSIBLE: pysimplegui does not allow for changing of the layout object after the window is created, # so the number of rows of checkboxes cannot be changed without reopening the window # It would be possible to have a "main menu" but all the processing work would still happen during the "sub menu" phase # and it would open more race-condition issues with overlapping requests # So it doesn't make much difference compared to simply re-running the program #---LOW PRIORITY (due to payroll being entered by ULAs directly)--- #TODO hours database #TODO section/helproom attendence verification form (filled out by ULAs themselves) #TODO add to hours database. #TODO staff meeting attendence google form #TODO add to hours database #TODO request ad hoc hours google form & approval interface (mirrors sub requests workflow) #TODO add to hours database #TODO payroll chart from hours database #TODO payroll chart click on entry to get detailed breakdown #set parameters defaultFont=("Courier",11) #Make sure that the font is evenly spaced or else the tables will be wonky. sectionDatabaseFilename="sectionsDatabase.csv" staffDatabaseFilename="staffDatabase.csv" subRequestsFilename="substitutionRequestForm.csv" subRequestsArchiveFilename="archivedSubRequests.csv" RegHoursFilename="regularHoursPayrollForm.csv" #create the folder for stringOutputs if it doesn't already exist if not os.path.exists("stringOutputs"): os.makedirs("stringOutputs" ) #load databases HF.getForms(subRequestsFilename) secD = pd.read_csv(sectionDatabaseFilename,dtype=str,index_col=False) stfD = pd.read_csv(staffDatabaseFilename,dtype=str,index_col=False) #remove leading/trailing whitespace secD = secD.apply(lambda x: x.str.strip()) stfD = stfD.apply(lambda x: x.str.strip()) #rewrite to file (each GUI function reads/writes on its own so that the state on disk matches what the user expects while the program is running) secD.to_csv(sectionDatabaseFilename,index=False,index_label=False) stfD.to_csv(staffDatabaseFilename,index=False,index_label=False) #remove timestamp & chosen email (which is NOT necessarily their MSU email), from Google Forms #this has the side effect of deleting the quotation marks on each entry, which is fine as they are unnecesssary subs = pd.read_csv(subRequestsFilename,dtype=str) subs.drop(['Username'],inplace=True,axis=1,errors='ignore') try: subs.rename({(subs.loc[:, subs.columns.str.startswith('Section')].columns[0]):"Section"},inplace=True,axis=1) subs.rename({(subs.loc[:, subs.columns.str.startswith('Substit')].columns[0]):"Requestor"},inplace=True,axis=1) subs.rename({(subs.loc[:, subs.columns.str.startswith('Dates')].columns[0]):"Dates"},inplace=True,axis=1) subs.rename({(subs.loc[:, subs.columns.str.startswith('MSU netID of Intend')].columns[0]):"Replacement"},inplace=True,axis=1) subs.rename({(subs.loc[:, subs.columns.str.startswith('Reason')].columns[0]):"Reason"},inplace=True,axis=1) except: pass subs.to_csv(subRequestsFilename,index=False,index_label=False) HF.createStrings() SWin.subAppWin(staffDatabaseFilename,sectionDatabaseFilename,subRequestsFilename,subRequestsArchiveFilename,defaultFont) #Diff check on original section assignments df1 = pd.read_csv(sectionDatabaseFilename,dtype=str) df2 = pd.read_csv(sectionDatabaseFilename[:-4]+"_Orig.csv",dtype=str) df1.fillna(value="",inplace=True) df2.fillna(value="",inplace=True) diff = df1.merge(df2, indicator=True, how='outer') diff=diff.loc[diff['_merge'] != 'both'] print("\n"+"-"*200+"\nTo-Date difference from default shifts:") print(diff) print("-"*200) #PWin.scheduledPayWin(sectionDatabaseFilename,RegHoursFilename,defaultFont)