@@ -10,9 +10,9 @@ |
||
| 10 | 10 | interface IProgramFormFactory |
| 11 | 11 | { |
| 12 | 12 | |
| 13 | - /** |
|
| 14 | - * @return \App\Forms\ProgramForm |
|
| 15 | - */ |
|
| 16 | - public function create(): ProgramForm; |
|
| 13 | + /** |
|
| 14 | + * @return \App\Forms\ProgramForm |
|
| 15 | + */ |
|
| 16 | + public function create(): ProgramForm; |
|
| 17 | 17 | |
| 18 | 18 | } |
@@ -46,9 +46,9 @@ |
||
| 46 | 46 | |
| 47 | 47 | foreach($recipients as $recipient) { |
| 48 | 48 | $message->addTo( |
| 49 | - $recipient->email, |
|
| 50 | - trim($recipient->name . ' ' . $recipient->surname) |
|
| 51 | - ); |
|
| 49 | + $recipient->email, |
|
| 50 | + trim($recipient->name . ' ' . $recipient->surname) |
|
| 51 | + ); |
|
| 52 | 52 | } |
| 53 | 53 | // add bcc |
| 54 | 54 | if(!empty($bccMail)) { |
@@ -91,24 +91,24 @@ discard block |
||
| 91 | 91 | return $this->getVisitorModel()->find($id); |
| 92 | 92 | } |
| 93 | 93 | |
| 94 | - /** |
|
| 95 | - * @param int $id |
|
| 96 | - * @return ArrayHash |
|
| 97 | - */ |
|
| 98 | - public function findExpandedById(int $id): ArrayHash |
|
| 99 | - { |
|
| 100 | - $visitor = $this->findById($id); |
|
| 101 | - $meals = $this->getMealModel()->findByVisitorId($id); |
|
| 102 | - $programs = $this->assembleFormPrograms($id); |
|
| 103 | - |
|
| 104 | - return ArrayHash::from( |
|
| 105 | - array_merge( |
|
| 106 | - $visitor->toArray(), |
|
| 107 | - $meals, |
|
| 108 | - $programs |
|
| 109 | - ) |
|
| 110 | - ); |
|
| 111 | - } |
|
| 94 | + /** |
|
| 95 | + * @param int $id |
|
| 96 | + * @return ArrayHash |
|
| 97 | + */ |
|
| 98 | + public function findExpandedById(int $id): ArrayHash |
|
| 99 | + { |
|
| 100 | + $visitor = $this->findById($id); |
|
| 101 | + $meals = $this->getMealModel()->findByVisitorId($id); |
|
| 102 | + $programs = $this->assembleFormPrograms($id); |
|
| 103 | + |
|
| 104 | + return ArrayHash::from( |
|
| 105 | + array_merge( |
|
| 106 | + $visitor->toArray(), |
|
| 107 | + $meals, |
|
| 108 | + $programs |
|
| 109 | + ) |
|
| 110 | + ); |
|
| 111 | + } |
|
| 112 | 112 | |
| 113 | 113 | /** |
| 114 | 114 | * Return visitor by guid |
@@ -196,30 +196,30 @@ discard block |
||
| 196 | 196 | return $id; |
| 197 | 197 | } |
| 198 | 198 | |
| 199 | - /** |
|
| 200 | - * @param integer $id |
|
| 201 | - * @param array $data |
|
| 202 | - * @return integer |
|
| 203 | - */ |
|
| 204 | - public function updateByGuid($guid, $values) |
|
| 205 | - { |
|
| 206 | - $visitor = $this->filterFields($values, $this->getVisitorModel()->getColumns()); |
|
| 199 | + /** |
|
| 200 | + * @param integer $id |
|
| 201 | + * @param array $data |
|
| 202 | + * @return integer |
|
| 203 | + */ |
|
| 204 | + public function updateByGuid($guid, $values) |
|
| 205 | + { |
|
| 206 | + $visitor = $this->filterFields($values, $this->getVisitorModel()->getColumns()); |
|
| 207 | 207 | |
| 208 | - $visitor['birthday'] = $this->convertToDateTime($visitor['birthday']); |
|
| 208 | + $visitor['birthday'] = $this->convertToDateTime($visitor['birthday']); |
|
| 209 | 209 | |
| 210 | - $visitor['code'] = $this->calculateCode4Bank( |
|
| 211 | - $visitor['name'], |
|
| 212 | - $visitor['surname'], |
|
| 213 | - $visitor['birthday']->format('d. m. Y') |
|
| 214 | - ); |
|
| 210 | + $visitor['code'] = $this->calculateCode4Bank( |
|
| 211 | + $visitor['name'], |
|
| 212 | + $visitor['surname'], |
|
| 213 | + $visitor['birthday']->format('d. m. Y') |
|
| 214 | + ); |
|
| 215 | 215 | |
| 216 | - $meals = $this->filterFields($values, $this->getMealModel()->getColumns()); |
|
| 217 | - $programs = $this->filterProgramFields($values); |
|
| 216 | + $meals = $this->filterFields($values, $this->getMealModel()->getColumns()); |
|
| 217 | + $programs = $this->filterProgramFields($values); |
|
| 218 | 218 | |
| 219 | - $guid = $this->getVisitorModel()->modifyByGuid($guid, $visitor, $meals, $programs); |
|
| 219 | + $guid = $this->getVisitorModel()->modifyByGuid($guid, $visitor, $meals, $programs); |
|
| 220 | 220 | |
| 221 | - return $guid; |
|
| 222 | - } |
|
| 221 | + return $guid; |
|
| 222 | + } |
|
| 223 | 223 | |
| 224 | 224 | /** |
| 225 | 225 | * @param integer $id |
@@ -240,21 +240,21 @@ discard block |
||
| 240 | 240 | return $this->getVisitorModel()->getCount(); |
| 241 | 241 | } |
| 242 | 242 | |
| 243 | - /** |
|
| 244 | - * @param int $id |
|
| 245 | - * @return string |
|
| 246 | - * @throws \Exception |
|
| 247 | - */ |
|
| 243 | + /** |
|
| 244 | + * @param int $id |
|
| 245 | + * @return string |
|
| 246 | + * @throws \Exception |
|
| 247 | + */ |
|
| 248 | 248 | public function payCostCharge($id) |
| 249 | 249 | { |
| 250 | 250 | return $this->getVisitorModel()->payCharge($id, 'cost'); |
| 251 | 251 | } |
| 252 | 252 | |
| 253 | - /** |
|
| 254 | - * @param int $id |
|
| 255 | - * @return string |
|
| 256 | - * @throws \Exception |
|
| 257 | - */ |
|
| 253 | + /** |
|
| 254 | + * @param int $id |
|
| 255 | + * @return string |
|
| 256 | + * @throws \Exception |
|
| 257 | + */ |
|
| 258 | 258 | public function payAdvanceCharge($id) |
| 259 | 259 | { |
| 260 | 260 | return $this->getVisitorModel()->payCharge($id, 'advance'); |
@@ -69,13 +69,13 @@ discard block |
||
| 69 | 69 | return $this->getProgramModel()->findByVisitorId($visitorId); |
| 70 | 70 | } |
| 71 | 71 | |
| 72 | - /** |
|
| 73 | - * @param int $blockId |
|
| 74 | - * @return array |
|
| 75 | - */ |
|
| 76 | - public function findByBlockId(int $blockId): array |
|
| 77 | - { |
|
| 78 | - return $this->getProgramModel()->findByBlockId($blockId); |
|
| 72 | + /** |
|
| 73 | + * @param int $blockId |
|
| 74 | + * @return array |
|
| 75 | + */ |
|
| 76 | + public function findByBlockId(int $blockId): array |
|
| 77 | + { |
|
| 78 | + return $this->getProgramModel()->findByBlockId($blockId); |
|
| 79 | 79 | } |
| 80 | 80 | |
| 81 | 81 | /** |
@@ -127,13 +127,13 @@ discard block |
||
| 127 | 127 | return $this->getProgramModel()->delete($id); |
| 128 | 128 | } |
| 129 | 129 | |
| 130 | - /** |
|
| 131 | - * @param int $programId |
|
| 132 | - * @return int |
|
| 133 | - */ |
|
| 134 | - public function countVisitors(int $programId): int |
|
| 135 | - { |
|
| 136 | - return $this->getProgramModel()->countProgramVisitors($programId); |
|
| 130 | + /** |
|
| 131 | + * @param int $programId |
|
| 132 | + * @return int |
|
| 133 | + */ |
|
| 134 | + public function countVisitors(int $programId): int |
|
| 135 | + { |
|
| 136 | + return $this->getProgramModel()->countProgramVisitors($programId); |
|
| 137 | 137 | } |
| 138 | 138 | |
| 139 | 139 | /** |
@@ -25,10 +25,10 @@ discard block |
||
| 25 | 25 | */ |
| 26 | 26 | public $onVisitorSave; |
| 27 | 27 | |
| 28 | - /** |
|
| 29 | - * @var Closure |
|
| 30 | - */ |
|
| 31 | - public $onVisitorReset; |
|
| 28 | + /** |
|
| 29 | + * @var Closure |
|
| 30 | + */ |
|
| 31 | + public $onVisitorReset; |
|
| 32 | 32 | |
| 33 | 33 | /** |
| 34 | 34 | * @var ProvinceModel |
@@ -60,13 +60,13 @@ discard block |
||
| 60 | 60 | */ |
| 61 | 61 | protected $programFields = []; |
| 62 | 62 | |
| 63 | - /** |
|
| 64 | - * VisitorForm constructor. |
|
| 65 | - * @param ProvinceModel $province |
|
| 66 | - * @param ProgramRepository $program |
|
| 67 | - * @param BlockModel $block |
|
| 68 | - * @param MeetingModel $meeting |
|
| 69 | - */ |
|
| 63 | + /** |
|
| 64 | + * VisitorForm constructor. |
|
| 65 | + * @param ProvinceModel $province |
|
| 66 | + * @param ProgramRepository $program |
|
| 67 | + * @param BlockModel $block |
|
| 68 | + * @param MeetingModel $meeting |
|
| 69 | + */ |
|
| 70 | 70 | public function __construct( |
| 71 | 71 | ProvinceModel $province, |
| 72 | 72 | ProgramRepository $program, |
@@ -128,15 +128,15 @@ discard block |
||
| 128 | 128 | ->getLabelPrototype()->setAttribute('class', 'required'); |
| 129 | 129 | $form->addEmail('email', 'E-mail:') |
| 130 | 130 | ->setRequired(static::MESSAGE_REQUIRED) |
| 131 | - ->setAttribute('size', 30) |
|
| 131 | + ->setAttribute('size', 30) |
|
| 132 | + ->getLabelPrototype()->setAttribute('class', 'required'); |
|
| 133 | + $form->addTbDatePicker('birthday', 'Datum narození:', null, 16) |
|
| 134 | + ->setRequired(static::MESSAGE_REQUIRED) |
|
| 135 | + ->setFormat('d.m.Y') |
|
| 136 | + ->setAttribute('placeholder', 'dd. mm. rrrr') |
|
| 137 | + ->setAttribute('id', 'birthday') |
|
| 138 | + ->setAttribute('class', 'datePicker') |
|
| 132 | 139 | ->getLabelPrototype()->setAttribute('class', 'required'); |
| 133 | - $form->addTbDatePicker('birthday', 'Datum narození:', null, 16) |
|
| 134 | - ->setRequired(static::MESSAGE_REQUIRED) |
|
| 135 | - ->setFormat('d.m.Y') |
|
| 136 | - ->setAttribute('placeholder', 'dd. mm. rrrr') |
|
| 137 | - ->setAttribute('id', 'birthday') |
|
| 138 | - ->setAttribute('class', 'datePicker') |
|
| 139 | - ->getLabelPrototype()->setAttribute('class', 'required'); |
|
| 140 | 140 | $form->addText('street', 'Ulice:', 30) |
| 141 | 141 | ->setRequired(static::MESSAGE_REQUIRED) |
| 142 | 142 | ->addRule(Form::MAX_LENGTH, static::MESSAGE_MAX_LENGTH, 30) |
@@ -179,53 +179,53 @@ discard block |
||
| 179 | 179 | ->setAttribute('placeholder', 'Vaše nabídka na sdílení dobré praxe (co u vás umíte dobře a jste ochotni se o to podělit)'); |
| 180 | 180 | $form->addTextArea('question2', 'Počet a typy lodí:', 50, 8) |
| 181 | 181 | ->setAttribute('placeholder', 'Počet a typy lodí, které sebou přivezete (vyplňte pokud ano)'); |
| 182 | - $form->addText('bill', 'Zaplaceno:', 30) |
|
| 183 | - ->setDefaultValue(0); |
|
| 184 | - $form->addText('cost', 'Poplatek:', 30) |
|
| 185 | - ->setDefaultValue($this->getMeetingModel()->getPrice('cost')); |
|
| 182 | + $form->addText('bill', 'Zaplaceno:', 30) |
|
| 183 | + ->setDefaultValue(0); |
|
| 184 | + $form->addText('cost', 'Poplatek:', 30) |
|
| 185 | + ->setDefaultValue($this->getMeetingModel()->getPrice('cost')); |
|
| 186 | 186 | |
| 187 | 187 | $form = $this->buildProgramSwitcher($form); |
| 188 | 188 | |
| 189 | 189 | $form->addHidden('mid', $this->getMeetingId()); |
| 190 | - $form->addHidden('meeting', $this->getMeetingId()); |
|
| 190 | + $form->addHidden('meeting', $this->getMeetingId()); |
|
| 191 | 191 | $form->addHidden('backlink'); |
| 192 | 192 | |
| 193 | - $form->addSubmit('save', 'Uložit') |
|
| 194 | - ->setAttribute('class', 'btn-primary') |
|
| 195 | - ->onClick[] = [$this, 'processSave']; |
|
| 196 | - $form->addSubmit('reset', 'Storno') |
|
| 197 | - ->setAttribute('class', 'btn-reset') |
|
| 198 | - ->onClick[] = [$this, 'processReset']; |
|
| 193 | + $form->addSubmit('save', 'Uložit') |
|
| 194 | + ->setAttribute('class', 'btn-primary') |
|
| 195 | + ->onClick[] = [$this, 'processSave']; |
|
| 196 | + $form->addSubmit('reset', 'Storno') |
|
| 197 | + ->setAttribute('class', 'btn-reset') |
|
| 198 | + ->onClick[] = [$this, 'processReset']; |
|
| 199 | 199 | |
| 200 | 200 | |
| 201 | - $form = $this->setupRendering($form); |
|
| 201 | + $form = $this->setupRendering($form); |
|
| 202 | 202 | |
| 203 | 203 | $form->onSuccess[] = [$this, 'processForm']; |
| 204 | 204 | |
| 205 | 205 | return $form; |
| 206 | 206 | } |
| 207 | 207 | |
| 208 | - /** |
|
| 209 | - * @param SubmitButton $button |
|
| 210 | - * @return void |
|
| 211 | - */ |
|
| 212 | - public function processSave(SubmitButton $button) |
|
| 213 | - { |
|
| 214 | - $visitor = $button->getForm()->getValues(); |
|
| 215 | - |
|
| 216 | - $this->onVisitorSave($this, $visitor); |
|
| 217 | - } |
|
| 218 | - |
|
| 219 | - /** |
|
| 220 | - * @param SubmitButton $button |
|
| 221 | - * @return void |
|
| 222 | - */ |
|
| 223 | - public function processReset(SubmitButton $button) |
|
| 224 | - { |
|
| 225 | - $visitor = $button->getForm()->getValues(); |
|
| 226 | - |
|
| 227 | - $this->onVisitorReset($this, $visitor); |
|
| 228 | - } |
|
| 208 | + /** |
|
| 209 | + * @param SubmitButton $button |
|
| 210 | + * @return void |
|
| 211 | + */ |
|
| 212 | + public function processSave(SubmitButton $button) |
|
| 213 | + { |
|
| 214 | + $visitor = $button->getForm()->getValues(); |
|
| 215 | + |
|
| 216 | + $this->onVisitorSave($this, $visitor); |
|
| 217 | + } |
|
| 218 | + |
|
| 219 | + /** |
|
| 220 | + * @param SubmitButton $button |
|
| 221 | + * @return void |
|
| 222 | + */ |
|
| 223 | + public function processReset(SubmitButton $button) |
|
| 224 | + { |
|
| 225 | + $visitor = $button->getForm()->getValues(); |
|
| 226 | + |
|
| 227 | + $this->onVisitorReset($this, $visitor); |
|
| 228 | + } |
|
| 229 | 229 | |
| 230 | 230 | /** |
| 231 | 231 | * @param Form $form |
@@ -10,9 +10,9 @@ |
||
| 10 | 10 | interface IVisitorFormFactory |
| 11 | 11 | { |
| 12 | 12 | |
| 13 | - /** |
|
| 14 | - * @return \App\Components\Forms\VisitorForm |
|
| 15 | - */ |
|
| 16 | - public function create(): VisitorForm; |
|
| 13 | + /** |
|
| 14 | + * @return \App\Components\Forms\VisitorForm |
|
| 15 | + */ |
|
| 16 | + public function create(): VisitorForm; |
|
| 17 | 17 | |
| 18 | 18 | } |
@@ -88,22 +88,22 @@ discard block |
||
| 88 | 88 | ->update($data); |
| 89 | 89 | } |
| 90 | 90 | |
| 91 | - /** |
|
| 92 | - * @param int $visitorId |
|
| 93 | - * @param array $values |
|
| 94 | - * @return ActiveRow|bool |
|
| 95 | - */ |
|
| 91 | + /** |
|
| 92 | + * @param int $visitorId |
|
| 93 | + * @param array $values |
|
| 94 | + * @return ActiveRow|bool |
|
| 95 | + */ |
|
| 96 | 96 | public function updateOrCreate(int $visitorId, array $values) |
| 97 | - { |
|
| 98 | - $result = $this->updateByVisitor($visitorId, $values); |
|
| 97 | + { |
|
| 98 | + $result = $this->updateByVisitor($visitorId, $values); |
|
| 99 | 99 | |
| 100 | - if(!$result) { |
|
| 101 | - $values['visitor'] = $visitorId; |
|
| 102 | - $result = $this->create($values); |
|
| 103 | - } |
|
| 100 | + if(!$result) { |
|
| 101 | + $values['visitor'] = $visitorId; |
|
| 102 | + $result = $this->create($values); |
|
| 103 | + } |
|
| 104 | 104 | |
| 105 | - return $result; |
|
| 106 | - } |
|
| 105 | + return $result; |
|
| 106 | + } |
|
| 107 | 107 | |
| 108 | 108 | /** |
| 109 | 109 | * Get meals data by visitor id |
@@ -120,12 +120,12 @@ discard block |
||
| 120 | 120 | ->fetch(); |
| 121 | 121 | |
| 122 | 122 | if(!$meals) { |
| 123 | - $meals = []; |
|
| 124 | - } else { |
|
| 125 | - $meals = $meals->toArray(); |
|
| 126 | - } |
|
| 123 | + $meals = []; |
|
| 124 | + } else { |
|
| 125 | + $meals = $meals->toArray(); |
|
| 126 | + } |
|
| 127 | 127 | |
| 128 | - return $meals; |
|
| 128 | + return $meals; |
|
| 129 | 129 | |
| 130 | 130 | } |
| 131 | 131 | |
@@ -55,20 +55,20 @@ discard block |
||
| 55 | 55 | */ |
| 56 | 56 | protected $skautisEventService; |
| 57 | 57 | |
| 58 | - /** |
|
| 59 | - * @var MealModel |
|
| 60 | - */ |
|
| 58 | + /** |
|
| 59 | + * @var MealModel |
|
| 60 | + */ |
|
| 61 | 61 | private $mealModel; |
| 62 | 62 | |
| 63 | - /** |
|
| 64 | - * @var ProgramRepository |
|
| 65 | - */ |
|
| 63 | + /** |
|
| 64 | + * @var ProgramRepository |
|
| 65 | + */ |
|
| 66 | 66 | private $programRepository; |
| 67 | 67 | |
| 68 | - protected $error = FALSE; |
|
| 69 | - protected $hash = NULL; |
|
| 70 | - private $user; |
|
| 71 | - private $event; |
|
| 68 | + protected $error = FALSE; |
|
| 69 | + protected $hash = NULL; |
|
| 70 | + private $user; |
|
| 71 | + private $event; |
|
| 72 | 72 | |
| 73 | 73 | /** |
| 74 | 74 | * @param MeetingModel $meetingModel |
@@ -107,10 +107,10 @@ discard block |
||
| 107 | 107 | } |
| 108 | 108 | |
| 109 | 109 | /** |
| 110 | - * Injector |
|
| 111 | - * |
|
| 112 | - * @param IRegistrationFormFactory $factory |
|
| 113 | - */ |
|
| 110 | + * Injector |
|
| 111 | + * |
|
| 112 | + * @param IRegistrationFormFactory $factory |
|
| 113 | + */ |
|
| 114 | 114 | public function injectRegistrationFormFactory(IRegistrationFormFactory $factory) |
| 115 | 115 | { |
| 116 | 116 | $this->registrationFormFactory = $factory; |
@@ -268,7 +268,7 @@ discard block |
||
| 268 | 268 | $control = $this->registrationFormFactory->create(); |
| 269 | 269 | $control->setMeetingId($this->getMeetingId()); |
| 270 | 270 | $control->onRegistrationSave[] = function(RegistrationForm $control, $visitor) { |
| 271 | - $guid = $this->getParameter('guid'); |
|
| 271 | + $guid = $this->getParameter('guid'); |
|
| 272 | 272 | |
| 273 | 273 | if($guid) { |
| 274 | 274 | $guid = $this->actionUpdate($guid, $visitor); |
@@ -422,23 +422,23 @@ discard block |
||
| 422 | 422 | return $this; |
| 423 | 423 | } |
| 424 | 424 | |
| 425 | - /** |
|
| 426 | - * @return ProgramRepository |
|
| 427 | - */ |
|
| 428 | - protected function getProgramRepository(): ProgramRepository |
|
| 429 | - { |
|
| 430 | - return $this->programRepository; |
|
| 431 | - } |
|
| 432 | - |
|
| 433 | - /** |
|
| 434 | - * @param ProgramRepository $repository |
|
| 435 | - * @return RegistrationPresenter |
|
| 436 | - */ |
|
| 437 | - protected function setProgramRepository(ProgramRepository $repository): self |
|
| 438 | - { |
|
| 439 | - $this->programRepository = $repository; |
|
| 440 | - |
|
| 441 | - return $this; |
|
| 442 | - } |
|
| 425 | + /** |
|
| 426 | + * @return ProgramRepository |
|
| 427 | + */ |
|
| 428 | + protected function getProgramRepository(): ProgramRepository |
|
| 429 | + { |
|
| 430 | + return $this->programRepository; |
|
| 431 | + } |
|
| 432 | + |
|
| 433 | + /** |
|
| 434 | + * @param ProgramRepository $repository |
|
| 435 | + * @return RegistrationPresenter |
|
| 436 | + */ |
|
| 437 | + protected function setProgramRepository(ProgramRepository $repository): self |
|
| 438 | + { |
|
| 439 | + $this->programRepository = $repository; |
|
| 440 | + |
|
| 441 | + return $this; |
|
| 442 | + } |
|
| 443 | 443 | |
| 444 | 444 | } |
@@ -480,19 +480,19 @@ |
||
| 480 | 480 | } |
| 481 | 481 | } |
| 482 | 482 | |
| 483 | - /** |
|
| 484 | - * @param Nette\Utils\ArrayHash $array |
|
| 485 | - * @return self |
|
| 486 | - */ |
|
| 487 | - protected function setBacklinkFromArray(ArrayHash $array): self |
|
| 488 | - { |
|
| 489 | - if(array_key_exists('backlink', $array) && !empty($array['backlink'])) { |
|
| 490 | - $this->setBacklink($array['backlink']); |
|
| 491 | - unset($array['backlink']); |
|
| 492 | - } |
|
| 493 | - |
|
| 494 | - return $this; |
|
| 495 | - } |
|
| 483 | + /** |
|
| 484 | + * @param Nette\Utils\ArrayHash $array |
|
| 485 | + * @return self |
|
| 486 | + */ |
|
| 487 | + protected function setBacklinkFromArray(ArrayHash $array): self |
|
| 488 | + { |
|
| 489 | + if(array_key_exists('backlink', $array) && !empty($array['backlink'])) { |
|
| 490 | + $this->setBacklink($array['backlink']); |
|
| 491 | + unset($array['backlink']); |
|
| 492 | + } |
|
| 493 | + |
|
| 494 | + return $this; |
|
| 495 | + } |
|
| 496 | 496 | |
| 497 | 497 | /** |
| 498 | 498 | * Flashes success message |