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

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

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

  $departmentid = $_GET['departmentid'];

  $sqlGetDepartment = "SELECT * FROM departments WHERE departmentid = $departmentid";

  $resultDepartment = mysqli_query($db,$sqlGetDepartment);

  $countDepartment = mysqli_num_rows($resultDepartment);

  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 ($countDepartment !== 0) { 

  	while ($rowDepartment = mysqli_fetch_array($resultDepartment)) {

    	echo "<h1 class=\"h2\">Edit Department</h1>";
      echo "<a href=\"departments.php\" class=\"btn btn-sm btn-outline-secondary\" role=\"button\">Back</a>";
    
    	echo "</div>";

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

    	echo "<input type = \"hidden\" value = \"" . $departmentid . "\" name = \"departmentid\">";

          echo "<p>Department Name*
                <input type=\"text\" value = \"" . $rowDepartment['departmentname'] . "\" name=\"department_name\" required class=\"form-control\"> 
              </p>";

    }

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

   }

} 


include('footer1.php');
?>