-
Notifications
You must be signed in to change notification settings - Fork 11
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Co-authored-by: Jan Havelka <[email protected]>
- Loading branch information
1 parent
d3e96af
commit f122fcf
Showing
412 changed files
with
3,949 additions
and
1,536 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace App\ActionModule\Presenters; | ||
|
||
use App\Presenters\BasePresenter; | ||
|
||
/** | ||
* BasePresenter pro ActionModule. | ||
*/ | ||
abstract class ActionBasePresenter extends BasePresenter | ||
{ | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace App\ActionModule\Presenters; | ||
|
||
use App\Model\Settings\Exceptions\SettingsItemNotFoundException; | ||
use App\Model\Settings\Queries\SettingDateValueQuery; | ||
use App\Model\Settings\Settings; | ||
use App\Services\BankService; | ||
use App\Services\QueryBus; | ||
use Nette\Application\Responses\TextResponse; | ||
use Nette\DI\Attributes\Inject; | ||
use Throwable; | ||
|
||
/** | ||
* Presenter obsluhující načítání plateb z API banky. | ||
*/ | ||
class BankPresenter extends ActionBasePresenter | ||
{ | ||
#[Inject] | ||
public QueryBus $queryBus; | ||
|
||
#[Inject] | ||
public BankService $bankService; | ||
|
||
/** | ||
* Zkontroluje splatnost přihlášek. | ||
* | ||
* @throws SettingsItemNotFoundException | ||
* @throws Throwable | ||
*/ | ||
public function actionCheck(): void | ||
{ | ||
$from = $this->queryBus->handle(new SettingDateValueQuery(Settings::BANK_DOWNLOAD_FROM)); | ||
$this->bankService->downloadTransactions($from); | ||
|
||
$response = new TextResponse(null); | ||
$this->sendResponse($response); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace App\ActionModule\Presenters; | ||
|
||
use App\Model\Acl\Permission; | ||
use App\Model\Acl\SrsResource; | ||
use App\Model\Settings\Commands\SetSettingStringValue; | ||
use App\Model\Settings\Queries\SettingStringValueQuery; | ||
use App\Model\Settings\Settings; | ||
use App\Services\CommandBus; | ||
use App\Services\QueryBus; | ||
use Nette\Application\AbortException; | ||
use Nette\DI\Attributes\Inject; | ||
use Throwable; | ||
|
||
/** | ||
* Presenter obsluhující potvrzení změny e-mailu. | ||
*/ | ||
class MailingPresenter extends ActionBasePresenter | ||
{ | ||
#[Inject] | ||
public CommandBus $commandBus; | ||
|
||
#[Inject] | ||
public QueryBus $queryBus; | ||
|
||
/** | ||
* Ověří e-mail semináře. | ||
* | ||
* @throws AbortException | ||
* @throws Throwable | ||
*/ | ||
public function actionVerify(string $code): void | ||
{ | ||
if ($code === $this->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'); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,134 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace App\ActionModule\Presenters; | ||
|
||
use App\Model\Acl\Repositories\RoleRepository; | ||
use App\Model\Acl\Role; | ||
use App\Model\Enums\ApplicationState; | ||
use App\Model\Mailing\Template; | ||
use App\Model\Mailing\TemplateVariable; | ||
use App\Model\Settings\Queries\SettingIntValueQuery; | ||
use App\Model\Settings\Queries\SettingStringValueQuery; | ||
use App\Model\Settings\Settings; | ||
use App\Model\User\Repositories\UserRepository; | ||
use App\Services\ApplicationService; | ||
use App\Services\IMailService; | ||
use App\Services\QueryBus; | ||
use App\Utils\Helpers; | ||
use DateTimeImmutable; | ||
use Doctrine\Common\Collections\ArrayCollection; | ||
use Doctrine\ORM\EntityManagerInterface; | ||
use Nette\Application\Responses\TextResponse; | ||
use Nette\DI\Attributes\Inject; | ||
use Throwable; | ||
|
||
/** | ||
* Presenter obsluhující kontrolu splatnosti přihlášek. | ||
*/ | ||
class MaturityPresenter extends ActionBasePresenter | ||
{ | ||
#[Inject] | ||
public QueryBus $queryBus; | ||
|
||
#[Inject] | ||
public EntityManagerInterface $em; | ||
|
||
#[Inject] | ||
public UserRepository $userRepository; | ||
|
||
#[Inject] | ||
public RoleRepository $roleRepository; | ||
|
||
#[Inject] | ||
public IMailService $mailService; | ||
|
||
#[Inject] | ||
public ApplicationService $applicationService; | ||
|
||
/** | ||
* Zruší přihlášky po splatnosti. | ||
* | ||
* @throws Throwable | ||
*/ | ||
public function actionCancelApplications(): void | ||
{ | ||
$cancelRegistration = $this->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); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.