A free open source IT asset/license management system
Added bulk options for consumables
snipe4cfc69144b36
diff --git a/resources/views/blade/table/consumables.blade.php b/resources/views/blade/table/consumables.blade.phpindex 505d253fc1..3690740a1a 100644--- a/resources/views/blade/table/consumables.blade.php+++ b/resources/views/blade/table/consumables.blade.php@@ -17,6 +17,10 @@{{ $table_header }}</x-slot:table_header>+ <x-slot:bulkactions>+ <x-table.bulk-consumables />+ </x-slot:bulkactions>+<x-table:$presenter:$fixed_right_numberdiff --git a/resources/views/components/bulk-delete.blade.php b/resources/views/components/bulk-delete.blade.phpindex 889eb6496f..11128f2961 100644--- a/resources/views/components/bulk-delete.blade.php+++ b/resources/views/components/bulk-delete.blade.php@@ -9,12 +9,12 @@{{-- Page content --}}@section('content')<x-container class="col-md-8 col-md-offset-2">- <p>{{ trans('admin/components/general.bulk_delete_help') }}</p>+ <p>{{ trans('general.bulk_delete_help', ['items' => trans('general.components')]) }}</p><x-form route="{{ route('components.bulkdelete.store') }}"><x-box><x-callout type="warning" icon="warning" live="assertive">- {{ trans_choice('admin/components/general.bulk_delete_warn', count($components), ['component_count' => count($components)]) }}+ {{ trans_choice('general.bulk_delete_warn', count($components), ['count' => count($components), 'item' => trans('general.component'), 'items' => trans('general.components')]) }}</x-callout><table class="table table-striped">diff --git a/resources/views/components/bulk-edit.blade.php b/resources/views/components/bulk-edit.blade.phpindex 49132596f5..c9676700c2 100644--- a/resources/views/components/bulk-edit.blade.php+++ b/resources/views/components/bulk-edit.blade.php@@ -12,11 +12,11 @@<x-form :route="route('components.bulkedit.store')"><x-box><x-slot:header>- {{ trans_choice('admin/components/general.bulk_edit_warn', count($components), ['component_count' => count($components)]) }}+ {{ trans_choice('general.bulk_edit_warn', count($components), ['count' => count($components), 'item' => trans('general.component'), 'items' => trans('general.components')]) }}</x-slot:header><x-callout type="info" icon="tip" live="polite">- {{ trans('admin/components/general.bulk_edit_help') }}+ {{ trans('general.bulk_edit_help', ['items' => trans('general.components')]) }}</x-callout><table class="table table-striped" style="margin-bottom: 25px; border-bottom: 1px solid light-dark(#eeeeee, #656464);">diff --git a/resources/views/consumables/bulk-consume.blade.php b/resources/views/consumables/bulk-consume.blade.phpnew file mode 100644index 0000000000..059af0e613--- /dev/null+++ b/resources/views/consumables/bulk-consume.blade.php@@ -0,0 +1,56 @@+@extends('layouts/default')++{{-- Page title --}}+@section('title')+ {{ trans('admin/consumables/general.bulk_consume') }}+ @parent+@stop++{{-- Page content --}}+@section('content')+ <x-container class="col-md-8 col-md-offset-2">+ <x-form route="{{ route('consumables.bulkconsume.store') }}">+ <x-box>+ <x-callout type="warning" icon="warning" live="assertive">+ {{ trans_choice('admin/consumables/general.bulk_consume_warn', $assignments->count(), ['count' => $assignments->count()]) }}+ </x-callout>++ <x-callout type="info" icon="tip" live="polite">+ {{ trans('admin/consumables/general.bulk_consume_help') }}+ </x-callout>++ <table class="table table-striped" style="margin-bottom: 25px; border-bottom: 1px solid light-dark(#eeeeee, #656464);">+ <thead>+ <tr>+ <th>{{ trans('general.name') }}</th>+ <th>{{ trans('general.date') }}</th>+ <th>{{ trans('general.notes') }}</th>+ </tr>+ </thead>+ <tbody>+ @foreach ($assignments as $assignment)+ <tr>+ <td>{{ $assignment->user?->present()?->fullName ?? $assignment->user?->display_name ?? trans('general.deleted') }}</td>+ <td>{{ \App\Helpers\Helper::getFormattedDateObject($assignment->created_at, 'datetime', false) }}</td>+ <td>{{ $assignment->note }}</td>+ </tr>+ @endforeach+ </tbody>+ </table>++ @foreach ($ids as $id)+ <input type="hidden" name="ids[]" value="{{ $id }}">+ @endforeach++ <x-slot:customfooter>+ <div class="box-footer text-right">+ <a class="btn btn-link pull-left" href="{{ route('consumables.show', $consumable) }}">{{ trans('button.cancel') }}</a>+ <button type="submit" class="btn btn-success" id="submit-button">+ <x-icon type="checkmark" /> {{ trans('admin/consumables/general.bulk_consume') }}+ </button>+ </div>+ </x-slot:customfooter>+ </x-box>+ </x-form>+ </x-container>+@stopdiff --git a/resources/views/consumables/bulk-delete.blade.php b/resources/views/consumables/bulk-delete.blade.phpnew file mode 100644index 0000000000..968f1cf2d4--- /dev/null+++ b/resources/views/consumables/bulk-delete.blade.php@@ -0,0 +1,63 @@+@extends('layouts/default')++{{-- Page title --}}+@section('title')+ {{ trans('general.bulk_delete') }}+ @parent+@stop++{{-- Page content --}}+@section('content')+ <x-container class="col-md-8 col-md-offset-2">+ <p>{{ trans('general.bulk_delete_help', ['items' => trans('general.consumables')]) }}</p>++ <x-form route="{{ route('consumables.bulkdelete.store') }}">+ <x-box>+ <x-callout type="warning" icon="warning" live="assertive">+ {{ trans_choice('general.bulk_delete_warn', count($consumables), ['count' => count($consumables), 'item' => trans('general.consumable'), 'items' => trans('general.consumables')]) }}+ </x-callout>++ <table class="table table-striped">+ <tr>+ <th></th>+ <th>{{ trans('general.id') }}</th>+ <th>{{ trans('general.name') }}</th>+ <th>{{ trans('general.category') }}</th>+ <th>{{ trans('general.location') }}</th>+ <th>{{ trans('general.qty') }}</th>+ <th>{{ trans('general.checked_out') }}</th>+ </tr>++ <tbody>+ @foreach ($consumables as $consumable)+ <tr @class(['bulk-action-incompatible' => ! $consumable->isDeletable()])>+ <td>+ @if ($consumable->isDeletable())+ <input type="checkbox" name="ids[]" value="{{ $consumable->id }}" checked>+ @else+ <x-icon type="x" />+ @endif+ </td>+ <td>{{ $consumable->id }}</td>+ <td>{{ $consumable->name }}</td>+ <td>{{ $consumable->category?->name }}</td>+ <td>{{ $consumable->location?->display_name }}</td>+ <td>{{ $consumable->qty }}</td>+ <td>{{ $consumable->consumables_users_count }}</td>+ </tr>+ @endforeach+ </tbody>+ </table>++ <x-slot:customfooter>+ <div class="box-footer text-right">+ <a class="btn btn-link pull-left" href="{{ URL::previous() }}">{{ trans('button.cancel') }}</a>+ <button type="submit" class="btn btn-success" id="submit-button">+ <x-icon type="checkmark" /> {{ trans('button.delete') }}+ </button>+ </div>+ </x-slot:customfooter>+ </x-box>+ </x-form>+ </x-container>+@stopdiff --git a/resources/views/consumables/bulk-edit.blade.php b/resources/views/consumables/bulk-edit.blade.phpnew file mode 100644index 0000000000..9de10d5ba3--- /dev/null+++ b/resources/views/consumables/bulk-edit.blade.php@@ -0,0 +1,113 @@+@extends('layouts/default')++{{-- Page title --}}+@section('title')+ {{ trans('general.bulk_edit') }}+ @parent+@stop++{{-- Page content --}}+@section('content')+ <x-container class="col-md-8 col-md-offset-2">+ <x-form :route="route('consumables.bulkedit.store')">+ <x-box>+ <x-slot:header>+ {{ trans_choice('general.bulk_edit_warn', count($consumables), ['count' => count($consumables), 'item' => trans('general.consumable'), 'items' => trans('general.consumables')]) }}+ </x-slot:header>++ <x-callout type="info" icon="tip" live="polite">+ {{ trans('general.bulk_edit_help', ['items' => trans('general.consumables')]) }}+ </x-callout>++ <table class="table table-striped" style="margin-bottom: 25px; border-bottom: 1px solid light-dark(#eeeeee, #656464);">+ <thead>+ <tr>+ <th>{{ trans('general.id') }}</th>+ <th>{{ trans('general.name') }}</th>+ <th>{{ trans('general.category') }}</th>+ <th>{{ trans('general.location') }}</th>+ </tr>+ </thead>+ <tbody>+ @foreach ($consumables as $consumable)+ <tr>+ <td>{{ $consumable->id }}</td>+ <td>{{ $consumable->name }}</td>+ <td>{{ $consumable->category?->name }}</td>+ <td>{{ $consumable->location?->display_name }}</td>+ </tr>+ @endforeach+ </tbody>+ </table>++ @foreach ($ids as $id)+ <input type="hidden" name="ids[]" value="{{ $id }}">+ @endforeach++ <x-input.company-select+ :label="trans('general.company')"+ name="company_id"+ :selected="old('company_id', '')"+ />++ <x-input.category-select+ :label="trans('general.category')"+ name="category_id"+ :selected="old('category_id', '')"+ categoryType="consumable"+ />++ <x-input.manufacturer-select+ :label="trans('general.manufacturer')"+ name="manufacturer_id"+ :selected="old('manufacturer_id', '')"+ />++ <x-input.location-select+ :label="trans('general.location')"+ name="location_id"+ :selected="old('location_id', '')"+ />++ <x-input.supplier-select+ :label="trans('general.default_supplier')"+ name="default_supplier_id"+ :selected="old('default_supplier_id', '')"+ />++ <x-input.minimum-quantity />++ <x-form.radio-row+ :label="trans('admin/hardware/general.requestable')"+ name="requestable"+ :selected="old('requestable', '')"+ :options="[+ '' => trans('general.do_not_change'),+ '1' => trans('general.yes'),+ '0' => trans('general.no'),+ ]"+ />++ <x-form.radio-row+ :label="trans('general.archived')"+ name="archived"+ :selected="old('archived', '')"+ :options="[+ '' => trans('general.do_not_change'),+ '1' => trans('general.yes'),+ '0' => trans('general.no'),+ ]"+ />++ <x-slot:customfooter>+ <div class="box-footer text-right">+ <a class="btn btn-link pull-left" href="{{ URL::previous() }}">{{ trans('button.cancel') }}</a>+ <button type="submit" class="btn btn-success" id="submit-button">+ <x-icon type="checkmark" /> {{ trans('general.save') }}+ </button>+ </div>+ </x-slot:customfooter>+ </x-box>+ </x-form>+ </x-container>+@stopdiff --git a/resources/views/consumables/edit.blade.php b/resources/views/consumables/edit.blade.phpindex 9416724c9a..51fed36819 100644--- a/resources/views/consumables/edit.blade.php+++ b/resources/views/consumables/edit.blade.php@@ -136,6 +136,24 @@name="requestable":label="trans('admin/hardware/general.requestable')":item="$item"+ data-mutex-with="archived"+ />++ {{-- Suppress help_text when an archived validation error is+ already surfacing. --}}+ <x-form.checkbox-row+ name="archived"+ :label="trans('general.archived')"+ :help_text="$errors->has('archived') ? null : (($item->exists && $item->numOutstanding() > 0)+ ? trans('general.archived_blocked_by_outstanding', ['item_type' => trans('general.consumable')])+ : (($pendingRequestCount > 0)+ ? trans_choice('general.archived_cancels_pending_requests', $pendingRequestCount, ['count' => $pendingRequestCount, 'item_type' => trans('general.consumable')])+ : trans('general.archived_help', ['item_type_plural' => trans('general.consumables')])))"+ :help_icon="$pendingRequestCount > 0 ? 'warning' : null"+ :help_class="$pendingRequestCount > 0 ? 'text-warning' : null"+ :item="$item"+ :disabled="$item->exists && $item->numOutstanding() > 0"+ data-mutex-with="requestable"/><x-slot:customfooter>diff --git a/resources/views/consumables/index.blade.php b/resources/views/consumables/index.blade.phpindex c9bf6f0ad0..ccd4ff9ec9 100644--- a/resources/views/consumables/index.blade.php+++ b/resources/views/consumables/index.blade.php@@ -1,17 +1,36 @@@extends('layouts/default')+@section('title0')+ @if (request('status') === 'Archived')+ {{ trans('general.archived') }}+ @elseif (request('status') === 'Deleted')+ {{ ucfirst(trans('general.deleted')) }}+ @endif+ {{ trans('general.consumables') }}+@stop+{{-- Page title --}}@section('title')-{{ trans('general.consumables') }}-@parent+ @yield('title0') @parent@stop{{-- Page content --}}@section('content')<x-container><x-box name="consumables" sr_only_title>- <x-table.consumables :route="route('api.consumables.index')" />+ {{-- Remaining and % Remaining measure "available to give out,"+ which has no meaning for archived (retired) or deleted+ rows. Drop both columns on those two filter views. --}}+ <x-table.consumables+ name="consumables"+ :route="route('api.consumables.index', ['status' => e(request('status'))])"+ :presenter="\App\Presenters\ConsumablePresenter::dataTableLayout(+ request('status') === 'Deleted',+ in_array(request('status'), ['Archived', 'Deleted'], true) ? ['remaining', 'percent_remaining'] : [],+ )"+ /></x-box>+ <x-shiftclick/></x-container>@can('update', \App\Models\Consumable::class)<x-modals.adjust-quantity />diff --git a/resources/views/consumables/view.blade.php b/resources/views/consumables/view.blade.phpindex bd5f7fb969..803ce48362 100644--- a/resources/views/consumables/view.blade.php+++ b/resources/views/consumables/view.blade.php@@ -16,6 +16,20 @@@section('content')<x-container columns="2">+ @if ($consumable->deleted_at)+ <x-page-column>+ <x-callout type="warning" icon="warning" live="assertive">+ {{ trans('general.item_deleted_warning', ['item_type' => trans('general.consumable')]) }}+ </x-callout>+ </x-page-column>+ @elseif ($consumable->archived)+ <x-page-column>+ <x-callout type="warning" icon="warning" live="assertive">+ {{ trans('general.item_archived_warning', ['item_type' => trans('general.consumable')]) }}+ </x-callout>+ </x-page-column>+ @endif+<x-page-column class="col-md-9 main-panel"><x-tabs><x-slot:tabnav>@@ -25,7 +39,7 @@class="active"icon_type="checkedout"label="{{ trans('general.assigned') }}"- count="{{ $consumable->numCheckedOut() }}"+ count="{{ $consumable->numOutstanding() }}"/><x-tabs.files-tab :item="$consumable" count="{{ $consumable->uploads()->count() }}"/>@@ -39,6 +53,19 @@<x-tabs.pane name="assigned">+ @can('checkout', $consumable)+ <x-slot:bulkactions>+ <x-table.bulk-actions+ name="consumableCheckedOut"+ :action_route="route('consumables.bulkconsume.show')"+ model_name="consumables_user"+ :actions="[+ 'consume' => ['label' => trans('admin/consumables/general.bulk_consume')],+ ]"+ />+ </x-slot:bulkactions>+ @endcan+<x-tablename="consumableCheckedOut" :presenter="\App\Presenters\ConsumablePresenter::checkedOut()":api_url="route('api.consumables.show.users', $consumable->id)"@@ -72,26 +99,92 @@<x-info-panel :infoPanelObj="$consumable" img_path="{{ app('consumables_upload_url') }}" :qr_code_url="route('qr_code/common', ['object_type' => 'consumables', 'id' => $consumable->id])"><x-slot:buttons>- <x-button.edit :item="$consumable" :route="route('consumables.edit', $consumable->id)"/>- <x-button.clone :item="$consumable" :route="route('consumables.clone.create', $consumable->id)"/>- @can('update', $consumable)- @php $lastOrder = $consumable->lastOrderDefaults(); @endphp- <button type="button"- class="btn btn-sm btn-primary adjust-quantity"- data-tooltip="true"- title="{{ trans('general.adjust_quantity') }}"- data-adjust-url="{{ route('consumables.adjust-quantity', $consumable) }}"- data-item-name="{{ e($consumable->name) }}"- data-available="{{ (int) $consumable->numRemaining() }}"- @if ($lastOrder && $lastOrder['unit_cost'] !== null) data-last-unit-cost="{{ $lastOrder['unit_cost'] }}" @endif- @if ($lastOrder && $lastOrder['currency'] !== null) data-last-currency="{{ e($lastOrder['currency']) }}" @endif- >- <x-icon type="plus-minus" class="fa-fw" />- <span class="sr-only">{{ trans('general.adjust_quantity') }}</span>- </button>- @endcan- <x-button.delete :item="$consumable"/>- <x-button.checkout :item="$consumable" :route="route('consumables.checkout.show', $consumable->id)" />+ @if ($consumable->deleted_at)+ {{-- Soft-deleted: every write action stays+ visually present but non-interactive.+ Clone remains active because it produces a+ fresh row and leaves the deleted parent+ untouched. Restore takes the delete+ button's slot in the info panel. --}}+ @can('update', $consumable)+ <a href="#" class="btn btn-sm btn-warning hidden-print disabled" data-tooltip="true" data-placement="top" data-title="{{ trans('general.item_deleted_warning', ['item_type' => trans('general.consumable')]) }}">+ <x-icon type="edit" class="fa-fw" />+ </a>+ @endcan+ <x-button.clone :item="$consumable" :route="route('consumables.clone.create', $consumable->id)"/>+ @can('checkout', $consumable)+ <button type="button" class="btn btn-sm bg-maroon hidden-print disabled" data-tooltip="true" data-placement="top" data-title="{{ trans('general.item_deleted_warning', ['item_type' => trans('general.consumable')]) }}" disabled>+ <x-icon type="checkout" class="fa-fw" />+ </button>+ @endcan+ @can('update', $consumable)+ <button type="button" class="btn btn-sm btn-primary adjust-quantity disabled" data-tooltip="true" data-placement="top" data-title="{{ trans('general.item_deleted_warning', ['item_type' => trans('general.consumable')]) }}" disabled>+ <x-icon type="plus-minus" class="fa-fw" />+ <span class="sr-only">{{ trans('general.adjust_quantity') }}</span>+ </button>+ @endcan+ <x-button.restore :item="$consumable" :route="route('consumables.restore', ['consumableId' => $consumable->id])" />+ @elseif ($consumable->archived)+ {{-- Archived (but live): mirror the deleted-row+ treatment on edit, checkout, and delete.+ Archived rows are retired from active+ inventory, so interactive paths that would+ extend their footprint stay visually+ present but non-interactive. Clone and+ adjust-quantity keep their existing+ archived-aware behavior. --}}+ @can('update', $consumable)+ <a href="#" class="btn btn-sm btn-warning hidden-print disabled" data-tooltip="true" data-placement="top" data-title="{{ trans('general.archived_item_label', ['item_type' => trans('general.consumable')]) }}">+ <x-icon type="edit" class="fa-fw" />+ </a>+ @endcan+ <x-button.clone :item="$consumable" :route="route('consumables.clone.create', $consumable->id)"/>+ @can('checkout', $consumable)+ <button type="button" class="btn btn-sm bg-maroon hidden-print disabled" data-tooltip="true" data-placement="top" data-title="{{ trans('general.archived_item_label', ['item_type' => trans('general.consumable')]) }}" disabled>+ <x-icon type="checkout" class="fa-fw" />+ </button>+ @endcan+ @can('update', $consumable)+ <button type="button" class="btn btn-sm btn-primary adjust-quantity disabled" data-tooltip="true" data-placement="top" data-title="{{ trans('general.archived_item_label', ['item_type' => trans('general.consumable')]) }}" disabled>+ <x-icon type="plus-minus" class="fa-fw" />+ <span class="sr-only">{{ trans('general.adjust_quantity') }}</span>+ </button>+ @endcan+ @can('update', $consumable)+ {{-- Pull-right matches the delete button's+ alignment on live rows, so unarchive+ sits in the same slot in the info+ panel without the destructive action+ migrating around. --}}+ <form method="POST" action="{{ route('consumables.unarchive', $consumable) }}" class="inline pull-right">+ @csrf+ <button class="btn btn-sm btn-warning hidden-print" data-tooltip="true" data-placement="top" data-title="{{ trans('general.unarchive') }}">+ <x-icon type="unarchive" class="fa-fw" />+ </button>+ </form>+ @endcan+ @else+ <x-button.edit :item="$consumable" :route="route('consumables.edit', $consumable->id)"/>+ <x-button.clone :item="$consumable" :route="route('consumables.clone.create', $consumable->id)"/>+ @can('update', $consumable)+ @php $lastOrder = $consumable->lastOrderDefaults(); @endphp+ <button type="button"+ class="btn btn-sm btn-primary adjust-quantity"+ data-tooltip="true"+ title="{{ trans('general.adjust_quantity') }}"+ data-adjust-url="{{ route('consumables.adjust-quantity', $consumable) }}"+ data-item-name="{{ e($consumable->name) }}"+ data-available="{{ (int) $consumable->numRemaining() }}"+ @if ($lastOrder && $lastOrder['unit_cost'] !== null) data-last-unit-cost="{{ $lastOrder['unit_cost'] }}" @endif+ @if ($lastOrder && $lastOrder['currency'] !== null) data-last-currency="{{ e($lastOrder['currency']) }}" @endif+ >+ <x-icon type="plus-minus" class="fa-fw" />+ <span class="sr-only">{{ trans('general.adjust_quantity') }}</span>+ </button>+ @endcan+ <x-button.delete :item="$consumable"/>+ <x-button.checkout :item="$consumable" :route="route('consumables.checkout.show', $consumable->id)" />+ @endif</x-slot:buttons></x-info-panel>