<?php
if (isset($_POST["action"])) {
    
	$output = '';
	require('../config/dbcon.php');
	if ($_POST["action"] == "Update") {
	    
		$id = mysqli_escape_string($connect, $_POST["id"]);
		$date_one = mysqli_escape_string($connect, $_POST["date_one"]);
		$bill_number = mysqli_escape_string($connect, $_POST["bill_number"]);
		$bill_date = mysqli_escape_string($connect, $_POST["bill_date"]);
		$party_name = mysqli_escape_string($connect, $_POST["party_name"]);
		$party_place = mysqli_escape_string($connect, $_POST["party_place"]);
		$truck_number = mysqli_escape_string($connect, $_POST["truck_number"]);
		$truck_owner_name = mysqli_escape_string($connect, $_POST["truck_owner_name"]);
		$supp_name = mysqli_escape_string($connect, $_POST["supp_name"]);
		$supp_place = mysqli_escape_string($connect, $_POST["supp_place"]);
		$inv_number = mysqli_escape_string($connect, $_POST["inv_number"]);
		$lchno = mysqli_escape_string($connect, $_POST["lchno"]);
		$lrno = mysqli_escape_string($connect, $_POST["lrno"]);
		$placefrom = mysqli_escape_string($connect, $_POST["placefrom"]);
		$destination = mysqli_escape_string($connect, $_POST["destination"]);
		$weight = mysqli_escape_string($connect, $_POST["weight"]);
		$booking_rate = mysqli_escape_string($connect, $_POST["booking_rate"]);
		$lorry_freight = mysqli_escape_string($connect, $_POST["lorry_freight"]);
		$advance = mysqli_escape_string($connect, $_POST["advance"]);
		$cash_advance = mysqli_escape_string($connect, $_POST["cash_advance"]);
		$diesel = mysqli_escape_string($connect, $_POST["diesel"]);
		$neft_amount = mysqli_escape_string($connect, $_POST["neft_amount"]);
		$neft_date = mysqli_escape_string($connect, $_POST["neft_date"]);
		$others = mysqli_escape_string($connect, $_POST["others"]);
		$extra = mysqli_escape_string($connect, $_POST["extra"]);
		$mamul_charges = mysqli_escape_string($connect, $_POST["mamul_charges"]);
		$balance = mysqli_escape_string($connect, $_POST["balance"]);
		$total_paid = mysqli_escape_string($connect, $_POST["total_paid"]);
		$profit = mysqli_escape_string($connect, $_POST["profit"]);
		$payment_amount = mysqli_escape_string($connect, $_POST["payment_amount"]);
		$rupeesinwords = mysqli_escape_string($connect, $_POST["rupeesinwords"]);
		
		$update = "update bill_mst set booking_rate = '" . $booking_rate . "',lorry_freight = '" . $lorry_freight . "',advance = '" . $advance . "',cash_advance = '" . $cash_advance . "',diesel = '" . $diesel . "',neft_amount = '" . $neft_amount . "',neft_date = '" . $neft_date . "',others = '" . $others . "',extra = '" . $extra . "',mamul_charges = '" . $mamul_charges . "',balance = '" . $balance . "',total_paid = '" . $total_paid . "',profit = '" . $profit . "',payment_amount = '" . $payment_amount . "',rupeesinwords = '" . $rupeesinwords . "' where id = '" . $id . "'";
		if (mysqli_query($connect, $update)) {
		    $update1 = "update audit_mst set booking_rate = '" . $booking_rate . "',lorry_freight = '" . $lorry_freight . "',advance = '" . $advance . "',cash_advance = '" . $cash_advance . "',diesel = '" . $diesel . "',neft_amount = '" . $neft_amount . "',neft_date = '" . $neft_date . "',others = '" . $others . "',extra = '" . $extra . "',mamul_charges = '" . $mamul_charges . "',balance = '" . $balance . "',total_paid = '" . $total_paid . "',profit = '" . $profit . "',payment_amount = '" . $payment_amount . "',rupeesinwords = '" . $rupeesinwords . "' where id = '" . $id . "'";
    		if (mysqli_query($connect, $update1)) {
    		    
    		}
		}
		
	}
	if ($_POST["action"] == "Delete") {
		$delete = "Delete from bill_mst where id = '" . $_POST["id"] . "'";
		if (mysqli_query($connect, $delete)) {
		    
		}
	}
	
}