Skip to content

Commit

Permalink
clean up
Browse files Browse the repository at this point in the history
  • Loading branch information
ramisa2108 committed Dec 11, 2020
2 parents 55ba1f6 + 509d874 commit ff90022
Show file tree
Hide file tree
Showing 11 changed files with 300 additions and 42 deletions.
155 changes: 155 additions & 0 deletions Miscellaneous/Project SQLs/ProjectSQLs.md
Original file line number Diff line number Diff line change
Expand Up @@ -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;
```
Binary file modified Miscellaneous/ReadMe Files/home_gif.gif
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
29 changes: 28 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand All @@ -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 .
Expand All @@ -37,11 +47,28 @@ 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`
* [Md. Zarif Ul Alam](https://github.com/zarif98sjs/) : `1705010`

# Project Supervisor

- [Md. Toufikuzzaman](https://cse.buet.ac.bd/faculty_list/detail/toufikuzzaman)
- [Md. Toufikuzzaman](https://cse.buet.ac.bd/faculty_list/detail/toufikuzzaman)
Binary file modified hotel/__pycache__/views.cpython-37.pyc
Binary file not shown.
Binary file modified hotel/__pycache__/views.cpython-38.pyc
Binary file not shown.
27 changes: 26 additions & 1 deletion hotel/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -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])
Expand Down Expand Up @@ -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')
Expand Down
Binary file modified hotel_admin/__pycache__/views.cpython-38.pyc
Binary file not shown.
Binary file modified register/__pycache__/views.cpython-37.pyc
Binary file not shown.
Binary file modified register/__pycache__/views.cpython-38.pyc
Binary file not shown.
46 changes: 37 additions & 9 deletions register/templates/register/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,32 @@
</head>

<body>

{% if alert_flag or invalid_username%}

<!-- Modal -->
<div class="modal show" id="myModal" role="dialog">
<div class="modal-dialog">
<!-- Modal content-->
<div class="modal-content">
<div class="modal-header" style="background-color: #7729a5;color: whitesmoke">

<h4 class="modal-title">innOcity</h4>

</div>
<div class="modal-body">
<p style="text-align: center">{{ alert_message }}</p>
</div>
<div class="modal-footer" >
<button type="button" class="btn btn-default" data-dismiss="modal" onclick = "$('.modal').removeClass('show').addClass('fade');">Close</button>
</div>
</div>

</div>
</div>
{% endif %}


<header class="header">
<div class="container">
<div class="row">
Expand Down Expand Up @@ -356,15 +382,17 @@ <h2 class="title">Create Account</h2>
}
</script>

{% if alert_flag %}
<script>
alert("Complete the form.");
</script>
{% elif invalid_username %}
<script>
alert("This username is already taken")
</script>
{% endif %}
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.4.1/css/bootstrap.min.css">

{#{% if alert_flag %}#}
{# <script>#}
{# alert("Complete the form.");#}
{# </script>#}
{#{% elif invalid_username %}#}
{# <script>#}
{# alert("This username is already taken")#}
{# </script>#}
{#{% endif %}#}
</body>
</html>
<!-- end document-->
Loading

0 comments on commit ff90022

Please sign in to comment.