|
|
@@ -1,32 +1,43 @@
|
|
|
@extends('layouts.app')
|
|
|
|
|
|
@section('content')
|
|
|
+ @php
|
|
|
+ $catalogReadableFields = $catalogReadableFields ?? [];
|
|
|
+ $catalogWritableFields = $catalogWritableFields ?? [];
|
|
|
+ $canView = static fn (string $field): bool => (bool)($catalogReadableFields[$field] ?? false);
|
|
|
+ $canUpdate = static fn (string $field): bool => (bool)($catalogWritableFields[$field] ?? false);
|
|
|
+ $visibleName = ($product && $canView('article') && $canView('nomenclature_number')) ? $product->common_name : 'МАФ';
|
|
|
+ @endphp
|
|
|
<div class="px-3">
|
|
|
<div class="row mb-2">
|
|
|
<div class="col-md-6 d-flex align-items-center">
|
|
|
- <h3 class="mb-0">МАФ {{ $product->common_name ?? 'Новый МАФ' }} ({{ $product->year ?? year() }})</h3>
|
|
|
+ <h3 class="mb-0">МАФ {{ $product ? $visibleName : 'Новый МАФ' }} ({{ $product->year ?? year() }})</h3>
|
|
|
</div>
|
|
|
<div class="col-md-6 d-flex align-items-center justify-content-end action-toolbar">
|
|
|
- @if(isset($product) && hasRole('admin'))
|
|
|
- @if($product->image)
|
|
|
+ @if(isset($product))
|
|
|
+ @if($canView('image') && $product->image)
|
|
|
<a href="{{ $product->image }}" data-toggle="lightbox" data-gallery="photos" data-size="fullscreen">
|
|
|
<img src="{{ $product->image }}" alt="Миниатюра" class="img-thumbnail img-max-40">
|
|
|
</a>
|
|
|
@endif
|
|
|
- <button class="btn btn-sm text-success" onclick="$('#upl-thumb').trigger('click');" title="Загрузить изображение"><i class="bi bi-image"></i> Изображение</button>
|
|
|
+ @if(hasAccess('catalog.thumbnail.upload', 'admin'))
|
|
|
+ <button class="btn btn-sm text-success" onclick="$('#upl-thumb').trigger('click');" title="Загрузить изображение"><i class="bi bi-image"></i> Изображение</button>
|
|
|
|
|
|
- <form action="{{ route('catalog.upload-thumbnail', ['product' => $product, 'nav' => $nav ?? null]) }}" class="visually-hidden" method="POST" enctype="multipart/form-data">
|
|
|
- @csrf
|
|
|
- <input type="file" name="thumbnail" accept=".jpg,.jpeg" onchange="$(this).parent().submit()" required id="upl-thumb" />
|
|
|
- </form>
|
|
|
+ <form action="{{ route('catalog.upload-thumbnail', ['product' => $product, 'nav' => $nav ?? null]) }}" class="visually-hidden" method="POST" enctype="multipart/form-data">
|
|
|
+ @csrf
|
|
|
+ <input type="file" name="thumbnail" accept=".jpg,.jpeg" onchange="$(this).parent().submit()" required id="upl-thumb" />
|
|
|
+ </form>
|
|
|
+ @endif
|
|
|
|
|
|
- <button class="btn btn-sm text-success" onclick="$('#upl-cert').trigger('click');"><i class="bi bi-plus-circle-fill"></i> Загрузить сертификат</button>
|
|
|
+ @if(hasAccess('catalog.certificates.upload', 'admin'))
|
|
|
+ <button class="btn btn-sm text-success" onclick="$('#upl-cert').trigger('click');"><i class="bi bi-plus-circle-fill"></i> Загрузить сертификат</button>
|
|
|
|
|
|
- <form action="{{ route('catalog.upload-certificate', ['product' => $product, 'nav' => $nav ?? null]) }}" class="visually-hidden" method="POST" enctype="multipart/form-data">
|
|
|
- @csrf
|
|
|
- <input type="file" name="certificate" onchange="$(this).parent().submit()" required id="upl-cert" />
|
|
|
+ <form action="{{ route('catalog.upload-certificate', ['product' => $product, 'nav' => $nav ?? null]) }}" class="visually-hidden" method="POST" enctype="multipart/form-data">
|
|
|
+ @csrf
|
|
|
+ <input type="file" name="certificate" onchange="$(this).parent().submit()" required id="upl-cert" />
|
|
|
|
|
|
- </form>
|
|
|
+ </form>
|
|
|
+ @endif
|
|
|
@endif
|
|
|
</div>
|
|
|
</div>
|
|
|
@@ -37,51 +48,53 @@
|
|
|
<div class="row">
|
|
|
<div class="col-xl-6">
|
|
|
@include('partials.input', ['name' => 'year', 'title' => 'Год', 'value' => $product->year ?? year(), 'disabled' => true])
|
|
|
- @include('partials.input', ['name' => 'article', 'title' => 'Артикул', 'required' => true, 'value' => $product->article ?? '', 'disabled' => !hasRole('admin'), 'disabled' => !hasRole('admin')])
|
|
|
- @include('partials.input', ['name' => 'nomenclature_number', 'title' => 'Номер номенклатуры', 'required' => true, 'value' => $product->nomenclature_number ?? '', 'disabled' => !hasRole('admin')])
|
|
|
- @include('partials.input', ['name' => 'name_tz', 'title' => 'Наименование по ТЗ', 'required' => true, 'value' => $product->name_tz ?? '', 'disabled' => !hasRole('admin')])
|
|
|
- @include('partials.input', ['name' => 'type_tz', 'title' => 'Тип по ТЗ', 'required' => true, 'value' => $product->type_tz ?? '', 'disabled' => !hasRole('admin')])
|
|
|
- @include('partials.input', ['name' => 'unit', 'title' => 'Ед. изм.', 'required' => true, 'value' => $product->unit ?? '', 'disabled' => !hasRole('admin')])
|
|
|
- @include('partials.input', ['name' => 'manufacturer', 'title' => 'Производитель', 'required' => true, 'value' => $product->manufacturer ?? '', 'disabled' => !hasRole('admin')])
|
|
|
- @include('partials.input', ['name' => 'type', 'title' => 'Тип', 'value' => $product->type ?? '', 'disabled' => !hasRole('admin')])
|
|
|
- @include('partials.input', ['name' => 'manufacturer_name', 'title' => 'Наименование производителя', 'required' => true, 'value' => $product->manufacturer_name ?? '', 'disabled' => !hasRole('admin')])
|
|
|
- @include('partials.input', ['name' => 'sizes', 'title' => 'Размеры', 'required' => true, 'value' => $product->sizes ?? '', 'disabled' => !hasRole('admin')])
|
|
|
- @include('partials.input', ['name' => 'product_price', 'type' => 'number', 'title' => 'Цена товара', 'required' => true, 'value' => $product->product_price ?? '', 'disabled' => !hasRole('admin')])
|
|
|
- @include('partials.input', ['name' => 'installation_price', 'type' => 'number', 'title' => 'Цена установки', 'required' => true, 'value' => $product->installation_price ?? '', 'disabled' => !hasRole('admin')])
|
|
|
- @include('partials.input', ['name' => 'total_price', 'type' => 'number', 'title' => 'Итоговая цена', 'required' => true, 'value' => $product->total_price ?? '', 'disabled' => !hasRole('admin')])
|
|
|
- @include('partials.input', ['name' => 'passport_name', 'title' => 'Наименование по паспорту', 'value' => $product->passport_name ?? '', 'disabled' => !hasRole('admin')])
|
|
|
- @include('partials.input', ['name' => 'statement_name', 'title' => 'Наименование в ведомости', 'value' => $product->statement_name ?? '', 'disabled' => !hasRole('admin')])
|
|
|
- @include('partials.input', ['name' => 'service_life', 'title' => 'Срок службы', 'type' => 'number', 'value' => $product?->service_life, 'disabled' => !hasRole('admin')])
|
|
|
+ @if($canView('article')) @include('partials.input', ['name' => 'article', 'title' => 'Артикул', 'required' => true, 'value' => $product->article ?? '', 'disabled' => !$canUpdate('article')]) @endif
|
|
|
+ @if($canView('nomenclature_number')) @include('partials.input', ['name' => 'nomenclature_number', 'title' => 'Номер номенклатуры', 'required' => true, 'value' => $product->nomenclature_number ?? '', 'disabled' => !$canUpdate('nomenclature_number')]) @endif
|
|
|
+ @if($canView('name_tz')) @include('partials.input', ['name' => 'name_tz', 'title' => 'Наименование по ТЗ', 'required' => true, 'value' => $product->name_tz ?? '', 'disabled' => !$canUpdate('name_tz')]) @endif
|
|
|
+ @if($canView('type_tz')) @include('partials.input', ['name' => 'type_tz', 'title' => 'Тип по ТЗ', 'required' => true, 'value' => $product->type_tz ?? '', 'disabled' => !$canUpdate('type_tz')]) @endif
|
|
|
+ @if($canView('unit')) @include('partials.input', ['name' => 'unit', 'title' => 'Ед. изм.', 'required' => true, 'value' => $product->unit ?? '', 'disabled' => !$canUpdate('unit')]) @endif
|
|
|
+ @if($canView('manufacturer')) @include('partials.input', ['name' => 'manufacturer', 'title' => 'Производитель', 'required' => true, 'value' => $product->manufacturer ?? '', 'disabled' => !$canUpdate('manufacturer')]) @endif
|
|
|
+ @if($canView('type')) @include('partials.input', ['name' => 'type', 'title' => 'Тип', 'value' => $product->type ?? '', 'disabled' => !$canUpdate('type')]) @endif
|
|
|
+ @if($canView('manufacturer_name')) @include('partials.input', ['name' => 'manufacturer_name', 'title' => 'Наименование производителя', 'required' => true, 'value' => $product->manufacturer_name ?? '', 'disabled' => !$canUpdate('manufacturer_name')]) @endif
|
|
|
+ @if($canView('sizes')) @include('partials.input', ['name' => 'sizes', 'title' => 'Размеры', 'required' => true, 'value' => $product->sizes ?? '', 'disabled' => !$canUpdate('sizes')]) @endif
|
|
|
+ @if($canView('product_price')) @include('partials.input', ['name' => 'product_price', 'type' => 'number', 'title' => 'Цена товара', 'required' => true, 'value' => $product->product_price ?? '', 'disabled' => !$canUpdate('product_price')]) @endif
|
|
|
+ @if($canView('installation_price')) @include('partials.input', ['name' => 'installation_price', 'type' => 'number', 'title' => 'Цена установки', 'required' => true, 'value' => $product->installation_price ?? '', 'disabled' => !$canUpdate('installation_price')]) @endif
|
|
|
+ @if($canView('total_price')) @include('partials.input', ['name' => 'total_price', 'type' => 'number', 'title' => 'Итоговая цена', 'required' => true, 'value' => $product->total_price ?? '', 'disabled' => !$canUpdate('total_price')]) @endif
|
|
|
+ @if($canView('passport_name')) @include('partials.input', ['name' => 'passport_name', 'title' => 'Наименование по паспорту', 'value' => $product->passport_name ?? '', 'disabled' => !$canUpdate('passport_name')]) @endif
|
|
|
+ @if($canView('statement_name')) @include('partials.input', ['name' => 'statement_name', 'title' => 'Наименование в ведомости', 'value' => $product->statement_name ?? '', 'disabled' => !$canUpdate('statement_name')]) @endif
|
|
|
+ @if($canView('service_life')) @include('partials.input', ['name' => 'service_life', 'title' => 'Срок службы', 'type' => 'number', 'value' => $product?->service_life, 'disabled' => !$canUpdate('service_life')]) @endif
|
|
|
|
|
|
<input type="hidden" name="nav" value="{{ $nav ?? '' }}">
|
|
|
</div>
|
|
|
<div class="col-xl-6">
|
|
|
- @if($product?->certificate)
|
|
|
+ @if($canView('certificate_id') && $product?->certificate)
|
|
|
@include('partials.input', ['name' => 'cert', 'title' => 'Сертификат', 'value' => $product->certificate->original_name, 'disabled' => true])
|
|
|
@endif
|
|
|
|
|
|
- @include('partials.input', ['name' => 'certificate_number', 'title' => 'Номер сертификата', 'value' => $product?->certificate_number, 'disabled' => !hasRole('admin')])
|
|
|
- @include('partials.input', ['name' => 'certificate_date', 'title' => 'Дата сертификата', 'type' => 'date', 'value' => $product?->certificate_date, 'disabled' => !hasRole('admin')])
|
|
|
- @include('partials.input', ['name' => 'certificate_issuer', 'title' => 'Орган сертификации', 'value' => $product?->certificate_issuer, 'disabled' => !hasRole('admin')])
|
|
|
- @include('partials.input', ['name' => 'certificate_type', 'title' => 'Вид сертификации', 'value' => $product?->certificate_type, 'disabled' => !hasRole('admin')])
|
|
|
- @include('partials.input', ['name' => 'weight', 'title' => 'Вес', 'value' => $product?->weight, 'type' => 'number', 'step' => '0.01', 'disabled' => !hasRole('admin'), 'required' => true])
|
|
|
- @include('partials.input', ['name' => 'volume', 'title' => 'Объём', 'value' => $product?->volume, 'type' => 'number', 'step' => '0.01', 'disabled' => !hasRole('admin'), 'required' => true])
|
|
|
- @include('partials.input', ['name' => 'places', 'title' => 'Кол-во мест', 'value' => $product?->places, 'type' => 'number', 'step' => '1', 'disabled' => !hasRole('admin'), 'required' => true])
|
|
|
+ @if($canView('certificate_number')) @include('partials.input', ['name' => 'certificate_number', 'title' => 'Номер сертификата', 'value' => $product?->certificate_number, 'disabled' => !$canUpdate('certificate_number')]) @endif
|
|
|
+ @if($canView('certificate_date')) @include('partials.input', ['name' => 'certificate_date', 'title' => 'Дата сертификата', 'type' => 'date', 'value' => $product?->certificate_date, 'disabled' => !$canUpdate('certificate_date')]) @endif
|
|
|
+ @if($canView('certificate_issuer')) @include('partials.input', ['name' => 'certificate_issuer', 'title' => 'Орган сертификации', 'value' => $product?->certificate_issuer, 'disabled' => !$canUpdate('certificate_issuer')]) @endif
|
|
|
+ @if($canView('certificate_type')) @include('partials.input', ['name' => 'certificate_type', 'title' => 'Вид сертификации', 'value' => $product?->certificate_type, 'disabled' => !$canUpdate('certificate_type')]) @endif
|
|
|
+ @if($canView('weight')) @include('partials.input', ['name' => 'weight', 'title' => 'Вес', 'value' => $product?->weight, 'type' => 'number', 'step' => '0.01', 'disabled' => !$canUpdate('weight'), 'required' => true]) @endif
|
|
|
+ @if($canView('volume')) @include('partials.input', ['name' => 'volume', 'title' => 'Объём', 'value' => $product?->volume, 'type' => 'number', 'step' => '0.01', 'disabled' => !$canUpdate('volume'), 'required' => true]) @endif
|
|
|
+ @if($canView('places')) @include('partials.input', ['name' => 'places', 'title' => 'Кол-во мест', 'value' => $product?->places, 'type' => 'number', 'step' => '1', 'disabled' => !$canUpdate('places'), 'required' => true]) @endif
|
|
|
|
|
|
- <div class="row mb-2">
|
|
|
- <label for="note" class="col-form-label my-1">
|
|
|
- Примечание <sup>*</sup>
|
|
|
- </label>
|
|
|
- <div>
|
|
|
- <textarea name="note" id="note" rows="15" @disabled(!hasRole('admin')) class="form-control @error('note') is-invalid @enderror" required>{{ old('note', $product->note ?? '') }}</textarea>
|
|
|
- @error('note')
|
|
|
- <span class="invalid-feedback" role="alert"><strong>{{ $message }}</strong></span>
|
|
|
- @enderror
|
|
|
+ @if($canView('note'))
|
|
|
+ <div class="row mb-2">
|
|
|
+ <label for="note" class="col-form-label my-1">
|
|
|
+ Примечание <sup>*</sup>
|
|
|
+ </label>
|
|
|
+ <div>
|
|
|
+ <textarea name="note" id="note" rows="15" @disabled(!$canUpdate('note')) class="form-control @error('note') is-invalid @enderror" required>{{ old('note', $product->note ?? '') }}</textarea>
|
|
|
+ @error('note')
|
|
|
+ <span class="invalid-feedback" role="alert"><strong>{{ $message }}</strong></span>
|
|
|
+ @enderror
|
|
|
+ </div>
|
|
|
</div>
|
|
|
- </div>
|
|
|
+ @endif
|
|
|
</div>
|
|
|
<div class="col-12">
|
|
|
- @include('partials.submit', ['deleteDisabled' => (!isset($product) || $product->hasRelations() || !hasRole('admin')), 'disabled' => !hasRole('admin'), 'offset' => 6, 'delete' => ['form_id' => 'deleteProduct'], 'back_url' => $back_url ?? route('catalog.index', session('gp_products'))])
|
|
|
+ @include('partials.submit', ['deleteDisabled' => (!isset($product) || $product->hasRelations() || !hasAccess('catalog.delete', 'admin')), 'disabled' => !(($product && hasAccess('catalog.update', 'admin')) || (!$product && hasAccess('catalog.create', 'admin'))), 'offset' => 6, 'delete' => ['form_id' => 'deleteProduct'], 'back_url' => $back_url ?? route('catalog.index', session('gp_products'))])
|
|
|
</div>
|
|
|
</div>
|
|
|
|