<?php
   include('session.php');
   include('header1.php');
   include('ietpartial.php');

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

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

  $employeeid = $_GET['employeeID'];

  if(isset($_GET['updated'])) {

    $updated = $_GET['updated'];

  }

 // $sqlGetEmployee = "SELECT * FROM employees WHERE employeeid = $employeeid";

  $sqlBanksView = "SELECT 
    employees.employeeid AS employeeid,
    employees.employeename AS employeename,
    employees.employeesurname AS employeesurname,
    employee_bank.employee_bank_name AS employee_bank_name,
    employee_bank.employee_bank_account AS employee_bank_account
    FROM employee_bank 
    LEFT JOIN employees
    ON employee_bank.employee_id = employees.employeeid
    WHERE employee_bank.employee_id = $employeeid";

  $resultBank = mysqli_query($db,$sqlBanksView);

  $countBank = mysqli_num_rows($resultBank);

  echo "<main role=\"main\" class=\"col-md-9 ml-sm-auto col-lg-10 px-4\">";

  echo "<div class=\"d-flex justify-content-between flex-wrap flex-md-nowrap align-items-center pt-3 pb-2 mb-3 border-bottom\">";

  if ($countBank !== 0) { 

  	while ($rowemployee = mysqli_fetch_array($resultBank)) {

    	echo "<h1 class=\"h2\">" . $rowemployee['employeesurname'] . ", " . $rowemployee['employeename'] . "</h1>";
      echo "<a href=\"viewEmployee.php?employeeID=" . $rowemployee['employeeid'] . "\" class=\"btn btn-sm btn-outline-secondary\" role=\"button\">Back to Employee File</a>";
    
    	echo "</div>";

    	echo "<form method = \"POST\" action=\"editBankDetail1.php\">";

    	echo "<input type = \"hidden\" value = \"" . $rowemployee['employeeid'] . "\" name = \"employee_id\">";

      $banksList = array(
        "ABC Banking Corporation Ltd",
                  "Absa Bank",
                  "AfrAsia Bank Limited",
                  "Bank of Baroda",
                  "Bank One Limited",
                  "BanyanTree Bank Limited",
                  "BCP Bank",
                  "Century Banking Corporation Ltd",
                  "Habib Bank Limited",
                  "Investec Bank",
                  "MauBank Ltd",
                  "SBI",
                  "Standard Bank",
                  "Standard Chartered Bank",
                  "SBM Bank",
                  "The Hongkong and Shanghai Banking Corporation Limited",
                  "The Mauritius Commercial Bank Ltd",

      );


      echo "<p>Bank Name*
                <select name=\"bank_Name\" id=\"cars\" required class=\"form-control\">";

      foreach( $banksList as $bank ) {
            echo "<option value = \"$bank\" ";
            if ($rowemployee['employee_bank_name'] == $bank) 
              {echo "selected";}
            echo ">$bank</option>";
         }


          echo "</select></p><br>";

          echo "<p>Bank Account*
                <input type=\"text\" value = \"" . $rowemployee['employee_bank_account'] . "\" name=\"bank_Account\" required class=\"form-control\"> 
              </p>";

    }

    echo "<input type=\"submit\"> </form>";

   } else {
    echo "<p>ERROR NO BANK DATA AVAILABLE FOR THIS EMPLOYEE. PLEASE ADD THROUGH EMPLOYEE MASTER FILE PAGE</p>";
   }

} 


include('footer1.php');
?>