<?
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();

$tablename='cf_tripsheet';
$flag = 0;
$recet='';$clt_cd='';$amt='';$sum_lttrs='';$tddate='';$sentto='';
	$tripid = $_REQUEST['trip_id'];
	$query1 = mysql_query("select * from cf_tripsheet where trip_id = '$tripid'");	
	$rows = mysql_fetch_array($query1);
	$getinv= explode("-01",$rows['trip_newsrno']);		
	$clientno = $getinv[0].'-03'.$getinv[1];
	
	//$sqlclient = mysql_query($query);	
	
	$query = "select * from cf_receipt where trip_id = '$tripid'";	
	$sqlclient = mysql_query($query);	
		
		$sqlclient = mysql_query($query);	
		$sql_arr	=	mysql_fetch_array($sqlclient);
			$finish = '';
			$recept_num	=	$sql_arr['receipt_id'] ;
			$clt_cd	=	$sql_arr['client_code'];
			$amt	=	$sql_arr['acc_amt'];
			$sum_lttrs = $sql_arr['amt_letter'];
			$tddate = $sql_arr['acc_date'];
			$tdynams	=	date("d-m-Y", strtotime($tddate));
			$sentto = $sql_arr['to'];
			$finish = $sql_arr['bill_status'];
			$flag = 1;	
		
	
	
     	
		
		if(isset($_POST['save_buut'])){
			$invstatus='';
			$tripno = $_POST['tripno'];
			$invno	=	$_POST['invoice_nums'] ;
			$clt_cd	=	$_POST['clntcode'];
			$amt	=	$_POST['amount'];
			$sum_lttrs = $_POST['sum_in_letters'];
			$tddate = $_POST['todaydate'];
			$tdynams	=	date("Y-m-d", strtotime($tddate));
			$getinvcnt= explode("-",$invno);	
			$sentto = $_POST['received_to'];
			if(isset($_POST['invoicestatus']))
			{
				$invstatus = $_POST['invoicestatus'];
			}
			else
			{
				$invstatus = 0;
			}
			
			//echo "update cf_receipt set acc_date='$tdynams',acc_amt = '$amt',amt_letter='$sum_lttrs',`to`='$sentto',bill_status='$invstatus' where trip_id ='$tripno'";
			//exit;
						
			$sqlupdate = mysql_query("update cf_receipt set acc_date='$tdynams',acc_amt = '$amt',amt_letter='$sum_lttrs',`to`='$sentto',bill_status='$invstatus' where trip_id ='$tripno'");
			header('Location: gen-bill-list.php');
						
			
			
			
		}
		
	
				

?>
<!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:800px;
	margin:0 auto;
	padding-bottom:15px;
}
.ptForm {
	/*border:1px solid #000000;*/
	width:800px;
	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;
}
.ptText07 {
	font-size:14px;
	
}
.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;
}
</style>
</head>

<body>
<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; position:relative;" > <div style="float:left;width:80%;"><h1 style="float:left">Client Invoice</h1> </div> 
     <div style="float:right;  margin-bottom:10px;width:19%; ">

     <div style="width:47%; float:left; margin-right:8px; margin-top:5px;">
     <?php 
	 if($finish != 1)
	 {
	 ?> 
     <input type="checkbox" name="invoicestatus" id="invoicestatus" value="1" style="margin-right:3px;"   />Finished</div>	 	
	 <div style="width:20%;float:left;margin-right:32px;"><button name="save_buut" type="submit" value="save" class="submit-btn" onClick="return validation()" style="margin-top:0px;" >Save</button> <?php } ?></div>
     <div style="width:10%;float:left;margin-right:3px;"><input type="submit" value="Print" class="submit-btn" onClick="printDiv('printableArea');" style="margin-top:0px;"   > </div>
		
   
      </div>
      </div>

   
   <div class="addEmp" style="margin-bottom:0px; border-bottom:0px solid;width:1000px;float:left;">
   <div class="div01" id="printableArea">
<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 
     if(!empty($_REQUEST['trip_id']))
	 {
	 	$tripid = $_REQUEST['trip_id'];
	 }
	 ?>
     <input name="tripno" type="hidden" class="tripno" value="<?=$tripid?>"  />
    <tr>
      <td  colspan="4"  class="ptText02" style="width:77%;">No
      <input name="invoice_nums" type="text" class="field01" value="<?=$clientno?>"  readonly="readonly"/>
       </td>
      <td class="ptText02"  style="text-align:left;">Date
        <input name="todaydate" type="text" class="field01" value="<?=date('d-m-Y')?>" id="todaydate"  /></td>
    </tr>
   
   <tr>
      <td  colspan="4"  class="ptText02" style="width:77%;">Client Code
      <input name="clntcode" id="clntcode" type="text" class="field01"  value="<?=$clt_cd?>" readonly="readonly"/>
       </td>
      <td class="ptText02"  style="text-align:left;">&nbsp;&nbsp;</td>
    </tr>   
  
   <tr>
      <td  colspan="5"  class="ptText02" style="width:100%;">RS
        <input name="amount" id="amount" type="text" class="field01" style="width:19%;" onKeyUp="changeval()"  <?php if($finish == 1) { ?> readonly="readonly" <?php } ?>   value="<?=$amt?>"/></td>
    </tr>

    <tr>
      <td  colspan="5"  class="ptText02" style="width:100%;">PAID  THE SUM  OF RUPEES
      <input name="sum_in_letters" id="sum_in_letters" type="text" class="field01" style="width:79%;" value="<?=$sum_lttrs?>" readonly="readonly" />
       </td>
    </tr>
    
    <tr>
      <td  colspan="5"  class="ptText02" style="width:100%;">TO
        <input name="received_to" type="text" class="field01" style="width:78%;" value="<?=$sentto?>" id ='received_to' <?php if($finish == 1) { ?> readonly="readonly" <?php } ?> /></td>
    </tr>
    
   
    
    
    
    <tr>
      <td  colspan="5" >&nbsp;</td>
    </tr>
   <tr>
      <td colspan="2" class="ptText07"> <input name="" type="text" class="field02"  /></td>
 
       <td colspan="2" class="ptText07" ><input name="" type="text" class="field02"  /></td>

      <td class="ptText07"><input name="" type="text" class="field02"  /></td>
    </tr>
<tr>
      <td colspan="2" class="ptText07">MANAGER</td>
 
       <td colspan="2" class="ptText07" >NAME & SIGNATURE</td>

      <td class="ptText07">RECEIVED PAYMENT</td>
    </tr>
 
    <tr>
      <td>&nbsp;</td>
      <td>&nbsp;</td>
      <td>&nbsp;</td>
      <td>&nbsp;</td>
      <td>&nbsp;</td>
    </tr>
  </table>
</div>
<div style="text-align:center;">

</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>


		






