<?php

/* =========================================================
   COMPLETE BLISS - PUBLIC FOOTER
========================================================= */

require_once
    __DIR__ .
    '/../../config/database.php';


$footerSettings = [

    'company_name' => 'Complete Bliss Solutions',
    'support_phone' => '',
    'support_email' => '',
    'support_whatsapp' => ''

];


try {

    $footerStatement =
        $pdo->query(
            "
            SELECT
                company_name,
                support_phone,
                support_email,
                support_whatsapp
            FROM settings
            LIMIT 1
            "
        );


    $footerRow =
        $footerStatement->fetch(
            PDO::FETCH_ASSOC
        );


    if ($footerRow) {

        $footerSettings =
            array_merge(
                $footerSettings,
                $footerRow
            );

    }

} catch (PDOException $e) {

    /* Keep footer working if DB settings fail */

}


$footerCompanyName =
    trim(
        $footerSettings['company_name']
        ?: 'Complete Bliss Solutions'
    );


$footerPhone =
    trim(
        $footerSettings['support_phone']
        ?? ''
    );


$footerEmail =
    trim(
        $footerSettings['support_email']
        ?? ''
    );


$footerWhatsapp =
    trim(
        $footerSettings['support_whatsapp']
        ?? ''
    );


/* =========================================================
   WHATSAPP LINK
========================================================= */

$footerWhatsappNumber =
    preg_replace(
        '/\D+/',
        '',
        $footerWhatsapp
    );


if (
    $footerWhatsappNumber !== '' &&
    str_starts_with(
        $footerWhatsappNumber,
        '0'
    )
) {

    $footerWhatsappNumber =
        '234' .
        substr(
            $footerWhatsappNumber,
            1
        );

}


$footerWhatsappLink =
    $footerWhatsappNumber !== ''
        ? 'https://wa.me/' .
          $footerWhatsappNumber .
          '?text=' .
          rawurlencode(
              'Hello Complete Bliss, I would like to make an enquiry.'
          )
        : '';

?>


<!-- =========================================================
     COMPLETE BLISS PUBLIC FOOTER
========================================================= -->

<footer class="cbx-footer">


    <!-- =====================================================
         FOOTER CTA
    ====================================================== -->

    <div class="cbx-footer-cta-wrap">

        <div class="cbx-container">


            <div class="cbx-footer-cta">


                <div class="cbx-footer-cta-icon">

                    <i class="fa-solid fa-seedling"></i>

                </div>


                <div class="cbx-footer-cta-content">

                    <span>
                        YOUR NEXT GOAL CAN START TODAY
                    </span>


                    <h2>
                        Plan today.
                        <strong>Enjoy tomorrow.</strong>
                    </h2>


                    <p>
                        Create your Complete Bliss account,
                        explore available schemes and start
                        working towards something meaningful.
                    </p>

                </div>


                <div class="cbx-footer-cta-actions">


                    <a
                        href="register.php"
                        class="cbx-footer-cta-primary"
                    >

                        Become a Member

                        <i class="fa-solid fa-arrow-right"></i>

                    </a>


                    <a
                        href="index.php#schemes"
                        class="cbx-footer-cta-secondary"
                    >

                        Explore Schemes

                    </a>


                </div>


            </div>


        </div>

    </div>



    <!-- =====================================================
         MAIN FOOTER
    ====================================================== -->

    <div class="cbx-footer-main">

        <div class="cbx-container">


            <div class="cbx-footer-grid">


                <!-- =========================================
                     BRAND
                ========================================== -->

                <div class="cbx-footer-brand">


                    <a
                        href="index.php"
                        class="cbx-footer-logo"
                    >

                        <img
                            src="public-site/assets/images/logo.png"
                            alt="<?= htmlspecialchars($footerCompanyName) ?>"
                        >

                    </a>


                    <p>
                        A clearer and more convenient way
                        to participate in contribution schemes,
                        monitor your progress and work towards
                        practical goals.
                    </p>


                    <div class="cbx-footer-trust">


                        <div>

                            <i class="fa-solid fa-circle-check"></i>

                            <span>
                                Clear Tracking
                            </span>

                        </div>


                        <div>

                            <i class="fa-solid fa-circle-check"></i>

                            <span>
                                Flexible Schemes
                            </span>

                        </div>


                        <div>

                            <i class="fa-solid fa-circle-check"></i>

                            <span>
                                Member Support
                            </span>

                        </div>


                    </div>


                </div>



                <!-- =========================================
                     QUICK LINKS
                ========================================== -->

                <div class="cbx-footer-column">


                    <h3>
                        Quick Links
                    </h3>


                    <nav class="cbx-footer-links">


                        <a href="index.php#home">
                            Home
                        </a>


                        <a href="index.php#schemes">
                            Available Schemes
                        </a>


                        <a href="index.php#how-it-works">
                            How It Works
                        </a>


                        <a href="index.php#about">
                            About Us
                        </a>


                        <a href="gallery.php">
                            Gallery
                        </a>


                        <a href="testimonials.php">
                            Testimonials
                        </a>


                    </nav>


                </div>



                <!-- =========================================
                     SUPPORT LINKS
                ========================================== -->

                <div class="cbx-footer-column">


                    <h3>
                        Help & Support
                    </h3>


                    <nav class="cbx-footer-links">


                        <a href="index.php#faq">
                            Frequently Asked Questions
                        </a>


                        <a href="index.php#contact">
                            Contact Us
                        </a>

<a href="terms.php">
    Terms & Conditions
</a>

<a href="privacy.php">
    Privacy Policy
</a>


                        <a href="login.php">
                            Member Login
                        </a>


                        <a href="register.php">
                            Create Account
                        </a>


                    </nav>


                </div>



                <!-- =========================================
                     CONTACT
                ========================================== -->

                <div class="cbx-footer-column cbx-footer-contact">


                    <h3>
                        Get In Touch
                    </h3>


                    <p>
                        Need clarification before joining?
                        Reach Complete Bliss through any
                        available support channel.
                    </p>



                    <?php if ($footerWhatsappLink !== ''): ?>


                        <a
                            href="<?= htmlspecialchars($footerWhatsappLink) ?>"
                            target="_blank"
                            rel="noopener noreferrer"
                            class="cbx-footer-contact-item"
                        >

                            <div class="cbx-footer-contact-icon cbx-footer-whatsapp">

                                <i class="fa-brands fa-whatsapp"></i>

                            </div>


                            <div>

                                <span>
                                    WhatsApp
                                </span>

                                <strong>
                                    <?= htmlspecialchars($footerWhatsapp) ?>
                                </strong>

                            </div>

                        </a>


                    <?php endif; ?>



                    <?php if ($footerPhone !== ''): ?>


                        <a
                            href="tel:<?= htmlspecialchars(
                                preg_replace(
                                    '/[^0-9+]/',
                                    '',
                                    $footerPhone
                                )
                            ) ?>"
                            class="cbx-footer-contact-item"
                        >

                            <div class="cbx-footer-contact-icon cbx-footer-phone">

                                <i class="fa-solid fa-phone"></i>

                            </div>


                            <div>

                                <span>
                                    Call Us
                                </span>

                                <strong>
                                    <?= htmlspecialchars($footerPhone) ?>
                                </strong>

                            </div>

                        </a>


                    <?php endif; ?>



                    <?php if ($footerEmail !== ''): ?>


                        <a
                            href="mailto:<?= htmlspecialchars($footerEmail) ?>"
                            class="cbx-footer-contact-item"
                        >

                            <div class="cbx-footer-contact-icon cbx-footer-email">

                                <i class="fa-solid fa-envelope"></i>

                            </div>


                            <div>

                                <span>
                                    Email
                                </span>

                                <strong>
                                    <?= htmlspecialchars($footerEmail) ?>
                                </strong>

                            </div>

                        </a>


                    <?php endif; ?>


                </div>


            </div>



            <!-- =========================================
                 BOTTOM
            ========================================== -->

            <div class="cbx-footer-bottom">


                <div>

                    <p>
                        &copy;
                        <?= date('Y') ?>
                        <?= htmlspecialchars($footerCompanyName) ?>.
                        All rights reserved.
                    </p>

                </div>


                <div class="cbx-footer-bottom-links">


                    <span>

                        <i class="fa-solid fa-shield-halved"></i>

                        Your journey. Clearly tracked.

                    </span>


                    <a href="login.php">

                        Member Portal

                        <i class="fa-solid fa-arrow-right"></i>

                    </a>


                </div>


            </div>


        </div>

    </div>


</footer>



<!-- =========================================================
     CLOSE PUBLIC SITE WRAPPER
========================================================= -->

</div>


<!-- =========================================================
     BOOTSTRAP
========================================================= -->

<script
    src="https://cdn.jsdelivr.net/npm/bootstrap@5.3.7/dist/js/bootstrap.bundle.min.js">
</script>


<!-- =========================================================
     COMPLETE BLISS PUBLIC JAVASCRIPT
========================================================= -->

<script
    src="public-site/assets/js/main.js">
</script>


</body>

</html>