OwlCyberSecurity - MANAGER
Edit File: booking_form.php
<fieldset> <h3 style="font-weight: bold;">Booking Information</h3><br> <!-- New field to display the auto-generated Booking ID --> <div class="row"> <div class="form-group col-md-3"> <!-- Changed from col-md-6 to col-md-3 for a smaller field --> <label for="booking_id_display"><strong>Booking ID</strong></label> <input type="text" id="booking_id_display" class="form-control" value="<?php echo htmlspecialchars($edit ? $booking['booking_id'] : $next_booking_id, ENT_QUOTES, 'UTF-8'); ?>" readonly style="font-weight: bold;"> </div> <!-- This column is intentionally left blank for alignment, or can be filled with other booking info --> <div class="form-group col-md-9"> <!-- Adjusted to col-md-9 to fill the remaining space (3 + 9 = 12) --> <!-- Space holder if needed, otherwise this div can be removed if no other element takes its place --> </div> </div> <h3 style="font-weight: bold;">Customer Information</h3><br> <div class="row"> <div class="form-group col-md-6"> <label for="name">Full Name *</label> <input type="text" name="name" value="<?php echo htmlspecialchars($edit ? $booking['full_name'] : '', ENT_QUOTES, 'UTF-8'); ?>" placeholder="Full Name" class="form-control" required id="name"> </div> <div class="form-group col-md-6"> <label for="father_name">Father/Husband Name *</label> <input type="text" name="father_name" value="<?php echo htmlspecialchars($edit ? $booking['father_name'] : '', ENT_QUOTES, 'UTF-8'); ?>" placeholder="Father/Husband Name" class="form-control" required id="father_name"> </div> </div> <div class="row"> <div class="form-group col-md-6"> <label for="mobile_no">Mobile No *</label> <input type="text" name="mobile_no" value="<?php echo htmlspecialchars($edit ? $booking['mobile_no'] : '', ENT_QUOTES, 'UTF-8'); ?>" placeholder="0300-1234567" class="form-control" required id="mobile_no"> </div> <div class="form-group col-md-6"> <label for="cnic">CNIC # *</label> <input type="text" name="cnic" value="<?php echo htmlspecialchars($edit ? $booking['cnic'] : '', ENT_QUOTES, 'UTF-8'); ?>" placeholder="XXXXX-XXXXXXX-X" class="form-control" required id="cnic"> </div> </div> <!-- Booking Date is now back in Customer Information section --> <div class="row"> <div class="form-group col-md-6"> <label for="booking_date">Booking Date *</label> <input type="date" name="booking_date" value="<?php echo htmlspecialchars($edit ? $booking['booking_date'] : date('Y-m-d'), ENT_QUOTES, 'UTF-8'); ?>" class="form-control" required id="booking_date"> </div> <div class="form-group col-md-6"> <label for="address">Address *</label> <textarea name="address" placeholder="Full Address" class="form-control" required id="address" style="height: 100%;"><?php echo htmlspecialchars(($edit) ? $booking['address'] : '', ENT_QUOTES, 'UTF-8'); ?></textarea> </div> </div> <h3 style="font-weight: bold;">Tour Information</h3><br> <div class="row"> <div class="form-group col-md-6"> <label for="start_tour_date">Start Tour Date *</label> <input type="date" name="start_tour_date" value="<?php echo htmlspecialchars($edit ? $booking['start_tour_date'] : '', ENT_QUOTES, 'UTF-8'); ?>" class="form-control" required id="start_tour_date"> </div> <div class="form-group col-md-6"> <label for="end_tour_date">End Tour Date *</label> <input type="date" name="end_tour_date" value="<?php echo htmlspecialchars($edit ? $booking['end_tour_date'] : '', ENT_QUOTES, 'UTF-8'); ?>" class="form-control" required id="end_tour_date"> </div> </div> <div class="row"> <div class="form-group col-md-6"> <label for="tour_name">Tour Destination *</label> <input type="text" name="tour_name" value="<?php echo htmlspecialchars($edit ? $booking['tour_name'] : '', ENT_QUOTES, 'UTF-8'); ?>" placeholder="Tour Destination" class="form-control" required id="tour_name"> </div> <div class="form-group col-md-6"> <label for="rate_per_day">Rate Per Day Per Vehicle (PKR) *</label> <input type="number" name="rate_per_day" value="<?php echo htmlspecialchars($edit ? $booking['rate_per_day'] : '', ENT_QUOTES, 'UTF-8'); ?>" step="0.01" class="form-control" required id="rate_per_day"> </div> </div> <div class="row"> <div class="form-group col-md-6"> <label for="num_vehicles">Number of Vehicles *</label> <input type="number" name="num_vehicles" value="<?php echo htmlspecialchars($edit ? $booking['num_vehicles'] : '1', ENT_QUOTES, 'UTF-8'); ?>" class="form-control" required id="num_vehicles" min="1"> </div> <div class="form-group col-md-6"> <label for="no_of_days">No of Days *</label> <input type="number" name="no_of_days" value="<?php echo htmlspecialchars($edit ? $booking['no_of_days'] : '0', ENT_QUOTES, 'UTF-8'); ?>" class="form-control" required id="no_of_days" readonly> </div> </div> <div class="row"> <div class="form-group col-md-6"> <label for="total_amount">Total Amount (PKR) *</label> <input type="number" name="total_amount" value="<?php echo htmlspecialchars($edit ? $booking['total_amount'] : '0.00', ENT_QUOTES, 'UTF-8'); ?>" step="0.01" class="form-control" required id="total_amount" readonly> </div> <div class="form-group col-md-6"> <label for="advance">Advance Payment (PKR) *</label> <input type="number" name="advance" value="<?php echo htmlspecialchars($edit ? $booking['advance'] : '', ENT_QUOTES, 'UTF-8'); ?>" step="0.01" class="form-control" required id="advance"> </div> </div> <h3 style="font-weight: bold;">Vehicle Information</h3><br> <div class="row"> <div class="form-group col-md-6"> <label for="vehicle_no">Vehicle Number *</label> <input type="text" name="vehicle_no" value="<?php echo htmlspecialchars($edit ? $booking['vehicle_number'] : '', ENT_QUOTES, 'UTF-8'); ?>" placeholder="e.g., LEA-1234" class="form-control" required id="vehicle_no"> </div> <div class="form-group col-md-6"> <label for="driver_name">Driver Name *</label> <input type="text" name="driver_name" value="<?php echo htmlspecialchars($edit ? $booking['driver_name'] : '', ENT_QUOTES, 'UTF-8'); ?>" placeholder="Driver's Full Name" class="form-control" required id="driver_name"> </div> <div class="form-group col-md-6"> <label for="transport_type">Transport Type *</label> <input type="text" name="transport_type" value="<?php echo htmlspecialchars($edit ? $booking['transport_type'] : '', ENT_QUOTES, 'UTF-8'); ?>" placeholder="e.g., Hiace, Coaster" class="form-control" required id="transport_type"> </div> <div class="form-group col-md-6"> <label for="finalization_date">Finalization Date *</label> <input type="date" name="finalization_date" value="<?php echo htmlspecialchars($edit ? $booking['finalization_date'] : '', ENT_QUOTES, 'UTF-8'); ?>" class="form-control" required id="finalization_date"> </div> </div><br> <div class="form-group text-center"> <button type="submit" class="btn btn-success"> <?php echo $edit ? 'Update' : 'Create'; ?> Booking <span class="glyphicon glyphicon-ok"></span> </button> </div> </fieldset> <script> document.addEventListener('DOMContentLoaded', function() { const startTourDateInput = document.getElementById('start_tour_date'); const endTourDateInput = document.getElementById('end_tour_date'); const noOfDaysInput = document.getElementById('no_of_days'); const ratePerDayInput = document.getElementById('rate_per_day'); const numVehiclesInput = document.getElementById('num_vehicles'); const totalAmountInput = document.getElementById('total_amount'); function calculateNoOfDays() { const startDate = new Date(startTourDateInput.value); const endDate = new Date(endTourDateInput.value); if (startDate && endDate && endDate >= startDate) { const timeDiff = endDate.getTime() - startDate.getTime(); const days = (timeDiff / (1000 * 3600 * 24)) + 1; noOfDaysInput.value = Math.floor(days); } else { noOfDaysInput.value = 0; } calculateTotalAmount(); } function calculateTotalAmount() { const ratePerDay = parseFloat(ratePerDayInput.value) || 0; const noOfDays = parseFloat(noOfDaysInput.value) || 0; const numVehicles = parseFloat(numVehiclesInput.value) || 1; const totalAmount = ratePerDay * noOfDays * numVehicles; totalAmountInput.value = totalAmount.toFixed(2); } startTourDateInput.addEventListener('change', calculateNoOfDays); endTourDateInput.addEventListener('change', calculateNoOfDays); ratePerDayInput.addEventListener('input', calculateTotalAmount); numVehiclesInput.addEventListener('input', calculateTotalAmount); calculateNoOfDays(); calculateTotalAmount(); }); </script>