notification

This commit is contained in:
2025-01-27 20:03:58 +03:00
parent 4692c70378
commit 6534b3155d
19 changed files with 670 additions and 38 deletions

View File

@ -0,0 +1,84 @@
<?php
/**
* @var \kernel\app_modules\tgbot\models\TgbotNotification $model
*/
use app\modules\tgbot\models\Tgbot;
$form = new \itguild\forms\ActiveForm();
$form->beginForm(isset($model) ? "/admin/tg-bot-notification/edit/" . $model->id : "/admin/tg-bot-notification");
$form->field(class: \itguild\forms\inputs\TextInput::class, name: "bot_id", params: [
'class' => "form-control",
'placeholder' => 'Bot ID',
'value' => $model->bot_id ?? ''
])
->setLabel("Bot ID")
->render();
$form->field(class: \itguild\forms\inputs\TextInput::class, name: "dialog_id", params: [
'class' => "form-control",
'placeholder' => 'Dialog ID',
'value' => $model->dialog_id ?? ''
])
->setLabel("Dialog ID")
->render();
$form->field(class: \itguild\forms\inputs\TextInput::class, name: "to_group", params: [
'class' => "form-control",
'placeholder' => '',
'value' => $model->to_group ?? ''
])
->setLabel("To user group")
->render();
$form->field(class: \itguild\forms\inputs\TextInput::class, name: "content", params: [
'class' => "form-control",
'placeholder' => 'Content',
'value' => $model->content ?? ''
])
->setLabel("Content")
->render();
$form->field(class: \itguild\forms\inputs\TextInput::class, name: "photo", params: [
'class' => "form-control",
'placeholder' => 'Photo',
'value' => $model->photo ?? ''
])
->setLabel("Photo")
->render();
$form->field(\itguild\forms\inputs\Select::class, 'status', [
'class' => "form-control",
'value' => $model->status ?? ''
])
->setLabel("Статус")
->setOptions(\kernel\app_modules\tgbot\models\TgbotNotification::getStatus())
->render();
?>
<div class="row">
<div class="col-sm-2">
<?php
$form->field(\itguild\forms\inputs\Button::class, name: "btn-submit", params: [
'class' => "btn btn-primary ",
'value' => 'Отправить',
'typeInput' => 'submit'
])
->render();
?>
</div>
<div class="col-sm-2">
<?php
$form->field(\itguild\forms\inputs\Button::class, name: "btn-reset", params: [
'class' => "btn btn-warning",
'value' => 'Сбросить',
'typeInput' => 'reset'
])
->render();
?>
</div>
</div>
<?php
$form->endForm();

View File

@ -0,0 +1,63 @@
<?php
/**
* @var int $page_number
* @var \kernel\CgView $view
*/
use Itguild\EloquentTable\EloquentDataProvider;
use Itguild\EloquentTable\ListEloquentTable;
use kernel\app_modules\tag\models\Tag;
use kernel\IGTabel\btn\PrimaryBtn;
use kernel\models\Menu;
use kernel\modules\menu\table\columns\MenuDeleteActionColumn;
use kernel\modules\menu\table\columns\MenuEditActionColumn;
use kernel\modules\menu\table\columns\MenuViewActionColumn;
use kernel\widgets\IconBtn\IconBtnDeleteWidget;
use kernel\widgets\IconBtn\IconBtnEditWidget;
use kernel\widgets\IconBtn\IconBtnViewWidget;
$view->setTitle("Список существующих диалогов");
$table = new ListEloquentTable(new EloquentDataProvider(\kernel\app_modules\tgbot\models\TgbotNotification::query()->orderBy("id", "DESC"), [
'currentPage' => $page_number,
'perPage' => 8,
'params' => ["class" => "table table-bordered", "border" => "2"],
'baseUrl' => "/admin/tg-bot-notification",
'searchPrefix' => "",
'searchParams' => (new \kernel\Request())->get(),
]));
$table->beforePrint(function () {
return PrimaryBtn::create("Создать", "/admin/tg-bot-notification/create")->fetch();
});
$table->columns([
"status" => [
"value" => function ($cell) {
return \kernel\app_modules\tgbot\models\TgbotNotification::getStatus()[$cell] ?? 0;
}
],
"bot_id" => [
"filter" => [
"class" => \Itguild\Tables\Filter\InputTextFilter::class
]
],
"dialog_id" => [
"filter" => [
"class" => \Itguild\Tables\Filter\InputTextFilter::class
]
]
]);
$table->addAction(function($row) {
return IconBtnViewWidget::create(['url' => '/admin/tg-bot-notification/' . $row['id']])->run();
});
$table->addAction(function($row) {
return IconBtnEditWidget::create(['url' => '/admin/tg-bot-notification/update/' . $row['id']])->run();
});
$table->addAction(function($row) {
return IconBtnDeleteWidget::create(['url' => '/admin/tg-bot-notification/delete/' . $row['id']])->run();
});
$table->create();
$table->render();

View File

@ -0,0 +1,30 @@
<?php
/**
* @var \Illuminate\Database\Eloquent\Collection $tg
*/
use kernel\modules\user\models\User;
use Itguild\EloquentTable\ViewEloquentTable;
use Itguild\EloquentTable\ViewJsonTableEloquentModel;
use kernel\IGTabel\btn\DangerBtn;
use kernel\IGTabel\btn\PrimaryBtn;
use kernel\IGTabel\btn\SuccessBtn;
$table = new ViewEloquentTable(new ViewJsonTableEloquentModel($tg, [
'params' => ["class" => "table table-bordered", "border" => "2"],
'baseUrl' => "/admin/tg-bot-notification",
]));
$table->beforePrint(function () use ($tg) {
$btn = PrimaryBtn::create("Список", "/admin/tg-bot-notification")->fetch();
$btn .= SuccessBtn::create("Редактировать", "/admin/tg-bot-notification/update/" . $tg->id)->fetch();
$btn .= DangerBtn::create("Удалить", "/admin/tg-bot-notification/delete/" . $tg->id)->fetch();
return $btn;
});
$table->rows([
'status' => (function ($data) {
return \kernel\app_modules\tgbot\models\TgbotNotification::getStatus()[$data];
})
]);
$table->create();
$table->render();