<?php
include("../include/session.php");
//include("../include/db.php");
if(!$session->isAdmin() && !$session->isRadstoneReceptionUser()){
	header("Location: ../Store/storeMenu.php");
}else{
	$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");
	}
	include("../productionHeader.php");
	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++;
	}
	?>
<script language="javascript">
<!--

function validate() {
	var ErrorString='';
	<?php 
		if(!$session->isAdmin()){
		?>
			if(document.production.skip.value < 0){
				ErrorString+='Please enter a valid number of skips \n';
			}
		<?php 	
		}
	?>

	if(document.production.skip.value==''){
	    ErrorString+='Please enter the number of skips\n';
		}
		if(isNaN(document.production.skip.value)){
		ErrorString+='Please Enter a Valid number of Skips\n';
		}	
		if(document.production.recipieId.value==''){
	    ErrorString+='Please select the Recipie\n';
		}

		if(document.production.wet.value==''){
		    ErrorString+='Please enter the number of Wet tiles\n';
			}
			if(isNaN(document.production.wet.value)){
			ErrorString+='Please Enter a Valid number of Wet tiles\n';
			}	

			if(document.production.hours.value==''){
			    ErrorString+='Please enter the number of heating hours\n';
				}
				if(isNaN(document.production.hours.value)){
				ErrorString+='Please Enter a Valid number of heating hours\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>
<style type="text/css">
<!--
.style1 {font-size: medium}
-->
</style>
<div class="headerbox2">Days Skip Count and Wet Tiles Production</div><br /><br /><br /><br />
<form action="manipulation/daysProduction.php" name="production" method="POST">
  <table width="594">
    <tr>
      <td colspan=4>Production date:
        <?php
		$myCalendar = new tc_calendar("date1", true);
		$myCalendar->setIcon("../img/iconCalendar.gif");
		$myCalendar->setDate($d, $m, $y);
		$myCalendar->setPath("./");
		$myCalendar->setYearInterval(2000, 2030);
		$myCalendar->writeScript();

		?></td>
    </tr>
    <tr>
      <td colspan=4><strong>Skip Count:</strong></td>
    </tr>
    <tr>
      <td width="233" id="row1">Number of Skips:</td>
      <td width="126"><input name="skip" value="" /></td>
      <td width="124">Select a Recipie:</td>
      <td width="91"><select name="recipieId" onchange="setOptions(document.myform.optone.options[document.myform.optone.selectedIndex].value);">
        <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 colspan=4><strong>Tiles:</strong></td>
    </tr>
    <tr>
      <td colspan="2">Number of Wet Tiles Produced:</td>
      <td colspan="2"><input name="wet" value="" /></td>
    </tr>
    <tr>
      <td colspan="4"><strong>Diesel:</strong></td>
    </tr>
    <tr>
      <td>Hours of Heating</td>
      <td><input name="hours" type="text" value="0" disabled="disabled"/></td>
      <td>Diesel used: </td>
      <td><input name="dieselText" type="text" disabled="disabled" size="5" />
        &nbsp;ltrs.</td>
    </tr>
    <tr>
      <td colspan="4"><strong>Production notes:</strong></td>
    </tr>
    <tr>
      <td valign="top">Maintenance done:</td>
      <td colspan="3"><label>
        <textarea name="maintenanceText" cols="60" rows="3" disabled="disabled" id="maintenanceText"></textarea>
      </label></td>
    </tr>
    <tr>
      <td valign="top">Production issues:</td>
      <td colspan="3"><label>
        <textarea name="productionText" cols="60" rows="3" disabled="disabled" id="productionText"></textarea>
      </label></td>
    </tr>
  </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>
		

		<?php
		include("../footer.php");
}
?>