show.blade.php 29 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515
  1. @php
  2. use App\Models\Order;
  3. @endphp
  4. @extends('layouts.app')
  5. @section('content')
  6. <div class="px-3">
  7. <div class="row mb-2">
  8. <div class="col-md-6">
  9. <h3>
  10. Площадка {{ $order->object_address }}
  11. <div class="badge text-bg-{{ Order::STATUS_COLOR[$order->order_status_id] }}">{{ $order->orderStatus->name }}</div>
  12. </h3>
  13. </div>
  14. <div class="col-md-6 text-end">
  15. @if(hasRole('admin,manager'))
  16. <a href="{{ route('order.edit', ['order' => $order, 'previous_url' => $previous_url]) }}"
  17. class="btn btn-sm mb-1 btn-primary">Редактировать</a>
  18. <a href="#" class="btn btn-sm btn-primary mb-1" onclick="$('#export-order').submit()">Экспорт МАФ</a>
  19. <form class="d-none" method="post" action="{{ route('order.export-one', $order) }}" id="export-order">
  20. @csrf
  21. </form>
  22. @endif
  23. @if(hasRole('admin') && ($order->order_status_id == Order::STATUS_NEW))
  24. <a href="#" onclick="if(confirm('Удалить площадку?')) $('form#destroy').submit();"
  25. class="btn btn-sm mb-1 btn-danger">Удалить</a>
  26. <form action="{{ route('order.destroy', $order) }}" method="post" class="d-none" id="destroy">
  27. @csrf
  28. @method('DELETE')
  29. </form>
  30. @endif
  31. @if(in_array($order->order_status_id, [Order::STATUS_READY_TO_MOUNT, Order::STATUS_IN_MOUNT]) && $order->isAllMafConnected() && hasRole('admin,manager'))
  32. <a href="{{ route('order.generate-installation-pack', $order) }}"
  33. class="btn btn-sm mb-1 btn-primary">Документы для монтажа</a>
  34. @if(hasRole('admin'))
  35. <button @disabled(is_null($order->brigadier_id)) class="btn btn-primary btn-sm mb-1"
  36. id="createScheduleButton">Перенести в график
  37. </button>
  38. @endif
  39. @endif
  40. @if($order->canCreateHandover() && hasRole('admin,manager'))
  41. <a href="{{ route('order.generate-handover-pack', $order) }}" class="btn btn-sm mb-1 btn-primary">Документы
  42. для сдачи</a>
  43. @endif
  44. <a href="{{ $previous_url ?? route('order.index', session('gp_orders')) }}"
  45. class="btn btn-sm mb-1 btn-outline-secondary">Назад</a>
  46. </div>
  47. </div>
  48. <div class="row">
  49. <div class="col-xl-3 border-end">
  50. <h4>Общая информация об объекте</h4>
  51. <div>ID площадки: {{ $order->id }}</div>
  52. @include('partials.input', ['name' => 'name', 'title' => 'Название', 'value' => $order->name ?? old('name'), 'required' => true, 'disabled' => !hasRole('admin'), 'classes' => ['update-once']])
  53. @include('partials.input', ['name' => 'object_address', 'title' => 'Адрес объекта', 'value' => $order->object_address ?? old('object_address'), 'required' => true, 'disabled' => !hasRole('admin'), 'classes' => ['update-once']])
  54. @include('partials.select', ['name' => 'object_type_id', 'title' => 'Тип объекта', 'options' => $objectTypes, 'value' => $order->object_type_id ?? old('object_type_id'), 'required' => true, 'first_empty' => true, 'disabled' => !hasRole('admin'), 'classes' => ['update-once']])
  55. @include('partials.select', ['name' => 'order_status_id', 'title' => 'Статус', 'options' => $orderStatuses, 'value' => $order->order_status_id ?? old('order_status_id'), 'required' => true, 'classes' => ['update-once']])
  56. @include('partials.textarea', ['name' => 'comment', 'title' => 'Комментарий', 'value' => $order->comment ?? old('comment'), 'classes' => ['update-once']])
  57. @include('partials.input', ['name' => 'installation_date', 'title' => 'Дата выхода на монтаж', 'type' => 'date', 'value' => $order->installation_date ?? old('installation_date'), 'disabled' => !hasRole('admin'), 'classes' => ['update-once']])
  58. @include('partials.input', ['name' => 'install_days', 'title' => 'Дней на монтаж', 'type' => 'number', 'min' => 1, 'value' => $order->install_days ?? old('install_days'), 'disabled' => !hasRole('admin'), 'classes' => ['update-once']])
  59. @include('partials.input', ['name' => 'ready_date', 'title' => 'Дата готовности площадки', 'type' => 'date', 'value' => $order->ready_date ?? old('ready_date'), 'disabled' => !hasRole('admin'), 'classes' => ['update-once']])
  60. @include('partials.select', ['name' => 'brigadier_id', 'title' => 'Бригадир', 'options' => $brigadiers, 'value' => $order->brigadier_id ?? old('brigadier_id'), 'first_empty' => true, 'disabled' => !hasRole('admin'), 'classes' => ['update-once']])
  61. @include('partials.select', ['name' => 'user_id', 'title' => 'Менеджер', 'options' => $users, 'value' => $order->user_id ?? old('user_id') ?? auth()->user()->id, 'disabled' => !hasRole('admin'), 'classes' => ['update-once']])
  62. @include('partials.input', ['name' => 'tg_group_name', 'title' => 'Название группы в ТГ', 'value' => $order->tg_group_name ?? old('tg_group_name'), 'classes' => ['update-once']])
  63. @include('partials.input', ['name' => 'tg_group_link', 'title' => 'https://t.me/', 'value' => $order->tg_group_link ?? old('tg_group_link'), 'classes' => ['update-once'], 'button' => (!empty($order->tg_group_link)) ? 'tg' : null, 'buttonText' => '<i class="bi bi-telegram"></i>'])
  64. <hr>
  65. <div class="reclamations">
  66. Рекламации
  67. @foreach($order->reclamations as $reclamation)
  68. <div>
  69. <a href="{{ route('reclamations.show', ['reclamation' => $reclamation, 'previous_url' => url()->current()]) }}">
  70. Рекламация № {{ $reclamation->id }} от {{ $reclamation->create_date }}
  71. </a>
  72. </div>
  73. @endforeach
  74. </div>
  75. @if(hasRole('admin,manager'))
  76. <hr>
  77. <div class="documents">
  78. Документы
  79. <button class="btn btn-sm text-success" onclick="$('#upl-documents').trigger('click');"><i
  80. class="bi bi-plus-circle-fill"></i> Загрузить
  81. </button>
  82. <form action="{{ route('order.upload-document', $order) }}" enctype="multipart/form-data"
  83. method="post" class="visually-hidden">
  84. @csrf
  85. <input required type="file" id="upl-documents" onchange="$(this).parent().submit()" multiple
  86. name="document[]" class="form-control form-control-sm">
  87. </form>
  88. <div class="row my-2 g-1">
  89. @foreach($order->documents as $document)
  90. <div class="col-12">
  91. <a href="{{ $document->link }}" target="_blank">
  92. {{ $document->original_name }}
  93. </a>
  94. @if(hasRole('admin'))
  95. <i class="bi bi-x-circle-fill fs-6 text-danger cursor-pointer ms-2"
  96. onclick="if(confirm('Удалить?')) $('#document-{{ $document->id }}').submit()"
  97. title="Удалить"></i>
  98. @endif
  99. <form action="{{ route('order.delete-document', [$order, $document]) }}" method="POST"
  100. id="document-{{ $document->id }}" class="visually-hidden">
  101. @csrf
  102. @method('DELETE')
  103. </form>
  104. </div>
  105. @endforeach
  106. </div>
  107. </div>
  108. <hr>
  109. <div class="statements">
  110. Ведомости
  111. <button class="btn btn-sm text-success" onclick="$('#upl-statements').trigger('click');"><i
  112. class="bi bi-plus-circle-fill"></i> Загрузить
  113. </button>
  114. <form action="{{ route('order.upload-statement', $order) }}" enctype="multipart/form-data"
  115. method="post" class="visually-hidden">
  116. @csrf
  117. <input required type="file" id="upl-statements" onchange="$(this).parent().submit()" multiple
  118. name="statement[]" class="form-control form-control-sm">
  119. </form>
  120. <div class="row my-2 g-1">
  121. @foreach($order->statements as $statement)
  122. <div class="col-12">
  123. <a href="{{ $statement->link }}" target="_blank">
  124. {{ $statement->original_name }}
  125. </a>
  126. @if(hasRole('admin'))
  127. <i class="bi bi-x-circle-fill fs-6 text-danger cursor-pointer ms-2"
  128. onclick="if(confirm('Удалить?')) $('#statement-{{ $statement->id }}').submit()"
  129. title="Удалить"></i>
  130. @endif
  131. <form action="{{ route('order.delete-statement', [$order, $statement]) }}" method="POST"
  132. id="statement-{{ $statement->id }}" class="visually-hidden">
  133. @csrf
  134. @method('DELETE')
  135. </form>
  136. </div>
  137. @endforeach
  138. </div>
  139. </div>
  140. @endif
  141. <hr>
  142. <div class="photo">
  143. <a href="#photos" data-bs-toggle="collapse">Фотографии ({{ $order->photos->count() }})</a>
  144. <button class="btn btn-sm text-success" onclick="$('#upl-photo').trigger('click');"><i
  145. class="bi bi-plus-circle-fill"></i> Загрузить
  146. </button>
  147. @if($order->photos->count())
  148. <a href="{{ route('order.generate-photos-pack', $order) }}" class="btn btn-sm text-primary"><i
  149. class="bi bi-download"></i> Скачать все
  150. </a>
  151. @endif
  152. <form action="{{ route('order.upload-photo', $order) }}" enctype="multipart/form-data" method="post"
  153. class="visually-hidden">
  154. @csrf
  155. <input required type="file" id="upl-photo" onchange="$(this).parent().submit()" multiple
  156. name="photo[]" class="form-control form-control-sm" accept=".jpg,.jpeg,.png">
  157. </form>
  158. <div class="row my-2 g-1 collapse" id="photos">
  159. @foreach($order->photos as $photo)
  160. <div class="col-4">
  161. <a href="{{ $photo->link }}"
  162. data-toggle="lightbox" data-gallery="photos" data-size="fullscreen">
  163. <img class="img-thumbnail" src="{{ $photo->link }}" alt="">
  164. </a>
  165. @if(hasRole('admin'))
  166. <i class="bi bi-x-circle-fill fs-6 text-danger cursor-pointer rm-but"
  167. onclick="if(confirm('Удалить фото?')) $('#photo-{{ $photo->id }}').submit()"
  168. title="Удалить"></i>
  169. @endif
  170. <form action="{{ route('order.delete-photo', [$order, $photo]) }}" method="POST"
  171. id="photo-{{ $photo->id }}" class="visually-hidden">
  172. @csrf
  173. @method('DELETE')
  174. </form>
  175. </div>
  176. @endforeach
  177. </div>
  178. </div>
  179. </div>
  180. <div class="col-xl-9">
  181. <h4>МАФы заказа</h4>
  182. <div id="selected_maf">
  183. @if(isset($order) && $order->products_sku)
  184. <div class="col-12 overflow-x-scroll mb-3">
  185. <table class="table">
  186. <thead>
  187. <tr>
  188. <th><input type="checkbox" class="form-check" id="check-all-maf"></th>
  189. <th>Картинка</th>
  190. <th>МАФ</th>
  191. <th>Тип</th>
  192. <th>Статус</th>
  193. <th>Номер заказа МАФ</th>
  194. <th>RFID</th>
  195. <th>Заводской номер</th>
  196. <th>Дата производства</th>
  197. <th>Склад</th>
  198. <th>Паспорт</th>
  199. </tr>
  200. </thead>
  201. <tbody>
  202. @php
  203. $needs = $order->getNeeds();
  204. @endphp
  205. @foreach($order->products_sku as $p)
  206. <tr>
  207. <td>
  208. <input type="checkbox" class="form-check check-maf"
  209. data-maf-id="{{ $p->id }}">
  210. </td>
  211. <td>
  212. @if($p->product->image)
  213. <a href="{{ $p->product->image }}" data-toggle="lightbox"
  214. data-gallery="maf" data-size="fullscreen">
  215. <img src="{{ $p->product->image }}" alt=""
  216. class="img-thumbnail maf-img">
  217. </a>
  218. @endif
  219. </td>
  220. <td>
  221. @if(hasRole('admin'))
  222. <a href="{{ route('product_sku.show', ['product_sku' =>$p, 'previous_url' => url()->current()]) }}">
  223. {!! $p->product->article !!}
  224. </a>
  225. <br>
  226. <a class="small"
  227. href="{{ route('catalog.show', ['product' => $p->product, 'previous_url' => request()->fullUrl()]) }}">каталог</a>
  228. @else
  229. {!! $p->product->article !!}
  230. @endif
  231. </td>
  232. <td>{!! $p->product->nomenclature_number !!}</td>
  233. <td>{{ $p->status }}</td>
  234. <td>
  235. @if($p->maf_order_id && hasRole('admin'))
  236. <a href="{{ route('maf_order.show', $p->maf_order) }}">{{ $p->maf_order->order_number }}</a>
  237. @else
  238. {{ $p->maf_order?->order_number }}
  239. @endif
  240. </td>
  241. <td>{{ $p->rfid }}</td>
  242. <td>{{ $p->factory_number }}</td>
  243. <td>{{ $p->manufacture_date }}</td>
  244. <td class="text-center">
  245. @if($p->maf_order?->order_number)
  246. <i class="bi bi-check-all text-success fw-bold"></i>
  247. @else
  248. @if(isset($needs[$p->product_id]) && ($needs[$p->product_id]['sku']-- > 0))
  249. <i class="bi bi-check text-success fw-bold"></i>
  250. @else
  251. <i class="bi bi-x text-danger fw-bold"></i>
  252. @endif
  253. @endif
  254. </td>
  255. <td class="text-center">
  256. @if($p->passport)
  257. <i class="bi bi-check text-success fw-bold"></i>
  258. @else
  259. <i class="bi bi-x text-danger fw-bold"></i>
  260. @endif
  261. </td>
  262. </tr>
  263. @endforeach
  264. </tbody>
  265. </table>
  266. </div>
  267. <div>
  268. @if(hasRole('admin,manager'))
  269. <a href="{{ route('order.get-maf', $order) }}"
  270. class="btn btn-primary btn-sm mb-1 @disabled($order->ready_to_mount == 'Нет' )">Привязать
  271. все МАФы</a>
  272. <br class="d-md-none">
  273. <a href="{{ route('order.revert-maf', $order) }}" class="btn btn-primary btn-sm mb-1">Отвязать
  274. все МАФы</a>
  275. <br class="d-md-none">
  276. <button class="btn btn-primary btn-sm mb-1" data-bs-toggle="modal"
  277. data-bs-target="#moveModal">Перенести МАФы
  278. </button>
  279. <br class="d-md-none">
  280. <button class="btn btn-sm mb-1 btn-warning" id="create-reclamation-button">Создать
  281. рекламацию
  282. </button>
  283. <form action="{{ route('reclamations.create', $order) }}" method="post"
  284. class="visually-hidden" id="create-reclamation-form">
  285. @csrf
  286. </form>
  287. <a href="#" class="btn btn-primary btn-sm mb-1" id="ttnBtn">ТН</a>
  288. @endif
  289. </div>
  290. @endif
  291. </div>
  292. </div>
  293. </div>
  294. </div>
  295. <!-- Модальное окно графика -->
  296. <div class="modal fade" id="copySchedule" tabindex="-1" aria-labelledby="exampleModalLabel" aria-hidden="true">
  297. <div class="modal-dialog modal-fullscreen-sm-down modal-lg">
  298. <div class="modal-content">
  299. <div class="modal-header">
  300. <h1 class="modal-title fs-5" id="addModalLabel">Перенести в график монтажей</h1>
  301. <button type="button" class="btn-close" data-bs-dismiss="modal" aria-label="Закрыть"></button>
  302. </div>
  303. <div class="modal-body">
  304. <form action="{{ route('schedule.create-from-order') }}" method="post" id="scheduleCreateForm">
  305. @csrf
  306. <div>
  307. <input type="hidden" name="order_id" value="{{ $order->id }}">
  308. <textarea name="comment" placeholder="Комментарий для графика" class="form-control mb-3"></textarea>
  309. <input type="checkbox" checked="checked" id="sendNotifications" name="send_notifications" class="form-check-inline">
  310. <label for="sendNotifications" class="form-check-label mb-2">Уведомить менеджера и бригадира</label><br>
  311. <input type="checkbox" id="deleteOldRecords" name="delete_old_records" class="form-check-inline">
  312. <label for="deleteOldRecords" class="form-check-label mb-2">Удалить старые записи в графике для этой площадки?</label><br>
  313. <button type="submit" class="btn btn-primary btn-sm">Обновить график</button>
  314. </div>
  315. </form>
  316. </div>
  317. </div>
  318. </div>
  319. </div>
  320. <!-- Модальное окно ТН -->
  321. <div class="modal fade" id="createTtnModal" tabindex="-1" aria-labelledby="exampleModalLabel" aria-hidden="true">
  322. <div class="modal-dialog modal-fullscreen-sm-down modal-lg">
  323. <div class="modal-content">
  324. <div class="modal-header">
  325. <h1 class="modal-title fs-5" id="addModalLabel">Введите данные для ТН</h1>
  326. <button type="button" class="btn-close" data-bs-dismiss="modal" aria-label="Закрыть"></button>
  327. </div>
  328. <div class="modal-body">
  329. <form action="{{ route('order.create-ttn') }}" method="post" id="ttnForm">
  330. @csrf
  331. <div>
  332. <input type="text" class="form-control mb-2" name="order_number" placeholder="Номер заказа">
  333. <input type="date" class="form-control mb-2" name="order_date" placeholder="Дата заказа" value="{{ date('Y-m-d') }}">
  334. <input type="number" class="form-control mb-2" name="order_sum" placeholder="Сумма заказа" value="0">
  335. <button href="#" class="btn btn-primary" id="createTtn">Создать ТН</button>
  336. </div>
  337. </form>
  338. </div>
  339. </div>
  340. </div>
  341. </div>
  342. <!-- Модальное окно переноса -->
  343. <div class="modal fade" id="moveModal" tabindex="-1" aria-labelledby="exampleModalLabel" aria-hidden="true">
  344. <div class="modal-dialog modal-fullscreen-sm-down modal-lg">
  345. <div class="modal-content">
  346. <div class="modal-header">
  347. <h1 class="modal-title fs-5" id="addModalLabel">Выбрать площадку, куда переносим</h1>
  348. <button type="button" class="btn-close" data-bs-dismiss="modal" aria-label="Закрыть"></button>
  349. </div>
  350. <div class="modal-body">
  351. <form action="{{ route('order.move-maf') }}" method="post">
  352. @csrf
  353. <div id="select_maf_form">
  354. <input type="text" class="form-control mb-2" placeholder="Поиск площадки" id="search_order">
  355. <select id="select_order" name="new_order_id" class="form-select mb-3" size="20" multiple
  356. required></select>
  357. <a href="#" class="btn btn-primary" id="moveMaf">Перенести</a>
  358. </div>
  359. </form>
  360. </div>
  361. </div>
  362. </div>
  363. </div>
  364. @if($errors->any())
  365. @dump($errors)
  366. @endif
  367. @endsection
  368. @push('scripts')
  369. <script type="module">
  370. $('#tg').on('click', function () {
  371. window.open('https://t.me/{{ $order->tg_group_link }}', '_blank');
  372. });
  373. // select order
  374. $('#search_order').on('keyup', function () {
  375. // search products on backend
  376. $.get('{{ route('order.search') }}?s=' + $(this).val(),
  377. function (data) {
  378. $('#select_order').children().remove()
  379. $.each(data, function (id, name) {
  380. $('#select_order').append('<option value=\'' + id + '\'>' + name + '</option>');
  381. });
  382. }
  383. );
  384. }).trigger('keyup');
  385. $('#check-all-maf').on('change', function () {
  386. $('input:checkbox.check-maf').not(this).prop('checked', this.checked);
  387. });
  388. // move maf
  389. $('#moveMaf').on('click', function () {
  390. let ids = Array();
  391. $('.check-maf').each(function () {
  392. if ($(this).prop('checked')) {
  393. ids.push($(this).attr('data-maf-id'));
  394. }
  395. });
  396. $.post('{{ route('order.move-maf') }}',
  397. {
  398. '_token': $('meta[name=csrf-token]').attr('content'),
  399. ids: JSON.stringify(ids),
  400. 'new_order_id': $('#select_order').find(":selected").val()
  401. },
  402. function () {
  403. location.reload();
  404. }
  405. );
  406. });
  407. $('#create-reclamation-button').on('click', function () {
  408. let ids = Array();
  409. $('.check-maf').each(function () {
  410. if ($(this).prop('checked')) {
  411. ids.push($(this).attr('data-maf-id'));
  412. $('#create-reclamation-form').append('<input type="hidden" name="skus[]" value="' + $(this).attr('data-maf-id') + '">');
  413. }
  414. });
  415. if (ids.length) {
  416. $('#create-reclamation-form').submit();
  417. } else {
  418. customAlert('Нужно выбрать МАФ для рекламации!');
  419. }
  420. });
  421. $('#createScheduleButton').on('click', function () {
  422. let ids = Array();
  423. $('.check-maf').each(function () {
  424. if ($(this).prop('checked')) {
  425. ids.push($(this).attr('data-maf-id'));
  426. $('#scheduleCreateForm').append('<input type="hidden" name="skus[]" value="' + $(this).attr('data-maf-id') + '">');
  427. }
  428. });
  429. let myModalSchedule = new bootstrap.Modal(document.getElementById("copySchedule"), {});
  430. myModalSchedule.show();
  431. });
  432. $('#ttnBtn').on('click', function () {
  433. if ($('input.check-maf:checkbox:checked').length > 0) {
  434. let myModalTtn = new bootstrap.Modal(document.getElementById("createTtnModal"), {});
  435. myModalTtn.show();
  436. } else {
  437. customAlert('Нужно выбрать МАФ для ТН!');
  438. }
  439. });
  440. $('#createTtn').on('click', function () {
  441. let ids = Array();
  442. $('.check-maf').each(function () {
  443. if ($(this).prop('checked')) {
  444. ids.push($(this).attr('data-maf-id'));
  445. $('#ttnForm').append('<input type="hidden" name="skus[]" value="' + $(this).attr('data-maf-id') + '">');
  446. }
  447. });
  448. if (ids.length) {
  449. $('#ttnForm').submit();
  450. } else {
  451. customAlert('Нужно выбрать МАФ для ТН!');
  452. }
  453. });
  454. $('.update-once').on('change', function () {
  455. let v = $(this).val();
  456. let n = $(this).attr('name');
  457. $.post(
  458. '{{ route('order.update', $order->id) }}',
  459. {
  460. '_token': '{{ csrf_token() }}',
  461. id: '{{ $order->id }}',
  462. [n]: v
  463. },
  464. function () {
  465. $('.alerts').append(
  466. '<div class="main-alert alert alert-success" role="alert">Площадка обновлена!</div>'
  467. );
  468. setTimeout(function () {
  469. $('.main-alert').fadeTo(2000, 500).slideUp(500, function () {
  470. $(".main-alert").slideUp(500);
  471. })
  472. }, 3000);
  473. }
  474. );
  475. });
  476. </script>
  477. @endpush