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


/********************************** ADD ***************************************/
if($_POST['action']=='ADD')
{
$company_name=ucfirst($_POST['company_name']);
$address1=$_POST['address1'];
$address2=$_POST['address2'];
$address3=$_POST['address3'];
$cinno=$_POST['cinno'];
$cstno=$_POST['cstno'];
$tinno=$_POST['tinno'];
$session_user_name=$_POST['session_user_name'];
$session_territory_id=$_POST['session_territory_id'];
$create_date=date('Y-m-d');
$acadamic_yr=explode("-",$create_date);
$acdmc_yr_res=$acadamic_yr[0];
$Insql=mysql_query("insert into company_name(company_name,address_1,address_2,address_3,tin_no,cst_no,cin_no,created_date)values('$company_name','$address1','$address2','$address3','$tinno','$cstno','$cinno','$create_date')");
echo "Successfully Added";
}
/*********************************** UPDATE QUERY *********************************************/
if($_POST[action]=='EDIT')
{
$edit_id=$_POST['edit_id'];
$company_name=ucfirst($_POST['company_name']);
$address1=$_POST['address1'];
$address2=$_POST['address2'];
$address3=$_POST['address3'];
$cinno=$_POST['cinno'];
$cstno=$_POST['cstno'];
$tinno=$_POST['tinno'];
$session_user_name=$_POST['session_user_name'];
$session_territory_id=$_POST['session_territory_id'];
$active_status=$_POST['active_status'];
$create_date=date('Y-m-d');
$acadamic_yr=explode("-",$create_date);
$acdmc_yr_res=$acadamic_yr[0];
$Insql=mysql_query("update company_name SET company_name='$company_name',address_1='$address1',address_2='$address2',address_3='$address3',tin_no='$tinno',cst_no='$cstno',cin_no='$cinno',created_date='$create_date' where c_id='$_POST[edit_id]'");
echo "Updated Successfully!!";

}

/**********************************************************************************************/
if($_POST[action]== 'delete_customer')
{
 $Insql=mysql_query("delete from company_name where c_id='$_POST[id]'");
 include("company_entry_list.php");

}
?>
