<?php
/*

Template Name: gallery

*/
?>



<?php if(isset($_REQUEST["um_page"])):
 			if(isset($_POST["paged"])):?>
 			
 			
 			<?php 
				
				if(isset($_POST["um_change"])){
					if($_POST["um_change"] == true){
						$paged = (get_query_var('paged')) ? get_query_var('paged') : 1; 
					}else{
						$paged = $_POST["paged"];
					}
				}
				else{
					$paged = $_POST["paged"];
				}
			
			
				if(isset($_POST["um_cat"])){
						$filterData = $_POST['um_cat'];
						$tax_query = array('relation' => 'AND');
						$tax = '';
						$terms = array();
						
						foreach($filterData as $data){
	
								foreach($data as $cat)
								{	
									if($cat['selected'] != "um_all")
									{
										$tax = $cat['tax'];
										array_push($terms, $cat['selected']);		
							  		}
								}			
								if($tax != '')
								{
								 	array_push($tax_query,array(
						                        'taxonomy' => $tax,
						                        'terms' => $terms,
						                        'field' => 'slug',
						                        'include_children' => false,
						                        'operator' => 'IN'
						                        )
							            );
								}
						}
						$args = array(
							'post_type' => 'room_post',
							'orderby'	=>	'menu_order date',
							'order' 	=> 	'DESC',
							'paged'     => $paged,
							'tax_query' => $tax_query
							
						);
				}
				else{
		
						$args = array(
								'post_type' => 'room_post',
								'orderby'	=>	'menu_order date',
								'order' 	=> 	'DESC',
								'paged'     => $paged
							);
				}
		
						
				$the_Query = new WP_Query($args);
				while ($the_Query->have_posts()):
					$the_Query->the_post();?>

						
			       <div class="col-md-4 um_in animated">
	                        <article class="theBox roomsBox mainBgColor">
	                            <div class="boxContent">
	
									<?php if(has_post_thumbnail()): ?>
	                               		<a href="<?php the_permalink(); ?>">
	                               		<?php the_post_thumbnail('blogMasonry'); ?>	
	                           			</a>
	                            	<?php endif; ?>
	                            </div>
	                            <footer>
	                                <div class="roomTitle um_left">
	                                    <a href="<?php the_permalink(); ?>"><h5 class="title titleUp"><?php the_title(); ?></h5></a>
	                                    <h6><?php the_field('price_label'); ?></h6>
	                                </div>
	                                <div class="roomIcons um_right">
	                                    <div class="boxIcons list-unstyled list-inline text-right">
	                                        <a class="iconHolder brandHover text-center um_expand_lightbox " data-postID="<?php echo $post->ID; ?>" href="#"><i class="fa fa-expand"></i></a>
	                                        
	                                        	<?php 
													$redirectClass = 'um_book';
													if(get_field('redirect_to') != "booking"){
														$redirectClass = '';	
													}
												 ?>
	                                        <a class="iconHolder brandHover text-center <?php echo $redirectClass; ?>" data-postID="<?php echo $the_Query->post->ID; ?>" href="<?php the_field('shop_link',$the_Query->post->ID); ?>"><i class="fa fa-bookmark-o"></i></a>
	                                        
	                                    </div>
	                                </div>
	                            </footer>
	                        </article>
	                    </div>

 			<?php endwhile; ?>
 			
 			<?php endif;
		die();
	endif;  ?>

<?php get_header(); ?>

<?php wp_reset_postdata(); ?>

<?php $featuredImageType = get_field('background_image_type'); ?>
<?php setBgImg();  ?>

<main class="content1 hasFilter roomsPage <?php echo $featuredImageType;?>">
	<div class="breadcrumb_box"> <div class="container"><?php
echo do_shortcode( '[breadcrumb]' ); 
?></div></div>
		<section class="pageImage">
        
			<?php putRevSlider("about","279") ?>
		</section>
	
        
    </main>
    <div style="clear:both"></div>
<div class="container">
            <div class="row">
                <section class="pageTitle text-center">
                	<div class="um_helper">
                		<div class="um_middle">
                			<h3 class="title pageTitle titleUp"><?php the_title(); ?></h3>
                		</div>
                	</div>        
                    
                    <section id="portfolio" class="margin-top50">
        <div class="container">
            <ul class="portfolio-filter text-center">
                <li><a class="btn btn-default active" href="#" data-filter="*">All</a></li>
                <li><a class="btn btn-default" href="#" data-filter=".room">Accommodation</a></li>
                <li><a class="btn btn-default" href="#" data-filter=".dining">DINING</a></li>
                <li><a class="btn btn-default" href="#" data-filter=".spa">SPA</a></li>
            </ul><!--/#portfolio-filter-->

            <div class="row">
                <div class="portfolio-items">
                 <?php $id=331; $post = get_page($id); echo $post->post_content;  ?>
                  
                </div>
            </div>
        </div>
    </section><!--/#portfolio-item--> 
       
          
                </section>
                
			<?php /*?>	<?php get_template_part('content','filters'); ?><?php */?>
                   
	        </div>
            <!--row-->
          
			
        </div>
        
<?php /*?>        
<script>
		var pageRooms = parseInt("<?php echo $paged; ?>");
    	var lastPageRooms = parseInt('<?php echo $the_Query->max_num_pages; ?>');
    	var postId = "<?php echo $post->ID; ?>";	
	
</script><?php */?>

    <?php get_footer(); ?>