Merge remote-tracking branch 'origin/dev' into dev

This commit is contained in:
velz 2026-06-25 14:09:21 +05:30
commit 1a907b5032
25 changed files with 1016 additions and 300 deletions

View File

@ -153,6 +153,18 @@ LEAD_CLIENT_FROM_MAIL_ID =
# BDS Daily Report Emails Configuration
bds.dailyReportEmails =
# BDS Installment Reminder (pending UTR / overdue) — used by getLeadInstallmentDetails / sendInstallmentRemainderMail cron
# Master switch: when false, no installment reminder records are fetched
bds.installmentReminder.enabled = true
# Business days ahead of today to match upcoming payment_date (was hardcoded 5)
bds.installmentReminder.businessDays = 5
# When true, also fetch records with null UTR whose payment_date is already past (overdue)
bds.installmentReminder.fetchOverduePendingUtr = false
# When true, fetch every day; when false, only on days listed in bds.installmentReminder.days
bds.installmentReminder.daily = true
# Comma-separated weekdays (mon,tue,wed,thu,fri,sat,sun) — used only when daily = false
bds.installmentReminder.days = mon,tue,wed,thu,fri
#--------------------------------------------------------------------
# MEDI ASSIST WELLNESS SSO Configuration

View File

@ -44,7 +44,8 @@ class Acl
'#^/sendDataToTPA#' => ['roles' => [ADMIN_ROLE_ID, HEAD_ROLE_ID, ACCOUNT_MANAGER_ROLE_ID, MANAGER_ROLE_ID]],
'#^/swagger#' => ['roles' => [ADMIN_ROLE_ID, HEAD_ROLE_ID, ACCOUNT_MANAGER_ROLE_ID, MANAGER_ROLE_ID]],
'#^/viewClaimFile#' => ['roles' => [ADMIN_ROLE_ID, HEAD_ROLE_ID, ACCOUNT_MANAGER_ROLE_ID, MANAGER_ROLE_ID, STAFF_ROLE_ID]],
'#^/employee/tpaReportsDashboard#' => ['roles' => [ACCOUNT_MANAGER_ROLE_ID]],
'#^/employee/tpaReportsDashboard#' => ['roles' => [ACCOUNT_MANAGER_ROLE_ID, ADMIN_ROLE_ID, HEAD_ROLE_ID]],
'#^/policy_tranction/sendInstallmentRemainderMail#' => ['roles' => [ADMIN_ROLE_ID, HEAD_ROLE_ID]],

64
app/Config/BdsConfig.php Normal file
View File

@ -0,0 +1,64 @@
<?php
namespace Config;
use CodeIgniter\Config\BaseConfig;
class BdsConfig extends BaseConfig
{
public bool $installmentReminderEnabled = false;
public int $installmentReminderBusinessDays = 5;
public bool $installmentReminderFetchOverduePendingUtr = false;
public bool $installmentReminderDaily = false;
/** @var string[] Lowercase three-letter day abbreviations, e.g. mon, tue */
public array $installmentReminderDays = [];
public function __construct()
{
parent::__construct();
$this->installmentReminderEnabled = $this->envToBool(
env('bds.installmentReminder.enabled', 'true')
);
$this->installmentReminderBusinessDays = max(
0,
(int) env('bds.installmentReminder.businessDays', 5)
);
$this->installmentReminderFetchOverduePendingUtr = $this->envToBool(
env('bds.installmentReminder.fetchOverduePendingUtr', 'false')
);
$this->installmentReminderDaily = $this->envToBool(
env('bds.installmentReminder.daily', 'true')
);
$days = env('bds.installmentReminder.days', 'mon,tue,wed,thu,fri');
$this->installmentReminderDays = array_values(array_filter(array_map(
static fn (string $day): string => strtolower(substr(trim($day), 0, 3)),
explode(',', (string) $days)
)));
}
public function shouldFetchInstallmentRemindersToday(): bool
{
if (!$this->installmentReminderEnabled) {
return false;
}
if ($this->installmentReminderDaily) {
return true;
}
$today = strtolower(date('D'));
return in_array($today, $this->installmentReminderDays, true);
}
private function envToBool(mixed $value): bool
{
return in_array(strtolower((string) $value), ['1', 'true', 'yes', 'on'], true);
}
}

View File

@ -3,7 +3,7 @@
namespace Config;
use CodeIgniter\Config\BaseConfig;
use CodeIgniter\Debug\ExceptionHandler;
use App\Debug\CorsExceptionHandler;
use CodeIgniter\Debug\ExceptionHandlerInterface;
use Psr\Log\LogLevel;
use Throwable;
@ -99,6 +99,6 @@ class Exceptions extends BaseConfig
*/
public function handler(int $statusCode, Throwable $exception): ExceptionHandlerInterface
{
return new ExceptionHandler($this);
return new CorsExceptionHandler($this);
}
}

View File

@ -447,6 +447,7 @@ $routes->group("/util", ["filter" => "authMVC"], function ($routes) {
$routes->get('downloadFullMemberDataExcelErrorFile/(:any)', 'LeadsController::downloadFullMemberDataExcelErrorFile/$1');
$routes->get('getMemberDataExcelFileErrors', 'LeadsController::getMemberDataExcelFileErrors');
$routes->post('savePlacementDataAndValidateMemberDataFile', 'LeadsController::savePlacementDataAndValidateMemberDataFile');
$routes->post('savePlacementDataWithoutMail', 'LeadsController::savePlacementDataWithoutMail');
$routes->get('checkMemberDataFileValidationStatus', 'LeadsController::checkMemberDataFileValidationStatus');
$routes->match(['get', 'post', 'delete'], 'nhanceBranchMaster', 'MasterController::nhanceBranchMaster');
$routes->match(['get', 'post', 'delete'], 'vehicleTypeMaster', 'MasterController::vehicleTypeMaster');
@ -482,7 +483,7 @@ $routes->group("/util", ["filter" => "authMVC"], function ($routes) {
});
});
$routes->post("policy_tranction/sendInstallmentRemainderMail","PolicyTransactionController::sendInstallmentRemainderMail");
$routes->get("policy_tranction/sendInstallmentRemainderMail","PolicyTransactionController::sendInstallmentRemainderMail");
$routes->cli("cli/sendInstallmentRemainderMail","PolicyTransactionController::sendInstallmentRemainderMail");
$routes->cli("cli/cronDailyBDSReport", "PolicyTransactionController::cronDailyBDSReport");
$routes->cli('cli/croneDailyActivityReport', 'DashboardController::croneDailyActivityReport');
@ -725,6 +726,7 @@ $routes->group("employeeRest", ["filter" => ['GlobalPostFileUploadGuard', 'ratel
$routes->get("deleteDependence", "EmployeeRestController::deleteDependence");
$routes->get("getEmployeeAndDependenceByClientId", "EmployeeRestController::getEmployeeAndDependenceByClientId");
$routes->get("getClientPolicy", "EmployeeRestController::getClientPolicy");
$routes->get("getClientRM", "EmployeeRestController::getClientRM");
$routes->get("getAddOnPolicy", "EmployeeRestController::getAddOnPolicy");
$routes->post("iAgreeForAddOn", "EmployeeRestController::iAgreeForAddOn");
$routes->get("exportDataByClientPolicyId", "EmployeeRestController::exportDataByClientPolicyId");

View File

@ -2474,11 +2474,11 @@ class ClientController extends AdminController
]
],
'name.*' => [
'rules' => 'required|min_length[3]|regex_match[/^[a-zA-Z0-9\s\-_]+$/]',
'rules' => 'required|min_length[3]|regex_match[/^[a-zA-Z0-9\s.\-_]+$/]',
'errors' => [
'required' => 'Contact name is required',
'min_length' => 'Contact name must be at least 3 characters long',
'regex_match' => 'Contact name can only contain letters, numbers, spaces, hyphens and underscores.'
'regex_match' => 'Contact name can only contain letters, numbers, spaces, periods, hyphens and underscores.'
]
],
'designation.*' => [
@ -2658,11 +2658,11 @@ class ClientController extends AdminController
]
],
'name.*' => [
'rules' => 'required|min_length[3]|regex_match[/^[a-zA-Z0-9\s\-_]+$/]',
'rules' => 'required|min_length[3]|regex_match[/^[a-zA-Z0-9\s.\-_]+$/]',
'errors' => [
'required' => 'Contact name is required',
'min_length' => 'Contact name must be at least 3 characters long',
'regex_match' => 'Contact name can only contain letters, numbers, spaces, hyphens and underscores.'
'regex_match' => 'Contact name can only contain letters, numbers, spaces, periods, hyphens and underscores.'
]
],
'designation.*' => [
@ -7798,7 +7798,6 @@ class ClientController extends AdminController
public function getTheEmpDataForClaim($param, $type = null)
{
// Construct the base query
$data = $this->clientPolicyModel
->select("
clients.id AS client_id,
@ -7816,36 +7815,34 @@ class ClientController extends AdminController
employee_polices.uhid AS policy_no,
employee_polices.client_policy_id
")
->join('clients', 'client_policy.client_id = clients.id', 'left')
->join('insurers', 'client_policy.insurer_id = insurers.id', 'left')
->join('clients', 'client_policy.client_id = clients.id')
->join('insurers', 'client_policy.insurer_id = insurers.id')
->join('tpa', 'client_policy.tpa_id = tpa.id', 'left')
->join('employees', 'clients.id = employees.client_id', 'left')
->join('employee_polices', 'employees.id = employee_polices.employee_id', 'left')
->join('employees', 'clients.id = employees.client_id')
->join('employee_polices', 'employees.id = employee_polices.employee_id AND client_policy.id = employee_polices.client_policy_id')
->where('client_policy.is_active', 1)
->where('insurers.is_active', 1)
->where('tpa.is_active', 1)
->where('employees.is_active', 1)
->where('employees.relationship', "Self")
->where('employee_polices.is_active', 1)
->whereIn('employees.emp_status', ['active', 'expired'])
->whereIn('employee_polices.status', ['active', 'expired'])
->where('employees.is_active', 1)
->where('client_policy.id', $param)
->groupBy('employees.emp_code')
->where('employees.is_active', 1)
->where('employees.relationship', 'Self')
->whereIn('employees.emp_status', ['active', 'expired'])
->where('employee_polices.is_active', 1)
->whereIn('employee_polices.status', ['active', 'expired'])
->groupBy('employees.id')
->orderBy('employees.name', 'ASC')
->get()
->getResultArray();
// print_r(db_connect()->getLastQuery()); die;
// print_r(db_connect()->getLastQuery()->getQuery()); die;
$dataForClientAndInsurer = $this->clientPolicyModel
->select("
clients.id AS client_id,
clients.client_name,
insurers.id AS insurer_id,
insurers.name AS insurer_name,
tpa.id AS tpa_id,
tpa.name AS tpa_name,
")
clients.id AS client_id,
clients.client_name,
insurers.id AS insurer_id,
insurers.name AS insurer_name,
tpa.id AS tpa_id,
tpa.name AS tpa_name
")
->join('clients', 'client_policy.client_id = clients.id', 'left')
->join('insurers', 'client_policy.insurer_id = insurers.id', 'left')
->join('tpa', 'client_policy.tpa_id = tpa.id', 'left')
@ -7938,8 +7935,8 @@ class ClientController extends AdminController
->join('employees', 'clients.id = employees.client_id')
->join('employee_polices', 'employees.id = employee_polices.employee_id AND client_policy.id = employee_polices.client_policy_id')
->where('client_policy.is_active', 1)
->where('insurers.is_active', 1)
->where('tpa.is_active', 1)
// ->where('insurers.is_active', 1)
// ->where('tpa.is_active', 1)
->where('employees.is_active', 1)
->whereIn('employees.emp_status', ['active', 'expired'])
->where('employees.relationship', "Self")
@ -7964,7 +7961,7 @@ class ClientController extends AdminController
$data = $query->get()->getRowArray();
// print_r(db_connect()->getLastQuery()); die;
// print_r(db_connect()->getLastQuery()->getQuery()); die;
$memberData = [];
$dataForClientAndInsurer = [];

View File

@ -2217,18 +2217,18 @@ class EmpDataServiceController extends BaseController
'file_id' => $file_id,
]]);
$r = Jobs::addJob(['job_name' => 'makeEntryForBDSPolicyTransaction', 'payload' => [
'client_policy_id' => $client_policy_id ?? null,
'endorsement_no' => $endorsement_id ?? null,
'emp_count' => $emp_count ?? null,
'action_type' => $file['event_type'] ?? null,
'no_of_insured' => count($no_of_insured ?? []) ?? null,
'no_of_dependent' => count($no_of_dependent ?? []) ?? null,
'base_premium' => $base_bremium_and_gst['base_premium'] ?? null,
'gst' => $base_bremium_and_gst['gst'] ?? null,
'policy_issue_date' => $policy_issue_date ?? null,
'created_by' => $file['created_by'] ?? null,
]]);
// $r = Jobs::addJob(['job_name' => 'makeEntryForBDSPolicyTransaction', 'payload' => [
// 'client_policy_id' => $client_policy_id ?? null,
// 'endorsement_no' => $endorsement_id ?? null,
// 'emp_count' => $emp_count ?? null,
// 'action_type' => $file['event_type'] ?? null,
// 'no_of_insured' => count($no_of_insured ?? []) ?? null,
// 'no_of_dependent' => count($no_of_dependent ?? []) ?? null,
// 'base_premium' => $base_bremium_and_gst['base_premium'] ?? null,
// 'gst' => $base_bremium_and_gst['gst'] ?? null,
// 'policy_issue_date' => $policy_issue_date ?? null,
// 'created_by' => $file['created_by'] ?? null,
// ]]);
// $this->cashDepositCalculationForInception($depositeData);
// $this->sendMailForDownloadingECard($emp_policy_ids);
@ -2666,14 +2666,14 @@ class EmpDataServiceController extends BaseController
$file_data = $this->getDataByFileId($file_id, 'success');
$this->setPullNotification($file_data);
$r = Jobs::addJob(['job_name' => 'makeEntryForBDSPolicyTransaction', 'payload' => [
'client_policy_id' => $client_policy_id ?? null,
'endorsement_no' => $endorsement_id[0] ?? null,
'emp_count' => $emp_count ?? null,
'action_type' => $file['event_type'] ?? null,
'policy_issue_date' => $policy_issue_date ?? null,
'created_by' => $file['created_by'] ?? null,
]]);
// $r = Jobs::addJob(['job_name' => 'makeEntryForBDSPolicyTransaction', 'payload' => [
// 'client_policy_id' => $client_policy_id ?? null,
// 'endorsement_no' => $endorsement_id[0] ?? null,
// 'emp_count' => $emp_count ?? null,
// 'action_type' => $file['event_type'] ?? null,
// 'policy_issue_date' => $policy_issue_date ?? null,
// 'created_by' => $file['created_by'] ?? null,
// ]]);
//import file to upload Google Drive
@ -3401,18 +3401,18 @@ class EmpDataServiceController extends BaseController
'file_id' => $file_id,
]]);
$r = Jobs::addJob(['job_name' => 'makeEntryForBDSPolicyTransaction', 'payload' => [
'client_policy_id' => $client_policy_id ?? null,
'endorsement_no' => $endorsement_id ?? null,
'emp_count' => $emp_count ?? null,
'action_type' => $file['event_type'] ?? null,
'no_of_insured' => count($no_of_insured ?? []) ?? null,
'no_of_dependent' => count($no_of_dependent ?? []) ?? null,
'base_premium' => $base_bremium_and_gst['base_premium'] ?? null,
'gst' => $base_bremium_and_gst['gst'] ?? null,
'policy_issue_date' => $policy_issue_date ?? null,
'created_by' => $file['created_by'] ?? null,
]]);
// $r = Jobs::addJob(['job_name' => 'makeEntryForBDSPolicyTransaction', 'payload' => [
// 'client_policy_id' => $client_policy_id ?? null,
// 'endorsement_no' => $endorsement_id ?? null,
// 'emp_count' => $emp_count ?? null,
// 'action_type' => $file['event_type'] ?? null,
// 'no_of_insured' => count($no_of_insured ?? []) ?? null,
// 'no_of_dependent' => count($no_of_dependent ?? []) ?? null,
// 'base_premium' => $base_bremium_and_gst['base_premium'] ?? null,
// 'gst' => $base_bremium_and_gst['gst'] ?? null,
// 'policy_issue_date' => $policy_issue_date ?? null,
// 'created_by' => $file['created_by'] ?? null,
// ]]);
}
@ -3920,18 +3920,18 @@ class EmpDataServiceController extends BaseController
'file_id' => $file_id,
]]);
$r = Jobs::addJob(['job_name' => 'makeEntryForBDSPolicyTransaction', 'payload' => [
'client_policy_id' => $client_policy_id ?? null,
'endorsement_no' => $endorsement_id ?? null,
'emp_count' => $emp_count ?? null,
'action_type' => $file['event_type'] ?? null,
'no_of_insured' => count($no_of_insured ?? []) ?? null,
'no_of_dependent' => count($no_of_dependent ?? []) ?? null,
'base_premium' => $base_bremium_and_gst['base_premium'] ?? null,
'gst' => $base_bremium_and_gst['gst'] ?? null,
'policy_issue_date' => $policy_issue_date ?? null,
'created_by' => $file['created_by'] ?? null,
]]);
// $r = Jobs::addJob(['job_name' => 'makeEntryForBDSPolicyTransaction', 'payload' => [
// 'client_policy_id' => $client_policy_id ?? null,
// 'endorsement_no' => $endorsement_id ?? null,
// 'emp_count' => $emp_count ?? null,
// 'action_type' => $file['event_type'] ?? null,
// 'no_of_insured' => count($no_of_insured ?? []) ?? null,
// 'no_of_dependent' => count($no_of_dependent ?? []) ?? null,
// 'base_premium' => $base_bremium_and_gst['base_premium'] ?? null,
// 'gst' => $base_bremium_and_gst['gst'] ?? null,
// 'policy_issue_date' => $policy_issue_date ?? null,
// 'created_by' => $file['created_by'] ?? null,
// ]]);
}
$file_data = $this->getDataByFileId($file_id, 'success');

View File

@ -1643,6 +1643,53 @@ class EmployeeRestController extends AdminController
}
}
public function getClientRM()
{
try {
$client_id = $this->request->getGet('client_id');
if (empty($client_id)) {
return $this->respond(['status' => 'failed', 'code' => 400, 'message' => 'client_id is required'], 200);
}
$clientRmRecords = $this->clientRMModel
->select('client_rm.level, user_profiles.first_name, user_profiles.email, user_profiles.mobile')
->join('user_profiles', 'user_profiles.id = client_rm.user_id')
->where('md5(client_rm.client_id)', $client_id)
->where('client_rm.is_active', 1)
->whereIn('client_rm.level', [1, 3])
->findAll();
$level_1 = [];
$level_2 = [];
foreach ($clientRmRecords as $record) {
$user = [
'first_name' => $record['first_name'],
'email' => $record['email'],
'mobile' => $record['mobile'],
];
if ((int) $record['level'] === 3) {
$level_1[] = $user;
} else {
$level_2[] = $user;
}
}
return $this->respond([
'status' => 'success',
'code' => 200,
'data' => [
'level_1' => $level_1,
'level_2' => $level_2,
],
], 200);
} catch (\Exception $e) {
return $this->respond(['status' => 'failed', 'code' => 500, 'data' => $e->getMessage()], 500);
}
}
public function getAddOnPolicy()
{
try {
@ -2264,6 +2311,11 @@ class EmployeeRestController extends AdminController
client_policy.inception_type as inception_type,
client_policy.policy_no as policy_no,
client_policy.insurer_id as insurer_id,
client_policy.policy_terms,
insurers.name as insurer_name,
tpa.name as tpa_name,
tpa.short_name as tpa_short_name,
insurers.short_name as insurer_short_name,
DATE_FORMAT(client_policy.policy_start_date, '%d-%m-%Y') AS policy_start_date,
DATE_FORMAT(client_policy.policy_end_date, '%d-%m-%Y') AS policy_expiry_date,
clients.client_logo as client_logo,
@ -2278,6 +2330,8 @@ class EmployeeRestController extends AdminController
", false)
->join('clients', 'clients.id = client_policy.client_id', 'left')
->join('policy_type', 'policy_type.id = client_policy.policy_type_id', 'left')
->join('insurers', 'insurers.id = client_policy.insurer_id', 'left')
->join('tpa', 'tpa.id = client_policy.tpa_id', 'left')
->where('md5(client_policy.client_id)', $this->request->getGet('client_id'))
->where('client_policy.client_branch_id', $this->request->getGet('client_branch_id'))
->where('client_policy.is_active', 1)
@ -2316,6 +2370,26 @@ class EmployeeRestController extends AdminController
$value['is_ecard_bulk_download'] = 0;
$value['is_ecard_bulk_download_for_employee'] = 0;
$terms = json_decode($value['policy_terms'], true) ?? [];
if ($value['policy_type_id'] == 1) {
$policyGroup = 'gpa';
} elseif (in_array($value['policy_type_id'], [6, 7, 72])) {
$policyGroup = 'other';
} else {
$policyGroup = 'gmc';
}
$value['policy_terms'] = isset($terms['enrollment_display_key']) && ! empty($terms['enrollment_display_key'])
? $terms['enrollment_display_key']
: $this->policyTermsFiter($terms, $policyGroup);
$sumInsuredLabel = in_array($value['policy_type_id'], [1, 6, 7]) ? 'Sum Assured' : 'Sum Insured';
$sumInsuredValue = $terms['sum_insured'] ?? ($terms['sumInsured2'] ?? null);
if ($sumInsuredValue !== null && $sumInsuredValue !== '') {
if (! array_key_exists($sumInsuredLabel, $value['policy_terms'])) {
$value['policy_terms'] = array_merge([$sumInsuredLabel => $sumInsuredValue], $value['policy_terms']);
}
}
array_push($result, $value);
}

View File

@ -3764,7 +3764,7 @@ class LeadsController extends BaseController
if(isset($propsal_and_insurer)) {
if (! empty($propsal_and_insurer[0])) {
$parts = explode('-', $propsal_and_insurer[0], 2);
$parts = explode('-', $propsal_and_insurer, 2);
$proposal_key = $parts[0] ?? null;
$insurer_key = $parts[1] ?? null;
} else {
@ -3811,8 +3811,8 @@ class LeadsController extends BaseController
if (! empty($installment_data)) {
foreach ($installment_data as $key => $value) {
// print_r($value);die
$value['payment_date'] = ! empty($value['payment_date']) && strtotime($value['payment_date'])
? date('Y/m/d', strtotime($value['payment_date']))
$value['payment_date'] = ! empty($value['payment_date'])
? change_date_format($value['payment_date'])
: null;
if (isset($value['id']) && ! empty($value['id'])) {
$this->leadInstallmentPaymentDetails->where('id', $value['id'])->set($value)->update();
@ -8272,8 +8272,8 @@ class LeadsController extends BaseController
if (is_array($installments) && ! empty($installments)) {
foreach ($installments as $installment) {
$installment['payment_date'] = ! empty($installment['payment_date']) && strtotime($installment['payment_date'])
? date('Y-m-d', strtotime($installment['payment_date']))
$installment['payment_date'] = ! empty($installment['payment_date'])
? change_date_format($installment['payment_date'])
: null;
$installment['lead_id'] = $lead_id;
@ -8326,6 +8326,105 @@ class LeadsController extends BaseController
}
}
public function savePlacementDataWithoutMail()
{
try {
$params = $this->request->getPost();
if (empty($params['lead_id'])) {
return $this->respond([
'status' => false,
'code' => 400,
'message' => 'Opportunity ID is required',
], 400);
}
$lead_id = $params['lead_id'];
$lead_data = $this->leadsModel->where('id', $lead_id)->first();
if (! $lead_data) {
return $this->respond([
'status' => false,
'code' => 404,
'message' => 'Lead not found',
], 404);
}
$data = [
'placement_date' => ! empty($params['placement_date']) ? change_date_format($params['placement_date']) : null,
'payment_date' => ! empty($params['payment_date']) ? change_date_format($params['payment_date']) : null,
'utr_no' => $params['utr_no'] ?? null,
'is_cd' => $params['is_cd'] ?? null,
'premium_amount' => $params['premium_amount'] ?? null,
'total_amount' => $params['total_amount'] ?? null,
'cd_amount' => $params['cd_amount'] ?? null,
'no_of_installment' => $params['no_of_installment'] ?? null,
'is_installment' => $params['is_installment'] ?? null,
'agreed_percentage' => $params['agreed_percentage'] ?? null,
];
if (! empty($params['acm_pk'])) {
$data['acm_id'] = $params['acm_pk'];
}
if (! empty($params['policy_start_date'])) {
$converted_start = change_date_format($params['policy_start_date']);
if ($converted_start !== $lead_data['policy_start_date']) {
$data['policy_start_date'] = $converted_start;
}
}
if (! empty($params['policy_end_date'])) {
$converted_end = change_date_format($params['policy_end_date']);
if ($converted_end !== $lead_data['policy_end_date']) {
$data['policy_end_date'] = $converted_end;
}
}
if (! empty($params['tpa_id']) && strpos($params['tpa_id'], '-') !== false) {
list($tpaBranchId, $tpaId) = explode('-', $params['tpa_id']);
$data['tpa_branch_id'] = $tpaBranchId;
$data['tpa_id'] = $tpaId;
}
$this->leadsModel->update($lead_id, $data);
if (! empty($params['installments'])) {
$installments = json_decode($params['installments'], true);
if (is_array($installments) && ! empty($installments)) {
foreach ($installments as $installment) {
$installment['payment_date'] = ! empty($installment['payment_date'])
? change_date_format($installment['payment_date'])
: null;
$installment['lead_id'] = $lead_id;
if (! empty($installment['id'])) {
$this->leadInstallmentPaymentDetails->update($installment['id'], $installment);
} else {
$this->leadInstallmentPaymentDetails->insert($installment);
}
}
}
}
return $this->respond([
'status' => true,
'code' => 200,
'message' => 'Placement data saved successfully',
'lead_id' => $lead_id,
], 200);
} catch (\Exception $e) {
return $this->respond([
'status' => false,
'code' => 500,
'message' => 'Error while saving placement data',
'error' => $e->getMessage(),
], 500);
}
}
public function checkMemberDataFileValidationStatus()
{
$lead_id = $this->request->getVar('lead_id');

View File

@ -40,6 +40,7 @@ use App\Models\NhanceBranchModel;
use App\Models\BDSDumpModel;
use App\Models\VehicleModel;
use CodeIgniter\CLI\CLI;
use Config\BdsConfig;
use Exception;
class PolicyTransactionController extends BaseController
@ -1023,7 +1024,6 @@ class PolicyTransactionController extends BaseController
'follower_policy_no.*' => ['label' => 'Follower Policy No', 'rules' => 'permit_empty|regex_match[/^[a-zA-Z0-9\/_-]+$/]', 'errors' => [
'regex_match' => 'The {field} can only contain letters, numbers, spaces, dashes, and underscores.'
]],
'calc_policy_issue_date.*' => ['label' => 'Policy Issue Date', 'rules' => 'required', 'errors' => ['required' => 'Policy Issue Date is required']],
'co_share_per.*' => ['label' => 'Co-Share %', 'rules' => 'permit_empty|decimal', 'errors' => ['decimal' => 'Co-Share % must be a valid decimal.']],
'non_comm_per_amt.*' => ['label' => 'Non-Comm Premium', 'rules' => 'permit_empty|decimal', 'errors' => ['decimal' => 'Amount must be numeric.']],
'base_premium.*' => ['label' => 'Base Premium','rules' => 'permit_empty|decimal', 'errors' => ['decimal' => 'Base Premium must be numeric.']],
@ -1054,6 +1054,26 @@ class PolicyTransactionController extends BaseController
'exp_amt.*' => ['label' => 'Expected Amount', 'rules' => 'permit_empty|decimal', 'errors' => ['decimal' => 'The Expected Amount field must contain a valid number.']]
];
$isCoShare = !empty($post_data['co_share']);
$calcPolicyIssueDateRule = [
'label' => 'Policy Issue Date',
'rules' => 'required',
'errors' => ['required' => 'Policy Issue Date is required'],
];
if ($isCoShare) {
$coShareTypes = $post_data['co_share_type'] ?? [];
if (is_array($coShareTypes)) {
foreach ($coShareTypes as $index => $type) {
if ((int) $type === 1) {
$rules["calc_policy_issue_date.$index"] = $calcPolicyIssueDateRule;
}
}
}
} else {
$rules['calc_policy_issue_date.*'] = $calcPolicyIssueDateRule;
}
if(isset($post_data['client_type']) && $post_data['client_type'] == 1){
$rules['client_branch_id'] = ['label' => 'Client Branch', 'rules' => 'required', 'errors' => ['required' => 'Client branch is required']];
}
@ -1181,6 +1201,15 @@ class PolicyTransactionController extends BaseController
$data['co_share'] = 1;
}
if ($data['co_share'] == 1 && !empty($data['follow_insurer_id']) && is_array($data['follow_insurer_id'])) {
foreach ($data['follow_insurer_id'] as $index => $followInsurer) {
if (($data['co_share_type'][$index] ?? 2) == 1 && !empty($followInsurer)) {
list($data['insurer_branch_id'], $data['insurer_id']) = explode('-', $followInsurer);
break;
}
}
}
// if (!isset($data['bro_payable_by'])) {
// $data['bro_payable_by'] = 0;
// } elseif ($data['bro_payable_by']) {
@ -5321,6 +5350,16 @@ class PolicyTransactionController extends BaseController
$this->myLogger->logme("error", "Cron Job For Send Installment Remainder Mail Started");
try {
/** @var BdsConfig $bdsConfig */
$bdsConfig = config(BdsConfig::class);
if (!$bdsConfig->shouldFetchInstallmentRemindersToday()) {
$this->myLogger->logme(
'error',
'Installment reminder fetch skipped (bds.installmentReminder.enabled / daily / days config)'
);
CLI::write('Installment reminder fetch skipped per .env configuration');
return ['status' => false, 'message' => 'Fetch skipped per configuration', 'response' => []];
}
$bdsInstallmentData = [];
@ -5331,11 +5370,11 @@ class PolicyTransactionController extends BaseController
}
$this->myLogger->logme("error", "Data for BDS Installment " . json_encode($bdsInstallmentData));
// print_r($bdsInstallmentData);die();
// print_rr($bdsInstallmentData);die();
if (empty($bdsInstallmentData)) {
$this->myLogger->logme("error", "No Client Installment is Due in the 15th Day");
CLI::write("No Client Installment is Due in the 15th Day");
$this->myLogger->logme("error", "No Client Installment is Due in the 5th Day");
CLI::write("No Client Installment is Due in the 5th Day");
return ['status' => false, 'message' => 'No data found', 'response' => []];
}
@ -5356,8 +5395,10 @@ class PolicyTransactionController extends BaseController
$this->myLogger->logme('error', 'res: ' . json_encode($res));
if ($res->status == 'success') {
CLI::write("Mail sent successfully to " . count($to_mail) . " recipients");
return ['status' => true, 'message' => 'Mail sent successfully', 'response' => $res];
} else {
CLI::write("Mail sent failed to " . count($to_mail) . " recipients");
return ['status' => false, 'message' => 'Mail sent failed', 'response' => $res];
}
}
@ -5390,14 +5431,17 @@ class PolicyTransactionController extends BaseController
Policy No : {$policy_no}";
$contactPersonEmail = trim((string) ($data['contact_person_email'] ?? ''));
$to_mail = array_merge(
array_column($heads, 'email'),
array_column($admins, 'email'),
array_column($buisness_team, 'email'),
[$sales_person_mail]
[$sales_person_mail],
$contactPersonEmail !== '' ? [$contactPersonEmail] : []
);
$to_mail = array_unique($to_mail);
$to_mail = array_values(array_unique(array_filter($to_mail)));
$this->myLogger->logme("error", "Selected To Address : " . json_encode($to_mail));

View File

@ -3321,78 +3321,71 @@ class TicketController extends BaseController
}
}
public function getPoliciesbyEmpID()
public function getPoliciesbyEmpID()
{
$received_data = $this->request->getPost();
$ticket_type_id = $this->request->getPost('ticket_type_id') ?? null;
$client_id = $this->request->getPost('client_id') ?? null;
$emp_id = $received_data['emp_id'];
$emp_id = (int) ($this->request->getPost('emp_id') ?? 0);
$ticket_type_id = (int) ($this->request->getPost('ticket_type_id') ?? 0);
$client_id = (int) ($this->request->getPost('client_id') ?? 0);
// Get all client policy IDs for the given employee
if ($ticket_type_id == 1) {
//get the self data for get the all policy list aginst the emp_code
$self_data = $this->employeeModel->where('is_active', 1)->where('id', $emp_id)->first();
$db = db_connect();
$builder = $db->table('employees e');
$builder->select('ep.*');
$builder->join('employee_polices ep', 'e.id = ep.employee_id');
$builder->join('client_policy cp', 'cp.id = ep.client_policy_id AND cp.policy_type_id IN (2,3,4,5)');
$builder->where('e.is_active', 1);
$builder->where('ep.is_active', 1);
$builder->where('e.emp_code', $self_data['emp_code']);
if(!empty($client_id)){
$builder->where('e.client_id', $client_id);
}
$builder->groupBy('client_policy_id');
$query = $builder->get();
$policies = $query->getResultArray();
} else {
$policies = $this->employeePolicyModel
->select('client_policy_id')
->where('employee_id', $emp_id)
->where('is_active', 1)
->where('status', 'active')
->findAll();
if ($emp_id <= 0) {
return $this->respond(['status' => false, 'message' => 'Invalid Employee']);
}
// Return empty if no policies found
if (empty($policies)) {
return [];
$policyTypeMap = [
1 => [2, 3, 4, 5], // GMC
2 => [1], // GPA
3 => [6], // EDLI
4 => [7], // GTLI
72 => [72], // OPD
];
$db = db_connect();
$builder = $db->table('employee_polices ep');
$builder->select('ep.client_policy_id');
$builder->join('employees e', 'e.id = ep.employee_id');
$builder->join('client_policy cp', 'cp.id = ep.client_policy_id');
$builder->where('ep.employee_id', $emp_id);
$builder->where('ep.is_active', 1);
$builder->whereIn('ep.status', ['active', 'expired']);
$builder->where('e.is_active', 1);
if ($client_id > 0) {
$builder->where('e.client_id', $client_id);
}
// Extract client policy IDs into an array
$policy_ids = array_column($policies, 'client_policy_id');
// Fetch all policy names and IDs in one query
if (isset($policyTypeMap[$ticket_type_id])) {
$builder->whereIn('cp.policy_type_id', $policyTypeMap[$ticket_type_id]);
}
$policyRows = $builder->groupBy('ep.client_policy_id')->get()->getResultArray();
$policy_ids = array_values(array_unique(array_column($policyRows, 'client_policy_id')));
if (empty($policy_ids)) {
return $this->respond(['status' => false, 'message' => 'Policy Not Found']);
}
$policyNameandID = $this->clientPolicyModel
->select('
CONCAT(policy_type.policy_type, "-", client_policy.policy_no) as client_policy_name,
client_policy.id as client_policy_value,
client_policy.policy_type_id,
client_policy.policy_no,
insurers.id as insurer_id,
insurers.name as insurer_name,
tpa.name as tpa_name,
tpa.id as tpa_id,
')
CONCAT(policy_type.policy_type, "-", client_policy.policy_no) as client_policy_name,
client_policy.id as client_policy_value,
client_policy.policy_type_id,
client_policy.policy_no,
insurers.id as insurer_id,
insurers.name as insurer_name,
tpa.name as tpa_name,
tpa.id as tpa_id
')
->join('policy_type', 'policy_type.id = client_policy.policy_type_id AND policy_type.is_active = 1')
->join('insurers', 'insurers.id = client_policy.insurer_id AND insurers.is_active = 1', 'left')
->join('tpa', 'tpa.id = client_policy.tpa_id AND tpa.is_active = 1', 'left')
// ->where('client_policy.policy_status', 1)
->whereIn('client_policy.id', $policy_ids)
->findAll();
// dd($policyNameandID);
if ($policyNameandID){
->findAll();
return $this->respond(['status'=>true,'policy_data'=> $policyNameandID]);
}else{
return $this->respond(['status'=>false,'message'=> "Policy Not Found"]);
if (!empty($policyNameandID)) {
return $this->respond(['status' => true, 'policy_data' => $policyNameandID]);
}
return $this->respond(['status' => false, 'message' => 'Policy Not Found']);
}
public function getCheckListAndConvertArrayToString($ticket_data)

View File

@ -0,0 +1,39 @@
<?php
namespace App\Debug;
use App\Filters\Cors;
use CodeIgniter\Debug\ExceptionHandler;
use CodeIgniter\Debug\ExceptionHandlerInterface;
use CodeIgniter\HTTP\RequestInterface;
use CodeIgniter\HTTP\ResponseInterface;
use Config\Exceptions;
use Throwable;
/**
* Ensures CORS headers are present on uncaught exception responses.
*
* The global Cors filter's after() method is not invoked when an exception
* bypasses the normal filter pipeline.
*/
class CorsExceptionHandler implements ExceptionHandlerInterface
{
protected ExceptionHandler $handler;
public function __construct(Exceptions $config)
{
$this->handler = new ExceptionHandler($config);
}
public function handle(
Throwable $exception,
RequestInterface $request,
ResponseInterface $response,
int $statusCode,
int $exitCode
): void {
(new Cors())->after($request, $response);
$this->handler->handle($exception, $request, $response, $statusCode, $exitCode);
}
}

View File

@ -355,9 +355,13 @@ class Cors implements FilterInterface
return $response;
}
// For non-OPTIONS requests, don't return a response
// Let the request proceed to the controller
// CORS headers will be added in after() method
// Apply CORS headers on the shared response before other before-filters run.
// When a before-filter returns early (4xx/5xx), CodeIgniter skips after-filters,
// so relying only on after() leaves error responses without CORS headers.
if (! empty($origin) && $this->isOriginAllowed($origin)) {
$this->addCorsHeaders(Services::response(), $request, $origin, false);
}
return null;
}

View File

@ -3,6 +3,7 @@
namespace App\Models;
use CodeIgniter\Model;
use Config\BdsConfig;
class BdsPlacementModel extends Model
{
@ -115,8 +116,31 @@ class BdsPlacementModel extends Model
return $data;
}
private function addBusinessDays(int $days, ?string $fromDate = null): string
{
$date = new \DateTime($fromDate ?? 'today');
$added = 0;
while ($added < $days) {
$date->modify('+1 day');
if ((int) $date->format('N') < 6) {
$added++;
}
}
return $date->format('Y-m-d');
}
public function getLeadInstallmentDetails()
{
/** @var BdsConfig $config */
$config = config(BdsConfig::class);
// print_r($config);die();
if (!$config->shouldFetchInstallmentRemindersToday()) {
return [];
}
$heads = $this->db->table('user_profiles')
->select('email')->where(['role' => 5, 'is_active' => 1])
->get()->getResultArray();
@ -132,17 +156,30 @@ class BdsPlacementModel extends Model
->get()->getResultArray();
$builder = $this->db->table("lead_installment_payment_details lipd")
->select("lipd.*, COALESCE(ct.client_name, leads.client_name) as client_name, COALESCE(ct.short_name, leads.client_short_name) as short_name, COALESCE(cb.branch_name, leads.branch_name) as branch_name, leads.salse_person_id, cp.policy_no")
->select("lipd.*, COALESCE(ct.client_name, leads.client_name) as client_name, COALESCE(ct.short_name, leads.client_short_name) as short_name, COALESCE(cb.branch_name, leads.branch_name) as branch_name, leads.salse_person_id, leads.contact_person_email, cp.policy_no")
->join("leads", "leads.id = lipd.lead_id")
->join("clients ct", "ct.id = leads.client_id", "left")
->join("client_branch cb", "cb.id = leads.client_branch_id", "left")
->join("client_policy cp", "cp.id = leads.source_policy_id", "left")
->where("lipd.is_active", 1)
->where("lipd.utr_no IS NULL")
->where("lipd.payment_date", date('Y-m-d', strtotime('+15 days')));
->where("lipd.utr_no IS NULL OR lipd.utr_no = ''");
$targetPaymentDate = $this->addBusinessDays($config->installmentReminderBusinessDays);
// print_r($targetPaymentDate);die();
if ($config->installmentReminderFetchOverduePendingUtr) {
$builder->groupStart()
->where('lipd.payment_date', $targetPaymentDate)
->orWhere('lipd.payment_date <', date('Y-m-d'))
->groupEnd();
} else {
$builder->where('lipd.payment_date', $targetPaymentDate);
}
$data = $builder->get()->getResultArray();
// print_r($this->db->getLastQuery()->getQuery());die();
foreach ($data as &$row) {
$sales_person_ids = json_decode($row['salse_person_id'], true);
$sales_person_id = $sales_person_ids[0] ?? null;

View File

@ -176,6 +176,10 @@ class LeadsModel extends Model
->join('lead_files', 'leads.id = lead_files.lead_id AND lead_files.type = 2 AND lead_files.is_active = 1', 'left')
->where('leads.is_active', 1);
if (get_role_id() == STAFF_ROLE_ID) {
$data->where('leads.created_by', get_session_userid());
}
if (! empty($where)) {
$data->where($where);
}

View File

@ -202,7 +202,7 @@ input:checked + .slider-branch-contact:before {
<label for="state">State<span class="text-danger">*</span></label>
<select class="form-control" id="state" name="state" required>
<option value="">Select State</option>
<?php foreach($state as $value) { ?>
<?php foreach($state ?? [] as $value) { ?>
<option value="<?= $value['id'] ?>"><?= $value['state'] ?></option>
<?php } ?>
</select>
@ -265,8 +265,8 @@ input:checked + .slider-branch-contact:before {
<label for="first_name">Name<span class="text-danger">*</span></label>
<input value="" type="text" class="form-control" placeholder="Enter Contact Name"
name="name[]" id="name" required
data-parsley-pattern="^[A-Za-z\s]+$"
data-parsley-pattern-message="Contact name may contain only letters and spaces.">
data-parsley-pattern="^[A-Za-z\s.]+$"
data-parsley-pattern-message="Contact name may contain only letters, spaces, and periods.">
</div>
<div class="form-group col-md-6">
<label for="designation">Designation<span class="text-danger">*</span></label>
@ -773,8 +773,8 @@ function appendContactHtml(contact = false, reset = false) {
<div class="form-group col-md-6">
<label for="${uniqueId}_first_name">Name<span class="text-danger">*</span></label>
<input value="${contact !== undefined && contact !== false ? contact.name : ''}" type="text" class="form-control" placeholder="Enter Contact Name" name="name[]" id="${uniqueId}_name" required
data-parsley-pattern="^[A-Za-z\s]+$"
data-parsley-pattern-message="Contact name may contain only letters and spaces.">
data-parsley-pattern="^[A-Za-z\\s.]+$"
data-parsley-pattern-message="Contact name may contain only letters, spaces, and periods.">
</div>
<div class="form-group col-md-6">
<label for="${uniqueId}_designation">Designation<span class="text-danger">*</span></label>

View File

@ -37,9 +37,12 @@
font-weight: 500;
color: #333;
justify-content: flex-end;
margin-right: 40px;
}
.expired-policies-toggle-wrap {
padding-bottom: 10px;
}
.switch-label input {
opacity: 0;
width: 0;
@ -48,7 +51,8 @@
.switch-label .slider,
.switch-label .slider_blue {
pointer-events: none;
cursor: pointer;
flex-shrink: 0;
}
.slider,
@ -142,19 +146,15 @@ input:checked + .slider_blue::before {
<button type="button" id="BtnAdd" class="btn btn-primary waves-effect waves-light btnAdd btn-sm" style="position: relative;right: 10px;"><span class="mdi mdi-plus-box-outline" aria-hidden="true" style="padding: 5px 10px;"></span>Add Policy</button>
<button type="button" id="BtnAddSuccess" class="btn btn-success waves-effect waves-light BtnAddSuccess btn-sm" onclick="showModal()"><span class="mdi mdi-plus-box-outline" aria-hidden="true" style="padding: 5px 10px;"></span>Add Policy From Opportunities</button>
</div>
<br>
<div class="" style="padding-bottom: 10px; position: absolute;
right: 0;">
<label class="switch-label">
<input type="checkbox" id="chk-show-expired">
<span class="slider"></span>
<span class="switch-text">Expired Policies</span>
</label>
</div>
<div class="table-responsive" id="table_list">
<div class="expired-policies-toggle-wrap d-flex justify-content-end">
<label class="switch-label" for="chk-show-expired">
<input type="checkbox" id="chk-show-expired">
<span class="slider"></span>
<span class="switch-text">Expired Policies</span>
</label>
</div>
<table data-custom-table-css="table" class="table table-borderless table mb-0 w-100 nowrap" id="table-client-policy">
<thead class="">
<tr style="color:black !important;">
@ -177,8 +177,8 @@ input:checked + .slider_blue::before {
<div class="col-12">
<div class="card-body">
<div class="row float-right" style="position: relative; bottom: 20px; right: 13px;">
<button type="button" id="btnPolicyBack" class="btn btn-primary waves-effect waves-light btn-sm btnBack btn-sm"><span class="mdi mdi-format-list-bulleted" aria-hidden="true" style="padding: 5px 10px;"></span>Back To List</button>
<div class="d-flex justify-content-end mb-2" style="padding-right: 13px;">
<button type="button" id="btnPolicyBack" class="btn btn-primary waves-effect waves-light btn-sm btnBack"><span class="mdi mdi-format-list-bulleted" aria-hidden="true" style="padding: 5px 10px;"></span>Back To List</button>
</div>
<hr>
@ -1546,14 +1546,8 @@ input:checked + .slider_blue::before {
return isNaN(parsed.getTime()) ? null : parsed;
}
var policyMonthNames = ['Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec'];
function formatPolicyDisplayDate(inputDate) {
var d = parsePolicyDate(inputDate);
if (!d) {
return (inputDate && String(inputDate).trim() !== '') ? String(inputDate) : '';
}
return d.getDate() + '/' + policyMonthNames[d.getMonth()] + '/' + d.getFullYear();
return formatPolicyFormDate(inputDate);
}
function formatPolicyFormDate(inputDate) {
@ -2903,7 +2897,7 @@ $(document).ready(function () {
$('#table-client-policy').DataTable().clear().destroy();
}
$('#table-client-policy tbody').html(policyTable); // replace tbody content
$('#policy_table').html(policyTable);
const policyTableInstance = $('#table-client-policy').DataTable({
paging: true,

View File

@ -2017,7 +2017,7 @@ body[data-sidebar-size="condensed"] .footer {
<li>
<a href="<?= base_url('/employee/retail-endorsement-list') ?>">Retail Endorsement</a>
</li>
<?php if(in_array(get_role_id(), [ACCOUNT_MANAGER_ROLE_ID])) { ?>
<?php if(in_array(get_role_id(), [ACCOUNT_MANAGER_ROLE_ID, ADMIN_ROLE_ID, HEAD_ROLE_ID])) { ?>
<li>
<a href="<?= base_url('/employee/tpaReportsDashboard') ?>">TPA Reports</a>
</li>
@ -2218,7 +2218,7 @@ body[data-sidebar-size="condensed"] .footer {
<ul class="nav-third-level">
<?php if (
in_array(POS_TEAM_ID, user_team()) // Case 4: Role Any + Must be in POS Team (global guard)
&& (
||(
in_array(get_role_id(), [1, 5]) // Case 1: Role 1 or 5
|| (in_array(get_role_id(), [4]) && in_array(FINANCE_TEAM_ID, user_team())) // Case 2: Role 4 + Finance Team
|| in_array(MANAGEMENT_TEAM_ID, user_team()) // Case 3: Role Any + Management Team

View File

@ -614,7 +614,7 @@
<label for="listed_insurers">Shortlisted Insurers</label>
<select class="form-control" id="listed_insurers" name="listed_insurers" multiple>
<option value=""></option>
<?php foreach ($insurer_branch as $value) { ?>
<?php foreach ($insurer_branch ?? [] as $value) { ?>
<option value="<?= $value['id'] . '-' . $value['insurer_id'] ?>" data-id="<?= $value['insurer_id'] ?>">
<?= $value['insurer_name'] . '-' . $value['branch_code'] ?>
</option>
@ -779,8 +779,8 @@
<label for="tpa"> TPA <span id="tpa_danger"class="text-danger"></span></label>
<select class="form-control" id="tpa" name="tpa" >
<option value="" selected>Select TPA</option>
<?php foreach ($tpa as $value) { ?>
<option value="<?= $value['id'] . '-' . $value['tpa_id'] ?>">
<?php foreach ($tpa ?? [] as $value) { ?>
<option value="<?= $value['id'] . '-' . $value['tpa_id'] ?>">f
<?= $value['tpa_short_name'] . '-' . $value['branch_code'] ?>
</option>
<?php } ?>
@ -2115,7 +2115,7 @@
$(this).prop('checked', false);
return;
}else{
$('#insurer_id').val(insurer)
syncInsurerIdFromLeader();
}
$('[name="calc_policy_issue_date[]"]').each(function () {
@ -2173,6 +2173,8 @@
}
syncInsurerIdFromLeader();
});
$(document).on('change', 'select[name="relationship[]"]', function() {
@ -2230,7 +2232,7 @@
return false;
}
$('#insurer_id').val(insurer)
syncInsurerIdFromLeader();
if (!policy_type_id || !client_id) {
$(this).val('').select2();
@ -3472,6 +3474,27 @@
$('#co_ter_premium_' + input).val(cotep.toFixed(2));
}
function syncInsurerIdFromLeader() {
if ($('#cop_yes').is(':checked')) {
let leaderInsurer = '';
$('input[type="checkbox"][name="co_share_type[]"]:checked').each(function() {
let uniqueid = $(this).data('id');
let insurer = $('#follow_insurer_id_' + uniqueid).val();
if (insurer) {
leaderInsurer = insurer;
}
});
if (leaderInsurer) {
$('#insurer_id').val(leaderInsurer);
}
} else {
let insurer = $('#follow_insurer_id_1').val();
if (insurer) {
$('#insurer_id').val(insurer);
}
}
}
function select_leader_disable_premium_amt(input, value) {
if ($(input).is(':checked')) {
@ -3508,6 +3531,8 @@
$('input[name="co_ter_premium[]"]').removeClass('readonly-select');
}
syncInsurerIdFromLeader();
}
function select_leader_disable_premium_amt_in_edit() {
@ -3553,6 +3578,8 @@
}
}
});
syncInsurerIdFromLeader();
}
function validateRange(input) {
@ -4113,6 +4140,10 @@
co_share_type.forEach((value, index) => {
formData.append(`co_share_type[${index}]`, value);
});
syncInsurerIdFromLeader();
formData.set('insurer_id', $('#insurer_id').val());
//covert date to mysql format
// alert(formData.get('policy_issue_date'));
@ -4490,6 +4521,8 @@
// $(this).val(''); // Clear value
// console.log('Input cleared:', $(this).attr('name')); // Log cleared input
// });
syncInsurerIdFromLeader();
} else {
$('#add_more_row').addClass('d-none');
@ -4506,6 +4539,8 @@
// $(this).val(''); // Clear value
// console.log('Input cleared:', $(this).attr('name')); // Log cleared input
// });
syncInsurerIdFromLeader();
}
});
@ -4933,7 +4968,7 @@
newCell = `<td>
<select class="form-control follow_insurer" data-count="${insurerCount}" id="follow_insurer_id_${insurerCount}" name="follow_insurer_id[]" onchange="getCDAccountNumber(this)" required>
<option value="" selected>Select Insurer</option>
<?php foreach ($insurer_branch as $value) { ?>
<?php foreach ($insurer_branch ?? [] as $value) { ?>
<option value="<?= $value['id'] . '-' . $value['insurer_id'] ?>" data-id="<?= $value['insurer_id'] ?>" data-bid="<?= $value['id'] ?>" data-ic="<?= $value['category'] ?>">
<?= $value['insurer_name'] . '-' . $value['branch_code'] ?>
</option>
@ -5078,7 +5113,7 @@
newCell = `<td>
<select class="form-control follow_insurer" data-language="1" data-count="${insurerCount}" id="follow_insurer_id_${insurerCount}" name="follow_insurer_id[]" onchange="getCDAccountNumber(this)" required>
<option value="" selected>Select Insurer</option>
<?php foreach ($insurer_branch as $value) { ?>
<?php foreach ($insurer_branch ?? [] as $value) { ?>
<option value="<?= $value['id'] . '-' . $value['insurer_id'] ?>" data-id="<?= $value['insurer_id'] ?>" data-bid="<?= $value['id'] ?>" data-ic="<?= $value['category'] ?>">
<?= $value['insurer_name'] . '-' . $value['branch_code'] ?>
</option>
@ -5399,6 +5434,8 @@
$('.follow_insurer').prop('required', true);
}
syncInsurerIdFromLeader();
console.log('#################################### END Remove Insurer Column ####################################');
}
@ -5676,6 +5713,8 @@
// $('input:disabled, select:disabled, textarea:disabled').addClass('readonly-color');
syncInsurerIdFromLeader();
console.log('#################################### END Populate Table ####################################');
}

View File

@ -767,10 +767,7 @@ async function fetchActivities(isLoadMore = false) {
.sort((a, b) => Number(b.activity_id) - Number(a.activity_id))
.map(a => {
let formattedCreatedDate = a.created_at
? new Date(a.created_at).toLocaleString('en-US', {
month: 'short', day: 'numeric', year: 'numeric',
hour: '2-digit', minute: '2-digit', hour12: true
})
? formatIndianDate(a.created_at)
: 'N/A';
let displayNote = 'N/A';
@ -910,14 +907,7 @@ function renderCard(opps) {
let opp_status_value = o.status?.replace(/[-_']/g, ' ').toUpperCase();
let formattedDate = new Date(o.created_at).toLocaleString('en-US', {
month: 'short',
day: 'numeric',
year: 'numeric',
hour: '2-digit',
minute: '2-digit',
hour12: true
});
let formattedDate = formatIndianDate(o.created_at);
// ${o.client_short_name}
return `
<div class="opportunities-list" id="leadOpportunitiesList">
@ -971,14 +961,7 @@ function renderTimeline(acts) {
const icon = activityIcons[a.activity_type] || "";
const formattedType = a.activity_type?.toUpperCase() || "";
const formattedDate = new Date(a.scheduled_date).toLocaleString('en-US', {
month: 'short',
day: 'numeric',
year: 'numeric',
hour: '2-digit',
minute: '2-digit',
hour12: true
});
const formattedDate = formatIndianDate(a.scheduled_date);
// Then use the variable in your HTML:
// <span style="font-size:11px; color:#999">${formattedDate}</span>
@ -1406,14 +1389,16 @@ function formatIndianDate(value) {
const date = new Date(String(value).replace(' ', 'T'));
if (Number.isNaN(date.getTime())) return value;
return date.toLocaleString('en-IN', {
day: '2-digit',
month: '2-digit',
year: 'numeric',
hour: '2-digit',
minute: '2-digit',
hour12: true
}).replace(',', '').toUpperCase();
const day = String(date.getDate()).padStart(2, '0');
const month = String(date.getMonth() + 1).padStart(2, '0');
const year = date.getFullYear();
let hours = date.getHours();
const minutes = String(date.getMinutes()).padStart(2, '0');
const seconds = String(date.getSeconds()).padStart(2, '0');
const ampm = hours >= 12 ? 'PM' : 'AM';
hours = hours % 12 || 12;
return `${day}/${month}/${year} ${String(hours).padStart(2, '0')}:${minutes}:${seconds} ${ampm}`;
}
function downloadCsv(filename, rows) {
@ -1473,7 +1458,7 @@ function initActivityExportDateRangePicker() {
opens: 'left',
drops: 'down',
locale: {
format: 'DD-MM-YYYY',
format: 'DD/MM/YYYY',
applyLabel: 'Generate Excel',
cancelLabel: 'Cancel'
},

View File

@ -1176,10 +1176,7 @@ async function fetchLeads(isLoadMore = false) {
.sort((a, b) => Number(b.lead_id) - Number(a.lead_id))
.map(l => {
let formattedCreatedDate = l.created_at
? new Date(l.created_at).toLocaleString('en-US', {
month: 'short', day: 'numeric', year: 'numeric',
hour: '2-digit', minute: '2-digit', hour12: true
})
? formatIndianDate(l.created_at)
: 'N/A';
return `
@ -1308,14 +1305,7 @@ function renderCard(opps) {
let formattedDate = new Date(o.created_at).toLocaleString('en-US', {
month: 'short',
day: 'numeric',
year: 'numeric',
hour: '2-digit',
minute: '2-digit',
hour12: true
});
let formattedDate = formatIndianDate(o.created_at);
// ${o.client_short_name}
return `
<div class="opportunities-list" id="leadOpportunitiesList">
@ -1368,14 +1358,7 @@ function renderTimeline(acts) {
const icon = activityIcons[a.activity_type] || "";
const formattedType = a.activity_type?.toUpperCase() || "";
const formattedDate = new Date(a.scheduled_date).toLocaleString('en-US', {
month: 'short',
day: 'numeric',
year: 'numeric',
hour: '2-digit',
minute: '2-digit',
hour12: true
});
const formattedDate = formatIndianDate(a.scheduled_date);
// Then use the variable in your HTML:
// <span style="font-size:11px; color:#999">${formattedDate}</span>
@ -2568,14 +2551,16 @@ function formatIndianDate(value) {
const date = new Date(String(value).replace(' ', 'T'));
if (Number.isNaN(date.getTime())) return value;
return date.toLocaleString('en-IN', {
day: '2-digit',
month: '2-digit',
year: 'numeric',
hour: '2-digit',
minute: '2-digit',
hour12: true
}).replace(',', '').toUpperCase();
const day = String(date.getDate()).padStart(2, '0');
const month = String(date.getMonth() + 1).padStart(2, '0');
const year = date.getFullYear();
let hours = date.getHours();
const minutes = String(date.getMinutes()).padStart(2, '0');
const seconds = String(date.getSeconds()).padStart(2, '0');
const ampm = hours >= 12 ? 'PM' : 'AM';
hours = hours % 12 || 12;
return `${day}/${month}/${year} ${String(hours).padStart(2, '0')}:${minutes}:${seconds} ${ampm}`;
}
function downloadCsv(filename, rows) {
@ -2635,7 +2620,7 @@ function initLeadExportDateRangePicker() {
opens: 'left',
drops: 'down',
locale: {
format: 'DD-MM-YYYY',
format: 'DD/MM/YYYY',
applyLabel: 'Generate Excel',
cancelLabel: 'Cancel'
},

View File

@ -819,14 +819,31 @@
});
}
function appendPolicyDropdown(data) {
function isGpaFormPolicyType(ticket_type, item) {
if (ticket_type == 2) {
return item.policy_type_id == 1;
}
if (ticket_type == 3) {
return item.policy_type_id == 6;
}
if (ticket_type == 4) {
return item.policy_type_id == 7;
}
return ticket_type != 1 && item.policy_type_id != 2;
}
// var ticket_type = $('#ticket_type').val();
function appendPolicyDropdown(data) {
hiddenData = $("#empIDHidden").val();
hiddenData = JSON.parse(hiddenData);
console.log("second function is called : ", data);
let ticket_type = $('#ticket_type_id').val();
if ($('#emp_client_policy').hasClass('select2-hidden-accessible')) {
$('#emp_client_policy').select2('destroy');
}
$('#emp_client_policy').removeClass('readonly-select');
$('#emp_client_policy').empty();
$('#emp_client_policy').append($('<option>', {
value: '',
@ -834,47 +851,46 @@
}));
var policyAppendCount = 0;
console.log("got data from backend ",data);
let policyCount = 1;
console.log("got data from backend ", data);
$.each(data, function(index, item) {
// console.log("item len",item.length);
if (ticket_type != 1 && item.policy_type_id != 2) {
$('#emp_client_policy').append($('<option>', {
value: item.client_policy_value,
text: item.client_policy_name,
'data-insurerid' : item.insurer_id ?? "",
'data-tpaid' : item.tpa_id ?? "",
'data-insurername' : item.insurer_name ?? "",
'data-tpaname' : item.tpa_name ?? "",
}));
console.log("policy count from loop","");
$("#policy_no").val("");
if (policyCount == 1){
console.log("policy count from if",item.policy_no);
$("#policy_no").val(item.policy_no);
}else{
console.log("policy count from greter if ","");
$("#policy_no").val("");
}
policyCount++;
policyAppendCount++;
if (hiddenData['searchType'] != null && hiddenData['searchType'] != "" && hiddenData['policy_id'] != null && hiddenData['policy_id'] != "") {
// $('#emp_client_policy').select2();
$("#emp_client_policy").select2();
$('#emp_client_policy').val(hiddenData['policy_id']).addClass('readonly-select').select2('destroy').trigger("change");
} else {
// $('#emp_client_policy').append($('<option>', {
// value: item.client_policy_value,
// text: item.client_policy_name
// }));
}
if (!isGpaFormPolicyType(ticket_type, item)) {
return;
}
})
$('#emp_client_policy').append($('<option>', {
value: item.client_policy_value,
text: item.client_policy_name,
'data-insurerid': item.insurer_id ?? "",
'data-tpaid': item.tpa_id ?? "",
'data-insurername': item.insurer_name ?? "",
'data-tpaname': item.tpa_name ?? "",
'data-policy-no': item.policy_no ?? ""
}));
policyAppendCount++;
});
$('#emp_client_policy').select2();
if (policyAppendCount == 0) {
$("#policy_no").val("");
toastr.warning("No Policies found for the Employee", "Warning");
return;
}
let selectedPolicyId = '';
if (hiddenData['searchType'] != null && hiddenData['searchType'] != "" && hiddenData['policy_id'] != null && hiddenData['policy_id'] != "") {
let policyId = String(hiddenData['policy_id']);
if ($('#emp_client_policy option[value="' + policyId + '"]').length) {
selectedPolicyId = policyId;
$('#emp_client_policy').addClass('readonly-select');
}
}
if (!selectedPolicyId) {
selectedPolicyId = $('#emp_client_policy option:not([value=""])').first().val();
}
$('#emp_client_policy').val(selectedPolicyId).trigger('change');
}
// $('#emp_client_policy').select2();
$("#emp_client_policy").on('change', function() {

View File

@ -887,17 +887,17 @@
<div class="form-group col-md-3">
<label for="policy_start_date">Policy Start Date <span class="text-danger">*</span></label>
<input type="text" class="form-control" id="policy_start_date" name="policy_start_date" placeholder="DD/MM/YYY" value="<?= isset($lead_data['policy_start_date']) ? date('d-m-Y', strtotime($lead_data['policy_start_date'])) : "" ?>" required>
<input type="text" class="form-control" id="policy_start_date" name="policy_start_date" placeholder="DD/MM/YYYY" value="<?= isset($lead_data['policy_start_date']) ? date('d/m/Y', strtotime($lead_data['policy_start_date'])) : "" ?>" required>
</div>
<div class="form-group col-md-3">
<label for="policy_end_date">Policy End Date <span class="text-danger">*</span></label>
<input type="text" class="form-control" id="policy_end_date" name="policy_end_date" placeholder="DD/MM/YYY" value="<?= isset($lead_data['policy_end_date']) ? date('d-m-Y', strtotime($lead_data['policy_end_date'])) : "" ?>" required>
<input type="text" class="form-control" id="policy_end_date" name="policy_end_date" placeholder="DD/MM/YYYY" value="<?= isset($lead_data['policy_end_date']) ? date('d/m/Y', strtotime($lead_data['policy_end_date'])) : "" ?>" required>
</div>
<div class="form-group col-md-3">
<label for="placement_date">Placement Date</label>
<input type="text" class="form-control" id="placement_date" name="placement_date" placeholder="DD/MM/YYY" value="<?= isset($lead_data['placement_date']) ? date('d-m-Y', strtotime($lead_data['placement_date'])) : "" ?>">
<input type="text" class="form-control" id="placement_date" name="placement_date" placeholder="DD/MM/YYYY" value="<?= isset($lead_data['placement_date']) ? date('d/m/Y', strtotime($lead_data['placement_date'])) : "" ?>">
</div>
<div class="form-group col-md-3">
@ -945,7 +945,7 @@
<?php if (isset($lead_data['is_installment']) && $lead_data['is_installment'] == 0 || !isset($lead_data['is_installment'])) { ?>
<div class="form-group col-md-3">
<label for="payment_date">Payment Date</label>
<input type="text" class="form-control payment_date" id="payment_date" name="payment_date" placeholder="DD/MM/YYY" value="<?= isset($lead_data['payment_date']) ? date('d-m-Y', strtotime($lead_data['payment_date'])) : "" ?>">
<input type="text" class="form-control payment_date" id="payment_date" name="payment_date" placeholder="DD/MM/YYYY" value="<?= isset($lead_data['payment_date']) ? date('d/m/Y', strtotime($lead_data['payment_date'])) : "" ?>">
</div>
<div class="form-group col-md-3">
@ -962,8 +962,14 @@
<div id="installment_form_row">
<?= isset($lead_data['is_installment']) && $lead_data['is_installment'] == 1 && isset($lead_data['installment_data']) && !empty($lead_data['installment_data']) ? $lead_data['installment_data'] : '' ?>
</div>
<div id="placement_mail_section">
<hr>
<div class="form-group text-right m-b-0" id="save_placement_btn">
<button type="button" class="btn btn-success" onclick="savePlacementDataWithoutMail()">Save</button>
</div>
<div class="form-row">
<div class="form-group col-md-6">
@ -1018,6 +1024,7 @@
</div>
</div>
<hr>
<div class="form-row">
<div class="form-group col-md-12">
@ -1026,8 +1033,6 @@
</div>
</div>
</div>
<br>
<h4>Attachments Files</h4>
<hr>
@ -1037,6 +1042,7 @@
<?php echo isset($attachment_html) && !empty($attachment_html) ? $attachment_html : ''; ?>
</div>
</div>
</div>
<div class="form-group text-right m-b-0" id="send_mail_btn">
<button type="submit" class="btn btn-primary" onclick="constructURL(3)">Send Mail</button>
@ -1327,22 +1333,22 @@
const editor2 = Jodit.make("#internal_mail_content", editorConfig);
var placement_date_datePicker = flatpickr("#placement_date", {
dateFormat: "d-m-Y",
dateFormat: "d/m/Y",
allowInput: false,
});
var payment_date_datePicker = flatpickr("#payment_date", {
dateFormat: "d-m-Y",
dateFormat: "d/m/Y",
allowInput: false,
});
var policy_start_date_datePicker = flatpickr("#policy_start_date", {
dateFormat: "d-m-Y",
dateFormat: "d/m/Y",
allowInput: false,
});
var policy_end_date_datePicker = flatpickr("#policy_end_date", {
dateFormat: "d-m-Y",
dateFormat: "d/m/Y",
allowInput: false,
});
@ -4664,7 +4670,7 @@ function appendInsurerContact(data) {
$.each(data, function(index, item) {
$('#placement_to').append($('<option>', {
value: item.id,
value: item.contact_person_email,
text: item.contact_person_email
}));
@ -7046,7 +7052,7 @@ function appendMultiFileData(data) {
newhtml = `
<div class="form-group col-md-3">
<label for="payment_date">Payment Date</label>
<input type="text" class="form-control payment_date" id="payment_date" name="payment_date" placeholder="DD/MM/YYY">
<input type="text" class="form-control payment_date" id="payment_date" name="payment_date" placeholder="DD/MM/YYYY">
</div>
<div class="form-group col-md-3">
@ -7056,7 +7062,7 @@ function appendMultiFileData(data) {
`;
$('#not_installment').append(newhtml);
$('.payment_date').flatpickr({
dateFormat: 'd-m-Y',
dateFormat: 'd/m/Y',
});
} else {
toastr.error(response.message, 'Warning');
@ -7155,7 +7161,7 @@ function appendMultiFileData(data) {
$('#installment_form_row').append(html);
$('.payment_date').flatpickr({
dateFormat: 'd-m-Y',
dateFormat: 'd/m/Y',
});
}
@ -7312,7 +7318,7 @@ function appendMultiFileData(data) {
$(document).ready(function(){
setTimeout(function(){
$('.payment_date').flatpickr({
dateFormat: 'd-m-Y',
dateFormat: 'd/m/Y',
});
}, 2000)
})
@ -7560,6 +7566,107 @@ function appendMultiFileData(data) {
}
}
function constructPlacementDataPayload() {
var lead_id = $('#lead_id').val();
let placement_date = $('#placement_date').val();
let policy_end_date = $('#policy_end_date').val();
let policy_start_date = $('#policy_start_date').val();
let payment_date = $('#payment_date').val();
let is_cd = $("#is_cd_switch").is(":checked") ? 1 : 0;
let utr_no = $('#utr_no').val();
let premium_amount = $('#premium_amount').val();
let agreed_percentage = $('#agreed_percentage').val();
let total_amount = $('#total_amount').val();
let cd_amount = $('#cd_amount').val();
let no_of_installment = $('#no_of_installment').val();
let tpa_id = $('#tpa_id').val();
let acm_pk = $('#acm_id option:selected').data('id');
let is_installment = $("#is_installment_switch").is(":checked") ? 1 : 0;
if (!policy_start_date) {
toastr.warning('Policy Start Date is required.', 'Warning');
$('#policy_start_date').focus();
return false;
}
if (!policy_end_date) {
toastr.warning('Policy End Date is required.', 'Warning');
$('#policy_end_date').focus();
return false;
}
let installments = [];
$('#installment_form_row .form-row').each(function () {
let installment_amount = $(this).find('input[name="installment_amount[]"]').val();
let installment_payment_date = $(this).find('input[name="payment_date[]"]').val();
let installment_utr_no = $(this).find('input[name="utr_no[]"]').val();
let id = $(this).find('input[name="installment_primary_key[]"]').val();
let obj = {
lead_id: lead_id,
installment_amount: installment_amount,
payment_date: installment_payment_date,
utr_no: installment_utr_no
};
if (id != undefined && id != null && id != '') {
obj.id = id;
}
installments.push(obj);
});
return {
lead_id: lead_id,
placement_date: placement_date,
payment_date: payment_date,
policy_end_date: policy_end_date,
policy_start_date: policy_start_date,
is_cd: is_cd,
utr_no: utr_no,
premium_amount: premium_amount,
total_amount: total_amount,
cd_amount: cd_amount,
no_of_installment: no_of_installment,
is_installment: is_installment,
tpa_id: tpa_id,
acm_pk: acm_pk,
agreed_percentage: agreed_percentage,
installments: JSON.stringify(installments),
};
}
function savePlacementDataWithoutMail() {
let url = '<?= base_url('util/savePlacementDataWithoutMail') ?>';
let requestData = constructPlacementDataPayload();
if (requestData === false) {
return false;
}
$('.loader').fadeIn();
$('.loader-mask').fadeIn();
sendAjaxRequestForGlobal(url, 'POST', requestData, function(res) {
$('.loader').fadeOut();
$('.loader-mask').delay(350).fadeOut('slow');
if (res.status == true) {
toastr.success(res.message, 'Success');
$('.close').click();
} else {
toastr.warning(res.message || 'Failed to save placement data', 'Warning');
}
}, function(xhr, status, error) {
$('.loader').fadeOut();
$('.loader-mask').delay(350).fadeOut('slow');
console.error('Error saving placement data:', error);
console.error(xhr.responseText);
toastr.error('An error occurred while saving placement data.', 'Error');
});
}
function savePlacementDataAndValidateMemberDataFile(){
let url = '<?= base_url('util/savePlacementDataAndValidateMemberDataFile') ?>';
@ -7719,6 +7826,8 @@ function appendMultiFileData(data) {
}
function toggleButtons(status) {
$("#save_placement_btn").show();
if (status === "failed") {
$("#send_mail_btn").hide();
$("#validate_file_btn").show();

211
get-client-rm-api.md Normal file
View File

@ -0,0 +1,211 @@
# Get Client RM API
Returns Level 1 (Account Manager) and Level 2 (Head) contact details for a client.
**Controller:** `EmployeeRestController::getClientRM`
**Method:** `GET`
---
## Endpoint
```
GET /employeeRest/getClientRM
```
---
## Authentication
**JWT token is required.** This endpoint is available only in the authenticated route group.
| Filter | Description |
|--------|-------------|
| `ratelimit` | Rate limiting |
| `appSignature` | App signature validation |
| `authJWT` | JWT token validation |
### Required Headers
| Header | Required | Description |
|--------|----------|-------------|
| `App-Signature` | Yes | Must match server `APP_SIGNATURE` from `.env` |
| `Authorization` | Yes | JWT token in format `Bearer <token>` |
### Example Headers
```
App-Signature: <your_app_signature>
Authorization: Bearer <jwt_token>
```
---
## Query Parameters
| Parameter | Type | Required | Description |
|-----------|------|----------|-------------|
| `client_id` | string | Yes | MD5 hash of the client ID (32-character hex string) |
### Example Request
```
GET /employeeRest/getClientRM?client_id=5d41402abc4b2a76b9719d911017c592
```
**Note:** Pass the MD5 hash of the numeric client ID, not the raw client ID.
Example:
```
MD5(123) = 202cb962ac59075b964b07152d234b70
```
```
GET /employeeRest/getClientRM?client_id=202cb962ac59075b964b07152d234b70
```
---
## Success Response
**HTTP Status:** `200`
```json
{
"status": "success",
"code": 200,
"data": {
"level_1": [
{
"first_name": "John",
"email": "john@example.com",
"mobile": "9876543210"
}
],
"level_2": [
{
"first_name": "Jane",
"email": "jane@example.com",
"mobile": "9123456789"
}
]
}
}
```
---
## Response Fields
| Key | Type | Description |
|-----|------|-------------|
| `status` | string | `success` or `failed` |
| `code` | integer | Response code |
| `data.level_1` | array | Account Manager contact list |
| `data.level_2` | array | Head contact list |
| `first_name` | string | RM name |
| `email` | string | RM email |
| `mobile` | string | RM mobile number |
If no RM is assigned for a level, the corresponding array will be empty (`[]`).
---
## Level Mapping
| Response Key | Role | `client_rm.level` in DB |
|--------------|------|-------------------------|
| `level_1` | Account Manager | `3` |
| `level_2` | Head | `1` |
**Notes:**
- Only active records are returned (`client_rm.is_active = 1`).
- Manager (DB level `2`) is not included in this API.
- `level_1` can contain multiple Account Managers.
---
## Error Responses
### Missing `client_id`
**HTTP Status:** `200`
```json
{
"status": "failed",
"code": 400,
"message": "client_id is required"
}
```
### Missing Token
**HTTP Status:** `403`
```json
{
"status": 403,
"message": "Access Forbidden"
}
```
### Invalid or Expired Token
**HTTP Status:** `401`
```json
{
"status": 401,
"message": "Token is Invalid"
}
```
```json
{
"status": 401,
"message": "Token expired"
}
```
### Invalid App Signature
**HTTP Status:** `403`
```json
{
"status": false,
"message": "Forbidden: Invalid App Signature"
}
```
### Server Error
**HTTP Status:** `500`
```json
{
"status": "failed",
"code": 500,
"data": "Error message"
}
```
---
## Route Registration
Defined in `app/Config/Routes.php` (authenticated group only):
```php
$routes->group("employeeRest", ["filter" => ['GlobalPostFileUploadGuard', 'ratelimit', 'appSignature', 'authJWT']], function ($routes) {
$routes->get("getClientRM", "EmployeeRestController::getClientRM");
});
```
---
## Source
Implementation: `app/Controllers/EmployeeRestController.php``getClientRM()`

View File

@ -38,6 +38,13 @@
return false;
}
var name = (el.name || '').toLowerCase();
var id = (el.id || '').toLowerCase();
if (name === 'policy_holder_name' || id === 'policy_holder_name' ||
name === 'family_name[]' || name === 'client_name' || name === 'name') {
return false;
}
var type = (el.type || '').toLowerCase();
if (type === 'file' || type === 'checkbox' || type === 'radio' || type === 'password' || type === 'email' || type === 'url' || type === 'submit' || type === 'button' || type === 'reset') {
return false;