From: fomichev Date: Thu, 27 Mar 2025 06:45:30 +0000 (+0300) Subject: Поиск и отладка X-Git-Url: https://gitweb.erp-flowers.ru/?a=commitdiff_plain;h=aa6f8eae501665405d2351c11d2620e6a11a4790;p=erp24_rep%2Fyii-erp24%2F.git Поиск и отладка --- diff --git a/erp24/controllers/BouquetController.php b/erp24/controllers/BouquetController.php index a3c31f76..cab7a973 100644 --- a/erp24/controllers/BouquetController.php +++ b/erp24/controllers/BouquetController.php @@ -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]), diff --git a/erp24/records/BouquetComposition.php b/erp24/records/BouquetComposition.php index 4b9ba74f..7ff5510d 100644 --- a/erp24/records/BouquetComposition.php +++ b/erp24/records/BouquetComposition.php @@ -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(), ]; } diff --git a/erp24/services/FileService.php b/erp24/services/FileService.php index 31bee4fd..ab3b8d77 100755 --- a/erp24/services/FileService.php +++ b/erp24/services/FileService.php @@ -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;