update agent dashboard, agent target assign,

This commit is contained in:
2025-09-26 14:19:31 +00:00
parent 32562554ad
commit ab034aeb72
5 changed files with 144 additions and 546 deletions

View File

@@ -146,6 +146,11 @@
$conn = new mysqli($GLOBALS['host'], $GLOBALS['user'], $GLOBALS['pass'], $GLOBALS['db']);
if ($conn->connect_error) { die("Connection failed: " . $conn->connect_error); }
$totalLoanEMIAmount = 0;
$totalDeuEMITillDate = 0;
$totalRecurringEMIAmount = 0;
$totalDeuInstallTillDate = 0;
$agent_id = $_SESSION['user_id'];
$types = ['Loan', 'Recurring'];
@@ -197,9 +202,13 @@ foreach($types as $type){
$paidInstallment = number_format($paidInstallment, 2, '.', '');
$deuEMITillDate = countCycles($row['AA_ACTYPE'], $row['AA_DATE'], $row['AA_NO_OF_PAYMENT'], $row['AA_TYPE']) - $paidInstallment;
// $deuEMITillDate = abs($deuEMITillDate);
$deuEMITillDate = number_format($deuEMITillDate, 2, '.', '');
if($deuEMITillDate > 0){
// echo $deuEMITillDate;
$totalDeuEMITillDate += $deuEMITillDate; // এখানে যোগ হচ্ছে
$totalLoanEMIAmount += $row['AA_INSTALLMENT'];
}
}elseif($row['AA_TYPE'] === 'Recurring'){
$paidInstallment = $row['AA_BAL'] / $row['AA_INSTALLMENT'];
$paidInstallment = number_format($paidInstallment, 2, '.', '');
@@ -208,6 +217,13 @@ foreach($types as $type){
// $deuEMITillDate = abs($deuEMITillDate);
$deuEMITillDate = number_format($deuEMITillDate, 2, '.', '');
if($deuEMITillDate > 0){
// echo $deuEMITillDate;
$totalDeuInstallTillDate += $deuEMITillDate; // এখানে যোগ হচ্ছে
$totalRecurringEMIAmount += $row['AA_INSTALLMENT'];
}
}
// HTML table row
if($deuEMITillDate > 0){
@@ -262,6 +278,12 @@ foreach($types as $type){
}
}
$conn->close();
$grandTotal['totalNumberOfLoanEMI'] = $totalDeuEMITillDate;
$grandTotal['totalNumberOfRecurringEMI'] = $totalDeuInstallTillDate;
$grandTotal['totalLoanEMIAmount'] = $totalLoanEMIAmount;
$grandTotal['totalRecurringEMIAmount'] = $totalRecurringEMIAmount;
// echo "<br>Total Due EMI Till Date (Loan): ".$totalDeuEMITillDate;
// echo "<br>Total Due Installment Till Date (Recurring): ".$totalDeuInstallTillDate;
?>
</table>
@@ -352,12 +374,21 @@ document.addEventListener('DOMContentLoaded', function() {
y = doc.lastAutoTable.finalY + 20;
}
// Grand Total
doc.setFont(undefined,'bold');
doc.text(`Grand Total Accounts: ${grandTotal.accounts}`,40,y);
doc.text(`Grand Total Paid Installments: ${grandTotal.paidInstallments}`,40,y+15);
doc.text(`Grand Total Due Installments: ${grandTotal.dueInstallments}`,40,y+30);
doc.text(`Grand Total Due Amount: ${grandTotal.dueAmount.toLocaleString('en-IN',{minimumFractionDigits:2, maximumFractionDigits:2})}`,40,y+45);
// Grand Total totalNumberOfLoanEMI totalNumberOfRecurringEMI totalLoanEMIAmount totalRecurringEMIAmount
doc.setFont(undefined, 'bold');
let lineHeight = 12; // fixed gap between lines
let currentY = y-8;
doc.text(`Total Number of Loan EMI: ${grandTotal.totalNumberOfLoanEMI}`, 20, currentY);
currentY += lineHeight;
doc.text(`Total Number of Recurring Installment: ${grandTotal.totalNumberOfRecurringEMI}`, 20, currentY);
currentY += lineHeight;
doc.text(`Grand Total Loan EMI Amount: ${grandTotal.totalLoanEMIAmount.toLocaleString('en-IN',{minimumFractionDigits:2, maximumFractionDigits:2})}`, 20, currentY);
currentY += lineHeight;
doc.text(`Grand Total Recurring EMI Amount: ${grandTotal.totalRecurringEMIAmount.toLocaleString('en-IN',{minimumFractionDigits:2, maximumFractionDigits:2})}`, 20, currentY);
// Footer with page numbers
const pageCount = doc.internal.getNumberOfPages();