<?php 
    session_start();
    if(!$_SESSION['id']){
        header('location:index.php');
    }
?>
<?php 
  require_once '../system/conn.php';
if(isset($_POST["submit"]))
{
    $emp_id=$_POST['ename'];
    $salary=$_POST['salary'];
    
    $query1 = "UPDATE `emp_details` SET `salary`='$salary' WHERE `e_id`='$emp_id' AND `status`=1 ";
    $statement1 = $conn->prepare($query1)->execute($data);
    if($statement1)
    {
        echo "<script>alert('Salary Modification successfull')</script>";
        echo "<script>window.location.href = 'emp-salary-change.php'</script>";
    }
    else
    {
        echo "<script>alert('NOT SUCCESSFULL !!!!!!')</script>";
        echo "<script>window.location.href = 'emp-salary-change.php'</script>";
    }
} 
?>
<!doctype html>
<html lang="en" class="semi-dark">
  <head>
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1">
	<link href="assets/css/pace.min.css" rel="stylesheet" />
	<script src="assets/js/pace.min.js"></script>
    <link href="assets/plugins/perfect-scrollbar/css/perfect-scrollbar.css" rel="stylesheet" />
    <link href="assets/plugins/simplebar/css/simplebar.css" rel="stylesheet" />
    <link href="assets/plugins/metismenu/css/metisMenu.min.css" rel="stylesheet" />
    <link href="assets/plugins/datatable/css/dataTables.bootstrap5.min.css" rel="stylesheet" />
    <link href="assets/css/bootstrap.min.css" rel="stylesheet">
    <link href="assets/css/bootstrap-extended.css" rel="stylesheet">
    <link href="assets/css/style.css" rel="stylesheet">
    <link href="assets/css/icons.css" rel="stylesheet">
	<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/bootstrap-icons@1.7.2/font/bootstrap-icons.css">
    <link href="https://fonts.googleapis.com/css2?family=Roboto:wght@400;500&display=swap" rel="stylesheet">
    <link href="assets/css/dark-theme.css" rel="stylesheet" />
    <link href="assets/css/semi-dark.css" rel="stylesheet" />
    <link href="assets/css/header-colors.css" rel="stylesheet" />
    <title>Employee Salary change</title>
  </head>
  <body>
    <div class="wrapper">
    <?php include'system/header.php'?>
	    <div class="page-content-wrapper">
         <div class="page-content">
          <!--start breadcrumb-->
          <div class="page-breadcrumb d-none d-sm-flex align-items-center mb-3">
            <div class="breadcrumb-title pe-3">Employee Salary change (Will be changed in All Branches)</div>
            <div class="ms-auto">
            </div>
          </div>
			<hr/>

            <div class="row">
              <div class="col-xl-12 mx-auto">
                <div class="card">
                  <div class="card-body">
                    <div class="p-4 border rounded">
                      <form method="post">
                                           
                        <div class="row mb-3">
                            <div class="col l12 s12">
                                <h6>Select Employee Name:</h6>
                                <div class="input-field">
                                    <!--<input class="form-control" id="input-5" name="ename" required>-->
                                    <input list="brow" id="ename"  onchange="Room(this.value);" class="form-control" name="ename" placeholder="Select Emplyoee" required>
                                      <datalist id="brow">
                                        <?php
                                          $a=1;
                                          $stmt = $conn->prepare(" SELECT DISTINCT `e_id`, `e_name`, `salary` FROM emp_details WHERE status='1' ORDER BY `e_id` ASC ");
                                          $stmt->execute();
                                          $users = $stmt->fetchAll();
                                          foreach($users as $row) { ?>
                                            <option class="col-md-12" value="<?php echo $row['e_id']?>"><?php echo $row['e_name'];?> - <?php echo $row['salary'];?></option>
                                        <?php $a++; }?>
                                      </datalist> 
                                </div>
                            </div>
                            
                            <div class="col l12 s12">
                                <h6>Set Monthly Salary:</h6>
                                <div class="input-field">
                                    <input type="text" class="form-control" id="validationCustom01" placeholder="Enter Monthly Salary" name="salary" required>
                                </div>
                            </div>
                        </div>
                        <div class="row mb-3">                
                            <div class="col-12">
                                <input type="submit" name="submit" class="btn btn-primary" value="submit" >
                            </div>
                        </div>
                       </form>    
                    </div>
                  </div>
                </div>
                
              </div>
            </div>
            <!--end row-->
        
          </div>
          <!-- end page content-->
         </div>

<?php include'system/footer.php'?>