<?php $__env->startSection('title',($trip->exists?'Edit':'New').' Trip'); ?>
<?php $__env->startSection('page_title',($trip->exists?'Edit':'New').' Trip'); ?>
<?php $__env->startSection('content'); ?>
<div class="page-head"><div><h1><?php echo e($trip->exists?'Edit':'Create'); ?> Trip</h1><p>Assign own or hired transport and record customer/vendor rates separately.</p></div><a class="btn btn-secondary" href="<?php echo e($trip->exists?route('trips.show',$trip):route('trips.index')); ?>">Back</a></div>
<form method="post" action="<?php echo e($trip->exists?route('trips.update',$trip):route('trips.store')); ?>"><?php echo csrf_field(); ?> <?php if($trip->exists): ?><?php echo method_field('put'); ?><?php endif; ?><div class="card"><div class="card-body"><div class="form-grid">
<div class="field"><label>Branch *</label><select class="control" name="branch_id"><?php $__currentLoopData = $branches; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $b): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); ?><option value="<?php echo e($b->id); ?>" <?php if(old('branch_id',$trip->branch_id)==$b->id): echo 'selected'; endif; ?>><?php echo e($b->code); ?> - <?php echo e($b->name); ?></option><?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); ?></select></div><div class="field"><label>Transport Job *</label><select class="control" name="transport_job_id" required><?php $__currentLoopData = $jobs; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $j): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); ?><option value="<?php echo e($j->id); ?>" <?php if(old('transport_job_id',$trip->transport_job_id)==$j->id): echo 'selected'; endif; ?>><?php echo e($j->job_number); ?> - <?php echo e($j->customer?->legal_name); ?></option><?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); ?></select></div>
<div class="field"><label>Vehicle</label><select class="control" name="vehicle_id"><option value="">External / unassigned</option><?php $__currentLoopData = $vehicles; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $v): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); ?><option value="<?php echo e($v->id); ?>" <?php if(old('vehicle_id',$trip->vehicle_id)==$v->id): echo 'selected'; endif; ?>><?php echo e($v->plate_number); ?> - <?php echo e($v->vehicle_type); ?></option><?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); ?></select></div><div class="field"><label>Driver</label><select class="control" name="driver_id"><option value="">Unassigned</option><?php $__currentLoopData = $drivers; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $d): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); ?><option value="<?php echo e($d->id); ?>" <?php if(old('driver_id',$trip->driver_id)==$d->id): echo 'selected'; endif; ?>><?php echo e($d->name); ?> (<?php echo e($d->driver_code); ?>)</option><?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); ?></select></div>
<div class="field"><label>Subcontractor / Vendor</label><select class="control" name="vendor_id"><option value="">Own vehicle</option><?php $__currentLoopData = $vendors; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $v): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); ?><option value="<?php echo e($v->id); ?>" <?php if(old('vendor_id',$trip->vendor_id)==$v->id): echo 'selected'; endif; ?>><?php echo e($v->legal_name); ?></option><?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); ?></select></div><div class="field"><label>Status</label><select class="control" name="status"><?php $__currentLoopData = ['scheduled','vehicle_assigned','driver_assigned','in_transit','reached_destination','delivered','cancelled']; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $s): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); ?><option value="<?php echo e($s); ?>" <?php if(old('status',$trip->status)===$s): echo 'selected'; endif; ?>><?php echo e(ucwords(str_replace('_',' ',$s))); ?></option><?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); ?></select></div>
<div class="field"><label>Pickup Date & Time</label><input class="control" type="datetime-local" name="pickup_at" value="<?php echo e(old('pickup_at',optional($trip->pickup_at)->format('Y-m-d\TH:i'))); ?>"></div><div class="field"><label>Delivery Date & Time</label><input class="control" type="datetime-local" name="delivery_at" value="<?php echo e(old('delivery_at',optional($trip->delivery_at)->format('Y-m-d\TH:i'))); ?>"></div>
<div class="field"><label>Pickup Location</label><input class="control" name="pickup_location" value="<?php echo e(old('pickup_location',$trip->pickup_location)); ?>"></div><div class="field"><label>Delivery Location</label><input class="control" name="delivery_location" value="<?php echo e(old('delivery_location',$trip->delivery_location)); ?>"></div>
<div class="field"><label>Customer Rate</label><input class="control" type="number" step="0.01" name="customer_rate" value="<?php echo e(old('customer_rate',$trip->customer_rate??0)); ?>"></div><div class="field"><label>Vendor Rate</label><input class="control" type="number" step="0.01" name="vendor_rate" value="<?php echo e(old('vendor_rate',$trip->vendor_rate??0)); ?>"></div>
<div class="field"><label>Additional Revenue</label><input class="control" type="number" step="0.01" name="additional_revenue" value="<?php echo e(old('additional_revenue',$trip->additional_revenue??0)); ?>"></div><div class="field"><label>Additional Cost</label><input class="control" type="number" step="0.01" name="additional_cost" value="<?php echo e(old('additional_cost',$trip->additional_cost??0)); ?>"></div>
<div class="field"><label>Start Odometer</label><input class="control" type="number" step="0.01" name="start_odometer" value="<?php echo e(old('start_odometer',$trip->start_odometer)); ?>"></div><div class="field"><label>End Odometer</label><input class="control" type="number" step="0.01" name="end_odometer" value="<?php echo e(old('end_odometer',$trip->end_odometer)); ?>"></div>
<div class="field full"><label>Notes</label><textarea class="control" name="notes"><?php echo e(old('notes',$trip->notes)); ?></textarea></div></div></div><div class="card-head" style="justify-content:flex-end"><button class="btn btn-primary">Save Trip</button></div></div></form>
<?php $__env->stopSection(); ?>

<?php echo $__env->make('layouts.app', array_diff_key(get_defined_vars(), ['__data' => 1, '__path' => 1]))->render(); ?><?php /**PATH /home/cbo/public_html/resources/views/trips/form.blade.php ENDPATH**/ ?>