Improved the rendering of a part instock change log entry

This commit is contained in:
Jan Böhmer 2023-01-08 01:41:04 +01:00
parent 4c94d9c150
commit 5d6b7a9470
3 changed files with 72 additions and 1 deletions

View file

@ -32,10 +32,12 @@ use App\Entity\LogSystem\ElementDeletedLogEntry;
use App\Entity\LogSystem\ElementEditedLogEntry;
use App\Entity\LogSystem\ExceptionLogEntry;
use App\Entity\LogSystem\LegacyInstockChangedLogEntry;
use App\Entity\LogSystem\PartStockChangedLogEntry;
use App\Entity\LogSystem\SecurityEventLogEntry;
use App\Entity\LogSystem\UserLoginLogEntry;
use App\Entity\LogSystem\UserLogoutLogEntry;
use App\Entity\LogSystem\UserNotAllowedLogEntry;
use App\Entity\Parts\PartLot;
use App\Services\ElementTypeNameGenerator;
use Symfony\Contracts\Translation\TranslatorInterface;
@ -179,6 +181,23 @@ class LogEntryExtraFormatter
$array[] = htmlspecialchars($context->getMessage());
}
if ($context instanceof PartStockChangedLogEntry) {
$array['log.part_stock_changed.change'] = sprintf("%s %s %s (%s)",
$context->getOldStock(),
'<i class="fa-solid fa-right-long"></i>',
$context->getNewStock(),
($context->getNewStock() > $context->getOldStock() ? '+' : '-'). $context->getChangeAmount(),
);
if (!empty($context->getComment())) {
$array['log.part_stock_changed.comment'] = htmlspecialchars($context->getComment());
}
if ($context->getInstockChangeType() === PartStockChangedLogEntry::TYPE_MOVE) {
$array['log.part_stock_changed.move_target'] =
$this->elementTypeNameGenerator->getLocalizedTypeLabel(PartLot::class)
.' ' . $context->getMoveToTargetID();
}
}
return $array;
}
}