mirror of
https://github.com/snipe/snipe-it.git
synced 2025-03-05 20:52:15 -08:00
Use footer sumformatter for cost totals
This commit is contained in:
parent
585fcfb7d4
commit
5cd2857d5d
|
@ -96,6 +96,7 @@ class AccessoryPresenter extends Presenter
|
|||
"searchable" => true,
|
||||
"sortable" => true,
|
||||
"title" => trans('general.purchase_cost'),
|
||||
"footerFormatter" => 'sumFormatter',
|
||||
], [
|
||||
"field" => "order_number",
|
||||
"searchable" => true,
|
||||
|
|
|
@ -139,6 +139,7 @@ class AssetPresenter extends Presenter
|
|||
"searchable" => true,
|
||||
"sortable" => true,
|
||||
"title" => trans('general.purchase_cost'),
|
||||
"footerFormatter" => 'sumFormatter',
|
||||
], [
|
||||
"field" => "order_number",
|
||||
"searchable" => true,
|
||||
|
|
|
@ -85,6 +85,7 @@ class ComponentPresenter extends Presenter
|
|||
"sortable" => true,
|
||||
"title" => trans('general.purchase_cost'),
|
||||
"visible" => true,
|
||||
"footerFormatter" => 'sumFormatter',
|
||||
],
|
||||
];
|
||||
|
||||
|
|
|
@ -89,6 +89,7 @@ class ConsumablePresenter extends Presenter
|
|||
"sortable" => true,
|
||||
"title" => trans('general.purchase_cost'),
|
||||
"visible" => true,
|
||||
"footerFormatter" => 'sumFormatter',
|
||||
],[
|
||||
"field" => "change",
|
||||
"searchable" => false,
|
||||
|
|
|
@ -98,6 +98,7 @@ class LicensePresenter extends Presenter
|
|||
"sortable" => true,
|
||||
"visible" => false,
|
||||
"title" => trans('general.purchase_cost'),
|
||||
"footerFormatter" => 'sumFormatter',
|
||||
], [
|
||||
"field" => "purchase_order",
|
||||
"searchable" => true,
|
||||
|
|
|
@ -42,6 +42,7 @@
|
|||
@include ('partials.bootstrap-table', [
|
||||
'exportFile' => 'accessories-export',
|
||||
'search' => true,
|
||||
'showFooter' => true,
|
||||
'columns' => \App\Presenters\AccessoryPresenter::dataTableLayout()
|
||||
])
|
||||
@stop
|
||||
|
|
|
@ -45,7 +45,7 @@
|
|||
@stop
|
||||
|
||||
@section('moar_scripts')
|
||||
@include ('partials.bootstrap-table', ['exportFile' => 'components-export', 'search' => true, 'columns' => \App\Presenters\ComponentPresenter::dataTableLayout()])
|
||||
@include ('partials.bootstrap-table', ['exportFile' => 'components-export', 'search' => true, 'showFooter' => true, 'columns' => \App\Presenters\ComponentPresenter::dataTableLayout()])
|
||||
|
||||
|
||||
|
||||
|
|
|
@ -40,5 +40,5 @@
|
|||
@stop
|
||||
|
||||
@section('moar_scripts')
|
||||
@include ('partials.bootstrap-table', ['exportFile' => 'consumables-export', 'search' => true,'columns' => \App\Presenters\ConsumablePresenter::dataTableLayout()])
|
||||
@include ('partials.bootstrap-table', ['exportFile' => 'consumables-export', 'search' => true,'showFooter' => true, 'columns' => \App\Presenters\ConsumablePresenter::dataTableLayout()])
|
||||
@stop
|
||||
|
|
|
@ -101,6 +101,7 @@
|
|||
@include ('partials.bootstrap-table', [
|
||||
'exportFile' => 'assets-export',
|
||||
'search' => true,
|
||||
'showFooter' => true,
|
||||
'columns' => \App\Presenters\AssetPresenter::dataTableLayout()
|
||||
])
|
||||
|
||||
|
|
|
@ -45,6 +45,7 @@
|
|||
@include ('partials.bootstrap-table', [
|
||||
'exportFile' => 'licenses-export',
|
||||
'search' => true,
|
||||
'showFooter' => true,
|
||||
'columns' => \App\Presenters\LicensePresenter::dataTableLayout()])
|
||||
|
||||
@stop
|
||||
|
|
|
@ -38,6 +38,9 @@ $('.snipe-table').bootstrapTable({
|
|||
cookie: true,
|
||||
cookieExpire: '2y',
|
||||
showExport: true,
|
||||
@if (isset($showFooter))
|
||||
showFooter: true,
|
||||
@endif
|
||||
showColumns: true,
|
||||
trimOnSearch: false,
|
||||
|
||||
|
@ -202,7 +205,7 @@ $('.snipe-table').bootstrapTable({
|
|||
}
|
||||
|
||||
|
||||
// This handles
|
||||
// This handles the icons and display of polymorphic entries
|
||||
function polymorphicItemFormatter(value) {
|
||||
|
||||
var item_destination = '';
|
||||
|
@ -419,6 +422,15 @@ $('.snipe-table').bootstrapTable({
|
|||
}
|
||||
}
|
||||
|
||||
function sumFormatter(data) {
|
||||
var field = this.field;
|
||||
var total_sum = data.reduce(function(sum, row) {
|
||||
return (sum) + (parseFloat(row[field]) || 0);
|
||||
}, 0);
|
||||
return total_sum.toFixed(2);
|
||||
}
|
||||
|
||||
|
||||
$(function () {
|
||||
$('#bulkEdit').click(function () {
|
||||
var selectedIds = $('.snipe-table').bootstrapTable('getSelections');
|
||||
|
@ -429,7 +441,9 @@ $('.snipe-table').bootstrapTable({
|
|||
});
|
||||
});
|
||||
|
||||
// This is necessary to make the bootstrap tooltips work inside of the wenzhixin/bootstrap-table formatters
|
||||
|
||||
// This is necessary to make the bootstrap tooltips work inside of the
|
||||
// wenzhixin/bootstrap-table formatters
|
||||
$(function() {
|
||||
$('#table').on('post-body.bs.table', function () {
|
||||
$('[data-tooltip="true"]').tooltip({
|
||||
|
@ -439,4 +453,6 @@ $('.snipe-table').bootstrapTable({
|
|||
});
|
||||
|
||||
|
||||
|
||||
|
||||
</script>
|
||||
|
|
|
@ -33,7 +33,7 @@
|
|||
<th data-searchable="true" data-sortable="false" data-field="start_date" data-formatter="dateDisplayFormatter">{{ trans('admin/asset_maintenances/form.start_date') }}</th>
|
||||
<th data-searchable="true" data-sortable="true" data-field="completion_date" data-formatter="dateDisplayFormatter">{{ trans('admin/asset_maintenances/form.completion_date') }}</th>
|
||||
<th data-searchable="true" data-sortable="true" data-field="asset_maintenance_time">{{ trans('admin/asset_maintenances/form.asset_maintenance_time') }}</th>
|
||||
<th data-searchable="true" data-sortable="true" data-field="cost" class="text-right">{{ trans('admin/asset_maintenances/form.cost') }}</th>
|
||||
<th data-searchable="true" data-sortable="true" data-field="cost" class="text-right" data-footer-formatter="sumFormatter">{{ trans('admin/asset_maintenances/form.cost') }}</th>
|
||||
<th data-searchable="true" data-sortable="true" data-field="user_id" data-formatter="usersLinkObjFormatter">{{ trans('general.admin') }}</th>
|
||||
<th data-searchable="true" data-sortable="true" data-field="notes" data-visible="false">{{ trans('admin/asset_maintenances/form.notes') }}</th>
|
||||
</tr>
|
||||
|
@ -48,5 +48,8 @@
|
|||
@stop
|
||||
|
||||
@section('moar_scripts')
|
||||
@include ('partials.bootstrap-table', ['exportFile' => 'maintenances-export', 'search' => true])
|
||||
@include ('partials.bootstrap-table',
|
||||
['exportFile' => 'maintenances-export',
|
||||
'search' => true,
|
||||
'showFooter' => true ])
|
||||
@stop
|
||||
|
|
Loading…
Reference in a new issue