<?php
error_reporting(0);
include("../../include/db.php");

/***************************** Main Add***********************************************************/
if(($_POST['action']=="PAY")) 
{
$book_no=$_POST['book_no'];
$booking_date=$_POST['booking_date'];
$booking_place=$_POST['booking_place'];
$booking_branch=$_POST['booking_branch'];
$pay_to_pay_val=$_POST['pay_to_pay_val'];
$from_party_name=$_POST['from_party_name'];
$from_address=$_POST['from_address'];
$from_mob_no=$_POST['from_mob_no'];
$to_party_name=$_POST['to_party_name'];
 $to_party_address=$_POST['to_party_address'];
$to_party_mob=$_POST['to_party_mob'];
$st_charges=$_POST['st_charges'];
$tot_amt=$_POST['tot_amt'];
$remarks=$_POST['remarks'];
$create_date1=date('Y-m-d');
$acadamic_yr=explode("-",$create_date1);
$acdmc_yr_res=$acadamic_yr[0];
$Insql1=mysql_query("insert into booking_main_list(booking_no,book_date,book_place,book_branch,pay_type,from_party_name,from_party_address,from_party_mob,to_party_name,to_party_addrs,to_party_mob,unloading_st_charge,tot_amt,remarks,acad_yr,cr_date)values('$book_no','$booking_date','$booking_place','$booking_branch','$pay_to_pay_val','$from_party_name','$from_address','$from_mob_no','$to_party_name','$to_party_address','$to_party_mob','$st_charges','$tot_amt','$remarks','$acdmc_yr_res','$create_date1')");
}
/***************************** Main Update***********************************************************/
if($_POST['action']=="UPDATE")
{
$edit_ids=$_POST['edit_id'];
$book_no=$_POST['book_no'];
$booking_date=$_POST['booking_date'];
$booking_place=$_POST['booking_place'];
$booking_branch=$_POST['booking_branch'];
$pay_to_pay_val=$_POST['pay_to_pay_val'];
$from_party_name=$_POST['from_party_name'];
$from_address=$_POST['from_address'];
$from_mob_no=$_POST['from_mob_no'];
$to_party_name=$_POST['to_party_name'];
$to_party_address=$_POST['to_party_address'];
$to_party_mob=$_POST['to_party_mob'];
$st_charges=$_POST['st_charges'];
$tot_amt=$_POST['tot_amt'];
$remarks=$_POST['remarks'];
$create_date1=date('Y-m-d');
$acadamic_yr=explode("-",$create_date1);
$acdmc_yr_res=$acadamic_yr[0];
  $Upsq12="update booking_main_list set booking_no='$book_no',book_date='$booking_date',book_place='$booking_place',book_branch='$booking_branch',pay_type='$pay_to_pay_val',from_party_name='$from_party_name',from_party_address='$from_address',from_party_mob='$from_mob_no',to_party_name='$to_party_name',to_party_addrs='$to_party_address',to_party_mob='$to_party_mob',unloading_st_charge='$st_charges',tot_amt='$tot_amt',remarks='$remarks',acad_yr='$acdmc_yr_res',
  cr_date='$create_date1' where id='$_POST[edit_id]'";
 mysql_query($Upsq12) or die(error);
}
 /**********************************SUB ADD  QUERY ***************************************/
 if($_POST['action']=="ADD")
	{
	  $book_no=$_POST['book_no'];
      $booking_date=$_POST['booking_date'];
      $booking_place=$_POST['booking_place'];
      $booking_branch=$_POST['booking_branch'];
      $pay_to_pay_val=$_POST['pay_to_pay_val'];
      $book_particulars=$_POST['book_particulars'];
      $weight=$_POST['weight_kg'];
      $rates=$_POST['rates'];
      $freight_rs=$_POST['freight_rs'];
      $create_date1=date('Y-m-d');
	  $acadamic_yr=explode("-",$create_date1);
      $acdmc_yr_res=$acadamic_yr[0];
 
$Insql1=mysql_query("insert into booking_sub_list(book_no,book_date,book_place,book_branch,pay_type,particulars,weight_kg,kg_rate,frieght_charge,acad_yr,cr_date	 )values('$book_no','$booking_date','$booking_place','$booking_branch','$pay_to_pay_val','$book_particulars','$weight','$rates','$freight_rs','$acdmc_yr_res','$create_date1')");
include("booking_sublist.php");
}
 /**********************************SUB Edit  QUERY ***************************************/
	if($_POST['action']=="EDIT")
    {
      $id=$_POST['edit_id'];
      $book_no=$_POST['book_no'];
      $booking_date=$_POST['booking_date'];
      $booking_place=$_POST['booking_place'];
      $booking_branch=$_POST['booking_branch'];
      $pay_to_pay_val=$_POST['pay_to_pay_val'];
      $book_particulars=$_POST['book_particulars'];
      $weight=$_POST['weight_kg'];
      $rates=$_POST['rates'];
      $freight_rs=$_POST['freight_rs'];
      $create_date1=date('Y-m-d');
	  $acadamic_yr=explode("-",$create_date1);
      $acdmc_yr_res=$acadamic_yr[0];
	
   $Upsql1="update booking_sub_list set book_no='$book_no',book_date='$booking_date',
book_place='$booking_place',book_branch='$booking_branch',pay_type='$pay_to_pay_val',particulars='$book_particulars',weight_kg='$weight',kg_rate='$rates',frieght_charge='$freight_rs',acad_yr='$acdmc_yr_res',cr_date='$create_date1' where sub_id='$_POST[edit_id]'";
   mysql_query($Upsql1);
  
include("booking_sublist.php");
}
/******************************************** SUB DELETE*****************************************************************/
if($_POST['action']=="del_book_sublist")
{ 		 
		      $delete1="delete from booking_sub_list where sub_id='$_POST[id]'";
			 mysql_query($delete1);
			 
			 include("booking_sublist.php");
}
/******************************************** Main DELETE*****************************************************************/
if($_POST['action']=="delete_book_main")
{ 		 
  $delete2="delete from booking_main_list where id='$_POST[id]' and booking_no='$_POST[booking_no]'";
   mysql_query($delete2);

  $Delsql5="delete from booking_sub_list where  book_no='$_POST[booking_no]' ";
  mysql_query($Delsql5);
  
  include("booking_entry_list.php");

  $msg="<span class='success'>Successfully Deleted </span>";
  echo $msg;
}
?>