$new_reservation->create($fields); $next_capacity = $previous_capacity - $fields['people_size']; $sql = 'update time_slots_capacity set ' . $time_to_slots_hash[$_POST['time']] . ' = ' . $next_capacity . ' where date = "' . $fields['date_of_reservation'] . '" and restaurant_id = "' . $fields['restaurant_id'] . '"'; if ($query_tool->query($sql)) { // send email to user to confirm reservation $restaurant = new Restaurant(); $restaurant->find($fields['restaurant_id']); $mail = Mail::getInstance(); $mailto = $_POST['user_email']; $subject = 'FineTable - Restaurant Reservation Confirmation!'; if (isset($_POST['guest_reservation']) && $_POST['guest_reservation'] == 'true') { $body = ' <div class="mail-body" style="padding: 20px; border: 5px solid rgb(254, 127, 65); border-radius: 4px; margin: 0 auto; width: 90%;"> <p>Hello ' . $_POST['guest_fullname'] . ',</p> <p>Congratulations!</p> <p>You have made a reservation with restaurant: ' . $restaurant->get_restaurant_name() . '.</p> <p>' . $restaurant->get_full_address() . '</p> <p><b>Date: </b>' . $_POST['date'] . '</p> <p><b>Time: </b>' . $_POST['time'] . '</p> <p>If you need to make a change with the reservation, please contact the restaurant at: ' . $restaurant->get_phone() . '</p> <p>Thank you!</p> <p>FineTable team</p> </div> '; } else { $body = ' <div class="mail-body" style="padding: 20px; border: 5px solid rgb(254, 127, 65); border-radius: 4px; margin: 0 auto; width: 90%;"> <p>Hello ' . $_COOKIE["login_user_firstname"] . ',</p> <p>Congratulations!</p> <p>You have made a reservation with restaurant: ' . $restaurant->get_restaurant_name() . '.</p> <p>' . $restaurant->get_full_address() . '</p>