chnage some feaures

main
Suvodip 2025-04-02 19:46:00 +05:30
parent 43f6f2ce21
commit 1ceb71c146
8 changed files with 109 additions and 234 deletions

1
assets/download.svg Normal file
View File

@ -0,0 +1 @@
<svg width="25px" height="25px" viewBox="0 0 24 24" fill="none" xmlns="http://www.w3.org/2000/svg"><g id="SVGRepo_bgCarrier" stroke-width="0"></g><g id="SVGRepo_tracerCarrier" stroke-linecap="round" stroke-linejoin="round"></g><g id="SVGRepo_iconCarrier"> <path d="M12 7L12 14M12 14L15 11M12 14L9 11" stroke="#374151" stroke-width="1.5" stroke-linecap="round" stroke-linejoin="round"></path> <path d="M16 17H12H8" stroke="#374151" stroke-width="1.5" stroke-linecap="round"></path> <path d="M22 12C22 16.714 22 19.0711 20.5355 20.5355C19.0711 22 16.714 22 12 22C7.28595 22 4.92893 22 3.46447 20.5355C2 19.0711 2 16.714 2 12C2 7.28595 2 4.92893 3.46447 3.46447C4.92893 2 7.28595 2 12 2C16.714 2 19.0711 2 20.5355 3.46447C21.5093 4.43821 21.8356 5.80655 21.9449 8" stroke="#374151" stroke-width="1.5" stroke-linecap="round"></path> </g></svg>

After

Width:  |  Height:  |  Size: 839 B

1
assets/print.svg Normal file
View File

@ -0,0 +1 @@
<svg width="25px" height="25px" viewBox="0 0 24 24" fill="none" xmlns="http://www.w3.org/2000/svg"><g id="SVGRepo_bgCarrier" stroke-width="0"></g><g id="SVGRepo_tracerCarrier" stroke-linecap="round" stroke-linejoin="round"></g><g id="SVGRepo_iconCarrier"><path fill-rule="evenodd" clip-rule="evenodd" d="M17 7H7V6h10v1zm0 12H7v-6h10v6zm2-12V3H5v4H1v8.996C1 17.103 1.897 18 3.004 18H5v3h14v-3h1.996A2.004 2.004 0 0 0 23 15.996V7h-4z" fill="#374151"></path></g></svg>

After

Width:  |  Height:  |  Size: 465 B

View File

@ -190,7 +190,7 @@
<th>Amount</th>
<th>Date</th>
<th>Payment Date</th>
<th>Payment Status</th>
<th>Status</th>
<th>Action</th>
</tr>
</thead>
@ -208,7 +208,7 @@
<input value="<?= date('Y-m-d', strtotime($emi['emiDate'])); ?>" id="paymentDateId" class="form-control" type="date" />
<?php } ?>
</td>
<td>
<td class="text-center">
<span id="status-<?= $emi['id']; ?>" class="badge <?= $emi['payStatus'] == 0 ? 'bg-danger' : 'bg-success'; ?>">
<?= $emi['payStatus'] == 0 ? 'Unpaid' : 'Paid'; ?>
</span>

View File

@ -22,41 +22,10 @@
$description = $_POST['description'];
$quantity = $_POST['quantity'];
$rate = $_POST['rate'];
$discount = $_POST['discount'];
$discountAmount = $_POST['discountAmount'];
// EMI Calculation
$emiAmount = round($totalAmount / $tenure, 2);
$outstandingAmount = $totalAmount;
$emiDate = new DateTime($bookingDate); // Set initial date
// $stmt = $db->prepare("INSERT INTO emi (customerId, emiNumber, emiAmount, emiDate, totalAmount, outstanding, tenure, frequency, bookingDate, invoiceId) VALUES (:customerId, :emiNumber, :emiAmount, :emiDate, :totalAmount, :outstanding, :tenure, :frequency, :bookingDate, :invoiceId)");
// for ($i = 1; $i <= $tenure; $i++) {
// $outstandingAmount -= $emiAmount;
// $emiDateFormatted = $emiDate->format('Y-m-d');
// $stmt->bindParam(':customerId', $_GET['customerId']);
// $stmt->bindParam(':emiNumber', $i);
// $stmt->bindParam(':emiAmount', $emiAmount);
// $stmt->bindParam(':emiDate', $emiDateFormatted);
// $stmt->bindParam(':totalAmount', $totalAmount);
// $stmt->bindParam(':outstanding', $outstandingAmount);
// $stmt->bindParam(':tenure', $tenure);
// $stmt->bindParam(':frequency', $frequency);
// $stmt->bindParam(':bookingDate', $bookingDate);
// $stmt->bindParam(':invoiceId', $invoiceId);
// $stmt->execute();
// // Move to the next EMI date
// if (trim(strtolower($frequency)) === 'weekly') {
// $emiDate->modify('+1 week');
// } elseif (trim(strtolower($frequency)) === 'monthly') {
// $emiDate->modify('+1 month');
// }
// }
// Insert into invoice table
$stmt2 = $db->prepare("UPDATE invoice SET customerName = :customerName, address = :address, invoiceDate = :invoiceDate, paymentMode = :paymentMode, salesAgent = :salesAgent, marketingAgent = :marketingAgent, item = :item, description = :description, adminNote = :adminNote WHERE customerId = :customerId AND invoiceId = :invoiceId");
// Update invoice table
$stmt2 = $db->prepare("UPDATE invoice SET customerName = :customerName, address = :address, invoiceDate = :invoiceDate, paymentMode = :paymentMode, salesAgent = :salesAgent, marketingAgent = :marketingAgent, item = :item, description = :description, adminNote = :adminNote, discountAmount = :discountAmount, totalAmount = :totalAmount WHERE customerId = :customerId AND invoiceId = :invoiceId");
$stmt2->bindParam(':customerId', $_GET['customerId']);
$stmt2->bindParam(':invoiceId', $invoiceId);
$stmt2->bindParam(':customerName', $customerName);
@ -68,8 +37,11 @@
$stmt2->bindParam(':item', $item);
$stmt2->bindParam(':description', $description);
$stmt2->bindParam(':adminNote', $adminNote);
$stmt2->bindParam(':discountAmount', $discountAmount);
$stmt2->bindParam(':totalAmount', $totalAmount);
$stmt2->execute();
echo '<div class="alert alert-success">New EMI Plan Saved Successfully!</div>';
echo '<div class="alert alert-success">Invoice Updated Successfully!</div>';
echo '<script>
document.addEventListener("DOMContentLoaded", function() {
document.getElementById("printBtn").classList.remove("visually-hidden");
@ -85,8 +57,9 @@
$db = new PDO("mysql:host=$mariaServer;dbname=$mariaDb", $mariaUser, $mariaPass);
$db->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
$stmt = $db->prepare("SELECT * FROM invoice WHERE customerId = :customerId");
$stmt = $db->prepare("SELECT * FROM invoice WHERE customerId = :customerId AND invoiceId = :invoiceId");
$stmt->bindParam(':customerId', $_GET['customerId']);
$stmt->bindParam(':invoiceId', $_GET['invoiceId']);
$stmt->execute();
$invoiceData = $stmt->fetch(PDO::FETCH_ASSOC);
$invoiceDate = date('Y-m-d', strtotime($invoiceData['invoiceDate']));
@ -96,9 +69,8 @@
}
?>
<div class="container mt-4">
<h4>Create New Invoice</h4>
<h4>Edit Invoice</h4>
<hr>
<form method="POST">
<div class="d-flex justify-content-between gap-4">
@ -119,10 +91,10 @@
<div class="mb-3">
<label for="frequency" class="form-label">Frequency:</label>
<select name="frequency" class="form-control" disabled>
<option value="Weekly" <?php echo ($invoiceData['frequency'] === 'Weekly') ? 'selected' : ''; ?>>Weekly</option>
<option value="Monthly" <?php echo ($invoiceData['frequency'] === 'Monthly') ? 'selected' : ''; ?>>Monthly</option>
<option value="Weekly" <?= ($invoiceData['frequency'] === 'Weekly') ? 'selected' : ''; ?>>Weekly</option>
<option value="Monthly" <?= ($invoiceData['frequency'] === 'Monthly') ? 'selected' : ''; ?>>Monthly</option>
</select>
<input type="hidden" name="frequency" value="<?php echo htmlspecialchars($invoiceData['frequency']); ?>">
<input type="hidden" name="frequency" value="<?= htmlspecialchars($invoiceData['frequency']); ?>">
</div>
<div class="d-flex w-100 gap-2">
<div class="mb-3 w-100">
@ -134,7 +106,7 @@
<div class="w-100">
<div class="mb-3">
<label for="paymentMode" class="form-label">Payment Methods:</label>
<select name="paymentMode" class="form-control"required>
<select name="paymentMode" class="form-control" required>
<option value="">-Select-</option>
<?php
$paymentModes = ["Stripe", "Zelle", "Bank Transfer", "Cheque", "Other"];
@ -147,15 +119,15 @@
</div>
<div class="mb-3">
<label for="salesAgent" class="form-label">Sales Agent:</label>
<select name="salesAgent" class="form-control"required>
<select name="salesAgent" class="form-control" required>
<option value="">-Select-</option>
<?php
$salesAgentOptions = ["Prabhat Mishra", "Suvojit Mishra"];
foreach ($salesAgentOptions as $salesAgentItems) {
$selected = ($invoiceData['salesAgent'] === $salesAgentItems) ? 'selected' : '';
echo "<option value=\"$salesAgentItems\" $selected>$salesAgentItems</option>";
}
?>
<?php
$salesAgentOptions = ["Prabhat Mishra", "Suvojit Mishra"];
foreach ($salesAgentOptions as $salesAgentItems) {
$selected = ($invoiceData['salesAgent'] === $salesAgentItems) ? 'selected' : '';
echo "<option value=\"$salesAgentItems\" $selected>$salesAgentItems</option>";
}
?>
</select>
</div>
<div class="mb-3">
@ -171,28 +143,22 @@
?>
</select>
</div>
<?php
$tenureOptions = [ "1" => "One Time","3" => "3","6" => "6","9" => "9","12" => "12","0" => "Custom" ];
$selectedTenure = $invoiceData['tenure'] ?? ''; // Get selected tenure value
?>
<div class="mb-3">
<label for="tenure" class="form-label">Total Cycles:</label>
<select id="tenureAuto" name="tenure" class="form-control" disabled>
<option value="">-Select-</option>
<?php
foreach ($tenureOptions as $value => $label) {
$selected = ($selectedTenure == $value) ? 'selected' : '';
echo "<option value=\"$value\" $selected>$label</option>";
}
$tenureOptions = ["1" => "One Time", "3" => "3", "6" => "6", "9" => "9", "12" => "12", "0" => "Custom"];
$selectedTenure = $invoiceData['tenure'] ?? '';
foreach ($tenureOptions as $value => $label) {
$selected = ($selectedTenure == $value) ? 'selected' : '';
echo "<option value=\"$value\" $selected>$label</option>";
}
?>
</select>
<input type="hidden" name="tenure" value="<?php echo htmlspecialchars($selectedTenure); ?>">
<input type="text" name="tenure" id="tenureCustom" class="form-control visually-hidden"
placeholder="Enter custom value" disabled onblur="restoreDropdown(this)" />
<input type="hidden" name="tenure" value="<?= htmlspecialchars($selectedTenure); ?>">
<input type="text" name="tenure" id="tenureCustom" class="form-control visually-hidden" placeholder="Enter custom value" disabled onblur="restoreDropdown(this)" />
</div>
<div class="mb-3">
<label for="adminNote" class="form-label">Admin Note:</label>
<textarea class="form-control" name="adminNote" id="adminNote" cols="30" rows="4"><?= htmlspecialchars($invoiceData['adminNote']); ?></textarea>
@ -207,8 +173,7 @@
<th class="p-2">Description</th>
<th class="p-2">Qty</th>
<th class="p-2">Rate</th>
<th class="p-2">Discount&nbsp;% </th>
<th class="p-2">Discount&nbsp;&#36;</th>
<th class="p-2">Discount&nbsp;$</th>
<th class="p-2">Amount</th>
</tr>
</thead>
@ -218,30 +183,16 @@
<input type="text" class="form-control w-100" name="item" id="item" value="<?= htmlspecialchars($invoiceData['item']); ?>" />
</td>
<td>
<input type="text" class="form-control w-100" name="description" id="description" value="<?= htmlspecialchars($invoiceData['description']); ?>" />
<input type="text" class="form-control w-100" name="description" id="description" value="<?= htmlspecialchars($invoiceData['description']); ?>" />
</td>
<td>
<input class="form-control w-100" name="quantity" id="quantity" value="<?= htmlspecialchars($invoiceData['qty']); ?>" readonly/>
<input class="form-control w-100" name="quantity" id="quantity" value="<?= htmlspecialchars($invoiceData['qty']); ?>" />
</td>
<td>
<input class="form-control w-100" name="rate" id="rate" value="<?= htmlspecialchars($invoiceData['rate']); ?>" readonly/>
<input class="form-control w-100" name="rate" id="rate" value="<?= htmlspecialchars($invoiceData['rate']); ?>" />
</td>
<td>
<select name="discount" id="discount" class="form-control" disabled>
<option value="0" <?php echo ($invoiceData['discount'] === "0") ? 'selected' : ''; ?>>No Discount</option>
<?php
$discountOptions = ["5", "10", "12", "18"];
foreach ($discountOptions as $discountItems) {
$selected = ($invoiceData['discount'] === $discountItems) ? 'selected' : '';
echo "<option value=\"$discountItems\" $selected> $discountItems%</option>";
}
?>
</select>
<input type="hidden" name="discount" value="<?php echo htmlspecialchars($invoiceData['discount']); ?>">
</td>
<td>
<input readonly class="form-control" name="discountAmount" id="discountAmount" value="<?= htmlspecialchars($invoiceData['discountAmount']); ?>" />
<input class="form-control" name="discountAmount" id="discountAmount" value="<?= htmlspecialchars($invoiceData['discountAmount']); ?>" />
</td>
<td>
<input readonly class="form-control" name="totalAmount" id="totalAmount" value="<?= htmlspecialchars($invoiceData['totalAmount']); ?>"/>
@ -257,72 +208,29 @@
<a href="/customers/print-invoice/?customerId=<?= $_GET['customerId'] . '&invoiceId='. $_GET['invoiceId']; ?>" id="printBtn" class="btn text-white visually-" style="background-color: #374151;">Print Invoice</a>
</div>
</div>
</form>
</div>
<script>
function changeTenureField() {
const tenureAuto = document.getElementById('tenureAuto');
const tenureCustom = document.getElementById('tenureCustom');
if (tenureAuto.value === "0") {
tenureAuto.classList.add('visually-hidden');
tenureAuto.setAttribute('disabled', 'true');
tenureAuto.removeAttribute('name');
tenureCustom.classList.remove('visually-hidden');
tenureCustom.removeAttribute('disabled');
tenureCustom.setAttribute('name', 'tenure');
tenureCustom.focus();
}
}
function restoreDropdown(input) {
const tenureAuto = document.getElementById('tenureAuto');
if (input.value.trim() === "") {
tenureAuto.classList.remove('visually-hidden');
tenureAuto.removeAttribute('disabled');
tenureAuto.setAttribute('name', 'tenure');
tenureAuto.value = ""; // Reset dropdown selection
input.classList.add('visually-hidden');
input.setAttribute('disabled', 'true');
input.removeAttribute('name');
input.value = ""; // Clear input value
} else {
tenureAuto.value = "0"; // Ensure dropdown remains on "Custom" if input has a value
}
}
document.addEventListener("DOMContentLoaded", function () {
const quantityInput = document.getElementById("quantity");
const rateInput = document.getElementById("rate");
const taxSelect = document.getElementById("discount");
const taxAmountInput = document.getElementById("discountAmount");
const discountAmountInput = document.getElementById("discountAmount");
const totalAmountInput = document.getElementById("totalAmount");
function calculateTotal() {
const quantity = parseFloat(quantityInput.value) || 0;
const rate = parseFloat(rateInput.value) || 0;
const tax = parseFloat(taxSelect.value) || 0;
const discountAmount = parseFloat(discountAmountInput.value) || 0;
let subtotal = quantity * rate;
let taxAmount = (subtotal * tax) / 100;
let grandTotal = subtotal - taxAmount;
let grandTotal = subtotal - discountAmount;
taxAmountInput.value = taxAmount.toFixed(2); // Format Tax Amount
totalAmountInput.value = grandTotal.toFixed(2); // Format Total Amount
totalAmountInput.value = grandTotal.toFixed(2);
}
// Event listeners for real-time calculation
quantityInput.addEventListener("input", calculateTotal);
rateInput.addEventListener("input", calculateTotal);
taxSelect.addEventListener("change", calculateTotal);
discountAmountInput.addEventListener("input", calculateTotal);
});
</script>
<!-- cust_67c9925ff14f4834489101 -->
<!-- CB03252 -->
</script>

View File

@ -22,7 +22,6 @@
$description = $_POST['description'];
$quantity = $_POST['quantity'];
$rate = $_POST['rate'];
$discount = $_POST['discount'];
$discountAmount = $_POST['discountAmount'];
// EMI Calculation
@ -54,7 +53,7 @@
}
// Insert into invoice table
$stmt2 = $db->prepare("INSERT INTO invoice (customerId, invoiceId, customerName, address, frequency, invoiceDate, paymentMode, salesAgent, marketingAgent, tenure, item, description, qty, rate, discount, totalAmount, adminNote, discountAmount) VALUES (:customerId, :invoiceId, :customerName, :address, :frequency, :invoiceDate, :paymentMode, :salesAgent, :marketingAgent, :tenure, :item, :description, :qty, :rate, :discount, :totalAmount, :adminNote, :discountAmount)");
$stmt2 = $db->prepare("INSERT INTO invoice (customerId, invoiceId, customerName, address, frequency, invoiceDate, paymentMode, salesAgent, marketingAgent, tenure, item, description, qty, rate, totalAmount, adminNote, discountAmount) VALUES (:customerId, :invoiceId, :customerName, :address, :frequency, :invoiceDate, :paymentMode, :salesAgent, :marketingAgent, :tenure, :item, :description, :qty, :rate, :totalAmount, :adminNote, :discountAmount)");
$stmt2->bindParam(':customerId', $_GET['customerId']);
$stmt2->bindParam(':invoiceId', $invoiceId);
$stmt2->bindParam(':customerName', $customerName);
@ -69,7 +68,6 @@
$stmt2->bindParam(':description', $description);
$stmt2->bindParam(':qty', $quantity);
$stmt2->bindParam(':rate', $rate);
$stmt2->bindParam(':discount', $discount);
$stmt2->bindParam(':totalAmount', $totalAmount);
$stmt2->bindParam(':adminNote', $adminNote);
$stmt2->bindParam(':discountAmount', $discountAmount);
@ -111,7 +109,6 @@
$stmt = $db->query("SELECT invoiceId FROM invoice ORDER BY id DESC LIMIT 1");
$lastInvoicePrint = $stmt->fetch(PDO::FETCH_ASSOC);
// $invoiceIdPrint = "ASDQ-" . ($lastInvoice ? ($lastInvoice['id'] + 1) : '1');
} catch (PDOException $e) {
echo '<div class="alert alert-danger">Error: ' . $e->getMessage() . '</div>';
@ -214,7 +211,6 @@
<th class="p-2">Description</th>
<th class="p-2">Qty</th>
<th class="p-2">Rate</th>
<th class="p-2">Discount&nbsp;% </th>
<th class="p-2">Discount&nbsp;$</th>
<th class="p-2">Amount</th>
</tr>
@ -234,18 +230,7 @@
<input class="form-control w-100" name="rate" id="rate" />
</td>
<td>
<select onchange="changeDiscountField();" id="discountAuto" name="discount" class="form-control" required>
<option value="">-Select-</option>
<option value="5">5%</option>
<option value="10">10%</option>
<option value="12">12%</option>
<option value="18">18%</option>
<option value="0">Custom</option>
</select>
<input type="text" name="discount" id="discountCustom" class="form-control visually-hidden" placeholder="Enter custom discount" disabled onblur="restoreDiscounDropdown(this)" />
</td>
<td>
<input readonly class="form-control" name="discountAmount" id="discountAmount" />
<input class="form-control" name="discountAmount" id="discountAmount" />
</td>
<td>
<input readonly class="form-control" name="totalAmount" id="totalAmount" />
@ -269,8 +254,6 @@
const formattedDate = today.toISOString().split('T')[0];
document.getElementById('bookingDate').value = formattedDate;
function changeTenureField() {
const tenureAuto = document.getElementById('tenureAuto');
const tenureCustom = document.getElementById('tenureCustom');
@ -299,75 +282,27 @@
tenureAuto.value = "";
}
}
document.addEventListener("DOMContentLoaded", function () {
const quantityInput = document.getElementById("quantity");
const rateInput = document.getElementById("rate");
const discountSelect = document.getElementById("discountAuto");
const discountInput = document.getElementById("discountCustom");
const discountAmountInput = document.getElementById("discountAmount");
const totalAmountInput = document.getElementById("totalAmount");
function getDiscountValue() {
// Use the visible element's value (dropdown or input)
if (!discountSelect.disabled) {
return parseFloat(discountSelect.value) || 0;
} else {
return parseFloat(discountInput.value) || 0;
}
}
function calculateTotal() {
const quantity = parseFloat(quantityInput.value) || 0;
const rate = parseFloat(rateInput.value) || 0;
const discount = getDiscountValue();
const discountAmount = parseFloat(discountAmountInput.value) || 0;
let subtotal = quantity * rate;
let discountAmount = (subtotal * discount) / 100;
let grandTotal = subtotal - discountAmount;
discountAmountInput.value = discountAmount.toFixed(2);
totalAmountInput.value = grandTotal.toFixed(2);
}
// Event listeners for real-time calculation
quantityInput.addEventListener("input", calculateTotal);
rateInput.addEventListener("input", calculateTotal);
discountSelect.addEventListener("change", calculateTotal);
discountInput.addEventListener("input", calculateTotal);
discountAmountInput.addEventListener("input", calculateTotal);
});
function changeDiscountField() {
const discountAuto = document.getElementById('discountAuto');
const discountCustom = document.getElementById('discountCustom');
if (discountAuto.value === "0") { // "Custom" option selected
discountAuto.classList.add('visually-hidden');
discountAuto.removeAttribute('name');
discountAuto.setAttribute('disabled', 'true');
discountCustom.classList.remove('visually-hidden');
discountCustom.setAttribute('name', 'discount');
discountCustom.removeAttribute('disabled');
discountCustom.focus();
}
}
function restoreDiscounDropdown(input) {
const discountAuto = document.getElementById('discountAuto');
if (input.value.trim() === "") { // If input is empty, restore the dropdown
discountAuto.classList.remove('visually-hidden');
discountAuto.removeAttribute('disabled');
discountAuto.setAttribute('name', 'discount');
discountAuto.value = "";
input.classList.add('visually-hidden');
input.removeAttribute('name');
input.setAttribute('disabled', 'true');
}
}
</script>

View File

@ -19,8 +19,13 @@ if ($invoiceInfo['tenure'] > 1) {
$emiPlans = $stmt->fetchAll(PDO::FETCH_ASSOC);
}
?>
<div class="container my-5">
<div class="mt-2">
<div class="d-flex gap-1 justify-content-end invoices-button">
<button onclick="downloadPDF()" class="btn-print" style=""><img src="/assets/download.svg" alt=""> Download</button>
<button onclick="window.print()" class="btn-print" style=""><img src="/assets/print.svg" alt=""> Print</button>
</div>
</div>
<div class="container mx-auto ">
<div class="invoice-box" id="invoice-box">
<div class="d-flex justify-content-between" >
<img src="/assets/logo_dark.png" alt="" style="width: 150px; height: fit-content;" />
@ -54,7 +59,6 @@ if ($invoiceInfo['tenure'] > 1) {
<th>Description</th>
<th>Qty</th>
<th>Rate</th>
<th>Discount(%)</th>
<th>Discount</th>
<th>Total</th>
</tr>
@ -65,7 +69,6 @@ if ($invoiceInfo['tenure'] > 1) {
<td><?= $invoiceInfo['description'] ?></td>
<td><?= $invoiceInfo['qty'] ?></td>
<td><?= $invoiceInfo['rate'] ?></td>
<td><?= $invoiceInfo['discount'] ?>%</td>
<td>$<?= $invoiceInfo['discountAmount'] ?></td>
<td>$<?= number_format($invoiceInfo['totalAmount'], 2) ?></td>
</tr>
@ -135,11 +138,8 @@ if ($invoiceInfo['tenure'] > 1) {
<?php } ?>
<p class="text-muted mt-3"><strong>Admin Note:</strong> <?= $invoiceInfo['adminNote'] ?></p>
<p style="font-size: 12px;"><strong>Invoice Generate Date: </strong><span id="invoiceGenDate"></span></p>
<div class="d-flex gap-1">
<button onclick="downloadPDF()" class="btn text-white btn-print w-100" style="background-color: #374151;">Download Invoice</button>
<button onclick="window.print()" class="btn text-white btn-print w-100" style="background-color: #374151;">Print Invoice</button>
</div>
</div>
</div>
<script src="/assets/js/html2pdf.bundle.min.js"></script>
<script>
@ -148,9 +148,9 @@ if ($invoiceInfo['tenure'] > 1) {
function downloadPDF() {
const invoice = document.getElementById("invoice-box");
html2pdf(invoice, {
margin: 10,
margin: 0,
filename: 'invoice.pdf',
image: { type: 'jpeg', quality: 0.98 },
image: { type: 'jpeg', quality: 1 },
html2canvas: { scale: 2 },
jsPDF: { unit: 'mm', format: 'a4', orientation: 'portrait' }
});
@ -162,14 +162,29 @@ if ($invoiceInfo['tenure'] > 1) {
}
.invoice-box {
max-width: 800px;
margin: auto;
padding: 30px;
margin: 0 auto;
padding: 25px 30px;
/* border: 1px solid #ddd; */
background: #fff;
border-radius: 10px;
border-bottom-left-radius: 10px;
border-bottom-right-radius: 10px;
}
.invoices-button {
max-width: 800px;
margin: 0 auto;
/* padding: 30px 30px; */
/* border: 1px solid #ddd; */
background: #fff;
border-top-left-radius: 10px;
border-top-right-radius: 10px;
}
.text-blue { color: #007bff; }
.btn-print { margin-top: 20px; }
.btn-print {
margin: 8px 8px 0px 8px;
border: 1px solid #374151;
background: transparent;
border-radius: 6px;
}
@media print {
body * {

View File

@ -92,7 +92,7 @@ try {
<th>Installment</th>
<th>Amount</th>
<th>Date</th>
<th>Payment Status</th>
<th>Status</th>
<th>Outstanding</th>
</tr>
</thead>
@ -103,7 +103,7 @@ try {
<td><?= $emi['emiNumber']; ?></td>
<td>$<?= number_format($emi['emiAmount'], 2); ?></td>
<td><?= date('m/d/Y', strtotime($emi['emiDate'])); ?></td>
<td>
<td class="text-center">
<span id="status-<?= $emi['id']; ?>" class="badge <?= $emi['payStatus'] == 0 ? 'bg-danger' : 'bg-success'; ?>">
<?= $emi['payStatus'] == 0 ? 'Unpaid' : 'Paid'; ?>
</span>

View File

@ -19,8 +19,13 @@ if ($invoiceInfo['tenure'] > 1) {
$emiPlans = $stmt->fetchAll(PDO::FETCH_ASSOC);
}
?>
<div class="container my-5">
<div class="mt-2">
<div class="d-flex gap-1 justify-content-end invoices-button">
<button onclick="downloadPDF()" class="btn-print" style=""><img src="/assets/download.svg" alt=""> Download</button>
<button onclick="window.print()" class="btn-print" style=""><img src="/assets/print.svg" alt=""> Print</button>
</div>
</div>
<div class="container mx-auto ">
<div class="invoice-box" id="invoice-box">
<div class="d-flex justify-content-between" >
<img src="/assets/logo_dark.png" alt="" style="width: 150px; height: fit-content;" />
@ -54,7 +59,6 @@ if ($invoiceInfo['tenure'] > 1) {
<th>Description</th>
<th>Qty</th>
<th>Rate</th>
<th>Discount(%)</th>
<th>Discount</th>
<th>Total</th>
</tr>
@ -65,7 +69,6 @@ if ($invoiceInfo['tenure'] > 1) {
<td><?= $invoiceInfo['description'] ?></td>
<td><?= $invoiceInfo['qty'] ?></td>
<td><?= $invoiceInfo['rate'] ?></td>
<td><?= $invoiceInfo['discount'] ?>%</td>
<td>$<?= $invoiceInfo['discountAmount'] ?></td>
<td>$<?= number_format($invoiceInfo['totalAmount'], 2) ?></td>
</tr>
@ -135,11 +138,8 @@ if ($invoiceInfo['tenure'] > 1) {
<?php } ?>
<p class="text-muted mt-3"><strong>Admin Note:</strong> <?= $invoiceInfo['adminNote'] ?></p>
<p style="font-size: 12px;"><strong>Invoice Generate Date: </strong><span id="invoiceGenDate"></span></p>
<div class="d-flex gap-1">
<button onclick="downloadPDF()" class="btn text-white btn-print w-100" style="background-color: #374151;">Download Invoice</button>
<button onclick="window.print()" class="btn text-white btn-print w-100" style="background-color: #374151;">Print Invoice</button>
</div>
</div>
</div>
<script src="/assets/js/html2pdf.bundle.min.js"></script>
<script>
@ -148,9 +148,9 @@ if ($invoiceInfo['tenure'] > 1) {
function downloadPDF() {
const invoice = document.getElementById("invoice-box");
html2pdf(invoice, {
margin: 10,
margin: 0,
filename: 'invoice.pdf',
image: { type: 'jpeg', quality: 0.98 },
image: { type: 'jpeg', quality: 1 },
html2canvas: { scale: 2 },
jsPDF: { unit: 'mm', format: 'a4', orientation: 'portrait' }
});
@ -162,14 +162,29 @@ if ($invoiceInfo['tenure'] > 1) {
}
.invoice-box {
max-width: 800px;
margin: auto;
padding: 30px;
margin: 0 auto;
padding: 25px 30px;
/* border: 1px solid #ddd; */
background: #fff;
border-radius: 10px;
border-bottom-left-radius: 10px;
border-bottom-right-radius: 10px;
}
.invoices-button {
max-width: 800px;
margin: 0 auto;
/* padding: 30px 30px; */
/* border: 1px solid #ddd; */
background: #fff;
border-top-left-radius: 10px;
border-top-right-radius: 10px;
}
.text-blue { color: #007bff; }
.btn-print { margin-top: 20px; }
.btn-print {
margin: 8px 8px 0px 8px;
border: 1px solid #374151;
background: transparent;
border-radius: 6px;
}
@media print {
body * {