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

include("include/config.php");
require_once "include/Database_functions.php";
$sqlObj=new sqlclass();
$flag = 0;
	
if(isset($_REQUEST['saveprint'])){
$flag = 1;
}     
		
	
				

?>
<!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 type="text/css" href="css_date/ui-lightness/jquery-ui-1.7.2.custom.css" rel="stylesheet" />
<link rel="stylesheet" type="text/css" href="js/jquery.autocomplete.css" />


<script type='text/javascript' src="https://ajax.googleapis.com/ajax/libs/jquery/1.8.3/jquery.min.js"></script>
<script type='text/javascript' src="js/jquery.autocomplete.js"></script>

<script type="text/javascript" src="scripts_date/jquery-calendar-1.7.2.js"></script>
<script>
$(document).ready(function(){

$('#todaydate').datepicker({
showOn: 'both',
buttonImage: 'icons_date/calendar.gif',
buttonImageOnly: true,
changeMonth: true,
changeYear: true,
dateFormat: 'dd-mm-yy'
})
	
	$('#clntcode').autocomplete("codelist.php", {
			width: 260,
			matchContains: true,
			//mustMatch: true,
			//minChars: 0,
			//multiple: true,
			//highlight: false,
			//multipleSeparator: ",",
			selectFirst: false
	});


});

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



</script>


<script type="text/javascript">

function validation(){

if(document.cashreceipt_frm.clntcode.value==''){
alert("Select the Client Code");
document.cashreceipt_frm.clntcode.focus();
return false;
}
if(document.cashreceipt_frm.amount.value==''){
alert("Please Enter the amount");
document.cashreceipt_frm.amount.focus();
return false;
}
if(document.cashreceipt_frm.received_to.value==''){
alert("Please Enter whom amount is paid to");
document.cashreceipt_frm.received_to.focus();
return false;
}
if(document.cashreceipt_frm.todaydate.value==''){
alert("Select a date");
document.cashreceipt_frm.todaydate.focus();
return false;
}





/*var cnt=document.getElementById('divcnt').value;chasisnum1 enginenum1
for(i=1;i<=cnt;i++){alert(document.getElementById('vehiclenum'+i).value);
if(document.getElementById('vehiclenum'+i)){
if(document.getElementById('vehiclenum'+i).value==''){
alert("Enter the Vehicle Number");
document.getElementById('vehiclenum'+i).focus();
return false;
}
}
}*/
}

</script>

<script type="text/javascript">

function changeval()
{  
	
	var val= document.cashreceipt_frm.amount.value;
	var strURL="get_sum_inl.php?val="+val;
	//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('sum_in_letters').value=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);
   }
}
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;
	}   

</script>

<script type="text/javascript">
function printDiv(divName) {
     var printContents = document.getElementById(divName).innerHTML;
	
     var originalContents = document.body.innerHTML;

     document.body.innerHTML = printContents;

     window.print();
	setTimeout(function(){document.body.innerHTML = originalContents;},3000);
     
}


</script>




<style>
.lableentrytext{
font-size: 12px;
color: #505050;
clear: both;
margin-bottom: 5px;
text-transform: capitalize;
}

body {
	padding:0px;
	margin:0px;
	font-family:Arial, Helvetica, sans-serif;
	color:#000000;
}
.div01 {
	width:80%;
		margin:0 70px;
	padding-bottom:15px;
}
.ptForm {
	/*border:1px solid #000000;*/
	width:100%;
	margin:0 auto;
	padding:4px;
}
.ptText01 {
	font-size:20px;
	font-weight:bold;
}
.ptText02 {
	font-size:12px;
}
.ptText03 {
	font-size:16px;
	font-weight:bold;
}
.ptText04 {
	font-size:16px;
	font-weight:bold;
	border-left:solid 1px #000000;
	border-right:solid 1px #000000;
	border-top:solid 1px #000000;
}
.ptText05 {
	font-size:14px;
	font-weight:bold;
}
.field01 {
	border-bottom:#333333 dotted 1px;
	border-left:none;
	border-top:none;
	border-right:none;
	color:#000000;
	font-size:12px;
	font-weight:bold;
	background-color:#f1f1f1;
}
.field02 {
	border:none;
	color:#000000;
	font-size:12px;
	font-weight:bold;
	background-color:#f1f1f1;
}
.ptText06 {
	font-size:12px;
	font-weight:bold;
}
.rightTd {
	border-bottom:solid 1px #000000;
}
.leftTd {
	border-bottom:solid 1px #000000;
	border-right:solid 1px #000000;
	padding:4px;
}
.tdItem {
	border-bottom:solid 1px #000000;
	border-right:solid 1px #000000;
	padding:4px;
}
.rightTd {
	border-bottom:solid 1px #000000;
	padding:4px;
}
/*.rightTdBtm {
	border:none;
	padding:4px;
}
.leftTdBtm {
	border-right:solid 1px #000000;
	padding:4px;
}*/
.tdItemBtm {
	
	padding:4px;
}

#adv{

	display:none;
	
}


.ckl{
	 background-image:url(images/inputBg.gif); border:none; background-repeat:repeat-x; border-radius:4px; height:29px; padding:0 0px; border:1px solid #cccccc; 
}
</style>
</head>

<body onLoad="<?php if($flag == 1){?>printDiv('div01');<?php }?>">
<div class="wrapper">
  <div>
<?php 
	include("header.php");
	
	//$tripdriver = 2000;
?>
 
</div>
 

 <div class="tabbedArea">
  
  <div class="tabBody"> 

  
   <form name="cashreceipt_frm" method="post" action="">
   <div style="width:1100px;" >
     <div style="float:right;  margin-bottom:10px;">
     <span style="float:right;"> 
	 	<input name="saveprint" type="submit" value="Print" class="submit-btn" style="margin-top:0px;" />
      </span>
      </div>
      </div>
   <div style="width:1100px;" > <div style="float:left;"><h1 style="float:left">Client Invoice</h1> </div> 
     <div style="float:right;  margin-bottom:10px;">
     
      </div>
      </div>

   
   <div class="addEmp" style="margin-bottom:0px; border-bottom:0px solid;width:1000px;float:left;">
   <div id="printableArea">
   <div class="div01" id="div01">
<div class="ptForm">
<table width="100%" border="0" cellspacing="5" cellpadding="2"  style="border:1px solid #000000; padding:4px;">


    <tr>
      <td  colspan="5" class="ptText01" style="text-align:center;">G M  TRANSPORTS</td>
    </tr>
    <tr>
      <td  colspan="5" class="ptText02" style="text-align:center;">HO : No.32/1840, Mammoottil Complex , Padivattom, Cochin - 682024</td>
    </tr>
    <tr>
      <td  colspan="5" class="ptText03" style="text-align:center;">Client Invoice </td>
    </tr>
    <?php 
     $billid = $_REQUEST['bill_id'];
	 ?>
     <tr>
      <td  colspan="4"  class="ptText02" style="width:60%;">No
      <?=$billid?>
       </td>
       <?php 
	   	$sqldate = mysql_query("SELECT MIN(trip_date) as mindate, MAX(trip_date) as maxdate from cf_genbill where gen_billno = '$billid'");
		$rwdate = mysql_fetch_array($sqldate);
		
	   ?>
      <td class="ptText02"  style="text-align:left; width:36%;">Freight Bill for the Period
        <?=$rwdate['mindate']?> To <?=$rwdate['maxdate']?></td>
    </tr>
  <tr>
  	<td colspan="5">
  		<table  width="100%"  cellspacing="0" cellpadding="0"   class="List" align="center" style="border-top:solid 1px #000000; border-bottom:none; border-left:solid 1px #000000; border-right:solid 1px #000000;" >
        <tr>
        	<td class="leftTd" style="font-weight:bold; font-size:13px;">Tripsheet Date</td>
            <td class="tdItem" style="font-weight:bold;font-size:13px;">Trip Sheet No</td>
            <td class="tdItem" style="font-weight:bold;font-size:13px;">Dealer</td>
            <td class="tdItem" style="font-weight:bold;font-size:13px;">Invoice No</td>
            <td class="tdItem" style="width:1%; font-weight:bold;font-size:13px;">Gross Weight</td>
            <td class="tdItem" style="width:1%; font-weight:bold;font-size:13px;">Net Weight</td>
            <td class="tdItem" style="width:1%; font-weight:bold;font-size:13px;">Rate Charged</td>
            <td class="rightTd" style="width:1%; font-weight:bold;font-size:13px;">Freight Amount</td>
        </tr>   
        
        <?php 
		$totfreight1 = '';
		$totrate = '';
		//echo "select * from cf_genbill where gen_billno = '$billid'";
			$sqls = mysql_query("select * from cf_genbill where gen_billno = '$billid'");
			$addrate = '';
			$newfrgh='';
			while($row = mysql_fetch_array($sqls))
			{
				//echo $row['freight_amt'];
				
				$totfreight1 = $totfreight1 + $row['freight_amt'];
				$totrate = $totrate + $row['rate_chg'];
				$tripno = $row['tripsheet_no'];
				
				$sqltrip = mysql_query("select a.trip_newsrno,a.trip_sub_client_id,b.trip_location,b.trip_location_id,b.trip_dealer,b.invoice_no,b.grossweight,b.netweight from cf_tripsheet as a  join cf_tripsheetsub as b on a.trip_id = b.trip_id where a.delete_status = 0 and a.trip_newsrno = '$tripno'");
				$totfreight='';
				$grossweight='';
				$netweight='';
				while($rwdeal = mysql_fetch_array($sqltrip))
				{
					$locationid = $rwdeal['trip_location_id'];
					$town_name = $rwdeal['trip_location'];
					$clientids = $rwdeal['trip_sub_client_id'];
					$sqlrate = mysql_query("select * from cf_rate_act where  client_code = '$clientids' and town_name = '$town_name'");
					$rw4 = mysql_fetch_array($sqlrate);
					$rates = $rw4['rate'];
				?>
					<tr>
						<td class="leftTd ptText02"><?=$row['trip_date']?></td>
						<td class="tdItem ptText02"><?=$row['tripsheet_no']?></td>
						<td class="tdItem ptText02"><?=$rwdeal['trip_dealer']?></td>
                        <td class="tdItem ptText02"><?=$rwdeal['invoice_no']?></td>
						<td class="tdItem ptText02"><?=$rwdeal['grossweight']?></td>
						<td class="tdItem ptText02"><?=$rwdeal['netweight']?></td>
                        <td class="tdItem ptText02"><?=$rates?></td>      
                        <?php 
							$addrate+= $rates;
							$frightamt = $rwdeal['grossweight'] * $rates;
							
							$totfreight+= $frightamt;
							
							$grossweight+=$rwdeal['grossweight'];
							$netweight+=$rwdeal['netweight'];
							//echo $totfreight; 
							//echo "<br/>";
						?>                  
						<td class="tdItem ptText02"><?=round($frightamt,2)?></td>
        			</tr>
		<?php }
		?>
        <tr>
						<td class="leftTd ptText02"></td>
						<td class="tdItem ptText02"></td>
                        <td style="border-bottom:solid 1px #000000;"></td>
						<td class="tdItem ptText02"><span style="font-weight:bold;">Total</span></td>
						<td class="tdItem ptText02"><span style="font-weight:bold;"><?=$grossweight?></span></td>
						<td class="tdItem ptText02"><span style="font-weight:bold;"><?=$netweight?></span></td>
						<td class="tdItem ptText02"></td>
                        <td class="tdItem ptText02"><span style="font-weight:bold;"><?=round($totfreight,2)?></span></td>
        			</tr>
        
        <?php $newfrgh+=$totfreight; } ?>  
        
        <tr>
        	<td style="border-bottom:solid 1px #000000;"></td>
            <td style="border-bottom:solid 1px #000000;"></td>
            <td style="border-bottom:solid 1px #000000;"></td>
            <td style="border-bottom:solid 1px #000000;"></td>
            <td style="border-bottom:solid 1px #000000;"></td>
            <td style="border-bottom:solid 1px #000000; font-weight:bold;font-size:13px;">Total</td>
            <td style="border-bottom:solid 1px #000000;font-size:13px;"></td>
            <td style="border-bottom:solid 1px #000000;font-size:13px;"><?php
			echo round($newfrgh,2);?></td>
            
        </tr>   
        </table>
  
  	</td>
  </tr> 
  
    
   
    
    
    
    <tr>
      <td  colspan="5" >&nbsp;</td>
    </tr>
   

 
    
  </table>
  
  
</div>
<div style="text-align:center;">

</div>
</div>
</div>

<!--<div class="mand"><p>Fields marked <span style="color:#FF3300">*</span> are Mandatory</p></div>-->
</div>

	
    <!-- <input name="save" type="submit" class="input1" value="Save" onClick="return validation();"/> onClick="printDiv('div01');"-->
   <input type="hidden" name="csh_rcpt" id="csh_rcpt" value="2">
    
   </form>
   </div>
 </div>
 
 <div class="footer"><p>Powered by <a href="#">Aadhocc</a></p></div>
 
</div>
<div class="quicLInksCover">
 <?php 
	include("leftlink.php");
?>

</div>


<!--<div style="width:86%; margin:0 auto;">


<a href="trip-sheets.php">Back To Trip Sheet Page</a>

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


		






