<?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']);
    $bank_Name = mysqli_real_escape_string($db,$_POST['bank_Name']);
    //$bank_Code = mysqli_real_escape_string($db,$_POST['bank_Code']);
    $bank_Code = "";
    $bank_Account = mysqli_real_escape_string($db,$_POST['bank_Account']);

    $sqlAddBank = "INSERT INTO employee_bank (
      employee_id,
      employee_bank_name,
      employee_bank_code,
      employee_bank_account
      ) VALUES (
      '$employee_id',
      '$bank_Name',
      '$bank_Code',
      '$bank_Account');";


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

      $employeeUpdate = "User updated employee bank ";

      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!!!";
   }
 
}

?>