œ_#ÁÕ§TE NAŒ“KeÉ:”(åŽÖJÞùY’‚ñùž7; «]Û ý`8g“¯B© jdÖÖ¸ðzœ¸¦4Ç3Kó^(ÍÖ¼ Õ€pvìwšõB4df$Èü^0˜…åÌC$#2FŽÑ§±¦ÛZ/÷š&m£ñzÒÖ ’.Î]!Î;ƒ(Õ–¢d/—#Kª+tZyuÏB>NÛÖ†(¸ŒSà'³„Y˜´-_•¦¼´˜OlNK§¶ÒàŠˆTHµƒeTPå·fïM’…þuÏÍüp6دªE£åü‡ZØ'CKF#â«;‹eyO 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"Qaq2‘¡#±Á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
<?php
// rental-invoice.php
session_start();
// Include your database connection
include "connection/config.php"; // should define $pdo or similar
if (!isset($_SESSION['customer_id'])) {
header("Location: login.php");
exit();
}
$customer_id = intval($_SESSION['customer_id']);
if (!isset($_GET['order_id'])) {
echo "Invalid invoice request.";
exit();
}
$order_id = intval($_GET['order_id']);
// Fetch the order
$sql = "SELECT * FROM allorders WHERE allorder_id = :oid AND customer_id = :cid";
$stmt = $pdo->prepare($sql);
$stmt->execute([':oid' => $order_id, ':cid' => $customer_id]);
$order = $stmt->fetch(PDO::FETCH_ASSOC);
if (!$order) {
echo "Invoice not found or access denied.";
exit();
}
// Decode the JSON structure
$orderJson = json_decode($order['order_json'], true);
if (!$orderJson) {
echo "Order data invalid.";
exit();
}
// Fetch customer info
$stmt2 = $pdo->prepare("SELECT * FROM customers WHERE customer_id = :cid");
$stmt2->execute([':cid' => $customer_id]);
$customer = $stmt2->fetch(PDO::FETCH_ASSOC);
// Helper to fetch product metadata
function fetchProduct($pdo, $product_id) {
$stmt = $pdo->prepare("SELECT product_name, thumbnail_image FROM products WHERE product_id = :pid");
$stmt->execute([':pid' => $product_id]);
return $stmt->fetch(PDO::FETCH_ASSOC);
}
// Extract totals
$totals = $orderJson['totals'];
$saleItems = $orderJson['sales_order']['items'] ?? [];
$rentalItems = $orderJson['rental_orders'] ?? [];
?>
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>Invoice #<?= htmlspecialchars($order_id) ?></title>
<meta name="viewport" content="width=device-width, initial-scale=1">
<style>
/* (Include your full CSS here — copied from your original with minor tweaks) */
:root {
--ink: #222;
--muted: #7b8790;
--line: #e6edf1;
--cyan: #9c1137;
--cyan-dark: #9c1137;
--paper: #fff;
}
html, body { height:100%; margin:0; background:#efeff0; font-family:"Open Sans", sans-serif; color: var(--ink); }
.wrap { max-width:860px; margin:86px auto 96px; padding:0 16px; position:relative; }
.wrap::before { content:""; position:absolute; inset:0; left:5%; right:5%; background: linear-gradient(90deg, transparent 8%, rgba(27,193,204,0.22) 8%, rgba(27,193,204,0.22) 92%, transparent 92%); border-radius:6px; }
.sheet { position:relative; background: var(--paper); border-radius:4px; box-shadow:0 10px 30px rgba(0,0,0,0.12); overflow: hidden; }
.header { display:flex; justify-content:space-between; align-items:flex-start; padding:18px 26px 10px; }
.brand { display:flex; align-items:center; gap:14px; }
.logo { height:40px; width:auto; display:block; }
.ribbon { position:relative; display:inline-block; background: var(--cyan); color:#fff; font:700 13px Montserrat, sans-serif; letter-spacing:.8px; padding:10px 16px; border-radius:4px; box-shadow:0 3px 0 var(--cyan-dark); text-transform:uppercase; }
.ribbon small { display:block; font:700 9px Montserrat, sans-serif; opacity:.9; letter-spacing:1.2px; }
.ribbon::after { content:""; position:absolute; right:-14px; top:0; border-top:22px solid var(--cyan); border-bottom:22px solid transparent; border-left:14px solid var(--cyan); width:0; height:0; }
.info { display:grid; grid-template-columns:1fr 1fr; gap:24px; padding:6px 26px 16px; }
.block h6 { margin:0 0 6px 0; color:var(--cyan); font:700 11px Montserrat, sans-serif; letter-spacing:1px; text-transform:uppercase; }
.block .name { margin:0 0 6px; font:700 18px Montserrat, sans-serif; }
.block p { margin:0; font-size:13px; color:#444; line-height:1.5; }
.meta { display:grid; grid-template-columns:repeat(4,1fr); gap:12px; border-top:1px solid var(--line); border-bottom:1px solid var(--line); padding:12px 26px; }
.meta .k { display:block; color:var(--muted); text-transform:uppercase; font:700 10px Montserrat, sans-serif; letter-spacing:1px; }
.meta .v { font-weight:600; font-size:13px; }
.table-area { padding:16px 26px 8px; position:relative; }
table { width:100%; border-collapse:collapse; font-size:14px; }
thead th { background: var(--cyan); color:#fff; font:700 11px Montserrat, sans-serif; letter-spacing:.8px; text-transform:uppercase; padding:11px 10px; border-right:2px solid var(--paper); }
thead th:first-child { text-align:left; border-top-left-radius:4px; }
thead th:last-child { border-right:none; border-top-right-radius:4px; }
tbody td { padding:12px 10px; border-bottom:1px solid var(--line); vertical-align:middle; }
.cell-item { display:flex; align-items:center; gap:12px; }
.thumb { width:50px; height:50px; object-fit:cover; border:1px solid var(--line); border-radius:4px; }
.item-title { font-weight:600; }
.item-sub { display:block; font-size:12px; color:var(--muted); margin-top:2px; }
.float-note { position:absolute; right:26px; bottom:72px; border:1px solid var(--line); border-radius:4px; background:#fbfeff; padding:8px 10px; width:180px; font-size:12px; }
.float-note .line { display:flex; justify-content:space-between; margin:2px 0; }
.totals { display:flex; justify-content:flex-end; padding:10px 26px 0; }
.total-box { width:260px; border:1px solid var(--line); border-radius:6px; background:#f8fcfd; padding:10px 12px; }
.total-row { display:flex; justify-content:space-between; margin:4px 0; font-size:14px; }
.total-row .k { color:#5b6670; }
.total-row.grand { font:700 18px Montserrat, sans-serif; margin-top:6px; }
.bottom { display:grid; grid-template-columns:1fr 220px; gap:18px; align-items:end; padding:12px 26px 24px; }
.notice { background:#f1feff; border:1px dashed var(--cyan); color:#47535c; border-radius:4px; padding:10px 12px; font-size:12.5px; }
.sign { text-align:right; }
.sign .line { width:160px; border-bottom:1px solid #cfd6db; margin-left:auto; margin-bottom:6px; }
.sign .by { font-size:12px; color:var(--muted); }
.watermark { position:absolute; left:26px; bottom:92px; opacity:.06; width:150px; pointer-events:none; }
.footer { border-top:1px solid var(--line); background:#fbfdfe; font-size:12.5px; color:#5b6670; display:flex; flex-wrap:wrap; gap:12px; justify-content:center; padding:10px 26px 14px; }
.footer span::after { content:"•"; margin:0 8px; color:#a9b4bc; }
.footer span:last-child::after { content:""; }
@media (max-width:768px) {
.info { grid-template-columns:1fr; }
.meta { grid-template-columns:1fr 1fr; }
.bottom { grid-template-columns:1fr; }
.ribbon { padding:8px 12px; font-size:12px; }
.ribbon::after { right:-12px; border-top:20px solid var(--cyan); border-left-width:12px; }
}
@media print {
body { background:#fff; }
.wrap::before { display:none; }
.sheet { box-shadow:none; }
.float-note { border-color:#ddd; }
}
/* Button style */
.invoice-action {
display: inline-flex;
align-items: center;
justify-content: center;
padding: 12px 20px;
background: var(--cyan);
color: #fff;
border-radius: 4px;
font-weight: 600;
text-decoration: none;
font-size: 14px;
border: none;
min-width: 160px;
gap: 8px;
cursor: pointer;
transition: background 0.2s ease;
}
.invoice-action:hover {
background: #7d0f2d;
}
</style>
</head>
<body>
<div class="wrap">
<div class="sheet">
<!-- HEADER -->
<div class="header">
<div class="brand">
<img class="logo" src="assets/image/headerlogo.webp" alt="Your Logo">
</div>
<div class="ribbon">
INVOICE
<small>SALE & RENTAL</small>
</div>
</div>
<!-- INFO -->
<div class="info">
<div class="block">
<h6>Store Details</h6>
<p class="name">Pooja Jewellers</p>
<p>8RG9+5P3, District Center, Chandrasekharpur, Bhubaneswar, Odisha 751016</p>
<p>+91 7008304043 • poojajewellersbbsr@gmail.com</p>
</div>
<div class="block">
<h6>Client Details</h6>
<p class="name"><?= htmlspecialchars($customer['first_name'] . ' ' . $customer['last_name']) ?></p>
<p><?= htmlspecialchars($customer['email']) ?></p>
<p><?= htmlspecialchars($customer['phone']) ?></p>
</div>
</div>
<!-- META -->
<div class="meta">
<div><span class="k">Payment Method</span><span class="v"><?= htmlspecialchars($orderJson['sales_order']['payment_method'] ?? 'N/A') ?></span></div>
<div><span class="k">Invoice No</span><span class="v">INV<?= $order_id ?></span></div>
</div>
<!-- TABLE AREA -->
<div class="table-area">
<table>
<thead>
<tr>
<th style="text-align:left">Item Description</th>
<th>Price</th>
<th>Qty</th>
<th>Total</th>
</tr>
</thead>
<tbody>
<?php foreach ($saleItems as $item):
$prod = fetchProduct($pdo, $item['product_id']);
?>
<tr>
<td>
<div class="cell-item">
<img class="thumb" src="<?= htmlspecialchars($prod['thumbnail_image']) ?>" alt="">
<div>
<div class="item-title"><?= htmlspecialchars($item['name']) ?></div>
<span class="item-sub">Code: <?= htmlspecialchars($prod['product_name']) ?></span>
</div>
</div>
</td>
<td style="text-align:center">₹ <?= number_format($item['price'], 2) ?></td>
<td style="text-align:center"><?= intval($item['quantity']) ?></td>
<td style="text-align:center">₹ <?= number_format($item['price'] * $item['quantity'], 2) ?></td>
</tr>
<?php endforeach; ?>
<?php foreach ($rentalItems as $rental):
$prod = fetchProduct($pdo, $rental['product_id']);
?>
<tr>
<td>
<div class="cell-item">
<img class="thumb" src="<?= htmlspecialchars($prod['thumbnail_image']) ?>" alt="">
<div>
<div class="item-title"><?= htmlspecialchars($rental['name']) ?> (Rental)</div>
<span class="item-sub">Days: <?= intval($rental['days']) ?></span>
</div>
</div>
</td>
<td style="text-align:center">
₹ <?= number_format($rental['price'], 2) ?><br>
<small style="color:var(--muted)">+ ₹ <?= number_format($rental['deposit'], 2) ?> Deposit</small>
</td>
<td style="text-align:center">1 </td>
<td style="text-align:center">₹ <?= number_format($rental['deposit'], 2) ?></td>
</tr>
<?php endforeach; ?>
</tbody>
</table>
<div class="">
</div>
</div>
<?php
// Initialize totals
$saleSubtotal = 0;
$rentalDepositTotal = 0;
// ---- Calculate Sale Product Subtotal ----
foreach ($saleItems as $item) {
$saleSubtotal += $item['price'] * $item['quantity'];
}
// ---- Calculate Rental Deposits ----
foreach ($rentalItems as $rental) {
$rentalDepositTotal += $rental['deposit'];
}
// ---- Calculate GST (3%) only for Sale ----
$gst = $saleSubtotal * 0.03;
// ---- Calculate Delivery Charge ----
$deliveryCharge = ($saleSubtotal > 0 && $saleSubtotal < 5000) ? 150 : 0;
// ---- Calculate Final Totals ----
$subtotal = $saleSubtotal + $rentalDepositTotal;
$finalAmount = $saleSubtotal + $gst + $deliveryCharge + $rentalDepositTotal;
// Store totals for display
$totals = [
'sale_subtotal' => $saleSubtotal,
'rental_deposit_total' => $rentalDepositTotal,
'gst' => $gst,
'delivery_charge' => $deliveryCharge,
'subtotal' => $subtotal,
'final_amount' => $finalAmount
];
?>
<!-- TOTALS BOX -->
<div class="totals">
<div class="total-box">
<div class="total-row">
<span class="k">Subtotal</span>
<span>₹ <?= number_format($totals['subtotal'], 2) ?></span>
</div>
<?php if ($totals['gst'] > 0): ?>
<div class="total-row">
<span class="k">GST (3%)</span>
<span>₹ <?= number_format($totals['gst'], 2) ?></span>
</div>
<?php endif; ?>
<?php if ($totals['delivery_charge'] > 0): ?>
<div class="total-row">
<span class="k">Delivery Charge</span>
<span>₹ <?= number_format($totals['delivery_charge'], 2) ?></span>
</div>
<?php endif; ?>
<hr style="border:none;border-top:1px solid var(--line); margin:8px 0;">
<div class="total-row grand">
<span>Total Payable</span>
<span>₹ <?= number_format($totals['final_amount'], 2) ?></span>
</div>
</div>
</div>
<!-- NOTE + SIGN -->
<div class="bottom">
<div class="notice">
This invoice includes both sale & rental. Rented items must be returned in original condition. Deposit refund will be processed after inspection.
</div>
<div class="sign">
<div class="line"></div>
<div class="by">Authorised Signature</div>
</div>
</div>
<!-- FOOTER -->
<div class="footer">
<span>poojajewellersbbsr.com</span>
<span>poojajewellersbbsr@gmail.com</span>
<span>+91 7008304043</span>
<span>@poojajewellers</span>
</div>
</div>
</div>
<!-- Print Button -->
<div class="invoice-button" style="margin-top:30px;">
<div style="display:flex; justify-content:center; gap:20px; flex-wrap:wrap;">
<button onclick="window.print()" class="invoice-action">
<i class="ri-printer-line icon-16 me-2"></i>
<span>Print Invoice</span>
</button>
</div>
</div>
</body>
</html>