--- /dev/null
+<?php
+
+namespace app\controllers;
+
+use yii_app\records\UsersWhatsappMessage;
+use yii_app\records\UsersWhatsappMessageSearch;
+use yii\web\Controller;
+use yii\web\NotFoundHttpException;
+use yii\filters\VerbFilter;
+
+/**
+ * UsersWhatsappMessageController implements the CRUD actions for UsersWhatsappMessage model.
+ */
+class UsersWhatsappMessageController extends Controller
+{
+ /**
+ * @inheritDoc
+ */
+ public function behaviors()
+ {
+ return array_merge(
+ parent::behaviors(),
+ [
+ 'verbs' => [
+ 'class' => VerbFilter::className(),
+ 'actions' => [
+ 'delete' => ['POST'],
+ ],
+ ],
+ ]
+ );
+ }
+
+ /**
+ * Lists all UsersWhatsappMessage models.
+ *
+ * @return string
+ */
+ public function actionIndex()
+ {
+ $searchModel = new UsersWhatsappMessageSearch();
+ $dataProvider = $searchModel->search($this->request->queryParams);
+
+ return $this->render('index', [
+ 'searchModel' => $searchModel,
+ 'dataProvider' => $dataProvider,
+ ]);
+ }
+
+ /**
+ * Displays a single UsersWhatsappMessage model.
+ * @param int $id ID
+ * @return string
+ * @throws NotFoundHttpException if the model cannot be found
+ */
+ public function actionView($id)
+ {
+ return $this->render('view', [
+ 'model' => $this->findModel($id),
+ ]);
+ }
+
+ /**
+ * Creates a new UsersWhatsappMessage model.
+ * If creation is successful, the browser will be redirected to the 'view' page.
+ * @return string|\yii\web\Response
+ */
+ public function actionCreate()
+ {
+ $model = new UsersWhatsappMessage();
+
+ if ($this->request->isPost) {
+ if ($model->load($this->request->post()) && $model->save()) {
+ return $this->redirect(['view', 'id' => $model->id]);
+ }
+ } else {
+ $model->loadDefaultValues();
+ }
+
+ return $this->render('create', [
+ 'model' => $model,
+ ]);
+ }
+
+ /**
+ * Updates an existing UsersWhatsappMessage 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($id)
+ {
+ $model = $this->findModel($id);
+
+ if ($this->request->isPost && $model->load($this->request->post()) && $model->save()) {
+ return $this->redirect(['view', 'id' => $model->id]);
+ }
+
+ return $this->render('update', [
+ 'model' => $model,
+ ]);
+ }
+
+ /**
+ * Deletes an existing UsersWhatsappMessage 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($id)
+ {
+ $this->findModel($id)->delete();
+
+ return $this->redirect(['index']);
+ }
+
+ /**
+ * Finds the UsersWhatsappMessage 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 UsersWhatsappMessage the loaded model
+ * @throws NotFoundHttpException if the model cannot be found
+ */
+ protected function findModel($id)
+ {
+ if (($model = UsersWhatsappMessage::findOne(['id' => $id])) !== null) {
+ return $model;
+ }
+
+ throw new NotFoundHttpException('The requested page does not exist.');
+ }
+}
--- /dev/null
+<?php
+
+use yii\db\Migration;
+
+/**
+ * Handles the creation of table `{{%users_whatsapp_message}}`.
+ */
+class m250303_142459_create_users_whatsapp_message_table extends Migration
+{
+ const TABLE_NAME = 'erp24.users_whatsapp_message';
+ /**
+ * {@inheritdoc}
+ */
+ public function safeUp()
+ {
+ $tableSchema = $this->db->getTableSchema(self::TABLE_NAME);
+
+ if (!isset($tableSchema)) {
+ $this->createTable(self::TABLE_NAME, [
+ 'id' => $this->bigPrimaryKey()->comment('ID'),
+ 'request_id' => $this->string()->notNull()->comment('ID сообщения'),
+ 'phone' => $this->string()->notNull()->comment('Телефон'),
+ 'message' => $this->text()->notNull()->comment('Текст сообщения в WhatsApp'),
+ 'kogort_date' => $this->date()->notNull()->comment('Дата когорты'),
+ 'target_date' => $this->date()->notNull()->comment('Целевая дата'),
+ 'status' => $this->string(20)->notNull()->defaultValue('sent')
+ ->comment(
+ "Статус сообщения: " .
+ "sent - отправлено, " .
+ "delivered - доставлено, " .
+ "read - прочитано, " .
+ "undelivered - не доставлено, " .
+ "cancelled - отменено, " .
+ "expired - истек срок, " .
+ "failed - ошибка обработки"
+ ), // Статус сообщения в текстовом формате
+ 'created_at' => $this->dateTime()->notNull()->defaultExpression('CURRENT_TIMESTAMP')
+ ->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;
+
+/**
+ * This is the model class for table "users_whatsapp_message".
+ *
+ * @property int $id ID
+ * @property string $request_id ID сообщения
+ * @property string $phone Телефон
+ * @property string $message Текст сообщения в WhatsApp
+ * @property string $kogort_date Дата когорты
+ * @property string $target_date Целевая дата
+ * @property string $status Статус сообщения: sent - отправлено, delivered - доставлено, read - прочитано, undelivered - не доставлено, cancelled - отменено, expired - истек срок, failed - ошибка обработки
+ * @property string $created_at Дата создания записи
+ */
+class UsersWhatsappMessage extends \yii\db\ActiveRecord
+{
+
+
+ /**
+ * {@inheritdoc}
+ */
+ public static function tableName()
+ {
+ return 'users_whatsapp_message';
+ }
+
+ /**
+ * {@inheritdoc}
+ */
+ public function rules()
+ {
+ return [
+ [['status'], 'default', 'value' => 'sent'],
+ [['request_id', 'phone', 'message', 'kogort_date', 'target_date'], 'required'],
+ [['message'], 'string'],
+ [['kogort_date', 'target_date', 'created_at'], 'safe'],
+ [['request_id', 'phone'], 'string', 'max' => 255],
+ [['status'], 'string', 'max' => 20],
+ ];
+ }
+
+ /**
+ * {@inheritdoc}
+ */
+ public function attributeLabels()
+ {
+ return [
+ 'id' => 'ID',
+ 'request_id' => 'ID сообщения',
+ 'phone' => 'Телефон',
+ 'message' => 'Текст сообщения в WhatsApp',
+ 'kogort_date' => 'Дата когорты',
+ 'target_date' => 'Целевая дата',
+ 'status' => 'Статус сообщения: sent - отправлено, delivered - доставлено, read - прочитано, undelivered - не доставлено, cancelled - отменено, expired - истек срок, failed - ошибка обработки',
+ 'created_at' => 'Дата создания записи',
+ ];
+ }
+
+}
--- /dev/null
+<?php
+
+namespace yii_app\records;
+
+use yii\base\Model;
+use yii\data\ActiveDataProvider;
+use yii_app\records\UsersWhatsappMessage;
+
+/**
+ * UsersWhatsappMessageSearch represents the model behind the search form of `yii_app\records\UsersWhatsappMessage`.
+ */
+class UsersWhatsappMessageSearch extends UsersWhatsappMessage
+{
+ /**
+ * {@inheritdoc}
+ */
+ public function rules()
+ {
+ return [
+ [['id'], 'integer'],
+ [['request_id', 'phone', 'message', 'kogort_date', 'target_date', 'status', 'created_at'], 'safe'],
+ ];
+ }
+
+ /**
+ * {@inheritdoc}
+ */
+ public function scenarios()
+ {
+ // bypass scenarios() implementation in the parent class
+ return Model::scenarios();
+ }
+
+ /**
+ * Creates data provider instance with search query applied
+ *
+ * @param array $params
+ * @param string|null $formName Form name to be used into `->load()` method.
+ *
+ * @return ActiveDataProvider
+ */
+ public function search($params, $formName = null)
+ {
+ $query = UsersWhatsappMessage::find();
+
+ // add conditions that should always apply here
+
+ $dataProvider = new ActiveDataProvider([
+ 'query' => $query,
+ ]);
+
+ $this->load($params, $formName);
+
+ if (!$this->validate()) {
+ // uncomment the following line if you do not want to return any records when validation fails
+ // $query->where('0=1');
+ return $dataProvider;
+ }
+
+ // grid filtering conditions
+ $query->andFilterWhere([
+ 'id' => $this->id,
+ 'kogort_date' => $this->kogort_date,
+ 'target_date' => $this->target_date,
+ 'created_at' => $this->created_at,
+ ]);
+
+ $query->andFilterWhere(['ilike', 'request_id', $this->request_id])
+ ->andFilterWhere(['ilike', 'phone', $this->phone])
+ ->andFilterWhere(['ilike', 'message', $this->message])
+ ->andFilterWhere(['ilike', 'status', $this->status]);
+
+ return $dataProvider;
+ }
+}
--- /dev/null
+<?php
+
+use yii_app\records\UsersWhatsappMessage;
+use yii\helpers\Html;
+use yii\helpers\Url;
+use yii\grid\ActionColumn;
+use yii\grid\GridView;
+
+/** @var yii\web\View $this */
+/** @var yii_app\records\UsersWhatsappMessageSearch $searchModel */
+/** @var yii\data\ActiveDataProvider $dataProvider */
+
+$this->title = 'Users Whatsapp Messages';
+$this->params['breadcrumbs'][] = $this->title;
+?>
+<div class="users-whatsapp-message-index">
+
+ <h1><?= Html::encode($this->title) ?></h1>
+
+ <p>
+ <?= Html::a('Create Users Whatsapp Message', ['create'], ['class' => 'btn btn-success']) ?>
+ </p>
+
+ <?php // echo $this->render('_search', ['model' => $searchModel]); ?>
+
+ <?= GridView::widget([
+ 'dataProvider' => $dataProvider,
+ 'filterModel' => $searchModel,
+ 'columns' => [
+ ['class' => 'yii\grid\SerialColumn'],
+
+ 'id',
+ 'request_id',
+ 'phone',
+ 'message:ntext',
+ 'kogort_date',
+ //'target_date',
+ //'status',
+ //'created_at',
+ [
+ 'class' => ActionColumn::className(),
+ 'urlCreator' => function ($action, UsersWhatsappMessage $model, $key, $index, $column) {
+ return Url::toRoute([$action, 'id' => $model->id]);
+ }
+ ],
+ ],
+ ]); ?>
+
+
+</div>
--- /dev/null
+<?php
+
+use yii\helpers\Html;
+use yii\widgets\DetailView;
+
+/** @var yii\web\View $this */
+/** @var yii_app\records\UsersWhatsappMessage $model */
+
+$this->title = $model->id;
+$this->params['breadcrumbs'][] = ['label' => 'Users Whatsapp Messages', 'url' => ['index']];
+$this->params['breadcrumbs'][] = $this->title;
+\yii\web\YiiAsset::register($this);
+?>
+<div class="users-whatsapp-message-view">
+
+ <h1><?= Html::encode($this->title) ?></h1>
+
+ <p>
+ <?= Html::a('Update', ['update', 'id' => $model->id], ['class' => 'btn btn-primary']) ?>
+ <?= Html::a('Delete', ['delete', 'id' => $model->id], [
+ 'class' => 'btn btn-danger',
+ 'data' => [
+ 'confirm' => 'Are you sure you want to delete this item?',
+ 'method' => 'post',
+ ],
+ ]) ?>
+ </p>
+
+ <?= DetailView::widget([
+ 'model' => $model,
+ 'attributes' => [
+ 'id',
+ 'request_id',
+ 'phone',
+ 'message:ntext',
+ 'kogort_date',
+ 'target_date',
+ 'status',
+ 'created_at',
+ ],
+ ]) ?>
+
+</div>