From 634f65ec96089541b8db7cc4407699c282f3d422 Mon Sep 17 00:00:00 2001 From: velz Date: Mon, 14 Jul 2025 14:34:11 +0530 Subject: [PATCH 01/14] FIX_HD_CESUMMARY_API --- app/Controllers/EmployeeRestController.php | 46 ++++++++++--------- .../RestAuthenticationController.php | 10 ++++ app/Models/UserActivityHistoryModel.php | 18 ++++++++ 3 files changed, 53 insertions(+), 21 deletions(-) create mode 100644 app/Models/UserActivityHistoryModel.php diff --git a/app/Controllers/EmployeeRestController.php b/app/Controllers/EmployeeRestController.php index 8a77865c..78e99a86 100755 --- a/app/Controllers/EmployeeRestController.php +++ b/app/Controllers/EmployeeRestController.php @@ -2376,41 +2376,45 @@ class EmployeeRestController extends AdminController $hr_id = $this->request->getGet('hr_id'); $HRAccessData = $this->getHRAccessData($hr_id,'post_enrollment'); - - if(isset($HRAccessData['allowed_active_policies'])) + // print_rr($HRAccessData);die(); + if(isset($HRAccessData['allowed_cd'])) { - $policyId = json_decode($HRAccessData['allowed_active_policies'],true); + $allowed_cd = json_decode($HRAccessData['allowed_cd'],true); }else{ - $policyId = []; + $allowed_cd = []; } - - if(count($policyId) == 0){ - return $this->respond(['status' => 'failed','code' => (count($policyId) ? 200 : 404),'data' => [] ], 200); + // $allowed_cd = [125]; + // print_r($allowed_cd);die(); + if(count($allowed_cd) == 0){ + return $this->respond(['status' => 'failed','code' => (count($allowed_cd) ? 200 : 404),'data' => [] ], 200); } $clientId = $this->request->getGet('client_id'); $clientController = new ClientController; - $result = $clientController->deposit($clientId , $requestFrom = 'rest' , $policyId); - + $result = $clientController->deposit($clientId , $requestFrom = 'rest' , []); + // print_rr($result);die(); $data = []; foreach ($result['clientData'] as $key => $value) { - $temp['client_id'] = $value->client_id; - $temp['insurer_id'] = $value->insurer_id; - $temp['cd_ac_pk'] = $value->cd_ac_pk; - $temp['insurer_name'] = $value->insurer_name; - $temp['cd_master_account_no'] = $value->cd_master_account_no; - if (isset($result['balances'][$temp['insurer_id']])) { - $balance = $result['balances'][$temp['insurer_id']]->balance; - $temp['balance'] = $balance; - } else { - $temp['balance'] = "N/A"; + if( in_array($value->cd_ac_pk, $allowed_cd) ) + { + $temp['client_id'] = $value->client_id; + $temp['insurer_id'] = $value->insurer_id; + $temp['cd_ac_pk'] = $value->cd_ac_pk; + $temp['insurer_name'] = $value->insurer_name; + $temp['cd_master_account_no'] = $value->cd_master_account_no; + if (isset($result['balances'][$temp['insurer_id']])) { + $balance = $result['balances'][$temp['insurer_id']]->balance; + $temp['balance'] = $balance; + } else { + $temp['balance'] = "N/A"; + } + + array_push($data,$temp); } - - array_push($data,$temp); } diff --git a/app/Controllers/RestAuthenticationController.php b/app/Controllers/RestAuthenticationController.php index 4aa0d89d..478d563b 100755 --- a/app/Controllers/RestAuthenticationController.php +++ b/app/Controllers/RestAuthenticationController.php @@ -23,6 +23,7 @@ use App\Models\AuthHistoryModel; use App\Models\LevelContactModel; use App\Models\HRAccessControlModel; use App\Models\ClientModel; +use App\Models\UserActivityHistoryModel; use Firebase\JWT\JWT; // require_once('../vendor/autoload.php'); @@ -39,6 +40,7 @@ class RestAuthenticationController extends AdminController protected $hrModel; protected $hrAccessControlModel; protected $clientModel; + protected $userActivityHistoryModel; public function __construct() @@ -51,6 +53,7 @@ class RestAuthenticationController extends AdminController $this->hrModel = new LevelContactModel(); $this->hrAccessControlModel = new HRAccessControlModel(); $this->clientModel = new ClientModel(); + $this->userActivityHistoryModel = new UserActivityHistoryModel(); } @@ -1231,6 +1234,13 @@ class RestAuthenticationController extends AdminController ], 404); } + public function logHrActivity() + { + $json = $this->request->getJSON(); + print_r($json);die(); + // $this->userActivityHistoryModel->insert(); + } + } \ No newline at end of file diff --git a/app/Models/UserActivityHistoryModel.php b/app/Models/UserActivityHistoryModel.php new file mode 100644 index 00000000..e56fcadd --- /dev/null +++ b/app/Models/UserActivityHistoryModel.php @@ -0,0 +1,18 @@ + Date: Tue, 15 Jul 2025 11:14:51 +0530 Subject: [PATCH 02/14] FEAT_LEVEL_CONTACT_REMOVE_API : RV --- app/Config/Routes.php | 1 + app/Controllers/ClientController.php | 36 +++++++++- app/Views/client_branch.php | 99 ++++++++++++++++++++++++---- 3 files changed, 121 insertions(+), 15 deletions(-) diff --git a/app/Config/Routes.php b/app/Config/Routes.php index a6cef1ed..920fa023 100755 --- a/app/Config/Routes.php +++ b/app/Config/Routes.php @@ -360,6 +360,7 @@ $routes->group("/util", ["filter" => "authMVC"], function ($routes) { $routes->get('removeInstallments', 'LeadsController::removeInstallments'); $routes->get('viewHrAccessData', 'ClientController::viewHrAccessData'); $routes->post('saveHrAccessData', 'ClientController::saveHrAccessData'); + $routes->post('removeLevelContacts', 'ClientController::removeLevelContacts'); }); $routes->post("policy_tranction/sendInstallmentRemainderMail","PolicyTransactionController::sendInstallmentRemainderMail"); diff --git a/app/Controllers/ClientController.php b/app/Controllers/ClientController.php index 4b09e9ae..f2efbf1b 100755 --- a/app/Controllers/ClientController.php +++ b/app/Controllers/ClientController.php @@ -143,7 +143,7 @@ class ClientController extends AdminController // Perform the query $builder = $db->table($table); - $isDuplicate = $builder->where($field, $value)->countAllResults() > 0; + $isDuplicate = $builder->where($field, $value)->where('is_active', 1)->countAllResults() > 0; // Return the result return $this->response->setJSON(['isDuplicate' => $isDuplicate]); @@ -1171,6 +1171,40 @@ class ClientController extends AdminController } } + public function removeLevelContacts() + { + $id = $this->request->getGet('id'); + try { + if (empty($id)) { + return $this->respond([ + 'status' => false, + 'message' => 'Invalid ID provided. ID is empty', + 'data' => $id + ], 400); + } + + $updated = $this->levelContactModel->update($id, ['is_active' => 0]); + + if ($updated === false) { + return $this->respond([ + 'status' => false, + 'message' => 'Failed to remove contact' + ], 500); + } + + return $this->respond([ + 'status' => true, + 'message' => 'Contact removed successfully' + ]); + } catch (\Exception $e) { + return $this->respond([ + 'status' => false, + 'message' => 'An error occurred: ' . $e->getMessage() + ], 500); + } + } + + public function createClientPolicy() diff --git a/app/Views/client_branch.php b/app/Views/client_branch.php index 708a66df..b8f4cd05 100755 --- a/app/Views/client_branch.php +++ b/app/Views/client_branch.php @@ -580,12 +580,12 @@ $('body').on('click', '.btnBranchEdit', function() { console.log(branch_form_action); }); -$("#remove_btn").click(function() { - $("#name").val(''); - $("#email").val(''); - $("#mobile").val(''); - $("#designation").val(''); -}) +// $("#remove_btn").click(function() { +// $("#name").val(''); +// $("#email").val(''); +// $("#mobile").val(''); +// $("#designation").val(''); +// }) // Initialize the contact count function appendContactHtml(contact = false, reset = false) { @@ -644,21 +644,68 @@ function appendContactHtml(contact = false, reset = false) { } +// function removeContact(button) { +// var uniqueId = button.id.split("_")[0]; +// var contactSection = document.getElementById(uniqueId); + +// if (contactSection) { +// contactSection.parentNode.removeChild(contactSection); +// contactCount--; + +// if (contactCount < 3) { +// var addButton = document.querySelector('.ac'); +// if (addButton) { +// addButton.style.display = 'block'; +// } +// } +// } +// } + function removeContact(button) { + var uniqueId = button.id.split("_")[0]; + console.log('uniqueId', uniqueId); var contactSection = document.getElementById(uniqueId); + console.log('contactSection', contactSection); - if (contactSection) { - contactSection.parentNode.removeChild(contactSection); - contactCount--; + confirmActionSweertAlert("Do you want to remove this contact?", "Yes, Proceed!", "No, Cancel").then((confirmed) => { + if(confirmed){ + if (contactSection) { - if (contactCount < 3) { - var addButton = document.querySelector('.ac'); - if (addButton) { - addButton.style.display = 'block'; + let unique_param = uniqueId + '_branch_table_pk'; + console.log('unique_param', unique_param); + let other_id = $('#' + unique_param).val(); + console.log('other_id', other_id); + + contactSection.parentNode.removeChild(contactSection); + contactCount--; + + if (contactCount < 3) { + var addButton = document.querySelector('.ac'); + if (addButton) { + addButton.style.display = 'block'; + } + } + + if(other_id){ + removeLevelContacts(other_id); + } + + }else{ + + $("#name").val(''); + $("#email").val(''); + $("#mobile").val(''); + $("#designation").val(''); + + let first_id = $('#branch_table_pk').val(); + console.log('first_id', first_id); + if(first_id){ + removeLevelContacts(first_id); + } } } - } + }); } function storeButtonId(id) { @@ -839,6 +886,30 @@ function getContactsData() { return contacts; } +function removeLevelContacts(id){ + + let url = ''; + + let requestData = { + id: id, + }; + + // Send AJAX request + sendAjaxRequestForGlobal(url, 'GET', requestData, function(response) { + + console.log('Data fetched successfully:', response); + if (response.status == true) { + toastr.success(response.message, 'SUCCESS'); + } else { + toastr.warning(response.message, 'WARNING'); + } + + }, function(xhr, status, error) { + console.error('Error fetching data:', error); + console.error(xhr.responseText); + }); +} + \ No newline at end of file From cd2f69e1dca0ee1562b6f497b84c35984caec13a Mon Sep 17 00:00:00 2001 From: "venkatesh.r" Date: Wed, 16 Jul 2025 18:17:03 +0530 Subject: [PATCH 12/14] CHANGE_RV --- app/Views/hr_access_controll.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/Views/hr_access_controll.php b/app/Views/hr_access_controll.php index 06a89347..033b54cb 100644 --- a/app/Views/hr_access_controll.php +++ b/app/Views/hr_access_controll.php @@ -19,7 +19,7 @@
From ce8308c898dcd17df5fa5c39316170e7ca205b4b Mon Sep 17 00:00:00 2001 From: "venkatesh.r" Date: Wed, 16 Jul 2025 22:24:43 +0530 Subject: [PATCH 13/14] FIX_CD_DEPOSIT_SUMMARY_AND_TRANSACTION : RV --- app/Controllers/EmployeeRestController.php | 5 +- app/Models/ClientPolicyModel.php | 53 +++++++++++++++++----- app/Views/client_deposit_list.php | 5 +- 3 files changed, 48 insertions(+), 15 deletions(-) diff --git a/app/Controllers/EmployeeRestController.php b/app/Controllers/EmployeeRestController.php index 78e99a86..d8ec8b0e 100755 --- a/app/Controllers/EmployeeRestController.php +++ b/app/Controllers/EmployeeRestController.php @@ -2406,8 +2406,9 @@ class EmployeeRestController extends AdminController $temp['cd_ac_pk'] = $value->cd_ac_pk; $temp['insurer_name'] = $value->insurer_name; $temp['cd_master_account_no'] = $value->cd_master_account_no; - if (isset($result['balances'][$temp['insurer_id']])) { - $balance = $result['balances'][$temp['insurer_id']]->balance; + + if (isset($result['balances'][$temp['insurer_id'].'-'.$temp['cd_ac_pk']])) { + $balance = $result['balances'][$temp['insurer_id'].'-'.$temp['cd_ac_pk']]->balance; $temp['balance'] = $balance; } else { $temp['balance'] = "N/A"; diff --git a/app/Models/ClientPolicyModel.php b/app/Models/ClientPolicyModel.php index f571659e..1ad8e8bb 100755 --- a/app/Models/ClientPolicyModel.php +++ b/app/Models/ClientPolicyModel.php @@ -295,11 +295,23 @@ class ClientPolicyModel extends Model public function getDepositSummary($clientId, $insurerId, $cd_ac_pk) { + + $subQuery = $this->db->table('cash_deposit') + ->select('balance') + ->where('client_id', $clientId) + ->where('insurer_id', $insurerId) + ->where('cd_ac_pk', $cd_ac_pk) + ->where('is_active', 1) + ->orderBy('id', 'DESC') + ->limit(1) + ->getCompiledSelect(); + // Fetch the sum of credit and debit transactions and calculate the balance - return $this->db->table('cash_deposit') + $data = $this->db->table('cash_deposit') + ->select("($subQuery) AS balance", false) ->select('SUM(CASE WHEN transaction_type = "Credit" THEN amount ELSE 0 END) AS total_credit') ->select('SUM(CASE WHEN transaction_type = "Debit" THEN amount ELSE 0 END) AS total_withdraw') - ->select('SUM(CASE WHEN transaction_type = "Credit" THEN amount ELSE -amount END) AS balance') + // ->select('SUM(CASE WHEN transaction_type = "Credit" THEN amount ELSE -amount END) AS balance') ->select('SUM(CASE WHEN sub_type = 3 THEN amount ELSE 0 END) AS total_refund') ->where('client_id', $clientId) ->where('insurer_id', $insurerId) @@ -307,6 +319,9 @@ class ClientPolicyModel extends Model ->where('cash_deposit.is_active', 1) ->get() ->getRow(); + + // dd($this->db->getLastQuery()); + return $data; } // Inside your clientPolicyModel // Inside your clientPolicyModel @@ -347,7 +362,8 @@ class ClientPolicyModel extends Model foreach ($depositsummary as $summary) { $insurerId = $summary->insurer_id; - $balances[$insurerId] = $summary; + $cd_ac_pk = $summary->cd_ac_pk; + $balances[$insurerId . '-'. $cd_ac_pk] = $summary; } return $balances; @@ -366,20 +382,35 @@ class ClientPolicyModel extends Model // ->get() // ->getResult(); + // $sql = " + // SELECT cd.insurer_id, cd.cd_ac_pk, cd.balance + // FROM cash_deposit cd + // INNER JOIN ( + // SELECT insurer_id, MAX(id) AS max_id + // FROM cash_deposit + // WHERE client_id = ? + // AND is_active = 1 + // GROUP BY insurer_id + // ) latest ON cd.insurer_id = latest.insurer_id AND cd.id = latest.max_id + // ORDER BY cd.id DESC + // "; + $sql = " SELECT cd.insurer_id, cd.cd_ac_pk, cd.balance FROM cash_deposit cd - INNER JOIN ( - SELECT insurer_id, MAX(id) AS max_id + JOIN cd_master cdm ON cdm.id = cd.cd_ac_pk + JOIN ( + SELECT MAX(id) AS max_id FROM cash_deposit - WHERE client_id = ? - AND is_active = 1 - GROUP BY insurer_id - ) latest ON cd.insurer_id = latest.insurer_id AND cd.id = latest.max_id - ORDER BY cd.id DESC + WHERE is_active = 1 AND client_id = $id + GROUP BY insurer_id, cd_ac_pk + ) latest ON latest.max_id = cd.id + JOIN insurers on cd.insurer_id = insurers.id + WHERE cd.is_active = 1 AND cd.client_id = $id AND cdm.is_active = 1 + ORDER BY cd.insurer_id; "; - return $this->db->query($sql, [$id])->getResult(); + return $this->db->query($sql)->getResult(); } diff --git a/app/Views/client_deposit_list.php b/app/Views/client_deposit_list.php index ab076ebb..18f9fc29 100755 --- a/app/Views/client_deposit_list.php +++ b/app/Views/client_deposit_list.php @@ -38,9 +38,10 @@ ₹ insurer_id; + $cd_ac_pk = $value->cd_ac_pk; // Check if the balance information exists for the insurer - if (isset($balances[$insurerId])) { - $balance = $balances[$insurerId]->balance; + if (isset($balances[$insurerId . '-'. $cd_ac_pk])) { + $balance = $balances[$insurerId . '-'. $cd_ac_pk]->balance; echo $balance; } else { echo "N/A"; // Display "Not Available" if balance information is not present From bf6924f85525dcabbddaf5d3f010db0b5674fad4 Mon Sep 17 00:00:00 2001 From: "venkatesh.r" Date: Thu, 17 Jul 2025 09:27:37 +0530 Subject: [PATCH 14/14] CHNAGE_HR_ACTIVITY : RV --- app/Views/client_onboarding.php | 2 +- app/Views/hr_activity_history.php | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/app/Views/client_onboarding.php b/app/Views/client_onboarding.php index ac83d0c8..0cc8e7d7 100755 --- a/app/Views/client_onboarding.php +++ b/app/Views/client_onboarding.php @@ -317,7 +317,7 @@ body {