<?php 

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


$edit_id  =  $_GET['id'];

$sql = mysqli_query($conn,"SELECT id, ename, eaddress, mobile, ecode FROM employee_master WHERE id='$edit_id' ");
 
$row=mysqli_fetch_array($sql,MYSQLI_ASSOC);

$ename  = $row['ename'];
$eaddress  = $row['eaddress'];
$mobile  = $row['mobile'];
$ecode      = $row['ecode'];


?>

<!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="employeeMasterUpdate.php" method="post" id="employeeMasterForm">
    <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" value="<?php echo $ename; ?>" required> 
        <input type="hidden" value="<?php echo $edit_id; ?>" name="edit_id">
      </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 $ecode; ?>" 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="address" rows="4" ><?php echo $eaddress; ?></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 value="<?php echo $mobile; ?>">
      </div>
     
    </div>

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


    <?php require 'footer.php' ?>
    <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>