Repository navigation
Expand file tree
/
Copy pathbooking.php
More file actions
215 lines (189 loc) · 6.22 KB
/
Copy pathbooking.php
File metadata and controls
215 lines (189 loc) · 6.22 KB
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
<?php
require_once('./config.php');
if(isset($_GET['id']) && $_GET['id'] > 0){
$qry = $conn->query("SELECT * from `booking_list` where id = '{$_GET['id']}' ");
if($qry->num_rows > 0){
foreach($qry->fetch_assoc() as $k => $v){
$$k=$v;
}
}
}
?>
<style>
/* Modal styling */
#uni_modal .modal-header {
background: linear-gradient(135deg, #f1683a, #ff8c00);
color: white;
border-radius: 0;
padding: 15px 20px;
}
#uni_modal .modal-title {
font-weight: 600;
text-shadow: 0 1px 2px rgba(0,0,0,0.1);
}
#uni_modal .modal-content {
border: none;
border-radius: 8px;
box-shadow: 0 5px 15px rgba(0,0,0,0.1);
overflow: hidden;
}
#uni_modal .modal-footer {
background-color: #f8f9fa;
border-top: 1px solid #eee;
padding: 15px 20px;
}
#uni_modal .btn-primary {
background: linear-gradient(135deg, #f1683a, #ff8c00);
border: none;
box-shadow: 0 2px 5px rgba(241, 104, 58, 0.3);
transition: all 0.3s ease;
}
#uni_modal .btn-primary:hover {
background: linear-gradient(135deg, #ff8c00, #f1683a);
transform: translateY(-2px);
box-shadow: 0 4px 8px rgba(241, 104, 58, 0.4);
}
#uni_modal .btn-secondary {
background-color: #6c757d;
border: none;
box-shadow: 0 2px 5px rgba(108, 117, 125, 0.3);
transition: all 0.3s ease;
}
#uni_modal .btn-secondary:hover {
background-color: #5a6268;
transform: translateY(-2px);
box-shadow: 0 4px 8px rgba(108, 117, 125, 0.4);
}
/* Form styling */
.booking-form-container {
padding: 20px;
}
.booking-form-container .form-group {
margin-bottom: 20px;
}
.booking-form-container label {
font-weight: 600;
color: #333;
margin-bottom: 8px;
display: block;
}
.booking-form-container input[type="date"] {
border: 1px solid #ddd;
border-radius: 5px;
padding: 10px;
width: 100%;
transition: all 0.3s ease;
}
.booking-form-container input[type="date"]:focus {
border-color: #f1683a;
box-shadow: 0 0 0 0.2rem rgba(241, 104, 58, 0.25);
outline: none;
}
.booking-note {
font-size: 0.85rem;
color: #666;
margin-top: 15px;
font-style: italic;
}
/* Success message */
.booking-success {
display: none;
background-color: #d4edda;
color: #155724;
border: 1px solid #c3e6cb;
border-radius: 5px;
padding: 15px;
margin-bottom: 20px;
animation: fadeIn 0.5s ease;
}
@keyframes fadeIn {
from { opacity: 0; transform: translateY(-10px); }
to { opacity: 1; transform: translateY(0); }
}
</style>
<div class="booking-form-container">
<!-- Success message container -->
<div class="booking-success" id="booking-success">
<strong><i class="fa fa-check-circle"></i> Réservation réussie!</strong> Votre espace a été réservé avec succès.
</div>
<form action="" id="booking-form">
<input type="hidden" name="id" value="<?= isset($id) ? $id : '' ?>">
<input type="hidden" name="facility_id" value="<?= isset($_GET['fid']) ? $_GET['fid'] : (isset($facility_id) ? $facility_id : "") ?>">
<div class="form-group">
<label for="date_from" class="control-label">Date de début</label>
<input name="date_from" id="date_from" type="date" class="form-control" required />
</div>
<div class="form-group">
<label for="date_to" class="control-label">Date de fin</label>
<input name="date_to" id="date_to" type="date" class="form-control" required />
</div>
<p class="booking-note">Veuillez sélectionner les dates pour lesquelles vous souhaitez réserver cet espace.</p>
</form>
</div>
<script>
$(document).ready(function(){
// Initialize date inputs with today's date as minimum
var today = new Date().toISOString().split('T')[0];
$('#date_from, #date_to').attr('min', today);
// Set date_from to today by default
$('#date_from').val(today);
// When date_from changes, ensure date_to is not before it
$('#date_from').change(function(){
var fromDate = $(this).val();
$('#date_to').attr('min', fromDate);
// If date_to is before date_from, update it
if($('#date_to').val() < fromDate) {
$('#date_to').val(fromDate);
}
});
$('#booking-form').submit(function(e){
e.preventDefault();
var _this = $(this);
$('.err-msg').remove();
start_loader();
$.ajax({
url:_base_url_+"classes/Master.php?f=save_booking",
data: new FormData($(this)[0]),
cache: false,
contentType: false,
processData: false,
method: 'POST',
type: 'POST',
dataType: 'json',
error:err=>{
console.log(err);
alert_toast("Une erreur s'est produite",'error');
end_loader();
},
success:function(resp){
if(typeof resp =='object' && resp.status == 'success'){
// Hide the form
$('#booking-form').slideUp();
// Show success message with animation
$('#booking-success').slideDown();
// Update modal footer
$('#uni_modal .modal-footer #submit').hide();
$('#uni_modal .modal-footer .btn-secondary').text('Fermer');
// End loader
end_loader();
// Redirect after 3 seconds
setTimeout(function(){
location.href = './?p=booking_list';
}, 3000);
} else if(resp.status == 'failed' && !!resp.msg) {
var el = $('<div>');
el.addClass("alert alert-danger err-msg").text(resp.msg);
_this.prepend(el);
el.show('slow');
end_loader();
} else {
alert_toast("Une erreur s'est produite",'error');
end_loader();
console.log(resp);
}
$("html, body, .modal").scrollTop(0);
}
});
});
});
</script>