diff --git a/app/Config/Routes.php b/app/Config/Routes.php index 3437c08..f517640 100644 --- a/app/Config/Routes.php +++ b/app/Config/Routes.php @@ -40,7 +40,7 @@ use CodeIgniter\Router\RouteCollection; $routes->match(['get','post'],'/client_branch_list','ClientController::client_branch_list'); $routes->post('add_client_branch','ClientController::add_client_branch'); $routes->get('get_client_branch/(:any)','ClientController::get_client_branch/$1'); - $routes->get('delete_client_branch/(:any)','ClientController::delete_client_branch/$1'); + $routes->post('status_client_branch','ClientController::status_client_branch'); $routes->post('client_upload','ClientController::client_upload'); diff --git a/app/Controllers/BusinessController.php b/app/Controllers/BusinessController.php index 3c8d217..27f3776 100644 --- a/app/Controllers/BusinessController.php +++ b/app/Controllers/BusinessController.php @@ -46,7 +46,7 @@ class BusinessController extends BaseController if ($business_id === '0') { $data['business'] = []; - $data['page_name']="Add Business"; + $data['page_name']="Create Business"; } else if ($business_id !== '0') { $BusinessModel = new BusinessModel(); diff --git a/app/Controllers/ClientController.php b/app/Controllers/ClientController.php index dd333d0..c7b0993 100644 --- a/app/Controllers/ClientController.php +++ b/app/Controllers/ClientController.php @@ -323,22 +323,26 @@ class ClientController extends BaseController - public function delete_client_branch($branch_id) + public function status_client_branch() { - $where = ['id' => $branch_id]; // Assuming 'isactive' is a column in your database - $existingBranch = $this->ClientBranchModel->where($where)->first(); - - if ($existingBranch) { - $data['is_active'] = 0; - - if ($this->ClientBranchModel->update($branch_id, $data)) { - session()->setFlashdata('success', 'Deleted successfully.'); - $this->logger->info("Branch: has been Inactivated successfully. Inactivated ID = ".$branch_id); + try { + $client_branch_id = $this->request->getPost('client_branch_id'); + $is_active = $this->request->getPost('is_active'); + $data = [ + 'is_active' => $is_active + ]; + + $updated = $this->ClientBranchModel->update($client_branch_id, $data); + + if ($updated) { + return $this->respond(['status' => 'success','code' => 200,'data' => true],200); + } else { + $result = "No Match's"; + return $this->respond(['status' => 'failed','code' => 404,'data' => $result],404); } - } - - - return redirect()->to('client_branch_list'); + } catch (\Exception $exception) { + return $this->respond(['status' => 'failed','code' => 500,'data' => $exception],500); + } } diff --git a/app/Models/BranchModel.php b/app/Models/BranchModel.php index 1b364aa..831eca7 100644 --- a/app/Models/BranchModel.php +++ b/app/Models/BranchModel.php @@ -5,7 +5,7 @@ class BranchModel extends Model { protected $table = 'branches'; protected $primaryKey = 'branch_id'; - protected $allowedFields = ['business_id','branch_id','branch_name','gstno','email','contact_1','contact_2','address','city','state','country','postal_code','state_code','isactive']; + protected $allowedFields = ['business_id','branch_id','branch_name','gstno','email','contact','address','city','state','country','postal_code','state_code','isactive']; public function getBranchesByBusinessId($business_id) { diff --git a/app/Views/branch_list.php b/app/Views/branch_list.php index a08bbb7..491d8f5 100644 --- a/app/Views/branch_list.php +++ b/app/Views/branch_list.php @@ -57,7 +57,7 @@ - + Inactive @@ -149,14 +149,8 @@
- - -
-
-
-
- - + +
@@ -227,8 +221,7 @@ business_id: $('#business').val(), gstno: $('#gst_no').val(), email: $('#email').val(), - contact_1: $('#contact_1').val(), - contact_2: $('#contact_2').val(), + contact: $('#contact').val(), country: $('#country').val(), state_code: $('#state_code').val(), branch_name: $('#branch_name').val(), @@ -283,8 +276,7 @@ $('#branch_name').val(response.branch_name); $('#gst_no').val(response.gstno); $('#email').val(response.email); - $('#contact_1').val(response.contact_1); - $('#contact_2').val(response.contact_2); + $('#contact').val(response.contact); $('#address').val(response.address); $('#branch_id').val(response.branch_id); $('#city').val(response.city); diff --git a/app/Views/business.php b/app/Views/business.php index 3d25d31..9c10843 100644 --- a/app/Views/business.php +++ b/app/Views/business.php @@ -68,18 +68,11 @@
- +
-
-
- -
- -
-
-
+
diff --git a/app/Views/business_form.php b/app/Views/business_form.php index ee2a0c2..6b8d1ca 100644 --- a/app/Views/business_form.php +++ b/app/Views/business_form.php @@ -8,10 +8,14 @@
-
+
+
+
-

Create Business

+

+ Back +