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

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

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

  $payrollid = $_GET['payrollID'];


 // $sqlGetEmployee = "SELECT * FROM employees WHERE employeeid = $employeeid";

  $sqlPayrollView = "SELECT *
    FROM periods
    WHERE periodid = $payrollid";

  $resultPayroll = mysqli_query($db,$sqlPayrollView);

  $countPayroll = mysqli_num_rows($resultPayroll);

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

    

  	while ($rowpayroll = mysqli_fetch_array($resultPayroll)) {

    	echo "<h1 class=\"h2\">Edit " . $rowpayroll['startDate'] . " - " . $rowpayroll['endDate'] . "</h1>";
      echo "<a href=\"payrolls.php\" class=\"btn btn-sm btn-outline-secondary\" role=\"button\">Back to Listing</a>";
    
    	echo "</div>";

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

    	echo "<input type = \"hidden\" value = \"" . $rowpayroll['periodid'] . "\" name = \"period_id\">";


      echo "<p>Period Name*
                <input type=\"text\" value = \"" . $rowpayroll['periodName'] . "\" name=\"period_name\" required class=\"form-control\"> 
              </p>";

      echo "<p>Start Date*
                <input type=\"date\" value = \"" . $rowpayroll['startDate'] . "\" name=\"start_date\" required class=\"form-control\"> 
              </p>";

      echo "<p>End Date*
                <input type=\"date\" value = \"" . $rowpayroll['endDate'] . "\" name=\"end_date\" required class=\"form-control\"> 
              </p>";

      echo "<p>No of Working Days*
                <input type=\"numeric\" value = \"" . $rowpayroll['workingDays'] . "\" name=\"workingDays\" required class=\"form-control\"> 
              </p>";
        


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

  }


} 

}

include('footer1.php');
?>