edit.blade.php 22 KB

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