<?php
session_start();
if(!isset($_SESSION['username']) || !isset($_SESSION['password'])){
 header("Location: index.php");
} 
 //include 'logoff.html';
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>PMS Member's Only</title>
<meta name="keywords" content="" />
<meta name="description" content="" />
<link href="http://fonts.googleapis.com/css?family=Open+Sans+Condensed:300" rel="stylesheet" type="text/css" />
<link href="default.css" rel="stylesheet" type="text/css" media="all" />
<script type="text/ecmascript">
function printdiv(printpage)
{
var headstr = "<html><head><title></title></head><body>";
var footstr = "</body>";
var newstr = document.all.item(printpage).innerHTML;
var oldstr = document.body.innerHTML;
document.body.innerHTML = headstr+newstr+footstr;
window.print();
document.body.innerHTML = oldstr;
return false;
}

    function visitPage(){
        window.location='select.php';
    }

</script>
</head>
<body>
<div id="header" class="container">
	<div id="logo">
		<h1>PMS - Porter's Management System</h1>
	</div>
</div>

<div id="page" class="container">
	<div id="sidebar1">
		<div id="box1"><ul class="style1">
				<li class="first"><a href="select_porters.php" class="link-style">SELECT PORTERS</a></li>
				
                               <li><a href="logout.php" class="link-style">Logout</a></li>
			</ul>
            </div>
	</div>
	<div id="content" align="center"><br />
<table>
  <tr>
    <td align="center"><h4>Selected List for current Kilimanjaro Trip on:<? print(Date("F d, Y")); ?></h4></td>
  </tr>
  <tr>
    <td align="center">
      <table border="1">
      <tr>
      <td>S/N</td>
        <td>Account Number</td>
        <td>Full Name</td>
        <td>Phone Number</td>
       
 </tr>
<?php
$conn=mysqli_connect("localhost", "comeadve_glory1", "Safari#@2027$", "comeadve_tdmc");
if (mysqli_connect_errno())
  {
  echo "Failed to connect to MySQL: " . mysqli_connect_error();
  }
$idNum=$_POST['porterID'];	
	
$order = "SELECT * FROM employees WHERE (IDNumber=$idNum AND Status =0)";	
$result = mysqli_query($conn, $order);	
  
if(mysqli_num_rows($result)== 0){
	
	echo'<a href="#">'."Sorry, Porter with A/C number".$idNum." "."Has beed selected,Or does not exist. Click Here to reset his status". '</a>'.'<br>'.'<br>';
}
else{
   while($data = mysqli_fetch_array($result)) {

   echo("<tr><td>$data[0]</td><td>$data[1]</td><td>$data[2]</td><td>$data[3]</td></tr>");

   }
}

$sql = "UPDATE employees
        SET Status='1'
        WHERE (Status =0 AND IDNumber LIKE'%$idNum%') ";
mysqli_query($conn, $sql);	

mysqli_close($conn);

?>
</table>
</td>
</tr>
</table>
	</div>
	<div class="print" align="center"><br /><br /><input name="b_print" type="button" class="ipt"   onClick="printdiv('content');" value="&nbsp;&nbsp;Print List&nbsp;&nbsp;"> 
	  &nbsp;&nbsp;<button onclick="visitPage();">&nbsp;New Selection&nbsp;</button></div>
</div>
<div id="footer">
	<p>&copy; Private Kilimanjaro. All rights reserved. Design by <a href="#">Pamoja Web Solutions</a></p>
</div>
</body>
</html>
