<?php
session_start();
if(!isset($_SESSION['username']) || !isset($_SESSION['password'])){
 header("Location: index.php");
} 
?>
<!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>
<script>
window.onbeforeunload = function (e) {
e = e || window.event;

// For IE and Firefox prior to version 4
if (e) {
    e.returnValue = 'Sure?';
}

// For Safari
return 'Sure?';
};
</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.php" class="link-style">SELECT PORTERS</a></li>
				<li><a href="addporters.php" class="link-style">ADD PORTERS</a></li>
				<li><a href="deleteporter.php" class="link-style">DELETE PORTER</a></li>
				<li><a href="update.php" class="link-style">UPDATE INDIVIDUAL INFO</a></li>
                <li><a href="resetall.php" class="link-style">Reset All INFO</a></li>
                <li><a href="logout.php" class="link-style">Logout</a></li>
			</ul>
            </div>
	</div>
	<div id="content" align="center"><br />
<table style="width:800px">
  <tr>
    <td align="center"><h4>Selected List for current Kilimanjaro Trip on:<? print(Date("F d, Y")); ?></h4><br />Number of porters</td>
  </tr>
  <tr>
    <td align="center">
      <table border="1" style="width:750px">
      <tr>
      <td>S/N</td>
        <td>Account Number</td>
        <td>Full Name</td>
        <td>Phone Number</td>
        <td>Postal Address(Street)</td>
        <td>Residence</td>
 </tr>
<?php
$con=mysqli_connect("localhost","pdandf_lyimo","ThadeyX10","pdandf_system");
if (mysqli_connect_errno())
  {
  echo "Failed to connect to MySQL: " . mysqli_connect_error();
  }
  
$lmt=$_POST['NumberOfPorters'];	
	
$order = "SELECT * FROM employees WHERE (Status =0) ORDER BY Id LIMIT $lmt";	
$result=mysqli_query($con,$order);	
  
if(mysqli_num_rows($result)== 0){
	
	echo'<a href="reset.php">'."Sorry, All Porters Have been selected. Click Here to reset and Start new rotation". '</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><td>$data[4]</td><td>$data[5]</td></tr>");
   }
   //header("Location: selected.php");
}

$sql = "UPDATE employees
        SET Status='1'
        WHERE (Status =0) ORDER BY Id LIMIT $lmt";
mysqli_query($con,$sql);

	
mysqli_close($con);
?>
</table>
</td>
</tr>
</table>

<table style="width:800px">
  <tr>
    <td align="center"><h5>Number of Waiter(s)</h5></td>
  </tr>
  <tr>
    <td align="center">
      <table border="1" style="width:750px">
      <tr>
      <td>S/N</td>
        <td>Account Number</td>
        <td>Full Name</td>
        <td>Phone Number</td>
        <td>Postal Address(Street)</td>
        <td>Residence</td>
 </tr>
<?php
$conn=mysqli_connect("localhost","pdandf_lyimo","ThadeyX10","pdandf_system");
if (mysqli_connect_errno())
  {
  echo "Failed to connect to MySQL: " . mysqli_connect_error();
  }
$lmt1=$_POST['Waiters'];	
	
$order1 = "SELECT * FROM waiters WHERE (Status =0) ORDER BY Id LIMIT $lmt1";	
$result1=mysqli_query($conn,$order1);	
  
if(mysqli_num_rows($result1)== 0){
	
	echo'<a href="#">'."Sorry, no waiter selected". '</a>'.'<br>'.'<br>';
}
else{
   while($data1 = mysqli_fetch_array($result1)) {

   echo("<tr><td>$data1[0]</td><td>$data1[1]</td><td>$data1[2]</td><td>$data1[3]</td><td>$data1[4]</td><td>$data1[5]</td></tr>");
       //header("Location: selected.php");
   }
}

$sqll = "UPDATE waiters
        SET Status='1'
        WHERE (Status =0) ORDER BY Id LIMIT $lmt1";
mysqli_query($conn,$sqll);	
mysqli_close($conn);
?>
</table>
</td>
</tr>
</table>
</table>
</td>
</tr>
</table>

<table style="width:800px">
  <tr>
    <td align="center"><h5>Tent Crew</h5></td>
  </tr>
  <tr>
    <td align="center">
      <table border="1" style="width:750px">
      <tr>
      <td>S/N</td>
        <td>Account Number</td>
        <td>Full Name</td>
        <td>Phone Number</td>
        <td>Postal Address(Street)</td>
        <td>Residence</td>
 </tr>
<?php
$conm=mysqli_connect("localhost","pdandf_lyimo","ThadeyX10","pdandf_system");
if (mysqli_connect_errno())
  {
  echo "Failed to connect to MySQL: " . mysqli_connect_error();
  }
$lmttc=$_POST['Tentcrew'];	
	
$ordertc = "SELECT * FROM tentcrew WHERE (Status =0) ORDER BY Id LIMIT $lmttc";	
$resulttc=mysqli_query($conm,$ordertc);	
  
if(mysqli_num_rows($resulttc)== 0){
	
	echo'<a href="#">'."Sorry, no tent crew selected". '</a>'.'<br>'.'<br>';
}
else{
   while($datatc = mysqli_fetch_array($resulttc)) {

   echo("<tr><td>$datatc[0]</td><td>$datatc[1]</td><td>$datatc[2]</td><td>$datatc[3]</td><td>$datatc[4]</td><td>$datatc[5]</td></tr>");
     //header("Location: selected.php");
   }
}

$sqltc = "UPDATE tentcrew
        SET Status='1'
        WHERE (Status =0) ORDER BY Id LIMIT $lmttc";
mysqli_query($conm,$sqltc);	
mysqli_close($conm);
?>
</table>
</td>
</tr>
</table>

<table style="width:800px">
  <tr>
    <td align="center"><h5>Toilet Boy</h5></td>
  </tr>
  <tr>
    <td align="center">
      <table border="1" style="width:750px">
      <tr>
      <td>S/N</td>
        <td>Account Number</td>
        <td>Full Name</td>
        <td>Phone Number</td>
        <td>Postal Address(Street)</td>
        <td>Residence</td>
 </tr>
<?php
$conb=mysqli_connect("localhost","pdandf_lyimo","ThadeyX10","pdandf_system");
if (mysqli_connect_errno())
  {
  echo "Failed to connect to MySQL: " . mysqli_connect_error();
  }
$lmttb=$_POST['Toiletboy'];	
	
$ordertb = "SELECT * FROM toiletboy WHERE (Status =0) ORDER BY Id LIMIT $lmttb";	
$resulttb=mysqli_query($conb,$ordertb);	
  
if(mysqli_num_rows($resulttb)== 0){
	
	echo'<a href="#">'."Sorry, no toilet boy selected". '</a>'.'<br>'.'<br>';
}
else{
   while($datatb = mysqli_fetch_array($resulttb)) {

   echo("<tr><td>$datatb[0]</td><td>$datatb[1]</td><td>$datatb[2]</td><td>$datatb[3]</td><td>$datatb[4]</td><td>$datatb[5]</td></tr>");
    //header("Location: selected.php");
   }
}

$sqltb = "UPDATE toiletboy
        SET Status='1'
        WHERE (Status =0) ORDER BY Id LIMIT $lmttb";
mysqli_query($conb,$sqltb);	
mysqli_close($conb);
?>
</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 & Save(pdf) file&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>
