From 3e6736342011f03935d7b430074c8ddb666f7512 Mon Sep 17 00:00:00 2001 From: fomichev Date: Tue, 8 Apr 2025 17:32:54 +0300 Subject: [PATCH] =?utf8?q?=D0=B4=D0=BE=D0=B1=D0=B0=D0=B2=D0=BB=D0=B5=D0=BD?= =?utf8?q?=D0=B8=D0=B5=20=D1=86=D0=B5=D0=BD=20=D0=B8=20=D0=B8=D1=81=D0=BF?= =?utf8?q?=D1=80=D0=B0=D0=B2=D0=BB=D0=B5=D0=BD=D0=B8=D0=B5=20=D0=BD=D0=B5?= =?utf8?q?=D0=B4=D0=B5=D0=BB=D1=8C?= MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit --- erp24/services/StorePlanService.php | 12 ++++++++---- erp24/views/category-plan/show-history-data.php | 14 ++++++++++++-- 2 files changed, 20 insertions(+), 6 deletions(-) diff --git a/erp24/services/StorePlanService.php b/erp24/services/StorePlanService.php index dd088a6d..cba51c3f 100755 --- a/erp24/services/StorePlanService.php +++ b/erp24/services/StorePlanService.php @@ -221,9 +221,11 @@ class StorePlanService $month = date('m', $prevTimestamp); $periods[$month] = []; } - // var_dump($periods); die(); + //var_dump($periods); die(); foreach ($periods as $monthKey => $month) { - for ($weekNumber = 1; $weekNumber <= 4; $weekNumber++) { + $days = cal_days_in_month(CAL_GREGORIAN, (int)$monthKey, (int)$year); + $weeks = $days > 28 ? 5 : 4; + for ($weekNumber = 1; $weekNumber <= $weeks; $weekNumber++) { $range = Motivation::getWeekRange(null, $weekNumber, (int)$monthKey, $year); $periods[$monthKey][$weekNumber - 1] = $range; } @@ -286,7 +288,7 @@ class StorePlanService } else { $weekData = []; $activeWeeks = 0; - for ($weekIndex = 0; $weekIndex < 4; $weekIndex++) { + for ($weekIndex = 0; $weekIndex < 5; $weekIndex++) { $salesCount = isset($monthsData[$monthKey][$weekIndex]) ? $monthsData[$monthKey][$weekIndex] : 0; $weekData[$weekIndex] = $salesCount; if ($salesCount > 0) { @@ -450,7 +452,6 @@ class StorePlanService */ public static function getPriceForProductAndMonth($productId, $year, $month) { - // Для проверки возьмем первый день месяца $dateToCheck = "$year-$month-01"; $priceRecord = PricesDynamic::find() ->where(['product_id' => $productId, 'active' => 1]) @@ -513,6 +514,7 @@ class StorePlanService $monthlySales = []; $monthlyWeighted = []; $weightedSum = 0; + $monthlyPrice = []; foreach ($weightedMonths as $mInfo) { $mKey = $mInfo['month']; @@ -522,12 +524,14 @@ class StorePlanService $monthlySales[$mKey] = $sales; $weightedValue = $sales * $price * $mInfo['weight']; $monthlyWeighted[$mKey] = $weightedValue; + $monthlyPrice[$mKey] = $price; $weightedSum += $weightedValue; } $productsData[$guid] = [ 'monthlySales' => $monthlySales, 'monthlyWeighted' => $monthlyWeighted, 'weightedSum' => $weightedSum, + 'monthlyPrice' => $monthlyPrice, ]; $globalTotal += $weightedSum; } diff --git a/erp24/views/category-plan/show-history-data.php b/erp24/views/category-plan/show-history-data.php index bd79da79..76c07f36 100644 --- a/erp24/views/category-plan/show-history-data.php +++ b/erp24/views/category-plan/show-history-data.php @@ -4,6 +4,7 @@ use yii\helpers\ArrayHelper; use yii\widgets\ActiveForm; use yii\base\DynamicModel; use yii_app\records\CityStore; +use yii_app\records\PricesDynamic; use yii_app\records\Products1c; use yii_app\records\Products1cNomenclature; @@ -205,9 +206,18 @@ JS; - where(['product_id' => $product['guid']]) - ->andWhere(['active' => 1])->one()->price) * + ->andWhere(['active' => 1]); + if (CityStore::find()->where(['id' => $model->storeId])->one()->city_id == 1342) { + $region = 52; + } elseif (CityStore::find()->where(['id' => $model->storeId])->one()->city_id == 1) { + $region = 77; + } else { + $region = null; + } + $price = $query->andWhere(['region_id' => $region])->one()->price;?> + -- 2.39.5