From: vladfo Date: Tue, 8 Oct 2024 12:53:33 +0000 (+0300) Subject: Добавлена страница с магазинами в меню X-Git-Tag: 1.6~30^2~12 X-Git-Url: https://gitweb.erp-flowers.ru/?a=commitdiff_plain;h=abad492c08e9d7673208770c8697e2c22d7a2715;p=erp24_rep%2Fyii-erp24%2F.git Добавлена страница с магазинами в меню --- diff --git a/erp24/controllers/StoreController.php b/erp24/controllers/StoreController.php index 20666274..71cfe336 100755 --- a/erp24/controllers/StoreController.php +++ b/erp24/controllers/StoreController.php @@ -2,10 +2,29 @@ namespace app\controllers; +use yii\data\ActiveDataProvider; use yii\web\Controller; +use yii_app\records\CityStore; class StoreController extends Controller { public function actionStats() { return $this->render('stats'); } + + public function actionIndex() + { + // Создаем DataProvider, чтобы получить магазины, у которых visible = 1 + $dataProvider = new ActiveDataProvider([ + 'query' => CityStore::find() + ->where(['visible' => 1]) + ->with(['city', 'cluster', 'administrator']), // Загружаем связанные данные + 'pagination' => [ + 'pageSize' => 20, + ], + ]); + + return $this->render('index', [ + 'dataProvider' => $dataProvider, + ]); + } public function actionItemmatrix() { return $this->render('itemmatrix'); } } \ No newline at end of file diff --git a/erp24/records/CityStore.php b/erp24/records/CityStore.php index 3e32d5b0..f5da7e8f 100755 --- a/erp24/records/CityStore.php +++ b/erp24/records/CityStore.php @@ -337,4 +337,20 @@ class CityStore extends ActiveRecord return $query; } + + public function getCity() + { + return $this->hasOne(City::class, ['id_city' => 'city_id']); + } + + public function getCluster() + { + return $this->hasOne(Cluster::class, ['id' => 'cluster_id']); + } + + public function getAdministrator() + { + return $this->hasOne(Admin::class, ['id' => 'administrator_id']); + } + } \ No newline at end of file diff --git a/erp24/views/store/index.php b/erp24/views/store/index.php new file mode 100644 index 00000000..cc2e939f --- /dev/null +++ b/erp24/views/store/index.php @@ -0,0 +1,90 @@ +title = 'Список магазинов'; +$this->params['breadcrumbs'][] = $this->title; +?> +
+ +

title) ?>

+ +

+ 'btn btn-success']) ?> +

+ + $dataProvider, + 'columns' => [ + ['class' => 'yii\grid\SerialColumn'], + + [ + 'attribute' => 'name', + 'label' => 'Наименование магазина', + ], + [ + 'attribute' => 'city.city_name_ru', + 'label' => 'Город', + 'value' => function ($model) { + return $model->city ? $model->city->city_name_ru : '(Не указан)'; + }, + ], + [ + 'attribute' => 'cluster.name', + 'label' => 'Куст', + 'value' => function ($model) { + return $model->cluster ? $model->cluster->name : '(Не указан)'; + }, + ], + [ + 'attribute' => 'administrator.name', + 'label' => 'Администратор', + 'value' => function ($model) { + return $model->administrator ? $model->administrator->name : '(Не указан)'; + }, + ], + + [ + 'class' => 'yii\grid\ActionColumn', + 'template' => '{view} {update}', // Убираем действие удаления + 'buttons' => [ + 'view' => function ($url, $model, $key) { + + return Html::a(Html::img('@web/images/icon-view.svg', ['alt' => 'View Icon', 'style' => 'width: 1em; height: 1em; display: inline-block; vertical-align: -0.125em;']), [ + '/city-store/view', + 'id' => $model->id, + + ], [ + 'class' => 'btn btn-primary btn-sm', + 'title' => 'Просмотр', + 'data-bs-toggle' => 'tooltip', // Подсказка на иконке + 'data-bs-placement' => 'top', + ]); + + + }, + 'update' => function ($url, $model, $key) { + + return Html::a(Html::img('@web/images/icon-edit.svg', ['alt' => 'Edit Icon', 'style' => 'width: 1em; height: 1em; display: inline-block; vertical-align: -0.125em;']), [ + '/city-store/update', + 'id' => $model->id, + + ], [ + 'class' => 'btn btn-success btn-sm', + 'title' => 'Редактировать', + 'data-bs-toggle' => 'tooltip', + 'data-bs-placement' => 'top', + ]); + + }, + + ], + ], + + ], + ]); ?> +