<?php 

require_once("config/configDB.php"); 
require "userPermission.php";

$id  =  $_GET['id'];

$sql = mysqli_query($conn,"SELECT * FROM supplier_master WHERE id='$id' ");
 
$row=mysqli_fetch_array($sql,MYSQLI_ASSOC);

// `sname`, `saddress`, `customer_state`, `pincode`, `mobile`, `email`, `gstin`, `other_ref`, `scode`

$suppliername   = $row['sname'];
$address1       = $row['saddress'];
$sname_tamil         = $row['sname_tamil'];
$pincode        = $row['pincode'];
$mobile         = $row['mobile'];
$area          = $row['area'];
$area_tamil          = $row['area_tamil'];

$suppliercode   = $row['scode'];


?>

<!DOCTYPE html>
<html>
<head>
    
<?php 
      require 'meta.php'; 
      require 'header.php'; 
    ?>

</head>
<body>
    <?php require 'menu.php' ?>


<div class="container-fluid">
<h2 class="text-center">Edit Supplier Details</h2><br>
    <form class="form-horizontal" action="supplierMasterUpdate.php" method="post">
      

    <div class="form-group">
      <label class="control-label col-sm-2" for="email">Supplier Name *</label>
      <div class="col-sm-4">
        <input type="text" class="form-control input-lg" placeholder="Enter Supplier Name" name="suppliername" autocomplete="off" value='<?php echo $suppliername; ?>' required> 
        <input type="hidden" value=<?php echo $id; ?> name="edit_id">
      </div>
       <label class="control-label col-sm-2" for="email">Supplier Name Tamil*</label>
      <div class="col-sm-4">
        <input type="text" class="form-control input-lg tamil" placeholder="Enter supplier Name" name="sname_tamil" id="sname_tamil" autocomplete="off" required value='<?php echo $sname_tamil; ?>'> <br>
         <a href="https://www.google.com/intl/ta/inputtools/try/" target="_blank">Tamil Type</a>
      </div>
    </div>

    <div class="form-group">
      <label class="control-label col-sm-2" for="email">Address </label>
      <div class="col-sm-4">
        <textarea  class="form-control input-lg" placeholder="Enter Address" name="address1" rows="4"><?php echo $address1; ?></textarea>
      </div>

      <label class="control-label col-sm-2" for="email"> Supplier Code *</label>
        <div class="col-sm-4">
          <input type="text" class="form-control input-lg" placeholder="Enter customer Code" name="suppliercode" value='<?php echo $suppliercode; ?>' autocomplete="off" required readonly>
        </div> 
      
    </div>

    <div class="form-group">

    <label class="control-label col-sm-2" for="email"> Area</label>
      <div class="col-sm-4">
        <input type="text" class="form-control input-lg " placeholder="Enter area" name="area" required value='<?php echo $area; ?>'>
      </div>

     <label class="control-label col-sm-2" for="email"> Area Tamil</label>
      <div class="col-sm-4">
        <input type="text" class="form-control input-lg tamil" placeholder="Enter area" name="area_tamil" reqyured value='<?php echo $area_tamil; ?>'>
      </div>
    
     
    </div>
    
    <div class="form-group">
      
      <label class="control-label col-sm-2" for="email"> Pincode</label>
      <div class="col-sm-4">
        <input type="text" class="form-control input-lg" placeholder="Enter Pincode"  value='<?php echo $pincode; ?>' name="pincode">
      </div>

      <label class="control-label col-sm-2" for="email">Mobile *</label>
      <div class="col-sm-4">
        <input type="number" class="form-control input-lg" placeholder="Enter mobile Number" name="mobile" value='<?php echo $mobile; ?>' required>
      </div>

      
            
    </div>
        
    
        
    
        
    
        
    

    
    <div class="form-group">        
      <div class="col-sm-12 text-center">
        <button type="submit" class="btn btn-default btn-lg">Update</button>
      </div>
    </div>
  </form>   
</div>

 <?php require 'footer.php' ?>
 
 
 <SCRIPT language=JavaScript src="js/utf.js"></SCRIPT>
		<SCRIPT language=JavaScript src="js/tamil.js"></SCRIPT>
		
		<script>
			$(document).ready(function(){
				$('.tamil').on('keydown',function(event){
					if(event.which==121){
						$(this).toggleClass('tamil');
						return false;
					}
					if($(this).hasClass('tamil')){
						toggleKBMode(event);
					}else{
						return true;
					}
				});
				$('.tamil').on('keypress',function(event){
					if($(this).hasClass('tamil')){
						convertThis(event);
					}
				});
			});
		</script>
 
 
 <script>
      $('#customerMasterForm').bootstrapValidator({
        // To use feedback icons, ensure that you use Bootstrap v3.1.0 or later
        feedbackIcons: {
            valid: 'glyphicon glyphicon-ok',
            invalid: 'glyphicon glyphicon-remove',
            validating: 'glyphicon glyphicon-refresh'
        },
        fields: {
          customername: {
                message: 'The customer name is not valid',
                validators: {
                    notEmpty: {
                        message: 'The customer name is required and cannot be empty'
                    }
                }
            },
            mobile: {
                message: 'The mobile is not valid',
                validators: {
                    notEmpty: {
                        message: 'The mobile is required and cannot be empty'
                    },
                    stringLength: {
                        min: 10,
                        max: 10,
                        message: 'The mobile must be more than 6 and less than 30 characters long'
                    },
                    regexp: {
                        regexp: /^[0-9]+$/,
                        message: 'The mobile can only consist of number'
                    },
                }
            }

        }
    });
    
    </script>
</body>
</html>