diff --git a/.env b/.env index c96b9e02..ee3e3ec5 100644 --- a/.env +++ b/.env @@ -30,7 +30,7 @@ CI_ENVIRONMENT = development # DATABASE #-------------------------------------------------------------------- - database.default.hostname = localhost + database.default.hostname = 127.0.0.1 database.default.database = bbbp_uat database.default.username = root database.default.password = '' @@ -38,7 +38,7 @@ CI_ENVIRONMENT = development database.default.DBPrefix = database.default.port = 3306 - database.tests.hostname = localhost + database.tests.hostname = 127.0.0.1 database.tests.database = BBVPB-local database.tests.username = root database.tests.password = '' diff --git a/app/Config/Routes.php b/app/Config/Routes.php index dc1f5c72..9d4811ef 100644 --- a/app/Config/Routes.php +++ b/app/Config/Routes.php @@ -61,8 +61,10 @@ $routes->get("subscribers_list/", "Home::subscribers_list"); $routes->get("add_subscribers/", "Home::add_subscribers"); $routes->get("edit_subscribers/", "Home::edit_subscribers"); - - +#custome routes +$routes->get("customer_list/", "Customer::index"); +$routes->get("new_customer/(:any)", "Customer::new_customer/$1"); +$routes->post("insert_customer/", "Customer::insert_customer"); /* * -------------------------------------------------------------------- diff --git a/app/Controllers/Business.php b/app/Controllers/Business.php index 4b5fca83..9c51d6ce 100644 --- a/app/Controllers/Business.php +++ b/app/Controllers/Business.php @@ -76,14 +76,20 @@ class Business extends BaseController 'business_logo'=>$this->request->getPost('bfile'), 'isactive' => $this->request->getPost('bcheckbox') ? 1 : 0 ]; - + $business_id = $this->request->getPost('business_id'); // Get the business ID for update + + if (empty($business_id)) { + // It's an insert operation $BusinessModel->insert($data); - + } else { + // It's an update operation + $BusinessModel->update($business_id, $data); } $this->index(); } - public function delete_business($id) + } + public function delete_business($id) { $BusinessModel = new BusinessModel(); @@ -98,7 +104,8 @@ class Business extends BaseController $BusinessModel->delete($id); // return redirect()->to(base_url('Business/index'))->with('success', 'Business deleted successfully.'); - return redirect()->route('business_list')->with('success', 'Business deleted successfully.'); + return redirect()->route('business_list'); } } - \ No newline at end of file + + diff --git a/app/Controllers/Customer.php b/app/Controllers/Customer.php new file mode 100644 index 00000000..26e07483 --- /dev/null +++ b/app/Controllers/Customer.php @@ -0,0 +1,70 @@ +get('user_role'); + $session_bid = $session->get('business_id'); + $CustomerModel =new CustomerModel(); + + $data['page_name'] = 'Customer Listing'; + $data['customer'] = $CustomerModel->findAll(); + // print_r($data); die(); + + $this->render_page('customer_list', $data); + } + public function new_customer($id) + { + if ($id === '0') { + $data['page_name'] = 'Add Customer'; + $data['customer'] = []; + } else if ($id !== '0') { + $data['page_name'] = 'Edit Customer'; + $model = new BusinessModel(); + $model->setTable('business'); + $edit_user_details = $model->where(['business_id ' => $id])->first(); + + $data['businesses'] = $edit_user_details; + } + + + $this->render_page('customer_form', $data); + } + public function insert_customer() + { + + $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 + ]; + + + + $CustomerModel->insert($data); + + + $this->index(); + } + } diff --git a/app/Models/CustomerModel.php b/app/Models/CustomerModel.php new file mode 100644 index 00000000..ad076126 --- /dev/null +++ b/app/Models/CustomerModel.php @@ -0,0 +1,19 @@ +insert($data); + } +} +?> \ No newline at end of file diff --git a/app/Views/customer_form.php b/app/Views/customer_form.php new file mode 100644 index 00000000..17e60d34 --- /dev/null +++ b/app/Views/customer_form.php @@ -0,0 +1,131 @@ +
+
+
+
+

+

+
+
+
+ +
+ + +
+
+ + +
+
+ +
+
+ + +
+ +
+ + +
+
+ +
+
+ + +
+
+ + +
+
+ +
+
+ + + + +
+ +
+ + +
+
+ +
+
+ + +
+ + +
+ + +
+
+
+
+ + +
+ +
+ + +
+ + + +
+ + +
+
+ + +
+ +
+ > + +
+
+ +
+ + + +
+
+ + + + + +
+
+
+
+
+ + + + + + + + \ No newline at end of file diff --git a/app/Views/customer_list.php b/app/Views/customer_list.php new file mode 100644 index 00000000..c1f3c5fd --- /dev/null +++ b/app/Views/customer_list.php @@ -0,0 +1,64 @@ +
+
+
+
+ + + + +
+

+
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
First NameLast NameMobile NumberEmailAddressCountryStateCityTypeMode
+
+
+
+
+
+ + diff --git a/app/Views/template/header.php b/app/Views/template/header.php index 488f5a11..8b4ace90 100644 --- a/app/Views/template/header.php +++ b/app/Views/template/header.php @@ -132,26 +132,23 @@
  • "> - + Business -
  • - - - Customers - +
  • +
  • + "> + + Customer -
    - -
    -
  • + +
  • + "> + + Subscription + +
  • +