<?php
session_start();
include("header.php");
$errmsg="";
$menuID=0;

if(trim($_GET['id'])!="")
	$menuID=$_GET['id'];

$action=$_POST['action'];
$details=$_POST['details'];

if(strtoupper($action) == "CREATE" && $menuID!='0')
{
	if(trim($details)=="")
		$errmsg = "Ingredient Details field is empty<br/>";

	if(trim($errmsg)=="")
	{
		$strSql =mysql_query("insert into tr_ingredient(menu_id,ingredient_desc,status)values('".$menuID."','".$details."','1');");

		$errmsg = "You have successfully created your Ingredient.";
	}
}

$strSql = mysql_query("select menu_name,menu_code from tr_menu where menu_id='".$menuID."'");
$rsc=@mysql_num_rows($strSql);
if($rs2=@mysql_fetch_array($strSql))
{
	$menuName=$rs2['menu_name'];
	$mCode=$rs2['menu_code'];
} 
?>
<table width="100%" cellpadding="0" cellspacing="0" border="0">
	<tr><td></td><td align="center" class="fs14"><u><b>Create New Menu Ingredient <?=$menuName?></b></u></td></tr>
	<tr><td width="200" class="fs12" valign="top"><?php include("sidemenu.php");?></td>
		<td width="700" class="fs12">
			<table width="680" cellpadding="1" cellspacing="1" border="0">
				<tr><td colspan="4"><hr /></td></tr>
				<?php
				if(strtoupper(substr(trim($errmsg),0,8))== "YOU HAVE")
				{
					echo "<tr valign='top' align='center'><td colspan='4'>".$errmsg."</td></tr>";
				?>
					<meta http-equiv="Refresh" content="3;url=menus.php"><br/><br/><br/><br/><br/>
				<?php
				}
				else 
				{
				?>
				<form action="ingredientNew.php?id=<?=$menuID?>" method="POST" name="frm">
					<input type="hidden" name="ingrID" value="<?=$ingrID?>" />
					<tr><td height="10" width="17%"></td><td width="30%" class="fs10"><i>* required fields</i></td><td height="10" width="15%"></td>
					<td width="38%"></td></tr>
					<tr valign="top"><td colspan="2">MENU NAME:&nbsp;<b><?=$menuName?></b><br/>MENU CODE:&nbsp;<b><?=$mCode?></b></td>
						<td align="right"><b style="color:#FF0000; font-size:15px">* </b>DETAILS:&nbsp;</td>
						<td><textarea name="details" class="formtextarea"><?=$details?></textarea></td></tr>
					<tr valign="top"><td></td><td class="errmsg" colspan="2"><?=$errmsg?></td>
					<td><input class="fs12" type="submit" name="action" value="CREATE" /></td></tr>
					</form>
				<?php
				}
				?>
				<tr><td colspan="4"><hr /></td></tr>
			</table></td></tr>
</table>
<?php
include("footer.php");
?>