<?php ob_start();
include("config.php");

$cdate=dtformat($_POST[tdate]);
include("config2.php");
 

 
$vat_amount = $conn->real_escape_string($_POST['vat_amount']);	
$vat = $conn->real_escape_string($_POST['vat']);	
$total_price = $conn->real_escape_string($_POST['total_price']);	
$discount = $conn->real_escape_string($_POST['discount']);	
	
$total_payeble = $conn->real_escape_string($_POST['total_payeble']);	
$payment = $conn->real_escape_string($_POST['payment_amount']);	
$pay_methode = $conn->real_escape_string($_POST['pay_methode']);	
$due = $conn->real_escape_string($_POST['due']);
$mvn = $conn->real_escape_string($_POST['mvn']);
		
  $user_ip = getUserIP(); 	  	 	 


$adresult=mysql_query("select bill_id from bill WHERE customer_id='$_POST[client]' order by cdate desc limit 1");
$adrow=mysql_fetch_array($adresult);



mysql_query("insert into restaurant_chalan (id ,cdate ,com_id ,client_id ,discount,vat,vat_amount,total_payeble,payment,pay_methode,due,all_payment_total,last_due,remarks,suser,user_ip,hbill_id,mvn)VALUES (NULL , '$cdate','$_POST[company]', '$_POST[client]','$discount','$vat','$vat_amount','$total_payeble','$payment','$pay_methode','$due','$payment','$due', '$_POST[remarks]', '$_SESSION[uid]','$user_ip','$adrow[bill_id]','$mvn')");
 
 
mysql_query("UPDATE restaurant_chalan_product SET client='$_POST[client]',date1='$cdate' where cid='$_POST[cid]'");


header("location:restaurant_chalan_view.php?cid=$_POST[cid]");
?> 