<?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_production 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++;
	}
	
	$tCost = 0;
?>


<h3>Production 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">Skips</th>
        <th class="sortable-numeric">Cost</th>
        <th class="sortable-numeric">Wet</th>

        

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

       $b2 = mysql_result($resultLate, $i, "date");
       $b3 = mysql_result($resultLate, $i, "skips");
       $b4 = mysql_result($resultLate, $i, "cost");
       $b5 = mysql_result($resultLate, $i, "wet");
       $b6 = mysql_result($resultLate, $i, "depalet");
       $b7 = mysql_result($resultLate, $i, "recipieId");
       $b8 = mysql_result($resultLate, $i, "depRecId");
		$tSkips += $b3;
		$tCost += $b4;
		$tWet += $b5;
      // 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 $b2?></td>
        <td><a href="../Production/viewRecipies.php?id=<?php echo $b7?>"><?php echo $proArray[$b7]?></a></td>
        <td><?php echo $b3?></td>
        <td><?php echo $b4?></td>
        <td><?php echo $b5?></td>
     
       
       </tr>
<?php
    $i++;
    }
?>
<tr><b><td></td><td></td><td><b><?php echo $tSkips?></b></td><td><b><?php echo $tCost?></b></td><td><b><?php echo $tWet?></b></td></b></tr>
</tbody>
</table>

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