Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions app/Models/Consumable.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\Relations\Relation;
use Illuminate\Database\Eloquent\SoftDeletes;
use Illuminate\Support\Facades\Gate;
use Illuminate\Support\Facades\Storage;
use Watson\Validating\ValidatingTrait;

Expand Down Expand Up @@ -131,6 +132,13 @@ public function setRequestableAttribute($value)
$this->attributes['requestable'] = filter_var($value, FILTER_VALIDATE_BOOLEAN);
}

public function isDeletable()
{
return Gate::allows('delete', $this)
&& ($this->numCheckedOut() === 0)
&& ($this->deleted_at == '');
}

/**
* Establishes the consumable -> admin user relationship
*
Expand Down
52 changes: 52 additions & 0 deletions app/Presenters/ConsumablePresenter.php
Original file line number Diff line number Diff line change
Expand Up @@ -187,6 +187,58 @@ public static function dataTableLayout()
return json_encode($layout);
}

public static function checkedOut()
{
$layout = [

[
'field' => 'avatar',
'searchable' => false,
'sortable' => false,
'title' => trans('general.image'),
'visible' => true,
'formatter' => 'imageFormatter',
],
[
'field' => 'user',
'searchable' => false,
'sortable' => false,
'title' => trans('general.name'),
'visible' => true,
'formatter' => 'usersLinkObjFormatter',
],
[
'field' => 'created_at',
'searchable' => false,
'sortable' => false,
'title' => trans('general.date'),
'visible' => true,
'formatter' => 'dateDisplayFormatter',
],

[
'field' => 'note',
'searchable' => false,
'sortable' => false,
'title' => trans('general.notes'),
'visible' => true,
],

[
'field' => 'created_by',
'searchable' => false,
'sortable' => false,
'title' => trans('general.created_by'),
'visible' => true,
'formatter' => 'usersLinkObjFormatter',
],


];

return json_encode($layout);
}

/**
* Url to view this item.
* @return string
Expand Down
91 changes: 67 additions & 24 deletions resources/views/blade/box/info-panel.blade.php
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
@props([
'infoPanelObj' => null,
'img_path' => null,
'snipeSettings' => \App\Models\Setting::getSettings()
])



<!-- start side info-box -->
<div class="box-header with-border" style="padding-top: 0;">
<h3 class="box-title side-box-header" style="line-height: 20px">
{{ $infoPanelObj->display_name }}
Expand Down Expand Up @@ -83,8 +83,20 @@
@endif

@if ($infoPanelObj->model_number)
<x-info-element icon_type="number" title="{{ trans('general.model_number') }}">
<x-info-element icon_type="number" title="{{ trans('general.model_no') }}">
{{ trans('general.model_no') }}
<x-copy-to-clipboard copy_what="model_number" class="pull-right">
{{ $infoPanelObj->model_number }}
</x-copy-to-clipboard>
</x-info-element>
@endif

@if ($infoPanelObj->item_no)
<x-info-element icon_type="number" title="{{ trans('admin/consumables/general.item_no') }}">
{{ trans('admin/consumables/general.item_no') }}
<x-copy-to-clipboard copy_what="item_no" class="pull-right">
{{ $infoPanelObj->item_no }}
</x-copy-to-clipboard>
</x-info-element>
@endif

Expand All @@ -95,27 +107,64 @@
</x-info-element>
@endif

@if ($infoPanelObj->order_number)
<x-info-element icon_type="order" title="{{ trans('general.order_number') }}">
{{ $infoPanelObj->order_number }}
</x-info-element>
@endif

@if ($infoPanelObj->purchase_order)
<x-info-element icon_type="purchase_order" title="{{ trans('admin/licenses/form.purchase_order') }}">
{{ $infoPanelObj->purchase_order }}
@if (method_exists($infoPanelObj, 'numCheckedOut'))
<x-info-element icon_type="checkedout" title="{{ trans('general.checked_out') }}">
{{ (int) $infoPanelObj->numCheckedOut() }}
{{ trans('general.checked_out') }}
</x-info-element>
@endif

@if (function_exists('numRemaining'))
@if (method_exists($infoPanelObj, 'numRemaining'))
<x-info-element icon_type="available" title="{{ trans('general.remaining') }}">
{{ $infoPanelObj->numRemaining() }}
{{ trans('general.remaining') }}
</x-info-element>
@endif

<x-info-element icon_type="checkedout" title="{{ trans('general.available') }}">
{{ $infoPanelObj->checkouts_count }}
{{ trans('general.checked_out') }}
@if ($infoPanelObj->purchase_cost)
<x-info-element>
<x-icon type="cost" class="fa-fw" title="{{ trans('general.unit_cost') }}" />
{{ trans('general.unit_cost') }}

@if ((isset($infoPanelObj->location)) && ($infoPanelObj->location->currency!=''))
{{ $infoPanelObj->location->currency }}
@else
{{ $snipeSettings->default_currency }}
@endif

{{ Helper::formatCurrencyOutput($infoPanelObj->purchase_cost) }}
</x-info-element>

@if (isset($infoPanelObj->qty))
<x-info-element>
<x-icon type="cost" class="fa-fw" title="{{ trans('general.total_cost') }}" />
{{ trans('general.total_cost') }}

@if ((isset($infoPanelObj->location)) && ($infoPanelObj->location->currency!=''))
{{ $infoPanelObj->location->currency }}
@else
{{ $snipeSettings->default_currency }}
@endif

{{ Helper::formatCurrencyOutput($infoPanelObj->totalCostSum()) }}
</x-info-element>
@endif

@endif

@if ($infoPanelObj->order_number)
<x-info-element icon_type="order" title="{{ trans('general.order_number') }}">
<x-copy-to-clipboard copy_what="order_number" class="pull-right">
{{ $infoPanelObj->order_number }}
</x-copy-to-clipboard>
</x-info-element>
@endif

@if ($infoPanelObj->purchase_order)
<x-info-element icon_type="purchase_order" title="{{ trans('admin/licenses/form.purchase_order') }}">
<x-copy-to-clipboard copy_what="purchase_order" class="pull-right">
{{ $infoPanelObj->purchase_order }}
</x-copy-to-clipboard>
</x-info-element>
@endif

Expand Down Expand Up @@ -187,7 +236,7 @@
</x-info-element.url>
</x-info-element>

<x-info-element icon_type="external-link" class="subitem" title="{{ trans('general.url') }}">
<x-info-element icon_type="external-link" class="subitem" title="{{ trans('admin/manufacturers/table.support_url') }}">
<x-info-element.url>
{{ $infoPanelObj->manufacturer->support_url }}
</x-info-element.url>
Expand Down Expand Up @@ -337,12 +386,6 @@
</x-info-element>
@endif

@if ($infoPanelObj->purchase_cost)
<x-info-element>
<x-icon type="cost" class="fa-fw" title="{{ trans('general.purchase_cost') }}" />
{{ Helper::formatCurrencyOutput($infoPanelObj->purchase_cost) }}
</x-info-element>
@endif


@if ($infoPanelObj->purchase_date)
Expand Down Expand Up @@ -489,5 +532,5 @@

</div>


<!-- end side info-box -->

12 changes: 7 additions & 5 deletions resources/views/blade/button/wide-checkout.blade.php
Original file line number Diff line number Diff line change
@@ -1,11 +1,13 @@
@props([
'item' => null,
'route' => null,
'route',
])

@can('checkout', $item)
<a href="{{ $route }}" class="btn btn-sm bg-maroon btn-social btn-block hidden-print">
<x-icon type="checkout" />
{{ trans('general.checkout') }}
</a>
@if ((method_exists($item, 'numRemaining')) && ($item->numRemaining() > 0))
<a href="{{ $route }}" class="btn btn-sm bg-maroon btn-social btn-block hidden-print">
<x-icon type="checkout" />
{{ trans('general.checkout') }}
</a>
@endif
@endcan
2 changes: 1 addition & 1 deletion resources/views/blade/copy-to-clipboard.blade.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
])

<!-- copy to clipboard -->
<i class="fa-regular fa-clipboard js-copy-link hidden-print fa-fw" data-clipboard-target=".js-copy-{{ $copy_what }}" aria-hidden="true" data-tooltip="true" data-placement="top" title="{{ trans('general.copy_to_clipboard') }}">
<i {{ $attributes->merge(['class' => 'fa-regular fa-clipboard js-copy-link hidden-print fa-fw']) }} style="font-size: 16px;" data-clipboard-target=".js-copy-{{ $copy_what }}" aria-hidden="true" data-tooltip="true" data-placement="top" title="{{ trans('general.copy_to_clipboard') }}">
<span class="sr-only">{{ trans('general.copy_to_clipboard') }}</span>
</i>

Expand Down
2 changes: 2 additions & 0 deletions resources/views/blade/tabs/accessory-tab.blade.php
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
@props([
'count' => null,
])
@aware(['class'])

@can('view', \App\Models\Accessory::class)
<x-tabs.nav-item
:$class
name="accessories"
icon_type="accessory"
label="{{ trans('general.accessories') }}"
Expand Down
3 changes: 2 additions & 1 deletion resources/views/blade/tabs/asset-tab.blade.php
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
@props([
'count' => null,
])
@aware(['class'])

@can('view', \App\Models\Asset::class)
<x-tabs.nav-item
:$class
name="assets"
class="active"
icon_type="assets"
label="{{ trans('general.assets') }}"
count="{{ $count }}"
Expand Down
1 change: 1 addition & 0 deletions resources/views/blade/tabs/checkedout-tab.blade.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
'model' => null,
'class' => null,
])
@aware(['class'])

@can('view', $model)
<x-tabs.nav-item
Expand Down
1 change: 1 addition & 0 deletions resources/views/blade/tabs/component-tab.blade.php
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
@props([
'count' => null,
])
@aware(['class'])

@can('view', \App\Models\Component::class)
<x-tabs.nav-item
Expand Down
1 change: 1 addition & 0 deletions resources/views/blade/tabs/consumable-tab.blade.php
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
@props([
'count' => null,
])
@aware(['class'])

@can('view', \App\Models\Consumable::class)
<x-tabs.nav-item
Expand Down
3 changes: 3 additions & 0 deletions resources/views/blade/tabs/files-tab.blade.php
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
@props([
'count' => null,
])

@aware(['class'])

<x-tabs.nav-item
name="files"
icon_type="files"
Expand Down
1 change: 1 addition & 0 deletions resources/views/blade/tabs/history-tab.blade.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
'model' => null,
])

@aware(['class'])

@can('view', $model)
<x-tabs.nav-item
Expand Down
2 changes: 2 additions & 0 deletions resources/views/blade/tabs/license-tab.blade.php
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
@props([
'count' => null,
])
@aware(['class'])

@can('view', \App\Models\License::class)
<x-tabs.nav-item
:$class
name="licenses"
icon_type="licenses"
label="{{ trans('general.licenses') }}"
Expand Down
1 change: 1 addition & 0 deletions resources/views/blade/tabs/nav-item.blade.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
'tooltip' => null,
'icon_type' => null,
])

<!-- start tab nav item -->
<li {{ $attributes->merge(['class' => '']) }}>

Expand Down
2 changes: 2 additions & 0 deletions resources/views/blade/tabs/user-tab.blade.php
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
@props([
'count' => null,
])
@aware(['class'])

@can('view', \App\Models\User::class)
<x-tabs.nav-item
:$class
name="users"
icon_type="user"
label="{{ trans('general.users') }}"
Expand Down
7 changes: 1 addition & 6 deletions resources/views/components/view.blade.php
Original file line number Diff line number Diff line change
Expand Up @@ -81,16 +81,11 @@ class="active"

<x-slot:before_list>

@can('checkout', \App\Models\Component::class)
<x-button.wide-checkout :item="$snipe_component" :route="route('components.checkout.show', $snipe_component->id)" />
@endcan

<x-button.wide-checkout :item="$snipe_component" :route="route('components.checkout.show', $snipe_component->id)" />
<x-button.wide-edit :item="$snipe_component" :route="route('components.edit', $snipe_component->id)" />
<x-button.wide-clone :item="$snipe_component" :route="route('components.clone.create', $snipe_component->id)" />

<x-button.wide-delete :item="$snipe_component" />


</x-slot:before_list>

</x-box.info-panel>
Expand Down
Loading
Loading