show.blade.php 29 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507
  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. <a href="{{ route('product_sku.show', ['product_sku' =>$p, 'previous_url' => url()->current()]) }}">
  222. {!! $p->product->article !!}
  223. </a>
  224. <br>
  225. <a class="small" href="{{ route('catalog.show', ['product' => $p->product, 'previous_url' => request()->fullUrl()]) }}">каталог</a>
  226. </td>
  227. <td>{!! $p->product->nomenclature_number !!}</td>
  228. <td>{{ $p->status }}</td>
  229. <td>
  230. <a href="{{ route('maf_order.show', $p->maf_order) }}">{{ $p->maf_order->order_number }}</a>
  231. </td>
  232. <td>{{ $p->rfid }}</td>
  233. <td>{{ $p->factory_number }}</td>
  234. <td>{{ $p->manufacture_date }}</td>
  235. <td class="text-center">
  236. @if($p->maf_order?->order_number)
  237. <i class="bi bi-check-all text-success fw-bold"></i>
  238. @else
  239. @if(isset($needs[$p->product_id]) && ($needs[$p->product_id]['sku']-- > 0))
  240. <i class="bi bi-check text-success fw-bold"></i>
  241. @else
  242. <i class="bi bi-x text-danger fw-bold"></i>
  243. @endif
  244. @endif
  245. </td>
  246. <td class="text-center">
  247. @if($p->passport)
  248. <i class="bi bi-check text-success fw-bold"></i>
  249. @else
  250. <i class="bi bi-x text-danger fw-bold"></i>
  251. @endif
  252. </td>
  253. </tr>
  254. @endforeach
  255. </tbody>
  256. </table>
  257. </div>
  258. <div>
  259. @if(hasRole('admin,manager'))
  260. <a href="{{ route('order.get-maf', $order) }}"
  261. class="btn btn-primary btn-sm mb-1 @disabled($order->ready_to_mount == 'Нет' )">Привязать
  262. все МАФы</a>
  263. <br class="d-md-none">
  264. <a href="{{ route('order.revert-maf', $order) }}" class="btn btn-primary btn-sm mb-1">Отвязать
  265. все МАФы</a>
  266. <br class="d-md-none">
  267. <button class="btn btn-primary btn-sm mb-1" data-bs-toggle="modal"
  268. data-bs-target="#moveModal">Перенести МАФы
  269. </button>
  270. <br class="d-md-none">
  271. <button class="btn btn-sm mb-1 btn-warning" id="create-reclamation-button">Создать
  272. рекламацию
  273. </button>
  274. <form action="{{ route('reclamations.create', $order) }}" method="post"
  275. class="visually-hidden" id="create-reclamation-form">
  276. @csrf
  277. </form>
  278. <a href="#" class="btn btn-primary btn-sm mb-1" id="ttnBtn">ТН</a>
  279. @endif
  280. </div>
  281. @endif
  282. </div>
  283. </div>
  284. </div>
  285. </div>
  286. <!-- Модальное окно графика -->
  287. <div class="modal fade" id="copySchedule" tabindex="-1" aria-labelledby="exampleModalLabel" aria-hidden="true">
  288. <div class="modal-dialog modal-fullscreen-sm-down modal-lg">
  289. <div class="modal-content">
  290. <div class="modal-header">
  291. <h1 class="modal-title fs-5" id="addModalLabel">Перенести в график монтажей</h1>
  292. <button type="button" class="btn-close" data-bs-dismiss="modal" aria-label="Закрыть"></button>
  293. </div>
  294. <div class="modal-body">
  295. <form action="{{ route('schedule.create-from-order') }}" method="post" id="scheduleCreateForm">
  296. @csrf
  297. <div>
  298. <input type="hidden" name="order_id" value="{{ $order->id }}">
  299. <textarea name="comment" placeholder="Комментарий для графика" class="form-control mb-3"></textarea>
  300. <input type="checkbox" checked="checked" id="sendNotifications" name="send_notifications" class="form-check-inline">
  301. <label for="sendNotifications" class="form-check-label mb-2">Уведомить менеджера и бригадира</label><br>
  302. <input type="checkbox" id="deleteOldRecords" name="delete_old_records" class="form-check-inline">
  303. <label for="deleteOldRecords" class="form-check-label mb-2">Удалить старые записи в графике для этой площадки?</label><br>
  304. <button type="submit" class="btn btn-primary btn-sm">Обновить график</button>
  305. </div>
  306. </form>
  307. </div>
  308. </div>
  309. </div>
  310. </div>
  311. <!-- Модальное окно ТН -->
  312. <div class="modal fade" id="createTtnModal" tabindex="-1" aria-labelledby="exampleModalLabel" aria-hidden="true">
  313. <div class="modal-dialog modal-fullscreen-sm-down modal-lg">
  314. <div class="modal-content">
  315. <div class="modal-header">
  316. <h1 class="modal-title fs-5" id="addModalLabel">Введите данные для ТН</h1>
  317. <button type="button" class="btn-close" data-bs-dismiss="modal" aria-label="Закрыть"></button>
  318. </div>
  319. <div class="modal-body">
  320. <form action="{{ route('order.create-ttn') }}" method="post" id="ttnForm">
  321. @csrf
  322. <div>
  323. <input type="text" class="form-control mb-2" name="order_number" placeholder="Номер заказа">
  324. <input type="date" class="form-control mb-2" name="order_date" placeholder="Дата заказа" value="{{ date('Y-m-d') }}">
  325. <input type="number" class="form-control mb-2" name="order_sum" placeholder="Сумма заказа" value="0">
  326. <button href="#" class="btn btn-primary" id="createTtn">Создать ТН</button>
  327. </div>
  328. </form>
  329. </div>
  330. </div>
  331. </div>
  332. </div>
  333. <!-- Модальное окно переноса -->
  334. <div class="modal fade" id="moveModal" tabindex="-1" aria-labelledby="exampleModalLabel" aria-hidden="true">
  335. <div class="modal-dialog modal-fullscreen-sm-down modal-lg">
  336. <div class="modal-content">
  337. <div class="modal-header">
  338. <h1 class="modal-title fs-5" id="addModalLabel">Выбрать площадку, куда переносим</h1>
  339. <button type="button" class="btn-close" data-bs-dismiss="modal" aria-label="Закрыть"></button>
  340. </div>
  341. <div class="modal-body">
  342. <form action="{{ route('order.move-maf') }}" method="post">
  343. @csrf
  344. <div id="select_maf_form">
  345. <input type="text" class="form-control mb-2" placeholder="Поиск площадки" id="search_order">
  346. <select id="select_order" name="new_order_id" class="form-select mb-3" size="20" multiple
  347. required></select>
  348. <a href="#" class="btn btn-primary" id="moveMaf">Перенести</a>
  349. </div>
  350. </form>
  351. </div>
  352. </div>
  353. </div>
  354. </div>
  355. @if($errors->any())
  356. @dump($errors)
  357. @endif
  358. @endsection
  359. @push('scripts')
  360. <script type="module">
  361. $('#tg').on('click', function () {
  362. window.open('https://t.me/{{ $order->tg_group_link }}', '_blank');
  363. });
  364. // select order
  365. $('#search_order').on('keyup', function () {
  366. // search products on backend
  367. $.get('{{ route('order.search') }}?s=' + $(this).val(),
  368. function (data) {
  369. $('#select_order').children().remove()
  370. $.each(data, function (id, name) {
  371. $('#select_order').append('<option value=\'' + id + '\'>' + name + '</option>');
  372. });
  373. }
  374. );
  375. }).trigger('keyup');
  376. $('#check-all-maf').on('change', function () {
  377. $('input:checkbox.check-maf').not(this).prop('checked', this.checked);
  378. });
  379. // move maf
  380. $('#moveMaf').on('click', function () {
  381. let ids = Array();
  382. $('.check-maf').each(function () {
  383. if ($(this).prop('checked')) {
  384. ids.push($(this).attr('data-maf-id'));
  385. }
  386. });
  387. $.post('{{ route('order.move-maf') }}',
  388. {
  389. '_token': $('meta[name=csrf-token]').attr('content'),
  390. ids: JSON.stringify(ids),
  391. 'new_order_id': $('#select_order').find(":selected").val()
  392. },
  393. function () {
  394. location.reload();
  395. }
  396. );
  397. });
  398. $('#create-reclamation-button').on('click', function () {
  399. let ids = Array();
  400. $('.check-maf').each(function () {
  401. if ($(this).prop('checked')) {
  402. ids.push($(this).attr('data-maf-id'));
  403. $('#create-reclamation-form').append('<input type="hidden" name="skus[]" value="' + $(this).attr('data-maf-id') + '">');
  404. }
  405. });
  406. if (ids.length) {
  407. $('#create-reclamation-form').submit();
  408. } else {
  409. customAlert('Нужно выбрать МАФ для рекламации!');
  410. }
  411. });
  412. $('#createScheduleButton').on('click', function () {
  413. let ids = Array();
  414. $('.check-maf').each(function () {
  415. if ($(this).prop('checked')) {
  416. ids.push($(this).attr('data-maf-id'));
  417. $('#scheduleCreateForm').append('<input type="hidden" name="skus[]" value="' + $(this).attr('data-maf-id') + '">');
  418. }
  419. });
  420. let myModalSchedule = new bootstrap.Modal(document.getElementById("copySchedule"), {});
  421. myModalSchedule.show();
  422. });
  423. $('#ttnBtn').on('click', function () {
  424. if ($('input.check-maf:checkbox:checked').length > 0) {
  425. let myModalTtn = new bootstrap.Modal(document.getElementById("createTtnModal"), {});
  426. myModalTtn.show();
  427. } else {
  428. customAlert('Нужно выбрать МАФ для ТН!');
  429. }
  430. });
  431. $('#createTtn').on('click', function () {
  432. let ids = Array();
  433. $('.check-maf').each(function () {
  434. if ($(this).prop('checked')) {
  435. ids.push($(this).attr('data-maf-id'));
  436. $('#ttnForm').append('<input type="hidden" name="skus[]" value="' + $(this).attr('data-maf-id') + '">');
  437. }
  438. });
  439. if (ids.length) {
  440. $('#ttnForm').submit();
  441. } else {
  442. customAlert('Нужно выбрать МАФ для ТН!');
  443. }
  444. });
  445. $('.update-once').on('change', function () {
  446. let v = $(this).val();
  447. let n = $(this).attr('name');
  448. $.post(
  449. '{{ route('order.update', $order->id) }}',
  450. {
  451. '_token': '{{ csrf_token() }}',
  452. id: '{{ $order->id }}',
  453. [n]: v
  454. },
  455. function () {
  456. $('.alerts').append(
  457. '<div class="main-alert alert alert-success" role="alert">Площадка обновлена!</div>'
  458. );
  459. setTimeout(function () {
  460. $('.main-alert').fadeTo(2000, 500).slideUp(500, function () {
  461. $(".main-alert").slideUp(500);
  462. })
  463. }, 3000);
  464. }
  465. );
  466. });
  467. </script>
  468. @endpush