MERGE_TEST_VAPT&LIVE_ISSUES

This commit is contained in:
Ubuntu 2026-01-28 10:03:29 +05:30
commit 6ca9b7fe61
100 changed files with 12505 additions and 940 deletions

View File

@ -33,11 +33,11 @@ database.default.DBDriver =
# session.driver = 'CodeIgniter\Session\Handlers\FileHandler'
# session.cookieName = 'ci_session'
#session.expiration = 28800
session.expiration =
# session.savePath = null
# session.matchIP = false
# session.timeToUpdate = 300
# session.regenerateDestroy = false
session.timeToUpdate = 300
session.regenerateDestroy = false
#--------------------------------------------------------------------
# LOGGER
@ -81,16 +81,6 @@ cookie.secure = 'true';// if https set as true or if http set as false
unlayer.projectID =
email.enquiryMail =
database.postDB.hostname =
database.postDB.database =
database.postDB.username =
database.postDB.password =
database.postDB.DBDriver =
database.postDB.DBPrefix =
database.postDB.port =
POST_ENROLLMENT_BASEURL =
#SMS
SMS_API_KEY =
SMS_SENDER_ID =
@ -109,4 +99,16 @@ CORS_DEBUG=true
APP_SIGNATURE =
TOKENTIMEOUT =
JWT_SECRET =
JWT_SECRET =
ICICI_PRIMARY_KEY_CONSTANT =
ABHI_PRIMARY_KEY_CONSTANT =
R_CARE_PRIMARY_KEY_CONSTANT =
FHPL_PRIMARY_KEY_CONSTANT =
VIDAL_PRIMARY_KEY_CONSTANT =
MEDI_ASSIST_PRIMARY_KEY_CONSTANT =

View File

@ -62,7 +62,7 @@ class Filters extends BaseConfig
'before' => [
'HttpRequestLog' => ['except' => 'cli/*'],
'Cors',
'AclFilter' => ['except' => ['login', 'logout', 'auth/*', 'oauth2callback','claim-form-download', 'claims-feedback-form', 'autobookstackLogin','employeeRest/*','processjob']],
// 'AclFilter' => ['except' => ['login', 'logout', 'auth/*', 'oauth2callback','claim-form-download', 'claims-feedback-form', 'autobookstackLogin','employeeRest/*','processjob','getCommission']],
'SecurityInputFilter' => ['except' => ['notification/create','/ticket/crud_mail_template/*','test_mail','leads/sendMail'] ],
'GlobalPostFileUploadGuard'
// 'csrf',
@ -95,5 +95,5 @@ class Filters extends BaseConfig
* Example:
* 'isLoggedIn' => ['before' => ['account/*', 'profiles/*']]
*/
public array $filters = [];
// public array $filters = [ 'Cors' => ['before' => ['employeeRest/*']]];
}

View File

@ -427,6 +427,7 @@ $routes->group("/util", ["filter" => "authMVC"], function ($routes) {
$routes->get('checkDuplicateCdAccount', 'MasterController::checkDuplicateCdAccount');
$routes->get('proceedExcelFileDataValidation', 'EmployeeController::proceedExcelFileDataValidation');
$routes->get('checkTpaApiEnable', 'EmployeeRestController::checkTpaApiEnable');
$routes->get('generateDemographyDataTable', 'LeadsController::generateDemographyDataTable');
});
$routes->post("policy_tranction/sendInstallmentRemainderMail","PolicyTransactionController::sendInstallmentRemainderMail");
@ -525,7 +526,6 @@ $routes->cli('cli/check_env', 'MasterController::checkEnv');
$routes->cli('cli/enrollOpendAndClose', 'DashboardController::updatePolicyEnrollmentStatus');
$routes->cli("cli/sendCroneRemainderMail", "DashboardController::sendCroneRemainderMail");
$routes->cli('cli/update-emp-policy-status', 'ClientController::updateEmpAndPolicyStatus');
$routes->cli('cli/update-emp-policy-status', 'ClientController::updateEmpAndPolicyStatus');
$routes->cli('cli/insurerRFQRemainder', 'LeadsController::remainderForQcr');
$routes->cli('cli/sendMailWithAutoQuery','TicketController::sendMailWithAutoQuery');
$routes->cli('cli/MediAssit-ClaimStatusUpdate','MediAssistApiController::ClaimStatusUpdate');
@ -770,12 +770,12 @@ $routes->get('fetchUHIDDetails','ICICILombardController::fetchUHIDDetails');
//Third party - testing route
$routes->get('FhplGetBenefDetails','FhplApiController::FhplGetBenefDetails');
$routes->get('EcardRequest','VidalApiController::EcardRequest');
$routes->get('HospitalNetwork','MediAssistApiController::HospitalNetwork');
$routes->get('VidalGetBenefDetails','VidalApiController::VidalGetBenefDetails');
$routes->get('ClaimDetail','VidalApiController::ClaimDetail');
$routes->get('SubmitClaim','MediAssistApiController::SubmitClaim');
$routes->get('ClaimDetail','FhplApiController::ClaimDetail');
$routes->get('SubmitClaim','FhplApiController::SubmitClaim');
$routes->get('IntimateClaim','MediAssistApiController::IntimateClaim');
$routes->get('IRSubmission','MediAssistApiController::IRSubmission');
$routes->get('ClaimStatusUpdate','MediAssistApiController::ClaimStatusUpdate');

View File

@ -59,8 +59,48 @@ class AppContentManagementController extends AdminController
// add and edit
public function add_advertise_image() {
try {
$data = $this->request->getPost();
$sanitized_post_data = sanitizeInputArrayAdvanced($data);
$id = ((int) $sanitized_post_data['add_image_id']) ?? null;
$rules = [
'client_id' => [
'rules' => 'required|integer',
'errors' => [
'required' => 'Client is required',
'integer' => 'Invalid client selected'
]
],
];
$rules['advertise_image'] = [
'rules' => ($id === 0 ? 'uploaded[advertise_image]|' : '') // required only for ADD
. 'is_image[advertise_image]'
. '|mime_in[advertise_image,image/jpg,image/jpeg,image/png]'
. '|max_size[advertise_image,200]'
. '|min_dims[advertise_image,1640,664]'
. '|max_dims[advertise_image,1640,664]',
'errors' => [
'uploaded' => 'Image is required',
'is_image' => 'File must be an image',
'mime_in' => 'Only JPG, JPEG, PNG allowed',
'max_size' => 'Image size must not exceed 200 KB',
'min_dims' => 'Image dimensions must be exactly 1640x664 pixels',
'max_dims' => 'Image dimensions must be exactly 1640x664 pixels',
]
];
if (!$this->validate($rules)) {
return $this->response->setStatusCode(400)->setJSON([
'status' => false,
'message' => 'Input validation failed',
'code' => 400,
'errors' => $this->validator->getErrors()
]);
}
$file = $this->request->getFile('advertise_image');
$client_id = $this->request->getPost('client_id');
$client_id = $sanitized_post_data['client_id'] ?? null;
//1) original file name for vaildations
$fileName = $file->getClientName(); //original file name for vaildations
$existing = $this->addImgModel->where('name', $fileName)->where('client_id', $fileName)->where('is_active', 1)->first();
@ -80,13 +120,13 @@ class AppContentManagementController extends AdminController
$file->move($uploadPath, $fileName);
$id = $this->request->getPost('add_image_id');
$data = ['name' => $fileName,'client_id'=>$client_id];
$id = $sanitized_post_data['add_image_id'] ?? null;
$details = ['name' => $fileName,'client_id'=>$client_id];
if ($id == 0) {
$this->addImgModel->insert($data);
$this->addImgModel->insert($details);
} else {
$this->addImgModel->update($id, $data);
$this->addImgModel->update($id, $details);
}
return $this->respond(['status' => true, 'message' => 'Image saved successfully.']);
@ -143,8 +183,56 @@ class AppContentManagementController extends AdminController
if ($this->request->getMethod() === 'post') {
$id = $this->request->getPost('fe_id');
$data = $this->request->getPost();
$rules = [
'type' => [
'rules' => 'required|max_length[255]',
'errors' => [
'required' => 'Type is required',
'max_length' => 'Type cannot exceed 255 characters'
]
],
'content_section' => [
'rules' => 'required|max_length[255]',
'errors' => [
'required' => 'Content Section is required',
'max_length' => 'Content Section cannot exceed 255 characters'
]
],
'heading' => [
'rules' => 'required|max_length[255]',
'errors' => [
'required' => 'Heading is required',
'max_length' => 'Heading cannot exceed 255 characters'
]
],
'content' => [
'rules' => 'required|max_length[5000]',
'errors' => [
'required' => 'Content is required',
'max_length' => 'Content cannot exceed 5000 characters'
]
],
'notes' => [
'rules' => 'required|max_length[1500]',
'errors' => [
'required' => 'Notes are required',
'max_length' => 'Notes cannot exceed 1500 characters'
]
]
];
if (!$this->validate($rules)) {
return $this->response->setStatusCode(400)->setJSON([
'status' => false,
'message' => 'Input validation failed',
'code' => 400,
'errors' => $this->validator->getErrors()
]);
}
$request_post_data = $this->request->getPost();
$data = sanitizeInputArrayAdvanced($request_post_data);
$id = $data['fe_id'];
unset($data['fe_id']);
@ -231,8 +319,30 @@ class AppContentManagementController extends AdminController
try {
// --- 1. POST: CREATE OR UPDATE ---
if ($method === 'post') {
$id = $this->request->getPost('faq_id');
$data = array_filter($this->request->getPost(), fn($v) => $v !== '' && $v !== null);
$rules = [
'category' => [
'rules' => 'required',
'errors' => [
'required' => 'Category is required'
]
],
'question' => [
'rules' => 'required',
'errors' => [
'required' => 'Question is required'
]
],
'answer' => [
'rules' => 'required',
'errors' => [
'required' => 'Answer is required'
]
]
];
$request_post_data = $this->request->getPost();
$sanitized_post_data = sanitizeInputArrayAdvanced($request_post_data);
$data = array_filter($sanitized_post_data, fn($v) => $v !== '' && $v !== null);
$id = $data['faq_id'];
if (empty($id)) {
$status = $this->faqModel->insert($data);

View File

@ -191,10 +191,13 @@ class BDSReportController extends AdminController
return $this->loadLayout('irba_report', $data);
} else {
$fromDate = $this->request->getPost('fromDate');
$toDate = $this->request->getPost('toDate');
$category = $this->request->getPost('category');
$report_type = $this->request->getPost('report_type');
$request_post_data = $this->request->getPost();
$sanitized_post_data = sanitizeInputArrayAdvanced($request_post_data);
$fromDate = $sanitized_post_data['fromDate'] ?? null;
$toDate = $sanitized_post_data['toDate'] ?? null;
$category = $sanitized_post_data['category'] ?? null;
$report_type = $sanitized_post_data['report_type'] ?? null;
// log_message('error',json_encode($_POST));die();
if ($report_type == 'insurer') {
$life = $category == 'life' ? 1 : 0;
@ -937,11 +940,13 @@ class BDSReportController extends AdminController
return $this->loadLayout('renewal_search', $data);
} else {
$fromDate = $this->request->getPost('fromDate');
$toDate = $this->request->getPost('toDate');
$client_id = $this->request->getPost('client_id');
$client_type = $this->request->getPost('client_type');
$issuer_branch = $this->request->getPost('issuer_branch');
$request_post_data = $this->request->getPost();
$sanitized_post_data = sanitizeInputArrayAdvanced($request_post_data);
$fromDate = $sanitized_post_data['fromDate'] ?? null;
$toDate = $sanitized_post_data['toDate'] ?? null;
$client_id = $sanitized_post_data['client_id'] ?? null;
$client_type = $sanitized_post_data['client_type'] ?? null;
$issuer_branch = $sanitized_post_data['issuer_branch'] ?? null;
$data['issuer_branch'] = $this->nhanceBranchModel->where('is_active', 1)->findAll();
$data['client_type'] = [1 => 'Group', 2 => 'Individual'];

File diff suppressed because it is too large Load Diff

View File

@ -1108,7 +1108,39 @@ class EmployeeController extends AdminController
try {
$filePath = WRITEPATH . '/uploads/excel/' . $file_name['file_name'];
if (!$file_name) {
return $this->respond([
'dataStatus' => false,
'code' => 200,
'data' => '<div class="text-center">No Data Found</div>',
'file_data' => null
], 200);
}
$filePath = WRITEPATH . 'uploads/excel/' . $file_name['file_name'];
// ✅ File not exists on disk
if (!file_exists($filePath)) {
return $this->respond([
'dataStatus' => false,
'code' => 200,
'data' => '<div class="text-center">No Data Found</div>',
'file_data' => $file_name
], 200);
}
$excel_data = $empDataServiceController->readExcelFileToArray($filePath);
// ✅ Excel empty or header only
if (empty($excel_data) || count($excel_data) <= 1) {
return $this->respond([
'dataStatus' => false,
'code' => 200,
'data' => '<div class="text-center">No Data Found</div>',
'file_data' => $file_name
], 200);
}
if (file_exists($filePath)) {
@ -1144,8 +1176,7 @@ class EmployeeController extends AdminController
$errorMessage = 'Error occurred:' . PHP_EOL . json_encode($errorData, JSON_PRETTY_PRINT);
$this->myLogger->logme('error', $errorMessage);
$html = '<div class="text-center">No Data Found</div>';
return $this->respond(['dataStatus' => false, 'code' => 500, 'data' => $html, 'file_data' => $file_name], 500);
return $this->respond(['dataStatus' => false, 'code' => 500, 'data' => '<div class="text-center">Something went wrong</div>', 'file_data' => $file_name ?? null], 500);
}
}
@ -2676,12 +2707,73 @@ class EmployeeController extends AdminController
//UPDATE EMPLOYEE
public function update_emp_data()
{
$data = $this->request->getPost();
$rules = [
'emp_code' => [
'rules' => 'required',
'errors' => [
'required' => 'Employee Code is missing'
]
],
'name' => [
'rules' => 'required|min_length[2]|max_length[100]',
'errors' => [
'required' => 'Employee name is required',
'min_length' => 'Name must be at least 2 characters',
'max_length' => 'Name cannot exceed 100 characters'
]
],
'gender' => [
'rules' => 'permit_empty|in_list[M,F]',
'errors' => [
'in_list' => 'Invalid gender selected'
]
],
'email_corporate' => [
'rules' => 'required|valid_email',
'errors' => [
'required' => 'Email is required',
'valid_email' => 'Enter a valid email address'
]
],
'mobile' => [
'rules' => 'required|numeric|exact_length[10]',
'errors' => [
'required' => 'Mobile number is required',
'numeric' => 'Mobile number must contain digits only',
'exact_length' => 'Mobile number must be exactly 10 digits'
]
],
];
$request_post_data = $this->request->getPost();
$data = sanitizeInputArrayAdvanced($request_post_data);
if (isset($data['relationship'])) {
$rules['relationship'] = [
'rules' => 'required|in_list[Self,Spouse,Child,Father,Mother,Father-in-law,Mother-in-law]',
'errors' => [
'required' => 'Relationship is required',
'in_list' => 'The selected relationship is invalid.'
]
];
}
if (!$this->validate($rules)) {
return $this->response->setStatusCode(400)->setJSON([
'status' => false,
'message' => 'Input validation failed',
'code' => 400,
'errors' => $this->validator->getErrors()
]);
}
// print_rr($data);die();
// $data['dob'] = date('Y-m-d', strtotime($data['dob']));
if(isset( $data['dob'])){
$data['dob'] = change_date_format($data['dob'], null, 'Y-m-d');
}
$data['dob'] = (!empty($data['dob'])) ? change_date_format($data['dob'], null, 'Y-m-d') : null;
// print_rr($data); die;
// Fetch current employee data
@ -2971,12 +3063,15 @@ class EmployeeController extends AdminController
}
public function mapEmployees(){
$client_id = $this->request->getPost('client_id');
$branch_id = $this->request->getPost('branch_id');
$policy_id = $this->request->getPost('client_policy_id');
$selected_employees = (array)$this->request->getPost('selected');
$si_amt = $this->request->getPost('si_amt');
$policy_start_date_unformatted = $this->request->getPost('policy_start_date');
$request_post_data = $this->request->getPost();
$sanitized_post_data = sanitizeInputArrayAdvanced($request_post_data);
$client_id = $sanitized_post_data['client_id'] ?? null;
$branch_id = $sanitized_post_data['branch_id'] ?? null;
$policy_id = $sanitized_post_data['client_policy_id'] ?? null;
$selected_employees = (array)$sanitized_post_data['selected'] ?? [];
$si_amt = $sanitized_post_data['si_amt'] ?? null;
$policy_start_date_unformatted = $sanitized_post_data['policy_start_date'] ?? null;
$policy_start_date = change_date_format($policy_start_date_unformatted, 'd/M/Y', 'Y-m-d');
@ -3013,7 +3108,9 @@ class EmployeeController extends AdminController
}
public function unmapEmployees($actionType){
$selected_employees = (array)$this->request->getPost('selected');
$request_post_data = $this->request->getPost();
$sanitized_post_data = sanitizeInputArrayAdvanced($request_post_data);
$selected_employees = (array)$sanitized_post_data['selected'] ?? [];
if($actionType == 0){
for($i = 0;$i<count($selected_employees);$i++){log_message('error',$selected_employees[$i]);
$result1 = $this->employeeModel->set(['client_id' => null, 'client_branch_id' => null])->where('id',$selected_employees[$i])->update();log_message('error',$result1);
@ -3273,7 +3370,31 @@ class EmployeeController extends AdminController
public function retailendorsementsave()
{
try {
$data = $this->request->getPost();
$rules = [
'endorsement_no' => [
'rules' => 'required',
'errors' => [
'required' => 'Endorsement Number is missing'
]
],
'status' => [
'rules' => 'required',
'errors' => [
'required' => 'Status is required',
]
]
];
if (!$this->validate($rules)) {
return $this->response->setStatusCode(400)->setJSON([
'status' => false,
'message' => 'Input validation failed',
'code' => 400,
'errors' => $this->validator->getErrors()
]);
}
$request_post_data = $this->request->getPost();
$data = sanitizeInputArrayAdvanced($request_post_data);
if (!empty($data['id'])) {
$text = "update";
$updateID = $data['id'];

View File

@ -1665,10 +1665,10 @@ class EmployeeRestController extends AdminController
{
try {
$client = $this->clientModel->where('id', $this->request->getGet('client_id'))->first();
$client = $this->clientModel->where('md5(id)', $this->request->getGet('client_id'))->first();
if (!empty($client)) {
$client['client_logo'] = base_url() . 'public/uploads/logo/' . $client['client_logo'];
$clientPolicy = $this->clientPolicyModel->where('client_id', $this->request->getGet('client_id'))
$clientPolicy = $this->clientPolicyModel->where('md5(client_id)', $this->request->getGet('client_id'))
->where('client_branch_id', $this->request->getGet('client_branch_id'))->findAll();
return $this->respond(['status' => 'success', 'code' => 200, 'data' => ['client' => $client, 'client_policy' => $clientPolicy]], 200);
} else {
@ -2307,7 +2307,7 @@ class EmployeeRestController extends AdminController
$ClientPolicyData = $this->clientPolicyModel->select('client_policy.id as client_policy_id , client_policy.client_id as client_id, client_policy.policy_type_id as policy_type_id, client_policy.is_addon as is_addon , client_policy.open_for_enrollment as OpenForEnrollment , client_policy.inception_type as inception_type, client_policy.policy_no as policy_no, client_policy.insurer_id as insurer_id, DATE_FORMAT(client_policy.policy_end_date, "%d-%m-%Y") AS policy_expiry_date ')
->where('client_policy.client_id', $this->request->getGet('client_id'))
->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)
->where('client_policy.policy_status', $this->request->getGet('policy_status'))
@ -2329,7 +2329,7 @@ class EmployeeRestController extends AdminController
// dd($employeeDetails);
$activeCount = 0;
$inactiveCount = 0;
if (count($employeeDetails)) {
if (count($employeeDetails)) {
foreach ($employeeDetails as $item) {
if ($item['emp_status'] === 'active') {
$activeCount++;
@ -2555,7 +2555,7 @@ class EmployeeRestController extends AdminController
$builder->where('tm.is_active', 1);
if ($client_id > 0) {
$builder->where('tm.client_id', $client_id);
$builder->where('md5(tm.client_id)', $client_id);
}
if (!empty($from_date) && !empty($to_date)) {
@ -3658,7 +3658,7 @@ class EmployeeRestController extends AdminController
where emp.id = :employee_id: and emp.is_active = 1 and emp.emp_status = 'active'
limit 1 ";
$binds = ['insured_emp_id'=>$insured_emp_id,'client_policy_id'=>(int)$client_policy_id,'$employee_id'=>$employee_id ];
$binds = ['insured_emp_id'=>$insured_emp_id,'client_policy_id'=>(int)$client_policy_id,'employee_id'=>$employee_id ];
$emp_ticket_data = $this->employeeModel->query($sql,$binds)->getResultArray();
// print_r(db_connect()->getLastQuery()); die;
@ -4468,7 +4468,21 @@ class EmployeeRestController extends AdminController
return $this->respondCreated(['status' => false, 'message' => 'Client is required', 'data' => []]);
}
$client_data = $this->clientModel->where('id', $post_data['client_id'])->first();
// Handle raw client_id vs MD5
if (is_string($post_data['client_id']) && preg_match('/^[a-f0-9]{32}$/i', $post_data['client_id'])) {
$client_data = $this->clientModel->where('MD5(id)', $post_data['client_id'])->first();
} else {
$client_data = $this->clientModel->where('id', $post_data['client_id'])->first();
}
if(empty($client_data)){
return $this->respondCreated(['status' => false, 'message' => 'Invalid Client Id', 'data' => []]);
}
$post_data['client_id'] = $client_data['id'];
// print_r($client_data); die;
if($client_data['hr_file_processed_by'] == 1){

View File

@ -27,13 +27,13 @@ class FhplApiController extends BaseController
public function generateAuthToken()
{
$url = env('FHPL_TOKEN_URL'); // example: https://uat.fhpl.net/token
$url = env('FHPL_TOKEN_URL');
// x-www-form-urlencoded body
$postData = http_build_query([
'UserName' => 'TestApi@fhpl',
'Password' => 'Fhpl@12345',
'grant_type' => 'password',
'UserName' => env('FHPL_USER_NAME'),
'Password' => env('FHPL_PASSWORD'),
'grant_type' => env('FHPL_GRANT_TYPE'),
]);
$ch = curl_init();
@ -65,9 +65,447 @@ class FhplApiController extends BaseController
return $this->response->setJSON([
'status' => $httpCode === 200,
'http_code' => $httpCode,
'response' => json_decode($response, true),
'data' => json_decode($response, true),
]);
}
public function SubmitClaim($claimId = 515)
{
helper('api');
$data = $this->db->table('ticket_master tm')
->select('
tm.id,
tm.emp_mobile as mobileNo,
tm.emp_mail as emailId,
tm.doa as admissionDate,
tm.dod as dischargeDate,
tm.hospital_name as hospitalName,
tm.claim_amount as requestedAmount,
tm.tpa_no as dependentUniqueId,
cp.policy_no as policyNo,
e.emp_code as memberId,
tn.note as disease,
cf.url as filePath
')
->join('employees e', 'e.id = tm.emp_id', 'left')
->join('client_policy cp', 'tm.client_policy_id = cp.id', 'left')
->join('ticket_notes tn', 'tn.ticket_id = tm.id', 'left')
->join('claim_files cf', "cf.ticket_id = tm.id AND cf.file_type = 2 AND cf.mime_type='application/pdf'", 'left')
->where('tm.id', $claimId)
->get()
->getRowArray();
if (count($data) && $data['filePath'] == null) {
log_message('error', "TPA CLAIM PUSH FAILED FHPL | claimId: '.$claimId.' - Claim or File Missing");
return $this->response->setJSON(['status' => false,'message' => 'Claim or File Missing', ]);
}
// Build absolute file path
$filename = basename($data['filePath']);
$pdfPath = WRITEPATH . 'uploads/claim_files/' . $filename;
if (!file_exists($pdfPath)) {
log_message('error', "TPA CLAIM PUSH FAILED FHPL | claimId: '.$claimId.' - PDF not found on server");
return $this->response->setJSON(['status' => false,'message' => 'PDF not found on server']);
}
// Convert PDF to Base64
$fileContent = base64_encode(file_get_contents($pdfPath));
// Generate FHPL Token
$tokenResponse = json_decode($this->generateAuthToken()->getBody(), true);
if (empty($tokenResponse['data']['access_token'])) {
return $this->response->setJSON(['status' => false,'message' => 'FHPL Token generation failed']);
}
$token = $tokenResponse['data']['access_token'];
// Build FHPL Request
$body = [
"IssueID" => $data['dependentUniqueId'], // this key added after seeing the error in responce have to click with fhpl team
"Userid" => getenv('FHPL_USER_NAME'),
"PolicyNo" => "111700-TATAMTORS", // $data['policyNo'],
"UhidNo" => "OIC40830846", //$data['dependentUniqueId'],
"ClaimID" => (string) $data['id'],
"DOA" => "2025-10-11",//date('Y-m-d', strtotime($data['admissionDate'])),
"DateofDischarge"=> $data['dischargeDate'] ? date('Y-m-d', strtotime($data['dischargeDate'])) : null,
"ClaimedAmount" => (float) $data['requestedAmount'],
"DocumentType" => 20, // Fresh Claim
"PayeeName" => $data['memberId'],
"HospitalName" => $data['hospitalName'],
"MobileNo" => $data['mobileNo'],
"Documents" => [
[
"documentName" => $filename,
"documentCategory" => "IRR",
"filecontent" => $fileContent
]
]
];
$url = getenv('FHPL_BASE_URL') . "/api/ClaimSubmission";
$headers = [
"Authorization: Bearer " . $token,
"Content-Type: application/json"
];
log_message('error', 'TPA CLAIM PUSH FHPL | claimId: '.$claimId.' | payload: '.json_encode($body));
$response = call_third_party_api($url, 'POST', $headers, $body);
log_message('error', 'FHPL RESPONSE | ' . json_encode($response));
if($response['status'] != true){
log_message('error', 'TPA CLAIM PUSH FAILED FHPL | claimId: '.$claimId.' | response: '.json_encode($response));
$this->db->table('ticket_master')
->where('id',$claimId)
->update([ 'tpa_push_response' => json_encode($response) ]);
return;
}
if ($response['status'] === true && !empty($response['data'][0]['ClaimsInfo']))
{
$claimsInfo = json_decode($response['data'][0]['ClaimsInfo'], true);
if (!empty($claimsInfo[0]['ClaimID'])) {
$fhplClaimNo = $claimsInfo[0]['ClaimID'];
$this->db->table('ticket_master')
->where('id', $claimId)
->update([
'claim_number' => $fhplClaimNo,
'tpa_claim_id' => $fhplClaimNo,
'tpa_claim_push_reference_no' => $fhplClaimNo,
'updated_at' => date('Y-m-d H:i:s')
]);
log_message('error', 'TPA CLAIM PUSH SUCCESS FHPL | claimId: '.$claimId.' | claimNO: '.$fhplClaimNo);
}
}
return $this->response->setJSON($response);
}
public function ClaimDetail($claimId = 515)
{
helper('api');
$ticket = $this->db->table('ticket_master tm')
->select("tm.id, tm.tpa_claim_id as claimNo, cp.policy_no , cp.policy_start_date , cp.policy_end_date")
->join('client_policy cp','tm.client_policy_id=cp.id')
->where('tm.id',$claimId)
->get()->getRowArray();
if(!$ticket) return $this->response->setJSON(['status'=>false,'message'=>'Invalid claim']);
// Generate FHPL Token
$tokenResponse = json_decode($this->generateAuthToken()->getBody(), true);
if (empty($tokenResponse['data']['access_token'])) {
return $this->response->setJSON(['status' => false,'message' => 'FHPL Token generation failed']);
}
$token = $tokenResponse['data']['access_token'];
$url = getenv('FHPL_BASE_URL')."/api/GetTPA_ClaimsDetails";
$body = [
"UserName" => getenv('FHPL_USER_NAME'),
"Password" => getenv('FHPL_PASSWORD'),
"PolicyNumber" => "GHI-81-25-00087313-000",//$ticket['policy_no'],
"Fromdate" => "2025-04-26",//$ticket['claimNo'],
"Todate" => "2025-04-27",//$ticket['claimNo'],
];
$headers = ["Authorization: Bearer ".$token,"Content-Type: application/json"];
$response = call_third_party_api($url,'POST',$headers,$body);
// dd($response);
if (empty($response['data'][0])) {
log_message('error', 'CLAIM STATUS FAILED | for ticket ID: ' . $claimId.' | response: '.json_encode($response));
return $this->response->setJSON([
'status' => false,
'message' => 'API call failed.',
'data' => $response
]);
}
$status = null;
// find this claim
foreach($response['data'] as $row){
if($row['CLAIM_ID']==$ticket['claimNo']){
$status = $row['CLAIM_STATUS'];
}
}
$map = [
"In-Progress" => 5,
"Under Process" => 5,
"Query" => 4,
"Paid" => 11,
"Rejected" => 8,
"Approved" => 8,
"Required Information" => 4,
];
if( $status != null && isset($map[$status]))
{
$this->db->table('ticket_master')->where('id',$claimId)->update(['claim_status_id'=>$map[$status],'tpa_claim_status'=>$status]);
// LOG UPDATE
log_message('error', "CLAIM STATUS SUCCESS | Updated ticket ID $claimId with claim status: $status");
}
return $this->response->setJSON([
'status' => true,
'message' => 'Claim status updated.',
'updated_status' => $status,
'api_response' => $response
]);
}
public function ClaimStatusUpdate()
{
helper('api');
$tickets = $this->db->table('ticket_master tm')
->select("tm.id,tm.tpa_claim_id,cp.policy_no")
->join('client_policy cp','tm.client_policy_id=cp.id')
->where('tm.tpa_claim_id IS NOT NULL')
->get()->getResultArray();
$count=0;
foreach($tickets as $t){
$this->ClaimDetail($t['id']);
$count++;
}
return $this->response->setJSON(['status'=>true,'updated'=>$count]);
}
public function EcardRequest($employeeId,$policyNo,$uhid)
{
helper('api');
// Generate FHPL Token
$tokenResponse = json_decode($this->generateAuthToken()->getBody(), true);
if (empty($tokenResponse['data']['access_token'])) {
return $this->response->setJSON(['status' => false,'message' => 'FHPL Token generation failed']);
}
// Generate FHPL Token
$tokenResponse = json_decode($this->generateAuthToken()->getBody(), true);
if (empty($tokenResponse['data']['access_token'])) {
return $this->response->setJSON(['status' => false,'message' => 'FHPL Token generation failed']);
}
$token = $tokenResponse['data']['access_token'];
$url = getenv('FHPL_BASE_URL')."/api/GetEcard";
$body = [
"UserName" => getenv('FHPL_USER_NAME'),
"Password" => getenv('FHPL_PASSWORD'),
"PolicyNumber" => $policyNo,
"EmployeeID" => $employeeId
];
$headers = ["Authorization: Bearer ".$token,"Content-Type: application/json"];
$response = call_third_party_api($url,'POST',$headers,$body);
if(($response['data']['STATUS'] ?? '')=='SUCCESS'){
return $response['data']['E_Card'];
}
return null;
}
public function FhplGetBenefDetails($requestData = null)
{
helper('api');
$policyNo = $requestData['policy_no'] ?? "10/12/2025/16/17";
$client_policy_id = $requestData['client_policy_id'] ?? 0;
// Generate FHPL Token
$tokenResponse = json_decode($this->generateAuthToken()->getBody(), true);
if (empty($tokenResponse['data']['access_token'])) {
return $this->response->setJSON(['status' => false,'message' => 'FHPL Token generation failed']);
}
$token = $tokenResponse['data']['access_token'];
$url = getenv('FHPL_BASE_URL')."/api/GetEnrollmentDetailsPolicy";
$headers = [
"Authorization: Bearer ".$token,
"Content-Type: application/json"
];
$startIndex = 0;
$range = 100;
$allMembers = [];
do {
$body = [
"UserName" => getenv('FHPL_USER_NAME'),
"Password" => getenv('FHPL_PASSWORD'),
"PolicyNumber" => $policyNo,
"StartIndex" => $startIndex,
"Range" => $range
];
$response = call_third_party_api($url,'POST',$headers,$body);
dd($response);
if(empty($response['data']['Members'])){
break;
}
$allMembers = array_merge($allMembers,$response['data']['Members']);
$startIndex += $range;
} while($startIndex < ($response['data']['Total'] ?? 0));
dd($allMembers);
// Now same matching logic you already have
$employeePolicyModel = new EmployeePolicyModel();
$employeePolicyData = $employeePolicyModel
->join('employees','employees.id=employee_polices.employee_id')
->where('employee_polices.client_policy_id',$client_policy_id)
->where('employee_polices.tpa_id IS NULL')
->findAll();
$updated = 0;
foreach($employeePolicyData as $policy){
foreach($allMembers as $m){
if(
strtolower(trim($policy['name']))==strtolower(trim($m['Name'])) &&
$policy['emp_code']==$m['MemberID'] &&
strtolower($policy['relationship'])==strtolower($m['Relation'])
){
$this->db->table('employee_polices')
->where('id',$policy['emp_policy_id'])
->update(['tpa_id'=>$m['UHID']]);
$updated++;
}
}
}
return [
'status'=>true,
'total_fetched'=>count($allMembers),
'updated'=>$updated
];
}
public function syncFhplClaimsToNhance()
{
helper('api');
// Generate FHPL Token
$tokenResponse = json_decode($this->generateAuthToken()->getBody(), true);
if (empty($tokenResponse['data']['access_token'])) {
return $this->response->setJSON(['status' => false,'message' => 'FHPL Token generation failed']);
}
$token = $tokenResponse['data']['access_token'];
$url = getenv('FHPL_BASE_URL')."/api/GetTPA_ClaimsDetails";
$headers = [
"Authorization: Bearer ".$token,
"Content-Type: application/json"
];
$policies = $this->db->table('client_policy')
->where('tpa_id',$this->fhplTpaId)
->get()->getResultArray();
$finalResult=[];
foreach($policies as $policy){
$body = [
"UserName" => getenv('FHPL_USER_NAME'),
"Password" => getenv('FHPL_PASSWORD'),
"PolicyNumber" => $policy['policy_no'],
"Fromdate" => $policy['policy_start_date'],
"Todate" => $policy['policy_end_date']
];
$response = call_third_party_api($url,'POST',$headers,$body);
if(!empty($response['data'])){
$finalResult = array_merge($finalResult,$response['data']);
}
}
// Insert / update ticket_master same way you already do for MediAssist
foreach($finalResult as $row){
$status = $row['CLAIM_STATUS'];
$map = [
"Under Process"=>5,
"Paid"=>11,
"Rejected"=>8,
"Approved"=>8
];
$claimStatus = $map[$status] ?? 1;
$this->db->table('ticket_master')->insert([
'policy_no'=>$row['POLICY_NO'],
'claim_number'=>$row['CLAIM_ID'],
'tpa_claim_id'=>$row['CLAIM_ID'],
'emp_code'=>$row['EMPLOYEE_NO'],
'insured_name'=>$row['PATIENT_NAME'],
'claim_amount'=>$row['CLAIM_AMOUNT'],
'hospital_name'=>$row['HOSPITAL_NAME'],
'doa'=>$row['DATE_OF_ADMISSION'],
'dod'=>$row['DATE_OF_DISCHARGE'],
'claim_status_id'=>$claimStatus,
'tpa_id'=>$this->fhplTpaId
]);
}
return ['status'=>true,'total'=>count($finalResult)];
}
}

View File

@ -155,6 +155,14 @@ class JobWorker extends AdminController
'type' => 'CC', // Handler Category
'handler' => 'App\Controllers\TicketServiceController',
],
'tpaClaimDumpImporter' => [
'type' => 'CC', // Handler Category
'handler' => 'App\Controllers\TicketServiceController',
],
'tpaClaimDumpToTicketMasterImporters' => [
'type' => 'CC', // Handler Category
'handler' => 'App\Controllers\TicketServiceController',
],
'excelMultieventFileFormateValidation' => [
'type' => 'CC', // Handler Category
'handler' => 'App\Controllers\EmployeeMultiEventServiceController',

View File

@ -378,7 +378,95 @@ class LeadsController extends BaseController
private function prepareLeadData()
{
$data = $this->request->getPost();
$rules = [
'lead_type' => [
'rules' => 'required',
'errors' => ['required' => 'Lead Type is required']
],
'issuer' => [
'rules' => 'required',
'errors' => ['required' => 'Issuer is required']
],
'entity_type_id' => [
'rules' => 'required',
'errors' => ['required' => 'Entity Type is required']
],
'client_name' => [
'rules' => 'required',
'errors' => ['required' => 'Client Name is required']
],
'client_short_name' => [
'rules' => 'required',
'errors' => ['required' => 'Client Short Name is required']
],
'gst' => [
'rules' => 'required',
'errors' => ['required' => 'GST Number is required']
],
'branch_name' => [
'rules' => 'required',
'errors' => ['required' => 'Branch Name is required']
],
'branch_code' => [
'rules' => 'required',
'errors' => ['required' => 'Branch Code is required']
],
'contact_person_name' => [
'rules' => 'required',
'errors' => ['required' => 'Contact Person Name is required']
],
'contact_person_mobile' => [
'rules' => 'required',
'errors' => ['required' => 'Contact Person Mobile is required']
],
'contact_person_email' => [
'rules' => 'required|valid_email',
'errors' => [
'required' => 'Contact Person Email is required',
'valid_email' => 'Please enter a valid email address'
]
],
'salse_person_id' => [
'rules' => 'required',
'errors' => ['required' => 'Sales Person is required']
],
'status' => [
'rules' => 'required',
'errors' => ['required' => 'Status is required']
]
];
$request_data = $this->request->getPost();
$data = sanitizeInputArrayAdvanced($request_data);
if($data['lead_form_type'] == 2){
$rules['client_type'] = [
'rules' => 'required',
'errors' => ['required' => 'Client Type is required']
];
$rules['policy_type_id'] = [
'rules' => 'required',
'errors' => ['required' => 'Policy Type is required']
];
$rules['policy_start_date'] = [
'rules' => 'required',
'errors' => ['required' => 'Date of Commencement is required']
];
$rules['policy_end_date'] = [
'rules' => 'required',
'errors' => ['required' => 'Date of Expiry is required']
];
}
if (!$this->validate($rules)) {
return $this->response->setStatusCode(400)->setJSON([
'status' => false,
'message' => 'Input validation failed',
'code' => 400,
'errors' => $this->validator->getErrors()
]);
}
$data['client_type'] = 1;
$data['pan'] = "";
@ -1136,7 +1224,7 @@ class LeadsController extends BaseController
// 12. Conditional rendering based on lead_form_type
if ($lead_data['lead_form_type'] == 1) {
$data['demogrphy_html_data'] = $this->generateDemographyDataTable(['lead_id' => $id]);
// $data['demogrphy_html_data'] = $this->generateDemographyDataTable(['lead_id' => $id]);
$this->loadLayout('view_rfq.php', $data);
} else if ($lead_data['lead_form_type'] == 2) {
$data['occupancy'] = $this->occupancyModel->findAll();
@ -5384,8 +5472,13 @@ class LeadsController extends BaseController
return [];
}
public function generateDemographyDataTable($param)
{
public function generateDemographyDataTable($param = [])
{
if ($this->request !== null) {
$param['lead_id'] = $this->request->getGet('lead_id');
}
$returnData = $this->calculateMembersDemography($param, "internal");
$html = "";
@ -5431,6 +5524,14 @@ class LeadsController extends BaseController
}
}
if ($this->request !== null) {
if(!empty($html)){
return $this->respond(['status' => true, 'data' => $html], 200);
}else{
return $this->respond(['status' => false, 'data' => $html], 200);
}
}
return $html;
}
@ -5726,7 +5827,7 @@ class LeadsController extends BaseController
$first_file_name = $isFirstField ? 'Member List' : '';
$member_data_link = $isFirstField ? $sample_dwn_link : '';
$read_only = $isFirstField ? 'readonly' : '';
$accept = $isFirstField ? '.xls,.xlsx' : '';
$accept = $isFirstField ? '.xls,.xlsx' : '.xls,.xlsx,.pdf,.jpg,.jpeg,.png';
$displayIndex = $index + 1;
$html .= '

View File

@ -62,9 +62,7 @@ class LoginController extends BaseController
set_session_data($session_data);
// Bind session to device
set_session_data(['fingerprint' => hash('sha256',
($this->request->getUserAgent()->getAgentString() . '|' . ($this->request->getIPAddress()
)))]);
set_session_data(['fingerprint' => generateFingerprint()]);
log_message('error', 'Set The UserId : `'. $user->id .'` in Session');
log_message('error', 'User Login Sucessfully');

File diff suppressed because it is too large Load Diff

View File

@ -281,13 +281,17 @@ class PayoutController extends BaseController
//... Payout-invoice Mapping - Save/update/soft Delete/Hard Delete Data
public function saveInvoice()
{
$json = $this->request->getJSON(true);
// print_rr($json);die();
if (!$json) {
$raw_json = $this->request->getJSON(true);
// 1. Check if the JSON was actually valid/parsed before sanitizing
if (is_null($raw_json)) {
return $this->response->setJSON(['error' => 'Invalid JSON','message' => 'Invalid JSON received.'])->setStatusCode(400);
}
// 2. Sanitize the data
$json = sanitizeInputArrayAdvanced($raw_json);
// 3. Now you can safely use $json (even if it is an empty array)
$id = $json['invoice_id'] ?? null;
try {

View File

@ -917,12 +917,14 @@
// policy Transaction Create function start
public function createInceptionPolicy()
{
$post_data = $this->request->getPost() ?? [];
$post_data = $this->request->getPost();
$post_data = $post_data ? sanitizeInputArrayAdvanced($post_data) : [];
$this->myLogger->logme('error', 'Policy Trancaction form data : '. json_encode($post_data));
$id = $this->request->getPost('id');
$id = $post_data['id'] ?? null;
$data = $this->preparePolicyData();
$data['cd_ac_pk'] = $this->request->getPost('cd_ac_no');
$data['cd_ac_pk'] = $post_data['cd_ac_no'];
$data['issuer'] = 2;
$data['status'] = 'completed';
$this->myLogger->logme('error', 'Policy Trancaction modified form data ( insert data ) : '. json_encode($data));
@ -937,7 +939,8 @@
private function preparePolicyData()
{
$data = $this->request->getPost();
$request_data = $this->request->getPost();
$data = sanitizeInputArrayAdvanced($request_data);
$file_data = $this->request->getFiles() ?? null;
$data['file_data'] = $file_data ?? null;
@ -1094,6 +1097,7 @@
private function updateInceptionPolicy($id, $data)
{
// print_r($data); die;
$data['updated_by'] = get_session_userid();
$old_pt_data = $this->policyTransactionModel->where('is_active', 1)->where("id", $id)->first();
$old_pt_co_share_data = $this->PTCOShareDetailsModel->where('is_active', 1)->where("id", $id)->first();
if ($this->policyTransactionModel->update($id, $data)) {
@ -2007,6 +2011,7 @@
{
if ($id) {
$data['is_active'] = 0;
$data['updated_by'] = get_session_userid();
$policy_transaction_data = $this->policyTransactionModel->where('id', $id)->first();
if($policy_transaction_data['policy_type_id'] > 7 && $type == 0){
@ -2247,9 +2252,10 @@
public function createEndorsementPolicy()
{
$id = $this->request->getPost('id');
// $id = $this->request->getPost('id');
$data = $this->preparePolicyTransactionData();
$data['status'] = 'completed';
$id = $data['id'] ?? null;
// print_r($data); die;
if (!$id) {
@ -2261,8 +2267,8 @@
private function preparePolicyTransactionData()
{
$data = $this->request->getPost();
$request_post_data = $this->request->getPost();
$data = sanitizeInputArrayAdvanced($request_post_data);
// echo '<pre>';
// print_r($data);
// die;
@ -2418,6 +2424,7 @@
private function updateEndorsementTransaction($id, $data)
{
$data['updated_by'] = get_session_userid();
$old_endorse_data = $this->policyTransactionModel->where('id', $id)->where('is_active', 1)->first();
$update = $this->policyTransactionModel->where('id', $id)->set($data)->update();
@ -3250,10 +3257,12 @@
$client_policy_id = (!isset($client_policy_id) || $client_policy_id === '' || $client_policy_id === null) ? 0 : $client_policy_id;
$user_id = (!isset($user_id) || $user_id === '' || $user_id === null) ? 0 : $user_id;
if ($this->request->is('post')) {
$isFromDashboard = $this->request->getPost("is_dashboard");
$request_post_data = $this->request->getPost();
$sanitized_post_data = sanitizeInputArrayAdvanced($request_post_data);
$isFromDashboard = $sanitized_post_data["is_dashboard"];
if (isset($isFromDashboard) && !empty($isFromDashboard) && $isFromDashboard == 1) {
$ids = $this->request->getPost('ids');
$ids = $sanitized_post_data['ids'];
$ids = array_filter(explode(',', $ids));
@ -4221,10 +4230,12 @@
// echo 'scbsc';die();
if ($this->request->is('post')) {
// $jsonData = (array)$this->request->getJSON();
$customer_id = $this->request->getPost('customer_id');
$policy_id = $this->request->getPost('policy_id');
$cus_doc_name = $this->request->getPost('cus_doc_name');
$policy_doc_name = $this->request->getPost('policy_doc_name');
$request_data = $this->request->getPost();
$data = sanitizeInputArrayAdvanced($request_data);
$customer_id = $data['customer_id'];
$policy_id = $data['policy_id'];
$cus_doc_name = $data['cus_doc_name'];
$policy_doc_name = $data['policy_doc_name'];
$pt_files = [];
$kyc_files = [];
$batch_files = [];

View File

@ -759,6 +759,8 @@ class RestAuthenticationController extends AdminController
$decoded = json_decode($HRAccessData['allowed_modules'], true);
$getAllhrData[$key]['allowed_modules'] = $decoded;
$HRAccessData['pre_client_id'] = md5($HRAccessData['pre_client_id']);
$HRAccessData['post_client_id'] = md5($HRAccessData['post_client_id']);
$token = JWTToken::encode($HRAccessData);
$getAllhrData[$key]['token'] = $token;

View File

@ -63,7 +63,98 @@ class ThzController extends BaseController
public function ticketSave()
{
try {
$data = $this->request->getPost();
$rules = [
'client_id' => [
'rules' => 'permit_empty|integer',
'errors' => [
'integer' => 'Invalid client selected'
]
],
'mobile' => [
'rules' => 'required|regex_match[/^[0-9]{10}$/]',
'errors' => [
'required' => 'Mobile number is required',
'regex_match' => 'Mobile number must be exactly 10 digits'
]
],
'name' => [
'rules' => 'required|min_length[3]|max_length[100]|alpha_space',
'errors' => [
'required' => 'Name is required',
'min_length' => 'Name must be at least 3 characters',
'alpha_space'=> 'Name can contain only letters and spaces'
]
],
'email' => [
'rules' => 'required|valid_email|max_length[150]',
'errors' => [
'required' => 'Email is required',
'valid_email' => 'Please enter a valid email address'
]
],
'empcode' => [
'rules' => 'permit_empty|max_length[50]',
'errors' => [
'max_length' => 'Employee code is too long'
]
],
'ticket_type' => [
'rules' => 'required|in_list[Sales,Service]',
'errors' => [
'required' => 'Ticket Type is required',
'in_list' => 'Invalid Ticket Type selected'
]
],
'assign_to' => [
'rules' => 'permit_empty|integer',
'errors' => [
'integer' => 'Invalid assignee selected'
]
],
'subject' => [
'rules' => 'required|min_length[5]|max_length[150]',
'errors' => [
'required' => 'Subject is required',
'min_length' => 'Subject must be at least 5 characters',
'max_length' => 'Subject cannot exceed 150 characters'
]
],
'message' => [
'rules' => 'required|min_length[10]|max_length[1500]',
'errors' => [
'required' => 'Message is required',
'min_length' => 'Message must be at least 10 characters',
'max_length' => 'Message cannot exceed 1500 characters'
]
],
'status' => [
'rules' => 'permit_empty|in_list[Open,In Progress,Resolved,Closed]',
'errors' => [
'in_list' => 'Invalid ticket status'
]
],
];
if (!$this->validate($rules)) {
return $this->response->setStatusCode(400)->setJSON([
'status' => false,
'message' => 'Input validation failed',
'code' => 400,
'errors' => $this->validator->getErrors()
]);
}
$request_post_data = $this->request->getPost();
$data = sanitizeInputArrayAdvanced($request_post_data);
$references = "";
if (!empty($data['thz_id'])) {
@ -157,7 +248,30 @@ class ThzController extends BaseController
{
try {
$data = $this->request->getPost();
$rules = [
'notes' => [
'rules' => 'required|string|min_length[1]|max_length[1500]',
'errors' => [
'required' => 'Notes is required',
'string' => 'Notes must be valid text',
'min_length' => 'Notes cannot be empty',
'max_length' => 'Notes cannot exceed 1500 characters'
]
],
];
if (!$this->validate($rules)) {
return $this->response->setStatusCode(400)->setJSON([
'status' => false,
'message' => 'Input validation failed',
'code' => 400,
'errors' => $this->validator->getErrors()
]);
}
$request_post_data = $this->request->getPost();
$data = sanitizeInputArrayAdvanced($request_post_data);
$data['notes_type'] = $data['notes_type'] ?? 'External';

View File

@ -1122,8 +1122,130 @@ class TicketController extends BaseController
public function createTicket()
{
$ticket_data = $this->request->getPost();
$ticket_data = $this->formatDateForClaim($ticket_data);
$rules = [
'emp_code' => [
'rules' => 'required',
'errors' => ['required' => 'Employee Code is required']
],
'emp_name' => [
'rules' => 'required',
'errors' => ['required' => 'Employee Name is required']
],
'insured_name' => [
'rules' => 'required',
'errors' => ['required' => 'Insured Name is required']
],
'relationship' => [
'rules' => 'required',
'errors' => ['required' => 'Relationship is required']
],
'emp_mobile' => [
'rules' => 'required',
'errors' => ['required' => 'Employee Mobile is required']
],
'emp_mail' => [
'rules' => 'required',
'errors' => ['required' => 'Employee Email is required']
],
'client_name' => [
'rules' => 'required',
'errors' => ['required' => 'Client Name is required']
],
'insurer_id' => [
'rules' => 'required',
'errors' => ['required' => 'Insurer is required']
],
'client_policy_id' => [
'rules' => 'required',
'errors' => ['required' => 'Policy is required']
],
'claim_status_id' => [
'rules' => 'required',
'errors' => ['required' => 'Claim Status is required']
],
'priority' => [
'rules' => 'required',
'errors' => ['required' => 'Priority is required']
],
'mode_of_intimation' => [
'rules' => 'required',
'errors' => ['required' => 'Mode of Intimation is required']
],
'claim_type' => [
'rules' => 'required',
'errors' => ['required' => 'Claim Type is required']
],
'hospital_name' => [
'rules' => 'required',
'errors' => ['required' => 'Hospital Name is required']
],
'hospital_address' => [
'rules' => 'required',
'errors' => ['required' => 'Hospital Address is required']
],
'hospital_city' => [
'rules' => 'required',
'errors' => ['required' => 'Hospital City is required']
],
'hospital_state' => [
'rules' => 'required',
'errors' => ['required' => 'Hospital State is required']
],
'hospital_pin_code' => [
'rules' => 'required',
'errors' => ['required' => 'Hospital Pincode is required']
],
'hospital_phone_no' => [
'rules' => 'required',
'errors' => ['required' => 'Hospital Phone Number is required']
],
'doa' => [
'rules' => 'required',
'errors' => ['required' => 'Date of Admission is required']
],
'dod' => [
'rules' => 'required',
'errors' => ['required' => 'Date of Discharge is required']
],
'claim_amount' => [
'rules' => 'required',
'errors' => ['required' => 'Claim Amount is required']
],
];
if (!$this->validate($rules)) {
return $this->response->setStatusCode(400)->setJSON([
'status' => false,
'message' => 'Input validation failed',
'code' => 400,
'errors' => $this->validator->getErrors()
]);
}
$request_data = $this->request->getPost();
$sanitized_data = sanitizeInputArrayAdvanced($request_data);
$ticket_data = $this->formatDateForClaim($sanitized_data);
// $ticket_data = $this->getLastMatchedStatus($ticket_data, );
// print_rr($ticket_data); die;
@ -1183,9 +1305,132 @@ class TicketController extends BaseController
public function updateTicket()
{
$rules = [
'emp_code' => [
'rules' => 'required',
'errors' => ['required' => 'Employee Code is required']
],
'emp_name' => [
'rules' => 'required',
'errors' => ['required' => 'Employee Name is required']
],
'insured_name' => [
'rules' => 'required',
'errors' => ['required' => 'Insured Name is required']
],
'relationship' => [
'rules' => 'required',
'errors' => ['required' => 'Relationship is required']
],
'emp_mobile' => [
'rules' => 'required',
'errors' => ['required' => 'Employee Mobile is required']
],
'emp_mail' => [
'rules' => 'required',
'errors' => ['required' => 'Employee Email is required']
],
'client_name' => [
'rules' => 'required',
'errors' => ['required' => 'Client Name is required']
],
'insurer_id' => [
'rules' => 'required',
'errors' => ['required' => 'Insurer is required']
],
'client_policy_id' => [
'rules' => 'required',
'errors' => ['required' => 'Policy is required']
],
'claim_status_id' => [
'rules' => 'required',
'errors' => ['required' => 'Claim Status is required']
],
'priority' => [
'rules' => 'required',
'errors' => ['required' => 'Priority is required']
],
'mode_of_intimation' => [
'rules' => 'required',
'errors' => ['required' => 'Mode of Intimation is required']
],
'claim_type' => [
'rules' => 'required',
'errors' => ['required' => 'Claim Type is required']
],
'hospital_name' => [
'rules' => 'required',
'errors' => ['required' => 'Hospital Name is required']
],
'hospital_address' => [
'rules' => 'required',
'errors' => ['required' => 'Hospital Address is required']
],
'hospital_city' => [
'rules' => 'required',
'errors' => ['required' => 'Hospital City is required']
],
'hospital_state' => [
'rules' => 'required',
'errors' => ['required' => 'Hospital State is required']
],
'hospital_pin_code' => [
'rules' => 'required',
'errors' => ['required' => 'Hospital Pincode is required']
],
'hospital_phone_no' => [
'rules' => 'required',
'errors' => ['required' => 'Hospital Phone Number is required']
],
'doa' => [
'rules' => 'required',
'errors' => ['required' => 'Date of Admission is required']
],
'dod' => [
'rules' => 'required',
'errors' => ['required' => 'Date of Discharge is required']
],
'claim_amount' => [
'rules' => 'required',
'errors' => ['required' => 'Claim Amount is required']
],
];
if (!$this->validate($rules)) {
return $this->response->setStatusCode(400)->setJSON([
'status' => false,
'message' => 'Input validation failed',
'code' => 400,
'errors' => $this->validator->getErrors()
]);
}
$request_data = $this->request->getPost();
$sanitized_data = sanitizeInputArrayAdvanced($request_data);
$ticket_data = $this->formatDateForClaim($sanitized_data);
$ticket_id = $this->request->getPost('ticket_master_id');
$ticket_data = $this->request->getPost();
$ticket_data = $this->formatDateForClaim($ticket_data);
$old_ticket_data = $this->ticketMasterModel->where('id', $ticket_id)->where('is_active', 1)->first();
$ticket_data['claim_status_id'] = $this->getLastMatchedStatus($ticket_data, $old_ticket_data);
// print_rr($ticket_data); die;
@ -1250,7 +1495,49 @@ class TicketController extends BaseController
{
//action 1 is create. action 2 is edit and action 3 is delete
if ($action == 1) {
$received_data = $this->request->getPost();
$rules = [
'template_name' => [
'rules' => 'required',
'errors' => [
'required' => 'Template Name is required'
]
],
'ticket_type' => [
'rules' => 'required',
'errors' => [
'required' => 'Policy Type is required'
]
],
'trigger_type' => [
'rules' => 'required',
'errors' => [
'required' => 'Trigger Type is required'
]
],
'subject' => [
'rules' => 'required',
'errors' => [
'required' => 'Subject is required'
]
],
'mail_content' => [
'rules' => 'required',
'errors' => [
'required' => 'Mail Content is required'
]
]
];
if (!$this->validate($rules)) {
return $this->response->setStatusCode(400)->setJSON([
'status' => false,
'message' => 'Input validation failed',
'code' => 400,
'errors' => $this->validator->getErrors()
]);
}
$data = $this->request->getPost();
$received_data = sanitizeInputArrayAdvanced($data);
if (isset($received_data['id']) && $received_data['id'] != '') {
$status = $this->ticketMailTemplateModel->save($received_data);
if ($status) {
@ -2502,7 +2789,7 @@ class TicketController extends BaseController
$insertData = [
'doc_name' => $data['docs_name'][$key] ?? '',
'url' => $data['url'][$key] ?? '',
'url' => convertGoogleDriveToDownloadLink($data['url'][$key] ?? ''),
'ticket_id' => $data['ticket_id_url'] ?? '',
'created_by' => get_session_userid(),
'is_active' => 1,
@ -2813,6 +3100,8 @@ class TicketController extends BaseController
{
$data['tab_name'] = "Claim Dupm Upload";
$data['page_name'] = "Claims";
$data['tpa_list'] = $this->TPAModel->where('is_active', 1)->findAll();
if($this->request->is('get')){
@ -2877,17 +3166,25 @@ class TicketController extends BaseController
$status = 'inprogress';
$insert_data = [
'file_name' => $filename,
'status' => $status
'status' => $status,
'client_id' => !empty($this->request->getPost('client_id')) ? $this->request->getPost('client_id') : null,
'client_policy_id' => !empty($this->request->getPost('client_policy_id')) ? $this->request->getPost('client_policy_id') : null,
'tpa_id' => !empty($this->request->getPost('tpa_id')) ? $this->request->getPost('tpa_id') : null,
];
$file_id = $this->claimDumpFileModel->insert($insert_data);
$this->myLogger->logme("error", 'claim_dumb_file_id : {file_id}, uploaded success', ['file_id' => $file_id]);
//after file upload success than call the file formate validation in service controller
$ticketServiceController = new TicketServiceController();
// $response = $ticketServiceController->claimDumpExcelFileFormatValidation(["file_id" => $file_id]);
$r = Jobs::addJob(['job_name' => 'claimDumpExcelFileFormatValidation', 'payload' => ['file_id' => $file_id]]);
// $ticketServiceController = new TicketServiceController();
if(!empty($insert_data['tpa_id'])){
$r = Jobs::addJob(['job_name' => 'tpaClaimDumpImporter', 'payload' => ['file_id' => $file_id]]);
// $response = $ticketServiceController->claimDumpExcelFileFormatValidation(["file_id" => $file_id]);
}else{
$r = Jobs::addJob(['job_name' => 'claimDumpExcelFileFormatValidation', 'payload' => ['file_id' => $file_id]]);
// $response = $ticketServiceController->claimDumpExcelFileFormatValidation(["file_id" => $file_id]);
}
return $this->respond(['status' => true, 'code' => 200, 'message' => 'File uploaded successfully. File being validated'], 200);
}
@ -2986,8 +3283,12 @@ class TicketController extends BaseController
}
// -------- CLAIM MIS UPLOAD ----------------------------------------------------------------------------------------------
public function claimMisFileList()
{
{
$data['tab_name'] = "Claim MIS Upload";
$data['page_name'] = "Cliam MIS Files";
$data['claim_mis_file_list'] = $this->claimmisFileModel
->select('claims_mis_files.*, user_profiles.first_name as user_name')
@ -3002,6 +3303,71 @@ class TicketController extends BaseController
public function uploadClaimMisFile()
{
$filename = '';
$fileSize = '';
//validate uploaded file
$validated = $this->validate([
'file' => [
'uploaded[file]',
'mime_in[file,application/vnd.ms-excel,application/vnd.openxmlformats-officedocument.spreadsheetml.sheet,application/vnd.oasis.opendocument.spreadsheet]',
'max_size[file,16384]',
],
]);
if ($validated)
{
$file = $this->request->getFile('file');
if (!$file) {
$this->myLogger->logme("error", 'File not found');
return $this->respond(['status' => false, 'code' => 400, 'message' => 'File not found'], 400);
}
$is_moved = $file->move(WRITEPATH . 'uploads/claims_mis/');
if ($is_moved) {
$file_path = WRITEPATH.'uploads/claims_mis';
$filename = file_Upload_for_lead($file, $file_path);
$fileSize = $file->getSize(); // File size in bytes
$fileSize = $fileSize / (1024 * 1024); // Convert to MB
$this->myLogger->logme("error", 'File move successful');
$request_data = $this->request->getPost();
$data = sanitizeInputArrayAdvanced($request_data);
if(isset($data['from_date']) && !empty($data['from_date'])){
$data['from_date'] = change_date_format($data['from_date'], 'd/m/Y', 'Y-m-d');
}
if(isset($data['to_date']) && !empty($data['to_date'])){
$data['to_date'] = change_date_format($data['to_date'], 'd/m/Y', 'Y-m-d');
}
if(!empty($file_name)){
$data['file_name'] = $file;
}
$response = $this->claimmisFileModel->insert($data);
if($response){
return $this->respond(['status'=>true, 'code'=>200, 'message'=>'MIS file uploaded successfully'], 200);
}else{
return $this->respond(['status'=>true, 'code'=>500, 'message'=>'Failed to upload'], 200);
}
} else {
$this->myLogger->logme("error", 'File move failed');
return $this->respond(['status' => false, 'code' => 500, 'message' => 'File move failed'], 500);
}
} else {
$this->myLogger->logme("error", 'Upload failed Invalid file');
return $this->respond(['status' => false, 'code' => 404, 'message' => 'Invalid file'], 404);
}
/*** OLD CODE KEEP it Safe
$file = $this->request->getFile('file');
$data = $this->request->getPost();
@ -3027,6 +3393,7 @@ class TicketController extends BaseController
}else{
return $this->respond(['status'=>true, 'code'=>500, 'message'=>'Failed to upload'], 200);
}
****/
}
public function downloadClaimMisFile()

View File

@ -7,6 +7,9 @@ use CodeIgniter\HTTP\ResponseInterface;
use CodeIgniter\API\ResponseTrait;
use PhpOffice\PhpSpreadsheet\Cell\Coordinate;
use Kint\Kint;
use App\Libraries\TpaClaimsImportFactory;
use App\Libraries\TPAClaimsImportServices\FhplClaimImportService;
use App\Libraries\TPAClaimsImportServices\BaseTpaClaimImportService;
use App\Models\ClaimDumpFileModel;
use App\Models\EmployeeModel;
@ -15,10 +18,14 @@ use App\Models\TPAModel;
use App\Models\ClientModel;
use App\Models\TicketClaimStatusModel;
use App\Models\ClientPolicyModel;
use App\Models\ClaimsDumpFhplModel;
use App\Helpers\ExcelSanitizeHelper;
use App\Models\TicketMasterModel;
use PhpOffice\PhpSpreadsheet\IOFactory;
use PhpOffice\PhpSpreadsheet\Spreadsheet;
class TicketServiceController extends BaseController
{
use ResponseTrait;
@ -35,6 +42,10 @@ class TicketServiceController extends BaseController
protected $ticketClaimStatusModel;
protected $clientPolicyModel;
protected $medi_assist_primary_key;
protected $vidal_primary_key;
protected $icici_primary_key;
public function __construct()
{
@ -50,6 +61,11 @@ class TicketServiceController extends BaseController
$this->ticketClaimStatusModel = new TicketClaimStatusModel();
$this->clientPolicyModel = new ClientPolicyModel();
$this->medi_assist_primary_key = getenv('MEDI_ASSIST_PRIMARY_KEY_CONSTANT');
$this->vidal_primary_key = getenv('VIDAL_PRIMARY_KEY_CONSTANT');
$this->icici_primary_key = getenv('ICICI_PRIMARY_KEY_CONSTANT');
$this->claim_dump_excel_columns = [
// Mandatory Fields
@ -1819,5 +1835,243 @@ class TicketServiceController extends BaseController
{
}
// --------------------------------------------------------------------------------------------------------------------------------
public function tpaClaimImporter($params)
{
$file_id = $params['file_id'];
$tpa_claims_files_data = $this->claimDumpFileModel->where('id', $file_id)->first();
if($this->vidal_primary_key == $tpa_claims_files_data['tpa_id']){
}else if($this->icici_primary_key == $tpa_claims_files_data['tpa_id']){
}else{
$this->myLogger->logme('error', 'No TPA found to import');
return ['status' => false, 'message' => 'No TPA found to import'];
}
}
public function tpaClaimDumpImporter($params)
{
try {
$file_id = $params['file_id'] ?? null;
$file_path = WRITEPATH . 'uploads/claim_dump_excel/';
if (!$file_id) {
return ['status' => false, 'message' => 'File ID is missing'];
}
$fileData = $this->claimDumpFileModel->where('id', $file_id)->first();
if (!$fileData) {
return ['status' => false, 'message' => 'Invalid file ID. No file data found'];
}
$file_full_path = $file_path . $fileData['file_name'];
if (!is_file($file_full_path)) {
return ['status' => false, 'message' => 'Claim dump file not found'];
}
$handler = TpaClaimsImportFactory::make($fileData['tpa_id'] ?? 0);
$result = $handler->runTpaClaimDumpInsert($file_full_path, $file_id);
// ---------- Prepare update data ----------
$data = [];
if (!empty($result['status']) && $result['status'] === true) {
$data['status'] = 'success';
$data['reason'] = null;
} else {
$data['status'] = 'failed';
$errorMessage = $result['message'] ?? 'Unknown import error';
$reason = [
'error_summary' => array_count_values([5]),
'error_data' => $errorMessage
];
$data['reason'] = json_encode($reason, JSON_UNESCAPED_UNICODE);
}
// dd($data);
// ---------- Update DB ----------
$sql = "UPDATE claim_dump_files SET status = ?, reason = ? WHERE id = ?";
$updated = db_connect()->query(
$sql,
[
$data['status'] ?? null,
$data['reason'] ?? null,
$file_id
]
);
if (!$updated) {
$this->myLogger->logme('error', 'Claim dump file update failed for file_id: ' . $file_id);
}
dd(db_connect()->getLastQuery()->getQuery());
if(!empty($result['status']) && $result['status'] === true){
$r = Jobs::addJob(['job_name' => 'tpaClaimDumpToTicketMasterImporters', 'payload' => ['file_id' => $file_id]]);
}
return $result;
} catch (\Throwable $th) {
$this->myLogger->logme(
"error",
'TPA_CLAIM_IMPORTER_JOB : ' .
$th->getMessage() . ' | Line: ' . $th->getLine()
);
return [
'status' => false,
'message' => 'TPA Claim dump import failed',
'error_data' => [
'message' => $th->getMessage(),
'file' => $th->getFile(),
'line' => $th->getLine(),
'trace' => $th->getTraceAsString()
]
];
}
}
public function tpaClaimDumpToTicketMasterImporters($params)
{
try {
$file_id = $params['file_id'] ?? null;
$fileData = $this->claimDumpFileModel->where('id', $file_id)->first();
if (!$fileData) {
return ['status' => false, 'message' => 'Invalid file ID No file data found to import'];
}
$handler = TpaClaimsImportFactory::make($fileData['tpa_id'] ?? 0);
$result = $handler->runTicketMasterInsert($params);
return $result;
} catch (\Throwable $th) {
$this->myLogger->logme("error", 'TICKET_MASTER_CLAIM_IMPORTER_JOB :' .($th->getMessage() . ' --- ' . $th->getLine() . '----' . $th->getTraceAsString()));
$errorData = [
'message' => $th->getMessage(),
'file' => $th->getFile(),
'line' => $th->getLine(),
'code' => $th->getCode(),
'trace' => $th->getTraceAsString(),
'trace_array' => $th->getTrace(), // full array version (optional)
'function' => $th->getTrace()[0]['function'] ?? null,
'class' => $th->getTrace()[0]['class'] ?? null,
];
return [
'status' => false,
'message' => $th->getMessage(),
'error_data' => json_encode($errorData, JSON_PRETTY_PRINT)
];
}
}
public function tpaClaimDumpToTicketMasterImportBatchSeperater($params)
{
try {
$file_id = $params['file_id'] ?? null;
$fileData = $this->claimDumpFileModel->where('id', $file_id)->first();
if (!$fileData) {
return ['status' => false, 'message' => 'Invalid file ID No file data found to import'];
}
$handler = TpaClaimsImportFactory::make($fileData['tpa_id'] ?? 0);
$result = $handler->runTicketMasterInsert($params);
return $result;
} catch (\Throwable $th) {
$this->myLogger->logme("error", 'TICKET_MASTER_CLAIM_IMPORTER_JOB :' .($th->getMessage() . ' --- ' . $th->getLine() . '----' . $th->getTraceAsString()));
$errorData = [
'message' => $th->getMessage(),
'file' => $th->getFile(),
'line' => $th->getLine(),
'code' => $th->getCode(),
'trace' => $th->getTraceAsString(),
'trace_array' => $th->getTrace(), // full array version (optional)
'function' => $th->getTrace()[0]['function'] ?? null,
'class' => $th->getTrace()[0]['class'] ?? null,
];
return [
'status' => false,
'message' => $th->getMessage(),
'error_data' => json_encode($errorData, JSON_PRETTY_PRINT)
];
}
}
public function readExcelBySheetName(string $filePath, string $sheetName): array
{
if (!file_exists($filePath)) {
return [];
}
$spreadsheet = IOFactory::load($filePath);
// Get sheet by name
$sheet = $spreadsheet->getSheetByName($sheetName);
if ($sheet === null) {
return [];
}
$rows = $sheet->toArray(null, true, true, true);
// Need at least header + one row
if (count($rows) < 2) {
return [];
}
// First row = headers
$headers = array_shift($rows);
$headers = array_map('trim', $headers);
$data = [];
foreach ($rows as $row) {
// Skip completely empty rows
if (!array_filter($row)) {
continue;
}
$item = [];
foreach ($headers as $key => $headerName) {
if ($headerName !== '') {
$item[$headerName] = $row[$key] ?? null;
}
}
$data[] = $item;
}
return $data;
}
}

View File

@ -83,7 +83,114 @@ class UserController extends AdminController
return redirect()->to(base_url('/user/list'));
} else {
$userData = $this->request->getPost();
// $userData = $this->request->getPost();
$data = $this->request->getPost();
$userData = sanitizeInputArrayAdvanced($data);
$rules = [
// ======================
// Nhance Branch
// ======================
'nhance_branch_id' => [
'rules' => 'required|integer',
'errors' => [
'required' => 'Nhance Branch is required',
'integer' => 'Invalid Nhance Branch selected'
]
],
// ======================
// Reporting Manager
// ======================
'rm_id' => [
'rules' => 'required|integer',
'errors' => [
'required' => 'Reporting Manager is required',
'integer' => 'Invalid Reporting Manager selected'
]
],
// ======================
// Employee Code
// ======================
'emp_code' => [
'rules' => 'required|alpha_numeric|min_length[3]|max_length[20]|is_unique[user_profiles.emp_code,id,{PrimaryKey}]',
'errors' => [
'required' => 'Employee Code is required',
'alpha_numeric' => 'Employee Code must be alphanumeric',
'min_length' => 'Employee Code must be at least 3 characters',
'max_length' => 'Employee Code cannot exceed 20 characters',
'is_unique' => 'Employee Code already exists'
]
],
// ======================
// First Name
// ======================
'first_name' => [
'rules' => 'required|alpha_space|min_length[2]|max_length[100]',
'errors' => [
'required' => 'Name is required',
'alpha_space' => 'Name can contain only letters and spaces',
'min_length' => 'Name must be at least 2 characters',
'max_length' => 'Name cannot exceed 100 characters'
]
],
// ======================
// Email
// ======================
'email' => [
'rules' => 'required|valid_email|is_unique[user_profiles.email,id,{PrimaryKey}]',
'errors' => [
'required' => 'Email is required',
'valid_email' => 'Please enter a valid email address',
'is_unique' => 'Email already exists'
]
],
// ======================
// Mobile
// ======================
'mobile' => [
'rules' => 'required|regex_match[/^[6-9][0-9]{9}$/]|is_unique[user_profiles.mobile,id,{PrimaryKey}]',
'errors' => [
'required' => 'Mobile number is required',
'regex_match' => 'Enter a valid 10-digit mobile number starting with 6, 7, 8, or 9',
'is_unique' => 'Mobile number already exists'
]
],
// ======================
// Role
// ======================
'role' => [
'rules' => 'required|integer',
'errors' => [
'required' => 'User Role is required',
'integer' => 'Invalid User Role selected'
]
],
// ======================
// Team (Multiple select)
// ======================
'team' => [
'rules' => 'required',
'errors' => [
'required' => 'At least one User Team must be selected'
]
],
];
if (!$this->validate($rules)) {
return $this->response->setStatusCode(400)->setJSON([
'status' => false,
'message' => 'Input validation failed',
'code' => 400,
'errors' => $this->validator->getErrors()
]);
}
$userData['created_by'] = get_session_userid();
$temp_team = $userData['team'];
unset($userData['team']);
@ -167,9 +274,116 @@ class UserController extends AdminController
return redirect()->to(base_url('/user/list'));
} else {
// echo ":/ in 163";
$id = $this->request->getPost('PrimaryKey');
$teams = $this->request->getPost('team');
$userData = $this->request->getPost();
$rules = [
// ======================
// Nhance Branch
// ======================
'nhance_branch_id' => [
'rules' => 'required|integer',
'errors' => [
'required' => 'Nhance Branch is required',
'integer' => 'Invalid Nhance Branch selected'
]
],
// ======================
// Reporting Manager
// ======================
'rm_id' => [
'rules' => 'required|integer',
'errors' => [
'required' => 'Reporting Manager is required',
'integer' => 'Invalid Reporting Manager selected'
]
],
// ======================
// Employee Code
// ======================
'emp_code' => [
'rules' => 'required|alpha_numeric|min_length[3]|max_length[20]|is_unique[user_profiles.emp_code,id,{PrimaryKey}]',
'errors' => [
'required' => 'Employee Code is required',
'alpha_numeric' => 'Employee Code must be alphanumeric',
'min_length' => 'Employee Code must be at least 3 characters',
'max_length' => 'Employee Code cannot exceed 20 characters',
'is_unique' => 'Employee Code already exists'
]
],
// ======================
// First Name
// ======================
'first_name' => [
'rules' => 'required|alpha_space|min_length[2]|max_length[100]',
'errors' => [
'required' => 'Name is required',
'alpha_space' => 'Name can contain only letters and spaces',
'min_length' => 'Name must be at least 2 characters',
'max_length' => 'Name cannot exceed 100 characters'
]
],
// ======================
// Email
// ======================
'email' => [
'rules' => 'required|valid_email|is_unique[user_profiles.email,id,{PrimaryKey}]',
'errors' => [
'required' => 'Email is required',
'valid_email' => 'Please enter a valid email address',
'is_unique' => 'Email already exists'
]
],
// ======================
// Mobile
// ======================
'mobile' => [
'rules' => 'required|regex_match[/^[6-9][0-9]{9}$/]|is_unique[user_profiles.mobile,id,{PrimaryKey}]',
'errors' => [
'required' => 'Mobile number is required',
'regex_match' => 'Enter a valid 10-digit mobile number starting with 6, 7, 8, or 9',
'is_unique' => 'Mobile number already exists'
]
],
// ======================
// Role
// ======================
'role' => [
'rules' => 'required|integer',
'errors' => [
'required' => 'User Role is required',
'integer' => 'Invalid User Role selected'
]
],
// ======================
// Team (Multiple select)
// ======================
'team' => [
'rules' => 'required',
'errors' => [
'required' => 'At least one User Team must be selected'
]
],
];
if (!$this->validate($rules)) {
return $this->response->setStatusCode(400)->setJSON([
'status' => false,
'message' => 'Input validation failed',
'code' => 400,
'errors' => $this->validator->getErrors()
]);
}
$data = $this->request->getPost();
$userData = sanitizeInputArrayAdvanced($data);
$id = $userData['PrimaryKey'];
$teams = $userData['team'];
unset($userData['csrf_test_name']);
unset($userData['PrimaryKey']);
@ -594,29 +808,100 @@ class UserController extends AdminController
// add/update
if ($method === 'post') {
$data = $this->request->getPost();
$id = !empty($data['PrimaryKey']) ? $data['PrimaryKey'] : null;
$rules = [
// ======================
// Partner Name
// ======================
'name' => [
'rules' => 'required|alpha_space|min_length[2]|max_length[100]',
'errors' => [
'required' => 'Partner name is required',
'alpha_space' => 'Partner name can contain only letters and spaces',
'min_length' => 'Partner name must be at least 2 characters',
'max_length' => 'Partner name cannot exceed 100 characters'
]
],
// ======================
// Mobile Number
// ======================
'mobile' => [
'rules' => 'required|regex_match[/^[6-9][0-9]{9}$/]',
'errors' => [
'required' => 'Mobile number is required',
'regex_match' => 'Enter a valid 10-digit mobile number starting with 6, 7, 8, or 9',
]
],
// ======================
// Email
// ======================
'email' => [
'rules' => 'required|valid_email',
'errors' => [
'required' => 'Email is required',
'valid_email' => 'Please enter a valid email address',
]
],
// ======================
// Retention Rate
// ======================
'retention_rate' => [
'rules' => [
'required',
'regex_match[/^(100(\.0{1,2})?|([0-9]{1,2})(\.[0-9]{1,2})?)$/]'
],
'errors' => [
'required' => 'Retention Rate is required',
'regex_match' => 'Retention Rate must be between 0 and 100 with up to 2 decimal places'
]
],
// ======================
// Nhance Branch
// ======================
'nhance_branch_id' => [
'rules' => 'required|integer',
'errors' => [
'required' => 'Nhance Branch is required',
'integer' => 'Invalid Nhance Branch selected'
]
],
];
if (! $this->validate($rules)) {
return $this->response->setStatusCode(400)->setJSON([
'status' => false,
'message' => 'Input validation failed',
'code' => 400,
'errors' => $this->validator->getErrors()
]);
}
$data = $this->request->getPost();
$sanitized_post_data = sanitizeInputArrayAdvanced($data);
$id = !empty($sanitized_post_data['PrimaryKey']) ? $sanitized_post_data['PrimaryKey'] : null;
unset($sanitized_post_data['pk']);
// don't forgot same means just unset the key because partner_staff some UNIQUE KEY sets in table thats why
if ($id) {
$existing = $this->partnerStaffModel->find((int)$id);
if ($existing) {
if ($data['email'] === $existing['email']) { unset($data['email']); }
if ($data['mobile'] === $existing['mobile']) { unset($data['mobile']); }
if ($sanitized_post_data['email'] === $existing['email']) { unset($sanitized_post_data['email']); }
if ($sanitized_post_data['mobile'] === $existing['mobile']) { unset($sanitized_post_data['mobile']); }
}
}
$errors = [];
// Check Email Duplicate (if it wasn't unset)
if (isset($data['email'])) {
$count = $this->partnerStaffModel->where('email', $data['email'])->countAllResults();
if (isset($sanitized_post_data['email'])) {
$count = $this->partnerStaffModel->where('email', $sanitized_post_data['email'])->countAllResults();
if ($count > 0) $errors['email'] = "This email is already taken by another user.";
}
// Check Mobile Duplicate (if it wasn't unset)
if (isset($data['mobile'])) {
$count = $this->partnerStaffModel->where('mobile', $data['mobile'])->countAllResults();
if (isset($sanitized_post_data['mobile'])) {
$count = $this->partnerStaffModel->where('mobile', $sanitized_post_data['mobile'])->countAllResults();
if ($count > 0) $errors['mobile'] = "This mobile is already taken by another user.";
}
@ -632,14 +917,14 @@ class UserController extends AdminController
// --- Save/Update ---
if ($id) {
$text = "update";
$data['updated_by'] = get_session_userid();
$sanitized_post_data['updated_by'] = get_session_userid();
$result = $this->partnerStaffModel->update($id, $data);
$result = $this->partnerStaffModel->update($id, $sanitized_post_data);
} else {
$text = "create";
$data['role_id'] = 1;
$data['created_by'] = get_session_userid();
$id = $this->partnerStaffModel->insert($data);
$sanitized_post_data['role_id'] = 1;
$sanitized_post_data['created_by'] = get_session_userid();
$id = $this->partnerStaffModel->insert($sanitized_post_data);
if($id){
$details['manager_id'] = $id;
$details['updated_by'] = get_session_userid();

View File

@ -112,7 +112,7 @@ class VidalApiController extends BaseController
];
}
public function SubmitClaim ($claimId = 515)
public function SubmitClaim ($claimId = null) //515
{
helper('api');

View File

@ -23,13 +23,11 @@ class AuthMVC implements FilterInterface
// }
// Fingerprint validation
$fp = hash('sha256',
$request->getUserAgent()->getAgentString() . '|' . $request->getIPAddress()
);
if (session()->get('fingerprint') !== $fp) {
return AuthLogout::logout();
}
// $fp = generateFingerprint();
// // log_message('error',$fp);
// if (session()->get('fingerprint') !== $fp) {
// return AuthLogout::logout();
// }
}

View File

@ -38,6 +38,7 @@ class JWTToken
}else{
$models = new LevelContactModel();
$id = $request_data['post_hr_id'];
$models->update($id, $data);
}

View File

@ -1884,7 +1884,7 @@ if (!function_exists('premium_calculation_manager')) {
}
// if the family floater case first self add first the process completed, after spouse or any dependent add the rata premium not added this change will handle this
if (strtolower($emp_data['relationship']) != 'self' && $temp_slab_rates[0]['premium_type'] == 1 && $emp_data['temp']['action'] == 'DA') {
if (strtolower($emp_data['relationship']) != 'self' && empty($emp_data['temp']['acting_self']) && $temp_slab_rates[0]['premium_type'] == 1 && $emp_data['temp']['action'] == 'DA') {
//set dependent si to 0
$emp_data['policy_details']['basic_cover_si'] = 0;
$emp_data['policy_details']['premium'] = 0;
@ -1897,7 +1897,7 @@ if (!function_exists('premium_calculation_manager')) {
$emp_data['policy_details']['gst'] = (float) number_format(($emp_data['policy_details']['rata_premimum'] * ($gst / 100)), 2, '.', '');
}
}else if(strtolower($emp_data['relationship']) != 'self' && $temp_slab_rates[0]['premium_type'] == 1 && ($emp_data['temp']['action'] == 'I' || $emp_data['temp']['action'] == 'A' || $emp_data['temp']['action'] == 'MI')){
}else if(strtolower($emp_data['relationship']) != 'self' && empty($emp_data['temp']['acting_self']) && $temp_slab_rates[0]['premium_type'] == 1 && ($emp_data['temp']['action'] == 'I' || $emp_data['temp']['action'] == 'A' || $emp_data['temp']['action'] == 'MI')){
$emp_data['policy_details']['basic_cover_si'] = 0;
$emp_data['policy_details']['premium'] = 0;

View File

@ -640,6 +640,8 @@ if (!function_exists('change_date_format')) {
'd/m/Y', // 01/01/2025
'd-m-Y', // 01-01-2025
'm/d/Y h:i:s A', // 01-01-2025
'm/d/Y', // 25-05-2025
];
@ -649,7 +651,7 @@ if (!function_exists('change_date_format')) {
$date = DateTime::createFromFormat($source_format, $date_str);
if (!$date) {
// throw new Exception("Invalid date string for source format: $source_format");
log_message('error', "❌ Date format error : Invalid date string | Params => date_str: {$date_str}, source_format: {$source_format}, output_format: {$output_format}");
// log_message('error', "❌ Date format error : Invalid date string | Params => date_str: {$date_str}, source_format: {$source_format}, output_format: {$output_format}");
return null;
}
return $date->format($output_format);
@ -660,7 +662,7 @@ if (!function_exists('change_date_format')) {
$date = DateTime::createFromFormat($source_format, $date_str);
if (!$date) {
// throw new Exception("Invalid date string for source format: $source_format");
log_message('error', "❌ Date format error : Invalid date string | Params => date_str: {$date_str}, source_format: {$source_format}, output_format: {$output_format}");
// log_message('error', "❌ Date format error : Invalid date string | Params => date_str: {$date_str}, source_format: {$source_format}, output_format: {$output_format}");
return null;
}
return $date->format('Y-m-d'); // MySQL default format
@ -677,15 +679,15 @@ if (!function_exists('change_date_format')) {
// If no format matches, throw an exception
$allowed_placeholders = implode(', ', $allowed_formats);
// throw new Exception("Invalid date string format. Allowed formats: $allowed_placeholders");
log_message(
'error',
"❌ Date format error: Invalid date string. Allowed formats: {$allowed_placeholders} | Params => date_str: {$date_str}, source_format: {$source_format}, output_format: {$output_format}"
);
// log_message(
// 'error',
// "❌ Date format error: Invalid date string. Allowed formats: {$allowed_placeholders} | Params => date_str: {$date_str}, source_format: {$source_format}, output_format: {$output_format}"
// );
return null;
}
} catch (Exception $e) {
// return "Error: " . $e->getMessage();
log_message('error', "❌ Date format error: {$e->getMessage()} | Params => date_str: {$date_str}, source_format: {$source_format}, output_format: {$output_format}");
// log_message('error', "❌ Date format error: {$e->getMessage()} | Params => date_str: {$date_str}, source_format: {$source_format}, output_format: {$output_format}");
return null;
}
@ -1036,3 +1038,66 @@ if (!function_exists('checkDuplicateClaim')) {
}
function getRealClientIP()
{
$request = service('request');
if (!empty($_SERVER['HTTP_CF_CONNECTING_IP'])) {
return $_SERVER['HTTP_CF_CONNECTING_IP'];
}
if (!empty($_SERVER['HTTP_X_FORWARDED_FOR'])) {
return explode(',', $_SERVER['HTTP_X_FORWARDED_FOR'])[0];
}
return $request->getIPAddress();
}
function generateFingerprint()
{
$request = service('request');
$ua = $request->getUserAgent()->getAgentString();
$ip = getRealClientIP();
// Use only subnet (first 3 blocks) to tolerate IP change
$ipParts = explode('.', $ip);
$ipSubnet = $ipParts[0] . '.' . $ipParts[1] . '.' . $ipParts[2];
// $secret = env('app.sessionFingerprintSalt');
// return hash('sha256', $ua . '|' . $ipSubnet . '|' . $secret);
return hash('sha256', $ua . '|' . $ipSubnet );
}
if (!function_exists('convertGoogleDriveToDownloadLink')) {
function convertGoogleDriveToDownloadLink(?string $url): ?string
{
if (empty($url)) {
return null;
}
// Trim spaces
$url = trim($url);
// Pattern to extract Google Drive file ID
$patterns = [
'#https?://drive\.google\.com/file/d/([^/]+)/?#',
'#https?://drive\.google\.com/open\?id=([^&]+)#',
'#https?://drive\.google\.com/uc\?id=([^&]+)#'
];
foreach ($patterns as $pattern) {
if (preg_match($pattern, $url, $matches)) {
$fileId = $matches[1];
// Return direct download link
return 'https://drive.google.com/uc?export=download&id=' . $fileId;
}
}
// Not a Google Drive link → return original
return $url;
}
}

View File

@ -0,0 +1,480 @@
<?php
namespace App\Libraries\TPAClaimsImportServices;
use App\Models\TicketMasterModel;
use App\Models\ClientPolicyModel;
use App\Models\ClientRMModel;
use App\Models\EmployeeModel;
use App\Models\ClaimDumpFileModel;
class AbhiClaimImportService extends BaseTpaClaimImportService
{
/**
* MAPPING ARRAYs
*/
protected $mapping = [
["excel_column" => ["col_name" => "ABHI Claim No", "col_index" => 0], "db_column" => "abhi_claim_no"],
["excel_column" => ["col_name" => "New ABHI Claim No With Extension", "col_index" => 1], "db_column" => "new_abhi_claim_no_with_extension"],
["excel_column" => ["col_name" => "Unique Count", "col_index" => 2], "db_column" => "unique_count"],
["excel_column" => ["col_name" => "Proposer Name", "col_index" => 3], "db_column" => "proposer_name"],
["excel_column" => ["col_name" => "Patient Name", "col_index" => 4], "db_column" => "patient_name"],
["excel_column" => ["col_name" => "Family ID", "col_index" => 5], "db_column" => "family_id"],
["excel_column" => ["col_name" => "Member Code", "col_index" => 6], "db_column" => "member_code"],
["excel_column" => ["col_name" => "Patient Age", "col_index" => 7], "db_column" => "patient_age"],
["excel_column" => ["col_name" => "Relation", "col_index" => 8], "db_column" => "relation"],
["excel_column" => ["col_name" => "Gender", "col_index" => 9], "db_column" => "gender"],
["excel_column" => ["col_name" => "Certificate No", "col_index" => 10], "db_column" => "certificate_no"],
["excel_column" => ["col_name" => "Master Policy No", "col_index" => 11], "db_column" => "master_policy_no"],
["excel_column" => ["col_name" => "Policy Number", "col_index" => 12], "db_column" => "policy_number"],
["excel_column" => ["col_name" => "Policy From", "col_index" => 13], "db_column" => "policy_from"],
["excel_column" => ["col_name" => "Policy Upto", "col_index" => 14], "db_column" => "policy_upto"],
["excel_column" => ["col_name" => "Product Name", "col_index" => 15], "db_column" => "product_name"],
["excel_column" => ["col_name" => "Product Name 1", "col_index" => 16], "db_column" => "product_name_1"],
["excel_column" => ["col_name" => "Sub - Product", "col_index" => 17], "db_column" => "sub_product"],
["excel_column" => ["col_name" => "Policy Category", "col_index" => 18], "db_column" => "policy_category"],
["excel_column" => ["col_name" => "Policy Category (Carry Forward till Q3 18-19)+(New Q4 18-19 Onward)", "col_index" => 19], "db_column" => "policy_category_cf_q3_q4"],
["excel_column" => ["col_name" => "Sum Insured", "col_index" => 20], "db_column" => "sum_insured"],
["excel_column" => ["col_name" => "Bonus", "col_index" => 21], "db_column" => "bonus"],
["excel_column" => ["col_name" => "Intimation Date", "col_index" => 22], "db_column" => "intimation_date"],
["excel_column" => ["col_name" => "Date Of Doc Rec", "col_index" => 23], "db_column" => "date_of_doc_rec"],
["excel_column" => ["col_name" => "Intimation Final Month", "col_index" => 24], "db_column" => "intimation_final_month"],
["excel_column" => ["col_name" => "Reported Year", "col_index" => 25], "db_column" => "reported_year"],
["excel_column" => ["col_name" => "Reported Qurter", "col_index" => 26], "db_column" => "reported_quarter"],
["excel_column" => ["col_name" => "Hospital Name", "col_index" => 27], "db_column" => "hospital_name"],
["excel_column" => ["col_name" => "Hospital City", "col_index" => 28], "db_column" => "hospital_city"],
["excel_column" => ["col_name" => "Hospital State", "col_index" => 29], "db_column" => "hospital_state"],
["excel_column" => ["col_name" => "Diagnosis", "col_index" => 30], "db_column" => "diagnosis"],
["excel_column" => ["col_name" => "ICD Chapter", "col_index" => 31], "db_column" => "icd_chapter"],
["excel_column" => ["col_name" => "ICD Block", "col_index" => 32], "db_column" => "icd_block"],
["excel_column" => ["col_name" => "ICD Level1", "col_index" => 33], "db_column" => "icd_level1"],
["excel_column" => ["col_name" => "ICD Level2", "col_index" => 34], "db_column" => "icd_level2"],
["excel_column" => ["col_name" => "Procedure Description", "col_index" => 35], "db_column" => "procedure_description"],
["excel_column" => ["col_name" => "PCS Description", "col_index" => 36], "db_column" => "pcs_description"],
["excel_column" => ["col_name" => "DOA", "col_index" => 37], "db_column" => "doa"],
["excel_column" => ["col_name" => "DOD", "col_index" => 38], "db_column" => "dod"],
["excel_column" => ["col_name" => "Claim Type", "col_index" => 39], "db_column" => "claim_type"],
["excel_column" => ["col_name" => "Claim Category", "col_index" => 40], "db_column" => "claim_category"],
["excel_column" => ["col_name" => "Disc Datails", "col_index" => 41], "db_column" => "disc_details"],
["excel_column" => ["col_name" => "Disc Date", "col_index" => 42], "db_column" => "disc_date"],
["excel_column" => ["col_name" => "Hospital Code", "col_index" => 43], "db_column" => "hospital_code"],
["excel_column" => ["col_name" => "Claim Status", "col_index" => 44], "db_column" => "claim_status"],
["excel_column" => ["col_name" => "Final ABHI Status-Current Month", "col_index" => 45], "db_column" => "final_abhi_status_current_month"],
["excel_column" => ["col_name" => "Claimed Amount", "col_index" => 46], "db_column" => "claimed_amount"],
["excel_column" => ["col_name" => "ABHI Amount Less Coins - Current Month", "col_index" => 47], "db_column" => "abhi_amount_less_coins_current_month"],
["excel_column" => ["col_name" => "Repudiation Date", "col_index" => 48], "db_column" => "repudiation_date"],
["excel_column" => ["col_name" => "Settled Date", "col_index" => 49], "db_column" => "settled_date"],
["excel_column" => ["col_name" => "Settled Month", "col_index" => 50], "db_column" => "settled_month"],
["excel_column" => ["col_name" => "Settled Year", "col_index" => 51], "db_column" => "settled_year"],
["excel_column" => ["col_name" => "Settled Quarter", "col_index" => 52], "db_column" => "settled_quarter"],
["excel_column" => ["col_name" => "Rejection Category", "col_index" => 53], "db_column" => "rejection_category"],
["excel_column" => ["col_name" => "Rejection Category - Level 1", "col_index" => 54], "db_column" => "rejection_category_level_1"],
["excel_column" => ["col_name" => "Rejection Category - Level 2", "col_index" => 55], "db_column" => "rejection_category_level_2"],
["excel_column" => ["col_name" => "COVID tagging - Current Month", "col_index" => 56], "db_column" => "covid_tagging_current_month"],
["excel_column" => ["col_name" => "EXPECTED DOA", "col_index" => 57], "db_column" => "expected_doa"],
["excel_column" => ["col_name" => "EXPECTED DOD", "col_index" => 58], "db_column" => "expected_dod"],
["excel_column" => ["col_name" => "AGENT/BROKER CODE", "col_index" => 59], "db_column" => "agent_broker_code"],
["excel_column" => ["col_name" => "AGENT/BROKER NAME", "col_index" => 60], "db_column" => "agent_broker_name"],
["excel_column" => ["col_name" => "HEALTHCARD_ID", "col_index" => 61], "db_column" => "healthcard_id"],
["excel_column" => ["col_name" => "ABHI_NETWORK_NON_NETWORK", "col_index" => 62], "db_column" => "abhi_network_non_network"],
["excel_column" => ["col_name" => "CORPORATE_EMPLOYEE_CODE", "col_index" => 63], "db_column" => "corporate_employee_code"],
];
protected $ticketMasterMapping = [
// Employee / Member details
'member_code' => 'emp_code',
'relation' => 'relationship',
// Policy / Claim identifiers
'policy_number' => 'policy_no',
'abhi_claim_no' => 'claim_number',
// Dates
'doa' => 'doa',
'dod' => 'dod',
'intimation_date' => 'date_of_intimat',
// Claim info
'claim_status' => 'tpa_claim_status',
'claimed_amount' => 'claim_amount',
// Hospital details
'hospital_name' => 'hospital_name',
'hospital_city' => 'hospital_city',
'hospital_state' => 'hospital_state',
// Settlement / decision
'repudiation_date' => 'denial_date',
'settled_date' => 'settled_date',
'rejection_category' => 'denial_reason',
// Misc
'diagnosis' => 'claim_description',
'healthcard_id' => 'tpa_no',
];
protected $statusMapping = [
'Settled' => 11,
'Rejected' => 8,
'Cancelled' => 13,
];
protected $dateColumns = [
'policy_from',
'policy_upto',
'intimation_date',
'date_of_doc_rec',
'doa',
'dod',
'repudiation_date',
'settled_date',
'expected_doa',
'expected_dod',
];
/**
* ABSTRACT FUNCTIONs
*/
public function bulkInsertTPATable(array $data): bool
{
if (empty($data)) {
return false;
}
$builder = $this->db->table('claims_dump_abhi');
foreach ($data as $value) {
if (!$builder->insert($value)) {
// 🔍 Debug purpose
log_message('error', print_r($this->db->error(), true));
log_message('error', $this->db->getLastQuery());
return false;
}
}
return true;
}
public function importClaimMaster(array $data): bool
{
if (empty($data)) {
return false;
}
$ticketMasterModel = new TicketMasterModel();
$ticketMasterModel->insertBatch($data);
return true;
}
public function updateTicketIdInTPATable(): bool
{
if (empty($data)) {
return false;
}
$builder = $this->db->table('claims_dump_abhi');
$builder->insertBatch($data);
return true;
}
public function updateTicketMasterRejectedReasonInTPATable($data): bool
{
if (empty($data)) {
return false;
}
$builder = $this->db->table('claims_dump_abhi');
$builder->insertBatch($data);
return true;
}
/**
* MAPPING FUNCTIONs
*/
public function mapTPAData(array $rows, $file_id): array
{
$ClientPolicyModel = new ClaimDumpFileModel();
$file_data = $ClientPolicyModel->where('id', $file_id)->first();
$mapped = [];
foreach ($rows as $row) {
$item = [];
foreach ($this->mapping as $map) {
$excelColumn = $map['excel_column']['col_name'];
$dbColumn = $map['db_column'];
$value = $row[$excelColumn] ?? null;
$item[$dbColumn] = trim($value);
}
foreach ($this->dateColumns as $key => $value) {
$item[$value] = change_date_format($item[$value] ?? null, 'm/d/Y h:i:s A', 'Y-m-d');
}
$params = [
'doa' => $item['doa'] ?? null,
'member_code' => $item['member_code'] ?? null,
'claimed_amount' => $item['claimed_amount'] ?? null,
'healthcard_id' => $item['healthcard_id'] ?? null
];
$is_duplicate = $this->checkDuplicateTpaClaim('claims_dump_abhi', $params);
if ($is_duplicate) {
$item = [];
continue;
}
$item['file_id'] = $file_id ?? null;
$item['client_id'] = $file_data['client_id'] ?? null;
$item['client_policy_id'] = $file_data['client_policy_id'] ?? null;
$item['created_by'] = $file_data['created_by'] ?? null;
$mapped[] = $item;
}
return $mapped;
}
public function mapClaimMasterData($file_id): array
{
$ClientPolicyModel = new ClaimDumpFileModel();
$file_data = $ClientPolicyModel->where('id', $file_id)->first();
$tpaClaimDumpData = $this->getTpaClaimDumpData('claims_dump_abhi', ['file_id' => $file_id]);
if (empty($tpaClaimDumpData)) {
return ['status' => false, 'message' => "No data to insert in TICKET MASTER"];
}
$ClientPolicyModel = new ClientPolicyModel();
$client_policy_data = $ClientPolicyModel
->select("
client_policy.*,
(
SELECT id
FROM client_rm
WHERE is_active = 1
AND level = 3
AND client_id = client_policy.client_id
ORDER BY id ASC
LIMIT 1
) AS acm_id
")
->where('client_policy.id', $file_data['client_policy_id'])
->where('client_policy.is_active', 1)
->first();
try {
$mapped = [];
$rejecetd_reason = [];
foreach ($tpaClaimDumpData as $row) {
$params = [
'doa' => change_date_format($row['doa'] ?? '') ?? null,
'emp_code' => $row['member_code'] ?? null,
'claim_amount' => $row['claimed_amount'] ?? null,
'tpa_no' => $row['healthcard_id'] ?? null
];
$isduplicate = $this->checkDublicateTicketMasterClaim($params);
if ($isduplicate) {
$reason = "This claim already exists in our system.";
$rejecetd_reason[$row['id']] = ["ticket_master_insert_reject_reason" => $reason];
continue;
}
$item = [];
$item['client_id'] = $client_policy_data['client_id'] ?? null;
$item['client_policy_id'] = $client_policy_data['id'] ?? null;
$item['insurer_id'] = $client_policy_data['insurer_id'] ?? null;
$item['tpa_id'] = $client_policy_data['tpa_id'] ?? null;
$item['acm_id'] = $client_policy_data['acm_id'] ?? null;
$item['policy_no'] = $client_policy_data['policy_no'] ?? null;
$item['relationship'] = $this->convertRelation($row['relation'] ?? null);
$employee_data = $this->getEmployeeDetails($file_data['client_id'], $file_data['client_policy_id'], $row['member_code'], $item['relationship']);
if (!empty($employee_data)) {
$item['emp_id'] = $employee_data['id'] ?? null;
$item['emp_name'] = $employee_data['name'] ?? null;
$item['emp_mail'] = $employee_data['email_corporate'] ?? null;
$item['emp_mobile'] = $employee_data['mobile'] ?? null;
$item['insured_emp_id'] = $employee_data['insured_emp_id'] ?? null;
$item['insured_name'] = $employee_data['insured_name'] ?? null;
} else {
$reason = sprintf(
'The policy number "%s" does not exist in our system. ' .
'Details - Client ID: %s, Client Policy ID: %s, Employee Number: %s, Relationship: %s',
$row['insurer_policy_number'],
$file_data['client_id'],
$file_data['client_policy_id'],
$row['employee_number'],
$item['relationship']
);
$rejecetd_reason[$row['id']] = ["ticket_master_insert_reject_reason" => $reason];
continue;
}
foreach ($this->ticketMasterMapping as $tpaKey => $ticketMasterKey) {
$item[$ticketMasterKey] = array_key_exists($tpaKey, $row) ? $row[$tpaKey] : null;
}
// Meta fields
$item['claim_status_id'] = $statusMapping[$row['claim_status']] ?? 61;
$item['file_id'] = $file_id;
$item['claim_dump_ref_id'] = $row['id'];
$item['created_by'] = $file_data['created_by'] ?? null;
$item['claim_type'] = isset($row['mainclaim_prepost_type']) && !empty($row['mainclaim_prepost_type']) && strtolower($row['mainclaim_prepost_type']) == 'normal' ? 1 : 3;
$item['priority'] = 1;
$item['mode_of_intimation'] = 5;
$item['ticket_type_id'] = 1;
$mapped[] = $item;
}
return ['status' => true, 'mapped_array' => $mapped, 'rejected_reason_array' => $rejecetd_reason];
} catch (\Throwable $th) {
$errorData = [
'message' => $th->getMessage(),
'file' => $th->getFile(),
'line' => $th->getLine(),
'code' => $th->getCode(),
'trace' => $th->getTraceAsString(),
'trace_array' => $th->getTrace(), // full array version (optional)
'function' => $th->getTrace()[0]['function'] ?? null,
'class' => $th->getTrace()[0]['class'] ?? null,
];
return ['status' => false, "message" => $errorData['message'], 'error_data' => $errorData];
}
}
/**
* HELPER FUNCTIONs
*/
public function isDateValue($value): bool
{
if (empty($value)) {
return false;
}
// Excel numeric date
if (is_numeric($value) && $value > 30000) {
return true;
}
return strtotime(str_replace('/', '-', $value)) !== false;
}
public function normalizeDate($value): ?string
{
try {
if (empty($value)) {
return null;
}
// Excel numeric date
if (is_numeric($value)) {
return date(
'Y-m-d',
\PhpOffice\PhpSpreadsheet\Shared\Date::excelToTimestamp($value)
);
}
$value = trim((string) $value);
// Replace / with - for strtotime compatibility
$value = str_replace('/', '-', $value);
$timestamp = strtotime($value);
if ($timestamp === false) {
return null;
}
return date('Y-m-d', $timestamp);
} catch (\Throwable $e) {
return null;
}
}
public function convertRelation(?string $relation): ?string
{
if (empty($relation)) {
return null;
}
$relation = strtolower($relation);
if (str_contains($relation, 'self')) {
return 'self';
}
if (str_contains($relation, 'spouse') || str_contains($relation, 'wife') || str_contains($relation, 'husband')) {
return 'spouse';
}
if (str_contains($relation, 'daughter')) {
return 'daughter';
}
if (str_contains($relation, 'son')) {
return 'son';
}
if (str_contains($relation, 'father in law') || str_contains($relation, 'father-in-law')) {
return 'father-in-law';
}
if (str_contains($relation, 'mother in law') || str_contains($relation, 'mother-in-law')) {
return 'mother-in-law';
}
if (str_contains($relation, 'father')) {
return 'father';
}
if (str_contains($relation, 'mother')) {
return 'mother';
}
return null; // unmatched case
}
}

View File

@ -0,0 +1,368 @@
<?php
namespace App\Libraries\TPAClaimsImportServices;
use CodeIgniter\Database\BaseConnection;
use PhpOffice\PhpSpreadsheet\IOFactory;
use PhpOffice\PhpSpreadsheet\Spreadsheet;
use App\Models\TicketMasterModel;
use App\Models\EmployeeModel;
use App\Models\ClaimDumpFileModel;
use App\Models\ClaimsDumpFhplModel;
use RuntimeException;
abstract class BaseTpaClaimImportService
{
protected BaseConnection $db;
protected $claimDumpFileModel;
public function __construct()
{
$this->db = db_connect();
$this->claimDumpFileModel = new ClaimDumpFileModel();
}
/**
* First JOB for insert TPA wise Bulk Upload
*/
public function runTpaClaimDumpInsert(string $filePath, int $fileId): array
{
$this->db->transStart();
$fileData = $this->claimDumpFileModel->where('id', $fileId)->first();
if (env('FHPL_PRIMARY_KEY_CONSTANT') == $fileData['tpa_id']) {
$rows = $this->readExcelBySheetName($filePath, 'Claims&Preauth');
} else if (env('R_CARE_PRIMARY_KEY_CONSTANT') == $fileData['tpa_id']) {
$rows = $this->readExcelBySheetName($filePath, 'CL');
// $AL = $this->readExcelBySheetName($filePath, 'AL');
// $rows = array_merge($CL, $AL);
} else {
$rows = $this->readExcel($filePath);
}
// dd($rows);
if (empty($rows)) {
return ['status' => false, 'message' => 'Excel file contains no data or wrong file upload'];
}
$tpaInsertData = $this->mapTPAData($rows, $fileId);
// dd($tpaInsertData);
if (empty($tpaInsertData)) {
return ['status' => false, 'message' => 'These records already exist in the system.'];
}
if (env('FHPL_PRIMARY_KEY_CONSTANT') == $fileData['tpa_id']) {
$ClaimsDumpFhplModel = $this->db->table('claims_dump_fhpl');
$return_res = $ClaimsDumpFhplModel->insertBatch($tpaInsertData);
} else if (env('R_CARE_PRIMARY_KEY_CONSTANT') == $fileData['tpa_id']) {
$ClaimsDumpIciciModel = $this->db->table('claims_dump_reliance');
$return_res = $ClaimsDumpIciciModel->insertBatch($tpaInsertData);
} else if (env('ICICI_PRIMARY_KEY_CONSTANT') == $fileData['tpa_id']) {
$ClaimsDumpIciciModel = $this->db->table('claims_dump_icici');
$return_res = $ClaimsDumpIciciModel->insertBatch($tpaInsertData);
} else if (env('ABHI_PRIMARY_KEY_CONSTANT') == $fileData['tpa_id']) {
// $ClaimsDumpAbhiModel = $this->db->table('claims_dump_abhi');
// $return_res = $ClaimsDumpAbhiModel->insertBatch($tpaInsertData);
$return_res = $this->bulkInsertTPATable($tpaInsertData);
} else if (env('VIDAL_PRIMARY_KEY_CONSTANT') == $fileData['tpa_id']) {
$ClaimsDumpVidalModel = $this->db->table('claims_dump_vidal');
$return_res = $ClaimsDumpVidalModel->insertBatch($tpaInsertData);
} else if (env('MEDI_ASSIST_PRIMARY_KEY_CONSTANT') == $fileData['tpa_id']) {
$ClaimsDumpMediAssistModel = $this->db->table('claims_dump_medi_assist');
$return_res = $ClaimsDumpMediAssistModel->insertBatch($tpaInsertData);
} else{
}
// $return_res = $this->bulkInsertTPATable($tpaInsertData);
if (!$return_res) {
return ['status' => false, 'message' => 'TPA Import bulk insert failed'];
}
$this->db->transComplete();
if ($this->db->transStatus() === false) {
$error = $this->db->error();
$error_data = [
'message' => $error['message'] ?: 'Unknown DB error',
'code' => $error['code'] ?? null,
'last_query' => (string) $this->db->getLastQuery()
];
// dd($error_data);
// unset($error_data['last_query']);
return ['status' => false, 'message' => 'TPA Import transaction failed', 'error_data' => $error_data];
}
return ['status' => true, 'message' => 'File uploaded successfully', 'record_count' => count($tpaInsertData ?? [])];
}
/**
* Second JOB for insert Ticket Master table after insert the TPA bulk upload success
*/
public function runTicketMasterInsert(array $params): array
{
$this->db->transStart();
$file_id = $params['file_id'];
$ticketMasterData = $this->mapClaimMasterData($file_id);
if (!$ticketMasterData['status']) {
return $ticketMasterData;
}
$return_res = $this->importClaimMaster($ticketMasterData['mapped_array']);
if(!$return_res){
return ['status' => false, 'message' => 'Ticket Master Claim bulk insert failed'];
}
$this->updateTicketMasterRejectedReasonInTPATable($ticketMasterData['rejected_reason_array']);
$this->db->transComplete();
if ($this->db->transStatus() === false) {
return ['status' => false, 'message' => 'Ticket Master Claim bulk insert failed'];
}
return ['status' => true, 'message' => 'Ticket Master Claim inserted successfully'];
}
/**
* Read Excel and return associative rows (header based)
*/
protected function readExcel(string $filePath): array
{
helper('excel_util_helper');
if (!file_exists($filePath)) {
throw new RuntimeException("File not found: {$filePath}");
}
$spreadsheet = IOFactory::load($filePath);
$sheet = $spreadsheet->getActiveSheet();
$rows = $sheet->toArray(null, true, true, true);
// dd($rows);
if (count($rows) < 2) {
return [];
}
// First row is header
$headers = array_shift($rows);
$headers = array_map('trim', $headers);
$data = [];
foreach ($rows as $row) {
if(check_row_is_empty_or_null($row)){
break;
}
$item = [];
foreach ($headers as $key => $headerName) {
if ($headerName !== '') {
$item[$headerName] = $row[$key] ?? null;
}
}
$data[] = $item;
}
return $data;
}
/**
* Read Excel By Sheet name and return associative rows (header based)
*/
protected function readExcelBySheetName(string $filePath, string $sheetName): array
{
if (!file_exists($filePath)) {
throw new RuntimeException("File not found: {$filePath}");
}
$spreadsheet = IOFactory::load($filePath);
// Get sheet by name
$sheet = $spreadsheet->getSheetByName($sheetName);
if ($sheet === null) {
throw new RuntimeException("Sheet '{$sheetName}' not found in Excel file");
}
$rows = $sheet->toArray(null, true, true, true);
// Need at least header + one row
if (count($rows) < 2) {
return [];
}
// First row = headers
$headers = array_shift($rows);
$headers = array_map('trim', $headers);
$data = [];
foreach ($rows as $row) {
// Skip completely empty rows
if (!array_filter($row)) {
continue;
}
$item = [];
foreach ($headers as $key => $headerName) {
if ($headerName !== '') {
$item[$headerName] = $row[$key] ?? null;
}
}
$data[] = $item;
}
return $data;
}
/**
* Dublicate check in the ticket_master table records
*/
protected function checkDublicateTicketMasterClaim(array $param): bool
{
$ticketMaster = new TicketMasterModel();
$ticket_master_data = $ticketMaster
->where('doa', $param['doa'])
->where('tpa_no', $param['tpa_no'])
->where('claim_amount', $param['claim_amount'])
->where('emp_code', $param['emp_code'])
->where('is_active', 1)
->findAll();
if(count($ticket_master_data) > 0){
return true;
}
return false;
}
/**
* Dublicate check in the TPA specific table records
*/
protected function checkDuplicateTpaClaim(string $table, array $params): bool
{
return $this->db->table($table)
->where($params)
->where('is_active', 1)
->countAllResults() > 0;
}
/**
* Dublicate check in the TPA specific table records
*/
protected function getTpaClaimDumpData(string $table, array $params): array
{
$tpaClaimDumpDataCount = $this->db
->table($table)
->where('is_active', 1)
->where('file_id', $params['file_id'])
->where('ticket_id IS NULL')
->countAllResults();
$batch_size = 100;
$total_batch = (int) ceil($tpaClaimDumpDataCount / $batch_size);
$batch_no = isset($params['batch_no']) ? (int) $params['batch_no'] : null;
$last_emp_id = (int) ($params['last_emp_id'] ?? 0);
return $this->db
->table($table)
->where('is_active', 1)
->where('file_id', $params['file_id'])
->where('ticket_id IS NULL')
->get()
->getResultArray();
}
/**
* Dublicate check in the TPA specific table records
*/
public function getEmployeeDetails(int $client_id, int $client_policy_id, string $emp_code, string $relation): array
{
$EmployeeModel = new EmployeeModel();
$employeeData = $EmployeeModel
->select([
'employees.id AS emp_id',
'employees.email_corporate AS emp_mail',
'employees.mobile AS emp_mobile',
'employees.name AS emp_name',
// insured employee
'insured.id AS insured_emp_id',
'insured.name AS insured_name'
])
->join(
'employee_polices',
'employees.id = employee_polices.employee_id'
)
->join(
'employees AS insured',
"insured.emp_code = employees.emp_code
AND insured.client_id = employees.client_id
AND LOWER(insured.relationship) = " . $EmployeeModel->db->escape(strtolower($relation)),
'left'
)
->where('employees.is_active', 1)
->where('employee_polices.is_active', 1)
->where('employee_polices.client_policy_id', $client_policy_id)
->where('employees.client_id', $client_id)
->where('employees.emp_code', $emp_code)
->where('LOWER(employees.relationship)', 'self')
->first();
return $employeeData ?? [];
}
/**
* Map Excel rows to TPA table structure
*/
abstract protected function mapTPAData(array $rows, $fileId): array;
/**
* Map DB rows to Ticket Master table structure
*/
abstract protected function mapClaimMasterData($fileId): array;
/**
* Insert into TPA-specific table (bulk)
*/
abstract protected function bulkInsertTPATable(array $data): bool;
/**
* Insert into Ticket-Master-specific table (bulk)
*/
abstract protected function importClaimMaster(array $data): bool;
/**
* Update TPA table with ticket_master primary key
*/
abstract protected function updateTicketIdInTPATable(): bool;
/**
* Update TPA table with ticket_master insert rejected reason
*/
abstract protected function updateTicketMasterRejectedReasonInTPATable(array $data): bool;
}

View File

@ -0,0 +1,500 @@
<?php
namespace App\Libraries\TPAClaimsImportServices;
use App\Models\TicketMasterModel;
use App\Models\ClientPolicyModel;
use App\Models\ClaimDumpFileModel;
use App\Models\ClaimsDumpFhplModel;
class FhplClaimImportService extends BaseTpaClaimImportService
{
/**
* MAPPING ARRAYs
*/
protected $mapping = [
["excel_column"=>["col_name"=>"Requesttype","col_index"=>0],"db_column"=>"request_type"],
["excel_column"=>["col_name"=>"Intimation ID","col_index"=>1],"db_column"=>"intimation_id"],
["excel_column"=>["col_name"=>"Intimation Date","col_index"=>2],"db_column"=>"intimation_date"],
["excel_column"=>["col_name"=>"claimid","col_index"=>3],"db_column"=>"claim_id"],
["excel_column"=>["col_name"=>"slno","col_index"=>4],"db_column"=>"sl_no"],
["excel_column"=>["col_name"=>"UHIDNO","col_index"=>5],"db_column"=>"uhid_no"],
["excel_column"=>["col_name"=>"Membername","col_index"=>6],"db_column"=>"member_name"],
["excel_column"=>["col_name"=>"Main Memuhidno","col_index"=>7],"db_column"=>"main_member_uhid_no"],
["excel_column"=>["col_name"=>"Main Memname","col_index"=>8],"db_column"=>"main_member_name"],
["excel_column"=>["col_name"=>"Gender","col_index"=>9],"db_column"=>"gender"],
["excel_column"=>["col_name"=>"DOB","col_index"=>10],"db_column"=>"dob"],
["excel_column"=>["col_name"=>"Yrs","col_index"=>11],"db_column"=>"years"],
["excel_column"=>["col_name"=>"relationship","col_index"=>12],"db_column"=>"relationship"],
["excel_column"=>["col_name"=>"employeeid","col_index"=>13],"db_column"=>"employee_id"],
["excel_column"=>["col_name"=>"Mobile","col_index"=>14],"db_column"=>"mobile"],
["excel_column"=>["col_name"=>"Email","col_index"=>15],"db_column"=>"email"],
["excel_column"=>["col_name"=>"Policy No","col_index"=>16],"db_column"=>"policy_no"],
["excel_column"=>["col_name"=>"Policy Start Date","col_index"=>17],"db_column"=>"policy_start_date"],
["excel_column"=>["col_name"=>"Policy Commencing Date","col_index"=>18],"db_column"=>"policy_commencing_date"],
["excel_column"=>["col_name"=>"Policy Expiry Date","col_index"=>19],"db_column"=>"policy_expiry_date"],
["excel_column"=>["col_name"=>"Organisationname","col_index"=>20],"db_column"=>"organisation_name"],
["excel_column"=>["col_name"=>"Claimreceiveddate","col_index"=>21],"db_column"=>"claim_received_date"],
["excel_column"=>["col_name"=>"Admdate","col_index"=>22],"db_column"=>"admission_date"],
["excel_column"=>["col_name"=>"Dis Date","col_index"=>23],"db_column"=>"discharge_date"],
["excel_column"=>["col_name"=>"Diagnosis","col_index"=>24],"db_column"=>"diagnosis"],
["excel_column"=>["col_name"=>"Service Type","col_index"=>25],"db_column"=>"service_type"],
["excel_column"=>["col_name"=>"Service Sub Type","col_index"=>26],"db_column"=>"service_sub_type"],
["excel_column"=>["col_name"=>"icdcode First Level","col_index"=>27],"db_column"=>"icd_code_first_level"],
["excel_column"=>["col_name"=>"icdcode Second Level","col_index"=>28],"db_column"=>"icd_code_second_level"],
["excel_column"=>["col_name"=>"icdcode Third Level","col_index"=>29],"db_column"=>"icd_code_third_level"],
["excel_column"=>["col_name"=>"Claim Type","col_index"=>30],"db_column"=>"claim_type"],
["excel_column"=>["col_name"=>"Providername","col_index"=>31],"db_column"=>"provider_name"],
["excel_column"=>["col_name"=>"provideraddress","col_index"=>32],"db_column"=>"provider_address"],
["excel_column"=>["col_name"=>"providerplace","col_index"=>33],"db_column"=>"provider_place"],
["excel_column"=>["col_name"=>"providerstate","col_index"=>34],"db_column"=>"provider_state"],
["excel_column"=>["col_name"=>"Provider Pincode","col_index"=>35],"db_column"=>"provider_pincode"],
["excel_column"=>["col_name"=>"PROVIDERTYPE","col_index"=>36],"db_column"=>"provider_type"],
["excel_column"=>["col_name"=>"Provider Identification","col_index"=>37],"db_column"=>"provider_identification"],
["excel_column"=>["col_name"=>"coverageamount","col_index"=>38],"db_column"=>"coverage_amount"],
["excel_column"=>["col_name"=>"claimamount","col_index"=>39],"db_column"=>"claim_amount"],
["excel_column"=>["col_name"=>"billedamount","col_index"=>40],"db_column"=>"billed_amount"],
["excel_column"=>["col_name"=>"Disallowed Amount","col_index"=>41],"db_column"=>"disallowed_amount"],
["excel_column"=>["col_name"=>"Dis Allowence Reason1","col_index"=>42],"db_column"=>"dis_allowance_reason_1"],
["excel_column"=>["col_name"=>"Dis Allowence Reason2","col_index"=>43],"db_column"=>"dis_allowance_reason_2"],
["excel_column"=>["col_name"=>"settledamt","col_index"=>44],"db_column"=>"settled_amount"],
["excel_column"=>["col_name"=>"Incurred Amount","col_index"=>45],"db_column"=>"incurred_amount"],
["excel_column"=>["col_name"=>"Discountamount","col_index"=>46],"db_column"=>"discount_amount"],
["excel_column"=>["col_name"=>"TDSAmount","col_index"=>47],"db_column"=>"tds_amount"],
["excel_column"=>["col_name"=>"Net Amount Paid","col_index"=>48],"db_column"=>"net_amount_paid"],
["excel_column"=>["col_name"=>"Co Payment","col_index"=>49],"db_column"=>"co_payment"],
["excel_column"=>["col_name"=>"Current Claim Status","col_index"=>50],"db_column"=>"current_claim_status"],
["excel_column"=>["col_name"=>"Balance Suminsured","col_index"=>51],"db_column"=>"balance_sum_insured"],
["excel_column"=>["col_name"=>"Chequeno","col_index"=>52],"db_column"=>"cheque_no"],
["excel_column"=>["col_name"=>"chequedate","col_index"=>53],"db_column"=>"cheque_date"],
["excel_column"=>["col_name"=>"Claim Passed Date","col_index"=>54],"db_column"=>"claim_passed_date"],
["excel_column"=>["col_name"=>"Settled Date","col_index"=>55],"db_column"=>"settled_date"],
["excel_column"=>["col_name"=>"Pending Remarks","col_index"=>56],"db_column"=>"pending_remarks"],
["excel_column"=>["col_name"=>"Ir Investigation","col_index"=>57],"db_column"=>"ir_investigation"],
["excel_column"=>["col_name"=>"Date of IR","col_index"=>58],"db_column"=>"ir_date"],
["excel_column"=>["col_name"=>"Date of IRretrieval Date","col_index"=>59],"db_column"=>"ir_retrieval_date"],
["excel_column"=>["col_name"=>"first Reminder","col_index"=>60],"db_column"=>"first_reminder"],
["excel_column"=>["col_name"=>"Second Reminder","col_index"=>61],"db_column"=>"second_reminder"],
["excel_column"=>["col_name"=>"Rejection Remarks","col_index"=>62],"db_column"=>"rejection_remarks"],
["excel_column"=>["col_name"=>"Payee name","col_index"=>63],"db_column"=>"payee_name"],
["excel_column"=>["col_name"=>"Treatment Type","col_index"=>64],"db_column"=>"treatment_type"],
["excel_column"=>["col_name"=>"roomdays","col_index"=>65],"db_column"=>"room_days"],
["excel_column"=>["col_name"=>"icudays","col_index"=>66],"db_column"=>"icu_days"],
["excel_column"=>["col_name"=>"totalstay","col_index"=>67],"db_column"=>"total_stay"],
["excel_column"=>["col_name"=>"Room Rent Claimed","col_index"=>68],"db_column"=>"room_rent_claimed"],
["excel_column"=>["col_name"=>"ICU Claimed","col_index"=>69],"db_column"=>"icu_claimed"],
["excel_column"=>["col_name"=>"ICU Related","col_index"=>70],"db_column"=>"icu_related"],
["excel_column"=>["col_name"=>"Nursing Claimed","col_index"=>71],"db_column"=>"nursing_claimed"],
["excel_column"=>["col_name"=>"Nursing Charges","col_index"=>72],"db_column"=>"nursing_charges"],
["excel_column"=>["col_name"=>"Room Rent Related","col_index"=>73],"db_column"=>"room_rent_related"],
["excel_column"=>["col_name"=>"Professional Charges","col_index"=>74],"db_column"=>"professional_charges"],
["excel_column"=>["col_name"=>"Drugs Medication Consumables Investigationsetc","col_index"=>75],"db_column"=>"drugs_medication_consumables"],
["excel_column"=>["col_name"=>"Investigations Procedures IP","col_index"=>76],"db_column"=>"investigations_procedures_ip"],
["excel_column"=>["col_name"=>"Domicillary Hospitalization","col_index"=>77],"db_column"=>"domicillary_hospitalization"],
["excel_column"=>["col_name"=>"Maternity","col_index"=>78],"db_column"=>"maternity"],
["excel_column"=>["col_name"=>"Day Care","col_index"=>79],"db_column"=>"day_care"],
["excel_column"=>["col_name"=>"Operation Theatre","col_index"=>80],"db_column"=>"operation_theatre"],
["excel_column"=>["col_name"=>"Organ Donar","col_index"=>81],"db_column"=>"organ_donor"],
["excel_column"=>["col_name"=>"Ancilliary Services","col_index"=>82],"db_column"=>"ancillary_services"],
["excel_column"=>["col_name"=>"Dental","col_index"=>83],"db_column"=>"dental"],
["excel_column"=>["col_name"=>"Out Patient Coverage","col_index"=>84],"db_column"=>"out_patient_coverage"],
["excel_column"=>["col_name"=>"Personal Accident","col_index"=>85],"db_column"=>"personal_accident"],
["excel_column"=>["col_name"=>"Critical Illness","col_index"=>86],"db_column"=>"critical_illness"],
["excel_column"=>["col_name"=>"Health Check Up","col_index"=>87],"db_column"=>"health_check_up"],
["excel_column"=>["col_name"=>"Spectacles Contact Lenses Hearing Aid","col_index"=>88],"db_column"=>"spectacles_contact_lenses_hearing_aid"],
["excel_column"=>["col_name"=>"Notes","col_index"=>89],"db_column"=>"notes"],
["excel_column"=>["col_name"=>"Buffer Amount","col_index"=>90],"db_column"=>"buffer_amount"],
["excel_column"=>["col_name"=>"tertiaryamount","col_index"=>91],"db_column"=>"tertiary_amount"],
["excel_column"=>["col_name"=>"insurancename","col_index"=>92],"db_column"=>"insurance_name"],
["excel_column"=>["col_name"=>"Roname","col_index"=>93],"db_column"=>"ro_name"],
["excel_column"=>["col_name"=>"Class Of Accommodation","col_index"=>94],"db_column"=>"class_of_accommodation"],
["excel_column"=>["col_name"=>"claimcreateddatetime","col_index"=>95],"db_column"=>"claim_created_datetime"],
["excel_column"=>["col_name"=>"Insurer Claim ID","col_index"=>96],"db_column"=>"insurer_claim_id"],
["excel_column"=>["col_name"=>"Gipsa","col_index"=>97],"db_column"=>"gipsa"],
["excel_column"=>["col_name"=>"Date Of Joining","col_index"=>98],"db_column"=>"date_of_joining"],
["excel_column"=>["col_name"=>"GIPSAHospital","col_index"=>99],"db_column"=>"gipsa_hospital"],
["excel_column"=>["col_name"=>"Package","col_index"=>100],"db_column"=>"package"],
["excel_column"=>["col_name"=>"Is NIDB","col_index"=>101],"db_column"=>"is_nidb"],
["excel_column"=>["col_name"=>"NIDB Removed Date","col_index"=>102],"db_column"=>"nidb_removed_date"],
["excel_column"=>["col_name"=>"Investigationdate","col_index"=>103],"db_column"=>"investigation_date"],
["excel_column"=>["col_name"=>"Investigation Retrieval Date","col_index"=>104],"db_column"=>"investigation_retrieval_date"],
["excel_column"=>["col_name"=>"Reopeneddate","col_index"=>105],"db_column"=>"reopened_date"],
["excel_column"=>["col_name"=>"Referto Insurer Date","col_index"=>106],"db_column"=>"refer_to_insurer_date"],
["excel_column"=>["col_name"=>"Receiveddatefrom Insurer","col_index"=>107],"db_column"=>"received_date_from_insurer"],
["excel_column"=>["col_name"=>"Rejection Category","col_index"=>108],"db_column"=>"rejection_category"],
["excel_column"=>["col_name"=>"Referto Insurer Reasons","col_index"=>109],"db_column"=>"refer_to_insurer_reasons"],
["excel_column"=>["col_name"=>"Is VIP","col_index"=>110],"db_column"=>"is_vip"],
["excel_column"=>["col_name"=>"Main Claim Status","col_index"=>111],"db_column"=>"main_claim_status"],
["excel_column"=>["col_name"=>"Main Claimtype","col_index"=>112],"db_column"=>"main_claim_type"],
["excel_column"=>["col_name"=>"icd Third Level Code","col_index"=>113],"db_column"=>"icd_third_level_code"],
["excel_column"=>["col_name"=>"Benefit Plan Name","col_index"=>114],"db_column"=>"benefit_plan_name"],
["excel_column"=>["col_name"=>"zone","col_index"=>115],"db_column"=>"zone"],
["excel_column"=>["col_name"=>"Grade","col_index"=>116],"db_column"=>"grade"],
["excel_column"=>["col_name"=>"Last Modified Date","col_index"=>117],"db_column"=>"last_modified_date"],
["excel_column"=>["col_name"=>"Temp MOU","col_index"=>118],"db_column"=>"temp_mou"],
];
protected $ticketMasterMapping = [
// Claim / Reference
'claim_id' => 'claim_number',
// Policy
'policy_no' => 'policy_no',
// Employee / Member
'employee_id' => 'emp_code',
'relationship' => 'relationship',
// Claim Dates
'admission_date' => 'doa',
'discharge_date' => 'dod',
'claim_received_date' => 'date_of_intimat',
'claim_passed_date' => 'approved_date',
'settled_date' => 'settled_date',
'current_claim_status' => 'tpa_claim_status',
// Amounts
'claim_amount' => 'claim_amount',
'settled_amount' => 'settled_amount',
'disallowed_amount' => 'denial_reason',
'coverage_amount' => 'si_amt',
// Hospital
'provider_name' => 'hospital_name',
'provider_address' => 'hospital_address',
'provider_state' => 'hospital_state',
'provider_place' => 'hospital_city',
'provider_pincode' => 'hospital_pin_code',
// Remarks / Description
'diagnosis' => 'claim_description',
'rejection_remarks' => 'return_remark',
// Payment
'cheque_no' => 'utr_details',
'uhid_no' => 'tpa_no',
'priority' => 1,
'mode_of_intimation' => 5,
'ticket_type_id' => 1,
];
protected $statusMapping = [
'Settled' => 11,
'Rejected' => 8,
];
protected $dateColumns = [
'intimation_date',
'policy_start_date',
'policy_commencing_date',
'policy_expiry_date',
'claim_received_date',
'admission_date',
'discharge_date',
'cheque_date',
'claim_passed_date',
'settled_date',
'ir_date',
'ir_retrieval_date',
'first_reminder',
'second_reminder',
'date_of_joining',
'nidb_removed_date',
'investigation_date',
'investigation_retrieval_date',
'reopened_date',
'refer_to_insurer_date',
'received_date_from_insurer',
'claim_created_datetime',
'last_modified_date'
];
/**
* ABSTRACT FUNCTIONs
*/
public function bulkInsertTPATable(array $data): bool
{
if (empty($data)) {
return false;
}
$ClaimsDumpFhplModel = new ClaimsDumpFhplModel();
$result = $ClaimsDumpFhplModel->insertBatch($data);
return true;
}
public function importClaimMaster(array $data): bool
{
if (empty($data)) {
return false;
}
$ticketMasterModel = new TicketMasterModel();
$ticketMasterModel->insertBatch($data);
return true;
}
public function updateTicketIdInTPATable(): bool
{
if (empty($data)) {
return false;
}
$builder = $this->db->table('claims_dump_fhpl');
$builder->insertBatch($data);
return true;
}
public function updateTicketMasterRejectedReasonInTPATable($data): bool
{
if (empty($data)) {
return false;
}
$builder = $this->db->table('claims_dump_fhpl');
$builder->insertBatch($data);
return true;
}
/**
* MAPPING FUNCTIONs
*/
public function mapTPAData(array $rows, $file_id): array
{
$ClientPolicyModel = new ClaimDumpFileModel();
$file_data = $ClientPolicyModel->where('id', $file_id)->first();
$mapped = [];
foreach ($rows as $row) {
$item = [];
foreach ($this->mapping as $map) {
$excelColumn = $map['excel_column']['col_name'];
$dbColumn = $map['db_column'];
$value = $row[$excelColumn] ?? null;
$item[$dbColumn] = trim($value);
}
foreach ($this->dateColumns as $key => $value) {
$item[$value] = change_date_format($item[$value] ?? null, 'd-M-y', 'Y-m-d');
}
$params = [
'admission_date' => $item['admission_date'] ?? null,
'employee_id' => $item['employee_id'] ?? null,
'claim_amount' => $item['claim_amount'] ?? null,
'uhid_no' => $item['uhid_no'] ?? null
];
$is_duplicate = $this->checkDuplicateTpaClaim('claims_dump_fhpl', $params);
if ($is_duplicate) {
$item = [];
continue;
}
$item['file_id'] = $file_id ?? null;
$item['client_id'] = $file_data['client_id'] ?? null;
$item['client_policy_id'] = $file_data['client_policy_id'] ?? null;
$item['created_by'] = $file_data['created_by'] ?? null;
$mapped[] = $item;
}
return $mapped;
}
public function mapClaimMasterData($file_id): array
{
$ClientPolicyModel = new ClaimDumpFileModel();
$file_data = $ClientPolicyModel->where('id', $file_id)->first();
$tpaClaimDumpData = $this->getTpaClaimDumpData('claims_dump_fhpl', ['file_id' => $file_id]);
if (empty($tpaClaimDumpData)) {
return ['status' => false, 'message' => "No data to insert in TICKET MASTER"];
}
$ClientPolicyModel = new ClientPolicyModel();
$client_policy_data = $ClientPolicyModel
->select("
client_policy.*,
(
SELECT id
FROM client_rm
WHERE is_active = 1
AND level = 3
AND client_id = client_policy.client_id
ORDER BY id ASC
LIMIT 1
) AS acm_id
")
->where('client_policy.id', $file_data['client_policy_id'])
->where('client_policy.is_active', 1)
->first();
try {
$mapped = [];
$rejecetd_reason = [];
foreach ($tpaClaimDumpData as $row) {
$params = [
'doa' => change_date_format($row['admission_date'] ?? '') ?? null,
'emp_code' => $row['employee_id'] ?? null,
'claim_amount' => $row['claim_amount'] ?? null,
'tpa_no' => $row['uhid_no'] ?? null
];
$isduplicate = $this->checkDublicateTicketMasterClaim($params);
if ($isduplicate) {
$reason = "This claim already exists in our system.";
$rejecetd_reason[$row['id']] = ["ticket_master_insert_reject_reason" => $reason];
continue;
}
$item = [];
$item['client_id'] = $client_policy_data['client_id'] ?? null;
$item['client_policy_id'] = $client_policy_data['id'] ?? null;
$item['insurer_id'] = $client_policy_data['insurer_id'] ?? null;
$item['tpa_id'] = $client_policy_data['tpa_id'] ?? null;
$item['acm_id'] = $client_policy_data['acm_id'] ?? null;
$item['policy_no'] = $client_policy_data['policy_no'] ?? null;
$item['relationship'] = $this->convertRelation($row['relationship'] ?? null);
$employee_data = $this->getEmployeeDetails($file_data['client_id'], $file_data['client_policy_id'], $row['employee_id'], $item['relationship']);
if (!empty($employee_data)) {
$item['emp_id'] = $employee_data['id'] ?? null;
$item['emp_name'] = $employee_data['name'] ?? null;
$item['emp_mail'] = $employee_data['email_corporate'] ?? null;
$item['emp_mobile'] = $employee_data['mobile'] ?? null;
$item['insured_emp_id'] = $employee_data['insured_emp_id'] ?? null;
$item['insured_name'] = $employee_data['insured_name'] ?? null;
} else {
$reason = sprintf(
'The policy number "%s" does not exist in our system. ' .
'Details - Client ID: %s, Client Policy ID: %s, Employee Number: %s, Relationship: %s',
$row['insurer_policy_number'],
$file_data['client_id'],
$file_data['client_policy_id'],
$row['employee_number'],
$item['relationship']
);
$rejecetd_reason[$row['id']] = ["ticket_master_insert_reject_reason" => $reason];
continue;
}
foreach ($this->ticketMasterMapping as $tpaKey => $ticketMasterKey) {
$item[$ticketMasterKey] = array_key_exists($tpaKey, $row) ? $row[$tpaKey] : null;
}
// Meta fields
$item['claim_status_id'] = $statusMapping[$row['current_claim_status']] ?? 61;
$item['file_id'] = $file_id;
$item['claim_dump_ref_id'] = $row['id'];
$item['created_by'] = $file_data['created_by'] ?? null;
$item['claim_type'] = 1;
$item['priority'] = 1;
$item['mode_of_intimation'] = 5;
$item['ticket_type_id'] = 1;
$mapped[] = $item;
}
return ['status' => true, 'mapped_array' => $mapped, 'rejected_reason_array' => $rejecetd_reason];
} catch (\Throwable $th) {
$errorData = [
'message' => $th->getMessage(),
'file' => $th->getFile(),
'line' => $th->getLine(),
'code' => $th->getCode(),
'trace' => $th->getTraceAsString(),
'trace_array' => $th->getTrace(), // full array version (optional)
'function' => $th->getTrace()[0]['function'] ?? null,
'class' => $th->getTrace()[0]['class'] ?? null,
];
return ['status' => false, "message" => $errorData['message'], 'error_data' => $errorData];
}
}
/**
* HELPER FUNCTIONs
*/
public function convertRelation(?string $relation): ?string
{
if (empty($relation)) {
return null;
}
$relation = strtolower($relation);
if (str_contains($relation, 'self')) {
return 'self';
}
if (str_contains($relation, 'spouse') || str_contains($relation, 'wife') || str_contains($relation, 'husband')) {
return 'spouse';
}
if (str_contains($relation, 'daughter')) {
return 'daughter';
}
if (str_contains($relation, 'son')) {
return 'son';
}
if (str_contains($relation, 'father in law') || str_contains($relation, 'father-in-law')) {
return 'father-in-law';
}
if (str_contains($relation, 'mother in law') || str_contains($relation, 'mother-in-law')) {
return 'mother-in-law';
}
if (str_contains($relation, 'father')) {
return 'father';
}
if (str_contains($relation, 'mother')) {
return 'mother';
}
return null; // unmatched case
}
}

View File

@ -0,0 +1,430 @@
<?php
namespace App\Libraries\TPAClaimsImportServices;
use App\Models\TicketMasterModel;
use App\Models\ClientPolicyModel;
use App\Models\ClientRMModel;
use App\Models\EmployeeModel;
use App\Models\ClaimDumpFileModel;
use App\Models\ClaimsDumpFhplModel;
class IciciClaimImportService extends BaseTpaClaimImportService
{
/**
* MAPPING ARRAYs
*/
protected $mapping = [
["excel_column" => ["col_name" => "POLICY_NAME", "col_index" => 0], "db_column" => "policy_name"],
["excel_column" => ["col_name" => "POLICY_NO", "col_index" => 1], "db_column" => "policy_no"],
["excel_column" => ["col_name" => "UHID", "col_index" => 2], "db_column" => "uhid"],
["excel_column" => ["col_name" => "INSURED_NAME", "col_index" => 3], "db_column" => "insured_name"],
["excel_column" => ["col_name" => "MAIN_MEMBER_NAME", "col_index" => 4], "db_column" => "main_member_name"],
["excel_column" => ["col_name" => "EMPLOYEE_MEMBER_ID", "col_index" => 5], "db_column" => "employee_member_id"],
["excel_column" => ["col_name" => "GRADE", "col_index" => 6], "db_column" => "grade"],
["excel_column" => ["col_name" => "RELATION", "col_index" => 7], "db_column" => "relation"],
["excel_column" => ["col_name" => "AGE", "col_index" => 8], "db_column" => "age"],
["excel_column" => ["col_name" => "GENDER", "col_index" => 9], "db_column" => "gender"],
["excel_column" => ["col_name" => "DIAGNOSIS", "col_index" => 10], "db_column" => "diagnosis"],
["excel_column" => ["col_name" => "CLAIMED_AMOUNT", "col_index" => 11], "db_column" => "claimed_amount"],
["excel_column" => ["col_name" => "NET_SANCT_AMT", "col_index" => 12], "db_column" => "net_sanct_amt"],
["excel_column" => ["col_name" => "COPAYMENT_AMT", "col_index" => 13], "db_column" => "copayment_amt"],
["excel_column" => ["col_name" => "DISALLOWED_AMOUNT", "col_index" => 14], "db_column" => "disallowed_amount"],
["excel_column" => ["col_name" => "REASON_FOR_DISALLOWANCE", "col_index" => 15], "db_column" => "reason_for_disallowance"],
["excel_column" => ["col_name" => "PAYMENT_AMOUNT", "col_index" => 16], "db_column" => "payment_amount"],
["excel_column" => ["col_name" => "SUM_INSURED", "col_index" => 17], "db_column" => "sum_insured"],
["excel_column" => ["col_name" => "BAL_SUM_INSURED", "col_index" => 18], "db_column" => "bal_sum_insured"],
["excel_column" => ["col_name" => "TYPE_OF_CLAIM", "col_index" => 19], "db_column" => "type_of_claim"],
["excel_column" => ["col_name" => "Claim_r_Os_Amt", "col_index" => 20], "db_column" => "claim_r_os_amt"],
["excel_column" => ["col_name" => "Updated_status", "col_index" => 21], "db_column" => "updated_status"],
["excel_column" => ["col_name" => "Disease_Category", "col_index" => 22], "db_column" => "disease_category"],
["excel_column" => ["col_name" => "POLICY_START_DATE", "col_index" => 23], "db_column" => "policy_start_date"],
["excel_column" => ["col_name" => "POLICY_END_DATE", "col_index" => 24], "db_column" => "policy_end_date"],
["excel_column" => ["col_name" => "CLAIM_NUMBER", "col_index" => 25], "db_column" => "claim_number"],
["excel_column" => ["col_name" => "AL_NO", "col_index" => 26], "db_column" => "al_no"],
["excel_column" => ["col_name" => "HOSPITAL_CODE", "col_index" => 27], "db_column" => "hospital_code"],
["excel_column" => ["col_name" => "HOSPITAL_ID", "col_index" => 28], "db_column" => "hospital_id"],
["excel_column" => ["col_name" => "HOSPITAL_NAME", "col_index" => 29], "db_column" => "hospital_name"],
["excel_column" => ["col_name" => "TREATMENT_TAKEN", "col_index" => 30], "db_column" => "treatment_taken"],
["excel_column" => ["col_name" => "CF_Utilised_Amounnt", "col_index" => 31], "db_column" => "cf_utilised_amount"],
["excel_column" => ["col_name" => "DT_OF_DEFICIENCIES_SENT", "col_index" => 32], "db_column" => "dt_of_deficiencies_sent"],
["excel_column" => ["col_name" => "DT_OF_DEFICIENCIES_RECIEVED", "col_index" => 33], "db_column" => "dt_of_deficiencies_received"],
["excel_column" => ["col_name" => "PAYMENT_DATE", "col_index" => 34], "db_column" => "payment_date"],
["excel_column" => ["col_name" => "PAYEE_NAME", "col_index" => 35], "db_column" => "payee_name"],
["excel_column" => ["col_name" => "PAYMENT_MODE", "col_index" => 36], "db_column" => "payment_mode"],
["excel_column" => ["col_name" => "CHEQUE_NUMBER", "col_index" => 37], "db_column" => "cheque_number"],
["excel_column" => ["col_name" => "DOA", "col_index" => 38], "db_column" => "doa"],
["excel_column" => ["col_name" => "DOD", "col_index" => 39], "db_column" => "dod"],
["excel_column" => ["col_name" => "HOSPITAL_CITY", "col_index" => 40], "db_column" => "hospital_city"],
["excel_column" => ["col_name" => "HOSPITAL_STATE", "col_index" => 41], "db_column" => "hospital_state"],
["excel_column" => ["col_name" => "REJECTED_QUERY_REASON", "col_index" => 42], "db_column" => "rejected_query_reason"],
["excel_column" => ["col_name" => "REJECTED_QUERY_DESC", "col_index" => 43], "db_column" => "rejected_query_desc"],
["excel_column" => ["col_name" => "REJECTED_QUERY_CLOSED_DATE", "col_index" => 44], "db_column" => "rejected_query_closed_date"],
["excel_column" => ["col_name" => "REJREOPEN_CLOSURE_DATE", "col_index" => 45], "db_column" => "rejreopen_closure_date"],
["excel_column" => ["col_name" => "CLAIM_CLASSIFICATION", "col_index" => 46], "db_column" => "claim_classification"],
["excel_column" => ["col_name" => "TAGGED_INWARD_NO", "col_index" => 47], "db_column" => "tagged_inward_no"],
["excel_column" => ["col_name" => "INWARD_DATE", "col_index" => 48], "db_column" => "inward_date"],
["excel_column" => ["col_name" => "ICD_ID_L3", "col_index" => 49], "db_column" => "icd_id_l3"],
["excel_column" => ["col_name" => "Incidence_Count", "col_index" => 50], "db_column" => "incidence_count"],
["excel_column" => ["col_name" => "FLEXI_OPTION", "col_index" => 51], "db_column" => "flexi_option"],
["excel_column" => ["col_name" => "Base_TopUp_Option", "col_index" => 52], "db_column" => "base_topup_option"],
["excel_column" => ["col_name" => "POLICY_GROUP_NAME", "col_index" => 53], "db_column" => "policy_group_name"],
["excel_column" => ["col_name" => "Relation_Group", "col_index" => 54], "db_column" => "relation_group"],
["excel_column" => ["col_name" => "Age_Band", "col_index" => 55], "db_column" => "age_band"],
["excel_column" => ["col_name" => "Work_Location", "col_index" => 56], "db_column" => "work_location"],
["excel_column" => ["col_name" => "ILTC_TAG", "col_index" => 57], "db_column" => "iltc_tag"],
];
protected $ticketMasterMapping = [
// Employee / Member
'employee_member_id' => 'emp_code',
'relation_group' => 'relationship',
// Claim
'claim_number' => 'claim_number',
'claimed_amount' => 'claim_amount',
'claim_status' => 'tpa_claim_status',
// Dates
'doa' => 'doa',
'dod' => 'dod',
'payment_date' => 'settled_date',
// Hospital
'hospital_name' => 'hospital_name',
'hospital_city' => 'hospital_city',
'hospital_state' => 'hospital_state',
'cheque_number' => 'utr_details',
'uhid' => 'tpa_no',
'rejected_query_desc' => 'claim_description',
];
protected $statusMapping = [
'PAID' => 11,
'REJECTED' => 8,
];
protected $dateColumns = [
'policy_start_date',
'policy_end_date',
'dt_of_deficiencies_sent',
'dt_of_deficiencies_received',
'payment_date',
'doa',
'dod',
'rejected_query_closed_date',
'rejreopen_closure_date',
];
/**
* ABSTRACT FUNCTIONs
*/
public function bulkInsertTPATable(array $data): bool
{
if (empty($data)) {
return false;
}
try {
$ClaimsDumpFhplModel = new ClaimsDumpFhplModel();
$result = $ClaimsDumpFhplModel->insertBatch($data);
return true;
} catch (\Throwable $th) {
$errorData = [
'message' => $th->getMessage(),
'file' => $th->getFile(),
'line' => $th->getLine(),
'code' => $th->getCode(),
'trace' => $th->getTraceAsString(),
'trace_array' => $th->getTrace(), // full array version (optional)
'function' => $th->getTrace()[0]['function'] ?? null,
'class' => $th->getTrace()[0]['class'] ?? null,
];
return false;
}
}
public function importClaimMaster(array $data): bool
{
if (empty($data)) {
return false;
}
$ticketMasterModel = new TicketMasterModel();
$ticketMasterModel->insertBatch($data);
return true;
}
public function updateTicketIdInTPATable(): bool
{
if (empty($data)) {
return false;
}
$builder = $this->db->table('claims_dump_icici');
$builder->insertBatch($data);
return true;
}
public function updateTicketMasterRejectedReasonInTPATable($data): bool
{
if (empty($data)) {
return false;
}
$builder = $this->db->table('claims_dump_icici');
$builder->insertBatch($data);
return true;
}
/**
* MAPPING FUNCTIONs
*/
public function mapTPAData(array $rows, $file_id): array
{
$ClientPolicyModel = new ClaimDumpFileModel();
$file_data = $ClientPolicyModel->where('id', $file_id)->first();
$mapped = [];
foreach ($rows as $row) {
$item = [];
foreach ($this->mapping as $map) {
$excelColumn = $map['excel_column']['col_name'];
$dbColumn = $map['db_column'];
$value = $row[$excelColumn] ?? null;
$item[$dbColumn] = $value;
}
foreach ($this->dateColumns as $key => $value) {
$item[$value] = change_date_format($item[$value] ?? null);
}
$params = [
'doa' => change_date_format($item['doa'] ?? '') ?? null,
'employee_member_id' => $item['employee_member_id'] ?? null,
'claimed_amount' => $item['claimed_amount'] ?? null,
'uhid' => $item['uhid'] ?? null
];
$is_duplicate = $this->checkDuplicateTpaClaim('claims_dump_icici', $params);
if ($is_duplicate) {
$item = [];
continue;
}
$item['file_id'] = $file_id ?? null;
$item['client_id'] = $file_data['client_id'] ?? null;
$item['client_policy_id'] = $file_data['client_policy_id'] ?? null;
$item['created_by'] = $file_data['created_by'] ?? null;
$mapped[] = $item;
}
return $mapped;
}
public function mapClaimMasterData($file_id): array
{
$ClientPolicyModel = new ClaimDumpFileModel();
$file_data = $ClientPolicyModel->where('id', $file_id)->first();
$tpaClaimDumpData = $this->getTpaClaimDumpData('claims_dump_icici', ['file_id' => $file_id]);
if (empty($tpaClaimDumpData)) {
return ['status' => false, 'message' => "No data to insert in TICKET MASTER"];
}
$ClientPolicyModel = new ClientPolicyModel();
$client_policy_data = $ClientPolicyModel
->select("
client_policy.*,
(
SELECT id
FROM client_rm
WHERE is_active = 1
AND level = 3
AND client_id = client_policy.client_id
ORDER BY id ASC
LIMIT 1
) AS acm_id
")
->where('client_policy.id', $file_data['client_policy_id'])
->where('client_policy.is_active', 1)
->first();
try {
$mapped = [];
$rejecetd_reason = [];
foreach ($tpaClaimDumpData as $row) {
$params = [
'doa' => change_date_format($row['doa'] ?? '') ?? null,
'emp_code' => $row['employee_member_id'] ?? null,
'claim_amount' => $row['claim_amount'] ?? null,
'tpa_no' => $row['uhid'] ?? null
];
$isduplicate = $this->checkDublicateTicketMasterClaim($params);
if ($isduplicate) {
$reason = "This claim already exists in our system.";
$rejecetd_reason[$row['id']] = ["ticket_master_insert_reject_reason" => $reason];
continue;
}
$item = [];
$item['client_id'] = $client_policy_data['client_id'] ?? null;
$item['client_policy_id'] = $client_policy_data['id'] ?? null;
$item['insurer_id'] = $client_policy_data['insurer_id'] ?? null;
$item['tpa_id'] = $client_policy_data['tpa_id'] ?? null;
$item['acm_id'] = $client_policy_data['acm_id'] ?? null;
$item['policy_no'] = $client_policy_data['policy_no'] ?? null;
$item['relationship'] = $this->convertRelation($row['relation_group'] ?? '');
$employee_data = $this->getEmployeeDetails($file_data['client_id'], $file_data['client_policy_id'], $row['employee_member_id'], $item['relationship']);
if (!empty($employee_data)) {
$item['emp_id'] = $employee_data['id'] ?? null;
$item['emp_name'] = $employee_data['name'] ?? null;
$item['emp_mail'] = $employee_data['email_corporate'] ?? null;
$item['emp_mobile'] = $employee_data['mobile'] ?? null;
$item['insured_emp_id'] = $employee_data['insured_emp_id'] ?? null;
$item['insured_name'] = $employee_data['insured_name'] ?? null;
} else {
$reason = sprintf(
'The policy number "%s" does not exist in our system. ' .
'Details - Client ID: %s, Client Policy ID: %s, Employee Number: %s, Relationship: %s',
$row['insurer_policy_number'],
$file_data['client_id'],
$file_data['client_policy_id'],
$row['employee_number'],
$item['relationship']
);
$rejecetd_reason[$row['id']] = ["ticket_master_insert_reject_reason" => $reason];
continue;
}
foreach ($this->ticketMasterMapping as $tpaKey => $ticketMasterKey) {
$item[$ticketMasterKey] = array_key_exists($tpaKey, $row) ? $row[$tpaKey] : null;
}
// Meta fields
$item['claim_status_id'] = $statusMapping[$row['updated_status']] ?? 61;
$item['claim_dump_ref_id'] = $row['id'];
$item['file_id'] = $file_id;
$item['created_by'] = $file_data['created_by'] ?? null;
$item['claim_type'] = 1;
$item['priority'] = 1;
$item['mode_of_intimation'] = 5;
$item['ticket_type_id'] = 1;
$mapped[] = $item;
}
return ['status' => true, 'mapped_array' => $mapped, 'rejected_reason_array' => $rejecetd_reason];
} catch (\Throwable $th) {
$errorData = [
'message' => $th->getMessage(),
'file' => $th->getFile(),
'line' => $th->getLine(),
'code' => $th->getCode(),
'trace' => $th->getTraceAsString(),
'trace_array' => $th->getTrace(), // full array version (optional)
'function' => $th->getTrace()[0]['function'] ?? null,
'class' => $th->getTrace()[0]['class'] ?? null,
];
return ['status' => false, "message" => $errorData['message'], 'error_data' => $errorData];
}
}
/**
* HELPER FUNCTIONs
*/
public function convertRelation(?string $relation): ?string
{
if (empty($relation)) {
return null;
}
$relation = strtolower($relation);
if (str_contains($relation, 'self')) {
return 'self';
}
if (str_contains($relation, 'spouse') || str_contains($relation, 'wife') || str_contains($relation, 'husband')) {
return 'spouse';
}
if (str_contains($relation, 'daughter')) {
return 'daughter';
}
if (str_contains($relation, 'son')) {
return 'son';
}
if (str_contains($relation, 'father in law') || str_contains($relation, 'father-in-law')) {
return 'father-in-law';
}
if (str_contains($relation, 'mother in law') || str_contains($relation, 'mother-in-law')) {
return 'mother-in-law';
}
if (str_contains($relation, 'father')) {
return 'father';
}
if (str_contains($relation, 'mother')) {
return 'mother';
}
return null; // unmatched case
}
}

View File

@ -0,0 +1,446 @@
<?php
namespace App\Libraries\TPAClaimsImportServices;
use App\Models\TicketMasterModel;
use App\Models\ClientPolicyModel;
use App\Models\ClientRMModel;
use App\Models\EmployeeModel;
use App\Models\ClaimDumpFileModel;
class MediAssistClaimImportService extends BaseTpaClaimImportService
{
/**
* MAPPING ARRAYs
*/
protected $mapping = [
["excel_column" => ["col_name" => "insurance_company", "col_index" => 0], "db_column" => "insurance_company"],
["excel_column" => ["col_name" => "insurer_region_name", "col_index" => 1], "db_column" => "insurer_region_name"],
["excel_column" => ["col_name" => "insurer_ro_code", "col_index" => 2], "db_column" => "insurer_ro_code"],
["excel_column" => ["col_name" => "insurer_do_code", "col_index" => 3], "db_column" => "insurer_do_code"],
["excel_column" => ["col_name" => "insurer_bo_code", "col_index" => 4], "db_column" => "insurer_bo_code"],
["excel_column" => ["col_name" => "event_id", "col_index" => 5], "db_column" => "event_id"],
["excel_column" => ["col_name" => "claim_id", "col_index" => 6], "db_column" => "claim_id"],
["excel_column" => ["col_name" => "insurer_claim_ref_no", "col_index" => 7], "db_column" => "insurer_claim_ref_no"],
["excel_column" => ["col_name" => "claim_pre_auths", "col_index" => 8], "db_column" => "claim_pre_auths"],
["excel_column" => ["col_name" => "ma_policy_id", "col_index" => 9], "db_column" => "ma_policy_id"],
["excel_column" => ["col_name" => "policy_no", "col_index" => 10], "db_column" => "policy_no"],
["excel_column" => ["col_name" => "policy_holder_name", "col_index" => 11], "db_column" => "policy_holder_name"],
["excel_column" => ["col_name" => "policy_type", "col_index" => 12], "db_column" => "policy_type"],
["excel_column" => ["col_name" => "policy_subtype_desc", "col_index" => 13], "db_column" => "policy_subtype_desc"],
["excel_column" => ["col_name" => "policy_start_date", "col_index" => 14], "db_column" => "policy_start_date"],
["excel_column" => ["col_name" => "policy_end_date", "col_index" => 15], "db_column" => "policy_end_date"],
["excel_column" => ["col_name" => "devlopment_officer", "col_index" => 16], "db_column" => "devlopment_officer"],
["excel_column" => ["col_name" => "agent", "col_index" => 17], "db_column" => "agent"],
["excel_column" => ["col_name" => "broker", "col_index" => 18], "db_column" => "broker"],
["excel_column" => ["col_name" => "pribenef_employee_code", "col_index" => 19], "db_column" => "pribenef_employee_code"],
["excel_column" => ["col_name" => "pribenef_name", "col_index" => 20], "db_column" => "pribenef_name"],
["excel_column" => ["col_name" => "pribenef_floater_sum", "col_index" => 21], "db_column" => "pribenef_floater_sum"],
["excel_column" => ["col_name" => "benef_maid", "col_index" => 22], "db_column" => "benef_maid"],
["excel_column" => ["col_name" => "benef_insurer_id", "col_index" => 23], "db_column" => "benef_insurer_id"],
["excel_column" => ["col_name" => "benef_name", "col_index" => 24], "db_column" => "benef_name"],
["excel_column" => ["col_name" => "benef_gender", "col_index" => 25], "db_column" => "benef_gender"],
["excel_column" => ["col_name" => "benef_relation", "col_index" => 26], "db_column" => "benef_relation"],
["excel_column" => ["col_name" => "benef_age", "col_index" => 27], "db_column" => "benef_age"],
["excel_column" => ["col_name" => "benef_sum_insured", "col_index" => 28], "db_column" => "benef_sum_insured"],
["excel_column" => ["col_name" => "balance_sum_insured", "col_index" => 29], "db_column" => "balance_sum_insured"],
["excel_column" => ["col_name" => "intimation_id", "col_index" => 30], "db_column" => "intimation_id"],
["excel_column" => ["col_name" => "intimation_date", "col_index" => 31], "db_column" => "intimation_date"],
["excel_column" => ["col_name" => "settled_date", "col_index" => 32], "db_column" => "settled_date"],
["excel_column" => ["col_name" => "ClaimSource", "col_index" => 33], "db_column" => "claim_source"],
["excel_column" => ["col_name" => "claim_mode_of_rcpt", "col_index" => 34], "db_column" => "claim_mode_of_rcpt"],
["excel_column" => ["col_name" => "claim_type", "col_index" => 35], "db_column" => "claim_type"],
["excel_column" => ["col_name" => "claim_sub_type", "col_index" => 36], "db_column" => "claim_sub_type"],
["excel_column" => ["col_name" => "claim_stage", "col_index" => 37], "db_column" => "claim_stage"],
["excel_column" => ["col_name" => "claim_status", "col_index" => 38], "db_column" => "claim_status"],
["excel_column" => ["col_name" => "is_cashlessanywhere", "col_index" => 39], "db_column" => "is_cashlessanywhere"],
["excel_column" => ["col_name" => "date_of_admission", "col_index" => 40], "db_column" => "date_of_admission"],
["excel_column" => ["col_name" => "date_of_discharge", "col_index" => 41], "db_column" => "date_of_discharge"],
["excel_column" => ["col_name" => "claim_amount", "col_index" => 42], "db_column" => "claim_amount"],
["excel_column" => ["col_name" => "claim_approved_amount", "col_index" => 43], "db_column" => "claim_approved_amount"],
["excel_column" => ["col_name" => "incurred_amount", "col_index" => 44], "db_column" => "incurred_amount"],
["excel_column" => ["col_name" => "primary_icd_group", "col_index" => 45], "db_column" => "primary_icd_group"],
["excel_column" => ["col_name" => "primary_ailment_name", "col_index" => 46], "db_column" => "primary_ailment_name"],
["excel_column" => ["col_name" => "primary_ailment_code", "col_index" => 47], "db_column" => "primary_ailment_code"],
["excel_column" => ["col_name" => "treatment_type", "col_index" => 48], "db_column" => "treatment_type"],
["excel_column" => ["col_name" => "treatment_name", "col_index" => 49], "db_column" => "treatment_name"],
["excel_column" => ["col_name" => "hospital_id", "col_index" => 50], "db_column" => "hospital_id"],
["excel_column" => ["col_name" => "hospital_name", "col_index" => 51], "db_column" => "hospital_name"],
["excel_column" => ["col_name" => "hospital_city", "col_index" => 52], "db_column" => "hospital_city"],
["excel_column" => ["col_name" => "hospital_state", "col_index" => 53], "db_column" => "hospital_state"],
["excel_column" => ["col_name" => "hospital_pincode", "col_index" => 54], "db_column" => "hospital_pincode"],
["excel_column" => ["col_name" => "hospital_address", "col_index" => 55], "db_column" => "hospital_address"],
["excel_column" => ["col_name" => "Clinic_DoctorName_Hospital", "col_index" => 56], "db_column" => "clinic_doctorname_hospital"],
["excel_column" => ["col_name" => "OPD_pincode", "col_index" => 57], "db_column" => "opd_pincode"],
["excel_column" => ["col_name" => "payable_amount_OPD_Consultation", "col_index" => 58], "db_column" => "payable_amount_opd_consultation"],
["excel_column" => ["col_name" => "payable_amount_Dental", "col_index" => 59], "db_column" => "payable_amount_dental"],
["excel_column" => ["col_name" => "payable_amount_Diagnostics", "col_index" => 60], "db_column" => "payable_amount_diagnostics"],
["excel_column" => ["col_name" => "payable_amount_Other", "col_index" => 61], "db_column" => "payable_amount_other"],
["excel_column" => ["col_name" => "payable_amount_Pharmacy", "col_index" => 62], "db_column" => "payable_amount_pharmacy"],
["excel_column" => ["col_name" => "payable_amount_Vaccination", "col_index" => 63], "db_column" => "payable_amount_vaccination"],
["excel_column" => ["col_name" => "payable_amount_Miscellaneous_Charges", "col_index" => 64], "db_column" => "payable_amount_miscellaneous_charges"],
["excel_column" => ["col_name" => "payable_amount_Health_Checkup", "col_index" => 65], "db_column" => "payable_amount_health_checkup"],
["excel_column" => ["col_name" => "deduction_amount_copay", "col_index" => 66], "db_column" => "deduction_amount_copay"],
["excel_column" => ["col_name" => "deduction_amount_excess_ailment", "col_index" => 67], "db_column" => "deduction_amount_excess_ailment"],
["excel_column" => ["col_name" => "deduction_amount_excess_policy", "col_index" => 68], "db_column" => "deduction_amount_excess_policy"],
["excel_column" => ["col_name" => "deduction_amount_prorata", "col_index" => 69], "db_column" => "deduction_amount_prorata"],
["excel_column" => ["col_name" => "deduction_amount_hospital_discount", "col_index" => 70], "db_column" => "deduction_amount_hospital_discount"],
["excel_column" => ["col_name" => "deduction_amount_paid_by_patient", "col_index" => 71], "db_column" => "deduction_amount_paid_by_patient"],
["excel_column" => ["col_name" => "deduction_amount_issurer_approved", "col_index" => 72], "db_column" => "deduction_amount_issurer_approved"],
["excel_column" => ["col_name" => "deduction_amount_deductible", "col_index" => 73], "db_column" => "deduction_amount_deductible"],
["excel_column" => ["col_name" => "deduction_amount_intimation_penalty", "col_index" => 74], "db_column" => "deduction_amount_intimation_penalty"],
["excel_column" => ["col_name" => "claim_payable_to_name", "col_index" => 75], "db_column" => "claim_payable_to_name"],
["excel_column" => ["col_name" => "utr_no", "col_index" => 76], "db_column" => "utr_no"],
["excel_column" => ["col_name" => "utr_date", "col_index" => 77], "db_column" => "utr_date"],
["excel_column" => ["col_name" => "denial_short_description", "col_index" => 78], "db_column" => "denial_short_description"],
["excel_column" => ["col_name" => "claim_received_date", "col_index" => 79], "db_column" => "claim_received_date"],
["excel_column" => ["col_name" => "last_necessary_doc_rec_date", "col_index" => 80], "db_column" => "last_necessary_doc_rec_date"],
["excel_column" => ["col_name" => "processed_date", "col_index" => 81], "db_column" => "processed_date"],
["excel_column" => ["col_name" => "first_document_attached_date", "col_index" => 82], "db_column" => "first_document_attached_date"],
["excel_column" => ["col_name" => "claim_processing_tat_days", "col_index" => 83], "db_column" => "claim_processing_tat_days"],
["excel_column" => ["col_name" => "ready_for_payment_date", "col_index" => 84], "db_column" => "ready_for_payment_date"],
["excel_column" => ["col_name" => "payment_date", "col_index" => 85], "db_column" => "payment_date"],
["excel_column" => ["col_name" => "claim_payment_tat_days", "col_index" => 86], "db_column" => "claim_payment_tat_days"],
["excel_column" => ["col_name" => "denial_description", "col_index" => 87], "db_column" => "denial_description"],
["excel_column" => ["col_name" => "error_group", "col_index" => 88], "db_column" => "error_group"],
["excel_column" => ["col_name" => "tpa_name", "col_index" => 89], "db_column" => "tpa_name"],
["excel_column" => ["col_name" => "new_short_error_group", "col_index" => 90], "db_column" => "new_short_error_group"],
["excel_column" => ["col_name" => "death_claim", "col_index" => 91], "db_column" => "death_claim"],
["excel_column" => ["col_name" => "vip_claim", "col_index" => 92], "db_column" => "vip_claim"],
["excel_column" => ["col_name" => "balance_sum_insured_exhausted", "col_index" => 93], "db_column" => "balance_sum_insured_exhausted"],
];
protected $ticketMasterMapping = [
// Employee / Beneficiary details
'pribenef_employee_code' => 'emp_code',
'benef_relation' => 'relationship',
// Policy / Claim identifiers
'policy_no' => 'policy_no',
'claim_id' => 'claim_number',
'event_id' => 'tpa_no',
'claim_pre_auths' => 'tpa_claim_push_reference_no',
// Claim type & status
'claim_status' => 'tpa_claim_status',
// Dates
'date_of_admission' => 'doa',
'date_of_discharge' => 'dod',
'intimation_date' => 'date_of_intimat',
'settled_date' => 'settled_date',
'claim_received_date' => 'registration_date',
'processed_date' => 'approved_date',
// Amounts
'claim_amount' => 'claim_amount',
'claim_approved_amount' => 'approved_amount',
// Hospital details
'hospital_name' => 'hospital_name',
'hospital_address' => 'hospital_address',
'hospital_city' => 'hospital_city',
'hospital_state' => 'hospital_state',
'hospital_pincode' => 'hospital_pin_code',
'hospital_phone_no' => 'hospital_phone_no',
// Denial / approval
'denial_description' => 'denial_reason',
'approved_description' => 'approved_description',
// Payment
'utr_no' => 'utr_details',
];
protected $statusMapping = [
'Settled' => 11,
'Rejected' => 8,
'Denied' => 8,
'Cancelled' => 13,
'Processed' => 61,
'Information Awaited' => 4,
'Denied Letter Sent' => 66,
'Cashless Document Awaited' => 3,
];
/**
* ABSTRACT FUNCTIONs
*/
public function bulkInsertTPATable(array $data): bool
{
if (empty($data)) {
return false;
}
$builder = $this->db->table('claims_dump_medi_assist');
$builder->insertBatch($data);
return true;
}
public function importClaimMaster(array $data): bool
{
if (empty($data)) {
return false;
}
$ticketMasterModel = new TicketMasterModel();
$ticketMasterModel->insertBatch($data);
return true;
}
public function updateTicketIdInTPATable(): bool
{
if (empty($data)) {
return false;
}
$builder = $this->db->table('claims_dump_medi_assist');
$builder->insertBatch($data);
return true;
}
public function updateTicketMasterRejectedReasonInTPATable($data): bool
{
if (empty($data)) {
return false;
}
$builder = $this->db->table('claims_dump_medi_assist');
$builder->insertBatch($data);
return true;
}
/**
* MAPPING FUNCTIONs
*/
public function mapTPAData(array $rows, $file_id): array
{
$ClientPolicyModel = new ClaimDumpFileModel();
$file_data = $ClientPolicyModel->where('id', $file_id)->first();
$mapped = [];
foreach ($rows as $row) {
$item = [];
foreach ($this->mapping as $map) {
$excelColumn = $map['excel_column']['col_name'];
$dbColumn = $map['db_column'];
$value = $row[$excelColumn] ?? null;
$item[$dbColumn] = $value;
}
$params = [
'date_of_admission' => change_date_format($item['date_of_admission'] ?? '') ?? null,
'pribenef_employee_code' => $item['pribenef_employee_code'] ?? null,
'claim_amount' => $item['claim_amount'] ?? null,
'event_id' => $item['event_id'] ?? null
];
$is_duplicate = $this->checkDuplicateTpaClaim('claims_dump_medi_assist', $params);
if ($is_duplicate) {
$item = [];
continue;
}
$item['file_id'] = $file_id ?? null;
$item['client_id'] = $file_data['client_id'] ?? null;
$item['client_policy_id'] = $file_data['client_policy_id'] ?? null;
$item['created_by'] = $file_data['created_by'] ?? null;
$mapped[] = $item;
}
return $mapped;
}
public function mapClaimMasterData($file_id): array
{
$ClientPolicyModel = new ClaimDumpFileModel();
$file_data = $ClientPolicyModel->where('id', $file_id)->first();
$tpaClaimDumpData = $this->getTpaClaimDumpData('claims_dump_medi_assist', ['file_id' => $file_id]);
if (empty($tpaClaimDumpData)) {
return ['status' => false, 'message' => "No data to insert in TICKET MASTER"];
}
$ClientPolicyModel = new ClientPolicyModel();
$client_policy_data = $ClientPolicyModel
->select("
client_policy.*,
(
SELECT id
FROM client_rm
WHERE is_active = 1
AND level = 3
AND client_id = client_policy.client_id
ORDER BY id ASC
LIMIT 1
) AS acm_id
")
->where('client_policy.id', $file_data['client_policy_id'])
->where('client_policy.is_active', 1)
->first();
try {
$mapped = [];
$rejecetd_reason = [];
foreach ($tpaClaimDumpData as $row) {
$params = [
'doa' => change_date_format($row['date_of_admission'] ?? '') ?? null,
'emp_code' => $row['pribenef_employee_code'] ?? null,
'claim_amount' => $row['claim_amount'] ?? null,
'tpa_no' => $row['event_id'] ?? null
];
$isduplicate = $this->checkDublicateTicketMasterClaim($params);
if ($isduplicate) {
$reason = "This claim already exists in our system.";
$rejecetd_reason[$row['id']] = ["ticket_master_insert_reject_reason" => $reason];
continue;
}
$item = [];
$item['client_id'] = $client_policy_data['client_id'] ?? null;
$item['client_policy_id'] = $client_policy_data['id'] ?? null;
$item['insurer_id'] = $client_policy_data['insurer_id'] ?? null;
$item['tpa_id'] = $client_policy_data['tpa_id'] ?? null;
$item['acm_id'] = $client_policy_data['acm_id'] ?? null;
$item['policy_no'] = $client_policy_data['policy_no'] ?? null;
$item['relationship'] = $this->convertRelation($row['benef_relation'] ?? null);
$employee_data = $this->getEmployeeDetails($file_data['client_id'], $file_data['client_policy_id'], $row['pribenef_employee_code'], $item['relationship']);
if (!empty($employee_data)) {
$item['emp_id'] = $employee_data['id'] ?? null;
$item['emp_name'] = $employee_data['name'] ?? null;
$item['emp_mail'] = $employee_data['email_corporate'] ?? null;
$item['emp_mobile'] = $employee_data['mobile'] ?? null;
$item['insured_emp_id'] = $employee_data['insured_emp_id'] ?? null;
$item['insured_name'] = $employee_data['insured_name'] ?? null;
} else {
$reason = sprintf(
'The policy number "%s" does not exist in our system. ' .
'Details - Client ID: %s, Client Policy ID: %s, Employee Number: %s, Relationship: %s',
$row['insurer_policy_number'],
$file_data['client_id'],
$file_data['client_policy_id'],
$row['employee_number'],
$item['relationship']
);
$rejecetd_reason[$row['id']] = ["ticket_master_insert_reject_reason" => $reason];
continue;
}
foreach ($this->ticketMasterMapping as $tpaKey => $ticketMasterKey) {
$item[$ticketMasterKey] = array_key_exists($tpaKey, $row) ? $row[$tpaKey] : null;
}
// Meta fields
$item['claim_dump_ref_id'] = $row['id'];
$item['file_id'] = $file_id;
$item['claim_status_id'] = $statusMapping[$row['claim_status']] ?? 61;
$item['created_by'] = $file_data['created_by'] ?? null;
$item['claim_type'] = 1;
$item['priority'] = 1;
$item['mode_of_intimation'] = 5;
$item['ticket_type_id'] = 1;
$mapped[] = $item;
}
return ['status' => true, 'mapped_array' => $mapped, 'rejected_reason_array' => $rejecetd_reason];
} catch (\Throwable $th) {
$errorData = [
'message' => $th->getMessage(),
'file' => $th->getFile(),
'line' => $th->getLine(),
'code' => $th->getCode(),
'trace' => $th->getTraceAsString(),
'trace_array' => $th->getTrace(), // full array version (optional)
'function' => $th->getTrace()[0]['function'] ?? null,
'class' => $th->getTrace()[0]['class'] ?? null,
];
return ['status' => false, "message" => $errorData['message'], 'error_data' => $errorData];
}
}
/**
* HELPER FUNCTIONs
*/
public function convertRelation(?string $relation): ?string
{
if (empty($relation)) {
return null;
}
$relation = strtolower($relation);
if (str_contains($relation, 'self')) {
return 'self';
}
if (str_contains($relation, 'spouse') || str_contains($relation, 'wife') || str_contains($relation, 'husband')) {
return 'spouse';
}
if (str_contains($relation, 'daughter')) {
return 'daughter';
}
if (str_contains($relation, 'son')) {
return 'son';
}
if (str_contains($relation, 'father in law') || str_contains($relation, 'father-in-law')) {
return 'father-in-law';
}
if (str_contains($relation, 'mother in law') || str_contains($relation, 'mother-in-law')) {
return 'mother-in-law';
}
if (str_contains($relation, 'father')) {
return 'father';
}
if (str_contains($relation, 'mother')) {
return 'mother';
}
return null; // unmatched case
}
}

View File

@ -0,0 +1,420 @@
<?php
namespace App\Libraries\TPAClaimsImportServices;
use App\Models\TicketMasterModel;
use App\Models\ClientPolicyModel;
use App\Models\ClientRMModel;
use App\Models\EmployeeModel;
use App\Models\ClaimDumpFileModel;
use App\Models\ClaimsDumpFhplModel;
class RcareClaimImportService extends BaseTpaClaimImportService
{
/**
* MAPPING ARRAYs
*/
protected $mapping = [
["excel_column" => ["col_name" => "CLInwardNo", "col_index" => 0], "db_column" => "cl_inward_no"],
["excel_column" => ["col_name" => "Inward Date", "col_index" => 1], "db_column" => "inward_date"],
["excel_column" => ["col_name" => "Claim Classification", "col_index" => 2], "db_column" => "claim_classification"],
["excel_column" => ["col_name" => "Policy Name", "col_index" => 3], "db_column" => "policy_name"],
["excel_column" => ["col_name" => "Policy Number", "col_index" => 4], "db_column" => "policy_number"],
["excel_column" => ["col_name" => "Policy Start Date", "col_index" => 5], "db_column" => "policy_start_date"],
["excel_column" => ["col_name" => "Policy End Date", "col_index" => 6], "db_column" => "policy_end_date"],
["excel_column" => ["col_name" => "UHID", "col_index" => 7], "db_column" => "uhid"],
["excel_column" => ["col_name" => "Insured Name", "col_index" => 8], "db_column" => "insured_name"],
["excel_column" => ["col_name" => "Patient Name", "col_index" => 9], "db_column" => "patient_name"],
["excel_column" => ["col_name" => "Employee/Member Id", "col_index" => 10], "db_column" => "employee_member_id"],
["excel_column" => ["col_name" => "Grade", "col_index" => 11], "db_column" => "grade"],
["excel_column" => ["col_name" => "Relation", "col_index" => 12], "db_column" => "relation"],
["excel_column" => ["col_name" => "Age", "col_index" => 13], "db_column" => "age"],
["excel_column" => ["col_name" => "Gender", "col_index" => 14], "db_column" => "gender"],
["excel_column" => ["col_name" => "DF/DNF idenitifcation", "col_index" => 15], "db_column" => "df_dnf_identification"],
["excel_column" => ["col_name" => "Sum Insured", "col_index" => 16], "db_column" => "sum_insured"],
["excel_column" => ["col_name" => "DOA/OPD Treatment From", "col_index" => 17], "db_column" => "doa_opd_treatment_from"],
["excel_column" => ["col_name" => "DOD/OPD Treatment To", "col_index" => 18], "db_column" => "dod_opd_treatment_to"],
["excel_column" => ["col_name" => "Hospital Name", "col_index" => 19], "db_column" => "hospital_name"],
["excel_column" => ["col_name" => "Hospital District", "col_index" => 20], "db_column" => "hospital_district"],
["excel_column" => ["col_name" => "Hospital State", "col_index" => 21], "db_column" => "hospital_state"],
["excel_column" => ["col_name" => "ICDCode", "col_index" => 22], "db_column" => "icd_code"],
["excel_column" => ["col_name" => "Disease Category", "col_index" => 23], "db_column" => "disease_category"],
["excel_column" => ["col_name" => "Final Status", "col_index" => 24], "db_column" => "final_status"],
["excel_column" => ["col_name" => "Approved Date", "col_index" => 25], "db_column" => "approved_date"],
["excel_column" => ["col_name" => "Claimed Amount", "col_index" => 26], "db_column" => "claimed_amount"],
["excel_column" => ["col_name" => "Disallowed Amount", "col_index" => 27], "db_column" => "disallowed_amount"],
["excel_column" => ["col_name" => "Net Sanct Amt", "col_index" => 28], "db_column" => "net_sanction_amount"],
["excel_column" => ["col_name" => "Reason For Disallowance", "col_index" => 29], "db_column" => "reason_for_disallowance"],
["excel_column" => ["col_name" => "External Query Remarks", "col_index" => 30], "db_column" => "external_query_remarks"],
["excel_column" => ["col_name" => "Rejection Remarks", "col_index" => 31], "db_column" => "rejection_remarks"],
["excel_column" => ["col_name" => "Cheque/NEFT Number", "col_index" => 32], "db_column" => "cheque_neft_number"],
["excel_column" => ["col_name" => "Cheque/NEFT Date", "col_index" => 33], "db_column" => "cheque_neft_date"],
["excel_column" => ["col_name" => "Diagnosis", "col_index" => 34], "db_column" => "diagnosis"],
["excel_column" => ["col_name" => "Treatment Detail", "col_index" => 35], "db_column" => "treatment_detail"],
["excel_column" => ["col_name" => "Member Reimbursement CL Type", "col_index" => 36], "db_column" => "member_reimbursement_cl_type"],
];
protected $ticketMasterMapping = [
// Employee / Member
'employee_member_id' => 'emp_code',
'relation' => 'relationship',
// Policy
'policy_number' => 'policy_no',
'policy_start_date' => 'date_of_incep',
// Claim Dates
'doa_opd_treatment_from' => 'doa',
'dod_opd_treatment_to' => 'dod',
'approved_date' => 'approved_date',
// Claim Amounts
'claimed_amount' => 'claim_amount',
'net_sanction_amount' => 'approved_amount',
// Status / Remarks
'final_status' => 'tpa_claim_status',
'reason_for_disallowance' => 'denial_reason',
'rejection_remarks' => 'return_remark',
// Hospital
'hospital_name' => 'hospital_name',
'hospital_state' => 'hospital_state',
'hospital_district' => 'hospital_city',
'diagnosis' => 'claim_description',
// Payment
'cheque_neft_number' => 'utr_details',
'cheque_neft_date' => 'settled_date',
// References
'cl_inward_no' => 'claim_number',
];
protected $statusMapping = [
'Settled' => 11,
'Rejected' => 8,
'Denied' => 8,
'Cancelled' => 13,
'Processed' => 61,
'Information Awaited' => 4,
'Denied Letter Sent' => 66,
'Cashless Document Awaited' => 3,
];
protected $dateColumns = [
'inward_date',
'policy_start_date',
'policy_end_date',
'doa_opd_treatment_from',
'dod_opd_treatment_to',
'approved_date',
'cheque_neft_date'
];
/**
* ABSTRACT FUNCTIONs
*/
public function bulkInsertTPATable(array $data): bool
{
if (empty($data)) {
return false;
}
try {
$builder = $this->db->table('claims_dump_reliance');
$builder->insertBatch($data);
return true;
} catch (\Throwable $th) {
$errorData = [
'message' => $th->getMessage(),
'file' => $th->getFile(),
'line' => $th->getLine(),
'code' => $th->getCode(),
'trace' => $th->getTraceAsString(),
'trace_array' => $th->getTrace(), // full array version (optional)
'function' => $th->getTrace()[0]['function'] ?? null,
'class' => $th->getTrace()[0]['class'] ?? null,
];
dd($errorData);
return false;
}
}
public function importClaimMaster(array $data): bool
{
if (empty($data)) {
return false;
}
$ticketMasterModel = new TicketMasterModel();
$ticketMasterModel->insertBatch($data);
return true;
}
public function updateTicketIdInTPATable(): bool
{
if (empty($data)) {
return false;
}
$builder = $this->db->table('claims_dump_reliance');
$builder->insertBatch($data);
return true;
}
public function updateTicketMasterRejectedReasonInTPATable($data): bool
{
if (empty($data)) {
return false;
}
$builder = $this->db->table('claims_dump_reliance');
$builder->insertBatch($data);
return true;
}
/**
* MAPPING FUNCTIONs
*/
public function mapTPAData(array $rows, $file_id): array
{
$ClientPolicyModel = new ClaimDumpFileModel();
$file_data = $ClientPolicyModel->where('id', $file_id)->first();
$mapped = [];
foreach ($rows as $row) {
$item = [];
foreach ($this->mapping as $map) {
$excelColumn = $map['excel_column']['col_name'];
$dbColumn = $map['db_column'];
$value = $row[$excelColumn] ?? null;
$item[$dbColumn] = $value;
}
foreach ($this->dateColumns as $key => $value) {
$item[$value] = change_date_format($item[$value] ?? null, 'd-M-y', 'Y-m-d');
}
$params = [
'doa_opd_treatment_from' => $item['doa_opd_treatment_from'] ?? null,
'employee_member_id' => $item['employee_member_id'] ?? null,
'claimed_amount' => $item['claimed_amount'] ?? null,
'uhid' => $item['uhid'] ?? null
];
$is_duplicate = $this->checkDuplicateTpaClaim('claims_dump_reliance', $params);
if ($is_duplicate) {
$item = [];
continue;
}
$item['file_id'] = $file_id ?? null;
$item['client_id'] = $file_data['client_id'] ?? null;
$item['client_policy_id'] = $file_data['client_policy_id'] ?? null;
$item['created_by'] = $file_data['created_by'] ?? null;
$mapped[] = $item;
}
return $mapped;
}
public function mapClaimMasterData($file_id): array
{
$ClientPolicyModel = new ClaimDumpFileModel();
$file_data = $ClientPolicyModel->where('id', $file_id)->first();
$tpaClaimDumpData = $this->getTpaClaimDumpData('claims_dump_reliance', ['file_id' => $file_id]);
if (empty($tpaClaimDumpData)) {
return ['status' => false, 'message' => "No data to insert in TICKET MASTER"];
}
$ClientPolicyModel = new ClientPolicyModel();
$client_policy_data = $ClientPolicyModel
->select("
client_policy.*,
(
SELECT id
FROM client_rm
WHERE is_active = 1
AND level = 3
AND client_id = client_policy.client_id
ORDER BY id ASC
LIMIT 1
) AS acm_id
")
->where('client_policy.id', $file_data['client_policy_id'])
->where('client_policy.is_active', 1)
->first();
try {
$mapped = [];
$rejecetd_reason = [];
foreach ($tpaClaimDumpData as $row) {
$params = [
'doa' => change_date_format($row['doa_opd_treatment_from'] ?? '') ?? null,
'emp_code' => $row['employee_member_id'] ?? null,
'claim_amount' => $row['claimed_amount'] ?? null,
'tpa_no' => $row['uhid'] ?? null
];
$isduplicate = $this->checkDublicateTicketMasterClaim($params);
if ($isduplicate) {
$reason = "This claim already exists in our system.";
$rejecetd_reason[$row['id']] = ["ticket_master_insert_reject_reason" => $reason];
continue;
}
$item = [];
$item['client_id'] = $client_policy_data['client_id'] ?? null;
$item['client_policy_id'] = $client_policy_data['id'] ?? null;
$item['insurer_id'] = $client_policy_data['insurer_id'] ?? null;
$item['tpa_id'] = $client_policy_data['tpa_id'] ?? null;
$item['acm_id'] = $client_policy_data['acm_id'] ?? null;
$item['policy_no'] = $client_policy_data['policy_no'] ?? null;
$item['relationship'] = $this->convertRelation($row['relation'] ?? null);
$employee_data = $this->getEmployeeDetails($file_data['client_id'], $file_data['client_policy_id'], $row['employee_member_id'], $item['relationship']);
if (!empty($employee_data)) {
$item['emp_id'] = $employee_data['id'] ?? null;
$item['emp_name'] = $employee_data['name'] ?? null;
$item['emp_mail'] = $employee_data['email_corporate'] ?? null;
$item['emp_mobile'] = $employee_data['mobile'] ?? null;
$item['insured_emp_id'] = $employee_data['insured_emp_id'] ?? null;
$item['insured_name'] = $employee_data['insured_name'] ?? null;
} else {
$reason = sprintf(
'The policy number "%s" does not exist in our system. ' .
'Details - Client ID: %s, Client Policy ID: %s, Employee Number: %s, Relationship: %s',
$row['insurer_policy_number'],
$file_data['client_id'],
$file_data['client_policy_id'],
$row['employee_number'],
$item['relationship']
);
$rejecetd_reason[$row['id']] = ["ticket_master_insert_reject_reason" => $reason];
continue;
}
foreach ($this->ticketMasterMapping as $tpaKey => $ticketMasterKey) {
$item[$ticketMasterKey] = array_key_exists($tpaKey, $row) ? $row[$tpaKey] : null;
}
// Meta fields
$item['claim_status_id'] = $statusMapping[$row['final_status']] ?? 61;
$item['file_id'] = $file_id;
$item['created_by'] = $file_data['created_by'] ?? null;
$item['claim_dump_ref_id'] = $row['id'];
$item['claim_type'] = 1;
$item['priority'] = 1;
$item['mode_of_intimation'] = 5;
$item['ticket_type_id'] = 1;
$mapped[] = $item;
}
return ['status' => true, 'mapped_array' => $mapped, 'rejected_reason_array' => $rejecetd_reason];
} catch (\Throwable $th) {
$errorData = [
'message' => $th->getMessage(),
'file' => $th->getFile(),
'line' => $th->getLine(),
'code' => $th->getCode(),
'trace' => $th->getTraceAsString(),
'trace_array' => $th->getTrace(), // full array version (optional)
'function' => $th->getTrace()[0]['function'] ?? null,
'class' => $th->getTrace()[0]['class'] ?? null,
];
return ['status' => false, "message" => $errorData['message'], 'error_data' => $errorData];
}
}
/**
* HELPER FUNCTIONs
*/
public function convertRelation(?string $relation): ?string
{
if (empty($relation)) {
return null;
}
$relation = strtolower($relation);
if (str_contains($relation, 'self')) {
return 'self';
}
if (str_contains($relation, 'spouse') || str_contains($relation, 'wife') || str_contains($relation, 'husband')) {
return 'spouse';
}
if (str_contains($relation, 'daughter')) {
return 'daughter';
}
if (str_contains($relation, 'son')) {
return 'son';
}
if (str_contains($relation, 'father in law') || str_contains($relation, 'father-in-law')) {
return 'father-in-law';
}
if (str_contains($relation, 'mother in law') || str_contains($relation, 'mother-in-law')) {
return 'mother-in-law';
}
if (str_contains($relation, 'father')) {
return 'father';
}
if (str_contains($relation, 'mother')) {
return 'mother';
}
return null; // unmatched case
}
}

View File

@ -0,0 +1,811 @@
<?php
namespace App\Libraries\TPAClaimsImportServices;
use App\Models\TicketMasterModel;
use App\Models\ClientPolicyModel;
use App\Models\ClientRMModel;
use App\Models\EmployeeModel;
use App\Models\ClaimDumpFileModel;
class VidalClaimImportService extends BaseTpaClaimImportService
{
/**
* MAPPING ARRAYs
*/
protected $mapping_old = [
["excel_column" => "TPA Policy Number", "db_column" => "tpa_policy_number"],
["excel_column" => "Insurer Policy Number", "db_column" => "insurer_policy_number"],
["excel_column" => "Corporate Name", "db_column" => "corporate_name"],
["excel_column" => "Proposer Name", "db_column" => "proposer_name"],
["excel_column" => "Corporate Group ID", "db_column" => "corporate_group_id"],
["excel_column" => "Policy Start Date", "db_column" => "policy_start_date"],
["excel_column" => "Policy End date", "db_column" => "policy_end_date"],
["excel_column" => "Insurance Company Name", "db_column" => "insurance_company_name"],
["excel_column" => "Employee Number", "db_column" => "employee_number"],
["excel_column" => "Employee Location", "db_column" => "employee_location"],
["excel_column" => "Primary Policy Holder Name", "db_column" => "primary_policy_holder_name"],
["excel_column" => "Primary Policy Holder Card ID", "db_column" => "primary_policy_holder_card_id"],
["excel_column" => "Employee Grade", "db_column" => "employee_grade"],
["excel_column" => "Patient Health Card ID", "db_column" => "patient_health_card_id"],
["excel_column" => "Patient Name", "db_column" => "patient_name"],
["excel_column" => "Date of Birth", "db_column" => "date_of_birth"],
["excel_column" => "Age", "db_column" => "age"],
["excel_column" => "Gender", "db_column" => "gender"],
["excel_column" => "Relation", "db_column" => "relation"],
["excel_column" => "Sum Insured", "db_column" => "sum_insured"],
["excel_column" => "Balance Sum Insured", "db_column" => "balance_sum_insured"],
["excel_column" => "Top Up Sum Insured", "db_column" => "top_up_sum_insured"],
["excel_column" => "Enrollment status", "db_column" => "enrollment_status"],
["excel_column" => "Policy Inception date", "db_column" => "policy_inception_date"],
["excel_column" => "Policy Exit Date", "db_column" => "policy_exit_date"],
["excel_column" => "Insurer Risk ID", "db_column" => "insurer_risk_id"],
["excel_column" => "Claim Preauth Identifier", "db_column" => "claim_preauth_identifier"],
["excel_column" => "TPA Claim Number", "db_column" => "tpa_claim_number"],
["excel_column" => "Preauth Number", "db_column" => "preauth_number"],
["excel_column" => "Insurer Claim Number", "db_column" => "insurer_claim_number"],
["excel_column" => "Claim Received date", "db_column" => "claim_received_date"],
["excel_column" => "Date of Admission", "db_column" => "date_of_admission"],
["excel_column" => "Date of Discharge", "db_column" => "date_of_discharge"],
["excel_column" => "Hospital Name", "db_column" => "hospital_name"],
["excel_column" => "Hospital ID", "db_column" => "hospital_id"],
["excel_column" => "Hospital Address", "db_column" => "hospital_address"],
["excel_column" => "Hospital City", "db_column" => "hospital_city"],
["excel_column" => "Hospital State", "db_column" => "hospital_state"],
["excel_column" => "Hospital Pincode", "db_column" => "hospital_pincode"],
["excel_column" => "Hospital Network status", "db_column" => "hospital_network_status"],
["excel_column" => "PPN Hospital Status", "db_column" => "ppn_hospital_status"],
["excel_column" => "Room Category", "db_column" => "room_category"],
["excel_column" => "Room Days", "db_column" => "room_days"],
["excel_column" => "ICU Days", "db_column" => "icu_days"],
["excel_column" => "Medical Surgical Identifier", "db_column" => "medical_surgical_identifier"],
["excel_column" => "Treatment Type of AYUSH", "db_column" => "treatment_type_of_ayush"],
["excel_column" => "Package", "db_column" => "package"],
["excel_column" => "Diagnosis", "db_column" => "diagnosis"],
["excel_column" => "Illness Details", "db_column" => "illness_details"],
["excel_column" => "Ailment Grouping", "db_column" => "ailment_grouping"],
["excel_column" => "Primary ICD Code", "db_column" => "primary_icd_code"],
["excel_column" => "Secondary ICD Code", "db_column" => "secondary_icd_code"],
["excel_column" => "Procedure Code", "db_column" => "procedure_code"],
["excel_column" => "Procedure Description", "db_column" => "procedure_description"],
["excel_column" => "Procedure Grouping", "db_column" => "procedure_grouping"],
["excel_column" => "Claim Submission mode", "db_column" => "claim_submission_mode"],
["excel_column" => "Admission Category", "db_column" => "admission_category"],
["excel_column" => "Type of Claim", "db_column" => "type_of_claim"],
["excel_column" => "MainClaim_Prepost type", "db_column" => "mainclaim_prepost_type"],
["excel_column" => "Type of Hospitalization", "db_column" => "type_of_hospitalization"],
["excel_column" => "Death Status", "db_column" => "death_status"],
["excel_column" => "Treatement Given", "db_column" => "treatment_given"],
["excel_column" => "Claim Amount", "db_column" => "claim_amount"],
["excel_column" => "Total Billed Amount", "db_column" => "total_billed_amount"],
["excel_column" => "Claim Consultation Charges", "db_column" => "claim_consultation_charges"],
["excel_column" => "Claim Investigation Charges", "db_column" => "claim_investigation_charges"],
["excel_column" => "Claim Medicines", "db_column" => "claim_medicines"],
["excel_column" => "Claim Nursing", "db_column" => "claim_nursing"],
["excel_column" => "Claim Room Charges", "db_column" => "claim_room_charges"],
["excel_column" => "Claim Icu Charges", "db_column" => "claim_icu_charges"],
["excel_column" => "Claim Stay Charges", "db_column" => "claim_stay_charges"],
["excel_column" => "Claim Surgeon Charges", "db_column" => "claim_surgeon_charges"],
["excel_column" => "Claim Surgery Charges", "db_column" => "claim_surgery_charges"],
["excel_column" => "Claim Miscellaneous Charges", "db_column" => "claim_miscellaneous_charges"],
["excel_column" => "Claim Other Charges", "db_column" => "claim_other_charges"],
["excel_column" => "Approved Consultation Charges", "db_column" => "approved_consultation_charges"],
["excel_column" => "Approved Investigation Charges", "db_column" => "approved_investigation_charges"],
["excel_column" => "Approved Medicines", "db_column" => "approved_medicines"],
["excel_column" => "Approved Nursing", "db_column" => "approved_nursing"],
["excel_column" => "Approved Room Charges", "db_column" => "approved_room_charges"],
["excel_column" => "Approved Icu Charges", "db_column" => "approved_icu_charges"],
["excel_column" => "Approved Stay Charges", "db_column" => "approved_stay_charges"],
["excel_column" => "Approved Surgeon Charges", "db_column" => "approved_surgeon_charges"],
["excel_column" => "Approved Surgery Charges", "db_column" => "approved_surgery_charges"],
["excel_column" => "Approved Miscellaneous Charges", "db_column" => "approved_miscellaneous_charges"],
["excel_column" => "Approved Others Charges", "db_column" => "approved_others_charges"],
["excel_column" => "Total Disallowed Amount", "db_column" => "total_disallowed_amount"],
["excel_column" => "Copayment Amount", "db_column" => "copayment_amount"],
["excel_column" => "Deposit Amount", "db_column" => "deposit_amount"],
["excel_column" => "Exceeds Policy Limit", "db_column" => "exceeds_policy_limit"],
["excel_column" => "Copay Buffer", "db_column" => "copay_buffer"],
["excel_column" => "Hospital Discount Amount", "db_column" => "hospital_discount_amount"],
["excel_column" => "Deductible Amount", "db_column" => "deductible_amount"],
["excel_column" => "Approved Amount", "db_column" => "approved_amount"],
["excel_column" => "Total Incurred Amount", "db_column" => "total_incurred_amount"],
["excel_column" => "Total Buffer Approved", "db_column" => "total_buffer_approved"],
["excel_column" => "Total Buffer Utlilized", "db_column" => "total_buffer_utilized"],
["excel_column" => "TDS Amount", "db_column" => "tds_amount"],
["excel_column" => "Net Amount", "db_column" => "net_amount"],
["excel_column" => "Claim Decision date", "db_column" => "claim_decision_date"],
["excel_column" => "Payment Reference Number", "db_column" => "payment_reference_number"],
["excel_column" => "Payment Reference Date", "db_column" => "payment_reference_date"],
["excel_column" => "Claim Status", "db_column" => "claim_status"],
["excel_column" => "Deduction Remarks", "db_column" => "deduction_remarks"],
["excel_column" => "Rejection Reasons", "db_column" => "rejection_reasons"],
["excel_column" => "Claim Query Reasons", "db_column" => "claim_query_reasons"],
["excel_column" => "Insurer Request Sent date", "db_column" => "insurer_request_sent_date"],
["excel_column" => "Insurer Conf. Received date", "db_column" => "insurer_conf_received_date"],
["excel_column" => "Claim Reopen Date", "db_column" => "claim_reopen_date"],
["excel_column" => "First Query Raised date", "db_column" => "first_query_raised_date"],
["excel_column" => "First Query response date", "db_column" => "first_query_response_date"],
["excel_column" => "Last Query Raised date", "db_column" => "last_query_raised_date"],
["excel_column" => "Last Query response date", "db_column" => "last_query_response_date"],
["excel_column" => "Last Document Received date", "db_column" => "last_document_received_date"],
];
protected $mapping = [
["excel_column" => ["col_name" => "TPA Policy Number", "col_index" => 0], "db_column" => "tpa_policy_number"],
["excel_column" => ["col_name" => "Insurer Policy Number", "col_index" => 1], "db_column" => "insurer_policy_number"],
["excel_column" => ["col_name" => "Corporate Name", "col_index" => 2], "db_column" => "corporate_name"],
["excel_column" => ["col_name" => "Proposer Name", "col_index" => 3], "db_column" => "proposer_name"],
["excel_column" => ["col_name" => "Corporate Group ID", "col_index" => 4], "db_column" => "corporate_group_id"],
["excel_column" => ["col_name" => "Policy Start Date", "col_index" => 5], "db_column" => "policy_start_date"],
["excel_column" => ["col_name" => "Policy End date", "col_index" => 6], "db_column" => "policy_end_date"],
["excel_column" => ["col_name" => "Insurance Company Name", "col_index" => 7], "db_column" => "insurance_company_name"],
["excel_column" => ["col_name" => "Employee Number", "col_index" => 8], "db_column" => "employee_number"],
["excel_column" => ["col_name" => "Employee Location", "col_index" => 9], "db_column" => "employee_location"],
["excel_column" => ["col_name" => "Primary Policy Holder Name", "col_index" => 10], "db_column" => "primary_policy_holder_name"],
["excel_column" => ["col_name" => "Primary Policy Holder Card ID", "col_index" => 11], "db_column" => "primary_policy_holder_card_id"],
["excel_column" => ["col_name" => "Employee Grade", "col_index" => 12], "db_column" => "employee_grade"],
["excel_column" => ["col_name" => "Patient Health Card ID", "col_index" => 13], "db_column" => "patient_health_card_id"],
["excel_column" => ["col_name" => "Patient Name", "col_index" => 14], "db_column" => "patient_name"],
["excel_column" => ["col_name" => "Date of Birth", "col_index" => 15], "db_column" => "date_of_birth"],
["excel_column" => ["col_name" => "Age", "col_index" => 16], "db_column" => "age"],
["excel_column" => ["col_name" => "Gender", "col_index" => 17], "db_column" => "gender"],
["excel_column" => ["col_name" => "Relation", "col_index" => 18], "db_column" => "relation"],
["excel_column" => ["col_name" => "Sum Insured", "col_index" => 19], "db_column" => "sum_insured"],
["excel_column" => ["col_name" => "Balance Sum Insured", "col_index" => 20], "db_column" => "balance_sum_insured"],
["excel_column" => ["col_name" => "Top Up Sum Insured", "col_index" => 21], "db_column" => "top_up_sum_insured"],
["excel_column" => ["col_name" => "Enrollment status", "col_index" => 22], "db_column" => "enrollment_status"],
["excel_column" => ["col_name" => "Policy Inception date", "col_index" => 23], "db_column" => "policy_inception_date"],
["excel_column" => ["col_name" => "Policy Exit Date", "col_index" => 24], "db_column" => "policy_exit_date"],
["excel_column" => ["col_name" => "Insurer Risk ID", "col_index" => 25], "db_column" => "insurer_risk_id"],
["excel_column" => ["col_name" => "Claim Preauth Identifier", "col_index" => 26], "db_column" => "claim_preauth_identifier"],
["excel_column" => ["col_name" => "TPA Claim Number", "col_index" => 27], "db_column" => "tpa_claim_number"],
["excel_column" => ["col_name" => "Preauth Number", "col_index" => 28], "db_column" => "preauth_number"],
["excel_column" => ["col_name" => "Insurer Claim Number", "col_index" => 29], "db_column" => "insurer_claim_number"],
["excel_column" => ["col_name" => "Claim Received date", "col_index" => 30], "db_column" => "claim_received_date"],
["excel_column" => ["col_name" => "Date of Admission", "col_index" => 31], "db_column" => "date_of_admission"],
["excel_column" => ["col_name" => "Date of Discharge", "col_index" => 32], "db_column" => "date_of_discharge"],
["excel_column" => ["col_name" => "Hospital Name", "col_index" => 33], "db_column" => "hospital_name"],
["excel_column" => ["col_name" => "Hospital ID", "col_index" => 34], "db_column" => "hospital_id"],
["excel_column" => ["col_name" => "Hospital Address", "col_index" => 35], "db_column" => "hospital_address"],
["excel_column" => ["col_name" => "Hospital City", "col_index" => 36], "db_column" => "hospital_city"],
["excel_column" => ["col_name" => "Hospital State", "col_index" => 37], "db_column" => "hospital_state"],
["excel_column" => ["col_name" => "Hospital Pincode", "col_index" => 38], "db_column" => "hospital_pincode"],
["excel_column" => ["col_name" => "Hospital Network status", "col_index" => 39], "db_column" => "hospital_network_status"],
["excel_column" => ["col_name" => "PPN Hospital Status", "col_index" => 40], "db_column" => "ppn_hospital_status"],
["excel_column" => ["col_name" => "Room Category", "col_index" => 41], "db_column" => "room_category"],
["excel_column" => ["col_name" => "Room Days", "col_index" => 42], "db_column" => "room_days"],
["excel_column" => ["col_name" => "ICU Days", "col_index" => 43], "db_column" => "icu_days"],
["excel_column" => ["col_name" => "Medical Surgical Identifier", "col_index" => 44], "db_column" => "medical_surgical_identifier"],
["excel_column" => ["col_name" => "Treatment Type of AYUSH", "col_index" => 45], "db_column" => "treatment_type_of_ayush"],
["excel_column" => ["col_name" => "Package", "col_index" => 46], "db_column" => "package"],
["excel_column" => ["col_name" => "Diagnosis", "col_index" => 47], "db_column" => "diagnosis"],
["excel_column" => ["col_name" => "Illness Details", "col_index" => 48], "db_column" => "illness_details"],
["excel_column" => ["col_name" => "Ailment Grouping", "col_index" => 49], "db_column" => "ailment_grouping"],
["excel_column" => ["col_name" => "Primary ICD Code", "col_index" => 50], "db_column" => "primary_icd_code"],
["excel_column" => ["col_name" => "Secondary ICD Code", "col_index" => 51], "db_column" => "secondary_icd_code"],
["excel_column" => ["col_name" => "Procedure Code", "col_index" => 52], "db_column" => "procedure_code"],
["excel_column" => ["col_name" => "Procedure Description", "col_index" => 53], "db_column" => "procedure_description"],
["excel_column" => ["col_name" => "Procedure Grouping", "col_index" => 54], "db_column" => "procedure_grouping"],
["excel_column" => ["col_name" => "Claim Submission mode", "col_index" => 55], "db_column" => "claim_submission_mode"],
["excel_column" => ["col_name" => "Admission Category", "col_index" => 56], "db_column" => "admission_category"],
["excel_column" => ["col_name" => "Type of Claim", "col_index" => 57], "db_column" => "type_of_claim"],
["excel_column" => ["col_name" => "MainClaim_Prepost type", "col_index" => 58], "db_column" => "mainclaim_prepost_type"],
["excel_column" => ["col_name" => "Type of Hospitalization", "col_index" => 59], "db_column" => "type_of_hospitalization"],
["excel_column" => ["col_name" => "Death Status", "col_index" => 60], "db_column" => "death_status"],
["excel_column" => ["col_name" => "Treatement Given", "col_index" => 61], "db_column" => "treatment_given"],
["excel_column" => ["col_name" => "Claim Amount", "col_index" => 62], "db_column" => "claim_amount"],
["excel_column" => ["col_name" => "Total Billed Amount", "col_index" => 63], "db_column" => "total_billed_amount"],
["excel_column" => ["col_name" => "Claim Consultation Charges", "col_index" => 64], "db_column" => "claim_consultation_charges"],
["excel_column" => ["col_name" => "Claim Investigation Charges", "col_index" => 65], "db_column" => "claim_investigation_charges"],
["excel_column" => ["col_name" => "Claim Medicines", "col_index" => 66], "db_column" => "claim_medicines"],
["excel_column" => ["col_name" => "Claim Nursing", "col_index" => 67], "db_column" => "claim_nursing"],
["excel_column" => ["col_name" => "Claim Room Charges", "col_index" => 68], "db_column" => "claim_room_charges"],
["excel_column" => ["col_name" => "Claim Icu Charges", "col_index" => 69], "db_column" => "claim_icu_charges"],
["excel_column" => ["col_name" => "Claim Stay Charges", "col_index" => 70], "db_column" => "claim_stay_charges"],
["excel_column" => ["col_name" => "Claim Surgeon Charges", "col_index" => 71], "db_column" => "claim_surgeon_charges"],
["excel_column" => ["col_name" => "Claim Surgery Charges", "col_index" => 72], "db_column" => "claim_surgery_charges"],
["excel_column" => ["col_name" => "Claim Miscellaneous Charges", "col_index" => 73], "db_column" => "claim_miscellaneous_charges"],
["excel_column" => ["col_name" => "Claim Other Charges", "col_index" => 74], "db_column" => "claim_other_charges"],
["excel_column" => ["col_name" => "Approved Consultation Charges", "col_index" => 75], "db_column" => "approved_consultation_charges"],
["excel_column" => ["col_name" => "Approved Investigation Charges", "col_index" => 76], "db_column" => "approved_investigation_charges"],
["excel_column" => ["col_name" => "Approved Medicines", "col_index" => 77], "db_column" => "approved_medicines"],
["excel_column" => ["col_name" => "Approved Nursing", "col_index" => 78], "db_column" => "approved_nursing"],
["excel_column" => ["col_name" => "Approved Room Charges", "col_index" => 79], "db_column" => "approved_room_charges"],
["excel_column" => ["col_name" => "Approved Icu Charges", "col_index" => 80], "db_column" => "approved_icu_charges"],
["excel_column" => ["col_name" => "Approved Stay Charges", "col_index" => 81], "db_column" => "approved_stay_charges"],
["excel_column" => ["col_name" => "Approved Surgeon Charges", "col_index" => 82], "db_column" => "approved_surgeon_charges"],
["excel_column" => ["col_name" => "Approved Surgery Charges", "col_index" => 83], "db_column" => "approved_surgery_charges"],
["excel_column" => ["col_name" => "Approved Miscellaneous Charges", "col_index" => 84], "db_column" => "approved_miscellaneous_charges"],
["excel_column" => ["col_name" => "Approved Others Charges", "col_index" => 85], "db_column" => "approved_others_charges"],
["excel_column" => ["col_name" => "Total Disallowed Amount", "col_index" => 86], "db_column" => "total_disallowed_amount"],
["excel_column" => ["col_name" => "Copayment Amount", "col_index" => 87], "db_column" => "copayment_amount"],
["excel_column" => ["col_name" => "Deposit Amount", "col_index" => 88], "db_column" => "deposit_amount"],
["excel_column" => ["col_name" => "Exceeds Policy Limit", "col_index" => 89], "db_column" => "exceeds_policy_limit"],
["excel_column" => ["col_name" => "Copay Buffer", "col_index" => 90], "db_column" => "copay_buffer"],
["excel_column" => ["col_name" => "Hospital Discount Amount", "col_index" => 91], "db_column" => "hospital_discount_amount"],
["excel_column" => ["col_name" => "Deductible Amount", "col_index" => 92], "db_column" => "deductible_amount"],
["excel_column" => ["col_name" => "Approved Amount", "col_index" => 93], "db_column" => "approved_amount"],
["excel_column" => ["col_name" => "Total Incurred Amount", "col_index" => 94], "db_column" => "total_incurred_amount"],
["excel_column" => ["col_name" => "Total Buffer Approved", "col_index" => 95], "db_column" => "total_buffer_approved"],
["excel_column" => ["col_name" => "Total Buffer Utlilized", "col_index" => 96], "db_column" => "total_buffer_utilized"],
["excel_column" => ["col_name" => "TDS Amount", "col_index" => 97], "db_column" => "tds_amount"],
["excel_column" => ["col_name" => "Net Amount", "col_index" => 98], "db_column" => "net_amount"],
["excel_column" => ["col_name" => "Claim Decision date", "col_index" => 99], "db_column" => "claim_decision_date"],
["excel_column" => ["col_name" => "Payment Reference Number", "col_index" => 100], "db_column" => "payment_reference_number"],
["excel_column" => ["col_name" => "Payment Reference Date", "col_index" => 101], "db_column" => "payment_reference_date"],
["excel_column" => ["col_name" => "Claim Status", "col_index" => 102], "db_column" => "claim_status"],
["excel_column" => ["col_name" => "Deduction Remarks", "col_index" => 103], "db_column" => "deduction_remarks"],
["excel_column" => ["col_name" => "Rejection Reasons", "col_index" => 104], "db_column" => "rejection_reasons"],
["excel_column" => ["col_name" => "Claim Query Reasons", "col_index" => 105], "db_column" => "claim_query_reasons"],
["excel_column" => ["col_name" => "Insurer Request Sent date", "col_index" => 106], "db_column" => "insurer_request_sent_date"],
["excel_column" => ["col_name" => "Insurer Conf. Received date", "col_index" => 107], "db_column" => "insurer_conf_received_date"],
["excel_column" => ["col_name" => "Claim Reopen Date", "col_index" => 108], "db_column" => "claim_reopen_date"],
["excel_column" => ["col_name" => "First Query Raised date", "col_index" => 109], "db_column" => "first_query_raised_date"],
["excel_column" => ["col_name" => "First Query response date", "col_index" => 110], "db_column" => "first_query_response_date"],
["excel_column" => ["col_name" => "Last Query Raised date", "col_index" => 111], "db_column" => "last_query_raised_date"],
["excel_column" => ["col_name" => "Last Query response date", "col_index" => 112], "db_column" => "last_query_response_date"],
["excel_column" => ["col_name" => "Last Document Received date", "col_index" => 113], "db_column" => "last_document_received_date"],
];
protected $ticketMasterMapping = [
// Policy / Claim identifiers
'insurer_policy_number' => 'policy_no',
'insurer_claim_number' => 'claim_number',
'tpa_claim_number' => 'tpa_claim_id',
// Employee / Insured details
'employee_number' => 'emp_code',
'primary_policy_holder_name' => 'emp_name',
'patient_name' => 'insured_name',
// Dates
'date_of_admission' => 'doa',
'date_of_discharge' => 'dod',
'date_of_birth' => 'dob',
'claim_received_date' => 'registration_date',
// Claim details
'claim_amount' => 'claim_amount',
'approved_amount' => 'approved_amount',
'sum_insured' => 'si_amt',
'claim_status' => 'tpa_claim_status',
// Hospital details
'hospital_name' => 'hospital_name',
'hospital_address' => 'hospital_address',
'hospital_city' => 'hospital_city',
'hospital_state' => 'hospital_state',
'hospital_pincode' => 'hospital_pin_code',
// Meta
'file_id' => 'file_id',
];
protected $statusMapping = [
'CL Paid with Settlement Letter' => 11,
'CL Rejected' => 8,
'CL Approved' => 9,
'AL Closed' => 12,
];
/**
* ABSTRACT FUNCTIONs
*/
public function bulkInsertTPATable(array $data): bool
{
if (empty($data)) {
return false;
}
$builder = $this->db->table('claims_dump_vidal');
$builder->insertBatch($data);
return true;
}
public function importClaimMaster(array $data): bool
{
if (empty($data)) {
return false;
}
$ticketMasterModel = new TicketMasterModel();
$ticketMasterModel->insertBatch($data);
return true;
}
public function updateTicketIdInTPATable(): bool
{
if (empty($data)) {
return false;
}
$builder = $this->db->table('claims_dump_vidal');
$builder->insertBatch($data);
return true;
}
public function updateTicketMasterRejectedReasonInTPATable($data): bool
{
if (empty($data)) {
return false;
}
$builder = $this->db->table('claims_dump_vidal');
$builder->insertBatch($data);
return true;
}
/**
* MAPPING FUNCTIONs
*/
public function mapTPAData(array $rows, $file_id): array
{
$ClientPolicyModel = new ClaimDumpFileModel();
$file_data = $ClientPolicyModel->where('id', $file_id)->first();
$mapped = [];
foreach ($rows as $row) {
$item = [];
foreach ($this->mapping as $map) {
$excelColumn = $map['excel_column']['col_name'];
$dbColumn = $map['db_column'];
$value = $row[$excelColumn] ?? null;
if ($this->isDateValue($value)) {
$value = $this->normalizeDate($value);
}
$item[$dbColumn] = $value;
}
$params = [
'date_of_admission' => change_date_format($item['date_of_admission'] ?? '') ?? null,
'employee_number' => $item['employee_number'] ?? null,
'claim_amount' => $item['claim_amount'] ?? null,
'primary_policy_holder_card_id' => $item['primary_policy_holder_card_id'] ?? null
];
$is_duplicate = $this->checkDuplicateTpaClaim('claims_dump_vidal', $params);
if ($is_duplicate) {
$item = [];
continue;
}
$item['file_id'] = $file_id ?? null;
$item['client_id'] = $file_data['client_id'] ?? null;
$item['client_policy_id'] = $file_data['client_policy_id'] ?? null;
$item['created_by'] = $file_data['created_by'] ?? null;
$mapped[] = $item;
}
return $mapped;
}
public function mapClaimMasterData($file_id): array
{
$ClientPolicyModel = new ClaimDumpFileModel();
$file_data = $ClientPolicyModel->where('id', $file_id)->first();
$tpaClaimDumpData = $this->getTpaClaimDumpData('claims_dump_vidal', ['file_id' => $file_id]);
if (empty($tpaClaimDumpData)) {
return ['status' => false, 'message' => "No data to insert in TICKET MASTER"];
}
$ClientPolicyModel = new ClientPolicyModel();
$client_policy_data = $ClientPolicyModel
->select("
client_policy.*,
(
SELECT id
FROM client_rm
WHERE is_active = 1
AND level = 3
AND client_id = client_policy.client_id
ORDER BY id ASC
LIMIT 1
) AS acm_id
")
->where('client_policy.id', $file_data['client_policy_id'])
->where('client_policy.is_active', 1)
->first();
try {
$mapped = [];
$rejecetd_reason = [];
foreach ($tpaClaimDumpData as $row) {
$params = [
'doa' => change_date_format($row['date_of_admission'] ?? '') ?? null,
'emp_code' => $row['employee_number'] ?? null,
'claim_amount' => $row['claim_amount'] ?? null,
'tpa_no' => $row['primary_policy_holder_card_id'] ?? null
];
$isduplicate = $this->checkDublicateTicketMasterClaim($params);
if ($isduplicate) {
$reason = "This claim already exists in our system.";
$rejecetd_reason[$row['id']] = ["ticket_master_insert_reject_reason" => $reason];
continue;
}
$item = [];
$item['client_id'] = $client_policy_data['client_id'] ?? null;
$item['client_policy_id'] = $client_policy_data['id'] ?? null;
$item['insurer_id'] = $client_policy_data['insurer_id'] ?? null;
$item['tpa_id'] = $client_policy_data['tpa_id'] ?? null;
$item['acm_id'] = $client_policy_data['acm_id'] ?? null;
$item['policy_no'] = $client_policy_data['policy_no'] ?? null;
$item['relationship'] = $this->convertRelation($row['relation'] ?? null, $row['gender'] ?? null);
$employee_data = $this->getEmployeeDetails($file_data['client_id'], $file_data['client_policy_id'], $row['employee_number'], $item['relationship']);
if (!empty($employee_data)) {
$item['emp_id'] = $employee_data['id'] ?? null;
$item['emp_name'] = $employee_data['name'] ?? null;
$item['emp_mail'] = $employee_data['email_corporate'] ?? null;
$item['emp_mobile'] = $employee_data['mobile'] ?? null;
$item['insured_emp_id'] = $employee_data['insured_emp_id'] ?? null;
$item['insured_name'] = $employee_data['insured_name'] ?? null;
} else {
$reason = sprintf(
'The policy number "%s" does not exist in our system. ' .
'Details - Client ID: %s, Client Policy ID: %s, Employee Number: %s, Relationship: %s',
$row['insurer_policy_number'],
$file_data['client_id'],
$file_data['client_policy_id'],
$row['employee_number'],
$item['relationship']
);
$rejecetd_reason[$row['id']] = ["ticket_master_insert_reject_reason" => $reason];
continue;
}
foreach ($this->ticketMasterMapping as $tpaKey => $ticketMasterKey) {
$item[$ticketMasterKey] = array_key_exists($tpaKey, $row) ? $row[$tpaKey] : null;
}
// Meta fields
$item['claim_status_id'] = $statusMapping[$row['status']] ?? 61;
$item['file_id'] = $file_id;
$item['claim_dump_ref_id'] = $row['id'];
$item['created_by'] = $file_data['created_by'] ?? null;
$item['claim_type'] = isset($row['mainclaim_prepost_type']) && !empty($row['mainclaim_prepost_type']) && strtolower($row['mainclaim_prepost_type']) == 'normal' ? 1 : 3;
$item['priority'] = 1;
$item['mode_of_intimation'] = 5;
$item['ticket_type_id'] = 1;
$mapped[] = $item;
}
return ['status' => true, 'mapped_array' => $mapped, 'rejected_reason_array' => $rejecetd_reason];
} catch (\Throwable $th) {
$errorData = [
'message' => $th->getMessage(),
'file' => $th->getFile(),
'line' => $th->getLine(),
'code' => $th->getCode(),
'trace' => $th->getTraceAsString(),
'trace_array' => $th->getTrace(), // full array version (optional)
'function' => $th->getTrace()[0]['function'] ?? null,
'class' => $th->getTrace()[0]['class'] ?? null,
];
return ['status' => false, "message" => $errorData['message'], 'error_data' => $errorData];
}
}
public function mapClaimMasterDataOld($file_id): array
{
$tpaClaimDumpData = $this->db
->table('claims_dump_vidal')
->where('is_active', 1)
->where('file_id', $file_id)
->where('ticket_id IS NULL')
->get()
->getResultArray();
if (empty($tpaClaimDumpData)) {
return [];
}
$ClientPolicyModel = new ClientPolicyModel();
$client_policy_data = $ClientPolicyModel->where('is_active', 1)->findAll();
$mapped = [];
$rejecetd_reason = [];
foreach ($tpaClaimDumpData as $row) {
$item = [];
if(isset($row['insurer_policy_number']) && !empty($row['insurer_policy_number'])){
$basic_claim_data = $this->getClientPolicyDataBypolicyNo($client_policy_data, $row['insurer_policy_number']);
if(empty($basic_claim_data)){
$reason = " This policy no ( " . $row['insurer_policy_number'] ." ) does not exist in our system";
$rejecetd_reason[$row['id']] = ["ticket_master_insert_reject_reason" => $reason];
continue;
}
$item['client_id'] = $basic_claim_data['client_id'] ?? null;
$item['client_policy_id'] = $basic_claim_data['id'] ?? null;
$item['insurer_id'] = $basic_claim_data['insurer_id'] ?? null;
$item['tpa_id'] = $basic_claim_data['tpa_id'] ?? null;
$item['acm_id'] = $basic_claim_data['acm_id'] ?? null;
$item['policy_no'] = $basic_claim_data['policy_no'] ?? null;
$item['relationship'] = $this->convertRelation($row['relation'] ?? null, $row['gender'] ?? null);
$employee_data = $this->getEmployeeDetails($item['client_id'], $item['client_policy_id'], $row['employee_number'], $item['relationship']);
if(!empty($employee_data)){
$item['emp_id'] = $employee_data['client_id'] ?? null;
$item['emp_name'] = $employee_data['id'] ?? null;
$item['emp_mail'] = $employee_data['insurer_id'] ?? null;
$item['emp_mobile'] = $employee_data['tpa_id'] ?? null;
$item['insured_emp_id'] = $employee_data['insured_emp_id'] ?? null;
$item['insured_name'] = $employee_data['insured_name'] ?? null;
}else{
$reason = " This policy no ( " . $row['insurer_policy_number'] ." ) does not exist in our system";
$rejecetd_reason[$row['id']] = ["ticket_master_insert_reject_reason" => $reason];
continue;
}
}else{
$reason = " Policy Number is empty";
$rejecetd_reason[$row['id']] = ["ticket_master_insert_reject_reason" => $reason];
continue;
}
foreach ($this->ticketMasterMapping as $tpaKey => $ticketMasterKey) {
$item[$ticketMasterKey] = array_key_exists($tpaKey, $row)
? $row[$tpaKey]
: null;
}
$isduplicate = checkDuplicateClaim([
'doa' => change_date_format($item['doa'] ?? '') ?? null,
'emp_code' => $item['emp_code'] ?? null,
'claim_amount' => $item['claim_amount'] ?? null,
'policy_no' => $item['policy_no'] ?? null
]);
if($isduplicate){
$reason = " This claim ( " . $row['insurer_policy_number'] ." ) does not exist in our system";
$rejecetd_reason[$row['id']] = ["ticket_master_insert_reject_reason" => $reason];
continue;
}
// Meta fields
$item['file_id'] = $file_id;
$item['created_by'] = get_session_userid() ?? null;
$item['claim_type'] = isset($row['mainclaim_prepost_type']) && !empty($row['mainclaim_prepost_type']) && strtolower($row['mainclaim_prepost_type']) == 'normal' ? 1 : 3;
$mapped[] = $item;
}
return ['mapped_array' => $mapped, 'rejected_reason_array' => $rejecetd_reason];
}
/**
* HELPER FUNCTIONs
*/
public function isDateValue($value): bool
{
if (empty($value)) {
return false;
}
// Excel numeric date (e.g. 44927)
if (is_numeric($value) && $value > 30000) {
return true;
}
// Common date formats
return preg_match(
'/^\d{1,2}[\/\-]\d{1,2}[\/\-]\d{2,4}$|^\d{4}[\/\-]\d{1,2}[\/\-]\d{1,2}$/',
(string) $value
) === 1;
}
public function normalizeDate($value): ?string
{
try {
// Excel numeric date
if (is_numeric($value)) {
return date('Y-m-d', \PhpOffice\PhpSpreadsheet\Shared\Date::excelToTimestamp($value));
}
// String date
return date('Y-m-d', strtotime(str_replace('/', '-', $value)));
} catch (\Throwable $e) {
return null;
}
}
public function looksLikeDate($value): bool
{
if (empty($value)) {
return false;
}
// Excel numeric date
if (is_numeric($value) && $value > 30000) {
return true;
}
return preg_match(
'/\d{1,2}[\/\-]\d{1,2}[\/\-]\d{2,4}|
\d{4}[\/\-]\d{1,2}[\/\-]\d{1,2}|
\d{1,2}\s?[A-Za-z]{3,}\s?\d{2,4}|
\d{8}/x',
(string) $value
) === 1;
}
public function convertRelation(string $relation, string $gender): ?string
{
if (empty($relation)) {
return null;
}
$relation = strtolower($relation);
$gender = strtolower($gender);
if ($relation == 'self') {
return $relation;
}
if ($relation == 'spouse') {
return $relation;
}
if ($relation == 'child' && $gender == 'male') {
return 'son';
}
if ($relation == 'child' && $gender == 'female') {
return 'daughter';
}
if ($relation == 'parents' && $gender == 'male') {
return 'father';
}
if ($relation == 'parents' && $gender == 'female') {
return 'mother';
}
if ($relation == 'parents-in-law' && $gender == 'male') {
return 'father-in-law';
}
if ($relation == 'parents-in-law' && $gender == 'female') {
return 'mother-in-law';
}
return null;
}
public function getClientPolicyDataBypolicyNo(array $client_policy_data, string $policy_number): array
{
$matched_data = [];
foreach ($client_policy_data as $key => $value) {
if(trim($value) == trim($policy_number)){
$matched_data = $value;
}
}
if(!empty($matched_data)){
$ClientRMModel = new ClientRMModel();
$acm_data = $ClientRMModel->where('is_active', 1)->where('level', 3)->where('client_id', $matched_data['client_id'])->orderBy('id', 'asc')->first();
if(!empty($acm_data)){
$matched_data['acm_id'] = $acm_data['id'] ?? null;
}
}
return $matched_data;
}
}

View File

@ -0,0 +1,37 @@
<?php
namespace App\Libraries;
use App\Libraries\TPAClaimsImportServices\BaseTpaClaimImportService;
use App\Libraries\TPAClaimsImportServices\VidalClaimImportService;
use App\Libraries\TPAClaimsImportServices\AbhiClaimImportService;
use App\Libraries\TPAClaimsImportServices\FhplClaimImportService;
use App\Libraries\TPAClaimsImportServices\MediAssistClaimImportService;
use App\Libraries\TPAClaimsImportServices\RcareClaimImportService;
use App\Libraries\TPAClaimsImportServices\IciciClaimImportService;
use InvalidArgumentException;
class TpaClaimsImportFactory
{
/**
* Resolve TPA Import Service based on TPA ID
*
* @param int $tpaId
* @return BaseTpaClaimImportService
*/
public static function make(int $tpaId): BaseTpaClaimImportService
{
return match ($tpaId) {
(int) env('VIDAL_PRIMARY_KEY_CONSTANT') => new VidalClaimImportService(),
(int) env('ABHI_PRIMARY_KEY_CONSTANT') => new AbhiClaimImportService(),
(int) env('MEDI_ASSIST_PRIMARY_KEY_CONSTANT') => new MediAssistClaimImportService(),
(int) env('FHPL_PRIMARY_KEY_CONSTANT') => new FhplClaimImportService(),
(int) env('R_CARE_PRIMARY_KEY_CONSTANT') => new RcareClaimImportService(),
(int) env('ICICI_PRIMARY_KEY_CONSTANT') => new IciciClaimImportService(),
default => throw new InvalidArgumentException(
"Unsupported TPA ID: {$tpaId}"
),
};
}
}

View File

@ -10,6 +10,9 @@ class ClaimDumpFileModel extends Model
protected $primaryKey = 'id';
protected $allowedFields = [
"id",
"client_id",
"client_policy_id",
"tpa_id",
"file_name",
"status",
"reason",

View File

@ -0,0 +1,141 @@
<?php
namespace App\Models;
use CodeIgniter\Model;
class ClaimsDumpFhplModel extends Model
{
protected $table = 'claims_dump_fhpl';
protected $primaryKey = 'id';
protected $allowedFields = [
'id',
'client_id',
'client_policy_id',
'ticket_id',
'file_id',
'created_by',
'updated_by',
'is_active',
'request_type',
'intimation_id',
'intimation_date',
'claim_id',
'sl_no',
'uhid_no',
'member_name',
'main_member_uhid_no',
'main_member_name',
'gender',
'dob',
'years',
'relationship',
'employee_id',
'mobile',
'email',
'policy_no',
'policy_start_date',
'policy_commencing_date',
'policy_expiry_date',
'organisation_name',
'claim_received_date',
'admission_date',
'discharge_date',
'diagnosis',
'service_type',
'service_sub_type',
'icd_code_first_level',
'icd_code_second_level',
'icd_code_third_level',
'claim_type',
'provider_name',
'provider_address',
'provider_place',
'provider_state',
'provider_pincode',
'provider_type',
'provider_identification',
'coverage_amount',
'claim_amount',
'billed_amount',
'disallowed_amount',
'dis_allowance_reason_1',
'dis_allowance_reason_2',
'settled_amount',
'incurred_amount',
'discount_amount',
'tds_amount',
'net_amount_paid',
'co_payment',
'current_claim_status',
'balance_sum_insured',
'cheque_no',
'cheque_date',
'claim_passed_date',
'settled_date',
'pending_remarks',
'ir_investigation',
'ir_date',
'ir_retrieval_date',
'first_reminder',
'second_reminder',
'rejection_remarks',
'payee_name',
'treatment_type',
'room_days',
'icu_days',
'total_stay',
'room_rent_claimed',
'icu_claimed',
'icu_related',
'nursing_claimed',
'nursing_charges',
'room_rent_related',
'professional_charges',
'drugs_medication_consumables',
'investigations_procedures_ip',
'domicillary_hospitalization',
'maternity',
'day_care',
'operation_theatre',
'organ_donor',
'ancillary_services',
'dental',
'out_patient_coverage',
'personal_accident',
'critical_illness',
'health_check_up',
'spectacles_contact_lenses_hearing_aid',
'notes',
'buffer_amount',
'tertiary_amount',
'insurance_name',
'ro_name',
'class_of_accommodation',
'claim_created_datetime',
'insurer_claim_id',
'gipsa',
'date_of_joining',
'gipsa_hospital',
'package',
'is_nidb',
'nidb_removed_date',
'investigation_date',
'investigation_retrieval_date',
'reopened_date',
'refer_to_insurer_date',
'received_date_from_insurer',
'rejection_category',
'refer_to_insurer_reasons',
'is_vip',
'main_claim_status',
'main_claim_type',
'icd_third_level_code',
'benefit_plan_name',
'zone',
'grade',
'last_modified_date',
'temp_mou'
];
}

View File

@ -118,7 +118,16 @@ class ClientPolicyModel extends Model
return $this->db->table('client_policy')
->select('client_policy.*')
->select('
client_policy.*,
CASE
WHEN client_policy.policy_entry_from = 3
AND client_policy.cd_ac_pk IS NULL
THEN leads.cd_amount
ELSE NULL
END AS lead_cd_amount
', false)
->select('insurers.name as insurer_name, insurers.short_name as insurer_short')
->select('tpa.name as tpa_name, tpa.short_name as tpa_short')
->select('policy_type.policy_type as policy_type_name')
@ -132,6 +141,7 @@ class ClientPolicyModel extends Model
->join('tpa_branch', 'client_policy.tpa_branch_id = tpa_branch.id', 'left')
->join('policy_type', 'policy_type.id = client_policy.policy_type_id')
->join('client_branch', 'client_branch.id = client_policy.client_branch_id')
->join('leads', 'client_policy.is_from_lead = leads.id', 'left')
->where('client_policy.client_id', $client_id)
// ->where('client_policy.policy_status', 1)
->where('client_policy.is_active', 1)
@ -183,9 +193,14 @@ class ClientPolicyModel extends Model
->join('clients', 'clients.id = client_policy.client_id')
->join('insurers', 'insurers.id = client_policy.insurer_id')
->join('insurer_branch', 'client_policy.insurer_branch_id = insurer_branch.id', 'left')
->join('cd_master', 'cd_master.insurer_id = insurers.id AND cd_master.client_id = client_policy.client_id')
->where('client_policy.client_id', $id)
->where('cd_master.id = client_policy.cd_ac_pk')
->join('cd_master', 'cd_master.insurer_id = insurers.id AND cd_master.client_id = client_policy.client_id');
// ->where('client_policy.client_id', $id)
if (is_string($id) && preg_match('/^[a-f0-9]{32}$/i', $id)) {
$builder->where('MD5(client_policy.client_id)', $id);
} else {
$builder->where('client_policy.client_id', $id);
}
$builder->where('cd_master.id = client_policy.cd_ac_pk')
->where('cd_master.is_active', 1)
->groupBy('client_policy.client_id')
->groupBy('client_policy.insurer_id')
@ -248,14 +263,33 @@ class ClientPolicyModel extends Model
}
public function getClientById($id)
// public function getClientById($id)
// {
// $query = $this->db->table('clients')->getWhere(['id' => $id]);
// // Debug statement
// return $query->getRow();
// }
public function getClientById($client_id)
{
$query = $this->db->table('clients')->getWhere(['id' => $id]);
// Debug statement
return $query->getRow();
if (empty($client_id)) {
return null;
}
$builder = $this->db->table('clients');
// MD5 vs normal ID check
if (is_string($client_id) && preg_match('/^[a-f0-9]{32}$/i', $client_id)) {
$builder->where('MD5(id)', $client_id);
} else {
$builder->where('id', $client_id);
}
return $builder->get()->getRow();
}
public function getDepositData($clientId, $insurerId, $cd_ac_pk = null, $subTypeOptions = null)
{
@ -285,9 +319,16 @@ class ClientPolicyModel extends Model
->join('client_policy', 'client_policy.id = cash_deposit.client_policy_id', 'left')
->join('cd_master', 'cd_master.id = cash_deposit.cd_ac_pk', 'left')
// ->join('policies', 'policies.id = client_policy.policy_id', 'left')
->join('policy_type', 'policy_type.id = client_policy.policy_type_id', 'left')
->where('cash_deposit.client_id', $clientId)
->where('cash_deposit.insurer_id', $insurerId)
->join('policy_type', 'policy_type.id = client_policy.policy_type_id', 'left');
// ->where('cash_deposit.client_id', $clientId)
if (!empty($clientId)) {
if (is_string($clientId) && preg_match('/^[a-f0-9]{32}$/i', $clientId)) {
$query->where('MD5(cash_deposit.client_id)', $clientId);
} else {
$query->where('cash_deposit.client_id', $clientId);
}
}
$query->where('cash_deposit.insurer_id', $insurerId)
->where('cash_deposit.is_active', 1)
->where('cd_master.is_active', 1);
// ->where('cash_deposit.cd_ac_pk = cd_master.id')
@ -300,12 +341,56 @@ class ClientPolicyModel extends Model
}
// public function getDepositSummary($clientId, $insurerId, $cd_ac_pk)
// {
// $subQuery = $this->db->table('cash_deposit')
// ->select('balance')
// ->where('client_id', $clientId)
// ->where('insurer_id', $insurerId)
// ->where('cd_ac_pk', $cd_ac_pk)
// ->where('is_active', 1)
// ->orderBy('id', 'DESC')
// ->limit(1)
// ->getCompiledSelect();
// // Fetch the sum of credit and debit transactions and calculate the balance
// $data = $this->db->table('cash_deposit')
// ->select("($subQuery) AS balance", false)
// ->select('SUM(CASE WHEN transaction_type = "Credit" THEN amount ELSE 0 END) AS total_credit')
// ->select('SUM(CASE WHEN transaction_type = "Debit" THEN amount ELSE 0 END) AS total_withdraw')
// // ->select('SUM(CASE WHEN transaction_type = "Credit" THEN amount ELSE -amount END) AS balance')
// ->select('SUM(CASE WHEN sub_type = 3 THEN amount ELSE 0 END) AS total_refund')
// ->where('client_id', $clientId)
// ->where('insurer_id', $insurerId)
// ->where('cd_ac_pk', $cd_ac_pk)
// ->where('cash_deposit.is_active', 1)
// ->get()
// ->getRow();
// // dd($this->db->getLastQuery());
// return $data;
// }
public function getDepositSummary($clientId, $insurerId, $cd_ac_pk)
{
if (empty($clientId)) {
return null;
}
// Build SAFE client condition (NO BINDS!)
if (is_string($clientId) && preg_match('/^[a-f0-9]{32}$/i', $clientId)) {
$clientCondition = 'MD5(client_id) = ' . $this->db->escape($clientId);
} else {
$clientCondition = 'client_id = ' . $this->db->escape($clientId);
}
/* -------------------------------------------------
Subquery: latest balance
------------------------------------------------- */
$subQuery = $this->db->table('cash_deposit')
->select('balance')
->where('client_id', $clientId)
->where($clientCondition, null, false)
->where('insurer_id', $insurerId)
->where('cd_ac_pk', $cd_ac_pk)
->where('is_active', 1)
@ -313,14 +398,15 @@ class ClientPolicyModel extends Model
->limit(1)
->getCompiledSelect();
// Fetch the sum of credit and debit transactions and calculate the balance
/* -------------------------------------------------
Main query: totals
------------------------------------------------- */
$data = $this->db->table('cash_deposit')
->select("($subQuery) AS balance", false)
->select('SUM(CASE WHEN transaction_type = "Credit" THEN amount ELSE 0 END) AS total_credit')
->select('SUM(CASE WHEN transaction_type = "Debit" THEN amount ELSE 0 END) AS total_withdraw')
// ->select('SUM(CASE WHEN transaction_type = "Credit" THEN amount ELSE -amount END) AS balance')
->select('SUM(CASE WHEN sub_type = 3 THEN amount ELSE 0 END) AS total_refund')
->where('client_id', $clientId)
->where($clientCondition, null, false)
->where('insurer_id', $insurerId)
->where('cd_ac_pk', $cd_ac_pk)
->where('cash_deposit.is_active', 1)
@ -330,6 +416,8 @@ class ClientPolicyModel extends Model
// dd($this->db->getLastQuery());
return $data;
}
// Inside your clientPolicyModel
// Inside your clientPolicyModel
// public function getDepositDataWithBalance($clientId, $insurerId)
@ -402,6 +490,35 @@ class ClientPolicyModel extends Model
// ORDER BY cd.id DESC
// ";
// $sql = "
// SELECT cd.insurer_id, cd.cd_ac_pk, cd.balance
// FROM cash_deposit cd
// JOIN cd_master cdm ON cdm.id = cd.cd_ac_pk
// JOIN (
// SELECT MAX(id) AS max_id
// FROM cash_deposit
// WHERE is_active = 1 AND client_id = :id:
// GROUP BY insurer_id, cd_ac_pk
// ) latest ON latest.max_id = cd.id
// JOIN insurers on cd.insurer_id = insurers.id
// WHERE cd.is_active = 1 AND cd.client_id = :id: AND cdm.is_active = 1
// ORDER BY cd.insurer_id;
// ";
// $binds = ['id'=>(int)$id];
// return $this->db->query($sql,$binds)->getResult();
$whereClient = 'cd.client_id = :id:';
$subWhereClient = 'client_id = :id:';
$binds = ['id' => $id];
// 🔐 MD5 handling
if (is_string($id) && preg_match('/^[a-f0-9]{32}$/i', $id)) {
$whereClient = 'MD5(cd.client_id) = :id:';
$subWhereClient = 'MD5(client_id) = :id:';
}
$sql = "
SELECT cd.insurer_id, cd.cd_ac_pk, cd.balance
FROM cash_deposit cd
@ -409,16 +526,17 @@ class ClientPolicyModel extends Model
JOIN (
SELECT MAX(id) AS max_id
FROM cash_deposit
WHERE is_active = 1 AND client_id = :id:
WHERE is_active = 1 AND {$subWhereClient}
GROUP BY insurer_id, cd_ac_pk
) latest ON latest.max_id = cd.id
JOIN insurers on cd.insurer_id = insurers.id
WHERE cd.is_active = 1 AND cd.client_id = :id: AND cdm.is_active = 1
ORDER BY cd.insurer_id;
JOIN insurers ON cd.insurer_id = insurers.id
WHERE cd.is_active = 1
AND {$whereClient}
AND cdm.is_active = 1
ORDER BY cd.insurer_id
";
$binds = ['id'=>(int)$id];
return $this->db->query($sql,$binds)->getResult();
return $this->db->query($sql, $binds)->getResult();
}

View File

@ -295,7 +295,10 @@ class EmployeePolicyModel extends Model
->orderBy('emp.emp_code', 'ASC')
->orderBy('employee_polices.employee_id', 'ASC');
// Conditionally add where clauses
if ($client_id != 0 && !empty($client_id)) {
if (is_string($client_id) && preg_match('/^[a-f0-9]{32}$/i', $client_id)) {
// MD5 hash → compare using md5()
$result->where('md5(emp.client_id)', $client_id);
}else if ($client_id != 0 && !empty($client_id)) {
$result->where('emp.client_id', $client_id);
}
if ($branch_id != 0 && !empty($branch_id)) {

View File

@ -37,27 +37,67 @@ class InsurerModel extends Model
->getResult();
}
// public function getInsurerName($insurerId, $client_id)
// {
// // Fetch the insurer name based on the insurer ID
// $query = $this->db->table('client_policy')
// ->select('insurers.id, insurers.name, cd_master.cd_ac_no as cd_master_account_no')
// ->join('insurers', 'insurers.id = client_policy.insurer_id')
// ->join('cd_master', 'cd_master.insurer_id = insurers.id AND cd_master.client_id = client_policy.client_id')
// ->where('client_policy.insurer_id', $insurerId)
// ->where('client_policy.client_id', $client_id)
// ->where('cd_master.id = client_policy.cd_ac_pk')
// ->where('cd_master.is_active', 1)
// ->get();
// if ($query->resultID->num_rows > 0) {
// $result = $query->getRow();
// return $result;
// }
// return null; // or handle accordingly if the insurer is not found
// }
public function getInsurerName($insurerId, $client_id)
{
// Fetch the insurer name based on the insurer ID
$query = $this->db->table('client_policy')
->select('insurers.id, insurers.name, cd_master.cd_ac_no as cd_master_account_no')
->join('insurers', 'insurers.id = client_policy.insurer_id')
->join('cd_master', 'cd_master.insurer_id = insurers.id AND cd_master.client_id = client_policy.client_id')
->where('client_policy.insurer_id', $insurerId)
->where('client_policy.client_id', $client_id)
->where('cd_master.id = client_policy.cd_ac_pk')
->where('cd_master.is_active', 1)
->get();
$builder = $this->db->table('client_policy')
->select('
insurers.id,
insurers.name,
cd_master.cd_ac_no AS cd_master_account_no
')
->join('insurers', 'insurers.id = client_policy.insurer_id')
->join(
'cd_master',
'cd_master.insurer_id = insurers.id
AND cd_master.client_id = client_policy.client_id
AND cd_master.id = client_policy.cd_ac_pk
AND cd_master.is_active = 1'
)
->where('client_policy.insurer_id', $insurerId);
if ($query->resultID->num_rows > 0) {
$result = $query->getRow();
return $result;
// Handle raw client_id vs MD5
if (!empty($client_id)) {
if (is_string($client_id) && preg_match('/^[a-f0-9]{32}$/i', $client_id)) {
$builder->where('MD5(client_policy.client_id)', $client_id);
} else {
$builder->where('client_policy.client_id', $client_id);
}
}
return null; // or handle accordingly if the insurer is not found
$result = $builder
->groupBy([
'insurers.id',
'cd_master.cd_ac_no'
])
->limit(1)
->get()
->getRow();
return $result ?? null;
}
public function getInsurerTemplateByInsurerID($insurer_id)
{
$insurer_data = $this->db->table('insurer_excel_export_template')

View File

@ -2569,8 +2569,10 @@
pt.action_type as action_type_string,
c.client_name,
c.id as client_id,
c.short_name AS client_short_name,
cb.branch_name AS client_branch_name,
cb.id AS client_branch_id,
cb.address1 AS client_address,
ptype.policy_type,
ptype.bap,
@ -2578,6 +2580,7 @@
ins.name AS insurer_name,
ins.short_name AS insurer_short_name,
ib.branch_name AS insurer_branch_name,
ib.id AS insurer_branch_id,
ib.branch_code AS insurer_branch_code,
created_user.first_name AS user_name,
@ -2735,8 +2738,10 @@
pt.action_type as action_type_string,
c.client_name,
c.id as client_id,
c.short_name AS client_short_name,
cb.branch_name AS client_branch_name,
cb.id AS client_branch_id,
cb.address1 AS client_address,
ptype.policy_type,
ptype.bap,
@ -2744,6 +2749,7 @@
ins.name AS insurer_name,
ins.short_name AS insurer_short_name,
ib.branch_name AS insurer_branch_name,
ib.id AS insurer_branch_id,
ib.branch_code AS insurer_branch_code,
created_user.first_name as user_name,
@ -3003,13 +3009,14 @@
public function getBDSReportList($start_date = 0, $end_date = 0, $client_id = 0, $insurer_id = 0, $policy_type_id = 0, $date_type = 0, $issuer = 0, $client_branch_id = 0, $insurer_branch_id = 0, $client_policy_id = 0, $user_id = 0, $where = [])
{
$whereAdded = false;
$statement_month_condition = '';
if ($date_type == 'statement_month' && $start_date != 0 && $end_date != 0) {
$statement_month_condition = "
WHERE statement_month >= '" . $start_date . "'
AND statement_month <= '" . $end_date . "'
";
$whereAdded = true;
}
$default_date_filter = '';
@ -3072,7 +3079,7 @@
}
if ($insurer_id != 0) {
$conditions .= " AND pt.insurer_id = $insurer_id ";
$conditions .= " AND pcsd.insurer_id = $insurer_id ";
}
if ($client_branch_id != 0) {
@ -3080,7 +3087,7 @@
}
if ($insurer_branch_id != 0) {
$conditions .= " AND pt.insurer_branch_id = $insurer_branch_id ";
$conditions .= " AND pcsd.insurer_branch_id = $insurer_branch_id ";
}
if ($client_policy_id != 0) {
@ -3099,6 +3106,33 @@
$conditions .= " AND pt.issuer = $issuer ";
}
$main_conditions = '';
function addCondition(&$main_conditions, &$whereAdded, $condition)
{
if (!$whereAdded) {
$main_conditions .= " WHERE $condition ";
$whereAdded = true;
} else {
$main_conditions .= " AND $condition ";
}
}
// 4. Common filters
if ($client_id != 0) {
addCondition($main_conditions, $whereAdded, "client_id = $client_id");
}
if ($insurer_id != 0) {
addCondition($main_conditions, $whereAdded, "insurer_id = $insurer_id");
}
if ($client_branch_id != 0) {
addCondition($main_conditions, $whereAdded, "client_branch_id = $client_branch_id");
}
if ($insurer_branch_id != 0) {
addCondition($main_conditions, $whereAdded, "insurer_branch_id = $insurer_branch_id");
}
$sql = "
SELECT * FROM (
@ -3138,8 +3172,10 @@
pt.action_type as action_type_string,
c.client_name,
c.id as client_id,
c.short_name AS client_short_name,
cb.branch_name AS client_branch_name,
cb.id AS client_branch_id,
cb.address1 AS client_address,
ptype.policy_type,
ptype.bap,
@ -3147,6 +3183,7 @@
ins.name AS insurer_name,
ins.short_name AS insurer_short_name,
ib.branch_name AS insurer_branch_name,
ib.id AS insurer_branch_id,
ib.branch_code AS insurer_branch_code,
created_user.first_name AS user_name,
@ -3295,8 +3332,10 @@
pt.action_type as action_type_string,
c.client_name,
c.id as client_id,
c.short_name AS client_short_name,
cb.branch_name AS client_branch_name,
cb.id AS client_branch_id,
cb.address1 AS client_address,
ptype.policy_type,
ptype.bap,
@ -3304,6 +3343,7 @@
ins.name AS insurer_name,
ins.short_name AS insurer_short_name,
ib.branch_name AS insurer_branch_name,
ib.id AS insurer_branch_id,
ib.branch_code AS insurer_branch_code,
created_user.first_name as user_name,
@ -3480,8 +3520,10 @@
pt.action_type as action_type_string,
c.client_name,
c.id as client_id,
c.short_name AS client_short_name,
cb.branch_name AS client_branch_name,
cb.id AS client_branch_id,
cb.address1 AS client_address,
ptype.policy_type,
ptype.bap,
@ -3489,6 +3531,7 @@
ins.name AS insurer_name,
ins.short_name AS insurer_short_name,
ib.branch_name AS insurer_branch_name,
ib.id AS insurer_branch_id,
ib.branch_code AS insurer_branch_code,
created_user.first_name as user_name,
@ -3617,6 +3660,7 @@
) AS final_result
$statement_month_condition
$main_conditions
-- GROUP BY statement_month, insurer_name, policy_no
-- WHERE id = 6143
@ -3632,7 +3676,7 @@
$result = $query->getResultArray();
// $countofalldata = count($result);
// dd($result);
// dd($this->db->getLastQuery());
dd($this->db->getLastQuery()->getQuery());
$keys = [];
$filtered = [];

View File

@ -684,7 +684,7 @@ table.dataTable tbody td {
<div class="form-group col-md-5">
<label for="incentive_file_name">Upload File</label>
<div class="input-icon">
<input type="file" class="form-control" name="incentive_file_name" id="incentive_file_name" required>
<input type="file" class="form-control" name="incentive_file_name" id="incentive_file_name" required accept=".jpg,.jpeg,.png">
<i class="mdi mdi-upload additional-icon"></i>
</div>
</div>
@ -1134,6 +1134,16 @@ table.dataTable tbody td {
console.error("Response Headers:", xhr.getAllResponseHeaders());
console.error("Error Thrown:", error);
console.error("Status:", status);
if (xhr.status === 400) {
let response = JSON.parse(xhr.responseText);
if (response.errors) {
$.each(response.errors, function (field, message) {
toastr.warning(message, 'Validation Error');
});
} else {
toastr.warning(response.message || 'Validation failed', 'Warning');
}
}else{toastr.error('Server error occurred.', 'Error');}
}
});
@ -1333,7 +1343,16 @@ table.dataTable tbody td {
},
error: function(xhr) {
console.log("Error: " + xhr.statusText);
toastr.error('Server error occurred.', 'Error');
if (xhr.status === 400) {
let response = JSON.parse(xhr.responseText);
if (response.errors) {
$.each(response.errors, function (field, message) {
toastr.warning(message, 'Validation Error');
});
} else {
toastr.warning(response.message || 'Validation failed', 'Warning');
}
}else{toastr.error('Server error occurred.', 'Error');}
},
complete: function() {
btn.disabled = false;
@ -1395,6 +1414,16 @@ table.dataTable tbody td {
error: function(xhr) {
console.log("Error: " + xhr.statusText);
toastr.error('Server error occurred.', 'Error');
if (xhr.status === 400) {
let response = JSON.parse(xhr.responseText);
if (response.errors) {
$.each(response.errors, function (field, message) {
toastr.warning(message, 'Validation Error');
});
} else {
toastr.warning(response.message || 'Validation failed', 'Warning');
}
}else{toastr.error('Server error occurred.', 'Error');}
},
complete: function() {
btn.disabled = false;

View File

@ -56,7 +56,7 @@ table.dataTable thead th {
<td class="client_info" ><?php echo $row['status']; ?></td>
<td>
<div class="btn-group dropdown">
<a href="javascript: void(0);" class="dropdown-toggle arrow-none btn btn-light btn-sm" data-toggle="dropdown"aria-expanded="false"><i class="mdi mdi-dots-horizontal"></i></a>
<a href="javascript: void(0);" class="dropdown-toggle arrow-none btn btn-light btn-sm" data-toggle="dropdown" aria-expanded="false"><i class="mdi mdi-dots-horizontal"></i></a>
<div class="dropdown-menu dropdown-menu-right">
<a class="dropdown-item advertise_image_edit" href="#" data-toggle="modal" data-wholearray='<?php echo json_encode($row, JSON_HEX_APOS); ?>' data-target="#bike_make_login-modal"><i class="mdi mdi-pencil mr-2 text-muted font-18 vertical-middle"></i>Edit</a>
<?php if($row['client_id'] != 0) { ?> <a class="dropdown-item" onclick="remove_advertise_image('<?= $row['id'];?>')"><i class="mdi mdi-delete mr-2 text-muted font-18 vertical-middle"></i>Delete</a> <?php } ?>
@ -126,7 +126,7 @@ table.dataTable thead th {
<div class="form-group">
<label for="branchname">Upload Image</label>
<div class="input-icon">
<input type="file" class="form-control" name="advertise_image" id="advertise_image" accept="image/*" onchange="PreviewImage();" required>
<input type="file" class="form-control" name="advertise_image" id="advertise_image" accept=".jpg,.jpeg,.png" onchange="PreviewImage();" required>
<i class="mdi mdi-upload additional-icon"></i>
</div>
</div>
@ -227,7 +227,15 @@ table.dataTable thead th {
switch (xhr.status) {
case 400:
msg = xhr.responseJSON?.message || 'Bad Request — Invalid input.';
let response = xhr.responseJSON || JSON.parse(xhr.responseText);
if (response.errors) {
$.each(response.errors, function (field, message) {
toastr.warning(message, 'Validation Error');
});
} else {
toastr.warning(response.message || 'Validation failed', 'Warning');
}
msg = response.message || 'Bad Request — Invalid input.';
break;
case 401:
msg = 'Unauthorized — Please log in again.';

View File

@ -197,6 +197,14 @@
// Handle error response
console.error('Upload failed:', error);
console.error('Upload failed:', error);
if (xhr.status === 400) {
var response = JSON.parse(xhr.responseText);
toastr.warning(response.message || 'Validation failed', 'Warning');
}
if (xhr.status === 500) {
var response = JSON.parse(xhr.responseText);
toastr.warning(response.message || 'Validation failed', 'Warning');
}
},
complete: function() {
// Reset button state

View File

@ -204,6 +204,16 @@
console.error(status, error);
$('.loader').fadeOut();
$('.loader-mask').delay(350).fadeOut('slow');
if (xhr.status === 400) {
let response = JSON.parse(xhr.responseText);
if (response.errors) {
$.each(response.errors, function (field, message) {
toastr.warning(message, 'Validation Error');
});
} else {
toastr.warning(response.message || 'Validation failed', 'Warning');
}
}
toastr.error('An error occurred while adding the CD account number.', 'ERROR');
}
});
@ -279,7 +289,6 @@
$('#opening_date').val('');
$('#cd_ac_no_for_cd_master').val('');
$('#opening_bal').val('');
// $('#CDMasterForm').attr('action', '<?php echo base_url('master/cash_deposite/create');?>');
$('#title').html('Add Opening Amount');
$('#cd_master_btn_Submit').html('Submit');

View File

@ -98,7 +98,7 @@ table.dataTable thead th {
<td><?php echo date('d-M-Y h:i A', strtotime($row['created_at'])) ?> <br>by <?php echo $row['user_name']; ?></td>
<td>
<div class="btn-group dropdown">
<a href="javascript: void(0);"class="dropdown-toggle arrow-none btn btn-light btn-sm" data-toggle="dropdown"aria-expanded="false"><i class="mdi mdi-dots-horizontal"></i></a>
<a href="javascript: void(0);"class="dropdown-toggle arrow-none btn btn-light btn-sm" data-toggle="dropdown" aria-expanded="false"><i class="mdi mdi-dots-horizontal"></i></a>
<div class="dropdown-menu dropdown-menu-right">
<a class="dropdown-item btnEdit" data-id="<?= $row['id'];?>" data-toggle="modal" data-target="#con-close-modal"> <i class="mdi mdi-pencil mr-2 text-muted font-18 vertical-middle"></i>Edit</a>
<?php if($row['cd_ac_no_count'] == 0) { ?>

View File

@ -22,6 +22,8 @@
}
.dataTables_length label {height: 21px !important;}
.readonly-select { background-color: #f3f3f3 !important; cursor: not-allowed; pointer-events: none; }
</style>
<!-- <div class="row">
@ -155,10 +157,35 @@
<div class="modal-body">
<form class="parsley-examples" id="claim-upload-form" enctype="multipart/form-data">
<div class="form-group">
<div class="form-row">
<div class="form-group col-md-12">
<label>Client<span id="tpa_danger" class="text-danger"></span></label>
<select name="client_id" class="form-control" id="client_id">
<option value="">Select</option>
</select>
</div>
<div class="form-group col-md-12">
<label>Policy <span id="tpa_danger" class="text-danger"></span></label>
<select name="client_policy_id" class="form-control" id="client_policy_id">
<option value="">Select</option>
</select>
</div>
<div class="form-group col-md-12">
<label for="tpa">TPA<span id="tpa_danger" class="text-danger"></span></label>
<select class="form-control readonly-select" id="tpa_id" name="tpa_id">
<option value="">Select TPA</option>
<?php foreach ($tpa_list as $value) { ?>
<option value="<?= $value['id'] ?>"><?= $value['short_name'] ?></option>
<?php } ?>
</select>
</div>
</div>
<div class="form-row" id="file_upload">
<div class="form-group col-md-9">
<label>Upload file</label>
<!-- &nbsp;[ <a href="#" id="excel_download" data-toggle="tooltip" data-placement="top" title="Download Sample Excel">Sample Excel</a> ] -->
&nbsp;[ <a href="#" id="excel_download" data-toggle="tooltip" data-placement="top" title="Download Sample Excel">Sample Excel</a> ]
<input type="file" name="claim_dump_list" id="claim_dump_list" accept=" application/vnd.openxmlformats-officedocument.spreadsheetml.sheet, application/vnd.ms-excel,application/vnd.oasis.opendocument.spreadsheet" required>
</div>
<div class="form-group col-md-3" style="margin-top: 40px;">
@ -172,14 +199,47 @@
</div><!-- /.modal-dialog -->
</div><!-- /.modal -->
<div id="full-width-modal-emp-list" class="modal fade" tabindex="-1" role="dialog" aria-labelledby="fullWidthModalLabel"
aria-hidden="true">
<div class="modal-dialog modal-full-width">
<div class="modal-content">
<div class="modal-header">
<h4 class="modal-title" id="fullWidthModalLabel">View Uploaded File<span
id="title_header_name"></span></h4>
<button type="button" class="close" data-dismiss="modal" aria-hidden="true">×</button>
</div>
<div class="modal-body" id="emp_data_success">
</div>
</div><!-- /.modal-content -->
</div><!-- /.modal-dialog -->
</div><!-- /.modal -->
<script>
let policyListByClient = null;
let client_list = null;
$(document).ready(function() {
getClientAndBranchAndPolicy();
$('#client_id').select2();
$('#client_policy_id').select2();
// AJAX Form Submit Function
$('#claim-upload-form').on('submit', function(e) {
e.preventDefault(); // Prevent default form submission
let client_id = $('#client_id').val() ?? null;
let client_policy_id = $('#client_policy_id').val() ?? null;
if(client_id){
if(!client_policy_id){
toastr.warning('Please select the client policy', 'WARNING');
return;
}
}
// Get form data
var formData = new FormData(this);
var fileInput = $('#claim_dump_list')[0];
@ -275,6 +335,28 @@
}
})
$('#client_id').on('change', function(){
let client_id = $(this).val();
if(policyListByClient != '') {
console.log(policyListByClient[client_id]);
let data = policyListByClient[client_id];
appendPolicies(data);
}
})
$('#client_policy_id').on('change', function(){
let tpa_id = $(this).find(':selected').data('tpaid');
console.log('tpa_id', tpa_id);
if(tpa_id){
$('#tpa_id').val(tpa_id);
}else{
$('#tpa_id').val('');
}
})
});
// Datatable document ready
@ -390,6 +472,7 @@
}
}
if (err_id != 5 && err_id != 6 && err_id != 0) {
file_error_html += (file_error_html != "" ?
"<a href ='<?php echo base_url('util/claim_dump_excel_error/') ?>" + file_id +
@ -428,5 +511,139 @@
var myModal = new bootstrap.Modal(document.getElementById('claim-file-upload-modal'));
myModal.show();
}
function getClientAndBranchAndPolicy() {
$.ajax({
url: '<?= base_url("/util/getClientAndBranchAndPolicy") ?>',
type: "GET",
dataType: 'json',
success: function(res) {
console.log('getClientAndBranchAndPolicy', res);
if (res.status == true) {
policyListByClient = res.policyListByClient;
client_list = res.client_data;
appendClients(res.client_data);
} else {
console.log('No data found');
}
},
error: function(xhr, status, error) {
console.error(xhr.responseText);
console.error(status, error);
}
});
}
function appendClients(data) {
$('#client_id').empty();
$('#client_id').append($('<option>', {
value: '',
text: 'Select Client'
}));
$.each(data, function(index, item) {
if (item.client_policy_count > 0) {
var option = $('<option>', {
value: item.id,
text: item.client_name
});
$('#client_id').append(option);
}
});
}
function appendPolicies(data) {
$('#client_policy_id').empty();
$('#client_policy_id').append($('<option>', {
value: '',
text: 'Select Policy',
}));
$.each(data, function(index, item) {
var option = $('<option>', {
value: item.id,
text: item.policy_type + '-' + item.policy_no,
'data-tpaid': item.tpa_id,
});
$('#client_policy_id').append(option);
});
}
$('body').on('click', '.view_emp_list', function() {
$('#emp_data_success').empty();
var file_id = $(this).attr('data-id');
console.log(file_id);
var queryParams = {
file_id: file_id,
};
console.log('queryParams', queryParams)
const queryString = objectToQueryString(queryParams);
console.log('queryString', queryString)
$('.loader').fadeIn();
$('.loader-mask').fadeIn();
var uri = '<?= base_url('util/view-success-emp-list') ?>?' + queryString
console.log(uri)
$.ajax({
url: uri,
data: {
file_id: file_id,
},
type: "GET",
dataType: 'json',
processData: false,
contentType: false,
success: function(res) {
console.log(res);
if (res) {
setTimeout(function() {
$('.loader').fadeOut();
$('.loader-mask').delay(350).fadeOut('slow');
}, 1000);
}
var title = " - ";
if (res.file_data) {
title += (res.file_data.file_name || "") + " - ";
title += (res.file_data.short_name || "") + " - ";
title += (res.file_data.policy_name || "") + " - ";
title += (res.file_data.action || "") + " - ";
title += (res.file_data.status || "");
}
$('#title_header_name').html(title);
$('#emp_data_success').html(res.data);
},
error: function(xhr, status, error) {
console.error(xhr.responseText);
console.error(status, error);
setTimeout(function() {
$('.loader').fadeOut();
$('.loader-mask').delay(350).fadeOut('slow');
toastr.warning('Something went wrong', 'Warning');
}, 1000);
}
});
})
</script>

View File

@ -236,6 +236,14 @@
// Handle error response
console.error('Upload failed:', error);
console.error('Upload failed:', error);
if (xhr.status === 400) {
var response = JSON.parse(xhr.responseText);
toastr.warning(response.message || 'Validation failed', 'Warning');
}
if (xhr.status === 500) {
var response = JSON.parse(xhr.responseText);
toastr.warning(response.message || 'Validation failed', 'Warning');
}
},
complete: function() {
// Reset button state

View File

@ -81,7 +81,7 @@ input:checked + .slider:before {
style="border-radius:25px; border:1px solid #00999E;padding:10px;color:#00999E;"
alt="avatar"/>
<span style="margin-bottom:5px;">
<input type="file" name="client_logo" id="client_logo" accept="image/*" onchange="PreviewImage();"><br>
<input type="file" name="client_logo" id="client_logo" accept=".jpg,.jpeg,.png" onchange="PreviewImage();"><br>
<i class="text">( Image dimensions 100 x 100 pixels and size of 200KB. )</i>
</span>
<br>
@ -324,7 +324,7 @@ input:checked + .slider:before {
$.each(res.data, function (index, item) {
var row = `<tr>
<td> ${item.file_name}</td>
<td id="form_${item.id}" style=""><form class="ajax" ><input class="file-input__input" type="file" name="file_name">
<td id="form_${item.id}" style=""><form class="ajax" ><input class="file-input__input" type="file" name="file_name" accept=".jpg,.jpeg,.png">
<input type="hidden" class="form-control" value="<?= csrf_hash() ?>" name="<?= csrf_token() ?>" />
<input type="hidden" class="form-control" value="${item.id}" name="kyc_doc_type_id" />
<input type="hidden" name="client_id" id="id_for_kyc_file" value="${client_id_for_file}"/>
@ -349,7 +349,16 @@ input:checked + .slider:before {
$('.loader').fadeOut();
$('.loader-mask').delay(350).fadeOut('slow');
$submitButton.prop('disabled', false);
if (xhr.status === 404) {
if (xhr.status === 400) {
let response = JSON.parse(xhr.responseText);
if (response.errors) {
$.each(response.errors, function (field, message) {
toastr.warning(message, 'Validation Error');
});
} else {
toastr.warning(response.message || 'Validation failed', 'Warning');
}
} else if (xhr.status === 404) {
toastr.warning('Resource not found', 'Warning');
} else if (xhr.status === 500) {
toastr.warning('Internal server error', 'Warning');

View File

@ -281,7 +281,7 @@ $(document).ready(function() {
</tr>
`;
}
});
$('#branch_list').append(branchTable);
}

View File

@ -304,7 +304,8 @@
<td>${item.file_name}</td>
<td id="form_${item.id}">
<form class="ajax">
<input class="file-input__input" type="file" name="file_name">
<input class="file-input__input" type="file" name="file_name"
accept=".pdf,.jpg,.jpeg,.png">
<input type="hidden" class="form-control" value="<?= csrf_hash() ?>" name="<?= csrf_token() ?>">
<input type="hidden" class="form-control" value="${item.id}" name="kyc_doc_type_id">
<input type="hidden" name="client_id" value="${client_id}">

View File

@ -36,6 +36,7 @@
<div class="form-group col-md-3 file-input-group">
<label for="file_input">Browser File<span class="text-danger">*</span></label>
<input type="file" class="form-control file-input" id="kyc_docs_file" name="file_name" required
accept=".pdf,.jpg,.jpeg,.png"
style="box-shadow: none !important; outline: none !important; border: none; height: unset !important;padding: 0px !important;background: transparent !important;">
</div>

View File

@ -4,7 +4,7 @@
<!-- <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></a></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>
</tr>
<?php endforeach; ?>
<?php else: ?>

View File

@ -7,7 +7,7 @@
<?php if(empty($item['upload_doc_name'])) { ?>
<td id="form_<?= esc($item['id']); ?>">
<form class="ajax" enctype="multipart/form-data" method="post">
<input class="file-input__input" type="file" name="file_name">
<input class="file-input__input" type="file" name="file_name" accept=".pdf,.jpg,.jpeg,.png">
<input type="hidden" class="form-control" value="<?= csrf_hash() ?>" name="<?= csrf_token() ?>">
<input type="hidden" class="form-control" value="<?= esc($item['id']); ?>" name="kyc_doc_type_id">
<input type="hidden" name="client_id" value="<?= esc($client_id); ?>">

View File

@ -48,6 +48,7 @@
name="file_name"
id="kyc_docs_file_<?= $value['id'] ?>"
class="form-control edit-file-input"
accept=".pdf,.jpg,.jpeg,.png"
style="box-shadow:none!important; outline:none!important; border:none; height:unset!important;padding: 0px !important;background: transparent !important;">
</div>

View File

@ -115,7 +115,7 @@ table.dataTable thead th {
</td>
<td>
<div class="btn-group dropdown">
<a href="javascript: void(0);" class="dropdown-toggle arrow-none btn btn-light btn-sm" data-toggle="dropdown"aria-expanded="false"><i class="mdi mdi-dots-horizontal"></i></a>
<a href="javascript: void(0);" class="dropdown-toggle arrow-none btn btn-light btn-sm" data-toggle="dropdown" aria-expanded="false"><i class="mdi mdi-dots-horizontal"></i></a>
<div class="dropdown-menu dropdown-menu-right">
<a class="dropdown-item" href="<?= base_url("client/list/"); ?><?= $row->id;?>"><i class="mdi mdi-pencil mr-2 text-muted font-18 vertical-middle"></i>Edit</a>
<a class="dropdown-item" href="<?= base_url("client/deposit/{$row->id}"); ?>"><i class="mdi mdi-cash mr-2 text-muted font-18 vertical-middle"></i>CD Transactions</a>
@ -645,7 +645,11 @@ function featchClient(){
$('.loader-mask').delay(350).fadeOut('slow');
if(res.status == true){
let client_url = '<?= base_url('client/list/') ?>' + res.client_id + '?client_policy_id=' + res.client_policy_id+'#police-tab';
let client_url = '<?= base_url('client/list/') ?>'
+ res.client_id
+ '?cd_amt=' + (res.cd_amount ?? 0)
+ '&client_policy_id=' + res.client_policy_id
+ '#police-tab';
toastr.success(res.message, 'SUCCESS')
window.location.href = client_url
}else{

View File

@ -525,9 +525,9 @@ input:checked + .slider_blue::before {
<td>${checkDateStatus(item.policy_end_date, 1)}</td>
<td>
<div class="btn-group dropdown">
<a href="javascript: void(0);" class="dropdown-toggle arrow-none btn btn-light btn-sm" data-toggle="dropdown"aria-expanded="false"><i class="mdi mdi-dots-horizontal"></i></a>
<a href="javascript: void(0);" class="dropdown-toggle arrow-none btn btn-light btn-sm" data-toggle="dropdown" aria-expanded="false"><i class="mdi mdi-dots-horizontal"></i></a>
<div class="dropdown-menu dropdown-menu-right">
<a href="#" data-id="${item.id}" id="${item.policy_id}" class="dropdown-item btnPolicyEdit"><i class="mdi mdi-lead-pencil mr-2 text-muted font-18 vertical-middle"></i>Edit</a>
<a href="#" data-id="${item.id}" id="${item.policy_id}" data-cdamt="${item.lead_cd_amount}" class="dropdown-item btnPolicyEdit"><i class="mdi mdi-lead-pencil mr-2 text-muted font-18 vertical-middle"></i>Edit</a>
<a href="#" data-id="${item.id}" id="${search_term}" data-typeid="${item.policy_type_id}" class="dropdown-item btnPolicyMaster" ><i class="mdi mdi-wrench mr-2 text-muted font-18 vertical-middle"></i>Terms</a>
<a href="#" data-id="${item.id}" id="${search_term}" data-typeid="${item.policy_type_id}" class="dropdown-item btnPolicyModel" data-toggle="modal" data-target="#bs-example-modal-lg"><i class="mdi mdi-book-open mr-2 text-muted font-18 vertical-middle"></i>Rack Rate</a>`;
@ -792,9 +792,9 @@ input:checked + .slider_blue::before {
<td>${checkDateStatus(item.policy_end_date, 1)}</td>
<td>
<div class="btn-group dropdown">
<a href="javascript: void(0);" class="dropdown-toggle arrow-none btn btn-light btn-sm" data-toggle="dropdown"aria-expanded="false"><i class="mdi mdi-dots-horizontal"></i></a>
<a href="javascript: void(0);" class="dropdown-toggle arrow-none btn btn-light btn-sm" data-toggle="dropdown" aria-expanded="false"><i class="mdi mdi-dots-horizontal"></i></a>
<div class="dropdown-menu dropdown-menu-right">
<a href="#" data-id="${item.id}" id="${item.policy_id}" class="dropdown-item btnPolicyEdit"><i class="mdi mdi-lead-pencil mr-2 text-muted font-18 vertical-middle"></i>Edit</a>
<a href="#" data-id="${item.id}" id="${item.policy_id}" data-cdamt="${item.lead_cd_amount}" class="dropdown-item btnPolicyEdit"><i class="mdi mdi-lead-pencil mr-2 text-muted font-18 vertical-middle"></i>Edit</a>
<a href="#" data-id="${item.id}" id="${search_term}" data-typeid="${item.policy_type_id}" class="dropdown-item btnPolicyMaster" ><i class="mdi mdi-wrench mr-2 text-muted font-18 vertical-middle"></i>Terms</a>
<a href="#" data-id="${item.id}" id="${search_term}" data-typeid="${item.policy_type_id}" class="dropdown-item btnPolicyModel" data-toggle="modal" data-target="#bs-example-modal-lg"><i class="mdi mdi-book-open mr-2 text-muted font-18 vertical-middle"></i>Rack Rate</a>`;
@ -825,6 +825,13 @@ input:checked + .slider_blue::before {
$('#open_date').val('');
$('#close_date').val('');
$('#policy').html('<option value="" selected>Select Policy</option>');
const urlParams = new URLSearchParams(window.location.search);
const clientPolicyId = urlParams.get('client_policy_id');
if (clientPolicyId) {
let client_url = '<?= base_url('client/list/') ?>' + res.client_id ;
window.location.href = client_url
}
},
error: function(xhr, status, error) {
console.error(xhr.responseText);
@ -832,7 +839,16 @@ input:checked + .slider_blue::before {
setTimeout(function() {
$('.loader').fadeOut();
$('.loader-mask').delay(350).fadeOut('slow');
if (xhr.status === 404) {
if (xhr.status === 400) {
let response = JSON.parse(xhr.responseText);
if (response.errors) {
$.each(response.errors, function (field, message) {
toastr.warning(message, 'Validation Error');
});
} else {
toastr.warning(response.message || 'Validation failed', 'Warning');
}
} else if (xhr.status === 404) {
//console.log('Resource not found', 'Warning');
} else if (xhr.status === 500) {
//console.log('Internal server error', 'Warning');
@ -842,6 +858,7 @@ input:checked + .slider_blue::before {
}, 1000);
},
complete :function(){
$('#opening_bal').val("")
console.log('AJAX request completed');
}
});
@ -926,6 +943,14 @@ input:checked + .slider_blue::before {
var policy_form_action = '';
var policy_id = $(this).attr('data-id');
var opening_bal = $(this).attr('data-cdamt') ?? "";
console.log('opening_bal', opening_bal)
console.log('opening_bal', $('#opening_bal'))
if(opening_bal != "null"){
$('#opening_bal').val(opening_bal);
}
$('.loader').fadeIn();
$('.loader-mask').fadeIn();
@ -2022,6 +2047,7 @@ input:checked + .slider_blue::before {
// Get the `client_policy_id` from the URL
const urlParams = new URLSearchParams(window.location.search);
const clientPolicyId = urlParams.get('client_policy_id');
const cd_amt = urlParams.get('cd_amt');
if (clientPolicyId) {
// Call your function with the `client_policy_id`
@ -2029,6 +2055,10 @@ input:checked + .slider_blue::before {
getClientPolicyDataForEdit(clientPolicyId);
}, 3000);
}
if(cd_amt){
$('#opening_bal').val(cd_amt);
}
}
});
@ -2487,9 +2517,9 @@ $(document).ready(function () {
<td>${checkDateStatus(item.policy_end_date, 1)}</td>
<td>
<div class="btn-group dropdown">
<a href="javascript: void(0);" class="dropdown-toggle arrow-none btn btn-light btn-sm" data-toggle="dropdown"aria-expanded="false"><i class="mdi mdi-dots-horizontal"></i></a>
<a href="javascript: void(0);" class="dropdown-toggle arrow-none btn btn-light btn-sm" data-toggle="dropdown" aria-expanded="false"><i class="mdi mdi-dots-horizontal"></i></a>
<div class="dropdown-menu dropdown-menu-right">
<a href="#" data-id="${item.id}" id="${item.policy_id}" class="dropdown-item btnPolicyEdit"><i class="mdi mdi-lead-pencil mr-2 text-muted font-18 vertical-middle"></i>Edit</a>
<a href="#" data-id="${item.id}" id="${item.policy_id}" data-cdamt="${item.lead_cd_amount}" class="dropdown-item btnPolicyEdit"><i class="mdi mdi-lead-pencil mr-2 text-muted font-18 vertical-middle"></i>Edit</a>
<a href="#" data-id="${item.id}" id="${search_term}" data-typeid="${item.policy_type_id}" class="dropdown-item btnPolicyMaster" ><i class="mdi mdi-wrench mr-2 text-muted font-18 vertical-middle"></i>Terms</a>
<a href="#" data-id="${item.id}" id="${search_term}" data-typeid="${item.policy_type_id}" class="dropdown-item btnPolicyModel" data-toggle="modal" data-target="#bs-example-modal-lg"><i class="mdi mdi-book-open mr-2 text-muted font-18 vertical-middle"></i>Rack Rate</a>`;
@ -2523,9 +2553,9 @@ $(document).ready(function () {
<td>${checkDateStatus(item.policy_end_date, 1)}</td>
<td>
<div class="btn-group dropdown">
<a href="javascript: void(0);" class="dropdown-toggle arrow-none btn btn-light btn-sm" data-toggle="dropdown"aria-expanded="false"><i class="mdi mdi-dots-horizontal"></i></a>
<a href="javascript: void(0);" class="dropdown-toggle arrow-none btn btn-light btn-sm" data-toggle="dropdown" aria-expanded="false"><i class="mdi mdi-dots-horizontal"></i></a>
<div class="dropdown-menu dropdown-menu-right">
<a href="#" data-id="${item.id}" id="${item.policy_id}" class="dropdown-item btnPolicyEdit"><i class="mdi mdi-lead-pencil mr-2 text-muted font-18 vertical-middle"></i>Edit</a>
<a href="#" data-id="${item.id}" id="${item.policy_id}" data-cdamt="${item.lead_cd_amount}" class="dropdown-item btnPolicyEdit"><i class="mdi mdi-lead-pencil mr-2 text-muted font-18 vertical-middle"></i>Edit</a>
<a href="#" data-id="${item.id}" id="${search_term}" data-typeid="${item.policy_type_id}" class="dropdown-item btnPolicyMaster" ><i class="mdi mdi-wrench mr-2 text-muted font-18 vertical-middle"></i>Terms</a>
<a href="#" data-id="${item.id}" id="${search_term}" data-typeid="${item.policy_type_id}" class="dropdown-item btnPolicyModel" data-toggle="modal" data-target="#bs-example-modal-lg"><i class="mdi mdi-book-open mr-2 text-muted font-18 vertical-middle"></i>Rack Rate</a>`;

View File

@ -183,7 +183,7 @@
<td><?php $gst_total += $employee['gst']; echo format_indian_number($employee['gst']); ?></td>
<td>
<div class="btn-group dropdown">
<a href="javascript: void(0);" class="dropdown-toggle arrow-none btn btn-light btn-sm" data-toggle="dropdown"aria-expanded="false"><i class="mdi mdi-dots-horizontal"></i></a>
<a href="javascript: void(0);" class="dropdown-toggle arrow-none btn btn-light btn-sm" data-toggle="dropdown" aria-expanded="false"><i class="mdi mdi-dots-horizontal"></i></a>
<div class="dropdown-menu dropdown-menu-right">
<?php
@ -548,8 +548,16 @@
console.error('Response Text: ', xhr.responseText);
}
toastr.warning('Error uploading file', 'WARNING');
console.error('Upload error:', error);
if (xhr.status === 400) {
let response = JSON.parse(xhr.responseText);
if (response.errors) {
$.each(response.errors, function (field, message) {
toastr.warning(message, 'Validation Error');
});
} else {
toastr.warning(response.message || 'Validation failed', 'Warning');
}
}else{ toastr.warning('Error uploading file', 'WARNING'); }
},
complete: function() {
$('.loader').fadeOut();

View File

@ -326,6 +326,18 @@
},
error: function () {
$('.loader, .loader-mask').fadeOut();
if (xhr.status === 400) {
let response = JSON.parse(xhr.responseText);
if (response.errors) {
$.each(response.errors, function (field, message) {
toastr.warning(message, 'Validation Error');
});
} else {
toastr.warning(response.message || 'Validation failed', 'Warning');
}
}else{
toastr.error("Something went wrong!", 'Error');
}
}
});
}

View File

@ -449,7 +449,18 @@
},
error: function () {
$('.loader, .loader-mask').fadeOut();
}
if (xhr.status === 400) {
let response = JSON.parse(xhr.responseText);
if (response.errors) {
$.each(response.errors, function (field, message) {
toastr.warning(message, 'Validation Error');
});
} else {
toastr.warning(response.message || 'Validation failed', 'Warning');
}
}else{
toastr.error("Something went wrong!", 'Error');
}}
});
}
@ -467,8 +478,13 @@
function appendEditData(data) {
$('#frontEndContentForm')[0].reset();
$('#fe_id').val(data.id);
$('#type').val(data.type);
$('#content_section').val(data.content_section);
if (/video/i.test(data.content_section)) {
$('#content_section').val('Video');
$('#type').val(8);
} else {
$('#type').val(data.type);
$('#content_section').val(data.content_section);
}
$('#heading').val(data.heading);
// $('#content').val(data.content);
// $('#notes').val(data.notes);
@ -522,6 +538,34 @@
return text.length === 0;
}
// $('#content_section').on('keyup blur change', function () {
// let val = $(this).val();
// if (/video/i.test(val)) {
// $(this).val('Video');
// $('#type').val(8);
// }
// });
$('#content_section').on('input blur', function () {
let $this = $(this);
let val = $this.val().trim();
// 1. Handle Empty Input
if (val === '') {
$('#type').val('');
return;
}
// 2. Check for "video" (case insensitive)
if (/video/i.test(val)) {
$('#type').val(8);
if (val !== 'Video') { $this.val('Video'); }
} else {
$('#type').val('');
}
});
</script>
<script>

View File

@ -254,6 +254,16 @@ input:checked + .slider:before {
$('.loader').fadeOut();
$('.loader-mask').delay(350).fadeOut('slow');
console.log('Something Wrong!', 'warning');
if (xhr.status === 400) {
let response = JSON.parse(xhr.responseText);
if (response.errors) {
$.each(response.errors, function (field, message) {
toastr.warning(message, 'Validation Error');
});
} else {
toastr.warning(response.message || 'Validation failed', 'Warning');
}
}
}
});
}

View File

@ -99,7 +99,7 @@
<td style="overflow: hidden;" class="truncate" ><?= $value['jsoncolumns']; ?></td>
<td>
<div class="btn-group dropdown">
<a href="javascript: void(0);" class="dropdown-toggle arrow-none btn btn-light btn-sm" data-toggle="dropdown"aria-expanded="false"><i class="mdi mdi-dots-horizontal"></i></a>
<a href="javascript: void(0);" class="dropdown-toggle arrow-none btn btn-light btn-sm" data-toggle="dropdown" aria-expanded="false"><i class="mdi mdi-dots-horizontal"></i></a>
<div class="dropdown-menu dropdown-menu-right">
<a class="dropdown-item" href="#" onclick="editJSONExportTemplate(this, '<?= $value['id']; ?>')"><i class="mdi mdi-pencil mr-2 text-muted font-18 vertical-middle"></i>Edit</a>
<a class="dropdown-item" id="template_id_for_duplicate" data-id="<?= $value['id']; ?>" data-toggle="modal" data-target="#centermodal"><i class="mdi mdi-content-duplicate mr-2 text-muted font-18 vertical-middle"></i>Duplicate</a>
@ -305,7 +305,7 @@
window.location.reload();
},
error: function(xhr, status, error) {
error: function (xhr, status, error) {
$('.loader').fadeOut();
$('.loader-mask').delay(350).fadeOut('slow');
@ -323,14 +323,37 @@
console.error('Response headers:', xhr.getAllResponseHeaders());
console.error('Response URL:', xhr.responseURL);
// Example of throwing a detailed error for further handling
throw new Error(`AJAX Request failed:
Status: ${status},
Error: ${error},
Status Code: ${xhr.status},
Status Text: ${xhr.statusText},
Response: ${xhr.responseText}
`);
// Handle validation errors (CI4)
if (xhr.status === 400) {
let response = null;
try {
response = JSON.parse(xhr.responseText);
} catch (e) {
toastr.error('Invalid server response', 'Error');
return;
}
if (response.errors) {
$.each(response.errors, function (field, message) {
toastr.warning(message, 'Validation Error');
});
} else {
toastr.warning(response.message || 'Validation failed', 'Warning');
}
return;
}
// Handle server errors
if (xhr.status >= 500) {
toastr.error('Server error. Please try again later.', 'Error');
return;
}
// Fallback
toastr.error('Unexpected error occurred.', 'Error');
},
complete: function() {
$('.loader').fadeOut();

View File

@ -254,6 +254,16 @@ $(document).ready(function () {
setTimeout(function() {
$('.loader').fadeOut();
$('.loader-mask').delay(350).fadeOut('slow');
if (xhr.status === 400) {
let response = JSON.parse(xhr.responseText);
if (response.errors) {
$.each(response.errors, function (field, message) {
toastr.warning(message, 'Validation Error');
});
} else {
toastr.warning(response.message || 'Validation failed', 'Warning');
}
}
toastr.warning('Something Wrong!', 'warning');
}, 1000);
}
@ -296,6 +306,16 @@ $(document).ready(function () {
setTimeout(function() {
$('.loader').fadeOut();
$('.loader-mask').delay(350).fadeOut('slow');
if (xhr.status === 400) {
let response = JSON.parse(xhr.responseText);
if (response.errors) {
$.each(response.errors, function (field, message) {
toastr.warning(message, 'Validation Error');
});
} else {
toastr.warning(response.message || 'Validation failed', 'Warning');
}
}
toastr.warning('Something Wrong!', 'warning');
}, 1000);
}

View File

@ -64,7 +64,7 @@
<td><?php echo $row['name']; ?> </td>
<td>
<div class="btn-group dropdown">
<a href="javascript: void(0);" class="dropdown-toggle arrow-none btn btn-light btn-sm" data-toggle="dropdown"aria-expanded="false"><i class="mdi mdi-dots-horizontal"></i></a>
<a href="javascript: void(0);" class="dropdown-toggle arrow-none btn btn-light btn-sm" data-toggle="dropdown" aria-expanded="false"><i class="mdi mdi-dots-horizontal"></i></a>
<div class="dropdown-menu dropdown-menu-right">
<a class="dropdown-item" href="<?= base_url("master/kyc/list/"); ?><?= $row['id'];?>"><i class="mdi mdi-pencil mr-2 text-muted font-18 vertical-middle"></i>Edit</a>
<a class="dropdown-item" data-id="<?= $row['id'];?>" onclick="removeKYC(this)"><i class="mdi mdi-delete mr-2 text-muted font-18 vertical-middle"></i>Delete</a>

View File

@ -66,87 +66,69 @@
<!-- /Right-bar -->
<!-- Right bar overlay-->
<!-- Right bar overlay -->
<div class="rightbar-overlay"></div>
<!-- Vendor js -->
<script src="<?= base_url() . "public"; ?>/assets/js/vendor.min.js"></script>
<!-- ============================= -->
<!-- Core Vendor JS (Local) -->
<!-- ============================= -->
<script src="<?= base_url("public/assets/js/vendor.min.js"); ?>"></script>
<!-- KNOB JS -->
<script src="<?= base_url() . "public"; ?>/assets/libs/jquery-knob/jquery.knob.min.js"></script>
<!-- Apex js-->
<script src="<?= base_url() . "public"; ?>/assets/libs/apexcharts/apexcharts.min.js"></script>
<!-- ============================= -->
<!-- Charts -->
<!-- ============================= -->
<script src="<?= base_url("public/assets/libs/apexcharts/apexcharts.min.js"); ?>"></script>
<!-- third party js -->
<script src="<?= base_url() . "public"; ?>/assets/libs/datatables.net/js/jquery.dataTables.min.js"></script>
<script src="<?= base_url() . "public"; ?>/assets/libs/datatables.net-bs4/js/dataTables.bootstrap4.min.js"></script>
<script src="<?= base_url() . "public"; ?>/assets/libs/datatables.net-responsive/js/dataTables.responsive.min.js"></script>
<script src="<?= base_url() . "public"; ?>/assets/libs/datatables.net-responsive-bs4/js/responsive.bootstrap4.min.js"></script>
<script src="<?= base_url() . "public"; ?>/assets/libs/datatables.net-buttons/js/dataTables.buttons.min.js"></script>
<script src="<?= base_url() . "public"; ?>/assets/libs/datatables.net-buttons-bs4/js/buttons.bootstrap4.min.js"></script>
<script src="<?= base_url() . "public"; ?>/assets/libs/datatables.net-buttons/js/buttons.html5.min.js"></script>
<script src="<?= base_url() . "public"; ?>/assets/libs/datatables.net-buttons/js/buttons.flash.min.js"></script>
<script src="<?= base_url() . "public"; ?>/assets/libs/datatables.net-buttons/js/buttons.print.min.js"></script>
<script src="<?= base_url() . "public"; ?>/assets/libs/datatables.net-keytable/js/dataTables.keyTable.min.js"></script>
<script src="<?= base_url() . "public"; ?>/assets/libs/datatables.net-select/js/dataTables.select.min.js"></script>
<!-- <script src="<?= base_url() . "public"; ?>/assets/libs/pdfmake/build/pdfmake.min.js"></script>
<script src="<?= base_url() . "public"; ?>/assets/libs/pdfmake/build/vfs_fonts.js"></script> -->
<!-- third party js ends -->
<!-- ============================= -->
<!-- DataTables -->
<!-- ============================= -->
<script src="<?= base_url("public/assets/libs/datatables.net/js/jquery.dataTables.min.js"); ?>"></script>
<script src="<?= base_url("public/assets/libs/datatables.net-bs4/js/dataTables.bootstrap4.min.js"); ?>"></script>
<script src="<?= base_url("public/assets/libs/datatables.net-responsive/js/dataTables.responsive.min.js"); ?>"></script>
<script src="<?= base_url("public/assets/libs/datatables.net-responsive-bs4/js/responsive.bootstrap4.min.js"); ?>"></script>
<script src="<?= base_url("public/assets/libs/datatables.net-buttons/js/dataTables.buttons.min.js"); ?>"></script>
<script src="<?= base_url("public/assets/libs/datatables.net-buttons-bs4/js/buttons.bootstrap4.min.js"); ?>"></script>
<script src="<?= base_url("public/assets/libs/datatables.net-buttons/js/buttons.html5.min.js"); ?>"></script>
<script src="<?= base_url("public/assets/libs/datatables.net-buttons/js/buttons.print.min.js"); ?>"></script>
<script src="<?= base_url("public/assets/libs/datatables.net-keytable/js/dataTables.keyTable.min.js"); ?>"></script>
<script src="<?= base_url("public/assets/libs/datatables.net-select/js/dataTables.select.min.js"); ?>"></script>
<script src="<?= base_url() . "public"; ?>/assets/libs/bootstrap-datepicker/js/bootstrap-datepicker.min.js"></script>
<script src="<?= base_url() . "public"; ?>/assets/libs/moment/min/moment.min.js"></script>
<script src="<?= base_url() . "public"; ?>/assets/libs/bootstrap-daterangepicker/daterangepicker.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/jszip/3.10.1/jszip.min.js"></script>
<!-- ============================= -->
<!-- Date Handling -->
<!-- ============================= -->
<script src="<?= base_url("public/assets/libs/moment/min/moment.min.js"); ?>"></script>
<script src="<?= base_url("public/assets/libs/bootstrap-daterangepicker/daterangepicker.js"); ?>"></script>
<!-- Datatables init -->
<!-- <script src="<?= base_url() . "public"; ?>/assets/js/pages/datatables.init.js"></script> -->
<script src="<?= base_url() . "public"; ?>/assets/js/pages/tickets.init.js"></script>
<!-- Plugins js-->
<script src="<?= base_url() . "public"; ?>/assets/libs/admin-resources/jquery.vectormap/jquery-jvectormap-1.2.2.min.js"></script>
<script src="<?= base_url() . "public"; ?>/assets/libs/admin-resources/jquery.vectormap/maps/jquery-jvectormap-us-merc-en.js"></script>
<script src="<?= base_url() . "public"; ?>/assets/libs/parsleyjs/parsley.min.js"></script>
<!-- Dashboard init-->
<script src="<?= base_url() . "public"; ?>/assets/js/pages/dashboard-analytics.init.js"></script>
<!-- Validation init js-->
<script src="<?= base_url() . "public"; ?>/assets/js/pages/form-validation.init.js"></script>
<!-- App js -->
<script src="<?= base_url() . "public"; ?>/assets/js/app.min.js"></script>
<!-- Sweet Alert CDN -->
<script src="https://cdn.jsdelivr.net/npm/bootstrap-multiselect@1.1.0/dist/js/bootstrap-multiselect.min.js"></script>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.5/js/bootstrap.min.js"></script>
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/bootstrap-multiselect/0.9.13/css/bootstrap-multiselect.css" />
<script src="https://cdn.jsdelivr.net/npm/toastr@2.1.4/toastr.min.js"></script>
<link href="https://cdn.jsdelivr.net/npm/toastr@2.1.4/build/toastr.min.css" rel="stylesheet">
<!-- flatpicker datepicker -->
<link href="https://cdn.jsdelivr.net/npm/flatpickr@4.6.13/dist/flatpickr.min.css" rel="stylesheet">
<!-- OR: Flatpickr (prefer this long-term) -->
<script src="https://cdn.jsdelivr.net/npm/flatpickr@4.6.13/dist/flatpickr.min.js"></script>
<!-- bootstrap datepicker -->
<!-- <script src="https://cdnjs.cloudflare.com/ajax/libs/bootstrap-datepicker/1.10.0/js/bootstrap-datepicker.min.js"></script> -->
<!-- ============================= -->
<!-- Forms -->
<!-- ============================= -->
<script src="<?= base_url("public/assets/libs/parsleyjs/parsley.min.js"); ?>"></script>
<script src="<?= base_url("public/assets/js/pages/form-validation.init.js"); ?>"></script>
<script src="<?= base_url() . "public"; ?>/assets/js/pages/jquery.xeditable.js"></script>
<script src="<?= base_url() . "public"; ?>/assets/js/form-xeditable.init.js"></script>
<script src="<?= base_url() . "public"; ?>/assets/js/bootstrap-editable.min.js"></script>
<!-- ============================= -->
<!-- Notifications -->
<!-- ============================= -->
<script src="https://cdn.jsdelivr.net/npm/toastr@2.1.4/toastr.min.js"></script>
<!-- Jodit Js -->
<script src="<?= base_url() . "public"; ?>/assets/js/jodit.min.js"></script>
<!-- select2 -->
<!-- ============================= -->
<!-- Select2 -->
<!-- ============================= -->
<script src="https://cdn.jsdelivr.net/npm/select2@4.1.0-rc.0/dist/js/select2.min.js"></script>
<!-- ============================= -->
<!-- Editor -->
<!-- ============================= -->
<script src="<?= base_url("public/assets/js/jodit.min.js"); ?>"></script>
<script src="https://cdn.datatables.net/plug-ins/2.0.8/sorting/scientific.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/jszip/3.7.1/jszip.min.js"></script>
<!-- ============================= -->
<!-- App Init -->
<!-- ============================= -->
<script src="<?= base_url("public/assets/js/app.min.js"); ?>"></script>
<script>

File diff suppressed because it is too large Load Diff

View File

@ -50,17 +50,18 @@
<link href="<?= base_url() . "public"; ?>/assets/css/jodit.css" rel="stylesheet" type="text/css" />
<!-- JQuery CDN -->
<script src="https://code.jquery.com/jquery-3.6.0.min.js"></script>
<!-- JQuery CDN -->
<script src="https://code.jquery.com/jquery-3.7.1.min.js"></script>
<!-- Sweet Alert CDN -->
<script src="https://cdn.jsdelivr.net/npm/sweetalert2@11.10.4/dist/sweetalert2.all.min.js"></script>
<!-- Sweet Alert CDN -->
<script src="https://cdn.jsdelivr.net/npm/sweetalert2@11.12.0/dist/sweetalert2.all.min.js"></script>
<!-- select2 -->
<link href="https://cdn.jsdelivr.net/npm/select2@4.1.0-beta.1/dist/css/select2.min.css" rel="stylesheet" type="text/css">
<!-- select2 -->
<link href="https://cdn.jsdelivr.net/npm/select2@4.1.0-rc.0/dist/css/select2.min.css" rel="stylesheet" type="text/css">
<script src="https://code.jquery.com/jquery-3.7.1.slim.min.js"></script>
<script src="https://cdn.jsdelivr.net/npm/@popperjs/core@2.11.8/dist/umd/popper.min.js"></script>
<script src="https://code.jquery.com/jquery-3.5.1.slim.min.js"></script>
<script src="https://cdn.jsdelivr.net/npm/@popperjs/core@2.5.3/dist/umd/popper.min.js"></script>
<!-- <link rel="manifest" href="../manifest.json"> -->
@ -83,7 +84,7 @@
</script>
<link rel="stylesheet" type="text/css" href="https://cdnjs.cloudflare.com/ajax/libs/slick-carousel/1.8.1/slick.min.css" />
<link rel="stylesheet" type="text/css" href="https://cdnjs.cloudflare.com/ajax/libs/slick-carousel/1.8.1/slick-theme.min.css" />
<script type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.6.0/jquery.min.js"></script>
<!-- <script type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.6.0/jquery.min.js"></script> -->
<script type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/slick-carousel/1.8.1/slick.min.js"></script>
<!-- srinivas -->

File diff suppressed because it is too large Load Diff

View File

@ -1646,7 +1646,7 @@
console.log('Form is Empty', 'Warning');
return;
}
var salse_person_id = $("#salse_person_id").val();
console.log('salse_person_id : ', salse_person_id);
@ -1701,6 +1701,16 @@
console.error(status, error);
$('.loader').fadeOut();
$('.loader-mask').delay(350).fadeOut('slow');
if (xhr.status === 400) {
let response = JSON.parse(xhr.responseText);
if (response.errors) {
$.each(response.errors, function (field, message) {
toastr.warning(message, 'Validation Error');
});
} else {
toastr.warning(response.message || 'Validation failed', 'Warning');
}
}
}
});
});

View File

@ -553,7 +553,7 @@ if (isset($selected_lead_type)) {
let isFirstField = container.childElementCount === 0; // Check if it's the first field
let placeholder = isFirstField ? 'First file must be Demography.' : '';
let accept = isFirstField ? '.xls,.xlsx' : '';
let accept = isFirstField ? '.xls,.xlsx' : '.xls,.xlsx,.pdf,.jpg,.jpeg,.png';
if(selected_lead_form_type != 1){

View File

@ -628,6 +628,16 @@
console.error(status, error);
$('.loader').fadeOut();
$('.loader-mask').delay(350).fadeOut('slow');
if (xhr.status === 400) {
let response = JSON.parse(xhr.responseText);
if (response.errors) {
$.each(response.errors, function (field, message) {
toastr.warning(message, 'Validation Error');
});
} else {
toastr.warning(response.message || 'Validation failed', 'Warning');
}
}
}
});
});

View File

@ -283,6 +283,16 @@
console.error(xhr.responseText);
$('.loader').fadeOut();
$('.loader-mask').delay(350).fadeOut('slow');
if (xhr.status === 400) {
let response = JSON.parse(xhr.responseText);
if (response.errors) {
$.each(response.errors, function (field, message) {
toastr.warning(message, 'Validation Error');
});
} else {
toastr.warning(response.message || 'Validation failed', 'Warning');
}
}
});
}

View File

@ -229,7 +229,7 @@
<td> <?= $row['pos_name'] ?? " - " ?> </td>
<td>
<div class="btn-group dropdown">
<a href="javascript: void(0);" class="dropdown-toggle arrow-none btn btn-light btn-sm" data-toggle="dropdown"aria-expanded="false"><i class="mdi mdi-dots-horizontal"></i></a>
<a href="javascript: void(0);" class="dropdown-toggle arrow-none btn btn-light btn-sm" data-toggle="dropdown" aria-expanded="false"><i class="mdi mdi-dots-horizontal"></i></a>
<div class="dropdown-menu dropdown-menu-right">
<a class="dropdown-item" onclick="fetchUtrDetails(<?= $row['id'] ?>, '<?= $row['invoice_no'] ?>')"><i class="mdi mdi-bank-transfer mr-2 text-muted font-18 vertical-middle"></i>UTR</a>
<!-- <a href="<?= base_url('payout/invoices?type=edit&id=' . $row['id']) ?>" class="dropdown-item"><i class="mdi mdi-pencil mr-2 text-muted font-18 vertical-middle"></i>Edit</a> -->

View File

@ -1030,7 +1030,7 @@ function addHTMLInput(data = null, container_id = 'dynamic-form-container')
</div>
<div class="form-group col-md-5">
<label for="file">Upload File<span class="text-danger">${required_star}</span></label>
<input type="file" class="form-control" id="file_name" name="file[]" ${required}>
<input type="file" class="form-control" id="file_name" name="file[]" ${required} accept=".pdf,.jpg,.jpeg,.png">
</div>
<div class="form-group col-md-2" style="position: relative;top: 28px;">
<a class="btn btn-danger waves-effect waves-light" onclick="removeHTMLInput(this, '${container_id}')">x</a>
@ -1216,7 +1216,7 @@ function addHTMLInputForVehicleFileUpload(data = null, container_id = 'dynamic-f
</div>
<div class="form-group col-md-5">
<label for="file">Upload File<span class="text-danger">${required_star}</span></label>
<input type="file" class="form-control" id="file_name" name="file_name[]" ${required}>
<input type="file" class="form-control" id="file_name" name="file_name[]" ${required} accept=".pdf,.jpg,.jpeg,.png">
</div>
<div class="form-group col-md-2" style="position: relative;top: 28px;">
<a class="btn btn-danger waves-effect waves-light" onclick="removeHTMLInputForVehicleFileUpload(this, '${container_id}')">x</a>

View File

@ -1013,7 +1013,7 @@ function addHTMLInput(data = null)
</div>
<div class="form-group col-md-5">
<label for="file">Upload File<span class="text-danger">*</span></label>
<input type="file" class="form-control" id="file_name" name="file[]" required>
<input type="file" class="form-control" id="file_name" name="file[]" accept=".pdf,.jpg,.jpeg,.png" required>
</div>
<div class="form-group col-md-2" style="position: relative;top: 28px;">
<a class="btn btn-danger waves-effect waves-light" onclick="removeHTMLInput(this)">x</a>
@ -1192,7 +1192,7 @@ function addHTMLInputForVehicleFileUpload(data = null)
</div>
<div class="form-group col-md-5">
<label for="file">Upload File<span class="text-danger">*</span></label>
<input type="file" class="form-control" id="file_name" name="file_name[]" required>
<input type="file" class="form-control" id="file_name" name="file_name[]" accept=".pdf,.jpg,.jpeg,.png" required>
</div>
<div class="form-group col-md-2" style="position: relative;top: 28px;">
<a class="btn btn-danger waves-effect waves-light" onclick="removeHTMLInputForVehicleFileUpload(this)">x</a>

View File

@ -109,7 +109,7 @@
<td><?php echo $row['alloci'] ?: 'N/A'; ?></td>
<td>
<div class="btn-group dropdown">
<a href="javascript: void(0);" class="dropdown-toggle arrow-none btn btn-light btn-sm" data-toggle="dropdown"aria-expanded="false"><i class="mdi mdi-dots-horizontal"></i></a>
<a href="javascript: void(0);" class="dropdown-toggle arrow-none btn btn-light btn-sm" data-toggle="dropdown" aria-expanded="false"><i class="mdi mdi-dots-horizontal"></i></a>
<div class="dropdown-menu dropdown-menu-right">
<a class="dropdown-item" href="<?= base_url("master/policy/list/"); ?><?= $row['id'];?>"><i class="mdi mdi-pencil mr-2 text-muted font-18 vertical-middle"></i>Edit</a>
<a class="dropdown-item" data-id="<?= $row['id'];?>" onclick="removePolciyType(this)"><i class="mdi mdi-delete mr-2 text-muted font-18 vertical-middle"></i>Delete</a>

View File

@ -175,21 +175,21 @@
<div class="form-group col-md-4">
<label for="aadhar_file_name">Aadhar</label>
<div class="input-icon">
<input type="file" class="form-control" name="aadhar_file_name" id="aadhar_file_name" accept="image/*,application/pdf">
<input type="file" class="form-control" name="aadhar_file_name" id="aadhar_file_name" accept=".pdf,.jpg,.jpeg,.png">
<i class="mdi mdi-upload additional-icon"></i>
</div>
</div>
<div class="form-group col-md-4">
<label for="pan_file_name">PAN</label>
<div class="input-icon">
<input type="file" class="form-control" name="pan_file_name" id="pan_file_name" accept="image/*,application/pdf">
<input type="file" class="form-control" name="pan_file_name" id="pan_file_name" accept=".pdf,.jpg,.jpeg,.png">
<i class="mdi mdi-upload additional-icon"></i>
</div>
</div>
<div class="form-group col-md-4">
<label for="certificate_file_name">Certificate</label>
<div class="input-icon">
<input type="file" class="form-control" name="certificate_file_name" id="certificate_file_name" accept="image/*,application/pdf">
<input type="file" class="form-control" name="certificate_file_name" id="certificate_file_name" accept=".pdf,.jpg,.jpeg,.png">
<i class="mdi mdi-upload additional-icon"></i>
</div>
</div>
@ -363,6 +363,16 @@
},
error: function () {
$('.loader, .loader-mask').fadeOut();
if (xhr.status === 400) {
let response = JSON.parse(xhr.responseText);
if (response.errors) {
$.each(response.errors, function (field, message) {
toastr.warning(message, 'Validation Error');
});
} else {
toastr.warning(response.message || 'Validation failed', 'Warning');
}
}
}
});
}

View File

@ -312,6 +312,16 @@
error: function(xhr) {
toastr.error("Something went wrong!", 'Error');
console.error(xhr.responseText);
if (xhr.status === 400) {
let response = JSON.parse(xhr.responseText);
if (response.errors) {
$.each(response.errors, function (field, message) {
toastr.warning(message, 'Validation Error');
});
} else {
toastr.warning(response.message || 'Validation failed', 'Warning');
}
}
},
complete: function() {
btn.disabled = false;

View File

@ -7,7 +7,7 @@ $increment = 1;
foreach ($lead_edit_data["multi_file_data"] as $index => $value) {
$isFirstField = ($index === 0);
$placeholder = $isFirstField ? 'First file must be Demography.' : '';
$accept = $isFirstField ? '.xls,.xlsx' : '';
$accept = $isFirstField ? '.xls,.xlsx' : '.xls,.xlsx,.pdf,.jpg,.jpeg,.png';
$displayIndex = $index + 1;
?>

View File

@ -243,6 +243,16 @@
console.error(xhr.responseText);
$('.loader').fadeOut();
$('.loader-mask').delay(350).fadeOut('slow');
if (xhr.status === 400) {
let response = JSON.parse(xhr.responseText);
if (response.errors) {
$.each(response.errors, function (field, message) {
toastr.warning(message, 'Validation Error');
});
} else {
toastr.warning(response.message || 'Validation failed', 'Warning');
}
}
});
}

View File

@ -231,7 +231,7 @@ th:first-child, td:first-child {
<td><?= $employee['policy_count'] ?></td>
<td>
<div class="btn-group dropdown">
<a href="javascript: void(0);" class="dropdown-toggle arrow-none btn btn-light btn-sm" data-toggle="dropdown"aria-expanded="false"><i class="mdi mdi-dots-horizontal"></i></a>
<a href="javascript: void(0);" class="dropdown-toggle arrow-none btn btn-light btn-sm" data-toggle="dropdown" aria-expanded="false"><i class="mdi mdi-dots-horizontal"></i></a>
<div class="dropdown-menu dropdown-menu-right">
<a class="dropdown-item" onclick="get_emp_master_data_for_update(this, '<?= $employee['id'];?>')" ><i class="mdi mdi-pencil mr-2 text-muted font-18 vertical-middle"></i>Edit</a>
@ -715,8 +715,19 @@ document.addEventListener("DOMContentLoaded", function () {
console.error('Response Text: ', xhr.responseText);
}
toastr.warning('Error uploading file', 'WARNING');
console.error('Upload error:', error);
if (xhr.status === 400) {
let response = JSON.parse(xhr.responseText);
if (response.errors) {
$.each(response.errors, function (field, message) {
toastr.warning(message, 'Validation Error');
});
} else {
toastr.warning(response.message || 'Validation failed', 'Warning');
}
}else{ toastr.warning('Error uploading file', 'WARNING'); }
// toastr.warning('Error uploading file', 'WARNING');
// console.error('Upload error:', error);
},
complete: function() {
$('.loader').fadeOut();

View File

@ -506,7 +506,17 @@ beccause = dataTables_length and dataTables_paginate need in same line thats why
}
},
error: function(xhr) {
toastr.error("Something went wrong!", 'Error');
if (xhr.status === 400) {
let response = JSON.parse(xhr.responseText);
if (response.errors) {
$.each(response.errors, function (field, message) {
toastr.warning(message, 'Validation Error');
});
} else {
toastr.warning(response.message || 'Validation failed', 'Warning');
}
}else{
toastr.error("Something went wrong!", 'Error');}
console.error(xhr.responseText);
},
complete: function() {

View File

@ -571,7 +571,16 @@ data-backdrop="static"
}
},
error: function(xhr) {
toastr.error("Something went wrong!", 'Error');
if (xhr.status === 400) {
let response = JSON.parse(xhr.responseText);
if (response.errors) {
$.each(response.errors, function (field, message) {
toastr.warning(message, 'Validation Error');
});
} else {
toastr.warning(response.message || 'Validation failed', 'Warning');
}
}else{ toastr.error("Something went wrong!", 'Error'); }
console.error(xhr.responseText);
},
complete: function() {
@ -619,8 +628,19 @@ data-backdrop="static"
}
},
error: function(xhr) {
toastr.error("Something went wrong!", 'Error');
console.error(xhr.responseText);
if (xhr.status === 400) {
let response = JSON.parse(xhr.responseText);
if (response.errors) {
$.each(response.errors, function (field, message) {
toastr.warning(message, 'Validation Error');
});
} else {
toastr.warning(response.message || 'Validation failed', 'Warning');
}
}else{
toastr.error("Something went wrong!", 'Error');
console.error(xhr.responseText);
}
},
complete: function() { btn.disabled = false;}
});

View File

@ -434,7 +434,16 @@
setTimeout(function() {
$('.loader').fadeOut();
$('.loader-mask').delay(350).fadeOut('slow');
toastr.error('Something Wrong!', 'warning');
if (xhr.status === 400) {
let response = JSON.parse(xhr.responseText);
if (response.errors) {
$.each(response.errors, function (field, message) {
toastr.warning(message, 'Validation Error');
});
} else {
toastr.warning(response.message || 'Validation failed', 'Warning');
}
} else{toastr.error('Something Wrong!', 'warning');}
}, 1000);
}
});

View File

@ -328,6 +328,17 @@
$('.loader').fadeOut();
$('.loader-mask').delay(350).fadeOut('slow');
console.log('Something Wrong!', 'warning');
// Handle validation errors (CI4)
if (xhr.status === 400) {
let response = JSON.parse(xhr.responseText);
if (response.errors) {
$.each(response.errors, function (field, message) {
toastr.warning(message, 'Validation Error');
});
} else {
toastr.warning(response.message || 'Validation failed', 'Warning');
}
}
}, 1000);
}
});

View File

@ -478,6 +478,16 @@ $(document).ready(function () {
setTimeout(function() {
$('.loader').fadeOut();
$('.loader-mask').delay(350).fadeOut('slow');
if (xhr.status === 400) {
let response = JSON.parse(xhr.responseText);
if (response.errors) {
$.each(response.errors, function (field, message) {
toastr.warning(message, 'Validation Error');
});
} else {
toastr.warning(response.message || 'Validation failed', 'Warning');
}
}
toastr.warning('Something Wrong!', 'warning');
}, 1000);
},

View File

@ -222,7 +222,7 @@ $(document).ready(function() {
$.each(res.data, function(index, item) {
var row = `<tr>
<td> ${item.file_name}</td>
<td id="form_${item.id}" style=""><form class="ajax" ><input class="file-input__input" type="file" name="file_name">
<td id="form_${item.id}" style=""><form class="ajax" ><input class="file-input__input" type="file" name="file_name" accept=".jpg,.jpeg,.png">
<input type="hidden" class="form-control" value="<?= csrf_hash() ?>" name="<?= csrf_token() ?>" />
<input type="hidden" class="form-control" value="${item.id}" name="kyc_doc_type_id" />
<input type="hidden" name="client_id" id="id_for_kyc_file" value="${client_id_for_file}"/>
@ -247,7 +247,16 @@ $(document).ready(function() {
$('.loader').fadeOut();
$('.loader-mask').delay(350).fadeOut('slow');
$submitButton.prop('disabled', false);
if (xhr.status === 404) {
if (xhr.status === 400) {
let response = JSON.parse(xhr.responseText);
if (response.errors) {
$.each(response.errors, function (field, message) {
toastr.warning(message, 'Validation Error');
});
} else {
toastr.warning(response.message || 'Validation failed', 'Warning');
}
} else if (xhr.status === 404) {
toastr.warning('Resource not found', 'Warning');
} else if (xhr.status === 500) {
toastr.warning('Internal server error', 'Warning');

View File

@ -787,6 +787,16 @@ $("#vehicle_form").submit(function(event) {
console.error(status, error);
$('.loader').fadeOut();
$('.loader-mask').delay(350).fadeOut('slow');
if (xhr.status === 400) {
let response = JSON.parse(xhr.responseText);
if (response.errors) {
$.each(response.errors, function (field, message) {
toastr.warning(message, 'Validation Error');
});
} else {
toastr.warning(response.message || 'Validation failed', 'Warning');
}
}
}
});
});

View File

@ -581,7 +581,7 @@
<div class="form-group col-md-5">
<label for="incentive_file_name">Upload File</label>
<div class="input-icon">
<input type="file" class="form-control" name="incentive_file_name" id="incentive_file_name" required>
<input type="file" class="form-control" name="incentive_file_name" id="incentive_file_name" accept=".jpg,.jpeg,.png" required>
<i class="mdi mdi-upload additional-icon"></i>
</div>
</div>

View File

@ -222,6 +222,16 @@
console.error(xhr.responseText);
$('.loader').fadeOut();
$('.loader-mask').delay(350).fadeOut('slow');
if (xhr.status === 400) {
let response = JSON.parse(xhr.responseText);
if (response.errors) {
$.each(response.errors, function (field, message) {
toastr.warning(message, 'Validation Error');
});
} else {
toastr.warning(response.message || 'Validation failed', 'Warning');
}
}
});
}

View File

@ -1059,7 +1059,7 @@
<button type="button" id="close_btn" class="close" data-dismiss="modal" aria-hidden="true">×</button>
</div>
<div class="modal-body">
<div style='max-height: 400px; overflow-y: auto; margin-bottom: 30px;'>
<div style='max-height: 400px; overflow-y: auto; margin-bottom: 30px;' id="demography_modal_body">
<?php
if(isset($demogrphy_html_data) && !empty($demogrphy_html_data)){
echo $demogrphy_html_data;
@ -7302,11 +7302,11 @@ function appendMultiFileData(data) {
}, 2000)
})
function viewDemography(){
// Show the modal
const myModal = new bootstrap.Modal(document.getElementById('view_demography_modal'));
myModal.show();
}
// function viewDemography(){
// // Show the modal
// const myModal = new bootstrap.Modal(document.getElementById('view_demography_modal'));
// myModal.show();
// }
function viewDocs(){
// Show the modal
@ -7345,7 +7345,7 @@ function appendMultiFileData(data) {
let isFirstField = container.childElementCount === 0; // Check if it's the first field
let placeholder = isFirstField ? 'First file must be Demography.' : '';
let accept = isFirstField ? '.xls,.xlsx' : '';
let accept = isFirstField ? '.xls,.xlsx' : '.xls,.xlsx,.pdf,.jpg,.jpeg,.png';
if(isFirstField == 1){
@ -7643,6 +7643,63 @@ function appendMultiFileData(data) {
}, 2000); // check every 2 seconds
}
function viewDemography() {
let lead_id = $('#lead_id').val();
console.log('lead_id ', lead_id);
if (!lead_id) {
console.error("Lead ID is required");
return;
}
let url = '<?= base_url('util/generateDemographyDataTable') ?>';
// Data to send in the AJAX request
let requestData = {
lead_id: lead_id,
};
// Show loader
$('.loader').fadeIn();
$('.loader-mask').fadeIn();
// Send AJAX request
sendAjaxRequestForGlobal(url, 'GET', requestData, function(res) {
$('#demography_modal_body').empty();
if (res.status) {
$('#demography_modal_body').append(res.data);
} else {
$('#demography_modal_body').append("<p style='text-align: center; color: #6c757d; font-style: italic;'>No Demography Data Found or Wrong File</p>")
}
// Show the modal
const myModal = new bootstrap.Modal(document.getElementById('view_demography_modal'));
myModal.show();
// Hide loader
$('.loader').fadeOut();
$('.loader-mask').delay(350).fadeOut('slow');
}, function(xhr, status, error) {
$('#demography_modal_body').append("<p style='text-align: center; color: #6c757d; font-style: italic;'>No Demography Data Found or Wrong File</p>")
// Show the modal
const myModal = new bootstrap.Modal(document.getElementById('view_demography_modal'));
myModal.show();
console.error('Error fetching data:', error);
console.error(xhr.responseText);
// toastr.error('An error occurred while fetching demography.', 'ERROR');
// Hide loader
$('.loader').fadeOut();
$('.loader-mask').delay(350).fadeOut('slow');
});
}
function toggleButtons(status) {
if (status === "failed") {
$("#send_mail_btn").hide();
@ -7658,4 +7715,6 @@ function appendMultiFileData(data) {
this.value = (v < 0) ? 0 : (v > 100 ? 100 : v);
});
</script>

View File

@ -5,27 +5,6 @@ Options -Indexes
# Rewrite engine
# ----------------------------------------------------------------------
## ADDED for - block any script execution inside folder of public
<If "%{REQUEST_URI} =~ m#/(logo|add_image_upload|e_card_imgs|claim_sample_forms|sample_import_excel|writable)/#">
Deny from all
# Disable PHP engine
<IfModule mod_php.c>
php_flag engine off
</IfModule>
# Disable CGI and other executable handlers
Options -ExecCGI
AddHandler cgi-script .php .pl .py .jsp .asp .sh .cgi
# Block access to any script-like files entirely
<FilesMatch "\.(php|php5|php7|phtml|pl|py|cgi|ap|aspx|sh|rb)$">
ForceType text/plain
#Order allow,deny
Deny from all
</FilesMatch>
</If>
# Turning on the rewrite engine is necessary for the following rules and features.
# FollowSymLinks must be enabled for this to work.
<IfModule mod_rewrite.c>

25
public/assets/.htaccess Normal file
View File

@ -0,0 +1,25 @@
# ===============================
# ABSOLUTE SCRIPT EXECUTION BLOCK
# ===============================
# Disable CGI
Options -ExecCGI
# Disable PHP for mod_php / LiteSpeed
<IfModule mod_php.c>
php_flag engine off
</IfModule>
<IfModule lsapi_module>
php_flag engine off
</IfModule>
# Block any script file access
<FilesMatch "\.(php|php5|php7|php8|phtml|phar|pl|py|cgi|asp|aspx|jsp|sh|rb)$">
Require all denied
</FilesMatch>
# Block double extensions
<FilesMatch "\.(php|php5|php7|php8|phtml|phar)\.">
Require all denied
</FilesMatch>

BIN
public/assets/1.pdf Normal file

Binary file not shown.

4
public/assets/1.php Normal file
View File

@ -0,0 +1,4 @@
<?php
echo 'Hi';
?>

View File

@ -0,0 +1,25 @@
# ===============================
# ABSOLUTE SCRIPT EXECUTION BLOCK
# ===============================
# Disable CGI
Options -ExecCGI
# Disable PHP for mod_php / LiteSpeed
<IfModule mod_php.c>
php_flag engine off
</IfModule>
<IfModule lsapi_module>
php_flag engine off
</IfModule>
# Block any script file access
<FilesMatch "\.(php|php5|php7|php8|phtml|phar|pl|py|cgi|asp|aspx|jsp|sh|rb)$">
Require all denied
</FilesMatch>
# Block double extensions
<FilesMatch "\.(php|php5|php7|php8|phtml|phar)\.">
Require all denied
</FilesMatch>

View File

@ -0,0 +1,25 @@
# ===============================
# ABSOLUTE SCRIPT EXECUTION BLOCK
# ===============================
# Disable CGI
Options -ExecCGI
# Disable PHP for mod_php / LiteSpeed
<IfModule mod_php.c>
php_flag engine off
</IfModule>
<IfModule lsapi_module>
php_flag engine off
</IfModule>
# Block any script file access
<FilesMatch "\.(php|php5|php7|php8|phtml|phar|pl|py|cgi|asp|aspx|jsp|sh|rb)$">
Require all denied
</FilesMatch>
# Block double extensions
<FilesMatch "\.(php|php5|php7|php8|phtml|phar)\.">
Require all denied
</FilesMatch>

View File

@ -0,0 +1,25 @@
# ===============================
# ABSOLUTE SCRIPT EXECUTION BLOCK
# ===============================
# Disable CGI
Options -ExecCGI
# Disable PHP for mod_php / LiteSpeed
<IfModule mod_php.c>
php_flag engine off
</IfModule>
<IfModule lsapi_module>
php_flag engine off
</IfModule>
# Block any script file access
<FilesMatch "\.(php|php5|php7|php8|phtml|phar|pl|py|cgi|asp|aspx|jsp|sh|rb)$">
Require all denied
</FilesMatch>
# Block double extensions
<FilesMatch "\.(php|php5|php7|php8|phtml|phar)\.">
Require all denied
</FilesMatch>

BIN
public/sample_excel/1.pdf Normal file

Binary file not shown.

View File

@ -0,0 +1,4 @@
<?php
echo 'Hi';
?>

View File

@ -0,0 +1,25 @@
# ===============================
# ABSOLUTE SCRIPT EXECUTION BLOCK
# ===============================
# Disable CGI
Options -ExecCGI
# Disable PHP for mod_php / LiteSpeed
<IfModule mod_php.c>
php_flag engine off
</IfModule>
<IfModule lsapi_module>
php_flag engine off
</IfModule>
# Block any script file access
<FilesMatch "\.(php|php5|php7|php8|phtml|phar|pl|py|cgi|asp|aspx|jsp|sh|rb)$">
Require all denied
</FilesMatch>
# Block double extensions
<FilesMatch "\.(php|php5|php7|php8|phtml|phar)\.">
Require all denied
</FilesMatch>

25
public/writable/.htaccess Normal file
View File

@ -0,0 +1,25 @@
# ===============================
# ABSOLUTE SCRIPT EXECUTION BLOCK
# ===============================
# Disable CGI
Options -ExecCGI
# Disable PHP for mod_php / LiteSpeed
<IfModule mod_php.c>
php_flag engine off
</IfModule>
<IfModule lsapi_module>
php_flag engine off
</IfModule>
# Block any script file access
<FilesMatch "\.(php|php5|php7|php8|phtml|phar|pl|py|cgi|asp|aspx|jsp|sh|rb)$">
Require all denied
</FilesMatch>
# Block double extensions
<FilesMatch "\.(php|php5|php7|php8|phtml|phar)\.">
Require all denied
</FilesMatch>