<?php
/*
 * Templatation.com
 *
 * Hero block box shortcode for VC
 *
 */

$css_class = $gallery_type = '';
$atts = vc_map_get_attributes( $this->getShortcode(), $atts );
extract( $atts );
$css_class = apply_filters( VC_SHORTCODE_CUSTOM_CSS_FILTER_TAG, vc_shortcode_custom_css_class( $css, ' ' ), $this->settings['base'], $atts );

if($gallery_type == 'type1') { ?>


<section class="fleet-gallery  gray-bg sec-padding  <?php echo esc_attr($el_class).' '.esc_attr($css_class); ?>">
	<div class="thm-container">
		<ul class="gallery-filter text-center">
			<li class="filter" data-filter="all"><span><?php esc_html_e('All', 'logiscargo'); ?></span></li>
			<?php
                        $categories = get_terms('type');
                         foreach( (array)$categories as $categorie){
                            $cat_name = $categorie->name;
                            $cat_slug = $categorie->slug;
                    ?>
			<li class="filter" data-filter=".<?php echo esc_attr($cat_slug);?>"><span><?php echo esc_attr($cat_name);?></span></li>
			<?php } ?>
		</ul>
		<div class="clearfix single-fleet-gallery-wrapper">

			<?php
                        $args = array(
                                    'post_type' => 'tt-gallery',
                                    'posts_per_page' => '-1',
                                );
                                $wp_query = new WP_Query($args);
                                $i = 1;
                                while ($wp_query -> have_posts()) : $wp_query -> the_post();
                                $cates = get_the_terms(get_the_ID(),'type');
                                $cate_name ='';
                                $cate_slug = '';
                                      foreach((array)$cates as $cate){
                            if(count($cates)>0){
                                $cate_name .= $cate->name.' ' ;
                                $cate_slug .= $cate->slug .' ';
                                }
                                }
                ?>
			<div class="col-md-4 col-sm-6 col-xs-12 mix <?php echo esc_attr($cate_slug);?>">
				<div class="single-fleet-gallery img-cap-effect">
					<div class="img-box">
						<img src="<?php echo wp_get_attachment_url( get_post_thumbnail_id());?>" alt=""/>
						<div class="img-caption">
							<div class="box-holder">
								<div class="box-caption">
									<div class="caption-text">
										<h3><?php the_title();?></h3>
									<p><?php tt_logiscargo_excerpt_charlength('200'); ?></p>
									</div>
									<ul>
										<li><a href="<?php echo wp_get_attachment_url( get_post_thumbnail_id());?>" class="fancybox"><i class="fa fa-search-plus"></i></a></li>
									</ul>
								</div>
							</div>
						</div>
					</div>
				</div>
			</div>
			<?php $i++;
                endwhile; wp_reset_postdata(); ?>

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

<?php } elseif($gallery_type == 'type2') { ?>

<section class="fleet-gallery pt0 sec-padding <?php echo esc_attr($el_class).' '.esc_attr($css_class); ?>">
	<div class="clearfix">
		<ul class="gallery-filter text-center">
			<li class="filter" data-filter="all"><span><?php esc_html_e('All', 'logiscargo'); ?></span></li>
			<?php
                        $categories = get_terms('type');
                         foreach( (array)$categories as $categorie){
                            $cat_name = $categorie->name;
                            $cat_slug = $categorie->slug;
                    ?>
			<li class="filter" data-filter=".<?php echo esc_attr($cat_slug);?>"><span><?php echo esc_attr($cat_name);?></span></li>
			<?php } ?>
		</ul>
		<div class="clearfix single-fleet-gallery-wrapper style-two">
			<?php
                        $args = array(
                                    'post_type' => 'tt-gallery',
                                    'posts_per_page' => '-1',
                                );
                                $wp_query = new WP_Query($args);
                                $i = 1;
                                while ($wp_query -> have_posts()) : $wp_query -> the_post();
                                $cates = get_the_terms(get_the_ID(),'type');
                                $cate_name ='';
                                $cate_slug = '';
                                      foreach((array)$cates as $cate){
                            if(count($cates)>0){
                                $cate_name .= $cate->name.' ' ;
                                $cate_slug .= $cate->slug .' ';
                                }
                                }
                ?>
			<div class="single-fleet-gallery img-cap-effect mix <?php echo esc_attr($cate_slug);?>">
				<div class="img-box">
					<img src="<?php echo wp_get_attachment_url( get_post_thumbnail_id());?>" alt=""/>
					<div class="img-caption">
						<div class="box-holder">
							<div class="box-caption">
								<div class="caption-text">
									<h3><?php the_title();?></h3>
									<p><?php tt_logiscargo_excerpt_charlength('35'); ?></p>
								</div>
								<ul>
									<li><a href="<?php echo wp_get_attachment_url( get_post_thumbnail_id());?>" class="fancybox"><i class="fa fa-search-plus"></i></a></li>
								</ul>
							</div>
						</div>
					</div>
				</div>
			</div>
			<?php $i++;
                endwhile; wp_reset_postdata(); ?>


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

<?php }