From 0692db9c805087f0c621162f421cc33436247ea5 Mon Sep 17 00:00:00 2001 From: Arsen Mirzaev Tatyano-Muradovich Date: Wed, 25 Feb 2026 23:40:04 +0500 Subject: [PATCH] receivers --- .../system/localizations/russian.php | 14 +++- .../project/enumerations/architecture.php | 9 +- .../telegram/conversations/project/create.php | 84 +++++++++++++++++-- .../system/settings/system.php.sample | 2 +- 4 files changed, 100 insertions(+), 9 deletions(-) diff --git a/kodorvan/constructor/system/localizations/russian.php b/kodorvan/constructor/system/localizations/russian.php index a9aa276..39ee76b 100644 --- a/kodorvan/constructor/system/localizations/russian.php +++ b/kodorvan/constructor/system/localizations/russian.php @@ -49,6 +49,18 @@ return [ 'project_create_requested' => 'Проект создан и отправлен оператору', 'project_create_cancelled' => 'Создание проекта отменено', + 'project_request_title' => 'Заказ #%d', + 'project_request_architecture' => 'Архитектура', + 'project_request_purpose' => 'Назначение', + 'project_request_hours' => 'Часы', + 'project_request_cost' => 'Стоимость', + 'project_request_command' => 'Команда', + 'project_request_empty' => 'Пусто', + 'project_request_button_accept' => 'Принять', + 'project_request_button_refuse' => 'Отказать', + 'project_request_button_edit' => 'Редактировать', + 'project_request_button_chat' => 'Чат с заказчиком', + // Проект: типы 'project_architecture_chat_robot' => 'Чат-робот', 'project_architecture_parser' => 'Парсер', @@ -68,7 +80,7 @@ return [ 'project_purpose_marketplace' => 'Маркетплейс', 'project_purpose_charity' => 'Благотворительность', 'project_purpose_search' => 'Поиск', - 'project_purpose_calculate' => 'Расчёт', + 'project_purpose_calcul+ate' => 'Расчёт', 'project_purpose_tools' => 'Инструменты', 'project_purpose_workers' => 'Рабочие', 'project_purpose_objects' => 'Предметы', diff --git a/kodorvan/constructor/system/models/project/enumerations/architecture.php b/kodorvan/constructor/system/models/project/enumerations/architecture.php index 59baeb5..a92324a 100644 --- a/kodorvan/constructor/system/models/project/enumerations/architecture.php +++ b/kodorvan/constructor/system/models/project/enumerations/architecture.php @@ -33,7 +33,7 @@ enum architecture case crm; case site; case program; - /* case calculator; */ + /* case calculator; */ case complex; @@ -105,6 +105,13 @@ enum architecture */ public function purposes(): array { + // Initializing purposes + $purposes = purpose::cases(); + + // Deleting the special purpose + $indexes = array_keys($purposes, purpose::special); + foreach ($indexes as $index) unset($purposes[$index]); + // Exit (success) return match ($this) { static::chat_robot => [ diff --git a/kodorvan/constructor/system/models/telegram/conversations/project/create.php b/kodorvan/constructor/system/models/telegram/conversations/project/create.php index d0959f1..a1e2f01 100644 --- a/kodorvan/constructor/system/models/telegram/conversations/project/create.php +++ b/kodorvan/constructor/system/models/telegram/conversations/project/create.php @@ -100,9 +100,9 @@ final class create extends menu [ "🏛 *$localization->project_create_title*", /* $hours > 0 ? "*$localization->project_create_time* " . unmarkdown((string) $hours) . " $localization->hours" : $localization->project_create_description */ - $hours > 0 - ? "*$localization->project_create_time:* $hours$localization->project_create_time_hours" - : $localization->project_create_description, + $new + ? $localization->project_create_description + : "*$localization->project_create_time:* $hours$localization->project_create_time_hours" ] ); @@ -127,7 +127,7 @@ final class create extends menu callback_data: '@architectures' ); - if (isset($this->purpose) || $this->architecture === project_architecture::complex) { + if (isset($this->purpose)) { // Initialized the project purpose // Writing the project purpose button into the buffer of the first row @@ -474,7 +474,7 @@ final class create extends menu ); } - if ($hours > 0) { + if (!$new) { // The project development hours was calculated // Writing the project architecture button @@ -658,7 +658,12 @@ final class create extends menu // Initializing the project architecture purposes $purposes = $this->architecture->purposes(); - if (count($purposes) === 1) { + if (empty($purposes)) { + // The project architecture has no purposes + + // Initializing the project purpose + $this->purpose = project_purpose::special; + } else if (count($purposes) === 1) { // The project architecture has only 1 purpose // Initializing the project purpose @@ -936,6 +941,73 @@ final class create extends menu // Initializing the account localization $localization = $robot->get('localization') ?? new localization($language); + // Initializing the receivers registry + $receivers = PROJECT_CREATE_REQUEST_RECEIVERS; + + // Initializing project data + $architecture = unmarkdown($this->architecture?->label(language: $language) ?? $localization->project_request_empty); + $purpose = unmarkdown(isset($this->purpose) ? $this->purpose->label(language: $language) : $localization->project_request_empty); + $hours = $this->hours(); + + // Generating the message text + $text = implode( + "\n\n", + [ + '*' . unmarkdown(sprintf("💸 $localization->project_request_title", $sex ?? 0)) . '*', + <<project_request_architecture:* $architecture + *$localization->project_request_purpose:* $purpose + TXT, + <<project_request_hours:* $hours + TXT + ] + ); + + // Initializing the keyboard + $keyboard = keyboard::make(); + + // Writing the row into the keyboard + $keyboard->addRow( + button::make( + text: "✉️ $localization->project_request_button_chat", + url: 'https://t.me/' . $robot->user()->username + ) + ); + + // Writing the row into the keyboard + $keyboard->addRow( + button::make( + text: "⚖️ $localization->project_request_button_edit", + callback_data: 'edit' + ) + ); + + // Writing the row into the keyboard + $keyboard->addRow( + button::make( + text: "✅ $localization->project_request_button_accept", + callback_data: 'accept' + ), + button::make( + text: "❌ $localization->project_request_button_refuse", + callback_data: 'refuse' + ) + ); + + foreach ($receivers as $index => $receiver) { + // Iterating over receivers + + // Sending the message + $robot->sendMessage( + text: $text, + chat_id: $receiver, + parse_mode: mode::MARKDOWN, + disable_notification: true, + reply_markup: $keyboard + ); + } + // Sending the message $robot->sendMessage( text: "✅ *$localization->project_create_requested*", diff --git a/kodorvan/constructor/system/settings/system.php.sample b/kodorvan/constructor/system/settings/system.php.sample index ed18a15..d8c4992 100644 --- a/kodorvan/constructor/system/settings/system.php.sample +++ b/kodorvan/constructor/system/settings/system.php.sample @@ -28,7 +28,7 @@ define('PROJECT_CREATE_HOURS_ADDITIONAL', 0); define('PROJECT_CREATE_HOURS_MINIMAL', 4); define('PROJECT_CREATE_COST_HOUR_DEFAULT', 1200); -define('PROJECT_CREATE_REQUEST_CHATS', [ +define('PROJECT_CREATE_REQUEST_RECEIVERS', [ ]);