work on deemand sheet
This commit is contained in:
@@ -1,4 +1,4 @@
|
||||
<div class="container">
|
||||
<div class="">
|
||||
<div class="text-right mb-3" style="margin-bottom: 15px;">
|
||||
<button id="downloadPdf" class="btn btn-primary">Download Demand Sheet</button>
|
||||
</div>
|
||||
@@ -10,16 +10,80 @@
|
||||
<th>AC No</th>
|
||||
<th>Name</th>
|
||||
<th>Mobile</th>
|
||||
<th>Account Creation Date</th>
|
||||
<th>Account Create Date</th>
|
||||
<th>Maturity Value</th>
|
||||
<th>Balance</th>
|
||||
<th>No Of Installment</th>
|
||||
<th>No Of Paid Installment</th>
|
||||
<th>Installment Amount</th>
|
||||
<th>Total EMI</th>
|
||||
<th>Total Paid EMI</th>
|
||||
<th>Deu EMI Till Date</th>
|
||||
<th>EMI Amount</th>
|
||||
<th>Total Due Amount</th>
|
||||
|
||||
</tr>
|
||||
|
||||
<?php
|
||||
function countCycles($cycle, $createDate, $totalInstallment) {
|
||||
$today = new DateTime();
|
||||
$startDate = new DateTime($createDate);
|
||||
|
||||
$cycle = strtoupper(trim($cycle));
|
||||
|
||||
if ($cycle === "D") {
|
||||
// দৈনিক চক্র: পরের দিন থেকে শুরু
|
||||
$firstPaymentDate = (clone $startDate)->modify('+1 day');
|
||||
|
||||
if ($firstPaymentDate > $today) {
|
||||
$count = 0;
|
||||
} else {
|
||||
$diff = $firstPaymentDate->diff($today);
|
||||
$count = $diff->days + 1; // +1 because diff->days doesn't include start day
|
||||
}
|
||||
} elseif ($cycle === "W") {
|
||||
// সাপ্তাহিক চক্র: ৭ দিন পরে প্রথম EMI
|
||||
$firstPaymentDate = (clone $startDate)->modify('+7 days');
|
||||
|
||||
if ($firstPaymentDate > $today) {
|
||||
$count = 0;
|
||||
} else {
|
||||
$diff = $firstPaymentDate->diff($today);
|
||||
$count = floor($diff->days / 7) + 1;
|
||||
}
|
||||
} elseif ($cycle === "M") {
|
||||
// মাসিক চক্র: পরের মাসের同一天 প্রথম EMI
|
||||
$firstPaymentDate = (clone $startDate)->modify('+1 month');
|
||||
|
||||
// যদি পরের মাসে同一天 না থাকে (যেমন 31st Jan থেকে 28/29th Feb)
|
||||
if ($firstPaymentDate->format('d') != $startDate->format('d')) {
|
||||
$firstPaymentDate->modify('last day of this month');
|
||||
}
|
||||
|
||||
if ($firstPaymentDate > $today) {
|
||||
$count = 0;
|
||||
} else {
|
||||
$count = 1; // প্রথম EMI already due
|
||||
$nextPaymentDate = clone $firstPaymentDate;
|
||||
|
||||
// পরের মাসগুলির জন্য গণনা
|
||||
while ($nextPaymentDate <= $today) {
|
||||
$nextPaymentDate->modify('+1 month');
|
||||
|
||||
// তারিখ adjust করাが必要 হলে
|
||||
if ($nextPaymentDate->format('d') != $firstPaymentDate->format('d')) {
|
||||
$nextPaymentDate->modify('last day of this month');
|
||||
}
|
||||
|
||||
if ($nextPaymentDate <= $today) {
|
||||
$count++;
|
||||
}
|
||||
}
|
||||
}
|
||||
} else {
|
||||
$count = 0;
|
||||
}
|
||||
|
||||
return min($count, $totalInstallment);
|
||||
}
|
||||
|
||||
$conn = new mysqli($GLOBALS['host'], $GLOBALS['user'], $GLOBALS['pass'], $GLOBALS['db']);
|
||||
if ($conn->connect_error) { die("Connection failed: " . $conn->connect_error); }
|
||||
|
||||
@@ -39,11 +103,11 @@ $grandTotal = [
|
||||
foreach($types as $type){
|
||||
$typeLike = "%$type%";
|
||||
if($_SESSION['type']==='admin'){
|
||||
$sql = "SELECT * FROM `" . $GLOBALS['arif_ac'] . "` WHERE `AA_TYPE` LIKE ? AND (`STATUS` IS NULL OR `STATUS`!='closed') ORDER BY `AA_ID` DESC";
|
||||
$sql = "SELECT * FROM `" . $GLOBALS['arif_ac'] . "` WHERE `AA_TYPE` LIKE ? AND (`STATUS` IS NULL OR (`STATUS`!='closed' AND `STATUS`!='matured')) ORDER BY `AA_ID` DESC";
|
||||
$stmt = $conn->prepare($sql);
|
||||
$stmt->bind_param("s", $typeLike);
|
||||
} elseif($_SESSION['type']==='agent'){
|
||||
$sql = "SELECT * FROM `" . $GLOBALS['arif_ac'] . "` WHERE `AA_TYPE` LIKE ? AND (`STATUS` IS NULL OR `STATUS`!='closed') AND `AA_AGENT`=? ORDER BY `AA_ID` DESC";
|
||||
$sql = "SELECT * FROM `" . $GLOBALS['arif_ac'] . "` WHERE `AA_TYPE` LIKE ? AND (`STATUS` IS NULL OR (`STATUS`!='closed' AND `STATUS`!='matured')) AND `AA_AGENT`=? ORDER BY `AA_ID` DESC";
|
||||
$stmt = $conn->prepare($sql);
|
||||
$stmt->bind_param("ss", $typeLike, $agent_id);
|
||||
}
|
||||
@@ -52,7 +116,7 @@ foreach($types as $type){
|
||||
$result = $stmt->get_result();
|
||||
|
||||
if($result->num_rows>0){
|
||||
echo "<tr><td colspan='11' style='text-align:center; font-weight:bold; background:#f0f0f0;'>$type Demand</td></tr>";
|
||||
echo "<tr><td colspan='13' style='text-align:center; font-weight:bold; background:#f0f0f0;'>$type Demand</td></tr>";
|
||||
|
||||
while($row = $result->fetch_assoc()){
|
||||
$totalDueAmt = $row['AA_BAL'];
|
||||
@@ -68,36 +132,48 @@ foreach($types as $type){
|
||||
$paidInst = 0; // বা অন্য লজিক
|
||||
$remainInst = 0;
|
||||
}
|
||||
// echo $row['AA_BAL'] . ' : ' . $row['AA_INSTALLMENT'];
|
||||
$paidInstallment = ($row['AA_MATURE_VALUE'] + $row['AA_BAL']) / $row['AA_INSTALLMENT'];
|
||||
$paidInstallment = number_format($paidInstallment, 2, '.', '');
|
||||
|
||||
$deuEMITillDate = countCycles($row['AA_ACTYPE'], $row['AA_DATE'], $row['AA_NO_OF_PAYMENT']) - $paidInstallment;
|
||||
$deuEMITillDate = abs($deuEMITillDate);
|
||||
$deuEMITillDate = number_format($deuEMITillDate, 2, '.', '');
|
||||
// HTML table row
|
||||
echo "<tr>
|
||||
<td>".$sl."</td>
|
||||
<td>".$row['AA_TYPE']."</td>
|
||||
<td>".$row['AA_ACNO']."</td>
|
||||
<td>".$row['AA_NAME']."</td>
|
||||
<td>".$row['AA_PHONE']."</td>
|
||||
<td>".$row['AA_DATE']."</td>
|
||||
<td>".$row['AA_MATURE_VALUE']."</td>
|
||||
<td>".$row['AA_BAL']."</td>
|
||||
<td>".$remainInst."</td>
|
||||
<td>".$paidInst."</td>
|
||||
<td>".$row['AA_INSTALLMENT']."</td>
|
||||
<td>".$totalDueAmt."</td>
|
||||
</tr>";
|
||||
|
||||
<td>".$sl."</td>
|
||||
<td>".$row['AA_ACTYPE'].", ".$row['AA_TYPE']."</td>
|
||||
<td>".$row['AA_ACNO']."</td>
|
||||
<td>".$row['AA_NAME']."</td>
|
||||
<td>".$row['AA_PHONE']."</td>
|
||||
<td>".$row['AA_DATE']."</td>
|
||||
<td>".$row['AA_MATURE_VALUE']."</td>
|
||||
<td>".$row['AA_BAL']."</td>
|
||||
<td>".$row['AA_NO_OF_PAYMENT']."</td>
|
||||
<td>".$paidInstallment."</td>
|
||||
<td>".$deuEMITillDate."</td>
|
||||
<td>".$row['AA_INSTALLMENT']."</td>
|
||||
<td>".$totalDueAmt."</td>
|
||||
|
||||
</tr>";
|
||||
// <td>".$remainInst."</td> <td>".$row['AA_NO_OF_PAYMENT']."</td>
|
||||
// PDF simplified row
|
||||
$pdfData[] = [
|
||||
$type,
|
||||
$sl,
|
||||
$row['AA_NAME'], // NAME OF ACCOUNT HOLDER
|
||||
$row['AA_PHONE'], // MOBILE NO (blank)
|
||||
$row['AA_ACNO'], // ACCOUNT NO
|
||||
$paidInst, // NO OF INSTALLMENT PAID
|
||||
$remainInst, // NO OF INSTALLMENT DUE
|
||||
$row['AA_INSTALLMENT'], // EMI AMOUNT
|
||||
$totalDueAmt, // TOTAL DUE AMOUNT
|
||||
"" // CUSTOMER SIGNATURE
|
||||
];
|
||||
// "SL","NAME ","MOBILE NO", "CYCLE", "ACCOUNT NO","EMI PAID","EMI DUE", "EMI AMOUNT", "CUSTOMER. SIGN"
|
||||
if($deuEMITillDate != 0){
|
||||
$pdfData[] = [
|
||||
$type,
|
||||
$sl,
|
||||
$row['AA_NAME'], // NAME OF ACCOUNT HOLDER
|
||||
$row['AA_PHONE'], // MOBILE NO (blank)
|
||||
$row['AA_ACTYPE'], // EMI Cycle
|
||||
$row['AA_ACNO'], // ACCOUNT NO
|
||||
$paidInstallment, // NO OF INSTALLMENT PAID
|
||||
$deuEMITillDate, // NO OF INSTALLMENT DUE
|
||||
$row['AA_INSTALLMENT'], // EMI AMOUNT
|
||||
// $totalDueAmt, // TOTAL DUE AMOUNT
|
||||
"" // CUSTOMER SIGNATURE
|
||||
];
|
||||
}
|
||||
|
||||
|
||||
// Update grand total
|
||||
$grandTotal['accounts']++;
|
||||
@@ -149,7 +225,7 @@ document.addEventListener('DOMContentLoaded', function() {
|
||||
|
||||
let y = 130;
|
||||
|
||||
const headers = ["SL","NAME ","MOBILE NO","ACCOUNT NO","EMI PAID","EMI DUE", "EMI AMOUNT", "TOTAL DUE AMOUNT","CUSTOMER. SIGN"];
|
||||
const headers = ["SL","NAME ","MOBILE NO", "CYCLE", "ACCOUNT NO","EMI PAID","EMI DUE", "EMI AMOUNT", "CUSTOMER. SIGN"];
|
||||
let currentType = '';
|
||||
let rows = [];
|
||||
|
||||
@@ -162,7 +238,7 @@ document.addEventListener('DOMContentLoaded', function() {
|
||||
startY:y,
|
||||
styles:{
|
||||
fontSize:7,
|
||||
cellPadding:6,
|
||||
cellPadding:3,
|
||||
lineWidth: 0.1, // border width
|
||||
lineColor: [0, 0, 0] // black border color
|
||||
},
|
||||
@@ -190,7 +266,7 @@ document.addEventListener('DOMContentLoaded', function() {
|
||||
startY:y,
|
||||
styles:{
|
||||
fontSize:7,
|
||||
cellPadding:6,
|
||||
cellPadding:3,
|
||||
lineWidth: 0.1, // border width
|
||||
lineColor: [0, 0, 0] // black border color
|
||||
},
|
||||
|
||||
1160
pma/tmp/twig/0d/0db8cfffd3d09171c872ac1e72f62ca0.php
Normal file
1160
pma/tmp/twig/0d/0db8cfffd3d09171c872ac1e72f62ca0.php
Normal file
File diff suppressed because it is too large
Load Diff
71
pma/tmp/twig/a1/a1e2156a9f6527a4e1b3d8858b435fa0.php
Normal file
71
pma/tmp/twig/a1/a1e2156a9f6527a4e1b3d8858b435fa0.php
Normal file
@@ -0,0 +1,71 @@
|
||||
<?php
|
||||
|
||||
use Twig\Environment;
|
||||
use Twig\Error\LoaderError;
|
||||
use Twig\Error\RuntimeError;
|
||||
use Twig\Extension\SandboxExtension;
|
||||
use Twig\Markup;
|
||||
use Twig\Sandbox\SecurityError;
|
||||
use Twig\Sandbox\SecurityNotAllowedTagError;
|
||||
use Twig\Sandbox\SecurityNotAllowedFilterError;
|
||||
use Twig\Sandbox\SecurityNotAllowedFunctionError;
|
||||
use Twig\Source;
|
||||
use Twig\Template;
|
||||
|
||||
/* table/import/index.twig */
|
||||
class __TwigTemplate_5ea560073dcab819362801734e57360e extends Template
|
||||
{
|
||||
private $source;
|
||||
private $macros = [];
|
||||
|
||||
public function __construct(Environment $env)
|
||||
{
|
||||
parent::__construct($env);
|
||||
|
||||
$this->source = $this->getSourceContext();
|
||||
|
||||
$this->blocks = [
|
||||
'title' => [$this, 'block_title'],
|
||||
];
|
||||
}
|
||||
|
||||
protected function doGetParent(array $context)
|
||||
{
|
||||
// line 1
|
||||
return "import.twig";
|
||||
}
|
||||
|
||||
protected function doDisplay(array $context, array $blocks = [])
|
||||
{
|
||||
$macros = $this->macros;
|
||||
$this->parent = $this->loadTemplate("import.twig", "table/import/index.twig", 1);
|
||||
$this->parent->display($context, array_merge($this->blocks, $blocks));
|
||||
}
|
||||
|
||||
// line 3
|
||||
public function block_title($context, array $blocks = [])
|
||||
{
|
||||
$macros = $this->macros;
|
||||
echo twig_escape_filter($this->env, twig_sprintf(_gettext("Importing into the table \"%s\""), ($context["table"] ?? null)), "html", null, true);
|
||||
}
|
||||
|
||||
public function getTemplateName()
|
||||
{
|
||||
return "table/import/index.twig";
|
||||
}
|
||||
|
||||
public function isTraitable()
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
public function getDebugInfo()
|
||||
{
|
||||
return array ( 46 => 3, 35 => 1,);
|
||||
}
|
||||
|
||||
public function getSourceContext()
|
||||
{
|
||||
return new Source("", "table/import/index.twig", "/home/suvo/web/graffin.ns77.siliconpin.com/public_html/pma/templates/table/import/index.twig");
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user