diff --git a/app/modules/tgbot/controllers/TgMainController.php b/app/modules/tgbot/controllers/TgMainController.php index 40be69d..53bd634 100644 --- a/app/modules/tgbot/controllers/TgMainController.php +++ b/app/modules/tgbot/controllers/TgMainController.php @@ -8,8 +8,13 @@ use app\modules\tgbot\services\TgBotService; use Cassandra\Decimal; use kernel\app_modules\card\conditions\CashbackCondition; use kernel\app_modules\card\models\Card; +use kernel\app_modules\card\models\CardTransaction; use kernel\app_modules\card\services\CardService; +use kernel\app_modules\card\services\CardTransactionService; use kernel\app_modules\tag\service\TagService; +use kernel\app_modules\tgbot\models\forms\CreateTgbotNotificationForm; +use kernel\app_modules\tgbot\models\TgbotNotification; +use kernel\app_modules\tgbot\services\TgbotNotificationService; use kernel\Controller; use kernel\Flash; use kernel\helpers\Debug; @@ -76,15 +81,15 @@ class TgMainController extends Controller $card = CardService::getCardById($params->getItem("card_id")); - if ($params->getItem('type') === 'add_money'){ + if ($params->getItem('type') === 'add_money') { Flash::setMessage("success", "Баланс пополнен на " . $params->getItem('amount')); $transaction = CardService::addMoneyToCard($card, (int)$params->getItem('amount')); } - if ($params->getItem('type') === 'withdraw'){ + if ($params->getItem('type') === 'withdraw') { Flash::setMessage("success", "С карты списано " . $params->getItem('amount')); $transaction = CardService::withdrawMoneyFromCard($card, (int)$params->getItem('amount')); } - if ($params->getItem('type') === 'add_purchase'){ + if ($params->getItem('type') === 'add_purchase') { // Flash::setMessage("success", "С карты списано " . $params->getItem('amount')); // CardService::withdrawMoneyFromCard($card, (int)$params->getItem('amount')); $cashback = new CashbackCondition(); @@ -94,7 +99,30 @@ class TgMainController extends Controller $card = $card->fresh(); + $tgbot = Tgbot::where("user_id", $card->user_id)->first(); + if ($tgbot) { + $notificationForm = new CreateTgbotNotificationForm(); + $notificationForm->load([ + 'bot_id' => $tgbot->bot_id, + 'dialog_id' => $tgbot->dialog_id, + 'content' => "На вашу карту начисленно " . $transaction->amount . " бонуса.", + 'status' => TgbotNotification::TO_SEND_STATUS, + ]); + $notificationService = new TgbotNotificationService(); + $notificationService->create($notificationForm); + } + + $this->cgView->render("card_action_step_3.php", ['card' => $card, 'transaction' => $transaction ?? null]); } + public function actionCardInfo(int $cardId): void + { + $card = Card::where("id", $cardId)->first(); + + $transactions = CardTransaction::where("from", $cardId)->orWhere("to", $cardId)->get(); + + $this->cgView->render("card_info.php", ['card' => $card, 'transactions' => $transactions]); + } + } \ No newline at end of file diff --git a/app/modules/tgbot/routs/tgbot.php b/app/modules/tgbot/routs/tgbot.php index 75971a6..d17f1ec 100644 --- a/app/modules/tgbot/routs/tgbot.php +++ b/app/modules/tgbot/routs/tgbot.php @@ -18,6 +18,7 @@ App::$collector->group(["prefix" => "miniapp"], function (CGRouteCollector $rout App::$collector->get('/card_action/{cardId}', [\app\modules\tgbot\controllers\TgMainController::class, 'actionCardActionStep1']); App::$collector->get('/card_action_step_2', [\app\modules\tgbot\controllers\TgMainController::class, 'actionCardActionStep2']); App::$collector->post('/card_action_step_3', [\app\modules\tgbot\controllers\TgMainController::class, 'actionCardActionStep3']); + App::$collector->get('/card_info/{cardId}', [\app\modules\tgbot\controllers\TgMainController::class, 'actionCardInfo']); }); }); }); \ No newline at end of file diff --git a/app/modules/tgbot/views/tgbot/main/card_action_step_1.php b/app/modules/tgbot/views/tgbot/main/card_action_step_1.php index 36433d3..25bfd38 100644 --- a/app/modules/tgbot/views/tgbot/main/card_action_step_1.php +++ b/app/modules/tgbot/views/tgbot/main/card_action_step_1.php @@ -35,4 +35,9 @@ use kernel\helpers\Html;
Списать
+ +
+
+ Информация о карте +
\ No newline at end of file diff --git a/app/modules/tgbot/views/tgbot/main/card_info.php b/app/modules/tgbot/views/tgbot/main/card_info.php new file mode 100644 index 0000000..051ff48 --- /dev/null +++ b/app/modules/tgbot/views/tgbot/main/card_info.php @@ -0,0 +1,80 @@ + ["class" => "table table-bordered", "border" => "2"], + 'baseUrl' => "/admin/card", +])); + +$table->beforePrint(function () use ($card) { + $btn = "

Информация о карте

"; + $btn .= IconBtnListWidget::create(['url' => '/miniapp/card_action/' . $card->id])->run(); + + return $btn; +}); + +$table->rows([ + 'user_id' => (function ($data) { + return User::find($data)->username; + }), + 'status' => function ($data) { + return \kernel\app_modules\card\models\Card::getStatus()[$data]; + } +]); + +$table->create(); +$table->render(); + +echo "

Тразакции

"; + +foreach ($transactions as $transaction){ + $table = new ViewEloquentTable(new ViewJsonTableEloquentModel($transaction, [ + 'params' => ["class" => "table table-bordered", "border" => "2"], + 'baseUrl' => "/admin/card_program", + ])); + + $table->rows([ + 'status' => [ + 'value' => function ($data) { + return \kernel\app_modules\card\models\CardProgram::getStatus()[$data]; + } + ], + 'from' => [ + 'value' => function ($data) { + if ((int)$data === 1001){ + $username = "System"; + } + else { + $username = Card::find($data)->username ?? ''; + } + return $username; + } + ], + 'to' => [ + 'value' => function ($data) { + if ((int)$data === 1001){ + $username = "System"; + } + else { + $username = Card::find($data)->username ?? ''; + } + return $username; + } + ], + ]); + + $table->create(); + $table->render(); +} \ No newline at end of file diff --git a/bootstrap/secure.php b/bootstrap/secure.php index a8baf09..b57765e 100644 --- a/bootstrap/secure.php +++ b/bootstrap/secure.php @@ -1,7 +1,7 @@ 'email_code', // login_password, email_code + 'web_auth_type' => 'login_password', // login_password, email_code 'token_type' => 'hash', // random_bytes, md5, crypt, hash, JWT 'token_expired_time' => "+30 days", // +1 day ]; diff --git a/kernel/app_modules/card/models/CardTransaction.php b/kernel/app_modules/card/models/CardTransaction.php index 73b63f5..10615c8 100644 --- a/kernel/app_modules/card/models/CardTransaction.php +++ b/kernel/app_modules/card/models/CardTransaction.php @@ -43,6 +43,11 @@ class CardTransaction extends Model ]; } + public function fromCard(): \Illuminate\Database\Eloquent\Relations\BelongsTo + { + return $this->belongsTo(Card::class, ownerKey: "from"); + } + /** * @return string[] */ diff --git a/kernel/app_modules/card/views/card_transaction/index.php b/kernel/app_modules/card/views/card_transaction/index.php index bbe3035..e12025f 100644 --- a/kernel/app_modules/card/views/card_transaction/index.php +++ b/kernel/app_modules/card/views/card_transaction/index.php @@ -27,32 +27,12 @@ $table = new ListEloquentTable(new EloquentDataProvider(\kernel\app_modules\card 'baseUrl' => "/admin/card_transaction" ])); - -//$table = new \Itguild\Tables\ListJsonTable(json_encode( -// [ -// 'meta' => [ -// 'total' => 0, -// 'totalWithFilters' => 0, -// 'columns' => [ -// 'title', -// 'slug', -// 'status', -// ], -// 'perPage' => 5, -// 'currentPage' => 1, -// 'baseUrl' => '/admin/some', -// 'params' => [ -// 'class' => 'table table-bordered', -// 'border' => 2 -// ] -// ], -// 'filters' => [], -// 'data' => [], -// ] -//)); - $table->beforePrint(function () { - return IconBtnCreateWidget::create(['url' => '/admin/card_transaction/create'])->run(); + $count = \kernel\app_modules\card\models\CardTransaction::all()->count(); + $html = IconBtnCreateWidget::create(['url' => '/admin/card_transaction/create'])->run(); + $html .= "
Всего записей: $count
"; + + return $html; }); $table->columns([ @@ -61,7 +41,28 @@ $table->columns([ return \kernel\app_modules\card\models\CardTransaction::getStatus()[$data]; } ], - + 'from' => [ + 'value' => function ($data) { + if ((int)$data === 1001){ + $username = "System"; + } + else { + $username = Card::find($data)->username ?? ''; + } + return $username; + } + ], + 'to' => [ + 'value' => function ($data) { + if ((int)$data === 1001){ + $username = "System"; + } + else { + $username = Card::find($data)->username ?? ''; + } + return $username; + } + ], ]); $table->addAction(function($row) { diff --git a/kernel/app_modules/tgbot/TgbotModule.php b/kernel/app_modules/tgbot/TgbotModule.php index 674e489..914beb1 100644 --- a/kernel/app_modules/tgbot/TgbotModule.php +++ b/kernel/app_modules/tgbot/TgbotModule.php @@ -29,11 +29,27 @@ class TgbotModule extends Module "url" => "/admin/tg-bot", "slug" => "tg-bot", ]); + + $this->menuService->createItem([ + "label" => "Диалоги", + "url" => "/admin/tg-bot", + "slug" => "tg-bot-dialogs", + "parent_slug" => "tg-bot", + ]); + + $this->menuService->createItem([ + "label" => "Уведомления", + "url" => "/admin/tg-bot-notification", + "slug" => "tg-bot-notification", + "parent_slug" => "tg-bot", + ]); } public function deactivate() { $this->menuService->removeItemBySlug("tg-bot"); + $this->menuService->removeItemBySlug("tg-bot-dialogs"); + $this->menuService->removeItemBySlug("tg-bot-notification"); $this->migrationService->rollbackAtPath("{KERNEL_APP_MODULES}/tgbot/migrations"); } } \ No newline at end of file diff --git a/kernel/app_modules/tgbot/controllers/TgbotNotificationController.php b/kernel/app_modules/tgbot/controllers/TgbotNotificationController.php new file mode 100644 index 0000000..fbff410 --- /dev/null +++ b/kernel/app_modules/tgbot/controllers/TgbotNotificationController.php @@ -0,0 +1,114 @@ +cgView->viewPath = KERNEL_APP_MODULES_DIR . "/tgbot/views/notification/"; + $this->notificationService = new TgbotNotificationService(); + } + + public function actionCreate(): void + { + $this->cgView->render("form.php"); + } + + public function actionIndex($page_number = 1): void + { + $this->cgView->render("index.php", ['page_number' => $page_number]); + } + + #[NoReturn] public function actionAdd(): void + { + $tgForm = new CreateTgbotNotificationForm(); + $tgForm->load($_REQUEST); + if ($tgForm->validate()) { + $tg = $this->notificationService->create($tgForm); + if ($tg) { + $this->redirect("/admin/tg-bot-notification/view/" . $tg->id); + } + } + + Flash::setMessage("error", $tgForm->getErrorsStr()); + $this->redirect("/admin/tg-bot-notification/create"); + } + + /** + * @throws Exception + */ + public function actionUpdate($id): void + { + $model = TgbotNotification::find($id); + if (!$model) { + throw new Exception(message: "The notification not found"); + } + + $this->cgView->render("form.php", ['model' => $model]); + } + + /** + * @throws Exception + */ + public function actionEdit($id): void + { + $tg = TgbotNotification::find($id); + if (!$tg) { + throw new Exception(message: "The tag not found"); + } + $tgForm = new CreateTgbotNotificationForm(); + $tgService = new TgbotNotificationService(); + $tgForm->load($_REQUEST); + if ($tgForm->validate()) { + $tg = $tgService->update($tgForm, $tg); + if ($tg) { + $this->redirect("/admin/tg-bot-notification/view/" . $tg->id); + } + } + + Flash::setMessage("error", $tgForm->getErrorsStr()); + $this->redirect("/admin/tg-bot-notification/update/" . $id); + } + + /** + * @throws Exception + */ + public function actionView($id): void + { + $tg = TgbotNotification::find($id); + + if (!$tg) { + throw new Exception(message: "The notification not found"); + } + $this->cgView->render("view.php", ['tg' => $tg]); + } + + /** + * @throws Exception + */ + #[NoReturn] public function actionDelete(int $id): void + { + $post = TgbotNotification::find($id)->first(); + if (!$post){ + throw new Exception(message: "The tg notification not found"); + } + + Flash::setMessage("success", "Notification deleted"); + $post->delete(); + $this->redirect("/admin/tg-bot-notification/"); + } + + +} \ No newline at end of file diff --git a/kernel/app_modules/tgbot/controllers/TgbotNotificationRestController.php b/kernel/app_modules/tgbot/controllers/TgbotNotificationRestController.php new file mode 100644 index 0000000..155d09e --- /dev/null +++ b/kernel/app_modules/tgbot/controllers/TgbotNotificationRestController.php @@ -0,0 +1,30 @@ +model = new TgbotNotification(); + } + + #[NoReturn] public function actionGetToSend(): void + { + $notification = TgbotNotification::where("status", TgbotNotification::TO_SEND_STATUS)->first(); + if ($notification){ + $notification->status = TgbotNotification::SENT_STATUS; + $notification->save(); + + $this->renderApi($notification->toArray()); + } + + $this->renderApi([]); + } + +} \ No newline at end of file diff --git a/kernel/app_modules/tgbot/migrations/2025_01_27_120553_create_tgbot_notification_table.php b/kernel/app_modules/tgbot/migrations/2025_01_27_120553_create_tgbot_notification_table.php new file mode 100644 index 0000000..4877483 --- /dev/null +++ b/kernel/app_modules/tgbot/migrations/2025_01_27_120553_create_tgbot_notification_table.php @@ -0,0 +1,34 @@ +schema->create('tgbot_notification', function (Blueprint $table) { + $table->increments('id'); + $table->bigInteger('bot_id')->nullable(false); + $table->bigInteger('dialog_id')->nullable(); + $table->string('to_group')->nullable(); + $table->text('content')->nullable(); + $table->string('photo')->nullable(); + $table->integer('status')->nullable()->default(1); + $table->timestamps(); + }); + } + + /** + * Reverse the migrations. + */ + public function down(): void + { + \kernel\App::$db->schema->dropIfExists('tgbot_notification'); + } +}; diff --git a/kernel/app_modules/tgbot/models/TgbotNotification.php b/kernel/app_modules/tgbot/models/TgbotNotification.php new file mode 100644 index 0000000..2450642 --- /dev/null +++ b/kernel/app_modules/tgbot/models/TgbotNotification.php @@ -0,0 +1,53 @@ + 'Bot ID', + 'dialog_id' => 'Dialog ID', + 'to_group' => 'Group', + 'content' => 'Контент', + 'photo' => 'Фото', + 'status' => 'Статус', + ]; + } + + /** + * @return string[] + */ + public static function getStatus(): array + { + return [ + self::DISABLE_STATUS => "Не активный", + self::NEW_STATUS => "Новое", + self::TO_SEND_STATUS => "На отправку", + self::SENT_STATUS => "Отправлено", + ]; + } + +} \ No newline at end of file diff --git a/kernel/app_modules/tgbot/models/forms/CreateTgbotNotificationForm.php b/kernel/app_modules/tgbot/models/forms/CreateTgbotNotificationForm.php new file mode 100644 index 0000000..1b7b51e --- /dev/null +++ b/kernel/app_modules/tgbot/models/forms/CreateTgbotNotificationForm.php @@ -0,0 +1,30 @@ + 'required|alpha-numeric', + 'dialog_id' => 'alpha-numeric', + 'to_group' => 'alpha-numeric', + 'content' => 'min-str-len:5', + 'photo' => 'min-str-len:5', + 'status' => 'alpha-numeric' + ]; + } + +} \ No newline at end of file diff --git a/kernel/app_modules/tgbot/routs/tgbot.php b/kernel/app_modules/tgbot/routs/tgbot.php index 729ce2e..94c3d58 100644 --- a/kernel/app_modules/tgbot/routs/tgbot.php +++ b/kernel/app_modules/tgbot/routs/tgbot.php @@ -4,18 +4,30 @@ use kernel\App; use kernel\CgRouteCollector; use Phroute\Phroute\RouteCollector; +use kernel\app_modules\tgbot\controllers\TgbotNotificationController; +use kernel\app_modules\tgbot\controllers\TgbotController; App::$collector->group(["prefix" => "admin"], function (CgRouteCollector $router) { App::$collector->group(["before" => "auth"], function (RouteCollector $router) { App::$collector->group(["prefix" => "tg-bot"], function (CGRouteCollector $router) { - App::$collector->get('/', [\app\modules\tgbot\controllers\TgbotController::class, 'actionIndex']); - App::$collector->get('/page/{page_number}', [\app\modules\tgbot\controllers\TgbotController::class, 'actionIndex']); - App::$collector->get('/create', [\app\modules\tgbot\controllers\TgbotController::class, 'actionCreate']); - App::$collector->post("/", [\app\modules\tgbot\controllers\TgbotController::class, 'actionAdd']); - App::$collector->get('/view/{id}', [\app\modules\tgbot\controllers\TgbotController::class, 'actionView']); - App::$collector->any('/update/{id}', [\app\modules\tgbot\controllers\TgbotController::class, 'actionUpdate']); - App::$collector->any("/edit/{id}", [\app\modules\tgbot\controllers\TgbotController::class, 'actionEdit']); - App::$collector->get('/delete/{id}', [\app\modules\tgbot\controllers\TgbotController::class, 'actionDelete']); + App::$collector->get('/', [TgbotController::class, 'actionIndex']); + App::$collector->get('/page/{page_number}', [TgbotController::class, 'actionIndex']); + App::$collector->get('/create', [TgbotController::class, 'actionCreate']); + App::$collector->post("/", [TgbotController::class, 'actionAdd']); + App::$collector->get('/view/{id}', [TgbotController::class, 'actionView']); + App::$collector->any('/update/{id}', [TgbotController::class, 'actionUpdate']); + App::$collector->any("/edit/{id}", [TgbotController::class, 'actionEdit']); + App::$collector->get('/delete/{id}', [TgbotController::class, 'actionDelete']); + }); + App::$collector->group(["prefix" => "tg-bot-notification"], function (CGRouteCollector $router) { + App::$collector->get('/', [TgbotNotificationController::class, 'actionIndex']); + App::$collector->get('/page/{page_number}', [TgbotNotificationController::class, 'actionIndex']); + App::$collector->get('/create', [TgbotNotificationController::class, 'actionCreate']); + App::$collector->post("/", [TgbotNotificationController::class, 'actionAdd']); + App::$collector->get('/view/{id}', [TgbotNotificationController::class, 'actionView']); + App::$collector->any('/update/{id}', [TgbotNotificationController::class, 'actionUpdate']); + App::$collector->any("/edit/{id}", [TgbotNotificationController::class, 'actionEdit']); + App::$collector->get('/delete/{id}', [TgbotNotificationController::class, 'actionDelete']); }); }); }); @@ -28,4 +40,5 @@ App::$collector->group(["prefix" => "api"], function (CgRouteCollector $router){ }); $router->get('/tg-bot/get-scan-btn/{id}', [\app\modules\tgbot\controllers\TgBotRestController::class, 'actionGetScanBtn']); $router->get('/tg-bot/get-card-by-dialog/{dialog_id}/{bot_id}', [\app\modules\tgbot\controllers\TgBotRestController::class, 'actionGetCardByDialog']); + $router->get('/tg-bot-notification/get-to-send', [\kernel\app_modules\tgbot\controllers\TgbotNotificationRestController::class, 'actionGetToSend']); }); \ No newline at end of file diff --git a/kernel/app_modules/tgbot/services/TgbotNotificationService.php b/kernel/app_modules/tgbot/services/TgbotNotificationService.php new file mode 100644 index 0000000..afdac5d --- /dev/null +++ b/kernel/app_modules/tgbot/services/TgbotNotificationService.php @@ -0,0 +1,43 @@ +to_group = $form_model->getItem('to_group'); + $model->bot_id = $form_model->getItem('bot_id'); + $model->dialog_id = $form_model->getItem('dialog_id'); + $model->content = $form_model->getItem('content'); + $model->photo = $form_model->getItem('username'); + $model->status = $form_model->getItem('status'); + if ($model->save()){ + return $model; + } + + return false; + } + + public function update(FormModel $form_model, TgbotNotification $model): false|TgbotNotification + { + $model->bot_id = $form_model->getItem('bot_id'); + $model->dialog_id = $form_model->getItem('dialog_id'); + $model->to_group = $form_model->getItem('to_group'); + $model->content = $form_model->getItem('content'); + $model->photo = $form_model->getItem('photo'); + $model->status = $form_model->getItem('status'); + + if ($model->save()){ + return $model; + } + + return false; + } + +} \ No newline at end of file diff --git a/kernel/app_modules/tgbot/views/notification/form.php b/kernel/app_modules/tgbot/views/notification/form.php new file mode 100644 index 0000000..d69a5d0 --- /dev/null +++ b/kernel/app_modules/tgbot/views/notification/form.php @@ -0,0 +1,84 @@ +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(); +?> +
+
+ field(\itguild\forms\inputs\Button::class, name: "btn-submit", params: [ + 'class' => "btn btn-primary ", + 'value' => 'Отправить', + 'typeInput' => 'submit' + ]) + ->render(); + ?> +
+
+ field(\itguild\forms\inputs\Button::class, name: "btn-reset", params: [ + 'class' => "btn btn-warning", + 'value' => 'Сбросить', + 'typeInput' => 'reset' + ]) + ->render(); + ?> +
+
+endForm(); diff --git a/kernel/app_modules/tgbot/views/notification/index.php b/kernel/app_modules/tgbot/views/notification/index.php new file mode 100644 index 0000000..89aa087 --- /dev/null +++ b/kernel/app_modules/tgbot/views/notification/index.php @@ -0,0 +1,63 @@ +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(); \ No newline at end of file diff --git a/kernel/app_modules/tgbot/views/notification/view.php b/kernel/app_modules/tgbot/views/notification/view.php new file mode 100644 index 0000000..bdcf2bd --- /dev/null +++ b/kernel/app_modules/tgbot/views/notification/view.php @@ -0,0 +1,30 @@ + ["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(); \ No newline at end of file diff --git a/kernel/modules/menu/controllers/MenuController.php b/kernel/modules/menu/controllers/MenuController.php index 30d777c..02f2588 100644 --- a/kernel/modules/menu/controllers/MenuController.php +++ b/kernel/modules/menu/controllers/MenuController.php @@ -6,6 +6,7 @@ use Exception; use JetBrains\PhpStorm\NoReturn; use kernel\AdminController; use kernel\FileUpload; +use kernel\Flash; use kernel\models\Menu; use kernel\modules\menu\models\forms\CreateMenuForm; use kernel\modules\menu\service\MenuService; @@ -46,6 +47,7 @@ class MenuController extends AdminController $this->redirect("/admin/settings/menu/view/" . $menuItem->id, code: 302); } } + Flash::setMessage("error", $menuForm->getErrorsStr()); $this->redirect("/admin/settings/menu/create", code: 302); }