diff options
-rw-r--r-- | app/Http/Controllers/ReservationsController.php | 8 | ||||
-rw-r--r-- | public/js/reservations.js | 38 | ||||
-rw-r--r-- | resources/views/pages/reserve.blade.php | 3 |
3 files changed, 49 insertions, 0 deletions
diff --git a/app/Http/Controllers/ReservationsController.php b/app/Http/Controllers/ReservationsController.php index 1865f46..249d18a 100644 --- a/app/Http/Controllers/ReservationsController.php +++ b/app/Http/Controllers/ReservationsController.php @@ -92,6 +92,14 @@ class ReservationsController extends Controller $validator = Validator::make($request->all(), $rules, $messages); + $validator->after(function ($validator) use ($request) { + $fromStamp = strtotime($request->sdate . ' ' . $request->stime); + $toStamp = strtotime($request->edate . ' ' . $request->etime); + if (!($fromStamp < $toStamp)) { + $validator->errors()->add('time', 'FROM time and date needs to be before TO time and date.'); + } + }); + if ($validator->fails()) { return Redirect::back() ->withErrors($validator) diff --git a/public/js/reservations.js b/public/js/reservations.js index e69de29..94bee2d 100644 --- a/public/js/reservations.js +++ b/public/js/reservations.js @@ -0,0 +1,38 @@ +$.ajaxSetup({ + headers: { + 'X-CSRF-TOKEN': $('input[name="csrf-token"]').attr('content') + } +}); + +jQuery('select#call-sign').change(fillTable); +jQuery(document).ready(fillTable); + +function fillTable() { + tableData = jQuery('table#ajax-table>tbody').first(); + tableData.html('<tr><td class="font-weight-bold text-center" colspan="6">Loading...</td></tr>'); + + sign = jQuery('select#call-sign').first().val(); + + jQuery.post('/api/activities', {'call-sign': sign}, function (data, status) { + if (status === 'success') { + if (data.data.length > 0) { + tableData.empty(); + for (var i = 0, len = data.data.length; i < len; i++) { + tr = '<tr><td>' + data.data[i].operatorCall + '</td>' + + '<td>' + data.data[i].fromTime + '</td>' + + '<td>' + data.data[i].toTime + '</td>' + + '<td>' + data.data[i].specialCall + '</td>' + + '<td>' + data.data[i].frequencies + '</td>' + + '<td>' + data.data[i].qso + '</td></tr>'; + tableData.append(tr); + } + } + else { + tableData.html('<tr><td class="font-weight-bold text-center" colspan="6">No data...</td></tr>'); + } + } + else { + tableData.html('<tr><td class="font-weight-bold text-center" colspan="6">Error!</td></tr>'); + } + }); +} diff --git a/resources/views/pages/reserve.blade.php b/resources/views/pages/reserve.blade.php index 0bcab42..244d70a 100644 --- a/resources/views/pages/reserve.blade.php +++ b/resources/views/pages/reserve.blade.php @@ -37,6 +37,9 @@ </div> </div> +@error('time') + <div class="alert alert-danger mt-2">{{ $message }}</div> +@enderror <!-- START TIME --> <div class="form-group"> <label for="start-date">Start date:</label> |