<?php
   include('session.php');
   include('connect.php');
   include('logging.php');

// start role specific 
$user_role = $_SESSION['role'];

if ($_SERVER["REQUEST_METHOD"] == "POST") {

  if (isset($_POST['employee_id'])) {

    $employee_id = mysqli_real_escape_string($db,$_POST['employee_id']);
    $employee_car_benefit = mysqli_real_escape_string($db,$_POST['employee_car_benefit']);

    $sqlUpdateCarBenefit = "
              UPDATE employees
              SET employee_carbenefit = '$employee_car_benefit'
              WHERE employeeid = $employee_id;";


    if(mysqli_query($db, $sqlUpdateCarBenefit)) {

      $employeeUpdate = "User updated employee ";

      logEvent($db,"Employee updated",$employeeUpdate,$last_id);
      
      header("location: viewEmployee.php?employeeID=$employee_id");
      } else {
         echo "Error: " . mysqli_error($db);
    }

    } else {
    echo "Employee not selected!!!";
   }
 
}

?>
