<?php
/*
|--------------------------------------------------------------------------
| NEWSLETTER SUBSCRIPTION
|--------------------------------------------------------------------------
*/

if (isset($_POST['emailsubscibe'])) {

    $subscriberemail = trim($_POST['subscriberemail']);

    if (!empty($subscriberemail)) {

        $sql = "SELECT SubscriberEmail
                FROM tblsubscribers
                WHERE SubscriberEmail = :subscriberemail
                LIMIT 1";

        $query = $dbh->prepare($sql);

        $query->bindParam(
            ':subscriberemail',
            $subscriberemail,
            PDO::PARAM_STR
        );

        $query->execute();

        if ($query->rowCount() > 0) {

            echo "<script>
                alert('Already Subscribed.');
            </script>";

        } else {

            $sql = "INSERT INTO tblsubscribers
                    (SubscriberEmail)
                    VALUES
                    (:subscriberemail)";

            $query = $dbh->prepare($sql);

            $query->bindParam(
                ':subscriberemail',
                $subscriberemail,
                PDO::PARAM_STR
            );

            $query->execute();

            $lastInsertId = $dbh->lastInsertId();

            if ($lastInsertId) {

                echo "<script>
                    alert('Subscribed successfully.');
                </script>";

            } else {

                echo "<script>
                    alert('Something went wrong. Please try again.');
                </script>";

            }

        }

    }

}


/*
|--------------------------------------------------------------------------
| CONTACT INFORMATION
|--------------------------------------------------------------------------
*/

$footerEmail = '';
$footerPhone = '';

try {

    $sql = "SELECT EmailId, ContactNo
            FROM tblcontactusinfo
            LIMIT 1";

    $query = $dbh->prepare($sql);

    $query->execute();

    $footerContact = $query->fetch(PDO::FETCH_OBJ);

    if ($footerContact) {

        $footerEmail = $footerContact->EmailId;
        $footerPhone = $footerContact->ContactNo;

    }

} catch (Exception $e) {

    $footerEmail = '';
    $footerPhone = '';

}

?>


<!-- =========================================================
     MODERN FOOTER
========================================================= -->

<footer class="modern-footer">


    <!-- =====================================================
         NEWSLETTER / CTA
    ====================================================== -->

    <section class="footer-newsletter">

        <div class="modern-footer-container">

            <div class="newsletter-card">

                <div class="newsletter-content">

                    <span class="newsletter-badge">

                        <i class="fa fa-paper-plane"></i>

                        Stay Updated

                    </span>

                    <h2>

                        Get the best rental deals
                        <br>
                        straight to your inbox.

                    </h2>

                    <p>

                        Subscribe to receive special offers,
                        new vehicles and useful travel updates.

                    </p>

                </div>


                <div class="newsletter-form-wrapper">

                    <form
                        method="post"
                        class="modern-newsletter-form"
                    >

                        <div class="newsletter-input-wrapper">

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

                            <input
                                type="email"
                                name="subscriberemail"
                                placeholder="Enter your email address"
                                required
                            >

                        </div>


                        <button
                            type="submit"
                            name="emailsubscibe"
                        >

                            Subscribe

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

                        </button>

                    </form>


                    <small>

                        <i class="fa fa-lock"></i>

                        We respect your privacy. No spam.

                    </small>

                </div>

            </div>

        </div>

    </section>


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

    <div class="footer-main">

        <div class="modern-footer-container">

            <div class="footer-grid">


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

                <div class="footer-brand">

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

                        <img
                            src="assets/images/logo.png"
                            alt="Car Rental"
                        >

                    </a>


                    <p>

                        Your trusted partner for comfortable,
                        reliable and affordable car rentals.
                        Find the right vehicle for every journey.

                    </p>


                    <div class="footer-contact-list">


                        <?php if (!empty($footerPhone)) { ?>

                            <a
                                href="tel:<?php echo htmlentities($footerPhone); ?>"
                                class="footer-contact-item"
                            >

                                <span class="footer-contact-icon">

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

                                </span>

                                <span>

                                    <small>Call us</small>

                                    <strong>
                                        <?php echo htmlentities($footerPhone); ?>
                                    </strong>

                                </span>

                            </a>

                        <?php } ?>


                        <?php if (!empty($footerEmail)) { ?>

                            <a
                                href="mailto:<?php echo htmlentities($footerEmail); ?>"
                                class="footer-contact-item"
                            >

                                <span class="footer-contact-icon">

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

                                </span>

                                <span>

                                    <small>Email us</small>

                                    <strong>
                                        <?php echo htmlentities($footerEmail); ?>
                                    </strong>

                                </span>

                            </a>

                        <?php } ?>

                    </div>

                </div>


                <!-- =================================================
                     COMPANY
                ================================================== -->

                <div class="footer-column">

                    <h4>Company</h4>

                    <ul>

                        <li>
                            <a href="page.php?type=aboutus">
                                About Us
                            </a>
                        </li>

                        <li>
                            <a href="car-listing.php">
                                Our Cars
                            </a>
                        </li>

                        <li>
                            <a href="page.php?type=faqs">
                                FAQs
                            </a>
                        </li>

                        <li>
                            <a href="contact-us.php">
                                Contact Us
                            </a>
                        </li>

                    </ul>

                </div>


                <!-- =================================================
                     CUSTOMER
                ================================================== -->

                <div class="footer-column">

                    <h4>Customer</h4>

                    <ul>

                        <?php if (!empty($_SESSION['login'])) { ?>

                            <li>
                                <a href="profile.php">
                                    My Profile
                                </a>
                            </li>

                            <li>
                                <a href="my-booking.php">
                                    My Bookings
                                </a>
                            </li>

                            <li>
                                <a href="post-testimonial.php">
                                    Write a Review
                                </a>
                            </li>

                            <li>
                                <a href="update-password.php">
                                    Update Password
                                </a>
                            </li>

                        <?php } else { ?>

                            <li>
                                <a
                                    href="#loginform"
                                    data-toggle="modal"
                                >
                                    Login
                                </a>
                            </li>

                            <li>
                                <a
                                    href="#registration"
                                    data-toggle="modal"
                                >
                                    Create Account
                                </a>
                            </li>

                            <li>
                                <a href="car-listing.php">
                                    Browse Cars
                                </a>
                            </li>

                        <?php } ?>

                    </ul>

                </div>


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

                <div class="footer-column">

                    <h4>Support</h4>

                    <ul>

                        <li>
                            <a href="page.php?type=privacy">
                                Privacy Policy
                            </a>
                        </li>

                        <li>
                            <a href="page.php?type=terms">
                                Terms & Conditions
                            </a>
                        </li>

                        <li>
                            <a href="page.php?type=faqs">
                                Help Center
                            </a>
                        </li>

                        <li>
                            <a href="contact-us.php">
                                Contact Support
                            </a>
                        </li>

                    </ul>

                </div>

            </div>

        </div>

    </div>


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

    <div class="footer-bottom">

        <div class="modern-footer-container">

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


                <p class="copyright">

                    © <?php echo date('Y'); ?>

                    Car Rental Portal.

                    All rights reserved.

                </p>


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


                    <span>
                        Follow us
                    </span>


                    <div class="footer-socials">


                        <a
                            href="#"
                            aria-label="Facebook"
                        >

                            <i class="fa fa-facebook"></i>

                        </a>


                        <a
                            href="#"
                            aria-label="Twitter"
                        >

                            <i class="fa fa-twitter"></i>

                        </a>


                        <a
                            href="#"
                            aria-label="Instagram"
                        >

                            <i class="fa fa-instagram"></i>

                        </a>


                        <a
                            href="#"
                            aria-label="LinkedIn"
                        >

                            <i class="fa fa-linkedin"></i>

                        </a>

                    </div>


                    <a
                        href="admin/"
                        class="admin-login-link"
                    >

                        Admin

                    </a>

                </div>

            </div>

        </div>

    </div>

</footer>


<!-- =========================================================
     FOOTER STYLES
========================================================= -->

<style>

/* =========================================================
   FOOTER VARIABLES
========================================================= */

.modern-footer {

    --footer-dark: #071A33;

    --footer-dark-2: #0A2342;

    --footer-primary: #0B5ED7;

    --footer-blue: #3B82F6;

    --footer-text: #98A2B3;

    --footer-white: #FFFFFF;

    --footer-border: rgba(255,255,255,.10);

    width: 100%;

    color: #fff;

}


/* =========================================================
   FOOTER CONTAINER
========================================================= */

.modern-footer-container {

    width: 100%;

    max-width: 1200px;

    margin: 0 auto;

    padding-left: 20px;

    padding-right: 20px;

}


/* =========================================================
   NEWSLETTER
========================================================= */

.footer-newsletter {

    position: relative;

    padding: 70px 0 0;

    background: #F8FAFC;

}


.newsletter-card {

    position: relative;

    display: flex;

    align-items: center;

    justify-content: space-between;

    gap: 40px;

    padding: 42px 45px;

    border-radius: 18px;

    background:
        linear-gradient(
            135deg,
            #071A33,
            #0B3B78
        );

    overflow: hidden;

    box-shadow:
        0 20px 50px rgba(7,26,51,.18);

}


.newsletter-card:after {

    content: "";

    position: absolute;

    width: 300px;

    height: 300px;

    right: -120px;

    top: -150px;

    border-radius: 50%;

    border: 1px solid rgba(255,255,255,.08);

    box-shadow:
        0 0 0 45px rgba(255,255,255,.03),
        0 0 0 90px rgba(255,255,255,.02);

}


.newsletter-content {

    position: relative;

    z-index: 2;

    max-width: 520px;

}


.newsletter-badge {

    display: inline-flex;

    align-items: center;

    gap: 7px;

    margin-bottom: 12px;

    padding: 6px 10px;

    border-radius: 50px;

    background: rgba(255,255,255,.10);

    color: #BBD7FF;

    font-size: 10px;

    font-weight: 900;

    text-transform: uppercase;

    letter-spacing: .6px;

}


.newsletter-content h2 {

    margin: 0 0 12px;

    color: #fff;

    font-size: 30px;

    line-height: 1.2;

    font-weight: 900;

}


.newsletter-content p {

    margin: 0;

    color: rgba(255,255,255,.68);

    font-size: 13px;

    line-height: 1.7;

}


.newsletter-form-wrapper {

    position: relative;

    z-index: 2;

    width: 440px;

    flex-shrink: 0;

}


.modern-newsletter-form {

    display: flex;

    gap: 8px;

    padding: 5px;

    border-radius: 10px;

    background: #fff;

}


.newsletter-input-wrapper {

    position: relative;

    flex: 1;

}


.newsletter-input-wrapper i {

    position: absolute;

    left: 13px;

    top: 50%;

    transform: translateY(-50%);

    color: #98A2B3;

}


.newsletter-input-wrapper input {

    width: 100%;

    height: 43px;

    padding: 0 10px 0 37px;

    border: none;

    outline: none;

    background: transparent;

    color: #101828;

    font-size: 12px;

}


.modern-newsletter-form button {

    height: 43px;

    padding: 0 18px;

    border: none;

    border-radius: 7px;

    background: var(--footer-primary);

    color: #fff;

    font-size: 12px;

    font-weight: 900;

    cursor: pointer;

    white-space: nowrap;

}


.modern-newsletter-form button:hover {

    background: #084298;

}


.modern-newsletter-form button i {

    margin-left: 6px;

    font-size: 10px;

}


.newsletter-form-wrapper > small {

    display: block;

    margin-top: 9px;

    color: rgba(255,255,255,.55);

    font-size: 10px;

}


.newsletter-form-wrapper > small i {

    margin-right: 4px;

}


/* =========================================================
   MAIN FOOTER
========================================================= */

.footer-main {

    padding: 75px 0 65px;

    background: var(--footer-dark);

}


.footer-grid {

    display: grid;

    grid-template-columns:
        2fr
        1fr
        1fr
        1fr;

    gap: 55px;

}


/* =========================================================
   BRAND
========================================================= */

.footer-brand {

    max-width: 360px;

}


.footer-logo {

    display: inline-flex;

    align-items: center;

    margin-bottom: 22px;

}


.footer-logo img {

    max-width: 155px;

    max-height: 50px;

    width: auto;

    height: auto;

    filter: brightness(0) invert(1);

}


.footer-brand > p {

    margin: 0 0 24px;

    color: var(--footer-text);

    font-size: 12px;

    line-height: 1.8;

}


/* =========================================================
   CONTACT
========================================================= */

.footer-contact-list {

    display: flex;

    flex-direction: column;

    gap: 13px;

}


.footer-contact-item {

    display: flex;

    align-items: center;

    gap: 10px;

    color: #fff;

    text-decoration: none !important;

}


.footer-contact-item:hover {

    color: #fff;

}


.footer-contact-icon {

    width: 35px;

    height: 35px;

    display: flex;

    align-items: center;

    justify-content: center;

    border-radius: 8px;

    background: rgba(255,255,255,.07);

    color: #5EA5FF;

}


.footer-contact-item small {

    display: block;

    margin-bottom: 2px;

    color: #667085;

    font-size: 9px;

    text-transform: uppercase;

    letter-spacing: .5px;

}


.footer-contact-item strong {

    display: block;

    color: #D0D5DD;

    font-size: 11px;

    font-weight: 700;

}


/* =========================================================
   FOOTER COLUMNS
========================================================= */

.footer-column h4 {

    margin: 5px 0 20px;

    color: #fff;

    font-size: 13px;

    font-weight: 900;

}


.footer-column h4:after {

    content: "";

    display: block;

    width: 25px;

    height: 2px;

    margin-top: 8px;

    border-radius: 5px;

    background: var(--footer-primary);

}


.footer-column ul {

    padding: 0;

    margin: 0;

    list-style: none;

}


.footer-column li {

    margin-bottom: 12px;

}


.footer-column a {

    color: #98A2B3;

    font-size: 11px;

    font-weight: 600;

    text-decoration: none;

    transition: .2s ease;

}


.footer-column a:hover {

    padding-left: 4px;

    color: #fff;

}


/* =========================================================
   BOTTOM FOOTER
========================================================= */

.footer-bottom {

    border-top: 1px solid var(--footer-border);

    background: #06162B;

}


.footer-bottom-inner {

    min-height: 72px;

    display: flex;

    align-items: center;

    justify-content: space-between;

    gap: 20px;

}


.copyright {

    margin: 0;

    color: #667085;

    font-size: 10px;

}


.footer-bottom-right {

    display: flex;

    align-items: center;

    gap: 15px;

}


.footer-bottom-right > span {

    color: #667085;

    font-size: 10px;

}


.footer-socials {

    display: flex;

    align-items: center;

    gap: 7px;

}


.footer-socials a {

    width: 31px;

    height: 31px;

    display: flex;

    align-items: center;

    justify-content: center;

    border: 1px solid rgba(255,255,255,.08);

    border-radius: 7px;

    color: #98A2B3;

    text-decoration: none;

    transition: .2s ease;

}


.footer-socials a:hover {

    background: var(--footer-primary);

    border-color: var(--footer-primary);

    color: #fff;

}


.footer-socials i {

    font-size: 12px;

}


.admin-login-link {

    padding-left: 15px;

    border-left: 1px solid var(--footer-border);

    color: #667085 !important;

    font-size: 10px;

    text-decoration: none;

}


.admin-login-link:hover {

    color: #fff !important;

}


/* =========================================================
   TABLET
========================================================= */

@media(max-width: 900px) {

    .newsletter-card {

        flex-direction: column;

        align-items: flex-start;

        padding: 35px;

    }


    .newsletter-form-wrapper {

        width: 100%;

    }


    .footer-grid {

        grid-template-columns:
            1.5fr
            1fr
            1fr;

        gap: 40px;

    }


    .footer-brand {

        grid-column: span 3;

        max-width: 600px;

    }

}


/* =========================================================
   MOBILE
========================================================= */

@media(max-width: 600px) {

    .footer-newsletter {

        padding-top: 45px;

    }


    .newsletter-card {

        padding: 28px 22px;

        border-radius: 14px;

    }


    .newsletter-content h2 {

        font-size: 24px;

    }


    .newsletter-content p {

        font-size: 12px;

    }


    .modern-newsletter-form {

        flex-direction: column;

        padding: 7px;

    }


    .newsletter-input-wrapper input {

        height: 45px;

    }


    .modern-newsletter-form button {

        width: 100%;

    }


    .footer-main {

        padding: 50px 0 40px;

    }


    .footer-grid {

        display: grid;

        grid-template-columns: 1fr 1fr;

        gap: 35px 25px;

    }


    .footer-brand {

        grid-column: span 2;

    }


    .footer-column h4 {

        margin-bottom: 15px;

    }


    .footer-bottom-inner {

        padding: 18px 0;

        flex-direction: column;

        align-items: flex-start;

    }


    .footer-bottom-right {

        width: 100%;

        justify-content: space-between;

    }


    .footer-bottom-right > span {

        display: none;

    }

}


@media(max-width: 380px) {

    .footer-grid {

        grid-template-columns: 1fr;

    }


    .footer-brand {

        grid-column: span 1;

    }


    .footer-bottom-right {

        flex-wrap: wrap;

    }

}

</style>