Merge branch 'dev' of bitbucket.org:jubilian/nhance into dev

This commit is contained in:
velz 2026-02-16 18:14:46 +05:30
commit 43bec44d07
27 changed files with 6933 additions and 6281 deletions

View File

@ -120,4 +120,13 @@ FHPL_USER_NAME =
FHPL_PASSWORD = FHPL_PASSWORD =
FHPL_GRANT_TYPE = FHPL_GRANT_TYPE =
METABASE_SECRET_KEY= METABASE_SECRET_KEY=
# Health care api details
HEALTH_INDIA_BASE_URL =
HEALTH_INDIA_TOKEN_URL =
HEALTH_INDIA_USERNAME =
HEALTH_INDIA_PASSWORD =
HEALTH_INDIA_PRIMARY_KEY_CONSTANT =

View File

@ -16,6 +16,8 @@ class Acl
'#^/getVerifyPosMobileNo#' => ['public' => true], '#^/getVerifyPosMobileNo#' => ['public' => true],
'#^/getVerifiedPosUserData#' => ['public' => true], '#^/getVerifiedPosUserData#' => ['public' => true],
'#^/swagger#' => ['roles' => [ADMIN_ROLE_ID]], '#^/swagger#' => ['roles' => [ADMIN_ROLE_ID]],
'#^/getEmployeeActiveOrInactivePolicy#' => ['roles' => [ADMIN_ROLE_ID, HEAD_ROLE_ID]],
'#^/test/testingquerys#' => ['roles' => [ADMIN_ROLE_ID, HEAD_ROLE_ID]],
'#^/fedeploy#' => ['roles' => [ADMIN_ROLE_ID]], '#^/fedeploy#' => ['roles' => [ADMIN_ROLE_ID]],
'#^/visitOffBoardCheck#' => ['roles' => [ADMIN_ROLE_ID]], '#^/visitOffBoardCheck#' => ['roles' => [ADMIN_ROLE_ID]],
'#^/logs#' => ['roles' => [ADMIN_ROLE_ID]], '#^/logs#' => ['roles' => [ADMIN_ROLE_ID]],

View File

@ -783,10 +783,10 @@ $routes->get('fetchUHIDDetails','ICICILombardController::fetchUHIDDetails');
//Third party - testing route //Third party - testing route
$routes->get('FhplGetBenefDetails','FhplApiController::FhplGetBenefDetails'); $routes->get('FhplGetBenefDetails','FhplApiController::FhplGetBenefDetails');
$routes->get('EcardRequest','FhplApiController::EcardRequest'); $routes->get('EcardRequest','HealthIndiaApiController::EcardRequest');
$routes->get('HospitalNetwork','MediAssistApiController::HospitalNetwork'); $routes->get('HospitalNetwork','MediAssistApiController::HospitalNetwork');
$routes->get('VidalGetBenefDetails','VidalApiController::VidalGetBenefDetails'); $routes->get('VidalGetBenefDetails','VidalApiController::VidalGetBenefDetails');
$routes->get('ClaimDetail','FhplApiController::ClaimDetail'); $routes->get('ClaimDetail','HealthIndiaApiController::ClaimDetail');
$routes->get('SubmitClaim','HealthIndiaApiController::SubmitClaim'); $routes->get('SubmitClaim','HealthIndiaApiController::SubmitClaim');
$routes->get('IntimateClaim','MediAssistApiController::IntimateClaim'); $routes->get('IntimateClaim','MediAssistApiController::IntimateClaim');
$routes->get('IRSubmission','MediAssistApiController::IRSubmission'); $routes->get('IRSubmission','MediAssistApiController::IRSubmission');
@ -836,6 +836,7 @@ $routes->group('test', function($routes) {
$routes->get('membervalidation', 'TestingController::membervalidation'); $routes->get('membervalidation', 'TestingController::membervalidation');
$routes->get('generateExcel', 'TestingController::generateExcel'); $routes->get('generateExcel', 'TestingController::generateExcel');
$routes->get('logo_renaming','TestingController::logo_renaming'); $routes->get('logo_renaming','TestingController::logo_renaming');
$routes->get('testingquerys','TestingController::testingquerys');
$routes->get('thzReminderCrone','ThzController::getOpenTicketsOlderThan24HoursAndAssignNextLevel'); $routes->get('thzReminderCrone','ThzController::getOpenTicketsOlderThan24HoursAndAssignNextLevel');
// $routes->get('createDefaultMailTempalteInDB','TestingController::createDefaultMailTempalteInCrossDB'); // $routes->get('createDefaultMailTempalteInDB','TestingController::createDefaultMailTempalteInCrossDB');
// $routes->get('createDefaultMailTempalteInSameDB','TestingController::createDefaultMailTempalteInSameDB'); // $routes->get('createDefaultMailTempalteInSameDB','TestingController::createDefaultMailTempalteInSameDB');

View File

@ -64,6 +64,10 @@ class ApiServiceController extends BaseController
{ // fhpl { // fhpl
$fhplApiController = new FhplApiController; $fhplApiController = new FhplApiController;
return $fhplApiController->SubmitClaim($claimId); return $fhplApiController->SubmitClaim($claimId);
}else if ($tpaID == $this->health_india_primary_key)
{ // health india
$healthIndiaApiController = new HealthIndiaApiController;
return $healthIndiaApiController->SubmitClaim($claimId);
}else{ }else{
log_message('error', "This ticket id ( {$claimId} ) TPA has no API service enabled. TPA ID : {$tpaID}"); log_message('error', "This ticket id ( {$claimId} ) TPA has no API service enabled. TPA ID : {$tpaID}");
} }
@ -145,6 +149,12 @@ class ApiServiceController extends BaseController
$fhplApiController = new FhplApiController; $fhplApiController = new FhplApiController;
$data['eCardDownload'] = $fhplApiController->EcardRequest( $emp_code, $policy_no , $employee_policy[0]['tpa_id'] ); $data['eCardDownload'] = $fhplApiController->EcardRequest( $emp_code, $policy_no , $employee_policy[0]['tpa_id'] );
}else if($employee_policy[0]['tpa_primary_id'] == $this->health_india_primary_key)// health india
{
$healthIndiaApiController = new HealthIndiaApiController;
$data['eCardDownload'] = $healthIndiaApiController->EcardRequest( $emp_code, $policy_no , $employee_policy[0]['tpa_id'] );
}else{ }else{
if($type == "download"){ if($type == "download"){
@ -292,6 +302,17 @@ class ApiServiceController extends BaseController
return $this->respond(['status' => true, 'code' => 200, 'message' => 'Action Triggered','data' => [] ]); return $this->respond(['status' => true, 'code' => 200, 'message' => 'Action Triggered','data' => [] ]);
}else if ($tpa_id == $this->health_india_primary_key) // health india
{
$file_id = $fileModel->insert($data);
log_message('error', "Files table inserted successfully, File id : {$file_id}");
// $healthIndiaApiController = new HealthIndiaApiController;
// $healthIndiaApiController->HealthIndiaGetBenefDetails( [ 'polict_no' => $policy_no, 'file_id' =>$file_id ] );
$r = Jobs::addJob(['job_name' => 'HealthIndiaGetBenefDetails', 'payload' => ['policy_no' => $policy_no, 'file_id' => $file_id, 'client_policy_id' => $policy_id, 'return_type' => 'job']]);
log_message('error', "HealthIndiaGetBenefDetails job pushed successfully.");
return $this->respond(['status' => true, 'code' => 200, 'message' => 'Action Triggered','data' => [] ]);
}else{ }else{
return $this->respond(['status' => false, 'code' => 200,'message' => 'TPA not found ','data' => [] ]); return $this->respond(['status' => false, 'code' => 200,'message' => 'TPA not found ','data' => [] ]);
} }
@ -328,6 +349,12 @@ class ApiServiceController extends BaseController
$res = $fhplApiController->ClaimDetail($claimId); $res = $fhplApiController->ClaimDetail($claimId);
return $this->response->setJSON(['status' => $res['status'],'message' => $res['message'] ]); return $this->response->setJSON(['status' => $res['status'],'message' => $res['message'] ]);
}else if ($tpaID == $this->health_india_primary_key) { // health india
$healthIndiaApiController = new HealthIndiaApiController;
$res = $healthIndiaApiController->ClaimDetail($claimId);
return $this->response->setJSON(['status' => $res['status'],'message' => $res['message'] ]);
}else{ }else{
log_message('error', "This ticket id ( {$claimId} ) TPA has no API service enabled. TPA ID : {$tpaID}"); log_message('error', "This ticket id ( {$claimId} ) TPA has no API service enabled. TPA ID : {$tpaID}");
$message = "This TPA has no API service enabled"; $message = "This TPA has no API service enabled";

View File

@ -783,11 +783,19 @@ class ClientController extends AdminController
] ]
], ],
// 'cd_ac_no' => [
// 'rules' => 'required|regex_match[/^[a-zA-Z0-9\/_\\-]+$/]',
// 'errors' => [
// 'required' => 'Account number is required',
// 'regex_match' => 'Account number can only contain letters, numbers, slashes (/), underscores (_), and hyphens (-)',
// ]
// ],
'cd_ac_no' => [ 'cd_ac_no' => [
'rules' => 'required|regex_match[/^[a-zA-Z0-9\/_\\-]+$/]', 'rules' => 'required|numeric',
'errors' => [ 'errors' => [
'required' => 'Account number is required', 'required' => 'CD Account number is required.',
'regex_match' => 'Account number can only contain letters, numbers, slashes (/), underscores (_), and hyphens (-)', 'numeric' => 'CD Account number must contain only numbers.',
] ]
], ],
@ -981,19 +989,19 @@ class ClientController extends AdminController
] ]
], ],
'client_name' => [ 'client_name' => [
'rules' => 'required|regex_match[/^[a-zA-Z0-9\s_-]+$/]|min_length[2]||max_length[45]', 'rules' => 'required|regex_match[/^[a-zA-Z0-9\s_-]+$/]|min_length[2]|max_length[45]',
'errors' => [ 'errors' => [
'required' => 'Client Name is required', 'required' => 'Client Name is required',
'regex_match' => 'Client Name can only contain letters, numbers, spaces, hyphens(-), and underscores(_).', 'regex_match' => 'Client Name can only contain letters, numbers, spaces, hyphens and underscores.',
'min_length' => 'Client Name must be at least 2 characters.', 'min_length' => 'Client Name must be at least 2 characters.',
'max_length' => 'Client Name must not exceed 45 characters.', 'max_length' => 'Client Name must not exceed 45 characters.',
] ]
], ],
'short_name' => [ 'short_name' => [
'rules' => 'required|regex_match[/^[a-zA-Z0-9_-]+$/]|min_length[2]||max_length[15]', 'rules' => 'required|regex_match[/^[a-zA-Z0-9_-]+$/]|min_length[2]|max_length[15]',
'errors' => [ 'errors' => [
'required' => 'Client Short Name is required', 'required' => 'Client Short Name is required',
'regex_match' => 'Client Short Name can only contain letters, numbers, hyphens(-), and underscores(_) with no spaces.', 'regex_match' => 'Client Short Name can only contain letters, numbers, hyphens and underscores.',
'min_length' => 'Client Short Name must be at least 2 characters.', 'min_length' => 'Client Short Name must be at least 2 characters.',
'max_length' => 'Client Short Name must not exceed 15 characters.', 'max_length' => 'Client Short Name must not exceed 15 characters.',
] ]
@ -1011,21 +1019,32 @@ class ClientController extends AdminController
'required' => 'HR File Processed By is required.', 'required' => 'HR File Processed By is required.',
] ]
], ],
// 'client_logo' => [
// 'rules' => [
// 'uploaded[client_logo]', // Add this to check if a file was actually sent
// 'is_image[client_logo]',
// 'max_size[client_logo,200]',
// 'ext_in[client_logo,jpg,jpeg,png]',
// 'max_dims[client_logo,100,100]',
// ],
// 'errors' => [
// 'uploaded' => 'Please upload a client logo',
// 'is_image' => 'The uploaded file must be an image',
// 'max_size' => 'File size should not exceed 200 KB',
// 'ext_in' => 'Allowed file types: jpg, jpeg, png',
// 'max_dims' => 'Image dimensions must be 100 x 100 pixels',
// ]
// ],
'client_logo' => [ 'client_logo' => [
'rules' => [ 'label' => 'Client Logo',
'is_image[client_logo]', 'rules' => 'permit_empty|is_image[client_logo]|max_size[client_logo,200]|ext_in[client_logo,jpg,jpeg,png]|max_dims[client_logo,100,100]',
'max_size[client_logo,200]', // 200 KB 'errors' => [
'ext_in[client_logo,jpg,jpeg,png]', 'is_image' => 'Please upload a valid image file.',
'max_dims[client_logo,100,100]', 'max_size' => 'The logo is too heavy (Max 200KB).',
], 'ext_in' => 'Only JPG, JPEG, and PNG files are allowed.',
'errors' => [ 'max_dims' => 'The logo must be no larger than 100x100 pixels.',
'is_image' => 'The uploaded file must be an image', ]
'max_size' => 'File size should not exceed 200 KB',
'ext_in' => 'Allowed file types: jpg, jpeg, png',
'max_dims' => 'Image dimensions must be 100 x 100 pixels',
]
], ],
]; ];
if (!$this->validate($rules)) { if (!$this->validate($rules)) {
@ -1077,6 +1096,65 @@ class ClientController extends AdminController
public function editClientGeneralInfo() public function editClientGeneralInfo()
{ {
$rules = [
'entity_type_id' => [
'rules' => 'required|numeric',
'errors' => [
'required' => 'Entity Type is required',
'numeric' => 'Invalid Entity Type selected'
]
],
'client_name' => [
'rules' => 'required|regex_match[/^[a-zA-Z0-9\s_-]+$/]',
'errors' => [
'required' => 'Client Name is required',
'regex_match' => 'Client Name can only contain letters, numbers, spaces, hyphens and underscores.',
'min_length' => 'Client Name must be at least 2 characters.',
'max_length' => 'Client Name must not exceed 45 characters.',
]
],
'short_name' => [
'rules' => 'required|regex_match[/^[a-zA-Z0-9_-]+$/]',
'errors' => [
'required' => 'Client Short Name is required',
'regex_match' => 'Client Short Name can only contain letters, numbers, hyphens and underscores.',
'min_length' => 'Client Short Name must be at least 2 characters.',
'max_length' => 'Client Short Name must not exceed 15 characters.',
]
],
'pan' => [
'rules' => 'required|regex_match[/^[A-Z]{5}[0-9]{4}[A-Z]$/]',
'errors' => [
'required' => 'PAN Number is required.',
'regex_match' => 'Invalid PAN format. Example: ABCDE1234F'
]
],
'hr_file_processed_by' => [
'rules' => 'required',
'errors' => [
'required' => 'HR File Processed By is required.',
]
],
'client_logo' => [
'rules' => 'permit_empty|is_image[client_logo]|max_size[client_logo,200]|ext_in[client_logo,jpg,jpeg,png]|max_dims[client_logo,100,100]',
'errors' => [
'is_image' => 'The uploaded file must be an image',
'max_size' => 'File size should not exceed 200 KB',
'ext_in' => 'Allowed file types: jpg, jpeg, png',
'max_dims' => 'Image dimensions must be 100 x 100 pixels',
]
],
];
if (!$this->validate($rules)) {
return $this->response->setStatusCode(400)->setJSON([
'status' => false,
'message' => 'Input validation failed',
'code' => 400,
'errors' => $this->validator->getErrors()
]);
}
$this->myLogger->logme('error', 'edit client general info function called'); $this->myLogger->logme('error', 'edit client general info function called');
$uploadFilePath = ROOTPATH . 'public/uploads/logo/'; $uploadFilePath = ROOTPATH . 'public/uploads/logo/';
$file_name = file_Upload($this->request->getFile('client_logo'), $uploadFilePath); $file_name = file_Upload($this->request->getFile('client_logo'), $uploadFilePath);
@ -1559,14 +1637,14 @@ class ClientController extends AdminController
] ]
], ],
]; ];
if (!$this->validate($rules)) { // if (!$this->validate($rules)) {
return $this->response->setStatusCode(400)->setJSON([ // return $this->response->setStatusCode(400)->setJSON([
'status' => false, // 'status' => false,
'message' => 'Input validation failed', // 'message' => 'Input validation failed',
'code' => 400, // 'code' => 400,
'errors' => $this->validator->getErrors() // 'errors' => $this->validator->getErrors()
]); // ]);
} // }
$data['client_id'] = $this->request->getPost('client_id'); $data['client_id'] = $this->request->getPost('client_id');
$data['created_by'] = get_session_userid(); $data['created_by'] = get_session_userid();
@ -1640,14 +1718,14 @@ class ClientController extends AdminController
] ]
], ],
]; ];
if (!$this->validate($rules)) { // if (!$this->validate($rules)) {
return $this->response->setStatusCode(400)->setJSON([ // return $this->response->setStatusCode(400)->setJSON([
'status' => false, // 'status' => false,
'message' => 'Input validation failed', // 'message' => 'Input validation failed',
'code' => 400, // 'code' => 400,
'errors' => $this->validator->getErrors() // 'errors' => $this->validator->getErrors()
]); // ]);
} // }
$id = $this->request->getPost('PrimaryKey'); $id = $this->request->getPost('PrimaryKey');
$data['client_id'] = $this->request->getPost('client_id'); $data['client_id'] = $this->request->getPost('client_id');
@ -1729,14 +1807,14 @@ class ClientController extends AdminController
'rules' => 'required|regex_match[/^[a-zA-Z0-9\s_-]+$/]|min_length[3]', 'rules' => 'required|regex_match[/^[a-zA-Z0-9\s_-]+$/]|min_length[3]',
'errors' => [ 'errors' => [
'required' => 'Branch Name is required', 'required' => 'Branch Name is required',
'regex_match' => 'Branch Name can only contain letters, numbers, spaces, hyphens(-), and underscores(_).', 'regex_match' => 'Branch Name can only contain letters, numbers, spaces, hyphens and underscores.',
] ]
], ],
'branch_code' => [ 'branch_code' => [
'rules' => 'required|regex_match[/^[a-zA-Z0-9_-]+$/]', 'rules' => 'required|regex_match[/^[a-zA-Z0-9_-]+$/]',
'errors' => [ 'errors' => [
'required' => 'Branch Code is required', 'required' => 'Branch Code is required',
'regex_match' => 'Branch Code can only contain letters, numbers, hyphens(-), and underscores(_).', 'regex_match' => 'Branch Code can only contain letters, numbers, hyphens and underscores.',
] ]
], ],
'address1' => [ 'address1' => [
@ -1747,23 +1825,34 @@ class ClientController extends AdminController
'rules' => 'permit_empty|string', 'rules' => 'permit_empty|string',
], ],
'state' => [ 'state' => [
'rules' => 'required|numeric', 'label' => 'State',
'errors' => ['required' => 'State is required'] 'rules' => 'required',
'errors' => ['required' => 'State is required.']
// 'rules' => 'required|regex_match[/^[a-zA-Z\s\-]+$/]',
// 'errors' => [
// 'required' => 'State is required.',
// 'regex_match' => 'State name can only contain letters, spaces, and hyphens.'
// ]
], ],
'district' => [ 'district' => [
'rules' => 'required', 'rules' => 'required|regex_match[/^[a-zA-Z0-9\s\-]+$/]',
'errors' => ['required' => 'District is required.'] 'errors' => [
'required' => 'District is required.',
'regex_match' => 'District can contain letters, numbers, spaces, and hyphens.'
]
], ],
'city' => [ 'city' => [
'rules' => 'required', 'rules' => 'required|regex_match[/^[a-zA-Z0-9\s\-]+$/]',
'errors' => ['required' => 'City is required.'] 'errors' => [
'regex_match' => 'City can contain letters, numbers, spaces, and hyphens.'
]
], ],
'pincode' => [ 'pincode' => [
'rules' => 'required|numeric|exact_length[6]', 'rules' => 'required|numeric|exact_length[6]',
'errors' => [ 'errors' => [
'required' => 'Pincode is required.', 'required' => 'Pincode is required.',
'numeric' => 'Pincode must be numeric', 'numeric' => 'Pincode must be digits only.',
'exact_length' => 'Pincode must be exactly 6 digits' 'exact_length' => 'Pincode must be exactly 6 digits.'
] ]
], ],
'gst' => [ 'gst' => [
@ -2120,15 +2209,20 @@ class ClientController extends AdminController
$rules = [ $rules = [
'branch_name' => [ 'branch_name' => [
'rules' => 'required', 'rules' => 'required|min_length[3]|regex_match[/^[a-zA-Z0-9\s\-_]+$/]',
'errors' => [ 'errors' => [
'required' => 'Branch Name is required', 'required' => 'Branch Name is required',
'min_length' => 'Branch Name must be at least 3 characters long',
'regex_match' => 'Branch Name can only contain letters, numbers, spaces, hyphens and underscores.'
] ]
], ],
'branch_code' => [ 'branch_code' => [
'rules' => 'required', // Note: Codes usually don't have spaces, but I've included the others
'rules' => 'required|min_length[2]|regex_match[/^[a-zA-Z0-9\-_]+$/]',
'errors' => [ 'errors' => [
'required' => 'Branch Code is required', 'required' => 'Branch Code is required',
'min_length' => 'Branch Code must be at least 2 characters long',
'regex_match' => 'Branch Code can only contain letters, numbers, hyphens and underscores.'
] ]
], ],
'address1' => [ 'address1' => [
@ -2138,29 +2232,35 @@ class ClientController extends AdminController
] ]
], ],
'state' => [ 'state' => [
'rules' => 'required', 'label' => 'State',
'errors' => [ // 'rules' => 'required|regex_match[/^[a-zA-Z\s\-]+$/]',
'required' => 'State is required', 'rules' => 'required',
] 'errors' => [
], 'required' => 'State is required.',
'district' => [ // 'regex_match' => 'State name can only contain letters, spaces, and hyphens.'
'rules' => 'required', ]
'errors' => [ ],
'required' => 'District is required.', 'district' => [
] 'rules' => 'required|regex_match[/^[a-zA-Z0-9\s\-]+$/]',
], 'errors' => [
'city' => [ 'required' => 'District is required.',
'rules' => 'required', 'regex_match' => 'District can contain letters, numbers, spaces, and hyphens.'
'errors' => [ ]
'required' => 'City is required.', ],
] 'city' => [
], 'rules' => 'required|regex_match[/^[a-zA-Z0-9\s\-]+$/]',
'pincode' => [ 'errors' => [
'rules' => 'required', 'regex_match' => 'City can contain letters, numbers, spaces, and hyphens.'
'errors' => [ ]
'required' => 'Pincode is required.', ],
] 'pincode' => [
], 'rules' => 'required|numeric|exact_length[6]',
'errors' => [
'required' => 'Pincode is required.',
'numeric' => 'Pincode must be digits only.',
'exact_length' => 'Pincode must be exactly 6 digits.'
]
],
'gst' => [ 'gst' => [
'rules' => 'required|regex_match[/^\d{2}[A-Z]{5}\d{4}[A-Z]{1}[A-Z\d]{1}Z[A-Z\d]{1}$/]', 'rules' => 'required|regex_match[/^\d{2}[A-Z]{5}\d{4}[A-Z]{1}[A-Z\d]{1}Z[A-Z\d]{1}$/]',
'errors' => [ 'errors' => [
@ -2169,10 +2269,11 @@ class ClientController extends AdminController
] ]
], ],
'name.*' => [ 'name.*' => [
'rules' => 'required|alpha_space', 'rules' => 'required|min_length[3]|regex_match[/^[a-zA-Z0-9\s\-_]+$/]',
'errors' => [ 'errors' => [
'required' => 'Contact name is required', 'required' => 'Contact name is required',
'alpha_space' => 'Contact name may contain only letters and spaces' 'min_length' => 'Contact name must be at least 3 characters long',
'regex_match' => 'Contact name can only contain letters, numbers, spaces, hyphens and underscores.'
] ]
], ],
'designation.*' => [ 'designation.*' => [
@ -2294,6 +2395,104 @@ class ClientController extends AdminController
$client_id = $this->request->getPost('client_id'); $client_id = $this->request->getPost('client_id');
$pre_branch_id = $this->request->getPost('pre_branch_id') ?? ''; $pre_branch_id = $this->request->getPost('pre_branch_id') ?? '';
$rules = [
'branch_name' => [
'rules' => 'required|min_length[3]|regex_match[/^[a-zA-Z0-9\s\-_]+$/]',
'errors' => [
'required' => 'Branch Name is required',
'min_length' => 'Branch Name must be at least 3 characters long',
'regex_match' => 'Branch Name can only contain letters, numbers, spaces, hyphens and underscores.'
]
],
'branch_code' => [
// Note: Codes usually don't have spaces, but I've included the others
'rules' => 'required|min_length[2]|regex_match[/^[a-zA-Z0-9\-_]+$/]',
'errors' => [
'required' => 'Branch Code is required',
'min_length' => 'Branch Code must be at least 2 characters long',
'regex_match' => 'Branch Code can only contain letters, numbers, hyphens and underscores.'
]
],
'address1' => [
'rules' => 'required',
'errors' => [
'required' => 'Address Line 1 is required',
]
],
'state' => [
'label' => 'State',
'rules' => 'required',
'errors' => ['required' => 'State is required.']
],
'district' => [
'rules' => 'required|regex_match[/^[a-zA-Z0-9\s\-]+$/]',
'errors' => [
'required' => 'District is required.',
'regex_match' => 'District can contain letters, numbers, spaces, and hyphens.'
]
],
'city' => [
'rules' => 'required|regex_match[/^[a-zA-Z0-9\s\-]+$/]',
'errors' => [
'regex_match' => 'City can contain letters, numbers, spaces, and hyphens.'
]
],
'pincode' => [
'rules' => 'required|numeric|exact_length[6]',
'errors' => [
'required' => 'Pincode is required.',
'numeric' => 'Pincode must be digits only.',
'exact_length' => 'Pincode must be exactly 6 digits.'
]
],
'gst' => [
'rules' => 'required|regex_match[/^\d{2}[A-Z]{5}\d{4}[A-Z]{1}[A-Z\d]{1}Z[A-Z\d]{1}$/]',
'errors' => [
'required' => 'GST number is required',
'regex_match' => 'Invalid GST Number. Example: 12ABCDE1234F5Z6'
]
],
'name.*' => [
'rules' => 'required|min_length[3]|regex_match[/^[a-zA-Z0-9\s\-_]+$/]',
'errors' => [
'required' => 'Contact name is required',
'min_length' => 'Contact name must be at least 3 characters long',
'regex_match' => 'Contact name can only contain letters, numbers, spaces, hyphens and underscores.'
]
],
'designation.*' => [
'rules' => 'required|alpha_space',
'errors' => [
'required' => 'Designation is required',
'alpha_space' => 'Designation may contain only letters and spaces'
]
],
'email.*' => [
'rules' => 'required|regex_match[/^[a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,}$/]',
'errors' => [
'required' => 'Email address is required.',
'regex_match' => 'Please enter a valid email format (e.g., name@domain.com).'
]
],
'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'
]
],
];
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(); $data = $this->request->getPost();
$data = sanitizeInputArrayAdvanced($data); $data = sanitizeInputArrayAdvanced($data);
$data['pre_branch_id'] = $pre_branch_id; $data['pre_branch_id'] = $pre_branch_id;
@ -2486,13 +2685,12 @@ class ClientController extends AdminController
$sanitized_post_data = sanitizeInputArrayAdvanced($request_post_data); $sanitized_post_data = sanitizeInputArrayAdvanced($request_post_data);
$rules = [ $rules = [
// --- BASIC SELECTS (Required) ---
'client_branch_id' => [ 'client_branch_id' => [
'rules' => 'required', 'rules' => 'required',
'errors' => ['required' => 'Please select a Client Branch.'] 'errors' => ['required' => 'Please select a Client Branch.']
], ],
'policy_type_id' => [ 'policy_type_id' => [
'rules' => 'required|is_natural_no_zero', 'rules' => ['required', 'is_natural_no_zero'],
'errors' => [ 'errors' => [
'required' => 'Policy Type is required.', 'required' => 'Policy Type is required.',
'is_natural_no_zero' => 'Please select a valid Policy Type.' 'is_natural_no_zero' => 'Please select a valid Policy Type.'
@ -2506,17 +2704,20 @@ class ClientController extends AdminController
'rules' => 'required', 'rules' => 'required',
'errors' => ['required' => 'Please select a TPA.'] 'errors' => ['required' => 'Please select a TPA.']
], ],
// --- TEXT FIELDS (Required & Specific Format) ---
'policy_no' => [ 'policy_no' => [
'rules' => 'required|regex_match[/^[a-zA-Z0-9\s_\-\/\\\]+$/]', 'rules' => ['required', 'regex_match[/^[a-zA-Z0-9\s_\-\/\\\]+$/]'],
'errors' => [ 'errors' => [
'required' => 'This field is required.', 'required' => 'Policy No is required.',
'regex_match' => 'Only letters, numbers, spaces, _, -, /, and \ are allowed.' 'regex_match' => 'Invalid characters in Policy No.'
] ]
], ],
'gst' => [ 'gst' => [
'rules' => 'required|numeric|greater_than_equal_to[0]|less_than_equal_to[100]', 'rules' => [
'required',
'numeric',
'greater_than_equal_to[0]',
'less_than_equal_to[100]'
],
'errors' => [ 'errors' => [
'required' => 'GST percentage is required.', 'required' => 'GST percentage is required.',
'numeric' => 'GST must be a valid number.', 'numeric' => 'GST must be a valid number.',
@ -2524,45 +2725,47 @@ class ClientController extends AdminController
'less_than_equal_to' => 'GST percentage cannot exceed 100%.' 'less_than_equal_to' => 'GST percentage cannot exceed 100%.'
] ]
], ],
// --- DATE FIELDS (Required) ---
'policy_start_date' => [ 'policy_start_date' => [
'rules' => 'required', 'rules' => 'required',
'errors' => [ 'errors' => ['required' => 'Start date is required.']
'required' => 'Start date is required.',
]
], ],
'policy_end_date' => [ 'policy_end_date' => [
'rules' => 'required', 'rules' => 'required',
'errors' => [ 'errors' => ['required' => 'End date is required.']
'required' => 'End date is required.',
]
],
// --- PERMIT EMPTY FIELDS (Optional) ---
'base_policy' => [
'rules' => 'permit_empty'
], ],
'wellness_plan_id' => [ 'wellness_plan_id' => [
'rules' => 'permit_empty|alpha_numeric', 'rules' => 'permit_empty|alpha_numeric',
'errors' => [ 'errors' => ['alpha_numeric' => 'Wellness Plan ID can only contain letters and numbers.']
'alpha_numeric' => 'Wellness Plan ID can only contain letters and numbers (no spaces or special characters).'
]
], ],
'wellness_vendor_id' => [ 'wellness_vendor_id' => [
'rules' => 'permit_empty' 'rules' => 'permit_empty'
], ],
'disclaimer' => [ 'disclaimer' => [
'rules' => 'permit_empty|string|min_length[5]', 'rules' => ['permit_empty', 'string', 'min_length[5]'],
'errors' => ['min_length' => 'Disclaimer should be at least 5 characters long if provided.'] 'errors' => ['min_length' => 'Disclaimer should be at least 5 characters long if provided.']
], ],
// --- CHECKBOXES (Permit Empty) ---
'enrolment_visibility' => ['rules' => 'permit_empty'], 'enrolment_visibility' => ['rules' => 'permit_empty'],
'is_lgbtq' => ['rules' => 'permit_empty'] 'is_lgbtq' => ['rules' => 'permit_empty']
]; ];
if (!$this->validate($rules)) { // 2. Run the initial validation
$isValid = $this->validate($rules);
// 3. Perform manual date comparison
$start = $this->request->getPost('policy_start_date');
$end = $this->request->getPost('policy_end_date');
$startDate = change_date_format($start ?? null, 'd-m-Y', 'Y-m-d') ?? null;
$endDate = change_date_format($end ?? null, 'd-m-Y', 'Y-m-d') ?? null;
if ($startDate && $endDate && ($endDate < $startDate)) {
// Manually push the error into the validator
$this->validator->setError('policy_end_date', 'Policy start and end date are mismatched (End date cannot be before Start date).');
$isValid = false;
}
// 4. Check final status
if (!$isValid) {
return $this->response->setStatusCode(400)->setJSON([ return $this->response->setStatusCode(400)->setJSON([
'status' => false, 'status' => false,
'message' => 'Input validation failed', 'message' => 'Input validation failed',
@ -2669,13 +2872,12 @@ class ClientController extends AdminController
public function editClientPolicy() public function editClientPolicy()
{ {
$rules = [ $rules = [
// --- BASIC SELECTS (Required) ---
'client_branch_id' => [ 'client_branch_id' => [
'rules' => 'required', 'rules' => 'required',
'errors' => ['required' => 'Please select a Client Branch.'] 'errors' => ['required' => 'Please select a Client Branch.']
], ],
'policy_type_id' => [ 'policy_type_id' => [
'rules' => 'required|is_natural_no_zero', 'rules' => ['required', 'is_natural_no_zero'],
'errors' => [ 'errors' => [
'required' => 'Policy Type is required.', 'required' => 'Policy Type is required.',
'is_natural_no_zero' => 'Please select a valid Policy Type.' 'is_natural_no_zero' => 'Please select a valid Policy Type.'
@ -2689,17 +2891,20 @@ class ClientController extends AdminController
'rules' => 'required', 'rules' => 'required',
'errors' => ['required' => 'Please select a TPA.'] 'errors' => ['required' => 'Please select a TPA.']
], ],
// --- TEXT FIELDS (Required & Specific Format) ---
'policy_no' => [ 'policy_no' => [
'rules' => 'required|regex_match[/^[a-zA-Z0-9\s_\-\/\\\]+$/]', 'rules' => ['required', 'regex_match[/^[a-zA-Z0-9\s_\-\/\\\]+$/]'],
'errors' => [ 'errors' => [
'required' => 'This field is required.', 'required' => 'Policy No is required.',
'regex_match' => 'Only letters, numbers, spaces, _, -, /, and \ are allowed.' 'regex_match' => 'Invalid characters in Policy No.'
] ]
], ],
'gst' => [ 'gst' => [
'rules' => 'required|numeric|greater_than_equal_to[0]|less_than_equal_to[100]', 'rules' => [
'required',
'numeric',
'greater_than_equal_to[0]',
'less_than_equal_to[100]'
],
'errors' => [ 'errors' => [
'required' => 'GST percentage is required.', 'required' => 'GST percentage is required.',
'numeric' => 'GST must be a valid number.', 'numeric' => 'GST must be a valid number.',
@ -2707,47 +2912,47 @@ class ClientController extends AdminController
'less_than_equal_to' => 'GST percentage cannot exceed 100%.' 'less_than_equal_to' => 'GST percentage cannot exceed 100%.'
] ]
], ],
// --- DATE FIELDS (Required) ---
'policy_start_date' => [ 'policy_start_date' => [
'rules' => 'required|valid_date', 'rules' => 'required',
'errors' => [ 'errors' => ['required' => 'Start date is required.']
'required' => 'Start date is required.',
'valid_date' => 'Enter a valid date format (YYYY-MM-DD).'
]
], ],
'policy_end_date' => [ 'policy_end_date' => [
'rules' => 'required|valid_date', 'rules' => 'required',
'errors' => [ 'errors' => ['required' => 'End date is required.']
'required' => 'End date is required.',
'valid_date' => 'Enter a valid date format (YYYY-MM-DD).'
]
],
// --- PERMIT EMPTY FIELDS (Optional) ---
'base_policy' => [
'rules' => 'permit_empty'
], ],
'wellness_plan_id' => [ 'wellness_plan_id' => [
'rules' => 'permit_empty|alpha_numeric', 'rules' => 'permit_empty|alpha_numeric',
'errors' => [ 'errors' => ['alpha_numeric' => 'Wellness Plan ID can only contain letters and numbers.']
'alpha_numeric' => 'Wellness Plan ID can only contain letters and numbers (no spaces or special characters).'
]
], ],
'wellness_vendor_id' => [ 'wellness_vendor_id' => [
'rules' => 'permit_empty' 'rules' => 'permit_empty'
], ],
'disclaimer' => [ 'disclaimer' => [
'rules' => 'permit_empty|string|min_length[5]', 'rules' => ['permit_empty', 'string', 'min_length[5]'],
'errors' => ['min_length' => 'Disclaimer should be at least 5 characters long if provided.'] 'errors' => ['min_length' => 'Disclaimer should be at least 5 characters long if provided.']
], ],
// --- CHECKBOXES (Permit Empty) ---
'enrolment_visibility' => ['rules' => 'permit_empty'], 'enrolment_visibility' => ['rules' => 'permit_empty'],
'is_lgbtq' => ['rules' => 'permit_empty'] 'is_lgbtq' => ['rules' => 'permit_empty']
]; ];
if (!$this->validate($rules)) { // 2. Run the initial validation
$isValid = $this->validate($rules);
// 3. Perform manual date comparison
$start = $this->request->getPost('policy_start_date');
$end = $this->request->getPost('policy_end_date');
$startDate = change_date_format($start ?? null, 'd-m-Y', 'Y-m-d') ?? null;
$endDate = change_date_format($end ?? null, 'd-m-Y', 'Y-m-d') ?? null;
if ($startDate && $endDate && ($endDate < $startDate)) {
// Manually push the error into the validator
$this->validator->setError('policy_end_date', 'Policy start and end date are mismatched (End date cannot be before Start date).');
$isValid = false;
}
// 4. Check final status
if (!$isValid) {
return $this->response->setStatusCode(400)->setJSON([ return $this->response->setStatusCode(400)->setJSON([
'status' => false, 'status' => false,
'message' => 'Input validation failed', 'message' => 'Input validation failed',

View File

@ -2770,7 +2770,7 @@ class EmployeeController extends AdminController
'rules' => 'required|regex_match[/^[a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,}$/]', 'rules' => 'required|regex_match[/^[a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,}$/]',
'errors' => [ 'errors' => [
'required' => 'Email address is required.', 'required' => 'Email address is required.',
'regex_match' => 'Please enter a valid email format (e.g., name@company.com).' 'regex_match' => 'Please enter a valid email format (e.g., name@domain.com).'
] ]
], ],
'mobile' => [ 'mobile' => [

View File

@ -79,7 +79,7 @@ class HealthIndiaApiController extends BaseController
]); ]);
} }
public function SubmitClaim($claimId = 515) public function SubmitClaim($claimId = 729)
{ {
helper('api'); helper('api');
@ -205,7 +205,7 @@ class HealthIndiaApiController extends BaseController
$response = call_third_party_api($url, 'POST', $headers, $body); $response = call_third_party_api($url, 'POST', $headers, $body);
dd($response); // dd($response);
log_message('error', 'TPA CLAIM PUSH HEALTH_INDIA RESPONSE | claimId: ' . $claimId . ' | response: ' . json_encode($response)); log_message('error', 'TPA CLAIM PUSH HEALTH_INDIA RESPONSE | claimId: ' . $claimId . ' | response: ' . json_encode($response));
@ -239,7 +239,7 @@ class HealthIndiaApiController extends BaseController
return; return;
} }
public function ClaimDetail($claimId = null) public function ClaimDetail($claimId = 729)
{ {
helper('api'); helper('api');
@ -284,6 +284,8 @@ class HealthIndiaApiController extends BaseController
$response = call_third_party_api($url, 'POST', $headers, $body); $response = call_third_party_api($url, 'POST', $headers, $body);
// dd($response);
log_message('error', 'CLAIM STATUS HEALTH_INDIA | claimId: ' . $claimId . ' | Response: ' . json_encode($response)); log_message('error', 'CLAIM STATUS HEALTH_INDIA | claimId: ' . $claimId . ' | Response: ' . json_encode($response));
if (empty($response['data']['result'][0])) { if (empty($response['data']['result'][0])) {
@ -368,9 +370,9 @@ class HealthIndiaApiController extends BaseController
$url = getenv('HEALTH_INDIA_BASE_URL') . "/Member/GetMemberEcard"; $url = getenv('HEALTH_INDIA_BASE_URL') . "/Member/GetMemberEcard";
$body = [ $body = [
"policY_NUMBER" => $policyNo, "policY_NUMBER" => $policyNo ,//'141600_POLICY_AWAITED',
"employeE_CODE" => $employeeId, "employeE_CODE" => $employeeId,//'DECP000',
"membeR_ID" => $memberId "membeR_ID" => $memberId//'19662410E',
]; ];
$headers = [ $headers = [
@ -416,8 +418,8 @@ class HealthIndiaApiController extends BaseController
try { try {
helper('api'); helper('api');
$policyNo = $requestData['policy_no'] ?? '141600_POLICY_AWAITED'; $policyNo = $requestData['policy_no'] ?? null; //'141600_POLICY_AWAITED';
$client_policy_id = $requestData['client_policy_id'] ?? 6473; $client_policy_id = $requestData['client_policy_id'] ?? null; // 6473;
@ -442,24 +444,24 @@ class HealthIndiaApiController extends BaseController
log_message('error', "TPA ID PULL HEALTH_INDIA | called for policy_no: {$policyNo}, client_policy_id: {$client_policy_id}"); log_message('error', "TPA ID PULL HEALTH_INDIA | called for policy_no: {$policyNo}, client_policy_id: {$client_policy_id}");
// Fetch file download dates // Fetch file download dates
// $batchFiles = $this->db->table('batch_files f') $batchFiles = $this->db->table('batch_files f')
// ->select("f.created_at") ->select("f.created_at")
// ->where('f.client_policy_id', $client_policy_id) ->where('f.client_policy_id', $client_policy_id)
// ->where('f.insurer_or_tpa', 'tpa') ->where('f.insurer_or_tpa', 'tpa')
// ->where('f.actions', 'export') ->where('f.actions', 'export')
// ->get() ->get()
// ->getResultArray(); ->getResultArray();
// if (empty($batchFiles)) { if (empty($batchFiles)) {
// log_message('error', 'TPA ID PULL FAILED HEALTH_INDIA | batchFiles is empty for this tpa id pull request'); log_message('error', 'TPA ID PULL FAILED HEALTH_INDIA | batchFiles is empty for this tpa id pull request');
// if ($function_calling_type == "job") { if ($function_calling_type == "job") {
// return ['status' => false, 'message' => 'batchFiles not found']; return ['status' => false, 'message' => 'batchFiles not found'];
// } else { } else {
// return $this->respond(['status' => false, 'message' => 'batchFiles not found']); return $this->respond(['status' => false, 'message' => 'batchFiles not found']);
// } }
// } }
// Generate Health India Token // Generate Health India Token
$tokenResponse = json_decode($this->generateAuthToken()->getBody(), true); $tokenResponse = json_decode($this->generateAuthToken()->getBody(), true);
@ -489,9 +491,9 @@ class HealthIndiaApiController extends BaseController
$response = call_third_party_api($url, 'POST', $headers, $body); $response = call_third_party_api($url, 'POST', $headers, $body);
dd($response); // dd($response);
log_message('error', "TPA ID PULL HEALTH_INDIA | API Response: " . json_encode($response)); log_message('error', "TPA ID PULL HEALTH_INDIA | API Response Received ");
if (($response['status'] ?? false) !== true) { if (($response['status'] ?? false) !== true) {
log_message('error', 'HEALTH_INDIA API FAILED | response: ' . json_encode($response)); log_message('error', 'HEALTH_INDIA API FAILED | response: ' . json_encode($response));
@ -560,11 +562,22 @@ class HealthIndiaApiController extends BaseController
$employeePolicyModel = new EmployeePolicyModel(); $employeePolicyModel = new EmployeePolicyModel();
$employeePolicyData = $employeePolicyModel $employeePolicyData = $employeePolicyModel
->join('employees', 'employees.id = employee_polices.employee_id') ->select('
->where('employee_polices.client_policy_id', $client_policy_id) employees.*,
->where('employee_polices.tpa_id IS NULL') employee_polices.id as emp_policy_id,
->findAll(); employee_polices.client_policy_id,
')
->join('employees', 'employees.id = employee_polices.employee_id')
->where('employee_polices.is_active', 1)
->where('employee_polices.status', 'active')
->where('employees.is_active', 1)
->where('employees.emp_status', 'active')
->where('employee_polices.tpa_id IS NULL')
->where('employee_polices.client_policy_id', $client_policy_id)
->findAll();
// echo (string) $employeePolicyModel->db->getLastQuery();
// dd($employeePolicyData);
$updated = 0; $updated = 0;
$batch_file_success = 'success'; $batch_file_success = 'success';
@ -575,10 +588,15 @@ class HealthIndiaApiController extends BaseController
foreach ($allMembers as $m) { foreach ($allMembers as $m) {
// Match based on: employee name, employee code, and relation // Match based on: employee name, employee code, and relation
if($m['relation'] == 'Employee') { $relation = 'self'; }
else if($m['relation'] == 'WIFE') { $relation = 'spouse'; }
else { $relation = $m['relation']; }
if ( if (
strtolower(trim($policy['name'])) === strtolower(trim($m['insured_Name'] ?? '')) && strtolower(trim($policy['name'])) === strtolower(trim($m['insured_Name'] ?? '')) &&
($policy['emp_code'] ?? '') == ($m['employeeCode'] ?? '') && ($policy['emp_code'] ?? '') == ($m['employeeCode'] ?? '') &&
strtolower($policy['relationship']) === strtolower($m['relation'] ?? '') strtolower($policy['relationship']) === strtolower($relation ?? '')
) { ) {
$hasMatchForThisPolicy = true; $hasMatchForThisPolicy = true;

View File

@ -121,29 +121,29 @@ class ICICILombardController extends AdminController
$body = [ $body = [
"PolicyNumber" => "4016/PPN/A/O/53185987/00/000", "PolicyNumber" => "4016/PPN/A/O/53185987/00/000",
"CDBGAccountNumber" => "CD-MUM-0026", "CDBGAccountNumber" => "CD-MUM-0026",
"CorrelationId" => "550e8400-e29b-41d4-a716-446655440018", "CorrelationId" => "550e8400-e29b-41d4-a716-446655440022",
"MemberDetails" => [ "MemberDetails" => [
[ [
"MemberEmpId" => "EMPID3625562", "MemberEmpId" => "EMPID3625565",
"DOJ" => "21-MAR-2019", "DOJ" => "21-MAR-2019",
"InsuredName" => "Jeeva", "InsuredName" => "sanjeev",
"DOB" => "7-JUL-1993", "DOB" => "7-JUL-1993",
"Relationship" => "SELF", "Relationship" => "SELF",
"Gender" => "MALE", "Gender" => "MALE",
"DOC" => '19-Nov-2025', "DOC" => '25-Jan-2026',
"SumInsured" => "500000", "SumInsured" => "500000",
"EmailId" => "Jeeva@GMAIL.COM", "EmailId" => "sanjeev@GMAIL.COM",
"FlagStatus" => "A" "FlagStatus" => "A"
], ],
[ [
"MemberEmpId" => "EMPID3625562", "MemberEmpId" => "EMPID3625565",
"DOJ" => "21-MAR-2019", "DOJ" => "21-MAR-2019",
"InsuredName" => "Muthu", "InsuredName" => "bhavya",
"DOB" => "8-AUG-1970", "DOB" => "8-AUG-1970",
"Relationship" => "MOTHER", "Relationship" => "MOTHER",
"Gender" => "FEMALE", "Gender" => "FEMALE",
"DOC" => '19-Nov-2025', "DOC" => '25-Jan-2026',
"EmailId" => "Muthu@GMAIL.COM", "EmailId" => "bhavya@GMAIL.COM",
"FlagStatus" => "A" "FlagStatus" => "A"
], ],
] ]
@ -180,8 +180,8 @@ class ICICILombardController extends AdminController
$body = [ $body = [
"PolicyNumber" => "4016/PPN/A/O/53185987/00/000", "PolicyNumber" => "4016/PPN/A/O/53185987/00/000",
"BatchId" => "3725147", "BatchId" => "3728144",
"CorrelationId" => "550e8400-e29b-41d4-a716-446655440018" "CorrelationId" => "550e8400-e29b-41d4-a716-446655440022"
]; ];
$response = call_third_party_api($url, 'POST', $headers, $body, true); $response = call_third_party_api($url, 'POST', $headers, $body, true);
@ -213,9 +213,9 @@ class ICICILombardController extends AdminController
]; ];
$body = [ $body = [
"PolicyNumber" => "4016/PPN/A/O/53167743/00/000", "PolicyNumber" => "4016/PPN/A/O/53185987/00/000",
"IMID" => "201580517901", "IMID" => "201580517901",
"CorrelationId" => "550e8400-e29b-41d4-a716-446655440018" "CorrelationId" => "550e8400-e29b-41d4-a716-446655440022"
]; ];
$response = call_third_party_api($url, 'POST', $headers, $body, true); $response = call_third_party_api($url, 'POST', $headers, $body, true);

View File

@ -195,6 +195,10 @@ class JobWorker extends AdminController
'type' => 'CC', // Handler Category 'type' => 'CC', // Handler Category
'handler' => 'App\Controllers\FhplApiController', 'handler' => 'App\Controllers\FhplApiController',
], ],
'HealthIndiaGetBenefDetails' => [
'type' => 'CC', // Handler Category
'handler' => 'App\Controllers\HealthIndiaApiController',
],
'bdsDumpExcelFileFormatValidation' => [ 'bdsDumpExcelFileFormatValidation' => [
'type' => 'CC', // Handler Category 'type' => 'CC', // Handler Category
'handler' => 'App\Controllers\PolicyTransactionController', 'handler' => 'App\Controllers\PolicyTransactionController',

View File

@ -365,21 +365,10 @@ class LeadsController extends BaseController
{ {
// print_r($this->request->getPost()); die; // print_r($this->request->getPost()); die;
$id = $this->request->getPost('id'); $id = $this->request->getPost('id');
$postData = $this->request->getPost();
$data = $this->prepareLeadData(); $data = $this->prepareLeadData();
// print_r($data); die;
if (!$id) {
return $this->insertNewLead($data);
} else {
return $this->updateOldLead($id, $data);
}
}
private function prepareLeadData()
{
$rules = [ $rules = [
'lead_type' => [ 'lead_type' => [
'rules' => 'integer', 'rules' => 'integer',
'errors' => ['required' => 'Lead Type is required'] 'errors' => ['required' => 'Lead Type is required']
@ -396,16 +385,12 @@ class LeadsController extends BaseController
'rules' => 'required|regex_match[/^[a-zA-Z0-9_ -]+$/]', 'rules' => 'required|regex_match[/^[a-zA-Z0-9_ -]+$/]',
'errors' => [ 'errors' => [
'required' => 'Client Name is required', 'required' => 'Client Name is required',
'regex_match' => 'Client Name only letters, numbers and characters _ - and space are allowed' 'regex_match' => 'Client Name only letters, numbers, space, hyphens and underscores are allowed'
] ]
], ],
'client_short_name' => [ 'client_short_name' => [
'rules' => 'required|regex_match[/^[a-zA-Z0-9_-]+$/]', 'rules' => 'required|regex_match[/^[a-zA-Z0-9_-]+$/]',
'errors' => ['required' => 'Client Short Name is required','regex_match' => 'Client Short Name only letters, numbers and characters _ and - are allowed'] 'errors' => ['required' => 'Client Short Name is required','regex_match' => 'Client Short Name only letters, numbers, hyphens and underscores are allowed']
],
'gst' => [
'rules' => 'required',
'errors' => ['required' => 'GST Number is required']
], ],
'gst' => [ 'gst' => [
'rules' => 'required|regex_match[/^[0-9]{2}[A-Z]{5}[0-9]{4}[A-Z]{1}[1-9A-Z]{1}Z[0-9A-Z]{1}$/]', 'rules' => 'required|regex_match[/^[0-9]{2}[A-Z]{5}[0-9]{4}[A-Z]{1}[1-9A-Z]{1}Z[0-9A-Z]{1}$/]',
@ -418,7 +403,7 @@ class LeadsController extends BaseController
'rules' => 'required|regex_match[/^[a-zA-Z0-9\s_-]+$/]|min_length[3]', 'rules' => 'required|regex_match[/^[a-zA-Z0-9\s_-]+$/]|min_length[3]',
'errors' => [ 'errors' => [
'required' => 'Branch Name is required.', 'required' => 'Branch Name is required.',
'regex_match' => 'Branch Name can only contain letters, numbers, spaces, - and _.', 'regex_match' => 'Branch Name can only contain letters, numbers, spaces, hyphens and underscores..',
'min_length' => 'Branch Name must be at least 3 characters long.' 'min_length' => 'Branch Name must be at least 3 characters long.'
] ]
], ],
@ -426,21 +411,23 @@ class LeadsController extends BaseController
'rules' => 'required|regex_match[/^[a-zA-Z0-9_-]+$/]', 'rules' => 'required|regex_match[/^[a-zA-Z0-9_-]+$/]',
'errors' => [ 'errors' => [
'required' => 'Branch Code is required.', 'required' => 'Branch Code is required.',
'regex_match' => 'Branch Code can only contain letters, numbers, - and _.' 'regex_match' => 'Branch Code can only contain letters, numbers, hyphens and underscores..'
] ]
], ],
'contact_person_name' => [ 'contact_person_name' => [
'rules' => 'required|regex_match[/^[a-zA-Z0-9_ -]+$/]', 'rules' => 'required|regex_match[/^[a-zA-Z0-9_ -]+$/]',
'errors' => [ 'errors' => [
'required' => 'Contact Person Name is required', 'required' => 'Contact Person Name is required',
'regex_match' => 'Contact person name only letters, numbers and spaces, - and _.' 'regex_match' => 'Contact person name only letters, numbers and spaces, hyphens and underscores..'
] ]
], ],
'contact_person_mobile' => [ 'contact_person_mobile' => [
'rules' => 'required', 'rules' => 'required',
'rules' => 'required|regex_match[/^[0-9]+$/]', 'rules' => 'required|exact_length[10]|regex_match[/^[0-9]+$/]',
'errors' => ['required' => 'Contact Person Mobile is required' , 'errors' => [
'regex_match' => 'Contact Person Mobile Only numbers' 'required' => 'Contact Person Mobile is required' ,
'regex_match' => 'Contact Person Mobile Only numbers',
'exact_length'=> 'Contact Person Mobile must be exactly 10 digits long.'
] ]
], ],
'contact_person_email' => [ 'contact_person_email' => [
@ -462,9 +449,23 @@ class LeadsController extends BaseController
'errors' => ['required' => 'Status is required'] 'errors' => ['required' => 'Status is required']
] ]
]; ];
$request_data = $this->request->getPost();
$data = sanitizeInputArrayAdvanced($request_data); foreach ($postData as $key => $value) {
if (isset($data['lead_form_type']) && (int)$data['lead_form_type'] === 2) { // Check if the key starts with 'docs_name_'
if (strpos($key, 'docs_name_') === 0) {
$rules[$key . '.*'] = [
'label' => 'Document Name',
'rules' => 'permit_empty|regex_match[/^[a-zA-Z0-9_\- ]+$/]',
'errors' => [
'regex_match' => 'Document Name in {field} can only contain letters, numbers, hyphens, and underscores.'
]
];
}
}
// print_r($rules); die;
if ((int)$this->request->getPost('lead_form_type') === 2) {
$rules['client_type'] = [ $rules['client_type'] = [
'rules' => 'required', 'rules' => 'required',
'errors' => ['required' => 'Client Type is required'] 'errors' => ['required' => 'Client Type is required']
@ -481,6 +482,51 @@ class LeadsController extends BaseController
'rules' => 'required', 'rules' => 'required',
'errors' => ['required' => 'Date of Expiry is required'] 'errors' => ['required' => 'Date of Expiry is required']
]; ];
if ((int)$this->request->getPost('claim_history') === 1) {
$rules['first_year.*'] = [
'rules' => 'required|regex_match[/^\d{4}-\d{4}$/]',
'errors' => ['required' => 'Claim Year is required for all entries.','regex_match' => 'Year must be in format YYYY-YYYY.']
];
$rules['first_policy_type_.*'] = [
'rules' => 'required|regex_match[/^[a-zA-Z0-9_-]+$/]',
'errors' => ['required' => 'Policy Type is required in Claim History.',
'regex_match' => 'Policy Type only letters, numbers, space, hyphens and underscores are allowed'
]
];
$rules['first_date_of_loss_.*'] = [
'rules' => 'required|regex_match[/^[0-9]{2}-[0-9]{2}-[0-9]{4}$/]',
'errors' => ['required' => 'Date of Loss is required.',
'regex_match' => 'Date of Loss must be inValid format.']
];
$rules['first_cause_of_loss.*'] = [
'rules' => 'required|regex_match[/^[a-zA-Z0-9\s_-]+$/]',
'errors' => [
'required' => 'Cause of Loss is required.',
'regex_match' => 'Cause of Loss only letters, numbers, space, hyphens and underscores are allowed'
]
];
$rules['first_claim_amount.*'] = [
'rules' => 'required|numeric',
'errors' => [
'required' => 'Claim Amount is required.',
'numeric' => 'Claim Amount must be a number.'
]
];
$rules['first_settled_amount.*'] = [
'rules' => 'required|numeric',
'errors' => ['required' => 'Settled Amount is required.',
'numeric' => 'Settled Amount must be a number.']
];
$rules['first_claim_status.*'] = [
'rules' => 'required|alpha_space',
'errors' => [
'required' => 'Claim Status is required.',
'alpha_space' => 'Claim Status should only contain letters and spaces.'
]
];
}
} }
// 1. MANUALLY VALIDATE FILES BEFORE PROCESSING // 1. MANUALLY VALIDATE FILES BEFORE PROCESSING
@ -515,7 +561,41 @@ class LeadsController extends BaseController
// } // }
// } // }
if (!$this->validate($rules)) {
$isValid = $this->validate($rules);
$start_dates = $this->request->getPost('policy_start_date');
$end_dates = $this->request->getPost('policy_end_date');
if ($start_dates && $end_dates) {
$starts = is_array($start_dates) ? $start_dates : [$start_dates];
$ends = is_array($end_dates) ? $end_dates : [$end_dates];
foreach ($starts as $index => $s_date) {
$e_date = $ends[$index] ?? null;
if ($s_date && $e_date) {
$f_start = change_date_format($s_date, 'd/m/Y', 'Y-m-d');
$f_end = change_date_format($e_date, 'd/m/Y', 'Y-m-d');
if ($f_start && $f_end && ($f_end < $f_start)) {
$isValid = false;
// Determine the error key name
// If it's an array, we use index (e.g., policy_end_date.0)
$errorKey = is_array($start_dates) ? "policy_end_date.$index" : "policy_end_date";
$this->validator->setError($errorKey, 'Date of Expiry cannot be before Date of Commencement.');
}
}
}
}
if (!$isValid) {
return $this->response->setStatusCode(400)->setJSON([ return $this->response->setStatusCode(400)->setJSON([
'status' => false, 'status' => false,
'message' => 'Input validation failed', 'message' => 'Input validation failed',
@ -524,8 +604,23 @@ class LeadsController extends BaseController
]); ]);
} }
// print_r($data); die;
if (!$id) {
return $this->insertNewLead($data);
} else {
return $this->updateOldLead($id, $data);
}
}
private function prepareLeadData()
{
$request_data = $this->request->getPost();
$data = sanitizeInputArrayAdvanced($request_data);
$data['client_type'] = 1; $data['client_type'] = 1;
$data['pan'] = ""; $data['pan'] = "";
@ -793,7 +888,7 @@ class LeadsController extends BaseController
'source_policy_end_date' => $data['source_policy_end_date'] ?? null, 'source_policy_end_date' => $data['source_policy_end_date'] ?? null,
'claim_history' => $data['claim_history'] ?? 0, 'claim_history' => $data['claim_history'] ?? 0,
'next_reminder_date' => $data['next_reminder_date'] ?? 0, 'next_reminder_date' => $data['next_reminder_date'] ?? null,
'is_insurer_auto_mail' => $data['is_insurer_auto_mail'] ?? 0 'is_insurer_auto_mail' => $data['is_insurer_auto_mail'] ?? 0
]; ];
} }

View File

@ -254,7 +254,7 @@ class MasterController extends AdminController
$this->myLogger->logme('error','Insurer Onboarding function called'); $this->myLogger->logme('error','Insurer Onboarding function called');
$headerData['tab_name'] = 'Insurer Masters'; $headerData['tab_name'] = 'Insurer Masters';
$headerData['page_name'] = 'Insurers'; $headerData['page_name'] = 'Insurers';
$types = array( $types = array(
(object) array('id' => 'pvt', 'name' => 'PVT'), (object) array('id' => 'pvt', 'name' => 'PVT'),
(object) array('id' => 'psu', 'name' => 'PSU') (object) array('id' => 'psu', 'name' => 'PSU')
@ -284,29 +284,78 @@ class MasterController extends AdminController
$this->myLogger->logme('error','Insurer general info function called'); $this->myLogger->logme('error','Insurer general info function called');
$rules = [ $rules = [
'name' => [ 'name' => [
'rules' => 'required', 'label' => 'Insurer Name',
'errors' => [ 'rules' => ['required', 'regex_match[/^[a-zA-Z0-9\s\-_]+$/]'],
'required' => 'Name is required' 'errors' => [
] 'required' => 'Insurer Name is required.',
], 'regex_match' => 'Insurer Name can only contain letters, numbers, spaces, hyphens, and underscores.',
'short_name' => [ ]
'rules' => 'required|min_length[3]|max_length[8]', ],
'errors' => [ 'short_name' => [
'required' => 'Short name is required', 'label' => 'Insurer Short Name',
'min_length' => 'Short name must be at least 3 characters', 'rules' => ['required', 'regex_match[/^[a-zA-Z0-9\-_]+$/]'],
'max_length' => 'Short name cannot exceed 8 characters' 'errors' => [
] 'required' => 'Short Name is required.',
], 'regex_match' => 'Short Name can only contain letters, numbers, hyphens, and underscores.',
'insurer_logo' => [ ]
],
'type' => [
'label' => 'Insurer Type',
'rules' => 'permit_empty|in_list[pvt,psu]',
'errors' => [
'in_list' => 'Please select a valid Insurer Type (PVT or PSU).'
]
],
'category' => [
'label' => 'Insurer Category',
'rules' => 'permit_empty|in_list[life,general]',
'errors' => [
'in_list' => 'Please select a valid Category (Life or General).'
]
],
'addition_add_day' => [
'rules' => 'permit_empty' // Checkboxes return null if unchecked
],
'deletion_add_day' => [
'rules' => 'permit_empty'
],
'is_multi_event' => [
'rules' => 'permit_empty'
],
'insurer_logo' => [
'rules' => 'if_exist|is_image[insurer_logo]|max_size[insurer_logo,200]|ext_in[insurer_logo,jpg,jpeg,png]', 'rules' => 'if_exist|is_image[insurer_logo]|max_size[insurer_logo,200]|ext_in[insurer_logo,jpg,jpeg,png]',
'errors' => [ 'errors' => [
'is_image' => 'The uploaded file must be an image', 'is_image' => 'The uploaded file must be an image',
'max_size' => 'File size should not exceed 200 KB', 'max_size' => 'File size should not exceed 200 KB',
'ext_in' => 'Allowed file types: jpg, jpeg, png', 'ext_in' => 'Allowed file types: jpg, jpeg, png',
] ]
], ],
]; ];
// $rules = [
// 'name' => [
// 'rules' => 'required',
// 'errors' => [
// 'required' => 'Name is required'
// ]
// ],
// 'short_name' => [
// 'rules' => 'required|min_length[3]|max_length[8]',
// 'errors' => [
// 'required' => 'Short name is required',
// 'min_length' => 'Short name must be at least 3 characters',
// 'max_length' => 'Short name cannot exceed 8 characters'
// ]
// ],
// 'insurer_logo' => [
// 'rules' => 'if_exist|is_image[insurer_logo]|max_size[insurer_logo,200]|ext_in[insurer_logo,jpg,jpeg,png]',
// 'errors' => [
// 'is_image' => 'The uploaded file must be an image',
// 'max_size' => 'File size should not exceed 200 KB',
// 'ext_in' => 'Allowed file types: jpg, jpeg, png',
// ]
// ],
// ];
if (!$this->validate($rules)) { if (!$this->validate($rules)) {
return $this->response->setStatusCode(400)->setJSON([ return $this->response->setStatusCode(400)->setJSON([
@ -370,34 +419,34 @@ class MasterController extends AdminController
], ],
'state' => [ 'state' => [
'rules' => 'required|is_natural_no_zero', 'label' => 'State',
'errors' => [ 'rules' => 'required|regex_match[/^[a-zA-Z\s\-]+$/]',
'required' => 'State is required' 'errors' => [
] 'required' => 'State is required.',
], 'regex_match' => 'State name can only contain letters, spaces, and hyphens.'
]
'district' => [ ],
'rules' => 'required|trim', 'district' => [
'errors' => [ 'rules' => 'required|regex_match[/^[a-zA-Z0-9\s\-]+$/]',
'required' => 'District is required' 'errors' => [
] 'required' => 'District is required.',
], 'regex_match' => 'District can contain letters, numbers, spaces, and hyphens.'
]
'city' => [ ],
'rules' => 'required|trim', 'city' => [
'errors' => [ 'rules' => 'required|regex_match[/^[a-zA-Z0-9\s\-]+$/]',
'required' => 'City is required' 'errors' => [
] 'regex_match' => 'City can contain letters, numbers, spaces, and hyphens.'
], ]
],
'pincode' => [ 'pincode' => [
'rules' => 'required|numeric|exact_length[6]', 'rules' => 'required|numeric|exact_length[6]',
'errors' => [ 'errors' => [
'required' => 'Pincode is required', 'required' => 'Pincode is required.',
'numeric' => 'Pincode must contain only numbers', 'numeric' => 'Pincode must be digits only.',
'exact_length' => 'Pincode must be exactly 6 digits' 'exact_length' => 'Pincode must be exactly 6 digits.'
] ]
], ],
// ====================== // ======================
// Contact Details (Array) // Contact Details (Array)
@ -422,7 +471,7 @@ class MasterController extends AdminController
'rules' => 'required|regex_match[/^[a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,}$/]', 'rules' => 'required|regex_match[/^[a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,}$/]',
'errors' => [ 'errors' => [
'required' => 'Email address is required.', 'required' => 'Email address is required.',
'regex_match' => 'Please enter a valid email format (e.g., name@company.com).' 'regex_match' => 'Please enter a valid email format (e.g., name@domain.com).'
] ]
], ],
@ -611,34 +660,34 @@ class MasterController extends AdminController
], ],
'state' => [ 'state' => [
'rules' => 'required|is_natural_no_zero', 'label' => 'State',
'errors' => [ 'rules' => 'required|regex_match[/^[a-zA-Z\s\-]+$/]',
'required' => 'State is required' 'errors' => [
] 'required' => 'State is required.',
], 'regex_match' => 'State name can only contain letters, spaces, and hyphens.'
]
'district' => [ ],
'rules' => 'required|trim', 'district' => [
'errors' => [ 'rules' => 'required|regex_match[/^[a-zA-Z0-9\s\-]+$/]',
'required' => 'District is required' 'errors' => [
] 'required' => 'District is required.',
], 'regex_match' => 'District can contain letters, numbers, spaces, and hyphens.'
]
'city' => [ ],
'rules' => 'required|trim', 'city' => [
'errors' => [ 'rules' => 'required|regex_match[/^[a-zA-Z0-9\s\-]+$/]',
'required' => 'City is required' 'errors' => [
] 'regex_match' => 'City can contain letters, numbers, spaces, and hyphens.'
], ]
],
'pincode' => [ 'pincode' => [
'rules' => 'required|numeric|exact_length[6]', 'rules' => 'required|numeric|exact_length[6]',
'errors' => [ 'errors' => [
'required' => 'Pincode is required', 'required' => 'Pincode is required.',
'numeric' => 'Pincode must contain only numbers', 'numeric' => 'Pincode must be digits only.',
'exact_length' => 'Pincode must be exactly 6 digits' 'exact_length' => 'Pincode must be exactly 6 digits.'
] ]
], ],
// ====================== // ======================
// Contact Details (Array) // Contact Details (Array)
@ -662,7 +711,7 @@ class MasterController extends AdminController
'rules' => 'required|regex_match[/^[a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,}$/]', 'rules' => 'required|regex_match[/^[a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,}$/]',
'errors' => [ 'errors' => [
'required' => 'Email address is required.', 'required' => 'Email address is required.',
'regex_match' => 'Please enter a valid email format (e.g., name@company.com).' 'regex_match' => 'Please enter a valid email format (e.g., name@domain.com).'
] ]
], ],
@ -1007,34 +1056,34 @@ class MasterController extends AdminController
], ],
'state' => [ 'state' => [
'rules' => 'required|is_natural_no_zero', 'label' => 'State',
'errors' => [ 'rules' => 'required|regex_match[/^[a-zA-Z\s\-]+$/]',
'required' => 'State is required' 'errors' => [
] 'required' => 'State is required.',
], 'regex_match' => 'State name can only contain letters, spaces, and hyphens.'
]
'district' => [ ],
'rules' => 'required|trim', 'district' => [
'errors' => [ 'rules' => 'required|regex_match[/^[a-zA-Z0-9\s\-]+$/]',
'required' => 'District is required' 'errors' => [
] 'required' => 'District is required.',
], 'regex_match' => 'District can contain letters, numbers, spaces, and hyphens.'
]
'city' => [ ],
'rules' => 'required|trim', 'city' => [
'errors' => [ 'rules' => 'required|regex_match[/^[a-zA-Z0-9\s\-]+$/]',
'required' => 'City is required' 'errors' => [
] 'regex_match' => 'City can contain letters, numbers, spaces, and hyphens.'
], ]
],
'pincode' => [ 'pincode' => [
'rules' => 'required|numeric|exact_length[6]', 'rules' => 'required|numeric|exact_length[6]',
'errors' => [ 'errors' => [
'required' => 'Pincode is required', 'required' => 'Pincode is required.',
'numeric' => 'Pincode must contain only numbers', 'numeric' => 'Pincode must be digits only.',
'exact_length' => 'Pincode must be exactly 6 digits' 'exact_length' => 'Pincode must be exactly 6 digits.'
] ]
], ],
// ====================== // ======================
// Contact Details (Array) // Contact Details (Array)
@ -1058,7 +1107,7 @@ class MasterController extends AdminController
'rules' => 'required|regex_match[/^[a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,}$/]', 'rules' => 'required|regex_match[/^[a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,}$/]',
'errors' => [ 'errors' => [
'required' => 'Email address is required.', 'required' => 'Email address is required.',
'regex_match' => 'Please enter a valid email format (e.g., name@company.com).' 'regex_match' => 'Please enter a valid email format (e.g., name@domain.com).'
] ]
], ],
@ -1320,35 +1369,34 @@ class MasterController extends AdminController
], ],
'state' => [ 'state' => [
'rules' => 'required|is_natural_no_zero', 'label' => 'State',
'errors' => [ 'rules' => 'required|regex_match[/^[a-zA-Z\s\-]+$/]',
'required' => 'State is required' 'errors' => [
] 'required' => 'State is required.',
], 'regex_match' => 'State name can only contain letters, spaces, and hyphens.'
]
'district' => [ ],
'rules' => 'required|trim', 'district' => [
'errors' => [ 'rules' => 'required|regex_match[/^[a-zA-Z0-9\s\-]+$/]',
'required' => 'District is required' 'errors' => [
] 'required' => 'District is required.',
], 'regex_match' => 'District can contain letters, numbers, spaces, and hyphens.'
]
'city' => [ ],
'rules' => 'required|trim', 'city' => [
'errors' => [ 'rules' => 'required|regex_match[/^[a-zA-Z0-9\s\-]+$/]',
'required' => 'City is required' 'errors' => [
] 'regex_match' => 'City can contain letters, numbers, spaces, and hyphens.'
], ]
],
'pincode' => [ 'pincode' => [
'rules' => 'required|numeric|exact_length[6]', 'rules' => 'required|numeric|exact_length[6]',
'errors' => [ 'errors' => [
'required' => 'Pincode is required', 'required' => 'Pincode is required.',
'numeric' => 'Pincode must contain only numbers', 'numeric' => 'Pincode must be digits only.',
'exact_length' => 'Pincode must be exactly 6 digits' 'exact_length' => 'Pincode must be exactly 6 digits.'
] ]
], ],
// ====================== // ======================
// Contact Details (Array) // Contact Details (Array)
// ====================== // ======================
@ -1371,7 +1419,7 @@ class MasterController extends AdminController
'rules' => 'required|regex_match[/^[a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,}$/]', 'rules' => 'required|regex_match[/^[a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,}$/]',
'errors' => [ 'errors' => [
'required' => 'Email address is required.', 'required' => 'Email address is required.',
'regex_match' => 'Please enter a valid email format (e.g., name@company.com).' 'regex_match' => 'Please enter a valid email format (e.g., name@domain.com).'
] ]
], ],
@ -3522,7 +3570,7 @@ class MasterController extends AdminController
'rules' => 'required|regex_match[/^[a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,}$/]', 'rules' => 'required|regex_match[/^[a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,}$/]',
'errors' => [ 'errors' => [
'required' => 'Email address is required.', 'required' => 'Email address is required.',
'regex_match' => 'Please enter a valid email format (e.g., name@company.com).' 'regex_match' => 'Please enter a valid email format (e.g., name@domain.com).'
] ]
], ],
'mobile' => [ 'mobile' => [
@ -3540,28 +3588,28 @@ class MasterController extends AdminController
'min_length' => 'Address must be at least 5 characters' 'min_length' => 'Address must be at least 5 characters'
] ]
], ],
'city' => [
'rules' => 'required|alpha_space',
'errors' => [
'required' => 'City is required',
'alpha_space' => 'City must contain only letters and spaces'
]
],
'state' => [ 'state' => [
'rules' => 'required|alpha_space', 'label' => 'State',
'errors' => [ 'rules' => 'required|regex_match[/^[a-zA-Z\s\-]+$/]',
'required' => 'State is required', 'errors' => [
'alpha_space' => 'State must contain only letters and spaces' 'required' => 'State is required.',
] 'regex_match' => 'State name can only contain letters, spaces, and hyphens.'
], ]
'pincode' => [ ],
'rules' => 'required|numeric|exact_length[6]', 'city' => [
'errors' => [ 'rules' => 'required|regex_match[/^[a-zA-Z0-9\s\-]+$/]',
'required' => 'Pincode is required', 'errors' => [
'numeric' => 'Pincode must contain only digits', 'regex_match' => 'City can contain letters, numbers, spaces, and hyphens.'
'exact_length' => 'Pincode must be exactly 6 digits' ]
] ],
], 'pincode' => [
'rules' => 'required|numeric|exact_length[6]',
'errors' => [
'required' => 'Pincode is required.',
'numeric' => 'Pincode must be digits only.',
'exact_length' => 'Pincode must be exactly 6 digits.'
]
],
'aadhar' => [ 'aadhar' => [
'rules' => 'required|numeric|exact_length[12]', 'rules' => 'required|numeric|exact_length[12]',
'errors' => [ 'errors' => [

File diff suppressed because it is too large Load Diff

View File

@ -92,7 +92,7 @@ class ThzController extends BaseController
'rules' => 'required|regex_match[/^[a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,}$/]', 'rules' => 'required|regex_match[/^[a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,}$/]',
'errors' => [ 'errors' => [
'required' => 'Email address is required.', 'required' => 'Email address is required.',
'regex_match' => 'Please enter a valid email format (e.g., name@company.com).' 'regex_match' => 'Please enter a valid email format (e.g., name@domain.com).'
] ]
], ],

View File

@ -1136,11 +1136,11 @@ class TicketController extends BaseController
$rules = [ $rules = [
// --- EMPLOYEE DETAILS --- // --- EMPLOYEE DETAILS ---
'emp_code' => [ 'emp_code' => [
'label' => 'Employee Code', 'label' => 'Employee ID',
'rules' => 'required|min_length[2]|max_length[20]|regex_match[/^[a-zA-Z0-9_-]+$/]', 'rules' => 'required|min_length[2]|max_length[20]|regex_match[/^[a-zA-Z0-9_-]+$/]',
'errors' => [ 'errors' => [
'required' => 'Employee Code is required.', 'required' => 'Employee ID is required.',
'regex_match' => 'Employee Code cannot contain spaces or special characters (only letters, numbers, - and _ allowed).' 'regex_match' => 'Employee ID cannot contain spaces or special characters (only letters, numbers, hyphens and underscores. allowed).'
] ]
], ],
'emp_name' => [ 'emp_name' => [
@ -1170,10 +1170,12 @@ class TicketController extends BaseController
'rules' => 'permit_empty|min_length[3]|max_length[50]|regex_match[/^[a-zA-Z0-9\s\-\/_]+$/]', 'rules' => 'permit_empty|min_length[3]|max_length[50]|regex_match[/^[a-zA-Z0-9\s\-\/_]+$/]',
'errors' => [ 'errors' => [
'min_length' => 'Policy Number appears too short (min 5 characters).', 'min_length' => 'Policy Number appears too short (min 5 characters).',
'regex_match' => 'Policy Number can only contain letters, numbers, spaces, hyphens(-), underscores(_), and slashes(/).' 'regex_match' => 'Policy Number can only contain letters, numbers, spaces, hyphens(-) underscores(_), and slashes(/).'
] ]
], ],
'tpa_no' => ['label' => 'TPA ID','rules' => 'permit_empty','errors' => []], 'tpa_no' => ['label' => 'TPA ID','rules' => 'permit_empty|regex_match[/^[a-zA-Z0-9]+$/]','errors' => [
'regex_match' => 'TPA ID can only contain letters and numbers.'
]],
'emp_mobile' => ['label' => 'Employee Mobile No','rules' => 'required|numeric|exact_length[10]', 'emp_mobile' => ['label' => 'Employee Mobile No','rules' => 'required|numeric|exact_length[10]',
'errors' => [ 'errors' => [
'required' => 'Mobile number is required', 'required' => 'Mobile number is required',
@ -1189,9 +1191,8 @@ class TicketController extends BaseController
] ]
], ],
'emp_personal_mail' => ['label' => 'Personal Mail ID', 'emp_personal_mail' => ['label' => 'Personal Mail ID',
'rules' => 'required|regex_match[/^[a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,}$/]', 'rules' => 'permit_empty|regex_match[/^[a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,}$/]',
'errors' => [ 'errors' => [
'required' => 'Personal Email address is required.',
'regex_match' => 'Please enter a valid email format (e.g., name@domain.com).' 'regex_match' => 'Please enter a valid email format (e.g., name@domain.com).'
] ]
], ],
@ -1215,23 +1216,51 @@ class TicketController extends BaseController
'claim_type' => ['label' => 'Claim Type','rules' => 'required', 'claim_type' => ['label' => 'Claim Type','rules' => 'required',
'errors' => ['required' => 'Claim Type is required'] 'errors' => ['required' => 'Claim Type is required']
], ],
'hospital_name' => ['label' => 'Hospital Name','rules' => 'required', 'hospital_name' => [
'errors' => ['required' => 'Hospital Name is required'] 'label' => 'Hospital Name',
'rules' => 'required|regex_match[/^[a-zA-Z0-9\s\-_.\']+$/]',
'errors' => [
'required' => 'Hospital Name is required',
'regex_match' => 'The {field} can only contain letters, numbers, spaces, dashes, underscores, dots, and apostrophes.'
]
], ],
'hospital_address' => ['label' => 'Hospital Address','rules' => 'required', 'hospital_address' => [
'errors' => ['required' => 'Hospital Address is required'] 'label' => 'Hospital Address',
'rules' => 'permit_empty|regex_match[/^[a-zA-Z0-9\s\-_.,#\/]+$/]',
'errors' => [
'regex_match' => 'The {field} contains invalid characters (Allowed: letters, numbers, spaces, dashes, commas, dots, # and /).'
],
], ],
'hospital_city' => ['label' => 'Hospital City','rules' => 'required', 'hospital_state' => [
'errors' => ['required' => 'City is required'] 'label' => 'Hospital State',
'rules' => 'permit_empty|regex_match[/^[a-zA-Z\s\-]+$/]',
'errors' => [
'regex_match' => 'Hospital State name can only contain letters, spaces, and hyphens.'
]
], ],
'hospital_state' => ['label' => 'Hospital State','rules' => 'required', 'hospital_city' => [
'errors' => ['required' => 'State is required'] 'label' => 'Hospital City', // Added label for consistency
'rules' => 'permit_empty|regex_match[/^[a-zA-Z\s\-]+$/]',
'errors' => [
'regex_match' => 'Hospital City can only contain letters, spaces, and hyphens.'
]
], ],
'hospital_pin_code' => ['label' => 'Hospital Pincode','rules' => 'required|numeric|exact_length[6]', 'hospital_pin_code' => [
'errors' => ['exact_length' => 'Pincode must be 6 digits'] 'label' => 'Hospital Pincode',
'rules' => 'permit_empty|numeric|exact_length[6]',
'errors' => [
'numeric' => 'Hospital Pincode must be digits only.',
'exact_length' => 'Hospital Pincode must be exactly 6 digits.'
]
], ],
'hospital_phone_no' => ['label' => 'Hospital Phone','rules' => 'required|numeric|min_length[10]', 'hospital_phone_no' => [
'errors' => ['min_length' => 'Phone number too short'] 'label' => 'Hospital Phone',
'rules' => 'permit_empty|numeric|min_length[10]|max_length[15]',
'errors' => [
'numeric' => 'Phone number must contain only digits.',
'min_length' => 'Phone number is too short.',
'max_length' => 'Phone number is too long.'
]
], ],
'doa' => ['label' => 'DOA', 'rules' => 'required', 'doa' => ['label' => 'DOA', 'rules' => 'required',
'errors' => ['required' => 'Date of Admission is required'] 'errors' => ['required' => 'Date of Admission is required']
@ -1317,11 +1346,11 @@ class TicketController extends BaseController
$rules = [ $rules = [
// --- EMPLOYEE DETAILS --- // --- EMPLOYEE DETAILS ---
'emp_code' => [ 'emp_code' => [
'label' => 'Employee Code', 'label' => 'Employee ID',
'rules' => 'required|min_length[2]|max_length[20]|regex_match[/^[a-zA-Z0-9_-]+$/]', 'rules' => 'required|min_length[2]|max_length[20]|regex_match[/^[a-zA-Z0-9_-]+$/]',
'errors' => [ 'errors' => [
'required' => 'Employee Code is required.', 'required' => 'Employee ID is required.',
'regex_match' => 'Employee Code cannot contain spaces or special characters (only letters, numbers, - and _ allowed).', 'regex_match' => 'Employee ID cannot contain spaces or special characters (only letters, numbers, hyphens and underscores. allowed).',
] ]
], ],
'emp_name' => [ 'emp_name' => [
@ -1348,9 +1377,8 @@ class TicketController extends BaseController
] ]
], ],
'emp_personal_mail' => ['label' => 'Personal Mail ID', 'emp_personal_mail' => ['label' => 'Personal Mail ID',
'rules' => 'required|regex_match[/^[a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,}$/]', 'rules' => 'permit_empty|regex_match[/^[a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,}$/]',
'errors' => [ 'errors' => [
'required' => 'Personal Email address is required.',
'regex_match' => 'Please enter a valid email format (e.g., name@domain.com).' 'regex_match' => 'Please enter a valid email format (e.g., name@domain.com).'
] ]
], ],
@ -1457,11 +1485,11 @@ class TicketController extends BaseController
$rules = [ $rules = [
// --- EMPLOYEE DETAILS --- // --- EMPLOYEE DETAILS ---
'emp_code' => [ 'emp_code' => [
'label' => 'Employee Code', 'label' => 'Employee ID',
'rules' => 'required|min_length[2]|max_length[20]|regex_match[/^[a-zA-Z0-9_-]+$/]', 'rules' => 'required|min_length[2]|max_length[20]|regex_match[/^[a-zA-Z0-9_-]+$/]',
'errors' => [ 'errors' => [
'required' => 'Employee Code is required.', 'required' => 'Employee ID is required.',
'regex_match' => 'Employee Code cannot contain spaces or special characters (only letters, numbers, - and _ allowed).', 'regex_match' => 'Employee ID cannot contain spaces or special characters (only letters, numbers, hyphens and underscores. allowed).',
] ]
], ],
'emp_name' => [ 'emp_name' => [
@ -1490,11 +1518,13 @@ class TicketController extends BaseController
// Allows: A-Z, a-z, 0-9, spaces (\s), hyphens (\-), underscores (_), and slashes (\/) // Allows: A-Z, a-z, 0-9, spaces (\s), hyphens (\-), underscores (_), and slashes (\/)
'rules' => 'permit_empty|min_length[3]|max_length[50]|regex_match[/^[a-zA-Z0-9\s\-\/_]+$/]', 'rules' => 'permit_empty|min_length[3]|max_length[50]|regex_match[/^[a-zA-Z0-9\s\-\/_]+$/]',
'errors' => [ 'errors' => [
'min_length' => 'Policy Number appears too short (min 5 characters).', 'min_length' => 'Policy Number appears too short (min 3 characters).',
'regex_match' => 'Policy Number can only contain letters, numbers, spaces, hyphens(-), underscores(_), and slashes(/).' 'regex_match' => 'Policy Number can only contain letters, numbers, spaces, hyphens(-) underscores(_), and slashes(/).'
] ]
], ],
'tpa_no' => ['label' => 'TPA ID','rules' => 'permit_empty','errors' => []], 'tpa_no' => ['label' => 'TPA ID','rules' => 'permit_empty|regex_match[/^[a-zA-Z0-9]+$/]','errors' => [
'regex_match' => 'TPA ID can only contain letters and numbers.'
]],
'emp_mobile' => ['label' => 'Employee Mobile No','rules' => 'required|numeric|exact_length[10]', 'emp_mobile' => ['label' => 'Employee Mobile No','rules' => 'required|numeric|exact_length[10]',
'errors' => [ 'errors' => [
'required' => 'Mobile number is required', 'required' => 'Mobile number is required',
@ -1510,9 +1540,8 @@ class TicketController extends BaseController
] ]
], ],
'emp_personal_mail' => ['label' => 'Personal Mail ID', 'emp_personal_mail' => ['label' => 'Personal Mail ID',
'rules' => 'required|regex_match[/^[a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,}$/]', 'rules' => 'permit_empty|regex_match[/^[a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,}$/]',
'errors' => [ 'errors' => [
'required' => 'Personal Email address is required.',
'regex_match' => 'Please enter a valid email format (e.g., name@domain.com).' 'regex_match' => 'Please enter a valid email format (e.g., name@domain.com).'
] ]
], ],
@ -1536,23 +1565,51 @@ class TicketController extends BaseController
'claim_type' => ['label' => 'Claim Type','rules' => 'required', 'claim_type' => ['label' => 'Claim Type','rules' => 'required',
'errors' => ['required' => 'Claim Type is required'] 'errors' => ['required' => 'Claim Type is required']
], ],
'hospital_name' => ['label' => 'Hospital Name','rules' => 'required', 'hospital_name' => [
'errors' => ['required' => 'Hospital Name is required'] 'label' => 'Hospital Name',
'rules' => 'required|regex_match[/^[a-zA-Z0-9\s\-_.\']+$/]',
'errors' => [
'required' => 'Hospital Name is required',
'regex_match' => 'The {field} can only contain letters, numbers, spaces, dashes, underscores, dots, and apostrophes.'
]
], ],
'hospital_address' => ['label' => 'Hospital Address','rules' => 'required', 'hospital_address' => [
'errors' => ['required' => 'Hospital Address is required'] 'label' => 'Hospital Address',
'rules' => 'permit_empty|regex_match[/^[a-zA-Z0-9\s\-_.,#\/]+$/]',
'errors' => [
'regex_match' => 'The {field} contains invalid characters (Allowed: letters, numbers, spaces, dashes, commas, dots, # and /).'
],
], ],
'hospital_city' => ['label' => 'Hospital City','rules' => 'required', 'hospital_state' => [
'errors' => ['required' => 'City is required'] 'label' => 'Hospital State',
'rules' => 'permit_empty|regex_match[/^[a-zA-Z\s\-]+$/]',
'errors' => [
'regex_match' => 'Hospital State name can only contain letters, spaces, and hyphens.'
]
], ],
'hospital_state' => ['label' => 'Hospital State','rules' => 'required', 'hospital_city' => [
'errors' => ['required' => 'State is required'] 'label' => 'Hospital City', // Added label for consistency
'rules' => 'permit_empty|regex_match[/^[a-zA-Z\s\-]+$/]',
'errors' => [
'regex_match' => 'Hospital City can only contain letters, spaces, and hyphens.'
]
], ],
'hospital_pin_code' => ['label' => 'Hospital Pincode','rules' => 'required|numeric|exact_length[6]', 'hospital_pin_code' => [
'errors' => ['exact_length' => 'Pincode must be 6 digits'] 'label' => 'Hospital Pincode',
'rules' => 'permit_empty|numeric|exact_length[6]',
'errors' => [
'numeric' => 'Hospital Pincode must be digits only.',
'exact_length' => 'Hospital Pincode must be exactly 6 digits.'
]
], ],
'hospital_phone_no' => ['label' => 'Hospital Phone','rules' => 'required|numeric|min_length[10]', 'hospital_phone_no' => [
'errors' => ['min_length' => 'Phone number too short'] 'label' => 'Hospital Phone',
'rules' => 'permit_empty|numeric|min_length[10]|max_length[15]',
'errors' => [
'numeric' => 'Phone number must contain only digits.',
'min_length' => 'Phone number is too short.',
'max_length' => 'Phone number is too long.'
]
], ],
'doa' => ['label' => 'DOA', 'rules' => 'required', 'doa' => ['label' => 'DOA', 'rules' => 'required',
'errors' => ['required' => 'Date of Admission is required'] 'errors' => ['required' => 'Date of Admission is required']
@ -1638,11 +1695,11 @@ class TicketController extends BaseController
$rules = [ $rules = [
// --- EMPLOYEE DETAILS --- // --- EMPLOYEE DETAILS ---
'emp_code' => [ 'emp_code' => [
'label' => 'Employee Code', 'label' => 'Employee ID',
'rules' => 'required|min_length[2]|max_length[20]|regex_match[/^[a-zA-Z0-9_-]+$/]', 'rules' => 'required|min_length[2]|max_length[20]|regex_match[/^[a-zA-Z0-9_-]+$/]',
'errors' => [ 'errors' => [
'required' => 'Employee Code is required.', 'required' => 'Employee ID is required.',
'regex_match' => 'Employee Code cannot contain spaces or special characters (only letters, numbers, - and _ allowed).', 'regex_match' => 'Employee ID cannot contain spaces or special characters (only letters, numbers, hyphens and underscores. allowed).',
] ]
], ],
'emp_name' => [ 'emp_name' => [
@ -1669,9 +1726,8 @@ class TicketController extends BaseController
] ]
], ],
'emp_personal_mail' => ['label' => 'Personal Mail ID', 'emp_personal_mail' => ['label' => 'Personal Mail ID',
'rules' => 'required|regex_match[/^[a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,}$/]', 'rules' => 'permit_empty|regex_match[/^[a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,}$/]',
'errors' => [ 'errors' => [
'required' => 'Personal Email address is required.',
'regex_match' => 'Please enter a valid email format (e.g., name@domain.com).' 'regex_match' => 'Please enter a valid email format (e.g., name@domain.com).'
] ]
], ],
@ -1930,7 +1986,7 @@ class TicketController extends BaseController
'rules' => 'required|regex_match[/^[a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,}$/]', 'rules' => 'required|regex_match[/^[a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,}$/]',
'errors' => [ 'errors' => [
'required' => 'Email address is required.', 'required' => 'Email address is required.',
'regex_match' => 'Please enter a valid email format (e.g., name@company.com).' 'regex_match' => 'Please enter a valid email format (e.g., name@domain.com).'
] ]
], ],
'mail_subject' => [ 'mail_subject' => [
@ -3124,11 +3180,12 @@ class TicketController extends BaseController
], ],
'url.*' => [ 'url.*' => [
'label' => 'URL', 'label' => 'URL',
'rules' => 'required', 'rules' => 'if_exist|required|regex_match[/^(https?:\/\/)?([\da-z\.-]+)\.([a-z\.]{2,6})([\/\w \.-]*)*\/?$/]',
'errors' => [ 'errors' => [
'required' => 'URL is required', 'required' => 'URL is required.',
'regex_match' => 'The URL format is invalid. Example: www.google.com or https://google.com'
] ]
] ],
]; ];
if (!$this->validate($rules)) { if (!$this->validate($rules)) {

View File

@ -114,11 +114,13 @@ class UserController extends AdminController
// Employee Code // Employee Code
// ====================== // ======================
'emp_code' => [ 'emp_code' => [
'rules' => 'required|min_length[3]|max_length[15]', 'label' => 'Employee Code',
'rules' => 'required|min_length[3]|max_length[15]|regex_match[/^[a-zA-Z0-9_\-\/]+$/]',
'errors' => [ 'errors' => [
'required' => 'Employee Code is required', 'required' => 'Employee Code is required',
'min_length' => 'Employee Code must be at least 3 characters', 'min_length' => 'Employee Code must be at least 3 characters',
'max_length' => 'Employee Code cannot exceed 15 characters', 'max_length' => 'Employee Code cannot exceed 15 characters',
'regex_match' => 'Employee Code can only contain letters, numbers, underscores, hyphens, and forward slashes (/).'
] ]
], ],
@ -142,7 +144,7 @@ class UserController extends AdminController
'rules' => 'required|regex_match[/^[a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,}$/]', 'rules' => 'required|regex_match[/^[a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,}$/]',
'errors' => [ 'errors' => [
'required' => 'Email address is required.', 'required' => 'Email address is required.',
'regex_match' => 'Please enter a valid email format (e.g., name@company.com).' 'regex_match' => 'Please enter a valid email format (e.g., name@domain.com).'
] ]
], ],
@ -178,13 +180,10 @@ class UserController extends AdminController
] ]
], ],
]; ];
if (!$this->validate($rules)) { if (!$this->validate($rules)) {
return $this->response->setStatusCode(400)->setJSON([ return redirect()->to(base_url('/user/list'))
'status' => false, ->withInput()
'message' => 'Input validation failed', ->with('errors', $this->validator->getErrors());
'code' => 400,
'errors' => $this->validator->getErrors()
]);
} }
$userData['created_by'] = get_session_userid(); $userData['created_by'] = get_session_userid();
@ -298,11 +297,13 @@ class UserController extends AdminController
// Employee Code // Employee Code
// ====================== // ======================
'emp_code' => [ 'emp_code' => [
'rules' => 'required|min_length[3]|max_length[15]', 'label' => 'Employee Code',
'rules' => 'required|min_length[3]|max_length[15]|regex_match[/^[a-zA-Z0-9_\-\/]+$/]',
'errors' => [ 'errors' => [
'required' => 'Employee Code is required', 'required' => 'Employee Code is required',
'min_length' => 'Employee Code must be at least 3 characters', 'min_length' => 'Employee Code must be at least 3 characters',
'max_length' => 'Employee Code cannot exceed 15 characters', 'max_length' => 'Employee Code cannot exceed 15 characters',
'regex_match' => 'Employee Code can only contain letters, numbers, underscores, hyphens, and forward slashes (/).'
] ]
], ],
@ -326,7 +327,7 @@ class UserController extends AdminController
'rules' => 'required|regex_match[/^[a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,}$/]', 'rules' => 'required|regex_match[/^[a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,}$/]',
'errors' => [ 'errors' => [
'required' => 'Email address is required.', 'required' => 'Email address is required.',
'regex_match' => 'Please enter a valid email format (e.g., name@company.com).' 'regex_match' => 'Please enter a valid email format (e.g., name@domain.com).'
] ]
], ],
@ -363,12 +364,9 @@ class UserController extends AdminController
], ],
]; ];
if (!$this->validate($rules)) { if (!$this->validate($rules)) {
return $this->response->setStatusCode(400)->setJSON([ return redirect()->to(base_url('/user/list'))
'status' => false, ->withInput()
'message' => 'Input validation failed', ->with('errors', $this->validator->getErrors());
'code' => 400,
'errors' => $this->validator->getErrors()
]);
} }
$data = $this->request->getPost(); $data = $this->request->getPost();
@ -832,7 +830,7 @@ class UserController extends AdminController
'rules' => 'required|regex_match[/^[a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,}$/]', 'rules' => 'required|regex_match[/^[a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,}$/]',
'errors' => [ 'errors' => [
'required' => 'Email address is required.', 'required' => 'Email address is required.',
'regex_match' => 'Please enter a valid email format (e.g., name@company.com).' 'regex_match' => 'Please enter a valid email format (e.g., name@domain.com).'
] ]
], ],
// ====================== // ======================
@ -845,7 +843,7 @@ class UserController extends AdminController
], ],
'errors' => [ 'errors' => [
'required' => 'Retention Rate is required', 'required' => 'Retention Rate is required',
'regex_match' => 'Retention Rate must be between 0 and 100 with up to 2 decimal places' 'regex_match' => 'Retention Rate must be between 0 to 100 with up to 2 decimal places'
] ]
], ],
// ====================== // ======================

View File

@ -77,7 +77,8 @@ class VidalApiController extends BaseController
curl_setopt($ch2, CURLOPT_RETURNTRANSFER, true); curl_setopt($ch2, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch2, CURLOPT_HTTPHEADER, [ curl_setopt($ch2, CURLOPT_HTTPHEADER, [
"x-ms-blob-type: BlockBlob", "x-ms-blob-type: BlockBlob",
"Content-Length: $fileSize" "Content-Length: $fileSize" ,
"Content-Type: multipart/form-data"
]); ]);
$uploadResponse = curl_exec($ch2); $uploadResponse = curl_exec($ch2);

View File

@ -1114,9 +1114,9 @@ class EmployeePolicyModel extends Model
public function getDeletionEmployeeDataForExportExcel($ref_data, $return_type = 0) public function getDeletionEmployeeDataForExportExcel($ref_data, $return_type = 0)
{ {
$client_id = $ref_data['client_id']; $client_id = (string) "'".$ref_data['client_id']."'";
$client_policy_id = $ref_data['client_policy_id']; $client_policy_id = (string) "'".$ref_data['client_policy_id']."'";
$client_branch_id = $ref_data['client_branch_id']; $client_branch_id = (string) "'".$ref_data['client_branch_id']."'";
$insurer_or_tpa = $ref_data['insurer_or_tpa']; $insurer_or_tpa = $ref_data['insurer_or_tpa'];
$get_insurer_id_from_client_policy = $this->db->table('client_policy') $get_insurer_id_from_client_policy = $this->db->table('client_policy')
@ -1929,6 +1929,8 @@ class EmployeePolicyModel extends Model
public function getDeletionDataForTruncated($file_id) public function getDeletionDataForTruncated($file_id)
{ {
$file_id = (int)$file_id;
// Fetch the necessary details in a single query using JOINs // Fetch the necessary details in a single query using JOINs
$result = $this->db->table('files f') $result = $this->db->table('files f')
->select('i.deletion_add_day') ->select('i.deletion_add_day')
@ -2064,6 +2066,8 @@ class EmployeePolicyModel extends Model
$action = "da"; $action = "da";
} }
$file_id = (int)$file_id;
$query = $this->db->query(" $query = $this->db->query("
SELECT SELECT
@ -2086,6 +2090,7 @@ class EmployeePolicyModel extends Model
// dd($this->db->getLastQuery(), $result); // dd($this->db->getLastQuery(), $result);
// dd($result); // dd($result);
return $result[0]; return $result[0];
} }
@ -2096,6 +2101,8 @@ class EmployeePolicyModel extends Model
log_message('error', 'updateEmployeePolicyTruncateReverse model function called'); log_message('error', 'updateEmployeePolicyTruncateReverse model function called');
log_message('error', 'FILE ID : {data}', ['data' => $file_id]); log_message('error', 'FILE ID : {data}', ['data' => $file_id]);
$file_id = (int)$file_id;
$this->db->query(" $this->db->query("
UPDATE employee_polices UPDATE employee_polices
SET SET
@ -2137,6 +2144,9 @@ class EmployeePolicyModel extends Model
//calculate the CD Transaction sum of the amount for the inception, addition, dependent addition, missed inception //calculate the CD Transaction sum of the amount for the inception, addition, dependent addition, missed inception
public function calculateCdTranctionAmount($file_id) public function calculateCdTranctionAmount($file_id)
{ {
$file_id = (int)$file_id;
$query = $this->db->query(" $query = $this->db->query("
SELECT SELECT

View File

@ -73,6 +73,6 @@ class MessageModel extends Model
$query = $builder->get(); $query = $builder->get();
return $query->getResult(); return $query->getResult();
dd($this->db->getLastQuery()); // dd($this->db->getLastQuery());
} }
} }

View File

@ -2432,6 +2432,9 @@
return $result; return $result;
} }
//not in use function due to complexity of query and union, so writing raw query with bindings to avoid sql injection
public function getBDSReportListSingleUnion($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 = []) public function getBDSReportListSingleUnion($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 = [])
{ {
@ -3015,6 +3018,15 @@
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 = []) 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 = [])
{ {
$client_id = (int)$client_id;
$insurer_id = (int)$insurer_id;
$policy_type_id = (int)$policy_type_id;
$client_branch_id = (int)$client_branch_id;
$insurer_branch_id = (int)$insurer_branch_id;
$client_policy_id = (int)$client_policy_id;
$user_id = (int)$user_id;
$issuer = (int)$issuer;
$whereAdded = false; $whereAdded = false;
$statement_month_condition = ''; $statement_month_condition = '';
if ($date_type == 'statement_month' && $start_date != 0 && $end_date != 0) { if ($date_type == 'statement_month' && $start_date != 0 && $end_date != 0) {
@ -3689,6 +3701,8 @@
"; ";
$query = $this->db->query($sql); $query = $this->db->query($sql);
$result = $query->getResultArray(); $result = $query->getResultArray();
// $countofalldata = count($result); // $countofalldata = count($result);
// dd($result); // dd($result);
// dd($this->db->getLastQuery()->getQuery()); // dd($this->db->getLastQuery()->getQuery());

View File

@ -884,12 +884,18 @@ table.dataTable tbody td {
</table> </table>
</div> </div>
</div> </div>
<?php if (session()->getFlashdata('errors')): ?>
<script>
$(document).ready(function() {
<?php foreach (session()->getFlashdata('errors') as $error): ?>
toastr.error("<?= addslashes($error) ?>", "Validation Error");
<?php endforeach; ?>
});
</script>
<?php endif; ?>
<?php if (session()->getFlashdata('error')) : ?> <?php if (session()->getFlashdata('error')) : ?>
<?php foreach (session()->getFlashdata('error') as $error) : ?>
<script>
toastr.error("<?= esc($error) ?>", "Validation Error");
</script>
<?php endforeach; ?>
<script> <script>
var errorModal = new bootstrap.Modal( var errorModal = new bootstrap.Modal(

View File

@ -67,12 +67,12 @@
<div class="form-row"> <div class="form-row">
<div class="form-group col-md-6"> <div class="form-group col-md-6">
<label for="mobile">CD Account Number<span class="text-danger">*</span></label> <label for="mobile">CD Account Number<span class="text-danger">*</span></label>
<input type="text" class="form-control" id="cd_ac_no_for_cd_master" name="cd_ac_no" required> <input type="text" class="form-control" id="cd_ac_no_for_cd_master" name="cd_ac_no" onkeypress="return onlyNumbers(event)" required data-parsley-type="digits">
</div> </div>
<div class="form-group col-md-6"> <div class="form-group col-md-6">
<label for="mobile">Opening Amount<span class="text-danger">*</span></label> <label for="mobile">Opening Amount<span class="text-danger">*</span></label>
<input type="text" class="form-control" id="opening_bal" name="opening_bal" onkeypress="return onlyNumbers(event)" required> <input type="text" class="form-control" id="opening_bal" name="opening_bal" onkeypress="return onlyNumbers(event)" required data-parsley-type="digits">
</div> </div>
</div> </div>

View File

@ -221,6 +221,7 @@ input:checked + .slider:before {
$(document).ready(function() { $(document).ready(function() {
$('#client_logo').change(function() { $('#client_logo').change(function() {
validateFile(this); validateFile(this);
return;
}); });
$('#parent_client_id').select2(); $('#parent_client_id').select2();
}); });
@ -415,44 +416,60 @@ input:checked + .slider:before {
function validateFile(input) { function validateFile(input) {
if (!input.files || !input.files[0]) return;
const file = input.files[0]; const file = input.files[0];
const allowedExtensions = ["jpg", "jpeg", "png"]; const allowedExtensions = ["jpg", "jpeg", "png"];
const fileExtension = file.name.split(".").pop().toLowerCase(); const fileExtension = file.name.split(".").pop().toLowerCase();
const fileSize = file.size / 1024; // KB
// Log Initial Info
console.log("File Selected:", file.name);
console.log("File Size:", fileSize.toFixed(2) + " KB");
// Check if the file extension is allowed // Check if the file extension is allowed
if (!allowedExtensions.includes(fileExtension)) { if (!allowedExtensions.includes(fileExtension)) {
toastr.warning('Only JPG, JPEG, PNG files are allowed.', 'Invalid file type.'); toastr.warning('Only JPG, JPEG, PNG files are allowed.', 'Invalid file type.');
$("#uploadPreview").attr("src", "<?= base_url()?>/public/assets/images/avatar_2x.png"); resetImageInput(input);
input.value = ""; return;
} }
// Check file size // Check file size
const fileSize = file.size / 1024; // in KB
if (fileSize > 200) { if (fileSize > 200) {
console.error("Validation Failed: File too large (" + fileSize.toFixed(2) + " KB)");
toastr.warning('Maximum file size allowed is 200KB.', 'File size exceeds limit.'); toastr.warning('Maximum file size allowed is 200KB.', 'File size exceeds limit.');
$("#uploadPreview").attr("src", "<?= base_url()?>/public/assets/images/avatar_2x.png"); resetImageInput(input);
input.value = ""; return;
} }
// Check image dimensions // Check image dimensions
const img = new Image(); const img = new Image();
img.src = URL.createObjectURL(file);
img.onload = function() { img.onload = function() {
console.log("Dimensions Detected:", this.width + "x" + this.height);
if (this.width !== 100 || this.height !== 100) { if (this.width !== 100 || this.height !== 100) {
console.error("Validation Failed: Wrong dimensions.");
toastr.warning('Image dimensions should be 100x100 pixels.', 'Invalid image dimensions.'); toastr.warning('Image dimensions should be 100x100 pixels.', 'Invalid image dimensions.');
$("#uploadPreview").attr("src", "<?= base_url()?>/public/assets/images/avatar_2x.png"); resetImageInput(input); // CRITICAL: This stops the file from being sent
} }else {
console.log("Validation Passed: Image is 100x100 and under 200KB.");
// If both size and dimensions are valid, you can proceed with your logic here // If both size and dimensions are valid, you can proceed with your logic here
// For example, you can display the image // For example, you can display the image
const reader = new FileReader(); const reader = new FileReader();
reader.onload = function(e) { reader.onload = function(e) {
document.getElementById("uploadPreview").src = e.target.result; $("#uploadPreview").attr("src", e.target.result);
}; };
reader.readAsDataURL(file); reader.readAsDataURL(file);
}
}; };
img.src = URL.createObjectURL(file);
} }
// Helper function to clear the preview and the file input
function resetImageInput(input) {
input.value = ""; // This clears the file so it won't be submitted
$("#uploadPreview").attr("src", "<?= base_url()?>/public/assets/images/avatar_2x.png");
}
</script> </script>

View File

@ -108,11 +108,36 @@ $("#drive_file_upload_form").submit(function(event) {
$('#drive_file_upload_form')[0].reset(); $('#drive_file_upload_form')[0].reset();
}, },
error: function (xhr, status, error) { error:function (xhr) {
console.error(xhr.responseText);
console.error(status, error); if (xhr.status === 400) {
let response = JSON.parse(xhr.responseText);
let errorMessages = "";
let seenMessages = []; // Array to store unique messages
if (response.errors) {
$.each(response.errors, function (field, message) {
if (!seenMessages.includes(message)) {
errorMessages += `• ${message}<br>`;
seenMessages.push(message); // Mark this message as "seen"
}
});
toastr.error(errorMessages, 'Validation Error', { "allowHtml": true });
} else {
toastr.warning(response.message || 'Validation failed', 'Warning');
}
} else if (xhr.status === 403) {
let response = JSON.parse(xhr.responseText);
toastr.error(response.message, 'Security Policy');
} else if (xhr.status === 500) {
toastr.error('Something went wrong . Please try again later.', 'Server Error');
} else {
toastr.error('An unexpected error occurred. Please try again later.', 'Error');
}
$('.loader').fadeOut(); $('.loader').fadeOut();
$('.loader-mask').delay(350).fadeOut('slow'); $('.loader-mask').delay(350).fadeOut('slow');
} }
}); });
}); });

View File

@ -573,7 +573,8 @@ if (isset($selected_lead_type)) {
<input type="text" class="form-control" name="docs_name_${increment}[]" placeholder="${placeholder}"> <input type="text" class="form-control" name="docs_name_${increment}[]" placeholder="${placeholder}">
</div> </div>
<div class="form-group col-md-5"> <div class="form-group col-md-5">
<label>File Upload<span class="text-danger"></span></label> <label>File Upload<span class="text-danger"></span></label><br>
<span class="text-danger">PDF | Excel (XLSX, XLS) | Images (PNG, JPG)</span>
<input type="file" class="form-control" id="file_name_${fileIndex}" name="file_name_${increment}[]" accept="${accept}"> <input type="file" class="form-control" id="file_name_${fileIndex}" name="file_name_${increment}[]" accept="${accept}">
</div> </div>
<div class="col-md-2" style="position: relative; bottom: 16px;"> <div class="col-md-2" style="position: relative; bottom: 16px;">
@ -638,7 +639,8 @@ if (isset($selected_lead_type)) {
</div> </div>
<div class="col-auto" style="align-content: center;"> <div class="col-auto" style="align-content: center;">
<label>File Upload </label> <label>File Upload </label> <br>
<span class="text-danger">PDF | Excel (XLSX, XLS) | Images (PNG, JPG)</span>
</div> </div>
<div class="col-md-3"> <div class="col-md-3">
<div class="input-icon"> <div class="input-icon">

View File

@ -1027,7 +1027,7 @@
<div class="form-group col-md-2"> <div class="form-group col-md-2">
<label for="first_year_${increment}">Year<span class="text-danger">*</span></label> <label for="first_year_${increment}">Year<span class="text-danger">*</span></label>
<select class="form-control first_year_" id="first_year_${increment}" name="first_year[]"> <select class="form-control claim-input first_year_" id="first_year_${increment}" name="first_year[]">
<option value="">Select Year</option> <option value="">Select Year</option>
<?php foreach ($lastFiveYears as $year) { <?php foreach ($lastFiveYears as $year) {
echo "<option value='$year'>$year</option>"; echo "<option value='$year'>$year</option>";
@ -1036,27 +1036,27 @@
</div> </div>
<div class="form-group col-md-2"> <div class="form-group col-md-2">
<label for="first_policy_type_${increment}">Policy Type<span class="text-danger">*</span></label> <label for="first_policy_type_${increment}">Policy Type<span class="text-danger">*</span></label>
<input type="text" class="form-control" id="first_policy_type_${increment}" name="first_policy_type_[]"> <input type="text" class="form-control claim-input" id="first_policy_type_${increment}" name="first_policy_type_[]">
</div> </div>
<div class="form-group col-md-2"> <div class="form-group col-md-2">
<label for="first_date_of_loss_${increment}">Date of Loss<span class="text-danger">*</span></label> <label for="first_date_of_loss_${increment}">Date of Loss<span class="text-danger">*</span></label>
<input type="text" class="form-control loss_date" id="first_date_of_loss_${increment}" name="first_date_of_loss_[]"> <input type="text" class="form-control loss_date claim-input" id="first_date_of_loss_${increment}" name="first_date_of_loss_[]">
</div> </div>
<div class="form-group col-md-2"> <div class="form-group col-md-2">
<label for="first_cause_of_death_${increment}">Cause Of Loss <span class="text-danger">*</span></label> <label for="first_cause_of_death_${increment}">Cause Of Loss <span class="text-danger">*</span></label>
<input type="text" class="form-control" id="first_cause_of_loss_${increment}" name="first_cause_of_loss[]"> <input type="text" class="form-control claim-input" id="first_cause_of_loss_${increment}" name="first_cause_of_loss[]">
</div> </div>
<div class="form-group col-md-2"> <div class="form-group col-md-2">
<label for="first_claim_amount_${increment}">Claim Amount<span class="text-danger">*</span></label> <label for="first_claim_amount_${increment}">Claim Amount<span class="text-danger">*</span></label>
<input type="text" class="form-control" id="first_claim_amount_${increment}" name="first_claim_amount[]"> <input type="text" class="form-control claim-input" id="first_claim_amount_${increment}" name="first_claim_amount[]">
</div> </div>
<div class="form-group col-md-2"> <div class="form-group col-md-2">
<label for="first_claim_amount_${increment}">Settled Amount<span class="text-danger">*</span></label> <label for="first_claim_amount_${increment}">Settled Amount<span class="text-danger">*</span></label>
<input type="text" class="form-control" id="first_settled_amount_${increment}" name="first_settled_amount[]"> <input type="text" class="form-control claim-input" id="first_settled_amount_${increment}" name="first_settled_amount[]">
</div> </div>
<div class="form-group col-md-2"> <div class="form-group col-md-2">
<label for="first_claim_status_${increment}">Claim Status<span class="text-danger">*</span></label> <label for="first_claim_status_${increment}">Claim Status<span class="text-danger">*</span></label>
<input type="text" class="form-control" id="first_claim_status_${increment}" name="first_claim_status[]"> <input type="text" class="form-control claim-input" id="first_claim_status_${increment}" name="first_claim_status[]">
</div> </div>
<div class="form-group col-md-2"> <div class="form-group col-md-2">
<div class="" style="position: relative; top: 28px; float: right; text-align: end;"> <div class="" style="position: relative; top: 28px; float: right; text-align: end;">
@ -1072,6 +1072,16 @@
referenceDiv.insertAdjacentHTML('beforeend', claimsFields); referenceDiv.insertAdjacentHTML('beforeend', claimsFields);
let isChecked = $("#claim_history").length > 0 ? $("#claim_history").prop("checked") : true;
let lastRow = $(".claim-row").last();
if (isChecked) {
lastRow.show();
lastRow.find(".claim-input").attr("required", true);
} else {
lastRow.hide();
lastRow.find(".claim-input").removeAttr("required");
}
// Increment claim index // Increment claim index
increment = increment + 1; increment = increment + 1;
@ -1143,9 +1153,15 @@
// No rows yet, so create them // No rows yet, so create them
appendThreeYearsClaims(); appendThreeYearsClaims();
} }
$(".claim-input").attr("required", true);
} else { } else {
$(".claim-row").hide(); $(".claim-row").hide();
$(".claim-input").removeAttr("required"); // Required Attributes Remove
$(".claim-input").val(""); // Value Reset
$(".claim-input").each(function() {
$(this).parsley().reset(); // Validation Reset
});
} }
} }

View File

@ -741,12 +741,12 @@
</div> </div>
<div class="form-group col-md-3"> <div class="form-group col-md-3">
<label for="bp_cgst">D.O.C</label> <label for="bp_cgst">D.O.C <span class="text-danger">*</span></label>
<input id="policy_start_date" type="text" class="form-control" name="policy_start_date" placeholder="DD/MM/YYYY" > <input id="policy_start_date" type="text" class="form-control" name="policy_start_date" placeholder="DD/MM/YYYY" >
</div> </div>
<div class="form-group col-md-3"> <div class="form-group col-md-3">
<label for="bp_igst">D.O.E</label> <label for="bp_igst">D.O.E <span class="text-danger">*</span></label>
<input id="policy_end_date" type="text" class="form-control" name="policy_end_date" placeholder="DD/MM/YYYY" > <input id="policy_end_date" type="text" class="form-control" name="policy_end_date" placeholder="DD/MM/YYYY" >
</div> </div>
<!-- <!--

View File

@ -383,12 +383,23 @@
let $label = $('#employee_data_points_label'); let $label = $('#employee_data_points_label');
let $input = $('#emp_mobile_number_for_claim'); let $input = $('#emp_mobile_number_for_claim');
// Remove old attributes but DO NOT clear the .val()
$input.removeAttr('onkeypress maxlength oninput');
if (value == "mobile") { if (value == "mobile") {
$label.text('Employee Mobile Number'); $label.text('Employee Mobile Number');
$input.attr('onkeypress', 'return onlyNumbers(event)').attr('maxlength', '10'); $input.attr('onkeypress', 'return onlyNumbers(event)').attr('maxlength', '10');
$input.val($input.val().replace(/[^0-9]/g, '').substring(0, 10));
$input.attr('oninput', "this.value = this.value.replace(/[^0-9]/g, '').substring(0, 10)");
} else { } else {
$label.text('Employee ID'); $label.text('Employee ID');
$input.removeAttr('onkeypress maxlength'); $input.removeAttr('onkeypress maxlength');
$input.attr('onkeypress', 'return onlyEmployee(event)');
$input.val($input.val().replace(/[^a-zA-Z0-9\s\-_/]/g, ''));
$input.attr('oninput', "this.value = this.value.replace(/[^a-zA-Z0-9\\s\\-_/]/g, '')");
} }
}); });
@ -1069,6 +1080,24 @@
return false; return false;
} }
function onlyEmployee(event) {
var charCode = (event.which) ? event.which : event.keyCode;
// Allow Numbers (48-57)
// Allow Uppercase (65-90)
// Allow Lowercase (97-122)
// Allow Space (32), Hyphen (45), Underscore (95), Forward Slash (47)
if (
(charCode >= 48 && charCode <= 57) ||
(charCode >= 65 && charCode <= 90) ||
(charCode >= 97 && charCode <= 122) ||
[32, 45, 95, 47].includes(charCode)
) {
return true;
}
return false;
}
function setClientPolicyData(input) { function setClientPolicyData(input) {
// console.log('policy_value ',input); // console.log('policy_value ',input);