Skip to content

A free open source IT asset/license management system

Added sum footers to presenters on fields where a total makes sense

snipe75d2a7ffb7cb
diff --git a/app/Presenters/ActionlogPresenter.php b/app/Presenters/ActionlogPresenter.php
index 197cc459e4..bc63ab3880 100644
--- a/app/Presenters/ActionlogPresenter.php
+++ b/app/Presenters/ActionlogPresenter.php
@@ -57,10 +57,6 @@ class ActionlogPresenter extends Presenter
return 'fa-solid fa-user-minus';
}
- if ($this->action_type == 'delete') {
- return 'fa-solid fa-user-minus';
- }
-
if ($this->action_type == 'upload deleted') {
return 'fa-solid fa-trash';
}
@@ -144,10 +140,10 @@ class ActionlogPresenter extends Presenter
public function actionType()
{
- // Zero-delta QuantityAdjust entries are audit-only submissions —
- // the operator counted the shelf and confirmed the on-hand qty
+ // Zero-delta QuantityAdjust entries are audit-only submissions.
+ // The operator counted the shelf and confirmed the on-hand qty
// matches the DB. Rendering these as "adjusted quantity" with a
- // blank change column is confusing; surface them as "confirmed
+ // blank change column is confusing. Surface them as "confirmed
// quantity" instead. The underlying action_type value stays
// 'adjusted quantity' so filters and reports keep working.
if ($this->action_type === 'adjusted quantity' && (int) $this->quantity === 0) {
diff --git a/app/Presenters/CategoryPresenter.php b/app/Presenters/CategoryPresenter.php
index 619e11a6e9..5733bf3deb 100644
--- a/app/Presenters/CategoryPresenter.php
+++ b/app/Presenters/CategoryPresenter.php
@@ -63,6 +63,8 @@ class CategoryPresenter extends Presenter
'sortable' => true,
'title' => trans('general.qty'),
'visible' => true,
+ 'class' => 'text-right text-padding-number-cell',
+ 'footerFormatter' => 'qtySumFormatter',
], [
'field' => 'has_eula',
'scope' => 'col',
diff --git a/app/Presenters/CompanyPresenter.php b/app/Presenters/CompanyPresenter.php
index 455496b2e7..b5a751b204 100644
--- a/app/Presenters/CompanyPresenter.php
+++ b/app/Presenters/CompanyPresenter.php
@@ -57,6 +57,8 @@ class CompanyPresenter extends Presenter
'switchable' => true,
'title' => trans('admin/companies/table.children'),
'visible' => true,
+ 'class' => 'text-right text-padding-number-cell',
+ 'footerFormatter' => 'qtySumFormatter',
], [
'field' => 'phone',
'scope' => 'col',
@@ -100,8 +102,8 @@ class CompanyPresenter extends Presenter
'sortable' => true,
'title' => trans('general.users'),
'visible' => true,
- 'class' => 'css-users',
-
+ 'class' => 'css-users text-right text-padding-number-cell',
+ 'footerFormatter' => 'qtySumFormatter',
], [
'field' => 'assets_count',
'scope' => 'col',
@@ -109,8 +111,8 @@ class CompanyPresenter extends Presenter
'sortable' => true,
'title' => trans('general.assets'),
'visible' => true,
- 'class' => 'css-barcode',
-
+ 'class' => 'css-barcode text-right text-padding-number-cell',
+ 'footerFormatter' => 'qtySumFormatter',
], [
'field' => 'licenses_count',
'scope' => 'col',
@@ -118,7 +120,8 @@ class CompanyPresenter extends Presenter
'sortable' => true,
'title' => trans('general.licenses'),
'visible' => true,
- 'class' => 'css-license',
+ 'class' => 'css-license text-right text-padding-number-cell',
+ 'footerFormatter' => 'qtySumFormatter',
], [
'field' => 'accessories_count',
'scope' => 'col',
@@ -126,7 +129,8 @@ class CompanyPresenter extends Presenter
'sortable' => true,
'title' => trans('general.accessories'),
'visible' => true,
- 'class' => 'css-accessory',
+ 'class' => 'css-accessory text-right text-padding-number-cell',
+ 'footerFormatter' => 'qtySumFormatter',
], [
'field' => 'consumables_count',
'scope' => 'col',
@@ -134,7 +138,8 @@ class CompanyPresenter extends Presenter
'sortable' => true,
'title' => trans('general.consumables'),
'visible' => true,
- 'class' => 'css-consumable',
+ 'class' => 'css-consumable text-right text-padding-number-cell',
+ 'footerFormatter' => 'qtySumFormatter',
], [
'field' => 'components_count',
'scope' => 'col',
@@ -142,7 +147,8 @@ class CompanyPresenter extends Presenter
'sortable' => true,
'title' => trans('general.components'),
'visible' => true,
- 'class' => 'css-component',
+ 'class' => 'css-component text-right text-padding-number-cell',
+ 'footerFormatter' => 'qtySumFormatter',
], [
'field' => 'tag_color',
'scope' => 'col',
diff --git a/app/Presenters/DepartmentPresenter.php b/app/Presenters/DepartmentPresenter.php
index 571a496d06..6f8d12872d 100644
--- a/app/Presenters/DepartmentPresenter.php
+++ b/app/Presenters/DepartmentPresenter.php
@@ -85,7 +85,8 @@ class DepartmentPresenter extends Presenter
'title' => trans('general.people'),
'titleTooltip' => trans('general.people'),
'visible' => true,
- 'class' => 'css-house-user',
+ 'class' => 'css-house-user text-right text-padding-number-cell',
+ 'footerFormatter' => 'qtySumFormatter',
], [
'field' => 'tag_color',
'scope' => 'col',
diff --git a/app/Presenters/LocationPresenter.php b/app/Presenters/LocationPresenter.php
index b83406eb26..5d58a248cd 100644
--- a/app/Presenters/LocationPresenter.php
+++ b/app/Presenters/LocationPresenter.php
@@ -78,7 +78,8 @@ class LocationPresenter extends Presenter
'title' => trans('general.people'),
'titleTooltip' => trans('general.people'),
'visible' => true,
- 'class' => 'css-house-user',
+ 'class' => 'css-house-user text-right text-padding-number-cell',
+ 'footerFormatter' => 'qtySumFormatter',
], [
'field' => 'assets_count',
'scope' => 'col',
@@ -88,7 +89,8 @@ class LocationPresenter extends Presenter
'title' => trans('admin/locations/message.current_location'),
'titleTooltip' => trans('admin/locations/message.current_location'),
'visible' => true,
- 'class' => 'css-house-laptop',
+ 'class' => 'css-house-laptop text-right text-padding-number-cell',
+ 'footerFormatter' => 'qtySumFormatter',
], [
'field' => 'rtd_assets_count',
'scope' => 'col',
@@ -99,7 +101,8 @@ class LocationPresenter extends Presenter
'titleTooltip' => trans('admin/hardware/form.default_location'),
'tooltip' => 'true',
'visible' => false,
- 'class' => 'css-house-flag',
+ 'class' => 'css-house-flag text-right text-padding-number-cell',
+ 'footerFormatter' => 'qtySumFormatter',
], [
'field' => 'assigned_assets_count',
'scope' => 'col',
@@ -109,7 +112,8 @@ class LocationPresenter extends Presenter
'title' => trans('admin/locations/message.assigned_assets'),
'titleTooltip' => trans('admin/locations/message.assigned_assets'),
'visible' => true,
- 'class' => 'css-house-laptop',
+ 'class' => 'css-house-laptop text-right text-padding-number-cell',
+ 'footerFormatter' => 'qtySumFormatter',
], [
'field' => 'accessories_count',
'scope' => 'col',
@@ -119,7 +123,8 @@ class LocationPresenter extends Presenter
'title' => trans('general.accessories'),
'titleTooltip' => trans('general.accessories'),
'visible' => true,
- 'class' => 'css-accessory',
+ 'class' => 'css-accessory text-right text-padding-number-cell',
+ 'footerFormatter' => 'qtySumFormatter',
], [
'field' => 'assigned_accessories_count',
'scope' => 'col',
@@ -129,7 +134,8 @@ class LocationPresenter extends Presenter
'title' => trans('general.accessories_assigned'),
'titleTooltip' => trans('general.accessories_assigned'),
'visible' => true,
- 'class' => 'css-accessory-alt',
+ 'class' => 'css-accessory-alt text-right text-padding-number-cell',
+ 'footerFormatter' => 'qtySumFormatter',
], [
'field' => 'components_count',
'scope' => 'col',
@@ -139,7 +145,8 @@ class LocationPresenter extends Presenter
'title' => trans('general.components'),
'titleTooltip' => trans('general.components'),
'visible' => true,
- 'class' => 'css-component',
+ 'class' => 'css-component text-right text-padding-number-cell',
+ 'footerFormatter' => 'qtySumFormatter',
],
[
'field' => 'consumables_count',
@@ -150,7 +157,8 @@ class LocationPresenter extends Presenter
'title' => trans('general.consumables'),
'titleTooltip' => trans('general.consumables'),
'visible' => true,
- 'class' => 'css-consumable',
+ 'class' => 'css-consumable text-right text-padding-number-cell',
+ 'footerFormatter' => 'qtySumFormatter',
],
[
'field' => 'children_count',
@@ -161,7 +169,8 @@ class LocationPresenter extends Presenter
'title' => trans('general.child_locations'),
'titleTooltip' => trans('general.child_locations'),
'visible' => true,
- 'class' => 'css-child-locations',
+ 'class' => 'css-child-locations text-right text-padding-number-cell',
+ 'footerFormatter' => 'qtySumFormatter',
], [
'field' => 'currency',
'scope' => 'col',
diff --git a/app/Presenters/ManufacturerPresenter.php b/app/Presenters/ManufacturerPresenter.php
index 6ffa46c637..504ace9f77 100644
--- a/app/Presenters/ManufacturerPresenter.php
+++ b/app/Presenters/ManufacturerPresenter.php
@@ -114,7 +114,8 @@ class ManufacturerPresenter extends Presenter
'switchable' => true,
'title' => trans('general.assets'),
'visible' => true,
- 'class' => 'css-barcode',
+ 'class' => 'css-barcode text-right text-padding-number-cell',
+ 'footerFormatter' => 'qtySumFormatter',
],
[
'field' => 'licenses_count',
@@ -124,7 +125,8 @@ class ManufacturerPresenter extends Presenter
'switchable' => true,
'title' => trans('general.licenses'),
'visible' => true,
- 'class' => 'css-license',
+ 'class' => 'css-license text-right text-padding-number-cell',
+ 'footerFormatter' => 'qtySumFormatter',
],
[
'field' => 'consumables_count',
@@ -134,7 +136,8 @@ class ManufacturerPresenter extends Presenter
'switchable' => true,
'title' => trans('general.consumables'),
'visible' => true,
- 'class' => 'css-consumable',
+ 'class' => 'css-consumable text-right text-padding-number-cell',
+ 'footerFormatter' => 'qtySumFormatter',
],
[
'field' => 'accessories_count',
@@ -144,7 +147,8 @@ class ManufacturerPresenter extends Presenter
'switchable' => true,
'title' => trans('general.accessories'),
'visible' => true,
- 'class' => 'css-accessory',
+ 'class' => 'css-accessory text-right text-padding-number-cell',
+ 'footerFormatter' => 'qtySumFormatter',
], [
'field' => 'components_count',
'scope' => 'col',
@@ -153,7 +157,8 @@ class ManufacturerPresenter extends Presenter
'switchable' => true,
'title' => trans('general.components'),
'visible' => true,
- 'class' => 'css-component',
+ 'class' => 'css-component text-right text-padding-number-cell',
+ 'footerFormatter' => 'qtySumFormatter',
], [
'field' => 'created_by',
'scope' => 'col',
diff --git a/app/Presenters/OrderItemsPresenter.php b/app/Presenters/OrderItemsPresenter.php
new file mode 100644
index 0000000000..f235ddcc07
--- /dev/null
+++ b/app/Presenters/OrderItemsPresenter.php
@@ -0,0 +1,108 @@
+<?php
+
+namespace App\Presenters;
+
+/**
+ * Column layout for the Orders tab on Accessory / Consumable /
+ * Component / AssetModel view pages. Rendered by <x-table> against
+ * the corresponding /orders API endpoint per model.
+ */
+class OrderItemsPresenter
+{
+ public static function dataTableLayout(): string
+ {
+ return json_encode([
+ [
+ 'field' => 'created_at',
+ 'scope' => 'col',
+ 'searchable' => false,
+ 'sortable' => true,
+ 'switchable' => true,
+ 'title' => trans('general.created_at'),
+ 'visible' => true,
+ 'formatter' => 'dateDisplayFormatter',
+ ],
+ [
+ 'field' => 'created_by',
+ 'scope' => 'col',
+ 'searchable' => true,
+ 'sortable' => false,
+ 'switchable' => true,
+ 'title' => trans('general.created_by'),
+ 'visible' => true,
+ 'formatter' => 'usersLinkObjFormatter',
+ ],
+ [
+ 'field' => 'purchase_date',
+ 'scope' => 'col',
+ 'searchable' => false,
+ 'sortable' => false,
+ 'switchable' => true,
+ 'title' => trans('general.purchase_date'),
+ 'visible' => true,
+ 'formatter' => 'dateDisplayFormatter',
+ ],
+ [
+ 'field' => 'order_number',
+ 'scope' => 'col',
+ 'searchable' => true,
+ 'sortable' => false,
+ 'switchable' => true,
+ 'title' => trans('general.order_number'),
+ 'visible' => true,
+ ],
+ [
+ 'field' => 'supplier',
+ 'scope' => 'col',
+ 'searchable' => true,
+ 'sortable' => false,
+ 'switchable' => true,
+ 'title' => trans('general.supplier'),
+ 'visible' => true,
+ 'formatter' => 'suppliersLinkObjFormatter',
+ ],
+ [
+ 'field' => 'qty',
+ 'scope' => 'col',
+ 'searchable' => false,
+ 'sortable' => true,
+ 'switchable' => true,
+ 'title' => trans('general.qty'),
+ 'visible' => true,
+ 'footerFormatter' => 'sumFormatter',
+ 'class' => 'text-right text-padding-number-cell',
+ ],
+ [
+ 'field' => 'unit_cost',
+ 'scope' => 'col',
+ 'searchable' => false,
+ 'sortable' => false,
+ 'switchable' => true,
+ 'title' => trans('general.unit_cost'),
+ 'visible' => true,
+ 'footerFormatter' => 'sumFormatter',
+ 'class' => 'text-right text-padding-number-cell',
+ ],
+ [
+ 'field' => 'currency',
+ 'scope' => 'col',
+ 'searchable' => false,
+ 'sortable' => false,
+ 'switchable' => true,
+ 'title' => trans('general.currency'),
+ 'visible' => true,
+ ],
+ [
+ 'field' => 'total_cost',
+ 'scope' => 'col',
+ 'searchable' => false,
+ 'sortable' => false,
+ 'switchable' => true,
+ 'title' => trans('general.total_cost'),
+ 'visible' => true,
+ 'footerFormatter' => 'sumFormatter',
+ 'class' => 'text-right text-padding-number-cell',
+ ],
+ ]);
+ }
+}