<?php
/**
 * Template for displaying archive accommodation
 **/

inoby_enqueue_parted_script("accommodation", "post_types");
inoby_enqueue_parted_style("accommodation", "post_types");

get_header();

$archive_accommodation_heroimg = rwmb_meta("archive_accommodation_heroimg", ["limit" => 1, "size" => "archive-banner", "object_type" => "setting"], "options");
$archive_accommodation_hero = reset($archive_accommodation_heroimg);
$archive_accommodation_heading = rwmb_meta("archive_accommodation_heading", ["object_type" => "setting"], "options");
$archive_accommodation_text = rwmb_meta("archive_accommodation_text", ["object_type" => "setting"], "options");
?>

<?php
the_post();

$styles = apply_filters("inoby_archive_accomodation_inline_styles", ".banner {background: center/cover no-repeat url('" . ($archive_accommodation_hero["url"] ?? "") . "');}");
?>
<main id="primary" class="site-main">
  <style><?= $styles ?></style>
  <section class="archive-banner">
    <div class="container">
      <div class="row">
        <div class="col-7 col-md-12">
          <div class="banner-content">
            <h1><?= $archive_accommodation_heading ?></h1>
            <p><?= $archive_accommodation_text ?></p>
          </div>
        </div>
      </div>
    </div>
  </section>

  <section class="banner-search">
    <div class="container">
      <div class="row">
        <div class="col-12">
          <div class="search-wrapper">
            <?= do_shortcode('[wpbs-search calendars="all" language="sk" title="no"]') ?>
          </div>
        </div>
      </div>
    </div>
  </section>

  <section class="archive-content">
    <div class="container">
      <div class="masonry-wrap">
        <?php
        do_action("inoby_archive_accomodation_cards_before");
        $args = [
          "post_type" => "accommodation",
          "posts_per_page" => -1,
          "orderby" => "date",
          "order" => "asc",
        ];
        $query = new WP_Query($args);
        if ($query->have_posts()) {
          while ($query->have_posts()) {
            $query->the_post();
            get_template_part("post-types/accommodation/parts/card");
          }
          wp_reset_postdata();
        }
        do_action("inoby_archive_accomodation_cards_after");
        ?>
      </div>
    </div>
  </section>

  <?php do_action("inoby_after_archive_accomodation"); ?>

</main>
<?php get_footer();
