-
Notifications
You must be signed in to change notification settings - Fork 6
/
reservation.php
228 lines (190 loc) · 8.64 KB
/
reservation.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
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
<?php
/**/
if($database==null){
require 'db/db.php';
}
/*---------------------------------------time for reservation from database--------------------------*/
$time = $database->select("tbtime",[
"nameTime",
"time",
"state"
],[
"state" => "int"
]);
if($_POST){
/*--------------------------------date format change for mysql date format----------------------*/
$fecha=date("Y-m-d",strtotime($_POST["date"] ));
$database->insert("tbreservations", [
"reservationHour"=> $_POST["time"],
"peopleAmount" => $_POST["tableAmount"],
"clientName" => $_POST["name"],
"clientPhone" => $_POST["phone"],
"clientEmail" => $_POST["email"],
"state" => 1,
"date" => $fecha
]);
header("Location: index.php#reservaciones");
}
?>
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Calendario</title>
</head>
<body>
<!--reseration code-->
<div class="container">
<article class="row">
<article class="containerReserve col-xs-12 col-sm-12 col-md-12 col-lg-12">
<p class="labels">Reservaciones</p>
<p>
En La Parrilla Argentina puede realizar sus reservaciones para esa fecha especial.
</p>
<p>
Le ofrecemos el mejor servicio.
</p>
</article>
</div>
<!-- ***************************form to add the information of reservation************************ -->
<form method="post" action="reservation.php" enctype="multipart/form-data">
<div class="container">
<article class="row">
<article class="reserve-left col-xs-12 col-sm-6 col-md-6 col-lg-6">
<p class="labels">Nombre</p>
<input class="input" type="text" size="15" maxlength="30" placeholder="Nombre" name="name">
<br></br>
<!-- *************************************position for the DATE************************ -->
<label class="labels"> Ingresar Fecha</label>
<br/>
<input id="datePicker" name="date" onchange="mDate(date.value);" class="input" type="date" />
<!-- *************************************END position for the DATE************************ -->
<br></br>
<p class="labels">Correo</p>
<input class="input" type="text" size="15" maxlength="30" placeholder="[email protected]" name="email">
</article>
<article class="reserve-right col-xs-12 col-sm-6 col-md-6 col-lg-6">
<!-- FORM for calendar -->
<!-- *************************************position for the HOUR************************ -->
<p class="labels">Hora</p>
<!-- <form name=myform> -->
<select name=time id="hour-list" onchange="mTables();">
<option name=default value='default'> Seleccione la hora </option>
<?php
for($i=0; $i<count($time); $i++){
echo "<option name=".$time[$i]["nameTime"].">".$time[$i]["time"]."</option>";
}
?>
</select>
<br></br>
<!--</form>-->
<!-- *************************************END position for the HOUR************************ -->
<!-- FORM for calendar -->
<p class="labels">Mesa (4 personas c/u)</p>
<!-- <form method="post" name=myform> -->
<select id="tables" name=tableAmount>
<option name=cero value=0 disabled>Cantidad de Mesas</option>
<option name=uno value=1> 1 mesa </option>
<option name=dos value=2> 2 mesas </option>
<option name=tres value=3> 3 mesas </option>
<option name=cuatro value=4> 4 mesas </option>
</select>
<!-- </form> -->
<br></br>
<p class="labels">Telefono</p>
<input class="input" type="text" size="15" maxlength="30" placeholder="Teléfono" name="phone">
</article>
</article>
</div>
<div class="container">
<article class="row">
<article class="col-xs-12 col-sm-12 col-md-4 col-md-offset-5 col-sm-offset-2">
<button type="submit" name="reserv" class="hvr-float-shadow buttons" data-toggle="modal" data-target="#myModal">RESERVAR</button>
</article>
</article>
</div>
</form>
<!-- *********************end form reservation ********************************** -->
<!--Notification pop-up for reservation-->
<div id="myModal" class="modal fade" role="dialog">
<div class="modal-dialog">
<!-- Modal content-->
<div class="modal-content">
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal">×</button>
<h4 class="modal-title">Reservación exitosa</h4>
</div>
<div class="modal-body">
<p>Reservación ha sido realizada</p>
</div>
<div class="modal-footer">
<button type="button" class="btn btn-default" data-dismiss="modal">Close</button>
</div>
</div>
</div>
</div>
<script>
function clearItems() {
$("#hour-list").find('option').remove();
$("#tables").find('option').remove(); //selimpia la lista
}
function mDate(selectedDate) {
clearItems();
$.ajax({
method: "POST",
url: "hourReserv.php",
data: {
param: selectedDate
},
dataType: "text"
})
.done(function (items) {
items = JSON.parse(items);
$("#hour-list").show();
var len = items.length;
for (var i = 0; i < len; i++) {
$("#hour-list").append("<option value='" + items[i].name + "'>" + items[i].name + "</option>");
}
});
}
function mTables() {
var selectedHour = $('#hour-list').val();
var selectedDate = $('#datePicker').val();
console.log(selectedHour, selectedDate);
$.ajax({
method: "POST",
url: "tbReserv.php",
data: {
H: selectedHour,
D: selectedDate
},
dataType: "text"
})
.done(function (items) {
items = JSON.parse(items);
$("#tables").show();
var len = items.length;
console.log(len); // alert(len);
for (var i = 0; i < len; i++) {
$("#tables").append("<option value='" + items[i].name + "'>" + items[i].name + "</option>");
}
});
}
</script>
</body>
<script>
(function (i, s, o, g, r, a, m) {
i['GoogleAnalyticsObject'] = r;
i[r] = i[r] || function () {
(i[r].q = i[r].q || []).push(arguments)
}, i[r].l = 1 * new Date();
a = s.createElement(o),
m = s.getElementsByTagName(o)[0];
a.async = 1;
a.src = g;
m.parentNode.insertBefore(a, m)
})(window, document, 'script', 'https://www.google-analytics.com/analytics.js', 'ga');
ga('create', 'UA-77610408-2', 'auto');
ga('send', 'pageview');
</script>
</html>