<?php
/**
 * Template Name: Home Template
 */
 use Roots\Sage\Utils;
?>
<?php get_template_part('templates/home', 'header'); ?>
    <!--End header-->

    <div class="content">
        <div class="content-head">
		<?php
			  $header_img_url=Utils\get_theme_option('header-image','url');
			 // echo $bg_url;
		  ?>
            <img src="<?php echo $header_img_url; ?>" alt="home" class="img-responsive" />
            <ul class="head-link">
                <!--
                <li><a href="#" data-toggle="modal" data-target="#modal-info" class="link-detail">Information</a></li>
                <li><a href="#" data-toggle="modal" data-target="#modal-buy"  class="link-detail buy-tickets">Buy Tickets</a></li>
                <li><a href="javascript:void(0)"  data-toggle="modal" data-target="#modal-sponsors"  class="link-detail">Sponsors</a></li>
                -->
                <li> <a href="#remodal-info" class="link-detail">Information</a></li>
                <li><a href="#remodal-buy" class="link-detail">Buy Tickets</a></li>
                <li><a href="#remodal-sponsors" class="link-detail">Sponsors</a></li>


            </ul>
        </div>
        <div class="clear"></div>
        <div class="col-md-12 col-sm-12 col-xs-12 content-main">
            <?php 
                $type = 'package';
                $taxonomies = 'package-cat';                
                $args_cate = array(
                    'orderby' => 'id', 
                    'order' => 'ASC',
                    'hide_empty' => true,                    
                );
                $terms = get_terms($taxonomies, $args_cate);                
                if(!empty($terms)) foreach ($terms as $key => $row) {                                   
            ?>
                <div class="package-group">
                    <?php if($row->term_id != 3) { ?> 
                        <h3 class="package-group-title"> <?php echo $row->name ?> </h3>
                    <?php } ?>
                <?php 
                    $args=array(
                        'post_type' => $type,
                        'post_status' => 'publish',
                        'posts_per_page' => -1,
                        'orderby' => 'menu_order',
                        'order' => 'ASC', 
                        'tax_query' => array(
                            array(
                                'taxonomy' => $taxonomies,
                                'field' => 'id',
                                'terms' => $row->term_id,                                
                              )
                        ),
                    );               
                    $count = 0;
                    $my_query = null;
                    $my_query = new WP_Query($args);
                    if( $my_query->have_posts() ) {
                        while ($my_query->have_posts()) : $my_query->the_post(); ?>
                            <?php $count++;?>

                            <div class=" col-md-3 col-sm-4 col-xs-6 package <?php if($count%4==1) echo 'first_package'; if($count%4==0) echo 'last_package'; ?> <?php $package_type = get_post_meta(get_the_ID(), 'package_type'); echo $package_type[0]; ?>">
                                <div class="top-package">
                                    <span class="title"><?php the_title(); ?></span>
                                    <span class="sponsor"><?php $sponsor =  get_post_meta(get_the_ID(), 'package_sub_title'); echo $sponsor[0] ; ?></span>
                                </div>
                                <div class="main-package">
                                    <span class="price"><?php $price =  get_post_meta(get_the_ID(), 'package_price'); echo '$'.$price[0]; ?></span>
                                    <span class="description"><?php the_excerpt(); ?></span>
                                    <!-- <a class="readmore readmore-popup" data-id="<?php echo get_the_ID() ?>" href="#">Read more</a> -->
                                    <a class="readmore readmore-popup" data-id="<?php echo get_the_ID() ?>" href="#">Read more</a>
                                </div>
                            </div>
                        <?php
                        endwhile;
                    }
                    wp_reset_query();  // Restore global post data stomped by the_post().
                ?>
                </div>
                <div class="clear"></div>

            <?php  } ?>

        </div>

        <div class="content-bot">
            <a onclick="window.open('<?php echo Roots\Sage\Utils\get_theme_option('map-link'); ?>', 'newwindow', 'width=1000, height=500'); return false;" href="<?php echo Roots\Sage\Utils\get_theme_option('map-link'); ?>" title="Map">
                <img src="<?php echo Roots\Sage\Utils\get_theme_option('map-image','url'); ?>" />
            </a>
        </div>
    </div>
    <!--End content-->


<?php get_template_part('templates/home', 'footer'); ?>