Skip to content

Commit

Permalink
Merge pull request #465 from jan-stanek/prehodnoceni-podakci
Browse files Browse the repository at this point in the history
Prehodnoceni podakci
  • Loading branch information
Jan Staněk authored Dec 27, 2017
2 parents ff0da82 + 4b1d45c commit 014d38c
Show file tree
Hide file tree
Showing 151 changed files with 3,855 additions and 2,270 deletions.
2 changes: 1 addition & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
language: php

php: 5.6
php: 7.1

before_install:
- composer self-update
Expand Down
10 changes: 4 additions & 6 deletions app/ActionModule/presenters/MailingPresenter.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,6 @@
use App\Model\ACL\Resource;
use App\Model\Settings\Settings;
use App\Model\Settings\SettingsRepository;
use App\Model\Structure\SubeventRepository;
use Nette\Application\Responses\TextResponse;


/**
Expand All @@ -27,6 +25,8 @@ class MailingPresenter extends ActionBasePresenter
/**
* Ověří e-mail semináře.
* @param $code
* @throws \App\Model\Settings\SettingsException
* @throws \Nette\Application\AbortException
*/
public function actionVerify($code)
{
Expand All @@ -38,15 +38,13 @@ public function actionVerify($code)
$this->settingsRepository->setValue(Settings::SEMINAR_EMAIL_VERIFICATION_CODE, NULL);

$this->flashMessage('admin.configuration.mailing_email_verification_success', 'success');
}
else {
} else {
$this->flashMessage('admin.configuration.mailing_email_verification_error', 'danger');
}

if ($this->user->isAllowed(Resource::CONFIGURATION, Permission::MANAGE)) {
$this->redirect(':Admin:Configuration:Mailing:default');
}
else {
} else {
$this->redirect(':Web:Page:default');
}
}
Expand Down
118 changes: 78 additions & 40 deletions app/ActionModule/presenters/MaturityPresenter.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,6 @@

namespace App\ActionModule\Presenters;

use App\Model\ACL\Permission;
use App\Model\ACL\Resource;
use App\Model\ACL\Role;
use App\Model\ACL\RoleRepository;
use App\Model\Enums\ApplicationState;
Expand All @@ -12,12 +10,16 @@
use App\Model\Program\ProgramRepository;
use App\Model\Settings\Settings;
use App\Model\Settings\SettingsRepository;
use App\Model\Structure\SubeventRepository;
use App\Model\User\Application;
use App\Model\User\ApplicationRepository;
use App\Model\User\RolesApplication;
use App\Model\User\RolesApplicationRepository;
use App\Model\User\SubeventsApplicationRepository;
use App\Model\User\UserRepository;
use App\Services\ApplicationService;
use App\Services\MailService;
use App\Services\ProgramService;
use Doctrine\Common\Collections\ArrayCollection;
use Nette\Application\Responses\TextResponse;


/**
Expand Down Expand Up @@ -63,9 +65,37 @@ class MaturityPresenter extends ActionBasePresenter
*/
public $mailService;

/**
* @var ProgramService
* @inject
*/
public $programService;

/**
* @var ApplicationService
* @inject
*/
public $applicationService;

/**
* @var RolesApplicationRepository
* @inject
*/
public $rolesApplicationRepository;

/**
* @var SubeventsApplicationRepository
* @inject
*/
public $subeventsApplicationRepository;


/**
* Zkontroluje splatnost přihlášek.
* @throws \App\Model\Settings\SettingsException
* @throws \Throwable
* @throws \Ublaboo\Mailing\Exception\MailingException
* @throws \Ublaboo\Mailing\Exception\MailingMailCreationException
*/
public function actionCheck()
{
Expand All @@ -77,46 +107,54 @@ public function actionCheck()
if ($maturityReminder !== NULL)
$maturityReminderDate = (new \DateTime())->setTime(0, 0)->modify('+' . $maturityReminder . ' days');

foreach ($this->applicationRepository->findWaitingForPaymentApplications() as $application) {
$maturityDate = $application->getMaturityDate();
if ($maturityDate === NULL)
continue;

//zrušení registrace
if ($cancelRegistration !== NULL && $cancelRegistrationDate > $maturityDate) {
$this->userRepository->getEntityManager()->transactional(function($em) use($application) {
if ($application->isFirst()) {
$user = $application->getUser();

$user->setRoles(new ArrayCollection([$this->roleRepository->findBySystemName(Role::NONREGISTERED)]));
$user->setApproved(TRUE);
foreach ($user->getApplications() as $application) {
$this->applicationRepository->remove($application);
foreach ($this->userRepository->findAllWithWaitingForPaymentApplication() as $user) {
$this->applicationRepository->getEntityManager()->transactional(function ($em) use ($user, $cancelRegistration, $cancelRegistrationDate, $maturityReminder, $maturityReminderDate) {
foreach ($user->getWaitingForPaymentRolesApplications() as $application) {
if ($application->getType() == Application::ROLES) {
$maturityDate = $application->getMaturityDate();
if ($maturityDate === NULL)
continue;

if ($cancelRegistration !== NULL && $cancelRegistrationDate > $maturityDate) {
$rolesWithoutFee = $user->getRoles()->filter(function (Role $role) {
return $role->getFee() == 0;
});

if ($rolesWithoutFee->isEmpty()) {
$this->applicationService->cancelRegistration($user, ApplicationState::CANCELED_NOT_PAID, NULL);
return;
} else {
$this->applicationService->updateRoles($user, $rolesWithoutFee, NULL);
}
}
$this->userRepository->save($user);

$this->mailService->sendMailFromTemplate(new ArrayCollection(), new ArrayCollection([$user]), '', Template::REGISTRATION_CANCELED, [
TemplateVariable::SEMINAR_NAME => $this->settingsRepository->getValue(Settings::SEMINAR_NAME)
]);
}
else {
$application->setState(ApplicationState::CANCELED_NOT_PAID);
$this->applicationRepository->save($application);
}

foreach ($user->getWaitingForPaymentSubeventsApplications() as $application) {
if ($application->getType() == Application::SUBEVENTS) {
$maturityDate = $application->getMaturityDate();
if ($maturityDate === NULL)
continue;

if ($cancelRegistration !== NULL && $cancelRegistrationDate > $maturityDate) {
$this->applicationService->cancelSubeventsApplication($application, ApplicationState::CANCELED_NOT_PAID, NULL);
}
}
}

$this->programRepository->updateUserPrograms($application->getUser());
$this->userRepository->save($application->getUser());
});
continue;
}

//připomenutí splatnosti
if ($maturityReminder !== NULL && $maturityReminderDate == $maturityDate) {
$this->mailService->sendMailFromTemplate(new ArrayCollection(), new ArrayCollection([$application->getUser()]), '', Template::MATURITY_REMINDER, [
TemplateVariable::SEMINAR_NAME => $this->settingsRepository->getValue(Settings::SEMINAR_NAME),
TemplateVariable::APPLICATION_MATURITY => $maturityDate->format('j. n. Y')
]);
}
foreach ($user->getWaitingForPaymentApplications() as $application) {
$maturityDate = $application->getMaturityDate();
if ($maturityDate === NULL)
continue;

if ($maturityReminder !== NULL && $maturityReminderDate == $maturityDate) {
$this->mailService->sendMailFromTemplate($application->getUser(), '', Template::MATURITY_REMINDER, [
TemplateVariable::SEMINAR_NAME => $this->settingsRepository->getValue(Settings::SEMINAR_NAME),
TemplateVariable::APPLICATION_MATURITY => $maturityDate->format('j. n. Y')
]);
}
}
});
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ public function render()
/**
* Vytvoří komponentu.
* @param $name
* @throws \Ublaboo\DataGrid\Exception\DataGridException
*/
public function createComponentDocumentTagsGrid($name)
{
Expand Down Expand Up @@ -96,6 +97,7 @@ public function createComponentDocumentTagsGrid($name)
/**
* Zpracuje přidání štítku dokumentu.
* @param $values
* @throws \Nette\Application\AbortException
*/
public function add($values)
{
Expand All @@ -114,6 +116,7 @@ public function add($values)
* Zpracuje úpravu štítku dokumentu.
* @param $id
* @param $values
* @throws \Nette\Application\AbortException
*/
public function edit($id, $values)
{
Expand All @@ -131,6 +134,7 @@ public function edit($id, $values)
/**
* Zpracuje odstranění štítku dokumentu.
* @param $id
* @throws \Nette\Application\AbortException
*/
public function handleDelete($id)
{
Expand Down
4 changes: 4 additions & 0 deletions app/AdminModule/CMSModule/components/DocumentsGridControl.php
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,7 @@ public function render()
/**
* Vytvoří komponentu.
* @param $name
* @throws \Ublaboo\DataGrid\Exception\DataGridException
*/
public function createComponentDocumentsGrid($name)
{
Expand Down Expand Up @@ -153,6 +154,7 @@ public function createComponentDocumentsGrid($name)
/**
* Zpracuje přidání dokumentu.
* @param $values
* @throws \Nette\Application\AbortException
*/
public function add($values)
{
Expand All @@ -179,6 +181,7 @@ public function add($values)
* Zpracuje úpravu dokumentu.
* @param $id
* @param $values
* @throws \Nette\Application\AbortException
*/
public function edit($id, $values)
{
Expand Down Expand Up @@ -208,6 +211,7 @@ public function edit($id, $values)
/**
* Zpracuje odstranění dokumentu.
* @param $id
* @throws \Nette\Application\AbortException
*/
public function handleDelete($id)
{
Expand Down
6 changes: 6 additions & 0 deletions app/AdminModule/CMSModule/components/FaqGridControl.php
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,8 @@ public function render()
/**
* Vytvoří komponentu.
* @param $name
* @throws \Ublaboo\DataGrid\Exception\DataGridColumnStatusException
* @throws \Ublaboo\DataGrid\Exception\DataGridException
*/
public function createComponentFaqGrid($name)
{
Expand Down Expand Up @@ -96,6 +98,7 @@ public function createComponentFaqGrid($name)
/**
* Zpracuje odstranění otázky.
* @param $id
* @throws \Nette\Application\AbortException
*/
public function handleDelete($id)
{
Expand All @@ -112,6 +115,7 @@ public function handleDelete($id)
* @param $item_id
* @param $prev_id
* @param $next_id
* @throws \Nette\Application\AbortException
*/
public function handleSort($item_id, $prev_id, $next_id)
{
Expand All @@ -132,6 +136,8 @@ public function handleSort($item_id, $prev_id, $next_id)
* Změní viditelnost otázky.
* @param $id
* @param $public
* @throws \Doctrine\ORM\NonUniqueResultException
* @throws \Nette\Application\AbortException
*/
public function changeStatus($id, $public)
{
Expand Down
4 changes: 4 additions & 0 deletions app/AdminModule/CMSModule/components/NewsGridControl.php
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,8 @@ public function render()
/**
* Vytvoří komponentu.
* @param $name
* @throws \Ublaboo\DataGrid\Exception\DataGridColumnStatusException
* @throws \Ublaboo\DataGrid\Exception\DataGridException
*/
public function createComponentNewsGrid($name)
{
Expand Down Expand Up @@ -91,6 +93,7 @@ public function createComponentNewsGrid($name)
/**
* Zpracuje odstranění aktuality.
* @param $id
* @throws \Nette\Application\AbortException
*/
public function handleDelete($id)
{
Expand All @@ -106,6 +109,7 @@ public function handleDelete($id)
* Změní připíchnutí aktuality.
* @param $id
* @param $pinned
* @throws \Nette\Application\AbortException
*/
public function changePinned($id, $pinned)
{
Expand Down
16 changes: 14 additions & 2 deletions app/AdminModule/CMSModule/components/PagesGridControl.php
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,8 @@ public function render()
/**
* Vytvoří komponentu.
* @param $name
* @throws \Ublaboo\DataGrid\Exception\DataGridColumnStatusException
* @throws \Ublaboo\DataGrid\Exception\DataGridException
*/
public function createComponentPagesGrid($name)
{
Expand Down Expand Up @@ -162,6 +164,8 @@ public function createComponentPagesGrid($name)
/**
* Zpracuje přidání stránky.
* @param $values
* @throws \Doctrine\ORM\NonUniqueResultException
* @throws \Nette\Application\AbortException
*/
public function add($values)
{
Expand All @@ -182,6 +186,8 @@ public function add($values)
* Zpracuje upravení stránky.
* @param $id
* @param $values
* @throws \Doctrine\ORM\NonUniqueResultException
* @throws \Nette\Application\AbortException
*/
public function edit($id, $values)
{
Expand All @@ -203,6 +209,8 @@ public function edit($id, $values)
/**
* Zpracuje odstranění stránky.
* @param $id
* @throws \App\Model\Page\PageException
* @throws \Nette\Application\AbortException
*/
public function handleDelete($id)
{
Expand All @@ -219,6 +227,7 @@ public function handleDelete($id)
* @param $item_id
* @param $prev_id
* @param $next_id
* @throws \Nette\Application\AbortException
*/
public function handleSort($item_id, $prev_id, $next_id)
{
Expand All @@ -239,15 +248,18 @@ public function handleSort($item_id, $prev_id, $next_id)
* Změní viditelnost stránky.
* @param $id
* @param $public
* @throws \Doctrine\ORM\NonUniqueResultException
* @throws \Nette\Application\AbortException
*/
public function changeStatus($id, $public)
{
$p = $this->getPresenter();

if ($this->pageRepository->findById($id)->getSlug() == '/' && !$public) {
$page = $this->pageRepository->findById($id);

if ($page->getSlug() == '/' && !$public) {
$p->flashMessage('admin.cms.pages_change_public_denied', 'danger');
} else {
$page = $this->pageRepository->findById($id);
$page->setPublic($public);
$this->pageRepository->save($page);

Expand Down
1 change: 1 addition & 0 deletions app/AdminModule/CMSModule/forms/FaqForm.php
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,7 @@ public function create($id, $userId)
* Zpracuje formulář.
* @param Form $form
* @param \stdClass $values
* @throws \Doctrine\ORM\NonUniqueResultException
*/
public function processForm(Form $form, \stdClass $values)
{
Expand Down
Loading

0 comments on commit 014d38c

Please sign in to comment.