diff --git a/app/Config/Routes.php b/app/Config/Routes.php index b3e0c0f1..dc98c576 100644 --- a/app/Config/Routes.php +++ b/app/Config/Routes.php @@ -42,7 +42,8 @@ $routes->get('dashboard/', 'Home::index'); # Users Routes $routes->get("user_list/", "Users::index"); $routes->get("user_page/(:any)", "Users::user_page/$1"); -$routes->post("user_synchronization", "Users::user_synchronization"); +$routes->post("insert_users", "Users::insert_users"); +$routes->get("delete_user/(:any)", "Users::delete_user/$1"); # Books Routes $routes->get("book_list/", "Books::index"); @@ -54,6 +55,7 @@ $routes->get("delete_books/(:any)", "Books::delete_books/$1"); $routes->get("sitesetting_list/", "Settings::index"); $routes->get("sitesetting_page/(:any)", "Settings::sitesetting_page/$1"); $routes->post("sitesetting_synchronization", "Settings::sitesetting_synchronization"); +$routes->get("delete_sitesetting/(:any)", "Books::delete_sitesetting/$1"); # Business Routes $routes->get("business_list/", "Business::index"); @@ -61,18 +63,19 @@ $routes->get("new_bussiness/(:any)", "Business::new_bussiness/$1"); $routes->post("insert_business/", "Business::insert_business"); $routes->get("delete_business/(:any)", "Business::delete_business/$1"); -#custome routes +# Custome Routes $routes->get("customer_list/", "Customer::index"); $routes->get("new_customer/(:any)", "Customer::new_customer/$1"); -$routes->post("insert_customer/", "Customer::insert_customer"); +$routes->post("insert_customer", "Customer::insert_customer"); $routes->get("delete_customer/(:any)", "Customer::delete_customer/$1"); -#scheme routes + +# Scheme Routes $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 +# Api integration Routes $routes->get("apiintegration", "Home::apiintegration"); /* * -------------------------------------------------------------------- diff --git a/app/Controllers/Books.php b/app/Controllers/Books.php index 6001c306..00b1fd99 100755 --- a/app/Controllers/Books.php +++ b/app/Controllers/Books.php @@ -4,35 +4,36 @@ namespace App\Controllers; use App\Models\BooksModel; + class Books extends BaseController { + ## For Book Listing public function index() { helper('session'); - if (is_session_active()) { - $session_role = get_user_role(); - $session_bid = get_business_id(); + if (is_session_active()) { + $session_role = get_user_role(); + $session_bid = get_business_id(); - if (!empty($session_role) && $session_role !== "sadmin") { - $where = ['books.business_id' => $session_bid, 'books.isactive' => 1]; - }else{ - $where = ['books.isactive !=' => NULL]; + if (!empty($session_role) && $session_role !== "sadmin") { + $where = ['books.business_id' => $session_bid, 'books.isactive' => 1]; + } else { + $where = ['books.isactive !=' => NULL]; + } + $model = new BooksModel(); + $model->setTable('books'); + $book_details = $model->where($where)->orderBy('book_id', 'DESC')->findAll(); + $data['page_name'] = 'Book Details'; + $data['details'] = $book_details; + $this->render_page('book_list', $data); + } else { + // Session is not active or user is not logged in + return redirect()->to('login'); } - - $model = new BooksModel(); - $model->setTable('books'); - $book_details = $model->where($where)->orderBy('book_id', 'DESC')->findAll(); - $data['page_name'] = 'Book Details'; - $data['details'] = $book_details; - $this->render_page('book_list', $data); - } else { - // Session is not active or user is not logged in - return redirect()->to('login'); - } } - ## To Load Book Add/Update page + ## To Load Book Form (Add/Update) public function book_page($id) { helper('session'); @@ -42,23 +43,21 @@ class Books extends BaseController $data['details'] = []; } else if ($id !== '0') { $data['page_name'] = 'Edit Book'; - $model = new UsersModel(); - $model->setTable('users'); - $details = $model->where(['user_id' => $id, 'isactive' => 1])->first(); + $model = new BooksModel(); + $model->setTable('books'); + $details = $model->where(['book_id' => $id, 'isactive' => 1])->first(); $data['details'] = $details; } - $this->render_page('user_form', $data); + $this->render_page('book_form', $data); } - - ## To Save/Update Book Data on DB. + ## For inserting/updating details of book public function insert_books() { helper('session'); $session_uid = get_logged_user_id(); $session_bid = get_business_id(); - // print_r($_FILES);die(); $validationRule = [ 'userfile' => [ 'label' => 'Image File', @@ -77,16 +76,16 @@ class Books extends BaseController return 'hello'; } $img = $this->request->getFile('coverpicture'); - $book_id = $this->request->getPost('book_id'); + $book_id = $this->request->getPost('book_id'); $business_id = $this->request->getPost('business_id'); - $filePath ='public/uploads/' . $this->request->getPost('coverpicture'); + $filePath = 'public/uploads/' . $this->request->getPost('coverpicture'); ## 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 ($book_id) { $previousFileName = $this->request->getPost('previous_file'); @@ -97,11 +96,11 @@ class Books extends BaseController } else { $fileName = $this->request->getPost('previous_file', ''); // Use the previous filename if no new image is provided } - + $BooksModel = new BooksModel(); $data = [ - + 'title' => $this->request->getPost('title'), 'cover_picture' => $fileName, 'publication_date' => $this->request->getPost('publication_date'), @@ -109,17 +108,16 @@ class Books extends BaseController 'genre' => $this->request->getPost('genre'), 'language' => $this->request->getPost('language'), 'description' => $this->request->getPost('description'), - 'page_count'=> $this->request->getPost('page_count'), - 'price'=> $this->request->getPost('price'), - 'business_id'=>$business_id + 'page_count' => $this->request->getPost('page_count'), + 'price' => $this->request->getPost('price'), + 'business_id' => $business_id ]; - $book_id = $this->request->getPost('book_id'); // Get the business ID for update + $book_id = $this->request->getPost('book_id'); // Get the book ID for update purpose if (empty($book_id)) { // It's an insert operation $data['isactive'] = 1; $data['created_by'] = $session_uid; - //print_r($data);die; $BooksModel->insert($data); } else { // It's an update operation @@ -130,26 +128,24 @@ class Books extends BaseController } return redirect()->route('book_list'); } + + ## For delete the book details (Which means inactive the details) public function delete_books($id) { - $BooksModel = new BooksModel(); - - // Check if the business ID exists - $existingBook = $BooksModel->find($id); - if (!$existingBook) { - // return redirect()->to(base_url('Business/index'))->with('error', 'Business not found.'); - return redirect()->route('book_list'); - } helper('session'); $session_uid = get_logged_user_id(); - // Delete the business record - $data['isactive'] = 0; - $data['updated_by'] = $session_uid; - $BooksModel->update($id, $data); - //$BusinessModel->delete($id); - // return redirect()->to(base_url('Business/index'))->with('success', 'Business deleted successfully.'); + $BooksModel = new BooksModel(); + + $existingBook = $BooksModel->find($id); + if (!$existingBook) { + return redirect()->route('book_list'); + } + + $data['isactive'] = 0; + $data['updated_by'] = $session_uid; + $BooksModel->update($id, $data); return redirect()->route('book_list'); } } diff --git a/app/Controllers/Business.php b/app/Controllers/Business.php index c0edb68e..d254fa19 100644 --- a/app/Controllers/Business.php +++ b/app/Controllers/Business.php @@ -12,20 +12,16 @@ class Business extends BaseController { helper('session'); if (is_session_active()) { - $session_role = get_user_role('user_role'); - $session_bid = get_business_id('business_id'); - $BusinessModel = new BusinessModel(); $data['page_name'] = 'Buiness Listing'; - $data['businesses'] = $BusinessModel->where(['isactive'=>1])->findAll(); + $data['businesses'] = $BusinessModel->where(['isactive' => 1])->findAll(); $this->render_page('business_list', $data); } else { - // Session is not active or user is not logged in return redirect()->to('login'); } } - ## For Business page load add and Update + ## To Load Business Form (Add/Update) public function new_bussiness($id) { if ($id === '0') { @@ -48,7 +44,6 @@ class Business extends BaseController helper('session'); $session_uid = get_logged_user_id(); - // print_r($_FILES);die(); $validationRule = [ 'user' => [ 'label' => 'Image File', @@ -67,15 +62,15 @@ class Business extends BaseController return 'hello'; } $img = $this->request->getFile('bfile'); - $business_id = $this->request->getPost('business_id'); - $filePath ='public/uploads/' . $this->request->getPost('bfile'); + $business_id = $this->request->getPost('business_id'); + $filePath = 'public/uploads/' . $this->request->getPost('bfile'); ## 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 ($business_id) { $previousFileName = $this->request->getPost('previous_bfile'); @@ -86,7 +81,7 @@ class Business extends BaseController } else { $fileName = $this->request->getPost('previous_bfile', ''); // Use the previous filename if no new image is provided } - + $BusinessModel = new BusinessModel(); $data = [ @@ -116,26 +111,25 @@ class Business extends BaseController return redirect()->route('business_list'); } + ## For delete the business details (Which means inactive the details) public function delete_business($id) { + helper('session'); + $session_uid = get_logged_user_id(); $BusinessModel = new BusinessModel(); // Check if the business ID exists $existingBusiness = $BusinessModel->find($id); if (!$existingBusiness) { - // return redirect()->to(base_url('Business/index'))->with('error', 'Business not found.'); return redirect()->route('business_list'); } - helper('session'); - $session_uid = get_logged_user_id(); // Delete the business record $data['isactive'] = 0; - $data['updated_by'] = $session_uid; - $BusinessModel->update($id, $data); + $data['updated_by'] = $session_uid; + $BusinessModel->update($id, $data); //$BusinessModel->delete($id); - // return redirect()->to(base_url('Business/index'))->with('success', 'Business deleted successfully.'); return redirect()->route('business_list'); } } diff --git a/app/Controllers/Customer.php b/app/Controllers/Customer.php index 6f74830f..f2ab8d4c 100644 --- a/app/Controllers/Customer.php +++ b/app/Controllers/Customer.php @@ -30,7 +30,8 @@ class Customer extends BaseController } } - ## load Customer page + + ## To Load Customer Form (Add/Update) public function new_customer($id) { helper('session'); @@ -50,7 +51,8 @@ class Customer extends BaseController $data['session_bid'] = $session_bid; $this->render_page('customer_form', $data); } - ## insert and updation for customer + + ## For inserting/updating details of customer public function insert_customer() { helper('session'); @@ -94,7 +96,7 @@ class Customer extends BaseController return redirect()->route('customer_list'); } - ## delete for customer + ## For delete the customer details (Which means inactive the details) public function delete_customer($id) { $CustomerModel = new CustomerModel(); diff --git a/app/Controllers/Scheme.php b/app/Controllers/Scheme.php index 1eee0942..714e027c 100644 --- a/app/Controllers/Scheme.php +++ b/app/Controllers/Scheme.php @@ -7,28 +7,31 @@ use App\Models\SchemeModel; class Scheme extends BaseController { - ## For Business Listing + ## For Scheme Listing public function index() { helper('session'); - - if (is_session_active()) { + + if (is_session_active()) { $session_bid = get_business_id(); $session_role = get_user_role(); if (!empty($session_role) && $session_role !== "sadmin") { - $where = ['isactive'=>1,'business_id'=>(int)$session_bid]; - }else{ $where = ['isactive != '=>NULL];} - $SchemeModel =new SchemeModel(); - - $data['page_name'] = 'Scheme Listing'; - $data['scheme'] = $SchemeModel->where($where)->findAll(); - - $this->render_page('scheme_list', $data);} - else{ + $where = ['isactive' => 1, 'business_id' => (int)$session_bid]; + } else { + $where = ['isactive != ' => NULL]; + } + $SchemeModel = new SchemeModel(); + + $data['page_name'] = 'Scheme Listing'; + $data['scheme'] = $SchemeModel->where($where)->findAll(); + + $this->render_page('scheme_list', $data); + } else { return redirect()->to('login'); } } + ## To Load Scheme Form (Add/Update) public function new_scheme($id) { helper('session'); @@ -49,64 +52,65 @@ class Scheme extends BaseController $this->render_page('scheme_form', $data); } - + ## For inserting/updating details of scheme public function insert_scheme() { helper('session'); $session_bid = get_business_id(); $session_uid = get_logged_user_id(); - - $SchemeModel =new SchemeModel(); - $data = [ - 'scheme_name' => $this->request->getPost('sname'), - 'description' => $this->request->getPost('sdescription'), - 'price' => $this->request->getPost('sprice'), - 'duration' => $this->request->getPost('sduration'), - 'business_id' => $this->request->getPost('business_id') - - ]; - $scheme_id = $this->request->getPost('scheme_id'); // Get the business ID for update - if (empty($scheme_id)) { - // It's an insert operation - $data['isactive'] = 1; - $data['created_by'] = $session_uid; - $SchemeModel->insert($data); - } else { - // It's an update operation - $isactive = $this->request->getPost('isactive'); - $data['isactive'] = ($isactive == 'on') ? 1 : 0; - $data['updated_by'] = $session_uid; - $SchemeModel->update($scheme_id, $data); - } - return redirect()->route('scheme_list'); - } - public function delete_scheme($id) - { - $SchemeModel = new SchemeModel(); - - // Check if the business ID exists - $existingScheme = $SchemeModel->find($id); + $SchemeModel = new SchemeModel(); + $data = [ + 'scheme_name' => $this->request->getPost('sname'), + 'description' => $this->request->getPost('sdescription'), + 'price' => $this->request->getPost('sprice'), + 'duration' => $this->request->getPost('sduration'), + 'business_id' => $this->request->getPost('business_id') - if (!$existingScheme) { - // 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; + ]; + $scheme_id = $this->request->getPost('scheme_id'); // Get the business ID for update + + if (empty($scheme_id)) { + // It's an insert operation + $data['isactive'] = 1; + $data['created_by'] = $session_uid; + $SchemeModel->insert($data); + } else { + // It's an update operation + $isactive = $this->request->getPost('isactive'); + $data['isactive'] = ($isactive == 'on') ? 1 : 0; $data['updated_by'] = $session_uid; - //echo 'id='.$id; - print_r($data); - //die(); - $SchemeModel->update($id, $data); - // print_r($data);die(); - //$BusinessModel->delete($id); - - // return redirect()->to(base_url('Business/index'))->with('success', 'Business deleted successfully.'); + $SchemeModel->update($scheme_id, $data); + } + return redirect()->route('scheme_list'); + } + + ## For delete the Scheme details (Which means inactive the details) + public function delete_scheme($id) + { + $SchemeModel = new SchemeModel(); + + // Check if the business ID exists + $existingScheme = $SchemeModel->find($id); + + if (!$existingScheme) { + // 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; + //echo 'id='.$id; + print_r($data); + //die(); + $SchemeModel->update($id, $data); + // print_r($data);die(); + //$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 bbf8543a..525df3d8 100755 --- a/app/Controllers/Users.php +++ b/app/Controllers/Users.php @@ -54,6 +54,7 @@ class Users extends BaseController $data['session_bid'] = $session_bid; $this->render_page('user_form', $data); } + ## For SuperAdmin Role business Dropdown displayed on Userpage.otherwise Hidden fields public function business_details() { @@ -63,8 +64,8 @@ class Users extends BaseController return $business_details; } - ## To Save/Update User Data on DB. - public function user_synchronization() + ## For inserting/updating details of user + public function insert_users() { helper('session'); $session_uid = get_logged_user_id(); @@ -148,4 +149,24 @@ class Users extends BaseController } return redirect()->route('user_list'); } + + ## For delete the user details (Which means inactive the details) + public function delete_user($id) + { + + helper('session'); + $session_uid = get_logged_user_id(); + + $model = new UsersModel(); + + $existingBook = $model->find($id); + if (!$existingBook) { + return redirect()->route('user_list'); + } + + $data['isactive'] = 0; + $data['updated_by'] = $session_uid; + $model->update($id, $data); + return redirect()->route('user_list'); + } } diff --git a/app/Views/book_form.php b/app/Views/book_form.php index 659ae809..981ca74f 100644 --- a/app/Views/book_form.php +++ b/app/Views/book_form.php @@ -7,28 +7,32 @@ getFlashdata('success')) : ?>
getFlashdata('success') ?>
-
"> + ">
+
Please provide.
+
Please provide.
+
Please provide.
+
Please provide.
@@ -54,6 +58,7 @@
+
Please provide.
@@ -61,10 +66,12 @@
+
Please provide.
+
Please provide.
@@ -83,12 +90,11 @@ - + " class="btn btn-secondary waves-effect">Cancel
- - \ No newline at end of file + \ No newline at end of file diff --git a/app/Views/book_list.php b/app/Views/book_list.php index 104739dd..e21ba591 100644 --- a/app/Views/book_list.php +++ b/app/Views/book_list.php @@ -3,17 +3,12 @@

- - - @@ -30,37 +25,35 @@ - - - - - - - - - - - + + + + + + + + + + - +
- - +
+ + - - " - class="delete-button"> + + " class="delete-button"> -
diff --git a/app/Views/business_form.php b/app/Views/business_form.php index e66879b6..df8f22be 100644 --- a/app/Views/business_form.php +++ b/app/Views/business_form.php @@ -1,14 +1,20 @@ - + + @@ -25,36 +31,42 @@

-
+
+
Please provide.
+
Please provide.
+
Please provide.
+
Please provide.
+
Please provide.
+
Please provide.
- - - diff --git a/app/Views/customer_form.php b/app/Views/customer_form.php index 9459fbf7..eedbb3c2 100644 --- a/app/Views/customer_form.php +++ b/app/Views/customer_form.php @@ -4,134 +4,107 @@

- +
- - + + +
Please provide.
- - + + +
Please provide.
- - + + +
Please provide.
- - + + +
Please provide.
- - + + +
Please provide.
- + +
Please provide.
- - + + +
Please provide.
- - + + +
Please provide.
- + +
Please provide.
- - + + +
Please provide.
- - + + +
Please provide.
- + +
Please provide.
- + +
Please provide.
- - + + -
- > - -
-
+
+ > + +
+
- + " class="btn btn-secondary waves-effect">Cancel
diff --git a/app/Views/customer_list.php b/app/Views/customer_list.php index 1889dd22..f3c14b6a 100644 --- a/app/Views/customer_list.php +++ b/app/Views/customer_list.php @@ -1,74 +1,53 @@ - - - - -
- - -

- - - -
- - - - - - - - - - - - - - + + + + + + + + + + + - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + +
First NameLast NameMobile NumberEmailAddressCountryStateCityTypeModeActionFirst NameLast NameMobile NumberEmailAddressCountryStateCityTypeModeAction
- " class="edit-button"> - " class="delete-button"> -
+ " class="edit-button"> + " class="delete-button"> +
- - + + \ No newline at end of file diff --git a/app/Views/scheme_form.php b/app/Views/scheme_form.php index ec454b12..f371fa67 100644 --- a/app/Views/scheme_form.php +++ b/app/Views/scheme_form.php @@ -4,47 +4,38 @@

-
+
- - + + +
Please provide.
- - + + +
Please provide.
- - + + +
Please provide.
- - + + +
Please provide.
- - - + + +
> @@ -60,7 +51,7 @@ - + " class="btn btn-secondary waves-effect">Cancel
diff --git a/app/Views/scheme_list.php b/app/Views/scheme_list.php index 3a35b535..1eb9dc2d 100644 --- a/app/Views/scheme_list.php +++ b/app/Views/scheme_list.php @@ -2,59 +2,39 @@
- - -

- - - - - + +
- - - - - - - - - + + + + + - - - - - - - - - - - - - - - + + + + + + + + + +
Scheme NameDescriptionPriceDurationActionScheme NameDescriptionPriceDurationAction
- " class="edit-button"> - " class="delete-button"> - -
+ " class="edit-button"> + " class="delete-button"> +
-
- - +
\ No newline at end of file diff --git a/app/Views/user_form.php b/app/Views/user_form.php index 97214ea5..889e4c16 100644 --- a/app/Views/user_form.php +++ b/app/Views/user_form.php @@ -6,186 +6,141 @@ -
" - method="post" enctype="multipart/form-data"> + " method="post" enctype="multipart/form-data">
- - + +
Please provide.
- - + +
Please provide.
-
- - -
Please provide.
-
+
+ + +
Please provide.
+
- - + +
Please provide.
- - + +
Please provide.
- - + +
Please provide.
- +
- - + +
Please provide.
- +
- +
- +
Please provide.
-
- - Business Logo -
+
+ + Business Logo +
- + - +
-
- - +
+ + +
Please provide.
+
+
+
+ +
Please provide.
-
-
- - -
Please provide.
-
-
- - -
Please provide.
-
-
- - -
Please provide.
-
+
+ + +
Please provide.
- +
+ + +
Please provide.
+
+
+
- +
- - - - - + + + + +
- > + >

- - + + +
- + \ No newline at end of file diff --git a/app/Views/user_list.php b/app/Views/user_list.php index 631ecfcd..ec71cb96 100644 --- a/app/Views/user_list.php +++ b/app/Views/user_list.php @@ -11,11 +11,8 @@
getFlashdata('success') ?>
- - - - - + +
@@ -24,7 +21,6 @@ - @@ -55,11 +51,8 @@
NameMobile Number File AddressStatus Action
-
    -
  • - -
  • -
+ + " class="delete-button">