<!doctype html>
<?php
include("../connection.php");
include("../user.php");
$cur_date = date('Y-m-d H:i:s');
$user = $_SESSION['user'];
$eid = $_REQUEST['id'];
$branch_id = $_SESSION['branch_id'];
$ho_access = $_SESSION['ha'];
$editemp = mysqli_fetch_array(mysqli_query($con, "select em.branch_id,em.profile_photo,em.id as eid,em.emp_no,em.employee_name,em.fathers_name,em.dob,em.gender,em.department,em.mail_id,em.mobile,em.adhar_no,em.address,em.blood_group,bm.id,bm.branch_name from employee_master em join branch_master bm on bm.id=em.branch_id  where  em.id='$eid'"));

?>
<html class="no-js" lang="">

<head>
  <meta charset="utf-8">
  <meta http-equiv="X-UA-Compatible" content="IE=edge">
  <title><?php echo TITLE; ?></title>
  <meta name="description" content="Ela Admin - HTML5 Admin Template">
  <meta name="viewport" content="width=device-width, initial-scale=1">
  <link rel="apple-touch-icon" href="../images/bluebase.png">
  <link rel="shortcut icon" href="../images/bluebase.png">
  <!-- <script type="text/javascript" src="https://cdn.jsdelivr.net/html5shiv/3.7.3/html5shiv.min.js"></script> -->
  <style>
    input[type=text] {
      text-transform: uppercase;
    }

    textarea {
      text-transform: uppercase;
    }

    select {
      text-transform: uppercase;
    }

    .select2-results__option {
      text-transform: uppercase;
    }
  </style>
  <script>
    $(document).ready(function () {
      $('.select-search').select2({
        placeholder: "-- SELECT --",
        allowClear: true,
        templateResult: function (data) {
          if (!data.id) return data.text;
          return data.text.toUpperCase();
        },
        templateSelection: function (data) {
          if (!data.id) return data.text;
          return data.text.toUpperCase();
        }
      });
    });
  </script>
</head>

<body>

  <div class="col-lg-8">
    <div class="card">
      <div class="card-header">
        <strong style="float:left;">Edit Employee</strong>
        <a href="employee_bulk_report.php"><button class="btn btn-primary" style="width:50px;float:right;" onclick=""><i
              class="fa fa-backward"></i></button></a>

      </div>
      <div class="card-body card-block">
        <form method="post" enctype="multipart/form-data" class="form-horizontal" action="employee_update.php">

          <?php
          if ($ho_access == "yes") {
            ?>
            <div class="row form-group">
              <div class="col col-md-3"><label for="text-input" class=" form-control-label">Branch</label><span style="color:red;">*</span></div>
              <div class="col-12 col-md-9"><select id="branch" name="branch" placeholder="select branch"
                  class="form-control select-search" autocomplete="off" required>
                  <!--<option value="<?php echo $editemp['branch_id']; ?>" ><?php echo $editemp['branch_name']; ?></option>-->
                  <?php
                  $brn = mysqli_query($con, "SELECT * FROM branch_master where  status='0' order by id asc");
                  while ($brc = mysqli_fetch_array($brn)) {
                    ?>
                    <option value="<?php echo $brc['id']; ?>" <?php if ($brc['id'] == $editemp['branch_id']) {
                         echo "selected";
                       } ?>><?php echo strtoupper($brc['branch_name']); ?></option>
                    <?php
                  }
                  ?>
                </select></div>
            </div>
            <div class="row form-group">
              <div class="col col-md-3"><label for="text-input" class=" form-control-label">Employee Name</label><span style="color:red;">*</span></div>
              <div class="col-12 col-md-9"><input type="text" id="emp_name"
                  value="<?php echo $editemp['employee_name']; ?>" name="emp_name" onchange="emp(this.value)"
                  placeholder="Enter  your employee name" class="form-control" autocomplete="off" required></div>
            </div>
            <div class="row form-group">
              <div class="col col-md-3"><label for="text-input" class=" form-control-label">Employee Code</label></div>
              <div class="col-12 col-md-9"><input type="text" value="<?php echo $editemp['emp_no']; ?>" id="emp_code"
                  name="emp_code" placeholder="Enter Employee Code" class="form-control" autocomplete="off">
              </div>
            </div>
            <div class="row form-group">
              <div class="col col-md-3"><label for="email-input" class=" form-control-label">Email </label></div>
              <div class="col-12 col-md-9"><input type="email" id="email" value="<?php echo $editemp['mail_id']; ?>"
                  onchange="user(this.value)" name="email" placeholder="Enter your  Email" class="form-control"
                  autocomplete="off"></div>
            </div>
            <div class="row form-group">
              <div class="col col-md-3"><label for="password-input" class=" form-control-label">Mobile No</label></div>
              <div class="col-12 col-md-9"><input type="number" value="<?php echo $editemp['mobile']; ?>" id="mbl"
                  name="mbl" placeholder="Enter your Mobile Number" class="form-control" autocomplete="off">
              </div>
            </div>
            <div class="row form-group">
              <div class="col col-md-3"><label class=" form-control-label">Gender</label></div>
              <div class="col col-md-9">
                <div class="form-check">
                  <div class="radio">
                    <label for="radio1" class="form-check-label ">
                      <input type="radio" id="gender" name="gender" value="male" class="form-check-input" <?php if ($editemp['gender'] == "male") {
                        echo "checked";
                      } ?>>Male <?php echo $editemp['gender']; ?>
                    </label>
                  </div>
                  <div class="radio">
                    <label for="radio2" class="form-check-label ">
                      <input type="radio" id="gender" name="gender" value="female" class="form-check-input" <?php if ($editemp['gender'] == "female") {
                        echo "checked";
                      } ?>>Female
                    </label>
                  </div>
                </div>
              </div>
            </div>

            <div class="row form-group">
              <div class="col col-md-3"><label for="text-input" class=" form-control-label">Date of Birth</label></div>
              <div class="col-12 col-md-9"><input type="date" value="<?php echo $editemp['dob']; ?>" id="dob" name="dob"
                  placeholder="Enter your D.O.B" class="form-control" autocomplete="off"></div>
            </div>
            <div class="row form-group">
              <div class="col col-md-3"><label for="text-input" class=" form-control-label">Father's Name</label></div>
              <div class="col-12 col-md-9"><input type="text" value="<?php echo $editemp['fathers_name']; ?>" id="f_name"
                  name="f_name" placeholder="Enter your father's name" class="form-control" autocomplete="off"></div>
            </div>
            <div class="row form-group">
              <div class="col col-md-3"><label for="text-input" class=" form-control-label">Department</label></div>
              <div class="col-12 col-md-9"><input type="text" value="<?php echo $editemp['department']; ?>"
                  id="department" name="department" placeholder="Enter your department" class="form-control"
                  autocomplete="off"></div>
            </div>
            <div class="row form-group">
              <div class="col col-md-3"><label for="text-input" class=" form-control-label">Adhaar No</label></div>
              <div class="col-12 col-md-9"><input type="text" value="<?php echo $editemp['adhar_no']; ?>" id="adhaar_no"
                  name="adhaar_no" placeholder="Enter your adhaar number" class="form-control" autocomplete="off"></div>
            </div>
            <div class="row form-group">
              <div class="col col-md-3"><label for="text-input" class=" form-control-label">Blood Group</label></div>
              <div class="col-12 col-md-9"><input type="text" id="blood" name="blood"
                  value="<?php echo $editemp['blood_group']; ?>" placeholder="Enter Blood group" class="form-control"
                  autocomplete="off"></div>
            </div>


            <div class="row form-group">
              <div class="col col-md-3"><label for="text-input" class=" form-control-label">Address</label></div>
              <div class="col-12 col-md-9"><textarea type="text" id="address" name="address"
                  placeholder="Enter your address" class="form-control"
                  autocomplete="off"><?php echo $editemp['address']; ?></textarea></div>
            </div>

            <div class="row form-group">
              <div class="col col-md-3"><label for="file-input" class=" form-control-label">Profile Photo</label></div>
              <div class="col-12 col-md-9"><input type="file" id="file" name="file" class="form-control-file"></div>
              <div class="col-12 col-md-9"><input type="hidden" id="filename" name="filename"
                  value="<?php echo $editemp['profile_photo']; ?>" class="form-control-file"></div>
            </div>

            <?php
          } else {
            ?>
            <div class="row form-group">
              <div class="col col-md-3"><label for="text-input" class=" form-control-label">Branch</label><span style="color:red;">*</span></div>
              <div class="col-12 col-md-9"><select id="branch" name="branch" placeholder="select branch"
                  class="form-control select-search" autocomplete="off" required>
                  <!--<option value="<?php echo $editemp['branch_id']; ?>"><?php echo $editemp['branch_name']; ?></option>-->
                  <?php
                  $brn = mysqli_query($con, "SELECT * FROM branch_master where status='0' order by id asc");
                  while ($brc = mysqli_fetch_array($brn)) {
                    ?>
                    <option value="<?php echo $brc['id']; ?>" <?php if ($brc['id'] == $editemp['branch_id']) {
                         echo "selected";
                       } ?>><?php echo strtoupper($brc['branch_name']); ?></option>
                    <?php
                  }
                  ?>
                </select></div>
            </div>
            <div class="row form-group">
              <div class="col col-md-3"><label for="text-input" class=" form-control-label">Employee Name</label><span style="color:red;">*</span></div>
              <div class="col-12 col-md-9"><input type="text" id="emp_name"
                  value="<?php echo $editemp['employee_name']; ?>" name="emp_name" onchange="emp(this.value)"
                  placeholder="Enter  your employee name" class="form-control" autocomplete="off" required></div>
            </div>
            <div class="row form-group">
              <div class="col col-md-3"><label for="text-input" class=" form-control-label">Employee Code</label></div>
              <div class="col-12 col-md-9"><input type="text" value="<?php echo $editemp['emp_no']; ?>" id="emp_code"
                  name="emp_code" placeholder="Enter Employee Code" class="form-control" autocomplete="off">
              </div>
            </div>
            <div class="row form-group">
              <div class="col col-md-3"><label for="email-input" class=" form-control-label">Email </label></div>
              <div class="col-12 col-md-9"><input type="email" id="email" value="<?php echo $editemp['mail_id']; ?>"
                  onchange="user(this.value)" name="email" placeholder="Enter your  Email" class="form-control"
                  autocomplete="off"></div>
            </div>
            <div class="row form-group">
              <div class="col col-md-3"><label for="password-input" class=" form-control-label">Mobile No</label></div>
              <div class="col-12 col-md-9"><input type="number" value="<?php echo $editemp['mobile']; ?>" id="mbl"
                  name="mbl" placeholder="Enter your Mobile Number" class="form-control" autocomplete="off">
              </div>
            </div>
            <div class="row form-group">
              <div class="col col-md-3"><label class=" form-control-label">Gender</label></div>
              <div class="col col-md-9">
                <div class="form-check">
                  <div class="radio">
                    <label for="radio1" class="form-check-label ">
                      <input type="radio" id="gender" name="gender" value="male" class="form-check-input" <?php if ($editemp['gender'] == "male") {
                        echo "checked";
                      } ?>>Male
                    </label>
                  </div>
                  <div class="radio">
                    <label for="radio2" class="form-check-label ">
                      <input type="radio" id="gender" name="gender" value="female" class="form-check-input" <?php if ($editemp['gender'] == "female") {
                        echo "checked";
                      } ?>>Female
                    </label>
                  </div>
                </div>
              </div>
            </div>

            <div class="row form-group">
              <div class="col col-md-3"><label for="text-input" class=" form-control-label">Date of Birth</label></div>
              <div class="col-12 col-md-9"><input type="date" value="<?php echo $editemp['dob']; ?>" id="dob" name="dob"
                  placeholder="Enter your D.O.B" class="form-control" autocomplete="off"></div>
            </div>
            <div class="row form-group">
              <div class="col col-md-3"><label for="text-input" class=" form-control-label">Father's Name</label></div>
              <div class="col-12 col-md-9"><input type="text" value="<?php echo $editemp['fathers_name']; ?>" id="f_name"
                  name="f_name" placeholder="Enter your father's name" class="form-control" autocomplete="off"></div>
            </div>
            <div class="row form-group">
              <div class="col col-md-3"><label for="text-input" class=" form-control-label">Department</label></div>
              <div class="col-12 col-md-9"><input type="text" value="<?php echo $editemp['department']; ?>"
                  id="department" name="department" placeholder="Enter your department" class="form-control"
                  autocomplete="off"></div>
            </div>
            <div class="row form-group">
              <div class="col col-md-3"><label for="text-input" class=" form-control-label">Adhaar No</label></div>
              <div class="col-12 col-md-9"><input type="text" value="<?php echo $editemp['adhar_no']; ?>" id="adhaar_no"
                  name="adhaar_no" placeholder="Enter your adhaar number" class="form-control" autocomplete="off"></div>
            </div>
            <div class="row form-group">
              <div class="col col-md-3"><label for="text-input" class=" form-control-label">Blood Group</label></div>
              <div class="col-12 col-md-9"><input type="text" id="blood" name="blood"
                  value="<?php echo $editemp['blood_group']; ?>" placeholder="Enter Blood group" class="form-control"
                  autocomplete="off"></div>
            </div>


            <div class="row form-group">
              <div class="col col-md-3"><label for="text-input" class=" form-control-label">Address</label></div>
              <div class="col-12 col-md-9"><textarea type="text" id="address" name="address"
                  placeholder="Enter your address" class="form-control"
                  autocomplete="off"><?php echo $editemp['address']; ?></textarea></div>
            </div>

            <div class="row form-group">
              <div class="col col-md-3"><label for="file-input" class=" form-control-label">Profile Photo</label></div>
              <div class="col-12 col-md-9"><input type="file" id="file" name="file" class="form-control-file"></div>
              <div class="col-12 col-md-9"><input type="hidden" id="filename" name="filename"
                  value="<?php echo $editemp['profile_photo']; ?>" class="form-control-file"></div>
            </div>
            <?php
          }
          ?>
          <input type="hidden" name="id" value="<?php echo $editemp['eid']; ?>">

          <div style="">

            <button type="submit" name="submit" id="submit" class="btn btn-success"><i
                class="fa fa-dot-circle-o"></i>Update</button>
          </div>
        </form>
      </div>
    </div>
    <div class="clearfix"></div>

    <footer class="site-footer">

    </footer>

  </div><!-- /#right-panel -->

  <!-- Right Panel -->

  <!-- Scripts -->




</body>

</html>
<?php require("../mainjavascript.js"); ?>