
<?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['payrollID'])) {

    $payrollid = mysqli_real_escape_string($db,$_GET['payrollID']);

    $sqlClosePeriod = "
              UPDATE periods
              SET status = '2'
              WHERE periodid = $payrollid;";


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

      $employeeUpdate = "User closed period ";

      logEvent($db,"Period Closed",$employeeUpdate,$last_id);
      
      header("location: newPayroll.php?payrollID=$payrollid");
      } else {
         echo "Error: " . mysqli_error($db);
    }

    } else {
    echo "Payroll not selected..Error..";
   }
 
}

?>