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

$bill_id = $conn->real_escape_string($_POST['bill_id']);

if($_POST[payment_amount]>"0"){
	
 	
$payment_amount = $conn->real_escape_string($_POST['payment_amount']);	
$pay_methode = $conn->real_escape_string($_POST['pay_methode']);	
 
$cdate=dtformat($_POST[cdate]);
	
	
//----------------------customer entry -------------------------
$dresult=mysql_query("select all_payment_total,last_due from restaurant_chalan WHERE id='$bill_id' limit 1");
$drow=mysql_fetch_array($dresult);
	
$all_payment_total=$drow[all_payment_total]+$payment_amount;
$last_due=$drow[last_due]-$payment_amount;
	
mysql_query("update restaurant_chalan set all_payment_total='$all_payment_total',last_due='$last_due' where  id='$bill_id'");


//----------------------customer entry -------------------------
	
	  $user_ip = getUserIP(); 	
	  
 mysql_query("INSERT INTO restaurant_chalan_payment (
 
 id ,bill_id ,cdate, payment_amount,pay_methode ,suser ,created_at,user_ip
 
 )VALUES (
 
 NULL , '$bill_id','$cdate', '$payment_amount', '$pay_methode','$_SESSION[uid]',CURRENT_TIMESTAMP,'$user_ip')");

 
//----------------------Booking  -------------------------
	
 
//----------------------end Booking  -------------------------
header("location:restaurant_due_payment.php?cid=$bill_id&info=Payment Updated");
}else{
header("location:restaurant_due_payment.php?cid=$bill_id&info=Payment Amount is $_POST[payment_amount]");
}
?>