<?php
include("../include/session.php");
//include("../include/db.php");
if(!$session->isAdmin() && !$session->isRadstoneReceptionUser()){
	header("Location: ../main.php");
}else{
    include("../productionHeader.php");
	$date = mysql_real_escape_string($_GET['date']);
	if($date > 0){
		$d = date("d", strtotime($date));
		$m = date("m", strtotime($date));
		$y = date("Y", strtotime($date));
	}else{
		$d = date("d");
		$m = date("m");
		$y = date("Y");
	}
	
	require_once('classes/tc_calendar.php');
	$q = "SELECT recipieId, recipieName FROM nam_recipie";
	$arrId = array();
	$arrName = array();
	$result = execsql($q);
	$num = mysql_num_rows($result);
	$b = 0;
	while($b < $num){
		$arrId[$b] = mysql_result($result, $b, "recipieId");
		$arrName[$b] = mysql_result($result, $b, "recipieName");
		$b++;
	}


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

	?>
<script language="javascript">
<!--
function validate() {
var ErrorString='';

<?php 
	if(!$session->isAdmin()){
	?>
		if(document.dep.dep.value < 0){
			ErrorString+='Please enter a valid number of depaletised tiles \n';
		}
	<?php 	
	}
?>

	if(document.dep.recipieId.value==''){
    ErrorString+='Please Select A Recipie';
	}
	
	if(document.dep.depRecipieId.value==''){
    ErrorString+='\nPlease Select A Depaletising Recipie';
	}

	if(document.dep.dep.value==''){
	    ErrorString+='\nPlease enter the amount of Tiles Depaletised';
		}
	if(isNaN(document.dep.dep.value)){
		ErrorString+='\nPlease Enter a Valid number of tiles\n';
	}

	if( ErrorString == '' ){
    return true;
     }else{
	alert(ErrorString);
	return false;
	}
}
//-->
</script>

<link
	href="calendar.css" rel="stylesheet" type="text/css" />
<script
	language="javascript" src="../include/calendar.js"></script>
<div class="headerbox2">Depalletised Tiles</div><br /><br /><br />

<form name="dep" action="manipulation/depDaysProduction.php"
	method="post">
<table>
	<tr>
		<td id="row1">Recipie of depalleted tiles:</td>
		<td><select name="recipieId">
			<option value="">Choose Me</option>
			<?php
			for ($i = 0 ; $i < count($arrId) ; $i++) {

				echo "<option value=". "\"". $arrId[$i]. "\"" .">" . $arrName[$i] . "</option>";
			}

			?>
		</select></td>
	</tr>
	<tr>
		<td>Depalletising Recipie</td>
		<td><select name="depRecipieId">
			<option value="">Choose Me</option>
			<?php
			foreach ($proArray as $key=>$value) {
				echo "<option value=". "\"". $key . "\"" . ">" . $value . "</option>";
			}?>

			<td>Depalletised Tile Count: <input name="dep" value="" /></td>
	
	</tr>
	<tr>
		<td>Date:
		<td colspan="2"><?php
		$myCalendar = new tc_calendar("date3", true);
		$myCalendar->setIcon("../img/iconCalendar.gif");
		$myCalendar->setDate($d, $m, $y);
		$myCalendar->setPath("./");
		$myCalendar->setYearInterval(2000, 2030);
		$myCalendar->writeScript();

		?> 
	
</table>
<input type="hidden" name="cat" value="<?php echo $cat?>" /><br />
<input type="submit" name="submitok" onclick="return validate();"
	value="Save and New" /><input type="submit" name="submitok"
	onclick="return validate();" value="Save and Close" /><input
	type="reset" value="Reset Form" /></form>
		<p>
		  <?php  }?>
</p>
		<p>
		  <?php
		include("../footer.php");

?>
		
