From e97d30ce72d5ae1fd705e65784a20daaa85c7412 Mon Sep 17 00:00:00 2001 From: Suvodip Date: Fri, 7 Mar 2025 17:49:48 +0530 Subject: [PATCH] s22 --- customers/.hta_slug/list.php | 77 +++++++++++++++++++++--------------- 1 file changed, 45 insertions(+), 32 deletions(-) diff --git a/customers/.hta_slug/list.php b/customers/.hta_slug/list.php index 7da7637..93ac870 100644 --- a/customers/.hta_slug/list.php +++ b/customers/.hta_slug/list.php @@ -1,11 +1,11 @@ -
-

Customer List

+
+

Customer List


- - +
+ @@ -14,7 +14,7 @@ - + @@ -30,6 +30,11 @@ $stmt->execute(); $content = $stmt->fetchAll(PDO::FETCH_ASSOC); + // Fetch EMI data + $stmt = $db->prepare("SELECT * FROM emi ORDER BY invoiceId ASC"); + $stmt->execute(); + $emiContent = $stmt->fetchAll(PDO::FETCH_ASSOC); + // Fetch invoice data $stmt2 = $db->prepare("SELECT * FROM invoice"); $stmt2->execute(); @@ -46,25 +51,42 @@ // If there are matching invoices, loop through them if (!empty($matchingInvoices)) { foreach ($matchingInvoices as $invoice) { - ?> + // Find corresponding EMI records for this invoice + $matchingEMIs = array_filter($emiContent, function ($emi) use ($invoice) { + return $emi['invoiceId'] === $invoice['invoiceId']; + }); + + // If EMI exists, use its data; otherwise, display empty fields + // $emi = reset($matchingEMIs) ?: []; + $matchingEmis = array_filter($emiContent, function ($emi) use ($invoice) { + return $emi['invoiceId'] === $invoice['invoiceId']; + }); + + if (!empty($matchingEmis)) { + $emi = reset($matchingEmis); // Get the first matching EMI record safely + } else { + $emi = []; + } + + ?> - - - - - - - - - + + + + + + + + - - - + '; + echo ''; } ?> - -
Sl No NameNumber of Installments Monthly Payment Date Monthly Payment AmountTotoal AmountTotal Amount Action
$$ - - New Invoice - Edit Invoice - - - Payment + + + + modify('+'.$emi['tenure']-'1'.'months')->format('d-m-Y') : 'N/A'; ?>$$ + New Invoice + Edit Invoice + Payment
No invoice availableNo EMI or Invoice Data - - Create Invoice - - Additional Payment -
Error: ' . $e->getMessage() . '
Error: ' . $e->getMessage() . '