diff --git a/customers/.hta_slug/billing-details.php b/customers/.hta_slug/billing-details.php index c3aa1ca..f00462f 100644 --- a/customers/.hta_slug/billing-details.php +++ b/customers/.hta_slug/billing-details.php @@ -2,18 +2,39 @@ require('../.hta_config/conf.php'); $db = new PDO("mysql:host=$mariaServer;dbname=$mariaDb", $mariaUser, $mariaPass); $db->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION); + + $customerId = $_GET['customerId']; + $invoiceId = $_GET['invoiceId']; + + if($_SERVER['REQUEST_METHOD'] === 'POST' && isset($_POST['additional-payment'])){ + $adPaymentAmount = floatval($_POST['adPaymentAmount']); + $adPaymentDate = $_POST['adPaymentDate']; + $adPaymentSource = $_POST['adPaymentSource']; + $adPaymentTran = $_POST['adPaymentTran']; + $adPaymentRemarks = $_POST['adPaymentRemarks']; + // Insert additional payment record + 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', $customerId); + $stmt3->bindParam(':invoiceId', $invoiceId); + $stmt3->bindParam(':adPaymentAmount', $adPaymentAmount); + $stmt3->bindParam(':adPaymentDate', $adPaymentDate); + $stmt3->bindParam(':adPaymentSource', $adPaymentSource); + $stmt3->bindParam(':adPaymentTran', $adPaymentTran); + $stmt3->bindParam(':adPaymentRemarks', $adPaymentRemarks); + if ($stmt3->execute()) { + echo '
Additional Payment ' . htmlspecialchars($_POST['adPaymentAmount']) . ' applied successfully.
'; + } else { + echo '
Failed to record the additional payment.
'; + } + }catch(PDOException $e){ + echo '
Error: ' . $e->getMessage() . '
'; + } + } if ($_SERVER['REQUEST_METHOD'] === 'POST') { + $adPaymentAmount = floatval($_POST['adPaymentAmount']); try { - // Get customer EMI details - $customerId = $_GET['customerId']; - $invoiceId = $_GET['invoiceId']; - $adPaymentAmount = floatval($_POST['adPaymentAmount']); - $adPaymentDate = $_POST['adPaymentDate']; - $adPaymentSource = $_POST['adPaymentSource']; - $adPaymentTran = $_POST['adPaymentTran']; - $adPaymentRemarks = $_POST['adPaymentRemarks']; - // Fetch EMIs of the customer (Assuming we have emiNumber in ascending order) $stmt = $db->prepare("SELECT * FROM emi WHERE customerId = :customerId AND invoiceId = :invoiceId ORDER BY emiNumber DESC"); $stmt->bindParam(':customerId', $customerId); @@ -52,20 +73,6 @@ $updateStmt->execute(); } - // Insert additional payment record - $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', $customerId); - $stmt3->bindParam(':invoiceId', $invoiceId); - $stmt3->bindParam(':adPaymentAmount', $adPaymentAmount); - $stmt3->bindParam(':adPaymentDate', $adPaymentDate); - $stmt3->bindParam(':adPaymentSource', $adPaymentSource); - $stmt3->bindParam(':adPaymentTran', $adPaymentTran); - $stmt3->bindParam(':adPaymentRemarks', $adPaymentRemarks); - if ($stmt3->execute()) { - echo '
Additional Payment ' . htmlspecialchars($_POST['adPaymentAmount']) . ' applied successfully.
'; - } else { - echo '
Failed to record the additional payment.
'; - } } catch (PDOException $e) { echo '
Error: ' . $e->getMessage() . '
'; } @@ -157,12 +164,12 @@ $frequency = $frequency !== null ? $frequency : 0; ?>
-

Installment Details

+

Installment Details


Customer Name:

Mobile Number:

-

Booking Date:

+

Installment Start Date:

Invoice Id:

Email:

@@ -216,31 +223,27 @@ - 0 ) { ?> -

Additional Payment Details

- - - - - - - +

Additional Payment Details

+
AmountPayment DateTransaction IdRemarks
+ + + + + + + + + + + + + + + - - - - - - - - - - - -
AmountPayment DateTransaction IdRemarks
$
$
- - + + +