Skip to content
Open
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 29 additions & 1 deletion src/Cartridge.php
Original file line number Diff line number Diff line change
Expand Up @@ -250,7 +250,18 @@ public function backToStock(array $input, $history = true)
'id' => $input['id'],
]
);
return $result && ($DB->affectedRows() > 0);
if ($result && ($DB->affectedRows() > 0)) {
$changesCartrige = [
0,
'',
__('Cartridge') . ' (' . $input['id'] . ') : ' . strtolower(__('Back to stock')),
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's probably easier to read and translate to use one sentence with replacements rather than a string concatenation:

Suggested change
__('Cartridge') . ' (' . $input['id'] . ') : ' . strtolower(__('Back to stock')),
sprintf(__('Cartridge (%1$s): back to stock', $input['id']),

(same applies for other cases in this PR)

Copy link
Author

@Axel35000-tech Axel35000-tech Oct 28, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for your return, I realized the change

];
$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
Expand Down Expand Up @@ -302,6 +313,14 @@ public function install($pID, $tID)
__('Installing a cartridge'),
];
Log::history($pID, 'Printer', $changes, 0, Log::HISTORY_LOG_SIMPLE_MESSAGE);

$changesCartrige = [
0,
'',
__('Installing a cartridge') . ' (' . $cID . '). ' . __('Printer') . ' : ' . $pID,
];
$this->getFromDB($cID);
Log::history($this->fields['cartridgeitems_id'], CartridgeItem::class, $changesCartrige, Cartridge::class, Log::HISTORY_UPDATE_SUBITEM);
return true;
}
} else {
Expand Down Expand Up @@ -355,6 +374,15 @@ public function uninstall($ID)
Log::HISTORY_LOG_SIMPLE_MESSAGE
);

$this->getFromDB($ID);
$changesCartrige = [
0,
'',
__('Uninstalling a cartridge') . ' (' . $ID . ') ' . __('and') . ' ' . strtolower(__('Delete')),
];

Log::history($this->fields['cartridgeitems_id'], CartridgeItem::class, $changesCartrige, Cartridge::class, Log::HISTORY_UPDATE_SUBITEM);

return true;
}
}
Expand Down
36 changes: 36 additions & 0 deletions src/Consumable.php
Original file line number Diff line number Diff line change
Expand Up @@ -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,
'',
__('Return') . ' : ' . $this->getPreAdditionalInfosForName() . ' (' . $input['id'] . '), ' . __('To') . ' : ' . __('Stock'),
],
static::class,
Log::HISTORY_UPDATE_SUBITEM
);
return true;
}
return false;
Expand Down Expand Up @@ -188,6 +201,29 @@ public function out($ID, $itemtype = '', $items_id = 0)
]
);
if ($result) {
switch ($itemtype) {
case 'User' :
$model = new User();
$model->getFromDB($items_id);
$name = strtoupper($model->fields['name']);
break;
case 'Group' :
default:
$model = new Group();
$model->getFromDB($items_id);
break;
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

`switch` seems useless:

Suggested change
switch ($itemtype) {
case 'User' :
$model = new User();
$model->getFromDB($items_id);
$name = strtoupper($model->fields['name']);
break;
case 'Group' :
default:
$model = new Group();
$model->getFromDB($items_id);
break;
}
$item = getItemForItemtype($itemtype);
$item->getFromDB($items_id);

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for your return, I realized the change

Log::history(
$this->fields["consumableitems_id"],
ConsumableItem::class,
[
0,
'',
$this->getPreAdditionalInfosForName() . ' (' . $ID . ') ' . strtolower(__('Given to')) . ' : '. $model->fields['name'] . ' (' . $ID . ')',
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Isn't the itemtype information missing here?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Adding the itemtype allows for better understanding, I hadded the information

],
static::class,
Log::HISTORY_UPDATE_SUBITEM
);
return true;
}
}
Expand Down
Loading