<?
session_start();
$brcode=$_SESSION['brcode'];
$user=$_SESSION['user'];
//$br=$_SESSION['branch'];
if(strlen($user)<=0)
{
  print "<script> alert('Invalid User'); document.location='inde.php' </script>";
  return;
}
include ("opendb.php");
$addr1=$_REQUEST['addr1'];
$addr2=$_REQUEST['addr2'];
$city=$_REQUEST['city'];
$district=$_REQUEST['district'];
$state=$_REQUEST['state'];
$pin=$_REQUEST['pin'];
$phone1=$_REQUEST['phone1'];
$email=$_REQUEST['email'];
$tin=$_REQUEST['tin'];
$cst=$_REQUEST['cst'];
$suptype=$_REQUEST['suptype'];
$supname=$_REQUEST['supname'];

 $code=substr($supname,0,3).substr(time(),7,3); 
 $code=str_replace(' ','-',$code);
 $supname=strtoupper($supname);
 $sql="insert into sup_master(code,supname,addr1,addr2,city,dist,stat,pin,phone1,tin,cst,email,branch,suptype) values('$code','$supname','$addr1','$addr2','$city','$district','$state','$pin','$phone1','$tin','$cst','$email','$brcode','$suptype')";

 mysqli_query($db,$sql);
 $re=mysqli_query($db,"select * from ledger where led='$supname' and grp='Sundry Creditors' and brcode='$brcode'") or die(mysqli_error($db));
 if(mysqli_num_rows($re)>0)
    {
     //print "<script> alert('Supplier A/c already exists'); history.back(1);  </script>";
     //return;
   }
else
{
 $sql="insert into ledger(led,grp,op,drcr,code,brcode) values('$supname','Sundry Creditors','0','Cr','$code','$brcode')";
 mysqli_query($db,$sql) or die(mysqli_error($db));
}

?>
<div id="adnw_panel" class="itemalist" style="display:none;position: absolute;">
  <table  border='1' class='conf_tbl' style="border_collpase:collapse;background-color:white;  " width='100%'>
  
 	  <tr><th colspan=2>Added Item  <?echo $pcode;?>     <input type="button" value='x' id='close' onclick='updclose_div();'/></th></tr>

      
  </table>


</div>






