FIX_ISSUE_3
This commit is contained in:
parent
e00e55c517
commit
7119fe98fb
@ -216,6 +216,9 @@ $routes->group("/employee", ["filter" => "authMVC"], function ($routes) {
|
|||||||
$routes->post("retail-endorsement-save", "EmployeeController::retailendorsementsave");
|
$routes->post("retail-endorsement-save", "EmployeeController::retailendorsementsave");
|
||||||
$routes->get("getTPADataVariationReport/(:num)", "EmployeeController::getTPADataVariationReport/$1");
|
$routes->get("getTPADataVariationReport/(:num)", "EmployeeController::getTPADataVariationReport/$1");
|
||||||
$routes->get("bulkGenerateEcardAndStoreinS3", "EmployeeController::bulkGenerateEcardAndStoreinS3");
|
$routes->get("bulkGenerateEcardAndStoreinS3", "EmployeeController::bulkGenerateEcardAndStoreinS3");
|
||||||
|
$routes->get('clearCdSession', 'EmployeeController::clearCdSession');
|
||||||
|
$routes->get('checkSessionStatus', 'EmployeeController::checkSessionStatus');
|
||||||
|
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@ -209,24 +209,23 @@ class EmpDataServiceController extends BaseController
|
|||||||
//check CD amt insufficient only insurer, not tpa // DO NOT REMOVE THIS
|
//check CD amt insufficient only insurer, not tpa // DO NOT REMOVE THIS
|
||||||
if($export_data['insurer_or_tpa'] == 'insurer')
|
if($export_data['insurer_or_tpa'] == 'insurer')
|
||||||
{
|
{
|
||||||
if (!empty($cash_balance)) {
|
if ((int) $cash_balance['balance'] < (int) $totals) {
|
||||||
clear_cd_balance_session();
|
clear_cd_balance_session(); // Clear old junk first
|
||||||
if ((int) $cash_balance['balance'] == (int) $totals) {
|
|
||||||
$this->myLogger->logme('error', 'Inception export failed due to insufficient deposit amount.');
|
|
||||||
$this->myLogger->logme('error', 'Inception export failed due to insufficient deposit amount. CASH BALANCE : {balance} and TOTAL AMOUNT : {total}', ['balance' => $cash_balance['balance'], 'total' => $totals]);
|
|
||||||
|
|
||||||
$cd_session_data = json_encode(['cd_balance' => false, 'cd_amount' => $cash_balance['balance'], 'excel_file_amt' => $totals]);
|
$cd_session_data = json_encode([
|
||||||
session()->set('cd_balance_info', $cd_session_data);
|
'cd_balance' => false,
|
||||||
session()->set('cd_balance', false);
|
'cd_amount' => $cash_balance['balance'],
|
||||||
|
'excel_file_amt' => $totals
|
||||||
|
]);
|
||||||
|
|
||||||
$hr_data = $this->getHrdataForInsufficientMailSend($export_data['client_branch_id']);
|
session()->set('cd_balance_info', $cd_session_data);
|
||||||
$session_data = json_encode(['client_id' => $export_data['client_id'], 'hr_data' => $hr_data]);
|
session()->set('cd_balance', 'insufficient'); // Use a string status for clarity
|
||||||
session()->set('hr_data', $session_data);
|
|
||||||
|
|
||||||
}else{
|
$hr_data = $this->getHrdataForInsufficientMailSend($export_data['client_branch_id']);
|
||||||
session()->set('cd_balance', true);
|
session()->set('hr_data', json_encode(['client_id' => $export_data['client_id'], 'hr_data' => $hr_data]));
|
||||||
|
}else{
|
||||||
}
|
session()->set('cd_balance', 'sufficient'); // Use a string status for clarity
|
||||||
|
session()->set('cd_balance_info', null);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -4584,6 +4584,20 @@ class EmployeeController extends AdminController
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function clearCdSession()
|
||||||
|
{
|
||||||
|
clear_cd_balance_session();
|
||||||
|
return $this->response->setJSON(['status' => 'cleared']);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function checkSessionStatus()
|
||||||
|
{
|
||||||
|
// Uses your existing get_cd_balance() helper
|
||||||
|
$data = get_cd_balance();
|
||||||
|
|
||||||
|
// Return as JSON so JavaScript can read it
|
||||||
|
return $this->response->setJSON($data);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@ -1108,6 +1108,7 @@ if (!function_exists('get_cd_balance')) {
|
|||||||
|
|
||||||
return [
|
return [
|
||||||
'has_cd_balance' => $session->has('cd_balance'),
|
'has_cd_balance' => $session->has('cd_balance'),
|
||||||
|
'cd_balance' => $session->get('cd_balance') ?? null,
|
||||||
'hr_data' => $session->get('hr_data') ?? [],
|
'hr_data' => $session->get('hr_data') ?? [],
|
||||||
'cd_balance_info' => $session->get('cd_balance_info') ?? [],
|
'cd_balance_info' => $session->get('cd_balance_info') ?? [],
|
||||||
];
|
];
|
||||||
|
|||||||
@ -1163,68 +1163,50 @@
|
|||||||
<?php endif; ?>
|
<?php endif; ?>
|
||||||
}
|
}
|
||||||
|
|
||||||
function checkCDBalance() {
|
async function checkCDBalance() {
|
||||||
|
try {
|
||||||
|
// 1. Fetch the LATEST session data from the server
|
||||||
|
const response = await fetch('checkSessionStatus');
|
||||||
|
const cdData = await response.json();
|
||||||
|
|
||||||
const cdData = <?= json_encode(get_cd_balance()) ?>;
|
console.log('Current Session Data:', cdData);
|
||||||
console.log(cdData, typeof cdData);
|
|
||||||
|
|
||||||
// cdData itself null / undefined safety
|
// 2. Check if cd_balance_info exists and isn't empty
|
||||||
if (!cdData || typeof cdData !== 'object') {
|
if (cdData.has_cd_balance && cdData.cd_balance_info) {
|
||||||
console.log('CD data not available');
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
let cd_balance_info = cdData.cd_balance_info
|
if(cdData.cd_balance === 'sufficient'){
|
||||||
console.log('cd_balance_info', cd_balance_info);
|
stopInterval(); // Stop checking once we find the error
|
||||||
cd_balance_info = JSON.parse(cd_balance_info);
|
console.log("CD Balance is sufficient");
|
||||||
console.log('cd_balance_info', cd_balance_info);
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
let hr_data = cdData.hr_data
|
let cd_balance_info = JSON.parse(cdData.cd_balance_info) ?? null;
|
||||||
console.log('hr_data', hr_data);
|
let hr_info = cdData.hr_data ? JSON.parse(cdData.hr_data) : null;
|
||||||
hr_data = JSON.parse(hr_data);
|
|
||||||
console.log('hr_data', hr_data);
|
|
||||||
|
|
||||||
|
// If balance is marked as false (insufficient)
|
||||||
|
if (cd_balance_info.cd_balance === false) {
|
||||||
|
|
||||||
let cd_balance = cd_balance_info.cd_balance;
|
stopInterval(); // Stop checking once we find the error
|
||||||
let cd_amount = cd_balance_info.cd_amount;
|
|
||||||
let excel_file_amt = cd_balance_info.excel_file_amt;
|
|
||||||
|
|
||||||
console.log(cd_balance ,cd_amount ,excel_file_amt);
|
toastr.warning(
|
||||||
|
`Insufficient CD Balance.<br>Balance: ₹${cd_balance_info.cd_amount}`,
|
||||||
|
'WARNING',
|
||||||
|
{ allowHtml: true }
|
||||||
|
);
|
||||||
|
|
||||||
window.hr_data = hr_data.hr_data;
|
if(hr_info) {
|
||||||
$('#client_id_for_hr_mail_send').val(hr_data.client_id)
|
$('#client_id_for_hr_mail_send').val(hr_info.client_id);
|
||||||
|
window.hr_data = hr_info.hr_data;
|
||||||
|
}
|
||||||
|
|
||||||
console.log(cd_balance, typeof cd_balance);
|
openModal();
|
||||||
|
|
||||||
if (cd_balance === false && messageShown === false) {
|
// 3. Clear the session now that we've handled it
|
||||||
|
fetch('clearCdSession');
|
||||||
const message1 =
|
}
|
||||||
'Insufficient CD Balance deducted. Please wait the file will be downloaded<br>' +
|
}
|
||||||
'<strong>CD Amount:</strong> ₹' + cd_amount + '<br>' +
|
} catch (error) {
|
||||||
'<strong>Total Amount:</strong> ₹' + excel_file_amt;
|
console.error('Error checking CD balance:', error);
|
||||||
|
|
||||||
toastr.warning(message1, 'WARNING', {
|
|
||||||
allowHtml: true,
|
|
||||||
timeOut: 10000,
|
|
||||||
extendedTimeOut: 3000
|
|
||||||
});
|
|
||||||
|
|
||||||
messageShown = true;
|
|
||||||
stopInterval();
|
|
||||||
openModal();
|
|
||||||
|
|
||||||
<?php clear_cd_balance_session(); ?>
|
|
||||||
|
|
||||||
}
|
|
||||||
else if (cd_balance === true) {
|
|
||||||
|
|
||||||
console.log('CD Balance is sufficient');
|
|
||||||
stopInterval();
|
|
||||||
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
|
|
||||||
console.log('CD balance info not available');
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1234,7 +1216,7 @@
|
|||||||
messageShown = false; // Reset message flag
|
messageShown = false; // Reset message flag
|
||||||
submitInterval = setInterval(function() {
|
submitInterval = setInterval(function() {
|
||||||
checkCDBalance();
|
checkCDBalance();
|
||||||
}, 10000);
|
}, 2000);
|
||||||
console.log("Checking CD balance started...");
|
console.log("Checking CD balance started...");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user