-
Total Demand EMI Amount: ₹
+
+
+
Pending EMIs ()
+
+
+
+
+
+
+
+
+
+ Customer Name |
+ EMI Amount |
+ EMI Date |
+ Pay Status |
+ Outstanding |
+
+
+
+
+
+
+ |
+ $ |
+ |
+
+
+ Pending
+
+ Paid
+
+ |
+ $ |
+
+
+
+
+ No pending EMIs in this period |
+
+
+
+
+
+
+
Total Demand EMI Amount: $
+
diff --git a/admin/index.php b/admin/index.php
index b39e111..7d5cf99 100644
--- a/admin/index.php
+++ b/admin/index.php
@@ -1,4 +1,5 @@
+
+setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
+
+ if($_SERVER['REQUEST_METHOD'] === 'POST'){
+
+ try{
+ $stmt3 = $db->prepare("INSERT INTO emi (customerId, invoiceId, adPaymentAmount, adPaymentDate, adPaymentSource, adPaymentTran, adPaymentRemarks, payStatus) VALUES (:customerId, :invoiceId, :adPaymentAmount, :adPaymentDate, :adPaymentSource, :adPaymentTran, :adPaymentRemarks, 1)");
+ $stmt3->bindParam(':customerId', $_GET['customerId']);
+ $stmt3->bindParam(':invoiceId', $_GET['invoiceId']);
+ $stmt3->bindParam(':adPaymentAmount', $_POST['adPaymentAmount']);
+ $stmt3->bindParam(':adPaymentDate', $_POST['adPaymentDate']);
+ $stmt3->bindParam(':adPaymentSource', $_POST['adPaymentSource']);
+ $stmt3->bindParam(':adPaymentTran', $_POST['adPaymentTran']);
+ $stmt3->bindParam(':adPaymentRemarks', $_POST['adPaymentRemarks']);
+ if($stmt3->execute()){
+ echo '
Additional Payment ' . htmlspecialchars($_POST['adPaymentAmount']) . ' Paid Successfully.
';
+ }else{
+ echo '
Additional Payment ' . htmlspecialchars($_POST['adPaymentAmount']) . ' Payment Faild.
';
+ }
+ } catch(PDOException $e){
+ echo '
Error: ' . $e->getMessage() . '
';
+ }
+
+ }
+ try {
+ $stmt = $db->prepare("SELECT * FROM invoice WHERE customerId = :customerId");
+ $stmt->bindParam(':customerId', $_GET['customerId']);
+ $stmt->execute();
+ $invoiceData = $stmt->fetch(PDO::FETCH_ASSOC);
+
+ $stmt2 = $db->prepare("SELECT * FROM emi WHERE customerId = :customerId");
+ $stmt2->bindParam(':customerId', $_GET['customerId']);
+ $stmt2->execute();
+ $emiData = $stmt2->fetch(PDO::FETCH_ASSOC);
+
+ // var_dump($emiData);
+ } catch (PDOException $e) {
+ echo '
Error: ' . $e->getMessage() . '
';
+ }
+?>
+
+
+
\ No newline at end of file
diff --git a/customers/.hta_slug/billing-details.php b/customers/.hta_slug/billing-details.php
index fb48388..1176940 100644
--- a/customers/.hta_slug/billing-details.php
+++ b/customers/.hta_slug/billing-details.php
@@ -1,108 +1,226 @@
setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
-
- if ($_SERVER['REQUEST_METHOD'] === 'POST' && isset($_POST['emiId'], $_POST['payStatus'])) {
- header('Content-Type: application/json');
- ob_end_clean(); // Clears any accidental HTML output
- try {
- $stmt = $db->prepare("UPDATE emi SET payStatus = :payStatus WHERE customerId = :customerId AND id = :emiId");
- $stmt->bindParam(':customerId', $_GET['customerId']);
- $stmt->bindParam(':payStatus', $_POST['payStatus'], PDO::PARAM_INT);
- $stmt->bindParam(':emiId', $_POST['emiId'], PDO::PARAM_INT);
- $stmt->execute();
- echo json_encode(['status' => 'success']);
- } catch (PDOException $e) {
- echo json_encode(['status' => 'error', 'message' => $e->getMessage()]);
+
+ if($_SERVER['REQUEST_METHOD'] === 'POST'){
+ try{
+ $stmt3 = $db->prepare("INSERT INTO emi (customerId, invoiceId, adPaymentAmount, adPaymentDate, adPaymentSource, adPaymentTran, adPaymentRemarks, payStatus) VALUES (:customerId, :invoiceId, :adPaymentAmount, :adPaymentDate, :adPaymentSource, :adPaymentTran, :adPaymentRemarks, 1)");
+ $stmt3->bindParam(':customerId', $_GET['customerId']);
+ $stmt3->bindParam(':invoiceId', $_GET['invoiceId']);
+ $stmt3->bindParam(':adPaymentAmount', $_POST['adPaymentAmount']);
+ $stmt3->bindParam(':adPaymentDate', $_POST['adPaymentDate']);
+ $stmt3->bindParam(':adPaymentSource', $_POST['adPaymentSource']);
+ $stmt3->bindParam(':adPaymentTran', $_POST['adPaymentTran']);
+ $stmt3->bindParam(':adPaymentRemarks', $_POST['adPaymentRemarks']);
+ if($stmt3->execute()){
+ echo '
Additional Payment ' . htmlspecialchars($_POST['adPaymentAmount']) . ' Paid Successfully.
';
+ }else{
+ echo '
Additional Payment ' . htmlspecialchars($_POST['adPaymentAmount']) . ' Payment Faild.
';
+ }
+ } catch(PDOException $e){
+ echo '
Error: ' . $e->getMessage() . '
';
+ }
}
+ try {
+ $stmt = $db->prepare("SELECT * FROM invoice WHERE customerId = :customerId");
+ $stmt->bindParam(':customerId', $_GET['customerId']);
+ $stmt->execute();
+ $invoiceData = $stmt->fetch(PDO::FETCH_ASSOC);
- exit;
- }
+ $stmt2 = $db->prepare("SELECT * FROM emi WHERE customerId = :customerId");
+ $stmt2->bindParam(':customerId', $_GET['customerId']);
+ $stmt2->execute();
+ $emiData = $stmt2->fetch(PDO::FETCH_ASSOC);
- // Fetch EMI data
- $stmt = $db->prepare("SELECT * FROM emi WHERE customerId = :customerId AND invoiceId = :invoiceId ORDER BY emiDate ASC");
- $stmt->bindParam(':customerId', $_GET['customerId']);
- $stmt->bindParam(':invoiceId', $_GET['invoiceId']);
- $stmt->execute();
- $emiPlans = $stmt->fetchAll(PDO::FETCH_ASSOC);
- // var_dump($emiPlans);
+ // var_dump($emiData);
+ } catch (PDOException $e) {
+ echo '
Error: ' . $e->getMessage() . '
';
+ }
+
+ if ($_SERVER['REQUEST_METHOD'] === 'POST' && isset($_POST['emiId'], $_POST['payStatus'])) {
+ header('Content-Type: application/json');
+ ob_end_clean(); // Clears any accidental HTML output
+ try {
+ $stmt = $db->prepare("UPDATE emi SET payStatus = :payStatus WHERE customerId = :customerId AND id = :emiId");
+ $stmt->bindParam(':customerId', $_GET['customerId']);
+ $stmt->bindParam(':payStatus', $_POST['payStatus'], PDO::PARAM_INT);
+ $stmt->bindParam(':emiId', $_POST['emiId'], PDO::PARAM_INT);
+ $stmt->execute();
+ echo json_encode(['status' => 'success']);
+ } catch (PDOException $e) {
+ echo json_encode(['status' => 'error', 'message' => $e->getMessage()]);
+ }
+ }
+ try {
+ // Fetch EMI data
+ $stmt = $db->prepare("SELECT * FROM emi WHERE customerId = :customerId AND invoiceId = :invoiceId ORDER BY emiDate ASC");
+ $stmt->bindParam(':customerId', $_GET['customerId']);
+ $stmt->bindParam(':invoiceId', $_GET['invoiceId']);
+ $stmt->execute();
+ $emiPlans = $stmt->fetchAll(PDO::FETCH_ASSOC);
+ // var_dump($emiPlans);
- $stmt = $db->prepare("SELECT * FROM customers WHERE customerId = :customerId");
- $stmt->bindParam(':customerId', $_GET['customerId']);
- $stmt->execute();
- $customer = $stmt->fetch(PDO::FETCH_ASSOC);
- // var_dump($customer);
-
-} catch (PDOException $e) {
- die('
Error: ' . $e->getMessage() . '
');
-}
+ $stmt = $db->prepare("SELECT * FROM customers WHERE customerId = :customerId");
+ $stmt->bindParam(':customerId', $_GET['customerId']);
+ $stmt->execute();
+ $customer = $stmt->fetch(PDO::FETCH_ASSOC);
+ // var_dump($customer);
+
+ } catch (PDOException $e) {
+ die('
Error: ' . $e->getMessage() . '
');
+ }
+
+ $currentOutstanding = 0;
+ $totalAmount = 0;
+ $bookingDate = null;
+ $currentOutstanding = 0;
+ $totalAmount = 0;
+ $bookingDate = null;
+ $tenure = null;
+ $frequency = null;
+
+ foreach ($emiPlans as $emi) {
+ $totalAmount = $emi['totalAmount'];
+ if ($bookingDate === null && !empty($emi['bookingDate'])) {
+ $bookingDate = $emi['bookingDate'];
+ }
+ if ($emi['payStatus'] == 0) {
+ $currentOutstanding += $emi['emiAmount'];
+ }
+ if ($tenure === null && isset($emi['tenure'])) {
+ $tenure = $emi['tenure'];
+ }
+ if ($frequency === null && isset($emi['frequency'])) {
+ $frequency = $emi['frequency'];
+ }
+ }
+ $currentOutstanding = round($currentOutstanding);
+ $tenure = $tenure !== null ? $tenure : 0;
+ $frequency = $frequency !== null ? $frequency : 0;
?>
-
EMI Details
+
EMI Details
Customer Name:
Mobile Number:
-
EMI Booking Date:
-
EMI Booking Date:
+
EMI Booking Date:
+
Invoice Id:
-
-
Total Amount:
-
Outstanding:
-
Tenure:
-
Frequency:
+
Total Amount: $
+
Outstanding: $
+
Tenure:
+
Frequency:
+
-
-
-
-
- Number of EMI |
- EMI Amount |
- EMI Date |
- Payment Status |
- Outstanding |
- Action |
-
-
-
-
-
- = $emi['emiNumber']; ?> |
- ₹= number_format($emi['emiAmount'], 2); ?> |
- = date('d-m-Y', strtotime($emi['emiDate'])); ?> |
-
-
- = $emi['payStatus'] == 0 ? 'Unpaid' : 'Paid'; ?>
-
- |
- ₹= number_format($emi['outstanding'], 2); ?> |
-
-
- |
+
+
+
+
+
+ Number of EMI |
+ EMI Amount |
+ EMI Date |
+ Payment Status |
+ Outstanding |
+ Action |
-
-
-
+
+
+
+
+ = $emi['emiNumber']; ?> |
+ $= number_format($emi['emiAmount'], 2); ?> |
+ = date('d-m-Y', strtotime($emi['emiDate'])); ?> |
+
+
+ = $emi['payStatus'] == 0 ? 'Unpaid' : 'Paid'; ?>
+
+ |
+ $= number_format($emi['outstanding'], 2); ?> |
+
+
+ |
+
+
+
+
+
+
Additional Payment Details
+
+
+
+ Amount |
+ Payment Date |
+ Transaction Id |
+ Payment Status |
+
+
+
+
+
+ $= $emi['adPaymentAmount']; ?> |
+ = $emi['adPaymentDate']; ?> |
+ = $emi['adPaymentTran']; ?> |
+
+
+ = $emi['payStatus'] == 0 ? 'Unpaid' : 'Paid'; ?>
+
+ |
+
+
+
+
+
+
+
+
+
Error: ' . $e->getMessage() . '
';
+ }
+ }
+ $invoiceData = null;
+ if (!empty($_GET['customerId'])) {
+ try {
+ $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->bindParam(':customerId', $_GET['customerId']);
+ $stmt->execute();
+ $invoiceData = $stmt->fetch(PDO::FETCH_ASSOC);
+ $invoiceDate = date('Y-m-d', strtotime($invoiceData['invoiceDate']));
+ } catch (PDOException $e) {
+ echo '
Error: ' . $e->getMessage() . '
+
\ No newline at end of file
diff --git a/customers/.hta_slug/generate-invoice.php b/customers/.hta_slug/generate-invoice.php
index a6bdda4..b9abbf8 100644
--- a/customers/.hta_slug/generate-invoice.php
+++ b/customers/.hta_slug/generate-invoice.php
@@ -105,9 +105,9 @@
$customerAddress = $stmt->fetch(PDO::FETCH_ASSOC);
}
- $stmt = $db->query("SELECT id FROM invoice ORDER BY id DESC LIMIT 1");
+ $stmt = $db->query("SELECT id FROM invoice WHERE DATE(invoiceDate) = CURDATE() ORDER BY id DESC LIMIT 1");
$lastInvoice = $stmt->fetch(PDO::FETCH_ASSOC);
- $invoiceId = "ASDQ-" . ($lastInvoice ? ($lastInvoice['id'] + 1) : '1');
+ $invoiceId = "CB" . date('my') . ($lastInvoice ? ($lastInvoice['id'] + 1) : '1');
$stmt = $db->query("SELECT invoiceId FROM invoice ORDER BY id DESC LIMIT 1");
$lastInvoicePrint = $stmt->fetch(PDO::FETCH_ASSOC);
@@ -136,7 +136,7 @@