<?php
   include('session.php');
   include('connect.php');
   include('logging.php');

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

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

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

    $positionid = mysqli_real_escape_string($db,$_GET['positionid']);
    $departmentid = mysqli_real_escape_string($db,$_GET['departmentid']);

    $sqlUpdatePosition = "
    DELETE FROM
    positions
    WHERE positionid = $positionid;";

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

      $positionUpdate = "User deleted position ";

      logEvent($db,"Position Deleted",$positionUpdate,$last_id);
      
      header("location: viewdepartment.php?departmentid=$departmentid");

      } else {
         echo "Error: " . mysqli_error($db);
    }

    } else {
    echo "Position not selected!!!";
   }
 
}

?>