
<?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 = '1'
              WHERE periodid = $payrollid;";


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

      $employeeUpdate = "User reopened period ";

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

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

?>