diff --git a/app/Controllers/Items.php b/app/Controllers/Items.php index 9b7647170..4c3a18990 100644 --- a/app/Controllers/Items.php +++ b/app/Controllers/Items.php @@ -940,6 +940,7 @@ class Items extends Secure_Controller $items_to_delete = $this->request->getPost('ids'); if ($this->item->delete_list($items_to_delete)) { + Events::trigger('item_deleted', $items_to_delete); $message = lang('Items.successful_deleted') . ' ' . count($items_to_delete) . ' ' . lang('Items.one_or_multiple'); return $this->response->setJSON(['success' => true, 'message' => $message]); } else { diff --git a/app/Models/Item.php b/app/Models/Item.php index c865d70dc..2a403a522 100644 --- a/app/Models/Item.php +++ b/app/Models/Item.php @@ -16,7 +16,6 @@ use stdClass; */ class Item extends Model { - public const ALLOWED_SUGGESTIONS_COLUMNS = ['name', 'item_number', 'description', 'cost_price', 'unit_price']; public const ALLOWED_SUGGESTIONS_COLUMNS_WITH_EMPTY = ['', 'name', 'item_number', 'description', 'cost_price', 'unit_price']; @@ -428,11 +427,11 @@ class Item extends Model /** * Gets information about multiple items */ - public function get_multiple_info(array $item_ids, int $location_id): ResultInterface + public function getMultipleInfo(array $itemIds, int $locationId): ResultInterface { $format = $this->db->escape(dateformat_mysql()); - $builder = $this->db->table('items'); + $builder = $this->db->table($this->table); $builder->select('items.*'); $builder->select('MAX(company_name) AS company_name'); $builder->select('GROUP_CONCAT(DISTINCT CONCAT_WS(\'_\', definition_id, attribute_value) ORDER BY definition_id SEPARATOR \'|\') AS attribute_values'); @@ -445,8 +444,8 @@ class Item extends Model $builder->join('attribute_links', 'attribute_links.item_id = items.item_id AND sale_id IS NULL AND receiving_id IS NULL', 'left'); $builder->join('attribute_values', 'attribute_links.attribute_id = attribute_values.attribute_id', 'left'); - $builder->where('location_id', $location_id); - $builder->whereIn('items.item_id', $item_ids); + $builder->where('location_id', $locationId); + $builder->whereIn('items.item_id', $itemIds); $builder->groupBy('items.item_id'); @@ -455,7 +454,7 @@ class Item extends Model public function getItems(array $itemIds): array { - return $this->db->table('items') + return $this->db->table($this->table) ->whereIn('item_id', $itemIds) ->get() ->getResultArray();