diff --git a/kodorvan/constructor/system/localizations/russian.php b/kodorvan/constructor/system/localizations/russian.php index d45f1fd..110f683 100644 --- a/kodorvan/constructor/system/localizations/russian.php +++ b/kodorvan/constructor/system/localizations/russian.php @@ -26,18 +26,26 @@ return [ 'project_create_title' => 'Создание проекта', /* 'project_create_description' => "Расчитайте ориентировочное время разработки, затем выберите разработчиков и получите стоимость\n\nПосле расчётов можно будет отправить проект в заказ разработчикам и приложить ТЗ, либо краткое описание задачи\n\nМы погружаемся в проекты полностью, поэтому стараемся не распыляться - от степени нагрузки меняется коэффициент стоимости!", */ 'project_create_description' => "Установите параметры и получите ориентировочное время разработки\n\n_После расчётов можно отправить проект в заказ приложив ТЗ, либо описание задачи_", - 'project_create_cost_description' => "Стоимость и сроки выполнения предоставлены для планирования и *не являются публичной офертой*", - 'project_create_time' => 'Время разработки', + 'project_create_warning_cost' => "Стоимость и сроки выполнения предоставлены для планирования и *не являются публичной офертой*", + 'project_create_team_warning' => "", + 'project_create_time' => 'Время', 'project_create_time_hours' => 'ч', 'project_create_time_hours_from' => 'от', 'project_create_time_days' => 'дн', 'project_create_cost' => 'Стоимость', - 'project_create_request_cost_title' => 'Стоимость разработки', - 'project_create_request_cost_description' => 'Введите предложение по *оплате за 1 час* разработки', - 'project_create_request_cost_default' => '*`%d%s`* \- средняя стоимость с учётом *компетенции*, совокупного опыта, *уникальных* разработок\. Цена уже включает\: *наши сервера*, документирование кода, *передачу кода*, ведение репозитория, *техподдержку* и репутационные гарантии', - 'project_create_request_cost_warning' => '_Если цена окажется *недостаточной*, мы выставим *справедливое* и *конкурентное* встречное предложение_', - 'project_create_request_cost_error_distance' => 'Длина сообщения должна быть от %d и до %d символов', - 'project_create_request_cost_error_not_a_number' => 'Значение должно быть числом', + 'project_create_cost_prepayment' => 'Предоплата', + 'project_create_team_title' => 'Сбор команды', + 'project_create_team_description' => '_Вы можете *убрать* или *добавить* специалистов, создавая максимально удобное сотрудничество под вашу систему_', + 'project_create_team_warning_cost' => '_*Не влияет на время разработки*_', + 'project_create_team_button_programmers' => 'Программисты: %d%s', + 'project_create_team_button_designers' => 'Дизайнеры: %d%s', + 'project_create_team_button_boosters' => 'Бустеры: %d%s', + 'project_create_cost_title' => 'Стоимость разработки', + 'project_create_cost_description' => 'Введите предложение по *оплате за 1 час* разработки', + 'project_create_cost_default' => '*`%d%s`* \- средняя стоимость с учётом *компетенции*, совокупного опыта, *уникальных* разработок\. Цена уже включает\: *наши сервера*, документирование кода, *передачу кода*, ведение репозитория, *техподдержку* и репутационные гарантии', + 'project_create_cost_warning' => '_Если цена окажется *недостаточной*, мы выставим *справедливое* и *конкурентное* встречное предложение_', + 'project_create_cost_error_distance' => 'Длина сообщения должна быть от %d и до %d символов', + 'project_create_cost_error_not_a_number' => 'Значение должно быть числом', 'project_create_button_back' => 'Назад', 'project_create_button_cost_per_hour' => 'Час', 'project_create_button_request' => 'Заказать', @@ -56,7 +64,8 @@ return [ 'project_create_integrations_description' => "Синхронизация заказов, товаров, публикаций и прочего в реальном времени, скачивание, загрузка, админ\-панель, рассылка сообщений, подключение аккаунтов\.\.\.\n\n_Отправка запросов в *API*, генерация и перехват *HTTP\-сообщений*, *эмуляция действий пользователя*_", 'project_create_button_integrations' => 'Интеграции', 'project_create_button_integrations_selected' => 'Интеграции', - + 'project_create_button_team' => 'Команда: %d%s', + 'project_create_peoples' => '', 'project_create_requested' => 'Проект создан и отправлен оператору', 'project_create_cancelled' => 'Создание проекта отменено', @@ -65,7 +74,7 @@ return [ 'project_request_purpose' => 'Назначение', 'project_request_hours' => 'Часы', 'project_request_cost' => 'Стоимость', - 'project_request_command' => 'Команда', + 'project_request_team' => 'Команда', 'project_request_empty' => 'Пусто', 'project_request_button_accept' => 'Принять', 'project_request_button_refuse' => 'Отказать', @@ -96,7 +105,7 @@ return [ 'project_purpose_workers' => 'Рабочие', 'project_purpose_objects' => 'Предметы', 'project_purpose_events' => 'События', - 'project_purpose_special' => 'Особенный', + 'project_purpose_special' => 'Особенное', // Проект: интеграции 'project_integration_one_c' => '1C', diff --git a/kodorvan/constructor/system/models/project/enumerations/architecture.php b/kodorvan/constructor/system/models/project/enumerations/architecture.php index bf45b4d..d043c67 100644 --- a/kodorvan/constructor/system/models/project/enumerations/architecture.php +++ b/kodorvan/constructor/system/models/project/enumerations/architecture.php @@ -6,7 +6,8 @@ namespace kodorvan\constructor\models\project\enumerations; // Files of the project use kodorvan\constructor\models\project\enumerations\purpose, - kodorvan\constructor\models\project\enumerations\integration; + kodorvan\constructor\models\project\enumerations\integration, + kodorvan\constructor\models\worker\enumerations\type as worker_type; // The library for languages support use mirzaev\languages\language; @@ -83,11 +84,11 @@ enum architecture { // Exit (success) return match ($this) { - static::chat_robot => 1, + static::chat_robot => 2, static::parser => 1, static::script => 1, - static::site => 1, - static::program => 1, + static::site => 2, + static::program => 2, static::complex => 4, default => 1 }; @@ -146,44 +147,6 @@ enum architecture }; } - /** - * Integrations - * - * @return array Integrations - */ - /* public function integrations(): array - { - // Exit (success) - return match ($this) { - static::chat_robot => [ - integration::one_c, - integration::moy_sklad - ], - static::parser => [ - integration::one_c, - integration::moy_sklad - ], - static::script => [], - static::crm => [ - integration::one_c, - integration::moy_sklad - ], - static::site => [ - integration::one_c, - integration::moy_sklad - ], - static::program => [ - integration::one_c, - integration::moy_sklad - ], - static::complex => [ - integration::one_c, - integration::moy_sklad - ], - default => [] - }; - } */ - /** * Cost * @@ -240,4 +203,41 @@ enum architecture default => 5 }; } + + /** + * Workers + * + * @return array Workers + */ + public function workers(): array + { + // Exit (success) + return match ($this) { + static::chat_robot => [ + worker_type::programmer->name => 1, + worker_type::booster->name => 1 + ], + static::parser => [ + worker_type::programmer->name => 1 + ], + static::script => [ + worker_type::programmer->name => 1 + ], + static::site => [ + worker_type::programmer->name => 1, + worker_type::designer->name => 1, + worker_type::booster->name => 1 + ], + static::program => [ + worker_type::programmer->name => 1, + worker_type::designer->name => 1 + ], + static::complex => [ + worker_type::programmer->name => 1 + ], + default => [ + worker_type::programmer->name => 1 + ] + }; + } } diff --git a/kodorvan/constructor/system/models/project/enumerations/purpose.php b/kodorvan/constructor/system/models/project/enumerations/purpose.php index 29271bf..2444ebc 100644 --- a/kodorvan/constructor/system/models/project/enumerations/purpose.php +++ b/kodorvan/constructor/system/models/project/enumerations/purpose.php @@ -31,7 +31,7 @@ enum purpose /* case charity; */ case search; case calculate; - /* case logic; */ + case logic; case game; /* case workers; @@ -121,7 +121,7 @@ enum purpose }, */ static::special => match ($language) { language::en => 'Special', - language::ru => 'Особенный' + language::ru => 'Особенное' } }; } diff --git a/kodorvan/constructor/system/models/telegram/conversations/project/create.php b/kodorvan/constructor/system/models/telegram/conversations/project/create.php index 52a2259..f98c010 100644 --- a/kodorvan/constructor/system/models/telegram/conversations/project/create.php +++ b/kodorvan/constructor/system/models/telegram/conversations/project/create.php @@ -12,6 +12,7 @@ use kodorvan\constructor\models\core, kodorvan\constructor\models\project\enumerations\architecture as project_architecture, kodorvan\constructor\models\project\enumerations\purpose as project_purpose, kodorvan\constructor\models\project\enumerations\integration as project_integration, + kodorvan\constructor\models\worker\enumerations\type as worker_type, kodorvan\constructor\models\telegram\processes\language\select as process_language_select; // Library for languages support @@ -87,6 +88,15 @@ final class create extends menu */ public array $messages = []; + /** + * Workers + * + * Registry of project developments workers + * + * @var array $workers + */ + public array $workers = []; + /** * Start * @@ -100,7 +110,7 @@ final class create extends menu public function start(telegram $robot, bool $new = true): void { if ($new) { - // Requested creating a new process + // New // Ending the conversation $robot->endConversation(); @@ -118,29 +128,67 @@ final class create extends menu // Initializing the account $account = $robot->get('account'); - // Initializing the project development hours - $hours = $this->hours(); + // Title + $title = "🏛 *$localization->project_create_title*"; - // Initializing the calculated offer - $offer = "*$localization->project_create_time:* $hours$localization->project_create_time_hours _\(" . ceil(($hours / PROJECT_CREATE_DAY_HOURS) + PROJECT_CREATE_DAY_ADDITIONAL) . "$localization->project_create_time_days\)_\n" . "*$localization->project_create_cost:* " . unmarkdown((string) ceil($hours * $this->cost)) . $account->currency->symbol(); + // Declaring the message generation variables + $costs = $warnings = []; + $welcome = $time = null; + + if ($new) { + // New + + // Writing the project create message content + $welcome = $localization->project_create_description; + } else { + // Continue + + // Hours + $hours = $this->hours(); + + // Days + $days = ceil(($hours / PROJECT_CREATE_DAY_HOURS) + PROJECT_CREATE_DAY_ADDITIONAL); + + // Writing the project create message content (hours and days) + $time = "*$localization->project_create_time:* $hours$localization->project_create_time_hours _\($days$localization->project_create_time_days\)_"; + + if (isset($this->cost)) { + // Initialized the project development cost + + // Full cost + $full = ceil($hours * $this->cost); + + // Prepayment + $prepayment = ceil($full * (PROJECT_CREATE_COST_PREPAYMENT_PERCENTS / 100)); + + // Writing the project create message full cost + $costs['full'] = "*$localization->project_create_cost:* $full" . $account->currency->symbol(); + + // Writing the project create message cost prepayment + $costs['prepayment'] = "*$localization->project_create_cost_prepayment:* $prepayment" . $account->currency->symbol() . ' _\(' . PROJECT_CREATE_COST_PREPAYMENT_PERCENTS . '%\)_'; + + // Writing the project create message cost warning + $warnings['cost'] = "⚠️ " . $localization->project_create_warning_cost; + } + } // Generating the message text $text = implode( "\n\n", array_filter( [ - "🏛 *$localization->project_create_title*", - $new - ? $localization->project_create_description - : $offer, - !$new || isset($this->cost) - ? '⚠️ ' . $localization->project_create_cost_description - : null, + $title, + $welcome, + $time, + implode("\n", $costs), + implode("\n", $warnings), ] ) ); if ($this->text !== $text) { + // The message text was changed + $this->menuText( text: $text, opt: [ @@ -517,32 +565,32 @@ final class create extends menu if (!$new) { // The project development hours was calculated + // Cost + $cost = '🛠 ' . (isset($this->cost) ? "$localization->project_create_button_cost_per_hour: $this->cost" . $account->currency->symbol() : $localization->project_create_button_cost_per_hour); - if (isset($this->cost)) { - // Initialized the project cost per hour + // Initializing the project development workers + if (empty($this->workers)) $this->workers = $this->architecture?->workers() ?? []; - // Writing the project buttons - $this->addButtonRow( - button::make( - text: '🛠 ' . "$localization->project_create_button_cost_per_hour: $this->cost" . $account->currency->symbol(), - callback_data: 'set@cost' - ), - button::make( - text: "📦 $localization->project_create_button_request", - callback_data: '@request' - ) - ); - } else { - // Not initialized the project cost per hour + // Writing the project buttons + $this->addButtonRow( + button::make( + text: $cost, + callback_data: 'set@cost' + ), + button::make( + text: '🤠 ' . sprintf($localization->project_create_button_team, count($this->workers), $localization->project_create_peoples), + callback_data: 'open@team' + ) + ); - // Writing the project cost per hour button - $this->addButtonRow( - button::make( - text: '🛠 ' . $localization->project_create_button_cost_per_hour, - callback_data: 'set@cost' - ) - ); - } + + // Writing the project cost per hour button + $this->addButtonRow( + button::make( + text: "📦 $localization->project_create_button_request", + callback_data: '@request' + ) + ); } // Updating the message and saving its text @@ -564,6 +612,89 @@ final class create extends menu $this->start(robot: $robot, new: false); } + /** + * Team + * + * Generate the project create team settings menu + * + * @param telegram $robot The robot + * + * @return void + */ + public function team(telegram $robot): void + { + // Initializing the account language + $language = $robot->get('language') ?? LANGUAGE_DEFAULT; + + // Initializing the account localization + $localization = $robot->get('localization') ?? new localization($language); + + // Initializing the project development workers + $this->workers ??= $this->architecture?->workers() ?? []; + + // Clearing the message buttons + $this->clearButtons(); + + // Writing the row into the keyboard + $this->addButtonRow( + button::make( + text: sprintf("🥷🏻 $localization->project_create_team_button_programmers", $this->workers[worker_type::programmer->name] ?? [], $localization->project_create_peoples), + callback_data: '@programmers' + ) + ); + + // Writing the row into the keyboard + $this->addButtonRow( + button::make( + text: sprintf("👽 $localization->project_create_team_button_designers", $this->workers[worker_type::designer->name] ?? [], $localization->project_create_peoples), + callback_data: '@designers' + ), + button::make( + text: sprintf("🦹🏻‍♀️ $localization->project_create_team_button_boosters", $this->workers[worker_type::booster->name] ?? [], $localization->project_create_peoples), + callback_data: '@boosters' + ) + ); + + // Writing the row into the keyboard + $this->addButtonRow( + button::make( + text: "🔏 $localization->project_create_button_back", + callback_data: '@continue' + ) + ); + + // Title + $title = "🤠 $localization->project_create_team_title"; + + // Description + $description = $localization->project_create_team_description; + + // Warning: cost + $warning_cost = '⚠️ ' . $localization->project_create_team_warning_cost; + + // Generating the message text + $text = implode( + "\n\n", + array_filter( + [ + $title, + $description, + $warning_cost, + ] + ) + ); + + // Updating the message text + $this->menuText( + text: $text, + opt: [ + 'parse_mode' => mode::MARKDOWN + ] + ); + + // Updating the message + $this->showMenu(); + } /** * Architectures @@ -744,7 +875,7 @@ final class create extends menu $this->clearButtons(); // Sending the process main menu - $this->start(robot: $robot, new: false); + $this->continue(robot: $robot); } /** @@ -934,7 +1065,7 @@ final class create extends menu $this->clearButtons(); // Sending the process main menu - $this->start(robot: $robot, new: false); + $this->continue(robot: $robot); } /** @@ -1060,10 +1191,12 @@ final class create extends menu } // Writing the "back" button into the menu - $this->addButtonRow(button::make( - text: "🔏 $localization->project_create_button_back", - callback_data: '@continue' - )); + $this->addButtonRow( + button::make( + text: "🔏 $localization->project_create_button_back", + callback_data: '@continue' + ) + ); // Deinitializing deprecated variables unset($row, $limit, $length, $generated, $integrations, $integration); @@ -1184,7 +1317,7 @@ final class create extends menu } // Sending the process main menu - $this->start(robot: $robot, new: false); + $this->continue(robot: $robot); } else { // Not a number @@ -1194,7 +1327,7 @@ final class create extends menu "\n\n", array_filter( [ - "⚠️ $localization->project_create_request_cost_error_not_a_number", + "⚠️ $localization->project_create_cost_error_not_a_number", ] ) ), @@ -1215,7 +1348,7 @@ final class create extends menu array_filter( [ sprintf( - "⚠️ $localization->project_create_request_cost_error_distance", + "⚠️ $localization->project_create_cost_error_distance", $minimum, $maximum ) @@ -1239,14 +1372,452 @@ final class create extends menu "\n\n", array_filter( [ - "✏️ *$localization->project_create_request_cost_title*", - $localization->project_create_request_cost_description, + "✏️ *$localization->project_create_cost_title*", + $localization->project_create_cost_description, sprintf( - $localization->project_create_request_cost_default, + $localization->project_create_cost_default, PROJECT_CREATE_COST_HOUR_DEFAULT, CURRENCY_DEFAULT->symbol() ?? '' ), - "⚠️ $localization->project_create_request_cost_warning" + "⚠️ $localization->project_create_cost_warning" + ] + ) + ), + parse_mode: mode::MARKDOWN, + disable_notification: true, + ) + ]; + + // Waiting for the user input + $this->next('cost'); + } + } + + /** + * Programmers + * + * Write the project programmers + * + * @param telegram $robot The robot + * + * @return void + */ + public function programmers(telegram $robot): void + { + // Initializing the account language + $language = $robot->get('language') ?? LANGUAGE_DEFAULT; + + // Initializing the account localization + $localization = $robot->get('localization') ?? new localization($language); + + // Initializing the user input message + $message = $robot->message(); + + // Initializing the user input message text + $text = $message?->text; + + // Initializing the message data + $data = $robot->callbackQuery()?->data; + + if (!empty($text) && $data !== 'set') { + // Not empty text + + // Initializing the message filters + $minimum = 2; + $maximum = 5; + + // Writing the user input message into the messages registry + $this->messages[] = $message; + + // Initializing the text length + $length = mb_strlen($text); + + if ($length >= $minimum) { + // More than minimum amount of symbols + + // Sanitizing + $float = filter_var($text, FILTER_SANITIZE_NUMBER_FLOAT); + + if (filter_var($float, FILTER_VALIDATE_FLOAT)) { + // Number + + // Writing the cost + $this->cost = (float) $float; + + try { + foreach ($this->messages as $message) { + // Iterating over messages registry + + // Deleting the message + $message->delete(); + + // Waiting just for rofls + usleep(200); + } + } catch (exception $exception) { + // Sending into the errors output buffer + error_log($exception->getMessage()); + } finally { + // Deinitializing the messages registry + $this->messages = []; + } + + // Sending the process main menu + $this->continue(robot: $robot); + } else { + // Not a number + + // Sending the message + $this->messages[] = $robot->sendMessage( + text: implode( + "\n\n", + array_filter( + [ + "⚠️ $localization->project_create_cost_error_not_a_number", + ] + ) + ), + parse_mode: mode::MARKDOWN, + disable_notification: true, + ); + + // Waiting for the user input + $this->next('cost'); + } + } else { + // Less or equal than minimum amount of symbols + + // Sending the message + $this->messages[] = $robot->sendMessage( + text: implode( + "\n\n", + array_filter( + [ + sprintf( + "⚠️ $localization->project_create_cost_error_distance", + $minimum, + $maximum + ) + ] + ) + ), + parse_mode: mode::MARKDOWN, + disable_notification: true, + ); + + // Waiting for the user input + $this->next('cost'); + } + } else { + // Empty text + + // Sending the message and reinitializing the messages registry + $this->messages = [ + $robot->sendMessage( + text: implode( + "\n\n", + array_filter( + [ + "✏️ *$localization->project_create_cost_title*", + $localization->project_create_cost_description, + sprintf( + $localization->project_create_cost_default, + PROJECT_CREATE_COST_HOUR_DEFAULT, + CURRENCY_DEFAULT->symbol() ?? '' + ), + "⚠️ $localization->project_create_cost_warning" + ] + ) + ), + parse_mode: mode::MARKDOWN, + disable_notification: true, + ) + ]; + + // Waiting for the user input + $this->next('cost'); + } + } + + /** + * Designers + * + * Write the project designers + * + * @param telegram $robot The robot + * + * @return void + */ + public function designers(telegram $robot): void + { + // Initializing the account language + $language = $robot->get('language') ?? LANGUAGE_DEFAULT; + + // Initializing the account localization + $localization = $robot->get('localization') ?? new localization($language); + + // Initializing the user input message + $message = $robot->message(); + + // Initializing the user input message text + $text = $message?->text; + + // Initializing the message data + $data = $robot->callbackQuery()?->data; + + if (!empty($text) && $data !== 'set') { + // Not empty text + + // Initializing the message filters + $minimum = 2; + $maximum = 5; + + // Writing the user input message into the messages registry + $this->messages[] = $message; + + // Initializing the text length + $length = mb_strlen($text); + + if ($length >= $minimum) { + // More than minimum amount of symbols + + // Sanitizing + $float = filter_var($text, FILTER_SANITIZE_NUMBER_FLOAT); + + if (filter_var($float, FILTER_VALIDATE_FLOAT)) { + // Number + + // Writing the cost + $this->cost = (float) $float; + + try { + foreach ($this->messages as $message) { + // Iterating over messages registry + + // Deleting the message + $message->delete(); + + // Waiting just for rofls + usleep(200); + } + } catch (exception $exception) { + // Sending into the errors output buffer + error_log($exception->getMessage()); + } finally { + // Deinitializing the messages registry + $this->messages = []; + } + + // Sending the process main menu + $this->continue(robot: $robot); + } else { + // Not a number + + // Sending the message + $this->messages[] = $robot->sendMessage( + text: implode( + "\n\n", + array_filter( + [ + "⚠️ $localization->project_create_cost_error_not_a_number", + ] + ) + ), + parse_mode: mode::MARKDOWN, + disable_notification: true, + ); + + // Waiting for the user input + $this->next('cost'); + } + } else { + // Less or equal than minimum amount of symbols + + // Sending the message + $this->messages[] = $robot->sendMessage( + text: implode( + "\n\n", + array_filter( + [ + sprintf( + "⚠️ $localization->project_create_cost_error_distance", + $minimum, + $maximum + ) + ] + ) + ), + parse_mode: mode::MARKDOWN, + disable_notification: true, + ); + + // Waiting for the user input + $this->next('cost'); + } + } else { + // Empty text + + // Sending the message and reinitializing the messages registry + $this->messages = [ + $robot->sendMessage( + text: implode( + "\n\n", + array_filter( + [ + "✏️ *$localization->project_create_cost_title*", + $localization->project_create_cost_description, + sprintf( + $localization->project_create_cost_default, + PROJECT_CREATE_COST_HOUR_DEFAULT, + CURRENCY_DEFAULT->symbol() ?? '' + ), + "⚠️ $localization->project_create_cost_warning" + ] + ) + ), + parse_mode: mode::MARKDOWN, + disable_notification: true, + ) + ]; + + // Waiting for the user input + $this->next('cost'); + } + } + + /** + * Boosters + * + * Write the project boosters + * + * @param telegram $robot The robot + * + * @return void + */ + public function boosters(telegram $robot): void + { + // Initializing the account language + $language = $robot->get('language') ?? LANGUAGE_DEFAULT; + + // Initializing the account localization + $localization = $robot->get('localization') ?? new localization($language); + + // Initializing the user input message + $message = $robot->message(); + + // Initializing the user input message text + $text = $message?->text; + + // Initializing the message data + $data = $robot->callbackQuery()?->data; + + if (!empty($text) && $data !== 'set') { + // Not empty text + + // Initializing the message filters + $minimum = 2; + $maximum = 5; + + // Writing the user input message into the messages registry + $this->messages[] = $message; + + // Initializing the text length + $length = mb_strlen($text); + + if ($length >= $minimum) { + // More than minimum amount of symbols + + // Sanitizing + $float = filter_var($text, FILTER_SANITIZE_NUMBER_FLOAT); + + if (filter_var($float, FILTER_VALIDATE_FLOAT)) { + // Number + + // Writing the cost + $this->cost = (float) $float; + + try { + foreach ($this->messages as $message) { + // Iterating over messages registry + + // Deleting the message + $message->delete(); + + // Waiting just for rofls + usleep(200); + } + } catch (exception $exception) { + // Sending into the errors output buffer + error_log($exception->getMessage()); + } finally { + // Deinitializing the messages registry + $this->messages = []; + } + + // Sending the process main menu + $this->continue(robot: $robot); + } else { + // Not a number + + // Sending the message + $this->messages[] = $robot->sendMessage( + text: implode( + "\n\n", + array_filter( + [ + "⚠️ $localization->project_create_cost_error_not_a_number", + ] + ) + ), + parse_mode: mode::MARKDOWN, + disable_notification: true, + ); + + // Waiting for the user input + $this->next('cost'); + } + } else { + // Less or equal than minimum amount of symbols + + // Sending the message + $this->messages[] = $robot->sendMessage( + text: implode( + "\n\n", + array_filter( + [ + sprintf( + "⚠️ $localization->project_create_cost_error_distance", + $minimum, + $maximum + ) + ] + ) + ), + parse_mode: mode::MARKDOWN, + disable_notification: true, + ); + + // Waiting for the user input + $this->next('cost'); + } + } else { + // Empty text + + // Sending the message and reinitializing the messages registry + $this->messages = [ + $robot->sendMessage( + text: implode( + "\n\n", + array_filter( + [ + "✏️ *$localization->project_create_cost_title*", + $localization->project_create_cost_description, + sprintf( + $localization->project_create_cost_default, + PROJECT_CREATE_COST_HOUR_DEFAULT, + CURRENCY_DEFAULT->symbol() ?? '' + ), + "⚠️ $localization->project_create_cost_warning" ] ) ), @@ -1283,7 +1854,7 @@ final class create extends menu // Initializing the project purpose $this->purpose = $purposes[0]; } else if (isset($this->purpose) && array_search($this->purpose, $purposes) !== false) { - // The project architrcture purpose is the same from deprecated purpose + // The project architecture purpose is the same from deprecated purpose // keep it } else { @@ -1410,11 +1981,17 @@ final class create extends menu // Initializing the receivers registry $receivers = PROJECT_CREATE_REQUEST_RECEIVERS; - // Initializing project data + // Architecture $architecture = unmarkdown($this->architecture?->label(language: $language) ?? $localization->project_request_empty); + + // Purpose $purpose = unmarkdown(isset($this->purpose) ? $this->purpose->label(language: $language) : $localization->project_request_empty); + + // Hours $hours = $this->hours(); + // P + // Generating the message text $text = implode( "\n\n", diff --git a/kodorvan/constructor/system/models/worker/enumerations/type.php b/kodorvan/constructor/system/models/worker/enumerations/type.php index fd1365d..ec31582 100644 --- a/kodorvan/constructor/system/models/worker/enumerations/type.php +++ b/kodorvan/constructor/system/models/worker/enumerations/type.php @@ -4,6 +4,9 @@ declare(strict_types=1); namespace kodorvan\constructor\models\worker\enumerations; +// The library for languages support +use mirzaev\languages\language; + // Built-in libraries use InvalidArgumentException as exception_argument, DomainException as exception_domain; @@ -15,11 +18,36 @@ use InvalidArgumentException as exception_argument, * * @license http://www.wtfpl.net/ Do What The Fuck You Want To Public License * @author Arsen Mirzaev Tatyano-Muradovich - * - * @deprecated */ enum type { case programmer; case designer; + case booster; + + /** + * Label + * + * @param language $language The language + * + * @return string The project architecture label + */ + public function label(language $language = LANGUAGE_DEFAULT): string + { + // Exit (success) + return match ($this) { + static::programmer => match ($language) { + language::en => 'Programmer', + language::ru => 'Программист' + }, + static::designer => match ($language) { + language::en => 'Designer', + language::ru => 'Дизайнер' + }, + static::booster => match ($language) { + language::en => 'Booster', + language::ru => 'Бустер' + } + }; + } }