3
0
mirror of https://github.com/snipe/snipe-it.git synced 2026-02-05 06:35:35 +00:00

Display qty in history

This commit is contained in:
Marcus Moore
2025-12-15 15:12:34 -08:00
parent 1ccf38221f
commit 8a595aa269
2 changed files with 23 additions and 3 deletions

View File

@ -80,7 +80,7 @@ class ActionlogsTransformer
// this is a custom field
if (str_starts_with($fieldname, '_snipeit_')) {
foreach ($custom_fields as $custom_field) {
if ($custom_field->db_column == $fieldname) {
@ -185,7 +185,7 @@ class ActionlogsTransformer
'name' => e($actionlog->target->display_name) ?? null,
'type' => e($actionlog->targetType()),
] : null,
'qty' => $this->getQuantity($actionlog),
'note' => ($actionlog->note) ? Helper::parseEscapedMarkedownInline($actionlog->note): null,
'signature_file' => ($actionlog->accept_signature) ? route('log.signature.view', ['filename' => $actionlog->accept_signature ]) : null,
'log_meta' => ((isset($clean_meta)) && (is_array($clean_meta))) ? $clean_meta: null,
@ -336,6 +336,19 @@ class ActionlogsTransformer
}
private function getQuantity(Actionlog $actionlog): ?int
{
if (!$actionlog->qty) {
return null;
}
// only a few action types will have a quantity we are interested in.
if (!in_array($actionlog->action_type, ['checkout', 'accepted', 'declined', 'checkin from'])) {
return null;
}
return (int) $actionlog->qty;
}
}

View File

@ -117,6 +117,13 @@ class HistoryPresenter extends Presenter
'visible' => true,
'formatter' => 'fileDownloadButtonsFormatter',
],
[
'field' => 'qty',
'searchable' => false,
'sortable' => true,
'visible' => true,
'title' => trans('general.quantity'),
],
[
'field' => 'note',
'searchable' => true,
@ -169,4 +176,4 @@ class HistoryPresenter extends Presenter
return json_encode($merged);
}
}
}