diff --git a/app/Controllers/Business.php b/app/Controllers/Business.php
index 5501754c..620bb55b 100644
--- a/app/Controllers/Business.php
+++ b/app/Controllers/Business.php
@@ -57,11 +57,11 @@ class Business extends BaseController
$session_uid = get_logged_user_id();
$session_role = get_user_role();
- ## CI validation rule for bfile
+ ## CI validation rule for business_logo
$validationRule = [
- 'bfile' => [
+ 'business_logo' => [
'label' => 'Image File',
- 'rules' => 'uploaded[bfile]|is_image[bfile]|mime_in[bfile,image/jpg,image/jpeg,image/gif,image/png,image/webp]'
+ 'rules' => 'uploaded[business_logo]|is_image[business_logo]|mime_in[business_logo,image/jpg,image/jpeg,image/gif,image/png,image/webp]'
]
];
@@ -69,58 +69,57 @@ class Business extends BaseController
$img = $this->request->getFile('bfile');
$business_id = $this->request->getPost('business_id');
- $img_details = $this->request->getFile('bfile'); // Here I Have Image details ;
+ $img_details = $this->request->getFile('business_logo'); // Here I Have Image details ;
$final_img_name = NULL;//Just flag
$existing_img_name = $this->request->getPost('existing_business_logo_name'); // HiddenField for if have any pic name means;
$img_path = 'public/uploads/';
-
- ## File Already Existing or not
+
##Step 1 : image details available
if($img_details){
- $this->logger->info("Business: image details avaiable");
+ $this->logger->info("business logo: image details avaiable");
##Step 2 : i have image details .
if ($img_details->isValid()) {
##Step 3 : image Name.$new_img_name."
";
$new_img_name = $img_details->getName(); // before movement name
- $this->logger->info("Business: Image Name B4 Upload".$new_img_name);
+ $this->logger->info("business logo: Image Name B4 Upload".$new_img_name);
##Step 4 : Validation Rule Apply here.if not throw the error"
";
if (!$this->validate($validationRule)) {
if($new_img_name !== ''){
$error = $this->validator->getErrors();
// echo "Error : ".(string)$error."
";
- $this->logger->error("Business: Err on image upload".$error['bfile']);
- throw new \Exception((string)$error['bfile']);
+ $this->logger->error("business logo: Err on image upload".$error['business_logo']);
+ throw new \Exception((string)$error['business_logo']);
}
}
##Step 5 : Check Existing and New Image Name Same Or not same no use to move on target folder
if($new_img_name !== $existing_img_name){
- $this->logger->info("Business: Image Name are Differ".$new_img_name." & ".$existing_img_name);
+ $this->logger->info("business logo: Image Name are Differ".$new_img_name." & ".$existing_img_name);
## Step 6 : Different Image Name means removed on target folder using Unlink;
if ($existing_img_name && is_file($img_path.$existing_img_name)) {
- $this->logger->info("Business: already Image Available on target Folder Path : ".$img_path.$existing_img_name." So, Deleted.");
+ $this->logger->info("business logo: already Image Available on target Folder Path : ".$img_path.$existing_img_name." So, Deleted.");
// echo "Deleted_file : ".(string)$img_path.$existing_img_name."
";
unlink($img_path.$existing_img_name);
}
## Step 7 : Moved to target;
$img_details->move($img_path, $new_img_name);
$final_img_name = $img_details->getName(); // after movement name
- $this->logger->info("Business: Image Name After Upload".$final_img_name);
+ $this->logger->info("business logo: Image Name After Upload".$final_img_name);
}else{
$final_img_name = $existing_img_name;
- $this->logger->info("Business: Image Name are same".$new_img_name." & ".$existing_img_name." Can't Upload");
+ $this->logger->info("business logo: Image Name are same".$new_img_name." & ".$existing_img_name." Can't Upload");
}
}
else{
## Step 8 : Not a Vaild Image File so replace Existing file name;
$final_img_name = $existing_img_name;
- $this->logger->info("Business: Not a Vaild Image File Nothing To Update/Upload");
+ $this->logger->info("business logo: Not a Vaild Image File Nothing To Update/Upload");
// throw new \Exception("Not a Vaild Image File");
}
}
else{
## Step 9 : Testing Purpose File Details Not Available. so i can't move it.;
- $this->logger->info("Business: Testing Purpose Image Details Not Available. so i can't move it.");
+ $this->logger->info("business logo: Testing Purpose Image Details Not Available. so i can't move it.");
$final_img_name = $existing_img_name;
//throw new \Exception("Testing Purpose File Details Not Available so i can't move it if you have existing filee means save it or your choice");
}
diff --git a/app/Controllers/Settings.php b/app/Controllers/Settings.php
index a2230d69..539326a1 100755
--- a/app/Controllers/Settings.php
+++ b/app/Controllers/Settings.php
@@ -47,7 +47,11 @@ class Settings extends BaseController
{
$model = new BusinessModel();
$model->setTable('business');
- $business_details = $model->orderBy('business_id', 'DESC')->findAll();
+ $business_details = $model->orderBy('business.business_id', 'DESC')
+ ->select('business.*,settings.setting_id')
+ ->join('settings', 'settings.business_id = business.business_id', 'left')
+ ->groupBy('business.business_id')
+ ->findAll();
return $business_details;
}
@@ -59,80 +63,95 @@ class Settings extends BaseController
$session_bid = get_business_id();
$session_uid = get_logged_user_id();
- $validationRule = [
- 'usersetiing' => [
- 'label' => 'Image File',
- 'rules' => [
- 'uploaded[slogo]',
- 'is_image[slogo]',
- 'mime_in[slogo,image/jpg,image/jpeg,image/gif,image/png,image/webp]',
+ // $validationRule = [
+ // 'favicon' => [
+ // 'label' => 'Favicon',
+ // 'rules' => [
+ // 'uploaded[favicon]',
+ // 'is_image[favicon]',
+ // 'mime_in[favicon,image/ico,image/x-icon]',
+ // ],
+ // ],
+ // ];
- ],
- ],
+ // if (!$this->validate($validationRule)) {
+ // // Validation failed, return to the form with errors
+ // $data['validation_errors'] = $this->validator->getErrors();
+ // $this->render_page('setting_form', $data);
+ // return;
+ // }
- 'favicon' => [
- 'label' => 'Favicon',
- 'rules' => [
- 'uploaded[favicon]',
- 'is_image[favicon]',
- 'mime_in[favicon,image/ico,image/x-icon]',
- ],
- ],
- ];
-
- if (!$this->validate($validationRule)) {
- // Validation failed, return to the form with errors
- $data['validation_errors'] = $this->validator->getErrors();
- $this->render_page('setting_form', $data);
- return;
- }
- $img = $this->request->getFile('slogo');
$setting_id = $this->request->getPost('setting_id');
$business_id = $this->request->getPost('business_id');
-
-
- $filePath ='public/uploads/' . $this->request->getPost('slogo');
-
- ## File Already Existing or not
+ $img_details = $this->request->getFile('favicon'); // Here I Have Image details ;
+
+ ## CI validation rule for favicon
+ $validationRule = [
+ 'favicon' => [
+ 'label' => 'Image File',
+ 'rules' => 'uploaded[favicon]|is_image[favicon]|mime_in[favicon,image/jpg,image/jpeg,image/gif,image/png,image/webp]'
+ ]
+ ];
+
+ $final_img_name = NULL;//Just flag
+ $existing_img_name = $this->request->getPost('existing_favicon_name'); // HiddenField for if have any pic name means;
+ $img_path = 'public/uploads/';
- if ($img->isValid() && !$img->hasMoved()) {
- $fileName = $img->getName();
- $img->move('public/uploads/', $fileName);
-
-
- // Delete the previous image file if it exists
- if ($setting_id) {
- $previousFileName = $this->request->getPost('previous_sfile');
- if ($previousFileName && is_file('public/uploads/' . $previousFileName)) {
- unlink('public/uploads/' . $previousFileName);
+ ##Step 1 : image details available
+ if($img_details){
+ $this->logger->info("Sitesetting Favicon: image details avaiable");
+ ##Step 2 : i have image details .
+ if ($img_details->isValid()) {
+ ##Step 3 : image Name.$new_img_name."
";
+ $new_img_name = $img_details->getName(); // before movement name
+ $this->logger->info("Sitesetting Favicon: Image Name B4 Upload".$new_img_name);
+ ##Step 4 : Validation Rule Apply here.if not throw the error"
";
+ if (!$this->validate($validationRule)) {
+ if($new_img_name !== ''){
+
+ $error = $this->validator->getErrors();
+ // echo "Error : ".(string)$error."
";
+ $this->logger->error("Sitesetting Favicon: Err on image upload".$error['favicon']);
+ throw new \Exception((string)$error['favicon']);
+ }
}
+ ##Step 5 : Check Existing and New Image Name Same Or not same no use to move on target folder
+ if($new_img_name !== $existing_img_name){
+ $this->logger->info("Sitesetting Favicon: Image Name are Differ".$new_img_name." & ".$existing_img_name);
+ ## Step 6 : Different Image Name means removed on target folder using Unlink;
+ if ($existing_img_name && is_file($img_path.$existing_img_name)) {
+ $this->logger->info("Sitesetting Favicon: already Image Available on target Folder Path : ".$img_path.$existing_img_name." So, Deleted.");
+ // echo "Deleted_file : ".(string)$img_path.$existing_img_name."
";
+ unlink($img_path.$existing_img_name);
+ }
+ ## Step 7 : Moved to target;
+ $img_details->move($img_path, $new_img_name);
+ $final_img_name = $img_details->getName(); // after movement name
+ $this->logger->info("Sitesetting Favicon: Image Name After Upload".$final_img_name);
+ }else{
+ $final_img_name = $existing_img_name;
+ $this->logger->info("Sitesetting Favicon: Image Name are same".$new_img_name." & ".$existing_img_name." Can't Upload");
+ }
+ }
+ else{
+ ## Step 8 : Not a Vaild Image File so replace Existing file name;
+ $final_img_name = $existing_img_name;
+ $this->logger->info("Sitesetting Favicon: Not a Vaild Image File Nothing To Update/Upload");
+ // throw new \Exception("Not a Vaild Image File");
}
- } else {
- $fileName = $this->request->getPost('previous_sfile', ''); // Use the previous filename if no new image is provided
}
- $favicon = $this->request->getFile('favicon');
- if ($favicon->isValid() && !$favicon->hasMoved()) {
- $faviconName = $favicon->getName();
- $favicon->move('public/uploads/', $faviconName);
-
- // Delete the previous favicon file if it exists
- if ($setting_id) {
- $previousFaviconName = $this->request->getPost('previous_favicon');
- if ($previousFaviconName && is_file('public/uploads/' . $previousFaviconName)) {
- unlink('public/uploads/' . $previousFaviconName);
+ else{
+ ## Step 9 : Testing Purpose File Details Not Available. so i can't move it.;
+ $this->logger->info("Sitesetting Favicon: Testing Purpose Image Details Not Available. so i can't move it.");
+ $final_img_name = $existing_img_name;
+ //throw new \Exception("Testing Purpose File Details Not Available so i can't move it if you have existing filee means save it or your choice");
}
- }
-} else {
- $faviconName = $this->request->getPost('previous_favicon', ''); // Use the previous favicon filename if no new favicon is provided
-}
$SettingsModel = new SettingsModel();
$data = [
-
'site_name' => $this->request->getPost('site_name'),
'site_title' => $this->request->getPost('site_title'),
- 'favicon' => $this->request->getPost('favicon'),
'logo' => $this->request->getPost('logo'),
'terms_service' => $this->request->getPost('terms_service'),
'footer_about' => $this->request->getPost('footer_about'),
@@ -152,8 +171,7 @@ class Settings extends BaseController
'currency'=> $this->request->getPost('currency'),
'country'=> $this->request->getPost('country'),
'business_id'=> $this->request->getPost('business_id'),
- 'logo'=>$fileName,
- 'favicon'=>$faviconName
+ 'favicon'=>$final_img_name
];
$setting_id = $this->request->getPost('setting_id'); // Get the business ID for update
diff --git a/app/Views/business_form.php b/app/Views/business_form.php
index 03a22511..b5157eb0 100644
--- a/app/Views/business_form.php
+++ b/app/Views/business_form.php
@@ -87,23 +87,25 @@
+
= $businesses['business_logo']; ?>
- +