<?php
include("../include/session.php");
if(!$session->logged_in){
	header("Location: ../main.php");
}else{
	
	include "../header.php";
	//include("../include/db.php");
	$entry_date = mysql_real_escape_string($_POST['entryDate']);
	$selectColor1 = mysql_real_escape_string($_POST['selectColor1']);
	$productionNo1 = mysql_real_escape_string($_POST['productionNo1']);
	$selectColor2 = mysql_real_escape_string($_POST['selectColor2']);
	$productionNo2 = mysql_real_escape_string($_POST['productionNo2']);
	$note1 = mysql_real_escape_string($_POST['note1']);
	$note2 = mysql_real_escape_string($_POST['note2']);
	$note3 = mysql_real_escape_string($_POST['note3']);
	$note4 = mysql_real_escape_string($_POST['note4']);
	$note5 = mysql_real_escape_string($_POST['note5']);
	$note6 = mysql_real_escape_string($_POST['note6']);
	
	
	$d = date("d");
	$m = date("m");
	$y = date("Y");
	$today = date('Y-m-d');
		
	$query = "SELECT * FROM agenda WHERE entrydate = \" $entry_date\" ";
	$result = execsql($query);
	$num = mysql_num_rows($result);
	
	if ($num=="0") 
	{    
	$query = "INSERT INTO agenda (entrydate, selectColor1, productionNo1, selectColor2, productionNo2, note1, note2, note3, note4, note5, note6) VALUES ('".$entry_date."','".$selectColor1."', '".$productionNo1."','".$selectColor2."', '".$productionNo2."','".$note1."', '".$note2."','".$note3."', '".$note4."', '".$note5."', '".$note6."')";
	execsql($query); 
	}
	else
	{
	$query = "UPDATE agenda SET entrydate='$entry_date', selectColor1='$selectColor1', productionNo1='$productionNo1', selectColor2='$selectColor2', productionNo2 = '$productionNo2', note1 = '$note1', note2 = '$note2', note3 = '$note3', note4 = '$note4', note5 = '$note5', note6 = '$note6' WHERE entrydate ='$entry_date'";
//	echo $query;
	$r = execsql($query);  
	
	}

	//header("Location: agendaEntries.php");
	
	}

?>
<script type="text/JavaScript">
<!--
function MM_goToURL() { //v3.0
  var i, args=MM_goToURL.arguments; document.MM_returnValue = false;
  for (i=0; i<(args.length-1); i+=2) eval(args[i]+".location='"+args[i+1]+"'");
}
//-->
</script>
<div class="headerbox">Agenda Entries Updated</div><br /><br />
<p><?php if ($num==nill) 
	{    echo "The following information has been added to the agenda:";
	}
	else
	{    echo "The agenda information was updated as below:";
	}
	?>

</p>
</p>
<table width="504" border="0">
  <tr>
    <td width="129">date:</td>
    <td width="138"><?php echo $entry_date ?></td>
    <td width="223">&nbsp;</td>
  </tr>
  <tr>
    <td>production target 1: </td>
    <td><?php echo $productionNo1 ?></td>
    <td>color:&nbsp;&nbsp;<?php echo $selectColor1 ?></td>
  </tr>
  <tr>
    <td>production target 2: </td>
    <td><?php echo $productionNo2 ?></td>
    <td>color: &nbsp;<?php echo $selectColor2 ?></td>
  </tr>
  <tr>
    <td>note 1 </td>
    <td colspan="2"><?php echo $note1 ?></td>
  </tr>
  <tr>
    <td>note 2: </td>
    <td colspan="2"><?php echo $note2 ?></td>
  </tr>
  <tr>
    <td>note 3: </td>
    <td colspan="2"><?php echo $note3 ?></td>
  </tr>
  <tr>
    <td>note 4: </td>
    <td colspan="2"><?php echo $note4 ?></td>
  </tr>
  <tr>
    <td>note 5: </td>
    <td colspan="2"><?php echo $note5 ?></td>
  </tr>
  <tr>
    <td>note 6: </td>
    <td colspan="2"><?php echo $note6 ?></td>
  </tr>
  <tr>
    <td>&nbsp;</td>
    <td colspan="2">&nbsp;</td>
  </tr>
  <tr>
    <td>&nbsp;</td>
    <td colspan="2">&nbsp;</td>
  </tr>
</table>
<p>
  <input name="submitok"  type="image" src="../../Images/new_entry_btn.png" width="75" height="25" onclick="MM_goToURL('parent','agendaEntries.php');return document.MM_returnValue">
  <input name="submitok"  type="image" src="../../Images/go_to_calendar_btn.png" width="100" height="25" onclick="MM_goToURL('parent','Calendar.php?date3= <?php echo $today ?>');return document.MM_returnValue">
</p>
<p>
  <?php
		

include "../footer.php";

?>
</p>
<p>&nbsp;</p>
