Skip to content

A free open source IT asset/license management system

Updated routes for interstitial

snipe63efc6818d37
diff --git a/app/Presenters/AccessoryPresenter.php b/app/Presenters/AccessoryPresenter.php
index 0509525608..2fdad14f03 100644
--- a/app/Presenters/AccessoryPresenter.php
+++ b/app/Presenters/AccessoryPresenter.php
@@ -12,7 +12,15 @@ class AccessoryPresenter extends Presenter
*
* @return string
*/
- public static function dataTableLayout()
+ /**
+ * JSON column layout for bootstrap-table.
+ *
+ * @param bool $showDeletedAt Make the deleted_at column visible
+ * by default. Passed from the Deleted-index view so admins
+ * see when each row was deleted. Still switchable elsewhere.
+ * @return string
+ */
+ public static function dataTableLayout(bool $showDeletedAt = false)
{
$layout = [
[
@@ -202,6 +210,15 @@ class AccessoryPresenter extends Presenter
'visible' => false,
'title' => trans('admin/hardware/general.requestable'),
'formatter' => 'trueFalseFormatter',
+ ], [
+ 'field' => 'archived',
+ 'scope' => 'col',
+ 'searchable' => false,
+ 'sortable' => true,
+ 'switchable' => true,
+ 'visible' => false,
+ 'title' => trans('general.archived'),
+ 'formatter' => 'trueFalseFormatter',
], [
'field' => 'created_by',
'scope' => 'col',
@@ -228,6 +245,15 @@ class AccessoryPresenter extends Presenter
'title' => trans('general.updated_at'),
'visible' => false,
'formatter' => 'dateDisplayFormatter',
+ ], [
+ 'field' => 'deleted_at',
+ 'scope' => 'col',
+ 'searchable' => false,
+ 'sortable' => true,
+ 'switchable' => true,
+ 'visible' => $showDeletedAt,
+ 'title' => trans('general.deleted_at'),
+ 'formatter' => 'dateDisplayFormatter',
], [
'field' => 'change',
'scope' => 'col',
@@ -256,6 +282,15 @@ class AccessoryPresenter extends Presenter
public static function assignedDataTableLayout()
{
$layout = [
+ [
+ 'field' => 'checkbox',
+ 'scope' => 'col',
+ 'checkbox' => true,
+ 'formatter' => 'checkboxEnabledFormatter',
+ 'titleTooltip' => trans('general.select_all_none'),
+ 'printIgnore' => true,
+ 'class' => 'hidden-print',
+ ],
[
'field' => 'id',
'scope' => 'col',
diff --git a/resources/views/accessories/bulk-checkin.blade.php b/resources/views/accessories/bulk-checkin.blade.php
new file mode 100644
index 0000000000..723a01f192
--- /dev/null
+++ b/resources/views/accessories/bulk-checkin.blade.php
@@ -0,0 +1,36 @@
+@extends('layouts/default')
+
+@section('title')
+ {{ trans('general.checkin') }}
+ @parent
+@stop
+
+@section('content')
+ <x-bulk-checkin-form
+ :action_route="route('accessories.bulkcheckin.store')"
+ :ids="$ids"
+ :count="count($checkouts)"
+ :return_url="$return_url"
+ >
+ <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.accessory') }}</th>
+ <th>{{ trans('general.checked_out_to') }}</th>
+ <th>{{ trans('admin/hardware/table.checkout_date') }}</th>
+ </tr>
+ </thead>
+ <tbody>
+ @foreach ($checkouts as $checkout)
+ <tr>
+ <td>{{ $checkout->id }}</td>
+ <td>{{ $checkout->accessory?->name }}</td>
+ <td>{{ $checkout->assignedTo?->present()?->fullName ?? $checkout->assignedTo?->display_name ?? trans('general.deleted') }}</td>
+ <td>{{ \App\Helpers\Helper::getFormattedDateObject($checkout->created_at, 'datetime', false) }}</td>
+ </tr>
+ @endforeach
+ </tbody>
+ </table>
+ </x-bulk-checkin-form>
+@stop
diff --git a/resources/views/accessories/edit.blade.php b/resources/views/accessories/edit.blade.php
index 2892076697..9ecb7fc1c2 100644
--- a/resources/views/accessories/edit.blade.php
+++ b/resources/views/accessories/edit.blade.php
@@ -132,6 +132,24 @@
name="requestable"
:label="trans('admin/accessories/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->checkouts()->count() > 0)
+ ? trans('general.archived_blocked_by_checkouts', ['item_type' => trans('general.accessory')])
+ : (($pendingRequestCount > 0)
+ ? trans_choice('general.archived_cancels_pending_requests', $pendingRequestCount, ['count' => $pendingRequestCount, 'item_type' => trans('general.accessory')])
+ : trans('general.archived_help', ['item_type_plural' => trans('general.accessories')])))"
+ :help_icon="$pendingRequestCount > 0 ? 'warning' : null"
+ :help_class="$pendingRequestCount > 0 ? 'text-warning' : null"
+ :item="$item"
+ :disabled="$item->exists && $item->checkouts()->count() > 0"
+ data-mutex-with="requestable"
/>
<x-slot:customfooter>
diff --git a/resources/views/accessories/view.blade.php b/resources/views/accessories/view.blade.php
index 3a63ea29be..4030197e48 100644
--- a/resources/views/accessories/view.blade.php
+++ b/resources/views/accessories/view.blade.php
@@ -19,6 +19,20 @@
{{-- Page content --}}
@section('content')
<x-container columns="2">
+ @if ($accessory->deleted_at != '')
+ <x-page-column>
+ <x-callout type="warning" icon="warning" live="assertive">
+ {{ trans('admin/accessories/general.accessory_deleted_warning') }}
+ </x-callout>
+ </x-page-column>
+ @elseif ($accessory->archived)
+ <x-page-column>
+ <x-callout type="warning" icon="warning" live="assertive">
+ {{ trans('general.item_archived_warning', ['item_type' => trans('general.accessory')]) }}
+ </x-callout>
+ </x-page-column>
+ @endif
+
<x-page-column class="col-md-9 main-panel">
@@ -28,7 +42,9 @@
<x-tabs.files-tab :item="$accessory" count="{{ $accessory->uploads()->count() }}"/>
<x-tabs.orders-tab count="{{ $accessory->orderItemsCount() }}"/>
<x-tabs.history-tab count="{{ $accessory->history()->count() }}" :model="$accessory"/>
- <x-tabs.upload-tab :item="$accessory"/>
+ @if ($accessory->deleted_at == '')
+ <x-tabs.upload-tab :item="$accessory"/>
+ @endif
</x-slot:tabnav>
<x-slot:tabpanes>
@@ -39,6 +55,19 @@
{{ trans('general.checked_out') }}
</x-slot:table_header>
+ @can('checkin', $accessory)
+ <x-slot:bulkactions>
+ <x-table.bulk-actions
+ name="accessoryCheckedOut"
+ :action_route="route('accessories.bulkcheckin.show')"
+ model_name="accessory_checkout"
+ :actions="[
+ 'checkin' => ['label' => trans('general.checkin')],
+ ]"
+ />
+ </x-slot:bulkactions>
+ @endcan
+
<x-table
name="accessoryCheckedOut" api_url="{{ route('api.accessories.checkedout', $accessory->id) }}"
:presenter="\App\Presenters\AccessoryPresenter::assignedDataTableLayout()"
@@ -75,26 +104,95 @@
<x-box class="side-box expanded">
<x-info-panel :infoPanelObj="$accessory" img_path="{{ app('accessories_upload_url') }}" :qr_code_url="route('qr_code/common', ['object_type' => 'accessories', 'id' => $accessory->id])">
<x-slot:buttons>
- <x-button.edit :item="$accessory" :route="route('accessories.edit', $accessory->id)"/>
- <x-button.clone :item="$accessory" :route="route('clone/accessories', $accessory->id)"/>
- <x-button.checkout permission="checkout" :item="$accessory" :route="route('accessories.checkout.show', $accessory->id)" />
- @can('update', $accessory)
- @php $lastOrder = $accessory->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('accessories.adjust-quantity', $accessory) }}"
- data-item-name="{{ e($accessory->name) }}"
- data-available="{{ (int) $accessory->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="$accessory" />
+ @if ($accessory->deleted_at != '')
+ {{-- Soft-deleted: keep every action visually
+ present but non-interactive. x-button.edit
+ hides itself on deleted rows, so render
+ disabled stand-ins inline. Clone stays
+ active since cloning a deleted accessory
+ produces a new row without touching the
+ deleted parent. --}}
+ @can('update', $accessory)
+ <a href="#" class="btn btn-sm btn-warning hidden-print disabled" data-tooltip="true" data-placement="top" data-title="{{ trans('admin/accessories/general.accessory_deleted_warning') }}">
+ <x-icon type="edit" class="fa-fw" />
+ </a>
+ @endcan
+ <x-button.clone :item="$accessory" :route="route('clone/accessories', $accessory->id)"/>
+ @can('checkout', $accessory)
+ <button type="button" class="btn btn-sm bg-maroon hidden-print disabled" data-tooltip="true" data-placement="top" data-title="{{ trans('admin/accessories/general.accessory_deleted_warning') }}" disabled>
+ <x-icon type="checkout" class="fa-fw" />
+ </button>
+ @endcan
+ @can('update', $accessory)
+ <button type="button" class="btn btn-sm btn-primary adjust-quantity disabled" data-tooltip="true" data-placement="top" data-title="{{ trans('admin/accessories/general.accessory_deleted_warning') }}" disabled>
+ <x-icon type="plus-minus" class="fa-fw" />
+ <span class="sr-only">{{ trans('general.adjust_quantity') }}</span>
+ </button>
+ @endcan
+ <x-button.restore :item="$accessory" :route="route('accessories.restore', ['accessoryId' => $accessory->id])" />
+ @elseif ($accessory->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', $accessory)
+ <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.accessory')]) }}">
+ <x-icon type="edit" class="fa-fw" />
+ </a>
+ @endcan
+ <x-button.clone :item="$accessory" :route="route('clone/accessories', $accessory->id)"/>
+ @can('checkout', $accessory)
+ <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.accessory')]) }}" disabled>
+ <x-icon type="checkout" class="fa-fw" />
+ </button>
+ @endcan
+ @can('update', $accessory)
+ <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.accessory')]) }}" disabled>
+ <x-icon type="plus-minus" class="fa-fw" />
+ <span class="sr-only">{{ trans('general.adjust_quantity') }}</span>
+ </button>
+ @endcan
+ @can('update', $accessory)
+ {{-- 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('accessories.unarchive', $accessory) }}" 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="restore" class="fa-fw" />
+ </button>
+ </form>
+ @endcan
+ @else
+ <x-button.edit :item="$accessory" :route="route('accessories.edit', $accessory->id)"/>
+ <x-button.clone :item="$accessory" :route="route('clone/accessories', $accessory->id)"/>
+ <x-button.checkout permission="checkout" :item="$accessory" :route="route('accessories.checkout.show', $accessory->id)" />
+ @can('update', $accessory)
+ @php
+ $lastOrder = $accessory->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('accessories.adjust-quantity', $accessory) }}"
+ data-item-name="{{ e($accessory->name) }}"
+ data-available="{{ (int) $accessory->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="$accessory" />
+ @endif
</x-slot:buttons>
</x-info-panel>
</x-box>
@@ -107,13 +205,15 @@
@section('moar_scripts')
- @can('files', $accessory)
- <x-modals.upload-file item-type="accessories" :item-id="$accessory->id" />
- @endcan
-
- @can('update', $accessory)
- <x-modals.adjust-quantity />
- @endcan
+ @if ($accessory->deleted_at == '')
+ @can('files', $accessory)
+ <x-modals.upload-file item-type="accessories" :item-id="$accessory->id" />
+ @endcan
+
+ @can('update', $accessory)
+ <x-modals.adjust-quantity />
+ @endcan
+ @endif
@include ('partials.bootstrap-table')
@endsection
diff --git a/resources/views/blade/bulk-checkin-form.blade.php b/resources/views/blade/bulk-checkin-form.blade.php
new file mode 100644
index 0000000000..605cd79d2c
--- /dev/null
+++ b/resources/views/blade/bulk-checkin-form.blade.php
@@ -0,0 +1,45 @@
+@props([
+ 'action_route',
+ 'ids',
+ 'count',
+ 'return_url' => null,
+])
+
+<x-container class="col-md-8 col-md-offset-2">
+ <x-form :route="$action_route">
+ @if ($return_url)
+ <input type="hidden" name="return_url" value="{{ $return_url }}">
+ @endif
+
+ <x-box>
+ <x-slot:header>
+ {{ trans_choice('general.bulk_checkin_warn', $count, ['count' => $count]) }}
+ </x-slot:header>
+
+ <x-callout type="info" icon="tip" live="polite">
+ {{ trans('general.bulk_checkin_note_help') }}
+ </x-callout>
+
+ {{ $slot }}
+
+ @foreach ($ids as $id)
+ <input type="hidden" name="ids[]" value="{{ $id }}">
+ @endforeach
+
+ <x-form.row
+ :label="trans('general.notes')"
+ name="note"
+ type="textarea"
+ />
+
+ <x-slot:customfooter>
+ <div class="box-footer text-right">
+ <a class="btn btn-link pull-left" href="{{ $return_url ?? URL::previous() }}">{{ trans('button.cancel') }}</a>
+ <button type="submit" class="btn btn-success" id="submit-button">
+ <x-icon type="checkin" /> {{ trans('general.checkin') }}
+ </button>
+ </div>
+ </x-slot:customfooter>
+ </x-box>
+ </x-form>
+</x-container>
diff --git a/resources/views/components/bulk-checkin.blade.php b/resources/views/components/bulk-checkin.blade.php
new file mode 100644
index 0000000000..c2f902ad9c
--- /dev/null
+++ b/resources/views/components/bulk-checkin.blade.php
@@ -0,0 +1,38 @@
+@extends('layouts/default')
+
+@section('title')
+ {{ trans('general.checkin') }}
+ @parent
+@stop
+
+@section('content')
+ <x-bulk-checkin-form
+ :action_route="route('components.bulkcheckin.store')"
+ :ids="$ids"
+ :count="count($assignments)"
+ :return_url="$return_url"
+ >
+ <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.component') }}</th>
+ <th>{{ trans('general.asset') }}</th>
+ <th>{{ trans('general.qty') }}</th>
+ <th>{{ trans('admin/hardware/table.checkout_date') }}</th>
+ </tr>
+ </thead>
+ <tbody>
+ @foreach ($assignments as $assignment)
+ <tr>
+ <td>{{ $assignment->id }}</td>
+ <td>{{ $assignment->component?->name }}</td>
+ <td>{{ $assignment->resolvedAsset?->present()?->fullName ?? trans('general.deleted') }}</td>
+ <td>{{ (int) $assignment->assigned_qty }}</td>
+ <td>{{ \App\Helpers\Helper::getFormattedDateObject($assignment->created_at, 'datetime', false) }}</td>
+ </tr>
+ @endforeach
+ </tbody>
+ </table>
+ </x-bulk-checkin-form>
+@stop
diff --git a/resources/views/components/edit.blade.php b/resources/views/components/edit.blade.php
index 833d5f5ea6..fd69f5edb2 100644
--- a/resources/views/components/edit.blade.php
+++ b/resources/views/components/edit.blade.php
@@ -151,10 +151,10 @@
name="archived"
:label="trans('general.archived')"
:help_text="$errors->has('archived') ? null : (($item->exists && $item->numCheckedOut() > 0)
- ? trans('admin/components/message.archived_blocked_by_checkouts')
+ ? trans('general.archived_blocked_by_checkouts', ['item_type' => trans('general.component')])
: (($pendingRequestCount > 0)
- ? trans_choice('admin/components/general.archived_cancels_pending_requests', $pendingRequestCount, ['count' => $pendingRequestCount])
- : trans('admin/components/general.archived_help')))"
+ ? trans_choice('general.archived_cancels_pending_requests', $pendingRequestCount, ['count' => $pendingRequestCount, 'item_type' => trans('general.component')])
+ : trans('general.archived_help', ['item_type_plural' => trans('general.components')])))"
:help_icon="$pendingRequestCount > 0 ? 'warning' : null"
:help_class="$pendingRequestCount > 0 ? 'text-warning' : null"
:item="$item"
diff --git a/resources/views/components/view.blade.php b/resources/views/components/view.blade.php
index 45fb5f13cd..b8ef7634ed 100644
--- a/resources/views/components/view.blade.php
+++ b/resources/views/components/view.blade.php
@@ -53,7 +53,7 @@
<x-slot:bulkactions>
<x-table.bulk-actions
name="componentCheckedOut"
- :action_route="route('components.bulkcheckin.selected')"
+ :action_route="route('components.bulkcheckin.show')"
model_name="components_asset"
:actions="[
'checkin' => ['label' => trans('general.checkin')],
@@ -130,7 +130,7 @@
@php
$lastOrder = $snipe_component->lastOrderDefaults();
$adjustDisabledReason = $snipe_component->archived
- ? trans('admin/components/general.archived_component')
+ ? trans('general.archived_item_label', ['item_type' => trans('general.component')])
: null;
@endphp
<button type="button"
diff --git a/resources/views/hardware/view.blade.php b/resources/views/hardware/view.blade.php
index df7400a42e..62b53ce9e8 100755
--- a/resources/views/hardware/view.blade.php
+++ b/resources/views/hardware/view.blade.php
@@ -375,7 +375,8 @@
@can('checkin', \App\Models\License::class)
<x-slot:bulkactions>
<x-table.bulk-actions
- action_route="{{ route('licenses.bulkcheckin.selected') }}"
+ name="assetLicenses"
+ action_route="{{ route('licenses.bulkcheckin.show') }}"
model_name="seat"
>
<option value="checkin">{{ trans('general.checkin') }}</option>
diff --git a/resources/views/licenses/bulk-checkin.blade.php b/resources/views/licenses/bulk-checkin.blade.php
new file mode 100644
index 0000000000..bb9f99783e
--- /dev/null
+++ b/resources/views/licenses/bulk-checkin.blade.php
@@ -0,0 +1,36 @@
+@extends('layouts/default')
+
+@section('title')
+ {{ trans('general.checkin') }}
+ @parent
+@stop
+
+@section('content')
+ <x-bulk-checkin-form
+ :action_route="route('licenses.bulkcheckin.store')"
+ :ids="$ids"
+ :count="count($seats)"
+ :return_url="$return_url"
+ >
+ <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.license') }}</th>
+ <th>{{ trans('general.checked_out_to') }}</th>
+ <th>{{ trans('admin/hardware/table.checkout_date') }}</th>
+ </tr>
+ </thead>
+ <tbody>
+ @foreach ($seats as $seat)
+ <tr>
+ <td>{{ $seat->id }}</td>
+ <td>{{ $seat->license?->name }}</td>
+ <td>{{ $seat->user?->present()?->fullName ?? $seat->asset?->present()?->fullName ?? trans('general.deleted') }}</td>
+ <td>{{ \App\Helpers\Helper::getFormattedDateObject($seat->created_at, 'datetime', false) }}</td>
+ </tr>
+ @endforeach
+ </tbody>
+ </table>
+ </x-bulk-checkin-form>
+@stop
diff --git a/resources/views/licenses/view.blade.php b/resources/views/licenses/view.blade.php
index b7c16bddb9..c47e38a744 100755
--- a/resources/views/licenses/view.blade.php
+++ b/resources/views/licenses/view.blade.php
@@ -49,7 +49,8 @@
@can('checkin', $license)
<x-slot:bulkactions>
<x-table.bulk-actions
- action_route="{{ route('licenses.bulkcheckin.selected') }}"
+ name="licenseAssignedSeats"
+ action_route="{{ route('licenses.bulkcheckin.show') }}"
model_name="seat"
>
<option value="checkin">{{ trans('general.checkin') }}</option>
diff --git a/resources/views/partials/bootstrap-table.blade.php b/resources/views/partials/bootstrap-table.blade.php
index 59c2fcdd43..b34f5878ab 100644
--- a/resources/views/partials/bootstrap-table.blade.php
+++ b/resources/views/partials/bootstrap-table.blade.php
@@ -2888,7 +2888,7 @@
var adjustDisabled = adjustDeleted || row.archived === true;
var adjustReason = adjustDeleted
? '{{ trans('general.component_deleted_warning') }}'
- : '{{ trans('admin/components/general.archived_component') }}';
+ : '{{ trans('general.archived_item_label', ['item_type' => trans('general.component')]) }}';
actions += window.renderAdjustQuantityButton({
dest: dest,
id: row.id,
diff --git a/resources/views/users/view.blade.php b/resources/views/users/view.blade.php
index 776ea7c846..d4ce80cbe9 100755
--- a/resources/views/users/view.blade.php
+++ b/resources/views/users/view.blade.php
@@ -329,7 +329,7 @@
<x-slot:bulkactions>
<x-table.bulk-actions
name="userLicenseTable"
- :action_route="route('licenses.bulkcheckin.selected')"
+ :action_route="route('licenses.bulkcheckin.show')"
model_name="license_seats"
:actions="[
'checkin' => ['label' => trans('general.checkin')],