diff --git a/app/Config/Routes.php b/app/Config/Routes.php
index 639a1409..1cf4572f 100755
--- a/app/Config/Routes.php
+++ b/app/Config/Routes.php
@@ -530,6 +530,7 @@ $routes->cli('cli/insurerRFQRemainder', 'LeadsController::remainderForQcr');
$routes->cli('cli/sendMailWithAutoQuery','TicketController::sendMailWithAutoQuery');
$routes->cli('cli/ClaimStatusUpdate','MediAssistApiController::ClaimStatusUpdate');
$routes->cli('cli/syncTpaClaimToNhance','MediAssistApiController::syncTpaClaimToNhance');
+$routes->cli('cli/thzReminderCrone','ThzController::getOpenTicketsOlderThan24HoursAndAssignNextLevel');
@@ -822,6 +823,7 @@ $routes->group('test', function($routes) {
$routes->get('membervalidation', 'TestingController::membervalidation');
$routes->get('generateExcel', 'TestingController::generateExcel');
$routes->get('logo_renaming','TestingController::logo_renaming');
+ $routes->get('thzReminderCrone','ThzController::getOpenTicketsOlderThan24HoursAndAssignNextLevel');
// $routes->get('createDefaultMailTempalteInDB','TestingController::createDefaultMailTempalteInCrossDB');
// $routes->get('createDefaultMailTempalteInSameDB','TestingController::createDefaultMailTempalteInSameDB');
});
diff --git a/app/Controllers/EmpDataServiceController.php b/app/Controllers/EmpDataServiceController.php
index 179aa7b3..452f414b 100755
--- a/app/Controllers/EmpDataServiceController.php
+++ b/app/Controllers/EmpDataServiceController.php
@@ -2203,6 +2203,9 @@ class EmpDataServiceController extends BaseController
if ($get_policy_type['policy_type_id'] != 1) {
+ // generate e-card and store S3
+ $r = Jobs::addJob(['job_name' => 'bulkGenerateEcardAndStoreinS3', 'payload' => ['client_policy_id' => $client_policy_id]]);
+
$job_details = new Jobs();
$r = Jobs::addJob(['job_name' => 'sendMailForDownloadingECard', 'payload' => ['ids' => $emp_policy_ids, 'client_policy_id' => $client_policy_id]]);
}
@@ -2524,6 +2527,7 @@ class EmpDataServiceController extends BaseController
$event_type = $file['event_type'];
$policy_issue_date = $file['policy_issue_date'];
+ $client_policy_data = $this->clientPolicyModel->where('id', $client_policy_id)->first();
$status_val = 'success';
if ($status == 'in-progress-partially') {
@@ -2613,6 +2617,10 @@ class EmpDataServiceController extends BaseController
'status' => $status_val,
]);
+ if($client_policy_data['policy_type_id'] != 1){
+ // re-generate e-card and store S3
+ $r = Jobs::addJob(['job_name' => 'bulkGenerateEcardAndStoreinS3', 'payload' => ['client_policy_id' => $client_policy_id]]);
+ }
$this->myLogger->logme('error', 'importCorrectionUpdateEndorsementID employee count : {data}', ['data'=> $emp_count]);
$this->myLogger->logme('error', 'importCorrectionUpdateEndorsementID batch file status : {data}', ['data'=> $status_val]);
diff --git a/app/Controllers/EmployeeController.php b/app/Controllers/EmployeeController.php
index 66549050..d394de03 100755
--- a/app/Controllers/EmployeeController.php
+++ b/app/Controllers/EmployeeController.php
@@ -1076,10 +1076,23 @@ class EmployeeController extends AdminController
}
return $this->respond(['dataStatus' => true, 'code' => 200, 'data' => $html, 'file_data' => $file_name, 'excel_data' => $excel_data], 200);
- } catch (\Exception $e) {
+ } catch (\Throwable $th) {
+
+ $errorData = [
+ 'message' => $th->getMessage(),
+ 'file' => $th->getFile(),
+ 'line' => $th->getLine(),
+ 'code' => $th->getCode(),
+ 'trace' => $th->getTraceAsString(),
+ 'trace_array' => $th->getTrace(), // full array version (optional)
+ 'function' => $th->getTrace()[0]['function'] ?? null,
+ 'class' => $th->getTrace()[0]['class'] ?? null,
+ ];
+
// Handle exception
- $errorMessage = 'Error occurred: ' . $e->getMessage();
+ $errorMessage = 'Error occurred:' . PHP_EOL . json_encode($errorData, JSON_PRETTY_PRINT);
$this->myLogger->logme('error', $errorMessage);
+
$html = '
No Data Found
';
return $this->respond(['dataStatus' => false, 'code' => 500, 'data' => $html, 'file_data' => $file_name], 500);
}
@@ -4150,6 +4163,8 @@ class EmployeeController extends AdminController
return $this->respond([
'status' => 'ECARD_BULK_TO_S3 Job queued',
+ 'message' => 'E-card re-generation process has started successfully.',
+ 'dataStatus' => true,
'total' => $total,
'batches' => $total_batches
], 200);
diff --git a/app/Controllers/NotificationController.php b/app/Controllers/NotificationController.php
index c59102e5..0d85df18 100755
--- a/app/Controllers/NotificationController.php
+++ b/app/Controllers/NotificationController.php
@@ -362,7 +362,7 @@ class NotificationController extends AdminController
// Define upload path and attempt file upload
$uploadFilePath = WRITEPATH . 'uploads/attachments';
$uploadedFile = $this->request->getFile('file');
- $fileName = file_Upload($uploadedFile, $uploadFilePath); // Assume file_Upload handles file saving
+ $fileName = file_Upload_for_lead($uploadedFile, $uploadFilePath); // Assume file_Upload handles file saving
if ($fileName) {
// Prepare data for insertion
diff --git a/app/Controllers/RestAuthenticationController.php b/app/Controllers/RestAuthenticationController.php
index 9c9065b9..bad20540 100755
--- a/app/Controllers/RestAuthenticationController.php
+++ b/app/Controllers/RestAuthenticationController.php
@@ -101,6 +101,7 @@ class RestAuthenticationController extends AdminController
->where('employees.mobile', $mobile_number)
->where('EP.is_active', 1)
->whereIn('EP.status', ['active', 'expired'])
+ ->orderBy('employees.id', 'desc')
->first();
$lastQuery = $this->employeeModel->db->getLastQuery();
@@ -122,7 +123,7 @@ class RestAuthenticationController extends AdminController
AND employees.relationship = 'self'
AND employees.is_active = 1
AND employee_polices.is_active = 1
- AND employee_polices.status IN ('active')
+ AND employee_polices.status IN ('active', 'expired')
";
$db = db_connect();
@@ -166,7 +167,7 @@ class RestAuthenticationController extends AdminController
log_message('error', ' ');
log_message('error', ' ************************************* POST END **************************************** ');
log_message('error', ' ');
- return $this->respond(['status' => 'failed','code' => 500,'data' => $th],500);
+ return $this->respond(['status' => 'failed','code' => 500,'data' => $th->getMessage()],500);
}
}
diff --git a/app/Controllers/ThzController.php b/app/Controllers/ThzController.php
index 8ffdbfd7..0d152a31 100644
--- a/app/Controllers/ThzController.php
+++ b/app/Controllers/ThzController.php
@@ -5,6 +5,8 @@ namespace App\Controllers;
use App\Controllers\BaseController;
use App\Helpers\MailHelper;
use CodeIgniter\HTTP\ResponseInterface;
+use CodeIgniter\API\ResponseTrait;
+
use App\Models\ThzMasterModel;
use App\Models\ThzMasterNotesModel;
@@ -20,6 +22,7 @@ use App\Models\ClientRMModel;
class ThzController extends BaseController
{
+ use ResponseTrait;
protected $thzMasterModel;
protected $thzMasterNotesModel;
@@ -685,6 +688,151 @@ class ThzController extends BaseController
return null;
}
+ private function getRmsIdUsingClientId($client_id)
+ {
+ if(!empty($client_id)){
+
+ $acm_data = $this->cientRmModel
+ ->select('client_rm.*, user_profiles.email')
+ ->join('user_profiles', 'client_rm.user_id = user_profiles.id')
+ ->where('client_rm.is_active', 1)
+ ->where('client_rm.client_id', $client_id)
+ ->orderBy('id', 'asc')
+ ->findAll();
+
+ if($acm_data){
+ return $acm_data;
+ }
+
+ $this->myLogger->logme('error', 'Account Manager data not found');
+ return [];
+
+ }
+
+ $this->myLogger->logme('error', 'client id is null');
+ return null;
+ }
+
+ public function getOpenTicketsOlderThan24HoursAndAssignNextLevel()
+ {
+
+ $current_day = date('D'); // Sun, Mon, Tue...
+
+ $nl = (php_sapi_name() === 'cli') ? PHP_EOL : '
';
+
+ echo $current_day . $nl;
+
+ if ($this->request) {
+ echo "REQUEST" . $nl;
+ } else {
+ echo "CLI" . $nl;
+ }
+
+ if ($current_day === 'Sun') {
+
+ if($this->request){
+ return $this->respond(['message' => "Today is Sunday. Ticket reminder mail skipped"], 200);
+ }else{
+ $this->myLogger->logme('error', 'Today is Sunday. Ticket reminder mail skipped');
+ echo 'Today is Sunday. Ticket reminder mail skipped';
+ return;
+ }
+ }
+
+ $client_id = $this->request->getGet('client_id') ?? null;
+ $ticket_id = $this->request->getGet('ticket_id') ?? null;
+
+ // Fetch tickets older than 8 hours
+ $builder = $this->thzMasterModel
+ ->whereIn('status', ['Open', 'In Progress'])
+ // ->where('thz_id', 85)
+ ->where('created_at <= DATE_SUB(NOW(), INTERVAL 8 HOUR)', null, false);
+
+ // add condition only if client_id exists
+ if (!empty($client_id)) {
+ $builder->where('client_id', $client_id);
+ }
+
+ // add condition only if ticket_id exists
+ if (!empty($ticket_id)) {
+ $builder->where('thz_id', $ticket_id);
+ }
+
+ $result = $builder->findAll();
+
+
+ $subjectTemplate = 'Ticket Pending for More Than ((HOURS)) Hours – Action Required';
+ $messageTemplate = ' Ticket ID : ((TICKET_ID)) has remained in the same status for ((HOURS)) hours. Please take the necessary action.';
+
+ $common = [
+ 'module' => 'THZ',
+ 'mail_type' => 'Thz_Reminder_mail'
+ ];
+
+ $mail_send_count = 0;
+
+ if(!empty($result)){
+ foreach ($result as $value) {
+
+ // Calculate hours difference
+ $createdAt = new \DateTime($value['created_at']);
+ $now = new \DateTime();
+ $hours = floor(($now->getTimestamp() - $createdAt->getTimestamp()) / 3600);
+ $ticket_url = base_url('ticketConversationList?return_type=web&thz_id=' . $value['thz_id']);
+
+ // Replace placeholders
+ $subject = str_replace('((HOURS))', $hours, $subjectTemplate);
+
+ $message = str_replace(
+ ['((TICKET_ID))', '((HOURS))', '((TICKET_URL))'],
+ [$value['thz_id'], $hours, $ticket_url],
+ $messageTemplate
+ );
+
+
+ $client_id = $value['client_id'];
+ $level_of_user_data = $this->getRmsIdUsingClientId($client_id);
+
+ if(!empty($level_of_user_data)){
+ foreach ($level_of_user_data as $user) {
+
+ $res = MailHelper::send_email([
+ 'mail' => $user['email'],
+ 'subject' => $subject,
+ 'message' => $message,
+ 'common' => $common
+ ]);
+
+ $mail_send_count++;
+
+ $this->myLogger->logme(
+ 'error',
+ 'THZ Reminder Mail Sent | Ticket ID: ' . $value['thz_id'] . ' | Client ID : ' . $client_id . ' | Response: ' . json_encode($res)
+ );
+ }
+ }else{
+ $this->myLogger->logme('error', 'CLIENT ID : ' . $client_id . "has no RM's found skipped...." );
+ }
+ }
+ }else{
+ if($this->request){
+ return $this->respond(['message' => "No ticket Pending for More Than 8 hrs"], 200);
+ }else{
+ $this->myLogger->logme('error', 'No ticket Pending for More Than 8 hrs');
+ echo 'No ticket Pending for More Than 8 hrs';
+ return;
+ }
+ }
+
+ if($this->request){
+ return $this->respond(['mail_send_count' => $mail_send_count], 200);
+ }else{
+ print_r(['mail_send_count' => $mail_send_count]);
+ return;
+ }
+ }
+
+
}
diff --git a/app/Models/EmployeePolicyModel.php b/app/Models/EmployeePolicyModel.php
index 0e86d94a..81f8c580 100755
--- a/app/Models/EmployeePolicyModel.php
+++ b/app/Models/EmployeePolicyModel.php
@@ -279,6 +279,7 @@ class EmployeePolicyModel extends Model
'client_branch.branch_code as client_branch_code',
'cp.policy_no',
'cp.policy_type_id',
+ 'cp.is_addon',
$ecard_download_link
])
->join('employees emp', 'employee_polices.employee_id = emp.id')
diff --git a/app/Views/employee_data_list.php b/app/Views/employee_data_list.php
index 3e3178b6..d4704749 100755
--- a/app/Views/employee_data_list.php
+++ b/app/Views/employee_data_list.php
@@ -206,6 +206,14 @@
Send E-Card Mail
+
+ Re-Generate E-Card
+
+
+
+ Re-Generate E-Card
+
+
@@ -780,4 +788,67 @@
}
+ function showReGenerateConfirmation(client_policy_id, emp_code){
+
+ Swal.fire({
+ title: "Do you want to Re-Generate Ecard for this family?",
+ showDenyButton: true,
+ showCancelButton: false,
+ confirmButtonText: "Yes",
+ denyButtonText: "No"
+ }).then((result) => {
+
+ if (result.isConfirmed) {
+ reGenerateEcardForSingleFamily(client_policy_id, emp_code)
+ }
+
+ });
+
+ }
+
+ function reGenerateEcardForSingleFamily(client_policy_id, emp_code)
+ {
+ if(!client_policy_id){
+ toastr.warning('Failed to re-Generate E-card', 'WARNING');
+ }
+ if(!emp_code){
+ toastr.warning('Failed to re-Generate E-card', 'WARNING');
+ }
+
+ console.log({client_policy_id, emp_code});
+
+ let url = '= base_url('/employee/bulkGenerateEcardAndStoreinS3') ?>';
+
+ // Data to send in the AJAX request
+ let requestData = {
+ client_policy_id: client_policy_id,
+ emp_code: emp_code,
+ };
+
+ $('.loader').fadeIn();
+ $('.loader-mask').fadeIn();
+
+ // Send AJAX request
+ sendAjaxRequestForGlobal(url, 'GET', requestData, function(response) {
+
+ console.log('Data fetched successfully:', response);
+
+ if (response.dataStatus == true) {
+ toastr.success(response.message || 'Initiating successafully.', 'SUCCESS');
+ } else {
+ toastr.warning(response.status || 'Unable to regenerate e-card.', 'WARNING');
+ }
+
+ $('.loader').fadeOut();
+ $('.loader-mask').delay(350).fadeOut('slow');
+
+ }, function(xhr, status, error) {
+ console.error('Error fetching data:', error);
+ console.error(xhr.responseText);
+ toastr.error('Unable to regenerate e-card.', 'ERROR');
+ });
+
+
+ }
+
diff --git a/app/Views/view_file_upload_emp_list.php b/app/Views/view_file_upload_emp_list.php
index 96ce9b36..aab97b08 100755
--- a/app/Views/view_file_upload_emp_list.php
+++ b/app/Views/view_file_upload_emp_list.php
@@ -22,15 +22,13 @@ table.dataTable tbody td {
-
-
-
- |
-
- |
-
-
-
+
+
+
+ | = esc($data) ?> |
+
+
+