Merge remote-tracking branch 'origin/dev' into dev
This commit is contained in:
commit
2c3707d86f
@ -106,6 +106,7 @@ class ApiServiceController extends BaseController
|
||||
->join('client_policy', 'employee_polices.client_policy_id = client_policy.id', 'left')
|
||||
->where('employees.emp_code', $emp_code)
|
||||
->where('employee_polices.client_policy_id', $client_policy_id)
|
||||
->where('employees.id', $id)
|
||||
->where('employee_polices.is_active', 1)
|
||||
->where('employees.is_active', 1)
|
||||
->where('employee_polices.status', 'active')
|
||||
|
||||
@ -188,7 +188,7 @@ class EmployeeController extends AdminController
|
||||
}
|
||||
|
||||
//handles employee & dependent bulk upload with events like inception,addition,deletion, correction and SI enhancements
|
||||
public function employeesUplodWithEvents()
|
||||
public function employeesUplodWithEvents($post_data = null)
|
||||
{
|
||||
|
||||
// $empDataServiceController = new EmpDataServiceController();
|
||||
@ -242,64 +242,85 @@ class EmployeeController extends AdminController
|
||||
// $this->truncateFileData(747, 5) ;
|
||||
// print_rr($this->cloneWorksheet());
|
||||
// die();
|
||||
if ($this->request->getMethod() == 'post') {
|
||||
|
||||
if (!empty($post_data) || $this->request->is('post') == 'post') {
|
||||
|
||||
//validate uploaded file
|
||||
$filename = '';
|
||||
$fileSize = '';
|
||||
$validated = $this->validate([
|
||||
'emplist' => [
|
||||
'uploaded[emplist]',
|
||||
'mime_in[emplist,application/vnd.ms-excel,application/vnd,application/vnd.openxmlformats-officedocument.spreadsheetml.sheet,application/vnd.oasis.opendocument.spreadsheet]',
|
||||
'max_size[emplist,16384]',
|
||||
],
|
||||
]);
|
||||
|
||||
if ($validated)
|
||||
{
|
||||
$avatar = $this->request->getFile('emplist');
|
||||
if (!$avatar) {
|
||||
$this->myLogger->logme("error", 'File not found');
|
||||
|
||||
if (empty($post_data)) {
|
||||
$validated = $this->validate([
|
||||
'emplist' => [
|
||||
'uploaded[emplist]',
|
||||
'mime_in[emplist,application/vnd.ms-excel,application/vnd,application/vnd.openxmlformats-officedocument.spreadsheetml.sheet,application/vnd.oasis.opendocument.spreadsheet]',
|
||||
'max_size[emplist,16384]',
|
||||
],
|
||||
]);
|
||||
} else {
|
||||
$validated = validateExcelFile($post_data['file_name']);
|
||||
}
|
||||
|
||||
if ($validated) {
|
||||
|
||||
$avatar = isset($post_data['file_name']) ? $post_data['file_name'] : $this->request->getFile('emplist');
|
||||
if (!$avatar) {
|
||||
$this->myLogger->logme("error", 'File not found');
|
||||
if (!empty($post_data)) {
|
||||
return ['status' => false, 'message' => 'File not found'];
|
||||
} else {
|
||||
return $this->respond(['dataStatus' => false, 'code' => 400, 'message' => 'File not found'], 400);
|
||||
}
|
||||
}
|
||||
|
||||
$is_moved = $avatar->move(WRITEPATH . 'uploads/excel/');
|
||||
if ($is_moved) {
|
||||
$filename = $avatar->getName();
|
||||
$fileSize = $avatar->getSize(); // File size in bytes
|
||||
$fileSize = $fileSize / (1024 * 1024); // Convert to MB
|
||||
// Handle successful upload, e.g., log success or further processing
|
||||
$this->myLogger->logme("error", 'File move successful');
|
||||
|
||||
$is_moved = $avatar->move(WRITEPATH . 'uploads/excel/');
|
||||
if ($is_moved) {
|
||||
$filename = $avatar->getName();
|
||||
$fileSize = $avatar->getSize(); // File size in bytes
|
||||
$fileSize = $fileSize / (1024 * 1024); // Convert to MB
|
||||
// Handle successful upload, e.g., log success or further processing
|
||||
$this->myLogger->logme("error", 'File move successful');
|
||||
} else {
|
||||
$this->myLogger->logme("error", 'File move failed');
|
||||
if (!empty($post_data)) {
|
||||
return ['status' => false, 'message' => 'File move failed'];
|
||||
} else {
|
||||
$this->myLogger->logme("error", 'File move failed');
|
||||
return $this->respond(['dataStatus' => false, 'code' => 500, 'message' => 'File move failed'], 500);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
$this->myLogger->logme("error", 'Upload failed Invalid file');
|
||||
return $this->respond(['dataStatus' => false, 'code' => 404, 'message' => 'Invalid file'], 404);
|
||||
if (!empty($post_data)) {
|
||||
return ['status' => false, 'message' => 'Invalid file'];
|
||||
} else {
|
||||
return $this->respond(['dataStatus' => false, 'code' => 404, 'message' => 'Invalid file'], 404);
|
||||
}
|
||||
}
|
||||
|
||||
//process post variable entry in file table
|
||||
$loggedInUserID = get_session_userid();
|
||||
// dd($loggedInUserID);
|
||||
// $loggedInUserID = 8;
|
||||
$loggedInUserID = $post_data['created_by'] ?? get_session_userid();
|
||||
|
||||
$client_id = $this->request->getPost('client_id');
|
||||
$policy_id = $this->request->getPost('policy_id');
|
||||
$branch_id = $this->request->getPost('branch_id');
|
||||
$hr_file_id = $this->request->getPost('hr_file_id') ?? null;
|
||||
$action = $this->request->getPost('upload-action-type');
|
||||
$status = 'inprogress';
|
||||
$client_id = isset($post_data['client_id']) ? $post_data['client_id'] : $this->request->getPost('client_id');
|
||||
$policy_id = isset($post_data['policy_id']) ? $post_data['policy_id'] : $this->request->getPost('policy_id');
|
||||
$branch_id = isset($post_data['client_branch_id']) ? $post_data['client_branch_id'] : $this->request->getPost('branch_id');
|
||||
$action = isset($post_data['file_action']) ? $post_data['file_action'] : $this->request->getPost('upload-action-type');
|
||||
|
||||
if(empty($post_data)){
|
||||
$hr_file_id = $this->request->getPost('hr_file_id') ?? null;
|
||||
}else{
|
||||
$hr_file_id = $post_data['hr_file_id'] ?? null ;
|
||||
}
|
||||
|
||||
$file_id = $this->fileModel->insert(['file_name' => $filename, 'client_id' => $client_id, 'policy_id' => $policy_id, 'created_by' => $loggedInUserID, 'status' => $status, 'action' => $action, 'client_branch_id' => $branch_id,'uploaded_by' => 1, 'hr_file_id' => $hr_file_id]); //here field policy_id have client_policy_id and not policy id from policy master
|
||||
$hr_id = $post_data['created_by'] ?? null;
|
||||
$status = 'inprogress';
|
||||
|
||||
$file_id = $this->fileModel->insert(['file_name' => $filename, 'client_id' => $client_id, 'policy_id' => $policy_id, 'created_by' => $loggedInUserID, 'status' => $status, 'action' => $action, 'client_branch_id' => $branch_id, 'uploaded_by' => 1, 'hr_file_id' => $hr_file_id, 'hr_id' => $hr_id]); //here field policy_id have client_policy_id and not policy id from policy master
|
||||
$this->myLogger->logme("error", '{file_id} uploaded success', ['file_id' => $file_id]);
|
||||
|
||||
if ($action == "all") {
|
||||
|
||||
$r = Jobs::addJob(['job_name' => 'excelMultieventFileFormateValidation', 'payload' => ['file_id' => $file_id]]);
|
||||
$this->myLogger->logme("error", '{file_id} is greather than 1MB, validating with job queue', ['file_id' => $file_id]);
|
||||
|
||||
} else {
|
||||
//start validation process
|
||||
if ($fileSize < 1) // if file size less than 1
|
||||
@ -309,7 +330,11 @@ class EmployeeController extends AdminController
|
||||
$this->myLogger->logme("error", '{file_id} is less than 1MB, validating on the fly', ['file_id' => $file_id]);
|
||||
//endof validation process
|
||||
if (isset($result['error_summary']) && count($result['error_summary'])) {
|
||||
return $this->respond(['dataStatus' => false, 'code' => 404, 'message' => 'file rejected with errors'], 200);
|
||||
if(!empty($post_data)){
|
||||
return ['status' => true, 'message' => 'file rejected with errors', 'file_id' => $file_id];
|
||||
}else{
|
||||
return $this->respond(['dataStatus' => false, 'code' => 404, 'message' => 'file rejected with errors'], 200);
|
||||
}
|
||||
}
|
||||
} else //if file size greater than 1 add the file as job
|
||||
{
|
||||
@ -319,7 +344,11 @@ class EmployeeController extends AdminController
|
||||
}
|
||||
}
|
||||
|
||||
return $this->respond(['dataStatus' => true, 'code' => 200, 'data' => 'file upload success'], 200);
|
||||
if (!empty($post_data)) {
|
||||
return ['status' => true, 'message' => 'File upload successs, Data validation is in-progress', 'file_id' => $file_id];
|
||||
} else {
|
||||
return $this->respond(['dataStatus' => true, 'code' => 200, 'data' => 'file upload success'], 200);
|
||||
}
|
||||
}
|
||||
|
||||
$data['tab_name'] = 'View Inception';
|
||||
@ -350,7 +379,7 @@ class EmployeeController extends AdminController
|
||||
->select([
|
||||
'files.id','files.file_name','files.created_by','files.created_at','files.is_active','files.status','files.client_id','files.policy_id','files.client_branch_id','files.action','files.uploaded_by',
|
||||
'up.emp_code',
|
||||
'up.first_name',
|
||||
// 'up.first_name',
|
||||
'c.short_name',
|
||||
'cb.branch_name',
|
||||
'cp.id as client_policy_id',
|
||||
@ -358,8 +387,22 @@ class EmployeeController extends AdminController
|
||||
'"0" as total',
|
||||
'policy_type.policy_type' ,
|
||||
'cp.policy_no' ,
|
||||
"CASE
|
||||
WHEN files.hr_id IS NOT NULL THEN
|
||||
CONCAT(
|
||||
(
|
||||
SELECT lc.name
|
||||
FROM level_contect lc
|
||||
WHERE lc.id = files.hr_id
|
||||
LIMIT 1
|
||||
),
|
||||
' (HR)'
|
||||
)
|
||||
ELSE up.first_name
|
||||
END AS first_name
|
||||
"
|
||||
])
|
||||
->join('user_profiles up', 'files.created_by = up.id')
|
||||
->join('user_profiles up', 'files.created_by = up.id', 'left')
|
||||
->join('client_policy cp', 'files.policy_id = cp.id', 'left')
|
||||
->join('client_branch cb', 'files.client_branch_id = cb.id', 'left')
|
||||
->join('policy_type', 'policy_type.id = cp.policy_type_id')
|
||||
@ -435,14 +478,22 @@ class EmployeeController extends AdminController
|
||||
}
|
||||
}
|
||||
|
||||
public function getExcelFileErrors()
|
||||
public function getExcelFileErrors($file_id, $retun_type = null)
|
||||
{
|
||||
$file_id = $this->request->uri->getSegment(3);
|
||||
// $file_id = $this->request->uri->getSegment(3);
|
||||
$empServiceController = new EmployeeServiceController();
|
||||
|
||||
// Render views and capture output
|
||||
$result = $empServiceController->getExcelErrorData($file_id);
|
||||
|
||||
if($retun_type == 'api'){
|
||||
if(!empty($result)){
|
||||
return $this->respond(['status' => true, 'code' => 200, 'message' => 'Error data feteched successfully', 'data' => $result], 200);
|
||||
}else{
|
||||
return $this->respond(['status' => false, 'code' => 404, 'message' => 'Failed to fetch error data', 'data' => []], 200);
|
||||
}
|
||||
}
|
||||
|
||||
if ($result != 0) {
|
||||
|
||||
$result['file_id'] = $file_id;
|
||||
|
||||
@ -159,9 +159,9 @@ class EmployeeRestController extends AdminController
|
||||
->where('employees.client_branch_id', $client_branch_id)
|
||||
->where('employees.is_active', 1)
|
||||
->where('employees.relationship', $relationship)
|
||||
->where('employee_polices.status', ['active'])
|
||||
->whereIn('employee_polices.status', ['active', 'expired'])
|
||||
->where('employees.is_active', 1)
|
||||
->where('employees.emp_status', ['active'])
|
||||
->whereIn('employees.emp_status', ['active', 'expired'])
|
||||
->first();
|
||||
|
||||
if (null !== $this->request->getGet('client_policy_id')) {
|
||||
@ -2929,6 +2929,7 @@ class EmployeeRestController extends AdminController
|
||||
$data['claim_subject'] = "Claim GTLI";
|
||||
$data['sum_insured_label'] = "Sum Assured";
|
||||
} else if ($ClientPolicyValue['policy_type_id'] == 72){
|
||||
$policyGroup = 'other';
|
||||
$data['ticket_type_id'] = 72;
|
||||
$data['ticket_settled_status_id'] = 76;
|
||||
$data['claim_subject'] = "Claim OPD";
|
||||
@ -3571,6 +3572,20 @@ class EmployeeRestController extends AdminController
|
||||
$get_docs_name = $this->request->getPost('claim_doc_names') ?? [];
|
||||
$policy_transaction_id = $this->request->getPost('policy_transaction_id') ?? null;
|
||||
|
||||
$client_policy_data = $this->clientPolicyModel->where('id', $received_data['client_policy_id'] ?? null)->first();
|
||||
|
||||
$isduplicate = checkDuplicateClaim([
|
||||
'doa' => change_date_format($received_data['doa'] ?? '') ?? null,
|
||||
'emp_code' => $received_data['emp_code'] ?? null,
|
||||
'claim_amount' => $received_data['claim_amount'] ?? null,
|
||||
'policy_no' => $client_policy_data['policy_no'] ?? null
|
||||
]);
|
||||
|
||||
if($isduplicate){
|
||||
$response = ['status' => false, 'code' => 404, 'message' => 'Claim already exist'];
|
||||
return $this->respond($response, 200);
|
||||
}
|
||||
|
||||
if(!empty($policy_transaction_id)){
|
||||
$response = $this->retailClaimInitiate($received_data);
|
||||
return $this->respond($response, 200);
|
||||
@ -3648,6 +3663,7 @@ class EmployeeRestController extends AdminController
|
||||
|
||||
if (!empty($emp_ticket_data)) {
|
||||
|
||||
unset($received_data['relationship']);
|
||||
$fetchData = $emp_ticket_data[0];
|
||||
|
||||
$claimStatusQuery = $this->claimStatusModel
|
||||
@ -3671,7 +3687,9 @@ class EmployeeRestController extends AdminController
|
||||
$fetchData['claim_type'] = 1;
|
||||
$fetchData = array_merge($fetchData, $received_data);
|
||||
|
||||
$fetchData['relationship'] = strtolower($fetchData['relationship']) ?? $fetchData['relationship'];
|
||||
// $fetchData['relationship'] = strtolower($fetchData['relationship']) ?? $fetchData['relationship'];
|
||||
$fetchData['relationship'] = isset($fetchData['relationship']) ? strtolower($fetchData['relationship']) : null;
|
||||
|
||||
// print_r($fetchData); die;
|
||||
$insert_status = $this->ticketMaster->insert($fetchData);
|
||||
$ticket_id = $this->ticketMaster->insertID();
|
||||
@ -4434,57 +4452,105 @@ class EmployeeRestController extends AdminController
|
||||
public function hrFileUpload()
|
||||
{
|
||||
try {
|
||||
// Check file
|
||||
$file = $this->request->getFile('file_name');
|
||||
if (!$file) {
|
||||
return $this->response->setJSON([
|
||||
'status' => false,
|
||||
'message' => "Invalid file or file not uploaded.",
|
||||
'data' => "No Data"
|
||||
]);
|
||||
}
|
||||
|
||||
// Upload folder path
|
||||
$uploadPath = WRITEPATH . 'uploads/hr_files/';
|
||||
|
||||
// If directory not exists, create it
|
||||
if (!is_dir($uploadPath)) {
|
||||
mkdir($uploadPath, 0777, true);
|
||||
}
|
||||
|
||||
// New file name with timestamp
|
||||
$newFileName = time() . '_' . $file->getRandomName();
|
||||
|
||||
// Move file
|
||||
$file->move($uploadPath, $newFileName);
|
||||
|
||||
// Prepare data
|
||||
$data = [
|
||||
'client_id' => $this->request->getPost('client_id'),
|
||||
$post_data = [
|
||||
'client_id' => $this->request->getPost('client_id') ?? null,
|
||||
'client_branch_id' => $this->request->getPost('client_branch_id'),
|
||||
'policy_id' => $this->request->getPost('policy_id'),
|
||||
'policy_no' => $this->request->getPost('policy_no'),
|
||||
'file_name' => $newFileName,
|
||||
'file_action' => $this->request->getPost('file_action'),
|
||||
'status' => 'Yet to start',
|
||||
'created_by' => $this->request->getPost('created_by'),
|
||||
'updated_by' => $this->request->getPost('created_by'),
|
||||
'file_name' => $this->request->getFile('file_name')
|
||||
];
|
||||
// print_r($post_data); die;
|
||||
|
||||
// Save into DB
|
||||
$result = $this->hrFileUploadModel->insert($data);
|
||||
|
||||
if ($result) {
|
||||
$this->giveNotificationToClientsAccountManager($data);
|
||||
if(empty($post_data['client_id'])){
|
||||
return $this->respondCreated(['status' => false, 'message' => 'Client is required', 'data' => []]);
|
||||
}
|
||||
|
||||
return $this->respondCreated([
|
||||
$client_data = $this->clientModel->where('id', $post_data['client_id'])->first();
|
||||
// print_r($client_data); die;
|
||||
|
||||
if($client_data['hr_file_processed_by'] == 1){
|
||||
$responce = $this->fileUploadInFilesTable($post_data);
|
||||
}else{
|
||||
$responce = $this->fileUploadInHrFileUploadTable($post_data);
|
||||
}
|
||||
|
||||
return $this->respondCreated($responce);
|
||||
|
||||
} catch (\Exception $e) {
|
||||
// return $this->failServerError($e->getMessage());
|
||||
return $this->respondCreated(['status' => false, 'message' => $e->getMessage(), 'data' => []]);
|
||||
}
|
||||
}
|
||||
|
||||
public function fileUploadInHrFileUploadTable($post_data)
|
||||
{
|
||||
// Check file
|
||||
$file = $post_data['file_name'];
|
||||
|
||||
if (!$file) {
|
||||
return [
|
||||
'status' => false,
|
||||
'message' => "Invalid file or file not uploaded.",
|
||||
'data' => []
|
||||
];
|
||||
}
|
||||
|
||||
// Upload folder path
|
||||
$uploadPath = WRITEPATH . 'uploads/hr_files/';
|
||||
|
||||
// If directory not exists, create it
|
||||
if (!is_dir($uploadPath)) {
|
||||
mkdir($uploadPath, 0777, true);
|
||||
}
|
||||
|
||||
// New file name with timestamp
|
||||
$newFileName = time() . '_' . $file->getRandomName();
|
||||
|
||||
// Move file
|
||||
$file->move($uploadPath, $newFileName);
|
||||
|
||||
// Prepare data
|
||||
$data = [
|
||||
'client_id' => $this->request->getPost('client_id'),
|
||||
'client_branch_id' => $this->request->getPost('client_branch_id'),
|
||||
'policy_id' => $this->request->getPost('policy_id'),
|
||||
'policy_no' => $this->request->getPost('policy_no'),
|
||||
'file_name' => $newFileName,
|
||||
'file_action' => $this->request->getPost('file_action'),
|
||||
'status' => 'Yet to start',
|
||||
'created_by' => $this->request->getPost('created_by'),
|
||||
'updated_by' => $this->request->getPost('created_by'),
|
||||
];
|
||||
|
||||
// Save into DB
|
||||
$result = $this->hrFileUploadModel->insert($data);
|
||||
|
||||
if ($result) {
|
||||
$this->giveNotificationToClientsAccountManager($data);
|
||||
$response = [
|
||||
'status' => true,
|
||||
'message' => 'File uploaded successfully',
|
||||
'data' => $data
|
||||
]);
|
||||
} catch (\Exception $e) {
|
||||
return $this->failServerError($e->getMessage());
|
||||
];
|
||||
return $response;
|
||||
}
|
||||
}
|
||||
|
||||
public function fileUploadInFilesTable($post_data)
|
||||
{
|
||||
$employeeController = new EmployeeController();
|
||||
$responce = $employeeController->employeesUplodWithEvents($post_data);
|
||||
// print_r($responce); die;
|
||||
|
||||
if($responce['status']){
|
||||
$file_data = $this->getDataFromHrFilesTable(['file_id' => $responce['file_id']]);
|
||||
$responce['data'] = $file_data;
|
||||
return $responce;
|
||||
}else{
|
||||
$responce['data'] = [];
|
||||
return $responce;
|
||||
}
|
||||
}
|
||||
|
||||
@ -4643,17 +4709,48 @@ class EmployeeRestController extends AdminController
|
||||
public function hrFileList()
|
||||
{
|
||||
try {
|
||||
|
||||
$request = service('request');
|
||||
$search_data = $request->getGetPost() ?? []; // supports both GET and POST
|
||||
$table = "";
|
||||
|
||||
// Start builder from model
|
||||
// $builder = $this->hrFileUploadModel
|
||||
// ->select('hr_file_upload.* , c.short_name , cb.branch_name , lc.name as first_name')
|
||||
// ->join('clients c', 'c.id = hr_file_upload.client_id AND c.is_active = 1', 'left')
|
||||
// ->join('client_branch cb', 'cb.id = hr_file_upload.client_branch_id AND cb.is_active = 1', 'left')
|
||||
// ->join('level_contacts lc', 'lc.id = hr_file_upload.created_by AND lc.contact_type = "client" AND lc.is_active = 1', 'left');
|
||||
if(isset($search_data['hr_file_type']) && $search_data['hr_file_type'] == "CRM"){
|
||||
$data = $this->getDataFromHrFileUploadTable($search_data);
|
||||
$table = "hr_file_upload";
|
||||
}else{
|
||||
$client_data = $this->clientModel->where('id', $search_data['client_id'])->first();
|
||||
if($client_data['hr_file_processed_by'] == 1){
|
||||
$data = $this->getDataFromHrFileUploadTable($search_data);
|
||||
$table = "hr_file_upload 2";
|
||||
}else{
|
||||
$data = $this->getDataFromHrFilesTable($search_data);
|
||||
$table = "files";
|
||||
}
|
||||
}
|
||||
|
||||
$builder = $this->hrFileUploadModel
|
||||
->select('
|
||||
return $this->respond([
|
||||
'status' => "success",
|
||||
'message' => 'File list fetched successfully',
|
||||
'data' => $data,
|
||||
'table' => $table
|
||||
]);
|
||||
|
||||
} catch (\Exception $e) {
|
||||
return $this->failServerError($e->getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
public function getDataFromHrFileUploadTable($search_data)
|
||||
{
|
||||
// Start builder from model
|
||||
// $builder = $this->hrFileUploadModel
|
||||
// ->select('hr_file_upload.* , c.short_name , cb.branch_name , lc.name as first_name')
|
||||
// ->join('clients c', 'c.id = hr_file_upload.client_id AND c.is_active = 1', 'left')
|
||||
// ->join('client_branch cb', 'cb.id = hr_file_upload.client_branch_id AND cb.is_active = 1', 'left')
|
||||
// ->join('level_contacts lc', 'lc.id = hr_file_upload.created_by AND lc.contact_type = "client" AND lc.is_active = 1', 'left');
|
||||
|
||||
$builder = $this->hrFileUploadModel
|
||||
->select("
|
||||
hr_file_upload.id,
|
||||
hr_file_upload.client_id,
|
||||
hr_file_upload.client_branch_id,
|
||||
@ -4672,51 +4769,112 @@ class EmployeeRestController extends AdminController
|
||||
WHEN f.status IS NULL
|
||||
THEN hr_file_upload.status
|
||||
ELSE CONCAT(UCASE(LEFT(f.status, 1)), LCASE(SUBSTRING(f.status, 2)))
|
||||
END AS status
|
||||
', false)
|
||||
->join('clients c', 'c.id = hr_file_upload.client_id AND c.is_active = 1', 'left')
|
||||
->join('client_branch cb', 'cb.id = hr_file_upload.client_branch_id AND cb.is_active = 1', 'left')
|
||||
->join('level_contacts lc', 'lc.id = hr_file_upload.created_by AND lc.contact_type = "client" AND lc.is_active = 1', 'left')
|
||||
->join(
|
||||
'(SELECT f1.*
|
||||
END AS status,
|
||||
'1' as file_error_status
|
||||
", false)
|
||||
->join('clients c', 'c.id = hr_file_upload.client_id AND c.is_active = 1', 'left')
|
||||
->join('client_branch cb', 'cb.id = hr_file_upload.client_branch_id AND cb.is_active = 1', 'left')
|
||||
->join('level_contacts lc', 'lc.id = hr_file_upload.created_by AND lc.contact_type = "client" AND lc.is_active = 1', 'left')
|
||||
->join(
|
||||
'(SELECT f1.*
|
||||
FROM files f1
|
||||
WHERE f1.is_active = 1
|
||||
ORDER BY f1.id DESC
|
||||
LIMIT 1) f',
|
||||
'f.hr_file_id = hr_file_upload.id',
|
||||
'left'
|
||||
);
|
||||
'f.hr_file_id = hr_file_upload.id',
|
||||
'left'
|
||||
);
|
||||
|
||||
// Allowed filter keys
|
||||
$filters = [
|
||||
'client_id',
|
||||
'client_branch_id',
|
||||
'policy_id',
|
||||
'policy_no',
|
||||
'file_action',
|
||||
'status',
|
||||
'created_by'
|
||||
];
|
||||
// Allowed filter keys
|
||||
$filters = [
|
||||
'client_id',
|
||||
'client_branch_id',
|
||||
'policy_id',
|
||||
'policy_no',
|
||||
'file_action',
|
||||
'status',
|
||||
'created_by'
|
||||
];
|
||||
|
||||
// Apply filters dynamically
|
||||
foreach ($filters as $key) {
|
||||
$value = $request->getGetPost($key); // supports both GET and POST
|
||||
if (!empty($value)) {
|
||||
$builder->where("hr_file_upload.$key", $value);
|
||||
}
|
||||
// Apply filters dynamically
|
||||
foreach ($filters as $key) {
|
||||
$value = $search_data[$key] ?? null; // supports both GET and POST
|
||||
if (!empty($value)) {
|
||||
$builder->where("hr_file_upload.$key", $value);
|
||||
}
|
||||
|
||||
// Execute query
|
||||
$data = $builder->get()->getResultArray();
|
||||
|
||||
return $this->respond([
|
||||
'status' => "success",
|
||||
'message' => 'File list fetched successfully',
|
||||
'data' => $data
|
||||
]);
|
||||
} catch (\Exception $e) {
|
||||
return $this->failServerError($e->getMessage());
|
||||
}
|
||||
|
||||
// Execute query
|
||||
$data = $builder->get()->getResultArray();
|
||||
|
||||
if(!empty($data)){
|
||||
return $data;
|
||||
}
|
||||
|
||||
return [];
|
||||
}
|
||||
|
||||
public function getDataFromHrFilesTable($search_data)
|
||||
{
|
||||
$file_download_base = base_url('util/download-file-list/');
|
||||
$builder = $this->fileModel
|
||||
->select("
|
||||
files.id,
|
||||
files.client_id,
|
||||
files.client_branch_id,
|
||||
files.policy_id,
|
||||
cp.policy_no,
|
||||
files.file_name,
|
||||
files.action,
|
||||
files.created_at,
|
||||
files.created_by,
|
||||
files.updated_at,
|
||||
files.updated_by,
|
||||
c.short_name,
|
||||
cb.branch_name,
|
||||
lc.name as first_name,
|
||||
CONCAT(UCASE(LEFT(files.status, 1)), LCASE(SUBSTRING(files.status, 2))) as status,
|
||||
CASE
|
||||
WHEN status = 'failed' THEN 1
|
||||
ELSE 0
|
||||
END AS file_error_status,
|
||||
CONCAT('{$file_download_base}', files.id, '/api') AS file_download_link
|
||||
", false)
|
||||
->join('clients c', 'files.client_id = c.id AND c.is_active = 1', 'left')
|
||||
->join('client_branch cb', 'files.client_branch_id = cb.id AND cb.is_active = 1', 'left')
|
||||
->join('client_policy cp', 'files.policy_id = cp.id AND cp.is_active = 1', 'left')
|
||||
->join('level_contacts lc', 'files.hr_id = lc.id AND lc.contact_type = "client" AND lc.is_active = 1', 'left');
|
||||
|
||||
|
||||
if (isset($search_data['policy_id']) && !empty($search_data['policy_id'])) {
|
||||
$builder->where("files.policy_id", $search_data['policy_id']);
|
||||
}
|
||||
|
||||
if (isset($search_data['created_by']) && !empty($search_data['created_by'])) {
|
||||
$builder->where("files.hr_id", $search_data['created_by']);
|
||||
}
|
||||
|
||||
if (isset($search_data['policy_no']) && !empty($search_data['policy_no'])) {
|
||||
$builder->where("cp.policy_no", $search_data['policy_no']);
|
||||
}
|
||||
|
||||
if (isset($search_data['client_id']) && !empty($search_data['client_id'])) {
|
||||
$builder->where("files.client_id", $search_data['client_id']);
|
||||
}
|
||||
|
||||
if (isset($search_data['file_id']) && !empty($search_data['file_id'])) {
|
||||
$builder->where("files.id", $search_data['file_id']);
|
||||
}
|
||||
|
||||
|
||||
// Execute query
|
||||
$data = $builder->get()->getResultArray();
|
||||
|
||||
if (!empty($data)) {
|
||||
return $data;
|
||||
}
|
||||
|
||||
return [];
|
||||
}
|
||||
|
||||
public function hrFileUploadMasters()
|
||||
|
||||
@ -138,6 +138,9 @@ class MediAssistApiController extends BaseController
|
||||
if($response['status'] != true){
|
||||
|
||||
log_message('error', 'TPA CLAIM PUSH FAILED | claimId: '.$claimId.' | response: '.json_encode($response));
|
||||
$this->db->table('ticket_master')
|
||||
->where('id',$claimId)
|
||||
->update([ 'tpa_push_response' => json_encode($response) ]);
|
||||
return;
|
||||
}
|
||||
|
||||
@ -1106,7 +1109,9 @@ class MediAssistApiController extends BaseController
|
||||
$ticket = $this->db->table('ticket_master tm')->select("tm.id")
|
||||
->where('tm.policy_no', $value['policY_NUMBER'])
|
||||
->where('tm.emp_code', $value['employeE_NO'])
|
||||
->where('tm.claim_number', $value['tpA_CLAIM_NO'])
|
||||
->where('tm.claim_amount', $value['estimateD_CLAIM_AMOUNT'])
|
||||
->where('tm.doa', $this->mediDate($value['datE_OF_ADMISSION'] ?? null))
|
||||
// ->where('tm.claim_number', $value['tpA_CLAIM_NO'])
|
||||
->get()
|
||||
->getRowArray();
|
||||
|
||||
@ -1173,6 +1178,7 @@ class MediAssistApiController extends BaseController
|
||||
")
|
||||
->join('client_rm', 'client_rm.client_id = cp.client_id AND client_rm.level = 3', 'left')
|
||||
->where('cp.policy_no', $value['policY_NUMBER'])
|
||||
->orderBy('client_rm.id','DESC')
|
||||
->get()
|
||||
->getRowArray();
|
||||
|
||||
@ -1181,12 +1187,14 @@ class MediAssistApiController extends BaseController
|
||||
e.id as emp_id,
|
||||
e.emp_code ,
|
||||
e2.id as insured_emp_id,
|
||||
ep.tpa_id as tpa_no,
|
||||
")
|
||||
->join(
|
||||
'employees e2',
|
||||
"e2.emp_code = e.emp_code AND e2.relationship = ".$this->db->escape($relationship),
|
||||
'left'
|
||||
)
|
||||
->join( 'employee_polices ep', "ep.employee_id = e2.id ", 'left' )
|
||||
->where('e.emp_code', $value['employeE_NO'])
|
||||
->where('e.relationship', 'self')
|
||||
->get()
|
||||
@ -1200,7 +1208,7 @@ class MediAssistApiController extends BaseController
|
||||
'claim_status_id' => $claimStatusId,
|
||||
'policy_no' => $value['policY_NUMBER'] ?? null,
|
||||
'claim_number' => $value['tpA_CLAIM_NO'] ?? null,
|
||||
'tpa_claim_id' => $value['tpA_CLAIM_NO'] ?? null,
|
||||
'tpa_claim_id' => $value['tpA_CLAIM_NO'] ?? null,
|
||||
|
||||
// local promary id
|
||||
'tpa_id' => $clientpolicy['tpa_id'] ?? null,
|
||||
@ -1212,6 +1220,7 @@ class MediAssistApiController extends BaseController
|
||||
// Employee / Insured
|
||||
'emp_id' => $employee['emp_id'] ?? null,
|
||||
'insured_emp_id' => $employee['insured_emp_id'] ?? null,
|
||||
'tpa_no' => $employee['tpa_no'] ?? null,
|
||||
'emp_code' => $value['employeE_NO'] ?? null,
|
||||
'emp_name' => $value['employeE_NAME'] ?? null,
|
||||
'insured_name' => $value['beneficiarY_NAME'] ?? null,
|
||||
@ -1250,9 +1259,8 @@ class MediAssistApiController extends BaseController
|
||||
$this->db->table('ticket_master')->insert($claimData);
|
||||
|
||||
log_message(
|
||||
'info',
|
||||
'New claim created | Policy: '.$claimData['policy_no'].
|
||||
' | Claim: '.$claimData['claim_number']
|
||||
'error',
|
||||
'New claim created | Policy: '.$claimData['policy_no'].' | Claim: '.$claimData['claim_number']
|
||||
);
|
||||
|
||||
}
|
||||
|
||||
@ -234,8 +234,24 @@ class ThzController extends BaseController
|
||||
->where('thz_master.thz_id', $thz_id)
|
||||
->findAll();
|
||||
|
||||
$clientId = $result['master'][0]['client_id'];
|
||||
|
||||
$accManagerId = $this->getAcmIdUsingClientId($clientId ?? null);
|
||||
|
||||
$accManager = $this->userModel->find($accManagerId);
|
||||
|
||||
if (!empty($result['master'])) {
|
||||
$notes = $this->thzMasterNotesModel->ticketConversationList($thz_id, $returnType);
|
||||
$accManagerName = $accManager['first_name'] ?? '';
|
||||
|
||||
foreach ($notes as &$note) {
|
||||
|
||||
if (empty($note['name'])) {
|
||||
$note['name'] = $accManagerName;
|
||||
}
|
||||
}
|
||||
|
||||
unset($note);
|
||||
$result['notes'] = !empty($notes) ? $notes : [];
|
||||
} else {
|
||||
$this->myLogger->logme('error', 'No tickets found for ticket id ' . json_encode($thz_id));
|
||||
|
||||
@ -1124,6 +1124,43 @@ class TicketController extends BaseController
|
||||
// $ticket_data = $this->getLastMatchedStatus($ticket_data, );
|
||||
// print_rr($ticket_data); die;
|
||||
|
||||
$isduplicate = checkDuplicateClaim([
|
||||
'doa' => change_date_format($ticket_data['doa'] ?? '') ?? null,
|
||||
'emp_code' => $ticket_data['emp_code'] ?? null,
|
||||
'claim_amount' => $ticket_data['claim_amount'] ?? null,
|
||||
'policy_no' => $ticket_data['policy_no'] ?? null
|
||||
]);
|
||||
|
||||
if ($isduplicate) {
|
||||
|
||||
$errorDetails = [];
|
||||
|
||||
if (!empty($ticket_data['doa'])) {
|
||||
$errorDetails[] = 'DOA: ' . change_date_format($ticket_data['doa']);
|
||||
}
|
||||
|
||||
if (!empty($ticket_data['claim_amount'])) {
|
||||
$errorDetails[] = 'Claim Amount: ₹' . number_format($ticket_data['claim_amount'], 2);
|
||||
}
|
||||
|
||||
if (!empty($ticket_data['emp_code'])) {
|
||||
$errorDetails[] = 'Emp Code: ' . $ticket_data['emp_code'];
|
||||
}
|
||||
|
||||
if (!empty($ticket_data['policy_no'])) {
|
||||
$errorDetails[] = 'Policy No: ' . $ticket_data['policy_no'];
|
||||
}
|
||||
|
||||
$response = [
|
||||
'status' => false,
|
||||
'code' => 409,
|
||||
'message' => 'Duplicate claim found for ' . implode(', ', $errorDetails)
|
||||
];
|
||||
|
||||
return $this->respond($response, 200);
|
||||
}
|
||||
|
||||
|
||||
if ($ticket_data) {
|
||||
$return_value = $this->ticketMasterModel->insert($ticket_data);
|
||||
if ($return_value) {
|
||||
|
||||
@ -244,6 +244,9 @@ class VidalApiController extends BaseController
|
||||
|
||||
if($response['status'] != true){
|
||||
log_message('error', 'TPA CLAIM PUSH FAILED | claimId: '.$claimId.' | response: '.json_encode($response));
|
||||
$this->db->table('ticket_master')
|
||||
->where('id',$claimId)
|
||||
->update([ 'tpa_push_response' => json_encode($response) ]);
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
@ -6,6 +6,7 @@ use App\Models\BatchFileModelFileModel;
|
||||
use App\Controllers\GoogleDriveController;
|
||||
use App\Models\BatchFileModel;
|
||||
use App\Controllers\ApiServiceController;
|
||||
use App\Models\TicketMasterModel;
|
||||
|
||||
// File: app/Helpers/Uuid_helper.php
|
||||
|
||||
@ -940,6 +941,28 @@ if (!function_exists('getMimeTypeByFileName')) {
|
||||
}
|
||||
}
|
||||
|
||||
if (!function_exists('validateExcelFile')) {
|
||||
|
||||
function validateExcelFile($file)
|
||||
{
|
||||
$allowed = [
|
||||
'application/vnd.ms-excel',
|
||||
'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet',
|
||||
'application/vnd.oasis.opendocument.spreadsheet'
|
||||
];
|
||||
|
||||
// if ($file->getError() !== UPLOAD_ERR_OK) return 'Upload error';
|
||||
// if ($file->getSize() > (16 * 1024 * 1024)) return 'File too large';
|
||||
// if (!in_array($file->getClientMimeType(), $allowed, true)) return 'Invalid file type';
|
||||
|
||||
if ($file->getError() !== UPLOAD_ERR_OK) return false;
|
||||
if ($file->getSize() > (16 * 1024 * 1024)) return false;
|
||||
if (!in_array($file->getClientMimeType(), $allowed, true)) return false;
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
if (!function_exists('generate_ecard_download_link_based_on_tpa')) {
|
||||
|
||||
function generate_ecard_download_link_based_on_tpa($params) {
|
||||
@ -956,3 +979,34 @@ if (!function_exists('generate_ecard_download_link_based_on_tpa')) {
|
||||
}
|
||||
}
|
||||
|
||||
if (!function_exists('checkDuplicateClaim')) {
|
||||
|
||||
function checkDuplicateClaim(array $params): bool
|
||||
{
|
||||
$ticketMaster = new TicketMasterModel();
|
||||
$query = $ticketMaster->where('is_active', 1);
|
||||
|
||||
if(empty($params['doa']) && empty($params['claim_amount'])){
|
||||
return false;
|
||||
}
|
||||
|
||||
$hasValidCondition = false;
|
||||
|
||||
foreach ($params as $key => $value) {
|
||||
if ($value !== null && $value !== '') {
|
||||
$query->where($key, $value);
|
||||
$hasValidCondition = true;
|
||||
}
|
||||
}
|
||||
|
||||
if (!$hasValidCondition) {
|
||||
return false;
|
||||
}
|
||||
|
||||
$result = $query->countAllResults();
|
||||
// print_r($ticketMaster->getLastQuery()->getQuery()); die;
|
||||
if($result > 0){ return true; }else{ return false; }
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
@ -42,6 +42,7 @@ class ClientModel extends Model
|
||||
"addon_subheading",
|
||||
"parent_client_id",
|
||||
"otp",
|
||||
"hr_file_processed_by",
|
||||
];
|
||||
|
||||
|
||||
|
||||
@ -23,6 +23,7 @@ class FileModel extends Model
|
||||
"updated_by",
|
||||
"hr_file_id",
|
||||
"is_comparison_skipped",
|
||||
"hr_id",
|
||||
];
|
||||
|
||||
|
||||
|
||||
@ -206,9 +206,8 @@ class InvoiceModel extends Model
|
||||
WHEN payout_status = 2 THEN 'Completed'
|
||||
END AS status_text,
|
||||
|
||||
partner_agent.name as agent_name
|
||||
")
|
||||
->join('partner_agent', 'partner_invoice.agent_id = partner_agent.id')
|
||||
// ->join('partner_agent', 'partner_invoice.agent_id = partner_agent.id')
|
||||
->where('partner_invoice.is_active', 1)
|
||||
->where('partner_invoice.id', $invoice_id)
|
||||
->first();
|
||||
|
||||
@ -142,6 +142,32 @@ input:checked + .slider:before {
|
||||
</select>
|
||||
</div>
|
||||
|
||||
<div class="form-group col-md-4">
|
||||
|
||||
<label>HR File Processed By <span class="text-danger">*</span></label>
|
||||
<div class="d-flex align-items-center">
|
||||
<div class="form-check form-check-inline mb-0" style="margin-right: -356px;">
|
||||
<input class="form-check-input"
|
||||
type="radio"
|
||||
name="hr_file_processed_by"
|
||||
id="hr_processed"
|
||||
value="1" <?php echo(isset($client['hr_file_processed_by']) && $client['hr_file_processed_by'] == 1) ? 'checked' : '' ?>>
|
||||
<label class="form-check-label" for="hr_processed">HR</label>
|
||||
</div>
|
||||
|
||||
<div class="form-check form-check-inline mb-0">
|
||||
<input class="form-check-input"
|
||||
type="radio"
|
||||
name="hr_file_processed_by"
|
||||
id="account_manager_processed"
|
||||
value="2"
|
||||
<?php echo(isset($client['hr_file_processed_by']) && $client['hr_file_processed_by'] == 2) ? 'checked' : '' ?>>
|
||||
<label class="form-check-label" for="account_manager_processed">Account Manager</label>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
|
||||
</div>
|
||||
<hr>
|
||||
</div>
|
||||
|
||||
@ -851,4 +851,11 @@
|
||||
|
||||
}
|
||||
|
||||
$('#tickets-table tbody').on('click', 'td', function () {
|
||||
const colIndex = this.cellIndex;
|
||||
const rowIndex = this.parentElement.rowIndex - 1; // minus header
|
||||
console.log('Row:', rowIndex, 'Column:', colIndex);
|
||||
init();
|
||||
});
|
||||
|
||||
</script>
|
||||
|
||||
@ -622,7 +622,7 @@ function fetchFileError(file_id) {
|
||||
file_error_html += (file_error_html != "" ?
|
||||
"<a href ='<?php echo base_url()?>" +
|
||||
"employee/excel_error/" + file_id +
|
||||
"' target=_blank class='text-center'>click here to more details...</a>" : "");
|
||||
"' target=_blank class='text-center'>Click here to more details...</a>" : "");
|
||||
}
|
||||
|
||||
// console.log(file_error_html);
|
||||
@ -1106,7 +1106,7 @@ function checkWellnessOnboardStatus(event)
|
||||
console.log('check wellness response', response);
|
||||
if(response.data && response.data != 0)
|
||||
{
|
||||
var btn_txt = 'click here to onboard ('+ response.data +') employees to Visit wellness';
|
||||
var btn_txt = 'Click here to onboard ('+ response.data +') employees to Visit wellness';
|
||||
$("#on_board_btn_txt").attr("data-id", response.data);
|
||||
$('#on_board_btn_txt').text(btn_txt);
|
||||
$('#onboard_div').show();
|
||||
|
||||
@ -37,7 +37,8 @@
|
||||
<!-- <div class="text-center"> -->
|
||||
<form class="parsley-examples" id="hr_file_upload_search" >
|
||||
<input type="hidden" name="<?= csrf_token() ?>" value="<?= csrf_hash() ?>" id="csrf_token">
|
||||
|
||||
<input type="hidden" name="hr_file_type" value="CRM">
|
||||
|
||||
<div class="form-group">
|
||||
<div class="form-row">
|
||||
<div class="form-group col-md-4">
|
||||
|
||||
@ -770,11 +770,15 @@
|
||||
|
||||
if (response.status === true) {
|
||||
toastr.success(response.message, 'SUCCESS');
|
||||
window.location.href = '<?= base_url('ticket/list') ?>';
|
||||
} else {
|
||||
toastr.error(response.message, 'ERROR');
|
||||
if(response.code == 409){
|
||||
toastr.warning(response.message, 'WARNING');
|
||||
}else{
|
||||
toastr.error(response.message, 'ERROR');
|
||||
}
|
||||
}
|
||||
|
||||
window.location.href = '<?= base_url('ticket/list') ?>';
|
||||
},
|
||||
error: function(xhr, status, error) {
|
||||
console.error(xhr.responseText);
|
||||
|
||||
Loading…
Reference in New Issue
Block a user