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']; // EMI Calculation $emiAmount = round($totalAmount / $tenure, 2); $outstandingAmount = $totalAmount; $emiDate = new DateTime($firstEmiDate); // Set initial date $stmt = $db->prepare("INSERT INTO emi (customerId, emiNumber, emiAmount, emiDate, totalAmount, outstanding, tenure, frequency, bookingDate, paymentMode) VALUES (:customerId, :emiNumber, :emiAmount, :emiDate, :totalAmount, :outstanding, :tenure, :frequency, bookingDate, :paymentMode)"); 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->execute(); // Move to the next month's EMI date if($frequency === 'Weekly'){ $emiDate->modify('+1 week'); } elseif($frequency === 'Monthly'){ $emiDate->modify('+1 month'); } } echo '
New EMI Plan Saved Successfully!
'; } catch (PDOException $e) { echo '
Error: ' . $e->getMessage() . '
'; } } $customer = 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 customers WHERE customerId = :customerId"); $stmt->bindParam(':customerId', $_GET['customerId']); if ($stmt->execute()) { $customer = $stmt->fetch(PDO::FETCH_ASSOC); } $stmt = $db->prepare("SELECT * FROM address WHERE customerId = :customerId"); $stmt->bindParam(':customerId', $_GET['customerId']); if ($stmt->execute()) { $customerAddress = $stmt->fetch(PDO::FETCH_ASSOC); } } catch (PDOException $e) { echo '
Error: ' . $e->getMessage() . '
'; } } ?>

Create Invoice

Mobile:

Customer not found.