diff --git a/Miscellaneous/Project SQLs/ProjectSQLs.md b/Miscellaneous/Project SQLs/ProjectSQLs.md index 9c9b2a32..9011f025 100644 --- a/Miscellaneous/Project SQLs/ProjectSQLs.md +++ b/Miscellaneous/Project SQLs/ProjectSQLs.md @@ -487,4 +487,159 @@ with connection.cursor() as cur: cur.execute(sql, list_vars) result = cur.fetchall() +``` + +# **PL SQLS** + +`ADD_NEW_FREE_SERVICE` +```sql +CREATE OR REPLACE PROCEDURE "ADD_NEW_FREE_SERVICE"(HID IN NUMBER, FAC IN VARCHAR2,EXISTING OUT NUMBER) AS + +BEGIN + SELECT COUNT(*) INTO EXISTING FROM HOTEL_FACILITY WHERE HOTELID = HID AND FACILITIES = INITCAP(FAC); + IF EXISTING = 0 THEN + INSERT INTO HOTEL_FACILITY VALUES(HID, INITCAP(FAC)); + END IF; +END; +``` + +`ADD_NEW_PAID_SERVICE` +```sql +CREATE OR REPLACE PROCEDURE "ADD_NEW_PAID_SERVICE"(S_TYPE IN VARCHAR2, S_SUBTYPE IN VARCHAR2, +COST IN NUMBER, HID IN NUMBER, EXISTING OUT NUMBER) +AS + SID NUMBER; +BEGIN + SELECT SERVICEID INTO EXISTING FROM SERVICE WHERE HOTELID = HID AND SERVICE_TYPE = INITCAP(S_TYPE) AND + SERVICE_SUBTYPE = INITCAP(S_SUBTYPE); +EXCEPTION + WHEN NO_DATA_FOUND THEN + EXISTING := 0; + SID := GENERATE_ID('SERVICE', 'SERVICEID'); + INSERT INTO SERVICE VALUES(SID, INITCAP(S_TYPE), INITCAP(S_SUBTYPE), COST, HID); +END; +``` + +`ADD_NEW_ROOM` +```sql +CREATE OR REPLACE PROCEDURE "ADD_NEW_ROOM"(HID IN NUMBER, RT_NAME IN VARCHAR2, FL_NUM IN NUMBER, RID OUT NUMBER) +AS + RTID NUMBER; +BEGIN + SELECT ROOMTYPEID INTO RTID FROM ROOM_TYPE WHERE HOTELID = HID AND ROOMTYPE_NAME = RT_NAME; + RID := GENERATE_ID('ROOM', 'ROOMID'); + INSERT INTO ROOM(ROOMID, FLOOR_NUMBER, HOTELID, ROOMTYPEID) VALUES(RID, FL_NUM, HID, RTID); +EXCEPTION + WHEN NO_DATA_FOUND THEN + RID := 0; + DBMS_OUTPUT.PUT_LINE('NO DATA'); + WHEN OTHERS THEN + RID := 0; + DBMS_OUTPUT.PUT_LINE('OTHER ERROR'); +END; +``` + +`ADD_NEW_ROOM_TYPE` +```sql +CREATE OR REPLACE PROCEDURE "ADD_NEW_ROOM_TYPE"(RT IN VARCHAR2, HID IN NUMBER, BT IN VARCHAR2, COST IN NUMBER, DISC IN NUMBER,EXISTING OUT NUMBER) AS + RTID NUMBER; +BEGIN + SELECT ROOMTYPEID INTO EXISTING FROM ROOM_TYPE WHERE HOTELID = HID AND UPPER(ROOMTYPE_NAME) = UPPER(RT); +EXCEPTION + WHEN NO_DATA_FOUND THEN + EXISTING := 0; + RTID := GENERATE_ID('ROOM_TYPE', 'ROOMTYPEID'); + INSERT INTO ROOM_TYPE(ROOMTYPEID, ROOMTYPE_NAME, BED_TYPE, COST_PER_DAY, DISCOUNT, HOTELID) VALUES(RTID, + INITCAP(RT), INITCAP(BT), COST, DISC, HID); +END; +``` + +`GENERATE_ID` +```sql +CREATE OR REPLACE FUNCTION "GENERATE_ID"(TABLE_NAME IN VARCHAR2, COLUMN_NAME IN VARCHAR2) RETURN NUMBER +AS + ID NUMBER; + EXISTING NUMBER; + SQ VARCHAR2(100); +BEGIN + LOOP + ID := ROUND(10000000 + DBMS_RANDOM.VALUE() * (99999999-10000000)); + SQ := 'SELECT COUNT(*) FROM ' || TABLE_NAME || ' WHERE ' || COLUMN_NAME || ' = :1'; + EXECUTE IMMEDIATE SQ INTO EXISTING USING ID; + EXIT WHEN (EXISTING = 0); + END LOOP; + RETURN ID; +END; +``` + +`LOGIN_CUSTOMER` +```sql +CREATE OR REPLACE FUNCTION "LOGIN_CUSTOMER"(UNAME IN VARCHAR2, PASS IN VARCHAR2) RETURN INT -- VARCHAR2 +AS + CID NUMBER; +BEGIN + SELECT CUSTOMERID INTO CID FROM CUSTOMER WHERE USERNAME = UNAME AND PASSWORD = PASS AND ISVERIFIED = 'YES'; + RETURN CID; +EXCEPTION + WHEN NO_DATA_FOUND THEN + RETURN 0; +END; +``` + +`LOGIN_HOTEL` +```sql +CREATE OR REPLACE FUNCTION "LOGIN_HOTEL"(HID IN VARCHAR2, PASS IN VARCHAR2) RETURN NUMBER +AS + RES NUMBER; +BEGIN + SELECT HOTELID INTO RES FROM HOTEL WHERE HOTELID = HID AND PASSWORD = PASS; + RETURN RES; +EXCEPTION + WHEN NO_DATA_FOUND THEN + RETURN 0; + WHEN OTHERS THEN + RETURN 0; +END; +``` + +`RATING_TRIGGER` +```sql +CREATE TRIGGER "INNOCITY"."RATING_TRIGGER" AFTER UPDATE OF "RATING" ON "INNOCITY"."RESERVATION" REFERENCING OLD AS "OLD" NEW AS "NEW" FOR EACH ROW +DECLARE + HOTEL_RATING NUMBER; + RATING_COUNT NUMBER; +BEGIN + SELECT RATING, RATINGCOUNT INTO HOTEL_RATING, RATING_COUNT FROM HOTEL WHERE HOTELID = :OLD.HOTELID; + IF :OLD.RATING IS NULL THEN + + HOTEL_RATING := (HOTEL_RATING * RATING_COUNT + :NEW.RATING)/(RATING_COUNT + 1); + RATING_COUNT := RATING_COUNT + 1; + + ELSE + HOTEL_RATING := (HOTEL_RATING * RATING_COUNT - :OLD.RATING + :NEW.RATING )/RATING_COUNT; + + END IF; + UPDATE HOTEL SET RATING = HOTEL_RATING, RATINGCOUNT = RATING_COUNT WHERE HOTELID = :OLD.HOTELID; +END; +``` + +`REGISTER` +```sql +CREATE OR REPLACE FUNCTION "REGISTER"(C_NAME IN VARCHAR2, C_EMAIL IN VARCHAR2, C_UNAME IN VARCHAR2, C_PASSWORD IN VARCHAR2,C_GENDER IN VARCHAR2, C_STREET IN VARCHAR2, C_ZIPCODE IN VARCHAR2, C_CITY IN VARCHAR2, C_COUNTRY IN VARCHAR2, +C_PHONE IN VARCHAR2) +RETURN NUMBER +AS + CID NUMBER; + EXISTING NUMBER; +BEGIN + SELECT COUNT(*) INTO EXISTING FROM CUSTOMER WHERE USERNAME = C_UNAME; + IF EXISTING > 0 THEN + CID := 0; + ELSE + CID := GENERATE_ID('CUSTOMER', 'CUSTOMERID'); + INSERT INTO CUSTOMER VALUES(CID, C_NAME, C_EMAIL, C_UNAME, C_PASSWORD, C_GENDER, C_STREET, C_ZIPCODE, + C_CITY, C_COUNTRY, C_PHONE, 'NO'); + END IF; + RETURN CID; +END; ``` \ No newline at end of file diff --git a/Miscellaneous/ReadMe Files/home_gif.gif b/Miscellaneous/ReadMe Files/home_gif.gif index 264e76df..344eb601 100644 Binary files a/Miscellaneous/ReadMe Files/home_gif.gif and b/Miscellaneous/ReadMe Files/home_gif.gif differ diff --git a/README.md b/README.md index 5cda5c52..98c2ec74 100644 --- a/README.md +++ b/README.md @@ -3,6 +3,7 @@ ![](/Miscellaneous/ReadMe%20Files/home2.png) # Project Overview +innOcity is a hotel booking platform designed using Oracle database and django framework. This website was built as our Database course project. # Programming Language @@ -25,6 +26,15 @@ Upon registration the user will be sent a verification mail . Using the link , t ![](/Miscellaneous/ReadMe%20Files/register_gif.gif) ![](/Miscellaneous/ReadMe%20Files/activation_gif.gif) +## `Hotels` +Available hotels based on search location and dates will be returned. +User can visit the hotel pages and check out the rooms and services +Rooms and services can be booked in the booking sections +Payment can be done by credit card or mobile banking. Information saved in users wallet can be used her. + +![](/Miscellaneous/ReadMe%20Files/hotel.gif) + + ## `Dashboard` - Past Visits in Map - All the past visits can be viewed from here . @@ -37,6 +47,23 @@ Upon registration the user will be sent a verification mail . Using the link , t ![](Miscellaneous/ReadMe%20Files/dashboard_gif.gif) +## `Admin Dashboard` +Hotel data can be updated by logging in as hotel admin +- Rooms + - Update room charges and discounts + - Add new room + - Add new room type + - Services + - Add new free/ paid service + - Update cost for paid service + - Delete a free service + - Reservations + - View hotel income in a plot + - view the details of all the reservations + - Search by year/ month / room types + + ![](Miscellaneous/ReadMe%20Files/admin.gif) + # Project Team * [Ramisa Alam](https://github.com/ramisa2108) : `1705004` @@ -44,4 +71,4 @@ Upon registration the user will be sent a verification mail . Using the link , t # Project Supervisor -- [Md. Toufikuzzaman](https://cse.buet.ac.bd/faculty_list/detail/toufikuzzaman) \ No newline at end of file +- [Md. Toufikuzzaman](https://cse.buet.ac.bd/faculty_list/detail/toufikuzzaman) diff --git a/hotel/__pycache__/views.cpython-37.pyc b/hotel/__pycache__/views.cpython-37.pyc index 8b224f2d..fecc310a 100644 Binary files a/hotel/__pycache__/views.cpython-37.pyc and b/hotel/__pycache__/views.cpython-37.pyc differ diff --git a/hotel/__pycache__/views.cpython-38.pyc b/hotel/__pycache__/views.cpython-38.pyc index 3a989266..8ae326f9 100644 Binary files a/hotel/__pycache__/views.cpython-38.pyc and b/hotel/__pycache__/views.cpython-38.pyc differ diff --git a/hotel/views.py b/hotel/views.py index 56e19225..a1634eda 100644 --- a/hotel/views.py +++ b/hotel/views.py @@ -197,7 +197,7 @@ def get_customer_info(customer_id): customer.card_username = result[1] customer.card_type = result[2] customer.cvc = result[3] - customer.expiration = result[4] + customer.expiration = str(result[4].date()) cur.execute("SELECT PHONE_NUMBER , SERVICE_PROVIDER , CUSTOMERID FROM MOBILE_BANKING " "WHERE customerId = %s",[customer_id]) @@ -322,6 +322,31 @@ def complete_payment(request, hotel_id): reservation_charge=context['total_cost']) context['reservation_list'] = r + + with connection.cursor() as cur: + sql_add_payment = "INSERT INTO PAYMENT " \ + "VALUES (%s, SYSDATE)" + cur.execute(sql_add_payment, [payment_id]) + connection.commit() + sql_add_reservation = "INSERT INTO RESERVATION (RESERVATIONID, DATE_OF_ARRIVAL, DATE_OF_DEPARTURE, CUSTOMERID, " \ + "PAYMENTID, HOTELID, RESERVATION_CHARGE) " \ + "VALUES ( %s, %s, %s , %s , %s , %s , %s )" + cur.execute(sql_add_reservation, + [r.reservationid, r.date_of_arrival, r.date_of_departure, r.customerid, r.paymentid, r.hotelid, + r.reservation_charge]) + connection.commit() + + with connection.cursor() as cur: + + for r in booked_room_id: + sql_add_room = "INSERT INTO RESERVATION_ROOM VALUES(%s, %s)" + cur.execute(sql_add_room, [reservation_id, r]) + connection.commit() + + for s in booked_services: + cur.execute("INSERT INTO RESERVATION_SERVICE VALUES(%s, %s, %s)", [reservation_id, s.serviceId, s.count]) + connection.commit() + send_booking_mail(context) return redirect('dashboard:maps') diff --git a/hotel_admin/__pycache__/views.cpython-38.pyc b/hotel_admin/__pycache__/views.cpython-38.pyc index cce521d5..2c2da423 100644 Binary files a/hotel_admin/__pycache__/views.cpython-38.pyc and b/hotel_admin/__pycache__/views.cpython-38.pyc differ diff --git a/register/__pycache__/views.cpython-37.pyc b/register/__pycache__/views.cpython-37.pyc index e07982a5..28f00d89 100644 Binary files a/register/__pycache__/views.cpython-37.pyc and b/register/__pycache__/views.cpython-37.pyc differ diff --git a/register/__pycache__/views.cpython-38.pyc b/register/__pycache__/views.cpython-38.pyc index fe36639c..a89767ea 100644 Binary files a/register/__pycache__/views.cpython-38.pyc and b/register/__pycache__/views.cpython-38.pyc differ diff --git a/register/templates/register/index.html b/register/templates/register/index.html index 993d9027..092d315d 100644 --- a/register/templates/register/index.html +++ b/register/templates/register/index.html @@ -110,6 +110,32 @@
+ +{% if alert_flag or invalid_username%} + + +