<?php 
include "includes/header.php"; 
include "includes/Mdme-functions.php";
$mdme = getMdmeMenu($db,'');
include_once "includes/pagepermission.php";

//check permission - START
if(!($res_modm_prm)){
	header("Location:".admin_public_url."error.php");
}
//check permission - END

$id=$_REQUEST['id'];
if($id!="")
{
	
//check edit permission - START	
if(trim($res_modm_prm['EditPrm'])=="0") {
?>
<script>
  window.location="error.php";
</script>
<?php	
}
//check edit permission - END	

$operation="Edit";
$act="update";
$btn='Update';

$str_ed = "select * from a_menus where IsActive != '2' and MenuId = '".base64_decode($id)."' ";
$res_ed = $db->get_a_line($str_ed);

$edit_id = $res_ed['MenuId'];

$chk='';
if($res_ed['IsActive']=='1')
{
	$chk='checked';
}

}
else
{
	
//check edit permission - START	
if(trim($res_modm_prm['AddPrm'])=="0") {
?>
<script>
  window.location="error.php";
</script>
<?php	
}
//check edit permission - END

	$operation="Add";
	$act="insert";
	$btn='Save';
}
?>  


<div class="wrapper">
    <div class="container">
        <!-- Page-Title - START -->
        <div class="row">
            <div class="col-sm-12">										
                <h4 class="page-title"><?php echo $operation; ?> Menu</h4>				
            </div>
        </div>
		<!-- Page-Title - END -->	
					
		<div class="row">
            <div class="col-sm-12">
				<form class="form-horizontal" role="form" id="jvalidate" name="frmMenu" action="#" method="post" >
				<input type="hidden" name="action" value="<?php echo $act; ?>" />
				<input type="hidden" name="edit_id" value="<?php echo $edit_id; ?>"  />
				
				<div class="card-box">
					<div class="form-group row">
						<label class="col-md-2 form-control-label">Menu Name</label>
						<div class="col-md-10">											
							<input type="text" class="form-control jsrequired" name="txtMenuname" id="txtMenuname" value="<?php echo $res_ed['MenuName']; ?>" />											
						</div>
					</div>	
					<div class="form-group row">
						<label class="col-md-2 form-control-label">Description &nbsp;</label>
						<div class="col-md-10">		
							<textarea class="form-control" name="txtMenuDesc" id="txtMenuDesc"><?php echo $res_ed['Description']; ?></textarea>		
						</div>
					</div>
					<div class="form-group row">
                        <label class="col-md-2 form-control-label">Sorting Order</label>
                        <div class="col-md-10">
                            <input type="text" class="form-control" name="txtSortingorder" id="txtSortingorder" value="<?php echo $res_ed['SortingOrder']; ?>" onkeypress="return isNumber(event)" />
                        </div>
                    </div>
					<div class="form-group row">
                        <label class="col-md-2 form-control-label" for="chkstatus">Status</label>
                        <div class="col-md-10">
                            <input type="checkbox" id="chkstatus" name="chkstatus" <?php echo $chk; ?> />
                        </div>
                    </div>
					
					<div class="form-group row">
						<div class="col-md-2"></div>
						<div class="col-md-10">														
							<button class="btn btn-primary waves-effect waves-light" type="button" onClick="javascript:funSubmt('frmMenu','menu_actions.php','jvalidate','menu','menu_mng.php');" ><span id="spSubmit"><?php echo $btn; ?></span></button>	
										 
							<button class="btn btn-secondary waves-effect m-l-5" type="button" onClick="javascript:funCancel('frmMenu','jvalidate','menu','menu_mng.php');" >Cancel</button>							
							
						</div>
					</div>
					
				</div>
				
					
				</form>
            </div>
        </div> <!-- end row -->		

<?php include "includes/footer.php";  ?> 
	</div> <!-- container -->
</div> <!-- End wrapper -->

<?php include "includes/footer_script.php";  ?> 

</body>
</html>