<?php 

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

$sql_InvoiceQuery   = mysqli_query($conn,"SELECT count(*) as code FROM supplier_master");
$rowInvoiceCount    = mysqli_fetch_array($sql_InvoiceQuery,MYSQLI_ASSOC);
$code_count      = $rowInvoiceCount['code']+1;

?>

<!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">Supplier Master Details</h2><br>
    <form class="form-horizontal" action="supplierMasterInsert.php" method="post" id="supplierMasterForm" onSubmit="return checkForm(this);" autocomplete="off">
      

    <div class="form-group">
      <label class="control-label col-sm-2" for="email">supplier Name *</label>
      <div class="col-sm-9">
        <input type="text" class="form-control input-lg" placeholder="Enter supplier Name" name="suppliername" autocomplete="off" required> 
      </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" required></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 supplier Code" name="suppliercode" autocomplete="off" value="<?php echo "SUPP-".$code_count; ?>" required readonly>
        </div> 
      
    </div>

    
    
    <div class="form-group">
      <label class="control-label col-sm-2" for="email">State</label>
      <div class="col-sm-4">
      <select class="form-control input-lg" name="state" required>
        <option value="">SELECT STATE</option>
        <option value="Andhra Pradesh">Andhra Pradesh</option>
        <option value="Arunachal Pradesh">Arunachal Pradesh</option>
        <option value="Assam">Assam</option>
        <option value="Bihar">Bihar</option>
        <option value="Chhattisgarh">Chhattisgarh</option>
        <option value="Dadra and Nagar Haveli">Dadra and Nagar Haveli</option>
        <option value="Daman and Diu">Daman and Diu</option>
        <option value="Delhi">Delhi</option>
        <option value="Goa">Goa</option>
        <option value="Gujarat">Gujarat</option>
        <option value="Haryana">Haryana</option>
        <option value="Himachal Pradesh">Himachal Pradesh</option>
        <option value="Jammu and Kashmir">Jammu and Kashmir</option>
        <option value="Jharkhand">Jharkhand</option>
        <option value="Karnataka">Karnataka</option>
        <option value="Kerala">Kerala</option>
        <option value="Madhya Pradesh">Madhya Pradesh</option>
        <option value="Maharashtra">Maharashtra</option>
        <option value="Manipur">Manipur</option>
        <option value="Meghalaya">Meghalaya</option>
        <option value="Mizoram">Mizoram</option>
        <option value="Nagaland">Nagaland</option>
        <option value="Orissa">Orissa</option>
        <option value="Puducherry">Puducherry</option>
        <option value="Punjab">Punjab</option>
        <option value="Rajasthan">Rajasthan</option>
        <option value="Sikkim">Sikkim</option>
        <option value="TamilNadu">TamilNadu</option>
        <option value="Telangana">Telangana</option>
        <option value="Tripura">Tripura</option>
        <option value="Uttar Pradesh">Uttar Pradesh</option>
        <option value="Uttarakhand">Uttarakhand</option>
        <option value="West Bengal">West Bengal</option>
        </select>
      </div>
    
      <label class="control-label col-sm-2" for="email">Mobile *</label>
      <div class="col-sm-4">
        <input type="text" class="form-control input-lg" placeholder="Enter mobile Number" name="mobile" autocomplete="off" required >
      </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" name="pincode" >
      </div>

      <label class="control-label col-sm-2" for="email"> Email ID</label>
      <div class="col-sm-4">
        <input type="text" class="form-control input-lg" placeholder="Enter Email Id" name="email" >
      </div>
    
     
    </div>
        
    
        
    <div class="form-group">
<label class="control-label col-sm-2" for="email"> GST Number</label>
      <div class="col-sm-4">
        <input type="text" class="form-control input-lg" placeholder="Enter GST Number" name="gstin"  maxlength="15">
     </div>

      <label class="control-label col-sm-2" for="email"> PAN</label>
      <div class="col-sm-4">
        <input type="text" class="form-control input-lg" placeholder="Enter PAN Number" name="pan"
        >
      </div>

           

      
           
    </div>
    <div class="form-group">
      <label class="control-label col-sm-2" for="email">Supplier Type</label>
      <div class="col-sm-4">
      <select class="form-control input-lg" name="stype" required>
        <option value="">Select Supplier Type</option>
        <option value="Spare">Spare</option>
        <option value="Diesel">Diesel</option>
        <option value="Explosive">Explosive</option>
        <option value="Contractor">Contractor</option>
        </select>
      </div>
        
    </div>

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


    <?php require 'footer.php' ?>
    
    <script>

  var checkForm = function(form) {

    //
    // validate form fields
    //

    form.myButton.disabled = true;
    return true;
  };


</script>

    
    <script>
      $('#supplierMasterForm').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: {
          suppliername: {
                message: 'The supplier name is not valid',
                validators: {
                    notEmpty: {
                        message: 'The supplier 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 10 and less than 10 characters long'
                    },
                    regexp: {
                        regexp: /^[0-9]+$/,
                        message: 'The mobile can only consist of number'
                    },
                }
            }

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