From d1d34abe5a2321c7d372f50f113c544c1967c830 Mon Sep 17 00:00:00 2001 From: marina Date: Thu, 20 Feb 2025 15:55:42 +0300 Subject: [PATCH] =?utf8?q?ERP-302=20=D0=A0=D0=B5=D0=B4=D0=B0=D0=BA=D1=82?= =?utf8?q?=D0=B8=D1=80=D0=BE=D0=B2=D0=B0=D0=BD=D0=B8=D0=B5=20=D0=B1=D1=83?= =?utf8?q?=D0=BA=D0=B5=D1=82=D0=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit --- erp24/controllers/BouquetController.php | 86 +++++++++++++------------ 1 file changed, 44 insertions(+), 42 deletions(-) diff --git a/erp24/controllers/BouquetController.php b/erp24/controllers/BouquetController.php index 0351a290..4e876dbb 100644 --- a/erp24/controllers/BouquetController.php +++ b/erp24/controllers/BouquetController.php @@ -76,65 +76,67 @@ class BouquetController extends Controller if ($data['matrix_type_id']) { BouquetCompositionMatrixTypeHistory::setData($data['matrix_type_id'], $model->id); } + if ($model->save()) { - $month = $data['month']; - $year = $data['year']; + $month = $data['month']; + $year = $data['year']; - $model->photo_bouquet = UploadedFile::getInstances($model, 'photo_bouquet'); - if ($model->photo_bouquet) { - Files::deleteAll(['file_type' => 'image', 'entity_id' => $model->id, 'entity' => BouquetComposition::PHOTO_BOUQUET]); - foreach ($model->photo_bouquet as $photo) { - FileService::saveUploadedFile($photo, BouquetComposition::PHOTO_BOUQUET, $model->id); + $model->photo_bouquet = UploadedFile::getInstances($model, 'photo_bouquet'); + if ($model->photo_bouquet) { + Files::deleteAll(['file_type' => 'image', 'entity_id' => $model->id, 'entity' => BouquetComposition::PHOTO_BOUQUET]); + foreach ($model->photo_bouquet as $photo) { + FileService::saveUploadedFile($photo, BouquetComposition::PHOTO_BOUQUET, $model->id); + } } - } - $model->video_presentation = UploadedFile::getInstances($model, 'video_presentation'); - if ($model->video_presentation) { - Files::deleteAll(['file_type' => 'video', 'entity_id' => $model->id, 'entity' => BouquetComposition::VIDEO_PRESENTATION]); - FileService::saveUploadedFile($model->video_presentation, BouquetComposition::VIDEO_PRESENTATION, $model->id); - } + $model->video_presentation = UploadedFile::getInstances($model, 'video_presentation'); + if ($model->video_presentation) { + Files::deleteAll(['file_type' => 'video', 'entity_id' => $model->id, 'entity' => BouquetComposition::VIDEO_PRESENTATION]); + FileService::saveUploadedFile($model->video_presentation, BouquetComposition::VIDEO_PRESENTATION, $model->id); + } - $model->video_build_process = UploadedFile::getInstances($model, 'video_build_process'); - if ($model->video_build_process) { - Files::deleteAll(['file_type' => 'video', 'entity_id' => $model->id, 'entity' => BouquetComposition::VIDEO_BUILD_PROCESS]); - FileService::saveUploadedFile($model->video_build_process, BouquetComposition::VIDEO_BUILD_PROCESS, $model->id); - } + $model->video_build_process = UploadedFile::getInstances($model, 'video_build_process'); + if ($model->video_build_process) { + Files::deleteAll(['file_type' => 'video', 'entity_id' => $model->id, 'entity' => BouquetComposition::VIDEO_BUILD_PROCESS]); + FileService::saveUploadedFile($model->video_build_process, BouquetComposition::VIDEO_BUILD_PROCESS, $model->id); + } - if (!empty($data['BouquetForecast']['type_sales_value'])) { - $salesData = $data['BouquetForecast']['type_sales_value']; + if (!empty($data['BouquetForecast']['type_sales_value'])) { + $salesData = $data['BouquetForecast']['type_sales_value']; - if (!empty($salesData['offline'])) { - BouquetForecast::processSalesData($model->id, $year, $month, $salesData['offline'], BouquetForecast::OFFLINE_STORES); - } + if (!empty($salesData['offline'])) { + BouquetForecast::processSalesData($model->id, $year, $month, $salesData['offline'], BouquetForecast::OFFLINE_STORES); + } - if (!empty($salesData['online'])) { - BouquetForecast::processSalesData($model->id, $year, $month, $salesData['online'], BouquetForecast::ONLINE_STORES); - } + if (!empty($salesData['online'])) { + BouquetForecast::processSalesData($model->id, $year, $month, $salesData['online'], BouquetForecast::ONLINE_STORES); + } - if (!empty($salesData['marketplace'])) { - BouquetForecast::processSalesData($model->id, $year, $month, $salesData['marketplace'], BouquetForecast::MARKETPLACE); + if (!empty($salesData['marketplace'])) { + BouquetForecast::processSalesData($model->id, $year, $month, $salesData['marketplace'], BouquetForecast::MARKETPLACE); + } } - } - if ($data['products_quantity']) { - $bouquetProducts = Yii::$app->request->post('products_quantity'); - foreach ($bouquetProducts as $key => $value) { - $product = new BouquetCompositionProducts([ - 'bouquet_id' => $model->id, - 'product_guid' => $key, - 'count' => $value - ]); - $product->save(); + if (array_key_exists('products_quantity', $data) ) { + $bouquetProducts = Yii::$app->request->post('products_quantity'); + foreach ($bouquetProducts as $key => $value) { + $product = new BouquetCompositionProducts([ + 'bouquet_id' => $model->id, + 'product_guid' => $key, + 'count' => $value + ]); + if (!$product->save()) { + var_dump($model->getErrors()); + die(); + } + } } - } - if ($model->save()) { return $this->redirect(['view', 'id' => $model->id]); } } - - + $availableItems = ArrayHelper::map( Products1c::find() ->where([ -- 2.39.5