FEAT_CLAIM_DUMP_UPLOAD : RV

This commit is contained in:
VENKATESHWARAN 2025-08-22 08:50:10 +05:30
parent 1240eef35c
commit ab76c4d426
13 changed files with 2902 additions and 118 deletions

View File

@ -369,6 +369,9 @@ $routes->group("/util", ["filter" => "authMVC"], function ($routes) {
$routes->get('viewHrAccessData', 'ClientController::viewHrAccessData');
$routes->post('saveHrAccessData', 'ClientController::saveHrAccessData');
$routes->get('removeLevelContacts', 'ClientController::removeLevelContacts');
$routes->get('getClaimDumpFileErrorData', 'TicketController::getClaimDumpFileErrorData');
$routes->get("claim_dump_excel_error/(:any)", "TicketController::getClaimDumpExcelFileErrors/$1");
$routes->get("download_claim_dump_file/(:any)", "TicketController::downloadClaimDumpFile/$1");
});
$routes->post("policy_tranction/sendInstallmentRemainderMail","PolicyTransactionController::sendInstallmentRemainderMail");

View File

@ -143,7 +143,11 @@ class ClientController extends AdminController
// Perform the query
$builder = $db->table($table);
$isDuplicate = $builder->where($field, $value)->where('is_active', 1)->countAllResults() > 0;
if(is_array($value)){
$isDuplicate = $builder->where($value)->where('is_active', 1)->countAllResults() > 0;
}else{
$isDuplicate = $builder->where($field, $value)->where('is_active', 1)->countAllResults() > 0;
}
// Return the result
return $this->response->setJSON(['isDuplicate' => $isDuplicate]);
@ -5037,7 +5041,16 @@ class ClientController extends AdminController
// $employeeController = new EmployeeController();
// $employeeController->truncateFileData('633');
// ---------- TICKET SERVICE CONTROLLER --------------------------------------------------------------------------------
$ticketServiceController = new TicketServiceController();
// $response = $ticketServiceController->claimDumpExcelFileFormatValidation(["file_id" => 3]);
// $response = $ticketServiceController->claimDumpExcelFileDataValidation(["file_id" => 3]);
// $response = $ticketServiceController->claimDumpOnBoardProcess(["file_id" => 3]);
// $response = $ticketServiceController->extractExcelData("claims_dump_form_client.xlsx");
// dd($response);
// ---------- EMP SERVICE CONTROLLER --------------------------------------------------------------------------------
$empServiceController = new EmployeeServiceController();
@ -5054,18 +5067,18 @@ class ClientController extends AdminController
// ---------- POLICY TRANSACTION CONTROLLER --------------------------------------------------------------------------------
$policyTransactionController = new PolicyTransactionController();
// $res = $policyTransactionController->validateInsurerStatement(['file_id' => '17']);
// $res = $policyTransactionController->validateInsurerStatement(['file_id' => '57']);
// $res = $policyTransactionController->updateInsurerStatement(['file_id' => '22']);
// dd('-----', $res);
// ----------EMP DATA SERVICE CONTROLLER--------------------------------------------------------------------------------
$batch_data = [
'client_id' => 20,
'client_branch_id' => 72,
'client_policy_id' => 127,
'client_id' => 51,
'client_branch_id' => 40,
'client_policy_id' => 63,
'insurer_or_tpa' => "insurer",
'event_type' => "deletion",
'event_type' => "correction",
'actions' => "export",
'file_name' => "deletion_enhancement_test_file.xlsx",
];
@ -5132,25 +5145,30 @@ class ClientController extends AdminController
// $EmpDataServiceController->cashDepositCalculationForDeletion($array);
// $result = $this->employeePolicyModel->getInceptionEmployeeDataForExportExcel($batch_data);
// $result = $this->employeePolicyModel->getCorrectionEmployeesDataForExportExcel($batch_data);
// dd(db_connect()->getLastQuery());
// ------------- LEADS CONTROLLER ----------------------------------------------------------
$LeadsController = new LeadsController();
// $RFQModel = new RFQModel();
$RFQModel = new RFQModel();
// $data = $RFQModel->where('is_active', 1)->where('lead_id', 40)->first();
// // dd($data);
// $data = $RFQModel->where('is_active', 1)->where('lead_id', 323)->orderBy('id', 'desc')->first();
// $data = db_connect()->table('leads')->where('is_active', 1)->where('id', 326)->orderBy('id', 'desc')->get()->getResultArray();
// dd($data);
// $policy_type = 2;
// $proposel_name = "Proposal 2";
// $insurer_name = "ICICI-P-ICICI002-V1";
// $jsonArray = json_decode($data['json'], true);
// // dd($jsonArray);
// dd($jsonArray);
// $returndata = $LeadsController->convertQCRJsonToPolicyTerms($jsonArray, $policy_type, $proposel_name, $insurer_name);
// dd($returndata);
// $LeadsController->handleMemberDataGPATotalSumInsurerFromExcel(['lead_id' => 169]);
// $res = $LeadsController->convertQCRJsonToPolicyTerms($jsonArray, $policy_type, $proposel_name, $insurer_name);
// $res = $LeadsController->handleMemberDataGPATotalSumInsurerFromExcel(['lead_id' => 169]);
// $res = $LeadsController->reorderProposalsByInsurerTotal($jsonArray);
// $res = $LeadsController->calculateMembersDemography(['lead_id' => 326]);
// $res = $LeadsController->generateDemographyDataTable(['lead_id' => 326]);
// echo $res;
// dd($res);
// -----------BDS REPORT CONTROLLER---------------------------------------------------------------------------------

View File

@ -143,6 +143,18 @@ class JobWorker extends AdminController
'type' => 'CC', // Handler Category
'handler' => 'App\Controllers\ClientController',
],
'claimDumpExcelFileFormatValidation' => [
'type' => 'CC', // Handler Category
'handler' => 'App\Controllers\TicketServiceController',
],
'claimDumpExcelFileDataValidation' => [
'type' => 'CC', // Handler Category
'handler' => 'App\Controllers\TicketServiceController',
],
'claimDumpOnBoardProcess' => [
'type' => 'CC', // Handler Category
'handler' => 'App\Controllers\TicketServiceController',
],
];

View File

@ -995,8 +995,16 @@ class PolicyTransactionController extends BaseController
if ($id) {
$data['is_active'] = 0;
$this->policyTransactionModel->where('id', $id)->set($data)->update();
$this->PTCOShareDetailsModel->where('pt_id', $id)->set($data)->update();
$policy_transaction_data = $this->policyTransactionModel->where('id', $id)->first();
if($policy_transaction_data['policy_type_id'] > 7){
$this->policyTransactionModel->where('id', $id)->set($data)->update();
$this->PTCOShareDetailsModel->where('pt_id', $id)->set($data)->update();
$this->clientPolicyModel->where('id', $policy_transaction_data['client_policy_id'])->set($data)->update();
}else{
$this->policyTransactionModel->where('id', $id)->set($data)->update();
$this->PTCOShareDetailsModel->where('pt_id', $id)->set($data)->update();
}
return $this->respond(['status' => true, 'code' => 200, 'message' => 'Policy Transaction removed successfully'], 200);
} else {

View File

@ -21,6 +21,7 @@ use App\Models\InsurerModel;
use App\Models\EmployeeModel;
use App\Models\TPAModel;
use App\Models\ClaimFilesModel;
use App\Models\ClaimDumpFileModel;
use DOMDocument;
use Psr\Log\LoggerInterface;
@ -60,6 +61,7 @@ class TicketController extends BaseController
protected $insurerModel;
protected $TPAModel;
protected $claimFilesModel;
protected $claimDumpFileModel;
public function __construct()
{
@ -345,6 +347,7 @@ class TicketController extends BaseController
$this->insurerModel = new InsurerModel();
$this->TPAModel = new TPAModel();
$this->claimFilesModel = new ClaimFilesModel();
$this->claimDumpFileModel = new ClaimDumpFileModel();
}
public function ticketList()
@ -2445,6 +2448,154 @@ class TicketController extends BaseController
}
// -------- CLAIM DUMP UPLOAD ----------------------------------------------------------------------------------------------
public function claimDumpUpload()
{
$data['page_name'] = "Claim Dupm Upload";
if($this->request->is('get')){
$data['claim_dump_file_data'] = $this->claimDumpFileModel
->select('
claim_dump_files.id as file_id,
claim_dump_files.file_name,
claim_dump_files.status,
claim_dump_files.created_at,
up.first_name as user_name
')
->join('user_profiles as up', 'claim_dump_files.created_by = up.id', 'left')
->where('claim_dump_files.is_active', 1)
->findAll();
return $this->loadLayout('claim_dump_file_list', $data);
}else{
// print_r($this->request->getFile('claim_dump_list')); die;
$filename = '';
$fileSize = '';
//validate uploaded file
$validated = $this->validate([
'claim_dump_list' => [
'uploaded[claim_dump_list]',
'mime_in[claim_dump_list,application/vnd.ms-excel,application/vnd.openxmlformats-officedocument.spreadsheetml.sheet,application/vnd.oasis.opendocument.spreadsheet]',
'max_size[claim_dump_list,16384]',
],
]);
if ($validated)
{
$avatar = $this->request->getFile('claim_dump_list');
if (!$avatar) {
$this->myLogger->logme("error", 'File not found');
return $this->respond(['status' => false, 'code' => 400, 'message' => 'File not found'], 400);
}
$is_moved = $avatar->move(WRITEPATH . 'uploads/claim_dump_excel/');
if ($is_moved) {
$filename = $avatar->getName();
$fileSize = $avatar->getSize(); // File size in bytes
$fileSize = $fileSize / (1024 * 1024); // Convert to MB
$this->myLogger->logme("error", 'File move successful');
} else {
$this->myLogger->logme("error", 'File move failed');
return $this->respond(['status' => false, 'code' => 500, 'message' => 'File move failed'], 500);
}
} else {
$this->myLogger->logme("error", 'Upload failed Invalid file');
return $this->respond(['status' => false, 'code' => 404, 'message' => 'Invalid file'], 404);
}
$status = 'inprogress';
$insert_data = [
'file_name' => $filename,
'status' => $status
];
$file_id = $this->claimDumpFileModel->insert($insert_data);
$this->myLogger->logme("error", 'claim_dumb_file_id : {file_id}, uploaded success', ['file_id' => $file_id]);
//after file upload success than call the file formate validation in service controller
$ticketServiceController = new TicketServiceController();
// $response = $ticketServiceController->claimDumpExcelFileFormatValidation(["file_id" => $file_id]);
$r = Jobs::addJob(['job_name' => 'claimDumpExcelFileFormatValidation', 'payload' => ['file_id' => $file_id]]);
return $this->respond(['status' => true, 'code' => 200, 'message' => 'File uploaded successfully. File being validated'], 200);
}
}
public function getClaimDumpFileErrorData()
{
$file_id = $this->request->getGet('file_id');
$file = $this->claimDumpFileModel->where('id', $file_id)->first();
if (!isset($file)) {
return $this->respond(['status' => false, 'code' => 404, 'message' => 'No data found'], 200);
} else {
return $this->respond(['status' => true, 'code' => 200, 'data' => $file['reason']], 200);
}
}
public function getClaimDumpExcelFileErrors($file_id)
{
// $file_id = $this->request->getGet('file_id');
$ticketServiceController = new TicketServiceController();
// Render views and capture output
$result = $ticketServiceController->getClaimExcelErrorData($file_id) ?? [];
// dd($result);
if ($result != 0) {
$result['file_id'] = $file_id;
echo view('excel_errors', $result);
} else if ($result == 0) {
$data['message'] = 'File Not Found Physically';
return view('errors/404', $data);
} else {
echo view('errors/html/production');
}
}
public function downloadClaimDumpFile($file_id)
{
// $actionType = $this->request->getGet();
$file_data = $this->claimDumpFileModel->where('id', $file_id)->first();
$fileName = $file_data['file_name'];
$filePath = WRITEPATH . '/uploads/claim_dump_excel/' . $fileName;
try {
// Check if the file exists
if (file_exists($filePath)) {
// Set the appropriate MIME type
$mimeType = mime_content_type($filePath);
// Send the file to the client for download
return $this->response->download($filePath, null, $mimeType);
} else {
$data['message'] = 'The Physical File Not Found';
echo view('errors/404', $data);
}
} catch (\Exception $e) {
// Handle any exceptions
$errorMessage = $e->getMessage();
$this->myLogger->logme('error', $errorMessage);
// You can return an error response here
echo $errorMessage;
}
}
}

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,179 @@
<?php
use App\Models\EmployeeModel;
use App\Models\InsurerModel;
use App\Models\TPAModel;
use Kint\Kint;
if (!function_exists('check_client')) {
function check_client($params)
{
$client_data = $params['client_data'] ?? [];
$client_name = $params['client_name'] ?? "";
// Kint::dump($client_name);
if (!empty($client_data)) {
foreach ($client_data as $key => $value) {
// Kint::dump($value['client_name'], $client_name);
if(trim($value['client_name']) === trim($client_name)){
return array('status' => true, 'client_id' => $value['id'], 'error' => '');
}
}
}
return array('status' => false, 'error' => 'This Client Name does not exist in the system');
}
}
if (!function_exists('check_insurer')) {
function check_insurer($params)
{
$insurer_data = $params['insurer_data'] ?? [];
$insurer_name = $params['insurer_name'] ?? "";
if (!empty($insurer_data)) {
foreach ($insurer_data as $key => $value) {
if(trim($value['short_name']) === trim($insurer_name)){
return array('status' => true, 'insuer_id' => $value['id'], 'error' => '');
}
}
}
return array('status' => false, 'error' => 'This Insurer does not exist in the system');
}
}
if (!function_exists('check_tpa')) {
function check_tpa($params)
{
$tpa_data = $params['tpa_data'] ?? [];
$tpa_name = $params['tpa_name'] ?? "";
if (!empty($tpa_data)) {
foreach ($tpa_data as $key => $value) {
if(trim($value['short_name']) === trim($tpa_name)){
return array('status' => true, 'tpa_id' => $value['id'], 'error' => '');
}
}
}
return array('status' => false, 'error' => 'This TPA does not exist in the system');
}
}
if (!function_exists('check_status')) {
function check_status($params)
{
$data = $params['data'] ?? [];
$check_value = $params['value'] ?? "";
if (!empty($data)) {
foreach ($data as $key => $value) {
// Kint::dump(strtolower(trim($value['claim_status'])), strtolower(trim($check_value)));
if(strtolower(trim($value['claim_status'])) === strtolower(trim($check_value))){
return array('status' => true, 'status_id' => $value['id'], 'error' => '');
}
}
}
return array('status' => false, 'error' => "This Status ('{$check_value}') does not exist in the system");
}
}
if (!function_exists('check_policy')) {
function check_policy($params)
{
$data = $params['data'] ?? [];
$client_id = $params['client_id'] ?? "";
$check_value = $params['value'] ?? "";
if (!empty($data)) {
foreach ($data as $key => $value) {
if($value['client_id'] === $client_id && trim($value['policy_no']) === trim($check_value)){
return array('status' => true, 'status_id' => $value['id'], 'error' => '');
}
}
}
return array('status' => false, 'error' => "This Policy Number does not exist in the Client");
}
}
if (!function_exists('check_emp_and_insured')) {
function check_emp_and_insured($params)
{
$employee_modal = new EmployeeModel();
$tpa_data = $employee_modal
->join('employee_polices', 'employees.id = employee_polices.employee_id')
->where('employees.client', $params['client_id'])
->where('employees.name', $params['emp_name'])
->where('employees.emp_code', $params['emp_code'])
->where('employees.is_active', 1)
->where('employees.emp_status !=', "truncated")
->where('employee_polices.is_active', 1)
->where('employees.status !=', "truncated")
->first();
if (empty($tpa_data)) {
return false;
}
return $tpa_data['id'];
}
}
if (!function_exists('dynamic_check_excel_date_format')) {
function dynamic_check_excel_date_format($dateString, $format = 'd/m/Y')
{
if ($dateString == "") {
return array('status' => true);
}
$date = DateTime::createFromFormat($format, $dateString);
if ($date && $date->format($format) == $dateString) {
return array('status' => true);
} else {
$res = validate_date_flexible($dateString, $format);
if (!$res) {
return array('status' => false, 'error' => "wrong date format: Expected {$format}({$res}) and received $dateString");
} else {
return array('status' => true);
}
}
}
}
if (!function_exists('validate_date_flexible')) {
function validate_date_flexible($date, $format = 'm/d/Y')
{
// Create a DateTime from the given format
$d = DateTime::createFromFormat($format, $date);
if (!$d) return false;
// Compare normalized values (remove leading zeros)
$original = preg_replace('/\b0+/', '', $date);
$normalized = preg_replace('/\b0+/', '', $d->format($format));
return $original === $normalized;
}
}
if (!function_exists('normalizeDate')) {
function normalizeDate($dateString, $formats = ['d-m-Y', 'd/m/Y', 'm-d-Y', 'm/d/Y', 'Y-m-d'])
{
if (empty($dateString)) {
return null; // keep null if no value
}
foreach ($formats as $format) {
$dt = DateTime::createFromFormat($format, trim($dateString));
if ($dt && $dt->format($format) === trim($dateString)) {
return $dt->format('Y-m-d'); // ✅ return in DB format
}
}
return null; // if no valid format found
}
}
?>

View File

@ -0,0 +1,56 @@
<?php
namespace App\Models;
use CodeIgniter\Model;
class ClaimDumpFileModel extends Model
{
protected $table = 'claim_dump_files';
protected $primaryKey = 'id';
protected $allowedFields = [
"id",
"file_name",
"status",
"reason",
"created_by",
"created_at",
"updated_by",
"updated_at",
"is_active",
];
// Callbacks
protected $allowCallbacks = true;
protected $beforeInsert = ["checkAndADDCreatedByValue"];
protected $afterInsert = [];
protected $beforeUpdate = ["checkAndUpdateUpdatedByValue"];
protected $afterUpdate = [];
protected $beforeFind = [];
protected $afterFind = [];
protected $beforeDelete = [];
protected $afterDelete = [];
protected function checkAndADDCreatedByValue(array $data)
{
// Check if 'updated_by' value is null or empty
if (empty($data['data']['created_by'])) {
// Set 'updated_by' value to the current session user ID
$data['data']['created_by'] = get_session_userid();
}
return $data;
}
protected function checkAndUpdateUpdatedByValue(array $data)
{
// Check if 'updated_by' value is null or empty
if (empty($data['data']['updated_by'])) {
// Set 'updated_by' value to the current session user ID
$data['data']['updated_by'] = get_session_userid();
}
return $data;
}
}

View File

@ -76,7 +76,9 @@ class TicketMasterModel extends Model
'emp_personal_mail',
'client_policy_id',
'approved_description'
'approved_description',
'file_id',
'denial_letter',
];
@ -883,8 +885,6 @@ class TicketMasterModel extends Model
return $finalResults;
}
public function getNotSettledbutApprovedCount($ticket_type)
{
// Fetch the approved and settled claim_status IDs
@ -975,7 +975,198 @@ class TicketMasterModel extends Model
return json_encode(['policy_terms' => null]);
}
// ---------- CLAIM DUMP UPLOAD-------------------------------------------------------------------------------------------
public function getPolicyData($params)
{
$client_name = $params['client_name'] ?? null;
$insurer_short_name = $params['insurer_short_name'] ?? null;
$tpa_short_name = $params['tpa_short_name'] ?? null;
$policy_no = $params['policy_no'] ?? null;
$builder = $this->db->table('client_policy');
$builder->select('client_policy.*');
$builder->join('clients c', 'client_policy.client_id = c.id');
$builder->join('insurers i', 'client_policy.insurer_id = i.id');
$builder->join('tpa', 'client_policy.tpa_id = tpa.id and tpa.is_active = 1', 'left');
$builder->where('c.is_active', 1);
$builder->where('client_policy.is_active', 1);
$builder->where('i.is_active', 1);
$builder->where('c.client_name', trim($client_name));
$builder->where('i.short_name', trim($insurer_short_name));
if(!empty($tpa_short_name)){
$builder->where('tpa.short_name', trim($tpa_short_name));
}
$builder->where('client_policy.policy_no', trim($policy_no));
$query = $builder->get();
$result = $query->getResultArray();
// dd($this->db->getLastQuery());
return $result;
}
public function getTheClaimDetails($params)
{
$client_name = $params['client_name'] ?? null;
$policy_no = $params['policy_no'] ?? null;
$insurer_short_name = $params['insurer_short_name'] ?? null;
$tpa_short_name = $params['tpa_short_name'] ?? null;
$emp_code = $params['emp_code'] ?? null;
$emp_name = $params['emp_name'] ?? null;
$insured_name = $params['insured_name'] ?? null;
$claim_no = $params['claim_no'] ?? null;
$tpa_no = $params['tpa_no'] ?? null;
$relationship = $params['relationship'] ?? null;
$builder = $this->table('ticket_master');
$builder->select('ticket_master.*');
$builder->join('clients c', 'ticket_master.client_id = c.id');
$builder->join('insurers i', 'ticket_master.insurer_id = i.id');
$builder->join('tpa', 'ticket_master.tpa_id = tpa.id', 'left');
$builder->where('c.is_active', 1);
$builder->where('i.is_active', 1);
$builder->where('tpa.is_active', 1);
$builder->where('ticket_master.is_active', 1);
$builder->where('c.client_name', trim($client_name));
$builder->where('i.short_name', trim($insurer_short_name));
$builder->where('ticket_master.policy_no', trim($policy_no));
$builder->where('ticket_master.emp_code', trim($emp_code));
$builder->where('ticket_master.emp_name', trim($emp_name));
$builder->where('ticket_master.insured_name', trim($insured_name));
$builder->where('ticket_master.tpa_no', trim($tpa_no));
$builder->where('ticket_master.claim_number', trim($claim_no));
$builder->where('ticket_master.relationship', trim($relationship));
if(!empty($tpa_short_name)){
$builder->where('tpa.short_name', trim($tpa_short_name));
}
$query = $builder->get();
$result = $query->getResultArray();
return $result;
}
public function getEmployeeAndEmployeePolicyDetails($params)
{
$client_name = $params['client_name'] ?? null;
$emp_code = $params['emp_code'] ?? null;
$emp_name = $params['emp_name'] ?? null;
$policy_no = $params['policy_no'] ?? null;
$relationship = $params['relationship'] ?? null;
$insured_name = $params['insured_name'] ?? null;
$client_name = "6-Eleven";
$emp_code = "EMP0020K12";
$emp_name = "Lokesh";
$policy_no = "GMC-1999/2000/2021/2022";
$builder = $this->db->table('employees e');
$builder->select("
e.id as emp_id,
e.client_id,
e.client_branch_id,
e.emp_code,
e.name as emp_name,
e.mobile as emp_mobile,
e.email_corporate as emp_mail,
e.email_personal as emp_mail_personal,
ep.id as emp_policy_id,
ep.tpa_id as tpa_no,
cp.id as client_policy_id,
cp.insurer_id,
cp.tpa_id,
cp.policy_no,
CASE
WHEN cp.policy_type_id = 2 THEN 1
WHEN cp.policy_type_id = 1 THEN 2
WHEN cp.policy_type_id = 6 THEN 3
WHEN cp.policy_type_id = 7 THEN 4
ELSE NULL
END AS ticket_type_id
", false);
$builder->join('employee_polices ep', 'e.id = ep.employee_id');
$builder->join('clients c', 'e.client_id = c.id');
$builder->join('client_policy cp', 'ep.client_policy_id = cp.id');
$builder->where('e.is_active', 1);
$builder->where('ep.is_active', 1);
$builder->where('c.is_active', 1);
$builder->where('cp.is_active', 1);
$builder->where('e.emp_code', trim($emp_code));
$builder->where('e.name', trim($emp_name));
$builder->where('c.client_name', trim($client_name));
$builder->where('cp.policy_no', trim($policy_no));
$builder->where('LOWER(e.relationship)', strtolower('self'));
$query = $builder->get();
$result = $query->getResultArray();
return $result;
}
public function getAcmUserDetails($params)
{
$acm_name = $params['acm_name'] ?? null;
$acm_mobile = $params['acm_mobile'] ?? null;
if ($acm_mobile != null) {
$builder = $this->db->table('user_profiles');
$builder->select("user_profiles.*");
$builder->where('user_profiles.is_active', 1);
$builder->where('user_profiles.mobile', trim($acm_mobile));
$query = $builder->get();
$result = $query->getResultArray();
return $result;
}
return [];
}
public function getInsuredDetails($params)
{
$client_id = $params['client_id'] ?? null;
$emp_code = $params['emp_code'] ?? null;
$policy_id = $params['client_policy_id'] ?? null;
$insured_name = $params['insured_name'] ?? null;
$builder = $this->db->table('employees e');
$builder->select("
e.id as emp_id,
e.client_id,
e.client_branch_id,
e.emp_code,
e.name as emp_name,
e.mobile as emp_mobile,
e.email_corporate as emp_mail,
e.email_personal as emp_mail_personal,
ep.id as emp_policy_id,
ep.tpa_id as tpa_no,
");
$builder->join('employee_polices ep', 'e.id = ep.employee_id');
$builder->where('e.is_active', 1);
$builder->where('ep.is_active', 1);
$builder->where('e.emp_code', trim($emp_code));
$builder->where('e.name', trim($insured_name));
$builder->where('e.client_id', trim($client_id));
$builder->where('ep.client_policy_id', trim($policy_id));
$query = $builder->get();
$result = $query->getResultArray();
return $result;
}
// -----------------------------------------------------------------------------------------------------
}

View File

@ -0,0 +1,330 @@
<style>
.reload:hover {
cursor: pointer;
}
</style>
<div class="row">
<div class="col-xl-12" style="margin-left: 14px;max-width: 98%;">
<div id="accordion1" class="mb-3">
<div class="card mb-1">
<h5 class="m-1">
<a id="toggleIcon1" class="text-dark float-right" data-toggle="collapse" href="#collapseTwo"
aria-expanded="true">
<i id="icon1" class="mdi mdi-chevron-down mr-1 text-primary" style="font-size: 28px;"></i>
</a>
</h5>
<div id="collapseTwo" class="collapse show" aria-labelledby="headingOne" data-parent="#accordion1">
<div class="card-body">
<form class="parsley-examples" id="claim-upload-form" enctype="multipart/form-data">
<div class="form-group">
<div class="form-row" id="file_upload">
<div class="form-group col-md-4">
<label>Upload file</label>
<!-- &nbsp;[ <a href="#" id="excel_download" data-toggle="tooltip" data-placement="top" title="Download Sample Excel">Sample Excel</a> ] -->
<input type="file" name="claim_dump_list" id="claim_dump_list" accept=" application/vnd.openxmlformats-officedocument.spreadsheetml.sheet, application/vnd.ms-excel,application/vnd.oasis.opendocument.spreadsheet" required>
</div>
<div class="d-flex align-items-center justify-content-start">
<div class="form-group col-md-11">
<div class="col-md-3">
<button id="claim_form_submit_button" type="submit" class="btn btn-primary waves-effect waves-light justify-content-end">Upload</button>
</div>
</div>
</div>
</div>
</div>
</form>
</div>
</div>
</div>
</div>
</div>
</div>
<div class="col-12">
<div class="card">
<div class="card-body">
<div class="row" style="padding-bottom: 10px;">
<div class="col-6" style="align-self: center;">
<h4 style="position: relative;">Files</h4>
</div>
</div>
<table class="table table-hover m-0 table-centered dt-responsive w-100" cellspacing="0" id="tickets-table">
<thead class="bg-light">
<tr>
<th class="font-weight-medium">SNO</th>
<th class="font-weight-medium">File name</th>
<th class="font-weight-medium">User/Time</th>
<th class="font-weight-medium">Status</th>
<th class="font-weight-medium">Action</th>
</tr>
</thead>
<tbody class="font-12">
<?php
if (isset($claim_dump_file_data)) {
foreach ($claim_dump_file_data as $key => $file) {
?>
<tr>
<td><b><?php echo ($key + 1) ?></b></td>
<td style="overflow: hidden;" class="reload truncate" data-toggle="tooltip" data-placement="top" title="<?php echo $file['file_name'] ?>">
<?php echo $file['file_name'] ?>
</td>
<td><?php echo change_date_format($file['created_at'], 'Y-m-d H:i:s', 'd M Y h:i a') . ' by <strong>' . $file['user_name'] . '</strong>' ?> </td>
<td>
<?php if ($file['status'] == "failed") { ?>
<?= $file['status'] ?> <span class='col-xl-3 col-lg-4 col-sm-6'>
<!-- <a href="<?= base_url('util/claim_dump_excel_error/') . $file['file_id'] ?>" target="_blank" class='fe-alert-circle' data-err="<?= $file['file_id'] ?>"></a> -->
<a href="#" class='fe-alert-circle' onclick="fetchFileError(<?= $file['file_id'] ?>)"></a>
</span>
<?php } else if ($file['status'] == "inprogress") { ?>
<a data-id="<?= $file['status'] ?>" class="reload" href="#"><?= $file['status'] ?></a>
<?php } else { ?>
<?= $file['status'] ?>
<?php } ?>
</td>
<td>
<div class="btn-group dropdown">
<a href="javascript: void(0);" class="dropdown-toggle arrow-none btn btn-light btn-sm"
data-toggle="dropdown" aria-expanded="false"><i
class="mdi mdi-dots-horizontal"></i></a>
<div class="dropdown-menu dropdown-menu-right">
<a target="_blank" class="dropdown-item" href="<?= base_url("util/download_claim_dump_file/") . $file['file_id']; ?>"><i class="mdi mdi-download mr-2 text-muted font-18 vertical-middle"></i>Download</a>
<!-- <a data-id="<?php echo $file['file_id'] ?>" data-toggle="modal" data-target="#full-width-modal-emp-list" class="dropdown-item view_emp_list" href="#"><i class="mdi mdi-eye mr-2 text-muted font-18 vertical-middle"></i>View</a> -->
</div>
</div>
</td>
</tr>
<?php }
} ?>
</tbody>
</table>
</div>
</div>
</div><!-- end col -->
<!-- Center modal content -->
<div class="modal fade" id="cliam-dump-file-err-modal" tabindex="-1" role="dialog" aria-hidden="true" data-backdrop="static">
<div class="modal-dialog modal-dialog-centered">
<div class="modal-content">
<div class="modal-header">
<h4 class="modal-title" id="myCenterModalLabel">File Rejected Reason</h4>
<button type="button" class="close" data-dismiss="modal" aria-hidden="true">×</button>
</div>
<div id="modal_body" class="modal-body">
<div class="spinner-border text-primary" role="status" style="position: relative; left: 200px;"></div>
</div>
</div>
</div><!-- /.modal-dialog -->
</div><!-- /.modal -->
<script>
$(document).ready(function() {
// AJAX Form Submit Function
$('#claim-upload-form').on('submit', function(e) {
e.preventDefault(); // Prevent default form submission
// Get form data
var formData = new FormData(this);
var fileInput = $('#claim_dump_list')[0];
// Validate file type
var allowedTypes = [
'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet',
'application/vnd.ms-excel',
'application/vnd.oasis.opendocument.spreadsheet'
];
var selectedFile = fileInput.files[0];
if (!allowedTypes.includes(selectedFile.type)) {
alert('Please upload a valid Excel file (.xlsx, .xls, .ods)');
return false;
}
//form submit url;
let url = `<?php echo base_url('ticket/claim-upload'); ?>`;
// Show loading state
var submitButton = $('#claim_form_submit_button');
var originalText = submitButton.text();
submitButton.prop('disabled', true).text('Uploading...');
// AJAX request
$.ajax({
url: url, // Your route URL
type: 'POST',
data: formData,
processData: false, // CRITICAL: Don't process the data
contentType: false, // CRITICAL: Don't set content-type header
cache: false,
success: function(response) {
// Handle successful response
console.log('Upload successful:', response);
if (response.status == true) {
toastr.success(response.message, "SUCCESS");
} else {
toastr.error(response.message, "ERROR");
}
// Reset form
$('#claim-upload-form')[0].reset();
window.location.reload();
},
error: function(xhr, status, error) {
// Handle error response
console.error('Upload failed:', error);
console.error('Upload failed:', error);
},
complete: function() {
// Reset button state
submitButton.prop('disabled', false).text(originalText);
}
});
});
// File input change event for additional validation
$('#claim_dump_list').on('change', function() {
var fileInput = this;
var file = fileInput.files[0];
if (file) {
// Check file size (optional - set max size as needed, e.g., 10MB)
var maxSize = 10 * 1024 * 1024; // 10MB in bytes
if (file.size > maxSize) {
toastr.warning('File size should not exceed 10MB');
$(this).val(''); // Clear the input
return false;
}
// Display selected file name
var fileName = file.name;
if ($('#selected-file').length === 0) {
$('<div id="selected-file" class="mt-2 text-muted"><small>Selected file: <span id="file-name"></span></small></div>')
.insertAfter('#claim_dump_list');
}
$('#file-name').text(fileName);
}
});
$('body').on('click', '.reload', function() {
status = this.getAttribute('data-id')
console.log(status);
if (status == 'inprogress') {
window.location.reload(true);
}
})
});
function fetchFileError(file_id) {
var url = '<?php echo base_url('util/getClaimDumpFileErrorData/'); ?>';
let requestData = { file_id: file_id };
var myModal = new bootstrap.Modal(document.getElementById('cliam-dump-file-err-modal'));
myModal.show();
sendAjaxRequestForGlobal(url, 'GET', requestData, function(response) {
console.log('Data fetched successfully:', response);
$('#modal_body').empty();
if (response.status === true) {
var file_error_data = (JSON.parse(response.data));
var file_error_html = "";
for (var key in file_error_data['error_summary']) {
var err_id = parseInt(key);
var err_count = file_error_data['error_summary'][key];
switch (err_id) {
case 0:
file_error_html += "<strong>" + file_error_data['error_data'] + "</strong>";
break;
case 1:
file_error_html += "<strong>Mandatory values missing</strong> <span class='badge badge-danger float-right'>" +
err_count + "</span><br>";
break;
case 2:
file_error_html += "<strong>Values not in expected format</strong> <span class='badge badge-danger float-right'>" +
err_count + "</span><br>";
break;
case 3:
file_error_html += "<strong>Field contains not allowed values</strong> <span class='badge badge-danger float-right'>" +
err_count + "</span><br>";
break;
case 4:
file_error_html += "<strong>Rule Conflict</strong> <span class='badge badge-danger float-right'>" +
err_count + "</span><br>";
break;
case 5:
file_error_html += "<strong>" + (file_error_data['error_data'] || 'Error data not available') + "</strong>";
break;
case 6:
file_error_html += "<strong>" + (file_error_data['error_data'] || 'Error data not available') + "</strong>";
break;
case 7:
file_error_html += "<strong>Claim already exist</strong> <span class='badge badge-danger float-right'>" +
err_count + "</span><br>";
break;
case 8:
file_error_html += "<strong>Policy not found</strong> <span class='badge badge-warning float-right'>" +
err_count + "</span><br>";
break;
case 9:
file_error_html += "<strong>Employee not found</strong> <span class='badge badge-danger float-right'>" +
err_count + "</span><br>";
break;
case 10:
file_error_html += "<strong>ACM not found</strong> <span class='badge badge-danger float-right'>" +
err_count + "</span><br>";
break;
default:
file_error_html += "<strong>Unknown error type</strong> <span class='badge badge-secondary float-right'>" +
err_count + "</span><br>";
break;
}
}
if (err_id != 5 && err_id != 6 && err_id != 0) {
file_error_html += (file_error_html != "" ?
"<a href ='<?php echo base_url('util/claim_dump_excel_error/') ?>" + file_id +
"' target=_blank>click here to more details...</a>" : "");
}
// console.log(file_error_html);
$('#modal_body').append(file_error_html);
} else {
console.log('Response status was false');
$('#modal_body').append('<div class="alert alert-warning">No error data available.</div>');
}
}, function(xhr, status, error) {
console.error('Error fetching data:', error);
console.error('Status:', status);
console.error('Response:', xhr.responseText);
// Show error message to user
$('#modal_body').empty().append(
'<div class="alert alert-danger">Failed to fetch error data. Please try again.</div>'
);
});
}
$('.close').click(function(){
$('#modal_body').empty()
let html = `<div class="spinner-border text-primary" role="status" style="position: relative; left: 200px;"></div>`
$('#modal_body').append(html);
});
</script>

View File

@ -287,12 +287,12 @@
<div class="form-group col-md-12">
<label for="email">Email<span class="text-danger">*</span></label>
<input type="text" class="form-control" id="email_corporate" placeholder="Enter Email" name="email_corporate" data-parsley-trigger="change" data-parsley-type="email" onchange="validateInput(this, 'employees', 'email_corporate')" required>
<input type="text" class="form-control" id="email_corporate" placeholder="Enter Email" name="email_corporate" data-parsley-trigger="change" data-parsley-type="email" onkeyup="validateInput(this, 'employees', 'email_corporate')" required>
</div>
<div class="form-group col-md-12">
<label for="mobile">Mobile Number<span class="text-danger">*</span></label>
<input type="text" class="form-control" id="mobile" placeholder="Enter Mobile Number" name="mobile" onkeypress = "return onlyNumbers(event)" maxlength="10" minlength="10" onchange="validateInput(this, 'employees', 'mobile')" required>
<input type="text" class="form-control" id="mobile" placeholder="Enter Mobile Number" name="mobile" onkeypress = "return onlyNumbers(event)" maxlength="10" minlength="10" onkeyup="validateInput(this, 'employees', 'mobile')" required>
</div>
</div>
@ -570,21 +570,53 @@
});
}
function validateInput(input, table, field){
// function validateInput(input, table, field){
// let value = $(input).val();
// let label = $(input).closest('.form-group').find('label').text().replace('*', '').trim();
// let message = "Value is duplicate!";
// if(label){
// message = label + " already exists!";
// }
// checkDuplicateTableFieldValue(table, field, value, function(isDuplicate) {
// if (isDuplicate) {
// toastr.warning(message, 'WARNING');
// $(input).val('')
// }
// });
// }
function validateInput(input, table, field) {
let emp_code = $('#emp_code_for_edit').val();
let client_id = $('#clients').val();
console.log("emp_code", emp_code);
console.log("client_id", client_id);
let value = $(input).val();
let label = $(input).closest('.form-group').find('label').text().replace('*', '').trim();
let message = "Value is duplicate!";
if(label){
if (label) {
message = label + " already exists!";
}
checkDuplicateTableFieldValue(table, field, value, function(isDuplicate) {
let data = {};
data["emp_code !="] = emp_code;
data[field] = value;
console.log(data);
checkDuplicateTableFieldValue(table, field, data, function(isDuplicate) {
if (isDuplicate) {
toastr.warning(message, 'WARNING');
$(input).val('')
}
$("#btnSubmit").prop('disabled', true);
}else{
$("#btnSubmit").prop('disabled', false);
}
});
}
@ -597,108 +629,106 @@
}
var modalInstance; // Store the modal instance globally
function showModal() {
var myModalEl = document.getElementById('emp_history_modal');
modalInstance = new bootstrap.Modal(myModalEl, {
backdrop: true, // Ensures the backdrop is shown
keyboard: true // Allows closing with the Escape key
});
modalInstance.show();
}
function closeModal() {
if (modalInstance) {
modalInstance.hide(); // Hide the modal and its backdrop
// Manually remove backdrop if it's still visible
setTimeout(function () {
document.querySelector('.modal-backdrop').classList.remove('show');
}, 150); // Wait for animation to finish
function showModal() {
var myModalEl = document.getElementById('emp_history_modal');
modalInstance = new bootstrap.Modal(myModalEl, {
backdrop: true, // Ensures the backdrop is shown
keyboard: true // Allows closing with the Escape key
});
modalInstance.show();
}
}
function closeModal() {
if (modalInstance) {
modalInstance.hide(); // Hide the modal and its backdrop
// Manually remove backdrop if it's still visible
setTimeout(function () {
document.querySelector('.modal-backdrop').classList.remove('show');
}, 150); // Wait for animation to finish
}
}
function get_emp_history(input, emp_id) {
$('.loader').fadeIn();
$('.loader-mask').fadeIn();
$('.loader').fadeIn();
$('.loader-mask').fadeIn();
let url = '<?= base_url("employee/get_emp_history")?>';
let requestData = { emp_id: emp_id };
let url = '<?= base_url("employee/get_emp_history")?>';
let requestData = { emp_id: emp_id };
sendAjaxRequestForGlobal(url, 'POST', requestData, function(response) {
$('.loader').fadeOut();
$('.loader-mask').delay(350).fadeOut('slow');
sendAjaxRequestForGlobal(url, 'POST', requestData, function(response) {
$('.loader').fadeOut();
$('.loader-mask').delay(350).fadeOut('slow');
if (response.status === true) {
console.log('response data length', response.data.emp_history.length);
if (response.status === true) {
console.log('response data length', response.data.emp_history.length);
// **Clear old data**
$('#emp_history_content').html('');
// **Clear old data**
$('#emp_history_content').html('');
// **Check if data exists**
if (response.data.emp_history.length > 0) {
let historyTable = `
<div class="card-body">
<div class="table-responsive">
<table class="table w-100">
<thead class="bg-light">
<tr>
<th>Field</th>
<th>Change</th>
<th>User</th>
<th>Date/Time</th>
</tr>
</thead>
<tbody>
`;
// **Loop through the data dynamically**
response.data.emp_history.forEach(row => {
historyTable += `
<tr>
<td>${row.field_name}</td>
<td>${row.old_value} => ${row.new_value}</td>
<td>${row.created_by}</td>
<td>${row.created_at}</td>
</tr>
// **Check if data exists**
if (response.data.emp_history.length > 0) {
let historyTable = `
<div class="card-body">
<div class="table-responsive">
<table class="table w-100">
<thead class="bg-light">
<tr>
<th>Field</th>
<th>Change</th>
<th>User</th>
<th>Date/Time</th>
</tr>
</thead>
<tbody>
`;
});
historyTable += `
</tbody>
</table>
// **Loop through the data dynamically**
response.data.emp_history.forEach(row => {
historyTable += `
<tr>
<td>${row.field_name}</td>
<td>${row.old_value} => ${row.new_value}</td>
<td>${row.created_by}</td>
<td>${row.created_at}</td>
</tr>
`;
});
historyTable += `
</tbody>
</table>
</div>
</div>
</div>
`;
`;
// **Append to modal**
$('#emp_history_content').append(historyTable);
// **Append to modal**
$('#emp_history_content').append(historyTable);
} else {
$('#emp_history_content').html('<p class="text-center text-muted">No history available.</p>');
}
// **Show the modal**
showModal();
} else {
$('#emp_history_content').html('<p class="text-center text-muted">No history available.</p>');
let message = response.message;
toastr.error(message, 'ERROR');
}
}, function(xhr, status, error) {
console.error('Error fetching data:', error);
console.error(xhr.responseText);
toastr.error('An error occurred while fetching the report page.', 'ERROR');
// **Show the modal**
showModal();
} else {
let message = response.message;
toastr.error(message, 'ERROR');
}
}, function(xhr, status, error) {
console.error('Error fetching data:', error);
console.error(xhr.responseText);
toastr.error('An error occurred while fetching the report page.', 'ERROR');
$('.loader').fadeOut();
$('.loader-mask').delay(350).fadeOut('slow');
});
}
$('.loader').fadeOut();
$('.loader-mask').delay(350).fadeOut('slow');
});
}
// function closeModal(){
// var myModalEl = document.getElementById('emp_history_modal');
// var modalInstance = bootstrap.Modal.getInstance(myModalEl);
// if (modalInstance) {
// modalInstance.hide();
// }
// }
// function closeModal(){
// var myModalEl = document.getElementById('emp_history_modal');
// var modalInstance = bootstrap.Modal.getInstance(myModalEl);
// if (modalInstance) {
// modalInstance.hide();
// }
// }
</script>

View File

@ -689,6 +689,9 @@
<li>
<a href="<?= base_url('/ticket/feedback-list') ?>">Claim Feedback List</a>
</li>
<li>
<a href="<?= base_url('/ticket/claim-upload') ?>">Claim Dump Upload</a>
</li>
</ul>
</div>
</li>

View File

@ -321,7 +321,7 @@ table.dataTable tbody td {
<a class="dropdown-item btnEdit" data-id="<?= $row['id'];?>" onclick="getPolicyTransactionDataForEdit('<?= htmlspecialchars($row['id'], ENT_QUOTES) ?>')">
<i class="mdi mdi-pencil mr-2 text-muted font-18 vertical-middle"></i>Edit
</a>
<a class="dropdown-item delete" data-id="<?= $row['id'];?>" onclick="removePolicyTransaction(this, '<?= htmlspecialchars($row['id'], ENT_QUOTES) ?>')">
<a class="dropdown-item delete" data-id="<?= $row['id'];?>" onclick="removePolicyTransaction(this, '<?= htmlspecialchars($row['id'], ENT_QUOTES) ?>', <?= $row['policy_type_id'] ?>)">
<i class="mdi mdi-delete mr-2 text-muted font-18 vertical-middle"></i>Delete
</a>
</div>
@ -1668,9 +1668,14 @@ function hideDateField(input = null)
}
}
function removePolicyTransaction(input, pt_id) {
function removePolicyTransaction(input, pt_id, policy_type_id) {
confirmActionSweertAlert("Do you want to delete this transaction?", "Yes, Proceed!", "No, Cancel").then((confirmed) => {
let string = "Do you want to delete this transaction?";
if(policy_type_id > 7){
string = "Do you want to delete this transaction? Deleting this will also remove the linked CRM policy entry.";
}
confirmActionSweertAlert(string, "Yes, Proceed!", "No, Cancel").then((confirmed) => {
if (confirmed) {
let url = '<?= base_url('policy_tranction/inception/removePolicyTransaction/') ?>' + pt_id;
@ -1694,6 +1699,4 @@ function removePolicyTransaction(input, pt_id) {
});
}
</script>