FIX_RAG_EMP_DETAILS_API
This commit is contained in:
parent
44161347d2
commit
6d3cf50442
@ -239,6 +239,9 @@ $routes->group("/employee", ["filter" => "authMVC"], function ($routes) {
|
||||
$routes->get("search", "EmployeeController::search");
|
||||
$routes->get("upload", "EmployeeController::employeesUplodWithEvents");
|
||||
$routes->post("upload", "EmployeeController::employeesUplodWithEvents");
|
||||
$routes->post("upload/file-list/datatable", "EmployeeController::fileListDataTable");
|
||||
$routes->post("upload/batch-list/datatable", "EmployeeController::batchListDataTable");
|
||||
$routes->post("upload/hr-file-list/datatable", "EmployeeController::hrFileListDataTable");
|
||||
$routes->get("excel_error/(:any)", "EmployeeController::getExcelFileErrors/$1");
|
||||
$routes->get("endorsement-list", "EmployeeController::endorsementList");
|
||||
$routes->match(['get','post'],'enrollment-list','EmployeeController::enrollmentClientList');
|
||||
|
||||
@ -19,6 +19,7 @@ use App\Models\PolicesModel;
|
||||
use App\Models\FileModel;
|
||||
use App\Models\BatchListModel;
|
||||
use App\Models\BatchFileModel;
|
||||
use App\Models\HrFileUploadModel;
|
||||
use App\Models\EmpEndorsementModel;
|
||||
use App\Models\ClientPolicyModel;
|
||||
use App\Models\TPAModel;
|
||||
@ -70,6 +71,7 @@ class EmployeeController extends AdminController
|
||||
protected $fileModel;
|
||||
protected $batchListModel;
|
||||
protected $batchFileModel;
|
||||
protected $hrFileUploadModel;
|
||||
protected $empEndorsementModel;
|
||||
protected $clientPolicyModel;
|
||||
protected $TPAModel;
|
||||
@ -96,6 +98,7 @@ class EmployeeController extends AdminController
|
||||
$this->fileModel = new FileModel();
|
||||
$this->batchListModel = new BatchListModel();
|
||||
$this->batchFileModel = new BatchFileModel();
|
||||
$this->hrFileUploadModel = new HrFileUploadModel();
|
||||
$this->empEndorsementModel = new EmpEndorsementModel();
|
||||
$this->clientPolicyModel = new ClientPolicyModel();
|
||||
$this->TPAModel = new TPAModel();
|
||||
@ -416,9 +419,6 @@ class EmployeeController extends AdminController
|
||||
}
|
||||
}
|
||||
|
||||
$get_data = $this->request->getGet();
|
||||
// dd($get_data);
|
||||
|
||||
$data['tab_name'] = 'View Inception';
|
||||
$data['page_name'] = 'View Inception';
|
||||
|
||||
@ -432,201 +432,10 @@ class EmployeeController extends AdminController
|
||||
$data['import_or_export'] = ['import' => 'Upload', 'export' => 'Download'];
|
||||
$data['insurer_or_tpa'] = ['insurer' => 'Insurer', 'tpa' => 'TPA'];
|
||||
|
||||
// $data['fileList'] = $this->fileModel
|
||||
// ->select(['files.*', 'up.emp_code', 'up.first_name', 'pm.name as policy_name', 'c.short_name', 'cp.id as client_policy_id'])
|
||||
// ->join('user_profiles up', 'files.created_by = up.id')
|
||||
// ->join('client_policy cp', 'files.policy_id = cp.id', 'left')
|
||||
// ->join('policies pm', 'cp.policy_id = pm.id', 'left')
|
||||
// ->join('clients c', 'files.client_id = c.id and files.client_id = cp.client_id', 'left')
|
||||
// ->where('files.created_by', get_session_userid())->orderBy('files.created_at', 'desc')->findAll();
|
||||
// dd($this->fileModel->getLastQuery());
|
||||
$role_id = get_role_id();
|
||||
$user_id = get_session_userid();
|
||||
// List rows are loaded via server-side DataTables AJAX (10 per page).
|
||||
$data['fileList'] = [];
|
||||
$data['batch_list'] = [];
|
||||
|
||||
$query = $this->fileModel
|
||||
->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',
|
||||
'c.short_name',
|
||||
'cb.branch_name',
|
||||
'cp.id as client_policy_id',
|
||||
'"0" as employee_count',
|
||||
'"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_contacts 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', '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')
|
||||
->join('clients c', 'files.client_id = c.id and files.client_id = cp.client_id', 'left')
|
||||
->join("client_rm cr", "cr.client_id = c.id and cr.is_active = 1", 'left')
|
||||
->where('files.is_active', 1);
|
||||
|
||||
if (!empty($get_data['start_date'] ?? null) && !empty($get_data['end_date'] ?? null)) {
|
||||
// 1. If dates are provided, use the user's filter
|
||||
$start = change_date_format($get_data['start_date'], 'd/m/Y', 'Y-m-d') . ' 00:00:00';
|
||||
$end = change_date_format($get_data['end_date'], 'd/m/Y', 'Y-m-d') . ' 23:59:59';
|
||||
|
||||
$query->where('files.created_at >=', $start)
|
||||
->where('files.created_at <=', $end);
|
||||
} else {
|
||||
if(empty($get_data['tab_type'] ?? null)){
|
||||
// 2. Default: If no dates are selected, show last 90 days (or all data)
|
||||
$query->where('files.created_at >=', date('Y-m-d 00:00:00', strtotime('-90 days')))
|
||||
->where('files.created_at <=', date('Y-m-d 23:59:59'));
|
||||
}
|
||||
}
|
||||
|
||||
if(!empty($get_data['client_id'] ?? null)){
|
||||
$query->where('files.client_id', $get_data['client_id']);
|
||||
}
|
||||
|
||||
if(!empty($get_data['client_branch_id'] ?? null)){
|
||||
$query->where('files.client_branch_id', $get_data['client_branch_id']);
|
||||
}
|
||||
|
||||
if(!empty($get_data['policy_id'] ?? null)){
|
||||
$query->where('files.policy_id', $get_data['policy_id']);
|
||||
}
|
||||
|
||||
if(!empty($get_data['event_type'] ?? null)){
|
||||
$query->where('files.action', $get_data['event_type']);
|
||||
}
|
||||
|
||||
if (in_array($role_id, [2, 3])) {
|
||||
// If the user is a Account Manager or Manager, filter by user_id
|
||||
$query->where('cr.user_id', (int)$user_id);
|
||||
}
|
||||
|
||||
$data['fileList'] = $query->groupBy("files.id")
|
||||
->orderBy('files.created_at', 'desc')
|
||||
->find();
|
||||
|
||||
// dd($this->fileModel->getLastQuery());
|
||||
// dd($data['fileList']);
|
||||
|
||||
$query2 = $this->batchFileModel->select("
|
||||
|
||||
batch_files.id,
|
||||
batch_files.client_id,
|
||||
batch_files.client_policy_id,
|
||||
batch_files.batch_code,
|
||||
batch_files.file_name,
|
||||
batch_files.insurer_or_tpa,
|
||||
batch_files.event_type,
|
||||
batch_files.actions,
|
||||
batch_files.count,
|
||||
batch_files.created_by,
|
||||
batch_files.created_at,
|
||||
batch_files.updated_by,
|
||||
batch_files.updated_at,
|
||||
batch_files.is_active,
|
||||
batch_files.amount,
|
||||
batch_files.status,
|
||||
batch_files.icici_status_flag,
|
||||
batch_files.client_branch_id,
|
||||
insurers.short_name as insurer_short_name,
|
||||
tpa.short_name as tpa_short_name,
|
||||
DATE_FORMAT(batch_files.policy_issue_date, '%d/%m/%Y') AS policy_issue_date,
|
||||
|
||||
CASE
|
||||
WHEN batch_files.status IN ('partially success', 'in-progress-partially', 'failed-7')
|
||||
THEN batch_files.error_data
|
||||
ELSE NULL
|
||||
END AS error_data,
|
||||
|
||||
clients.short_name as client_short_name,
|
||||
client_branch.branch_name,
|
||||
client_policy.policy_no,
|
||||
policy_type.policy_type
|
||||
|
||||
")
|
||||
->join('client_policy', 'client_policy.id = batch_files.client_policy_id')
|
||||
->join('insurers', 'client_policy.insurer_id = insurers.id')
|
||||
->join('tpa', 'client_policy.tpa_id = tpa.id', 'left')
|
||||
->join('client_branch', 'client_branch.id = batch_files.client_branch_id')
|
||||
->join('policy_type', 'policy_type.id = client_policy.policy_type_id')
|
||||
->join('clients', 'clients.id = client_policy.client_id')
|
||||
->join("client_rm cr", "cr.client_id = clients.id and cr.is_active = 1", 'left')
|
||||
->where('batch_files.is_active', 1);
|
||||
|
||||
if (!empty($get_data['start_date'] ?? null) && !empty($get_data['end_date'] ?? null)) {
|
||||
// 1. If dates are provided, use the user's filter
|
||||
$start = change_date_format($get_data['start_date'], 'd/m/Y', 'Y-m-d') . ' 00:00:00';
|
||||
$end = change_date_format($get_data['end_date'], 'd/m/Y', 'Y-m-d') . ' 23:59:59';
|
||||
|
||||
$query2->where('batch_files.created_at >=', $start)
|
||||
->where('batch_files.created_at <=', $end);
|
||||
|
||||
} else {
|
||||
if(empty($get_data['tab_type'] ?? null)){
|
||||
// 2. Default: If no dates are selected, show last 90 days (or all data)
|
||||
$query2->where('batch_files.created_at >=', date('Y-m-d 00:00:00', strtotime('-90 days')))
|
||||
->where('batch_files.created_at <=', date('Y-m-d 23:59:59'));
|
||||
}
|
||||
}
|
||||
|
||||
if(!empty($get_data['client_id'] ?? null)){
|
||||
$query2->where('batch_files.client_id', $get_data['client_id']);
|
||||
}
|
||||
|
||||
if(!empty($get_data['client_branch_id'] ?? null)){
|
||||
$query2->where('batch_files.client_branch_id', $get_data['client_branch_id']);
|
||||
}
|
||||
|
||||
if(!empty($get_data['policy_id'] ?? null)){
|
||||
$query2->where('batch_files.client_policy_id', $get_data['policy_id']);
|
||||
}
|
||||
|
||||
if(!empty($get_data['event_type'] ?? null)){
|
||||
$query2->where('batch_files.event_type', $get_data['event_type']);
|
||||
}
|
||||
|
||||
if(!empty($get_data['insurer_or_tpa'] ?? null)){
|
||||
$query2->where('batch_files.insurer_or_tpa', $get_data['insurer_or_tpa']);
|
||||
}
|
||||
|
||||
if(!empty($get_data['action_type'] ?? null)){
|
||||
$query2->where('batch_files.actions', $get_data['action_type']);
|
||||
}
|
||||
|
||||
if (in_array($role_id, [2, 3])) {
|
||||
|
||||
// If the user is a Account Manager or Manager, filter by user_id
|
||||
$query2->where('cr.user_id', (int)$user_id);
|
||||
}
|
||||
|
||||
$data['batch_list'] = $query2->groupBy("batch_files.id")
|
||||
->orderBy('batch_files.id', 'desc')
|
||||
->find();
|
||||
|
||||
// dd($data['fileList']);die();
|
||||
if ($this->request->getMethod() == "get") {
|
||||
$this->loadLayout('import_export', $data);
|
||||
}
|
||||
@ -7557,5 +7366,685 @@ class EmployeeController extends AdminController
|
||||
]);
|
||||
}
|
||||
|
||||
/**
|
||||
* DataTables AJAX: Data From Client file list (server-side pagination).
|
||||
*/
|
||||
public function fileListDataTable()
|
||||
{
|
||||
if (!$this->request->isAJAX()) {
|
||||
return $this->response->setStatusCode(400)->setJSON([
|
||||
'status' => false,
|
||||
'message' => 'Invalid request.',
|
||||
]);
|
||||
}
|
||||
|
||||
$draw = (int) ($this->request->getPost('draw') ?? 0);
|
||||
$start = max(0, (int) ($this->request->getPost('start') ?? 0));
|
||||
$length = (int) ($this->request->getPost('length') ?? 10);
|
||||
if ($length < 1) {
|
||||
$length = 10;
|
||||
}
|
||||
$search = trim((string) ($this->request->getPost('search')['value'] ?? ''));
|
||||
$filters = $this->buildUploadListFiltersFromRequest();
|
||||
|
||||
$db = \Config\Database::connect();
|
||||
|
||||
$countBuilder = $this->buildFileListQuery($filters, '');
|
||||
$countSql = $countBuilder->select('files.id')->groupBy('files.id')->getCompiledSelect();
|
||||
$recordsTotal = (int) ($db->query('SELECT COUNT(*) AS cnt FROM (' . $countSql . ') AS counted')->getRowArray()['cnt'] ?? 0);
|
||||
|
||||
$filteredBuilder = $this->buildFileListQuery($filters, $search);
|
||||
$filteredSql = $filteredBuilder->select('files.id')->groupBy('files.id')->getCompiledSelect();
|
||||
$recordsFiltered = ($search === '')
|
||||
? $recordsTotal
|
||||
: (int) ($db->query('SELECT COUNT(*) AS cnt FROM (' . $filteredSql . ') AS counted')->getRowArray()['cnt'] ?? 0);
|
||||
|
||||
$dataBuilder = $this->buildFileListQuery($filters, $search);
|
||||
$rows = $dataBuilder
|
||||
->select($this->fileListSelectColumns(), false)
|
||||
->groupBy('files.id')
|
||||
->orderBy('files.created_at', 'DESC')
|
||||
->limit($length, $start)
|
||||
->get()
|
||||
->getResultArray();
|
||||
|
||||
$data = [];
|
||||
foreach ($rows as $index => $row) {
|
||||
$data[] = $this->formatFileListRowForDataTable($row, $start + $index + 1);
|
||||
}
|
||||
|
||||
return $this->response->setJSON([
|
||||
'draw' => $draw,
|
||||
'recordsTotal' => $recordsTotal,
|
||||
'recordsFiltered' => $recordsFiltered,
|
||||
'data' => $data,
|
||||
]);
|
||||
}
|
||||
|
||||
/**
|
||||
* DataTables AJAX: Insurer/TPA batch list (server-side pagination).
|
||||
*/
|
||||
public function batchListDataTable()
|
||||
{
|
||||
if (!$this->request->isAJAX()) {
|
||||
return $this->response->setStatusCode(400)->setJSON([
|
||||
'status' => false,
|
||||
'message' => 'Invalid request.',
|
||||
]);
|
||||
}
|
||||
|
||||
$draw = (int) ($this->request->getPost('draw') ?? 0);
|
||||
$start = max(0, (int) ($this->request->getPost('start') ?? 0));
|
||||
$length = (int) ($this->request->getPost('length') ?? 10);
|
||||
if ($length < 1) {
|
||||
$length = 10;
|
||||
}
|
||||
$search = trim((string) ($this->request->getPost('search')['value'] ?? ''));
|
||||
$filters = $this->buildUploadListFiltersFromRequest();
|
||||
|
||||
$db = \Config\Database::connect();
|
||||
|
||||
$countBuilder = $this->buildBatchListQuery($filters, '');
|
||||
$countSql = $countBuilder->select('batch_files.id')->groupBy('batch_files.id')->getCompiledSelect();
|
||||
$recordsTotal = (int) ($db->query('SELECT COUNT(*) AS cnt FROM (' . $countSql . ') AS counted')->getRowArray()['cnt'] ?? 0);
|
||||
|
||||
$filteredBuilder = $this->buildBatchListQuery($filters, $search);
|
||||
$filteredSql = $filteredBuilder->select('batch_files.id')->groupBy('batch_files.id')->getCompiledSelect();
|
||||
$recordsFiltered = ($search === '')
|
||||
? $recordsTotal
|
||||
: (int) ($db->query('SELECT COUNT(*) AS cnt FROM (' . $filteredSql . ') AS counted')->getRowArray()['cnt'] ?? 0);
|
||||
|
||||
$dataBuilder = $this->buildBatchListQuery($filters, $search);
|
||||
$rows = $dataBuilder
|
||||
->select($this->batchListSelectColumns(), false)
|
||||
->groupBy('batch_files.id')
|
||||
->orderBy('batch_files.id', 'DESC')
|
||||
->limit($length, $start)
|
||||
->get()
|
||||
->getResultArray();
|
||||
|
||||
$insurerOrTpa = ['insurer' => 'Insurer', 'tpa' => 'TPA'];
|
||||
$importOrExport = ['import' => 'Upload', 'export' => 'Download'];
|
||||
|
||||
$data = [];
|
||||
foreach ($rows as $index => $row) {
|
||||
$data[] = $this->formatBatchListRowForDataTable($row, $start + $index + 1, $insurerOrTpa, $importOrExport);
|
||||
}
|
||||
|
||||
return $this->response->setJSON([
|
||||
'draw' => $draw,
|
||||
'recordsTotal' => $recordsTotal,
|
||||
'recordsFiltered' => $recordsFiltered,
|
||||
'data' => $data,
|
||||
]);
|
||||
}
|
||||
|
||||
/**
|
||||
* DataTables AJAX: HR uploaded files (server-side pagination).
|
||||
*/
|
||||
public function hrFileListDataTable()
|
||||
{
|
||||
if (!$this->request->isAJAX()) {
|
||||
return $this->response->setStatusCode(400)->setJSON([
|
||||
'status' => false,
|
||||
'message' => 'Invalid request.',
|
||||
]);
|
||||
}
|
||||
|
||||
$draw = (int) ($this->request->getPost('draw') ?? 0);
|
||||
$start = max(0, (int) ($this->request->getPost('start') ?? 0));
|
||||
$length = (int) ($this->request->getPost('length') ?? 10);
|
||||
if ($length < 1) {
|
||||
$length = 10;
|
||||
}
|
||||
$search = trim((string) ($this->request->getPost('search')['value'] ?? ''));
|
||||
$filters = $this->buildUploadListFiltersFromRequest();
|
||||
|
||||
// HR form fields (CRM search)
|
||||
$filters['client_id'] = $this->request->getPost('client_id') ?: ($filters['client_id'] ?? null);
|
||||
$filters['client_branch_id'] = $this->request->getPost('client_branch_id') ?: ($filters['client_branch_id'] ?? null);
|
||||
$filters['policy_id'] = $this->request->getPost('policy_id') ?: ($filters['policy_id'] ?? null);
|
||||
$filters['event_type'] = $this->request->getPost('file_action') ?: ($this->request->getPost('event_type') ?: ($filters['event_type'] ?? null));
|
||||
|
||||
$db = \Config\Database::connect();
|
||||
|
||||
$countBuilder = $this->buildHrFileListQuery($filters, '');
|
||||
$countSql = $countBuilder->select('hr_file_upload.id')->groupBy('hr_file_upload.id')->getCompiledSelect();
|
||||
$recordsTotal = (int) ($db->query('SELECT COUNT(*) AS cnt FROM (' . $countSql . ') AS counted')->getRowArray()['cnt'] ?? 0);
|
||||
|
||||
$filteredBuilder = $this->buildHrFileListQuery($filters, $search);
|
||||
$filteredSql = $filteredBuilder->select('hr_file_upload.id')->groupBy('hr_file_upload.id')->getCompiledSelect();
|
||||
$recordsFiltered = ($search === '')
|
||||
? $recordsTotal
|
||||
: (int) ($db->query('SELECT COUNT(*) AS cnt FROM (' . $filteredSql . ') AS counted')->getRowArray()['cnt'] ?? 0);
|
||||
|
||||
$dataBuilder = $this->buildHrFileListQuery($filters, $search);
|
||||
$rows = $dataBuilder
|
||||
->select($this->hrFileListSelectColumns(), false)
|
||||
->groupBy('hr_file_upload.id')
|
||||
->orderBy('hr_file_upload.id', 'DESC')
|
||||
->limit($length, $start)
|
||||
->get()
|
||||
->getResultArray();
|
||||
|
||||
$data = [];
|
||||
foreach ($rows as $index => $row) {
|
||||
$data[] = $this->formatHrFileListRowForDataTable($row, $start + $index + 1);
|
||||
}
|
||||
|
||||
return $this->response->setJSON([
|
||||
'draw' => $draw,
|
||||
'recordsTotal' => $recordsTotal,
|
||||
'recordsFiltered' => $recordsFiltered,
|
||||
'data' => $data,
|
||||
]);
|
||||
}
|
||||
|
||||
protected function buildUploadListFiltersFromRequest(): array
|
||||
{
|
||||
$post = $this->request->getPost();
|
||||
|
||||
$clientBranchId = $post['client_branch_id'] ?? ($post['branch_id'] ?? null);
|
||||
if ($clientBranchId === '0' || $clientBranchId === 0) {
|
||||
$clientBranchId = null;
|
||||
}
|
||||
|
||||
$policyId = $post['policy_id'] ?? ($post['client_policy_id'] ?? null);
|
||||
if ($policyId === '0' || $policyId === 0) {
|
||||
$policyId = null;
|
||||
}
|
||||
|
||||
$clientId = $post['client_id'] ?? null;
|
||||
if ($clientId === '' || $clientId === '0' || $clientId === 0) {
|
||||
$clientId = null;
|
||||
}
|
||||
|
||||
return [
|
||||
'start_date' => !empty($post['start_date']) ? $post['start_date'] : null,
|
||||
'end_date' => !empty($post['end_date']) ? $post['end_date'] : null,
|
||||
'client_id' => $clientId,
|
||||
'client_branch_id'=> $clientBranchId,
|
||||
'policy_id' => $policyId,
|
||||
'event_type' => !empty($post['event_type']) ? $post['event_type'] : null,
|
||||
'insurer_or_tpa' => !empty($post['insurer_or_tpa']) ? $post['insurer_or_tpa'] : null,
|
||||
'action_type' => !empty($post['action_type']) ? $post['action_type'] : null,
|
||||
'use_default_date'=> !isset($post['use_default_date']) || (string) $post['use_default_date'] === '1',
|
||||
];
|
||||
}
|
||||
|
||||
protected function applyDateFilter($builder, array $filters, string $column)
|
||||
{
|
||||
if (!empty($filters['start_date']) && !empty($filters['end_date'])) {
|
||||
$start = change_date_format($filters['start_date'], 'd/m/Y', 'Y-m-d') . ' 00:00:00';
|
||||
$end = change_date_format($filters['end_date'], 'd/m/Y', 'Y-m-d') . ' 23:59:59';
|
||||
$builder->where($column . ' >=', $start)->where($column . ' <=', $end);
|
||||
} elseif (!empty($filters['use_default_date'])) {
|
||||
$builder->where($column . ' >=', date('Y-m-d 00:00:00', strtotime('-90 days')))
|
||||
->where($column . ' <=', date('Y-m-d 23:59:59'));
|
||||
}
|
||||
|
||||
return $builder;
|
||||
}
|
||||
|
||||
protected function fileListSelectColumns(): string
|
||||
{
|
||||
return '
|
||||
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,
|
||||
c.short_name,
|
||||
cb.branch_name,
|
||||
cp.id as client_policy_id,
|
||||
"0" as employee_count,
|
||||
"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_contacts lc
|
||||
WHERE lc.id = files.hr_id
|
||||
LIMIT 1
|
||||
),
|
||||
" (HR)"
|
||||
)
|
||||
ELSE up.first_name
|
||||
END AS first_name
|
||||
';
|
||||
}
|
||||
|
||||
protected function buildFileListQuery(array $filters, string $search = '')
|
||||
{
|
||||
$db = \Config\Database::connect();
|
||||
$builder = $db->table('files');
|
||||
$builder
|
||||
->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')
|
||||
->join('clients c', 'files.client_id = c.id and files.client_id = cp.client_id', 'left')
|
||||
->join('client_rm cr', 'cr.client_id = c.id and cr.is_active = 1', 'left')
|
||||
->where('files.is_active', 1);
|
||||
|
||||
$this->applyDateFilter($builder, $filters, 'files.created_at');
|
||||
|
||||
if (!empty($filters['client_id'])) {
|
||||
$builder->where('files.client_id', $filters['client_id']);
|
||||
}
|
||||
if (!empty($filters['client_branch_id'])) {
|
||||
$builder->where('files.client_branch_id', $filters['client_branch_id']);
|
||||
}
|
||||
if (!empty($filters['policy_id'])) {
|
||||
$builder->where('files.policy_id', $filters['policy_id']);
|
||||
}
|
||||
if (!empty($filters['event_type'])) {
|
||||
$builder->where('files.action', $filters['event_type']);
|
||||
}
|
||||
|
||||
$roleId = (int) get_role_id();
|
||||
if (in_array($roleId, [2, 3], true)) {
|
||||
$builder->where('cr.user_id', (int) get_session_userid());
|
||||
}
|
||||
|
||||
if ($search !== '') {
|
||||
$builder->groupStart()
|
||||
->like('files.file_name', $search)
|
||||
->orLike('c.short_name', $search)
|
||||
->orLike('cb.branch_name', $search)
|
||||
->orLike('cp.policy_no', $search)
|
||||
->orLike('policy_type.policy_type', $search)
|
||||
->orLike('files.action', $search)
|
||||
->orLike('files.status', $search)
|
||||
->orLike('up.first_name', $search)
|
||||
->groupEnd();
|
||||
}
|
||||
|
||||
return $builder;
|
||||
}
|
||||
|
||||
protected function formatFileListRowForDataTable(array $file, int $serialNo): array
|
||||
{
|
||||
$fileName = htmlspecialchars((string) ($file['file_name'] ?? ''), ENT_QUOTES, 'UTF-8');
|
||||
$policyDisplay = trim(($file['policy_type'] ?? '') . ' - ' . ($file['policy_no'] ?? ''));
|
||||
$userTime = change_date_format($file['created_at'] ?? '', 'Y-m-d H:i:s', 'd/m/Y h:i a')
|
||||
. ' by <strong>' . htmlspecialchars((string) ($file['first_name'] ?? ''), ENT_QUOTES, 'UTF-8') . '</strong>';
|
||||
|
||||
$status = (string) ($file['status'] ?? '');
|
||||
$action = (string) ($file['action'] ?? '');
|
||||
if ($status === 'failed') {
|
||||
$statusHtml = $status . " <span class='col-xl-3 col-lg-4 col-sm-6'> <i class='fe-alert-circle' data-toggle='modal' data-target='#file-err-modal' data-err='" . (int) $file['id'] . "'></i></span>";
|
||||
} elseif ($status === 'inprogress') {
|
||||
if (in_array($action, ['inception', 'addition', 'dependent_addtion'], true)) {
|
||||
$toolTip = 'Live(s) : ' . ($file['employee_count'] ?? '0')
|
||||
. ' | Total premium : ₹ ' . format_indian_number($file['total'] ?? 0)
|
||||
. ' | Click to reload';
|
||||
$statusHtml = '<a data-toggle="tooltip" data-placement="top" data-id="' . htmlspecialchars($status, ENT_QUOTES, 'UTF-8') . '" class="reload" title="' . htmlspecialchars($toolTip, ENT_QUOTES, 'UTF-8') . '" href="#">' . htmlspecialchars($status, ENT_QUOTES, 'UTF-8') . '</a>';
|
||||
} else {
|
||||
$statusHtml = '<a data-id="' . htmlspecialchars($status, ENT_QUOTES, 'UTF-8') . '" class="reload" href="#">' . htmlspecialchars($status, ENT_QUOTES, 'UTF-8') . '</a>';
|
||||
}
|
||||
} elseif ($status === 'success') {
|
||||
if (in_array($action, ['inception', 'addition', 'dependent_addtion'], true)) {
|
||||
$toolTip = 'Live(s) : ' . ($file['employee_count'] ?? '0')
|
||||
. ' | Total premium : ₹ ' . format_indian_number($file['total'] ?? 0);
|
||||
$statusHtml = '<span data-toggle="tooltip" data-placement="top" data-id="' . htmlspecialchars($status, ENT_QUOTES, 'UTF-8') . '" title=" ' . htmlspecialchars($toolTip, ENT_QUOTES, 'UTF-8') . ' ">' . htmlspecialchars($status, ENT_QUOTES, 'UTF-8') . '</span>';
|
||||
} else {
|
||||
$statusHtml = '<span data-id="' . htmlspecialchars($status, ENT_QUOTES, 'UTF-8') . '" >' . htmlspecialchars($status, ENT_QUOTES, 'UTF-8') . '</span>';
|
||||
}
|
||||
} else {
|
||||
$statusHtml = '<span data-id="' . htmlspecialchars($status, ENT_QUOTES, 'UTF-8') . '" >' . htmlspecialchars($status, ENT_QUOTES, 'UTF-8') . '</span>';
|
||||
}
|
||||
|
||||
$reuploadPayload = htmlspecialchars(json_encode([
|
||||
'client_id' => $file['client_id'] ?? null,
|
||||
'client_policy_id' => $file['client_policy_id'] ?? null,
|
||||
'client_branch_id' => $file['client_branch_id'] ?? null,
|
||||
'action' => $file['action'] ?? null,
|
||||
]), ENT_QUOTES, 'UTF-8');
|
||||
|
||||
$actionHtml = '<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">';
|
||||
if ($status === 'failed') {
|
||||
$actionHtml .= '<a data-id="' . $reuploadPayload . '" data-toggle="modal" data-target="#file-upload-modal" class="dropdown-item upload_button" href="#"><i class="mdi mdi-upload mr-2 text-muted font-18 vertical-middle"></i>Re-Upload</a>';
|
||||
}
|
||||
$actionHtml .= '<a class="dropdown-item" href="' . base_url('util/download-file-list/') . (int) $file['id'] . '"><i class="mdi mdi-download mr-2 text-muted font-18 vertical-middle"></i>Download</a>';
|
||||
$actionHtml .= '<a data-id="' . (int) $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>';
|
||||
if ($status === 'success') {
|
||||
$actionHtml .= '<a data-id="' . (int) $file['id'] . '" class="dropdown-item truncate2" href="#"><i class="mdi mdi-delete mr-2 text-muted font-18 vertical-middle"></i>Truncate</a>';
|
||||
}
|
||||
$actionHtml .= '</div></div>';
|
||||
|
||||
return [
|
||||
0 => '<b>' . $serialNo . '</b>',
|
||||
1 => '<span style="overflow: hidden;" class="reload truncate" data-toggle="tooltip" data-placement="top" title="' . $fileName . '">' . $fileName . '</span>',
|
||||
2 => htmlspecialchars((string) ($file['short_name'] ?? ''), ENT_QUOTES, 'UTF-8'),
|
||||
3 => htmlspecialchars((string) ($file['branch_name'] ?? ''), ENT_QUOTES, 'UTF-8'),
|
||||
4 => htmlspecialchars($policyDisplay, ENT_QUOTES, 'UTF-8'),
|
||||
5 => htmlspecialchars($action, ENT_QUOTES, 'UTF-8'),
|
||||
6 => $userTime,
|
||||
7 => $statusHtml,
|
||||
8 => $actionHtml,
|
||||
];
|
||||
}
|
||||
|
||||
protected function batchListSelectColumns(): string
|
||||
{
|
||||
return "
|
||||
batch_files.id,
|
||||
batch_files.client_id,
|
||||
batch_files.client_policy_id,
|
||||
batch_files.batch_code,
|
||||
batch_files.file_name,
|
||||
batch_files.insurer_or_tpa,
|
||||
batch_files.event_type,
|
||||
batch_files.actions,
|
||||
batch_files.count,
|
||||
batch_files.created_by,
|
||||
batch_files.created_at,
|
||||
batch_files.updated_by,
|
||||
batch_files.updated_at,
|
||||
batch_files.is_active,
|
||||
batch_files.amount,
|
||||
batch_files.status,
|
||||
batch_files.icici_status_flag,
|
||||
batch_files.client_branch_id,
|
||||
insurers.short_name as insurer_short_name,
|
||||
tpa.short_name as tpa_short_name,
|
||||
DATE_FORMAT(batch_files.policy_issue_date, '%d/%m/%Y') AS policy_issue_date,
|
||||
CASE
|
||||
WHEN batch_files.status IN ('partially success', 'in-progress-partially', 'failed-7')
|
||||
THEN batch_files.error_data
|
||||
ELSE NULL
|
||||
END AS error_data,
|
||||
clients.short_name as client_short_name,
|
||||
client_branch.branch_name,
|
||||
client_policy.policy_no,
|
||||
policy_type.policy_type
|
||||
";
|
||||
}
|
||||
|
||||
protected function buildBatchListQuery(array $filters, string $search = '')
|
||||
{
|
||||
$db = \Config\Database::connect();
|
||||
$builder = $db->table('batch_files');
|
||||
$builder
|
||||
->join('client_policy', 'client_policy.id = batch_files.client_policy_id')
|
||||
->join('insurers', 'client_policy.insurer_id = insurers.id')
|
||||
->join('tpa', 'client_policy.tpa_id = tpa.id', 'left')
|
||||
->join('client_branch', 'client_branch.id = batch_files.client_branch_id')
|
||||
->join('policy_type', 'policy_type.id = client_policy.policy_type_id')
|
||||
->join('clients', 'clients.id = client_policy.client_id')
|
||||
->join('client_rm cr', 'cr.client_id = clients.id and cr.is_active = 1', 'left')
|
||||
->where('batch_files.is_active', 1);
|
||||
|
||||
$this->applyDateFilter($builder, $filters, 'batch_files.created_at');
|
||||
|
||||
if (!empty($filters['client_id'])) {
|
||||
$builder->where('batch_files.client_id', $filters['client_id']);
|
||||
}
|
||||
if (!empty($filters['client_branch_id'])) {
|
||||
$builder->where('batch_files.client_branch_id', $filters['client_branch_id']);
|
||||
}
|
||||
if (!empty($filters['policy_id'])) {
|
||||
$builder->where('batch_files.client_policy_id', $filters['policy_id']);
|
||||
}
|
||||
if (!empty($filters['event_type'])) {
|
||||
$builder->where('batch_files.event_type', $filters['event_type']);
|
||||
}
|
||||
if (!empty($filters['insurer_or_tpa'])) {
|
||||
$builder->where('batch_files.insurer_or_tpa', $filters['insurer_or_tpa']);
|
||||
}
|
||||
if (!empty($filters['action_type'])) {
|
||||
$builder->where('batch_files.actions', $filters['action_type']);
|
||||
}
|
||||
|
||||
$roleId = (int) get_role_id();
|
||||
if (in_array($roleId, [2, 3], true)) {
|
||||
$builder->where('cr.user_id', (int) get_session_userid());
|
||||
}
|
||||
|
||||
if ($search !== '') {
|
||||
$builder->groupStart()
|
||||
->like('batch_files.batch_code', $search)
|
||||
->orLike('batch_files.file_name', $search)
|
||||
->orLike('clients.short_name', $search)
|
||||
->orLike('client_branch.branch_name', $search)
|
||||
->orLike('client_policy.policy_no', $search)
|
||||
->orLike('policy_type.policy_type', $search)
|
||||
->orLike('batch_files.event_type', $search)
|
||||
->orLike('batch_files.insurer_or_tpa', $search)
|
||||
->orLike('batch_files.actions', $search)
|
||||
->orLike('batch_files.status', $search)
|
||||
->groupEnd();
|
||||
}
|
||||
|
||||
return $builder;
|
||||
}
|
||||
|
||||
protected function formatBatchListRowForDataTable(array $file, int $serialNo, array $insurerOrTpa, array $importOrExport): array
|
||||
{
|
||||
$fileName = htmlspecialchars((string) ($file['file_name'] ?? ''), ENT_QUOTES, 'UTF-8');
|
||||
$policyDisplay = trim(($file['policy_type'] ?? '') . ' - ' . ($file['policy_no'] ?? ''));
|
||||
$insLabel = $insurerOrTpa[$file['insurer_or_tpa'] ?? ''] ?? '';
|
||||
$insurerOrTpaDisplay = ($insLabel === 'TPA')
|
||||
? ($file['tpa_short_name'] ?? '')
|
||||
: ($file['insurer_short_name'] ?? '');
|
||||
|
||||
$insurerCell = htmlspecialchars($insLabel, ENT_QUOTES, 'UTF-8')
|
||||
. ' <a href="#" class="fe-alert-circle" style="color: #000;" aria-hidden="true" data-toggle="tooltip" data-placement="top" title="'
|
||||
. htmlspecialchars((string) $insurerOrTpaDisplay, ENT_QUOTES, 'UTF-8') . '"></a>';
|
||||
|
||||
$actKey = $file['actions'] ?? '';
|
||||
$actLabel = $importOrExport[$actKey] ?? ucfirst((string) $actKey);
|
||||
$actionCell = htmlspecialchars((string) $actLabel, ENT_QUOTES, 'UTF-8');
|
||||
if ($actKey === 'push') {
|
||||
$tooltipText = $insurerOrTpaDisplay . ' TPA Push Status: ' . ($file['icici_status_flag'] ?? 'N/A')
|
||||
. "\n\n\nNote: TPA ID can be fetched only after the TPA push status is completed.";
|
||||
$actionCell .= ' <a href="#" class="fe-alert-circle" style="color: #000;" aria-hidden="true" data-toggle="tooltip" data-placement="top" title="'
|
||||
. htmlspecialchars($tooltipText, ENT_QUOTES, 'UTF-8') . '"></a>';
|
||||
}
|
||||
|
||||
$userTime = change_date_format($file['created_at'] ?? '', 'Y-m-d H:i:s', 'd/m/Y h:i a')
|
||||
. ' by ' . get_username($file['created_by'] ?? '');
|
||||
|
||||
$status = (string) ($file['status'] ?? '');
|
||||
$statusHtml = htmlspecialchars($status, ENT_QUOTES, 'UTF-8');
|
||||
if ($status === 'failed') {
|
||||
$statusHtml = htmlspecialchars($status, ENT_QUOTES, 'UTF-8')
|
||||
. ' <a href="' . base_url('/util/export-import-error-list/') . (int) $file['id'] . '" class="fe-alert-circle" style="color: #000;" aria-hidden="true" target="_blank" data-toggle="tooltip" data-placement="top" title="Click to show the error"></a> ';
|
||||
} elseif ($status === 'partially success') {
|
||||
$statusHtml = htmlspecialchars($status, ENT_QUOTES, 'UTF-8');
|
||||
if (!empty($file['error_data']) && (string) $file['error_data'] !== '0') {
|
||||
$statusHtml .= ' <a class="fe-alert-circle" style="color: #000;" data-toggle="tooltip" data-placement="top" title="'
|
||||
. htmlspecialchars((string) $file['error_data'], ENT_QUOTES, 'UTF-8') . '"></a> ';
|
||||
}
|
||||
} elseif ($status === 'in-progress-partially') {
|
||||
$statusHtml = htmlspecialchars($status, ENT_QUOTES, 'UTF-8');
|
||||
if (!empty($file['error_data']) && function_exists('is_json_string') && !is_json_string($file['error_data'])) {
|
||||
$statusHtml .= ' <a class="fe-alert-circle" style="color: #000;" data-toggle="tooltip" data-placement="top" title="'
|
||||
. htmlspecialchars((string) $file['error_data'], ENT_QUOTES, 'UTF-8') . '"></a> ';
|
||||
}
|
||||
} elseif ($status === 'failed-1') {
|
||||
$title = ($file['event_type'] ?? '') === 'inception'
|
||||
? 'The list of employees provided has already been updated with the TPA ID.'
|
||||
: 'The list of employees provided has already been updated with the ENDORSEMENT ID.';
|
||||
$statusHtml = 'failed <a class="fe-alert-circle" style="color: #000;" data-toggle="tooltip" data-placement="top" title="'
|
||||
. htmlspecialchars($title, ENT_QUOTES, 'UTF-8') . '"></a>';
|
||||
} elseif ($status === 'failed-2') {
|
||||
$title = ($file['event_type'] ?? '') === 'inception'
|
||||
? 'The list of employees provided has already been updated with the UHID.'
|
||||
: 'The list of employees provided has already been updated with the ENDORSEMENT ID.';
|
||||
$statusHtml = 'failed <a class="fe-alert-circle" style="color: #000;" data-toggle="tooltip" data-placement="top" title="'
|
||||
. htmlspecialchars($title, ENT_QUOTES, 'UTF-8') . '"></a>';
|
||||
} elseif ($status === 'failed-3') {
|
||||
$statusHtml = 'failed <a class="fe-alert-circle" style="color: #000;" data-toggle="tooltip" data-placement="top" title="The Excel record count exceeds the DB record count."></a>';
|
||||
} elseif ($status === 'failed-4') {
|
||||
$statusHtml = 'failed <a class="fe-alert-circle" style="color: #000;" data-toggle="tooltip" data-placement="top" title="Physical File Not Found."></a>';
|
||||
} elseif ($status === 'failed-5') {
|
||||
$statusHtml = 'failed <a class="fe-alert-circle" style="color: #000;" data-toggle="tooltip" data-placement="top" title="Wrong File Uploaded"></a>';
|
||||
} elseif ($status === 'failed-6') {
|
||||
$statusHtml = 'failed <a class="fe-alert-circle" style="color: #000;" data-toggle="tooltip" data-placement="top" title="There is no data to update"></a>';
|
||||
} elseif ($status === 'failed-7') {
|
||||
$statusHtml = 'failed <a class="fe-alert-circle" style="color: #000;" data-toggle="tooltip" data-placement="top" title="'
|
||||
. htmlspecialchars((string) ($file['error_data'] ?? 'Unknown error. Contact system administrator.'), ENT_QUOTES, 'UTF-8') . '"></a>';
|
||||
} elseif ($status === 'failed-8') {
|
||||
$statusHtml = 'failed';
|
||||
}
|
||||
|
||||
$menuHtml = '<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>';
|
||||
if (($file['actions'] ?? '') !== 'export') {
|
||||
$menuHtml .= '<div class="dropdown-menu dropdown-menu-right">';
|
||||
if (str_starts_with($status, 'failed')) {
|
||||
$menuHtml .= '<a href="#" data-id="' . (int) $file['id'] . '" data-client_id="' . (int) ($file['client_id'] ?? 0)
|
||||
. '" data-client_policy_id="' . (int) ($file['client_policy_id'] ?? 0)
|
||||
. '" data-insurer_or_tpa="' . htmlspecialchars((string) ($file['insurer_or_tpa'] ?? ''), ENT_QUOTES, 'UTF-8')
|
||||
. '" data-event_type="' . htmlspecialchars((string) ($file['event_type'] ?? ''), ENT_QUOTES, 'UTF-8')
|
||||
. '" data-actions="' . htmlspecialchars((string) ($file['actions'] ?? ''), ENT_QUOTES, 'UTF-8')
|
||||
. '" data-client_branch_id="' . (int) ($file['client_branch_id'] ?? 0)
|
||||
. '" data-issue_date="' . htmlspecialchars((string) ($file['policy_issue_date'] ?? ''), ENT_QUOTES, 'UTF-8')
|
||||
. '" onclick="getBatchFileData(this)" class="dropdown-item upload_button"><i class="mdi mdi-upload mr-2 text-muted font-18 vertical-middle"></i>Re-Upload</a>';
|
||||
}
|
||||
if (($file['actions'] ?? '') === 'import') {
|
||||
$menuHtml .= '<a href="' . base_url('/util/download_import_file/') . (int) $file['id'] . '" class="dropdown-item" style="color: #000;" aria-hidden="true" target="_blank"><i class="mdi mdi-download mr-2 text-muted font-18 vertical-middle"></i>Download</a>';
|
||||
}
|
||||
if (($file['actions'] ?? '') === 'fetch' && $status === 'partially success') {
|
||||
$menuHtml .= '<a href="' . base_url('employee/getTPADataVariationReport/') . (int) $file['id'] . '" class="dropdown-item" style="color: #000;" aria-hidden="true" target="_blank"><i class="mdi mdi-download mr-2 text-muted font-18 vertical-middle"></i>Download TPA Variation report</a>';
|
||||
$menuHtml .= '<a href="#" class="dropdown-item" style="color: #000;" aria-hidden="true" onclick="getTPADataVariationReport(' . (int) $file['id'] . ')"><i class="mdi mdi-eye mr-2 text-muted font-18 vertical-middle"></i>View TPA Variation report</a>';
|
||||
}
|
||||
$menuHtml .= '</div>';
|
||||
}
|
||||
$menuHtml .= '</div>';
|
||||
|
||||
return [
|
||||
0 => '<b>' . $serialNo . '</b>',
|
||||
1 => htmlspecialchars((string) ($file['batch_code'] ?? ''), ENT_QUOTES, 'UTF-8'),
|
||||
2 => '<span class="reload batch-file-cell" data-toggle="tooltip" data-placement="top" title="' . $fileName . '">' . $fileName . '</span>',
|
||||
3 => htmlspecialchars((string) ($file['client_short_name'] ?? ''), ENT_QUOTES, 'UTF-8'),
|
||||
4 => htmlspecialchars((string) ($file['branch_name'] ?? ''), ENT_QUOTES, 'UTF-8'),
|
||||
5 => '<span class="batch-policy-cell reload" data-toggle="tooltip" data-placement="top" title="'
|
||||
. htmlspecialchars($policyDisplay, ENT_QUOTES, 'UTF-8') . '">'
|
||||
. htmlspecialchars($policyDisplay, ENT_QUOTES, 'UTF-8') . '</span>',
|
||||
6 => htmlspecialchars((string) ($file['event_type'] ?? ''), ENT_QUOTES, 'UTF-8'),
|
||||
7 => $insurerCell,
|
||||
8 => $actionCell,
|
||||
9 => ($file['count'] === null || $file['count'] === '') ? '-' : htmlspecialchars((string) $file['count'], ENT_QUOTES, 'UTF-8'),
|
||||
10 => format_indian_number($file['amount'] ?? 0),
|
||||
11 => '<span class="reload">' . $userTime . '</span>',
|
||||
12 => $statusHtml,
|
||||
13 => $menuHtml,
|
||||
];
|
||||
}
|
||||
|
||||
protected function hrFileListSelectColumns(): string
|
||||
{
|
||||
return "
|
||||
hr_file_upload.id,
|
||||
hr_file_upload.client_id,
|
||||
hr_file_upload.client_branch_id,
|
||||
hr_file_upload.policy_id,
|
||||
hr_file_upload.policy_no,
|
||||
hr_file_upload.file_name,
|
||||
hr_file_upload.file_action,
|
||||
hr_file_upload.created_at,
|
||||
hr_file_upload.created_by,
|
||||
hr_file_upload.status,
|
||||
c.short_name,
|
||||
cb.branch_name,
|
||||
lc.name as first_name
|
||||
";
|
||||
}
|
||||
|
||||
protected function buildHrFileListQuery(array $filters, string $search = '')
|
||||
{
|
||||
$db = \Config\Database::connect();
|
||||
$builder = $db->table('hr_file_upload');
|
||||
$builder
|
||||
->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('client_rm cr', 'cr.client_id = c.id and cr.is_active = 1', 'left');
|
||||
|
||||
$this->applyDateFilter($builder, $filters, 'hr_file_upload.created_at');
|
||||
|
||||
if (!empty($filters['client_id'])) {
|
||||
$builder->where('hr_file_upload.client_id', $filters['client_id']);
|
||||
}
|
||||
if (!empty($filters['client_branch_id'])) {
|
||||
$builder->where('hr_file_upload.client_branch_id', $filters['client_branch_id']);
|
||||
}
|
||||
if (!empty($filters['policy_id'])) {
|
||||
$builder->where('hr_file_upload.policy_id', $filters['policy_id']);
|
||||
}
|
||||
if (!empty($filters['event_type'])) {
|
||||
$builder->where('hr_file_upload.file_action', $filters['event_type']);
|
||||
}
|
||||
|
||||
$roleId = (int) get_role_id();
|
||||
if (in_array($roleId, [2, 3], true)) {
|
||||
$builder->where('cr.user_id', (int) get_session_userid());
|
||||
}
|
||||
|
||||
if ($search !== '') {
|
||||
$builder->groupStart()
|
||||
->like('hr_file_upload.file_name', $search)
|
||||
->orLike('c.short_name', $search)
|
||||
->orLike('cb.branch_name', $search)
|
||||
->orLike('hr_file_upload.policy_no', $search)
|
||||
->orLike('hr_file_upload.file_action', $search)
|
||||
->orLike('hr_file_upload.status', $search)
|
||||
->orLike('lc.name', $search)
|
||||
->groupEnd();
|
||||
}
|
||||
|
||||
return $builder;
|
||||
}
|
||||
|
||||
protected function formatHrFileListRowForDataTable(array $file, int $serialNo): array
|
||||
{
|
||||
$fileName = htmlspecialchars((string) ($file['file_name'] ?? ''), ENT_QUOTES, 'UTF-8');
|
||||
$fileAction = (string) ($file['file_action'] ?? '');
|
||||
$fileActionLabel = ucwords(str_replace('_', ' ', strtolower($fileAction)));
|
||||
$createdAt = change_date_format($file['created_at'] ?? '', 'Y-m-d H:i:s', 'd/m/Y h:i A');
|
||||
$userTime = htmlspecialchars((string) $createdAt, ENT_QUOTES, 'UTF-8')
|
||||
. ' by <strong>' . htmlspecialchars((string) ($file['first_name'] ?? ''), ENT_QUOTES, 'UTF-8') . '</strong>';
|
||||
|
||||
$baseUrl = rtrim(base_url(), '/');
|
||||
$actionHtml = '<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 href="' . $baseUrl . '/hrFileDownload?id=' . (int) $file['id'] . '" class="dropdown-item" style="color: #000;" aria-hidden="true" target="_blank"><i class="mdi mdi-download mr-2 text-muted font-18 vertical-middle"></i>Download</a>'
|
||||
. '<a class="dropdown-item" onclick="uploadEndorsementFile('
|
||||
. (int) ($file['client_id'] ?? 0) . ', '
|
||||
. (int) ($file['client_branch_id'] ?? 0) . ', '
|
||||
. (int) ($file['policy_id'] ?? 0) . ', '
|
||||
. (int) $file['id'] . ', \''
|
||||
. htmlspecialchars($fileAction, ENT_QUOTES, 'UTF-8') . '\')" style="color: #000;" aria-hidden="true"><i class="mdi mdi-upload mr-2 text-muted font-18 vertical-middle"></i>Initiate Endorsement</a>'
|
||||
. '</div></div>';
|
||||
|
||||
return [
|
||||
0 => '<b>' . $serialNo . '</b>',
|
||||
1 => '<span id="' . (int) $file['id'] . '" class="reload truncate" title="' . $fileName . '">' . $fileName . '</span>',
|
||||
2 => htmlspecialchars((string) ($file['short_name'] ?? ''), ENT_QUOTES, 'UTF-8'),
|
||||
3 => htmlspecialchars((string) ($file['branch_name'] ?? ''), ENT_QUOTES, 'UTF-8'),
|
||||
4 => htmlspecialchars((string) ($file['policy_no'] ?? ''), ENT_QUOTES, 'UTF-8'),
|
||||
5 => htmlspecialchars($fileActionLabel, ENT_QUOTES, 'UTF-8'),
|
||||
6 => $userTime,
|
||||
7 => htmlspecialchars((string) ($file['status'] ?? ''), ENT_QUOTES, 'UTF-8'),
|
||||
8 => $actionHtml,
|
||||
];
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
@ -7377,14 +7377,14 @@ class EmployeeRestController extends AdminController
|
||||
'disclaimer' => $policy['disclaimer'],
|
||||
'sum_insured_label' => $ticketMeta['sum_insured_label'],
|
||||
'claim_subject' => $ticketMeta['claim_subject'],
|
||||
'terms_and_conditions' => [
|
||||
'raw' => $termsArray,
|
||||
'display' => $displayTerms,
|
||||
],
|
||||
'premium_details' => $premiumDetails,
|
||||
'claim_details' => $claimDetails,
|
||||
'emp_details' => $empDetails,
|
||||
],
|
||||
'terms_and_conditions' => [
|
||||
'raw' => $termsArray,
|
||||
'display' => $displayTerms,
|
||||
],
|
||||
'premium_details' => $premiumDetails,
|
||||
'claim_details' => $claimDetails,
|
||||
'emp_details' => $empDetails,
|
||||
];
|
||||
}
|
||||
|
||||
|
||||
@ -9,40 +9,17 @@ $batch_col_max_len = array_fill(0, $batch_col_count, 0);
|
||||
for ($i = 0; $i < $batch_col_count; $i++) {
|
||||
$batch_col_max_len[$i] = mb_strlen($batch_header_labels[$i]);
|
||||
}
|
||||
$batch_col_max_len[1] = max($batch_col_max_len[1], 14);
|
||||
$batch_col_max_len[2] = max($batch_col_max_len[2], 36);
|
||||
$batch_col_max_len[3] = max($batch_col_max_len[3], 12);
|
||||
$batch_col_max_len[4] = max($batch_col_max_len[4], 14);
|
||||
$batch_col_max_len[5] = max($batch_col_max_len[5], 22);
|
||||
$batch_col_max_len[6] = max($batch_col_max_len[6], 12);
|
||||
$batch_col_max_len[11] = max($batch_col_max_len[11], 28);
|
||||
$batch_col_max_len[12] = max($batch_col_max_len[12], 16);
|
||||
$insurer_or_tpa = $insurer_or_tpa ?? [];
|
||||
$import_or_export = $import_or_export ?? [];
|
||||
|
||||
if (!empty($batch_list) && is_array($batch_list)) {
|
||||
foreach ($batch_list as $key => $file) {
|
||||
$batch_col_max_len[0] = max($batch_col_max_len[0], mb_strlen((string) ($key + 1)));
|
||||
$batch_col_max_len[1] = max($batch_col_max_len[1], mb_strlen((string) ($file['batch_code'] ?? '')));
|
||||
$batch_col_max_len[2] = max($batch_col_max_len[2], mb_strlen((string) ($file['file_name'] ?? '')));
|
||||
$batch_col_max_len[3] = max($batch_col_max_len[3], mb_strlen((string) ($file['client_short_name'] ?? '')));
|
||||
$batch_col_max_len[4] = max($batch_col_max_len[4], mb_strlen((string) ($file['branch_name'] ?? '')));
|
||||
$policy_display_len = trim(
|
||||
(isset($file['policy_type']) ? $file['policy_type'] : '')
|
||||
. ' - '
|
||||
. (isset($file['policy_no']) ? $file['policy_no'] : '')
|
||||
);
|
||||
$batch_col_max_len[5] = max($batch_col_max_len[5], mb_strlen($policy_display_len));
|
||||
$batch_col_max_len[6] = max($batch_col_max_len[6], mb_strlen((string) ($file['event_type'] ?? '')));
|
||||
$insLabel = $insurer_or_tpa[$file['insurer_or_tpa'] ?? ''] ?? '';
|
||||
$batch_col_max_len[7] = max($batch_col_max_len[7], mb_strlen((string) $insLabel));
|
||||
$actKey = $file['actions'] ?? '';
|
||||
$actLabel = $import_or_export[$actKey] ?? ucfirst((string) $actKey);
|
||||
$batch_col_max_len[8] = max($batch_col_max_len[8], mb_strlen((string) $actLabel));
|
||||
$countStr = ($file['count'] ?? null) === null ? '-' : (string) $file['count'];
|
||||
$batch_col_max_len[9] = max($batch_col_max_len[9], mb_strlen($countStr));
|
||||
$batch_col_max_len[10] = max($batch_col_max_len[10], mb_strlen((string) format_indian_number($file['amount'])));
|
||||
$userTime = change_date_format($file['created_at'] ?? '', 'Y-m-d H:i:s', 'd/m/Y h:i a')
|
||||
. ' by '
|
||||
. get_username($file['created_by'] ?? '');
|
||||
$batch_col_max_len[11] = max($batch_col_max_len[11], mb_strlen($userTime));
|
||||
$batch_col_max_len[12] = max($batch_col_max_len[12], mb_strlen((string) ($file['status'] ?? '')));
|
||||
$batch_col_max_len[13] = max($batch_col_max_len[13], 2);
|
||||
}
|
||||
}
|
||||
|
||||
$batch_col_min_px = [48, 72, 100, 72, 80, 120, 88, 96, 72, 56, 80, 160, 96, 52];
|
||||
$batch_col_max_px = [64, 220, 480, 240, 240, 640, 200, 200, 140, 110, 160, 560, 320, 64];
|
||||
$batch_col_width_px = [];
|
||||
@ -292,190 +269,6 @@ for ($i = 0; $i < $batch_col_count; $i++) {
|
||||
</thead>
|
||||
|
||||
<tbody class="font-12">
|
||||
<?php
|
||||
if (isset($batch_list)) {
|
||||
foreach ($batch_list as $key => $file) {
|
||||
?>
|
||||
|
||||
<tr>
|
||||
<td><b><?php echo ($key + 1) ?></b></td>
|
||||
<td><?php echo $file['batch_code'] ?></td>
|
||||
<td class="reload batch-file-cell" data-toggle="tooltip" data-placement="top" title="<?php echo htmlspecialchars($file['file_name'] ?? '', ENT_QUOTES, 'UTF-8') ?>">
|
||||
<?php echo $file['file_name']?>
|
||||
</td>
|
||||
<td><?php echo $file['client_short_name'] ?></td>
|
||||
<td><?php echo $file['branch_name'] ?></td>
|
||||
<!-- <td><?php echo isset($file['policy_name']) ? $file['policy_name'] : '' ?> - <?php echo isset($file['policy_no']) ? $file['policy_no'] : '' ?> - <?php echo isset($file['policy_type']) ? $file['policy_type'] : '' ?></td> -->
|
||||
<?php
|
||||
$policy_display = trim(
|
||||
(isset($file['policy_type']) ? $file['policy_type'] : '')
|
||||
. ' - '
|
||||
. (isset($file['policy_no']) ? $file['policy_no'] : '')
|
||||
);
|
||||
?>
|
||||
<td class="batch-policy-cell reload"
|
||||
data-toggle="tooltip"
|
||||
data-placement="top"
|
||||
title="<?= esc($policy_display) ?>"><?= esc($policy_display) ?></td>
|
||||
<td><?php echo $file['event_type'] ?></td>
|
||||
|
||||
<td><?php echo $insurer_or_tpa[$file['insurer_or_tpa']] ?>
|
||||
<?php $insurer_or_tpa_display = $insurer_or_tpa[$file['insurer_or_tpa']] == 'TPA' ? $file['tpa_short_name'] : $file['insurer_short_name'] ?>
|
||||
<a href="#" class="fe-alert-circle" style="color: #000;" aria-hidden="true" data-toggle="tooltip" data-placement="top" title="<?php echo $insurer_or_tpa_display ?>"></a>
|
||||
</td>
|
||||
|
||||
<td>
|
||||
<?php echo $import_or_export[$file['actions']] ?? ucfirst($file['actions']); ?>
|
||||
|
||||
<?php if ($file['actions'] == 'push'): ?>
|
||||
<?php $tpa_push_status = $file['icici_status_flag']; ?>
|
||||
|
||||
<?php
|
||||
$tooltipText = $insurer_or_tpa_display . ' TPA Push Status: ' . ($tpa_push_status ?? 'N/A');
|
||||
$tooltipText .= "\n\n\nNote: TPA ID can be fetched only after the TPA push status is completed.";
|
||||
?>
|
||||
|
||||
<a href="#"
|
||||
class="fe-alert-circle"
|
||||
style="color: #000;"
|
||||
aria-hidden="true"
|
||||
data-toggle="tooltip"
|
||||
data-placement="top"
|
||||
title="<?php echo htmlspecialchars($tooltipText, ENT_QUOTES, 'UTF-8'); ?>">
|
||||
</a>
|
||||
<?php endif; ?>
|
||||
</td>
|
||||
|
||||
<td><?php echo $file['count'] == null ? '-' : $file['count'] ?></td>
|
||||
|
||||
<td><?php echo format_indian_number($file['amount'])?></td>
|
||||
<td class="reload">
|
||||
<?php echo change_date_format($file['created_at'],'Y-m-d H:i:s', 'd/m/Y h:i a') ?> by <?php echo get_username($file['created_by']) ?>
|
||||
</td>
|
||||
|
||||
|
||||
<td>
|
||||
<?php if ($file['status'] == 'failed') { ?>
|
||||
<?php echo $file['status']; ?>
|
||||
|
||||
<a href="<?= base_url('/util/export-import-error-list/') . $file['id'] ?>"
|
||||
class="fe-alert-circle" style="color: #000;" aria-hidden="true" target="_blank"
|
||||
data-toggle="tooltip" data-placement="top" title="Click to show the error"></a>
|
||||
|
||||
|
||||
<?php } else if ($file['status'] == 'partially success') { ?>
|
||||
|
||||
<?php echo $file['status']; ?>
|
||||
|
||||
<?php if ($file['error_data'] != 0) { ?>
|
||||
|
||||
<a class="fe-alert-circle" style="color: #000;" data-toggle="tooltip"
|
||||
data-placement="top" title="<?= $file['error_data'] ?>"></a>
|
||||
|
||||
|
||||
<?php } ?>
|
||||
|
||||
<?php } else if ($file['status'] == 'in-progress-partially') { ?>
|
||||
|
||||
<?php echo $file['status']; ?>
|
||||
<?php if (!is_json_string($file['error_data'])) { ?>
|
||||
<a class="fe-alert-circle" style="color: #000;" data-toggle="tooltip"
|
||||
data-placement="top" title="<?= $file['error_data'] ?>"></a>
|
||||
|
||||
<?php } ?>
|
||||
|
||||
<?php } else if ($file['status'] == 'failed-1') { ?>
|
||||
|
||||
failed <a class="fe-alert-circle" style="color: #000;" data-toggle="tooltip"
|
||||
data-placement="top"
|
||||
title="<?= $file['event_type'] == 'inception' ? 'The list of employees provided has already been updated with the TPA ID.' : 'The list of employees provided has already been updated with the ENDORSEMENT ID.' ?> "></a>
|
||||
|
||||
|
||||
<?php } else if ($file['status'] == 'failed-2') { ?>
|
||||
|
||||
failed <a class="fe-alert-circle" style="color: #000;" data-toggle="tooltip"
|
||||
data-placement="top"
|
||||
title="<?= $file['event_type'] == 'inception' ? 'The list of employees provided has already been updated with the UHID.' : 'The list of employees provided has already been updated with the ENDORSEMENT ID.' ?>"></a>
|
||||
|
||||
<?php } else if ($file['status'] == 'failed-3') { ?>
|
||||
|
||||
failed <a class="fe-alert-circle" style="color: #000;" data-toggle="tooltip"
|
||||
data-placement="top"
|
||||
title="The Excel record count exceeds the DB record count."></a>
|
||||
|
||||
<?php } else if ($file['status'] == 'failed-4') { ?>
|
||||
|
||||
failed <a class="fe-alert-circle" style="color: #000;" data-toggle="tooltip"
|
||||
data-placement="top" title="Physical File Not Found."></a>
|
||||
|
||||
<?php } else if ($file['status'] == 'failed-5') { ?>
|
||||
|
||||
failed <a class="fe-alert-circle" style="color: #000;" data-toggle="tooltip"
|
||||
data-placement="top" title="Wrong File Uploaded"></a>
|
||||
|
||||
<?php } else if ($file['status'] == 'failed-6') { ?>
|
||||
|
||||
failed <a class="fe-alert-circle" style="color: #000;" data-toggle="tooltip"
|
||||
data-placement="top" title="There is no data to update"></a>
|
||||
|
||||
<?php } else if ($file['status'] == 'failed-7') { ?>
|
||||
|
||||
failed <a class="fe-alert-circle" style="color: #000;" data-toggle="tooltip"
|
||||
data-placement="top" title="<?= $file['error_data'] ?? 'Unknown error. Contact system administrator.' ?>"></a>
|
||||
|
||||
<?php } else if ($file['status'] == 'failed-8') { ?>
|
||||
|
||||
failed
|
||||
|
||||
<?php } else { ?>
|
||||
|
||||
<?php echo $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>
|
||||
|
||||
<?php if($file['actions'] != 'export') { ?>
|
||||
|
||||
<div class="dropdown-menu dropdown-menu-right">
|
||||
|
||||
<?php if (str_starts_with($file['status'], 'failed')) { ?>
|
||||
<a href="#"
|
||||
data-id="<?= $file['id'] ?>"
|
||||
data-client_id="<?= $file['client_id'] ?>"
|
||||
data-client_policy_id="<?= $file['client_policy_id'] ?>"
|
||||
data-insurer_or_tpa="<?= $file['insurer_or_tpa'] ?>"
|
||||
data-event_type="<?= $file['event_type'] ?>"
|
||||
data-actions="<?= $file['actions'] ?>"
|
||||
data-client_branch_id="<?= $file['client_branch_id'] ?>"
|
||||
data-issue_date="<?= $file['policy_issue_date'] ?>"
|
||||
|
||||
onclick="getBatchFileData(this)" class="dropdown-item upload_button" ><i class="mdi mdi-upload mr-2 text-muted font-18 vertical-middle"></i>Re-Upload</a>
|
||||
<?php } ?>
|
||||
|
||||
<?php if ($file['actions'] == "import") { ?>
|
||||
<a href="<?= base_url('/util/download_import_file/') . $file['id'] ?>" class="dropdown-item" style="color: #000;" aria-hidden="true" target="_blank" ><i class="mdi mdi-download mr-2 text-muted font-18 vertical-middle"></i>Download</a>
|
||||
<?php } ?>
|
||||
|
||||
<?php if ($file['actions'] == "fetch" && $file['status'] == 'partially success') { ?>
|
||||
<a href="<?= base_url('employee/getTPADataVariationReport/') . $file['id'] ?>" class="dropdown-item" style="color: #000;" aria-hidden="true" target="_blank" ><i class="mdi mdi-download mr-2 text-muted font-18 vertical-middle"></i>Download TPA Variation report</a>
|
||||
<a href="#" class="dropdown-item" style="color: #000;" aria-hidden="true" onclick="getTPADataVariationReport(<?= $file['id'] ?>)"><i class="mdi mdi-eye mr-2 text-muted font-18 vertical-middle"></i>View TPA Variation report</a>
|
||||
|
||||
<?php } ?>
|
||||
|
||||
</div>
|
||||
|
||||
<?php } ?>
|
||||
</div>
|
||||
</td>
|
||||
</tr>
|
||||
<?php }
|
||||
} ?>
|
||||
|
||||
</tbody>
|
||||
</table>
|
||||
<div>
|
||||
@ -949,6 +742,25 @@ for ($i = 0; $i < $batch_col_count; $i++) {
|
||||
$.extend($.fn.dataTable.defaults, { scrollX: false, scrollY: false, scrollCollapse: false });
|
||||
|
||||
const batchListTable = $('#batch-list-table').DataTable({
|
||||
processing: true,
|
||||
serverSide: true,
|
||||
deferRender: true,
|
||||
searchDelay: 400,
|
||||
pageLength: 10,
|
||||
columns: (function() {
|
||||
var cols = [];
|
||||
for (var i = 0; i < <?= (int) $batch_col_count ?>; i++) {
|
||||
cols.push({ data: String(i), orderable: false });
|
||||
}
|
||||
return cols;
|
||||
})(),
|
||||
ajax: {
|
||||
url: '<?= base_url("employee/upload/batch-list/datatable") ?>',
|
||||
type: 'POST',
|
||||
data: function(d) {
|
||||
return $.extend({}, d, window.uploadListFilters || {});
|
||||
}
|
||||
},
|
||||
dom: "<'row'<'col-sm-7'f><'col-sm-5 text-right'B>>" + // Filter left, buttons right
|
||||
"<'row'<'col-sm-12'tr>>" +
|
||||
"<'row align-items-center'<'col-5 text-start'i><'col-7 d-flex justify-content-end align-items-center'<'me-2'l>p>>",
|
||||
@ -1017,9 +829,15 @@ for ($i = 0; $i < $batch_col_count; $i++) {
|
||||
},
|
||||
autoWidth: false,
|
||||
paging: true,
|
||||
responsive: false
|
||||
ordering: false,
|
||||
responsive: false,
|
||||
drawCallback: function() {
|
||||
$('[data-toggle="tooltip"]').tooltip({ container: 'body' });
|
||||
}
|
||||
});
|
||||
|
||||
window.batchListTableInstance = batchListTable;
|
||||
|
||||
$.extend($.fn.dataTable.defaults, _dtDefScroll);
|
||||
|
||||
// Keep TH and TD widths in sync after any table redraw (search/sort/paginate).
|
||||
|
||||
@ -9,32 +9,14 @@ $fl_col_max_len = array_fill(0, $fl_col_count, 0);
|
||||
for ($i = 0; $i < $fl_col_count; $i++) {
|
||||
$fl_col_max_len[$i] = mb_strlen($fl_header_labels[$i]);
|
||||
}
|
||||
$fileList = $fileList ?? [];
|
||||
if (!empty($fileList) && is_array($fileList)) {
|
||||
foreach ($fileList as $key => $file) {
|
||||
$fl_col_max_len[0] = max($fl_col_max_len[0], mb_strlen((string) ($key + 1)));
|
||||
$fl_col_max_len[1] = max($fl_col_max_len[1], mb_strlen((string) ($file['file_name'] ?? '')));
|
||||
$fl_col_max_len[2] = max($fl_col_max_len[2], mb_strlen((string) ($file['short_name'] ?? '')));
|
||||
$fl_col_max_len[3] = max($fl_col_max_len[3], mb_strlen((string) ($file['branch_name'] ?? '')));
|
||||
$policy_display = trim(
|
||||
(isset($file['policy_type']) ? $file['policy_type'] : '')
|
||||
. ' - '
|
||||
. (isset($file['policy_no']) ? $file['policy_no'] : '')
|
||||
);
|
||||
$fl_col_max_len[4] = max($fl_col_max_len[4], mb_strlen($policy_display));
|
||||
$fl_col_max_len[5] = max($fl_col_max_len[5], mb_strlen((string) ($file['action'] ?? '')));
|
||||
$userTime = change_date_format($file['created_at'] ?? '', 'Y-m-d H:i:s', 'd/m/Y h:i a')
|
||||
. ' by '
|
||||
. ($file['first_name'] ?? '');
|
||||
$fl_col_max_len[6] = max($fl_col_max_len[6], mb_strlen($userTime));
|
||||
$st = (string) ($file['status'] ?? '');
|
||||
$fl_col_max_len[7] = max($fl_col_max_len[7], mb_strlen($st));
|
||||
if ($st === 'inprogress' || $st === 'success') {
|
||||
$fl_col_max_len[7] = max($fl_col_max_len[7], 12);
|
||||
}
|
||||
$fl_col_max_len[8] = max($fl_col_max_len[8], 4);
|
||||
}
|
||||
}
|
||||
// Prefer readable defaults for server-side pages (row lengths unknown at render).
|
||||
$fl_col_max_len[1] = max($fl_col_max_len[1], 28);
|
||||
$fl_col_max_len[2] = max($fl_col_max_len[2], 12);
|
||||
$fl_col_max_len[3] = max($fl_col_max_len[3], 14);
|
||||
$fl_col_max_len[4] = max($fl_col_max_len[4], 22);
|
||||
$fl_col_max_len[5] = max($fl_col_max_len[5], 14);
|
||||
$fl_col_max_len[6] = max($fl_col_max_len[6], 28);
|
||||
$fl_col_max_len[7] = max($fl_col_max_len[7], 12);
|
||||
$fl_col_min_px = [48, 100, 72, 80, 120, 88, 160, 96, 72];
|
||||
$fl_col_max_px = [64, 320, 180, 180, 360, 160, 320, 200, 88];
|
||||
$fl_col_width_px = nhance_dt_column_widths_px($fl_header_labels, $fl_col_max_len, $fl_col_min_px, $fl_col_max_px);
|
||||
@ -117,11 +99,24 @@ $fl_col_width_px = nhance_dt_column_widths_px($fl_header_labels, $fl_col_max_len
|
||||
#file-list-table_wrapper .datatable-clear-icon{
|
||||
right: 11px !important;
|
||||
}
|
||||
#file-list-page .card-body > .table-responsive {
|
||||
|
||||
/*
|
||||
* One horizontal scrollbar (same as batch_list):
|
||||
* - No .dataTables_scrollBody → outer .table-responsive scrolls wide columns.
|
||||
* - With .dataTables_scrollBody → outer stays visible (custom.css / nh-dt-no-outer-scroll);
|
||||
* only the inner DT strip scrolls. Do not force overflow-x:auto on the outer wrapper
|
||||
* or you get a second scrollbar under the pagination row.
|
||||
*/
|
||||
#file-list-page .card-body > .table-responsive:not(:has(.dataTables_scrollBody)) {
|
||||
overflow-x: auto !important;
|
||||
-webkit-overflow-scrolling: touch;
|
||||
max-width: 100%;
|
||||
}
|
||||
#file-list-page .card-body > .table-responsive:has(.dataTables_scrollBody) {
|
||||
overflow-x: visible !important;
|
||||
-webkit-overflow-scrolling: auto;
|
||||
max-width: 100%;
|
||||
}
|
||||
|
||||
</style>
|
||||
<style>
|
||||
@ -185,81 +180,6 @@ $fl_col_width_px = nhance_dt_column_widths_px($fl_header_labels, $fl_col_max_len
|
||||
</thead>
|
||||
|
||||
<tbody class="font-12">
|
||||
<?php
|
||||
if (isset($fileList)) {
|
||||
foreach ($fileList as $key => $file) { //print_r((json_decode($file['reason'])));
|
||||
// $reason = json_decode(($file['reason']));
|
||||
// $reason = "{'date':'value data kbckl kcn/aksl'}";
|
||||
// echo $reason;
|
||||
?>
|
||||
|
||||
<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 $file['short_name'] ?></td>
|
||||
<td><?php echo $file['branch_name'] ?></td>
|
||||
<!-- <td><?php echo isset($file['policy_name']) ? $file['policy_name'] : '' ?> - <?php echo isset($file['policy_no']) ? $file['policy_no'] : '' ?> - <?php echo isset($file['policy_type']) ? $file['policy_type'] : '' ?></td> -->
|
||||
<td><?php echo isset($file['policy_type']) ? $file['policy_type'] : '' ?> - <?php echo isset($file['policy_no']) ? $file['policy_no'] : '' ?></td>
|
||||
<td><?php echo $file['action'] ?></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['first_name'] . '</strong>' ?>
|
||||
</td>
|
||||
<td>
|
||||
<?php
|
||||
if ($file['status'] == 'failed') {
|
||||
echo $file['status'] . " <span class='col-xl-3 col-lg-4 col-sm-6'> <i class='fe-alert-circle' data-toggle='modal' data-target='#file-err-modal' data-err=" . $file['id'] . "></i></span>";
|
||||
} else if ($file['status'] == 'inprogress') {
|
||||
|
||||
if ($file['action'] == 'inception' || $file['action'] == 'addition' || $file['action'] == 'dependent_addtion') {
|
||||
|
||||
$tool_tip_text = "Live(s) : {$file['employee_count']}" . " | Total premium : ₹ " . format_indian_number($file['total'], 2, ',') . " | Click to reload";
|
||||
echo '<a data-toggle="tooltip" data-placement="top" data-id="' . $file['status'] . '" class="reload" title="' . $tool_tip_text . '" href="#">' . $file['status'] . '</a>';
|
||||
}else{
|
||||
|
||||
echo '<a data-id="' . $file['status'] . '" class="reload" href="#">' . $file['status'] . '</a>';
|
||||
}
|
||||
} else if ($file['status'] == 'success') {
|
||||
|
||||
if ($file['action'] == 'inception' || $file['action'] == 'addition' || $file['action'] == 'dependent_addtion') {
|
||||
$tool_tip_text = "Live(s) : {$file['employee_count']}" . " | Total premium : ₹ " . format_indian_number($file['total'], 2, ',');
|
||||
// $tool_tip_text = "dssd";
|
||||
// Total Amount : $file['total']";
|
||||
echo '<span data-toggle="tooltip" data-placement="top" data-id="' . $file['status'] . '" title=" ' . $tool_tip_text . ' ">' . $file['status'] . '</span>';
|
||||
}else{
|
||||
echo '<span data-id="' . $file['status'] . '" >' . $file['status'] . '</span>';
|
||||
}
|
||||
}else{
|
||||
|
||||
echo '<span data-id="' . $file['status'] . '" >' . $file['status'] . '</span>';
|
||||
}
|
||||
?>
|
||||
</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">
|
||||
<?php if ($file['status'] == 'failed') { ?>
|
||||
<a data-id="<?= htmlspecialchars(json_encode(['client_id' => $file['client_id'], 'client_policy_id' => $file['client_policy_id'], 'client_branch_id' => $file['client_branch_id'], 'action' => $file['action']])) ?>" data-toggle="modal" data-target="#file-upload-modal" class="dropdown-item upload_button" href="#"><i class="mdi mdi-upload mr-2 text-muted font-18 vertical-middle"></i>Re-Upload</a>
|
||||
<?php } ?>
|
||||
|
||||
<a class="dropdown-item" href="<?= base_url("util/download-file-list/") . $file['id']; ?>"><i class="mdi mdi-download mr-2 text-muted font-18 vertical-middle"></i>Download</a>
|
||||
<a data-id="<?php echo $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>
|
||||
|
||||
<?php if ($file['status'] == 'success') { ?>
|
||||
<a data-id="<?php echo $file['id'] ?>" class="dropdown-item truncate2" href="#"><i class="mdi mdi-delete mr-2 text-muted font-18 vertical-middle"></i>Truncate</a>
|
||||
<?php } ?>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
</td>
|
||||
</tr>
|
||||
<?php }
|
||||
} ?>
|
||||
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
@ -696,9 +616,66 @@ $fl_col_width_px = nhance_dt_column_widths_px($fl_header_labels, $fl_col_max_len
|
||||
|
||||
$(document).ready(function() {
|
||||
|
||||
nhanceListDataTableBeforeInit();
|
||||
var nhFileListTable = $('#file-list-table').DataTable(nhanceMergeListDataTableOptions({
|
||||
window.fileListTableInstance = window.fileListTableInstance || null;
|
||||
window.uploadListFilters = window.uploadListFilters || {
|
||||
client_id: '',
|
||||
client_branch_id: '',
|
||||
policy_id: '',
|
||||
event_type: '',
|
||||
insurer_or_tpa: '',
|
||||
action_type: '',
|
||||
start_date: '',
|
||||
end_date: '',
|
||||
use_default_date: '1'
|
||||
};
|
||||
|
||||
(function seedUploadListFiltersFromUrl() {
|
||||
const urlParams = new URLSearchParams(window.location.search);
|
||||
['client_id', 'event_type', 'insurer_or_tpa', 'action_type', 'start_date', 'end_date'].forEach(function(key) {
|
||||
if (urlParams.get(key)) {
|
||||
window.uploadListFilters[key] = urlParams.get(key);
|
||||
}
|
||||
});
|
||||
if (urlParams.get('client_branch_id') || urlParams.get('branch_id')) {
|
||||
window.uploadListFilters.client_branch_id = urlParams.get('client_branch_id') || urlParams.get('branch_id');
|
||||
}
|
||||
if (urlParams.get('policy_id') || urlParams.get('client_policy_id')) {
|
||||
window.uploadListFilters.policy_id = urlParams.get('policy_id') || urlParams.get('client_policy_id');
|
||||
}
|
||||
if (urlParams.get('client_id') || urlParams.get('client_branch_id') || urlParams.get('policy_id') || urlParams.get('event_type') || urlParams.get('start_date') || urlParams.get('end_date') || urlParams.get('insurer_or_tpa') || urlParams.get('action_type') || urlParams.get('tab_type')) {
|
||||
// Match legacy filter redirect: when any filter/tab param is present without dates, do not force 90-day default.
|
||||
if (!urlParams.get('start_date') && !urlParams.get('end_date') && urlParams.get('tab_type')) {
|
||||
window.uploadListFilters.use_default_date = '0';
|
||||
}
|
||||
}
|
||||
})();
|
||||
|
||||
nhanceListDataTableBeforeInit();
|
||||
window.fileListTableInstance = $('#file-list-table').DataTable(nhanceMergeListDataTableOptions({
|
||||
processing: true,
|
||||
serverSide: true,
|
||||
deferRender: true,
|
||||
searchDelay: 400,
|
||||
pageLength: 10,
|
||||
scrollX: false,
|
||||
scrollY: false,
|
||||
scrollCollapse: false,
|
||||
autoWidth: false,
|
||||
responsive: false,
|
||||
columns: (function() {
|
||||
var cols = [];
|
||||
for (var i = 0; i < <?= (int) $fl_col_count ?>; i++) {
|
||||
cols.push({ data: String(i), orderable: false });
|
||||
}
|
||||
return cols;
|
||||
})(),
|
||||
ajax: {
|
||||
url: '<?= base_url("employee/upload/file-list/datatable") ?>',
|
||||
type: 'POST',
|
||||
data: function(d) {
|
||||
return $.extend({}, d, window.uploadListFilters || {});
|
||||
}
|
||||
},
|
||||
dom: "<'row'<'col-sm-7'f><'col-sm-5 text-right'B>>" +
|
||||
"<'row'<'col-sm-12'tr>>" +
|
||||
"<'row align-items-center'<'col-5 text-start'i><'col-7 d-flex justify-content-end align-items-center'<'me-2'l>p>>",
|
||||
@ -748,14 +725,21 @@ $fl_col_width_px = nhance_dt_column_widths_px($fl_header_labels, $fl_col_max_len
|
||||
emptyTable: '<div class="text-center text-muted">No Data found</div>'
|
||||
},
|
||||
paging: true,
|
||||
ordering: false,
|
||||
columnDefs: [
|
||||
<?php for ($i = 0; $i < $fl_col_count; $i++) : ?>
|
||||
{ targets: <?= $i ?>, width: '<?= (int) $fl_col_width_px[$i] ?>px' },
|
||||
<?php endfor; ?>
|
||||
],
|
||||
initComplete: function () {
|
||||
$(this.api().table().container()).closest('.table-responsive').addClass('nh-dt-no-outer-scroll');
|
||||
},
|
||||
drawCallback: function() {
|
||||
$('[data-toggle="tooltip"]').tooltip({ container: 'body' });
|
||||
}
|
||||
}));
|
||||
nhanceListDataTableAfterInit();
|
||||
nhanceListDataTableBindAdjust(nhFileListTable);
|
||||
nhanceListDataTableBindAdjust(window.fileListTableInstance);
|
||||
|
||||
});
|
||||
|
||||
|
||||
@ -6,58 +6,77 @@ $hr_col_max_len = array_fill(0, $hr_col_count, 0);
|
||||
for ($i = 0; $i < $hr_col_count; $i++) {
|
||||
$hr_col_max_len[$i] = mb_strlen($hr_header_labels[$i]);
|
||||
}
|
||||
$fileList = $fileList ?? [];
|
||||
foreach ($fileList as $key => $file) {
|
||||
$hr_col_max_len[0] = max($hr_col_max_len[0], mb_strlen((string) ($key + 1)));
|
||||
$hr_col_max_len[1] = max($hr_col_max_len[1], mb_strlen((string) ($file['file_name'] ?? '')));
|
||||
$hr_col_max_len[2] = max($hr_col_max_len[2], mb_strlen((string) ($file['short_name'] ?? '')));
|
||||
$hr_col_max_len[3] = max($hr_col_max_len[3], mb_strlen((string) ($file['branch_name'] ?? '')));
|
||||
$hr_col_max_len[4] = max($hr_col_max_len[4], mb_strlen((string) ($file['policy_no'] ?? '')));
|
||||
$hr_col_max_len[5] = max($hr_col_max_len[5], mb_strlen((string) ($file['file_action'] ?? '')));
|
||||
$userTimePlain = change_date_format($file['created_at'] ?? '', 'Y-m-d H:i:s', 'd M Y h:i A')
|
||||
. ' by '
|
||||
. (string) ($file['first_name'] ?? '');
|
||||
$hr_col_max_len[6] = max($hr_col_max_len[6], mb_strlen($userTimePlain));
|
||||
$hr_col_max_len[7] = max($hr_col_max_len[7], mb_strlen((string) ($file['status'] ?? '')));
|
||||
$hr_col_max_len[8] = max($hr_col_max_len[8], 4);
|
||||
}
|
||||
$hr_col_max_len[1] = max($hr_col_max_len[1], 28);
|
||||
$hr_col_max_len[2] = max($hr_col_max_len[2], 12);
|
||||
$hr_col_max_len[3] = max($hr_col_max_len[3], 14);
|
||||
$hr_col_max_len[4] = max($hr_col_max_len[4], 16);
|
||||
$hr_col_max_len[5] = max($hr_col_max_len[5], 14);
|
||||
$hr_col_max_len[6] = max($hr_col_max_len[6], 28);
|
||||
$hr_col_min_px = [48, 120, 88, 96, 120, 88, 200, 96, 52];
|
||||
$hr_col_max_px = [64, 480, 240, 240, 360, 200, 520, 200, 72];
|
||||
$hr_col_width_px = nhance_dt_column_widths_px($hr_header_labels, $hr_col_max_len, $hr_col_min_px, $hr_col_max_px);
|
||||
?>
|
||||
<style>
|
||||
.table th,
|
||||
.table td {
|
||||
padding: 8px;
|
||||
}
|
||||
table.dataTable tbody td {
|
||||
padding: 4px 4px !important;
|
||||
}
|
||||
.select2-container .select2-selection--multiple .select2-selection__choice {
|
||||
padding: 5px 7px 5px 0 !important;
|
||||
color: #000000;
|
||||
}
|
||||
.dataTables_length label {height: 21px !important;}
|
||||
|
||||
/* Compact table + buttons — match file_list.php / Data From Client */
|
||||
#hr_tickets_table tbody td {
|
||||
padding: 6px 12px !important;
|
||||
font-size: 13px;
|
||||
line-height: 1.25;
|
||||
}
|
||||
#hr_tickets_table_wrapper .dataTables_scrollHead table thead th,
|
||||
#hr_tickets_table thead th {
|
||||
padding: 6px 2.35rem 6px 12px !important;
|
||||
font-size: 13px;
|
||||
line-height: 1.25;
|
||||
}
|
||||
#hr_tickets_table .font-12 {
|
||||
font-size: 12px;
|
||||
}
|
||||
#hr_tickets_table .dropdown-toggle.btn-sm {
|
||||
padding: 4px 9px !important;
|
||||
font-size: 13px;
|
||||
line-height: 1.2;
|
||||
}
|
||||
#hr_tickets_table_wrapper .dt-buttons .btn {
|
||||
padding: 6px 13px !important;
|
||||
font-size: 13px;
|
||||
}
|
||||
#hr_tickets_table_wrapper .dt-buttons .btn .btn-custom {
|
||||
font-size: 13px;
|
||||
}
|
||||
#hr_tickets_table {
|
||||
width: 100% !important;
|
||||
/* Tighter row gap than global card spacing (header.php uses 8px) */
|
||||
border-spacing: 0 4px !important;
|
||||
}
|
||||
#hr_tickets_table thead th {
|
||||
white-space: nowrap;
|
||||
vertical-align: middle;
|
||||
}
|
||||
#hr_tickets_table_wrapper .dataTables_filter {
|
||||
margin-bottom: 12px;
|
||||
}
|
||||
#hr_tickets_table_wrapper .datatable-search-wrapper {
|
||||
width: auto !important;
|
||||
}
|
||||
#hr_tickets_table_wrapper .dataTables_filter {
|
||||
margin-bottom: 0;
|
||||
}
|
||||
#hr_tickets_table_wrapper .dataTables_filter input {
|
||||
width: 220px !important;
|
||||
background: #F0F0F0;
|
||||
border: none;
|
||||
border-radius: 8px;
|
||||
padding-right: 34px !important;
|
||||
}
|
||||
#hr_tickets_table_wrapper .row.align-items-center {
|
||||
flex-wrap: nowrap;
|
||||
}
|
||||
#hr_tickets_table_wrapper .dataTables_info,
|
||||
#hr_tickets_table_wrapper .dataTables_length,
|
||||
#hr_tickets_table_wrapper .dataTables_paginate {
|
||||
white-space: nowrap;
|
||||
}
|
||||
#hr_tickets_table_wrapper .datatable-search-icon,
|
||||
#hr_tickets_table_wrapper .datatable-clear-icon {
|
||||
right: 11px !important;
|
||||
@ -67,10 +86,6 @@ $hr_col_width_px = nhance_dt_column_widths_px($hr_header_labels, $hr_col_max_len
|
||||
justify-content: flex-end;
|
||||
align-items: center;
|
||||
}
|
||||
#hr_tickets_table_wrapper .dt-buttons .app-btn-secondary,
|
||||
#hr_tickets_table_wrapper .dt-buttons .btn-secondary {
|
||||
border-radius: 10px;
|
||||
}
|
||||
#hr_tickets_table_wrapper .dataTables_scrollHeadInner,
|
||||
#hr_tickets_table_wrapper .dataTables_scrollHeadInner table,
|
||||
#hr_tickets_table_wrapper .dataTables_scrollBody table {
|
||||
@ -79,6 +94,16 @@ $hr_col_width_px = nhance_dt_column_widths_px($hr_header_labels, $hr_col_max_len
|
||||
#hr_tickets_table tbody tr:hover {
|
||||
background-color: #e0e0e0;
|
||||
}
|
||||
#hr-file-list-page .card-body > .table-responsive:not(:has(.dataTables_scrollBody)) {
|
||||
overflow-x: auto !important;
|
||||
-webkit-overflow-scrolling: touch;
|
||||
max-width: 100%;
|
||||
}
|
||||
#hr-file-list-page .card-body > .table-responsive:has(.dataTables_scrollBody) {
|
||||
overflow-x: visible !important;
|
||||
-webkit-overflow-scrolling: auto;
|
||||
max-width: 100%;
|
||||
}
|
||||
|
||||
<?php for ($i = 0; $i < $hr_col_count; $i++) : ?>
|
||||
#hr_tickets_table_wrapper .dataTables_scrollHead table thead th:nth-child(<?= $i + 1 ?>),
|
||||
@ -216,7 +241,7 @@ $hr_col_width_px = nhance_dt_column_widths_px($hr_header_labels, $hr_col_max_len
|
||||
|
||||
<!-- end page title -->
|
||||
<div class="row" id="hr_file_list">
|
||||
<div class="col-12">
|
||||
<div class="col-12" id="hr-file-list-page">
|
||||
<div class="card">
|
||||
<div class="card-body">
|
||||
<div class="row" style="padding-bottom: 10px;">
|
||||
@ -230,38 +255,19 @@ $hr_col_width_px = nhance_dt_column_widths_px($hr_header_labels, $hr_col_max_len
|
||||
id="hr_tickets_table">
|
||||
<thead class="bg-light">
|
||||
<tr>
|
||||
<th class="font-weight-medium">S.No </th>
|
||||
<th class="font-weight-medium">File name </th>
|
||||
<th class="font-weight-medium">Client </th>
|
||||
<th class="font-weight-medium">Client Branch </th>
|
||||
<th class="font-weight-medium">Policy </th>
|
||||
<th class="font-weight-medium">Event </th>
|
||||
<th class="font-weight-medium">User/Time </th>
|
||||
<th class="font-weight-medium">Status </th>
|
||||
<th class="font-weight-medium">Action </th>
|
||||
<th class="font-weight-medium"><div class="column-header">S.No</div></th>
|
||||
<th class="font-weight-medium"><div class="column-header">File name</div></th>
|
||||
<th class="font-weight-medium"><div class="column-header">Client</div></th>
|
||||
<th class="font-weight-medium"><div class="column-header">Client Branch</div></th>
|
||||
<th class="font-weight-medium"><div class="column-header">Policy</div></th>
|
||||
<th class="font-weight-medium"><div class="column-header">Event</div></th>
|
||||
<th class="font-weight-medium"><div class="column-header">User/Time</div></th>
|
||||
<th class="font-weight-medium"><div class="column-header">Status</div></th>
|
||||
<th class="font-weight-medium"><div class="column-header">Action</div></th>
|
||||
</tr>
|
||||
</thead>
|
||||
|
||||
<tbody class="font-12">
|
||||
<?php
|
||||
if (isset($HRfileList)) { foreach ($fileList as $key => $file) { ?>
|
||||
|
||||
<tr>
|
||||
<td><b><?php echo ($key + 1) ?></b></td>
|
||||
<td title="<?php echo $file['file_name'] ?>">
|
||||
<?php echo $file['file_name']?>
|
||||
</td>
|
||||
<td><?php echo $file['short_name'] ?></td>
|
||||
<td><?php echo $file['branch_name'] ?></td>
|
||||
<td><?php echo $file['policy_no'] ?></td>
|
||||
<td><?php echo $file['file_action'] ?></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['first_name'] . '</strong>' ?></td>
|
||||
<td><?php echo $file['status']; ?> </td>
|
||||
<td> </td>
|
||||
</tr>
|
||||
<?php }
|
||||
} ?>
|
||||
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
@ -334,81 +340,21 @@ $hr_col_width_px = nhance_dt_column_widths_px($hr_header_labels, $hr_col_max_len
|
||||
$("#policy2").select2();
|
||||
$("#client_branch_id2").select2();
|
||||
|
||||
// Form submit event
|
||||
// Form submit event — reload server-side DataTable with HR form filters
|
||||
$("#hr_file_upload_search").on("submit", function (e) {
|
||||
e.preventDefault();
|
||||
|
||||
e.preventDefault(); // stop normal form submit
|
||||
window.hrFileListFilters = window.hrFileListFilters || {};
|
||||
window.hrFileListFilters.client_id = $('#client2').val() || '';
|
||||
window.hrFileListFilters.client_branch_id = $('#client_branch_id2').val() || '';
|
||||
window.hrFileListFilters.policy_id = $('#policy2').val() || '';
|
||||
window.hrFileListFilters.file_action = $('#hr_file_upload_search #event_type').val() || '';
|
||||
window.hrFileListFilters.event_type = $('#hr_file_upload_search #event_type').val() || '';
|
||||
window.hrFileListFilters.use_default_date = '0';
|
||||
|
||||
let formData = $(this).serialize(); // serialize form with csrf
|
||||
var baseurl = `<?= base_url() ?>`;
|
||||
$.ajax({
|
||||
url: "<?= base_url('hrFileList') ?>",
|
||||
type: "POST",
|
||||
data: formData,
|
||||
dataType: "json",
|
||||
beforeSend: function () {
|
||||
// optional loader
|
||||
$("#hr_tickets_table tbody").html(
|
||||
"<tr><td colspan='9' class='text-center'>Loading...</td></tr>"
|
||||
);
|
||||
},
|
||||
success: function (res) {
|
||||
let tbody = "";
|
||||
|
||||
if (res.status === "success" && res.data.length > 0) {
|
||||
$.each(res.data, function (index, file) {
|
||||
tbody += `
|
||||
<tr>
|
||||
<td><b>${index + 1}</b></td>
|
||||
<td id="${file.id}" class="reload truncate" title="${file.file_name}">${file.file_name}</td>
|
||||
<td>${file.short_name ?? ""}</td>
|
||||
<td>${file.branch_name ?? ""}</td>
|
||||
<td>${file.policy_no ?? ""}</td>
|
||||
<td>${formatTextToCamelCase(file.file_action) ?? ""}</td>
|
||||
<td>${file.created_at} by <strong>${file.first_name ?? ""}</strong></td>
|
||||
<td>${file.status}</td>
|
||||
<td>
|
||||
|
||||
<div class="btn-group dropdown">
|
||||
<a href="javascript: void(0);" class="dropdown-toggle arrow-none btn btn-light btn-sm"
|
||||
data-toggle="dropdown" aria-expanded="false"><i class="mdi mdi-dots-horizontal"></i></a>
|
||||
|
||||
<div class="dropdown-menu dropdown-menu-right">
|
||||
<a href="${baseurl}/hrFileDownload?id=${file.id}" class="dropdown-item" style="color: #000;" aria-hidden="true" target="_blank" ><i class="mdi mdi-download mr-2 text-muted font-18 vertical-middle"></i>Download</a>
|
||||
<a class="dropdown-item" onclick="uploadEndorsementFile(${file.client_id}, ${file.client_branch_id}, ${file.policy_id}, ${file.id}, '${file.file_action}')" style="color: #000;" aria-hidden="true"><i class="mdi mdi-upload mr-2 text-muted font-18 vertical-middle"></i>Initiate Endorsement</a>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
</td>
|
||||
</tr>
|
||||
`;
|
||||
});
|
||||
} else {
|
||||
tbody = `<tr><td colspan="9" class="text-center">No records found</td></tr>`;
|
||||
}
|
||||
|
||||
if (window.hrFileTableInstance) {
|
||||
window.hrFileTableInstance.clear();
|
||||
$("#hr_tickets_table tbody").html(tbody);
|
||||
window.hrFileTableInstance.rows.add($("#hr_tickets_table tbody tr")).draw();
|
||||
window.hrFileTableInstance.columns.adjust().draw(false);
|
||||
} else {
|
||||
$("#hr_tickets_table tbody").html(tbody);
|
||||
}
|
||||
},
|
||||
error: function (xhr, status, error) {
|
||||
console.error("Error:", error);
|
||||
const errorRow = `<tr><td colspan="9" class="text-center text-danger">Something went wrong</td></tr>`;
|
||||
if (window.hrFileTableInstance) {
|
||||
window.hrFileTableInstance.clear();
|
||||
$("#hr_tickets_table tbody").html(errorRow);
|
||||
window.hrFileTableInstance.rows.add($("#hr_tickets_table tbody tr")).draw();
|
||||
window.hrFileTableInstance.columns.adjust().draw(false);
|
||||
} else {
|
||||
$("#hr_tickets_table tbody").html(errorRow);
|
||||
}
|
||||
},
|
||||
});
|
||||
if (window.hrFileTableInstance) {
|
||||
window.hrFileTableInstance.ajax.reload();
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
@ -499,24 +445,59 @@ $hr_col_width_px = nhance_dt_column_widths_px($hr_header_labels, $hr_col_max_len
|
||||
if (window.hrFileTableInstance) {
|
||||
return;
|
||||
}
|
||||
|
||||
window.hrFileListFilters = window.hrFileListFilters || {
|
||||
client_id: '',
|
||||
client_branch_id: '',
|
||||
policy_id: '',
|
||||
file_action: '',
|
||||
event_type: '',
|
||||
use_default_date: '1'
|
||||
};
|
||||
|
||||
nhanceListDataTableBeforeInit();
|
||||
window.hrFileTableInstance = $('#hr_tickets_table').DataTable(nhanceMergeListDataTableOptions({
|
||||
// dom: "<'row'<'col-12 d-flex justify-content-between align-items-center'<'datatable-search dataTables_filter'f><'datatable-buttons dt-buttons'B>>>" +
|
||||
// "<'row'<'col-sm-12'tr>>" +
|
||||
// "<'row'<'col-sm-5'i><'col-sm-7'p>>",
|
||||
dom: "<'row'<'col-12 d-flex justify-content-between align-items-center'<'datatable-search dataTables_filter'f><'datatable-buttons dt-buttons'B>>>" +
|
||||
processing: true,
|
||||
serverSide: true,
|
||||
deferRender: true,
|
||||
searchDelay: 400,
|
||||
pageLength: 10,
|
||||
scrollX: false,
|
||||
scrollY: false,
|
||||
scrollCollapse: false,
|
||||
autoWidth: false,
|
||||
responsive: false,
|
||||
columns: (function() {
|
||||
var cols = [];
|
||||
for (var i = 0; i < <?= (int) $hr_col_count ?>; i++) {
|
||||
cols.push({ data: String(i), orderable: false });
|
||||
}
|
||||
return cols;
|
||||
})(),
|
||||
ajax: {
|
||||
url: '<?= base_url("employee/upload/hr-file-list/datatable") ?>',
|
||||
type: 'POST',
|
||||
data: function(d) {
|
||||
return $.extend({}, d, window.hrFileListFilters || {}, {
|
||||
// Also allow sidebar filters to apply when present
|
||||
start_date: (window.uploadListFilters && window.uploadListFilters.start_date) || '',
|
||||
end_date: (window.uploadListFilters && window.uploadListFilters.end_date) || ''
|
||||
});
|
||||
}
|
||||
},
|
||||
dom: "<'row'<'col-sm-7'f><'col-sm-5 text-right'B>>" +
|
||||
"<'row'<'col-sm-12'tr>>" +
|
||||
"<'row align-items-center'<'col-5 text-start'i><'col-7 d-flex justify-content-end align-items-center'<'me-2'l>p>>",
|
||||
lengthMenu: [[10, 20, 50, 100], [10, 20, 50, 100]],
|
||||
buttons: [{
|
||||
extend: 'collection',
|
||||
text: '<span class=" btn-custom"> Export </span><i class="mdi mdi-menu-down"></i>',
|
||||
className: 'btn app-btn-secondary ',
|
||||
className: 'btn app-btn-secondary mr-2',
|
||||
buttons: [
|
||||
{
|
||||
extend: 'csv',
|
||||
text: '<i class="mdi mdi-file-delimited " ></i><span class=" btn-custom"> CSV </span>',
|
||||
title: 'Employee-Upload-List',
|
||||
title: 'HR-Uploaded-Files',
|
||||
className: 'app-btn-primary ',
|
||||
exportOptions: {
|
||||
columns: ':not(:last-child)'
|
||||
@ -544,16 +525,12 @@ $hr_col_width_px = nhance_dt_column_widths_px($hr_header_labels, $hr_col_max_len
|
||||
{ targets: <?= $i ?>, width: '<?= (int) $hr_col_width_px[$i] ?>px' },
|
||||
<?php endfor; ?>
|
||||
],
|
||||
initComplete: function () {
|
||||
$(this.api().table().container()).closest('.table-responsive').addClass('nh-dt-no-outer-scroll');
|
||||
},
|
||||
}));
|
||||
nhanceListDataTableAfterInit();
|
||||
nhanceListDataTableBindAdjust(window.hrFileTableInstance);
|
||||
$('.dataTables_filter input').css({
|
||||
'background': '#F0F0F0',
|
||||
'border': 'none',
|
||||
'border-radius': '8px',
|
||||
'padding-right': '34px'
|
||||
});
|
||||
|
||||
setTimeout(fixHrUploadTableHeaderWidth, 0);
|
||||
});
|
||||
|
||||
|
||||
@ -114,6 +114,31 @@ table.dataTable thead th {
|
||||
var policy_list = ''; // local variable for storing the client policy list
|
||||
var branch_policy = '';
|
||||
|
||||
window.uploadListFilters = window.uploadListFilters || {
|
||||
client_id: '',
|
||||
client_branch_id: '',
|
||||
policy_id: '',
|
||||
event_type: '',
|
||||
insurer_or_tpa: '',
|
||||
action_type: '',
|
||||
start_date: '',
|
||||
end_date: '',
|
||||
use_default_date: '1'
|
||||
};
|
||||
|
||||
function reloadActiveUploadListTable() {
|
||||
var tabType = String($('#tab_type').val() || '1');
|
||||
if ((tabType === '2' || tabType === 'kyc_tab') && window.batchListTableInstance) {
|
||||
window.batchListTableInstance.ajax.reload();
|
||||
} else if ((tabType === '3' || tabType === 'hr_tab') && window.hrFileTableInstance) {
|
||||
window.hrFileTableInstance.ajax.reload();
|
||||
} else if (window.fileListTableInstance) {
|
||||
window.fileListTableInstance.ajax.reload();
|
||||
} else if (window.batchListTableInstance) {
|
||||
window.batchListTableInstance.ajax.reload();
|
||||
}
|
||||
}
|
||||
|
||||
$(document).ready(function() {
|
||||
getClientAndBranchAndPolicy();
|
||||
})
|
||||
@ -473,6 +498,9 @@ table.dataTable thead th {
|
||||
if(activeTabId == 'kyc_tab'){
|
||||
$('#tab_type').val(2)
|
||||
$('.hide_filter_input').show();
|
||||
}else if(activeTabId == 'hr_tab'){
|
||||
$('#tab_type').val(3)
|
||||
$('.hide_filter_input').hide();
|
||||
}else{
|
||||
$('#tab_type').val(1)
|
||||
$('.hide_filter_input').hide();
|
||||
@ -493,18 +521,28 @@ table.dataTable thead th {
|
||||
var policy_id = $('#policy_id_for_filter').val();
|
||||
var event_type = $('#event_type_for_filter').val();
|
||||
var insurer_or_tpa = $('#insurer_or_tpa_for_filter').val();
|
||||
var action_type = $('#action_type').val(); // This ID was correct
|
||||
var action_type = $('#action_type_for_filter').val() || $('#action_type').val();
|
||||
|
||||
// Note: If you have date pickers elsewhere, keep these.
|
||||
// Otherwise, ensure they exist in your UI.
|
||||
var start_date = $('#startDate').val() || '';
|
||||
var end_date = $('#endDate').val() || '';
|
||||
|
||||
// 3. Construct the Query Parameters object
|
||||
window.uploadListFilters = window.uploadListFilters || {};
|
||||
window.uploadListFilters.client_id = client_id || '';
|
||||
window.uploadListFilters.client_branch_id = (branch_id && branch_id !== '0') ? branch_id : '';
|
||||
window.uploadListFilters.policy_id = (policy_id && policy_id !== '0') ? policy_id : '';
|
||||
window.uploadListFilters.event_type = event_type || '';
|
||||
window.uploadListFilters.insurer_or_tpa = insurer_or_tpa || '';
|
||||
window.uploadListFilters.action_type = action_type || '';
|
||||
window.uploadListFilters.start_date = start_date;
|
||||
window.uploadListFilters.end_date = end_date;
|
||||
// Legacy: when filters are applied without dates, do not force 90-day default.
|
||||
window.uploadListFilters.use_default_date = (start_date && end_date) ? '1' : '0';
|
||||
|
||||
var queryParams = {
|
||||
tab_type: tab_type,
|
||||
client_id: client_id,
|
||||
branch_id: branch_id,
|
||||
client_branch_id: branch_id,
|
||||
policy_id: policy_id,
|
||||
event_type: event_type,
|
||||
insurer_or_tpa: insurer_or_tpa,
|
||||
@ -513,26 +551,64 @@ table.dataTable thead th {
|
||||
end_date: end_date
|
||||
};
|
||||
|
||||
console.log("Filters applied:", queryParams);
|
||||
|
||||
// 4. Build the Query String and Redirect
|
||||
const queryString = new URLSearchParams(queryParams).toString();
|
||||
const baseUrl = $('#get_base_url').attr('href');
|
||||
console.log("queryString to:", queryString);
|
||||
console.log("baseUrl to:", baseUrl);
|
||||
|
||||
const apiURL = baseUrl + "?" + queryString;
|
||||
|
||||
console.log("Redirecting to:", apiURL);
|
||||
window.location.href = apiURL;
|
||||
if (window.history && window.history.replaceState) {
|
||||
window.history.replaceState({}, '', baseUrl + '?' + queryString);
|
||||
}
|
||||
|
||||
$('.hide-clear-filter').show();
|
||||
reloadActiveUploadListTable();
|
||||
}
|
||||
|
||||
function clearFilterData(){
|
||||
|
||||
const url = $('#get_base_url').attr('href');
|
||||
console.log("url to:", url);
|
||||
window.uploadListFilters = {
|
||||
client_id: '',
|
||||
client_branch_id: '',
|
||||
policy_id: '',
|
||||
event_type: '',
|
||||
insurer_or_tpa: '',
|
||||
action_type: '',
|
||||
start_date: '',
|
||||
end_date: '',
|
||||
use_default_date: '1'
|
||||
};
|
||||
|
||||
window.location.href = url;
|
||||
window.hrFileListFilters = {
|
||||
client_id: '',
|
||||
client_branch_id: '',
|
||||
policy_id: '',
|
||||
file_action: '',
|
||||
event_type: '',
|
||||
use_default_date: '1'
|
||||
};
|
||||
|
||||
$('#client_id_for_filter').val('').trigger('change');
|
||||
$('#client_branch_id_for_filter').val('0').trigger('change');
|
||||
$('#policy_id_for_filter').val('').trigger('change');
|
||||
$('#event_type_for_filter').val('');
|
||||
$('#insurer_or_tpa_for_filter').val('');
|
||||
$('#action_type_for_filter').val('');
|
||||
$('#startDate').val('');
|
||||
$('#endDate').val('');
|
||||
$('#reportrange span').html('Select Date Range');
|
||||
|
||||
const url = $('#get_base_url').attr('href');
|
||||
if (window.history && window.history.replaceState) {
|
||||
window.history.replaceState({}, '', url);
|
||||
}
|
||||
$('.hide-clear-filter').hide();
|
||||
reloadActiveUploadListTable();
|
||||
if (window.fileListTableInstance) {
|
||||
window.fileListTableInstance.ajax.reload();
|
||||
}
|
||||
if (window.batchListTableInstance) {
|
||||
window.batchListTableInstance.ajax.reload();
|
||||
}
|
||||
if (window.hrFileTableInstance) {
|
||||
window.hrFileTableInstance.ajax.reload();
|
||||
}
|
||||
}
|
||||
|
||||
$(function() {
|
||||
|
||||
Loading…
Reference in New Issue
Block a user