From 81bd410d71119d15966a65f836fa768e29d76ad6 Mon Sep 17 00:00:00 2001 From: fomichev Date: Mon, 16 Dec 2024 13:52:58 +0300 Subject: [PATCH] =?utf8?q?=D0=94=D0=BE=D0=B1=D0=B0=D0=B2=D0=B8=D0=BB=20?= =?utf8?q?=D0=BA=D0=BE=D0=BB=D0=BE=D0=BD=D0=BA=D1=83=20=D0=B8=20=D1=84?= =?utf8?q?=D0=B8=D0=BB=D1=8C=D1=82=D1=80=20=D0=BD=D0=B0=20=D0=B2=D0=BE?= =?utf8?q?=D1=82=D1=81=D0=B0=D0=BF?= MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit --- erp24/records/Users.php | 20 ++++-- .../users-message-management/view-kogort.php | 65 ++++++------------- 2 files changed, 35 insertions(+), 50 deletions(-) diff --git a/erp24/records/Users.php b/erp24/records/Users.php index ffa32846..ecac5348 100755 --- a/erp24/records/Users.php +++ b/erp24/records/Users.php @@ -73,6 +73,12 @@ class Users extends \yii\db\ActiveRecord const NIGHT_FLORIST_ID = 35; const DAY_FLORIST_ID = 40; + const KOGORT_TYPES = [ + 'target' => 'Таргет', + 'whatsapp' => 'WhatsApp', + 'call' => 'Звонок', + ]; + /** * {@inheritdoc} */ @@ -310,10 +316,16 @@ class Users extends \yii\db\ActiveRecord $usersArray = array_unique(array_merge($salesPhone, $memorableDate)); - $users = Users::find() - ->andWhere(['phone' => $usersArray]) -// ->andWhere() //заглушка на проверку что он уже участвовал в - ->all(); + + $query = Users::find() + // ->andWhere() //заглушка на проверку что он уже участвовал в + ->andWhere(['phone' => $usersArray]); + + if ($type === 'whatsapp') { + $query->andWhere(['telegram_is_subscribed' => 0]); + } + + $users = $query->all(); $data = []; diff --git a/erp24/views/users-message-management/view-kogort.php b/erp24/views/users-message-management/view-kogort.php index 9756039b..4b675139 100644 --- a/erp24/views/users-message-management/view-kogort.php +++ b/erp24/views/users-message-management/view-kogort.php @@ -1,70 +1,43 @@ title = 'Когорта пользователей'; $this->params['breadcrumbs'][] = $this->title; +$model = $dataProvider->getModels()[0] ?? null; +$attributes = $model ? array_keys($model) : []; + +$columns = array_map(function ($attribute) { + return [ + 'attribute' => $attribute, + 'value' => function ($model) use ($attribute) { + return $model[$attribute] ?? '(Нет данных)'; + }, + 'label' => ucfirst(str_replace('_', ' ', $attribute)), + ]; +}, $attributes); + +array_unshift($columns, ['class' => 'yii\grid\SerialColumn']); + ?> 'btn btn-primary m-5']) ?>
-

title) ?>

+

title) ?>: -

$dataProvider, - /*'columns' => [ - ['class' => 'yii\grid\SerialColumn'], - - [ - 'attribute' => 'id', - 'label' => 'ID', - ], - [ - 'attribute' => 'phone', - 'label' => 'Телефон', - ], - [ - 'attribute' => 'phone', - 'label' => 'Телефон', - ], - [ - 'attribute' => 'name', - 'label' => 'ФИО', - ], - [ - 'attribute' => 'date', - 'label' => 'Дата', - ], - [ - 'attribute' => 'name_name', - 'label' => 'Имя', - ], - [ - 'attribute' => 'name_last', - 'label' => 'Отчество', - ], - [ - 'attribute' => 'name_family', - 'label' => 'Фамилия', - ], - [ - 'attribute' => 'pol', - 'label' => 'Пол', - 'value' => function ($model) { - return $model->pol === 'male' ? "Муж" : "Жен"; - }, - ], - - - ],*/ + 'columns' => $columns, ]); ?>
-- 2.39.5