<?php

include("../include/session.php");
if(!$session->isAdmin() && !$session->isRadstoneReceptionUser()){
    header("Location: ../main.php");
}else{
//	include("../include/db.php");
	include("../productionHeader.php");

$date = date("m");

	$queryLate = "SELECT * FROM nam_productiondepalet WHERE MONTH(date) = '$date' ORDER BY date DESC";
	$resultLate = execsql($queryLate);
	$numLate = mysql_num_rows($resultLate);

		$q = "SELECT recipieId, recipieName FROM nam_recipie";
	$resultPro = execsql($q);
	$numPro = mysql_num_rows($resultPro);
	$j = 0;
	$proArray = array();
	while($j < $numPro){
		$proArray[mysql_result($resultPro, $j, "recipieId")] = mysql_result($resultPro, $j, "recipieName");
		$j++;
	}
?>


<h3>Depaleted this Month</h3><br />
<input type="button" value="Print" onclick="JavaScript:printPreviewDiv('top-bar');">
<table id="test1" cellpadding="0" cellspacing="0" border="0" class="rowstyle-alt colstyle-alt no-arrow">
    <thead>
      <tr>
        <th class="sortable-date-ymd">Date</th>
        <th class="sortable-numeric">Recipie Id</th>
        <th class="sortable-numeric">Cost</th>
        <th class="sortable-numeric">Amount of Tiles</th>
        
        

      </tr>
    </thead>
    <tbody>
<?php
    $i = 0;
    while($i < $numLate){

       $b1 = mysql_result($resultLate, $i, "date");
       $b2 = mysql_result($resultLate, $i, "recipieId");
       $b3 = mysql_result($resultLate, $i, "cost");
       $b4 = mysql_result($resultLate, $i, "amountOfTiles");
       $tCost += $b3;
       $tDep += $b4;


      // echo "<tr><td class="sortable-numeric">$b1</td><td>$b2</td><td>$permission</td><td>$b4</td><td>$b5</td><td>$b6</td></tr>";
      // $i++;
   // }
?>

 <tr class="alt">
        <td><?php echo $b1?></td>
        <td><a href="../Production/viewRecipies.php?id=<?php echo $b2?>"><?php echo $proArray[$b2]?></a></td>
        <td><?php echo $b3?></td>
        <td><?php echo $b4?></td>
       
       </tr>
<?php
    $i++;
    }
?>
<tr><td></td><td></td><td><b><?php echo $tCost?></b></td><td><b><?php echo $tDep?></b></td></tr>
</tbody>
</table>

<?php
    include "../footer.html";
}
?>
