chnage count cycle function as per account type
This commit is contained in:
8
CONTENT/ROOT_URI/Admin/Agent/add_agent.php
Normal file
8
CONTENT/ROOT_URI/Admin/Agent/add_agent.php
Normal file
@@ -0,0 +1,8 @@
|
||||
<?php
|
||||
echo "<h3>Add New Agent</h3>";
|
||||
// Your form to add new agent
|
||||
echo "<form method='POST' action='?action=save'>
|
||||
<input type='text' name='agent_name' placeholder='Agent Name'>
|
||||
<button type='submit'>Save Agent</button>
|
||||
</form>";
|
||||
?>
|
||||
8
CONTENT/ROOT_URI/Admin/Agent/deemand.php
Normal file
8
CONTENT/ROOT_URI/Admin/Agent/deemand.php
Normal file
@@ -0,0 +1,8 @@
|
||||
<div class="container mx-auto">
|
||||
<form action="">
|
||||
<div>
|
||||
<label for="ACCOUNT_NUMBER">Account Number</label>
|
||||
<input class="form-control" type="text" name="ACCOUNT_NUMBER" id="ACCOUNT_NUMBER" />
|
||||
</div>
|
||||
</form>
|
||||
</div>
|
||||
27
CONTENT/ROOT_URI/Admin/Agent/index.php
Normal file
27
CONTENT/ROOT_URI/Admin/Agent/index.php
Normal file
@@ -0,0 +1,27 @@
|
||||
<?php
|
||||
// Get the absolute path to Admin directory
|
||||
$admin_dir = dirname(__DIR__);
|
||||
|
||||
// Include admin files with absolute paths
|
||||
include($admin_dir . "/ADMIN_HEADER.php");
|
||||
include($admin_dir . "/ADMIN_nav.php");
|
||||
|
||||
|
||||
// Use the $lnk variable that comes from main engine.php
|
||||
// $lnk already contains 'deemand' for /Admin/Agent/deemand
|
||||
|
||||
if ($lnk == "") {
|
||||
include("list_agents.php");
|
||||
}
|
||||
// Check if the requested file exists
|
||||
elseif (file_exists(__DIR__ . "/" . $lnk . ".php")) {
|
||||
include($lnk . ".php");
|
||||
}
|
||||
// If file doesn't exist, show list or 404
|
||||
else {
|
||||
include("list_agents.php");
|
||||
// or include("404.php");
|
||||
}
|
||||
|
||||
include($admin_dir . "/ADMIN_FOOTER.php");
|
||||
?>
|
||||
6
CONTENT/ROOT_URI/Admin/Agent/list_agents.php
Normal file
6
CONTENT/ROOT_URI/Admin/Agent/list_agents.php
Normal file
@@ -0,0 +1,6 @@
|
||||
<?php
|
||||
echo "<h3>Agent List</h3>";
|
||||
// Your code to display list of agents
|
||||
echo "<p>This will show a list of all agents</p>";
|
||||
echo "<a href='?action=add' class='btn btn-primary'>Add New Agent</a>";
|
||||
?>
|
||||
@@ -69,63 +69,95 @@
|
||||
// // Ensure count doesn't exceed total installments
|
||||
// return min($count, $totalInstallment);
|
||||
// }
|
||||
function countCycles($cycle, $createDate, $totalInstallment) {
|
||||
function countCycles($cycle, $createDate, $totalInstallment, $accountType) {
|
||||
$today = new DateTime();
|
||||
$startDate = new DateTime($createDate);
|
||||
|
||||
$cycle = strtoupper(trim($cycle));
|
||||
$accountType = strtoupper(trim($accountType));
|
||||
|
||||
if ($cycle === "D") {
|
||||
// দৈনিক চক্র: ক্রিয়েশন ডেট থেকেই শুরু
|
||||
$firstPaymentDate = clone $startDate; // পরের দিন নয়, সেই দিনই
|
||||
if ($accountType === "Recurring") {
|
||||
// Recurring account: creation date ই first EMI date
|
||||
$firstPaymentDate = clone $startDate;
|
||||
|
||||
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');
|
||||
if ($cycle === "D") {
|
||||
$diff = $firstPaymentDate->diff($today);
|
||||
$count = $diff->days + 1;
|
||||
} elseif ($cycle === "W") {
|
||||
$diff = $firstPaymentDate->diff($today);
|
||||
$count = floor($diff->days / 7) + 1;
|
||||
} elseif ($cycle === "M") {
|
||||
$count = 1; // প্রথম EMI already due
|
||||
$nextPaymentDate = clone $firstPaymentDate;
|
||||
|
||||
// তারিখ adjust করাが必要 হলে
|
||||
if ($nextPaymentDate->format('d') != $firstPaymentDate->format('d')) {
|
||||
$nextPaymentDate->modify('last day of this month');
|
||||
}
|
||||
|
||||
if ($nextPaymentDate <= $today) {
|
||||
$count++;
|
||||
while ($nextPaymentDate <= $today) {
|
||||
$nextPaymentDate->modify('+1 month');
|
||||
|
||||
if ($nextPaymentDate->format('d') != $firstPaymentDate->format('d')) {
|
||||
$nextPaymentDate->modify('last day of this month');
|
||||
}
|
||||
|
||||
if ($nextPaymentDate <= $today) {
|
||||
$count++;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
$count = 0;
|
||||
}
|
||||
}
|
||||
} elseif ($accountType === "Loan") {
|
||||
// Loan account: cycle অনুযায়ী first EMI later
|
||||
if ($cycle === "D") {
|
||||
$firstPaymentDate = (clone $startDate)->modify('+1 day');
|
||||
|
||||
if ($firstPaymentDate > $today) {
|
||||
$count = 0;
|
||||
} else {
|
||||
$diff = $firstPaymentDate->diff($today);
|
||||
$count = $diff->days + 1;
|
||||
}
|
||||
} elseif ($cycle === "W") {
|
||||
$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") {
|
||||
$firstPaymentDate = (clone $startDate)->modify('+1 month');
|
||||
|
||||
if ($firstPaymentDate->format('d') != $startDate->format('d')) {
|
||||
$firstPaymentDate->modify('last day of this month');
|
||||
}
|
||||
|
||||
if ($firstPaymentDate > $today) {
|
||||
$count = 0;
|
||||
} else {
|
||||
$count = 1;
|
||||
$nextPaymentDate = clone $firstPaymentDate;
|
||||
|
||||
while ($nextPaymentDate <= $today) {
|
||||
$nextPaymentDate->modify('+1 month');
|
||||
|
||||
if ($nextPaymentDate->format('d') != $firstPaymentDate->format('d')) {
|
||||
$nextPaymentDate->modify('last day of this month');
|
||||
}
|
||||
|
||||
if ($nextPaymentDate <= $today) {
|
||||
$count++;
|
||||
}
|
||||
}
|
||||
}
|
||||
} else {
|
||||
$count = 0;
|
||||
}
|
||||
} else {
|
||||
$count = 0;
|
||||
$count = 0; // Unknown account type
|
||||
}
|
||||
|
||||
return min($count, $totalInstallment);
|
||||
@@ -183,7 +215,7 @@ foreach($types as $type){
|
||||
$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 = countCycles($row['AA_ACTYPE'], $row['AA_DATE'], $row['AA_NO_OF_PAYMENT'], $row['AA_TYPE']) - $paidInstallment;
|
||||
// $deuEMITillDate = abs($deuEMITillDate);
|
||||
$deuEMITillDate = number_format($deuEMITillDate, 2, '.', '');
|
||||
|
||||
@@ -191,7 +223,7 @@ foreach($types as $type){
|
||||
$paidInstallment = $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 = countCycles($row['AA_ACTYPE'], $row['AA_DATE'], $row['AA_NO_OF_PAYMENT'], $row['AA_TYPE']) - $paidInstallment;
|
||||
// $deuEMITillDate = abs($deuEMITillDate);
|
||||
$deuEMITillDate = number_format($deuEMITillDate, 2, '.', '');
|
||||
|
||||
|
||||
@@ -1,24 +1,13 @@
|
||||
<?php
|
||||
$lnk2 = explode('?', $lnk);
|
||||
include("ADMIN_HEADER.php");
|
||||
//if(isset($_SESSION['EMAIL']) && ($_SESSION['EMAIL'] =="sarkar.suvankar@gmail.com" || $_SESSION['EMAIL']=="samiran.in@gmail.com" || $_SESSION['EMAIL']=="arif.kanyashree@gmail.com") ) {
|
||||
// if($_SESSION['EMAIL'] =="sarkar.suvankar@gmail.com" || $_SESSION['EMAIL']=="samiran.in@gmail.com" || $_SESSION['EMAIL']=="arif.kanyashree@gmail.com") {
|
||||
// if(isset($_SESSION['EMAIL']) && ($_SESSION['EMAIL'] =="sarkar.suvankar@gmail.com" || $_SESSION['EMAIL']=="samiran.in@gmail.com" || $_SESSION['EMAIL']=="arif.kanyashree@gmail.com") ) {
|
||||
|
||||
include("ADMIN_nav.php");
|
||||
echo "<br>";
|
||||
if($lnk=="") include("home.php");
|
||||
elseif(file_exists(__DIR__."/".$lnk.".php")) include($lnk.".php");
|
||||
elseif(isset($lnk2[1]) && file_exists(__DIR__."/".$lnk2[0].".php") ) include($lnk2[0].".php");
|
||||
else include("404.php");
|
||||
/*}
|
||||
elseif(get_user() == true){
|
||||
include("AGENT_nav.php");
|
||||
echo "<br>";
|
||||
if($lnk=="") include("home.php");
|
||||
elseif(file_exists(__DIR__."/agent_".$lnk.".php")) include("agent_".$lnk.".php");
|
||||
elseif(isset($lnk2[1]) && file_exists(__DIR__."/agent_".$lnk2[0].".php") ) include("agent_".$lnk2[0].".php");
|
||||
else include("404.php");
|
||||
} else echo '<center><h2>Provide Details to login</h2> <a href="https://siliconpin.com/id/auth"><button class="btn btn-default">Login</button></a></center>'; */
|
||||
include("ADMIN_nav.php");
|
||||
echo "<br>";
|
||||
if($lnk=="") include("home.php");
|
||||
elseif(file_exists(__DIR__."/".$lnk.".php")) include($lnk.".php");
|
||||
elseif(isset($lnk2[1]) && file_exists(__DIR__."/".$lnk2[0].".php") ) include($lnk2[0].".php");
|
||||
else include("404.php");
|
||||
|
||||
include("ADMIN_FOOTER.php");
|
||||
?>
|
||||
|
||||
Reference in New Issue
Block a user