From: Alexander Smirnov Date: Thu, 22 Aug 2024 15:42:45 +0000 (+0300) Subject: [ERP-152] Доработка отдела storage X-Git-Tag: 1.5~30^2~1 X-Git-Url: https://gitweb.erp-flowers.ru/?a=commitdiff_plain;h=b9f8b9c8f1099c3421cb86e4b4c2af8e79473623;p=erp24_rep%2Fyii-erp24%2F.git [ERP-152] Доработка отдела storage --- diff --git a/erp24/actions/storage/AjaxBalancesInGroupAction.php b/erp24/actions/storage/AjaxBalancesInGroupAction.php new file mode 100644 index 00000000..0a9c9d05 --- /dev/null +++ b/erp24/actions/storage/AjaxBalancesInGroupAction.php @@ -0,0 +1,23 @@ +request->post('store_id'); + $parent_id = Yii::$app->request->post('parent_id'); + + $data = Products1c::find()->alias('p1c')->select(['p1c.name as name', 'p.price as price', 'b.quantity as quantity', 'b.reserv as reserv']) + ->leftJoin('prices p', 'p.product_id = p1c.id')->leftJoin('balances b', 'b.store_id = \'' . $store_id . '\' and b.product_id = p1c.id') + ->where(['p1c.tip' => 'products'])->andWhere(['p1c.parent_id' => $parent_id]) + ->asArray()->all(); + + return $this->controller->renderPartial('ajax-balances-in-group', + compact('data')); + } +} \ No newline at end of file diff --git a/erp24/actions/storage/IndexAction.php b/erp24/actions/storage/IndexAction.php new file mode 100644 index 00000000..27678bb5 --- /dev/null +++ b/erp24/actions/storage/IndexAction.php @@ -0,0 +1,33 @@ + null], [['store_id', 'safe']]); + + $model->load(Yii::$app->request->get()); + + $products1c = null; + if ($model->store_id) { + $products1c = Products1c::find()->where(['id' => $model->store_id])->one(); + } + + $stores = ArrayHelper::map(Products1c::find()->where(['tip' => 'city_store', 'view' => 1])->orderBy(['name' => SORT_ASC])->all(),"id", "name"); + + $products = ArrayHelper::map(Products1c::find()->where(['tip' => 'products'])->all(),"id", "name"); + + $balances = Balances::find()->select(['product_id', 'quantity', 'reserv'])->where(['store_id' => $model->store_id])->orderBy(['quantity' => SORT_DESC])->all(); + + return $this->controller->render('index', + compact('products1c', 'stores', 'model', 'products', 'balances')); + } +} \ No newline at end of file diff --git a/erp24/actions/storage/StoreAction.php b/erp24/actions/storage/StoreAction.php new file mode 100644 index 00000000..79cdf3e1 --- /dev/null +++ b/erp24/actions/storage/StoreAction.php @@ -0,0 +1,37 @@ + null], [['store_id', 'safe']]); + + $model->load(Yii::$app->request->get()); + + $products1c = null; + if ($model->store_id) { + $products1c = Products1c::find()->where(['id' => $model->store_id])->one(); + } + + $stores = ArrayHelper::map(Products1c::find()->where(['tip' => 'city_store', 'view' => 1])->orderBy(['name' => SORT_ASC])->all(),"id", "name"); + + $productGroups = Products1c::find()->where(['tip' => 'products_group', 'view' => 1])->orderBy(['name' => SORT_ASC])->all(); + $groups = ArrayHelper::map($productGroups, 'id', 'name'); + $groups_arr = []; + foreach ($productGroups as $productGroup) { + $groups_arr[$productGroup->parent_id][$productGroup->id] = $productGroup; + } + + + return $this->controller->render('store', + compact('model', 'stores', 'products1c', 'groups_arr')); + } +} \ No newline at end of file diff --git a/erp24/controllers/StorageController.php b/erp24/controllers/StorageController.php index dc4dda8e..a7196a22 100644 --- a/erp24/controllers/StorageController.php +++ b/erp24/controllers/StorageController.php @@ -6,7 +6,12 @@ use yii\web\Controller; class StorageController extends Controller { - public function actionIndex() { return $this->render('index'); } - public function actionStore() { return $this->render('store'); } - public function actionAjaxBalancesInGroup() { return $this->renderPartial('ajax-balances-in-group'); } + public function actions() + { + return [ + 'index' => \yii_app\actions\storage\IndexAction::class, + 'store' => \yii_app\actions\storage\StoreAction::class, + 'ajax-balances-in-group' => \yii_app\actions\storage\AjaxBalancesInGroupAction::class, + ]; + } } \ No newline at end of file diff --git a/erp24/views/storage/ajax-balances-in-group.php b/erp24/views/storage/ajax-balances-in-group.php index 26b42f0d..3c307306 100644 --- a/erp24/views/storage/ajax-balances-in-group.php +++ b/erp24/views/storage/ajax-balances-in-group.php @@ -1,5 +1,24 @@ + + + + + + + + + + + +
+ + + () + + + +
\ No newline at end of file diff --git a/erp24/views/storage/index.php b/erp24/views/storage/index.php index 095d8314..e61610d0 100644 --- a/erp24/views/storage/index.php +++ b/erp24/views/storage/index.php @@ -1,5 +1,73 @@ + +
+ + + + 'GET', "action" => "/storage"]) ?> + +
+
+ field($model, 'store_id')->widget(Select2::class, [ + 'data' => $stores, + 'language' => 'ru', + 'options' => ['placeholder' => 'Магазин...', 'onchange' => 'this.form.submit()'], + 'pluginOptions' => [ + 'allowClear' => true + ], + ])->label(false) ?> +
+
+ + + + 'btn btn-info']) ?> + + +
+
+
+ + + + + + + + + + + + + + + + + +
ОстатокРезервНаименование
+ quantity ?> + + reserv ?> + + product_id] ?> +
+
+
+
+ + +
diff --git a/erp24/views/storage/store.php b/erp24/views/storage/store.php index 4a1249c8..1c6ce732 100644 --- a/erp24/views/storage/store.php +++ b/erp24/views/storage/store.php @@ -1,5 +1,83 @@ '; + if (!$only_parent) { + foreach ($cats[$parent_id] as $cat) { + $tree .= '
  • '; + $tree .= ''; + + $tree .= '
    + + '.$cat['name'].' +
    '; + $tree .= build_tree($cats, $cat['id'], $store_id); + $tree .= '
  • '; + } + } + $tree .= ''; + return $tree; + } + return null; +} + +?> + +
    + + 'GET', "action" => "/storage/store"]) ?> + +
    +
    + field($model, 'store_id')->widget(Select2::class, [ + 'data' => $stores, + 'language' => 'ru', + 'options' => ['placeholder' => 'Магазин...', 'onchange' => 'this.form.submit()'], + 'pluginOptions' => [ + 'allowClear' => true + ], + ])->label(false) ?> +
    +
    + + + + +

    Остатки в 1с name ?>

    +
    +
    + id) ?> +
    +
    + +
    + + \ No newline at end of file