From: fomichev Date: Fri, 4 Jul 2025 13:25:25 +0000 (+0300) Subject: Другие правки ошибок - отсутствие плана на магазин X-Git-Url: https://gitweb.erp-flowers.ru/?a=commitdiff_plain;h=94cba3b7008ceb989ac55896de3e37fd972d1e7e;p=erp24_rep%2Fyii-erp24%2F.git Другие правки ошибок - отсутствие плана на магазин --- 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); /////////////////////////////////////////////////////////////////////////////////////