diff --git a/app/Config/Routes.php b/app/Config/Routes.php index 599236aa..b9cd244a 100755 --- a/app/Config/Routes.php +++ b/app/Config/Routes.php @@ -47,6 +47,7 @@ $routes->get("frontend_content", "AppContentManagementController::frontend_conte // $routes->get('/', 'LoginController::index'); $routes->get('/test', 'Home::index'); $routes->get('/check_gemini', 'Home::check_Gemini'); +$routes->get('/check_gemini2', 'Home::check_gemini_2'); $routes->get('/login', 'LoginController::index'); ///auth/google $routes->get('/loginPos', 'LoginController::loginPos'); //login POS team $routes->post('/getVerifyPosMobileNo', 'LoginController::getVerifyPosMobileNo'); //Verify POS team mobile no @@ -371,6 +372,9 @@ $routes->group("/util", ["filter" => "authMVC"], function ($routes) { $routes->get('viewHrAccessData', 'ClientController::viewHrAccessData'); $routes->post('saveHrAccessData', 'ClientController::saveHrAccessData'); $routes->get('removeLevelContacts', 'ClientController::removeLevelContacts'); + $routes->get('getClaimDumpFileErrorData', 'TicketController::getClaimDumpFileErrorData'); + $routes->get("claim_dump_excel_error/(:any)", "TicketController::getClaimDumpExcelFileErrors/$1"); + $routes->get("download_claim_dump_file/(:any)", "TicketController::downloadClaimDumpFile/$1"); }); $routes->post("policy_tranction/sendInstallmentRemainderMail","PolicyTransactionController::sendInstallmentRemainderMail"); @@ -552,7 +556,13 @@ $routes->group("employeeRest", ["filter" => "authJWT"], function ($routes) { $routes->get("claimView", "EmployeeRestController::claimView"); $routes->get("exportCashDepositData", "EmployeeRestController::exportCashDepositData"); - //hr file upload api's + + //thz_master's + $routes->post("ticketSave", "ThzController::ticketSave"); + $routes->get("ticketList", "ThzController::ticketList"); + $routes->post("ticketConversationSave", "ThzController::ticketConversationSave"); + $routes->get("ticketConversationList", "ThzController::ticketConversationList"); + $routes->get("hrFileList", "EmployeeRestController::hrFileList"); $routes->get("hrFileUploadMasters", "EmployeeRestController::hrFileUploadMasters"); $routes->get("hrFileDownload", "EmployeeRestController::hrFileDownload"); @@ -645,4 +655,8 @@ $routes->post('newClaim','VidalApiController::newClaim'); $routes->post('enrollment','VidalApiController::enrollment'); -$routes->post("ticketCreation", "ThzController::ticketCreation"); \ No newline at end of file +$routes->post("ticketSave", "ThzController::ticketSave"); +$routes->get("ticketList", "ThzController::ticketList"); +$routes->post("ticketConversationSave", "ThzController::ticketConversationSave"); +$routes->get("ticketConversationList", "ThzController::ticketConversationList"); +$routes->post('ticketAutoFetchDetails',"ThzController::ticketAutoFetchDetails"); \ No newline at end of file diff --git a/app/Controllers/ClientController.php b/app/Controllers/ClientController.php index d4bfa5d8..7126cd69 100755 --- a/app/Controllers/ClientController.php +++ b/app/Controllers/ClientController.php @@ -143,7 +143,11 @@ class ClientController extends AdminController // Perform the query $builder = $db->table($table); - $isDuplicate = $builder->where($field, $value)->where('is_active', 1)->countAllResults() > 0; + if(is_array($value)){ + $isDuplicate = $builder->where($value)->where('is_active', 1)->countAllResults() > 0; + }else{ + $isDuplicate = $builder->where($field, $value)->where('is_active', 1)->countAllResults() > 0; + } // Return the result return $this->response->setJSON(['isDuplicate' => $isDuplicate]); @@ -5037,7 +5041,16 @@ class ClientController extends AdminController // $employeeController = new EmployeeController(); // $employeeController->truncateFileData('633'); - + + // ---------- TICKET SERVICE CONTROLLER -------------------------------------------------------------------------------- + + $ticketServiceController = new TicketServiceController(); + // $response = $ticketServiceController->claimDumpExcelFileFormatValidation(["file_id" => 3]); + // $response = $ticketServiceController->claimDumpExcelFileDataValidation(["file_id" => 3]); + // $response = $ticketServiceController->claimDumpOnBoardProcess(["file_id" => 3]); + // $response = $ticketServiceController->extractExcelData("claims_dump_form_client.xlsx"); + // dd($response); + // ---------- EMP SERVICE CONTROLLER -------------------------------------------------------------------------------- $empServiceController = new EmployeeServiceController(); @@ -5054,18 +5067,18 @@ class ClientController extends AdminController // ---------- POLICY TRANSACTION CONTROLLER -------------------------------------------------------------------------------- $policyTransactionController = new PolicyTransactionController(); - // $res = $policyTransactionController->validateInsurerStatement(['file_id' => '17']); + // $res = $policyTransactionController->validateInsurerStatement(['file_id' => '57']); // $res = $policyTransactionController->updateInsurerStatement(['file_id' => '22']); // dd('-----', $res); // ----------EMP DATA SERVICE CONTROLLER-------------------------------------------------------------------------------- $batch_data = [ - 'client_id' => 20, - 'client_branch_id' => 72, - 'client_policy_id' => 127, + 'client_id' => 51, + 'client_branch_id' => 40, + 'client_policy_id' => 63, 'insurer_or_tpa' => "insurer", - 'event_type' => "deletion", + 'event_type' => "correction", 'actions' => "export", 'file_name' => "deletion_enhancement_test_file.xlsx", ]; @@ -5132,25 +5145,30 @@ class ClientController extends AdminController // $EmpDataServiceController->cashDepositCalculationForDeletion($array); // $result = $this->employeePolicyModel->getInceptionEmployeeDataForExportExcel($batch_data); + // $result = $this->employeePolicyModel->getCorrectionEmployeesDataForExportExcel($batch_data); // dd(db_connect()->getLastQuery()); // ------------- LEADS CONTROLLER ---------------------------------------------------------- $LeadsController = new LeadsController(); - // $RFQModel = new RFQModel(); + $RFQModel = new RFQModel(); - // $data = $RFQModel->where('is_active', 1)->where('lead_id', 40)->first(); - // // dd($data); + // $data = $RFQModel->where('is_active', 1)->where('lead_id', 323)->orderBy('id', 'desc')->first(); + // $data = db_connect()->table('leads')->where('is_active', 1)->where('id', 326)->orderBy('id', 'desc')->get()->getResultArray(); + // dd($data); // $policy_type = 2; // $proposel_name = "Proposal 2"; // $insurer_name = "ICICI-P-ICICI002-V1"; // $jsonArray = json_decode($data['json'], true); - // // dd($jsonArray); + // dd($jsonArray); - // $returndata = $LeadsController->convertQCRJsonToPolicyTerms($jsonArray, $policy_type, $proposel_name, $insurer_name); - // dd($returndata); - - // $LeadsController->handleMemberDataGPATotalSumInsurerFromExcel(['lead_id' => 169]); + // $res = $LeadsController->convertQCRJsonToPolicyTerms($jsonArray, $policy_type, $proposel_name, $insurer_name); + // $res = $LeadsController->handleMemberDataGPATotalSumInsurerFromExcel(['lead_id' => 169]); + // $res = $LeadsController->reorderProposalsByInsurerTotal($jsonArray); + // $res = $LeadsController->calculateMembersDemography(['lead_id' => 326]); + // $res = $LeadsController->generateDemographyDataTable(['lead_id' => 326]); + // echo $res; + // dd($res); // -----------BDS REPORT CONTROLLER--------------------------------------------------------------------------------- diff --git a/app/Controllers/Home.php b/app/Controllers/Home.php index 09d3dc19..cc084f72 100755 --- a/app/Controllers/Home.php +++ b/app/Controllers/Home.php @@ -7,6 +7,10 @@ use GeminiAPI\Client; use GeminiAPI\Resources\ModelName; use GeminiAPI\Resources\Parts\TextPart; +use Mpdf\Mpdf; +use PhpOffice\PhpSpreadsheet\IOFactory; +use PhpOffice\PhpSpreadsheet\Shared\Date; + class Home extends PublicController { @@ -36,24 +40,300 @@ class Home extends PublicController public function check_Gemini() { - try { - $apiKey = 'AIzaSyBbx-uotRBqkYhqLpmD60420E_a0G0duP8'; - // Initialize the Gemini client - $client = new Client($apiKey); + try { + $apiKey = 'AIzaSyBbx-uotRBqkYhqLpmD60420E_a0G0duP8'; + // Initialize the Gemini client + $client = new Client($apiKey); - // Send a prompt to the Gemini Pro model - $response = $client->generativeModel(ModelName::GEMINI_PRO)->generateContent( - new TextPart('Write a short, creative story about a knight and a dragon.') - ); + // Send a prompt to the Gemini Pro model + $response = $client->generativeModel(ModelName::GEMINI_PRO)->generateContent( + new TextPart('Write a short, creative story about a knight and a dragon.') + ); - // Display the generated text - $data['gemini_response'] = $response->text(); - } catch (\Exception $e) { - // Handle any errors that occur during the API call - $data['gemini_response'] = 'An error occurred: ' . $e->getMessage(); - } + // Display the generated text + $data['gemini_response'] = $response->text(); + } catch (\Exception $e) { + // Handle any errors that occur during the API call + $data['gemini_response'] = 'An error occurred: ' . $e->getMessage(); + } + + print_rr($data); + } + + public function check_gemini_2() + { + + // $this->convertToPdf();die(); + // Replace with your actual Gemini API key + $apiKey = 'AIzaSyBbx-uotRBqkYhqLpmD60420E_a0G0duP8'; + + // The model to use and the API endpoint + $model = "gemini-pro"; + $model = "gemini-2.5-flash"; + // $model = "gemini-1.5-pro"; + // $model = "gemini-1.5-pro"; + $url = "https://generativelanguage.googleapis.com/v1beta/models/{$model}:generateContent?key={$apiKey}"; + + $filePath = 'C:\Users\Venba\Downloads\NIA MDU May-2025 (2).pdf'; + $filePath = 'C:/Users/Venba/Desktop/ins stmts/NIC MDU June-2025 (1).pdf'; + $filePath = 'C:/Users/Venba/Desktop/ins stmts/UIIC GR June-2025.pdf'; + $filePath = 'C:/Users/Venba/Desktop/ins stmts/UIIC VLR June-2025 (2).xlsx'; + $filePath = 'C:/Users/Venba/Desktop/ins stmts/pdf/2.pdf'; + $filePath = 'C:\Users\Venba\Downloads\Raheja June-2025.csv'; + // $filePath = 'C:/Users/Venba/Downloads/Raheja June-2025.pdf'; + // $filePath = 'C:/Users/Venba/Desktop/ins stmts/ICICI Pru June-2025 (1).xlsx'; + // $filePath = 'C:/Users/Venba/Desktop/ins stmts/Digit Life June-2025.xlsx'; + + // Check if the file exists + if (!file_exists($filePath)) { + die("Error: File not found at {$filePath}"); + } + + // Get the file's MIME type using the finfo extension + $finfo = finfo_open(FILEINFO_MIME_TYPE); + $mimeType = finfo_file($finfo, $filePath); + finfo_close($finfo); + // print_r($mimeType);die(); + // Define supported inline MIME types + $supportedInlineMimeTypes = ['application/pdf','text/csv']; + + // Read the file content and encode it to Base64 + $fileContent = file_get_contents($filePath); + $base64Content = base64_encode($fileContent); + // The prompt you want to send to the model + $prompt = "give me a json with emp data like name,age,dob,mobile and email. only json not any explanations"; + $prompt = "Read the following insurer monthly statement file and convert into JSON format as sample specified.attach statement items in 'items' key and if any other data available put it in 'meta'. Give me only JSON,not any explanations. If you find the same details like insured name, policy number,endorsement no,policy start date,policy end date group it as single policy and identify base premium, third party premium and terrorism premium."; + $prompt .= "{\'items\': [{\'sno\': 1, \'policy_no\': \'\', \'insured_name\': \'\', \'endorsement_no\': \'\', \'policy_start_date\': \'\', \'policy_end_date\': \'\', \'actual_base_premium_amount\': \'\', \'actual_third_party_premium_amount\': \'\', \'actual_terrorism_premium_amount\': \'\', \'actual_base_premium_percentage\': \'\', \'actual_third_party_premium_percentage\': \'\', \'actual_terrorism_premium_percentage\': \'\', \'actual_bp_brokerage_amount\': \'\', \'actual_tp_brokerage_amount\': \'\', \'actual_tep_brokerage_amount\': \'\', \'reward_amount\': \'\'}]}"; + + $payloadPart = null; + + // The text part of the prompt + $text_part = [ + "text" => $prompt + ]; + // Conditionally handle the file upload based on MIME type + if (in_array($mimeType, $supportedInlineMimeTypes)) { + echo "Detected supported format inline MIME type ({$mimeType})"; + // Handle PDF as inline data + $fileContent = file_get_contents($filePath); + $base64Content = base64_encode($fileContent); + $payloadPart = [ + "inlineData" => [ + "mimeType" => $mimeType, + "data" => $base64Content + ] + ]; + + $content_parts = [ + "parts" => [ + $text_part, + $payloadPart + ] + ]; + } else { + // Handle Excel/CSV using the Files API + echo "Detected unsupported inline MIME type ({$mimeType}). Uploading via Files API...\n"; + $fileInfo = $this->uploadFileToGemini($filePath, $apiKey); // Pass apiKey + + print_r($fileInfo); + // The file part, using the URI from the Files API upload + $file_part = [ + "fileData" => [ + "fileUri" => $fileInfo['uri'], + "mimeType" => $fileInfo['mimeType'] + ] + ]; + + // The full content array, containing both parts + $content_parts = [ + "parts" => [ + $text_part, + $file_part + ] + ]; + } + + + + + + // The final JSON payload + $data = [ + "contents" => [ + $content_parts + ] + ]; + + // Encode the data to a JSON string + $json_data = json_encode($data); + + // Initialize cURL + $ch = curl_init($url); + + // Set cURL options + curl_setopt($ch, CURLOPT_HTTPHEADER, array('Content-Type: application/json')); // Set the Content-Type header + curl_setopt($ch, CURLOPT_POSTFIELDS, $json_data); // Set the JSON payload + curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); // Return the response as a string + curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false); // Optional: to bypass SSL verification if needed (not recommended for production) + + // Execute the cURL request and get the response + $response = curl_exec($ch); + + // Check for cURL errors + if (curl_errno($ch)) { + echo 'cURL Error: ' . curl_error($ch); + } + + // Close the cURL handle + curl_close($ch); + + // Decode the JSON response + $responseData = json_decode($response, true); + echo '
';
+                print_r($responseData);
+            echo '
';
+            // Check if the response contains generated text
+            if (isset($responseData['candidates'][0]['content']['parts'][0]['text'])) {
+                $generatedText = $responseData['candidates'][0]['content']['parts'][0]['text'];
+                echo "Generated Text: " . $generatedText;
+            } else {
+                echo "Error or no text generated. Response: " . $response;
+            }
 
-        print_rr($data);
     }
 
+    
+
+// Function to upload a file to the Gemini Files API
+function uploadFileToGemini($filePath, $apiKey)
+{
+    // Define the URL for the Files API upload
+    $uploadUrl = "https://generativelanguage.googleapis.com/upload/v1beta/files?key={$apiKey}";
+
+    // Get file info
+    $finfo = finfo_open(FILEINFO_MIME_TYPE);
+    $fileMimeType = finfo_file($finfo, $filePath);
+    finfo_close($finfo);
+
+    $displayName = basename($filePath);
+
+    // Build the request body for the Files API
+    $fileUploadData = [
+        'file' => [
+            'display_name' => $displayName,
+        ],
+    ];
+    $jsonUploadData = json_encode($fileUploadData);
+
+    // Initialize cURL for the upload
+    $ch_upload = curl_init();
+    curl_setopt($ch_upload, CURLOPT_URL, $uploadUrl);
+    curl_setopt($ch_upload, CURLOPT_RETURNTRANSFER, true);
+    curl_setopt($ch_upload, CURLOPT_POST, true);
+
+    // Use CURLFile for multipart/form-data upload
+    $payload = [
+        'metadata' => $jsonUploadData,
+        'file' => new \CURLFile($filePath, $fileMimeType, $displayName),
+    ];
+
+    curl_setopt($ch_upload, CURLOPT_POSTFIELDS, $payload);
+    curl_setopt($ch_upload, CURLOPT_HTTPHEADER, [
+        'X-Goog-Upload-Protocol: multipart',
+    ]);
+    curl_setopt($ch_upload, CURLOPT_SSL_VERIFYPEER, false); // Optional: not for production
+
+    // Execute the upload request
+    $uploadResponse = curl_exec($ch_upload);
+
+    if (curl_errno($ch_upload)) {
+        die('cURL Error (Files API): ' . curl_error($ch_upload));
+    }
+
+    curl_close($ch_upload);
+
+    $uploadResponseData = json_decode($uploadResponse, true);
+
+    // Check for a successful upload and return the file URI
+    if (!isset($uploadResponseData['file']['uri'])) {
+        die("Error uploading file. Response: " . $uploadResponse);
+    }
+
+    return [
+        'uri' => $uploadResponseData['file']['uri'],
+        'mimeType' => $fileMimeType
+    ];
+}
+
+
+public function convertToPdf($inputFile = null)
+    {
+        // 1. Load your Excel file
+        $inputFile = 'C:/Users/Venba/Desktop/ins stmts/Raheja June-2025.xlsx';
+        // $inputFile = 'C:/Users/Venba/Desktop/ins stmts/pdf/sample.pdf';
+        $spreadsheet = IOFactory::load($inputFile);
+        
+        // 2. Initialize mPDF with proper configuration
+        $mpdf = new Mpdf([
+            'mode' => 'utf-8',
+            'format' => 'A4',
+            'margin_header' => 5,
+            'margin_footer' => 5,
+            'orientation' => 'L',
+            'default_font_size' => 18,
+            // 'default_font' => 'Arial'
+        ]);
+        
+        // 3. Process each worksheet
+        foreach ($spreadsheet->getWorksheetIterator() as $worksheet) {
+            // Get HTML representation of the sheet
+            $html = $this->worksheetToHtml($worksheet);
+            // print_r($html);
+            // Add to PDF
+            $mpdf->AddPage();
+            $mpdf->WriteHTML($html);
+        }
+        $pdfPath = 'C:/Users/Venba/Desktop/ins stmts/pdf/2.pdf';
+        // $pdfPath = WRITEPATH.'tmp';
+        $mpdf->Output($pdfPath, \Mpdf\Output\Destination::FILE); // Save file on server
+        // 4. Output
+        // $mpdf->Output('financial_report.pdf', 'D');
+    }
+
+
+    
+
+    protected function worksheetToHtml($worksheet)
+    {
+        // Customize this based on your needs
+        $html = '

' . htmlspecialchars($worksheet->getTitle()) . '

'; + $html .= ''; + + foreach ($worksheet->getRowIterator() as $row) { + $html .= ''; + $cellIterator = $row->getCellIterator(); + $cellIterator->setIterateOnlyExistingCells(true); + + foreach ($cellIterator as $cell) { + $value = $cell->getValue(); + + // ✅ Detect and format Excel date cells + if (Date::isDateTime($cell)) { + $formattedValue = Date::excelToDateTimeObject($value)->format('Y-m-d'); + } else { + $formattedValue = $cell->getCalculatedValue(); + } + + $html .= ''; + } + + $html .= ''; + } + + $html .= '
' . htmlspecialchars($formattedValue) . '
'; + return $html; + } + + + } diff --git a/app/Controllers/JobWorker.php b/app/Controllers/JobWorker.php index 4cbf5350..7136c017 100755 --- a/app/Controllers/JobWorker.php +++ b/app/Controllers/JobWorker.php @@ -143,6 +143,18 @@ class JobWorker extends AdminController 'type' => 'CC', // Handler Category 'handler' => 'App\Controllers\ClientController', ], + 'claimDumpExcelFileFormatValidation' => [ + 'type' => 'CC', // Handler Category + 'handler' => 'App\Controllers\TicketServiceController', + ], + 'claimDumpExcelFileDataValidation' => [ + 'type' => 'CC', // Handler Category + 'handler' => 'App\Controllers\TicketServiceController', + ], + 'claimDumpOnBoardProcess' => [ + 'type' => 'CC', // Handler Category + 'handler' => 'App\Controllers\TicketServiceController', + ], ]; diff --git a/app/Controllers/LeadsController.php b/app/Controllers/LeadsController.php index 4d7e2170..fc4a4e86 100644 --- a/app/Controllers/LeadsController.php +++ b/app/Controllers/LeadsController.php @@ -2080,95 +2080,102 @@ class LeadsController extends BaseController if (!$lead_data) { return ['status' => 'failed', 'message' => 'Lead data not found']; } - if ($lead_data['file_name']) { - // $file_name_with_path = WRITEPATH . "/uploads/lead_files/NonPrintableCharacters.xlsx"; - //check physical file - if (!file_exists($file_name_with_path)) { - //file not found update status and reason - $message = "Lead Physcial file not found"; - // echo $message; - $this->myLogger->logme('error', ($message . ' for file ' . $file_name_with_path)); - return ['status' => 'failed', 'message' => 'no physical file']; - } + try{ + if ($lead_data['file_name']) { + // $file_name_with_path = WRITEPATH . "/uploads/lead_files/NonPrintableCharacters.xlsx"; - $spreadsheet = \PhpOffice\PhpSpreadsheet\IOFactory::load($file_name_with_path); - - //get members data - $members_sheet = $spreadsheet->getSheet(0); - $highestRowAndColumn = $members_sheet->getHighestRowAndColumn(); - // dd($highestRowAndColumn); - $uncleaned_members = $members_sheet->rangeToArray('A1:' . $highestRowAndColumn['column'] . $highestRowAndColumn['row']); - $members = ExcelSanitizeHelper::sanitizeArrayData($uncleaned_members); - //get age band data - $age_band_sheet = $spreadsheet->getSheet(1); - $highestRowAndColumn = $age_band_sheet->getHighestRowAndColumn(); - $age_band_data = $age_band_sheet->rangeToArray('A1:' . $highestRowAndColumn['column'] . $highestRowAndColumn['row']); - - - //check age or dob column - $members_heading = $members[0]; - $available_col = null; - $col_index = null; - - if (in_array('age', array_map('strtolower', $members_heading))) { - $available_col = 'age'; - $col_index = array_search('age', array_map('strtolower', $members_heading)); - } elseif (in_array('dob', array_map('strtolower', $members_heading))) { - $available_col = 'dob'; - $col_index = array_search('dob', array_map('strtolower', $members_heading)); - } - - if ($available_col == null) { - $message = 'No DOB or Age column '; - $this->myLogger->logme('error', ($message . $file_name_with_path)); - return ['status' => 'failed', 'message' => $message]; - } - - try { - $classifiers = $this->getDemographyData($members, $age_band_data, $members_heading, $available_col, $col_index); - } catch (Exception $e) { - return ['status' => 'fail', 'message' => $e->getMessage()]; - } - - //for this to view the demography in the RFQ and QCR page to using internal - if($returnType == "internal"){ - return ['data' => $classifiers]; - // print_rr($classifiers); die; - } - - - try { - $result = $this->generateClassifierSpreadsheet($classifiers, WRITEPATH . 'uploads/lead_files/'); - if ($result['success']) { - $this->myLogger->logme('error', "Spreadsheet generated successfully!"); - - echo "Location: " . $result['fullpath'] . "\n"; - echo "Filename: " . $result['filename'] . "\n"; - $filePaths = [ - ['file_path' => WRITEPATH . 'uploads/lead_files/' . $lead_data['file_name'], 'sheets' => [0, 1]], - ['file_path' => WRITEPATH . '/uploads/lead_files/' . $result['filename'], 'sheets' => []], - ]; - $outputPath = WRITEPATH . 'uploads/lead_files/' . $lead_data['file_name']; - $result_merge = ExcelMergeHelper::mergeExcelFiles($filePaths, $outputPath); - if ($result_merge) { - // Call the delete function after the file is successfully created - $deleteResponse = $this->deleteGeneratedFile($result['fullpath']); - - // Add delete message to response - $response['deleteMessage'] = $deleteResponse['message']; - return ['status' => 'success', 'message' => 'Member_Data Merged Suceesfully']; - } - } else { - echo "Error generating spreadsheet: " . $result['error']; + //check physical file + if (!file_exists($file_name_with_path)) { + //file not found update status and reason + $message = "Lead Physcial file not found"; + // echo $message; + $this->myLogger->logme('error', ($message . ' for file ' . $file_name_with_path)); + return ['status' => 'failed', 'message' => 'no physical file']; } - } catch (Exception $e) { - echo "Error: " . $e->getMessage(); - return ['status' => 'fail', 'message' => $e->getMessage()]; + + $spreadsheet = \PhpOffice\PhpSpreadsheet\IOFactory::load($file_name_with_path); + + //get members data + $members_sheet = $spreadsheet->getSheet(0); + $highestRowAndColumn = $members_sheet->getHighestRowAndColumn(); + // dd($highestRowAndColumn); + $uncleaned_members = $members_sheet->rangeToArray('A1:' . $highestRowAndColumn['column'] . $highestRowAndColumn['row']); + $members = ExcelSanitizeHelper::sanitizeArrayData($uncleaned_members); + //get age band data + $age_band_sheet = $spreadsheet->getSheet(1); + $highestRowAndColumn = $age_band_sheet->getHighestRowAndColumn(); + $age_band_data = $age_band_sheet->rangeToArray('A1:' . $highestRowAndColumn['column'] . $highestRowAndColumn['row']); + + + //check age or dob column + $members_heading = $members[0]; + $available_col = null; + $col_index = null; + + if (in_array('age', array_map('strtolower', $members_heading))) { + $available_col = 'age'; + $col_index = array_search('age', array_map('strtolower', $members_heading)); + } elseif (in_array('dob', array_map('strtolower', $members_heading))) { + $available_col = 'dob'; + $col_index = array_search('dob', array_map('strtolower', $members_heading)); + } + + if ($available_col == null) { + $message = 'No DOB or Age column '; + $this->myLogger->logme('error', ($message . $file_name_with_path)); + return ['status' => 'failed', 'message' => $message]; + } + + try { + $classifiers = $this->getDemographyData($members, $age_band_data, $members_heading, $available_col, $col_index); + } catch (Exception $e) { + return ['status' => 'fail', 'message' => $e->getMessage()]; + } + + //for this to view the demography in the RFQ and QCR page to using internal + if($returnType == "internal"){ + return ['data' => $classifiers]; + // print_rr($classifiers); die; + } + + + try { + $result = $this->generateClassifierSpreadsheet($classifiers, WRITEPATH . 'uploads/lead_files/'); + if ($result['success']) { + $this->myLogger->logme('error', "Spreadsheet generated successfully!"); + + echo "Location: " . $result['fullpath'] . "\n"; + echo "Filename: " . $result['filename'] . "\n"; + $filePaths = [ + ['file_path' => WRITEPATH . 'uploads/lead_files/' . $lead_data['file_name'], 'sheets' => [0, 1]], + ['file_path' => WRITEPATH . '/uploads/lead_files/' . $result['filename'], 'sheets' => []], + ]; + $outputPath = WRITEPATH . 'uploads/lead_files/' . $lead_data['file_name']; + $result_merge = ExcelMergeHelper::mergeExcelFiles($filePaths, $outputPath); + if ($result_merge) { + // Call the delete function after the file is successfully created + $deleteResponse = $this->deleteGeneratedFile($result['fullpath']); + + // Add delete message to response + $response['deleteMessage'] = $deleteResponse['message']; + return ['status' => 'success', 'message' => 'Member_Data Merged Suceesfully']; + } + } else { + echo "Error generating spreadsheet: " . $result['error']; + } + } catch (Exception $e) { + echo "Error: " . $e->getMessage(); + return ['status' => 'fail', 'message' => $e->getMessage()]; + } + } else { + $this->myLogger->logme('error', (' no file found ' . $file_name_with_path)); + return ['status' => 'failed', 'message' => 'no file found']; } - } else { - $this->myLogger->logme('error', (' no file found ' . $file_name_with_path)); - return ['status' => 'failed', 'message' => 'no file found']; + + }catch(Exception $e){ + $this->myLogger->logme("error", "Exception: " . $e->getMessage() . " --- Line: " . $e->getLine() . " --- Trace: " . $e->getTraceAsString()); + return ['status' => 'fail', 'error' => "File not found / Wrong file"]; } } diff --git a/app/Controllers/PolicyTransactionController.php b/app/Controllers/PolicyTransactionController.php index d6bc5167..9f7d7341 100644 --- a/app/Controllers/PolicyTransactionController.php +++ b/app/Controllers/PolicyTransactionController.php @@ -995,8 +995,16 @@ class PolicyTransactionController extends BaseController if ($id) { $data['is_active'] = 0; - $this->policyTransactionModel->where('id', $id)->set($data)->update(); - $this->PTCOShareDetailsModel->where('pt_id', $id)->set($data)->update(); + $policy_transaction_data = $this->policyTransactionModel->where('id', $id)->first(); + if($policy_transaction_data['policy_type_id'] > 7){ + + $this->policyTransactionModel->where('id', $id)->set($data)->update(); + $this->PTCOShareDetailsModel->where('pt_id', $id)->set($data)->update(); + $this->clientPolicyModel->where('id', $policy_transaction_data['client_policy_id'])->set($data)->update(); + }else{ + $this->policyTransactionModel->where('id', $id)->set($data)->update(); + $this->PTCOShareDetailsModel->where('pt_id', $id)->set($data)->update(); + } return $this->respond(['status' => true, 'code' => 200, 'message' => 'Policy Transaction removed successfully'], 200); } else { diff --git a/app/Controllers/ThzController.php b/app/Controllers/ThzController.php index 590e8f78..059ebfce 100644 --- a/app/Controllers/ThzController.php +++ b/app/Controllers/ThzController.php @@ -3,11 +3,17 @@ namespace App\Controllers; use App\Controllers\BaseController; +use App\Helpers\MailHelper; use CodeIgniter\HTTP\ResponseInterface; use App\Models\ThzMasterModel; use App\Models\ThzMasterNotesModel; use App\ControllerCleaners\ThzControllerCleaner; +use App\Models\UserModel; +use App\Models\ClientPolicyModel; +use App\Models\ClientModel; +use App\Models\TicketMailTemplateModel; + class ThzController extends BaseController { @@ -17,11 +23,21 @@ class ThzController extends BaseController protected $thzControllerCleaner; + protected $userModel; + protected $clientPolicyModel; + protected $clientModel; + + protected $ticketMailTemplateModel; + public function __construct() { - $this->thzMasterModel = new ThzMasterModel(); - $this->thzMasterNotesModel = new ThzMasterNotesModel(); - $this->thzControllerCleaner = new ThzControllerCleaner(); + $this->thzMasterModel = new ThzMasterModel(); + $this->thzMasterNotesModel = new ThzMasterNotesModel(); + $this->thzControllerCleaner = new ThzControllerCleaner(); + $this->userModel = new UserModel(); + $this->clientPolicyModel = new ClientPolicyModel(); + $this->clientModel = new ClientModel(); + $this->ticketMailTemplateModel = new TicketMailTemplateModel(); } public function index() @@ -29,140 +45,433 @@ class ThzController extends BaseController // } - public function ticketCreation(){ + public function ticketSave(){ - $data = $this->request->getJSON(true); + $data = $this->request->getPost(); - $cleanedData = $this->thzControllerCleaner->ticketCreation($data); + if (!empty($data['thz_id'])) { + + $text = "update"; + $result = $this->updateTicket($data); + $updateID = $data['thz_id']; + + } else { + + $text = "create"; + $insertID = $this->insertTicket($data); + $result = true; - if ($cleanedData === false) { - return $this->response->setJSON((['status' => 'error', 'message' => 'Invalid data given'])); } - $result = $this->thzMasterModel->insert($cleanedData); + $id = isset($insertID) && !empty($insertID) ? $insertID : $updateID ; - return $this->response->setJSON((['status' => 'success', 'message' => 'Ticket created successfully'])); + $emailNotificationResult = $this->ticketSaveNotification($data , $insertOrUpdate = $text , $id); + return $this->response->setJSON([ + 'status' => $result ? 'success' : 'error', + 'message' => $result ? "Ticket {$text}d successfully " : "Unable to {$text} ticket. Please try again." , + 'notification' => $emailNotificationResult ? 'Email Notification Success..!!' : 'Email Notification Failed..!!' + ])->setStatusCode($result ? 200 : 400); } + + public function ticketList() + { - public function ticketList(){ - - $data = $this->request->getJson(true); - - $cleanedData = $this->thzControllerCleaner->ticketList($data); - - if( $cleanedData === false ) { - return $this->response->setJSON((['status' => 'error', 'message' => 'Invalid data given'])); - } - - $id = $cleanedData['id'] ?? null; - - if (empty($id)) { - $result = $this->thzMasterModel->findAll(); - } - - $result = $this->thzMasterModel->where('id',$id)->findAll(); - - if(empty($result)){ - return $this->response->setJSON((['status' => 'error', 'message' => 'No tickets found'])); - } - - return $this->response->setJSON((['status' => 'success', 'data' => $result])); + $returnType = strtolower($this->request->getGet('return_type') ?? 'api'); + + $data = $this->request->getGet(); + + $tickets = $this->fetchTicketsBasedOnrole($data); + + + if ($returnType === 'api') { + if (empty($tickets)) { + return $this->response->setJSON([ 'status' => 'error','message' => 'No tickets found'])->setStatusCode(404); + } + }else{ + + $data['page_name'] = "Ticket List"; + $data['ticket_data'] = $tickets; + $data['assignee'] = $this->userModel->where('is_active', 1)->whereIn('role', ['2', '3','4'])->findAll(); // enga 5-"head" and 1-"admin" assign pannvaga so dropdown la varakudhathu + // 2,3,4 remain person varannum. + $data['client_list'] = $this->clientModel->getCreatedByUserName(); + + return $this->loadLayout('thz_list', $data); + } + + return $this->response->setJSON([ + 'status' => 'success', + 'data' => $tickets, + ])->setStatusCode(200); } public function ticketConversationSave(){ - $data = $this->request->getJson(true); + $data = $this->request->getPost(); - $cleanedData = $this->thzControllerCleaner->ticketList($data); - - if( $cleanedData === false ) { - return $this->response->setJSON((['status' => 'error', 'message' => 'Invalid data given'])); - } + $data['notes_type'] = $data['notes_type'] ?? 'External' ; $result = $this->thzMasterNotesModel->insert($data); - if(empty($result)){ - return $this->response->setJSON((['status' => 'error', 'message' => 'No tickets found'])); - } + if(empty($result)){ + return $this->response->setJSON((['status' => 'error', 'message' => 'No tickets found']))->setStatusCode(404); + } - return $this->response->setJSON((['status' => 'success', 'data' => $result])); + if($data['notes_type'] == "External"){ + $emailNotificationResult = $this->ticketConversationSaveNotification($data); + }else{ + $emailNotificationResult = false ; + } + + + return $this->response->setJSON([ + 'status' => $result ? 'success' : 'error', + 'message' => $result ? "Ticket Notes created successfully" : "Unable to create ticket notes. Please try again." , + 'notification' => $emailNotificationResult ? 'Email Notification Success..!!' : 'Email Notification Failed Or No Need..!!' + ])->setStatusCode($result ? 200 : 400); } - public function ticketListForUser(){ + public function ticketAutoFetchDetails(){ + $data = $this->request->getPost(); - $data = $this->request->getJson(true); + $client_id = $data['client_id']; + $mobile = $data['mobile']; - $cleanedData = $this->thzControllerCleaner->ticketList($data); + if($client_id && $mobile){ + + $details = $this->thzMasterModel->ticketAutoFetchDetails($client_id ,$mobile); + + if(empty($details)){ + return $this->response->setJSON((['status' => 'error', 'message' => 'No Data found']))->setStatusCode(400); + }else{ - if( $cleanedData === false ) { - return $this->response->setJSON((['status' => 'error', 'message' => 'Invalid data given'])); - } + $policyIds = array_column($details, 'policy_id'); + $policyIds = array_filter($policyIds); + $clientPolicy = $this->clientPolicyModel->whereIn('id', $policyIds)->where('is_active', 1)->get()->getResultArray(); + $result['client_details'] = $details; + $result['policy_details'] = empty($clientPolicy) ? [] : $clientPolicy ; - $result = $this->thzMasterNotesModel->insert($data); - - if(empty($result)){ - return $this->response->setJSON((['status' => 'error', 'message' => 'No tickets found'])); - } - - return $this->response->setJSON((['status' => 'success', 'data' => $result])); + } + }else{ + return $this->response->setJSON((['status' => 'error', 'message' => 'Client and Mobile Not found']))->setStatusCode(400); + } + + return $this->response->setJSON((['status' => 'success', 'data' => $result]))->setStatusCode(200); + } - public function conversationListForUserPerTicket(){ + public function ticketConversationList(){ - $data = $this->request->getJson(true); + $data = $this->request->getGet(); - $cleanedData = $this->thzControllerCleaner->ticketList($data); + $returnType = strtolower($this->request->getGet('return_type') ?? 'api'); - if( $cleanedData === false ) { - return $this->response->setJSON((['status' => 'error', 'message' => 'Invalid data given'])); - } + $thz_id = $data['thz_id'] ?? null; + + $ticketType = $data['notes_type'] ?? 'External' ; - $thz_id = $cleanedData['thz_id'] ?? null; + if($thz_id){ + $result['master'] = $this->thzMasterModel + ->select('thz_master.*, CONCAT(user_profiles.first_name, " ", user_profiles.last_name) as assignee_name') + ->join('user_profiles', 'user_profiles.id = thz_master.assign_to', 'left') + ->where('thz_master.thz_id', $thz_id) + ->findAll(); - $result = $this->thzMasterNotesModel->conversationListForUserPerTicket($thz_id); + if(!empty($result['master'])){ + $notes = $this->thzMasterNotesModel->ticketConversationList($thz_id, $returnType ); + $result['notes'] = !empty($notes) ? $notes : []; + }else{ + return $this->response->setJSON((['status' => 'error', 'message' => 'No tickets found']))->setStatusCode(400); + } + }else{ + return $this->response->setJSON((['status' => 'error', 'message' => 'No tickets found']))->setStatusCode(404); + } - if(empty($result)){ - return $this->response->setJSON((['status' => 'error', 'message' => 'No tickets found'])); - } + + + if ($returnType === 'api') { + return $this->response->setJSON((['status' => 'success', 'data' => $result]))->setStatusCode(200); + }else{ + $toGetCreatedBy = $result['master'][0]['created_by']; + $toGetPolicyId = (!empty($result['master'][0]['policy_id']) && strtolower($result['master'][0]['policy_id']) !== 'null') + ? $result['master'][0]['policy_id'] + : ''; - return $this->response->setJSON((['status' => 'success', 'data' => $result])); + $result['related_tickets'] = $this->thzMasterModel + ->select('thz_master.*, CONCAT(user_profiles.first_name, " ", user_profiles.last_name) as assignee_name') + ->join('user_profiles', 'user_profiles.id = thz_master.assign_to', 'left') + ->where('thz_master.created_by', $toGetCreatedBy) + ->findAll(); + $result['assignee'] = $this->userModel->where('is_active', 1)->whereIn('role', ['2', '3','4'])->findAll(); // enga 5-"head" and 1-"admin" assign pannvaga so dropdown la varakudhathu + // 2,3,4 remain person varannum. + $result['policy_terms'] = $toGetPolicyId ? $this->getPolicyTerms($toGetPolicyId) : ''; + return $this->loadLayout('thz_notes', $result); + } } - public function ticketListForAssignedStaff(){ - - } - - public function conversationListForAssignedStaffPerTicket(){ - - } - - - /************************************************** PRIVATE FUNCTIONS ********************************************************/ - private function checkGeneralUserOrEmployee($data){ + private function fetchTicketsBasedOnrole(array $data): array + { + // $id = $data['thz_id'] ?? null; + $assign_to = $data['assign_to'] ?? null; + $mobile = $data['mobile'] ?? null; - if($data['empcode']){ - return $data['empcode']; - } elseif ($data['mobile']) { - return $data['mobile']; - } elseif ($data['email']) { - return $data['email']; - } else { - return null; + if (!empty($assign_to)) { + // Tickets assigned to a staff + return $this->thzMasterModel + ->select('thz_master.*, CONCAT(user_profiles.first_name, " ", user_profiles.last_name) as assignee_name') + ->join('user_profiles', 'user_profiles.id = thz_master.assign_to', 'left') + ->where('thz_master.assign_to', $assign_to) + ->orderBy('thz_master.created_at','desc') + ->findAll(); } + // if (!empty($id) && !empty($mobile)) { + if (!empty($mobile)) { + // Specific ticket by ID and mobile + return $this->thzMasterModel + ->select('thz_master.*, CONCAT(user_profiles.first_name, " ", user_profiles.last_name) as assignee_name') + ->join('user_profiles', 'user_profiles.id = thz_master.assign_to', 'left') + // ->where('thz_id', $id) + ->where('thz_master.mobile', $mobile) + ->orderBy('thz_master.created_at','desc') + ->findAll(); + } + + // All tickets (e.g., for managers) + return $this->thzMasterModel + ->select('thz_master.*, CONCAT(user_profiles.first_name, " ", user_profiles.last_name) as assignee_name') + ->join('user_profiles', 'user_profiles.id = thz_master.assign_to', 'left') + ->orderBy('thz_master.created_at','desc') + ->findAll(); } + private function ticketSaveNotification( $data , $insertOrUpdate , $id){ + + $user_email = $data['email'] ?? null; + + $assignee_id = $data['assign_to'] ?? null; + + $assignee_email = $this->findAssigneeEmail($assignee_id); + + $emailToNotified = [ + 'user_email' => $user_email, + 'assignee_email' => $assignee_email + ]; + + $ticketId = $id; + + $result = $this->ticketSaveEmailNotificationBasedOnRole($emailToNotified , $insertOrUpdate , $ticketId , $data); + + return $result; + + } + + private function ticketConversationSaveNotification($data){ + + $thz_id = $data['thz_id'] ; // thz is alias of ticket + + $data['subject'] = $this->findSubject($data['thz_id']); + + $assignee_id = $this->findAssigneeId($data['thz_id']) ; + + $user_email = $this->findUserEmail($data['thz_id']) ; + + $assignee_email = $this->findAssigneeEmail($assignee_id) ?? ''; + + $sender_mail = $data['notes_by'] == "User" ? $user_email : $assignee_email ; + $receiver_mail = $data['notes_by'] == "User" ? $assignee_email : $user_email ; + + $templateName = "ticket_conversation_save_notification"; + + $to_email = $receiver_mail; + + $ticketId = $thz_id; + + $message = $data['notes'] ?? ''; + + $this->sendEmail( $templateName, $data , $to_email , $ticketId , $message); + + return true; + + } + + + private function findAssigneeEmail($assignee_id){ + + $row = $this->userModel->where('id', $assignee_id)->get()->getRow(); + $assigneeEmail = $row ? $row->email : null; + return $assigneeEmail ? $assigneeEmail : ""; + + } + + private function findAssigneeId($ticketId){ + $row = $this->thzMasterModel->where('thz_id', $ticketId)->get()->getRow(); + $assigneeId = $row ? $row->assign_to : null; + return $assigneeId ? $assigneeId : 0 ; + } + + private function findUserEmail($ticket_id){ + $row = $this->thzMasterModel->where('thz_id', $ticket_id)->get()->getRow(); + $email = $row ? $row->email : null; + return $email ? $email : " " ; + } + + private function findSubject($ticketId){ + $row = $this->thzMasterModel->where('thz_id', $ticketId)->get()->getRow(); + $subject = $row ? $row->subject : null; + return $subject ? $subject : " " ; + } + + private function ticketSaveEmailNotificationBasedOnRole($emailToNotified , $insertOrUpdate , $ticketId , $data){ + + $user_email = $emailToNotified['user_email'] ?? null; + $assignee_email = $emailToNotified['assignee_email'] ?? null; + + + if (!empty($assignee_email)) { + + switch ($insertOrUpdate) { + + case 'update': + + $this->sendEmail( 'ticket_save_update_assignee', $data ,$assignee_email , $ticketId ) ; + + break; + + case 'create': + + $this->sendEmail( 'ticket_save_create_assignee', $data ,$assignee_email , $ticketId ) ; + + break; + + default: + # code... + break; + } + + } + + if (!empty($user_email)) { + + switch ($insertOrUpdate) { + + case 'update': + + if(empty($assignee_email)){ + $data['assigneeAndStatus'] = "Not Yet Assigned"; + $this->sendEmail( 'ticket_save_update_user', $data ,$user_email , $ticketId ) ; + }else{ + $data['assigneeAndStatus'] = "Assigned With {$assignee_email}"; + $this->sendEmail( 'ticket_save_update_user', $data ,$user_email , $ticketId ) ; + } + + break; + + case 'create': + + if(empty($assignee_email)){ + $this->sendEmail( 'ticket_save_create_user_unassigned', $data ,$user_email , $ticketId ) ; + }else{ + $data['assignee_email'] = $assignee_email ; + $this->sendEmail( 'ticket_save_create_user_assigned', $data , $user_email , $ticketId ) ; + } + + break; + + default: + # code... + break; + } + + } + + return true; + + + } + + private function updateTicket($data){ + + $data['updated_by'] = get_session_userid(); + $ticket_id = $data['thz_id']; + $result = $this->thzMasterModel->where('thz_id', $ticket_id)->set($data)->update(); + + return $result; + + } + + private function insertTicket($data) + { + $data['created_by'] = get_session_userid(); + $this->thzMasterModel->insert($data); + + return $this->thzMasterModel->insertID(); // returns the inserted row's ID + } + + + private function sendEmail( $templateName, $data , $to_email , $ticketId , $message = ""){ + + $mailTemplate = $this->ticketMailTemplateModel->where('template_name',$templateName )->findAll()[0] ?? []; + + if(empty($mailTemplate)){ + return ; + } + + $mailTemplate['subject'] = str_replace('%subject%', $data['subject'] ?? '', $mailTemplate['subject']); + + $mailTemplate['mail_content'] = str_replace('%subject%', $data['subject'] ?? '', $mailTemplate['mail_content']); + + $mailTemplate['mail_content'] = str_replace('%ticketId%', $ticketId ?? '', $mailTemplate['mail_content']); + + $mailTemplate['mail_content'] = str_replace('%message%', $message ?? '', $mailTemplate['mail_content']); + + $mailTemplate['mail_content'] = str_replace('%assignee_email%', $data['assignee_email'] ?? '', $mailTemplate['mail_content']); + + $mailTemplate['mail_content'] = str_replace('%assigneeAndStatus%',$data['assigneeAndStatus'] ?? '' ,$mailTemplate['mail_content']); + + $from_mail = ""; + $to_mail = $to_email; + $cc_string = ""; + $subject = $mailTemplate['subject'] ; + $message = $mailTemplate['mail_content'] ; + $attachments = ""; + $reply_to = ""; + $bcc_string = ""; + + $res = MailHelper::send_email(['from_mail' => $from_mail, 'mail' => $to_mail , 'cc' => $cc_string, 'subject' => $subject, 'message' => $message, 'attachments' => $attachments, 'reply_to' => $reply_to, 'bcc' => $bcc_string]); + + } + + + public function getPolicyTerms($client_policy_id) + { + $policy_data = $this->clientPolicyModel->where('is_active', 1)->where('id', $client_policy_id)->first(); + + $policy_terms = []; + if(isset($policy_data['policy_terms']) && !empty($policy_data['policy_terms'])){ + + $raw_terms = json_decode($policy_data['policy_terms'] ?? [] , true) ?? []; + + $ticketController = new TicketController(); + $policy_terms = $ticketController->convertTermsToDisplay($raw_terms); + } + + $data['policy_terms'] = $policy_terms; + return view('view_policy_terms', $data); + } + + } + diff --git a/app/Controllers/TicketController.php b/app/Controllers/TicketController.php index 95a4bbe2..800f464b 100644 --- a/app/Controllers/TicketController.php +++ b/app/Controllers/TicketController.php @@ -21,6 +21,7 @@ use App\Models\InsurerModel; use App\Models\EmployeeModel; use App\Models\TPAModel; use App\Models\ClaimFilesModel; +use App\Models\ClaimDumpFileModel; use DOMDocument; use Psr\Log\LoggerInterface; @@ -60,6 +61,7 @@ class TicketController extends BaseController protected $insurerModel; protected $TPAModel; protected $claimFilesModel; + protected $claimDumpFileModel; public function __construct() { @@ -95,6 +97,7 @@ class TicketController extends BaseController 4 => "Smart Service Desk", 5 => "Direct to TPA" ]; + $this->claimType = [ 1 => [ 1 => "Main Hospitalization", @@ -344,6 +347,7 @@ class TicketController extends BaseController $this->insurerModel = new InsurerModel(); $this->TPAModel = new TPAModel(); $this->claimFilesModel = new ClaimFilesModel(); + $this->claimDumpFileModel = new ClaimDumpFileModel(); } public function ticketList() @@ -2382,17 +2386,20 @@ class TicketController extends BaseController } // 5. Merge the Sum Insured value if the multiple sum insured exists - if(isset($data['multiple_sum_insured'])){ - if($data['sumInsured2']){ - $data['sumInsured2'] = $data['sumInsured2'] . ", " . implode(", ", $data['multiple_sum_insured']); - }else{ - $data['sum_insured'] = $data['sum_insured'] . ", " . implode(", ", $data['multiple_sum_insured']); + if (isset($data['multiple_sum_insured'])) { + + $multipleSumInsured = is_array($data['multiple_sum_insured']) ? $data['multiple_sum_insured'] : [$data['multiple_sum_insured']]; // force into array if string + + if (isset($data['sumInsured2'])) { + $data['sumInsured2'] .= ", " . implode(", ", $multipleSumInsured); + } else { + $data['sum_insured'] .= ", " . implode(", ", $multipleSumInsured); } + unset($data['multiple_sum_insured']); } // 6. Add the special condition to key value pair - if(!empty($data['special_condition_label'])){ foreach ($data['special_condition_label'] as $key => $value) { if($value != "" && $value != null) { @@ -2444,6 +2451,154 @@ class TicketController extends BaseController } + // -------- CLAIM DUMP UPLOAD ---------------------------------------------------------------------------------------------- + + public function claimDumpUpload() + { + $data['page_name'] = "Claim Dupm Upload"; + + if($this->request->is('get')){ + + $data['claim_dump_file_data'] = $this->claimDumpFileModel + ->select(' + claim_dump_files.id as file_id, + claim_dump_files.file_name, + claim_dump_files.status, + claim_dump_files.created_at, + up.first_name as user_name + ') + ->join('user_profiles as up', 'claim_dump_files.created_by = up.id', 'left') + ->where('claim_dump_files.is_active', 1) + ->findAll(); + + return $this->loadLayout('claim_dump_file_list', $data); + + }else{ + + // print_r($this->request->getFile('claim_dump_list')); die; + $filename = ''; + $fileSize = ''; + + //validate uploaded file + $validated = $this->validate([ + 'claim_dump_list' => [ + 'uploaded[claim_dump_list]', + 'mime_in[claim_dump_list,application/vnd.ms-excel,application/vnd.openxmlformats-officedocument.spreadsheetml.sheet,application/vnd.oasis.opendocument.spreadsheet]', + 'max_size[claim_dump_list,16384]', + ], + ]); + + if ($validated) + { + $avatar = $this->request->getFile('claim_dump_list'); + if (!$avatar) { + $this->myLogger->logme("error", 'File not found'); + return $this->respond(['status' => false, 'code' => 400, 'message' => 'File not found'], 400); + } + + $is_moved = $avatar->move(WRITEPATH . 'uploads/claim_dump_excel/'); + + if ($is_moved) { + $filename = $avatar->getName(); + $fileSize = $avatar->getSize(); // File size in bytes + $fileSize = $fileSize / (1024 * 1024); // Convert to MB + + $this->myLogger->logme("error", 'File move successful'); + + } else { + $this->myLogger->logme("error", 'File move failed'); + return $this->respond(['status' => false, 'code' => 500, 'message' => 'File move failed'], 500); + } + + } else { + $this->myLogger->logme("error", 'Upload failed Invalid file'); + return $this->respond(['status' => false, 'code' => 404, 'message' => 'Invalid file'], 404); + } + + + $status = 'inprogress'; + $insert_data = [ + 'file_name' => $filename, + 'status' => $status + ]; + + $file_id = $this->claimDumpFileModel->insert($insert_data); + $this->myLogger->logme("error", 'claim_dumb_file_id : {file_id}, uploaded success', ['file_id' => $file_id]); + + //after file upload success than call the file formate validation in service controller + $ticketServiceController = new TicketServiceController(); + // $response = $ticketServiceController->claimDumpExcelFileFormatValidation(["file_id" => $file_id]); + $r = Jobs::addJob(['job_name' => 'claimDumpExcelFileFormatValidation', 'payload' => ['file_id' => $file_id]]); + + return $this->respond(['status' => true, 'code' => 200, 'message' => 'File uploaded successfully. File being validated'], 200); + + } + } + + public function getClaimDumpFileErrorData() + { + $file_id = $this->request->getGet('file_id'); + $file = $this->claimDumpFileModel->where('id', $file_id)->first(); + if (!isset($file)) { + return $this->respond(['status' => false, 'code' => 404, 'message' => 'No data found'], 200); + } else { + return $this->respond(['status' => true, 'code' => 200, 'data' => $file['reason']], 200); + } + } + + public function getClaimDumpExcelFileErrors($file_id) + { + // $file_id = $this->request->getGet('file_id'); + $ticketServiceController = new TicketServiceController(); + + // Render views and capture output + $result = $ticketServiceController->getClaimExcelErrorData($file_id) ?? []; + // dd($result); + + if ($result != 0) { + + $result['file_id'] = $file_id; + echo view('excel_errors', $result); + } else if ($result == 0) { + + $data['message'] = 'File Not Found Physically'; + return view('errors/404', $data); + } else { + + echo view('errors/html/production'); + } + } + + public function downloadClaimDumpFile($file_id) + { + // $actionType = $this->request->getGet(); + $file_data = $this->claimDumpFileModel->where('id', $file_id)->first(); + $fileName = $file_data['file_name']; + + $filePath = WRITEPATH . '/uploads/claim_dump_excel/' . $fileName; + + try { + + // Check if the file exists + if (file_exists($filePath)) { + // Set the appropriate MIME type + $mimeType = mime_content_type($filePath); + + // Send the file to the client for download + return $this->response->download($filePath, null, $mimeType); + } else { + + $data['message'] = 'The Physical File Not Found'; + echo view('errors/404', $data); + } + } catch (\Exception $e) { + // Handle any exceptions + $errorMessage = $e->getMessage(); + $this->myLogger->logme('error', $errorMessage); + // You can return an error response here + echo $errorMessage; + } + } } diff --git a/app/Controllers/TicketServiceController.php b/app/Controllers/TicketServiceController.php new file mode 100644 index 00000000..e6c137f4 --- /dev/null +++ b/app/Controllers/TicketServiceController.php @@ -0,0 +1,1800 @@ +myLogger = \Config\Services::mylogger(); + set_session_context('Ticket Service Controller'); + + $this->claimDumpFileModel = new ClaimDumpFileModel(); + $this->clientModel = new ClientModel(); + $this->insurerModel = new InsurerModel(); + $this->TPAModel = new TPAModel(); + $this->ticketClaimStatusModel = new TicketClaimStatusModel(); + $this->clientPolicyModel = new ClientPolicyModel(); + + $this->claim_dump_excel_columns = [ + + // Mandatory Fields + 'sno' => [ + 'col_idx' => 0, + 'col_cell_name' => 'A', + 'col_name' => 'S.No.', + 'is_mandatory' => true, + 'data_type' => 'int', + 'format' => null, + 'allowed_values' => null + ], + + 'policy_type' => [ + 'col_idx' => 1, + 'col_cell_name' => 'B', + 'col_name' => 'Policy Type', + 'is_mandatory' => true, + 'data_type' => 'str', + 'format' => null, + 'allowed_values' => ['GMC', 'GPA', 'EDLI', 'GTLI'] + ], + + 'status' => [ + 'col_idx' => 2, + 'col_cell_name' => 'C', + 'col_name' => 'Status', + 'is_mandatory' => true, + 'data_type' => 'str', + 'format' => null, + 'allowed_values' => null + ], + + 'client_short_name' => [ + 'col_idx' => 3, + 'col_cell_name' => 'D', + 'col_name' => 'Corporate Name', + 'is_mandatory' => true, + 'data_type' => 'str', + 'format' => null, + 'allowed_values' => null + ], + + 'insurer' => [ + 'col_idx' => 4, + 'col_cell_name' => 'E', + 'col_name' => 'Insurer', + 'is_mandatory' => true, + 'data_type' => 'str', + 'format' => null, + 'allowed_values' => null + ], + + 'tpa' => [ + 'col_idx' => 5, + 'col_cell_name' => 'F', + 'col_name' => 'TPA', + 'is_mandatory' => true, + 'data_type' => 'str', + 'format' => null, + 'allowed_values' => null + ], + + 'policy_no' => [ + 'col_idx' => 6, + 'col_cell_name' => 'G', + 'col_name' => 'Policy No', + 'is_mandatory' => true, + 'data_type' => 'str', + 'format' => null, + 'allowed_values' => null + ], + + 'employee_code' => [ + 'col_idx' => 7, + 'col_cell_name' => 'H', + 'col_name' => 'Employee Code', + 'is_mandatory' => true, + 'data_type' => 'str', + 'format' => null, + 'allowed_values' => null + ], + + 'employee_name' => [ + 'col_idx' => 8, + 'col_cell_name' => 'I', + 'col_name' => 'Employee Name', + 'is_mandatory' => true, + 'data_type' => 'str', + 'format' => null, + 'allowed_values' => null + ], + + 'insured_name' => [ + 'col_idx' => 9, + 'col_cell_name' => 'J', + 'col_name' => 'Insured Name', + 'is_mandatory' => true, + 'data_type' => 'str', + 'format' => null, + 'allowed_values' => null + ], + + 'relationship' => [ + 'col_idx' => 10, + 'col_cell_name' => 'K', + 'col_name' => 'Relationship', + 'is_mandatory' => true, + 'data_type' => 'str', + 'format' => null, + 'allowed_values' => ['Self', 'Spouse', 'Child', 'Parent', 'Other'] + ], + + 'mode_of_intimation' => [ + 'col_idx' => 11, + 'col_cell_name' => 'L', + 'col_name' => 'Mode of Intimation', + 'is_mandatory' => true, + 'data_type' => 'str', + 'format' => null, + 'allowed_values' => ['Email', 'Phone', 'Portal', 'Physical'] + ], + + 'acm' => [ + 'col_idx' => 12, + 'col_cell_name' => 'M', + 'col_name' => 'ACM', + 'is_mandatory' => false, + 'data_type' => 'str', + 'format' => null, + 'allowed_values' => null + ], + + 'claim_type' => [ + 'col_idx' => 13, + 'col_cell_name' => 'N', + 'col_name' => 'Claim Type', + 'is_mandatory' => true, + 'data_type' => 'str', + 'format' => null, + 'allowed_values' => null + ], + + 'priority' => [ + 'col_idx' => 14, + 'col_cell_name' => 'O', + 'col_name' => 'Priority', + 'is_mandatory' => true, + 'data_type' => 'str', + 'format' => null, + 'allowed_values' => ['Critical', 'Emergency', 'Urgent', 'High', 'Medium', 'Low'] + ], + + // Common Fields + 'date_of_birth' => [ + 'col_idx' => 15, + 'col_cell_name' => 'P', + 'col_name' => 'Date of Birth', + 'is_mandatory' => false, + 'data_type' => 'date', + 'format' => 'd-m-Y', + 'allowed_values' => null + ], + + 'employee_mobile' => [ + 'col_idx' => 16, + 'col_cell_name' => 'Q', + 'col_name' => 'Employee Mobile', + 'is_mandatory' => false, + 'data_type' => 'str', + 'format' => '/^[0-9]{10}$/', + 'allowed_values' => null + ], + + 'employee_email' => [ + 'col_idx' => 17, + 'col_cell_name' => 'R', + 'col_name' => 'Employee Email', + 'is_mandatory' => false, + 'data_type' => 'str', + 'format' => 'email', + 'allowed_values' => null + ], + + 'employee_personal_email' => [ + 'col_idx' => 18, + 'col_cell_name' => 'S', + 'col_name' => 'Employee Personal Email', + 'is_mandatory' => false, + 'data_type' => 'str', + 'format' => 'email', + 'allowed_values' => null + ], + + // GMC Specific Fields + 'hospital_name' => [ + 'col_idx' => 19, + 'col_cell_name' => 'T', + 'col_name' => 'Hospital Name', + 'is_mandatory' => false, + 'data_type' => 'str', + 'format' => null, + 'allowed_values' => null + ], + + 'doa' => [ + 'col_idx' => 20, + 'col_cell_name' => 'U', + 'col_name' => 'DOA (Date of Admission)', + 'is_mandatory' => false, + 'data_type' => 'date', + 'format' => 'd-m-Y', + 'allowed_values' => null + ], + + 'dod' => [ + 'col_idx' => 21, + 'col_cell_name' => 'V', + 'col_name' => 'DOD (Date of Discharge)', + 'is_mandatory' => false, + 'data_type' => 'date', + 'format' => 'd-m-Y', + 'allowed_values' => null + ], + + 'claim_amount' => [ + 'col_idx' => 22, + 'col_cell_name' => 'W', + 'col_name' => 'Claim Amount', + 'is_mandatory' => false, + 'data_type' => 'decimal', + 'format' => '2', + 'allowed_values' => null + ], + + 'pod_no' => [ + 'col_idx' => 23, + 'col_cell_name' => 'X', + 'col_name' => 'POD No.', + 'is_mandatory' => false, + 'data_type' => 'str', + 'format' => null, + 'allowed_values' => null + ], + + 'tpa_id' => [ + 'col_idx' => 24, + 'col_cell_name' => 'Y', + 'col_name' => 'TPA ID', + 'is_mandatory' => false, + 'data_type' => 'str', + 'format' => null, + 'allowed_values' => null + ], + + 'claim_number' => [ + 'col_idx' => 25, + 'col_cell_name' => 'Z', + 'col_name' => 'Claim Number', + 'is_mandatory' => false, + 'data_type' => 'str', + 'format' => null, + 'allowed_values' => null + ], + + // GPA Specific Fields + 'sum_insured' => [ + 'col_idx' => 26, + 'col_cell_name' => 'AA', + 'col_name' => 'Sum Insured', + 'is_mandatory' => false, + 'data_type' => 'decimal', + 'format' => '2', + 'allowed_values' => null + ], + + 'date_of_join' => [ + 'col_idx' => 27, + 'col_cell_name' => 'AB', + 'col_name' => 'Date of Join', + 'is_mandatory' => false, + 'data_type' => 'date', + 'format' => 'd-m-Y', + 'allowed_values' => null + ], + + 'date_of_inception' => [ + 'col_idx' => 28, + 'col_cell_name' => 'AC', + 'col_name' => 'Date of Inception', + 'is_mandatory' => false, + 'data_type' => 'date', + 'format' => 'd-m-Y', + 'allowed_values' => null + ], + + 'date_of_accident' => [ + 'col_idx' => 29, + 'col_cell_name' => 'AD', + 'col_name' => 'Date of Accident', + 'is_mandatory' => false, + 'data_type' => 'date', + 'format' => 'd-m-Y', + 'allowed_values' => null + ], + + 'date_of_death' => [ + 'col_idx' => 30, + 'col_cell_name' => 'AE', + 'col_name' => 'Date of Death', + 'is_mandatory' => false, + 'data_type' => 'date', + 'format' => 'd-m-Y', + 'allowed_values' => null + ], + + 'date_of_intimate' => [ + 'col_idx' => 31, + 'col_cell_name' => 'AF', + 'col_name' => 'Date of Intimate', + 'is_mandatory' => false, + 'data_type' => 'date', + 'format' => 'd-m-Y', + 'allowed_values' => null + ], + + // Status Wise Column Mandatory + 'raised_date' => [ + 'col_idx' => 32, + 'col_cell_name' => 'AG', + 'col_name' => 'Raised Date', + 'is_mandatory' => false, + 'data_type' => 'date', + 'format' => 'd-m-Y', + 'allowed_values' => null + ], + + 'registration_date' => [ + 'col_idx' => 33, + 'col_cell_name' => 'AH', + 'col_name' => 'Registration Date', + 'is_mandatory' => false, + 'data_type' => 'date', + 'format' => 'd-m-Y', + 'allowed_values' => null + ], + + 'query_received_date' => [ + 'col_idx' => 34, + 'col_cell_name' => 'AI', + 'col_name' => 'Query Received Date', + 'is_mandatory' => false, + 'data_type' => 'date', + 'format' => 'd-m-Y', + 'allowed_values' => null + ], + + 'payment_initiate_date' => [ + 'col_idx' => 35, + 'col_cell_name' => 'AJ', + 'col_name' => 'Payment Initiate Date', + 'is_mandatory' => false, + 'data_type' => 'date', + 'format' => 'd-m-Y', + 'allowed_values' => null + ], + + 'denial_reason' => [ + 'col_idx' => 36, + 'col_cell_name' => 'AK', + 'col_name' => 'Denial Reason', + 'is_mandatory' => false, + 'data_type' => 'str', + 'format' => null, + 'allowed_values' => null + ], + + 'denial_date' => [ + 'col_idx' => 37, + 'col_cell_name' => 'AL', + 'col_name' => 'Denial Date', + 'is_mandatory' => false, + 'data_type' => 'date', + 'format' => 'd-m-Y', + 'allowed_values' => null + ], + + 'approved_date' => [ + 'col_idx' => 38, + 'col_cell_name' => 'AM', + 'col_name' => 'Approved Date', + 'is_mandatory' => false, + 'data_type' => 'date', + 'format' => 'd-m-Y', + 'allowed_values' => null + ], + + 'approved_letter' => [ + 'col_idx' => 39, + 'col_cell_name' => 'AN', + 'col_name' => 'Approved Letter', + 'is_mandatory' => false, + 'data_type' => 'str', + 'format' => null, + 'allowed_values' => null + ], + + 'approved_amount' => [ + 'col_idx' => 40, + 'col_cell_name' => 'AO', + 'col_name' => 'Approved Amount', + 'is_mandatory' => false, + 'data_type' => 'decimal', + 'format' => '2', + 'allowed_values' => null + ], + + 'approved_description' => [ + 'col_idx' => 41, + 'col_cell_name' => 'AP', + 'col_name' => 'Approved Description', + 'is_mandatory' => false, + 'data_type' => 'str', + 'format' => null, + 'allowed_values' => null + ], + + 'utr_details' => [ + 'col_idx' => 42, + 'col_cell_name' => 'AQ', + 'col_name' => 'UTR Details', + 'is_mandatory' => false, + 'data_type' => 'str', + 'format' => null, + 'allowed_values' => null + ], + + 'settle_letter' => [ + 'col_idx' => 43, + 'col_cell_name' => 'AR', + 'col_name' => 'Settle Letter', + 'is_mandatory' => false, + 'data_type' => 'str', + 'format' => null, + 'allowed_values' => null + ], + + 'settled_date' => [ + 'col_idx' => 44, + 'col_cell_name' => 'AS', + 'col_name' => 'Settled Date', + 'is_mandatory' => false, + 'data_type' => 'date', + 'format' => 'd-m-Y', + 'allowed_values' => null + ], + + 'return_remark' => [ + 'col_idx' => 45, + 'col_cell_name' => 'AT', + 'col_name' => 'Return Remark', + 'is_mandatory' => false, + 'data_type' => 'str', + 'format' => null, + 'allowed_values' => null + ], + + 'cancel_remark' => [ + 'col_idx' => 46, + 'col_cell_name' => 'AU', + 'col_name' => 'Cancel Remark', + 'is_mandatory' => false, + 'data_type' => 'str', + 'format' => null, + 'allowed_values' => null + ], + + 'awb_courier' => [ + 'col_idx' => 47, + 'col_cell_name' => 'AV', + 'col_name' => 'AWB No. and Courier Name', + 'is_mandatory' => false, + 'data_type' => 'str', + 'format' => null, + 'allowed_values' => null + ], + + 'non_id_reason' => [ + 'col_idx' => 48, + 'col_cell_name' => 'AW', + 'col_name' => 'Non ID Reason', + 'is_mandatory' => false, + 'data_type' => 'str', + 'format' => null, + 'allowed_values' => null + ] + ]; + + $this->tableHeaders = [ + "S NO", + "POLICY #", + "Status", + "Account manager", + "Insurer", + "TPA", + "Corporate", + "Emp ID", + "TPA ID", + "Claim ID", + "Employee Name", + "Insured Name", + "Relationship", + "Emp. Mobile", + "Emp mail id", + "Claim Collection", + "Source Detail", + "Claim Type", + "Hospital", + "DOA", + "DOD", + "Claim Amount", + "Date of Claim Receipt", + "Date sent to TPA", + "Date of Claim Registration", + "Date - Latest Query Raise", + "Date - Latest Query Resolution", + "Approved Amt", + "Date of Approval", + "UTR - Settlement", + "Date of Settlement", + "Reason", + "Remarks", + "Approval Letter", + "Settlement Letter", + "Denial Letter", + ]; + + $this->actualHeaders = [ + + "sno" => [ + 'col_idx' => 0, + 'col_cell_name' => 'A', + 'col_name' => 'S NO', + 'is_mandatory' => true, + 'data_type' => 'int', + 'format' => null, + 'allowed_values' => null + ], + "corporate" => [ + 'col_idx' => 6, + 'col_cell_name' => 'G', + 'col_name' => 'Corporate', + 'is_mandatory' => true, + 'data_type' => 'string', + 'format' => null, + 'allowed_values' => null, + 'custom' => 'check_client', + 'params' => ['client_excel_name'] + ], + "policy_no" => [ + 'col_idx' => 1, + 'col_cell_name' => 'B', + 'col_name' => 'POLICY #', + 'is_mandatory' => true, + 'data_type' => 'string', + 'format' => null, + 'allowed_values' => null, + ], + "status" => [ + 'col_idx' => 2, + 'col_cell_name' => 'C', + 'col_name' => 'Status', + 'is_mandatory' => true, + 'data_type' => 'string', + 'format' => null, + 'allowed_values' => null, + 'custom' => 'check_status', + 'params' => ['excel_status_data'] + ], + "acm" => [ + 'col_idx' => 3, + 'col_cell_name' => 'D', + 'col_name' => 'Account manager', + 'is_mandatory' => false, + 'data_type' => 'string', + 'format' => null, + 'allowed_values' => null + ], + "insurer" => [ + 'col_idx' => 4, + 'col_cell_name' => 'E', + 'col_name' => 'Insurer', + 'is_mandatory' => true, + 'data_type' => 'string', + 'format' => null, + 'allowed_values' => null, + 'custom' => 'check_insurer', + 'params' => ['insurer_excel_name'] + ], + "tpa" => [ + 'col_idx' => 5, + 'col_cell_name' => 'F', + 'col_name' => 'TPA', + 'is_mandatory' => false, + 'data_type' => 'string', + 'format' => null, + 'allowed_values' => null, + 'custom' => 'check_tpa', + 'params' => ['tpa_excel_name'] + ], + "emp_id" => [ + 'col_idx' => 7, + 'col_cell_name' => 'H', + 'col_name' => 'Emp ID', + 'is_mandatory' => true, + 'data_type' => 'string', + 'format' => null, + 'allowed_values' => null + ], + "tpa_id" => [ + 'col_idx' => 8, + 'col_cell_name' => 'I', + 'col_name' => 'TPA ID', + 'is_mandatory' => false, + 'data_type' => 'string', + 'format' => null, + 'allowed_values' => null + ], + "claim_id" => [ + 'col_idx' => 9, + 'col_cell_name' => 'J', + 'col_name' => 'Claim ID', + 'is_mandatory' => false, + 'data_type' => 'string', + 'format' => null, + 'allowed_values' => null + ], + "employee_name" => [ + 'col_idx' => 10, + 'col_cell_name' => 'K', + 'col_name' => 'Employee Name', + 'is_mandatory' => true, + 'data_type' => 'string', + 'format' => null, + 'allowed_values' => null + ], + "insured_name" => [ + 'col_idx' => 11, + 'col_cell_name' => 'L', + 'col_name' => 'Insured Name', + 'is_mandatory' => true, + 'data_type' => 'string', + 'format' => null, + 'allowed_values' => null + ], + "relationship" => [ + 'col_idx' => 12, + 'col_cell_name' => 'M', + 'col_name' => 'Relationship', + 'is_mandatory' => true, + 'data_type' => 'string', + 'format' => null, + 'allowed_values' => ['self', 'spouse', 'son', 'daughter', 'father', 'mother', 'father-in-law', 'mother-in-law'] + ], + "emp_mobile" => [ + 'col_idx' => 13, + 'col_cell_name' => 'N', + 'col_name' => 'Emp. Mobile', + 'is_mandatory' => false, + 'data_type' => 'string', + 'format' => 'phone', + 'allowed_values' => null + ], + "emp_email" => [ + 'col_idx' => 14, + 'col_cell_name' => 'O', + 'col_name' => 'Emp mail id', + 'is_mandatory' => false, + 'data_type' => 'string', + 'format' => 'email', + 'allowed_values' => null + ], + "claim_collection" => [ + 'col_idx' => 15, + 'col_cell_name' => 'P', + 'col_name' => 'Claim Collection', + 'is_mandatory' => true, + 'data_type' => 'string', + 'format' => null, + 'allowed_values' => ["In Person", "Courier", "Online Mode - Email", "Smart Service Desk", "Direct to TPA"] + ], + "source_detail" => [ + 'col_idx' => 16, + 'col_cell_name' => 'Q', + 'col_name' => 'Source Detail', + 'is_mandatory' => false, + 'data_type' => 'string', + 'format' => null, + 'allowed_values' => null + ], + "claim_type" => [ + 'col_idx' => 17, + 'col_cell_name' => 'R', + 'col_name' => 'Claim Type', + 'is_mandatory' => true, + 'data_type' => 'string', + 'format' => null, + 'allowed_values' => ["Claim", "Main Hospitalization", "Pre / Post", "OPD", "ReOpen", "TTD", "PTD", "PPD", "Death"] + ], + "hospital" => [ + 'col_idx' => 18, + 'col_cell_name' => 'S', + 'col_name' => 'Hospital', + 'is_mandatory' => false, + 'data_type' => 'string', + 'format' => null, + 'allowed_values' => null + ], + "doa" => [ + 'col_idx' => 19, + 'col_cell_name' => 'T', + 'col_name' => 'DOA', + 'is_mandatory' => false, + 'data_type' => 'date', + 'format' => 'm/d/Y', + 'allowed_values' => null + ], + "dod" => [ + 'col_idx' => 20, + 'col_cell_name' => 'U', + 'col_name' => 'DOD', + 'is_mandatory' => false, + 'data_type' => 'date', + 'format' => 'm/d/Y', + 'allowed_values' => null + ], + "claim_amount" => [ + 'col_idx' => 21, + 'col_cell_name' => 'V', + 'col_name' => 'Claim Amount', + 'is_mandatory' => false, + 'data_type' => 'str', + 'format' => null, + 'allowed_values' => null + ], + "date_claim_receipt" => [ + 'col_idx' => 22, + 'col_cell_name' => 'W', + 'col_name' => 'Date of Claim Receipt', + 'is_mandatory' => false, + 'data_type' => 'date', + 'format' => 'm/d/Y', + 'allowed_values' => null + ], + "date_claim_registration" => [ + 'col_idx' => 24, + 'col_cell_name' => 'Y', + 'col_name' => 'Date of Claim Registration', + 'is_mandatory' => false, + 'data_type' => 'date', + 'format' => 'm/d/Y', + 'allowed_values' => null + ], + "date_latest_query_raise" => [ + 'col_idx' => 25, + 'col_cell_name' => 'Z', + 'col_name' => 'Date - Latest Query Raise', + 'is_mandatory' => false, + 'data_type' => 'date', + 'format' => 'm/d/Y', + 'allowed_values' => null + ], + "date_latest_query_resolution" => [ + 'col_idx' => 26, + 'col_cell_name' => 'AA', + 'col_name' => 'Date - Latest Query Resolution', + 'is_mandatory' => false, + 'data_type' => 'date', + 'format' => 'm/d/Y', + 'allowed_values' => null + ], + "approved_amt" => [ + 'col_idx' => 27, + 'col_cell_name' => 'AB', + 'col_name' => 'Approved Amt', + 'is_mandatory' => false, + 'data_type' => 'str', + 'format' => null, + 'allowed_values' => null + ], + "date_approval" => [ + 'col_idx' => 28, + 'col_cell_name' => 'AC', + 'col_name' => 'Date of Approval', + 'is_mandatory' => false, + 'data_type' => 'date', + 'format' => 'm/d/Y', + 'allowed_values' => null + ], + "utr_settlement" => [ + 'col_idx' => 29, + 'col_cell_name' => 'AD', + 'col_name' => 'UTR - Settlement', + 'is_mandatory' => false, + 'data_type' => 'string', + 'format' => null, + 'allowed_values' => null + ], + "date_settlement" => [ + 'col_idx' => 30, + 'col_cell_name' => 'AE', + 'col_name' => 'Date of Settlement', + 'is_mandatory' => false, + 'data_type' => 'date', + 'format' => 'm/d/Y', + 'allowed_values' => null + ], + "reason" => [ + 'col_idx' => 31, + 'col_cell_name' => 'AF', + 'col_name' => 'Reason', + 'is_mandatory' => false, + 'data_type' => 'text', + 'format' => null, + 'allowed_values' => null + ], + "remarks" => [ + 'col_idx' => 32, + 'col_cell_name' => 'AG', + 'col_name' => 'Remarks', + 'is_mandatory' => false, + 'data_type' => 'text', + 'format' => null, + 'allowed_values' => null + ], + "approval_letter" => [ + 'col_idx' => 33, + 'col_cell_name' => 'AH', + 'col_name' => 'Approval Letter', + 'is_mandatory' => false, + 'data_type' => 'string', + 'format' => null, + 'allowed_values' => null + ], + "settlement_letter" => [ + 'col_idx' => 34, + 'col_cell_name' => 'AI', + 'col_name' => 'Settlement Letter', + 'is_mandatory' => false, + 'data_type' => 'string', + 'format' => null, + 'allowed_values' => null + ], + "denial_letter" => [ + 'col_idx' => 35, + 'col_cell_name' => 'AJ', + 'col_name' => 'Denial Letter', + 'is_mandatory' => false, + 'data_type' => 'string', + 'format' => null, + 'allowed_values' => null + ] + ]; + + } + + //create a sample excel for development + public function createSampleClaimDumpExcelFileWithHeaderOnly() + { + + // create a sample file + $headers = []; + foreach ($this->claim_dump_excel_columns as $key => $value) { + $headers[] = $value['col_name']; + } + generateExcelWithHeader($headers, 'claim_dump_sample.xlsx'); + dd($headers); + } + + // --------------------------------------------------------------------------------------------------------- + + public function claimDumpExcelFileFormatValidation($params) + { + $file_id = $params['file_id']; + $file = $this->claimDumpFileModel->where("id", $file_id)->first(); + $this->myLogger->logme('error', "Start the claim dump file format validataion with the file id : " . $file_id); + // dd($file); + + $return = []; + if (empty($file)) { + return array('status' => false, 'message' => 'File not found in Database'); + } + + $file_name_with_path = WRITEPATH . "/uploads/claim_dump_excel/" . $file['file_name']; + + //check physical file exist + if (!file_exists($file_name_with_path)) { + + $message = "Physcial file not found"; + $this->myLogger->logme('error', ($message . ' for file id : ' . $file_id)); + $this->claimDumpFileModel->where('id', $file_id)->set(['status' => 'failed', 'reason' => json_encode(['error_summary' => array_count_values([5]), 'error_data' => $message])])->update(); + return array('error_summary' => [5], 'error_data' => $message); + } + + //Read the excel file + try { + $excel_data_and_headers = $this->extractExcelData($file['file_name']); + $excel_data = $excel_data_and_headers['excel_data']; + } catch (\Exception $e) { + $errorDetails = [ + 'error_message' => $e->getMessage(), + 'file' => $e->getFile(), + 'line' => $e->getLine(), + 'stack_trace' => $e->getTraceAsString(), + ]; + $message = "Contact system admin"; + $this->claimDumpFileModel->where('id', $file_id)->set(['status' => 'failed', 'reason' => json_encode(['error_summary' => array_count_values([5]), 'error_data' => $message])])->update(); + $this->myLogger->logme("error", 'Excel data extraction failed due to : ' . json_encode($errorDetails ?? [])); + return $errorDetails; + } + // dd($excel_data_and_headers); + + //Claim dump excel colums + $columns_to_check = $excel_data_and_headers['claim_dump_excel_columns']; + // dd($columns_to_check); + + $client_data = $this->clientModel->where('is_active', 1)->where('client_type', 1)->findAll(); + $insurer_data = $this->insurerModel->where('is_active', 1)->findAll(); + $tpa_data = $this->TPAModel->where('is_active', 1)->findAll(); + $claim_status_data = $this->ticketClaimStatusModel->select('id, claim_status')->where('is_active', 1)->orderBy('id', 'asc')->groupBy('claim_status')->findAll(); + + + //Store the error data by this structure + $result = ['error_type' => 1, 'error_summary' => [], 'error_data' => []]; + + //excel data is empty than through the error + if(count($excel_data ?? []) <= 1){ + $message = "Uploaded file is empty"; + return array('error_summary' => [5], 'error_data' => $message); + } + + //check no of columns in excel + $excel_columns = ($excel_data[0]); + // $keys = array_keys($columns_to_check); + + //check columns order in excel + $column_count_res = check_columns_name($columns_to_check, $excel_columns); + // dd($column_count_res); + + if (isset($column_count_res) && count($column_count_res)) { + //columns count mismatch + $message = implode("\n", $column_count_res); + $this->myLogger->logme('error', ($message . ' for file id ' . $file_id)); + $this->claimDumpFileModel->where('id', $file_id)->set(['status' => 'failed', 'reason' => json_encode(['error_summary' => array_count_values([6]), 'error_data' => $message])])->update(); + return array('error_summary' => [6], 'error_data' => $message); + } + + //remove header + unset($excel_data[0]); + + try { + foreach ($excel_data as $row_key => $row) { + + //avoid empty rows + if (check_row_is_empty_or_null($row)) { + break; + } + + //iterate each row for columns validations + foreach ($row as $col_key => $col) { + + if (!isset($columns_to_check[$col_key])) { + continue; + } + + $is_mandatory = $columns_to_check[$col_key]['is_mandatory']; + $format = $columns_to_check[$col_key]['format']; + $allowed_values = $columns_to_check[$col_key]['allowed_values']; + $custom_function = isset($columns_to_check[$col_key]['custom']) ? $columns_to_check[$col_key]['custom'] : null; + $binding_params = isset($columns_to_check[$col_key]['params']) ? $columns_to_check[$col_key]['params'] : null; + + + $column_dispaly_name = $columns_to_check[$col_key]['col_name']; + $column_index = $columns_to_check[$col_key]['col_idx']; + $column_cell = $columns_to_check[$col_key]['col_cell_name']; + + + if ($column_dispaly_name == "Corporate") { + $client_excel_name = ["client_name" => $col, "client_data" => $client_data]; + } + + if ($column_dispaly_name == "Insurer") { + $insurer_excel_name = ["insurer_name" => $col, "insurer_data" => $insurer_data]; + } + + if ($column_dispaly_name == "TPA") { + $tpa_excel_name = ["tpa_name" => $col, "tpa_data" => $tpa_data]; + } + + if ($column_dispaly_name == "Status") { + $excel_status_data = ["value" => $col, "data" => $claim_status_data]; + } + + //mandatory check + if (is_bool($is_mandatory) && $is_mandatory === true) { + if ($col == "" || $col == NULL) { + array_push($result['error_summary'], 1); //push error code for summary + $result['error_data'][$row_key][$col_key]['col_name'] = $column_dispaly_name; //push column name + $result['error_data'][$row_key][$col_key]['col_idx'] = $column_index; //push column index + $result['error_data'][$row_key][$col_key]['error'][] = 'Value is mandatory'; //push exact error desc + } + } + + //format check + if (isset($format)) { + $format_error = dynamic_check_excel_date_format($col, $format); + if (!$format_error['status']) { + array_push($result['error_summary'], 2); + $result['error_data'][$row_key][$col_key]['col_name'] = $column_dispaly_name; //push column name + $result['error_data'][$row_key][$col_key]['col_idx'] = $column_index; //push column index + $result['error_data'][$row_key][$col_key]['error'][] = $format_error['error']; + } + } + + //allowed values check + if (($is_mandatory === true && isset($allowed_values) && is_array($allowed_values)) || (is_array($is_mandatory) && (isset($allowed_values) && is_array($allowed_values)))) { + if (!in_array((trim($col)), $allowed_values)) { + array_push($result['error_summary'], 3); + $result['error_data'][$row_key][$col_key]['col_name'] = $column_dispaly_name; //push column name + $result['error_data'][$row_key][$col_key]['col_idx'] = $column_index; //push column index + $result['error_data'][$row_key][$col_key]['error'][] = "Value not allowed: Expected " . implode(",", $allowed_values) . " and received $col"; + } + } + + //custom function check + if (isset($custom_function)) { + + // convert string params into PHP variables + // Create an array of variables to pass custom helper funcitons + $param_values = []; + foreach ($binding_params as $bkey => $bparam) { + $param_values[] = ($$bparam); + } + + $res = call_user_func_array($custom_function, $param_values); + + if ($res['status'] === false) { + array_push($result['error_summary'], 4); + $result['error_data'][$row_key][$col_key]['col_name'] = $column_dispaly_name; //push column name + $result['error_data'][$row_key][$col_key]['col_idx'] = $column_index; //push column index + $result['error_data'][$row_key][$col_key]['error'][] = $res['error']; + } + } + } + } + } catch (\Exception $e) { + $errorDetails = [ + 'error_message' => $e->getMessage(), + 'file' => $e->getFile(), + 'line' => $e->getLine(), + 'stack_trace' => $e->getTraceAsString(), + ]; + $message = "Contact system admin"; + $this->claimDumpFileModel->where('id', $file_id)->set(['status' => 'failed', 'reason' => json_encode(['error_summary' => array_count_values([5]), 'error_data' => $message])])->update(); + $this->myLogger->logme("error", 'Claim dump file format validation failed due to : ' . json_encode($errorDetails ?? [])); + return $errorDetails; + } + + if (isset($result['error_summary']) && count($result['error_summary'])) { + $result['error_summary'] = array_count_values($result['error_summary']); + $status = 'failed'; + $failure_reason = ((json_encode($result))); + $this->claimDumpFileModel->where('id', $file_id)->set(['status' => $status, 'reason' => $failure_reason])->update(); + $this->myLogger->logme("error", '{file_id} uploaded failed', ['file_id' => $file_id]); + } else { //trigger next data validation via job queue server + //proceed next data level validation in JOB queue + $r = Jobs::addJob(['job_name' => 'claimDumpExcelFileDataValidation', 'payload' => ['file_id' => $file_id]]); + // $response = $this->claimDumpExcelFileDataValidation(['file_id' => $file_id]); + } + + return $result; + } + + public function claimDumpExcelFileDataValidation($params) + { + //get file name + $file_id = $params['file_id']; + $file = $this->claimDumpFileModel->find($file_id); + $this->myLogger->logme('error', "Start the claim dump File Data Validataion with the file id : " . $file_id); + // dd($file); + + if (!isset($file)) { + return array('status' => false, 'message' => 'File not found in Database'); + } + + $file_name_with_path = WRITEPATH . "/uploads/claim_dump_excel/" . $file['file_name']; + + //check physical file + if (!file_exists($file_name_with_path)) { + $message = "Physical file not found"; + $this->myLogger->logme('error', ($message . ' for file id ' . $file_id)); + $this->claimDumpFileModel->where('id', $file_id)->set(['status' => 'failed', 'reason' => json_encode(['error_summary' => array_count_values([5]), 'error_data' => $message])])->update(); + return array('error_summary' => [5], 'error_data' => $message); + } + + //Read the excel file + try { + $excel_data_and_headers = $this->extractExcelData($file['file_name'], "modified_column"); + $excel_data = $excel_data_and_headers['excel_data']; + } catch (\Exception $e) { + $errorDetails = [ + 'error_message' => $e->getMessage(), + 'file' => $e->getFile(), + 'line' => $e->getLine(), + 'stack_trace' => $e->getTraceAsString(), + ]; + $message = "Contact system admin"; + $this->claimDumpFileModel->where('id', $file_id)->set(['status' => 'failed', 'reason' => json_encode(['error_summary' => array_count_values([5]), 'error_data' => $message])])->update(); + $this->myLogger->logme("error", 'Excel data extraction failed due to : ' . json_encode($errorDetails ?? [])); + return $errorDetails; + } + // dd($excel_data_and_headers); + // print_rr($excel_data); + + //Claim dump excel colums + $columns_to_check = $excel_data_and_headers['claim_dump_excel_columns']; + // dd($columns_to_check); + + $result = ['error_type' => 2, 'error_summary' => [], 'error_data' => []]; + + //remove header + unset($excel_data[0]); + + try { + foreach ($excel_data as $row_key => $row) { + + //avoid empty rows + if (check_row_is_empty_or_null($row)) { + break; + } + + $client_column_index = $columns_to_check['corporate']['col_idx']; + $policy_no_column_index = $columns_to_check['policy_no']['col_idx']; + $insurer_column_index = $columns_to_check['insurer']['col_idx']; + $tpa_column_index = $columns_to_check['tpa']['col_idx']; + + $emp_id_column_index = $columns_to_check['emp_id']['col_idx']; + $emp_name_column_index = $columns_to_check['employee_name']['col_idx']; + $insured_name_column_index = $columns_to_check['insured_name']['col_idx']; + $claim_no_column_index = $columns_to_check['claim_id']['col_idx']; + $tpa_no_column_index = $columns_to_check['tpa_id']['col_idx']; + $relation_column_index = $columns_to_check['relationship']['col_idx']; + $acm_column_index = $columns_to_check['acm']['col_idx']; + + //excel file Account Manager Details like Name and Mobile Number + $excel_acm_data = $row[$acm_column_index] ?? null; + + $acm_name = null; + $acm_mobile = null; + + //seperate the Account Manager Name and Mobile No + if (!empty($excel_acm_data)) { + $parts = array_map('trim', explode('-', $excel_acm_data, 2)); + $acm_name = $parts[0] ?? null; + $acm_mobile = $parts[1] ?? null; + } + + $params = [ + 'client_name' => $row[$client_column_index] ?? null, + 'policy_no' => $row[$policy_no_column_index] ?? null, + 'insurer_short_name' => $row[$insurer_column_index] ?? null, + 'tpa_short_name' => $row[$tpa_column_index] ?? null, + 'emp_code' => $row[$emp_id_column_index] ?? null, + 'emp_name' => $row[$emp_name_column_index] ?? null, + 'insured_name' => $row[$insured_name_column_index] ?? null, + 'claim_no' => $row[$claim_no_column_index] ?? null, + 'tpa_no' => $row[$tpa_no_column_index] ?? null, + 'relationship' => $row[$relation_column_index] ?? null, + 'acm_mobile' => $acm_mobile ?? null, + 'acm_name' => $acm_name ?? null, + ]; + + $ticketMasterModal = new TicketMasterModel(); + + //check the Claim + $claim_data = $ticketMasterModal->getTheClaimDetails($params); + // dd($claim_data); + if (count($claim_data) != 0) { + + array_push($result['error_summary'], 7); + $result['error_data'][$row_key][$policy_no_column_index]['col_name'] = $columns_to_check['policy_no']['col_name']; //push column name + $result['error_data'][$row_key][$policy_no_column_index]['col_idx'] = $policy_no_column_index; //push column index + $result['error_data'][$row_key][$policy_no_column_index]['error'][] = "This claim already exist in the system"; + + } else { + + //check the policy + $policy_data = $ticketMasterModal->getPolicyData($params); + // dd($policy_data); + if (count($policy_data) == 0) { + + array_push($result['error_summary'], 8); + $result['error_data'][$row_key][$policy_no_column_index]['col_name'] = $columns_to_check['policy_no']['col_name']; //push column name + $result['error_data'][$row_key][$policy_no_column_index]['col_idx'] = $policy_no_column_index; //push column index + $result['error_data'][$row_key][$policy_no_column_index]['error'][] = "The combination of Client, Insurer, TPA and Policy No. does not exist in the system"; + + } else { + + //check the employee and insured + $employee_data = $ticketMasterModal->getEmployeeAndEmployeePolicyDetails($params) ?? []; + // dd($employee_data); + if (count($employee_data) == 0) { + array_push($result['error_summary'], 9); + $result['error_data'][$row_key][$emp_name_column_index]['col_name'] = $columns_to_check['employee_name']['col_name']; //push column name + $result['error_data'][$row_key][$emp_name_column_index]['col_idx'] = $emp_name_column_index; //push column index + $result['error_data'][$row_key][$emp_name_column_index]['error'][] = "This employee not exist in the system"; + } + } + + //check the Account Manager exist + $acm_data = $ticketMasterModal->getAcmUserDetails($params) ?? []; + // dd($acm_data); + if (count($acm_data) == 0) { + array_push($result['error_summary'], 10); + $result['error_data'][$row_key][$emp_name_column_index]['col_name'] = $columns_to_check['employee_name']['col_name']; //push column name + $result['error_data'][$row_key][$emp_name_column_index]['col_idx'] = $emp_name_column_index; //push column index + $result['error_data'][$row_key][$emp_name_column_index]['error'][] = "This Acount Manager not exist in the system"; + } + } + + } + } catch (\Exception $e) { + $errorDetails = [ + 'error_message' => $e->getMessage(), + 'file' => $e->getFile(), + 'line' => $e->getLine(), + 'stack_trace' => $e->getTraceAsString(), + ]; + $message = "Contact system admin"; + $this->claimDumpFileModel->where('id', $file_id)->set(['status' => 'failed', 'reason' => json_encode(['error_summary' => array_count_values([5]), 'error_data' => $message])])->update(); + $this->myLogger->logme("error", 'Claim dump file data validation failed due to : ' . json_encode($errorDetails ?? [])); + return $errorDetails; + } + + if (isset($result['error_summary']) && count($result['error_summary'])) { + + $result['error_summary'] = array_count_values($result['error_summary']); + $status = 'failed'; + $failure_reason = ((json_encode($result))); + $this->claimDumpFileModel->where('id', $file_id)->set(['status' => $status, 'reason' => $failure_reason])->update(); + $this->myLogger->logme("error", '{file_id} uploaded failed', ['file_id' => $file_id]); + + } else { + $r = Jobs::addJob(['job_name' => 'claimDumpOnBoardProcess', 'payload' => ['file_id' => $file_id]]); + } + + return $result; + } + + public function claimDumpOnBoardProcess($params) + { + //get file name + $file_id = $params['file_id']; + $file = $this->claimDumpFileModel->find($file_id); + $this->myLogger->logme('error', "Start the claim dump OnBoard Process with the file id : " . $file_id); + // dd($file); + + if (!isset($file)) { + return array('status' => false, 'message' => 'File not found in Database'); + } + + $file_name_with_path = WRITEPATH . "/uploads/claim_dump_excel/" . $file['file_name']; + + //check physical file + if (!file_exists($file_name_with_path)) { + $message = "Physical file not found"; + $this->myLogger->logme('error', ($message . ' for file id ' . $file_id)); + $this->claimDumpFileModel->where('id', $file_id)->set(['status' => 'failed', 'reason' => json_encode(['error_summary' => array_count_values([5]), 'error_data' => $message])])->update(); + return array('error_summary' => [5], 'error_data' => $message); + } + + //Read the excel file + try { + $excel_data_and_headers = $this->extractExcelData($file['file_name'], "modified_column"); + $excel_data = $excel_data_and_headers['excel_data']; + unset($excel_data[0]); //remove header + } catch (\Exception $e) { + $errorDetails = [ + 'error_message' => $e->getMessage(), + 'file' => $e->getFile(), + 'line' => $e->getLine(), + 'stack_trace' => $e->getTraceAsString(), + ]; + $message = "Contact system admin"; + $this->claimDumpFileModel->where('id', $file_id)->set(['status' => 'failed', 'reason' => json_encode(['error_summary' => array_count_values([5]), 'error_data' => $message])])->update(); + $this->myLogger->logme("error", 'Excel data extraction failed due to : ' . json_encode($errorDetails ?? [])); + return $errorDetails; + } + // dd($excel_data_and_headers); + + //Claim dump excel colums + $columns_to_check = $excel_data_and_headers['claim_dump_excel_columns']; + + //create the instance of the ticket master modal + $ticketMasterModal = new TicketMasterModel(); + + $inserted_claim_list = []; + //loop the excel data to be insert the ticket master modal + + try{ + foreach ($excel_data as $row_key => $row) { + + //avoid empty rows + if (check_row_is_empty_or_null($row)) { + break; + } + + $client_column_index = $columns_to_check['corporate']['col_idx']; + $policy_no_column_index = $columns_to_check['policy_no']['col_idx']; + $insurer_column_index = $columns_to_check['insurer']['col_idx']; + $tpa_column_index = $columns_to_check['tpa']['col_idx']; + $emp_id_column_index = $columns_to_check['emp_id']['col_idx']; + $emp_name_column_index = $columns_to_check['employee_name']['col_idx']; + $insured_name_column_index = $columns_to_check['insured_name']['col_idx']; + $claim_no_column_index = $columns_to_check['claim_id']['col_idx']; + $tpa_no_column_index = $columns_to_check['tpa_id']['col_idx']; + $relation_column_index = $columns_to_check['relationship']['col_idx']; + + $params = [ + 'client_name' => $row[$client_column_index] ?? null, + 'policy_no' => $row[$policy_no_column_index] ?? null, + 'insurer_short_name' => $row[$insurer_column_index] ?? null, + 'tpa_short_name' => $row[$tpa_column_index] ?? null, + 'emp_code' => $row[$emp_id_column_index] ?? null, + 'emp_name' => $row[$emp_name_column_index] ?? null, + 'insured_name' => $row[$insured_name_column_index] ?? null, + 'claim_no' => $row[$claim_no_column_index] ?? null, + 'tpa_no' => $row[$tpa_no_column_index] ?? null, + 'relationship' => $row[$relation_column_index] ?? null, + ]; + + // get the policy data + $policy_data = $ticketMasterModal->getEmployeeAndEmployeePolicyDetails($params); + // dd($policy_data); + + //construct the claim data to be insert + $data = $this->constructClaimData($row, $policy_data, $columns_to_check); + // dd($data); + + if(!empty($data)){ + + $data['file_id'] = $file_id; + //insert the claim data to ticket master table + $insert = $ticketMasterModal->insert($data); + $inserted_claim_list[] = $insert; + + $str = implode(', ', array_map(fn($k, $v) => "$k=$v", array_keys($params), $params)) ?? ""; + $this->myLogger->logme("error",'Claim insert success --- :' . $str); + + }else{ + $str = implode(', ', array_map(fn($k, $v) => "$k=$v", array_keys($params), $params)) ?? ""; + $this->myLogger->logme("error",'This employee claim dose not insert --- :' . $str); + } + + + } + }catch(\Exception $e){ + $errorDetails = [ + 'error_message' => $e->getMessage(), + 'file' => $e->getFile(), + 'line' => $e->getLine(), + 'stack_trace' => $e->getTraceAsString(), + ]; + $message = "Contact system admin"; + $this->claimDumpFileModel->where('id', $file_id)->set(['status' => 'failed', 'reason' => json_encode(['error_summary' => array_count_values([5]), 'error_data' => $message])])->update(); + $this->myLogger->logme("error", 'Claim dump file Onboard Process failed due to : ' . json_encode( $errorDetails ?? [])); + return $errorDetails; + } + + $this->claimDumpFileModel->where('id', $file_id)->set(['status' => 'success','reason' => ''])->update(); + $this->myLogger->logme("error",'{file_id} claim dump uploaded success',['file_id' => $file_id]); + return $inserted_claim_list; + } + + public function extractExcelData($file_name, $returnType = null) + { + // $file_name = "claims_dump_form_client.xlsx"; + // Load the Excel file + $file_name_with_path = WRITEPATH . "/uploads/claim_dump_excel/" . $file_name; + $spreadsheet = \PhpOffice\PhpSpreadsheet\IOFactory::load($file_name_with_path); + $worksheet = $spreadsheet->getActiveSheet(); + + // Get the highest row and column numbers + $highestRow = $worksheet->getHighestDataRow(); + $highestColumn = $worksheet->getHighestDataColumn(); + // dd($highestRow, $highestColumn); + + // Get header row (assuming headers are in row 1) + // $headerRow = $worksheet->rangeToArray('A1:' . $highestColumn . '1', null, true, false)[0]; + $excel_data = $worksheet->rangeToArray('A1:' . $highestColumn . $highestRow); + // print_rr($excel_data); die; + + $header_with_column_index = $this->getTheColumnIndex($excel_data[0], $this->actualHeaders, $returnType); + + //Sanitize the excel data + // $excel_data = ExcelSanitizeHelper::sanitizeArrayData($excel_data); + + $data = [ + 'claim_dump_excel_columns' => $header_with_column_index, + 'excel_data' => $excel_data, + ]; + + // dd($data); + return $data; + } + + private function getTheColumnIndex($headerRow, $definedColumns, $returnType = null) + { + $result = []; + foreach ($definedColumns as $key => $value) { + foreach ($headerRow as $col_index => $col_name) { + + if($returnType == null){ + if(trim($col_name) == trim($value['col_name'])){ + $columnLetter = Coordinate::stringFromColumnIndex(($col_index + 1)); + $result[$col_index] = $value; + $result[$col_index]["col_idx"] = $col_index; + $result[$col_index]["col_cell_name"] = $columnLetter; + } + }else{ + if(trim($col_name) == trim($value['col_name'])){ + $columnLetter = Coordinate::stringFromColumnIndex(($col_index + 1)); + $definedColumns[$key]["col_idx"] = $col_index; + $definedColumns[$key]["col_cell_name"] = $columnLetter; + } + } + } + } + + // dd($result); + if($returnType == null){ + return $result; + } + + return $definedColumns; + + } + + private function constructClaimData($excel_data, $db_data, $columns_to_check) + { + $client_column_index = $columns_to_check['corporate']['col_idx']; + $policy_no_column_index = $columns_to_check['policy_no']['col_idx']; + $insurer_column_index = $columns_to_check['insurer']['col_idx']; + $tpa_column_index = $columns_to_check['tpa']['col_idx']; + + $emp_id_column_index = $columns_to_check['emp_id']['col_idx']; + $emp_name_column_index = $columns_to_check['employee_name']['col_idx']; + $insured_name_column_index = $columns_to_check['insured_name']['col_idx']; + $claim_no_column_index = $columns_to_check['claim_id']['col_idx']; + $tpa_no_column_index = $columns_to_check['tpa_id']['col_idx']; + $relation_column_index = $columns_to_check['relationship']['col_idx']; + + $status_column_index = $columns_to_check['status']['col_idx']; + $acm_column_index = $columns_to_check['acm']['col_idx']; + $tpa_id_column_index = $columns_to_check['tpa_id']['col_idx']; + $claim_id_column_index = $columns_to_check['claim_id']['col_idx']; + $emp_mobile_column_index = $columns_to_check['emp_mobile']['col_idx']; + $emp_email_column_index = $columns_to_check['emp_email']['col_idx']; + $claim_collection_column_index = $columns_to_check['claim_collection']['col_idx']; + $source_detail_column_index = $columns_to_check['source_detail']['col_idx']; + $claim_type_column_index = $columns_to_check['claim_type']['col_idx']; + $hospital_column_index = $columns_to_check['hospital']['col_idx']; + $doa_column_index = $columns_to_check['doa']['col_idx']; + $dod_column_index = $columns_to_check['dod']['col_idx']; + $claim_amount_column_index = $columns_to_check['claim_amount']['col_idx']; + $date_claim_receipt_column_index = $columns_to_check['date_claim_receipt']['col_idx']; + $date_claim_registration_column_index = $columns_to_check['date_claim_registration']['col_idx']; + $date_latest_query_raise_column_index = $columns_to_check['date_latest_query_raise']['col_idx']; + $date_latest_query_resolution_index = $columns_to_check['date_latest_query_resolution']['col_idx']; + $approved_amt_column_index = $columns_to_check['approved_amt']['col_idx']; + $date_approval_column_index = $columns_to_check['date_approval']['col_idx']; + $utr_settlement_column_index = $columns_to_check['utr_settlement']['col_idx']; + $date_settlement_column_index = $columns_to_check['date_settlement']['col_idx']; + $reason_column_index = $columns_to_check['reason']['col_idx']; + $remarks_column_index = $columns_to_check['remarks']['col_idx']; + $approval_letter_column_index = $columns_to_check['approval_letter']['col_idx']; + $settlement_letter_column_index = $columns_to_check['settlement_letter']['col_idx']; + $denial_letter_column_index = $columns_to_check['denial_letter']['col_idx']; + + $excel_status_data = $excel_data[$status_column_index] ?? null; + $excel_relationship_data = $excel_data[$relation_column_index] ?? null; + $excel_acm_data = $excel_data[$acm_column_index] ?? null; + $excel_tpa_id_data = $excel_data[$tpa_id_column_index] ?? null; + $excel_claim_id_data = $excel_data[$claim_id_column_index] ?? null; + $excel_emp_mobile_data = $excel_data[$emp_mobile_column_index] ?? null; + $excel_emp_email_data = $excel_data[$emp_email_column_index] ?? null; + $excel_claim_collection_data = $excel_data[$claim_collection_column_index] ?? null; + $excel_source_detail_data = $excel_data[$source_detail_column_index] ?? null; + $excel_claim_type_data = $excel_data[$claim_type_column_index] ?? null; + $excel_hospital_data = $excel_data[$hospital_column_index] ?? null; + $excel_doa_data = $excel_data[$doa_column_index] ?? null; + $excel_dod_data = $excel_data[$dod_column_index] ?? null; + $excel_claim_amount_data = $excel_data[$claim_amount_column_index] ?? null; + $excel_date_claim_receipt_data = $excel_data[$date_claim_receipt_column_index] ?? null; + $excel_date_claim_registration_data = $excel_data[$date_claim_registration_column_index] ?? null; + $excel_date_latest_query_raise_data = $excel_data[$date_latest_query_raise_column_index] ?? null; + $excel_date_latest_query_resolution_data = $excel_data[$date_latest_query_resolution_index] ?? null; + $excel_approved_amt_data = $excel_data[$approved_amt_column_index] ?? null; + $excel_date_approval_data = $excel_data[$date_approval_column_index] ?? null; + $excel_utr_settlement_data = $excel_data[$utr_settlement_column_index] ?? null; + $excel_date_settlement_data = $excel_data[$date_settlement_column_index] ?? null; + $excel_reason_data = $excel_data[$reason_column_index] ?? null; + $excel_remarks_data = $excel_data[$remarks_column_index] ?? null; + $excel_approval_letter_data = $excel_data[$approval_letter_column_index] ?? null; + $excel_settlement_letter_data = $excel_data[$settlement_letter_column_index] ?? null; + $excel_denial_letter_data = $excel_data[$denial_letter_column_index] ?? null; + + + //create the instance of the ticket master modal + $ticketMasterModal = new TicketMasterModel(); + + //excel file Account Manager Details like Name and Mobile Number + $excel_acm_data = $excel_data[$acm_column_index] ?? null; + + $acm_name = null; + $acm_mobile = null; + + //seperate the Account Manager Name and Mobile No + if (!empty($excel_acm_data)) { + $parts = array_map('trim', explode('-', $excel_acm_data, 2)); + $acm_name = $parts[0] ?? null; + $acm_mobile = $parts[1] ?? null; + } + + $params = [ + "acm_name" => $acm_name, + "acm_mobile" => $acm_mobile, + ]; + + //get the acountmanager data + $acm_data = $ticketMasterModal->getAcmUserDetails($params) ?? []; + + //get the claim status id from the database + $claim_status_data = $this->ticketClaimStatusModel + ->select('id, claim_status') + ->where('is_active', 1) + ->where('ticket_type', $db_data['ticket_type_id']) + ->where('LOWER(claim_status)', strtolower($excel_status_data)) + ->first(); + + $claim_status_id = $claim_status_data['id'] ?? null; + + //initialize Ticket controller for the other data + $ticketController = new TicketController(); + $mode_of_intimation = array_flip($ticketController->modeOFIntimate); + + //handle the Claim Type data key + $cliam_type_id = 1; + if(isset($db_data['ticket_type_id'])){ + if($db_data['ticket_type_id'] == 2){ + $claim_type = array_flip($ticketController->claimType[1]); + $cliam_type_id = $claim_type[$excel_claim_type_data] ?? 1; + }else{ + $claim_type = array_flip($ticketController->claimType[2]); + $cliam_type_id = $claim_type[$excel_claim_type_data] ?? 1; + } + } + + $db_data['insured_name'] = $db_data['insured_emp_id'] ?? null; + //get Insured emp name and Insured emp id + $insured_data = $ticketMasterModal->getInsuredDetails($db_data); + + //handle remarks based on the status + $return_remarks = null; + $cancel_remarks = null; + $denial_reason = null; + if(strtolower($excel_status_data) == strtolower('RETURNED')){ + $return_remarks = $excel_remarks_data ?? null; + }else if(strtolower($excel_status_data) == strtolower('CANCELLED')){ + $cancel_remarks = $excel_remarks_data ?? null; + }else if(strtolower($excel_status_data) == strtolower('REJECTED')){ + $denial_reason = $excel_reason_data ?? null; + } + + $ticketMaster = [ + 'ticket_type_id' => $db_data['ticket_type_id'] ?? null, + 'claim_status_id' => $claim_status_id ?? null, + 'acm_id' => $acm_data['id'] ?? null, + 'insurer_id' => $db_data['insurer_id'] ?? null, + 'tpa_id' => $excel_tpa_id_data ?? $db_data['tpa_id'] ?? null, + 'client_id' => $db_data['client_id'] ?? null, + 'emp_id' => $db_data['emp_id'] ?? null, + 'client_policy_id' => $db_data['client_policy_id'] ?? null, + 'policy_no' => $db_data['policy_no'] ?? null, + 'emp_code' => $db_data['emp_code'] ?? null, + 'tpa_no' => $db_data['tpa_no'] ?? null, + 'emp_name' => $db_data['emp_name'] ?? null, + 'relationship' => $excel_relationship_data ?? null, + 'emp_mobile' => $excel_emp_mobile_data ?? $db_data['emp_mobile'] ?? null, + 'emp_mail' => $excel_emp_email_data ?? $db_data['emp_mail'] ?? null, + + 'mode_of_intimation' => $mode_of_intimation[$excel_claim_collection_data] ?? null, + 'claim_type' => $cliam_type_id ?? null, + + 'insured_emp_id' => $insured_data['emp_id'] ?? null, + 'insured_name' => $insured_data['name'] ?? $db_data['insured_emp_id'] ?? null, + + 'hospital_name' => $excel_hospital_data ?? null, + 'claim_amount' => $excel_claim_amount_data ?? null, + 'claim_number' => $excel_claim_id_data ?? null, + 'approved_letter' => $excel_approval_letter_data ?? null, + 'approved_amount' => $excel_approved_amt_data ?? null, + 'utr_details' => $excel_utr_settlement_data ?? null, + 'settle_letter' => $excel_settlement_letter_data ?? null, + 'return_remark' => $return_remarks, + 'cancel_remark' => $cancel_remarks, + 'denial_reason' => $denial_reason ?? null, + + 'doa' => normalizeDate($excel_doa_data), + 'dod' => normalizeDate($excel_dod_data), + 'raised_date' => normalizeDate($excel_date_latest_query_raise_data), + 'registration_date' => normalizeDate($excel_date_claim_registration_data), + 'query_received_date' => normalizeDate($excel_date_latest_query_resolution_data), + 'approved_date' => normalizeDate($excel_date_approval_data), + 'settled_date' => normalizeDate($excel_date_settlement_data), + + 'priority' => null, + 'emp_personal_mail' => null, + 'pod_no' => null, + 'dob' => null, + 'date_of_join' => null, + 'date_of_incep' => null, + 'date_of_accident' => null, + 'date_of_death' => null, + 'date_of_intimat' => null, + 'si_amt' => null, + 'denial_date' => null, + 'awb_no_courier_name' => null, + 'non_id_reason' => null, + 'pay_initiate_date' => null, + 'approved_description' => null + ]; + + return $ticketMaster; + } + + public function getClaimExcelErrorData($file_id) + { + try { + + $file = $this->claimDumpFileModel->where('id', $file_id)->first(); + $error_data = json_decode($file['reason']); + // dd($error_data); + + $file_name_with_path = WRITEPATH . "/uploads/claim_dump_excel/" . $file['file_name']; + + //check the file exist or not + if (!file_exists($file_name_with_path)) { + $error_message = "File not found"; + $this->myLogger->logme('error', ($error_message . ' for file id ' . $file_id)); + return 0; + } + + $excel_data_and_headers = $this->extractExcelData($file['file_name']); + $excel_data = $excel_data_and_headers['excel_data']; + $excelErrorData['excel_header'] = $excel_data[0]; + unset($excel_data[0]); + + // Kint::dump($excel_data); + if ($error_data->error_type == 1) { + + $finalArray = []; + foreach ($error_data->error_data as $key => $value) { + foreach ($value as $key2 => $value2) { + $error_data = $value2->error; + $data = ['value' => $excel_data[$key][$value2->col_idx], 'error' => $error_data,]; + $excel_data[$key][$value2->col_idx] = $data; + } + array_push($finalArray, $excel_data[$key]); + } + + foreach ($finalArray as $fkey => $value) { + foreach ($value as $vkey => $arrayData) { + if (!is_array($arrayData)) { + $data = ['value' => $arrayData]; + $finalArray[$fkey][$vkey] = $data; + } + } + } + + $excelErrorData['excel_data'] = $finalArray; + return $excelErrorData; + } else if ($error_data->error_type == 2) { + + + $allErrors = []; + $typeTowArray = []; + + foreach ($error_data->error_data as $index => $item) { + + foreach ($item as $field) { + if (!isset($allErrors[$index])) { + $allErrors[$index] = []; + } + $allErrors[$index] = array_merge($allErrors[$index], $field->error); + } + } + + // dd(array_keys($allErrors)); + foreach ($allErrors as $key => $value) { + // echo $key; + // print_r($value); + foreach ($excel_data as $excel_data_index => $excel_data_value) { + if ($excel_data_value[0] == $key) { + $data = ['value' => $excel_data[$excel_data_index][1], 'error' => $value,]; + $excel_data[$excel_data_index][1] = $data; + array_push($typeTowArray, $excel_data[$excel_data_index]); + break; + } + } + } + // dd($data); + foreach ($typeTowArray as $fkey => $value) { + foreach ($value as $vkey => $arrayData) { + if (!is_array($arrayData)) { + $data = ['value' => $arrayData]; + $typeTowArray[$fkey][$vkey] = $data; + } + } + } + + $excelErrorData['excel_data'] = $typeTowArray; + return $excelErrorData; + } + } catch (\Exception $e) { + // Handle any exceptions + $errorMessage = $e->getMessage(); //die(); + $this->myLogger->logme('error', $errorMessage); + return false; // You can return an error response here + } + } + + public function truncateClaimDumpFile($file_id) + { + + } + +} diff --git a/app/Helpers/claim_dump_helper.php b/app/Helpers/claim_dump_helper.php new file mode 100644 index 00000000..6f740e8a --- /dev/null +++ b/app/Helpers/claim_dump_helper.php @@ -0,0 +1,179 @@ + $value) { + // Kint::dump($value['client_name'], $client_name); + if(trim($value['client_name']) === trim($client_name)){ + return array('status' => true, 'client_id' => $value['id'], 'error' => ''); + } + } + } + + return array('status' => false, 'error' => 'This Client Name does not exist in the system'); + } +} + +if (!function_exists('check_insurer')) { + function check_insurer($params) + { + $insurer_data = $params['insurer_data'] ?? []; + $insurer_name = $params['insurer_name'] ?? ""; + if (!empty($insurer_data)) { + foreach ($insurer_data as $key => $value) { + if(trim($value['short_name']) === trim($insurer_name)){ + return array('status' => true, 'insuer_id' => $value['id'], 'error' => ''); + } + } + } + + return array('status' => false, 'error' => 'This Insurer does not exist in the system'); + + } +} + +if (!function_exists('check_tpa')) { + function check_tpa($params) + { + $tpa_data = $params['tpa_data'] ?? []; + $tpa_name = $params['tpa_name'] ?? ""; + if (!empty($tpa_data)) { + foreach ($tpa_data as $key => $value) { + if(trim($value['short_name']) === trim($tpa_name)){ + return array('status' => true, 'tpa_id' => $value['id'], 'error' => ''); + } + } + } + + return array('status' => false, 'error' => 'This TPA does not exist in the system'); + } +} + +if (!function_exists('check_status')) { + function check_status($params) + { + $data = $params['data'] ?? []; + $check_value = $params['value'] ?? ""; + if (!empty($data)) { + foreach ($data as $key => $value) { + // Kint::dump(strtolower(trim($value['claim_status'])), strtolower(trim($check_value))); + if(strtolower(trim($value['claim_status'])) === strtolower(trim($check_value))){ + return array('status' => true, 'status_id' => $value['id'], 'error' => ''); + } + } + } + + return array('status' => false, 'error' => "This Status ('{$check_value}') does not exist in the system"); + } +} + +if (!function_exists('check_policy')) { + function check_policy($params) + { + $data = $params['data'] ?? []; + $client_id = $params['client_id'] ?? ""; + $check_value = $params['value'] ?? ""; + if (!empty($data)) { + foreach ($data as $key => $value) { + if($value['client_id'] === $client_id && trim($value['policy_no']) === trim($check_value)){ + return array('status' => true, 'status_id' => $value['id'], 'error' => ''); + } + } + } + + return array('status' => false, 'error' => "This Policy Number does not exist in the Client"); + } +} + +if (!function_exists('check_emp_and_insured')) { + function check_emp_and_insured($params) + { + + $employee_modal = new EmployeeModel(); + $tpa_data = $employee_modal + ->join('employee_polices', 'employees.id = employee_polices.employee_id') + ->where('employees.client', $params['client_id']) + ->where('employees.name', $params['emp_name']) + ->where('employees.emp_code', $params['emp_code']) + ->where('employees.is_active', 1) + ->where('employees.emp_status !=', "truncated") + ->where('employee_polices.is_active', 1) + ->where('employees.status !=', "truncated") + ->first(); + + if (empty($tpa_data)) { + return false; + } + + return $tpa_data['id']; + } +} + +if (!function_exists('dynamic_check_excel_date_format')) { + + function dynamic_check_excel_date_format($dateString, $format = 'd/m/Y') + { + + if ($dateString == "") { + return array('status' => true); + } + $date = DateTime::createFromFormat($format, $dateString); + + if ($date && $date->format($format) == $dateString) { + return array('status' => true); + } else { + + $res = validate_date_flexible($dateString, $format); + if (!$res) { + return array('status' => false, 'error' => "wrong date format: Expected {$format}({$res}) and received $dateString"); + } else { + return array('status' => true); + } + } + } +} + +if (!function_exists('validate_date_flexible')) { + function validate_date_flexible($date, $format = 'm/d/Y') + { + // Create a DateTime from the given format + $d = DateTime::createFromFormat($format, $date); + if (!$d) return false; + + // Compare normalized values (remove leading zeros) + $original = preg_replace('/\b0+/', '', $date); + $normalized = preg_replace('/\b0+/', '', $d->format($format)); + + return $original === $normalized; + } +} + +if (!function_exists('normalizeDate')) { + function normalizeDate($dateString, $formats = ['d-m-Y', 'd/m/Y', 'm-d-Y', 'm/d/Y', 'Y-m-d']) + { + if (empty($dateString)) { + return null; // keep null if no value + } + + foreach ($formats as $format) { + $dt = DateTime::createFromFormat($format, trim($dateString)); + if ($dt && $dt->format($format) === trim($dateString)) { + return $dt->format('Y-m-d'); // ✅ return in DB format + } + } + + return null; // if no valid format found + } +} + +?> \ No newline at end of file diff --git a/app/Helpers/header.php b/app/Helpers/header.php index 2ade2b0b..dc193798 100755 --- a/app/Helpers/header.php +++ b/app/Helpers/header.php @@ -267,7 +267,6 @@ .right-bar { - width: 300px; /* Adjust as needed */ overflow: hidden; } diff --git a/app/Models/ClaimDumpFileModel.php b/app/Models/ClaimDumpFileModel.php new file mode 100644 index 00000000..224adafc --- /dev/null +++ b/app/Models/ClaimDumpFileModel.php @@ -0,0 +1,56 @@ +db->table('employees e') + ->select('e.id, e.email_personal, e.client_id, e.client_branch_id as branch_id, e.mobile, e.emp_code, e.name, ep.client_policy_id as policy_id') + ->join('employee_polices ep', 'ep.employee_id = e.id AND ep.is_active = 1', 'left') + ->whereIn('e.emp_status', ['active', 'draft', 'enrolled']) + ->where('e.is_active', 1) + ->where('e.mobile', $mobile) + ->where('e.client_id', $client_id) + ->groupBy('e.client_id') + ->get() + ->getResultArray(); + + return $result; + + } + } diff --git a/app/Models/ThzMasterNotesModel.php b/app/Models/ThzMasterNotesModel.php index 2072c094..ac970b67 100644 --- a/app/Models/ThzMasterNotesModel.php +++ b/app/Models/ThzMasterNotesModel.php @@ -12,7 +12,7 @@ class ThzMasterNotesModel extends Model protected $returnType = 'array'; protected $useSoftDeletes = false; protected $protectFields = true; - protected $allowedFields = ['thz_id','notes','notes_by','created_by','created_at']; + protected $allowedFields = ['thz_id','notes','notes_by','created_by','created_at','notes_type']; protected bool $allowEmptyInserts = false; @@ -40,7 +40,7 @@ class ThzMasterNotesModel extends Model protected $beforeDelete = []; protected $afterDelete = []; - public function conversationListForUserPerTicket($thz_id){ + public function ticketConversationLists($thz_id){ if(empty($thz_id)){ @@ -50,6 +50,7 @@ class ThzMasterNotesModel extends Model $sql = "SELECT + thz_master.*, thz_master_notes.id, thz_master_notes.thz_id, thz_master_notes.notes, @@ -60,6 +61,7 @@ class ThzMasterNotesModel extends Model thz_master_notes Join thz_master ON thz_master.thz_id = :thz_id: + WHERE thz_master_notes.thz_id = :thz_id: ORDER BY @@ -74,5 +76,42 @@ class ThzMasterNotesModel extends Model } + public function ticketConversationList($thz_id , $returnType) + { + $ticketTypeFilter = ""; + + if ($returnType == 'api') { + //user only see his message + $ticketTypeFilter = "AND thz_master_notes.notes_type = 'External' "; + } + + $integer_ticket_id = (int)$thz_id; + + $notes_sql = "SELECT + thz_master_notes.*, + CASE + WHEN LOWER(thz_master_notes.notes_by) = 'staff' + THEN CONCAT(user_profiles.first_name, ' ', user_profiles.last_name) + WHEN LOWER(thz_master_notes.notes_by) = 'user' + THEN thz_master.name + ELSE thz_master_notes.notes_by + END AS name + FROM thz_master_notes + LEFT JOIN user_profiles + ON user_profiles.id = thz_master_notes.created_by + AND LOWER(thz_master_notes.notes_by) = 'staff' + LEFT JOIN thz_master + ON thz_master.thz_id = thz_master_notes.thz_id + AND LOWER(thz_master_notes.notes_by) = 'user' + WHERE thz_master_notes.thz_id = ". $integer_ticket_id ." + $ticketTypeFilter + ORDER BY thz_master_notes.created_at DESC"; + + $result = $this->db->query($notes_sql)->getResultArray(); + + return $result; + } + + } diff --git a/app/Models/TicketMasterModel.php b/app/Models/TicketMasterModel.php index 3a7c191a..013e5ad7 100644 --- a/app/Models/TicketMasterModel.php +++ b/app/Models/TicketMasterModel.php @@ -76,7 +76,9 @@ class TicketMasterModel extends Model 'emp_personal_mail', 'client_policy_id', - 'approved_description' + 'approved_description', + 'file_id', + 'denial_letter', ]; @@ -883,8 +885,6 @@ class TicketMasterModel extends Model return $finalResults; } - - public function getNotSettledbutApprovedCount($ticket_type) { // Fetch the approved and settled claim_status IDs @@ -975,7 +975,198 @@ class TicketMasterModel extends Model return json_encode(['policy_terms' => null]); } + // ---------- CLAIM DUMP UPLOAD------------------------------------------------------------------------------------------- + + public function getPolicyData($params) + { + $client_name = $params['client_name'] ?? null; + $insurer_short_name = $params['insurer_short_name'] ?? null; + $tpa_short_name = $params['tpa_short_name'] ?? null; + $policy_no = $params['policy_no'] ?? null; + $builder = $this->db->table('client_policy'); + $builder->select('client_policy.*'); + $builder->join('clients c', 'client_policy.client_id = c.id'); + $builder->join('insurers i', 'client_policy.insurer_id = i.id'); + $builder->join('tpa', 'client_policy.tpa_id = tpa.id and tpa.is_active = 1', 'left'); + $builder->where('c.is_active', 1); + $builder->where('client_policy.is_active', 1); + $builder->where('i.is_active', 1); + $builder->where('c.client_name', trim($client_name)); + $builder->where('i.short_name', trim($insurer_short_name)); + if(!empty($tpa_short_name)){ + $builder->where('tpa.short_name', trim($tpa_short_name)); + } + $builder->where('client_policy.policy_no', trim($policy_no)); + + $query = $builder->get(); + $result = $query->getResultArray(); + // dd($this->db->getLastQuery()); + return $result; + } + + public function getTheClaimDetails($params) + { + $client_name = $params['client_name'] ?? null; + $policy_no = $params['policy_no'] ?? null; + $insurer_short_name = $params['insurer_short_name'] ?? null; + $tpa_short_name = $params['tpa_short_name'] ?? null; + $emp_code = $params['emp_code'] ?? null; + $emp_name = $params['emp_name'] ?? null; + $insured_name = $params['insured_name'] ?? null; + $claim_no = $params['claim_no'] ?? null; + $tpa_no = $params['tpa_no'] ?? null; + $relationship = $params['relationship'] ?? null; + + $builder = $this->table('ticket_master'); + $builder->select('ticket_master.*'); + $builder->join('clients c', 'ticket_master.client_id = c.id'); + $builder->join('insurers i', 'ticket_master.insurer_id = i.id'); + $builder->join('tpa', 'ticket_master.tpa_id = tpa.id', 'left'); + $builder->where('c.is_active', 1); + $builder->where('i.is_active', 1); + $builder->where('tpa.is_active', 1); + $builder->where('ticket_master.is_active', 1); + + $builder->where('c.client_name', trim($client_name)); + $builder->where('i.short_name', trim($insurer_short_name)); + $builder->where('ticket_master.policy_no', trim($policy_no)); + $builder->where('ticket_master.emp_code', trim($emp_code)); + $builder->where('ticket_master.emp_name', trim($emp_name)); + $builder->where('ticket_master.insured_name', trim($insured_name)); + $builder->where('ticket_master.tpa_no', trim($tpa_no)); + $builder->where('ticket_master.claim_number', trim($claim_no)); + $builder->where('ticket_master.relationship', trim($relationship)); + + if(!empty($tpa_short_name)){ + $builder->where('tpa.short_name', trim($tpa_short_name)); + } + + $query = $builder->get(); + $result = $query->getResultArray(); + + return $result; + + } + + public function getEmployeeAndEmployeePolicyDetails($params) + { + $client_name = $params['client_name'] ?? null; + $emp_code = $params['emp_code'] ?? null; + $emp_name = $params['emp_name'] ?? null; + $policy_no = $params['policy_no'] ?? null; + $relationship = $params['relationship'] ?? null; + $insured_name = $params['insured_name'] ?? null; + + $client_name = "6-Eleven"; + $emp_code = "EMP0020K12"; + $emp_name = "Lokesh"; + $policy_no = "GMC-1999/2000/2021/2022"; + + + $builder = $this->db->table('employees e'); + $builder->select(" + e.id as emp_id, + e.client_id, + e.client_branch_id, + e.emp_code, + e.name as emp_name, + e.mobile as emp_mobile, + e.email_corporate as emp_mail, + e.email_personal as emp_mail_personal, + + ep.id as emp_policy_id, + ep.tpa_id as tpa_no, + + cp.id as client_policy_id, + cp.insurer_id, + cp.tpa_id, + cp.policy_no, + CASE + WHEN cp.policy_type_id = 2 THEN 1 + WHEN cp.policy_type_id = 1 THEN 2 + WHEN cp.policy_type_id = 6 THEN 3 + WHEN cp.policy_type_id = 7 THEN 4 + ELSE NULL + END AS ticket_type_id + ", false); + $builder->join('employee_polices ep', 'e.id = ep.employee_id'); + $builder->join('clients c', 'e.client_id = c.id'); + $builder->join('client_policy cp', 'ep.client_policy_id = cp.id'); + + $builder->where('e.is_active', 1); + $builder->where('ep.is_active', 1); + $builder->where('c.is_active', 1); + $builder->where('cp.is_active', 1); + $builder->where('e.emp_code', trim($emp_code)); + $builder->where('e.name', trim($emp_name)); + $builder->where('c.client_name', trim($client_name)); + $builder->where('cp.policy_no', trim($policy_no)); + $builder->where('LOWER(e.relationship)', strtolower('self')); + + $query = $builder->get(); + $result = $query->getResultArray(); + + return $result; + } + + public function getAcmUserDetails($params) + { + $acm_name = $params['acm_name'] ?? null; + $acm_mobile = $params['acm_mobile'] ?? null; + + if ($acm_mobile != null) { + + $builder = $this->db->table('user_profiles'); + $builder->select("user_profiles.*"); + $builder->where('user_profiles.is_active', 1); + $builder->where('user_profiles.mobile', trim($acm_mobile)); + $query = $builder->get(); + $result = $query->getResultArray(); + + return $result; + } + + return []; + } + + public function getInsuredDetails($params) + { + $client_id = $params['client_id'] ?? null; + $emp_code = $params['emp_code'] ?? null; + $policy_id = $params['client_policy_id'] ?? null; + $insured_name = $params['insured_name'] ?? null; + + $builder = $this->db->table('employees e'); + $builder->select(" + e.id as emp_id, + e.client_id, + e.client_branch_id, + e.emp_code, + e.name as emp_name, + e.mobile as emp_mobile, + e.email_corporate as emp_mail, + e.email_personal as emp_mail_personal, + + ep.id as emp_policy_id, + ep.tpa_id as tpa_no, + "); + $builder->join('employee_polices ep', 'e.id = ep.employee_id'); + $builder->where('e.is_active', 1); + $builder->where('ep.is_active', 1); + $builder->where('e.emp_code', trim($emp_code)); + $builder->where('e.name', trim($insured_name)); + $builder->where('e.client_id', trim($client_id)); + $builder->where('ep.client_policy_id', trim($policy_id)); + + $query = $builder->get(); + $result = $query->getResultArray(); + + return $result; + + } + + // ----------------------------------------------------------------------------------------------------- } diff --git a/app/Views/DashBoard.php b/app/Views/DashBoard.php index 08e08855..e3c54d7d 100755 --- a/app/Views/DashBoard.php +++ b/app/Views/DashBoard.php @@ -171,79 +171,113 @@ margin: 0 5px 10px!important; } + .nav-link{ + color:black !important; + background-color: #D4F5F6 !important; + font-size: small; + padding:8px; + border-radius: 10px !important; + } + .nav-link.active-tab { + color: white !important; + background-color: #00999E !important; + font-size: small; + padding:8px; + border-radius: 10px !important; + + } + .tab-content-styles{ + background-color:#F4F4F4; + margin-right:20px; + border-radius:25px!important; + min-height: 70vh !important; + } + + .active{ + color : white !important ; + } + + +

Dashboard

+
-
-
-
-
-
-
- -
+
-
+
+
+ @@ -257,7 +291,6 @@ - @@ -234,9 +248,6 @@ table.dataTable tbody td {

User List

-
- -
@@ -372,7 +383,7 @@ table.dataTable tbody td {
-
+
@@ -464,7 +475,7 @@ table.dataTable tbody td {
-
Team
+
@@ -520,7 +531,17 @@ table.dataTable tbody td { exportOptions: { columns: ':not(:last-child)' } + }, + { + text: 'ADD', + className: 'btn-color', + attr: { + id: 'btnAdd', + title: 'Add' + } } + + ], @@ -541,14 +562,6 @@ table.dataTable tbody td { }); - $('#btnAdd').click(function(){ - $('#first_name').val(''); - $('#last_name').val(''); - $('#email').val(''); - $('#mobile').val(''); - $('#emp_code').val(''); - $('#UserForm').attr('action', ''); - }) $('.close').click(function(){ @@ -815,3 +828,17 @@ table.dataTable tbody td { } + \ No newline at end of file diff --git a/app/Views/bds_dash.php b/app/Views/bds_dash.php index 0544e646..c91b2b6e 100644 --- a/app/Views/bds_dash.php +++ b/app/Views/bds_dash.php @@ -1,9 +1,4 @@ @@ -130,26 +157,32 @@ body{ -
-
-
Team
+ + + + + + + + + + + + $file) { + ?> + + + + + + + + + + + +
SNOFile nameUser/TimeStatusAction
+ + ' . $file['user_name'] . '' ?> + + + + + + + + + + + + +
+
+
+
+ + + + + \ No newline at end of file diff --git a/app/Views/claims_dash.php b/app/Views/claims_dash.php index c62af2ab..f37a2ed7 100644 --- a/app/Views/claims_dash.php +++ b/app/Views/claims_dash.php @@ -1,8 +1,4 @@
-
-
-
-
GMC
-

-

 

-

 

+
+
+
+
+

GMC

+

+
All GMC Records
+
+
+ +
+
+
+
+

GPA

+

+
All GPA Records
+
- -
-
-
-
-
GPA
-

-

 

-

 

+
+
+
+

EDLI

+

+
All EDLI Records
+
+
+
+
+
+
+

GTLI

+

+
All GTLI Records
+
-
-
-
-
EDLI
-

-

 

-

 

-
-
-
- -
-
-
-
GTLI
-

-

 

-

 

-
-
-
-
-
- Back to Overview
+ + +
+
+
- +
+
+
$statuses) : ?> @@ -213,18 +242,32 @@ $isActive = get_role_id() == STAFF_ROLE_ID && in_array(CLAIMS_TEAM_ID,user_team( $truncatedStatus = strlen($formattedStatus) > 20 ? substr($formattedStatus, 0, 15) . '...' : $formattedStatus; $showTooltip = strlen($formattedStatus) > 20; ?> - @@ -239,6 +282,21 @@ $isActive = get_role_id() == STAFF_ROLE_ID && in_array(CLAIMS_TEAM_ID,user_team( function hideAndShowTile(type, claimType = null) { + let dashboardHistoryString = localStorage.getItem('dashboardHistory'); + + if (dashboardHistoryString){ + + let dashboardHistory = JSON.parse(dashboardHistoryString); + + dashboardHistory['tile_params'] = { majorType: type, minorType: claimType }; + dashboardHistory['function_name'] = 'hideAndShowTile'; + + localStorage.setItem('dashboardHistory', JSON.stringify(dashboardHistory)); + + } + + + if (type == 1) { $('.claimTypeTile').hide(); @@ -252,17 +310,25 @@ $isActive = get_role_id() == STAFF_ROLE_ID && in_array(CLAIMS_TEAM_ID,user_team( if (type == 1 && claimType != null) { + if ($('.claimStatusTitle_' + claimType).length > 0) { + console.log("Element exists!"); + } else { + console.log("Element does NOT exist!"); + } + + + $('.claimTypeTile').hide(); - $('.claimStatusTitle_' + claimType).show(); + $('.claimStatusTitle_'+claimType).show(); if (claimType == 1) { - $('#current_tile').text("Viewing Details For : GMC"); + $('#current_tile').text(" GMC"); } else if (claimType == 2) { - $('#current_tile').text("Viewing Details For : GPA"); + $('#current_tile').text(" GPA"); } else if (claimType == 3) { - $('#current_tile').text("Viewing Details For : EDLI"); + $('#current_tile').text(" EDLI"); } else if (claimType == 4) { - $('#current_tile').text("Viewing Details For : GTLI"); + $('#current_tile').text(" GTLI"); } } } @@ -312,7 +378,6 @@ $isActive = get_role_id() == STAFF_ROLE_ID && in_array(CLAIMS_TEAM_ID,user_team( const form = document.createElement('form'); form.method = 'POST'; form.action = url; - form.target = '_blank'; for (const key in data) { if (data.hasOwnProperty(key)) { diff --git a/app/Views/client_deposit_list.php b/app/Views/client_deposit_list.php index b1818640..79adc7f7 100755 --- a/app/Views/client_deposit_list.php +++ b/app/Views/client_deposit_list.php @@ -10,7 +10,7 @@
- "> + ">
@@ -570,20 +570,17 @@ body { if (otherCard !== card) { const otherContent = otherCard.querySelector('.card-content'); const otherIcon = otherCard.querySelector('.accordion-icon i'); - otherContent.classList.remove('active'); - otherIcon.classList.remove('fa-chevron-up'); - otherIcon.classList.add('fa-chevron-down'); + otherIcon.setAttribute('class', 'mdi mdi-chevron-down'); + } }); // Toggle current accordion content.classList.toggle('active'); if (content.classList.contains('active')) { - icon.classList.remove('fa-chevron-down'); - icon.classList.add('fa-chevron-up'); + icon.classList.setAttribute('class', 'mdi mdi-chevron-up'); } else { - icon.classList.remove('fa-chevron-up'); - icon.classList.add('fa-chevron-down'); + icon.classList.setAttribute('class', 'mdi mdi-chevron-down'); } } diff --git a/app/Views/client_policy.php b/app/Views/client_policy.php index 8dfdcce8..4d5503ec 100755 --- a/app/Views/client_policy.php +++ b/app/Views/client_policy.php @@ -23,8 +23,8 @@
- - + +
@@ -669,7 +669,7 @@ // Conditionally render the delete option based on the role if (role !== 3 && role !== 4) { policyTable += ` - Delete`; + Delete`; } policyTable += ` diff --git a/app/Views/employee_data_list.php b/app/Views/employee_data_list.php index feefb665..08d47835 100755 --- a/app/Views/employee_data_list.php +++ b/app/Views/employee_data_list.php @@ -287,12 +287,12 @@
- +
- +
@@ -570,21 +570,53 @@ }); } - function validateInput(input, table, field){ + // function validateInput(input, table, field){ + + // let value = $(input).val(); + // let label = $(input).closest('.form-group').find('label').text().replace('*', '').trim(); + + // let message = "Value is duplicate!"; + // if(label){ + // message = label + " already exists!"; + // } + + // checkDuplicateTableFieldValue(table, field, value, function(isDuplicate) { + // if (isDuplicate) { + // toastr.warning(message, 'WARNING'); + // $(input).val('') + // } + // }); + + // } + + function validateInput(input, table, field) { + + let emp_code = $('#emp_code_for_edit').val(); + let client_id = $('#clients').val(); + console.log("emp_code", emp_code); + console.log("client_id", client_id); let value = $(input).val(); let label = $(input).closest('.form-group').find('label').text().replace('*', '').trim(); let message = "Value is duplicate!"; - if(label){ + if (label) { message = label + " already exists!"; } - checkDuplicateTableFieldValue(table, field, value, function(isDuplicate) { + let data = {}; + data["emp_code !="] = emp_code; + data[field] = value; + + console.log(data); + + checkDuplicateTableFieldValue(table, field, data, function(isDuplicate) { if (isDuplicate) { toastr.warning(message, 'WARNING'); - $(input).val('') - } + $("#btnSubmit").prop('disabled', true); + }else{ + $("#btnSubmit").prop('disabled', false); + } }); } @@ -597,108 +629,106 @@ } var modalInstance; // Store the modal instance globally -function showModal() { - var myModalEl = document.getElementById('emp_history_modal'); - modalInstance = new bootstrap.Modal(myModalEl, { - backdrop: true, // Ensures the backdrop is shown - keyboard: true // Allows closing with the Escape key - }); - modalInstance.show(); -} - -function closeModal() { - if (modalInstance) { - modalInstance.hide(); // Hide the modal and its backdrop - // Manually remove backdrop if it's still visible - setTimeout(function () { - document.querySelector('.modal-backdrop').classList.remove('show'); - }, 150); // Wait for animation to finish + function showModal() { + var myModalEl = document.getElementById('emp_history_modal'); + modalInstance = new bootstrap.Modal(myModalEl, { + backdrop: true, // Ensures the backdrop is shown + keyboard: true // Allows closing with the Escape key + }); + modalInstance.show(); } -} - + function closeModal() { + if (modalInstance) { + modalInstance.hide(); // Hide the modal and its backdrop + // Manually remove backdrop if it's still visible + setTimeout(function () { + document.querySelector('.modal-backdrop').classList.remove('show'); + }, 150); // Wait for animation to finish + } + } function get_emp_history(input, emp_id) { - $('.loader').fadeIn(); - $('.loader-mask').fadeIn(); + $('.loader').fadeIn(); + $('.loader-mask').fadeIn(); - let url = ''; - let requestData = { emp_id: emp_id }; + let url = ''; + let requestData = { emp_id: emp_id }; - sendAjaxRequestForGlobal(url, 'POST', requestData, function(response) { - $('.loader').fadeOut(); - $('.loader-mask').delay(350).fadeOut('slow'); + sendAjaxRequestForGlobal(url, 'POST', requestData, function(response) { + $('.loader').fadeOut(); + $('.loader-mask').delay(350).fadeOut('slow'); - if (response.status === true) { - console.log('response data length', response.data.emp_history.length); + if (response.status === true) { + console.log('response data length', response.data.emp_history.length); - // **Clear old data** - $('#emp_history_content').html(''); + // **Clear old data** + $('#emp_history_content').html(''); - // **Check if data exists** - if (response.data.emp_history.length > 0) { - let historyTable = ` -
-
- - - - - - - - - - - `; - - // **Loop through the data dynamically** - response.data.emp_history.forEach(row => { - historyTable += ` - - - - - - + // **Check if data exists** + if (response.data.emp_history.length > 0) { + let historyTable = ` +
+
+
FieldChangeUserDate/Time
${row.field_name}${row.old_value} => ${row.new_value}${row.created_by}${row.created_at}
+ + + + + + + + + `; - }); - historyTable += ` - -
FieldChangeUserDate/Time
+ // **Loop through the data dynamically** + response.data.emp_history.forEach(row => { + historyTable += ` + + ${row.field_name} + ${row.old_value} => ${row.new_value} + ${row.created_by} + ${row.created_at} + + `; + }); + + historyTable += ` + + +
-
- `; + `; - // **Append to modal** - $('#emp_history_content').append(historyTable); + // **Append to modal** + $('#emp_history_content').append(historyTable); + } else { + $('#emp_history_content').html('

No history available.

'); + } + + // **Show the modal** + showModal(); } else { - $('#emp_history_content').html('

No history available.

'); + let message = response.message; + toastr.error(message, 'ERROR'); } + }, function(xhr, status, error) { + console.error('Error fetching data:', error); + console.error(xhr.responseText); + toastr.error('An error occurred while fetching the report page.', 'ERROR'); - // **Show the modal** - showModal(); - } else { - let message = response.message; - toastr.error(message, 'ERROR'); - } - }, function(xhr, status, error) { - console.error('Error fetching data:', error); - console.error(xhr.responseText); - toastr.error('An error occurred while fetching the report page.', 'ERROR'); + $('.loader').fadeOut(); + $('.loader-mask').delay(350).fadeOut('slow'); + }); + } - $('.loader').fadeOut(); - $('.loader-mask').delay(350).fadeOut('slow'); - }); -} - -// function closeModal(){ -// var myModalEl = document.getElementById('emp_history_modal'); -// var modalInstance = bootstrap.Modal.getInstance(myModalEl); -// if (modalInstance) { -// modalInstance.hide(); -// } -// } + // function closeModal(){ + // var myModalEl = document.getElementById('emp_history_modal'); + // var modalInstance = bootstrap.Modal.getInstance(myModalEl); + // if (modalInstance) { + // modalInstance.hide(); + // } + // } diff --git a/app/Views/endorsement_dash.php b/app/Views/endorsement_dash.php index 20b2710d..adfd445e 100755 --- a/app/Views/endorsement_dash.php +++ b/app/Views/endorsement_dash.php @@ -1,9 +1,5 @@ -
+
-
-
-
-
-
Inception Pending
-

-

 

-

 

+
+ +
+
+
+

Inception Pending

+

+ +

+
 Inception Action
+
-
- -
-
-
-
Pending Insurer
-

-

Exported

-

Not Exported

+ +
+
+
+

Pending Insurer

+

+ +

+
+ Exported : + Not Exported : +
+ +
-
- -
-
-
-
Pending TPA
-

-

Exported

-

Not Exported

+ +
+
+
+

Pending TPA

+

+ +

+
+ Exported : + Not Exported : +
+ +
-
- -
-
-
-
Correction Pending
-

-

Exported

-

Not Exported

+ +
+
+
+

Correction Pending

+

+ +

+
+ Exported : + Not Exported : +
+ +
-
- -
-
-
-
Deletion Pending
-

-

Exported

-

Not Exported

+ +
+
+
+

Deletion Pending

+

+ +

+
+ Exported : + Not Exported : +
+ +
-
- -
-
-
-
SI Enhancment Pending
-

-

Exported

-

Not Exported

+ +
+
+
+

SI Enhancment

+

+ +

+
+ Exported : + Not Exported : +
+ +
-
- -
-
-
-
Policy
-

-

 

-

 

+ +
+
+
+

Policy

+

+ +

+
 Policy Documents
+ +
-
- -
-
-
-
Ticket
-

-

 

-

 

+ +
+
+
+

Ticket

+

+ +

+
 Support Tickets
+ +
+
- -
@@ -38,7 +38,7 @@ value="1" > - Pre enrollment + Pre enrollment
@@ -84,7 +84,7 @@ value="2" > - Active policies + Active policies
@@ -128,7 +128,7 @@
> - CD statement + CD statement
@@ -153,7 +153,7 @@
> - Claims + Claims
diff --git a/app/Views/hr_activity_history.php b/app/Views/hr_activity_history.php index e9dc0a18..15d53361 100644 --- a/app/Views/hr_activity_history.php +++ b/app/Views/hr_activity_history.php @@ -27,8 +27,8 @@ table.dataTable tbody td {
-   - +   +
diff --git a/app/Views/import_export.php b/app/Views/import_export.php index 65a30b3c..0879c988 100755 --- a/app/Views/import_export.php +++ b/app/Views/import_export.php @@ -21,7 +21,7 @@ diff --git a/app/Views/insurer_list.php b/app/Views/insurer_list.php index 5168ba4f..e7ce6e82 100755 --- a/app/Views/insurer_list.php +++ b/app/Views/insurer_list.php @@ -26,6 +26,19 @@ color: #16181b !important; cursor: pointer !important; } + +.btn-color{ + background-color: rgba(52, 174, 178, 1); + color: white; + border:1px solid rgba(52, 174, 178, 1); +} + +.btn-color:hover{ + background-color: rgba(41, 139, 142, 1); + color: white; + border:1px solid rgba(41, 139, 142, 1); +} +
@@ -182,6 +192,13 @@ document.addEventListener("DOMContentLoaded", function () { exportOptions: { columns: ':not(:last-child)' } + }, + { + text: 'ADD', + className: 'btn btn-color', + action: function () { + window.location.href = ""; + } } ], diff --git a/app/Views/insurer_onboarding.php b/app/Views/insurer_onboarding.php index bdc3fd71..68c10e80 100755 --- a/app/Views/insurer_onboarding.php +++ b/app/Views/insurer_onboarding.php @@ -8,7 +8,7 @@ diff --git a/app/Views/irba_report.php b/app/Views/irba_report.php index d86d4452..bb4d0427 100644 --- a/app/Views/irba_report.php +++ b/app/Views/irba_report.php @@ -15,8 +15,8 @@
-   - +   +
> > diff --git a/app/Views/kyc_list.php b/app/Views/kyc_list.php index c1a72d31..8e8eefd6 100755 --- a/app/Views/kyc_list.php +++ b/app/Views/kyc_list.php @@ -26,6 +26,19 @@ color: #16181b !important; cursor: pointer !important; } + +.btn-color{ + background-color: rgba(52, 174, 178, 1); + color: white; + border:1px solid rgba(52, 174, 178, 1); +} + +.btn-color:hover{ + background-color: rgba(41, 139, 142, 1); + color: white; + border:1px solid rgba(41, 139, 142, 1); +} +
@@ -176,6 +186,13 @@ exportOptions: { columns: ':not(:last-child)' } + }, + { + text: 'ADD', + className: 'btn btn-color', + action: function () { + window.location.href = ""; + } } ], diff --git a/app/Views/kyc_onboarding.php b/app/Views/kyc_onboarding.php index 412331ba..7ddeefb4 100755 --- a/app/Views/kyc_onboarding.php +++ b/app/Views/kyc_onboarding.php @@ -39,7 +39,7 @@ body {

KYC Entity Type

+ + + + - + + + + + +
+
+
Welcome first_name) ? get_session_userdata()->first_name : 'NOT SET') ?>
+
+ +
+ + +
+ + diff --git a/app/Views/layout/header_old.php b/app/Views/layout/header_old.php new file mode 100644 index 00000000..def757d5 --- /dev/null +++ b/app/Views/layout/header_old.php @@ -0,0 +1,899 @@ + + + + + + + <?= isset($page_name) ? $page_name : 'NHance'; ?> + + + + + + + + /assets/images/Nhance_Favi.svg"> + + + /assets/libs/admin-resources/jquery.vectormap/jquery-jvectormap-1.2.2.css" rel="stylesheet" type="text/css" /> + + + /assets/libs/datatables.net-bs4/css/dataTables.bootstrap4.min.css" rel="stylesheet" type="text/css" /> + /assets/libs/datatables.net-responsive-bs4/css/responsive.bootstrap4.min.css" rel="stylesheet" type="text/css" /> + /assets/libs/datatables.net-buttons-bs4/css/buttons.bootstrap4.min.css" rel="stylesheet" type="text/css" /> + /assets/libs/datatables.net-select-bs4/css//select.bootstrap4.min.css" rel="stylesheet" type="text/css" /> + + + + /assets/css/bootstrap-creative.min.css" rel="stylesheet" type="text/css" id="bs-default-stylesheet" /> + /assets/css/app-creative.min.css" rel="stylesheet" type="text/css" id="app-default-stylesheet" /> + + /assets/css/bootstrap-creative-dark.min.css" rel="stylesheet" type="text/css" id="bs-dark-stylesheet" /> + /assets/css/app-creative-dark.min.css" rel="stylesheet" type="text/css" id="app-dark-stylesheet" /> + + + /assets/css/icons.min.css" rel="stylesheet" type="text/css" /> + + /assets/libs/bootstrap-datepicker/css/bootstrap-datepicker.min.css" rel="stylesheet" type="text/css" /> + /assets/libs/bootstrap-daterangepicker/daterangepicker.css" rel="stylesheet" type="text/css"> + /assets/libs/bootstrap-daterangepicker/daterangepicker.css" rel="stylesheet" type="text/css"> + + + + + + + + + + + /assets/css/jodit.css" rel="stylesheet" type="text/css" /> + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+
+ /assets/images/nhance-loader-fast.gif" height="40" width="40" alt="Loading..."> +
+
+ + + +
+ + + + + + +
+ + + + +
+ + + +
+ + +
+ + + + + + +
+
+ + +
\ No newline at end of file diff --git a/app/Views/lead_filter.php b/app/Views/lead_filter.php index 441b363b..86938097 100644 --- a/app/Views/lead_filter.php +++ b/app/Views/lead_filter.php @@ -11,7 +11,7 @@
-

Lead Filter

+

Lead Filter

- body { - margin-top: 20px; - background: #FAFAFA; - } .order-card { color: #fff; @@ -123,129 +119,185 @@ margin-top: 0; margin-bottom: 5px; } + + .leadStatusTitle_1{margin-left:20px;} + .leadStatusTitle_2{margin-left:20px;} + + + .inside-tab-content-div{ + display:flex; + justify-content:flex-start !important; + flex-flow: row wrap; + + } + + .dash-card{ + background-color:#F4FBFB !important; + border-radius:25px; + border:2px solid #09B9BF; + box-shadow: 0px 1px 5px rgba(0, 0, 0, 0.1), 0px 4px 8px rgba(0, 0, 0, 0.2); + min-width: 300px; + } + + #leads-dash-tab{ + padding-right: 20px; + } + + .span-color{ + color:#09B9BF !important; + } + + .leadTypeTile{ + margin-left: 20px; + } + + + + +
-
-
-
-
Leads
-

-

-

 

-

 

+
+
+
+
+

Leads

+

+

+
Lead Tracker
+
-
-
-
-
-
BDS Renewals
-

-

-

 

-

 

+
+
+
+

BDS Renewals

+

+ +

+
Renewal Tracker
+
+
-
-
- Back to Overview + + + + +
+ - +
+
- + $value) : ?> + + $value) : ?> - - + 20 ? substr($formattedStatus, 0, 15) . '...' : $formattedStatus; + $showTooltip = strlen($formattedStatus) > 20; + ?> + +
- - $value) : ?> +
- - 20 ? substr($formattedStatus, 0, 15) . '...' : $formattedStatus; - $showTooltip = strlen($formattedStatus) > 20; - ?> - + + // Get the background color for the current tile + $bgColor = $colorShades[$colorSetIndex][$shadeIndex]; + ?> + 20 ? substr($formattedStatus, 0, 15) . '...' : $formattedStatus; + $showTooltip = strlen($formattedStatus) > 20; + ?> + + + +
\ No newline at end of file diff --git a/app/Views/policy_type_onboarding.php b/app/Views/policy_type_onboarding.php index 04e867e0..88a0c68e 100755 --- a/app/Views/policy_type_onboarding.php +++ b/app/Views/policy_type_onboarding.php @@ -39,7 +39,7 @@ body {

Policy Type

- "> + ">
+ + + + + + + + + + + + + + + + $row){ ?> + + + + + + + + + + + + + + + +
Ticket NoNamePolicy NumberTicket TypeSubjectStatusAssign ToCreated AtUpdated At
+ +
+ +
+ + format('d/m/Y') . "
" . $cdt->format('h:i a') . ""; + endif; + ?> +
+ format('d/m/Y') . "
" . $udt->format('h:i a') . ""; + endif; + ?> +
+ +
+
+
+
+
+
+ + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/app/Views/thz_notes.php b/app/Views/thz_notes.php new file mode 100644 index 00000000..6bffa681 --- /dev/null +++ b/app/Views/thz_notes.php @@ -0,0 +1,471 @@ + + + + + +
+
+
+ + +
+ +

+ + + + Ticket ID- +

+
+ + +
+ + +
+
+
+
Details
+ + + + +
+
+
+
Ticket ID
+
+
+
+
Name
+
+
+
+
Mobile
+
+
+
+
Policy Number
+
+ + ' + .$master[0]['policy_no'].' + + ' + : 'N/A'; ?> +
+
+
+
Assigned To
+
+
+
+
Status
+
+
+
+
Ticket Type
+
+
+
+
Subject
+
+
+
+
Message
+
+
+
+
Related Tickets
+
+ + + View + + +
+ +
+ +
+
+
+ + + +
+ + +
+
+
Conversation
+
+
+ +
+ + $conv): ?> + + +
+

+ + + + +
+ + +
+ + +
+ + ' : ''; ?> + + + +
+

No Data Found

+
+ +
+
+ + +
+
+ + + + +
+ +
+ + + + +
+
+
+
+ +
+
+ +
+
+
+ + + + + + + + + + \ No newline at end of file diff --git a/app/Views/ticket_conversation.php b/app/Views/ticket_conversation.php index d2fa00c3..13707a84 100644 --- a/app/Views/ticket_conversation.php +++ b/app/Views/ticket_conversation.php @@ -23,7 +23,7 @@
-
format('j F Y h:i a');?>
+
format('j F Y h:i a');?>

@@ -58,7 +58,7 @@
-
format('j F Y h:i a');?>
+
format('j F Y h:i a');?>

diff --git a/app/Views/ticket_edit_onbording.php b/app/Views/ticket_edit_onbording.php index c84a7206..5a6812ac 100644 --- a/app/Views/ticket_edit_onbording.php +++ b/app/Views/ticket_edit_onbording.php @@ -14,7 +14,7 @@
diff --git a/app/Views/ticket_form_gmc.php b/app/Views/ticket_form_gmc.php index 56e299aa..2d8c2aa2 100644 --- a/app/Views/ticket_form_gmc.php +++ b/app/Views/ticket_form_gmc.php @@ -36,7 +36,7 @@
@@ -58,7 +58,7 @@
-
@@ -51,7 +51,7 @@
- '; } elseif ($row['is_head_approved'] == 1) { - echo $row['status'] . ' '; + echo $row['status'] . ' '; } elseif ($row['is_head_approved'] == 2) { echo $row['status'] . ' '; } else { diff --git a/app/Views/ticket_mail_template.php b/app/Views/ticket_mail_template.php index 9f67a034..5d69d8d9 100644 --- a/app/Views/ticket_mail_template.php +++ b/app/Views/ticket_mail_template.php @@ -23,6 +23,7 @@ .addbtnStyle { margin-left: 20px !important; + color: #000; } .custom-dropdown-menu { @@ -51,6 +52,13 @@ color: #16181b !important; cursor: pointer !important; } + /* strongest, beats most parent rules and pasted styles on wrappers */ + .jodit-container .jodit-wysiwyg, + .jodit-container .jodit-wysiwyg * { + color: #000 !important; + background-color: #fff !important; /* optional: ensure white background */ + } +
@@ -279,6 +287,9 @@ toolbarAdaptive: false, saveHeightInStorage: true, minHeight: 400, + defaultStyle: { + color: '#000000' // 👈 force black text + }, extraButtons: [{ name: 'info', iconURL: '/assets/images/image-solid.svg', // Replace with the actual icon URL diff --git a/app/Views/ticket_reports.php b/app/Views/ticket_reports.php index 4fe9732d..57c73a2e 100644 --- a/app/Views/ticket_reports.php +++ b/app/Views/ticket_reports.php @@ -15,8 +15,8 @@
-   - +   +
> > diff --git a/app/Views/ticket_search.php b/app/Views/ticket_search.php index 7594a910..8a79e1e9 100644 --- a/app/Views/ticket_search.php +++ b/app/Views/ticket_search.php @@ -10,7 +10,8 @@
-
+
+

Claim Filter

diff --git a/app/Views/tpa_list.php b/app/Views/tpa_list.php index d6d44e58..a2a1b5eb 100755 --- a/app/Views/tpa_list.php +++ b/app/Views/tpa_list.php @@ -25,7 +25,21 @@ background-color: #f8f9fa !important; color: #16181b !important; cursor: pointer !important; -} +} + +.btn-color{ + background-color: rgba(52, 174, 178, 1); + color: white; + border:1px solid rgba(52, 174, 178, 1); +} + +.btn-color:hover{ + background-color: rgba(41, 139, 142, 1); + color: white; + border:1px solid rgba(41, 139, 142, 1); +} + +
@@ -176,7 +187,15 @@ document.addEventListener("DOMContentLoaded", function () { exportOptions: { columns: ':not(:last-child)' } + }, + { + text: 'ADD', + className: 'btn btn-color', + action: function () { + window.location.href = ""; + } } + ], diff --git a/app/Views/tpa_onboarding.php b/app/Views/tpa_onboarding.php index 2d6196aa..107d61f9 100755 --- a/app/Views/tpa_onboarding.php +++ b/app/Views/tpa_onboarding.php @@ -39,7 +39,7 @@ body {

TPA

- "> + ">
@@ -461,7 +469,8 @@ $(document).ready(function() { dom: "<'row'<'col-sm-0'f><'col-sm-9 text-right'B>>" + "<'row'<'col-sm-12'tr>>" + "<'row'<'col-sm-5'i><'col-sm-7'p>>", - buttons: [{ + buttons: [ + { extend: 'csv', text: 'CSV', title: 'Vehicle-Master-List', @@ -469,7 +478,19 @@ $(document).ready(function() { exportOptions: { columns: ':not(:last-child)' }, - }], + }, + { + text: 'ADD', + className: 'btn-color', + attr: { + id: 'btnAdd', + title: 'Add' + }, + action: function () { + showModal('add') + } + } + ], language: { search: "_INPUT_", searchPlaceholder: "Search..." diff --git a/app/Views/view_deposit.php b/app/Views/view_deposit.php index 30ee261a..3f18ce81 100755 --- a/app/Views/view_deposit.php +++ b/app/Views/view_deposit.php @@ -86,7 +86,7 @@ diff --git a/app/Views/view_rfq.php b/app/Views/view_rfq.php index f00350cb..87085a6d 100644 --- a/app/Views/view_rfq.php +++ b/app/Views/view_rfq.php @@ -293,7 +293,7 @@ onclick="checkTheTableDataChanged(3)">Send Insurer Mail - + @@ -567,7 +567,7 @@
- > + >
@@ -591,7 +591,7 @@
- > + >
@@ -706,7 +706,7 @@ if(isset($demogrphy_html_data) && !empty($demogrphy_html_data)){ echo $demogrphy_html_data; }else{ - echo "

No Demography Data Found

"; + echo "

No Demography Data Found or Wrong File

"; } ?>
diff --git a/app/Views/view_rfq_non_eb.php b/app/Views/view_rfq_non_eb.php index 8e75cf94..89cf7748 100644 --- a/app/Views/view_rfq_non_eb.php +++ b/app/Views/view_rfq_non_eb.php @@ -461,7 +461,7 @@
- > + >
@@ -485,7 +485,7 @@
- > + >
diff --git a/composer.json b/composer.json index bbe0843f..e86456ca 100755 --- a/composer.json +++ b/composer.json @@ -21,6 +21,7 @@ "google/apiclient": "^2.15.0", "kreait/firebase-php": "^7.0", "laminas/laminas-escaper": "^2.9", + "mpdf/mpdf": "*", "php-amqplib/php-amqplib": "^2.8", "phpmailer/phpmailer": "^6.9", "phpoffice/phpspreadsheet": "^2.1", diff --git a/public/assets/images/active_bds.png b/public/assets/images/active_bds.png new file mode 100644 index 00000000..c0a1b32f Binary files /dev/null and b/public/assets/images/active_bds.png differ diff --git a/public/assets/images/active_claims.png b/public/assets/images/active_claims.png new file mode 100644 index 00000000..2ef84f75 Binary files /dev/null and b/public/assets/images/active_claims.png differ diff --git a/public/assets/images/active_leads_and_bds_renewal.png b/public/assets/images/active_leads_and_bds_renewal.png new file mode 100644 index 00000000..327d5d8c Binary files /dev/null and b/public/assets/images/active_leads_and_bds_renewal.png differ diff --git a/public/assets/images/active_pending_actions.png b/public/assets/images/active_pending_actions.png new file mode 100644 index 00000000..aadbcb25 Binary files /dev/null and b/public/assets/images/active_pending_actions.png differ diff --git a/public/assets/images/inactive_bds.png b/public/assets/images/inactive_bds.png new file mode 100644 index 00000000..4bc9aa57 Binary files /dev/null and b/public/assets/images/inactive_bds.png differ diff --git a/public/assets/images/inactive_claims.png b/public/assets/images/inactive_claims.png new file mode 100644 index 00000000..c405503c Binary files /dev/null and b/public/assets/images/inactive_claims.png differ diff --git a/public/assets/images/inactive_leads_and_bds_renewal.png b/public/assets/images/inactive_leads_and_bds_renewal.png new file mode 100644 index 00000000..b34db30e Binary files /dev/null and b/public/assets/images/inactive_leads_and_bds_renewal.png differ diff --git a/public/assets/images/inactive_pending_actions.png b/public/assets/images/inactive_pending_actions.png new file mode 100644 index 00000000..b75a15f4 Binary files /dev/null and b/public/assets/images/inactive_pending_actions.png differ diff --git a/public/assets/js/pages/treeview.init.js b/public/assets/js/pages/treeview.init.js index 400c7029..33a26040 100755 --- a/public/assets/js/pages/treeview.init.js +++ b/public/assets/js/pages/treeview.init.js @@ -1 +1 @@ -$(document).ready(function(){$("#basicTree").jstree({core:{themes:{responsive:!1}},types:{default:{icon:"mdi mdi-folder-star text-warning"},file:{icon:"mdi mdi-file text-primary"}},plugins:["types"]}),$("#checkTree").jstree({core:{themes:{responsive:!1}},types:{default:{icon:"fa fa-folder text-warning"},file:{icon:"fa fa-file text-primary"}},plugins:["types","checkbox"]}),$("#dragTree").jstree({core:{check_callback:!0,themes:{responsive:!1}},types:{default:{icon:"fa fa-folder text-warning"},file:{icon:"fa fa-file text-primary"}},plugins:["types","dnd"]}),$("#ajaxTree").jstree({core:{check_callback:!0,themes:{responsive:!1},data:{url:function(e){return"#"===e.id?"../assets/data/ajax_roots.json":"../assets/data/ajax_children.json"},data:function(e){return{id:e.id}}}},types:{default:{icon:"fa fa-folder text-warning"},file:{icon:"fa fa-file text-primary"}},plugins:["contextmenu","dnd","search","state","types","wholerow"]})}); \ No newline at end of file +$(document).ready(function(){$("#basicTree").jstree({core:{themes:{responsive:!1}},types:{default:{icon:"mdi mdi-folder-star text-warning"},file:{icon:"mdi mdi-file text-primary"}},plugins:["types"]}),$("#checkTree").jstree({core:{themes:{responsive:!1}},types:{default:{icon:"fa fa-folder text-warning"},file:{icon:"mdi mdi-file text-primary"}},plugins:["types","checkbox"]}),$("#dragTree").jstree({core:{check_callback:!0,themes:{responsive:!1}},types:{default:{icon:"fa fa-folder text-warning"},file:{icon:"mdi mdi-file text-primary"}},plugins:["types","dnd"]}),$("#ajaxTree").jstree({core:{check_callback:!0,themes:{responsive:!1},data:{url:function(e){return"#"===e.id?"../assets/data/ajax_roots.json":"../assets/data/ajax_children.json"},data:function(e){return{id:e.id}}}},types:{default:{icon:"fa fa-folder text-warning"},file:{icon:"mdi mdi-file text-primary"}},plugins:["contextmenu","dnd","search","state","types","wholerow"]})}); \ No newline at end of file diff --git a/public/assets/libs/bootstrap-daterangepicker/index.html b/public/assets/libs/bootstrap-daterangepicker/index.html index 4621257c..459d6138 100755 --- a/public/assets/libs/bootstrap-daterangepicker/index.html +++ b/public/assets/libs/bootstrap-daterangepicker/index.html @@ -31,7 +31,7 @@