diff --git a/app/Controllers/DashboardController.php b/app/Controllers/DashboardController.php index 97897d25..1378abbf 100644 --- a/app/Controllers/DashboardController.php +++ b/app/Controllers/DashboardController.php @@ -22,7 +22,7 @@ class DashboardController extends AdminController public function __construct() { $this->messageModel = new MessageModel(); - $this->userMessageModel = new UserMessageModel(); + $this->userMessageModel = new UserMessageModel(); } public function dashboard() diff --git a/app/Controllers/EmpDataServiceController.php b/app/Controllers/EmpDataServiceController.php index d1e9ebda..b0814d11 100644 --- a/app/Controllers/EmpDataServiceController.php +++ b/app/Controllers/EmpDataServiceController.php @@ -644,7 +644,7 @@ class EmpDataServiceController extends BaseController $this->batchFileModel->where('id', $file_id)->set($data)->update(); $this->myLogger->logme('error', 'importInceptionFileValidation TPAID already updated'); - $file_data = $this->getDataByFileId($file_id, 'Failure'); + $file_data = $this->getDataByFileId($file_id, 'failure'); $this->setPullNotification($file_data); return 'The list of employees provided has already been updated with the TPA ID, or this is not the correct file'; @@ -658,7 +658,7 @@ class EmpDataServiceController extends BaseController $this->batchFileModel->where('id', $file_id)->set($data)->update(); $this->myLogger->logme('error', 'importInceptionFileValidation UHID already updated'); - $file_data = $this->getDataByFileId($file_id, 'Failure'); + $file_data = $this->getDataByFileId($file_id, 'failure'); $this->setPullNotification($file_data); return 'The list of employees provided has already been updated with the UHID, or this is not the correct file'; @@ -697,7 +697,7 @@ class EmpDataServiceController extends BaseController $this->batchFileModel->where('id', $file_id)->set($data)->update(); $this->myLogger->logme('error', 'importInceptionFileValidation excel file count ( {excel} ) exceeds db count ( {db} )', ['db' => $emp_data_count, 'excel' => $excel_data_count]); - $file_data = $this->getDataByFileId($file_id, 'Failure'); + $file_data = $this->getDataByFileId($file_id, 'failure'); $this->setPullNotification($file_data); return 'The Excel record count exceeds the DB record count. excel file count : ' . $excel_data_count . 'db count : ' . $emp_data_count; @@ -892,14 +892,14 @@ class EmpDataServiceController extends BaseController if ($insurer_or_tpa == 'tpa') { - $file_data = $this->getDataByFileId($file_id, 'Failure'); + $file_data = $this->getDataByFileId($file_id, 'failure'); $this->setPullNotification($file_data); return 'The TPA ID column is either partially or entirely empty.'; } else if ($insurer_or_tpa == 'insurer') { - $file_data = $this->getDataByFileId($file_id, 'Failure'); + $file_data = $this->getDataByFileId($file_id, 'failure'); $this->setPullNotification($file_data); return 'The UHID column is either partially or entirely empty.'; @@ -967,7 +967,7 @@ class EmpDataServiceController extends BaseController $this->batchFileModel->where('id', $file_id)->set($data)->update(); $this->myLogger->logme('error', 'importInceptionUpdateTPAandUHID the Physical file not found - file id : {data}', ['data' => $file_id]); - $file_data = $this->getDataByFileId($file_id, 'Failure'); + $file_data = $this->getDataByFileId($file_id, 'failure'); $this->setPullNotification($file_data); return 'importInceptionUpdateTPAandUHID the Physical file not found'; // Return error code if file not found @@ -1114,7 +1114,7 @@ class EmpDataServiceController extends BaseController } - $file_data = $this->getDataByFileId($file_id); + $file_data = $this->getDataByFileId($file_id, 'success'); $this->setPullNotification($file_data); return 'Import Inception Updated '. $status_val . '- Updated Count : ' . $emp_count; @@ -2215,37 +2215,56 @@ class EmpDataServiceController extends BaseController } - public function getDataByFileId($file_id, $status = 'Success'){ + public function getDataByFileId($file_id, $status = 'success'){ $data = $this->batchFileModel - ->select('batch_files.*, clients.client_name, policies.name as policy_name') + ->select('batch_files.*, clients.client_name, clients.short_name, policies.name as policy_name') ->join('clients', 'clients.id = batch_files.client_id') ->join('client_policy', 'client_policy.id = batch_files.client_policy_id') ->join('policies', 'policies.id = client_policy.policy_id') ->where('batch_files.id', $file_id) ->first(); - $msg_txt = 'Client : '. $data['client_name'] . ', Client policy : '. $data['policy_name'] . ', Event : ' . $data['event_type'] . ', Action : ' .$data['actions'] . ', Insure or TPA : ' . $data['insurer_or_tpa'] . ' Status : ' . $status; + + if($status == 'success'){ + + $msg_txt = $data['short_name'] . ' - ' . $data['policy_name'] . ' - ' . $data['event_type'] . ' - ' . $data['actions'] . ' - ' . $data['insurer_or_tpa']; + $msg_title = 'File Upload Success'; + + }else if ($status == 'failure'){ + + $msg_txt = $data['short_name'] . ' - ' . $data['policy_name'] . ' - ' . $data['event_type'] . ' - ' . $data['actions'] . ' - ' . $data['insurer_or_tpa']; + $msg_title = 'File Upload Failure'; + } + $user_id = $data['created_by']; $url = 'employee/upload#KYC-DOC-tab'; - return ['msg_txt' => $msg_txt, 'user_id' => $user_id, 'url' => $url]; + return ['msg_txt' => $msg_txt, 'user_id' => $user_id, 'url' => $url, 'status' => $status, 'title' => $msg_title]; } public function setPullNotification($data){ + + $array = ['message_text' => $data['msg_txt'], 'action_url' => $data['url'], 'msg_status' => $data['status'], 'msg_title' => $data['title']]; + $jsonEncodeData = json_encode($array); + $msg_data = [ - 'message_text' => $data['msg_txt'], + + 'message_text' => $jsonEncodeData, 'user_id' => $data['user_id'], 'role_id' => NULL, 'team_id' => NULL, 'message_type' => '1to1', - 'action_url' => $data['url'], ]; + $this->messageModel->insert($msg_data); } + + + } diff --git a/app/Models/MessageModel.php b/app/Models/MessageModel.php index bf9bd03d..eac21cbe 100644 --- a/app/Models/MessageModel.php +++ b/app/Models/MessageModel.php @@ -22,6 +22,7 @@ class MessageModel extends Model 'message_type', 'created_at', 'action_url', + 'msg_status', ]; diff --git a/app/Views/client_policy.php b/app/Views/client_policy.php index d26b3f20..e66f59b0 100644 --- a/app/Views/client_policy.php +++ b/app/Views/client_policy.php @@ -54,7 +54,7 @@