diff --git a/app/ActionModule/Presenters/ActionBasePresenter.php b/app/ActionModule/Presenters/ActionBasePresenter.php new file mode 100644 index 000000000..b52d48501 --- /dev/null +++ b/app/ActionModule/Presenters/ActionBasePresenter.php @@ -0,0 +1,14 @@ +queryBus->handle(new SettingDateValueQuery(Settings::BANK_DOWNLOAD_FROM)); + $this->bankService->downloadTransactions($from); + + $response = new TextResponse(null); + $this->sendResponse($response); + } +} diff --git a/app/ActionModule/Presenters/MailingPresenter.php b/app/ActionModule/Presenters/MailingPresenter.php new file mode 100644 index 000000000..b91673a2c --- /dev/null +++ b/app/ActionModule/Presenters/MailingPresenter.php @@ -0,0 +1,55 @@ +queryBus->handle(new SettingStringValueQuery(Settings::SEMINAR_EMAIL_VERIFICATION_CODE))) { + $newEmail = $this->queryBus->handle(new SettingStringValueQuery(Settings::SEMINAR_EMAIL_UNVERIFIED)); + $this->commandBus->handle(new SetSettingStringValue(Settings::SEMINAR_EMAIL, $newEmail)); + + $this->commandBus->handle(new SetSettingStringValue(Settings::SEMINAR_EMAIL_UNVERIFIED, null)); + $this->commandBus->handle(new SetSettingStringValue(Settings::SEMINAR_EMAIL_VERIFICATION_CODE, null)); + + $this->flashMessage('admin.configuration.mailing_email_verification_successful', 'success'); + } else { + $this->flashMessage('admin.configuration.mailing_email_verification_error', 'danger'); + } + + if ($this->user->isAllowed(SrsResource::CONFIGURATION, Permission::MANAGE)) { + $this->redirect(':Admin:Configuration:Mailing:default'); + } else { + $this->redirect(':Web:Page:default'); + } + } +} diff --git a/app/ActionModule/Presenters/MaturityPresenter.php b/app/ActionModule/Presenters/MaturityPresenter.php new file mode 100644 index 000000000..bd432220b --- /dev/null +++ b/app/ActionModule/Presenters/MaturityPresenter.php @@ -0,0 +1,134 @@ +queryBus->handle(new SettingIntValueQuery(Settings::CANCEL_REGISTRATION_AFTER_MATURITY)); + if ($cancelRegistration !== null) { + $cancelRegistrationDate = (new DateTimeImmutable())->setTime(0, 0)->modify('-' . $cancelRegistration . ' days'); + } else { + return; + } + + foreach ($this->userRepository->findAllWithWaitingForPaymentApplication() as $user) { + $this->em->wrapInTransaction(function () use ($user, $cancelRegistrationDate): void { + // odhlášení účastníků s nezaplacnou přihláškou rolí + foreach ($user->getWaitingForPaymentRolesApplications() as $application) { + $maturityDate = $application->getMaturityDate(); + + if ($maturityDate !== null && $cancelRegistrationDate > $maturityDate) { + $this->applicationService->cancelRegistration($user, ApplicationState::CANCELED_NOT_PAID, null); + + return; + } + } + + // zrušení nezaplacených přihlášek podakcí + $subeventsApplicationCanceled = false; + foreach ($user->getWaitingForPaymentSubeventsApplications() as $application) { + $maturityDate = $application->getMaturityDate(); + + if ($maturityDate !== null && $cancelRegistrationDate > $maturityDate) { + $this->applicationService->cancelSubeventsApplication($application, ApplicationState::CANCELED_NOT_PAID, null); + $subeventsApplicationCanceled = true; + } + } + + // pokud účastníkovi nezbyde žádná podakce, je třeba odebrat i roli s cenou podle podakcí, případně jej odhlásit + if ($subeventsApplicationCanceled && $user->getSubevents()->isEmpty()) { + $newRoles = $user->getRoles()->filter(static fn (Role $role) => $role->getFee() !== null); + if ($newRoles->isEmpty()) { + $this->applicationService->cancelRegistration($user, ApplicationState::CANCELED_NOT_PAID, null); + } else { + $this->applicationService->updateRoles($user, $newRoles, null); + } + } + }); + } + + $response = new TextResponse(null); + $this->sendResponse($response); + } + + /** + * Rozešle přípomínky splatnosti. + * + * @throws Throwable + */ + public function actionSendReminders(): void + { + $maturityReminder = $this->queryBus->handle(new SettingIntValueQuery(Settings::MATURITY_REMINDER)); + if ($maturityReminder !== null) { + $maturityReminderDate = (new DateTimeImmutable())->setTime(0, 0)->modify('+' . $maturityReminder . ' days'); + } else { + return; + } + + foreach ($this->userRepository->findAllWithWaitingForPaymentApplication() as $user) { + foreach ($user->getWaitingForPaymentApplications() as $application) { + $maturityDate = $application->getMaturityDate(); + + if ($maturityReminderDate == $maturityDate) { + $this->mailService->sendMailFromTemplate(new ArrayCollection([$application->getUser()]), null, Template::MATURITY_REMINDER, [ + TemplateVariable::SEMINAR_NAME => $this->queryBus->handle(new SettingStringValueQuery(Settings::SEMINAR_NAME)), + TemplateVariable::APPLICATION_MATURITY => $maturityDate->format(Helpers::DATE_FORMAT), + ]); + } + } + } + + $response = new TextResponse(null); + $this->sendResponse($response); + } +} diff --git a/app/AdminModule/CmsModule/Components/DocumentTagsGridControl.php b/app/AdminModule/CmsModule/Components/DocumentTagsGridControl.php index 65379ff11..4aa9b1d8d 100644 --- a/app/AdminModule/CmsModule/Components/DocumentTagsGridControl.php +++ b/app/AdminModule/CmsModule/Components/DocumentTagsGridControl.php @@ -28,10 +28,10 @@ class DocumentTagsGridControl extends Control { public function __construct( - private readonly Translator $translator, - private readonly RoleRepository $roleRepository, - private readonly AclService $aclService, - private readonly TagRepository $tagRepository, + private Translator $translator, + private RoleRepository $roleRepository, + private AclService $aclService, + private TagRepository $tagRepository, ) { } diff --git a/app/AdminModule/CmsModule/Components/DocumentsGridControl.php b/app/AdminModule/CmsModule/Components/DocumentsGridControl.php index 893ff80af..48dda95b4 100644 --- a/app/AdminModule/CmsModule/Components/DocumentsGridControl.php +++ b/app/AdminModule/CmsModule/Components/DocumentsGridControl.php @@ -32,10 +32,10 @@ class DocumentsGridControl extends Control { public function __construct( - private readonly Translator $translator, - private readonly DocumentRepository $documentRepository, - private readonly TagRepository $tagRepository, - private readonly FilesService $filesService, + private Translator $translator, + private DocumentRepository $documentRepository, + private TagRepository $tagRepository, + private FilesService $filesService, ) { } diff --git a/app/AdminModule/CmsModule/Components/FaqGridControl.php b/app/AdminModule/CmsModule/Components/FaqGridControl.php index 9d66c4e1f..1a210a3ca 100644 --- a/app/AdminModule/CmsModule/Components/FaqGridControl.php +++ b/app/AdminModule/CmsModule/Components/FaqGridControl.php @@ -6,7 +6,7 @@ use App\Model\Cms\Repositories\FaqRepository; use Doctrine\ORM\NonUniqueResultException; -use Doctrine\ORM\NoResultException; +use Doctrine\ORM\ORMException; use Nette\Application\AbortException; use Nette\Application\UI\Control; use Nette\Localization\Translator; @@ -19,7 +19,7 @@ */ class FaqGridControl extends Control { - public function __construct(private readonly Translator $translator, private readonly FaqRepository $faqRepository) + public function __construct(private Translator $translator, private FaqRepository $faqRepository) { } @@ -102,6 +102,7 @@ public function handleDelete(int $id): void /** * Přesuene otázku $item_id mezi $prev_id a $next_id. * + * @throws ORMException * @throws AbortException */ public function handleSort(string|null $item_id, string|null $prev_id, string|null $next_id): void @@ -123,8 +124,8 @@ public function handleSort(string|null $item_id, string|null $prev_id, string|nu * Změní viditelnost otázky. * * @throws NonUniqueResultException + * @throws ORMException * @throws AbortException - * @throws NoResultException */ public function changeStatus(string $id, string $public): void { diff --git a/app/AdminModule/CmsModule/Components/NewsGridControl.php b/app/AdminModule/CmsModule/Components/NewsGridControl.php index b5b10c9c1..692f4d94f 100644 --- a/app/AdminModule/CmsModule/Components/NewsGridControl.php +++ b/app/AdminModule/CmsModule/Components/NewsGridControl.php @@ -6,6 +6,7 @@ use App\Model\Cms\Repositories\NewsRepository; use App\Utils\Helpers; +use Doctrine\ORM\ORMException; use Nette\Application\AbortException; use Nette\Application\UI\Control; use Nette\Localization\Translator; @@ -18,7 +19,7 @@ */ class NewsGridControl extends Control { - public function __construct(private readonly Translator $translator, private readonly NewsRepository $newsRepository) + public function __construct(private Translator $translator, private NewsRepository $newsRepository) { } @@ -97,6 +98,7 @@ public function handleDelete(int $id): void /** * Změní připíchnutí aktuality. * + * @throws ORMException * @throws AbortException */ public function changePinned(string $id, string $pinned): void diff --git a/app/AdminModule/CmsModule/Components/PagesGridControl.php b/app/AdminModule/CmsModule/Components/PagesGridControl.php index 94db1840a..1157c003a 100644 --- a/app/AdminModule/CmsModule/Components/PagesGridControl.php +++ b/app/AdminModule/CmsModule/Components/PagesGridControl.php @@ -11,8 +11,8 @@ use App\Services\AclService; use App\Services\CmsService; use Doctrine\ORM\NonUniqueResultException; -use Doctrine\ORM\NoResultException; use Doctrine\ORM\OptimisticLockException; +use Doctrine\ORM\ORMException; use Nette\Application\AbortException; use Nette\Application\UI\Control; use Nette\Application\UI\Form; @@ -34,11 +34,11 @@ class PagesGridControl extends Control { public function __construct( - private readonly Translator $translator, - private readonly CmsService $cmsService, - private readonly PageRepository $pageRepository, - private readonly RoleRepository $roleRepository, - private readonly AclService $aclService, + private Translator $translator, + private CmsService $cmsService, + private PageRepository $pageRepository, + private RoleRepository $roleRepository, + private AclService $aclService, ) { } @@ -159,7 +159,8 @@ public function createComponentPagesGrid(string $name): DataGrid * Zpracuje přidání stránky. * * @throws NonUniqueResultException - * @throws NoResultException + * @throws ORMException + * @throws OptimisticLockException */ public function add(stdClass $values): void { @@ -179,7 +180,8 @@ public function add(stdClass $values): void * Zpracuje upravení stránky. * * @throws NonUniqueResultException - * @throws NoResultException + * @throws ORMException + * @throws OptimisticLockException */ public function edit(string $id, stdClass $values): void { @@ -217,6 +219,7 @@ public function handleDelete(int $id): void * Přesune stránku s $item_id mezi $prev_id a $next_id. * * @throws AbortException + * @throws ORMException * @throws OptimisticLockException */ public function handleSort(string|null $item_id, string|null $prev_id, string|null $next_id): void @@ -239,8 +242,8 @@ public function handleSort(string|null $item_id, string|null $prev_id, string|nu * * @throws AbortException * @throws NonUniqueResultException + * @throws ORMException * @throws OptimisticLockException - * @throws NoResultException */ public function changeStatus(string $id, string $public): void { diff --git a/app/AdminModule/CmsModule/Forms/FaqFormFactory.php b/app/AdminModule/CmsModule/Forms/FaqFormFactory.php index 7cd27a033..f6b41f65b 100644 --- a/app/AdminModule/CmsModule/Forms/FaqFormFactory.php +++ b/app/AdminModule/CmsModule/Forms/FaqFormFactory.php @@ -7,9 +7,10 @@ use App\AdminModule\Forms\BaseFormFactory; use App\Model\Cms\Faq; use App\Model\Cms\Repositories\FaqRepository; +use App\Model\User\Repositories\UserRepository; use App\Model\User\User; use Doctrine\ORM\NonUniqueResultException; -use Doctrine\ORM\NoResultException; +use Doctrine\ORM\ORMException; use Nette; use Nette\Application\UI\Form; use stdClass; @@ -29,21 +30,22 @@ class FaqFormFactory /** * Přihlášený uživatel. */ - private User $user; + private User|null $user = null; public function __construct( - private readonly BaseFormFactory $baseFormFactory, - private readonly FaqRepository $faqRepository, + private BaseFormFactory $baseFormFactory, + private FaqRepository $faqRepository, + private UserRepository $userRepository, ) { } /** * Vytvoří formulář. */ - public function create(int|null $id, User $user): Form + public function create(int|null $id, int $userId): Form { $this->faq = $id === null ? null : $this->faqRepository->findById($id); - $this->user = $user; + $this->user = $this->userRepository->findById($userId); $form = $this->baseFormFactory->create(); @@ -86,11 +88,11 @@ public function create(int|null $id, User $user): Form * Zpracuje formulář. * * @throws NonUniqueResultException - * @throws NoResultException + * @throws ORMException */ public function processForm(Form $form, stdClass $values): void { - if ($form->isSubmitted() == $form['cancel']) { + if ($form->isSubmitted() === $form['cancel']) { return; } diff --git a/app/AdminModule/CmsModule/Forms/NewsFormFactory.php b/app/AdminModule/CmsModule/Forms/NewsFormFactory.php index 5a3b5d458..0005b2241 100644 --- a/app/AdminModule/CmsModule/Forms/NewsFormFactory.php +++ b/app/AdminModule/CmsModule/Forms/NewsFormFactory.php @@ -25,7 +25,7 @@ class NewsFormFactory */ private News|null $news = null; - public function __construct(private readonly BaseFormFactory $baseFormFactory, private readonly NewsRepository $newsRepository) + public function __construct(private BaseFormFactory $baseFormFactory, private NewsRepository $newsRepository) { } @@ -82,7 +82,7 @@ public function create(int|null $id): Form */ public function processForm(Form $form, stdClass $values): void { - if ($form->isSubmitted() == $form['cancel']) { + if ($form->isSubmitted() === $form['cancel']) { return; } diff --git a/app/AdminModule/CmsModule/Forms/PageForm.php b/app/AdminModule/CmsModule/Forms/PageForm.php index 4ca4110d4..5b6aa9542 100644 --- a/app/AdminModule/CmsModule/Forms/PageForm.php +++ b/app/AdminModule/CmsModule/Forms/PageForm.php @@ -20,6 +20,7 @@ use App\Services\CmsService; use App\Services\FilesService; use Doctrine\ORM\OptimisticLockException; +use Doctrine\ORM\ORMException; use Nette\Application\UI; use Nette\Application\UI\Form; use stdClass; @@ -58,13 +59,13 @@ class PageForm extends UI\Control public function __construct( public int $id, public string $area, - private readonly BaseFormFactory $baseFormFactory, - private readonly PageRepository $pageRepository, - private readonly AclService $aclService, - private readonly CmsService $cmsService, - private readonly RoleRepository $roleRepository, - private readonly TagRepository $tagRepository, - private readonly FilesService $filesService, + private BaseFormFactory $baseFormFactory, + private PageRepository $pageRepository, + private AclService $aclService, + private CmsService $cmsService, + private RoleRepository $roleRepository, + private TagRepository $tagRepository, + private FilesService $filesService, ) { $this->page = $this->pageRepository->findById($id); } @@ -152,6 +153,7 @@ public function createComponentForm(): Form * Zpracuje formulář. * * @throws PageException + * @throws ORMException * @throws OptimisticLockException */ public function processForm(Form $form, stdClass $values): void @@ -172,20 +174,20 @@ public function processForm(Form $form, stdClass $values): void } } - if ($form->isSubmitted() == $form['submitAdd']) { + if ($form->isSubmitted() === $form['submitAdd']) { $contentClass = '\\App\\Model\\Cms\\' . str_replace('_', '', ucwords($type, '_')) . 'Content'; $content = new $contentClass($page, $area); $content->setHeading($form->getTranslator()->translate('common.content.default_heading.' . $type)); $this->cmsService->saveContent($content); } - if ($form->isSubmitted() == $form['submitAdd']) { + if ($form->isSubmitted() === $form['submitAdd']) { $submitName = 'submitAdd'; - } elseif ($form->isSubmitted() == $form['submitMain']) { + } elseif ($form->isSubmitted() === $form['submitMain']) { $submitName = 'submitMain'; - } elseif ($form->isSubmitted() == $form['submitSidebar']) { + } elseif ($form->isSubmitted() === $form['submitSidebar']) { $submitName = 'submitSidebar'; - } elseif ($form->isSubmitted() == $form['submitAndContinue']) { + } elseif ($form->isSubmitted() === $form['submitAndContinue']) { $submitName = 'submitAndContinue'; } else { $submitName = 'submit'; diff --git a/app/AdminModule/CmsModule/Forms/templates/page_form.latte b/app/AdminModule/CmsModule/Forms/templates/page_form.latte index f87617c9e..8f68991cb 100644 --- a/app/AdminModule/CmsModule/Forms/templates/page_form.latte +++ b/app/AdminModule/CmsModule/Forms/templates/page_form.latte @@ -32,7 +32,7 @@
- {_"common.content.name.$type"} + {_common.content.name.$type}
diff --git a/app/AdminModule/CmsModule/Presenters/FaqPresenter.php b/app/AdminModule/CmsModule/Presenters/FaqPresenter.php index 8ceadcb8c..3242d709f 100644 --- a/app/AdminModule/CmsModule/Presenters/FaqPresenter.php +++ b/app/AdminModule/CmsModule/Presenters/FaqPresenter.php @@ -37,16 +37,16 @@ protected function createComponentFaqGrid(): FaqGridControl protected function createComponentFaqForm(): Form { - $form = $this->faqFormFactory->create((int) $this->getParameter('id'), $this->dbUser); + $form = $this->faqFormFactory->create((int) $this->getParameter('id'), $this->user->id); $form->onSuccess[] = function (Form $form, stdClass $values): void { - if ($form->isSubmitted() == $form['cancel']) { + if ($form->isSubmitted() === $form['cancel']) { $this->redirect('Faq:default'); } $this->flashMessage('admin.cms.faq.message.save_success', 'success'); - if ($form->isSubmitted() == $form['submitAndContinue']) { + if ($form->isSubmitted() === $form['submitAndContinue']) { $id = $values->id ?: $this->faqRepository->findLastId(); // todo: nahradit $this->redirect('Faq:edit', ['id' => $id]); } else { diff --git a/app/AdminModule/CmsModule/Presenters/NewsPresenter.php b/app/AdminModule/CmsModule/Presenters/NewsPresenter.php index dd5839710..207023269 100644 --- a/app/AdminModule/CmsModule/Presenters/NewsPresenter.php +++ b/app/AdminModule/CmsModule/Presenters/NewsPresenter.php @@ -40,13 +40,13 @@ protected function createComponentNewsForm(): Form $form = $this->newsFormFactory->create((int) $this->getParameter('id')); $form->onSuccess[] = function (Form $form, stdClass $values): void { - if ($form->isSubmitted() == $form['cancel']) { + if ($form->isSubmitted() === $form['cancel']) { $this->redirect('News:default'); } $this->flashMessage('admin.cms.news.message.save_success', 'success'); - if ($form->isSubmitted() == $form['submitAndContinue']) { + if ($form->isSubmitted() === $form['submitAndContinue']) { $id = $values->id ?: $this->newsRepository->findLastId(); // todo: nahradit $this->redirect('News:edit', ['id' => $id]); } else { diff --git a/app/AdminModule/Components/ApplicationsGridControl.php b/app/AdminModule/Components/ApplicationsGridControl.php index fc36c5a1b..5a3284b32 100644 --- a/app/AdminModule/Components/ApplicationsGridControl.php +++ b/app/AdminModule/Components/ApplicationsGridControl.php @@ -4,7 +4,6 @@ namespace App\AdminModule\Components; -use App\AdminModule\Presenters\AdminBasePresenter; use App\Model\Application\Application; use App\Model\Application\Repositories\ApplicationRepository; use App\Model\Application\RolesApplication; @@ -33,8 +32,6 @@ use Ublaboo\DataGrid\DataGrid; use Ublaboo\DataGrid\Exception\DataGridException; -use function assert; - /** * Komponenta pro správu přihlášek. */ @@ -43,14 +40,14 @@ class ApplicationsGridControl extends Control private User|null $user = null; public function __construct( - private readonly Translator $translator, - private readonly EntityManagerInterface $em, - private readonly ApplicationRepository $applicationRepository, - private readonly UserRepository $userRepository, - private readonly SubeventRepository $subeventRepository, - private readonly ApplicationService $applicationService, - private readonly SubeventService $subeventService, - private readonly Validators $validators, + private Translator $translator, + private EntityManagerInterface $em, + private ApplicationRepository $applicationRepository, + private UserRepository $userRepository, + private SubeventRepository $subeventRepository, + private ApplicationService $applicationService, + private SubeventService $subeventService, + private Validators $validators, ) { } @@ -214,7 +211,6 @@ public function add(stdClass $values): void $selectedSubevents = $this->subeventRepository->findSubeventsByIds($values->subevents); $p = $this->getPresenter(); - assert($p instanceof AdminBasePresenter); if (! $this->validators->validateSubeventsCapacities($selectedSubevents, $this->user)) { $p->flashMessage('admin.users.users_applications_subevents_occupied', 'danger'); @@ -230,7 +226,9 @@ public function add(stdClass $values): void return; } - $this->applicationService->addSubeventsApplication($this->user, $selectedSubevents, $p->getDbUser()); + $loggedUser = $this->userRepository->findById($this->getPresenter()->user->id); + + $this->applicationService->addSubeventsApplication($this->user, $selectedSubevents, $loggedUser); $p->flashMessage('admin.users.users_applications_saved', 'success'); $p->redrawControl('flashes'); @@ -248,7 +246,6 @@ public function edit(string $id, stdClass $values): void $selectedSubevents = $this->subeventRepository->findSubeventsByIds($values->subevents); $p = $this->getPresenter(); - assert($p instanceof AdminBasePresenter); if ($application instanceof RolesApplication) { if (! $selectedSubevents->isEmpty()) { @@ -280,7 +277,7 @@ public function edit(string $id, stdClass $values): void return; } - $loggedUser = $p->getDbUser(); + $loggedUser = $this->userRepository->findById($this->getPresenter()->user->id); $this->em->wrapInTransaction(function () use ($application, $selectedSubevents, $values, $loggedUser): void { if ($application instanceof SubeventsApplication) { @@ -331,10 +328,10 @@ public function handleCancelApplication(int $id): void $application = $this->applicationRepository->findById($id); $p = $this->getPresenter(); - assert($p instanceof AdminBasePresenter); if ($application instanceof SubeventsApplication && ! $application->isCanceled()) { - $this->applicationService->cancelSubeventsApplication($application, ApplicationState::CANCELED, $p->getDbUser()); + $loggedUser = $this->userRepository->findById($this->getPresenter()->user->id); + $this->applicationService->cancelSubeventsApplication($application, ApplicationState::CANCELED, $loggedUser); $p->flashMessage('admin.users.users_applications_application_canceled', 'success'); } diff --git a/app/AdminModule/Components/RolesGridControl.php b/app/AdminModule/Components/RolesGridControl.php index a77bbc29c..af95c3dc6 100644 --- a/app/AdminModule/Components/RolesGridControl.php +++ b/app/AdminModule/Components/RolesGridControl.php @@ -9,6 +9,7 @@ use App\Services\AclService; use App\Utils\Helpers; use Doctrine\ORM\OptimisticLockException; +use Doctrine\ORM\ORMException; use Nette\Application\AbortException; use Nette\Application\UI\Control; use Nette\Localization\Translator; @@ -23,9 +24,9 @@ class RolesGridControl extends Control { public function __construct( - private readonly Translator $translator, - private readonly AclService $aclService, - private readonly RoleRepository $roleRepository, + private Translator $translator, + private AclService $aclService, + private RoleRepository $roleRepository, ) { } @@ -128,6 +129,7 @@ public function handleDelete(int $id): void * Změní registrovatelnost role. * * @throws AbortException + * @throws ORMException * @throws OptimisticLockException */ public function changeRegisterable(string $id, string $registerable): void diff --git a/app/AdminModule/Components/UsersGridControl.php b/app/AdminModule/Components/UsersGridControl.php index e24d86ce1..2ff8a2281 100644 --- a/app/AdminModule/Components/UsersGridControl.php +++ b/app/AdminModule/Components/UsersGridControl.php @@ -4,7 +4,6 @@ namespace App\AdminModule\Components; -use App\AdminModule\Presenters\AdminBasePresenter; use App\Model\Acl\Repositories\RoleRepository; use App\Model\Acl\Role; use App\Model\CustomInput\CustomCheckbox; @@ -36,6 +35,7 @@ use App\Utils\Helpers; use DateTimeImmutable; use Doctrine\ORM\EntityManagerInterface; +use Doctrine\ORM\ORMException; use Doctrine\ORM\QueryBuilder; use Exception; use InvalidArgumentException; @@ -51,7 +51,6 @@ use Ublaboo\DataGrid\Exception\DataGridColumnStatusException; use Ublaboo\DataGrid\Exception\DataGridException; -use function assert; use function basename; /** @@ -62,20 +61,20 @@ class UsersGridControl extends Control private SessionSection $sessionSection; public function __construct( - private readonly QueryBus $queryBus, - private readonly Translator $translator, - private readonly EntityManagerInterface $em, - private readonly UserRepository $userRepository, - private readonly CustomInputRepository $customInputRepository, - private readonly RoleRepository $roleRepository, - private readonly ExcelExportService $excelExportService, - private readonly Session $session, - private readonly AclService $aclService, - private readonly ApplicationService $applicationService, - private readonly UserService $userService, - private readonly SkautIsEventEducationService $skautIsEventEducationService, - private readonly SkautIsEventGeneralService $skautIsEventGeneralService, - private readonly SubeventService $subeventService, + private QueryBus $queryBus, + private Translator $translator, + private EntityManagerInterface $em, + private UserRepository $userRepository, + private CustomInputRepository $customInputRepository, + private RoleRepository $roleRepository, + private ExcelExportService $excelExportService, + private Session $session, + private AclService $aclService, + private ApplicationService $applicationService, + private UserService $userService, + private SkautIsEventEducationService $skautIsEventEducationService, + private SkautIsEventGeneralService $skautIsEventGeneralService, + private SubeventService $subeventService, ) { $this->sessionSection = $session->getSection('srs'); } @@ -450,6 +449,7 @@ public function handleDelete(int $id): void /** * Změní stav uživatele. * + * @throws ORMException * @throws AbortException */ public function changeApproved(string $id, string $approved): void @@ -472,6 +472,7 @@ public function changeApproved(string $id, string $approved): void /** * Změní účast uživatele na semináři. * + * @throws ORMException * @throws AbortException */ public function changeAttended(string $id, string $attended): void @@ -528,7 +529,6 @@ public function groupChangeRoles(array $ids, array $value): void $selectedRoles = $this->roleRepository->findRolesByIds($value); $p = $this->getPresenter(); - assert($p instanceof AdminBasePresenter); // neni vybrana zadna role if ($selectedRoles->isEmpty()) { @@ -566,7 +566,7 @@ public function groupChangeRoles(array $ids, array $value): void return; } - $loggedUser = $p->getDbUser(); + $loggedUser = $this->userRepository->findById($p->getUser()->id); $this->em->wrapInTransaction(function () use ($selectedRoles, $users, $loggedUser): void { foreach ($users as $user) { @@ -613,9 +613,8 @@ public function groupMarkPaidToday(array $ids, string $paymentMethod): void $users = $this->userRepository->findUsersByIds($ids); $p = $this->getPresenter(); - assert($p instanceof AdminBasePresenter); - $loggedUser = $p->getDbUser(); + $loggedUser = $this->userRepository->findById($p->getUser()->id); $this->em->wrapInTransaction(function () use ($users, $paymentMethod, $loggedUser): void { foreach ($users as $user) { @@ -873,7 +872,6 @@ private function prepareInsertIntoSkautIsOptions(): array return $options; } - /** @throws AbortException */ private function reload(): void { $p = $this->getPresenter(); diff --git a/app/AdminModule/ConfigurationModule/Components/CustomInputsGridControl.php b/app/AdminModule/ConfigurationModule/Components/CustomInputsGridControl.php index 9b6d3d29e..ff396e73b 100644 --- a/app/AdminModule/ConfigurationModule/Components/CustomInputsGridControl.php +++ b/app/AdminModule/ConfigurationModule/Components/CustomInputsGridControl.php @@ -11,7 +11,7 @@ use App\Model\CustomInput\Repositories\CustomInputRepository; use App\Services\AclService; use Doctrine\ORM\NonUniqueResultException; -use Doctrine\ORM\NoResultException; +use Doctrine\ORM\ORMException; use Nette\Application\AbortException; use Nette\Application\UI\Control; use Nette\Localization\Translator; @@ -27,9 +27,9 @@ class CustomInputsGridControl extends Control { public function __construct( - private readonly Translator $translator, - private readonly CustomInputRepository $customInputRepository, - private readonly AclService $aclService, + private Translator $translator, + private CustomInputRepository $customInputRepository, + private AclService $aclService, ) { } @@ -117,6 +117,7 @@ public function handleDelete(int $id): void /** * Přesune vlastní pole s id $item_id mezi $prev_id a $next_id. * + * @throws ORMException * @throws AbortException */ public function handleSort(string|null $item_id, string|null $prev_id, string|null $next_id): void @@ -138,8 +139,8 @@ public function handleSort(string|null $item_id, string|null $prev_id, string|nu * Změní povinnost pole. * * @throws NonUniqueResultException + * @throws ORMException * @throws AbortException - * @throws NoResultException */ public function changeMandatory(string $id, string $mandatory): void { diff --git a/app/AdminModule/ConfigurationModule/Components/DiscountsGridControl.php b/app/AdminModule/ConfigurationModule/Components/DiscountsGridControl.php index f8b33d6e9..10f6f4024 100644 --- a/app/AdminModule/ConfigurationModule/Components/DiscountsGridControl.php +++ b/app/AdminModule/ConfigurationModule/Components/DiscountsGridControl.php @@ -19,7 +19,7 @@ */ class DiscountsGridControl extends Control { - public function __construct(private readonly Translator $translator, private readonly DiscountRepository $discountRepository, private readonly DiscountService $discountService) + public function __construct(private Translator $translator, private DiscountRepository $discountRepository, private DiscountService $discountService) { } diff --git a/app/AdminModule/ConfigurationModule/Components/PlacePointsGridControl.php b/app/AdminModule/ConfigurationModule/Components/PlacePointsGridControl.php index bdf45ab7f..96f87e183 100644 --- a/app/AdminModule/ConfigurationModule/Components/PlacePointsGridControl.php +++ b/app/AdminModule/ConfigurationModule/Components/PlacePointsGridControl.php @@ -20,7 +20,7 @@ */ class PlacePointsGridControl extends Control { - public function __construct(private readonly Translator $translator, private readonly PlacePointRepository $placePointRepository) + public function __construct(private Translator $translator, private PlacePointRepository $placePointRepository) { } diff --git a/app/AdminModule/ConfigurationModule/Components/SkautIsEventEducationGridControl.php b/app/AdminModule/ConfigurationModule/Components/SkautIsEventEducationGridControl.php index eca8ff6af..d89038194 100644 --- a/app/AdminModule/ConfigurationModule/Components/SkautIsEventEducationGridControl.php +++ b/app/AdminModule/ConfigurationModule/Components/SkautIsEventEducationGridControl.php @@ -20,9 +20,9 @@ class SkautIsEventEducationGridControl extends Control { public function __construct( - private readonly Translator $translator, - private readonly SubeventRepository $subeventRepository, - private readonly SkautIsCourseRepository $skautIsCourseRepository, + private Translator $translator, + private SubeventRepository $subeventRepository, + private SkautIsCourseRepository $skautIsCourseRepository, ) { } diff --git a/app/AdminModule/ConfigurationModule/Components/SubeventsGridControl.php b/app/AdminModule/ConfigurationModule/Components/SubeventsGridControl.php index a7f7424a9..76ff4f698 100644 --- a/app/AdminModule/ConfigurationModule/Components/SubeventsGridControl.php +++ b/app/AdminModule/ConfigurationModule/Components/SubeventsGridControl.php @@ -18,7 +18,7 @@ */ class SubeventsGridControl extends Control { - public function __construct(private readonly Translator $translator, private readonly SubeventRepository $subeventRepository) + public function __construct(private Translator $translator, private SubeventRepository $subeventRepository) { } diff --git a/app/AdminModule/ConfigurationModule/Forms/ApplicationFormFactory.php b/app/AdminModule/ConfigurationModule/Forms/ApplicationFormFactory.php index e84eed397..d0606d7bd 100644 --- a/app/AdminModule/ConfigurationModule/Forms/ApplicationFormFactory.php +++ b/app/AdminModule/ConfigurationModule/Forms/ApplicationFormFactory.php @@ -25,7 +25,7 @@ class ApplicationFormFactory { use Nette\SmartObject; - public function __construct(private readonly BaseFormFactory $baseFormFactory, private readonly CommandBus $commandBus, private readonly QueryBus $queryBus) + public function __construct(private BaseFormFactory $baseFormFactory, private CommandBus $commandBus, private QueryBus $queryBus) { } diff --git a/app/AdminModule/ConfigurationModule/Forms/BankFormFactory.php b/app/AdminModule/ConfigurationModule/Forms/BankFormFactory.php index 769bfc63b..a327a5484 100644 --- a/app/AdminModule/ConfigurationModule/Forms/BankFormFactory.php +++ b/app/AdminModule/ConfigurationModule/Forms/BankFormFactory.php @@ -31,7 +31,7 @@ class BankFormFactory { use Nette\SmartObject; - public function __construct(private readonly BaseFormFactory $baseFormFactory, private readonly CommandBus $commandBus, private readonly BankService $bankService) + public function __construct(private BaseFormFactory $baseFormFactory, private CommandBus $commandBus, private BankService $bankService) { } diff --git a/app/AdminModule/ConfigurationModule/Forms/CustomInputFormFactory.php b/app/AdminModule/ConfigurationModule/Forms/CustomInputFormFactory.php index 87be2a47e..380648982 100644 --- a/app/AdminModule/ConfigurationModule/Forms/CustomInputFormFactory.php +++ b/app/AdminModule/ConfigurationModule/Forms/CustomInputFormFactory.php @@ -19,7 +19,7 @@ use App\Services\AclService; use App\Utils\Helpers; use Doctrine\ORM\NonUniqueResultException; -use Doctrine\ORM\NoResultException; +use Doctrine\ORM\ORMException; use Nette; use Nette\Application\UI\Form; use stdClass; @@ -41,7 +41,7 @@ class CustomInputFormFactory */ private CustomInput|null $customInput = null; - public function __construct(private readonly BaseFormFactory $baseFormFactory, private readonly CustomInputRepository $customInputRepository, private readonly AclService $aclService, private readonly RoleRepository $roleRepository) + public function __construct(private BaseFormFactory $baseFormFactory, private CustomInputRepository $customInputRepository, private AclService $aclService, private RoleRepository $roleRepository) { } @@ -54,6 +54,8 @@ public function create(int $id): Form $form = $this->baseFormFactory->create(); + $form->addHidden('id'); + $form->addText('name', 'admin.configuration.custom_inputs_name') ->addRule(Form::FILLED, 'admin.configuration.custom_inputs_name_empty'); @@ -81,6 +83,7 @@ public function create(int $id): Form $optionsText->setDisabled(); $form->setDefaults([ + 'id' => $id, 'name' => $this->customInput->getName(), 'roles' => Helpers::getIds($this->customInput->getRoles()), 'type' => $this->customInput->getType(), @@ -104,11 +107,11 @@ public function create(int $id): Form * Zpracuje formulář. * * @throws NonUniqueResultException - * @throws NoResultException + * @throws ORMException */ public function processForm(Form $form, stdClass $values): void { - if ($form->isSubmitted() == $form['cancel']) { + if ($form->isSubmitted() === $form['cancel']) { return; } diff --git a/app/AdminModule/ConfigurationModule/Forms/DiscountForm.php b/app/AdminModule/ConfigurationModule/Forms/DiscountForm.php index d7e46e204..78de78429 100644 --- a/app/AdminModule/ConfigurationModule/Forms/DiscountForm.php +++ b/app/AdminModule/ConfigurationModule/Forms/DiscountForm.php @@ -9,6 +9,7 @@ use App\Model\Structure\Repositories\DiscountRepository; use App\Model\Structure\Repositories\SubeventRepository; use App\Services\DiscountService; +use Doctrine\ORM\ORMException; use Nette\Application\UI; use Nette\Application\UI\Form; use stdClass; @@ -40,10 +41,10 @@ class DiscountForm extends UI\Control /** @param int $id Id upravované slevy. */ public function __construct( public int $id, - private readonly BaseFormFactory $baseFormFactory, - private readonly DiscountRepository $discountRepository, - private readonly SubeventRepository $subeventRepository, - private readonly DiscountService $discountService, + private BaseFormFactory $baseFormFactory, + private DiscountRepository $discountRepository, + private SubeventRepository $subeventRepository, + private DiscountService $discountService, ) { $this->discount = $this->discountRepository->findById($id); } @@ -106,6 +107,8 @@ public function createComponentForm(): Form /** * Zpracuje formulář. + * + * @throws ORMException */ public function processForm(Form $form, stdClass $values): void { diff --git a/app/AdminModule/ConfigurationModule/Forms/GroupFormFactory.php b/app/AdminModule/ConfigurationModule/Forms/GroupFormFactory.php new file mode 100644 index 000000000..dc7f7681c --- /dev/null +++ b/app/AdminModule/ConfigurationModule/Forms/GroupFormFactory.php @@ -0,0 +1,119 @@ +baseFormFactory->create(); + + $renderer = $form->getRenderer(); + assert($renderer instanceof Bs4FormRenderer); + $renderer->wrappers['control']['container'] = 'div class="col-7"'; + $renderer->wrappers['label']['container'] = 'div class="col-5 col-form-label"'; + + $form->addText('groupMinMembers', 'admin.configuration.group_min_members') + ->addRule(Form::FILLED, 'admin.configuration.group_min_members_empty'); + + $form->addText('groupMaxMembers', 'admin.configuration.group_max_members') + ->addRule(Form::FILLED, 'admin.configuration.group_max_members_empty'); + + $groupFillTerm = new DateControl('admin.configuration.group_fill_term'); + $groupFillTerm->addRule(Form::FILLED, 'admin.configuration.group_fill_term_empty'); + $form->addComponent($groupFillTerm, 'groupFillTerm'); + + + + $form->addSubmit('submit', 'admin.common.save'); + + $form->setDefaults([ + 'groupMinMembers' => $this->queryBus->handle(new SettingStringValueQuery(Settings::GROUP_MIN_MEMBERS)), + 'groupMaxMembers' => $this->queryBus->handle(new SettingStringValueQuery(Settings::GROUP_MAX_MEMBERS)), + 'groupFillTerm' => $this->queryBus->handle(new SettingDateValueQuery(Settings::GROUP_FILL_TERM)), + ]); + + $form->onSuccess[] = [$this, 'processForm']; + + return $form; + } + + /** + * Zpracuje formulář. + * + * @throws Throwable + */ + public function processForm(Form $form, stdClass $values): void + { + $this->commandBus->handle(new SetSettingStringValue(Settings::GROUP_MIN_MEMBERS, $values->groupMinMembers)); + $this->commandBus->handle(new SetSettingStringValue(Settings::GROUP_MAX_MEMBERS, $values->groupMaxMembers)); + $this->commandBus->handle(new SetSettingDateValue(Settings::GROUP_FILL_TERM, $values->groupFillTerm)); + } + + /** + * Ověří, že datum začátku semináře je dříve než konce. + * + * @param DateTime[] $args + */ + public function validateSeminarFromDate(DateControl $field, array $args): bool + { + return $args[0] <= $args[1]; + } + + /** + * Ověří, že datum konce semináře je později než začátku. + * + * @param DateTime[] $args + */ + public function validateSeminarToDate(DateControl $field, array $args): bool + { + return $args[0] >= $args[1]; + } + + /** + * Ověří, že datum uzavření registrace je dříve než začátek semináře. + * + * @param DateTime[] $args + */ + public function validateEditRegistrationTo(DateControl $field, array $args): bool + { + return $args[0] < $args[1]; + } +} diff --git a/app/AdminModule/ConfigurationModule/Forms/MailingFormFactory.php b/app/AdminModule/ConfigurationModule/Forms/MailingFormFactory.php index b62828e5d..de4136bb3 100644 --- a/app/AdminModule/ConfigurationModule/Forms/MailingFormFactory.php +++ b/app/AdminModule/ConfigurationModule/Forms/MailingFormFactory.php @@ -5,15 +5,22 @@ namespace App\AdminModule\ConfigurationModule\Forms; use App\AdminModule\Forms\BaseFormFactory; +use App\Model\Mailing\Template; +use App\Model\Mailing\TemplateVariable; use App\Model\Settings\Commands\SetSettingArrayValue; use App\Model\Settings\Commands\SetSettingBoolValue; +use App\Model\Settings\Commands\SetSettingStringValue; use App\Model\Settings\Queries\SettingArrayValueQuery; use App\Model\Settings\Queries\SettingBoolValueQuery; +use App\Model\Settings\Queries\SettingStringValueQuery; use App\Model\Settings\Settings; use App\Services\CommandBus; +use App\Services\IMailService; use App\Services\QueryBus; use App\Utils\Validators; +use Doctrine\Common\Collections\ArrayCollection; use Nette; +use Nette\Application\LinkGenerator; use Nette\Application\UI\Form; use Nette\Forms\Controls\TextInput; use Nextras\FormsRendering\Renderers\Bs4FormRenderer; @@ -24,7 +31,11 @@ use function assert; use function explode; use function implode; +use function md5; +use function mt_rand; +use function substr; use function trim; +use function uniqid; /** * Formulář pro nastavení mailingu. @@ -34,10 +45,12 @@ class MailingFormFactory use Nette\SmartObject; public function __construct( - private readonly BaseFormFactory $baseFormFactory, - private readonly CommandBus $commandBus, - private readonly QueryBus $queryBus, - private readonly Validators $validators, + private BaseFormFactory $baseFormFactory, + private CommandBus $commandBus, + private QueryBus $queryBus, + private IMailService $mailService, + private LinkGenerator $linkGenerator, + private Validators $validators, ) { } @@ -55,6 +68,10 @@ public function create(int $id): Form $renderer->wrappers['control']['container'] = 'div class="col-7"'; $renderer->wrappers['label']['container'] = 'div class="col-5 col-form-label"'; + $form->addText('seminarEmail', 'admin.configuration.mailing_email') + ->addRule(Form::FILLED, 'admin.configuration.mailing_email_empty') + ->addRule(Form::EMAIL, 'admin.configuration.mailing_email_format'); + $form->addText('contactFormRecipients', 'admin.configuration.mailing_contact_form_recipients') ->addRule(Form::FILLED, 'admin.configuration.mailing_contact_form_recipients_empty') ->addRule([$this, 'validateEmails'], 'admin.configuration.mailing_contact_form_recipients_format'); @@ -64,6 +81,7 @@ public function create(int $id): Form $form->addSubmit('submit', 'admin.common.save'); $form->setDefaults([ + 'seminarEmail' => $this->queryBus->handle(new SettingStringValueQuery(Settings::SEMINAR_EMAIL)), 'contactFormRecipients' => implode(', ', $this->queryBus->handle(new SettingArrayValueQuery(Settings::CONTACT_FORM_RECIPIENTS))), 'contactFormGuestsAllowed' => $this->queryBus->handle(new SettingBoolValueQuery(Settings::CONTACT_FORM_GUESTS_ALLOWED)), ]); @@ -81,6 +99,25 @@ public function create(int $id): Form */ public function processForm(Form $form, stdClass $values): void { + if ($this->queryBus->handle(new SettingStringValueQuery(Settings::SEMINAR_EMAIL)) !== $values->seminarEmail) { + $this->commandBus->handle(new SetSettingStringValue(Settings::SEMINAR_EMAIL_UNVERIFIED, $values->seminarEmail)); + + $verificationCode = substr(md5(uniqid((string) mt_rand(), true)), 0, 8); + $this->commandBus->handle(new SetSettingStringValue(Settings::SEMINAR_EMAIL_VERIFICATION_CODE, $verificationCode)); + + $link = $this->linkGenerator->link('Action:Mailing:verify', ['code' => $verificationCode]); + + $this->mailService->sendMailFromTemplate( + null, + new ArrayCollection([$values->seminarEmail]), + Template::EMAIL_VERIFICATION, + [ + TemplateVariable::SEMINAR_NAME => $this->queryBus->handle(new SettingStringValueQuery(Settings::SEMINAR_NAME)), + TemplateVariable::EMAIL_VERIFICATION_LINK => $link, + ], + ); + } + $contactFormRecipients = array_map( static fn (string $o) => trim($o), explode(',', $values->contactFormRecipients), diff --git a/app/AdminModule/ConfigurationModule/Forms/PaymentForm.php b/app/AdminModule/ConfigurationModule/Forms/PaymentForm.php index 0efbde1d9..dfaad5c08 100644 --- a/app/AdminModule/ConfigurationModule/Forms/PaymentForm.php +++ b/app/AdminModule/ConfigurationModule/Forms/PaymentForm.php @@ -39,7 +39,7 @@ class PaymentForm extends UI\Control */ public array $onSave = []; - public function __construct(private readonly BaseFormFactory $baseFormFactory, private readonly CommandBus $commandBus, private readonly QueryBus $queryBus) + public function __construct(private BaseFormFactory $baseFormFactory, private CommandBus $commandBus, private QueryBus $queryBus) { } diff --git a/app/AdminModule/ConfigurationModule/Forms/PaymentProofFormFactory.php b/app/AdminModule/ConfigurationModule/Forms/PaymentProofFormFactory.php index 50cf0649f..6de145b08 100644 --- a/app/AdminModule/ConfigurationModule/Forms/PaymentProofFormFactory.php +++ b/app/AdminModule/ConfigurationModule/Forms/PaymentProofFormFactory.php @@ -25,7 +25,7 @@ class PaymentProofFormFactory { use Nette\SmartObject; - public function __construct(private readonly BaseFormFactory $baseFormFactory, private readonly CommandBus $commandBus, private readonly QueryBus $queryBus) + public function __construct(private BaseFormFactory $baseFormFactory, private CommandBus $commandBus, private QueryBus $queryBus) { } diff --git a/app/AdminModule/ConfigurationModule/Forms/PlaceDescriptionFormFactory.php b/app/AdminModule/ConfigurationModule/Forms/PlaceDescriptionFormFactory.php index 5134e378f..4f9d6ad1f 100644 --- a/app/AdminModule/ConfigurationModule/Forms/PlaceDescriptionFormFactory.php +++ b/app/AdminModule/ConfigurationModule/Forms/PlaceDescriptionFormFactory.php @@ -23,7 +23,7 @@ class PlaceDescriptionFormFactory { use Nette\SmartObject; - public function __construct(private readonly BaseFormFactory $baseFormFactory, private readonly CommandBus $commandBus, private readonly QueryBus $queryBus) + public function __construct(private BaseFormFactory $baseFormFactory, private CommandBus $commandBus, private QueryBus $queryBus) { } diff --git a/app/AdminModule/ConfigurationModule/Forms/PlacePointFormFactory.php b/app/AdminModule/ConfigurationModule/Forms/PlacePointFormFactory.php index 0f388acfe..3b9317709 100644 --- a/app/AdminModule/ConfigurationModule/Forms/PlacePointFormFactory.php +++ b/app/AdminModule/ConfigurationModule/Forms/PlacePointFormFactory.php @@ -22,7 +22,7 @@ class PlacePointFormFactory private PlacePoint|null $placePoint = null; - public function __construct(private readonly BaseFormFactory $baseFormFactory, private readonly PlacePointRepository $placePointRepository) + public function __construct(private BaseFormFactory $baseFormFactory, private PlacePointRepository $placePointRepository) { } @@ -70,7 +70,7 @@ public function create(int $id): Form */ public function processForm(Form $form, stdClass $values): void { - if ($form->isSubmitted() == $form['cancel']) { + if ($form->isSubmitted() === $form['cancel']) { return; } diff --git a/app/AdminModule/ConfigurationModule/Forms/ProgramFormFactory.php b/app/AdminModule/ConfigurationModule/Forms/ProgramFormFactory.php index 8fd3cc061..0776c963f 100644 --- a/app/AdminModule/ConfigurationModule/Forms/ProgramFormFactory.php +++ b/app/AdminModule/ConfigurationModule/Forms/ProgramFormFactory.php @@ -33,7 +33,7 @@ class ProgramFormFactory { use Nette\SmartObject; - public function __construct(private readonly BaseFormFactory $baseFormFactory, private readonly CommandBus $commandBus, private readonly QueryBus $queryBus) + public function __construct(private BaseFormFactory $baseFormFactory, private CommandBus $commandBus, private QueryBus $queryBus) { } diff --git a/app/AdminModule/ConfigurationModule/Forms/SeminarFormFactory.php b/app/AdminModule/ConfigurationModule/Forms/SeminarFormFactory.php index 9e7877bda..107bb3dff 100644 --- a/app/AdminModule/ConfigurationModule/Forms/SeminarFormFactory.php +++ b/app/AdminModule/ConfigurationModule/Forms/SeminarFormFactory.php @@ -31,10 +31,10 @@ class SeminarFormFactory use Nette\SmartObject; public function __construct( - private readonly BaseFormFactory $baseFormFactory, - private readonly CommandBus $commandBus, - private readonly QueryBus $queryBus, - private readonly SubeventRepository $subeventRepository, + private BaseFormFactory $baseFormFactory, + private CommandBus $commandBus, + private QueryBus $queryBus, + private SubeventRepository $subeventRepository, ) { } diff --git a/app/AdminModule/ConfigurationModule/Forms/SkautIsEventFormFactory.php b/app/AdminModule/ConfigurationModule/Forms/SkautIsEventFormFactory.php index 108ee4f84..97ba18f31 100644 --- a/app/AdminModule/ConfigurationModule/Forms/SkautIsEventFormFactory.php +++ b/app/AdminModule/ConfigurationModule/Forms/SkautIsEventFormFactory.php @@ -18,6 +18,7 @@ use App\Services\SkautIsEventEducationService; use App\Services\SkautIsEventGeneralService; use Doctrine\ORM\NonUniqueResultException; +use Doctrine\ORM\ORMException; use Nette; use Nette\Application\UI\Form; use Nextras\FormsRendering\Renderers\Bs4FormRenderer; @@ -35,13 +36,13 @@ class SkautIsEventFormFactory use Nette\SmartObject; public function __construct( - private readonly BaseFormFactory $baseFormFactory, - private readonly CommandBus $commandBus, - private readonly QueryBus $queryBus, - private readonly SkautIsCourseRepository $skautIsCourseRepository, - private readonly SkautIsEventGeneralService $skautIsEventGeneralService, - private readonly SkautIsEventEducationService $skautIsEventEducationService, - private readonly SubeventRepository $subeventRepository, + private BaseFormFactory $baseFormFactory, + private CommandBus $commandBus, + private QueryBus $queryBus, + private SkautIsCourseRepository $skautIsCourseRepository, + private SkautIsEventGeneralService $skautIsEventGeneralService, + private SkautIsEventEducationService $skautIsEventEducationService, + private SubeventRepository $subeventRepository, ) { } @@ -98,6 +99,7 @@ public function create(): Form * Zpracuje formulář. * * @throws NonUniqueResultException + * @throws ORMException * @throws Throwable */ public function processForm(Form $form, stdClass $values): void diff --git a/app/AdminModule/ConfigurationModule/Forms/SubeventFormFactory.php b/app/AdminModule/ConfigurationModule/Forms/SubeventFormFactory.php index 205fb8043..dad4428ec 100644 --- a/app/AdminModule/ConfigurationModule/Forms/SubeventFormFactory.php +++ b/app/AdminModule/ConfigurationModule/Forms/SubeventFormFactory.php @@ -33,10 +33,10 @@ class SubeventFormFactory private Subevent|null $subevent = null; public function __construct( - private readonly EntityManagerInterface $em, - private readonly BaseFormFactory $baseFormFactory, - private readonly SubeventRepository $subeventRepository, - private readonly SubeventService $subeventService, + private EntityManagerInterface $em, + private BaseFormFactory $baseFormFactory, + private SubeventRepository $subeventRepository, + private SubeventService $subeventService, ) { } @@ -49,6 +49,8 @@ public function create(int $id): Form $form = $this->baseFormFactory->create(); + $form->addHidden('id'); + $nameText = $form->addText('name', 'admin.configuration.subevents_name') ->addRule(Form::FILLED, 'admin.configuration.subevents_name_empty'); @@ -121,6 +123,7 @@ public function create(int $id): Form if ($this->subevent) { $form->setDefaults([ + 'id' => $id, 'name' => $this->subevent->getName(), 'registerableFrom' => $this->subevent->getRegisterableFrom(), 'registerableTo' => $this->subevent->getRegisterableTo(), @@ -141,7 +144,7 @@ public function create(int $id): Form */ public function processForm(Form $form, stdClass $values): void { - if ($form->isSubmitted() == $form['cancel']) { + if ($form->isSubmitted() === $form['cancel']) { return; } diff --git a/app/AdminModule/ConfigurationModule/Forms/SubeventsFormFactory.php b/app/AdminModule/ConfigurationModule/Forms/SubeventsFormFactory.php index 8a86a63f1..16c56cb6a 100644 --- a/app/AdminModule/ConfigurationModule/Forms/SubeventsFormFactory.php +++ b/app/AdminModule/ConfigurationModule/Forms/SubeventsFormFactory.php @@ -23,9 +23,9 @@ class SubeventsFormFactory use Nette\SmartObject; public function __construct( - private readonly BaseFormFactory $baseFormFactory, - private readonly CommandBus $commandBus, - private readonly QueryBus $queryBus, + private BaseFormFactory $baseFormFactory, + private CommandBus $commandBus, + private QueryBus $queryBus, ) { } diff --git a/app/AdminModule/ConfigurationModule/Forms/TicketsFormFactory.php b/app/AdminModule/ConfigurationModule/Forms/TicketsFormFactory.php index 55879ea1b..3a71e235a 100644 --- a/app/AdminModule/ConfigurationModule/Forms/TicketsFormFactory.php +++ b/app/AdminModule/ConfigurationModule/Forms/TicketsFormFactory.php @@ -23,7 +23,7 @@ */ class TicketsFormFactory { - public function __construct(private readonly BaseFormFactory $baseFormFactory, private readonly CommandBus $commandBus, private readonly QueryBus $queryBus) + public function __construct(private BaseFormFactory $baseFormFactory, private CommandBus $commandBus, private QueryBus $queryBus) { } diff --git a/app/AdminModule/ConfigurationModule/Forms/WebFormFactory.php b/app/AdminModule/ConfigurationModule/Forms/WebFormFactory.php index 5e5207855..1eac0f8e4 100644 --- a/app/AdminModule/ConfigurationModule/Forms/WebFormFactory.php +++ b/app/AdminModule/ConfigurationModule/Forms/WebFormFactory.php @@ -35,11 +35,11 @@ class WebFormFactory use Nette\SmartObject; public function __construct( - private readonly BaseFormFactory $baseFormFactory, - private readonly CommandBus $commandBus, - private readonly QueryBus $queryBus, - private readonly PageRepository $pageRepository, - private readonly FilesService $filesService, + private BaseFormFactory $baseFormFactory, + private CommandBus $commandBus, + private QueryBus $queryBus, + private PageRepository $pageRepository, + private FilesService $filesService, ) { } diff --git a/app/AdminModule/ConfigurationModule/Presenters/ApplicationPresenter.php b/app/AdminModule/ConfigurationModule/Presenters/ApplicationPresenter.php index 5a5ce1523..ea3b0a975 100644 --- a/app/AdminModule/ConfigurationModule/Presenters/ApplicationPresenter.php +++ b/app/AdminModule/ConfigurationModule/Presenters/ApplicationPresenter.php @@ -63,7 +63,7 @@ protected function createComponentCustomInputForm(): Form $form = $this->customInputFormFactory->create((int) $this->getParameter('id')); $form->onSuccess[] = function (Form $form, stdClass $values): void { - if ($form->isSubmitted() != $form['cancel']) { + if ($form->isSubmitted() !== $form['cancel']) { $this->flashMessage('admin.configuration.custom_inputs_saved', 'success'); } diff --git a/app/AdminModule/ConfigurationModule/Presenters/GroupPresenter.php b/app/AdminModule/ConfigurationModule/Presenters/GroupPresenter.php new file mode 100644 index 000000000..214815ace --- /dev/null +++ b/app/AdminModule/ConfigurationModule/Presenters/GroupPresenter.php @@ -0,0 +1,37 @@ +groupFormFactory->create(); + + $form->onSuccess[] = function (Form $form, stdClass $values): void { + $this->flashMessage('admin.configuration.configuration_saved', 'success'); + $this->redirect('this'); + }; + + return $form; + } +} diff --git a/app/AdminModule/ConfigurationModule/Presenters/MailingPresenter.php b/app/AdminModule/ConfigurationModule/Presenters/MailingPresenter.php index 3bb916be6..71c98392f 100644 --- a/app/AdminModule/ConfigurationModule/Presenters/MailingPresenter.php +++ b/app/AdminModule/ConfigurationModule/Presenters/MailingPresenter.php @@ -6,6 +6,8 @@ use App\AdminModule\ConfigurationModule\Forms\MailingFormFactory; use App\Model\Settings\Exceptions\SettingsItemNotFoundException; +use App\Model\Settings\Queries\SettingStringValueQuery; +use App\Model\Settings\Settings; use Nette\Application\UI\Form; use Nette\DI\Attributes\Inject; use stdClass; @@ -19,6 +21,12 @@ class MailingPresenter extends ConfigurationBasePresenter #[Inject] public MailingFormFactory $mailingFormFactory; + /** @throws Throwable */ + public function renderDefault(): void + { + $this->template->waiting = $this->queryBus->handle(new SettingStringValueQuery(Settings::SEMINAR_EMAIL_VERIFICATION_CODE)) !== null; + } + /** * @throws SettingsItemNotFoundException * @throws Throwable diff --git a/app/AdminModule/ConfigurationModule/Presenters/PlacePresenter.php b/app/AdminModule/ConfigurationModule/Presenters/PlacePresenter.php index 4ebfa07c2..4a488147d 100644 --- a/app/AdminModule/ConfigurationModule/Presenters/PlacePresenter.php +++ b/app/AdminModule/ConfigurationModule/Presenters/PlacePresenter.php @@ -59,7 +59,7 @@ protected function createComponentPlacePointForm(): Form $form = $this->placePointFormFactory->create((int) $this->getParameter('id')); $form->onSuccess[] = function (Form $form, stdClass $values): void { - if ($form->isSubmitted() == $form['cancel']) { + if ($form->isSubmitted() === $form['cancel']) { $this->redirect('Place:default'); } diff --git a/app/AdminModule/ConfigurationModule/Presenters/SubeventsPresenter.php b/app/AdminModule/ConfigurationModule/Presenters/SubeventsPresenter.php index 32a8af20e..14450c3fc 100644 --- a/app/AdminModule/ConfigurationModule/Presenters/SubeventsPresenter.php +++ b/app/AdminModule/ConfigurationModule/Presenters/SubeventsPresenter.php @@ -49,7 +49,7 @@ protected function createComponentSubeventForm(): Form $form = $this->subeventFormFactory->create((int) $this->getParameter('id')); $form->onSuccess[] = function (Form $form, stdClass $values): void { - if ($form->isSubmitted() != $form['cancel']) { + if ($form->isSubmitted() !== $form['cancel']) { $this->flashMessage('admin.configuration.subevents_saved', 'success'); } diff --git a/app/AdminModule/ConfigurationModule/Presenters/templates/Group/default.latte b/app/AdminModule/ConfigurationModule/Presenters/templates/Group/default.latte new file mode 100644 index 000000000..15324a3ce --- /dev/null +++ b/app/AdminModule/ConfigurationModule/Presenters/templates/Group/default.latte @@ -0,0 +1,6 @@ +{block main} +

{_admin.configuration.group_heading}

+
+ {control groupForm} +
+{/block} \ No newline at end of file diff --git a/app/AdminModule/ConfigurationModule/Presenters/templates/Mailing/default.latte b/app/AdminModule/ConfigurationModule/Presenters/templates/Mailing/default.latte index 1c32be5fb..2eb7dcc4a 100644 --- a/app/AdminModule/ConfigurationModule/Presenters/templates/Mailing/default.latte +++ b/app/AdminModule/ConfigurationModule/Presenters/templates/Mailing/default.latte @@ -1,6 +1,9 @@ {block main}

{_admin.configuration.mailing_heading}

+ {if $waiting} +
{_admin.configuration.mailing_email_verification_needed}
+ {/if} {control mailingForm}
{/block} \ No newline at end of file diff --git a/app/AdminModule/ConfigurationModule/Presenters/templates/sidebar.latte b/app/AdminModule/ConfigurationModule/Presenters/templates/sidebar.latte index e992fd693..cd16a581e 100644 --- a/app/AdminModule/ConfigurationModule/Presenters/templates/sidebar.latte +++ b/app/AdminModule/ConfigurationModule/Presenters/templates/sidebar.latte @@ -31,6 +31,9 @@
{_admin.configuration.menu.skautis} + + {_admin.configuration.menu.group} + {_admin.configuration.menu.web} diff --git a/app/AdminModule/Forms/AddLectorFormFactory.php b/app/AdminModule/Forms/AddLectorFormFactory.php index 8440aac67..f2052f847 100644 --- a/app/AdminModule/Forms/AddLectorFormFactory.php +++ b/app/AdminModule/Forms/AddLectorFormFactory.php @@ -30,10 +30,10 @@ class AddLectorFormFactory use Nette\SmartObject; public function __construct( - private readonly BaseFormFactory $baseFormFactory, - private readonly UserRepository $userRepository, - private readonly RoleRepository $roleRepository, - private readonly FilesService $filesService, + private BaseFormFactory $baseFormFactory, + private UserRepository $userRepository, + private RoleRepository $roleRepository, + private FilesService $filesService, ) { } @@ -106,7 +106,7 @@ public function create(): Form */ public function processForm(Form $form, stdClass $values): void { - if ($form->isSubmitted() == $form['cancel']) { + if ($form->isSubmitted() === $form['cancel']) { return; } diff --git a/app/AdminModule/Forms/AddRoleFormFactory.php b/app/AdminModule/Forms/AddRoleFormFactory.php index 4d9b683e9..fd41dd690 100644 --- a/app/AdminModule/Forms/AddRoleFormFactory.php +++ b/app/AdminModule/Forms/AddRoleFormFactory.php @@ -19,7 +19,7 @@ class AddRoleFormFactory { use Nette\SmartObject; - public function __construct(private readonly BaseFormFactory $baseFormFactory, private readonly AclService $aclService, private readonly RoleRepository $roleRepository) + public function __construct(private BaseFormFactory $baseFormFactory, private AclService $aclService, private RoleRepository $roleRepository) { } @@ -57,7 +57,7 @@ public function create(): Form */ public function processForm(Form $form, stdClass $values): void { - if ($form->isSubmitted() == $form['cancel']) { + if ($form->isSubmitted() === $form['cancel']) { return; } diff --git a/app/AdminModule/Forms/BaseFormFactory.php b/app/AdminModule/Forms/BaseFormFactory.php index c2f1591cd..3bcae5ae8 100644 --- a/app/AdminModule/Forms/BaseFormFactory.php +++ b/app/AdminModule/Forms/BaseFormFactory.php @@ -16,7 +16,7 @@ class BaseFormFactory { use Nette\SmartObject; - public function __construct(private readonly Translator $translator) + public function __construct(private Translator $translator) { } diff --git a/app/AdminModule/Forms/EditRoleFormFactory.php b/app/AdminModule/Forms/EditRoleFormFactory.php index e8a775a20..d7d6ba973 100644 --- a/app/AdminModule/Forms/EditRoleFormFactory.php +++ b/app/AdminModule/Forms/EditRoleFormFactory.php @@ -39,12 +39,12 @@ class EditRoleFormFactory private Role|null $role = null; public function __construct( - private readonly BaseFormFactory $baseFormFactory, - private readonly EntityManagerInterface $em, - private readonly AclService $aclService, - private readonly RoleRepository $roleRepository, - private readonly PageRepository $pageRepository, - private readonly PermissionRepository $permissionRepository, + private BaseFormFactory $baseFormFactory, + private EntityManagerInterface $em, + private AclService $aclService, + private RoleRepository $roleRepository, + private PageRepository $pageRepository, + private PermissionRepository $permissionRepository, ) { } @@ -183,7 +183,7 @@ public function create(int $id): Form */ public function processForm(Form $form, stdClass $values): void { - if ($form->isSubmitted() == $form['cancel']) { + if ($form->isSubmitted() === $form['cancel']) { return; } diff --git a/app/AdminModule/Forms/EditUserPersonalDetailsFormFactory.php b/app/AdminModule/Forms/EditUserPersonalDetailsFormFactory.php index 976a4d49b..83eac50a3 100644 --- a/app/AdminModule/Forms/EditUserPersonalDetailsFormFactory.php +++ b/app/AdminModule/Forms/EditUserPersonalDetailsFormFactory.php @@ -7,7 +7,7 @@ use App\Model\User\Repositories\UserRepository; use App\Model\User\User; use App\Services\FilesService; -use JsonException; +use Doctrine\ORM\ORMException; use Nette; use Nette\Application\UI\Form; use Nette\Utils\ImageException; @@ -35,16 +35,14 @@ class EditUserPersonalDetailsFormFactory private User|null $user = null; public function __construct( - private readonly BaseFormFactory $baseFormFactory, - private readonly UserRepository $userRepository, - private readonly FilesService $filesService, + private BaseFormFactory $baseFormFactory, + private UserRepository $userRepository, + private FilesService $filesService, ) { } /** * Vytvoří formulář. - * - * @throws JsonException */ public function create(int $id): Form { @@ -52,13 +50,15 @@ public function create(int $id): Form $form = $this->baseFormFactory->create(); + $form->addHidden('id'); + $photoUpload = $form->addUpload('photo', 'admin.users.users_photo'); $photoUpload->setHtmlAttribute('accept', 'image/*') ->setHtmlAttribute('data-show-preview', 'true') ->addCondition(Form::FILLED) ->addRule(Form::IMAGE, 'admin.users.users_photo_format'); - if ($this->user->hasPhoto()) { + if ($this->user->getPhoto() !== null) { $photoUpload->setHtmlAttribute('data-delete-url', '?do=removePhoto') ->setHtmlAttribute('data-initial-preview', json_encode([$this->user->getPhoto()], JSON_THROW_ON_ERROR)) ->setHtmlAttribute('data-initial-preview-show-delete', 'true') @@ -105,6 +105,7 @@ public function create(int $id): Form ->setHtmlAttribute('class', 'btn btn-warning'); $form->setDefaults([ + 'id' => $id, 'firstName' => $this->user->getFirstName(), 'lastName' => $this->user->getLastName(), 'nickName' => $this->user->getNickName(), @@ -127,11 +128,12 @@ public function create(int $id): Form * Zpracuje formulář. * * @throws Nette\Utils\UnknownImageFileException + * @throws ORMException * @throws ImageException */ public function processForm(Form $form, stdClass $values): void { - if ($form->isSubmitted() == $form['cancel']) { + if ($form->isSubmitted() === $form['cancel']) { return; } diff --git a/app/AdminModule/Forms/EditUserSeminarFormFactory.php b/app/AdminModule/Forms/EditUserSeminarFormFactory.php index 6a42e7c53..af070a837 100644 --- a/app/AdminModule/Forms/EditUserSeminarFormFactory.php +++ b/app/AdminModule/Forms/EditUserSeminarFormFactory.php @@ -4,7 +4,6 @@ namespace App\AdminModule\Forms; -use App\AdminModule\Presenters\AdminBasePresenter; use App\Model\Acl\Repositories\RoleRepository; use App\Model\Acl\Role; use App\Model\CustomInput\CustomCheckbox; @@ -23,7 +22,6 @@ use App\Model\CustomInput\CustomTextValue; use App\Model\CustomInput\Repositories\CustomInputRepository; use App\Model\CustomInput\Repositories\CustomInputValueRepository; -use App\Model\Mailing\Commands\CreateTemplateMail; use App\Model\Mailing\Template; use App\Model\Mailing\TemplateVariable; use App\Model\Settings\Queries\SettingStringValueQuery; @@ -32,8 +30,8 @@ use App\Model\User\User; use App\Services\AclService; use App\Services\ApplicationService; -use App\Services\CommandBus; use App\Services\FilesService; +use App\Services\IMailService; use App\Services\QueryBus; use App\Services\UserService; use App\Utils\Helpers; @@ -41,7 +39,6 @@ use Doctrine\Common\Collections\ArrayCollection; use Doctrine\ORM\EntityManagerInterface; use InvalidArgumentException; -use JsonException; use Nette; use Nette\Application\UI\Form; use Nette\Forms\Controls\MultiSelectBox; @@ -72,26 +69,24 @@ class EditUserSeminarFormFactory private User|null $user = null; public function __construct( - private readonly BaseFormFactory $baseFormFactory, - private readonly CommandBus $commandBus, - private readonly QueryBus $queryBus, - private readonly EntityManagerInterface $em, - private readonly UserRepository $userRepository, - private readonly CustomInputRepository $customInputRepository, - private readonly CustomInputValueRepository $customInputValueRepository, - private readonly RoleRepository $roleRepository, - private readonly ApplicationService $applicationService, - private readonly Validators $validators, - private readonly FilesService $filesService, - private readonly AclService $aclService, - private readonly UserService $userService, + private BaseFormFactory $baseFormFactory, + private QueryBus $queryBus, + private EntityManagerInterface $em, + private UserRepository $userRepository, + private CustomInputRepository $customInputRepository, + private CustomInputValueRepository $customInputValueRepository, + private RoleRepository $roleRepository, + private ApplicationService $applicationService, + private Validators $validators, + private FilesService $filesService, + private IMailService $mailService, + private AclService $aclService, + private UserService $userService, ) { } /** * Vytvoří formulář. - * - * @throws JsonException */ public function create(int $id): Form { @@ -99,6 +94,8 @@ public function create(int $id): Form $form = $this->baseFormFactory->create(); + $form->addHidden('id'); + if (! $this->user->isExternalLector()) { $rolesSelect = $form->addMultiSelect( 'roles', @@ -233,6 +230,7 @@ public function create(int $id): Form ->setHtmlAttribute('class', 'btn btn-warning'); $form->setDefaults([ + 'id' => $id, 'roles' => $this->roleRepository->findRolesIds($this->user->getRoles()), 'approved' => $this->user->isApproved(), 'attended' => $this->user->isAttended(), @@ -252,14 +250,11 @@ public function create(int $id): Form */ public function processForm(Form $form, stdClass $values): void { - if ($form->isSubmitted() == $form['cancel']) { + if ($form->isSubmitted() === $form['cancel']) { return; } - $presenter = $form->getPresenter(); - assert($presenter instanceof AdminBasePresenter); - - $loggedUser = $presenter->getDbUser(); + $loggedUser = $this->userRepository->findById($form->getPresenter()->user->id); $this->em->wrapInTransaction(function () use ($values, $loggedUser): void { $customInputValueChanged = false; @@ -338,10 +333,10 @@ public function processForm(Form $form, stdClass $values): void if ($customInputValueChanged) { assert($this->user instanceof User); - $this->commandBus->handle(new CreateTemplateMail(new ArrayCollection([$this->user]), null, Template::CUSTOM_INPUT_VALUE_CHANGED, [ + $this->mailService->sendMailFromTemplate(new ArrayCollection([$this->user]), null, Template::CUSTOM_INPUT_VALUE_CHANGED, [ TemplateVariable::SEMINAR_NAME => $this->queryBus->handle(new SettingStringValueQuery(Settings::SEMINAR_NAME)), TemplateVariable::USER => $this->user->getDisplayName(), - ])); + ]); } }); } diff --git a/app/AdminModule/GroupsModule/Components/GroupsGridControl.php b/app/AdminModule/GroupsModule/Components/GroupsGridControl.php new file mode 100644 index 000000000..0ca28d3f3 --- /dev/null +++ b/app/AdminModule/GroupsModule/Components/GroupsGridControl.php @@ -0,0 +1,166 @@ +sessionSection = $session->getSection('srs'); + } + + /** + * Vykreslí komponentu. + */ + public function render(): void + { + $this->template->setFile(__DIR__ . '/templates/groups_grid.latte'); + $this->template->render(); + } + + /** + * Vytvoří komponentu. + * + * @throws DataGridException + */ + public function createComponentGroupsGrid(string $name): void + { + $grid = new DataGrid($this, $name); + $grid->setTranslator($this->translator); + $grid->setDataSource($this->groupRepository->createQueryBuilder('g')); + $grid->setDefaultSort(['name' => 'ASC']); + $grid->setPagination(false); + + + $grid->addColumnText('name', 'admin.program.groups.column.name'); + + $grid->addColumnText('leader_email', 'admin.program.groups.column.name'); + $grid->addColumnText('places', 'admin.program.groups.column.name'); + $grid->addColumnText('price', 'admin.program.groups.column.name'); + + $grid->addInlineAdd()->setPositionTop()->onControlAdd[] = function (Container $container): void { + $container->addText('name', '') + ->addRule(Form::FILLED, 'admin.program.groups.column.name_empty') + ->addRule(Form::IS_NOT_IN, 'admin.program.groups.column.name_exists', $this->groupRepository->findAll()); + + $container->addText('places', '') + ->addCondition(Form::FILLED) + ->addRule(Form::INTEGER, 'admin.program.groups.column.capacity_format'); + }; + $grid->getInlineAdd()->onSubmit[] = [$this, 'add']; + + $grid->addInlineEdit()->onControlAdd[] = static function (Container $container): void { + $container->addText('name', '') + ->addRule(Form::FILLED, 'admin.program.groups.column.name_empty'); + + $container->addText('places', '') + ->addCondition(Form::FILLED) + ->addRule(Form::INTEGER, 'admin.program.groups.column.capacity_format'); + }; + $grid->getInlineEdit()->onSetDefaults[] = function (Container $container, Group $item): void { + $nameText = $container['name']; + assert($nameText instanceof TextInput); + $nameText->addRule(Form::IS_NOT_IN, 'admin.program.groups.column.name_exists', $this->groupRepository->findOthersNames($item->getId())); + + $container->setDefaults([ + 'name' => $item->getName(), + 'places' => $item->getPlaces(), + ]); + }; + $grid->getInlineEdit()->onSubmit[] = [$this, 'edit']; + + $grid->addAction('detail', 'admin.common.detail', 'Groups:detail') + ->setClass('btn btn-xs btn-primary'); + + $grid->addAction('delete', '', 'delete!') + ->setIcon('trash') + ->setTitle('admin.common.delete') + ->setClass('btn btn-xs btn-danger') + ->addAttributes([ + 'data-toggle' => 'confirmation', + 'data-content' => $this->translator->translate('admin.program.groups.action.delete_confirm'), + ]); + } + + /** + * Zpracuje přidání místnosti. + */ + public function add(stdClass $values): void + { + $group = new Group($values->name, $values->capacity !== '' ? $values->capacity : null); + + $this->commandBus->handle(new SaveGroup($group)); + + $p = $this->getPresenter(); + $p->flashMessage('admin.program.groups.message.save_success', 'success'); + $p->redrawControl('flashes'); + } + + /** + * Zpracuje úpravu místnosti. + */ + public function edit(string $id, stdClass $values): void + { + $group = $this->groupRepository->findById((int) $id); + + $group->setName($values->name); + $group->setCapacity($values->capacity !== '' ? $values->capacity : null); + + $this->commandBus->handle(new SaveGroup($group)); + + $p = $this->getPresenter(); + $p->flashMessage('admin.program.groups.message.save_success', 'success'); + $p->redrawControl('flashes'); + } + + /** + * Odstraní místnost. + * + * @throws AbortException + */ + public function handleDelete(int $id): void + { + $group = $this->groupRepository->findById($id); + + $this->commandBus->handle(new RemoveGroup($group)); + + $p = $this->getPresenter(); + $p->flashMessage('admin.program.groups.message.delete_success', 'success'); + $p->redirect('this'); + } + + +} diff --git a/app/AdminModule/GroupsModule/Components/IGroupsGridControlFactory.php b/app/AdminModule/GroupsModule/Components/IGroupsGridControlFactory.php new file mode 100644 index 000000000..af0adfb4b --- /dev/null +++ b/app/AdminModule/GroupsModule/Components/IGroupsGridControlFactory.php @@ -0,0 +1,16 @@ +template->setFile(__DIR__ . '/templates/status_grid.latte'); + $this->template->render(); + } + + /** + * Vytvoří komponentu. + * + * @throws DataGridException + */ + public function createComponentStatusGrid(string $name): void + { + $grid = new DataGrid($this, $name); + $grid->setTranslator($this->translator); + $grid->setDataSource($this->statusRepository->createQueryBuilder('c')); + $grid->setDefaultSort(['name' => 'ASC']); + $grid->setPagination(false); + + $grid->addColumnText('name', 'admin.groups.status.column.name'); + + $grid->addInlineAdd()->setPositionTop()->onControlAdd[] = function (Container $container): void { + $container->addText('name', '') + ->addRule(Form::FILLED, 'admin.groups.status.column.name_empty') + ->addRule(Form::IS_NOT_IN, 'admin.groups.status.column.name_exists', $this->statusRepository->findAllNames()); + + }; + $grid->getInlineAdd()->onSubmit[] = [$this, 'add']; + + $grid->addInlineEdit()->onControlAdd[] = static function (Container $container): void { + $container->addText('name', '') + ->addRule(Form::FILLED, 'admin.groups.status.column.name_empty'); + + }; + $grid->getInlineEdit()->onSetDefaults[] = function (Container $container, Status $item): void { + $nameText = $container['name']; + assert($nameText instanceof TextInput); + $nameText->addRule(Form::IS_NOT_IN, 'admin.groups.status.column.name_exists', $this->statusRepository->findOthersNames($item->getId())); + + $container->setDefaults([ + 'name' => $item->getName(), + ]); + }; + $grid->getInlineEdit()->onSubmit[] = [$this, 'edit']; + + $grid->addAction('delete', '', 'delete!') + ->setIcon('trash') + ->setTitle('admin.common.delete') + ->setClass('btn btn-xs btn-danger') + ->addAttributes([ + 'data-toggle' => 'confirmation', + 'data-content' => $this->translator->translate('admin.groups.status.action.delete_confirm'), + ]); + } + + /** + * Zpracuje přidání kategorie. + */ + public function add(stdClass $values): void + { + $status = new Status($values->name); + + + $this->commandBus->handle(new SaveStatus($status)); + + $this->getPresenter()->flashMessage('admin.groups.status.message.save_success', 'success'); + $this->getPresenter()->redrawControl('flashes'); + } + + /** + * Zpracuje úpravu kategorie. + * + * @throws Throwable + */ + public function edit(string $id, stdClass $values): void + { + $status = $this->statusRepository->findById((int) $id); + $statusOld = clone $status; + + $status->setName($values->name); + + $this->commandBus->handle(new SaveStatus($status)); + + $this->getPresenter()->flashMessage('admin.groups.status.message.save_success', 'success'); + $this->getPresenter()->redrawControl('flashes'); + } + + /** + * Odstraní kategorii. + * + * @throws AbortException + * @throws Throwable + */ + public function handleDelete(int $id): void + { + $status = $this->statusRepository->findById($id); + + $p = $this->getPresenter(); + + if ($status->getBlocks()->isEmpty()) { + $this->commandBus->handle(new RemoveStatus($status)); + $p->flashMessage('admin.groups.status.message.delete_success', 'success'); + } else { + $p->flashMessage('admin.groups.status.message.delete_failed', 'danger'); + } + + $p->redirect('this'); + } +} diff --git a/app/AdminModule/GroupsModule/Components/templates/groups_grid.latte b/app/AdminModule/GroupsModule/Components/templates/groups_grid.latte new file mode 100644 index 000000000..b84b0d0e4 --- /dev/null +++ b/app/AdminModule/GroupsModule/Components/templates/groups_grid.latte @@ -0,0 +1 @@ +{control groupsGrid} \ No newline at end of file diff --git a/app/AdminModule/GroupsModule/Components/templates/status_grid.latte b/app/AdminModule/GroupsModule/Components/templates/status_grid.latte new file mode 100644 index 000000000..cb03db51c --- /dev/null +++ b/app/AdminModule/GroupsModule/Components/templates/status_grid.latte @@ -0,0 +1 @@ +{control statusGrid} \ No newline at end of file diff --git a/app/AdminModule/GroupsModule/Presenters/GroupsBasePresenter.php b/app/AdminModule/GroupsModule/Presenters/GroupsBasePresenter.php new file mode 100644 index 000000000..180535821 --- /dev/null +++ b/app/AdminModule/GroupsModule/Presenters/GroupsBasePresenter.php @@ -0,0 +1,26 @@ +checkPermission(Permission::MANAGE); + } +} diff --git a/app/AdminModule/GroupsModule/Presenters/GroupsPresenter.php b/app/AdminModule/GroupsModule/Presenters/GroupsPresenter.php new file mode 100644 index 000000000..d1e233206 --- /dev/null +++ b/app/AdminModule/GroupsModule/Presenters/GroupsPresenter.php @@ -0,0 +1,45 @@ +checkPermission(Permission::MANAGE); + } + + public function renderDetail(int $id): void + { + $group = $this->groupRepository->findById($id); + + $this->template->group = $group; + } + + protected function createComponentGroupsGrid(): GroupsGridControl + { + return $this->groupsGridControlFactory->create(); + } +} diff --git a/app/AdminModule/GroupsModule/Presenters/StatusPresenter.php b/app/AdminModule/GroupsModule/Presenters/StatusPresenter.php new file mode 100644 index 000000000..cb706769c --- /dev/null +++ b/app/AdminModule/GroupsModule/Presenters/StatusPresenter.php @@ -0,0 +1,33 @@ +checkPermission(Permission::MANAGE); + } + + protected function createComponentStatusGrid(): StatusGridControl + { + return $this->statusGridControlFactory->create(); + } +} diff --git a/app/AdminModule/GroupsModule/Presenters/templates/@layout.latte b/app/AdminModule/GroupsModule/Presenters/templates/@layout.latte new file mode 100644 index 000000000..1cc7452c7 --- /dev/null +++ b/app/AdminModule/GroupsModule/Presenters/templates/@layout.latte @@ -0,0 +1,2 @@ +{layout '../../../Presenters/templates/@layout.latte'} +{import 'sidebar.latte'} \ No newline at end of file diff --git a/app/AdminModule/GroupsModule/Presenters/templates/Groups/default.latte b/app/AdminModule/GroupsModule/Presenters/templates/Groups/default.latte new file mode 100644 index 000000000..e3374c03a --- /dev/null +++ b/app/AdminModule/GroupsModule/Presenters/templates/Groups/default.latte @@ -0,0 +1,4 @@ +{block main} +

{_admin.groups.group.heading}

+ {control groupsGrid} +{/block} \ No newline at end of file diff --git a/app/AdminModule/GroupsModule/Presenters/templates/Groups/detail.latte b/app/AdminModule/GroupsModule/Presenters/templates/Groups/detail.latte new file mode 100644 index 000000000..ffa3bba41 --- /dev/null +++ b/app/AdminModule/GroupsModule/Presenters/templates/Groups/detail.latte @@ -0,0 +1,6 @@ +{block main} +

{_admin.program.groups.detail.heading, ['name' => $room->getName()]}

+ +

{_admin.program.groups.schedule.heading}

+ {control groupscheduleGrid} +{/block} \ No newline at end of file diff --git a/app/AdminModule/GroupsModule/Presenters/templates/Status/default.latte b/app/AdminModule/GroupsModule/Presenters/templates/Status/default.latte new file mode 100644 index 000000000..c81cb73a3 --- /dev/null +++ b/app/AdminModule/GroupsModule/Presenters/templates/Status/default.latte @@ -0,0 +1,4 @@ +{block main} +

{_admin.groups.status.heading}

+ {control statusGrid} +{/block} \ No newline at end of file diff --git a/app/AdminModule/GroupsModule/Presenters/templates/sidebar.latte b/app/AdminModule/GroupsModule/Presenters/templates/sidebar.latte new file mode 100644 index 000000000..05f1d9ac9 --- /dev/null +++ b/app/AdminModule/GroupsModule/Presenters/templates/sidebar.latte @@ -0,0 +1,12 @@ +{block sidebar} + +{/block} \ No newline at end of file diff --git a/app/AdminModule/MailingModule/Components/MailHistoryGridControl.php b/app/AdminModule/MailingModule/Components/MailHistoryGridControl.php index 31ea730bf..17c68154f 100644 --- a/app/AdminModule/MailingModule/Components/MailHistoryGridControl.php +++ b/app/AdminModule/MailingModule/Components/MailHistoryGridControl.php @@ -21,10 +21,10 @@ class MailHistoryGridControl extends Control { public function __construct( - private readonly Translator $translator, - private readonly MailRepository $mailRepository, - private readonly AclService $aclService, - private readonly SubeventService $subeventService, + private Translator $translator, + private MailRepository $mailRepository, + private AclService $aclService, + private SubeventService $subeventService, ) { } @@ -49,14 +49,6 @@ public function createComponentMailHistoryGrid(string $name): void $grid->setItemsPerPageList([25, 50, 100, 250, 500]); $grid->setStrictSessionFilterValues(false); - $grid->addColumnText('recipientUsers', 'admin.mailing.history.recipient_users', 'recipientUsersText') - ->setFilterText() - ->setCondition(static function (QueryBuilder $qb, string $value): void { - $qb->join('m.recipientUsers', 'u') - ->andWhere('u.displayName LIKE :displayName') - ->setParameter('displayName', '%' . $value . '%'); - }); - $grid->addColumnText('recipientRoles', 'admin.mailing.history.recipient_roles', 'recipientRolesText') ->setFilterMultiSelect($this->aclService->getRolesWithoutRolesOptions([Role::GUEST, Role::UNAPPROVED, Role::NONREGISTERED])) ->setCondition(static function (QueryBuilder $qb, ArrayHash $values): void { @@ -73,11 +65,12 @@ public function createComponentMailHistoryGrid(string $name): void ->setParameter('sids', (array) $values); }); - $grid->addColumnText('recipientEmails', 'admin.mailing.history.recipient_emails', 'recipientEmailsText') + $grid->addColumnText('recipientUsers', 'admin.mailing.history.recipient_users', 'recipientUsersText') ->setFilterText() ->setCondition(static function (QueryBuilder $qb, string $value): void { - $qb->andWhere('m.recipientEmails LIKE :email') - ->setParameter('email', '%' . $value . '%'); + $qb->join('m.recipientUsers', 'u') + ->andWhere('u.displayName LIKE :displayName') + ->setParameter('displayName', '%' . $value . '%'); }); $grid->addColumnText('subject', 'admin.mailing.history.subject') diff --git a/app/AdminModule/MailingModule/Components/MailTemplatesGridControl.php b/app/AdminModule/MailingModule/Components/MailTemplatesGridControl.php index 9a4870bea..a1daf0b68 100644 --- a/app/AdminModule/MailingModule/Components/MailTemplatesGridControl.php +++ b/app/AdminModule/MailingModule/Components/MailTemplatesGridControl.php @@ -5,6 +5,7 @@ namespace App\AdminModule\MailingModule\Components; use App\Model\Mailing\Repositories\TemplateRepository; +use Doctrine\ORM\ORMException; use Nette\Application\AbortException; use Nette\Application\UI\Control; use Nette\Localization\Translator; @@ -17,7 +18,7 @@ */ class MailTemplatesGridControl extends Control { - public function __construct(private readonly Translator $translator, private readonly TemplateRepository $templateRepository) + public function __construct(private Translator $translator, private TemplateRepository $templateRepository) { } @@ -65,6 +66,7 @@ public function createComponentMailTemplatesGrid(string $name): DataGrid /** * Aktivuje/deaktivuje automatický e-mail. * + * @throws ORMException * @throws AbortException */ public function changeActive(string $id, string $active): void diff --git a/app/AdminModule/MailingModule/Forms/EditTemplateFormFactory.php b/app/AdminModule/MailingModule/Forms/EditTemplateFormFactory.php index bf5eab301..887c254c1 100644 --- a/app/AdminModule/MailingModule/Forms/EditTemplateFormFactory.php +++ b/app/AdminModule/MailingModule/Forms/EditTemplateFormFactory.php @@ -23,7 +23,7 @@ class EditTemplateFormFactory */ private Template|null $template = null; - public function __construct(private readonly BaseFormFactory $baseFormFactory, private readonly TemplateRepository $templateRepository) + public function __construct(private BaseFormFactory $baseFormFactory, private TemplateRepository $templateRepository) { } @@ -36,6 +36,8 @@ public function create(int $id): Form $form = $this->baseFormFactory->create(); + $form->addHidden('id'); + $form->addCheckbox('active', 'admin.mailing.templates.active_form'); $form->addText('subject', 'admin.mailing.templates.subject') @@ -52,6 +54,7 @@ public function create(int $id): Form ->setHtmlAttribute('class', 'btn btn-warning'); $form->setDefaults([ + 'id' => $id, 'active' => $this->template->isActive(), 'subject' => $this->template->getSubject(), 'text' => $this->template->getText(), @@ -68,7 +71,7 @@ public function create(int $id): Form */ public function processForm(Form $form, stdClass $values): void { - if ($form->isSubmitted() == $form['cancel']) { + if ($form->isSubmitted() === $form['cancel']) { return; } diff --git a/app/AdminModule/MailingModule/Forms/SendFormFactory.php b/app/AdminModule/MailingModule/Forms/SendFormFactory.php index 257a0caa0..6c9b0a945 100644 --- a/app/AdminModule/MailingModule/Forms/SendFormFactory.php +++ b/app/AdminModule/MailingModule/Forms/SendFormFactory.php @@ -7,17 +7,19 @@ use App\AdminModule\Forms\BaseFormFactory; use App\Model\Acl\Repositories\RoleRepository; use App\Model\Acl\Role; -use App\Model\Mailing\Commands\CreateMail; use App\Model\Structure\Repositories\SubeventRepository; use App\Model\User\Repositories\UserRepository; use App\Services\AclService; -use App\Services\CommandBus; +use App\Services\IMailService; use App\Services\SubeventService; use Doctrine\Common\Collections\ArrayCollection; use Nette; use Nette\Application\UI\Form; +use Nette\Mail\SendException; use stdClass; use Throwable; +use Tracy\Debugger; +use Tracy\ILogger; /** * Formulář pro vytvoření e-mailu. @@ -26,14 +28,19 @@ class SendFormFactory { use Nette\SmartObject; + /** + * Stav odeslání e-mailu. + */ + public bool $mailSuccess; + public function __construct( - private readonly BaseFormFactory $baseFormFactory, - private readonly CommandBus $commandBus, - private readonly RoleRepository $roleRepository, - private readonly UserRepository $userRepository, - private readonly SubeventRepository $subeventRepository, - private readonly AclService $aclService, - private readonly SubeventService $subeventService, + private BaseFormFactory $baseFormFactory, + private IMailService $mailService, + private RoleRepository $roleRepository, + private UserRepository $userRepository, + private SubeventRepository $subeventRepository, + private AclService $aclService, + private SubeventService $subeventService, ) { } @@ -44,13 +51,6 @@ public function create(): Form { $form = $this->baseFormFactory->create(); - $recipientUsersMultiSelect = $form->addMultiSelect( - 'recipientUsers', - 'admin.mailing.send.recipient_users', - $this->userRepository->getUsersOptions(), - ) - ->setHtmlAttribute('data-live-search', 'true'); - $recipientRolesMultiSelect = $form->addMultiSelect( 'recipientRoles', 'admin.mailing.send.recipient_roles', @@ -63,10 +63,12 @@ public function create(): Form $this->subeventService->getSubeventsOptionsWithUsersCount(), ); - $recipientUsersMultiSelect - ->addConditionOn($recipientRolesMultiSelect, Form::BLANK) - ->addConditionOn($recipientSubeventsMultiSelect, Form::BLANK) - ->addRule(Form::FILLED, 'admin.mailing.send.recipients_empty'); + $recipientUsersMultiSelect = $form->addMultiSelect( + 'recipientUsers', + 'admin.mailing.send.recipient_users', + $this->userRepository->getUsersOptions(), + ) + ->setHtmlAttribute('data-live-search', 'true'); $recipientRolesMultiSelect ->addConditionOn($recipientSubeventsMultiSelect, Form::BLANK) @@ -78,6 +80,11 @@ public function create(): Form ->addConditionOn($recipientUsersMultiSelect, Form::BLANK) ->addRule(Form::FILLED, 'admin.mailing.send.recipients_empty'); + $recipientUsersMultiSelect + ->addConditionOn($recipientRolesMultiSelect, Form::BLANK) + ->addConditionOn($recipientSubeventsMultiSelect, Form::BLANK) + ->addRule(Form::FILLED, 'admin.mailing.send.recipients_empty'); + $form->addText('copy', 'admin.mailing.send.copy') ->addCondition(Form::FILLED) ->addRule(Form::EMAIL, 'admin.mailing.send.copy_format'); @@ -104,15 +111,20 @@ public function create(): Form */ public function processForm(Form $form, stdClass $values): void { - $recipientsUsers = $this->userRepository->findUsersByIds($values->recipientUsers); - $recipientsRoles = $this->roleRepository->findRolesByIds($values->recipientRoles); - $recipientsSubevents = $this->subeventRepository->findSubeventsByIds($values->recipientSubevents); - $recipientsEmails = null; - - if (! empty($values->copy)) { - $recipientsEmails = new ArrayCollection([$values->copy]); + try { + $recipientsRoles = $this->roleRepository->findRolesByIds($values->recipientRoles); + $recipientsSubevents = $this->subeventRepository->findSubeventsByIds($values->recipientSubevents); + $recipientsUsers = $this->userRepository->findUsersByIds($values->recipientUsers); + $recipientsEmails = new ArrayCollection(); + if (! empty($values->copy)) { + $recipientsEmails->add($values->copy); + } + + $this->mailService->sendMail($recipientsRoles, $recipientsSubevents, $recipientsUsers, $recipientsEmails, $values->subject, $values->text); + $this->mailSuccess = true; + } catch (SendException $ex) { + Debugger::log($ex, ILogger::WARNING); + $this->mailSuccess = false; } - - $this->commandBus->handle(new CreateMail($recipientsUsers, $recipientsRoles, $recipientsSubevents, $recipientsEmails, $values->subject, $values->text)); } } diff --git a/app/AdminModule/MailingModule/Presenters/SendPresenter.php b/app/AdminModule/MailingModule/Presenters/SendPresenter.php index e77c75bea..8d0dc0d27 100644 --- a/app/AdminModule/MailingModule/Presenters/SendPresenter.php +++ b/app/AdminModule/MailingModule/Presenters/SendPresenter.php @@ -22,7 +22,12 @@ protected function createComponentSendForm(): Form $form = $this->sendFormFactory->create(); $form->onSuccess[] = function (Form $form, stdClass $values): void { - $this->flashMessage('admin.mailing.send.sent', 'success'); + if ($this->sendFormFactory->mailSuccess) { + $this->flashMessage('admin.mailing.send.sent', 'success'); + } else { + $this->flashMessage('admin.mailing.send.error', 'danger'); + } + $this->redirect('this'); }; diff --git a/app/AdminModule/MailingModule/Presenters/TemplatesPresenter.php b/app/AdminModule/MailingModule/Presenters/TemplatesPresenter.php index a5cf63f7d..635daf646 100644 --- a/app/AdminModule/MailingModule/Presenters/TemplatesPresenter.php +++ b/app/AdminModule/MailingModule/Presenters/TemplatesPresenter.php @@ -44,7 +44,7 @@ protected function createComponentEditTemplateForm(): Form $form = $this->editTemplateFormFactory->create((int) $this->getParameter('id')); $form->onSuccess[] = function (Form $form, stdClass $values): void { - if ($form->isSubmitted() == $form['cancel']) { + if ($form->isSubmitted() === $form['cancel']) { $this->redirect('Templates:default'); } diff --git a/app/AdminModule/PaymentsModule/Components/PaymentsGridControl.php b/app/AdminModule/PaymentsModule/Components/PaymentsGridControl.php index c1f7a7299..83053c539 100644 --- a/app/AdminModule/PaymentsModule/Components/PaymentsGridControl.php +++ b/app/AdminModule/PaymentsModule/Components/PaymentsGridControl.php @@ -4,7 +4,6 @@ namespace App\AdminModule\PaymentsModule\Components; -use App\AdminModule\Presenters\AdminBasePresenter; use App\Model\Enums\PaymentState; use App\Model\Payment\Payment; use App\Model\Payment\Repositories\PaymentRepository; @@ -12,6 +11,7 @@ use App\Model\Settings\Queries\SettingDateValueQuery; use App\Model\Settings\Queries\SettingStringValueQuery; use App\Model\Settings\Settings; +use App\Model\User\Repositories\UserRepository; use App\Services\ApplicationService; use App\Services\BankService; use App\Services\QueryBus; @@ -29,20 +29,19 @@ use Ublaboo\DataGrid\DataGrid; use Ublaboo\DataGrid\Exception\DataGridException; -use function assert; - /** * Komponenta pro správu plateb. */ class PaymentsGridControl extends Control { public function __construct( - private readonly QueryBus $queryBus, - private readonly Translator $translator, - private readonly PaymentRepository $paymentRepository, - private readonly ApplicationService $applicationService, - private readonly BankService $bankService, - private readonly Session $session, + private QueryBus $queryBus, + private Translator $translator, + private PaymentRepository $paymentRepository, + private UserRepository $userRepository, + private ApplicationService $applicationService, + private BankService $bankService, + private Session $session, ) { } @@ -141,13 +140,12 @@ public function createComponentPaymentsGrid(string $name): void */ public function add(stdClass $values): void { - $p = $this->getPresenter(); - assert($p instanceof AdminBasePresenter); + $loggedUser = $this->userRepository->findById($this->getPresenter()->user->id); - $this->applicationService->createPaymentManual($values->date, $values->amount, $values->variableSymbol, $p->getDbUser()); + $this->applicationService->createPaymentManual($values->date, $values->amount, $values->variableSymbol, $loggedUser); - $p->flashMessage('admin.payments.payments.saved', 'success'); - $p->redrawControl('flashes'); + $this->getPresenter()->flashMessage('admin.payments.payments.saved', 'success'); + $this->getPresenter()->redrawControl('flashes'); } /** @@ -159,11 +157,11 @@ public function handleDelete(int $id): void { $payment = $this->paymentRepository->findById($id); - $p = $this->getPresenter(); - assert($p instanceof AdminBasePresenter); + $loggedUser = $this->userRepository->findById($this->getPresenter()->user->id); - $this->applicationService->removePayment($payment, $p->getDbUser()); + $this->applicationService->removePayment($payment, $loggedUser); + $p = $this->getPresenter(); $p->flashMessage('admin.payments.payments.deleted', 'success'); $p->redirect('this'); } diff --git a/app/AdminModule/PaymentsModule/Forms/EditPaymentFormFactory.php b/app/AdminModule/PaymentsModule/Forms/EditPaymentFormFactory.php index 59b8cf5c2..2977b2b2e 100644 --- a/app/AdminModule/PaymentsModule/Forms/EditPaymentFormFactory.php +++ b/app/AdminModule/PaymentsModule/Forms/EditPaymentFormFactory.php @@ -5,10 +5,10 @@ namespace App\AdminModule\PaymentsModule\Forms; use App\AdminModule\Forms\BaseFormFactory; -use App\AdminModule\Presenters\AdminBasePresenter; use App\Model\Application\Repositories\ApplicationRepository; use App\Model\Payment\Payment; use App\Model\Payment\Repositories\PaymentRepository; +use App\Model\User\Repositories\UserRepository; use App\Services\ApplicationService; use Nette; use Nette\Application\UI\Form; @@ -16,8 +16,6 @@ use stdClass; use Throwable; -use function assert; - /** * Formulář pro úpravu platby. */ @@ -31,10 +29,11 @@ class EditPaymentFormFactory private Payment|null $payment = null; public function __construct( - private readonly BaseFormFactory $baseFormFactory, - private readonly PaymentRepository $paymentRepository, - private readonly ApplicationRepository $applicationRepository, - private readonly ApplicationService $applicationService, + private BaseFormFactory $baseFormFactory, + private PaymentRepository $paymentRepository, + private ApplicationRepository $applicationRepository, + private UserRepository $userRepository, + private ApplicationService $applicationService, ) { } @@ -47,6 +46,8 @@ public function create(int $id): Form $form = $this->baseFormFactory->create(); + $form->addHidden('id'); + $inputDate = new DateControl('admin.payments.payments.date'); $form->addComponent($inputDate, 'date'); @@ -87,6 +88,7 @@ public function create(int $id): Form ); $form->setDefaults([ + 'id' => $id, 'date' => $this->payment->getDate(), 'amount' => $this->payment->getAmount(), 'variableSymbol' => $this->payment->getVariableSymbol(), @@ -105,13 +107,12 @@ public function create(int $id): Form */ public function processForm(Form $form, stdClass $values): void { - if ($form->isSubmitted() != $form['cancel']) { - $presenter = $form->getPresenter(); - assert($presenter instanceof AdminBasePresenter); + if ($form->isSubmitted() !== $form['cancel']) { + $loggedUser = $this->userRepository->findById($form->getPresenter()->user->id); $pairedApplications = $this->applicationRepository->findApplicationsByIds($values->pairedApplications); - $this->applicationService->updatePayment($this->payment, $values->date, $values->amount, $values->variableSymbol, $pairedApplications, $presenter->getDbUser()); + $this->applicationService->updatePayment($this->payment, $values->date, $values->amount, $values->variableSymbol, $pairedApplications, $loggedUser); } } } diff --git a/app/AdminModule/PaymentsModule/Presenters/PaymentsPresenter.php b/app/AdminModule/PaymentsModule/Presenters/PaymentsPresenter.php index 1ef645cd6..50fc5d52d 100644 --- a/app/AdminModule/PaymentsModule/Presenters/PaymentsPresenter.php +++ b/app/AdminModule/PaymentsModule/Presenters/PaymentsPresenter.php @@ -38,7 +38,7 @@ protected function createComponentEditPaymentForm(): Form $form = $this->editPaymentFormFactory->create((int) $this->getParameter('id')); $form->onSuccess[] = function (Form $form, stdClass $values): void { - if ($form->isSubmitted() != $form['cancel']) { + if ($form->isSubmitted() !== $form['cancel']) { $this->flashMessage('admin.payments.payments.saved', 'success'); } diff --git a/app/AdminModule/Presenters/AclPresenter.php b/app/AdminModule/Presenters/AclPresenter.php index c59f09b01..d4376d966 100644 --- a/app/AdminModule/Presenters/AclPresenter.php +++ b/app/AdminModule/Presenters/AclPresenter.php @@ -62,7 +62,7 @@ public function actionTest(int $id): void { $role = $this->roleRepository->findById($id); - $this->authenticator->updateRoles($this->getPresenter()->getUser(), $role); + $this->authenticator->updateRoles($this->getPresenter()->user, $role); $this->redirect(':Web:Page:default'); } @@ -78,7 +78,7 @@ protected function createComponentAddRoleForm(): Form $form = $this->addRoleFormFactory->create(); $form->onSuccess[] = function (Form $form, stdClass $values): void { - if ($form->isSubmitted() == $form['cancel']) { + if ($form->isSubmitted() === $form['cancel']) { $this->redirect('Acl:default'); } @@ -100,13 +100,13 @@ protected function createComponentEditRoleForm(): Form $form = $this->editRoleFormFactory->create((int) $this->getParameter('id')); $form->onSuccess[] = function (Form $form, stdClass $values): void { - if ($form->isSubmitted() == $form['cancel']) { + if ($form->isSubmitted() === $form['cancel']) { $this->redirect('Acl:default'); } $this->flashMessage('admin.acl.roles_saved', 'success'); - if ($form->isSubmitted() == $form['submitAndContinue']) { + if ($form->isSubmitted() === $form['submitAndContinue']) { $id = $values->id; $this->redirect('Acl:edit', ['id' => $id]); } else { diff --git a/app/AdminModule/Presenters/AdminBasePresenter.php b/app/AdminModule/Presenters/AdminBasePresenter.php index d311660ac..d5a9c9424 100644 --- a/app/AdminModule/Presenters/AdminBasePresenter.php +++ b/app/AdminModule/Presenters/AdminBasePresenter.php @@ -49,7 +49,7 @@ abstract class AdminBasePresenter extends BasePresenter /** * Přihlášený uživatel. */ - public User $dbUser; + public User|null $dbuser = null; /** @throws AbortException */ public function startup(): void @@ -71,7 +71,7 @@ public function startup(): void $this->redirect(':Web:Page:default'); } - $this->dbUser = $this->userRepository->findById($this->user->id); + $this->dbuser = $this->userRepository->findById($this->user->id); } /** @@ -82,7 +82,7 @@ public function beforeRender(): void { parent::beforeRender(); - $this->template->dbUser = $this->dbUser; + $this->template->dbuser = $this->dbuser; $this->template->resourceAcl = SrsResource::ACL; $this->template->resourceCms = SrsResource::CMS; @@ -91,6 +91,7 @@ public function beforeRender(): void $this->template->resourcePayments = SrsResource::PAYMENTS; $this->template->resourceMailing = SrsResource::MAILING; $this->template->resourceProgram = SrsResource::PROGRAM; + $this->template->resourceGroups = SrsResource::GROUPS; $this->template->permissionAccess = Permission::ACCESS; $this->template->permissionManage = Permission::MANAGE; @@ -103,7 +104,7 @@ public function beforeRender(): void $this->template->footer = $this->queryBus->handle(new SettingStringValueQuery(Settings::FOOTER)); $this->template->seminarName = $this->queryBus->handle(new SettingStringValueQuery(Settings::SEMINAR_NAME)); - $skautIsUserId = $this->dbUser->getSkautISUserId(); + $skautIsUserId = $this->dbuser->getSkautISUserId(); $skautIsRoles = $this->skautIsService->getUserRoles($skautIsUserId); $skautIsRoleSelectedId = $this->skautIsService->getUserRoleId(); $skautIsRoleSelected = array_filter($skautIsRoles, static fn (stdClass $r) => $r->ID === $skautIsRoleSelectedId); @@ -134,9 +135,4 @@ public function handleChangeRole(int $roleId): void $this->skautIsService->updateUserRole($roleId); $this->redirect('this'); } - - public function getDbUser(): User - { - return $this->dbUser; - } } diff --git a/app/AdminModule/Presenters/UsersPresenter.php b/app/AdminModule/Presenters/UsersPresenter.php index a78806f51..fb2812446 100644 --- a/app/AdminModule/Presenters/UsersPresenter.php +++ b/app/AdminModule/Presenters/UsersPresenter.php @@ -21,7 +21,6 @@ use App\Model\User\Queries\UserAttendsProgramsQuery; use App\Services\ApplicationService; use App\Services\ExcelExportService; -use JsonException; use Nette\Application\AbortException; use Nette\Application\UI\Form; use Nette\DI\Attributes\Inject; @@ -152,15 +151,15 @@ public function handleEditPayment(): void /** @throws Throwable */ public function handleCancelRegistration(): void { - $user = $this->userRepository->findById((int) $this->getParameter('id')); + $user = $this->userRepository->findById((int) $this->getParameter('id')); + $loggedUser = $this->userRepository->findById($this->user->id); - $this->applicationService->cancelRegistration($user, ApplicationState::CANCELED, $this->dbUser); + $this->applicationService->cancelRegistration($user, ApplicationState::CANCELED, $loggedUser); $this->flashMessage('admin.users.users_registration_canceled', 'success'); $this->redirect('this'); } - /** @throws AbortException */ public function handleRemovePhoto(): void { $user = $this->userRepository->findById((int) $this->getParameter('id')); @@ -181,7 +180,7 @@ protected function createComponentAddLectorForm(): Form $form = $this->addLectorFormFactory->create(); $form->onSuccess[] = function (Form $form, stdClass $values): void { - if ($form->isSubmitted() != $form['cancel']) { + if ($form->isSubmitted() !== $form['cancel']) { $this->flashMessage('admin.users.users_saved', 'success'); } @@ -191,13 +190,12 @@ protected function createComponentAddLectorForm(): Form return $form; } - /** @throws JsonException */ protected function createComponentEditUserPersonalDetailsForm(): Form { $form = $this->editUserPersonalDetailsFormFactory->create((int) $this->getParameter('id')); $form->onSuccess[] = function (Form $form, stdClass $values): void { - if ($form->isSubmitted() != $form['cancel']) { + if ($form->isSubmitted() !== $form['cancel']) { $this->flashMessage('admin.users.users_saved', 'success'); } @@ -207,7 +205,6 @@ protected function createComponentEditUserPersonalDetailsForm(): Form return $form; } - /** @throws JsonException */ protected function createComponentEditUserSeminarForm(): Form { $form = $this->editUserSeminarFormFactory->create((int) $this->getParameter('id')); @@ -221,7 +218,7 @@ protected function createComponentEditUserSeminarForm(): Form }; $form->onSuccess[] = function (Form $form, stdClass $values): void { - if ($form->isSubmitted() != $form['cancel']) { + if ($form->isSubmitted() !== $form['cancel']) { $this->flashMessage('admin.users.users_saved', 'success'); } diff --git a/app/AdminModule/Presenters/templates/Dashboard/default.latte b/app/AdminModule/Presenters/templates/Dashboard/default.latte index 079890a8d..33e4e8f19 100644 --- a/app/AdminModule/Presenters/templates/Dashboard/default.latte +++ b/app/AdminModule/Presenters/templates/Dashboard/default.latte @@ -83,7 +83,7 @@ @@ -106,7 +106,27 @@
-
+
+ +
+ +
{_admin.menu.mailing}
@@ -186,6 +206,11 @@
{_admin.configuration.menu.skautis}
+

{_admin.configuration.menu.web} diff --git a/app/AdminModule/Presenters/templates/Users/detail.latte b/app/AdminModule/Presenters/templates/Users/detail.latte index 75f1644a4..c5435d176 100644 --- a/app/AdminModule/Presenters/templates/Users/detail.latte +++ b/app/AdminModule/Presenters/templates/Users/detail.latte @@ -7,7 +7,7 @@

{_admin.users.users_detail_personal_details}

{if !$editPersonalDetails} -
+
{_admin.users.users_photo}
@@ -182,12 +182,12 @@ {var $startDay = $program->getStart()->format('N')} - {_"common.day.$startDay"} + {_common.day.$startDay} {$program->getStart()|date:"j. n. G:i"} {var $endDay = $program->getEnd()->format('N')} - {_"common.day.$endDay"} + {_common.day.$endDay} {$program->getEnd()|date:"j. n. G:i"} {$program->getBlock()->getName()} diff --git a/app/AdminModule/Presenters/templates/includes/main_menu.latte b/app/AdminModule/Presenters/templates/includes/main_menu.latte index 6c9ed73f0..c358cad91 100644 --- a/app/AdminModule/Presenters/templates/includes/main_menu.latte +++ b/app/AdminModule/Presenters/templates/includes/main_menu.latte @@ -42,7 +42,13 @@
{_admin.menu.mailing} -
  • + {_admin.menu.groups} +
  • + +
  • - +
    @@ -53,12 +53,12 @@ {var $startDay = $program->getStart()->format('N')} - {_"common.day.$startDay"} + {_common.day.$startDay} {$program->getStart()|date:"j. n. G:i"} {var $endDay = $program->getEnd()->format('N')} - {_"common.day.$endDay"} + {_common.day.$endDay} {$program->getEnd()|date:"j. n. G:i"} {$program->getBlock()->getName()} diff --git a/app/Mailing/SrsMail.php b/app/Mailing/SrsMail.php index f297c62ee..0aab9cf1a 100644 --- a/app/Mailing/SrsMail.php +++ b/app/Mailing/SrsMail.php @@ -17,8 +17,14 @@ class SrsMail extends AbstractMail implements IComposableMail /** @param SrsMailData|null $mailData */ public function compose(Message $message, IMessageData|null $mailData = null): void { - $message->setFrom($this->mailAddresses['senderEmail'], $mailData->getSenderName()); - $message->addTo($mailData->getTo()->getEmail(), $mailData->getTo()->getName()); + $message->setFrom($mailData->getFrom()->getEmail(), $mailData->getFrom()->getName()); + + foreach ($mailData->getRecipients() as $recipient) { + if (! empty($recipient->getEmail())) { + $message->addBcc($recipient->getEmail(), $recipient->getName()); + } + } + $message->setSubject($mailData->getSubject()); $this->template->subject = $mailData->getSubject(); diff --git a/app/Mailing/SrsMailData.php b/app/Mailing/SrsMailData.php index 77a41311d..43d890407 100644 --- a/app/Mailing/SrsMailData.php +++ b/app/Mailing/SrsMailData.php @@ -13,27 +13,28 @@ class SrsMailData implements IMessageData { /** - * @param string $senderName Jméno odesilatele mailu. - * @param Recipient $to Příjemce mailu. - * @param string $subject Předmět mailu. - * @param string $text Text mailu. + * @param Recipient $from Odesilatel mailu. + * @param Recipient[] $recipients Příjemci mailu. + * @param string $subject Předmět mailu. + * @param string $text Text mailu. */ public function __construct( - private readonly string $senderName, - private readonly Recipient $to, - private readonly string $subject, - private readonly string $text, + private Recipient $from, + private array $recipients, + private string $subject, + private string $text, ) { } - public function getSenderName(): string + public function getFrom(): Recipient { - return $this->senderName; + return $this->from; } - public function getTo(): Recipient + /** @return Recipient[] */ + public function getRecipients(): array { - return $this->to; + return $this->recipients; } public function getSubject(): string diff --git a/app/Model/Acl/Permission.php b/app/Model/Acl/Permission.php index 8d57f10ea..4d4608e75 100644 --- a/app/Model/Acl/Permission.php +++ b/app/Model/Acl/Permission.php @@ -81,7 +81,7 @@ class Permission /** * Prostředek oprávnění. */ - #[ORM\ManyToOne(targetEntity: SrsResource::class, cascade: ['persist'], inversedBy: 'permissions')] + #[ORM\ManyToOne(targetEntity: SrsResource::class, inversedBy: 'permissions', cascade: ['persist'])] protected SrsResource $resource; public function __construct(string $name, SrsResource $resource) diff --git a/app/Model/Acl/SrsResource.php b/app/Model/Acl/SrsResource.php index 2a0a8f4ca..7371688f9 100644 --- a/app/Model/Acl/SrsResource.php +++ b/app/Model/Acl/SrsResource.php @@ -45,6 +45,11 @@ class SrsResource */ public const USERS = 'users'; + /** + * Skupiny. + */ + public const GROUPS = 'groups'; + /** * Mailing. */ @@ -63,6 +68,7 @@ class SrsResource self::PROGRAM, self::CONFIGURATION, self::USERS, + self::GROUPS, self::MAILING, self::PAYMENTS, ]; @@ -83,7 +89,7 @@ class SrsResource * * @var Collection */ - #[ORM\OneToMany(mappedBy: 'resource', targetEntity: Permission::class, cascade: ['persist'])] + #[ORM\OneToMany(targetEntity: Permission::class, mappedBy: 'resource', cascade: ['persist'])] protected Collection $permissions; /** @param string $name Název prostředku. */ diff --git a/app/Model/Application/Application.php b/app/Model/Application/Application.php index 01e17a98c..812ea854e 100644 --- a/app/Model/Application/Application.php +++ b/app/Model/Application/Application.php @@ -62,7 +62,7 @@ abstract class Application /** * Uživatel. */ - #[ORM\ManyToOne(targetEntity: User::class, cascade: ['persist'], inversedBy: 'applications')] + #[ORM\ManyToOne(targetEntity: User::class, inversedBy: 'applications', cascade: ['persist'])] protected User $user; /** @@ -120,7 +120,7 @@ abstract class Application /** * Spárovaná platba. */ - #[ORM\ManyToOne(targetEntity: Payment::class, cascade: ['persist'], inversedBy: 'pairedApplications')] + #[ORM\ManyToOne(targetEntity: Payment::class, inversedBy: 'pairedApplications', cascade: ['persist'])] protected Payment|null $payment = null; /** @@ -318,9 +318,13 @@ public function getPayment(): Payment|null public function setPayment(Payment|null $payment): void { - $this->payment?->removePairedApplication($this); + if ($this->payment !== null) { + $this->payment->removePairedApplication($this); + } - $payment?->addPairedApplication($this); + if ($payment !== null) { + $payment->addPairedApplication($this); + } $this->payment = $payment; } diff --git a/app/Model/Application/Events/ApplicationUpdatedEvent.php b/app/Model/Application/Events/ApplicationUpdatedEvent.php index 08fc6b6ed..bd1b91704 100644 --- a/app/Model/Application/Events/ApplicationUpdatedEvent.php +++ b/app/Model/Application/Events/ApplicationUpdatedEvent.php @@ -8,7 +8,7 @@ class ApplicationUpdatedEvent { - public function __construct(private readonly User $user) + public function __construct(private User $user) { } diff --git a/app/Model/Application/Events/Subscribers/ApplicationUpdatedEventListener.php b/app/Model/Application/Events/Subscribers/ApplicationUpdatedEventListener.php index f5e65cfa8..b95b57649 100644 --- a/app/Model/Application/Events/Subscribers/ApplicationUpdatedEventListener.php +++ b/app/Model/Application/Events/Subscribers/ApplicationUpdatedEventListener.php @@ -11,7 +11,7 @@ class ApplicationUpdatedEventListener implements MessageHandlerInterface { - public function __construct(private readonly CommandBus $commandBus) + public function __construct(private CommandBus $commandBus) { } diff --git a/app/Model/Cms/Content.php b/app/Model/Cms/Content.php index 4f933d5a6..eb2abe666 100644 --- a/app/Model/Cms/Content.php +++ b/app/Model/Cms/Content.php @@ -38,7 +38,6 @@ 'organizer_content' => OrganizerContent::class, 'contact_form_content' => ContactFormContent::class, 'slideshow_content' => SlideshowContent::class, - 'ticket_content' => TicketContent::class, ])] abstract class Content implements IContent { @@ -122,11 +121,6 @@ abstract class Content implements IContent */ public const SLIDESHOW = 'slideshow'; - /** - * TicketContent. - */ - public const TICKET = 'ticket'; - /** * Hlavní oblast stránky. */ @@ -146,7 +140,6 @@ abstract class Content implements IContent self::NEWS, self::DOCUMENT, self::APPLICATION, - self::TICKET, self::PROGRAMS, self::CONTACT_FORM, self::FAQ, @@ -183,7 +176,7 @@ abstract class Content implements IContent /** * Stránka, na které je obsah umístěn. */ - #[ORM\ManyToOne(targetEntity: Page::class, cascade: ['persist'], inversedBy: 'contents')] + #[ORM\ManyToOne(targetEntity: Page::class, inversedBy: 'contents', cascade: ['persist'])] protected Page $page; /** diff --git a/app/Model/Cms/Dto/PageDto.php b/app/Model/Cms/Dto/PageDto.php index 3306a876a..7c57cdb37 100644 --- a/app/Model/Cms/Dto/PageDto.php +++ b/app/Model/Cms/Dto/PageDto.php @@ -4,8 +4,6 @@ namespace App\Model\Cms\Dto; -use function in_array; - class PageDto { /** @@ -67,8 +65,10 @@ public function hasSidebar(): bool public function isAllowedForRoles(array $userRoles): bool { foreach ($userRoles as $userRole) { - if (in_array($userRole, $this->allowedRoles, true)) { - return true; + foreach ($this->allowedRoles as $allowedRole) { + if ($userRole === $allowedRole) { + return true; + } } } diff --git a/app/Model/Cms/ImageContent.php b/app/Model/Cms/ImageContent.php index befcdb84d..f903d6200 100644 --- a/app/Model/Cms/ImageContent.php +++ b/app/Model/Cms/ImageContent.php @@ -8,7 +8,6 @@ use App\Model\Cms\Dto\ImageContentDto; use App\Services\FilesService; use Doctrine\ORM\Mapping as ORM; -use JsonException; use Nette\Application\UI\Form; use Nette\Forms\Container; use Nette\Http\FileUpload; @@ -139,8 +138,6 @@ public function setHeight(int|null $height): void /** * Přidá do formuláře pro editaci stránky formulář pro úpravu obsahu. - * - * @throws JsonException */ public function addContentForm(Form $form): Form { diff --git a/app/Model/Cms/Page.php b/app/Model/Cms/Page.php index 9fbe2cb5c..eaddd4ab6 100644 --- a/app/Model/Cms/Page.php +++ b/app/Model/Cms/Page.php @@ -65,7 +65,7 @@ class Page * * @var Collection */ - #[ORM\OneToMany(mappedBy: 'page', targetEntity: Content::class, cascade: ['persist'])] + #[ORM\OneToMany(targetEntity: Content::class, mappedBy: 'page', cascade: ['persist'])] #[ORM\OrderBy(['position' => 'ASC'])] protected Collection $contents; diff --git a/app/Model/Cms/Repositories/FaqRepository.php b/app/Model/Cms/Repositories/FaqRepository.php index c3b47682d..a106b2d5f 100644 --- a/app/Model/Cms/Repositories/FaqRepository.php +++ b/app/Model/Cms/Repositories/FaqRepository.php @@ -9,6 +9,7 @@ use Doctrine\ORM\EntityManagerInterface; use Doctrine\ORM\NonUniqueResultException; use Doctrine\ORM\NoResultException; +use Doctrine\ORM\ORMException; use const PHP_INT_MAX; @@ -72,7 +73,7 @@ public function findPublishedOrderedByPosition(): array * Uloží otázku. * * @throws NonUniqueResultException - * @throws NoResultException + * @throws ORMException */ public function save(Faq $faq): void { @@ -95,6 +96,8 @@ public function remove(Faq $faq): void /** * Přesune otázku mezi otázky s id prevId a nextId. + * + * @throws ORMException */ public function sort(int $itemId, int $prevId, int $nextId): void { diff --git a/app/Model/Cms/Repositories/PageRepository.php b/app/Model/Cms/Repositories/PageRepository.php index 743448c31..df85c65a5 100644 --- a/app/Model/Cms/Repositories/PageRepository.php +++ b/app/Model/Cms/Repositories/PageRepository.php @@ -13,6 +13,7 @@ use Doctrine\ORM\NonUniqueResultException; use Doctrine\ORM\NoResultException; use Doctrine\ORM\OptimisticLockException; +use Doctrine\ORM\ORMException; use Throwable; use function array_map; @@ -168,7 +169,7 @@ public function getPagesOptions(): array * Uloží stránku. * * @throws NonUniqueResultException - * @throws NoResultException + * @throws ORMException */ public function save(Page $page): void { @@ -198,6 +199,7 @@ public function remove(Page $page): void /** * Přesune stránku mezi stránky s id prevId a nextId. * + * @throws ORMException * @throws OptimisticLockException */ public function sort(int $itemId, int $prevId, int $nextId): void diff --git a/app/Model/Cms/SlideshowContent.php b/app/Model/Cms/SlideshowContent.php index 74c341f58..6dd5d6556 100644 --- a/app/Model/Cms/SlideshowContent.php +++ b/app/Model/Cms/SlideshowContent.php @@ -8,7 +8,6 @@ use App\Model\Cms\Dto\SlideshowContentDto; use App\Services\FilesService; use Doctrine\ORM\Mapping as ORM; -use JsonException; use Nette\Application\UI\Form; use Nette\Forms\Container; use Nette\Http\FileUpload; @@ -60,8 +59,6 @@ public function setImages(array|null $images): void /** * Přidá do formuláře pro editaci stránky formulář pro úpravu obsahu. - * - * @throws JsonException */ public function addContentForm(Form $form): Form { diff --git a/app/Model/CustomInput/CustomInput.php b/app/Model/CustomInput/CustomInput.php index 8533fcf1d..7caf296e7 100644 --- a/app/Model/CustomInput/CustomInput.php +++ b/app/Model/CustomInput/CustomInput.php @@ -108,7 +108,7 @@ abstract class CustomInput * * @var Collection */ - #[ORM\OneToMany(mappedBy: 'input', targetEntity: CustomInputValue::class, cascade: ['persist'])] + #[ORM\OneToMany(targetEntity: CustomInputValue::class, mappedBy: 'input', cascade: ['persist'])] protected Collection $customInputValues; /** diff --git a/app/Model/CustomInput/CustomInputValue.php b/app/Model/CustomInput/CustomInputValue.php index beaf15b00..1adb1833b 100644 --- a/app/Model/CustomInput/CustomInputValue.php +++ b/app/Model/CustomInput/CustomInputValue.php @@ -33,13 +33,13 @@ abstract class CustomInputValue /** * Vlastní pole přihlášky. */ - #[ORM\ManyToOne(targetEntity: CustomInput::class, cascade: ['persist'], inversedBy: 'customInputValues')] + #[ORM\ManyToOne(targetEntity: CustomInput::class, inversedBy: 'customInputValues', cascade: ['persist'])] protected CustomInput $input; /** * Uživatel. */ - #[ORM\ManyToOne(targetEntity: User::class, cascade: ['persist'], inversedBy: 'customInputValues')] + #[ORM\ManyToOne(targetEntity: User::class, inversedBy: 'customInputValues', cascade: ['persist'])] protected User $user; public function __construct(CustomInput $input, User $user) diff --git a/app/Model/CustomInput/CustomMultiSelectValue.php b/app/Model/CustomInput/CustomMultiSelectValue.php index a65d53336..d7b0a49bd 100644 --- a/app/Model/CustomInput/CustomMultiSelectValue.php +++ b/app/Model/CustomInput/CustomMultiSelectValue.php @@ -22,7 +22,7 @@ class CustomMultiSelectValue extends CustomInputValue * @var string[] */ #[ORM\Column(type: 'simple_array', nullable: true)] - protected array|null $value; + protected array $value = []; /** @return string[] */ public function getValue(): array @@ -33,11 +33,7 @@ public function getValue(): array /** @param string[] $value */ public function setValue(array $value): void { - if (empty($value)) { - $this->value = null; - } else { - $this->value = $value; - } + $this->value = $value; } /** diff --git a/app/Model/CustomInput/Repositories/CustomInputRepository.php b/app/Model/CustomInput/Repositories/CustomInputRepository.php index 171f5b59a..a481b9ea0 100644 --- a/app/Model/CustomInput/Repositories/CustomInputRepository.php +++ b/app/Model/CustomInput/Repositories/CustomInputRepository.php @@ -12,6 +12,7 @@ use Doctrine\ORM\EntityManagerInterface; use Doctrine\ORM\NonUniqueResultException; use Doctrine\ORM\NoResultException; +use Doctrine\ORM\ORMException; use const PHP_INT_MAX; @@ -89,7 +90,7 @@ public function findLastPosition(): int * Uloží pole. * * @throws NonUniqueResultException - * @throws NoResultException + * @throws ORMException */ public function save(CustomInput $input): void { @@ -116,6 +117,8 @@ public function remove(CustomInput $input): void /** * Přesune pole mezi pole s id prevId a nextId. + * + * @throws ORMException */ public function sort(int $itemId, int $prevId, int $nextId): void { diff --git a/app/Model/Group/Commands/Handlers/RemoveGroupHandler.php b/app/Model/Group/Commands/Handlers/RemoveGroupHandler.php new file mode 100644 index 000000000..8b21c64c3 --- /dev/null +++ b/app/Model/Group/Commands/Handlers/RemoveGroupHandler.php @@ -0,0 +1,32 @@ +em->wrapInTransaction(function (EntityManager $em) use ($command): void { + $group = $command->getGroup(); + + $this->groupRepository->remove($group); + }); + } +} diff --git a/app/Model/Group/Commands/Handlers/RemoveStatusHandler.php b/app/Model/Group/Commands/Handlers/RemoveStatusHandler.php new file mode 100644 index 000000000..54fb20f19 --- /dev/null +++ b/app/Model/Group/Commands/Handlers/RemoveStatusHandler.php @@ -0,0 +1,31 @@ +em->wrapInTransaction(function () use ($command): void { + $status = $command->getStatus(); + + + $this->statusRepository->remove($status); + }); + } +} diff --git a/app/Model/Group/Commands/Handlers/SaveGroupHandler.php b/app/Model/Group/Commands/Handlers/SaveGroupHandler.php new file mode 100644 index 000000000..8093374cd --- /dev/null +++ b/app/Model/Group/Commands/Handlers/SaveGroupHandler.php @@ -0,0 +1,21 @@ +groupRepository->save($command->getGroup()); + } +} diff --git a/app/Model/Group/Commands/Handlers/SaveStatusHandler.php b/app/Model/Group/Commands/Handlers/SaveStatusHandler.php new file mode 100644 index 000000000..16a596469 --- /dev/null +++ b/app/Model/Group/Commands/Handlers/SaveStatusHandler.php @@ -0,0 +1,59 @@ +statusRepository->save($command->getStatus()); + } +} + +/* +namespace App\Model\Group\Commands\Handlers; + +use App\Model\Group\Commands\SaveStatus; +use App\Model\Group\Events\StatusUpdatedEvent; +use App\Model\Group\Repositories\StatusRepository; +use App\Services\EventBus; +use Doctrine\ORM\EntityManagerInterface; +use Symfony\Component\Messenger\Handler\MessageHandlerInterface; + +class SaveStatusHandler implements MessageHandlerInterface +{ + public function __construct( + private EventBus $eventBus, + private EntityManagerInterface $em, + private StatusRepository $statusRepository, + ) { + } + + public function __invoke(SaveStatus $command): void + { + $status = $command->getStatus(); +// $statusOld = $command->getStatusOld(); + + if ($status->getId() === null) { + $this->statusRepository->save($status); + } else { + $this->em->wrapInTransaction(function () use ($status, $statusOld): void { + + $this->statusRepository->save($status); + + $this->eventBus->handle(new StatusUpdatedEvent($status, $registerableRolesOld)); + }); + } + } +} +*/ diff --git a/app/Model/Group/Commands/RemoveGroup.php b/app/Model/Group/Commands/RemoveGroup.php new file mode 100644 index 000000000..fdf378e52 --- /dev/null +++ b/app/Model/Group/Commands/RemoveGroup.php @@ -0,0 +1,19 @@ +group; + } +} diff --git a/app/Model/Group/Commands/RemoveStatus.php b/app/Model/Group/Commands/RemoveStatus.php new file mode 100644 index 000000000..ab166f7d2 --- /dev/null +++ b/app/Model/Group/Commands/RemoveStatus.php @@ -0,0 +1,19 @@ +status; + } +} diff --git a/app/Model/Group/Commands/SaveGroup.php b/app/Model/Group/Commands/SaveGroup.php new file mode 100644 index 000000000..cbf0d16f7 --- /dev/null +++ b/app/Model/Group/Commands/SaveGroup.php @@ -0,0 +1,19 @@ +group; + } +} diff --git a/app/Model/Group/Commands/SaveStatus.php b/app/Model/Group/Commands/SaveStatus.php new file mode 100644 index 000000000..066cf3dba --- /dev/null +++ b/app/Model/Group/Commands/SaveStatus.php @@ -0,0 +1,20 @@ +status; + } + +} diff --git a/app/Model/Group/Events/GroupUpdatedEvent.php b/app/Model/Group/Events/GroupUpdatedEvent.php new file mode 100644 index 000000000..c080eb66d --- /dev/null +++ b/app/Model/Group/Events/GroupUpdatedEvent.php @@ -0,0 +1,24 @@ +user; + } + + public function isApprovedOld(): bool + { + return $this->approvedOld; + } +} diff --git a/app/Model/Group/Events/StatusUpdatedEvent.php b/app/Model/Group/Events/StatusUpdatedEvent.php new file mode 100644 index 000000000..30655129f --- /dev/null +++ b/app/Model/Group/Events/StatusUpdatedEvent.php @@ -0,0 +1,28 @@ + $registerableRolesOld */ + public function __construct(private Status $status, private Collection $registerableRolesOld) + { + } + + public function getStatus(): Status + { + return $this->status; + } + + /** @return Collection */ + public function getRegisterableRolesOld(): Collection + { + return $this->registerableRolesOld; + } +} diff --git a/app/Model/Group/Events/Subscribers/GroupUpdatedEventListener.php b/app/Model/Group/Events/Subscribers/GroupUpdatedEventListener.php new file mode 100644 index 000000000..2df0143d5 --- /dev/null +++ b/app/Model/Group/Events/Subscribers/GroupUpdatedEventListener.php @@ -0,0 +1,22 @@ +commandBus->handle(new UpdateGroupPrograms($event->getGroup())); + } +} diff --git a/app/Model/Group/Events/Subscribers/StatusUpdatedEventListener.php b/app/Model/Group/Events/Subscribers/StatusUpdatedEventListener.php new file mode 100644 index 000000000..c18914aa8 --- /dev/null +++ b/app/Model/Group/Events/Subscribers/StatusUpdatedEventListener.php @@ -0,0 +1,75 @@ +em->wrapInTransaction(function () use ($event): void { + $registerableRoles = $event->getStatus()->getRegisterableRoles(); + $registerableRolesOld = $event->getRegisterableRolesOld(); + + if (Helpers::collectionsEquals($registerableRoles, $registerableRolesOld)) { + return; + } + + foreach ($event->getStatus()->getBlocks() as $block) { + $registrationBeforePaymentAllowed = $this->queryBus->handle(new SettingBoolValueQuery(Settings::IS_ALLOWED_REGISTER_PROGRAMS_BEFORE_PAYMENT)); + $allowedUsers = $this->userRepository->findBlockAllowed($block, ! $registrationBeforePaymentAllowed); + + foreach ($block->getGroups() as $program) { + $programAlternates = $this->queryBus->handle(new GroupAlternatesQuery($program)); + foreach ($programAlternates as $user) { + if (! $allowedUsers->contains($user)) { + $this->commandBus->handle(new UnregisterGroup($user, $program)); + } + } + + $programAttendees = $this->queryBus->handle(new GroupAttendeesQuery($program)); + foreach ($programAttendees as $user) { + if (! $allowedUsers->contains($user)) { + $this->commandBus->handle(new UnregisterGroup($user, $program)); + } + } + + if ($block->getMandatory() === GroupMandatoryType::AUTO_REGISTERED) { + foreach ($allowedUsers as $user) { + if (! $programAttendees->contains($user)) { + $this->commandBus->handle(new RegisterGroup($user, $program)); + } + } + } + } + } + }); + } +} diff --git a/app/Model/Group/Group.php b/app/Model/Group/Group.php new file mode 100644 index 000000000..190aad342 --- /dev/null +++ b/app/Model/Group/Group.php @@ -0,0 +1,186 @@ +applications = new ArrayCollection(); + $this->roles = new ArrayCollection(); + $this->programApplications = new ArrayCollection(); + $this->lecturersBlocks = new ArrayCollection(); + $this->notRegisteredMandatoryBlocks = new ArrayCollection(); + $this->customInputValues = new ArrayCollection(); + } + + public function getId(): int|null + { + return $this->id; + } + + public function getName(): string|null + { + return $this->name; + } + + public function setName(string|null $name): void + { + $this->name = $name; + } + + public function getLeaderId(): int|null + { + return $this->leaderId; + } + + public function setLeaderId(int|null $leaderId): void + { + $this->leaderId = $leaderId; + } + + public function getLeaderEmail(): string|null + { + return $this->leaderEmail; + } + + public function setLeaderEmail(string|null $leaderEmail): void + { + $this->leaderEmail = $leaderEmail; + } + + public function getCreateDate(): DateTimeImmutable|null + { + return $this->createDate; + } + + public function setCreateDate(DateTimeImmutable|null $createDate): void + { + $this->createDate = $createDate; + } + + public function getGroupStatusId(): int|null + { + return $this->groupStatusId; + } + + public function setGroupStatusId(int|null $groupStatusId): void + { + $this->groupStatusId = $groupStatusId; + } + + public function getPlaces(): string|null + { + return $this->places; + } + + public function setPlaces(string|null $places): void + { + $this->places = $places; + } + + public function getPrice(): int|null + { + return $this->price; + } + + public function setPrice(int|null $price): void + { + $this->price = $price; + } + + public function getNote(): string|null + { + return $this->note; + } + + public function setNote(string|null $note): void + { + $this->note = $note; + } + + + +} diff --git a/app/Model/Group/Repositories/GroupRepository.php b/app/Model/Group/Repositories/GroupRepository.php new file mode 100644 index 000000000..d442a29bf --- /dev/null +++ b/app/Model/Group/Repositories/GroupRepository.php @@ -0,0 +1,194 @@ + */ + public function findAll(): Collection + { + $result = $this->getRepository()->findAll(); + + return new ArrayCollection($result); + } + + /** + * Vrací uživatele podle id. + */ + public function findById(int|null $id): Group|null + { + return $this->getRepository()->findOneBy(['id' => $id]); + } + + /** + * Vrací uživatele podle id. + * + * @param int[] $ids + * + * @return Collection + */ + public function findUsersByIds(array $ids): Collection + { + $criteria = Criteria::create() + ->where(Criteria::expr()->in('id', $ids)); + + return $this->getRepository()->matching($criteria); + } + + /** + * Vrací uživatele přihlášené na podakce. + * + * @param int[] $subeventsIds + * + * @return Collection + */ + public function findAllWithSubevents(array $subeventsIds): Collection + { + $result = $this->createQueryBuilder('u') + ->join('u.applications', 'a') + ->join('a.subevents', 's') + ->where('a.validTo IS NULL') + ->andWhere('a.state IN (:states)') + ->andWhere('s.id IN (:ids)') + ->setParameter('states', [ApplicationState::PAID, ApplicationState::PAID_FREE, ApplicationState::WAITING_FOR_PAYMENT]) + ->setParameter('ids', $subeventsIds) + ->getQuery() + ->getResult(); + + return new ArrayCollection($result); + } + + /** + * Vrací uživatele s přihláškou čekající na zaplacení. + * + * @return Collection + */ + public function findAllWithWaitingForPaymentApplication(): Collection + { + $result = $this->createQueryBuilder('u') + ->join('u.applications', 'a') + ->where('a.validTo IS NULL') + ->andWhere('a.state = :state') + ->setParameter('state', ApplicationState::WAITING_FOR_PAYMENT) + ->getQuery() + ->getResult(); + + return new ArrayCollection($result); + } + + + /** + * Vrací uživatele jako možnosti pro select. + * + * @return string[] + */ + public function getUsersOptions(): array + { + $users = $this->createQueryBuilder('u') + ->select('u.id, u.displayName') + ->orderBy('u.displayName') + ->getQuery() + ->getResult(); + + $options = []; + foreach ($users as $user) { + $options[$user['id']] = $user['displayName']; + } + + return $options; + } + + + /** + * Uloží uživatele. + */ + public function save(Group $group): void + { + $this->em->persist($group); + $this->em->flush(); + } + + /** + * Odstraní externího uživatele. + */ + public function remove(Group $group): void + { + foreach ($user->getCustomInputValues() as $customInputValue) { + $this->em->remove($customInputValue); + } + + foreach ($user->getApplications() as $application) { + $this->em->remove($application); + } + + $this->em->remove($user); + $this->em->flush(); + } + + public function blockAllowedQuery(Block $block, bool $paidOnly): QueryBuilder + { + $qb = $this->createQueryBuilder('u') + ->join('u.applications', 'sa', 'WITH', 'sa.validTo IS NULL AND sa.state != :stateCanceled AND sa.state != :stateCanceledNotPaid') + ->join('sa.subevents', 's') + ->where('u.approved = true') + ->andWhere('s = :subevent') + ->setParameter('subevent', $block->getSubevent()) + ->setParameter('stateCanceled', ApplicationState::CANCELED) + ->setParameter('stateCanceledNotPaid', ApplicationState::CANCELED_NOT_PAID); + + if ($block->getCategory() !== null) { + $qb = $qb->join('u.roles', 'r') + ->join('r.registerableCategories', 'c') + ->andWhere('c = :category') + ->setParameter('category', $block->getCategory()); + } + + if ($paidOnly) { + $qb = $qb->join('u.applications', 'ra', 'WITH', 'ra.validTo IS NULL AND ra.state != :stateCanceled AND ra.state != :stateCanceledNotPaid AND ra.state != :stateWaitingForPayment') + ->join('ra.roles', 'rar') + ->andWhere('sa.state != :stateWaitingForPayment') + ->setParameter('stateWaitingForPayment', ApplicationState::WAITING_FOR_PAYMENT); + } + + return $qb; + } + + private function programAttendeesQuery(Program $program, bool|null $alternate): QueryBuilder + { + $qb = $this->createQueryBuilder('u') + ->leftJoin('u.programApplications', 'a') + ->where('a.program = :program')->setParameter('program', $program); + + if ($alternate !== null) { + $qb = $qb->andWhere('a.alternate = :alternate') + ->setParameter('alternate', $alternate); + } + + return $qb; + } +} diff --git a/app/Model/Group/Repositories/StatusRepository.php b/app/Model/Group/Repositories/StatusRepository.php new file mode 100644 index 000000000..04ac710dd --- /dev/null +++ b/app/Model/Group/Repositories/StatusRepository.php @@ -0,0 +1,124 @@ + */ + public function findAll(): Collection + { + $result = $this->getRepository()->findAll(); + + return new ArrayCollection($result); + } + + /** + * Vrací status podle id. + */ + public function findById(int|null $id): Status|null + { + return $this->getRepository()->findOneBy(['id' => $id]); + } + + /** + * Vrací statusy seřazené podle názvu. + * + * @return Status[] + */ + public function findAllOrderedByName(): array + { + return $this->createQueryBuilder('c') + ->orderBy('c.name') + ->getQuery() + ->getResult(); + } + + /** + * Vrací názvy všech statusů. + * + * @return string[] + */ + public function findAllNames(): array + { + $names = $this->createQueryBuilder('c') + ->select('c.name') + ->getQuery() + ->getScalarResult(); + + return array_map('current', $names); + } + + /** + * Vrací názvy statusů, kromě statusů s id. + * + * @return string[] + */ + public function findOthersNames(int $id): array + { + $names = $this->createQueryBuilder('c') + ->select('c.name') + ->where('c.id != :id') + ->setParameter('id', $id) + ->getQuery() + ->getScalarResult(); + + return array_map('current', $names); + } + + /** + * Vrací statusy jako možnosti pro select. + * + * @return string[] + */ + public function getCategoriesOptions(): array + { + $categories = $this->createQueryBuilder('c') + ->select('c.id, c.name') + ->orderBy('c.name') + ->getQuery() + ->getResult(); + + $options = []; + foreach ($statuses as $status) { + $options[$status['id']] = $status['name']; + } + + return $options; + } + + /** + * Uloží status. + */ + public function save(Status $status): void + { + $this->em->persist($status); + $this->em->flush(); + } + + /** + * Odstraní status. + */ + public function remove(Status $status): void + { + $this->em->remove($status); + $this->em->flush(); + } +} diff --git a/app/Model/Group/Status.php b/app/Model/Group/Status.php new file mode 100644 index 000000000..3a4d79245 --- /dev/null +++ b/app/Model/Group/Status.php @@ -0,0 +1,49 @@ +id; + } + + public function getName(): string + { + return $this->name; + } + + public function setName(string $name): void + { + $this->name = $name; + } + + +} diff --git a/app/Model/Infrastructure/Repositories/AbstractRepository.php b/app/Model/Infrastructure/Repositories/AbstractRepository.php index ce2504e27..1cce6e51b 100644 --- a/app/Model/Infrastructure/Repositories/AbstractRepository.php +++ b/app/Model/Infrastructure/Repositories/AbstractRepository.php @@ -16,7 +16,7 @@ class AbstractRepository { /** @param class-string $className */ - public function __construct(protected EntityManagerInterface $em, private readonly string $className) + public function __construct(protected EntityManagerInterface $em, private string $className) { } diff --git a/app/Model/Mailing/Mail.php b/app/Model/Mailing/Mail.php index dc452fdc5..f7cf2621a 100644 --- a/app/Model/Mailing/Mail.php +++ b/app/Model/Mailing/Mail.php @@ -27,15 +27,7 @@ class Mail private int|null $id = null; /** - * Příjemci e-mailu - uživatelé. - * - * @var Collection - */ - #[ORM\ManyToMany(targetEntity: User::class)] - protected Collection $recipientUsers; - - /** - * Příjemci e-mailu - uživatelé s rolemi. + * Role, kterým byl e-mail odeslán. * * @var Collection */ @@ -43,7 +35,7 @@ class Mail protected Collection $recipientRoles; /** - * Příjemci e-mailu - uživatelé s podakcemi. + * Podakce, jejichž účastníkům byl e-mail odeslán. * * @var Collection */ @@ -51,12 +43,12 @@ class Mail protected Collection $recipientSubevents; /** - * Příjemci e-mailu - e-maily. + * Uživatelé, kterém byl e-mail odeslán. * - * @var string[] + * @var Collection */ - #[ORM\Column(type: 'simple_array', nullable: true)] - protected array|null $recipientEmails; + #[ORM\ManyToMany(targetEntity: User::class)] + protected Collection $recipientUsers; /** * Předmět e-mailu. @@ -71,7 +63,7 @@ class Mail protected string $text; /** - * Datum a čas vytvoření. + * Datum a čas odeslání. */ #[ORM\Column(type: 'datetime_immutable')] protected DateTimeImmutable $datetime; @@ -84,9 +76,9 @@ class Mail public function __construct() { - $this->recipientUsers = new ArrayCollection(); $this->recipientRoles = new ArrayCollection(); $this->recipientSubevents = new ArrayCollection(); + $this->recipientUsers = new ArrayCollection(); } public function getId(): int|null @@ -94,29 +86,6 @@ public function getId(): int|null return $this->id; } - /** @return Collection */ - public function getRecipientUsers(): Collection - { - return $this->recipientUsers; - } - - /** @param Collection $recipientUsers */ - public function setRecipientUsers(Collection $recipientUsers): void - { - $this->recipientUsers->clear(); - foreach ($recipientUsers as $recipientUser) { - $this->recipientUsers->add($recipientUser); - } - } - - /** - * Vrací příjemce (uživatele) oddělené čárkou. - */ - public function getRecipientUsersText(): string - { - return implode(', ', $this->recipientUsers->map(static fn (User $user) => $user->getDisplayName())->toArray()); - } - /** @return Collection */ public function getRecipientRoles(): Collection { @@ -163,21 +132,27 @@ public function getRecipientSubeventsText(): string return implode(', ', $this->recipientSubevents->map(static fn (Subevent $subevent) => $subevent->getName())->toArray()); } - /** @return string[] */ - public function getRecipientEmails(): array + /** @return Collection */ + public function getRecipientUsers(): Collection { - return $this->recipientEmails; + return $this->recipientUsers; } - /** @param string[] $recipientEmails */ - public function setRecipientEmails(array|null $recipientEmails): void + /** @param Collection $recipientUsers */ + public function setRecipientUsers(Collection $recipientUsers): void { - $this->recipientEmails = $recipientEmails; + $this->recipientUsers->clear(); + foreach ($recipientUsers as $recipientUser) { + $this->recipientUsers->add($recipientUser); + } } - public function getRecipientEmailsText(): string + /** + * Vrací příjemce (uživatele) oddělené čárkou. + */ + public function getRecipientUsersText(): string { - return implode(', ', $this->recipientEmails); + return implode(', ', $this->recipientUsers->map(static fn (User $user) => $user->getDisplayName())->toArray()); } public function getSubject(): string diff --git a/app/Model/Mailing/Recipient.php b/app/Model/Mailing/Recipient.php index 64196ea56..4e05aeece 100644 --- a/app/Model/Mailing/Recipient.php +++ b/app/Model/Mailing/Recipient.php @@ -16,8 +16,8 @@ class Recipient * @param ?string $name Jméno příjemce. */ public function __construct( - private readonly string $email, - private readonly string|null $name = null, + private string $email, + private string|null $name = null, ) { } @@ -31,15 +31,10 @@ public function getName(): string|null return $this->name; } - public function isValid(): bool - { - return ! empty($this->email); - } - /** * Vytvoří objekt na základě údajů uživatele. */ - public static function createFromUser(User $user): Recipient|null + public static function createFromUser(User $user): Recipient { return new Recipient($user->getEmail(), $user->getDisplayName()); } diff --git a/app/Model/Mailing/Template.php b/app/Model/Mailing/Template.php index 12029e3b4..4f2fbaca8 100644 --- a/app/Model/Mailing/Template.php +++ b/app/Model/Mailing/Template.php @@ -188,9 +188,4 @@ public function isSystemTemplate(): bool { return $this->systemTemplate; } - - public function setSystemTemplate(bool $systemTemplate): void - { - $this->systemTemplate = $systemTemplate; - } } diff --git a/app/Model/Mailing/TemplateVariable.php b/app/Model/Mailing/TemplateVariable.php index 59bccf3f1..e2731adf7 100644 --- a/app/Model/Mailing/TemplateVariable.php +++ b/app/Model/Mailing/TemplateVariable.php @@ -63,6 +63,11 @@ class TemplateVariable */ public const BANK_ACCOUNT = 'bank_account'; + /** + * Odkaz pro potvrzení změny e-mailu. + */ + public const EMAIL_VERIFICATION_LINK = 'email_verification_link'; + /** * Jméno uživatele. */ diff --git a/app/Model/Payment/Payment.php b/app/Model/Payment/Payment.php index 727d3c696..009c5137b 100644 --- a/app/Model/Payment/Payment.php +++ b/app/Model/Payment/Payment.php @@ -74,7 +74,7 @@ class Payment * * @var Collection */ - #[ORM\OneToMany(mappedBy: 'payment', targetEntity: Application::class, cascade: ['persist'])] + #[ORM\OneToMany(targetEntity: Application::class, mappedBy: 'payment', cascade: ['persist'])] protected Collection $pairedApplications; /** diff --git a/app/Model/Program/Block.php b/app/Model/Program/Block.php index 6083e308d..17dc94fb1 100644 --- a/app/Model/Program/Block.php +++ b/app/Model/Program/Block.php @@ -35,7 +35,7 @@ class Block * * @var Collection */ - #[ORM\OneToMany(mappedBy: 'block', targetEntity: Program::class, cascade: ['persist'])] + #[ORM\OneToMany(targetEntity: Program::class, mappedBy: 'block', cascade: ['persist'])] #[ORM\OrderBy(['start' => 'ASC'])] protected Collection $programs; @@ -50,13 +50,13 @@ class Block /** * Kategorie bloku. */ - #[ORM\ManyToOne(targetEntity: Category::class, cascade: ['persist'], inversedBy: 'blocks')] + #[ORM\ManyToOne(targetEntity: Category::class, inversedBy: 'blocks', cascade: ['persist'])] protected Category|null $category = null; /** * Podakce bloku. */ - #[ORM\ManyToOne(targetEntity: Subevent::class, cascade: ['persist'], inversedBy: 'blocks')] + #[ORM\ManyToOne(targetEntity: Subevent::class, inversedBy: 'blocks', cascade: ['persist'])] protected Subevent $subevent; /** @@ -200,9 +200,13 @@ public function getCategory(): Category|null public function setCategory(Category|null $category): void { - $this->category?->removeBlock($this); + if ($this->category !== null) { + $this->category->removeBlock($this); + } - $category?->addBlock($this); + if ($category !== null) { + $category->addBlock($this); + } $this->category = $category; } diff --git a/app/Model/Program/Category.php b/app/Model/Program/Category.php index 897d4aad7..90f6c7421 100644 --- a/app/Model/Program/Category.php +++ b/app/Model/Program/Category.php @@ -42,7 +42,7 @@ class Category * * @var Collection */ - #[ORM\OneToMany(mappedBy: 'category', targetEntity: Block::class, cascade: ['persist'])] + #[ORM\OneToMany(targetEntity: Block::class, mappedBy: 'category', cascade: ['persist'])] #[ORM\OrderBy(['name' => 'ASC'])] protected Collection $blocks; diff --git a/app/Model/Program/Commands/Handlers/RemoveBlockHandler.php b/app/Model/Program/Commands/Handlers/RemoveBlockHandler.php index 15c90401e..94865dbe2 100644 --- a/app/Model/Program/Commands/Handlers/RemoveBlockHandler.php +++ b/app/Model/Program/Commands/Handlers/RemoveBlockHandler.php @@ -14,9 +14,9 @@ class RemoveBlockHandler implements MessageHandlerInterface { public function __construct( - private readonly CommandBus $commandBus, - private readonly EntityManagerInterface $em, - private readonly BlockRepository $blockRepository, + private CommandBus $commandBus, + private EntityManagerInterface $em, + private BlockRepository $blockRepository, ) { } diff --git a/app/Model/Program/Commands/Handlers/RemoveCategoryHandler.php b/app/Model/Program/Commands/Handlers/RemoveCategoryHandler.php index c498c1832..7f6db547c 100644 --- a/app/Model/Program/Commands/Handlers/RemoveCategoryHandler.php +++ b/app/Model/Program/Commands/Handlers/RemoveCategoryHandler.php @@ -14,9 +14,9 @@ class RemoveCategoryHandler implements MessageHandlerInterface { public function __construct( - private readonly CommandBus $commandBus, - private readonly EntityManagerInterface $em, - private readonly CategoryRepository $categoryRepository, + private CommandBus $commandBus, + private EntityManagerInterface $em, + private CategoryRepository $categoryRepository, ) { } diff --git a/app/Model/Program/Commands/Handlers/RemoveProgramHandler.php b/app/Model/Program/Commands/Handlers/RemoveProgramHandler.php index 2b29f45e8..758ba4d6b 100644 --- a/app/Model/Program/Commands/Handlers/RemoveProgramHandler.php +++ b/app/Model/Program/Commands/Handlers/RemoveProgramHandler.php @@ -17,10 +17,10 @@ class RemoveProgramHandler implements MessageHandlerInterface { public function __construct( - private readonly CommandBus $commandBus, - private readonly QueryBus $queryBus, - private readonly EntityManagerInterface $em, - private readonly ProgramRepository $programRepository, + private CommandBus $commandBus, + private QueryBus $queryBus, + private EntityManagerInterface $em, + private ProgramRepository $programRepository, ) { } diff --git a/app/Model/Program/Commands/Handlers/RemoveRoomHandler.php b/app/Model/Program/Commands/Handlers/RemoveRoomHandler.php index eeacea9ff..02ff5c847 100644 --- a/app/Model/Program/Commands/Handlers/RemoveRoomHandler.php +++ b/app/Model/Program/Commands/Handlers/RemoveRoomHandler.php @@ -15,9 +15,9 @@ class RemoveRoomHandler implements MessageHandlerInterface { public function __construct( - private readonly CommandBus $commandBus, - private readonly EntityManagerInterface $em, - private readonly RoomRepository $roomRepository, + private CommandBus $commandBus, + private EntityManagerInterface $em, + private RoomRepository $roomRepository, ) { } diff --git a/app/Model/Program/Commands/Handlers/SaveBlockHandler.php b/app/Model/Program/Commands/Handlers/SaveBlockHandler.php index f24e0380b..c21d4142a 100644 --- a/app/Model/Program/Commands/Handlers/SaveBlockHandler.php +++ b/app/Model/Program/Commands/Handlers/SaveBlockHandler.php @@ -14,9 +14,9 @@ class SaveBlockHandler implements MessageHandlerInterface { public function __construct( - private readonly EventBus $eventBus, - private readonly EntityManagerInterface $em, - private readonly BlockRepository $blockRepository, + private EventBus $eventBus, + private EntityManagerInterface $em, + private BlockRepository $blockRepository, ) { } diff --git a/app/Model/Program/Commands/Handlers/SaveCategoryHandler.php b/app/Model/Program/Commands/Handlers/SaveCategoryHandler.php index 9c6041046..1451294c7 100644 --- a/app/Model/Program/Commands/Handlers/SaveCategoryHandler.php +++ b/app/Model/Program/Commands/Handlers/SaveCategoryHandler.php @@ -14,9 +14,9 @@ class SaveCategoryHandler implements MessageHandlerInterface { public function __construct( - private readonly EventBus $eventBus, - private readonly EntityManagerInterface $em, - private readonly CategoryRepository $categoryRepository, + private EventBus $eventBus, + private EntityManagerInterface $em, + private CategoryRepository $categoryRepository, ) { } diff --git a/app/Model/Program/Commands/Handlers/SaveProgramHandler.php b/app/Model/Program/Commands/Handlers/SaveProgramHandler.php index aea98f6d9..ecab7a3aa 100644 --- a/app/Model/Program/Commands/Handlers/SaveProgramHandler.php +++ b/app/Model/Program/Commands/Handlers/SaveProgramHandler.php @@ -14,9 +14,9 @@ class SaveProgramHandler implements MessageHandlerInterface { public function __construct( - private readonly EventBus $eventBus, - private readonly EntityManagerInterface $em, - private readonly ProgramRepository $programRepository, + private EventBus $eventBus, + private EntityManagerInterface $em, + private ProgramRepository $programRepository, ) { } diff --git a/app/Model/Program/Commands/Handlers/SaveRoomHandler.php b/app/Model/Program/Commands/Handlers/SaveRoomHandler.php index b18fdfc0c..c523c5f06 100644 --- a/app/Model/Program/Commands/Handlers/SaveRoomHandler.php +++ b/app/Model/Program/Commands/Handlers/SaveRoomHandler.php @@ -10,7 +10,7 @@ class SaveRoomHandler implements MessageHandlerInterface { - public function __construct(private readonly RoomRepository $roomRepository) + public function __construct(private RoomRepository $roomRepository) { } diff --git a/app/Model/Program/Commands/RemoveBlock.php b/app/Model/Program/Commands/RemoveBlock.php index 2608b97a8..e487ee133 100644 --- a/app/Model/Program/Commands/RemoveBlock.php +++ b/app/Model/Program/Commands/RemoveBlock.php @@ -8,7 +8,7 @@ class RemoveBlock { - public function __construct(private readonly Block $block) + public function __construct(private Block $block) { } diff --git a/app/Model/Program/Commands/RemoveCategory.php b/app/Model/Program/Commands/RemoveCategory.php index aba7e7aee..31dec9b26 100644 --- a/app/Model/Program/Commands/RemoveCategory.php +++ b/app/Model/Program/Commands/RemoveCategory.php @@ -8,7 +8,7 @@ class RemoveCategory { - public function __construct(private readonly Category $category) + public function __construct(private Category $category) { } diff --git a/app/Model/Program/Commands/RemoveProgram.php b/app/Model/Program/Commands/RemoveProgram.php index df6c0c951..dd670f1ed 100644 --- a/app/Model/Program/Commands/RemoveProgram.php +++ b/app/Model/Program/Commands/RemoveProgram.php @@ -8,7 +8,7 @@ class RemoveProgram { - public function __construct(private readonly Program $program) + public function __construct(private Program $program) { } diff --git a/app/Model/Program/Commands/RemoveRoom.php b/app/Model/Program/Commands/RemoveRoom.php index 8fadc63c8..94b887830 100644 --- a/app/Model/Program/Commands/RemoveRoom.php +++ b/app/Model/Program/Commands/RemoveRoom.php @@ -8,7 +8,7 @@ class RemoveRoom { - public function __construct(private readonly Room $room) + public function __construct(private Room $room) { } diff --git a/app/Model/Program/Commands/SaveBlock.php b/app/Model/Program/Commands/SaveBlock.php index 4054bc936..e8ab69f45 100644 --- a/app/Model/Program/Commands/SaveBlock.php +++ b/app/Model/Program/Commands/SaveBlock.php @@ -8,7 +8,7 @@ class SaveBlock { - public function __construct(private readonly Block $block, private readonly Block|null $blockOld = null) + public function __construct(private Block $block, private Block|null $blockOld = null) { } diff --git a/app/Model/Program/Commands/SaveCategory.php b/app/Model/Program/Commands/SaveCategory.php index 15ec61ed8..c9069ed51 100644 --- a/app/Model/Program/Commands/SaveCategory.php +++ b/app/Model/Program/Commands/SaveCategory.php @@ -8,7 +8,7 @@ class SaveCategory { - public function __construct(private readonly Category $category, private readonly Category|null $categoryOld) + public function __construct(private Category $category, private Category|null $categoryOld) { } diff --git a/app/Model/Program/Commands/SaveProgram.php b/app/Model/Program/Commands/SaveProgram.php index f39c9ec12..08e638d9d 100644 --- a/app/Model/Program/Commands/SaveProgram.php +++ b/app/Model/Program/Commands/SaveProgram.php @@ -8,7 +8,7 @@ class SaveProgram { - public function __construct(private readonly Program $program) + public function __construct(private Program $program) { } diff --git a/app/Model/Program/Commands/SaveRoom.php b/app/Model/Program/Commands/SaveRoom.php index 15a1737c8..67cdb023a 100644 --- a/app/Model/Program/Commands/SaveRoom.php +++ b/app/Model/Program/Commands/SaveRoom.php @@ -8,7 +8,7 @@ class SaveRoom { - public function __construct(private readonly Room $room) + public function __construct(private Room $room) { } diff --git a/app/Model/Program/Events/BlockUpdatedEvent.php b/app/Model/Program/Events/BlockUpdatedEvent.php index 719f75b32..44078bdab 100644 --- a/app/Model/Program/Events/BlockUpdatedEvent.php +++ b/app/Model/Program/Events/BlockUpdatedEvent.php @@ -11,12 +11,12 @@ class BlockUpdatedEvent { public function __construct( - private readonly Block $block, - private readonly Category|null $categoryOld, - private readonly Subevent $subeventOld, - private readonly string $mandatoryOld, - private readonly int|null $capacityOld, - private readonly bool $alternatesAllowedOld, + private Block $block, + private Category|null $categoryOld, + private Subevent $subeventOld, + private string $mandatoryOld, + private int|null $capacityOld, + private bool $alternatesAllowedOld, ) { } diff --git a/app/Model/Program/Events/CategoryUpdatedEvent.php b/app/Model/Program/Events/CategoryUpdatedEvent.php index b3a422d7b..a19fc724f 100644 --- a/app/Model/Program/Events/CategoryUpdatedEvent.php +++ b/app/Model/Program/Events/CategoryUpdatedEvent.php @@ -11,7 +11,7 @@ class CategoryUpdatedEvent { /** @param Collection $registerableRolesOld */ - public function __construct(private readonly Category $category, private readonly Collection $registerableRolesOld) + public function __construct(private Category $category, private Collection $registerableRolesOld) { } diff --git a/app/Model/Program/Events/ProgramCreatedEvent.php b/app/Model/Program/Events/ProgramCreatedEvent.php index db12d7399..56d3442a1 100644 --- a/app/Model/Program/Events/ProgramCreatedEvent.php +++ b/app/Model/Program/Events/ProgramCreatedEvent.php @@ -8,7 +8,7 @@ class ProgramCreatedEvent { - public function __construct(private readonly Program $program) + public function __construct(private Program $program) { } diff --git a/app/Model/Program/Events/Subscribers/BlockUpdatedEventListener.php b/app/Model/Program/Events/Subscribers/BlockUpdatedEventListener.php index 2ae9be582..5a932377d 100644 --- a/app/Model/Program/Events/Subscribers/BlockUpdatedEventListener.php +++ b/app/Model/Program/Events/Subscribers/BlockUpdatedEventListener.php @@ -26,10 +26,10 @@ class BlockUpdatedEventListener implements MessageHandlerInterface { public function __construct( - private readonly CommandBus $commandBus, - private readonly QueryBus $queryBus, - private readonly EntityManagerInterface $em, - private readonly UserRepository $userRepository, + private CommandBus $commandBus, + private QueryBus $queryBus, + private EntityManagerInterface $em, + private UserRepository $userRepository, ) { } diff --git a/app/Model/Program/Events/Subscribers/CategoryUpdatedEventListener.php b/app/Model/Program/Events/Subscribers/CategoryUpdatedEventListener.php index 7af86bd97..825428e91 100644 --- a/app/Model/Program/Events/Subscribers/CategoryUpdatedEventListener.php +++ b/app/Model/Program/Events/Subscribers/CategoryUpdatedEventListener.php @@ -22,10 +22,10 @@ class CategoryUpdatedEventListener implements MessageHandlerInterface { public function __construct( - private readonly CommandBus $commandBus, - private readonly QueryBus $queryBus, - private readonly EntityManagerInterface $em, - private readonly UserRepository $userRepository, + private CommandBus $commandBus, + private QueryBus $queryBus, + private EntityManagerInterface $em, + private UserRepository $userRepository, ) { } diff --git a/app/Model/Program/Events/Subscribers/ProgramCreatedEventListener.php b/app/Model/Program/Events/Subscribers/ProgramCreatedEventListener.php index c6e751785..5a65d70a1 100644 --- a/app/Model/Program/Events/Subscribers/ProgramCreatedEventListener.php +++ b/app/Model/Program/Events/Subscribers/ProgramCreatedEventListener.php @@ -18,10 +18,10 @@ class ProgramCreatedEventListener implements MessageHandlerInterface { public function __construct( - private readonly CommandBus $commandBus, - private readonly QueryBus $queryBus, - private readonly EntityManagerInterface $em, - private readonly UserRepository $userRepository, + private CommandBus $commandBus, + private QueryBus $queryBus, + private EntityManagerInterface $em, + private UserRepository $userRepository, ) { } diff --git a/app/Model/Program/Program.php b/app/Model/Program/Program.php index 73d5703d6..91d79307b 100644 --- a/app/Model/Program/Program.php +++ b/app/Model/Program/Program.php @@ -27,7 +27,7 @@ class Program /** * Programový blok. */ - #[ORM\ManyToOne(targetEntity: Block::class, cascade: ['persist'], inversedBy: 'programs')] + #[ORM\ManyToOne(targetEntity: Block::class, inversedBy: 'programs', cascade: ['persist'])] protected Block $block; /** @@ -35,7 +35,7 @@ class Program * * @var Collection */ - #[ORM\OneToMany(mappedBy: 'program', targetEntity: ProgramApplication::class, cascade: ['persist'])] + #[ORM\OneToMany(targetEntity: ProgramApplication::class, mappedBy: 'program', cascade: ['persist'])] protected Collection $programApplications; /** @@ -47,7 +47,7 @@ class Program /** * Místnost. */ - #[ORM\ManyToOne(targetEntity: Room::class, cascade: ['persist'], inversedBy: 'programs')] + #[ORM\ManyToOne(targetEntity: Room::class, inversedBy: 'programs', cascade: ['persist'])] protected Room|null $room = null; /** @@ -104,9 +104,13 @@ public function getRoom(): Room|null public function setRoom(Room|null $room): void { - $this->room?->removeProgram($this); + if ($this->room !== null) { + $this->room->removeProgram($this); + } - $room?->addProgram($this); + if ($room !== null) { + $room->addProgram($this); + } $this->room = $room; } diff --git a/app/Model/Program/ProgramApplication.php b/app/Model/Program/ProgramApplication.php index dad23d080..01681a013 100644 --- a/app/Model/Program/ProgramApplication.php +++ b/app/Model/Program/ProgramApplication.php @@ -23,13 +23,13 @@ class ProgramApplication /** * Uživatel. */ - #[ORM\ManyToOne(targetEntity: User::class, cascade: ['persist'], inversedBy: 'programApplications')] + #[ORM\ManyToOne(targetEntity: User::class, inversedBy: 'programApplications', cascade: ['persist'])] protected User $user; /** * Zapsaný program. */ - #[ORM\ManyToOne(targetEntity: Program::class, cascade: ['persist'], inversedBy: 'programApplications')] + #[ORM\ManyToOne(targetEntity: Program::class, inversedBy: 'programApplications', cascade: ['persist'])] protected Program $program; /** diff --git a/app/Model/Program/Queries/BlockAttendeesQuery.php b/app/Model/Program/Queries/BlockAttendeesQuery.php index 8db6ff677..ea6aa3f28 100644 --- a/app/Model/Program/Queries/BlockAttendeesQuery.php +++ b/app/Model/Program/Queries/BlockAttendeesQuery.php @@ -8,7 +8,7 @@ class BlockAttendeesQuery { - public function __construct(private readonly Block $block) + public function __construct(private Block $block) { } diff --git a/app/Model/Program/Queries/Handlers/BlockAttendeesQueryHandler.php b/app/Model/Program/Queries/Handlers/BlockAttendeesQueryHandler.php index 4072ecd9b..a4427282d 100644 --- a/app/Model/Program/Queries/Handlers/BlockAttendeesQueryHandler.php +++ b/app/Model/Program/Queries/Handlers/BlockAttendeesQueryHandler.php @@ -12,7 +12,7 @@ class BlockAttendeesQueryHandler implements MessageHandlerInterface { - public function __construct(private readonly UserRepository $userRepository) + public function __construct(private UserRepository $userRepository) { } diff --git a/app/Model/Program/Queries/Handlers/MinBlockAllowedCapacityQueryHandler.php b/app/Model/Program/Queries/Handlers/MinBlockAllowedCapacityQueryHandler.php index 9fa066661..48f480b54 100644 --- a/app/Model/Program/Queries/Handlers/MinBlockAllowedCapacityQueryHandler.php +++ b/app/Model/Program/Queries/Handlers/MinBlockAllowedCapacityQueryHandler.php @@ -10,7 +10,7 @@ class MinBlockAllowedCapacityQueryHandler implements MessageHandlerInterface { - public function __construct(private readonly BlockRepository $blockRepository) + public function __construct(private BlockRepository $blockRepository) { } diff --git a/app/Model/Program/Queries/Handlers/ProgramAlternatesQueryHandler.php b/app/Model/Program/Queries/Handlers/ProgramAlternatesQueryHandler.php index 8256fdea0..de78a38cd 100644 --- a/app/Model/Program/Queries/Handlers/ProgramAlternatesQueryHandler.php +++ b/app/Model/Program/Queries/Handlers/ProgramAlternatesQueryHandler.php @@ -12,7 +12,7 @@ class ProgramAlternatesQueryHandler implements MessageHandlerInterface { - public function __construct(private readonly UserRepository $userRepository) + public function __construct(private UserRepository $userRepository) { } diff --git a/app/Model/Program/Queries/Handlers/ProgramAttendeesQueryHandler.php b/app/Model/Program/Queries/Handlers/ProgramAttendeesQueryHandler.php index 7096e9980..17c42d79c 100644 --- a/app/Model/Program/Queries/Handlers/ProgramAttendeesQueryHandler.php +++ b/app/Model/Program/Queries/Handlers/ProgramAttendeesQueryHandler.php @@ -12,7 +12,7 @@ class ProgramAttendeesQueryHandler implements MessageHandlerInterface { - public function __construct(private readonly UserRepository $userRepository) + public function __construct(private UserRepository $userRepository) { } diff --git a/app/Model/Program/Queries/MinBlockAllowedCapacityQuery.php b/app/Model/Program/Queries/MinBlockAllowedCapacityQuery.php index ebc7e5f82..02737b5fd 100644 --- a/app/Model/Program/Queries/MinBlockAllowedCapacityQuery.php +++ b/app/Model/Program/Queries/MinBlockAllowedCapacityQuery.php @@ -8,7 +8,7 @@ class MinBlockAllowedCapacityQuery { - public function __construct(private readonly Block $block) + public function __construct(private Block $block) { } diff --git a/app/Model/Program/Queries/ProgramAlternatesQuery.php b/app/Model/Program/Queries/ProgramAlternatesQuery.php index fece6b40a..1397ec66b 100644 --- a/app/Model/Program/Queries/ProgramAlternatesQuery.php +++ b/app/Model/Program/Queries/ProgramAlternatesQuery.php @@ -8,7 +8,7 @@ class ProgramAlternatesQuery { - public function __construct(private readonly Program $program) + public function __construct(private Program $program) { } diff --git a/app/Model/Program/Queries/ProgramAttendeesQuery.php b/app/Model/Program/Queries/ProgramAttendeesQuery.php index 98dd0e358..446697be3 100644 --- a/app/Model/Program/Queries/ProgramAttendeesQuery.php +++ b/app/Model/Program/Queries/ProgramAttendeesQuery.php @@ -8,7 +8,7 @@ class ProgramAttendeesQuery { - public function __construct(private readonly Program $program) + public function __construct(private Program $program) { } diff --git a/app/Model/Program/Repositories/ProgramApplicationRepository.php b/app/Model/Program/Repositories/ProgramApplicationRepository.php index 52bba7613..b0cec8244 100644 --- a/app/Model/Program/Repositories/ProgramApplicationRepository.php +++ b/app/Model/Program/Repositories/ProgramApplicationRepository.php @@ -18,9 +18,6 @@ use Doctrine\DBAL\LockMode; use Doctrine\ORM\EntityManager; use Doctrine\ORM\EntityManagerInterface; -use Doctrine\ORM\NonUniqueResultException; -use Doctrine\ORM\NoResultException; -use Exception; use Throwable; use function assert; @@ -115,10 +112,6 @@ private function findByUserAlternateAndBlock(User $user, Block $block): Collecti return new ArrayCollection($result); } - /** - * @throws NonUniqueResultException - * @throws NoResultException - */ private function userAttendsSameProgram(User $user, Program $program): bool { $result = $this->createQueryBuilder('pa') @@ -134,10 +127,6 @@ private function userAttendsSameProgram(User $user, Program $program): bool return $result !== 0; } - /** - * @throws NonUniqueResultException - * @throws NoResultException - */ private function userAttendsSameBlockProgram(User $user, Block $block): bool { $result = $this->createQueryBuilder('pa') @@ -153,11 +142,6 @@ private function userAttendsSameBlockProgram(User $user, Block $block): bool return $result !== 0; } - /** - * @throws NonUniqueResultException - * @throws NoResultException - * @throws Exception - */ private function userAttendsOrAlternatesConflictingProgram(User $user, Program $program): bool { $start = $program->getStart(); diff --git a/app/Model/Program/Room.php b/app/Model/Program/Room.php index b10075721..5bb2a326f 100644 --- a/app/Model/Program/Room.php +++ b/app/Model/Program/Room.php @@ -37,7 +37,7 @@ class Room * * @var Collection */ - #[ORM\OneToMany(mappedBy: 'room', targetEntity: Program::class, cascade: ['persist'])] + #[ORM\OneToMany(targetEntity: Program::class, mappedBy: 'room', cascade: ['persist'])] #[ORM\OrderBy(['start' => 'ASC'])] protected Collection $programs; diff --git a/app/Model/Settings/Commands/Handlers/SetSettingArrayValueHandler.php b/app/Model/Settings/Commands/Handlers/SetSettingArrayValueHandler.php index 52f478d83..f6339bfec 100644 --- a/app/Model/Settings/Commands/Handlers/SetSettingArrayValueHandler.php +++ b/app/Model/Settings/Commands/Handlers/SetSettingArrayValueHandler.php @@ -13,7 +13,7 @@ class SetSettingArrayValueHandler implements MessageHandlerInterface { - public function __construct(private readonly SettingsRepository $settingsRepository) + public function __construct(private SettingsRepository $settingsRepository) { } diff --git a/app/Model/Settings/Commands/Handlers/SetSettingBoolValueHandler.php b/app/Model/Settings/Commands/Handlers/SetSettingBoolValueHandler.php index bc82cd7c3..7df1580d6 100644 --- a/app/Model/Settings/Commands/Handlers/SetSettingBoolValueHandler.php +++ b/app/Model/Settings/Commands/Handlers/SetSettingBoolValueHandler.php @@ -11,7 +11,7 @@ class SetSettingBoolValueHandler implements MessageHandlerInterface { - public function __construct(private readonly SettingsRepository $settingsRepository) + public function __construct(private SettingsRepository $settingsRepository) { } diff --git a/app/Model/Settings/Commands/Handlers/SetSettingDateTimeValueHandler.php b/app/Model/Settings/Commands/Handlers/SetSettingDateTimeValueHandler.php index 912eabb79..fe3c07e8f 100644 --- a/app/Model/Settings/Commands/Handlers/SetSettingDateTimeValueHandler.php +++ b/app/Model/Settings/Commands/Handlers/SetSettingDateTimeValueHandler.php @@ -12,7 +12,7 @@ class SetSettingDateTimeValueHandler implements MessageHandlerInterface { - public function __construct(private readonly SettingsRepository $settingsRepository) + public function __construct(private SettingsRepository $settingsRepository) { } @@ -24,7 +24,7 @@ public function __invoke(SetSettingDateTimeValue $command): void if ($value === null) { $setting->setValue(null); } else { - $setting->setValue($value->format(DateTimeImmutable::ATOM)); + $setting->setValue($value->format(DateTimeImmutable::ISO8601)); } $this->settingsRepository->save($setting); diff --git a/app/Model/Settings/Commands/Handlers/SetSettingDateValueHandler.php b/app/Model/Settings/Commands/Handlers/SetSettingDateValueHandler.php index 32248f470..cc49165e4 100644 --- a/app/Model/Settings/Commands/Handlers/SetSettingDateValueHandler.php +++ b/app/Model/Settings/Commands/Handlers/SetSettingDateValueHandler.php @@ -11,7 +11,7 @@ class SetSettingDateValueHandler implements MessageHandlerInterface { - public function __construct(private readonly SettingsRepository $settingsRepository) + public function __construct(private SettingsRepository $settingsRepository) { } diff --git a/app/Model/Settings/Commands/Handlers/SetSettingIntValueHandler.php b/app/Model/Settings/Commands/Handlers/SetSettingIntValueHandler.php index 56e92a4b3..b0cdde886 100644 --- a/app/Model/Settings/Commands/Handlers/SetSettingIntValueHandler.php +++ b/app/Model/Settings/Commands/Handlers/SetSettingIntValueHandler.php @@ -11,7 +11,7 @@ class SetSettingIntValueHandler implements MessageHandlerInterface { - public function __construct(private readonly SettingsRepository $settingsRepository) + public function __construct(private SettingsRepository $settingsRepository) { } diff --git a/app/Model/Settings/Commands/Handlers/SetSettingStringValueHandler.php b/app/Model/Settings/Commands/Handlers/SetSettingStringValueHandler.php index 05e5d29fa..bc1feed68 100644 --- a/app/Model/Settings/Commands/Handlers/SetSettingStringValueHandler.php +++ b/app/Model/Settings/Commands/Handlers/SetSettingStringValueHandler.php @@ -11,7 +11,7 @@ class SetSettingStringValueHandler implements MessageHandlerInterface { - public function __construct(private readonly SettingsRepository $settingsRepository) + public function __construct(private SettingsRepository $settingsRepository) { } diff --git a/app/Model/Settings/Commands/SetSettingArrayValue.php b/app/Model/Settings/Commands/SetSettingArrayValue.php index 7760886cb..2b97a00e1 100644 --- a/app/Model/Settings/Commands/SetSettingArrayValue.php +++ b/app/Model/Settings/Commands/SetSettingArrayValue.php @@ -6,8 +6,8 @@ class SetSettingArrayValue { - /** @param string[]|null $value */ - public function __construct(private readonly string $item, private readonly array|null $value) + /** @param mixed[] $value */ + public function __construct(private string $item, private array|null $value) { } @@ -16,7 +16,7 @@ public function getItem(): string return $this->item; } - /** @return string[]|null */ + /** @return mixed[]|null */ public function getValue(): array|null { return $this->value; diff --git a/app/Model/Settings/Commands/SetSettingBoolValue.php b/app/Model/Settings/Commands/SetSettingBoolValue.php index a1a7d36f9..1be8209ae 100644 --- a/app/Model/Settings/Commands/SetSettingBoolValue.php +++ b/app/Model/Settings/Commands/SetSettingBoolValue.php @@ -6,7 +6,7 @@ class SetSettingBoolValue { - public function __construct(private readonly string $item, private readonly bool|null $value) + public function __construct(private string $item, private bool|null $value) { } diff --git a/app/Model/Settings/Commands/SetSettingDateTimeValue.php b/app/Model/Settings/Commands/SetSettingDateTimeValue.php index e13058470..d3e371b8b 100644 --- a/app/Model/Settings/Commands/SetSettingDateTimeValue.php +++ b/app/Model/Settings/Commands/SetSettingDateTimeValue.php @@ -8,7 +8,7 @@ class SetSettingDateTimeValue { - public function __construct(private readonly string $item, private readonly DateTimeImmutable|null $value) + public function __construct(private string $item, private DateTimeImmutable|null $value) { } diff --git a/app/Model/Settings/Commands/SetSettingDateValue.php b/app/Model/Settings/Commands/SetSettingDateValue.php index 9833e0dd7..59f35edc1 100644 --- a/app/Model/Settings/Commands/SetSettingDateValue.php +++ b/app/Model/Settings/Commands/SetSettingDateValue.php @@ -8,7 +8,7 @@ class SetSettingDateValue { - public function __construct(private readonly string $item, private readonly DateTimeImmutable|null $value) + public function __construct(private string $item, private DateTimeImmutable|null $value) { } diff --git a/app/Model/Settings/Commands/SetSettingIntValue.php b/app/Model/Settings/Commands/SetSettingIntValue.php index 5af7e713d..456b50b69 100644 --- a/app/Model/Settings/Commands/SetSettingIntValue.php +++ b/app/Model/Settings/Commands/SetSettingIntValue.php @@ -6,7 +6,7 @@ class SetSettingIntValue { - public function __construct(private readonly string $item, private readonly int|null $value) + public function __construct(private string $item, private int|null $value) { } diff --git a/app/Model/Settings/Commands/SetSettingStringValue.php b/app/Model/Settings/Commands/SetSettingStringValue.php index 67038bd52..ad5c645f0 100644 --- a/app/Model/Settings/Commands/SetSettingStringValue.php +++ b/app/Model/Settings/Commands/SetSettingStringValue.php @@ -6,7 +6,7 @@ class SetSettingStringValue { - public function __construct(private readonly string $item, private readonly string|null $value) + public function __construct(private string $item, private string|null $value) { } diff --git a/app/Model/Settings/Queries/Handlers/IsAllowedRegisterProgramsQueryHandler.php b/app/Model/Settings/Queries/Handlers/IsAllowedRegisterProgramsQueryHandler.php index 5213efcde..eb9838a45 100644 --- a/app/Model/Settings/Queries/Handlers/IsAllowedRegisterProgramsQueryHandler.php +++ b/app/Model/Settings/Queries/Handlers/IsAllowedRegisterProgramsQueryHandler.php @@ -15,7 +15,7 @@ class IsAllowedRegisterProgramsQueryHandler implements MessageHandlerInterface { - public function __construct(private readonly QueryBus $queryBus) + public function __construct(private QueryBus $queryBus) { } diff --git a/app/Model/Settings/Queries/Handlers/SettingArrayValueQueryHandler.php b/app/Model/Settings/Queries/Handlers/SettingArrayValueQueryHandler.php index e67bd5417..fe2cb0a3a 100644 --- a/app/Model/Settings/Queries/Handlers/SettingArrayValueQueryHandler.php +++ b/app/Model/Settings/Queries/Handlers/SettingArrayValueQueryHandler.php @@ -13,12 +13,12 @@ class SettingArrayValueQueryHandler implements MessageHandlerInterface { - public function __construct(private readonly SettingsRepository $settingsRepository) + public function __construct(private SettingsRepository $settingsRepository) { } /** - * @return string[]|null + * @return mixed[]|null * * @throws SettingsItemNotFoundException */ diff --git a/app/Model/Settings/Queries/Handlers/SettingBoolValueQueryHandler.php b/app/Model/Settings/Queries/Handlers/SettingBoolValueQueryHandler.php index d631e9a0b..688d63d44 100644 --- a/app/Model/Settings/Queries/Handlers/SettingBoolValueQueryHandler.php +++ b/app/Model/Settings/Queries/Handlers/SettingBoolValueQueryHandler.php @@ -15,7 +15,7 @@ class SettingBoolValueQueryHandler implements MessageHandlerInterface { - public function __construct(private readonly SettingsRepository $settingsRepository) + public function __construct(private SettingsRepository $settingsRepository) { } diff --git a/app/Model/Settings/Queries/Handlers/SettingDateTimeValueAsTextQueryHandler.php b/app/Model/Settings/Queries/Handlers/SettingDateTimeValueAsTextQueryHandler.php index e1ee0c22e..fdbd0992f 100644 --- a/app/Model/Settings/Queries/Handlers/SettingDateTimeValueAsTextQueryHandler.php +++ b/app/Model/Settings/Queries/Handlers/SettingDateTimeValueAsTextQueryHandler.php @@ -9,19 +9,15 @@ use App\Model\Settings\Repositories\SettingsRepository; use App\Utils\Helpers; use DateTimeImmutable; -use Exception; use Symfony\Component\Messenger\Handler\MessageHandlerInterface; class SettingDateTimeValueAsTextQueryHandler implements MessageHandlerInterface { - public function __construct(private readonly SettingsRepository $settingsRepository) + public function __construct(private SettingsRepository $settingsRepository) { } - /** - * @throws SettingsItemNotFoundException - * @throws Exception - */ + /** @throws SettingsItemNotFoundException */ public function __invoke(SettingDateTimeValueAsTextQuery $query): string|null { $setting = $this->settingsRepository->findByItem($query->getItem()); diff --git a/app/Model/Settings/Queries/Handlers/SettingDateTimeValueQueryHandler.php b/app/Model/Settings/Queries/Handlers/SettingDateTimeValueQueryHandler.php index d84849995..0d51363b2 100644 --- a/app/Model/Settings/Queries/Handlers/SettingDateTimeValueQueryHandler.php +++ b/app/Model/Settings/Queries/Handlers/SettingDateTimeValueQueryHandler.php @@ -8,19 +8,15 @@ use App\Model\Settings\Queries\SettingDateTimeValueQuery; use App\Model\Settings\Repositories\SettingsRepository; use DateTimeImmutable; -use Exception; use Symfony\Component\Messenger\Handler\MessageHandlerInterface; class SettingDateTimeValueQueryHandler implements MessageHandlerInterface { - public function __construct(private readonly SettingsRepository $settingsRepository) + public function __construct(private SettingsRepository $settingsRepository) { } - /** - * @throws SettingsItemNotFoundException - * @throws Exception - */ + /** @throws SettingsItemNotFoundException */ public function __invoke(SettingDateTimeValueQuery $query): DateTimeImmutable|null { $setting = $this->settingsRepository->findByItem($query->getItem()); diff --git a/app/Model/Settings/Queries/Handlers/SettingDateValueAsTextQueryHandler.php b/app/Model/Settings/Queries/Handlers/SettingDateValueAsTextQueryHandler.php index 5cc8168ad..82d75f543 100644 --- a/app/Model/Settings/Queries/Handlers/SettingDateValueAsTextQueryHandler.php +++ b/app/Model/Settings/Queries/Handlers/SettingDateValueAsTextQueryHandler.php @@ -9,19 +9,15 @@ use App\Model\Settings\Repositories\SettingsRepository; use App\Utils\Helpers; use DateTimeImmutable; -use Exception; use Symfony\Component\Messenger\Handler\MessageHandlerInterface; class SettingDateValueAsTextQueryHandler implements MessageHandlerInterface { - public function __construct(private readonly SettingsRepository $settingsRepository) + public function __construct(private SettingsRepository $settingsRepository) { } - /** - * @throws SettingsItemNotFoundException - * @throws Exception - */ + /** @throws SettingsItemNotFoundException */ public function __invoke(SettingDateValueAsTextQuery $query): string|null { $setting = $this->settingsRepository->findByItem($query->getItem()); diff --git a/app/Model/Settings/Queries/Handlers/SettingDateValueQueryHandler.php b/app/Model/Settings/Queries/Handlers/SettingDateValueQueryHandler.php index ad877d0e6..c83d9a166 100644 --- a/app/Model/Settings/Queries/Handlers/SettingDateValueQueryHandler.php +++ b/app/Model/Settings/Queries/Handlers/SettingDateValueQueryHandler.php @@ -8,19 +8,15 @@ use App\Model\Settings\Queries\SettingDateValueQuery; use App\Model\Settings\Repositories\SettingsRepository; use DateTimeImmutable; -use Exception; use Symfony\Component\Messenger\Handler\MessageHandlerInterface; class SettingDateValueQueryHandler implements MessageHandlerInterface { - public function __construct(private readonly SettingsRepository $settingsRepository) + public function __construct(private SettingsRepository $settingsRepository) { } - /** - * @throws SettingsItemNotFoundException - * @throws Exception - */ + /** @throws SettingsItemNotFoundException */ public function __invoke(SettingDateValueQuery $query): DateTimeImmutable|null { $setting = $this->settingsRepository->findByItem($query->getItem()); diff --git a/app/Model/Settings/Queries/Handlers/SettingIntValueQueryHandler.php b/app/Model/Settings/Queries/Handlers/SettingIntValueQueryHandler.php index 9e868cdb1..9d8f8c873 100644 --- a/app/Model/Settings/Queries/Handlers/SettingIntValueQueryHandler.php +++ b/app/Model/Settings/Queries/Handlers/SettingIntValueQueryHandler.php @@ -15,7 +15,7 @@ class SettingIntValueQueryHandler implements MessageHandlerInterface { - public function __construct(private readonly SettingsRepository $settingsRepository) + public function __construct(private SettingsRepository $settingsRepository) { } diff --git a/app/Model/Settings/Queries/Handlers/SettingStringValueQueryHandler.php b/app/Model/Settings/Queries/Handlers/SettingStringValueQueryHandler.php index 3cc2243b0..c2ab73a6b 100644 --- a/app/Model/Settings/Queries/Handlers/SettingStringValueQueryHandler.php +++ b/app/Model/Settings/Queries/Handlers/SettingStringValueQueryHandler.php @@ -11,7 +11,7 @@ class SettingStringValueQueryHandler implements MessageHandlerInterface { - public function __construct(private readonly SettingsRepository $settingsRepository) + public function __construct(private SettingsRepository $settingsRepository) { } diff --git a/app/Model/Settings/Queries/SettingArrayValueQuery.php b/app/Model/Settings/Queries/SettingArrayValueQuery.php index 3a1656036..411cbabbc 100644 --- a/app/Model/Settings/Queries/SettingArrayValueQuery.php +++ b/app/Model/Settings/Queries/SettingArrayValueQuery.php @@ -6,7 +6,7 @@ class SettingArrayValueQuery { - public function __construct(private readonly string $item) + public function __construct(private string $item) { } diff --git a/app/Model/Settings/Queries/SettingBoolValueQuery.php b/app/Model/Settings/Queries/SettingBoolValueQuery.php index 356070a33..fbae1cd28 100644 --- a/app/Model/Settings/Queries/SettingBoolValueQuery.php +++ b/app/Model/Settings/Queries/SettingBoolValueQuery.php @@ -6,7 +6,7 @@ class SettingBoolValueQuery { - public function __construct(private readonly string $item) + public function __construct(private string $item) { } diff --git a/app/Model/Settings/Queries/SettingDateTimeValueAsTextQuery.php b/app/Model/Settings/Queries/SettingDateTimeValueAsTextQuery.php index 9f657d6f7..5507e9196 100644 --- a/app/Model/Settings/Queries/SettingDateTimeValueAsTextQuery.php +++ b/app/Model/Settings/Queries/SettingDateTimeValueAsTextQuery.php @@ -6,7 +6,7 @@ class SettingDateTimeValueAsTextQuery { - public function __construct(private readonly string $item) + public function __construct(private string $item) { } diff --git a/app/Model/Settings/Queries/SettingDateTimeValueQuery.php b/app/Model/Settings/Queries/SettingDateTimeValueQuery.php index 766207b4e..0569e4609 100644 --- a/app/Model/Settings/Queries/SettingDateTimeValueQuery.php +++ b/app/Model/Settings/Queries/SettingDateTimeValueQuery.php @@ -6,7 +6,7 @@ class SettingDateTimeValueQuery { - public function __construct(private readonly string $item) + public function __construct(private string $item) { } diff --git a/app/Model/Settings/Queries/SettingDateValueAsTextQuery.php b/app/Model/Settings/Queries/SettingDateValueAsTextQuery.php index e62439e73..de9abf898 100644 --- a/app/Model/Settings/Queries/SettingDateValueAsTextQuery.php +++ b/app/Model/Settings/Queries/SettingDateValueAsTextQuery.php @@ -6,7 +6,7 @@ class SettingDateValueAsTextQuery { - public function __construct(private readonly string $item) + public function __construct(private string $item) { } diff --git a/app/Model/Settings/Queries/SettingDateValueQuery.php b/app/Model/Settings/Queries/SettingDateValueQuery.php index 663669264..df0484fe0 100644 --- a/app/Model/Settings/Queries/SettingDateValueQuery.php +++ b/app/Model/Settings/Queries/SettingDateValueQuery.php @@ -6,7 +6,7 @@ class SettingDateValueQuery { - public function __construct(private readonly string $item) + public function __construct(private string $item) { } diff --git a/app/Model/Settings/Queries/SettingIntValueQuery.php b/app/Model/Settings/Queries/SettingIntValueQuery.php index f9dbdca56..c927cc078 100644 --- a/app/Model/Settings/Queries/SettingIntValueQuery.php +++ b/app/Model/Settings/Queries/SettingIntValueQuery.php @@ -6,7 +6,7 @@ class SettingIntValueQuery { - public function __construct(private readonly string $item) + public function __construct(private string $item) { } diff --git a/app/Model/Settings/Queries/SettingStringValueQuery.php b/app/Model/Settings/Queries/SettingStringValueQuery.php index 36747a6f1..44e001afc 100644 --- a/app/Model/Settings/Queries/SettingStringValueQuery.php +++ b/app/Model/Settings/Queries/SettingStringValueQuery.php @@ -6,7 +6,7 @@ class SettingStringValueQuery { - public function __construct(private readonly string $item) + public function __construct(private string $item) { } diff --git a/app/Model/Settings/Repositories/SettingsRepository.php b/app/Model/Settings/Repositories/SettingsRepository.php index a69fd313e..788187533 100644 --- a/app/Model/Settings/Repositories/SettingsRepository.php +++ b/app/Model/Settings/Repositories/SettingsRepository.php @@ -23,8 +23,6 @@ public function __construct(EntityManagerInterface $em) /** * Vrací položku nastavení podle názvu. - * - * @throws SettingsItemNotFoundException */ public function findByItem(string $item): Settings { diff --git a/app/Model/Settings/Settings.php b/app/Model/Settings/Settings.php index d5ffb6f82..a6fb5e2ad 100644 --- a/app/Model/Settings/Settings.php +++ b/app/Model/Settings/Settings.php @@ -24,6 +24,21 @@ class Settings */ public const SEMINAR_NAME = 'seminar_name'; + /** + * E-mail semináře. + */ + public const SEMINAR_EMAIL = 'seminar_email'; + + /** + * Neověřený změněný e-mail semináře. + */ + public const SEMINAR_EMAIL_UNVERIFIED = 'seminar_email_unverified'; + + /** + * Ověřovací kód pro změnu e-mailu. + */ + public const SEMINAR_EMAIL_VERIFICATION_CODE = 'seminar_email_verification_code'; + /** * Začátek semináře. */ @@ -99,6 +114,11 @@ class Settings */ public const ACCOUNTANT = 'accountant'; + /** + * Místo vystavení dokladu. + */ + public const PRINT_LOCATION = 'print_location'; + /** * Číslo účtu. */ @@ -214,6 +234,21 @@ class Settings */ public const CONTACT_FORM_GUESTS_ALLOWED = 'contact_form_guests_allowed'; + /** + * Skupina - minimalni pocet clenu + */ + public const GROUP_MIN_MEMBERS = 'group_min_members'; + + /** + * Skupina - maximalni pocet clenu + */ + public const GROUP_MAX_MEMBERS = 'group_max_members'; + + /** + * Skupina - termin pro naplneni skupiny + */ + public const GROUP_FILL_TERM = 'group_fill_term'; + /** * Název položky nastavení. */ diff --git a/app/Model/Structure/Queries/Handlers/SubeventByIdQueryHandler.php b/app/Model/Structure/Queries/Handlers/SubeventByIdQueryHandler.php index 6040b595d..72b69c0fa 100644 --- a/app/Model/Structure/Queries/Handlers/SubeventByIdQueryHandler.php +++ b/app/Model/Structure/Queries/Handlers/SubeventByIdQueryHandler.php @@ -11,7 +11,7 @@ class SubeventByIdQueryHandler implements MessageHandlerInterface { - public function __construct(private readonly SubeventRepository $subeventRepository) + public function __construct(private SubeventRepository $subeventRepository) { } diff --git a/app/Model/Structure/Queries/Handlers/SubeventsQueryHandler.php b/app/Model/Structure/Queries/Handlers/SubeventsQueryHandler.php index 5e0cde837..58daa6827 100644 --- a/app/Model/Structure/Queries/Handlers/SubeventsQueryHandler.php +++ b/app/Model/Structure/Queries/Handlers/SubeventsQueryHandler.php @@ -12,7 +12,7 @@ class SubeventsQueryHandler implements MessageHandlerInterface { - public function __construct(private readonly SubeventRepository $subeventRepository) + public function __construct(private SubeventRepository $subeventRepository) { } diff --git a/app/Model/Structure/Queries/SubeventByIdQuery.php b/app/Model/Structure/Queries/SubeventByIdQuery.php index f432bc994..cd9d3276a 100644 --- a/app/Model/Structure/Queries/SubeventByIdQuery.php +++ b/app/Model/Structure/Queries/SubeventByIdQuery.php @@ -6,7 +6,7 @@ class SubeventByIdQuery { - public function __construct(private readonly int $id) + public function __construct(private int $id) { } diff --git a/app/Model/Structure/Queries/SubeventsQuery.php b/app/Model/Structure/Queries/SubeventsQuery.php index 7b3f64d80..b12d492fb 100644 --- a/app/Model/Structure/Queries/SubeventsQuery.php +++ b/app/Model/Structure/Queries/SubeventsQuery.php @@ -9,11 +9,11 @@ class SubeventsQuery { public function __construct( - private readonly bool $explicitOnly = false, - private readonly bool $registerableNowOnly = false, - private readonly User|null $user = null, - private readonly bool $userNotRegisteredOnly = false, - private readonly bool $includeUserRegistered = false, + private bool $explicitOnly = false, + private bool $registerableNowOnly = false, + private User|null $user = null, + private bool $userNotRegisteredOnly = false, + private bool $includeUserRegistered = false, ) { } diff --git a/app/Model/Structure/Subevent.php b/app/Model/Structure/Subevent.php index 4d8fc182e..b58f04cb6 100644 --- a/app/Model/Structure/Subevent.php +++ b/app/Model/Structure/Subevent.php @@ -53,7 +53,7 @@ class Subevent * * @var Collection */ - #[ORM\OneToMany(mappedBy: 'subevent', targetEntity: Block::class, cascade: ['persist'])] + #[ORM\OneToMany(targetEntity: Block::class, mappedBy: 'subevent', cascade: ['persist'])] #[ORM\OrderBy(['name' => 'ASC'])] protected Collection $blocks; diff --git a/app/Model/User/Commands/CheckTicket.php b/app/Model/User/Commands/CheckTicket.php index 673a75bd5..a3dd7aea5 100644 --- a/app/Model/User/Commands/CheckTicket.php +++ b/app/Model/User/Commands/CheckTicket.php @@ -10,8 +10,8 @@ class CheckTicket { public function __construct( - private readonly User $user, - private readonly Subevent|null $subevent, + private User $user, + private Subevent|null $subevent, ) { } diff --git a/app/Model/User/Commands/Handlers/CheckTicketHandler.php b/app/Model/User/Commands/Handlers/CheckTicketHandler.php index 75273cddd..02706ce10 100644 --- a/app/Model/User/Commands/Handlers/CheckTicketHandler.php +++ b/app/Model/User/Commands/Handlers/CheckTicketHandler.php @@ -12,7 +12,7 @@ class CheckTicketHandler implements MessageHandlerInterface { - public function __construct(private readonly TicketCheckRepository $ticketCheckRepository, private readonly UserRepository $userRepository) + public function __construct(private TicketCheckRepository $ticketCheckRepository, private UserRepository $userRepository) { } diff --git a/app/Model/User/Commands/Handlers/RegisterProgramHandler.php b/app/Model/User/Commands/Handlers/RegisterProgramHandler.php index 0a4387b5a..5d1871cdf 100644 --- a/app/Model/User/Commands/Handlers/RegisterProgramHandler.php +++ b/app/Model/User/Commands/Handlers/RegisterProgramHandler.php @@ -20,10 +20,10 @@ class RegisterProgramHandler implements MessageHandlerInterface { public function __construct( - private readonly QueryBus $queryBus, - private readonly EventBus $eventBus, - private readonly EntityManagerInterface $em, - private readonly ProgramApplicationRepository $programApplicationRepository, + private QueryBus $queryBus, + private EventBus $eventBus, + private EntityManagerInterface $em, + private ProgramApplicationRepository $programApplicationRepository, ) { } diff --git a/app/Model/User/Commands/Handlers/UnregisterProgramHandler.php b/app/Model/User/Commands/Handlers/UnregisterProgramHandler.php index 41330ac0d..270cfd6b4 100644 --- a/app/Model/User/Commands/Handlers/UnregisterProgramHandler.php +++ b/app/Model/User/Commands/Handlers/UnregisterProgramHandler.php @@ -15,13 +15,12 @@ class UnregisterProgramHandler implements MessageHandlerInterface { public function __construct( - private readonly EventBus $eventBus, - private readonly EntityManagerInterface $em, - private readonly ProgramApplicationRepository $programApplicationRepository, + private EventBus $eventBus, + private EntityManagerInterface $em, + private ProgramApplicationRepository $programApplicationRepository, ) { } - /** @throws UserNotAttendsProgramException */ public function __invoke(UnregisterProgram $command): void { $programApplication = $this->programApplicationRepository->findByUserAndProgram($command->getUser(), $command->getProgram()); diff --git a/app/Model/User/Commands/Handlers/UpdateUserProgramsHandler.php b/app/Model/User/Commands/Handlers/UpdateUserProgramsHandler.php index 7a4c69c31..6e4253ad7 100644 --- a/app/Model/User/Commands/Handlers/UpdateUserProgramsHandler.php +++ b/app/Model/User/Commands/Handlers/UpdateUserProgramsHandler.php @@ -20,9 +20,9 @@ class UpdateUserProgramsHandler implements MessageHandlerInterface { public function __construct( - private readonly QueryBus $queryBus, - private readonly CommandBus $commandBus, - private readonly EntityManagerInterface $em, + private QueryBus $queryBus, + private CommandBus $commandBus, + private EntityManagerInterface $em, ) { } diff --git a/app/Model/User/Commands/RegisterProgram.php b/app/Model/User/Commands/RegisterProgram.php index eab310950..3cac5f7d9 100644 --- a/app/Model/User/Commands/RegisterProgram.php +++ b/app/Model/User/Commands/RegisterProgram.php @@ -10,9 +10,9 @@ class RegisterProgram { public function __construct( - private readonly User $user, - private readonly Program $program, - private readonly bool $notifyUser = true, + private User $user, + private Program $program, + private bool $notifyUser = true, ) { } diff --git a/app/Model/User/Commands/UnregisterProgram.php b/app/Model/User/Commands/UnregisterProgram.php index 891f472e2..ea5b0d03c 100644 --- a/app/Model/User/Commands/UnregisterProgram.php +++ b/app/Model/User/Commands/UnregisterProgram.php @@ -10,9 +10,9 @@ class UnregisterProgram { public function __construct( - private readonly User $user, - private readonly Program $program, - private readonly bool $notifyUser = true, + private User $user, + private Program $program, + private bool $notifyUser = true, ) { } diff --git a/app/Model/User/Commands/UpdateUserPrograms.php b/app/Model/User/Commands/UpdateUserPrograms.php index d0507f687..91ca951df 100644 --- a/app/Model/User/Commands/UpdateUserPrograms.php +++ b/app/Model/User/Commands/UpdateUserPrograms.php @@ -8,7 +8,7 @@ class UpdateUserPrograms { - public function __construct(private readonly User $user) + public function __construct(private User $user) { } diff --git a/app/Model/User/Events/ProgramRegisteredEvent.php b/app/Model/User/Events/ProgramRegisteredEvent.php index 4508ed20b..70afe46ce 100644 --- a/app/Model/User/Events/ProgramRegisteredEvent.php +++ b/app/Model/User/Events/ProgramRegisteredEvent.php @@ -10,10 +10,10 @@ class ProgramRegisteredEvent { public function __construct( - private readonly User $user, - private readonly Program $program, - private readonly bool $alternate, - private readonly bool $notifyUser, + private User $user, + private Program $program, + private bool $alternate, + private bool $notifyUser, ) { } diff --git a/app/Model/User/Events/ProgramUnregisteredEvent.php b/app/Model/User/Events/ProgramUnregisteredEvent.php index 6527a7b02..35c5ca3e4 100644 --- a/app/Model/User/Events/ProgramUnregisteredEvent.php +++ b/app/Model/User/Events/ProgramUnregisteredEvent.php @@ -10,10 +10,10 @@ class ProgramUnregisteredEvent { public function __construct( - private readonly User $user, - private readonly Program $program, - private readonly bool $alternate, - private readonly bool $notifyUser, + private User $user, + private Program $program, + private bool $alternate, + private bool $notifyUser, ) { } diff --git a/app/Model/User/Events/Subscribers/ProgramRegisteredEventListener.php b/app/Model/User/Events/Subscribers/ProgramRegisteredEventListener.php index f87a3e56d..2476a7f48 100644 --- a/app/Model/User/Events/Subscribers/ProgramRegisteredEventListener.php +++ b/app/Model/User/Events/Subscribers/ProgramRegisteredEventListener.php @@ -4,35 +4,29 @@ namespace App\Model\User\Events\Subscribers; -use App\Model\Mailing\Commands\CreateTemplateMail; use App\Model\Mailing\Template; use App\Model\Mailing\TemplateVariable; use App\Model\Settings\Queries\SettingStringValueQuery; use App\Model\Settings\Settings; use App\Model\User\Events\ProgramRegisteredEvent; -use App\Services\CommandBus; +use App\Services\IMailService; use App\Services\QueryBus; use Doctrine\Common\Collections\ArrayCollection; use Symfony\Component\Messenger\Handler\MessageHandlerInterface; class ProgramRegisteredEventListener implements MessageHandlerInterface { - public function __construct(private readonly CommandBus $commandBus, private readonly QueryBus $queryBus) + public function __construct(private QueryBus $queryBus, private IMailService $mailService) { } public function __invoke(ProgramRegisteredEvent $event): void { if (! $event->isAlternate() && $event->isNotifyUser()) { - $this->commandBus->handle(new CreateTemplateMail( - new ArrayCollection([$event->getUser()]), - null, - Template::PROGRAM_REGISTERED, - [ - TemplateVariable::SEMINAR_NAME => $this->queryBus->handle(new SettingStringValueQuery(Settings::SEMINAR_NAME)), - TemplateVariable::PROGRAM_NAME => $event->getProgram()->getBlock()->getName(), - ], - )); + $this->mailService->sendMailFromTemplate(new ArrayCollection([$event->getUser()]), null, Template::PROGRAM_REGISTERED, [ + TemplateVariable::SEMINAR_NAME => $this->queryBus->handle(new SettingStringValueQuery(Settings::SEMINAR_NAME)), + TemplateVariable::PROGRAM_NAME => $event->getProgram()->getBlock()->getName(), + ]); } } } diff --git a/app/Model/User/Events/Subscribers/ProgramUnregisteredEventListener.php b/app/Model/User/Events/Subscribers/ProgramUnregisteredEventListener.php index 06140e139..6e30a353d 100644 --- a/app/Model/User/Events/Subscribers/ProgramUnregisteredEventListener.php +++ b/app/Model/User/Events/Subscribers/ProgramUnregisteredEventListener.php @@ -4,7 +4,6 @@ namespace App\Model\User\Events\Subscribers; -use App\Model\Mailing\Commands\CreateTemplateMail; use App\Model\Mailing\Template; use App\Model\Mailing\TemplateVariable; use App\Model\Settings\Queries\SettingStringValueQuery; @@ -13,6 +12,7 @@ use App\Model\User\Events\ProgramUnregisteredEvent; use App\Model\User\Repositories\UserRepository; use App\Services\CommandBus; +use App\Services\IMailService; use App\Services\QueryBus; use Doctrine\Common\Collections\ArrayCollection; use Symfony\Component\Messenger\Handler\MessageHandlerInterface; @@ -20,9 +20,10 @@ class ProgramUnregisteredEventListener implements MessageHandlerInterface { public function __construct( - private readonly CommandBus $commandBus, - private readonly QueryBus $queryBus, - private readonly UserRepository $userRepository, + private CommandBus $commandBus, + private QueryBus $queryBus, + private UserRepository $userRepository, + private IMailService $mailService, ) { } @@ -36,10 +37,10 @@ public function __invoke(ProgramUnregisteredEvent $event): void } if ($event->isNotifyUser()) { - $this->commandBus->handle(new CreateTemplateMail(new ArrayCollection([$event->getUser()]), null, Template::PROGRAM_UNREGISTERED, [ + $this->mailService->sendMailFromTemplate(new ArrayCollection([$event->getUser()]), null, Template::PROGRAM_UNREGISTERED, [ TemplateVariable::SEMINAR_NAME => $this->queryBus->handle(new SettingStringValueQuery(Settings::SEMINAR_NAME)), TemplateVariable::PROGRAM_NAME => $event->getProgram()->getBlock()->getName(), - ])); + ]); } } } diff --git a/app/Model/User/Events/Subscribers/UserUpdatedEventListener.php b/app/Model/User/Events/Subscribers/UserUpdatedEventListener.php index 28530ff04..49f4620b6 100644 --- a/app/Model/User/Events/Subscribers/UserUpdatedEventListener.php +++ b/app/Model/User/Events/Subscribers/UserUpdatedEventListener.php @@ -11,7 +11,7 @@ class UserUpdatedEventListener implements MessageHandlerInterface { - public function __construct(private readonly CommandBus $commandBus) + public function __construct(private CommandBus $commandBus) { } diff --git a/app/Model/User/Events/UserUpdatedEvent.php b/app/Model/User/Events/UserUpdatedEvent.php index d560f1e94..c528fd44c 100644 --- a/app/Model/User/Events/UserUpdatedEvent.php +++ b/app/Model/User/Events/UserUpdatedEvent.php @@ -8,7 +8,7 @@ class UserUpdatedEvent { - public function __construct(private readonly User $user, private readonly bool $approvedOld) + public function __construct(private User $user, private bool $approvedOld) { } diff --git a/app/Model/User/Queries/Handlers/TicketChecksByUserAndSubeventQueryHandler.php b/app/Model/User/Queries/Handlers/TicketChecksByUserAndSubeventQueryHandler.php index 39f424782..d22fa2348 100644 --- a/app/Model/User/Queries/Handlers/TicketChecksByUserAndSubeventQueryHandler.php +++ b/app/Model/User/Queries/Handlers/TicketChecksByUserAndSubeventQueryHandler.php @@ -12,7 +12,7 @@ class TicketChecksByUserAndSubeventQueryHandler implements MessageHandlerInterface { - public function __construct(private readonly TicketCheckRepository $ticketCheckRepository) + public function __construct(private TicketCheckRepository $ticketCheckRepository) { } diff --git a/app/Model/User/Queries/Handlers/UserAllowedBlocksQueryHandler.php b/app/Model/User/Queries/Handlers/UserAllowedBlocksQueryHandler.php index 092ace73c..7519e5b63 100644 --- a/app/Model/User/Queries/Handlers/UserAllowedBlocksQueryHandler.php +++ b/app/Model/User/Queries/Handlers/UserAllowedBlocksQueryHandler.php @@ -12,7 +12,7 @@ class UserAllowedBlocksQueryHandler implements MessageHandlerInterface { - public function __construct(private readonly BlockRepository $blockRepository) + public function __construct(private BlockRepository $blockRepository) { } diff --git a/app/Model/User/Queries/Handlers/UserAllowedProgramsQueryHandler.php b/app/Model/User/Queries/Handlers/UserAllowedProgramsQueryHandler.php index beb5e2093..af13d657c 100644 --- a/app/Model/User/Queries/Handlers/UserAllowedProgramsQueryHandler.php +++ b/app/Model/User/Queries/Handlers/UserAllowedProgramsQueryHandler.php @@ -12,7 +12,7 @@ class UserAllowedProgramsQueryHandler implements MessageHandlerInterface { - public function __construct(private readonly ProgramRepository $programRepository) + public function __construct(private ProgramRepository $programRepository) { } diff --git a/app/Model/User/Queries/Handlers/UserAttendsBlocksQueryHandler.php b/app/Model/User/Queries/Handlers/UserAttendsBlocksQueryHandler.php index 402712cde..7c1b00600 100644 --- a/app/Model/User/Queries/Handlers/UserAttendsBlocksQueryHandler.php +++ b/app/Model/User/Queries/Handlers/UserAttendsBlocksQueryHandler.php @@ -12,7 +12,7 @@ class UserAttendsBlocksQueryHandler implements MessageHandlerInterface { - public function __construct(private readonly BlockRepository $blockRepository) + public function __construct(private BlockRepository $blockRepository) { } diff --git a/app/Model/User/Queries/Handlers/UserAttendsProgramsQueryHandler.php b/app/Model/User/Queries/Handlers/UserAttendsProgramsQueryHandler.php index a2d65befa..7f5abc8d3 100644 --- a/app/Model/User/Queries/Handlers/UserAttendsProgramsQueryHandler.php +++ b/app/Model/User/Queries/Handlers/UserAttendsProgramsQueryHandler.php @@ -12,7 +12,7 @@ class UserAttendsProgramsQueryHandler implements MessageHandlerInterface { - public function __construct(private readonly ProgramRepository $programRepository) + public function __construct(private ProgramRepository $programRepository) { } diff --git a/app/Model/User/Queries/Handlers/UserByIdQueryHandler.php b/app/Model/User/Queries/Handlers/UserByIdQueryHandler.php index 35734213d..3f6108981 100644 --- a/app/Model/User/Queries/Handlers/UserByIdQueryHandler.php +++ b/app/Model/User/Queries/Handlers/UserByIdQueryHandler.php @@ -11,7 +11,7 @@ class UserByIdQueryHandler implements MessageHandlerInterface { - public function __construct(private readonly UserRepository $userRepository) + public function __construct(private UserRepository $userRepository) { } diff --git a/app/Model/User/Queries/Handlers/UserRegisteredProgramAtQueryHandler.php b/app/Model/User/Queries/Handlers/UserRegisteredProgramAtQueryHandler.php index e43da4c29..95abe7899 100644 --- a/app/Model/User/Queries/Handlers/UserRegisteredProgramAtQueryHandler.php +++ b/app/Model/User/Queries/Handlers/UserRegisteredProgramAtQueryHandler.php @@ -11,7 +11,7 @@ class UserRegisteredProgramAtQueryHandler implements MessageHandlerInterface { - public function __construct(private readonly ProgramApplicationRepository $programApplicationRepository) + public function __construct(private ProgramApplicationRepository $programApplicationRepository) { } diff --git a/app/Model/User/Queries/TicketChecksByUserAndSubeventQuery.php b/app/Model/User/Queries/TicketChecksByUserAndSubeventQuery.php index b75cf9372..16c73fb0d 100644 --- a/app/Model/User/Queries/TicketChecksByUserAndSubeventQuery.php +++ b/app/Model/User/Queries/TicketChecksByUserAndSubeventQuery.php @@ -9,7 +9,7 @@ class TicketChecksByUserAndSubeventQuery { - public function __construct(private readonly User $user, private readonly Subevent $subevent) + public function __construct(private User $user, private Subevent $subevent) { } diff --git a/app/Model/User/Queries/UserAllowedBlocksQuery.php b/app/Model/User/Queries/UserAllowedBlocksQuery.php index 249869362..4ad20a515 100644 --- a/app/Model/User/Queries/UserAllowedBlocksQuery.php +++ b/app/Model/User/Queries/UserAllowedBlocksQuery.php @@ -8,7 +8,7 @@ class UserAllowedBlocksQuery { - public function __construct(private readonly User $user, private readonly bool $paidOnly) + public function __construct(private User $user, private bool $paidOnly) { } diff --git a/app/Model/User/Queries/UserAllowedProgramsQuery.php b/app/Model/User/Queries/UserAllowedProgramsQuery.php index afffbde57..85641a266 100644 --- a/app/Model/User/Queries/UserAllowedProgramsQuery.php +++ b/app/Model/User/Queries/UserAllowedProgramsQuery.php @@ -8,7 +8,7 @@ class UserAllowedProgramsQuery { - public function __construct(private readonly User $user, private readonly bool $paidOnly) + public function __construct(private User $user, private bool $paidOnly) { } diff --git a/app/Model/User/Queries/UserAttendsBlocksQuery.php b/app/Model/User/Queries/UserAttendsBlocksQuery.php index 72b8c5b71..e7c4f7698 100644 --- a/app/Model/User/Queries/UserAttendsBlocksQuery.php +++ b/app/Model/User/Queries/UserAttendsBlocksQuery.php @@ -8,7 +8,7 @@ class UserAttendsBlocksQuery { - public function __construct(private readonly User $user) + public function __construct(private User $user) { } diff --git a/app/Model/User/Queries/UserAttendsProgramsQuery.php b/app/Model/User/Queries/UserAttendsProgramsQuery.php index ef3c505f6..be19ebf8a 100644 --- a/app/Model/User/Queries/UserAttendsProgramsQuery.php +++ b/app/Model/User/Queries/UserAttendsProgramsQuery.php @@ -8,7 +8,7 @@ class UserAttendsProgramsQuery { - public function __construct(private readonly User $user) + public function __construct(private User $user) { } diff --git a/app/Model/User/Queries/UserByIdQuery.php b/app/Model/User/Queries/UserByIdQuery.php index eac5d5342..6f327ab53 100644 --- a/app/Model/User/Queries/UserByIdQuery.php +++ b/app/Model/User/Queries/UserByIdQuery.php @@ -6,7 +6,7 @@ class UserByIdQuery { - public function __construct(private readonly int $id) + public function __construct(private int $id) { } diff --git a/app/Model/User/Queries/UserRegisteredProgramAtQuery.php b/app/Model/User/Queries/UserRegisteredProgramAtQuery.php index eb5a2bf9c..fb83fc4ff 100644 --- a/app/Model/User/Queries/UserRegisteredProgramAtQuery.php +++ b/app/Model/User/Queries/UserRegisteredProgramAtQuery.php @@ -9,7 +9,7 @@ class UserRegisteredProgramAtQuery { - public function __construct(private readonly User $user, private readonly Program $program) + public function __construct(private User $user, private Program $program) { } diff --git a/app/Model/User/User.php b/app/Model/User/User.php index 43af1a12a..46e0d40b3 100644 --- a/app/Model/User/User.php +++ b/app/Model/User/User.php @@ -141,13 +141,13 @@ class User /** * Id uživatele ve skautIS. */ - #[ORM\Column(name: 'skautis_user_id', type: 'integer', unique: true, nullable: true)] + #[ORM\Column(type: 'integer', unique: true, nullable: true, name: 'skautis_user_id')] protected int|null $skautISUserId = null; /** * Id osoby ve skautIS. */ - #[ORM\Column(name: 'skautis_person_id', type: 'integer', unique: true, nullable: true)] + #[ORM\Column(type: 'integer', unique: true, nullable: true, name: 'skautis_person_id')] protected int|null $skautISPersonId = null; /** @@ -211,7 +211,7 @@ class User * * @var Collection */ - #[ORM\OneToMany(mappedBy: 'user', targetEntity: Application::class, cascade: ['persist'])] + #[ORM\OneToMany(targetEntity: Application::class, mappedBy: 'user', cascade: ['persist'])] protected Collection $applications; /** @@ -219,7 +219,7 @@ class User * * @var Collection */ - #[ORM\OneToMany(mappedBy: 'user', targetEntity: ProgramApplication::class, cascade: ['persist'])] + #[ORM\OneToMany(targetEntity: ProgramApplication::class, mappedBy: 'user', cascade: ['persist'])] protected Collection $programApplications; /** @@ -279,7 +279,7 @@ class User * * @var Collection */ - #[ORM\OneToMany(mappedBy: 'user', targetEntity: CustomInputValue::class, cascade: ['persist'])] + #[ORM\OneToMany(targetEntity: CustomInputValue::class, mappedBy: 'user', cascade: ['persist'])] protected Collection $customInputValues; /** @@ -1025,11 +1025,6 @@ public function getPhoto(): string|null return $this->photo; } - public function hasPhoto(): bool - { - return $this->photo !== null; - } - public function setPhoto(string|null $photo): void { $this->photo = $photo; diff --git a/app/Presenters/AuthPresenter.php b/app/Presenters/AuthPresenter.php index 449c587bc..534a0ffd1 100644 --- a/app/Presenters/AuthPresenter.php +++ b/app/Presenters/AuthPresenter.php @@ -4,7 +4,6 @@ namespace App\Presenters; -use App\Model\Mailing\Commands\CreateTemplateMail; use App\Model\Mailing\Template; use App\Model\Mailing\TemplateVariable; use App\Model\Settings\Exceptions\SettingsItemNotFoundException; @@ -12,7 +11,7 @@ use App\Model\Settings\Settings; use App\Model\User\Repositories\UserRepository; use App\Model\User\User; -use App\Services\CommandBus; +use App\Services\IMailService; use App\Services\QueryBus; use App\Services\SkautIsService; use Doctrine\Common\Collections\ArrayCollection; @@ -31,9 +30,6 @@ */ class AuthPresenter extends BasePresenter { - #[Inject] - public CommandBus $commandBus; - #[Inject] public QueryBus $queryBus; @@ -43,6 +39,9 @@ class AuthPresenter extends BasePresenter #[Inject] public UserRepository $userRepository; + #[Inject] + public IMailService $mailService; + /** * Přesměruje na přihlašovací stránku skautIS, nastaví přihlášení. * @@ -69,9 +68,9 @@ public function actionLogin(string $backlink = ''): void $user = $this->userRepository->findById($this->user->id); assert($user instanceof User); - $this->commandBus->handle(new CreateTemplateMail(new ArrayCollection([$user]), null, Template::SIGN_IN, [ + $this->mailService->sendMailFromTemplate(new ArrayCollection([$user]), null, Template::SIGN_IN, [ TemplateVariable::SEMINAR_NAME => $this->queryBus->handle(new SettingStringValueQuery(Settings::SEMINAR_NAME)), - ])); + ]); } $this->redirectAfterLogin($this->getParameter('ReturnUrl')); diff --git a/app/Presenters/ErrorPresenter.php b/app/Presenters/ErrorPresenter.php index 816e20ddf..8ca40eb12 100644 --- a/app/Presenters/ErrorPresenter.php +++ b/app/Presenters/ErrorPresenter.php @@ -15,7 +15,7 @@ final class ErrorPresenter implements Nette\Application\IPresenter { use Nette\SmartObject; - public function __construct(private readonly ILogger $logger) + public function __construct(private ILogger $logger) { } diff --git a/app/Router/RouterFactory.php b/app/Router/RouterFactory.php index 931c2e617..acfb0bad2 100644 --- a/app/Router/RouterFactory.php +++ b/app/Router/RouterFactory.php @@ -12,7 +12,7 @@ final class RouterFactory { - public function __construct(private readonly CmsService $cmsService) + public function __construct(private CmsService $cmsService) { } @@ -36,6 +36,13 @@ public function createRouter(): RouteList 'id' => null, ]); + $router->addRoute('action//[/]', [ + 'module' => 'Action', + 'presenter' => null, + 'action' => null, + 'id' => null, + ]); + $router->addRoute('admin/cms//[/][/]', [ 'module' => 'Admin:Cms', 'presenter' => 'Page', @@ -65,7 +72,14 @@ public function createRouter(): RouteList 'id' => null, ]); - $router->addRoute('admin/configuration//[/]', [ + $router->addRoute('admin/groups//[/]', [ + 'module' => 'Admin:Groups', + 'presenter' => 'Auto', + 'action' => 'default', + 'id' => null, + ]); + + $router->addRoute('admin/configuration//[/]', [ 'module' => 'Admin:Configuration', 'presenter' => 'Seminar', 'action' => 'default', diff --git a/app/Services/AclService.php b/app/Services/AclService.php index ecea0e523..64837de8a 100644 --- a/app/Services/AclService.php +++ b/app/Services/AclService.php @@ -33,10 +33,10 @@ class AclService private Cache $resourceNamesCache; public function __construct( - private readonly RoleRepository $roleRepository, - private readonly PermissionRepository $permissionRepository, - private readonly SrsResourceRepository $resourceRepository, - private readonly Translator $translator, + private RoleRepository $roleRepository, + private PermissionRepository $permissionRepository, + private SrsResourceRepository $resourceRepository, + private Translator $translator, Storage $storage, ) { $this->roleNamesCache = new Cache($storage, 'RoleNames'); @@ -72,8 +72,8 @@ public function findAllRoleNames(): array public function saveRole(Role $role): void { $this->roleRepository->save($role); - $this->roleNamesCache->clean([Cache::Namespaces => ['RoleNames']]); - $this->permissionNamesCache->clean([Cache::Namespaces => ['PermissionNames']]); + $this->roleNamesCache->clean([Cache::NAMESPACES => ['RoleNames']]); + $this->permissionNamesCache->clean([Cache::NAMESPACES => ['PermissionNames']]); } /** @@ -82,7 +82,7 @@ public function saveRole(Role $role): void public function removeRole(Role $role): void { $this->roleRepository->remove($role); - $this->roleNamesCache->clean([Cache::Namespaces => ['RoleNames']]); + $this->roleNamesCache->clean([Cache::NAMESPACES => ['RoleNames']]); } /** diff --git a/app/Services/ApplicationService.php b/app/Services/ApplicationService.php index e38ab730e..0f0ae3c50 100644 --- a/app/Services/ApplicationService.php +++ b/app/Services/ApplicationService.php @@ -19,7 +19,6 @@ use App\Model\Enums\MaturityType; use App\Model\Enums\PaymentState; use App\Model\Enums\PaymentType; -use App\Model\Mailing\Commands\CreateTemplateMail; use App\Model\Mailing\Template; use App\Model\Mailing\TemplateVariable; use App\Model\Payment\Payment; @@ -41,6 +40,7 @@ use Doctrine\Common\Collections\Collection; use Doctrine\ORM\EntityManagerInterface; use Doctrine\ORM\OptimisticLockException; +use Doctrine\ORM\ORMException; use InvalidArgumentException; use Nette; use Nette\Localization\Translator; @@ -64,21 +64,21 @@ class ApplicationService use Nette\SmartObject; public function __construct( - private readonly CommandBus $commandBus, - private readonly QueryBus $queryBus, - private readonly EntityManagerInterface $em, - private readonly ApplicationRepository $applicationRepository, - private readonly UserRepository $userRepository, - private readonly AclService $aclService, - private readonly RoleRepository $roleRepository, - private readonly SubeventRepository $subeventRepository, - private readonly DiscountService $discountService, - private readonly VariableSymbolRepository $variableSymbolRepository, - private readonly UserService $userService, - private readonly Translator $translator, - private readonly PaymentRepository $paymentRepository, - private readonly IncomeProofRepository $incomeProofRepository, - private readonly EventBus $eventBus, + private QueryBus $queryBus, + private EntityManagerInterface $em, + private ApplicationRepository $applicationRepository, + private UserRepository $userRepository, + private AclService $aclService, + private RoleRepository $roleRepository, + private SubeventRepository $subeventRepository, + private DiscountService $discountService, + private VariableSymbolRepository $variableSymbolRepository, + private MailService $mailService, + private UserService $userService, + private Translator $translator, + private PaymentRepository $paymentRepository, + private IncomeProofRepository $incomeProofRepository, + private EventBus $eventBus, ) { } @@ -134,7 +134,7 @@ public function register( new SettingDateValueAsTextQuery(Settings::EDIT_REGISTRATION_TO), ); - $this->commandBus->handle(new CreateTemplateMail( + $this->mailService->sendMailFromTemplate( new ArrayCollection( [$user], ), @@ -150,7 +150,7 @@ public function register( new SettingStringValueQuery(Settings::ACCOUNT_NUMBER), ), ], - )); + ); } /** @@ -239,7 +239,7 @@ public function updateRoles(User $user, Collection $roles, User|null $createdBy, $this->updateUserPaymentInfo($user); }); - $this->commandBus->handle(new CreateTemplateMail( + $this->mailService->sendMailFromTemplate( new ArrayCollection( [$user], ), @@ -249,7 +249,7 @@ public function updateRoles(User $user, Collection $roles, User|null $createdBy, TemplateVariable::SEMINAR_NAME => $this->queryBus->handle(new SettingStringValueQuery(Settings::SEMINAR_NAME)), TemplateVariable::USERS_ROLES => implode(', ', $roles->map(static fn (Role $role) => $role->getName())->toArray()), ], - )); + ); } /** @@ -301,7 +301,7 @@ public function cancelRegistration(User $user, string $state, User|null $created }); if ($state === ApplicationState::CANCELED) { - $this->commandBus->handle(new CreateTemplateMail( + $this->mailService->sendMailFromTemplate( new ArrayCollection( [$user], ), @@ -312,9 +312,9 @@ public function cancelRegistration(User $user, string $state, User|null $created new SettingStringValueQuery(Settings::SEMINAR_NAME), ), ], - )); + ); } elseif ($state === ApplicationState::CANCELED_NOT_PAID) { - $this->commandBus->handle(new CreateTemplateMail( + $this->mailService->sendMailFromTemplate( new ArrayCollection( [$user], ), @@ -327,7 +327,7 @@ public function cancelRegistration(User $user, string $state, User|null $created ), ), ], - )); + ); } } @@ -349,7 +349,7 @@ public function addSubeventsApplication(User $user, Collection $subevents, User $this->updateUserPaymentInfo($user); }); - $this->commandBus->handle(new CreateTemplateMail( + $this->mailService->sendMailFromTemplate( new ArrayCollection( [$user], ), @@ -361,7 +361,7 @@ public function addSubeventsApplication(User $user, Collection $subevents, User ), TemplateVariable::USERS_SUBEVENTS => $user->getSubeventsText(), ], - )); + ); } /** @@ -407,7 +407,7 @@ public function updateSubeventsApplication(SubeventsApplication $application, Co $this->decrementSubeventsOccupancy($application->getSubevents()); }); - $this->commandBus->handle(new CreateTemplateMail( + $this->mailService->sendMailFromTemplate( new ArrayCollection( [$application->getUser()], ), @@ -419,7 +419,7 @@ public function updateSubeventsApplication(SubeventsApplication $application, Co ), TemplateVariable::USERS_SUBEVENTS => $application->getUser()->getSubeventsText(), ], - )); + ); } /** @@ -462,7 +462,7 @@ public function cancelSubeventsApplication(SubeventsApplication $application, st $this->decrementSubeventsOccupancy($application->getSubevents()); }); - $this->commandBus->handle(new CreateTemplateMail( + $this->mailService->sendMailFromTemplate( new ArrayCollection( [$application->getUser()], ), @@ -474,7 +474,7 @@ public function cancelSubeventsApplication(SubeventsApplication $application, st ), TemplateVariable::USERS_SUBEVENTS => $application->getUser()->getSubeventsText(), ], - )); + ); } /** @@ -518,7 +518,7 @@ public function updateApplicationPayment( }); if ($paymentDate !== null && $oldPaymentDate === null) { - $this->commandBus->handle(new CreateTemplateMail( + $this->mailService->sendMailFromTemplate( new ArrayCollection( [ $application->getUser(), @@ -532,7 +532,7 @@ public function updateApplicationPayment( ), TemplateVariable::APPLICATION_SUBEVENTS => $application->getSubeventsText(), ], - )); + ); } } @@ -787,6 +787,7 @@ public function isAllowedEditCustomInputs(): bool * @param Collection $roles * * @throws SettingsItemNotFoundException + * @throws ORMException * @throws OptimisticLockException * @throws ReflectionException * @throws Throwable @@ -838,6 +839,7 @@ private function createRolesApplication(User $user, Collection $roles, User $cre * @param Collection $subevents * * @throws SettingsItemNotFoundException + * @throws ORMException * @throws OptimisticLockException * @throws ReflectionException * @throws Throwable @@ -885,6 +887,7 @@ private function generateVariableSymbol(): VariableSymbol /** * Vypočítá datum splatnosti podle zvolené metody. * + * @throws ReflectionException * @throws Throwable */ private function countMaturityDate(): DateTimeImmutable|null diff --git a/app/Services/Authenticator.php b/app/Services/Authenticator.php index 0449c20fb..e37d5fa3b 100644 --- a/app/Services/Authenticator.php +++ b/app/Services/Authenticator.php @@ -9,6 +9,7 @@ use App\Model\User\Repositories\UserRepository; use App\Model\User\User; use DateTimeImmutable; +use Doctrine\ORM\ORMException; use Exception; use Nette; use Nette\Caching\Cache; @@ -29,10 +30,10 @@ class Authenticator implements Nette\Security\Authenticator private Cache $userRolesCache; public function __construct( - private readonly UserRepository $userRepository, - private readonly RoleRepository $roleRepository, + private UserRepository $userRepository, + private RoleRepository $roleRepository, protected SkautIsService $skautIsService, - private readonly FilesService $filesService, + private FilesService $filesService, Storage $storage, ) { $this->userRolesCache = new Cache($storage, 'UserRoles'); @@ -41,6 +42,7 @@ public function __construct( /** * Autentizuje uživatele a případně vytvoří nového. * + * @throws ORMException * @throws Exception */ public function authenticate(string $user, string $password): SimpleIdentity @@ -133,13 +135,13 @@ private function updateUserFromSkautIS(User $user, stdClass $skautISUser): void */ public function updateRoles(NS\User $user, Role|null $testedRole = null): void { - $dbUser = $this->userRepository->findById($user->id); + $dbuser = $this->userRepository->findById($user->id); $netteRoles = []; if (! $testedRole) { - if ($dbUser->isApproved()) { - foreach ($dbUser->getRoles() as $role) { + if ($dbuser->isApproved()) { + foreach ($dbuser->getRoles() as $role) { $netteRoles[$role->getId()] = $role->getName(); } } else { diff --git a/app/Services/BankService.php b/app/Services/BankService.php index 514a230f4..73ff9d896 100644 --- a/app/Services/BankService.php +++ b/app/Services/BankService.php @@ -25,11 +25,11 @@ class BankService use Nette\SmartObject; public function __construct( - private readonly CommandBus $commandBus, - private readonly QueryBus $queryBus, - private readonly ApplicationService $applicationService, - private readonly EntityManagerInterface $em, - private readonly PaymentRepository $paymentRepository, + private CommandBus $commandBus, + private QueryBus $queryBus, + private ApplicationService $applicationService, + private EntityManagerInterface $em, + private PaymentRepository $paymentRepository, ) { } diff --git a/app/Services/CmsService.php b/app/Services/CmsService.php index 7e95bb439..180a0c9ac 100644 --- a/app/Services/CmsService.php +++ b/app/Services/CmsService.php @@ -11,8 +11,8 @@ use App\Model\Cms\Repositories\ContentRepository; use App\Model\Cms\Repositories\PageRepository; use Doctrine\ORM\NonUniqueResultException; -use Doctrine\ORM\NoResultException; use Doctrine\ORM\OptimisticLockException; +use Doctrine\ORM\ORMException; use Nette\Caching\Cache; use Nette\Caching\Storage; use Throwable; @@ -28,7 +28,7 @@ class CmsService private Cache $menuCache; - public function __construct(private readonly PageRepository $pageRepository, private readonly ContentRepository $contentRepository, Storage $storage) + public function __construct(private PageRepository $pageRepository, private ContentRepository $contentRepository, Storage $storage) { $this->pageCache = new Cache($storage, 'Page'); $this->menuCache = new Cache($storage, 'Menu'); @@ -38,13 +38,14 @@ public function __construct(private readonly PageRepository $pageRepository, pri * Uloží stránku. * * @throws NonUniqueResultException - * @throws NoResultException + * @throws ORMException + * @throws OptimisticLockException */ public function savePage(Page $page): void { $this->pageRepository->save($page); - $this->pageCache->clean([Cache::Namespaces => ['Page']]); - $this->menuCache->clean([Cache::Namespaces => ['Menu']]); + $this->pageCache->clean([Cache::NAMESPACES => ['Page']]); + $this->menuCache->clean([Cache::NAMESPACES => ['Menu']]); } /** @@ -55,20 +56,21 @@ public function savePage(Page $page): void public function removePage(Page $page): void { $this->pageRepository->remove($page); - $this->pageCache->clean([Cache::Namespaces => ['Page']]); - $this->menuCache->clean([Cache::Namespaces => ['Menu']]); + $this->pageCache->clean([Cache::NAMESPACES => ['Page']]); + $this->menuCache->clean([Cache::NAMESPACES => ['Menu']]); } /** * Přesune stránku mezi stránky s id prevId a nextId. * + * @throws ORMException * @throws OptimisticLockException */ public function sort(int $itemId, int $prevId, int $nextId): void { $this->pageRepository->sort($itemId, $prevId, $nextId); - $this->pageCache->clean([Cache::Namespaces => ['Page']]); - $this->menuCache->clean([Cache::Namespaces => ['Menu']]); + $this->pageCache->clean([Cache::NAMESPACES => ['Page']]); + $this->menuCache->clean([Cache::NAMESPACES => ['Menu']]); } /** @@ -117,8 +119,8 @@ public function findPublishedOrderedByPositionDto(): array public function saveContent(Content $content): void { $this->contentRepository->save($content); - $this->pageCache->clean([Cache::Namespaces => ['Page']]); - $this->menuCache->clean([Cache::Namespaces => ['Menu']]); + $this->pageCache->clean([Cache::NAMESPACES => ['Page']]); + $this->menuCache->clean([Cache::NAMESPACES => ['Menu']]); } /** @@ -127,7 +129,7 @@ public function saveContent(Content $content): void public function removeContent(Content $content): void { $this->contentRepository->remove($content); - $this->pageCache->clean([Cache::Namespaces => ['Page']]); - $this->menuCache->clean([Cache::Namespaces => ['Menu']]); + $this->pageCache->clean([Cache::NAMESPACES => ['Page']]); + $this->menuCache->clean([Cache::NAMESPACES => ['Menu']]); } } diff --git a/app/Services/CommandBus.php b/app/Services/CommandBus.php index 9fde80a94..4791e3533 100644 --- a/app/Services/CommandBus.php +++ b/app/Services/CommandBus.php @@ -8,7 +8,7 @@ final class CommandBus { - public function __construct(private readonly MessageBusInterface $bus) + public function __construct(private MessageBusInterface $bus) { } diff --git a/app/Services/DiscountService.php b/app/Services/DiscountService.php index 95cf5b405..6cb57fa0e 100644 --- a/app/Services/DiscountService.php +++ b/app/Services/DiscountService.php @@ -42,9 +42,9 @@ class DiscountService private array $selectedSubeventsIds; public function __construct( - private readonly DiscountRepository $discountRepository, - private readonly SubeventRepository $subeventRepository, - private readonly Translator $translator, + private DiscountRepository $discountRepository, + private SubeventRepository $subeventRepository, + private Translator $translator, ) { } diff --git a/app/Services/EventBus.php b/app/Services/EventBus.php index 5923fd8ff..052ef0524 100644 --- a/app/Services/EventBus.php +++ b/app/Services/EventBus.php @@ -8,7 +8,7 @@ final class EventBus { - public function __construct(private readonly MessageBusInterface $bus) + public function __construct(private MessageBusInterface $bus) { } diff --git a/app/Services/ExcelExportService.php b/app/Services/ExcelExportService.php index f8291cc50..283689c70 100644 --- a/app/Services/ExcelExportService.php +++ b/app/Services/ExcelExportService.php @@ -23,6 +23,7 @@ use InvalidArgumentException; use Nette; use Nette\Localization\Translator; +use PhpOffice\PhpSpreadsheet\Cell\DataType; use PhpOffice\PhpSpreadsheet\Spreadsheet; use PhpOffice\PhpSpreadsheet\Style\Alignment; use PhpOffice\PhpSpreadsheet\Worksheet\Worksheet; @@ -40,13 +41,13 @@ class ExcelExportService private Spreadsheet $spreadsheet; public function __construct( - private readonly Translator $translator, - private readonly CustomInputRepository $customInputRepository, - private readonly UserService $userService, - private readonly SubeventRepository $subeventRepository, - private readonly CategoryRepository $categoryRepository, - private readonly ProgramRepository $programRepository, - private readonly QueryBus $queryBus, + private Translator $translator, + private CustomInputRepository $customInputRepository, + private UserService $userService, + private SubeventRepository $subeventRepository, + private CategoryRepository $categoryRepository, + private ProgramRepository $programRepository, + private QueryBus $queryBus, ) { $this->spreadsheet = new Spreadsheet(); } @@ -70,7 +71,7 @@ public function exportUsersRoles(Collection $users, Collection $roles, string $f $sheet->getColumnDimensionByColumn($column++)->setWidth(25); foreach ($roles as $role) { - $sheet->setCellValue([$column, $row], $role->getName()); + $sheet->setCellValueByColumnAndRow($column, $row, $role->getName()); $sheet->getColumnDimensionByColumn($column)->setAutoSize(false); $sheet->getColumnDimensionByColumn($column)->setWidth(15); $column++; @@ -80,13 +81,13 @@ public function exportUsersRoles(Collection $users, Collection $roles, string $f $row++; $column = 1; - $sheet->setCellValue([$column, $row], $user->getDisplayName()); + $sheet->setCellValueByColumnAndRow($column, $row, $user->getDisplayName()); foreach ($roles as $role) { $column++; if ($user->isInRole($role)) { - $sheet->setCellValue([$column, $row], 'X'); - $sheet->getStyle([$column, $row])->getAlignment()->setHorizontal(Alignment::HORIZONTAL_CENTER); + $sheet->setCellValueByColumnAndRow($column, $row, 'X'); + $sheet->getStyleByColumnAndRow($column, $row)->getAlignment()->setHorizontal(Alignment::HORIZONTAL_CENTER); } } } @@ -124,28 +125,28 @@ public function exportUsersSchedules(Collection $users, string $filename): Excel $row = 1; $column = 1; - $sheet->setCellValue([$column, $row], $this->translator->translate('common.export.schedule.from')); - $sheet->getStyle([$column, $row])->getFont()->setBold(true); + $sheet->setCellValueByColumnAndRow($column, $row, $this->translator->translate('common.export.schedule.from')); + $sheet->getStyleByColumnAndRow($column, $row)->getFont()->setBold(true); $sheet->getColumnDimensionByColumn($column)->setAutoSize(false); $sheet->getColumnDimensionByColumn($column++)->setWidth(15); - $sheet->setCellValue([$column, $row], $this->translator->translate('common.export.schedule.to')); - $sheet->getStyle([$column, $row])->getFont()->setBold(true); + $sheet->setCellValueByColumnAndRow($column, $row, $this->translator->translate('common.export.schedule.to')); + $sheet->getStyleByColumnAndRow($column, $row)->getFont()->setBold(true); $sheet->getColumnDimensionByColumn($column)->setAutoSize(false); $sheet->getColumnDimensionByColumn($column++)->setWidth(15); - $sheet->setCellValue([$column, $row], $this->translator->translate('common.export.schedule.program_name')); - $sheet->getStyle([$column, $row])->getFont()->setBold(true); + $sheet->setCellValueByColumnAndRow($column, $row, $this->translator->translate('common.export.schedule.program_name')); + $sheet->getStyleByColumnAndRow($column, $row)->getFont()->setBold(true); $sheet->getColumnDimensionByColumn($column)->setAutoSize(false); $sheet->getColumnDimensionByColumn($column++)->setWidth(30); - $sheet->setCellValue([$column, $row], $this->translator->translate('common.export.schedule.room')); - $sheet->getStyle([$column, $row])->getFont()->setBold(true); + $sheet->setCellValueByColumnAndRow($column, $row, $this->translator->translate('common.export.schedule.room')); + $sheet->getStyleByColumnAndRow($column, $row)->getFont()->setBold(true); $sheet->getColumnDimensionByColumn($column)->setAutoSize(false); $sheet->getColumnDimensionByColumn($column++)->setWidth(25); - $sheet->setCellValue([$column, $row], $this->translator->translate('common.export.schedule.lectors')); - $sheet->getStyle([$column, $row])->getFont()->setBold(true); + $sheet->setCellValueByColumnAndRow($column, $row, $this->translator->translate('common.export.schedule.lectors')); + $sheet->getStyleByColumnAndRow($column, $row)->getFont()->setBold(true); $sheet->getColumnDimensionByColumn($column)->setAutoSize(false); $sheet->getColumnDimensionByColumn($column++)->setWidth(25); @@ -155,11 +156,11 @@ public function exportUsersSchedules(Collection $users, string $filename): Excel $row++; $column = 1; - $sheet->setCellValue([$column++, $row], $program->getStart()->format('j. n. H:i')); - $sheet->setCellValue([$column++, $row], $program->getEnd()->format('j. n. H:i')); - $sheet->setCellValue([$column++, $row], $program->getBlock()->getName()); - $sheet->setCellValue([$column++, $row], $program->getRoom() ? $program->getRoom()->getName() : null); - $sheet->setCellValue([$column++, $row], $program->getBlock()->getLectorsText()); + $sheet->setCellValueByColumnAndRow($column++, $row, $program->getStart()->format('j. n. H:i')); + $sheet->setCellValueByColumnAndRow($column++, $row, $program->getEnd()->format('j. n. H:i')); + $sheet->setCellValueByColumnAndRow($column++, $row, $program->getBlock()->getName()); + $sheet->setCellValueByColumnAndRow($column++, $row, $program->getRoom() ? $program->getRoom()->getName() : null); + $sheet->setCellValueByColumnAndRow($column++, $row, $program->getBlock()->getLectorsText()); } } @@ -195,23 +196,23 @@ public function exportRoomsSchedules(Collection $rooms, string $filename): Excel $row = 1; $column = 1; - $sheet->setCellValue([$column, $row], $this->translator->translate('common.export.schedule.from')); - $sheet->getStyle([$column, $row])->getFont()->setBold(true); + $sheet->setCellValueByColumnAndRow($column, $row, $this->translator->translate('common.export.schedule.from')); + $sheet->getStyleByColumnAndRow($column, $row)->getFont()->setBold(true); $sheet->getColumnDimensionByColumn($column)->setAutoSize(false); $sheet->getColumnDimensionByColumn($column++)->setWidth(15); - $sheet->setCellValue([$column, $row], $this->translator->translate('common.export.schedule.to')); - $sheet->getStyle([$column, $row])->getFont()->setBold(true); + $sheet->setCellValueByColumnAndRow($column, $row, $this->translator->translate('common.export.schedule.to')); + $sheet->getStyleByColumnAndRow($column, $row)->getFont()->setBold(true); $sheet->getColumnDimensionByColumn($column)->setAutoSize(false); $sheet->getColumnDimensionByColumn($column++)->setWidth(15); - $sheet->setCellValue([$column, $row], $this->translator->translate('common.export.schedule.program_name')); - $sheet->getStyle([$column, $row])->getFont()->setBold(true); + $sheet->setCellValueByColumnAndRow($column, $row, $this->translator->translate('common.export.schedule.program_name')); + $sheet->getStyleByColumnAndRow($column, $row)->getFont()->setBold(true); $sheet->getColumnDimensionByColumn($column)->setAutoSize(false); $sheet->getColumnDimensionByColumn($column++)->setWidth(30); - $sheet->setCellValue([$column, $row], $this->translator->translate('common.export.schedule.occupancy')); - $sheet->getStyle([$column, $row])->getFont()->setBold(true); + $sheet->setCellValueByColumnAndRow($column, $row, $this->translator->translate('common.export.schedule.occupancy')); + $sheet->getStyleByColumnAndRow($column, $row)->getFont()->setBold(true); $sheet->getColumnDimensionByColumn($column)->setAutoSize(false); $sheet->getColumnDimensionByColumn($column++)->setWidth(15); @@ -219,10 +220,10 @@ public function exportRoomsSchedules(Collection $rooms, string $filename): Excel $row++; $column = 1; - $sheet->setCellValue([$column++, $row], $program->getStart()->format('j. n. H:i')); - $sheet->setCellValue([$column++, $row], $program->getEnd()->format('j. n. H:i')); - $sheet->setCellValue([$column++, $row], $program->getBlock()->getName()); - $sheet->setCellValue([$column++, $row], $room->getCapacity() !== null + $sheet->setCellValueByColumnAndRow($column++, $row, $program->getStart()->format('j. n. H:i')); + $sheet->setCellValueByColumnAndRow($column++, $row, $program->getEnd()->format('j. n. H:i')); + $sheet->setCellValueByColumnAndRow($column++, $row, $program->getBlock()->getName()); + $sheet->setCellValueByColumnAndRow($column++, $row, $room->getCapacity() !== null ? $program->getAttendeesCount() . '/' . $room->getCapacity() : $program->getAttendeesCount()); } @@ -243,88 +244,88 @@ public function exportUsersList(Collection $users, string $filename): ExcelRespo $row = 1; $column = 1; - $sheet->setCellValue([$column, $row], $this->translator->translate('common.export.user.display_name')); - $sheet->getStyle([$column, $row])->getFont()->setBold(true); + $sheet->setCellValueByColumnAndRow($column, $row, $this->translator->translate('common.export.user.display_name')); + $sheet->getStyleByColumnAndRow($column, $row)->getFont()->setBold(true); $sheet->getColumnDimensionByColumn($column)->setAutoSize(false); $sheet->getColumnDimensionByColumn($column++)->setWidth(30); - $sheet->setCellValue([$column, $row], $this->translator->translate('common.export.user.username')); - $sheet->getStyle([$column, $row])->getFont()->setBold(true); + $sheet->setCellValueByColumnAndRow($column, $row, $this->translator->translate('common.export.user.username')); + $sheet->getStyleByColumnAndRow($column, $row)->getFont()->setBold(true); $sheet->getColumnDimensionByColumn($column)->setAutoSize(false); $sheet->getColumnDimensionByColumn($column++)->setWidth(20); - $sheet->setCellValue([$column, $row], $this->translator->translate('common.export.user.roles')); - $sheet->getStyle([$column, $row])->getFont()->setBold(true); + $sheet->setCellValueByColumnAndRow($column, $row, $this->translator->translate('common.export.user.roles')); + $sheet->getStyleByColumnAndRow($column, $row)->getFont()->setBold(true); $sheet->getColumnDimensionByColumn($column)->setAutoSize(false); $sheet->getColumnDimensionByColumn($column++)->setWidth(30); - $sheet->setCellValue([$column, $row], $this->translator->translate('common.export.user.subevents')); - $sheet->getStyle([$column, $row])->getFont()->setBold(true); + $sheet->setCellValueByColumnAndRow($column, $row, $this->translator->translate('common.export.user.subevents')); + $sheet->getStyleByColumnAndRow($column, $row)->getFont()->setBold(true); $sheet->getColumnDimensionByColumn($column)->setAutoSize(false); $sheet->getColumnDimensionByColumn($column++)->setWidth(30); - $sheet->setCellValue([$column, $row], $this->translator->translate('common.export.user.approved')); - $sheet->getStyle([$column, $row])->getFont()->setBold(true); + $sheet->setCellValueByColumnAndRow($column, $row, $this->translator->translate('common.export.user.approved')); + $sheet->getStyleByColumnAndRow($column, $row)->getFont()->setBold(true); $sheet->getColumnDimensionByColumn($column)->setAutoSize(false); $sheet->getColumnDimensionByColumn($column++)->setWidth(10); - $sheet->setCellValue([$column, $row], $this->translator->translate('common.export.user.membership')); - $sheet->getStyle([$column, $row])->getFont()->setBold(true); + $sheet->setCellValueByColumnAndRow($column, $row, $this->translator->translate('common.export.user.membership')); + $sheet->getStyleByColumnAndRow($column, $row)->getFont()->setBold(true); $sheet->getColumnDimensionByColumn($column)->setAutoSize(false); $sheet->getColumnDimensionByColumn($column++)->setWidth(20); - $sheet->setCellValue([$column, $row], $this->translator->translate('common.export.user.age')); - $sheet->getStyle([$column, $row])->getFont()->setBold(true); + $sheet->setCellValueByColumnAndRow($column, $row, $this->translator->translate('common.export.user.age')); + $sheet->getStyleByColumnAndRow($column, $row)->getFont()->setBold(true); $sheet->getColumnDimensionByColumn($column)->setAutoSize(false); $sheet->getColumnDimensionByColumn($column++)->setWidth(10); - $sheet->setCellValue([$column, $row], $this->translator->translate('common.export.user.email')); - $sheet->getStyle([$column, $row])->getFont()->setBold(true); + $sheet->setCellValueByColumnAndRow($column, $row, $this->translator->translate('common.export.user.email')); + $sheet->getStyleByColumnAndRow($column, $row)->getFont()->setBold(true); $sheet->getColumnDimensionByColumn($column)->setAutoSize(false); $sheet->getColumnDimensionByColumn($column++)->setWidth(30); - $sheet->setCellValue([$column, $row], $this->translator->translate('common.export.user.phone')); - $sheet->getStyle([$column, $row])->getFont()->setBold(true); + $sheet->setCellValueByColumnAndRow($column, $row, $this->translator->translate('common.export.user.phone')); + $sheet->getStyleByColumnAndRow($column, $row)->getFont()->setBold(true); $sheet->getColumnDimensionByColumn($column)->setAutoSize(false); $sheet->getColumnDimensionByColumn($column++)->setWidth(15); - $sheet->setCellValue([$column, $row], $this->translator->translate('common.export.user.city')); - $sheet->getStyle([$column, $row])->getFont()->setBold(true); + $sheet->setCellValueByColumnAndRow($column, $row, $this->translator->translate('common.export.user.city')); + $sheet->getStyleByColumnAndRow($column, $row)->getFont()->setBold(true); $sheet->getColumnDimensionByColumn($column)->setAutoSize(false); $sheet->getColumnDimensionByColumn($column++)->setWidth(20); - $sheet->setCellValue([$column, $row], $this->translator->translate('common.export.user.fee')); - $sheet->getStyle([$column, $row])->getFont()->setBold(true); + $sheet->setCellValueByColumnAndRow($column, $row, $this->translator->translate('common.export.user.fee')); + $sheet->getStyleByColumnAndRow($column, $row)->getFont()->setBold(true); $sheet->getColumnDimensionByColumn($column)->setAutoSize(false); $sheet->getColumnDimensionByColumn($column++)->setWidth(15); - $sheet->setCellValue([$column, $row], $this->translator->translate('common.export.user.fee_remaining')); - $sheet->getStyle([$column, $row])->getFont()->setBold(true); + $sheet->setCellValueByColumnAndRow($column, $row, $this->translator->translate('common.export.user.fee_remaining')); + $sheet->getStyleByColumnAndRow($column, $row)->getFont()->setBold(true); $sheet->getColumnDimensionByColumn($column)->setAutoSize(false); $sheet->getColumnDimensionByColumn($column++)->setWidth(15); - $sheet->setCellValue([$column, $row], $this->translator->translate('common.export.user.variable_symbol')); - $sheet->getStyle([$column, $row])->getFont()->setBold(true); + $sheet->setCellValueByColumnAndRow($column, $row, $this->translator->translate('common.export.user.variable_symbol')); + $sheet->getStyleByColumnAndRow($column, $row)->getFont()->setBold(true); $sheet->getColumnDimensionByColumn($column)->setAutoSize(false); $sheet->getColumnDimensionByColumn($column++)->setWidth(25); - $sheet->setCellValue([$column, $row], $this->translator->translate('common.export.user.payment_method')); - $sheet->getStyle([$column, $row])->getFont()->setBold(true); + $sheet->setCellValueByColumnAndRow($column, $row, $this->translator->translate('common.export.user.payment_method')); + $sheet->getStyleByColumnAndRow($column, $row)->getFont()->setBold(true); $sheet->getColumnDimensionByColumn($column)->setAutoSize(false); $sheet->getColumnDimensionByColumn($column++)->setWidth(15); - $sheet->setCellValue([$column, $row], $this->translator->translate('common.export.user.payment_date')); - $sheet->getStyle([$column, $row])->getFont()->setBold(true); + $sheet->setCellValueByColumnAndRow($column, $row, $this->translator->translate('common.export.user.payment_date')); + $sheet->getStyleByColumnAndRow($column, $row)->getFont()->setBold(true); $sheet->getColumnDimensionByColumn($column)->setAutoSize(false); $sheet->getColumnDimensionByColumn($column++)->setWidth(20); - $sheet->setCellValue([$column, $row], $this->translator->translate('common.export.user.first_application_date')); - $sheet->getStyle([$column, $row])->getFont()->setBold(true); + $sheet->setCellValueByColumnAndRow($column, $row, $this->translator->translate('common.export.user.first_application_date')); + $sheet->getStyleByColumnAndRow($column, $row)->getFont()->setBold(true); $sheet->getColumnDimensionByColumn($column)->setAutoSize(false); $sheet->getColumnDimensionByColumn($column++)->setWidth(20); - $sheet->setCellValue([$column, $row], $this->translator->translate('common.export.user.attended')); - $sheet->getStyle([$column, $row])->getFont()->setBold(true); + $sheet->setCellValueByColumnAndRow($column, $row, $this->translator->translate('common.export.user.attended')); + $sheet->getStyleByColumnAndRow($column, $row)->getFont()->setBold(true); $sheet->getColumnDimensionByColumn($column)->setAutoSize(false); $sheet->getColumnDimensionByColumn($column++)->setWidth(10); @@ -352,14 +353,14 @@ public function exportUsersList(Collection $users, string $filename): ExcelRespo throw new InvalidArgumentException(); } - $sheet->setCellValue([$column, $row], $this->translator->translate($customInput->getName())); - $sheet->getStyle([$column, $row])->getFont()->setBold(true); + $sheet->setCellValueByColumnAndRow($column, $row, $this->translator->translate($customInput->getName())); + $sheet->getStyleByColumnAndRow($column, $row)->getFont()->setBold(true); $sheet->getColumnDimensionByColumn($column)->setAutoSize(false); $sheet->getColumnDimensionByColumn($column++)->setWidth($width); } - $sheet->setCellValue([$column, $row], $this->translator->translate('common.export.user.private_note')); - $sheet->getStyle([$column, $row])->getFont()->setBold(true); + $sheet->setCellValueByColumnAndRow($column, $row, $this->translator->translate('common.export.user.private_note')); + $sheet->getStyleByColumnAndRow($column, $row)->getFont()->setBold(true); $sheet->getColumnDimensionByColumn($column)->setAutoSize(false); $sheet->getColumnDimensionByColumn($column++)->setWidth(60); @@ -367,41 +368,43 @@ public function exportUsersList(Collection $users, string $filename): ExcelRespo $row++; $column = 1; - $sheet->setCellValue([$column++, $row], $user->getDisplayName()); + $sheet->setCellValueByColumnAndRow($column++, $row, $user->getDisplayName()); - $sheet->setCellValue([$column++, $row], $user->getUsername()); + $sheet->setCellValueByColumnAndRow($column++, $row, $user->getUsername()); - $sheet->setCellValue([$column++, $row], $user->getRolesText()); + $sheet->setCellValueByColumnAndRow($column++, $row, $user->getRolesText()); - $sheet->setCellValue([$column++, $row], $user->getSubeventsText()); + $sheet->setCellValueByColumnAndRow($column++, $row, $user->getSubeventsText()); - $sheet->setCellValue([$column++, $row], $user->isApproved() + $sheet->setCellValueByColumnAndRow($column++, $row, $user->isApproved() ? $this->translator->translate('common.export.common.yes') : $this->translator->translate('common.export.common.no')); - $sheet->getCell([$column++, $row])->setValueExplicit($this->userService->getMembershipText($user)); + $sheet->getCellByColumnAndRow($column++, $row) + ->setValueExplicit($this->userService->getMembershipText($user), DataType::TYPE_STRING); - $sheet->setCellValue([$column++, $row], $user->getAge()); + $sheet->setCellValueByColumnAndRow($column++, $row, $user->getAge()); - $sheet->setCellValue([$column++, $row], $user->getEmail()); + $sheet->setCellValueByColumnAndRow($column++, $row, $user->getEmail()); - $sheet->getCell([$column++, $row])->setValueExplicit($user->getPhone()); + $sheet->setCellValueByColumnAndRow($column++, $row, $user->getPhone()); - $sheet->setCellValue([$column++, $row], $user->getCity()); + $sheet->setCellValueByColumnAndRow($column++, $row, $user->getCity()); - $sheet->setCellValue([$column++, $row], $user->getFee()); + $sheet->setCellValueByColumnAndRow($column++, $row, $user->getFee()); - $sheet->setCellValue([$column++, $row], $user->getFeeRemaining()); + $sheet->setCellValueByColumnAndRow($column++, $row, $user->getFeeRemaining()); - $sheet->getCell([$column++, $row])->setValueExplicit($user->getVariableSymbolsText()); + $sheet->getCellByColumnAndRow($column++, $row) + ->setValueExplicit($user->getVariableSymbolsText(), DataType::TYPE_STRING); - $sheet->setCellValue([$column++, $row], $user->getPaymentMethod() ? $this->translator->translate('common.payment.' . $user->getPaymentMethod()) : ''); + $sheet->setCellValueByColumnAndRow($column++, $row, $user->getPaymentMethod() ? $this->translator->translate('common.payment.' . $user->getPaymentMethod()) : ''); - $sheet->setCellValue([$column++, $row], $user->getLastPaymentDate()?->format(Helpers::DATE_FORMAT) ?? ''); + $sheet->setCellValueByColumnAndRow($column++, $row, $user->getLastPaymentDate()?->format(Helpers::DATE_FORMAT) ?? ''); - $sheet->setCellValue([$column++, $row], $user->getRolesApplicationDate()?->format(Helpers::DATE_FORMAT) ?? ''); + $sheet->setCellValueByColumnAndRow($column++, $row, $user->getRolesApplicationDate()?->format(Helpers::DATE_FORMAT) ?? ''); - $sheet->setCellValue([$column++, $row], $user->isAttended() + $sheet->setCellValueByColumnAndRow($column++, $row, $user->isAttended() ? $this->translator->translate('common.export.common.yes') : $this->translator->translate('common.export.common.no')); @@ -421,11 +424,11 @@ public function exportUsersList(Collection $users, string $filename): ExcelRespo $value = $customInputValue->getValueText(); } - $sheet->setCellValue([$column++, $row], $value); + $sheet->setCellValueByColumnAndRow($column++, $row, $value); } - $sheet->setCellValue([$column, $row], $user->getNote()); - $sheet->getStyle([$column++, $row])->getAlignment()->setWrapText(true); + $sheet->setCellValueByColumnAndRow($column, $row, $user->getNote()); + $sheet->getStyleByColumnAndRow($column++, $row)->getAlignment()->setWrapText(true); } return new ExcelResponse($this->spreadsheet, $filename); @@ -443,41 +446,41 @@ public function exportUsersSubeventsAndCategories(Collection $users, string $fil $row = 1; $column = 1; - $sheet->setCellValue([$column, $row], $this->translator->translate('common.export.user.variable_symbol')); - $sheet->getStyle([$column, $row])->getFont()->setBold(true); + $sheet->setCellValueByColumnAndRow($column, $row, $this->translator->translate('common.export.user.variable_symbol')); + $sheet->getStyleByColumnAndRow($column, $row)->getFont()->setBold(true); $sheet->getColumnDimensionByColumn($column)->setAutoSize(false); $sheet->getColumnDimensionByColumn($column++)->setWidth(20); - $sheet->setCellValue([$column, $row], $this->translator->translate('common.export.user.first_name')); - $sheet->getStyle([$column, $row])->getFont()->setBold(true); + $sheet->setCellValueByColumnAndRow($column, $row, $this->translator->translate('common.export.user.first_name')); + $sheet->getStyleByColumnAndRow($column, $row)->getFont()->setBold(true); $sheet->getColumnDimensionByColumn($column)->setAutoSize(false); $sheet->getColumnDimensionByColumn($column++)->setWidth(20); - $sheet->setCellValue([$column, $row], $this->translator->translate('common.export.user.last_name')); - $sheet->getStyle([$column, $row])->getFont()->setBold(true); + $sheet->setCellValueByColumnAndRow($column, $row, $this->translator->translate('common.export.user.last_name')); + $sheet->getStyleByColumnAndRow($column, $row)->getFont()->setBold(true); $sheet->getColumnDimensionByColumn($column)->setAutoSize(false); $sheet->getColumnDimensionByColumn($column++)->setWidth(20); - $sheet->setCellValue([$column, $row], $this->translator->translate('common.export.user.nickname')); - $sheet->getStyle([$column, $row])->getFont()->setBold(true); + $sheet->setCellValueByColumnAndRow($column, $row, $this->translator->translate('common.export.user.nickname')); + $sheet->getStyleByColumnAndRow($column, $row)->getFont()->setBold(true); $sheet->getColumnDimensionByColumn($column)->setAutoSize(false); $sheet->getColumnDimensionByColumn($column++)->setWidth(20); foreach ($this->subeventRepository->findFilteredSubevents(true, false, false, false) as $subevent) { - $sheet->setCellValue([$column, $row], $subevent->getName()); - $sheet->getStyle([$column, $row])->getFont()->setBold(true); + $sheet->setCellValueByColumnAndRow($column, $row, $subevent->getName()); + $sheet->getStyleByColumnAndRow($column, $row)->getFont()->setBold(true); $sheet->getColumnDimensionByColumn($column)->setAutoSize(false); $sheet->getColumnDimensionByColumn($column++)->setWidth(10); } foreach ($this->categoryRepository->findAll() as $category) { - $sheet->setCellValue([$column, $row], $category->getName() . ' - ' . $this->translator->translate('common.export.schedule.program_name')); - $sheet->getStyle([$column, $row])->getFont()->setBold(true); + $sheet->setCellValueByColumnAndRow($column, $row, $category->getName() . ' - ' . $this->translator->translate('common.export.schedule.program_name')); + $sheet->getStyleByColumnAndRow($column, $row)->getFont()->setBold(true); $sheet->getColumnDimensionByColumn($column)->setAutoSize(false); $sheet->getColumnDimensionByColumn($column++)->setWidth(20); - $sheet->setCellValue([$column, $row], $category->getName() . ' - ' . $this->translator->translate('common.export.schedule.room')); - $sheet->getStyle([$column, $row])->getFont()->setBold(true); + $sheet->setCellValueByColumnAndRow($column, $row, $category->getName() . ' - ' . $this->translator->translate('common.export.schedule.room')); + $sheet->getStyleByColumnAndRow($column, $row)->getFont()->setBold(true); $sheet->getColumnDimensionByColumn($column)->setAutoSize(false); $sheet->getColumnDimensionByColumn($column++)->setWidth(10); } @@ -486,17 +489,17 @@ public function exportUsersSubeventsAndCategories(Collection $users, string $fil $row++; $column = 1; - $sheet->getCell([$column++, $row]) - ->setValueExplicit($user->getVariableSymbolsText()); + $sheet->getCellByColumnAndRow($column++, $row) + ->setValueExplicit($user->getVariableSymbolsText(), DataType::TYPE_STRING); - $sheet->setCellValue([$column++, $row], $user->getFirstName()); + $sheet->setCellValueByColumnAndRow($column++, $row, $user->getFirstName()); - $sheet->setCellValue([$column++, $row], $user->getLastName()); + $sheet->setCellValueByColumnAndRow($column++, $row, $user->getLastName()); - $sheet->setCellValue([$column++, $row], $user->getNickname()); + $sheet->setCellValueByColumnAndRow($column++, $row, $user->getNickname()); foreach ($this->subeventRepository->findFilteredSubevents(true, false, false, false) as $subevent) { - $sheet->setCellValue([$column++, $row], $user->hasSubevent($subevent) + $sheet->setCellValueByColumnAndRow($column++, $row, $user->hasSubevent($subevent) ? $this->translator->translate('common.export.common.yes') : $this->translator->translate('common.export.common.no')); } @@ -509,8 +512,8 @@ public function exportUsersSubeventsAndCategories(Collection $users, string $fil $rooms[] = $program->getRoom() ? $program->getRoom()->getName() : ''; } - $sheet->setCellValue([$column++, $row], implode(', ', $blocks)); - $sheet->setCellValue([$column++, $row], implode(', ', $rooms)); + $sheet->setCellValueByColumnAndRow($column++, $row, implode(', ', $blocks)); + $sheet->setCellValueByColumnAndRow($column++, $row, implode(', ', $rooms)); } } @@ -534,23 +537,23 @@ public function exportBlocksAttendees(Collection $blocks, string $filename): Exc $row = 1; $column = 1; - $sheet->setCellValue([$column, $row], $this->translator->translate('common.export.user.display_name')); - $sheet->getStyle([$column, $row])->getFont()->setBold(true); + $sheet->setCellValueByColumnAndRow($column, $row, $this->translator->translate('common.export.user.display_name')); + $sheet->getStyleByColumnAndRow($column, $row)->getFont()->setBold(true); $sheet->getColumnDimensionByColumn($column)->setAutoSize(false); $sheet->getColumnDimensionByColumn($column++)->setWidth(30); - $sheet->setCellValue([$column, $row], $this->translator->translate('common.export.user.email')); - $sheet->getStyle([$column, $row])->getFont()->setBold(true); + $sheet->setCellValueByColumnAndRow($column, $row, $this->translator->translate('common.export.user.email')); + $sheet->getStyleByColumnAndRow($column, $row)->getFont()->setBold(true); $sheet->getColumnDimensionByColumn($column)->setAutoSize(false); $sheet->getColumnDimensionByColumn($column++)->setWidth(30); - $sheet->setCellValue([$column, $row], $this->translator->translate('common.export.user.phone')); - $sheet->getStyle([$column, $row])->getFont()->setBold(true); + $sheet->setCellValueByColumnAndRow($column, $row, $this->translator->translate('common.export.user.phone')); + $sheet->getStyleByColumnAndRow($column, $row)->getFont()->setBold(true); $sheet->getColumnDimensionByColumn($column)->setAutoSize(false); $sheet->getColumnDimensionByColumn($column++)->setWidth(15); - $sheet->setCellValue([$column, $row], $this->translator->translate('common.export.user.address')); - $sheet->getStyle([$column, $row])->getFont()->setBold(true); + $sheet->setCellValueByColumnAndRow($column, $row, $this->translator->translate('common.export.user.address')); + $sheet->getStyleByColumnAndRow($column, $row)->getFont()->setBold(true); $sheet->getColumnDimensionByColumn($column)->setAutoSize(false); $sheet->getColumnDimensionByColumn($column++)->setWidth(40); @@ -560,10 +563,10 @@ public function exportBlocksAttendees(Collection $blocks, string $filename): Exc $row++; $column = 1; - $sheet->setCellValue([$column++, $row], $attendee->getDisplayName()); - $sheet->setCellValue([$column++, $row], $attendee->getEmail()); - $sheet->getCell([$column++, $row])->setValueExplicit($attendee->getPhone()); - $sheet->setCellValue([$column++, $row], $attendee->getAddress()); + $sheet->setCellValueByColumnAndRow($column++, $row, $attendee->getDisplayName()); + $sheet->setCellValueByColumnAndRow($column++, $row, $attendee->getEmail()); + $sheet->setCellValueByColumnAndRow($column++, $row, $attendee->getPhone()); + $sheet->setCellValueByColumnAndRow($column++, $row, $attendee->getAddress()); } } diff --git a/app/Services/ExcelResponse.php b/app/Services/ExcelResponse.php index 946971c72..f9be3f942 100644 --- a/app/Services/ExcelResponse.php +++ b/app/Services/ExcelResponse.php @@ -17,7 +17,7 @@ class ExcelResponse implements Response { use Nette\SmartObject; - public function __construct(private readonly Spreadsheet $spreadsheet, private readonly string $filename) + public function __construct(private Spreadsheet $spreadsheet, private string $filename) { } diff --git a/app/Services/FilesService.php b/app/Services/FilesService.php index 5b0c4e8e7..85ed4ff59 100644 --- a/app/Services/FilesService.php +++ b/app/Services/FilesService.php @@ -25,7 +25,7 @@ class FilesService { use Nette\SmartObject; - public function __construct(private readonly string $dir) + public function __construct(private string $dir) { } diff --git a/app/Services/IMailService.php b/app/Services/IMailService.php new file mode 100644 index 000000000..006bf5a97 --- /dev/null +++ b/app/Services/IMailService.php @@ -0,0 +1,32 @@ +|null $recipientsRoles + * @param Collection|null $recipientsSubevents + * @param Collection|null $recipientsUsers + * @param Collection|null $recipientEmails + */ + public function sendMail(Collection|null $recipientsRoles, Collection|null $recipientsSubevents, Collection|null $recipientsUsers, Collection|null $recipientEmails, string $subject, string $text, bool $automatic = false): void; + + /** + * Rozešle e-mail podle šablony. + * + * @param Collection|null $recipientsUsers + * @param Collection|null $recipientsEmails + * @param string[] $parameters + */ + public function sendMailFromTemplate(Collection|null $recipientsUsers, Collection|null $recipientsEmails, string $type, array $parameters): void; +} diff --git a/app/Services/IcalResponse.php b/app/Services/IcalResponse.php index 4fed49c52..2845c1a01 100644 --- a/app/Services/IcalResponse.php +++ b/app/Services/IcalResponse.php @@ -16,7 +16,7 @@ class IcalResponse implements Response { use Nette\SmartObject; - public function __construct(private readonly Calendar $calendar, private readonly string $filename) + public function __construct(private Calendar $calendar, private string $filename) { } diff --git a/app/Services/MailService.php b/app/Services/MailService.php new file mode 100644 index 000000000..468926950 --- /dev/null +++ b/app/Services/MailService.php @@ -0,0 +1,163 @@ +|null $recipientsRoles + * @param Collection|null $recipientsSubevents + * @param Collection|null $recipientsUsers + * @param Collection|null $recipientEmails + * + * @throws Throwable + * @throws MailingMailCreationException + */ + public function sendMail(Collection|null $recipientsRoles, Collection|null $recipientsSubevents, Collection|null $recipientsUsers, Collection|null $recipientEmails, string $subject, string $text, bool $automatic = false): void + { + $recipients = []; + + if ($recipientsRoles !== null) { + foreach ($this->userRepository->findAllApprovedInRoles($this->roleRepository->findRolesIds($recipientsRoles)) as $user) { + $recipient = Recipient::createFromUser($user); + if (! in_array($recipient, $recipients)) { + $recipients[] = $recipient; + } + } + } + + if ($recipientsSubevents !== null) { + foreach ($this->userRepository->findAllWithSubevents($this->subeventRepository->findSubeventsIds($recipientsSubevents)) as $user) { + $recipient = Recipient::createFromUser($user); + if (! in_array($recipient, $recipients)) { + $recipients[] = $recipient; + } + } + } + + if ($recipientsUsers !== null) { + foreach ($recipientsUsers as $user) { + $recipient = Recipient::createFromUser($user); + if (! in_array($recipient, $recipients)) { + $recipients[] = $recipient; + } + } + } + + if ($recipientEmails !== null) { + foreach ($recipientEmails as $email) { + $recipient = new Recipient($email); + if (! in_array($recipient, $recipients)) { + $recipients[] = $recipient; + } + } + } + + $from = new Recipient($this->queryBus->handle(new SettingStringValueQuery(Settings::SEMINAR_EMAIL)), $this->queryBus->handle(new SettingStringValueQuery(Settings::SEMINAR_NAME))); + + $messageData = new SrsMailData($from, $recipients, $subject, $text); + $mail = $this->mailFactory->createByType(SrsMail::class, $messageData); + $mail->send(); + + $mailLog = new Mail(); + + if ($recipientsRoles !== null) { + $mailLog->setRecipientRoles($recipientsRoles); + } + + if ($recipientsSubevents !== null) { + $mailLog->setRecipientSubevents($recipientsSubevents); + } + + if ($recipientsUsers !== null) { + $mailLog->setRecipientUsers($recipientsUsers); + } + + $mailLog->setSubject($subject); + $mailLog->setText($text); + $mailLog->setDatetime(new DateTimeImmutable()); + $mailLog->setAutomatic($automatic); + $this->mailRepository->save($mailLog); + } + + /** + * Rozešle e-mail podle šablony. + * + * @param Collection|null $recipientsUsers + * @param Collection|null $recipientsEmails + * @param string[] $parameters + * + * @throws MailingMailCreationException + * @throws SettingsItemNotFoundException + * @throws Throwable + */ + public function sendMailFromTemplate(Collection|null $recipientsUsers, Collection|null $recipientsEmails, string $type, array $parameters): void + { + $template = $this->templateRepository->findByType($type); + + if (! $template->isActive()) { + return; + } + + $subject = $template->getSubject(); + $text = $template->getText(); + + foreach ($template->getVariables() as $variable) { + $variableName = '%' . $this->translator->translate('common.mailing.variable_name.' . $variable->getName()) . '%'; + $value = $parameters[$variable->getName()]; + + $subject = str_replace($variableName, strval($value), $subject); + $text = str_replace($variableName, strval($value), $text); + } + + $this->sendMail(null, null, $recipientsUsers, $recipientsEmails, $subject, $text, true); + } +} diff --git a/app/Services/QueryBus.php b/app/Services/QueryBus.php index 7675dfaf0..18fb40bb1 100644 --- a/app/Services/QueryBus.php +++ b/app/Services/QueryBus.php @@ -11,7 +11,7 @@ final class QueryBus { - public function __construct(private readonly MessageBusInterface $bus) + public function __construct(private MessageBusInterface $bus) { } diff --git a/app/Services/SkautIsEventEducationService.php b/app/Services/SkautIsEventEducationService.php index 07a40ac1f..b58baf534 100644 --- a/app/Services/SkautIsEventEducationService.php +++ b/app/Services/SkautIsEventEducationService.php @@ -25,8 +25,8 @@ class SkautIsEventEducationService extends SkautIsEventService { public function __construct( Skautis $skautIs, - private readonly SkautIsCourseRepository $skautIsCourseRepository, - private readonly SubeventRepository $subeventRepository, + private SkautIsCourseRepository $skautIsCourseRepository, + private SubeventRepository $subeventRepository, ) { parent::__construct($skautIs); } diff --git a/app/Services/SkautIsService.php b/app/Services/SkautIsService.php index 05ac85713..ba6a56fdd 100644 --- a/app/Services/SkautIsService.php +++ b/app/Services/SkautIsService.php @@ -21,7 +21,7 @@ class SkautIsService private Cache $userRolesCache; - public function __construct(private readonly Skautis $skautIs, Storage $storage) + public function __construct(private Skautis $skautIs, Storage $storage) { $this->userRolesCache = new Cache($storage, 'UserRoles'); } diff --git a/app/Services/SubeventService.php b/app/Services/SubeventService.php index 2d44e5902..1a0b59893 100644 --- a/app/Services/SubeventService.php +++ b/app/Services/SubeventService.php @@ -16,7 +16,7 @@ class SubeventService { use Nette\SmartObject; - public function __construct(private readonly SubeventRepository $subeventRepository, private readonly Translator $translator) + public function __construct(private SubeventRepository $subeventRepository, private Translator $translator) { } diff --git a/app/Services/UserService.php b/app/Services/UserService.php index 4cd37bd45..c8bac01ba 100644 --- a/app/Services/UserService.php +++ b/app/Services/UserService.php @@ -5,7 +5,6 @@ namespace App\Services; use App\Model\Enums\PaymentType; -use App\Model\Mailing\Commands\CreateTemplateMail; use App\Model\Mailing\Template; use App\Model\Mailing\TemplateVariable; use App\Model\Settings\Queries\SettingStringValueQuery; @@ -26,12 +25,12 @@ class UserService use Nette\SmartObject; public function __construct( - private readonly CommandBus $commandBus, - private readonly QueryBus $queryBus, - private readonly EventBus $eventBus, - private readonly Translator $translator, - private readonly UserRepository $userRepository, - private readonly EntityManagerInterface $em, + private QueryBus $queryBus, + private EventBus $eventBus, + private Translator $translator, + private UserRepository $userRepository, + private MailService $mailService, + private EntityManagerInterface $em, ) { } @@ -93,9 +92,9 @@ public function setApproved(User $user, bool $approved): void $this->eventBus->handle(new UserUpdatedEvent($user, $approvedOld)); if ($approved) { - $this->commandBus->handle(new CreateTemplateMail(new ArrayCollection([$user]), null, Template::REGISTRATION_APPROVED, [ + $this->mailService->sendMailFromTemplate(new ArrayCollection([$user]), null, Template::REGISTRATION_APPROVED, [ TemplateVariable::SEMINAR_NAME => $this->queryBus->handle(new SettingStringValueQuery(Settings::SEMINAR_NAME)), - ])); + ]); } }); } diff --git a/app/Utils/Validators.php b/app/Utils/Validators.php index 680efbcdd..5557aa519 100644 --- a/app/Utils/Validators.php +++ b/app/Utils/Validators.php @@ -16,7 +16,6 @@ use App\Model\User\User; use App\Services\QueryBus; use Doctrine\Common\Collections\Collection; -use Exception; use Throwable; use function array_map; @@ -29,9 +28,9 @@ class Validators { public function __construct( - private readonly QueryBus $queryBus, - private readonly RoleRepository $roleRepository, - private readonly ProgramRepository $programRepository, + private QueryBus $queryBus, + private RoleRepository $roleRepository, + private ProgramRepository $programRepository, ) { } @@ -223,8 +222,6 @@ public function validateSubeventsRegistered( /** * Ověří, zda může být program automaticky přihlašovaný. - * - * @throws Exception */ public function validateBlockAutoRegistered(Block $block, int|null $capacity): bool { diff --git a/app/WebModule/Components/ApplicationContentControl.php b/app/WebModule/Components/ApplicationContentControl.php index 1eae072d4..9c6c39870 100644 --- a/app/WebModule/Components/ApplicationContentControl.php +++ b/app/WebModule/Components/ApplicationContentControl.php @@ -12,28 +12,27 @@ use App\Model\Settings\Queries\SettingStringValueQuery; use App\Model\Settings\Settings; use App\Model\Structure\Repositories\SubeventRepository; +use App\Model\User\Repositories\UserRepository; use App\Services\Authenticator; use App\Services\QueryBus; use App\WebModule\Forms\ApplicationFormFactory; -use App\WebModule\Presenters\WebBasePresenter; use Doctrine\ORM\NonUniqueResultException; use Nette\Application\UI\Form; use stdClass; use Throwable; -use function assert; - /** - * Komponenta obsahu s přihláškou. + * Komponenta s přihláškou. */ class ApplicationContentControl extends BaseContentControl { public function __construct( - private readonly QueryBus $queryBus, - private readonly ApplicationFormFactory $applicationFormFactory, - private readonly Authenticator $authenticator, - private readonly RoleRepository $roleRepository, - private readonly SubeventRepository $subeventRepository, + private QueryBus $queryBus, + private ApplicationFormFactory $applicationFormFactory, + private Authenticator $authenticator, + private UserRepository $userRepository, + private RoleRepository $roleRepository, + private SubeventRepository $subeventRepository, public IApplicationsGridControlFactory $applicationsGridControlFactory, public CustomInputRepository $customInputRepository, ) { @@ -52,20 +51,17 @@ public function render(ContentDto|null $content = null): void $template->heading = $content->getHeading(); } - $presenter = $this->getPresenter(); - assert($presenter instanceof WebBasePresenter); - - $template->backlink = $presenter->getHttpRequest()->getUrl()->getPath(); + $template->backlink = $this->getPresenter()->getHttpRequest()->getUrl()->getPath(); - $user = $presenter->getUser(); + $user = $this->getPresenter()->user; $template->guestRole = $user->isInRole($this->roleRepository->findBySystemName(Role::GUEST)->getName()); $template->testRole = Role::TEST; $explicitSubeventsExists = $this->subeventRepository->explicitSubeventsExists(); if ($user->isLoggedIn()) { - $dbUser = $presenter->getDbUser(); - $userHasFixedFeeRole = $dbUser->hasFixedFeeRole(); + $dbuser = $this->userRepository->findById($user->id); + $userHasFixedFeeRole = $dbuser->hasFixedFeeRole(); $template->unapprovedRole = $user->isInRole($this->roleRepository->findBySystemName(Role::UNAPPROVED)->getName()); $template->nonregisteredRole = $user->isInRole($this->roleRepository->findBySystemName(Role::NONREGISTERED)->getName()); @@ -73,14 +69,14 @@ public function render(ContentDto|null $content = null): void $template->registrationStart = $this->roleRepository->getRegistrationStart(); $template->registrationEnd = $this->roleRepository->getRegistrationEnd(); $template->bankAccount = $this->queryBus->handle(new SettingStringValueQuery(Settings::ACCOUNT_NUMBER)); - $template->dbUser = $dbUser; + $template->dbuser = $dbuser; $template->userHasFixedFeeRole = $userHasFixedFeeRole; $template->usersApplications = $explicitSubeventsExists && $userHasFixedFeeRole - ? $dbUser->getNotCanceledApplications() + ? $dbuser->getNotCanceledApplications() : ($explicitSubeventsExists - ? $dbUser->getNotCanceledSubeventsApplications() - : $dbUser->getNotCanceledRolesApplications() + ? $dbuser->getNotCanceledSubeventsApplications() + : $dbuser->getNotCanceledRolesApplications() ); } @@ -103,21 +99,18 @@ public function renderScripts(): void */ protected function createComponentApplicationForm(): Form { - $p = $this->getPresenter(); - assert($p instanceof WebBasePresenter); - - $form = $this->applicationFormFactory->create($p->getDbUser()); + $form = $this->applicationFormFactory->create($this->getPresenter()->user->id); - $form->onSuccess[] = function (Form $form, stdClass $values) use ($p): void { - $p->flashMessage('web.application_content.register_successful', 'success'); + $form->onSuccess[] = function (Form $form, stdClass $values): void { + $this->getPresenter()->flashMessage('web.application_content.register_successful', 'success'); - $this->authenticator->updateRoles($p->getUser()); + $this->authenticator->updateRoles($this->getPresenter()->user); - $p->redirect('this'); + $this->getPresenter()->redirect('this'); }; - $this->applicationFormFactory->onSkautIsError[] = static function () use ($p): void { - $p->flashMessage('web.application_content.register_synchronization_failed', 'danger'); + $this->applicationFormFactory->onSkautIsError[] = function (): void { + $this->getPresenter()->flashMessage('web.application_content.register_synchronization_failed', 'danger'); }; return $form; diff --git a/app/WebModule/Components/ApplicationsGridControl.php b/app/WebModule/Components/ApplicationsGridControl.php index 082522d1d..b927cc24b 100644 --- a/app/WebModule/Components/ApplicationsGridControl.php +++ b/app/WebModule/Components/ApplicationsGridControl.php @@ -15,16 +15,15 @@ use App\Model\Settings\Queries\SettingStringValueQuery; use App\Model\Settings\Settings; use App\Model\Structure\Repositories\SubeventRepository; +use App\Model\User\Repositories\UserRepository; use App\Model\User\User; use App\Services\ApplicationService; use App\Services\QueryBus; use App\Services\SubeventService; use App\Utils\Helpers; use App\Utils\Validators; -use App\WebModule\Presenters\WebBasePresenter; use Doctrine\ORM\NonUniqueResultException; use Nette\Application\AbortException; -use Nette\Application\UI\Control; use Nette\Application\UI\Form; use Nette\Forms\Container; use Nette\Localization\Translator; @@ -35,25 +34,24 @@ use Ublaboo\DataGrid\Exception\DataGridException; use Ublaboo\Mailing\Exception\MailingMailCreationException; -use function assert; - /** * Komponenta pro správu vlastních přihlášek. */ -class ApplicationsGridControl extends Control +class ApplicationsGridControl extends BaseContentControl { private User|null $user = null; public function __construct( - private readonly QueryBus $queryBus, - private readonly Translator $translator, - private readonly ApplicationRepository $applicationRepository, - private readonly SubeventRepository $subeventRepository, - private readonly ApplicationService $applicationService, - private readonly Validators $validators, - private readonly RolesApplicationRepository $rolesApplicationRepository, - private readonly SubeventsApplicationRepository $subeventsApplicationRepository, - private readonly SubeventService $subeventService, + private QueryBus $queryBus, + private Translator $translator, + private ApplicationRepository $applicationRepository, + private UserRepository $userRepository, + private SubeventRepository $subeventRepository, + private ApplicationService $applicationService, + private Validators $validators, + private RolesApplicationRepository $rolesApplicationRepository, + private SubeventsApplicationRepository $subeventsApplicationRepository, + private SubeventService $subeventService, ) { } @@ -76,10 +74,7 @@ public function render(): void */ public function createComponentApplicationsGrid(string $name): void { - $presenter = $this->getPresenter(); - assert($presenter instanceof WebBasePresenter); - - $this->user = $presenter->getDbUser(); + $this->user = $this->userRepository->findById($this->getPresenter()->getUser()->getId()); $explicitSubeventsExists = $this->subeventRepository->explicitSubeventsExists(); $userHasFixedFeeRole = $this->user->hasFixedFeeRole(); @@ -105,25 +100,25 @@ public function createComponentApplicationsGrid(string $name): void $grid->setDataSource($qb); $grid->setPagination(false); - $grid->addColumnDateTime('applicationDate', 'web.profile.seminar.applications.application_date') + $grid->addColumnDateTime('applicationDate', 'web.profile.applications_application_date') ->setFormat(Helpers::DATETIME_FORMAT); if ($userHasFixedFeeRole) { - $grid->addColumnText('roles', 'web.profile.seminar.applications.roles', 'rolesText'); + $grid->addColumnText('roles', 'web.profile.applications_roles', 'rolesText'); } if ($explicitSubeventsExists) { - $grid->addColumnText('subevents', 'web.profile.seminar.applications.subevents', 'subeventsText'); + $grid->addColumnText('subevents', 'web.profile.applications_subevents', 'subeventsText'); } - $grid->addColumnNumber('fee', 'web.profile.seminar.applications.fee'); + $grid->addColumnNumber('fee', 'web.profile.applications_fee'); - $grid->addColumnText('variable_symbol', 'web.profile.seminar.applications.variable_symbol', 'variableSymbolText'); + $grid->addColumnText('variable_symbol', 'web.profile.applications_variable_symbol', 'variableSymbolText'); - $grid->addColumnDateTime('maturityDate', 'web.profile.seminar.applications.maturity_date') + $grid->addColumnDateTime('maturityDate', 'web.profile.applications_maturity_date') ->setFormat(Helpers::DATE_FORMAT); - $grid->addColumnText('state', 'web.profile.seminar.applications.state') + $grid->addColumnText('state', 'web.profile.applications_state') ->setRenderer(fn (Application $row) => $this->applicationService->getStateText($row)); if ($explicitSubeventsExists) { @@ -132,9 +127,9 @@ public function createComponentApplicationsGrid(string $name): void $options = $this->subeventService->getSubeventsOptionsWithCapacity(true, true, true, false, $this->user); $container->addMultiSelect('subevents', '', $options) ->setHtmlAttribute('class', 'datagrid-multiselect') - ->addRule(Form::FILLED, 'web.profile.seminar.applications.subevents_empty'); + ->addRule(Form::FILLED, 'web.profile.applications_subevents_empty'); }; - $grid->getInlineAdd()->setText($this->translator->translate('web.profile.seminar.applications.add_subevents')); + $grid->getInlineAdd()->setText($this->translator->translate('web.profile.applications_add_subevents')); $grid->getInlineAdd()->onSubmit[] = [$this, 'add']; } @@ -142,9 +137,9 @@ public function createComponentApplicationsGrid(string $name): void $options = $this->subeventService->getSubeventsOptionsWithCapacity(true, true, false, true, $this->user); $container->addMultiSelect('subevents', '', $options) ->setHtmlAttribute('class', 'datagrid-multiselect') - ->addRule(Form::FILLED, 'web.profile.seminar.applications.subevents_empty'); + ->addRule(Form::FILLED, 'web.profile.applications_subevents_empty'); }; - $grid->getInlineEdit()->setText($this->translator->translate('web.profile.seminar.applications.edit')); + $grid->getInlineEdit()->setText($this->translator->translate('web.profile.applications_edit')); $grid->getInlineEdit()->onSetDefaults[] = function (Container $container, SubeventsApplication $item): void { $container->setDefaults([ 'subevents' => $this->subeventRepository->findSubeventsIds($item->getSubevents()), @@ -154,24 +149,24 @@ public function createComponentApplicationsGrid(string $name): void $grid->allowRowsInlineEdit(fn (Application $item) => $this->applicationService->isAllowedEditApplication($item)); } - $grid->addAction('generatePaymentProofBank', 'web.profile.seminar.applications.download_payment_proof'); + $grid->addAction('generatePaymentProofBank', 'web.profile.applications_download_payment_proof'); $grid->allowRowsAction('generatePaymentProofBank', static fn (Application $item) => $item->getState() === ApplicationState::PAID && $item->getPaymentMethod() === PaymentType::BANK && $item->getPaymentDate()); if ($this->user->getNotCanceledSubeventsApplications()->count() > 1) { - $grid->addAction('cancelApplication', 'web.profile.seminar.applications.cancel_application') + $grid->addAction('cancelApplication', 'web.profile.applications_cancel_application') ->addAttributes([ 'data-toggle' => 'confirmation', - 'data-content' => $this->translator->translate('web.profile.seminar.applications.cancel_application_confirm'), + 'data-content' => $this->translator->translate('web.profile.applications_cancel_application_confirm'), ])->setClass('btn btn-xs btn-danger'); $grid->allowRowsAction('cancelApplication', fn (Application $item) => $this->applicationService->isAllowedEditApplication($item)); } $grid->setItemsDetail() ->setRenderCondition(static fn (Application $item) => $item->isWaitingForPayment()) - ->setText($this->translator->translate('web.profile.seminar.applications.pay')) - ->setIcon('money-bill-1') + ->setText($this->translator->translate('web.profile.applications_pay')) + ->setIcon('money') ->setClass('btn btn-xs btn-primary ajax') ->setTemplateParameters([ 'account' => $this->queryBus->handle(new SettingStringValueQuery(Settings::ACCOUNT_NUMBER)), @@ -205,7 +200,7 @@ public function add(stdClass $values): void $p = $this->getPresenter(); if (! $this->validators->validateSubeventsCapacities($selectedSubevents, $this->user)) { - $p->flashMessage('web.profile.seminar.applications.subevents_capacity_occupied', 'danger'); + $p->flashMessage('web.profile.applications_subevents_capacity_occupied', 'danger'); $p->redrawControl('flashes'); return; @@ -214,7 +209,7 @@ public function add(stdClass $values): void foreach ($this->subeventRepository->findFilteredSubevents(true, false, false, false) as $subevent) { if (! $this->validators->validateSubeventsIncompatible($selectedAndUsersSubevents, $subevent)) { $message = $this->translator->translate( - 'web.profile.seminar.applications.incompatible_subevents_selected', + 'web.profile.applications_incompatible_subevents_selected', null, ['subevent' => $subevent->getName(), 'incompatibleSubevents' => $subevent->getIncompatibleSubeventsText()], ); @@ -226,7 +221,7 @@ public function add(stdClass $values): void if (! $this->validators->validateSubeventsRequired($selectedAndUsersSubevents, $subevent)) { $message = $this->translator->translate( - 'web.profile.seminar.applications.required_subevents_not_selected', + 'web.profile.applications_required_subevents_not_selected', null, ['subevent' => $subevent->getName(), 'requiredSubevents' => $subevent->getRequiredSubeventsTransitiveText()], ); @@ -239,7 +234,7 @@ public function add(stdClass $values): void $this->applicationService->addSubeventsApplication($this->user, $selectedSubevents, $this->user); - $p->flashMessage('web.profile.seminar.applications.add_subevents_successful', 'success'); + $p->flashMessage('web.profile.applications_add_subevents_successful', 'success'); $p->redrawControl('flashes'); } @@ -269,7 +264,7 @@ public function edit(string $id, stdClass $values): void $p = $this->getPresenter(); if (! $this->validators->validateSubeventsCapacities($selectedSubevents, $this->user)) { - $p->flashMessage('web.profile.seminar.applications.subevents_capacity_occupied', 'danger'); + $p->flashMessage('web.profile.applications_subevents_capacity_occupied', 'danger'); $p->redrawControl('flashes'); return; @@ -278,7 +273,7 @@ public function edit(string $id, stdClass $values): void foreach ($this->subeventRepository->findFilteredSubevents(true, false, false, false) as $subevent) { if (! $this->validators->validateSubeventsIncompatible($selectedAndUsersSubevents, $subevent)) { $message = $this->translator->translate( - 'web.profile.seminar.applications.incompatible_subevents_selected', + 'web.profile.applications_incompatible_subevents_selected', null, ['subevent' => $subevent->getName(), 'incompatibleSubevents' => $subevent->getIncompatibleSubeventsText()], ); @@ -290,7 +285,7 @@ public function edit(string $id, stdClass $values): void if (! $this->validators->validateSubeventsRequired($selectedAndUsersSubevents, $subevent)) { $message = $this->translator->translate( - 'web.profile.seminar.applications.required_subevents_not_selected', + 'web.profile.applications_required_subevents_not_selected', null, ['subevent' => $subevent->getName(), 'requiredSubevents' => $subevent->getRequiredSubeventsTransitiveText()], ); @@ -303,7 +298,7 @@ public function edit(string $id, stdClass $values): void $this->applicationService->updateSubeventsApplication($application, $selectedSubevents, $this->user); - $p->flashMessage('web.profile.seminar.applications.edit_successful', 'success'); + $p->flashMessage('web.profile.applications_edit_successful', 'success'); $p->redrawControl('flashes'); } } @@ -333,7 +328,7 @@ public function handleCancelApplication(int $id): void if ($application instanceof SubeventsApplication && $this->applicationService->isAllowedEditApplication($application)) { $this->applicationService->cancelSubeventsApplication($application, ApplicationState::CANCELED, $application->getUser()); - $p->flashMessage('web.profile.seminar.applications.application_canceled', 'success'); + $p->flashMessage('web.profile.applications_application_canceled', 'success'); } $p->redirect('this'); diff --git a/app/WebModule/Components/BlocksContentControl.php b/app/WebModule/Components/BlocksContentControl.php index 6f4aa215d..af8989e9e 100644 --- a/app/WebModule/Components/BlocksContentControl.php +++ b/app/WebModule/Components/BlocksContentControl.php @@ -9,11 +9,11 @@ use App\Model\Program\Repositories\CategoryRepository; /** - * Komponenta obsahu s podrobnostmi o programových blocích. + * Komponenta s podrobnostmi o programových blocích. */ class BlocksContentControl extends BaseContentControl { - public function __construct(private readonly BlockRepository $blockRepository, private readonly CategoryRepository $categoryRepository) + public function __construct(private BlockRepository $blockRepository, private CategoryRepository $categoryRepository) { } diff --git a/app/WebModule/Components/CapacitiesContentControl.php b/app/WebModule/Components/CapacitiesContentControl.php index 3c2208185..2c898c418 100644 --- a/app/WebModule/Components/CapacitiesContentControl.php +++ b/app/WebModule/Components/CapacitiesContentControl.php @@ -8,11 +8,11 @@ use App\Model\Cms\Dto\CapacitiesContentDto; /** - * Komponenta obsahu s kapacitami rolí. + * Komponenta s kapacitami rolí. */ class CapacitiesContentControl extends BaseContentControl { - public function __construct(private readonly RoleRepository $roleRepository) + public function __construct(private RoleRepository $roleRepository) { } diff --git a/app/WebModule/Components/ContactFormContentControl.php b/app/WebModule/Components/ContactFormContentControl.php index abed27c96..4894c731c 100644 --- a/app/WebModule/Components/ContactFormContentControl.php +++ b/app/WebModule/Components/ContactFormContentControl.php @@ -15,14 +15,14 @@ use Throwable; /** - * Komponenta obsahu s kontaktním formulářem. + * Komponenta s kontaktním formulářem. */ class ContactFormContentControl extends BaseContentControl { public function __construct( - private readonly QueryBus $queryBus, - private readonly IContactFormFactory $contactFormFactory, - private readonly RoleRepository $roleRepository, + private QueryBus $queryBus, + private IContactFormFactory $contactFormFactory, + private RoleRepository $roleRepository, ) { } @@ -36,7 +36,8 @@ public function render(ContentDto $content): void $template->backlink = $this->getPresenter()->getHttpRequest()->getUrl()->getPath(); - $template->guestRole = $this->getPresenter()->getUser()->isInRole($this->roleRepository->findBySystemName(Role::GUEST)->getName()); + $user = $this->getPresenter()->user; + $template->guestRole = $user->isInRole($this->roleRepository->findBySystemName(Role::GUEST)->getName()); $template->guestsAllowed = $this->queryBus->handle(new SettingBoolValueQuery(Settings::CONTACT_FORM_GUESTS_ALLOWED)); $template->render(); diff --git a/app/WebModule/Components/DocumentContentControl.php b/app/WebModule/Components/DocumentContentControl.php index 25f73e7e5..a53c9833b 100644 --- a/app/WebModule/Components/DocumentContentControl.php +++ b/app/WebModule/Components/DocumentContentControl.php @@ -10,11 +10,11 @@ use function array_keys; /** - * Komponenta obsahu s dokumenty. + * Komponenta s dokumenty. */ class DocumentContentControl extends BaseContentControl { - public function __construct(private readonly DocumentRepository $documentRepository) + public function __construct(private DocumentRepository $documentRepository) { } @@ -23,7 +23,7 @@ public function render(DocumentContentDto $content): void $template = $this->template; $template->setFile(__DIR__ . '/templates/document_content.latte'); - $roles = $this->presenter->getUser()->getRoles(); + $roles = $this->presenter->user->roles; $template->heading = $content->getHeading(); $template->documents = $this->documentRepository->findRolesAllowedByTagsOrderedByName(array_keys($roles), $content->getTags()); diff --git a/app/WebModule/Components/FaqContentControl.php b/app/WebModule/Components/FaqContentControl.php index bb3c9cdec..afd01b30e 100644 --- a/app/WebModule/Components/FaqContentControl.php +++ b/app/WebModule/Components/FaqContentControl.php @@ -9,21 +9,18 @@ use App\Model\Cms\Dto\ContentDto; use App\Model\Cms\Repositories\FaqRepository; use App\WebModule\Forms\FaqFormFactory; -use App\WebModule\Presenters\WebBasePresenter; use Nette\Application\UI\Form; use stdClass; -use function assert; - /** - * Komponenta obsahu s FAQ. + * Komponenta s FAQ. */ class FaqContentControl extends BaseContentControl { public function __construct( - private readonly FaqFormFactory $faqFormFactory, - private readonly FaqRepository $faqRepository, - private readonly RoleRepository $roleRepository, + private FaqFormFactory $faqFormFactory, + private FaqRepository $faqRepository, + private RoleRepository $roleRepository, ) { } @@ -37,19 +34,18 @@ public function render(ContentDto $content): void $template->backlink = $this->getPresenter()->getHttpRequest()->getUrl()->getPath(); - $template->guestRole = $this->getPresenter()->getUser()->isInRole($this->roleRepository->findBySystemName(Role::GUEST)->getName()); + $user = $this->getPresenter()->user; + $template->guestRole = $user->isInRole($this->roleRepository->findBySystemName(Role::GUEST)->getName()); $template->render(); } public function createComponentFaqForm(): Form { - $p = $this->getPresenter(); - assert($p instanceof WebBasePresenter); - - $form = $this->faqFormFactory->create($p->getDbUser()); + $form = $this->faqFormFactory->create($this->getPresenter()->getUser()->id); - $form->onSuccess[] = static function (Form $form, stdClass $values) use ($p): void { + $form->onSuccess[] = function (Form $form, stdClass $values): void { + $p = $this->getPresenter(); $p->flashMessage('web.faq_content.add_question_successful', 'success'); $p->redirect('this'); }; diff --git a/app/WebModule/Components/HtmlContentControl.php b/app/WebModule/Components/HtmlContentControl.php index 540644038..fa7b186ed 100644 --- a/app/WebModule/Components/HtmlContentControl.php +++ b/app/WebModule/Components/HtmlContentControl.php @@ -7,7 +7,7 @@ use App\Model\Cms\Dto\HtmlContentDto; /** - * Komponenta obsahu s HTML. + * Komponenta s HTML. */ class HtmlContentControl extends BaseContentControl { diff --git a/app/WebModule/Components/IApplicationContentControlFactory.php b/app/WebModule/Components/IApplicationContentControlFactory.php index 894b08c29..dbf81cef9 100644 --- a/app/WebModule/Components/IApplicationContentControlFactory.php +++ b/app/WebModule/Components/IApplicationContentControlFactory.php @@ -5,7 +5,7 @@ namespace App\WebModule\Components; /** - * Factory komponenty obsahu s přihláškou. + * Factory komponenty s přihláškou. */ interface IApplicationContentControlFactory { diff --git a/app/WebModule/Components/IApplicationsGridControlFactory.php b/app/WebModule/Components/IApplicationsGridControlFactory.php index 0207959ec..28c2b8099 100644 --- a/app/WebModule/Components/IApplicationsGridControlFactory.php +++ b/app/WebModule/Components/IApplicationsGridControlFactory.php @@ -9,5 +9,8 @@ */ interface IApplicationsGridControlFactory { + /** + * Vytvoří komponentu. + */ public function create(): ApplicationsGridControl; } diff --git a/app/WebModule/Components/IBlocksContentControlFactory.php b/app/WebModule/Components/IBlocksContentControlFactory.php index be2217c28..23044733b 100644 --- a/app/WebModule/Components/IBlocksContentControlFactory.php +++ b/app/WebModule/Components/IBlocksContentControlFactory.php @@ -5,7 +5,7 @@ namespace App\WebModule\Components; /** - * Factory komponenty obsahu s podrobnostmi o programových blocích. + * Factory komponenty s podrobnostmi o programových blocích. */ interface IBlocksContentControlFactory { diff --git a/app/WebModule/Components/ICapacitiesContentControlFactory.php b/app/WebModule/Components/ICapacitiesContentControlFactory.php index faebb2b45..f73457f63 100644 --- a/app/WebModule/Components/ICapacitiesContentControlFactory.php +++ b/app/WebModule/Components/ICapacitiesContentControlFactory.php @@ -5,7 +5,7 @@ namespace App\WebModule\Components; /** - * Factory komponenty obsahu s kapacitami rolí. + * Factory komponenty s kapacitami rolí. */ interface ICapacitiesContentControlFactory { diff --git a/app/WebModule/Components/IContactFormContentControlFactory.php b/app/WebModule/Components/IContactFormContentControlFactory.php index 577beab2a..f5f5c5da7 100644 --- a/app/WebModule/Components/IContactFormContentControlFactory.php +++ b/app/WebModule/Components/IContactFormContentControlFactory.php @@ -5,7 +5,7 @@ namespace App\WebModule\Components; /** - * Factory komponenty obsahu s kontaktním formulářem. + * Factory komponenty s kontaktním formulářem. */ interface IContactFormContentControlFactory { diff --git a/app/WebModule/Components/IDocumentContentControlFactory.php b/app/WebModule/Components/IDocumentContentControlFactory.php index 0a1ebd86b..c2c1294f5 100644 --- a/app/WebModule/Components/IDocumentContentControlFactory.php +++ b/app/WebModule/Components/IDocumentContentControlFactory.php @@ -5,7 +5,7 @@ namespace App\WebModule\Components; /** - * Factory komponenty obsahu s dokumenty. + * Factory komponenty s dokumenty. */ interface IDocumentContentControlFactory { diff --git a/app/WebModule/Components/IFaqContentControlFactory.php b/app/WebModule/Components/IFaqContentControlFactory.php index b2e1f00f8..d4fffd2b9 100644 --- a/app/WebModule/Components/IFaqContentControlFactory.php +++ b/app/WebModule/Components/IFaqContentControlFactory.php @@ -5,7 +5,7 @@ namespace App\WebModule\Components; /** - * Factory komponenty obsahu s FAQ. + * Factory komponenty s FAQ. */ interface IFaqContentControlFactory { diff --git a/app/WebModule/Components/IHtmlContentControlFactory.php b/app/WebModule/Components/IHtmlContentControlFactory.php index 91e53f3ad..793acf133 100644 --- a/app/WebModule/Components/IHtmlContentControlFactory.php +++ b/app/WebModule/Components/IHtmlContentControlFactory.php @@ -5,7 +5,7 @@ namespace App\WebModule\Components; /** - * Factory komponenty obsahu s HTML. + * Factory komponenty s HTML. */ interface IHtmlContentControlFactory { diff --git a/app/WebModule/Components/IImageContentControlFactory.php b/app/WebModule/Components/IImageContentControlFactory.php index 4264bf165..e17ed64ac 100644 --- a/app/WebModule/Components/IImageContentControlFactory.php +++ b/app/WebModule/Components/IImageContentControlFactory.php @@ -5,7 +5,7 @@ namespace App\WebModule\Components; /** - * Factory komponenty obsahu s obrázkem. + * Factory komponenty s obrázkem. */ interface IImageContentControlFactory { diff --git a/app/WebModule/Components/ILectorsContentControlFactory.php b/app/WebModule/Components/ILectorsContentControlFactory.php index 308c39089..9d4f4d50d 100644 --- a/app/WebModule/Components/ILectorsContentControlFactory.php +++ b/app/WebModule/Components/ILectorsContentControlFactory.php @@ -5,7 +5,7 @@ namespace App\WebModule\Components; /** - * Factory komponenty obsahu s přehledem lektorů. + * Factory komponenty s přehledem lektorů. */ interface ILectorsContentControlFactory { diff --git a/app/WebModule/Components/INewsContentControlFactory.php b/app/WebModule/Components/INewsContentControlFactory.php index 8d4f72e86..3bbc4c0bb 100644 --- a/app/WebModule/Components/INewsContentControlFactory.php +++ b/app/WebModule/Components/INewsContentControlFactory.php @@ -5,7 +5,7 @@ namespace App\WebModule\Components; /** - * Factory komponenty obsahu s aktualitami. + * Factory komponenty s aktualitami. */ interface INewsContentControlFactory { diff --git a/app/WebModule/Components/IOrganizerContentControlFactory.php b/app/WebModule/Components/IOrganizerContentControlFactory.php index e95face6d..3ad117f6c 100644 --- a/app/WebModule/Components/IOrganizerContentControlFactory.php +++ b/app/WebModule/Components/IOrganizerContentControlFactory.php @@ -5,7 +5,7 @@ namespace App\WebModule\Components; /** - * Factory komponenty obsahu s informací o pořadateli. + * Factory komponenty s informací o pořadateli. */ interface IOrganizerContentControlFactory { diff --git a/app/WebModule/Components/IPlaceContentControlFactory.php b/app/WebModule/Components/IPlaceContentControlFactory.php index 672a8b05c..5202f7120 100644 --- a/app/WebModule/Components/IPlaceContentControlFactory.php +++ b/app/WebModule/Components/IPlaceContentControlFactory.php @@ -5,7 +5,7 @@ namespace App\WebModule\Components; /** - * Factory komponenty obsahu s místem. + * Factory komponenty s místem. */ interface IPlaceContentControlFactory { diff --git a/app/WebModule/Components/IProgramsContentControlFactory.php b/app/WebModule/Components/IProgramsContentControlFactory.php index 84e53488f..bf29520f2 100644 --- a/app/WebModule/Components/IProgramsContentControlFactory.php +++ b/app/WebModule/Components/IProgramsContentControlFactory.php @@ -5,7 +5,7 @@ namespace App\WebModule\Components; /** - * Factory komponenty obsahu s výběrem programů. + * Factory komponenty s výběrem programů. */ interface IProgramsContentControlFactory { diff --git a/app/WebModule/Components/ISlideshowContentControlFactory.php b/app/WebModule/Components/ISlideshowContentControlFactory.php index ecd03255a..23f782fd8 100644 --- a/app/WebModule/Components/ISlideshowContentControlFactory.php +++ b/app/WebModule/Components/ISlideshowContentControlFactory.php @@ -5,7 +5,7 @@ namespace App\WebModule\Components; /** - * Factory komponenty obsahu se slideshow. + * Factory komponenty se slideshow. */ interface ISlideshowContentControlFactory { diff --git a/app/WebModule/Components/ITextContentControlFactory.php b/app/WebModule/Components/ITextContentControlFactory.php index e4cb65ae7..6d95656d5 100644 --- a/app/WebModule/Components/ITextContentControlFactory.php +++ b/app/WebModule/Components/ITextContentControlFactory.php @@ -5,7 +5,7 @@ namespace App\WebModule\Components; /** - * Factory komponenty obsahu s textem. + * Factory komponenty s textem. */ interface ITextContentControlFactory { diff --git a/app/WebModule/Components/IUsersContentControlFactory.php b/app/WebModule/Components/IUsersContentControlFactory.php index 70cc4424c..468613fce 100644 --- a/app/WebModule/Components/IUsersContentControlFactory.php +++ b/app/WebModule/Components/IUsersContentControlFactory.php @@ -5,7 +5,7 @@ namespace App\WebModule\Components; /** - * Factory komponenty obsahu s přehledem uživatelů. + * Factory komponenty s přehledem uživatelů. */ interface IUsersContentControlFactory { diff --git a/app/WebModule/Components/ImageContentControl.php b/app/WebModule/Components/ImageContentControl.php index 340886401..78d797fd5 100644 --- a/app/WebModule/Components/ImageContentControl.php +++ b/app/WebModule/Components/ImageContentControl.php @@ -7,7 +7,7 @@ use App\Model\Cms\Dto\ImageContentDto; /** - * Komponenta obsahu s obrázkem. + * Komponenta s obrázkem. */ class ImageContentControl extends BaseContentControl { diff --git a/app/WebModule/Components/LectorsContentControl.php b/app/WebModule/Components/LectorsContentControl.php index 868f0d5aa..13f8c8c12 100644 --- a/app/WebModule/Components/LectorsContentControl.php +++ b/app/WebModule/Components/LectorsContentControl.php @@ -10,11 +10,11 @@ use App\Model\User\Repositories\UserRepository; /** - * Komponenta obsahu s přehledem lektorů. + * Komponenta s přehledem lektorů. */ class LectorsContentControl extends BaseContentControl { - public function __construct(private readonly UserRepository $userRepository, private readonly RoleRepository $roleRepository) + public function __construct(private UserRepository $userRepository, private RoleRepository $roleRepository) { } diff --git a/app/WebModule/Components/NewsContentControl.php b/app/WebModule/Components/NewsContentControl.php index 531da8fd5..7aeedb3f6 100644 --- a/app/WebModule/Components/NewsContentControl.php +++ b/app/WebModule/Components/NewsContentControl.php @@ -8,11 +8,11 @@ use App\Model\Cms\Repositories\NewsRepository; /** - * Komponenta obsahu s aktualitami. + * Komponenta s aktualitami. */ class NewsContentControl extends BaseContentControl { - public function __construct(private readonly NewsRepository $newsRepository) + public function __construct(private NewsRepository $newsRepository) { } diff --git a/app/WebModule/Components/OrganizerContentControl.php b/app/WebModule/Components/OrganizerContentControl.php index dd34c59b2..c523e862c 100644 --- a/app/WebModule/Components/OrganizerContentControl.php +++ b/app/WebModule/Components/OrganizerContentControl.php @@ -7,7 +7,7 @@ use App\Model\Cms\Dto\OrganizerContentDto; /** - * Komponenta obsahu s informací o pořadateli. + * Komponenta s informací o pořadateli. */ class OrganizerContentControl extends BaseContentControl { diff --git a/app/WebModule/Components/PlaceContentControl.php b/app/WebModule/Components/PlaceContentControl.php index 698f7a64c..7b24c5b69 100644 --- a/app/WebModule/Components/PlaceContentControl.php +++ b/app/WebModule/Components/PlaceContentControl.php @@ -12,11 +12,11 @@ use Throwable; /** - * Komponenta obsahu s místem. + * Komponenta s místem. */ class PlaceContentControl extends BaseContentControl { - public function __construct(private readonly QueryBus $queryBus, private readonly PlacePointRepository $placePointRepository) + public function __construct(private QueryBus $queryBus, private PlacePointRepository $placePointRepository) { } diff --git a/app/WebModule/Components/ProgramsContentControl.php b/app/WebModule/Components/ProgramsContentControl.php index 892007bc5..89cb4aedc 100644 --- a/app/WebModule/Components/ProgramsContentControl.php +++ b/app/WebModule/Components/ProgramsContentControl.php @@ -13,20 +13,19 @@ use App\Model\Settings\Queries\SettingDateTimeValueQuery; use App\Model\Settings\Queries\SettingStringValueQuery; use App\Model\Settings\Settings; +use App\Model\User\Repositories\UserRepository; use App\Services\QueryBus; -use App\WebModule\Presenters\WebBasePresenter; use Throwable; -use function assert; - /** - * Komponenta obsahu s výběrem programů. + * Komponenta s výběrem programů. */ class ProgramsContentControl extends BaseContentControl { public function __construct( - private readonly QueryBus $queryBus, - private readonly RoleRepository $roleRepository, + private QueryBus $queryBus, + private UserRepository $userRepository, + private RoleRepository $roleRepository, ) { } @@ -46,14 +45,12 @@ public function render(ContentDto $content): void $template->registerProgramsFrom = $this->queryBus->handle(new SettingDateTimeValueQuery(Settings::REGISTER_PROGRAMS_FROM)); $template->registerProgramsTo = $this->queryBus->handle(new SettingDateTimeValueQuery(Settings::REGISTER_PROGRAMS_TO)); - $presenter = $this->getPresenter(); - assert($presenter instanceof WebBasePresenter); - - $template->guestRole = $presenter->getUser()->isInRole($this->roleRepository->findBySystemName(Role::GUEST)->getName()); + $user = $this->getPresenter()->user; + $template->guestRole = $user->isInRole($this->roleRepository->findBySystemName(Role::GUEST)->getName()); - if ($presenter->getUser()->isLoggedIn()) { + if ($user->isLoggedIn()) { $template->userWaitingForPayment = ! $this->queryBus->handle(new SettingBoolValueQuery(Settings::IS_ALLOWED_REGISTER_PROGRAMS_BEFORE_PAYMENT)) - && $presenter->getDbUser()->getWaitingForPaymentApplications()->count() > 0; + && $this->userRepository->findById($user->getId())->getWaitingForPaymentApplications()->count() > 0; } $template->render(); diff --git a/app/WebModule/Components/SlideshowContentControl.php b/app/WebModule/Components/SlideshowContentControl.php index 873628b7b..efc37e513 100644 --- a/app/WebModule/Components/SlideshowContentControl.php +++ b/app/WebModule/Components/SlideshowContentControl.php @@ -7,7 +7,7 @@ use App\Model\Cms\Dto\SlideshowContentDto; /** - * Komponenta obsahu se slideshow. + * Komponenta se slideshow. */ class SlideshowContentControl extends BaseContentControl { diff --git a/app/WebModule/Components/TextContentControl.php b/app/WebModule/Components/TextContentControl.php index 84483d799..1a63270ec 100644 --- a/app/WebModule/Components/TextContentControl.php +++ b/app/WebModule/Components/TextContentControl.php @@ -7,7 +7,7 @@ use App\Model\Cms\Dto\TextContentDto; /** - * Komponenta obsahu s textem. + * Komponenta s textem. */ class TextContentControl extends BaseContentControl { diff --git a/app/WebModule/Components/UsersContentControl.php b/app/WebModule/Components/UsersContentControl.php index 1f0a3a53e..c4235e293 100644 --- a/app/WebModule/Components/UsersContentControl.php +++ b/app/WebModule/Components/UsersContentControl.php @@ -8,11 +8,11 @@ use App\Model\User\Repositories\UserRepository; /** - * Komponenta obsahu s přehledem uživatelů. + * Komponenta s přehledem uživatelů. */ class UsersContentControl extends BaseContentControl { - public function __construct(private readonly UserRepository $userRepository) + public function __construct(private UserRepository $userRepository) { } diff --git a/app/WebModule/Components/templates/application_content.latte b/app/WebModule/Components/templates/application_content.latte index 9e110bc06..257f3e1dc 100644 --- a/app/WebModule/Components/templates/application_content.latte +++ b/app/WebModule/Components/templates/application_content.latte @@ -47,7 +47,7 @@
    - {_web.application_content.unapproved_registration, ['roles' => $dbUser->getRolesText()]} + {_web.application_content.unapproved_registration, ['roles' => $dbuser->getRolesText()]}
    @@ -55,7 +55,7 @@
    - {_web.application_content.approved_registration, ['roles' => $dbUser->getRolesText()]} + {_web.application_content.approved_registration, ['roles' => $dbuser->getRolesText()]}
    diff --git a/app/WebModule/Components/templates/applications_grid_detail.latte b/app/WebModule/Components/templates/applications_grid_detail.latte index 71c6628fa..7ff77b87b 100644 --- a/app/WebModule/Components/templates/applications_grid_detail.latte +++ b/app/WebModule/Components/templates/applications_grid_detail.latte @@ -8,7 +8,7 @@
    - {_web.profile.seminar.applications.account} + {_web.profile.applications_account}
    {$account} @@ -16,7 +16,7 @@
    - {_web.profile.seminar.applications.variable_symbol} + {_web.profile.applications_variable_symbol}
    {$item->getVariableSymbolText()} @@ -24,7 +24,7 @@
    - {_web.profile.seminar.applications.fee} + {_web.profile.applications_fee}
    {$item->getFee()} diff --git a/app/WebModule/Components/templates/contact_form_content.latte b/app/WebModule/Components/templates/contact_form_content.latte index f6ef6937e..57fac23b7 100644 --- a/app/WebModule/Components/templates/contact_form_content.latte +++ b/app/WebModule/Components/templates/contact_form_content.latte @@ -7,19 +7,23 @@
    -
    diff --git a/app/WebModule/Components/templates/lectors_content.latte b/app/WebModule/Components/templates/lectors_content.latte index 08146867f..b4c3b5ccd 100644 --- a/app/WebModule/Components/templates/lectors_content.latte +++ b/app/WebModule/Components/templates/lectors_content.latte @@ -12,7 +12,7 @@

    {$lector->getLectorName()}

    -
    +
    diff --git a/app/WebModule/Forms/AdditionalInformationFormFactory.php b/app/WebModule/Forms/AdditionalInformationFormFactory.php index 24e1d8d20..ddcd3c8b7 100644 --- a/app/WebModule/Forms/AdditionalInformationFormFactory.php +++ b/app/WebModule/Forms/AdditionalInformationFormFactory.php @@ -20,7 +20,6 @@ use App\Model\CustomInput\CustomTextValue; use App\Model\CustomInput\Repositories\CustomInputRepository; use App\Model\CustomInput\Repositories\CustomInputValueRepository; -use App\Model\Mailing\Commands\CreateTemplateMail; use App\Model\Mailing\Template; use App\Model\Mailing\TemplateVariable; use App\Model\Settings\Exceptions\SettingsItemNotFoundException; @@ -29,8 +28,8 @@ use App\Model\User\Repositories\UserRepository; use App\Model\User\User; use App\Services\ApplicationService; -use App\Services\CommandBus; use App\Services\FilesService; +use App\Services\IMailService; use App\Services\QueryBus; use Doctrine\Common\Collections\ArrayCollection; use Doctrine\ORM\EntityManagerInterface; @@ -61,18 +60,18 @@ class AdditionalInformationFormFactory /** * Přihlášený uživatel. */ - private User $user; + private User|null $user = null; public function __construct( - private readonly BaseFormFactory $baseFormFactory, - private readonly CommandBus $commandBus, - private readonly QueryBus $queryBus, - private readonly EntityManagerInterface $em, - private readonly UserRepository $userRepository, - private readonly CustomInputRepository $customInputRepository, - private readonly ApplicationService $applicationService, - private readonly CustomInputValueRepository $customInputValueRepository, - private readonly FilesService $filesService, + private BaseFormFactory $baseFormFactory, + private QueryBus $queryBus, + private EntityManagerInterface $em, + private UserRepository $userRepository, + private CustomInputRepository $customInputRepository, + private ApplicationService $applicationService, + private CustomInputValueRepository $customInputValueRepository, + private FilesService $filesService, + private IMailService $mailService, ) { } @@ -82,9 +81,9 @@ public function __construct( * @throws SettingsItemNotFoundException * @throws Throwable */ - public function create(User $user): Form + public function create(int $userId): Form { - $this->user = $user; + $this->user = $this->userRepository->findById($userId); $isAllowedEditCustomInputs = $this->applicationService->isAllowedEditCustomInputs(); $form = $this->baseFormFactory->create(); @@ -187,13 +186,13 @@ public function create(User $user): Form $custom->setDisabled(! $isAllowedEditCustomInputs); if ($customInput->isMandatory()) { - $custom->addRule(Form::FILLED, 'web.profile.additional_information.custom_input_empty'); + $custom->addRule(Form::FILLED, 'web.profile.custom_input_empty'); } } - $form->addTextArea('about', 'web.profile.additional_information.about_me'); + $form->addTextArea('about', 'web.profile.about_me'); - $form->addSubmit('submit', 'web.profile.additional_information.update'); + $form->addSubmit('submit', 'web.profile.update_additional_information'); $form->setDefaults([ 'about' => $this->user->getAbout(), @@ -280,10 +279,10 @@ public function processForm(Form $form, stdClass $values): void if ($customInputValueChanged) { assert($this->user instanceof User); - $this->commandBus->handle(new CreateTemplateMail(new ArrayCollection([$this->user]), null, Template::CUSTOM_INPUT_VALUE_CHANGED, [ + $this->mailService->sendMailFromTemplate(new ArrayCollection([$this->user]), null, Template::CUSTOM_INPUT_VALUE_CHANGED, [ TemplateVariable::SEMINAR_NAME => $this->queryBus->handle(new SettingStringValueQuery(Settings::SEMINAR_NAME)), TemplateVariable::USER => $this->user->getDisplayName(), - ])); + ]); } }); } diff --git a/app/WebModule/Forms/ApplicationFormFactory.php b/app/WebModule/Forms/ApplicationFormFactory.php index a4ff334fc..7d1e46d92 100644 --- a/app/WebModule/Forms/ApplicationFormFactory.php +++ b/app/WebModule/Forms/ApplicationFormFactory.php @@ -74,27 +74,27 @@ class ApplicationFormFactory /** * Přihlášený uživatel. */ - private User $user; + private User|null $user = null; /** @var callable[] */ public array $onSkautIsError = []; public function __construct( - private readonly BaseFormFactory $baseFormFactory, - private readonly QueryBus $queryBus, - private readonly EntityManagerInterface $em, - private readonly UserRepository $userRepository, - private readonly RoleRepository $roleRepository, - private readonly CustomInputRepository $customInputRepository, - private readonly CustomInputValueRepository $customInputValueRepository, - private readonly SkautIsService $skautIsService, - private readonly SubeventRepository $subeventRepository, - private readonly AclService $aclService, - private readonly ApplicationService $applicationService, - private readonly Validators $validators, - private readonly FilesService $filesService, - private readonly SubeventService $subeventService, - private readonly Translator $translator, + private BaseFormFactory $baseFormFactory, + private QueryBus $queryBus, + private EntityManagerInterface $em, + private UserRepository $userRepository, + private RoleRepository $roleRepository, + private CustomInputRepository $customInputRepository, + private CustomInputValueRepository $customInputValueRepository, + private SkautIsService $skautIsService, + private SubeventRepository $subeventRepository, + private AclService $aclService, + private ApplicationService $applicationService, + private Validators $validators, + private FilesService $filesService, + private SubeventService $subeventService, + private Translator $translator, ) { } @@ -104,12 +104,14 @@ public function __construct( * @throws NonUniqueResultException * @throws Throwable */ - public function create(User $user): Form + public function create(int $id): Form { - $this->user = $user; + $this->user = $this->userRepository->findById($id); $form = $this->baseFormFactory->create(); + $form->addHidden('id'); + $inputSex = $form->addRadioList('sex', 'web.application_content.sex', Sex::getSexOptions()); $inputFirstName = $form->addText('firstName', 'web.application_content.firstname') @@ -164,6 +166,7 @@ public function create(User $user): Form $form->addSubmit('submit', 'web.application_content.register'); $form->setDefaults([ + 'id' => $id, 'sex' => $this->user->getSex(), 'firstName' => $this->user->getFirstName(), 'lastName' => $this->user->getLastName(), diff --git a/app/WebModule/Forms/BaseFormFactory.php b/app/WebModule/Forms/BaseFormFactory.php index 83b5fcc59..450b8bcff 100644 --- a/app/WebModule/Forms/BaseFormFactory.php +++ b/app/WebModule/Forms/BaseFormFactory.php @@ -16,7 +16,7 @@ class BaseFormFactory { use Nette\SmartObject; - public function __construct(private readonly Translator $translator) + public function __construct(private Translator $translator) { } diff --git a/app/WebModule/Forms/ContactForm.php b/app/WebModule/Forms/ContactForm.php index 9975de8d6..bdcfc934d 100644 --- a/app/WebModule/Forms/ContactForm.php +++ b/app/WebModule/Forms/ContactForm.php @@ -4,17 +4,16 @@ namespace App\WebModule\Forms; -use App\Model\Mailing\Commands\CreateTemplateMail; use App\Model\Mailing\Template; use App\Model\Mailing\TemplateVariable; use App\Model\Settings\Exceptions\SettingsItemNotFoundException; use App\Model\Settings\Queries\SettingArrayValueQuery; use App\Model\Settings\Queries\SettingStringValueQuery; use App\Model\Settings\Settings; +use App\Model\User\Repositories\UserRepository; use App\Model\User\User; -use App\Services\CommandBus; +use App\Services\IMailService; use App\Services\QueryBus; -use App\WebModule\Presenters\WebBasePresenter; use Contributte\ReCaptcha\Forms\ReCaptchaField; use Contributte\ReCaptcha\ReCaptchaProvider; use Doctrine\Common\Collections\ArrayCollection; @@ -24,7 +23,6 @@ use Throwable; use Ublaboo\Mailing\Exception\MailingMailCreationException; -use function assert; use function nl2br; use function str_replace; @@ -46,10 +44,11 @@ class ContactForm extends UI\Control public array $onSave = []; public function __construct( - private readonly BaseFormFactory $baseFormFactory, - private readonly CommandBus $commandBus, - private readonly QueryBus $queryBus, - private readonly ReCaptchaProvider $recaptchaProvider, + private BaseFormFactory $baseFormFactory, + private QueryBus $queryBus, + private UserRepository $userRepository, + private ReCaptchaProvider $recaptchaProvider, + private IMailService $mailService, ) { } @@ -67,10 +66,7 @@ public function render(): void */ public function createComponentForm(): Form { - $presenter = $this->getPresenter(); - assert($presenter instanceof WebBasePresenter); - - $this->user = $presenter->getDbUser(); + $this->user = $this->userRepository->findById($this->presenter->user->getId()); $form = $this->baseFormFactory->create(); @@ -140,7 +136,7 @@ public function processForm(Form $form, stdClass $values): void $recipientsEmails->add($recipient); } - $this->commandBus->handle(new CreateTemplateMail( + $this->mailService->sendMailFromTemplate( $recipientsUsers, $recipientsEmails, Template::CONTACT_FORM, @@ -150,7 +146,7 @@ public function processForm(Form $form, stdClass $values): void TemplateVariable::SENDER_EMAIL => $senderEmail, TemplateVariable::MESSAGE => str_replace(["\n", "\r"], '', nl2br($values->message, false)), ], - )); + ); $this->onSave(); } diff --git a/app/WebModule/Forms/FaqFormFactory.php b/app/WebModule/Forms/FaqFormFactory.php index bc1c1ec94..d0feb82b8 100644 --- a/app/WebModule/Forms/FaqFormFactory.php +++ b/app/WebModule/Forms/FaqFormFactory.php @@ -6,9 +6,10 @@ use App\Model\Cms\Faq; use App\Model\Cms\Repositories\FaqRepository; +use App\Model\User\Repositories\UserRepository; use App\Model\User\User; use Doctrine\ORM\NonUniqueResultException; -use Doctrine\ORM\NoResultException; +use Doctrine\ORM\ORMException; use Nette; use Nette\Application\UI\Form; use stdClass; @@ -23,20 +24,21 @@ class FaqFormFactory /** * Přihlášený uživatel. */ - private User $user; + private User|null $user = null; public function __construct( - private readonly BaseFormFactory $baseFormFactory, - private readonly FaqRepository $faqRepository, + private BaseFormFactory $baseFormFactory, + private FaqRepository $faqRepository, + private UserRepository $userRepository, ) { } /** * Vytvoří formulář. */ - public function create(User $user): Form + public function create(int $id): Form { - $this->user = $user; + $this->user = $this->userRepository->findById($id); $form = $this->baseFormFactory->create(); @@ -54,7 +56,7 @@ public function create(User $user): Form * Zpracuje formulář. * * @throws NonUniqueResultException - * @throws NoResultException + * @throws ORMException */ public function processForm(Form $form, stdClass $values): void { diff --git a/app/WebModule/Forms/PersonalDetailsFormFactory.php b/app/WebModule/Forms/PersonalDetailsFormFactory.php index 651f7f28b..41cbc17e3 100644 --- a/app/WebModule/Forms/PersonalDetailsFormFactory.php +++ b/app/WebModule/Forms/PersonalDetailsFormFactory.php @@ -8,6 +8,7 @@ use App\Model\User\Repositories\UserRepository; use App\Model\User\User; use App\Services\SkautIsService; +use Doctrine\ORM\ORMException; use Nette; use Nette\Application\UI\Form; use Nextras\FormComponents\Controls\DateControl; @@ -28,39 +29,41 @@ class PersonalDetailsFormFactory /** * Přihlášený uživatel. */ - private User $user; + private User|null $user = null; /** @var callable[] */ public array $onSkautIsError = []; public function __construct( - private readonly BaseFormFactory $baseFormFactory, - private readonly UserRepository $userRepository, - private readonly SkautIsService $skautIsService, + private BaseFormFactory $baseFormFactory, + private UserRepository $userRepository, + private SkautIsService $skautIsService, ) { } /** * Vytvoří formulář. */ - public function create(User $user): Form + public function create(int $id): Form { - $this->user = $user; + $this->user = $this->userRepository->findById($id); $form = $this->baseFormFactory->create(); - $inputSex = $form->addRadioList('sex', 'web.profile.personal_details.sex', Sex::getSexOptions()); + $form->addHidden('id'); - $inputFirstName = $form->addText('firstName', 'web.profile.personal_details.firstname') - ->addRule(Form::FILLED, 'web.profile.personal_details.firstname_empty'); + $inputSex = $form->addRadioList('sex', 'web.profile.sex', Sex::getSexOptions()); - $inputLastName = $form->addText('lastName', 'web.profile.personal_details.lastname') - ->addRule(Form::FILLED, 'web.profile.personal_details.lastname_empty'); + $inputFirstName = $form->addText('firstName', 'web.profile.firstname') + ->addRule(Form::FILLED, 'web.profile.firstname_empty'); - $inputNickName = $form->addText('nickName', 'web.profile.personal_details.nickname'); + $inputLastName = $form->addText('lastName', 'web.profile.lastname') + ->addRule(Form::FILLED, 'web.profile.lastname_empty'); - $inputBirthdateDate = new DateControl('web.profile.personal_details.birthdate'); - $inputBirthdateDate->addRule(Form::FILLED, 'web.profile.personal_details.birthdate_empty'); + $inputNickName = $form->addText('nickName', 'web.profile.nickname'); + + $inputBirthdateDate = new DateControl('web.profile.birthdate'); + $inputBirthdateDate->addRule(Form::FILLED, 'web.profile.birthdate_empty'); $form->addComponent($inputBirthdateDate, 'birthdate'); if ($this->user->isMember()) { @@ -71,29 +74,30 @@ public function create(User $user): Form $inputBirthdateDate->setDisabled(); } - $form->addText('email', 'web.profile.personal_details.email') + $form->addText('email', 'web.profile.email') ->setDisabled(); - $form->addText('phone', 'web.profile.personal_details.phone') + $form->addText('phone', 'web.profile.phone') ->setDisabled(); - $form->addText('street', 'web.profile.personal_details.street') - ->addRule(Form::FILLED, 'web.profile.personal_details.street_empty') - ->addRule(Form::PATTERN, 'web.profile.personal_details.street_format', '^(.*[^0-9]+) (([1-9][0-9]*)/)?([1-9][0-9]*[a-cA-C]?)$'); + $form->addText('street', 'web.profile.street') + ->addRule(Form::FILLED, 'web.profile.street_empty') + ->addRule(Form::PATTERN, 'web.profile.street_format', '^(.*[^0-9]+) (([1-9][0-9]*)/)?([1-9][0-9]*[a-cA-C]?)$'); - $form->addText('city', 'web.profile.personal_details.city') - ->addRule(Form::FILLED, 'web.profile.personal_details.city_empty'); + $form->addText('city', 'web.profile.city') + ->addRule(Form::FILLED, 'web.profile.city_empty'); - $form->addText('postcode', 'web.profile.personal_details.postcode') - ->addRule(Form::FILLED, 'web.profile.personal_details.postcode_empty') - ->addRule(Form::PATTERN, 'web.profile.personal_details.postcode_format', '^\d{3} ?\d{2}$'); + $form->addText('postcode', 'web.profile.postcode') + ->addRule(Form::FILLED, 'web.profile.postcode_empty') + ->addRule(Form::PATTERN, 'web.profile.postcode_format', '^\d{3} ?\d{2}$'); - $form->addText('state', 'web.profile.personal_details.state') - ->addRule(Form::FILLED, 'web.profile.personal_details.state_empty'); + $form->addText('state', 'web.profile.state') + ->addRule(Form::FILLED, 'web.profile.state_empty'); - $form->addSubmit('submit', 'web.profile.personal_details.update'); + $form->addSubmit('submit', 'web.profile.update_personal_details'); $form->setDefaults([ + 'id' => $id, 'sex' => $this->user->getSex(), 'firstName' => $this->user->getFirstName(), 'lastName' => $this->user->getLastName(), @@ -114,6 +118,8 @@ public function create(User $user): Form /** * Zpracuje formulář. + * + * @throws ORMException */ public function processForm(Form $form, stdClass $values): void { diff --git a/app/WebModule/Forms/RolesFormFactory.php b/app/WebModule/Forms/RolesFormFactory.php index a310718b4..76bc1eadc 100644 --- a/app/WebModule/Forms/RolesFormFactory.php +++ b/app/WebModule/Forms/RolesFormFactory.php @@ -8,10 +8,15 @@ use App\Model\Acl\Role; use App\Model\Enums\ApplicationState; use App\Model\Settings\Exceptions\SettingsItemNotFoundException; +use App\Model\Settings\Queries\SettingDateTimeValueQuery; +use App\Model\Settings\Settings; +use App\Model\User\Repositories\UserRepository; use App\Model\User\User; use App\Services\AclService; use App\Services\ApplicationService; +use App\Services\QueryBus; use App\Utils\Validators; +use DateTimeImmutable; use Nette; use Nette\Application\UI\Form; use Nette\Forms\Controls\MultiSelectBox; @@ -29,15 +34,17 @@ class RolesFormFactory /** * Přihlášený uživatel. */ - private User $user; + private User|null $user = null; public function __construct( - private readonly BaseFormFactory $baseFormFactory, - private readonly RoleRepository $roleRepository, - private readonly ApplicationService $applicationService, - private readonly Translator $translator, - private readonly Validators $validators, - private readonly AclService $aclService, + private BaseFormFactory $baseFormFactory, + private QueryBus $queryBus, + private UserRepository $userRepository, + private RoleRepository $roleRepository, + private ApplicationService $applicationService, + private Translator $translator, + private Validators $validators, + private AclService $aclService, ) { } @@ -47,19 +54,21 @@ public function __construct( * @throws SettingsItemNotFoundException * @throws Throwable */ - public function create(User $user): Form + public function create(int $id): Form { - $this->user = $user; + $this->user = $this->userRepository->findById($id); $form = $this->baseFormFactory->create(); - $rolesSelect = $form->addMultiSelect('roles', 'web.profile.seminar.roles.roles')->setItems( + $form->addHidden('id'); + + $rolesSelect = $form->addMultiSelect('roles', 'web.profile.roles')->setItems( $this->aclService->getRolesOptionsWithCapacity(true, true, $this->user), ) - ->addRule(Form::FILLED, 'web.profile.seminar.roles.roles_empty') - ->addRule([$this, 'validateRolesCapacities'], 'web.profile.seminar.roles.roles_capacity_occupied') - ->addRule([$this, 'validateRolesRegisterable'], 'web.profile.seminar.roles.roles_not_registerable') - ->addRule([$this, 'validateRolesMinimumAge'], 'web.profile.seminar.roles.roles_require_minimum_age') + ->addRule(Form::FILLED, 'web.profile.roles_empty') + ->addRule([$this, 'validateRolesCapacities'], 'web.profile.roles_capacity_occupied') + ->addRule([$this, 'validateRolesRegisterable'], 'web.profile.roles_not_registerable') + ->addRule([$this, 'validateRolesMinimumAge'], 'web.application_content.roles_require_minimum_age') ->setDisabled(! $this->applicationService->isAllowedEditRegistration($this->user)); foreach ($this->roleRepository->findFilteredRoles(true, false, true, $this->user) as $role) { @@ -67,7 +76,7 @@ public function create(User $user): Form $rolesSelect->addRule( [$this, 'validateRolesIncompatible'], $this->translator->translate( - 'web.profile.seminar.roles.incompatible_roles_selected', + 'web.profile.incompatible_roles_selected', null, ['role' => $role->getName(), 'incompatibleRoles' => $role->getIncompatibleRolesText()], ), @@ -79,7 +88,7 @@ public function create(User $user): Form $rolesSelect->addRule( [$this, 'validateRolesRequired'], $this->translator->translate( - 'web.profile.seminar.roles.required_roles_not_selected', + 'web.profile.required_roles_not_selected', null, ['role' => $role->getName(), 'requiredRoles' => $role->getRequiredRolesTransitiveText()], ), @@ -88,32 +97,51 @@ public function create(User $user): Form } } - $submitButton = $form->addSubmit('submit', 'web.profile.seminar.roles.change_roles'); + $submitButton = $form->addSubmit('submit', 'web.profile.change_roles'); - $cancelRegistrationButton = $form->addSubmit('cancelRegistration', 'web.profile.seminar.roles.cancel_registration') + $cancelRegistrationButton = $form->addSubmit('cancelRegistration', 'web.profile.cancel_registration') ->setHtmlAttribute('class', 'btn-danger'); if ($this->applicationService->isAllowedEditRegistration($this->user)) { $submitButton ->setHtmlAttribute('data-toggle', 'confirmation') - ->setHtmlAttribute('data-content', $form->getTranslator()->translate('web.profile.seminar.roles.change_roles_confirm')); + ->setHtmlAttribute('data-content', $form->getTranslator()->translate('web.profile.change_roles_confirm')); $cancelRegistrationButton ->setHtmlAttribute('data-toggle', 'confirmation') - ->setHtmlAttribute('data-content', $form->getTranslator()->translate('web.profile.seminar.roles.cancel_registration_confirm')); + ->setHtmlAttribute('data-content', $form->getTranslator()->translate('web.profile.cancel_registration_confirm')); } else { $submitButton ->setDisabled() ->setHtmlAttribute('data-toggle', 'tooltip') ->setHtmlAttribute('data-placement', 'bottom') - ->setHtmlAttribute('title', $form->getTranslator()->translate('web.profile.seminar.roles.change_roles_disabled')); + ->setHtmlAttribute('title', $form->getTranslator()->translate('web.profile.change_roles_disabled')); $cancelRegistrationButton ->setDisabled() ->setHtmlAttribute('data-toggle', 'tooltip') ->setHtmlAttribute('data-placement', 'bottom') - ->setHtmlAttribute('title', $form->getTranslator()->translate('web.profile.seminar.roles.cancel_registration_disabled')); + ->setHtmlAttribute('title', $form->getTranslator()->translate('web.profile.cancel_registration_disabled')); + } + + $ticketDownloadFrom = $this->queryBus->handle(new SettingDateTimeValueQuery(Settings::TICKETS_FROM)); + if ($ticketDownloadFrom !== null) { + $downloadTicketButton = $form->addSubmit('downloadTicket', 'web.profile.download_ticket') + ->setHtmlAttribute('class', 'btn-secondary'); + + if ( + $this->user->isInRole($this->roleRepository->findBySystemName(Role::NONREGISTERED)) + || ! $this->user->hasPaidEveryApplication() + || $ticketDownloadFrom > new DateTimeImmutable() + ) { + $downloadTicketButton + ->setDisabled() + ->setHtmlAttribute('data-toggle', 'tooltip') + ->setHtmlAttribute('data-placement', 'bottom') + ->setHtmlAttribute('title', $form->getTranslator()->translate('web.profile.download_ticket_disabled')); + } } $form->setDefaults([ + 'id' => $id, 'roles' => $this->roleRepository->findRolesIds($this->user->getRoles()), ]); $form->onSuccess[] = [$this, 'processForm']; @@ -128,10 +156,10 @@ public function create(User $user): Form */ public function processForm(Form $form, stdClass $values): void { - if ($form->isSubmitted() == $form['submit']) { + if ($form->isSubmitted() === $form['submit']) { $selectedRoles = $this->roleRepository->findRolesByIds($values->roles); $this->applicationService->updateRoles($this->user, $selectedRoles, $this->user); - } elseif ($form->isSubmitted() == $form['cancelRegistration']) { + } elseif ($form->isSubmitted() === $form['cancelRegistration']) { $this->applicationService->cancelRegistration($this->user, ApplicationState::CANCELED, $this->user); } } diff --git a/app/WebModule/Presenters/PagePresenter.php b/app/WebModule/Presenters/PagePresenter.php index 6c56480f2..d45647cc1 100644 --- a/app/WebModule/Presenters/PagePresenter.php +++ b/app/WebModule/Presenters/PagePresenter.php @@ -27,7 +27,6 @@ use App\WebModule\Components\IProgramsContentControlFactory; use App\WebModule\Components\ISlideshowContentControlFactory; use App\WebModule\Components\ITextContentControlFactory; -use App\WebModule\Components\ITicketContentControlFactory; use App\WebModule\Components\IUsersContentControlFactory; use App\WebModule\Components\LectorsContentControl; use App\WebModule\Components\NewsContentControl; @@ -36,7 +35,6 @@ use App\WebModule\Components\ProgramsContentControl; use App\WebModule\Components\SlideshowContentControl; use App\WebModule\Components\TextContentControl; -use App\WebModule\Components\TicketContentControl; use App\WebModule\Components\UsersContentControl; use Nette\Application\BadRequestException; use Nette\DI\Attributes\Inject; @@ -95,9 +93,6 @@ class PagePresenter extends WebBasePresenter #[Inject] public ISlideshowContentControlFactory $slideshowContentFactory; - #[Inject] - public ITicketContentControlFactory $ticketContentControlFactory; - /** * @throws BadRequestException * @throws Throwable @@ -211,9 +206,4 @@ protected function createComponentSlideshowContent(): SlideshowContentControl { return $this->slideshowContentFactory->create(); } - - protected function createComponentTicketContent(): TicketContentControl - { - return $this->ticketContentControlFactory->create(); - } } diff --git a/app/WebModule/Presenters/ProfilePresenter.php b/app/WebModule/Presenters/ProfilePresenter.php index 477d83c16..26e0b5a07 100644 --- a/app/WebModule/Presenters/ProfilePresenter.php +++ b/app/WebModule/Presenters/ProfilePresenter.php @@ -6,7 +6,6 @@ use App\Model\Enums\PaymentType; use App\Model\Settings\Exceptions\SettingsItemNotFoundException; -use App\Model\Settings\Queries\SettingDateTimeValueQuery; use App\Model\Settings\Queries\SettingStringValueQuery; use App\Model\Settings\Settings; use App\Model\Structure\Repositories\SubeventRepository; @@ -14,10 +13,9 @@ use App\Services\ApplicationService; use App\Services\Authenticator; use App\Services\ExcelExportService; +use App\Services\IMailService; use App\WebModule\Components\ApplicationsGridControl; use App\WebModule\Components\IApplicationsGridControlFactory; -use App\WebModule\Components\ITicketControlFactory; -use App\WebModule\Components\TicketControl; use App\WebModule\Forms\AdditionalInformationFormFactory; use App\WebModule\Forms\PersonalDetailsFormFactory; use App\WebModule\Forms\RolesFormFactory; @@ -45,15 +43,15 @@ class ProfilePresenter extends WebBasePresenter #[Inject] public IApplicationsGridControlFactory $applicationsGridControlFactory; - #[Inject] - public ITicketControlFactory $ticketControlFactory; - #[Inject] public ExcelExportService $excelExportService; #[Inject] public SubeventRepository $subeventRepository; + #[Inject] + public IMailService $mailService; + #[Inject] public ApplicationService $applicationService; @@ -83,9 +81,8 @@ public function renderDefault(): void $this->template->pageName = $this->translator->translate('web.profile.title'); $this->template->paymentMethodBank = PaymentType::BANK; $this->template->isAllowedEditCustomInputs = $this->applicationService->isAllowedEditCustomInputs(); - $this->template->userPrograms = $this->queryBus->handle(new UserAttendsProgramsQuery($this->dbUser)); + $this->template->userPrograms = $this->queryBus->handle(new UserAttendsProgramsQuery($this->dbuser)); $this->template->accountNumber = $this->queryBus->handle(new SettingStringValueQuery(Settings::ACCOUNT_NUMBER)); - $this->template->ticketsActive = $this->queryBus->handle(new SettingDateTimeValueQuery(Settings::TICKETS_FROM)) !== null; } /** @@ -96,36 +93,33 @@ public function renderDefault(): void */ public function actionExportSchedule(): void { - $response = $this->excelExportService->exportUserSchedule($this->dbUser, 'harmonogram.xlsx'); + $user = $this->userRepository->findById($this->user->id); + $response = $this->excelExportService->exportUserSchedule($user, 'harmonogram.xlsx'); $this->sendResponse($response); } protected function createComponentPersonalDetailsForm(): Form { - $form = $this->personalDetailsFormFactory->create($this->dbUser); + $form = $this->personalDetailsFormFactory->create($this->user->id); $form->onSuccess[] = function (Form $form, stdClass $values): void { - $this->flashMessage('web.profile.personal_details.update_successful', 'success'); + $this->flashMessage('web.profile.personal_details_update_successful', 'success'); $this->redirect('this#personal-details'); }; $this->personalDetailsFormFactory->onSkautIsError[] = function (): void { - $this->flashMessage('web.profile.personal_details.synchronization_failed', 'danger'); + $this->flashMessage('web.profile.personal_details_synchronization_failed', 'danger'); }; return $form; } - /** - * @throws Throwable - * @throws SettingsItemNotFoundException - */ protected function createComponentAdditionalInformationForm(): Form { - $form = $this->additionalInformationFormFactory->create($this->dbUser); + $form = $this->additionalInformationFormFactory->create($this->user->id); $form->onSuccess[] = function (): void { - $this->flashMessage('web.profile.additional_information.update_successfull', 'success'); + $this->flashMessage('web.profile.additional_information_update_successfull', 'success'); $this->redirect('this#additional-information'); }; @@ -138,13 +132,15 @@ protected function createComponentAdditionalInformationForm(): Form */ protected function createComponentRolesForm(): Form { - $form = $this->rolesFormFactory->create($this->dbUser); + $form = $this->rolesFormFactory->create($this->user->id); $form->onSuccess[] = function (Form $form, stdClass $values): void { - if ($form->isSubmitted() == $form['submit']) { - $this->flashMessage('web.profile.roles.roles_changed', 'success'); - } elseif ($form->isSubmitted() == $form['cancelRegistration']) { - $this->flashMessage('web.profile.roles.registration_canceled', 'success'); + if ($form->isSubmitted() === $form['submit']) { + $this->flashMessage('web.profile.roles_changed', 'success'); + } elseif ($form->isSubmitted() === $form['cancelRegistration']) { + $this->flashMessage('web.profile.registration_canceled', 'success'); + } elseif ($form->isSubmitted() === $form['downloadTicket']) { + $this->redirect(':Export:Ticket:pdf'); } $this->authenticator->updateRoles($this->user); @@ -158,9 +154,4 @@ protected function createComponentApplicationsGrid(): ApplicationsGridControl { return $this->applicationsGridControlFactory->create(); } - - protected function createComponentTicket(): TicketControl - { - return $this->ticketControlFactory->create(); - } } diff --git a/app/WebModule/Presenters/WebBasePresenter.php b/app/WebModule/Presenters/WebBasePresenter.php index 78260bdae..5b1033015 100644 --- a/app/WebModule/Presenters/WebBasePresenter.php +++ b/app/WebModule/Presenters/WebBasePresenter.php @@ -51,7 +51,7 @@ abstract class WebBasePresenter extends BasePresenter #[Inject] public SkautIsService $skautIsService; - protected User|null $dbUser = null; + protected User|null $dbuser = null; /** * @throws AbortException @@ -69,7 +69,7 @@ public function startup(): void $this->user->setAuthorizator($this->authorizator); - $this->dbUser = $this->user->isLoggedIn() ? $this->userRepository->findById($this->user->id) : null; + $this->dbuser = $this->user->isLoggedIn() ? $this->userRepository->findById($this->user->id) : null; } /** @@ -80,7 +80,7 @@ public function beforeRender(): void { parent::beforeRender(); - $this->template->dbUser = $this->dbUser; + $this->template->dbuser = $this->dbuser; $this->template->backlink = $this->getHttpRequest()->getUrl()->getPath(); @@ -109,11 +109,6 @@ public function actionExitRoleTest(): void $this->redirect(':Admin:Acl:default'); } - public function getDbUser(): User|null - { - return $this->dbUser; - } - /** * Zkontroluje stav instalace. * diff --git a/app/WebModule/Presenters/templates/Member/default.latte b/app/WebModule/Presenters/templates/Member/default.latte index c5c68fcb4..a70bb0dad 100644 --- a/app/WebModule/Presenters/templates/Member/default.latte +++ b/app/WebModule/Presenters/templates/Member/default.latte @@ -11,7 +11,7 @@

    {_web.member.text_info}

    {_web.member.text_instructions}

    -

    {_web.member.text_details, ['username' => $dbUser->getUsername(), 'securityCode' => $dbUser->getSecurityCode()]|noescape}

    +

    {_web.member.text_details, ['username' => $dbuser->getUsername(), 'securityCode' => $dbuser->getSecurityCode()]|noescape}

    {_web.member.text_note}

    diff --git a/app/WebModule/Presenters/templates/Profile/default.latte b/app/WebModule/Presenters/templates/Profile/default.latte index 63ccdd49a..b3a9541a4 100644 --- a/app/WebModule/Presenters/templates/Profile/default.latte +++ b/app/WebModule/Presenters/templates/Profile/default.latte @@ -11,59 +11,97 @@
    - {_web.profile.seminar.attendance} + {_web.profile.attendance}
    - {if $dbUser->isInRole($nonregisteredRole)} - {_web.profile.seminar.nonregistered} - {elseif !$dbUser->isApproved()} - {_web.profile.seminar.unapproved} + {if $dbuser->isInRole($nonregisteredRole)} + {_web.profile.nonregistered} + {elseif !$dbuser->isApproved()} + {_web.profile.unapproved} {else} - {foreach $dbUser->getRoles() as $role}{$role->getName()}{sep}, {/sep}{/foreach} + {foreach $dbuser->getRoles() as $role}{$role->getName()}{sep}, {/sep}{/foreach} {/if}
    -
    +
    - {_web.profile.seminar.account_number} + {_web.profile.account_number}
    {$accountNumber}
    - - {_web.profile.seminar.roles.heading}
    {control rolesForm}
    - - {_web.profile.seminar.applications.heading}
    {control applicationsGrid}
    +
    +
    +
    + +
    +
    +
    {_web.profile.personal_details_group}
    + +
    +
    +
    +
    +
    + {_web.profile.photo} +
    +
    + user photo +
    +
    +
    +
    + {control personalDetailsForm} +
    +
    +
    +
    +
    - {if $ticketsActive} - {_web.profile.seminar.ticket.heading} - {control ticket} - {/if} +
    +
    +
    {_web.profile.additional_information_group}
    + +
    +
    +
    +
    +
    +
    + {_web.profile.additional_information_edit_not_allowed} +
    +
    +
    +
    +
    + {control additionalInformationForm} +
    +
    -

    {_web.profile.schedule.group_heading}

    +
    {_web.profile.my_schedule_group}
    @@ -71,7 +109,7 @@
    {if $userPrograms->isEmpty()} -

    {_web.profile.schedule.no_programs}

    +

    {_web.profile.no_programs}

    {else}
    @@ -79,23 +117,23 @@ - - - - - + + + + + @@ -110,17 +148,17 @@
    - -
    -
    -

    {_web.profile.personal_details.group_heading}

    - -
    -
    -
    -
    -
    - {_web.profile.personal_details.photo} -
    -
    - user photo -
    -
    -
    -
    - {control personalDetailsForm} -
    -
    -
    -
    -
    - -
    -
    -

    {_web.profile.additional_information.group_heading}

    - -
    -
    -
    -
    -
    -
    - {_web.profile.additional_information.edit_not_allowed} -
    -
    -
    -
    -
    - {control additionalInformationForm} -
    -
    -
    -
    -
    {/block} diff --git a/app/WebModule/Presenters/templates/includes/user_menu.latte b/app/WebModule/Presenters/templates/includes/user_menu.latte index 00d1db72d..dc23d8ecb 100644 --- a/app/WebModule/Presenters/templates/includes/user_menu.latte +++ b/app/WebModule/Presenters/templates/includes/user_menu.latte @@ -3,13 +3,13 @@
    {_web.common.logged_in_user} - {$dbUser->getUsername()} + {$dbuser->getUsername()} {_web.common.logged_in_roles, count($user->roles)} {foreach $user->roles as $role}{if $role !== $testRole}{$role}{sep}, {/sep}{/if}{/foreach} - + {_web.member.name}
    diff --git a/app/assets/admin/main.js b/app/assets/admin/main.js index e0087a355..a00013b33 100644 --- a/app/assets/admin/main.js +++ b/app/assets/admin/main.js @@ -7,13 +7,13 @@ import tinymce from 'tinymce'; import 'tinymce/themes/silver'; import 'tinymce/skins/ui/oxide/skin.css' import 'tinymce-i18n/langs/cs'; -import 'tinymce/models/dom' import 'tinymce/icons/default/icons'; import 'tinymce/plugins/autolink'; import 'tinymce/plugins/lists'; import 'tinymce/plugins/link'; import 'tinymce/plugins/code'; import 'tinymce/plugins/fullscreen'; +import 'tinymce/plugins/paste'; import contentUiCss from '!!raw-loader!tinymce/skins/ui/oxide/content.css'; import contentCss from '!!raw-loader!tinymce/skins/content/default/content.css'; @@ -26,7 +26,7 @@ tinymce.init({ skin: false, content_css: false, content_style: contentUiCss.toString() + '\n' + contentCss.toString(), - plugins: 'autolink lists link code fullscreen', + plugins: 'autolink lists link code fullscreen paste', toolbar: 'undo redo | bold italic | bullist numlist | link unlink | code | fullscreen', paste_auto_cleanup_on_paste: true, convert_urls : false, @@ -42,8 +42,8 @@ tinymce.init({ skin: false, content_css: false, content_style: contentUiCss.toString() + '\n' + contentCss.toString(), - plugins: 'autolink lists link code fullscreen', - toolbar: 'undo redo | blocks | bold italic | bullist numlist | link unlink | code | fullscreen', + plugins: 'autolink lists link code fullscreen paste', + toolbar: 'undo redo | formatselect | bold italic | bullist numlist | link unlink | code | fullscreen', paste_auto_cleanup_on_paste: true, convert_urls : false, relative_urls: false, diff --git a/app/config/common.neon b/app/config/common.neon index 050254868..f0487878d 100644 --- a/app/config/common.neon +++ b/app/config/common.neon @@ -103,8 +103,6 @@ translation: fallback: [cs] dirs: - %appDir%/lang - localeResolvers: - - Contributte\Translation\LocalesResolvers\Router messenger: buses: @@ -119,9 +117,6 @@ latte: macros: - Nextras\FormsRendering\LatteMacros\Bs3InputMacros::install -tracy: - maxDepth: 3 - forms: messages: MAX_FILE_SIZE: 'Velikost nahraného souboru může být nejvýše %d bytů.' diff --git a/app/config/production.local.neon b/app/config/production.local.neon index 7aca6b571..84a8177cf 100644 --- a/app/config/production.local.neon +++ b/app/config/production.local.neon @@ -20,11 +20,6 @@ mail: password: "__CONFIG_MAIL_PASSWORD__" secure: __CONFIG_MAIL_SECURE__ -mailing: - mails: [ - senderEmail: "__CONFIG_MAILING_SENDER_EMAIL__" - ] - recaptcha: siteKey: "__CONFIG_RECAPTCHA_SITE_KEY__" secretKey: "__CONFIG_RECAPTCHA_SECRET_KEY__" diff --git a/app/config/sample.local.neon b/app/config/sample.local.neon index c0b2c8bed..e621a714b 100644 --- a/app/config/sample.local.neon +++ b/app/config/sample.local.neon @@ -24,11 +24,6 @@ mail: password: "" secure: -mailing: - mails: [ - senderEmail: srs@skaut.cz - ] - recaptcha: siteKey: "" secretKey: "" diff --git a/app/lang/admin.cs_CZ.neon b/app/lang/admin.cs_CZ.neon index 1b4de5a09..f718748e0 100644 --- a/app/lang/admin.cs_CZ.neon +++ b/app/lang/admin.cs_CZ.neon @@ -40,6 +40,7 @@ menu: payments: "Platby" acl: "Role" mailing: "Mailing" + groups: "Skupiny" configuration: "Nastavení" help: "Nápověda" @@ -625,12 +626,25 @@ mailing: heading: "Historie" datetime: "Odesláno" subject: "Předmět" - recipient_users: "Příjemci - uživatelé" recipient_roles: "Příjemci - role" recipient_subevents: "Příjemci - podakce" - recipient_emails: "Příjemci - e-maily" + recipient_users: "Příjemci - uživatelé" automatic: "Automatický" +groups: + menu: + statuses: "Statusy" + groups: "Skupiny" + + status: + heading: "Statusy" + + group: + heading: "Skupiny" + + column: + name: "Název" + configuration: menu: seminar: "Seminář" @@ -641,6 +655,7 @@ configuration: place: "Místo" mailing: "Mailing" skautis: "SkautIS" + group: "Skupinová registrace" web: "Web" system: "Systém" subevents: "Podakce" @@ -818,10 +833,16 @@ configuration: place_points_saved: "Mapový bod byl úspěšně uložen." mailing_heading: "Mailing" + mailing_email: "E-mail pro mailing" + mailing_email_empty: "Zadejte e-mail." + mailing_email_format: "Zadejte e-mail ve správném formátu." mailing_contact_form_recipients: "E-maily pro zaslání zpráv z kontaktního formuláře" mailing_contact_form_recipients_empty: "Zadete alespoň jeden e-mail." mailing_contact_form_recipients_format: "Zadejte e-mailové adresy oddělené čárkou." mailing_contact_form_guests_allowed: "povolit kontaktní formulář pro nepřihlášené uživatele" + mailing_email_verification_needed: "Změna e-mailu čeká na ověření. Ověřit ji můžete pomocí odkazu zaslaného na nový e-mail." + mailing_email_verification_successful: "E-mail byl úspěšně ověřen." + mailing_email_verification_error: "E-mail se nepodařilo ověřit." skautis_event_heading: "Propojení s akcí ve skautIS" skautis_event_type: "Typ skautIS akce" @@ -839,6 +860,11 @@ configuration: skautis_event_education_skaut_is_courses: "Propojené skautIS kurzy" skautis_event_education_connection_saved: "Propojení se skautIS kurzy bylo úspěšně uloženo." + group_heading: "Nastavení skupin" + group_min_members: "Minimální počet členů" + group_max_members: "Maximální počet členů" + group_fill_term: "Termín pro naplnění skupiny členy" + web_heading: "Web" web_logo: "Logo" web_logo_format: "Logo musí být ve formátu JPG, PNG nebo GIF." diff --git a/app/lang/common.cs_CZ.neon b/app/lang/common.cs_CZ.neon index 525c31ce5..8ccf0c5e1 100644 --- a/app/lang/common.cs_CZ.neon +++ b/app/lang/common.cs_CZ.neon @@ -46,7 +46,6 @@ content: organizer: "Pořadatel" contact_form: "Kontaktní formulář" slideshow: "Slideshow" - ticket: "Vstupenka" default_heading: text: "" @@ -65,7 +64,6 @@ content: organizer: "Pořadatel" contact_form: "Kontaktní formulář" slideshow: "" - ticket: "Vstupenka" area: main: "Hlavní oblast" diff --git a/app/lang/web.cs_CZ.neon b/app/lang/web.cs_CZ.neon index 9b907d6c4..ea0e9b613 100644 --- a/app/lang/web.cs_CZ.neon +++ b/app/lang/web.cs_CZ.neon @@ -25,104 +25,95 @@ profile: title: "Můj profil" heading: "Můj profil" - seminar: - group_heading: "Účast na semináři" - attendance: "Účastním se jako" - nonregistered: "Neúčastníte se" - unapproved: "Vaše registrace zatím nebyla potvrzena" - account_number: "Poplatek uhraďte na účet" + seminar_group: "Seminář" + attendance: "Účast na semináři" + nonregistered: "Neúčastníte se" + unapproved: "Vaše registrace zatím nebyla potvrzena" + account_number: "Poplatek uhraďte na účet" - roles: - heading: "Role" - roles: "Role" - required_roles_not_selected: "K roli %role% musíte mít vybrané role: %requiredRoles%." - incompatible_roles_selected: "Není možné kombinovat roli %role% s rolemi: %incompatibleRoles%." - roles_empty: "Musí být vybrána alespoň jedna role." - roles_not_registerable: "Registrace do některé z rolí již není možná." - roles_capacity_occupied: "Všechna místa v některé roli jsou obsazena." - roles_require_minimum_age: "Některá role vyžaduje vyšší věk." - change_roles: "Změnit role" - change_roles_confirm: "Pokud nová role vyžaduje schválení organizátora, budete Vám nastavena role \"Neschválený\". Opravdu chcete pokračovat?" - change_roles_disabled: "Změna rolí již není možná nebo nejste na seminář registrováni." - roles_changed: "Role byly úspěšně změněny." - cancel_registration: "Odhlásit se ze semináře" - cancel_registration_confirm: "Opravdu se chcete odhlásit z celého semináře?" - cancel_registration_disabled: "Odhlášení již není možné nebo nejste na seminář registrováni." - registration_canceled: "Odhlášení ze semináře proběhlo úspěšně." - - applications: - heading: "Přihlášky" - application_date: "Datum přihlášky" - roles: "Role" - subevents: "Podakce" - required_subevents_not_selected: "K podakci %subevent% musíte mít vybrané podakce: %requiredSubevents%." - incompatible_subevents_selected: "Není možné kombinovat podakci %subevent% s podakcemi: %incompatibleSubevents%." - subevents_empty: "Musí být vybrána alespoň jedna podakce." - subevents_capacity_occupied: "Všechna místa na některé podakci jsou obsazena." - fee: "Poplatek" - variable_symbol: "Variabilní symbol" - maturity_date: "Splatnost" - state: "Stav" - add_subevents: "Přidat podakce" - add_subevents_successful: "Podakce byly úspěšně přidány." - edit: "Upravit přihlášku" - edit_successful: "Přihláška byla úspěšně upravena." - cancel_application: "Zrušit přihlášku" - cancel_application_confirm: "Opravdu chcete zrušit dodatečnou přihlášku?" - application_canceled: "Dodatečná přihláška byla úspěšně zrušena." - download_payment_proof: "Stáhnout potvrzení" - pay: "Zaplatit" - account: "Číslo účtu" - - ticket: - heading: "Vstupenka" - - schedule: - group_heading: "Můj harmonogram semináře" - from: "Od" - to: "Do" - program_name: "Program" - room: "Místnost" - lectors: "Lektoři" - no_programs: "Nemáte zvolené žádné programy." - download_schedule_excel: "Stáhnout harmonogram (XLSX)" - download_schedule_ical: "Stáhnout harmonogram (ICS)" - download_schedule_ical_copy: "Kopírovat URL kalendáře" - - personal_details: - group_heading: "Osobní údaje" - photo: "Fotka" - sex: "Pohlaví" - firstname: "Jméno" - firstname_empty: "Zadejte jméno." - lastname: "Příjmení" - lastname_empty: "Zadejte příjmení." - nickname: "Přezdívka" - email: "E-mail" - phone: "Telefon" - birthdate: "Datum narození" - birthdate_empty: "Zadejte datum narození." - street: "Ulice" - street_empty: "Zadejte ulici." - street_format: "Zadejte ulici ve správném formátu." - city: "Město" - city_empty: "Zadejte město." - postcode: "PSČ" - postcode_empty: "Zadejte PSČ." - postcode_format: "Zadejte PSČ ve správném formátu." - state: "Stát" - state_empty: "Zadejte stát." - update: "Aktualizovat údaje a uložit do skautISu" - synchronization_failed: "Synchronizace se skautIS se nepodařila. Zkuste se znovu přihlásit." - update_successful: "Osobní údaje úspěšně aktualizovány." + roles: "Role" + required_roles_not_selected: "K roli %role% musíte mít vybrané role: %requiredRoles%." + incompatible_roles_selected: "Není možné kombinovat roli %role% s rolemi: %incompatibleRoles%." + roles_empty: "Musí být vybrána alespoň jedna role." + roles_not_registerable: "Registrace do některé z rolí již není možná." + roles_capacity_occupied: "Všechna místa v některé roli jsou obsazena." + roles_require_minimum_age: "Některá role vyžaduje vyšší věk." + change_roles: "Změnit role" + change_roles_confirm: "Pokud nová role vyžaduje schválení organizátora, budete Vám nastavena role \"Neschválený\". Opravdu chcete pokračovat?" + change_roles_disabled: "Změna rolí již není možná nebo nejste na seminář registrováni." + roles_changed: "Role byly úspěšně změněny." + cancel_registration: "Odhlásit se ze semináře" + cancel_registration_confirm: "Opravdu se chcete odhlásit z celého semináře?" + cancel_registration_disabled: "Odhlášení již není možné nebo nejste na seminář registrováni." + registration_canceled: "Odhlášení ze semináře proběhlo úspěšně." + download_ticket: "Stáhnout vstupenku" + download_ticket_disabled: "Stahování vstupenek ještě není povoleno, nejste na seminář registrováni nebo chybí zaplatit některou přihlášku." + + applications_application_date: "Datum přihlášky" + applications_roles: "Role" + applications_subevents: "Podakce" + applications_required_subevents_not_selected: "K podakci %subevent% musíte mít vybrané podakce: %requiredSubevents%." + applications_incompatible_subevents_selected: "Není možné kombinovat podakci %subevent% s podakcemi: %incompatibleSubevents%." + applications_subevents_empty: "Musí být vybrána alespoň jedna podakce." + applications_subevents_capacity_occupied: "Všechna místa na některé podakci jsou obsazena." + applications_fee: "Poplatek" + applications_variable_symbol: "Variabilní symbol" + applications_maturity_date: "Splatnost" + applications_state: "Stav" + applications_add_subevents: "Přidat podakce" + applications_add_subevents_successful: "Podakce byly úspěšně přidány." + applications_edit: "Upravit přihlášku" + applications_edit_successful: "Přihláška byla úspěšně upravena." + applications_cancel_application: "Zrušit přihlášku" + applications_cancel_application_confirm: "Opravdu chcete zrušit dodatečnou přihlášku?" + applications_application_canceled: "Dodatečná přihláška byla úspěšně zrušena." + applications_download_payment_proof: "Stáhnout potvrzení" + applications_pay: "Zaplatit" + applications_account: "Číslo účtu" + + personal_details_group: "Osobní údaje" + photo: "Fotka" + sex: "Pohlaví" + firstname: "Jméno" + firstname_empty: "Zadejte jméno." + lastname: "Příjmení" + lastname_empty: "Zadejte příjmení." + nickname: "Přezdívka" + email: "E-mail" + phone: "Telefon" + birthdate: "Datum narození" + birthdate_empty: "Zadejte datum narození." + street: "Ulice" + street_empty: "Zadejte ulici." + street_format: "Zadejte ulici ve správném formátu." + city: "Město" + city_empty: "Zadejte město." + postcode: "PSČ" + postcode_empty: "Zadejte PSČ." + postcode_format: "Zadejte PSČ ve správném formátu." + state: "Stát" + state_empty: "Zadejte stát." + update_personal_details: "Aktualizovat údaje a uložit do skautISu" + personal_details_synchronization_failed: "Synchronizace se skautIS se nepodařila. Zkuste se znovu přihlásit." + personal_details_update_successful: "Osobní údaje úspěšně aktualizovány." - additional_information: - group_heading: "Doplňující informace" - custom_input_empty: "Pole je povinné." - about_me: "O mně" - update: "Upravit doplňující informace" - update_successfull: "Doplňující informace úspěšně upraveny." - edit_not_allowed: "Úprava údajů z přihlášky již není povolena." + additional_information_group: "Doplňující informace" + custom_input_empty: "Pole je povinné." + about_me: "O mně" + update_additional_information: "Upravit doplňující informace" + additional_information_update_successfull: "Doplňující informace úspěšně upraveny." + additional_information_edit_not_allowed: "Úprava údajů z přihlášky již není povolena." + + my_schedule_group: "Můj harmonogram semináře" + from: "Od" + to: "Do" + program_name: "Program" + room: "Místnost" + lectors: "Lektoři" + no_programs: "Nemáte zvolené žádné programy." + download_schedule_excel: "Stáhnout harmonogram (XLSX)" + download_schedule_ical: "Stáhnout harmonogram (ICS)" + download_schedule_ical_copy: "Kopírovat URL kalendáře" member: name: "Nepropojený účet člena" @@ -182,6 +173,14 @@ application_content: register_synchronization_failed: "Synchronizace se skautIS se nepodařila. Zkuste se znovu přihlásit a upravit údaje v profilu." register_successful: "Registrace byla úspěšně odeslána." + application_date: "Datum přihlášky" + application_roles: "Role" + application_subevents: "Podakce" + application_fee: "Poplatek" + application_variable_symbol: "Variabilní symbol" + application_maturity_date: "Splatnost" + application_state: "Stav" + blocks_content: uncategorized: "Nezařazené" categories: "Kategorie" @@ -245,22 +244,3 @@ contact_form_content: login_required_begin: "Pro použití kontaktního formuláře se musíte nejprve" login_required_link: "přihlásit přes skautIS" login_required_end: "." - -ticket_content: - login_required_begin: "Pro zobrazení vstupenky se musíte nejprve" - login_required_link: "přihlásit přes skautIS" - login_required_end: "." - no_membership_and_photo_begin: "Nemáte" - no_membership_and_photo_link_1: "propojený skautIS účet" - no_membership_and_photo_middle: "a nahranou" - no_membership_and_photo_link_2: "fotku ve skautIS" - no_membership_and_photo_end: "." - no_membership_begin: "Nemáte" - no_membership_link: "propojený skautIS účet" - no_membership_end: "." - no_photo_begin: "Nemáte nahranou" - no_photo_link: "fotku ve skautIS" - no_photo_end: "." - not_available: "Zobrazení vstupenek ještě není povoleno." - not_registered_or_paid: "Zobrazení vstupenky je možné až po přihlášení na seminář, schválení registrace a uhrazení poplatku za všechny podakce." - download_ticket: "Stáhnout vstupenku (PDF)" diff --git a/migrations/Version20170301173409.php b/migrations/Version20170301173409.php index e3f7d2227..128f795b7 100644 --- a/migrations/Version20170301173409.php +++ b/migrations/Version20170301173409.php @@ -11,6 +11,9 @@ use function preg_split; use function trim; +/** + * Auto-generated Migration: Please modify to your needs! + */ class Version20170301173409 extends AbstractMigration { public function up(Schema $schema): void diff --git a/migrations/Version20170331220954.php b/migrations/Version20170331220954.php index 2c4a34357..5b7f1f5f7 100644 --- a/migrations/Version20170331220954.php +++ b/migrations/Version20170331220954.php @@ -11,6 +11,9 @@ use function preg_split; use function trim; +/** + * Auto-generated Migration: Please modify to your needs! + */ class Version20170331220954 extends AbstractMigration { public function up(Schema $schema): void diff --git a/migrations/Version20170701074222.php b/migrations/Version20170701074222.php index 507cb55eb..c443844b5 100644 --- a/migrations/Version20170701074222.php +++ b/migrations/Version20170701074222.php @@ -7,6 +7,9 @@ use Doctrine\DBAL\Schema\Schema; use Doctrine\Migrations\AbstractMigration; +/** + * Auto-generated Migration: Please modify to your needs! + */ class Version20170701074222 extends AbstractMigration { public function up(Schema $schema): void diff --git a/migrations/Version20170706101111.php b/migrations/Version20170706101111.php index 1f105d485..febe542ee 100644 --- a/migrations/Version20170706101111.php +++ b/migrations/Version20170706101111.php @@ -7,6 +7,9 @@ use Doctrine\DBAL\Schema\Schema; use Doctrine\Migrations\AbstractMigration; +/** + * Auto-generated Migration: Please modify to your needs! + */ class Version20170706101111 extends AbstractMigration { public function up(Schema $schema): void diff --git a/migrations/Version20170810151002.php b/migrations/Version20170810151002.php index 148cd3ad0..ff00689e6 100644 --- a/migrations/Version20170810151002.php +++ b/migrations/Version20170810151002.php @@ -7,6 +7,9 @@ use Doctrine\DBAL\Schema\Schema; use Doctrine\Migrations\AbstractMigration; +/** + * Auto-generated Migration: Please modify to your needs! + */ class Version20170810151002 extends AbstractMigration { public function up(Schema $schema): void diff --git a/migrations/Version20170817213443.php b/migrations/Version20170817213443.php index 7aca663f1..1fb2cfa78 100644 --- a/migrations/Version20170817213443.php +++ b/migrations/Version20170817213443.php @@ -7,6 +7,9 @@ use Doctrine\DBAL\Schema\Schema; use Doctrine\Migrations\AbstractMigration; +/** + * Auto-generated Migration: Please modify to your needs! + */ class Version20170817213443 extends AbstractMigration { public function up(Schema $schema): void diff --git a/migrations/Version20170819062708.php b/migrations/Version20170819062708.php index 192a51be5..4fe2e81ae 100644 --- a/migrations/Version20170819062708.php +++ b/migrations/Version20170819062708.php @@ -7,6 +7,9 @@ use Doctrine\DBAL\Schema\Schema; use Doctrine\Migrations\AbstractMigration; +/** + * Auto-generated Migration: Please modify to your needs! + */ class Version20170819062708 extends AbstractMigration { public function up(Schema $schema): void diff --git a/migrations/Version20170819111505.php b/migrations/Version20170819111505.php index 9c9c66aaf..a74568a5c 100644 --- a/migrations/Version20170819111505.php +++ b/migrations/Version20170819111505.php @@ -7,6 +7,9 @@ use Doctrine\DBAL\Schema\Schema; use Doctrine\Migrations\AbstractMigration; +/** + * Auto-generated Migration: Please modify to your needs! + */ class Version20170819111505 extends AbstractMigration { public function up(Schema $schema): void diff --git a/migrations/Version20170822195233.php b/migrations/Version20170822195233.php index ae5c9b36b..0ad8944ec 100644 --- a/migrations/Version20170822195233.php +++ b/migrations/Version20170822195233.php @@ -7,6 +7,9 @@ use Doctrine\DBAL\Schema\Schema; use Doctrine\Migrations\AbstractMigration; +/** + * Auto-generated Migration: Please modify to your needs! + */ class Version20170822195233 extends AbstractMigration { public function up(Schema $schema): void diff --git a/migrations/Version20170823134902.php b/migrations/Version20170823134902.php index 16459eaf8..7798a6221 100644 --- a/migrations/Version20170823134902.php +++ b/migrations/Version20170823134902.php @@ -7,6 +7,9 @@ use Doctrine\DBAL\Schema\Schema; use Doctrine\Migrations\AbstractMigration; +/** + * Auto-generated Migration: Please modify to your needs! + */ class Version20170823134902 extends AbstractMigration { public function up(Schema $schema): void diff --git a/migrations/Version20170823205705.php b/migrations/Version20170823205705.php index 2b69d743f..62c3a8348 100644 --- a/migrations/Version20170823205705.php +++ b/migrations/Version20170823205705.php @@ -7,6 +7,9 @@ use Doctrine\DBAL\Schema\Schema; use Doctrine\Migrations\AbstractMigration; +/** + * Auto-generated Migration: Please modify to your needs! + */ class Version20170823205705 extends AbstractMigration { public function up(Schema $schema): void diff --git a/migrations/Version20170827194801.php b/migrations/Version20170827194801.php index 51b211140..a04b9d91d 100644 --- a/migrations/Version20170827194801.php +++ b/migrations/Version20170827194801.php @@ -7,6 +7,9 @@ use Doctrine\DBAL\Schema\Schema; use Doctrine\Migrations\AbstractMigration; +/** + * Auto-generated Migration: Please modify to your needs! + */ class Version20170827194801 extends AbstractMigration { public function up(Schema $schema): void diff --git a/migrations/Version20170828131201.php b/migrations/Version20170828131201.php index f1698f746..8c799eca7 100644 --- a/migrations/Version20170828131201.php +++ b/migrations/Version20170828131201.php @@ -7,6 +7,9 @@ use Doctrine\DBAL\Schema\Schema; use Doctrine\Migrations\AbstractMigration; +/** + * Auto-generated Migration: Please modify to your needs! + */ class Version20170828131201 extends AbstractMigration { public function up(Schema $schema): void diff --git a/migrations/Version20170828220102.php b/migrations/Version20170828220102.php index 669fd2eb5..3dd21446c 100644 --- a/migrations/Version20170828220102.php +++ b/migrations/Version20170828220102.php @@ -7,6 +7,9 @@ use Doctrine\DBAL\Schema\Schema; use Doctrine\Migrations\AbstractMigration; +/** + * Auto-generated Migration: Please modify to your needs! + */ class Version20170828220102 extends AbstractMigration { public function up(Schema $schema): void diff --git a/migrations/Version20170904190024.php b/migrations/Version20170904190024.php index 0c93752fc..2c37d6831 100644 --- a/migrations/Version20170904190024.php +++ b/migrations/Version20170904190024.php @@ -7,6 +7,9 @@ use Doctrine\DBAL\Schema\Schema; use Doctrine\Migrations\AbstractMigration; +/** + * Auto-generated Migration: Please modify to your needs! + */ class Version20170904190024 extends AbstractMigration { public function up(Schema $schema): void diff --git a/migrations/Version20170910192824.php b/migrations/Version20170910192824.php index 5fff3e939..6430cc4da 100644 --- a/migrations/Version20170910192824.php +++ b/migrations/Version20170910192824.php @@ -7,6 +7,9 @@ use Doctrine\DBAL\Schema\Schema; use Doctrine\Migrations\AbstractMigration; +/** + * Auto-generated Migration: Please modify to your needs! + */ class Version20170910192824 extends AbstractMigration { public function up(Schema $schema): void diff --git a/migrations/Version20170910214958.php b/migrations/Version20170910214958.php index 5afd845f7..472e6358c 100644 --- a/migrations/Version20170910214958.php +++ b/migrations/Version20170910214958.php @@ -7,6 +7,9 @@ use Doctrine\DBAL\Schema\Schema; use Doctrine\Migrations\AbstractMigration; +/** + * Auto-generated Migration: Please modify to your needs! + */ class Version20170910214958 extends AbstractMigration { public function up(Schema $schema): void diff --git a/migrations/Version20170912153411.php b/migrations/Version20170912153411.php index 3d17f70a9..51d4f5058 100644 --- a/migrations/Version20170912153411.php +++ b/migrations/Version20170912153411.php @@ -7,6 +7,9 @@ use Doctrine\DBAL\Schema\Schema; use Doctrine\Migrations\AbstractMigration; +/** + * Auto-generated Migration: Please modify to your needs! + */ class Version20170912153411 extends AbstractMigration { public function up(Schema $schema): void diff --git a/migrations/Version20170912210547.php b/migrations/Version20170912210547.php index fafa0b86e..0fa3d7bd8 100644 --- a/migrations/Version20170912210547.php +++ b/migrations/Version20170912210547.php @@ -7,6 +7,9 @@ use Doctrine\DBAL\Schema\Schema; use Doctrine\Migrations\AbstractMigration; +/** + * Auto-generated Migration: Please modify to your needs! + */ class Version20170912210547 extends AbstractMigration { public function up(Schema $schema): void diff --git a/migrations/Version20170919204840.php b/migrations/Version20170919204840.php index 7f4a40e00..a90894d22 100644 --- a/migrations/Version20170919204840.php +++ b/migrations/Version20170919204840.php @@ -7,6 +7,9 @@ use Doctrine\DBAL\Schema\Schema; use Doctrine\Migrations\AbstractMigration; +/** + * Auto-generated Migration: Please modify to your needs! + */ class Version20170919204840 extends AbstractMigration { public function up(Schema $schema): void diff --git a/migrations/Version20170920101536.php b/migrations/Version20170920101536.php index 859ec0c19..a0cf940ca 100644 --- a/migrations/Version20170920101536.php +++ b/migrations/Version20170920101536.php @@ -7,6 +7,9 @@ use Doctrine\DBAL\Schema\Schema; use Doctrine\Migrations\AbstractMigration; +/** + * Auto-generated Migration: Please modify to your needs! + */ class Version20170920101536 extends AbstractMigration { public function up(Schema $schema): void diff --git a/migrations/Version20170926083546.php b/migrations/Version20170926083546.php index 2c79539a1..06bc1e99f 100644 --- a/migrations/Version20170926083546.php +++ b/migrations/Version20170926083546.php @@ -7,6 +7,9 @@ use Doctrine\DBAL\Schema\Schema; use Doctrine\Migrations\AbstractMigration; +/** + * Auto-generated Migration: Please modify to your needs! + */ class Version20170926083546 extends AbstractMigration { public function up(Schema $schema): void diff --git a/migrations/Version20170926200349.php b/migrations/Version20170926200349.php index b2334a9a9..7d71d5b21 100644 --- a/migrations/Version20170926200349.php +++ b/migrations/Version20170926200349.php @@ -7,6 +7,9 @@ use Doctrine\DBAL\Schema\Schema; use Doctrine\Migrations\AbstractMigration; +/** + * Auto-generated Migration: Please modify to your needs! + */ class Version20170926200349 extends AbstractMigration { public function up(Schema $schema): void diff --git a/migrations/Version20170926202746.php b/migrations/Version20170926202746.php index b47c5945c..dcc00e07d 100644 --- a/migrations/Version20170926202746.php +++ b/migrations/Version20170926202746.php @@ -7,6 +7,9 @@ use Doctrine\DBAL\Schema\Schema; use Doctrine\Migrations\AbstractMigration; +/** + * Auto-generated Migration: Please modify to your needs! + */ class Version20170926202746 extends AbstractMigration { public function up(Schema $schema): void diff --git a/migrations/Version20170928194411.php b/migrations/Version20170928194411.php index 3e604c153..4caa32920 100644 --- a/migrations/Version20170928194411.php +++ b/migrations/Version20170928194411.php @@ -7,6 +7,9 @@ use Doctrine\DBAL\Schema\Schema; use Doctrine\Migrations\AbstractMigration; +/** + * Auto-generated Migration: Please modify to your needs! + */ class Version20170928194411 extends AbstractMigration { public function up(Schema $schema): void diff --git a/migrations/Version20170929214603.php b/migrations/Version20170929214603.php index f18230f8a..340c942e0 100644 --- a/migrations/Version20170929214603.php +++ b/migrations/Version20170929214603.php @@ -7,6 +7,9 @@ use Doctrine\DBAL\Schema\Schema; use Doctrine\Migrations\AbstractMigration; +/** + * Auto-generated Migration: Please modify to your needs! + */ class Version20170929214603 extends AbstractMigration { public function up(Schema $schema): void diff --git a/migrations/Version20170930105725.php b/migrations/Version20170930105725.php index d053a459c..8d206b6b2 100644 --- a/migrations/Version20170930105725.php +++ b/migrations/Version20170930105725.php @@ -7,6 +7,9 @@ use Doctrine\DBAL\Schema\Schema; use Doctrine\Migrations\AbstractMigration; +/** + * Auto-generated Migration: Please modify to your needs! + */ class Version20170930105725 extends AbstractMigration { public function up(Schema $schema): void diff --git a/migrations/Version20170930202001.php b/migrations/Version20170930202001.php index 8161675cc..abf9d3a97 100644 --- a/migrations/Version20170930202001.php +++ b/migrations/Version20170930202001.php @@ -7,6 +7,9 @@ use Doctrine\DBAL\Schema\Schema; use Doctrine\Migrations\AbstractMigration; +/** + * Auto-generated Migration: Please modify to your needs! + */ class Version20170930202001 extends AbstractMigration { public function up(Schema $schema): void diff --git a/migrations/Version20171001065213.php b/migrations/Version20171001065213.php index 59a16032e..4d9f4a50c 100644 --- a/migrations/Version20171001065213.php +++ b/migrations/Version20171001065213.php @@ -7,6 +7,9 @@ use Doctrine\DBAL\Schema\Schema; use Doctrine\Migrations\AbstractMigration; +/** + * Auto-generated Migration: Please modify to your needs! + */ class Version20171001065213 extends AbstractMigration { public function up(Schema $schema): void diff --git a/migrations/Version20171001080451.php b/migrations/Version20171001080451.php index 91133b8a9..d7c93bd58 100644 --- a/migrations/Version20171001080451.php +++ b/migrations/Version20171001080451.php @@ -7,6 +7,9 @@ use Doctrine\DBAL\Schema\Schema; use Doctrine\Migrations\AbstractMigration; +/** + * Auto-generated Migration: Please modify to your needs! + */ class Version20171001080451 extends AbstractMigration { public function up(Schema $schema): void diff --git a/migrations/Version20171011173539.php b/migrations/Version20171011173539.php index f88588117..306f510fa 100644 --- a/migrations/Version20171011173539.php +++ b/migrations/Version20171011173539.php @@ -7,6 +7,9 @@ use Doctrine\DBAL\Schema\Schema; use Doctrine\Migrations\AbstractMigration; +/** + * Auto-generated Migration: Please modify to your needs! + */ class Version20171011173539 extends AbstractMigration { public function up(Schema $schema): void diff --git a/migrations/Version20171011212501.php b/migrations/Version20171011212501.php index 6f1830920..d76117b8d 100644 --- a/migrations/Version20171011212501.php +++ b/migrations/Version20171011212501.php @@ -7,6 +7,9 @@ use Doctrine\DBAL\Schema\Schema; use Doctrine\Migrations\AbstractMigration; +/** + * Auto-generated Migration: Please modify to your needs! + */ class Version20171011212501 extends AbstractMigration { public function up(Schema $schema): void diff --git a/migrations/Version20171013214716.php b/migrations/Version20171013214716.php index 0cd3b7fe9..76d67e00d 100644 --- a/migrations/Version20171013214716.php +++ b/migrations/Version20171013214716.php @@ -7,6 +7,9 @@ use Doctrine\DBAL\Schema\Schema; use Doctrine\Migrations\AbstractMigration; +/** + * Auto-generated Migration: Please modify to your needs! + */ class Version20171013214716 extends AbstractMigration { public function up(Schema $schema): void diff --git a/migrations/Version20171014202019.php b/migrations/Version20171014202019.php index abc1ac5ce..c8a0ffeb6 100644 --- a/migrations/Version20171014202019.php +++ b/migrations/Version20171014202019.php @@ -7,6 +7,9 @@ use Doctrine\DBAL\Schema\Schema; use Doctrine\Migrations\AbstractMigration; +/** + * Auto-generated Migration: Please modify to your needs! + */ class Version20171014202019 extends AbstractMigration { public function up(Schema $schema): void diff --git a/migrations/Version20171107200206.php b/migrations/Version20171107200206.php index dc74a16d8..992f43637 100644 --- a/migrations/Version20171107200206.php +++ b/migrations/Version20171107200206.php @@ -7,6 +7,9 @@ use Doctrine\DBAL\Schema\Schema; use Doctrine\Migrations\AbstractMigration; +/** + * Auto-generated Migration: Please modify to your needs! + */ class Version20171107200206 extends AbstractMigration { public function up(Schema $schema): void diff --git a/migrations/Version20171112091358.php b/migrations/Version20171112091358.php index 8937240c7..f12dfee8d 100644 --- a/migrations/Version20171112091358.php +++ b/migrations/Version20171112091358.php @@ -7,6 +7,9 @@ use Doctrine\DBAL\Schema\Schema; use Doctrine\Migrations\AbstractMigration; +/** + * Auto-generated Migration: Please modify to your needs! + */ class Version20171112091358 extends AbstractMigration { public function up(Schema $schema): void diff --git a/migrations/Version20171205224933.php b/migrations/Version20171205224933.php index edffc347e..73971b1e2 100644 --- a/migrations/Version20171205224933.php +++ b/migrations/Version20171205224933.php @@ -7,6 +7,10 @@ use Doctrine\DBAL\Schema\Schema; use Doctrine\Migrations\AbstractMigration; +/** + * Auto-generated Migration: Please modify to your needs! + */ + class Version20171205224933 extends AbstractMigration { public function up(Schema $schema): void diff --git a/migrations/Version20171222203839.php b/migrations/Version20171222203839.php index 0543c29bf..7dab88084 100644 --- a/migrations/Version20171222203839.php +++ b/migrations/Version20171222203839.php @@ -7,6 +7,10 @@ use Doctrine\DBAL\Schema\Schema; use Doctrine\Migrations\AbstractMigration; +/** + * Auto-generated Migration: Please modify to your needs! + */ + class Version20171222203839 extends AbstractMigration { public function up(Schema $schema): void diff --git a/migrations/Version20171223230501.php b/migrations/Version20171223230501.php index fc31ce95f..1844a3885 100644 --- a/migrations/Version20171223230501.php +++ b/migrations/Version20171223230501.php @@ -7,6 +7,10 @@ use Doctrine\DBAL\Schema\Schema; use Doctrine\Migrations\AbstractMigration; +/** + * Auto-generated Migration: Please modify to your needs! + */ + class Version20171223230501 extends AbstractMigration { public function up(Schema $schema): void diff --git a/migrations/Version20171223233147.php b/migrations/Version20171223233147.php index aac06c41e..cff55b204 100644 --- a/migrations/Version20171223233147.php +++ b/migrations/Version20171223233147.php @@ -7,6 +7,10 @@ use Doctrine\DBAL\Schema\Schema; use Doctrine\Migrations\AbstractMigration; +/** + * Auto-generated Migration: Please modify to your needs! + */ + class Version20171223233147 extends AbstractMigration { public function up(Schema $schema): void diff --git a/migrations/Version20171224074439.php b/migrations/Version20171224074439.php index 2df4e7b9c..5a4e9302d 100644 --- a/migrations/Version20171224074439.php +++ b/migrations/Version20171224074439.php @@ -7,6 +7,10 @@ use Doctrine\DBAL\Schema\Schema; use Doctrine\Migrations\AbstractMigration; +/** + * Auto-generated Migration: Please modify to your needs! + */ + class Version20171224074439 extends AbstractMigration { public function up(Schema $schema): void diff --git a/migrations/Version20171224193507.php b/migrations/Version20171224193507.php index 4a3842e39..db684e93a 100644 --- a/migrations/Version20171224193507.php +++ b/migrations/Version20171224193507.php @@ -7,6 +7,10 @@ use Doctrine\DBAL\Schema\Schema; use Doctrine\Migrations\AbstractMigration; +/** + * Auto-generated Migration: Please modify to your needs! + */ + class Version20171224193507 extends AbstractMigration { public function up(Schema $schema): void diff --git a/migrations/Version20171224194026.php b/migrations/Version20171224194026.php index e7d233eb1..8bbd5ca6c 100644 --- a/migrations/Version20171224194026.php +++ b/migrations/Version20171224194026.php @@ -7,6 +7,10 @@ use Doctrine\DBAL\Schema\Schema; use Doctrine\Migrations\AbstractMigration; +/** + * Auto-generated Migration: Please modify to your needs! + */ + class Version20171224194026 extends AbstractMigration { public function up(Schema $schema): void diff --git a/migrations/Version20171224200017.php b/migrations/Version20171224200017.php index 2ce72ecca..d12004c0b 100644 --- a/migrations/Version20171224200017.php +++ b/migrations/Version20171224200017.php @@ -7,6 +7,10 @@ use Doctrine\DBAL\Schema\Schema; use Doctrine\Migrations\AbstractMigration; +/** + * Auto-generated Migration: Please modify to your needs! + */ + class Version20171224200017 extends AbstractMigration { public function up(Schema $schema): void diff --git a/migrations/Version20171225090913.php b/migrations/Version20171225090913.php index 69d791856..6a0b74266 100644 --- a/migrations/Version20171225090913.php +++ b/migrations/Version20171225090913.php @@ -7,6 +7,10 @@ use Doctrine\DBAL\Schema\Schema; use Doctrine\Migrations\AbstractMigration; +/** + * Auto-generated Migration: Please modify to your needs! + */ + class Version20171225090913 extends AbstractMigration { public function up(Schema $schema): void diff --git a/migrations/Version20171225091539.php b/migrations/Version20171225091539.php index 52f275dea..861eb02b2 100644 --- a/migrations/Version20171225091539.php +++ b/migrations/Version20171225091539.php @@ -7,6 +7,10 @@ use Doctrine\DBAL\Schema\Schema; use Doctrine\Migrations\AbstractMigration; +/** + * Auto-generated Migration: Please modify to your needs! + */ + class Version20171225091539 extends AbstractMigration { public function up(Schema $schema): void diff --git a/migrations/Version20171225144953.php b/migrations/Version20171225144953.php index db2f7b525..4ce365a4f 100644 --- a/migrations/Version20171225144953.php +++ b/migrations/Version20171225144953.php @@ -7,6 +7,10 @@ use Doctrine\DBAL\Schema\Schema; use Doctrine\Migrations\AbstractMigration; +/** + * Auto-generated Migration: Please modify to your needs! + */ + class Version20171225144953 extends AbstractMigration { public function up(Schema $schema): void diff --git a/migrations/Version20171226214906.php b/migrations/Version20171226214906.php index dbf222026..60f8d34bb 100644 --- a/migrations/Version20171226214906.php +++ b/migrations/Version20171226214906.php @@ -7,6 +7,10 @@ use Doctrine\DBAL\Schema\Schema; use Doctrine\Migrations\AbstractMigration; +/** + * Auto-generated Migration: Please modify to your needs! + */ + class Version20171226214906 extends AbstractMigration { public function up(Schema $schema): void diff --git a/migrations/Version20171226215255.php b/migrations/Version20171226215255.php index 51015a676..bc4fb0e97 100644 --- a/migrations/Version20171226215255.php +++ b/migrations/Version20171226215255.php @@ -7,6 +7,10 @@ use Doctrine\DBAL\Schema\Schema; use Doctrine\Migrations\AbstractMigration; +/** + * Auto-generated Migration: Please modify to your needs! + */ + class Version20171226215255 extends AbstractMigration { public function up(Schema $schema): void diff --git a/migrations/Version20171227152222.php b/migrations/Version20171227152222.php index b1cab071f..288029584 100644 --- a/migrations/Version20171227152222.php +++ b/migrations/Version20171227152222.php @@ -7,6 +7,10 @@ use Doctrine\DBAL\Schema\Schema; use Doctrine\Migrations\AbstractMigration; +/** + * Auto-generated Migration: Please modify to your needs! + */ + class Version20171227152222 extends AbstractMigration { public function up(Schema $schema): void diff --git a/migrations/Version20171227203925.php b/migrations/Version20171227203925.php index 1b4e5c113..634ea0735 100644 --- a/migrations/Version20171227203925.php +++ b/migrations/Version20171227203925.php @@ -7,6 +7,10 @@ use Doctrine\DBAL\Schema\Schema; use Doctrine\Migrations\AbstractMigration; +/** + * Auto-generated Migration: Please modify to your needs! + */ + class Version20171227203925 extends AbstractMigration { public function up(Schema $schema): void diff --git a/migrations/Version20171228185809.php b/migrations/Version20171228185809.php index a4b4eb919..471f1a099 100644 --- a/migrations/Version20171228185809.php +++ b/migrations/Version20171228185809.php @@ -7,6 +7,10 @@ use Doctrine\DBAL\Schema\Schema; use Doctrine\Migrations\AbstractMigration; +/** + * Auto-generated Migration: Please modify to your needs! + */ + class Version20171228185809 extends AbstractMigration { public function up(Schema $schema): void diff --git a/migrations/Version20171228213958.php b/migrations/Version20171228213958.php index ce73ed456..ba4f665eb 100644 --- a/migrations/Version20171228213958.php +++ b/migrations/Version20171228213958.php @@ -7,6 +7,10 @@ use Doctrine\DBAL\Schema\Schema; use Doctrine\Migrations\AbstractMigration; +/** + * Auto-generated Migration: Please modify to your needs! + */ + class Version20171228213958 extends AbstractMigration { public function up(Schema $schema): void diff --git a/migrations/Version20180220173247.php b/migrations/Version20180220173247.php index 68682a842..3893e34ae 100644 --- a/migrations/Version20180220173247.php +++ b/migrations/Version20180220173247.php @@ -7,6 +7,10 @@ use Doctrine\DBAL\Schema\Schema; use Doctrine\Migrations\AbstractMigration; +/** + * Auto-generated Migration: Please modify to your needs! + */ + class Version20180220173247 extends AbstractMigration { public function up(Schema $schema): void diff --git a/migrations/Version20180301143542.php b/migrations/Version20180301143542.php index e2a62a0e4..462b74981 100644 --- a/migrations/Version20180301143542.php +++ b/migrations/Version20180301143542.php @@ -7,6 +7,10 @@ use Doctrine\DBAL\Schema\Schema; use Doctrine\Migrations\AbstractMigration; +/** + * Auto-generated Migration: Please modify to your needs! + */ + class Version20180301143542 extends AbstractMigration { public function up(Schema $schema): void diff --git a/migrations/Version20180908084237.php b/migrations/Version20180908084237.php index a16edd9b0..1b592ac4e 100644 --- a/migrations/Version20180908084237.php +++ b/migrations/Version20180908084237.php @@ -7,6 +7,9 @@ use Doctrine\DBAL\Schema\Schema; use Doctrine\Migrations\AbstractMigration; +/** + * Auto-generated Migration: Please modify to your needs! + */ final class Version20180908084237 extends AbstractMigration { public function up(Schema $schema): void diff --git a/migrations/Version20180908154937.php b/migrations/Version20180908154937.php index e97fae9b2..fe4c39ca5 100644 --- a/migrations/Version20180908154937.php +++ b/migrations/Version20180908154937.php @@ -7,6 +7,9 @@ use Doctrine\DBAL\Schema\Schema; use Doctrine\Migrations\AbstractMigration; +/** + * Auto-generated Migration: Please modify to your needs! + */ final class Version20180908154937 extends AbstractMigration { public function up(Schema $schema): void diff --git a/migrations/Version20180908161003.php b/migrations/Version20180908161003.php index 6a212958b..bb2c3f6b1 100644 --- a/migrations/Version20180908161003.php +++ b/migrations/Version20180908161003.php @@ -7,6 +7,9 @@ use Doctrine\DBAL\Schema\Schema; use Doctrine\Migrations\AbstractMigration; +/** + * Auto-generated Migration: Please modify to your needs! + */ final class Version20180908161003 extends AbstractMigration { public function up(Schema $schema): void diff --git a/migrations/Version20180913022739.php b/migrations/Version20180913022739.php index dfa50efa1..4b1fa14d5 100644 --- a/migrations/Version20180913022739.php +++ b/migrations/Version20180913022739.php @@ -7,6 +7,9 @@ use Doctrine\DBAL\Schema\Schema; use Doctrine\Migrations\AbstractMigration; +/** + * Auto-generated Migration: Please modify to your needs! + */ final class Version20180913022739 extends AbstractMigration { public function up(Schema $schema): void diff --git a/migrations/Version20180923131041.php b/migrations/Version20180923131041.php index b785f43f1..ffe9197bb 100644 --- a/migrations/Version20180923131041.php +++ b/migrations/Version20180923131041.php @@ -7,6 +7,9 @@ use Doctrine\DBAL\Schema\Schema; use Doctrine\Migrations\AbstractMigration; +/** + * Auto-generated Migration: Please modify to your needs! + */ final class Version20180923131041 extends AbstractMigration { public function up(Schema $schema): void diff --git a/migrations/Version20180923193950.php b/migrations/Version20180923193950.php index d14d6eac7..551dd72a7 100644 --- a/migrations/Version20180923193950.php +++ b/migrations/Version20180923193950.php @@ -7,6 +7,9 @@ use Doctrine\DBAL\Schema\Schema; use Doctrine\Migrations\AbstractMigration; +/** + * Auto-generated Migration: Please modify to your needs! + */ final class Version20180923193950 extends AbstractMigration { public function up(Schema $schema): void diff --git a/migrations/Version20181005232108.php b/migrations/Version20181005232108.php index dd7f4467f..4d3ddf05d 100644 --- a/migrations/Version20181005232108.php +++ b/migrations/Version20181005232108.php @@ -7,6 +7,9 @@ use Doctrine\DBAL\Schema\Schema; use Doctrine\Migrations\AbstractMigration; +/** + * Auto-generated Migration: Please modify to your needs! + */ final class Version20181005232108 extends AbstractMigration { public function up(Schema $schema): void diff --git a/migrations/Version20181010230205.php b/migrations/Version20181010230205.php index 14da68db7..23389ccdd 100644 --- a/migrations/Version20181010230205.php +++ b/migrations/Version20181010230205.php @@ -7,6 +7,9 @@ use Doctrine\DBAL\Schema\Schema; use Doctrine\Migrations\AbstractMigration; +/** + * Auto-generated Migration: Please modify to your needs! + */ final class Version20181010230205 extends AbstractMigration { public function up(Schema $schema): void diff --git a/migrations/Version20181012230417.php b/migrations/Version20181012230417.php index f05324140..4c6dd32da 100644 --- a/migrations/Version20181012230417.php +++ b/migrations/Version20181012230417.php @@ -7,6 +7,9 @@ use Doctrine\DBAL\Schema\Schema; use Doctrine\Migrations\AbstractMigration; +/** + * Auto-generated Migration: Please modify to your needs! + */ final class Version20181012230417 extends AbstractMigration { public function up(Schema $schema): void diff --git a/migrations/Version20181013201838.php b/migrations/Version20181013201838.php index 4b1c2565e..fb9185b05 100644 --- a/migrations/Version20181013201838.php +++ b/migrations/Version20181013201838.php @@ -7,6 +7,9 @@ use Doctrine\DBAL\Schema\Schema; use Doctrine\Migrations\AbstractMigration; +/** + * Auto-generated Migration: Please modify to your needs! + */ final class Version20181013201838 extends AbstractMigration { public function up(Schema $schema): void diff --git a/migrations/Version20181020221331.php b/migrations/Version20181020221331.php index e0213798b..e15dd592c 100644 --- a/migrations/Version20181020221331.php +++ b/migrations/Version20181020221331.php @@ -7,6 +7,9 @@ use Doctrine\DBAL\Schema\Schema; use Doctrine\Migrations\AbstractMigration; +/** + * Auto-generated Migration: Please modify to your needs! + */ final class Version20181020221331 extends AbstractMigration { public function up(Schema $schema): void diff --git a/migrations/Version20181121205737.php b/migrations/Version20181121205737.php index c40f23828..0e529cae6 100644 --- a/migrations/Version20181121205737.php +++ b/migrations/Version20181121205737.php @@ -7,6 +7,9 @@ use Doctrine\DBAL\Schema\Schema; use Doctrine\Migrations\AbstractMigration; +/** + * Auto-generated Migration: Please modify to your needs! + */ final class Version20181121205737 extends AbstractMigration { public function up(Schema $schema): void diff --git a/migrations/Version20191019205131.php b/migrations/Version20191019205131.php index c0dde5eb0..46f75d79f 100644 --- a/migrations/Version20191019205131.php +++ b/migrations/Version20191019205131.php @@ -7,6 +7,9 @@ use Doctrine\DBAL\Schema\Schema; use Doctrine\Migrations\AbstractMigration; +/** + * Auto-generated Migration: Please modify to your needs! + */ final class Version20191019205131 extends AbstractMigration { public function getDescription(): string diff --git a/migrations/Version20191106203306.php b/migrations/Version20191106203306.php index e607dc707..8084828da 100644 --- a/migrations/Version20191106203306.php +++ b/migrations/Version20191106203306.php @@ -7,6 +7,9 @@ use Doctrine\DBAL\Schema\Schema; use Doctrine\Migrations\AbstractMigration; +/** + * Auto-generated Migration: Please modify to your needs! + */ final class Version20191106203306 extends AbstractMigration { public function getDescription(): string diff --git a/migrations/Version20200208121828.php b/migrations/Version20200208121828.php index 991860a6f..b24e6b36a 100644 --- a/migrations/Version20200208121828.php +++ b/migrations/Version20200208121828.php @@ -7,6 +7,9 @@ use Doctrine\DBAL\Schema\Schema; use Doctrine\Migrations\AbstractMigration; +/** + * Auto-generated Migration: Please modify to your needs! + */ final class Version20200208121828 extends AbstractMigration { public function getDescription(): string diff --git a/migrations/Version20200506201425.php b/migrations/Version20200506201425.php index 4d14607a2..a449f169a 100644 --- a/migrations/Version20200506201425.php +++ b/migrations/Version20200506201425.php @@ -7,6 +7,9 @@ use Doctrine\DBAL\Schema\Schema; use Doctrine\Migrations\AbstractMigration; +/** + * Auto-generated Migration: Please modify to your needs! + */ final class Version20200506201425 extends AbstractMigration { public function getDescription(): string diff --git a/migrations/Version20200510125434.php b/migrations/Version20200510125434.php index 9bff169e3..7e9291b60 100644 --- a/migrations/Version20200510125434.php +++ b/migrations/Version20200510125434.php @@ -7,6 +7,9 @@ use Doctrine\DBAL\Schema\Schema; use Doctrine\Migrations\AbstractMigration; +/** + * Auto-generated Migration: Please modify to your needs! + */ final class Version20200510125434 extends AbstractMigration { public function getDescription(): string diff --git a/migrations/Version20200510202019.php b/migrations/Version20200510202019.php index 252fa905e..aabff9eea 100644 --- a/migrations/Version20200510202019.php +++ b/migrations/Version20200510202019.php @@ -7,6 +7,9 @@ use Doctrine\DBAL\Schema\Schema; use Doctrine\Migrations\AbstractMigration; +/** + * Auto-generated Migration: Please modify to your needs! + */ final class Version20200510202019 extends AbstractMigration { public function getDescription(): string diff --git a/migrations/Version20200514180536.php b/migrations/Version20200514180536.php index 604167314..c9a047899 100644 --- a/migrations/Version20200514180536.php +++ b/migrations/Version20200514180536.php @@ -7,6 +7,9 @@ use Doctrine\DBAL\Schema\Schema; use Doctrine\Migrations\AbstractMigration; +/** + * Auto-generated Migration: Please modify to your needs! + */ final class Version20200514180536 extends AbstractMigration { public function getDescription(): string diff --git a/migrations/Version20200523200237.php b/migrations/Version20200523200237.php index c9b49f5bf..7d30237ae 100644 --- a/migrations/Version20200523200237.php +++ b/migrations/Version20200523200237.php @@ -7,6 +7,9 @@ use Doctrine\DBAL\Schema\Schema; use Doctrine\Migrations\AbstractMigration; +/** + * Auto-generated Migration: Please modify to your needs! + */ final class Version20200523200237 extends AbstractMigration { public function getDescription(): string diff --git a/migrations/Version20200614202940.php b/migrations/Version20200614202940.php index f72d62c23..5dc72adb4 100644 --- a/migrations/Version20200614202940.php +++ b/migrations/Version20200614202940.php @@ -7,6 +7,9 @@ use Doctrine\DBAL\Schema\Schema; use Doctrine\Migrations\AbstractMigration; +/** + * Auto-generated Migration: Please modify to your needs! + */ final class Version20200614202940 extends AbstractMigration { public function getDescription(): string diff --git a/migrations/Version20200616201433.php b/migrations/Version20200616201433.php index dd873c123..499126d2b 100644 --- a/migrations/Version20200616201433.php +++ b/migrations/Version20200616201433.php @@ -7,6 +7,9 @@ use Doctrine\DBAL\Schema\Schema; use Doctrine\Migrations\AbstractMigration; +/** + * Auto-generated Migration: Please modify to your needs! + */ final class Version20200616201433 extends AbstractMigration { public function getDescription(): string diff --git a/migrations/Version20201114190413.php b/migrations/Version20201114190413.php index d5b817da5..9b951db76 100644 --- a/migrations/Version20201114190413.php +++ b/migrations/Version20201114190413.php @@ -7,6 +7,9 @@ use Doctrine\DBAL\Schema\Schema; use Doctrine\Migrations\AbstractMigration; +/** + * Auto-generated Migration: Please modify to your needs! + */ final class Version20201114190413 extends AbstractMigration { public function getDescription(): string diff --git a/migrations/Version20201121074458.php b/migrations/Version20201121074458.php index c267f9538..2788d2707 100644 --- a/migrations/Version20201121074458.php +++ b/migrations/Version20201121074458.php @@ -7,6 +7,9 @@ use Doctrine\DBAL\Schema\Schema; use Doctrine\Migrations\AbstractMigration; +/** + * Auto-generated Migration: Please modify to your needs! + */ final class Version20201121074458 extends AbstractMigration { public function getDescription(): string diff --git a/migrations/Version20201220185758.php b/migrations/Version20201220185758.php index d22fd693d..a64bb8e4e 100644 --- a/migrations/Version20201220185758.php +++ b/migrations/Version20201220185758.php @@ -7,6 +7,9 @@ use Doctrine\DBAL\Schema\Schema; use Doctrine\Migrations\AbstractMigration; +/** + * Auto-generated Migration: Please modify to your needs! + */ final class Version20201220185758 extends AbstractMigration { public function getDescription(): string diff --git a/migrations/Version20201227221750.php b/migrations/Version20201227221750.php index 74be098e9..5812290fa 100644 --- a/migrations/Version20201227221750.php +++ b/migrations/Version20201227221750.php @@ -7,6 +7,9 @@ use Doctrine\DBAL\Schema\Schema; use Doctrine\Migrations\AbstractMigration; +/** + * Auto-generated Migration: Please modify to your needs! + */ final class Version20201227221750 extends AbstractMigration { public function getDescription(): string diff --git a/migrations/Version20210104221630.php b/migrations/Version20210104221630.php index a77ef6725..6f7bb06a9 100644 --- a/migrations/Version20210104221630.php +++ b/migrations/Version20210104221630.php @@ -7,6 +7,9 @@ use Doctrine\DBAL\Schema\Schema; use Doctrine\Migrations\AbstractMigration; +/** + * Auto-generated Migration: Please modify to your needs! + */ final class Version20210104221630 extends AbstractMigration { public function getDescription(): string diff --git a/migrations/Version20210115233300.php b/migrations/Version20210115233300.php index f76b3083a..5d10d670b 100644 --- a/migrations/Version20210115233300.php +++ b/migrations/Version20210115233300.php @@ -7,6 +7,9 @@ use Doctrine\DBAL\Schema\Schema; use Doctrine\Migrations\AbstractMigration; +/** + * Auto-generated Migration: Please modify to your needs! + */ final class Version20210115233300 extends AbstractMigration { public function getDescription(): string diff --git a/migrations/Version20210125223746.php b/migrations/Version20210125223746.php index 345736f76..1b652c660 100644 --- a/migrations/Version20210125223746.php +++ b/migrations/Version20210125223746.php @@ -7,6 +7,9 @@ use Doctrine\DBAL\Schema\Schema; use Doctrine\Migrations\AbstractMigration; +/** + * Auto-generated Migration: Please modify to your needs! + */ final class Version20210125223746 extends AbstractMigration { public function getDescription(): string diff --git a/migrations/Version20210203221708.php b/migrations/Version20210203221708.php index c835b4ed8..38c800fe1 100644 --- a/migrations/Version20210203221708.php +++ b/migrations/Version20210203221708.php @@ -7,6 +7,9 @@ use Doctrine\DBAL\Schema\Schema; use Doctrine\Migrations\AbstractMigration; +/** + * Auto-generated Migration: Please modify to your needs! + */ final class Version20210203221708 extends AbstractMigration { public function getDescription(): string diff --git a/migrations/Version20211104201111.php b/migrations/Version20211104201111.php index 4b1950540..a0d761574 100644 --- a/migrations/Version20211104201111.php +++ b/migrations/Version20211104201111.php @@ -7,6 +7,9 @@ use Doctrine\DBAL\Schema\Schema; use Doctrine\Migrations\AbstractMigration; +/** + * Auto-generated Migration: Please modify to your needs! + */ final class Version20211104201111 extends AbstractMigration { public function getDescription(): string diff --git a/migrations/Version20211205101030.php b/migrations/Version20211205101030.php index 6000e7a64..17fbee873 100644 --- a/migrations/Version20211205101030.php +++ b/migrations/Version20211205101030.php @@ -7,6 +7,9 @@ use Doctrine\DBAL\Schema\Schema; use Doctrine\Migrations\AbstractMigration; +/** + * Auto-generated Migration: Please modify to your needs! + */ final class Version20211205101030 extends AbstractMigration { public function getDescription(): string diff --git a/migrations/Version20220916203759.php b/migrations/Version20220916203759.php index c1eba62a5..8bbb0e11c 100644 --- a/migrations/Version20220916203759.php +++ b/migrations/Version20220916203759.php @@ -7,6 +7,9 @@ use Doctrine\DBAL\Schema\Schema; use Doctrine\Migrations\AbstractMigration; +/** + * Auto-generated Migration: Please modify to your needs! + */ final class Version20220916203759 extends AbstractMigration { public function getDescription(): string diff --git a/migrations/Version20231115155623.php b/migrations/Version20231115155623.php new file mode 100644 index 000000000..08a852159 --- /dev/null +++ b/migrations/Version20231115155623.php @@ -0,0 +1,91 @@ +abortIf($this->connection->getDatabasePlatform()->getName() !== 'mysql', 'Migration can only be executed safely on \'mysql\'.'); + + $this->addSql('CREATE TABLE `group` (id INT AUTO_INCREMENT NOT NULL, name VARCHAR(255) NOT NULL, leader_id INT NOT NULL, leader_email VARCHAR(255) NOT NULL, create_date DATETIME DEFAULT NULL COMMENT \'(DC2Type:datetime_immutable)\', group_status_id INT NOT NULL, places VARCHAR(255) NOT NULL, price INT NOT NULL, note LONGTEXT DEFAULT NULL, PRIMARY KEY(id)) DEFAULT CHARACTER SET utf8mb4 COLLATE `utf8mb4_unicode_ci` ENGINE = InnoDB'); + $this->addSql('CREATE TABLE status (id INT AUTO_INCREMENT NOT NULL, name VARCHAR(255) NOT NULL, UNIQUE INDEX UNIQ_7B00651C5E237E06 (name), PRIMARY KEY(id)) DEFAULT CHARACTER SET utf8mb4 COLLATE `utf8mb4_unicode_ci` ENGINE = InnoDB'); + $this->addSql('ALTER TABLE template_template_variable ADD CONSTRAINT FK_62257D3C5DA0FB8 FOREIGN KEY (template_id) REFERENCES mail_template (id) ON DELETE CASCADE'); + $this->addSql('ALTER TABLE template_template_variable ADD CONSTRAINT FK_62257D3CF8FA6AEA FOREIGN KEY (template_variable_id) REFERENCES mail_template_variable (id) ON DELETE CASCADE'); + $this->addSql('ALTER TABLE role_permission ADD CONSTRAINT FK_6F7DF886D60322AC FOREIGN KEY (role_id) REFERENCES role (id) ON DELETE CASCADE'); + $this->addSql('ALTER TABLE role_permission ADD CONSTRAINT FK_6F7DF886FED90CCA FOREIGN KEY (permission_id) REFERENCES permission (id) ON DELETE CASCADE'); + $this->addSql('ALTER TABLE role_role_incompatible ADD CONSTRAINT FK_30A89EE7D60322AC FOREIGN KEY (role_id) REFERENCES role (id)'); + $this->addSql('ALTER TABLE role_role_incompatible ADD CONSTRAINT FK_30A89EE7657B53D5 FOREIGN KEY (incompatible_role_id) REFERENCES role (id)'); + $this->addSql('ALTER TABLE role_role_required ADD CONSTRAINT FK_45B98BABD60322AC FOREIGN KEY (role_id) REFERENCES role (id)'); + $this->addSql('ALTER TABLE role_role_required ADD CONSTRAINT FK_45B98BABF7E2056C FOREIGN KEY (required_role_id) REFERENCES role (id)'); + $this->addSql('ALTER TABLE slideshow_content ADD CONSTRAINT FK_3001DAD3BF396750 FOREIGN KEY (id) REFERENCES content (id) ON DELETE CASCADE'); + $this->addSql('ALTER TABLE subevent_subevent_incompatible ADD CONSTRAINT FK_D89E46427A675502 FOREIGN KEY (subevent_id) REFERENCES subevent (id)'); + $this->addSql('ALTER TABLE subevent_subevent_incompatible ADD CONSTRAINT FK_D89E46428CEDA9BB FOREIGN KEY (incompatible_subevent_id) REFERENCES subevent (id)'); + $this->addSql('ALTER TABLE subevent_subevent_required ADD CONSTRAINT FK_91468A527A675502 FOREIGN KEY (subevent_id) REFERENCES subevent (id)'); + $this->addSql('ALTER TABLE subevent_subevent_required ADD CONSTRAINT FK_91468A523A243992 FOREIGN KEY (required_subevent_id) REFERENCES subevent (id)'); + $this->addSql('ALTER TABLE subevent_skaut_is_course ADD CONSTRAINT FK_EF3BE1D37A675502 FOREIGN KEY (subevent_id) REFERENCES subevent (id) ON DELETE CASCADE'); + $this->addSql('ALTER TABLE subevent_skaut_is_course ADD CONSTRAINT FK_EF3BE1D3D86001CA FOREIGN KEY (skaut_is_course_id) REFERENCES skaut_is_course (id) ON DELETE CASCADE'); + $this->addSql('ALTER TABLE tag_role ADD CONSTRAINT FK_B96635DCBAD26311 FOREIGN KEY (tag_id) REFERENCES tag (id) ON DELETE CASCADE'); + $this->addSql('ALTER TABLE tag_role ADD CONSTRAINT FK_B96635DCD60322AC FOREIGN KEY (role_id) REFERENCES role (id) ON DELETE CASCADE'); + $this->addSql('ALTER TABLE text_content ADD CONSTRAINT FK_DA641F96BF396750 FOREIGN KEY (id) REFERENCES content (id) ON DELETE CASCADE'); + $this->addSql('ALTER TABLE ticket_check ADD CONSTRAINT FK_14BECF98A76ED395 FOREIGN KEY (user_id) REFERENCES user (id)'); + $this->addSql('ALTER TABLE ticket_check ADD CONSTRAINT FK_14BECF987A675502 FOREIGN KEY (subevent_id) REFERENCES subevent (id)'); + $this->addSql('ALTER TABLE user_role ADD CONSTRAINT FK_2DE8C6A3A76ED395 FOREIGN KEY (user_id) REFERENCES user (id) ON DELETE CASCADE'); + $this->addSql('ALTER TABLE user_role ADD CONSTRAINT FK_2DE8C6A3D60322AC FOREIGN KEY (role_id) REFERENCES role (id) ON DELETE CASCADE'); + $this->addSql('ALTER TABLE user_block ADD CONSTRAINT FK_61D96C7AA76ED395 FOREIGN KEY (user_id) REFERENCES user (id) ON DELETE CASCADE'); + $this->addSql('ALTER TABLE user_block ADD CONSTRAINT FK_61D96C7AE9ED820C FOREIGN KEY (block_id) REFERENCES block (id) ON DELETE CASCADE'); + $this->addSql('ALTER TABLE users_content ADD CONSTRAINT FK_EC54463BF396750 FOREIGN KEY (id) REFERENCES content (id) ON DELETE CASCADE'); + $this->addSql('ALTER TABLE users_content_role ADD CONSTRAINT FK_C94F41A353CB0C79 FOREIGN KEY (users_content_id) REFERENCES users_content (id) ON DELETE CASCADE'); + $this->addSql('ALTER TABLE users_content_role ADD CONSTRAINT FK_C94F41A3D60322AC FOREIGN KEY (role_id) REFERENCES role (id) ON DELETE CASCADE'); + } + + public function down(Schema $schema) : void + { + // this down() migration is auto-generated, please modify it to your needs + $this->abortIf($this->connection->getDatabasePlatform()->getName() !== 'mysql', 'Migration can only be executed safely on \'mysql\'.'); + + $this->addSql('DROP TABLE `group`'); + $this->addSql('DROP TABLE status'); + $this->addSql('ALTER TABLE role_permission DROP FOREIGN KEY FK_6F7DF886D60322AC'); + $this->addSql('ALTER TABLE role_permission DROP FOREIGN KEY FK_6F7DF886FED90CCA'); + $this->addSql('ALTER TABLE role_role_incompatible DROP FOREIGN KEY FK_30A89EE7D60322AC'); + $this->addSql('ALTER TABLE role_role_incompatible DROP FOREIGN KEY FK_30A89EE7657B53D5'); + $this->addSql('ALTER TABLE role_role_required DROP FOREIGN KEY FK_45B98BABD60322AC'); + $this->addSql('ALTER TABLE role_role_required DROP FOREIGN KEY FK_45B98BABF7E2056C'); + $this->addSql('ALTER TABLE slideshow_content DROP FOREIGN KEY FK_3001DAD3BF396750'); + $this->addSql('ALTER TABLE subevent_skaut_is_course DROP FOREIGN KEY FK_EF3BE1D37A675502'); + $this->addSql('ALTER TABLE subevent_skaut_is_course DROP FOREIGN KEY FK_EF3BE1D3D86001CA'); + $this->addSql('ALTER TABLE subevent_subevent_incompatible DROP FOREIGN KEY FK_D89E46427A675502'); + $this->addSql('ALTER TABLE subevent_subevent_incompatible DROP FOREIGN KEY FK_D89E46428CEDA9BB'); + $this->addSql('ALTER TABLE subevent_subevent_required DROP FOREIGN KEY FK_91468A527A675502'); + $this->addSql('ALTER TABLE subevent_subevent_required DROP FOREIGN KEY FK_91468A523A243992'); + $this->addSql('ALTER TABLE tag_role DROP FOREIGN KEY FK_B96635DCBAD26311'); + $this->addSql('ALTER TABLE tag_role DROP FOREIGN KEY FK_B96635DCD60322AC'); + $this->addSql('ALTER TABLE template_template_variable DROP FOREIGN KEY FK_62257D3C5DA0FB8'); + $this->addSql('ALTER TABLE template_template_variable DROP FOREIGN KEY FK_62257D3CF8FA6AEA'); + $this->addSql('ALTER TABLE text_content DROP FOREIGN KEY FK_DA641F96BF396750'); + $this->addSql('ALTER TABLE ticket_check DROP FOREIGN KEY FK_14BECF98A76ED395'); + $this->addSql('ALTER TABLE ticket_check DROP FOREIGN KEY FK_14BECF987A675502'); + $this->addSql('ALTER TABLE user_block DROP FOREIGN KEY FK_61D96C7AA76ED395'); + $this->addSql('ALTER TABLE user_block DROP FOREIGN KEY FK_61D96C7AE9ED820C'); + $this->addSql('ALTER TABLE user_role DROP FOREIGN KEY FK_2DE8C6A3A76ED395'); + $this->addSql('ALTER TABLE user_role DROP FOREIGN KEY FK_2DE8C6A3D60322AC'); + $this->addSql('ALTER TABLE users_content DROP FOREIGN KEY FK_EC54463BF396750'); + $this->addSql('ALTER TABLE users_content_role DROP FOREIGN KEY FK_C94F41A353CB0C79'); + $this->addSql('ALTER TABLE users_content_role DROP FOREIGN KEY FK_C94F41A3D60322AC'); + } +} diff --git a/migrations/initial_data.sql b/migrations/initial_data.sql index 5c0394c22..18bc6d397 100644 --- a/migrations/initial_data.sql +++ b/migrations/initial_data.sql @@ -113,9 +113,9 @@ INSERT INTO `settings` (`item`, `value`) VALUES ('register_programs_from', NULL), ('register_programs_to', NULL), ('seminar_email', 'srs@skaut.cz'), - ('seminar_from_date', CURDATE() + INTERVAL 1 DAY), + ('seminar_from_date', CURDATE() + 1), ('seminar_name', 'Název semináře'), - ('seminar_to_date', CURDATE() + INTERVAL 2 DAY), + ('seminar_to_date', CURDATE() + 2), ('skautis_event_id', NULL), ('skautis_event_name', NULL), ('variable_symbol_code', '');
    {_web.profile.schedule.from}{_web.profile.schedule.to}{_web.profile.schedule.program_name}{_web.profile.schedule.room}{_web.profile.schedule.lectors}{_web.profile.from}{_web.profile.to}{_web.profile.program_name}{_web.profile.room}{_web.profile.lectors}
    {var $startDay = $program->getStart()->format('N')} - {_"common.day.$startDay"} + {_common.day.$startDay} {$program->getStart()|date:"j. n. G:i"} {var $endDay = $program->getEnd()->format('N')} - {_"common.day.$endDay"} + {_common.day.$endDay} {$program->getEnd()|date:"j. n. G:i"} {$program->getBlock()->getName()}