<?php
include 'header.php';
include('xcrud/xcrud.php');
echo Xcrud::load_css();
$xcrud=Xcrud::get_instance();
$xcrud->table('menu');
$xcrud->validation_required('menu_name');
$xcrud->change_type('has_option','select','No','No,Yes');
$xcrud->change_type('visibility','select','No','No,Yes');
$xcrud->change_type('file_format','select','jpg','jpg,pdf');
$xcrud->change_type('compulsory','select','yes','yes,no');
$xcrud->unset_title();
$xcrud->button('#','Options','fa fa-bars','',array('data-toggle'=>'modal','data-target'=>'#sm_modal','onclick'=>'openOption({menu_id})'));
$xcrud->after_insert('update_menu_after_insert', 'functions.php');
$xcrud->after_update('update_menu_after_update','functions.php');
if($type!='admin'){
	$xcrud->unset_remove();
	$xcrud->unset_print();
	$xcrud->unset_csv();
}
?>
<div class="row">
	<div class="col-sm-12"><button class="btn btn-blue btn-block">Menu</button></div>
	<div class="col-sm-12">&nbsp</div>
	<div class="col-sm-12">
<?php
echo $xcrud->render();
?>
	</div>
</div>
</div>
</div>
</div>
<?php
include "footer.php";
echo Xcrud::load_js();
?>

<!-- Tag Modal -->
<div id="sm_modal" class="modal fade" role="dialog" data-keyboard="false" data-backdrop="static">
	<div class="modal-dialog">
		<div class="modal-content">
			<div class="modal-header">
				<button type="button" class="close" data-dismiss="modal">&times;</button>
				<h4 class="modal-title">Package Details</h4>
			</div>
			<div class="modal-body" id="pd_data">
				
			</div>
			<div class="modal-footer">
				<button type="button" class="btn btn-default" data-dismiss="modal" onclick="reloadPage()">Close</button>
			</div>
		</div>
	</div>
</div>

<script type="text/javascript">
function openOption(id)
{
	dataString='action=openOption&id='+id;
	$.ajax({
		type:'POST',
		url:'ajax_data.php',
		data:dataString,
		success:function(data){
			$('#pd_data').html(data);
		}
	});
	$('#sm_modal').modal('show');
}
function reloadPage(){
	window.location.reload();
}
</script>