Skip to content

Conversation

@Axel35000-tech
Copy link

Checklist before requesting a review

Please delete options that are not relevant.

  • I have read the CONTRIBUTING document.
  • I have performed a self-review of my code.

Description

  • Here is a brief description of what this PR does
    Hello,
    my client want to have more logs about consumables and cartridges.
    The code in this PR is to add logs when :
  • you give a consumable or install a cartridge
  • the cartridge or consumable back to the stock
  • the cartridge is used

Copy link
Contributor

@trasher trasher left a comment

Choose a reason for hiding this comment

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

Please add tests

$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

Comment on lines 204 to 215
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

[
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

@Axel35000-tech
Copy link
Author

@trasher Hi, thanks for your returns, which types of tests you want here ? Thanks

@trasher
Copy link
Contributor

trasher commented Oct 28, 2025

@trasher Hi, thanks for your returns, which types of tests you want here ? Thanks

Just make sure logs table contains expected information after each impacted step.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants