
<?php $__env->startSection('title', 'Add Trip'); ?>
<?php $__env->startPush('style'); ?>
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/flatpickr/dist/flatpickr.min.css">
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/flatpickr/dist/themes/material_blue.css">
<?php $__env->stopPush(); ?>
<?php $__env->startSection('content'); ?>
<div class="container">
    <div class="page-inner">
        <div class="row">
            <div class="col-md-12">
                <div class="card card-round">
                    <div class="card-header project-details-card-header py-2 d-flex align-items-center justify-content-between">
                        <div>
                            <h4 class="project-details-card-header-title mb-0"><i class='bx bx-plus'></i> Add Trip</h4>
                        </div>
                        <div>
                            <a href="<?php echo e(route('trip.index')); ?>" class="btn btn-primary btn-sm" title="List">
                                <span class="btn-label">
                                    <i class="fas fa-plane"></i>
                                </span>
                                Trip List
                            </a>
                            <button class="btn btn-black btn-sm" title="Go Back" onclick="history.back();">
                                <span class="btn-label">
                                    <i class="fas fa-reply"></i>
                                </span>
                                Go Back
                            </button>
                        </div>
                    </div>
                    <div class="card-body">
                        <form id="tripForm" action="<?php echo e(route('trip.store')); ?>" method="POST">
                            <?php echo csrf_field(); ?>
                            <div class="row mb-3">
                                <div class="col-lg-4 mb-3">
                                    <label class="form-label">Select Passenger</label>
                                    <select name="passenger_id" class="form-control select2" data-placeholder="Select Person">
                                        <option value=""></option>
                                        <?php $__currentLoopData = $passengers; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $passenger): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); ?>
                                        <option value="<?php echo e($passenger->id); ?>" <?php echo e(old('passenger_id') == $passenger->id ? 'selected' : ''); ?>>
                                            <?php echo e($passenger->title.' '.$passenger->first_name.' '.$passenger->last_name); ?>

                                        </option>
                                        <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); ?>
                                    </select>
                                    <?php $__errorArgs = ['passenger_id'];
$__bag = $errors->getBag($__errorArgs[1] ?? 'default');
if ($__bag->has($__errorArgs[0])) :
if (isset($message)) { $__messageOriginal = $message; }
$message = $__bag->first($__errorArgs[0]); ?>
                                    <small class="text-danger"><?php echo e($message); ?></small>
                                    <?php unset($message);
if (isset($__messageOriginal)) { $message = $__messageOriginal; }
endif;
unset($__errorArgs, $__bag); ?>
                                </div>
                                <div class="col-lg-4 mb-3">
                                    <label class="form-label">Select Airlines Company</label>
                                    <select name="company_id" class="form-control select2" data-placeholder="Select One">
                                        <option value=""></option>
                                        <?php $__currentLoopData = $companies; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $company): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); ?>
                                        <option value="<?php echo e($company->id); ?>" <?php echo e(old('company_id') == $company->id ? 'selected' : ''); ?>>
                                            <?php echo e($company->name); ?>

                                        </option>
                                        <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); ?>
                                    </select>
                                    <?php $__errorArgs = ['company_id'];
$__bag = $errors->getBag($__errorArgs[1] ?? 'default');
if ($__bag->has($__errorArgs[0])) :
if (isset($message)) { $__messageOriginal = $message; }
$message = $__bag->first($__errorArgs[0]); ?>
                                    <small class="text-danger"><?php echo e($message); ?></small>
                                    <?php unset($message);
if (isset($__messageOriginal)) { $message = $__messageOriginal; }
endif;
unset($__errorArgs, $__bag); ?>
                                </div>
                                <div class="col-md-4 mt-2 mb-2">
                                    <label>Confirmation Number</label>
                                    <input type="text" name="confirmation_number" class="form-control" value="<?php echo e(old('confirmation_number')); ?>" placeholder="ex: ETIOWR" required>
                                    <?php $__errorArgs = ['confirmation_number'];
$__bag = $errors->getBag($__errorArgs[1] ?? 'default');
if ($__bag->has($__errorArgs[0])) :
if (isset($message)) { $__messageOriginal = $message; }
$message = $__bag->first($__errorArgs[0]); ?> <small class="text-danger"><?php echo e($message); ?></small> <?php unset($message);
if (isset($__messageOriginal)) { $message = $__messageOriginal; }
endif;
unset($__errorArgs, $__bag); ?>
                                </div>
                                <hr>
                                <h6>Departure Details</h6>
                                <div class="col-lg-3 mb-3">
                                    <label class="form-label">Select Airport</label>
                                    <select name="departure_airport_id" class="form-control select2" data-placeholder="Select One">
                                        <option value=""></option>
                                        <?php $__currentLoopData = $airports_new; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $new): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); ?>
                                        <option value="<?php echo e($new->id); ?>" <?php echo e(old('departure_airport_id') == $new->id ? 'selected' : ''); ?>>
                                            <?php echo e($new->name); ?>

                                        </option>
                                        <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); ?>
                                    </select>
                                    <?php $__errorArgs = ['departure_airport_id'];
$__bag = $errors->getBag($__errorArgs[1] ?? 'default');
if ($__bag->has($__errorArgs[0])) :
if (isset($message)) { $__messageOriginal = $message; }
$message = $__bag->first($__errorArgs[0]); ?>
                                    <small class="text-danger"><?php echo e($message); ?></small>
                                    <?php unset($message);
if (isset($__messageOriginal)) { $message = $__messageOriginal; }
endif;
unset($__errorArgs, $__bag); ?>
                                </div>
                                <div class="col-lg-2 mb-3">
                                    <label class="form-label">Airport Code</label>
                                    <select name="departure_airport_code_id" class="form-control select2" data-placeholder="Select One">
                                        <option value=""></option>
                                        <?php $__currentLoopData = $airports; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $new): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); ?>
                                        <option value="<?php echo e($new->id); ?>" <?php echo e(old('departure_airport_code_id') == $new->id ? 'selected' : ''); ?>>
                                            <?php echo e($new->code); ?>

                                        </option>
                                        <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); ?>
                                    </select>
                                    <?php $__errorArgs = ['departure_airport_code_id'];
$__bag = $errors->getBag($__errorArgs[1] ?? 'default');
if ($__bag->has($__errorArgs[0])) :
if (isset($message)) { $__messageOriginal = $message; }
$message = $__bag->first($__errorArgs[0]); ?>
                                    <small class="text-danger"><?php echo e($message); ?></small>
                                    <?php unset($message);
if (isset($__messageOriginal)) { $message = $__messageOriginal; }
endif;
unset($__errorArgs, $__bag); ?>
                                </div>
                                <div class="col-lg-3 mb-3">
                                    <label class="form-label">Airport State</label>
                                    <select name="departure_airport_state_id" class="form-control select2" data-placeholder="Select One">
                                        <option value=""></option>
                                        <?php $__currentLoopData = $airports; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $new): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); ?>
                                        <option value="<?php echo e($new->id); ?>" <?php echo e(old('departure_airport_state_id') == $new->id ? 'selected' : ''); ?>>
                                            <?php echo e($new->state); ?>

                                        </option>
                                        <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); ?>
                                    </select>
                                    <?php $__errorArgs = ['departure_airport_state_id'];
$__bag = $errors->getBag($__errorArgs[1] ?? 'default');
if ($__bag->has($__errorArgs[0])) :
if (isset($message)) { $__messageOriginal = $message; }
$message = $__bag->first($__errorArgs[0]); ?>
                                    <small class="text-danger"><?php echo e($message); ?></small>
                                    <?php unset($message);
if (isset($__messageOriginal)) { $message = $__messageOriginal; }
endif;
unset($__errorArgs, $__bag); ?>
                                </div>
                                <div class="col-lg-2 mb-3">
                                    <label class="form-label">Airport Identity</label>
                                    <select name="departure_airport_identity_id" class="form-control select2" data-placeholder="Select One">
                                        <option value=""></option>
                                        <?php $__currentLoopData = $airlines; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $identity): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); ?>
                                        <option value="<?php echo e($identity->id); ?>" <?php echo e(old('departure_airport_identity_id') == $identity->id ? 'selected' : ''); ?>>
                                            <?php echo e($identity->identity); ?>

                                        </option>
                                        <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); ?>
                                    </select>
                                    <?php $__errorArgs = ['departure_airport_identity_id'];
$__bag = $errors->getBag($__errorArgs[1] ?? 'default');
if ($__bag->has($__errorArgs[0])) :
if (isset($message)) { $__messageOriginal = $message; }
$message = $__bag->first($__errorArgs[0]); ?>
                                    <small class="text-danger"><?php echo e($message); ?></small>
                                    <?php unset($message);
if (isset($__messageOriginal)) { $message = $__messageOriginal; }
endif;
unset($__errorArgs, $__bag); ?>
                                </div>
                                <div class="col-md-2 mt-2 mb-3">
                                    <label>Depature Terminal</label>
                                    <input type="text" name="departure_terminal" class="form-control" value="<?php echo e(old('departure_terminal')); ?>" placeholder="ex: Terminal 1" required>
                                    <?php $__errorArgs = ['departure_terminal'];
$__bag = $errors->getBag($__errorArgs[1] ?? 'default');
if ($__bag->has($__errorArgs[0])) :
if (isset($message)) { $__messageOriginal = $message; }
$message = $__bag->first($__errorArgs[0]); ?> <small class="text-danger"><?php echo e($message); ?></small> <?php unset($message);
if (isset($__messageOriginal)) { $message = $__messageOriginal; }
endif;
unset($__errorArgs, $__bag); ?>
                                </div>
                                <div class="col-md-3 mb-3">
                                    <label>Departure Date</label>
                                    <input type="text" name="departure_date" class="form-control flat_date" placeholder="Wed, Jan 21, 2026">
                                    <?php $__errorArgs = ['departure_date'];
$__bag = $errors->getBag($__errorArgs[1] ?? 'default');
if ($__bag->has($__errorArgs[0])) :
if (isset($message)) { $__messageOriginal = $message; }
$message = $__bag->first($__errorArgs[0]); ?> <small class="text-danger"><?php echo e($message); ?></small> <?php unset($message);
if (isset($__messageOriginal)) { $message = $__messageOriginal; }
endif;
unset($__errorArgs, $__bag); ?>
                                </div>
                                <div class="col-md-3 mb-3">
                                    <label>Departure Time</label>
                                    <input type="text" name="departure_time" class="form-control flat_time" placeholder="10:30 AM" readonly>
                                    <?php $__errorArgs = ['departure_time'];
$__bag = $errors->getBag($__errorArgs[1] ?? 'default');
if ($__bag->has($__errorArgs[0])) :
if (isset($message)) { $__messageOriginal = $message; }
$message = $__bag->first($__errorArgs[0]); ?> <small class="text-danger"><?php echo e($message); ?></small> <?php unset($message);
if (isset($__messageOriginal)) { $message = $__messageOriginal; }
endif;
unset($__errorArgs, $__bag); ?>
                                </div>
                                <div class="col-md-3 mb-3">
                                    <label>Journey Type</label>
                                    <select name="journey_type" class="form-control select2" data-placeholder="Select One">
                                        <option value=""></option>

                                        <option value="Non-stop" <?php echo e(old('journey_type') == 'Non-stop' ? 'selected' : ''); ?>>
                                            Non-stop
                                        </option>

                                        <option value="1 Stop" <?php echo e(old('journey_type') == '1 Stop' ? 'selected' : ''); ?>>
                                            1 Stop
                                        </option>

                                        <option value="2+ Stops" <?php echo e(old('journey_type') == '2+ Stops' ? 'selected' : ''); ?>>
                                            2+ Stops
                                        </option>

                                        <option value="Direct" <?php echo e(old('journey_type') == 'Direct' ? 'selected' : ''); ?>>
                                            Direct
                                        </option>

                                        <option value="Connecting" <?php echo e(old('journey_type') == 'Connecting' ? 'selected' : ''); ?>>
                                            Connecting
                                        </option>
                                    </select>

                                    <?php $__errorArgs = ['journey_type'];
$__bag = $errors->getBag($__errorArgs[1] ?? 'default');
if ($__bag->has($__errorArgs[0])) :
if (isset($message)) { $__messageOriginal = $message; }
$message = $__bag->first($__errorArgs[0]); ?>
                                    <small class="text-danger"><?php echo e($message); ?></small>
                                    <?php unset($message);
if (isset($__messageOriginal)) { $message = $__messageOriginal; }
endif;
unset($__errorArgs, $__bag); ?>
                                </div>
                                <div class="col-md-3 mb-3">
                                    <label>Journey Duration</label>
                                    <input type="text" name="journey_duration" class="form-control" value="<?php echo e(old('journey_duration')); ?>" placeholder="ex: 2H 30M" required>
                                    <?php $__errorArgs = ['journey_duration'];
$__bag = $errors->getBag($__errorArgs[1] ?? 'default');
if ($__bag->has($__errorArgs[0])) :
if (isset($message)) { $__messageOriginal = $message; }
$message = $__bag->first($__errorArgs[0]); ?> <small class="text-danger"><?php echo e($message); ?></small> <?php unset($message);
if (isset($__messageOriginal)) { $message = $__messageOriginal; }
endif;
unset($__errorArgs, $__bag); ?>
                                </div>
                                <hr>
                                <h6>Arrival Details</h6>
                                <div class="col-lg-4 mb-3">
                                    <label class="form-label">Select Airport</label>
                                    <select name="arrival_airport_id" class="form-control select2" data-placeholder="Select One">
                                        <option value=""></option>
                                        <?php $__currentLoopData = $airports_new; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $new): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); ?>
                                        <option value="<?php echo e($new->id); ?>" <?php echo e(old('arrival_airport_id') == $new->id ? 'selected' : ''); ?>>
                                            <?php echo e($new->name); ?>

                                        </option>
                                        <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); ?>
                                    </select>
                                    <?php $__errorArgs = ['arrival_airport_id'];
$__bag = $errors->getBag($__errorArgs[1] ?? 'default');
if ($__bag->has($__errorArgs[0])) :
if (isset($message)) { $__messageOriginal = $message; }
$message = $__bag->first($__errorArgs[0]); ?>
                                    <small class="text-danger"><?php echo e($message); ?></small>
                                    <?php unset($message);
if (isset($__messageOriginal)) { $message = $__messageOriginal; }
endif;
unset($__errorArgs, $__bag); ?>
                                </div>
                                <div class="col-lg-2 mb-3">
                                    <label class="form-label">Airport Code</label>
                                    <select name="arrival_airport_code_id" class="form-control select2" data-placeholder="Select One">
                                        <option value=""></option>
                                        <?php $__currentLoopData = $airports; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $new): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); ?>
                                        <option value="<?php echo e($new->id); ?>" <?php echo e(old('arrival_airport_code_id') == $new->id ? 'selected' : ''); ?>>
                                            <?php echo e($new->code); ?>

                                        </option>
                                        <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); ?>
                                    </select>
                                    <?php $__errorArgs = ['arrival_airport_code_id'];
$__bag = $errors->getBag($__errorArgs[1] ?? 'default');
if ($__bag->has($__errorArgs[0])) :
if (isset($message)) { $__messageOriginal = $message; }
$message = $__bag->first($__errorArgs[0]); ?>
                                    <small class="text-danger"><?php echo e($message); ?></small>
                                    <?php unset($message);
if (isset($__messageOriginal)) { $message = $__messageOriginal; }
endif;
unset($__errorArgs, $__bag); ?>
                                </div>
                                <div class="col-lg-4 mb-3">
                                    <label class="form-label">Airport State</label>
                                    <select name="arrival_airport_state_id" class="form-control select2" data-placeholder="Select One">
                                        <option value=""></option>
                                        <?php $__currentLoopData = $airports; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $new): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); ?>
                                        <option value="<?php echo e($new->id); ?>" <?php echo e(old('arrival_airport_state_id') == $new->id ? 'selected' : ''); ?>>
                                            <?php echo e($new->state); ?>

                                        </option>
                                        <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); ?>
                                    </select>
                                    <?php $__errorArgs = ['arrival_airport_state_id'];
$__bag = $errors->getBag($__errorArgs[1] ?? 'default');
if ($__bag->has($__errorArgs[0])) :
if (isset($message)) { $__messageOriginal = $message; }
$message = $__bag->first($__errorArgs[0]); ?>
                                    <small class="text-danger"><?php echo e($message); ?></small>
                                    <?php unset($message);
if (isset($__messageOriginal)) { $message = $__messageOriginal; }
endif;
unset($__errorArgs, $__bag); ?>
                                </div>
                                <div class="col-lg-2 mb-3">
                                    <label class="form-label">Airport Identity</label>
                                    <select name="arrival_airport_identity_id" class="form-control select2" data-placeholder="Select One">
                                        <option value=""></option>
                                        <?php $__currentLoopData = $airlines; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $identity): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); ?>
                                        <option value="<?php echo e($identity->id); ?>" <?php echo e(old('arrival_airport_identity_id') == $identity->id ? 'selected' : ''); ?>>
                                            <?php echo e($identity->identity); ?>

                                        </option>
                                        <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); ?>
                                    </select>
                                    <?php $__errorArgs = ['arrival_airport_identity_id'];
$__bag = $errors->getBag($__errorArgs[1] ?? 'default');
if ($__bag->has($__errorArgs[0])) :
if (isset($message)) { $__messageOriginal = $message; }
$message = $__bag->first($__errorArgs[0]); ?>
                                    <small class="text-danger"><?php echo e($message); ?></small>
                                    <?php unset($message);
if (isset($__messageOriginal)) { $message = $__messageOriginal; }
endif;
unset($__errorArgs, $__bag); ?>
                                </div>
                                <div class="col-md-3 mb-3">
                                    <label>Arrival Date</label>
                                    <input type="text" name="arrival_date" class="form-control flat_date" placeholder="Wed, Jan 21, 2026">
                                    <?php $__errorArgs = ['arrival_date'];
$__bag = $errors->getBag($__errorArgs[1] ?? 'default');
if ($__bag->has($__errorArgs[0])) :
if (isset($message)) { $__messageOriginal = $message; }
$message = $__bag->first($__errorArgs[0]); ?> <small class="text-danger"><?php echo e($message); ?></small> <?php unset($message);
if (isset($__messageOriginal)) { $message = $__messageOriginal; }
endif;
unset($__errorArgs, $__bag); ?>
                                </div>
                                <div class="col-md-3 mb-3">
                                    <label>Arrival Time</label>
                                    <input type="text" name="arrival_time" class="form-control flat_time" placeholder="10:30 AM" readonly>
                                    <?php $__errorArgs = ['arrival_time'];
$__bag = $errors->getBag($__errorArgs[1] ?? 'default');
if ($__bag->has($__errorArgs[0])) :
if (isset($message)) { $__messageOriginal = $message; }
$message = $__bag->first($__errorArgs[0]); ?> <small class="text-danger"><?php echo e($message); ?></small> <?php unset($message);
if (isset($__messageOriginal)) { $message = $__messageOriginal; }
endif;
unset($__errorArgs, $__bag); ?>
                                </div>
                                <hr>
                                <h6>Flight Details</h6>
                                <div class="col-md-3">
                                    <label>Class of Service</label>
                                    <select name="class_of_service" class="form-control select2" data-placeholder="Select One">
                                        <option value="">Select Class</option>

                                        <option value="Economy" <?php echo e(old('class_of_service') == 'Economy' ? 'selected' : ''); ?>>
                                            Economy
                                        </option>

                                        <option value="Premium Economy" <?php echo e(old('class_of_service') == 'Premium Economy' ? 'selected' : ''); ?>>
                                            Premium Economy
                                        </option>

                                        <option value="Business" <?php echo e(old('class_of_service') == 'Business' ? 'selected' : ''); ?>>
                                            Business
                                        </option>

                                        <option value="First Class" <?php echo e(old('class_of_service') == 'First Class' ? 'selected' : ''); ?>>
                                            First Class
                                        </option>
                                    </select>
                                    <?php $__errorArgs = ['class_of_service'];
$__bag = $errors->getBag($__errorArgs[1] ?? 'default');
if ($__bag->has($__errorArgs[0])) :
if (isset($message)) { $__messageOriginal = $message; }
$message = $__bag->first($__errorArgs[0]); ?>
                                    <small class="text-danger"><?php echo e($message); ?></small>
                                    <?php unset($message);
if (isset($__messageOriginal)) { $message = $__messageOriginal; }
endif;
unset($__errorArgs, $__bag); ?>
                                </div>
                                <div class="col-md-5 mb-3">
                                    <label>Airbus Number</label>
                                    <input type="text" name="airbus_number" class="form-control" value="<?php echo e(old('airbus_number')); ?>" required>
                                    <?php $__errorArgs = ['airbus_number'];
$__bag = $errors->getBag($__errorArgs[1] ?? 'default');
if ($__bag->has($__errorArgs[0])) :
if (isset($message)) { $__messageOriginal = $message; }
$message = $__bag->first($__errorArgs[0]); ?> <small class="text-danger"><?php echo e($message); ?></small> <?php unset($message);
if (isset($__messageOriginal)) { $message = $__messageOriginal; }
endif;
unset($__errorArgs, $__bag); ?>
                                </div>
                                <div class="col-md-3">
                                    <label>Meal</label>
                                    <select name="meal" class="form-control select2" data-placeholder="Select One">
                                        <option value="">Select</option>
                                        <option value="included" <?php echo e(old('meal') == 'included' ? 'selected' : ''); ?>>
                                            Meal
                                        </option>
                                        <option value="snack" <?php echo e(old('meal') == 'snack' ? 'selected' : ''); ?>>
                                            Snack Only
                                        </option>
                                        <option value="no_meal" <?php echo e(old('meal') == 'no_meal' ? 'selected' : ''); ?>>
                                            No Meal
                                        </option>
                                    </select>

                                    <?php $__errorArgs = ['meal'];
$__bag = $errors->getBag($__errorArgs[1] ?? 'default');
if ($__bag->has($__errorArgs[0])) :
if (isset($message)) { $__messageOriginal = $message; }
$message = $__bag->first($__errorArgs[0]); ?>
                                    <small class="text-danger"><?php echo e($message); ?></small>
                                    <?php unset($message);
if (isset($__messageOriginal)) { $message = $__messageOriginal; }
endif;
unset($__errorArgs, $__bag); ?>
                                </div>
                            </div>
                            <div class="col-12 text-end mt-3">
                                <button type="submit" id="saveBtn" class="btn btn-info">
                                    <i class="fas fa-save me-1"></i>
                                    <span class="btn-text">Save Trip</span>
                                </button>
                            </div>
                        </form>
                    </div>
                </div>
            </div>
        </div>
    </div>
</div>
<?php $__env->stopSection(); ?>
<?php $__env->startPush('script'); ?>
<script src="https://cdn.jsdelivr.net/npm/flatpickr"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/Dropify/0.2.2/js/dropify.min.js"></script>
<script>
    flatpickr(".flat_date", {
        altInput: true
        , altFormat: "D, M d, Y", // Wed, Jan 21, 2026
        dateFormat: "Y-m-d", // submitted value
        minDate: "today"
    });
    flatpickr(".flat_time", {
        enableTime: true
        , noCalendar: true
        , altInput: true
        , altFormat: "h:i K", // UI: 10:30 AM
        dateFormat: "h:i K", // submitted: 10:30 AM
        time_24hr: false
    });
</script>
<script>
    $(document).ready(function() {
        $('.select2').each(function() {
            $(this).select2({
                placeholder: $(this).data('placeholder')
                , allowClear: true
                , width: '100%'
                , theme: 'bootstrap'
            });
        });
    });
</script>
<script>
$('#tripForm').on('submit', function (e) {
    e.preventDefault();

    let form = this;
    let formData = new FormData(form);

    // Disable button to prevent double submit
    $('#saveBtn').prop('disabled', true);

    Swal.fire({
        title: 'Saving Trip',
        html: 'Please wait...',
        allowOutsideClick: false,
        didOpen: () => {
            Swal.showLoading();
        }
    });

    $.ajax({
        url: $(form).attr('action'),
        type: 'POST',
        data: formData,
        processData: false,
        contentType: false,
        headers: {
            'X-CSRF-TOKEN': $('input[name="_token"]').val(),
            'Accept': 'application/json'
        },
        success: function (response) {

            let timerInterval;

            Swal.fire({
                icon: 'success',
                title: 'Trip Saved Successfully',
                html: 'Redirecting to trip list... <b></b>',
                timer: 2000,
                timerProgressBar: true,
                allowOutsideClick: false,
                didOpen: () => {
                    const b = Swal.getHtmlContainer().querySelector('b');
                    timerInterval = setInterval(() => {
                        b.textContent = Math.ceil(Swal.getTimerLeft() / 1000);
                    }, 100);
                },
                willClose: () => {
                    clearInterval(timerInterval);
                }
            }).then(() => {
                if (response.redirect) {
                    window.location.href = response.redirect;
                }
            });
        },
        error: function (xhr) {
            $('#saveBtn').prop('disabled', false);

            let msg = 'Something went wrong';

            if (xhr.status === 422) {
                let errors = xhr.responseJSON.errors;
                msg = Object.values(errors).map(e => e[0]).join('<br>');
            }

            Swal.fire({
                icon: 'error',
                title: 'Validation Error',
                html: msg
            });
        }
    });
});
</script>
<?php $__env->stopPush(); ?>

<?php echo $__env->make('backend.master', array_diff_key(get_defined_vars(), ['__data' => 1, '__path' => 1]))->render(); ?><?php /**PATH /home/u973467024/domains/mhjohn.xyz/public_html/view-trip/resources/views/backend/trip/show.blade.php ENDPATH**/ ?>