MERGE_UAT_BDS_CHANGES_LIVE
This commit is contained in:
commit
a218e5e248
@ -313,7 +313,7 @@ class Acl
|
||||
|
||||
// ===================== DEFAULT DENY (ZERO TRUST) =====================
|
||||
'#^/#' => [
|
||||
'roles' => [ADMIN_ROLE_ID],
|
||||
'roles' => [ADMIN_ROLE_ID, HEAD_ROLE_ID],
|
||||
'teams' => []
|
||||
],
|
||||
];
|
||||
|
||||
@ -604,12 +604,14 @@ $routes->group("/api", ["filter" => [ 'ratelimit' , 'authJWT']], function ($rout
|
||||
});
|
||||
|
||||
// Non-EB Claims External API v1
|
||||
$routes->group("api/v1", ["filter" => ['ratelimit', 'authJWT']], function ($routes) {
|
||||
$routes->group("employeeRest/api/v1", ["filter" => ['ratelimit', 'authJWT']], function ($routes) {
|
||||
$routes->group("non-eb-claim", function ($routes) {
|
||||
$routes->post('create', 'Api\NonEbClaimApiController::createClaim');
|
||||
$routes->post('list', 'Api\NonEbClaimApiController::listClaims');
|
||||
$routes->get('history/(:num)', 'Api\NonEbClaimApiController::claimHistory/$1');
|
||||
$routes->post('(:num)/upload-required-doc', 'Api\NonEbClaimApiController::uploadRequiredDoc/$1');
|
||||
$routes->get('statuses', 'Api\NonEbClaimApiController::listClaimStatuses');
|
||||
$routes->post('policies', 'Api\NonEbClaimApiController::listPolicies');
|
||||
});
|
||||
});
|
||||
|
||||
|
||||
@ -206,7 +206,11 @@ class NonEbClaimApiController extends BaseController
|
||||
return $this->respond(['status' => false, 'code' => 401, 'message' => 'Unauthorized'], 401);
|
||||
}
|
||||
|
||||
$body = $this->request->getJSON(true) ?? $this->request->getPost();
|
||||
$rawBody = $this->request->getBody();
|
||||
$isJson = str_contains($this->request->getHeaderLine('Content-Type'), 'application/json');
|
||||
$body = ($isJson || ($rawBody !== '' && $rawBody !== null))
|
||||
? (json_decode($rawBody, true) ?? $this->request->getPost())
|
||||
: $this->request->getPost();
|
||||
|
||||
// Validate minimal user-facing fields only
|
||||
$rules = [
|
||||
@ -363,7 +367,11 @@ class NonEbClaimApiController extends BaseController
|
||||
return $this->respond(['status' => false, 'code' => 401, 'message' => 'Unauthorized'], 401);
|
||||
}
|
||||
|
||||
$body = $this->request->getJSON(true) ?? [];
|
||||
try {
|
||||
$body = $this->request->getJSON(true) ?? [];
|
||||
} catch (\Throwable $e) {
|
||||
return $this->respond(['status' => false, 'code' => 400, 'message' => 'Invalid JSON body'], 400);
|
||||
}
|
||||
$page = max(1, (int)($body['page'] ?? 1));
|
||||
$per_page = min(100, max(1, (int)($body['per_page'] ?? 20)));
|
||||
$offset = ($page - 1) * $per_page;
|
||||
@ -402,7 +410,7 @@ class NonEbClaimApiController extends BaseController
|
||||
$builder->where('tm.is_active', 1);
|
||||
|
||||
// Filters
|
||||
if (!empty($body['client_id'])) $builder->where('tm.client_id', (int)$body['client_id']);
|
||||
if (!empty($body['client_id'])) $builder->where('md5(tm.client_id)', (int)$body['client_id']);
|
||||
if (!empty($body['insurer_id'])) $builder->where('tm.insurer_id', (int)$body['insurer_id']);
|
||||
if (!empty($body['policy_type_id'])) $builder->where('tm.policy_type_id', (int)$body['policy_type_id']);
|
||||
if (!empty($body['claim_status_id'])) $builder->where('tm.claim_status_id', (int)$body['claim_status_id']);
|
||||
@ -504,6 +512,99 @@ class NonEbClaimApiController extends BaseController
|
||||
], 200);
|
||||
}
|
||||
|
||||
/**
|
||||
* GET /api/v1/non-eb-claim/statuses
|
||||
* Returns Non-EB claim statuses (ticket_type = 50).
|
||||
*/
|
||||
public function listClaimStatuses()
|
||||
{
|
||||
$authUser = $this->getAuthUser();
|
||||
if (!$authUser) {
|
||||
return $this->respond(['status' => false, 'code' => 401, 'message' => 'Unauthorized'], 401);
|
||||
}
|
||||
|
||||
$statuses = $this->claimStatusModel
|
||||
->select('id, claim_status, display_name')
|
||||
->where('ticket_type', 50)
|
||||
->where('is_active', 1)
|
||||
->orderBy('id', 'ASC')
|
||||
->findAll();
|
||||
|
||||
return $this->respond([
|
||||
'status' => true,
|
||||
'code' => 200,
|
||||
'data' => $statuses,
|
||||
], 200);
|
||||
}
|
||||
|
||||
/**
|
||||
* POST /api/v1/non-eb-claim/policies
|
||||
* Returns Non-EB / Marine policies for a given client (md5) + branch.
|
||||
*
|
||||
* Body:
|
||||
* client_id string MD5 hash of the client's numeric id (required)
|
||||
* client_branch_id int client branch id (required)
|
||||
*/
|
||||
public function listPolicies()
|
||||
{
|
||||
$authUser = $this->getAuthUser();
|
||||
if (!$authUser) {
|
||||
return $this->respond(['status' => false, 'code' => 401, 'message' => 'Unauthorized'], 401);
|
||||
}
|
||||
|
||||
try {
|
||||
$body = $this->request->getJSON(true) ?? $this->request->getPost();
|
||||
} catch (\Throwable $e) {
|
||||
return $this->respond(['status' => false, 'code' => 400, 'message' => 'Invalid JSON body'], 400);
|
||||
}
|
||||
$client_id_md5 = trim($body['client_id'] ?? '');
|
||||
$client_branch_id = (int)($body['client_branch_id'] ?? 0);
|
||||
|
||||
$errors = [];
|
||||
if (empty($client_id_md5)) {
|
||||
$errors['client_id'] = 'client_id is required';
|
||||
} elseif (!preg_match('/^[a-f0-9]{32}$/i', $client_id_md5)) {
|
||||
$errors['client_id'] = 'client_id must be a valid MD5 hash';
|
||||
}
|
||||
if ($client_branch_id <= 0) {
|
||||
$errors['client_branch_id'] = 'client_branch_id is required';
|
||||
}
|
||||
if (!empty($errors)) {
|
||||
return $this->respond(['status' => false, 'code' => 400, 'message' => 'Input validation failed', 'errors' => $errors], 400);
|
||||
}
|
||||
|
||||
$db = db_connect();
|
||||
$builder = $db->table('client_policy cp');
|
||||
|
||||
$builder->select([
|
||||
'cp.id',
|
||||
'cp.policy_no',
|
||||
'cp.policy_type_id',
|
||||
'pt.policy_type AS policy_type_name',
|
||||
'cp.insurer_id',
|
||||
'i.name AS insurer_name',
|
||||
'i.short_name AS insurer_short_name',
|
||||
'DATE_FORMAT(cp.policy_start_date, "%d-%m-%Y") AS policy_start_date',
|
||||
'DATE_FORMAT(cp.policy_end_date, "%d-%m-%Y") AS policy_end_date',
|
||||
]);
|
||||
$builder->join('policy_type pt', 'pt.id = cp.policy_type_id', 'left');
|
||||
$builder->join('insurers i', 'i.id = cp.insurer_id AND i.is_active = 1', 'left');
|
||||
$builder->where('MD5(cp.client_id)', $client_id_md5);
|
||||
$builder->where('cp.client_branch_id', $client_branch_id);
|
||||
$builder->where('cp.is_active', 1);
|
||||
$builder->whereIn('pt.allocg', ['Non-EB', 'Marine']);
|
||||
$builder->orderBy('cp.id', 'DESC');
|
||||
|
||||
$policies = $builder->get()->getResultArray();
|
||||
|
||||
return $this->respond([
|
||||
'status' => true,
|
||||
'code' => 200,
|
||||
'total' => count($policies),
|
||||
'data' => $policies,
|
||||
], 200);
|
||||
}
|
||||
|
||||
public function uploadRequiredDoc(int $claim_id)
|
||||
{
|
||||
$authUser = $this->getAuthUser();
|
||||
|
||||
@ -1233,16 +1233,106 @@ class ClientController extends AdminController
|
||||
public function createClientKYCInfo()
|
||||
{
|
||||
$this->myLogger->logme('error', 'Create Client KYC function called');
|
||||
|
||||
$rules = [
|
||||
'other_docs_name' => [
|
||||
'label' => 'Documents Name',
|
||||
'rules' => 'permit_empty|regex_match[/^[a-zA-Z0-9_\- ]+$/]',
|
||||
'errors' => [
|
||||
'regex_match' => 'Document Name can only contain letters, numbers, hyphens, and underscores'
|
||||
]
|
||||
],
|
||||
$data = $this->request->getPost();
|
||||
$sanitized_data = sanitizeInputArrayAdvanced($data);
|
||||
$form_type = $sanitized_data['form_type'] ?? null;
|
||||
$client_id = $sanitized_data['client_id'] ?? null;
|
||||
$uploadFilePath = WRITEPATH . 'uploads/client_kyc_documents';
|
||||
$allowedExtensions = ['pdf', 'jpg', 'jpeg', 'png'];
|
||||
$maxFileSize = 5 * 1024 * 1024; // 5MB
|
||||
|
||||
if (empty($client_id)) {
|
||||
return $this->response->setStatusCode(400)->setJSON([
|
||||
'status' => false,
|
||||
'message' => 'Input validation failed',
|
||||
'code' => 400,
|
||||
'errors' => ['client_id' => 'Client is required']
|
||||
]);
|
||||
}
|
||||
|
||||
// Multi-row handler for Additional Documents form
|
||||
if ($form_type === 'others') {
|
||||
$docNames = $this->request->getPost('other_docs_name');
|
||||
if (!is_array($docNames)) {
|
||||
$docNames = [$docNames];
|
||||
}
|
||||
|
||||
$uploadedFiles = $this->request->getFileMultiple('file_name');
|
||||
if (!is_array($uploadedFiles)) {
|
||||
$uploadedFiles = [];
|
||||
}
|
||||
|
||||
$rows = max(count($docNames), count($uploadedFiles));
|
||||
$validationErrors = [];
|
||||
|
||||
if ($rows === 0) {
|
||||
return $this->response->setStatusCode(400)->setJSON([
|
||||
'status' => false,
|
||||
'message' => 'Input validation failed',
|
||||
'code' => 400,
|
||||
'errors' => ['file_name' => 'At least one file is required']
|
||||
]);
|
||||
}
|
||||
|
||||
for ($i = 0; $i < $rows; $i++) {
|
||||
$docName = trim((string)($docNames[$i] ?? ''));
|
||||
$fileObj = $uploadedFiles[$i] ?? null;
|
||||
|
||||
if ($docName === '') {
|
||||
$validationErrors["other_docs_name.$i"] = 'Documents Name is required';
|
||||
} elseif (!preg_match('/^[a-zA-Z0-9_\- ]+$/', $docName)) {
|
||||
$validationErrors["other_docs_name.$i"] = 'Document Name can only contain letters, numbers, hyphens, and underscores';
|
||||
}
|
||||
|
||||
if (!$fileObj || !$fileObj->isValid()) {
|
||||
$validationErrors["file_name.$i"] = 'KYC document file is required';
|
||||
} else {
|
||||
$extension = strtolower((string)$fileObj->getExtension());
|
||||
if (!in_array($extension, $allowedExtensions, true)) {
|
||||
$validationErrors["file_name.$i"] = 'Allowed file types: pdf, jpg, jpeg, png';
|
||||
}
|
||||
|
||||
if ((int)$fileObj->getSize() > $maxFileSize) {
|
||||
$validationErrors["file_name.$i"] = 'File size should not exceed 5MB';
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (!empty($validationErrors)) {
|
||||
return $this->response->setStatusCode(400)->setJSON([
|
||||
'status' => false,
|
||||
'message' => 'Input validation failed',
|
||||
'code' => 400,
|
||||
'errors' => $validationErrors
|
||||
]);
|
||||
}
|
||||
|
||||
foreach ($uploadedFiles as $index => $singleFile) {
|
||||
$fileName = file_Upload_for_lead($singleFile, $uploadFilePath, UPLOAD_EXT_KYC_DOCS);
|
||||
if (empty($fileName)) {
|
||||
return $this->respond(['status' => false, 'code' => 404, 'message' => 'Failed to upload KYC document'], 200);
|
||||
}
|
||||
|
||||
$insertData = [
|
||||
'client_id' => $client_id,
|
||||
'kyc_doc_type_id' => $sanitized_data['kyc_doc_type_id'] ?? 0,
|
||||
'other_docs_name' => trim((string)($docNames[$index] ?? '')),
|
||||
'file_name' => $fileName,
|
||||
'created_by' => get_session_userid()
|
||||
];
|
||||
|
||||
$insertID = $this->clientKYCDocsModel->insert($insertData);
|
||||
if (!$insertID) {
|
||||
return $this->respond(['status' => false, 'code' => 404, 'message' => 'Failed to upload KYC document'], 200);
|
||||
}
|
||||
}
|
||||
|
||||
$kycDocs = $this->generateKycOthersTable($client_id);
|
||||
return $this->respond(['status' => true, 'code' => 200, 'data' => $kycDocs], 200);
|
||||
}
|
||||
|
||||
// Backward compatible handler for primary KYC upload
|
||||
$rules = [
|
||||
'file_name' => [
|
||||
'rules' => 'uploaded[file_name]|max_size[file_name,5120]|ext_in[file_name,pdf,jpg,jpeg,png]',
|
||||
'errors' => [
|
||||
@ -1262,35 +1352,22 @@ class ClientController extends AdminController
|
||||
]);
|
||||
}
|
||||
|
||||
$data = $this->request->getPost();
|
||||
$sanitized_data = sanitizeInputArrayAdvanced($data);
|
||||
$form_type = $sanitized_data['form_type'] ?? null;
|
||||
$uploadFilePath = WRITEPATH . 'uploads/client_kyc_documents';
|
||||
|
||||
unset($data['file_name']);
|
||||
|
||||
$file = $this->request->getFile('file_name');
|
||||
|
||||
$fileName = file_Upload($file, $uploadFilePath, UPLOAD_EXT_KYC_DOCS);
|
||||
$fileName = file_Upload_for_lead($file, $uploadFilePath, UPLOAD_EXT_KYC_DOCS);
|
||||
|
||||
if (!empty($fileName)) {
|
||||
$sanitized_data['file_name'] = $fileName;
|
||||
}
|
||||
|
||||
$sanitized_data['created_by'] = get_session_userid();
|
||||
|
||||
$insertID = $this->clientKYCDocsModel->insert($sanitized_data);
|
||||
|
||||
if ($insertID) {
|
||||
if ($form_type === 'others') {
|
||||
$kycDocs = $this->generateKycOthersTable($sanitized_data['client_id']);
|
||||
} else {
|
||||
$kycDocs = $this->generateKycPrimaryTable($sanitized_data['client_id']);
|
||||
}
|
||||
return $this->respond(['status' => true, 'code' => 200, 'data' => $kycDocs, 'file_name' => $file
|
||||
], 200);
|
||||
} else {
|
||||
return $this->respond(['status' => false, 'code' => 404, 'message' => 'Failed to upload KYC document'], 200);
|
||||
$kycDocs = $this->generateKycPrimaryTable($client_id);
|
||||
return $this->respond(['status' => true, 'code' => 200, 'data' => $kycDocs, 'file_name' => $file], 200);
|
||||
}
|
||||
|
||||
return $this->respond(['status' => false, 'code' => 404, 'message' => 'Failed to upload KYC document'], 200);
|
||||
}
|
||||
|
||||
/** Edit Client KYC Documents V1 */
|
||||
@ -1327,7 +1404,7 @@ class ClientController extends AdminController
|
||||
|
||||
$file = $this->request->getFile('file_name');
|
||||
|
||||
$fileName = file_Upload($file, $uploadFilePath, UPLOAD_EXT_KYC_DOCS);
|
||||
$fileName = file_Upload_for_lead($file, $uploadFilePath, UPLOAD_EXT_KYC_DOCS);
|
||||
|
||||
if (!empty($fileName)) {
|
||||
$sanitized_data['file_name'] = $fileName;
|
||||
@ -1352,24 +1429,40 @@ class ClientController extends AdminController
|
||||
|
||||
public function deleteClientKycDocs($id = null)
|
||||
{
|
||||
$client_id = $this->request->getGet('client_id');
|
||||
$updateData = [
|
||||
'is_active' => 0,
|
||||
'updated_by' => get_session_userid()
|
||||
];
|
||||
|
||||
$delete = $this->clientKYCDocsModel->where('kyc_doc_type_id', $id)->delete();
|
||||
$delete = $this->clientKYCDocsModel->update($id, $updateData);
|
||||
if ($delete) {
|
||||
return $this->respond(['status' => true, 'code' => 200, 'id' => $id], 200);
|
||||
} else {
|
||||
return $this->respond(['status' => false, 'code' => 404, 'message' => 'no data found'], 200);
|
||||
$response = ['status' => true, 'code' => 200, 'id' => $id];
|
||||
if (!empty($client_id)) {
|
||||
$response['data'] = $this->generateKycPrimaryTable($client_id);
|
||||
}
|
||||
return $this->respond($response, 200);
|
||||
}
|
||||
return $this->respond(['status' => false, 'code' => 404, 'message' => 'no data found'], 200);
|
||||
}
|
||||
|
||||
public function deleteClientKycOtherDocs($id = null)
|
||||
{
|
||||
$client_id = $this->request->getGet('client_id');
|
||||
$updateData = [
|
||||
'is_active' => 0,
|
||||
'updated_by' => get_session_userid()
|
||||
];
|
||||
|
||||
$delete = $this->clientKYCDocsModel->where('id', $id)->delete();
|
||||
$delete = $this->clientKYCDocsModel->update($id, $updateData);
|
||||
if ($delete) {
|
||||
return $this->respond(['status' => true, 'code' => 200, 'id' => $id], 200);
|
||||
} else {
|
||||
return $this->respond(['status' => false, 'code' => 404, 'message' => 'no data found'], 200);
|
||||
$response = ['status' => true, 'code' => 200, 'id' => $id];
|
||||
if (!empty($client_id)) {
|
||||
$response['data'] = $this->generateKycOthersTable($client_id);
|
||||
}
|
||||
return $this->respond($response, 200);
|
||||
}
|
||||
return $this->respond(['status' => false, 'code' => 404, 'message' => 'no data found'], 200);
|
||||
}
|
||||
|
||||
|
||||
@ -3660,7 +3753,7 @@ class ClientController extends AdminController
|
||||
|
||||
$db = db_connect();
|
||||
$builder = $db->table('kyc_docs kd');
|
||||
$builder->select('kd.*, ck.file_name AS upload_doc_name');
|
||||
$builder->select('kd.*, ck.file_name AS upload_doc_name, ck.id AS client_kyc_id');
|
||||
$builder->join('clients c', 'kd.kyc_type_id = c.entity_type_id');
|
||||
$builder->join(
|
||||
'client_kyc_documents ck',
|
||||
@ -4712,7 +4805,8 @@ class ClientController extends AdminController
|
||||
if (file_exists($file)) {
|
||||
return $this->response->download($file, null)->setFileName($file_name);
|
||||
} else {
|
||||
return "File not found.";
|
||||
$data['message'] = 'The Physical File Not Found';
|
||||
echo view('errors/404', $data);
|
||||
}
|
||||
}
|
||||
|
||||
@ -9675,7 +9769,8 @@ class ClientController extends AdminController
|
||||
// download() takes the path as first param and null (or data) as second
|
||||
return $this->response->download($file, null);
|
||||
} else {
|
||||
return "File not found at: " . $file;
|
||||
$data['message'] = 'The Physical File Not Found';
|
||||
echo view('errors/404', $data);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -701,11 +701,11 @@ class PolicyTransactionController extends BaseController
|
||||
nhance_branch.branch_name as nhance_branch_name,
|
||||
rm.first_name AS rm_name
|
||||
')
|
||||
->join('user_teams', 'user_profiles.id = user_teams.user_id')
|
||||
// ->join('user_teams', 'user_profiles.id = user_teams.user_id')
|
||||
->join('nhance_branch', 'user_profiles.nhance_branch_id = nhance_branch.id','left')
|
||||
->join('user_profiles AS rm', 'user_profiles.rm_id = rm.id', 'left')
|
||||
->where('user_teams.team_id', 5)
|
||||
->where('user_teams.is_active', 1)
|
||||
// ->where('user_teams.team_id', 5)
|
||||
// ->where('user_teams.is_active', 1)
|
||||
->where('user_profiles.is_active', 1)
|
||||
->groupBy('user_profiles.id', 'asc')
|
||||
->findAll();
|
||||
@ -727,7 +727,7 @@ class PolicyTransactionController extends BaseController
|
||||
->join('user_teams', 'user_profiles.id = user_teams.user_id')
|
||||
->join('nhance_branch', 'user_profiles.nhance_branch_id = nhance_branch.id', 'left')
|
||||
->join('user_profiles AS rm', 'user_profiles.rm_id = rm.id', 'left')
|
||||
->where('user_profiles.role', 3)
|
||||
// ->where('user_profiles.role', 3)
|
||||
->where('user_profiles.is_active', 1)
|
||||
->groupBy('user_profiles.id', 'asc')
|
||||
->findAll();
|
||||
@ -970,8 +970,8 @@ class PolicyTransactionController extends BaseController
|
||||
'valid_date' => 'Please provide a valid D.O.E date.',
|
||||
'regex_match' => 'The D.O.E date format is incorrect. '
|
||||
]],
|
||||
'emp_count' => ['label' => 'No of Insured', 'rules' => 'permit_empty|numeric', 'errors' => [
|
||||
'numeric' => 'No of Insured must contain only numbers.'
|
||||
'emp_count' => ['label' => 'No of Employees', 'rules' => 'permit_empty|numeric', 'errors' => [
|
||||
'numeric' => 'No of Employees must contain only numbers.'
|
||||
]],
|
||||
'dependent_count' => ['label' => 'No of Dependents', 'rules' => 'permit_empty|numeric', 'errors' => [
|
||||
'numeric' => 'No of Dependents must contain only numbers.'
|
||||
@ -2491,9 +2491,9 @@ class PolicyTransactionController extends BaseController
|
||||
'errors' => ['valid_date' => 'Please provide a valid Endorsement Effective Date.']
|
||||
],
|
||||
'emp_count' => [
|
||||
'label' => 'No of Insured',
|
||||
'label' => 'No of Employees',
|
||||
'rules' => 'permit_empty|numeric',
|
||||
'errors' => ['numeric' => 'No of Insured must be a number.']
|
||||
'errors' => ['numeric' => 'No of Employees must be a number.']
|
||||
],
|
||||
'dependent_count' => [
|
||||
'label' => 'No of Dependents',
|
||||
@ -5792,7 +5792,7 @@ class PolicyTransactionController extends BaseController
|
||||
'pt_policy_issue_date' => change_date_format($policy_issue_date, 'd/M/Y', 'Y-m-d'),
|
||||
|
||||
'file_id' => $params['file_id'],
|
||||
'created_by' => $file['created_by'] ?? null,
|
||||
'created_by' => $file['created_by'] ?? null,
|
||||
];
|
||||
|
||||
if(!empty($vehicle_id) && !empty($client_id)){
|
||||
|
||||
@ -1063,15 +1063,21 @@
|
||||
->where('policy_transaction.is_active', 1)
|
||||
->where('policy_transaction.action_type', 'inception');
|
||||
|
||||
if (
|
||||
(!in_array(get_role_id(), [1, 5])) &&
|
||||
!(
|
||||
in_array(MANAGEMENT_TEAM_ID, user_team()) ||
|
||||
in_array(FINANCE_TEAM_ID, user_team()) ||
|
||||
in_array(BUSINESS_TEAM_ID, user_team())
|
||||
)
|
||||
) {
|
||||
if (get_role_id() == 4 && in_array(POS_TEAM_ID, user_team())) {
|
||||
// if (
|
||||
// (!in_array(get_role_id(), [1, 5])) &&
|
||||
// !(
|
||||
// in_array(MANAGEMENT_TEAM_ID, user_team()) ||
|
||||
// in_array(FINANCE_TEAM_ID, user_team()) ||
|
||||
// in_array(BUSINESS_TEAM_ID, user_team())
|
||||
// )
|
||||
// ) {
|
||||
// if (get_role_id() == 4 && in_array(POS_TEAM_ID, user_team())) {
|
||||
// $builder->where('policy_transaction.created_by', get_session_userid());
|
||||
// }
|
||||
// }
|
||||
|
||||
if ((!in_array(get_role_id(), [1, 5]))) {
|
||||
if (in_array(POS_TEAM_ID, user_team())) {
|
||||
$builder->where('policy_transaction.created_by', get_session_userid());
|
||||
}
|
||||
}
|
||||
@ -1165,20 +1171,27 @@
|
||||
->where('policy_transaction.is_active', 1)
|
||||
->where('policy_transaction.action_type !=', 'inception');
|
||||
|
||||
if (
|
||||
(!in_array(get_role_id(), [1, 5])) &&
|
||||
!(
|
||||
in_array(MANAGEMENT_TEAM_ID, user_team()) ||
|
||||
in_array(FINANCE_TEAM_ID, user_team()) ||
|
||||
in_array(BUSINESS_TEAM_ID, user_team())
|
||||
)
|
||||
) {
|
||||
if (get_role_id() == 4 && in_array(POS_TEAM_ID, user_team())) {
|
||||
// if (
|
||||
// (!in_array(get_role_id(), [1, 5])) &&
|
||||
// !(
|
||||
// in_array(MANAGEMENT_TEAM_ID, user_team()) ||
|
||||
// in_array(FINANCE_TEAM_ID, user_team()) ||
|
||||
// in_array(BUSINESS_TEAM_ID, user_team())
|
||||
// )
|
||||
// ) {
|
||||
// if (get_role_id() == 4 && in_array(POS_TEAM_ID, user_team())) {
|
||||
// $builder->where('policy_transaction.created_by', get_session_userid());
|
||||
// }
|
||||
// }
|
||||
|
||||
if ((!in_array(get_role_id(), [1, 5]))) {
|
||||
if (in_array(POS_TEAM_ID, user_team())) {
|
||||
$builder->where('policy_transaction.created_by', get_session_userid());
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
if ($start_date != 0 && $end_date != 0 && $date_type != 0) {
|
||||
|
||||
$this->validateDateType($date_type);
|
||||
@ -3067,15 +3080,21 @@
|
||||
$conditions = ""; // start safely
|
||||
|
||||
// 1. Role-based restrictions
|
||||
if (
|
||||
(!in_array(get_role_id(), [1, 5])) &&
|
||||
!(
|
||||
in_array(MANAGEMENT_TEAM_ID, user_team()) ||
|
||||
in_array(FINANCE_TEAM_ID, user_team()) ||
|
||||
in_array(BUSINESS_TEAM_ID, user_team())
|
||||
)
|
||||
) {
|
||||
if (get_role_id() == 4 && in_array(POS_TEAM_ID, user_team())) {
|
||||
// if (
|
||||
// (!in_array(get_role_id(), [1, 5])) &&
|
||||
// !(
|
||||
// in_array(MANAGEMENT_TEAM_ID, user_team()) ||
|
||||
// in_array(FINANCE_TEAM_ID, user_team()) ||
|
||||
// in_array(BUSINESS_TEAM_ID, user_team())
|
||||
// )
|
||||
// ) {
|
||||
// if (get_role_id() == 4 && in_array(POS_TEAM_ID, user_team())) {
|
||||
// $conditions .= " AND pt.created_by = " . get_session_userid();
|
||||
// }
|
||||
// }
|
||||
|
||||
if ((!in_array(get_role_id(), [1, 5]))) {
|
||||
if (in_array(POS_TEAM_ID, user_team())) {
|
||||
$conditions .= " AND pt.created_by = " . get_session_userid();
|
||||
}
|
||||
}
|
||||
|
||||
@ -39,26 +39,28 @@
|
||||
<input type="hidden" name="client_id" id="client_id_kyc" value="<?= isset($client['id']) ? $client['id'] : '' ?>"/>
|
||||
<input type="hidden" name="kyc_doc_type_id" value="" />
|
||||
<div class="form-group">
|
||||
|
||||
<div class="form-row">
|
||||
<div class="form-group col-md-4">
|
||||
<label for="emp_code">Document Name<span
|
||||
class="text-danger">*</span></label>
|
||||
<input type="text" class="form-control" id="other_docs_name" placeholder="Document Name" name="other_docs_name" required>
|
||||
</div>
|
||||
<div class="form-group col-md-4">
|
||||
<label for="kyc_docs">File<span
|
||||
class="text-danger">*</span></label>
|
||||
<input class="form-control" type="file" name="file_name"
|
||||
id="kyc_docs_file"
|
||||
required accept=".pdf, .jpeg, .jpg, .png">
|
||||
</div>
|
||||
<!-- <div class="form-group col-md-4 align-self-end"> -->
|
||||
<div class="form-group col-md-4" style="<?= isset($client['id']) ? 'margin-top: 41px;' : 'margin-top: 30px;' ?>">
|
||||
<button type="submit" class="btn btn-primary waves-effect waves-light mr-1"id="btnSubmit">Save</button>
|
||||
<div id="additional_docs_rows">
|
||||
<div class="form-row additional-doc-row" data-row-index="0">
|
||||
<div class="form-group col-md-4">
|
||||
<label>Document Name<span class="text-danger">*</span></label>
|
||||
<input type="text" class="form-control other-doc-name-field" placeholder="Document Name" name="other_docs_name[]" required>
|
||||
</div>
|
||||
<div class="form-group col-md-4">
|
||||
<label>File<span class="text-danger">*</span></label>
|
||||
<input class="form-control other-doc-file-field" type="file" name="file_name[]" required accept=".pdf, .jpeg, .jpg, .png">
|
||||
</div>
|
||||
<div class="form-group col-md-4" style="<?= isset($client['id']) ? 'margin-top: 41px;' : 'margin-top: 30px;' ?>">
|
||||
<button type="button" class="btn btn-outline-danger remove-additional-doc-row" style="display:none;">Remove</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="form-row">
|
||||
<div class="form-group col-md-12">
|
||||
<button type="button" class="btn btn-outline-primary waves-effect waves-light mr-1" id="add_more_other_docs">Add More</button>
|
||||
<button type="submit" class="btn btn-primary waves-effect waves-light mr-1" id="btnSubmit">Save</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</form>
|
||||
</div>
|
||||
@ -94,6 +96,24 @@
|
||||
|
||||
var kycPrimaryKey = $('#client_id_kyc').val();
|
||||
|
||||
function getAdditionalDocRowTemplate(index) {
|
||||
return `
|
||||
<div class="form-row additional-doc-row" data-row-index="${index}">
|
||||
<div class="form-group col-md-4">
|
||||
<label>Document Name<span class="text-danger">*</span></label>
|
||||
<input type="text" class="form-control other-doc-name-field" placeholder="Document Name" name="other_docs_name[]" required>
|
||||
</div>
|
||||
<div class="form-group col-md-4">
|
||||
<label>File<span class="text-danger">*</span></label>
|
||||
<input class="form-control other-doc-file-field" type="file" name="file_name[]" required accept=".pdf, .jpeg, .jpg, .png">
|
||||
</div>
|
||||
<div class="form-group col-md-4" style="<?= isset($client['id']) ? 'margin-top: 41px;' : 'margin-top: 30px;' ?>">
|
||||
<button type="button" class="btn btn-outline-danger remove-additional-doc-row">Remove</button>
|
||||
</div>
|
||||
</div>
|
||||
`;
|
||||
}
|
||||
|
||||
$(document).ready(function(){
|
||||
|
||||
kycPrimaryKey = $('#kyc_PrimaryKey').val();
|
||||
@ -195,6 +215,20 @@
|
||||
});
|
||||
});
|
||||
|
||||
$(document).on('click', '#add_more_other_docs', function () {
|
||||
var nextIndex = $('#additional_docs_rows .additional-doc-row').length;
|
||||
$('#additional_docs_rows').append(getAdditionalDocRowTemplate(nextIndex));
|
||||
$('#additional_docs_rows .remove-additional-doc-row').show();
|
||||
});
|
||||
|
||||
$(document).on('click', '.remove-additional-doc-row', function () {
|
||||
$(this).closest('.additional-doc-row').remove();
|
||||
|
||||
if ($('#additional_docs_rows .additional-doc-row').length <= 1) {
|
||||
$('#additional_docs_rows .remove-additional-doc-row').hide();
|
||||
}
|
||||
});
|
||||
|
||||
})
|
||||
|
||||
/*** for Others documents form submit ***/
|
||||
@ -202,8 +236,35 @@
|
||||
event.preventDefault();
|
||||
|
||||
var isValid = $('#kyc_form').parsley().validate();
|
||||
var rowHtml = '';
|
||||
var form_action = '';
|
||||
var allowedExtensions = ['pdf', 'png', 'jpeg', 'jpg'];
|
||||
|
||||
$('#kyc_form .other-doc-name-field, #kyc_form .other-doc-file-field').removeClass('is-invalid');
|
||||
|
||||
$('#additional_docs_rows .additional-doc-row').each(function() {
|
||||
var docNameField = $(this).find('.other-doc-name-field');
|
||||
var fileField = $(this).find('.other-doc-file-field');
|
||||
var docNameValue = (docNameField.val() || '').trim();
|
||||
var selectedFile = fileField[0].files[0];
|
||||
|
||||
if (docNameValue === '' || !selectedFile) {
|
||||
isValid = false;
|
||||
if (docNameValue === '') {
|
||||
docNameField.addClass('is-invalid');
|
||||
}
|
||||
if (!selectedFile) {
|
||||
fileField.addClass('is-invalid');
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
var fileExtension = selectedFile.name.split('.').pop().toLowerCase();
|
||||
if (allowedExtensions.indexOf(fileExtension) === -1) {
|
||||
isValid = false;
|
||||
fileField.addClass('is-invalid');
|
||||
}
|
||||
});
|
||||
|
||||
if (isValid) {
|
||||
|
||||
if(kycPrimaryKey === ''){
|
||||
@ -240,6 +301,8 @@
|
||||
}
|
||||
|
||||
$('#kyc_form').trigger('reset');
|
||||
$('#additional_docs_rows .additional-doc-row').not(':first').remove();
|
||||
$('#additional_docs_rows .remove-additional-doc-row').hide();
|
||||
},
|
||||
error: function(xhr, status, error) {
|
||||
console.error(xhr.responseText);
|
||||
@ -274,6 +337,8 @@
|
||||
}
|
||||
});
|
||||
|
||||
} else {
|
||||
toastr.warning('Please fill all Additional Document rows and upload valid files.', 'Warning');
|
||||
}
|
||||
});
|
||||
|
||||
@ -291,12 +356,14 @@
|
||||
if (result.isConfirmed) {
|
||||
|
||||
var kyc_id = $(this).attr('data-id');
|
||||
$.get('<?php echo base_url('client/kyc/delete/');?>'+kyc_id, function (data) {
|
||||
// console.log('kyc-'+ kyc_id)
|
||||
// console.log(data)
|
||||
if(data){
|
||||
$('#form_'+kyc_id).show();
|
||||
$('#name_'+kyc_id).hide();
|
||||
var client_id = $(this).attr('data-client-id') || $('#client_id_kyc').val();
|
||||
$.get('<?php echo base_url('client/kyc/delete/');?>'+kyc_id, { client_id: client_id }, function (data) {
|
||||
if(data && data.status){
|
||||
if (data.data) {
|
||||
$('#tbody').empty();
|
||||
$('#tbody').append(data.data);
|
||||
}
|
||||
toastr.success('Document deleted successfully', 'Success');
|
||||
}
|
||||
})
|
||||
}
|
||||
@ -317,10 +384,16 @@
|
||||
if (result.isConfirmed) {
|
||||
|
||||
var kyc_id = $(this).attr('data-id');
|
||||
$.get('<?php echo base_url('util/kyc-other-docs-delete/');?>'+kyc_id, function (data) {
|
||||
// console.log('kyc-'+ kyc_id)
|
||||
if(data){
|
||||
$('#kyc-'+ kyc_id).remove();
|
||||
var client_id = $(this).attr('data-client-id') || $('#client_id_kyc').val();
|
||||
$.get('<?php echo base_url('util/kyc-other-docs-delete/');?>'+kyc_id, { client_id: client_id }, function (data) {
|
||||
if(data && data.status){
|
||||
if (data.data) {
|
||||
$('#other_docs').empty();
|
||||
$('#other_docs').append(data.data);
|
||||
} else {
|
||||
$('#kyc-'+ kyc_id).remove();
|
||||
}
|
||||
toastr.success('Document deleted successfully', 'Success');
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
@ -2,9 +2,17 @@
|
||||
<?php foreach ($data as $index => $item): ?>
|
||||
<tr id="kyc-<?= $item['id'] ?>">
|
||||
<!-- <td><?= $index + 1; ?></td> -->
|
||||
<td><?= esc($item['file_name']); ?></td>
|
||||
<td><?= esc($item['other_docs_name']); ?></td>
|
||||
<td><a id="download_<?= esc($item['id']); ?>" data-id="<?= esc($item['id']); ?>" class="mdi mdi-download" style="font-size:18px;" download title="Download file"></a></td>
|
||||
<td><?= esc($item['file_name']); ?></td>
|
||||
<td>
|
||||
<a href="<?= base_url('download-kyc-docs/') . ($item['file_name'] ?? '') ?>" data-id="<?= esc($item['id']); ?>" class="mdi mdi-download mr-2" style="font-size:18px;" target="_blank"></a>
|
||||
<i
|
||||
data-id="<?= esc($item['id']); ?>"
|
||||
data-client-id="<?= esc($client_id); ?>"
|
||||
class="mdi mdi-delete btnKycOtherDelete"
|
||||
style="font-size:18px; cursor:pointer;"
|
||||
></i>
|
||||
</td>
|
||||
</tr>
|
||||
<?php endforeach; ?>
|
||||
<?php else: ?>
|
||||
|
||||
@ -17,7 +17,17 @@
|
||||
<td></td>
|
||||
<?php } else { ?>
|
||||
<td><?= esc($item['upload_doc_name']); ?></td>
|
||||
<td><a id="download_<?= esc($item['id']); ?>" data-id="<?= esc($item['id']); ?>" class="mdi mdi-download" style="font-size:18px;" download></a></td>
|
||||
<td>
|
||||
<a href="<?= base_url('download-kyc-docs/') . ($item['upload_doc_name'] ?? '') ?>" data-id="<?= esc($item['id']); ?>" class="mdi mdi-download mr-2" style="font-size:18px;" target="_blank"></a>
|
||||
<?php if (!empty($item['upload_doc_name']) && !empty($item['client_kyc_id'])): ?>
|
||||
<i
|
||||
data-id="<?= esc($item['client_kyc_id']); ?>"
|
||||
data-client-id="<?= esc($client_id); ?>"
|
||||
class="mdi mdi-delete btnKycDelete"
|
||||
style="font-size:18px; cursor:pointer;"
|
||||
></i>
|
||||
<?php endif; ?>
|
||||
</td>
|
||||
<?php } ?>
|
||||
</tr>
|
||||
<?php endforeach; ?>
|
||||
|
||||
@ -2108,9 +2108,10 @@ body[data-sidebar-size="condensed"] .footer {
|
||||
</div>
|
||||
</li>
|
||||
|
||||
<?php if ((get_role_id() == 1 || get_role_id() == 5) || (get_role_id() == 4 && in_array(FINANCE_TEAM_ID, user_team())) || (in_array(MANAGEMENT_TEAM_ID, user_team()) || in_array(FINANCE_TEAM_ID, user_team()) || in_array(BUSINESS_TEAM_ID, user_team()) || in_array(POS_TEAM_ID, user_team()))) { ?>
|
||||
<?php if ((get_role_id() == 1 || get_role_id() == 5) || (get_role_id() == 4 && in_array(FINANCE_TEAM_ID, user_team())) || (in_array(MANAGEMENT_TEAM_ID, user_team()) || in_array(FINANCE_TEAM_ID, user_team()) || in_array(BUSINESS_TEAM_ID, user_team()))) { ?>
|
||||
|
||||
<?php if (in_array(get_role_id(), [1, 5]) || (get_role_id() == 4 && in_array(FINANCE_TEAM_ID, user_team())) || in_array(MANAGEMENT_TEAM_ID, user_team())) { ?>
|
||||
|
||||
<?php if (in_array(get_role_id(), [1, 5]) || (get_role_id() == 4 && in_array(FINANCE_TEAM_ID, user_team())) || in_array(MANAGEMENT_TEAM_ID, user_team()) || in_array(POS_TEAM_ID, user_team())) { ?>
|
||||
<li>
|
||||
<a href="#policyReports" data-toggle="collapse" class="waves-effect">
|
||||
<i class="ri-file-chart-fill"></i>
|
||||
@ -2141,27 +2142,29 @@ body[data-sidebar-size="condensed"] .footer {
|
||||
</ul>
|
||||
</div>
|
||||
</li>
|
||||
<?php } ?>
|
||||
<li>
|
||||
<a href="#policy_tat_report_type" data-toggle="collapse" class="waves-effect">
|
||||
<i class="ri-file-chart-fill"></i>
|
||||
<span> Policy TAT Reports </span>
|
||||
</a>
|
||||
<div class="collapse" id="policy_tat_report_type">
|
||||
<ul class="nav-third-level">
|
||||
<li>
|
||||
<a href="<?= base_url('/bdsReport/getMultiReport/1') ?>">TAT Band Wise</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="<?= base_url('/bdsReport/getMultiReport/2') ?>">ACM Status Wise</a>
|
||||
</li>
|
||||
<li>
|
||||
<a href="<?= base_url('/bdsReport/getMultiReport/3') ?>">ACM TAT Wise</a>
|
||||
</li>
|
||||
</ul>
|
||||
</div>
|
||||
</li>
|
||||
<li>
|
||||
<a href="#policy_tat_report_type" data-toggle="collapse" class="waves-effect">
|
||||
<i class="ri-file-chart-fill"></i>
|
||||
<span> Policy TAT Reports </span>
|
||||
</a>
|
||||
<div class="collapse" id="policy_tat_report_type">
|
||||
<ul class="nav-third-level">
|
||||
<li>
|
||||
<a href="<?= base_url('/bdsReport/getMultiReport/1') ?>">TAT Band Wise</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="<?= base_url('/bdsReport/getMultiReport/2') ?>">ACM Status Wise</a>
|
||||
</li>
|
||||
<li>
|
||||
<a href="<?= base_url('/bdsReport/getMultiReport/3') ?>">ACM TAT Wise</a>
|
||||
</li>
|
||||
</ul>
|
||||
</div>
|
||||
</li>
|
||||
|
||||
<?php } ?>
|
||||
|
||||
<!-- This Menu Hide because of Role Merge REF : SVM,SVR,KV.
|
||||
<?php if ((get_role_id() == 1 || get_role_id() == 5) || (in_array(MANAGEMENT_TEAM_ID, user_team()) || in_array(FINANCE_TEAM_ID, user_team()) || in_array(BUSINESS_TEAM_ID, user_team()))) { ?>
|
||||
@ -2221,6 +2224,7 @@ body[data-sidebar-size="condensed"] .footer {
|
||||
</a>
|
||||
</li>
|
||||
<?php } ?>
|
||||
|
||||
<li>
|
||||
<a href="<?= base_url('/payout/list') ?>">
|
||||
<i class="ri-money-rupee-circle-line"></i>
|
||||
@ -2241,7 +2245,8 @@ body[data-sidebar-size="condensed"] .footer {
|
||||
</li>
|
||||
|
||||
<?php } ?>
|
||||
<?php if (in_array(get_role_id(), [1, 5]) || (in_array(MANAGEMENT_TEAM_ID, user_team()) || in_array(FINANCE_TEAM_ID, user_team()) || in_array(BUSINESS_TEAM_ID, user_team()) || in_array(POS_TEAM_ID, user_team()))) { ?>
|
||||
|
||||
<?php if (in_array(get_role_id(), [1, 5]) || (in_array(MANAGEMENT_TEAM_ID, user_team()) || in_array(FINANCE_TEAM_ID, user_team()) || in_array(BUSINESS_TEAM_ID, user_team()))) { ?>
|
||||
<li>
|
||||
<a href="<?= base_url('/policy_tranction/inception/list2') ?>">
|
||||
<i class="ri-barcode-line"></i>
|
||||
@ -2255,6 +2260,7 @@ body[data-sidebar-size="condensed"] .footer {
|
||||
</a>
|
||||
</li>
|
||||
<?php } ?>
|
||||
|
||||
</ul>
|
||||
</div>
|
||||
</li>
|
||||
|
||||
@ -766,7 +766,7 @@
|
||||
</div> -->
|
||||
|
||||
<div class="form-group col-md-3" id="no_of_insured_div">
|
||||
<label for="addon_policy">No of Insured<span id="base_danger"class="text-danger"></span></label>
|
||||
<label for="addon_policy">No of Employees<span id="base_danger"class="text-danger"></span></label>
|
||||
<input type="text" class="form-control" id="emp_count" name="emp_count" placeholder="Enter Employeee" onkeypress="return onlyNumbers(event)">
|
||||
</div>
|
||||
|
||||
|
||||
@ -661,6 +661,11 @@ function getAddPage(){
|
||||
|
||||
if(view == 1){
|
||||
runInceptionAddFlowFromList();
|
||||
setTimeout(() => {
|
||||
var backUrl = '<?= base_url("policy_tranction/inception/list"); ?>';
|
||||
var backButton = `<a href="${backUrl}" aria-label="Back to list"><i class="mdi mdi-arrow-left" style="font-size: 17px;"></i></a>`;
|
||||
updateNavTitle('Add Policy', backButton);
|
||||
}, 500);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
125
nonebapidocs.md
125
nonebapidocs.md
@ -64,6 +64,8 @@ All responses follow this consistent shape:
|
||||
| 2 | `POST` | `/api/v1/non-eb-claim/list` | List / search claims |
|
||||
| 3 | `GET` | `/api/v1/non-eb-claim/history/{claim_id}` | Status timeline of a claim |
|
||||
| 4 | `POST` | `/api/v1/non-eb-claim/{claim_id}/upload-required-doc` | Upload a required document |
|
||||
| 5 | `GET` | `/api/v1/non-eb-claim/statuses` | List Non-EB claim statuses |
|
||||
| 6 | `POST` | `/api/v1/non-eb-claim/policies` | List Non-EB policies by client (MD5) + branch |
|
||||
|
||||
---
|
||||
|
||||
@ -413,6 +415,129 @@ file = <file>
|
||||
|
||||
---
|
||||
|
||||
## 5. List Claim Statuses
|
||||
|
||||
**GET** `/api/v1/non-eb-claim/statuses`
|
||||
|
||||
### How it works
|
||||
|
||||
Returns all Non-EB claim statuses. Use this to populate status dropdowns in the UI or filter screens. Statuses are ordered by `id ASC`.
|
||||
|
||||
> Ticket type is hardcoded to `50` (Non-EB) on the server — you do not need to send it.
|
||||
|
||||
### Request
|
||||
|
||||
No body required. Only the `Authorization` header is needed.
|
||||
|
||||
```
|
||||
GET /api/v1/non-eb-claim/statuses
|
||||
Authorization: Bearer <token>
|
||||
```
|
||||
|
||||
### Success Response `200`
|
||||
|
||||
```json
|
||||
{
|
||||
"status": true,
|
||||
"code": 200,
|
||||
"data": [
|
||||
{ "id": 1, "claim_status": "Claim Intimation", "display_name": "Claim Intimation" },
|
||||
{ "id": 2, "claim_status": "Under Process", "display_name": "Under Process" },
|
||||
{ "id": 3, "claim_status": "Claim Settled", "display_name": "Claim Settled" }
|
||||
]
|
||||
}
|
||||
```
|
||||
|
||||
> `display_name` is the user-facing label. `claim_status` is the internal name. Use `id` when sending `claim_status_id` as a filter in the list endpoint.
|
||||
|
||||
### Error Responses
|
||||
|
||||
| Code | Scenario |
|
||||
|---|---|
|
||||
| `401` | Missing / expired token |
|
||||
|
||||
---
|
||||
|
||||
## 6. List Policies by Client + Branch
|
||||
|
||||
**POST** `/api/v1/non-eb-claim/policies`
|
||||
|
||||
### How it works
|
||||
|
||||
Returns Non-EB and Marine policies for a specific client branch. Use this to populate the policy dropdown before raising a new claim.
|
||||
|
||||
The client is identified by an **MD5 hash of their numeric ID** — the raw integer ID is never exposed to the API consumer.
|
||||
|
||||
### Request
|
||||
|
||||
**Content-Type:** `application/json`
|
||||
|
||||
| Field | Required | Type | Notes |
|
||||
|---|---|---|---|
|
||||
| `client_id` | Yes | string | MD5 hash (32-char hex) of the client's numeric ID |
|
||||
| `client_branch_id` | Yes | integer | The client branch to filter by |
|
||||
|
||||
### Example Request
|
||||
|
||||
```json
|
||||
{
|
||||
"client_id": "d41d8cd98f00b204e9800998ecf8427e",
|
||||
"client_branch_id": 3
|
||||
}
|
||||
```
|
||||
|
||||
### Success Response `200`
|
||||
|
||||
```json
|
||||
{
|
||||
"status": true,
|
||||
"code": 200,
|
||||
"total": 2,
|
||||
"data": [
|
||||
{
|
||||
"id": 10,
|
||||
"policy_no": "POL/2026/001",
|
||||
"policy_type_id": 50,
|
||||
"policy_type_name": "Fire",
|
||||
"insurer_id": 7,
|
||||
"insurer_name": "New India Assurance",
|
||||
"insurer_short_name": "NIA",
|
||||
"policy_start_date": "01-04-2025",
|
||||
"policy_end_date": "31-03-2026"
|
||||
},
|
||||
{
|
||||
"id": 11,
|
||||
"policy_no": "POL/2026/002",
|
||||
"policy_type_name": "Marine Cargo",
|
||||
"insurer_name": "HDFC Ergo",
|
||||
"insurer_short_name": "HDFC",
|
||||
"policy_start_date": "01-01-2026",
|
||||
"policy_end_date": "31-12-2026"
|
||||
}
|
||||
]
|
||||
}
|
||||
```
|
||||
|
||||
> Only **Non-EB** and **Marine** policy types are returned. EB policies are excluded automatically.
|
||||
> When no policies exist for the given client + branch, `total` is `0` and `data` is `[]`.
|
||||
|
||||
### How to use in create claim flow
|
||||
|
||||
1. Call this endpoint with the selected client's MD5 and branch ID
|
||||
2. Populate a dropdown with the returned policies — display `policy_no` + `policy_type_name` to the user
|
||||
3. When the user picks a policy, send its `id` as `client_policy_id` in the **Create Claim** request
|
||||
|
||||
### Error Responses
|
||||
|
||||
| Code | Scenario | Message |
|
||||
|---|---|---|
|
||||
| `400` | `client_id` not sent | `"client_id is required"` |
|
||||
| `400` | `client_id` is not a valid MD5 hash | `"client_id must be a valid MD5 hash"` |
|
||||
| `400` | `client_branch_id` not sent or zero | `"client_branch_id is required"` |
|
||||
| `401` | Missing / expired token | `"Unauthorized"` |
|
||||
|
||||
---
|
||||
|
||||
## Common Error Reference
|
||||
|
||||
| HTTP Code | Meaning | When it happens |
|
||||
|
||||
115
public/dev_logs/2026-03-31.md
Normal file
115
public/dev_logs/2026-03-31.md
Normal file
@ -0,0 +1,115 @@
|
||||
# Dev Log — 2026-03-31
|
||||
|
||||
## Non-EB Claims Module — Session 5
|
||||
|
||||
---
|
||||
|
||||
### 1. Asset File Upload — `createClaim()` API Endpoint
|
||||
|
||||
Replaced the silent `handleAssetFileUpload()` call with inline validation to give proper API error responses.
|
||||
|
||||
**Problems fixed:**
|
||||
- Invalid file extension was silently ignored — claim was created without the file, no error returned
|
||||
- Upload failure had no error response
|
||||
- Success response had no `asset_file` field
|
||||
|
||||
**Changes in `app/Controllers/Api/NonEbClaimApiController.php`:**
|
||||
- Reads `asset_file` from request directly
|
||||
- Returns **415** with allowed types listed if extension is not in `UPLOAD_EXT_ASSET_FILES` (`pdf, xls, xlsx, csv`)
|
||||
- Returns **400** if `loss_description` is missing when file is provided
|
||||
- Returns **500** if `file_Upload()` fails
|
||||
- Success response now includes `"asset_file": "filename.pdf"` (or `null` if none sent)
|
||||
- `asset_file` is optional — omitting it creates the claim normally
|
||||
|
||||
**How to call:**
|
||||
```
|
||||
POST /api/v1/non-eb-claim/create
|
||||
Content-Type: multipart/form-data
|
||||
Authorization: Bearer <token>
|
||||
|
||||
client_policy_id, nature_of_loss, loss_location, loss_date, [asset_file]
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
### 2. Sidebar — Claims Menu Restructured
|
||||
|
||||
**`app/Views/layout/header.php`**
|
||||
|
||||
| Before | After |
|
||||
|---|---|
|
||||
| New claim | New EB Claim |
|
||||
| Non EB Claims | EB Claim List |
|
||||
| Claim List | New Non EB Claim |
|
||||
| *(nothing)* | Non EB Claim List |
|
||||
|
||||
Final menu order:
|
||||
1. **New EB Claim** → `openTicketTypeAskModal()`
|
||||
2. **EB Claim List** → `/ticket/list`
|
||||
3. **New Non EB Claim** → `/non-eb-claim/new`
|
||||
4. **Non EB Claim List** → `/non-eb-claim/list`
|
||||
|
||||
---
|
||||
|
||||
### 3. New Non-EB Claim — Route Added
|
||||
|
||||
**`app/Config/Routes.php`**
|
||||
- Added `GET non-eb-claim/new` → `NonEbClaimController::claimForm/50` (bare route, policy type hardcoded to 50 temporarily)
|
||||
- Existing `new/(:any)` route preserved for dynamic use
|
||||
|
||||
---
|
||||
|
||||
### 4. Non-EB List Page — Add Button Bypasses Policy Type Modal
|
||||
|
||||
**`app/Views/non_eb_claim_search.php`**
|
||||
- `#policyTypeModal` HTML commented out
|
||||
- `goToNewClaim()` JS function commented out
|
||||
|
||||
**`app/Views/non_eb_claim_list.php`**
|
||||
- Add button action changed from `openPolicyTypeModal()` → `window.location.href = base_url('non-eb-claim/new/50')`
|
||||
- `openPolicyTypeModal()` JS function commented out
|
||||
|
||||
---
|
||||
|
||||
### 5. New Non-EB Claim Form — Nhance Logo Loader on Client Select
|
||||
|
||||
**`app/Views/non_eb_claim_form.php`**
|
||||
- Shows global nhance gif loader (`.loader` / `.loader-mask`) when client is selected and AJAX fires to fetch branches/policies
|
||||
- Hides loader on AJAX success and on AJAX error (so loader never gets stuck)
|
||||
|
||||
---
|
||||
|
||||
### 6. New API Endpoints — Policies List & Claim Statuses
|
||||
|
||||
**`app/Controllers/Api/NonEbClaimApiController.php`** — 2 new methods added
|
||||
|
||||
#### `GET /api/v1/non-eb-claim/statuses`
|
||||
- Returns all `ticket_claim_status` rows where `ticket_type = 50` (Non-EB, hardcoded) and `is_active = 1`
|
||||
- Returns: `id`, `claim_status`, `display_name`
|
||||
- No request body required
|
||||
|
||||
#### `POST /api/v1/non-eb-claim/policies`
|
||||
- Accepts: `client_id` (MD5 hash, required), `client_branch_id` (integer, required)
|
||||
- Validates MD5 format — returns 400 if not a 32-char hex string
|
||||
- Queries `client_policy` using `MD5(cp.client_id)` for secure lookup
|
||||
- Filters: `client_branch_id`, `is_active = 1`, `policy_type.allocg IN ('Non-EB', 'Marine')`
|
||||
- Returns: `id`, `policy_no`, `policy_type_id`, `policy_type_name`, `insurer_id`, `insurer_name`, `insurer_short_name`, `policy_start_date`, `policy_end_date`
|
||||
|
||||
**`app/Config/Routes.php`** — 2 new routes added inside `api/v1/non-eb-claim` group:
|
||||
```
|
||||
GET api/v1/non-eb-claim/statuses → listClaimStatuses
|
||||
POST api/v1/non-eb-claim/policies → listPolicies
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
### Files Modified Today
|
||||
|
||||
| File | Changes |
|
||||
|---|---|
|
||||
| `app/Controllers/Api/NonEbClaimApiController.php` | Asset file inline validation + 415/500 errors + asset_file in success response; added `listClaimStatuses()` and `listPolicies()` |
|
||||
| `app/Config/Routes.php` | Added `non-eb-claim/new` bare route; added `statuses` and `policies` API routes |
|
||||
| `app/Views/layout/header.php` | Claims sidebar menu restructured (4 items) |
|
||||
| `app/Views/non_eb_claim_search.php` | policyTypeModal + goToNewClaim commented out |
|
||||
| `app/Views/non_eb_claim_list.php` | Add button redirects directly; openPolicyTypeModal commented out |
|
||||
| `app/Views/non_eb_claim_form.php` | Nhance loader shown/hidden around getBranchAndPolicy AJAX |
|
||||
Loading…
Reference in New Issue
Block a user