]> gitweb.erp-flowers.ru Git - erp24_rep/yii-erp24/.git/commitdiff
ERP-282 Нужно сделать интерфейс настройки магазина
authormarina <m.zozirova@gmail.com>
Thu, 23 Jan 2025 13:31:35 +0000 (16:31 +0300)
committermarina <m.zozirova@gmail.com>
Thu, 23 Jan 2025 13:31:35 +0000 (16:31 +0300)
erp24/controllers/CityStoreParamsController.php
erp24/controllers/StoreTypeController.php [new file with mode: 0644]
erp24/views/city-store-params/index.php
erp24/views/city-store-params/view.php
erp24/views/store-type/create.php [new file with mode: 0644]
erp24/views/store-type/index.php [new file with mode: 0644]
erp24/views/store-type/update.php [new file with mode: 0644]
erp24/views/store-type/view.php [new file with mode: 0644]

index bf8df63869a8772883e4806b67439cf36c17d21c..b0565ef7b384ce23b85bd407a07d82996da0ea9a 100644 (file)
@@ -49,6 +49,9 @@ class CityStoreParamsController extends Controller
             : new CityStoreParams();
 
         if ($model->load(Yii::$app->request->post())) {
+            if (is_array($model->matrix_type)) {
+                $model->matrix_type = implode(',', $model->matrix_type);
+            }
             if ($model->validate()) {
                 $model->save();
                 return $this->redirect(['view', 'id' => $model->id]);
@@ -182,6 +185,7 @@ class CityStoreParamsController extends Controller
                 'showcaseVolume' => $params->showcase_volume ?? null,
                 'freezeArea' => $params->freeze_area ?? null,
                 'freezeVolume' => $params->freeze_volume ?? null,
+                'matrixType' => $params->matrix_type ?? 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'),
diff --git a/erp24/controllers/StoreTypeController.php b/erp24/controllers/StoreTypeController.php
new file mode 100644 (file)
index 0000000..5224912
--- /dev/null
@@ -0,0 +1,73 @@
+<?php
+
+namespace yii_app\controllers;
+
+use Yii;
+use yii\web\Controller;
+use yii\web\NotFoundHttpException;
+use yii\helpers\ArrayHelper;
+use yii_app\records\StoreType;
+
+class StoreTypeController extends Controller
+{
+    public function actionIndex()
+    {
+        $storeTypes = StoreType::find()->all();
+        return $this->render('index', [
+            'storeTypes' => $storeTypes,
+        ]);
+    }
+
+    public function actionCreate()
+    {
+        $model = new StoreType();
+
+        if ($model->load(Yii::$app->request->post()) && $model->save()) {
+            Yii::$app->session->setFlash('success', 'Тип магазина успешно создан!');
+            return $this->redirect(['index']);
+        }
+
+        return $this->render('create', [
+            'model' => $model,
+        ]);
+    }
+
+    public function actionUpdate($id)
+    {
+        $model = $this->findModel($id);
+
+        if ($model->load(Yii::$app->request->post()) && $model->save()) {
+            Yii::$app->session->setFlash('success', 'Тип магазина успешно обновлен!');
+            return $this->redirect(['index']);
+        }
+
+        return $this->render('update', [
+            'model' => $model,
+        ]);
+    }
+
+    public function actionDelete($id)
+    {
+        $this->findModel($id)->delete();
+        Yii::$app->session->setFlash('success', 'Тип магазина удален!');
+        return $this->redirect(['index']);
+    }
+
+    public function actionView($id)
+    {
+        $model = $this->findModel($id);
+
+        return $this->render('view', [
+            'model' => $model,
+        ]);
+    }
+
+    protected function findModel($id)
+    {
+        if (($model = StoreType::findOne($id)) !== null) {
+            return $model;
+        }
+
+        throw new NotFoundHttpException('Тип магазина не найден!');
+    }
+}
index 11a3db411d44ab0eda8a1cc67d8c259cbc063955..a92efd2f1ab3747cc26a6cb149344234d9f715f8 100644 (file)
@@ -27,7 +27,7 @@ $this->registerJsFile('/js/city-store-params/city-store-params.js', ['position'
                     ['prompt' => 'Выберите регион', 'class' => 'form-select', 'id' => 'address_region']);
                 ?>
                 <?= Html::a('Редактировать', [
-                    Url::to('/store_type')], ['class' => 'd-block mt-2 text-decoration-none']);
+                    Url::to('/store-city-list')], ['class' => 'd-block mt-2 text-decoration-none']);
                 ?>
             </div>
         </div>
index ca6ae92d4f7357cab1408437c8afa38adb9037e3..dbf9c58e373e6691ebac88745d65901185b5de07 100644 (file)
@@ -1,31 +1,59 @@
 <?php
 
 use yii\helpers\Html;
+use yii\widgets\DetailView;
+use yii\widgets\ActiveForm;
 
 /* @var $this yii\web\View */
-/* @var $model app\models\CityStoreParams */
+/* @var $model yii_app\records\CityStoreParams */
 
-$this->title = 'View City Store Param: ' . $model->id;
-$this->params['breadcrumbs'][] = ['label' => 'City Store Params', 'url' => ['index']];
+$this->title = "Параметры магазина: " . $model->store_id;
+$this->params['breadcrumbs'][] = ['label' => 'Параметры магазинов', 'url' => ['index']];
 $this->params['breadcrumbs'][] = $this->title;
 ?>
+
 <div class="city-store-params-view">
 
     <h1><?= Html::encode($this->title) ?></h1>
 
+    <!-- Данные о параметрах магазина -->
+    <div class="panel panel-default">
+        <div class="panel-heading">Детали параметров магазина</div>
+        <div class="panel-body">
+            <?= DetailView::widget([
+                'model' => $model,
+                'attributes' => [
+                    'id',
+                    'store_id',
+                    'stores_type',
+                    'address_city',
+                    'address_region',
+                    'address_district',
+                    'territorial_manager',
+                    'bush_chef_florist',
+                    'store_area',
+                    'showcase_volume',
+                    'freeze_area',
+                    'freeze_volume',
+                    'matrix_type',
+                    'created_by',
+                    'created_at',
+                    'updated_by',
+                    'updated_at',
+                ],
+            ]) ?>
+        </div>
+    </div>
+
     <p>
-        <?= Html::a('Update', ['update', 'id' => $model->id], ['class' => 'btn btn-primary']) ?>
+        <?= Html::a('Редактировать', ['update', 'id' => $model->id], ['class' => 'btn btn-primary']) ?>
+        <?= Html::a('Удалить', ['delete', 'id' => $model->id], [
+            'class' => 'btn btn-danger',
+            'data' => [
+                'confirm' => 'Вы уверены, что хотите удалить этот параметр магазина?',
+                'method' => 'post',
+            ],
+        ]) ?>
     </p>
 
-    <table class="table table-bordered">
-        <tr>
-            <th>ID</th>
-            <td><?= Html::encode($model->id) ?></td>
-        </tr>
-        <tr>
-            <th>Store ID</th>
-            <td><?= Html::encode($model->store_id) ?></td>
-        </tr>
-        <!-- Добавьте остальные поля по аналогии -->
-    </table>
 </div>
diff --git a/erp24/views/store-type/create.php b/erp24/views/store-type/create.php
new file mode 100644 (file)
index 0000000..d08fc28
--- /dev/null
@@ -0,0 +1,28 @@
+<?php
+
+use yii\helpers\Html;
+use yii\widgets\ActiveForm;
+
+/* @var $this yii\web\View */
+/* @var $model yii_app\records\StoreType */
+/* @var $form yii\widgets\ActiveForm */
+
+$this->title = 'Создать тип магазина';
+$this->params['breadcrumbs'][] = ['label' => 'Типы магазинов', 'url' => ['index']];
+$this->params['breadcrumbs'][] = $this->title;
+?>
+<div class="store-type-create">
+
+    <h1><?= Html::encode($this->title) ?></h1>
+
+    <?php $form = ActiveForm::begin(); ?>
+
+    <?= $form->field($model, 'name')->textInput(['maxlength' => true]) ?>
+
+    <div class="form-group">
+        <?= Html::submitButton('Сохранить', ['class' => 'btn btn-success']) ?>
+    </div>
+
+    <?php ActiveForm::end(); ?>
+
+</div>
diff --git a/erp24/views/store-type/index.php b/erp24/views/store-type/index.php
new file mode 100644 (file)
index 0000000..43c91e1
--- /dev/null
@@ -0,0 +1,44 @@
+<?php
+
+use yii\helpers\Html;
+use yii\widgets\GridView;
+
+/* @var $this yii\web\View */
+/* @var $storeTypes yii_app\records\StoreType[] */
+
+$this->title = 'Типы магазинов';
+$this->params['breadcrumbs'][] = $this->title;
+?>
+<div class="store-type-index">
+
+    <p>
+        <?= Html::a('Создать новый тип магазина', ['create'], ['class' => 'btn btn-success']) ?>
+    </p>
+
+    <?= GridView::widget([
+        'dataProvider' => new yii\data\ArrayDataProvider([
+            'allModels' => $storeTypes,
+        ]),
+        'columns' => [
+            'id',
+            'name',
+            [
+                'class' => 'yii\grid\ActionColumn',
+                'template' => '{update} {delete}',
+                'buttons' => [
+                    'update' => function ($url, $model) {
+                        return Html::a('Редактировать', ['update', 'id' => $model->id]);
+                    },
+                    'delete' => function ($url, $model) {
+                        return Html::a('Удалить', ['delete', 'id' => $model->id], [
+                            'data' => [
+                                'confirm' => 'Вы уверены, что хотите удалить этот тип магазина?',
+                                'method' => 'post',
+                            ],
+                        ]);
+                    },
+                ],
+            ],
+        ],
+    ]); ?>
+</div>
diff --git a/erp24/views/store-type/update.php b/erp24/views/store-type/update.php
new file mode 100644 (file)
index 0000000..ebbb734
--- /dev/null
@@ -0,0 +1,28 @@
+<?php
+
+use yii\helpers\Html;
+use yii\widgets\ActiveForm;
+
+/* @var $this yii\web\View */
+/* @var $model yii_app\records\StoreType */
+/* @var $form yii\widgets\ActiveForm */
+
+$this->title = 'Редактировать тип магазина: ' . $model->name;
+$this->params['breadcrumbs'][] = ['label' => 'Типы магазинов', 'url' => ['index']];
+$this->params['breadcrumbs'][] = $this->title;
+?>
+<div class="store-type-update">
+
+    <h1><?= Html::encode($this->title) ?></h1>
+
+    <?php $form = ActiveForm::begin(); ?>
+
+    <?= $form->field($model, 'name')->textInput(['maxlength' => true]) ?>
+
+    <div class="form-group">
+        <?= Html::submitButton('Сохранить', ['class' => 'btn btn-success']) ?>
+    </div>
+
+    <?php ActiveForm::end(); ?>
+
+</div>
diff --git a/erp24/views/store-type/view.php b/erp24/views/store-type/view.php
new file mode 100644 (file)
index 0000000..7c0b399
--- /dev/null
@@ -0,0 +1,40 @@
+<?php
+
+use yii\helpers\Html;
+use yii\widgets\DetailView;
+
+/* @var $this yii\web\View */
+/* @var $model yii_app\records\StoreType */
+
+$this->title = $model->name;
+$this->params['breadcrumbs'][] = ['label' => 'Типы магазинов', 'url' => ['index']];
+$this->params['breadcrumbs'][] = $this->title;
+?>
+<div class="store-type-view">
+
+    <h1><?= Html::encode($this->title) ?></h1>
+
+    <?= DetailView::widget([
+        'model' => $model,
+        'attributes' => [
+            'id',
+            'name',
+            'created_by',
+            'created_at',
+            'updated_by',
+            'updated_at',
+        ],
+    ]) ?>
+
+    <p>
+        <?= Html::a('Редактировать', ['update', 'id' => $model->id], ['class' => 'btn btn-primary']) ?>
+        <?= Html::a('Удалить', ['delete', 'id' => $model->id], [
+            'class' => 'btn btn-danger',
+            'data' => [
+                'confirm' => 'Вы уверены, что хотите удалить этот тип магазина?',
+                'method' => 'post',
+            ],
+        ]) ?>
+    </p>
+
+</div>