<?
include_once('includes/top.php');
include_once('opendb.php');
$brcode=$_SESSION['brcode'];
$user=$_SESSION['user'];
//$br=$_SESSION['branch'];
if(strlen($user)<=0)
{
  print "<script> alert('Invalid User'); document.location='inde.php' </script>";
  return;
}

?>
<title>AMPL EICHER</title>
<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>
<style>
#txt{
font-family: Arial, Helvetica;
background-color:#F2F2F2;

}
th{background-color:steelblue;color:white}
table.form{
font-weight: normal;border:1px;
} 
</style>
<body>

<?php //include('includes/top.php'); ?>

<table class="container" style="background-color:#F6E3CE" ><tr><td>
<font style="font-family: 'Trebuchet MS',Verdana,Helvetica,sans-serif; font-size:15px; color:black;">  &nbsp;&nbsp;Master >> Customer Master</font>
<br>

<link rel="stylesheet" href="style.css" type="text/css" />
<script>
function valid()
{ 
 subOK="false";
 x=confirm("Do you want to save?");
 if(x)
  subOK="true";
   if(subOK=="true")
     return true;
   else
     return false;
} 

function chkey(abc)
{
 yy=abc.value
 if(yy.length>35)
 { 
   alert('Name exeeds the limit');
   return;
 }

 if(yy.indexOf('  ')>-1) 
  {
    alert('Multiple space is not allowed');
    abc.value='';
  }
 if(yy.indexOf("'")>-1) 
  {
    alert("\' is not allowed");
    abc.value='';
  }
 if(yy.indexOf('"')>-1) 
  {
    alert("\" is not allowed");
    abc.value='';
  }

}
</script>
<script type="text/javascript">

/***********************************************
* Disable "Enter" key in Form script- By Nurul Fadilah(nurul@REMOVETHISvolmedia.com)
* This notice must stay intact for use
* Visit http://www.dynamicdrive.com/ for full source code
***********************************************/
                
function handleEnter (field, event) {
		var keyCode = event.keyCode ? event.keyCode : event.which ? event.which : event.charCode;
		if (keyCode == 13) {
			var i;
			for (i = 0; i < field.form.elements.length; i++)
				if (field == field.form.elements[i])
					break;
			i = (i + 1) % field.form.elements.length;
			field.form.elements[i].focus();
			return false;
		} 
		else
		return true;
	}      

</script>

<center>
<form action='svcustomer.php' onSubmit="return valid()">
<table cellspacing=1 cellpadding=2 class='form'>
<tr height=21><td colspan=2 align=center bgcolor='steelblue'><FONT COLOR=white><B>CUSTOMER MASTER</td></tr>
</td></tr>
<tr><td>Customer Name</td><td><input type=text name='cname' class='ent' onKeyPress="return handleEnter(this, event)" size=40 onKeyDown=chkey(this);></td></tr>

<tr><td>Corporate </td><td><select name='corp' onKeyPress="return handleEnter(this, event)"><option>-</option>
<?
$re=mysqli_query($db,"select * from corp_master where branch='$brcode'  order by corpname");
while($row=mysqli_fetch_row($re))
{
 print "<option>$row[1]</option>";
}
?>
</select>
</td></tr>
<tr><td>Customer Type</td><td><select name='custype' onKeyPress="return handleEnter(this, event)"><option>-select-</option>
<option value='Interstate'>Interstate</option>
<option value='Projects'>Projects - Instate</option>
<option value='Others'>Others - Insidestate</option>
</select>
</td></tr>
<tr><td>Address1</td><td><input type=text name='addr1' size=40 onKeyPress="return handleEnter(this, event)"></td></tr>
<tr><td>Address2</td><td><input type=text name='addr2' size=40 onKeyPress="return handleEnter(this, event)"></td></tr>
<tr><td>Address3</td><td><input type=text name='addr3' size=40 onKeyPress="return handleEnter(this, event)"></td></tr>
<tr><td>District</td><td><input type=text name='district' size=6 onKeyPress="return handleEnter(this, event)"></td></tr>
<tr><td>State</td><td><input type=text name='state' size=6 onKeyPress="return handleEnter(this, event)"></td></tr>
<tr><td>Pin</td><td><input type=text name='pin1' size=6 onKeyPress="return handleEnter(this, event)"></td></tr>
<tr><td>Phone</td><td><input type=text name='phone1' size=40 onKeyPress="return handleEnter(this, event)"></td></tr>


<tr><td>Email_id </td><td><input type=text name='email' size=40 onKeyPress="return handleEnter(this, event)"></td></tr>


<tr><td colspan=2>TIN <input type=text name='tin' size=10 onKeyPress="return handleEnter(this, event)">
GST <input type=text name='cst' size=10 onKeyPress="return handleEnter(this, event)">
PAN <input type=text name='kgst' size=10></td></tr>



<tr><td colspan=2 align=center bgcolor='lightsteelblue'>
<input type=submit value='Save' name='sv'> <input type=button value='Cancel'>
</td></tr>
</table>
</form>
<table cellspacing=1 cellpadding=3 class='report' >
<th>No.<th>Customer Id <th>Name <th>A/C Name<th>Address  <th> Pin <th>Phone<th>Action
<?
$re=mysqli_query($db,"select * from customer where brcode='$brcode' order by cname")or die(mysqli_error($db));
$i=1;
while($row=mysqli_fetch_array($re))
{
 print "\n<form action='editcust.php'>\n<input type=hidden name='code' value='$row[1]'><input type=hidden name='cname' value='$row[3]'>";
 print "\n<tr ><td>".$i++."</td><td>$row[code]</td><td>$row[cname]</td><td>$row[acname]</td><td>$row[addr1]</td><td>$row[pin1]</td><td>$row[phone1]</td>";
 print "<td>\n<input type=submit value='Edit' name='edit'></td></tr></form>";
}
?>
</table>

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

