]> gitweb.erp-flowers.ru Git - erp24_rep/yii-erp24/.git/commitdiff
Поиск и отладка
authorfomichev <vladimir.fomichev@erp-flowers.ru>
Thu, 27 Mar 2025 06:45:30 +0000 (09:45 +0300)
committerfomichev <vladimir.fomichev@erp-flowers.ru>
Thu, 27 Mar 2025 06:45:30 +0000 (09:45 +0300)
erp24/controllers/BouquetController.php
erp24/records/BouquetComposition.php
erp24/services/FileService.php

index a3c31f76054ce516e1d225591c72452f07f258ff..cab7a9733b0c6c3befd732b5c8c7dcdca4fcf50d 100644 (file)
@@ -85,12 +85,12 @@ class BouquetController extends Controller
 
         $data = $request->post();
         $isNew = $model->isNewRecord;
-
+        Yii::warning('Request: ' . json_encode($data, JSON_UNESCAPED_UNICODE));
         if ($isNew) {
             $model->guid = DataHelper::createGuidMy('07');
             $model->status = WriteOffsErp::STATUS_CREATED;
         }
-
+        Yii::warning('Model: ' . json_encode($model, JSON_UNESCAPED_UNICODE));
         if (isset($data['matrix_type_id'])) {
             $model->matrix_type_id = (int) $data['matrix_type_id'];
         }
@@ -100,7 +100,7 @@ class BouquetController extends Controller
             if (!$model->load($data) || !$model->validate() || !$model->save()) {
                 throw new Exception('Ошибка при сохранении букета');
             }
-
+            Yii::warning('Model 2: ' . json_encode($model, JSON_UNESCAPED_UNICODE));
             $model->processRelations($data);
             $transaction->commit();
             Yii::$app->session->setFlash('success', 'Данные успешно сохранены');
@@ -126,7 +126,9 @@ class BouquetController extends Controller
     private function renderView(BouquetComposition $model)
     {
         $files = $model->getFiles();
-
+       // usort($files['photo'], fn($a, $b) => strtotime($a->created_at) <=> strtotime($b->created_at));
+        Yii::warning('Order files' . json_encode($files['photo'], JSON_UNESCAPED_UNICODE));
+        Yii::warning('Order files url' . json_encode(array_map(fn($file) => Url::to([$file->url], true), $files['photo']), JSON_UNESCAPED_UNICODE));
         return $this->render('view', [
             'model' => $model,
             'onlineStoresList' => BouquetForecast::getStoresList($model->id, BouquetForecast::ONLINE_STORES, CityStore::class, ['visible' => CityStore::IS_VISIBLE]),
index 4b9ba74f64bd731bbc856a8c96b46e5274642c63..7ff5510dee287c5b33f4a50ce52c28cfae62ee8f 100644 (file)
@@ -231,9 +231,16 @@ class BouquetComposition extends ActiveRecord
     public function getFiles(): array
     {
         return [
-            'photo' => Files::find()->where(['entity_id' => $this->id, 'file_type' => self::PHOTO_TYPE, 'entity' => self::PHOTO_BOUQUET])->all(),
-            'video' => Files::find()->where(['entity_id' => $this->id, 'file_type' => self::VIDEO_TYPE, 'entity' => self::VIDEO_PRESENTATION])->all(),
-            'process' => Files::find()->where(['entity_id' => $this->id, 'file_type' => self::VIDEO_TYPE, 'entity' => self::VIDEO_BUILD_PROCESS])->all(),
+            'photo' => Files::find()
+                ->where(['entity_id' => $this->id, 'file_type' => self::PHOTO_TYPE, 'entity' => self::PHOTO_BOUQUET])
+                ->orderBy(['created_at' => SORT_ASC])
+                ->all(),
+            'video' => Files::find()
+                ->where(['entity_id' => $this->id, 'file_type' => self::VIDEO_TYPE, 'entity' => self::VIDEO_PRESENTATION])
+                ->all(),
+            'process' => Files::find()
+                ->where(['entity_id' => $this->id, 'file_type' => self::VIDEO_TYPE, 'entity' => self::VIDEO_BUILD_PROCESS])
+                ->all(),
         ];
     }
 
index 31bee4fddb32c98f2334b221237d515fdfdcbdac..ab3b8d773bf854c9be272e8ef7fd4627edbc243f 100755 (executable)
@@ -128,6 +128,7 @@ class FileService
             mkdir($filePath, 0777, true);
         }
         $targetFile = $uploads . $target_dir. "/" . $file->baseName . '.' . $file->extension;
+        Yii::warning('Saved file: ' . json_encode($targetFile, JSON_UNESCAPED_UNICODE));
         $file->saveAs($targetFile);
         
         $type = 'image';
@@ -142,7 +143,7 @@ class FileService
         }
 
         $fileRecord = new Files;
-        $fileRecord->created_at = date("Y-m-d H:i:s");
+        $fileRecord->created_at = date("Y-m-d H:i:s", time() + 1);
         $fileRecord->entity_id = $entity_id;
         $fileRecord->entity = $entity;
         $fileRecord->file_type = $type;