<!DOCTYPE html>

<!--[if IE 8 ]><html class="ie" xmlns="http://www.w3.org/1999/xhtml" xml:lang="en-US" lang="en-US"> <![endif]-->
<!--[if (gte IE 9)|!(IE)]><!-->
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en-US" lang="en-US">
<!--<![endif]-->


<!-- Mirrored from themesflat.co/html/vemus/account-addresses.html by HTTrack Website Copier/3.x [XR&CO'2014], Thu, 02 Oct 2025 09:24:15 GMT -->
<head>
    <meta charset="utf-8">
    <title>Add Address - Jewelry Ecommerce </title>
    <meta name="author" content="themesflat.com">
    <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
    <meta name="description"
        content="Themesflat Vemus - A modern and elegant Jewelry Ecommerce HTML Template, perfect for online stores selling rings, necklaces, watches, and other accessories. SEO-optimized, fast-loading, and fully customizable.">

    <!-- font -->
    <link rel="stylesheet" href="fonts/fonts.css">
    <link rel="stylesheet" href="icon/icomoon/style.css">
    <!-- css -->
    <link rel="stylesheet" href="css/bootstrap.min.css">
    <link rel="stylesheet" href="css/swiper-bundle.min.css">
    <link rel="stylesheet" href="css/animate.css">
    <link rel="stylesheet" href="../../../sibforms.com/forms/end-form/build/sib-styles.css">
    <link rel="stylesheet" type="text/css" href="css/styles.css">

    <!-- Favicon and Touch Icons  -->
    <link rel="shortcut icon" href="images/logo/logo.png">
    <link rel="apple-touch-icon-precomposed" href="images/logo/logo.png">

</head>

<body>

    <!-- Scroll Top -->
    <button id="goTop">
        <span class="border-progress"></span>
        <span class="icon icon-arrow-right-2"></span>
    </button>

    <div id="wrapper">
        <!-- Top Bar-->
        
        <!-- /Top Bar -->
        <!-- Header -->
        <?php 
        include "common/header.php";
        ?>
        <!-- /Header -->
        <!-- Page Title -->
        <section class="flat-spacing-2 pb-0">
            <div class="container">
                <div class="page-title">
                    <div class="breadcrumbs">
                        
                        <h1 class="heading fw-normal text-uppercase">
                          My addresses
                        </h1>
                    </div>
                </div>
            </div>
        </section>
        <!-- /Page Title -->
        <!-- Account -->
        
        
        <?php
        
        $cust_id = $_SESSION['cust_id'] ?? 0;
        
        // Fetch number of addresses for this customer
        $stmt = $conn->prepare("SELECT COUNT(*) as total_addresses FROM cust_address WHERE cust_id = ?");
        $stmt->bind_param("i", $cust_id);
        $stmt->execute();
        $result = $stmt->get_result();
        $row = $result->fetch_assoc();
        $total_addresses = (int)$row['total_addresses'];
        $stmt->close();
        ?>
        
        <div class="flat-spacing">
            <div class="container">
                <div class="row">
                    <div class="col-lg-4">
                        <div class="sidebar-account-wrap sidebar-content-wrap sticky-top d-lg-block d-none">
                            <?php
                            include 'navbuttons.php';
                            ?>
                        </div>
                    </div>
                    <div class="col-lg-8">
                        <div class="my-acount-content account-order" id="updateCountMain">
                            <h4 class="heading fw-normal">
                                Your addresses (<span class="count_text"><?php echo $total_addresses; ?></span>)
                            </h4>
                            <div class="widget-inner-address">
                                <?php if ($total_addresses < 2): ?>
                                    <button class="tf-btn btn-fill animate-btn fw-medium btn-add-address">
                                        Add new address
                                    </button>
                                <?php endif; ?>
                                <form id="addAddressForm" class="wd-form-address style-border show-form-address" method="POST">
                                <div class="form-content-2">
                                    <div class="cols tf-grid-layout sm-col-2">
                                        <fieldset>
                                            <label class="text-label">Full Name</label>
                                            <input type="text" name="name" placeholder="Enter full name" required>
                                        </fieldset>
                                        <fieldset>
                                            <label class="text-label">Phone</label>
                                            <input type="text" name="phone" placeholder="Enter phone number" required>
                                        </fieldset>
                                    </div>
                            
                                    <fieldset>
                                        <label class="text-label">Email</label>
                                        <input type="email" name="email" placeholder="Enter email address">
                                    </fieldset>
                            
                                    <fieldset>
                                        <label class="text-label">Company</label>
                                        <input type="text" name="company" placeholder="Enter company name (optional)">
                                    </fieldset>
                            
                                    <fieldset>
                                        <label class="text-label">Address Label</label>
                                        <select name="address_label" required>
                                            <option value="Home">Home</option>
                                            <option value="Office">Office</option>
                                            <option value="Other">Other</option>
                                        </select>
                                    </fieldset>
                            
                                    <fieldset>
                                        <label class="text-label">Address Line 1</label>
                                        <input type="text" name="address1" placeholder="House number, Street, etc." required>
                                    </fieldset>
                            
                                    <fieldset>
                                        <label class="text-label">Address Line 2</label>
                                        <input type="text" name="address2" placeholder="Apartment, Building, etc.">
                                    </fieldset>
                            
                                    <div class="cols tf-grid-layout sm-col-2">
                                        <fieldset>
                                            <label class="text-label">City</label>
                                            <input type="text" name="city" required>
                                        </fieldset>
                                        <fieldset>
                                            <label class="text-label">Country</label>
                                            <input type="text" name="country" placeholder="Enter country" required>
                                        </fieldset>
                                    </div>
                            
                                    <div class="cols tf-grid-layout sm-col-2">
                                        <fieldset>
                                            <label class="text-label">State</label>
                                            <input type="text" name="state" required>
                                        </fieldset>
                                        <fieldset>
                                            <label class="text-label">Pincode</label>
                                            <input type="text" name="pincode" required>
                                        </fieldset>
                                    </div>
                            
                                    <fieldset>
                                        <label class="text-label">Landmark</label>
                                        <input type="text" name="landmark" placeholder="Nearby landmark">
                                    </fieldset>
                            
                                    <div class="checkbox-wrap mt-3">
                                        <input id="set-default" name="is_default" type="checkbox" value="1" class="tf-check style-4 p-0">
                                        <label for="set-default">Set as default address</label>
                                    </div>
                                </div>
                            
                                <div class="group-btn-form">
                                    <button class="tf-btn btn-fill fw-medium animate-btn" type="submit">
                                        Add Address
                                    </button>
                                    <a href="javascript:void(0);" class="tf-btn btn-out-line fw-medium btn-hide-address">
                                        Cancel
                                    </a>
                                </div>
                            </form>
                            
                            <div id="addressMessage" style="margin-top:10px;"></div>

                                <?php
                                
                                
                                $cust_id = $_SESSION['cust_id']; // assuming user is logged in
                                
                                $sql = "SELECT * FROM cust_address WHERE cust_id = '$cust_id' ORDER BY is_default DESC, id DESC LIMIT 2";
                                $result = mysqli_query($conn, $sql);
                                ?>
                                
                                <ul class="list-account-address tf-grid-layout md-col-2">
                                    <?php
                                    if (mysqli_num_rows($result) > 0) {
                                        while ($row = mysqli_fetch_assoc($result)) {
                                            $default_text = ($row['is_default'] == 1) ? ' (Default address)' : '';
                                            ?>
                                            <li class="account-address-item count_item">
                                                <p class="title">
                                                    <?php echo htmlspecialchars($row['address_label']) . $default_text; ?>
                                                </p>
                                                <div class="info-detail">
                                                    <div class="box-infor">
                                                        <span><?php echo htmlspecialchars($row['name']); ?></span>
                                                        <span><?php echo htmlspecialchars($row['email']); ?></span>
                                                        <span><?php echo htmlspecialchars($row['company']); ?></span>
                                                        <span><?php echo htmlspecialchars($row['address1']); ?></span>
                                                        <?php if (!empty($row['address2'])) { ?>
                                                            <span><?php echo htmlspecialchars($row['address2']); ?></span>
                                                        <?php } ?>
                                                        <span><?php echo htmlspecialchars($row['city']); ?></span>
                                                        <span><?php echo htmlspecialchars($row['country']); ?></span>
                                                        <span><?php echo htmlspecialchars($row['pincode']); ?></span>
                                                        <span><?php echo htmlspecialchars($row['phone']); ?></span>
                                                    </div>
                                                    <div class="box-btn">
                                                        <!--<button class="tf-btn btn-out-line fw-medium btn-edit-address"-->
                                                        <!--    data-id="<?php echo $row['id']; ?>">-->
                                                        <!--    Edit-->
                                                        <!--</button>-->
                                                        <button class="tf-btn btn-out-line fw-medium btn-delete-address count_del"
                                                            data-id="<?php echo $row['id']; ?>">
                                                            Delete
                                                        </button>
                                                    </div>
                                                </div>
                                            </li>
                                            <?php
                                        }
                                    } else {
                                        echo '<p>No saved addresses found.</p>';
                                    }
                                    ?>
                                </ul>

                                <form class="wd-form-address style-border edit-form-address">
                                    <div class="form-content-2">
                                        <div class="cols tf-grid-layout sm-col-2">
                                            <fieldset>
                                                <label class="text-label">First Name</label>
                                                <input type="text" required>
                                            </fieldset>
                                            <fieldset>
                                                <label class="text-label">Last Name</label>
                                                <input type="text" required>
                                            </fieldset>
                                        </div>
                                        <fieldset>
                                            <label class="text-label">Company</label>
                                            <input type="text" required>
                                        </fieldset>
                                        <fieldset>
                                            <label class="text-label">Address 1</label>
                                            <input type="text" required>
                                        </fieldset>
                                        <fieldset>
                                            <label class="text-label">City</label>
                                            <input type="text" required>
                                        </fieldset>
                                        <fieldset>
                                            <label class="text-label">Country/region</label>
                                            <input type="text" required>
                                        </fieldset>
                                        <fieldset>
                                            <label class="text-label">Province</label>
                                            <input type="text" required>
                                        </fieldset>
                                        <fieldset>
                                            <label class="text-label">Postal/ZIP code</label>
                                            <input type="text" required>
                                        </fieldset>
                                        <fieldset>
                                            <label class="text-label">Phone</label>
                                            <input type="number" required>
                                        </fieldset>
                                        <div class="checkbox-wrap">
                                            <input id="set-def-2" type="checkbox" class="tf-check style-4 p-0">
                                            <label for="set-def-2">Set as default address</label>
                                        </div>
                                    </div>

                                    <div class="group-btn-form">
                                        <button class="tf-btn btn-fill fw-medium animate-btn" type="submit">
                                            Update
                                        </button>
                                        <a href="javascript:void(0);" class="tf-btn btn-out-line fw-medium btn-hide-edit-address">
                                            Cancel
                                        </a>
                                    </div>
                                </form>
                            </div>
                        </div>
                    </div>
                </div>
            </div>
        </div>
        <!-- /Account -->
        <!-- Footer -->
        <?php 
        include "common/footer.php";
        ?>
        <!-- /Footer -->
    </div>
    
    <style>
    #addressMessage {
        width: 100%;              /* full width of parent */
        max-width: 400px;         /* optional max width */
        margin: 20px auto;        /* center horizontally with margin */
        text-align: center;       /* center text */
        padding: 10px 20px;       /* inner spacing */
        border-radius: 8px;       /* rounded corners */
        font-weight: 500;         /* medium font */
        font-size: 16px;          /* readable size */
        transition: all 0.3s ease; /* smooth color transition */
    }

    #addressMessage span {
        display: inline-block;
        padding: 5px 15px;
        border-radius: 5px;
    }

    /* Success message style */
    #addressMessage span.success {
        background-color: #d4edda;
        color: #155724;
        border: 1px solid #c3e6cb;
    }

    /* Error message style */
    #addressMessage span.error {
        background-color: #f8d7da;
        color: #721c24;
        border: 1px solid #f5c6cb;
    }
</style>

    
    <!-- /Toolbar -->
    <!-- Javascript -->
    <script src="js/bootstrap.min.js"></script>
    <script src="js/jquery.min.js"></script>
    <script src="js/swiper-bundle.min.js"></script>
    <script src="js/carousel.js"></script>
    <script src="js/bootstrap-select.min.js"></script>
    <script src="js/lazysize.min.js"></script>
    <script src="js/count-down.js"></script>
    <script src="js/wow.min.js"></script>
    <script src="js/infinityslide.js"></script>
    <script src="js/gsap.min.js"></script>
    <script src="js/ScrollTrigger.min.js"></script>
    <script src="js/SplitText.min.js"></script>
    <script src="js/main.js"></script>
    <script src="js/sibforms.js" defer></script>
    <script>
        window.REQUIRED_CODE_ERROR_MESSAGE = 'Please choose a country code';
        window.LOCALE = 'en';
        window.EMAIL_INVALID_MESSAGE = window.SMS_INVALID_MESSAGE = "The information provided is invalid. Please review the field format and try again.";

        window.REQUIRED_ERROR_MESSAGE = "This field cannot be left blank. ";

        window.GENERIC_INVALID_MESSAGE = "The information provided is invalid. Please review the field format and try again.";

        window.translation = {
            common: {
                selectedList: '{quantity} list selected',
                selectedLists: '{quantity} lists selected'
            }
        };

        var AUTOHIDE = Boolean(0);
    </script>
</body>


<!-- Mirrored from themesflat.co/html/vemus/account-addresses.html by HTTrack Website Copier/3.x [XR&CO'2014], Thu, 02 Oct 2025 09:24:15 GMT -->
</html>