<?php
/**
 * Template Name: Contact Us Page
 *
 */

get_header();

$globalFields = get_fields('option');
$pageFields = get_fields();

$heading = $pageFields['heading_hero_ct'];
$sub_heading = $pageFields['sub_heading_hero_ct'];
$info = $pageFields['info_hero_ct'];
$embed_form = $pageFields['embed_form_hero_ct'];
?>

<section class="hero-section">
    <div class="container">
        <div class="wrapper">
            <div class="hero-content">
            <?php if( !empty($heading) ): ?>
                <h2 class="heading-section"><?php echo $heading ?></h2>
            <?php endif; ?>
            <?php if( !empty($sub_heading) ): ?>
                <div class="sub-heading-section"><?php echo $sub_heading ?></div>
            <?php endif; ?>
            <?php if( !empty($info) ): ?>
                <div class="info-list">
                    <?php foreach ($info as $key => $item) {
                        $label = $item['label'];
                        $text = $item['text'];
                        ?>
                        <div class="info-item">
                            <?php if( !empty($label) ): ?>
                                <span class="label"><?php echo $label; ?></span>
                            <?php endif; ?>
                            <?php if( !empty($text) ): ?>
                                <span class="text"><?php echo $text; ?></span>
                            <?php endif; ?>
                        </div>
                        <?php

                    } ?>
                </div>
            <?php endif; ?>
            </div>
            <?php if( !empty($embed_form) ): ?>
                <div class="form-container">
                    <?php echo do_shortcode('[gravityform id="'.$embed_form.'" title="false" ajax="true"]');  ?>
                </div>
            <?php endif; ?>
        </div>
    </div>
</section>
<?php

$heading_address = $pageFields['heading_address_ct'];
$locations_address = $pageFields['locations_address_ct'];

?>
<section class="address-section">
    <div class="container">
        <div class="wrapper">
            <?php if( !empty($heading_address) ): ?>
                <h2 class="address-heading"><?php echo $heading_address; ?></h2>
            <?php endif; ?>
            <?php if( !empty($locations_address) ): ?>
                <div class="locations">
                    <?php foreach ($locations_address as $key => $item) {
                        $label = $item['label'];
                        $content = $item['content'];
                        $map_list = $item['map_list'];
                        ?>
                        <div class="location-item">
                            <div class="location-info">
                            <?php if( !empty($label) ): ?>
                                <div class="label"><?php echo $label; ?></div>
                            <?php endif; ?>
                            <?php if( !empty($content) ): ?>
                                <div class="content"><?php echo $content; ?></div>
                            <?php endif; ?>
                            </div>
                            <?php if( !empty($map_list) ): ?>
                                <div class="map-list">
                                    <?php foreach ($map_list as $key => $map) {
                                        $embed_map = $map['embed_map'];
                                        ?>
                                        <?php if( !empty($embed_map) ): ?>
                                            <div class="map"><?php echo $embed_map; ?></div>
                                        <?php endif; ?>
                                        <?php
                                    } ?>
                                </div>
                            <?php endif; ?>
                        </div>
                        <?php
                    } ?>
                </div>
            <?php endif; ?>
        </div>
    </div>
</section>

<?php


get_footer();