FEAT_ACM_CD_LOW_BAL_MAIL_AND_FIX_CLAIM_SAVE_ISSUE
This commit is contained in:
parent
6be81691a4
commit
94eeff5a21
@ -69,7 +69,7 @@ class Filters extends BaseConfig
|
|||||||
'before' => [
|
'before' => [
|
||||||
'HttpRequestLog' => ['except' => 'cli/*'],
|
'HttpRequestLog' => ['except' => 'cli/*'],
|
||||||
'Cors',
|
'Cors',
|
||||||
'AclFilter' => ['except' => ['login', 'logout', 'auth/*', 'oauth2callback','claim-form-download', 'claims-feedback-form', 'autobookstackLogin','employeeRest/*','processjob','getCommission','downloadEmployeeEcardZip', 'downloadClaimFile/*', 'api/v1/*']],
|
'AclFilter' => ['except' => ['login', 'logout', 'auth/*', 'oauth2callback','claim-form-download', 'claims-feedback-form', 'autobookstackLogin','employeeRest/*','processjob','getCommission','downloadEmployeeEcardZip', 'downloadClaimFile/*', 'api/v1/*', 'cronCdLowBalanceAlert', 'sendCroneRemainderMail']],
|
||||||
'SecurityInputFilter' => ['except' => ['/client/notification/create','/ticket/crud_mail_template/*','test_mail','leads/sendMail', 'ticket/reply'] ],
|
'SecurityInputFilter' => ['except' => ['/client/notification/create','/ticket/crud_mail_template/*','test_mail','leads/sendMail', 'ticket/reply'] ],
|
||||||
'GlobalPostFileUploadGuard'
|
'GlobalPostFileUploadGuard'
|
||||||
// 'csrf',
|
// 'csrf',
|
||||||
|
|||||||
@ -56,6 +56,7 @@ $routes->get("testMailAttachments", "ClientController::testMailAttachments");
|
|||||||
$routes->get("updatePolicyTermsKey", "ClientController::updatePolicyTermsKey");
|
$routes->get("updatePolicyTermsKey", "ClientController::updatePolicyTermsKey");
|
||||||
$routes->get("updateRemainderDate", "ClientController::updateRemainderDate");
|
$routes->get("updateRemainderDate", "ClientController::updateRemainderDate");
|
||||||
$routes->get("sendCroneRemainderMail", "DashboardController::sendCroneRemainderMail");
|
$routes->get("sendCroneRemainderMail", "DashboardController::sendCroneRemainderMail");
|
||||||
|
$routes->get("cronCdLowBalanceAlert", "MasterController::cronCdLowBalanceAlert");
|
||||||
$routes->get("sendextraparam", "ClientController::sendextraparam");
|
$routes->get("sendextraparam", "ClientController::sendextraparam");
|
||||||
$routes->get("updateRenewalData", "ClientController::updateRenewalData");
|
$routes->get("updateRenewalData", "ClientController::updateRenewalData");
|
||||||
$routes->get("updateRenewalDataNotExistingClient", "ClientController::updateRenewalDataNotExistingClient");
|
$routes->get("updateRenewalDataNotExistingClient", "ClientController::updateRenewalDataNotExistingClient");
|
||||||
@ -595,6 +596,7 @@ $routes->cli('cli/check_env', 'MasterController::checkEnv');
|
|||||||
$routes->cli('cli/reset-token-timeout', 'RestAuthenticationController::resetTokenTimeOut');
|
$routes->cli('cli/reset-token-timeout', 'RestAuthenticationController::resetTokenTimeOut');
|
||||||
$routes->cli('cli/enrollOpendAndClose', 'DashboardController::updatePolicyEnrollmentStatus');
|
$routes->cli('cli/enrollOpendAndClose', 'DashboardController::updatePolicyEnrollmentStatus');
|
||||||
$routes->cli("cli/sendCroneRemainderMail", "DashboardController::sendCroneRemainderMail");
|
$routes->cli("cli/sendCroneRemainderMail", "DashboardController::sendCroneRemainderMail");
|
||||||
|
$routes->cli("cli/cronCdLowBalanceAlert", "MasterController::cronCdLowBalanceAlert");
|
||||||
$routes->cli('cli/update-emp-policy-status', 'ClientController::updateEmpAndPolicyStatus');
|
$routes->cli('cli/update-emp-policy-status', 'ClientController::updateEmpAndPolicyStatus');
|
||||||
$routes->cli('cli/insurerRFQRemainder', 'LeadsController::remainderForQcr');
|
$routes->cli('cli/insurerRFQRemainder', 'LeadsController::remainderForQcr');
|
||||||
$routes->cli('cli/sendMailWithAutoQuery','TicketController::sendMailWithAutoQuery');
|
$routes->cli('cli/sendMailWithAutoQuery','TicketController::sendMailWithAutoQuery');
|
||||||
|
|||||||
@ -2284,6 +2284,49 @@ class MasterController extends AdminController
|
|||||||
'greater_than_equal_to' => 'Opening amount cannot be negative'
|
'greater_than_equal_to' => 'Opening amount cannot be negative'
|
||||||
]
|
]
|
||||||
],
|
],
|
||||||
|
|
||||||
|
'cd_balance_low_alert_amount' => [
|
||||||
|
'rules' => 'permit_empty|numeric|greater_than_equal_to[0]',
|
||||||
|
'errors' => [
|
||||||
|
'numeric' => 'CD balance low alert amount must be numeric',
|
||||||
|
'greater_than_equal_to' => 'CD balance low alert amount cannot be negative'
|
||||||
|
]
|
||||||
|
],
|
||||||
|
];
|
||||||
|
if (!$this->validate($rules)) {
|
||||||
|
return $this->response->setStatusCode(400)->setJSON([
|
||||||
|
'status' => false,
|
||||||
|
'message' => 'Input validation failed',
|
||||||
|
'code' => 400,
|
||||||
|
'errors' => $this->validator->getErrors()
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
$existingRecord = $this->CDMasterModel->where('id', $id)->where('is_active', 1)->first();
|
||||||
|
if ($existingRecord) {
|
||||||
|
foreach (['client_id', 'insurer_id', 'insurer_branch_id', 'opening_date', 'cd_ac_no', 'opening_bal'] as $field) {
|
||||||
|
if (! isset($sanitized_post_data[$field]) || $sanitized_post_data[$field] === '') {
|
||||||
|
$sanitized_post_data[$field] = $existingRecord[$field] ?? null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
$rules = [
|
||||||
|
'opening_bal' => [
|
||||||
|
'rules' => 'required|numeric|greater_than_equal_to[0]',
|
||||||
|
'errors' => [
|
||||||
|
'required' => 'Opening amount is required',
|
||||||
|
'numeric' => 'Opening amount must be numeric',
|
||||||
|
'greater_than_equal_to' => 'Opening amount cannot be negative'
|
||||||
|
]
|
||||||
|
],
|
||||||
|
'cd_balance_low_alert_amount' => [
|
||||||
|
'rules' => 'permit_empty|numeric|greater_than_equal_to[0]',
|
||||||
|
'errors' => [
|
||||||
|
'numeric' => 'CD balance low alert amount must be numeric',
|
||||||
|
'greater_than_equal_to' => 'CD balance low alert amount cannot be negative'
|
||||||
|
]
|
||||||
|
],
|
||||||
];
|
];
|
||||||
if (!$this->validate($rules)) {
|
if (!$this->validate($rules)) {
|
||||||
return $this->response->setStatusCode(400)->setJSON([
|
return $this->response->setStatusCode(400)->setJSON([
|
||||||
@ -2298,6 +2341,9 @@ class MasterController extends AdminController
|
|||||||
|
|
||||||
$date = (string) ($sanitized_post_data['opening_date'] ?? '');
|
$date = (string) ($sanitized_post_data['opening_date'] ?? '');
|
||||||
$sanitized_post_data['opening_date'] = date('Y-m-d', strtotime($date));
|
$sanitized_post_data['opening_date'] = date('Y-m-d', strtotime($date));
|
||||||
|
if (array_key_exists('cd_balance_low_alert_amount', $sanitized_post_data) && $sanitized_post_data['cd_balance_low_alert_amount'] === '') {
|
||||||
|
$sanitized_post_data['cd_balance_low_alert_amount'] = null;
|
||||||
|
}
|
||||||
$this->myLogger->logme("error", 'Formatted opening_date: ' . $data['opening_date']);
|
$this->myLogger->logme("error", 'Formatted opening_date: ' . $data['opening_date']);
|
||||||
|
|
||||||
$loggedInUserID = get_session_userid();
|
$loggedInUserID = get_session_userid();
|
||||||
@ -2463,6 +2509,14 @@ class MasterController extends AdminController
|
|||||||
'greater_than_equal_to' => 'Opening amount cannot be negative'
|
'greater_than_equal_to' => 'Opening amount cannot be negative'
|
||||||
]
|
]
|
||||||
],
|
],
|
||||||
|
|
||||||
|
'cd_balance_low_alert_amount' => [
|
||||||
|
'rules' => 'permit_empty|numeric|greater_than_equal_to[0]',
|
||||||
|
'errors' => [
|
||||||
|
'numeric' => 'CD balance low alert amount must be numeric',
|
||||||
|
'greater_than_equal_to' => 'CD balance low alert amount cannot be negative'
|
||||||
|
]
|
||||||
|
],
|
||||||
];
|
];
|
||||||
if (!$this->validate($rules)) {
|
if (!$this->validate($rules)) {
|
||||||
return $this->response->setStatusCode(400)->setJSON([
|
return $this->response->setStatusCode(400)->setJSON([
|
||||||
@ -2477,6 +2531,9 @@ class MasterController extends AdminController
|
|||||||
$id = $sanitized_post_data['PrimaryKey'] ?? null;
|
$id = $sanitized_post_data['PrimaryKey'] ?? null;
|
||||||
$date = ((string) $sanitized_post_data['opening_date']) ?? null;
|
$date = ((string) $sanitized_post_data['opening_date']) ?? null;
|
||||||
$sanitized_post_data['opening_date'] = date('Y-m-d', strtotime($date));
|
$sanitized_post_data['opening_date'] = date('Y-m-d', strtotime($date));
|
||||||
|
if (array_key_exists('cd_balance_low_alert_amount', $sanitized_post_data) && $sanitized_post_data['cd_balance_low_alert_amount'] === '') {
|
||||||
|
$sanitized_post_data['cd_balance_low_alert_amount'] = null;
|
||||||
|
}
|
||||||
|
|
||||||
if ($data) {
|
if ($data) {
|
||||||
|
|
||||||
@ -3879,5 +3936,211 @@ class MasterController extends AdminController
|
|||||||
return $newName;
|
return $newName;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Cron: Check CD balances (cash_deposit via cd_ac_pk) against cd_balance_low_alert_amount
|
||||||
|
* and notify account managers when balance is low.
|
||||||
|
*/
|
||||||
|
public function cronCdLowBalanceAlert()
|
||||||
|
{
|
||||||
|
log_message('error', 'cronCdLowBalanceAlert: started');
|
||||||
|
|
||||||
|
try {
|
||||||
|
$cdMasters = $this->CDMasterModel->getCdMastersWithLowAlertThreshold();
|
||||||
|
log_message('error', 'cronCdLowBalanceAlert: CD masters with alert threshold count = ' . count($cdMasters));
|
||||||
|
|
||||||
|
$lowBalanceAccounts = [];
|
||||||
|
|
||||||
|
foreach ($cdMasters as $cdMaster) {
|
||||||
|
$cdAcPk = (int) ($cdMaster['id'] ?? 0);
|
||||||
|
$threshold = (float) ($cdMaster['cd_balance_low_alert_amount'] ?? 0);
|
||||||
|
|
||||||
|
if ($cdAcPk <= 0 || $threshold <= 0) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
$lastDeposit = $this->clientDepositModel
|
||||||
|
->select('balance')
|
||||||
|
->where('cd_ac_pk', $cdAcPk)
|
||||||
|
->where('is_active', 1)
|
||||||
|
->orderBy('id', 'DESC')
|
||||||
|
->first();
|
||||||
|
|
||||||
|
if (! empty($lastDeposit)) {
|
||||||
|
$currentBalance = (float) ($lastDeposit['balance'] ?? 0);
|
||||||
|
} else {
|
||||||
|
$currentBalance = (float) ($cdMaster['opening_bal'] ?? 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($currentBalance >= $threshold) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
$lowBalanceAccounts[] = array_merge($cdMaster, [
|
||||||
|
'current_balance' => $currentBalance,
|
||||||
|
'alert_amount' => $threshold,
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (empty($lowBalanceAccounts)) {
|
||||||
|
$response = [
|
||||||
|
'status' => true,
|
||||||
|
'message' => 'No CD accounts below the configured low-balance alert amount.',
|
||||||
|
'low_balance_count' => 0,
|
||||||
|
'account_manager_mails_sent' => 0,
|
||||||
|
'data' => [],
|
||||||
|
'errors' => [],
|
||||||
|
];
|
||||||
|
log_message('error', 'cronCdLowBalanceAlert: ' . json_encode($response));
|
||||||
|
return $this->respond($response, 200);
|
||||||
|
}
|
||||||
|
|
||||||
|
$accountManagerMailsSent = 0;
|
||||||
|
$mailErrors = [];
|
||||||
|
$data = [];
|
||||||
|
|
||||||
|
foreach ($lowBalanceAccounts as $account) {
|
||||||
|
$result = $this->sendCdLowBalanceAccountManagerAlert($account);
|
||||||
|
$accountManagerMailsSent += (int) ($result['sent'] ?? 0);
|
||||||
|
if (! empty($result['errors'])) {
|
||||||
|
$mailErrors = array_merge($mailErrors, $result['errors']);
|
||||||
|
}
|
||||||
|
if (! empty($result['data'])) {
|
||||||
|
$data = array_merge($data, $result['data']);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
$response = [
|
||||||
|
'status' => true,
|
||||||
|
'message' => 'CD low balance alert cron completed.',
|
||||||
|
'low_balance_count' => count($lowBalanceAccounts),
|
||||||
|
'account_manager_mails_sent' => $accountManagerMailsSent,
|
||||||
|
'data' => $data,
|
||||||
|
'errors' => $mailErrors,
|
||||||
|
];
|
||||||
|
|
||||||
|
log_message('error', 'cronCdLowBalanceAlert: ' . json_encode($response));
|
||||||
|
return $this->respond($response, 200);
|
||||||
|
} catch (\Throwable $e) {
|
||||||
|
$response = [
|
||||||
|
'status' => false,
|
||||||
|
'message' => 'CD low balance alert cron failed.',
|
||||||
|
'low_balance_count' => 0,
|
||||||
|
'account_manager_mails_sent' => 0,
|
||||||
|
'data' => [],
|
||||||
|
'errors' => [$e->getMessage()],
|
||||||
|
];
|
||||||
|
log_message('error', 'cronCdLowBalanceAlert Exception: ' . $e->getMessage());
|
||||||
|
log_message('error', 'cronCdLowBalanceAlert: ' . json_encode($response));
|
||||||
|
return $this->respond($response, 500);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private function sendCdLowBalanceAccountManagerAlert(array $account): array
|
||||||
|
{
|
||||||
|
$clientId = (int) ($account['client_id'] ?? 0);
|
||||||
|
$cdAcPk = (int) ($account['id'] ?? 0);
|
||||||
|
$cdAcNo = (string) ($account['cd_ac_no'] ?? '');
|
||||||
|
|
||||||
|
if ($clientId <= 0) {
|
||||||
|
log_message('error', 'cronCdLowBalanceAlert ACM mail: skipped, invalid client_id for cd_ac_pk=' . $cdAcPk);
|
||||||
|
return ['sent' => 0, 'errors' => [], 'data' => []];
|
||||||
|
}
|
||||||
|
|
||||||
|
$recipients = $this->getAccountManagerRecipients($clientId);
|
||||||
|
if (empty($recipients)) {
|
||||||
|
$error = "Client {$clientId}: No account manager found.";
|
||||||
|
log_message('error', 'cronCdLowBalanceAlert ACM mail: ' . $error);
|
||||||
|
return ['sent' => 0, 'errors' => [$error], 'data' => []];
|
||||||
|
}
|
||||||
|
|
||||||
|
$sent = 0;
|
||||||
|
$errors = [];
|
||||||
|
$data = [];
|
||||||
|
$subject = 'CD Low Balance Alert - ' . ($account['client_name'] ?? 'Client');
|
||||||
|
|
||||||
|
foreach ($recipients as $recipient) {
|
||||||
|
$acmEmail = (string) ($recipient['email'] ?? '');
|
||||||
|
$acmName = (string) ($recipient['name'] ?? 'Account Manager');
|
||||||
|
$message = $this->buildCdLowBalanceAccountManagerMailContent($account, $acmName);
|
||||||
|
|
||||||
|
$mailResponse = MailHelper::send_email([
|
||||||
|
'mail' => $acmEmail,
|
||||||
|
'subject' => $subject,
|
||||||
|
'message' => $message,
|
||||||
|
'common' => [
|
||||||
|
'mail_type' => 'account_manager_cd_low_balance_alert',
|
||||||
|
'client_id' => $clientId,
|
||||||
|
],
|
||||||
|
]);
|
||||||
|
|
||||||
|
$decoded = is_string($mailResponse) ? json_decode($mailResponse, true) : $mailResponse;
|
||||||
|
$mailStatus = is_array($decoded) && ($decoded['status'] ?? '') === 'success' ? 'success' : 'failed';
|
||||||
|
|
||||||
|
$data[] = [
|
||||||
|
'client_id' => $clientId,
|
||||||
|
'cd_ac_pk' => $cdAcPk,
|
||||||
|
'cd_ac_no' => $cdAcNo,
|
||||||
|
'acm_name' => $acmName,
|
||||||
|
'acm_email' => $acmEmail,
|
||||||
|
'mail_status' => $mailStatus,
|
||||||
|
];
|
||||||
|
|
||||||
|
if ($mailStatus === 'success') {
|
||||||
|
$sent++;
|
||||||
|
} else {
|
||||||
|
$errors[] = "Client {$clientId}: Failed to send alert to {$acmEmail}.";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return ['sent' => $sent, 'errors' => $errors, 'data' => $data];
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return array<int, array{name: string, email: string}>
|
||||||
|
*/
|
||||||
|
private function getAccountManagerRecipients(int $clientId): array
|
||||||
|
{
|
||||||
|
$rows = $this->insurerRMModel
|
||||||
|
->select('user_profiles.first_name, user_profiles.email')
|
||||||
|
->join('user_profiles', 'user_profiles.id = client_rm.user_id')
|
||||||
|
->where('client_rm.client_id', $clientId)
|
||||||
|
->where('client_rm.level', 3)
|
||||||
|
->where('client_rm.is_active', 1)
|
||||||
|
->where('user_profiles.is_active', 1)
|
||||||
|
->findAll();
|
||||||
|
|
||||||
|
$recipients = [];
|
||||||
|
$seenEmails = [];
|
||||||
|
|
||||||
|
foreach ($rows as $row) {
|
||||||
|
$email = strtolower(trim((string) ($row['email'] ?? '')));
|
||||||
|
if ($email === '' || isset($seenEmails[$email])) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
$seenEmails[$email] = true;
|
||||||
|
$recipients[] = [
|
||||||
|
'name' => trim((string) ($row['first_name'] ?? 'Account Manager')) ?: 'Account Manager',
|
||||||
|
'email' => (string) $row['email'],
|
||||||
|
];
|
||||||
|
}
|
||||||
|
|
||||||
|
return $recipients;
|
||||||
|
}
|
||||||
|
|
||||||
|
private function buildCdLowBalanceAccountManagerMailContent(array $account, string $recipientName): string
|
||||||
|
{
|
||||||
|
return '<p>Dear ' . esc($recipientName) . ',</p>'
|
||||||
|
. '<p>The CD account balance for <strong>' . esc((string) ($account['client_name'] ?? '')) . '</strong> has fallen below the configured alert threshold.</p>'
|
||||||
|
. '<table border="1" cellpadding="8" cellspacing="0" style="border-collapse:collapse;">'
|
||||||
|
. '<tr><td><strong>Insurer</strong></td><td>' . esc((string) ($account['insurer_name'] ?? '')) . '</td></tr>'
|
||||||
|
. '<tr><td><strong>Insurer Branch</strong></td><td>' . esc((string) ($account['insurer_branch_name'] ?? '')) . '</td></tr>'
|
||||||
|
. '<tr><td><strong>CD Account No</strong></td><td>' . esc((string) ($account['cd_ac_no'] ?? '')) . '</td></tr>'
|
||||||
|
. '<tr><td><strong>Current Balance</strong></td><td>' . esc(number_format((float) ($account['current_balance'] ?? 0), 2, '.', '')) . '</td></tr>'
|
||||||
|
. '<tr><td><strong>Alert Amount</strong></td><td>' . esc(number_format((float) ($account['alert_amount'] ?? 0), 2, '.', '')) . '</td></tr>'
|
||||||
|
. '</table>'
|
||||||
|
. '<p>Please review the CD account and take the required action.</p>';
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
@ -2134,7 +2134,7 @@ class TicketController extends BaseController
|
|||||||
|
|
||||||
//send mail to the head for rejected ticket approvel
|
//send mail to the head for rejected ticket approvel
|
||||||
if($ticket_data['claim_status_id'] == 8 && $ticket_data['is_head_approved'] == 0){
|
if($ticket_data['claim_status_id'] == 8 && $ticket_data['is_head_approved'] == 0){
|
||||||
$this->sendMailToTheHead($ticket_data);
|
$this->sendMailToTheHead($ticket_id);
|
||||||
}else{
|
}else{
|
||||||
$this->myLogger->logme('error', "Head Mail can't be sent");
|
$this->myLogger->logme('error', "Head Mail can't be sent");
|
||||||
$this->myLogger->logme('error', "CLAIM STATUS ID : {data}", ['data' => $ticket_data['claim_status_id']]);
|
$this->myLogger->logme('error', "CLAIM STATUS ID : {data}", ['data' => $ticket_data['claim_status_id']]);
|
||||||
@ -3096,9 +3096,11 @@ class TicketController extends BaseController
|
|||||||
// -------------------------------------------------------------------------------------------------------------------------
|
// -------------------------------------------------------------------------------------------------------------------------
|
||||||
|
|
||||||
// function for Reject ticket Head Approvel mail sent function
|
// function for Reject ticket Head Approvel mail sent function
|
||||||
public function sendMailToTheHead($ticket_data)
|
public function sendMailToTheHead($ticket_id)
|
||||||
{
|
{
|
||||||
$this->myLogger->logme('error', "sendMailToTheHead Function Called");
|
$this->myLogger->logme('error', "sendMailToTheHead Function Called");
|
||||||
|
|
||||||
|
$ticket_data = $this->ticketMasterModel->getTicketDataByTicketID($ticket_id);
|
||||||
if(!empty($ticket_data)){
|
if(!empty($ticket_data)){
|
||||||
|
|
||||||
// print_r($ticket_data); die;
|
// print_r($ticket_data); die;
|
||||||
|
|||||||
@ -20,6 +20,7 @@ class CDMasterModel extends Model
|
|||||||
'insurer_branch_id',
|
'insurer_branch_id',
|
||||||
'cd_ac_no',
|
'cd_ac_no',
|
||||||
'opening_bal',
|
'opening_bal',
|
||||||
|
'cd_balance_low_alert_amount',
|
||||||
'opening_date',
|
'opening_date',
|
||||||
'created_at',
|
'created_at',
|
||||||
'updated_at',
|
'updated_at',
|
||||||
@ -110,4 +111,26 @@ class CDMasterModel extends Model
|
|||||||
$result = $query->getResultArray();
|
$result = $query->getResultArray();
|
||||||
return $result;
|
return $result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Active CD master rows that have a low-balance alert threshold configured.
|
||||||
|
*
|
||||||
|
* @return array<int, array<string, mixed>>
|
||||||
|
*/
|
||||||
|
public function getCdMastersWithLowAlertThreshold(): array
|
||||||
|
{
|
||||||
|
return $this->db->table('cd_master')
|
||||||
|
->select('cd_master.*, clients.client_name, clients.short_name, insurers.name AS insurer_name, insurer_branch.branch_name AS insurer_branch_name')
|
||||||
|
->join('clients', 'clients.id = cd_master.client_id')
|
||||||
|
->join('insurers', 'insurers.id = cd_master.insurer_id')
|
||||||
|
->join('insurer_branch', 'insurer_branch.id = cd_master.insurer_branch_id', 'left')
|
||||||
|
->where('cd_master.is_active', 1)
|
||||||
|
->where('clients.is_active', 1)
|
||||||
|
->where('insurers.is_active', 1)
|
||||||
|
->where('cd_master.cd_balance_low_alert_amount IS NOT NULL', null, false)
|
||||||
|
->where('cd_master.cd_balance_low_alert_amount >', 0)
|
||||||
|
->orderBy('cd_master.id', 'desc')
|
||||||
|
->get()
|
||||||
|
->getResultArray();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -86,6 +86,21 @@
|
|||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
<div class="form-row">
|
||||||
|
<div class="form-group col-md-6">
|
||||||
|
<label for="cd_balance_low_alert_amount">CD Balance Low Alert Amount</label>
|
||||||
|
<input type="text" class="form-control" id="cd_balance_low_alert_amount" name="cd_balance_low_alert_amount"
|
||||||
|
inputmode="decimal"
|
||||||
|
autocomplete="off"
|
||||||
|
onkeypress="return cdAmountNumberOnly(event)"
|
||||||
|
data-parsley-pattern="^(\d+(\.\d{1,2})?)?$"
|
||||||
|
data-parsley-pattern-message="Only numbers are allowed."
|
||||||
|
data-parsley-min="0"
|
||||||
|
data-parsley-min-message="CD balance low alert amount cannot be negative."
|
||||||
|
data-parsley-trigger="keyup">
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div id="cdButtonWrapper" class="form-group text-right m-b-0">
|
<div id="cdButtonWrapper" class="form-group text-right m-b-0">
|
||||||
@ -103,6 +118,33 @@
|
|||||||
|
|
||||||
<script>
|
<script>
|
||||||
|
|
||||||
|
function cdAmountNumberOnly(event) {
|
||||||
|
var charcode = event.which || event.keyCode;
|
||||||
|
if (charcode === 8 || charcode === 9 || charcode === 37 || charcode === 39) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
if (charcode >= 48 && charcode <= 57) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
if (charcode === 46 && event.target.value.indexOf('.') === -1) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
function sanitizeCdAmountInput(input) {
|
||||||
|
var value = input.value.replace(/[^\d.]/g, '');
|
||||||
|
var parts = value.split('.');
|
||||||
|
if (parts.length > 2) {
|
||||||
|
value = parts[0] + '.' + parts.slice(1).join('');
|
||||||
|
parts = value.split('.');
|
||||||
|
}
|
||||||
|
if (parts.length > 1) {
|
||||||
|
value = parts[0] + '.' + parts[1].slice(0, 2);
|
||||||
|
}
|
||||||
|
input.value = value;
|
||||||
|
}
|
||||||
|
|
||||||
//checking and setting this is CD master page or not
|
//checking and setting this is CD master page or not
|
||||||
var isCdMasterPage = <?php echo isset($CD_Master_Data) ? 'true' : 'false'; ?>;
|
var isCdMasterPage = <?php echo isset($CD_Master_Data) ? 'true' : 'false'; ?>;
|
||||||
console.log("isCdMasterPage", isCdMasterPage);
|
console.log("isCdMasterPage", isCdMasterPage);
|
||||||
@ -156,6 +198,13 @@
|
|||||||
$('#insurer_id_for_cd').select2();
|
$('#insurer_id_for_cd').select2();
|
||||||
$('#insurer_branch_id').select2();
|
$('#insurer_branch_id').select2();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
$('#cd_balance_low_alert_amount').on('input paste', function() {
|
||||||
|
var input = this;
|
||||||
|
setTimeout(function() {
|
||||||
|
sanitizeCdAmountInput(input);
|
||||||
|
}, 0);
|
||||||
|
});
|
||||||
})
|
})
|
||||||
|
|
||||||
$('#cd_ac_no_for_cd_master').keyup(function(){
|
$('#cd_ac_no_for_cd_master').keyup(function(){
|
||||||
@ -209,6 +258,12 @@
|
|||||||
}
|
}
|
||||||
|
|
||||||
let formData = new FormData($('#CDMasterForm')[0]);
|
let formData = new FormData($('#CDMasterForm')[0]);
|
||||||
|
var $disabledInputs = $('#CDMasterForm').find('input:disabled, select:disabled, textarea:disabled');
|
||||||
|
$disabledInputs.each(function() {
|
||||||
|
if (this.name) {
|
||||||
|
formData.set(this.name, $(this).val());
|
||||||
|
}
|
||||||
|
});
|
||||||
var openingDate = formData.get('opening_date');
|
var openingDate = formData.get('opening_date');
|
||||||
if (openingDate) {
|
if (openingDate) {
|
||||||
formData.set('opening_date', cdOpeningDateForSubmit(openingDate));
|
formData.set('opening_date', cdOpeningDateForSubmit(openingDate));
|
||||||
@ -281,7 +336,6 @@
|
|||||||
} else {
|
} else {
|
||||||
toastr.error('An unexpected error occurred. Please try again later.', 'Error');
|
toastr.error('An unexpected error occurred. Please try again later.', 'Error');
|
||||||
}
|
}
|
||||||
toastr.error('An error occurred while adding the CD account number.', 'Error');
|
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
@ -294,6 +348,7 @@
|
|||||||
$('#opening_date').val('');
|
$('#opening_date').val('');
|
||||||
$('#cd_ac_no_for_cd_master').val('');
|
$('#cd_ac_no_for_cd_master').val('');
|
||||||
$('#opening_bal').val('');
|
$('#opening_bal').val('');
|
||||||
|
$('#cd_balance_low_alert_amount').val('');
|
||||||
$('#CDMasterForm').parsley().reset();
|
$('#CDMasterForm').parsley().reset();
|
||||||
$('#cd_ac_no_for_cd_master').prop("disabled", false);
|
$('#cd_ac_no_for_cd_master').prop("disabled", false);
|
||||||
$('#opening_bal').prop("disabled", false);
|
$('#opening_bal').prop("disabled", false);
|
||||||
|
|||||||
@ -1,7 +1,7 @@
|
|||||||
<?php
|
<?php
|
||||||
helper('datatable_view');
|
helper('datatable_view');
|
||||||
$cdm_header_labels = [
|
$cdm_header_labels = [
|
||||||
'S.No', 'Client Name', 'Insurer Name', 'Insurer Branch Name', 'Opening Date', 'CD Account No', 'Opening Amount', 'Date/User', 'Action',
|
'S.No', 'Client Name', 'Insurer Name', 'Insurer Branch Name', 'Opening Date', 'CD Account No', 'Opening Amount', 'CD Balance Low Alert Amount', 'Date/User', 'Action',
|
||||||
];
|
];
|
||||||
$cdm_col_count = count($cdm_header_labels);
|
$cdm_col_count = count($cdm_header_labels);
|
||||||
$cdm_col_max_len = array_fill(0, $cdm_col_count, 0);
|
$cdm_col_max_len = array_fill(0, $cdm_col_count, 0);
|
||||||
@ -19,29 +19,23 @@ foreach ($CD_Master_Data as $index => $row) {
|
|||||||
$cdm_col_max_len[4] = max($cdm_col_max_len[4], mb_strlen($od));
|
$cdm_col_max_len[4] = max($cdm_col_max_len[4], mb_strlen($od));
|
||||||
$cdm_col_max_len[5] = max($cdm_col_max_len[5], mb_strlen((string) ($row['cd_ac_no'] ?? '')));
|
$cdm_col_max_len[5] = max($cdm_col_max_len[5], mb_strlen((string) ($row['cd_ac_no'] ?? '')));
|
||||||
$cdm_col_max_len[6] = max($cdm_col_max_len[6], mb_strlen((string) ($row['opening_bal'] ?? '')));
|
$cdm_col_max_len[6] = max($cdm_col_max_len[6], mb_strlen((string) ($row['opening_bal'] ?? '')));
|
||||||
|
$cdm_col_max_len[7] = max($cdm_col_max_len[7], mb_strlen((string) ($row['cd_balance_low_alert_amount'] ?? '')));
|
||||||
$du = ! empty($row['created_at'])
|
$du = ! empty($row['created_at'])
|
||||||
? (date('d/m/Y h:i A', strtotime((string) $row['created_at'])) . ' by ' . ($row['user_name'] ?? ''))
|
? (date('d/m/Y h:i A', strtotime((string) $row['created_at'])) . ' by ' . ($row['user_name'] ?? ''))
|
||||||
: '';
|
: '';
|
||||||
$cdm_col_max_len[7] = max($cdm_col_max_len[7], mb_strlen($du));
|
$cdm_col_max_len[8] = max($cdm_col_max_len[8], mb_strlen($du));
|
||||||
$cdm_col_max_len[8] = max($cdm_col_max_len[8], 4);
|
$cdm_col_max_len[9] = max($cdm_col_max_len[9], 4);
|
||||||
}
|
}
|
||||||
$cdm_col_min_px = [48, 140, 120, 140, 100, 120, 100, 200, 72];
|
$cdm_col_min_px = [72, 140, 120, 140, 100, 120, 100, 160, 200, 72];
|
||||||
$cdm_col_max_px = [64, 400, 320, 360, 120, 200, 160, 480, 88];
|
$cdm_col_max_px = [88, 400, 320, 360, 120, 200, 160, 220, 480, 88];
|
||||||
$cdm_col_width_px = nhance_dt_column_widths_px($cdm_header_labels, $cdm_col_max_len, $cdm_col_min_px, $cdm_col_max_px);
|
$cdm_col_width_px = nhance_dt_column_widths_px($cdm_header_labels, $cdm_col_max_len, $cdm_col_min_px, $cdm_col_max_px);
|
||||||
?>
|
?>
|
||||||
<style>
|
<style>
|
||||||
.col-12 {
|
.col-12 {
|
||||||
|
|
||||||
max-width: 98% !important;
|
max-width: 98% !important;
|
||||||
}
|
}
|
||||||
|
|
||||||
.column-header {margin-right: 10px;}
|
.column-header {margin-right: 10px;}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
.dataTables_length label {height: 21px !important;}
|
.dataTables_length label {height: 21px !important;}
|
||||||
|
|
||||||
|
|
||||||
</style>
|
</style>
|
||||||
|
|
||||||
<style>
|
<style>
|
||||||
@ -75,10 +69,25 @@ $cdm_col_width_px = nhance_dt_column_widths_px($cdm_header_labels, $cdm_col_max_
|
|||||||
font-size: 13px;
|
font-size: 13px;
|
||||||
line-height: 1.25;
|
line-height: 1.25;
|
||||||
}
|
}
|
||||||
|
#cd-master-list-table_wrapper .dataTables_scrollHead table thead th,
|
||||||
#cd-master-list-table thead th {
|
#cd-master-list-table thead th {
|
||||||
padding: 5px 2.35rem 5px 11px !important;
|
padding: 6px 1.5rem 6px 11px !important;
|
||||||
font-size: 13px;
|
font-size: 13px;
|
||||||
line-height: 1.25;
|
line-height: 1.25;
|
||||||
|
height: auto !important;
|
||||||
|
white-space: nowrap !important;
|
||||||
|
vertical-align: middle !important;
|
||||||
|
}
|
||||||
|
#cd-master-list-table_wrapper .dataTables_scrollHead table thead th:first-child,
|
||||||
|
#cd-master-list-table thead th:first-child {
|
||||||
|
padding-right: 1.1rem !important;
|
||||||
|
}
|
||||||
|
#cd-master-list-table_wrapper .dataTables_scrollHead table thead th:last-child,
|
||||||
|
#cd-master-list-table thead th:last-child {
|
||||||
|
padding-right: 1.35rem !important;
|
||||||
|
}
|
||||||
|
#cd-master-list-table_wrapper {
|
||||||
|
overflow-x: auto;
|
||||||
}
|
}
|
||||||
</style>
|
</style>
|
||||||
|
|
||||||
@ -86,17 +95,6 @@ $cdm_col_width_px = nhance_dt_column_widths_px($cdm_header_labels, $cdm_col_max_
|
|||||||
<div class="col-12">
|
<div class="col-12">
|
||||||
<div class="card">
|
<div class="card">
|
||||||
<div class="card-body">
|
<div class="card-body">
|
||||||
<!-- <div class="row" style="margin-bottom:1rem;">
|
|
||||||
<div class="col-6" style="align-self: center;">
|
|
||||||
<h4 style="position: relative;">CD Master</h4>
|
|
||||||
</div>
|
|
||||||
<div class="col-6" style="text-align: right; position: relative;top: 56px;">
|
|
||||||
<!- <button type="button" id="btnAdd" class="btn btn-primary waves-effect waves-light"
|
|
||||||
data-toggle="modal" data-target="#con-close-modal" data-placement="top" title="Add"
|
|
||||||
data-trigger="hover">ADD</button> ->
|
|
||||||
</div>
|
|
||||||
</div> -->
|
|
||||||
|
|
||||||
<table data-custom-table-css="table" data-nhance-list-dt="1" id="cd-master-list-table" class="table mb-0 nowrap" cellspacing="0">
|
<table data-custom-table-css="table" data-nhance-list-dt="1" id="cd-master-list-table" class="table mb-0 nowrap" cellspacing="0">
|
||||||
<thead class="bg-light">
|
<thead class="bg-light">
|
||||||
<tr>
|
<tr>
|
||||||
@ -107,12 +105,13 @@ $cdm_col_width_px = nhance_dt_column_widths_px($cdm_header_labels, $cdm_col_max_
|
|||||||
<th class="font-weight-medium">Opening Date </th>
|
<th class="font-weight-medium">Opening Date </th>
|
||||||
<th class="font-weight-medium">CD Account No </th>
|
<th class="font-weight-medium">CD Account No </th>
|
||||||
<th class="font-weight-medium">Opening Amount </th>
|
<th class="font-weight-medium">Opening Amount </th>
|
||||||
|
<th class="font-weight-medium">CD Balance Low Alert Amount </th>
|
||||||
<th class="font-weight-medium">Date/User </th>
|
<th class="font-weight-medium">Date/User </th>
|
||||||
<th class="font-weight-medium text-center">Action </th>
|
<th class="font-weight-medium text-center">Action </th>
|
||||||
</tr>
|
</tr>
|
||||||
</thead>
|
</thead>
|
||||||
<tbody>
|
<tbody>
|
||||||
<?php foreach($CD_Master_Data as $index => $row){ ?>
|
<?php foreach ($CD_Master_Data as $index => $row) { ?>
|
||||||
<tr>
|
<tr>
|
||||||
<td><?= $index + 1; ?></td>
|
<td><?= $index + 1; ?></td>
|
||||||
<td><?php echo $row['client_name']; ?>( <?= $row['short_name'] ?> )</td>
|
<td><?php echo $row['client_name']; ?>( <?= $row['short_name'] ?> )</td>
|
||||||
@ -121,20 +120,21 @@ $cdm_col_width_px = nhance_dt_column_widths_px($cdm_header_labels, $cdm_col_max_
|
|||||||
<td><?php echo date('d/m/Y', strtotime($row['opening_date'])); ?></td>
|
<td><?php echo date('d/m/Y', strtotime($row['opening_date'])); ?></td>
|
||||||
<td><?php echo $row['cd_ac_no']; ?></td>
|
<td><?php echo $row['cd_ac_no']; ?></td>
|
||||||
<td><?php echo $row['opening_bal']; ?></td>
|
<td><?php echo $row['opening_bal']; ?></td>
|
||||||
<td><?php echo date('d/m/Y h:i A', strtotime($row['created_at'])) ?> <br>by <?php echo $row['user_name']; ?></td>
|
<td><?php echo ($row['cd_balance_low_alert_amount'] ?? '') !== '' && ($row['cd_balance_low_alert_amount'] ?? null) !== null ? $row['cd_balance_low_alert_amount'] : ' '; ?></td>
|
||||||
|
<td><?php echo date('d/m/Y h:i A', strtotime($row['created_at'])); ?> by <?php echo $row['user_name']; ?></td>
|
||||||
<td class="text-center table-action-cell">
|
<td class="text-center table-action-cell">
|
||||||
<div class="btn-group dropdown">
|
<div class="btn-group dropdown">
|
||||||
<a href="javascript: void(0);"class="dropdown-toggle arrow-none btn btn-light btn-sm" data-toggle="dropdown" aria-expanded="false"><i class="mdi mdi-dots-horizontal"></i></a>
|
<a href="javascript: void(0);" class="dropdown-toggle arrow-none btn btn-light btn-sm" data-toggle="dropdown" aria-expanded="false"><i class="mdi mdi-dots-horizontal"></i></a>
|
||||||
<div class="dropdown-menu dropdown-menu-right">
|
<div class="dropdown-menu dropdown-menu-right">
|
||||||
<a class="dropdown-item btnEdit" data-id="<?= $row['id'];?>" data-toggle="modal" data-target="#con-close-modal"> <i class="mdi mdi-pencil mr-2 text-muted font-18 vertical-middle"></i>Edit</a>
|
<a class="dropdown-item btnEdit" data-id="<?= $row['id']; ?>" data-toggle="modal" data-target="#con-close-modal"> <i class="mdi mdi-pencil mr-2 text-muted font-18 vertical-middle"></i>Edit</a>
|
||||||
<?php if($row['cd_ac_no_count'] == 0) { ?>
|
<?php if ($row['cd_ac_no_count'] == 0) { ?>
|
||||||
<a class="dropdown-item" data-id="<?= $row['id'];?>" onclick="removeCDMaster(this)"><i class="mdi mdi-delete mr-2 text-muted font-18 vertical-middle"></i>Delete</a>
|
<a class="dropdown-item" data-id="<?= $row['id']; ?>" onclick="removeCDMaster(this)"><i class="mdi mdi-delete mr-2 text-muted font-18 vertical-middle"></i>Delete</a>
|
||||||
<?php } ?>
|
<?php } ?>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</td>
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
<?php } ?>
|
<?php } ?>
|
||||||
</tbody>
|
</tbody>
|
||||||
</table>
|
</table>
|
||||||
</div>
|
</div>
|
||||||
@ -151,14 +151,11 @@ $cdm_col_width_px = nhance_dt_column_widths_px($cdm_header_labels, $cdm_col_max_
|
|||||||
|
|
||||||
nhanceListDataTableBeforeInit();
|
nhanceListDataTableBeforeInit();
|
||||||
var table = $('#cd-master-list-table').DataTable(nhanceMergeListDataTableOptions({
|
var table = $('#cd-master-list-table').DataTable(nhanceMergeListDataTableOptions({
|
||||||
// dom: "<'row'<'col-sm-6'f><'col-sm-6 text-right'B>>" +
|
dom: "<'row'<'col-12 d-flex justify-content-between align-items-center'<'datatable-search dataTables_filter'f><'datatable-buttons dt-buttons'B>>>" +
|
||||||
// "<'row'<'col-sm-12'tr>>" +
|
|
||||||
// "<'row'<'col-sm-5'i><'col-sm-7'p>>",
|
|
||||||
dom: "<'row'<'col-sm-6'f><'col-sm-6 text-right'B>>" +
|
|
||||||
"<'row'<'col-sm-12'tr>>" +
|
"<'row'<'col-sm-12'tr>>" +
|
||||||
"<'row align-items-center'<'col-5 text-start'i><'col-7 d-flex justify-content-end align-items-center'<'me-2'l>p>>",
|
"<'row align-items-center'<'col-5 text-start'i><'col-7 d-flex justify-content-end align-items-center'<'me-2'l>p>>",
|
||||||
lengthMenu: [[10, 20, 50, 100], [10, 20, 50, 100]],
|
lengthMenu: [[10, 20, 50, 100], [10, 20, 50, 100]],
|
||||||
buttons: [
|
buttons: [
|
||||||
{
|
{
|
||||||
text: '<i class="mdi mdi-plus" ></i><span class=" btn-custom"> Add </span>',
|
text: '<i class="mdi mdi-plus" ></i><span class=" btn-custom"> Add </span>',
|
||||||
className: 'btn app-btn-primary mr-2',
|
className: 'btn app-btn-primary mr-2',
|
||||||
@ -185,7 +182,8 @@ $cdm_col_width_px = nhance_dt_column_widths_px($cdm_header_labels, $cdm_col_max_
|
|||||||
text: '<i class="mdi mdi-file-excel " ></i><span class=" btn-custom"> EXCEL </span>',
|
text: '<i class="mdi mdi-file-excel " ></i><span class=" btn-custom"> EXCEL </span>',
|
||||||
sheetName: 'CD-Master-List',
|
sheetName: 'CD-Master-List',
|
||||||
exportOptions: {
|
exportOptions: {
|
||||||
orthogonal: 'sort'
|
orthogonal: 'sort',
|
||||||
|
columns: ':not(:last-child)'
|
||||||
},
|
},
|
||||||
className: 'app-btn-primary ',
|
className: 'app-btn-primary ',
|
||||||
}
|
}
|
||||||
@ -196,9 +194,9 @@ $cdm_col_width_px = nhance_dt_column_widths_px($cdm_header_labels, $cdm_col_max_
|
|||||||
search: `
|
search: `
|
||||||
<div class="datatable-search-wrapper" style="position:relative; display:inline-block;">
|
<div class="datatable-search-wrapper" style="position:relative; display:inline-block;">
|
||||||
_INPUT_
|
_INPUT_
|
||||||
<i class="mdi mdi-magnify datatable-search-icon"
|
<i class="mdi mdi-magnify datatable-search-icon"
|
||||||
style="position:absolute; right:10px; top:50%; transform:translateY(-50%); color:#666;"></i>
|
style="position:absolute; right:10px; top:50%; transform:translateY(-50%); color:#666;"></i>
|
||||||
<i class="mdi mdi-close-circle datatable-clear-icon"
|
<i class="mdi mdi-close-circle datatable-clear-icon"
|
||||||
style="position:absolute; right:10px; top:50%; transform:translateY(-50%); color:#666; display:none;"></i>
|
style="position:absolute; right:10px; top:50%; transform:translateY(-50%); color:#666; display:none;"></i>
|
||||||
</div>`,
|
</div>`,
|
||||||
searchPlaceholder: "Search",
|
searchPlaceholder: "Search",
|
||||||
@ -216,34 +214,7 @@ $cdm_col_width_px = nhance_dt_column_widths_px($cdm_header_labels, $cdm_col_max_
|
|||||||
{ targets: <?= $i ?>, width: '<?= (int) $cdm_col_width_px[$i] ?>px' },
|
{ targets: <?= $i ?>, width: '<?= (int) $cdm_col_width_px[$i] ?>px' },
|
||||||
<?php endfor; ?>
|
<?php endfor; ?>
|
||||||
],
|
],
|
||||||
// scrollX: true,
|
}));
|
||||||
// dom: "<'row'<'col-sm-6'f><'col-sm-6 text-right'B>>" +
|
|
||||||
// "<'row'<'col-sm-12'tr>>" +
|
|
||||||
// "<'row'<'col-sm-5'i><'col-sm-7'p>>",
|
|
||||||
// buttons: [
|
|
||||||
// {
|
|
||||||
// extend: 'csv',
|
|
||||||
// text: 'CSV',
|
|
||||||
// title: 'CD-Master-List',
|
|
||||||
// className: 'my_class',
|
|
||||||
// exportOptions: {
|
|
||||||
// columns: ':not(:last-child)'
|
|
||||||
// },
|
|
||||||
// },
|
|
||||||
// {
|
|
||||||
// text: 'Add',
|
|
||||||
// className: 'buttons-html5 ',
|
|
||||||
// action: function (e, dt, node, config) {
|
|
||||||
// showCdMasterAddModal();
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
// ],
|
|
||||||
// language: {
|
|
||||||
// search: "_INPUT_",
|
|
||||||
// searchPlaceholder: "Search..."
|
|
||||||
// },
|
|
||||||
// paging: true,
|
|
||||||
}));
|
|
||||||
nhanceListDataTableAfterInit();
|
nhanceListDataTableAfterInit();
|
||||||
nhanceListDataTableBindAdjust(table);
|
nhanceListDataTableBindAdjust(table);
|
||||||
|
|
||||||
@ -263,7 +234,7 @@ $cdm_col_width_px = nhance_dt_column_widths_px($cdm_header_labels, $cdm_col_max_
|
|||||||
}
|
}
|
||||||
applyBottomRowDropup();
|
applyBottomRowDropup();
|
||||||
$('#cd-master-list-table').on('draw.dt', applyBottomRowDropup);
|
$('#cd-master-list-table').on('draw.dt', applyBottomRowDropup);
|
||||||
})
|
});
|
||||||
|
|
||||||
$(document).ready(function(){
|
$(document).ready(function(){
|
||||||
|
|
||||||
@ -274,8 +245,8 @@ $cdm_col_width_px = nhance_dt_column_widths_px($cdm_header_labels, $cdm_col_max_
|
|||||||
<?php if (session()->has('success')) : ?>
|
<?php if (session()->has('success')) : ?>
|
||||||
toastr.success('<?= session()->getFlashdata('success') ?>', 'Success');
|
toastr.success('<?= session()->getFlashdata('success') ?>', 'Success');
|
||||||
<?php endif; ?>
|
<?php endif; ?>
|
||||||
})
|
});
|
||||||
|
|
||||||
$('body').on('click', '.btnEdit', function () {
|
$('body').on('click', '.btnEdit', function () {
|
||||||
|
|
||||||
var cd_id = $(this).attr('data-id');
|
var cd_id = $(this).attr('data-id');
|
||||||
@ -291,7 +262,7 @@ $cdm_col_width_px = nhance_dt_column_widths_px($cdm_header_labels, $cdm_col_max_
|
|||||||
|
|
||||||
$('#updateModal').modal('show');
|
$('#updateModal').modal('show');
|
||||||
$('#CDMasterForm').attr('action', '<?php echo base_url('master/cash_deposite/edit');?>');
|
$('#CDMasterForm').attr('action', '<?php echo base_url('master/cash_deposite/edit');?>');
|
||||||
$('#CD_Master_ID').val(res.data.id);
|
$('#CD_Master_ID').val(res.data.id);
|
||||||
$('#cd_client_id').val(res.data.client_id).change();
|
$('#cd_client_id').val(res.data.client_id).change();
|
||||||
$('#cd_client_id').prop("disabled", true);
|
$('#cd_client_id').prop("disabled", true);
|
||||||
$('#insurer_id_for_cd').val(res.data.insurer_id).change();
|
$('#insurer_id_for_cd').val(res.data.insurer_id).change();
|
||||||
@ -300,8 +271,8 @@ $cdm_col_width_px = nhance_dt_column_widths_px($cdm_header_labels, $cdm_col_max_
|
|||||||
$('#insurer_branch_id').prop("disabled", true);
|
$('#insurer_branch_id').prop("disabled", true);
|
||||||
$('#opening_date').val(res.data.opening_date);
|
$('#opening_date').val(res.data.opening_date);
|
||||||
$('#cd_ac_no_for_cd_master').val(res.data.cd_ac_no);
|
$('#cd_ac_no_for_cd_master').val(res.data.cd_ac_no);
|
||||||
//$('#cd_ac_no_for_cd_master').prop("disabled", true);
|
|
||||||
$('#opening_bal').val(res.data.opening_bal);
|
$('#opening_bal').val(res.data.opening_bal);
|
||||||
|
$('#cd_balance_low_alert_amount').val(res.data.cd_balance_low_alert_amount ?? '');
|
||||||
if(res.cd_transaction_count <= 1){
|
if(res.cd_transaction_count <= 1){
|
||||||
$('#opening_bal').prop("disabled", false)
|
$('#opening_bal').prop("disabled", false)
|
||||||
}else{
|
}else{
|
||||||
@ -313,10 +284,10 @@ $cdm_col_width_px = nhance_dt_column_widths_px($cdm_header_labels, $cdm_col_max_
|
|||||||
error: function (xhr, status, error) {
|
error: function (xhr, status, error) {
|
||||||
console.error(xhr.responseText);
|
console.error(xhr.responseText);
|
||||||
console.error(status, error);
|
console.error(status, error);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
function removeCDMaster(element) {
|
function removeCDMaster(element) {
|
||||||
|
|
||||||
Swal.fire({
|
Swal.fire({
|
||||||
@ -330,7 +301,7 @@ $cdm_col_width_px = nhance_dt_column_widths_px($cdm_header_labels, $cdm_col_max_
|
|||||||
|
|
||||||
if (result.isConfirmed) {
|
if (result.isConfirmed) {
|
||||||
var id = element.getAttribute('data-id');
|
var id = element.getAttribute('data-id');
|
||||||
var form_action = '<?= base_url("master/cash_deposite/remove/") ?>' + id;
|
var form_action = '<?= base_url("master/cash_deposite/remove/") ?>' + id;
|
||||||
$.ajax({
|
$.ajax({
|
||||||
url: form_action,
|
url: form_action,
|
||||||
type: "GET",
|
type: "GET",
|
||||||
@ -338,7 +309,6 @@ $cdm_col_width_px = nhance_dt_column_widths_px($cdm_header_labels, $cdm_col_max_
|
|||||||
processData: false,
|
processData: false,
|
||||||
contentType: false,
|
contentType: false,
|
||||||
success: function(res) {
|
success: function(res) {
|
||||||
// console.log(res.status == true);
|
|
||||||
if(res){
|
if(res){
|
||||||
if (res.status == true) {
|
if (res.status == true) {
|
||||||
toastr.success('CD removed successfully.', 'Success');
|
toastr.success('CD removed successfully.', 'Success');
|
||||||
@ -362,4 +332,4 @@ $cdm_col_width_px = nhance_dt_column_widths_px($cdm_header_labels, $cdm_col_max_
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
</script>
|
</script>
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user