<?php $pageno = 1; ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
	<?php include('template/head.php'); ?>
	<!--DATA TABLE --> 
    <script type="text/javascript" src="<?php echo base_url(); ?>assets/data_table/js/jquery.dataTables.js"></script>
    <link href="<?php echo base_url(); ?>assets/data_table/css/demo_table_jui.css" rel="stylesheet" type="text/css"/>
    <link href="<?php echo base_url(); ?>assets/data_table/css/jquery-ui-1.8.4.custom.css" rel="stylesheet" type="text/css"/>
    <!--DATA TABLE -->   
    <script type="text/javascript" charset="utf-8">
	$(document).ready(function(){
		$('#datatables').dataTable({
			"sPaginationType":"full_numbers",
			"iDisplayLength": 25,
			"aaSorting":[[0, "asc"]],
			"bJQueryUI":true
		});
	});
    </script>
	 <script type="text/javascript" charset="utf-8">
	$(document).ready(function(){
		$('#datatables1').dataTable({
			"sPaginationType":"full_numbers",
			"iDisplayLength": 25,
			"aaSorting":[[0, "asc"]],
			"bJQueryUI":true
		});
	});
    </script>
</head>
<body>
<?php include('template/header.php'); ?> 
<div class="grid_16" id="navheader">
	<?php include('template/topnav.php'); ?>
</div>
<div class="grid_16" id="tabs">
	<div class="container">
		<ul>
			<li><a href="<?php echo base_url(); ?>index.php/Administrator/UploadLog/"><span>Upload Handheld Data</span></a></li>
		</ul>
	</div>   
</div>
<div class="container_16" id="wrapper">	
    <div class="grid_16" id="content"> 
		<div class="grid_9">
			<h1 class="user">Buses – Last 7 days</h1>
		</div>
		<div class="grid_15" id="textcontent">
			<div id="table">
				<div id="user_profile_main_div">
					<div class="clear"></div>
					<table id="datatables" class="display">
						<thead>
							<tr>
								<th>Sno</th>
								<th>Tag Id</th>
								<th>Time In</th>
								<th>Time Out</th>
								<th>Vehicle Number</th> 
								<th>Route No.</th>
								<th>Route Name</th>
								<th>Vendor Name</th>
							</tr>
						</thead>
						<tbody>
							<?php
							$i=0;
							foreach ($busquery as $row)
							{
								$i++;
								$proid  = $row->vehicle_id;
							?>
							<tr>
								<td><?php echo $i;?></td>
								<td><?php echo $row->tag_no; ?></td>
								<td><?php echo $row->time_in; ?></td>
								<td>
									<?php 
									if(($row->time_out == '2010-01-01 01:01:01') || ($row->time_out == '2009-12-31 19:31:01') || ($row->time_out == '') ){
										echo "AUTO OUT";
									} else {
										echo $row->time_out;
									} 
									?>
								</td>
								<td>
									<a href="<?php echo base_url(); ?>index.php/Administrator/VehicleDetails/<?php echo $proid; ?>" title="View" class="ajax"><?php echo $row->vehicle_number; ?></a>
								</td>
								<td><?php echo $row->id; ?></td>
								<td><?php echo $row->route_details; ?></td>
								<td><?php echo $row->vender; ?></td>
							</tr>
							<?php
							}
							?>
						</tbody>
					</table>
				</div>
			</div>
		</div>
		<div class="clear"> </div>	
		<div class="grid_9">
			<h1 class="reports">Cabs – Last 7 days</h1>
		</div>
		<div class="grid_15" id="textcontent">
			<div id="table">
				<div id="user_profile_main_div">
					<div class="clear"></div>
					<table id="datatables1" class="display">
						<thead>
							<tr>
								<th>Sno</th>
								<th>Tag Id</th>
								<th>Time In</th>
								<th>Time Out</th>
								<th>Total Stay Time</th>
								<th>Vehicle Number</th> 
								<th>Vehicle Type</th>
								<th>Vendor Name</th>
							</tr>
						</thead>
						<tbody>
							<?php
							$i=0;
							foreach ($cabquery as $row)
							{
								$i++;
								$proid  = $row->vehicle_id;
							?>
							<tr>
								<td><?php echo $i;?></td>
								<td><?php echo $row->tag_no; ?></td>
								<td><?php echo $row->time_in; ?></td>
								<td>
									<?php 
									if(($row->time_out == '2010-01-01 01:01:01') || ($row->time_out == '2009-12-31 19:31:01') || ($row->time_out == '') ){	
										echo "AUTO OUT";
									} else {
										echo $row->time_out;
									} 
									?>
								</td>
								<td>
									<?php
									$time_in = new DateTime($row->time_in);
									$time_out = new DateTime($row->time_out);
									$difference = $time_in->diff($time_out);
									if(($row->time_out == '2010-01-01 01:01:01') || ($row->time_out == '2009-12-31 19:31:01') || ($row->time_out == '') ){	
										echo "--";	
									}
									else{	
										echo format_interval($difference);	
									}
									?>
								</td>
								<td>
									<a href="<?php echo base_url(); ?>index.php/Administrator/VehicleDetails/<?php echo $proid; ?>" title="View" class="ajax"><?php echo $row->vehicle_number; ?></a>
								</td>
								<td><?php echo $row->cab_type; ?></td>
								<td><?php echo $row->vender; ?></td>
							</tr>
							<?php
							}
							?>
						</tbody>
					</table>
				</div>
			</div>
		</div>
		<div class="clear"> </div>	
	</div>
</div>
<?php include('template/footer.php'); ?>
</body>
</html>