: 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]);
'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'),
--- /dev/null
+<?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('Тип магазина не найден!');
+ }
+}
['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>
<?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>
--- /dev/null
+<?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>
--- /dev/null
+<?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>
--- /dev/null
+<?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>
--- /dev/null
+<?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>