]> gitweb.erp-flowers.ru Git - erp24_rep/yii-erp24/.git/commitdiff
Добавил колонку и фильтр на вотсап
authorfomichev <vladimir.fomichev@erp-flowers.ru>
Mon, 16 Dec 2024 10:52:58 +0000 (13:52 +0300)
committerfomichev <vladimir.fomichev@erp-flowers.ru>
Mon, 16 Dec 2024 10:52:58 +0000 (13:52 +0300)
erp24/records/Users.php
erp24/views/users-message-management/view-kogort.php

index ffa32846604a32e276ddcaf17263e861e6732c2a..ecac53488bc6cc6ec8a84e0e6b07fe814affb24d 100755 (executable)
@@ -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 = [];
 
index 9756039b8649378bf8c18af5c0bd7e28cdb26090..4b6751390b9991b0ad0f218375f56a3b412ddfb6 100644 (file)
@@ -1,70 +1,43 @@
 <?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>