File: /home/cafsindia/allyindian_com/backend/application/views/print_chart/view_chart_layout.php
<?php $this->load->view("partial/header");?>
<html>
<head>
<style type="text/css">
.modal-body{
overflow: auto;
}
.tbl td{
border: 1px solid black;
text-align: center;
line-height: 22px;
width: 5%;
height: 5%;
}
.tbl{
width: 100%;
}
.tbl_data{
border:none !important;
}
h5{
font-weight: bold;
}
.tab td:nth-child(odd){
font-weight: bold;
line-height: 40px;
}
</style>
</head>
<div style="padding: 10px;font-weight: bold;" id="note"></span></div>
<?php
foreach ($vehicle_data as $key => $value){
$vehicle_id = $value['vehicleid'];
$seat_type = $value['seat_type'];
$multi_type = $value['multi_type'];
$seat_capacity = $value['seat_capacity'];
//Upper seat data
$no_of_seats_up = $value['no_of_seats_up'];
$seats_per_row_up = $value['seats_per_row_up'];
$seats_in_last_row_up = $value['seats_in_last_row_up'];
//Lower seats data
$no_of_seats_low = $value['no_of_seats_low'];
$seats_per_row_low = $value['seats_per_row_low'];
$seats_in_last_row_low = $value['seats_in_last_row_low'];
$lower = $value['vehicle_lower'];
$upper = $value['vehicle_upper'];
$guruswamy_name = $value['guruswamy_name'];
$guruswamy_mobile = $value['guruswamy_mobile'];
$driver_name = $value['driver_name'];
$driver_mobile = $value['driver_mobile'];
$cleaner_name = $value['cleaner_name'];
$cleaner_mobile = $value['cleaner_mobile'];
$vehicle_no = $value['vehicle_no'];
}
if($multi_type === "1"){
//Lower
$low_nos = $no_of_seats_low;
$nospr_low = $seats_per_row_low;
$noslr_low = $seats_in_last_row_low;
$seatnocol_low = "";
$fseat_low = $low_nos - $noslr_low;
$totrows_low = $nospr_low+1;
$coldiv_low = ceil($fseat_low / $nospr_low);
$colms_low = $coldiv_low + 1;
$pathrow_low = ceil($nospr_low/2)+1;
if($nospr_low === $noslr_low){
$nocolumn_low = $colms_low * $nospr_low;
}else{
$nocolumn_low = ($colms_low * $nospr_low) + ($noslr_low - $nospr_low);
}
//Upper seats
$nos_up = $no_of_seats_up;
$nospr_up = $seats_per_row_up;
$noslr_up = $seats_in_last_row_up;
$seatnocol = "";
$fseat_up = $nos_up - $noslr_up;
$totrows_up = $nospr_up + 1;
$coldiv_up = ceil($fseat_up / $nospr_up);
$colms_up = $coldiv_up + 1;
$pathrow_up = ceil($nospr_up / 2)+1;
if($nospr_up == $noslr_up){
$nocolumn_up = $colms_up * $nospr_up;
}else{
$nocolumn_up = ($colms_up * $nospr_up) + ($noslr_up - $nospr_up);
}
//$style = "style='height:30px;width:120px;text-align: center;'";
//$style = "style='height:60;width:120;text-align: center;'";
}else
if($multi_type === "2"){
$low_nos = $no_of_seats_low;
$nospr_low = $seats_per_row_low;
$noslr_low = $seats_in_last_row_low;
$seatnocol_low = "";
$fseat_low = $low_nos - $noslr_low;
$totrows_low = $nospr_low+1;
$coldiv_low = ceil($fseat_low / $nospr_low);
$colms_low = $coldiv_low + 1;
$pathrow_low = ceil($nospr_low/2)+1;
if($nospr_low === $noslr_low){
$nocolumn = $colms_low * $nospr_low;
}else{
$nocolumn = ($colms_low * $nospr_low) + ($noslr_low - $nospr_low);
}
//$style = "style='height:60px;width:120px;text-align: center;'";
}
?>
<br />
<br />
<?php $sno = 1; if($multi_type === "2"){ ?>
<div class="row" id="page-content" style="margin: 25px;padding: 5px;margin-top: -45px;overflow: auto;">
<button style="margin-bottom: 8px;" id="print_layout" class="btn btn-info btn-sm">Print</button>
<table class="tbl tab">
<tbody>
<tr ><h4 align="center"><?php echo $package_name; ?></h4></tr>
<tr>
<td>Guruswamy Name</td>
<td><?php echo $guruswamy_name; ?></td>
<td>Driver Name</td>
<td><?php echo $driver_name; ?></td>
<td>Cleaner Name</td>
<td><?php echo $cleaner_name; ?></td>
</tr>
<tr>
<td>Guruswamy Mobile</td>
<td><?php echo $guruswamy_mobile; ?></td>
<td>Driver Mobile</td>
<td><?php echo $driver_mobile; ?></td>
<td>Cleaner Mobile</td>
<td><?php echo $cleaner_mobile; ?></td>
</tr>
</tbody>
</table>
<table class="tbl">
<?php
$nobox = 0;
for($i=1;$i<=$totrows_low;$i++){
if($i == 1){ ?>
<tr>
<td style="padding: 2px;" rowspan="<?php echo $noslr_low?>" valign="top">Driver Seat</br>Vehicle No :</br><span style='font-weight: bold;white-space: nowrap;'><?php echo $vehicle_no; ?></span></td>
<?php for($j=1;$j<=$colms_low;$j++){ ?>
<td ><span id="seatno_lower" name="seatno_lower[]" type="text" class="seat_no number" <?php echo $style; ?> value="" /></span><?php //echo $sno?></td>
<?php $sno = $sno+1;
$nobox = $nobox+1;
}
?>
</tr>
<?php }
elseif($i == $pathrow_low){
if($nospr_low == $noslr_low){
$colsp = $colms_low;
?>
<tr><td colspan="<?php echo $colsp?>">Path Way</td></tr>
<?php }else{
$colsp = $colms_low - 1;
?>
<tr>
<td colspan="<?php echo $colsp?>">Path Way</td>
<td ><span id="seatno_lower" name="seatno_lower[]" type="text" class="seat_no number" <?php echo $style; ?> value="" /></span><?php //echo $sno?></td>
</tr>
<?php $sno = $sno + 1;
$nobox = $nobox + 1;
}
}else{ ?>
<tr>
<?php for($j=1;$j<=$colms_low;$j++){ ?>
<td ><span id="seatno_lower" name="seatno_lower[]" type="text" class="seat_no number" <?php echo $style; ?> value="" /></span><?php //echo $sno?></td>
<?php $sno = $sno+1;
$nobox = $nobox+1;
} ?>
</tr>
<?php }
}
?>
</table>
</div>
<?php }else if($multi_type === "1"){ ?>
<div class="row" style="margin: 25px;padding: 5px;margin-top: -45px;overflow: auto;">
<!--<button id="export" class="btn btn-info btn-sm">Export</button> -->
<button style="margin-bottom: 8px;" id="print_layout" class="btn btn-info btn-sm">Print</button>
<h3 style="text-align: center;"><?php echo $package_name; ?></h3>
<h5>Upper Desk</h5>
<table class="tbl">
<?php
$sno = 1;
$nobox = 0;
for($k=1;$k<=$totrows_up;$k++){
if($k == 1){ ?>
<tr>
<td style="padding: 2px;" rowspan="<?php echo $totrows_up?>" valign="top">Upper Desk</td>
<?php for($l=1;$l<=$colms_up;$l++){ ?>
<td ><span id="seatno_upper" name="seatno_upper[]" type="text" class="seat_no number" <?php echo $style; ?> value="" /></span><?php //echo $sno?></td>
<?php $sno = $sno+1;
$nobox = $nobox+1;
}
?>
</tr>
<?php }
else if($k == $pathrow_up){
if($nospr_up == $noslr_up){
$colsp = $colms_up;
?>
<tr><td colspan="<?php echo $colsp?>">Path Way</td></tr>
<?php }else{
$colsp = $colms_up - 1;
?>
<tr>
<td colspan="<?php echo $colsp?>">Path Way</td>
<td ><span id="seatno_upper" name="seatno_upper[]" type="text" class="seat_no number" <?php echo $style; ?> value="" /></span><?php //echo $sno?></td>
</tr>
<?php $sno = $sno+1;
$nobox = $nobox+1;
}
}else{ ?>
<tr>
<?php for($l=1;$l<=$colms_up;$l++){ ?>
<td ><span id="seatno_upper" name="seatno_upper[]" type="text" class="seat_no number" <?php echo $style; ?> value="" /></span><?php //echo $sno?></td>
<?php $sno = $sno+1;
$nobox = $nobox+1;
} ?>
</tr>
<?php }
}
?>
</table>
<h5>Lower Desk</h5>
<table class="tbl">
<?php
//$sno = 1;
$nobox = 0;
for($i=1;$i<=$totrows_low;$i++){
if($i == 1){ ?>
<tr>
<td style="padding: 2px;" rowspan="<?php echo $totrows_up?>" valign="top">Driver Seat</td>
<?php for($j=1;$j<=$colms_low;$j++){ ?>
<td ><span id="seatno_lower" name="seatno_lower[]" type="text" class="seat_no number" <?php echo $style; ?> value="" /></span><?php //echo $sno?></td>
<?php $sno = $sno+1;
$nobox = $nobox+1;
}
?>
</tr>
<?php }
elseif($i == $pathrow_low){
if($nospr_low == $noslr_low){
$colsp = $colms_low;
?>
<tr><td colspan="<?php echo $colsp?>">Path Way</td></tr>
<?php }else{
$colsp = $colms_low-1;
?>
<tr>
<td colspan="<?php echo $colsp?>">Path Way</td>
<td ><span id="seatno_lower" name="seatno_lower[]" type="text" class="seat_no number" <?php echo $style; ?> value="" /></span><?php //echo $sno?></td>
</tr>
<?php $sno = $sno+1;
$nobox = $nobox+1;
}
}else{ ?>
<tr>
<?php for($j=1;$j<=$colms_low;$j++){ ?>
<td ><span id="seatno_lower" name="seatno_lower[]" type="text" class="seat_no number" <?php echo $style; ?> value="" /></span><?php //echo $sno?></td>
<?php $sno = $sno+1;
$nobox = $nobox+1;
} ?>
</tr>
<?php }
}
?>
</table>
</div>
<?php } ?>
<!-- <button class="btn btn-info" style="float:right;" id="save_seats">Save Seats</button> -->
<!-- Total Boxes : <?php // echo $nobox?> -->
<span type="hidden" name="totbox" value="<?php echo $nobox?>"/>
<script src="./dist/word_export.js"></script>
<script type="text/javascript">
$(document).ready(function(){
var vehicle_id = '<?php echo $vehicle_id; ?>';
var seat_type = '<?php echo $seat_type; ?>';
var package_id = '<?php echo $package_id; ?>';
var package_date = '<?php echo $package_date; ?>';
var trip_id = '<?php echo $trip_id; ?>';
if(seat_type === "3"){
$('#note').text("Note: Use Keyword SL_ for Sleeper and S_ for Seater and Semi-sleeper Before Seat No --- Example : S_1 SL_2");
$("span[name='seatno_lower[]']").removeClass('number');
$("span[name='seatno_upper[]']").removeClass('number');
$("span[name='seatno_lower[]']").addClass('alpha');
$("span[name='seatno_upper[]']").addClass('alpha');
}
get_seat_data(vehicle_id,package_id,package_date,trip_id);
//Alphabetic and Numbers insert
$("body").on("keypress keyup blur",".number",function (event){
$(this).val($(this).val().replace(/[^\d].+/, ""));
if ((event.which < 48 || event.which > 57)) {
event.preventDefault();
}
});
$("body").on("keydown",".alpha", function(e){
// var arr = [8,9,16,17,20,32,35,36,37,38,39,40,45,46];
// for(var i = 65; i <= 90; i++){
// arr.push(i);
// }
// if(jQuery.inArray(event.which, arr) === -1){
// event.preventDefault();
// }
if(event.keyCode == 32) {
event.preventDefault();
}
});
$(".seat_no").change(function (e){
var seat_capacity = '<?php echo $seat_capacity; ?>';
var seat_type = '<?php echo $seat_type; ?>';
var lower = $("span[name='seatno_lower[]']")
.map(function(){return $(this).val();}).get();
var upper = $("span[name='seatno_upper[]']")
.map(function(){return $(this).val();}).get();
var value = $(this).val();
if(seat_type === "3"){
if((value.indexOf("S_") > -1) || (value.indexOf("SL_") > -1)){
if(value.match(/_(\d)+$/)) {
}else{
$(this).val('');
}
}else{
$(this).val('');
}
}
if(parseInt(value) > parseInt(seat_capacity)){
toastr.warning("Seat number is Greater than Seat Capacity");
$(this).val('0');
}else
if(value === ""){
$(this).val('0');
}
var count = 0;
$.each(lower,function(i){
if(value === lower[i]){
count ++;
}
});
$.each(upper,function(i){
if(value === upper[i]){
count ++;
}
});
if(count > 1){
toastr.warning("Seat Already Exist");
$(this).val('0');
}
});
$("#print_layout").click(function(event) {
window.print();
});
});
function get_seat_data(vehicle_id,package_id,package_date,trip_id){
var seat_type = '<?php echo $seat_type; ?>';
if(trip_id){
$.ajax({
type: "POST",
url: "<?php echo site_url($controller_name.'/get_seat_data'); ?>",
data:{vehicle_id:vehicle_id,package_id:package_id,package_date:package_date,trip_id:trip_id},
success: function(data){
var rslt = JSON.parse(data);
for(i = 0; i < rslt.seat_data.length; i++) {
if(rslt.seat_data[i].vehicle_lower){
vehicle_lower = rslt.seat_data[i].vehicle_lower.split(",");
$.each(vehicle_lower,function(i){
var lower = vehicle_lower[i].split('_');
var num = lower[1];
if(!num){
num = 0;
}
if(seat_type === "3"){
num = vehicle_lower[i];
}
var seatno_lower_id = "seatno_lower_"+num;
document.getElementById('seatno_lower').setAttribute('id',seatno_lower_id);
$("span[id="+seatno_lower_id+"]").html(num);
});
}
if(rslt.seat_data[i].vehicle_upper){
vehicle_upper = rslt.seat_data[i].vehicle_upper.split(",");
$.each(vehicle_upper,function(i){
var upper = vehicle_upper[i].split('_');
var unum = upper[1];
if(!unum){
unum = 0;
}
if(seat_type === "3"){
unum = vehicle_upper[i];
}
var seatno_upper_id = "seatno_upper_"+unum;
document.getElementById('seatno_upper').setAttribute('id',seatno_upper_id);
$("span[id="+seatno_upper_id+"]").html(unum);
});
}
}
get_passenger_data(package_id,package_date,trip_id);
},
});
}
}
function get_passenger_data(package_id,package_date,trip_id){
if(trip_id){
$.ajax({
type: "POST",
url: "<?php echo site_url($controller_name.'/get_passenger_data'); ?>",
data:{package_id:package_id,package_date:package_date,trip_id:trip_id},
success: function(data){
var rslt = JSON.parse(data);
for(i = 0; i < rslt.pass_data.length; i++) {
if(rslt.pass_data[i].seats){
seats = rslt.pass_data[i].seats.split("_");
$.each(seats,function(i){
var seat_no = seats[1];
var data = seats[0];
var pass_rslt = seats[0].split(",");
var pass_seat = "<table style='font-weight: bold;'><tr><td class='tbl_data'>Seat No #"+seat_no+"</td></tr><tr><td class='tbl_data'>"+pass_rslt[0]+"</td></tr><tr><td class='tbl_data'>"+pass_rslt[1]+"</td></tr></table>";
var seatno_lower_id = "seatno_lower_"+seat_no;
$("span[id="+seatno_lower_id+"]").html(pass_seat);
var seatno_upper_id = "seatno_upper_"+seat_no;
$("span[id="+seatno_upper_id+"]").html(pass_seat);
});
}
}
},
});
}
}
</script>