use yii\helpers\BaseConsole;
use yii\helpers\Json;
use yii\web\Controller;
+use yii_app\records\KogortStopList;
use yii_app\records\Sales;
use yii_app\records\SentKogort;
use yii_app\records\Users;
}
}
- $userStopList = UsersStopList::find()->with('author')->all();
+ $userStopList = KogortStopList::find()->with(['updatedBy', 'createdBy'])->all();
return $this->render('index', [
'model' => $model,
--- /dev/null
+<?php
+
+namespace yii_app\controllers\crud;
+
+use yii_app\records\KogortStopList;
+use yii\data\ActiveDataProvider;
+use yii\web\Controller;
+use yii\web\NotFoundHttpException;
+use yii\filters\VerbFilter;
+
+/**
+ * KogortStopListController implements the CRUD actions for KogortStopList model.
+ */
+class KogortStopListController extends Controller
+{
+ /**
+ * @inheritDoc
+ */
+ public function behaviors()
+ {
+ return array_merge(
+ parent::behaviors(),
+ [
+ 'verbs' => [
+ 'class' => VerbFilter::className(),
+ 'actions' => [
+ 'delete' => ['POST'],
+ ],
+ ],
+ ]
+ );
+ }
+
+ /**
+ * Lists all KogortStopList models.
+ *
+ * @return string
+ */
+ public function actionIndex()
+ {
+ $dataProvider = new ActiveDataProvider([
+ 'query' => KogortStopList::find(),
+ /*
+ 'pagination' => [
+ 'pageSize' => 50
+ ],
+ 'sort' => [
+ 'defaultOrder' => [
+ 'id' => SORT_DESC,
+ ]
+ ],
+ */
+ ]);
+
+ return $this->render('index', [
+ 'dataProvider' => $dataProvider,
+ ]);
+ }
+
+ /**
+ * Displays a single KogortStopList model.
+ * @param int $id ID
+ * @return string
+ * @throws NotFoundHttpException if the model cannot be found
+ */
+ public function actionView($phone)
+ {
+ return $this->render('view', [
+ 'model' => $this->findModel($phone),
+ ]);
+ }
+
+ /**
+ * Creates a new KogortStopList model.
+ * If creation is successful, the browser will be redirected to the 'view' page.
+ * @return string|\yii\web\Response
+ */
+ public function actionCreate()
+ {
+ $model = new KogortStopList();
+
+ if ($this->request->isPost) {
+ if ($model->load($this->request->post()) && $model->save()) {
+ return $this->redirect(['view', 'phone' => $model->phone]);
+ }
+ } else {
+ $model->loadDefaultValues();
+ }
+
+ return $this->render('create', [
+ 'model' => $model,
+ ]);
+ }
+
+ /**
+ * Updates an existing KogortStopList model.
+ * If update is successful, the browser will be redirected to the 'view' page.
+ * @param int $id ID
+ * @return string|\yii\web\Response
+ * @throws NotFoundHttpException if the model cannot be found
+ */
+ public function actionUpdate($phone)
+ {
+ $model = $this->findModel($phone);
+
+ if ($this->request->isPost && $model->load($this->request->post()) && $model->save()) {
+ return $this->redirect(['view', 'phone' => $model->phone]);
+ }
+
+ return $this->render('update', [
+ 'model' => $model,
+ ]);
+ }
+
+ /**
+ * Deletes an existing KogortStopList model.
+ * If deletion is successful, the browser will be redirected to the 'index' page.
+ * @param int $id ID
+ * @return \yii\web\Response
+ * @throws NotFoundHttpException if the model cannot be found
+ */
+ public function actionDelete($phone)
+ {
+ $this->findModel($phone)->delete();
+
+ return $this->redirect(['index']);
+ }
+
+ /**
+ * Finds the KogortStopList model based on its primary key value.
+ * If the model is not found, a 404 HTTP exception will be thrown.
+ * @param int $id ID
+ * @return KogortStopList the loaded model
+ * @throws NotFoundHttpException if the model cannot be found
+ */
+ protected function findModel($phone)
+ {
+ if (($model = KogortStopList::findOne(['phone' => $phone])) !== null) {
+ return $model;
+ }
+
+ throw new NotFoundHttpException('The requested page does not exist.');
+ }
+}
--- /dev/null
+<?php
+
+use yii\db\Migration;
+
+/**
+ * Class m250418_094900_create_table_kogort_stop_list
+ */
+class m250418_094900_create_table_kogort_stop_list extends Migration
+{
+ const TABLE_NAME = 'erp24.kogort_stop_list';
+
+ /**
+ * {@inheritdoc}
+ */
+ public function safeUp()
+ {
+ $tableSchema = $this->db->getTableSchema(self::TABLE_NAME);
+
+ if (!isset($tableSchema)) {
+ $this->createTable(self::TABLE_NAME, [
+ 'id' => $this->primaryKey(),
+ 'phone' => $this->string(20)->notNull()->comment('Телефон'),
+ 'comment' => $this->text()->null()->comment('Комментарий'),
+ 'created_at' => $this->dateTime()->notNull()->comment('Дата создания'),
+ 'updated_at' => $this->dateTime()->null()->comment('Дата обновления'),
+ 'created_by' => $this->integer()->notNull()->comment('ИД создателя'),
+ 'updated_by' => $this->integer()->null()->comment('ИД редактировавшего'),
+ ]);
+ }
+ }
+
+ /**
+ * {@inheritdoc}
+ */
+ public function safeDown()
+ {
+ $tableSchema = $this->db->getTableSchema(self::TABLE_NAME);
+
+ if (isset($tableSchema)) {
+ $this->dropTable(self::TABLE_NAME);
+ }
+ }
+}
--- /dev/null
+<?php
+
+namespace yii_app\records;
+
+use Yii;
+use yii\behaviors\BlameableBehavior;
+use yii\behaviors\TimestampBehavior;
+use yii\db\Expression;
+
+/**
+ * This is the model class for table "kogort_stop_list".
+ *
+ * @property int $id
+ * @property string $phone Телефон
+ * @property string|null $comment Комментарий
+ * @property string $created_at Дата создания
+ * @property string|null $updated_at Дата обновления
+ * @property int $created_by ИД создателя
+ * @property int|null $updated_by ИД редактировавшего
+ */
+class KogortStopList extends \yii\db\ActiveRecord
+{
+ /**
+ * {@inheritdoc}
+ */
+ public static function tableName()
+ {
+ return 'kogort_stop_list';
+ }
+
+ public function behaviors(): array
+ {
+ return [
+ [
+ 'class' => TimestampBehavior::class,
+ 'createdAtAttribute' => 'created_at',
+ 'updatedAtAttribute' => 'updated_at',
+ 'value' => new Expression('NOW()'),
+ ],
+ [
+ 'class' => BlameableBehavior::class,
+ 'createdByAttribute' => 'created_by',
+ 'updatedByAttribute' => 'updated_by',
+ ],
+ ];
+ }
+
+ /**
+ * {@inheritdoc}
+ */
+ public function rules()
+ {
+ return [
+ [['phone'], 'required'],
+ [['comment'], 'string'],
+ [['created_at', 'updated_at', 'created_by'], 'safe'],
+ [['created_by', 'updated_by'], 'default', 'value' => null],
+ [['created_by', 'updated_by'], 'integer'],
+ [['phone'], 'string', 'max' => 20],
+ ];
+ }
+
+ /**
+ * {@inheritdoc}
+ */
+ public function attributeLabels()
+ {
+ return [
+ 'id' => 'ID',
+ 'phone' => 'Телефон',
+ 'comment' => 'Комментарий',
+ 'created_at' => 'Создано в',
+ 'updated_at' => 'Обновлено в',
+ 'created_by' => 'Создано',
+ 'updated_by' => 'Обновлено',
+ ];
+ }
+
+ public function getUpdatedBy() {
+ return $this->hasOne(Admin::class, ['id' => 'updated_by']);
+ }
+
+ public function getCreatedBy() {
+ return $this->hasOne(Admin::class, ['id' => 'created_by']);
+ }
+}
--- /dev/null
+<?php
+
+use yii\helpers\Html;
+use yii\widgets\ActiveForm;
+
+/** @var yii\web\View $this */
+/** @var yii_app\records\KogortStopList $model */
+/** @var yii\widgets\ActiveForm $form */
+?>
+
+<div class="kogort-stop-list-form">
+
+ <?php $form = ActiveForm::begin(); ?>
+
+ <?= $form->field($model, 'phone')->textInput(['maxlength' => true]) ?>
+
+ <?= $form->field($model, 'comment')->textarea(['rows' => 6]) ?>
+
+ <div class="form-group">
+ <?= Html::submitButton('Сохранить', ['class' => 'btn btn-success']) ?>
+ </div>
+
+ <?php ActiveForm::end(); ?>
+
+</div>
--- /dev/null
+<?php
+
+use yii\helpers\Html;
+
+/** @var yii\web\View $this */
+/** @var yii_app\records\KogortStopList $model */
+
+$this->title = 'Создание стоп листа когорт';
+$this->params['breadcrumbs'][] = ['label' => 'Kogort Stop Lists', 'url' => ['index']];
+$this->params['breadcrumbs'][] = $this->title;
+?>
+<div class="kogort-stop-list-create m-5">
+
+ <h1><?= Html::encode($this->title) ?></h1>
+
+ <?= $this->render('_form', [
+ 'model' => $model,
+ ]) ?>
+
+</div>
--- /dev/null
+<?php
+
+use yii_app\records\KogortStopList;
+use yii\helpers\Html;
+use yii\helpers\Url;
+use yii\grid\ActionColumn;
+use yii\grid\GridView;
+
+/** @var yii\web\View $this */
+/** @var yii\data\ActiveDataProvider $dataProvider */
+
+$this->title = 'Стоп лист когорт';
+$this->params['breadcrumbs'][] = $this->title;
+?>
+<div class="kogort-stop-list-index m-5">
+
+ <h1><?= Html::encode($this->title) ?></h1>
+
+ <p>
+ <?= Html::a('Создать стоп лист когорт', ['create'], ['class' => 'btn btn-success']) ?>
+ </p>
+
+
+ <?= GridView::widget([
+ 'dataProvider' => $dataProvider,
+ 'columns' => [
+ ['class' => 'yii\grid\SerialColumn'],
+
+ 'id',
+ 'phone',
+ 'comment:ntext',
+ 'updated_at',
+ 'created_at',
+ [
+ 'label' => 'Обновлено кем',
+ 'attribute' => 'updated_by',
+ 'value' => function ($model) {
+ return $model->updatedBy->name ?? '-';
+ }
+ ],
+ [
+ 'label' => 'Создано кем',
+ 'attribute' => 'created_by',
+ 'value' => function ($model) {
+ return $model->createdBy->name ?? '-';
+ }
+ ],
+ [
+ 'class' => ActionColumn::className(),
+ 'urlCreator' => function ($action, KogortStopList $model, $key, $index, $column) {
+ return Url::toRoute([$action, 'id' => $model->id]);
+ }
+ ],
+ ],
+ ]); ?>
+
+
+</div>
--- /dev/null
+<?php
+
+use yii\helpers\Html;
+
+/** @var yii\web\View $this */
+/** @var yii_app\records\KogortStopList $model */
+
+$this->title = 'Редактировать запись в стоп листе когорт: ' . $model->phone . ' : ' . $model->comment;
+?>
+<div class="kogort-stop-list-update m-5">
+
+ <h1><?= Html::a('Назад', ['/crud/kogort-stop-list/index'], ['class' => 'btn btn-secondary']) ?>
+ <?= Html::encode($this->title) ?></h1>
+
+ <?= $this->render('_form', [
+ 'model' => $model,
+ ]) ?>
+
+</div>
--- /dev/null
+<?php
+
+use yii\helpers\Html;
+use yii\widgets\DetailView;
+
+/** @var yii\web\View $this */
+/** @var yii_app\records\KogortStopList $model */
+
+$this->title = $model->phone;
+
+\yii\web\YiiAsset::register($this);
+?>
+<div class="kogort-stop-list-view m-5">
+
+ <h1><?= Html::a('Назад', ['/crud/kogort-stop-list/index'], ['class' => 'btn btn-secondary']) ?>
+ <?= Html::encode($this->title) ?></h1>
+
+ <p>
+ <?= Html::a('Обновить', ['update', 'phone' => $model->phone], ['class' => 'btn btn-primary']) ?>
+ <?= Html::a('Удалить', ['delete', 'phone' => $model->phone], [
+ 'class' => 'btn btn-danger',
+ 'data' => [
+ 'confirm' => 'Вы действительно хотите удалить этот элемент?',
+ 'method' => 'post',
+ ],
+ ]) ?>
+ </p>
+
+ <?= DetailView::widget([
+ 'model' => $model,
+ 'attributes' => [
+ 'id',
+ 'phone',
+ 'comment:ntext',
+ 'created_at',
+ 'updated_at',
+ [
+ 'attribute' => 'created_by',
+ 'format' => 'raw',
+ 'value' => function ($model) {
+ return $model->createdBy->name ?? '-';
+ },
+ ],
+ [
+ 'attribute' => 'updated_by',
+ 'format' => 'raw',
+ 'value' => function ($model) {
+ return $model->updatedBy->name ?? '-';
+ },
+ ],
+ ],
+ ]) ?>
+
+</div>
use yii_app\records\Admin;
use yii_app\records\UsersMessageManagement;
-use yii_app\records\UsersStopList;
+use yii_app\records\KogortStopList;
/* @var $model UsersMessageManagement */
/* @var $tab integer */
/** @var array $links */
/** @var string $month */
/** @var string $year */
-/** @var UsersStopList[] $userStopList */
+/** @var KogortStopList[] $userStopList */
$this->registerJs('var tab = ' . \yii\helpers\Json::encode(['tab' => $tab]), \yii\web\View::POS_END);
$this->registerJsFile('/js/users-message-management/index.js', ['position' => \yii\web\View::POS_END]);
</div>
</div>
<div id="stopListTab">
+ <div class="row mb-3">
+ <div class="col-4 col-lg-offset-8">
+ <?= Html::a('Создать запись в столп листе когорт',
+ ['/crud/kogort-stop-list/create'], ['class' => 'btn btn-success', 'target' => '_blank']) ?>
+ </div>
+ </div>
<table id="stopListTable">
<thead>
<tr>
<th></th>
<th>Телефон</th>
<th>Комментарий</th>
- <th>Дата</th>
- <th>Автор</th>
+ <th>Дата обновления</th>
+ <th>Дата создания</th>
+ <th>Обновлено кем</th>
+ <th>Создано кем</th>
</tr>
</thead>
<tbody>
- <?php foreach($userStopList as $userStop): /* @var $userStop UsersStopList */ ?>
+ <?php foreach($userStopList as $userStop): ?>
<tr>
<td>
<?= Html::a('<svg aria-hidden="true" style="display:inline-block;font-size:inherit;height:1em;overflow:visible;vertical-align:-.125em;width:1.125em" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 576 512"><path fill="currentColor" d="M573 241C518 136 411 64 288 64S58 136 3 241a32 32 0 000 30c55 105 162 177 285 177s230-72 285-177a32 32 0 000-30zM288 400a144 144 0 11144-144 144 144 0 01-144 144zm0-240a95 95 0 00-25 4 48 48 0 01-67 67 96 96 0 1092-71z"></path></svg>',
- ['/crud/users-stop-list/view', 'phone' => $userStop->phone], ['class' => 'btn btn-link', 'style' => 'max-width: 20px', 'target' => '_blank']) ?>
+ ['/crud/kogort-stop-list/view', 'phone' => $userStop->phone], ['class' => 'btn btn-link', 'style' => 'max-width: 20px', 'target' => '_blank']) ?>
<?= Html::a('<svg aria-hidden="true" style="display:inline-block;font-size:inherit;height:1em;overflow:visible;vertical-align:-.125em;width:1em" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 512 512"><path fill="currentColor" d="M498 142l-46 46c-5 5-13 5-17 0L324 77c-5-5-5-12 0-17l46-46c19-19 49-19 68 0l60 60c19 19 19 49 0 68zm-214-42L22 362 0 484c-3 16 12 30 28 28l122-22 262-262c5-5 5-13 0-17L301 100c-4-5-12-5-17 0zM124 340c-5-6-5-14 0-20l154-154c6-5 14-5 20 0s5 14 0 20L144 340c-6 5-14 5-20 0zm-36 84h48v36l-64 12-32-31 12-65h36v48z"></path></svg>',
- ['/crud/users-stop-list/update', 'phone' => $userStop->phone], ['class' => 'btn btn-link', 'style' => 'max-width: 20px', 'target' => '_blank']) ?>
+ ['/crud/kogort-stop-list/update', 'phone' => $userStop->phone], ['class' => 'btn btn-link', 'style' => 'max-width: 20px', 'target' => '_blank']) ?>
<?= Html::a('<svg aria-hidden="true" style="display:inline-block;font-size:inherit;height:1em;overflow:visible;vertical-align:-.125em;width:.875em" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 448 512"><path fill="currentColor" d="M32 464a48 48 0 0048 48h288a48 48 0 0048-48V128H32zm272-256a16 16 0 0132 0v224a16 16 0 01-32 0zm-96 0a16 16 0 0132 0v224a16 16 0 01-32 0zm-96 0a16 16 0 0132 0v224a16 16 0 01-32 0zM432 32H312l-9-19a24 24 0 00-22-13H167a24 24 0 00-22 13l-9 19H16A16 16 0 000 48v32a16 16 0 0016 16h416a16 16 0 0016-16V48a16 16 0 00-16-16z"></path></svg>',
- ['/crud/users-stop-list/delete', 'phone' => $userStop->phone], ['class' => 'btn btn-link', 'style' => 'max-width: 20px', 'target' => '_blank', 'data-confirm' => 'Вы действительно хотите удалить этот элемент?', 'data-method' => 'POST']) ?>
+ ['/crud/kogort-stop-list/delete', 'phone' => $userStop->phone], ['class' => 'btn btn-link', 'style' => 'max-width: 20px', 'target' => '_blank', 'data-confirm' => 'Вы действительно хотите удалить этот элемент?', 'data-method' => 'POST']) ?>
</td>
<td><?= $userStop->phone ?></td>
- <td><?= $userStop->name ?></td>
- <td><?= $userStop->date ?></td>
- <td><?= $userStop->author->name ?? '-' ?></td>
+ <td><?= $userStop->comment ?></td>
+ <td><?= $userStop->updated_at ?></td>
+ <td><?= $userStop->created_at ?></td>
+ <td><?= $userStop->updatedBy->name ?? '-' ?></td>
+ <td><?= $userStop->createdBy->name ?? '-' ?></td>
</tr>
<?php endforeach; ?>
</tbody>