diff --git a/app/Config/Routes.php b/app/Config/Routes.php index 2dd7720b..b3e0c0f1 100644 --- a/app/Config/Routes.php +++ b/app/Config/Routes.php @@ -48,6 +48,7 @@ $routes->post("user_synchronization", "Users::user_synchronization"); $routes->get("book_list/", "Books::index"); $routes->get("book_page/(:any)", "Books::book_page/$1"); $routes->post("insert_books", "Books::insert_books"); +$routes->get("delete_books/(:any)", "Books::delete_books/$1"); # Site-Setting Routes $routes->get("sitesetting_list/", "Settings::index"); @@ -69,6 +70,7 @@ $routes->get("delete_customer/(:any)", "Customer::delete_customer/$1"); $routes->get("scheme_list/", "Scheme::index"); $routes->get("new_scheme/(:any)", "Scheme::new_scheme/$1"); $routes->post("insert_scheme/", "Scheme::insert_scheme"); +$routes->get("delete_scheme/(:any)", "Scheme::delete_scheme/$1"); # Api integration $routes->get("apiintegration", "Home::apiintegration"); diff --git a/app/Controllers/Books.php b/app/Controllers/Books.php index f5ef9fb7..6001c306 100755 --- a/app/Controllers/Books.php +++ b/app/Controllers/Books.php @@ -13,9 +13,11 @@ class Books extends BaseController $session_role = get_user_role(); $session_bid = get_business_id(); - $where = ['books.isactive' => 1]; if (!empty($session_role) && $session_role !== "sadmin") { $where = ['books.business_id' => $session_bid, 'books.isactive' => 1]; + }else{ + $where = ['books.isactive !=' => NULL]; + } $model = new BooksModel(); @@ -121,14 +123,14 @@ class Books extends BaseController $BooksModel->insert($data); } else { // It's an update operation - $isactive = $this->request->getPost('bcheckbox'); + $isactive = $this->request->getPost('isactive'); $data['isactive'] = ($isactive == 'on') ? 1 : 0; $data['updated_by'] = $session_uid; $BooksModel->update($book_id, $data); } return redirect()->route('book_list'); } - public function delete_book($id) + public function delete_books($id) { $BooksModel = new BooksModel(); diff --git a/app/Controllers/Customer.php b/app/Controllers/Customer.php index 102513c7..6f74830f 100644 --- a/app/Controllers/Customer.php +++ b/app/Controllers/Customer.php @@ -7,23 +7,34 @@ use App\Models\CustomerModel; class Customer extends BaseController { - ## For Business Listing + ## For Customer Listing public function index() { helper('session'); - $session_bid = get_business_id(); - $session_uid = get_logged_user_id(); + if (is_session_active()) { + $session_role = get_user_role(); + $session_bid = get_business_id(); + if (!empty($session_role) && $session_role !== "sadmin") { + $where = ['isactive'=>1,'business_id'=>(int)$session_bid]; + }else{ $where = ['isactive != '=>NULL];} + $CustomerModel = new CustomerModel(); + + $data['page_name'] = 'Customer Listing'; + $data['customer'] = $CustomerModel->where($where)->findAll(); + + // print_r($data); die(); + + $this->render_page('customer_list', $data); + }else{ + return redirect()->to('login'); + } - $CustomerModel =new CustomerModel(); - - $data['page_name'] = 'Customer Listing'; - $data['customer'] = $CustomerModel->findAll(); - // print_r($data); die(); - - $this->render_page('customer_list', $data); } + ## load Customer page public function new_customer($id) { + helper('session'); + $session_bid = get_business_id(); if ($id === '0') { $data['page_name'] = 'Add Customer'; $data['customer'] = []; @@ -32,96 +43,78 @@ class Customer extends BaseController $model = new CustomerModel(); $model->setTable('customers'); $edit_user_details = $model->where(['customer_id' => $id])->first(); - + $data['customer'] = $edit_user_details; } - - + + $data['session_bid'] = $session_bid; $this->render_page('customer_form', $data); } + ## insert and updation for customer public function insert_customer() { helper('session'); $session_bid = get_business_id(); $session_uid = get_logged_user_id(); - $validationRule = [ - 'userfile' => [ - 'label' => 'Image File', - 'rules' => [ - 'uploaded[cfile]', - 'is_image[cfile]', - 'mime_in[cfile,image/jpg,image/jpeg,image/gif,image/png,image/webp]', + $model = new CustomerModel(); + $data = [ + 'first_name' => $this->request->getPost('cfname'), + 'last_name' => $this->request->getPost('csname'), + 'mobile_no' => $this->request->getPost('cmobile'), + 'address' => $this->request->getPost('address'), + 'city' => $this->request->getPost('ccity'), + 'email' => $this->request->getPost('cmail'), + 'state' => $this->request->getPost('cstate'), + 'postal_code' => $this->request->getPost('czip'), + 'country' => $this->request->getPost('ccountry'), + 'type' => $this->request->getPost('ctype'), + 'date_of_birth' => $this->request->getPost('dob'), + 'gender' => $this->request->getPost('gen'), + 'profile_picture' => $this->request->getPost('cfile'), + 'mode' => $this->request->getPost('cmode'), + 'business_id' => $this->request->getPost('business_id') - ], - ], ]; - if (!$this->validate($validationRule)) { - $data = ['errors' => $this->validator->getErrors()]; - print_r($data); - return 'hello'; - } - $img = $this->request->getFile('cfile'); - if (!$img->hasMoved()) { - $filepath = WRITEPATH . 'uploads/' . $img->store(); - $fileName = $img->getName(); - $CustomerModel =new CustomerModel(); - $data = [ - 'first_name' => $this->request->getPost('cfname'), - 'last_name' => $this->request->getPost('csname'), - 'mobile_no' => $this->request->getPost('cmobile'), - 'address' => $this->request->getPost('address'), - 'city' => $this->request->getPost('ccity'), - 'email' => $this->request->getPost('cmail'), - 'state' => $this->request->getPost('cstate'), - 'postal_code' => $this->request->getPost('czip'), - 'country'=> $this->request->getPost('ccountry'), - 'type'=> $this->request->getPost('ctype'), - 'date_of_birth'=> $this->request->getPost('dob'), - 'gender'=>$this->request->getPost('gen'), - 'profile_picture'=>$this->request->getPost('cfile'), - 'mode'=>$this->request->getPost('cmode'), - 'isactive' => $this->request->getPost('ccheckbox') ? 1 : 0 - ]; - $customer_id = $this->request->getPost('customer_id'); // Get the business ID for update + $customer_id = $this->request->getPost('customer_id'); // Get the business ID for update - if (empty($customer_id)) { - // It's an insert operation - $data['isactive'] = 1; - $data['created_by'] = $session_uid; - $CustomerModel->insert($data); - } else { - // It's an update operation - $isactive = $this->request->getPost('isactivce'); - $data['isactive'] = ($isactive == 'on') ? 1 : 0; - $data['updated_by'] = $session_uid; - $CustomerModel->update($customer_id, $data); - } - return redirect()->route('customer_list'); + if (empty($customer_id)) { + // It's an insert operation + $data['isactive'] = 1; + $data['created_by'] = $session_uid; + //print_r($data);die; + $model->insert($data); + } else { + // It's an update operation + $isactive = $this->request->getPost('isactivce'); + $data['isactive'] = ($isactive == 'on') ? 1 : 0; + $data['updated_by'] = $session_uid; + $model->update($customer_id, $data); } + return redirect()->route('customer_list'); } + + ## delete for customer public function delete_customer($id) { - $CustomerModel =new CustomerModel(); - + $CustomerModel = new CustomerModel(); + // Check if the business ID exists $existingCustomer = $CustomerModel->find($id); if (!$existingCustomer) { - + // return redirect()->to(base_url('Business/index'))->with('error', 'Business not found.'); return redirect()->route('customer_list'); } helper('session'); $session_uid = get_logged_user_id(); - + // Delete the business record $data['isactive'] = 0; - $data['updated_by'] = $session_uid; - $CustomerModel->update($id, $data); - print_r($data); die(); + $data['updated_by'] = $session_uid; + $CustomerModel->update($id, $data); + //$BusinessModel->delete($id); + + // return redirect()->to(base_url('Business/index'))->with('success', 'Business deleted successfully.'); return redirect()->route('customer_list'); } -} - - - - +} \ No newline at end of file diff --git a/app/Controllers/Scheme.php b/app/Controllers/Scheme.php index 14aecabc..fcf4d6b9 100644 --- a/app/Controllers/Scheme.php +++ b/app/Controllers/Scheme.php @@ -69,4 +69,27 @@ class Scheme extends BaseController } return redirect()->route('scheme_list'); } - } \ No newline at end of file + public function delete_scheme($id) + { + $SchemeModel = new SchemeModel(); + + // Check if the business ID exists + $existingCustomer = $SchemeModel->find($id); + if (!$existingCustomer) { + // return redirect()->to(base_url('Business/index'))->with('error', 'Business not found.'); + return redirect()->route('scheme_list'); + } + + helper('session'); + $session_uid = get_logged_user_id(); + // Delete the business record + $data['isactive'] = 0; + $data['updated_by'] = $session_uid; + $SchemeModel->update($id, $data); + //$BusinessModel->delete($id); + + // return redirect()->to(base_url('Business/index'))->with('success', 'Business deleted successfully.'); + return redirect()->route('scheme_list'); + } + } + \ No newline at end of file diff --git a/app/Controllers/Users.php b/app/Controllers/Users.php index 800fec88..bbf8543a 100755 --- a/app/Controllers/Users.php +++ b/app/Controllers/Users.php @@ -89,16 +89,16 @@ class Users extends BaseController return 'hello'; } $img = $this->request->getFile('profile_picture'); - $user_id = $this->request->getPost('user_id'); + $user_id = $this->request->getPost('user_id'); $business_id = $this->request->getPost('business_id'); - $filePath ='public/uploads/' . $this->request->getPost('profile_picture'); + $filePath = 'public/uploads/' . $this->request->getPost('profile_picture'); ## File Already Existing or not if ($img->isValid() && !$img->hasMoved()) { $fileName = $img->getName(); $img->move('public/uploads/', $fileName); - - + + // Delete the previous image file if it exists if ($user_id) { $previousFileName = $this->request->getPost('previous_ufile'); @@ -109,11 +109,11 @@ class Users extends BaseController } else { $fileName = $this->request->getPost('previous_ufile', ''); // Use the previous filename if no new image is provided } - + $UsersModel = new UsersModel(); $data = [ - + 'user_name' => $this->request->getPost('user_name'), 'profile_picture' => $fileName, 'city' => $this->request->getPost('city'), @@ -127,9 +127,9 @@ class Users extends BaseController 'password' => $this->request->getPost('password'), 'mobile_no' => $this->request->getPost('mobile_no'), 'date_of_birth' => $this->request->getPost('date_of_birth'), - 'address'=> $this->request->getPost('address'), - 'gender'=> $this->request->getPost('gender'), - 'business_id'=>$business_id + 'address' => $this->request->getPost('address'), + 'gender' => $this->request->getPost('gender'), + 'business_id' => $business_id ]; $user_id = $this->request->getPost('user_id'); // Get the business ID for update @@ -148,4 +148,4 @@ class Users extends BaseController } return redirect()->route('user_list'); } -} \ No newline at end of file +} diff --git a/app/Models/CustomerModel.php b/app/Models/CustomerModel.php index ad076126..15e23421 100644 --- a/app/Models/CustomerModel.php +++ b/app/Models/CustomerModel.php @@ -9,7 +9,7 @@ class CustomerModel extends Model { protected $table = 'customers'; protected $primaryKey = 'customer_id '; - protected $allowedFields = ['customer_id ','first_name','last_name','email','mobile_no','country','state','postal_code' ,'address','profile_picture','date_of_birth','gender','mode','type','isactive']; + protected $allowedFields = ['customer_id ','first_name','last_name','email','mobile_no','country','state','postal_code' ,'address','profile_picture','date_of_birth','gender','mode','type','isactive','business_id']; public function insertCustomer($data) { diff --git a/app/Views/book_form.php b/app/Views/book_form.php index ee73befd..659ae809 100644 --- a/app/Views/book_form.php +++ b/app/Views/book_form.php @@ -4,10 +4,10 @@

- getFlashdata('success')): ?> -
getFlashdata('success') ?>
+ getFlashdata('success')) : ?> +
getFlashdata('success') ?>
-
" > + ">
@@ -31,14 +31,14 @@
-
- - coverpicture -
- +
+ + coverpicture +
+
-
+
@@ -46,7 +46,7 @@
- +
@@ -69,12 +69,12 @@
- -
- > - -
-
+ +
+ > + +
+
-
-
- - + + + + \ No newline at end of file diff --git a/app/Views/scheme_form.php b/app/Views/scheme_form.php index bcfefdc8..84d64535 100644 --- a/app/Views/scheme_form.php +++ b/app/Views/scheme_form.php @@ -7,36 +7,52 @@
- +
- - + +
- - -
+ + +
- - + + +
+ +
+ +
- -
- - -
-
- - -
- > -
+ + + +
+ > + +
+
+
- +
- - +
- - - - - - - - - - - \ No newline at end of file + \ No newline at end of file diff --git a/app/Views/scheme_list.php b/app/Views/scheme_list.php index b1ea05c4..3a35b535 100644 --- a/app/Views/scheme_list.php +++ b/app/Views/scheme_list.php @@ -40,7 +40,7 @@ " class="edit-button"> - " class="edit-button"> + " class="delete-button"> diff --git a/app/Views/user_form.php b/app/Views/user_form.php index 5ba8b552..97214ea5 100644 --- a/app/Views/user_form.php +++ b/app/Views/user_form.php @@ -38,7 +38,6 @@
-<<<<<<< HEAD
-======= - - -
Please provide.
-
-
- - -
Please provide.
-
-
- - -
Please provide.
-
- -
-
- - -
Please provide.
-
-
- - -
-
- - -
Please provide.
-
-
-
- -
- - Business Logo -
- -
-
-
- - - - -
-
-
-
- - -
Please provide.
-
-
-
-
- - -
Please provide.
-
-
- - -
Please provide.
-
-
- - -
Please provide.
-
-
- -
-
- - -
-
- - - - - -
- > - -
-
- -
- - - " class="btn btn-secondary waves-effect">Cancel - -
->>>>>>> ee8a2ba619d361191bbd1f7670242697a47ecea7 -<<<<<<< HEAD -======= - - ->>>>>>> ee8a2ba619d361191bbd1f7670242697a47ecea7