<?php 
/**
 * Template Name: Vacante
 */
get_header(); 
				   	wp_reset_query();
				   	$width =980;
					$height = 408;
					$image_url ='';
					$image_url = cs_get_post_img_src($post->ID, $width, $height);
					if (post_password_required()) { 
						
						echo '<div class="rich_editor_text">'.cs_password_form().'</div>';
					}else{
					$cs_meta_page = cs_meta_page('cs_page_builder');
					if (count($cs_meta_page) > 0) {
						if ( $cs_meta_page->sidebar_layout->cs_layout <> '' and $cs_meta_page->sidebar_layout->cs_layout <> "none" and $cs_meta_page->sidebar_layout->cs_layout == 'left') :   ?>
            				<aside class="col-md-3">
                     			<?php if ( !function_exists('dynamic_sidebar') || !dynamic_sidebar($cs_meta_page->sidebar_layout->cs_sidebar_left) ) : endif; ?>
                     		</aside>
                		<?php endif; ?>
                        <?php if ( $cs_meta_page->cs_layout == 'both_left') :   ?>
						   <?php cs_meta_sidebar();?>
                        <?php endif; ?>
               	 		<div class="<?php echo cs_meta_content_class();  ?> ">
                        <?php 
 						
						
						if($image_url <> ''){ 
					  		echo '<figure class="featured-img"><a href="'.get_permalink().'" ><img src="'.$image_url.'" alt="" ></a></figure>';
					   	}
						if($cs_meta_page->page_content == "Yes" && get_the_content() <> ''){
 							echo '<div class="rich_editor_text">';
								the_content();
								wp_link_pages( array( 'before' => '<div class="page-links"><span class="page-links-title">' . __( 'Pages:', 'WeStand' ) . '</span>', 'after' => '</div>', 'link_before' => '<span>', 'link_after' => '</span>' ) );
 							echo '</div>';
						}
						global $cs_counter_node;
						foreach ( $cs_meta_page->children() as $cs_node ) {
							
   							if ( $cs_node->getName() == "blog" ) {
								$cs_counter_node++;
								$layout = $cs_meta_page->sidebar_layout->cs_layout;
								get_template_part( 'page_blog', 'page' );
 							}
							else if ( $cs_node->getName() == "gallery" ) {
								$cs_counter_node++;
  								if ( $cs_node->album <> "" and $cs_node->album <> "0" ) {
									get_template_part( 'page_gallery', 'page' );
								}
							}
							else if ( $cs_node->getName() == "event" ) {
								$cs_counter_node++;
 								if ( $cs_node->cs_event_category <> "") {
									get_template_part( 'page_event', 'page' );
								}
							}
							elseif($cs_node->getName() == "cause"){

							   $cs_counter_node++;

							   get_template_part('page_cause','page');

 							}
							else if ( $cs_node->getName() == "slider"  and $cs_node->slider_view == "content") {
								$cs_counter_node++;
 								get_template_part( 'page_slider', 'page' );
 							}
														
							elseif($cs_node->getName() == "contact"){
							   $cs_counter_node++;
							   get_template_part('page_contact','page');
 							}
							else if ( $cs_node->getName() == "team" ) {
								$cs_counter_node++;
								get_template_part( 'page_team', 'page' );
							}
							
							
							elseif($cs_node->getName() == "accordions"){
								$cs_counter_node++;
								cs_accordions_page();
							}
							elseif($cs_node->getName() == "tabs"){
								$cs_counter_node++;
								echo cs_tabs_page();
							}
							elseif ($cs_node->getName() == "services") {
                                $cs_counter_node++;
                                cs_services_page();
                            }
							elseif($cs_node->getName() == "video"){
								$cs_counter_node++;
								echo cs_video_page();
							}
							elseif($cs_node->getName() == "quote"){
								$cs_counter_node++;
								echo cs_quote_page();
							}
							
 							elseif($cs_node->getName() == "column"){
								$cs_counter_node++;
								cs_column_page();
							}
							
							elseif($cs_node->getName() == "map"  and $cs_node->map_view == "content"){
								$cs_counter_node++;
								echo cs_map_page();
							}
							elseif ($cs_node->getName() == "parallax") {
                                $cs_counter_node++;
								get_template_part('page_parallax','page');
                            }
							
							

						}
                     	wp_reset_query(); 
					 	if ( comments_open() ) : 
					 		comments_template('', true); 
		   				endif; 
						?>
                 
                 
                 
	                 
	                 
	                 
	                 <?php
						$post_type = 'excursii';
						
						$args_new = array(
							'posts_per_page'   => -1,
							//'nopaging'         => true,
							'orderby' => array('date' => 'DESC', 'menu_order' => 'ASC' ),
							'post_type'        => $post_type,
							'post_status'      => 'publish',
							'suppress_filters' => false,
							'tax_query' => array(
								array(
									'taxonomy' => 'status',
									'terms' => array('expirat'),
									'field' => 'slug',
									'operator' => 'NOT IN',
								),
							),
						);
						
						$myposts = new WP_Query( $args_new );
						
						$myposts_count = $myposts->found_posts;
						
						if ( $myposts->have_posts() ) : 
					?>
					<div class="row excursii-shortcode">
						
						<?php while ( $myposts->have_posts() ) :$myposts->the_post(); ?>
							
							<?php include(locate_template('inc/loop-excursii.php')); ?>
							
						<?php endwhile; wp_reset_postdata(); ?>
						<?php if($myposts_count % 2 != 0){ ?>
							<div class="col-sm-6 col-xs-12 excursie excursie-shrotcode">
								<span class="excursie-prezentare excursie-subscribe">
									<span class="display-table-absolute">
										<span class="display-table">
											<span class="display-table-cell">
												<?php 
													$excursii_shortcode = get_theme_mod( 'excursii_subscribe' );
													echo do_shortcode($excursii_shortcode);
													//echo do_shortcode('[contact-form-7 id="7099" title="Nesletter"]'); 
												?>
											</span>
										</span>
									</span>
								</span>
							</div>
						<?php } ?>
					</div>
					<?php endif; ?>	
	                
	                
	                <?php
						$post_type = 'excursii';
						
						$args_new = array(
							'posts_per_page'   => -1,
							//'nopaging'         => true,
							'orderby' => array('date' => 'DESC', 'menu_order' => 'ASC' ),
							'post_type'        => $post_type,
							'post_status'      => 'publish',
							'suppress_filters' => false,
							'tax_query' => array(
								array(
									'taxonomy' => 'status',
									'terms' => array('expirat'),
									'field' => 'slug',
									'operator' => 'IN',
								),
							),
						);
						
						$myposts = new WP_Query( $args_new );
						
						$myposts_count = $myposts->found_posts;
						
						if ( $myposts->have_posts() ) : 
					?>
					<div class="row excursii-shortcode excursii-expirate" style="margin-top: 50px;">
						
						<div class="col-md-12">
							<h2><?php _e('Vacanțe din trecut','theme'); ?></h2>
						</div>
						
						<?php while ( $myposts->have_posts() ) :$myposts->the_post(); ?>
							
							<?php include(locate_template('inc/loop-excursii.php')); ?>
							
						<?php endwhile; wp_reset_postdata(); ?>
					</div>
					<?php endif; ?>
				
				
				
				</div>
                 
                 
                 
                 
                 
                 
                 
                 
                 
                 
						<?php if ( $cs_meta_page->sidebar_layout->cs_layout <> '' and $cs_meta_page->sidebar_layout->cs_layout <> "none" and $cs_meta_page->sidebar_layout->cs_layout == 'right') : ?>
                            <aside class="col-md-3">
                                    <?php if ( !function_exists('dynamic_sidebar') || !dynamic_sidebar($cs_meta_page->sidebar_layout->cs_sidebar_right) ) : endif; ?>
                             </aside>
                        <?php endif; ?>
                       
             		<?php }else{ 
						if($image_url <> ''){ 
					  		echo '<figure class="featured-img"><a href="'.get_permalink().'" ><img src="'.$image_url.'" alt="" ></a></figure>';
					   	}
					?>
            		<div class="rich_editor_text">
					<?php 
                        while (have_posts()) : the_post();
                            the_content();
							wp_link_pages( array( 'before' => '<div class="page-links"><span class="page-links-title">' . __( 'Pages:', 'WeStand' ) . '</span>', 'after' => '</div>', 'link_before' => '<span>', 'link_after' => '</span>' ) );
                        endwhile; 
						if ( comments_open() ) { 
					 		comments_template('', true); 
						}
						wp_reset_query();
                    ?>
                </div>
			<?php }
			} 
		?>
<?php get_footer();?>
<!-- Columns End -->