Exemple #1
0
<?php

session_start();
include_once "db/BookReservationDB.php";
include_once "db/BookDB.php";
include_once "db/UserDB.php";
$db = new DBHandler();
$bookDB = new BookDB($db);
$reservationDB = new BookReservationDB($db);
$userDB = new UserDB($db);
$reservations = array();
$user = NULL;
if ($_SERVER['REQUEST_METHOD'] === 'GET' && isset($_GET['userId'])) {
    $user = $userDB->GetUser($_GET['userId']);
    $reservations = $reservationDB->GetReservationForUser($user['id']);
}
?>

<!DOCTYPE html>
<html lang="en">
  <head>
    <meta http-equiv="content-type" content="text/html; charset=utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <!-- The above 3 meta tags *must* come first in the head; any other head content must come *after* these tags -->
    <title>BookÉTS</title>
    <!-- Favicon -->
    <link rel="shortcut icon" type="image/icon" href="assets/images/favicon.ico"/>
    <!-- Font Awesome -->
    <link href="assets/css/font-awesome.css" rel="stylesheet">
    <!-- Bootstrap -->
Exemple #2
0
            $date_start = date("Y-m-d");
            $date_end = date('Y-m-d', strtotime('+' . $_POST['reservationLength']));
            $reservations = $reservationDB->GetReservationsForBook($_POST['bookId']);
            $book = $bookDB->GetBookById($_POST['bookId']);
            if (count($reservations) >= $book['Count']) {
                $errorMessage[] = "Aucun exemplaire disponible.";
            }
            $reservations = $reservationDB->GetReservationForUser($_POST['userId']);
            if (count($reservations) >= $settings['MaxReservationCount']) {
                $errorMessage[] = "Nombre maximum de réservations atteint.";
            }
            if (count($errorMessage) == 0) {
                $reservationDB->AddReservation($date_start, $date_end, $_POST['bookId'], $_POST['userId']);
                // Send Email to User
                $userDB = new UserDB($db);
                $user = $userDB->GetUser($_POST['userId']);
                $Email = new MailSMTP();
                $Email->send($user['email'], "Nouvelle Réservation", "Vous avec réservé le livre " . $book['title'] . " du " . $date_start . " au " . $date_end . ".");
                ?>
			<span class="label label-success center-block">Réservé avec succès</span>
		<?php 
            } else {
                for ($i = 0; $i < count($errorMessage); $i++) {
                    ?>
				<span class="label label-danger center-block"><?php 
                    echo $errorMessage[$i];
                    ?>
</span>
			<?php 
                }
            }