diff --git a/.hta_slug/_nav.php b/.hta_slug/_nav.php
index b002639..adbf370 100644
--- a/.hta_slug/_nav.php
+++ b/.hta_slug/_nav.php
@@ -7,7 +7,7 @@
setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
$totalAmount = $_POST['totalAmount'];
$tenure = $_POST['tenure'];
- $firstEmiDate = $_POST['firstEmiDate'];
- $totalAmount = $_POST['totalAmount'];
$frequency = $_POST['frequency'];
$bookingDate = $_POST['bookingDate'];
$paymentMode = $_POST['paymentMode'];
+ $salesAgent = $_POST['salesAgent'];
+ $adminNote = $_POST['adminNote'];
+ $invoiceId = $_POST['invoiceId'];
+ $customerName = $_POST['customerName'];
+ $customerAddress = $_POST['customerAddress'];
+ $marketingAgent = $_POST['marketingAgent'];
+ $item = $_POST['item'];
+ $description = $_POST['description'];
+ $quantity = $_POST['quantity'];
+ $rate = $_POST['rate'];
+ $tax = $_POST['tax'];
+ $taxAmount = $_POST['taxAmount'];
+
+
+
// EMI Calculation
- $emiAmount = round($totalAmount / $tenure, 2);
- $outstandingAmount = $totalAmount;
- $emiDate = new DateTime($firstEmiDate); // Set initial date
+ $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, paymentMode, salesAgent) VALUES (:customerId, :emiNumber, :emiAmount, :emiDate, :totalAmount, :outstanding, :tenure, :frequency, bookingDate, :paymentMode, :salesAgent)");
-
- 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(':paymentMode', $paymentMode);
- $stmt->bindParam(':salesAgent', $salesAgent);
- $stmt->execute();
-
- // Move to the next month's EMI date
- if($frequency === 'Weekly'){
- $emiDate->modify('+1 week');
- } elseif($frequency === 'Monthly'){
- $emiDate->modify('+1 month');
- }
+ $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("INSERT INTO invoice (customerId, invoiceId, customerName, address, frequency, invoiceDate, paymentMode, salesAgent, marketingAgent, tenure, item, description, qty, rate, tax, totalAmount, adminNote, taxAmount) VALUES (:customerId, :invoiceId, :customerName, :address, :frequency, :invoiceDate, :paymentMode, :salesAgent, :marketingAgent, :tenure, :item, :description, :qty, :rate, :tax, :totalAmount, :adminNote, :taxAmount)");
+ $stmt2->bindParam(':customerId', $_GET['customerId']);
+ $stmt2->bindParam(':invoiceId', $invoiceId);
+ $stmt2->bindParam(':customerName', $customerName);
+ $stmt2->bindParam(':address', $customerAddress);
+ $stmt2->bindParam(':frequency', $frequency);
+ $stmt2->bindParam(':invoiceDate', $bookingDate);
+ $stmt2->bindParam(':paymentMode', $paymentMode);
+ $stmt2->bindParam(':salesAgent', $salesAgent);
+ $stmt2->bindParam(':marketingAgent', $marketingAgent);
+ $stmt2->bindParam(':tenure', $tenure);
+ $stmt2->bindParam(':item', $item);
+ $stmt2->bindParam(':description', $description);
+ $stmt2->bindParam(':qty', $quantity);
+ $stmt2->bindParam(':rate', $rate);
+ $stmt2->bindParam(':tax', $tax);
+ $stmt2->bindParam(':totalAmount', $totalAmount);
+ $stmt2->bindParam(':adminNote', $adminNote);
+ $stmt2->bindParam(':taxAmount', $taxAmount);
+ $stmt2->execute();
+
echo '
New EMI Plan Saved Successfully!
';
+ echo '';
} catch (PDOException $e) {
echo '
Error: ' . $e->getMessage() . '
';
}
}
-
$customer = null;
if (!empty($_GET['customerId'])) {
try {
@@ -67,6 +104,13 @@
$customerAddress = $stmt->fetch(PDO::FETCH_ASSOC);
}
+ $stmt = $db->query("SELECT id FROM invoice ORDER BY id DESC LIMIT 1");
+ $lastInvoice = $stmt->fetch(PDO::FETCH_ASSOC);
+ $invoiceId = "ASDQ-" . ($lastInvoice ? ($lastInvoice['id'] + 1) : '1');
+
+ $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 '
Error: ' . $e->getMessage() . '
';
@@ -74,29 +118,24 @@
}
?>
+
-
Create Invoice
-
-
-
Mobile: = htmlspecialchars($customer['mobile']) ?>
-
-
Customer not found.
-
-
+
Create New Invoice
+
-
Save EMI
+
+
+
+
\ No newline at end of file
diff --git a/customers/.hta_slug/list.php b/customers/.hta_slug/list.php
index 4603712..b4e0862 100644
--- a/customers/.hta_slug/list.php
+++ b/customers/.hta_slug/list.php
@@ -11,39 +11,86 @@