From 94cba3b7008ceb989ac55896de3e37fd972d1e7e Mon Sep 17 00:00:00 2001 From: fomichev Date: Fri, 4 Jul 2025 16:25:25 +0300 Subject: [PATCH] =?utf8?q?=D0=94=D1=80=D1=83=D0=B3=D0=B8=D0=B5=20=D0=BF?= =?utf8?q?=D1=80=D0=B0=D0=B2=D0=BA=D0=B8=20=D0=BE=D1=88=D0=B8=D0=B1=D0=BE?= =?utf8?q?=D0=BA=20-=20=D0=BE=D1=82=D1=81=D1=83=D1=82=D1=81=D1=82=D0=B2?= =?utf8?q?=D0=B8=D0=B5=20=D0=BF=D0=BB=D0=B0=D0=BD=D0=B0=20=D0=BD=D0=B0=20?= =?utf8?q?=D0=BC=D0=B0=D0=B3=D0=B0=D0=B7=D0=B8=D0=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit --- erp24/controllers/CategoryPlanController.php | 28 +++++++++++++++++--- 1 file changed, 24 insertions(+), 4 deletions(-) diff --git a/erp24/controllers/CategoryPlanController.php b/erp24/controllers/CategoryPlanController.php index d61d7c08..c9f47be3 100644 --- a/erp24/controllers/CategoryPlanController.php +++ b/erp24/controllers/CategoryPlanController.php @@ -51,7 +51,7 @@ class CategoryPlanController extends Controller { $service = new AutoPlannogrammaService(); $isEditable = date($model->year . '-' . $model->month . '-d') > date('Y-m-d') && ( - (date('d') < 27) || (date('Y-m-d', strtotime('-1 month', strtotime(date($model->year . '-' . $model->month . '-d')))) > date('Y-m-d'))); + (date('d') < 27) || (date('Y-m-d', strtotime('-2 month', strtotime(date($model->year . '-' . $model->month . '-d')))) > date('Y-m-d'))); //$isEditable = true; $categoryPlan = CategoryPlan::find()->where(['year' => $model->year, 'month' => $model->month, 'store_id' => $model->store_id])->indexBy('category')->asArray()->all(); $types = []; @@ -159,8 +159,13 @@ class CategoryPlanController extends Controller { $types[$saleMatrix['type']] = 1; $table[$saleMatrix['store_id']][$saleMatrix['type']] = ($table[$saleMatrix['store_id']][$saleMatrix['type']] ?? 0) + $weights[$saleMatrix['month']] * $saleMatrix['total'] ; } + if (!empty($salesWriteOffsPlan->offline_sales_plan)) { + $offlinePlannedSales = self::calculatePlannedSales($table, $salesWriteOffsPlan->offline_sales_plan); + } else { + $offlinePlannedSales = []; + Yii::$app->session->setFlash('error', 'Не установлен план для магазина'); + } - $offlinePlannedSales = self::calculatePlannedSales($table, $salesWriteOffsPlan->offline_sales_plan); $salesOnline = $service->getMonthCategoryShareOrWriteOff($currentDate->format('Y-m-d'), ['sales_type' => 'online', 'store_id' => $model->store_id], AutoPlannogrammaService::TYPE_SALES); @@ -196,7 +201,14 @@ class CategoryPlanController extends Controller { $tableOnline[$saleMatrix['store_id']][$saleMatrix['type']] = ($tableOnline[$saleMatrix['store_id']][$saleMatrix['type']] ?? 0) + $weights[$saleMatrix['month']] * $saleMatrix['total'] ; } - $onlinePlannedSales = self::calculatePlannedSales($tableOnline, $salesWriteOffsPlan->online_sales_shop_plan); + + if (!empty($salesWriteOffsPlan->online_sales_shop_plan)) { + $onlinePlannedSales = self::calculatePlannedSales($tableOnline, $salesWriteOffsPlan->online_sales_shop_plan); + } else { + $onlinePlannedSales = []; + Yii::$app->session->setFlash('error', 'Не установлен план для магазина'); + } + $eit = ExportImportTable::find()->where(['entity' => 'city_store', 'export_id' => 1, 'entity_id' => $model->store_id])->one(); $store_id = $eit->export_val ?? ''; @@ -233,7 +245,15 @@ class CategoryPlanController extends Controller { $tableWriteOffs[$writeOffMatrix['store_id']][$writeOffMatrix['p1ctype']] = ($tableWriteOffs[$writeOffMatrix['store_id']][$writeOffMatrix['p1ctype']] ?? 0) + $weights[$writeOffMatrix['month']] * $writeOffMatrix['total']; } - $plannedWriteOffs = self::calculatePlannedSales($tableWriteOffs, $salesWriteOffsPlan->write_offs_plan); + + if (!empty($salesWriteOffsPlan->write_offs_plan)) { + $plannedWriteOffs = self::calculatePlannedSales($tableWriteOffs, $salesWriteOffsPlan->write_offs_plan); + } else { + $plannedWriteOffs = []; + Yii::$app->session->setFlash('error', 'Не установлен план для магазина'); + } + + $types = array_keys($types); ///////////////////////////////////////////////////////////////////////////////////// -- 2.39.5