diff --git a/src/Consultations/ApprovedTermVariables.php b/src/Consultations/ApprovedTermVariables.php index e2088bd..32fba4a 100644 --- a/src/Consultations/ApprovedTermVariables.php +++ b/src/Consultations/ApprovedTermVariables.php @@ -4,14 +4,17 @@ class ApprovedTermVariables extends CommonConsultationVariables { - const VAR_COURSE_DEADLINE = '@VarApprovedTerm'; - - // TODO Add variable to emails public static function defaultSectionsContent(): array { return [ - 'title' => '', - 'content' => '' + 'title' => __('Approved term ":consultation"', [ + 'consultation' => self::VAR_CONSULTATION_TITLE, + ]), + 'content' => self::wrapWithMjml(__('

Hello :user_name!

Reported term :proposed_term for consultation ":consultation" was approved.

', [ + 'user_name' => self::VAR_USER_NAME, + 'consultation' => self::VAR_CONSULTATION_TITLE, + 'proposed_term' => self::VAR_CONSULTATION_PROPOSED_TERM + ]),), ]; } } diff --git a/src/Consultations/CommonConsultationVariables.php b/src/Consultations/CommonConsultationVariables.php index 8193031..aef76cd 100644 --- a/src/Consultations/CommonConsultationVariables.php +++ b/src/Consultations/CommonConsultationVariables.php @@ -10,14 +10,18 @@ abstract class CommonConsultationVariables extends EmailVariables { const VAR_USER_NAME = '@VarUserName'; - const VAR_COURSE_TITLE = '@VarCourseTitle'; + const VAR_CONSULTATION_TITLE = '@VarConsultationTitle'; + const VAR_CONSULTATION_PROPOSED_TERM = '@VarConsultationProposedTerm'; + + public static function mockedVariables(?User $user = null): array { $faker = \Faker\Factory::create(); return array_merge(parent::mockedVariables(), [ self::VAR_USER_NAME => $faker->name(), - self::VAR_COURSE_TITLE => $faker->word(), + self::VAR_CONSULTATION_TITLE => $faker->word(), + ]); } @@ -25,7 +29,8 @@ public static function variablesFromEvent(EventWrapper $event): array { return array_merge(parent::variablesFromEvent($event), [ self::VAR_USER_NAME => $event->getUser()->name, - self::VAR_COURSE_TITLE => $event->getCourse()->title, + self::VAR_CONSULTATION_TITLE => $event->getConsultationTerm()->consultation->name, + self::VAR_CONSULTATION_PROPOSED_TERM => $event->getConsultationTerm()->executed_at, ]); } @@ -33,16 +38,18 @@ public static function requiredVariables(): array { return [ self::VAR_USER_NAME, - self::VAR_COURSE_TITLE, + self::VAR_CONSULTATION_TITLE, + self::VAR_CONSULTATION_PROPOSED_TERM, ]; } public static function requiredVariablesInSection(string $sectionKey): array { if ($sectionKey === 'content') { - [ + return [ self::VAR_USER_NAME, - self::VAR_COURSE_TITLE, + self::VAR_CONSULTATION_TITLE, + self::VAR_CONSULTATION_PROPOSED_TERM, ]; } return []; diff --git a/src/Consultations/RejectTermVariables.php b/src/Consultations/RejectTermVariables.php index 9048d16..03886ed 100644 --- a/src/Consultations/RejectTermVariables.php +++ b/src/Consultations/RejectTermVariables.php @@ -4,14 +4,17 @@ class RejectTermVariables extends CommonConsultationVariables { - const VAR_COURSE_DEADLINE = '@VarRejectTerm'; - - // TODO Add variable to emails public static function defaultSectionsContent(): array { return [ - 'title' => '', - 'content' => '' + 'title' => __('Reject term ":consultation"', [ + 'consultation' => self::VAR_CONSULTATION_TITLE, + ]), + 'content' => self::wrapWithMjml(__('

Hello :user_name!

Reported term :proposed_term for consultation ":consultation" was rejected.

', [ + 'user_name' => self::VAR_USER_NAME, + 'consultation' => self::VAR_CONSULTATION_TITLE, + 'proposed_term' => self::VAR_CONSULTATION_PROPOSED_TERM + ]),), ]; } } diff --git a/src/Consultations/ReportTermVariables.php b/src/Consultations/ReportTermVariables.php index f064e61..aa3fd85 100644 --- a/src/Consultations/ReportTermVariables.php +++ b/src/Consultations/ReportTermVariables.php @@ -2,16 +2,48 @@ namespace EscolaLms\TemplatesEmail\Consultations; +use EscolaLms\Templates\Events\EventWrapper; + class ReportTermVariables extends CommonConsultationVariables { - const VAR_COURSE_DEADLINE = '@VarReportTerm'; + const VAR_CONSULTATION_BUYER_NAME = '@VarConsultationBuyerName'; + + public static function requiredVariables(): array + { + return array_merge(parent::requiredVariables(), [ + self::VAR_CONSULTATION_BUYER_NAME, + ]); + } + + public static function requiredVariablesInSection(string $sectionKey): array + { + if ($sectionKey === 'content') { + return array_merge(parent::requiredVariablesInSection($sectionKey), [ + self::VAR_CONSULTATION_BUYER_NAME, + ]); + } + return []; + } + + public static function variablesFromEvent(EventWrapper $event): array + { + return array_merge(parent::variablesFromEvent($event), [ + self::VAR_CONSULTATION_BUYER_NAME => $event->getConsultationTerm()->orderItem->order->user->name, + ]); + } - // TODO Add variable to emails public static function defaultSectionsContent(): array { return [ - 'title' => '', - 'content' => '' + 'title' => __('Report term ":consultation"', [ + 'consultation' => self::VAR_CONSULTATION_TITLE, + ]), + 'content' => self::wrapWithMjml(__('

Hello :user_name!

Buyer :consultation_buyer_name consultation ":consultation" reported proposed term realization: :proposed_term.

', [ + 'user_name' => self::VAR_USER_NAME, + 'consultation_buyer_name' => self::VAR_CONSULTATION_BUYER_NAME, + 'consultation' => self::VAR_CONSULTATION_TITLE, + 'proposed_term' => self::VAR_CONSULTATION_PROPOSED_TERM + ]),), ]; } } diff --git a/src/EscolaLmsTemplatesEmailServiceProvider.php b/src/EscolaLmsTemplatesEmailServiceProvider.php index 38f51fa..23d6e2d 100644 --- a/src/EscolaLmsTemplatesEmailServiceProvider.php +++ b/src/EscolaLmsTemplatesEmailServiceProvider.php @@ -15,8 +15,8 @@ use EscolaLms\TemplatesEmail\Providers\AssignWithoutAccountTemplatesEventServiceProvider; use EscolaLms\TemplatesEmail\Providers\AuthTemplatesEventServiceProvider; use EscolaLms\TemplatesEmail\Providers\AuthTemplatesServiceProvider; -use EscolaLms\TemplatesEmail\Providers\CartTemplatesServiceProvider; use EscolaLms\TemplatesEmail\Providers\ConsultationTemplatesServiceProvider; +use EscolaLms\TemplatesEmail\Providers\CartTemplatesServiceProvider; use EscolaLms\TemplatesEmail\Providers\CourseTemplatesServiceProvider; use EscolaLms\TemplatesEmail\Providers\CsvUsersTemplatesServiceProvider; use EscolaLms\TemplatesEmail\Providers\TemplateServiceProvider;