From b41380d36a8ec5aedec58cd5722fde9814486fc8 Mon Sep 17 00:00:00 2001 From: objec Date: Thu, 2 Apr 2026 23:51:07 +0400 Subject: [PATCH] CSV Import fixes - Corrected Capitalization in File Handling Logic - Populated $allowedStockLocations before sending it to the validation function Signed-off-by: objec --- .htaccess | 4 +-- app/Controllers/Items.php | 7 ++++- app/Views/partial/header.php | 57 ++++++++++++++++++++++++++++++++++++ public/.htaccess | 4 +-- 4 files changed, 67 insertions(+), 5 deletions(-) diff --git a/.htaccess b/.htaccess index 26ee09f0f..cc7e2bc9d 100755 --- a/.htaccess +++ b/.htaccess @@ -4,12 +4,12 @@ RewriteCond %{REQUEST_URI} !^public$ RewriteCond %{REQUEST_URI} !^/.well-known/acme-challenge [NC] - RewriteRule "^(.*)$" "/public/" [R=301,L] + # RewriteRule "^(.*)$" "/public/" [R=301,L] # If you installed CodeIgniter in a subfolder, you will need to # change the following line to match the subfolder you need. Uncomment # the line below and comment the line above. - #RewriteRule "^(.*)$" "/[SUBDIRECTORY]/public/" [R=301,L] + RewriteRule "^(.*)$" "/opensourcepos/public/" [R=301,L] # disable directory browsing diff --git a/app/Controllers/Items.php b/app/Controllers/Items.php index db684002b..da11672a4 100644 --- a/app/Controllers/Items.php +++ b/app/Controllers/Items.php @@ -1008,7 +1008,7 @@ class Items extends Secure_Controller 'pic_filename' => $row['Image'] ]; - if (!empty($row['supplier ID'])) { + if (!empty($row['Supplier ID'])) { $itemData['supplier_id'] = $this->supplier->exists($row['Supplier ID']) ? $row['Supplier ID'] : null; } @@ -1026,7 +1026,12 @@ class Items extends Secure_Controller } if (!$isFailedRow) { + $allowedStockLocations = $this->stock_location->get_allowed_locations(); $isFailedRow = $this->validateCSVData($row, $itemData, $allowedStockLocations, $attributeDefinitionNames, $attributeData); + if (!empty($invalidLocations)) { + $isFailedRow = true; + log_message('error', 'CSV import: Invalid stock location(s) found: ' . implode(', ', $invalidLocations)); + } } // Remove false, null, '' and empty strings but keep 0 diff --git a/app/Views/partial/header.php b/app/Views/partial/header.php index 3bb51ac57..5ab828e0f 100644 --- a/app/Views/partial/header.php +++ b/app/Views/partial/header.php @@ -23,11 +23,66 @@ $request = Services::request(); getGet('debug') == 'true') : ?> + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + @@ -35,6 +90,8 @@ $request = Services::request(); + + diff --git a/public/.htaccess b/public/.htaccess index 8d5f3efbb..6c802c7b4 100644 --- a/public/.htaccess +++ b/public/.htaccess @@ -39,10 +39,10 @@ Options All -Indexes RewriteCond %{REQUEST_FILENAME} !-d # If in web root - RewriteRule ^([\s\S]*)$ index.php/$1 [L,NC,QSA] + # RewriteRule ^([\s\S]*)$ index.php/$1 [L,NC,QSA] # If in subdir comment above line, uncomment the line below and replace with your path - #RewriteRule ^(.*)$ //public/index.php?/$1 [L] + RewriteRule ^(.*)$ /opensourcepos/public/index.php?/$1 [L] # Ensure Authorization header is passed along RewriteCond %{HTTP:Authorization} .