A free open source IT asset/license management system
Added edit buttons to supplier view
snipec2ca51e8ef22
diff --git a/app/Models/Supplier.php b/app/Models/Supplier.phpindex 7880c571d2..591d7e1787 100755--- a/app/Models/Supplier.php+++ b/app/Models/Supplier.php@@ -9,6 +9,7 @@ use App\Models\Traits\Searchable;use App\Presenters\Presentable;use Illuminate\Database\Eloquent\Factories\HasFactory;use Illuminate\Database\Eloquent\SoftDeletes;+use Illuminate\Support\Facades\Gate;use Watson\Validating\ValidatingTrait;use \Illuminate\Database\Eloquent\Relations\Relation;class Supplier extends SnipeModel@@ -72,6 +73,18 @@ class Supplier extends SnipeModel*/protected $fillable = ['name', 'address', 'address2', 'city', 'state', 'country', 'zip', 'phone', 'fax', 'email', 'contact', 'url', 'tag_color', 'notes'];++ public function isDeletable()+ {+ return Gate::allows('delete', $this)+ && (($this->assets_count ?? $this->assets()->count()) === 0)+ && (($this->licenses_count ?? $this->licenses()->count()) === 0)+ && (($this->consumables_count ?? $this->consumables()->count()) === 0)+ && (($this->accessories_count ?? $this->accessories()->count()) === 0)+ && (($this->components_count ?? $this->components()->count()) === 0)+ && (($this->maintenances_count ?? $this->maintenances()->count()) === 0)+ && ($this->deleted_at == '');+ }/*** Eager load counts*diff --git a/resources/views/blade/box/info-panel.blade.php b/resources/views/blade/box/info-panel.blade.phpindex 51c4374095..6cbf4bf5a3 100644--- a/resources/views/blade/box/info-panel.blade.php+++ b/resources/views/blade/box/info-panel.blade.php@@ -22,7 +22,7 @@@if (($contact->image) && ($img_path))<a href="{{ Storage::disk('public')->url($img_path.e($contact->image)) }}" data-toggle="lightbox" data-type="image">- <img src="{{ Storage::disk('public')->url($img_path.e($contact->image)) }}" class="profile-user-img img-responsive img-thumbnail" alt="{{ $contact->name }}">+ <img src="{{ Storage::disk('public')->url($img_path.e($contact->image)) }}" class="profile-user-img img-responsive img-thumbnail" alt="{{ $contact->name }}" style="margin-bottom: 10px;"></a><br>@endif@@ -272,14 +272,14 @@</x-info-element>@endif- <x-info-element icon_type="external-link">- <x-info-element.url title="{{ trans('general.url') }}">+ <x-info-element icon_type="external-link" title="{{ trans('general.url') }}">+ <x-info-element.url>{{ $contact->url }}</x-info-element.url></x-info-element>- <x-info-element icon_type="external-link">- <x-info-element.url title="{{ trans('general.url') }}">+ <x-info-element icon_type="external-link" title="{{ trans('admin/manufacturers/table.support_url') }}">+ <x-info-element.url>{{ $contact->support_url }}</x-info-element.url></x-info-element>diff --git a/resources/views/suppliers/view.blade.php b/resources/views/suppliers/view.blade.phpindex 2be8af68d5..6aed2359c6 100755--- a/resources/views/suppliers/view.blade.php+++ b/resources/views/suppliers/view.blade.php@@ -29,6 +29,17 @@/>@endcan+ @can('view', \App\Models\License::class)+ <x-tabs.nav-item+ name="licenses"+ icon="far fa-save"+ label="{{ trans('general.licenses') }}"+ count="{{ $supplier->licenses->count() }}"+ tooltip="{{ trans('general.licenses') }}"+ />+ @endcan++@can('view', \App\Models\Accessory::class)<x-tabs.nav-itemname="accessories"@@ -109,6 +120,26 @@@endcan<!-- end assets tab pane -->+ <!-- start licenses tab pane -->+ @can('view', \App\Models\License::class)+ <x-tabs.pane name="licenses">+ <x-slot:header>+ {{ trans('general.licenses') }}+ </x-slot:header>++ <x-slot:content>+ <x-table+ show_advanced_search="true"+ buttons="licenseButtons"+ api_url="{{ route('api.licenses.index', ['supplier_id' => $supplier->id]) }}"+ :presenter="\App\Presenters\LicensePresenter::dataTableLayout()"+ export_filename="export-{{ str_slug($supplier->name) }}-licenses-{{ date('Y-m-d') }}"+ />+ </x-slot:content>++ </x-tabs.pane>+ @endcan+ <!-- end licenses tab pane --><!-- start accessories tab pane -->@can('view', \App\Models\Accessory::class)@@ -131,26 +162,6 @@@endcan<!-- end accessories tab pane -->- <!-- start licenses tab pane -->- @can('view', \App\Models\License::class)- <x-tabs.pane name="licenses">- <x-slot:header>- {{ trans('general.licenses') }}- </x-slot:header>-- <x-slot:content>- <x-table- show_advanced_search="true"- buttons="licenseButtons"- api_url="{{ route('api.licenses.index', ['supplier_id' => $supplier->id]) }}"- :presenter="\App\Presenters\LicensePresenter::dataTableLayout()"- export_filename="export-{{ str_slug($supplier->name) }}-licenses-{{ date('Y-m-d') }}"- />- </x-slot:content>-- </x-tabs.pane>- @endcan- <!-- end licenses tab pane --><!-- start components tab pane -->@can('view', \App\Models\Component::class)@@ -231,6 +242,33 @@<x-box><x-box.info-panel :contact="$supplier" img_path="{{ app('suppliers_upload_url') }}">++ <x-slot:before_list>++ @can('update', \App\Models\Supplier::class)+ <a href="{{ ($supplier->deleted_at=='') ? route('suppliers.edit', $supplier->id) : '#' }}" class="btn btn-block btn-sm btn-warning btn-social hidden-print{{ ($supplier->deleted_at!='') ? ' disabled' : '' }}">+ <x-icon type="edit" />+ {{ trans('general.update') }}+ </a>+ @endcan++ @can('delete', \App\Models\Supplier::class)++ @if ($supplier->assets()->count() > 0)+ <button class="btn btn-block btn-sm btn-danger btn-social hidden-print disabled" data-tooltip="true" data-placement="top" data-title="{{ trans('general.cannot_be_deleted') }}">+ <x-icon type="delete" />+ {{ trans('general.delete') }}+ </button>+ @else+ <button class="btn btn-block btn-sm btn-danger btn-social delete-asset" data-toggle="modal" title="{{ trans('general.delete_what', ['item'=> trans('general.supplier')]) }}" data-content="{{ trans('general.sure_to_delete_var', ['item' => $manufacturer->name]) }}" data-target="#dataConfirmModal" data-tooltip="true" data-icon="fa fa-trash" data-placement="top" data-title="{{ trans('general.delete_what', ['item'=> trans('general.supplier')]) }}" onClick="return false;">+ <x-icon type="delete" />+ {{ trans('general.delete') }}+ </button>+ @endif+ @endcan++ </x-slot:before_list>+</x-box.info-panel></x-box></x-page-column>