[Bug]: Item Kits Save Failure
objecttothis opened this issue · comments
OpensourcePOS Version
opensourcepos 3.4.0-dev
Php version
Php 8.2
What browsers are you seeing the problem on?
Firefox
Server Operating System and version
Windows 11
Database Management System and version
MySQL 8.2.0
Web Server and version
Apache 2.4.58
Expected Behavior?
Item Kits search suggestion form to produce search suggestions for items to add based on typed characters and successful save
Bug Description?
When creating a new item kit in the Item Kits view typing text in Kit Item does not produce search suggestions or allow adding. Clicking submit produces the following error:
ERROR - 2024-03-12 17:32:20 --> mysqli_sql_exception: Column 'item_id' cannot be null in C:\Users\objec\PhpstormProjects\opensourcepos\vendor\codeigniter4\framework\system\Database\MySQLi\Connection.php:306
Stack trace:
#0 C:\Users\objec\PhpstormProjects\opensourcepos\vendor\codeigniter4\framework\system\Database\MySQLi\Connection.php(306): mysqli->query('INSERT INTO `os...', 0)
#1 C:\Users\objec\PhpstormProjects\opensourcepos\vendor\codeigniter4\framework\system\Database\BaseConnection.php(693): CodeIgniter\Database\MySQLi\Connection->execute('INSERT INTO `os...')
#2 C:\Users\objec\PhpstormProjects\opensourcepos\vendor\codeigniter4\framework\system\Database\BaseConnection.php(607): CodeIgniter\Database\BaseConnection->simpleQuery('INSERT INTO `os...')
#3 C:\Users\objec\PhpstormProjects\opensourcepos\vendor\codeigniter4\framework\system\Database\BaseBuilder.php(2307): CodeIgniter\Database\BaseConnection->query('INSERT INTO `os...', Array, false)
#4 C:\Users\objec\PhpstormProjects\opensourcepos\app\Models\Item_kit.php(176): CodeIgniter\Database\BaseBuilder->insert(Array)
#5 C:\Users\objec\PhpstormProjects\opensourcepos\app\Controllers\Item_kits.php(181): App\Models\Item_kit->save_value(Array, -1)
#6 C:\Users\objec\PhpstormProjects\opensourcepos\vendor\codeigniter4\framework\system\CodeIgniter.php(941): App\Controllers\Item_kits->postSave()
#7 C:\Users\objec\PhpstormProjects\opensourcepos\vendor\codeigniter4\framework\system\CodeIgniter.php(502): CodeIgniter\CodeIgniter->runController(Object(App\Controllers\Item_kits))
#8 C:\Users\objec\PhpstormProjects\opensourcepos\vendor\codeigniter4\framework\system\CodeIgniter.php(361): CodeIgniter\CodeIgniter->handleRequest(NULL, Object(Config\Cache), false)
#9 C:\Users\objec\PhpstormProjects\opensourcepos\public\index.php(79): CodeIgniter\CodeIgniter->run()
#10 {main}
CRITICAL - 2024-03-12 17:32:20 --> CodeIgniter\Database\Exceptions\DatabaseException: Column 'item_id' cannot be null
in SYSTEMPATH\Database\BaseConnection.php on line 647.
1 SYSTEMPATH\Database\BaseBuilder.php(2307): CodeIgniter\Database\BaseConnection->query('INSERT INTO `ospos_item_kits` (`name`, `item_kit_number`, `item_id`, `kit_discount`, `kit_discount_type`, `price_option`, `print_option`, `description`) VALUES (:name:, :item_kit_number:, :item_id:, :kit_discount:, :kit_discount_type:, :price_option:, :print_option:, :description:)', [...], false)
2 APPPATH\Models\Item_kit.php(176): CodeIgniter\Database\BaseBuilder->insert([...])
3 APPPATH\Controllers\Item_kits.php(181): App\Models\Item_kit->save_value([...], -1)
4 SYSTEMPATH\CodeIgniter.php(941): App\Controllers\Item_kits->postSave()
5 SYSTEMPATH\CodeIgniter.php(502): CodeIgniter\CodeIgniter->runController(Object(App\Controllers\Item_kits))
6 SYSTEMPATH\CodeIgniter.php(361): CodeIgniter\CodeIgniter->handleRequest(null, Object(Config\Cache), false)
7 FCPATH\index.php(79): CodeIgniter\CodeIgniter->run()
CRITICAL - 2024-03-12 17:32:20 --> [Caused by] CodeIgniter\Database\Exceptions\DatabaseException: Column 'item_id' cannot be null
in SYSTEMPATH\Database\MySQLi\Connection.php on line 311.
1 SYSTEMPATH\Database\BaseConnection.php(693): CodeIgniter\Database\MySQLi\Connection->execute('INSERT INTO `ospos_item_kits` (`name`, `item_kit_number`, `item_id`, `kit_discount`, `kit_discount_type`, `price_option`, `print_option`, `description`) VALUES (\'Test\', \'765765\', NULL, 12.35, 0, 0, 0, \'\')')
2 SYSTEMPATH\Database\BaseConnection.php(607): CodeIgniter\Database\BaseConnection->simpleQuery('INSERT INTO `ospos_item_kits` (`name`, `item_kit_number`, `item_id`, `kit_discount`, `kit_discount_type`, `price_option`, `print_option`, `description`) VALUES (\'Test\', \'765765\', NULL, 12.35, 0, 0, 0, \'\')')
3 SYSTEMPATH\Database\BaseBuilder.php(2307): CodeIgniter\Database\BaseConnection->query('INSERT INTO `ospos_item_kits` (`name`, `item_kit_number`, `item_id`, `kit_discount`, `kit_discount_type`, `price_option`, `print_option`, `description`) VALUES (:name:, :item_kit_number:, :item_id:, :kit_discount:, :kit_discount_type:, :price_option:, :print_option:, :description:)', [...], false)
4 APPPATH\Models\Item_kit.php(176): CodeIgniter\Database\BaseBuilder->insert([...])
5 APPPATH\Controllers\Item_kits.php(181): App\Models\Item_kit->save_value([...], -1)
6 SYSTEMPATH\CodeIgniter.php(941): App\Controllers\Item_kits->postSave()
7 SYSTEMPATH\CodeIgniter.php(502): CodeIgniter\CodeIgniter->runController(Object(App\Controllers\Item_kits))
8 SYSTEMPATH\CodeIgniter.php(361): CodeIgniter\CodeIgniter->handleRequest(null, Object(Config\Cache), false)
9 FCPATH\index.php(79): CodeIgniter\CodeIgniter->run()
CRITICAL - 2024-03-12 17:32:20 --> [Caused by] mysqli_sql_exception: Column 'item_id' cannot be null
in SYSTEMPATH\Database\MySQLi\Connection.php on line 306.
1 SYSTEMPATH\Database\MySQLi\Connection.php(306): mysqli->query('INSERT INTO `ospos_item_kits` (`name`, `item_kit_number`, `item_id`, `kit_discount`, `kit_discount_type`, `price_option`, `print_option`, `description`) VALUES (\'Test\', \'765765\', NULL, 12.35, 0, 0, 0, \'\')', 0)
2 SYSTEMPATH\Database\BaseConnection.php(693): CodeIgniter\Database\MySQLi\Connection->execute('INSERT INTO `ospos_item_kits` (`name`, `item_kit_number`, `item_id`, `kit_discount`, `kit_discount_type`, `price_option`, `print_option`, `description`) VALUES (\'Test\', \'765765\', NULL, 12.35, 0, 0, 0, \'\')')
3 SYSTEMPATH\Database\BaseConnection.php(607): CodeIgniter\Database\BaseConnection->simpleQuery('INSERT INTO `ospos_item_kits` (`name`, `item_kit_number`, `item_id`, `kit_discount`, `kit_discount_type`, `price_option`, `print_option`, `description`) VALUES (\'Test\', \'765765\', NULL, 12.35, 0, 0, 0, \'\')')
4 SYSTEMPATH\Database\BaseBuilder.php(2307): CodeIgniter\Database\BaseConnection->query('INSERT INTO `ospos_item_kits` (`name`, `item_kit_number`, `item_id`, `kit_discount`, `kit_discount_type`, `price_option`, `print_option`, `description`) VALUES (:name:, :item_kit_number:, :item_id:, :kit_discount:, :kit_discount_type:, :price_option:, :print_option:, :description:)', [...], false)
5 APPPATH\Models\Item_kit.php(176): CodeIgniter\Database\BaseBuilder->insert([...])
6 APPPATH\Controllers\Item_kits.php(181): App\Models\Item_kit->save_value([...], -1)
7 SYSTEMPATH\CodeIgniter.php(941): App\Controllers\Item_kits->postSave()
8 SYSTEMPATH\CodeIgniter.php(502): CodeIgniter\CodeIgniter->runController(Object(App\Controllers\Item_kits))
9 SYSTEMPATH\CodeIgniter.php(361): CodeIgniter\CodeIgniter->handleRequest(null, Object(Config\Cache), false)
10 FCPATH\index.php(79): CodeIgniter\CodeIgniter->run()
Steps to Reproduce?
Item Kits > New Item Kit
Type characters into "Kit Item"
Click submit
System Information Report (optional)
OSPOS Installation Info: 3.4.0-dev - dev
Language Code: en-US
Extensions & Modules:
» GD: Enabled ✓
» BC Math: Enabled ✓
» INTL: Enabled ✓
» OpenSSL: Enabled ✓
» MBString: Enabled ✓
» Curl: Enabled ✓
» Xml: Enabled ✓
User Configuration:
.Browser: Firefox
.Server Software: Apache/2.4.58 (Win64) OpenSSL/3.1.3 mod_fcgid/2.3.10-dev
.PHP Version: 8.2.12
.DB Version: 8.2.0
.Server Port: 80
.OS: Windows NT 10.0
File Permissions:
» [writeable/logs:] - 0777 | Writable ✓ | Vulnerable or Incorrect Permissions ✗
» [public/uploads:] - 0777 | Writable ✓ | Vulnerable or Incorrect Permissions ✗
» [writable/uploads/item_pics:] - 0777 | Writable ✓ | Vulnerable or Incorrect Permissions ✗
» [import_customers.csv:] - 0666 | Readable ✓ | Vulnerable or Incorrect Permissions ✗
Security Vulnerability Warning
Incorrect permissions leaves this software at risk.
» [writeable/logs:] is writable, but the permissions are incorrectly set. Please set it to 750 and refresh.
» [writable/uploads:] is writable, but the permissions are incorrectly set. Please set it to 750 and refresh.
» [writable/uploads/item_pics:] is writable, but the permissions are incorrectly set. Please set it to 750 and refresh.
» [import_customers.csv:] is readable, but the permissions are incorrectly set. Please set it to 640 or 660 and refresh.
Asia/Baku
Unmodified copy of OpensourcePOS
- I agree this copy has not been modified
Perhaps I'm not understanding properly what the kit item field is supposed to be. It's not saving the value entered. Also if you delete the last item in the item kits and click submit it will submit and tell you it was a success but then it does not save the changes. Validation should prevent you from submitting and dismissing the modal window if there are no items in the item kit.
3.3.9 does not support any versions of php8. Lol
3.3.9 does not support any versions of php8. Lol
Yeah, it's actually 3.4.0 dev bit that isn't a choice until the bug template gets merged.
Controller/Item_kits. Function postSave To fix that issue I replace 'item_id' => empty($this->request->getPost('kit_item_id')) ? null : intval($this->request->getPost('kit_item_id')), with 'item_id' => $this->request->getPost('kit_item_id'), and now the kit is being saved.
I found that if I removed empty() it works fine.
In the item kits form i also had to change line 92 to 'value' => $item_kit_info->kit_discount due to the following error.
CRITICAL - 2024-03-12 12:15:24 --> Argument 1 passed to to_decimals() must be of the type float or null, string given, called in C:\newwamp\www\ospos\app\Views\item_kits\form.php on line 92
in APPPATH\Helpers\locale_helper.php on line 434.
1 APPPATH\Views\item_kits\form.php(92): to_decimals('')
2 SYSTEMPATH\View\View.php(228): include('C:\newwamp\www\ospos\app\Views\item_kits\form.php')
3 SYSTEMPATH\View\View.php(231): CodeIgniter\View\View->CodeIgniter\View{closure}()
4 SYSTEMPATH\Common.php(1190): CodeIgniter\View\View->render('item_kits/form', [], true)
5 APPPATH\Controllers\Item_kits.php(161): view('item_kits/form', [...])
6 SYSTEMPATH\CodeIgniter.php(942): App\Controllers\Item_kits->getView()
7 SYSTEMPATH\CodeIgniter.php(502): CodeIgniter\CodeIgniter->runController(Object(App\Controllers\Item_kits))
8 SYSTEMPATH\CodeIgniter.php(361): CodeIgniter\CodeIgniter->handleRequest(null, Object(Config\Cache), false)
9 FCPATH\index.php(79): CodeIgniter\CodeIgniter->run()
For this issue in controller/item_kits in view i added the following and now it does not give this error.
if($item_kit_id == NEW_ENTRY)
{
$info->price_option = '0';
$info->print_option = PRINT_ALL;
$info->kit_item_id = 0;
$info->item_number = '';
$info->kit_discount = 0; this is the new info I had to add
}
It appears it iw working fine in the Dev demo. Only issue so far is the Register needs more changes.