const NIGHT_FLORIST_ID = 35;
const DAY_FLORIST_ID = 40;
+ const KOGORT_TYPES = [
+ 'target' => 'Таргет',
+ 'whatsapp' => 'WhatsApp',
+ 'call' => 'Звонок',
+ ];
+
/**
* {@inheritdoc}
*/
$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 = [];
<?php
use yii\grid\GridView;
+use yii\helpers\ArrayHelper;
use yii\helpers\Html;
/** @var yii\data\ActiveDataProvider $dataProvider */
/** @var string $date */
+/** @var string $type */
$this->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']);
+
?>
<?= Html::a('Назад', ['index'], ['class' => 'btn btn-primary m-5']) ?>
<div class="view-kogort p-5 bg-white mt-6 rounded-3">
- <h1><?= Html::encode($this->title) ?> <?= $date ?></h1>
+ <h1><?= Html::encode($this->title) ?>: <?= \yii_app\records\Users::KOGORT_TYPES[$type] ?> - <?= date('d-m-Y', strtotime($date)) ?></h1>
<?= GridView::widget([
'dataProvider' => $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,
]); ?>
</div>