diff --git a/src/Cartridge.php b/src/Cartridge.php index 6d1424bd5bf..a86e1ffd208 100644 --- a/src/Cartridge.php +++ b/src/Cartridge.php @@ -250,7 +250,24 @@ public function backToStock(array $input, $history = true) 'id' => $input['id'], ] ); - return $result && ($DB->affectedRows() > 0); + if ($result && ($DB->affectedRows() > 0)) { + $changesCartrige = [ + 0, + '', + sprintf(__('Cartridge (%1$s): back to stock'), $input['id']), + ]; + $this->getFromDB($input['id']); + Log::history( + $this->fields['cartridgeitems_id'], + CartridgeItem::class, + $changesCartrige, + Cartridge::class, + Log::HISTORY_UPDATE_SUBITEM + ); + return true; + } + + return false; } // SPECIFIC FUNCTIONS @@ -302,6 +319,20 @@ public function install($pID, $tID) __('Installing a cartridge'), ]; Log::history($pID, 'Printer', $changes, 0, Log::HISTORY_LOG_SIMPLE_MESSAGE); + + $changesCartrige = [ + 0, + '', + sprintf(__('Instal the cartridge %1$s on printer : %2$s'), $cID, $pID), + ]; + $this->getFromDB($cID); + Log::history( + $this->fields['cartridgeitems_id'], + CartridgeItem::class, + $changesCartrige, + Cartridge::class, + Log::HISTORY_UPDATE_SUBITEM + ); return true; } } else { @@ -355,6 +386,21 @@ public function uninstall($ID) Log::HISTORY_LOG_SIMPLE_MESSAGE ); + $this->getFromDB($ID); + $changesCartrige = [ + 0, + '', + sprintf(__('Uninstal the cartridge %1$s for end life'), $ID), + ]; + + Log::history( + $this->fields['cartridgeitems_id'], + CartridgeItem::class, + $changesCartrige, + Cartridge::class, + Log::HISTORY_UPDATE_SUBITEM + ); + return true; } } diff --git a/src/Consumable.php b/src/Consumable.php index a872e68dee5..e8519c78233 100644 --- a/src/Consumable.php +++ b/src/Consumable.php @@ -143,6 +143,19 @@ public function backToStock(array $input, $history = true) ] ); if ($result) { + + $this->getFromDB($input['id']); + Log::history( + $this->fields["consumableitems_id"], + ConsumableItem::class, + [ + 0, + '', + sprintf(__('Return %1$s (%2$s) to stock'), $this->getPreAdditionalInfosForName(), $input['id']), + ], + static::class, + Log::HISTORY_UPDATE_SUBITEM + ); return true; } return false; @@ -188,6 +201,26 @@ public function out($ID, $itemtype = '', $items_id = 0) ] ); if ($result) { + $item = getItemForItemtype($itemtype); + $item->getFromDB($items_id); + Log::history( + $this->fields["consumableitems_id"], + ConsumableItem::class, + [ + 0, + '', + sprintf( + __('%1$s (%2$s) given to : %3$s (%4$s id %5$s)'), + $this->getPreAdditionalInfosForName(), + $ID, + $item->fields['name'], + __($itemtype), + $item->fields['id'] + ), + ], + static::class, + Log::HISTORY_UPDATE_SUBITEM + ); return true; } }