diff --git a/app/Controllers/ApiIntegration.php b/app/Controllers/ApiIntegration.php index 03f14340..a78d5aae 100644 --- a/app/Controllers/ApiIntegration.php +++ b/app/Controllers/ApiIntegration.php @@ -355,7 +355,7 @@ class ApiIntegration extends ResourceController $this->logger->error("Api SaveBookDetails : Err = Image Data Not Found"); } if (count($categories) > 0 && $last_insert_book_id != "") { - //$this->save_categories_master_details($categories); + $this->save_categories_master_details($categories); $extensive_correspondence .= " Its have " . count($categories) . " Categories"; $basic_message .= " And Its have " . count($categories) . " Categories"; $this->logger->info("Api SaveBookDetails : ".$extensive_correspondence); @@ -1039,78 +1039,66 @@ class ApiIntegration extends ResourceController $response = ['status' => 204, 'message' => 'Data No Found']; } return $response; - } + } public function save_categories_master_details($records) { $api_model = new ApiIntegrationModel(); if (count($records) > 0) { - $this->logger->info("Api SaveCategoriesMasterDetails : Categories Count = ".count($records)); - $existing_categories = $api_model->getData('category', ['isactive' => 1]); - $request_categories = (array)$records; - - $filteringExistingCategoriesWpApiId = []; - $filteringRequestedCategoriesWpApiId = []; - $commonCategoriesElement = []; - if (!empty($existing_categories)) { - for ($z = 0; $z < count($request_categories); $z++) { - $filteringRequestedCategoriesWpApiId[$z] = $request_categories[$z]->id; - } - for ($y = 0; $y < count($existing_categories); $y++) { - $filteringExistingCategoriesWpApiId[$y] = $existing_categories[$y]->wp_api_category_id; - } - - if (!empty($filteringExistingCategoriesWpApiId)) { - $this->logger->info("Api SaveCategoriesMasterDetails : Incoming Categories Wp Id " .implode(",",$filteringRequestedCategoriesWpApiId)); - $this->logger->info("Api SaveCategoriesMasterDetails : Existing Categories Wp Id " .implode(",",$filteringExistingCategoriesWpApiId)); - $A = $filteringExistingCategoriesWpApiId; - $B = $filteringRequestedCategoriesWpApiId; - $missingCategoriesValues = array_diff($A, $B); //Find difference element in Existing Images only - $commonCategoriesElement = array_intersect($A, $B); - if (!empty($missingCategoriesValues)) { - $this->logger->info("Api SaveCategoriesMasterDetails : Missing Categories Wp Id " .implode(",",$missingCategoriesValues)." Are inactived"); - $inactive_where = ['isactive' => 1]; - $inactive_whereIn[0] = 'wp_api_category_id'; - $inactive_whereIn[1] = $missingCategoriesValues; - $api_model->inactiveMissingDetails('category', $inactive_where, $inactive_whereIn); - } - } + $this->logger->info("Api SaveCategoriesMasterDetails : Master Categories Count = " . count($records)); + $where = ['isactive' => 1]; + $where_in = null; + $existing_master_categories = $api_model->getData('category', $where); + $request_master_categories = (array)$records; + $common_master_categories = []; + $filter_existing_master_categories_WPID = []; + $filter_request_master_categories_WPID = []; + if (!empty($request_master_categories)) { + for ($z = 0; $z < count($request_master_categories); $z++) { + $filter_request_master_categories_WPID[$z] = $request_master_categories[$z]->id; } - - $where = ['isactive' => 1]; - if (!empty($commonCategoriesElement)) { - $whereIn[0] = 'wp_api_category_id'; - $whereIn[1] = $commonCategoriesElement; - } else { - $whereIn = null; - } - $lastestActiveCategoriesData = $api_model->getData('category', $where, $whereIn); - $this->logger->info("Api SaveCategoriesMasterDetails : lastest Active Book Categories Data Count " .count($lastestActiveCategoriesData)); - $book_category_data = []; - $a = 0; - foreach ($records as $r) { - $categoryId = null; - // Iterate through the array and find the 'book_img_id' based on 'wp_api_img_id' - if (!empty($lastestActiveBookImageData)) { - foreach ($lastestActiveBookImageData as $item) { - if ($item->wp_api_category_id == $r->id) { - $categoryId = $item->id; - break; // Found the match, no need to continue looping - } - } - } - $book_category_data[$a]['id'] = $categoryId; - $book_category_data[$a]['name'] = $r->name; - $book_category_data[$a]['wp_api_category_id'] = $r->id; - $book_category_data[$a]['parent_wp_api_category_id'] =NULL; - $a++; - $this->logger->info("Api SaveCategoriesMasterDetails : Categories Data = $a Request data to save master = ".json_encode($book_category_data)); - } // loop closed - $extensive_correspondence = (!empty($book_image_data) ? $api_model->insertAndUpdateChildDetails($book_category_data, 'category', 'id') : ""); - $this->logger->info("Api SaveCategoriesMasterDetails : ".$extensive_correspondence); - } // count closed - else{ - $this->logger->error("Api SaveCategoriesMasterDetails : Err = Categories Data Not Found"); + $this->logger->info("Api SaveCategoriesMasterDetails : Incoming Categories Wp Id " . implode(",", $filter_request_master_categories_WPID)); } + if (!empty($existing_master_categories)) { + for ($y = 0; $y < count($existing_master_categories); $y++) { + $filter_existing_master_categories_WPID[$y] = $existing_master_categories[$y]->wp_api_category_id; + } + $this->logger->info("Api SaveCategoriesMasterDetails : Existing Categories Wp Id " . implode(",", $filter_existing_master_categories_WPID)); + } + if (!empty($filter_existing_master_categories_WPID)) { + $common_master_categories = array_intersect($filter_existing_master_categories_WPID, $filter_request_master_categories_WPID); + if (!empty($common_master_categories)) { + $where_in[0] = 'wp_api_category_id'; + $where_in[1] = $common_master_categories; + } + } + $lastestActiveMasterCategoriesData = $api_model->getData('category', $where, $where_in); + $this->logger->info("Api SaveCategoriesMasterDetails : lastest Active Book Categories Data Count " . count($lastestActiveMasterCategoriesData)); + $book_category_data = []; + $a = 0; + foreach ($request_master_categories as $r) { + $masterCategoryId = null; + if (!empty($lastestActiveMasterCategoriesData)) { + foreach ($lastestActiveMasterCategoriesData as $l) { + if ($l->wp_api_category_id == $r->id) { + $masterCategoryId = $l->id; //local category id from Master Table + break; // Found the match, no need to continue looping + } + } + } + $book_category_data[$a]['id'] = $masterCategoryId; + $book_category_data[$a]['name'] = $r->name; + $book_category_data[$a]['wp_api_category_id'] = $r->id; + $book_category_data[$a]['business_id'] = 1; + $book_category_data[$a]['parent_wp_api_category_id'] = NULL; + $a++; + $this->logger->info("Api SaveCategoriesMasterDetails : Categories Data = $a Request data to save on master category = " . json_encode($book_category_data)); + } // loop closed + $message = (!empty($book_category_data) ? $api_model->insertAndUpdateChildDetails($book_category_data, 'category', 'id') : "Info : New Categories Not Avaialble to Save"); + $this->logger->info("Api SaveCategoriesMasterDetails : " . $message); + } // count closed + else { + $this->logger->error("Api SaveCategoriesMasterDetails : Err = Categories Data Not Found"); + } } } \ No newline at end of file diff --git a/app/Controllers/BaseController.php b/app/Controllers/BaseController.php index 5e90b4b2..5bc5988c 100644 --- a/app/Controllers/BaseController.php +++ b/app/Controllers/BaseController.php @@ -79,15 +79,15 @@ abstract class BaseController extends Controller $data['loggedin_person_role'] = $details[0]['role']; $data['favicon'] = !empty($details[0]['favicon']) && file_exists(FCPATH."public/uploads/".$details[0]['favicon']) ? base_url("public/uploads/".$details[0]['favicon']) : base_url("public/uploads/default.ico"); - $data['profile_picture'] = !empty($details[0]['profile_picture']) && file_exists(FCPATH."public/uploads/".$details[0]['profile_picture']) ? base_url("public/uploads/" . $details[0]['profile_picture']) : base_url("public/assets/images/users/avatar-9.jpg"); + $data['profile_picture'] = base_url("public/uploads/avatar.png"); $data['company_logo_small'] = !empty($details[0]['company_logo_small']) && file_exists(FCPATH."public/uploads/".$details[0]['company_logo_small']) ? base_url("public/uploads/" . $details[0]['company_logo_small']) : base_url("public/uploads/default_logo.png"); $data['company_logo_large'] = !empty($details[0]['company_logo_large']) && file_exists(FCPATH."public/uploads/".$details[0]['company_logo_large']) ? base_url("public/uploads/" . $details[0]['company_logo_large']) : base_url("public/uploads/default.png"); $data['browser_title'] = $data['company_name'] . ' | ' . $data['company_short_name'] . ' ' . $data['page_name']; $data['heading'] = $data['page_name'] === "Dashboard" ? 'Welcome to ' . $data['company_name'] : ""; $data['loggedin_person'] = $session_uname; $session_bid = get_business_id(); -$data['bid'] = $session_bid; - + $data['bid'] = $session_bid; + $data['footer_about'] = $details[0]['footer_about']; echo view('template/header.php', $data); echo view('template/topbar.php', $data); diff --git a/app/Models/AuthenticationModel.php b/app/Models/AuthenticationModel.php index 046977e5..f34224a7 100644 --- a/app/Models/AuthenticationModel.php +++ b/app/Models/AuthenticationModel.php @@ -5,12 +5,12 @@ class AuthenticationModel extends Model { protected $table = 'users'; protected $primaryKey = 'user_id'; - protected $allowedFields = ['user_id','user_name','email','first_name','last_name','password','mobile_no','date_of_birth','address','gender','profile_picture','city','state','postal_code','country','role','isactive','business_id','reset_link']; + protected $allowedFields = ['user_id','email','first_name','last_name','password','mobile_no','date_of_birth','address','gender','profile_picture','city','state','postal_code','country','role','isactive','business_id','reset_link']; public function getheringDetailsForHeader($user_id) { $builder = $this->db->table('users'); - $builder->select('users.user_id,users.user_name,users.business_id,users.profile_picture,users.role,settings.site_name,settings.site_title,settings.favicon,settings.logo as company_logo_large,business.business_logo as company_logo_small,business.email as company_email,business.address as company_address,business.mobile_no as company_mobile_no,business.title'); + $builder->select('users.user_id,users.business_id,users.profile_picture,users.role,settings.site_name,settings.site_title,settings.favicon,settings.logo as company_logo_large,business.business_logo as company_logo_small,business.email as company_email,business.address as company_address,business.mobile_no as company_mobile_no,business.title,settings.footer_about'); $builder->join('settings', 'settings.business_id = users.business_id', 'left'); $builder->join('business', 'business.business_id = users.business_id', 'left'); $builder->where('user_id', $user_id); diff --git a/app/Views/template/footer.php b/app/Views/template/footer.php index a7ddc74d..6d7a6d4e 100644 --- a/app/Views/template/footer.php +++ b/app/Views/template/footer.php @@ -6,42 +6,47 @@