<?php
$wrapper_width = get_sub_field('wrapper_width');
$title = get_sub_field('title');
?>

<div class="layout-lingotti" id="flex-section-<?php echo get_row_index();?>">
  <?php if($wrapper_width != 'full') echo "<div class='container {$wrapper_width}'>"; ?>
    <?php if($title) echo "<h3 class='layout-title'><span>{$title}</span></h3>"; ?>
    <div class="row row-padding center-row">
      <?php
      $lingotti_args = array(
        'post_type'=>'lingotto',
        'posts_per_page'  => -1
      );
      $lingotti_posts = new WP_Query($lingotti_args);
      if ($lingotti_posts->have_posts()) :
        while($lingotti_posts->have_posts()) : $lingotti_posts->the_post();
          echo '<div class="col-1-1 col-sm-1-4 block-content" data-mh>';
            get_template_part('inc/teaser/_teaser', 'lingotto');
          echo '</div>';
        endwhile;
      endif;
      wp_reset_query();?>

    </div><!--row-->
  <?php if($wrapper_width != 'full') echo "</div>"; ?>
</div>

<?php if ($lingotti_posts->have_posts()) :
  while($lingotti_posts->have_posts()) : $lingotti_posts->the_post(); ?>
  <!-- POPUP BOOKING -->
  <div class="book-gold-popup" id="gold-popup-<?= get_the_ID()?>">
    <div class="inner-wrapper">
      <div class="close-overlay"><i class="icon-cross"></i></div>
      <?php
        $form = get_field('booking_form','option');
        gravity_form($form['id'], true, true, true, '', true, 1);
      ?>
    </div>
  </div>
  <?php endwhile;
endif;
wp_reset_query();?>
