<?
session_start();
$brcode=$_SESSION['brcode'];
include_once('opendb.php');
$icode=$_REQUEST['icode'];
if(isset($_POST['save']))
{
$icode=$_REQUEST['icode'];
$code=$_REQUEST['code'];
$supname=$_REQUEST['supname'];
$addr1=$_REQUEST['addr1'];
$addr2=$_REQUEST['addr2'];
$city=$_REQUEST['city'];
$district=$_REQUEST['district'];
$state=$_REQUEST['state'];
$pin=$_REQUEST['pin'];
$phone1=$_REQUEST['phone1'];
$tin=$_REQUEST['tin'];
$cst=$_REQUEST['cst'];
$email=$_REQUEST['email'];
$suptype=$_REQUEST['suptype'];
$web=$_REQUEST['web'];
$msmetyp=$_REQUEST['msmetyp'];
$msmeno=$_REQUEST['msmeno'];
$msmetype1=$_REQUEST['msmetype1'];

$sql="update sup_master set addr1='$addr1',addr2='$addr2',city='$city',dist='$district',stat='$state',pin='$pin',phone1='$phone1',tin='$tin',cst='$cst',email='$email',suptype='$suptype' ,web='$web',msmetyp='$msmetyp',msmetype1='$msmetype1',msmeno='$msmeno' where icode='$icode'";
mysqli_query($db,$sql) or die('Insert Err:'.mysqli_error($db));
/*
$acname1=$supname;
$re=mysqli_query($db,"select * from ledger where led='$acname1' 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('$acname1','Sundry Creditors','0','Cr','$scode','$brcode')";
 mysqli_query($db,$sql) or die(mysqli_error($db));
 print"ledger inserted";
 
}

*/
 if(strlen($cst)>0)
 {
     //print $cst;

     $rrr="select * from partymaster where gst='$cst' ";
     //print $rrr;
      
 $re=mysqli_query($db,"select * from partymaster where gst='$cst' ") or die(mysqli_error($db));
 if(mysqli_num_rows($re)<=0)
    {
     $sql1="insert into partymaster (brcode,code,cname,addr1,dist1,state1,pin1,phone1,phone2,email,gst,pan,ptype) 
                 values('$brcode','$scode','$supname','$addr1','$district','$state','$pin','$phone1','$phone2','$email','$cst','$pan','SUP')";
 	     // print "$sql1<br>";
 	       mysqli_query($db,$sql1) or die('Insert Err1:'.mysqli_error($db));

   }
}


print "<script> document.location='supp-mast.php';</script>";
//return;
}
//$re=mysqli_query($db,"select * from configmaster");
//$row=mysqli_fetch_array($re);
?>
<link rel="stylesheet" href="style.css" type="text/css" />
<script type="text/javascript" src="scripts/jquery-latest.js"></script>
<link type="text/css" href="includes/style1.css" rel="stylesheet" />
<link rel="stylesheet" href="css/form.css" type="text/css" />
<script type="text/javascript">
        $(function() {
          if ($.browser.msie && $.browser.version.substr(0,1)<7)
          {
			$('li').has('ul').mouseover(function(){
				$(this).children('ul').show();
				}).mouseout(function(){
				$(this).children('ul').hide();
				})
          }
        });        
</script>
<script>
this.resizeTo(750,170);
function valid()
{
 
 /*if(document.f1.tax.value.length<=0)
 {
   alert("Invalid Tax.");
   document.f1.tax.focus();
   return false;
 }*/

}
</script>
<style>
#txt{
font-family: Arial, Helvetica;
background-color: #F2F2F2;

}
th{background-color:steelblue;color:white}
</style>
<?php include('includes/top.php'); ?>
<table class='container'><tr><td>
<font style="font-family: 'Trebuchet MS',Verdana,Helvetica,sans-serif; font-size:15px;">  &nbsp;&nbsp;Master >> Supplier >> Edit Supplier</font>
<br>
<center>

<?
$re=mysqli_query($db,"select * from sup_master where icode='$icode'");
//print $r=("select * from sup_master where icode='$icode'");

$rerow=mysqli_fetch_array($re);
?>
<table cellspacing=1 cellpadding=1 bgcolor=black >
<tr><td align=center bgcolor='white'>
<form name='f1' action='<?print $PHP_SELF?>' method='post' onSubmit="return valid()">
<input type=hidden name=code value='<?print $code?>'>
<table cellspacing=1 cellpadding=3 width='350' class=form>
<th colspan=2><font size=3 color=black>EDIT SUPPLIER MASTER</th>
<tr style={background:yellow}><td>Supplier Name <BR>
 <FONT SIZE=1 color=red>(Non editable)</font></td>
  <td><input type=text name='supname' size=40 readonly value='<?print $rerow['supname']?>' onKeyDown=chkey(this); style={color:red} title='As it will create A/c head, it cannot be edited'></td></tr>
<tr bgColor='c1d7bb'><td>Sup Type </td><td><select name='suptype'>
<option><?print $rerow[15]?> </option>
<option value='Interstate'>Interstate</option>
<option value='Instate'>Projects - Instate</option>
<option value='Insidestate'>Others - Insidestate</option>
</select>
</td></tr>

<tr ><td>Address1 </td><td><input type=text name='addr1' size=40 value='<?print $rerow[2]?>' onKeyPress='return handleEnter(this, event)'></td></tr>
<tr ><td>Bank Name</td><td><input type=text name='addr2' size=40 value='<?print $rerow[3]?>' onKeyPress='return handleEnter(this, event)'></td></tr>
<tr ><td>Branch</td><td><input type=text name='city' size=40 value='<?print $rerow[4]?>' onKeyPress='return handleEnter(this, event)'></td></tr>
<tr ><td>Account No</td><td><input type=text name='district' size=40 value='<?print $rerow[5]?>' onKeyPress='return handleEnter(this, event)'></td></tr>


<tr><td>State</td><td><select name='state' id=state><option><?print $rerow[6]?></option><option>Kerala</option><option>Tamil Nadu</option><option>Karnataka</option><option>Andhra Pradesh</option>
<option>Arunachal Pradesh</option><option>Assam</option><option>Bihar</option><option>Chandigarh</option><option>Chhattisgarh</option>
<option>Dadra and Nagar Haveli</option><option>Daman and Diu</option><option>Delhi</option><option>Goa</option>
<option>Gujarat</option><option>Haryana</option><option>Himachal Pradesh</option><option>Jammu and Kashmir</option>
<option>Jharkhand</option><option>Madhya Pradesh</option><option>Maharashtra</option><option>Manipur</option>
<option>Meghalaya</option><option>Mizoram</option><option>Nagaland</option><option>Orissa</option>
<option>Puducherry</option><option>Punjab</option><option>Rajasthan</option><option>Sikkim</option><option>Telangana</option>
<option>Tripura</option><option>Uttar Pradesh</option><option>Uttarakhand</option><option>West Bengal</option>
    </select>
</td></tr>

<tr ><td>Pin No </td><td><input type=text name='pin' size=40 value='<?print $rerow[7]?>' onKeyPress='return handleEnter(this, event)'></td></tr>
<tr ><td>Phone1 </td><td><input type=text name='phone1' size=40 value='<?print $rerow[8]?>' onKeyPress='return handleEnter(this, event)'></td></tr>
<tr ><td>Tin NO </td><td><input type=text name='tin' size=40 value='<?print $rerow[10]?>' onKeyPress='return handleEnter(this, event)'></td></tr>
<tr ><td>GSTIN</td><td><input type=text name='cst' size=40 value='<?print $rerow[11]?>' onKeyPress='return handleEnter(this, event)'></td></tr>
<tr><td>Email_id </td><td><input type=text name='email' size=40 value='<?print $rerow[12]?>' onKeyPress='return handleEnter(this, event)'></td></tr>

<tr><td>ledger </td><td><input type=text name='web' size=80 value='<?print $rerow[13]?>' onKeyPress='return handleEnter(this, event)'></td></tr>

<tr bgColor='c1d7bb'><td>MSME </td><td><select name='msmetyp'>
<option value='<?print $rerow[17] ?>'><?print $rerow[17]?> </option>
<option value='NO'>NO</option>
<option value='YES'>YES</option>
</select>
</td></tr>
<tr ><td>MSME NO </td><td><input type=text name='msmeno' value='<?print $rerow[18]?>' size=40 ></td></tr>
<tr bgColor='c1d7bb'><td>MSME TYPE</td><td><select name='msmetype1'>
    <option value='<?print $rerow[19] ?>'><?print $rerow[19]?> </option>
    <option value='MICRO'>MICRO</option>
<option value='SMALL'>SMALL</option>
<option value='MEDIUM'>MEDIUM</option>


</select>
</td></tr>
<th colspan=2><input type=submit value='Save' name='save'> <input type=button value='Cancel' onClick='window.location="supp-mast.php"'></td></tr>

</table>
</form>
</td></tr>
</table>
