<?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_sr.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><img src="assets/images/flag/rs.png" width="20" alt="Srpski" > Menu content</h1>
                            <span></span>
                        </div>            
                        <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"></p>
                                    <h5 class="mb-0"></h5>
                                </div>
                                <div class="border-right pr-4 mr-4 mb-2 mb-xl-0">
                                    <p class="text-muted mb-1"></p>
                                    <h5 class="mb-0"></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_sr.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
$menucat_images_dir = "../../uploads/menu/category/";

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_category_sr`");
$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_events = mysqli_query($leld,"SELECT * FROM le_menu_category_sr as c LEFT JOIN le_menu_category_photo as p ON c.menu_cat_id = p.lemcatid 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_events = mysqli_fetch_assoc($result_events)) { ?>
										<div class="col-lg-3 col-md-6">
										<div class="card n_category">
<?php if ($row_events['photo_id'] == '') { ?>
<?php if ($row_events['menu_cat_active'] == 'y') { ?>
											<span class="sub_n_category bg-green"><?php echo $row_events['menu_cat_name']; ?></span>
<?php } else { ?>
											<span class="sub_n_category bg-red"><?php echo $row_events['menu_cat_name']; ?></span>
<?php } ?>
											<img class="card-img-top" src="<?php echo $menucat_images_dir ?>default.jpg" alt="">
<?php } else { ?>
<?php if ($row_events['menu_cat_active'] == 'y') { ?>
											<span class="sub_n_category bg-green"><?php echo $row_events['menu_cat_name']; ?></span>
<?php } else { ?>
											<span class="sub_n_category bg-red"><?php echo $row_events['menu_cat_name']; ?></span>
<?php } ?>
											<img class="card-img-top" src="<?php echo $menucat_images_dir ?>tb_<?php echo $row_events['slika']; ?>" alt="">
<?php } ?>

						<div class="card-body">
<?php
$me = $row_events['menu_cat_id'];
$query_events_edit = "SELECT * FROM le_menu_category_sr WHERE menu_cat_id = '".$me."'";
$events_edit = mysqli_query($leld,$query_events_edit);
$row_events_edit = mysqli_fetch_assoc($events_edit);
$totalRows_events_edit = mysqli_num_rows($events_edit);
?>
							<h5 class="card-title"></h5>
							<p class="card-text"></p>
							<p class="card-text"><small class="text-muted"></small></p>
							<div class="">
							<a href="menu_sub_sr.php?menu_subcat_cat=<?php echo $row_events['menu_cat_id']; ?>" class="btn btn-blue btn-circle btn-sm" data-placement="top" data-toggle="tooltip" title="Podmenu"><i class="fa fa-th-list"></i></a>
							</div>
							
						</div>
					</div>
					</div>
<?php } ?>
										</div>
<nav>									
<ul class="pagination pagination-split">
<?php if($page_no > 1){ echo "<li class='page-item'><a href='?page_no=1' class='page-link'>&laquo;&laquo;</a></li>"; } ?>

<li <?php if($page_no <= 1){ echo "class='disabled'"; } ?>>
<?php if($page_no > 1){ echo "<a href='?page_no=$previous_page' class='page-link'>&laquo;</a>"; } ?>
</li>
   
<?php 
if ($total_no_of_pages <= 10){  	 
	for ($counter = 1; $counter <= $total_no_of_pages; $counter++){
		if ($counter == $page_no) {
	   echo "<li class='page-item active'><span class='page-link'>$counter</span></li>";	
			}else{
	   echo "<li class='page-item'><a href='?page_no=$counter' class='page-link'>$counter</a></li>";
			}
	}
}
elseif($total_no_of_pages > 10){
	
if($page_no <= 4) {			
 for ($counter = 1; $counter < 8; $counter++){		 
		if ($counter == $page_no) {
	   echo "<li class='page-item active'><span class='page-link'>$counter</span></li>";	
			}else{
	   echo "<li class='page-item'><a href='?page_no=$counter' class='page-link'>$counter</a></li>";
			}
	}
	echo "<li class='page-item'><span class='page-link'>...</span></li>";
	echo "<li class='page-item'><a href='?page_no=$second_last' class='page-link'>$second_last</a></li>";
	echo "<li class='page-item'><a href='?page_no=$total_no_of_pages' class='page-link'>$total_no_of_pages</a></li>";
	}

 elseif($page_no > 4 && $page_no < $total_no_of_pages - 4) {		 
	echo "<li class='page-item'><a href='?page_no=1' class='page-link'>1</a></li>";
	echo "<li class='page-item'><a href='?page_no=2' class='page-link'>2</a></li>";
	echo "<li class='page-item'><span class='page-link'>...</span></li>";
	for ($counter = $page_no - $adjacents; $counter <= $page_no + $adjacents; $counter++) {			
	   if ($counter == $page_no) {
	   echo "<li class='page-item active'><span class='page-link'>$counter</span></li>";	
			}else{
	   echo "<li class='page-item'><a href='?page_no=$counter' class='page-link'>$counter</a></li>";
			}                  
   }
   echo "<li class='page-item'><span class='page-link'>...</span></li>";
   echo "<li class='page-item'><a href='?page_no=$second_last' class='page-link'>$second_last</a></li>";
   echo "<li class='page-item'><a href='?page_no=$total_no_of_pages' class='page-link'>$total_no_of_pages</a></li>";      
		}
	
	else {
	echo "<li class='page-item'><a href='?page_no=1' class='page-link'>1</a></li>";
	echo "<li class='page-item'><a href='?page_no=2' class='page-link'>2</a></li>";
	echo "<li class='page-item'><span class='page-link'>...</span></li>";

	for ($counter = $total_no_of_pages - 6; $counter <= $total_no_of_pages; $counter++) {
	  if ($counter == $page_no) {
	   echo "<li class='page-item active'><span class='page-link'>$counter</span></li>";	
			}else{
	   echo "<li class='page-item'><a href='?page_no=$counter' class='page-link'>$counter</a></li>";
			}                   
			}
		}
}
?>

<li <?php if($page_no >= $total_no_of_pages){ echo "class='disabled'"; } ?>>
<?php if($page_no < $total_no_of_pages) { echo "<a href='?page_no=$next_page' class='page-link'>&raquo;</a>"; } ?>
</li>
<?php if($page_no < $total_no_of_pages){
	echo "<li class='page-item'><a href='?page_no=$total_no_of_pages' class='page-link'>&raquo;&raquo;</a></li>";
	} ?>
</ul>
</nav>
										
									</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>
