|
| 1 | +<!-- PHP INCLUDES --> |
| 2 | + |
| 3 | +<?php |
| 4 | + //Set page title |
| 5 | + $pageTitle = 'Table Reservation'; |
| 6 | + |
| 7 | + include "connect.php"; |
| 8 | + include 'Includes/functions/functions.php'; |
| 9 | + include "Includes/templates/header.php"; |
| 10 | + include "Includes/templates/navbar.php"; |
| 11 | + |
| 12 | + |
| 13 | +?> |
| 14 | + |
| 15 | + <style type="text/css"> |
| 16 | + .table_reservation_section |
| 17 | + { |
| 18 | + max-width: 850px; |
| 19 | + margin: 50px auto; |
| 20 | + min-height: 500px; |
| 21 | + } |
| 22 | + |
| 23 | + .check_availability_submit |
| 24 | + { |
| 25 | + background: #ffc851; |
| 26 | + color: white; |
| 27 | + border-color: #ffc851; |
| 28 | + font-family: work sans,sans-serif; |
| 29 | + } |
| 30 | + .client_details_tab .form-control |
| 31 | + { |
| 32 | + background-color: #fff; |
| 33 | + border-radius: 0; |
| 34 | + padding: 25px 10px; |
| 35 | + box-shadow: none; |
| 36 | + border: 2px solid #eee; |
| 37 | + } |
| 38 | + |
| 39 | + .client_details_tab .form-control:focus |
| 40 | + { |
| 41 | + border-color: #ffc851; |
| 42 | + box-shadow: none; |
| 43 | + outline: none; |
| 44 | + } |
| 45 | + .text_header |
| 46 | + { |
| 47 | + margin-bottom: 5px; |
| 48 | + font-size: 18px; |
| 49 | + font-weight: bold; |
| 50 | + line-height: 1.5; |
| 51 | + margin-top: 22px; |
| 52 | + text-transform: capitalize; |
| 53 | + } |
| 54 | + .layer |
| 55 | + { |
| 56 | + height: 100%; |
| 57 | + background: -moz-linear-gradient(top, rgba(45,45,45,0.4) 0%, rgba(45,45,45,0.9) 100%); |
| 58 | + background: -webkit-linear-gradient(top, rgba(45,45,45,0.4) 0%, rgba(45,45,45,0.9) 100%); |
| 59 | + background: linear-gradient(to bottom, rgba(45,45,45,0.4) 0%, rgba(45,45,45,0.9) 100%); |
| 60 | + } |
| 61 | + |
| 62 | + </style> |
| 63 | + |
| 64 | + <!-- START ORDER FOOD SECTION --> |
| 65 | + |
| 66 | + <section style=" |
| 67 | + background: url(Design/images/food_pic.jpg); |
| 68 | + background-position: center bottom; |
| 69 | + background-repeat: no-repeat; |
| 70 | + background-size: cover;"> |
| 71 | + <div class="layer"> |
| 72 | + <div style="text-align: center;padding: 15px;"> |
| 73 | + <h1 style="font-size: 120px; color: white;font-family: 'Roboto'; font-weight: 100; |
| 74 | +">Book a Table</h1> |
| 75 | + </div> |
| 76 | + </div> |
| 77 | + |
| 78 | + </section> |
| 79 | + |
| 80 | + <section class="table_reservation_section"> |
| 81 | + |
| 82 | + <div class="container"> |
| 83 | + <?php |
| 84 | + |
| 85 | + if(isset($_POST['submit_table_reservation_form']) && $_SERVER['REQUEST_METHOD'] === 'POST') |
| 86 | + { |
| 87 | + // Selected Date and Time |
| 88 | + |
| 89 | + $selected_date = $_POST['selected_date']; |
| 90 | + $selected_time = $_POST['selected_time']; |
| 91 | + |
| 92 | + $desired_date = $selected_date." ".$selected_time; |
| 93 | + |
| 94 | + //Nbr of Guests |
| 95 | + |
| 96 | + $number_of_guests = $_POST['number_of_guests']; |
| 97 | + |
| 98 | + //Table ID |
| 99 | + |
| 100 | + $table_id = $_POST['table_id']; |
| 101 | + |
| 102 | + //Client Details |
| 103 | + |
| 104 | + $client_full_name = test_input($_POST['client_full_name']); |
| 105 | + $client_phone_number = test_input($_POST['client_phone_number']); |
| 106 | + $client_email = test_input($_POST['client_email']); |
| 107 | + |
| 108 | + $con->beginTransaction(); |
| 109 | + try |
| 110 | + { |
| 111 | + $stmtgetCurrentClientID = $con->prepare("SELECT AUTO_INCREMENT FROM INFORMATION_SCHEMA.TABLES WHERE TABLE_SCHEMA = 'restaurant_website' AND TABLE_NAME = 'clients'"); |
| 112 | + |
| 113 | + $stmtgetCurrentClientID->execute(); |
| 114 | + $client_id = $stmtgetCurrentClientID->fetch(); |
| 115 | + |
| 116 | + $stmtClient = $con->prepare("insert into clients(client_name,client_phone,client_email) |
| 117 | + values(?,?,?)"); |
| 118 | + $stmtClient->execute(array($client_full_name,$client_phone_number,$client_email)); |
| 119 | + |
| 120 | + |
| 121 | + $stmt_reservation = $con->prepare("insert into reservations(date_created, client_id, selected_time, nbr_guests, table_id) values(?, ?, ?, ?, ?)"); |
| 122 | + $stmt_reservation->execute(array(Date("Y-m-d H:i"),$client_id[0], $desired_date, $number_of_guests, $table_id)); |
| 123 | + |
| 124 | + |
| 125 | + echo "<div class = 'alert alert-success'>"; |
| 126 | + echo "Great! Your Reservation has been created successfully."; |
| 127 | + echo "</div>"; |
| 128 | + |
| 129 | + $con->commit(); |
| 130 | + } |
| 131 | + catch(Exception $e) |
| 132 | + { |
| 133 | + $con->rollBack(); |
| 134 | + echo "<div class = 'alert alert-danger'>"; |
| 135 | + echo $e->getMessage(); |
| 136 | + echo "</div>"; |
| 137 | + } |
| 138 | + } |
| 139 | + |
| 140 | + ?> |
| 141 | + |
| 142 | + |
| 143 | + |
| 144 | + <div class="text_header"> |
| 145 | + <span> |
| 146 | + 1. Select Date & Time |
| 147 | + </span> |
| 148 | + </div> |
| 149 | + <form method="POST" action="table-reservation.php"> |
| 150 | + <div class="row"> |
| 151 | + <div class="col-lg-3 col-md-3 col-sm-6 col-xs-6"> |
| 152 | + <div class="form-group"> |
| 153 | + <label for="reservation_date">Date</label> |
| 154 | + <input type="date" min="<?php echo (isset($_POST['reservation_date']))?$_POST['reservation_date']:date('Y-m-d',strtotime("+1day")); ?>" |
| 155 | + value = "<?php echo (isset($_POST['reservation_date']))?$_POST['reservation_date']:date('Y-m-d',strtotime("+1day")); ?>" |
| 156 | + class="form-control" name="reservation_date"> |
| 157 | + </div> |
| 158 | + </div> |
| 159 | + <div class="col-lg-3 col-md-3 col-sm-6 col-xs-6"> |
| 160 | + <div class="form-group"> |
| 161 | + <label for="reservation_time">Time</label> |
| 162 | + <input type="time" value="<?php echo (isset($_POST['reservation_time']))?$_POST['reservation_time']:date('H:i'); ?>" class="form-control" name="reservation_time"> |
| 163 | + </div> |
| 164 | + </div> |
| 165 | + <div class="col-lg-3 col-md-3 col-sm-6 col-xs-6"> |
| 166 | + <div class="form-group"> |
| 167 | + <label for="number_of_guests">How many people?</label> |
| 168 | + <select class="form-control" name="number_of_guests"> |
| 169 | + <option value="1" <?php echo (isset($_POST['number_of_guests']))?"selected":""; ?>> |
| 170 | + One person |
| 171 | + </option> |
| 172 | + <option value="2" <?php echo (isset($_POST['number_of_guests']))?"selected":""; ?>>Two people</option> |
| 173 | + <option value="3" <?php echo (isset($_POST['number_of_guests']))?"selected":""; ?>>Three people</option> |
| 174 | + <option value="4" <?php echo (isset($_POST['number_of_guests']))?"selected":""; ?>>Four people</option> |
| 175 | + </select> |
| 176 | + </div> |
| 177 | + </div> |
| 178 | + <div class="col-lg-3 col-md-3 col-sm-6 col-xs-6"> |
| 179 | + <div class="form-group"> |
| 180 | + <label for="check_availability" style="visibility: hidden;">Check Availability</label> |
| 181 | + <input type="submit" class="form-control check_availability_submit" name="check_availability_submit"> |
| 182 | + </div> |
| 183 | + </div> |
| 184 | + </div> |
| 185 | + </form> |
| 186 | + |
| 187 | + <!-- CHECKING AVAILABILITY OF TABLES --> |
| 188 | + |
| 189 | + <?php |
| 190 | + |
| 191 | + if(isset($_POST['check_availability_submit'])) |
| 192 | + { |
| 193 | + $selected_date = $_POST['reservation_date']; |
| 194 | + $selected_time = $_POST['reservation_time']; |
| 195 | + $number_of_guests = $_POST['number_of_guests']; |
| 196 | + |
| 197 | + $stmt = $con->prepare("select table_id |
| 198 | + from tables |
| 199 | +
|
| 200 | + where table_id not in (select t.table_id |
| 201 | + from tables t, reservations r |
| 202 | + where |
| 203 | + t.table_id = r.table_id |
| 204 | + and |
| 205 | + date(r.selected_time) = ? |
| 206 | + and liberated = 0 |
| 207 | + and canceled = 0) |
| 208 | + "); |
| 209 | + |
| 210 | + $stmt->execute(array($selected_date)); |
| 211 | + $rows = $stmt->fetch(); |
| 212 | + |
| 213 | + if($stmt->rowCount() == 0) |
| 214 | + { |
| 215 | + ?> |
| 216 | + <div class="error_div"> |
| 217 | + <span class="error_message" style="font-size: 16px">ALL TABLES ARE RESERVED</span> |
| 218 | + </div> |
| 219 | + <?php |
| 220 | + } |
| 221 | + else |
| 222 | + { |
| 223 | + $table_id = $rows['table_id']; |
| 224 | + ?> |
| 225 | + <div class="text_header"> |
| 226 | + <span> |
| 227 | + 2. Client details |
| 228 | + </span> |
| 229 | + </div> |
| 230 | + <form method="POST" action="table-reservation.php"> |
| 231 | + <input type="hidden" name="selected_date" value="<?php echo $selected_date ?>"> |
| 232 | + <input type="hidden" name="selected_time" value="<?php echo $selected_time ?>"> |
| 233 | + <input type="hidden" name="number_of_guests" value="<?php echo $number_of_guests ?>"> |
| 234 | + <input type="hidden" name="table_id" value="<?php echo $table_id ?>"> |
| 235 | + <div class="client_details_tab"> |
| 236 | + <div class="form-group colum-row row"> |
| 237 | + <div class="col-sm-12"> |
| 238 | + <input type="text" name="client_full_name" id="client_full_name" oninput="document.getElementById('required_fname').style.display = 'none'" onkeyup="this.value=this.value.replace(/[^\sa-zA-Z]/g,'');" class="form-control" placeholder="Full name"> |
| 239 | + <div class="invalid-feedback" id="required_fname"> |
| 240 | + Invalid Name! |
| 241 | + </div> |
| 242 | + </div> |
| 243 | + </div> |
| 244 | + <div class="form-group row"> |
| 245 | + <div class="col-sm-6"> |
| 246 | + <input type="email" name="client_email" id="client_email" oninput="document.getElementById('required_email').style.display = 'none'" class="form-control" placeholder="E-mail"> |
| 247 | + <div class="invalid-feedback" id="required_email"> |
| 248 | + Invalid E-mail! |
| 249 | + </div> |
| 250 | + </div> |
| 251 | + <div class="col-sm-6"> |
| 252 | + <input type="text" name="client_phone_number" id="client_phone_number" oninput="document.getElementById('required_phone').style.display = 'none'" class="form-control" onkeyup="this.value=this.value.replace(/[^0-9]/g,'');" placeholder="Phone number"> |
| 253 | + <div class="invalid-feedback" id="required_phone"> |
| 254 | + Invalid Phone number! |
| 255 | + </div> |
| 256 | + </div> |
| 257 | + </div> |
| 258 | + |
| 259 | + </div> |
| 260 | + <div class="form-group"> |
| 261 | + <input type="submit" name="submit_table_reservation_form" class="btn btn-info" value="Make a Reservation"> |
| 262 | + </div> |
| 263 | + </form> |
| 264 | + <?php |
| 265 | + } |
| 266 | + |
| 267 | + } |
| 268 | + |
| 269 | + ?> |
| 270 | + </div> |
| 271 | + </section> |
| 272 | + |
| 273 | + <style type="text/css"> |
| 274 | + .details_card |
| 275 | + { |
| 276 | + display: flex; |
| 277 | + align-items: center; |
| 278 | + margin: 150px 0px; |
| 279 | + } |
| 280 | + .details_card>span |
| 281 | + { |
| 282 | + float: left; |
| 283 | + font-size: 60px; |
| 284 | + } |
| 285 | + |
| 286 | + .details_card>div |
| 287 | + { |
| 288 | + float: left; |
| 289 | + font-size: 20px; |
| 290 | + margin-left: 20px; |
| 291 | + letter-spacing: 2px |
| 292 | + } |
| 293 | + </style> |
| 294 | + |
| 295 | + <section class="restaurant_details" style="background: url(Design/images/food_pic_2.jpg); |
| 296 | + background-repeat: no-repeat; |
| 297 | + background-attachment: fixed; |
| 298 | + background-position: 50% 0%; |
| 299 | + background-size: cover; |
| 300 | + color:white !important; |
| 301 | + min-height: 300px;"> |
| 302 | + <div class="layer"> |
| 303 | + <div class="container"> |
| 304 | + <div class="row"> |
| 305 | + <div class="col-md-3 details_card"> |
| 306 | + <span>30</span> |
| 307 | + <div> |
| 308 | + Total |
| 309 | + <br> |
| 310 | + Reservations |
| 311 | + </div> |
| 312 | + </div> |
| 313 | + <div class="col-md-3 details_card"> |
| 314 | + <span>30</span> |
| 315 | + <div> |
| 316 | + Total |
| 317 | + <br> |
| 318 | + Menus |
| 319 | + </div> |
| 320 | + </div> |
| 321 | + <div class="col-md-3 details_card"> |
| 322 | + <span>30</span> |
| 323 | + <div> |
| 324 | + Years of |
| 325 | + <br> |
| 326 | + Experience |
| 327 | + </div> |
| 328 | + </div> |
| 329 | + <div class="col-md-3 details_card"> |
| 330 | + <span>30</span> |
| 331 | + <div> |
| 332 | + Profesionnal |
| 333 | + <br> |
| 334 | + Cook |
| 335 | + </div> |
| 336 | + </div> |
| 337 | + </div> |
| 338 | + </div> |
| 339 | + </div> |
| 340 | + </section> |
| 341 | + |
| 342 | + <!-- FOOTER BOTTOM --> |
| 343 | + |
| 344 | + <?php include "Includes/templates/footer.php"; ?> |
0 commit comments