| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247 |
- @extends('layouts.app')
- @section('content')
- @php
- $commonCatalogReadableFields = $commonCatalogReadableFields ?? [];
- $commonCatalogWritableFields = $commonCatalogWritableFields ?? [];
- $canView = static fn (string $field): bool => (bool) ($commonCatalogReadableFields[$field] ?? false);
- $canUpdate = static fn (string $field): bool => (bool) ($commonCatalogWritableFields[$field] ?? false);
- $calculatorEnabledValue = old(
- 'calculator_enabled',
- $item === null || $item->calculator_enabled === null ? '' : (string) (int) $item->calculator_enabled,
- );
- $priceFields = [
- 'builders_price' => 'строители',
- 'wholesale_price' => 'опт',
- 'recommended_price' => 'рек',
- 'retail_price' => 'розница',
- 'project_price' => 'проект',
- 'project_with_installation_price' => 'проект+м',
- 'pik_price' => 'пик',
- 'recommended_plus_10_price' => 'рек+10',
- ];
- @endphp
- <div class="px-3">
- <div class="row mb-3">
- <div class="col-md-7 d-flex align-items-center">
- <h3 class="mb-0">
- {{ $item ? 'Позиция '.($canView('article') ? $item->article : '') : 'Новая позиция общего каталога' }}
- </h3>
- </div>
- @if($item)
- <div class="col-md-5 d-flex flex-wrap align-items-center justify-content-end gap-2 action-toolbar">
- @if(hasPermission('common-catalog.image.upload'))
- <button type="button" class="btn btn-sm btn-outline-success"
- onclick="document.getElementById('common-catalog-image-input').click()">
- <i class="bi bi-image"></i> Загрузить фото
- </button>
- <form action="{{ route('common-catalog.image.upload', ['commonCatalogItem' => $item, 'nav' => $nav ?? null]) }}"
- method="POST" enctype="multipart/form-data" class="visually-hidden">
- @csrf
- <input id="common-catalog-image-input" type="file" name="image"
- accept=".jpg,.jpeg,.png,.webp" required onchange="this.form.submit()">
- </form>
- @endif
- <button type="button" class="btn btn-sm btn-outline-secondary" disabled
- title="Будет подключено после получения контракта API">
- <i class="bi bi-calculator"></i> Калькуляция
- </button>
- </div>
- @endif
- </div>
- @if($item?->imageFile && $canView('image'))
- <div class="card mb-3">
- <div class="card-body d-flex align-items-start gap-3">
- <a href="{{ $item->imageFile->link }}" data-toggle="lightbox" data-gallery="common-catalog">
- <img src="{{ $item->imageFile->thumbnail_link }}" alt="{{ $item->article }}"
- class="img-thumbnail" style="max-width: 180px; max-height: 180px">
- </a>
- @if(hasPermission('common-catalog.image.delete'))
- <form action="{{ route('common-catalog.image.delete', ['commonCatalogItem' => $item, 'nav' => $nav ?? null]) }}"
- method="POST" onsubmit="return confirm('Удалить изображение?')">
- @csrf
- @method('DELETE')
- <button type="submit" class="btn btn-sm btn-outline-danger">Удалить фото</button>
- </form>
- @endif
- </div>
- </div>
- @endif
- <form action="{{ $item ? route('common-catalog.update', $item) : route('common-catalog.store') }}" method="POST">
- @csrf
- @if($item) @method('PUT') @endif
- <input type="hidden" name="nav" value="{{ $nav ?? '' }}">
- <div class="row">
- <div class="col-xl-6">
- @if($canView('article'))
- @include('partials.input', ['name' => 'article', 'title' => 'Артикул', 'required' => true, 'value' => $item?->article, 'disabled' => !$canUpdate('article')])
- @endif
- @if($canView('calculator_name'))
- <div class="row mb-2">
- <label for="calculator_name" class="col-form-label small col-md-4 text-md-end">
- Наименование <sup>*</sup>
- </label>
- <div class="col-md-8">
- <textarea name="calculator_name" id="calculator_name" rows="4" required
- @disabled(!$canUpdate('calculator_name'))
- class="form-control form-control-sm @error('calculator_name') is-invalid @enderror">{{ old('calculator_name', $item?->calculator_name) }}</textarea>
- @error('calculator_name')
- <div class="invalid-feedback"><strong>{{ $message }}</strong></div>
- @enderror
- </div>
- </div>
- @endif
- @if($canView('kind')) @include('partials.input', ['name' => 'kind', 'title' => 'Вид', 'value' => $item?->kind, 'disabled' => !$canUpdate('kind')]) @endif
- @if($canView('dimension_length')) @include('partials.input', ['name' => 'dimension_length', 'title' => 'Габариты: длина', 'value' => $item?->dimension_length, 'disabled' => !$canUpdate('dimension_length')]) @endif
- @if($canView('dimension_width')) @include('partials.input', ['name' => 'dimension_width', 'title' => 'Габариты: ширина', 'value' => $item?->dimension_width, 'disabled' => !$canUpdate('dimension_width')]) @endif
- @if($canView('dimension_height')) @include('partials.input', ['name' => 'dimension_height', 'title' => 'Габариты: высота', 'value' => $item?->dimension_height, 'disabled' => !$canUpdate('dimension_height')]) @endif
- @if($canView('site_length')) @include('partials.input', ['name' => 'site_length', 'title' => 'Размер участка: длина', 'value' => $item?->site_length, 'disabled' => !$canUpdate('site_length')]) @endif
- @if($canView('site_width')) @include('partials.input', ['name' => 'site_width', 'title' => 'Размер участка: ширина', 'value' => $item?->site_width, 'disabled' => !$canUpdate('site_width')]) @endif
- @if($canView('fall_height')) @include('partials.input', ['name' => 'fall_height', 'title' => 'Высота падения', 'type' => 'number', 'min' => 0, 'step' => '0.001', 'value' => $item?->fall_height, 'disabled' => !$canUpdate('fall_height')]) @endif
- @if($canView('additional_info'))
- <div class="row mb-2">
- <label for="additional_info" class="col-form-label small col-md-4 text-md-end">Дополнительные сведения</label>
- <div class="col-md-8">
- <textarea name="additional_info" id="additional_info" rows="4"
- @disabled(!$canUpdate('additional_info'))
- class="form-control form-control-sm @error('additional_info') is-invalid @enderror">{{ old('additional_info', $item?->additional_info) }}</textarea>
- @error('additional_info')
- <div class="invalid-feedback"><strong>{{ $message }}</strong></div>
- @enderror
- </div>
- </div>
- @endif
- </div>
- <div class="col-xl-6">
- @if($canView('dimension_unit')) @include('partials.input', ['name' => 'dimension_unit', 'title' => 'Единица измерения габаритов', 'value' => $item?->dimension_unit, 'disabled' => !$canUpdate('dimension_unit')]) @endif
- @if($canView('weight')) @include('partials.input', ['name' => 'weight', 'title' => 'Вес, кг.', 'type' => 'number', 'min' => 0, 'step' => '0.001', 'value' => $item?->weight, 'disabled' => !$canUpdate('weight')]) @endif
- @if($canView('volume')) @include('partials.input', ['name' => 'volume', 'title' => 'Объем, м3', 'type' => 'number', 'min' => 0, 'step' => '0.001', 'value' => $item?->volume, 'disabled' => !$canUpdate('volume')]) @endif
- @if($canView('places')) @include('partials.input', ['name' => 'places', 'title' => 'Места', 'type' => 'number', 'min' => 0, 'step' => 1, 'value' => $item?->places, 'disabled' => !$canUpdate('places')]) @endif
- @if($canView('composition'))
- <div class="row mb-2">
- <label for="composition" class="col-form-label small col-md-4 text-md-end">Состав</label>
- <div class="col-md-8">
- <textarea name="composition" id="composition" rows="4"
- @disabled(!$canUpdate('composition'))
- class="form-control form-control-sm @error('composition') is-invalid @enderror">{{ old('composition', $item?->composition) }}</textarea>
- @error('composition')
- <div class="invalid-feedback"><strong>{{ $message }}</strong></div>
- @enderror
- </div>
- </div>
- @endif
- @if($canView('age_group')) @include('partials.input', ['name' => 'age_group', 'title' => 'Возрастная группа', 'value' => $item?->age_group, 'disabled' => !$canUpdate('age_group')]) @endif
- @if($canView('max_users')) @include('partials.input', ['name' => 'max_users', 'title' => 'Макс. кол-во пользователей', 'type' => 'number', 'min' => 0, 'step' => 1, 'value' => $item?->max_users, 'disabled' => !$canUpdate('max_users')]) @endif
- @if($canView('unit')) @include('partials.input', ['name' => 'unit', 'title' => 'Ед.', 'value' => $item?->unit, 'disabled' => !$canUpdate('unit')]) @endif
- @if($canView('series')) @include('partials.input', ['name' => 'series', 'title' => 'Серия', 'value' => $item?->series, 'disabled' => !$canUpdate('series')]) @endif
- @if($canView('trademark')) @include('partials.input', ['name' => 'trademark', 'title' => 'ТМ', 'value' => $item?->trademark, 'disabled' => !$canUpdate('trademark')]) @endif
- @if($canView('calculator_enabled'))
- <div class="row mb-2">
- <label for="calculator_enabled" class="col-form-label small col-md-4 text-md-end">Калькулятор</label>
- <div class="col-md-8">
- <select name="calculator_enabled" id="calculator_enabled"
- @disabled(!$canUpdate('calculator_enabled'))
- class="form-select form-select-sm @error('calculator_enabled') is-invalid @enderror">
- <option value="">—</option>
- <option value="1" @selected((string) $calculatorEnabledValue === '1')>да</option>
- <option value="0" @selected((string) $calculatorEnabledValue === '0')>нет</option>
- </select>
- @error('calculator_enabled')
- <div class="invalid-feedback"><strong>{{ $message }}</strong></div>
- @enderror
- </div>
- </div>
- @endif
- </div>
- </div>
- @if(collect(array_keys($priceFields))->contains(fn (string $field): bool => $canView($field)))
- <div class="card mt-3">
- <div class="card-header"><strong>Цены</strong></div>
- <div class="card-body row">
- @foreach($priceFields as $field => $label)
- @if($canView($field))
- <div class="col-xl-6">
- @include('partials.input', [
- 'name' => $field,
- 'title' => $label,
- 'type' => 'number',
- 'min' => 0,
- 'step' => '0.01',
- 'value' => $item?->{$field},
- 'disabled' => !$canUpdate($field),
- ])
- </div>
- @endif
- @endforeach
- </div>
- </div>
- @endif
- <div class="d-flex flex-wrap gap-2 mt-3">
- @if(($item && hasPermission('common-catalog.update')) || (!$item && hasPermission('common-catalog.create')))
- <button type="submit" class="btn btn-sm btn-primary">Сохранить</button>
- @endif
- <a href="{{ $back_url ?? route('common-catalog.index') }}" class="btn btn-sm btn-outline-secondary">Назад</a>
- </div>
- </form>
- @if($item)
- <div class="card mt-4">
- <div class="card-header d-flex justify-content-between align-items-center">
- <strong>Документы</strong>
- @if(hasPermission('common-catalog.documents.upload'))
- <form action="{{ route('common-catalog.documents.upload', ['commonCatalogItem' => $item, 'nav' => $nav ?? null]) }}"
- method="POST" enctype="multipart/form-data" class="d-flex gap-2">
- @csrf
- <input type="file" name="document" class="form-control form-control-sm" required>
- <button type="submit" class="btn btn-sm btn-outline-primary">Загрузить</button>
- </form>
- @endif
- </div>
- <div class="card-body">
- @forelse($item->documents as $document)
- <div class="d-flex justify-content-between align-items-center border-bottom py-2">
- <a href="{{ $document->link }}" target="_blank" rel="noopener">{{ $document->original_name }}</a>
- @if(hasPermission('common-catalog.documents.delete'))
- <form action="{{ route('common-catalog.documents.delete', ['commonCatalogItem' => $item, 'file' => $document, 'nav' => $nav ?? null]) }}"
- method="POST" onsubmit="return confirm('Удалить документ?')">
- @csrf
- @method('DELETE')
- <button type="submit" class="btn btn-sm btn-outline-danger">Удалить</button>
- </form>
- @endif
- </div>
- @empty
- <span class="text-muted">Документы не загружены.</span>
- @endforelse
- </div>
- </div>
- <div class="card mt-4">
- <div class="card-header"><strong>Техническое описание</strong></div>
- <div class="card-body text-muted">
- Блок подготовлен к подключению данных и выгрузок из готового Laravel-модуля технических описаний.
- </div>
- </div>
- @if(hasPermission('common-catalog.delete'))
- <form action="{{ route('common-catalog.destroy', $item) }}" method="POST" class="mt-4"
- onsubmit="return confirm('Удалить позицию общего каталога?')">
- @csrf
- @method('DELETE')
- <button type="submit" class="btn btn-sm btn-danger">Удалить позицию</button>
- </form>
- @endif
- @endif
- </div>
- @endsection
|