<?php include 'header.php';?>
<script>

      $(document).on('change',".gstinnumber", function(){    

        var inputvalues = $(this).val();

        var gstinformat = new RegExp('^[A-Z]{5}[0-9]{4}[A-Z]{1}[1-9A-Z]{1}Z[0-9A-Z]{1}$');

        

        if (gstinformat.test(inputvalues)) {

         return true;

        } else {

            alert('Please Enter Valid GSTIN Number');

            $(".gstinnumber").val('');

            $(".gstinnumber").focus();

        }

        

    });
 
	 



    </script>
<?php $querylogin = "select * from  mst_users where user_name = '". $_SESSION["LOGIN_NAME"]."' AND password = '".$_SESSION["EMPLOYEE_PASSWORD"]."'";

$resultlogin = mysqli_query($conn,$querylogin);

while($row=mysqli_fetch_array($resultlogin))

{

$user_name = $row['user_name'];

$user_id = $row['user_id'];

$first_name = $row['first_name'];

 $login_type_admin=$row['login_type']; 

}

$query1 = "select * from authority_staff_module where user_id='$user_id' and module_name='CUSTOMER' ";

$result1 = mysqli_query($conn,$query1);		

while($row=mysqli_fetch_array($result1))

{

$add_authority = $row['add_authority'];

$edit_authority = $row['edit_authority'];

$view_authority=$row['view_authority'];

}

?>
<? 

$queryls = "select * from mst_customer where customer_id = '".$_REQUEST['customer_id']."'";

$resultls = mysqli_query($conn,$queryls);	

while($row=mysqli_fetch_array($resultls))

{



$billing_address=$row['billing_address'];
$state=$row['state'];
$location=$row['location'];
$state_code=$row['state_code'];
$billing_GST_no=$row['billing_GST_no'];
$billing_PAN_no=$row['billing_PAN_no'];
$pincode=$row['pincode'];
$customer_name = $row['customer_name'];
$country = $row['country'];


$billing_contact_person=$row['billing_contact_person'];
$tel_no=$row['tel_no'];
$cell_no=$row['cell_no'];
$email_id=$row['email_id'];

$buyer_name=$row['buyer_name'];
$buyer_state=$row['buyer_state'];
$buyer_state_code=$row['buyer_state_code'];
$buyer_GST_no = $row['buyer_GST_no'];
$buyer_PAN_no=$row['buyer_PAN_no'];
$buyer_address = $row['buyer_address'];

$vendor_code = $row['vendor_code'];

$website=$row['website'];
$nature_of_company=$row['nature_of_company'];
$cust_category=$row['cust_category'];
$application=$row['application'];
$reference = $row['reference'];
$shipping_address = $row['shipping_address'];


}



?>
<?php

$maxid = "SELECT * FROM state_master WHERE stateid=(SELECT max(stateid) FROM state_master)";

$maxid1 = mysqli_query($conn,$maxid);

while($row=mysqli_fetch_array($maxid1))

{

$maxstateid = $row['stateid'];

}





?>

<script type="text/javascript">

var citiesByState = {<?php $qry9 = "select * from state_master";

$re9 = mysqli_query($conn,$qry9);

while($row=mysqli_fetch_array($re9))

{

$state = $row['state'];

$stateid = $row['stateid'];





$maxid2 = "SELECT * FROM city_master WHERE stateid='$stateid' ORDER BY id DESC LIMIT 1 ";

$maxid2a = mysqli_query($conn,$maxid2);

while($row=mysqli_fetch_array($maxid2a))

{

$maxid = $row['id'];

}

?>

<?php echo $state?>: [<?php $qry99 = "select * from city_master where stateid='$stateid' ";

$re99 = mysqli_query($conn,$qry99);

while($row=mysqli_fetch_array($re99))

		{  

		$city = $row['city'];

		$id = $row['id'];

?>"<?php echo $city?>"<?php if($maxid!=$id){?>,<?php }}?>]<?php if($maxstateid!=$stateid){?>,<?php }?><?php }?>



}



var citiesBygst = {<?php $qry96 = "select * from state_master";

$re96 = mysqli_query($conn,$qry96);

while($row=mysqli_fetch_array($re96))

{

$state = $row['state'];

$stateid9 = $row['stateid'];

$state_code = $row['state_code'];

?>

<?php echo $state?>: ["<?php echo $state_code?>"]<?php if($maxstateid!=$stateid9){?>,<?php }?>

<?php } ?>

}

function makeSubmenu(value) {

if(value.length==0) document.getElementById("citySelect").innerHTML = "<option></option>";

else {



var citiesOptions = "";

citiesOptions+=document.getElementById("citySelect").innerHTML = "<option><?php echo $bill_city;?></option>";





for(cityId in citiesByState[value]) {

citiesOptions+="<option>"+citiesByState[value][cityId]+"</option>";



}





document.getElementById("citySelect").innerHTML = citiesOptions;



var citiesOptions1 = "";

for(cityId in citiesBygst[value]) {

//citiesOptions+="<option>"+citiesByState[value][cityId]+"</option>";



}

citiesOptions1=citiesBygst[value][cityId];



document.getElementById("codegst").value = citiesOptions1;

}



}







</script>
<div class="content-page">
<div class="content">
<div class="container">
<div class="row">
<div class="col-sm-12">
<div class="page-header-title">

<button type="button" class="btn btn-dark waves-effect waves-light" onclick="location.href='view_customer.php'">BACK </button>

<div class="clearfix"></div>
</div>
</div>
</div>
<form name="chkForm" id="chkForm" action="update_customer.php"  method="post" >
<input type="hidden" name="customer_id" value="<?php echo $_REQUEST['customer_id']?>"/>

<div class="row">
<div class="col-md-12">
<div class="panel panel-primary">
<div class="panel-heading">
<h3 class="panel-title">View Customers </h3>
</div>
<div class="panel-body">
<div class="row">
<div class="col-sm-12 col-xs-12">
<div class="m-t-20">
<table class="table table-striped table-bordered dt-responsive nowrap">
<tr style="color:#000000">
<td width="238"><strong>Customer ID</strong></td>
<td width="246"><input type="text" class="form-control"  value="<?php echo $_REQUEST['customer_id']?>" readonly="readonly"/></td>
</tr>
<tr style="color:#000000">
<td><strong>Customer Name</strong></td>
<td><input type="text" class="form-control"  name="customer_name" value="<?php echo $customer_name?>"/></td>
</tr>

<tr style="color:#000000">
<td><strong>Billing Contact Person</strong></td>
<td><input type="text" class="form-control"  name="billing_contact_person" value="<?php echo $billing_contact_person?>"/></td>
</tr>
<tr style="color:#000000">
<td><strong>
Email ID</strong></td>
<td><input type="text" class="form-control"  name="email_id" value="<?php echo $email_id?>"/></td>
</tr>
<tr style="color:#000000">
<td><strong>Mobile Number</strong></td>
<td><input type="text" class="form-control"  name="tel_no" value="<?php echo $tel_no?>"/></td>
</tr>
<tr style="color:#000000">
<td><strong>Telephone Number</strong></td>
<td><input type="text" class="form-control"  name="cell_no" value="<?php echo $cell_no?>"/></td>
</tr>
<tr style="color:#000000">
<td><strong>Billing Address</strong></td>
<td><input type="text" class="form-control"  name="billing_address" value="<?php echo $billing_address?>"/></td>
</tr>
<tr style="color:#000000">
<td><strong>Country</strong></td>
<td><select name="country" class="form-control select2">
      <?php if($country!=''){?><option value="<?php echo $country?>" selected="selected"><?php echo $country?></option>
	  <?php }else {?><option value=""  selected="selected">Select Country</option><?php } ?>
      <?php 
$qry97 = "select * from country ORDER BY country_id ASC";
$re97 = mysqli_query($conn,$qry97);
while($row=mysqli_fetch_array($re97))
{
$country = $row['country'];
?>
      <option value="<?php echo $country?>"><?php echo $country?></option>
      <?php }?>
    </select></td>
</tr>
<tr style="color:#000000">
<td><strong>State</strong></td>
<td><select name="state" class="form-control" id="countrySelect" size="1" onchange="makeSubmenu(this.value)">
<?php if($bill_state!=''){?><option value="<?php echo $bill_state?>" selected><?php echo $bill_state?></option><?php }else{?>
<option value="" disabled selected>Select State</option>
<?php } ?>
<?php 
$qry97 = "select * from state_master ORDER BY state ASC";
$re97 = mysqli_query($conn,$qry97);
while($row=mysqli_fetch_array($re97))
{
$state = $row['state'];
$stateid9 = $row['stateid'];
$display_name = $row['display_name'];?>
<option value="<?php echo $state?>"><?php echo $display_name?></option>
<?php }?>
</select></td>
</tr>
<tr style="color:#000000">
<td><strong>Location</strong></td>
<td><select  class="form-control"  name="location" id="citySelect" size="1" >
<?php if($bill_city!=''){?><option value="<?php echo $bill_city?>" selected><?php echo $bill_city?></option><?php }else{?>
<option value="" disabled selected>Select City</option>
<?php } ?>
<option></option>
</select></td>
</tr>
<tr style="color:#000000">
<td><strong>Pincode</strong></td>
<td><input type="text" class="form-control"  name="pincode" value="<?php echo $pincode?>"/></td>
</tr>
<tr style="color:#000000">
<td><strong>Website</strong></td>
<td><input type="text" class="form-control"  name="website" value="<?php echo $website?>"/></td>
</tr>

<tr style="color:#000000">
<td><strong>PAN NO</strong></td>
<td><input type="text" class="form-control"  name="billing_PAN_no" value="<?php echo $billing_PAN_no?>"/></td>
</tr>

<tr style="color:#000000">
<td><strong>State Code</strong></td>
<td><input type="text" id="codegst"  name="state_code" class="form-control" readonly="readonly" value="<?php echo $state_code?>"/></td>
</tr>
<tr style="color:#000000">
<td><strong>GST NO.</strong></td>
<td><input type="text" class="form-control"  name="billing_GST_no" value="<?php echo $billing_GST_no?>"/></td>
</tr>

<tr style="color:#000000">
<td><strong>Delivery Address</strong></td>
<td><input type="text" class="form-control"  name="shipping_address" value="<?php echo $shipping_address?>"/></td>
</tr>

<!------------------>

<tr style="color:#000000">
<td><strong>Vendor Code</strong></td>
<td><input type="text" class="form-control"  name="vendor_code" value="<?php echo $vendor_code?>"/></td>
</tr>


<tr style="color:#000000">
<td><strong>Buyer Name</strong></td>
<td><input type="text" class="form-control"  name="buyer_name" value="<?php echo $buyer_name?>"/></td>
</tr>

<tr style="color:#000000">
<td><strong>Buyer GST No</strong></td>
<td><input type="text" class="form-control"  name="buyer_GST_no" value="<?php echo $buyer_GST_no?>"/></td>
</tr>

<tr style="color:#000000">
<td><strong>Buyer PAN No</strong></td>
<td><input type="text" class="form-control"  name="buyer_PAN_no" value="<?php echo $buyer_PAN_no?>"/></td>
</tr>

<tr style="color:#000000">
<td><strong>Buyer State</strong></td>
<td><input type="text" class="form-control"  name="buyer_state" value="<?php echo $buyer_state?>"/></td>
</tr><!------------------>
<tr style="color:#000000">
<td><strong>Buyer State Code</strong></td>
<td><input type="text" class="form-control"  name="buyer_state_code" value="<?php echo $buyer_state_code?>"/></td>
</tr>
<tr style="color:#000000">
<td><strong>Buyer Address</strong></td>
<td><input type="text" class="form-control"  name="buyer_address" value="<?php echo $buyer_address?>"/></td>
</tr>

<tr style="color:#000000">
<td colspan="2"><div align="center">
<button type="submit" class="btn btn-primary waves-effect waves-light"> SAVE </button>
</div></td>
</tr>
</table>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</form>



</div>
</div>
<?php include 'footer1.php';?>
