Skip to content

Commit 3b3f817

Browse files
authored
Merge pull request GEWIS#1990 from tomudding/feature/activity-facilities-update
feat(activity): add Zettle as option for facilities
2 parents 3aa758f + 7f855a3 commit 3b3f817

File tree

14 files changed

+213
-32
lines changed

14 files changed

+213
-32
lines changed

.env.dist

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,8 @@ MAIL_TO_ACTIVITY_CREATION_REQUIRE_GEFLITST_NAME=ApplicatieBeheerCommissie
3232
MAIL_TO_ACTIVITY_CREATION_REQUIRE_GEFLITST_PLANKA_ADDRESS=example@example.com
3333
MAIL_TO_ACTIVITY_CREATION_REQUIRE_GEFLITST_PLANKA_KEY=933632049134645737638108890119485901261134
3434
MAIL_TO_ACTIVITY_CREATION_REQUIRE_GEFLITST_PLANKA_NAME=ApplicatieBeheerCommissie
35+
MAIL_TO_ACTIVITY_CREATION_REQUIRE_ZETTLE_ADDRESS=example@example.com
36+
MAIL_TO_ACTIVITY_CREATION_REQUIRE_ZETTLE_NAME=ApplicatieBeheerCommissie
3537
MAIL_TO_ACTIVITY_CALENDAR_ADDRESS=example@example.com
3638
MAIL_TO_ACTIVITY_CALENDAR_NAME=ApplicatieBeheerCommissie
3739
MAIL_TO_ORGAN_UPDATE_ADDRESS=example@example.com

config/autoload/local.development.php.dist

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,10 @@ return [
6464
'key' => getenv('MAIL_TO_ACTIVITY_CREATION_REQUIRE_GEFLITST_PLANKA_KEY'),
6565
'name' => getenv('MAIL_TO_ACTIVITY_CREATION_REQUIRE_GEFLITST_PLANKA_NAME'),
6666
],
67+
'activity_creation_require_Zettle' => [
68+
'address' => getenv('MAIL_TO_ACTIVITY_CREATION_REQUIRE_ZETTLE_ADDRESS'),
69+
'name' => getenv('MAIL_TO_ACTIVITY_CREATION_REQUIRE_ZETTLE_NAME'),
70+
],
6771
],
6872
],
6973

config/autoload/local.production.php.dist

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,10 @@ return [
6464
'key' => getenv('MAIL_TO_ACTIVITY_CREATION_REQUIRE_GEFLITST_PLANKA_KEY'),
6565
'name' => getenv('MAIL_TO_ACTIVITY_CREATION_REQUIRE_GEFLITST_PLANKA_NAME'),
6666
],
67+
'activity_creation_require_Zettle' => [
68+
'address' => getenv('MAIL_TO_ACTIVITY_CREATION_REQUIRE_ZETTLE_ADDRESS'),
69+
'name' => getenv('MAIL_TO_ACTIVITY_CREATION_REQUIRE_ZETTLE_NAME'),
70+
],
6771
],
6872
],
6973

docker-compose.yml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,11 @@ services:
5353
# MAIL_TO_ACTIVITY_CREATION_NAME=
5454
# MAIL_TO_ACTIVITY_CREATION_REQUIRE_GEFLITST_ADDRESS=
5555
# MAIL_TO_ACTIVITY_CREATION_REQUIRE_GEFLITST_NAME=
56+
# MAIL_TO_ACTIVITY_CREATION_REQUIRE_GEFLITST_PLANKA_ADDRESS=
57+
# MAIL_TO_ACTIVITY_CREATION_REQUIRE_GEFLITST_PLANKA_KEY=
58+
# MAIL_TO_ACTIVITY_CREATION_REQUIRE_GEFLITST_PLANKA_NAME=
59+
# MAIL_TO_ACTIVITY_CREATION_REQUIRE_ZETTLE_ADDRESS=
60+
# MAIL_TO_ACTIVITY_CREATION_REQUIRE_ZETTLE_NAME=
5661
# MAIL_TO_ACTIVITY_CALENDAR_ADDRESS=
5762
# MAIL_TO_ACTIVITY_CALENDAR_NAME=
5863
# MAIL_TO_ORGAN_UPDATE_ADDRESS=

module/Activity/src/Form/Activity.php

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -152,6 +152,17 @@ public function __construct(Translator $translator)
152152
],
153153
);
154154

155+
$this->add(
156+
[
157+
'name' => 'requireZettle',
158+
'type' => Checkbox::class,
159+
'options' => [
160+
'checked_value' => '1',
161+
'unchecked_value' => '0',
162+
],
163+
],
164+
);
165+
155166
$this->add(
156167
[
157168
'name' => 'categories',

module/Activity/src/Model/Activity.php

Lines changed: 21 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,7 @@
4545
* company: ?CompanyModel,
4646
* isMyFuture: bool,
4747
* requireGEFLITST: bool,
48+
* requireZettle: bool,
4849
* categories: ImportedActivityCategoryArrayType[],
4950
* signupLists: ImportedSignupListArrayType[],
5051
* }
@@ -63,6 +64,7 @@
6364
* company: ?int,
6465
* isMyFuture: bool,
6566
* requireGEFLITST: bool,
67+
* requireZettle: bool,
6668
* categories: ImportedActivityCategoryGdprArrayType[],
6769
* signupLists: ImportedSignupListGdprArrayType[],
6870
* }
@@ -242,7 +244,13 @@ class Activity implements OrganResourceInterface, CreatorResourceInterface
242244
* Whether this activity needs a GEFLITST photographer.
243245
*/
244246
#[Column(type: 'boolean')]
245-
protected bool $requireGEFLITST;
247+
protected bool $requireGEFLITST = false;
248+
249+
/**
250+
* Whether this activity needs a Zettle.
251+
*/
252+
#[Column(type: 'boolean')]
253+
protected bool $requireZettle = false;
246254

247255
public function __construct()
248256
{
@@ -472,6 +480,16 @@ public function setRequireGEFLITST(bool $requireGEFLITST): void
472480
$this->requireGEFLITST = $requireGEFLITST;
473481
}
474482

483+
public function getRequireZettle(): bool
484+
{
485+
return $this->requireZettle;
486+
}
487+
488+
public function setRequireZettle(bool $requireZettle): void
489+
{
490+
$this->requireZettle = $requireZettle;
491+
}
492+
475493
/**
476494
* @return Collection<array-key, ActivityCategory>
477495
*/
@@ -523,6 +541,7 @@ public function toArray(): array
523541
'company' => $this->getCompany(),
524542
'isMyFuture' => $this->getIsMyFuture(),
525543
'requireGEFLITST' => $this->getRequireGEFLITST(),
544+
'requireZettle' => $this->getRequireZettle(),
526545
'categories' => $categoriesArrays,
527546
'signupLists' => $signupListsArrays,
528547
];
@@ -557,6 +576,7 @@ public function toGdprArray(): array
557576
'company' => $this->getCompany()?->getId(),
558577
'isMyFuture' => $this->getIsMyFuture(),
559578
'requireGEFLITST' => $this->getRequireGEFLITST(),
579+
'requireZettle' => $this->getRequireZettle(),
560580
'categories' => $categoriesArrays,
561581
'signupLists' => $signupListsArrays,
562582
];

module/Activity/src/Service/Activity.php

Lines changed: 20 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,11 @@ public function createActivity(array $data): bool
9090

9191
// Send email to GEFLITST if user checked checkbox of GEFLITST
9292
if ($activity->getRequireGEFLITST()) {
93-
$this->requestGEFLITST($activity, $member, $organ);
93+
$this->requestFacility('GEFLITST', $activity, $member, $organ);
94+
}
95+
96+
if ($activity->getRequireZettle()) {
97+
$this->requestFacility('Zettle', $activity, $member, $organ);
9498
}
9599

96100
return true;
@@ -179,6 +183,7 @@ protected function saveActivityData(
179183

180184
$activity->setIsMyFuture(boolval($data['isMyFuture']));
181185
$activity->setRequireGEFLITST(boolval($data['requireGEFLITST']));
186+
$activity->setRequireZettle(boolval($data['requireZettle']));
182187

183188
// Not user provided input
184189
$activity->setCreator($user);
@@ -337,7 +342,11 @@ protected function createSignupOption(
337342
$em->flush();
338343
}
339344

340-
private function requestGEFLITST(
345+
/**
346+
* @psalm-param 'GEFLITST'|'Zettle' $facilityType
347+
*/
348+
private function requestFacility(
349+
string $facilityType,
341350
ActivityModel $activity,
342351
MemberModel $user,
343352
?OrganModel $organ,
@@ -346,8 +355,8 @@ private function requestGEFLITST(
346355
$activityTitle = $activity->getName()->getText('en');
347356
$activityTime = $activity->getBeginTime()->format('d-m-Y H:i');
348357

349-
$type = 'activity_creation_require_GEFLITST';
350-
$view = 'email/activity_created_require_GEFLITST';
358+
$type = sprintf('activity_creation_require_%s', $facilityType);
359+
$view = sprintf('email/activity_created_require_%s', $facilityType);
351360

352361
if (null !== $organ) {
353362
$subject = sprintf('%s: %s on %s', $organ->getAbbr(), $activityTitle, $activityTime);
@@ -526,7 +535,13 @@ protected function isUpdateProposalNew(
526535
// HTML forms do not know anything about booleans, hence we need to
527536
// convert the strings to something we can use.
528537
array_walk_recursive($proposal, static function (&$v, $k): void {
529-
if (!in_array($k, ['isMyFuture', 'requireGEFLITST', 'onlyGEWIS', 'displaySubscribedNumber'], true)) {
538+
if (
539+
!in_array(
540+
$k,
541+
['isMyFuture', 'requireGEFLITST', 'requireZettle', 'onlyGEWIS', 'displaySubscribedNumber'],
542+
true,
543+
)
544+
) {
530545
return;
531546
}
532547

module/Activity/test/Mapper/ActivityMapperTest.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,7 @@ public function setUp(): void
4444
$this->object->setStatus(Activity::STATUS_APPROVED);
4545
$this->object->setIsMyFuture(false);
4646
$this->object->setRequireGEFLITST(false);
47+
$this->object->setRequireZettle(false);
4748
}
4849

4950
protected function setUpUser(): void
Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
For English, see below.
2+
3+
L.s.<br/><br/>
4+
5+
Er is een nieuwe activiteit aangemaakt op de GEWIS website waarvoor een Zettle nodig is.
6+
7+
<h3><?= $this->escapeHtml($activity->getName()->getText("nl")) ?></h3>
8+
9+
<p><?= $this->escapeHtml($activity->getDescription()->getText("nl")) ?></p>
10+
11+
<br/>
12+
13+
Ze zouden graag een antwoord van je horen. Kun je dat sturen naar '
14+
<strong><?= $this->escapeHtml($requester) ?></strong>'?
15+
Je kunt een antwoord sturen door te reageren op deze email.
16+
<br/><br/>
17+
18+
Met vriendelijke groeten,<br/>
19+
De ApplicatieBeheerCommissie
20+
<hr/>
21+
22+
L.s.<br/><br/>
23+
24+
A new activity has been created on the GEWIS website that needs Zettle for payments.
25+
26+
<h3><?= $this->escapeHtml($activity->getName()->getText("en")) ?></h3>
27+
28+
<p><?= $this->escapeHtml($activity->getDescription()->getText("en")) ?></p>
29+
30+
<br/>
31+
32+
The organ that created this activity would love to have a reply back from you. Can you send this to '
33+
<strong><?= $this->escapeHtml($requester) ?></strong>'?
34+
You can send a response by replying to this email.
35+
<br/><br/>
36+
37+
With kind regards,<br/>
38+
The ApplicatieBeheerCommissie
39+
<hr/>

module/Activity/view/partial/create.phtml

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -185,6 +185,14 @@ $lang = $this->plugin('translate')->getTranslator()->getLocale();
185185
</label>
186186
<?= $this->formElementErrors($isMyFuture) ?>
187187
</div>
188+
</div>
189+
</div>
190+
<div class="row">
191+
<div class="col-md-12">
192+
<h2><?= $this->translate('Facilities') ?></h2>
193+
<p><?= $this->translate('Choose which facilities you would like for this activity.') ?></p>
194+
</div>
195+
<div class="col-md-6">
188196
<?php
189197
$requireGEFLITST = $form->get('requireGEFLITST')
190198
->setAttribute('id', 'GEFLITST-check');
@@ -199,6 +207,20 @@ $lang = $this->plugin('translate')->getTranslator()->getLocale();
199207
</label>
200208
<?= $this->formElementErrors($requireGEFLITST) ?>
201209
</div>
210+
<?php
211+
$requireZettle = $form->get('requireZettle')
212+
->setAttribute('id', 'Zettle-check');
213+
?>
214+
<div class="form-group <?= $this->bootstrapElementError($requireZettle) ?>">
215+
<label for="<?= $requireZettle->getAttribute('id') ?>">
216+
<?= $this->formCheckbox($requireZettle) ?>
217+
<?= $this->translate('This activity needs a Zettle for payments') ?>
218+
<span data-toggle="tooltip" data-placement="right"
219+
title="<?= $this->translate('When this is checked, the treasurer will be notified that this activity needs a Zettle.') ?>"
220+
class="fas fa-info-circle" aria-hidden="true"></span>
221+
</label>
222+
<?= $this->formElementErrors($requireZettle) ?>
223+
</div>
202224
</div>
203225
</div>
204226
<script nonce="<?= NONCE_REPLACEMENT_STRING ?>">

0 commit comments

Comments
 (0)