<?php
/**
 * Template Name: Contact Us Template
 *
 * @package WordPress
 */
__('Contact Us Template', TEXT_DOMAIN);

$showMap = !empty(get_option(TEXT_DOMAIN . '_contact_show_map')) && get_option(TEXT_DOMAIN . '_contact_show_map') === 'true';
$mainImage = get_option(TEXT_DOMAIN . '_contact_image');
$mapCode = get_option(TEXT_DOMAIN . '_contact_map');
$subtitle = get_option(TEXT_DOMAIN . '_contact_subtitle');


$addressTitle = get_option(TEXT_DOMAIN . '_contact_address_title');
$address = get_option(TEXT_DOMAIN . '_contact_address');
$phoneTitle = get_option(TEXT_DOMAIN . '_contact_phone_title');
$phone = get_option(TEXT_DOMAIN . '_contact_phone');
$emailTitle = get_option(TEXT_DOMAIN . '_contact_email_title');
$email = get_option(TEXT_DOMAIN . '_contact_email');
$hoursTitle = get_option(TEXT_DOMAIN . '_contact_hours_title');
$hours = get_option(TEXT_DOMAIN . '_contact_hours');
$formTitle = get_option(TEXT_DOMAIN . '_contact_form_title');
?>
<?php get_header(); ?>
<?php if (have_posts()): ?><?php while (have_posts()): the_post(); ?>

    <main>
        <div class="mt-4 mb-5">
            <div class="custom-container">
                <div class="row mt-4 mt-lg-5">

                    <!-- contact info -->
                    <div class="col-lg-6">
                        <div class="single-box single-box-contact-image">
                            <div class="single-box-contact-content text-center">

                                <!-- image -->
                                <?php if (!empty($mainImage)): ?>
                                    <img class="main" src="<?php echo $mainImage ?>" alt="<?php the_title(); ?>">
                                <?php else: ?>
                                    <span><?php _e('Image not selected', TEXT_DOMAIN); ?></span>
                                <?php endif; ?>


                                <!-- icon boxes -->
                                <div class="row">
                                    <?php if (!empty($phone)): ?>
                                        <div class="col-sm-6 mb-4">
                                            <div class="contact-icon">
                                                <i class="iconly-Call"></i>
                                                <div class="d-flex flex-column align-items-start">
                                                    <span class="key"><?php echo $phoneTitle; ?></span>
                                                    <a href="tel:<?php echo $phone; ?>"><span class="value"><?php echo $phone; ?></span></a>
                                                </div>
                                            </div>
                                        </div>
                                    <?php endif; ?>

                                    <?php if (!empty($email)): ?>
                                        <div class="col-sm-6 mb-4">
                                            <div class="contact-icon">
                                                <i class="iconly-Message"></i>
                                                <div class="d-flex flex-column align-items-start">
                                                    <span class="key"><?php echo $emailTitle; ?></span>
                                                    <a href="mailto:<?php echo $email; ?>"><span class="value"><?php echo $email; ?></span></a>
                                                </div>
                                            </div>
                                        </div>
                                    <?php endif; ?>

                                    <?php if (!empty($address)): ?>
                                        <div class="col-sm-6 mb-4">
                                            <div class="contact-icon">
                                                <i class="iconly-Location"></i>
                                                <div class="d-flex flex-column align-items-start">
                                                    <span class="key"><?php echo $addressTitle; ?></span>
                                                    <span class="value"><?php echo $address; ?></span>
                                                </div>
                                            </div>
                                        </div>
                                    <?php endif; ?>


                                    <?php if (!empty($hours)): ?>
                                        <div class="col-sm-6 mb-4">
                                            <div class="contact-icon">
                                                <i class="iconly-Time-Square"></i>
                                                <div class="d-flex flex-column align-items-start">
                                                    <span class="key"><?php echo $hoursTitle; ?></span>
                                                    <span class="value"><?php echo $hours; ?></span>
                                                </div>
                                            </div>
                                        </div>
                                    <?php endif; ?>
                                </div>

                                <!-- map -->
                                <?php
                                if ($showMap):?>
                                    <div class="map-container mt-3">
                                        <?php echo $mapCode ?>
                                    </div>
                                <?php endif; ?>
                            </div>
                        </div>
                    </div>

                    <!-- form section -->
                    <div class="col-lg-6 order-first order-lg-last mb-4 mb-lg-5">

                        <!-- page title -->
                        <div class="contact-page-title">
                            <div class="icon">
                                <span class="iconlyBulk-Calling"><span class="path1"></span><span
                                            class="path2"></span><span class="path3"></span></span>
                            </div>
                            <div class="d-flex flex-column">
                                <h1 class="title"><?php the_title(); ?></h1>
                                <p class="subtitle"><?php echo $subtitle; ?></p>
                            </div>
                        </div>

                        <!-- form -->
                        <div class="single-box p-lg-4">
                            <div class="form-title"><?php echo $formTitle; ?></div>
                            <?php the_content(); ?>
                        </div>
                    </div>
                </div>
            </div>
        </div>

    </main>

<?php endwhile; ?>
<?php endif; ?>
<?php get_footer(); ?>