Răsfoiți Sursa

Колонки в списке импортов тип и статус на русском языке

Alexander Musikhin 4 zile în urmă
părinte
comite
94b9e74281

+ 31 - 3
app/Http/Controllers/ImportController.php

@@ -17,8 +17,8 @@ class ImportController extends Controller
         'id'        => 'import',
         'header'    => [
             'id'                        => 'ID',
-            'type'                      => 'Тип',
-            'status'                    => 'Статус',
+            'type_label'                => 'Тип',
+            'status_label'              => 'Статус',
             'created_at'                => 'Создано',
             'updated_at'                => 'Изменено',
         ],
@@ -36,7 +36,7 @@ class ImportController extends Controller
         $model = new Import;
         // fill filters
         $this->data['ranges'] = [];
-        $this->createFilters($model, 'type', 'status');
+        $this->createImportFilters($model);
         $this->createDateFilters($model, 'created_at', 'updated_at');
 
         $q = $model::query();
@@ -85,4 +85,32 @@ class ImportController extends Controller
         return view('import.show', $this->data);
     }
 
+    /**
+     * Создание фильтров с переведёнными значениями type и status
+     */
+    protected function createImportFilters(Import $model): void
+    {
+        // Фильтр по типу
+        $uniqueTypes = $model::query()->distinct()->pluck('type')->toArray();
+        $typeValues = [];
+        foreach ($uniqueTypes as $type) {
+            $typeValues[$type] = Import::TYPE_LABELS[$type] ?? $type;
+        }
+        $this->data['filters']['type'] = [
+            'title'  => 'Тип',
+            'values' => $typeValues,
+        ];
+
+        // Фильтр по статусу
+        $uniqueStatuses = $model::query()->distinct()->pluck('status')->toArray();
+        $statusValues = [];
+        foreach ($uniqueStatuses as $status) {
+            $statusValues[$status] = Import::STATUS_LABELS[$status] ?? $status;
+        }
+        $this->data['filters']['status'] = [
+            'title'  => 'Статус',
+            'values' => $statusValues,
+        ];
+    }
+
 }

+ 29 - 0
app/Models/Import.php

@@ -14,6 +14,25 @@ class Import extends Model
     const STATUS_COMPLETED = 'completed';
     const STATUS_FAILED = 'failed';
 
+    const TYPE_LABELS = [
+        'orders' => 'Площадки',
+        'reclamations' => 'Рекламации',
+        'mafs' => 'МАФы',
+        'catalog' => 'Каталог',
+        'spare_part_orders' => 'Заказы запчастей',
+        'maf_orders' => 'Заказы МАФ',
+    ];
+
+    const STATUS_LABELS = [
+        'new' => 'Новый',
+        'pending' => 'В ожидании',
+        'in_progress' => 'В процессе',
+        'completed' => 'Завершён',
+        'failed' => 'Ошибка',
+        'DONE' => 'Завершён',
+        'ERROR' => 'Ошибка',
+    ];
+
     protected $fillable = [
         'type',
         'year',
@@ -32,4 +51,14 @@ class Import extends Model
         $this->result = $this->result . $string;
         return $string;
     }
+
+    public function getTypeLabelAttribute(): string
+    {
+        return self::TYPE_LABELS[$this->type] ?? $this->type;
+    }
+
+    public function getStatusLabelAttribute(): string
+    {
+        return self::STATUS_LABELS[$this->status] ?? $this->status;
+    }
 }

+ 2 - 2
resources/views/import/show.blade.php

@@ -23,8 +23,8 @@
         <div class="row">
             <div class="col-xl-12 border-end">
 
-                @include('partials.input',  ['name' => 'type', 'title' => 'Тип', 'value' => $import->type, 'disabled' => true])
-                @include('partials.input',  ['name' => 'status', 'title' => 'Статус', 'value' => $import->status, 'disabled' => true])
+                @include('partials.input',  ['name' => 'type', 'title' => 'Тип', 'value' => $import->type_label, 'disabled' => true])
+                @include('partials.input',  ['name' => 'status', 'title' => 'Статус', 'value' => $import->status_label, 'disabled' => true])
                 @include('partials.input',  ['name' => 'filename', 'title' => 'Файл', 'value' => $import->filename, 'disabled' => true])
                 @include('partials.input',  ['name' => 'created_at', 'title' => 'Создан', 'value' => $import->created_at, 'disabled' => true])
                 @include('partials.input',  ['name' => 'updated_at', 'title' => 'Изменен', 'value' => $import->updated_at, 'disabled' => true])

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

@@ -326,11 +326,13 @@
                                       class="visually-hidden" id="create-reclamation-form">
                                     @csrf
                                 </form>
+                                <br class="d-md-none">
+
                                 <a href="#" class="btn btn-primary btn-sm mb-1" id="ttnBtn">ТН</a>
                             @endif
-                        </div>
-                        <div class="mt-2">
-                            <a href="{{ route('order.download-tech-docs', $order) }}" class="btn btn-sm btn-outline-primary">
+                                <br class="d-md-none">
+
+                                <a href="{{ route('order.download-tech-docs', $order) }}" class="btn btn-sm mb-1 btn-outline-primary">
                                 <i class="bi bi-download"></i> Скачать тех. документацию
                             </a>
                         </div>

+ 2 - 1
resources/views/users/profile.blade.php

@@ -21,7 +21,8 @@
                 @include('partials.input', ['name' => 'password', 'type' => 'password', 'title' => 'Новый пароль'])
                 @include('partials.input', ['name' => 'password_confirmation', 'type' => 'password', 'title' => 'Подтверждение пароля'])
             </div>
-            @include('partials.submit', ['delete' => ['title' => 'Удалить', 'question' => 'Удалить профиль?']])
+{{--            @include('partials.submit', ['delete' => ['title' => 'Удалить', 'question' => 'Удалить профиль?']])--}}
+            @include('partials.submit')
 {{--            <a href="#" class="btn btn-outline-info my-3 d-inline-block d-md-none" onclick="$('#logout').submit();">Выход</a>--}}
         </form>
         <form action="{{ route('profile.delete') }}" method="post" id="destroy_form" class="d-none">