edit.blade.php 8.8 KB

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