<?php
include('session.php');
?>
<!doctype html>
<html lang="en">

<head>
<title>LaktusDev | Home</title>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge, chrome=1">
<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=0">
<meta name="description" content="">
<meta name="author" content="LaktusDev, design by: laktusdev.com">

<link rel="icon" href="favicon.ico" type="image/x-icon">
<!-- VENDOR CSS -->
<link rel="stylesheet" href="assets/vendor/bootstrap/css/bootstrap.min.css">
<link rel="stylesheet" href="assets/vendor/font-awesome/css/font-awesome.min.css">
<link rel="stylesheet" href="assets/vendor/animate-css/vivify.min.css">

<link rel="stylesheet" href="assets/vendor/light-gallery/css/lightgallery.css">
<link rel="stylesheet" href="assets/vendor/dropify/css/dropify.min.css">
<link rel="stylesheet" href="assets/vendor/jquery-steps/jquery.steps.css">

<link rel="stylesheet" href="assets/vendor/bootstrap-multiselect/bootstrap-multiselect.css">
<link rel="stylesheet" href="assets/vendor/parsleyjs/css/parsley.css">

<link rel="stylesheet" href="assets/vendor/sweetalert/sweetalert.css"/>

<link rel="stylesheet" href="assets/vendor/jquery-datatable/dataTables.bootstrap4.min.css">
<link rel="stylesheet" href="assets/vendor/jquery-datatable/fixedeader/dataTables.fixedcolumns.bootstrap4.min.css">
<link rel="stylesheet" href="assets/vendor/jquery-datatable/fixedeader/dataTables.fixedheader.bootstrap4.min.css">

<!-- MAIN CSS -->
<link rel="stylesheet" href="assets/css/mooli.min.css">

<script src="assets/vendor/ckeditor/ckeditor.js"></script>

</head>
<body>
    
<div id="body" class="theme-green">

<?php require 'includes/page-loader.php'; ?>

<?php require 'includes/themesetting.php'; ?>

    <!-- Overlay For Sidebars -->
    <div class="overlay"></div>

    <div id="wrapper">

<?php require 'includes/topbar.php'; ?>

<?php require 'includes/leftbar.php'; ?> 

        <!-- Main body part  -->
        <div id="main-content">
            <div class="container-fluid">
                <!-- Page header section  -->
                <div class="block-header">
                    <div class="row clearfix">
                        <div class="col-md-5 col-sm-12">
                            <h1>Menu content</h1>
                            <span></span>
                        </div> 
<?php
$colname_cat = $_GET['content_cat'];
$content_sub = $_GET['content_sub'];
$query_links = "SELECT * FROM le_menu_category as c left join le_menu_subcat as s on c.menu_cat_id = s.menu_subcat_cat WHERE c.menu_cat_id = '".$colname_cat."' and s.menu_subcat_id = '".$content_sub."'";
$links = mysqli_query($leld,$query_links);
$row_links = mysqli_fetch_assoc($links);
$totalRows_links = mysqli_num_rows($links);
?>	
                        <div class="col-md-7 col-sm-12 text-md-right">
                            <div class="d-flex align-items-center justify-content-md-end mt-4 mt-md-0 flex-wrap vivify pullUp delay-550">
                                <div class="border-right pr-4 mr-4 mb-2 mb-xl-0">
                                    <p class="text-muted mb-1">&nbsp;</p>
                                    <h5 class="mb-0"><a href="menu_sub.php?menu_subcat_cat=<?php echo $colname_cat; ?>"><?php echo $row_links['menu_cat_name']; ?></a></h5>
                                </div>
                                <div class="border-right pr-4 mr-4 mb-2 mb-xl-0">
                                    <p class="text-muted mb-1">&nbsp;</p>
                                    <h5 class="mb-0"><?php echo $row_links['menu_subcat_name']; ?></h5>
                                </div>
                                <div class="border-right pr-4 mr-4 mb-2 mb-xl-0">
                                    <p class="text-muted mb-1"><?php echo date('l'); ?></p>
                                    <h5 class="mb-0"><?php echo date('d').'. '.date('m').'. '.date('Y'); ?></h5>
                                </div>
                                <div class="mb-3 mb-xl-0">
                                    <a href="add_content.php" class="btn btn-success"><i class="fa fa-plus-square"></i> Add content</a>
                                </div>
                            </div>
                        </div>
                    </div>
                </div>

                <div class="row clearfix">
                    <div class="col-12">
                        <div class="card">
                            <div class="header">
                                <ul class="nav nav-tabs3">
                                    <li class="nav-item"><a class="nav-link active show" data-toggle="tab" href="#Menu-Content">Menu content</a></li>
                                </ul>
                            </div>
                            <div class="body">
                                <div class="tab-content mt-0">
                                    <div class="tab-pane show active" id="Menu-Content">
<?php
$colname_cat = $_GET['content_cat'];
$content_sub = $_GET['content_sub'];

if (isset($_GET['page_no']) && $_GET['page_no']!="") {
$page_no = $_GET['page_no'];
} else {
	$page_no = 1;
	}

$total_records_per_page = 20;
$offset = ($page_no-1) * $total_records_per_page;
$previous_page = $page_no - 1;
$next_page = $page_no + 1;
$adjacents = "2"; 

$result_count = mysqli_query($leld,"SELECT COUNT(*) As total_records FROM `le_menu_content` WHERE content_cat='$colname_cat' and content_sub = '$content_sub'");
$total_records = mysqli_fetch_array($result_count);
$total_records = $total_records['total_records'];
$total_no_of_pages = ceil($total_records / $total_records_per_page);
$second_last = $total_no_of_pages - 1; // total page minus 1

$result_content = mysqli_query($leld,"SELECT * FROM le_menu_content WHERE content_cat='$colname_cat' and content_sub = $content_sub LIMIT $offset, $total_records_per_page");

?>
								<div class="card">
									<div class="card-header">
                                         <span class="badge badge-success"><?php echo $total_records ?></span>
                                    </div>
									<div class="card-body">
										
										<div class="row clearfix">
<?php while($row_content = mysqli_fetch_assoc($result_content)) { ?>
										<div class="col-lg-3 col-md-6">
										<div class="card n_category">

											<div class="card-body">
<?php
$me = $row_content['content_id'];
$query_content_edit = "SELECT * FROM le_menu_content WHERE content_id = '".$me."'";
$content_edit = mysqli_query($leld,$query_content_edit);
$row_content_edit = mysqli_fetch_assoc($content_edit);
$totalRows_content_edit = mysqli_num_rows($content_edit);
?>
												<h5 class="card-title">&nbsp;</h5>
												<p class="card-text"><?php echo $row_content['content']; ?></p>
												<p class="card-text"><small class="text-muted"></small></p>
<?php if ($row_content['content_active'] == 'y') { ?>
												<span class="sub_n_category bg-green"><?php echo $row_content['content_price']; ?></span>
<?php } else { ?>
												<span class="sub_n_category bg-red"><?php echo $row_content['content_price']; ?></span>
<?php } ?>
												<div class="align-left">
													<button type="button" class="btn btn-blue btn-circle btn-sm edit_button" data-toggle="modal" data-target=".edit<?php echo $row_content_edit['content_id']; ?>"><i class="fa fa-pencil" data-placement="top" data-toggle="tooltip" title="Izmeniti"></i></button>
													<button type="button" class="btn btn-blue btn-circle btn-sm delete_button" data-toggle="modal" data-target="#delete<?php echo $row_content_edit['content_id']; ?>"><i class="fa fa-trash-o" data-placement="top" data-toggle="tooltip" title="Izbrisati"></i></button>
												</div>
												<div class="modal fade edit<?php echo $row_content_edit['content_id']; ?>" role="dialog" data-backdrop="static" aria-labelledby="myLargeModalLabel" aria-hidden="true">
													<div class="modal-dialog modal-lg">
														<div class="modal-content">
															<div class="modal-header">                                            
																<h4 class="modal-title"><i class="fa fa-edit"></i>&nbsp;</h4>
																<button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">×</span></button>
															</div>
															<form action="content_edit.php" method="post" name="form<?php echo $row_content_edit['content_id']; ?>" id="form<?php echo $row_content_edit['content_id']; ?>">
															<div class="modal-body">
																<div class="form-group c_form_group">
																	<label>Sadržaj menija</label>
																	<div class="input-group">
																		<input type="text" name="content" value="<?php echo htmlentities($row_content_edit['content'], ENT_COMPAT, 'utf-8'); ?>" class="form-control" required data-parsley-maxlength="255">
																	</div>
																</div>
																<div class="form-group c_form_group">
																	<label>Cena</label>
																	<div class="input-group">
																		<input type="numeric" name="content_price" value="<?php echo htmlentities($row_content_edit['content_price'], ENT_COMPAT, 'utf-8'); ?>" class="form-control" data-parsley-maxlength="11">
																	</div>
																</div>
																<div class="form-group c_form_group">
																	<label>Status</label>
																	<select name="content_active" class="custom-select" id="inputGroupSelect01">
																		<option value="n"<?php if (!(strcmp('n', htmlentities($row_content_edit['content_active'])))) {echo "selected=\"selected\"";} ?>>Nije aktivan</option>
																		<option value="y"<?php if (!(strcmp('y', htmlentities($row_content_edit['content_active'])))) {echo "selected=\"selected\"";} ?>>Aktivan</option>
																	</select>
																</div>
															</div>
															<div class="modal-footer">
																<button type="submit" class="btn btn-success">Sačuvaj</button>
																<button type="button" class="btn btn-default" data-dismiss="modal">Close</button>
															</div>
															<input name="content_id" type="hidden" value="<?php echo $row_content_edit['content_id'];?>" />
															<input name="content_cat" type="hidden" value="<?php echo $row_content_edit['content_cat'];?>" />
															<input name="content_sub" type="hidden" value="<?php echo $row_content_edit['content_sub'];?>" />
															<input name="content_subsub" type="hidden" value="<?php echo $row_content_edit['content_subsub'];?>" />
															<input type="hidden" name="edit" value="1" />
															</form>
														</div>
													</div>
												</div>
												<div class="modal fade" id="delete<?php echo $row_content_edit['content_id']; ?>" data-backdrop="static" role="dialog" aria-labelledby="exampleModalCenterTitle" aria-hidden="true">
													<div class="modal-dialog modal-dialog-centered" role="document">
														<div class="modal-content">
															<div class="modal-header">
																<h5 class="modal-title" id="exampleModalCenterTitle">Upozorenje!</h5>
																<button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">&times;</span></button>
															</div>
															<div class="modal-body">
																<p>Da li ste sigurni da želite da obrišete podatke?</p>
															</div>
															<div class="modal-footer">
																<a href="content_delete.php?content_id=<?php echo $row_content_edit['content_id']; ?>" class="btn btn-primary theme-bg gradient">Da</a>
																<button type="button" class="btn btn-default" data-dismiss="modal">Ne</button>
															</div>
														</div>
													</div>
												</div>
											</div>
										</div>
										</div>
<?php } ?>
										</div>

										
									</div>
								</div>
                                    </div>
                                    
                                </div>
                            </div>
                        </div>
                    </div>
                </div>
            </div>
        </div>
        
    </div>

</div>
<!-- Javascript -->
<script src="assets/bundles/libscripts.bundle.js"></script>    
<script src="assets/bundles/vendorscripts.bundle.js"></script>

<!-- Vedor js file and create bundle with grunt  --> 

<!-- Project core js file minify with grunt --> 
<script src="assets/bundles/mainscripts.bundle.js"></script>

<!-- Vedor js file and create bundle with grunt  --> 

<script src="assets/vendor/light-gallery/js/lightgallery-all.min.js"></script><!-- Light Gallery Plugin Js --> 
<script src="assets/vendor/light-gallery/js/mousewheel.min.js"></script><!-- Light Gallery Plugin Js -->
<script src="assets/vendor/bootstrap-multiselect/bootstrap-multiselect.js"></script>
<script src="assets/vendor/parsleyjs/js/parsley.min.js"></script>
<script src="assets/vendor/sweetalert/sweetalert.min.js"></script><!-- SweetAlert Plugin Js -->
<script src="assets/vendor/dropify/js/dropify.js"></script>
<script src="assets/vendor/jquery-steps/jquery.steps.js"></script>
<script src="assets/bundles/datatablescripts.bundle.js"></script>
<script src="assets/vendor/jquery-datatable/buttons/dataTables.buttons.min.js"></script>
<script src="assets/vendor/jquery-datatable/buttons/buttons.bootstrap4.min.js"></script>
<script src="assets/vendor/jquery-datatable/buttons/buttons.colVis.min.js"></script>
<script src="assets/vendor/jquery-datatable/buttons/buttons.html5.min.js"></script>
<script src="assets/vendor/jquery-datatable/buttons/buttons.print.min.js"></script>

<!-- Project core js file minify with grunt --> 
<script src="assets/bundles/mainscripts.bundle.js"></script>
<script src="../js/pages/medias/image-gallery.js"></script>
<script src="../js/pages/forms/dropify.js"></script>
<script src="../js/pages/forms/form-wizard.js"></script>
<script src="../js/pages/ui/dialogs.js"></script>
<script src="../js/pages/tables/jquery-datatable.js"></script>
<script src="../js/pages/forms/editors.js"></script>

<script>
    $(function() {
        // validation needs name of the element
        $('#food').multiselect();

        // initialize after multiselect
        $('#advanced-form').parsley();
    });
</script>
</body>
</html>
