<?php
$tt_page_info = array(
  'Page_Info' =>   array(
    'Title' =>'ছবি',
    'Description' =>'' ,
    'Keyword' => '',
  ),
  'Social_og' => array(
    'Image' => '',
    'Type' => 'website',
    'URL' => 'photos/',
  ),
);

require_once('./header.php'); // Include Footer
?>
<section class="py-4">

  <div class="container">
    <div class="row g-3 mt-3">
      <div class="col-12">
        <?php
          echo getBlockTitle('', 'ফটো গ্যালারি ',$site_domain.'photos/');
        ?>
      </div>
      <div class="col-lg-6">
        <?php
        $first_gallery = getGallery(1, 1);
        if (!empty($first_gallery)) {
          ?>
          <div id="MahamudFutureITPhoto" class="carousel slide">
            <div class="carousel-inner rounded-2 overflow-hidden">
              <?php
                $gallery_f_items = json_decode($first_gallery[0]['gallery_items'], TRUE);
                $count_gall = 1;
                foreach ($gallery_f_items as $the_f_galllery) {
                  if ($the_f_galllery['storyimage'] !='') {
                    ?>
                    <div class="carousel-item <?php echo ($count_gall == 1) ? 'active' : '' ?> ">
                      <a href="<?php echo $site_domain ?>photos/<?php echo $first_gallery[0]['gallery_url']  ?>/">
                        <div class="featured-image-photo">
                          <img src="<?php echo $advancenews['ArticlePreloader'] ?>"  data-src="<?php echo $the_f_galllery['storyimage'] ?>" class="d-block gallery-img-cover-1" alt="">
                          <i class="bi bi-image"></i>
                        </div>
                      </a>
                    </div>
                    <?php
                    $count_gall++;
                  }
                }
              ?>
            </div>
            <button class="carousel-control-prev" type="button" data-bs-target="#MahamudFutureITPhoto" data-bs-slide="prev">
              <span class="carousel-control-prev-icon" aria-hidden="true"></span>
              <span class="visually-hidden">Previous</span>
            </button>
            <button class="carousel-control-next" type="button" data-bs-target="#MahamudFutureITPhoto" data-bs-slide="next">
              <span class="carousel-control-next-icon" aria-hidden="true"></span>
              <span class="visually-hidden">Next</span>
            </button>
          </div>
          <a href="<?php echo $site_domain ?>photos/<?php echo $first_gallery[0]['gallery_url']  ?>/">
            <h1 class="py-2 news-title  mt-1 "><?php echo $first_gallery[0]['gallery_title']  ?></h1>
          </a>
          <?php
        }else {
          ?>
          <div class="text-center p-2 bg-light rounded-t">
            কোন ছবি নেই !
          </div>
          <?php
        }
        ?>
      </div>
      <div class="col-lg-6">
        <div class="row g-3">
          <?php
          $all_gallery = getGallery(4, 1);
          if (!empty($all_gallery)) {
            foreach ($all_gallery as $the_galllery) {
              $gallery_items = json_decode($the_galllery['gallery_items'], TRUE);
              ?>
              <div class="col-6">
                <a  href="<?php echo $site_domain ?>photos/<?php echo $the_galllery['gallery_url'] ?>/" class="d-block prothom-songbad-post-style">
                    <div class="align-items-center">
                        <div class="position-relative  featured-image-photo overflow-hidden rounded-2">
                          <img class="gallery-img-1 ps-post-line-img " src="<?php echo $advancenews['ArticlePreloader'] ?>" data-src="<?php echo $gallery_items[1]['storyimage']; ?>" alt="<?php echo htmlentities($the_galllery['gallery_title'], ENT_QUOTES, 'utf-8'); ?>">
                          <i class="bi bi-image"></i>
                        </div>
                        <h1 class="py-2 news-title-2 m-0"> <?php echo htmlentities($the_galllery['gallery_title'], ENT_QUOTES, 'utf-8'); ?></h1>
                    </div>
                  </a>
              </div>
              <?php
            }
          }else {
            ?>
            <div class="text-center p-2 bg-light rounded-t">
              কোন ছবি নেই !
            </div>
            <?php
          }

          ?>
        </div>
      </div>
    </div>
    <div class="row   g-3  " id="news-container">
        <?php
        $all_gallery = getGallery(4, 5);
        if (!empty($all_gallery)) {
          foreach ($all_gallery as $the_galllery) {
            $gallery_items = json_decode($the_galllery['gallery_items'], TRUE);
            ?>
            <div class="col-md-6 col-lg-3 col-6">
              <a  href="<?php echo $site_domain ?>photos/<?php echo $the_galllery['gallery_url'] ?>/" class="d-block prothom-songbad-post-style">
                  <div class="align-items-center">
                      <div class="position-relative  featured-image-photo overflow-hidden rounded-2">
                        <img class="gallery-img-1 ps-post-line-img " src="<?php echo $advancenews['ArticlePreloader'] ?>" data-src="<?php echo $gallery_items[1]['storyimage']; ?>" alt="<?php echo htmlentities($the_galllery['gallery_title'], ENT_QUOTES, 'utf-8'); ?>">
                        <i class="bi bi-image"></i>
                      </div>
                      <h1 class="py-2 news-title-2 m-0"> <?php echo htmlentities($the_galllery['gallery_title'], ENT_QUOTES, 'utf-8'); ?></h1>
                  </div>
                </a>
            </div>
            <?php
          }
        }
        ?>
    </div>  
    <div class="row mb-2">
         <div id="loader" class="col-md-12 text-center py-3" style="display: none;"><img src="<?php echo $site_domain ?>assets/image/loading-post.gif" style=" height:40px;"></div>
         <div class="col-12 text-center py-3">
             <button class="btn btn-more-details tt-white tt-text" id="load-more-button"> আরো পড়ুন  </button>
         </div>
    </div>
  </div>
</section>
<script>
let page=3;
var data_type="ttpg";
data_id="";
let isLoading=!1;

function loadMoreNews() {
    if (isLoading) {
        return;
    }

    isLoading = true;
    $('#loader').show();

    $.ajax({
        url: '<?php echo $site_domain ?>ajax_master/load-post/',
        type: 'POST',
        data: {
            page: page ,
            data_id : data_id,
            data_type :data_type,

            },
        success: function(data) {
            const newsContainer = $('#news-container');
            newsContainer.append(data);

            page++;
            isLoading = false;
            $('#loader').hide();
            lazyLoadImages();
        },
        error: function(error) {
            isLoading = false;
            $('#loader').hide();
        }
    });
}
$('#load-more-button').click(function() {
    loadMoreNews();
});

</script>
<?php
require_once('./footer.php'); // Include Footer
?>
