<?php 
/* 
* Block name: Countdown
* Post Type: page, post
*/
?>
<?php if (isset($block['data']['previewImage'])): ?>
    <?php do_action('block_image', __FILE__); ?>
<?php else: ?>
    <?php

    // Block helper
    require \get_template_directory() . '/template-parts/base/block-helper.php';
    if (isset($disable) && $disable) {
        return;
    }

    // Load values and assing defaults
    $endDate = get_field('end_date') ?: false;
?>
    <section class="section countdown-section block <?php echo $className; ?>" 
        <?php if ($bgUrl): ?>
            style="background-image: url('<?php echo $bgUrl; ?>');"
            data-desktop-image="<?php echo $bgUrl; ?>"
        <?php endif; ?>
        <?php if ($mobileBgUrl): ?>
            data-mobile-image="<?php echo $mobileBgUrl; ?>"
        <?php endif; ?>
        <?php if ($sectionId): ?>
            id="<?php echo $sectionId; ?>"
        <?php endif; ?>
    >
        <div class="container">
            <div class="row">
                <div class="col-md-6 d-flex justify-content-center align-items-center order-1">
                    <div class="countdown d-flex" data-date="<?php echo $endDate; ?>">
                        <div class="item days">
                            <div class="value">00</div>
                            <small>Days</small>
                        </div>
                        <div class="item hours">
                            <div class="value">00</div>
                            <small>Hours</small>
                        </div>
                        <div class="item minutes">
                            <div class="value">00</div>
                            <small>Minutes</small>
                        </div>
                        <div class="item seconds">
                            <div class="value">00</div>
                            <small>Seconds</small>
                        </div>
                    </div>
                </div>
                <div class="col-md-6 order-md-0 order-2">
                    <?php if ($title): ?>
                        <h2 class="h2"><?php echo $title; ?></h2>
                    <?php endif; ?>
                    <?php if ($text): ?>
                        <p class="text"><?php echo $text; ?></p>
                    <?php endif; ?>
                    <?php if (is_array($cta) && !empty($cta)): ?>
                        <div class="cta">
                            <a href="<?php echo $cta['url']; ?>" target="<?php echo $cta['target']; ?>" class="button btn btn-primary"><?php echo $cta['title']; ?></a>
                        </div>
                    <?php endif; ?>
                </div>
            </div>
        </div>
    </section>
<?php endif; ?>

