<? include_once("../includes/cmain.inc.php");
$page_id = $_REQUEST['page_id'];
if(is_post_back()) {

	if($page_id!='') {		 
		  $name = $_POST['name'] ?? '';
        $status = $_POST['status'] ?? '';
        $title = $_POST['title'] ?? '';
        $keyword = $_POST['keyword'] ?? '';
        $description = $_POST['description'] ?? '';
        $content = $_POST['content'] ?? '';
		$sql = "update `the_menu` set name='$name', status='$status', title='$title', description='$description', keyword='$keyword', content='$content' where id = $page_id ";
		db_query($sql);		
		set_session_msg("Menu updated successfully.");		
	} else{		
	    $name = $_POST['name'] ?? '';
        $status = $_POST['status'] ?? '';
        $title = $_POST['title'] ?? '';
        $keyword = $_POST['keyword'] ?? '';
        $description = $_POST['description'] ?? '';
        $content = $_POST['content'] ?? '';
		 $sql = "insert into `the_menu` set name='$name',status='$status', title='$title', description='$description', keyword='$keyword', content='$content'";
		db_query($sql);
		set_session_msg("New Menu added successfully.");
	}
	header("Location: menu.php?start=$start");
	exit;
}
$page_id = $_REQUEST['page_id'];
if($page_id!='') {
	$sql = "select * from `the_menu` where id = '$page_id'";
	$result = db_query($sql);
	if ($line_raw = mysqli_fetch_array($result)) {
		@extract($line_raw);
	}
}
?>
<link href="styles.css" rel="stylesheet" type="text/css">

<? include("top.inc.php");?>
<table width="100%" border="0" cellspacing="0" cellpadding="0">
  <tr>
    <td id="pageHead"><div id="txtPageHead">
       Add/Edit Default Menu</div></td>
  </tr>
</table>
<script type="text/javascript" src="fckeditor/fckeditor.js"></script>
<table width="90%" align="left">
<tr><td>
<form method="post" action="" enctype="multipart/form-data" name="form1" id="form1" onSubmit="return validate(this);">
<table width="80%" align="center" border=0 cellpadding="0"  cellspacing="0" class="text">
<tr>
        <?php        $start = isset($_GET['start']) ? intval($_GET['start']) : 0;?>
<td  colspan="2"height="30"  align="right"><a href="menu.php?start=<?=$start?>" class="redcolor"><strong>Back To Default Menu List</strong></a></td>
</tr>    
<tr><td height="15"><div align="center"><span class="msg"><?=display_sess_msg();?></span></div><br /></td></tr>  

<tr><td>&nbsp;</td></tr>
<tr>
<td class="lables"><b>Default Menu Name</b></td>
<td class="feildstxt"><input type="text" style="width:300px;" value="<?=stripslashes($name ?? '')?>" name="name" id="name"  /></td>
</tr>
<tr><td>&nbsp;</td></tr>

<tr>
<td class="lables"><b>Status</b></td>
<td class="feildstxt"><select name="status" id="status">
<option value="1" <?php if(isset($country_status)=='1'){ echo 'selected="selected"'; } ?>>Active</option>
<option value="0" <?php if(isset($country_status)=='0'){ echo 'selected="selected"'; } ?>>InActive</option>          
</select></td>
</tr>
<tr><td>&nbsp;</td></tr>

<tr>
<td class="lables" colspan="2"><hr/></td>
</tr>
<tr><td>&nbsp;</td></tr>

<tr>
<td class="lables"><b>Title </b></td>
<td class="feildstxt"><textarea style="width:300px;" name="title" id="title"  ><?=stripslashes($title ?? '')?></textarea></td>
</tr>
<tr><td>&nbsp;</td></tr>

<tr>
<td class="lables"><b>Description </b></td>
<td class="feildstxt"><textarea style="width:300px;" name="description" id="description"  ><?=stripslashes($description ?? '')?></textarea></td>
</tr>
<tr><td>&nbsp;</td></tr>

<tr>
<td class="lables"><b>Keyword</b></td>
<td class="feildstxt"><textarea style="width:300px;" name="keyword" id="keyword"  ><?=stripslashes($keyword ?? '')?></textarea></td>
</tr>
<tr><td>&nbsp;</td></tr>
<tr>
<td class="lables" colspan="2"><hr/></td>
</tr>

<tr><td>&nbsp;</td></tr>

<tr>
<td class="lables"><b>Menu Content</b></td>
<td class="feildstxt"><textarea style="width:600px;" name="content" id="content"  ><?=stripslashes($content ?? '')?></textarea></td>
</tr>
<tr><td>&nbsp;</td></tr>

<tr>
<td align="left" class="lables">&nbsp;</td>
<td align="left" class="feildstxt"><input class="button" type="submit" name="submit" value="Save"></td>
</tr>
<tr><td height="25">&nbsp;</td></tr>
</table>
</form>
</td></tr></table> 
<script type="text/javascript">
var oFCKeditor=new FCKeditor('content','650','600')	;
oFCKeditor.BasePath="fckeditor/";	
oFCKeditor.ReplaceTextarea();
</script> 
<? include("bottom.inc.php");?>