-
Notifications
You must be signed in to change notification settings - Fork 0
/
sendBooking.php
89 lines (85 loc) · 3.66 KB
/
sendBooking.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
<?php
session_start();
require_once('admin/bddConnect.php');
$idEmployee = $_POST['idEmployee'];
$idUser = $_POST['idUser'];
$start = secure($_POST['start']);
$end = secure($_POST['end']);
$nbrPeople = secure($_POST['nbrPeople']);
$service = secure($_POST['service']);
function secure($data) {
$data = trim($data);
$data = stripslashes($data);
$data = htmlspecialchars($data);
return $data;
}
$check = $bdd->prepare("SELECT COUNT(*) AS available FROM service WHERE available = 1 AND idEmployee = ?");
$check->execute(array($idEmployee));
$available = $check->fetch(PDO::FETCH_ASSOC);
if($available['available'] == 1) // Si le chauffeur est dispo
{
$createBooking = $bdd->prepare("INSERT INTO booking(idUser, idEmployee, start, end, nbrPeople, price, services) VALUES (?, ?, ?, ?, ?, ?, ?)");
$createBooking->execute(array($idUser, $idEmployee, $start, $end, $nbrPeople, "40", $service));
$update = $bdd->prepare("UPDATE service SET available = 0 WHERE service.id = ?");
$update->execute(array($id));
?>
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>City Drive</title>
<meta name="description" content="Booking - Le nouveau Uber !">
<link rel="stylesheet" href="https://use.fontawesome.com/releases/v5.7.2/css/all.css" integrity="sha384-fnmOCqbTlWIlj8LyTjo7mOUStjsKC4pOpQbqyi7RrhN7udi9RwhKkMHpvLbHG9Sr" crossorigin="anonymous">
<link rel="stylesheet" href="css/style.css">
</head>
<body>
<div class="py-5 text-center text-white align-items-center d-flex" id="div4">
<div class="container w-50">
<div class="row">
<div class="col-md-12">
<div class="card text-primary">
<div class="card-header h1">Réservation enregistré sur City Drive.</div>
<div class="card-body">
<p class="text-dark">Votre réservation a bien été prise en compte retour a l'acceuil. </p>
<a href="index.php" class="btn btn-lg btn-primary mx-1">Retour vers l'accueil</a>
</div>
</div>
</div>
</div>
</div>
</div>
</body>
</html>
<?php
header( "Refresh:5; url=index.php" );
} else { ?>
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>City Drive</title>
<meta name="description" content="Booking - Le nouveau Uber !">
<link rel="stylesheet" href="https://use.fontawesome.com/releases/v5.7.2/css/all.css" integrity="sha384-fnmOCqbTlWIlj8LyTjo7mOUStjsKC4pOpQbqyi7RrhN7udi9RwhKkMHpvLbHG9Sr" crossorigin="anonymous">
<link rel="stylesheet" href="css/style.css">
</head>
<body>
<div class="py-5 text-center text-white align-items-center d-flex" id="div4">
<div class="container w-50">
<div class="row">
<div class="col-md-12">
<div class="card text-primary">
<div class="card-header h1">Réservation échoué. </div>
<div class="card-body">
<p class="text-dark">La réservation a échoué dommage, vous allez être redirigez vers l'acceuil. </p>
<a href="index.php" class="btn btn-lg btn-primary mx-1">Retour vers l'acceuil</a>
</div>
</div>
</div>
</div>
</div>
</div>
</body>
</html>
<?php header( "Refresh:5; url=index.php" ); } ?>