diff --git a/app/Controllers/Items.php b/app/Controllers/Items.php index 8060885bc..dbcdcc4d6 100644 --- a/app/Controllers/Items.php +++ b/app/Controllers/Items.php @@ -765,7 +765,7 @@ class Items extends Secure_Controller 'trans_inventory' => $updated_quantity - $item_quantity->quantity ]; - $success &= $this->inventory->insert($inv_data); + $success &= $this->inventory->insert($inv_data, false); } } @@ -908,7 +908,7 @@ class Items extends Secure_Controller 'trans_inventory' => parse_quantity($this->request->getPost('newquantity')) ]; - $this->inventory->insert($inv_data); + $this->inventory->insert($inv_data, false); //Update stock quantity $item_quantity = $this->item_quantity->get_item_quantity($item_id, $location_id); @@ -1362,7 +1362,7 @@ class Items extends Secure_Controller $this->item_quantity->save_value($item_quantity_data, $item_data['item_id'], $location_id); $csv_data['trans_inventory'] = $row["location_$location_name"]; - $this->inventory->insert($csv_data); //TODO: Reflection Exception + $this->inventory->insert($csv_data, false); } elseif($is_update) { @@ -1374,7 +1374,7 @@ class Items extends Secure_Controller $this->item_quantity->save_value($item_quantity_data, $item_data['item_id'], $location_id); $csv_data['trans_inventory'] = 0; - $this->inventory->insert($csv_data); //TODO: Reflection Exception + $this->inventory->insert($csv_data, false); } } } diff --git a/app/Database/Migrations/20220127000000_convert_to_ci4.php b/app/Database/Migrations/20220127000000_convert_to_ci4.php index c86df6517..f795c310b 100644 --- a/app/Database/Migrations/20220127000000_convert_to_ci4.php +++ b/app/Database/Migrations/20220127000000_convert_to_ci4.php @@ -6,7 +6,7 @@ use App\Models\Appconfig; use CodeIgniter\Database\Forge; use CodeIgniter\Database\Migration; use CodeIgniter\HTTP\RedirectResponse; -use CodeIgniter\Router\Exceptions\RedirectException; +use CodeIgniter\HTTP\Exceptions\RedirectException; use Config\Encryption; use Config\Services; diff --git a/app/Models/Inventory.php b/app/Models/Inventory.php index 1c77f8628..23eda3e4f 100644 --- a/app/Models/Inventory.php +++ b/app/Models/Inventory.php @@ -2,10 +2,8 @@ namespace App\Models; -use CodeIgniter\Database\BaseResult; use CodeIgniter\Database\ResultInterface; use CodeIgniter\Model; -use ReflectionException; /** * Inventory class @@ -28,20 +26,6 @@ class Inventory extends Model 'trans_location' ]; - /** - * Insert new data into the Inventory table. - * - * @param array|null|object $inventory_data Data to be inserted into the inventory table. - * @param bool $returnID Returns the value of the ID column for the inserted row. - * @return int|string|bool The ID of the inserted row on success or false on failure - */ - public function insert($inventory_data = null, bool $returnID = true) - { - $builder = $this->db->table('inventory'); - - return $builder->insert($inventory_data, $returnID); - } - /** * @param $comment * @param $inventory_data diff --git a/app/Models/Item.php b/app/Models/Item.php index 541ac7f90..943876a1e 100644 --- a/app/Models/Item.php +++ b/app/Models/Item.php @@ -510,7 +510,6 @@ class Item extends Model /** * Deletes one item - * @throws ReflectionException */ public function delete($item_id = null, bool $purge = false) { @@ -547,7 +546,6 @@ class Item extends Model /** * Deletes a list of items - * @throws ReflectionException */ public function delete_list(array $item_ids): bool { diff --git a/app/Models/Receiving.php b/app/Models/Receiving.php index 8c70f5752..d772f0274 100644 --- a/app/Models/Receiving.php +++ b/app/Models/Receiving.php @@ -185,7 +185,7 @@ class Receiving extends Model 'trans_inventory' => $items_received ]; - $inventory->insert($inv_data); + $inventory->insert($inv_data, false); $attribute->copy_attribute_links($item_data['item_id'], 'receiving_id', $receiving_id); $supplier = $supplier->get_info($supplier_id); //TODO: supplier is never used after this. } @@ -247,7 +247,7 @@ class Receiving extends Model 'trans_inventory' => $item['quantity_purchased'] * (-$item['receiving_quantity']) ]; // update inventory - $inventory->insert($inv_data); + $inventory->insert($inv_data, false); // update quantities $item_quantity->change_quantity($item['item_id'], $item['item_location'], $item['quantity_purchased'] * (-$item['receiving_quantity'])); diff --git a/app/Models/Sale.php b/app/Models/Sale.php index e2794f66a..9cddabec2 100644 --- a/app/Models/Sale.php +++ b/app/Models/Sale.php @@ -783,7 +783,7 @@ class Sale extends Model 'trans_inventory' => -$item_data['quantity'] ]; - $inventory->insert($inv_data); + $inventory->insert($inv_data, false); } $attribute->copy_attribute_links($item_data['item_id'], 'sale_id', $sale_id); @@ -955,7 +955,7 @@ class Sale extends Model 'trans_inventory' => $item_data['quantity_purchased'] ]; // update inventory - $inventory->insert($inv_data); + $inventory->insert($inv_data, false); // update quantities $item_quantity->change_quantity($item_data['item_id'], $item_data['item_location'], $item_data['quantity_purchased']);