File: /home/cafsindia/allyindian_com/sbltt/application/views/operation/form.php
<?php
$tp_url = base_url()."index.php/operation/print_tp/";
$op_url = base_url()."index.php/operation/print_trip_sheet/";
?>
<ul class="nav nav-tabs" data-tabs="tabs" style='background-color:#d84f57;'>
<li class="active" role="presentation" style='margin-left:20px;'>
<a data-toggle="tab" href="#assign_vehicle">Assign Vehicle</a>
</li>
<li role="presentation">
<a data-toggle="tab" href="#add_suspence">Add Suspense</a>
</li>
<li role="presentation">
<a data-toggle="tab" href="#suspence">Suspense</a>
</li>
<li role="presentation">
<a data-toggle="tab" href="#diesel">Diesel</a>
</li>
<li role="presentation">
<a data-toggle="tab" href="#extra_km">KM Management</a>
</li>
<li role="presentation">
<a data-toggle="tab" href="#maintenance">Maintenance</a>
</li>
<li role="presentation">
<a data-toggle="tab" href="#feed_back">Feedback</a>
</li>
<li role="presentation">
<a data-toggle="tab" href="#trip_summary">Trip Summary</a>
</li>
</ul>
<div class="tab-content">
<div class="tab-pane fade in active" id="assign_vehicle">
<div class="col-md-12" style='padding:8px;border-bottom:1px dashed #CCCCCC;'>
<div style='background-color: #EEEEEE; padding: 4px; overflow: auto;'>
<h5 style='color:#d84f57;margin: 7px 2px'>Customer Information</h5>
<table class="table table-hover table-striped table-bordered">
<thead>
<tr>
<th>Name</th>
<th>Mobile Number</th>
<th>Alt Mobile Number</th>
<th>Landline Number</th>
<th>Reporting Address</th>
<th>City</th>
<th>State</th>
<th>Landmark</th>
</tr>
</thead>
<tbody>
<?php
$customer_name = $booking_info->customer_name;
$phone_number = $booking_info->phone_number;
$alt_number = $booking_info->alt_number;
$land_line = $booking_info->land_line;
$report_address = $booking_info->report_address;
$city = $booking_info->city;
$state_name = $booking_info->state_name;
$landmark = $booking_info->landmark;
$operation_sts = $booking_info->operation_sts;
echo "<tr>
<td>$customer_name</td>
<td>$phone_number</td>
<td>$alt_number</td>
<td>$land_line</td>
<td>$report_address</td>
<td>$city</td>
<td>$state_name</td>
<td>$landmark</td>
</tr>";
?>
</tbody>
</table>
</div>
<div style='background-color: #EEEEEE; padding: 4px; overflow: auto;'>
<h5 style='color:#d84f57;margin: 7px 2px'>Booking Information</h5>
<table class="table table-hover table-striped table-bordered">
<thead>
<tr>
<th>Tour#</th>
<th>Type</th>
<th>Coach</th>
<th>Vehicle#</th>
<th>Days#</th>
<th>Vehicle</th>
<th>Origin</th>
<th>Destination</th>
<th>From</th>
<th>To</th>
<th>Trip</th>
<th>Remarks</th>
<th>Reporting</th>
<th>Shed Out</th>
<th>Extra</th>
</tr>
</thead>
<tbody>
<?php
$preferred = "";
foreach($preferred_list as $list){
$vehicle_no = $list->vehicle_no;
$preferred .= "$vehicle_no<br/>";
}
$customer_name = $booking_info->customer_name;
$tour_no = $booking_info->tour_no;
$trip_type_name = $booking_info->trip_type_name;
$veh_type = $booking_info->veh_type;
$from_date = date('d-m-Y',strtotime($booking_info->from_date));
$to_date = date('d-m-Y',strtotime($booking_info->to_date));
$frm_city_name = $booking_info->frm_city_name;
$to_city_name = $booking_info->to_city_name;
$bus_count = $booking_info->bus_count;
$trip_days = $booking_info->trip_days;
$preferred_vehicle = $booking_info->preferred_vehicle;
$trip_details = $booking_info->trip_details;
$remark = $booking_info->remark;
$reporting_time = date("G:i", strtotime($booking_info->reporting_time)).' '.'Hrs';
$shed_out_time = date("G:i", strtotime($booking_info->shed_out_time)).' '.'Hrs';
$trip_type = $booking_info->trip_type;
$booking_id = $booking_info->booking_id;
$operation_id = $booking_info->operation_id;
$extra = "";
if($booking_info->toll === "1"){
$extra = "Toll,";
}
if($booking_info->parking === "1"){
$extra .= "Parking,";
}
if($booking_info->driver_batta === "1"){
$extra .= "Driver Batta,";
}
if($booking_info->state_tax === "1"){
$extra .= "Other State tax";
}
$extra = rtrim($extra, ',');
if($extra === ""){
$extra = "Toll,Parking,Driver Batta,Other State tax all inclusive*";
}else{
$extra = $extra." extra*";
}
echo "<tr>
<td>$tour_no</td>
<td>$trip_type_name</td>
<td>$veh_type</td>
<td>$bus_count</td>
<td>$trip_days</td>
<td>$preferred</td>
<td>$frm_city_name</td>
<td>$to_city_name</td>
<td style='white-space:nowrap !important;'>$from_date</td>
<td style='white-space:nowrap !important;'>$to_date</td>
<td>$trip_details</td>
<td>$remark</td>
<td>$reporting_time</td>
<td>$shed_out_time</td>
<td>$extra</td>
</tr>";
?>
</tbody>
</table>
</div>
<div style='background-color: #EEEEEE; padding: 4px; overflow: auto;'>
<h5 style='color:#d84f57;margin: 7px 2px'>Amount Information</h5>
<table class="table table-hover table-striped table-bordered">
<thead>
<tr>
<th>Extra KM</th>
<th>Hire</th>
<th>Hotel</th>
<th>Food</th>
<th>Extra</th>
<th>Total</th>
<th>Paid</th>
<th>Discount</th>
<th>Tax</th>
<th>Balance</th>
</tr>
</thead>
</thead>
<tbody>
<?php
$tax_precentage = $booking_info->tax_precentage;
$booking_amount = $booking_info->booking_amount;
$advance_amount = $booking_info->advance_amount;
$discount_amount = $booking_info->discount_amount;
$balance_amount = $booking_info->balance_amount;
$stay_tot = $booking_info->stay_tot;
$food_tot = $booking_info->food_tot;
$paid_tot = $booking_info->paid_tot;
$extra_amount = $booking_info->extra_amt;
$extra_km = $booking_info->extra_km;
$advance_amount = $advance_amount + $paid_tot;
$tot = $booking_amount + $stay_tot + $food_tot + $extra_amount;
echo "<tr>
<td>$extra_km</td>
<td>$booking_amount</td>
<td>$stay_tot</td>
<td>$food_tot</td>
<td>$extra_amount</td>
<td>$tot</td>
<td>$advance_amount</td>
<td>$discount_amount</td>
<td>$tax_precentage%</td>
<td>$balance_amount</td>
</tr>";
?>
</tbody>
</table>
</div>
<div style='background-color: #EEEEEE; padding: 4px; overflow: auto;'>
<h5 style='color:#d84f57;margin: 7px 2px'>Trip Information</h5>
<table class="table table-hover table-striped table-bordered">
<thead>
<tr>
<th>Coach</th>
<th>Vehicle</th>
<th>Driver Name</th>
<th>Driver Mobile Number</th>
<th>Suspense Amount</th>
<th>Check List </th>
<th>Remarks</th>
<th>Red Alert</th>
<th>Edit</th>
<th>TP</th>
<th>Print</th>
<th>Remove</th>
</tr>
</thead>
<tbody id='op_line_list'>
<?php
$assiged_count = 0;
foreach($op_line_list as $list){
$assiged_count++;
$op_line_id = $list->op_line_id;
$operation_id = $list->operation_id;
$op_vehicle_type = $list->op_vehicle_type;
$veh_type = $list->veh_type;
$op_vehicle_id = $list->op_vehicle_id;
$vehicle_no = $list->vehicle_no;
$op_driver_id = $list->op_driver_id;
$op_driver_name = $list->op_driver_name;
$op_driver_number = $list->op_driver_number;
$op_suspence_amt = $list->op_suspence_amt;
$op_chk_list = $list->op_chk_list;
$remarks = $list->remarks;
$op_tp_info = $list->tp_info;
$status = $list->status;
$red_alert = $list->red_alert;
$op_chk_list = str_replace("_"," ",$op_chk_list);
$tp_url_line = $tp_url."$op_line_id";
$op_url_line = $op_url."$op_line_id";
echo "<tr>
<td>$veh_type </td>
<td>$vehicle_no </td>
<td>$op_driver_name </td>
<td>$op_driver_number </td>
<td>$op_suspence_amt </td>
<td>$op_chk_list </td>
<td>$remarks</td>
<td style='color:red;'>$red_alert</td>
<td><a style='cursor: pointer;' onclick=edit_op_line('$op_line_id')>Edit</a></td>
<td><a href='$tp_url_line' style='cursor: pointer;'>Print TP</a></td>
<td><a href='$op_url_line' style='cursor: pointer;'><i class='fa fa-print fa-lg'></i> Print</a></td>
<td><a style='cursor: pointer;' onclick=remove_op_line('$op_line_id')> Remove</a></td>
</tr>";
}
?>
</tbody>
</table>
</div>
</div>
<div class="col-md-12" style='padding:8px;border-bottom:1px dashed #CCCCCC;'>
<h5 style='color:#d84f57;margin: 7px 2px'>Update trip completed status</h5>
<div class="form-group ">
<label class="checkbox-inline">
<?php
$chk = false;
if($operation_sts === "4"){
$chk = true;
}
echo form_checkbox(array( 'name' => 'operation_sts', 'id' => 'operation_sts', 'value' =>'' , 'checked' =>$chk));
echo form_input( array( 'name'=>'mobile', 'id'=>'mobile', 'type'=>'Hidden','value'=>$phone_number));
?>
<?php echo form_label("Over all trip completed", 'operation_sts',array( 'style' => 'margin: 2px 9px;')); ?>
</label>
</div>
<style>
input[type="checkbox"]{
width: 20px; /*Desired width*/
height: 20px; /*Desired height*/
}
</style>
</div>
<div class="col-md-9" style='padding:8px;margin-bottom:4px;background-color:#f9f9f9;'>
<h5 style='color:#d84f57;'>Operation Information</h5>
<div id="availability_chart" style="display:none;"> <!-- Availability Chart content --> </div>
<?php echo form_open('operation/save/',array('id'=>'operation_form','class'=>'form-inline')); ?>
<?php
echo form_input( array( 'name'=>'trip_type', 'id'=>'trip_type', 'type'=>'Hidden','value'=>$trip_type ));
echo form_input( array( 'name'=>'from_date', 'id'=>'from_date', 'type'=>'Hidden','value'=>$from_date));
echo form_input( array( 'name'=>'to_date', 'id'=>'to_date', 'type'=>'Hidden','value'=>$to_date));
echo form_input( array( 'name'=>'booking_id', 'id'=>'booking_id', 'type'=>'Hidden','value'=>$booking_id));
echo form_input( array( 'name'=>'operation_id', 'id'=>'operation_id', 'type'=>'Hidden','value'=>$operation_id));
echo form_input( array( 'name'=>'bus_count', 'id'=>'bus_count', 'type'=>'Hidden','value'=>$bus_count));
echo form_input( array( 'name'=>'op_line_id', 'id'=>'op_line_id', 'type'=>'Hidden','value'=>""));
?>
<div class="form-group">
<?php echo form_label("Vehicle Type", 'booking_sts', array('class' => 'control-label required')); ?>
<?php
echo form_dropdown(array(
'name' => 'vehicle_type',
'id' => 'vehicle_type',
'class' => 'form-control input-sm'), $vehicle_type, $booking_info->vehicle_type);
?>
</div>
<div class="form-group">
<?php echo form_label("Select Vehicle", 'vehicle_id', array('class' => 'control-label required')); ?>
<?php
echo form_dropdown(array(
'name' => 'vehicle_id',
'id' => 'vehicle_id',
'class' => 'form-control input-sm'), $vehicle_list);
?>
</div>
<div class="form-group">
<?php echo form_label("Check list / Review Status", 'chk_list', array('class' => 'control-label required')); ?>
<?php
$chk_list = array('' => '--Select Check list / Review Status--','Reviewed' => 'Reviewed','Not_Reviewed' => 'Not Reviewed');
echo form_dropdown(array(
'name' => 'chk_list',
'id' => 'chk_list',
'class' => 'form-control input-sm'), $chk_list);
?>
</div>
<div class="form-group">
<textarea placeholder="Remarks" name="remarks" id="remarks" class="form-control" rows="4"></textarea>
</div>
<div class="form-group">
<?php echo form_label("Select Primary Driver", 'vehicle_id', array('class' => 'control-label required')); ?>
<?php
echo form_dropdown(array(
'name' => 'driver_id',
'id' => 'driver_id',
'class' => 'form-control input-sm'), $driver_list);
?>
</div>
<div class="form-group">
<?php echo form_label("Primary Driver Name", 'driver_name', array('class' => 'control-label required')); ?>
<?php
echo form_input(array(
'name' => 'driver_name',
'id' => 'driver_name',
'class' => 'form-control input-sm',
'value' => '')
);
?>
</div>
<div class="form-group">
<?php echo form_label("Primary Driver Mobile Number", 'driver_number', array('class' => 'control-label required')); ?>
<?php
echo form_input(array(
'name' => 'driver_number',
'id' => 'driver_number',
'class' => 'form-control input-sm number',
'value' => '')
);
?>
</div>
<div class="form-group">
<?php echo form_label("Suspense Amount", 'suspence_amt', array('class' => 'control-label required')); ?>
<?php
echo form_input(array(
'name' => 'suspence_amt',
'id' => 'suspence_amt',
'class' => 'form-control input-sm number',
'value' => '')
);
?>
</div>
<div class="form-group">
<?php echo form_label("Secondary Select Driver", 'second_driver_id', array('class' => 'control-label')); ?>
<?php
echo form_dropdown(array(
'name' => 'second_driver_id',
'id' => 'second_driver_id',
'class' => 'form-control input-sm'), $driver_list);
?>
</div>
<div class="form-group">
<?php echo form_label("Secondary Driver Name", 'second_driver_name', array('class' => 'control-label')); ?>
<?php
echo form_input(array(
'name' => 'second_driver_name',
'id' => 'second_driver_name',
'class' => 'form-control input-sm',
'value' => '')
);
?>
</div>
<div class="form-group">
<?php echo form_label("Secondary Driver Mobile Number", 'second_driver_number', array('class' => 'control-label')); ?>
<?php
echo form_input(array(
'name' => 'second_driver_number',
'id' => 'second_driver_number',
'class' => 'form-control input-sm number',
'value' => '')
);
?>
</div>
<div class="form-group">
<?php echo form_label("Select Cleaner", 'cleaner_id', array('class' => 'control-label')); ?>
<?php
echo form_dropdown(array(
'name' => 'cleaner_id',
'id' => 'cleaner_id',
'class' => 'form-control input-sm'), $cleaner_list);
?>
</div>
<div class="form-group">
<?php echo form_label("Cleaner Name", 'cleaner_name', array('class' => 'control-label')); ?>
<?php
echo form_input(array(
'name' => 'cleaner_name',
'id' => 'cleaner_name',
'class' => 'form-control input-sm',
'value' => '')
);
?>
</div>
<div class="form-group">
<?php echo form_label("Cleaner Mobile Number", 'cleaner_number', array('class' => 'control-label')); ?>
<?php
echo form_input(array(
'name' => 'cleaner_number',
'id' => 'cleaner_number',
'class' => 'form-control input-sm number',
'value' => '')
);
?>
</div><br/>
<div class="form-group" style='width:46.3%;'>
<textarea placeholder="Customer Route Information" name="cust_rout_info" id="cust_rout_info" class="form-control" rows="10"><?php echo $booking_info->trip_details;?></textarea>
</div>
<?php
if($book_tp_info === "Yes"){
?>
<div class="form-group" style='width:46.3%;'>
<textarea placeholder="Temporary Permit Information" name="tp_info" id="tp_info" class="form-control" rows="10"></textarea>
</div>
<?php
}
echo form_input(array('type'=>'hidden','id'=>'book_tp_info','value'=>$book_tp_info));
?>
<button type='submit' class='btn btn-primary btn-sm' style='background:#d84f57;border:1px solid #d84f57;padding:6px 30px;margin-bottom:8px;margin-top:8px;' id='operation_btn'>Add / Update</button>
<?php echo form_close(); ?>
</div>
<div class="col-md-3" style='padding:8px;height:500px;overflow:auto;margin-bottom:4px;border-left:1px dashed #CCCCCC;padding-left:4px;'>
<h5 style='color:#d84f57;'>Vehicle Information</h5>
<table class="table table-hover table-striped table-bordered" id='vch_info'>
<thead>
<tr>
<th>Documents</th>
<th>Expiry On</th>
<th>Status</th>
</tr>
</thead>
<tbody id="vch_info_list"> </tbody>
</table>
</div>
</div>
<div class="tab-pane fade" id="add_suspence">
<div class="col-md-12" style='padding:8px;margin-bottom:4px;'>
<?php echo form_open('operation/save_driver_suspence/',array('id'=>'save_driver_suspence','class'=>'form-inline')); ?>
<div class="form-group" style='width:19.5%;'>
<?php echo form_label("Select Date", 'date', array('class' => 'control-label required')); ?>
<select class='form-control input-sm' id='driver_suspence_date' name='driver_suspence_date'>
<option value="">--Select Date--</option>
<?php
$from_date = date('d-m-Y',strtotime($booking_info->from_date));
$to_date = date('d-m-Y',strtotime($booking_info->to_date));
$from = strtotime($from_date);
$to = strtotime($to_date);
for($i=$from; $i<=$to; $i+=86400) {
$bet_date = date("d-m-Y", $i);
echo "<option value='$bet_date'>$bet_date</option>";
}
?>
</select>
</div>
<div class="form-group" style='width:19.5%;'>
<?php echo form_label("Select Vehicle", 'driver_suspence_vch_id', array('class' => 'control-label required')); ?>
<?php
echo form_dropdown(array(
'name' => 'driver_suspence_vch_id',
'id' => 'driver_suspence_vch_id',
'class' => 'form-control input-sm'), $suspence_vech);
?>
</div>
<div class="form-group" style='width:19.5%;'>
<?php echo form_label("Suspense Amount", 'driver_suspence_amount', array('class' => 'control-label')); ?>
<?php
echo form_input(array(
'name' => 'driver_suspence_amount',
'id' => 'driver_suspence_amount',
'class' => 'form-control input-sm number',
'value' => '')
);
?>
</div>
<?php
echo form_input(array('type'=>'hidden','name'=>'driver_suspence_op_id','id'=>'driver_suspence_op_id','value'=>$booking_info->operation_id));
echo form_input(array('type'=>'hidden','name'=>'driver_suspence_id','id'=>'driver_suspence_id','value'=>''));
?>
<button type='submit' class='btn btn-primary btn-sm' style='background:#d84f57;border:1px solid #d84f57;padding:6px 30px;margin-top:-7px;' id='catering_add'>Add / Update</button>
<?php echo form_close(); ?>
<div style='background-color: #EEEEEE; padding: 4px; overflow: auto;'>
<h5 style='color:#d84f57;'>Driver Suspense Information</h5>
<table class="table table-hover table-striped table-bordered" id='suspence_table'>
<thead>
<tr>
<th>Date</th>
<th>Vehicle</th>
<th>Amount</th>
<th>Edit</th>
</tr>
</thead>
<tbody id="driver_suspence_list_tb">
<?php
$tot_driver_suspence = 0;
foreach($driver_suspence_list as $driver_suspence){
$driver_suspence_id = $driver_suspence->driver_suspence_id;
$driver_suspence_date = date("d-m-Y", strtotime($driver_suspence->driver_suspence_date));
$driver_vehicle_no = $driver_suspence->vehicle_no;
$driver_suspence_amt = $driver_suspence->driver_suspence_amount;
$tot_driver_suspence += $driver_suspence_amt;
echo "<tr>
<td>$driver_suspence_date</td>
<td>$driver_vehicle_no</td>
<td>$driver_suspence_amt</td>
<td><a style='cursor: pointer;' onclick=get_driver_suspence('$driver_suspence_id')>Edit</a></td>
</tr>";
}
echo "<tr><td colspan='2' style='font-weight:bold;'>Total Amount</td><td colspan='2' style='font-weight:bold;'>$tot_driver_suspence</td></tr>";
?>
</tbody>
</table>
</div>
</div>
</div>
<div class="tab-pane fade" id="suspence">
<div class="col-md-12" style='padding:8px;margin-bottom:4px;'>
<?php echo form_open('operation/save_suspence/',array('id'=>'save_suspence','class'=>'form-inline')); ?>
<div class="form-group" style='width:19.5%;'>
<?php echo form_label("Select Date", 'date', array('class' => 'control-label required')); ?>
<select class='form-control input-sm' id='suspence_date' name='suspence_date'>
<option value="">--Select Date--</option>
<?php
$from_date = date('d-m-Y',strtotime($booking_info->from_date));
$to_date = date('d-m-Y',strtotime($booking_info->to_date));
$from = strtotime($from_date);
$to = strtotime($to_date);
for($i=$from; $i<=$to; $i+=86400) {
$bet_date = date("d-m-Y", $i);
echo "<option value='$bet_date'>$bet_date</option>";
}
?>
</select>
</div>
<div class="form-group" style='width:19.5%;'>
<?php echo form_label("Select Vehicle", 'suspence_vch_id', array('class' => 'control-label required')); ?>
<?php
echo form_dropdown(array(
'name' => 'suspence_vch_id',
'id' => 'suspence_vch_id',
'class' => 'form-control input-sm'), $suspence_vech);
?>
</div>
<div class="form-group" style='width:19.5%;'>
<?php echo form_label("Suspense Information", 'suspence_info', array('class' => 'control-label')); ?>
<?php
$suspence_info = array('' => '--Suspense Type--','Toll' => 'Toll','Parking' => 'Parking','Kickbacks' => 'Kickbacks','Permit' => 'Permit','RTO' => 'RTO','TAX' => 'TAX','Driver' => 'Driver','Cleaner' => 'Cleaner','Balance_Received' => 'Balance Received','Others' => 'Others');
echo form_dropdown(array(
'name' => 'suspence_info',
'id' => 'suspence_info',
'class' => 'form-control input-sm'), $suspence_info);
?>
</div>
<div class="form-group" style='width:19.5%;'>
<?php echo form_label("Suspense Amount", 'suspence_amount', array('class' => 'control-label')); ?>
<?php
echo form_input(array(
'name' => 'suspence_amount',
'id' => 'suspence_amount',
'class' => 'form-control input-sm number',
'value' => '')
);
?>
</div>
<?php
echo form_input(array('type'=>'hidden','name'=>'suspence_book_id','id'=>'suspence_book_id','value'=>$booking_info->booking_id));
echo form_input(array('type'=>'hidden','name'=>'suspence_op_id','id'=>'suspence_op_id','value'=>$booking_info->operation_id));
echo form_input(array('type'=>'hidden','name'=>'suspence_id','id'=>'suspence_id','value'=>''));
?>
<button type='submit' class='btn btn-primary btn-sm' style='background:#d84f57;border:1px solid #d84f57;padding:6px 30px;margin-top:-7px;' id='catering_add'>Add / Update</button>
<?php echo form_close(); ?>
<div style='background-color: #EEEEEE; padding: 4px; overflow: auto;'>
<h5 style='color:#d84f57;'>Suspense Information</h5>
<table class="table table-hover table-striped table-bordered" id='suspence_table'>
<thead>
<tr>
<th>Date</th>
<th>Vehicle</th>
<th>Reson</th>
<th>Amount</th>
<th>Edit</th>
</tr>
</thead>
<tbody id="suspence_list">
<?php
$tot_suspence = 0;
foreach($suspence_list as $suspence){
$suspence_id = $suspence->suspence_id;
$suspence_date = date("d-m-Y", strtotime($suspence->suspence_date));
$vehicle_no = $suspence->vehicle_no;
$suspence_info = $suspence->suspence_info;
$suspence_amt = $suspence->suspence_amt;
$tot_suspence += $suspence_amt;
echo "<tr>
<td>$suspence_date</td>
<td>$vehicle_no</td>
<td>$suspence_info</td>
<td>$suspence_amt</td>
<td><a style='cursor: pointer;' onclick=get_suspence('$suspence_id')>Edit</a></td>
</tr>";
}
echo "<tr><td colspan='3' style='font-weight:bold;'>Total Amount</td><td colspan='2' style='font-weight:bold;'>$tot_suspence</td></tr>";
?>
</tbody>
</table>
<h5 style='color:#d84f57;'>Suspense Vehicle Total</h5>
<table class="table table-hover table-striped table-bordered" id='suspence_table'>
<thead>
<tr>
<th>Vehicle</th>
<th>Amount</th>
</tr>
</thead>
<tbody id='suspence_sub_list'>
<?php
$sp_tot = 0;
foreach($suspence_subtotal as $sup_tot){
$veh_no = $sup_tot->vehicle_no;
$amt = $sup_tot->amt;
$sp_tot += $amt;
echo "<tr><td>$veh_no</td><td>$amt</td></tr>";
}
echo "<tr><td style='font-weight:bold;'>Total Amount</td><td style='font-weight:bold;'>$sp_tot</td></tr>";
?>
</tbody>
</table>
</div>
</div>
</div>
<div class="tab-pane fade" id="diesel">
<div class="col-md-12" style='padding:8px;margin-bottom:4px;'>
<?php echo form_open('operation/save_diesel/',array('id'=>'save_diesel','class'=>'form-inline')); ?>
<div class="form-group" style='width:13.5%;'>
<?php echo form_label("Select Date", 'date', array('class' => 'control-label required')); ?>
<select class='form-control input-sm' id='diesel_date' name='diesel_date'>
<option value="">--Select Date--</option>
<?php
$from_date = date('d-m-Y',strtotime($booking_info->from_date));
$to_date = date('d-m-Y',strtotime($booking_info->to_date));
$from = strtotime($from_date);
$to = strtotime($to_date);
for($i=$from; $i<=$to; $i+=86400) {
$bet_date = date("d-m-Y", $i);
echo "<option value='$bet_date'>$bet_date</option>";
}
?>
</select>
</div>
<div class="form-group" style='width:13.5%;'>
<?php echo form_label("Select Vehicle", 'diesel_vch_id', array('class' => 'control-label required')); ?>
<?php
echo form_dropdown(array(
'name' => 'diesel_vch_id',
'id' => 'diesel_vch_id',
'class' => 'form-control input-sm'), $suspence_vech);
?>
</div>
<div class="form-group" style='width:13.5%;'>
<?php echo form_label("Start KM", 'start_km', array('class' => 'control-label')); ?>
<?php
echo form_input(array(
'name' => 'start_km',
'id' => 'start_km',
'class' => 'form-control input-sm number',
'value' => '')
);
?>
</div>
<div class="form-group" style='width:13.5%;'>
<?php echo form_label("End KM", 'end_km', array('class' => 'control-label')); ?>
<?php
echo form_input(array(
'name' => 'end_km',
'id' => 'end_km',
'class' => 'form-control input-sm number',
'value' => '')
);
?>
</div>
<div class="form-group" style='width:13.5%;'>
<?php echo form_label("Quantity", 'diesel_quantity', array('class' => 'control-label')); ?>
<?php
echo form_input(array(
'name' => 'diesel_quantity',
'id' => 'diesel_quantity',
'class' => 'form-control input-sm number',
'value' => '')
);
?>
</div>
<div class="form-group" style='width:13.5%;'>
<?php echo form_label("Amount", 'diesel_amt', array('class' => 'control-label')); ?>
<?php
echo form_input(array(
'name' => 'diesel_amt',
'id' => 'diesel_amt',
'class' => 'form-control input-sm number',
'value' => '')
);
?>
</div>
<?php
echo form_input(array('type'=>'hidden','name'=>'diesel_op_id','id'=>'diesel_op_id','value'=>$booking_info->operation_id));
echo form_input(array('type'=>'hidden','name'=>'diesel_id','id'=>'diesel_id','value'=>''));
?>
<button type='submit' class='btn btn-primary btn-sm' style='background:#d84f57;border:1px solid #d84f57;padding:6px 30px;margin-top:-7px;' id='catering_add'>Add / Update</button>
<?php echo form_close(); ?>
<div style='background-color: #EEEEEE; padding: 4px; overflow: auto;'>
<h5 style='color:#d84f57;'>Diesel Information</h5>
<table class="table table-hover table-striped table-bordered" id='diesel_table'>
<thead>
<tr>
<th>Date</th>
<th>Vehicle</th>
<th>Start KM</th>
<th>End KM</th>
<th>Quantity</th>
<th>Amount</th>
<th>Actual KM</th>
<th>Avg KM</th>
<th>Edit</th>
</tr>
</thead>
<tbody id="diesel_list">
<?php
$tot_diesel = 0;
foreach($diesel_list as $diesel){
$diesel_id = $diesel->diesel_id;
$diesel_date = date("d-m-Y", strtotime($diesel->diesel_date));
$vehicle_no = $diesel->vehicle_no;
$start_km = $diesel->start_km;
$end_km = $diesel->end_km;
$diesel_quantity = $diesel->diesel_quantity;
$diesel_amt = $diesel->diesel_amt;
$actual_km = $diesel->actual_km;
$avg_km = $diesel->avg_km;
$diesel_op_id = $diesel->diesel_op_id;
$tot_diesel += $diesel_amt;
echo "<tr>
<td>$diesel_date</td>
<td>$vehicle_no</td>
<td>$start_km</td>
<td>$end_km</td>
<td>$diesel_quantity</td>
<td>$diesel_amt</td>
<td>$actual_km</td>
<td>$avg_km</td>
<td><a style='cursor: pointer;' onclick=get_diesel('$diesel_id')>Edit</a></td>
</tr>";
}
echo "<tr><td colspan='5' style='font-weight:bold;'>Total Amount</td><td colspan='4' style='font-weight:bold;'>$tot_diesel</td></tr>";
?>
</tbody>
</table>
<h5 style='color:#d84f57;'>Diesel Vehicle Total</h5>
<table class="table table-hover table-striped table-bordered" id='suspence_table'>
<thead>
<tr>
<th>Vehicle</th>
<th>Amount</th>
</tr>
</thead>
<tbody id="diesel_sub_list">
<?php
$die_tot_amt = 0;
foreach($diesel_subtotal as $die_tot){
$die_veh_no = $die_tot->vehicle_no;
$die_amt = $die_tot->amt;
$die_tot_amt += $die_amt;
echo "<tr><td>$die_veh_no</td><td>$die_amt</td></tr>";
}
echo "<tr><td style='font-weight:bold;'>Total Amount</td><td style='font-weight:bold;'>$die_tot_amt</td></tr>";
?>
</tbody>
</table>
</div>
</div>
</div>
<div class="tab-pane fade" id="maintenance">
<div class="col-md-12" style='padding:8px;margin-bottom:4px;'>
<?php echo form_open('operation/save_maintenance/',array('id'=>'save_maintenance','class'=>'form-inline')); ?>
<div class="form-group" style='width:13.5%;'>
<?php echo form_label("Select Date", 'date', array('class' => 'control-label required')); ?>
<select class='form-control input-sm' id='maintenance_date' name='maintenance_date'>
<option value="">--Select Date--</option>
<?php
$from_date = date('d-m-Y',strtotime($booking_info->from_date));
$to_date = date('d-m-Y',strtotime($booking_info->to_date));
$from = strtotime($from_date);
$to = strtotime($to_date);
for($i=$from; $i<=$to; $i+=86400) {
$bet_date = date("d-m-Y", $i);
echo "<option value='$bet_date'>$bet_date</option>";
}
?>
</select>
</div>
<div class="form-group" style='width:13.5%;'>
<?php echo form_label("Select Vehicle", 'maintenance_vch_id', array('class' => 'required')); ?>
<?php
echo form_dropdown(array(
'name' => 'maintenance_vch_id',
'id' => 'maintenance_vch_id',
'class' => 'form-control input-sm'), $suspence_vech);
?>
</div>
<div class="form-group">
<?php echo form_label("Maintenance Type", 'maintenance_type', array('class' => 'required')); ?>
<?php
$maintenance_type = array('' => '--Select Maintenance Type--','1' => 'Break Down','2' => 'General Service');
echo form_dropdown(array(
'name' => 'maintenance_type',
'id' => 'maintenance_type',
'class' => 'form-control input-sm'), $maintenance_type);
?>
</div>
<div class="form-group">
<textarea placeholder="Service Remarks" name="service_remarks" id="service_remarks" class="form-control" rows="4" ></textarea>
</div>
<?php
echo form_input(array('type'=>'hidden','name'=>'maintenance_op_id','id'=>'maintenance_op_id','value'=>$booking_info->operation_id));
echo form_input(array('type'=>'hidden','name'=>'maintenance_id','id'=>'maintenance_id','value'=>''));
?>
<button type='submit' class='btn btn-primary btn-sm' style='background:#d84f57;border:1px solid #d84f57;padding:6px 30px;margin-top:-7px;' id='catering_add'>Add / Update</button>
<?php echo form_close(); ?>
<div style='background-color: #EEEEEE; padding: 4px; overflow: auto;'>
<h5 style='color:#d84f57;'>Maintenance Information</h5>
<table class="table table-hover table-striped table-bordered" id='diesel_table'>
<thead>
<tr>
<th>Date</th>
<th>Vehicle</th>
<th>Type</th>
<th>Service Information</th>
<th>Edit</th>
</tr>
</thead>
<tbody id="maintenance_list">
<?php
foreach($maintenance_list as $maintenance){
$maintenance_id = $maintenance->maintenance_id;
$maintenance_date = date("d-m-Y", strtotime($maintenance->maintenance_date));
$main_vehicle_no = $maintenance->vehicle_no;
$maintenance_type = $maintenance->maintenance_type;
$service_remarks = $maintenance->service_remarks;
if($maintenance_type === "1"){
$maintenance_type = "Break Down";
if($assiged_count > 0){
$assiged_count = $assiged_count - 1;
}
}else
if($maintenance_type === "2"){
$maintenance_type = "General Service";
}
echo "<tr>
<td>$maintenance_date</td>
<td>$main_vehicle_no</td>
<td>$maintenance_type</td>
<td>$service_remarks</td>
<td><a style='cursor: pointer;' onclick=get_maintenance('$maintenance_id')>Edit</a></td>
</tr>";
}
echo form_input( array( 'name'=>'assiged_bus_count', 'id'=>'assiged_bus_count', 'type'=>'Hidden','value'=>$assiged_count));
?>
</tbody>
</table>
</div>
</div>
</div>
<div class="tab-pane fade" id="extra_km">
<div class="col-md-12" style='padding:8px;margin-bottom:4px;'>
<?php echo form_open('operation/save_extra_km/',array('id'=>'save_extra_km','class'=>'form-inline')); ?>
<div class="form-group" style='width:13.5%;'>
<?php echo form_label("Select Vehicle", 'extra_vch_id', array('class' => 'required')); ?>
<?php
echo form_dropdown(array(
'name' => 'extra_vch_id',
'id' => 'extra_vch_id',
'class' => 'form-control input-sm'), $suspence_vech);
?>
</div>
<div class="form-group" style='width:13.5%;'>
<?php echo form_label("Hire charges", 'hire_charges', array('class' => 'control-label')); ?>
<?php
echo form_input(array(
'name' => 'hire_charges',
'id' => 'hire_charges',
'class' => 'form-control input-sm number',
'value' =>'0')
);
?>
</div>
<div class="form-group" style='width:13.5%;'>
<?php echo form_label("Start KM", 'trip_start_km', array('class' => 'control-label')); ?>
<?php
echo form_input(array(
'name' => 'trip_start_km',
'id' => 'trip_start_km',
'class' => 'form-control input-sm number',
'value' =>'0')
);
?>
</div>
<div class="form-group" style='width:13.5%;'>
<?php echo form_label("End KM", 'trip_end_km', array('class' => 'control-label')); ?>
<?php
echo form_input(array(
'name' => 'trip_end_km',
'id' => 'trip_end_km',
'class' => 'form-control input-sm number',
'value' =>'0')
);
?>
</div>
<div class="form-group" style='width:13.5%;'>
<?php echo form_label("Total KM", 'trip_end_km', array('class' => 'control-label')); ?>
<?php
echo form_input(array(
'name' => 'trip_tot_km',
'id' => 'trip_tot_km',
'class' => 'form-control input-sm number',
'value' =>'0',
'readonly'=>'true')
);
?>
</div>
<div class="form-group" style='width:13.5%;'>
<?php echo form_label("Extra KM", 'op_extra_km', array('class' => 'control-label')); ?>
<?php
echo form_input(array(
'name' => 'op_extra_km',
'id' => 'op_extra_km',
'class' => 'form-control input-sm number',
'value' =>'0')
);
?>
</div>
<div class="form-group" style='width:13.5%;'>
<?php echo form_label("Per KM Amount", 'op_extra_pre_km', array('class' => 'control-label')); ?>
<?php
echo form_input(array(
'name' => 'op_extra_pre_km',
'id' => 'op_extra_pre_km',
'class' => 'form-control input-sm number',
'value' =>'0')
);
?>
</div>
<div class="form-group" style='width:13.5%;'>
<?php echo form_label("Extra Amount", 'op_extra_amt', array('class' => 'control-label')); ?>
<?php
echo form_input(array(
'name' => 'op_extra_amt',
'id' => 'op_extra_amt',
'class' => 'form-control input-sm number',
'value' =>'0')
);
?>
</div>
<?php
echo form_input(array('type'=>'hidden','name'=>'extra_avg_km','id'=>'extra_avg_km','value'=>$booking_info->avg_km));
echo form_input(array('type'=>'hidden','name'=>'extra_op_id','id'=>'extra_op_id','value'=>$booking_info->operation_id));
echo form_input(array('type'=>'hidden','name'=>'extra_booking_id','id'=>'extra_booking_id','value'=>$booking_info->booking_id));
?>
<button type='submit' class='btn btn-primary btn-sm' style='background:#d84f57;border:1px solid #d84f57;padding:6px 30px;margin-top:-7px;' id='catering_add'>Add / Update</button>
<?php echo form_close(); echo "Coverage KM for this trip = ".$booking_info->avg_km; echo "Extra per km cost for this trip =";?>
<div style='background-color: #EEEEEE; padding: 4px; overflow: auto;'>
<table class="table table-hover table-striped table-bordered">
<thead>
<tr>
<th>Vehicle</th>
<th>Hire Charges</th>
<th>Start KM</th>
<th>End KM</th>
<th>Total KM</th>
<th>Extra KM</th>
<th>Per KM Amount</th>
<th>Total Amount</th>
<th>Edit</th>
</tr>
</thead>
<tbody id='op_line_extra_list'>
<?php
foreach($op_line_list as $list){
$op_line_id = $list->op_line_id;
$vehicle_no = $list->vehicle_no;
$hire_charges = $list->hire_charges;
$trip_start_km = $list->trip_start_km;
$trip_end_km = $list->trip_end_km;
$op_extra_km = $list->op_extra_km;
$op_extra_pre_km = $list->op_extra_pre_km;
$op_extra_amt = $list->op_extra_amt;
$trip_tot_km = (int)$trip_end_km - (int)$trip_start_km;
echo "<tr>
<td>$vehicle_no </td>
<td>$hire_charges </td>
<td>$trip_start_km </td>
<td>$trip_end_km </td>
<td>$trip_tot_km </td>
<td>$op_extra_km </td>
<td>$op_extra_pre_km </td>
<td>$op_extra_amt</td>
<td><a style='cursor: pointer;' onclick=edit_extra_line('$op_line_id')>Edit</a></td>
</tr>";
}
?>
</tbody>
</table>
</div>
</div>
</div>
<div class="tab-pane fade" id="feed_back">
<div class="col-md-12" style='padding:8px;margin-bottom:4px;'>
<div style='background-color: #EEEEEE; padding: 4px; overflow: auto;'>
<h5 style='color:#d84f57;'>Feedback Information</h5>
<table class="table table-hover table-striped table-bordered" id='diesel_table'>
<thead>
<tr>
<th>vehicle#</th>
<th>vehicle Quality</th>
<th>TV & DVD</th>
<th>Seat</th>
<th>Driving Skills</th>
<th>Behaviour</th>
<th>Sightseeing</th>
</tr>
</thead>
<tbody>
<?php
foreach($feedback_list as $feedback){
$vehicle_no = $feedback->vehicle_no;
$vch_quality = str_replace("_"," ",$feedback->vch_quality);
$vch_media = str_replace("_"," ",$feedback->vch_media);
$vch_seat = str_replace("_"," ",$feedback->vch_seat);
$driving_skill = str_replace("_"," ",$feedback->driving_skill);
$driver_behaviour = str_replace("_"," ",$feedback->driver_behaviour);
$sightseeing = str_replace("_"," ",$feedback->sightseeing);
echo "<tr>
<td>$vehicle_no</td>
<td>$vch_quality</td>
<td>$vch_media</td>
<td>$vch_seat</td>
<td>$driving_skill</td>
<td>$driver_behaviour</td>
<td>$sightseeing</td>
</tr>";
}
?>
</tbody>
</table>
</div>
</div>
</div>
<div class="tab-pane fade" id="trip_summary">
<div class="col-md-12" style='padding:8px;margin-bottom:4px;'>
<div style='background-color: #EEEEEE; padding: 4px; overflow: auto;'>
<h5 style='color:#d84f57;'>Trip Summary</h5>
<table class="table table-hover table-striped table-bordered" id='diesel_table'>
<thead>
<tr>
<th>vehicle#</th>
<th>Driver Name</th>
<th>Driver Suspense</th>
<th>Diesel</th>
<th>Toll</th>
<th>Parking</th>
<th>Kickbacks</th>
<th>Permit</th>
<th>RTO</th>
<th>TAX</th>
<th>Driver</th>
<th>Cleaner</th>
<th>Others</th>
<th>Total Expense</th>
<th>Received</th>
<th>Balance</th>
</tr>
</thead>
<tbody>
<?php
foreach($trip_summary as $trip){
$vehicle_no = $trip['vehicle_no'];
$op_driver_name = $trip['op_driver_name'];
$op_suspence_amt = $trip['op_suspence_amt'];
$diesel_amt = $trip['diesel_amt'];
$toll = $trip['toll'];
$parking = $trip['parking'];
$kickbacks = $trip['kickbacks'];
$permit = $trip['permit'];
$others = $trip['others'];
$rto = $trip['rto'];
$tax = $trip['tax'];
$driver = $trip['driver'];
$cleaner = $trip['cleaner'];
$received = $trip['balance_received'];
$expence = (int)$diesel_amt + (int)$toll + (int)$parking + (int)$kickbacks + (int)$permit + (int)$others + (int)$rto + (int)$tax + (int)$driver + (int)$cleaner;
$balance = (int)$op_suspence_amt - ((int)$expence + (int)$received);
$tot_sup += $op_suspence_amt;
$total_diesel += $diesel_amt;
$tot_toll += $toll;
$tot_parking += $parking;
$tot_kickbacks += $kickbacks;
$tot_permit += $permit;
$tot_rto += $rto;
$tot_tax += $tax;
$tot_driver += $driver;
$tot_cleaner += $cleaner;
$tot_others += $others;
$tot_expence += $expence;
$tot_received += $received;
$tot_balance += $balance;
echo "<tr>
<td>$vehicle_no</td>
<td>$op_driver_name</td>
<td>$op_suspence_amt</td>
<td>$diesel_amt</td>
<td>$toll</td>
<td>$parking</td>
<td>$kickbacks</td>
<td>$permit</td>
<td>$rto</td>
<td>$tax</td>
<td>$driver</td>
<td>$cleaner</td>
<td>$others</td>
<td>$expence</td>
<td>$received</td>
<td>$balance</td>
</tr>";
}
echo "<tr style='font-weight:bold;'>
<td colspan='2' style='text-align:center;'>Total</td>
<td>$tot_sup</td>
<td>$total_diesel</td>
<td>$tot_toll</td>
<td>$tot_parking</td>
<td>$tot_kickbacks</td>
<td>$tot_permit</td>
<td>$tot_rto</td>
<td>$tot_tax</td>
<td>$tot_driver</td>
<td>$tot_cleaner</td>
<td>$tot_others</td>
<td>$tot_expence</td>
<td>$tot_received</td>
<td>$tot_balance</td>
</tr>";
echo form_input(array('type'=>'hidden','name'=>'trip_tot_balance','id'=>'trip_tot_balance','value'=>$tot_balance));
?>
</tbody>
</table>
</div>
</div>
</div>
</div>
<script type="text/javascript">
function is_vechicle_assigned(){
vehicle_type = $("#vehicle_type").val();
if(vehicle_type === ""){
return false;
}else{
assiged_bus_count = $("#assiged_bus_count").val();
bus_count = $("#bus_count").val();
if(parseInt(bus_count) > parseInt(assiged_bus_count)){
return;
}else{
alert("All vechicle assigned");
$("#operation_btn").hide();
return false;
}
}
}
$(document).ready(function(){
var is_vehicle_valid = false;
var tp_url = '<?php echo $tp_url;?>';
var op_url = '<?php echo $op_url;?>';
$(function () {
$(".datepicker").datetimepicker({
format: 'DD-MM-YYYY'
});
});
//extra_km,extra_pre_km
$("#trip_start_km,#trip_end_km,#op_extra_km,#op_extra_pre_km,#op_extra_amt").keyup(function(e) {
op_extra_km = $("#op_extra_km").val();
op_extra_pre_km = $("#op_extra_pre_km").val();
trip_start_km = $("#trip_start_km").val();
trip_end_km = $("#trip_end_km").val();
//trip_start_km,trip_end_km,trip_tot_km
var extra_amt = 0;
if(parseInt(op_extra_pre_km) > 0){
extra_amt = parseInt(op_extra_km) * parseInt(op_extra_pre_km);
}
var trip_tot_km = 0;
if((parseInt(trip_start_km) > 0) && (parseInt(trip_end_km) > 0)){
trip_tot_km = parseInt(trip_end_km) - parseInt(trip_start_km);
}
$("#op_extra_amt").val(extra_amt);
$("#trip_tot_km").val(trip_tot_km);
});
$("#operation_sts").change(function() {
var operation_id = $("#operation_id").val();
var booking_id = $("#booking_id").val();
var mobile = $("#mobile").val();
var trip_tot_balance = $("#trip_tot_balance").val();
if(trip_tot_balance > 0){
alert("Suspense not clearted yet");
return false;
}else{
if(this.checked) {
mode = "CHK";
$.ajax({
type: "POST",
url: '<?php echo site_url($controller_name . "/update_sts"); ?>',
data: {mode:mode,operation_id:operation_id,booking_id:booking_id,mobile:mobile},
success: function(data) {
alert("Update to completed status");
},
});
}else{
mode = "UNCHK";
$.ajax({
type: "POST",
url: '<?php echo site_url($controller_name . "/update_sts"); ?>',
data: {mode:mode,operation_id:operation_id,booking_id:booking_id},
success: function(data) {
alert("Reverted complted status");
},
});
}
}
});
$(".number").bind('keyup', function(e) {
this.value = this.value.replace(/[^0-9_.]/g,'');
});
$("#vehicle_type").on('change',function(){
var vehicle_type = $("#vehicle_type").val();
if(vehicle_type !== ""){
get_vehicle_list(vehicle_type);
}
});
$("#vehicle_id").on('change',function(){
var vehicle_id = $("#vehicle_id").val();
if(vehicle_id !== ""){
get_vehicle_infromation(vehicle_id);
}
});
$("#cleaner_id").on('change',function(){
var cleaner_id = $("#cleaner_id").val();
if(cleaner_id !== ""){
$.ajax({
type: "POST",
url: '<?php echo site_url($controller_name . "/get_cleaner_info"); ?>',
data: {cleaner_id:cleaner_id},
success: function(data) {
var rslt = JSON.parse(data);
cleaner_id = rslt.cleaner_id;
cleaner_name = rslt.first_name;
cleaner_number = rslt.phone_number;
$("#cleaner_id").val(cleaner_id);
$("#cleaner_name").val(cleaner_name);
$("#cleaner_number").val(cleaner_number);
},
});
}
});
$("#driver_id").on('change',function(){
var driver_id = $("#driver_id").val();
if(driver_id === ""){
alert("Please select driver");
return false;
}else
if(driver_id === "0"){
$("#driver_name").val("");
$("#driver_number").val("");
return false;
}else{
second_driver_id = $("#second_driver_id").val();
if(driver_id === second_driver_id){
alert("Please select different drivers");
return false;
}
check_driver_expiry(driver_id);
}
});
$("#second_driver_id").on('change',function(){
var second_driver_id = $("#second_driver_id").val();
if(second_driver_id === ""){
alert("Please select driver");
return false;
}else
if(second_driver_id === "0"){
$("#second_driver_name").val("");
$("#second_driver_number").val("");
return false;
}else{
driver_id = $("#driver_id").val();
if(driver_id === second_driver_id){
alert("Please select different drivers");
return false;
}
second_driver_expiry(second_driver_id);
}
});
$('#operation_form').validate($.extend({
submitHandler: function (form){
$('#operation_form').attr('disabled','disabled');
$(form).ajaxSubmit({
success: function(rslt){
var tr = "";
count = 0;
for(i = 0; i < rslt.op_line.length; i++) {
count++;
op_line_id = rslt.op_line[i].op_line_id;
operation_id = rslt.op_line[i].operation_id;
op_vehicle_type = rslt.op_line[i].op_vehicle_type;
veh_type = rslt.op_line[i].veh_type;
op_vehicle_id = rslt.op_line[i].op_vehicle_id;
vehicle_no = rslt.op_line[i].vehicle_no;
op_driver_id = rslt.op_line[i].op_driver_id;
op_driver_name = rslt.op_line[i].op_driver_name;
op_driver_number = rslt.op_line[i].op_driver_number;
second_driver_id = rslt.op_line[i].second_driver_id;
second_driver_name = rslt.op_line[i].second_driver_name;
second_driver_number = rslt.op_line[i].second_driver_number;
op_chk_list = rslt.op_line[i].op_chk_list;
op_suspence_amt = rslt.op_line[i].op_suspence_amt;
remarks = rslt.op_line[i].remarks;
red_alert = rslt.op_line[i].red_alert;
tp_info = rslt.op_line[i].tp_info;
cust_rout_info = rslt.op_line[i].cust_rout_info;
op_chk_list = op_chk_list.replace("_", " ");
tp_url_line = tp_url+op_line_id;
op_url_line = op_url+op_line_id;
edit = "<a style='cursor: pointer;' onclick=edit_op_line('"+op_line_id+"')>Edit</a>";
tp = "<a href='"+tp_url_line+"' style='cursor: pointer;'>Print TP</a>";
print = "<a href='"+op_url_line+"' style='cursor: pointer;'><i class='fa fa-print fa-lg'></i> Print</a>";
remove = "<a style='cursor: pointer;' onclick=remove_op_line('"+op_line_id+"')>Remove</a>";
tr += "<tr><td>"+veh_type+"</td><td>"+vehicle_no+"</td><td>"+op_driver_name+"</td><td>"+op_driver_number+"</td><td>"+op_suspence_amt+"</td><td>"+op_chk_list+"</td><td>"+remarks+"</td><td style='color:red;'>"+red_alert+"</td><td>"+edit+"</td><td>"+tp+"</td><td>"+print+"</td><td>"+remove+"</td></tr>";
}
tr += "<input value='"+count+"' name='assiged_bus_count' id='assiged_bus_count' type='hidden'>";
$("#op_line_list").html(tr);
check_avilability();
$("#vehicle_type").val("");
$("#vehicle_id").val("");
$("#driver_id").val("");
$("#driver_name").val("");
$("#driver_number").val("");
$("#suspence_amt").val("");
$("#second_driver_id").val("");
$("#second_driver_name").val("");
$("#second_driver_number").val("");
$("#chk_list").val("");
$("#remarks").val("");
$("#tp_info").val("");
$("#cust_rout_info").val("");
},
dataType: 'json'
});
},
rules:{
vehicle_type: {
required: function(el) {
is_vechicle_assigned();
}
},
vehicle_id: "required",
driver_id: "required",
driver_name: "required",
driver_number: "required",
suspence_amt: "required",
chk_list: "required",
//remarks: "required",
tp_info: "required",
cust_rout_info: "required",
}
}));
$('#save_driver_suspence').validate($.extend({
submitHandler: function (form){
$('#save_driver_suspence').attr('disabled','disabled');
$(form).ajaxSubmit({
success: function(rslt){
var tr = "";
amt_tot = 0;
for(i = 0; i < rslt.driver_suspence_list.length; i++) {
driver_suspence_id = rslt.driver_suspence_list[i].driver_suspence_id;
vehicle_no = rslt.driver_suspence_list[i].vehicle_no;
driver_suspence_date = rslt.driver_suspence_list[i].driver_suspence_date;
driver_suspence_vch_id = rslt.driver_suspence_list[i].driver_suspence_vch_id;
driver_suspence_amount = rslt.driver_suspence_list[i].driver_suspence_amount;
driver_suspence_date = moment(driver_suspence_date).format('DD-MM-YYYY');
amt_tot += parseInt(driver_suspence_amount);
edit = "<a style='cursor: pointer;' onclick=get_driver_suspence('"+driver_suspence_id+"')>Edit</a>";
tr += "<tr><td>"+driver_suspence_date+"</td><td>"+vehicle_no+"</td><td>"+driver_suspence_amount+"</td><td>"+edit+"</td></tr>";
}
tr +="<tr><td colspan='2' style='font-weight:bold;'>Total Amount</td><td colspan='2' style='font-weight:bold;'>"+amt_tot+"</td></tr>";
$("#driver_suspence_list_tb").html(tr);
$("#driver_suspence_list_tb").html(tr);
$("#driver_suspence_id").val("");
$("#driver_suspence_date").val("");
$("#driver_suspence_vch_id").val("");
$("#driver_suspence_amount").val("");
$("#driver_suspence_date").val("");
},
dataType: 'json'
});
},
rules:{
driver_suspence_date: "required",
driver_suspence_vch_id: "required",
driver_suspence_amount: "required",
}
}));
$('#save_suspence').validate($.extend({
submitHandler: function (form){
$('#save_suspence').attr('disabled','disabled');
$(form).ajaxSubmit({
success: function(rslt){
var tr = "";
for(i = 0; i < rslt.suspence_list.length; i++) {
suspence_id = rslt.suspence_list[i].suspence_id;
suspence_date = rslt.suspence_list[i].suspence_date;
vehicle_no = rslt.suspence_list[i].vehicle_no;
suspence_vch_id = rslt.suspence_list[i].suspence_vch_id;
suspence_info = rslt.suspence_list[i].suspence_info;
suspence_amt = rslt.suspence_list[i].suspence_amt;
suspence_date = moment(suspence_date).format('DD-MM-YYYY');
edit = "<a style='cursor: pointer;' onclick=get_suspence('"+suspence_id+"')>Edit</a>";
tr += "<tr><td>"+suspence_date+"</td><td>"+vehicle_no+"</td><td>"+suspence_info+"</td><td>"+suspence_amt+"</td><td>"+edit+"</td></tr>";
}
amount = rslt.amount.suspence_amount;
tr +="<tr><td colspan='3' style='font-weight:bold;'>Total Amount</td><td colspan='2' style='font-weight:bold;'>"+amount+"</td></tr>";
$("#suspence_list").html(tr);
var sup_tr_sub = "";
var sup_amt_tot = 0;
for(i = 0; i < rslt.suspence_subtotal.length; i++) {
sup_vehicle_no = rslt.suspence_subtotal[i].vehicle_no;
sup_amt = rslt.suspence_subtotal[i].amt;
sup_amt_tot += parseInt(sup_amt);
sup_tr_sub += "<tr><td>"+sup_vehicle_no+"</td><td>"+sup_amt+"</td></tr>";
}
sup_tr_sub += "<tr><td>Total Amount</td><td>"+sup_amt_tot+"</td></tr>";
$("#suspence_sub_list").html(sup_tr_sub);
$("#suspence_id").val("");
$("#suspence_date").val("");
$("#suspence_vch_id").val("");
$("#suspence_info").val("");
$("#suspence_amount").val("");
},
dataType: 'json'
});
},
rules:{
suspence_date: "required",
suspence_vch_id: "required",
suspence_info: "required",
suspence_amount: "required",
}
}));
$('#save_diesel').validate($.extend({
submitHandler: function (form){
$('#save_diesel').attr('disabled','disabled');
$(form).ajaxSubmit({
success: function(rslt){
var tr = "";
for(i = 0; i < rslt.diesel_list.length; i++) {
diesel_id = rslt.diesel_list[i].diesel_id;
diesel_vch_id = rslt.diesel_list[i].diesel_vch_id;
diesel_date = rslt.diesel_list[i].diesel_date;
vehicle_no = rslt.diesel_list[i].vehicle_no;
start_km = rslt.diesel_list[i].start_km;
end_km = rslt.diesel_list[i].end_km;
diesel_quantity = rslt.diesel_list[i].diesel_quantity;
diesel_amt = rslt.diesel_list[i].diesel_amt;
actual_km = rslt.diesel_list[i].actual_km;
avg_km = rslt.diesel_list[i].avg_km;
diesel_op_id = rslt.diesel_list[i].diesel_op_id;
diesel_date = moment(diesel_date).format('DD-MM-YYYY');
edit = "<a style='cursor: pointer;' onclick=get_diesel('"+diesel_id+"')>Edit</a>";
tr += "<tr><td>"+diesel_date+"</td><td>"+vehicle_no+"</td><td>"+start_km+"</td><td>"+end_km+"</td><td>"+diesel_quantity+"</td><td>"+diesel_amt+"</td><td>"+actual_km+"</td><td>"+avg_km+"</td><td>"+edit+"</td></tr>";
}
amount = rslt.amount.diesel_amount;
tr +="<tr><td colspan='5' style='font-weight:bold;'>Total Amount</td><td colspan='4' style='font-weight:bold;'>"+amount+"</td></tr>";
$("#diesel_list").html(tr);
var tr_sub = "";
var die_amt_tot = 0;
for(i = 0; i < rslt.diesel_subtotal.length; i++) {
vehicle_no = rslt.diesel_subtotal[i].vehicle_no;
die_amt = rslt.diesel_subtotal[i].amt;
die_amt_tot += parseInt(die_amt);
tr_sub += "<tr><td>"+vehicle_no+"</td><td>"+die_amt+"</td></tr>";
}
tr_sub += "<tr><td>Total Amount</td><td>"+die_amt_tot+"</td></tr>";
$("#diesel_sub_list").html(tr_sub);
$("#diesel_id").val("");
$("#diesel_vch_id").val("");
$("#diesel_date").val("");
$("#start_km").val("");
$("#end_km").val("");
$("#diesel_quantity").val("");
$("#diesel_amt").val("");
},
dataType: 'json'
});
},
rules:{
diesel_date: "required",
diesel_vch_id: "required",
start_km: "required",
end_km: "required",
diesel_quantity: "required",
diesel_amt: "required",
}
}));
$('#save_maintenance').validate($.extend({
submitHandler: function (form){
$('#save_maintenance').attr('disabled','disabled');
$(form).ajaxSubmit({
success: function(rslt){
var tr = "";
var type = "";
for(i = 0; i < rslt.maintenance_list.length; i++) {
maintenance_id = rslt.maintenance_list[i].maintenance_id;
maintenance_date = rslt.maintenance_list[i].maintenance_date;
vehicle_no = rslt.maintenance_list[i].vehicle_no;
service_remarks = rslt.maintenance_list[i].service_remarks;
maintenance_type = rslt.maintenance_list[i].maintenance_type;
if(maintenance_type === "1"){
type = "Break Down";
}else
if(maintenance_type === "2"){
type = "General Service";
}
maintenance_date = moment(maintenance_date).format('DD-MM-YYYY');
edit = "<a style='cursor: pointer;' onclick=get_maintenance('"+maintenance_id+"')>Edit</a>";
tr += "<tr><td>"+maintenance_date+"</td><td>"+vehicle_no+"</td><td>"+type+"</td><td>"+service_remarks+"</td><td>"+edit+"</td></tr>";
}
$("#maintenance_list").html(tr);
$("#maintenance_date").val("");
$("#maintenance_vch_id").val("");
$("#service_remarks").val("");
$("#maintenance_type").val("");
},
dataType: 'json'
});
},
rules:{
maintenance_date: "required",
maintenance_vch_id: "required",
service_remarks: "required",
maintenance_type: "required",
}
}));
$('#save_extra_km').validate($.extend({
submitHandler: function (form){
$('#save_extra_km').attr('disabled','disabled');
$(form).ajaxSubmit({
success: function(rslt){
alert("Success");
var tr = "";
for(i = 0; i < rslt.op_line_list.length; i++) {
op_line_id = rslt.op_line_list[i].op_line_id;
vehicle_no = rslt.op_line_list[i].vehicle_no;
hire_charges = rslt.op_line_list[i].hire_charges;
trip_start_km = rslt.op_line_list[i].trip_start_km;
trip_end_km = rslt.op_line_list[i].trip_end_km;
op_extra_km = rslt.op_line_list[i].op_extra_km;
op_extra_pre_km = rslt.op_line_list[i].op_extra_pre_km;
op_extra_amt = rslt.op_line_list[i].op_extra_amt;
var trip_tot_km = 0;
if((parseInt(trip_start_km) > 0) && (parseInt(trip_end_km) > 0)){
trip_tot_km = parseInt(trip_end_km) - parseInt(trip_start_km);
}
edit = "<a style='cursor: pointer;' onclick=edit_extra_line('"+op_line_id+"')>Edit</a>";
tr += "<tr><td>"+vehicle_no+"</td><td>"+hire_charges+"</td><td>"+trip_start_km+"</td><td>"+trip_end_km+"</td><td>"+trip_tot_km+"</td><td>"+op_extra_km+"</td><td>"+op_extra_pre_km+"</td><td>"+op_extra_amt+"</td><td>"+edit+"</td></tr>";
}
$("#op_line_extra_list").html(tr);
$("#hire_charges").val("");
$("#extra_vch_id").val("");
$("#trip_start_km").val("");
$("#trip_end_km").val("");
$("#trip_tot_km").val("");
$("#op_extra_km").val("");
$("#op_extra_pre_km").val("");
$("#op_extra_amt").val("");
},
dataType: 'json'
});
},
rules:{
extra_vch_id: "required",
hire_charges: "required",
trip_start_km: "required",
trip_end_km: "required",
op_extra_km: "required",
op_extra_pre_km: "required",
op_extra_amt: "required",
}
}));
// UDY -:- textarea Stop Submit for shif enter
$('textarea').keyup(function (event) {
if (event.keyCode == 13) {
var content = this.value;
var caret = getCaret(this);
if(event.shiftKey){
this.value = content.substring(0, caret - 1) + "\n" + content.substring(caret, content.length);
event.stopPropagation();
}
}
});
});
function getCaret(el) {
if (el.selectionStart) {
return el.selectionStart;
} else if (document.selection) {
el.focus();
var r = document.selection.createRange();
if (r == null) {
return 0;
}
var re = el.createTextRange(), rc = re.duplicate();
re.moveToBookmark(r.getBookmark());
rc.setEndPoint('EndToStart', re);
return rc.text.length;
}
return 0;
}
function edit_extra_line(op_line_id){
if(op_line_id !== ""){
$.ajax({
type: "POST",
url: '<?php echo site_url($controller_name . "/get_op_line"); ?>',
data: {op_line_id:op_line_id},
success: function(data){
var rslt = JSON.parse(data);
op_vehicle_id = rslt.op_line.op_vehicle_id;
hire_charges = rslt.op_line.hire_charges;
trip_start_km = rslt.op_line.trip_start_km;
trip_end_km = rslt.op_line.trip_end_km;
op_extra_km = rslt.op_line.op_extra_km;
op_extra_pre_km = rslt.op_line.op_extra_pre_km;
op_extra_amt = rslt.op_line.op_extra_amt;
var trip_tot_km = 0;
if((parseInt(trip_start_km) > 0) && (parseInt(trip_end_km) > 0)){
trip_tot_km = parseInt(trip_end_km) - parseInt(trip_start_km);
}
$("#extra_vch_id").val(op_vehicle_id);
$("#hire_charges").val(hire_charges);
$("#trip_start_km").val(trip_start_km);
$("#trip_end_km").val(trip_end_km);
$("#trip_tot_km").val(trip_tot_km);
$("#op_extra_km").val(op_extra_km);
$("#op_extra_pre_km").val(op_extra_pre_km);
$("#op_extra_amt").val(op_extra_amt);
},
});
}
}
function remove_op_line(op_line_id){
if(op_line_id !== ""){
$.confirm({
content: 'Are you sure you want to remove this vechicle?',
escapeKey: 'Yes',
buttons: {
Yes: function(){
$.ajax({
type: "POST",
url: '<?php echo site_url($controller_name . "/remove_op_line"); ?>',
data: {op_line_id:op_line_id},
success: function(data) {
alert("Removed Success");
$(function () {
$('.modal').modal('toggle');
});
},
});
},
close: function(){
}
}
});
//if(confirm('Are you sure you need to remove this vechicle???')) {
//}
}
}
function edit_op_line(op_line_id){
if(op_line_id !== ""){
assiged_count = $("#assiged_bus_count").val();
if(parseInt(assiged_count) > 0){
assiged_count = assiged_count - 1;
$("#assiged_bus_count").val(assiged_count);
}
$.ajax({
type: "POST",
url: '<?php echo site_url($controller_name . "/get_op_line"); ?>',
data: {op_line_id:op_line_id},
success: function(data) {
var rslt = JSON.parse(data);
op_vehicle_type = rslt.op_line.op_vehicle_type;
op_vehicle_id = rslt.op_line.op_vehicle_id;
op_driver_id = rslt.op_line.op_driver_id;
op_driver_name = rslt.op_line.op_driver_name;
op_driver_number = rslt.op_line.op_driver_number;
op_suspence_amt = rslt.op_line.op_suspence_amt;
second_driver_id = rslt.op_line.second_driver_id;
second_driver_name = rslt.op_line.second_driver_name;
second_driver_number = rslt.op_line.second_driver_number;
op_chk_list = rslt.op_line.op_chk_list;
remarks = rslt.op_line.remarks;
tp_info = rslt.op_line.tp_info;
cust_rout_info = rslt.op_line.cust_rout_info;
$("#vehicle_type").val(op_vehicle_type);
$("#vehicle_id").val(op_vehicle_id);
$("#driver_id").val(op_driver_id);
$("#driver_name").val(op_driver_name);
$("#driver_number").val(op_driver_number);
$("#suspence_amt").val(op_suspence_amt);
$("#second_driver_id").val(second_driver_id);
$("#second_driver_name").val(second_driver_name);
$("#second_driver_number").val(second_driver_number);
$("#chk_list").val(op_chk_list);
$("#remarks").val(remarks);
$("#tp_info").val(tp_info);
$("#cust_rout_info").val(cust_rout_info);
check_avilability();
},
});
}
}
function get_driver_suspence(driver_suspence_id){
if(suspence_id !== ""){
$.ajax({
type: "POST",
url: '<?php echo site_url($controller_name . "/get_driver_suspence"); ?>',
data: {driver_suspence_id:driver_suspence_id},
success: function(data) {
var rslt = JSON.parse(data);
driver_suspence_id = rslt.driver_suspence[0].driver_suspence_id;
driver_suspence_date = rslt.driver_suspence[0].driver_suspence_date;
driver_suspence_vch_id = rslt.driver_suspence[0].driver_suspence_vch_id;
driver_suspence_amount = rslt.driver_suspence[0].driver_suspence_amount;
driver_suspence_date = moment(driver_suspence_date).format('DD-MM-YYYY');
$("#driver_suspence_id").val(driver_suspence_id);
$("#driver_suspence_date").val(driver_suspence_date);
$("#driver_suspence_vch_id").val(driver_suspence_vch_id);
$("#driver_suspence_amount").val(driver_suspence_amount);
},
});
}
}
function get_suspence(suspence_id){
if(suspence_id !== ""){
$.ajax({
type: "POST",
url: '<?php echo site_url($controller_name . "/get_suspence"); ?>',
data: {suspence_id:suspence_id},
success: function(data) {
var rslt = JSON.parse(data);
suspence_id = rslt.sus_data[0].suspence_id;
suspence_date = rslt.sus_data[0].suspence_date;
suspence_vch_id = rslt.sus_data[0].suspence_vch_id;
suspence_info = rslt.sus_data[0].suspence_info;
suspence_amt = rslt.sus_data[0].suspence_amt;
suspence_date = moment(suspence_date).format('DD-MM-YYYY');
$("#suspence_id").val(suspence_id);
$("#suspence_date").val(suspence_date);
$("#suspence_vch_id").val(suspence_vch_id);
$("#suspence_info").val(suspence_info);
$("#suspence_amount").val(suspence_amt);
},
});
}
}
function get_diesel(diesel_id){
if(diesel_id !== ""){
$.ajax({
type: "POST",
url: '<?php echo site_url($controller_name . "/get_diesel"); ?>',
data: {diesel_id:diesel_id},
success: function(data) {
var rslt = JSON.parse(data);
diesel_id = rslt.diesel_data[0].diesel_id;
diesel_vch_id = rslt.diesel_data[0].diesel_vch_id;
diesel_date = rslt.diesel_data[0].diesel_date;
start_km = rslt.diesel_data[0].start_km;
end_km = rslt.diesel_data[0].end_km;
diesel_quantity = rslt.diesel_data[0].diesel_quantity;
diesel_amt = rslt.diesel_data[0].diesel_amt;
diesel_op_id = rslt.diesel_data[0].diesel_op_id;
diesel_date = moment(diesel_date).format('DD-MM-YYYY');
$("#diesel_id").val(diesel_id);
$("#diesel_vch_id").val(diesel_vch_id);
$("#diesel_date").val(diesel_date);
$("#start_km").val(start_km);
$("#end_km").val(end_km);
$("#diesel_quantity").val(diesel_quantity);
$("#diesel_amt").val(diesel_amt);
},
});
}
}
function get_maintenance(maintenance_id){
if(maintenance_id !== ""){
$.ajax({
type: "POST",
url: '<?php echo site_url($controller_name . "/get_maintenance"); ?>',
data: {maintenance_id:maintenance_id},
success: function(data) {
var rslt = JSON.parse(data);
maintenance_id = rslt.maintenance_data[0].maintenance_id;
maintenance_date = rslt.maintenance_data[0].maintenance_date;
vehicle_id = rslt.maintenance_data[0].vehicle_id;
maintenance_type = rslt.maintenance_data[0].maintenance_type;
service_remarks = rslt.maintenance_data[0].service_remarks;
maintenance_date = moment(maintenance_date).format('DD-MM-YYYY');
$("#maintenance_id").val(maintenance_id);
$("#maintenance_vch_id").val(vehicle_id);
$("#maintenance_date").val(maintenance_date);
$("#maintenance_type").val(maintenance_type);
$("#service_remarks").val(service_remarks);
},
});
}
}
function check_driver_expiry(driver_id){
if(!is_vehicle_valid){
alert("Invalid vehicle documents Please updated");
return false;
}
$('#vch_info tr:last').remove();
$.ajax({
type: "POST",
url: '<?php echo site_url($controller_name . "/check_driver_expiry"); ?>',
data: {driver_id:driver_id},
success: function(data) {
var rslt = JSON.parse(data);
var tr = "";
var canprocess = true;
for(i = 0; i < rslt.vehicle_data.length; i++) {
name = rslt.vehicle_data[i].name;
date = rslt.vehicle_data[i].date;
date = moment(date).format('DD-MM-YYYY');
sts = rslt.vehicle_data[i].sts;
clr = "";
if(sts === "Expired"){
clr = "style='color:red;'";
canprocess = false;
}
if(name === "Driving License"){
driver_id = rslt.vehicle_data[i].driver_id;
first_name = rslt.vehicle_data[i].first_name;
phone_number = rslt.vehicle_data[i].phone_number;
$("#driver_id").val(driver_id);
$("#driver_name").val(first_name);
$("#driver_number").val(phone_number);
}else
if(name === "TP"){
book_tp_info = $("#book_tp_info").val();
if(book_tp_info == "Yes"){
if(sts === "Expired"){
clr = "style='color:red;'";
if(owned_by === "1"){
canprocess = false;
}else{
if(canprocess){
canprocess = true;
}
}
}
}else{
if(canprocess){
canprocess = true;
}
}
}
tr += "<tr "+clr+"><td>"+name+"</td><td>"+date+"</td><td>"+sts+"</td></tr>";
}
$('#vch_info tr:last').after(tr);
if(canprocess){
$("#operation_btn").show();
}else{
$("#operation_btn").hide();
}
},
});
}
function second_driver_expiry(second_driver_id){
if(!is_vehicle_valid){
alert("Invalid vehicle documents Please updated");
return false;
}
$('#vch_info tr:last').remove();
$.ajax({
type: "POST",
url: '<?php echo site_url($controller_name . "/check_driver_expiry"); ?>',
data: {driver_id:second_driver_id},
success: function(data) {
var rslt = JSON.parse(data);
var tr = "";
var canprocess = true;
for(i = 0; i < rslt.vehicle_data.length; i++) {
name = rslt.vehicle_data[i].name;
date = rslt.vehicle_data[i].date;
date = moment(date).format('DD-MM-YYYY');
sts = rslt.vehicle_data[i].sts;
clr = "";
if(sts === "Expired"){
clr = "style='color:red;'";
canprocess = false;
}
if(name === "Driving License"){
driver_id = rslt.vehicle_data[i].driver_id;
first_name = rslt.vehicle_data[i].first_name;
phone_number = rslt.vehicle_data[i].phone_number;
$("#second_driver_id").val(driver_id);
$("#second_driver_name").val(first_name);
$("#second_driver_number").val(phone_number);
}else
if(name === "TP"){
book_tp_info = $("#book_tp_info").val();
if(book_tp_info == "Yes"){
if(sts === "Expired"){
clr = "style='color:red;'";
if(owned_by === "1"){
canprocess = false;
}else{
if(canprocess){
canprocess = true;
}
}
}
}else{
if(canprocess){
canprocess = true;
}
}
}
tr += "<tr "+clr+"><td>"+name+"</td><td>"+date+"</td><td>"+sts+"</td></tr>";
}
$('#vch_info tr:last').after(tr);
if(canprocess){
$("#operation_btn").show();
}else{
$("#operation_btn").hide();
}
},
});
}
function get_vehicle_infromation(vehicle_id){
$.ajax({
type: "POST",
url: '<?php echo site_url($controller_name . "/get_vehicle_infromation"); ?>',
data: {vehicle_id:vehicle_id},
success: function(data) {
var rslt = JSON.parse(data);
var tr = "";
var canprocess = true;
is_vehicle_valid = true;
for(i = 0; i < rslt.vehicle_data.length; i++) {
owned_by = rslt.vehicle_data[i].owned_by;
name = rslt.vehicle_data[i].name;
date = rslt.vehicle_data[i].date;
date = moment(date).format('DD-MM-YYYY');
sts = rslt.vehicle_data[i].sts;
clr = "";
if(sts === "Expired"){
clr = "style='color:red;'";
if(owned_by === "1"){
canprocess = false;
is_vehicle_valid = false;
}
}
if(name === "Driving License"){
driver_id = rslt.vehicle_data[i].driver_id;
first_name = rslt.vehicle_data[i].first_name;
phone_number = rslt.vehicle_data[i].phone_number;
$("#driver_id").val(driver_id);
$("#driver_name").val(first_name);
$("#driver_number").val(phone_number);
}else
if(name === "TP"){
book_tp_info = $("#book_tp_info").val();
if(book_tp_info == "Yes"){
if(sts === "Expired"){
clr = "style='color:red;'";
if(owned_by === "1"){
canprocess = false;
is_vehicle_valid = false;
}else{
if(canprocess){
canprocess = true;
is_vehicle_valid = true;
}
}
}
}else
if(book_tp_info == "No"){
canprocess = true;
is_vehicle_valid = true;
}
/*
{
if(canprocess){
canprocess = true;
is_vehicle_valid = true;
}
}
*/
}
tr += "<tr "+clr+"><td>"+name+"</td><td>"+date+"</td><td>"+sts+"</td></tr>";
}
$("#vch_info_list").html(tr);
if(canprocess){
check_avilability();
$("#operation_btn").show();
}else{
var expired = "<div style='color:#d84f57;margin-bottom:8px;'>Please update all Expired documents</div>";
$("#availability_chart").html(expired);
$("#operation_btn").hide();
}
},
});
}
function get_vehicle_list(vehicle_type){
$.ajax({
type: "POST",
url: '<?php echo site_url($controller_name . "/get_vehicle_list"); ?>',
data: {vehicle_type:vehicle_type},
success: function(data) {
var rslt = JSON.parse(data);
var option = "<option value=''>--Select Vehicle--</option>";
for(i = 0; i < rslt.vehicle_list.length; i++){
vehicle_id = rslt.vehicle_list[i].vehicle_id;
vehicle_no = rslt.vehicle_list[i].vehicle_no;
option += "<option value='"+vehicle_id+"'>"+vehicle_no+"</option>";
}
$("#vehicle_id").html(option);
},
});
}
function check_avilability(){
trip_type = $("#trip_type").val();
vehicle_type = $("#vehicle_type").val();
from_date = $("#from_date").val();
to_date = $("#to_date").val();
var get_cout = "1";
if((trip_type !== "")&&(vehicle_type !== "")&&(to_date !== "")&&(to_date !== "")){
$("#availability_chart").show();
var chart = "<div style='color:#d84f57;margin-bottom:8px;'><i class='fa fa-spinner fa-lg fa-spin'></i> Checking avilability please wait...</div>";
$("#availability_chart").html(chart);
$.ajax({
type: "POST",
url: '<?php echo site_url($controller_name . "/check_avilability"); ?>',
data: {trip_type:trip_type,vehicle_type:vehicle_type,from_date:from_date,to_date:to_date,get_cout:get_cout},
success: function(data){
$("#availability_chart").html(data);
},
});
}else{
alert("Please select Trip type , vechicle type , from and to date");
}
}
</script>
<style>
.modal-body{
/*padding:4px 10px;*/
padding:0px;
max-height: calc(100vh - 150px);
}
.form-inline .form-group {
width: 22.5%;
margin-bottom: 25px;
margin-right: 9px;
}
table-bordered>thead>tr>th, .table-bordered>thead>tr>th, table-bordered>tbody>tr>th, .table-bordered>tbody>tr>th, table-bordered>tfoot>tr>th, .table-bordered>tfoot>tr>th, table-bordered>thead>tr>td, .table-bordered>thead>tr>td, table-bordered>tbody>tr>td, .table-bordered>tbody>tr>td, table-bordered>tfoot>tr>td, .table-bordered>tfoot>tr>td {
border: 1px solid #CCCCCC;
}
table-bordered>thead>tr>th, .table-bordered>thead>tr>th, table-bordered>tbody>tr>th, .table-bordered>tbody>tr>th, table-bordered>tfoot>tr>th, .table-bordered>tfoot>tr>th {
border: 1px solid #CCCCCC;
background-color: #FFFFFF;
color: #b5454b;
white-space:nowrap !important;
}
table.table.table-hover.table-striped.table-bordered {
font-size: 11px !important;
margin-bottom: 0px;
}
</style>