<?php 
/**
 * 
 * @package luzuk
 */
if(get_theme_mod('testimonials_area_disable') != 'on' ){ ?> 
 
<div id="testimonials"class="testimonials-area " >
    <?php
        // width 
        $c_width = get_theme_mod('testi_c_width', 'container-fluid');

          if ($c_width === 'container') {
              $c_alignment = 'container';
          } elseif ($c_width === 'container-fluid') {
              $c_alignment = 'container-fluid';
          } else {
              $text_alignment = 'container'; // Default to 'container' if the setting is invalid
          }

        //sub Heading Style
        $subheading_case = get_theme_mod('ts_subtitle_case', 'uppercase');

        if ($subheading_case === 'uppercase') {
            $text_case = 'uppercase';
          } elseif ($subheading_case === 'lowercase') {
              $text_case = 'lowercase';
          } elseif ($subheading_case === 'capitalize') {
              $text_case = 'capitalize';
          } else {
              $text_case = 'capitalize'; // Default to 'left' if the setting is invalid
          }

          // Heading Style
          $heading_case = get_theme_mod('testi_maintitle_case', 'capitalize');

          if ($heading_case === 'uppercase') {
            $text_case = 'uppercase';
          } elseif ($heading_case === 'lowercase') {
              $text_case = 'lowercase';
          } elseif ($heading_case === 'capitalize') {
              $text_case = 'capitalize';
          } else {
              $text_case = 'capitalize'; // Default to 'left' if the setting is invalid
          }
           
          // Alignment
      // $heading_alignment = get_theme_mod('testi_maintitle_align', 'center');

      //   if ($heading_alignment === 'left') {
      //     $text_alignment = 'left';
      //   } elseif ($heading_alignment === 'center') {
      //       $text_alignment = 'center';
      //   } elseif ($heading_alignment === 'right') {
      //       $text_alignment = 'right';
      //   } else {
      //       $text_alignment = 'right'; // Default to 'left' if the setting is invalid
      //   }
      ?>

    <?php             
      $ts_subtitle = get_theme_mod('ts_subtitle', 'Thousands trust fairstone');
      $testi_title = get_theme_mod('testi_title', "Don’t take our word for it, see what our clients say");
      $testi_txt = get_theme_mod('testi_txt', "We’re honored by the feedback, and it fuels our commitment to delivering exceptional financial service. Read the reviews to hear firsthand how Fairstone is making a positive impact on people’s lives. your trust is our greatest achievement.");
      
    ?>
    <div class="<?php echo esc_attr($c_width); ?> cf-ps">
        <div class="section-title">
            <div class="titlebx">
               <h2 style="text-transform: <?php echo esc_attr($subheading_case); ?>;"><?php echo ($ts_subtitle); ?></h2>
              <h3 style="text-transform: <?php echo esc_attr($heading_case); ?>;"><?php echo ($testi_title); ?></h3>
              <p > <?php echo ($testi_txt); ?> </p>
            </div>
        </div>
  
        <div class="row mr-0">
              <div class="tesbox">
                <div class="testimonials-single-area"> 
                    <div class="owl-carousel "> 
                      <?php  
                        $showStatic = true;
                        $cols = get_theme_mod('test_npp_count', 5);
                        $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 7:
                          case 8:
                          case 9:
                          case 10:
                          case 11:
                          case 12:
                            $colCls = 'col-md-4 col-sm-6 col-xs-12';
                            break;
                          default:
                            $colCls = 'col-md-3 col-sm-6 col-xs-12';
                            break;
                        }
                        $icons = array(1=>'heart', 2=>'star', 3=>'flash', 4=>'bell',5=>'heart', 6=>'star', 7=>'flash', 8=>'bell'); 

                        for( $i = 1; $i <= $cols; $i++ ){
                          $testimonials_page_id = get_theme_mod('testimonials_page'.$i); 
                          $testimonials_page_icon = get_theme_mod('testimonials_page_icon'.$i);
                          if($testimonials_page_id){
                            $showStatic = false;
                            echo testimonialShortCode($testimonials_page_id, $isCustomizer=true, $i);
                        }
                      }

                        // adding the static content
                        if($showStatic === true){
                          for( $i = 1; $i <= $cols; $i++ ){ ?>
                        <div class="item items innertest-item ">        
                            <div class="ts-area-single ">
                                <div class="ratingbx">
                                    <?php $rating = get_theme_mod('default_star_rating', '5'); ?>
                                    <div class="rating-container">
                                        <div class="rating-display">
                                            <!-- </?php for ($i = 1; $i <= 5; $i++) : ?>  -->
                                                <i class="fa fa-star<?php echo ($i <= $rating) ? '' : '-o'; ?>"></i>
                                            <!-- </?php endfor; ?>  -->
                                        </div>
                                    </div>
                                    <div class="clearfix"></div>
                                </div>
                                <div class="ts-area-c">   
                                    <p>A thorough report was done on our financial situation of what insurance covers etc existing. Better deals were found. These were processed on our behalf, which took a lot of stress away. Updates were given as required and outstanding responses chased after.</p>
                                </div>  
                                <div class="ts-area-content">
                                    <!-- <div class="row mr-0"> -->
                                        <!-- <div class="ts-area-thumb">
                                            <div class="testiimginn">
                                                <img class="img-responsive" src="</?php echo get_template_directory_uri(); ?>/images/b2.jpg" alt="">
                                            </div>
                                        </div> -->
                                        <div class="ts-area-bx">
                                            <h3 class="ts-area-title">Axel Nova</h3>
                                            <div class="text-designation">CEO, of the company</div>
                                            <div class="clearfix"></div>
                                        </div>
                                    <div class="clearfix"></div>
                                    <!-- </div> -->
                                </div>
                            </div>
                            <div class="clearfix"></div>
                        </div>
                          <?php }

                        }?>
                    </div>   
                </div>
                <div class="clearfix"></div>
            </div>
        </div>
        <div class="clearfix"></div>
    </div>
</div>
<script>
  document.addEventListener("DOMContentLoaded", function () {
    // Example rating value: change this to 3, 4, 4.5 etc.
    const customRating = 4;  // You can make this dynamic

    // Use `querySelector` to find input with matching value
    const starInput = document.querySelector(
      `input[name="rating"][value="${customRating}"]`
    );
    if (starInput) {
      starInput.checked = true;
    }
  });
</script>
<script>
  const customRating = <?php echo get_theme_mod('custom_rating', 3); ?>;
</script>
<script>
    $(document).ready(function() {
      $('.testimonials-area .owl-carousel').owlCarousel({
        refreshClass: 'owl-refresh',
        autoplayTimeout:5000,
        loop: true,
        margin: 30,
        autoHeight: false,
        autoWidth: false,
        autoplay: true,
        // animateIn: 'zoomIn',
        // animateOut: 'zoomOut',
        navText: [
                    '<i class="fa fa-long-arrow-left"></i>',
                    '<i class="fa fa-long-arrow-right"></i>'
                ],
        responsiveClass: true,
        responsive: {
          0: {
            items: 1,
            nav: true,
            margin: 10
          },
          600: {
            items:1,
            nav: true,
            margin: 10
          },

          760: {
            items:2,
            nav: true,
            margin: 10
          },

          1199: {
            items:2,
            nav: true,
            loop: true,
            margin: 30
          },

          1299: {
            items:3,
            nav: true,
            loop: true,
            margin: 30
          }
        }
      })
    })
</script> 
<?php } 

