From: Vladimir Fomichev Date: Wed, 30 Jul 2025 14:38:13 +0000 (+0300) Subject: Заполнение данных активности X-Git-Url: https://gitweb.erp-flowers.ru/?a=commitdiff_plain;h=dab39ca8d108b0ef0f7d77818193578caf559daa;p=erp24_rep%2Fyii-erp24%2F.git Заполнение данных активности --- diff --git a/erp24/controllers/Products1cNomenclatureActualityController.php b/erp24/controllers/Products1cNomenclatureActualityController.php index 196d785d..4bf97e1a 100644 --- a/erp24/controllers/Products1cNomenclatureActualityController.php +++ b/erp24/controllers/Products1cNomenclatureActualityController.php @@ -214,22 +214,20 @@ class Products1cNomenclatureActualityController extends Controller { $request = Yii::$app->request; - if (!$request->get('historyDays') || !$request->get('intervalMonths')) { + $historyDays = $request->get('historyDays'); + $intervalMonths = $request->get('intervalMonths'); + + + if ($historyDays === null || $intervalMonths === null) { return $this->render('add-activity', [ 'historyDays' => $historyDays ?? 14, 'intervalMonths' => $intervalMonths ?? 4, ]); } - $historyDays = (int)$request->get('historyDays'); - $intervalMonths = (int)$request->get('intervalMonths'); - $endDate = date('Y-m-d'); $startDate = date('Y-m-d', strtotime("-{$historyDays} days", strtotime($endDate))); - $storeIds = array_map(fn($s) => $s->id, $this->getVisibleStores()); - $countStores = count($storeIds); - $productIds = (new Query()) ->select('sp.product_id') ->from(['s' => 'sales']) @@ -240,7 +238,7 @@ class Products1cNomenclatureActualityController extends Controller ->groupBy('sp.product_id') //->having(['=', new \yii\db\Expression('COUNT(DISTINCT s.store_id)'), $countStores]) ->column(); - var_dump($productIds); die(); + if (empty($productIds)) { Yii::$app->session->setFlash('info', 'Нет товаров, удовлетворяющих условиям.'); return $this->render('add-activity', [ diff --git a/erp24/views/products1c-nomenclature-actuality/add-activity.php b/erp24/views/products1c-nomenclature-actuality/add-activity.php index 035f02d2..06ebb09f 100644 --- a/erp24/views/products1c-nomenclature-actuality/add-activity.php +++ b/erp24/views/products1c-nomenclature-actuality/add-activity.php @@ -11,25 +11,18 @@ $this->title = 'Заполнить актуальность';

title) ?>

- 'get', - 'action' => ['add-activity'], - 'options' => ['class' => 'form-inline'], -]); ?> + 'get', + 'action'=>['add-activity'], + ]); ?> + + + 1, 'class'=>'form-control']) ?> + + + 1, 'class'=>'form-control']) ?> + + 'btn btn-success mt-3']) ?> -
-
- field(new \yii\base\DynamicModel(['historyDays'=>$historyDays]), 'historyDays') - ->textInput(['type'=>'number','min'=>1,'value'=>$historyDays]) - ->label('История (дней)') ?> -
-
- field(new \yii\base\DynamicModel(['intervalMonths'=>$intervalMonths]), 'intervalMonths') - ->textInput(['type'=>'number','min'=>1,'value'=>$intervalMonths]) - ->label('Интервал (месяцы)') ?> -
-
- 'btn btn-success']) ?> -
\ No newline at end of file