<?php $pageno = 2; ?>
<!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> 
	<script type="text/javascript">
	function ValidateForm(){
		var from=document.forms["frmUsers"]["from"].value;
		if (from==null || from=="")
			{
				alert("Please Enter From Date");
				return false;
			}
		var day=document.forms["frmUsers"]["to"].value;
		if (to==null || to=="")
			{
				alert("Please Enter To Date");
				return false;
			}
	}
	</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/BusesList/" ><span>Master Details</span></a></li>
			<li><a href="<?php echo base_url(); ?>index.php/Administrator/BusDayReport/" ><span>Day Report</span></a></li>
			<li><a href="<?php echo base_url(); ?>index.php/Administrator/BusReport/" ><span>Month Report/Bus</span></a></li>
			<li><a href="<?php echo base_url(); ?>index.php/Administrator/BusReport/" ><span>Month Report/Route</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">Detailed Bus 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/IndivisualBusReports/" method="post" enctype="multipart/form-data" name="frmUsers" id="frmTransaction" onSubmit="return ValidateForm()">
						<table style="float: right;">
							<tr>
								<?php foreach ($query as $row) { $tagid = $row->route_id; } ?>
								<input type="hidden" class="input" name="tag_id"  value="<?php echo $tagid; ?>"/>
								<input type="hidden" class="input" name="routee_id"  value="<?php $row->route_id ?>"/>
								
								<td align="right" colspan="9">
									<input type="text" class="smallInput" name="from"  value="" placeholder="Date From" id="datepicker" />
									<input type="text" class="smallInput" name="to"  value="" 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>Time In</th>
								<th>Time Out</th>
								<th>Vehicle Number</th> 
								<th>Route No.</th>
								<th>Route Name</th>
							</tr>
						</thead>
						<tbody>
							<?php
							$i=0;
							foreach ($query as $row)
							{
								$i++;
								 $proid  = $row->vehicle_id;
								$tagid = $row->tag_id;
								
								$Dates = strtotime($row->time_in);
								$Date = date('Y-m-d', $Dates);
								$timein = date('H:i:s', $Dates);
								
							?>
							<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 $row->vehicle_id; ?>" title="View" class="ajax"></a> <?php echo $row->vehicle_number; ?>
								</td>
								<td>
								
									<?php 
									 echo $row->id;
									//echo $row->route_id;
									/* $uid = $this->uri->segment(3); //die; 
								    $route_result = bus_route($row->vehicle_id,$row->time_in);
									if($route_result[1] == 'till' ){
										//$old_route_no = $route_result[0]['route_no'];
										//echo $old_route_no;
										$ci =& get_instance();
										$ci->load->database();
										$query = $ci->db->query("SELECT r.route_name,r.id FROM tbl_tag_master as d left join route_details as r on r.id = d.route_id  WHERE  route_tag_id = '".$uid."'");
										$fatchrow = $query->row_array();
										echo $id =  $fatchrow['id'];
										echo $route_name =  $fatchrow['route_name'];
									}
									 else if($route_result == "noresult"){
										echo $id =  $fatchrow['id'];
										echo $route_name =  $fatchrow['route_name'];
									}
									else{
										echo $id =  $fatchrow['id'];
										echo $route_name =  $fatchrow['route_name'];
									}   */
									?>
								</td>
								<td><?php  echo $row->route_details; ?></td>
							</tr>
							<?php
							}
							//----------------Relationship-------------------//
							$total = $i;
							$fromdate = $from['0'];
							$todate = $from['1'];
							$vehicletype = "Bus";
							echo TagRelationship($tagid,$fromdate,$todate,$vehicletype,$total);
							//----------------Relationship-------------------//
							?>
						</tbody>
					</table>
				</div>
			</div>
		</div>
		<div class="clear"> </div>		
	</div>
</div>
<?php include('template/footer.php'); ?>
</body>
</html>