$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 = [];
$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);
$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 ?? '';
$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);
/////////////////////////////////////////////////////////////////////////////////////