edit.blade.php 22 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331
  1. @extends('layouts.app')
  2. @section('content')
  3. <div class="px-3">
  4. <div class="row">
  5. <div class="col-xl-6">
  6. <h4>Рекламация</h4>
  7. </div>
  8. <div class="col-xl-6 text-end mb-2">
  9. @if(hasRole('admin') && !is_null($reclamation->brigadier_id) && !is_null($reclamation->start_work_date))
  10. <button class="btn btn-sm btn-primary" id="createScheduleButton">Перенести в график</button>
  11. @endif
  12. @if(hasRole('admin,manager'))
  13. <a href="{{ route('order.generate-reclamation-pack', $reclamation) }}"
  14. class="btn btn-primary btn-sm">Пакет документов рекламации</a>
  15. @endif
  16. </div>
  17. </div>
  18. <div class="row">
  19. <div class="col-xl-5 border-end mb-3 mb-xl-0">
  20. <form action="{{ route('reclamations.update', $reclamation) }}" method="post">
  21. @csrf
  22. <input type="hidden" id="order_id" name="order_id" value="{{ $reclamation->order_id}}">
  23. <input type="hidden" name="previous_url" value="{{ $previous_url ?? '' }}">
  24. @include('partials.input', ['name' => 'order_name', 'title' => 'Площадка', 'disabled' => true, 'value' => $reclamation->order->common_name ?? ''])
  25. @include('partials.select', ['name' => 'status_id', 'title' => 'Статус', 'options' => $statuses, 'value' => $reclamation->status_id ?? old('status_id'), 'disabled' => !hasRole('admin,manager')])
  26. @include('partials.select', ['name' => 'user_id', 'title' => 'Менеджер', 'options' => $users, 'value' => $reclamation->user_id ?? old('user_id') ?? auth()->user()->id, 'disabled' => !hasRole('admin,manager')])
  27. @include('partials.input', ['name' => 'create_date', 'title' => 'Дата создания', 'type' => 'date', 'required' => true, 'value' => $reclamation->create_date ?? date('Y-m-d'), 'disabled' => !hasRole('admin,manager')])
  28. @include('partials.input', ['name' => 'finish_date', 'title' => 'Дата завершения', 'type' => 'date', 'required' => true, 'value' => $reclamation->finish_date ?? date('Y-m-d', strtotime('+30 days')), 'disabled' => !hasRole('admin,manager')])
  29. @include('partials.select', ['name' => 'brigadier_id', 'title' => 'Бригадир', 'options' => $brigadiers, 'value' => $reclamation->brigadier_id ?? old('brigadier_id'), 'disabled' => !hasRole('admin,manager'), 'first_empty' => true])
  30. @include('partials.input', ['name' => 'start_work_date', 'title' => 'Дата начала работ', 'type' => 'date', 'value' => $reclamation->start_work_date, 'disabled' => !hasRole('admin,manager')])
  31. @include('partials.input', ['name' => 'work_days', 'title' => 'Срок работ, дней', 'type' => 'number', 'min' => 1, 'value' => $reclamation->work_days, 'disabled' => !hasRole('admin,manager')])
  32. @include('partials.select', ['name' => 'reason', 'title' => 'Причина', 'size' => 6, 'value' => $reclamation->reason ?? '', 'options' => ['Вандализм', 'Гарантия', 'Сервисное обслуживание'], 'key_as_val' => true, 'disabled' => !hasRole('admin,manager')])
  33. @include('partials.textarea', ['name' => 'guarantee', 'title' => 'Гарантии', 'size' => 6, 'value' => $reclamation->guarantee ?? '', 'disabled' => !hasRole('admin,manager')])
  34. @include('partials.textarea', ['name' => 'whats_done', 'title' => 'Что сделано', 'size' => 6, 'value' => $reclamation->whats_done ?? '', 'disabled' => !hasRole('admin,manager')])
  35. @include('partials.textarea', ['name' => 'comment', 'title' => 'Комментарий', 'size' => 6, 'value' => $reclamation->comment ?? '', 'disabled' => !hasRole('admin,manager')])
  36. @include('partials.submit', ['name' => 'Сохранить', 'offset' => 5, 'disabled' => !hasRole('admin,manager'), 'backurl' => route('reclamations.index', session('gp_reclamations'))])
  37. </form>
  38. </div>
  39. <div class="col-xl-7 ">
  40. <div class="col-12 overflow-x-scroll">
  41. <table class="table">
  42. <thead>
  43. <tr>
  44. <th>Картинка</th>
  45. <th>МАФ</th>
  46. <th>Тип</th>
  47. <th>Номер заказа МАФ</th>
  48. <th>RFID</th>
  49. <th>Заводской номер</th>
  50. <th>Дата производства</th>
  51. </tr>
  52. </thead>
  53. <tbody>
  54. @foreach($reclamation->skus as $p)
  55. <tr>
  56. <td>
  57. @if($p->product->image)
  58. <a href="{{ $p->product->image }}" data-toggle="lightbox" data-gallery="maf"
  59. data-size="fullscreen">
  60. <img src="{{ $p->product->image }}" alt="" class="img-thumbnail maf-img">
  61. </a>
  62. @endif
  63. </td>
  64. <td>
  65. @if(hasRole('admin,manager'))
  66. <a href="{{ route('product_sku.show', $p) }}">
  67. {!! $p->product->article !!}
  68. </a>
  69. <br>
  70. <a class="small" href="{{ route('catalog.show', $p->product) }}">каталог</a>
  71. @endif
  72. </td>
  73. <td>{!! $p->product->nomenclature_number !!}</td>
  74. <td>
  75. @if($p->maf_order_id && hasRole('admin,manager'))
  76. <a href="{{ route('maf_order.show', $p->maf_order) }}">{{ $p->maf_order->order_number }}</a>
  77. @endif
  78. </td>
  79. <td>{{ $p->rfid }}</td>
  80. <td>{{ $p->factory_number }}</td>
  81. <td>{{ $p->manufacture_date }}</td>
  82. </tr>
  83. @endforeach
  84. </tbody>
  85. </table>
  86. </div>
  87. <div class="details">
  88. <a href="#details" data-bs-toggle="collapse">Детали замен ({{ $reclamation->details->count() }})</a>
  89. <form method="post" action="{{ route('reclamations.update-details', $reclamation) }}"
  90. class=" my-2 collapse" id="details">
  91. @csrf
  92. <div class="rows">
  93. @foreach($reclamation->details as $detail)
  94. <div class="row mb-1">
  95. <div class="col-10">
  96. <input type="text" name="name[]" value="{{ $detail->name }}"
  97. class="form-control form-control-sm col-auto"
  98. @disabled(!hasRole('admin,manager'))
  99. placeholder="наименование или номер детали">
  100. </div>
  101. <div class="col-2">
  102. <input type="text" name="quantity[]" value="{{ $detail->quantity }}"
  103. class="form-control form-control-sm col-auto text-end"
  104. @disabled(!hasRole('admin,manager'))
  105. placeholder="кол-во">
  106. </div>
  107. </div>
  108. @endforeach
  109. <div class="row mb-1">
  110. <div class="col-10">
  111. <input type="text" name="name[]" value=""
  112. class="form-control form-control-sm col-auto"
  113. @disabled(!hasRole('admin,manager'))
  114. placeholder="наименование или номер детали">
  115. </div>
  116. <div class="col-2">
  117. <input type="text" name="quantity[]" value=""
  118. @disabled(!hasRole('admin,manager'))
  119. class="form-control form-control-sm col-auto text-end" placeholder="кол-во">
  120. </div>
  121. </div>
  122. </div>
  123. <div class="row">
  124. <div class="col-12 text-end">
  125. <span class="text-secondary small">Для удаления детали поставьте в количество 0</span>
  126. <span class="btn btn-light btn-sm cursor-pointer"
  127. @disabled(!hasRole('admin,manager'))
  128. onclick="$('.rows').children().last().clone().appendTo('.rows');">Добавить строку</span>
  129. <button class="btn btn-primary btn-sm" type="submit" @disabled(!hasRole('admin,manager'))>Сохранить детали</button>
  130. </div>
  131. </div>
  132. @if($errors->any())
  133. @dump($errors->all())
  134. @endif
  135. </form>
  136. </div>
  137. <hr>
  138. <div class="documents">
  139. Документы
  140. @if(hasRole('admin,manager'))
  141. <button class="btn btn-sm text-success" onclick="$('#upl-documents').trigger('click');"><i
  142. class="bi bi-plus-circle-fill"></i> Загрузить
  143. </button>
  144. <form action="{{ route('reclamations.upload-document', $reclamation) }}"
  145. enctype="multipart/form-data" method="post" class="visually-hidden">
  146. @csrf
  147. <input required type="file" id="upl-documents" onchange="$(this).parent().submit()" multiple
  148. name="document[]" class="form-control form-control-sm">
  149. </form>
  150. @endif
  151. <div class="row my-2 g-1">
  152. @foreach($reclamation->documents as $document)
  153. <div class="col-12">
  154. <a href="{{ $document->link }}" target="_blank">
  155. {{ $document->original_name }}
  156. </a>
  157. @if(hasRole('admin'))
  158. <i class="bi bi-x-circle-fill fs-6 text-danger cursor-pointer ms-2"
  159. onclick="if(confirm('Удалить?')) $('#document-{{ $document->id }}').submit()"
  160. title="Удалить"></i>
  161. @endif
  162. <form action="{{ route('reclamations.delete-document', [$reclamation, $document]) }}"
  163. method="POST" id="document-{{ $document->id }}" class="visually-hidden">
  164. @csrf
  165. @method('DELETE')
  166. </form>
  167. </div>
  168. @endforeach
  169. </div>
  170. </div>
  171. <hr>
  172. <div class="acts">
  173. Акты
  174. @if(hasRole('admin,manager'))
  175. <button class="btn btn-sm text-success" onclick="$('#upl-acts').trigger('click');"><i
  176. class="bi bi-plus-circle-fill"></i> Загрузить
  177. </button>
  178. <form action="{{ route('reclamations.upload-act', $reclamation) }}" enctype="multipart/form-data"
  179. method="post" class="visually-hidden">
  180. @csrf
  181. <input required type="file" id="upl-acts" onchange="$(this).parent().submit()" multiple
  182. name="acts[]" class="form-control form-control-sm">
  183. </form>
  184. @endif
  185. <div class="row my-2 g-1">
  186. @foreach($reclamation->acts as $act)
  187. <div class="col-12">
  188. <a href="{{ $act->link }}" target="_blank">
  189. {{ $act->original_name }}
  190. </a>
  191. @if(hasRole('admin'))
  192. <i class="bi bi-x-circle-fill fs-6 text-danger cursor-pointer ms-2"
  193. onclick="if(confirm('Удалить?')) $('#act-{{ $act->id }}').submit()"
  194. title="Удалить"></i>
  195. <form action="{{ route('reclamations.delete-act', [$reclamation, $act]) }}"
  196. method="POST"
  197. id="act-{{ $act->id }}" class="visually-hidden">
  198. @csrf
  199. @method('DELETE')
  200. </form>
  201. @endif
  202. </div>
  203. @endforeach
  204. </div>
  205. </div>
  206. <hr>
  207. <div class="photo_before">
  208. <a href="#photos_before" data-bs-toggle="collapse">Фотографии проблемы
  209. ({{ $reclamation->photos_before->count() }})</a>
  210. <button class="btn btn-sm text-success" onclick="$('#upl-photo-before').trigger('click');"><i
  211. class="bi bi-plus-circle-fill"></i> Загрузить
  212. </button>
  213. @if($reclamation->photos_before->count())
  214. <a href="{{ route('reclamation.generate-photos-before-pack', $reclamation) }}"
  215. class="btn btn-sm text-primary"><i
  216. class="bi bi-download"></i> Скачать все
  217. </a>
  218. @endif
  219. <form action="{{ route('reclamations.upload-photo-before', $reclamation) }}"
  220. enctype="multipart/form-data" method="post" class="visually-hidden">
  221. @csrf
  222. <input required type="file" id="upl-photo-before" onchange="$(this).parent().submit()" multiple
  223. name="photo[]" class="form-control form-control-sm" accept=".jpg,.jpeg,.png">
  224. </form>
  225. <div class="row my-2 g-1 collapse" id="photos_before">
  226. @foreach($reclamation->photos_before as $photo)
  227. <div class="col-4">
  228. <a href="{{ $photo->link }}"
  229. data-toggle="lightbox" data-gallery="photos-before" data-size="fullscreen">
  230. <img class="img-thumbnail" src="{{ $photo->link }}" alt="">
  231. </a>
  232. @if(hasRole('admin'))
  233. <i class="bi bi-x-circle-fill fs-6 text-danger cursor-pointer rm-but"
  234. onclick="if(confirm('Удалить фото?')) $('#photo-{{ $photo->id }}').submit()"
  235. title="Удалить"></i>
  236. @endif
  237. <form action="{{ route('reclamations.delete-photo-before', [$reclamation, $photo]) }}"
  238. method="POST" id="photo-{{ $photo->id }}" class="visually-hidden">
  239. @csrf
  240. @method('DELETE')
  241. </form>
  242. </div>
  243. @endforeach
  244. </div>
  245. </div>
  246. <hr>
  247. <div class="photo_after">
  248. <a href="#photos_after" data-bs-toggle="collapse">Фотографии после устранения
  249. ({{ $reclamation->photos_after->count() }})</a>
  250. <button class="btn btn-sm text-success" onclick="$('#upl-photo-after').trigger('click');"><i
  251. class="bi bi-plus-circle-fill"></i> Загрузить
  252. </button>
  253. @if($reclamation->photos_after->count())
  254. <a href="{{ route('reclamation.generate-photos-after-pack', $reclamation) }}"
  255. class="btn btn-sm text-primary"><i
  256. class="bi bi-download"></i> Скачать все
  257. </a>
  258. @endif
  259. <form action="{{ route('reclamations.upload-photo-after', $reclamation) }}"
  260. enctype="multipart/form-data" method="post" class="visually-hidden">
  261. @csrf
  262. <input required type="file" id="upl-photo-after" onchange="$(this).parent().submit()" multiple
  263. name="photo[]" class="form-control form-control-sm" accept=".jpg,.jpeg,.png">
  264. </form>
  265. <div class="row my-2 g-1 collapse" id="photos_after">
  266. @foreach($reclamation->photos_after as $photo)
  267. <div class="col-4">
  268. <a href="{{ $photo->link }}"
  269. data-toggle="lightbox" data-gallery="photos-after" data-size="fullscreen">
  270. <img class="img-thumbnail" src="{{ $photo->link }}" alt="">
  271. </a>
  272. @if(hasRole('admin'))
  273. <i class="bi bi-x-circle-fill fs-6 text-danger cursor-pointer rm-but"
  274. onclick="if(confirm('Удалить фото?')) $('#photo-{{ $photo->id }}').submit()"
  275. title="Удалить"></i>
  276. @endif
  277. <form action="{{ route('reclamations.delete-photo-after', [$reclamation, $photo]) }}"
  278. method="POST" id="photo-{{ $photo->id }}" class="visually-hidden">
  279. @csrf
  280. @method('DELETE')
  281. </form>
  282. </div>
  283. @endforeach
  284. </div>
  285. </div>
  286. </div>
  287. </div>
  288. </div>
  289. <!-- Модальное окно графика -->
  290. <div class="modal fade" id="copySchedule" tabindex="-1" aria-labelledby="exampleModalLabel" aria-hidden="true">
  291. <div class="modal-dialog modal-fullscreen-sm-down modal-lg">
  292. <div class="modal-content">
  293. <div class="modal-header">
  294. <h1 class="modal-title fs-5" id="addModalLabel">Перенести в график монтажей</h1>
  295. <button type="button" class="btn-close" data-bs-dismiss="modal" aria-label="Закрыть"></button>
  296. </div>
  297. <div class="modal-body">
  298. <form action="{{ route('schedule.create-from-reclamation') }}" method="post" id="scheduleCreateForm">
  299. @csrf
  300. <div>
  301. <input type="hidden" name="reclamation_id" value="{{ $reclamation->id }}">
  302. {{-- <textarea name="comment" placeholder="Комментарий для графика" class="form-control mb-3"></textarea>--}}
  303. <input type="checkbox" checked="checked" id="sendNotifications" name="send_notifications" class="form-check-inline">
  304. <label for="sendNotifications" class="form-check-label mb-2">Уведомить менеджера и бригадира</label><br>
  305. <input type="checkbox" id="deleteOldRecords" name="delete_old_records" class="form-check-inline">
  306. <label for="deleteOldRecords" class="form-check-label mb-2">Удалить старые записи в графике для этой рекламации?</label><br>
  307. <button type="submit" class="btn btn-primary btn-sm">Обновить график</button>
  308. </div>
  309. </form>
  310. </div>
  311. </div>
  312. </div>
  313. </div>
  314. @endsection
  315. @push('scripts')
  316. <script type="module">
  317. $('#createScheduleButton').on('click', function () {
  318. let myModalSchedule = new bootstrap.Modal(document.getElementById("copySchedule"), {});
  319. myModalSchedule.show();
  320. });
  321. </script>
  322. @endpush