$post = $request->post();
$month = $post['DynamicModel']['month'] ?? 5;
$year = $post['DynamicModel']['year'] ?? 2025;
+ $storeId = $post['DynamicModel']['storeId'] ?? 2;
$model = DynamicModel::validateData(
- ['month' => $month, 'year' => $year],
+ ['month' => $month, 'year' => $year, 'storeId' => $storeId],
[
- [['month', 'year'], 'required'],
+ [['month', 'year', 'storeId'], 'required'],
['month', 'integer', 'min' => 1, 'max' => 12],
+ ['storeId', 'integer', 'min' => 1, 'max' => 100],
['year', 'integer', 'min' => 2000, 'max' => 2100],
]
);
if ($request->isPost && $model->validate()) {
$month = $model->month;
$year = $model->year;
+ $storeId = $model->storeId;
} else {
$model->month = $month;
$model->year = $year;
+ $model->storeId = $storeId;
}
- $result = StorePlanService::getBouquetSpiecesMonthGoalFromForecast($month, $year, 2);
+ $result = StorePlanService::getBouquetSpiecesMonthGoalFromForecast($month, $year, $storeId);
//var_dump($result); die();
$stores = CityStore::find()
->select(['id', 'name'])
foreach ($components as $productId => $count) {
$products[] = [
'product_guid' => $productId,
- 'count' => (int)$count,
+ 'count' => (float)$count,
];
}
}
}
foreach ($storesParams as $storeId => $regionId) {
+ if (!$regionId) {
+ if (CityStore::find()->where(['id' => $storeId])->one()->city_id == 1342) {
+ $regionId = 52;
+ } elseif (CityStore::find()->where(['id' => $storeId])->one()->city_id == 1) {
+ $regionId = 77;
+ } else {
+ $regionId = null;
+ }
+ }
+
$pricesData = ArrayHelper::map(
PricesDynamic::find()
->where(['product_id' => $productGuids])
->andWhere(['active' => 1])
- ->andWhere(['region_id' => $regionId])
+ ->andWhere(['or', ['region_id' => $regionId], ['region_id' => null]])
->select(['price', 'product_id'])
->asArray()
->all(),
<div class="month-goal-form col-4">
<?php $form = ActiveForm::begin([
- 'action' => Url::to(['bouquet/month-goal']),
+ 'action' => Url::to(['bouquet/month-goal-forecast']),
'method' => 'post',
]); ?>
<?= $form->field($model, 'month')->input('number')->label('Месяц') ?>
<?= $form->field($model, 'year')->input('number')->label('Год') ?>
+ <?= $form->field($model, 'storeId')->dropDownList($storesMap)->label('Магазин') ?>
<div class="form-group">
<?= Html::submitButton('Показать', ['class' => 'btn btn-primary']) ?>
$sum = array_sum($salesTypes);
return [
'species' => $species,
- 'offline' => $salesTypes[1] ?? 0,
- 'online' => $salesTypes[2] ?? 0,
- 'marketplace' => $salesTypes[3] ?? 0,
+ 'offline' => $salesTypes['offline'] ?? 0,
+ 'online' => $salesTypes['online'] ?? 0,
+ 'marketplace' => $salesTypes['marketplace'] ?? 0,
'sum' => $sum,
];
}, array_keys($speciesData), $speciesData),