From 79854eccff484dbe1f3823b8355f98cf11f09013 Mon Sep 17 00:00:00 2001 From: "venkatesh.r" Date: Thu, 16 May 2024 16:01:43 +0530 Subject: [PATCH] FEAT_PULL_NOTIFICATION : RV --- app/Config/Routes.php | 4 + app/Controllers/DashboardController.php | 31 +- app/Controllers/EmpDataServiceController.php | 79 ++- app/Controllers/EmployeeController.php | 1 + app/Models/MessageModel.php | 76 +++ app/Models/UserMessageModel.php | 69 +++ app/Views/import_export.php | 53 +- app/Views/layout/footer.php | 611 ++++++------------- app/Views/layout/header.php | 102 +--- app/Views/tpa_basic_info.php | 13 +- writable/e_card_template/hcl.html | 118 ++++ writable/e_card_template/tt786.html | 0 12 files changed, 607 insertions(+), 550 deletions(-) create mode 100644 app/Models/MessageModel.php create mode 100644 app/Models/UserMessageModel.php create mode 100644 writable/e_card_template/hcl.html create mode 100644 writable/e_card_template/tt786.html diff --git a/app/Config/Routes.php b/app/Config/Routes.php index c757962c..c26c0863 100644 --- a/app/Config/Routes.php +++ b/app/Config/Routes.php @@ -23,6 +23,10 @@ $routes->get('download-e-card/(:segment)', 'EmployeeController::generateIDCardFo $routes->get('download-kyc-docs/(:segment)', 'ClientController::downloadKYCDocument/$1'); +$routes->get('get-notification', 'DashboardController::getDashboardNotifications'); +$routes->get('acknowledge-notification/(:segment)', 'DashboardController::acknowledgeMessage/$1'); + + $routes->group("/user", ["filter" => "authMVC"], function ($routes) { $routes->post("create", "UserController::create"); diff --git a/app/Controllers/DashboardController.php b/app/Controllers/DashboardController.php index 1a370981..97897d25 100644 --- a/app/Controllers/DashboardController.php +++ b/app/Controllers/DashboardController.php @@ -7,12 +7,22 @@ use CodeIgniter\HTTP\RequestInterface; use CodeIgniter\HTTP\ResponseInterface; use Psr\Log\LoggerInterface; +use CodeIgniter\API\ResponseTrait; + +use App\Models\MessageModel; +use App\Models\UserMessageModel; + class DashboardController extends AdminController { + use ResponseTrait; + protected $messageModel; + protected $userMessageModel; + public function __construct() { - + $this->messageModel = new MessageModel(); + $this->userMessageModel = new UserMessageModel(); } public function dashboard() @@ -22,11 +32,26 @@ class DashboardController extends AdminController echo view('layout/footer'); } - public function dashboardNotifications() + public function getDashboardNotifications() { //pull notofications to dashboard especially for file upload cases + $userId = get_session_userid(); + $roleId = 5; + $teamId = 1; + + $messages = $this->messageModel->getMessagesForUser($userId, $roleId, $teamId); + + return $this->respond($messages); + } + + public function acknowledgeMessage($messageId) + { + $userId = get_session_userid(); + + $this->userMessageModel->markAsRead($userId, $messageId); + + return $this->respond(['status' => 'success']); } - } diff --git a/app/Controllers/EmpDataServiceController.php b/app/Controllers/EmpDataServiceController.php index 826c8a6b..220f6cde 100644 --- a/app/Controllers/EmpDataServiceController.php +++ b/app/Controllers/EmpDataServiceController.php @@ -22,6 +22,8 @@ use App\Models\BatchFileModel; use App\Models\EmpEndorsementModel; use App\Models\ClientDepositModel; use App\Models\NotificationModel; +use App\Models\MessageModel; +use App\Models\UserMessageModel; use App\Controllers\Jobs; use App\Controllers\JobWorker; @@ -48,6 +50,8 @@ class EmpDataServiceController extends BaseController protected $empEndorsementModel; protected $clientDepositModel; protected $notificationModel; + protected $messageModel; + protected $userMessageModel; public function __construct() { @@ -64,6 +68,8 @@ class EmpDataServiceController extends BaseController $this->empEndorsementModel = new EmpEndorsementModel(); $this->clientDepositModel = new ClientDepositModel(); $this->notificationModel = new NotificationModel(); + $this->messageModel = new MessageModel(); + $this->userMessageModel = new UserMessageModel(); } @@ -638,7 +644,10 @@ class EmpDataServiceController extends BaseController $this->batchFileModel->where('id', $file_id)->set($data)->update(); $this->myLogger->logme('error', 'importInceptionFileValidation TPAID already updated'); - return 3; + $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'; } else if ($insurer_or_tpa == 'insurer') { @@ -649,7 +658,10 @@ class EmpDataServiceController extends BaseController $this->batchFileModel->where('id', $file_id)->set($data)->update(); $this->myLogger->logme('error', 'importInceptionFileValidation UHID already updated'); - return 5; + $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'; } $this->myLogger->logme('error', 'importInceptionFileValidation UHID or TPAID already updated or the uploadedfile is not correct'); @@ -685,7 +697,10 @@ 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]); - return 6; + $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; } @@ -877,11 +892,17 @@ class EmpDataServiceController extends BaseController if ($insurer_or_tpa == 'tpa') { - return 2; + $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') { - return 4; + $file_data = $this->getDataByFileId($file_id, 'Failure'); + $this->setPullNotification($file_data); + + return 'The UHID column is either partially or entirely empty.'; } } @@ -923,6 +944,7 @@ class EmpDataServiceController extends BaseController $job_details = new Jobs(); $r = Jobs::addJob(['job_name' => 'importInceptionUpdateTPAandUHID','payload' => ['file_id' => $file_id]]); + // $this->importInceptionUpdateTPAandUHID(['file_id' => $file_id]); } @@ -945,7 +967,10 @@ 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]); - return 0; // Return error code if file not found + $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 } $client_id = $file['client_id']; @@ -1051,6 +1076,7 @@ class EmpDataServiceController extends BaseController $this->myLogger->logme('error', 'importInceptionUpdateTPAandUHID total amount for cash deposite : {data}', ['data'=> $totals]); + if ($file['insurer_or_tpa'] == 'tpa') { $this->myLogger->logme('error', 'importInceptionUpdateTPAandUHID set cashDepositCalculationForInception and sendMailForDownloadingECard in JOB QUEUE'); @@ -1086,10 +1112,12 @@ class EmpDataServiceController extends BaseController // $this->cashDepositCalculationForInception($depositeData); // $this->sendMailForDownloadingECard($empty_emp_tpa_uh_ids); - } - return 1; + $file_data = $this->getDataByFileId($file_id); + $this->setPullNotification($file_data); + + return 'Import Inception Updated '. $status_val . '- Updated Count : ' . $emp_count; } @@ -2173,5 +2201,40 @@ class EmpDataServiceController extends BaseController } + } + + + public function getDataByFileId($file_id, $status = 'Success'){ + + $data = $this->batchFileModel + ->select('batch_files.*, clients.client_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; + $user_id = $data['created_by']; + $url = 'employee/upload#KYC-DOC-tab'; + + return ['msg_txt' => $msg_txt, 'user_id' => $user_id, 'url' => $url]; + } + + + public function setPullNotification($data){ + + $msg_data = [ + 'message_text' => $data['msg_txt'], + '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/Controllers/EmployeeController.php b/app/Controllers/EmployeeController.php index 5692668a..5e531472 100644 --- a/app/Controllers/EmployeeController.php +++ b/app/Controllers/EmployeeController.php @@ -898,6 +898,7 @@ class EmployeeController extends AdminController '{CORPORATE_NAME}' =>$value['client_name'], '{AGE}' =>$value['emp_age'], '{TPA_NAME}' =>$value['emp_age'], + '{TPA_LOGO}' => base_url() . 'public/uploads/logo/' . $value['tpa_logo'], ]; // Replace placeholders with values in HTML content diff --git a/app/Models/MessageModel.php b/app/Models/MessageModel.php new file mode 100644 index 00000000..bf9bd03d --- /dev/null +++ b/app/Models/MessageModel.php @@ -0,0 +1,76 @@ +db->table($this->table); + $builder->select('messages.*'); + $builder->join('user_messages', 'user_messages.message_id = messages.id AND user_messages.user_id = ' . $this->db->escape($userId), 'left'); + $builder->groupStart(); + $builder->where('user_messages.is_read', null); + $builder->orWhere('user_messages.is_read', 0); + $builder->groupEnd(); + $builder->groupStart(); + $builder->orwhere('messages.message_type', 'broadcast'); + $builder->orWhere('messages.user_id', $userId); + $builder->orWhere('messages.role_id', $roleId); + $builder->orWhere('messages.team_id', $teamId); + $builder->groupEnd(); + + $query = $builder->get(); + return $query->getResult(); + dd($this->db->getLastQuery()); + } +} diff --git a/app/Models/UserMessageModel.php b/app/Models/UserMessageModel.php new file mode 100644 index 00000000..1b229269 --- /dev/null +++ b/app/Models/UserMessageModel.php @@ -0,0 +1,69 @@ + 1, + 'read_at' => date('Y-m-d H:i:s') + ]; + + $existingEntry = $this->where('user_id', $userId) + ->where('message_id', $messageId) + ->first(); + + if ($existingEntry) { + return $this->update($existingEntry['id'], $data); + } else { + $data['user_id'] = $userId; + $data['message_id'] = $messageId; + return $this->insert($data); + } + } +} diff --git a/app/Views/import_export.php b/app/Views/import_export.php index de0cb419..cd6138fb 100644 --- a/app/Views/import_export.php +++ b/app/Views/import_export.php @@ -1,42 +1,49 @@
+ \ No newline at end of file diff --git a/app/Views/layout/footer.php b/app/Views/layout/footer.php index 7e3f8005..5e74a274 100644 --- a/app/Views/layout/footer.php +++ b/app/Views/layout/footer.php @@ -7,7 +7,9 @@
- © NHANCE + © NHANCE
- -
-
+ +
+
- - + +
+ Notification +
- -
-
- - - -
Group Chats
- - - -
Favourites
- - - -
Other Chats
- - - -
- - -
-
- Theme Settings -
- -
- - -
Color Scheme
-
- - -
- -
- - -
- - -
Width
-
- - -
-
- - -
- - -
Topbar
- -
- - -
- -
- - -
- - -
Menus Positon (Leftsidebar and Topbar)
- -
- - -
- -
- - -
- - -
Left Sidebar Color
- -
- - -
- -
- - -
- -
- - -
- -
- - -
- - -
Left Sidebar Size
- -
- - -
- -
- - -
- -
- - -
- - -
Sidebar User Info
- -
- - -
- - - - - Purchase Now - -
- -
-
- -
+
+
+
    +
    - + + + +
    +
    +
    - + - + - + - - - - - - - - - - - - - + + + + + + + + + + + + + - + - + - - - + + + - + - + - + - + @@ -489,16 +117,12 @@ - - - + + + - - - - - + @@ -506,13 +130,140 @@ + + + + + + \ No newline at end of file diff --git a/app/Views/layout/header.php b/app/Views/layout/header.php index 6c9aff95..b2cf9647 100644 --- a/app/Views/layout/header.php +++ b/app/Views/layout/header.php @@ -43,10 +43,6 @@ /assets/css/jodit.css" rel="stylesheet" type="text/css" /> - - /assets/libs/quill/quill.snow.css" rel="stylesheet" type="text/css" /> - - @@ -236,6 +232,19 @@ } + + - @@ -330,88 +338,12 @@ - +