Browse Source

edit maf from order

Alexander Musikhin 7 tháng trước cách đây
mục cha
commit
ed0c8dcafb

+ 3 - 6
app/Http/Controllers/ProductSKUController.php

@@ -71,15 +71,12 @@ class ProductSKUController extends Controller
         return view('products_sku.index', $this->data);
     }
 
-    public function store(ProductSKUStoreRequest $request)
-    {
-        ProductSKU::query()->create($request->validated());
-        return redirect()->route('product_sku.index');
-    }
     public function update(ProductSKUStoreRequest $request, ProductSKU $product_sku)
     {
+        $url = $request->redirect_url ?? route('product_sku.index');
+
         $product_sku->update($request->validated());
-        return redirect()->route('product_sku.index');
+        return redirect($url);
     }
 
     public function show(Request $request, ProductSKU $product_sku)

+ 5 - 1
resources/views/orders/show.blade.php

@@ -71,7 +71,11 @@
                                     <td>
                                         <input type="checkbox" class="form-check check-maf" data-maf-id="{{ $p->id }}">
                                     </td>
-                                    <td>{!! $p->product->article !!}</td>
+                                    <td>
+                                        <a href="{{ route('product_sku.show', $p) }}">
+                                            {!! $p->product->article !!}
+                                        </a>
+                                    </td>
                                     <td>{!! $p->product->nomenclature_number !!}</td>
                                     <td>{{ $p->status }}</td>
                                     <td>{{ $p->maf_order?->order_number }}</td>

+ 1 - 0
resources/views/partials/submit.blade.php

@@ -4,6 +4,7 @@
         @if(isset($delete) && !($deleteDisabled ?? false))
             <a href="#" class="btn btn-danger delete">{{ $delete['title'] }}</a>
         @endif
+        <a href="{{ url()->previous() }}" class="btn btn-outline-secondary">Назад</a>
     </div>
 </div>
 

+ 3 - 1
resources/views/products_sku/edit.blade.php

@@ -10,6 +10,8 @@
                 @csrf
 
                 <input type="hidden" id="product_id" name="product_id" value="{{ $product_sku->product_id }}">
+
+                @include('partials.input', ['name' => 'order_name', 'title' => 'Площадка', 'disabled' => true, 'value' => $product_sku->order->common_name])
                 @include('partials.input', ['name' => 'product_name', 'title' => 'МАФ', 'disabled' => true, 'value' => $product_sku->product->common_name])
                 @include('partials.input', ['name' => 'rfid', 'title' => 'RFID', 'required' => true, 'value' => $product_sku->rfid, 'required' => true])
                 @include('partials.input', ['name' => 'factory_number', 'title' => 'Номер фабрики', 'required' => true, 'value' => $product_sku->factory_number, 'required' => true])
@@ -19,7 +21,7 @@
                 @include('partials.input', ['name' => 'certificate_date', 'title' => 'Дата сертификата', 'type' => 'date', 'required' => true, 'value' => $product_sku->certificate_date, 'required' => true])
                 @include('partials.input', ['name' => 'certificate_issuer', 'title' => 'Орган сертификации', 'required' => true, 'value' => $product_sku->certificate_issuer, 'required' => true])
                 @include('partials.input', ['name' => 'certificate_type', 'title' => 'Вид сертификации', 'required' => true, 'value' => $product_sku->certificate_type, 'required' => true])
-
+                <input type="hidden" name="redirect_url" value="{{ url()->previous() }}">
                 @include('partials.submit', ['name' => 'Сохранить'])
             </div>
         </form>

+ 36 - 38
resources/views/products_sku/index.blade.php

@@ -7,9 +7,9 @@
             <h3>Заказы МАФ</h3>
         </div>
         <div class="col-6 text-end">
-            <button type="button" class="btn btn-primary" data-bs-toggle="modal" data-bs-target="#addModal">
-                Добавить
-            </button>
+{{--            <button type="button" class="btn btn-primary" data-bs-toggle="modal" data-bs-target="#addModal">--}}
+{{--                Добавить--}}
+{{--            </button>--}}
 
         </div>
     </div>
@@ -29,39 +29,39 @@
     </div>
 
     <!-- Модальное окно редактирования -->
-    <div class="modal fade" id="addModal" tabindex="-1" aria-labelledby="exampleModalLabel" aria-hidden="true">
-        <div class="modal-dialog modal-fullscreen-sm-down modal-lg">
-            <div class="modal-content">
-                <div class="modal-header">
-                    <h1 class="modal-title fs-5" id="addModalLabel">Добавить заказ МАФ</h1>
-                    <button type="button" class="btn-close" data-bs-dismiss="modal" aria-label="Закрыть"></button>
-                </div>
-                <div class="modal-body">
-                    <form action="{{ route('product_sku.store') }}" method="post">
-                        @csrf
-                        <div id="select_maf_form">
-                            <input type="text" class="form-control mb-2" placeholder="Поиск номенклатуры" id="search_maf">
-                            <select id="select_maf" class="form-select mb-3" multiple></select>
-                        </div>
-                        <div style="display:none;" id="sku_form">
-                            <a href="#" onclick="$('#sku_form').slideUp(); $('#select_maf_form').slideDown()">назад</a>
-                            <input type="hidden" id="product_id" name="product_id" value="">
-                            @include('partials.input', ['name' => 'product_name', 'title' => 'МАФ', 'disabled' => true])
-                            @include('partials.input', ['name' => 'rfid', 'title' => 'RFID', 'required' => true])
-                            @include('partials.input', ['name' => 'factory_number', 'title' => 'Номер фабрики', 'required' => true])
-                            @include('partials.input', ['name' => 'manufacture_date', 'title' => 'Дата производства', 'type' => 'date', 'required' => true])
-                            @include('partials.input', ['name' => 'service_life', 'title' => 'Срок службы', 'required' => true, 'type' => 'number'])
-                            @include('partials.input', ['name' => 'certificate_number', 'title' => 'Номер сертификата', 'required' => true])
-                            @include('partials.input', ['name' => 'certificate_date', 'title' => 'Дата сертификата', 'type' => 'date', 'required' => true])
-                            @include('partials.input', ['name' => 'certificate_issuer', 'title' => 'Орган сертификации', 'required' => true])
-                            @include('partials.input', ['name' => 'certificate_type', 'title' => 'Вид сертификации', 'required' => true])
-                            @include('partials.submit', ['name' => 'Добавить'])
-                        </div>
-                    </form>
-                </div>
-            </div>
-        </div>
-    </div>
+{{--    <div class="modal fade" id="addModal" tabindex="-1" aria-labelledby="exampleModalLabel" aria-hidden="true">--}}
+{{--        <div class="modal-dialog modal-fullscreen-sm-down modal-lg">--}}
+{{--            <div class="modal-content">--}}
+{{--                <div class="modal-header">--}}
+{{--                    <h1 class="modal-title fs-5" id="addModalLabel">Добавить заказ МАФ</h1>--}}
+{{--                    <button type="button" class="btn-close" data-bs-dismiss="modal" aria-label="Закрыть"></button>--}}
+{{--                </div>--}}
+{{--                <div class="modal-body">--}}
+{{--                    <form action="{{ route('product_sku.store') }}" method="post">--}}
+{{--                        @csrf--}}
+{{--                        <div id="select_maf_form">--}}
+{{--                            <input type="text" class="form-control mb-2" placeholder="Поиск номенклатуры" id="search_maf">--}}
+{{--                            <select id="select_maf" class="form-select mb-3" multiple></select>--}}
+{{--                        </div>--}}
+{{--                        <div style="display:none;" id="sku_form">--}}
+{{--                            <a href="#" onclick="$('#sku_form').slideUp(); $('#select_maf_form').slideDown()">назад</a>--}}
+{{--                            <input type="hidden" id="product_id" name="product_id" value="">--}}
+{{--                            @include('partials.input', ['name' => 'product_name', 'title' => 'МАФ', 'disabled' => true])--}}
+{{--                            @include('partials.input', ['name' => 'rfid', 'title' => 'RFID', 'required' => true])--}}
+{{--                            @include('partials.input', ['name' => 'factory_number', 'title' => 'Номер фабрики', 'required' => true])--}}
+{{--                            @include('partials.input', ['name' => 'manufacture_date', 'title' => 'Дата производства', 'type' => 'date', 'required' => true])--}}
+{{--                            @include('partials.input', ['name' => 'service_life', 'title' => 'Срок службы', 'required' => true, 'type' => 'number'])--}}
+{{--                            @include('partials.input', ['name' => 'certificate_number', 'title' => 'Номер сертификата', 'required' => true])--}}
+{{--                            @include('partials.input', ['name' => 'certificate_date', 'title' => 'Дата сертификата', 'type' => 'date', 'required' => true])--}}
+{{--                            @include('partials.input', ['name' => 'certificate_issuer', 'title' => 'Орган сертификации', 'required' => true])--}}
+{{--                            @include('partials.input', ['name' => 'certificate_type', 'title' => 'Вид сертификации', 'required' => true])--}}
+{{--                            @include('partials.submit', ['name' => 'Добавить'])--}}
+{{--                        </div>--}}
+{{--                    </form>--}}
+{{--                </div>--}}
+{{--            </div>--}}
+{{--        </div>--}}
+{{--    </div>--}}
 
     @if($errors->count())
         @dump($errors)
@@ -76,8 +76,6 @@
             $('#product_name').val($('#select_maf option:selected').text()).slideDown();
             $('#select_maf_form').slideUp();
             $('#sku_form').slideDown();
-
-
         });
     </script>
 @endpush

+ 1 - 1
routes/web.php

@@ -77,7 +77,7 @@ Route::middleware('auth:web')->group(function () {
     // Склад (МАФ)
     Route::get('product_sku', [ProductSKUController::class, 'index'])->name('product_sku.index');
     Route::get('product_sku/{product_sku}', [ProductSKUController::class, 'show'])->name('product_sku.show');
-    Route::post('product_sku/store', [ProductSKUController::class, 'store'])->name('product_sku.store');
+//    Route::post('product_sku/store', [ProductSKUController::class, 'store'])->name('product_sku.store');
     Route::post('product_sku/update/{product_sku}', [ProductSKUController::class, 'update'])->name('product_sku.update');
 
    // Склад заказы МАФ