66 lines
2.4 KiB
Python
66 lines
2.4 KiB
Python
import PySimpleGUI as sg
|
|
import csv
|
|
import pandas as pd
|
|
import helperFunctions as HF
|
|
from datetime import datetime, timedelta
|
|
|
|
def subManualWin(staffDatabaseFilename,secDFilename,subRequestsArchiveFilename,defaultFont):
|
|
|
|
stfD = pd.read_csv(staffDatabaseFilename,dtype=str,index_col=False)
|
|
|
|
allnames=list(stfD["Name"].values)
|
|
sections=HF.getSectionTitles()
|
|
|
|
layout=[[sg.Text("Email?| Sec | Date | Replacee | Replacement")],
|
|
[sg.Checkbox('',size=(3,1),key='-EMAILCHECK-'),sg.Combo(sections,size=(6,1),key="-SECTION-",readonly=True, enable_events=True),sg.Combo([""],size=(6,1),key='-DATE-',readonly=True, enable_events=True),sg.Combo([""],size=(30,1),key="-REPLACEE-", enable_events=True,readonly=True),sg.Combo(allnames,size=(30,1),key="-REPLACEMENT-", enable_events=True,readonly=True)],
|
|
[sg.Text("Reason for manual change: "),sg.Input(key='-REASON-')],
|
|
[sg.Button("Close Window"),sg.Button("Make Change")]]
|
|
|
|
# Create the Window
|
|
window = sg.Window('Manual Substitution', layout, font=defaultFont,resizable=True)
|
|
|
|
#Event Loop to process "events" and get the "values" of the inputs
|
|
#Cease running if they close the window
|
|
event=-1
|
|
|
|
while event != sg.WIN_CLOSED and event != "Close Window":
|
|
event, values = window.read()
|
|
|
|
if event=="-SECTION-" and values['-SECTION-']!="":
|
|
sec=values['-SECTION-']
|
|
dates=HF.getDatesFromSection(sec)
|
|
window["-DATE-"].update(values=dates)
|
|
window["-REPLACEE-"].update(values=[""])
|
|
|
|
if event=="-DATE-" and values['-DATE-']!="":
|
|
date=values["-DATE-"]
|
|
names=list(HF.getAllNamesFromSection(sec,date))[0]
|
|
window["-REPLACEE-"].update(values=names)
|
|
|
|
|
|
if event == "Make Change":
|
|
sec=values['-SECTION-']
|
|
date=values["-DATE-"]
|
|
replacee=HF.nameToID(values["-REPLACEE-"])
|
|
replacement=HF.nameToID(values["-REPLACEMENT-"])
|
|
|
|
timeStamp=str(datetime.now())
|
|
request=[timeStamp,replacee,sec,date,replacement,values["-REASON-"],"APP","MANUALLY CHANGED BY COURSE ADMINS"]
|
|
|
|
HF.reassign(date,sec,replacee,replacement)
|
|
|
|
with open(subRequestsArchiveFilename,'a', newline='') as f:
|
|
writer = csv.writer(f)
|
|
writer.writerows([request])
|
|
|
|
|
|
window["-SECTION-"].update(values=sections)
|
|
window["-DATE-"].update(values=[""])
|
|
window["-REPLACEE-"].update(values=[""])
|
|
window["-REPLACEMENT-"].update(values=allnames)
|
|
if values['-EMAILCHECK-']:
|
|
HF.generateEmails([request])
|
|
|
|
|
|
|
|
window.close() |