Browse Source

фиксы

Alexander Musikhin 3 weeks ago
parent
commit
c63cfa83ed

+ 2 - 2
app/Http/Controllers/MafOrderController.php

@@ -59,9 +59,9 @@ class MafOrderController extends Controller
         return redirect()->route('maf_order.index', session('gp_maf_order'));
     }
 
-    public function show(Request $request, MafOrder $maf_order)
+    public function show(Request $request, int $maf_order)
     {
-        $this->data['maf_order'] = $maf_order;
+        $this->data['maf_order'] = MafOrder::query()->withoutGlobalScopes()->find($maf_order);
         $this->data['previous_url'] = $request->get('previous_url');
         return view('maf_orders.edit', $this->data);
     }

+ 2 - 2
app/Http/Controllers/OrderController.php

@@ -181,9 +181,9 @@ class OrderController extends Controller
     /**
      * Display the specified resource.
      */
-    public function show(Request $request, Order $order)
+    public function show(Request $request, int $order)
     {
-        $this->data['order'] = $order;
+        $this->data['order'] = Order::query()->withoutGlobalScopes()->find($order);
         $this->data['previous_url'] = $request->get('previous_url');
         return view('orders.show', $this->data);
     }

+ 2 - 2
app/Http/Controllers/ProductController.php

@@ -78,10 +78,10 @@ class ProductController extends Controller
         return view('catalog.index', $this->data);
     }
 
-    public function show(Request $request, Product $product)
+    public function show(Request $request, int $product)
     {
         $this->data['previous_url'] = $request->get('previous_url');
-        $this->data['product'] = $product;
+        $this->data['product'] = Product::query()->withoutGlobalScopes()->find($product);
         return view('catalog.edit', $this->data);
     }
 

+ 2 - 2
app/Http/Controllers/ProductSKUController.php

@@ -85,9 +85,9 @@ class ProductSKUController extends Controller
         return redirect($url);
     }
 
-    public function show(Request $request, ProductSKU $product_sku)
+    public function show(Request $request, int $product_sku)
     {
-        $this->data['product_sku'] = $product_sku;
+        $this->data['product_sku'] = ProductSKU::query()->withoutGlobalScopes()->find($product_sku);
         $this->data['previous_url'] = $request->get('previous_url');
         return view('products_sku.edit', $this->data);
     }

+ 1 - 0
app/Http/Controllers/ReclamationController.php

@@ -35,6 +35,7 @@ class ReclamationController extends Controller
             'district_name' => 'Округ',
             'area_name' => 'Район',
             'object_address' => 'Адрес объекта',
+            'maf_installation_year' => 'Год установки МАФ',
             'create_date' => 'Дата создания',
             'finish_date' => 'Дата завершения',
             'start_work_date' => 'Дата начала работ',

+ 1 - 1
app/Http/Controllers/ScheduleController.php

@@ -254,7 +254,7 @@ class ScheduleController extends Controller
             ->get();
 
         ExportScheduleJob::dispatch($schedules, $request->user()->id);
-        return redirect()->route('schedule.index', ['week' => $request->validated()['week']])
+        return redirect()->route('schedule.index', ['week' => (int) $request->validated()['week']])
             ->with(['success' => 'Задача генерации графика создана!']);
 
     }

+ 1 - 1
app/Http/Requests/ExportScheduleRequest.php

@@ -24,7 +24,7 @@ class ExportScheduleRequest extends FormRequest
         return [
             'start_date'    => 'required|date_format:Y-m-d',
             'end_date'      => 'required|date_format:Y-m-d',
-            'week'          => 'required|integer',
+            'week'          => 'required|string',
         ];
     }
 }

+ 2 - 2
app/Models/MafOrder.php

@@ -43,12 +43,12 @@ class MafOrder extends Model
 
     public function product(): BelongsTo
     {
-        return $this->belongsTo(Product::class);
+        return $this->belongsTo(Product::class)->withoutGlobalScopes();
     }
 
     public function products_sku(): HasMany
     {
-        return $this->hasMany(ProductSKU::class);
+        return $this->hasMany(ProductSKU::class)->withoutGlobalScopes();
     }
 
 }

+ 1 - 1
app/Models/ProductSKU.php

@@ -56,7 +56,7 @@ class ProductSKU extends Model
      */
     public function order(): BelongsTo
     {
-        return $this->belongsTo(Order::class, 'order_id', 'id');
+        return $this->belongsTo(Order::class, 'order_id', 'id')->withoutGlobalScopes();
     }
 
     /**

+ 1 - 0
app/Models/ReclamationView.php

@@ -38,5 +38,6 @@ class ReclamationView extends Model
         'area_name',
         'object_type_name',
         'status_name',
+        'maf_installation_year',
     ];
 }

+ 57 - 0
database/migrations/2026_02_12_184902_add_maf_installation_year_to_reclamations_view.php

@@ -0,0 +1,57 @@
+<?php
+
+use Illuminate\Database\Migrations\Migration;
+
+return new class extends Migration
+{
+    /**
+     * Run the migrations.
+     */
+    public function up(): void
+    {
+        $sql = "CREATE OR REPLACE VIEW reclamations_view AS
+
+                SELECT r.*,
+                    u.name as user_name,
+                    u1.name as brigadier_name,
+                    o.year,
+                    o.name as order_name,
+                    o.object_address,
+                    o.district_name,
+                    o.area_name,
+                    o.object_type_name,
+                    rs.name as status_name,
+                    o.year as maf_installation_year
+                FROM reclamations r
+                    LEFT JOIN users u ON r.user_id = u.id
+                    LEFT JOIN users u1 ON r.brigadier_id = u1.id
+                    LEFT JOIN reclamation_statuses rs ON r.status_id = rs.id
+                    LEFT JOIN orders_view o ON r.order_id = o.id";
+        DB::unprepared($sql);
+    }
+
+    /**
+     * Reverse the migrations.
+     */
+    public function down(): void
+    {
+        $sql = "CREATE OR REPLACE VIEW reclamations_view AS
+
+                SELECT r.*,
+                    u.name as user_name,
+                    u1.name as brigadier_name,
+                    o.year,
+                    o.name as order_name,
+                    o.object_address,
+                    o.district_name,
+                    o.area_name,
+                    o.object_type_name,
+                    rs.name as status_name
+                FROM reclamations r
+                    LEFT JOIN users u ON r.user_id = u.id
+                    LEFT JOIN users u1 ON r.brigadier_id = u1.id
+                    LEFT JOIN reclamation_statuses rs ON r.status_id = rs.id
+                    LEFT JOIN orders_view o ON r.order_id = o.id";
+        DB::unprepared($sql);
+    }
+};

+ 1 - 0
resources/views/catalog/edit.blade.php

@@ -36,6 +36,7 @@
                 @csrf
                 <div class="row">
                     <div class="col-xl-6">
+                        @include('partials.input', ['name' => 'year', 'title' => 'Год', 'value' => $product->year, 'disabled' => true])
                         @include('partials.input', ['name' => 'article', 'title' => 'Артикул', 'required' => true, 'value' => $product->article ?? '', 'disabled' => !hasRole('admin'), 'disabled' => !hasRole('admin')])
                         @include('partials.input', ['name' => 'nomenclature_number', 'title' => 'Номер номенклатуры', 'required' => true, 'value' => $product->nomenclature_number ?? '', 'disabled' => !hasRole('admin')])
                         @include('partials.input', ['name' => 'name_tz', 'title' => 'Наименование по ТЗ', 'required' => true, 'value' => $product->name_tz ?? '', 'disabled' => !hasRole('admin')])

+ 1 - 0
resources/views/maf_orders/edit.blade.php

@@ -10,6 +10,7 @@
                     @csrf
 
                     <input type="hidden" id="product_id" name="product_id" value="{{ $maf_order->product_id }}">
+                    @include('partials.input', ['name' => 'year', 'title' => 'Год', 'value' => $maf_order->year, 'disabled' => true])
                     @include('partials.input', ['name' => 'product_name', 'title' => 'МАФ', 'disabled' => true, 'value' => $maf_order->product->common_name])
                     @include('partials.input', ['name' => 'order_number', 'title' => 'Номер заказа', 'required' => false, 'value' => $maf_order->order_number, 'disabled' => $maf_order->products_sku->count()])
                     @include('partials.select', ['name' => 'status', 'title' => 'Статус', 'options' => ['заказан', 'на складе'], 'key_as_val' => true, 'value' => $maf_order->status, 'disabled' => $maf_order->products_sku->count()])

+ 14 - 0
resources/views/partials/link.blade.php

@@ -0,0 +1,14 @@
+<div class="row mb-2">
+    <label class="col-form-label small @if(!($right ?? null)) col-md-4 text-md-end @endif">
+        {{ $title ?? '' }}
+    </label>
+    <div class="@if(!($right ?? null)) col-md-8 @endif d-flex align-items-center">
+        @if($href ?? null)
+            <a href="{{ $href }}" target="{{ $target ?? '_self' }}" class="@isset($classes) {{ implode(' ', $classes) }} @endisset">
+                {{ $text ?? $href }}
+            </a>
+        @else
+            <span class="text-muted">—</span>
+        @endif
+    </div>
+</div>

+ 2 - 2
resources/views/products_sku/edit.blade.php

@@ -26,8 +26,8 @@
 
                 <input type="hidden" id="product_id" name="product_id" value="{{ $product_sku->product_id }}">
                 <input type="hidden" name="previous_url" value="{{ $previous_url ?? '' }}">
-
-                @include('partials.input', ['name' => 'order_name', 'title' => 'Площадка', 'disabled' => true, 'value' => $product_sku->order->common_name])
+                @include('partials.input', ['name' => 'year', 'title' => 'Год', 'value' => $product_sku->year, 'disabled' => true])
+                @include('partials.link',  ['href' => route('order.show', $product_sku->order_id), 'title' => 'Площадка', 'text' => $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, 'disabled' => !hasRole('admin'), 'value' => $product_sku->rfid])
                 @include('partials.input', ['name' => 'factory_number', 'title' => 'Номер фабрики', 'required' => true, 'disabled' => !hasRole('admin'), 'value' => $product_sku->factory_number])

+ 3 - 2
resources/views/reclamations/edit.blade.php

@@ -33,9 +33,10 @@
                     <input type="hidden" id="order_id" name="order_id" value="{{ $reclamation->order_id}}">
                     <input type="hidden" name="previous_url" value="{{ $previous_url ?? '' }}">
 
-                    @include('partials.input', ['name' => 'order_name', 'title' => 'Площадка', 'disabled' => true, 'value' => $reclamation->order->common_name ?? ''])
+                    @include('partials.link', ['title' => 'Площадка', 'href' => route('order.show', $reclamation->order_id), 'text' => $reclamation->order->common_name ?? ''])
                     @include('partials.select', ['name' => 'status_id', 'title' => 'Статус', 'options' => $statuses, 'value' => $reclamation->status_id ?? old('status_id'), 'disabled' => !hasRole('admin,manager')])
                     @include('partials.select', ['name' => 'user_id', 'title' => 'Менеджер', 'options' => $users, 'value' => $reclamation->user_id ?? old('user_id') ?? auth()->user()->id, 'disabled' => !hasRole('admin,manager')])
+                    @include('partials.input', ['name' => 'maf_installation_year', 'title' => 'Год установки МАФ', 'type' => 'text', 'value' => $reclamation->order->year, 'disabled' => true])
                     @include('partials.input', ['name' => 'create_date', 'title' => 'Дата создания', 'type' => 'date', 'required' => true, 'value' => $reclamation->create_date ?? date('Y-m-d'), 'disabled' => !hasRole('admin,manager')])
                     @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')])
                     @include('partials.select', ['name' => 'brigadier_id', 'title' => 'Бригадир', 'options' => $brigadiers, 'value' => $reclamation->brigadier_id ?? old('brigadier_id'), 'disabled' => !hasRole('admin,manager'), 'first_empty' => true])
@@ -581,7 +582,7 @@
                             <input type="hidden" name="reclamation_id" value="{{ $reclamation->id }}">
 {{--                            <textarea name="comment" placeholder="Комментарий для графика" class="form-control mb-3"></textarea>--}}
 
-                            <input type="checkbox" checked="checked" id="sendNotifications" name="send_notifications" class="form-check-inline">
+                            <input type="checkbox" checked="checked" id="sendNotifications" name="send_notifications" value="1" class="form-check-inline">
                             <label for="sendNotifications" class="form-check-label mb-2">Уведомить менеджера и бригадира</label><br>
 
                             <input type="checkbox" id="deleteOldRecords" name="delete_old_records" class="form-check-inline">