<?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\">" . $rowDepartment['departmentname'] . " - Add Position</h1>";
      echo "<a href=\"viewdepartment.php?departmentid=" . $rowDepartment['departmentid'] . "\" class=\"btn btn-sm btn-outline-secondary\" role=\"button\">Back</a>";
    
    	echo "</div>";

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

    	echo "<input type = \"hidden\" value = \"" . $rowDepartment['departmentid'] . "\" name = \"departmentid\">";

          echo "<p>Position Name*
                <input type=\"text\" name=\"position_name\" required class=\"form-control\"> 
              </p>";

    }

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

   }

} 


include('footer1.php');
?>