From 537cdf834e718c90ac9fa3eafe4f4be4070cee23 Mon Sep 17 00:00:00 2001 From: vadivelJ96 Date: Fri, 3 Oct 2025 18:18:13 +0530 Subject: [PATCH] CHANGE_Pre_app_having_post_branch_id - VADIVEL J 2025-09-03 --- app/Config/Routes.php | 2 + app/Controllers/ClientController.php | 104 ++++++++++++++++ app/Models/ClientBranchModel.php | 1 + app/Views/client_branch.php | 18 +++ app/Views/client_onboarding.php | 180 +++++++++++++++++++++++++++ app/Views/layout/footer.php | 23 ++++ 6 files changed, 328 insertions(+) diff --git a/app/Config/Routes.php b/app/Config/Routes.php index 896ca58..285ca8e 100755 --- a/app/Config/Routes.php +++ b/app/Config/Routes.php @@ -97,6 +97,8 @@ $routes->group("/client", ["filter" => "authMVC"], function ($routes) { $routes->post("edit", "ClientController::editClientBranch"); $routes->get("list/(:any)", "ClientController::getSingleBranchDataById/$1"); $routes->get("remove/(:any)", "ClientController::removeClientBranch/$1"); + $routes->post("auto_fetch_branch","ClientController::auto_fetch_branch"); + $routes->post("auto_fetch_branch_details","ClientController::auto_fetch_branch_details"); }); $routes->group("relation", ["filter" => "authMVC"], function ($routes) { diff --git a/app/Controllers/ClientController.php b/app/Controllers/ClientController.php index fdf55ca..6646aa6 100755 --- a/app/Controllers/ClientController.php +++ b/app/Controllers/ClientController.php @@ -481,6 +481,10 @@ class ClientController extends AdminController // dd($data['placeHolders']); + + // auto fetch client list and branch list from pre + $data['auto_fetch_client_list'] = $this->getClientListFromPost(); + echo view('layout/header', $headerData); echo view('client_onboarding', $data); echo view('layout/footer'); @@ -620,6 +624,8 @@ class ClientController extends AdminController $editData['client_policy']['role'] = get_role_id(); $editData['notification'] = $this->notificationModel->select('template_name,enabled')->where('client_id', $id)->findAll(); $editData['placeHolders'] = ['member_name', 'member_mobile', 'nhance_logo', 'tpa_id', 'ecard_download_link', 'client_logo', 'policy_no', 'member_summary', 'app_link', 'post_enrollment_app_link', 'client_name']; + + $editData['auto_fetch_client_list'] = $this->getClientListFromPost(); // dd($editData); echo view('layout/header', $headerData); @@ -5129,4 +5135,102 @@ class ClientController extends AdminController return $this->respond(['status' => true, 'message' => 'Demo client data wiped successfully'], 200); } + + + + private function getClientListFromPost (){ + + $db2 = \Config\Database::connect('postDB'); + + $auto_fetch_client_list = $db2->table('clients') + ->select('id,client_name') + ->where('is_active',1) + ->get()->getResultArray()??[]; + + return $auto_fetch_client_list; + + } + + public function auto_fetch_branch(){ + + $data = $this->request->getPost(); + + $db2 = \Config\Database::connect('postDB'); + + $auto_fetch_branch_list = $db2->table('client_branch') + ->select('id,branch_name') + ->where('client_id',$data['client_id']) + ->where('is_active',1) + ->get()->getResultArray()??[]; + + return + + empty($auto_fetch_branch_list) + + ? $this->response->setJSON([ + 'status' => false, + 'message' => 'branch list is empty', + 'data' => [] + ])->setStatusCode(400) + + : $this->response->setJSON([ + 'status' => true, + 'message' => 'branch list is found' , + 'data' => $auto_fetch_branch_list + ])->setStatusCode(200); + } + + public function auto_fetch_branch_details(){ + + $data = $this->request->getPost(); + + $db2 = \Config\Database::connect('postDB'); + + $auto_fetch_branch_details = $db2->table('client_branch') + ->where('client_id',$data['client_id']) + ->where('id',$data['branch_id']) + ->where('is_active',1) + ->get()->getResultArray()??[]; + + return empty($auto_fetch_branch_details) + + ? $this->response->setJSON([ + 'status' => false, + 'message' => 'branch details is empty', + 'data' => [] + ])->setStatusCode(400) + + : $this->response->setJSON([ + 'status' => true, + 'message' => 'branch details found' , + 'data' => $auto_fetch_branch_details + ])->setStatusCode(200); + + } + + + + + + + + + + + + + + + + + + + + + + + + + + } diff --git a/app/Models/ClientBranchModel.php b/app/Models/ClientBranchModel.php index 100f503..695cd16 100755 --- a/app/Models/ClientBranchModel.php +++ b/app/Models/ClientBranchModel.php @@ -25,6 +25,7 @@ class ClientBranchModel extends Model "gst", "sez", "units", + "post_branch_id" ]; public function getBranchAndContactByBranchId($branch_id){ diff --git a/app/Views/client_branch.php b/app/Views/client_branch.php index 9ef5c5a..0dc28eb 100755 --- a/app/Views/client_branch.php +++ b/app/Views/client_branch.php @@ -70,6 +70,12 @@
+ +
+ +
+
+
+ +
+
+
+ + + + + + + + + + diff --git a/app/Views/layout/footer.php b/app/Views/layout/footer.php index 9a52853..5026672 100755 --- a/app/Views/layout/footer.php +++ b/app/Views/layout/footer.php @@ -932,6 +932,29 @@ function confirmActionSweertAlert(message = "Are you sure?", confirmText = "Yes, + + \ No newline at end of file