edit.blade.php 51 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791
  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. <a href="{{ route('reclamation.generate-reclamation-payment-pack', $reclamation) }}"
  16. class="btn btn-primary btn-sm">Пакет документов на оплату</a>
  17. @endif
  18. @if(hasRole('admin'))
  19. <a href="#" onclick="customConfirm('Удалить рекламацию?', function () { $('form#destroy').submit(); }, 'Подтверждение удаления'); return false;"
  20. class="btn btn-sm btn-danger">Удалить</a>
  21. <form action="{{ route('reclamations.delete', $reclamation) }}" method="post" class="d-none" id="destroy">
  22. @csrf
  23. @method('DELETE')
  24. </form>
  25. @endif
  26. </div>
  27. </div>
  28. <div class="row">
  29. <div class="col-xl-5 border-end mb-3 mb-xl-0">
  30. <form action="{{ route('reclamations.update', $reclamation) }}" method="post">
  31. @csrf
  32. <input type="hidden" id="order_id" name="order_id" value="{{ $reclamation->order_id}}">
  33. <input type="hidden" name="previous_url" value="{{ $previous_url ?? '' }}">
  34. @include('partials.link', ['title' => 'Площадка', 'href' => route('order.show', $reclamation->order_id), 'text' => $reclamation->order->common_name ?? ''])
  35. @include('partials.select', ['name' => 'status_id', 'title' => 'Статус', 'options' => $statuses, 'value' => $reclamation->status_id ?? old('status_id'), 'disabled' => !hasRole('admin,manager')])
  36. @include('partials.select', ['name' => 'user_id', 'title' => 'Менеджер', 'options' => $users, 'value' => $reclamation->user_id ?? old('user_id') ?? auth()->user()->id, 'disabled' => !hasRole('admin,manager')])
  37. @include('partials.input', ['name' => 'maf_installation_year', 'title' => 'Год установки МАФ', 'type' => 'text', 'value' => $reclamation->order->year, 'disabled' => true])
  38. @include('partials.input', ['name' => 'create_date', 'title' => 'Дата создания', 'type' => 'date', 'required' => true, 'value' => $reclamation->create_date ?? date('Y-m-d'), 'disabled' => !hasRole('admin,manager')])
  39. @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')])
  40. @include('partials.select', ['name' => 'brigadier_id', 'title' => 'Бригадир', 'options' => $brigadiers, 'value' => $reclamation->brigadier_id ?? old('brigadier_id'), 'disabled' => !hasRole('admin,manager'), 'first_empty' => true])
  41. @include('partials.input', ['name' => 'start_work_date', 'title' => 'Дата начала работ', 'type' => 'date', 'value' => $reclamation->start_work_date, 'disabled' => !hasRole('admin,manager')])
  42. @include('partials.input', ['name' => 'work_days', 'title' => 'Срок работ, дней', 'type' => 'number', 'min' => 1, 'value' => $reclamation->work_days, 'disabled' => !hasRole('admin,manager')])
  43. @include('partials.select', ['name' => 'reason', 'title' => 'Причина', 'size' => 6, 'value' => $reclamation->reason ?? '', 'options' => ['Вандализм', 'Гарантия', 'Сервисное обслуживание'], 'key_as_val' => true, 'disabled' => !hasRole('admin,manager')])
  44. @include('partials.input', ['name' => 'factory_reclamation_number', 'title' => '№ рекламации на фабрике', 'type' => 'text', 'value' => $reclamation->factory_reclamation_number ?? '', 'disabled' => !hasRole('admin,manager')])
  45. @include('partials.textarea', ['name' => 'guarantee', 'title' => 'Гарантии', 'size' => 6, 'value' => $reclamation->guarantee ?? '', 'disabled' => !hasRole('admin,manager')])
  46. @include('partials.textarea', ['name' => 'whats_done', 'title' => 'Что сделано', 'size' => 6, 'value' => $reclamation->whats_done ?? '', 'disabled' => !hasRole('admin,manager')])
  47. @include('partials.textarea', ['name' => 'comment', 'title' => 'Комментарий', 'size' => 6, 'value' => $reclamation->comment ?? '', 'disabled' => !hasRole('admin,manager')])
  48. @include('partials.submit', ['name' => 'Сохранить', 'offset' => 5, 'disabled' => !hasRole('admin,manager'), 'backurl' => route('reclamations.index', session('gp_reclamations'))])
  49. </form>
  50. </div>
  51. <div class="col-xl-7 ">
  52. <div class="col-12 overflow-x-scroll">
  53. <table class="table">
  54. <thead>
  55. <tr>
  56. <th>Картинка</th>
  57. <th>МАФ</th>
  58. <th>Тип</th>
  59. <th>Номер заказа МАФ</th>
  60. <th>RFID</th>
  61. <th>Заводской номер</th>
  62. <th>Дата производства</th>
  63. </tr>
  64. </thead>
  65. <tbody>
  66. @foreach($reclamation->skus as $p)
  67. <tr>
  68. <td>
  69. @if($p->product->image)
  70. <a href="{{ $p->product->image }}" data-toggle="lightbox" data-gallery="maf"
  71. data-size="fullscreen">
  72. <img src="{{ $p->product->image }}" alt="" class="img-thumbnail maf-img">
  73. </a>
  74. @endif
  75. </td>
  76. <td>
  77. @if(hasRole('admin,manager'))
  78. <a href="{{ route('product_sku.show', $p) }}">
  79. {!! $p->product->article !!}
  80. </a>
  81. <br>
  82. <a class="small" href="{{ route('catalog.show', $p->product) }}">каталог</a>
  83. @endif
  84. </td>
  85. <td>{!! $p->product->nomenclature_number !!}</td>
  86. <td>
  87. @if($p->maf_order_id && hasRole('admin'))
  88. <a href="{{ route('maf_order.show', $p->maf_order) }}">{{ $p->maf_order->order_number }}</a>
  89. @else
  90. {{ $p->maf_order?->order_number }}
  91. @endif
  92. </td>
  93. <td>{{ $p->rfid }}</td>
  94. <td>{{ $p->factory_number }}</td>
  95. <td>{{ $p->manufacture_date }}</td>
  96. </tr>
  97. @endforeach
  98. </tbody>
  99. </table>
  100. </div>
  101. <div class="spare-parts">
  102. @php
  103. $activeReservationsCount = $reclamation->activeReservations()->count();
  104. $openShortagesCount = $reclamation->openShortages()->count();
  105. @endphp
  106. <a href="#spare_parts" data-bs-toggle="collapse">
  107. Запчасти ({{ $reclamation->spareParts->count() }})
  108. @if($activeReservationsCount > 0)
  109. <span class="badge bg-warning" title="Активных резервов">{{ $activeReservationsCount }} резерв</span>
  110. @endif
  111. @if($openShortagesCount > 0)
  112. <span class="badge bg-danger" title="Открытых дефицитов">{{ $openShortagesCount }} дефицит</span>
  113. @endif
  114. </a>
  115. <form method="post" action="{{ route('reclamations.update-spare-parts', $reclamation) }}"
  116. class="my-2 collapse" id="spare_parts">
  117. @csrf
  118. <div class="spare-parts-rows">
  119. @forelse($reclamation->spareParts as $idx => $sp)
  120. <div class="row mb-1 spare-part-row" data-index="{{ $idx }}">
  121. <div class="col-6 position-relative">
  122. <input type="hidden" name="rows[{{ $idx }}][spare_part_id]" value="{{ $sp->id }}" class="spare-part-id">
  123. <input type="text" class="form-control form-control-sm spare-part-search"
  124. value="{{ $sp->article }}@if($sp->used_in_maf) ({{ $sp->used_in_maf }})@endif"
  125. placeholder="Введите артикул или название"
  126. autocomplete="off"
  127. @disabled(!hasRole('admin,manager'))>
  128. <div class="spare-part-dropdown"></div>
  129. </div>
  130. <div class="col-2">
  131. <input type="number" name="rows[{{ $idx }}][quantity]" value="{{ $sp->pivot->quantity }}"
  132. min="0" class="form-control form-control-sm text-end"
  133. @disabled(!hasRole('admin,manager'))
  134. placeholder="кол-во">
  135. </div>
  136. <div class="col-3">
  137. <div class="form-check form-check-inline mt-1">
  138. <input type="hidden" name="rows[{{ $idx }}][with_documents]" value="0">
  139. <input type="checkbox" name="rows[{{ $idx }}][with_documents]" value="1"
  140. class="form-check-input" id="with_docs_{{ $idx }}"
  141. @checked($sp->pivot->with_documents)
  142. @disabled(!hasRole('admin,manager'))>
  143. <label class="form-check-label small" for="with_docs_{{ $idx }}">с док.</label>
  144. </div>
  145. </div>
  146. <div class="col-1">
  147. <span class="btn btn-sm text-danger remove-spare-part-row" title="Удалить строку">
  148. <i class="bi bi-x-circle"></i>
  149. </span>
  150. </div>
  151. </div>
  152. @empty
  153. <div class="row mb-1 spare-part-row" data-index="0">
  154. <div class="col-6 position-relative">
  155. <input type="hidden" name="rows[0][spare_part_id]" value="" class="spare-part-id">
  156. <input type="text" class="form-control form-control-sm spare-part-search"
  157. value=""
  158. placeholder="Введите артикул или название"
  159. autocomplete="off"
  160. @disabled(!hasRole('admin,manager'))>
  161. <div class="spare-part-dropdown"></div>
  162. </div>
  163. <div class="col-2">
  164. <input type="number" name="rows[0][quantity]" value=""
  165. min="0" class="form-control form-control-sm text-end"
  166. @disabled(!hasRole('admin,manager'))
  167. placeholder="кол-во">
  168. </div>
  169. <div class="col-3">
  170. <div class="form-check form-check-inline mt-1">
  171. <input type="hidden" name="rows[0][with_documents]" value="0">
  172. <input type="checkbox" name="rows[0][with_documents]" value="1"
  173. class="form-check-input" id="with_docs_0"
  174. @disabled(!hasRole('admin,manager'))>
  175. <label class="form-check-label small" for="with_docs_0">с док.</label>
  176. </div>
  177. </div>
  178. <div class="col-1">
  179. <span class="btn btn-sm text-danger remove-spare-part-row" title="Удалить строку">
  180. <i class="bi bi-x-circle"></i>
  181. </span>
  182. </div>
  183. </div>
  184. @endforelse
  185. </div>
  186. <div class="row mb-1 spare-part-row spare-part-template d-none" data-index="__INDEX__">
  187. <div class="col-6 position-relative">
  188. <input type="hidden" name="rows[__INDEX__][spare_part_id]" value="" class="spare-part-id">
  189. <input type="text" class="form-control form-control-sm spare-part-search"
  190. value=""
  191. placeholder="Введите артикул или название"
  192. autocomplete="off"
  193. disabled>
  194. <div class="spare-part-dropdown"></div>
  195. </div>
  196. <div class="col-2">
  197. <input type="number" name="rows[__INDEX__][quantity]" value=""
  198. min="0" class="form-control form-control-sm text-end" disabled
  199. placeholder="кол-во">
  200. </div>
  201. <div class="col-3">
  202. <div class="form-check form-check-inline mt-1">
  203. <input type="hidden" name="rows[__INDEX__][with_documents]" value="0">
  204. <input type="checkbox" name="rows[__INDEX__][with_documents]" value="1"
  205. class="form-check-input" disabled>
  206. <label class="form-check-label small">с док.</label>
  207. </div>
  208. </div>
  209. <div class="col-1">
  210. <span class="btn btn-sm text-danger remove-spare-part-row" title="Удалить строку">
  211. <i class="bi bi-x-circle"></i>
  212. </span>
  213. </div>
  214. </div>
  215. <div class="row">
  216. <div class="col-12 text-end">
  217. <span class="btn btn-light btn-sm cursor-pointer" id="add-spare-part-row"
  218. @disabled(!hasRole('admin,manager'))>Добавить строку</span>
  219. <button class="btn btn-primary btn-sm" type="submit" @disabled(!hasRole('admin,manager'))>Сохранить запчасти</button>
  220. </div>
  221. </div>
  222. @if($errors->any())
  223. @dump($errors->all())
  224. @endif
  225. </form>
  226. {{-- Резервы и дефициты --}}
  227. @php
  228. $reservations = $reclamation->sparePartReservations()
  229. ->with('sparePart', 'sparePartOrder')
  230. ->orderByDesc('created_at')
  231. ->get();
  232. $shortages = $reclamation->sparePartShortages()
  233. ->with('sparePart')
  234. ->orderByDesc('created_at')
  235. ->get();
  236. @endphp
  237. @if($reservations->count() > 0 || $shortages->count() > 0)
  238. <div class="mt-3 p-2 border rounded bg-light">
  239. {{-- Активные резервы --}}
  240. @if($reservations->where('status', 'active')->count() > 0)
  241. <div class="mb-3">
  242. <strong class="text-warning"><i class="bi bi-bookmark-fill"></i> Активные резервы</strong>
  243. <table class="table table-sm table-striped mt-1 mb-0">
  244. <thead>
  245. <tr>
  246. <th>Запчасть</th>
  247. <th class="text-center">Кол-во</th>
  248. <th class="text-center">С док.</th>
  249. <th>Партия</th>
  250. @if(hasRole('admin,manager'))
  251. <th></th>
  252. @endif
  253. </tr>
  254. </thead>
  255. <tbody>
  256. @foreach($reservations->where('status', 'active') as $reservation)
  257. <tr>
  258. <td>
  259. @if($reservation->sparePart)
  260. @if(hasRole('admin,manager'))
  261. <a href="{{ route('spare_parts.show', $reservation->sparePart->id) }}">
  262. {{ $reservation->sparePart->article }}
  263. </a>
  264. @else
  265. {{ $reservation->sparePart->article }}
  266. @endif
  267. @else
  268. -
  269. @endif
  270. </td>
  271. <td class="text-center">{{ $reservation->reserved_qty }}</td>
  272. <td class="text-center">
  273. @if($reservation->with_documents)
  274. <i class="bi bi-check-circle text-success"></i>
  275. @else
  276. <i class="bi bi-x-circle text-muted"></i>
  277. @endif
  278. </td>
  279. <td>
  280. @if($reservation->sparePartOrder)
  281. @if(hasRole('admin,manager'))
  282. <a href="{{ route('spare_part_orders.show', $reservation->sparePartOrder->id) }}">
  283. #{{ $reservation->sparePartOrder->id }}
  284. </a>
  285. @else
  286. #{{ $reservation->sparePartOrder->id }}
  287. @endif
  288. @else
  289. -
  290. @endif
  291. </td>
  292. @if(hasRole('admin,manager'))
  293. <td class="text-end">
  294. <form action="{{ route('spare_part_reservations.issue', $reservation) }}" method="POST" class="d-inline">
  295. @csrf
  296. <button type="submit" class="btn btn-sm btn-success" title="Списать">
  297. <i class="bi bi-check-lg"></i>
  298. </button>
  299. </form>
  300. <form action="{{ route('spare_part_reservations.cancel', $reservation) }}" method="POST" class="d-inline">
  301. @csrf
  302. <button type="submit" class="btn btn-sm btn-outline-warning" title="Отменить резерв">
  303. <i class="bi bi-x-lg"></i>
  304. </button>
  305. </form>
  306. </td>
  307. @endif
  308. </tr>
  309. @endforeach
  310. </tbody>
  311. </table>
  312. @if(hasRole('admin,manager') && $reservations->where('status', 'active')->count() > 1)
  313. <div class="text-end mt-1">
  314. <form action="{{ route('spare_part_reservations.issue_all', $reclamation->id) }}" method="POST" class="d-inline">
  315. @csrf
  316. <button type="submit" class="btn btn-sm btn-success">Списать все</button>
  317. </form>
  318. <form action="{{ route('spare_part_reservations.cancel_all', $reclamation->id) }}" method="POST" class="d-inline">
  319. @csrf
  320. <button type="submit" class="btn btn-sm btn-outline-warning">Отменить все резервы</button>
  321. </form>
  322. </div>
  323. @endif
  324. </div>
  325. @endif
  326. {{-- Списанные --}}
  327. @if($reservations->where('status', 'issued')->count() > 0)
  328. <div class="mb-3">
  329. <strong class="text-success"><i class="bi bi-check-circle-fill"></i> Списано</strong>
  330. <table class="table table-sm table-success mt-1 mb-0">
  331. <thead>
  332. <tr>
  333. <th>Запчасть</th>
  334. <th class="text-center">Кол-во</th>
  335. <th class="text-center">С док.</th>
  336. <th>Партия</th>
  337. <th>Дата</th>
  338. </tr>
  339. </thead>
  340. <tbody>
  341. @foreach($reservations->where('status', 'issued') as $reservation)
  342. <tr>
  343. <td>
  344. @if($reservation->sparePart)
  345. @if(hasRole('admin,manager'))
  346. <a href="{{ route('spare_parts.show', $reservation->sparePart->id) }}">
  347. {{ $reservation->sparePart->article }}
  348. </a>
  349. @else
  350. {{ $reservation->sparePart->article }}
  351. @endif
  352. @else
  353. -
  354. @endif
  355. </td>
  356. <td class="text-center">{{ $reservation->reserved_qty }}</td>
  357. <td class="text-center">
  358. @if($reservation->with_documents)
  359. <i class="bi bi-check-circle text-success"></i>
  360. @else
  361. <i class="bi bi-x-circle text-muted"></i>
  362. @endif
  363. </td>
  364. <td>
  365. @if($reservation->sparePartOrder)
  366. @if(hasRole('admin,manager'))
  367. <a href="{{ route('spare_part_orders.show', $reservation->sparePartOrder->id) }}">
  368. #{{ $reservation->sparePartOrder->id }}
  369. </a>
  370. @else
  371. #{{ $reservation->sparePartOrder->id }}
  372. @endif
  373. @else
  374. -
  375. @endif
  376. </td>
  377. <td>{{ $reservation->updated_at->format('d.m.Y H:i') }}</td>
  378. </tr>
  379. @endforeach
  380. </tbody>
  381. </table>
  382. </div>
  383. @endif
  384. {{-- Открытые дефициты --}}
  385. @if($shortages->where('status', 'open')->count() > 0)
  386. <div class="mb-3">
  387. <strong class="text-danger"><i class="bi bi-exclamation-triangle-fill"></i> Дефициты (нехватка)</strong>
  388. <table class="table table-sm table-danger mt-1 mb-0">
  389. <thead>
  390. <tr>
  391. <th>Запчасть</th>
  392. <th class="text-center">Требуется</th>
  393. <th class="text-center">Зарезервировано</th>
  394. <th class="text-center">Не хватает</th>
  395. <th class="text-center">С док.</th>
  396. </tr>
  397. </thead>
  398. <tbody>
  399. @foreach($shortages->where('status', 'open') as $shortage)
  400. <tr>
  401. <td>
  402. @if($shortage->sparePart)
  403. @if(hasRole('admin,manager'))
  404. <a href="{{ route('spare_parts.show', $shortage->sparePart->id) }}">
  405. {{ $shortage->sparePart->article }}
  406. </a>
  407. @else
  408. {{ $shortage->sparePart->article }}
  409. @endif
  410. @else
  411. -
  412. @endif
  413. </td>
  414. <td class="text-center">{{ $shortage->required_qty }}</td>
  415. <td class="text-center">{{ $shortage->reserved_qty }}</td>
  416. <td class="text-center fw-bold">{{ $shortage->missing_qty }}</td>
  417. <td class="text-center">
  418. @if($shortage->with_documents)
  419. <i class="bi bi-check-circle text-success"></i>
  420. @else
  421. <i class="bi bi-x-circle text-muted"></i>
  422. @endif
  423. </td>
  424. </tr>
  425. @endforeach
  426. </tbody>
  427. </table>
  428. </div>
  429. @endif
  430. </div>
  431. @endif
  432. </div>
  433. <hr>
  434. <div class="documents">
  435. Документы
  436. @if(hasRole('admin,manager'))
  437. <button class="btn btn-sm text-success" onclick="$('#upl-documents').trigger('click');"><i
  438. class="bi bi-plus-circle-fill"></i> Загрузить
  439. </button>
  440. <form action="{{ route('reclamations.upload-document', $reclamation) }}"
  441. enctype="multipart/form-data" method="post" class="visually-hidden">
  442. @csrf
  443. <input required type="file" id="upl-documents" onchange="$(this).parent().submit()" multiple
  444. name="document[]" class="form-control form-control-sm">
  445. </form>
  446. @endif
  447. <div class="row my-2 g-1">
  448. @foreach($reclamation->documents as $document)
  449. <div class="col-12">
  450. <a href="{{ $document->link }}" target="_blank">
  451. {{ $document->original_name }}
  452. </a>
  453. @if(hasRole('admin'))
  454. <i class="bi bi-x-circle-fill fs-6 text-danger cursor-pointer ms-2"
  455. onclick="customConfirm('Удалить?', function () { $('#document-{{ $document->id }}').submit(); }, 'Подтверждение удаления')"
  456. title="Удалить"></i>
  457. @endif
  458. <form action="{{ route('reclamations.delete-document', [$reclamation, $document]) }}"
  459. method="POST" id="document-{{ $document->id }}" class="visually-hidden">
  460. @csrf
  461. @method('DELETE')
  462. </form>
  463. </div>
  464. @endforeach
  465. </div>
  466. </div>
  467. <hr>
  468. <div class="acts">
  469. Акты
  470. @if(hasRole('admin,manager'))
  471. <button class="btn btn-sm text-success" onclick="$('#upl-acts').trigger('click');"><i
  472. class="bi bi-plus-circle-fill"></i> Загрузить
  473. </button>
  474. <form action="{{ route('reclamations.upload-act', $reclamation) }}" enctype="multipart/form-data"
  475. method="post" class="visually-hidden">
  476. @csrf
  477. <input required type="file" id="upl-acts" onchange="$(this).parent().submit()" multiple
  478. name="acts[]" class="form-control form-control-sm">
  479. </form>
  480. @endif
  481. <div class="row my-2 g-1">
  482. @foreach($reclamation->acts as $act)
  483. <div class="col-12">
  484. <a href="{{ $act->link }}" target="_blank">
  485. {{ $act->original_name }}
  486. </a>
  487. @if(hasRole('admin'))
  488. <i class="bi bi-x-circle-fill fs-6 text-danger cursor-pointer ms-2"
  489. onclick="customConfirm('Удалить?', function () { $('#act-{{ $act->id }}').submit(); }, 'Подтверждение удаления')"
  490. title="Удалить"></i>
  491. <form action="{{ route('reclamations.delete-act', [$reclamation, $act]) }}"
  492. method="POST"
  493. id="act-{{ $act->id }}" class="visually-hidden">
  494. @csrf
  495. @method('DELETE')
  496. </form>
  497. @endif
  498. </div>
  499. @endforeach
  500. </div>
  501. </div>
  502. <hr>
  503. <div class="photo_before">
  504. <a href="#photos_before" data-bs-toggle="collapse">Фотографии проблемы
  505. ({{ $reclamation->photos_before->count() }})</a>
  506. <button class="btn btn-sm text-success" onclick="$('#upl-photo-before').trigger('click');"><i
  507. class="bi bi-plus-circle-fill"></i> Загрузить
  508. </button>
  509. @if($reclamation->photos_before->count())
  510. <a href="{{ route('reclamation.generate-photos-before-pack', $reclamation) }}"
  511. class="btn btn-sm text-primary"><i
  512. class="bi bi-download"></i> Скачать все
  513. </a>
  514. @endif
  515. <form action="{{ route('reclamations.upload-photo-before', $reclamation) }}"
  516. enctype="multipart/form-data" method="post" class="visually-hidden">
  517. @csrf
  518. <input required type="file" id="upl-photo-before" onchange="$(this).parent().submit()" multiple
  519. name="photo[]" class="form-control form-control-sm" accept=".jpg,.jpeg,.png">
  520. </form>
  521. <div class="row my-2 g-1 collapse" id="photos_before">
  522. @foreach($reclamation->photos_before as $photo)
  523. <div class="col-4">
  524. <a href="{{ $photo->link }}"
  525. data-toggle="lightbox" data-gallery="photos-before" data-size="fullscreen">
  526. <img class="img-thumbnail" src="{{ $photo->link }}" alt="">
  527. </a>
  528. @if(hasRole('admin'))
  529. <i class="bi bi-x-circle-fill fs-6 text-danger cursor-pointer rm-but"
  530. onclick="customConfirm('Удалить фото?', function () { $('#photo-{{ $photo->id }}').submit(); }, 'Подтверждение удаления')"
  531. title="Удалить"></i>
  532. @endif
  533. <form action="{{ route('reclamations.delete-photo-before', [$reclamation, $photo]) }}"
  534. method="POST" id="photo-{{ $photo->id }}" class="visually-hidden">
  535. @csrf
  536. @method('DELETE')
  537. </form>
  538. </div>
  539. @endforeach
  540. </div>
  541. </div>
  542. <hr>
  543. <div class="photo_after">
  544. <a href="#photos_after" data-bs-toggle="collapse">Фотографии после устранения
  545. ({{ $reclamation->photos_after->count() }})</a>
  546. <button class="btn btn-sm text-success" onclick="$('#upl-photo-after').trigger('click');"><i
  547. class="bi bi-plus-circle-fill"></i> Загрузить
  548. </button>
  549. @if($reclamation->photos_after->count())
  550. <a href="{{ route('reclamation.generate-photos-after-pack', $reclamation) }}"
  551. class="btn btn-sm text-primary"><i
  552. class="bi bi-download"></i> Скачать все
  553. </a>
  554. @endif
  555. <form action="{{ route('reclamations.upload-photo-after', $reclamation) }}"
  556. enctype="multipart/form-data" method="post" class="visually-hidden">
  557. @csrf
  558. <input required type="file" id="upl-photo-after" onchange="$(this).parent().submit()" multiple
  559. name="photo[]" class="form-control form-control-sm" accept=".jpg,.jpeg,.png">
  560. </form>
  561. <div class="row my-2 g-1 collapse" id="photos_after">
  562. @foreach($reclamation->photos_after as $photo)
  563. <div class="col-4">
  564. <a href="{{ $photo->link }}"
  565. data-toggle="lightbox" data-gallery="photos-after" data-size="fullscreen">
  566. <img class="img-thumbnail" src="{{ $photo->link }}" alt="">
  567. </a>
  568. @if(hasRole('admin'))
  569. <i class="bi bi-x-circle-fill fs-6 text-danger cursor-pointer rm-but"
  570. onclick="customConfirm('Удалить фото?', function () { $('#photo-{{ $photo->id }}').submit(); }, 'Подтверждение удаления')"
  571. title="Удалить"></i>
  572. @endif
  573. <form action="{{ route('reclamations.delete-photo-after', [$reclamation, $photo]) }}"
  574. method="POST" id="photo-{{ $photo->id }}" class="visually-hidden">
  575. @csrf
  576. @method('DELETE')
  577. </form>
  578. </div>
  579. @endforeach
  580. </div>
  581. </div>
  582. </div>
  583. </div>
  584. </div>
  585. @if(hasRole('admin'))
  586. <!-- Модальное окно графика -->
  587. <div class="modal fade" id="copySchedule" tabindex="-1" aria-labelledby="exampleModalLabel" aria-hidden="true">
  588. <div class="modal-dialog modal-fullscreen-sm-down modal-lg">
  589. <div class="modal-content">
  590. <div class="modal-header">
  591. <h1 class="modal-title fs-5" id="addModalLabel">Перенести в график монтажей</h1>
  592. <button type="button" class="btn-close" data-bs-dismiss="modal" aria-label="Закрыть"></button>
  593. </div>
  594. <div class="modal-body">
  595. <form action="{{ route('schedule.create-from-reclamation') }}" method="post" id="scheduleCreateForm">
  596. @csrf
  597. <div>
  598. <input type="hidden" name="reclamation_id" value="{{ $reclamation->id }}">
  599. {{-- <textarea name="comment" placeholder="Комментарий для графика" class="form-control mb-3"></textarea>--}}
  600. <input type="checkbox" checked="checked" id="sendNotifications" name="send_notifications" value="1" class="form-check-inline">
  601. <label for="sendNotifications" class="form-check-label mb-2">Уведомить менеджера и бригадира</label><br>
  602. <input type="checkbox" id="deleteOldRecords" name="delete_old_records" class="form-check-inline">
  603. <label for="deleteOldRecords" class="form-check-label mb-2">Удалить старые записи в графике для этой рекламации?</label><br>
  604. <button type="submit" class="btn btn-primary btn-sm">Обновить график</button>
  605. </div>
  606. </form>
  607. </div>
  608. </div>
  609. </div>
  610. </div>
  611. @endif
  612. @endsection
  613. @push('scripts')
  614. <script type="module">
  615. @if(hasRole('admin'))
  616. $('#createScheduleButton').on('click', function () {
  617. let myModalSchedule = new bootstrap.Modal(document.getElementById("copySchedule"), {});
  618. myModalSchedule.show();
  619. });
  620. @endif
  621. let sparePartIndex = {{ max($reclamation->spareParts->count(), 1) }};
  622. const searchUrl = '{{ route('spare_parts.search') }}';
  623. // Инициализация автокомплита для поля
  624. function initSparePartAutocomplete($row) {
  625. const $input = $row.find('.spare-part-search');
  626. const $dropdown = $row.find('.spare-part-dropdown');
  627. const $hiddenId = $row.find('.spare-part-id');
  628. let currentFocus = -1;
  629. let searchTimeout;
  630. $input.on('input', function() {
  631. const query = $(this).val().trim();
  632. clearTimeout(searchTimeout);
  633. // Сбрасываем ID при изменении текста
  634. $hiddenId.val('');
  635. if (query.length >= 1) {
  636. searchTimeout = setTimeout(function() {
  637. $.get(searchUrl, { query: query }).done(function(data) {
  638. showDropdown(data, query);
  639. });
  640. }, 200);
  641. } else {
  642. $dropdown.hide();
  643. }
  644. });
  645. function showDropdown(items, query) {
  646. $dropdown.empty();
  647. currentFocus = -1;
  648. if (items.length === 0) {
  649. $dropdown.hide();
  650. return;
  651. }
  652. items.forEach(function(item) {
  653. const $item = $('<div class="sp-item"></div>');
  654. const highlightedArticle = highlightMatch(item.article, query);
  655. const highlightedUsed = item.used_in_maf ? highlightMatch(item.used_in_maf, query) : '';
  656. $item.html('<span class="sp-article">' + highlightedArticle + '</span>' +
  657. (item.used_in_maf ? ' <span class="sp-used">(' + highlightedUsed + ')</span>' : ''));
  658. $item.data('id', item.id);
  659. $item.data('article', item.article);
  660. $item.data('used', item.used_in_maf || '');
  661. $item.on('click', function() {
  662. selectItem($(this));
  663. });
  664. $dropdown.append($item);
  665. });
  666. $dropdown.show();
  667. }
  668. function highlightMatch(text, query) {
  669. if (!text || !query) return text || '';
  670. const regex = new RegExp('(' + escapeRegex(query) + ')', 'gi');
  671. return text.replace(regex, '<strong>$1</strong>');
  672. }
  673. function escapeRegex(str) {
  674. return str.replace(/[.*+?^${}()|[\]\\]/g, '\\$&');
  675. }
  676. function selectItem($item) {
  677. const article = $item.data('article');
  678. const used = $item.data('used');
  679. const displayText = article + (used ? ' (' + used + ')' : '');
  680. $input.val(displayText);
  681. $hiddenId.val($item.data('id'));
  682. $dropdown.hide();
  683. }
  684. // Навигация клавиатурой
  685. $input.on('keydown', function(e) {
  686. const $items = $dropdown.find('.sp-item');
  687. if (e.keyCode === 40) { // Стрелка вниз
  688. e.preventDefault();
  689. currentFocus++;
  690. if (currentFocus >= $items.length) currentFocus = 0;
  691. setActive($items);
  692. } else if (e.keyCode === 38) { // Стрелка вверх
  693. e.preventDefault();
  694. currentFocus--;
  695. if (currentFocus < 0) currentFocus = $items.length - 1;
  696. setActive($items);
  697. } else if (e.keyCode === 13) { // Enter
  698. e.preventDefault();
  699. if (currentFocus > -1 && $items.length > 0) {
  700. selectItem($items.eq(currentFocus));
  701. }
  702. } else if (e.keyCode === 27) { // Escape
  703. $dropdown.hide();
  704. }
  705. });
  706. function setActive($items) {
  707. $items.removeClass('active');
  708. if (currentFocus >= 0 && currentFocus < $items.length) {
  709. $items.eq(currentFocus).addClass('active');
  710. }
  711. }
  712. // Закрытие при клике вне
  713. $(document).on('click', function(e) {
  714. if (!$(e.target).closest($row).length) {
  715. $dropdown.hide();
  716. }
  717. });
  718. }
  719. // Инициализация для существующих строк
  720. $('.spare-part-row').not('.spare-part-template').each(function() {
  721. initSparePartAutocomplete($(this));
  722. });
  723. // Добавление новой строки запчасти
  724. $('#add-spare-part-row').on('click', function() {
  725. let template = $('.spare-part-template').first();
  726. let newRow = template.clone();
  727. newRow.removeClass('spare-part-template d-none');
  728. newRow.attr('data-index', sparePartIndex);
  729. // Заменяем __INDEX__ на реальный индекс во всех name атрибутах
  730. newRow.find('[name]').each(function() {
  731. let name = $(this).attr('name');
  732. $(this).attr('name', name.replace('__INDEX__', sparePartIndex));
  733. $(this).prop('disabled', false);
  734. });
  735. // Сбрасываем значения и разблокируем поле поиска
  736. newRow.find('.spare-part-search').val('').prop('disabled', false);
  737. newRow.find('.spare-part-id').val('');
  738. newRow.find('input[type="number"]').val('');
  739. newRow.find('input[type="checkbox"]').prop('checked', false);
  740. $('.spare-parts-rows').append(newRow);
  741. // Инициализируем автокомплит для новой строки
  742. initSparePartAutocomplete(newRow);
  743. sparePartIndex++;
  744. });
  745. // Удаление строки
  746. $(document).on('click', '.remove-spare-part-row', function() {
  747. $(this).closest('.spare-part-row').remove();
  748. });
  749. </script>
  750. @endpush