From 2b1e510031ea8e4ac49740224960d2423938adf1 Mon Sep 17 00:00:00 2001 From: marina Date: Thu, 23 Jan 2025 09:56:50 +0300 Subject: [PATCH] =?utf8?q?ERP-282=20=D0=9D=D1=83=D0=B6=D0=BD=D0=BE=20?= =?utf8?q?=D1=81=D0=B4=D0=B5=D0=BB=D0=B0=D1=82=D1=8C=20=D0=B8=D0=BD=D1=82?= =?utf8?q?=D0=B5=D1=80=D1=84=D0=B5=D0=B9=D1=81=20=D0=BD=D0=B0=D1=81=D1=82?= =?utf8?q?=D1=80=D0=BE=D0=B9=D0=BA=D0=B8=20=D0=BC=D0=B0=D0=B3=D0=B0=D0=B7?= =?utf8?q?=D0=B8=D0=BD=D0=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit --- .../controllers/CityStoreParamsController.php | 15 +- erp24/records/MatrixType.php | 73 ++++ erp24/records/StoreType.php | 74 ++++ erp24/views/city-store-params/index.php | 344 +++++++++--------- 4 files changed, 334 insertions(+), 172 deletions(-) create mode 100644 erp24/records/MatrixType.php create mode 100644 erp24/records/StoreType.php diff --git a/erp24/controllers/CityStoreParamsController.php b/erp24/controllers/CityStoreParamsController.php index 78436dd6..c6df8606 100644 --- a/erp24/controllers/CityStoreParamsController.php +++ b/erp24/controllers/CityStoreParamsController.php @@ -11,6 +11,7 @@ use yii\web\NotFoundHttpException; use yii\filters\VerbFilter; use yii\web\Response; use yii_app\records\Admin; +use yii_app\records\AdminGroup; use yii_app\records\City; use yii_app\records\CityStore; use yii_app\records\CityStoreParams; @@ -18,6 +19,7 @@ use yii_app\records\Cluster; use yii_app\records\ClusterAdmin; use yii_app\records\StoreCityList; use yii_app\records\StoreDynamic; +use yii_app\records\StoreType; /** * CityStoreParamsController реализует CRUD для модели CityStoreParams. @@ -171,6 +173,12 @@ class CityStoreParamsController extends Controller $freezeArea = CityStoreParams::findOne($storeId)->freeze_area ?? null; $freezeVolume = CityStoreParams::findOne($storeId)->freeze_volume ?? null; + $storeTypeArray = ArrayHelper::map(StoreType::find()->all(), 'id', 'name'); + $regionArray = ArrayHelper::map(StoreCityList::findAll(['type' => StoreCityList::TYPE_REGION]), 'id', 'name'); + $cityArray = ArrayHelper::map(StoreCityList::findAll(['type' => StoreCityList::TYPE_CITY]), 'id', 'name'); + $districtArray = ArrayHelper::map(StoreCityList::findAll(['type' => StoreCityList::TYPE_DISTRICT]), 'id', 'name'); + $bushChefFloristArray = ArrayHelper::map(Admin::findAll(['group_id' => AdminGroup::GROUP_BUSH_CHEF_FLORIST]), 'id', 'name'); + return [ 'success' => true, 'data' => [ @@ -184,7 +192,12 @@ class CityStoreParamsController extends Controller 'storeArea' => $storeArea, 'showcaseVolume' => $showcaseVolume, 'freezeArea' => $freezeArea, - 'freezeVolume' => $freezeVolume + 'freezeVolume' => $freezeVolume, + 'storeTypeArray' => $storeTypeArray, + 'regionArray' => $regionArray, + 'cityArray' => $cityArray, + 'districtArray' => $districtArray, + 'bushChefFloristArray' => $bushChefFloristArray, ], ]; } diff --git a/erp24/records/MatrixType.php b/erp24/records/MatrixType.php new file mode 100644 index 00000000..98faee6c --- /dev/null +++ b/erp24/records/MatrixType.php @@ -0,0 +1,73 @@ + TimestampBehavior::class, + 'createdAtAttribute' => 'created_at', + 'updatedAtAttribute' => 'updated_at', + 'value' => new Expression('NOW()'), + ], + [ + 'class' => BlameableBehavior::class, + 'createdByAttribute' => 'created_by', + 'updatedByAttribute' => 'updated_by', + ], + ]; + } + + /** + * {@inheritdoc} + */ + public function rules() + { + return [ + [['name', 'created_by', 'created_at'], 'required'], + [['created_by', 'updated_by'], 'integer'], + [['created_at', 'updated_at'], 'safe'], + [['name'], 'string', 'max' => 255], + ]; + } + + /** + * {@inheritdoc} + */ + public function attributeLabels() + { + return [ + 'id' => 'ID', + 'name' => 'Название типа матрицы', + 'created_by' => 'ИД создателя', + 'created_at' => 'Дата создания', + 'updated_by' => 'ИД редактировавшего', + 'updated_at' => 'Дата обновления', + ]; + } +} diff --git a/erp24/records/StoreType.php b/erp24/records/StoreType.php new file mode 100644 index 00000000..f08f7e43 --- /dev/null +++ b/erp24/records/StoreType.php @@ -0,0 +1,74 @@ + TimestampBehavior::class, + 'createdAtAttribute' => 'created_at', + 'updatedAtAttribute' => 'updated_at', + 'value' => new Expression('NOW()'), + ], + [ + 'class' => BlameableBehavior::class, + 'createdByAttribute' => 'created_by', + 'updatedByAttribute' => 'updated_by', + ], + ]; + } + + /** + * {@inheritdoc} + */ + public function rules() + { + return [ + [['name', 'created_by', 'created_at'], 'required'], + [['created_by', 'updated_by'], 'integer'], + [['created_at', 'updated_at'], 'safe'], + [['name'], 'string', 'max' => 255], + ]; + } + + /** + * {@inheritdoc} + */ + public function attributeLabels() + { + return [ + 'id' => 'ID', + 'name' => 'Название типа магазина', + 'created_by' => 'ИД создателя', + 'created_at' => 'Дата создания', + 'updated_by' => 'ИД редактировавшего', + 'updated_at' => 'Дата обновления', + ]; + } +} diff --git a/erp24/views/city-store-params/index.php b/erp24/views/city-store-params/index.php index 1992e827..921c2f29 100644 --- a/erp24/views/city-store-params/index.php +++ b/erp24/views/city-store-params/index.php @@ -8,6 +8,7 @@ use yii_app\records\Admin; use yii_app\records\AdminGroup; use yii_app\records\City; use yii_app\records\StoreCityList; +use yii_app\records\StoreType; /* @var $this yii\web\View */ /* @var $dataProvider yii\data\ActiveDataProvider */ @@ -17,211 +18,212 @@ $this->params['breadcrumbs'][] = $this->title; $this->registerJsFile('/js/city-store-params/city-store-params.js', ['position' => \yii\web\View::POS_END]); ?> -
-
- -
-
- StoreCityList::TYPE_REGION]), 'id', 'name'), - ['prompt' => 'Выберите регион', 'class' => 'form-select', 'id' => 'address_region']); - ?> - 'd-block mt-2 text-decoration-none']); - ?> -
- +
+
+ +
+
+ StoreCityList::TYPE_REGION]), 'id', 'name'), + ['prompt' => 'Выберите регион', 'class' => 'form-select', 'id' => 'address_region']); + ?> + 'd-block mt-2 text-decoration-none']); + ?>
-
-
- StoreCityList::TYPE_CITY]), 'id', 'name'), - ['prompt' => 'Выберите город', 'class' => 'form-select', 'id' => 'address_city']); - ?> -
+ +
+
+
+ StoreCityList::TYPE_CITY]), 'id', 'name'), + ['prompt' => 'Выберите город', 'class' => 'form-select', 'id' => 'address_city']); + ?>
+
-
-
- StoreCityList::TYPE_DISTRICT]), 'id', 'name'), - ['prompt' => 'Выберите район', 'class' => 'form-select', 'id' => 'address_district']); - ?> -
+
+
+ StoreCityList::TYPE_DISTRICT]), 'id', 'name'), + ['prompt' => 'Выберите район', 'class' => 'form-select', 'id' => 'address_district']); + ?>
+
-
-
- where(['!=', 'region_name', ''])->all(), 'id_region', 'region_name'), - ['prompt' => 'Выберите тип магазина', 'class' => 'form-select', 'id' => 'store_type']); - ?> - 'd-block mt-2 text-decoration-none']); ?> -
+
+
+ all(), 'id', 'name'), + ['prompt' => 'Выберите тип магазина', 'class' => 'form-select', 'id' => 'store_type']); + ?> + 'd-block mt-2 text-decoration-none']); ?>
+
-
-
- AdminGroup::GROUP_BUSH_DIRECTOR]), 'id', 'name_full'), - ['prompt' => 'Выберите территориального управляющего', 'class' => 'form-select', 'id' => 'territorial_manager']); - ?> -
+
+
+ AdminGroup::GROUP_BUSH_DIRECTOR]), 'id', 'name_full'), + ['prompt' => 'Выберите территориального управляющего', 'class' => 'form-select', 'id' => 'territorial_manager']); + ?>
+
-
-
+
+
-
+
-
+
-
-
- \yii_app\records\AdminGroup::GROUP_BUSH_CHEF_FLORIST]), 'id', 'name_full'), - ['prompt' => 'Выберите кустового шеф флориста', 'class' => 'form-select', 'id' => 'bush_chef_florist']); - ?> -
+
+
+ \yii_app\records\AdminGroup::GROUP_BUSH_CHEF_FLORIST]), 'id', 'name_full'), + ['prompt' => 'Выберите кустового шеф флориста', 'class' => 'form-select', 'id' => 'bush_chef_florist']); + ?>
+
-
+
-
-
- 'btn btn-primary w-100', 'id' => 'apply-button']); ?> -
+
+
+ 'btn btn-primary w-100', 'id' => 'apply-button']); ?>
- - -
-
-
-
- true, - 'size' => 16, - 'class' => 'form-control', - 'id' => 'selected-store', - ]) ?> - 'btn btn-primary w-100', 'id' => 'edit-button']); ?> -
+
+ + +
+
+
+
+ true, + 'size' => 16, + 'class' => 'form-control', + 'id' => 'selected-store', + ]) ?> + 'btn btn-primary w-100 mt-2 py-1', 'id' => 'edit-button']); ?>
-
-
-
-
- - 'store-name', 'class' => 'h5']); ?> -
-
- AdminGroup::GROUP_BUSH_DIRECTOR]), 'id', 'name_full'), - ['prompt' => 'Тип магазина', 'class' => 'form-select', 'id' => 'store_type']); ?> - 'd-block mt-2 text-decoration-none']); ?> -
+
+
+
+
+
+ + 'store-name', 'class' => 'h5']); ?>
-
-
- -
-
- - 'Регион', 'class' => 'form-select', 'id' => 'region']); ?> -
-
- - 'Город', 'class' => 'form-select', 'id' => 'city']); ?> -
-
- - 'Район', 'class' => 'form-select', 'id' => 'district']); ?> -
+
+ all(), 'id', 'name'), + ['prompt' => 'Тип магазина', 'class' => 'form-select', 'id' => 'store_type']); ?> + 'd-block mt-2 text-decoration-none']); ?>
-
-
- - 'd-block mb-5 text-decoration-none']); ?> - -
-
- 'territorial-manager', 'class' => 'h5']); ?> -
+
+
+
+ +
+
+ + 'Регион', 'class' => 'form-select', 'id' => 'region']); ?>
-
-
- - 'd-block mb-5 text-decoration-none']); ?> +
+ + 'Город', 'class' => 'form-select', 'id' => 'city']); ?> +
+
+ + 'Район', 'class' => 'form-select', 'id' => 'district']); ?> +
+
+
+
+ + 'd-block mb-5 text-decoration-none']); ?> -
-
- 'Кустовой шеф-флорист', 'class' => 'form-select', 'id' => 'bush-chef-florist']); ?> -
-
-
- 'form-label']); ?> - 'store-area', - 'class' => 'form-control', - 'placeholder' => 'Введите число', - 'oninput' => 'validateDecimal(this)' - ]); ?> +
+ 'territorial-manager', 'class' => 'h5']); ?> +
+
+
+
+ + 'd-block mb-5 text-decoration-none']); ?> - 'form-label']); ?> - 'showcase-volume', - 'class' => 'form-control', - 'placeholder' => 'Введите число', - 'oninput' => 'validateDecimal(this)' - ]); ?> +
+
+ 'Кустовой шеф-флорист', 'class' => 'form-select', 'id' => 'bush-chef-florist']); ?> +
+
+
+
+ 'form-label']); ?> + 'store-area', + 'class' => 'form-control', + 'placeholder' => 'Введите число', + 'oninput' => 'validateDecimal(this)' + ]); ?> + + 'form-label']); ?> + 'showcase-volume', + 'class' => 'form-control', + 'placeholder' => 'Введите число', + 'oninput' => 'validateDecimal(this)' + ]); ?> + + 'form-label']); ?> + 'freeze-area', + 'class' => 'form-control', + 'placeholder' => 'Введите число', + 'oninput' => 'validateDecimal(this)' + ]); ?> + + 'form-label']); ?> + 'freeze-volume', + 'class' => 'form-control', + 'placeholder' => 'Введите число', + 'oninput' => 'validateDecimal(this)' + ]); ?> +
- 'form-label']); ?> - 'freeze-area', - 'class' => 'form-control', - 'placeholder' => 'Введите число', - 'oninput' => 'validateDecimal(this)' - ]); ?> - 'form-label']); ?> - 'freeze-volume', - 'class' => 'form-control', - 'placeholder' => 'Введите число', - 'oninput' => 'validateDecimal(this)' +
+
+ 'matrix_type', + 'items' => ArrayHelper::map(\yii_app\records\MatrixType::find()->all(), 'id', 'name'), + 'options' => [ + 'size' => false + ], + 'clientOptions' => [ + 'moveOnSelect' => false, + 'nonSelectedListLabel' => "Тип матрицы
" . Html::a('Редактировать', '#'), + 'selectedListLabel' => " 

", + 'showFilterInputs' => false, + 'clearButton' => false, + ], ]); ?>
- - -
-
- 'matrix_type', - 'items' => [], - 'options' => [ - 'size' => false - ], - 'clientOptions' => [ - 'moveOnSelect' => false, - 'nonSelectedListLabel' => "Тип матрицы
" . Html::a('Редактировать', '#'), - 'selectedListLabel' => " 

", - 'showFilterInputs' => false, - 'clearButton' => false, - ], - ]); ?> -
-
+
+
+ 'btn btn-success btn']) ?>
+
- - - -- 2.39.5