From 7bd9d2822acf0cca6519dcedcc0bbb6091f65e5e Mon Sep 17 00:00:00 2001 From: objec Date: Thu, 11 Jun 2026 23:03:51 +0400 Subject: [PATCH] Stock Location changes - Add TODO for pending refactor - Add function to getUndeleted Stock Locations that don't pull in grants, people and permissions for Plugin use. - Remove unused function that was being called by Plugins but was inefficient. Signed-off-by: objec --- app/Models/Stock_location.php | 24 ++++++++++-------------- 1 file changed, 10 insertions(+), 14 deletions(-) diff --git a/app/Models/Stock_location.php b/app/Models/Stock_location.php index 2f4a7ef9f..4e9bde876 100644 --- a/app/Models/Stock_location.php +++ b/app/Models/Stock_location.php @@ -58,11 +58,20 @@ class Stock_location extends Model return $builder->get(); } + public function getUndeleted(): array + { + return $this->db->table('stock_locations') + ->select('location_id, location_name') + ->where('deleted', 0) + ->get() + ->getResultArray(); + } + /** * @param string $module_id * @return ResultInterface */ - public function get_undeleted_all(string $module_id = 'items'): ResultInterface + public function get_undeleted_all(string $module_id = 'items'): ResultInterface //TODO: Refactor this to getUndeletedWithPermissions() { $builder = $this->db->table('stock_locations'); $builder->join('permissions AS permissions', 'permissions.location_id = stock_locations.location_id'); @@ -260,19 +269,6 @@ class Stock_location extends Model } } - public function getStockLocationsByItem(int $itemId): array - { - return $this->db->table('item_quantities') - ->select('stock_locations.location_name, item_quantities.quantity') - ->join('stock_locations', 'stock_locations.location_id = item_quantities.location_id') - ->where('item_quantities.item_id', $itemId) - ->where('stock_locations.deleted', 0) - ->where('item_quantities.quantity >', 0) - ->orderBy('item_quantities.quantity', 'DESC') - ->get() - ->getResultArray(); - } - /** * Deletes one item * @param int|null $location_id