<?php
 
/**
 * Liting the team/trainer details 
 * @param : int $pageId default is null
 * @param : boolean $isCustomizer default is false, if set to true will get the data stored with customizer
 * @param : int $i default is null, it will used as a iteration for data with customizer, this will be used only if the $isCustomizer is set to true.
 * @return: Text $text
 */
function teamShortCode($pageId = null, $isCustomizer = false, $i = null) {

    ob_start();

    $args = array('post_type' => 'lz_fitness_teams');
    if (!empty($pageId)) {
        $args['page_id'] = absint($pageId); 
    }
    $colCls = '';
    // if($isCustomizer == true){
    $cols = get_theme_mod('lz_fitness_team_npp_count', 1);
    $cols++;
    switch($cols){
                        case 1:
                        $colCls = 'col-md-12 col-sm-12 col-xs-12';
                        break;
                        case 2:
                        $colCls = 'col-md-6 col-sm-12 col-xs-12';
                        break;
                        case 3:
                        case 5:
                        case 6:
                        $colCls = 'col-md-4 col-sm-12 col-xs-12';
                        break;
                        case 4:
                        $colCls = 'col-md-3 col-sm-12 col-xs-12';
                        break;
                        default: 
                        $colCls = 'col-md-4 col-sm-6 col-xs-12';
                        break;
    }
    
    // }
    $text = '';
    $query = new WP_Query($args);
    if ($query->have_posts()):
        $postN = 0;

        while ($query->have_posts()) : $query->the_post();
            $lz_fitness_image = wp_get_attachment_image_src(get_post_thumbnail_id(), 'total-team-thumb');
            if ($isCustomizer === true) {
                $lz_fitness_team_designation = get_theme_mod('lz_fitness_team_designation' . $i);
                $lz_fitness_team_facebook = get_theme_mod('lz_fitness_team_facebook' . $i);
                $lz_fitness_team_twitter = get_theme_mod('lz_fitness_team_twitter' . $i);
                $lz_fitness_team_google_plus = get_theme_mod('lz_fitness_team_google_plus' . $i);
                $lz_fitness_team_instagram = get_theme_mod('lz_fitness_team_instagram' . $i);
                $lz_fitness_team_pinterest = get_theme_mod('lz_fitness_team_pinterest' . $i);  
            } else {
                $lz_fitness_team_facebook = '';
                $lz_fitness_team_twitter = '';
                $lz_fitness_team_google_plus = '';
                $lz_fitness_team_instagram = '';
                $lz_fitness_team_pinterest = '';
            }

            $post = get_post();
            //Social media urls
            $teamFacebook = get_post_meta($post->ID, 'teamFacebook', false);
            $lz_fitness_team_facebook = !empty($teamFacebook[0]) ? $teamFacebook[0] : '';
            $teamTwitter = get_post_meta($post->ID, 'teamTwitter', false);
            $lz_fitness_team_twitter = !empty($teamTwitter[0]) ? $teamTwitter[0] : '';
            $teamGPlus = get_post_meta($post->ID, 'teamGPlus', false);
            $lz_fitness_team_google_plus = !empty($teamGPlus[0]) ? $teamGPlus[0] : '';
            $teamInstagram = get_post_meta($post->ID, 'teamInstagram', false);
            $lz_fitness_team_instagram = !empty($teamInstagram[0]) ? $teamInstagram[0] : '';
            $teamPinterest = get_post_meta($post->ID, 'teamPinterest', false);
            $lz_fitness_team_pinterest = !empty($teamPinterest[0]) ? $teamPinterest[0] : '';
            //designation
            $designation = get_post_meta($post->ID, 'designation', false);
            $lz_fitness_team_designation = !empty($designation[0]) ? $designation[0] : '';
?>
                <?php
            ++$postN;
            ?>
            <div class="<?php echo $colCls; ?>">
                <div class="ht-team-member text-center">
                    <div class="ht-title-wrap">
                        <div class="ht-team-member-image">
                            <?php
                            if (has_post_thumbnail()) {
                                $image_url = $lz_fitness_image[0];
                            } else {
                                $image_url = get_template_directory_uri() . '/images/team-thumb.png';
                            }
                            ?>                  
                            <img src="<?php echo esc_url($image_url); ?>" alt="<?php the_title(); ?>" />
                        </div>

                        <div class="team-member-designation"><?php echo esc_html($lz_fitness_team_designation); ?></div>   
                        <h6 class="member-name"><?php the_title(); ?></h6>                      
                        <!--   <div class class="ht-team-member-excerpt"> -->
                            <div class="ht-team-member-excerpt-wrap">
                                <div class="ht-team-member-span">
                                    <!-- <h6><?php //the_title(); ?></h6> -->
                                    
                                    <!-- <div class="ht-team-detail"><?php _e('Detail', 'total') ?></div> -->
                                </div>
                            </div>
                            <?php if ($lz_fitness_team_facebook || $lz_fitness_team_twitter || $lz_fitness_team_google_plus || $lz_fitness_team_instagram || $lz_fitness_team_pinterest ) { ?>
                                <div class="ht-team-social-id">
                                    <?php if ($lz_fitness_team_facebook) { ?>
                                        <a target="_blank" href="<?php echo esc_url($lz_fitness_team_facebook) ?>"><i class="fa fa-facebook"></i></a>
                                    <?php } ?>
                                    <?php if ($lz_fitness_team_twitter) { ?>
                                        <a target="_blank" href="<?php echo esc_url($lz_fitness_team_twitter) ?>"><i class="fa fa-twitter"></i></a>
                                    <?php } ?>
                                    <?php if ($lz_fitness_team_google_plus) { ?>
                                        <a target="_blank" href="<?php echo esc_url($lz_fitness_team_google_plus) ?>"><i class="fa fa-google-plus"></i></a>
                                    <?php } ?>
                                    <?php if ($lz_fitness_team_instagram) { ?>
                                        <a target="_blank" href="<?php echo esc_url($lz_fitness_team_instagram) ?>"><i class="fa fa-instagram"></i></a>
                                    <?php } ?>
                                    <?php if ($lz_fitness_team_pinterest) { ?>
                                        <a target="_blank" href="<?php echo esc_url($lz_fitness_team_pinterest) ?>"><i class="fa fa-pinterest"></i></a>
                                    <?php } ?>
                                </div>                
                            <?php } ?>
                            <!--  </div> -->
                        </div>                 
                        <div class="clearfix"></div>           
                    </div>
                </div>
                <?php
            endwhile;
            $text = ob_get_contents();
            ob_clean();
        endif;
        wp_reset_postdata();
        return $text;
    }

    /**
     * Use for the show the testimonials at home page and in testimonial page with shortcode
     * @param int $pageId default is null the id of a post
     * @param boolean $isCustomizer default is false if set to true it mean the output is set for the home page
     * @param int $i default null
     * @param boolean $showStaticVals default is false
     * @return void
     * @author Parag Chaure <support@luzuk.com>
     * */
    function testimonialShortCode($pageId = null, $isCustomizer = false, $i = 0, $showStaticVals = false, $totalItems=0) {
        global $query;
        $args = array('post_type' => 'lz_fitness_testimoni');
        if (!empty($pageId)) {
            $args['page_id'] = absint($pageId);
        } else {
            $args['paged'] = max(1, get_query_var('paged'));
        }
        $args['posts_per_page'] = (!empty($args['posts_per_page'])) ? $args['posts_per_page'] : -1;
        $i = !empty($i) && is_numeric($i) ? $i : 0;
        $text = '';
        $query = new WP_Query($args);
    // print_r($query);
        if ($query->have_posts()):
            $cssCls = ($isCustomizer == false) ? 'row' : 'col-sm-10 col-sm-offset-1';

            ob_start();
            while ($query->have_posts()) : $query->the_post();
                $post = get_post();
                $lz_fitness_image = wp_get_attachment_image_src(get_post_thumbnail_id(), 'total-team-thumb');
           // echo"(($i == 0) || ($i%2)==0)".__LINE__;
                if(($i == 0) || ($i%1)==0){
                    ?>
                    <div class="item <?php if ($i == 0) { ?>active<?php } ?>">
                        <div class="row">
                            <?php
                        }
                        ?>

                        <div class="<?php echo $cssCls; ?>">
                            <?php if ($isCustomizer == false) { ?>
                                <div class="row page-testimonial-box">
                                    <div class="team-thumb ">
                                        <img src="<?php echo (!empty($lz_fitness_image[0])) ? $lz_fitness_image[0] : get_template_directory_uri() . '/images/team-thumb.png' ?>" class="img-responsive" alt="<?php the_title(); ?>" />
                                    </div>
                                    <div class="col-md-12 testimonial-content">
                                    <?php } ?>
                                                  
                        <p><?php
                        if (has_excerpt()) {
                            echo get_the_excerpt();
                        } else {
                            echo get_the_content();
                        }
                        ?>
                    </p>

                    <?php if ($isCustomizer == false) { ?>
                    </div>
                    <div class="clearfix"></div>


                      <script>
                  jQuery.noConflict();
                  $(function(){
                    function testimonialcontentHeight(){
                      var ht = 0;
                      $('#testimonials-section .testimonial-content').each(function(i){
                        var tHt = $(this).height();
                        if(ht<tHt){
                          ht=tHt;
                        }
                      });
                      $('#testimonials-section .testimonial-content').height(ht+'px');
                    }
                    testimonialcontentHeight();
                  });
                  $( window ).resize(function(){
                    testimonialcontentHeight();
                  });
                </script>


                </div>
            <?php } ?>
        </div>
        <?php
            //echo"\n($i+1)%2 == 0 || $totalItems == ($i+1)";
        if(($i+1)%1 == 0 || $totalItems == ($i+1)){ ?>
        </div>
    </div>
    <?php
}
?>

<?php
endwhile;
$text = ob_get_contents();
ob_clean();
ob_end_flush();
endif;
wp_reset_postdata();
    // echo $text;
return $text;
}

    /**
     * Use for the show the gallery at home page and in the page where user add this the shortcode
     * @return void
     * @author Parag Chaure <support@luzuk.com>
     * */


    function galleryShortCode($pageId = null, $isCustomizer = false, $i = null) {

        ob_start();

        $args = array('post_type' => 'lz_fitness_gallery');
        if (!empty($pageId)) {
            $args['page_id'] = absint($pageId);
        }
        $args['posts_per_page'] = -1;
        $colCls = '';
    // if($isCustomizer == true){
        $cols = get_theme_mod('lz_fitness_gallery_npp_count', 7);  
        ++$cols;
        switch ($cols) {
            case 1:
            $colCls = 'col-md-12 col-sm-12 col-xs-12'; 
            break;
            case 2:
            $colCls = 'col-md-6 col-sm-6 col-xs-12';
            break;
            case 3:
            case 5:
            case 6:
            case 9:
            $colCls = 'col-md-4 col-sm-6 col-xs-12';
            break;
            case 4:
            case 7:
            case 8:
            case 10:
            case 11:
            case 12:
            $colCls = 'col-md-3 col-sm-6 col-xs-12';
            break;
            default:
            $colCls = 'col-md-3 col-sm-6 col-xs-12';
            break;
        }
    // }
        $text = '';
        $query = new WP_Query($args);
        if ($query->have_posts()):
            $postN = 0;

            while ($query->have_posts()) : $query->the_post();
                $lz_fitness_image = wp_get_attachment_image_src(get_post_thumbnail_id(), 'medium_large');
                if ($isCustomizer === true) {
                // $lz_fitness_gallery_designation = get_theme_mod('lz_fitness_gallery_designation' . $i);
                // $lz_fitness_gallery_facebook = get_theme_mod('lz_fitness_gallery_facebook' . $i);
                // $lz_fitness_gallery_twitter = get_theme_mod('lz_fitness_gallery_twitter' . $i);
                // $lz_fitness_gallery_google_plus = get_theme_mod('lz_fitness_gallery_google_plus' . $i);
                // $lz_fitness_gallery_pintrest = get_theme_mod('lz_fitness_gallery_pintrest' . $i);
                } else {
                // $lz_fitness_gallery_facebook = '';
                // $lz_fitness_gallery_twitter = '';
                // $lz_fitness_gallery_google_plus = '';
                // $lz_fitness_gallery_pintrest = '';
                }

                $post = get_post();
            //Social media urls
            // $galleryFacebook = get_post_meta($post->ID, 'galleryFacebook', false);
            // $lz_fitness_gallery_facebook = !empty($teamFacebook[0]) ? $galleryFacebook[0] : '';
            // $galleryTwitter = get_post_meta($post->ID, 'galleryTwitter', false);
            // $lz_fitness_gallery_twitter = !empty($teamTwitter[0]) ? $galleryTwitter[0] : '';
            // $galleryGPlus = get_post_meta($post->ID, 'galleryGPlus', false);
            // $lz_fitness_gallery_google_plus = !empty($teamGPlus[0]) ? $galleryGPlus[0] : '';
            // $galleryPintrest = get_post_meta($post->ID, 'galleryPintrest', false);
            // $lz_fitness_gallery_pintrest = !empty($galleryPintrest[0]) ? $galleryPintrest[0] : '';
            // //designation
            // $designation = get_post_meta($post->ID, 'designation', false);
            // $lz_fitness_gallery_designation = !empty($designation[0]) ? $designation[0] : '';

                if (($postN % 4) == 0 && $isCustomizer == false) {
                    ?>
                    <div class="clearfix paddingBot20"></div>
                </div>
                <div class="row">
                    <?php
                }
                ++$postN;
                ?>
                
                <div class="<?php echo $colCls; ?> lz-gallery-images padding7">
                    <div class="ht-gallery-member">
                        <div class="ht-gallery-member-image">
                            <?php
                            if (has_post_thumbnail()) {
                                $image_url = $lz_fitness_image[0];
                            } else {
                                $image_url = get_template_directory_uri() . '/images/about1.jpg';
                            }
                            ?>
                            <a class="group1" href="<?php echo esc_url($image_url); ?>" title="<?php the_title(); ?>"> <img class="secondry-bg img-responsive" src="<?php echo esc_url($image_url); ?>" alt="<?php the_title(); ?>" /> </a>
                        </div>

                        <!--  <h6 class="member-name"><?php //the_title(); ?></h6> -->

                        <!-- <div class="ht-gallery-member-excerpt-wrap"> -->
                           <!--   <div class="ht-gallery-member-span"> -->
                            <?php //if (!empty($lz_fitness_team_designation)) {// ?>
                                <!-- <div class="ht-team-designation"><?php //echo esc_html($lz_fitness_team_designation); ?></div> -->
                                <!--  <div class="ht-gallery-content">-->
                                    <?php                                   
                                           // if(has_excerpt()){
                                               // echo get_the_excerpt();
                                            // }else{
                                               // echo lz_fitness_excerpt( get_the_content() , 100 );
                                            // } 
                                    ?>
                                    <!--  </div>  -->
                                    <!-- <div class="ht-team-detail"><?php//_e('Detail', 'total') ?></div> -->
                                    <!-- </div> --> 
                                    <!--   </div> -->

                                <!-- <?php// if ($lz_fitness_gallery_facebook || $lz_fitness_gallery_twitter || $lz_fitness_gallery_google_plus) { ?>
                                <div class="ht-team-social-id">
                                    <?php // if ($lz_fitness_gallery_facebook) { ?>
                                        <a target="_blank" href="<?php // echo esc_url($lz_fitness_gallery_facebook) ?>"><i class="fa fa-facebook"></i></a>
                                    <?php //} ?>
                                    <?php //if ($lz_fitness_gallery_twitter) { ?>
                                        <a target="_blank" href="<?php // echo esc_url($lz_fitness_gallery_twitter) ?>"><i class="fa fa-twitter"></i></a>
                                    <?php // } ?>
                                    <?php //if ($lz_fitness_gallery_google_plus) { ?>
                                        <a target="_blank" href="<?php // echo esc_url($lz_fitness_gallery_google_plus) ?>"><i class="fa fa-google-plus"></i></a>
                                    <?php //} ?>
                                    <?php // if ($lz_fitness_gallery_pintrest) { ?>
                                        <a target="_blank" href="<?php // echo esc_url($lz_fitness_gallery_pintrest) ?>"><i class="fa fa-pinterest-p"></i></a>
                                    <?php // } ?>
                                </div>                          
                                <?php// } ?> -->

                            </div>
                        </div>
                        <?php
                    endwhile;
                    $text = ob_get_contents();
                    ob_clean();
                endif;
                wp_reset_postdata();
                return $text;
            }



    /**
     * Use for the show the testimonials at home page and in testimonial page with shortcode
     * @param int $pageId default is null the id of a post
     * @param boolean $isCustomizer default is false if set to true it mean the output is set for the home page
     * @param int $i default null
     * @param boolean $showStaticVals default is false
     * @return void
     * @author Parag Chaure <support@luzuk.com>
     * */
    function pricingShortcode() {
        ob_start();
        $cols = get_theme_mod('lz_fitness_pricing_npp_count', 2);
        $cols++;
        switch ($cols) {
            case 1:
            $colCls = 'col-md-12 col-sm-12';
            break;
            case 2:
            $colCls = 'col-md-6 col-sm-6';
            break;
            case 3:
            $colCls = 'col-md-4 col-sm-4';
            break;
            default:
            $colCls = 'col-md-3 col-sm-6';
            break;
        }
        echo '<div id="pricing-page">';
        $showStatic = true;
        for ($i = 1; $i <= $cols; $i++) {
            if( get_theme_mod('pages_CoursesFColor'.$i,true) ) {
                $pages_CoursesFColor = 'background-color:'.esc_attr(get_theme_mod('pages_CoursesFColor'.$i)).';';
            }

            if( get_theme_mod('pages_CoursesBColor'.$i,true) ) {
                $pages_CoursesBColor = 'border-color:'.esc_attr(get_theme_mod('pages_CoursesBColor'.$i)).';';
            }

            $PlanPageId = get_theme_mod('lz_fitness_pricing_plan_page_' . $i);
            $planheadline= get_theme_mod('lz_fitness_pricing_planheadline_' . $i, 'LIMITED TIME OFFER');

            $planTitle  = get_theme_mod('lz_fitness_pricing_plan_name_' . $i, 'YOUR FIRST');
            $planContents= get_theme_mod('lz_fitness_pricing_plancontent_' . $i, '5 CLASSES');

            $planPrice  = get_theme_mod('lz_fitness_pricing_plan_price_' . $i,'$29');

            
            //$PricingplanPrice  = get_theme_mod('lz_fitness_pricingplan_price_' . $i,'23');
            $planContent= get_theme_mod('lz_fitness_pricing_plan_content_' . $i, 'Must use within 2 weeks');

            $link = get_theme_mod('pricing_plan_url'.$i);
            $url = get_theme_mod('pricing_plan_url_'.$i, '#');

            if ($PlanPageId || $planheadline || $planTitle || $planPrice || $planContents || $planContent || $url) {
                $showStatic = false;
                ?>
                <div class="<?php echo $colCls; ?>">
                    <div class="ht-plan-block text-center" style="<?php echo esc_attr($pages_CoursesBColor); ?>">
                        <div class="ht-princing-text"  style="<?php echo esc_attr($pages_CoursesFColor); ?>">
                            <?php echo nl2br($planheadline); ?>
                        </div>
                        <div class="ht-princing-icon"><?php echo ($planTitle); ?></div>
                        <div class="ht-princing-icon-span"><?php echo nl2br($planContents); ?></div>
                        <div class="plan-amount"><?php echo esc_html($planPrice); ?></div>
                        <div class="ht-princing-link">
                            <?php
                                $pricebtntxt = get_theme_mod('pricebtntxt', 'BUY NOW'); 
                            ?>
                           <a href="<?php echo esc_url(!empty($url)?$url:'#');?>"><?php echo ($pricebtntxt);  ?></a>
                       </div>
                       <div class="ht-princing-excerpt">
                        <?php echo nl2br($planContent); ?>
                    </div>
                </div>
            </div>
            <?php
        }
    }
    if ($showStatic === true) {
        for ($i = 1; $i <= $cols; $i++) {
            $link = get_theme_mod('pricing_plan_url'.$i);
            $url = get_theme_mod('pricing_plan_url_'.$i, '#');

            ?>
            <div class="<?php echo $colCls; ?>">
                <div class="ht-plan-block text-center">
                    <div class="ht-princing-icon">YOUR FIRST <span>5 classes</span>span>JUST</div>
                    <div class="plan-amount">$29</div>
                    <div class="pricing-plan-amount">$23</div>
                    <div class="pricingplan-amount"> STUDENTS - </div>
                    <div class="ht-princing-link">
                        <a href="<?php echo esc_url(!empty($url)?$url:'#');?>"><?php _e('Join Now', 'lz-fitness-premium'); ?></a>
                    </div>
                    <div class="ht-princing-excerpt">
                        <?php echo nl2br("Must use within 2 weeks"); ?>
                    </div>
                    
                </div>
            </div>
            <?php
        }
        echo '<div class="clearfix"></div>';
        echo '</div>';
    }

    $pricingHtml = ob_get_contents();
        // echo $pricingHtml;
    ob_flush();
    ob_clean();
}

