diff --git a/app/Controllers/ApiServiceController.php b/app/Controllers/ApiServiceController.php index f8c4ca50..a6619e7e 100644 --- a/app/Controllers/ApiServiceController.php +++ b/app/Controllers/ApiServiceController.php @@ -79,6 +79,7 @@ class ApiServiceController extends BaseController $client_policy_id = $params['client_policy_id'] ?? null; $policy_no = $params['policy_no'] ?? null; $type = $params['type'] ?? 'download'; + $all_member = $params['all_member'] ?? null; log_message('error', 'Received Payload INTERNAL : '. json_encode($params ?? "")); @@ -107,10 +108,16 @@ class ApiServiceController extends BaseController // direct download $data['eCardDownload'] = base_url('download-e-card/') . $employee_policy[0]['rand_string'].'/1'; }else{ - // view and download - $data['eCardDownload'] = base_url('download-e-card/') . $employee_policy[0]['rand_string'].'/0/1'; + if(isset($all_member) && !empty($all_member)){ + // view and download all members + $data['eCardDownload'] = base_url('download-e-card/') . $employee_policy[0]['rand_string'].'/1/1'; + }else{ + // view and download single member + $data['eCardDownload'] = base_url('download-e-card/') . $employee_policy[0]['rand_string'].'/0/1'; + } } } + $data['message'] = "E-card generated"; if(empty($data['eCardDownload'])){ $data['message'] = "E-card not generated"; diff --git a/app/Controllers/EmpDataServiceController.php b/app/Controllers/EmpDataServiceController.php index dfaac349..1c22f967 100755 --- a/app/Controllers/EmpDataServiceController.php +++ b/app/Controllers/EmpDataServiceController.php @@ -4968,6 +4968,10 @@ class EmpDataServiceController extends BaseController 'client_policy_id' => $emp_details['client_policy_id'], ]; + if(empty($single_mail)){ + $params['all_member'] = 1; + } + $params['common'] = [ 'client_id' => $emp_details['client_id'], 'client_branch_id' => $emp_details['client_branch_id'], diff --git a/app/Controllers/EmployeeRestController.php b/app/Controllers/EmployeeRestController.php index 65b7ba3f..9165cc0f 100755 --- a/app/Controllers/EmployeeRestController.php +++ b/app/Controllers/EmployeeRestController.php @@ -754,7 +754,7 @@ class EmployeeRestController extends AdminController $result = $empServiceController->excelFileFormatValidation(['file_id' => $file_id]); if (isset($result['error_summary']) && count($result['error_summary'])) { $result = $empServiceController->getExcelErrorData($file_id); - return $this->respond(['status' => 'failed', 'code' => 404, 'message' => "file upload failed with errors", 'data' => $result], 200); + return $this->respond(['status' => 'failed', 'code' => 404, 'message' => "The data format is invalid. Click 'Next' to view details.", 'data' => $result], 200); } @@ -2573,95 +2573,117 @@ class EmployeeRestController extends AdminController public function claimView() { - $ticket_id = $this->request->getGet('ticket_id'); - $ticketController = new TicketController; - $data['ticket_history'] = $ticketController->ticketHistory($ticket_id); - $data['claims_data'] = $this->ticketMaster->getTicketDataByTicketID($ticket_id); - $data['ticket_data'] = $ticketController->getMoreInfo($requestFrom = 'rest', $ticket_id); + try { - // $ticketData = $data['ticket_data']; - // $ticketHistory = $data['ticket_history']; + $ticket_id = $this->request->getGet('ticket_id'); + $ticketController = new TicketController; + $data['ticket_history'] = $ticketController->ticketHistory($ticket_id); + $data['claims_data'] = $this->ticketMaster->getTicketDataByTicketID($ticket_id); + $data['ticket_data'] = $ticketController->getMoreInfo($requestFrom = 'rest', $ticket_id); - $ticketClaimStatus = $this->claimStatusModel->select('claim_status, display_name')->where('display_name is not null')->where('is_active', 1)->findAll(); - $status_list = array_column($ticketClaimStatus, 'display_name', 'claim_status'); - - $data['ticket_data'] = array_fill_keys(array_keys($data['ticket_data']), []); + // $ticketData = $data['ticket_data']; + // $ticketHistory = $data['ticket_history']; + // print_r($ticketHistory); die; + $currentClaimStatus = $this->claimStatusModel->select("claim_status")->where('id', $data['claims_data']['claim_status_id'])->where('is_active', 1)->first(); + $ticketClaimStatus = $this->claimStatusModel->select('claim_status, display_name')->where('display_name is not null')->where('is_active', 1)->findAll(); + $status_list = array_column($ticketClaimStatus, 'display_name', 'claim_status'); + // print_r($currentClaimStatus); die; - // Loop through ticket_data - foreach ($data['ticket_data'] as $status => &$fields) { - // Search ticket_history for matching old_status_value - foreach ($data['ticket_history'] as $history) { + $data['ticket_data'] = array_fill_keys(array_keys($data['ticket_data']), []); - if ($history['old_status_value'] === $status) { - // Attach modified_by and created_at - // $fields['modified_by'] = $history['modified_by']; - $fields['modified_by'] = ""; - $fields['modified_at'] = date('d-m-Y h:i A', strtotime($history['created_at'])); - // Break after first match (assuming latest entry is enough) - break; + // Loop through ticket_data + foreach ($data['ticket_data'] as $status => &$fields) { + // Search ticket_history for matching old_status_value + foreach ($data['ticket_history'] as $history) { + + if ($history['old_status_value'] === $status) { + // Attach modified_by and created_at + // $fields['modified_by'] = $history['modified_by']; + $fields['modified_by'] = ""; + $fields['modified_at'] = date('d-m-Y h:i A', strtotime($history['created_at'])); + // Break after first match (assuming latest entry is enough) + break; + } } } - } - $new_ticket_data = []; + $data['ticket_data'][$currentClaimStatus['claim_status']]['modified_by'] = ""; + $data['ticket_data'][$currentClaimStatus['claim_status']]['modified_at'] = $formatted = date('d-m-Y h:i A', strtotime($data['claims_data']['updated_at'])); - foreach ($data['ticket_data'] as $oldKey => $value) { + $new_ticket_data = []; - // Only process if key exists in status_list - if (!isset($status_list[$oldKey])) { - continue; // skip and do NOT add to new array + foreach ($data['ticket_data'] as $oldKey => $value) { + + // Only process if key exists in status_list + if (!isset($status_list[$oldKey])) { + continue; // skip and do NOT add to new array + } + + // Get new key based on mapping + $newKey = $status_list[$oldKey]; + + // Avoid duplicates + if (!isset($new_ticket_data[$newKey])) { + $new_ticket_data[$newKey] = $value; + } } - // Get new key based on mapping - $newKey = $status_list[$oldKey]; + uasort($new_ticket_data, function ($a, $b) { + $timeA = \DateTime::createFromFormat('d-m-Y h:i A', $a['modified_at']); + $timeB = \DateTime::createFromFormat('d-m-Y h:i A', $b['modified_at']); + return $timeA <=> $timeB; // Ascending + }); - // Avoid duplicates - if (!isset($new_ticket_data[$newKey])) { - $new_ticket_data[$newKey] = $value; - } - } - - uasort($new_ticket_data, function ($a, $b) { - $timeA = \DateTime::createFromFormat('d-m-Y h:i A', $a['modified_at']); - $timeB = \DateTime::createFromFormat('d-m-Y h:i A', $b['modified_at']); - return $timeA <=> $timeB; // Ascending - }); - - $data['ticket_data'] = $new_ticket_data; + $data['ticket_data'] = $new_ticket_data; - $ticketMesssageModel = new TicketMessageModel(); - $ticket_message = $ticketMesssageModel - ->where('is_active', 1) - ->where('sender', "user") - ->where('ticket_id', $ticket_id) - ->orderBy('id', "desc") - ->first(); - - $claim_file_urls = []; - - if (isset($ticket_message['id'])) { - - $claimFiles = new ClaimFilesModel(); - $claim_files_data = $claimFiles - ->select('id as claim_file_id, doc_name as claim_file_name') + $ticketMesssageModel = new TicketMessageModel(); + $ticket_message = $ticketMesssageModel ->where('is_active', 1) - ->where('file_type', 2) + ->where('sender', "user") ->where('ticket_id', $ticket_id) - ->where('ticket_message_id', $ticket_message['id']) - ->findAll(); + ->orderBy('id', "desc") + ->first(); - foreach ($claim_files_data as &$value) { - $value['url'] = base_url('downloadClaimFile/') . $value['claim_file_id']; - $claim_file_urls[] = $value; + $claim_file_urls = []; + + if (isset($ticket_message['id'])) { + + $claimFiles = new ClaimFilesModel(); + $claim_files_data = $claimFiles + ->select('id as claim_file_id, doc_name as claim_file_name') + ->where('is_active', 1) + ->where('file_type', 2) + ->where('ticket_id', $ticket_id) + ->where('ticket_message_id', $ticket_message['id']) + ->findAll(); + + foreach ($claim_files_data as &$value) { + $value['url'] = base_url('downloadClaimFile/') . $value['claim_file_id']; + $claim_file_urls[] = $value; + } + unset($value); } - unset($value); + + $data['claim_files'] = $claim_file_urls; + + return $this->respond(['status' => (count($data) ? 'success' : 'failed'), 'code' => (count($data) ? 200 : 404), 'data' => $data,], 200); + + } catch (\Throwable $th) { + $this->myLogger->logme("error", 'claim_view' .($th->getMessage() . ' --- ' . $th->getLine() . '----' . $th->getTraceAsString())); + $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, + ]; + return $this->respond(['status' => 'failed', 'code' => 500, 'data' => "", 'error_data' => $errorData], 500); } - - $data['claim_files'] = $claim_file_urls; - - return $this->respond(['status' => (count($data) ? 'success' : 'failed'), 'code' => (count($data) ? 200 : 404), 'data' => $data,], 200); } diff --git a/app/Controllers/MediAssistApiController.php b/app/Controllers/MediAssistApiController.php index 4e13298c..621a187f 100644 --- a/app/Controllers/MediAssistApiController.php +++ b/app/Controllers/MediAssistApiController.php @@ -331,6 +331,7 @@ class MediAssistApiController extends BaseController $db = \Config\Database::connect(); $updated = 0; + $employee_policy_ids = []; foreach ($employeePolicyData as $policy_data) { foreach ($allBenef as $row) { @@ -370,6 +371,10 @@ class MediAssistApiController extends BaseController WHERE id = ?"; $db->query($sql, [$row['benefMediAssistID'], $policy_data['emp_policy_id']]); + // for e-card send + if(strtolower(trim($policy_data['relationship'])) == 'self'){ + $employee_policy_ids[] = $policy_data['emp_policy_id']; + } if ($db->affectedRows() > 0) { $updated++; @@ -384,6 +389,12 @@ class MediAssistApiController extends BaseController } } + // send e-card + if(!empty($employee_policy_ids)){ + log_message('error', "sendMailForDownloadingECard JOB PUSHED."); + Jobs::addJob(['job_name' => 'sendMailForDownloadingECard', 'payload' => $employee_policy_ids]); + } + // update file table status after the tpa id successfully updated if (isset($requestData['file_id']) && !empty($requestData['file_id'])) { $file_model = new BatchFileModel(); diff --git a/app/Views/policy_transaction_endorsement_form.php b/app/Views/policy_transaction_endorsement_form.php index 04f4b2de..698ef0f9 100644 --- a/app/Views/policy_transaction_endorsement_form.php +++ b/app/Views/policy_transaction_endorsement_form.php @@ -241,11 +241,6 @@ -
- - -
-
+
+ + +
+
diff --git a/app/Views/policy_transaction_endorsement_list.php b/app/Views/policy_transaction_endorsement_list.php index 6f5485cb..59963f43 100644 --- a/app/Views/policy_transaction_endorsement_list.php +++ b/app/Views/policy_transaction_endorsement_list.php @@ -287,7 +287,6 @@ table.dataTable thead th {
- @@ -568,10 +567,24 @@ table.dataTable thead th { maxDate: today // Disallow future dates }); + var month = flatpickr("#month", { + dateFormat: "M/Y", // Format as month and year + allowInput: false, // Disable manual input + }); - var closure_date = flatpickr("#policy_issue_date", { - dateFormat: "d/m/Y", - allowInput: false + var policy_issue_date = flatpickr("#policy_issue_date", { + dateFormat: "d/m/Y", // Format as day-month-year + allowInput: false, // Disable manual input + onChange: function(selectedDates, dateStr, instance) { + // Get the selected date + var selectedDate = new Date(selectedDates[0]); + + // Format the selected date to "M-Y" + var formattedMonth = flatpickr.formatDate(selectedDate, "M/Y"); + + // Set the value of the #month input + month.setDate(formattedMonth); + } }); var install_due_date = flatpickr("#install_due_date", { @@ -579,26 +592,11 @@ table.dataTable thead th { allowInput: false }); - // var start_date = flatpickr("#policy_start_date", { - // dateFormat: "d/m/Y", - // allowInput: false - // }); - - // var end_date = flatpickr("#policy_end_date", { - // dateFormat: "d/m/Y", - // allowInput: false - // }); - var endorse_eff_date = flatpickr("#endorse_eff_date", { dateFormat: "d/m/Y", allowInput: false }); - var month = flatpickr("#month", { - dateFormat: "M/Y", - allowInput: false, - }); - }); function hide_list_show_add() {