<!DOCTYPE html>

<html>
    <head>
        <meta charset="utf-8">
        <title>Gallery - Luxury Event Catering Tivat</title>
        <meta name="description" content="Luxury Event Catering Tivat MONTENEGRO - Gallery">
		<meta name="robots" content="index,follow" />
        <meta name="author" content="LaktusDev">
        <meta name="keywords" content="">
        <meta name="viewport" content="width=device-width, initial-scale=1.0">

        <!-- Stylesheets -->
		<link rel="icon" href="icon.jpg">
        <link rel="stylesheet" href="css/bootstrap.min.css"/><!-- bootstrap grid -->
        <link rel="stylesheet" href="css/bootstrap-theme.min.css"/><!-- bootstrap theme -->
        <link rel="stylesheet" href="css/style.css"/><!-- template styles -->
        <link rel="stylesheet" href="css/color-default.css"/><!-- default template color styles -->
        <link rel="stylesheet" href="css/retina.css"/><!-- retina ready styles -->
        <link rel="stylesheet" href="css/responsive.css"/><!-- responsive styles -->
        <link rel="stylesheet" href="css/animate.css"/><!-- animation for content -->

        <!-- Magnific Popup - image lightbox -->
        <link rel="stylesheet" href="css/magnific-popup.css" />

        <!-- Google Web fonts -->
        <link href='https://fonts.googleapis.com/css?family=Montserrat:400,700' rel='stylesheet' type='text/css'>
        <link href='https://fonts.googleapis.com/css?family=Suranna' rel='stylesheet' type='text/css'>
        <link href='https://fonts.googleapis.com/css?family=Montez' rel='stylesheet' type='text/css'>

        <!-- Font icons -->
        <link rel="stylesheet" href="font-awesome/css/font-awesome.min.css"/><!-- Font awesome icons -->
    </head>

    <body>

<?php include("inc/header.php"); ?>

        <!-- .page-content start -->
        <div class="page-content custom-img-background dark page-title page-title-4 mb-100">
            <div class="container">
                <!-- .row start -->
                <div class="row">
                    <!-- .col-md-12 start -->
                    <div class="col-md-12 centered">
                        <div class="custom-heading style-1 triggerAnimation animated" data-animate='fadeInUp'>
                            <h1><span>Gallery</span></h1>
                            <h1>Take a look inside</h1>
                        </div><!-- .custom-heading.style-1 end -->
                    </div><!-- .col-md-12 end -->
                </div><!-- .row end -->
            </div><!-- .container end -->
        </div><!-- .page-content end -->

        <!-- .page-content start -->
        <div class="page-content">
            <!-- .container start -->
            <div class="container">
                <!-- .row start -->
                <div class="row gallery-filters">
                    <div class="col-md-12 mb-20 centered triggerAnimation animated" data-animate='fadeIn'>
                        <div class="custom-heading style-1">
                            <h3><span>Luxury Event</span></h3>
<?php
$me = (int)($_GET['cid']);
$query_gallery_edit = "SELECT * FROM le_gallery_category WHERE category_id = '".$me."'";
$gallery_edit = mysqli_query($leld,$query_gallery_edit);
$row_gallery_edit = mysqli_fetch_assoc($gallery_edit);
$totalRows_gallery_edit = mysqli_num_rows($gallery_edit);
?>
                            <h3><?php echo $row_gallery_edit['category_name']; ?></h3>

                            <!-- .divider.style-1 start -->
                            <div class="divider style-1 center">
                                <span class="hr-simple left"></span>
                                <i class="fa fa-circle hr-icon"></i>
                                <span class="hr-simple right"></span>
                            </div>
                        </div><!-- .custom-heading.style-1 end -->
                        
                    </div><!-- .col-md-12 end -->                    
                </div><!-- .row.gallery-filters end -->
            </div><!-- .container end -->
        </div><!-- .page-content end -->

        <div class="page-content">
            <div class="container-fluid">
                <div class="row">
                    <ul id="galleryitems" class="isotope isotopeitems-full">
<?php
if (isset($_GET['page_no']) && $_GET['page_no']!="") {
$page_no = $_GET['page_no'];
} else {
	$page_no = 1;
	}

$gallery_images_dir = "uploads/gallery/";
$cid = (int)($_GET['cid']);

$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_gallery_photos` where legcid = $cid");
$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_gallery = mysqli_query($leld,"SELECT * FROM le_gallery_photos where legcid = $cid LIMIT $offset, $total_records_per_page");

?>
<?php while($row_gallery = mysqli_fetch_assoc($result_gallery)) { ?>
                        <li class="col-xs-6 col-md-3 isotope-item outdoor">
                            <figure class="gallery-item-container">
                                <div class="gallery-img">
                                    <img src="<?php echo $gallery_images_dir ?><?php echo $row_gallery['slika']; ?>" alt="Luxury Event Catering Tivat"/>

                                    <div class="hover-mask-container">
                                        <div class="hover-zoom">
                                            <a href="<?php echo $gallery_images_dir ?><?php echo $row_gallery['slika']; ?>" class="triggerZoom fa fa-search" title="<?php echo $row_gallery['opis']; ?>"></a>
                                        </div><!-- .hover-zoom end -->
                                    </div><!-- .hover-mask-container end -->
                                </div><!-- .gallery-img end -->
                            </figure><!-- .gallery-item-container end -->
                        </li><!-- .isotope-item end -->
<?php } ?>
                    </ul><!-- #galleryitems.isotope end -->
                </div><!-- .row end -->
				<div class="row">
				<ul class="col-md-12 blog-posts post-list">
					<li class="pagination">
						<ul>

<?php if($page_no > 1){ echo "<li><a href='?cid=$cid&page_no=1'>&laquo;&laquo;</a></li>"; } ?>

<li <?php if($page_no <= 1){ echo "class='disabled'"; } ?>>
<?php if($page_no > 1){ echo "<a href='?cid=$cid&page_no=$previous_page'>&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='active'><a>$counter</a></li>";	
			}else{
	   echo "<li><a href='?cid=$cid&page_no=$counter'>$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='active'><a>$counter</a></li>";	
			}else{
	   echo "<li><a href='?cid=$cid&page_no=$counter'>$counter</a></li>";
			}
	}
	echo "<li'><span>...</span></li>";
	echo "<li><a href='?cid=$cid&page_no=$second_last'>$second_last</a></li>";
	echo "<li><a href='?cid=$cid&page_no=$total_no_of_pages'>$total_no_of_pages</a></li>";
	}

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

	for ($counter = $total_no_of_pages - 6; $counter <= $total_no_of_pages; $counter++) {
	  if ($counter == $page_no) {
	   echo "<li class='active'><a>$counter</a></li>";	
			}else{
	   echo "<li><a href='?cid=$cid&page_no=$counter'>$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='?cid=$cid&page_no=$next_page'>&raquo;</a>"; } ?>
</li>
<?php if($page_no < $total_no_of_pages){
	echo "<li><a href='?cid=$cid&page_no=$total_no_of_pages'>&raquo;&raquo;</a></li>";
	} ?>
						</ul>
					</li>
				</ul>
				</div>
            </div><!-- .container-fluid end -->
        </div><!-- .page-content end -->

<?php include("inc/footer.php"); ?>

<?php include("inc/copyright.php"); ?>

        <script src="js/jquery-2.1.4.min.js"></script><!-- jQuery library -->
        <script src="js/bootstrap.min.js"></script><!-- .bootstrap script -->
        <script src="js/jquery.scripts.min.js"></script><!-- modernizr, retina, stellar for parallax -->  
        <script src="js/gallery.js"></script><!-- for gallery -->
        <script src="js/jquery.dlmenu.min.js"></script><!-- for responsive menu -->
        <script src="js/include.js"></script><!-- custom js functions -->
        <script src="js/jquery.isotope.min.js"></script><!-- jQuery isotope plugin -->
        <script src="js/jquery.magnific-popup.min.js"></script><!-- used for image lightbox -->
        <script src="js/TweenMax.min.js"></script> <!-- Plugin for smooth scrolling-->
        <script src="js/ScrollToPlugin.min.js"></script> <!-- Plugin for smooth scrolling-->

        <script>
            /* <![CDATA[ */
            jQuery(document).ready(function ($) {
                'use strict';

                


            });
            /* ]]> */
        </script>

    </body>
</html>
