From ad2a9b98e0a41cf0ce6d79f41330d394328c1850 Mon Sep 17 00:00:00 2001 From: bitbucket Date: Fri, 5 Apr 2024 17:40:08 +0530 Subject: [PATCH] GWM:merging --- app/Controllers/Client.php | 2 +- app/Controllers/Products.php | 15 ++++++++++++--- 2 files changed, 13 insertions(+), 4 deletions(-) diff --git a/app/Controllers/Client.php b/app/Controllers/Client.php index b4ce784..a971e4d 100644 --- a/app/Controllers/Client.php +++ b/app/Controllers/Client.php @@ -88,7 +88,7 @@ class Client extends BaseController public function delete_client($client_id) { $model = new ClientModel(); - $where = ['client_id' => $client_id, 'isactive' => 1]; // Assuming 'isactive' is a column in your database + $where = ['client_id' => $client_id, 'isactive' => 1 , 'branch_id' => $this->session->get('logged_user_branch_id')]; // Assuming 'isactive' is a column in your database $existingBusiness = $model->where($where)->first(); if ($existingBusiness) { diff --git a/app/Controllers/Products.php b/app/Controllers/Products.php index 990cbf0..5832359 100644 --- a/app/Controllers/Products.php +++ b/app/Controllers/Products.php @@ -8,12 +8,19 @@ use App\Models\ProductModel; class Products extends BaseController { + + public $session; + public function __construct() + { + + $this->session = session(); + } public function product_index() { $ProductModel = new ProductModel(); - $products=$ProductModel->findAll(); + $products = $ProductModel->where('branch_id',$this->session->get('logged_user_branch_id'))->findAll(); $data['products']=$products; return view('product_list',$data); @@ -66,7 +73,8 @@ class Products extends BaseController 'qty'=> $this->request->getPost('qty_in_stock'), 'qty_in_demand'=> $this->request->getPost('qty_in_demand'), 'description' => $this->request->getPost('description'), - 'isactive' => 1 // Assuming this is a default value or handled separately + 'isactive' => 1 , + 'branch_id' => $this->session->get('logged_user_branch_id') ]; // print_r($data);die; @@ -84,10 +92,11 @@ class Products extends BaseController return redirect()->to('product_index'); } + public function delete_product($product_id) { $model = new ProductModel(); - $where = ['product_id' => $product_id, 'isactive' => 1]; // Assuming 'isactive' is a column in your database + $where = ['product_id' => $product_id, 'isactive' => 1 , 'branch_id' => $this->session->get('logged_user_branch_id')]; // Assuming 'isactive' is a column in your database $existingProduct = $model->where($where)->first(); if ($existingProduct) {