<?
ob_start();
session_start();
if(isset($_SESSION['ses_name']))
{
$user=$_SESSION['ses_name'];
}else{
header("location:index.php");
}


$veh_num='';
$sdate_12 ='';
$page='1';
include("include/config.php");
require_once "include/Database_functions.php";
$sqlObj=new sqlclass();
$msg = '';

if(isset($_REQUEST['del']) && $_REQUEST['del']=='delete')
{
	$id = $_REQUEST['id'];
	$sql=mysql_query("delete from cf_account_hire where trip_id='$id'");
	header("location:view-accountpay.php?msg=You Have Successfully Deleted");
}



if(isset($_POST['paybutton']))
{
	$dis =  $_POST['selecteds'];	
	foreach($dis as $dev_id)
		{
			$sql = mysql_query("update cf_account_hire set acc_status = '1' where acc_id = '$dev_id'");
		}
}

?>

<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Supply Chain Management</title>
<link href="css/styles.css" rel="stylesheet"  />
<link href="css/menu.css" rel="stylesheet" type="text/css" />
<link type="text/css" href="css_date/ui-lightness/jquery-ui-1.7.2.custom.css" rel="stylesheet" />
<script type='text/javascript' src="https://ajax.googleapis.com/ajax/libs/jquery/1.8.3/jquery.min.js"></script>

<script src="js/popup1.js" type="text/javascript"></script>


<script type='text/javascript' src="js/jquery.autocomplete.js"></script>
<link rel="stylesheet" type="text/css" href="js/jquery.autocomplete.css" />

<script type="text/javascript" src="scripts_date/jquery-calendar-1.7.2.js"></script>
<script>$(document).ready(function(){
$('#tripdate').datepicker({
showOn: 'both',
buttonImage: 'icons_date/calendar.gif',
buttonImageOnly: true,
changeMonth: true,
changeYear: true,
dateFormat: 'dd-mm-yy'
});
});

$(document).ready(function(){
$('#fromdate').datepicker({
showOn: 'both',
buttonImage: 'icons_date/calendar.gif',
buttonImageOnly: true,
changeMonth: true,
changeYear: true,
dateFormat: 'dd-mm-yy'
});
});

$(document).ready(function(){
$('#todate').datepicker({
showOn: 'both',
buttonImage: 'icons_date/calendar.gif',
buttonImageOnly: true,
changeMonth: true,
changeYear: true,
dateFormat: 'dd-mm-yy'
});
});


/*function drivername()
{
	alert(document.frmname.clientid.value);
}*/



</script>
<script language="javascript">
function getXMLHTTP()
	 { //fuction to return the xml http object
	var xmlhttp=false;	
		try
		{
		xmlhttp=new XMLHttpRequest();
		}
		catch(e)	
		{		
			try{			
				xmlhttp= new ActiveXObject("Microsoft.XMLHTTP");
				}
			catch(e)
			{
				try
				{
				xmlhttp = new ActiveXObject("Msxml2.XMLHTTP");
				}
				catch(e1)
				{
				xmlhttp=false;
				}
			}
		}
	return xmlhttp;
	}   

function Searchdate(val)
{ 
 	 var page=val;	
	 var routeid='';
	 var tripdate='';
	 var routeid='';
	 var clientcode='';
	
	 if(document.trip_frm.routeid){
	 routeid= document.trip_frm.routeid.value;
	 }
	 
	 if(document.trip_frm.client_code){
	 clientcode= document.trip_frm.client_code.value;
	 } 	 
	 
	 if(document.trip_frm.tripdate){
	 tripdate= document.trip_frm.tripdate.value;
	 }
	 
	 if(document.trip_frm.fromdate){
	 fromdate= document.trip_frm.fromdate.value;
	 }
	 
	 if(document.trip_frm.todate){
	 todate= document.trip_frm.todate.value;
	 }
	 
	 var strURL="ajax/trip_pendingsettle_data.php?&page="+page;
		if(routeid!=''){
		strURL+="&routeid="+routeid;
		}
		
		if(clientcode!=''){
		strURL+="&clientcode="+clientcode;
		}
	
		if(tripdate!=''){
		strURL+="&tripdate="+tripdate;
		}
		
		if(fromdate!=''){
		strURL+="&fromdate="+fromdate;
		}
		
		if(todate!=''){
		strURL+="&todate="+todate;
		}
	
	
	//alert(strURL);
	
	var req = getXMLHTTP();
   if (req)
   {
     req.onreadystatechange = function()
     {
		 
			if ((req.readyState == 0)||(req.readyState == 1)||(req.readyState == 2)||(req.readyState == 3))
      		{
			//document.getElementById('order').innerHTML='<div align="center"><img src="'+path+'images/ajax_loader.gif"/></div>';
			//document.getElementById('Cakeorder').innerHTML='<div align="center"><img src="'+path+'images/ajax_loader.gif"/></div>';
			}
		 
		 
      if (req.readyState == 4)
      {
	 // only if "OK"
	 	if (req.status == 200)
	 	{ 
	   document.getElementById('list').innerHTML=req.responseText;
	//	document.getElementById('Cakeorder').innerHTML=req.responseText;
	 	}
	  else 
	 	{
   	   alert("There was a problem while using XMLHTTP:\n" + req.statusText);

	 }
     }
     }
   req.open("GET", strURL, true);
   req.send(null);
   }
 
   
}
</script>

<SCRIPT language="javascript">

$(function(){
 
    // add multiple select / deselect functionality
    $("#selectall").click(function () {
          $('.case').attr('checked', this.checked);
    });
 
    // if all checkbox are selected, check the selectall checkbox
    // and viceversa
    $(".case").click(function(){
 
        if($(".case").length == $(".case:checked").length) {
            $("#selectall").attr("checked", "checked");
        } else {
            $("#selectall").removeAttr("checked");
        }
 
    });
});
</SCRIPT>


</head>

<body>
<!------------------popup area (view, edit)--------------->
<div class="viewEmployeePopup login-popup"  id="login-box">
<a href="#" class="close"><img src="images/close.png" class="btn_close" title="Close Window" alt="Close" /></a>
   <div id="popupid"></div>
   
     
    </div>


<!---------------popup area ends------------------>
<div class="wrapper">
   <div>
<?php 
	include("header.php");
?>
 
</div>
 
 <div class="tabbedArea">
  <?php if(isset($_REQUEST['msg'])){ ?>
  <div class="warningMessage">
     <p> <?=$_REQUEST['msg']?> </p>
    </div>
    <?php } ?>
  
  <div class="tabBody">
   <h1>Trip Pending Settlement Report</h1>
   <form name="trip_frm" id="trip_frm" method="post"  >
   <div class="searchBox" style="width:93%; margin-right:0px;  padding:0px; ">
   <div style="padding:20px;">
    <div class="searchField">
   
    </div>
    
    <?php 
    if(($_SESSION['typename'] == 'SuperAdmin')) {
	?>
    <div class="searchField" style="padding-left:20px;">
     <p class="input1">Client Code</p>
     <select class="input1 input3" name="client_code">
     <option value="">Client Code</option>
     	 <?php 
        	$sq_clientcd="select * from cf_client";
			$arr2=mysql_query($sq_clientcd);
			while($resclient=mysql_fetch_array($arr2))
			{
		?>
			<option value="<?=$resclient['client_sub_id']?>" ><?=$resclient['client_newcode']?></option>
        <?php
				}
	 ?>
     </select>
    </div>
    <?php } ?>
    
    <div class="searchField" style="padding-left:20px;">
     <p class="input1">Trip Date</p>
     <input type="text" name="tripsdate" id="tripdate" size="20" maxlength="100" class="input1" />
    </div>
    
    <div class="searchField" style="padding-left:20px;">
     <p class="input1">From Date</p>
     <input type="text" name="fromdate" id="fromdate" size="20" maxlength="100" class="input1" />
    </div>
    
    <div class="searchField" style="padding-left:20px;">
     <p class="input1">To Date</p>
     <input type="text" name="todate" id="todate" size="20" maxlength="100" class="input1" />
    </div>
       
    <div class="searchField">
     <input name="button" type="button" class="input1" onClick="Searchdate(1);" value="search" />
    </div>
  </div>
   </div></form>
      
   
   <div id="list" >
   
  
   <table  border="0" cellspacing="0" cellpadding="0" class="tableList">
   
  <tr class="heading">
  	<td>No</td>
    <td>Date</td>
    <td>Trip Sheet No</td>
    <td>Hire Amount</td>
    <td>Advance</td>
    <td>Net Amount Pending</td>
  </tr>
  
  <?php


/*
if(isset($_REQUEST['typename'])){
$typenames=$_REQUEST['typename'];
}*/

$i=1;
$clientcodeval = '';
if(($_SESSION['typename'] == 'SuperAdmin')) {
$sq_arr="select * from cf_tripsheet where trip_status = '0' and delete_status = '0' ";
}

if(($_SESSION['typename'] == 'SubAdmin')) {
	$userids = $_SESSION['admin_id'];
	
	$sq_clientid=mysql_query("select * from cf_user_clientid where user_id = $userids ");	
	while($rw = mysql_fetch_array($sq_clientid))
	{
		$clientcodeval.= "'".$rw['client_code']."',";
	}
	
	$clientnames = substr($clientcodeval, 0, -1);	
	$sq_arr="select * from cf_tripsheet where trip_status = '0' and delete_status = '0' and clientids IN ($clientnames)";
	
}	
$sq_arr.=" order by trip_id desc ";
$query=$sq_arr;
//echo $query;
$function="Searchdate";
include("pagingserch.php");
$sq_arr.=" LIMIT $start, $limit";
$i = 0;
if(isset($_REQUEST['page'])){
$page=$_REQUEST['page'];
}else{
$page=10;
}
$array=mysql_query($sq_arr);
if($array && mysql_num_rows($array)>0){
$pagecnt=$start;
while($res=mysql_fetch_array($array))
{
$pagecnt++;
  ?> 
  <tr>
  	<td><?php echo $pagecnt;?></td>
  	<?php 
		/*$routeid = $res['trip_route_id'];
    	$sq_route1="select * from cf_route where route_id = '$routeid' ";
		$array2=mysql_query($sq_route1);
		$res2=mysql_fetch_array($array2);*/
	?>
  	
    <td><?php echo date('d-m-Y', strtotime($res['trip_date']));?></td>
    <td><?php echo $res['trip_newsrno'];?></td>   
    <td><?php echo $res['hire_amt'];?></td>
    <td><?php echo $res['advt_amt'];?></td>
    <td><?php echo $res['bal_amt'];?></td>
    
    
  </tr>
  <?php 
    $i++;} ?>
	
	  <?php }
  ?>
 
 

   
</table>


  <div align="right" style="padding-top:10px;"><?=$pagination?></div> 
 </div> 
  </div>
 </div>
 <div class="footer"><p>Powered by <a href="http://www.aadhocc.co.uk/" target="_blank">Aadhocc</a></p></div>
 

<div class="quicLInksCover">
 <?php 
	include("leftlink.php");
?>

</div>
</body>
</html>
