From f8271483d37a9b17771b6b5ace30b654cd9f9cf2 Mon Sep 17 00:00:00 2001
From: n9-baker <nathan2.baker@live.uwe.ac.uk>
Date: Mon, 31 Mar 2025 17:09:18 +0100
Subject: [PATCH] view,create,remove bookings_cli are working, manage has SQL
 issues.

---
 README.md                                |   8 +-
 main.py                                  |  99 +++++++++++++---
 src/__pycache__/constants.cpython-38.pyc | Bin 507 -> 507 bytes
 src/__pycache__/dbfunc.cpython-38.pyc    | Bin 4550 -> 4688 bytes
 src/__pycache__/staffUser.cpython-38.pyc | Bin 5260 -> 5513 bytes
 src/dbfunc.py                            |   7 +-
 src/staffUser.py                         | 138 ++++++++++++++---------
 7 files changed, 180 insertions(+), 72 deletions(-)

diff --git a/README.md b/README.md
index 5814983..01316cc 100644
--- a/README.md
+++ b/README.md
@@ -18,4 +18,10 @@ You will now have the SQL database on your own system. Remember any word done to
 To get database connected within coding:
 1. Each person will need to update constants.py file
 2. In file find row 4-7.
-3. Update username & password with your own SQL workbench credentials.
\ No newline at end of file
+3. Update username & password with your own SQL workbench credentials.
+
+
+
+
+questions for clarification:
+- in user.createBooking  and tblBookings is the 'booking_date' the time that the booking is created or the time of the showing?
\ No newline at end of file
diff --git a/main.py b/main.py
index e09e231..fcaa8c0 100644
--- a/main.py
+++ b/main.py
@@ -41,6 +41,8 @@ def loginAttempt(username: str, password: str):
     
     # using dbfuncs to do this:   cursor.execute("SELECT username, password_hash, role FROM users WHERE username = %s AND password_hash = %s", (username, password)) 
     user_data = select_from_table_where("tblUsers", f"username = '{username}' AND password_hash = '{password}'", "user_id, username, password_hash, role, cinemas")
+    if user_data == None:
+        return None
     user_data = user_data[0]
     logging.debug(user_data)
     
@@ -63,10 +65,82 @@ def loginAttempt(username: str, password: str):
         logging.warning("Invalid username or password.")
         return None  # Return None if no user found
 
+def veiwBookings_cli(user):
+    data = user.veiwBookings()
+    logging.debug(f"\n# {data}")
+    print("\n\n")
+    for i in data:
+        print(i)
+    
+def createBooking_cli(user):
+    # input data and validation loop
+    while True:
+        print("Please input booking info.")
+        
+        showing_id = int(input("\nShowing ID:"))
+        seats = input("\nSeats in format '1' or '1 2 3' (no dupes):")
+        if showing_id == "exit" or seats == "exit":
+            return
+        elif showing_id != None and seats != None:
+            status = user.createBooking(showing_id, seats)
+            if status == True:
+                print("Booking created.")
+                createTicket_cli(user, booking_id)
+                break
+            else:
+                print(status)
+        else:
+            print("Missing input please try again.")
+
+def removeBooking_cli(user):
+    booking_id = int(input("\nInput Id of booking to remove: "))
+    user.removeBooking(booking_id)
+
+def manageBookings_cli(user):
+    veiwBookings_cli(user)
+    selected_booking = 0
+    # input val loop for booking_id
+    while True:
+        selected_booking = int(input("\nSelect booking_id to be managed: "))
+        logging.debug(f"selected_booking={selected_booking}")
+        if selected_booking == None or selected_booking == 0:
+            print("Invalid input try again.")
+        else:
+            selected_booking = select_from_table_where(table="tblBookings", selection="*", condition=f"booking_id={selected_booking}")
+            logging.debug(f"selected_booking={selected_booking}")
+            if selected_booking is not None:
+                break
+            else:
+                print("db error, try again.") # lol
+    # input for new vals
+    print("Input new values for booking, or leave blank for no change.")
+    user_id = int(input("user_id: "))
+    showing_id = int(input("showing_id: "))
+    seat_numbers= input("seat_numbers: ")
+    total_price= float(input("total_price: "))
+    booking_date= input("booking_date: ")
+    
+    status = user.updateBooking(booking_id=selected_booking, user_id=user_id, showing_id=showing_id, seat_numbers=seat_numbers, total_price=total_price, booking_date=booking_date)
+    if status:
+        print("Booking updated")
+    else:
+        print("Failed to update booking.")
+    
+def createTicket_cli(user, booking_id=None):
+    while booking_id == None:
+        booking_id = intput("Input booking_id to create a ticket")
+        if booking_id.isdigit():
+            booking_id = int(booking_id)
+            break
+        else:
+            print("Invalid booking_id.")
+    pass
+    # create ticket...
+
 def staffUser_options_cli(user:StaffUser) -> None:
     logging.debug("loaded into staffUser_options_cli.")
     while True:
-        selection = input("Menu options:\n"
+        selection = input("\nMenu options:\n"
                           "  1. View bookings\n"
                           "  2. Create booking \n"
                           "  3. Remove booking\n"
@@ -82,20 +156,16 @@ def staffUser_options_cli(user:StaffUser) -> None:
         # switch case:
         if selection == "1":
             logging.debug("selection 1, loading View bookings")
-            data = user.veiwBookings()
-            print(data)
-            print(type(data))
-            logging.debug(f"\n# {data}")
+            veiwBookings_cli(user)
         elif selection == "2":
             logging.debug("selection 2, loading Create booking")
-            user.createBooking()
+            createBooking_cli(user)
         elif selection == "3":
             logging.debug("selection 3, Remove booking")
-            user.removeBooking()
+            removeBooking_cli(user)
         elif selection == "4":
             logging.debug("selection 4, Manage existing booking")
-            user.veiwBookings()
-            user.updateBooking()
+            manageBookings_cli(user)
         elif selection == "5":
             logging.debug("selection 5, Create ticket")
             user.createTicket()
@@ -113,7 +183,7 @@ def staffUser_options_cli(user:StaffUser) -> None:
 def adminUser_options_cli(user:AdminUser) -> None:
     logging.debug("loaded into adminUser_options_cli.")
     while True:
-        selection = input("Menu options:\n"
+        selection = input("\nMenu options:\n"
                           "  1. View bookings\n"
                           "  2. Create booking \n"
                           "  3. Remove booking\n"
@@ -188,7 +258,7 @@ def adminUser_options_cli(user:AdminUser) -> None:
 def managerUser_options_cli(user:ManagerUser) -> None:
     logging.debug("loaded into managerUser_options_cli.")
     while True:
-        selection = input("Menu options:\n"
+        selection = input("\nMenu options:\n"
                           "  1. View bookings\n"
                           "  2. Create booking \n"
                           "  3. Remove booking\n"
@@ -333,9 +403,10 @@ def encrypt(string:str) -> str:
 def main_cli() -> None:
     print("\n\nSTARTING CINEMA MANAGEMENT SYSTEM.\n\n")
     # test db is connected....
-    #if not getConnection():
-    #    logging.critical("Database cannot connect, or dose not exist. \nClosing application.")
-    #    exit()
+    if not get_connection():
+        logging.critical("Database cannot connect, or dose not exist. \nClosing application.")
+        exit()
+    # cli loggin attempt
     print("To login please enter your credentials.\n")
     while True:
         username = encrypt(sanitize(input("username: ")))
diff --git a/src/__pycache__/constants.cpython-38.pyc b/src/__pycache__/constants.cpython-38.pyc
index 5ea3abf5d9a57105ebe07c9c1a834cae2e71d7a8..87b52b088241433803228ade4bd96969d18f15de 100644
GIT binary patch
delta 19
acmey({F|98l$V!_fq{X+ebGj)kBk5`O$8PJ

delta 19
acmey({F|98l$V!_fq{WxLjOjtkBk5{qy<a>

diff --git a/src/__pycache__/dbfunc.cpython-38.pyc b/src/__pycache__/dbfunc.cpython-38.pyc
index 8346d03f6a931ec3d5de2fd06882ba260d0076ca..af1388cc55098aac94986f5c8c7e356c1403c902 100644
GIT binary patch
delta 833
zcmX@6d_jdbl$V!_fq{YH!j4zzUpMk@;b8o=`49&?BcsmbQ=D32e;61TN*J0MYME-7
ziuqC)gBhx>RZW=8#pP6A!nS}tg`<XTHbV+$2}cd%0?vgD&5W}d=CUkgWMrseUcgnu
zh7e!K#K=&?w19gd10zET+X9{xE|98lhH!>O9x2?x3@i*Kyjgr%{MlSZ4;UG0*%=wC
z<Vx5U2&C}Tu+L_g%LGv!$*_ncoMDkz3S%%cLkjQYHC)Q9yul2be3P$m1&S4EGB7Yy
z@vG}7q$HLk>Xjwtl%^KjPFCf%U=*Aj$E~2s$H2f)q|Ly<aErC1v>+$-78^uOkvvF@
zEjd3oH?w5&JYFdUjv_^nT3rw!3?gJfD%g|rb4qjbii?aUU*tB?QUL`V6B{E7BMTD?
zBL^cNqX?q}qa33MBL^cFBNw9xqX44<69;3F>1JJ?3`R!d$<ug~8S^Lq;#D^>V_;xN
zW(FAm#heTb44{~BW?*0_egg}3<{D;bupg^xm>kMyR$sze!?=JA6x6lsCF~10U{L@L
zCP>h;Ea0qRt6>KRIr9Q8aFDYv;KmZ<JXyS1eA!$@7Z@38Ilw{AzJNc4r-lP-kTaz4
z)~a*VaYQggGUPEuFoZLhGSsjvU<6rE!wjJ#7*Ze+BF?{@v1jsrerIJ!v<RX`i-x9c
zm6S_jNuok&K}zCeLvG>83IY<Q0!8AW(3Sxapdc@j1F`f$gdvD90uk_N1jk#E@#NXO
zvK*Yy7@OQLpv)b`2}%L+iA6<~lM6USCm$E!)o%d>EP9klFp4qqfH7K>Sxx>gP$;GY
ciglKh%;b_HQ;^M|SSzxc+$LztEWsfP01!F1rT_o{

delta 582
zcmcbha!i>wl$V!_fq{YH>HJsewi|i3a4=SFKE%P!$f!N}6sMNhEd~aL5{71mTBaJN
zV!jl{V1}wKRe6)SxSTv{m>00su+=awU|-0vkcp9@hG_xELIy^L63zu&DI5zK85zPE
z!WkBMq;Li^urQQxXYpk5W^)zoV`QjhXJn|7E8$$gm%>%UK8aVHk$dtvE@f8kU<OT|
z$=|pFC&zMIF!E2{C?GO<6*rHFJOcy6Ew-}6oYK_dTWrbsxw)AolkfA&b8r+XGB7X{
z=}i91EzW2#S%6P&vN4aCh7!m_Ol*uSj4Vtnj2w)7j3SH@i~@`tj9iRdj3SHzj0#K~
zj77$qi+M5_84V}j;Z0`Do9w`+&St{Ez>v&5`3|Rq*d>_HnQNG#K3`LnHhDImnNJPN
z0@fO~5~$ys8Nt41Cd&8Qu=rk+yOzC<J%S;UA&)77A)LXKp@wAvBPb|qm?3loLkc8p
z%K4Wwc2AZUaGqQxU<M8$QE@#`5P*Y-wWPElC$-1`BmnZ25+Z=O1eGTjaEea$739@!
zW?*0_RzM3Q2}UtS5%dtUoZKl`D5ebxewLKX<dPy|kkOz(Dzcm`AY{ud&LIi_5(a<W

diff --git a/src/__pycache__/staffUser.cpython-38.pyc b/src/__pycache__/staffUser.cpython-38.pyc
index f2c28d2f5ea35cd2431b03f79b2148e91e4e7a19..e56a1ec292d1c9bcb4822fff91787f8ac3f0476b 100644
GIT binary patch
delta 1648
zcmeCt?9}E9<>lpKU|?X_wEb1Oo5DoC1B|mKo=>((Wlm*D5t_r4BAg=9!V<-sBAO!B
z!Vtxm%AdkMhcQJwMWTfzN+3ltMXH4%N-#w_MW%%zN+^Xbm_bu^a}HxQN4+M~Ew18>
z{PN7a^!Ut_Tdc*Yi6zC!%pkj<n3I8lft`VY!I^=9p*V?=fuV#Ug)xOGg}H`tHp5(|
z6qa7*TIL$&6jn)wTILeQ1xzK(HO$S73mF+1K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p35uHe+fl46C-JcYFUqTIw1
z1$9Gph5RA~bwdRs1!Hvujl6t?l+uFKVofW*$p^XR88s(A<kp(Z!&A(dJh_2qf;?9-
z#JKp(lqgORJH8|{H&v6hh=+lJp~!r)5pVG1HeN%sDtX_`;$o1!5LXpIoLEv+sgRhS
zn3<=i$#;vjpeQr1q{xVYf#DV_SlQ&Ayr$N-m~%7pZZYSi=G|gR$xJQ*8yzK>nOB@z
zR1%+=SCSuJl9-f}s>xo&54Mznfgy^u804|Z_IxsoW|MRHj6Iw{iJp~%iHDJcQG|(w
zk%^Jx9~(0VBOjvx6BiQ~qX3A-2omS{$HvUVD8Qt^B)}-cC;$@s&&I^U#Kp|TTqQoa
zk4JoRr9c;>^<);oAjZ1MydnzqPLMDz)?@)YuE-qZ4hs-r$-uyn%nq^}ia8h<7+4t?
z7{EDY3IiyoEMQClr|e9ITJ{>I6sBy>B9$8U1xzW-HB6acnHpxWs1;b0rG^<Q$^sS*
zs0jusX02g?3bTTR)4+<^YFMG7Y+%tEuqb;C8$`5(IfbK!J%tmR?YMfG85vTTf*CZq
zCrb)>%J^aPPLUPJW7d<qh2;HMiljgsX;750l@_EVmZTP`FfcG^a)9F^iVK?h;xkil
z8g+}KIJG1`C9x!NlCYd|8>j>U8Op%S#mK@4iXb%1G}%&kv4B3vUN;co4kA1!zY$ho
zoH3bKM3arx4+JKgil}pf(-L!WNzvp~5iNOFkV+R2;RSLqYg$fzVo8xNNWhPQfnjoh
zsL134B3x2p3=9k$jAGmzTztHIJbdgNoE)qihI|}iLX)3~L<snU6If|+YLQ`)4Md*_
Kt0D&z8zTVvggdeT

diff --git a/src/dbfunc.py b/src/dbfunc.py
index 828e58a..fd4179c 100644
--- a/src/dbfunc.py
+++ b/src/dbfunc.py
@@ -95,7 +95,8 @@ def insert_into_table(table:str, data:dict):
         columns = ', '.join(data.keys())
         values = ', '.join(['%s'] * len(data))
         query = f"INSERT INTO {table} ({columns}) VALUES ({values})"
-        cursor.execute(query, data.values())
+        logging.debug(f"query='{query}', data.values={tuple(data.values())}")
+        cursor.execute(query, tuple(data.values()))
         conn.commit()
         logging.info("Data inserted successfully.")
         return True
@@ -138,7 +139,9 @@ def update_table(table, data, condition):
         cursor = conn.cursor()
         set_clause = ', '.join([f"{key} = %s" for key in data.keys()])
         query = f"UPDATE {table} SET {set_clause} WHERE {condition}"
-        cursor.execute(query, tuple(data.values()))
+        data_arry = tuple(data.values())
+        logging.debug(f"query='{query}', data.values()={data_arry}")
+        cursor.execute(query, data_arry)
         conn.commit()
         logging.info("Data updated successfully.")
         return True
diff --git a/src/staffUser.py b/src/staffUser.py
index 2d9b4e4..560b6c4 100644
--- a/src/staffUser.py
+++ b/src/staffUser.py
@@ -74,54 +74,68 @@ class StaffUser:
         """
         raise NotImplementedError()
     
-    def createBooking(self):
+    def createBooking(self, showing_id:int, seats:str):
         """ Adds booking to db and returns ticket if succsessful.
         """
-        # input data and validation loop
-        while True:
-            print("Please input booking info.")
+        
+        # import showing data
+        showing_data = select_from_table_where(table="tblShowings",
+                                                selection="*",
+                                                condition=f"showing_id={showing_id}")
+        showing_data = showing_data[0]
+        logging.debug(type(showing_data))
+        logging.debug(f"showing_data={showing_data}")
+        
+        # check if showing_data was returned from db
+        if showing_data != None:
+            # validate selected seats
+            seats = seats.split(" ")
+            logging.debug(f"seats.split={seats}")
+            seats = [int(x) for x in seats]      # use while seats are int, remove when seats are str.
+            logging.debug(f"seats.int={seats}")
+            seating_cap = select_from_table_where(table="tblScreens",
+                                                    selection="seating_capacity",
+                                                    condition=f"screen_id={showing_data['screen_id']}")
+            seating_cap = seating_cap[0]['seating_capacity']
+            logging.debug(f"seating_cap={seating_cap}")
             
-            showing_id = int(input("\nShowing ID:"))
-            seats = input("\nSeats in format '1' or '1 2 3' (no dupes):")
-            if showing_id != None and seats != None:
-                # import showing data
-                showing_data = select_from_table_where(table="tblShowings",
-                                                       selection="*",
-                                                       condition=f"showing_id={showing_id}")
-                showing_data = showing_data[0]
-                logging.debug(type(showing_data))
-                logging.debug(f"showing_data={showing_data}")
-                # check if showing_data was returned from db
-                if showing_data != None:
-                    # validate selected seats
-                    seats = seats.split(" ")
-                    logging.debug(f"seats.split={seats}")
-                    seats = [int(x) for x in seats]      # use while seats are int, remove when seats are str.
-                    logging.debug(f"seats.int={seats}")
-                    seating_cap = select_from_table_where(table="tblScreens",
-                                                           selection="seating_capacity",
-                                                           condition=f"screen_id={showing_data['screen_id']}")
-                    seating_cap = seating_cap[0]['seating_capacity']
-                    logging.debug(f"seating_cap={seating_cap}")
-                    # check if seat selection in range
-                    if max(seats) <= int(seating_cap) and min(seats) > 0:
-                        # showing_id and seats exist, and seat selection is in range now save to tblBookings
-                        price = showing_data['price'] * len(seats)
-                        insert_data=dict(user_id=self.user_id, showing_id=showing_data['showing_id'], seat_numbers=seats, total_price=price, booking_date=showing_data['show_time'])
-                        logging.debug(f"insert_data={insert_data}")
-                        insert_into_table(table="tblBookings",
-                                          data=insert_data)
-                        return
-                        
-                    print("Invalid seating selection.")
-
-                else:
-                    print("Invalid showing_id.")
+            # check if seat selection in range
+            if max(seats) <= int(seating_cap) and min(seats) > 0: # if seats are str this needs reworking.
+                # now save to tblBookings
+                price = showing_data['price'] * len(seats)
+                seats_str = ""
+                
+                for i in range(len(seats)):
+                    seats_str = seats_str + str(seats[i]) + ","
                     
-            else:
-                print("Missing input please try again.")
+                seats_str = seats_str[:-1]
+                insert_data=dict(user_id=self.user_id, showing_id=showing_data['showing_id'], seat_numbers=seats_str, total_price=float(price), booking_date=showing_data['show_time'])
+                logging.debug(f"insert_data={insert_data}")
+                insert_into_table(table="tblBookings",
+                                    data=insert_data)
+                return True
+                
+            return "Invalid seating selection."     # needs to be updated for non cli use
+
+        else:
+            return "Invalid showing_id."            # needs to be updated for non cli use
+      
+    def removeBooking(self, booking_id):
+        """ remove bookings from db
+        """
+        logging.debug("called StaffUser.removeBooking method")
+        booking_exists = select_from_table_where(table="tblBookings", selection="booking_id", condition=f"booking_id={booking_id}")
         
-            
+        if booking_exists == None:
+            return False
+
+        if delete_from_table(table="tblBookings", condition=f"booking_id={booking_id}"):
+            return True
+        else:
+            return "db error."      # needs to be updated for non cli use
+        
+        
+
 
     def veiwBookings(self) -> dict:
         """ Gets bookings from db
@@ -131,23 +145,37 @@ class StaffUser:
         logging.debug(data)
         return data
     
-    def updateBooking(self, booking_id, user_id:int=None, showing_id:int=None, seat_numbers:list=None, total_price:float=None, booking_date=None):
+    def updateBooking(self, booking_id, **kwargs):
+                      #user_id:int=None, showing_id:int=None, seat_numbers:list=None, total_price:float=None, booking_date=None):
         """ updates existing booking from db
         """
         logging.debug("called manageBooking method")
+        logging.debug(f"kwargs={kwargs}, {type(kwargs)}")
         set_data = {}
-        if user_id is not None:
-            set_data.update({'user_id':user_id})
-        if showing_id is not None:
-            set_data.update({'showing_id':showing_id})
-        if seat_numbers is not None:
-            set_data.update({'seat_numbers':seat_numbers}) 
-        if total_price is not None:
-            set_data.update({'total_price':total_price})
-        if booking_date is not None:
-            set_data.update({'booking_date':booking_date}) 
+        for key, value in kwargs.items():
+            if value:
+                set_data.update({key: value})
+        
+        #dict({key:value} for key, value in kwargs.items() if not value)
+        
         
-        update_table("tblBookings", data=set_data, condition=f"booking_id = {booking_id}")
+        
+        
+        """
+        if kwargs['user_id'] != None or kwargs['user_id'] != "":
+            set_data.update({'user_id':kwargs['user_id']})
+        if kwargs['showing_id'] != None or kwargs['showing_id'] != "":
+            set_data.update({'showing_id':kwargs['showing_id']})
+        if kwargs['seat_numbers'] is not None or kwargs['seat_numbers'] != "":
+            set_data.update({'seat_numbers':kwargs['seat_numbers']}) 
+        if kwargs['total_price'] is not None or kwargs['total_price'] != "":
+            set_data.update({'total_price':kwargs['total_price']})
+        if kwargs['booking_date'] is not None or kwargs['booking_date'] != "":
+            set_data.update({'booking_date':kwargs['booking_date']})
+        """    
+        logging.debug(f"set_data={set_data}, booking_id={booking_id}")
+        status = update_table("tblBookings", data=set_data, condition=f"booking_id = {booking_id}")
+        return status
     
     def veiwShowings(self):
         """ Gets showings from db
-- 
GitLab