edit.blade.php 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112
  1. @extends('layouts.app')
  2. @section('content')
  3. @php
  4. $catalogReadableFields = $catalogReadableFields ?? [];
  5. $catalogWritableFields = $catalogWritableFields ?? [];
  6. $canView = static fn (string $field): bool => (bool)($catalogReadableFields[$field] ?? false);
  7. $canUpdate = static fn (string $field): bool => (bool)($catalogWritableFields[$field] ?? false);
  8. $visibleName = ($product && $canView('article') && $canView('nomenclature_number')) ? $product->common_name : 'МАФ';
  9. @endphp
  10. <div class="px-3">
  11. <div class="row mb-2">
  12. <div class="col-md-6 d-flex align-items-center">
  13. <h3 class="mb-0">МАФ {{ $product ? $visibleName : 'Новый МАФ' }} ({{ $product->year ?? year() }})</h3>
  14. </div>
  15. <div class="col-md-6 d-flex align-items-center justify-content-end action-toolbar">
  16. @if(isset($product))
  17. @if($canView('image') && $product->image)
  18. <a href="{{ $product->image }}" data-toggle="lightbox" data-gallery="photos" data-size="fullscreen">
  19. <img src="{{ $product->image }}" alt="Миниатюра" class="img-thumbnail img-max-40">
  20. </a>
  21. @endif
  22. @if(hasAccess('catalog.thumbnail.upload', 'admin'))
  23. <button class="btn btn-sm text-success" onclick="$('#upl-thumb').trigger('click');" title="Загрузить изображение"><i class="bi bi-image"></i> Изображение</button>
  24. <form action="{{ route('catalog.upload-thumbnail', ['product' => $product, 'nav' => $nav ?? null]) }}" class="visually-hidden" method="POST" enctype="multipart/form-data">
  25. @csrf
  26. <input type="file" name="thumbnail" accept=".jpg,.jpeg" onchange="$(this).parent().submit()" required id="upl-thumb" />
  27. </form>
  28. @endif
  29. @if(hasAccess('catalog.certificates.upload', 'admin'))
  30. <button class="btn btn-sm text-success" onclick="$('#upl-cert').trigger('click');"><i class="bi bi-plus-circle-fill"></i> Загрузить сертификат</button>
  31. <form action="{{ route('catalog.upload-certificate', ['product' => $product, 'nav' => $nav ?? null]) }}" class="visually-hidden" method="POST" enctype="multipart/form-data">
  32. @csrf
  33. <input type="file" name="certificate" onchange="$(this).parent().submit()" required id="upl-cert" />
  34. </form>
  35. @endif
  36. @endif
  37. </div>
  38. </div>
  39. <div class="">
  40. <form action="{{ ($product) ? route('catalog.update', $product) : route('catalog.store') }}" method="post">
  41. @csrf
  42. <div class="row">
  43. <div class="col-xl-6">
  44. @include('partials.input', ['name' => 'year', 'title' => 'Год', 'value' => $product->year ?? year(), 'disabled' => true])
  45. @if($canView('article')) @include('partials.input', ['name' => 'article', 'title' => 'Артикул', 'required' => true, 'value' => $product->article ?? '', 'disabled' => !$canUpdate('article')]) @endif
  46. @if($canView('nomenclature_number')) @include('partials.input', ['name' => 'nomenclature_number', 'title' => 'Номер номенклатуры', 'required' => true, 'value' => $product->nomenclature_number ?? '', 'disabled' => !$canUpdate('nomenclature_number')]) @endif
  47. @if($canView('name_tz')) @include('partials.input', ['name' => 'name_tz', 'title' => 'Наименование по ТЗ', 'required' => true, 'value' => $product->name_tz ?? '', 'disabled' => !$canUpdate('name_tz')]) @endif
  48. @if($canView('type_tz')) @include('partials.input', ['name' => 'type_tz', 'title' => 'Тип по ТЗ', 'required' => true, 'value' => $product->type_tz ?? '', 'disabled' => !$canUpdate('type_tz')]) @endif
  49. @if($canView('unit')) @include('partials.input', ['name' => 'unit', 'title' => 'Ед. изм.', 'required' => true, 'value' => $product->unit ?? '', 'disabled' => !$canUpdate('unit')]) @endif
  50. @if($canView('manufacturer')) @include('partials.input', ['name' => 'manufacturer', 'title' => 'Производитель', 'required' => true, 'value' => $product->manufacturer ?? '', 'disabled' => !$canUpdate('manufacturer')]) @endif
  51. @if($canView('type')) @include('partials.input', ['name' => 'type', 'title' => 'Тип', 'value' => $product->type ?? '', 'disabled' => !$canUpdate('type')]) @endif
  52. @if($canView('manufacturer_name')) @include('partials.input', ['name' => 'manufacturer_name', 'title' => 'Наименование производителя', 'required' => true, 'value' => $product->manufacturer_name ?? '', 'disabled' => !$canUpdate('manufacturer_name')]) @endif
  53. @if($canView('sizes')) @include('partials.input', ['name' => 'sizes', 'title' => 'Размеры', 'required' => true, 'value' => $product->sizes ?? '', 'disabled' => !$canUpdate('sizes')]) @endif
  54. @if($canView('product_price')) @include('partials.input', ['name' => 'product_price', 'type' => 'number', 'title' => 'Цена товара', 'required' => true, 'value' => $product->product_price ?? '', 'disabled' => !$canUpdate('product_price')]) @endif
  55. @if($canView('installation_price')) @include('partials.input', ['name' => 'installation_price', 'type' => 'number', 'title' => 'Цена установки', 'required' => true, 'value' => $product->installation_price ?? '', 'disabled' => !$canUpdate('installation_price')]) @endif
  56. @if($canView('total_price')) @include('partials.input', ['name' => 'total_price', 'type' => 'number', 'title' => 'Итоговая цена', 'required' => true, 'value' => $product->total_price ?? '', 'disabled' => !$canUpdate('total_price')]) @endif
  57. @if($canView('passport_name')) @include('partials.input', ['name' => 'passport_name', 'title' => 'Наименование по паспорту', 'value' => $product->passport_name ?? '', 'disabled' => !$canUpdate('passport_name')]) @endif
  58. @if($canView('statement_name')) @include('partials.input', ['name' => 'statement_name', 'title' => 'Наименование в ведомости', 'value' => $product->statement_name ?? '', 'disabled' => !$canUpdate('statement_name')]) @endif
  59. @if($canView('service_life')) @include('partials.input', ['name' => 'service_life', 'title' => 'Срок службы', 'type' => 'number', 'value' => $product?->service_life, 'disabled' => !$canUpdate('service_life')]) @endif
  60. <input type="hidden" name="nav" value="{{ $nav ?? '' }}">
  61. </div>
  62. <div class="col-xl-6">
  63. @if($canView('certificate_id') && $product?->certificate)
  64. @include('partials.input', ['name' => 'cert', 'title' => 'Сертификат', 'value' => $product->certificate->original_name, 'disabled' => true])
  65. @endif
  66. @if($canView('certificate_number')) @include('partials.input', ['name' => 'certificate_number', 'title' => 'Номер сертификата', 'value' => $product?->certificate_number, 'disabled' => !$canUpdate('certificate_number')]) @endif
  67. @if($canView('certificate_date')) @include('partials.input', ['name' => 'certificate_date', 'title' => 'Дата сертификата', 'type' => 'date', 'value' => $product?->certificate_date, 'disabled' => !$canUpdate('certificate_date')]) @endif
  68. @if($canView('certificate_issuer')) @include('partials.input', ['name' => 'certificate_issuer', 'title' => 'Орган сертификации', 'value' => $product?->certificate_issuer, 'disabled' => !$canUpdate('certificate_issuer')]) @endif
  69. @if($canView('certificate_type')) @include('partials.input', ['name' => 'certificate_type', 'title' => 'Вид сертификации', 'value' => $product?->certificate_type, 'disabled' => !$canUpdate('certificate_type')]) @endif
  70. @if($canView('weight')) @include('partials.input', ['name' => 'weight', 'title' => 'Вес', 'value' => $product?->weight, 'type' => 'number', 'step' => '0.01', 'disabled' => !$canUpdate('weight'), 'required' => true]) @endif
  71. @if($canView('volume')) @include('partials.input', ['name' => 'volume', 'title' => 'Объём', 'value' => $product?->volume, 'type' => 'number', 'step' => '0.01', 'disabled' => !$canUpdate('volume'), 'required' => true]) @endif
  72. @if($canView('places')) @include('partials.input', ['name' => 'places', 'title' => 'Кол-во мест', 'value' => $product?->places, 'type' => 'number', 'step' => '1', 'disabled' => !$canUpdate('places'), 'required' => true]) @endif
  73. @if($canView('note'))
  74. <div class="row mb-2">
  75. <label for="note" class="col-form-label my-1">
  76. Примечание <sup>*</sup>
  77. </label>
  78. <div>
  79. <textarea name="note" id="note" rows="15" @disabled(!$canUpdate('note')) class="form-control @error('note') is-invalid @enderror" required>{{ old('note', $product->note ?? '') }}</textarea>
  80. @error('note')
  81. <span class="invalid-feedback" role="alert"><strong>{{ $message }}</strong></span>
  82. @enderror
  83. </div>
  84. </div>
  85. @endif
  86. </div>
  87. <div class="col-12">
  88. @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'))])
  89. </div>
  90. </div>
  91. </form>
  92. @if($product)
  93. <div class="visually-hidden">
  94. <form action="{{ route('catalog.delete', $product) }}" method="POST" id="deleteProduct">
  95. @csrf
  96. @method('DELETE')
  97. </form>
  98. </div>
  99. @endif
  100. </div>
  101. </div>
  102. @endsection