SHARE
TWEET

Untitled

a guest Apr 23rd, 2019 116 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. import sys
  2. import pymysql
  3. import pandas as pd
  4. from datetime import datetime
  5. from PyQt5.QtGui import *
  6. from PyQt5.QtCore import *
  7. from PyQt5.QtWidgets import *
  8. from userlogin import Ui_UserLogin
  9. from registernav import Ui_RegisterNavigation
  10. from userfunc  import Ui_UserFunctionality
  11. from visitorfunc import Ui_VisitorFunctionality
  12. from staffvisitorfunc import Ui_StaffVisitorFunctionality
  13. from adminvisitorfunc import Ui_AdminVisitorFunctionality
  14. from managervisitorfunc import Ui_ManagerVisitorFunctionality
  15. from stafffunc import Ui_StaffFunctionality
  16. from adminfunc import Ui_AdminFunctionality
  17. from managerfunc import Ui_ManagerFunctionality
  18. from userviewtransithistory import Ui_UserTransitHistory
  19. from usertaketransit import Ui_UserTakeTransit
  20. from admineditsite import Ui_AdminEditSite
  21. from admincreatesite import Ui_AdminCreateSite
  22. from registeruser import Ui_RegisterUser
  23. from registervisitor import Ui_RegisterVisitor
  24. from registeremployee import Ui_RegisterEmployee
  25. from registeremployeevisitor import Ui_RegisterEmployeeVisitor
  26. from adminmanagesite import Ui_AdminManageSite
  27. from adminmanageuser import Ui_AdminManageUser
  28. from adminmanagetransit import Ui_AdminManageTransit
  29. from adminedittransit import Ui_AdminEditTransit
  30. from admincreatetransit import Ui_AdminCreateTransit
  31. from managermanageevent import Ui_ManagerManageEvent
  32. from managermanagestaff import Ui_ManagerManageStaff
  33. from managersitereport import Ui_ManagerSiteReport
  34. from managerdailydetail import Ui_ManagerDailyDetail
  35. from staffmanageprofile import Ui_EmployeeManageProfile
  36. from staffviewschedule import Ui_StaffViewSchedule
  37. from staffeventdetail import Ui_StaffEventDetail
  38. from managercreateevent import Ui_ManagerCreateEvent
  39. from visitorexploreevent import Ui_VisitorExploreEvent
  40. from visitoreventdetail import Ui_VisitorEventDetail
  41. from visitorexploresite import Ui_VisitorExploreSite
  42. from visitortransitdetail import Ui_VisitorTransitDetail
  43. from visitorsitedetail import Ui_VisitorSiteDetail
  44. from visitorvisithistory import Ui_VisitorVisitHistory
  45. from managervieweditevent import Ui_ManagerViewEditEvent
  46.  
  47. def hashPassword(password):
  48.     import hashlib
  49.     return hashlib.md5(str(password).encode('utf-8')).hexdigest()
  50.  
  51. class PandasModel(QAbstractTableModel):
  52.     """
  53.     Class to populate a table view with a pandas dataframe
  54.     """
  55.     def __init__(self, data, parent=None):
  56.         QAbstractTableModel.__init__(self, parent)
  57.         self._data = data
  58.  
  59.     def rowCount(self, parent=None):
  60.         return len(self._data.values)
  61.  
  62.     def columnCount(self, parent=None):
  63.         return self._data.columns.size
  64.  
  65.     def data(self, index, role=Qt.DisplayRole):
  66.         if index.isValid():
  67.             if role == Qt.DisplayRole:
  68.                 return str(self._data.values[index.row()][index.column()])
  69.         return None
  70.  
  71.     def headerData(self, col, orientation, role):
  72.         if orientation == Qt.Horizontal and role == Qt.DisplayRole:
  73.             return self._data.columns[col]
  74.         return None
  75.  
  76. class loginwindow(QMainWindow, Ui_UserLogin):
  77.  
  78.     def __init__(self, parent= None):
  79.         super(loginwindow, self).__init__(parent)
  80.         self.setupUi(self)
  81.         self.loginbutton.clicked.connect(self.login_button)
  82.         self.registrationbutton.clicked.connect(self.register_button)
  83.         self.lineEdit_2.setEchoMode(QLineEdit.Password)
  84.  
  85.     def register_button(self):
  86.         self.window = registernavigation()
  87.         self.close()
  88.         self.window.show()
  89.  
  90.     def login_button(self):
  91.         USERNAME = self.lineEdit.text()
  92.         PASSWORD = self.lineEdit_2.text()
  93.  
  94.         connection = pymysql.connect(host="localhost",
  95.                                     user="root",
  96.                                     password="12345678",
  97.                                     db="beltline")
  98.         cursor = connection.cursor()
  99.         get_user = f"SELECT * FROM user WHERE username = '{USERNAME}' and password ='{hashPassword(PASSWORD)}'"
  100.  
  101.         self.currentuser = USERNAME
  102.  
  103.         if cursor.execute(get_user):
  104.  
  105.             type_query = f"SELECT usertype from user where username = '{USERNAME}' and password ='{hashPassword(PASSWORD)}'"
  106.             cursor.execute(type_query)
  107.             usertype = cursor.fetchone()[0]
  108.  
  109.             if usertype == "User":
  110.                 self.window = userfunctionality()
  111.                 self.close()
  112.                 self.window.show()
  113.  
  114.             elif usertype == "Visitor":
  115.                 self.window = visitorfunctionality()
  116.                 self.close()
  117.                 self.window.show()
  118.  
  119.             elif usertype == "Employee":
  120.                 employeetypequery = f"SELECT user.usertype, employee.employeetype from employee join user on user.username = employee.username where user.username = '{USERNAME}' and user.password = '{hashPassword(PASSWORD)}'"
  121.                 cursor.execute(employeetypequery)
  122.                 employee_type = cursor.fetchone()[1]
  123.  
  124.  
  125.                 if employee_type == "Staff":
  126.                     self.window = stafffunctionality()
  127.                     self.close()
  128.                     self.window.show()
  129.  
  130.                 elif employee_type == "Administrator":
  131.                     self.window = adminfunctionality()
  132.                     self.close()
  133.                     self.window.show()
  134.  
  135.                 elif employee_type == "Manager":
  136.                     self.window = managerfunctionality()
  137.                     self.close()
  138.                     self.window.show()
  139.  
  140.             elif usertype == "Employee-Visitor":
  141.  
  142.                 employeetypequery = f"SELECT user.usertype, employee.employeetype from employee join user on user.username = employee.username where user.username = '{USERNAME}' and user.password = '{hashPassword(PASSWORD)}'"
  143.                 cursor.execute(employeetypequery)
  144.                 employee_type = cursor.fetchone()[1]
  145.  
  146.  
  147.                 if employee_type == "Staff":
  148.                     self.window = staffvisitorfunctionality()
  149.                     self.close()
  150.                     self.window.show()
  151.  
  152.                 elif employee_type == "Administrator":
  153.                     self.window = adminvisitorfunctionality()
  154.                     self.close()
  155.                     self.window.show()
  156.  
  157.                 elif employee_type == "Manager":
  158.                     self.window = managervisitorfunctionality()
  159.                     self.close()
  160.                     self.window.show()
  161.  
  162.  
  163.         else:
  164.             print("Incorrect Login Info")
  165.  
  166. class registernavigation(QMainWindow, Ui_RegisterNavigation):
  167.     def __init__(self, parent= None):
  168.         super(registernavigation, self).__init__(parent)
  169.         self.setupUi(self)
  170.         self.BackButton.clicked.connect(self.back_button)
  171.         self.UserButton.clicked.connect(self.user_button)
  172.         self.VisitorButton.clicked.connect(self.visitor_button)
  173.         self.EmployeeButton.clicked.connect(self.employee_button)
  174.         self.EmployeeVisitorButton.clicked.connect(self.employee_visitor_button)
  175.  
  176.     def back_button(self):
  177.         # self.window = loginwindow()
  178.         self.close()
  179.         # self.window.show()
  180.         loginwindow.show()
  181.  
  182.     def user_button(self):
  183.         self.window = registeruser()
  184.         self.close()
  185.         self.window.show()
  186.     def visitor_button(self):
  187.         self.window = registervisitor()
  188.         self.close()
  189.         self.window.show()
  190.     def employee_button(self):
  191.         self.window = registeremployee()
  192.         self.close()
  193.         self.window.show()
  194.     def employee_visitor_button(self):
  195.         self.window = registeremployeevisitor()
  196.         self.close()
  197.         self.window.show()
  198.  
  199. class registeruser(QMainWindow, Ui_RegisterUser):
  200.     def __init__(self, parent= None):
  201.         super(registeruser, self).__init__(parent)
  202.         self.setupUi(self)
  203.         self.BackButton.clicked.connect(self.back_button)
  204.         self.registerButton.clicked.connect(self.register_button)
  205.         self.addEmailButton.clicked.connect(self.add_button)
  206.         self.removeEmailButton.clicked.connect(self.remove_button)
  207.         self.emailList = []
  208.  
  209.     def back_button(self):
  210.         self.window = registernavigation()
  211.         self.close()
  212.         self.window.show()
  213.  
  214.     def add_button(self):
  215.         emailText = self.emailEdit.text()
  216.         self.emailList.append(emailText)
  217.  
  218.     def remove_button(self):
  219.         emailText = self.emailEdit.text()
  220.         try:
  221.             self.emailList.remove(emailText)
  222.         except:
  223.             print('fail')
  224.  
  225.     def register_button(self):
  226.         firstname = self.firstNameEdit.text()
  227.         lastname = self.lastNameEdit.text()
  228.         USERNAME = self.usernameEdit.text()
  229.         PASSWORD = self.passEdit.text()
  230.         confirm_password = self.confirmPassEdit.text()
  231.         #email = self.emailEdit.text()
  232.  
  233.         if PASSWORD == confirm_password:
  234.             connection = pymysql.connect(host="localhost",
  235.                                         user="root",
  236.                                         password="12345678",
  237.                                         db="beltline")
  238.             cursor = connection.cursor()
  239.             insert_user = f"INSERT INTO user (Username,Firstname,Lastname,Status,UserType,Password) VALUES ('{USERNAME}', '{firstname}', '{lastname}', 'Pending', 'User', '{hashPassword(PASSWORD)}')"
  240.             if cursor.execute(insert_user):
  241.                 connection.commit()
  242.                 for email in self.emailList:
  243.                     insert_email = f"insert into email (Username, Email) values ('{USERNAME}', '{email}')"
  244.                     cursor.execute(insert_email)
  245.                     connection.commit()
  246.                 self.close()
  247.                 loginwindow.show()
  248.  
  249. class registervisitor(QMainWindow, Ui_RegisterVisitor):
  250.     def __init__(self, parent= None):
  251.         super(registervisitor, self).__init__(parent)
  252.         self.setupUi(self)
  253.         self.BackButton.clicked.connect(self.back_button)
  254.         self.addEmailButton.clicked.connect(self.add_button)
  255.         self.removeEmailButton.clicked.connect(self.remove_button)
  256.         self.registerButton.clicked.connect(self.register_button)
  257.         self.emailList = []
  258.  
  259.     def back_button(self):
  260.         self.window = registernavigation()
  261.         self.close()
  262.         self.window.show()
  263.  
  264.     def add_button(self):
  265.         emailText = self.emailEdit.text()
  266.         self.emailList.append(emailText)
  267.         print(emailText)
  268.  
  269.     def remove_button(self):
  270.         emailText = self.emailEdit.text()
  271.         try:
  272.             self.emailList.remove(emailText)
  273.         except:
  274.             print('fail')
  275.  
  276.     def register_button(self):
  277.         firstname = self.firstNameEdit.text()
  278.         lastname = self.lastNameEdit.text()
  279.         USERNAME = self.usernameEdit.text()
  280.         PASSWORD = self.passEdit.text()
  281.         confirm_password = self.confirmPassEdit.text()
  282.         #email = self.emailEdit.text()
  283.  
  284.         if PASSWORD == confirm_password:
  285.             connection = pymysql.connect(host="localhost",
  286.                                         user="root",
  287.                                         password="12345678",
  288.                                         db="beltline")
  289.             cursor = connection.cursor()
  290.             insert_user = f"INSERT INTO user (Username,Firstname,Lastname,Status,UserType,Password) VALUES ('{USERNAME}', '{firstname}', '{lastname}', 'Pending', 'Visitor', '{hashPassword(PASSWORD)}')"
  291.             if cursor.execute(insert_user):
  292.                 connection.commit()
  293.                 for email in self.emailList:
  294.                     insert_email = f"insert into email (Username, Email) values ('{USERNAME}', '{email}')"
  295.                     cursor.execute(insert_email)
  296.                     connection.commit()
  297.  
  298.                 self.close()
  299.                 loginwindow.show()
  300.  
  301. class registeremployee(QMainWindow, Ui_RegisterEmployee):
  302.     def __init__(self, parent= None):
  303.         super(registeremployee, self).__init__(parent)
  304.         self.setupUi(self)
  305.         self.BackButton.clicked.connect(self.back_button)
  306.         self.registerButton.clicked.connect(self.register_button)
  307.         self.addEmailButton.clicked.connect(self.add_button)
  308.         self.removeEmailButton.clicked.connect(self.remove_button)
  309.         self.emailList = []
  310.  
  311.         stateList = ['AK', 'AL', 'AR', 'AZ', 'CA', 'CO',
  312.              'CT', 'DC', 'DE', 'FL', 'GA', 'HI',
  313.              'IA', 'ID', 'IL', 'IN', 'KS', 'KY',
  314.              'LA', 'MA', 'MD', 'ME', 'MI', 'MN',
  315.              'MO', 'MS', 'MT', 'NC', 'ND', 'NE',
  316.              'NH', 'NJ', 'NM', 'NV', 'NY', 'OH',
  317.              'OK', 'OR', 'PA', 'RI', 'SC', 'SD',
  318.              'TN', 'TX', 'UT', 'VA', 'VT', 'WA',
  319.              'WI', 'WV', 'WY', 'Other']
  320.         self.stateComboBox.addItems(stateList)
  321.  
  322.         typeList = ['Manager', 'Staff']
  323.         self.stateComboBox_2.addItems(typeList)
  324.  
  325.     def back_button(self):
  326.         self.window = registernavigation()
  327.         self.close()
  328.         self.window.show()
  329.  
  330.     def add_button(self):
  331.         emailText = self.emailEdit.text()
  332.         self.emailList.append(emailText)
  333.  
  334.     def remove_button(self):
  335.         emailText = self.emailEdit.text()
  336.         try:
  337.             self.emailList.remove(emailText)
  338.         except:
  339.             print('fail')
  340.  
  341.  
  342.     def register_button(self):
  343.         firstname = self.firstNameEdit.text()
  344.         lastname = self.lastNameEdit.text()
  345.         USERNAME = self.usernameEdit.text()
  346.         PASSWORD = self.passEdit.text()
  347.         confirm_password = self.confirmPassEdit.text()
  348.         email = self.emailEdit.text()
  349.         address = self.addressEdit.text()
  350.         phone = self.phoneEdit.text()
  351.         zipc = self.zipcodeEdit.text()
  352.         city = self.cityEdit.text()
  353.         state = self.stateComboBox.currentText()
  354.         employeetype = self.stateComboBox_2.currentText()
  355.         print(state)
  356.         print(employeetype)
  357.  
  358.  
  359.         if PASSWORD == confirm_password:
  360.             connection = pymysql.connect(host="localhost",
  361.                                         user="root",
  362.                                         password="12345678",
  363.                                         db="beltline")
  364.             cursor = connection.cursor()
  365.             insert_user = f"INSERT INTO user (Username,Firstname,Lastname,Status,UserType,Password) VALUES ('{USERNAME}', '{firstname}', '{lastname}', 'Pending', 'Employee', '{hashPassword(PASSWORD)}')"
  366.             cursor.execute(insert_user)
  367.             connection.commit()
  368.  
  369.             get_id = f"select employeeID from employee"
  370.             cursor.execute(get_id)
  371.             id_list = cursor.fetchall()
  372.             newID = int(id_list[-1][0]) + 1
  373.  
  374.  
  375.             insert_employee = f"INSERT INTO employee (EmployeeID,Username,Phone,Address, City, State, Zipcode, EmployeeType) values ('{newID}','{USERNAME}', '{phone}', '{address}', '{city}', '{state}', '{zipc}', '{employeetype}')"
  376.             cursor.execute(insert_employee)
  377.             connection.commit()
  378.  
  379.  
  380.             for email in self.emailList:
  381.                 insert_email = f"insert into email (Username, Email) values ('{USERNAME}', '{email}')"
  382.                 cursor.execute(insert_email)
  383.                 connection.commit()
  384.  
  385.             self.close()
  386.             loginwindow.show()
  387.  
  388. class registeremployeevisitor(QMainWindow, Ui_RegisterEmployeeVisitor):
  389.     def __init__(self, parent= None):
  390.         super(registeremployeevisitor, self).__init__(parent)
  391.         self.setupUi(self)
  392.         self.BackButton.clicked.connect(self.back_button)
  393.         self.registerButton.clicked.connect(self.register_button)
  394.         stateList = ['AK', 'AL', 'AR', 'AZ', 'CA', 'CO',
  395.              'CT', 'DC', 'DE', 'FL', 'GA', 'HI',
  396.              'IA', 'ID', 'IL', 'IN', 'KS', 'KY',
  397.              'LA', 'MA', 'MD', 'ME', 'MI', 'MN',
  398.              'MO', 'MS', 'MT', 'NC', 'ND', 'NE',
  399.              'NH', 'NJ', 'NM', 'NV', 'NY', 'OH',
  400.              'OK', 'OR', 'PA', 'RI', 'SC', 'SD',
  401.              'TN', 'TX', 'UT', 'VA', 'VT', 'WA',
  402.              'WI', 'WV', 'WY', 'Other']
  403.         self.stateComboBox.addItems(stateList)
  404.  
  405.         typeList = ['Manager', 'Staff']
  406.         self.stateComboBox_2.addItems(typeList)
  407.         self.addEmailButton.clicked.connect(self.add_button)
  408.         self.removeEmailButton.clicked.connect(self.remove_button)
  409.         self.emailList = []
  410.  
  411.  
  412.     def back_button(self):
  413.         self.window = registernavigation()
  414.         self.close()
  415.         self.window.show()
  416.  
  417.     def add_button(self):
  418.         emailText = self.emailEdit.text()
  419.         self.emailList.append(emailText)
  420.  
  421.     def remove_button(self):
  422.         emailText = self.emailEdit.text()
  423.         try:
  424.             self.emailList.remove(emailText)
  425.         except:
  426.             print('fail')
  427.  
  428.     def register_button(self):
  429.         firstname = self.firstNameEdit.text()
  430.         lastname = self.lastNameEdit.text()
  431.         USERNAME = self.usernameEdit.text()
  432.         PASSWORD = self.passEdit.text()
  433.         confirm_password = self.confirmPassEdit.text()
  434.         email = self.emailEdit.text()
  435.         address = self.addressEdit.text()
  436.         phone = self.phoneEdit.text()
  437.         zipc = self.zipcodeEdit.text()
  438.         city = self.cityEdit.text()
  439.         state = self.stateComboBox.currentText()
  440.         employeetype = self.stateComboBox_2.currentText()
  441.  
  442.  
  443.  
  444.         if PASSWORD == confirm_password:
  445.             connection = pymysql.connect(host="localhost",
  446.                                         user="root",
  447.                                         password="12345678",
  448.                                         db="beltline")
  449.             cursor = connection.cursor()
  450.             insert_user = f"INSERT INTO user (Username,Firstname,Lastname,Status,UserType,Password) VALUES ('{USERNAME}', '{firstname}', '{lastname}', 'Pending', 'Employee-Visitor', '{hashPassword(PASSWORD)}')"
  451.             cursor.execute(insert_user)
  452.             connection.commit()
  453.  
  454.             get_id = f"select employeeID from employee"
  455.             cursor.execute(get_id)
  456.             id_list = cursor.fetchall()
  457.             newID = int(id_list[-1][0]) + 1
  458.  
  459.             insert_employee = f"INSERT INTO employee (EmployeeID,Username,Phone,Address, City, State, Zipcode, EmployeeType) values ({newID},'{USERNAME}', '{phone}', '{address}', '{city}', '{state}', '{zipc}', '{employeetype}')"
  460.             cursor.execute(insert_employee)
  461.             connection.commit()
  462.  
  463.             for email in self.emailList:
  464.                 insert_email = f"insert into email (Username, Email) values ('{USERNAME}', '{email}')"
  465.                 cursor.execute(insert_email)
  466.                 connection.commit()
  467.  
  468.             self.close()
  469.             loginwindow.show()
  470.  
  471. class userfunctionality(QMainWindow, Ui_UserFunctionality):
  472.     def __init__(self, parent= None):
  473.         super(userfunctionality, self).__init__(parent)
  474.         self.setupUi(self)
  475.         self.BackButton.clicked.connect(self.back_button)
  476.         self.ViewTransitButton.clicked.connect(self.viewtransit)
  477.         self.TakeTransitButton.clicked.connect(self.taketransit)
  478.  
  479.  
  480.     def back_button(self):
  481.         # self.window = loginwindow()
  482.         self.close()
  483.         # self.window.show()
  484.         loginwindow.show()
  485.  
  486.     def taketransit(self):
  487.         self.window =usertaketransit()
  488.         self.close()
  489.         self.window.show()
  490.  
  491.     def viewtransit(self):
  492.         self.window = userviewtransithistory()
  493.         self.close()
  494.         self.window.show()
  495.  
  496. class userviewtransithistory(QMainWindow, Ui_UserTransitHistory):
  497.     def __init__(self, parent= None):
  498.         super(userviewtransithistory, self).__init__(parent)
  499.         self.setupUi(self)
  500.         self.BackButton.clicked.connect(self.back_button)
  501.         self.filterButton.clicked.connect(self.filter_button)
  502.         connection = pymysql.connect(host="localhost",
  503.                                         user="root",
  504.                                         password="12345678",
  505.                                         db="beltline")
  506.         cursor = connection.cursor()
  507.         managequery = f"select take.date, take.route, transit.transittype, transit.price from transit join take on take.route = transit.route where take.username ='{loginwindow.currentuser}' group by transit.route"
  508.         df = pd.read_sql(managequery, connection)
  509.         model = PandasModel(df)
  510.         self.tableView.setModel(model)
  511.  
  512.  
  513.  
  514.         self.comboBox.addItems(['MARTA', 'Bus', 'Bike'])
  515.  
  516.         siteQuery = f"select name from site"
  517.         cursor.execute(siteQuery)
  518.         list1OfSites = cursor.fetchall()
  519.         listOfSites = []
  520.         for a in list1OfSites:
  521.             listOfSites.append(a[0])
  522.         self.comboBox_2.addItems(listOfSites)
  523.  
  524.  
  525.     def back_button(self):
  526.         self.window = userfunctionality()
  527.         self.close()
  528.         self.window.show()
  529.  
  530.     def filter_button(self):
  531.         contain_site = self.comboBox_2.currentText()
  532.         transport_type= self.comboBox.currentText()
  533.         route = self.lineEdit.text()
  534.         start_date = self.lineEdit_2.text()
  535.         end_date = self.lineEdit_3.text()
  536.  
  537.         connection = pymysql.connect(host="localhost",
  538.                                         user="root",
  539.                                         password="12345678",
  540.                                         db="beltline")
  541.         cursor = connection.cursor()
  542.         managequery = f"select take.date, take.route, transit.transittype, transit.price from transit join take on take.route = transit.route join connect on connect.route where take.username ='{loginwindow.currentuser}' and connect.name = '{contain_site}' and transit.TransitType = '{transport_type}' and take.route ='{route}' and take.date between '{start_date}' and '{end_date}' group by transit.route"
  543.  
  544.         df = pd.read_sql(managequery, connection)
  545.         model = PandasModel(df)
  546.         self.tableView.setModel(model)
  547.  
  548. class usertaketransit(QMainWindow, Ui_UserTakeTransit):
  549.     def __init__(self, parent= None):
  550.         super(usertaketransit, self).__init__(parent)
  551.         self.setupUi(self)
  552.         self.BackButton.clicked.connect(self.back_button)
  553.         self.filterButton.clicked.connect(self.filter_button)
  554.         self.logTransitButton.clicked.connect(self.logTransit_button)
  555.         self.comboBox_2.addItems(["Bus", "Bike", "MARTA"])
  556.         connection = pymysql.connect(host="localhost",
  557.                                         user="root",
  558.                                         password="12345678",
  559.                                         db="beltline")
  560.  
  561.         cursor = connection.cursor()
  562.         managequery = f"select transit.route, transit.transittype, transit.price, count(connect.route) as '# Connected Sites' from transit join connect on connect.route = transit.route join take on take.route = transit.route group by transit.route"
  563.         df = pd.read_sql(managequery, connection)
  564.         model = PandasModel(df)
  565.         self.tableView.setModel(model)
  566.  
  567.         siteQuery = f"select name from site"
  568.         cursor.execute(siteQuery)
  569.         list1OfSites = cursor.fetchall()
  570.         listOfSites = []
  571.         for a in list1OfSites:
  572.             listOfSites.append(a[0])
  573.  
  574.         self.comboBox.addItems(listOfSites)
  575.  
  576.  
  577.         self.comboBox_2.addItems(['MARTA', 'Bus', 'Bike'])
  578.  
  579.         self.tableView.setSelectionBehavior(QTableView.SelectRows)
  580.         self.tableView.setSelectionMode(QAbstractItemView.SingleSelection)
  581.  
  582.  
  583.  
  584.  
  585.  
  586.     def back_button(self):
  587.         self.window = userfunctionality()
  588.         self.close()
  589.         self.window.show()
  590.  
  591.     def filter_button(self):
  592.         contain_site = self.comboBox.currentText()
  593.         transport_type= self.comboBox_2.currentText()
  594.         price_low = self.lineEdit.text()
  595.         price_high = self.lineEdit_2.text()
  596.         # transit_date = lineEdit_3.text()
  597.  
  598.         connection = pymysql.connect(host="localhost",
  599.                                         user="root",
  600.  
  601.                                         password="12345678",
  602.  
  603.  
  604.                                         db="beltline")
  605.         cursor = connection.cursor()
  606.         managequery = f"select transit.route, transit.transittype, transit.price, count(connect.route) as '# Connected Sites' from transit join connect on connect.route = transit.route join take on take.route = transit.route  where connect.name = 'Inman Park' and connect.TransitType = 'Bus' and transit.price between '{price_low}' and '{price_high}' group by transit.route"
  607.         df = pd.read_sql(managequery, connection)
  608.         model = PandasModel(df)
  609.         self.tableView.setModel(model)
  610.     def logTransit_button(self):
  611.         transport_type= self.comboBox_2.currentText()
  612.         price_low = self.lineEdit.text()
  613.         price_high = self.lineEdit_2.text()
  614.  
  615.  
  616.         connection = pymysql.connect(host="localhost",
  617.                                         user="root",
  618.                                         password="12345678",
  619.                                         db="beltline")
  620.         cursor = connection.cursor()
  621.         userlist = self.tableView.selectionModel().selectedRows()
  622.         for i in userlist:
  623.             index = i.row()
  624.  
  625.         model = self.tableView.model()
  626.         print(model.rowCount())
  627.         route = model.index(index, 0).data()
  628.         transitType = model.index(index, 1).data()
  629.  
  630.         print(route, transitType)
  631.  
  632.         logTransit = f"insert into take (Username, TransitType, Route, Date) values ('{loginwindow.currentuser}', '{transitType}', '{route}', '{self.lineEdit_3.text()}')"
  633.         cursor.execute(logTransit)
  634.         connection.commit()
  635.  
  636. class adminfunctionality(QMainWindow, Ui_AdminFunctionality):
  637.     def __init__(self, parent= None):
  638.         super(adminfunctionality, self).__init__(parent)
  639.         self.setupUi(self)
  640.         self.BackButton.clicked.connect(self.back_button)
  641.         self.ManageSiteButton.clicked.connect(self.managesite_button)
  642.         self.ManageUserButton.clicked.connect(self.manageuser_button)
  643.         self.ManageTransitButton.clicked.connect(self.managetransit_button)
  644.         self.manageProfileButton.clicked.connect(self.manageprofile_button)
  645.         self.ViewTransitButton.clicked.connect(self.viewtransit)
  646.         self.TakeTransitButton.clicked.connect(self.taketransit)
  647.  
  648.     def back_button(self):
  649.         # self.window = loginwindow()
  650.         self.close()
  651.         # self.window.show()
  652.         loginwindow.show()
  653.  
  654.     def managesite_button(self):
  655.         self.window = adminmanagesite()
  656.         self.close()
  657.         self.window.show()
  658.     def manageuser_button(self):
  659.         self.window = adminmanageuser()
  660.         self.close()
  661.         self.window.show()
  662.     def managetransit_button(self):
  663.         self.window = adminmanagetransit()
  664.         self.close()
  665.         self.window.show()
  666.     def manageprofile_button(self):
  667.         self.window = staffmanageprofile()
  668.         self.close()
  669.         self.window.show()
  670.     def taketransit(self):
  671.         self.window =usertaketransit()
  672.         self.close()
  673.         self.window.show()
  674.  
  675.     def viewtransit(self):
  676.         self.window = userviewtransithistory()
  677.         self.close()
  678.         self.window.show()
  679.  
  680. class adminmanageuser(QMainWindow, Ui_AdminManageUser):
  681.     def __init__(self, parent= None):
  682.         super(adminmanageuser, self).__init__(parent)
  683.         self.setupUi(self)
  684.         self.BackButton.clicked.connect(self.back_button)
  685.         self.approveButton.clicked.connect(self.approve_button)
  686.         self.declineButton.clicked.connect(self.decline_button)
  687.         self.filterButton.clicked.connect(self.filter_button)
  688.  
  689.         self.statusComboBox.addItems(["Approved", "Pending", "Declined"])
  690.         self.typeComboBox.addItems(["User", "Visitor", "Employee", "Manager"])
  691.  
  692.  
  693.         connection = pymysql.connect(host="localhost",
  694.                                     user="root",
  695.                                     password="12345678",
  696.                                     db="beltline")
  697.         cursor = connection.cursor()
  698.  
  699.  
  700.  
  701.  
  702.         managequery = f"select user.username, count(email), user.usertype, user.status from user join email on email.username = user.username group by user.username"
  703.         df = pd.read_sql(managequery, connection)
  704.         model = PandasModel(df)
  705.         self.tableView.setModel(model)
  706.  
  707.  
  708.     def back_button(self):
  709.         self.window = adminfunctionality()
  710.         self.close()
  711.         self.window.show()
  712.     def approve_button(self, managequery):
  713.         userlist = self.tableView.selectionModel().selectedRows()
  714.         for i in userlist:
  715.             index = i.row()
  716.         connection = pymysql.connect(host="localhost",
  717.                                     user="root",
  718.                                     password="12345678",
  719.                                     db="beltline")
  720.         cursor = connection.cursor()
  721.         managequery = f"select user.username, count(email), user.usertype, user.status from user join email on email.username = user.username group by user.username"
  722.         cursor.execute(managequery)
  723.  
  724.         username = cursor.fetchall()[index][0]
  725.  
  726.         updateuser = f"update user set status = 'Approved' where Username = '{username}'"
  727.         cursor.execute(updateuser)
  728.         connection.commit()
  729.         self.update()
  730.     def decline_button(self, managequery):
  731.         userlist = self.tableView.selectionModel().selectedRows()
  732.         for i in userlist:
  733.             index = i.row()
  734.         connection = pymysql.connect(host="localhost",
  735.                                     user="root",
  736.                                     password="12345678",
  737.                                     db="beltline")
  738.         cursor = connection.cursor()
  739.         managequery = f"select user.username, count(email), user.usertype, user.status from user join email on email.username = user.username group by user.username"
  740.         cursor.execute(managequery)
  741.  
  742.         fetchedData = cursor.fetchall()
  743.         username = fetchedData[index][0]
  744.         status = fetchedData[index][3]
  745.  
  746.         # updateuser = f"update user set status = 'Declined' where Username = '{username}'"
  747.  
  748.         if status != 'Approved':
  749.             updateuser = f"update user set status = 'Declined' where Username = '{username}'"
  750.             cursor.execute(updateuser)
  751.             connection.commit()
  752.         else:
  753.             print("Can't Deny an Approved Account")
  754.  
  755.     def filter_button(self):
  756.  
  757.         USERNAME = self.usernameEdit.text()
  758.         Status = self.statusComboBox.currentText()
  759.         userType = self.typeComboBox.currentText()
  760.  
  761.         connection = pymysql.connect(host="localhost",
  762.                                     user="root",
  763.                                     password="12345678",
  764.                                     db="beltline")
  765.         cursor = connection.cursor()
  766.         if USERNAME != "":
  767.             filterquery = f"select user.username, count(email), user.usertype, user.status from user join email on email.username = user.username where user.UserType = '{userType}' and Status = '{Status}' group by user.username"
  768.         else:
  769.             filterquery = f"select user.username, count(email), user.usertype, user.status from user join email on email.username = user.username where user.username ='{USERNAME}' and user.UserType = '{userType}' and Status = '{Status}' group by user.username"
  770.  
  771.         df = pd.read_sql(filterquery, connection)
  772.         model = PandasModel(df)
  773.         self.tableView.setModel(model)
  774.  
  775. class adminmanagesite(QMainWindow, Ui_AdminManageSite):
  776.     def __init__(self, parent= None):
  777.         super(adminmanagesite, self).__init__(parent)
  778.         self.setupUi(self)
  779.         self.BackButton.clicked.connect(self.back_button)
  780.         self.editButton.clicked.connect(self.edit_button)
  781.         self.deleteButton.clicked.connect(self.delete_button)
  782.         self.createButton.clicked.connect(self.create_button)
  783.         self.filterButton.clicked.connect(self.filter_button)
  784.  
  785.         connection = pymysql.connect(host="localhost",
  786.                                     user="root",
  787.                                     password="12345678",
  788.                                     db="beltline")
  789.         cursor = connection.cursor()
  790.         managequery = f"select site.name, concat(user.firstname, ' ' , user.lastname), site.openeveryday from site join employee on site.manager = employee.employeeid join user on user.username = employee.username"
  791.         df = pd.read_sql(managequery, connection)
  792.         model = PandasModel(df)
  793.         self.tableView.setModel(model)
  794.         self.tableView.setSelectionBehavior(QTableView.SelectRows)
  795.         self.tableView.setSelectionMode(QAbstractItemView.SingleSelection)
  796.  
  797.     def back_button(self):
  798.         self.window = adminfunctionality()
  799.         self.close()
  800.         self.window.show()
  801.     def edit_button(self):
  802.         userlist = self.tableView.selectionModel().selectedRows()
  803.         index=0
  804.         for i in userlist:
  805.             index = i.row()
  806.         connection = pymysql.connect(host="localhost",
  807.                                     user="root",
  808.                                     password="12345678",
  809.                                     db="beltline")
  810.         cursor = connection.cursor()
  811.         managequery = f"select site.name, concat(user.firstname, ' ' , user.lastname), site.openeveryday from site join employee on site.manager = employee.employeeid join user on user.username = employee.username"
  812.         cursor.execute(managequery)
  813.  
  814.         name = cursor.fetchall()[index][0]
  815.         self.window = admineditsite(name)
  816.         self.close()
  817.         self.window.show()
  818.     # def delete_button(self):
  819.     def create_button(self):
  820.         userlist = self.tableView.selectionModel().selectedRows()
  821.         for i in userlist:
  822.             index = i.row()
  823.         self.window = admincreatesite()
  824.         self.close()
  825.         self.window.show()
  826.  
  827.     def delete_button(self):
  828.         userlist = self.tableView.selectionModel().selectedRows()
  829.         index=0
  830.         for i in userlist:
  831.             index = i.row()
  832.             print(index)
  833.         connection = pymysql.connect(host="localhost",
  834.                                     user="root",
  835.                                     password="12345678",
  836.                                     db="beltline")
  837.         cursor = connection.cursor()
  838.         managequery = f"select site.name, concat(user.firstname, ' ' , user.lastname), site.openeveryday from site join employee on site.manager = employee.employeeid join user on user.username = employee.username"
  839.         cursor.execute(managequery)
  840.  
  841.         name = cursor.fetchall()[index][0]
  842.         print(name)
  843.         deletesite = f"delete from site where name = '{name}'"
  844.         cursor.execute(deletesite)
  845.         connection.commit()
  846.         # self.update()
  847.     def filter_button(self):
  848.  
  849.         # site =
  850.         # manager
  851.         # openeveryday =
  852.  
  853.         connection = pymysql.connect(host="localhost",
  854.                                     user="root",
  855.  
  856.                                     password="12345678",
  857.  
  858.  
  859.                                     db="beltline")
  860.         cursor = connection.cursor()
  861.  
  862.         filterquery = f"select site.name, concat(user.firstname, ' ' , user.lastname), site.openeveryday from site join employee on site.manager = employee.employeeid join user on user.username = employee.username where site.name = 'Inman Park' and concat(user.firstname, ' ' , user.lastname) = 'David Smith' and site.openeveryday = 'YES'"
  863.  
  864.         df = pd.read_sql(filterquery, connection)
  865.         model = PandasModel(df)
  866.         self.tableView.setModel(model)
  867.  
  868. class admineditsite(QMainWindow, Ui_AdminEditSite):
  869.     def __init__(self, name, parent= None):
  870.         super(admineditsite, self).__init__(parent)
  871.         print(name)
  872.         self.setupUi(self)
  873.         self.BackButton.clicked.connect(self.back_button)
  874.         self.updateButton.clicked.connect(self.update_button)
  875.         self.name = name
  876.  
  877.     def update_button(self):
  878.         address = self.addressEdit.text()
  879.         zipc = self.zipcodeEdit.text()
  880.         name = self.nameEdit.text()
  881.         openeveryday = "YES" if self.checkBox.isChecked() else "NO"
  882.  
  883.         connection = pymysql.connect(host="localhost",
  884.                                     user="root",
  885.                                     password="12345678",
  886.                                     db="beltline")
  887.         cursor = connection.cursor()
  888.         edit_site = f"update site set Name = '{name}', Address = '{address}', Zipcode = '{zipc}', OpenEveryday = '{openeveryday}' where Name = '{self.name}'"
  889.         cursor.execute(edit_site)
  890.         connection.commit()
  891.         self.window = adminfunctionality()
  892.         self.close()
  893.         self.window.show()
  894.  
  895.  
  896.     def back_button(self):
  897.         self.window = adminmanagesite()
  898.         self.close()
  899.         self.window.show()
  900.  
  901. class admincreatesite(QMainWindow, Ui_AdminCreateSite):
  902.     def __init__(self, parent= None):
  903.         super(admincreatesite, self).__init__(parent)
  904.         self.setupUi(self)
  905.         self.BackButton.clicked.connect(self.back_button)
  906.         self.updateButton.clicked.connect(self.create_button)
  907.  
  908.  
  909.     def back_button(self):
  910.         self.window = adminmanagesite()
  911.         self.close()
  912.         self.window.show()
  913.  
  914.     def create_button(self):
  915.  
  916.         sitename = self.nameEdit.text()
  917.         zipc = self.zipcodeEdit.text()
  918.         address = self.addressEdit.text()
  919.         # manager = self.managerComboBox.text()
  920.         openeveryday = "YES" if self.checkBox.isChecked() else "NO"
  921.  
  922.  
  923.  
  924.         connection = pymysql.connect(host="localhost",
  925.                                     user="root",
  926.                                     password="12345678",
  927.                                     db="beltline")
  928.         cursor = connection.cursor()
  929.         insert_site = f"INSERT INTO site (Name,Address,Zipcode,OpenEveryday,Manager) VALUES ('{sitename}', '{zipc}', '{address}', '{openeveryday}','000000006')"
  930.         if cursor.execute(insert_site):
  931.             connection.commit()
  932.             self.close()
  933.             self.window = adminmanagesite()
  934.             self.window.show()
  935.  
  936. class adminmanagetransit(QMainWindow, Ui_AdminManageTransit):
  937.     def __init__(self, parent= None):
  938.         super(adminmanagetransit, self).__init__(parent)
  939.         self.setupUi(self)
  940.         self.BackButton.clicked.connect(self.back_button)
  941.         self.editButton.clicked.connect(self.edit_button)
  942.         self.deleteButton.clicked.connect(self.delete_button)
  943.         self.createButton.clicked.connect(self.create_button)
  944.         self.filterButton.clicked.connect(self.filter_button)
  945.         connection = pymysql.connect(host="localhost",
  946.                                     user="root",
  947.                                     password="12345678",
  948.                                     db="beltline")
  949.         cursor = connection.cursor()
  950.         #Need CY to do query
  951.         managetransit = f"select transit.route, transit.transittype, transit.price, count(connect.route) as '# Connected Sites', count(take.route) as '# Transits Logged' from transit join connect on connect.route = transit.route join take on take.route = transit.route group by transit.route"
  952.         df = pd.read_sql(managetransit, connection)
  953.         model = PandasModel(df)
  954.         self.tableView.setModel(model)
  955.         self.tableView.setSelectionBehavior(QTableView.SelectRows)
  956.         self.tableView.setSelectionMode(QAbstractItemView.SingleSelection)
  957.  
  958.     def back_button(self):
  959.         self.window = adminfunctionality()
  960.         self.close()
  961.         self.window.show()
  962.     def edit_button(self):
  963.         userlist = self.tableView.selectionModel().selectedRows()
  964.         index=0
  965.         for i in userlist:
  966.             index = i.row()
  967.             print(index)
  968.         connection = pymysql.connect(host="localhost",
  969.                                     user="root",
  970.                                     password="12345678",
  971.                                     db="beltline")
  972.         cursor = connection.cursor()
  973.         managequery = f"select transit.route, transit.transittype, transit.price, count(connect.route) as '# Connected Sites', count(take.route) as '# Transits Logged' from transit join connect on connect.route = transit.route join take on take.route = transit.route group by transit.route"
  974.         cursor.execute(managequery)
  975.  
  976.         route = cursor.fetchall()[index][0]
  977.         self.window = adminedittransit(route)
  978.         self.close()
  979.         self.window.show()
  980.     # def delete_button(self):
  981.     def create_button(self):
  982.         userlist = self.tableView.selectionModel().selectedRows()
  983.         for i in userlist:
  984.             index = i.row()
  985.         self.window = admincreatetransit()
  986.         self.close()
  987.         self.window.show()
  988.  
  989.     def delete_button(self):
  990.         userlist = self.tableView.selectionModel().selectedRows()
  991.         index=0
  992.         for i in userlist:
  993.             index = i.row()
  994.             print(index)
  995.         connection = pymysql.connect(host="localhost",
  996.                                     user="root",
  997.                                     password="12345678",
  998.                                     db="beltline")
  999.         cursor = connection.cursor()
  1000.         managequery = f"select transit.route, transit.transittype, transit.price, count(connect.route) as '# Connected Sites', count(take.route) as '# Transits Logged' from transit join connect on connect.route = transit.route join take on take.route = transit.route group by transit.route"
  1001.         cursor.execute(managequery)
  1002.  
  1003.         route = cursor.fetchall()[index][0]
  1004.         print(route)
  1005.         deletetransit = f"delete from transit where route = '{route}'"
  1006.         cursor.execute(deletetransit)
  1007.         connection.commit()
  1008.  
  1009.     def filter_button(self):
  1010.  
  1011.         route = self.routeEdit.text()
  1012.         price_low = self.price1.text()
  1013.         price_high = self.price2.text()
  1014.  
  1015.         connection = pymysql.connect(host="localhost",
  1016.                                     user="root",
  1017.  
  1018.                                     password="12345678",
  1019.  
  1020.  
  1021.                                     db="beltline")
  1022.         cursor = connection.cursor()
  1023.         filterquery = f"select transit.route, transit.transittype, transit.price, count(connect.route) as '# Connected Sites', count(take.route) as '# Transits Logged' from transit join connect on connect.route = transit.route join take on take.route = transit.route where transit.route ='{route}' and transit.price between '{price_low}' and '{price_high}' and transit.transittype = 'BUS' group by transit.route"
  1024.         df = pd.read_sql(filterquery, connection)
  1025.         model = PandasModel(df)
  1026.         self.tableView.setModel(model)
  1027.         # self.update())
  1028.  
  1029. class adminedittransit(QMainWindow, Ui_AdminEditTransit):
  1030.     def __init__(self, route, parent= None):
  1031.         super(adminedittransit, self).__init__(parent)
  1032.         print(route)
  1033.  
  1034.         connection = pymysql.connect(host="localhost",
  1035.                                     user="root",
  1036.                                     password="12345678",
  1037.                                     db="beltline")
  1038.         cursor = connection.cursor()
  1039.         get_transport_type = f"select TransitType from transit where route = '{route}'"
  1040.         cursor.execute(get_transport_type)
  1041.         transitType = cursor.fetchone()[0]
  1042.         print(transitType)
  1043.  
  1044.         self.route = route
  1045.         self.setupUi(self)
  1046.         self.transportTypeLabel.setText(transitType)
  1047.         self.BackButton.clicked.connect(self.back_button)
  1048.         self.updateButton.clicked.connect(self.update_button)
  1049.  
  1050.         get_site = f"select name from site"
  1051.         df = pd.read_sql(get_site, connection)
  1052.         model = PandasModel(df)
  1053.         self.tableView.setModel(model)
  1054.         self.tableView.setSelectionMode(QAbstractItemView.MultiSelection)
  1055.  
  1056.         cursor.execute(get_site)
  1057.         full1ListOfNames = cursor.fetchall()
  1058.         fullListOfNames = []
  1059.         for name in full1ListOfNames:
  1060.             fullListOfNames.append(name[0])
  1061.         newNameQuery = f"select name from connect where transittype = '{self.transportTypeLabel.text()}' and route = '{self.route}'"
  1062.         cursor.execute(newNameQuery)
  1063.         selected1Names = cursor.fetchall()
  1064.         selectedNames = []
  1065.         for name in selected1Names:
  1066.             selectedNames.append(name[0])
  1067.  
  1068.         for i in range(0, len(fullListOfNames)):
  1069.             if fullListOfNames[i] in selectedNames:
  1070.                 self.tableView.selectRow(i)
  1071.  
  1072.  
  1073.     def update_button(self):
  1074.         route = self.routeEdit.text()
  1075.         price = self.priceEdit.text()
  1076.  
  1077.         connection = pymysql.connect(host="localhost",
  1078.                                     user="root",
  1079.                                     password="12345678",
  1080.                                     db="beltline")
  1081.  
  1082.         cursor = connection.cursor()
  1083.  
  1084.         userlist = self.tableView.selectionModel().selectedRows()
  1085.         listOfIndexes = []
  1086.         for i in userlist:
  1087.             listOfIndexes.append(i.row())
  1088.         print(listOfIndexes)
  1089.  
  1090.         nameQuery = f"select name from site"
  1091.         cursor.execute(nameQuery)
  1092.         fullListOfNames = cursor.fetchall()
  1093.         listOfNames = []
  1094.         for i in range(0, len(fullListOfNames)):
  1095.             if i in listOfIndexes:
  1096.                 listOfNames.append(fullListOfNames[i][0])
  1097.  
  1098.         print(self.transportTypeLabel.text())
  1099.         deleteQuery = f"delete from connect where transittype = '{self.transportTypeLabel.text()}' and route = '{self.route}'"
  1100.         print(cursor.execute(deleteQuery))
  1101.         connection.commit()
  1102.  
  1103.         edit_transit = f"update transit set Route = '{route}', Price = '{price}' where Route = '{self.route}'"
  1104.         cursor.execute(edit_transit)
  1105.         connection.commit()
  1106.  
  1107.         for name in listOfNames:
  1108.             insertQuery = f"insert into connect (Name, TransitType, Route) values ('{name}', '{self.transportTypeLabel.text()}', '{route}')"
  1109.             print(cursor.execute(insertQuery))
  1110.             connection.commit()
  1111.  
  1112.         self.window = adminmanagetransit()
  1113.         self.close()
  1114.         self.window.show()
  1115.  
  1116.     def back_button(self):
  1117.         self.window = adminmanagetransit()
  1118.         self.close()
  1119.         self.window.show()
  1120.  
  1121. class admincreatetransit(QMainWindow, Ui_AdminCreateTransit):
  1122.     def __init__(self, parent= None):
  1123.         super(admincreatetransit, self).__init__(parent)
  1124.         self.setupUi(self)
  1125.         self.BackButton.clicked.connect(self.back_button)
  1126.         self.createButton.clicked.connect(self.create_button)
  1127.  
  1128.         connection = pymysql.connect(host="localhost",
  1129.                                     user="root",
  1130.                                     password="12345678",
  1131.                                     db="beltline")
  1132.         cursor = connection.cursor()
  1133.         get_site = f"select name from site"
  1134.         df = pd.read_sql(get_site, connection)
  1135.         model = PandasModel(df)
  1136.         self.tableView.setModel(model)
  1137.  
  1138.         transportTypes = ['MARTA', 'Bus', 'Bike']
  1139.         self.transportTypeLabel.addItems(transportTypes)
  1140.  
  1141.  
  1142.  
  1143.  
  1144.     def back_button(self):
  1145.         self.window = adminmanagetransit()
  1146.         self.close()
  1147.         self.window.show()
  1148.     def create_button(self):
  1149.         route = self.routeEdit.text()
  1150.         price = self.priceEdit.text()
  1151.  
  1152.         connection = pymysql.connect(host="localhost",
  1153.                                     user="root",
  1154.                                     password="12345678",
  1155.                                     db="beltline")
  1156.         cursor = connection.cursor()
  1157.         create_site = f"insert into transit (Route, TransitType, Price) values ('{route}', '{str(self.transportTypeLabel.currentText())}', '{price}')"
  1158.         cursor.execute(create_site)
  1159.         connection.commit()
  1160.  
  1161.         userlist = self.tableView.selectionModel().selectedRows()
  1162.         listOfIndexes = []
  1163.         for i in userlist:
  1164.             listOfIndexes.append(i.row())
  1165.  
  1166.         nameQuery = f"select name from site"
  1167.         cursor.execute(nameQuery)
  1168.         fullListOfNames = cursor.fetchall()
  1169.         listOfNames = []
  1170.         for i in range(0, len(fullListOfNames)):
  1171.             if i in listOfIndexes:
  1172.                 listOfNames.append(fullListOfNames[i][0])
  1173.  
  1174.         for name in listOfNames:
  1175.             insertQuery = f"insert into connect (Name, TransitType, Route) values ('{name}', '{str(self.transportTypeLabel.currentText())}', '{route}')"
  1176.             print(cursor.execute(insertQuery))
  1177.             connection.commit()
  1178.  
  1179.  
  1180.  
  1181.  
  1182.         self.window = adminmanagetransit()
  1183.         self.close()
  1184.         self.window.show()
  1185.  
  1186. #starting from here: create, edit delete, filter buttons need to have correct functionality
  1187. class managerfunctionality(QMainWindow, Ui_ManagerFunctionality):
  1188.     def __init__(self, parent= None):
  1189.         super(managerfunctionality, self).__init__(parent)
  1190.         self.setupUi(self)
  1191.         self.BackButton.clicked.connect(self.back_button)
  1192.         self.manageeventButton.clicked.connect(self.manage_event_button)
  1193.         self.managestaffButton.clicked.connect(self.manage_staff_button)
  1194.         self.viewsiteButton.clicked.connect(self.viewsite_button)
  1195.         self.manageprofileButton.clicked.connect(self.manageprofile_button)
  1196.         self.viewtransithistoryButton.clicked.connect(self.viewtransit)
  1197.         self.taketransitButton.clicked.connect(self.taketransit)
  1198.  
  1199.     def taketransit(self):
  1200.         self.window =usertaketransit()
  1201.         self.close()
  1202.         self.window.show()
  1203.  
  1204.     def viewtransit(self):
  1205.         self.window = userviewtransithistory()
  1206.         self.close()
  1207.         self.window.show()
  1208.  
  1209.     def back_button(self):
  1210.         # self.window = loginwindow()
  1211.         self.close()
  1212.         # self.window.show()
  1213.         loginwindow.show()
  1214.     def manage_event_button(self):
  1215.         self.window = managermanageevent()
  1216.         self.close()
  1217.         self.window.show()
  1218.     def manage_staff_button(self):
  1219.         self.window = managermanagestaff()
  1220.         self.close()
  1221.         self.window.show()
  1222.     def viewsite_button(self):
  1223.         self.window = managersitereport()
  1224.         self.close()
  1225.         self.window.show()
  1226.     def manageprofile_button(self):
  1227.         self.window = staffmanageprofile()
  1228.         self.close()
  1229.         self.window.show()
  1230.  
  1231. #create, view/edit / delete needs to be updated queries.
  1232. class managermanageevent(QMainWindow, Ui_ManagerManageEvent):
  1233.     def __init__(self, parent= None):
  1234.         super(managermanageevent, self).__init__(parent)
  1235.         self.setupUi(self)
  1236.         self.BackButton.clicked.connect(self.back_button)
  1237.         self.viewEditButton.clicked.connect(self.edit_button)
  1238.         self.deleteButton.clicked.connect(self.delete_button)
  1239.         self.createButton.clicked.connect(self.create_button)
  1240.         self.filterButton.clicked.connect(self.filter_button)
  1241.         connection = pymysql.connect(host="localhost",
  1242.                                     user="root",
  1243.                                     password="12345678",
  1244.                                     db="beltline")
  1245.         cursor = connection.cursor()
  1246.         manageevent = f"select event.name, count(distinct assignto.employeeid, assignto.startdate) as StaffCount, DATEDIFF(event.EndDate, event.StartDate) + 1 as Duration, count(visitevent.username) as TotalVisits, count(visitevent.username)*event.price as TotalRevenue from event join assignto on assignto.name = event.name join visitevent on visitevent.name = event.name group by event.name"
  1247.         df = pd.read_sql(manageevent, connection)
  1248.         model = PandasModel(df)
  1249.         self.tableView.setModel(model)
  1250.  
  1251.     def back_button(self):
  1252.         self.window = managerfunctionality()
  1253.         self.close()
  1254.         self.window.show()
  1255.     def edit_button(self):
  1256.         userlist = self.tableView.selectionModel().selectedRows()
  1257.         index=0
  1258.         for i in userlist:
  1259.             index = i.row()
  1260.             print(index)
  1261.         connection = pymysql.connect(host="localhost",
  1262.                                     user="root",
  1263.  
  1264.                                     password="12345678",
  1265.  
  1266.  
  1267.                                     db="beltline")
  1268.         cursor = connection.cursor()
  1269.         managequery = f"select event.name, count(distinct assignto.employeeid, assignto.startdate) as StaffCount, DATEDIFF(event.EndDate, event.StartDate) + 1 as Duration from event join assignto on assignto.name = event.name group by event.name"
  1270.         cursor.execute(managequery)
  1271.  
  1272.  
  1273.         event = cursor.fetchall()[index][0]
  1274.         self.window = managereditevent(event)
  1275.         self.close()
  1276.         self.window.show()
  1277.     def create_button(self):
  1278.         userlist = self.tableView.selectionModel().selectedRows()
  1279.         for i in userlist:
  1280.             index = i.row()
  1281.         self.window = managercreateevent()
  1282.         self.close()
  1283.         self.window.show()
  1284.  
  1285.  
  1286.  
  1287.         event = cursor.fetchall()[index][0]
  1288.         self.window = managerviewedit(event)
  1289.         self.close()
  1290.         self.window.show()
  1291.     def create_button(self):
  1292.         userlist = self.tableView.selectionModel().selectedRows()
  1293.         for i in userlist:
  1294.             index = i.row()
  1295.         self.window = managercreateevent()
  1296.         self.close()
  1297.         self.window.show()
  1298.  
  1299.  
  1300.     def delete_button(self):
  1301.         userlist = self.tableView.selectionModel().selectedRows()
  1302.         index=0
  1303.         for i in userlist:
  1304.             index = i.row()
  1305.             print(index)
  1306.         connection = pymysql.connect(host="localhost",
  1307.                                     user="root",
  1308.  
  1309.                                     password="12345678",
  1310.  
  1311.  
  1312.                                     db="beltline")
  1313.         cursor = connection.cursor()
  1314.         managequery = f"select transit.route, transit.transittype, transit.price, count(connect.route) as '# Connected Sites', count(take.route) as '# Transits Logged' from transit join connect on connect.route = transit.route join take on take.route = transit.route group by transit.route"
  1315.         cursor.execute(managequery)
  1316.  
  1317.         route = cursor.fetchall()[index][0]
  1318.         print(route)
  1319.         deletetransit = f"delete from transit where route = '{route}'"
  1320.         cursor.execute(deletetransit)
  1321.         connection.commit()
  1322.     def filter_button(self):
  1323.  
  1324.         name = self.nameEdit.text()
  1325.         descriptionKeyword = self.descriptionKeyword.text()
  1326.         start_date = self.startDate.text()
  1327.         end_date = self.endDate.text()
  1328.         duration_low = self.duration1.text()
  1329.         duration_high = self.duration2.text()
  1330.         totalvisits_low = self.visits1.text()
  1331.         totalvisits_high = self.visits2.text()
  1332.         revenue_low = self.rev1.text()
  1333.         revenue_high = self.rev2.text()
  1334.  
  1335.  
  1336.  
  1337.         connection = pymysql.connect(host="localhost",
  1338.                                     user="root",
  1339.  
  1340.                                     password="12345678",
  1341.  
  1342.  
  1343.                                     db="beltline")
  1344.         cursor = connection.cursor()
  1345.         filterquery = f"select event.name, count(distinct assignto.employeeid, assignto.startdate) as StaffCount, DATEDIFF(event.EndDate, event.StartDate) + 1 as Duration, count(visitevent.username) as TotalVisits, count(visitevent.username)*event.price as TotalRevenue from event join assignto on assignto.name = event.name join visitevent on visitevent.name = event.name where event.name = '{name}' and DATEDIFF(event.EndDate, event.StartDate) + 1 between '{duration_low}' and '{duration_high}' group by event.name  having count(visitevent.username) between '{totalvisits_low}' and '{totalvisits_high}' and count(visitevent.username)*event.price between '{revenue_low}' and '{revenue_high}'"
  1346.         df = pd.read_sql(filterquery, connection)
  1347.         model = PandasModel(df)
  1348.         self.tableView.setModel(model)
  1349.         # and contains(Description, '{descriptionKeyword}')
  1350.  
  1351. class managereditevent(QMainWindow, Ui_ManagerViewEditEvent):
  1352.     def __init__(self, event, parent= None):
  1353.         super(managereditevent, self).__init__(parent)
  1354.         self.setupUi(self)
  1355.         print(event)
  1356.         self.event = event
  1357.         self.BackButton.clicked.connect(self.back_button)
  1358.         self.updateButton.clicked.connect(self.update_button)
  1359.         self.filterButton.clicked.connect(self.filter_button)
  1360.  
  1361.         connection = pymysql.connect(host="localhost",
  1362.                                     user="root",
  1363.                                     password="12345678",
  1364.                                     db="beltline")
  1365.         cursor = connection.cursor()
  1366.         getEvent = f"select * from event where name = '{event}'"
  1367.         cursor.execute(getEvent)
  1368.         name, startdate, sitename, enddate, price, capacity, description, minStaffReq = cursor.fetchone()
  1369.         self.price = price
  1370.         self.startdate = startdate
  1371.         self.enddate = enddate
  1372.         self.nameLabel.setText(name)
  1373.         self.priceLabel.setText(str(price))
  1374.         startdate = startdate.strftime('%Y-%m-%d')
  1375.         enddate = enddate.strftime('%Y-%m-%d')
  1376.         self.startLabel.setText(startdate)
  1377.         self.endLabel.setText(enddate)
  1378.         self.capacityLabel.setText(str(capacity))
  1379.         self.minStaffLabel.setText(str(minStaffReq))
  1380.         self.textBrowser.setText(description)
  1381.  
  1382.  
  1383.  
  1384.         showStaff = f"select concat(user.firstname, ' ', user.lastname) as 'Staff Name' from user join employee on user.username = employee.username join assignto on assignto.employeeid = employee.employeeid where assignto.name = '{event}'"
  1385.         df = pd.read_sql(showStaff, connection)
  1386.         model = PandasModel(df)
  1387.         self.staffTable.setModel(model)
  1388.  
  1389.     def back_button(self):
  1390.         self.window = managermanageevent()
  1391.         self.close()
  1392.         self.window.show()
  1393.  
  1394.  
  1395.     def update_button(self):
  1396.         visitrange1 = self.visitRange1.text()
  1397.         visitrange2 = self.visitRange2.text()
  1398.         revrange1 = self.revRange1.text()
  1399.         revrange2 = self.revRange2.text()
  1400.  
  1401.         connection = pymysql.connect(host="localhost",
  1402.                                     user="root",
  1403.                                     password="12345678",
  1404.                                     db="beltline")
  1405.  
  1406.         cursor = connection.cursor()
  1407.  
  1408.  
  1409.         userlist = self.tableView.selectionModel().selectedRows()
  1410.         listOfIndexes = []
  1411.         for i in userlist:
  1412.             listOfIndexes.append(i.row())
  1413.         print(listOfIndexes)
  1414.  
  1415.         self.window = managermanageevent()
  1416.         self.close()
  1417.         self.window.show()
  1418.  
  1419.     def filter_button(self):
  1420.         revrange1 = self.revRange1.text()
  1421.         revrange2 = self.revRange2.text()
  1422.         visitrange1 = self.visitRange1.text()
  1423.         visitrange2 = self.visitRange2.text()
  1424.         connection = pymysql.connect(host="localhost",
  1425.                                     user="root",
  1426.                                     password="12345678",
  1427.                                     db="beltline")
  1428.         cursor = connection.cursor()
  1429.         filterquery = f"select visitevent.date, count(visitevent.username) as 'Daily Visits', count(visitevent.username)*{self.price} as 'Daily Revenue' from visitevent join event where visitevent.date between '{self.startdate}' and '{self.enddate}' group by visitevent.name having count(visitevent.username) between '{visitrange1}' and '{visitrange2}' and count(visitevent.username)*{self.price} between '{revrange1}' and '{revrange2}' "
  1430.         df = pd.read_sql(filterquery, connection)
  1431.         model = PandasModel(df)
  1432.         self.revenueTable.setModel(model)
  1433.  
  1434. class managercreateevent(QMainWindow, Ui_ManagerCreateEvent):
  1435.     def __init__(self, parent= None):
  1436.         super(managercreateevent, self).__init__(parent)
  1437.         self.setupUi(self)
  1438.         self.BackButton.clicked.connect(self.back_button)
  1439.         self.createButton.clicked.connect(self.create_button)
  1440.         connection = pymysql.connect(host="localhost",
  1441.                                     user="root",
  1442.                                     password="12345678",
  1443.                                     db="beltline")
  1444.         cursor = connection.cursor()
  1445.         showStaff = f"select concat(user.firstname, ' ', user.lastname) as 'Staff Name' from user join employee on user.username = employee.username where employee.employeetype = 'Staff'"
  1446.         df = pd.read_sql(showStaff, connection)
  1447.         model = PandasModel(df)
  1448.         self.tableView.setModel(model)
  1449.  
  1450.  
  1451.     def back_button(self):
  1452.         self.window = managermanageevent()
  1453.         self.close()
  1454.         self.window.show()
  1455.  
  1456.     def create_button(self):
  1457.         name = self.nameEdit.text()
  1458.         price = self.priceEdit.text()
  1459.         capacity = self.capacityEdit.text()
  1460.         minStaffRequired = self.minStaffEdit.text()
  1461.         startDate = self.startDateEdit.text()
  1462.         endDate = self.endDateEdit.text()
  1463.         # description = self.textBrowser.text()
  1464.         connection = pymysql.connect(host="localhost",
  1465.                                     user="root",
  1466.                                     password="12345678",
  1467.                                     db="beltline")
  1468.         cursor = connection.cursor()
  1469.  
  1470.         userlist = self.tableView.selectionModel().selectedRows()
  1471.         for i in userlist:
  1472.             index = i.row()
  1473.  
  1474.  
  1475.         createQuery = f"select concat(user.firstname, ' ', user.lastname) from employee join user on employee.username = user.username where employee.employeetype = 'Staff'"
  1476.         cursor.execute(createQuery)
  1477.         # assignStaff = cursor.fetchall()[index][0]
  1478.  
  1479.         # print(assignStaff)
  1480.  
  1481.         get_site = f"select site.name from site join employee on employee.employeeid = site.manager where employee.username = '{loginwindow.currentuser}'"
  1482.         cursor.execute(get_site)
  1483.         # siteName = cursor.fetchone()[0]
  1484.         # print(siteName)
  1485.  
  1486.         insertQuery = f"insert into event (Name, StartDate, SiteName, EndDate, Price, Capacity, Description, minStaffReq) values ('{name}', '{startDate}','Inman Park','{endDate}','{price}','{capacity}', 'Not Applicable', '5')"
  1487.         # '{description}','{minStaffRequired}')"
  1488.         cursor.execute(insertQuery)
  1489.         connection.commit()
  1490.  
  1491.         self.window = managermanageevent()
  1492.         self.close()
  1493.         self.window.show()
  1494.  
  1495. class managermanagestaff(QMainWindow, Ui_ManagerManageStaff):
  1496.     def __init__(self, parent= None):
  1497.         super(managermanagestaff, self).__init__(parent)
  1498.         self.setupUi(self)
  1499.         self.BackButton.clicked.connect(self.back_button)
  1500.         self.filterButton.clicked.connect(self.filter_button)
  1501.  
  1502.         connection = pymysql.connect(host="localhost",
  1503.                                     user="root",
  1504.                                     password="12345678",
  1505.                                     db="beltline")
  1506.         cursor = connection.cursor()
  1507.         # manageevent = f"select * from assignto"
  1508.         manageevent = f"select concat(user.firstname, ' ', user.lastname) as 'Staff Name', count(assignto.employeeid) as eventShifts from user join employee on employee.username = user.username join assignto on employee.employeeid = assignto.employeeid join site on site.name = assignto.sitename group by employee.employeeid"
  1509.         df = pd.read_sql(manageevent, connection)
  1510.         model = PandasModel(df)
  1511.         self.tableView.setModel(model)
  1512.  
  1513.     def back_button(self):
  1514.         self.window = managerfunctionality()
  1515.         self.close()
  1516.         self.window.show()
  1517.     def filter_button(self):
  1518.         lastname = self.nameEdit.text()
  1519.         firstname = self.priceEdit.text()
  1520.         startdate = self.startDateEdit.text()
  1521.         enddate = self.endDateEdit.text()
  1522.  
  1523.  
  1524.         connection = pymysql.connect(host="localhost",
  1525.                                     user="root",
  1526.  
  1527.                                     password="12345678",
  1528.  
  1529.                                     db="beltline")
  1530.         cursor = connection.cursor()
  1531.         filterquery = f"select concat(user.firstname, ' ', user.lastname) as 'Staff Name', count(assignto.employeeid) as eventShifts from user join employee on employee.username = user.username join assignto on employee.employeeid = assignto.employeeid join site on site.name = assignto.sitename where site.name = 'Inman Park' and assignto.startdate between '{startdate}' and '{enddate}' and user.firstname = '{firstname}' and user.lastname ='{lastname}' group by employee.employeeid"
  1532.         df = pd.read_sql(filterquery, connection)
  1533.         model = PandasModel(df)
  1534.         self.tableView.setModel(model)
  1535.         # and contains(Description, '{descriptionKeyword}')
  1536.  
  1537. class managersitereport(QMainWindow, Ui_ManagerSiteReport):
  1538.     def __init__(self, parent= None):
  1539.         super(managersitereport, self).__init__(parent)
  1540.         self.setupUi(self)
  1541.         self.BackButton.clicked.connect(self.back_button)
  1542.         self.dailyDetailButton.clicked.connect(self.dailydetail_button)
  1543.         self.filterButton.clicked.connect(self.filter_button)
  1544.  
  1545.         connection = pymysql.connect(host="localhost",
  1546.                                     user="root",
  1547.                                     password="12345678",
  1548.                                     db="beltline")
  1549.         cursor = connection.cursor()
  1550.         manageevent = f"select assignto.startdate, count(distinct assignto.name, assignto.startdate) as EventCount, count(distinct assignto.employeeid, assignto.startdate) as StaffCount, count(visitevent.username) as TotalVisits, count(visitevent.username)*event.price as TotalRevenue from event join assignto on assignto.name = event.name join visitevent on visitevent.name = event.name group by event.name"
  1551.         df = pd.read_sql(manageevent, connection)
  1552.         model = PandasModel(df)
  1553.         self.tableView.setModel(model)
  1554.  
  1555.     def back_button(self):
  1556.         self.window = managerfunctionality()
  1557.         self.close()
  1558.         self.window.show()
  1559.  
  1560.     def dailydetail_button(self):
  1561.         userlist = self.tableView.selectionModel().selectedRows()
  1562.         for i in userlist:
  1563.             index = i.row()
  1564.         connection = pymysql.connect(host="localhost",
  1565.                                     user="root",
  1566.                                     password="12345678",
  1567.                                     db="beltline")
  1568.         cursor = connection.cursor()
  1569.         managequery = f"select assignto.startdate, count(distinct assignto.name, assignto.startdate) as EventCount, count(distinct assignto.employeeid, assignto.startdate) as StaffCount, count(visitevent.username) as TotalVisits, count(visitevent.username)*event.price as TotalRevenue from event join assignto on assignto.name = event.name join visitevent on visitevent.name = event.name group by event.name"
  1570.         cursor.execute(managequery)
  1571.         values = cursor.fetchall()[index]
  1572.  
  1573.         self.window = managerdailydetail(values)
  1574.         self.close()
  1575.         self.window.show()
  1576.  
  1577.     def filter_button(self):
  1578.         startdate = self.startDateEdit.text()
  1579.         enddate = self.endDateEdit.text()
  1580.  
  1581.  
  1582.         connection = pymysql.connect(host="localhost",
  1583.                                     user="root",
  1584.  
  1585.                                     password="12345678",
  1586.  
  1587.                                     db="beltline")
  1588.         cursor = connection.cursor()
  1589.         filterquery = f"select assignto.startdate, count(distinct assignto.name, assignto.startdate) as EventCount, count(distinct assignto.employeeid, assignto.startdate) as StaffCount, count(visitevent.username) as TotalVisits, count(visitevent.username)*event.price as TotalRevenue from event join assignto on assignto.name = event.name join visitevent on visitevent.name = event.name group by event.name"
  1590.         df = pd.read_sql(filterquery, connection)
  1591.         model = PandasModel(df)
  1592.         self.tableView.setModel(model)
  1593.         # and contains(Description, '{descriptionKeyword}')
  1594.  
  1595. #need to update the query
  1596. class managerdailydetail(QMainWindow, Ui_ManagerDailyDetail):
  1597.     def __init__(self, values, parent= None):
  1598.         super(managerdailydetail, self).__init__(parent)
  1599.         self.setupUi(self)
  1600.         self.values = values
  1601.         print(values)
  1602.         self.BackButton.clicked.connect(self.back_button)
  1603.  
  1604.         connection = pymysql.connect(host="localhost",
  1605.                                     user="root",
  1606.                                     password="12345678",
  1607.                                     db="beltline")
  1608.         cursor = connection.cursor()
  1609.         manageevent = f"select * from employee"
  1610.         df = pd.read_sql(manageevent, connection)
  1611.         model = PandasModel(df)
  1612.         self.tableView.setModel(model)
  1613.  
  1614.     def back_button(self):
  1615.         self.window = managerfunctionality()
  1616.         self.close()
  1617.         self.window.show()
  1618.  
  1619. class stafffunctionality(QMainWindow, Ui_StaffFunctionality):
  1620.     def __init__(self, parent= None):
  1621.         super(stafffunctionality, self).__init__(parent)
  1622.         self.setupUi(self)
  1623.         self.BackButton.clicked.connect(self.back_button)
  1624.         self.manageProfileButton.clicked.connect(self.manageprofile_button)
  1625.         self.viewScheduleButton.clicked.connect(self.viewschedule_button)
  1626.         self.viewTransitButton.clicked.connect(self.viewtransit)
  1627.         self.takeTransitButton.clicked.connect(self.taketransit)
  1628.  
  1629.     def taketransit(self):
  1630.         self.window =usertaketransit()
  1631.         self.close()
  1632.         self.window.show()
  1633.  
  1634.     def viewtransit(self):
  1635.         self.window = userviewtransithistory()
  1636.         self.close()
  1637.         self.window.show()
  1638.     def back_button(self):
  1639.         self.close()
  1640.         loginwindow.show()
  1641.     def manageprofile_button(self):
  1642.         self.window = staffmanageprofile()
  1643.         self.close()
  1644.         self.window.show()
  1645.     def viewschedule_button(self):
  1646.         self.window = staffviewschedule()
  1647.         self.close()
  1648.         self.window.show()
  1649.  
  1650. class staffmanageprofile(QMainWindow, Ui_EmployeeManageProfile):
  1651.     def __init__(self, parent= None):
  1652.         super(staffmanageprofile, self).__init__(parent)
  1653.         self.setupUi(self)
  1654.         self.BackButton.clicked.connect(self.back_button)
  1655.         self.updateButton.clicked.connect(self.update_button)
  1656.         self.BackButton_2.clicked.connect(self.add_button)
  1657.         self.BackButton_3.clicked.connect(self.remove_button)
  1658.  
  1659.         # loginwindow.currentuser
  1660.         # BACK BUTTON 2 IS ADD
  1661.         # BACK BUTTON 3 IS REMOVE
  1662.         connection = pymysql.connect(host="localhost",
  1663.                                     user="root",
  1664.  
  1665.                                     password="12345678",
  1666.  
  1667.  
  1668.                                     db="beltline")
  1669.         cursor = connection.cursor()
  1670.  
  1671.         managerQuery = f"select employeetype from employee where username = '{loginwindow.currentuser}'"
  1672.         cursor.execute(managerQuery)
  1673.         fetchAll = cursor.fetchall()
  1674.         role = fetchAll[0][0]
  1675.         query = None
  1676.         if role == 'Manager':
  1677.             #code
  1678.             query = f"select concat(employee.address, ', ', employee.city, ', ', employee.state, ' ', employee.zipcode) as ADDRESS, employee.employeeid, user.username, site.name  from employee join user on employee.username = user.username join site on employee.employeeid = site.manager where user.username = '{loginwindow.currentuser}'"
  1679.             cursor.execute(query)
  1680.             fetchAll = cursor.fetchall()
  1681.             try:
  1682.                 self.addressLabel.setText(fetchAll[0][0])
  1683.                 self.idLabel.setText(fetchAll[0][1])
  1684.                 self.siteNameLabel.setText(fetchAll[0][3])
  1685.                 self.usernameLabel.setText(fetchAll[0][2])
  1686.             except:
  1687.                 print('fail')
  1688.         else:
  1689.             #code
  1690.             query = f"select concat(employee.address, ', ', employee.city, ', ', employee.state, ' ', employee.zipcode) as ADDRESS, employee.employeeid, user.username from employee join user on employee.username = user.username where user.username = '{loginwindow.currentuser}'"
  1691.             cursor.execute(query)
  1692.             fetchAll = cursor.fetchall()
  1693.             try:
  1694.                 self.addressLabel.setText(fetchAll[0][0])
  1695.                 self.idLabel.setText(fetchAll[0][1])
  1696.                 self.usernameLabel.setText(fetchAll[0][2])
  1697.             except:
  1698.                 print('fail')
  1699.  
  1700.     def back_button(self):
  1701.         self.close()
  1702.         loginwindow.show()
  1703.     def update_button(self):
  1704.         firstname = self.firstNameEdit.text()
  1705.         lastname = self.lastNameEdit.text()
  1706.         phone = self.phoneEdit.text()
  1707.         email =  self.emailEdit.text()
  1708.  
  1709.         connection = pymysql.connect(host="localhost",
  1710.                                     user="root",
  1711.  
  1712.                                     password="12345678",
  1713.  
  1714.  
  1715.                                     db="beltline")
  1716.         cursor = connection.cursor()
  1717.         # edit_profile = f"update employee set firstName = '{firstname}, lastName = '{lastname}', phone = '{phone}' where username = '{loginwindow.currentuser}'"
  1718.         # cursor.execute(edit_profile)
  1719.         # connection.commit()
  1720.         update1 = f"update user set firstname = '{firstname}', lastname = '{lastname}' where username = '{loginwindow.currentuser}'"
  1721.         update2 = f"update employee set phone = '{phone}' where username = '{loginwindow.currentuser}'"
  1722.         cursor.execute(update1)
  1723.         connection.commit()
  1724.         cursor.execute(update2)
  1725.         connection.commit()
  1726.  
  1727.         if self.visitorCheckBox.isChecked():
  1728.             query = f"update user set usertype = 'Employee-Visitor' where username = '{loginwindow.currentuser}'"
  1729.             cursor.execute(query)
  1730.             connection.commit()
  1731.         else:
  1732.             query = f"update user set usertype = 'Employee' where username = '{loginwindow.currentuser}'"
  1733.             cursor.execute(query)
  1734.             connection.commit()
  1735.  
  1736.  
  1737.         self.window = adminfunctionality()
  1738.         self.close()
  1739.         self.window.show()
  1740.  
  1741.     def add_button(self):
  1742.         #code
  1743.         connection = pymysql.connect(host="localhost",
  1744.                                     user="root",
  1745.  
  1746.                                     password="12345678",
  1747.  
  1748.  
  1749.                                     db="beltline")
  1750.         cursor = connection.cursor()
  1751.         try:
  1752.             addQ = f"insert into email (Username, Email) values ('{loginwindow.currentuser}', '{self.emailEdit.text()}')"
  1753.             cursor.execute(addQ)
  1754.             connection.commit()
  1755.         except:
  1756.             print('add failed')
  1757.  
  1758.  
  1759.     def remove_button(self):
  1760.         #code
  1761.         connection = pymysql.connect(host="localhost",
  1762.                                     user="root",
  1763.  
  1764.                                     password="12345678",
  1765.  
  1766.  
  1767.                                     db="beltline")
  1768.         cursor = connection.cursor()
  1769.         try:
  1770.             deleteQ = f"delete from email where email = '{self.emailEdit.text()}' and username = '{loginwindow.currentuser}'"
  1771.             cursor.execute(deleteQ)
  1772.             connection.commit()
  1773.         except:
  1774.             print('delete failed!')
  1775.  
  1776. class staffviewschedule(QMainWindow, Ui_StaffViewSchedule):
  1777.     def __init__(self, parent= None):
  1778.         super(staffviewschedule, self).__init__(parent)
  1779.         self.setupUi(self)
  1780.         self.BackButton.clicked.connect(self.back_button)
  1781.         self.viewEventButton.clicked.connect(self.view_button)
  1782.         self.filterButton.clicked.connect(self.filter_button)
  1783.  
  1784.         connection = pymysql.connect(host="localhost",
  1785.                                     user="root",
  1786.  
  1787.                                     password="12345678",
  1788.  
  1789.  
  1790.                                     db="beltline")
  1791.         cursor = connection.cursor()
  1792.         manageevent = f"select event.name as 'Event Name', event.sitename as 'Site Name', event.StartDate, event.EndDate, count(distinct assignto.EmployeeID, assignto.Name) as 'Staff Count' from event join assignto on event.sitename = assignto.sitename group by assignto.sitename"
  1793.         df = pd.read_sql(manageevent, connection)
  1794.         model = PandasModel(df)
  1795.         self.tableView.setModel(model)
  1796.         self.tableView.setSelectionBehavior(QTableView.SelectRows)
  1797.         self.tableView.setSelectionMode(QAbstractItemView.SingleSelection)
  1798.  
  1799.  
  1800.     def back_button(self):
  1801.         self.window = stafffunctionality()
  1802.         self.close()
  1803.         self.window.show()
  1804.     def view_button(self):
  1805.         userlist = self.tableView.selectionModel().selectedRows()
  1806.         for i in userlist:
  1807.             index = i.row()
  1808.         connection = pymysql.connect(host="localhost",
  1809.                                     user="root",
  1810.                                     password="12345678",
  1811.                                     db="beltline")
  1812.         cursor = connection.cursor()
  1813.         managequery = f"select event.name, event.sitename as 'Site Name', event.StartDate, event.EndDate, count(distinct assignto.EmployeeID, assignto.Name) as 'Staff Count' from event join assignto on event.sitename = assignto.sitename group by assignto.sitename"
  1814.         cursor.execute(managequery)
  1815.         values = cursor.fetchall()[index]
  1816.         self.window = staffeventdetail(values)
  1817.         self.close()
  1818.         self.window.show()
  1819.     def filter_button(self):
  1820.         eventname = self.eventNameEdit.text()
  1821.         description = self.descriptionEdit.text()
  1822.         startdate = self.startDate.text()
  1823.         enddate = self.endDate.text()
  1824.  
  1825.  
  1826.  
  1827.         connection = pymysql.connect(host="localhost",
  1828.                                     user="root",
  1829.                                     password="12345678",
  1830.                                     db="beltline")
  1831.         cursor = connection.cursor()
  1832.         filterquery = f"select event.name, event.sitename as 'Site Name', event.StartDate, event.EndDate, count(distinct assignto.EmployeeID, assignto.Name) as 'Staff Count' from event join assignto on event.sitename = assignto.sitename where event.name = '{eventname}' and event.startdate >= '{startdate}' and event.enddate <= '{enddate}' and event.description like '%{description}%' group by assignto.sitename"
  1833.         df = pd.read_sql(filterquery, connection)
  1834.         model = PandasModel(df)
  1835.         self.tableView.setModel(model)
  1836.  
  1837. class staffeventdetail(QMainWindow, Ui_StaffEventDetail):
  1838.     def __init__(self, values, parent= None):
  1839.         super(staffeventdetail, self).__init__(parent)
  1840.         self.setupUi(self)
  1841.         self.eventLabel.setText(values[0])
  1842.         self.label_5.setText(values[1])
  1843.         startdate = values[2].strftime('%Y%m-%d')
  1844.         enddate = values[3].strftime('%Y-%m-%d')
  1845.         self.startDateLabel.setText(startdate)
  1846.         self.endDateLabel.setText(enddate)
  1847.         self.durationLabel.setText(str(abs((values[2] - values[3]).days)))
  1848.         connection = pymysql.connect(host="localhost",
  1849.                                     user="root",
  1850.                                     password="12345678",
  1851.                                     db="beltline")
  1852.         cursor = connection.cursor()
  1853.         detailquery = f"select price, capacity, description from event where name = '{values[0]}'"
  1854.         cursor.execute(detailquery)
  1855.         values_2 = cursor.fetchone()
  1856.         self.capacityLabel.setText(str(values_2[1]))
  1857.         self.priceLabel.setText(str(values_2[0]))
  1858.         self.textBrowser.setText(values_2[2])
  1859.  
  1860.         staffquery = f"select concat(user.firstname, ' ', user.lastname) as 'Staff Name' from user join employee on user.username = employee.username join assignto on assignto.employeeid = employee.employeeid where assignto.name = '{values[0]}'"
  1861.         df = pd.read_sql(staffquery, connection)
  1862.         model = PandasModel(df)
  1863.         self.tableView.setModel(model)
  1864.         print(values)
  1865.         self.backButton.clicked.connect(self.back_button)
  1866.         connection = pymysql.connect(host="localhost",
  1867.                                     user="root",
  1868.  
  1869.                                     password="12345678",
  1870.  
  1871.  
  1872.                                     db="beltline")
  1873.         cursor = connection.cursor()
  1874.  
  1875.     def back_button(self):
  1876.         self.window = staffviewschedule()
  1877.         self.close()
  1878.         self.window.show()
  1879.  
  1880. class visitorfunctionality(QMainWindow, Ui_VisitorFunctionality):
  1881.     def __init__(self, parent= None):
  1882.         super(visitorfunctionality, self).__init__(parent)
  1883.         self.setupUi(self)
  1884.         self.BackButton.clicked.connect(self.back_button)
  1885.         self.exploreEventButton.clicked.connect(self.exploreevent_button)
  1886.         self.exploreSiteButton.clicked.connect(self.exploresite_button)
  1887.         self.viewVisitButton.clicked.connect(self.viewTransit_button)
  1888.         self.viewTransitButton.clicked.connect(self.viewtransit)
  1889.         self.takeTransitButton.clicked.connect(self.taketransit)
  1890.  
  1891.  
  1892.     def taketransit(self):
  1893.         self.window =usertaketransit()
  1894.         self.close()
  1895.         self.window.show()
  1896.  
  1897.     def viewtransit(self):
  1898.         self.window = userviewtransithistory()
  1899.         self.close()
  1900.         self.window.show()
  1901.  
  1902.     def back_button(self):
  1903.         self.close()
  1904.         loginwindow.show()
  1905.     def exploreevent_button(self):
  1906.         self.window = visitorexploreevent()
  1907.         self.close()
  1908.         self.window.show()
  1909.     def exploresite_button(self):
  1910.         self.window = visitorexploresite()
  1911.         self.close()
  1912.         self.window.show()
  1913.     def viewTransit_button(self):
  1914.         self.window = visitorvisithistory()
  1915.         self.close()
  1916.         self.window.show()
  1917. #update query
  1918. class visitorexploreevent(QMainWindow, Ui_VisitorExploreEvent):
  1919.     def __init__(self, parent= None):
  1920.         super(visitorexploreevent, self).__init__(parent)
  1921.         self.setupUi(self)
  1922.         self.BackButton.clicked.connect(self.back_button)
  1923.         self.eventDetailButton.clicked.connect(self.dailydetail_button)
  1924.         self.filterButton.clicked.connect(self.filter_button)
  1925.  
  1926.  
  1927.         connection = pymysql.connect(host="localhost",
  1928.                                     user="root",
  1929.                                     password="12345678",
  1930.                                     db="beltline")
  1931.         cursor = connection.cursor()
  1932.         manageevent = f"select event.name, event.SiteName as 'Site Name', event.price as 'Ticket Price', event.capacity-count(distinct visitevent.name) as 'Tickets Remaining', count(visitevent.username) as TotalVisits, count(distinct visitevent.username, visitevent.sitename) as 'My Visits' from event join visitevent on visitevent.name = event.name group by event.name"
  1933.         # select event.name as 'Event Name', event.SiteName as 'Site Name', event.price as 'Ticket Price', event.capacity - count(distinct visitevent.name) as 'Tickets Remaining', count(something) as 'My Visits' from event join visitevent on visitevent.name = event.name group by event.name
  1934.         df = pd.read_sql(manageevent, connection)
  1935.         model = PandasModel(df)
  1936.         self.dataTable.setModel(model)
  1937.  
  1938.     def back_button(self):
  1939.         self.window = visitorfunctionality()
  1940.         self.close()
  1941.         self.window.show()
  1942.  
  1943.     def dailydetail_button(self):
  1944.         self.window = visitoreventdetail()
  1945.         self.close()
  1946.         self.window.show()
  1947.  
  1948.     def filter_button(self):
  1949.         eventname = self.nameEdit.text()
  1950.         description = self.descriptionEdit.text()
  1951.         startdate = self.startDate.text()
  1952.         enddate = self.endDate.text()
  1953.  
  1954.  
  1955.  
  1956.         connection = pymysql.connect(host="localhost",
  1957.                                     user="root",
  1958.                                     password="12345678",
  1959.                                     db="beltline")
  1960.         cursor = connection.cursor()
  1961.         filterquery = f"select event.name, event.SiteName as 'Site Name', event.price as 'Ticket Price', event.capacity-count(distinct visitevent.name) as 'Tickets Remaining', count(visitevent.username) as TotalVisits, count(distinct visitevent.username, visitevent.sitename) as 'My Visits' from event join visitevent on visitevent.name = event.name where visitevent.username = '{loginwindow.currentuser}' and event.name = '{eventname}' group by event.name event.startdate >= '{startdate}' and event.enddate <= '{enddate}' and event.description like '%{description}%'"
  1962.         df = pd.read_sql(filterquery, connection)
  1963.         model = PandasModel(df)
  1964.         self.tableView.setModel(model)
  1965.  
  1966. #need to create log visit button
  1967. class visitoreventdetail(QMainWindow, Ui_VisitorEventDetail):
  1968.     def __init__(self, parent= None):
  1969.         super(visitoreventdetail, self).__init__(parent)
  1970.         self.setupUi(self)
  1971.         self.BackButton.clicked.connect(self.back_button)
  1972.  
  1973.         connection = pymysql.connect(host="localhost",
  1974.                                     user="root",
  1975.                                     password="12345678",
  1976.                                     db="beltline")
  1977.         # cursor = connection.cursor()
  1978.         # manageevent = f"select * from employee"
  1979.         # df = pd.read_sql(manageevent, connection)
  1980.         # model = PandasModel(df)
  1981.         # self.tableView.setModel(model)
  1982.  
  1983.     def back_button(self):
  1984.         self.window = visitorexploreevent()
  1985.         self.close()
  1986.         self.window.show()
  1987.  
  1988. class visitorexploresite(QMainWindow, Ui_VisitorExploreSite):
  1989.     def __init__(self, parent= None):
  1990.         super(visitorexploresite, self).__init__(parent)
  1991.         self.setupUi(self)
  1992.         self.BackButton.clicked.connect(self.back_button)
  1993.         self.transitDetailButton.clicked.connect(self.transitdetail_button)
  1994.         self.siteDetailButton.clicked.connect(self.sitedetail_button)
  1995.         self.filterButton.clicked.connect(self.filter_button)
  1996.  
  1997.  
  1998.         connection = pymysql.connect(host="localhost",
  1999.                                     user="root",
  2000.  
  2001.                                     password="12345678",
  2002.  
  2003.  
  2004.                                     db="beltline")
  2005.         cursor = connection.cursor()
  2006.         manageevent = f"select event.name, event.SiteName as 'Site Name', event.price as 'Ticket Price', event.capacity-count(distinct visitevent.name) as 'Tickets Remaining', count(visitevent.username) as TotalVisits, count(distinct visitevent.username, visitevent.sitename) as 'My Visits' from event join visitevent on visitevent.name = event.name group by event.name"
  2007.         # select event.name as 'Event Name', event.SiteName as 'Site Name', event.price as 'Ticket Price', event.capacity - count(distinct visitevent.name) as 'Tickets Remaining', count(something) as 'My Visits' from event join visitevent on visitevent.name = event.name group by event.name
  2008.         df = pd.read_sql(manageevent, connection)
  2009.         model = PandasModel(df)
  2010.         self.dataTable.setModel(model)
  2011.  
  2012.     def back_button(self):
  2013.         self.window = visitorfunctionality()
  2014.         self.close()
  2015.         self.window.show()
  2016.  
  2017.     def transitdetail_button(self):
  2018.         self.window = visitortransitdetail()
  2019.         self.close()
  2020.         self.window.show()
  2021.  
  2022.     def sitedetail_button(self):
  2023.         self.window = visitorsitedetail()
  2024.         self.close()
  2025.         self.window.show()
  2026.  
  2027.     def filter_button(self):
  2028.         eventname = self.nameEdit.text()
  2029.         description = self.descriptionEdit.text()
  2030.         startdate = self.startDate.text()
  2031.         enddate = self.endDate.text()
  2032.  
  2033.  
  2034.  
  2035.         connection = pymysql.connect(host="localhost",
  2036.                                     user="root",
  2037.                                     password="12345678",
  2038.                                     db="beltline")
  2039.         cursor = connection.cursor()
  2040.         filterquery = f"select site.name as 'Site Name', event.capacity - count(distinct visitevent.name) as 'Tickets Remaining', count(distinct visitevent.username, visitevent.sitename) as 'My Visits' from event join visitevent on visitevent.name = event.name where visitevent.username = '{loginwindow.currentuser}' and site.name = '{sitename}' group by event.name event.startdate >= '{startdate}' and event.enddate <= '{enddate}' and event.description like '%{description}%'"
  2041.         df = pd.read_sql(filterquery, connection)
  2042.         model = PandasModel(df)
  2043.         self.tableView.setModel(model)
  2044.  
  2045. class visitorsitedetail(QMainWindow, Ui_VisitorSiteDetail):
  2046.     def __init__(self, parent= None):
  2047.         super(visitorsitedetail, self).__init__(parent)
  2048.         self.setupUi(self)
  2049.         self.BackButton.clicked.connect(self.back_button)
  2050.  
  2051.         connection = pymysql.connect(host="localhost",
  2052.                                     user="root",
  2053.  
  2054.                                     password="12345678",
  2055.  
  2056.  
  2057.                                     db="beltline")
  2058.         # cursor = connection.cursor()
  2059.         # manageevent = f"select * from employee"
  2060.         # df = pd.read_sql(manageevent, connection)
  2061.         # model = PandasModel(df)
  2062.         # self.tableView.setModel(model)
  2063.  
  2064.     def back_button(self):
  2065.         self.window = visitorexploresite()
  2066.         self.close()
  2067.         self.window.show()
  2068.  
  2069. class visitortransitdetail(QMainWindow, Ui_VisitorTransitDetail):
  2070.     def __init__(self, parent= None):
  2071.         super(visitortransitdetail, self).__init__(parent)
  2072.  
  2073.         self.setupUi(self)
  2074.         self.BackButton.clicked.connect(self.back_button)
  2075.  
  2076.         connection = pymysql.connect(host="localhost",
  2077.                                     user="root",
  2078.                                     password="12345678",
  2079.                                     db="beltline")
  2080.         cursor = connection.cursor()
  2081.         manageevent = f"select Take.Route, Take.TransitType as 'Transport Type', Transit.price, count(connect.route) from Take join Transit on Transit.route = Take.Route join connect on connect.route = Take.Route group by tranit.TransitType"
  2082.         df = pd.read_sql(manageevent, connection)
  2083.         model = PandasModel(df)
  2084.         self.tableView.setModel(model)
  2085.  
  2086.     def back_button(self):
  2087.         self.window = visitorexploresite()
  2088.         self.close()
  2089.         self.window.show()
  2090.  
  2091. class visitorvisithistory(QMainWindow, Ui_VisitorVisitHistory):
  2092.     def __init__(self, parent= None):
  2093.         super(visitorvisithistory, self).__init__(parent)
  2094.         self.setupUi(self)
  2095.         self.BackButton.clicked.connect(self.back_button)
  2096.         self.filterButton.clicked.connect(self.filter_button)
  2097.  
  2098.         connection = pymysql.connect(host="localhost",
  2099.                                     user="root",
  2100.                                     password="12345678",
  2101.                                     db="beltline")
  2102.         cursor = connection.cursor()
  2103.         filterquery = f"select visitsite.date, event.name, visitsite.name, event.price from visitsite join event on visitsite.name = event.sitename"
  2104.  
  2105.         df = pd.read_sql(filterquery, connection)
  2106.         model = PandasModel(df)
  2107.         self.dataTable.setModel(model)
  2108.  
  2109.  
  2110.         siteQuery = f"select name from site"
  2111.         cursor.execute(siteQuery)
  2112.         fetchAll = cursor.fetchall()
  2113.         siteList = []
  2114.         for site in fetchAll:
  2115.             siteList.append(site[0])
  2116.         self.sitesComboBox.addItems(siteList)
  2117.  
  2118.  
  2119.     def back_button(self):
  2120.         self.window = visitorfunctionality()
  2121.         self.close()
  2122.         self.window.show()
  2123.  
  2124.     def filter_button(self):
  2125.         sites = self.sitesComboBox.currentText()
  2126.         event = self.eventEdit.text()
  2127.         # startdate = self.startdate.text()
  2128.         # enddate = self.enddate.text()
  2129.  
  2130.         connection = pymysql.connect(host="localhost",
  2131.                                         user="root",
  2132.                                         password="12345678",
  2133.                                         db="beltline")
  2134.         filterquery = f"select visitsite.date, event.name, visitsite.name, event.price from visitsite join event on visitsite.name = event.sitename where visitsite.username = '{loginwindow.currentuser}' and event.sitename = '{sites}' and event.name = '{event}'"
  2135.         df = pd.read_sql(filterquery, connection)
  2136.         model = PandasModel(df)
  2137.         self.dataTable.setModel(model)
  2138.  
  2139. class adminvisitorfunctionality(QMainWindow, Ui_AdminVisitorFunctionality):
  2140.     def __init__(self, parent= None):
  2141.         super(adminvisitorfunctionality, self).__init__(parent)
  2142.         self.setupUi(self)
  2143.         self.BackButton.clicked.connect(self.back_button)
  2144.         self.ManageSiteButton.clicked.connect(self.managesite_button)
  2145.         self.ManageUserButton.clicked.connect(self.manageuser_button)
  2146.         self.ManageTransitButton.clicked.connect(self.managetransit_button)
  2147.         self.manageProfileButton.clicked.connect(self.manageprofile_button)
  2148.         self.ViewTransitButton.clicked.connect(self.viewtransit)
  2149.         self.TakeTransitButton.clicked.connect(self.taketransit)
  2150.         self.exploreEventButton.clicked.connect(self.exploreevent_button)
  2151.         self.exploreSiteButton.clicked.connect(self.exploresite_button)
  2152.         self.viewVisitButton.clicked.connect(self.viewTransit_button)
  2153.  
  2154.  
  2155.     def taketransit(self):
  2156.         self.window =usertaketransit()
  2157.         self.close()
  2158.         self.window.show()
  2159.  
  2160.     def viewtransit(self):
  2161.         self.window = userviewtransithistory()
  2162.         self.close()
  2163.         self.window.show()
  2164.  
  2165.     def back_button(self):
  2166.         self.close()
  2167.         loginwindow.show()
  2168.     def exploreevent_button(self):
  2169.         self.window = visitorexploreevent()
  2170.         self.close()
  2171.         self.window.show()
  2172.     def exploresite_button(self):
  2173.         self.window = visitorexploresite()
  2174.         self.close()
  2175.         self.window.show()
  2176.     def viewTransit_button(self):
  2177.         self.window = visitorvisithistory()
  2178.         self.close()
  2179.         self.window.show()
  2180.  
  2181.     def back_button(self):
  2182.         # self.window = loginwindow()
  2183.         self.close()
  2184.         # self.window.show()
  2185.         loginwindow.show()
  2186.  
  2187.     def managesite_button(self):
  2188.         self.window = adminmanagesite()
  2189.         self.close()
  2190.         self.window.show()
  2191.     def manageuser_button(self):
  2192.         self.window = adminmanageuser()
  2193.         self.close()
  2194.         self.window.show()
  2195.     def managetransit_button(self):
  2196.         self.window = adminmanagetransit()
  2197.         self.close()
  2198.         self.window.show()
  2199.     def manageprofile_button(self):
  2200.         self.window = staffmanageprofile()
  2201.         self.close()
  2202.         self.window.show()
  2203.     def taketransit(self):
  2204.         self.window =usertaketransit()
  2205.         self.close()
  2206.         self.window.show()
  2207.  
  2208.     def viewtransit(self):
  2209.         self.window = userviewtransithistory()
  2210.         self.close()
  2211.         self.window.show()
  2212.  
  2213. class staffvisitorfunctionality(QMainWindow, Ui_StaffVisitorFunctionality):
  2214.     def __init__(self, parent= None):
  2215.         super(staffvisitorfunctionality, self).__init__(parent)
  2216.         self.setupUi(self)
  2217.         self.BackButton.clicked.connect(self.back_button)
  2218.         self.manageProfileButton.clicked.connect(self.manageprofile_button)
  2219.         self.viewScheduleButton.clicked.connect(self.viewschedule_button)
  2220.         self.exploreEventButton.clicked.connect(self.exploreevent_button)
  2221.         self.exploreSiteButton.clicked.connect(self.exploresite_button)
  2222.         self.viewVisitButton.clicked.connect(self.viewTransit_button)
  2223.         self.viewTransitButton.clicked.connect(self.viewtransit)
  2224.         self.takeTransitButton.clicked.connect(self.taketransit)
  2225.  
  2226.  
  2227.     def taketransit(self):
  2228.         self.window =usertaketransit()
  2229.         self.close()
  2230.         self.window.show()
  2231.  
  2232.     def viewtransit(self):
  2233.         self.window = userviewtransithistory()
  2234.         self.close()
  2235.         self.window.show()
  2236.  
  2237.     def back_button(self):
  2238.         self.close()
  2239.         loginwindow.show()
  2240.  
  2241.     def exploreevent_button(self):
  2242.         self.window = visitorexploreevent()
  2243.         self.close()
  2244.         self.window.show()
  2245.  
  2246.     def exploresite_button(self):
  2247.         self.window = visitorexploresite()
  2248.         self.close()
  2249.         self.window.show()
  2250.     def viewTransit_button(self):
  2251.         self.window = visitorvisithistory()
  2252.         self.close()
  2253.         self.window.show()
  2254.  
  2255.     def manageprofile_button(self):
  2256.         self.window = staffmanageprofile()
  2257.         self.close()
  2258.         self.window.show()
  2259.     def viewschedule_button(self):
  2260.         self.window = staffviewschedule()
  2261.         self.close()
  2262.         self.window.show()
  2263.  
  2264. class managervisitorfunctionality(QMainWindow, Ui_ManagerVisitorFunctionality):
  2265.     def __init__(self, parent= None):
  2266.         super(managervisitorfunctionality, self).__init__(parent)
  2267.         self.setupUi(self)
  2268.         self.BackButton.clicked.connect(self.back_button)
  2269.         self.exploreEventButton.clicked.connect(self.exploreevent_button)
  2270.         self.exploreSiteButton.clicked.connect(self.exploresite_button)
  2271.         self.viewVisitButton.clicked.connect(self.viewTransit_button)
  2272.         self.viewTransitButton.clicked.connect(self.viewtransit)
  2273.         self.takeTransitButton.clicked.connect(self.taketransit)
  2274.         self.manageEventButton.clicked.connect(self.manage_event_button)
  2275.         self.manageStaffButton.clicked.connect(self.manage_staff_button)
  2276.         self.viewSiteButton.clicked.connect(self.viewsite_button)
  2277.         self.manageProfileButton.clicked.connect(self.manageprofile_button)
  2278.  
  2279.  
  2280.     def taketransit(self):
  2281.         self.window =usertaketransit()
  2282.         self.close()
  2283.         self.window.show()
  2284.  
  2285.     def viewtransit(self):
  2286.         self.window = userviewtransithistory()
  2287.         self.close()
  2288.         self.window.show()
  2289.  
  2290.     def back_button(self):
  2291.         self.close()
  2292.         loginwindow.show()
  2293.     def exploreevent_button(self):
  2294.         self.window = visitorexploreevent()
  2295.         self.close()
  2296.         self.window.show()
  2297.     def exploresite_button(self):
  2298.         self.window = visitorexploresite()
  2299.         self.close()
  2300.         self.window.show()
  2301.     def viewTransit_button(self):
  2302.         self.window = visitorvisithistory()
  2303.         self.close()
  2304.         self.window.show()
  2305.     def manage_event_button(self):
  2306.         self.window = managermanageevent()
  2307.         self.close()
  2308.         self.window.show()
  2309.     def manage_staff_button(self):
  2310.         self.window = managermanagestaff()
  2311.         self.close()
  2312.         self.window.show()
  2313.     def viewsite_button(self):
  2314.         self.window = managersitereport()
  2315.         self.close()
  2316.         self.window.show()
  2317.  
  2318.     def manageprofile_button(self):
  2319.         self.window = staffmanageprofile()
  2320.         self.close()
  2321.         self.window.show()
  2322.  
  2323.  
  2324. if __name__=='__main__':
  2325.     app = QApplication(sys.argv)
  2326.     loginwindow = loginwindow()
  2327.     loginwindow.show()
  2328.     app.exec_()
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top