diff --git a/app/Config/Acl.php b/app/Config/Acl.php index 371e1a21..b122e08b 100644 --- a/app/Config/Acl.php +++ b/app/Config/Acl.php @@ -8,6 +8,7 @@ class Acl // ===================== PUBLIC / AUTH ===================== '#^/login#' => ['public' => true], + '#^/downloadCdSplitUpFile#' => ['public' => true], '#^/logout#' => ['public' => true], '#^/auth#' => ['public' => true], '#^/oauth2callback#' => ['public' => true], @@ -21,6 +22,7 @@ class Acl '#^/util/log_list#' => ['roles' => [ADMIN_ROLE_ID]], '#^/util/view_log#' => ['roles' => [ADMIN_ROLE_ID]], '#^/util/download_log#' => ['roles' => [ADMIN_ROLE_ID]], + '#^/metaDashboardDemo#' => ['roles' => [ADMIN_ROLE_ID, HEAD_ROLE_ID]], // ===================== PUBLIC DOWNLOADS / FORMS ===================== '#^/download-#' => ['public' => true], diff --git a/app/Config/Filters.php b/app/Config/Filters.php index d96ae232..c9431b94 100755 --- a/app/Config/Filters.php +++ b/app/Config/Filters.php @@ -65,7 +65,7 @@ class Filters extends BaseConfig 'before' => [ 'HttpRequestLog' => ['except' => 'cli/*'], 'Cors', - // 'AclFilter' => ['except' => ['login', 'logout', 'auth/*', 'oauth2callback','claim-form-download', 'claims-feedback-form', 'autobookstackLogin','employeeRest/*','processjob','getCommission']], + 'AclFilter' => ['except' => ['login', 'logout', 'auth/*', 'oauth2callback','claim-form-download', 'claims-feedback-form', 'autobookstackLogin','employeeRest/*','processjob','getCommission']], 'SecurityInputFilter' => ['except' => ['/client/notification/create','/ticket/crud_mail_template/*','test_mail','leads/sendMail'] ], 'GlobalPostFileUploadGuard' // 'csrf', diff --git a/app/Controllers/ClientController.php b/app/Controllers/ClientController.php index 09f34f77..b0e59d7a 100755 --- a/app/Controllers/ClientController.php +++ b/app/Controllers/ClientController.php @@ -450,6 +450,8 @@ class ClientController extends AdminController public function index() { $this->myLogger->logme('error', 'Client list function called'); + // echo ""; + $headerData['tab_name'] = 'Clients'; $headerData['page_name'] = 'Clients'; // Both Browser Tab name And Page name are same. // $data['clientList'] = $this->clientModel->getCreatedByUserName(1); // passing client_type @@ -782,10 +784,10 @@ class ClientController extends AdminController ], 'cd_ac_no' => [ - 'rules' => 'required|is_natural_no_zero', + 'rules' => 'required|regex_match[/^[a-zA-Z0-9\/_\\-]+$/]', 'errors' => [ 'required' => 'Account number is required', - 'is_natural_no_zero' => 'must be a positive integer', + 'regex_match' => 'Account number can only contain letters, numbers, slashes (/), underscores (_), and hyphens (-)', ] ], @@ -2665,439 +2667,154 @@ class ClientController extends AdminController return $insert; } - - // Save Rack Rate function public function createClientPolicyPremium() { - - // echo json_encode(['key' => $this->request->getPost()]); die; - try { - $data = $this->request->getPost(); - $sanitized_post_data = sanitizeInputArrayAdvanced($data); + // 1. Fetch and Sanitize all input at once + $rawPost = $this->request->getPost(); + $data = sanitizeInputArrayAdvanced($rawPost); - $client_id = $sanitized_post_data['client_id'] ?? null; - $client_policy_id = $sanitized_post_data['client_policy_id'] ?? null; - $record = $this->clientPolicyModel->where('client_policy.id', $client_policy_id)->first(); - $premium_type = $sanitized_post_data['premium_type'] ?? null; - if (!empty($client_id) && $client_id != null) { - $client_policy_data = $this->clientPolicyModel->where('id', $client_policy_id)->first(); - $client_id = $client_policy_data['client_id'] ?? null; + // Extract base variables from the sanitized array + $client_id = $data['client_id'] ?? null; + $client_policy_id = $data['client_policy_id'] ?? null; + $premium_type = $data['premium_type'] ?? null; + $policy_grid_id = $data['policy_grid_id'] ?? null; + $rack_rate_name = $data['rack_rate_name'] ?? null; + $si_or_bp = $data['si_or_bp'] ?? null; + + $record = $this->clientPolicyModel->where('id', $client_policy_id)->first(); + if (!$record) { + return $this->respond(['status' => false, 'message' => 'Policy record not found'], 404); } - $branch_units = $this->getBranchUnitsByBranchId($record['client_branch_id']); - $branch_units = json_decode($branch_units); + if (empty($client_id)) { + $client_id = $record['client_id']; + } - $policy_grid_id = $sanitized_post_data['policy_grid_id'] ?? null; - $rack_rate_name = $sanitized_post_data['rack_rate_name'] ?? null; + $branch_units_raw = $this->getBranchUnitsByBranchId($record['client_branch_id']); + $branch_units = json_decode($branch_units_raw, true); + $default_unit = !empty($branch_units) ? $branch_units[0] : null; + // Relationship Logic $relation_data = [ - 'self' => $sanitized_post_data['self'] ?? 'NA', - 'spouse' => $sanitized_post_data['spouse'] ?? 'NA', - 'childrens' => $sanitized_post_data['childrens'] ?? 'NA', - 'parents' => $sanitized_post_data['parents'] ?? 'NA', - 'parents-in-law' => $sanitized_post_data['parents-in-law'] ?? 'NA', + 'self' => $data['self'] ?? 'NA', + 'spouse' => $data['spouse'] ?? 'NA', + 'childrens' => $data['childrens'] ?? 'NA', + 'parents' => $data['parents'] ?? 'NA', + 'parents-in-law' => $data['parents-in-law'] ?? 'NA', ]; - $relation_data_for_form_submit_check = [ - $rack_rate_name => [ - 'self' => $sanitized_post_data['self'] ?? 'NA', - 'spouse' => $sanitized_post_data['spouse'] ?? 'NA', - 'childrens' => $sanitized_post_data['childrens'] ?? 'NA', - 'parents' => $sanitized_post_data['parents'] ?? 'NA', - 'parents-in-law' => $sanitized_post_data['parents-in-law'] ?? 'NA', - ] - ]; - - if ($policy_grid_id == 1 || $policy_grid_id == 2) { - $relation_data = [ - 'self' => 1, - 'spouse' => 'NA', - 'childrens' => 'NA', - 'parents' => 'NA', - 'parents-in-law' => 'NA', - ]; + if (in_array($policy_grid_id, ['1', '2'])) { + $relation_data = ['self' => 1, 'spouse' => 'NA', 'childrens' => 'NA', 'parents' => 'NA', 'parents-in-law' => 'NA']; } - // Convert to JSON $jsonDataForRelation = json_encode($relation_data); - $json_data_relation_data_for_form_submit_check = json_encode($relation_data_for_form_submit_check); + $submit_check_json = json_encode([$rack_rate_name => $relation_data]); - $si_or_bp = $sanitized_post_data['si_or_bp'] ?? null; - $basic_multiplier = str_replace(',', '', $sanitized_post_data['basic_multiplier']); - $premium_multiplier = str_replace(',', '', $sanitized_post_data['premium_multiplier']); - $multiplier = str_replace(',', '', $sanitized_post_data['multiplier']); - $basic_pay = str_replace(',', '', $sanitized_post_data['basic_pay']); - - $data = []; - $data['client_id'] = $client_id; - $data['client_policy_id'] = $client_policy_id; - $data['policy_grid_id'] = $policy_grid_id; - $data['premium_type'] = $premium_type; - $data['rack_rate_name'] = $rack_rate_name; - $data['additional_relationship'] = $jsonDataForRelation; - - $premium = []; - - if ($policy_grid_id == '1' || $policy_grid_id == '2') { - $this->policyPremium1Model->where('client_id', $client_id)->where('client_policy_id', $client_policy_id)->set('is_active', 0)->update(); + // Deactivate old records + if (in_array($policy_grid_id, ['1', '2'])) { + $this->policyPremium1Model->where(['client_id' => $client_id, 'client_policy_id' => $client_policy_id])->set(['is_active' => 0])->update(); } else { - $this->policyPremium2Model->where('client_id', $client_id)->where('client_policy_id', $client_policy_id)->where('rack_rate_name', $rack_rate_name)->set('is_active', 0)->update(); + $this->policyPremium2Model->where(['client_id' => $client_id, 'client_policy_id' => $client_policy_id, 'rack_rate_name' => $rack_rate_name])->set(['is_active' => 0])->update(); } + // Helper closures for cleaning and unit selection + $cleanNum = fn($val) => str_replace(',', '', (string)($val ?? '0')); + $getUnit = fn($unitArr, $index) => (empty($unitArr[$index]) || $unitArr[$index] === 'undefined') ? $default_unit : $unitArr[$index]; + + $insert = false; + $baseInsertData = [ + 'client_id' => $client_id, + 'client_policy_id' => $client_policy_id, + 'policy_grid_id' => $policy_grid_id, + 'premium_type' => $premium_type, + 'rack_rate_name' => $rack_rate_name, + 'additional_relationship' => $jsonDataForRelation + ]; + + // --- Logic Switch based on Grid ID --- + if ($policy_grid_id == '1') { - if ($si_or_bp == '1') { - - $premium = str_replace(',', '', $sanitized_post_data['gpa_sum_premium[]']); - $sum_insure = str_replace(',', '', $sanitized_post_data['gpa_sum_si[]']); - $multiplier = $sanitized_post_data['gpa_sum_multiplier'] ?? null; - $unit = $sanitized_post_data['gpa_unit_1[]'] ?? null; - - for ($i = 0; $i < count($premium); $i++) { - $data['si'] = $sum_insure[$i]; - $data['premium'] = $premium[$i]; - $data['multiplier'] = $multiplier; - $data['si_or_bp'] = $sanitized_post_data['si_or_bp'] ?? null; - if (empty($unit) || !isset($unit[$i]) || empty($unit[$i])) { - $data['unit'] = $branch_units[0]; - } else { - $data['unit'] = $unit[$i]; - } - - $policyPremium = $this->policyPremium1Model->insert($data); + $premiums = $data['gpa_sum_premium'] ?? []; + foreach ($premiums as $i => $p) { + $this->policyPremium1Model->insert(array_merge($baseInsertData, [ + 'si' => $cleanNum($data['gpa_sum_si'][$i] ?? 0), + 'premium' => $cleanNum($p), + 'multiplier' => $data['gpa_sum_multiplier'] ?? null, + 'si_or_bp' => $si_or_bp, + 'unit' => $getUnit($data['gpa_unit_1'] ?? [], $i) + ])); + $insert = true; } } else if ($si_or_bp == '3') { - - $premium = str_replace(',', '', $sanitized_post_data['gpa_sum_premium2[]']); - $sum_insure = str_replace(',', '', $sanitized_post_data['gpa_sum_si2[]']); - $multiplier = $sanitized_post_data['gpa_sum_multiplier2'] ?? null; - $grade = $sanitized_post_data['gpa_band[]'] ?? null; - $unit = $sanitized_post_data['gpa_unit_3[]'] ?? null; - - - for ($i = 0; $i < count($premium); $i++) { - $data['si'] = $sum_insure[$i]; - $data['premium'] = $premium[$i]; - $data['grade'] = $grade[$i]; - $data['multiplier'] = $multiplier; - $data['si_or_bp'] = $sanitized_post_data['si_or_bp'] ?? null; - if (empty($unit) || !isset($unit[$i]) || empty($unit[$i])) { - $data['unit'] = $branch_units[0]; - } else { - $data['unit'] = $unit[$i]; - } - - $policyPremium = $this->policyPremium1Model->insert($data); + $premiums = $data['gpa_sum_premium2'] ?? []; + foreach ($premiums as $i => $p) { + $this->policyPremium1Model->insert(array_merge($baseInsertData, [ + 'si' => $cleanNum($data['gpa_sum_si2'][$i] ?? 0), + 'premium' => $cleanNum($p), + 'grade' => $data['gpa_band'][$i] ?? null, + 'multiplier' => $data['gpa_sum_multiplier2'] ?? null, + 'si_or_bp' => $si_or_bp, + 'unit' => $getUnit($data['gpa_unit_3'] ?? [], $i) + ])); + $insert = true; } } else if ($si_or_bp == '2') { - - $premium = str_replace(',', '', $sanitized_post_data['gpa_basic_premium[]']); - $sum_insure = str_replace(',', '', $sanitized_post_data['gpa_basic_si[]']); - $basic_pay = str_replace(',', '', $sanitized_post_data['basic_pay[]']); - $unit = $sanitized_post_data['gpa_unit[]'] ?? null; - - - for ($i = 0; $i < count($premium); $i++) { - - $data['si_or_bp'] = $sanitized_post_data['si_or_bp'] ?? null; - $data['basic_multiplier'] = str_replace(',', '', $sanitized_post_data['basic_multiplier']); - $data['multiplier'] = $sanitized_post_data['premium_multiplier'] ?? null; - $data['basic_pay'] = $basic_pay[$i]; - $data['si'] = $sum_insure[$i]; - $data['premium'] = $premium[$i]; - if (empty($unit) || !isset($unit[$i]) || empty($unit[$i])) { - $data['unit'] = $branch_units[0]; - } else { - $data['unit'] = $unit[$i]; - } - - $policyPremium = $this->policyPremium1Model->insert($data); + $premiums = $data['gpa_basic_premium'] ?? []; + foreach ($premiums as $i => $p) { + $this->policyPremium1Model->insert(array_merge($baseInsertData, [ + 'si_or_bp' => $si_or_bp, + 'basic_multiplier' => $cleanNum($data['basic_multiplier'] ?? 0), + 'multiplier' => $cleanNum($data['premium_multiplier'] ?? 0), + 'basic_pay' => $cleanNum($data['basic_pay'][$i] ?? 0), + 'si' => $cleanNum($data['gpa_basic_si'][$i] ?? 0), + 'premium' => $cleanNum($p), + 'unit' => $getUnit($data['gpa_unit'] ?? [], $i) + ])); + $insert = true; } - } else { - - $data['premium'] = str_replace(',', '', $sanitized_post_data['gpa_basic_premium']); - $data['si'] = str_replace(',', '', $sanitized_post_data['gpa_basic_si']); - $data['basic_multiplier'] = str_replace(',', '', $sanitized_post_data['basic_multiplier']); - $data['multiplier'] = $sanitized_post_data['premium_multiplier'] ?? null; - $data['basic_pay'] = str_replace(',', '', $sanitized_post_data['basic_pay']); - $data['si_or_bp'] = $sanitized_post_data['si_or_bp'] ?? null; - - $policyPremium = $this->policyPremium1Model->insert($data); } - - $data = $sanitized_post_data; - $insert = true; - } else if ($policy_grid_id == '2') { - - $premium = $sanitized_post_data['gpa_premium29[]'] ?? null; - $sum_insure = $sanitized_post_data['gpa_si29[]'] ?? null; - $unit = $sanitized_post_data['gpa_unit29[]'] ?? null; - - for ($i = 0; $i < count($premium); $i++) { - $data['premium'] = str_replace(',', '', $premium[$i]); - $data['si'] = str_replace(',', '', $sum_insure[$i]); - if (empty($unit) || !isset($unit[$i]) || empty($unit[$i])) { - $data['unit'] = $branch_units[0]; - } else { - $data['unit'] = $unit[$i]; - } - $dataa = $this->policyPremium1Model->insert($data); + } else if (in_array($policy_grid_id, ['2', '9'])) { + $premiums = $data['gpa_premium29'] ?? []; + $model = ($policy_grid_id == '2') ? $this->policyPremium1Model : $this->policyPremium2Model; + foreach ($premiums as $i => $p) { + $model->insert(array_merge($baseInsertData, [ + 'premium' => $cleanNum($p), + 'si' => $cleanNum($data['gpa_si29'][$i] ?? 0), + 'unit' => $getUnit($data['gpa_unit29'] ?? [], $i) + ])); + $insert = true; } + } else { + // Handles grids 3, 4, 5, 6, 7, 8, 10, 11, 12, 13 + $pfx = $policy_grid_id . "_"; + $premiums = $data[$pfx . 'premium'] ?? []; + $is_si_array = is_array($data[$pfx . 'si'] ?? null); - $data = $sanitized_post_data; - $insert = true; - } else if ($policy_grid_id == '3') { - - $premium = $sanitized_post_data['3_premium[]'] ?? null; - $sum_insure = $sanitized_post_data['3_si[]'] ?? null; - $unit = $sanitized_post_data['3_unit[]'] ?? null; - - for ($i = 0; $i < count($premium); $i++) { - $data['premium'] = str_replace(',', '', $premium[$i]); - $data['si'] = str_replace(',', '', $sum_insure[$i]); - if (empty($unit) || !isset($unit[$i]) || empty($unit[$i])) { - $data['unit'] = $branch_units[0]; - } else { - $data['unit'] = $unit[$i]; - } - $dataa = $this->policyPremium2Model->insert($data); + foreach ($premiums as $i => $p) { + $this->policyPremium2Model->insert(array_merge($baseInsertData, [ + 'premium' => $cleanNum($p), + 'si' => $cleanNum($is_si_array ? ($data[$pfx . 'si'][$i] ?? 0) : ($data[$pfx . 'si'] ?? 0)), + 'unit' => $getUnit($data[$pfx . 'unit'] ?? [], $i), + 'age_from' => $data[$pfx . 'age_from'][$i] ?? null, + 'age_to' => $data[$pfx . 'age_to'][$i] ?? null, + 'grade' => $data[$pfx . 'grade'][$i] ?? null, + 'relationship' => $data[$pfx . 'relationship'][$i] ?? null, + 'max_si' => $cleanNum($data[$pfx . 'max_si'][$i] ?? 0) + ])); + $insert = true; } - $data = $sanitized_post_data; - $insert = true; - } else if ($policy_grid_id == '4') { - - $premium = $sanitized_post_data['4_premium[]'] ?? null; - $sum_insure = $sanitized_post_data['4_si'] ?? null; - $age_from = $sanitized_post_data['4_age_from[]'] ?? null; - $age_to = $sanitized_post_data['4_age_to[]'] ?? null; - $unit = $sanitized_post_data['4_unit[]'] ?? null; - - for ($i = 0; $i < count($premium); $i++) { - $data['premium'] = str_replace(',', '', $premium[$i]); - $data['si'] = str_replace(',', '', $sum_insure); - $data['age_from'] = $age_from[$i]; - $data['age_to'] = $age_to[$i]; - if (empty($unit) || !isset($unit[$i]) || empty($unit[$i])) { - $data['unit'] = $branch_units[0]; - } else { - $data['unit'] = $unit[$i]; - } - - $dataa = $this->policyPremium2Model->insert($data); - } - $data = $sanitized_post_data; - $insert = true; - } else if ($policy_grid_id == '5') { - - $premium = $sanitized_post_data['5_premium[]'] ?? null; - $sum_insure = $sanitized_post_data['5_si[]']?? null; - $age_from = $sanitized_post_data['5_age_from[]']?? null; - $age_to = $sanitized_post_data['5_age_to[]']?? null; - $unit = $sanitized_post_data['5_unit[]']?? null; - - for ($i = 0; $i < count($premium); $i++) { - $data['premium'] = str_replace(',', '', $premium[$i]); - $data['si'] = str_replace(',', '', $sum_insure[$i]); - $data['age_from'] = $age_from[$i]; - $data['age_to'] = $age_to[$i]; - if (empty($unit) || !isset($unit[$i]) || empty($unit[$i] || $unit[$i] == 'undefined')) { - $data['unit'] = $branch_units[0]; - } else { - $data['unit'] = $unit[$i]; - } - - $dataa = $this->policyPremium2Model->insert($data); - } - - $data = $sanitized_post_data; - $insert = true; - } else if ($policy_grid_id == '6') { - - $premium = $sanitized_post_data['6_premium[]']?? null; - $sum_insure = $sanitized_post_data['6_si']?? null; - $age_from = $sanitized_post_data['6_age_from[]']?? null; - $age_to = $sanitized_post_data['6_age_to[]']?? null; - $unit = $sanitized_post_data['6_unit[]']?? null; - - for ($i = 0; $i < count($premium); $i++) { - $data['premium'] = str_replace(',', '', $premium[$i]); - $data['si'] = str_replace(',', '', $sum_insure); - $data['age_from'] = $age_from[$i]; - $data['age_to'] = $age_to[$i]; - if (empty($unit) || !isset($unit[$i]) || empty($unit[$i])) { - $data['unit'] = $branch_units[0]; - } else { - $data['unit'] = $unit[$i]; - } - - $dataa = $this->policyPremium2Model->insert($data); - } - $data = $sanitized_post_data; - $insert = true; - } else if ($policy_grid_id == '7') { - $premium = $sanitized_post_data['7_premium[]'] ?? null; - $sum_insure = $sanitized_post_data['7_si[]'] ?? null; - $age_from = $sanitized_post_data['7_age_from[]'] ?? null; - $age_to = $sanitized_post_data['7_age_to[]'] ?? null; - $unit = $sanitized_post_data['7_unit[]'] ?? null; - - for ($i = 0; $i < count($premium); $i++) { - $data['premium'] = str_replace(',', '', $premium[$i]); - $data['si'] = str_replace(',', '', $sum_insure[$i]); - $data['age_from'] = $age_from[$i]; - $data['age_to'] = $age_to[$i]; - if (empty($unit) || !isset($unit[$i]) || empty($unit[$i])) { - $data['unit'] = $branch_units[0]; - } else { - $data['unit'] = $unit[$i]; - } - - $dataa = $this->policyPremium2Model->insert($data); - } - $data = $sanitized_post_data; - $insert = true; - } else if ($policy_grid_id == '8') { - $premium = $sanitized_post_data['8_premium[]']?? null; - $sum_insure = $sanitized_post_data['8_si[]']?? null; - $grade = $sanitized_post_data['8_grade[]']?? null; - $unit = $sanitized_post_data['8_unit[]']?? null; - - for ($i = 0; $i < count($premium); $i++) { - $data['premium'] = str_replace(',', '', $premium[$i]); - $data['si'] = str_replace(',', '', $sum_insure[$i]); - $data['grade'] = $grade[$i]; - if (empty($unit) || !isset($unit[$i]) || empty($unit[$i])) { - $data['unit'] = $branch_units[0]; - } else { - $data['unit'] = $unit[$i]; - } - - $dataa = $this->policyPremium2Model->insert($data); - } - $data = $sanitized_post_data; - $insert = true; - } else if ($policy_grid_id == '9') { - - $premium = $sanitized_post_data['gpa_premium29[]']?? null; - $sum_insure = $sanitized_post_data['gpa_si29[]']?? null; - $unit = $sanitized_post_data['gpa_unit29[]']?? null; - - for ($i = 0; $i < count($premium); $i++) { - $data['premium'] = str_replace(',', '', $premium[$i]); - $data['si'] = str_replace(',', '', $sum_insure[$i]); - if (empty($unit) || !isset($unit[$i]) || empty($unit[$i])) { - $data['unit'] = $branch_units[0]; - } else { - $data['unit'] = $unit[$i]; - } - $dataa = $this->policyPremium2Model->insert($data); - } - - $data = $sanitized_post_data; - $insert = true; - } else if ($policy_grid_id == '10') { - $premium = $sanitized_post_data['10_premium[]']?? null; - $sum_insure = $sanitized_post_data['10_si[]']?? null; - $age_from = $sanitized_post_data['10_age_from[]']?? null; - $age_to = $sanitized_post_data['10_age_to[]']?? null; - $unit = $sanitized_post_data['10_unit[]']?? null; - - for ($i = 0; $i < count($premium); $i++) { - $data['premium'] = str_replace(',', '', $premium[$i]); - $data['si'] = str_replace(',', '', $sum_insure[$i]); - $data['age_from'] = $age_from[$i]; - $data['age_to'] = $age_to[$i]; - if (empty($unit) || !isset($unit[$i]) || empty($unit[$i])) { - $data['unit'] = $branch_units[0]; - } else { - $data['unit'] = $unit[$i]; - } - - - $policyPremium = $this->policyPremium2Model->insert($data); - } - $data = $sanitized_post_data; - $insert = true; - } else if ($policy_grid_id == '11') { - - $premium = $sanitized_post_data['11_premium[]']?? null; - $sum_insure = $sanitized_post_data['11_si[]']?? null; - $grade = $sanitized_post_data['11_grade[]']?? null; - $max_sum_insure = $sanitized_post_data['11_max_si[]']?? null; - $unit = $sanitized_post_data['11_unit[]']?? null; - - for ($i = 0; $i < count($premium); $i++) { - $data['premium'] = str_replace(',', '', $premium[$i]); - $data['si'] = str_replace(',', '', $sum_insure[$i]); - $data['grade'] = $grade[$i]; - $data['max_si'] = str_replace(',', '', $max_sum_insure[$i]); - if (empty($unit) || !isset($unit[$i]) || empty($unit[$i])) { - $data['unit'] = $branch_units[0]; - } else { - $data['unit'] = $unit[$i]; - } - - $dataa = $this->policyPremium2Model->insert($data); - } - $data = $sanitized_post_data; - $insert = true; - } else if ($policy_grid_id == '12') { - - $premium = $sanitized_post_data['12_premium[]']?? null; - $sum_insure = $sanitized_post_data['12_si[]']?? null; - $relationship = $sanitized_post_data['12_relationship[]']?? null; - $unit = $sanitized_post_data['12_unit[]']?? null; - - for ($i = 0; $i < count($premium); $i++) { - $data['premium'] = str_replace(',', '', $premium[$i]); - $data['si'] = str_replace(',', '', $sum_insure[$i]); - $data['relationship'] = $relationship[$i]; - if (empty($unit) || !isset($unit[$i]) || empty($unit[$i])) { - $data['unit'] = $branch_units[0]; - } else { - $data['unit'] = $unit[$i]; - } - - $dataa = $this->policyPremium2Model->insert($data); - } - $data = $sanitized_post_data; - $insert = true; - } else if ($policy_grid_id == '13') { - - $premium = $sanitized_post_data['13_premium[]']?? null; - $sum_insure = $sanitized_post_data['13_si[]']?? null; - $age_from = $sanitized_post_data['13_age_from[]']?? null; - $age_to = $sanitized_post_data['13_age_to[]']?? null; - $relationship = $sanitized_post_data['13_relationship[]']?? null; - $unit = $sanitized_post_data['13_unit[]']?? null; - - for ($i = 0; $i < count($premium); $i++) { - $data['premium'] = str_replace(',', '', $premium[$i]); - $data['si'] = str_replace(',', '', $sum_insure[$i]); - $data['age_from'] = $age_from[$i]; - $data['age_to'] = $age_to[$i]; - $data['relationship'] = $relationship[$i]; - if (empty($unit) || !isset($unit[$i]) || empty($unit[$i])) { - $data['unit'] = $branch_units[0]; - } else { - $data['unit'] = $unit[$i]; - } - - $dataa = $this->policyPremium2Model->insert($data); - } - $data = $sanitized_post_data; - $insert = true; } if ($insert) { - return $this->respond(['status' => true, 'code' => 200, 'data' => $data, 'rack_rate_json' => $json_data_relation_data_for_form_submit_check,], 200); - } else { - return $this->respond(['status' => false, 'code' => 404, 'data' => $data, 'message' => 'no data found'], 200); + return $this->respond(['status' => true, 'code' => 200, 'data' => $data, 'rack_rate_json' => $submit_check_json], 200); } + + return $this->respond(['status' => false, 'code' => 404, 'message' => 'No data found'], 200); } catch (\Exception $e) { - echo 'Error: ' . $e->getMessage() . ' at line no ' . $e->getLine(); + return $this->respond(['status' => false, 'message' => $e->getMessage() . ' line ' . $e->getLine()], 500); } } @@ -6731,12 +6448,12 @@ class ClientController extends AdminController // $response = $ticketServiceController->getClaimExcelErrorData(["file_id" => 41]); // $response = $ticketServiceController->claimDumpOnBoardProcess(["file_id" => 17]); // $response = $ticketServiceController->extractExcelData("claims_dump_form_client.xlsx"); - // $response = $ticketServiceController->tpaClaimDumpImporter(["file_id" => 52]); //reliance - // $response = $ticketServiceController->tpaClaimDumpImporter(["file_id" => 50]); //fhpl // $response = $ticketServiceController->tpaClaimDumpImporter(["file_id" => 51]); //abhi - // $response = $ticketServiceController->tpaClaimDumpImporter(["file_id" => 48]); //vidal + // $response = $ticketServiceController->tpaClaimDumpImporter(["file_id" => 50]); //fhpl // $response = $ticketServiceController->tpaClaimDumpImporter(["file_id" => 53]); //icici // $response = $ticketServiceController->tpaClaimDumpImporter(["file_id" => 54]); //mediassist + // $response = $ticketServiceController->tpaClaimDumpImporter(["file_id" => 52]); //reliance + // $response = $ticketServiceController->tpaClaimDumpImporter(["file_id" => 48]); //vidal // $response = $ticketServiceController->tpaClaimDumpToTicketMasterImporters(["file_id" => 48]); //vidal // $response = $ticketServiceController->tpaClaimDumpToTicketMasterImporters(["file_id" => 54]); //mediassist @@ -6753,9 +6470,9 @@ class ClientController extends AdminController // ---------- EMP SERVICE CONTROLLER -------------------------------------------------------------------------------- $empServiceController = new EmployeeServiceController(); - // $res = $empServiceController->excelFileFormatValidation(['file_id' => '1248']); - // $res = $empServiceController->excelFileDataValidation(['file_id' => '1252']); - // $res = $empServiceController->employeesOnboardPreprocess(['file_id' => 1263]); + // $res = $empServiceController->excelFileFormatValidation(['file_id' => '1264']); + // $res = $empServiceController->excelFileDataValidation(['file_id' => '1264']); + // $res = $empServiceController->employeesOnboardPreprocess(['file_id' => 1264]); // $res = $empServiceController->employeesOnboardPreprocess(['file_id' => 1262]); // $res = $empServiceController->employeesOnboardPreprocess(['file_id' => 1169]); // $res = $empServiceController->employeesOnboardProcess(['file_id' => 835]); diff --git a/app/Controllers/EmployeeController.php b/app/Controllers/EmployeeController.php index b279f1f2..bc12d31b 100755 --- a/app/Controllers/EmployeeController.php +++ b/app/Controllers/EmployeeController.php @@ -581,6 +581,8 @@ class EmployeeController extends AdminController $filePath = ROOTPATH . 'public/sample_excel/sample_multievent_file.xlsx'; }else if ($actionType == 'bds_upload') { $filePath = ROOTPATH . 'public/sample_excel/sample_bds_bulk_upload_excel.xlsx'; + }else if ($actionType == 'claim_dump_upload') { + $filePath = ROOTPATH . 'public/sample_excel/sample_claim_dump_upload_excel.xlsx'; } // Check if the file exists @@ -2744,27 +2746,26 @@ class EmployeeController extends AdminController { $rules = [ - 'emp_code' => [ - 'rules' => 'required', - 'errors' => [ - 'required' => 'Employee Code is missing' - ] - ], - - 'name' => [ - 'rules' => 'required|min_length[2]|max_length[100]', - 'errors' => [ - 'required' => 'Employee name is required', - 'min_length' => 'Name must be at least 2 characters', - 'max_length' => 'Name cannot exceed 100 characters' - ] - ], - 'gender' => [ - 'rules' => 'permit_empty|in_list[M,F]', - 'errors' => [ - 'in_list' => 'Invalid gender selected' - ] - ], + // 'emp_code' => [ + // 'rules' => 'required', + // 'errors' => [ + // 'required' => 'Employee Code is missing' + // ] + // ], + // 'name' => [ + // 'rules' => 'required|min_length[2]|max_length[100]', + // 'errors' => [ + // 'required' => 'Employee name is required', + // 'min_length' => 'Name must be at least 2 characters', + // 'max_length' => 'Name cannot exceed 100 characters' + // ] + // ], + // 'gender' => [ + // 'rules' => 'permit_empty|in_list[M,F]', + // 'errors' => [ + // 'in_list' => 'Invalid gender selected' + // ] + // ], 'email_corporate' => [ 'rules' => 'required|valid_email', 'errors' => [ @@ -2772,7 +2773,6 @@ class EmployeeController extends AdminController 'valid_email' => 'Enter a valid email address' ] ], - 'mobile' => [ 'rules' => 'required|numeric|exact_length[10]', 'errors' => [ @@ -3407,9 +3407,10 @@ class EmployeeController extends AdminController try { $rules = [ 'endorsement_no' => [ - 'rules' => 'required', + 'rules' => 'required|regex_match[/^[a-zA-Z0-9\/_\-]+$/]', 'errors' => [ - 'required' => 'Endorsement Number is missing' + 'required' => 'Endorsement Number is missing.', + 'regex_match' => 'Endorsement Number can only contain letters, numbers, slashes (/), underscores (_), and hyphens (-).' ] ], 'status' => [ diff --git a/app/Controllers/EmployeeRestController.php b/app/Controllers/EmployeeRestController.php index 7ca38900..a3368b66 100755 --- a/app/Controllers/EmployeeRestController.php +++ b/app/Controllers/EmployeeRestController.php @@ -607,7 +607,7 @@ class EmployeeRestController extends AdminController { try { - $empData = $this->employeePolicyModel->getEmployeePolicy(client_id: $this->request->getGet('client_id'), policy_id: $this->request->getGet('client_policy_id'), status: 0, branch_id: $this->request->getGet('client_branch_id')); + $empData = $this->employeePolicyModel->getEmployeePolicy(client_id: $this->request->getGet('client_id'), policy_id: $this->request->getGet('client_policy_id'), status: 0, branch_id: $this->request->getGet('client_branch_id'), status_type: 'inactive'); if ($empData) { return $this->respond(['status' => 'success', 'code' => 200, 'data' => $empData], 200); @@ -2360,15 +2360,15 @@ class EmployeeRestController extends AdminController $value['policy_name'] = $policyTypeData->long_name; $value['insurer_name'] = $insurerData->name; $value['insurer_short_name'] = $insurerData->short_name; - $employeeDetails = $this->employeePolicyModel->getEmployeePolicy(client_id: $value['client_id'], policy_id: $value['client_policy_id'], status: 0, branch_id: $this->request->getGet('client_branch_id')); + $employeeDetails = $this->employeePolicyModel->getEmployeePolicy(client_id: $value['client_id'], policy_id: $value['client_policy_id'], status: 0, branch_id: $this->request->getGet('client_branch_id'), status_type: 'inactive'); // dd($employeeDetails); $activeCount = 0; $inactiveCount = 0; if (count($employeeDetails)) { foreach ($employeeDetails as $item) { - if ($item['emp_status'] === 'active') { + if ($item['status'] === 'active') { $activeCount++; - } elseif ($item['emp_status'] === 'inactive') { + } elseif ($item['status'] === 'inactive') { $inactiveCount++; } } @@ -2457,6 +2457,7 @@ class EmployeeRestController extends AdminController $result = $clientController->view_Deposit($insurerId, $requestFrom = 'rest', $param = ['client_id' => $clientId, 'cd_ac_pk' => $cdAccountPrimaryKey]); $data['insurer_name'] = $result['insurerName']->name; + $data['insurer_short_name'] = $result['insurerName']->short_name; $data['account_number'] = $result['insurerName']->cd_master_account_no; $data['total_deposit'] = $result['deposiamount']->total_credit; $data['total_consumed'] = $result['deposiamount']->total_withdraw; @@ -2501,6 +2502,12 @@ class EmployeeRestController extends AdminController $search_data = $this->request->getJSON(true); // Get JSON as associative array + if ( isset($search_data['client_id']) &&is_string($search_data['client_id']) && preg_match('/^[a-f0-9]{32}$/i', $search_data['client_id'])) { + $client_data = $this->clientModel->where('MD5(id)', $search_data['client_id'])->first(); + $search_data['client_id'] = $client_data['id'] ?? null; + } + + $client_id = isset($search_data['client_id']) ? (int) $search_data['client_id'] : 0; unset($search_data['client_id']); unset($search_data['client_branch_id']); @@ -2612,7 +2619,7 @@ class EmployeeRestController extends AdminController $builder->where('tm.is_active', 1); if ($client_id > 0) { - $builder->where('md5(tm.client_id)', $client_id); + $builder->where('tm.client_id', $client_id); } if (!empty($from_date) && !empty($to_date)) { @@ -5440,7 +5447,7 @@ class EmployeeRestController extends AdminController $file_id = $this->request->getGet('id'); // Find record - $record = $this->batchFileModel->where('id', $file_id)->first();; + $record = $this->batchFileModel->where('MD5(id)', $file_id)->first(); if (!$record) { $data['message'] = 'File record not found'; return view('errors/404', $data); diff --git a/app/Controllers/EmployeeServiceController.php b/app/Controllers/EmployeeServiceController.php index 84761c68..bc4bfa7c 100755 --- a/app/Controllers/EmployeeServiceController.php +++ b/app/Controllers/EmployeeServiceController.php @@ -1402,6 +1402,8 @@ class EmployeeServiceController extends AdminController $employee_data_group_by_family = data_group_by_family($excel_data, 'excel', '', $current_column_action); // dd($employee_data_group_by_family); + + $employee_insert_count = 0; foreach ($employee_data_group_by_family as $emp_id => $family) { @@ -1425,11 +1427,25 @@ class EmployeeServiceController extends AdminController $data = calculate_premium_new(family_data:$family,policy_terms: $policy_terms,slab_details : $slab_details,fileArr: $file, existing_units:$existing_units); // dd($data); $employee_data_group_by_family[$emp_id] = $data; - $this->employeesOnboardProcess(['familiy_data' => $data,'file' => $file]); + $res = $this->employeesOnboardProcess(['familiy_data' => $data,'file' => $file]); + + if($res > 0){ + $employee_insert_count++; + } } - $this->fileModel->where('id', $file_id)->set(['status' => 'success','reason' => ''])->update(); - $this->myLogger->logme("error",'{file_id} uploaded success',['file_id' => $file_id]); + if($employee_insert_count > 0){ + $this->fileModel->where('id', $file_id)->set(['status' => 'success','reason' => ''])->update(); + $this->myLogger->logme("error",'{file_id} uploaded success',['file_id' => $file_id]); + }else{ + $reason = json_encode([ + 'error_summary' => [5 => 1], + 'error_data' => "Rack rate configuration issue: Please check the slab rates configuration" + ], JSON_UNESCAPED_UNICODE | JSON_UNESCAPED_SLASHES); + $this->fileModel->where('id', $file_id)->set(['status' => 'failed','reason' => $reason])->update(); + $this->myLogger->logme("error",'{file_id} uploaded failed with reason: Rack rate configuration issue: Please check the slab rates configuration',['file_id' => $file_id]); + + } $this->setPullNotification($this->getFileMetaDataByFileId($file_id,'success')); @@ -1842,6 +1858,7 @@ class EmployeeServiceController extends AdminController $policy_details = $this->clientPolicyModel->where('id', $file['policy_id'])->first(); // dd($policy_details); + $employee_insert_count = 0; foreach($familiy_data as $fkey => $value) { if(is_array($value)) @@ -1974,6 +1991,7 @@ class EmployeeServiceController extends AdminController // else{ $emp_policy_id = $employee_policy[0]['id']; } $this->myLogger->logme('error',$log_message); + $employee_insert_count++; }// if end }// is array check end @@ -1982,6 +2000,8 @@ class EmployeeServiceController extends AdminController $this->myLogger->logme('error','######Incoming value is not an array'); } }// for end + + return $employee_insert_count; }//function end diff --git a/app/Controllers/LeadsController.php b/app/Controllers/LeadsController.php index c8413098..dc577af0 100644 --- a/app/Controllers/LeadsController.php +++ b/app/Controllers/LeadsController.php @@ -380,7 +380,7 @@ class LeadsController extends BaseController { $rules = [ 'lead_type' => [ - 'rules' => 'required', + 'rules' => 'integer', 'errors' => ['required' => 'Lead Type is required'] ], 'issuer' => [ @@ -455,6 +455,38 @@ class LeadsController extends BaseController 'errors' => ['required' => 'Date of Expiry is required'] ]; } + + // 1. MANUALLY VALIDATE FILES BEFORE PROCESSING + // $allFiles = $this->request->getFiles(); + // foreach ($allFiles as $inputName => $files) { + // // If it's a single file, wrap it in an array to use the same logic + // $fileArray = is_array($files) ? $files : [$files]; + + // foreach ($fileArray as $index => $file) { + // if ($file->isValid() && !$file->hasMoved()) { + // $extension = strtolower($file->getExtension()); + + // // Logic: index 0 is Excel only, others are mixed + // if ($index === 0) { + // $allowed = ['xls', 'xlsx']; + // } else { + // $allowed = ['xls', 'xlsx', 'pdf', 'jpg', 'jpeg', 'png']; + // } + + // if (!in_array($extension, $allowed)) { + // // Return 400 Error immediately + // return $this->response->setStatusCode(400)->setJSON([ + // 'status' => false, + // 'message' => 'Input validation failed', + // 'code' => 400, + // 'errors' => [ + // $inputName => "File " . ($index + 1) . " has an invalid extension ($extension). Allowed: " . implode(',', $allowed) + // ] + // ]); + // } + // } + // } + // } if (!$this->validate($rules)) { return $this->response->setStatusCode(400)->setJSON([ diff --git a/app/Controllers/PolicyTransactionController.php b/app/Controllers/PolicyTransactionController.php index 592e7405..62a75808 100644 --- a/app/Controllers/PolicyTransactionController.php +++ b/app/Controllers/PolicyTransactionController.php @@ -918,6 +918,144 @@ public function createInceptionPolicy() { $post_data = $this->request->getPost(); + + $rules = [ + // ========================================== + // 1. CLIENT SECTION (5 Fields) + // ========================================== + 'client_id' => ['label' => 'Client','rules' => 'required','errors' => ['required' => 'Please select a Client.']], + 'client_type' => ['label' => 'Client Type','rules' => 'required','errors' => ['required' => 'Client Type must be selected.']], + 'industry_type' => ['label' => 'Industry','rules' => 'permit_empty','errors' => []], // No errors needed for permit_empty unless adding other rules + 'gst_no' => ['label' => 'GST Number','rules' => 'permit_empty|regex_match[/^[0-9]{2}[A-Z]{5}[0-9]{4}[A-Z]{1}[1-9A-Z]{1}Z[0-9A-Z]{1}$/]','errors' => ['alpha_numeric' => 'GST Number should only contain letters and numbers.','regex_match' => 'Invalid GST format. (Example: 22AAAAA0000A1Z5)']], + 'pan_no' => ['label' => 'PAN Number','rules' => 'permit_empty|regex_match[/^[A-Z]{5}[0-9]{4}[A-Z]{1}$/]','errors' => ['alpha_numeric' => 'PAN Number should only contain letters and numbers.','regex_match' => 'Invalid PAN format. (Example: ABCDE1234F)']], + // ========================================== + // 2. PRE-SALES SECTION (3 Fields) + // ========================================== + 'lead_source' => ['label' => 'Lead Source', 'rules' => 'permit_empty', 'errors' => []], + 'opportunity_id' => ['label' => 'Opportunity', 'rules' => 'permit_empty', 'errors' => []], + 'quotation_ref' => ['label' => 'Quotation Ref', 'rules' => 'permit_empty', 'errors' => []], + + // ========================================== + // 3. POLICY DOCUMENT (2 Fields) + // ========================================== + 'policy_copy' => ['label' => 'Policy Copy', 'rules' => 'permit_empty', 'errors' => []], + 'proposal_form' => ['label' => 'Proposal Form', 'rules' => 'permit_empty', 'errors' => []], + + // ========================================== + // 4. VEHICLE DOCUMENT (2 Fields) + // ========================================== + 'rc_copy' => ['label' => 'RC Copy', 'rules' => 'permit_empty', 'errors' => []], + 'inspection_report' => ['label' => 'Inspection Report', 'rules' => 'permit_empty', 'errors' => []], + + // ========================================== + // 5. SALES SECTION (12 Fields) + // ========================================== + 'base_policy' => ['label' => 'Base Policy', 'rules' => 'permit_empty','errors' => []], + 'policy_no' => ['label' => 'Policy Number', 'rules' => 'required|regex_match[/^[a-zA-Z0-9\/_-]+$/]', + 'errors' => [ + 'required' => 'Policy Number is Must.', + 'regex_match' => 'Policy Number can only contain letters, numbers, and symbols like / - or _' + ]], + 'policy_issue_date' => ['label' => 'Issue Date', 'rules' => 'required|valid_date[Y-m-d]|regex_match[/^\d{4}-\d{2}-\d{2}$/]', + 'errors' => [ + 'required' => 'Policy Issue Date is required.', + 'valid_date' => 'Please provide a valid Policy Issue Date.', + 'regex_match' => 'The Policy Issue Date format is incorrect. ' + ]], + 'month' => ['label' => 'Issue Month', 'rules' => 'required','errors' => [ + 'required' => 'Please select or enter the Policy Issue Month.' + ]], + 'policy_start_date' => ['label' => 'D.O.C', + 'rules' => 'required|valid_date[Y-m-d]|regex_match[/^\d{4}-\d{2}-\d{2}$/]', + 'errors' => [ + 'required' => 'D.O.C (Start Date) is required.', + 'valid_date' => 'Please provide a valid D.O.C date.', + 'regex_match' => 'The D.O.C date format is incorrect. ' + ]], + 'policy_end_date' => ['label' => 'D.O.E', 'rules' => 'required|valid_date[Y-m-d]|regex_match[/^\d{4}-\d{2}-\d{2}$/]','errors' => [ + 'required' => 'D.O.E (Expiry Date) is required.', + 'valid_date' => 'Please provide a valid D.O.E date.', + 'regex_match' => 'The D.O.E date format is incorrect. ' + ]], + 'emp_count' => ['label' => 'No of Insured', 'rules' => 'permit_empty|numeric','errors' => [ + 'numeric' => 'No of Insured must contain only numbers.' + ]], + 'dependent_count' => ['label' => 'No of Dependents', 'rules' => 'permit_empty|numeric','errors' => [ + 'numeric' => 'No of Dependents must contain only numbers.' + ]], + 'installment' => ['label' => 'Installment', 'rules' => 'permit_empty','errors' => []], + 'installment_data' => ['label' => 'Installment Data', 'rules' => 'permit_empty','errors' => []], + 'co_share' => ['label' => 'CoP Yes', 'rules' => 'permit_empty','errors' => []], + 'bro_payable_by' => ['label' => 'Remuneration Pay By', 'rules' => 'permit_empty','errors' => []], + 'renewal_date' => ['label' => 'Renewal Date', 'rules' => 'required|valid_date[Y-m-d]|regex_match[/^\d{4}-\d{2}-\d{2}$/]','errors' => [ + 'required' => 'Renewal Date is required.', + 'valid_date' => 'Please provide a valid Renewal Date.', + 'regex_match' => 'The Renewal Date format is incorrect. ' + ]], + 'sales_generated_by' => ['label' => 'Sales Generated By', 'rules' => 'permit_empty','errors' => [ + // 'required' => 'Please select the person who generated this sale.' + ]], + 'serviced_by' => ['label' => 'Serviced By', 'rules' => 'permit_empty','errors' => [ + // 'required' => 'Please select the service person for this policy.' + ]], + 'pos_id' => ['label' => 'POS', 'rules' => 'permit_empty','errors' => []], + + // ========================================== + // 6. PREMIUM DETAILS (Array Fields - 25 Fields) + // Use .* because these come from the dynamic table + // ========================================== + 'follow_insurer_id.*' => ['label' => 'Insurer', 'rules' => 'required','errors' => ['required' => 'Please select an Insurer.']], + 'co_share_type.*' => ['label' => 'Is Leader', 'rules' => 'permit_empty','errors' => []], + 'cd_ac_no_for_child.*' => ['label' => 'CD Acc No', 'rules' => 'permit_empty','errors' => []], + 'cd_current_balance.*' => ['label' => 'CD Amount', 'rules' => 'permit_empty','errors' => []], + 'follower_policy_no.*' => ['label' => 'Follower Policy No', 'rules' => 'permit_empty','errors' => []], + 'calc_policy_issue_date.*' => ['label' => 'Policy Issue Date', 'rules' => 'required','errors' => [ 'required' => 'Policy Issue Date is required' ]], + 'co_share_per.*' => ['label' => 'Co-Share %', 'rules' => 'permit_empty|decimal','errors' => ['decimal' => 'Co-Share % must be a valid decimal.']], + 'non_comm_per_amt.*' => ['label' => 'Non-Comm Premium', 'rules' => 'permit_empty|decimal','errors' => ['decimal' => 'Amount must be numeric.']], + 'base_premium.*' => ['label' => 'Base Premium', 'rules' => 'required|numeric|differs[0]','errors' => [ + 'required' => 'Base Premium is required.', + 'numeric' => 'Base Premium must be a valid number.', + 'differs' => 'Base Premium cannot be zero; please enter a positive or negative value.' + ]], + 'tp_premium.*' => ['label' => 'TP Premium', 'rules' => 'permit_empty|decimal','errors' => ['decimal' => 'TP Premium must be numeric.']], + 'ter_premium.*' => ['label' => 'TEP Premium', 'rules' => 'permit_empty|decimal','errors' => ['decimal' => 'TEP Premium must be numeric.']], + 'co_premium.*' => ['label' => 'Co-Premium', 'rules' => 'permit_empty|decimal','errors'=> ['decimal' => 'Co-Premium must be numeric.']], + 'co_tp_premium.*' => ['label' => 'Co-TP Premium', 'rules' => 'permit_empty|decimal','errors' => ['decimal' => 'Co-TP Premium must be numeric.']], + 'co_ter_premium.*' => ['label' => 'Co-TEP Premium', 'rules' => 'permit_empty|decimal','errors' => ['decimal' => 'Co-TEP Premium must be numeric.']], + 'cgst.*' => ['label' => 'CGST', 'rules' => 'permit_empty|decimal','errors' => ['decimal' => 'CGST must be numeric.']], + 'sgst.*' => ['label' => 'SGST', 'rules' => 'permit_empty|decimal','errors' => ['decimal' => 'SGST must be numeric.']], + 'igst.*' => ['label' => 'IGST', 'rules' => 'permit_empty|decimal','errors' => ['decimal' => 'IGST must be numeric.']], + 'gst_amount.*' => ['label' => 'GST Amount', 'rules' => 'permit_empty|decimal|greater_than[0]','errors' => [ + 'decimal' => 'GST Amount must be a valid numeric value.', + 'greater_than' => 'GST Amount cannot be zero; please enter a value greater than 0.' + ]], + 'stamp_duty.*' => ['label' => 'Stamp Duty', 'rules' => 'permit_empty|decimal','errors' => ['decimal' => 'Stamp Duty must be numeric.']], + 'total.*' => ['label' => 'Total', 'rules' => 'permit_empty|decimal','errors' => ['decimal' => 'Total must be a numeric value.']], + 'agreed_bp.*' => ['label' => 'Agreed BP %', 'rules' => 'permit_empty|decimal','errors' => ['decimal' => 'Agreed BP % must be numeric.']], + 'agreed_tp.*' => ['label' => 'Agreed TP %', 'rules' => 'permit_empty|decimal','errors' => ['decimal' => 'Agreed TP % must be numeric.']], + 'agreed_ter.*' => ['label' => 'Agreed TEP %', 'rules' => 'permit_empty|decimal','errors' => ['decimal' => 'Agreed TEP % must be numeric.']], + 'agreed_amount.*' => ['label' => 'Agreed Amount', 'rules' => 'permit_empty|decimal','errors' => ['decimal' => 'Agreed Amount must be numeric.']], + 'actual_bp_amt.*' => ['label' => 'Actual BP Amount', 'rules' => 'permit_empty|decimal','errors' => ['decimal' => 'Actual BP Amount must be numeric.']], + 'actual_tp_amt.*' => ['label' => 'Actual TP Amount', 'rules' => 'permit_empty|decimal','errors' => ['decimal' => 'Actual TP Amount must be numeric.']], + 'actual_tep_amt.*' => ['label' => 'Actual TEP Amount', 'rules' => 'permit_empty|decimal','errors' => ['decimal' => 'Actual TEP Amount must be numeric.']], + 'actual_bp_per.*' => ['label' => 'Actual BP %', 'rules' => 'permit_empty|decimal','errors' => ['decimal' => 'Actual BP % must be numeric.']], + 'actual_tp_per.*' => ['label' => 'Actual TP %', 'rules' => 'permit_empty|decimal','errors' => ['decimal' => 'Actual TP % must be numeric.']], + 'actual_tep_per.*' => ['label' => 'Actual TEP %', 'rules' => 'permit_empty|decimal','errors' => ['decimal' => 'Actual TEP % must be numeric.']], + 'actual_bp_brokerage_amt.*'=> ['label' => 'BP Remuneration', 'rules' => 'permit_empty|decimal','errors' => ['decimal' => 'BP Remuneration must be numeric.']], + 'actual_tp_brokerage_amt.*'=> ['label' => 'TP Remuneration', 'rules' => 'permit_empty|decimal','errors' => ['decimal' => 'TP Remuneration must be numeric.']], + 'actual_tep_brokerage_amt.*'=>['label' => 'TEP Remuneration', 'rules' => 'permit_empty|decimal','errors' => ['decimal' => 'TEP Remuneration must be numeric.']], + 'exp_amt.*' => ['label' => 'Expected Amount', 'rules' => 'permit_empty|decimal','errors' => ['decimal'=> 'The Expected Amount field must contain a valid number.']] + ]; + + if (!$this->validate($rules)) { + return $this->response->setStatusCode(400)->setJSON([ + 'status' => false, + 'message' => 'Input validation failed', + 'code' => 400, + 'errors' => $this->validator->getErrors() + ]); + } + $post_data = $post_data ? sanitizeInputArrayAdvanced($post_data) : []; $this->myLogger->logme('error', 'Policy Trancaction form data : '. json_encode($post_data)); @@ -2253,16 +2391,264 @@ public function createEndorsementPolicy() { // $id = $this->request->getPost('id'); + $rules = [ + // ========================================== + // 1. CLIENT SECTION + // ========================================== + 'client_id' => [ + 'label' => 'Client', + 'rules' => 'required', + 'errors' => ['required' => 'Client selection is mandatory.'] + ], + 'client_policy_id' => [ + 'label' => 'Policy', + 'rules' => 'required', + 'errors' => ['required' => 'Please select the policy to endorse.'] + ], + 'client_type' => ['rules' => 'permit_empty','errors' => []], + 'client_branch_id' => ['rules' => 'permit_empty','errors' => []], + + // ========================================== + // 2. ENDORSEMENT SECTION + // ========================================== + 'action_type' => [ + 'label' => 'Endorsement Type', + 'rules' => 'required', + 'errors' => ['required' => 'Select an Endorsement Type.'] + ], + 'endorsement_no' => ['label' => 'Endorsement No','rules' => 'permit_empty|regex_match[/^[a-zA-Z0-9\/_-]+$/]', + 'errors' => [ 'regex_match' => 'Endorsement No can only contain letters, numbers, and symbols like / - or _' ]], + 'data_received_date' => [ + 'label' => 'Data Received Date', + 'rules' => 'required|valid_date[d/m/Y]', + 'errors' => ['required' => 'Data Received Date is required.', 'valid_date' => 'Please provide a valid Data Received Date.'] + ], + 'policy_issue_date' => [ + 'label' => 'Endorsement Issue Date', + 'rules' => 'required|valid_date[d/m/Y]', + 'errors' => ['required' => 'Endorsement Issue Date is required.', 'valid_date' => 'Please provide a valid Endorsement Issue Date.'] + ], + // ========================================== + // ENDORSEMENT SECTION + // ========================================== + 'month' => [ + 'label' => 'Endorsement Issue Month', + 'rules' => 'required', + 'errors' => ['required' => 'Endorsement Issue Month (MM/YYYY) is required.'] + ], + 'endorse_eff_date' => [ + 'label' => 'Endorsement Effective Date', + 'rules' => 'permit_empty|valid_date[d/m/Y]', + 'errors' => ['valid_date' => 'Please provide a valid Endorsement Effective Date.'] + ], + 'emp_count' => [ + 'label' => 'No of Insured', + 'rules' => 'permit_empty|numeric', + 'errors' => ['numeric' => 'No of Insured must be a number.'] + ], + 'dependent_count' => [ + 'label' => 'No of Dependents', + 'rules' => 'permit_empty|numeric', + 'errors' => ['numeric' => 'No of Dependents must be a number.'] + ], + 'last_action_date' => [ + 'label' => 'Latest Action Date', + 'rules' => 'permit_empty|valid_date[d/m/Y]', + 'errors' => ['valid_date' => 'Please provide a valid Latest Action Date.'] + ], + 'install_due_date' => [ + 'label' => 'Installment Due Date', + 'rules' => 'permit_empty|valid_date[d/m/Y]', + 'errors' => ['valid_date' => 'Please provide a valid Installment Due Date.'] + ], + + // ========================================== + // PREMIUM DETAILS (ARRAY FIELDS .*) + // ========================================== + 'follow_insurer_id.*' => [ + 'label' => 'Insurer', + 'rules' => 'required', + 'errors' => ['required' => 'Please select an Insurer.'] + ], + 'calc_policy_issue_date.*' => [ + 'label' => 'Premium Endorsement Issue Date', + 'rules' => 'required', + 'errors' => ['required' => 'Endorsement Issue Date is required.'] + ], + 'co_share_per.*' => [ + 'label' => 'Co-Share %', + 'rules' => 'permit_empty|decimal', + 'errors' => ['decimal' => 'Co-Share % must be a valid decimal.'] + ], + 'base_premium.*' => [ + 'label' => 'Base Premium', + 'rules' => 'required|numeric|differs[0]', + 'errors' => [ + 'required' => 'Base Premium is required.', + 'numeric' => 'Base Premium must be a valid number.', + 'differs' => 'Base Premium cannot be zero; please enter a positive or negative value.' + ] + ], + 'total.*' => [ + 'label' => 'Total Premium', + 'rules' => 'permit_empty|decimal', + 'errors' => ['decimal' => 'Total Premium must be a valid amount.'], + ], + + // Decimal validation with Labels + 'non_comm_per_amt.*' => [ + 'label' => 'Non-Comm Premium', + 'rules' => 'permit_empty|decimal', + 'errors' => ['decimal' => 'Non-Comm Premium must be numeric.'] + ], + 'tp_premium.*' => [ + 'label' => 'TP Premium', + 'rules' => 'permit_empty|decimal', + 'errors' => ['decimal' => 'TP Premium must be numeric.'] + ], + 'ter_premium.*' => [ + 'label' => 'TEP Premium', + 'rules' => 'permit_empty|decimal', + 'errors' => ['decimal' => 'TEP Premium must be numeric.'] + ], + 'co_premium.*' => [ + 'label' => 'Co-Premium', + 'rules' => 'permit_empty|decimal', + 'errors' => ['decimal' => 'Co-Premium must be numeric.'] + ], + 'co_tp_premium.*' => [ + 'label' => 'Co-TP Premium', + 'rules' => 'permit_empty|decimal', + 'errors' => ['decimal' => 'Co-TP Premium must be numeric.'] + ], + 'co_ter_premium.*' => [ + 'label' => 'Co-TEP Premium', + 'rules' => 'permit_empty|decimal', + 'errors' => ['decimal' => 'Co-TEP Premium must be numeric.'] + ], + 'cgst.*' => [ + 'label' => 'CGST', + 'rules' => 'permit_empty|decimal', + 'errors' => ['decimal' => 'CGST must be numeric.'] + ], + 'sgst.*' => [ + 'label' => 'SGST', + 'rules' => 'permit_empty|decimal', + 'errors' => ['decimal' => 'SGST must be numeric.'] + ], + 'igst.*' => [ + 'label' => 'IGST', + 'rules' => 'permit_empty|decimal', + 'errors' => ['decimal' => 'IGST must be numeric.'] + ], + 'gst_amount.*' => [ + 'label' => 'GST Amount', + 'rules' => 'permit_empty|decimal|greater_than[0]', + 'errors' => ['decimal' => 'GST Amount must be numeric.','greater_than' => 'GST Amount cannot be zero; please enter a value greater than 0.'] + ], + 'stamp_duty.*' => [ + 'label' => 'Stamp Duty', + 'rules' => 'permit_empty|decimal', + 'errors' => ['decimal' => 'Stamp Duty must be numeric.'] + ], + 'agreed_bp.*' => [ + 'label' => 'Agreed BP %', + 'rules' => 'permit_empty|decimal', + 'errors' => ['decimal' => 'Agreed BP % must be numeric.'] + ], + 'agreed_tp.*' => [ + 'label' => 'Agreed TP %', + 'rules' => 'permit_empty|decimal', + 'errors' => ['decimal' => 'Agreed TP % must be numeric.'] + ], + 'agreed_ter.*' => [ + 'label' => 'Agreed TEP %', + 'rules' => 'permit_empty|decimal', + 'errors' => ['decimal' => 'Agreed TEP % must be numeric.'] + ], + 'agreed_amount.*' => [ + 'label' => 'Agreed Amount', + 'rules' => 'permit_empty|decimal', + 'errors' => ['decimal' => 'Agreed Amount must be numeric.'] + ], + + // Finance/Management Specific Labels + 'actual_bp_amt.*' => [ + 'label' => 'Actual BP Amount', + 'rules' => 'permit_empty|decimal', + 'errors' => ['decimal' => 'Actual BP Amount must be numeric.'] + ], + 'actual_tp_amt.*' => [ + 'label' => 'Actual TP Amount', + 'rules' => 'permit_empty|decimal', + 'errors' => ['decimal' => 'Actual TP Amount must be numeric.'] + ], + 'actual_tep_amt.*' => [ + 'label' => 'Actual TEP Amount', + 'rules' => 'permit_empty|decimal', + 'errors' => ['decimal' => 'Actual TEP Amount must be numeric.'] + ], + 'actual_bp_per.*' => [ + 'label' => 'Actual BP %', + 'rules' => 'permit_empty|decimal', + 'errors' => ['decimal' => 'Actual BP % must be numeric.'] + ], + 'actual_tp_per.*' => [ + 'label' => 'Actual TP %', + 'rules' => 'permit_empty|decimal', + 'errors' => ['decimal' => 'Actual TP % must be numeric.'] + ], + 'actual_tep_per.*' => [ + 'label' => 'Actual TEP %', + 'rules' => 'permit_empty|decimal', + 'errors' => ['decimal' => 'Actual TEP % must be numeric.'] + ], + 'actual_bp_brokerage_amt.*' => [ + 'label' => 'BP Remuneration', + 'rules' => 'permit_empty|decimal', + 'errors' => ['decimal' => 'BP Remuneration must be numeric.'] + ], + 'actual_tp_brokerage_amt.*' => [ + 'label' => 'TP Remuneration', + 'rules' => 'permit_empty|decimal', + 'errors' => ['decimal' => 'TP Remuneration must be numeric.'] + ], + 'actual_tep_brokerage_amt.*' => [ + 'label' => 'TEP Remuneration', + 'rules' => 'permit_empty|decimal', + 'errors' => ['decimal' => 'TEP Remuneration must be numeric.'] + ], + 'exp_amt.*' => [ + 'label' => 'Expected Amount', + 'rules' => 'permit_empty|decimal', + 'errors' => ['decimal' => 'Expected Amount must be numeric.'] + ], + 'co_share_type.*' => ['label' => 'Is Leader', 'rules' => 'permit_empty','errors' => []], + 'follower_policy_no.*' => ['label' => 'Follower Policy No', 'rules' => 'permit_empty','errors' => []], + 'co_share_id.*' => ['label' => 'Record ID', 'rules' => 'permit_empty','errors' => []], + ]; + + if (!$this->validate($rules)) { + return $this->response->setStatusCode(400)->setJSON([ + 'status' => false, + 'message' => 'Input validation failed', + 'code' => 400, + 'errors' => $this->validator->getErrors() + ]); + } + $data = $this->preparePolicyTransactionData(); + + $id = (isset($data['id']) && !empty($data['id'])) ? $data['id'] : null; + $data['status'] = 'completed'; - $id = $data['id'] ?? null; - // print_r($data); die; if (!$id) { return $this->insertEndorsementTransaction($data); } else { return $this->updateEndorsementTransaction($id, $data); } + } private function preparePolicyTransactionData() diff --git a/app/Controllers/ThzController.php b/app/Controllers/ThzController.php index 713a8fb7..827b6587 100644 --- a/app/Controllers/ThzController.php +++ b/app/Controllers/ThzController.php @@ -62,7 +62,6 @@ class ThzController extends BaseController public function ticketSave() { - try { $rules = [ 'client_id' => [ 'rules' => 'permit_empty|integer', @@ -70,6 +69,7 @@ class ThzController extends BaseController 'integer' => 'Invalid client selected' ] ], + 'mobile' => [ 'rules' => 'required|regex_match[/^[0-9]{10}$/]', @@ -97,17 +97,24 @@ class ThzController extends BaseController ], 'empcode' => [ - 'rules' => 'permit_empty|max_length[50]', + 'rules' => 'permit_empty|alpha_numeric_punct|max_length[50]', 'errors' => [ + 'alpha_numeric_punct' => 'Employee code contains invalid characters.', 'max_length' => 'Employee code is too long' ] ], 'ticket_type' => [ - 'rules' => 'required|in_list[Sales,Service]', + 'rules' => 'required', + 'errors' => [ + 'required' => 'Please select a Ticket Type.' + ] + ], + + 'ticket_type' => [ + 'rules' => 'required', 'errors' => [ 'required' => 'Ticket Type is required', - 'in_list' => 'Invalid Ticket Type selected' ] ], @@ -119,11 +126,12 @@ class ThzController extends BaseController ], 'subject' => [ - 'rules' => 'required|min_length[5]|max_length[150]', + 'rules' => 'required|min_length[3]|max_length[150]|regex_match[/^[a-zA-Z0-9 .,\-_()&\/\?]+$/]', 'errors' => [ - 'required' => 'Subject is required', - 'min_length' => 'Subject must be at least 5 characters', - 'max_length' => 'Subject cannot exceed 150 characters' + 'required' => 'Subject is required.', + 'min_length' => 'Subject must be at least 3 characters long.', + 'max_length' => 'Subject cannot exceed 150 characters', + 'regex_match' => 'Subject contains invalid characters (Avoid quotes and special symbols).' ] ], @@ -151,6 +159,7 @@ class ThzController extends BaseController 'errors' => $this->validator->getErrors() ]); } + try { $request_post_data = $this->request->getPost(); $data = sanitizeInputArrayAdvanced($request_post_data); diff --git a/app/Controllers/TicketController.php b/app/Controllers/TicketController.php index abb02e17..6f69ed45 100644 --- a/app/Controllers/TicketController.php +++ b/app/Controllers/TicketController.php @@ -952,6 +952,13 @@ class TicketController extends BaseController { // $ticket_data = $this->ticketMasterModel->where('id', $ticket_id)->where('is_active', 1)->first(); $ticket_data = $this->ticketMasterModel->getTicketDataByTicketID($ticket_id); + + + // Security Check: Verify if record exists + if (empty($ticket_data)) { + // Redirect or show a 404 to prevent "Undefined array key" errors + return redirect()->to(base_url('ticket/list'))->with('error', 'Ticket not found'); + } $ticket_data = $this->formatDateForClaim($ticket_data, 'd/m/Y'); @@ -1120,117 +1127,197 @@ class TicketController extends BaseController public function createTicket() { - $rules = [ - 'emp_code' => [ - 'rules' => 'required', - 'errors' => ['required' => 'Employee Code is required'] - ], + $request_data = $this->request->getPost(); + $selected_ticket_type = $this->request->getPost('ticket_type_id'); - 'emp_name' => [ - 'rules' => 'required', - 'errors' => ['required' => 'Employee Name is required'] - ], + // 1. Initialize an empty rules array + $rules = []; + if ($selected_ticket_type == 1 || $selected_ticket_type == 72) { + $rules = [ + // --- EMPLOYEE DETAILS --- + 'emp_code' => ['label' => 'Employee Code','rules' => 'required|alpha_numeric_space', + 'errors' => ['required' => 'Employee Code is required'] + ], + 'emp_name' => ['label' => 'Employee Name','rules' => 'required|min_length[3]', + 'errors' => ['required' => 'Employee Name is required','min_length' => 'Employee Name must be at least 3 characters long'] + ], + 'insured_name' => ['label' => 'Insured Name','rules' => 'required', + 'errors' => ['required' => 'Insured Name is required'] + ], + 'relationship' => ['label' => 'Relationship','rules' => 'required', + 'errors' => ['required' => 'Please select a Relationship'] + ], + 'policy_no' => ['label' => 'Policy No','rules' => 'permit_empty','errors' => []], + 'tpa_no' => ['label' => 'TPA ID','rules' => 'permit_empty','errors' => []], + 'emp_mobile' => ['label' => 'Employee Mobile No','rules' => 'required|numeric|exact_length[10]', + 'errors' => [ + 'required' => 'Mobile number is required', + 'numeric' => 'Mobile must contain only numbers', + 'exact_length' => 'Mobile must be exactly 10 digits' + ] + ], + 'emp_mail' => ['label' => 'Employee Mail ID','rules' => 'required|valid_email', + 'errors' => ['required' => 'Employee Email is required','valid_email' => 'Please provide a valid email address'] + ], + 'emp_personal_mail' => ['label' => 'Personal Mail ID','rules' => 'permit_empty|valid_email', + 'errors' => ['valid_email' => 'Personal email format is invalid'] + ], + 'client_policy_id' => ['label' => 'Policy','rules' => 'required', + 'errors' => ['required' => 'Please select a Policy'] + ], + 'acm_id' => ['label' => 'Account Manager','rules' => 'required', + 'errors' => ['required' => 'Select an Account Manager'] + ], - 'insured_name' => [ - 'rules' => 'required', - 'errors' => ['required' => 'Insured Name is required'] - ], + // --- CLAIM DETAILS --- + 'claim_status_id' => ['label' => 'Status','rules' => 'required', + 'errors' => ['required' => 'Claim Status is required'] + ], + 'priority' => ['label' => 'Priority','rules' => 'required', + 'errors' => ['required' => 'Priority is required'] + ], + 'mode_of_intimation' => ['label' => 'Mode of Submission','rules' => 'required', + 'errors' => ['required' => 'Mode of Submission is required'] + ], + 'claim_type' => ['label' => 'Claim Type','rules' => 'required', + 'errors' => ['required' => 'Claim Type is required'] + ], + 'hospital_name' => ['label' => 'Hospital Name','rules' => 'required', + 'errors' => ['required' => 'Hospital Name is required'] + ], + 'hospital_address' => ['label' => 'Hospital Address','rules' => 'required', + 'errors' => ['required' => 'Hospital Address is required'] + ], + 'hospital_city' => ['label' => 'Hospital City','rules' => 'required', + 'errors' => ['required' => 'City is required'] + ], + 'hospital_state' => ['label' => 'Hospital State','rules' => 'required', + 'errors' => ['required' => 'State is required'] + ], + 'hospital_pin_code' => ['label' => 'Hospital Pincode','rules' => 'required|numeric|exact_length[6]', + 'errors' => ['exact_length' => 'Pincode must be 6 digits'] + ], + 'hospital_phone_no' => ['label' => 'Hospital Phone','rules' => 'required|numeric|min_length[10]', + 'errors' => ['min_length' => 'Phone number too short'] + ], + 'doa' => ['label' => 'DOA', 'rules' => 'required', + 'errors' => ['required' => 'Date of Admission is required'] + ], + 'dod' => [ 'label' => 'DOD', 'rules' => 'required', + 'errors' => ['required' => 'Date of Discharge is required'] + ], + 'claim_amount' => [ + 'label' => 'Claim Amount', + 'rules' => 'permit_empty|numeric', + 'errors' => ['numeric' => 'Claim Amount must contain only numbers.'] + ], + 'pod_no' => ['label' => 'POD No','rules' => 'permit_empty','errors' => []], - 'relationship' => [ - 'rules' => 'required', - 'errors' => ['required' => 'Relationship is required'] - ], + // --- ADDITIONAL / CONDITIONAL FIELDS --- + 'claim_number' => ['label' => 'Claim Number','rules' => 'permit_empty|alpha_numeric_punct','errors' => ['alpha_numeric_punct' => 'Invalid Claim Number.']], + 'denial_date' => ['label' => 'Denial Date','rules' => 'permit_empty|regex_match[/^\d{2}\/\d{2}\/\d{4}$/]','errors' => ['regex_match' => 'Denial Date must be dd/mm/yyyy.']], + 'approved_amount' => ['label' => 'Approved Amount','rules' => 'permit_empty|numeric', + 'errors' => ['numeric' => 'Approved amount must be numeric'] + ], + 'approved_date' => ['label' => 'Approved Date','rules' => 'permit_empty|regex_match[/^\d{2}\/\d{2}\/\d{4}$/]','errors' => ['regex_match' => 'Approved Date must be dd/mm/yyyy.']], + 'approved_letter' => ['label' => 'Approved Letter','rules' => 'permit_empty','errors' => []], + 'approved_description' => ['label' => 'Approved Description','rules' => 'permit_empty','errors' => []], + 'utr_details' => ['label' => 'UTR Details','rules' => 'permit_empty|alpha_numeric_punct','errors' => ['alpha_numeric_punct' => 'UTR Details contains invalid characters.']], + 'settled_date' => ['label' => 'Settled Date','rules' => 'permit_empty|regex_match[/^\d{2}\/\d{2}\/\d{4}$/]','errors' => ['regex_match' => 'Settled Date must be dd/mm/yyyy.']], + 'settle_letter' => ['label' => 'Settle Letter','rules' => 'permit_empty','errors' => []], + 'pay_initiate_date' => ['label' => 'Payment Initiate Date','rules' => 'permit_empty|regex_match[/^\d{2}\/\d{2}\/\d{4}$/]','errors' => ['regex_match' => 'Payment Initiate Date must be dd/mm/yyyy.']], + 'cancel_remark' => ['label' => 'Cancel Remark','rules' => 'permit_empty','errors' => []], + 'return_remark' => ['label' => 'Return Remark','rules' => 'permit_empty','errors' => []], + 'awb_no_courier_name' => ['label' => 'AWB No','rules' => 'permit_empty','errors' => []], + 'non_id_reason' => ['label' => 'Non ID Reason','rules' => 'permit_empty','errors' => []], + 'client_id' => ['rules' => 'required','errors' => ['required' => 'Client ID is required']], + 'insurer_id' => ['rules' => 'required','errors' => ['required' => 'Insurer is required'], + 'si_amt' => [ 'label' => 'Sum Insured', 'rules' => 'permit_empty|numeric', 'errors' => ['numeric' => 'Sum Insured must be a valid number.']], + 'registration_date' => ['label' => 'Registration Date','rules' => 'permit_empty|regex_match[/^\d{2}\/\d{2}\/\d{4}$/]','errors' => ['regex_match' => 'Registration Date must be dd/mm/yyyy.']], + 'denial_reason' => ['label' => 'Denial Reason', 'rules' => 'permit_empty|string','errors' => ['string' => 'Invalid characters in Denial Reason.']], + ], + ]; + } else if ($selected_ticket_type == 8) { + $rules = [ + // --- GENERAL DETAILS --- + 'client_name' => ['label' => 'Client Name','rules' => 'required|is_not_list[0]', + 'errors' => [ + 'required' => 'Please select a Client Name.', + 'is_not_list' => 'Please select a valid Client from the list.' + ] + ], + 'vehicle_id' => ['label' => 'Vehicle', + 'rules' => 'required', + 'errors' => [ + 'required' => 'Vehicle selection is required.' + ] + ], + 'client_policy_id' => ['label' => 'Policy','rules' => 'required', + 'errors' => ['required' => 'Please select a Policy.',] + ], + 'insurer_id' => ['label' => 'Insurer ID','rules' => 'required', + 'errors' => ['required' => 'Insurer data is missing. Please re-select the policy.'] + ], + 'emp_mobile' => ['label' => 'Mobile No','rules' => 'permit_empty|numeric|exact_length[10]', + 'errors' => ['numeric' => 'Mobile number must contain only digits.', + 'exact_length' => 'Mobile number must be exactly 10 digits.' + ] + ], + 'emp_mail' => ['label' => 'Mail ID','rules' => 'permit_empty|valid_email', + 'errors' => ['valid_email' => 'Please provide a valid email address format.'] + ], - 'emp_mobile' => [ - 'rules' => 'required', - 'errors' => ['required' => 'Employee Mobile is required'] - ], + // --- CLAIM DETAILS --- + 'ticket_type_id' => ['label' => 'Policy Type','rules' => 'required','errors' => ['required' => 'Policy Type is required.']], + 'claim_status_id' => ['label' => 'Status','rules' => 'required','errors' => ['required' => 'Status is required.']], - 'emp_mail' => [ - 'rules' => 'required', - 'errors' => ['required' => 'Employee Email is required'] - ], + // --- HIDDEN KEYS (Integrity Checks) --- + 'ticket_master_id' => ['label' => 'Ticket Master ID','rules' => 'permit_empty','errors' => []], + 'client_id' => ['label' => 'Client ID','rules' => 'required','errors' => ['required' => 'System error: Client ID is missing.']] + ]; + } else { + $rules = [ + // --- EMPLOYEE DETAILS --- + 'emp_code' => ['label' => 'Employee ID', 'rules' => 'required', + 'errors' => ['required' => 'Employee Code is required'] + ], + 'emp_name' => ['label' => 'Employee Name','rules' => 'required|min_length[3]', + 'errors' => ['required' => 'Employee Name is required','min_length' => 'Employee Name must be at least 3 characters long'] + ], + 'emp_mobile' => ['label' => 'Mobile No','rules' => 'required|numeric|exact_length[10]', + 'errors' => [ + 'required' => 'Mobile number is required', + 'numeric' => 'Mobile must be digits only', + 'exact_length' => 'Mobile must be exactly 10 digits' + ] + ], + 'emp_mail' => ['label' => 'Mail ID','rules' => 'required|valid_email', + 'errors' => ['required' => 'Official email is required','valid_email' => 'Please provide a valid official email'] + ], + 'emp_personal_mail' => ['label' => 'Personal Mail','rules' => 'permit_empty|valid_email', + 'errors' => ['valid_email' => 'Personal email format is invalid'] + ], + 'client_policy_id' => ['label' => 'Policy','rules' => 'required','errors' => ['required' => 'Please select a Policy']], + 'acm_id' => ['label' => 'Account Manager','rules' => 'required','errors' => ['required' => 'Account Manager must be selected']], - 'client_id' => [ - 'rules' => 'required', - 'errors' => ['required' => 'Client ID is required'] - ], - - 'insurer_id' => [ - 'rules' => 'required', - 'errors' => ['required' => 'Insurer is required'] - ], - - 'client_policy_id' => [ - 'rules' => 'required', - 'errors' => ['required' => 'Policy is required'] - ], - - 'claim_status_id' => [ - 'rules' => 'required', - 'errors' => ['required' => 'Claim Status is required'] - ], - - 'priority' => [ - 'rules' => 'required', - 'errors' => ['required' => 'Priority is required'] - ], - - 'mode_of_intimation' => [ - 'rules' => 'required', - 'errors' => ['required' => 'Mode of Intimation is required'] - ], - - 'claim_type' => [ - 'rules' => 'required', - 'errors' => ['required' => 'Claim Type is required'] - ], - - 'hospital_name' => [ - 'rules' => 'required', - 'errors' => ['required' => 'Hospital Name is required'] - ], - - 'hospital_address' => [ - 'rules' => 'required', - 'errors' => ['required' => 'Hospital Address is required'] - ], - - 'hospital_city' => [ - 'rules' => 'required', - 'errors' => ['required' => 'Hospital City is required'] - ], - - 'hospital_state' => [ - 'rules' => 'required', - 'errors' => ['required' => 'Hospital State is required'] - ], - - 'hospital_pin_code' => [ - 'rules' => 'required', - 'errors' => ['required' => 'Hospital Pincode is required'] - ], - - 'hospital_phone_no' => [ - 'rules' => 'required', - 'errors' => ['required' => 'Hospital Phone Number is required'] - ], - - 'doa' => [ - 'rules' => 'required', - 'errors' => ['required' => 'Date of Admission is required'] - ], - - 'dod' => [ - 'rules' => 'required', - 'errors' => ['required' => 'Date of Discharge is required'] - ], - - 'claim_amount' => [ - 'rules' => 'required', - 'errors' => ['required' => 'Claim Amount is required'] - ], - ]; + // --- CLAIM DETAILS --- + 'claim_status_id' => ['label' => 'Status','rules' => 'required','errors' => ['required' => 'Claim status is required']], + 'claim_type' => ['label' => 'Claim Type','rules' => 'required','errors' => ['required' => 'Claim type is required']], + 'dob' => ['label' => 'Date of Birth','rules' => 'required','errors' => ['required' => 'Date of Birth is required']], + 'date_of_intimat' => ['label' => 'Date of Intimation','rules' => 'required','errors' => ['required' => 'Intimation date is required']], + 'si_amt' => ['label' => 'Sum Insured','rules' => 'required|numeric','errors' => ['numeric' => 'Sum insured must be a number']], + 'approved_amount' => ['label' => 'Approved Amount','rules' => 'permit_empty|numeric','errors' => ['numeric' => 'Approved amount must be numeric']], + 'approved_date' => ['label' => 'Approved Date','rules' => 'permit_empty|regex_match[/^\d{2}\/\d{2}\/\d{4}$/]','errors' => ['regex_match' => 'Approved Date must be dd/mm/yyyy.']], + 'approved_letter' => ['label' => 'Approved Letter','rules' => 'permit_empty','errors' => []], + 'approved_description' => ['label' => 'Approved Description','rules' => 'permit_empty','errors' => []], + 'utr_details' => ['label' => 'UTR Details','rules' => 'permit_empty|alpha_numeric_punct','errors' => ['alpha_numeric_punct' => 'UTR Details contains invalid characters.']], + 'settled_date' => ['label' => 'Settled Date','rules' => 'permit_empty|regex_match[/^\d{2}\/\d{2}\/\d{4}$/]','errors' => ['regex_match' => 'Settled Date must be dd/mm/yyyy.']], + 'settle_letter' => ['label' => 'Settle Letter','rules' => 'permit_empty','errors' => []], + 'pay_initiate_date' => ['label' => 'Payment Initiate Date','rules' => 'permit_empty|regex_match[/^\d{2}\/\d{2}\/\d{4}$/]','errors' => ['regex_match' => 'Payment Initiate Date must be dd/mm/yyyy.']], + 'cancel_remark' => ['label' => 'Cancel Remark','rules' => 'permit_empty','errors' => []], + 'return_remark' => ['label' => 'Return Remark','rules' => 'permit_empty','errors' => []], + ]; + } if (!$this->validate($rules)) { return $this->response->setStatusCode(400)->setJSON([ @@ -1303,119 +1390,198 @@ class TicketController extends BaseController public function updateTicket() { + + $request_data = $this->request->getPost(); + $selected_ticket_type = $this->request->getPost('ticket_type_id'); - $rules = [ - 'emp_code' => [ - 'rules' => 'required', - 'errors' => ['required' => 'Employee Code is required'] - ], + // 1. Initialize an empty rules array + $rules = []; + if ($selected_ticket_type == 1 || $selected_ticket_type == 72) { + $rules = [ + // --- EMPLOYEE DETAILS --- + 'emp_code' => ['label' => 'Employee Code','rules' => 'required|alpha_numeric_space', + 'errors' => ['required' => 'Employee Code is required'] + ], + 'emp_name' => ['label' => 'Employee Name','rules' => 'required|min_length[3]', + 'errors' => ['required' => 'Employee Name is required','min_length' => 'Employee Name must be at least 3 characters long'] + ], + 'insured_name' => ['label' => 'Insured Name','rules' => 'required', + 'errors' => ['required' => 'Insured Name is required'] + ], + 'relationship' => ['label' => 'Relationship','rules' => 'required', + 'errors' => ['required' => 'Please select a Relationship'] + ], + 'policy_no' => ['label' => 'Policy No','rules' => 'permit_empty','errors' => []], + 'tpa_no' => ['label' => 'TPA ID','rules' => 'permit_empty','errors' => []], + 'emp_mobile' => ['label' => 'Employee Mobile No','rules' => 'required|numeric|exact_length[10]', + 'errors' => [ + 'required' => 'Mobile number is required', + 'numeric' => 'Mobile must contain only numbers', + 'exact_length' => 'Mobile must be exactly 10 digits' + ] + ], + 'emp_mail' => ['label' => 'Employee Mail ID','rules' => 'required|valid_email', + 'errors' => ['required' => 'Employee Email is required','valid_email' => 'Please provide a valid email address'] + ], + 'emp_personal_mail' => ['label' => 'Personal Mail ID','rules' => 'permit_empty|valid_email', + 'errors' => ['valid_email' => 'Personal email format is invalid'] + ], + 'client_policy_id' => ['label' => 'Policy','rules' => 'required', + 'errors' => ['required' => 'Please select a Policy'] + ], + 'acm_id' => ['label' => 'Account Manager','rules' => 'required', + 'errors' => ['required' => 'Select an Account Manager'] + ], - 'emp_name' => [ - 'rules' => 'required', - 'errors' => ['required' => 'Employee Name is required'] - ], + // --- CLAIM DETAILS --- + 'claim_status_id' => ['label' => 'Status','rules' => 'required', + 'errors' => ['required' => 'Claim Status is required'] + ], + 'priority' => ['label' => 'Priority','rules' => 'required', + 'errors' => ['required' => 'Priority is required'] + ], + 'mode_of_intimation' => ['label' => 'Mode of Submission','rules' => 'required', + 'errors' => ['required' => 'Mode of Submission is required'] + ], + 'claim_type' => ['label' => 'Claim Type','rules' => 'required', + 'errors' => ['required' => 'Claim Type is required'] + ], + 'hospital_name' => ['label' => 'Hospital Name','rules' => 'required', + 'errors' => ['required' => 'Hospital Name is required'] + ], + 'hospital_address' => ['label' => 'Hospital Address','rules' => 'required', + 'errors' => ['required' => 'Hospital Address is required'] + ], + 'hospital_city' => ['label' => 'Hospital City','rules' => 'required', + 'errors' => ['required' => 'City is required'] + ], + 'hospital_state' => ['label' => 'Hospital State','rules' => 'required', + 'errors' => ['required' => 'State is required'] + ], + 'hospital_pin_code' => ['label' => 'Hospital Pincode','rules' => 'required|numeric|exact_length[6]', + 'errors' => ['exact_length' => 'Pincode must be 6 digits'] + ], + 'hospital_phone_no' => ['label' => 'Hospital Phone','rules' => 'required|numeric|min_length[10]', + 'errors' => ['min_length' => 'Phone number too short'] + ], + 'doa' => ['label' => 'DOA', 'rules' => 'required', + 'errors' => ['required' => 'Date of Admission is required'] + ], + 'dod' => [ 'label' => 'DOD', 'rules' => 'required', + 'errors' => ['required' => 'Date of Discharge is required'] + ], + 'claim_amount' => [ + 'label' => 'Claim Amount', + 'rules' => 'permit_empty|numeric', + 'errors' => ['numeric' => 'Claim Amount must contain only numbers.'] + ], + 'pod_no' => ['label' => 'POD No','rules' => 'permit_empty','errors' => []], - 'insured_name' => [ - 'rules' => 'required', - 'errors' => ['required' => 'Insured Name is required'] - ], + // --- ADDITIONAL / CONDITIONAL FIELDS --- + 'claim_number' => ['label' => 'Claim Number','rules' => 'permit_empty|alpha_numeric_punct','errors' => ['alpha_numeric_punct' => 'Invalid Claim Number.']], + 'denial_date' => ['label' => 'Denial Date','rules' => 'permit_empty|regex_match[/^\d{2}\/\d{2}\/\d{4}$/]','errors' => ['regex_match' => 'Denial Date must be dd/mm/yyyy.']], + 'approved_amount' => ['label' => 'Approved Amount','rules' => 'permit_empty|numeric', + 'errors' => ['numeric' => 'Approved amount must be numeric'] + ], + 'approved_date' => ['label' => 'Approved Date','rules' => 'permit_empty|regex_match[/^\d{2}\/\d{2}\/\d{4}$/]','errors' => ['regex_match' => 'Approved Date must be dd/mm/yyyy.']], + 'approved_letter' => ['label' => 'Approved Letter','rules' => 'permit_empty','errors' => []], + 'approved_description' => ['label' => 'Approved Description','rules' => 'permit_empty','errors' => []], + 'utr_details' => ['label' => 'UTR Details','rules' => 'permit_empty|alpha_numeric_punct','errors' => ['alpha_numeric_punct' => 'UTR Details contains invalid characters.']], + 'settled_date' => ['label' => 'Settled Date','rules' => 'permit_empty|regex_match[/^\d{2}\/\d{2}\/\d{4}$/]','errors' => ['regex_match' => 'Settled Date must be dd/mm/yyyy.']], + 'settle_letter' => ['label' => 'Settle Letter','rules' => 'permit_empty','errors' => []], + 'pay_initiate_date' => ['label' => 'Payment Initiate Date','rules' => 'permit_empty|regex_match[/^\d{2}\/\d{2}\/\d{4}$/]','errors' => ['regex_match' => 'Payment Initiate Date must be dd/mm/yyyy.']], + 'cancel_remark' => ['label' => 'Cancel Remark','rules' => 'permit_empty','errors' => []], + 'return_remark' => ['label' => 'Return Remark','rules' => 'permit_empty','errors' => []], + 'awb_no_courier_name' => ['label' => 'AWB No','rules' => 'permit_empty','errors' => []], + 'non_id_reason' => ['label' => 'Non ID Reason','rules' => 'permit_empty','errors' => []], + 'client_id' => ['rules' => 'required','errors' => ['required' => 'Client ID is required']], + 'insurer_id' => ['rules' => 'required','errors' => ['required' => 'Insurer is required'], + 'si_amt' => [ 'label' => 'Sum Insured', 'rules' => 'permit_empty|numeric', 'errors' => ['numeric' => 'Sum Insured must be a valid number.']], + 'registration_date' => ['label' => 'Registration Date','rules' => 'permit_empty|regex_match[/^\d{2}\/\d{2}\/\d{4}$/]','errors' => ['regex_match' => 'Registration Date must be dd/mm/yyyy.']], + 'denial_reason' => ['label' => 'Denial Reason', 'rules' => 'permit_empty|string','errors' => ['string' => 'Invalid characters in Denial Reason.']], + ], + ]; + } else if ($selected_ticket_type == 8) { + $rules = [ + // --- GENERAL DETAILS --- + 'client_name' => ['label' => 'Client Name','rules' => 'required|is_not_list[0]', + 'errors' => [ + 'required' => 'Please select a Client Name.', + 'is_not_list' => 'Please select a valid Client from the list.' + ] + ], + 'vehicle_id' => ['label' => 'Vehicle', + 'rules' => 'required', + 'errors' => [ + 'required' => 'Vehicle selection is required.' + ] + ], + 'client_policy_id' => ['label' => 'Policy','rules' => 'required', + 'errors' => ['required' => 'Please select a Policy.',] + ], + 'insurer_id' => ['label' => 'Insurer ID','rules' => 'required', + 'errors' => ['required' => 'Insurer data is missing. Please re-select the policy.'] + ], + 'emp_mobile' => ['label' => 'Mobile No','rules' => 'permit_empty|numeric|exact_length[10]', + 'errors' => ['numeric' => 'Mobile number must contain only digits.', + 'exact_length' => 'Mobile number must be exactly 10 digits.' + ] + ], + 'emp_mail' => ['label' => 'Mail ID','rules' => 'permit_empty|valid_email', + 'errors' => ['valid_email' => 'Please provide a valid email address format.'] + ], - 'relationship' => [ - 'rules' => 'required', - 'errors' => ['required' => 'Relationship is required'] - ], + // --- CLAIM DETAILS --- + 'ticket_type_id' => ['label' => 'Policy Type','rules' => 'required','errors' => ['required' => 'Policy Type is required.']], + 'claim_status_id' => ['label' => 'Status','rules' => 'required','errors' => ['required' => 'Status is required.']], - 'emp_mobile' => [ - 'rules' => 'required', - 'errors' => ['required' => 'Employee Mobile is required'] - ], - - 'emp_mail' => [ - 'rules' => 'required', - 'errors' => ['required' => 'Employee Email is required'] - ], - - 'client_id' => [ - 'rules' => 'required', - 'errors' => ['required' => 'Client ID is required'] - ], - - 'insurer_id' => [ - 'rules' => 'required', - 'errors' => ['required' => 'Insurer is required'] - ], - - 'client_policy_id' => [ - 'rules' => 'required', - 'errors' => ['required' => 'Policy is required'] - ], - - 'claim_status_id' => [ - 'rules' => 'required', - 'errors' => ['required' => 'Claim Status is required'] - ], - - 'priority' => [ - 'rules' => 'required', - 'errors' => ['required' => 'Priority is required'] - ], - - 'mode_of_intimation' => [ - 'rules' => 'required', - 'errors' => ['required' => 'Mode of Intimation is required'] - ], - - 'claim_type' => [ - 'rules' => 'required', - 'errors' => ['required' => 'Claim Type is required'] - ], - - 'hospital_name' => [ - 'rules' => 'required', - 'errors' => ['required' => 'Hospital Name is required'] - ], - - 'hospital_address' => [ - 'rules' => 'required', - 'errors' => ['required' => 'Hospital Address is required'] - ], - - 'hospital_city' => [ - 'rules' => 'required', - 'errors' => ['required' => 'Hospital City is required'] - ], - - 'hospital_state' => [ - 'rules' => 'required', - 'errors' => ['required' => 'Hospital State is required'] - ], - - 'hospital_pin_code' => [ - 'rules' => 'required', - 'errors' => ['required' => 'Hospital Pincode is required'] - ], - - 'hospital_phone_no' => [ - 'rules' => 'required', - 'errors' => ['required' => 'Hospital Phone Number is required'] - ], - - 'doa' => [ - 'rules' => 'required', - 'errors' => ['required' => 'Date of Admission is required'] - ], - - 'dod' => [ - 'rules' => 'required', - 'errors' => ['required' => 'Date of Discharge is required'] - ], - - 'claim_amount' => [ - 'rules' => 'required', - 'errors' => ['required' => 'Claim Amount is required'] - ], - ]; + // --- HIDDEN KEYS (Integrity Checks) --- + 'ticket_master_id' => ['label' => 'Ticket Master ID','rules' => 'permit_empty','errors' => []], + 'client_id' => ['label' => 'Client ID','rules' => 'required','errors' => ['required' => 'System error: Client ID is missing.']] + ]; + } else { + $rules = [ + // --- EMPLOYEE DETAILS --- + 'emp_code' => ['label' => 'Employee ID', 'rules' => 'required', + 'errors' => ['required' => 'Employee Code is required'] + ], + 'emp_name' => ['label' => 'Employee Name','rules' => 'required|min_length[3]', + 'errors' => ['required' => 'Employee Name is required','min_length' => 'Employee Name must be at least 3 characters long'] + ], + 'emp_mobile' => ['label' => 'Mobile No','rules' => 'required|numeric|exact_length[10]', + 'errors' => [ + 'required' => 'Mobile number is required', + 'numeric' => 'Mobile must be digits only', + 'exact_length' => 'Mobile must be exactly 10 digits' + ] + ], + 'emp_mail' => ['label' => 'Mail ID','rules' => 'required|valid_email', + 'errors' => ['required' => 'Official email is required','valid_email' => 'Please provide a valid official email'] + ], + 'emp_personal_mail' => ['label' => 'Personal Mail','rules' => 'permit_empty|valid_email', + 'errors' => ['valid_email' => 'Personal email format is invalid'] + ], + 'client_policy_id' => ['label' => 'Policy','rules' => 'required','errors' => ['required' => 'Please select a Policy']], + 'acm_id' => ['label' => 'Account Manager','rules' => 'required','errors' => ['required' => 'Account Manager must be selected']], + // --- CLAIM DETAILS --- + 'claim_status_id' => ['label' => 'Status','rules' => 'required','errors' => ['required' => 'Claim status is required']], + 'claim_type' => ['label' => 'Claim Type','rules' => 'required','errors' => ['required' => 'Claim type is required']], + 'dob' => ['label' => 'Date of Birth','rules' => 'required','errors' => ['required' => 'Date of Birth is required']], + 'date_of_intimat' => ['label' => 'Date of Intimation','rules' => 'required','errors' => ['required' => 'Intimation date is required']], + 'si_amt' => ['label' => 'Sum Insured','rules' => 'required|numeric','errors' => ['numeric' => 'Sum insured must be a number']], + 'approved_amount' => ['label' => 'Approved Amount','rules' => 'permit_empty|numeric','errors' => ['numeric' => 'Approved amount must be numeric']], + 'approved_date' => ['label' => 'Approved Date','rules' => 'permit_empty|regex_match[/^\d{2}\/\d{2}\/\d{4}$/]','errors' => ['regex_match' => 'Approved Date must be dd/mm/yyyy.']], + 'approved_letter' => ['label' => 'Approved Letter','rules' => 'permit_empty','errors' => []], + 'approved_description' => ['label' => 'Approved Description','rules' => 'permit_empty','errors' => []], + 'utr_details' => ['label' => 'UTR Details','rules' => 'permit_empty|alpha_numeric_punct','errors' => ['alpha_numeric_punct' => 'UTR Details contains invalid characters.']], + 'settled_date' => ['label' => 'Settled Date','rules' => 'permit_empty|regex_match[/^\d{2}\/\d{2}\/\d{4}$/]','errors' => ['regex_match' => 'Settled Date must be dd/mm/yyyy.']], + 'settle_letter' => ['label' => 'Settle Letter','rules' => 'permit_empty','errors' => []], + 'pay_initiate_date' => ['label' => 'Payment Initiate Date','rules' => 'permit_empty|regex_match[/^\d{2}\/\d{2}\/\d{4}$/]','errors' => ['regex_match' => 'Payment Initiate Date must be dd/mm/yyyy.']], + 'cancel_remark' => ['label' => 'Cancel Remark','rules' => 'permit_empty','errors' => []], + 'return_remark' => ['label' => 'Return Remark','rules' => 'permit_empty','errors' => []], + ]; + } if (!$this->validate($rules)) { return $this->response->setStatusCode(400)->setJSON([ 'status' => false, @@ -1424,8 +1590,7 @@ class TicketController extends BaseController 'errors' => $this->validator->getErrors() ]); } - - $request_data = $this->request->getPost(); + $sanitized_data = sanitizeInputArrayAdvanced($request_data); $ticket_data = $this->formatDateForClaim($sanitized_data); $ticket_id = $this->request->getPost('ticket_master_id'); @@ -1604,12 +1769,34 @@ class TicketController extends BaseController } } } elseif ($action == 2) { - $data = $this->request->getPost(); + $request_data = $this->request->getPost(); + + $rules = [ + 'note' => [ + 'label' => 'Add Notes', + 'rules' => 'required|min_length[3]|max_length[1000]', + 'errors' => [ + 'required' => 'The note field cannot be empty.', + 'min_length' => 'The note is too short (minimum 3 characters).', + 'max_length' => 'The note cannot exceed 1000 characters.' + ] + ], + ]; + + if (!$this->validate($rules)) { + return $this->response->setStatusCode(400)->setJSON([ + 'status' => false, + 'message' => 'Input validation failed', + 'code' => 400, + 'errors' => $this->validator->getErrors() + ]); + } + + $data = sanitizeInputArrayAdvanced($request_data); // if (isset($data['id']) && $data['id'] != ''){ // print_rr($data);die(); $status = $this->ticketNoteModel->save($data); $id = isset($data['id']) ? $data['id'] : $this->ticketNoteModel->insertID(); - // } if ($status) { return $this->respond(['status' => true, 'id' => $id], 200); @@ -1623,6 +1810,35 @@ class TicketController extends BaseController { $received_data = $this->request->getPost(); + $rules = [ + 'emp_mail' => [ + 'label' => 'To', + 'rules' => 'required|valid_email', + 'errors' => ['required' => 'Recipient email is missing.','valid_email' => 'Please provide a valid email address for the recipient.'] + ], + 'mail_subject' => [ + 'label' => 'Subject', + 'rules' => 'required|min_length[5]', + 'errors' => [ + 'required' => 'Please enter a Subject for the mail.', + 'min_length' => 'Subject should be at least 5 characters long.' + ] + ], + 'content' => [ + 'label' => 'Mail Content', + 'rules' => 'required', + 'errors' => ['required' => 'You cannot send an empty mail.'] + ] + ]; + + if (!$this->validate($rules)) { + return $this->response->setStatusCode(400)->setJSON([ + 'status' => false, + 'message' => 'Input validation failed', + 'code' => 400, + 'errors' => $this->validator->getErrors() + ]); + } // print_r($received_data); die; $received_data['sender'] = 'staff'; $status = $this->ticketMessageModel->insert($received_data); @@ -2773,7 +2989,45 @@ class TicketController extends BaseController public function upload_url() { - $data = $this->request->getPost(); + + $request_data = $this->request->getPost(); + $data = sanitizeInputArrayAdvanced($request_data); + + $rules = [ + 'ticket_id_url' => [ + 'label' => 'Ticket ID URL', + 'rules' => 'required|numeric', + 'errors' => [ + 'required' => 'System could not identify the Number.', + 'numeric' => 'Invalid format.' + ] + ], + 'docs_name.*' => [ + 'label' => 'Required Documents', + 'rules' => 'required|regex_match[/^[a-zA-Z0-9_\- ]+$/]', + 'errors' => [ + 'required' => 'Document Name is required', + 'regex_match' => 'Document Name can only contain letters, numbers, hyphens, and underscores' + ] + ], + 'url.*' => [ + 'label' => 'URL', + 'rules' => 'required', + 'errors' => [ + 'required' => 'URL is required', + ] + ] + ]; + + if (!$this->validate($rules)) { + return $this->response->setStatusCode(400)->setJSON([ + 'status' => false, + 'message' => 'Input validation failed', + 'code' => 400, + 'errors' => $this->validator->getErrors() + ]); + } + $get_file_data = $this->request->getFiles('file_upload') ?? []; $ticket_id = $data['ticket_id_url']; @@ -3096,7 +3350,7 @@ class TicketController extends BaseController public function claimDumpUpload() { - $data['tab_name'] = "Claim Dupm Upload"; + $data['tab_name'] = "Claim Dump Upload"; $data['page_name'] = "Claims"; $data['tpa_list'] = $this->TPAModel->where('is_active', 1)->findAll(); @@ -3254,12 +3508,40 @@ class TicketController extends BaseController } // -------- END CLAIM DUMP UPLOAD ---------------------------------------------------------------------------------------------- - - public function saveIRDocsJson() { - $ticket_id = $this->request->getPost('ticket_id'); - $required_docs = $this->request->getPost('required_docs'); + $request_data = $this->request->getPost(); + $data = sanitizeInputArrayAdvanced($request_data); + $ticket_id = $data['ticket_id']; + $required_docs = $data['required_docs']; + + $rules = [ + 'ticket_id' => [ + 'label' => 'Ticket ID', + 'rules' => 'required|numeric', + 'errors' => [ + 'required' => 'System could not identify the Number.', + 'numeric' => 'Invalid format.' + ] + ], + 'required_docs' => [ + 'label' => 'Required Documents', + 'rules' => 'required|regex_match[/^[a-zA-Z0-9_\- ]+$/]', + 'errors' => [ + 'required' => 'Document Name is required', + 'regex_match' => 'Document Name can only contain letters, numbers, hyphens, and underscores' + ] + ] + ]; + + if (!$this->validate($rules)) { + return $this->response->setStatusCode(400)->setJSON([ + 'status' => false, + 'message' => 'Input validation failed', + 'code' => 400, + 'errors' => $this->validator->getErrors() + ]); + } if(empty($ticket_id)){ return $this->respond(['status' => false, 'code' => 404, 'message' => 'Failed to save Docs'], 200); diff --git a/app/Controllers/TicketServiceController.php b/app/Controllers/TicketServiceController.php index 602f0708..f95f547d 100644 --- a/app/Controllers/TicketServiceController.php +++ b/app/Controllers/TicketServiceController.php @@ -1844,23 +1844,6 @@ class TicketServiceController extends BaseController // -------------------------------------------------------------------------------------------------------------------------------- - - public function tpaClaimImporter($params) - { - $file_id = $params['file_id']; - $tpa_claims_files_data = $this->claimDumpFileModel->where('id', $file_id)->first(); - - - if($this->vidal_primary_key == $tpa_claims_files_data['tpa_id']){ - - }else if($this->icici_primary_key == $tpa_claims_files_data['tpa_id']){ - - }else{ - $this->myLogger->logme('error', 'No TPA found to import'); - return ['status' => false, 'message' => 'No TPA found to import']; - } - } - public function tpaClaimDumpImporter($params) { $file_id = $params['file_id'] ?? null; // Move outside try to ensure catch can see it @@ -1980,45 +1963,6 @@ class TicketServiceController extends BaseController } } - public function tpaClaimDumpToTicketMasterImportBatchSeperater($params) - { - try { - - $file_id = $params['file_id'] ?? null; - $fileData = $this->claimDumpFileModel->where('id', $file_id)->first(); - - if (!$fileData) { - return ['status' => false, 'message' => 'Invalid file ID No file data found to import']; - } - - $handler = TpaClaimsImportFactory::make($fileData['tpa_id'] ?? 0); - $result = $handler->runTicketMasterInsert($params); - - return $result; - - } catch (\Throwable $th) { - - $this->myLogger->logme("error", 'TICKET_MASTER_CLAIM_IMPORTER_JOB :' .($th->getMessage() . ' --- ' . $th->getLine() . '----' . $th->getTraceAsString())); - - $errorData = [ - 'message' => $th->getMessage(), - 'file' => $th->getFile(), - 'line' => $th->getLine(), - 'code' => $th->getCode(), - 'trace' => $th->getTraceAsString(), - 'trace_array' => $th->getTrace(), // full array version (optional) - 'function' => $th->getTrace()[0]['function'] ?? null, - 'class' => $th->getTrace()[0]['class'] ?? null, - ]; - - return [ - 'status' => false, - 'message' => $th->getMessage(), - 'error_data' => json_encode($errorData, JSON_PRETTY_PRINT) - ]; - } - } - public function readExcelBySheetName(string $filePath, string $sheetName): array { if (!file_exists($filePath)) { diff --git a/app/Filters/Cors.php b/app/Filters/Cors.php index 3cfd1252..60a97a89 100644 --- a/app/Filters/Cors.php +++ b/app/Filters/Cors.php @@ -38,7 +38,7 @@ class Cors implements FilterInterface * * @var string */ - protected string $allowedMethods = 'GET,POST,PUT,PATCH,DELETE,OPTIONS'; + protected string $allowedMethods = 'GET,POST,OPTIONS'; /** * HTTP headers allowed in CORS requests diff --git a/app/Helpers/JWTToken.php b/app/Helpers/JWTToken.php index 311182d4..c964bac7 100755 --- a/app/Helpers/JWTToken.php +++ b/app/Helpers/JWTToken.php @@ -30,16 +30,16 @@ class JWTToken try{ $token = JWT::encode($request_data ,$secret_Key,'HS512'); $id = $request_data['id']; - $data["token_time_out"] = time() + getenv('TOKENTIMEOUT'); + $update["token_time_out"] = time() + getenv('TOKENTIMEOUT'); if(isset($data['emp_code'])){ $model = new EmployeeModel(); - $model->update($id, $data); + $model->update($id, $update); }else{ $models = new LevelContactModel(); $id = $request_data['post_hr_id']; - $models->update($id, $data); + $models->update($id, $update); } diff --git a/app/Libraries/TPAClaimsImportServices/AbhiClaimImportService.php b/app/Libraries/TPAClaimsImportServices/AbhiClaimImportService.php index 3ee5c066..ffb4b970 100644 --- a/app/Libraries/TPAClaimsImportServices/AbhiClaimImportService.php +++ b/app/Libraries/TPAClaimsImportServices/AbhiClaimImportService.php @@ -111,6 +111,7 @@ class AbhiClaimImportService extends BaseTpaClaimImportService 'diagnosis' => 'claim_description', 'healthcard_id' => 'tpa_no', 'claim_type' => 'tpa_claim_type', + 'diagnosis' => 'tpa_ailments', ]; @@ -148,20 +149,7 @@ class AbhiClaimImportService extends BaseTpaClaimImportService } $builder = $this->db->table('claims_dump_abhi'); - - foreach ($data as $value) { - - if (!$builder->insert($value)) { - - // 🔍 Debug purpose - log_message('error', print_r($this->db->error(), true)); - log_message('error', $this->db->getLastQuery()); - - return false; - } - } - - return true; + return $builder->insertBatch($data); } @@ -321,8 +309,14 @@ class AbhiClaimImportService extends BaseTpaClaimImportService $item['emp_code'] = $employee_data['emp_code'] ?? null; $item['emp_mail'] = $employee_data['email_corporate'] ?? null; $item['emp_mobile'] = $employee_data['mobile'] ?? null; - $item['insured_emp_id'] = $employee_data['insured_emp_id'] ?? null; - $item['insured_name'] = $employee_data['insured_name'] ?? null; + if (!empty($employee_data['insured_emp_id'])) { + $item['insured_emp_id'] = $employee_data['insured_emp_id'] ?? null; + $item['insured_name'] = $employee_data['insured_name'] ?? null; + }else{ + $reason = 'This Dependent employee not exist in our system.'; + $rejecetd_reason[] = ["id" => $row['id'], "master_reject_reason" => $reason]; + continue; + } } else { $reason = 'This employee not exist in our system.'; diff --git a/app/Libraries/TPAClaimsImportServices/BaseTpaClaimImportService.php b/app/Libraries/TPAClaimsImportServices/BaseTpaClaimImportService.php index f2e94cfa..3a6a5777 100644 --- a/app/Libraries/TPAClaimsImportServices/BaseTpaClaimImportService.php +++ b/app/Libraries/TPAClaimsImportServices/BaseTpaClaimImportService.php @@ -92,6 +92,7 @@ abstract class BaseTpaClaimImportService $message = ''; $hasExecutedTask = false; + $status = true; // Process Mapped Data if (!empty($ticketMasterData['mapped_array'])) { @@ -102,6 +103,8 @@ abstract class BaseTpaClaimImportService } $message .= 'Ticket Master Claim bulk insert success. '; $hasExecutedTask = true; + }else{ + $status = false; } // Process Rejected Reasons @@ -113,7 +116,7 @@ abstract class BaseTpaClaimImportService } $message .= empty($ticketMasterData['mapped_array']) - ? 'Those employees not in our system. ' + ? 'Those employee or dependent not in our system. ' : 'Ticket Master Claim rejected reason updated successfully. '; $hasExecutedTask = true; } @@ -126,7 +129,7 @@ abstract class BaseTpaClaimImportService // 2. Commit the transaction $this->db->transCommit(); - return ['status' => true, 'message' => trim($message)]; + return ['status' => $status, 'message' => trim($message)]; } catch (\Throwable $th) { // 3. Rollback on crash diff --git a/app/Libraries/TPAClaimsImportServices/FhplClaimImportService.php b/app/Libraries/TPAClaimsImportServices/FhplClaimImportService.php index f4410b55..324fd3a7 100644 --- a/app/Libraries/TPAClaimsImportServices/FhplClaimImportService.php +++ b/app/Libraries/TPAClaimsImportServices/FhplClaimImportService.php @@ -174,6 +174,8 @@ class FhplClaimImportService extends BaseTpaClaimImportService 'cheque_no' => 'utr_details', 'uhid_no' => 'tpa_no', 'claim_type' => 'tpa_claim_type', + 'diagnosis' => 'tpa_ailments', + ]; protected $statusMapping = [ @@ -217,11 +219,8 @@ class FhplClaimImportService extends BaseTpaClaimImportService return false; } - $ClaimsDumpFhplModel = new ClaimsDumpFhplModel(); - $result = $ClaimsDumpFhplModel->insertBatch($data); - - return true; - + $builder = $this->db->table('claims_dump_fhpl'); + return $builder->insertBatch($data); } @@ -381,8 +380,14 @@ class FhplClaimImportService extends BaseTpaClaimImportService $item['emp_code'] = $employee_data['emp_code'] ?? null; $item['emp_mail'] = $employee_data['email_corporate'] ?? null; $item['emp_mobile'] = $employee_data['mobile'] ?? null; - $item['insured_emp_id'] = $employee_data['insured_emp_id'] ?? null; - $item['insured_name'] = $employee_data['insured_name'] ?? null; + if (!empty($employee_data['insured_emp_id'])) { + $item['insured_emp_id'] = $employee_data['insured_emp_id'] ?? null; + $item['insured_name'] = $employee_data['insured_name'] ?? null; + }else{ + $reason = 'This Dependent employee not exist in our system.'; + $rejecetd_reason[] = ["id" => $row['id'], "master_reject_reason" => $reason]; + continue; + } } else { $reason = 'This employee not exist in our system.'; diff --git a/app/Libraries/TPAClaimsImportServices/IciciClaimImportService.php b/app/Libraries/TPAClaimsImportServices/IciciClaimImportService.php index fb1d731f..132986a2 100644 --- a/app/Libraries/TPAClaimsImportServices/IciciClaimImportService.php +++ b/app/Libraries/TPAClaimsImportServices/IciciClaimImportService.php @@ -101,6 +101,7 @@ class IciciClaimImportService extends BaseTpaClaimImportService 'uhid' => 'tpa_no', 'rejected_query_desc' => 'claim_description', 'type_of_claim' => 'tpa_claim_type', + 'diagnosis' => 'tpa_ailments', ]; protected $statusMapping = [ @@ -135,29 +136,8 @@ class IciciClaimImportService extends BaseTpaClaimImportService return false; } - try { - - - $ClaimsDumpFhplModel = new ClaimsDumpFhplModel(); - $result = $ClaimsDumpFhplModel->insertBatch($data); - - return true; - - } catch (\Throwable $th) { - - $errorData = [ - 'message' => $th->getMessage(), - 'file' => $th->getFile(), - 'line' => $th->getLine(), - 'code' => $th->getCode(), - 'trace' => $th->getTraceAsString(), - 'trace_array' => $th->getTrace(), // full array version (optional) - 'function' => $th->getTrace()[0]['function'] ?? null, - 'class' => $th->getTrace()[0]['class'] ?? null, - ]; - return false; - } - + $builder = $this->db->table('claims_dump_icici'); + return $builder->insertBatch($data); } @@ -317,8 +297,14 @@ class IciciClaimImportService extends BaseTpaClaimImportService $item['emp_code'] = $employee_data['emp_code'] ?? null; $item['emp_mail'] = $employee_data['email_corporate'] ?? null; $item['emp_mobile'] = $employee_data['mobile'] ?? null; - $item['insured_emp_id'] = $employee_data['insured_emp_id'] ?? null; - $item['insured_name'] = $employee_data['insured_name'] ?? null; + if (!empty($employee_data['insured_emp_id'])) { + $item['insured_emp_id'] = $employee_data['insured_emp_id'] ?? null; + $item['insured_name'] = $employee_data['insured_name'] ?? null; + }else{ + $reason = 'This Dependent employee not exist in our system.'; + $rejecetd_reason[] = ["id" => $row['id'], "master_reject_reason" => $reason]; + continue; + } } else { $reason = 'This employee not exist in our system.'; diff --git a/app/Libraries/TPAClaimsImportServices/MediAssistClaimImportService.php b/app/Libraries/TPAClaimsImportServices/MediAssistClaimImportService.php index 0c68ece9..d052c9f5 100644 --- a/app/Libraries/TPAClaimsImportServices/MediAssistClaimImportService.php +++ b/app/Libraries/TPAClaimsImportServices/MediAssistClaimImportService.php @@ -152,6 +152,7 @@ class MediAssistClaimImportService extends BaseTpaClaimImportService // Payment 'utr_no' => 'utr_details', 'claim_type' => 'tpa_claim_type', + 'primary_ailment_name' => 'tpa_ailments', ]; protected $statusMapping = [ @@ -334,8 +335,14 @@ class MediAssistClaimImportService extends BaseTpaClaimImportService $item['emp_code'] = $employee_data['emp_code'] ?? null; $item['emp_mail'] = $employee_data['email_corporate'] ?? null; $item['emp_mobile'] = $employee_data['mobile'] ?? null; - $item['insured_emp_id'] = $employee_data['insured_emp_id'] ?? null; - $item['insured_name'] = $employee_data['insured_name'] ?? null; + if (!empty($employee_data['insured_emp_id'])) { + $item['insured_emp_id'] = $employee_data['insured_emp_id'] ?? null; + $item['insured_name'] = $employee_data['insured_name'] ?? null; + }else{ + $reason = 'This Dependent employee not exist in our system.'; + $rejecetd_reason[] = ["id" => $row['id'], "master_reject_reason" => $reason]; + continue; + } } else { $reason = 'This employee not exist in our system.'; diff --git a/app/Libraries/TPAClaimsImportServices/RcareClaimImportService.php b/app/Libraries/TPAClaimsImportServices/RcareClaimImportService.php index a75289a2..770caadd 100644 --- a/app/Libraries/TPAClaimsImportServices/RcareClaimImportService.php +++ b/app/Libraries/TPAClaimsImportServices/RcareClaimImportService.php @@ -84,6 +84,8 @@ class RcareClaimImportService extends BaseTpaClaimImportService 'hospital_district' => 'hospital_city', 'diagnosis' => 'claim_description', + 'diagnosis' => 'tpa_ailments', + // Payment 'cheque_neft_number' => 'utr_details', @@ -124,28 +126,8 @@ class RcareClaimImportService extends BaseTpaClaimImportService return false; } - try { - - $builder = $this->db->table('claims_dump_reliance'); - $builder->insertBatch($data); - - return true; - - } catch (\Throwable $th) { - - $errorData = [ - 'message' => $th->getMessage(), - 'file' => $th->getFile(), - 'line' => $th->getLine(), - 'code' => $th->getCode(), - 'trace' => $th->getTraceAsString(), - 'trace_array' => $th->getTrace(), // full array version (optional) - 'function' => $th->getTrace()[0]['function'] ?? null, - 'class' => $th->getTrace()[0]['class'] ?? null, - ]; - dd($errorData); - return false; - } + $builder = $this->db->table('claims_dump_reliance'); + return $builder->insertBatch($data); } @@ -305,8 +287,14 @@ class RcareClaimImportService extends BaseTpaClaimImportService $item['emp_code'] = $employee_data['emp_code'] ?? null; $item['emp_mail'] = $employee_data['email_corporate'] ?? null; $item['emp_mobile'] = $employee_data['mobile'] ?? null; - $item['insured_emp_id'] = $employee_data['insured_emp_id'] ?? null; - $item['insured_name'] = $employee_data['insured_name'] ?? null; + if (!empty($employee_data['insured_emp_id'])) { + $item['insured_emp_id'] = $employee_data['insured_emp_id'] ?? null; + $item['insured_name'] = $employee_data['insured_name'] ?? null; + }else{ + $reason = 'This Dependent employee not exist in our system.'; + $rejecetd_reason[] = ["id" => $row['id'], "master_reject_reason" => $reason]; + continue; + } } else { $reason = 'This employee not exist in our system.'; diff --git a/app/Libraries/TPAClaimsImportServices/VidalClaimImportService.php b/app/Libraries/TPAClaimsImportServices/VidalClaimImportService.php index 50ef9924..c90d580b 100644 --- a/app/Libraries/TPAClaimsImportServices/VidalClaimImportService.php +++ b/app/Libraries/TPAClaimsImportServices/VidalClaimImportService.php @@ -343,7 +343,9 @@ class VidalClaimImportService extends BaseTpaClaimImportService // Meta 'file_id' => 'file_id', - 'type_of_claim' => 'tpa_claim_type', + 'type_of_claim' => 'tpa_claim_type', + 'diagnosis' => 'tpa_ailments', + ]; protected $statusMapping = [ @@ -364,9 +366,8 @@ class VidalClaimImportService extends BaseTpaClaimImportService } $builder = $this->db->table('claims_dump_vidal'); - $builder->insertBatch($data); + return $builder->insertBatch($data); - return true; } @@ -541,7 +542,7 @@ class VidalClaimImportService extends BaseTpaClaimImportService } // Meta fields - $item['claim_status_id'] = $statusMapping[$row['status']] ?? 61; + $item['claim_status_id'] = $statusMapping[$row['claim_status']] ?? 61; $item['file_id'] = $file_id; $item['claim_dump_ref_id'] = $row['id']; $item['created_by'] = $file_data['created_by'] ?? null; @@ -620,8 +621,14 @@ class VidalClaimImportService extends BaseTpaClaimImportService $item['emp_name'] = $employee_data['id'] ?? null; $item['emp_mail'] = $employee_data['insurer_id'] ?? null; $item['emp_mobile'] = $employee_data['tpa_id'] ?? null; - $item['insured_emp_id'] = $employee_data['insured_emp_id'] ?? null; - $item['insured_name'] = $employee_data['insured_name'] ?? null; + if (!empty($employee_data['insured_emp_id'])) { + $item['insured_emp_id'] = $employee_data['insured_emp_id'] ?? null; + $item['insured_name'] = $employee_data['insured_name'] ?? null; + }else{ + $reason = 'This Dependent employee not exist in our system.'; + $rejecetd_reason[] = ["id" => $row['id'], "master_reject_reason" => $reason]; + continue; + } }else{ $reason = " This policy no ( " . $row['insurer_policy_number'] ." ) does not exist in our system"; $rejecetd_reason[$row['id']] = ["ticket_master_insert_reject_reason" => $reason]; diff --git a/app/Models/BdsPlacementModel.php b/app/Models/BdsPlacementModel.php index 82edfce5..947f8a0f 100644 --- a/app/Models/BdsPlacementModel.php +++ b/app/Models/BdsPlacementModel.php @@ -57,6 +57,64 @@ class BdsPlacementModel extends Model public function getClientInstallmentDetails() + { + // 1. Fetch common data ONCE (Heads, Admins, Business Team) + // This saves hundreds of redundant queries + $heads = $this->db->table('user_profiles') + ->select('email')->where(['role' => 5, 'is_active' => 1]) + ->get()->getResultArray(); + + $admins = $this->db->table('user_profiles') + ->select('email')->where(['role' => 1, 'is_active' => 1]) + ->get()->getResultArray(); + + $businessTeam = $this->db->table("user_teams ut") + ->select("up.email") + ->join('user_profiles up', 'up.id = ut.user_id AND up.is_active = 1') + ->where(["ut.team_id" => 7, "ut.is_active" => 1]) + ->get()->getResultArray(); + + // 2. Main Query + $builder = $this->db->table("bds_installment_payment_details bipd") + ->select("bipd.*, ct.client_name, ct.short_name, cb.branch_name, leads.salse_person_id, cp.policy_no") + ->join("policy_transaction pt", "pt.id = bipd.pt_id") + ->join("clients ct", "ct.id = pt.client_id") + ->join("client_branch cb", "cb.id = pt.client_branch_id") + ->join("leads", "leads.id = bipd.lead_id") + ->join("client_policy cp", "cp.id = pt.client_policy_id") + ->where("bipd.is_active", 1) + ->where("bipd.payment_date", date('Y-m-d', strtotime('+15 days'))); + + $data = $builder->get()->getResultArray(); + + // Loop through to extract sales person details + // 3. Simple Loop for Sales Person (Since it relies on a JSON ID) + foreach ($data as &$row) { + $sales_person_ids = json_decode($row['salse_person_id'], true); + $sales_person_id = $sales_person_ids[0] ?? null; + + if ($sales_person_id) { + $user = $this->db->table('user_profiles') + ->select('email') // or whatever field + ->where('id', (int)$sales_person_id) // Cast to int for extra safety + ->get() + ->getRowArray(); + + $row['sales_person'] = $user['email'] ?? 'N/A'; + } else { + $row['sales_person'] = 'Not Assigned'; + } + + // Assign the pre-fetched data + $row['heads'] = $heads; + $row['admins'] = $admins; + $row['buisness_team'] = $businessTeam; + } + + + return $data; + } + public function getClientInstallmentDetails_olds() { $builder = $this->db->table("bds_installment_payment_details bipd") diff --git a/app/Models/ClientPolicyModel.php b/app/Models/ClientPolicyModel.php index b11c97f6..762e8c40 100755 --- a/app/Models/ClientPolicyModel.php +++ b/app/Models/ClientPolicyModel.php @@ -316,7 +316,7 @@ class ClientPolicyModel extends Model ->select('user_profiles.first_name as username') ->select("CASE WHEN cash_deposit.file_id IS NOT NULL AND cash_deposit.file_id != '' - THEN CONCAT(" . $this->db->escape($url) . ", cash_deposit.file_id) + THEN CONCAT(" . $this->db->escape($url) . ", MD5(cash_deposit.file_id)) ELSE NULL END AS split_up_url", false) diff --git a/app/Models/EmployeePolicyModel.php b/app/Models/EmployeePolicyModel.php index 6b9b17f1..33ecc71b 100755 --- a/app/Models/EmployeePolicyModel.php +++ b/app/Models/EmployeePolicyModel.php @@ -222,7 +222,7 @@ class EmployeePolicyModel extends Model // return $res; // } // remarks do not remove - public function getEmployeePolicy($client_id = 0, $policy_id = 0, $status = [], $branch_id = 0, $emp_code = "", $emp_name = "") + public function getEmployeePolicy($client_id = 0, $policy_id = 0, $status = [], $branch_id = 0, $emp_code = "", $emp_name = "", $status_type = '') { // dd($status); $ecard_download_link = " @@ -356,8 +356,13 @@ class EmployeePolicyModel extends Model // Always check these conditions $result ->where('employee_polices.is_active', 1) - ->where('emp.is_active', 1) - ->where('employee_polices.status !=', 'inactive'); + ->where('emp.is_active', 1); + + if($status_type == 'inactive'){ + $result->whereIn('employee_polices.status', ['active', 'inactive']); + }else{ + $result->where('employee_polices.status !=', 'inactive'); + } $res = $result->findAll(); diff --git a/app/Models/InsurerModel.php b/app/Models/InsurerModel.php index d264c231..a08b3c9e 100755 --- a/app/Models/InsurerModel.php +++ b/app/Models/InsurerModel.php @@ -64,6 +64,7 @@ class InsurerModel extends Model ->select(' insurers.id, insurers.name, + insurers.short_name, cd_master.cd_ac_no AS cd_master_account_no ') ->join('insurers', 'insurers.id = client_policy.insurer_id') diff --git a/app/Views/UserList.php b/app/Views/UserList.php index ca47296c..571ddda9 100755 --- a/app/Views/UserList.php +++ b/app/Views/UserList.php @@ -1148,15 +1148,28 @@ table.dataTable tbody td { console.error("Error Thrown:", error); console.error("Status:", status); if (xhr.status === 400) { - let response = JSON.parse(xhr.responseText); - if (response.errors) { - $.each(response.errors, function (field, message) { - toastr.warning(message, 'Validation Error'); - }); - } else { - toastr.warning(response.message || 'Validation failed', 'Warning'); - } - }else{toastr.error('Server error occurred.', 'Error');} + let response = JSON.parse(xhr.responseText); + let errorMessages = ""; + let seenMessages = []; // Array to store unique messages + if (response.errors) { + $.each(response.errors, function (field, message) { + if (!seenMessages.includes(message)) { + errorMessages += `• ${message}
`; + seenMessages.push(message); // Mark this message as "seen" + } + }); + toastr.error(errorMessages, 'Validation Error', { "allowHtml": true }); + } else { + toastr.warning(response.message || 'Validation failed', 'Warning'); + } + } else if (xhr.status === 403) { + let response = JSON.parse(xhr.responseText); + toastr.error(response.message, 'Security Policy'); + } else if (xhr.status === 500) { + toastr.error('Something went wrong . Please try again later.', 'Server Error'); + } else { + toastr.error('An unexpected error occurred. Please try again later.', 'Error'); + } } }); @@ -1177,7 +1190,7 @@ table.dataTable tbody td { var student_id = $(this).attr('data-id'); $.get(''+student_id, function (data) { console.log(data); - toastr.success('User removed successfully', 'success'); + toastr.success('User removed successfully', 'Success'); window.location.reload() }) } @@ -1357,15 +1370,31 @@ table.dataTable tbody td { error: function(xhr) { console.log("Error: " + xhr.statusText); if (xhr.status === 400) { - let response = JSON.parse(xhr.responseText); - if (response.errors) { - $.each(response.errors, function (field, message) { - toastr.warning(message, 'Validation Error'); - }); - } else { - toastr.warning(response.message || 'Validation failed', 'Warning'); - } - }else{toastr.error('Server error occurred.', 'Error');} + let response = JSON.parse(xhr.responseText); + let errorMessages = ""; + let seenMessages = []; // Array to store unique messages + if (response.errors) { + $.each(response.errors, function (field, message) { + if (!seenMessages.includes(message)) { + errorMessages += `• ${message}
`; + seenMessages.push(message); // Mark this message as "seen" + } + }); + toastr.error(errorMessages, 'Validation Error', { "allowHtml": true }); + } else { + toastr.warning(response.message || 'Validation failed', 'Warning'); + } + + }else if (xhr.status === 403) { + let response = JSON.parse(xhr.responseText); + toastr.error(response.message, 'Security Policy'); + } else if (xhr.status === 500) { + toastr.error('Something went wrong . Please try again later.', 'Server Error'); + } else { + toastr.error('An unexpected error occurred. Please try again later.', 'Error'); + } + console.error('Unexpected error:', xhr.responseText); + }, complete: function() { btn.disabled = false; @@ -1426,17 +1455,31 @@ table.dataTable tbody td { }, error: function(xhr) { console.log("Error: " + xhr.statusText); - toastr.error('Server error occurred.', 'Error'); + console.error(xhr.responseText); if (xhr.status === 400) { - let response = JSON.parse(xhr.responseText); - if (response.errors) { - $.each(response.errors, function (field, message) { - toastr.warning(message, 'Validation Error'); - }); - } else { - toastr.warning(response.message || 'Validation failed', 'Warning'); - } - }else{toastr.error('Server error occurred.', 'Error');} + let response = JSON.parse(xhr.responseText); + let errorMessages = ""; + let seenMessages = []; // Array to store unique messages + if (response.errors) { + $.each(response.errors, function (field, message) { + if (!seenMessages.includes(message)) { + errorMessages += `• ${message}
`; + seenMessages.push(message); // Mark this message as "seen" + } + }); + toastr.error(errorMessages, 'Validation Error', { "allowHtml": true }); + } else { + toastr.warning(response.message || 'Validation failed', 'Warning'); + } + + } else if (xhr.status === 403) { + let response = JSON.parse(xhr.responseText); + toastr.error(response.message, 'Security Policy'); + } else if (xhr.status === 500) { + toastr.error('Something went wrong . Please try again later.', 'Server Error'); + } else { + toastr.error('An unexpected error occurred. Please try again later.', 'Error'); + } }, complete: function() { btn.disabled = false; @@ -1969,7 +2012,7 @@ table.dataTable tbody td { checkDuplicateTableFieldValue(table, field, value, function(isDuplicate) { if (isDuplicate) { - toastr.warning(message, 'WARNING'); + toastr.warning(message, 'Warning'); // $(input).val('') $('#' + submitButId).prop('disabled', true); } else{ diff --git a/app/Views/add_image_list.php b/app/Views/add_image_list.php index 113ce962..d79655f6 100755 --- a/app/Views/add_image_list.php +++ b/app/Views/add_image_list.php @@ -219,39 +219,42 @@ table.dataTable thead th { } }, error: function(xhr, status, error) { - console.error(xhr.responseText); - console.error('Status:', status); - console.error('Error:', error); + // Get the current domain + const hostname = window.location.hostname; + if (hostname === 'localhost' || hostname === '127.0.0.1') { + // DEVELOPER MODE: Show everything in a nice group + console.group("%c Debug: Server Error ", "background: #222; color: #bada55; padding: 2px;"); + console.error("Status:", xhr.status); + console.error("Type:", error); + console.error("Full Response:", xhr.responseText); + console.groupEnd(); + } else { + // LIVE MODE: Only log a simple, non-revealing error + console.error("Server Error: Action could not be completed. Reference Code: " + xhr.responseText); + } - let msg = 'Something went wrong. Please try again later.'; - - switch (xhr.status) { - case 400: - let response = xhr.responseJSON || JSON.parse(xhr.responseText); - if (response.errors) { - $.each(response.errors, function (field, message) { - toastr.warning(message, 'Validation Error'); - }); - } else { - toastr.warning(response.message || 'Validation failed', 'Warning'); - } - msg = response.message || 'Bad Request — Invalid input.'; - break; - case 401: - msg = 'Unauthorized — Please log in again.'; - break; - case 403: - msg = 'Forbidden — You do not have permission.'; - break; - case 404: - msg = 'Not Found — Requested URL or resource not found.'; - break; - case 500: - console.log('Internal Server Error — Please contact support.'); - msg = xhr.responseJSON?.message || xhr.responseText || msg; - break; - default: - msg = xhr.responseJSON?.message || xhr.responseText || msg; + if (xhr.status === 400) { + let response = JSON.parse(xhr.responseText); + let errorMessages = ""; + let seenMessages = []; // Array to store unique messages + if (response.errors) { + $.each(response.errors, function (field, message) { + if (!seenMessages.includes(message)) { + errorMessages += `• ${message}
`; + seenMessages.push(message); // Mark this message as "seen" + } + }); + toastr.error(errorMessages, 'Validation Error', { "allowHtml": true }); + } else { + toastr.warning(response.message || 'Validation failed', 'Warning'); + } + } else if (xhr.status === 403) { + let response = JSON.parse(xhr.responseText); + toastr.error(response.message, 'Security Policy'); + } else if (xhr.status === 500) { + toastr.error('Something went wrong . Please try again later.', 'Server Error'); + } else { + toastr.error('An unexpected error occurred. Please try again later.', 'Error'); } } diff --git a/app/Views/bds_dump_file_list.php b/app/Views/bds_dump_file_list.php index bd6e23ff..b8a39153 100644 --- a/app/Views/bds_dump_file_list.php +++ b/app/Views/bds_dump_file_list.php @@ -182,9 +182,9 @@ console.log('Upload successful:', response); if (response.status == true) { - toastr.success(response.message, "SUCCESS"); + toastr.success(response.message, "Success"); } else { - toastr.error(response.message, "ERROR"); + toastr.error(response.message, "Error"); } // Reset form @@ -196,14 +196,29 @@ error: function(xhr, status, error) { // Handle error response console.error('Upload failed:', error); - console.error('Upload failed:', error); + console.error('Unexpected error:', xhr.responseText); if (xhr.status === 400) { - var response = JSON.parse(xhr.responseText); - toastr.warning(response.message || 'Validation failed', 'Warning'); - } - if (xhr.status === 500) { - var response = JSON.parse(xhr.responseText); - toastr.warning(response.message || 'Validation failed', 'Warning'); + let response = JSON.parse(xhr.responseText); + let errorMessages = ""; + let seenMessages = []; // Array to store unique messages + if (response.errors) { + $.each(response.errors, function (field, message) { + if (!seenMessages.includes(message)) { + errorMessages += `• ${message}
`; + seenMessages.push(message); // Mark this message as "seen" + } + }); + toastr.error(errorMessages, 'Validation Error', { "allowHtml": true }); + } else { + toastr.warning(response.message || 'Validation failed', 'Warning'); + } + } else if (xhr.status === 403) { + let response = JSON.parse(xhr.responseText); + toastr.error(response.message, 'Security Policy'); + } else if (xhr.status === 500) { + toastr.error('Something went wrong . Please try again later.', 'Server Error'); + } else { + toastr.error('An unexpected error occurred. Please try again later.', 'Error'); } }, complete: function() { @@ -222,7 +237,7 @@ // Check file size (optional - set max size as needed, e.g., 10MB) var maxSize = 10 * 1024 * 1024; // 10MB in bytes if (file.size > maxSize) { - toastr.warning('File size should not exceed 10MB'); + toastr.warning('File size should not exceed 10MB', 'Warning'); $(this).val(''); // Clear the input return false; } diff --git a/app/Views/cd_master_add_modal.php b/app/Views/cd_master_add_modal.php index d07b87d4..4cc06188 100644 --- a/app/Views/cd_master_add_modal.php +++ b/app/Views/cd_master_add_modal.php @@ -187,7 +187,7 @@ } } else { - toastr.warning(res.message, 'WARNING'); + toastr.warning(res.message, 'Warning'); } //this function for reset the form values after submitting the form or closing the form @@ -205,16 +205,29 @@ $('.loader').fadeOut(); $('.loader-mask').delay(350).fadeOut('slow'); if (xhr.status === 400) { - let response = JSON.parse(xhr.responseText); - if (response.errors) { - $.each(response.errors, function (field, message) { - toastr.warning(message, 'Validation Error'); - }); - } else { - toastr.warning(response.message || 'Validation failed', 'Warning'); + let response = JSON.parse(xhr.responseText); + let errorMessages = ""; + let seenMessages = []; // Array to store unique messages + if (response.errors) { + $.each(response.errors, function (field, message) { + if (!seenMessages.includes(message)) { + errorMessages += `• ${message}
`; + seenMessages.push(message); // Mark this message as "seen" } + }); + toastr.error(errorMessages, 'Validation Error', { "allowHtml": true }); + } else { + toastr.warning(response.message || 'Validation failed', 'Warning'); + } + } else if (xhr.status === 403) { + let response = JSON.parse(xhr.responseText); + toastr.error(response.message, 'Security Policy'); + } else if (xhr.status === 500) { + toastr.error('Something went wrong . Please try again later.', 'Server Error'); + } else { + toastr.error('An unexpected error occurred. Please try again later.', 'Error'); } - toastr.error('An error occurred while adding the CD account number.', 'ERROR'); + toastr.error('An error occurred while adding the CD account number.', 'Error'); } }); }); @@ -338,13 +351,13 @@ $('#cd_client_id').val('').select2(); $('#insurer_id_for_cd').val('').select2(); $('#insurer_branch_id').val('').select2(); - toastr.warning(response.message, 'WARNING'); + toastr.warning(response.message, 'Warning'); } }, function(xhr, status, error) { console.error('Error fetching data:', error); console.error(xhr.responseText); - toastr.error('An error occurred while checking the CD amount.', 'ERROR'); + toastr.error('An error occurred while checking the CD amount.', 'Error'); }); } } diff --git a/app/Views/cd_master_list.php b/app/Views/cd_master_list.php index 754b632c..57c23757 100755 --- a/app/Views/cd_master_list.php +++ b/app/Views/cd_master_list.php @@ -312,7 +312,7 @@ table.dataTable thead th { has('success')) : ?> - toastr.success('getFlashdata('success') ?>', 'success'); + toastr.success('getFlashdata('success') ?>', 'Success'); }) @@ -381,10 +381,10 @@ table.dataTable thead th { // console.log(res.status == true); if(res){ if (res.status == true) { - toastr.success('CD removed successfully.', 'success'); + toastr.success('CD removed successfully.', 'Success'); location.reload(); } else { - toastr.warning('Failed to remove CD.', 'warning'); + toastr.warning('Failed to remove CD.', 'Warning'); } } }, diff --git a/app/Views/claim_dump_file_list.php b/app/Views/claim_dump_file_list.php index 0cf55ed9..1330cded 100644 --- a/app/Views/claim_dump_file_list.php +++ b/app/Views/claim_dump_file_list.php @@ -185,7 +185,7 @@
-  [ Sample Excel ] +  [ " id="download_sample_file" style="font-size: small; color:red !important;">Download sample file ]
@@ -235,7 +235,7 @@ if(client_id){ if(!client_policy_id){ - toastr.warning('Please select the client policy', 'WARNING'); + toastr.warning('Please select the client policy', 'Warning'); return; } } @@ -280,9 +280,9 @@ console.log('Upload successful:', response); if (response.status == true) { - toastr.success(response.message, "SUCCESS"); + toastr.success(response.message, "Success"); } else { - toastr.error(response.message, "ERROR"); + toastr.error(response.message, "Error"); } // Reset form diff --git a/app/Views/claim_files_upload.php b/app/Views/claim_files_upload.php index 1c4f0079..7b9cd814 100644 --- a/app/Views/claim_files_upload.php +++ b/app/Views/claim_files_upload.php @@ -217,6 +217,29 @@ console.log("error in submission of url data"); console.error(xhr.responseText); console.error(status, error); + if (xhr.status === 400) { + let response = JSON.parse(xhr.responseText); + let errorMessages = ""; + let seenMessages = []; // Array to store unique messages + if (response.errors) { + $.each(response.errors, function (field, message) { + if (!seenMessages.includes(message)) { + errorMessages += `• ${message}
`; + seenMessages.push(message); // Mark this message as "seen" + } + }); + toastr.error(errorMessages, 'Validation Error', { "allowHtml": true }); + } else { + toastr.warning(response.message || 'Validation failed', 'Warning'); + } + } else if (xhr.status === 403) { + let response = JSON.parse(xhr.responseText); + toastr.error(response.message, 'Security Policy'); + } else if (xhr.status === 500) { + toastr.error('Something went wrong . Please try again later.', 'Server Error'); + } else { + toastr.error('An unexpected error occurred. Please try again later.', 'Error'); + } }, complete : function(){ @@ -566,7 +589,7 @@ function addDocument() { if (documentConfig.is_action_freeze) { - toastr.warning('Cannot add documents when action is frozen', 'WARNING'); + toastr.warning('Cannot add documents when action is frozen', 'Warning'); return; } @@ -591,7 +614,7 @@ function removeDocument(index) { if (documentConfig.is_action_freeze) { - toastr.warning('Cannot remove documents when action is frozen', 'WARNING'); + toastr.warning('Cannot remove documents when action is frozen', 'Warning'); return; } @@ -599,7 +622,7 @@ // ❗ If document is already received, do not remove if (doc.document_received === true) { - toastr.warning('Cannot remove a received document', 'WARNING'); + toastr.warning('Cannot remove a received document', 'Warning'); return; } @@ -640,7 +663,7 @@ const hasEmptyNames = documentConfig.docs.some(doc => !doc.document_name.trim()); if (hasEmptyNames) { - toastr.warning('Please fill in all document names', 'WARNING'); + toastr.warning('Please fill in all document names', 'Warning'); return false; } @@ -665,15 +688,38 @@ if (response.status) { loadConfiguration(response.data); - toastr.success(response.message, 'SUCCESS'); + toastr.success(response.message, 'Success'); } else { - toastr.warning(response.message, 'WARNING'); + toastr.warning(response.message, 'Warning'); } }, function(xhr, status, error) { console.error('Error fetching data:', error); console.error(xhr.responseText); - toastr.error('An error occurred while saving docs.', 'ERROR'); + if (xhr.status === 400) { + let response = JSON.parse(xhr.responseText); + let errorMessages = ""; + let seenMessages = []; // Array to store unique messages + if (response.errors) { + $.each(response.errors, function (field, message) { + if (!seenMessages.includes(message)) { + errorMessages += `• ${message}
`; + seenMessages.push(message); // Mark this message as "seen" + } + }); + toastr.error(errorMessages, 'Validation Error', { "allowHtml": true }); + } else { + toastr.warning(response.message || 'Validation failed', 'Warning'); + } + } else if (xhr.status === 403) { + let response = JSON.parse(xhr.responseText); + toastr.error(response.message, 'Security Policy'); + } else if (xhr.status === 500) { + toastr.error('Something went wrong . Please try again later.', 'Server Error'); + } else { + toastr.error('An unexpected error occurred. Please try again later.', 'Error'); + } + }); } diff --git a/app/Views/claim_mis_file_list.php b/app/Views/claim_mis_file_list.php index fc636bcb..56a7c04e 100644 --- a/app/Views/claim_mis_file_list.php +++ b/app/Views/claim_mis_file_list.php @@ -177,7 +177,7 @@ ]; if (!fileInput.files || !fileInput.files.length) { - toastr.warning('Please select a file', 'WARNING'); + toastr.warning('Please select a file', 'Warning'); return false; } @@ -193,7 +193,7 @@ ) { toastr.warning( 'Please upload a valid file (PDF / Excel: .pdf, .xls, .xlsx, .ods)', - 'WARNING' + 'Warning' ); return false; } @@ -221,9 +221,9 @@ console.log('Upload successful:', response); if (response.status == true) { - toastr.success(response.message, "SUCCESS"); + toastr.success(response.message, "Success"); } else { - toastr.error(response.message, "ERROR"); + toastr.error(response.message, "Error"); } // Reset form @@ -235,14 +235,29 @@ error: function(xhr, status, error) { // Handle error response console.error('Upload failed:', error); - console.error('Upload failed:', error); + console.error('Unexpected error:', xhr.responseText); if (xhr.status === 400) { - var response = JSON.parse(xhr.responseText); - toastr.warning(response.message || 'Validation failed', 'Warning'); - } - if (xhr.status === 500) { - var response = JSON.parse(xhr.responseText); - toastr.warning(response.message || 'Validation failed', 'Warning'); + let response = JSON.parse(xhr.responseText); + let errorMessages = ""; + let seenMessages = []; // Array to store unique messages + if (response.errors) { + $.each(response.errors, function (field, message) { + if (!seenMessages.includes(message)) { + errorMessages += `• ${message}
`; + seenMessages.push(message); // Mark this message as "seen" + } + }); + toastr.error(errorMessages, 'Validation Error', { "allowHtml": true }); + } else { + toastr.warning(response.message || 'Validation failed', 'Warning'); + } + } else if (xhr.status === 403) { + let response = JSON.parse(xhr.responseText); + toastr.error(response.message, 'Security Policy'); + } else if (xhr.status === 500) { + toastr.error('Something went wrong . Please try again later.', 'Server Error'); + } else { + toastr.error('An unexpected error occurred. Please try again later.', 'Error'); } }, complete: function() { diff --git a/app/Views/client_basic_info.php b/app/Views/client_basic_info.php index 625efc1e..17722d1c 100755 --- a/app/Views/client_basic_info.php +++ b/app/Views/client_basic_info.php @@ -351,19 +351,28 @@ input:checked + .slider:before { $submitButton.prop('disabled', false); if (xhr.status === 400) { let response = JSON.parse(xhr.responseText); + let errorMessages = ""; + let seenMessages = []; // Array to store unique messages if (response.errors) { $.each(response.errors, function (field, message) { - toastr.warning(message, 'Validation Error'); + if (!seenMessages.includes(message)) { + errorMessages += `• ${message}
`; + seenMessages.push(message); // Mark this message as "seen" + } }); + toastr.error(errorMessages, 'Validation Error', { "allowHtml": true }); } else { toastr.warning(response.message || 'Validation failed', 'Warning'); } + } else if (xhr.status === 403) { + let response = JSON.parse(xhr.responseText); + toastr.error(response.message, 'Security Policy'); } else if (xhr.status === 404) { toastr.warning('Resource not found', 'Warning'); } else if (xhr.status === 500) { - toastr.warning('Internal server error', 'Warning'); + toastr.error('Something went wrong . Please try again later.', 'Server Error'); } else { - toastr.warning('Unknown error occurred', 'Warning'); + toastr.error('An unexpected error occurred. Please try again later.', 'Error'); } }, 1000); } diff --git a/app/Views/client_branch.php b/app/Views/client_branch.php index 99ddb30f..97d8161a 100755 --- a/app/Views/client_branch.php +++ b/app/Views/client_branch.php @@ -44,6 +44,69 @@ cursor: pointer; } + +
@@ -162,12 +225,12 @@
-
@@ -495,6 +558,31 @@ $("#branch_form").submit(function(event) { if(xhr.status === 409){ alert('The Current Branch is Already Existing..!!'); } + else if (xhr.status === 400) { + let response = JSON.parse(xhr.responseText); + let errorMessages = ""; + let seenMessages = []; // Array to store unique messages + if (response.errors) { + $.each(response.errors, function (field, message) { + // Only add the message if it hasn't been seen before + if (!seenMessages.includes(message)) { + errorMessages += `• ${message}
`; + seenMessages.push(message); // Mark this message as "seen" + } + }); + + toastr.error(errorMessages, 'Validation Error', { "allowHtml": true }); + } else { + toastr.warning(response.message || 'Validation failed', 'Warning'); + } + } else if (xhr.status === 403) { + let response = JSON.parse(xhr.responseText); + toastr.error(response.message, 'Security Policy'); + } else if (xhr.status === 500) { + toastr.error('Something went wrong . Please try again later.', 'Server Error'); + } else { + toastr.error('An unexpected error occurred. Please try again later.', 'Error'); + } }, 300); }, complete: function() { @@ -967,7 +1055,7 @@ function validateInput(input, table, field, submitButId){ checkDuplicateTableFieldValue(table, field, value, function(isDuplicate) { if (isDuplicate) { - toastr.warning(message, 'WARNING'); + toastr.warning(message, 'Warning'); // $(input).val('') $('#' + submitButId).prop('disabled', true); } else{ @@ -1003,7 +1091,7 @@ function validateDuplicateByClientBranch(input, field, submitButId) { if (isLocalDuplicate) { console.log(`r u n Local`); console.log(`duplicate found for ${field}`); - toastr.warning(message, 'WARNING'); + toastr.warning(message, 'Warning'); $('#' + submitButId).prop('disabled', true); return; } @@ -1030,7 +1118,7 @@ function validateDuplicateByClientBranch(input, field, submitButId) { if (response.isDuplicate) { console.log(`r u n Server`); console.log(`duplicate found for ${field}`); - toastr.warning(message, 'WARNING'); + toastr.warning(message, 'Warning'); $('#' + submitButId).prop('disabled', true); } else { console.log(`No duplicate for ${field}`); @@ -1075,13 +1163,13 @@ function checkAllFieldsValid(submitButId) { $('#' + submitButId).prop('disabled', true); // show correct message based on what’s duplicated if (emailDuplicates && mobileDuplicates) { - toastr.warning("Email and Mobile values are duplicate!", "WARNING"); + toastr.warning("Email and Mobile values are duplicate!", "Warning"); console.log('Both Email and Mobile duplicates'); } else if (emailDuplicates) { - toastr.warning("Email duplicate!", "WARNING"); + toastr.warning("Email duplicate!", "Warning"); console.log('Cross Check Email duplicates'); } else if (mobileDuplicates) { - toastr.warning("Mobile duplicate!", "WARNING"); + toastr.warning("Mobile duplicate!", "Warning"); console.log('Cross Check Mobile duplicates'); } console.log(`btn Dis - true`); @@ -1127,9 +1215,9 @@ function removeLevelContacts(id){ console.log('Data fetched successfully:', response); if (response.status == true) { - toastr.success(response.message, 'SUCCESS'); + toastr.success(response.message, 'Success'); } else { - toastr.warning(response.message, 'WARNING'); + toastr.warning(response.message, 'Warning'); } }, function(xhr, status, error) { diff --git a/app/Views/client_kyc.php b/app/Views/client_kyc.php index f2d9adac..e9b726a5 100755 --- a/app/Views/client_kyc.php +++ b/app/Views/client_kyc.php @@ -157,7 +157,7 @@ $('#tbody').append(res.data); toastr.success('File uploaded successfully', 'Success'); }else{ - toastr.warning('File uploaded failed', 'WARNING'); + toastr.warning('File uploaded failed', 'Warning'); } }, error: function (xhr, status, error) { @@ -165,7 +165,7 @@ console.error(status, error); $('.loader').fadeOut(); $('.loader-mask').delay(350).fadeOut('slow'); - toastr.warning('Something Wrong!', 'warning'); + toastr.warning('Something Wrong!', 'Warning'); } }); }); @@ -211,7 +211,7 @@ $('#other_docs').append(res.data); toastr.success('File uploaded successfully', 'Success'); }else{ - toastr.warning('File uploaded failed', 'WARNING'); + toastr.warning('File uploaded failed', 'Warning'); } $('#kyc_form').trigger('reset'); @@ -221,7 +221,7 @@ console.error(status, error); $('.loader').fadeOut(); $('.loader-mask').delay(350).fadeOut('slow'); - toastr.warning('Something Wrong!', 'warning'); + toastr.warning('Something Wrong!', 'Warning'); } }); diff --git a/app/Views/client_kyc_2.php b/app/Views/client_kyc_2.php index 28e22522..7a34acc8 100755 --- a/app/Views/client_kyc_2.php +++ b/app/Views/client_kyc_2.php @@ -346,7 +346,7 @@ } // Invalid format - toastr.warning('Invalid file format. Only PDF or Image files are allowed.', 'WARNING!'); + toastr.warning('Invalid file format. Only PDF or Image files are allowed.', 'Warning'); $(fileInput).val(''); // clear file return false; // Invalid } diff --git a/app/Views/client_list.php b/app/Views/client_list.php index 8169b0b0..6594af87 100755 --- a/app/Views/client_list.php +++ b/app/Views/client_list.php @@ -378,55 +378,55 @@ $(document).ready(function() `); - $('#toggleButtons').on('change', function() { - let type = $(this).is(':checked') ? 1 : 2; - // $('div.col-6 h4').text( - // $(this).is(':checked') - // ? "GC Client List" - // : "RC Client List" - // ); - let url = '' + type; - $.ajax({ - url: url, - method: 'GET', - success: function(response) { - if (response.status === "success" && Array.isArray(response.data)) { - console.error("#CL 1 : ", response.data); - renderRows(response.data); - } else { - console.error("#CL 2 : ", response.data); - renderRows([]); - } - }, - error: function(xhr, status, error) { - console.error("Error loading:", error); - renderRows([]); - } - }); - }); +$('#toggleButtons').on('change', function() { + let type = $(this).is(':checked') ? 1 : 2; + let url = '' + type; + + $('.loader').fadeIn(); // Show loader during AJAX + + $.ajax({ + url: url, + method: 'GET', + success: function(response) { + $('.loader').fadeOut(); + // Pass response.data directly to the function + if (response.status === "success") { + renderRows(response.data); + } else { + // If the structure is slightly different, pass the whole object + renderRows(response); + } + }, + error: function(xhr, status, error) { + $('.loader').fadeOut(); + console.error("Error loading:", error); + renderRows([]); + } + }); +}); }) - function renderRows(data) { - table.clear(); - if (Array.isArray(data) && data.length) { - data.forEach((row, index) => { - // let clientrm = json_encode($client_rm) - // let account_managers = ""; - // - // clientrm.forEach(client => { - // if (client.client_id == row.id) { - // account_managers += client.account_manager + ", "; - // } - // }); - // account_managers = account_managers.replace(/,\s*$/, ""); - // if (account_managers === "") account_managers = "N/A"; + function renderRows(incomingData) { + + let actualList = []; + if (incomingData && incomingData.clientList) { + actualList = incomingData.clientList; + } else if (Array.isArray(incomingData)) { + actualList = incomingData; + } + + table.clear(); + + if (actualList.length > 0) { + actualList.forEach((row, index) => { + let rowData = [ index + 1, `${row.client_name} (${row.short_name})`, - row.account_managers, + row.account_managers || "N/A", ` @@ -428,7 +428,7 @@ $('#uploadForm').submit(function() { .data !== "") { toastr.success( 'File upload successs, Data validation is in-progress', - 'success'); + 'Success'); $('.close').click() window.location.reload(true); } else if (response.code === 404 && response.dataStatus === false) { diff --git a/app/Views/frontend_content_list.php b/app/Views/frontend_content_list.php index e2e62833..71f8e0ed 100644 --- a/app/Views/frontend_content_list.php +++ b/app/Views/frontend_content_list.php @@ -364,10 +364,10 @@ // $('#modalLabel').text('Edit Front End Content'); // appendEditData(response.data); // }else{ - // toastr.success(response.message, 'SUCCESS'); + // toastr.success(response.message, 'Success'); // } // } else { - // toastr.warning(response.message, 'WARNING'); + // toastr.warning(response.message, 'Warning'); // } // $('.loader').fadeOut(); @@ -450,17 +450,31 @@ error: function () { $('.loader, .loader-mask').fadeOut(); if (xhr.status === 400) { - let response = JSON.parse(xhr.responseText); - if (response.errors) { - $.each(response.errors, function (field, message) { - toastr.warning(message, 'Validation Error'); - }); - } else { - toastr.warning(response.message || 'Validation failed', 'Warning'); - } - }else{ - toastr.error("Something went wrong!", 'Error'); - }} + let response = JSON.parse(xhr.responseText); + let errorMessages = ""; + let seenMessages = []; // Array to store unique messages + if (response.errors) { + $.each(response.errors, function (field, message) { + if (!seenMessages.includes(message)) { + errorMessages += `• ${message}
`; + seenMessages.push(message); // Mark this message as "seen" + } + }); + toastr.error(errorMessages, 'Validation Error', { "allowHtml": true }); + } else { + toastr.warning(response.message || 'Validation failed', 'Warning'); + } + } + else if (xhr.status === 403) { + let response = JSON.parse(xhr.responseText); + toastr.error(response.message, 'Security Policy'); + } + else if (xhr.status === 500) { + toastr.error('Something went wrong . Please try again later.', 'Server Error'); + } else { + toastr.error('An unexpected error occurred. Please try again later.', 'Error'); + } + } }); } diff --git a/app/Views/hr_file_upload.php b/app/Views/hr_file_upload.php index 07b3a9fe..51f008b4 100644 --- a/app/Views/hr_file_upload.php +++ b/app/Views/hr_file_upload.php @@ -451,7 +451,7 @@ .data !== "") { toastr.success( 'File upload successs, Data validation is in-progress', - 'success'); + 'Success'); $('.close').click() window.location.reload(true); } else if (response.code === 404 && response.dataStatus === false) { diff --git a/app/Views/insurer_basic_info.php b/app/Views/insurer_basic_info.php index f553b093..fa13a529 100755 --- a/app/Views/insurer_basic_info.php +++ b/app/Views/insurer_basic_info.php @@ -264,16 +264,29 @@ input:checked + .slider:before { console.error(status, error); $('.loader').fadeOut(); $('.loader-mask').delay(350).fadeOut('slow'); - console.log('Something Wrong!', 'warning'); if (xhr.status === 400) { - let response = JSON.parse(xhr.responseText); - if (response.errors) { - $.each(response.errors, function (field, message) { - toastr.warning(message, 'Validation Error'); - }); - } else { - toastr.warning(response.message || 'Validation failed', 'Warning'); - } + let response = JSON.parse(xhr.responseText); + let errorMessages = ""; + let seenMessages = []; // Array to store unique messages + if (response.errors) { + $.each(response.errors, function (field, message) { + if (!seenMessages.includes(message)) { + errorMessages += `• ${message}
`; + seenMessages.push(message); // Mark this message as "seen" + } + }); + toastr.error(errorMessages, 'Validation Error', { "allowHtml": true }); + } else { + toastr.warning(response.message || 'Validation failed', 'Warning'); + } + + } else if (xhr.status === 403) { + let response = JSON.parse(xhr.responseText); + toastr.error(response.message, 'Security Policy'); + } else if (xhr.status === 500) { + toastr.error('Something went wrong . Please try again later.', 'Server Error'); + } else { + toastr.error('An unexpected error occurred. Please try again later.', 'Error'); } } }); diff --git a/app/Views/insurer_branch.php b/app/Views/insurer_branch.php index da147629..1923286b 100755 --- a/app/Views/insurer_branch.php +++ b/app/Views/insurer_branch.php @@ -564,7 +564,7 @@ setTimeout(function() { $('.loader').fadeOut(); $('.loader-mask').delay(350).fadeOut('slow'); - toastr.warning('Something Wrong!', 'warning'); + toastr.warning('Something Wrong!', 'Warning'); }, 1000); } }); @@ -824,10 +824,10 @@ function toggleAddButton() { // console.log(res.status == true); if(res){ if (res.status == true) { - toastr.success('Insurer branch removed successfully', 'success'); + toastr.success('Insurer branch removed successfully', 'Success'); location.reload(); } else { - toastr.warning('Failed to remove insurer branch', 'warning'); + toastr.warning('Failed to remove insurer branch', 'Warning'); } } }, @@ -836,7 +836,7 @@ function toggleAddButton() { console.error(status, error); $('.loader').fadeOut(); $('.loader-mask').delay(350).fadeOut('slow'); - toastr.warning('Failed to remove insurer branch', 'warning'); + toastr.warning('Failed to remove insurer branch', 'Warning'); } }); diff --git a/app/Views/insurer_export_templete.php b/app/Views/insurer_export_templete.php index e006d5a8..bac14afc 100755 --- a/app/Views/insurer_export_templete.php +++ b/app/Views/insurer_export_templete.php @@ -323,35 +323,31 @@ console.error('Response headers:', xhr.getAllResponseHeaders()); console.error('Response URL:', xhr.responseURL); - // Handle validation errors (CI4) - if (xhr.status === 400) { - - let response = null; - - try { - response = JSON.parse(xhr.responseText); - } catch (e) { - toastr.error('Invalid server response', 'Error'); - return; - } - - if (response.errors) { - $.each(response.errors, function (field, message) { - toastr.warning(message, 'Validation Error'); - }); - } else { - toastr.warning(response.message || 'Validation failed', 'Warning'); - } - - return; - } - - // Handle server errors - if (xhr.status >= 500) { - toastr.error('Server error. Please try again later.', 'Error'); - return; - } + if (xhr.status === 400) { + let response = JSON.parse(xhr.responseText); + let errorMessages = ""; + let seenMessages = []; // Array to store unique messages + if (response.errors) { + $.each(response.errors, function (field, message) { + if (!seenMessages.includes(message)) { + errorMessages += `• ${message}
`; + seenMessages.push(message); // Mark this message as "seen" + } + }); + toastr.error(errorMessages, 'Validation Error', { "allowHtml": true }); + } else { + toastr.warning(response.message || 'Validation failed', 'Warning'); + } + } else if (xhr.status === 403) { + let response = JSON.parse(xhr.responseText); + toastr.error(response.message, 'Security Policy'); + } else if (xhr.status === 500) { + toastr.error('Something went wrong . Please try again later.', 'Server Error'); + } else { + toastr.error('An unexpected error occurred. Please try again later.', 'Error'); + } + // Fallback toastr.error('Unexpected error occurred.', 'Error'); }, @@ -474,9 +470,9 @@ $('.loader-mask').delay(350).fadeOut('slow'); if(res.status == false){ - toastr.error(res.message, 'ERROR'); + toastr.error(res.message, 'Error'); }else{ - toastr.success(res.message, 'SUCCESS'); + toastr.success(res.message, 'Success'); } window.location.reload(true); @@ -730,9 +726,9 @@ $('.loader-mask').delay(350).fadeOut('slow'); if(res.status == false){ - toastr.error(res.message, 'ERROR'); + toastr.error(res.message, 'Error'); }else{ - toastr.success(res.message, 'SUCCESS'); + toastr.success(res.message, 'Success'); } window.location.reload(true); diff --git a/app/Views/insurer_list.php b/app/Views/insurer_list.php index 5a25fd9e..05e0dc7e 100755 --- a/app/Views/insurer_list.php +++ b/app/Views/insurer_list.php @@ -319,10 +319,10 @@ // console.log(res.status == true); if (res) { if (res.status == true) { - toastr.success('Insurer removed successfully', 'success'); + toastr.success('Insurer removed successfully', 'Success'); location.reload(); } else { - toastr.warning('Failed to remove insurer', 'warning'); + toastr.warning('Failed to remove insurer', 'Warning'); } } }, @@ -331,7 +331,7 @@ console.error(status, error); $('.loader').fadeOut(); $('.loader-mask').delay(350).fadeOut('slow'); - toastr.warning('Failed to remove insurer', 'warning'); + toastr.warning('Failed to remove insurer', 'Warning'); } }); } diff --git a/app/Views/insurer_onboarding.php b/app/Views/insurer_onboarding.php index 2889ba13..e1bd6ee6 100755 --- a/app/Views/insurer_onboarding.php +++ b/app/Views/insurer_onboarding.php @@ -75,7 +75,7 @@ if (check_insurer_id[0].value == '' || check_insurer_id[0].value == null || check_insurer_id[0].value == 0) { $('#btnBranchAdd').hide(); - toastr.warning('First Add the Insurer!', 'warning', { + toastr.warning('First Add the Insurer!', 'Warning', { timeOut: 2000 }); } else { diff --git a/app/Views/insurer_or_tpa_data.php b/app/Views/insurer_or_tpa_data.php index b0baf94d..2e9148ee 100755 --- a/app/Views/insurer_or_tpa_data.php +++ b/app/Views/insurer_or_tpa_data.php @@ -588,7 +588,7 @@ has('success')) : ?> - toastr.success('getFlashdata('success') ?>', 'success'); + toastr.success('getFlashdata('success') ?>', 'Success'); $('#import_excel_btn').hide(); @@ -632,7 +632,7 @@ $('.loader').fadeOut(); $('.loader-mask').delay(350).fadeOut('slow'); $$("#import_export_excel_form")[0].reset() - toastr.success('File Download successs', 'success'); + toastr.success('File Download successs', 'Success'); } else if (response.code === 404 && response.status === false) { @@ -1132,12 +1132,12 @@ // Only show message once and if status is false if (get_cd_balance?.cd_balance === false && !messageShown) { - // toastr.warning('Insufficient CD Balance deducated. Please wait the file will be downloaded', 'WARNING'); + // toastr.warning('Insufficient CD Balance deducated. Please wait the file will be downloaded', 'Warning'); var message1 = 'Insufficient CD Balance deducted. Please wait the file will be downloaded
' + 'CD Amount: ₹' + (cdAmount || 0) + '
' + 'Total Amount: ₹' + (excel_file_amt || 0); - toastr.warning(message1, 'WARNING', { + toastr.warning(message1, 'Warning', { allowHtml: true, timeOut: 10000, extendedTimeOut: 3000 @@ -1190,7 +1190,7 @@ toastr.warning( `Insufficient CD Balance.
Balance: ₹${cd_balance_info.cd_amount}`, - 'WARNING', + 'Warning', { allowHtml: true } ); @@ -1288,7 +1288,7 @@ for (let c of checks) { if (!c.val || c.val == 0) { - toastr.warning(c.msg, 'WARNING'); + toastr.warning(c.msg, 'Warning'); return; } } @@ -1310,15 +1310,15 @@ console.log('Data fetched successfully:', response); if (response.status == true) { - toastr.success(response.message || 'Initiating successafully', 'SUCCESS'); + toastr.success(response.message || 'Initiating successafully', 'Success'); } else { - toastr.error(response.message || 'Unable to fetch data', 'ERROR'); + toastr.error(response.message || 'Unable to fetch data', 'Error'); } }, function(xhr, status, error) { console.error('Error fetching data:', error); console.error(xhr.responseText); - toastr.error('An error occurred while checking the CD amount.', 'ERROR'); + toastr.error('An error occurred while checking the CD amount.', 'Error'); }); @@ -1441,12 +1441,12 @@ const selectedHRs = $('input[name="hr_emails[]"]:checked'); if (!mailToggle.is(':checked')) { - toastr.warning('Please Enable the mail option.', 'WARNING'); + toastr.warning('Please Enable the mail option.', 'Warning'); return; } if (selectedHRs.length === 0) { - toastr.warning('Please select at least one HR.', 'WARNING'); + toastr.warning('Please select at least one HR.', 'Warning'); return; } @@ -1489,14 +1489,14 @@ console.log('Response Success:', data); if (data.status === true) { - toastr.success(data.message, 'SUCCESS'); + toastr.success(data.message, 'Success'); } else { - toastr.warning(data.message, 'WARNING'); + toastr.warning(data.message, 'Warning'); } }, error: function (xhr, status, error) { console.error('Response Error:', error); - toastr.error('Something went wrong. Please try again.', 'ERROR'); + toastr.error('Something went wrong. Please try again.', 'Error'); }, complete: function () { // Reset button state diff --git a/app/Views/insurer_statement_list.php b/app/Views/insurer_statement_list.php index 4e4a9192..838c9fc4 100644 --- a/app/Views/insurer_statement_list.php +++ b/app/Views/insurer_statement_list.php @@ -1304,7 +1304,7 @@ .data !== "") { toastr.success( 'File upload successs', - 'success'); + 'Success'); $('.close').click(); window.location.reload(true); } else if (response.code === 404 && response.dataStatus === false) { diff --git a/app/Views/invoice_policy_mapping.php b/app/Views/invoice_policy_mapping.php index 3c357172..6d3d9fea 100644 --- a/app/Views/invoice_policy_mapping.php +++ b/app/Views/invoice_policy_mapping.php @@ -1090,7 +1090,7 @@ function downloadInvoicePdf(){ function fetchPreviewInvoiceDetails(invoice_id, invoice_no){ if (!invoice_id) { - toastr.warning("Invoice Id not found!", "WARNING"); + toastr.warning("Invoice Id not found!", "Warning"); return false; } diff --git a/app/Views/irba_report.php b/app/Views/irba_report.php index ee134535..6fd2ad16 100644 --- a/app/Views/irba_report.php +++ b/app/Views/irba_report.php @@ -159,14 +159,14 @@ $('.loader').fadeOut(); $('.loader-mask').delay(350).fadeOut('slow'); let message = response.message; - toastr.error(message, 'ERROR'); + 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'); + toastr.error('An error occurred while fetching the report page.', 'Error'); $('.loader').fadeOut(); $('.loader-mask').delay(350).fadeOut('slow'); diff --git a/app/Views/kyc_docs.php b/app/Views/kyc_docs.php index 3c6631e5..1efa8204 100755 --- a/app/Views/kyc_docs.php +++ b/app/Views/kyc_docs.php @@ -255,16 +255,27 @@ $(document).ready(function () { $('.loader').fadeOut(); $('.loader-mask').delay(350).fadeOut('slow'); if (xhr.status === 400) { - let response = JSON.parse(xhr.responseText); - if (response.errors) { - $.each(response.errors, function (field, message) { - toastr.warning(message, 'Validation Error'); - }); - } else { - toastr.warning(response.message || 'Validation failed', 'Warning'); - } + let response = JSON.parse(xhr.responseText); + let errorMessages = ""; + let seenMessages = []; // Array to store unique messages + if (response.errors) { + $.each(response.errors, function (field, message) { + if (!seenMessages.includes(message)) { + errorMessages += `• ${message}
`; + seenMessages.push(message); // Mark this message as "seen" + } + }); + toastr.error(errorMessages, 'Validation Error', { "allowHtml": true }); + } else { + toastr.warning(response.message || 'Validation failed', 'Warning'); + } + + }else if (xhr.status === 403) { + let response = JSON.parse(xhr.responseText); + toastr.error(response.message, 'Security Policy'); + } else { + toastr.error('An unexpected error occurred. Please try again later.', 'Error'); } - toastr.warning('Something Wrong!', 'warning'); }, 1000); } }); @@ -307,16 +318,27 @@ $(document).ready(function () { $('.loader').fadeOut(); $('.loader-mask').delay(350).fadeOut('slow'); if (xhr.status === 400) { - let response = JSON.parse(xhr.responseText); - if (response.errors) { - $.each(response.errors, function (field, message) { - toastr.warning(message, 'Validation Error'); - }); - } else { - toastr.warning(response.message || 'Validation failed', 'Warning'); - } - } - toastr.warning('Something Wrong!', 'warning'); + let response = JSON.parse(xhr.responseText); + let errorMessages = ""; + let seenMessages = []; // Array to store unique messages + if (response.errors) { + $.each(response.errors, function (field, message) { + if (!seenMessages.includes(message)) { + errorMessages += `• ${message}
`; + seenMessages.push(message); // Mark this message as "seen" + } + }); + toastr.error(errorMessages, 'Validation Error', { "allowHtml": true }); + } else { + toastr.warning(response.message || 'Validation failed', 'Warning'); + } + + }else if (xhr.status === 403) { + let response = JSON.parse(xhr.responseText); + toastr.error(response.message, 'Security Policy'); + } else { + toastr.error('An unexpected error occurred. Please try again later.', 'Error'); + } }, 1000); } }); @@ -427,7 +449,7 @@ $(document).ready(function () { window.location.href = '' + kyc_docs_id_for_reload; } else { - toastr.warning('Failed to remove KYC docs', 'warning'); + toastr.warning('Failed to remove KYC docs', 'Warning'); } } }, @@ -436,7 +458,7 @@ $(document).ready(function () { console.error(status, error); $('.loader').fadeOut(); $('.loader-mask').delay(350).fadeOut('slow'); - toastr.warning('Failed to remove KYC docs', 'warning'); + toastr.warning('Failed to remove KYC docs', 'Warning'); } }); } diff --git a/app/Views/kyc_entity_type_basic_info.php b/app/Views/kyc_entity_type_basic_info.php index 9998f144..88c08db9 100755 --- a/app/Views/kyc_entity_type_basic_info.php +++ b/app/Views/kyc_entity_type_basic_info.php @@ -88,7 +88,7 @@ $(document).ready(function () { setTimeout(function() { $('.loader').fadeOut(); $('.loader-mask').delay(350).fadeOut('slow'); - toastr.warning('Something Wrong!', 'warning'); + toastr.warning('Something Wrong!', 'Warning'); }, 1000); } }); diff --git a/app/Views/kyc_list.php b/app/Views/kyc_list.php index be618dd3..342e24d3 100755 --- a/app/Views/kyc_list.php +++ b/app/Views/kyc_list.php @@ -308,12 +308,12 @@ function removeKYC(element) { // console.log(res.status == true); if(res){ if (res.status == true) { - toastr.success('KYC entity removed successfully', 'success'); + toastr.success('KYC entity removed successfully', 'Success'); location.reload(); } else { - toastr.warning('Failed to remove KYC entity', 'warning'); + toastr.warning('Failed to remove KYC entity', 'Warning'); } } }, @@ -323,7 +323,7 @@ function removeKYC(element) { setTimeout(function() { $('.loader').fadeOut(); $('.loader-mask').delay(350).fadeOut('slow'); - toastr.warning('Something Wrong!', 'warning'); + toastr.warning('Something Wrong!', 'Warning'); }, 1000); } }); diff --git a/app/Views/kyc_onboarding.php b/app/Views/kyc_onboarding.php index eec84a12..6728620d 100755 --- a/app/Views/kyc_onboarding.php +++ b/app/Views/kyc_onboarding.php @@ -92,7 +92,7 @@ console.log(check_policy_type_id.val()); if (check_policy_type_id[0].value == '' || check_policy_type_id[0].value == null || check_policy_type_id[0].value == 0) { $('#btnBranchAdd').hide(); - toastr.warning('First Add the KYC Entity Type!', 'warning', { + toastr.warning('First Add the KYC Entity Type!', 'Warning', { timeOut: 2000 }); } else { diff --git a/app/Views/layout/header.php b/app/Views/layout/header.php index 73c56916..57aff2c2 100755 --- a/app/Views/layout/header.php +++ b/app/Views/layout/header.php @@ -51,7 +51,8 @@ - + + @@ -59,7 +60,8 @@ - + + @@ -1863,9 +1865,9 @@
  • Claim Dump Upload
  • -
  • + diff --git a/app/Views/lead_filter.php b/app/Views/lead_filter.php index 75cebd29..07cf83bb 100644 --- a/app/Views/lead_filter.php +++ b/app/Views/lead_filter.php @@ -213,13 +213,13 @@ $('.loader').fadeOut(); $('.loader-mask').delay(350).fadeOut('slow'); let message = response.message; - toastr.error(message, 'ERROR'); + 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 data.', 'ERROR'); + toastr.error('An error occurred while fetching the data.', 'Error'); $('.loader').fadeOut(); $('.loader-mask').delay(350).fadeOut('slow'); diff --git a/app/Views/leads_form.php b/app/Views/leads_form.php index ede380ea..ef30ba59 100644 --- a/app/Views/leads_form.php +++ b/app/Views/leads_form.php @@ -629,7 +629,7 @@ var next_reminder_date = flatpickr("#next_reminder_date", { dateFormat: "d/m/Y", allowInput: false, - maxDate: "today" + minDate: "today" }); @@ -1111,7 +1111,7 @@ }, function(xhr, status, error) { console.error('Error fetching data:', error); console.error(xhr.responseText); - toastr.error('An error occurred while fetch data.', 'ERROR'); + toastr.error('An error occurred while fetch data.', 'Error'); // Hide loader $('.loader').fadeOut(); @@ -1697,20 +1697,45 @@ }, error: function(xhr, status, error) { - console.error(xhr.responseText); - console.error(status, error); + const hostname = window.location.hostname; + if (hostname === 'localhost' || hostname === '127.0.0.1') { + // DEVELOPER MODE: Show everything in a nice group + console.group("%c Debug: Server Error ", "background: #222; color: #bada55; padding: 2px;"); + console.error("Status:", xhr.status); + console.error("Type:", error); + console.error("Full Response:", xhr.responseText); + console.groupEnd(); + } else { + // LIVE MODE: Only log a simple, non-revealing error + console.error("Server Error: Action could not be completed. Reference Code: " + xhr.responseText); + } + $('.loader').fadeOut(); $('.loader-mask').delay(350).fadeOut('slow'); if (xhr.status === 400) { - let response = JSON.parse(xhr.responseText); - if (response.errors) { - $.each(response.errors, function (field, message) { - toastr.warning(message, 'Validation Error'); - }); + let response = JSON.parse(xhr.responseText); + let errorMessages = ""; + let seenMessages = []; // Array to store unique messages + if (response.errors) { + $.each(response.errors, function (field, message) { + if (!seenMessages.includes(message)) { + errorMessages += `• ${message}
    `; + seenMessages.push(message); // Mark this message as "seen" + } + }); + toastr.error(errorMessages, 'Validation Error', { "allowHtml": true }); + } else { + toastr.warning(response.message || 'Validation failed', 'Warning'); + } + + } else if (xhr.status === 403) { + let response = JSON.parse(xhr.responseText); + toastr.error(response.message, 'Security Policy'); + } else if (xhr.status === 500) { + toastr.error('Something went wrong . Please try again later.', 'Server Error'); } else { - toastr.warning(response.message || 'Validation failed', 'Warning'); + toastr.error('An unexpected error occurred. Please try again later.', 'Error'); } - } } }); }); diff --git a/app/Views/leads_form_handler.php b/app/Views/leads_form_handler.php index 10924bf5..2773b0e2 100644 --- a/app/Views/leads_form_handler.php +++ b/app/Views/leads_form_handler.php @@ -513,7 +513,7 @@ if (isset($selected_lead_type)) { } if(client_type == ""){ - toastr.warning('Please select the client type', 'WARNING'); + toastr.warning('Please select the client type', 'Warning'); $('#client_short_name').val('') return; } @@ -528,7 +528,7 @@ if (isset($selected_lead_type)) { checkDuplicateTableFieldValue(table, field, value, function(isDuplicate) { if (isDuplicate) { - toastr.warning(message, 'WARNING'); + toastr.warning(message, 'Warning'); // $(input).val('') $('#lead_form_submit_btn').prop('disabled', true); } else{ @@ -662,7 +662,7 @@ if (isset($selected_lead_type)) { function removeFileField(index, lead_file_id = null) { if(index == 1){ - toastr.warning("You can't remove the first file field", 'WARNING'); + toastr.warning("You can't remove the first file field", 'Warning'); return false; } @@ -694,7 +694,7 @@ if (isset($selected_lead_type)) { console.log('Data fetched successfully:', response); if (response.status == true) { - toastr.success(response.message, 'SUCCESS'); + toastr.success(response.message, 'Success'); //remove the file field const field = document.getElementById(`fileField_${index}`); @@ -703,7 +703,7 @@ if (isset($selected_lead_type)) { } } else { - toastr.error(response.message, 'WARNING'); + toastr.warning(response.message, 'Warning'); } $('.loader').fadeOut(); @@ -714,7 +714,7 @@ if (isset($selected_lead_type)) { $('.loader-mask').delay(350).fadeOut('slow'); console.error('Error fetching data:', error); console.error(xhr.responseText); - toastr.error('An error occurred while checking the CD amount.', 'ERROR'); + toastr.error('An error occurred while checking the CD amount.', 'Error'); }); }else{ diff --git a/app/Views/leads_non_eb.php b/app/Views/leads_non_eb.php index ebdf741b..8f5a82f8 100644 --- a/app/Views/leads_non_eb.php +++ b/app/Views/leads_non_eb.php @@ -525,7 +525,7 @@ }, function(xhr, status, error) { console.error('Error fetching data:', error); console.error(xhr.responseText); - toastr.error('An error occurred while fetch data.', 'ERROR'); + toastr.error('An error occurred while fetch data.', 'Error'); // Hide loader $('.loader').fadeOut(); @@ -629,15 +629,29 @@ $('.loader').fadeOut(); $('.loader-mask').delay(350).fadeOut('slow'); if (xhr.status === 400) { - let response = JSON.parse(xhr.responseText); - if (response.errors) { - $.each(response.errors, function (field, message) { - toastr.warning(message, 'Validation Error'); - }); - } else { - toastr.warning(response.message || 'Validation failed', 'Warning'); - } - } + let response = JSON.parse(xhr.responseText); + let errorMessages = ""; + let seenMessages = []; // Array to store unique messages + if (response.errors) { + $.each(response.errors, function (field, message) { + if (!seenMessages.includes(message)) { + errorMessages += `• ${message}
    `; + seenMessages.push(message); // Mark this message as "seen" + } + }); + toastr.error(errorMessages, 'Validation Error', { "allowHtml": true }); + } else { + toastr.warning(response.message || 'Validation failed', 'Warning'); + } + + } else if (xhr.status === 403) { + let response = JSON.parse(xhr.responseText); + toastr.error(response.message, 'Security Policy'); + } else if (xhr.status === 500) { + toastr.error('Something went wrong . Please try again later.', 'Server Error'); + } else { + toastr.error('An unexpected error occurred. Please try again later.', 'Error'); + } } }); }); diff --git a/app/Views/newClientModal-old.php b/app/Views/newClientModal-old.php index 387578c9..1e2f3347 100644 --- a/app/Views/newClientModal-old.php +++ b/app/Views/newClientModal-old.php @@ -142,7 +142,7 @@ checkDuplicateTableFieldValue(table, field, value, function(isDuplicate) { isGSTValidating = false; if (isDuplicate) { - toastr.warning(message, 'WARNING'); + toastr.warning(message, 'Warning'); // $(input).val(''); isGSTValid = false; $('#client_add_modal_submit_btn').prop('disabled', true); diff --git a/app/Views/newClientModal.php b/app/Views/newClientModal.php index 7acdbf5a..6fcf603a 100644 --- a/app/Views/newClientModal.php +++ b/app/Views/newClientModal.php @@ -143,7 +143,7 @@ checkDuplicateTableFieldValue(table, field, value, function(isDuplicate) { isGSTValidating = false; if (isDuplicate) { - toastr.warning(message, 'WARNING'); + toastr.warning(message, 'Warning'); // $(input).val(''); isGSTValid = false; $('#client_add_modal_submit_btn').prop('disabled', true); diff --git a/app/Views/nhance_branch_list.php b/app/Views/nhance_branch_list.php index 11725ff2..7dc6f819 100644 --- a/app/Views/nhance_branch_list.php +++ b/app/Views/nhance_branch_list.php @@ -197,10 +197,10 @@ // $('#modalLabel').text('Edit Branch'); // appendEditData(response.data); // }else{ - // toastr.success(response.message, 'SUCCESS'); + // toastr.success(response.message, 'Success'); // } // } else { - // toastr.warning(response.message, 'WARNING'); + // toastr.warning(response.message, 'Warning'); // } // $('.loader').fadeOut(); @@ -279,20 +279,45 @@ $('.loader-mask').delay(350).fadeOut('slow'); }, function(xhr, status, error) { - console.error('Error fetching data:', error); - console.error(xhr.responseText); - $('.loader').fadeOut(); - $('.loader-mask').delay(350).fadeOut('slow'); - if (xhr.status === 400) { - let response = JSON.parse(xhr.responseText); - if (response.errors) { - $.each(response.errors, function (field, message) { - toastr.warning(message, 'Validation Error'); - }); - } else { - toastr.warning(response.message || 'Validation failed', 'Warning'); - } - } + $('.loader').fadeOut(); + $('.loader-mask').delay(350).fadeOut('slow'); + // Get the current domain + const hostname = window.location.hostname; + if (hostname === 'localhost' || hostname === '127.0.0.1') { + // DEVELOPER MODE: Show everything in a nice group + console.group("%c Debug: Server Error ", "background: #222; color: #bada55; padding: 2px;"); + console.error("Status:", xhr.status); + console.error("Type:", error); + console.error("Full Response:", xhr.responseText); + console.groupEnd(); + } else { + // LIVE MODE: Only log a simple, non-revealing error + console.error("Server Error: Action could not be completed. Reference Text: " + xhr.responseText); + } + if (xhr.status === 400) { + let response = JSON.parse(xhr.responseText); + let errorMessages = ""; + let seenMessages = []; // Array to store unique messages + if (response.errors) { + $.each(response.errors, function (field, message) { + if (!seenMessages.includes(message)) { + errorMessages += `• ${message}
    `; + seenMessages.push(message); // Mark this message as "seen" + } + }); + toastr.error(errorMessages, 'Validation Error', { "allowHtml": true }); + } else { + toastr.warning(response.message || 'Validation failed', 'Warning'); + } + + } else if (xhr.status === 403) { + let response = JSON.parse(xhr.responseText); + toastr.error(response.message, 'Security Policy'); + } else if (xhr.status === 500) { + toastr.error('Something went wrong . Please try again later.', 'Server Error'); + } else { + toastr.error('An unexpected error occurred. Please try again later.', 'Error'); + } }); } diff --git a/app/Views/notification old.php b/app/Views/notification old.php index 11cc74ed..c722ce12 100644 --- a/app/Views/notification old.php +++ b/app/Views/notification old.php @@ -993,7 +993,7 @@ { $('.loader').fadeOut(); $('.loader-mask').delay(350).fadeOut('slow'); - toastr.warning('Something Wrong!', 'warning'); + toastr.warning('Something Wrong!', 'Warning'); }, 1000); } }); @@ -1037,7 +1037,7 @@ { $('.loader').fadeOut(); $('.loader-mask').delay(350).fadeOut('slow'); - toastr.warning('Something Wrong!', 'warning'); + toastr.warning('Something Wrong!', 'Warning'); }, 1000); } }); @@ -1088,7 +1088,7 @@ { $('.loader').fadeOut(); $('.loader-mask').delay(350).fadeOut('slow'); - toastr.warning('Something Wrong!', 'warning'); + toastr.warning('Something Wrong!', 'Warning'); }, 1000); } }); @@ -1131,7 +1131,7 @@ { $('.loader').fadeOut(); $('.loader-mask').delay(350).fadeOut('slow'); - toastr.warning('Something Wrong!', 'warning'); + toastr.warning('Something Wrong!', 'Warning'); }, 1000); } }); @@ -1175,7 +1175,7 @@ // { // $('.loader').fadeOut(); // $('.loader-mask').delay(350).fadeOut('slow'); - // toastr.warning('Something Wrong!', 'warning'); + // toastr.warning('Something Wrong!', 'Warning'); // }, 1000); // } // }); @@ -1219,7 +1219,7 @@ { $('.loader').fadeOut(); $('.loader-mask').delay(350).fadeOut('slow'); - toastr.warning('Something Wrong!', 'warning'); + toastr.warning('Something Wrong!', 'Warning'); }, 1000); } }); @@ -1273,7 +1273,7 @@ { $('.loader').fadeOut(); $('.loader-mask').delay(350).fadeOut('slow'); - toastr.warning('Something Wrong!', 'warning'); + toastr.warning('Something Wrong!', 'Warning'); }, 1000); } }); @@ -1361,7 +1361,7 @@ template_name = ''; setTimeout(function() { $('.loader').fadeOut(); $('.loader-mask').delay(350).fadeOut('slow'); - toastr.warning('Something Wrong!', 'warning'); + toastr.warning('Something Wrong!', 'Warning'); }, 1000); } }); @@ -1433,13 +1433,13 @@ template_name = ''; console.log('Parsed respond', respond) if(respond.status == 'success'){ - toastr.success(respond.message, 'SUCCESS') + toastr.success(respond.message, 'Success') }else{ - toastr.warning(respond.message, 'WARNING') + toastr.warning(respond.message, 'Warning') } }else{ - toastr.warning('Failed to sent mail', 'WARNING') + toastr.warning('Failed to sent mail', 'Warning') } }, error: function (xhr, status, error) { @@ -1454,16 +1454,16 @@ template_name = ''; }else{ let alert_msg = 'Template ID not exist' - toastr.warning(alert_msg, 'WARNING'); + toastr.warning(alert_msg, 'Warning'); } }else{ - toastr.warning('Please enter the valid mail', 'WARNING'); + toastr.warning('Please enter the valid mail', 'Warning'); } }else{ - toastr.warning('Please enter the valid mail', 'WARNING'); + toastr.warning('Please enter the valid mail', 'Warning'); } } @@ -1600,10 +1600,10 @@ template_name = ''; $('.loader-mask').delay(350).fadeOut('slow'); if(response.status == true){ - toastr.success(response.message, 'SUCCESS'); + toastr.success(response.message, 'Success'); addHTMLInput(response.data); }else{ - toastr.error(response.message, 'ERROR'); + toastr.error(response.message, 'Error'); } }, error: function(xhr, status, error) { @@ -1620,7 +1620,7 @@ template_name = ''; console.error('Response Text: ', xhr.responseText); } - toastr.warning('Error uploading file', 'WARNING'); + toastr.warning('Error uploading file', 'Warning'); console.error('Upload error:', error); }, complete: function() { @@ -1652,10 +1652,10 @@ template_name = ''; $('.loader-mask').delay(350).fadeOut('slow'); if(res.status == true){ - toastr.success(res.message, 'SUCCESS') + toastr.success(res.message, 'Success') addHTMLInput(res.data); }else{ - toastr.warning(res.message, 'WARNING') + toastr.warning(res.message, 'Warning') } }, error: function (xhr, status, error) { @@ -1954,7 +1954,7 @@ $('#account_maneger_summary_mail_form').submit(function (event) { setTimeout(function() { $('.loader').fadeOut(); $('.loader-mask').delay(350).fadeOut('slow'); - toastr.warning('Something Went Wrong!', 'warning'); + toastr.warning('Something Went Wrong!', 'Warning'); }, 1000); } }); diff --git a/app/Views/notification.php b/app/Views/notification.php index 7948a3a4..5072ab39 100755 --- a/app/Views/notification.php +++ b/app/Views/notification.php @@ -1170,13 +1170,13 @@ console.log('Parsed respond', respond) if (respond.status == 'success') { - toastr.success(respond.message, 'SUCCESS') + toastr.success(respond.message, 'Success') } else { - toastr.warning(respond.message, 'WARNING') + toastr.warning(respond.message, 'Warning') } } else { - toastr.warning('Failed to sent mail', 'WARNING') + toastr.warning('Failed to sent mail', 'Warning') } }, error: function(xhr, status, error) { @@ -1191,16 +1191,16 @@ } else { let alert_msg = 'Template ID not exist' - toastr.warning(alert_msg, 'WARNING'); + toastr.warning(alert_msg, 'Warning'); } } else { - toastr.warning('Please enter the valid mail', 'WARNING'); + toastr.warning('Please enter the valid mail', 'Warning'); } } else { - toastr.warning('Please enter the valid mail', 'WARNING'); + toastr.warning('Please enter the valid mail', 'Warning'); } } @@ -1337,10 +1337,10 @@ $('.loader-mask').delay(350).fadeOut('slow'); if (response.status == true) { - toastr.success(response.message, 'SUCCESS'); + toastr.success(response.message, 'Success'); addHTMLInput(response.data); } else { - toastr.error(response.message, 'ERROR'); + toastr.error(response.message, 'Error'); } }, error: function(xhr, status, error) { @@ -1357,7 +1357,7 @@ console.error('Response Text: ', xhr.responseText); } - toastr.warning('Error uploading file', 'WARNING'); + toastr.warning('Error uploading file', 'Warning'); console.error('Upload error:', error); }, complete: function() { @@ -1389,10 +1389,10 @@ $('.loader-mask').delay(350).fadeOut('slow'); if (res.status == true) { - toastr.success(res.message, 'SUCCESS') + toastr.success(res.message, 'Success') addHTMLInput(res.data); } else { - toastr.warning(res.message, 'WARNING') + toastr.warning(res.message, 'Warning') } }, error: function(xhr, status, error) { @@ -1469,13 +1469,13 @@ console.log('Parsed respond', respond) if (respond.status == 'success') { - toastr.success(respond.message, 'SUCCESS') + toastr.success(respond.message, 'Success') } else { - toastr.warning(respond.message, 'WARNING') + toastr.warning(respond.message, 'Warning') } } else { - toastr.warning('Failed to sent mail', 'WARNING') + toastr.warning('Failed to sent mail', 'Warning') } }, error: function(xhr, status, error) { @@ -1490,16 +1490,16 @@ } else { let alert_msg = 'Template ID not exist , Kindly Save to Send Test Mails ..!!' - toastr.warning(alert_msg, 'WARNING'); + toastr.warning(alert_msg, 'Warning'); } } else { - toastr.warning('Please enter the valid mail', 'WARNING'); + toastr.warning('Please enter the valid mail', 'Warning'); } } else { - toastr.warning('Please enter the valid mail', 'WARNING'); + toastr.warning('Please enter the valid mail', 'Warning'); } } @@ -1552,9 +1552,9 @@ $('.loader-mask').delay(350).fadeOut('slow'); if (res.status === true) { - toastr.success(res.message, 'SUCCESS'); + toastr.success(res.message, 'Success'); } else { - toastr.warning('Failed to send mail', 'WARNING'); + toastr.warning('Failed to send mail', 'Warning'); } }, error: function(xhr, status, error) { @@ -1754,10 +1754,10 @@ $('.loader-mask').delay(350).fadeOut('slow'); if (response.status == true) { - toastr.success(response.message, 'SUCCESS'); + toastr.success(response.message, 'Success'); addHTMLInput(response.data); } else { - toastr.error(response.message, 'ERROR'); + toastr.error(response.message, 'Error'); } }, error: function(xhr, status, error) { @@ -1774,7 +1774,7 @@ console.error('Response Text: ', xhr.responseText); } - toastr.warning('Error uploading file', 'WARNING'); + toastr.warning('Error uploading file', 'Warning'); console.error('Upload error:', error); }, complete: function() { @@ -1808,10 +1808,10 @@ $('.loader-mask').delay(350).fadeOut('slow'); if (res.status == true) { - toastr.success(res.message, 'SUCCESS') + toastr.success(res.message, 'Success') addHTMLInput(res.data); } else { - toastr.warning(res.message, 'WARNING') + toastr.warning(res.message, 'Warning') } }, error: function(xhr, status, error) { @@ -2131,7 +2131,7 @@ setTimeout(function() { $('.loader').fadeOut(); $('.loader-mask').delay(350).fadeOut('slow'); - toastr.warning('Something Went Wrong!', 'warning'); + toastr.warning('Something Went Wrong!', 'Warning'); }, 1000); } }); @@ -2185,7 +2185,7 @@ setTimeout(function() { $('.loader').fadeOut(); $('.loader-mask').delay(350).fadeOut('slow'); - toastr.warning('Something Went Wrong!', 'warning'); + toastr.warning('Something Went Wrong!', 'Warning'); }, 1000); } }); @@ -2239,7 +2239,7 @@ setTimeout(function() { $('.loader').fadeOut(); $('.loader-mask').delay(350).fadeOut('slow'); - toastr.warning('Something Went Wrong!', 'warning'); + toastr.warning('Something Went Wrong!', 'Warning'); }, 1000); } }); @@ -2293,7 +2293,7 @@ setTimeout(function() { $('.loader').fadeOut(); $('.loader-mask').delay(350).fadeOut('slow'); - toastr.warning('Something Went Wrong!', 'warning'); + toastr.warning('Something Went Wrong!', 'Warning'); }, 1000); } }); @@ -2348,7 +2348,7 @@ setTimeout(function() { $('.loader').fadeOut(); $('.loader-mask').delay(350).fadeOut('slow'); - toastr.warning('Something Went Wrong!', 'warning'); + toastr.warning('Something Went Wrong!', 'Warning'); }, 1000); } }); @@ -2402,7 +2402,7 @@ setTimeout(function() { $('.loader').fadeOut(); $('.loader-mask').delay(350).fadeOut('slow'); - toastr.warning('Something Went Wrong!', 'warning'); + toastr.warning('Something Went Wrong!', 'Warning'); }, 1000); } }); @@ -2457,7 +2457,7 @@ setTimeout(function() { $('.loader').fadeOut(); $('.loader-mask').delay(350).fadeOut('slow'); - toastr.warning('Something Went Wrong!', 'warning'); + toastr.warning('Something Went Wrong!', 'Warning'); }, 1000); } }); @@ -2512,7 +2512,7 @@ setTimeout(function() { $('.loader').fadeOut(); $('.loader-mask').delay(350).fadeOut('slow'); - toastr.warning('Something Went Wrong!', 'warning'); + toastr.warning('Something Went Wrong!', 'Warning'); }, 1000); } }); @@ -2649,7 +2649,7 @@ setTimeout(function() { $('.loader').fadeOut(); $('.loader-mask').delay(350).fadeOut('slow'); - toastr.warning('Something Wrong!', 'warning'); + toastr.warning('Something Wrong!', 'Warning'); }, 1000); } }); @@ -2681,7 +2681,7 @@ let template_id = $btn.data('id'); let test_mail = "xyz@gmail.com"; if(!template_id){ - toastr.warning('Template ID not exist', 'WARNING'); + toastr.warning('Template ID not exist', 'Warning'); return; } @@ -2708,7 +2708,7 @@ $btn.data('previewing', true); } else { - toastr.warning('Failed to load content', 'WARNING'); + toastr.warning('Failed to load content', 'Warning'); } }, error: function(xhr){ diff --git a/app/Views/outstanding_report_list.php b/app/Views/outstanding_report_list.php index ac91143f..db7d0bb1 100644 --- a/app/Views/outstanding_report_list.php +++ b/app/Views/outstanding_report_list.php @@ -479,7 +479,7 @@ console.error('Response Text: ', xhr.responseText); } - toastr.warning('Error uploading file', 'WARNING'); + toastr.warning('Error uploading file', 'Werning'); console.error('Upload error:', error); }, complete: function() { diff --git a/app/Views/payout_list.php b/app/Views/payout_list.php index f9d0dff1..695e0cd9 100644 --- a/app/Views/payout_list.php +++ b/app/Views/payout_list.php @@ -381,7 +381,7 @@ function fetchUtrDetails(invoice_id, invoice_no){ if (!invoice_id) { - toastr.warning("Invoice Id not found!", "WARNING"); + toastr.warning("Invoice Id not found!", "Warning"); return false; } @@ -413,7 +413,7 @@ $('#modal_body').append(response.data); if (response.status == false) { - toastr.warning(response.message || 'Unable to fetch data', 'WARNING'); + toastr.warning(response.message || 'Unable to fetch data', 'Warning'); } $('.loader').fadeOut(); @@ -424,14 +424,14 @@ $('.loader-mask').delay(350).fadeOut('slow'); console.error('Error fetching data:', error); console.error(xhr.responseText); - toastr.error('An error occurred while fetching the data.', 'ERROR'); + toastr.error('An error occurred while fetching the data.', 'Error'); }); } function fetchPreviewInvoiceDetails(invoice_id, invoice_no){ if (!invoice_id) { - toastr.warning("Invoice Id not found!", "WARNING"); + toastr.warning("Invoice Id not found!", "Warning"); return false; } @@ -470,7 +470,7 @@ }, function(xhr, status, error) { console.error('Error fetching data:', error); console.error(xhr.responseText); - // toastr.error('An error occurred while fetching the data.', 'ERROR'); + // toastr.error('An error occurred while fetching the data.', 'Error'); $('#invoicePreview').empty(); $('#invoicePreview').append('
    No data found
    '); }); diff --git a/app/Views/payout_list_handler.php b/app/Views/payout_list_handler.php index 270ced48..8f32435b 100644 --- a/app/Views/payout_list_handler.php +++ b/app/Views/payout_list_handler.php @@ -157,7 +157,7 @@ if(!internalCall){ if (!pos_id && !status_id && !start_date && !end_date) { - toastr.warning("Please select any one filter!", "WARNING"); + toastr.warning("Please select any one filter!", "Warning"); return false; } } @@ -184,7 +184,7 @@ $('#payout_list').append(response.data); if (response.status == false) { - toastr.warning(response.message || 'Unable to fetch data', 'WARNING'); + toastr.warning(response.message || 'Unable to fetch data', 'Warning'); } $('.loader').fadeOut(); @@ -197,7 +197,7 @@ $('#payout_list').append(response.data); console.error('Error fetching data:', error); console.error(xhr.responseText); - toastr.error('An error occurred while fetching the data.', 'ERROR'); + toastr.error('An error occurred while fetching the data.', 'Error'); }); } diff --git a/app/Views/payout_utr_details.php b/app/Views/payout_utr_details.php index ee10ded8..0b77eaba 100644 --- a/app/Views/payout_utr_details.php +++ b/app/Views/payout_utr_details.php @@ -151,12 +151,12 @@ console.log('Data fetched successfully:', response); if (response.status == true) { - toastr.success(response.message, 'SUCCESS'); + toastr.success(response.message, 'Success'); $('#modal_body').empty(); $('#modal_body').append(response.data); window.location.href = ''; }else{ - toastr.warning(response.message || 'Unable to fetch data', 'WARNING'); + toastr.warning(response.message || 'Unable to fetch data', 'Warning'); } // Re-enable button @@ -170,7 +170,7 @@ $('.loader-mask').delay(350).fadeOut('slow'); console.error('Error fetching data:', error); console.error(xhr.responseText); - toastr.error('An error occurred while fetching the data.', 'ERROR'); + toastr.error('An error occurred while fetching the data.', 'Error'); }, complete: function() { $('#utr_submit_btn').prop('disabled', false).text('Add UTR'); @@ -239,9 +239,9 @@ $('#modal_body').append(response.data); if (response.status == true) { - toastr.success(response.message, 'SUCCESS'); + toastr.success(response.message, 'Success'); }else{ - toastr.warning(response.message || 'Unable to fetch data', 'WARNING'); + toastr.warning(response.message || 'Unable to fetch data', 'Warning'); } $('.loader').fadeOut(); @@ -252,7 +252,7 @@ $('.loader-mask').delay(350).fadeOut('slow'); console.error('Error fetching data:', error); console.error(xhr.responseText); - toastr.error('An error occurred while fetching the data.', 'ERROR'); + toastr.error('An error occurred while fetching the data.', 'Error'); }); utrHasBeenChanged = true; diff --git a/app/Views/policies.php b/app/Views/policies.php index 2d8fe5eb..c40ae5b0 100755 --- a/app/Views/policies.php +++ b/app/Views/policies.php @@ -266,7 +266,7 @@ $(document).ready(function () { setTimeout(function() { $('.loader').fadeOut(); $('.loader-mask').delay(350).fadeOut('slow'); - toastr.warning('Something Wrong!', 'warning'); + toastr.warning('Something Wrong!', 'Warning'); }, 1000); } }); @@ -315,7 +315,7 @@ $(document).ready(function () { setTimeout(function() { $('.loader').fadeOut(); $('.loader-mask').delay(350).fadeOut('slow'); - toastr.warning('Something Wrong!', 'warning'); + toastr.warning('Something Wrong!', 'Warning'); }, 1000); } }); @@ -385,7 +385,7 @@ $(document).ready(function () { setTimeout(function() { $('.loader').fadeOut(); $('.loader-mask').delay(350).fadeOut('slow'); - toastr.warning('Something Wrong!', 'warning'); + toastr.warning('Something Wrong!', 'Warning'); }, 1000); } }); @@ -420,13 +420,13 @@ function removePolicies(element) { // console.log(res.status == true); if(res){ if (res.status == true) { - toastr.success('Policy removed successfully', 'success'); + toastr.success('Policy removed successfully', 'Success'); // $('#branch_table').empty(); // location.reload(); window.location.href = '' + policy_id_for_reload; } else { - toastr.warning('Failed to remove policy', 'warning'); + toastr.warning('Failed to remove policy', 'Warning'); } } }, @@ -435,7 +435,7 @@ function removePolicies(element) { console.error(status, error); $('.loader').fadeOut(); $('.loader-mask').delay(350).fadeOut('slow'); - toastr.warning('Failed to remove policy', 'warning'); + toastr.warning('Failed to remove policy', 'Warning'); } }); } diff --git a/app/Views/policyRegisterModel.php b/app/Views/policyRegisterModel.php index 719633d4..1310585f 100644 --- a/app/Views/policyRegisterModel.php +++ b/app/Views/policyRegisterModel.php @@ -452,7 +452,7 @@ if (totalSI != allowedSI) { console.log("allowedSI : ", allowedSI, " totalSI : ", totalSI); - toastr.error("Sum Insured Does not Match Allowed Limit", "ERROR"); + toastr.error("Sum Insured Does not Match Allowed Limit", "Error"); return false; } // console.log("Total SI: ", totalSI); @@ -475,7 +475,7 @@ const totalRows = formDataSplitUp.filter(field => field.name === "building[]").length; if (totalRows != policyDetailsData.location_no) { - toastr.error("Please Enter All Risk Address", "ERROR"); + toastr.error("Please Enter All Risk Address", "Error"); return; } // Initialize empty objects for each row @@ -550,7 +550,7 @@ const totalRows = formData.filter(field => field.name === "pin_code[]").length; if (totalRows != policyDetailsData.location_no) { - toastr.error("Please Enter All Risk Address", "ERROR"); + toastr.error("Please Enter All Risk Address", "Error"); return; } // Initialize empty objects for each row @@ -1224,7 +1224,7 @@ } $('.loader').fadeIn(); $('.loader-mask').fadeIn(); - toastr.success("Policy Information Collected ", "SUCCESS"); + toastr.success("Policy Information Collected ", "Success"); closeModal(); changeTerrorism(Number($("#policySI").val())); $('.loader').fadeOut(); diff --git a/app/Views/policy_gmc_terms.php b/app/Views/policy_gmc_terms.php index a53b4c54..7fbabc3e 100755 --- a/app/Views/policy_gmc_terms.php +++ b/app/Views/policy_gmc_terms.php @@ -1532,7 +1532,7 @@ }); } else if (gmc_policy_type_id != 'GPA' && gmc_policy_type_id != 'GMC') { - // toastr.warning('The terms has no data ', 'warning'); + // toastr.warning('The terms has no data ', 'Warning'); } $(document).ready(function() { diff --git a/app/Views/policy_gpa_terms.php b/app/Views/policy_gpa_terms.php index e0304ae3..e7a550e8 100755 --- a/app/Views/policy_gpa_terms.php +++ b/app/Views/policy_gpa_terms.php @@ -806,7 +806,7 @@ }); } else if (gpa_policy_type_id != 'GPA' && gpa_policy_type_id != 'GMC') { - // toastr.warning("This policy has no policy terms.", 'warning'); + // toastr.warning("This policy has no policy terms.", 'Warning'); } }); diff --git a/app/Views/policy_grid.php b/app/Views/policy_grid.php index af786b4b..4c519a97 100755 --- a/app/Views/policy_grid.php +++ b/app/Views/policy_grid.php @@ -263,7 +263,7 @@ $(document).on('submit', 'form[id^="GridForm_"]', function(event) { console.log('checkFamiliFloatersKeysDuplicate', isEqual) if(isEqual){ - toastr.warning('Family floaters alerdey exist', 'warning'); + toastr.warning('Family floaters alerdey exist', 'Warning'); return false; } @@ -671,7 +671,7 @@ $(document).on('change', 'select[id^="grid_"]', function(event) setTimeout(function() { $('.loader').fadeOut(); $('.loader-mask').delay(350).fadeOut('slow'); - toastr.warning('Something Wrong!', 'warning'); + toastr.warning('Something Wrong!', 'Warning'); }, 1000); } }); @@ -2003,7 +2003,7 @@ function checkDuplicate(unique_id = null) if (siDuplicates) { // highlightDuplicates(duplicateIndices); - toastr.warning('Duplicates found!', 'warning'); + toastr.warning('Duplicates found!', 'Warning'); return true; } else { return false; @@ -2045,7 +2045,7 @@ function checkDuplicate(unique_id = null) if (siDuplicates) { // highlightDuplicates(duplicateIndices); - toastr.warning('Duplicates found!', 'warning'); + toastr.warning('Duplicates found!', 'Warning'); return true; } else { return false; @@ -2086,7 +2086,7 @@ function checkDuplicate(unique_id = null) } if (ageDuplicates) { - toastr.warning('Duplicates found!', 'warning'); + toastr.warning('Duplicates found!', 'Warning'); return true; } else { return false; @@ -2133,7 +2133,7 @@ function checkDuplicate(unique_id = null) } if (siDuplicates || ageDuplicates) { - toastr.warning('Duplicates found!', 'warning'); + toastr.warning('Duplicates found!', 'Warning'); return true; } else { return false; @@ -2173,7 +2173,7 @@ function checkDuplicate(unique_id = null) } if (ageDuplicates) { - toastr.warning('Duplicates found!', 'warning'); + toastr.warning('Duplicates found!', 'Warning'); return true; } else { return false; @@ -2219,7 +2219,7 @@ function checkDuplicate(unique_id = null) } if (siDuplicates || ageDuplicates) { - toastr.warning('Duplicates found!', 'warning'); + toastr.warning('Duplicates found!', 'Warning'); return true; } else { return false; @@ -2266,7 +2266,7 @@ function checkDuplicate(unique_id = null) } if (siDuplicates || ageDuplicates) { - toastr.warning('Duplicates found!', 'warning'); + toastr.warning('Duplicates found!', 'Warning'); return true; } else { return false; @@ -2306,7 +2306,7 @@ function checkDuplicate(unique_id = null) } if (duplicatesFound) { - toastr.warning('Duplicates found!', 'warning'); + toastr.warning('Duplicates found!', 'Warning'); return true; } else { return false; @@ -2356,7 +2356,7 @@ function checkDuplicate(unique_id = null) } if (duplicatesFound) { - toastr.warning('Duplicates found!', 'warning'); + toastr.warning('Duplicates found!', 'Warning'); return true; } else { return false; @@ -2401,7 +2401,7 @@ function checkDuplicate(unique_id = null) } if (duplicatesFound) { - toastr.warning('Duplicates found!', 'warning'); + toastr.warning('Duplicates found!', 'Warning'); return true; } else { return false; @@ -2455,7 +2455,7 @@ function checkDuplicate(unique_id = null) } if (duplicatesFound) { - toastr.warning('Duplicates found!', 'warning'); + toastr.warning('Duplicates found!', 'Warning'); return true; } else { return false; @@ -2491,7 +2491,7 @@ function checkDuplicate(unique_id = null) if (siDuplicates) { - toastr.warning('Duplicates found!', 'warning'); + toastr.warning('Duplicates found!', 'Warning'); return true; } else { return false; @@ -2532,7 +2532,7 @@ function checkDuplicate(unique_id = null) if (siDuplicates) { - toastr.warning('Duplicates found!', 'warning'); + toastr.warning('Duplicates found!', 'Warning'); return true; } else { return false; @@ -3150,7 +3150,7 @@ function checkCheckboxes() toastr.warning('You must select at least one checkbox.', 'Warning'); return false; } else if (checkedCount == uncheckedCount) { - toastr.warning('You can not select all of the checkboxes', 'Waraning'); + toastr.warning('You can not select all of the checkboxes', 'Warning'); return false; } return true; @@ -3596,7 +3596,7 @@ function removeTab(input, tabID, tabName) text: res.message, icon: "success" }); - // toastr.success('Policy removed successfully.', 'success'); + // toastr.success('Policy removed successfully.', 'Success'); } else { if(res.rr_count > 0){ Swal.fire({ @@ -3612,7 +3612,7 @@ function removeTab(input, tabID, tabName) }); } - // toastr.warning('Failed to remove policy', 'warning'); + // toastr.warning('Failed to remove policy', 'Warning'); } } }, @@ -3711,7 +3711,7 @@ function renameRackRateTab(input, unique_id = null, tabName = null) $('#rack_rate_name').val(newTabName); - // toastr.success('Policy removed successfully.', 'success'); + // toastr.success('Policy removed successfully.', 'Success'); } else { if(res.rr_count > 0){ Swal.fire({ @@ -3730,7 +3730,7 @@ function renameRackRateTab(input, unique_id = null, tabName = null) } - // toastr.warning('Failed to remove policy', 'warning'); + // toastr.warning('Failed to remove policy', 'Warning'); } } }, @@ -4028,7 +4028,7 @@ function checkValideUnits(unique_id = null) console.log('checkValideUnits function uncommonValues', uncommonValues); if (uncommonValues.length > 0) { - toastr.warning('Given unit does not exist in the branch!', 'warning'); + toastr.warning('Given unit does not exist in the branch!', 'Warning'); return true; } else { return false; @@ -4056,7 +4056,7 @@ function checkValideUnits(unique_id = null) console.log('checkValideUnits function uncommonValues', uncommonValues); if (uncommonValues.length > 0) { - toastr.warning('Given unit does not exist in the branch!', 'warning'); + toastr.warning('Given unit does not exist in the branch!', 'Warning'); return true; } else { return false; @@ -4085,7 +4085,7 @@ function checkValideUnits(unique_id = null) console.log('checkValideUnits function uncommonValues', uncommonValues); if (uncommonValues.length > 0) { - toastr.warning('Given unit does not exist in the branch!', 'warning'); + toastr.warning('Given unit does not exist in the branch!', 'Warning'); return true; } else { return false; @@ -4114,7 +4114,7 @@ function checkValideUnits(unique_id = null) console.log('checkValideUnits function uncommonValues', uncommonValues); if (uncommonValues.length > 0) { - toastr.warning('Given unit does not exist in the branch!', 'warning'); + toastr.warning('Given unit does not exist in the branch!', 'Warning'); return true; } else { return false; @@ -4144,7 +4144,7 @@ function checkValideUnits(unique_id = null) console.log('checkValideUnits function uncommonValues', uncommonValues); if (uncommonValues.length > 0) { - toastr.warning('Given unit does not exist in the branch!', 'warning'); + toastr.warning('Given unit does not exist in the branch!', 'Warning'); return true; } else { return false; @@ -4173,7 +4173,7 @@ function checkValideUnits(unique_id = null) console.log('checkValideUnits function uncommonValues', uncommonValues); if (uncommonValues.length > 0) { - toastr.warning('Given unit does not exist in the branch!', 'warning'); + toastr.warning('Given unit does not exist in the branch!', 'Warning'); return true; } else { return false; @@ -4202,7 +4202,7 @@ function checkValideUnits(unique_id = null) console.log('checkValideUnits function uncommonValues', uncommonValues); if (uncommonValues.length > 0) { - toastr.warning('Given unit does not exist in the branch!', 'warning'); + toastr.warning('Given unit does not exist in the branch!', 'Warning'); return true; } else { return false; @@ -4231,7 +4231,7 @@ function checkValideUnits(unique_id = null) console.log('checkValideUnits function uncommonValues', uncommonValues); if (uncommonValues.length > 0) { - toastr.warning('Given unit does not exist in the branch!', 'warning'); + toastr.warning('Given unit does not exist in the branch!', 'Warning'); return true; } else { return false; @@ -4260,7 +4260,7 @@ function checkValideUnits(unique_id = null) console.log('checkValideUnits function uncommonValues', uncommonValues); if (uncommonValues.length > 0) { - toastr.warning('Given unit does not exist in the branch!', 'warning'); + toastr.warning('Given unit does not exist in the branch!', 'Warning'); return true; } else { return false; @@ -4289,7 +4289,7 @@ function checkValideUnits(unique_id = null) console.log('checkValideUnits function uncommonValues', uncommonValues); if (uncommonValues.length > 0) { - toastr.warning('Given unit does not exist in the branch!', 'warning'); + toastr.warning('Given unit does not exist in the branch!', 'Warning'); return true; } else { return false; @@ -4318,7 +4318,7 @@ function checkValideUnits(unique_id = null) console.log('checkValideUnits function uncommonValues', uncommonValues); if (uncommonValues.length > 0) { - toastr.warning('Given unit does not exist in the branch!', 'warning'); + toastr.warning('Given unit does not exist in the branch!', 'Warning'); return true; } else { return false; @@ -4349,7 +4349,7 @@ function checkValideUnits(unique_id = null) console.log('checkValideUnits function uncommonValues', uncommonValues); if (uncommonValues.length > 0) { - toastr.warning('Given unit does not exist in the branch!', 'warning'); + toastr.warning('Given unit does not exist in the branch!', 'Warning'); return true; } else { return false; @@ -4377,7 +4377,7 @@ function checkValideUnits(unique_id = null) console.log('checkValideUnits function uncommonValues', uncommonValues); if (uncommonValues.length > 0) { - toastr.warning('Given unit does not exist in the branch!', 'warning'); + toastr.warning('Given unit does not exist in the branch!', 'Warning'); return true; } else { return false; diff --git a/app/Views/policy_grid_excel.php b/app/Views/policy_grid_excel.php index 10ee30b7..373cf154 100755 --- a/app/Views/policy_grid_excel.php +++ b/app/Views/policy_grid_excel.php @@ -203,7 +203,7 @@ function copyHeaders(unique_id) { //console.log('headerString', headerString); navigator.clipboard.writeText(headerString).then(function() { - toastr.success('Headers copied to clipboard', 'success'); + toastr.success('Headers copied to clipboard', 'Success'); }, function(err) { toastr.error(err, 'Could not copy headers:'); }); @@ -493,7 +493,7 @@ function generateTable(unique_id) { // console.log(secondKey) if ($('.duplicate').length > 0) { //console.log('test'); - toastr.warning("Duplicates found!", "warning"); + toastr.warning("Duplicates found!", "Warning"); $('.excel_table_class').empty(); $('.excel_textarea').val(''); } diff --git a/app/Views/policy_transaction_endorsement_form.php b/app/Views/policy_transaction_endorsement_form.php index 7f6237d2..4b4ab0ba 100644 --- a/app/Views/policy_transaction_endorsement_form.php +++ b/app/Views/policy_transaction_endorsement_form.php @@ -775,13 +775,13 @@ }else{ $('#ct_type').val(1) // addInsurerColumn() - toastr.warning("There is no policy inception data.", 'WARNING!'); + toastr.warning("There is no policy inception data.", 'Warning!'); $('#btnSubmit').prop('disabled', true).data('disable', true); } }else{ $('#ct_type').val(1) // addInsurerColumn() - toastr.warning(res.message, 'WARNING!'); + toastr.warning(res.message, 'Warning!'); $('#btnSubmit').prop('disabled', true).data('disable', true); } }, @@ -799,7 +799,7 @@ let isAnyChecked = $('input[type="checkbox"][name="co_share_type[]"]:checked').length > 1; if (isAnyChecked) { - toastr.warning('Only one leader can be selected.', 'WARNING!'); + toastr.warning('Only one leader can be selected.', 'Warning!'); $(this).prop('checked', false); } }); @@ -819,7 +819,7 @@ if(insurer == ""){ - toastr.warning('Please select the insurer.', 'WARNING!'); + toastr.warning('Please select the insurer.', 'Warning!'); $(this).prop('checked', false); }else{ if(client_id && insurer_id){ @@ -913,6 +913,29 @@ console.error(status, error); $('.loader').fadeOut(); $('.loader-mask').delay(350).fadeOut('slow'); + if (xhr.status === 400) { + let response = JSON.parse(xhr.responseText); + let errorMessages = ""; + let seenMessages = []; // Array to store unique messages + if (response.errors) { + $.each(response.errors, function (field, message) { + if (!seenMessages.includes(message)) { + errorMessages += `• ${message}
    `; + seenMessages.push(message); // Mark this message as "seen" + } + }); + toastr.error(errorMessages, 'Validation Error', { "allowHtml": true }); + } else { + toastr.warning(response.message || 'Validation failed', 'Warning'); + } + } else if (xhr.status === 403) { + let response = JSON.parse(xhr.responseText); + toastr.error(response.message, 'Security Policy'); + } else if (xhr.status === 500) { + toastr.error('Something went wrong . Please try again later.', 'Server Error'); + } else { + toastr.error('An unexpected error occurred. Please try again later.', 'Error'); + } } }); }); @@ -2067,7 +2090,7 @@ }); if (val_sum > 100) { - toastr.warning('Sum of the co-share is greater than 100', 'WARNING'); + toastr.warning('Sum of the co-share is greater than 100', 'Warning'); } } @@ -2974,7 +2997,7 @@ checkDuplicateTableFieldValue(table, field, value, function(isDuplicate) { if (isDuplicate) { - toastr.warning(message, 'WARNING'); + toastr.warning(message, 'Warning'); $(input).val('') } }); diff --git a/app/Views/policy_transaction_endorsement_form_2.php b/app/Views/policy_transaction_endorsement_form_2.php index b032e005..85564e49 100644 --- a/app/Views/policy_transaction_endorsement_form_2.php +++ b/app/Views/policy_transaction_endorsement_form_2.php @@ -649,13 +649,13 @@ }else{ $('#ct_type').val(1) // addInsurerColumn() - toastr.warning("There is no policy inception data.", 'WARNING!'); + toastr.warning("There is no policy inception data.", 'Warning!'); $('#btnSubmit').prop('disabled', true).data('disable', true); } }else{ $('#ct_type').val(1) // addInsurerColumn() - toastr.warning(res.message, 'WARNING!'); + toastr.warning(res.message, 'Warning!'); $('#btnSubmit').prop('disabled', true).data('disable', true); } }, @@ -673,7 +673,7 @@ let isAnyChecked = $('input[type="checkbox"][name="co_share_type[]"]:checked').length > 1; if (isAnyChecked) { - toastr.warning('Only one leader can be selected.', 'WARNING!'); + toastr.warning('Only one leader can be selected.', 'Warning!'); $(this).prop('checked', false); } }); @@ -693,7 +693,7 @@ if(insurer == ""){ - toastr.warning('Please select the insurer.', 'WARNING!'); + toastr.warning('Please select the insurer.', 'Warning!'); $(this).prop('checked', false); }else{ if(client_id && insurer_id){ @@ -1946,7 +1946,7 @@ }); if (val_sum > 100) { - toastr.warning('Sum of the co-share is greater than 100', 'WARNING'); + toastr.warning('Sum of the co-share is greater than 100', 'Warning'); } } @@ -2825,7 +2825,7 @@ checkDuplicateTableFieldValue(table, field, value, function(isDuplicate) { if (isDuplicate) { - toastr.warning(message, 'WARNING'); + toastr.warning(message, 'Warning'); $(input).val('') } }); diff --git a/app/Views/policy_transaction_endorsement_list.php b/app/Views/policy_transaction_endorsement_list.php index 10af48aa..0365496b 100644 --- a/app/Views/policy_transaction_endorsement_list.php +++ b/app/Views/policy_transaction_endorsement_list.php @@ -472,11 +472,11 @@ table.dataTable thead th { has('create_success')) : ?> - toastr.success('getFlashdata('create_success') ?>', 'success'); + toastr.success('getFlashdata('create_success') ?>', 'Success'); has('update_success')) : ?> - toastr.success('getFlashdata('update_success') ?>', 'success'); + toastr.success('getFlashdata('update_success') ?>', 'Success'); @@ -1024,10 +1024,10 @@ table.dataTable thead th { console.log('Data fetched successfully:', response); if (response.status === true) { - toastr.success(response.message, 'SUCCESS'); + toastr.success(response.message, 'Success'); window.location.reload(); } else { - toastr.warning(response.message, 'WARNING'); + toastr.warning(response.message, 'Warning'); } }, function(xhr, status, error) { console.error('Error fetching data:', error); diff --git a/app/Views/policy_transaction_endorsement_list_2.php b/app/Views/policy_transaction_endorsement_list_2.php index 60e37342..96ff7fa6 100644 --- a/app/Views/policy_transaction_endorsement_list_2.php +++ b/app/Views/policy_transaction_endorsement_list_2.php @@ -470,11 +470,11 @@ table.dataTable thead th { has('create_success')) : ?> - toastr.success('getFlashdata('create_success') ?>', 'success'); + toastr.success('getFlashdata('create_success') ?>', 'Success'); has('update_success')) : ?> - toastr.success('getFlashdata('update_success') ?>', 'success'); + toastr.success('getFlashdata('update_success') ?>', 'Success'); @@ -1020,10 +1020,10 @@ table.dataTable thead th { console.log('Data fetched successfully:', response); if (response.status === true) { - toastr.success(response.message, 'SUCCESS'); + toastr.success(response.message, 'Success'); window.location.reload(); } else { - toastr.warning(response.message, 'WARNING'); + toastr.warning(response.message, 'Warning'); } }, function(xhr, status, error) { console.error('Error fetching data:', error); diff --git a/app/Views/policy_transaction_inception_form.php b/app/Views/policy_transaction_inception_form.php index 6d29b5a6..7a9c9489 100644 --- a/app/Views/policy_transaction_inception_form.php +++ b/app/Views/policy_transaction_inception_form.php @@ -1797,7 +1797,7 @@ }else{ - toastr.warning('Please select the Owner type', 'WARNING'); + toastr.warning('Please select the Owner type', 'Warning'); } @@ -2065,7 +2065,7 @@ let isAnyChecked = $('input[type="checkbox"][name="co_share_type[]"]:checked').length > 1; if (isAnyChecked) { - toastr.warning('Only one leader can be selected.', 'WARNING!'); + toastr.warning('Only one leader can be selected.', 'Warning!'); $(this).prop('checked', false); return; } @@ -2084,7 +2084,7 @@ // console.log('insurer_id', insurer_id); if(insurer == ""){ - toastr.warning('Please select the insurer.', 'WARNING!'); + toastr.warning('Please select the insurer.', 'Warning!'); $(this).prop('checked', false); return; }else{ @@ -2203,7 +2203,7 @@ if (!policy_type_id || !client_id) { $(this).val('').select2(); - toastr.warning(!policy_type_id ? 'Please select the Policy Type' : 'Please select the Client', 'WARNING'); + toastr.warning(!policy_type_id ? 'Please select the Policy Type' : 'Please select the Client', 'Warning'); return false; } @@ -3244,7 +3244,7 @@ }); if (val_sum > 100) { - toastr.warning('Sum of the co-share is greater than 100', 'WARNING'); + toastr.warning('Sum of the co-share is greater than 100', 'Warning'); } // // Find the empty input(s) @@ -3779,7 +3779,7 @@ if(client_id == '' || insurer_id == ''){ - toastr.warning('Client, Insurer, or both do not exist.', 'WARNING!'); + toastr.warning('Client, Insurer, or both do not exist.', 'Warning!'); $(input).val('') return false; } @@ -3787,7 +3787,7 @@ if (isAnyLeaderChecked) { if(cop_yes){ $('#cd_ac_no_'+uniqueid).val(''); - toastr.warning('Please select the Leader.', 'WARNING!'); + toastr.warning('Please select the Leader.', 'Warning!'); return false; } } @@ -3795,7 +3795,7 @@ if(!leader){ if(cop_yes){ $('#cd_ac_no_'+uniqueid).val(''); - toastr.warning('The CD account number not for the Leader.', 'WARNING!'); + toastr.warning('The CD account number not for the Leader.', 'Warning!'); return false; } } @@ -3958,7 +3958,7 @@ } if(pt_form_sumbit_handler == 0){ - toastr.warning('Base premium greater than CD Amount', 'WARNING'); + toastr.warning('Base premium greater than CD Amount', 'Warning'); return; } @@ -4098,6 +4098,31 @@ console.error(status, error); $('.loader').fadeOut(); $('.loader-mask').delay(350).fadeOut('slow'); + setTimeout(function() { + if (xhr.status === 400) { + let response = JSON.parse(xhr.responseText); + let errorMessages = ""; + let seenMessages = []; // Array to store unique messages + if (response.errors) { + $.each(response.errors, function (field, message) { + if (!seenMessages.includes(message)) { + errorMessages += `• ${message}
    `; + seenMessages.push(message); // Mark this message as "seen" + } + }); + toastr.error(errorMessages, 'Validation Error', { "allowHtml": true }); + } else { + toastr.warning(response.message || 'Validation failed', 'Warning'); + } + } else if (xhr.status === 403) { + let response = JSON.parse(xhr.responseText); + toastr.error(response.message, 'Security Policy'); + } else if (xhr.status === 500) { + toastr.error('Something went wrong . Please try again later.', 'Server Error'); + } else { + toastr.error('An unexpected error occurred. Please try again later.', 'Error'); + } + }, 1000); } }); }); @@ -4690,7 +4715,7 @@ if (!client_id || !client_branch_id || !policy_type_id) { if(client_type == 1){ - toastr.warning('Please select the policy type, client and branch', "WARNING"); + toastr.warning('Please select the policy type, client and branch', "Warning"); $('#policy_no').val(''); return; } @@ -4710,7 +4735,7 @@ console.log('get_client_policy_data_using_policy_no response', res) if(res.status == true && res.code == 409){ - toastr.warning(res.message,'WARNING'); + toastr.warning(res.message,'Warning'); $('#policy_no').val(""); return; }else{ @@ -4719,7 +4744,7 @@ $('#policy_start_date').val(''); $('#policy_end_date').val(''); $('#tpa').val('').select2(); - console.log(res.message, 'warning'); + console.log(res.message, 'Warning'); } // if(res.status == true){ @@ -5603,7 +5628,7 @@ checkDuplicateTableFieldValue(table, field, value, function(isDuplicate) { if (isDuplicate) { - toastr.warning(message, 'WARNING'); + toastr.warning(message, 'Warning'); $(input).val('') if(table == 'vehicle'){ resetVehicleField(); @@ -5722,7 +5747,7 @@ // Validate inputs if (!base_premium || !cd_ac_no) { - toastr.warning('Base premium or CD account number is missing', 'WARNING'); + toastr.warning('Base premium or CD account number is missing', 'Warning'); return; } @@ -5743,7 +5768,7 @@ if (response.status) { if (!response.base_premium_greater_than_balance) { - console.log('Base premium is less than or equal to CD balance:', 'SUCCESS'); + console.log('Base premium is less than or equal to CD balance:', 'Success'); if(differnce_bp_amt !== 0){ $('#cd_amt_changed').prop('disabled', false).val(differnce_bp_amt); }else{ @@ -5751,13 +5776,13 @@ } $('#pt_form_sumbit_handler').val(1); } else { - toastr.warning('Base premium greater than CD Amount', 'WARNING'); + toastr.warning('Base premium greater than CD Amount', 'Warning'); $('#cd_amt_changed').prop('disabled', true).val(""); $('#pt_form_sumbit_handler').val(0); // $(input).val("0") } } else { - toastr.error(response.message || 'Unable to fetch data', 'ERROR'); + toastr.error(response.message || 'Unable to fetch data', 'Error'); } console.log('#################################### End Check CD Amount For Base Premium Response ####################################'); @@ -5765,7 +5790,7 @@ }, function(xhr, status, error) { console.error('Error fetching data:', error); console.error(xhr.responseText); - toastr.error('An error occurred while checking the CD amount.', 'ERROR'); + toastr.error('An error occurred while checking the CD amount.', 'Error'); }); }else{ @@ -5809,7 +5834,7 @@ }, function(xhr, status, error) { console.error('Error fetching data:', error); console.error(xhr.responseText); - toastr.error('An error occurred while checking the CD amount.', 'ERROR'); + toastr.error('An error occurred while checking the CD amount.', 'Error'); }); console.log('#################################### END Get CD Amount ####################################'); @@ -5966,12 +5991,12 @@ if (vhno === "" && rc === "") { - toastr.warning("Please enter any one of these: Vehicle No or Chassis No", "WARNING"); + toastr.warning("Please enter any one of these: Vehicle No or Chassis No", "Warning"); return; } if(vehicle_no_validation == 1){ - toastr.warning("Invalid Vehicle Number Format", "WARNING"); + toastr.warning("Invalid Vehicle Number Format", "Warning"); return; } @@ -6024,7 +6049,7 @@ if (response.status == true) { getClientAndBranchAndPolicy(false); - toastr.success(response.message, 'SUCCESS'); + toastr.success(response.message, 'Success'); appendClients(response.clients, response.client_id); appendVehicles(response.vehicles, response.vehicle_id); appendBranch(response.branches, response.branch_id); @@ -6041,7 +6066,7 @@ } $('#client_type').val(response.data?.client_type ?? "").trigger('change'); } else { - toastr.warning(response.message, 'WARNING'); + toastr.warning(response.message, 'Warning'); } $('#client_row_div').empty(); @@ -6057,7 +6082,7 @@ }, function(xhr, status, error) { console.error('Error fetching data:', error); console.error(xhr.responseText); - toastr.error('An error occurred while checking the CD amount.', 'ERROR'); + toastr.error('An error occurred while checking the CD amount.', 'Error'); $('.loader').fadeOut(); $('.loader-mask').delay(350).fadeOut('slow'); }); @@ -6103,11 +6128,11 @@ if (response.status == true) { getClientAndBranchAndPolicy(false); - toastr.success(response.message, 'SUCCESS'); + toastr.success(response.message, 'Success'); appendClients(response.clients, response.client_id); appendBranch(response.branches, response.branch_id); } else { - toastr.warning(response.message, 'WARNING'); + toastr.warning(response.message, 'Warning'); } $('#client_row_div').empty(); @@ -6123,7 +6148,7 @@ }, function(xhr, status, error) { console.error('Error fetching data:', error); console.error(xhr.responseText); - toastr.error('An error occurred while checking the CD amount.', 'ERROR'); + toastr.error('An error occurred while checking the CD amount.', 'Error'); $('.loader').fadeOut(); $('.loader-mask').delay(350).fadeOut('slow'); @@ -6829,7 +6854,7 @@ checkDuplicateTableFieldValue(table, field, value, function(isDuplicate) { isGSTValidating = false; if (isDuplicate) { - toastr.warning(message, 'WARNING'); + toastr.warning(message, 'Warning'); // $(input).val(''); isGSTValid = false; $('#client_form_submit_btn').prop('disabled', true); diff --git a/app/Views/policy_transaction_inception_form_2.php b/app/Views/policy_transaction_inception_form_2.php index 13c7b309..77f28d19 100644 --- a/app/Views/policy_transaction_inception_form_2.php +++ b/app/Views/policy_transaction_inception_form_2.php @@ -1440,7 +1440,7 @@ }else{ - toastr.warning('Please select the Owner type', 'WARNING'); + toastr.warning('Please select the Owner type', 'Warning'); } @@ -1669,7 +1669,7 @@ let isAnyChecked = $('input[type="checkbox"][name="co_share_type[]"]:checked').length > 1; if (isAnyChecked) { - toastr.warning('Only one leader can be selected.', 'WARNING!'); + toastr.warning('Only one leader can be selected.', 'Warning!'); $(this).prop('checked', false); return; } @@ -1683,7 +1683,7 @@ var insurer_branch_id = $('#follow_insurer_id_'+uniqueid).find('option:selected').attr('data-bid'); if(insurer == ""){ - toastr.warning('Please select the insurer.', 'WARNING!'); + toastr.warning('Please select the insurer.', 'Warning!'); $(this).prop('checked', false); return; }else{ @@ -2799,7 +2799,7 @@ if (userTouched && sum > 100) { toastr.warning( 'Sum of the co-share is greater than 100', - 'WARNING' + 'Warning' ); } } @@ -3357,7 +3357,7 @@ if(client_id == '' || insurer_id == ''){ - toastr.warning('Client, Insurer, or both do not exist.', 'WARNING!'); + toastr.warning('Client, Insurer, or both do not exist.', 'Warning!'); $(input).val('') return false; } @@ -3365,7 +3365,7 @@ if (isAnyLeaderChecked) { if(cop_yes){ $('#cd_ac_no_'+uniqueid).val(''); - toastr.warning('Please select the Leader.', 'WARNING!'); + toastr.warning('Please select the Leader.', 'Warning!'); return false; } } @@ -3373,7 +3373,7 @@ if(!leader){ if(cop_yes){ $('#cd_ac_no_'+uniqueid).val(''); - toastr.warning('The CD account number not for the Leader.', 'WARNING!'); + toastr.warning('The CD account number not for the Leader.', 'Warning!'); return false; } } @@ -3408,13 +3408,13 @@ // Missing base data if (!client_id || !insurer_id) { - toastr.warning('Client or Insurer does not exist.', 'WARNING!'); + toastr.warning('Client or Insurer does not exist.', 'Warning!'); return; } // COP enabled but no leader selected if (cop_yes && !isAnyLeaderSelected) { - toastr.warning('Please select a Leader.', 'WARNING!'); + toastr.warning('Please select a Leader.', 'Warning!'); $input.val(''); return; } @@ -3424,7 +3424,7 @@ toastr.warning( 'CD account number allowed only for Leader.', - 'WARNING!' + 'Warning!' ); // Clear current select @@ -3611,7 +3611,7 @@ } if(pt_form_sumbit_handler == 0){ - toastr.warning('Base premium greater than CD Amount', 'WARNING'); + toastr.warning('Base premium greater than CD Amount', 'Warning'); return; } @@ -4394,7 +4394,7 @@ if (!client_id || !client_branch_id || !policy_type_id) { if(client_type == 1){ - toastr.warning('Please select the policy type, client and branch', "WARNING"); + toastr.warning('Please select the policy type, client and branch', "Warning"); $('#policy_no').val(''); return; } @@ -4414,7 +4414,7 @@ console.log('get_client_policy_data_using_policy_no response', res) $('.follower_policy_no').val(policy_no);// auto fetched if(res.status == true && res.code == 409){ - toastr.warning(res.message,'WARNING'); + toastr.warning(res.message,'Warning'); $('#policy_no').val(""); $('.follower_policy_no').val(""); return; @@ -4424,7 +4424,7 @@ $('#policy_start_date').val(''); $('#policy_end_date').val(''); $('#tpa').val('').select2(); - console.log(res.message, 'warning'); + console.log(res.message, 'Warning'); } // if(res.status == true){ @@ -5290,7 +5290,7 @@ checkDuplicateTableFieldValue(table, field, value, function(isDuplicate) { if (isDuplicate) { - toastr.warning(message, 'WARNING'); + toastr.warning(message, 'Warning'); $(input).val('') if(table == 'vehicle'){ resetVehicleField(); @@ -5409,11 +5409,11 @@ // Validate inputs // if (!base_premium || !cd_ac_no) { - // toastr.warning('Base premium or CD account number is missing', 'WARNING'); + // toastr.warning('Base premium or CD account number is missing', 'Warning'); // return; // } if (!base_premium) { - toastr.warning('Base premium is missing', 'WARNING'); + toastr.warning('Base premium is missing', 'Warning'); return; } @@ -5442,13 +5442,13 @@ } $('#pt_form_sumbit_handler').val(1); } else { - toastr.warning('Base premium greater than CD Amount', 'WARNING'); + toastr.warning('Base premium greater than CD Amount', 'Warning'); $('#cd_amt_changed').prop('disabled', true).val(""); $('#pt_form_sumbit_handler').val(0); // $(input).val("0") } } else { - toastr.error(response.message || 'Unable to fetch data', 'ERROR'); + toastr.error(response.message || 'Unable to fetch data', 'Error'); } console.log('#################################### End Check CD Amount For Base Premium Response ####################################'); @@ -5456,7 +5456,7 @@ }, function(xhr, status, error) { console.error('Error fetching data:', error); console.error(xhr.responseText); - toastr.error('An error occurred while checking the CD amount.', 'ERROR'); + toastr.error('An error occurred while checking the CD amount.', 'Error'); }); }else{ @@ -5509,7 +5509,7 @@ }, function(xhr, status, error) { console.error('Error fetching data:', error); console.error(xhr.responseText); - toastr.error('An error occurred while checking the CD amount.', 'ERROR'); + toastr.error('An error occurred while checking the CD amount.', 'Error'); }); console.log('#################################### END Get CD Amount ####################################'); @@ -5665,12 +5665,12 @@ if (vhno === "" && rc === "") { - toastr.warning("Please enter any one of these: Vehicle No or Chassis No", "WARNING"); + toastr.warning("Please enter any one of these: Vehicle No or Chassis No", "Warning"); return; } if(vehicle_no_validation == 1){ - toastr.warning("Invalid Vehicle Number Format", "WARNING"); + toastr.warning("Invalid Vehicle Number Format", "Warning"); return; } @@ -5723,7 +5723,7 @@ if (response.status == true) { getClientAndBranchAndPolicy(false); - toastr.success(response.message, 'SUCCESS'); + toastr.success(response.message, 'Success'); appendClients(response.clients, response.client_id); appendVehicles(response.vehicles, response.vehicle_id); appendBranch(response.branches, response.branch_id); @@ -5740,7 +5740,7 @@ } $('#client_type').val(response.data?.client_type ?? "").trigger('change'); } else { - toastr.warning(response.message, 'WARNING'); + toastr.warning(response.message, 'Warning'); } $('#client_row_div').empty(); @@ -5756,7 +5756,7 @@ }, function(xhr, status, error) { console.error('Error fetching data:', error); console.error(xhr.responseText); - toastr.error('An error occurred while checking the CD amount.', 'ERROR'); + toastr.error('An error occurred while checking the CD amount.', 'Error'); $('.loader').fadeOut(); $('.loader-mask').delay(350).fadeOut('slow'); }); @@ -5802,11 +5802,11 @@ if (response.status == true) { getClientAndBranchAndPolicy(false); - toastr.success(response.message, 'SUCCESS'); + toastr.success(response.message, 'Success'); appendClients(response.clients, response.client_id); appendBranch(response.branches, response.branch_id); } else { - toastr.warning(response.message, 'WARNING'); + toastr.warning(response.message, 'Warning'); } $('#client_row_div').empty(); @@ -5822,7 +5822,7 @@ }, function(xhr, status, error) { console.error('Error fetching data:', error); console.error(xhr.responseText); - toastr.error('An error occurred while checking the CD amount.', 'ERROR'); + toastr.error('An error occurred while checking the CD amount.', 'Error'); $('.loader').fadeOut(); $('.loader-mask').delay(350).fadeOut('slow'); @@ -6615,7 +6615,7 @@ checkDuplicateTableFieldValue(table, field, value, function(isDuplicate) { isGSTValidating = false; if (isDuplicate) { - toastr.warning(message, 'WARNING'); + toastr.warning(message, 'Warning'); // $(input).val(''); isGSTValid = false; $('#client_form_submit_btn').prop('disabled', true); diff --git a/app/Views/policy_transaction_inception_list.php b/app/Views/policy_transaction_inception_list.php index cc850c55..56dec406 100644 --- a/app/Views/policy_transaction_inception_list.php +++ b/app/Views/policy_transaction_inception_list.php @@ -539,11 +539,11 @@ $(document).ready(function(){ has('create_success')) : ?> - toastr.success('getFlashdata('create_success') ?>', 'success'); + toastr.success('getFlashdata('create_success') ?>', 'Success'); has('update_success')) : ?> - toastr.success('getFlashdata('update_success') ?>', 'success'); + toastr.success('getFlashdata('update_success') ?>', 'Success'); @@ -1317,7 +1317,7 @@ $(document).ready(function(){ // myModal.show(); // }else{ // $('#client_id').val('').change(); - // toastr.warning('Please select the client type', 'WARNING') + // toastr.warning('Please select the client type', 'Warning') // } appendClientForm(); @@ -1494,7 +1494,7 @@ $('#cd_ac_no_data').change(function(){ console.log('CD Account Number Responcce', res) if(res.status == true){ - toastr.warning(res.message, 'warning'); + toastr.warning(res.message, 'Warning'); $('#cd_ac_no_data').val(''); } }, @@ -1809,10 +1809,10 @@ function removePolicyTransaction(input, pt_id, policy_type_id) { console.log('Data fetched successfully:', response); if (response.status === true) { - toastr.success(response.message, 'SUCCESS'); + toastr.success(response.message, 'Success'); window.location.reload(); } else { - toastr.warning(response.message, 'WARNING'); + toastr.warning(response.message, 'Warning'); } }, function(xhr, status, error) { console.error('Error fetching data:', error); diff --git a/app/Views/policy_transaction_inception_list_2.php b/app/Views/policy_transaction_inception_list_2.php index c7172902..9a47ffa9 100644 --- a/app/Views/policy_transaction_inception_list_2.php +++ b/app/Views/policy_transaction_inception_list_2.php @@ -536,11 +536,11 @@ $(document).ready(function(){ has('create_success')) : ?> - toastr.success('getFlashdata('create_success') ?>', 'success'); + toastr.success('getFlashdata('create_success') ?>', 'Success'); has('update_success')) : ?> - toastr.success('getFlashdata('update_success') ?>', 'success'); + toastr.success('getFlashdata('update_success') ?>', 'Success'); @@ -1293,7 +1293,7 @@ $(document).ready(function(){ // myModal.show(); // }else{ // $('#client_id').val('').change(); - // toastr.warning('Please select the client type', 'WARNING') + // toastr.warning('Please select the client type', 'Warning') // } appendClientForm(); @@ -1470,7 +1470,7 @@ $('#cd_ac_no_data').change(function(){ console.log('CD Account Number Responcce', res) if(res.status == true){ - toastr.warning(res.message, 'warning'); + toastr.warning(res.message, 'Warning'); $('#cd_ac_no_data').val(''); } }, @@ -1760,10 +1760,10 @@ function removePolicyTransaction(input, pt_id, policy_type_id) { console.log('Data fetched successfully:', response); if (response.status === true) { - toastr.success(response.message, 'SUCCESS'); + toastr.success(response.message, 'Success'); window.location.reload(); } else { - toastr.warning(response.message, 'WARNING'); + toastr.warning(response.message, 'Warning'); } }, function(xhr, status, error) { console.error('Error fetching data:', error); diff --git a/app/Views/policy_type_basic_info.php b/app/Views/policy_type_basic_info.php index 1bfb3fe3..2f9d6e6a 100755 --- a/app/Views/policy_type_basic_info.php +++ b/app/Views/policy_type_basic_info.php @@ -141,7 +141,7 @@ $(document).ready(function () { setTimeout(function() { $('.loader').fadeOut(); $('.loader-mask').delay(350).fadeOut('slow'); - toastr.warning('Something Wrong!', 'warning'); + toastr.warning('Something Wrong!', 'Warning'); }, 1000); } }); diff --git a/app/Views/policy_type_list.php b/app/Views/policy_type_list.php index bc9ac772..c9a89897 100755 --- a/app/Views/policy_type_list.php +++ b/app/Views/policy_type_list.php @@ -357,10 +357,10 @@ // console.log(res.status == true); if (res) { if (res.status == true) { - toastr.success('Policy type removed successfully', 'success'); + toastr.success('Policy type removed successfully', 'Success'); location.reload(); } else { - toastr.warning('Failed to remove policy type', 'warning'); + toastr.warning('Failed to remove policy type', 'Warning'); } } }, @@ -369,7 +369,7 @@ console.error(status, error); $('.loader').fadeOut(); $('.loader-mask').delay(350).fadeOut('slow'); - toastr.warning('Failed to remove policy type', 'warning'); + toastr.warning('Failed to remove policy type', 'Warning'); } }); } diff --git a/app/Views/policy_type_onboarding.php b/app/Views/policy_type_onboarding.php index 392e0cfe..a972675d 100755 --- a/app/Views/policy_type_onboarding.php +++ b/app/Views/policy_type_onboarding.php @@ -92,7 +92,7 @@ if (check_policy_type_id[0].value == '' || check_policy_type_id[0].value == null || check_policy_type_id[0].value == 0) { $('#btnBranchAdd').hide(); - toastr.warning('First Add the Policy Type!', 'warning', { + toastr.warning('First Add the Policy Type!', 'Warning', { timeOut: 2000 }); } else { diff --git a/app/Views/pos_list.php b/app/Views/pos_list.php index d94e45c2..500fbdfa 100644 --- a/app/Views/pos_list.php +++ b/app/Views/pos_list.php @@ -361,18 +361,34 @@ } $('.loader, .loader-mask').fadeOut(); }, - error: function () { + error: function (xhr) { $('.loader, .loader-mask').fadeOut(); - if (xhr.status === 400) { - let response = JSON.parse(xhr.responseText); - if (response.errors) { - $.each(response.errors, function (field, message) { - toastr.warning(message, 'Validation Error'); - }); - } else { - toastr.warning(response.message || 'Validation failed', 'Warning'); - } - } + if (xhr.status === 400) { + let response = JSON.parse(xhr.responseText); + let errorMessages = ""; + let seenMessages = []; // Array to store unique messages + if (response.errors) { + $.each(response.errors, function (field, message) { + if (!seenMessages.includes(message)) { + errorMessages += `• ${message}
    `; + seenMessages.push(message); // Mark this message as "seen" + } + }); + toastr.error(errorMessages, 'Validation Error', { "allowHtml": true }); + } else { + toastr.warning(response.message || 'Validation failed', 'Warning'); + } + + } else if (xhr.status === 403) { + let response = JSON.parse(xhr.responseText); + toastr.error(response.message, 'Security Policy'); + } else if (xhr.status === 500) { + toastr.error('Something went wrong . Please try again later.', 'Server Error'); + } else { + toastr.error('An unexpected error occurred. Please try again later.', 'Error'); + } + console.error('Unexpected error:', xhr.responseText); + } }); } diff --git a/app/Views/renewal_search.php b/app/Views/renewal_search.php index f6b8c348..abc5cdfc 100644 --- a/app/Views/renewal_search.php +++ b/app/Views/renewal_search.php @@ -161,14 +161,14 @@ $('.loader').fadeOut(); $('.loader-mask').delay(350).fadeOut('slow'); let message = response.message; - toastr.error(message, 'ERROR'); + 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'); + toastr.error('An error occurred while fetching the report page.', 'Error'); $('.loader').fadeOut(); $('.loader-mask').delay(350).fadeOut('slow'); diff --git a/app/Views/report_bds.php b/app/Views/report_bds.php index 7fd21f82..934b7fad 100644 --- a/app/Views/report_bds.php +++ b/app/Views/report_bds.php @@ -734,7 +734,7 @@ function getCoShareStatementDetails(pt_id){ appendTableData(response.data) } else { - toastr.warning(response.message, 'WARNING'); + toastr.warning(response.message, 'Warning'); } }, function(xhr, status, error) { console.error('Error fetching data:', error); diff --git a/app/Views/report_bds_filter.php b/app/Views/report_bds_filter.php index d55ab379..8dcb4da6 100644 --- a/app/Views/report_bds_filter.php +++ b/app/Views/report_bds_filter.php @@ -569,7 +569,7 @@ appendPolicies(response.data) } else { - toastr.warning(response.message, 'WARNING'); + toastr.warning(response.message, 'Warning'); } }, function(xhr, status, error) { console.error('Error fetching data:', error); diff --git a/app/Views/report_bds_new.php b/app/Views/report_bds_new.php index 1bb808aa..0dfb45ae 100644 --- a/app/Views/report_bds_new.php +++ b/app/Views/report_bds_new.php @@ -615,7 +615,7 @@ appendTableData(response.data) } else { - toastr.warning(response.message, 'WARNING'); + toastr.warning(response.message, 'Warning'); } }, function(xhr, status, error) { console.error('Error fetching data:', error); diff --git a/app/Views/retail_endorsement_list.php b/app/Views/retail_endorsement_list.php index 97a163a3..67ad9fce 100755 --- a/app/Views/retail_endorsement_list.php +++ b/app/Views/retail_endorsement_list.php @@ -273,6 +273,15 @@ }); + $(document).on('click', '.emp_data_model', function() { + + var id = $(this).attr('data-id'); + var eno = $(this).attr('data-eno'); + var status = $(this).attr('data-status'); + + fetchRetailEndorsementData(id, eno, status); + }); + function submitRetailEndorsement(e) { e.preventDefault(); // stop normal form submit var form = document.getElementById("retailEndorsementForm"); @@ -310,18 +319,31 @@ } }, error: function(xhr) { - toastr.error("Something went wrong!", 'Error'); console.error(xhr.responseText); if (xhr.status === 400) { - let response = JSON.parse(xhr.responseText); - if (response.errors) { - $.each(response.errors, function (field, message) { - toastr.warning(message, 'Validation Error'); - }); - } else { - toastr.warning(response.message || 'Validation failed', 'Warning'); - } - } + let response = JSON.parse(xhr.responseText); + let errorMessages = ""; + let seenMessages = []; // Array to store unique messages + if (response.errors) { + $.each(response.errors, function (field, message) { + if (!seenMessages.includes(message)) { + errorMessages += `• ${message}
    `; + seenMessages.push(message); // Mark this message as "seen" + } + }); + toastr.error(errorMessages, 'Validation Error', { "allowHtml": true }); + } else { + toastr.warning(response.message || 'Validation failed', 'Warning'); + } + + } else if (xhr.status === 403) { + let response = JSON.parse(xhr.responseText); + toastr.error(response.message, 'Security Policy'); + } else if (xhr.status === 500) { + toastr.error('Something went wrong . Please try again later.', 'Server Error'); + } else { + toastr.error('An unexpected error occurred. Please try again later.', 'Error'); + } }, complete: function() { btn.disabled = false; diff --git a/app/Views/rto_master_list.php b/app/Views/rto_master_list.php index 3c8c912a..b872d8be 100644 --- a/app/Views/rto_master_list.php +++ b/app/Views/rto_master_list.php @@ -244,15 +244,29 @@ $('.loader').fadeOut(); $('.loader-mask').delay(350).fadeOut('slow'); if (xhr.status === 400) { - let response = JSON.parse(xhr.responseText); - if (response.errors) { - $.each(response.errors, function (field, message) { - toastr.warning(message, 'Validation Error'); - }); - } else { - toastr.warning(response.message || 'Validation failed', 'Warning'); - } - } + let response = JSON.parse(xhr.responseText); + let errorMessages = ""; + let seenMessages = []; // Array to store unique messages + if (response.errors) { + $.each(response.errors, function (field, message) { + if (!seenMessages.includes(message)) { + errorMessages += `• ${message}
    `; + seenMessages.push(message); // Mark this message as "seen" + } + }); + toastr.error(errorMessages, 'Validation Error', { "allowHtml": true }); + } else { + toastr.warning(response.message || 'Validation failed', 'Warning'); + } + + } else if (xhr.status === 403) { + let response = JSON.parse(xhr.responseText); + toastr.error(response.message, 'Security Policy'); + } else if (xhr.status === 500) { + toastr.error('Something went wrong . Please try again later.', 'Server Error'); + } else { + toastr.error('An unexpected error occurred. Please try again later.', 'Error'); + } }); } diff --git a/app/Views/test_members_list.php b/app/Views/test_members_list.php index 93fbe9d7..5dc58646 100644 --- a/app/Views/test_members_list.php +++ b/app/Views/test_members_list.php @@ -637,7 +637,7 @@ document.addEventListener("DOMContentLoaded", function () { $('#email_corporate').val(''); $('#mobile').val(''); - toastr.warning(res.message, 'WARNING'); + toastr.warning(res.message, 'Warning'); } }, error: function (xhr, status, error) { @@ -684,7 +684,7 @@ document.addEventListener("DOMContentLoaded", function () { $('.loader-mask').delay(350).fadeOut('slow'); if(response.status == true){ - toastr.success(response.message, 'SUCCESS'); + toastr.success(response.message, 'Success'); $('.close').click(); @@ -699,7 +699,7 @@ document.addEventListener("DOMContentLoaded", function () { window.location.reload(); }else{ - toastr.error(response.message, 'ERROR'); + toastr.error(response.message, 'Error'); } }, error: function(xhr, status, error) { @@ -717,17 +717,23 @@ document.addEventListener("DOMContentLoaded", function () { } if (xhr.status === 400) { - let response = JSON.parse(xhr.responseText); - if (response.errors) { - $.each(response.errors, function (field, message) { - toastr.warning(message, 'Validation Error'); - }); - } else { - toastr.warning(response.message || 'Validation failed', 'Warning'); - } - }else{ toastr.warning('Error uploading file', 'WARNING'); } + let response = JSON.parse(xhr.responseText); + let errorMessages = ""; + let seenMessages = []; // Array to store unique messages + if (response.errors) { + $.each(response.errors, function (field, message) { + if (!seenMessages.includes(message)) { + errorMessages += `• ${message}
    `; + seenMessages.push(message); // Mark this message as "seen" + } + }); + toastr.error(errorMessages, 'Validation Error', { "allowHtml": true }); + } else { + toastr.warning(response.message || 'Validation failed', 'Warning'); + } + }else{ toastr.warning('Error uploading file', 'Warning'); } - // toastr.warning('Error uploading file', 'WARNING'); + // toastr.warning('Error uploading file', 'Warning'); // console.error('Upload error:', error); }, complete: function() { @@ -768,9 +774,9 @@ document.addEventListener("DOMContentLoaded", function () { // $('.loader-mask').delay(350).fadeOut('slow'); // if(res.status == true){ - // toastr.success(res.message, 'SUCCESS'); + // toastr.success(res.message, 'Success'); // }else{ - // toastr.error(res.message, 'ERROR'); + // toastr.error(res.message, 'Error'); // } // }, // error: function (xhr, status, error) { @@ -793,7 +799,7 @@ document.addEventListener("DOMContentLoaded", function () { }) if(selected.length == 0){ - toastr.warning('Please select atleast one employee', 'WARNING'); + toastr.warning('Please select atleast one employee', 'Warning'); return; } $('#employee_ids').val(selected); @@ -1072,12 +1078,12 @@ for (let i = 0; i < selected_count.length; i++) { if (response.code === 200) { console.log(`Iteration ${i}: Success - ${response.message}`); } else { - toastr.error(response.message, 'ERROR'); + toastr.error(response.message, 'Error'); } }, error: function(xhr, status, error) { console.error('AJAX Error:', error); - toastr.error('An error occurred. Please try again.', 'ERROR'); + toastr.error('An error occurred. Please try again.', 'Error'); }, complete: function() { // Increment the completed requests counter @@ -1085,7 +1091,7 @@ for (let i = 0; i < selected_count.length; i++) { // Check if all AJAX requests have completed if (completedRequests === selected_count.length) { - toastr.success('All employees have been successfully mapped.', 'SUCCESS'); + toastr.success('All employees have been successfully mapped.', 'Success'); $('#map_emp_modal').modal('hide'); window.location.reload(); } @@ -1102,7 +1108,7 @@ function unmapEmployees(){ }) if(selected.length == 0){ - toastr.warning('Please select atleast one employee', 'WARNING'); + toastr.warning('Please select atleast one employee', 'Warning'); return; } @@ -1147,10 +1153,10 @@ function unmapEmployees(){ $('.loader-mask').delay(350).fadeOut('slow'); if (res.status === true) { - toastr.success(res.message, 'SUCCESS'); + toastr.success(res.message, 'Success'); window.location.reload(); } else { - toastr.error(res.message, 'ERROR'); + toastr.error(res.message, 'Error'); } }, error: function (xhr, status, error) { diff --git a/app/Views/thz_list.php b/app/Views/thz_list.php index 84d8f4cf..d055fe91 100644 --- a/app/Views/thz_list.php +++ b/app/Views/thz_list.php @@ -162,9 +162,10 @@ beccause = dataTables_length and dataTables_paginate need in same line thats why
    -
    @@ -192,7 +193,6 @@ beccause = dataTables_length and dataTables_paginate need in same line thats why @@ -438,25 +438,25 @@ beccause = dataTables_length and dataTables_paginate need in same line thats why // Validation checks if (message.length === 0) { - toastr.error('Message cannot be empty', 'Warning'); + toastr.warning('Message cannot be empty', 'Warning'); form.classList.add('was-validated'); return; } if (message.length > 1500) { - toastr.error('Message cannot exceed 1500 characters', 'Warning'); + toastr.warning('Message cannot exceed 1500 characters', 'Warning'); form.classList.add('was-validated'); return; } if (subject.length === 0) { - toastr.error('Subject cannot be empty', 'Warning'); + toastr.warning('Subject cannot be empty', 'Warning'); form.classList.add('was-validated'); return; } if (subject.length > 150) { - toastr.error('Subject cannot exceed 150 characters', 'Warning'); + toastr.warning('Subject cannot exceed 150 characters', 'Warning'); form.classList.add('was-validated'); return; } @@ -506,18 +506,31 @@ beccause = dataTables_length and dataTables_paginate need in same line thats why } }, error: function(xhr) { - if (xhr.status === 400) { - let response = JSON.parse(xhr.responseText); - if (response.errors) { - $.each(response.errors, function (field, message) { - toastr.warning(message, 'Validation Error'); - }); - } else { - toastr.warning(response.message || 'Validation failed', 'Warning'); - } - }else{ - toastr.error("Something went wrong!", 'Error');} console.error(xhr.responseText); + if (xhr.status === 400) { + let response = JSON.parse(xhr.responseText); + let errorMessages = ""; + let seenMessages = []; // Array to store unique messages + if (response.errors) { + $.each(response.errors, function (field, message) { + if (!seenMessages.includes(message)) { + errorMessages += `• ${message}
    `; + seenMessages.push(message); // Mark this message as "seen" + } + }); + toastr.error(errorMessages, 'Validation Error', { "allowHtml": true }); + } else { + toastr.warning(response.message || 'Validation failed', 'Warning'); + } + + }else if (xhr.status === 403) { + let response = JSON.parse(xhr.responseText); + toastr.error(response.message, 'Security Policy'); + } else if (xhr.status === 500) { + toastr.error('Something went wrong . Please try again later.', 'Server Error'); + } else { + toastr.error('An unexpected error occurred. Please try again later.', 'Error'); + } }, complete: function() { btn.disabled = false; @@ -706,7 +719,7 @@ $(document).ready(function() { subjectCounter.textContent = `${subjectLength}/150`; if (subjectLength > 150) { - toastr.error('Subject cannot exceed 150 characters', 'Warning'); + toastr.warning('Subject cannot exceed 150 characters', 'Warning'); subjectInput.classList.add('is-invalid'); } else { subjectInput.classList.remove('is-invalid'); @@ -722,7 +735,7 @@ $(document).ready(function() { messageCounter.textContent = `${messageLength}/1500`; if (messageLength > 1500) { - toastr.error('Message cannot exceed 1500 characters', 'Warning'); + toastr.warning('Message cannot exceed 1500 characters', 'Warning'); messageInput.classList.add('is-invalid'); } else { messageInput.classList.remove('is-invalid'); diff --git a/app/Views/thz_notes.php b/app/Views/thz_notes.php index 91c916b8..194ed82d 100644 --- a/app/Views/thz_notes.php +++ b/app/Views/thz_notes.php @@ -491,7 +491,7 @@ data-backdrop="static" messageCounter.textContent = `${messageLength}/1500`; if (messageLength > 1500) { - toastr.error('Message cannot exceed 1500 characters', 'Warning'); + toastr.warning('Message cannot exceed 1500 characters', 'Warning'); messageInput.classList.add('is-invalid'); } else { messageInput.classList.remove('is-invalid'); @@ -571,17 +571,31 @@ data-backdrop="static" } }, error: function(xhr) { - if (xhr.status === 400) { - let response = JSON.parse(xhr.responseText); - if (response.errors) { - $.each(response.errors, function (field, message) { - toastr.warning(message, 'Validation Error'); - }); - } else { - toastr.warning(response.message || 'Validation failed', 'Warning'); - } - }else{ toastr.error("Something went wrong!", 'Error'); } console.error(xhr.responseText); + if (xhr.status === 400) { + let response = JSON.parse(xhr.responseText); + let errorMessages = ""; + let seenMessages = []; // Array to store unique messages + if (response.errors) { + $.each(response.errors, function (field, message) { + if (!seenMessages.includes(message)) { + errorMessages += `• ${message}
    `; + seenMessages.push(message); // Mark this message as "seen" + } + }); + toastr.error(errorMessages, 'Validation Error', { "allowHtml": true }); + } else { + toastr.warning(response.message || 'Validation failed', 'Warning'); + } + + } else if (xhr.status === 403) { + let response = JSON.parse(xhr.responseText); + toastr.error(response.message, 'Security Policy'); + } else if (xhr.status === 500) { + toastr.error('Something went wrong . Please try again later.', 'Server Error'); + } else { + toastr.error('An unexpected error occurred. Please try again later.', 'Error'); + } }, complete: function() { btn.disabled = false; @@ -628,19 +642,31 @@ data-backdrop="static" } }, error: function(xhr) { - if (xhr.status === 400) { - let response = JSON.parse(xhr.responseText); - if (response.errors) { - $.each(response.errors, function (field, message) { - toastr.warning(message, 'Validation Error'); - }); - } else { - toastr.warning(response.message || 'Validation failed', 'Warning'); - } - }else{ - toastr.error("Something went wrong!", 'Error'); console.error(xhr.responseText); - } + if (xhr.status === 400) { + let response = JSON.parse(xhr.responseText); + let errorMessages = ""; + let seenMessages = []; // Array to store unique messages + if (response.errors) { + $.each(response.errors, function (field, message) { + if (!seenMessages.includes(message)) { + errorMessages += `• ${message}
    `; + seenMessages.push(message); // Mark this message as "seen" + } + }); + toastr.error(errorMessages, 'Validation Error', { "allowHtml": true }); + } else { + toastr.warning(response.message || 'Validation failed', 'Warning'); + } + + }else if (xhr.status === 403) { + let response = JSON.parse(xhr.responseText); + toastr.error(response.message, 'Security Policy'); + } else if (xhr.status === 500) { + toastr.error('Something went wrong . Please try again later.', 'Server Error'); + } else { + toastr.error('An unexpected error occurred. Please try again later.', 'Error'); + } }, complete: function() { btn.disabled = false;} }); diff --git a/app/Views/ticket_auto_query.php b/app/Views/ticket_auto_query.php index 7c493e8c..a6651e8d 100644 --- a/app/Views/ticket_auto_query.php +++ b/app/Views/ticket_auto_query.php @@ -176,7 +176,7 @@ $('.loader').fadeOut(); $('.loader-mask').delay(350).fadeOut('slow'); let message = response.message; - toastr.error(message, 'ERROR'); + toastr.error(message, 'Error'); } window.location.reload(); @@ -184,7 +184,7 @@ }, 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'); + toastr.error('An error occurred while fetching the report page.', 'Error'); $('.loader').fadeOut(); $('.loader-mask').delay(350).fadeOut('slow'); diff --git a/app/Views/ticket_edit_onbording.php b/app/Views/ticket_edit_onbording.php index b21b1345..45eabbc3 100644 --- a/app/Views/ticket_edit_onbording.php +++ b/app/Views/ticket_edit_onbording.php @@ -222,7 +222,7 @@ var isValid = $('#ticket_form_data').parsley().validate(); if (!isValid) { - toastr.warning('Form validation failed. Please check the required fields.', 'WARNING'); + toastr.warning('Form validation failed. Please check the required fields.', 'Warning'); return false; } @@ -250,9 +250,9 @@ if (response.status === true) { location.reload(); - toastr.success(response.message, 'SUCCESS'); + toastr.success(response.message, 'Success'); } else { - toastr.error(response.message, 'ERROR'); + toastr.error(response.message, 'Error'); } $('.loader').fadeOut(); $('.loader-mask').delay(350).fadeOut('slow'); @@ -264,6 +264,30 @@ // Hide loader $('.loader').fadeOut(); $('.loader-mask').delay(350).fadeOut('slow'); + if (xhr.status === 400) { + let response = JSON.parse(xhr.responseText); + let errorMessages = ""; + let seenMessages = []; // Array to store unique messages + if (response.errors) { + $.each(response.errors, function (field, message) { + if (!seenMessages.includes(message)) { + errorMessages += `• ${message}
    `; + seenMessages.push(message); // Mark this message as "seen" + } + }); + toastr.error(errorMessages, 'Validation Error', { "allowHtml": true }); + } else { + toastr.warning(response.message || 'Validation failed', 'Warning'); + } + + } else if (xhr.status === 403) { + let response = JSON.parse(xhr.responseText); + toastr.error(response.message, 'Security Policy'); + } else if (xhr.status === 500) { + toastr.error('Something went wrong . Please try again later.', 'Server Error'); + } else { + toastr.error('An unexpected error occurred. Please try again later.', 'Error'); + } } }); } @@ -378,16 +402,16 @@ console.log('Data fetched successfully:', response); if (response.status) { - toastr.success(response.message || 'Status updated successfully', 'SUCCESS'); + toastr.success(response.message || 'Status updated successfully', 'Success'); window.location.reload(true); } else { - toastr.warning(response.message || 'Failed to update status', 'WARNING'); + toastr.warning(response.message || 'Failed to update status', 'Warning'); } }, function(xhr, status, error) { console.error('Error fetching data:', error); console.error(xhr.responseText); - toastr.error('An error occurred while saving docs.', 'ERROR'); + toastr.error('An error occurred while saving docs.', 'Error'); }); } \ No newline at end of file diff --git a/app/Views/ticket_form_handler.php b/app/Views/ticket_form_handler.php index 17a6715e..d744931e 100644 --- a/app/Views/ticket_form_handler.php +++ b/app/Views/ticket_form_handler.php @@ -740,7 +740,7 @@ var isValid = $('#ticket_form_data').parsley().validate(); if (!isValid) { - toastr.warning('Form validation failed. Please check the required fields.', 'WARNING'); + toastr.warning('Form validation failed. Please check the required fields.', 'Warning'); return false; } @@ -769,13 +769,13 @@ console.log('Form submitted response:', response); if (response.status === true) { - toastr.success(response.message, 'SUCCESS'); + toastr.success(response.message, 'Success'); window.location.href = ''; } else { if(response.code == 409){ - toastr.warning(response.message, 'WARNING'); + toastr.warning(response.message, 'Warning'); }else{ - toastr.error(response.message, 'ERROR'); + toastr.error(response.message, 'Error'); } } @@ -787,6 +787,31 @@ // Hide loader $('.loader').fadeOut(); $('.loader-mask').delay(350).fadeOut('slow'); + + if (xhr.status === 400) { + let response = JSON.parse(xhr.responseText); + let errorMessages = ""; + let seenMessages = []; // Array to store unique messages + if (response.errors) { + $.each(response.errors, function (field, message) { + if (!seenMessages.includes(message)) { + errorMessages += `• ${message}
    `; + seenMessages.push(message); // Mark this message as "seen" + } + }); + toastr.error(errorMessages, 'Validation Error', { "allowHtml": true }); + } else { + toastr.warning(response.message || 'Validation failed', 'Warning'); + } + + } else if (xhr.status === 403) { + let response = JSON.parse(xhr.responseText); + toastr.error(response.message, 'Security Policy'); + } else if (xhr.status === 500) { + toastr.error('Something went wrong . Please try again later.', 'Server Error'); + } else { + toastr.error('An unexpected error occurred. Please try again later.', 'Error'); + } } }); } @@ -814,12 +839,12 @@ console.log('Data fetched successfully:', response); if (response.status) { - console.log(response.message, 'SUCCESS'); + console.log(response.message, 'Success'); appendEmployee(response.data, 'search_by_client_employee'); setClientAndInsurerData(response.dataForClientAndInsurer); setClientPolicyData(input); } else { - toastr.warning(response.message, 'WARNING'); + toastr.warning(response.message, 'Warning'); } // Hide loader @@ -829,7 +854,7 @@ }, function(xhr, status, error) { console.error('Error fetching data:', error); console.error(xhr.responseText); - toastr.error('An error occurred while fetch data.', 'ERROR'); + toastr.error('An error occurred while fetch data.', 'Error'); // Hide loader $('.loader').fadeOut(); @@ -890,7 +915,7 @@ appendACMS(response.acms) } else { - toastr.warning(response.message, 'WARNING'); + toastr.warning(response.message, 'Warning'); appendACMS(response.acms); unSetClientPolicy(); unSetClientAndInsurerData() @@ -902,7 +927,7 @@ }, function(xhr, status, error) { console.error('Error fetching data:', error); console.error(xhr.responseText); - toastr.error('An error occurred while fetch data.', 'ERROR'); + toastr.error('An error occurred while fetch data.', 'Error'); // Hide loader $('.loader').fadeOut(); diff --git a/app/Views/ticket_list.php b/app/Views/ticket_list.php index fc467dfb..da6b20be 100644 --- a/app/Views/ticket_list.php +++ b/app/Views/ticket_list.php @@ -386,10 +386,10 @@ function removeClaim(input, ticket_id) { console.log('Data fetched successfully:', response); if (response.status === true) { - toastr.success(response.message, 'SUCCESS'); + toastr.success(response.message, 'Success'); window.location.reload(); } else { - toastr.warning(response.message, 'WARNING'); + toastr.warning(response.message, 'Warning'); } }, function(xhr, status, error) { console.error('Error fetching data:', error); diff --git a/app/Views/ticket_mail_template.php b/app/Views/ticket_mail_template.php index 9cda359e..00db4cb5 100644 --- a/app/Views/ticket_mail_template.php +++ b/app/Views/ticket_mail_template.php @@ -424,7 +424,7 @@ toastr.success('Template saved successfully!', 'Success'); location.reload(); } else if (res.status == false) { - toastr.error('Failed to Save Data', 'error'); + toastr.error('Failed to Save Data', 'Error'); } }, @@ -436,14 +436,29 @@ $('.loader-mask').delay(350).fadeOut('slow'); if (xhr.status === 400) { let response = JSON.parse(xhr.responseText); + let errorMessages = ""; + let seenMessages = []; // Array to store unique messages if (response.errors) { $.each(response.errors, function (field, message) { - toastr.warning(message, 'Validation Error'); + if (!seenMessages.includes(message)) { + errorMessages += `• ${message}
    `; + seenMessages.push(message); // Mark this message as "seen" + } }); + toastr.error(errorMessages, 'Validation Error', { "allowHtml": true }); } else { toastr.warning(response.message || 'Validation failed', 'Warning'); } - } else{toastr.error('Something Wrong!', 'warning');} + + }else if (xhr.status === 403) { + let response = JSON.parse(xhr.responseText); + toastr.error(response.message, 'Security Policy'); + } else if (xhr.status === 500) { + toastr.error('Something went wrong . Please try again later.', 'Server Error'); + } else { + toastr.error('An unexpected error occurred. Please try again later.', 'Error'); + } + }, 1000); } }); @@ -552,7 +567,7 @@ }); } } else { - toastr.error('Data Not Found', 'error'); + toastr.error('Data Not Found', 'Error'); } } $('.loader').fadeOut(); @@ -564,7 +579,7 @@ setTimeout(function() { $('.loader').fadeOut(); $('.loader-mask').delay(350).fadeOut('slow'); - toastr.warning('Something Went Wrong!', 'warning'); + toastr.warning('Something Went Wrong!', 'Warning'); }, 1000); } }); diff --git a/app/Views/ticket_note.php b/app/Views/ticket_note.php index 42ccd4ee..97c37331 100644 --- a/app/Views/ticket_note.php +++ b/app/Views/ticket_note.php @@ -42,7 +42,7 @@ $(document).ready(function() { setTimeout(function() { $('.loader').fadeOut(); $('.loader-mask').delay(350).fadeOut('slow'); - toastr.warning('Something Went Wrong!', 'warning'); + toastr.warning('Something Went Wrong!', 'Warning'); }, 1000); } }) @@ -79,17 +79,63 @@ $(document).ready(function() { $('.loader').fadeOut(); $('.loader-mask').delay(350).fadeOut('slow'); let message = response.message; - toastr.error(message, 'ERROR'); + if (xhr.status === 400) { + let response = JSON.parse(xhr.responseText); + let errorMessages = ""; + let seenMessages = []; // Array to store unique messages + if (response.errors) { + $.each(response.errors, function (field, message) { + if (!seenMessages.includes(message)) { + errorMessages += `• ${message}
    `; + seenMessages.push(message); // Mark this message as "seen" + } + }); + toastr.error(errorMessages, 'Validation Error', { "allowHtml": true }); + } else { + toastr.warning(response.message || 'Validation failed', 'Warning'); + } + + } else if (xhr.status === 403) { + let response = JSON.parse(xhr.responseText); + toastr.error(response.message, 'Security Policy'); + } else if (xhr.status === 500) { + toastr.error('Something went wrong . Please try again later.', 'Server Error'); + } else { + toastr.error('An unexpected error occurred. Please try again later.', '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'); + if (xhr.status === 400) { + let response = JSON.parse(xhr.responseText); + let errorMessages = ""; + let seenMessages = []; // Array to store unique messages + if (response.errors) { + $.each(response.errors, function (field, message) { + if (!seenMessages.includes(message)) { + errorMessages += `• ${message}
    `; + seenMessages.push(message); // Mark this message as "seen" + } + }); + toastr.error(errorMessages, 'Validation Error', { "allowHtml": true }); + } else { + toastr.warning(response.message || 'Validation failed', 'Warning'); + } + + } else if (xhr.status === 403) { + let response = JSON.parse(xhr.responseText); + toastr.error(response.message, 'Security Policy'); + } else if (xhr.status === 500) { + toastr.error('Something went wrong . Please try again later.', 'Server Error'); + } else { + toastr.error('An unexpected error occurred. Please try again later.', 'Error'); + } }); }); diff --git a/app/Views/ticket_reply.php b/app/Views/ticket_reply.php index d83fcbf8..9a732b39 100644 --- a/app/Views/ticket_reply.php +++ b/app/Views/ticket_reply.php @@ -195,7 +195,30 @@ $(document).ready(function() { { $('.loader').fadeOut(); $('.loader-mask').delay(350).fadeOut('slow'); - toastr.error('Something Wrong!', 'warning'); + if (xhr.status === 400) { + let response = JSON.parse(xhr.responseText); + let errorMessages = ""; + let seenMessages = []; // Array to store unique messages + if (response.errors) { + $.each(response.errors, function (field, message) { + if (!seenMessages.includes(message)) { + errorMessages += `• ${message}
    `; + seenMessages.push(message); // Mark this message as "seen" + } + }); + toastr.error(errorMessages, 'Validation Error', { "allowHtml": true }); + } else { + toastr.warning(response.message || 'Validation failed', 'Warning'); + } + + } else if (xhr.status === 403) { + let response = JSON.parse(xhr.responseText); + toastr.error(response.message, 'Security Policy'); + } else if (xhr.status === 500) { + toastr.error('Something went wrong . Please try again later.', 'Server Error'); + } else { + toastr.error('An unexpected error occurred. Please try again later.', 'Error'); + } }, 1000); } }); diff --git a/app/Views/ticket_reports.php b/app/Views/ticket_reports.php index 08785950..0cb76b64 100644 --- a/app/Views/ticket_reports.php +++ b/app/Views/ticket_reports.php @@ -129,14 +129,14 @@ $('.loader').fadeOut(); $('.loader-mask').delay(350).fadeOut('slow'); let message = response.message; - toastr.error(message, 'ERROR'); + 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'); + toastr.error('An error occurred while fetching the report page.', 'Error'); $('.loader').fadeOut(); $('.loader-mask').delay(350).fadeOut('slow'); diff --git a/app/Views/ticket_search.php b/app/Views/ticket_search.php index e248afb1..ea470c39 100644 --- a/app/Views/ticket_search.php +++ b/app/Views/ticket_search.php @@ -259,13 +259,13 @@ $('.loader').fadeOut(); $('.loader-mask').delay(350).fadeOut('slow'); let message = response.message; - toastr.error(message, 'ERROR'); + 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 data.', 'ERROR'); + toastr.error('An error occurred while fetching the data.', 'Error'); $('.loader').fadeOut(); $('.loader-mask').delay(350).fadeOut('slow'); @@ -303,13 +303,13 @@ $('.loader').fadeOut(); $('.loader-mask').delay(350).fadeOut('slow'); let message = response.message; - toastr.error(message, 'ERROR'); + 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 data.', 'ERROR'); + toastr.error('An error occurred while fetching the data.', 'Error'); $('.loader').fadeOut(); $('.loader-mask').delay(350).fadeOut('slow'); diff --git a/app/Views/tpa_basic_info.php b/app/Views/tpa_basic_info.php index b0ee3724..f258ff2d 100755 --- a/app/Views/tpa_basic_info.php +++ b/app/Views/tpa_basic_info.php @@ -327,18 +327,33 @@ setTimeout(function() { $('.loader').fadeOut(); $('.loader-mask').delay(350).fadeOut('slow'); - console.log('Something Wrong!', 'warning'); + console.log('Something Wrong!', 'Warning'); // Handle validation errors (CI4) if (xhr.status === 400) { let response = JSON.parse(xhr.responseText); + let errorMessages = ""; + let seenMessages = []; // Array to store unique messages if (response.errors) { $.each(response.errors, function (field, message) { - toastr.warning(message, 'Validation Error'); + if (!seenMessages.includes(message)) { + errorMessages += `• ${message}
    `; + seenMessages.push(message); // Mark this message as "seen" + } }); + toastr.error(errorMessages, 'Validation Error', { "allowHtml": true }); } else { toastr.warning(response.message || 'Validation failed', 'Warning'); } + + }else if (xhr.status === 403) { + let response = JSON.parse(xhr.responseText); + toastr.error(response.message, 'Security Policy'); + } else if (xhr.status === 500) { + toastr.error('Something went wrong . Please try again later.', 'Server Error'); + } else { + toastr.error('An unexpected error occurred. Please try again later.', 'Error'); } + }, 1000); } }); diff --git a/app/Views/tpa_branch.php b/app/Views/tpa_branch.php index d3da93aa..f8e30273 100755 --- a/app/Views/tpa_branch.php +++ b/app/Views/tpa_branch.php @@ -479,16 +479,29 @@ $(document).ready(function () { $('.loader').fadeOut(); $('.loader-mask').delay(350).fadeOut('slow'); if (xhr.status === 400) { - let response = JSON.parse(xhr.responseText); - if (response.errors) { - $.each(response.errors, function (field, message) { - toastr.warning(message, 'Validation Error'); - }); - } else { - toastr.warning(response.message || 'Validation failed', 'Warning'); - } - } - toastr.warning('Something Wrong!', 'warning'); + let response = JSON.parse(xhr.responseText); + let errorMessages = ""; + let seenMessages = []; // Array to store unique messages + if (response.errors) { + $.each(response.errors, function (field, message) { + if (!seenMessages.includes(message)) { + errorMessages += `• ${message}
    `; + seenMessages.push(message); // Mark this message as "seen" + } + }); + toastr.error(errorMessages, 'Validation Error', { "allowHtml": true }); + } else { + toastr.warning(response.message || 'Validation failed', 'Warning'); + } + + } else if (xhr.status === 403) { + let response = JSON.parse(xhr.responseText); + toastr.error(response.message, 'Security Policy'); + } else if (xhr.status === 500) { + toastr.error('Something went wrong . Please try again later.', 'Server Error'); + } else { + toastr.error('An unexpected error occurred. Please try again later.', 'Error'); + } }, 1000); }, complete: function() { @@ -556,7 +569,7 @@ $(document).ready(function () { setTimeout(function() { $('.loader').fadeOut(); $('.loader-mask').delay(350).fadeOut('slow'); - toastr.warning('Something Wrong!', 'warning'); + toastr.warning('Something Wrong!', 'Warning'); }, 1000); } }); @@ -610,7 +623,7 @@ $(document).ready(function () { setTimeout(function() { $('.loader').fadeOut(); $('.loader-mask').delay(350).fadeOut('slow'); - toastr.warning('Something Wrong!', 'warning'); + toastr.warning('Something Wrong!', 'Warning'); }, 1000); } }); @@ -866,10 +879,10 @@ function removeTPABranch(element) { // console.log(res.status == true); if(res){ if (res.status == true) { - toastr.success('TPA branch removed successfully', 'success'); + toastr.success('TPA branch removed successfully', 'Success'); location.reload(); } else { - toastr.warning('Failed to remove TPA branch', 'warning'); + toastr.warning('Failed to remove TPA branch', 'Warning'); } } }, @@ -878,7 +891,7 @@ function removeTPABranch(element) { console.error(status, error); $('.loader').fadeOut(); $('.loader-mask').delay(350).fadeOut('slow'); - toastr.warning('Failed to remove TPA branch', 'warning'); + toastr.warning('Failed to remove TPA branch', 'Warning'); } }); } diff --git a/app/Views/tpa_list.php b/app/Views/tpa_list.php index bec11d92..4f606a9f 100755 --- a/app/Views/tpa_list.php +++ b/app/Views/tpa_list.php @@ -314,10 +314,10 @@ // console.log(res.status == true); if (res) { if (res.status == true) { - toastr.success('TPA removed successfully', 'success'); + toastr.success('TPA removed successfully', 'Success'); location.reload(); } else { - toastr.warning('Failed to remove TPA', 'warning'); + toastr.warning('Failed to remove TPA', 'Warning'); } } }, @@ -326,7 +326,7 @@ console.error(status, error); $('.loader').fadeOut(); $('.loader-mask').delay(350).fadeOut('slow'); - toastr.warning('Failed to remove TPA', 'warning'); + toastr.warning('Failed to remove TPA', 'Warning'); } }); } diff --git a/app/Views/tpa_onboarding.php b/app/Views/tpa_onboarding.php index 9c5edb72..902517c3 100755 --- a/app/Views/tpa_onboarding.php +++ b/app/Views/tpa_onboarding.php @@ -90,7 +90,7 @@ if (check_tpa_id[0].value == '' || check_tpa_id[0].value == null || check_tpa_id[0].value == 0) { $('#btnBranchAdd').hide(); - toastr.warning('First Add the TPA!', 'warning', { + toastr.warning('First Add the TPA!', 'Warning', { timeOut: 2000 }); } else { diff --git a/app/Views/variance_report_list.php b/app/Views/variance_report_list.php index 144df61f..207af9b1 100644 --- a/app/Views/variance_report_list.php +++ b/app/Views/variance_report_list.php @@ -899,7 +899,7 @@ appendPolicies(response.data) } else { - toastr.warning(response.message, 'WARNING'); + toastr.warning(response.message, 'Warning'); } }, function(xhr, status, error) { console.error('Error fetching data:', error); diff --git a/app/Views/vehicle_details.php b/app/Views/vehicle_details.php index f4bb4e27..466795de 100644 --- a/app/Views/vehicle_details.php +++ b/app/Views/vehicle_details.php @@ -248,21 +248,32 @@ $(document).ready(function() { $('.loader-mask').delay(350).fadeOut('slow'); $submitButton.prop('disabled', false); if (xhr.status === 400) { - let response = JSON.parse(xhr.responseText); - if (response.errors) { - $.each(response.errors, function (field, message) { - toastr.warning(message, 'Validation Error'); - }); - } else { - toastr.warning(response.message || 'Validation failed', 'Warning'); - } + let response = JSON.parse(xhr.responseText); + let errorMessages = ""; + let seenMessages = []; // Array to store unique messages + if (response.errors) { + $.each(response.errors, function (field, message) { + if (!seenMessages.includes(message)) { + errorMessages += `• ${message}
    `; + seenMessages.push(message); // Mark this message as "seen" + } + }); + toastr.error(errorMessages, 'Validation Error', { "allowHtml": true }); + } else { + toastr.warning(response.message || 'Validation failed', 'Warning'); + } + + } else if (xhr.status === 403) { + let response = JSON.parse(xhr.responseText); + toastr.error(response.message, 'Security Policy'); } else if (xhr.status === 404) { toastr.warning('Resource not found', 'Warning'); } else if (xhr.status === 500) { - toastr.warning('Internal server error', 'Warning'); + toastr.error('Something went wrong . Please try again later.', 'Server Error'); } else { - toastr.warning('Unknown error occurred', 'Warning'); + toastr.error('An unexpected error occurred. Please try again later.', 'Error'); } + }, 1000); } }); @@ -395,7 +406,7 @@ $('#cost_center').change(function() { console.log(res) if (res.status == true) { - toastr.warning(res.message, 'warning'); + toastr.warning(res.message, 'Warning'); $('#cost_center').val(''); } }, diff --git a/app/Views/vehicle_docs.php b/app/Views/vehicle_docs.php index 07081588..5409ce0a 100644 --- a/app/Views/vehicle_docs.php +++ b/app/Views/vehicle_docs.php @@ -102,10 +102,10 @@ $("#vehicle_file_upload_form").submit(function(event) { console.log(res); if(res.status == true){ - toastr.success(res.message, 'SUCCESS'); + toastr.success(res.message, 'Success'); appendVehicleFileTableBody(res.vehicle_docs); }else{ - toastr.warning(res.message, 'WARNING'); + toastr.warning(res.message, 'Warning'); } $('#vehicle_file_upload_form')[0].reset(); diff --git a/app/Views/vehicle_master_list.php b/app/Views/vehicle_master_list.php index b153b534..9ddf3e56 100644 --- a/app/Views/vehicle_master_list.php +++ b/app/Views/vehicle_master_list.php @@ -636,10 +636,10 @@ function removeVehicleMasterData(element) { // console.log(res.status == true); if (res) { if (res.status == true) { - toastr.success('Vehicle Data removed successfully.', 'success'); + toastr.success('Vehicle Data removed successfully.', 'Success'); location.reload(); } else { - toastr.warning('Failed to remove Vehicle Data.', 'warning'); + toastr.warning('Failed to remove Vehicle Data.', 'Warning'); } } }, @@ -648,7 +648,7 @@ function removeVehicleMasterData(element) { console.error(status, error); $('.loader').fadeOut(); $('.loader-mask').delay(350).fadeOut('slow'); - console.log('Something Wrong!', 'warning'); + console.log('Something Wrong!', 'Warning'); } }); } @@ -787,16 +787,30 @@ $("#vehicle_form").submit(function(event) { console.error(status, error); $('.loader').fadeOut(); $('.loader-mask').delay(350).fadeOut('slow'); - if (xhr.status === 400) { - let response = JSON.parse(xhr.responseText); - if (response.errors) { - $.each(response.errors, function (field, message) { - toastr.warning(message, 'Validation Error'); - }); - } else { - toastr.warning(response.message || 'Validation failed', 'Warning'); - } - } + if (xhr.status === 400) { + let response = JSON.parse(xhr.responseText); + let errorMessages = ""; + let seenMessages = []; // Array to store unique messages + if (response.errors) { + $.each(response.errors, function (field, message) { + if (!seenMessages.includes(message)) { + errorMessages += `• ${message}
    `; + seenMessages.push(message); // Mark this message as "seen" + } + }); + toastr.error(errorMessages, 'Validation Error', { "allowHtml": true }); + } else { + toastr.warning(response.message || 'Validation failed', 'Warning'); + } + + } else if (xhr.status === 403) { + let response = JSON.parse(xhr.responseText); + toastr.error(response.message, 'Security Policy'); + } else if (xhr.status === 500) { + toastr.error('Something went wrong . Please try again later.', 'Server Error'); + } else { + toastr.error('An unexpected error occurred. Please try again later.', 'Error'); + } } }); }); diff --git a/app/Views/vehicle_type_list.php b/app/Views/vehicle_type_list.php index 53456a0f..8927d756 100644 --- a/app/Views/vehicle_type_list.php +++ b/app/Views/vehicle_type_list.php @@ -982,7 +982,7 @@ var student_id = $(this).attr('data-id'); $.get(''+student_id, function (data) { console.log(data); - toastr.success('User removed successfully', 'success'); + toastr.success('User removed successfully', 'Success'); window.location.reload() }) } diff --git a/app/Views/vehicle_type_master_list.php b/app/Views/vehicle_type_master_list.php index 984f4ecc..b06382b7 100755 --- a/app/Views/vehicle_type_master_list.php +++ b/app/Views/vehicle_type_master_list.php @@ -222,16 +222,30 @@ console.error(xhr.responseText); $('.loader').fadeOut(); $('.loader-mask').delay(350).fadeOut('slow'); - if (xhr.status === 400) { - let response = JSON.parse(xhr.responseText); - if (response.errors) { - $.each(response.errors, function (field, message) { - toastr.warning(message, 'Validation Error'); - }); - } else { - toastr.warning(response.message || 'Validation failed', 'Warning'); - } - } + if (xhr.status === 400) { + let response = JSON.parse(xhr.responseText); + let errorMessages = ""; + let seenMessages = []; // Array to store unique messages + if (response.errors) { + $.each(response.errors, function (field, message) { + if (!seenMessages.includes(message)) { + errorMessages += `• ${message}
    `; + seenMessages.push(message); // Mark this message as "seen" + } + }); + toastr.error(errorMessages, 'Validation Error', { "allowHtml": true }); + } else { + toastr.warning(response.message || 'Validation failed', 'Warning'); + } + + } else if (xhr.status === 403) { + let response = JSON.parse(xhr.responseText); + toastr.error(response.message, 'Security Policy'); + } else if (xhr.status === 500) { + toastr.error('Something went wrong . Please try again later.', 'Server Error'); + } else { + toastr.error('An unexpected error occurred. Please try again later.', 'Error'); + } }); } diff --git a/app/Views/view_rfq.php b/app/Views/view_rfq.php index 5d332d35..79cf9a97 100644 --- a/app/Views/view_rfq.php +++ b/app/Views/view_rfq.php @@ -2037,7 +2037,7 @@ rfqTable.addEventListener('click', function(e) { Swal.fire({ title: 'Are you sure?', text: "Do you want to remove the row?", - icon: 'warning', + icon: 'Warning', showCancelButton: true, confirmButtonColor: '#d33', cancelButtonColor: '#3085d6', @@ -2934,7 +2934,7 @@ function removeProposal(event) { Swal.fire({ title: 'Are you sure?', text: "Do you want to remove the Proposal?", - icon: 'warning', + icon: 'Warning', showCancelButton: true, confirmButtonColor: '#d33', cancelButtonColor: '#3085d6', @@ -2995,7 +2995,7 @@ function removeInsurer(event) { Swal.fire({ title: 'Are you sure?', text: "Do you want to remove the insurer?", - icon: 'warning', + icon: 'Warning', showCancelButton: true, confirmButtonColor: '#d33', cancelButtonColor: '#3085d6', @@ -3212,7 +3212,7 @@ function changeInsurer(event) { console.log('proposel Name', proposal_name); if(proposal_name == null || proposal_name == ""){ - toastr.warning("Could not change the insurer", "WARNING") + toastr.warning("Could not change the insurer", "Warning") return; } @@ -3349,7 +3349,7 @@ function changeInsurerData(event, newInsurerName, dataId){ }else{ - toastr.warning("Could not change the insurer", "WARNING") + toastr.warning("Could not change the insurer", "Warning") return; } } @@ -4276,7 +4276,7 @@ function constructURL(url_type) { if (validationStatus){ constructURL_ForInsurerAndClientMailSend(); }else{ - toastr.error("All Client Mail ID's Should Contain Same Domain","ERROR"); + toastr.error("All Client Mail ID's Should Contain Same Domain","Error"); } }else if(url_type == 2){ constructURL_ForInternalMailSend() @@ -4555,17 +4555,17 @@ function ajaxRequest(formData) { $('.loader-mask').delay(350).fadeOut('slow'); console.log(res); - if (res.status == 'success' && res.code == 200) { - toastr.success('Mail sent Successfully', 'SUCCESS') + if (res.status == 'Success' && res.code == 200) { + toastr.success('Mail sent Successfully', 'Success') if(res.is_placement == true){ clearInterval(intervalId); console.log('******** Intervel Cleared ********') } } else { if (res.messgae) { - toastr.error(res.messgae, 'ERROR') + toastr.error(res.messgae, 'Error') } else { - toastr.error('Mail send failed', 'ERROR') + toastr.error('Mail send failed', 'Error') } } @@ -4622,7 +4622,7 @@ function getInsurerBranchContacts(input){ $('.loader').fadeOut(); $('.loader-mask').delay(350).fadeOut('slow'); if(res.status == false){ - toastr.warning(res.message, 'WARNING') + toastr.warning(res.message, 'Warning') }else{ appendInsurerContact(res.data) } @@ -4798,7 +4798,7 @@ function getMailContent(id){ console.log(response); $('#'+id).val(response.data) } else { - toastr.error(response.message || 'Unable to fetch data', 'ERROR'); + toastr.error(response.message || 'Unable to fetch data', 'Error'); } }, function(xhr, status, error) { console.error('Error fetching data:', error); @@ -4872,7 +4872,7 @@ function checkTheTableDataChanged(redirect_type, url){ //PLACEMENT MAIL SEND showModal(3); // if(demography_file_status == "failed"){ - // toastr.warning('Member Demography file validation failed. Please re-upload', 'WARNING'); + // toastr.warning('Member Demography file validation failed. Please re-upload', 'Warning'); // }else{ // showModal(3); // } @@ -6416,14 +6416,14 @@ function appendMultiFileData(data) { if (response.status == true) { if(input == 1){ - console.log(response.message, 'SUCCESS'); + console.log(response.message, 'Success'); showTinyToast(); }else{ - toastr.success(response.message, 'SUCCESS'); + toastr.success(response.message, 'Success'); } $('#rfq_primaryKey').val(response.id); } else { - toastr.warning(response.message, 'WARNING'); + toastr.warning(response.message, 'Warning'); } if(input != 1){ @@ -6494,9 +6494,9 @@ function appendMultiFileData(data) { console.log('Data sent successfully:', response); if (response.status == true) { - toastr.success(response.message, 'SUCCESS'); + toastr.success(response.message, 'Success'); } else { - toastr.warning(response.message, 'WARNING'); + toastr.warning(response.message, 'Warning'); } window.location.href = '' + lead_id + '/' + 2; @@ -7017,7 +7017,7 @@ function appendMultiFileData(data) { console.log('Data fetched successfully:', response); if (response.status === true) { - toastr.success(response.message, 'SUCCESS'); + toastr.success(response.message, 'Success'); $("#no_of_installment").closest('.form-group').hide(); $('#no_of_installment').val(""); $('#installment_form_row').empty(); @@ -7044,7 +7044,7 @@ function appendMultiFileData(data) { dateFormat: 'd-m-Y', }); } else { - toastr.error(response.message, 'WARNING'); + toastr.error(response.message, 'Warning'); } $('.loader').fadeOut(); @@ -7055,7 +7055,7 @@ function appendMultiFileData(data) { $('.loader-mask').delay(350).fadeOut('slow'); console.error('Error fetching data:', error); console.error(xhr.responseText); - toastr.error('An error occurred while removing the installment.', 'ERROR'); + toastr.error('An error occurred while removing the installment.', 'Error'); }); }else{ // alert("Inside else"); @@ -7174,14 +7174,14 @@ function appendMultiFileData(data) { console.log('Data fetched successfully:', response); if (response.status === true) { - toastr.success(response.message, 'SUCCESS'); + toastr.success(response.message, 'Success'); $this.closest('.form-row').remove(); let updated_row_count = $('#installment_form_row .form-row').length; $('#no_of_installment').val(updated_row_count); console.log("after remove row_count", updated_row_count); } else { - toastr.error(response.message, 'WARNING'); + toastr.error(response.message, 'Warning'); } $('.loader').fadeOut(); @@ -7192,7 +7192,7 @@ function appendMultiFileData(data) { $('.loader-mask').delay(350).fadeOut('slow'); console.error('Error fetching data:', error); console.error(xhr.responseText); - toastr.error('An error occurred while removing the installment.', 'ERROR'); + toastr.error('An error occurred while removing the installment.', 'Error'); }); } }); @@ -7255,10 +7255,10 @@ function appendMultiFileData(data) { console.log('Data fetched successfully:', response); if (response.status === true) { - toastr.success(response.message, 'SUCCESS'); + toastr.success(response.message, 'Success'); $installmentContainer.find('.form-row').slice(-remove_count).remove(); } else { - toastr.error(response.message, 'WARNING'); + toastr.error(response.message, 'Warning'); } $('.loader').fadeOut(); @@ -7269,7 +7269,7 @@ function appendMultiFileData(data) { $('.loader-mask').delay(350).fadeOut('slow'); console.error('Error fetching data:', error); console.error(xhr.responseText); - toastr.error('An error occurred while removing the installment.', 'ERROR'); + toastr.error('An error occurred while removing the installment.', 'Error'); }); }else{ $('#no_of_installment').val(row_count); @@ -7381,7 +7381,7 @@ function appendMultiFileData(data) { function removeFileField(index, lead_file_id = null) { if(index == 1){ - toastr.warning("You can't remove the first file field", 'WARNING'); + toastr.warning("You can't remove the first file field", 'Warning'); return false; } @@ -7413,7 +7413,7 @@ function appendMultiFileData(data) { console.log('Data fetched successfully:', response); if (response.status == true) { - toastr.success(response.message, 'SUCCESS'); + toastr.success(response.message, 'Success'); //remove the file field const field = document.getElementById(`fileField_${index}`); @@ -7422,7 +7422,7 @@ function appendMultiFileData(data) { } } else { - toastr.error(response.message, 'WARNING'); + toastr.error(response.message, 'Warning'); } $('.loader').fadeOut(); @@ -7433,7 +7433,7 @@ function appendMultiFileData(data) { $('.loader-mask').delay(350).fadeOut('slow'); console.error('Error fetching data:', error); console.error(xhr.responseText); - toastr.error('An error occurred while checking the CD amount.', 'ERROR'); + toastr.error('An error occurred while checking the CD amount.', 'Error'); }); }else{ @@ -7480,14 +7480,14 @@ function appendMultiFileData(data) { console.log('uploadMultiFileFromRfq reponse', res); if(res.status == true){ - toastr.success(res.message, 'SUCCESS'); + toastr.success(res.message, 'Success'); $('#multiFileAppendArea').empty(); $('.attachmet_row').empty(); $('#multiFileAppendArea').append(res.document_data); $('.attachmet_row').html(res.attachment_html); window.location.reload(); }else{ - toastr.warning(res.message, 'WARNING'); + toastr.warning(res.message, 'Warning'); } // Hide loader @@ -7562,10 +7562,10 @@ function appendMultiFileData(data) { sendAjaxRequestForGlobal(url, 'POST', requestData, function(res) { if (res.status == true) { - toastr.success(res.message, 'SUCCESS'); + toastr.success(res.message, 'Success'); checkMemberDataValidationStatus(res.lead_id) } else { - toastr.warning(res.message, 'WARNING'); + toastr.warning(res.message, 'Warning'); // Hide loader $('.loader').fadeOut(); $('.loader-mask').delay(350).fadeOut('slow'); @@ -7575,7 +7575,7 @@ function appendMultiFileData(data) { clearInterval(interval); console.error('Error fetching data:', error); console.error(xhr.responseText); - toastr.error('An error occurred while validation.', 'ERROR'); + toastr.error('An error occurred while validation.', 'Error'); console.error("❌ Error checking validation status:", err); // Hide loader $('.loader').fadeOut(); @@ -7609,10 +7609,10 @@ function appendMultiFileData(data) { if (res.code === 200 && res.data.status != "pending") { clearInterval(interval); // stop checking - if(res.data.status == 'success'){ - toastr.success("✅ Validation Completed status : " + res.data.status, 'SUCCESS'); + if(res.data.status == 'Success'){ + toastr.success("✅ Validation Completed status : " + res.data.status, 'Success'); }else{ - toastr.warning("✅ Validation Completed status : " + res.data.status, 'WARNING'); + toastr.warning("✅ Validation Completed status : " + res.data.status, 'Warning'); } window.location.reload(); @@ -7633,7 +7633,7 @@ function appendMultiFileData(data) { clearInterval(interval); console.error('Error fetching data:', error); console.error(xhr.responseText); - toastr.error('An error occurred while validation.', 'ERROR'); + toastr.error('An error occurred while validation.', 'Error'); console.error("❌ Error checking validation status:", err); // Hide loader $('.loader').fadeOut(); @@ -7692,7 +7692,7 @@ function appendMultiFileData(data) { console.error('Error fetching data:', error); console.error(xhr.responseText); - // toastr.error('An error occurred while fetching demography.', 'ERROR'); + // toastr.error('An error occurred while fetching demography.', 'Error'); // Hide loader $('.loader').fadeOut(); $('.loader-mask').delay(350).fadeOut('slow'); diff --git a/app/Views/view_rfq_non_eb.php b/app/Views/view_rfq_non_eb.php index a1292e11..e55ed4a2 100644 --- a/app/Views/view_rfq_non_eb.php +++ b/app/Views/view_rfq_non_eb.php @@ -2992,7 +2992,7 @@ // Save all tables' data to localStorage localStorage.setItem('allTablesJsonData', JSON.stringify(allTablesData)); // // console.log('All tables data saved:', allTablesData); - // toastr.success("RFQ Saved Successfully", "SUCCESS"); + // toastr.success("RFQ Saved Successfully", "Success"); // If needed, reconstruct tables from JSON (implement jsonToTable accordingly) return allTablesData; @@ -5048,16 +5048,16 @@ // // console.log(res); if (res.status == 'success' && res.code == 200) { - toastr.success('Mail send Successfully', 'SUCCESS'); + toastr.success('Mail send Successfully', 'Success'); if(res.is_placement == true){ clearInterval(intervalId); console.log('******** Intervel Cleared ********') } } else { if (res.messgae) { - toastr.error(res.messgae, 'ERROR') + toastr.error(res.messgae, 'Error') } else { - toastr.error('Mail send failed', 'ERROR') + toastr.error('Mail send failed', 'Error') } } @@ -5113,7 +5113,7 @@ $('.loader').fadeOut(); $('.loader-mask').delay(350).fadeOut('slow'); if (res.status == false) { - toastr.warning(res.message, 'WARNING') + toastr.warning(res.message, 'Warning') } else { appendInsurerContact(res.data) } @@ -5490,7 +5490,7 @@ console.log('Data fetched successfully:', response); if (response.status === true) { - toastr.success(response.message, 'SUCCESS'); + toastr.success(response.message, 'Success'); $("#no_of_installment").hide(); $("#payment_date").show(); $("#utr_no").show(); @@ -5515,7 +5515,7 @@ dateFormat: 'd-m-Y', }); } else { - toastr.error(response.message, 'WARNING'); + toastr.error(response.message, 'Warning'); } $('.loader').fadeOut(); @@ -5526,7 +5526,7 @@ $('.loader-mask').delay(350).fadeOut('slow'); console.error('Error fetching data:', error); console.error(xhr.responseText); - toastr.error('An error occurred while removing the installment.', 'ERROR'); + toastr.error('An error occurred while removing the installment.', 'Error'); }); }else{ // alert("Inside else"); @@ -5592,10 +5592,10 @@ console.log('Data fetched successfully:', response); if (response.status === true) { - toastr.success(response.message, 'SUCCESS'); + toastr.success(response.message, 'Success'); $installmentContainer.find('.form-row').slice(-remove_count).remove(); } else { - toastr.error(response.message, 'WARNING'); + toastr.error(response.message, 'Warning'); } $('.loader').fadeOut(); @@ -5606,7 +5606,7 @@ $('.loader-mask').delay(350).fadeOut('slow'); console.error('Error fetching data:', error); console.error(xhr.responseText); - toastr.error('An error occurred while removing the installment.', 'ERROR'); + toastr.error('An error occurred while removing the installment.', 'Error'); }); }else{ $('#no_of_installment').val(row_count); @@ -5704,14 +5704,14 @@ console.log('Data fetched successfully:', response); if (response.status === true) { - toastr.success(response.message, 'SUCCESS'); + toastr.success(response.message, 'Success'); $this.closest('.form-row').remove(); let updated_row_count = $('#installment_form_row .form-row').length; $('#no_of_installment').val(updated_row_count); console.log("after remove row_count", updated_row_count); } else { - toastr.error(response.message, 'WARNING'); + toastr.error(response.message, 'Warning'); } $('.loader').fadeOut(); @@ -5722,7 +5722,7 @@ $('.loader-mask').delay(350).fadeOut('slow'); console.error('Error fetching data:', error); console.error(xhr.responseText); - toastr.error('An error occurred while removing the installment.', 'ERROR'); + toastr.error('An error occurred while removing the installment.', 'Error'); }); } }); diff --git a/app/Views/view_rfq_non_eb_new.php b/app/Views/view_rfq_non_eb_new.php index f2293ebb..abc4f3ad 100644 --- a/app/Views/view_rfq_non_eb_new.php +++ b/app/Views/view_rfq_non_eb_new.php @@ -3271,7 +3271,7 @@ }, function(xhr, status, error) { console.error('Error fetching data:', error); console.error(xhr.responseText); - toastr.error('An error occurred while checking the CD amount.', 'ERROR'); + toastr.error('An error occurred while checking the CD amount.', 'Error'); }); } diff --git a/public/sample_excel/sample_claim_dump_upload_excel.xlsx b/public/sample_excel/sample_claim_dump_upload_excel.xlsx new file mode 100644 index 00000000..93b0d758 Binary files /dev/null and b/public/sample_excel/sample_claim_dump_upload_excel.xlsx differ