diff --git a/app/Config/Constants.php b/app/Config/Constants.php
index b9cb843e..4f636275 100644
--- a/app/Config/Constants.php
+++ b/app/Config/Constants.php
@@ -96,4 +96,8 @@ define('EVENT_PRIORITY_HIGH', 10);
/**
* Constants For Api Integration.
*/
-define('VPB_BOOK', 'https://vbp.venbait.in/wp-json/wc/v3/products');
+define('VB_APIURL', 'https://vbp.venbait.in/wp-json/wc/v3/');
+define('VB_BOOKS', VB_APIURL.'products');
+define('VB_CUSTOMERS', VB_APIURL.'customers');
+
+
diff --git a/app/Config/Routes.php b/app/Config/Routes.php
index 89f45c86..aa5a6133 100644
--- a/app/Config/Routes.php
+++ b/app/Config/Routes.php
@@ -38,6 +38,11 @@ $routes->get('logout/', 'Authentication::logout');
$routes->get('auth_confirm_mail/', 'Authentication::auth_confirm_mail');//Routes For Confirmation Mail alert page.
$routes->get('auth_reset_password/', 'Authentication::auth_reset_password');//Routes For Load Reset password Page.
$routes->post('auth_reset_password_save/', 'Authentication::auth_reset_password_save');//Routes For update the Resetted password.
+$routes->get('lockscreen/', 'Authentication::lockscreen');
+$routes->get('lock/', 'Authentication::lock');
+$routes->post('unlock/', 'Authentication::unlock');
+
+
# Dashboard Routes
$routes->get('dashboard/', 'Home::index');
@@ -98,7 +103,9 @@ $routes->get("new_invoice/", "Invoice::new_invoice/");
# Api integration Routes
-$routes->get("apiintegration", "Home::apiintegration");
+$routes->get("book_api_integration", "Books::apiintegration");
+$routes->get("customer_api_integration", "Customer::apiintegration");
+
/*
* --------------------------------------------------------------------
* Additional Routing
diff --git a/app/Controllers/Authentication.php b/app/Controllers/Authentication.php
index 0b4bf994..142e7cd1 100755
--- a/app/Controllers/Authentication.php
+++ b/app/Controllers/Authentication.php
@@ -181,24 +181,26 @@ class Authentication extends BaseController
## Save Resetted password. and Redirect to login
public function auth_reset_password_save()
{
+
$auth_model = new AuthenticationModel();
$rules = [
'password1' => 'required',
'password2' => 'required',
];
if ($this->validate($rules)) {
+ // echo "try";die;
$email = $this->request->getVar('email');
$password = $this->request->getVar('password1');
$confirmation = $this->request->getVar('password2');
$hash_password = password_hash($password, PASSWORD_DEFAULT);
- try {
+ // try {
// code for password confirmation
if ($password === $confirmation) {
$auth_model = new AuthenticationModel();
$user_details = $auth_model->where(['email' => $email, 'isactive' => 1])->first();
if ($user_details) {
$update_user_details = ['email' => $email, 'password' => $hash_password];
- $auth_model->update($update_user_details['user_id'], $update_user_details);
+ $auth_model->update($user_details['user_id'], $update_user_details);
}
// Retrieve flashed session data
$successMessage = session()->getFlashdata('success');
@@ -214,12 +216,12 @@ class Authentication extends BaseController
$this->logger->error('Password confirmation failed');
return redirect()->back()->withInput()->with('error', 'Password confirmation failed');
}
- } catch (\Exception $e) {
- $error = "Exception Errno returned" . $e->getCode() . "
";
- $error_msg = $e->getMessage();
- $this->logger->error($error . '(' . $error_msg . ')');
- return redirect()->back()->withInput()->with('error', $error . '(' . $error_msg . ')');
- }
+ // } catch (\Exception $e) {
+ // $error = "Exception Errno returned" . $e->getCode() . "
";
+ // $error_msg = $e->getMessage();
+ // $this->logger->error($error . '(' . $error_msg . ')');
+ // return redirect()->back()->withInput()->with('error', $error . '(' . $error_msg . ')');
+ // }
} else {
// Validation failed, display errors
$this->logger->error('Password And Confirmation Password are Required.');
@@ -248,35 +250,51 @@ class Authentication extends BaseController
$this->response->setHeader('Cache-Control', 'no-store, no-cache, must-revalidate, max-age=0');
$this->response->setHeader('Pragma', 'no-cache');
$this->response->setHeader('Expires', 'Fri, 01 Jan 1990 00:00:00 GMT');
-
- return redirect()->to('/login'); //
+ $data = [];
+ return view('auth_logout', $data);
}
## Lock Screen - holded
public function lockscreen()
{
// Load the session library
- $session = \Config\Services::session();
+ helper('session');
+
+ $session_uid = get_logged_user_id();
+ $session_uname = get_logged_name();
+ $auth_model = new AuthenticationModel();
+
+ $details = $auth_model->getheringDetailsForHeader($session_uid);
+ $data['loggedin_person'] = $session_uname;
+ $data['loggedin_person_role'] = $details[0]['role'];
+ $data['favicon'] = $details[0]['favicon'];
+ $data['profile_picture'] = $details[0]['profile_picture'];
+ $successMessage = session()->getFlashdata('success');
+ $validationErrors = session()->getFlashdata('error');
+ // Load and display the form view with the above data
+ // Here, we'll use the default View class for demonstration purposes
// Check if the session is locked
- if ($session->get('session_locked')) {
+ if (get_session_locked()) {
+ $data['successMessage'] = $successMessage;
+ $data['validationErrors'] = $validationErrors;
// Load the lock screen view
- return view('lock_screen');
+ return view('auth_lock_screen', $data);
} else {
// Redirect the user to their previous page or dashboard
return redirect()->to('dashboard'); // Replace with appropriate URL
}
}
- ## Lock Screen - holded
+ ## Lock Screen
public function lock()
{
// Load the session library
- $session = \Config\Services::session();
+ helper('session');
// Set the session_locked flag
- $session->set('session_locked', true);
-
+ set_session_locked(true);
+
// Redirect the user to the lock screen
return redirect()->to('lockscreen'); // Replace with your lock screen URL
}
@@ -285,26 +303,31 @@ class Authentication extends BaseController
public function unlock()
{
// Load the session library
- $session = \Config\Services::session();
+ helper('session');
// Check password logic
- $password = $this->request->getPost('password');
-
+ $password = $this->request->getVar('password');
if ($this->checkPassword($password)) {
// Unlock the session
- $session->remove('session_locked');
+ remove_session_locked();
return redirect()->to('dashboard'); // Redirect to dashboard
} else {
// Incorrect password, show error
- return redirect()->back()->with('error', 'Incorrect password.');
+ return redirect()->back()->withInput()->with('error', 'Incorrect password.');
}
}
- ## Unlock Screen - Replace with your password checking logic - holded
+ ## Unlock Screen
private function checkPassword($password)
{
// Implement your password validation logic here
// For example, compare against a stored hash
- return $password === 'correct_password';
+ // return $password === 'correct_password';
+ helper('session');
+ $session_uid = get_logged_user_id();
+ $auth_model = new AuthenticationModel();
+ $user = $auth_model->where('user_id', $session_uid)->first();
+ $pwd_verify = password_verify((string)$password, $user['password']);
+ return $pwd_verify ;
}
}
diff --git a/app/Controllers/BaseController.php b/app/Controllers/BaseController.php
index 743c7294..812be8b8 100644
--- a/app/Controllers/BaseController.php
+++ b/app/Controllers/BaseController.php
@@ -72,6 +72,7 @@ abstract class BaseController extends Controller
$data['company_name'] = $details[0]['site_name'];
$data['company_short_name'] = $details[0]['site_title'];
$data['loggedin_person'] = $session_uname;
+ $data['loggedin_person_id'] = $session_uid;
$data['loggedin_person_role'] = $details[0]['role'];
$data['favicon'] = $details[0]['favicon'];
$data['profile_picture'] = $details[0]['profile_picture'];
diff --git a/app/Controllers/Books.php b/app/Controllers/Books.php
index 00b1fd99..5eaeaa06 100755
--- a/app/Controllers/Books.php
+++ b/app/Controllers/Books.php
@@ -148,4 +148,78 @@ class Books extends BaseController
$BooksModel->update($id, $data);
return redirect()->route('book_list');
}
+
+ ## ApiIntegration For Book.
+ public function apiintegration() {
+ helper('apiIntegration');
+ helper('session');
+ $session_role = get_user_role();
+ $session_uid = get_logged_user_id();
+ $response = perform_http_request('GET', VB_BOOKS);
+ $message = "";
+ if(count($response['response'])>0){
+ //$message = "Reponse Count : ".count($response['response'])."
";
+ echo "Note : This For CrossCheck Purpose 1ly
";
+ echo "Total Book API Reponse Count : " . count($response['response']) . "
";
+ $BooksModel = new BooksModel();
+ foreach($response['response'] as $row){
+ if($row->status == "publish"){
+ $publisher = '';
+ $language = '';
+ $attributes = $row->attributes;
+ if(count($attributes)>0){
+ foreach ($attributes as $att){
+ if($att->name == "Publisher"){ $publisher = implode(", ",$att->options); }
+ if($att->name == "Book Author"){ $publisher .= implode(", ",$att->options)."(Book Author)"; }
+ if($att->name == "Book Language"){ $language = implode(", ",$att->options); }
+ }
+ }
+ // echo $row->permalink ;
+ $insertion_data['title'] = $row->name ;
+ $insertion_data['publication_date'] = $row->date_created;
+ $insertion_data['publisher'] = $publisher;
+ $insertion_data['genre'] = $row->description;
+ $insertion_data['language'] = $language;
+ $insertion_data['description'] = $row->short_description;
+ $insertion_data['page_count']='';
+ $insertion_data['price'] = $row->sale_price != '' ? $row->sale_price : $row->regular_price;
+ $insertion_data['created_by'] = $session_uid;
+ $insertion_data['isactive'] = 1;
+ $insertion_data['business_id'] = 1;
+ $images = $row->images;
+ $i = 0;
+ $BooksModel->insert($insertion_data);
+ $lastInsertId = $BooksModel->insertID();
+ $insertion_img_data = [];
+ // $message .= "book ID : ".$lastInsertId." have Imgs".count($images)."
";
+ echo "book ID : ".$lastInsertId." have Imgs".count($images)."
";
+ if(count($images)>0){
+ foreach ($images as $img){
+ $insertion_img_data[$i]['img_name'] = $img->src;
+ $insertion_img_data[$i]['is_cover'] = 0;
+ $insertion_img_data[$i]['type'] = 2;
+ $insertion_img_data[$i]['book_id'] = $lastInsertId;
+ $insertion_img_data[$i]['created_by'] = $session_uid;
+ $insertion_img_data[$i]['isactive'] = 1;
+ $i++;
+ } // image loop closed
+ $BooksModel->insertImagesBatch($insertion_img_data);
+ //$message .= "book ID : ".$lastInsertId." Img. Batch Inserted Done
";
+ echo " Img Batch Inserted Done. ".$i. "
";
+ }//image count closed
+ }//if cond. closed
+ }//reponse foreach closed
+ }//reponse count if closed
+ if(!empty($response['error'])){
+ echo $response['error'];
+ echo $response['error_msg'];
+ $message .= $response['error'].$response['error_msg'];
+ echo $response['error'].$response['error_msg'];
+ echo "Error :".$response['error'] . $response['error_msg'];
+ }else{
+ echo "Done";
+ }
+ $go_to_list_page = base_url()."book_list";
+ echo "
go to list page";
+ }
}
diff --git a/app/Controllers/Customer.php b/app/Controllers/Customer.php
index f2ab8d4c..c5e0c06e 100644
--- a/app/Controllers/Customer.php
+++ b/app/Controllers/Customer.php
@@ -11,12 +11,14 @@ class Customer extends BaseController
public function index()
{
helper('session');
- if (is_session_active()) {
+ 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];}
+ $where = ['isactive' => 1, 'business_id' => (int)$session_bid];
+ } else {
+ $where = ['isactive != ' => NULL];
+ }
$CustomerModel = new CustomerModel();
$data['page_name'] = 'Customer Listing';
@@ -25,10 +27,9 @@ class Customer extends BaseController
// print_r($data); die();
$this->render_page('customer_list', $data);
- }else{
+ } else {
return redirect()->to('login');
}
-
}
## To Load Customer Form (Add/Update)
@@ -39,15 +40,17 @@ class Customer extends BaseController
if ($id === '0') {
$data['page_name'] = 'Add Customer';
$data['customer'] = [];
+ $data['customer_billing'] = [];
+ $data['customer_shipping'] = [];
} else if ($id !== '0') {
$data['page_name'] = 'Edit Customer';
$model = new CustomerModel();
$model->setTable('customers');
$edit_user_details = $model->where(['customer_id' => $id])->first();
-
$data['customer'] = $edit_user_details;
+ $data['customer_billing'] = $this->get_customer_address($id,1);
+ $data['customer_shipping'] = $this->get_customer_address($id,2);
}
-
$data['session_bid'] = $session_bid;
$this->render_page('customer_form', $data);
}
@@ -58,7 +61,7 @@ class Customer extends BaseController
helper('session');
$session_bid = get_business_id();
$session_uid = get_logged_user_id();
- $model = new CustomerModel();
+ $model = new CustomerModel();
$data = [
'first_name' => $this->request->getPost('cfname'),
'last_name' => $this->request->getPost('csname'),
@@ -75,27 +78,88 @@ class Customer extends BaseController
'profile_picture' => $this->request->getPost('cfile'),
'mode' => $this->request->getPost('cmode'),
'business_id' => $this->request->getPost('business_id')
-
];
$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;
//print_r($data);die;
$model->insert($data);
+ $FK_CID = $model->insertID(); // for Customer ADDRESS Table
} else {
// It's an update operation
- $isactive = $this->request->getPost('isactivce');
+ $isactive = $this->request->getPost('isactive');
$data['isactive'] = ($isactive == 'on') ? 1 : 0;
$data['updated_by'] = $session_uid;
- $model->update($customer_id, $data);
+ // $model->update($customer_id, $data);
+ $FK_CID = $customer_id; // for Customer ADDRESS Table
}
+ $requestData = $this->request->getPost();
+ $this->save_customer_addresses($FK_CID,$requestData,'b');
+ $this->save_customer_addresses($FK_CID,$requestData,'s');
return redirect()->route('customer_list');
}
+ public function save_customer_addresses($id,$requestData,$letteringflag){
+
+ $addressType = ($letteringflag == 'b') ? 1 : 2;
+ $getAddressdetails = $this->get_customer_address($id,$addressType);
+ $CAid = $requestData[$letteringflag.'customer_address_id']; // Available Address IDS in Form Fields.
+ $model = new CustomerModel();
+
+ // Compare Address Input Field PKIDS With Existing PKIDS
+ // IF Any Missing value Means that values are Inactive here....
+ if(!empty($CAid)){
+ $filteringAddressIds = [];
+ for ($y = 0; $y < count($getAddressdetails); $y++) {
+ $filteringAddressIds[$y] = $getAddressdetails[$y]['customer_address_id'];
+ }
+ if(!empty($filteringAddressIds)){
+ $A = $filteringAddressIds;
+ $B = $CAid;
+ $missingValues = array_diff($A,$B);
+ if(!empty($missingValues)){
+ $where = ['isactive'=>1,'customer_id'=>(int)$id,'address_type'=>$addressType];
+ $model->inactiveMissingAddressDetails($where,$missingValues);
+ }
+ }
+ }
+ $session_uid = get_logged_user_id();
+
+ $baddress1 = $requestData[$letteringflag.'address1'];
+ $baddress2 = $requestData[$letteringflag.'address2'];
+ $bcountry = $requestData[$letteringflag.'country'];
+ $bcity = $requestData[$letteringflag.'city'];
+ $bstate = $requestData[$letteringflag.'state'];
+ $bzip = $requestData[$letteringflag.'zip'];
+ $count = count($CAid);
+ $address_array = [];
+ if($count > 0){
+ for ($x = 0; $x < $count; $x++) {
+ $address_array[$x]['first_name'] = $requestData['cfname'];
+ $address_array[$x]['last_name'] = $requestData['csname'];
+ // $address_array[$x]['company'] = "";
+ $address_array[$x]['email'] = $requestData['cmail'];
+ $address_array[$x]['mobile_no'] = $requestData['cmobile'];
+ $address_array[$x]['address_1'] = $baddress1[$x];
+ $address_array[$x]['address_2'] = $baddress2[$x];
+ $address_array[$x]['city'] = $bcity[$x];
+ $address_array[$x]['state'] = $bstate[$x];
+ $address_array[$x]['country'] = $bcountry[$x];
+ $address_array[$x]['postal_code'] = $bzip[$x];
+ $address_array[$x]['customer_id'] = $id;
+ $address_array[$x]['address_type'] = $addressType;
+ $address_array[$x]['created_by'] = $session_uid;
+ $address_array[$x]['updated_by'] = $CAid[$x] ? $session_uid : null;
+ $address_array[$x]['customer_address_id'] = $CAid[$x];
+ }
+ $statement = $model->saveAddressDetails($address_array);
+ }
+ return $statement;
+ }
+
## For delete the customer details (Which means inactive the details)
public function delete_customer($id)
{
@@ -119,4 +183,111 @@ class Customer extends BaseController
// return redirect()->to(base_url('Business/index'))->with('success', 'Business deleted successfully.');
return redirect()->route('customer_list');
}
-}
\ No newline at end of file
+
+ public function get_customer_address($id,$type){
+ $model = new CustomerModel();
+ $model->setTable('customer_addresses');
+ $where = ['isactive' => 1, 'customer_id' => (int)$id,'address_type'=>(int)$type];
+ $address_details = $model->where($where)->findAll();
+ return $address_details;
+ }
+ ## ApiIntegration For Customer.
+ public function apiintegration()
+ {
+ helper('apiIntegration');
+ helper('session');
+ $session_bid = get_business_id();
+ $session_uid = get_logged_user_id();
+ $response = perform_http_request('GET', VB_CUSTOMERS);
+ $message = "";
+ if (count($response['response']) > 0) {
+ //$message = "Reponse Count : ".count($response['response'])."
";
+ echo "Note : This For CrossCheck Purpose 1ly
";
+ echo "Total Customer API Reponse Count : " . count($response['response']) . "
";
+ $CustomerModel = new CustomerModel();
+ $x=0;
+ foreach ($response['response'] as $row) {
+ $insertion_data['first_name'] = $row->first_name;
+ $insertion_data['last_name'] = $row->last_name;
+ $insertion_data['type'] = $row->role;
+ $insertion_data['email'] = $row->email;
+ // $insertion_data['profile_picture'] = $row->avatar_url;
+ $insertion_data['mode'] = 'online';
+ $insertion_data['created_by'] = $session_uid;
+ $insertion_data['business_id'] = $session_bid;
+ $billing = $row->billing;
+ $shipping = $row->shipping;
+ $CustomerModel->insert($insertion_data);
+ $lastInsertId = $CustomerModel->insertID();
+ $insertion_baddress_data = [];$insertion_saddress_data = [];
+ $i = 0; $j = 0;
+
+ if(isset($billing) && gettype($billing) === 'object') {$billing = [$billing];}
+ if(isset($shipping) && gettype($shipping) === 'object') {$shipping = [$shipping];}
+ echo "Customer ID : ".$lastInsertId." have Billing address = ".count($billing)." and Shipping address = ".count($shipping)."
";
+ if (count($billing) > 0) {
+ foreach ($billing as $bill) {
+ if ($bill->first_name !== '') {
+ $insertion_baddress_data[$i]['first_name'] = $bill->first_name;
+ $insertion_baddress_data[$i]['last_name'] = $bill->last_name;
+ $insertion_baddress_data[$i]['company'] = $bill->company;
+ $insertion_baddress_data[$i]['address_1'] = $bill->address_1;
+ $insertion_baddress_data[$i]['address_2'] = $bill->address_2;
+ $insertion_baddress_data[$i]['city'] = $bill->city;
+ $insertion_baddress_data[$i]['state'] = $bill->state;
+ $insertion_baddress_data[$i]['country'] = $bill->country;
+ $insertion_baddress_data[$i]['postal_code'] = $bill->postcode;
+ $insertion_baddress_data[$i]['customer_id'] = $lastInsertId;
+ $insertion_baddress_data[$i]['address_type'] = 1;
+ $insertion_baddress_data[$i]['created_by'] = $session_uid;
+ $insertion_baddress_data[$i]['email'] = isset($bill->email) ? $bill->email : '';
+ $insertion_baddress_data[$i]['mobile_no'] = isset($bill->phone) ? $bill->phone : '';
+ $i++;
+ echo " Billing address has a value and Inserted ".$i."
";
+ }else{
+ echo " Keys are available but Billing address has no value;
";
+ }
+ }
+ (!empty($insertion_baddress_data) ? $CustomerModel->insertAddressBatch($insertion_baddress_data) : "");
+ }
+ if (count($shipping) > 0) {
+ foreach ($shipping as $ship) {
+ if ($ship->first_name !== '') {
+ $insertion_saddress_data[$j]['first_name'] = $ship->first_name;
+ $insertion_saddress_data[$j]['last_name'] = $ship->last_name;
+ $insertion_saddress_data[$j]['company'] = $ship->company;
+ $insertion_saddress_data[$j]['address_1'] = $ship->address_1;
+ $insertion_saddress_data[$j]['address_2'] = $ship->address_2;
+ $insertion_saddress_data[$j]['city'] = $ship->city;
+ $insertion_saddress_data[$j]['state'] = $ship->state;
+ $insertion_saddress_data[$j]['country'] = $ship->country;
+ $insertion_saddress_data[$j]['postal_code'] = $ship->postcode;
+ $insertion_saddress_data[$j]['email'] = isset($ship->email)?$ship->email:"";
+ $insertion_saddress_data[$j]['mobile_no'] = isset($ship->phone)?$ship->phone:"";
+ $insertion_saddress_data[$j]['customer_id'] = $lastInsertId;
+ $insertion_saddress_data[$j]['address_type'] = 2;
+ $insertion_saddress_data[$j]['created_by'] = $session_uid;
+ $j++;
+ echo " Shipping address has a value and Inserted ".$j."
";
+ }
+ else{
+ echo " Keys are available but Shipping address has no value
";
+ }
+ }
+ (!empty($insertion_saddress_data) ? $CustomerModel->insertAddressBatch($insertion_saddress_data) : "");
+ }
+ } //reponse foreach closed
+ } //reponse count if closed
+ if (!empty($response['error'])) {
+ echo $response['error'];
+ echo $response['error_msg'];
+ $message .= $response['error'] . $response['error_msg'];
+ echo "Error :".$response['error'] . $response['error_msg'];
+ }else{
+ echo "Done";
+ }
+ $go_to_list_page = base_url()."customer_list";
+ echo "go to list page";
+ // return $message;
+ }
+}
diff --git a/app/Controllers/Home.php b/app/Controllers/Home.php
index 69c4838b..0cbf639b 100644
--- a/app/Controllers/Home.php
+++ b/app/Controllers/Home.php
@@ -1,86 +1,28 @@
1, 'business_id' => (int)$session_bid];
+ } else if (!empty($session_role) && $session_role !== "admin") {
+ $where = ['isactive != ' => NULL];
+ } else {
+ $where = [];
+ }
+ $model = new HomeModel();
+ $data['customer'] = $model->customers($where);
+ $data['customer']['label'] = "Customer";
$this->render_page('dashboard', $data);
-
}
- ## ApiIntegration.
- public function apiintegration() {
- helper('apiIntegration');
- helper('session');
- $session_role = get_user_role();
- $session_uid = get_logged_user_id();
- $response = perform_http_request('GET', VPB_BOOK);
- $message = "";
- if(count($response['response'])>0){
- //$message = "Reponse Count : ".count($response['response'])."
";
- echo "Reponse Count : ".count($response['response'])."
";
- $BooksModel = new BooksModel();
- foreach($response['response'] as $row){
- if($row->status == "publish"){
- $publisher = '';
- $language = '';
- $attributes = $row->attributes;
- if(count($attributes)>0){
- foreach ($attributes as $att){
- if($att->name == "Publisher"){ $publisher = implode(", ",$att->options); }
- if($att->name == "Book Author"){ $publisher .= implode(", ",$att->options)."(Book Author)"; }
- if($att->name == "Book Language"){ $language = implode(", ",$att->options); }
- }
- }
- // echo $row->permalink ;
- $insertion_data['title'] = $row->name ;
- $insertion_data['publication_date'] = $row->date_created;
- $insertion_data['publisher'] = $publisher;
- $insertion_data['genre'] = $row->description;
- $insertion_data['language'] = $language;
- $insertion_data['description'] = $row->short_description;
- $insertion_data['page_count']='';
- $insertion_data['price'] = $row->sale_price != '' ? $row->sale_price : $row->regular_price;
- $insertion_data['created_by'] = $session_uid;
- $insertion_data['isactive'] = 1;
- $insertion_data['business_id'] = 1;
- $images = $row->images;
- $i = 0;
- $BooksModel->insert($insertion_data);
- $lastInsertId = $BooksModel->insertID();
- $insertion_img_data = [];
- // $message .= "book ID : ".$lastInsertId." have Imgs".count($images)."
";
- echo "book ID : ".$lastInsertId." have Imgs".count($images)."
";
- if(count($images)>0){
- foreach ($images as $img){
- $insertion_img_data[$i]['img_name'] = $img->src;
- $insertion_img_data[$i]['is_cover'] = 0;
- $insertion_img_data[$i]['type'] = 2;
- $insertion_img_data[$i]['book_id'] = $lastInsertId;
- $insertion_img_data[$i]['created_by'] = $session_uid;
- $insertion_img_data[$i]['isactive'] = 1;
- $i++;
- } // image loop closed
- $BooksModel->insertImagesBatch($insertion_img_data);
- //$message .= "book ID : ".$lastInsertId." Img. Batch Inserted Done
";
- echo "book ID : ".$lastInsertId." Img. Batch Inserted Done
";
- }//image count closed
- }//if cond. closed
- }//reponse foreach closed
- }//reponse count if closed
- if(!empty($response['error'])){
- echo $response['error'];
- echo $response['error_msg'];
- $message .= $response['error'].$response['error_msg'];
- echo $response['error'].$response['error_msg'];
- }
- //return $message;
- echo "Done";
- }
}
diff --git a/app/Helpers/session_helper.php b/app/Helpers/session_helper.php
index 123cbcba..2e9a3b0d 100644
--- a/app/Helpers/session_helper.php
+++ b/app/Helpers/session_helper.php
@@ -91,4 +91,28 @@ if (!function_exists('is_session_destroy')) {
}
}
+if (!function_exists('set_session_locked')) {
+ function set_session_locked()
+ {
+ $session = \Config\Services::session();
+ $session->set('session_locked', true);
+ }
+}
+
+if (!function_exists('get_session_locked')) {
+ function get_session_locked()
+ {
+ $session = \Config\Services::session();
+ return $session->get('session_locked');
+ }
+}
+
+if (!function_exists('remove_session_locked')) {
+ function remove_session_locked()
+ {
+ $session = \Config\Services::session();
+ $session->remove('session_locked');
+ }
+}
+
?>
\ No newline at end of file
diff --git a/app/Models/CustomerModel.php b/app/Models/CustomerModel.php
index 98e9ce73..f396222f 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','business_id'];
+ protected $allowedFields = ['customer_id ','first_name','city','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)
{
@@ -21,6 +21,7 @@ class CustomerModel extends Model
$this->builder()->where('business_id ', $business_id); // Filter by business_id
$query = $this->builder()->get(); // Use findAll() instead of get()
return ($query->getResult());
+ }
// $customerNames = [];
@@ -30,7 +31,7 @@ class CustomerModel extends Model
// print_r($customerNames);
// die();
- }
+
// public function getCustomerIdByName($customerName, $businessId)
// {
@@ -49,4 +50,45 @@ class CustomerModel extends Model
// }
-}
\ No newline at end of file
+
+
+
+ public function insertAddress($addressData) {
+ $this->db->table('customer_addresses')->insert($addressData);
+ return $this->db->insertID(); // Return the last inserted ID
+ }
+
+ public function insertAddressBatch($addressesDataArray) {
+ $this->db->table('customer_addresses')->insertBatch($addressesDataArray);
+ return $this->db->insertID(); // Note: insertID() might not be applicable for batch inserts
+ }
+
+ public function saveAddressDetails($data){
+ $i = 0;
+ $statement = [];
+ foreach ($data as $row) {
+ $id = $row['customer_address_id'];
+ if($id != ''){
+ unset($row['customer_address_id']); // Remove the id from the data to avoid updating it
+ unset($row['created_by']); // bcoz here data Updating here.
+ $this->db->table('customer_addresses')->where('customer_address_id', $id)->update($row);// Update the row with the specified id
+ $affectedRows = $this->db->affectedRows();
+ $statement[$i] = "address - ".$id." ".$affectedRows ? " Updated":" Not Updated";
+ }else{
+
+ $this->db->table('customer_addresses')->insert($row);
+ $insertID = $this->db->insertID();
+ $statement[$i] = "address - ".$insertID." Inserted";
+ }
+ }
+
+ return $statement;
+ }
+
+
+ public function inactiveMissingAddressDetails($where,$missingValues){
+ $dataToUpdate = ['isactive' => 0];
+ $this->db->table('customer_addresses')->where($where)->whereIn('customer_address_id',$missingValues)->update($dataToUpdate);
+ }
+}
+?>
diff --git a/app/Models/HomeModel.php b/app/Models/HomeModel.php
new file mode 100644
index 00000000..1b774092
--- /dev/null
+++ b/app/Models/HomeModel.php
@@ -0,0 +1,27 @@
+db->table('customers');
+
+ $totalCustomers = $query->where($where)->countAll();
+ $activeCustomers = $query->where($where)->countAllResults();
+
+ $where['DATE(created_on)'] = date('Y-m-d');
+ $todayCustomers = $query->where($where)->countAllResults();
+
+ if ($totalCustomers > 0) {
+ $customer['percentage'] = ($activeCustomers / $totalCustomers) * 100;
+ } else {
+ $customer['percentage'] = 0;
+ }
+
+ $customer['total'] = $totalCustomers;
+ $customer['active'] = $activeCustomers;
+ $customer['today'] = $todayCustomers;
+ return $customer;
+ }
+}
diff --git a/app/Views/auth_confirm_mail.php b/app/Views/auth_confirm_mail.php
index 0f5491f3..7af74836 100644
--- a/app/Views/auth_confirm_mail.php
+++ b/app/Views/auth_confirm_mail.php
@@ -33,21 +33,23 @@
-
+
- BigBambooBookPublishEnter your email address and password to access admin panel.
+ Enter your email address and password to access admin panel.