<?php 

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

$sql_InvoiceQuery   = mysqli_query($conn,"SELECT count(*) as code FROM employee_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">employee Master Details</h2><br>
    <form class="form-horizontal" action="employeeMasterInsert.php" method="post" id="employeeMasterForm" onSubmit="return checkForm(this);" autocomplete="off">
    <div class="form-group">
      <label class="control-label col-sm-2" for="email">employee Name *</label>
      <div class="col-sm-9">
        <input type="text" class="form-control input-lg" placeholder="Enter employee Name" name="employeename" autocomplete="off" required > 
      </div>
    </div>
    <div class="form-group">
      <label class="control-label col-sm-2" for="email"> employee Code *</label>
        <div class="col-sm-4">
          <input type="text" class="form-control input-lg" placeholder="Enter employee Code" name="employeecode" autocomplete="off" value="<?php echo "EMP-".$code_count; ?>" required readonly>
        </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="address" rows="4"></textarea>
      </div>
    </div>
    
    <div class="form-group">
    
    <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" autocomplete="off" required  >
      </div>
     
    </div>
    
    <div class="form-group">
    
    <label class="control-label col-sm-2" for="email">Shift Working Amount</label>
      <div class="col-sm-4">
        <input type="text" class="form-control input-lg" placeholder="Enter Shift Working Amount" name="shiftworkamt" autocomplete="off" required>
      </div>
     
    </div>
    <div class="form-group">
    
    <label class="control-label col-sm-2" for="email">Extra Hours Amount</label>
      <div class="col-sm-4">
        <input type="text" class="form-control input-lg" placeholder="Enter Extra Hours Amount" name="extrahoursamt" autocomplete="off" required>
      </div>
     
    </div>

    <div class="form-group">        
      <div class="col-sm-12 text-center">
        <button type="submit" name="myButton" class="btn btn-default btn-lg">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>
      $('#employeeMasterForm').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: {
          employeename: {
                message: 'The employee name is not valid',
                validators: {
                    notEmpty: {
                        message: 'The employee name is required and cannot be empty'
                    }
                }
            },
          employeecode: {
              validators: {
                  notEmpty: {
                        message: 'The employee code 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>