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

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

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

  $positionid = $_GET['positionid'];
  $departmentid = $_GET['departmentid'];

  $sqlGetPosition = "SELECT * FROM positions WHERE positionid = $positionid";

  $resultPosition = mysqli_query($db,$sqlGetPosition);

  $countPosition = mysqli_num_rows($resultPosition);

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

  	while ($rowPosition = mysqli_fetch_array($resultPosition)) {

    	echo "<h1 class=\"h2\">Edit Position</h1>";
      echo "<a href=\"viewdepartment.php?departmentid=" . $departmentid . "\" class=\"btn btn-sm btn-outline-secondary\" role=\"button\">Back</a>";
    
    	echo "</div>";

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

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

          echo "<p>Position Name*
                <input type=\"text\" value = \"" . $rowPosition['positionname'] . "\" name=\"position_name\" required class=\"form-control\"> 
              </p>";

    }

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

   }

} 


include('footer1.php');
?>