<?php $pageno = 3; error_reporting(0);?>
<!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'); ?>
	<link rel="stylesheet" href="<?php echo base_url(); ?>assets/datepicker/jquery-ui.css" />
	<!--<script src="<?php echo base_url(); ?>assets/datepicker/jquery-1.9.1.js"></script>-->
	<script src="<?php echo base_url(); ?>assets/datepicker/jquery-ui.js"></script>
	<script type="text/javascript">
	$(function() {
		$( "#datepicker" ).datepicker({ dateFormat: "yy-mm-dd" }).val();
		$( "#datepicker1" ).datepicker({ dateFormat: "yy-mm-dd" }).val();
	});
	</script>
	<!--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": 100,
			"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/CabsList/"  ><span>Master Details</span></a></li> 
			<li><a href="<?php echo base_url(); ?>index.php/Administrator/CabDayReport/" ><span>Day Report</span></a></li>
			<li><a href="<?php echo base_url(); ?>index.php/Administrator/CabReport/" ><span>Month Report</span></a></li>
			<li><a href="<?php echo base_url(); ?>index.php/Administrator/CabConsolidatedReport/" class="current" ><span>Consolidated Report</span></a></li>
		</ul>
	</div>   
</div>
<div class="container_16" id="wrapper">	
    <div class="grid_16" id="content"> 
		<div class="grid_9">
			<h1 class="reports">Cabs Month Report</h1>
		</div>
		<div class="grid_15" id="textcontent">
			<div id="table">
				<div id="user_profile_main_div">
					<div id="message">
					<?php 
					if($this->session->flashdata('flsh_msg')) {
						?><p id="success" class="info"><span class="info_inner"><?php echo $this->session->flashdata('flsh_msg'); ?></span></p> <?php
					} 
					if($this->session->flashdata('flsh_msg1')) {
						?><p id="error" class="info"><span class="info_inner"><?php echo $this->session->flashdata('flsh_msg1'); ?></span></p> <?php
					} 
					?>
					</div>
					<div class="clear"></div>
					<form action="<?php echo base_url(); ?>index.php/Administrator/CabConsolidatedReport/" method="post" enctype="multipart/form-data" name="frmUsers" id="frmTransaction" >
					<table style="float: right;">
						<tr>
							<td align="right" colspan="9">
								<select name="vehicleid" id="clientid" class="smallInput">
								<option value="">Select Vehicle</option>
								<?php
									foreach ($result as $fatchrow)
									{ 
										?><option value="<?php echo $fatchrow->tag_id; ?>"><?php echo $fatchrow->vehicle_number; ?></option><?php 
									} 
								?>
								</select>
								<input type="text" class="smallInput" name="from" placeholder="Date From" id="datepicker"/>
								<input type="text" class="smallInput" name="to" placeholder="Date To" id="datepicker1"/>
								<span class="button">
									<input name="showresult" class="buttoncc" type="submit" id="delete" value="Show">
								</span>
								<span class="button">
									<input name="savereport" class="buttoncc" type="submit" id="delete" value="save as excel">
								</span>
							</td>
						</tr>
					</table>
					</form>	
					<table id="datatables" class="display">
						<thead>
							<tr>
								<th>Sno</th>
								<th>Tag Id</th>
								<th>Date</th>
								<th>Time In</th>
								<th>Time Out</th>
								<th>Vehicle Number</th>
								<th>Registration Date</th>
								<th>Fitness</th>
								<th>Permit</th>
								<th>Vehicle Type</th>
								<th>Vendor Name</th>
							</tr>
						</thead>
						<tbody>
							<?php
							$i=0;
							$fromdate = $from['0'];
							$todate = $from['1'];
							if(($fromdate !="") && ($todate !="")){
								$create_from=date_create($fromdate);
								$from = date_format($create_from,'Y-m-d');
								$create_to=date_create($todate);
								$to = date_format($create_to,'Y-m-d');
								$curdate = date('m-Y');
							}
							else{
								$from = "novalue";
								$to = "novalue";
								$curdate = date('m-Y');
							}
							foreach ($query as $row)
							{
								$i++;
								$proid  = $row->vehicle_id;
								if($row->tag_id != "")
								{
									$tagid = $row->tag_id;
								}
								else {
									echo $tagid = $row->alias_tag;
								}
								
								$Dates = strtotime($row->firstin);
								$Date = date('Y-m-d', $Dates);
								$timein = date('H:i:s', $Dates);
								$out = strtotime($row->lastout);
								$timeout = date('H:i:s', $out);
								$timet = date('H:i:s', $out);
								$lastin = strtotime($row->lastin);
								$lasttimein = date('H:i:s', $lastin);
								$lasttim = date('H:i:s', $lastin);
								if($timeout <= $lasttimein){
									$exittime = $lasttim;
								} else {
									$exittime = $timet;
								}
							?>
							<tr>
								<td><?php echo $i;?></td>
								<td>
									<a href="<?php echo base_url(); ?>index.php/Administrator/IndivisualCabReport/<?php echo $tagid; ?>"><?php echo $row->tag_no; ?></a>
								</td>
								<td><?php echo $Date;?></td>
								<td><?php echo $timein;?></td>
								<td><?php echo $exittime;?></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->fitness; ?></td>
								<td><?php echo $row->permit; ?></td>
								<td><?php echo $row->registration_date; ?></td>
								<td><?php echo $row->cab_type; ?></td>
								<td><?php echo $row->vender; ?></td>
							</tr>
							<?php
							//----------------Relationship-------------------//
							/*$tag = Relationship($tagid)['0'];
							$result = Relationship($tagid)['1'];	
							foreach ($result as $fatchresult)
							{
								$i++;
							?>
							<tr>
								<td><?php echo $i;?></td>
								<td><?php echo $tag; ?></td>
								<td><?php echo $Date;?></td>
								<td><?php echo $timein;?></td>
								<td><?php echo $exittime;?></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->fitness; ?></td>
								<td><?php echo $row->permit; ?></td>
								<td><?php echo $row->registration_date; ?></td>
								<td><?php echo $row->cab_type; ?></td>
								<td><?php echo $row->vender; ?></td>
							</tr>
							<?php
							}*/
							//----------------Relationship-------------------//
							}
							?>
						</tbody>
					</table>
				</div>
			</div>
		</div>
		<div class="clear"> </div>		
	</div>
</div>
<?php include('template/footer.php'); ?>
</body>
</html>
		