Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(activity): add Zettle as option for facilities #1990

Merged
merged 1 commit into from
Feb 27, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions .env.dist
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,8 @@ MAIL_TO_ACTIVITY_CREATION_REQUIRE_GEFLITST_NAME=ApplicatieBeheerCommissie
MAIL_TO_ACTIVITY_CREATION_REQUIRE_GEFLITST_PLANKA_ADDRESS=example@example.com
MAIL_TO_ACTIVITY_CREATION_REQUIRE_GEFLITST_PLANKA_KEY=933632049134645737638108890119485901261134
MAIL_TO_ACTIVITY_CREATION_REQUIRE_GEFLITST_PLANKA_NAME=ApplicatieBeheerCommissie
MAIL_TO_ACTIVITY_CREATION_REQUIRE_ZETTLE_ADDRESS=example@example.com
MAIL_TO_ACTIVITY_CREATION_REQUIRE_ZETTLE_NAME=ApplicatieBeheerCommissie
[email protected]
MAIL_TO_ACTIVITY_CALENDAR_NAME=ApplicatieBeheerCommissie
[email protected]
Expand Down
4 changes: 4 additions & 0 deletions config/autoload/local.development.php.dist
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,10 @@ return [
'key' => getenv('MAIL_TO_ACTIVITY_CREATION_REQUIRE_GEFLITST_PLANKA_KEY'),
'name' => getenv('MAIL_TO_ACTIVITY_CREATION_REQUIRE_GEFLITST_PLANKA_NAME'),
],
'activity_creation_require_Zettle' => [
'address' => getenv('MAIL_TO_ACTIVITY_CREATION_REQUIRE_ZETTLE_ADDRESS'),
'name' => getenv('MAIL_TO_ACTIVITY_CREATION_REQUIRE_ZETTLE_NAME'),
],
],
],

Expand Down
4 changes: 4 additions & 0 deletions config/autoload/local.production.php.dist
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,10 @@ return [
'key' => getenv('MAIL_TO_ACTIVITY_CREATION_REQUIRE_GEFLITST_PLANKA_KEY'),
'name' => getenv('MAIL_TO_ACTIVITY_CREATION_REQUIRE_GEFLITST_PLANKA_NAME'),
],
'activity_creation_require_Zettle' => [
'address' => getenv('MAIL_TO_ACTIVITY_CREATION_REQUIRE_ZETTLE_ADDRESS'),
'name' => getenv('MAIL_TO_ACTIVITY_CREATION_REQUIRE_ZETTLE_NAME'),
],
],
],

Expand Down
5 changes: 5 additions & 0 deletions docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,11 @@ services:
# MAIL_TO_ACTIVITY_CREATION_NAME=
# MAIL_TO_ACTIVITY_CREATION_REQUIRE_GEFLITST_ADDRESS=
# MAIL_TO_ACTIVITY_CREATION_REQUIRE_GEFLITST_NAME=
# MAIL_TO_ACTIVITY_CREATION_REQUIRE_GEFLITST_PLANKA_ADDRESS=
# MAIL_TO_ACTIVITY_CREATION_REQUIRE_GEFLITST_PLANKA_KEY=
# MAIL_TO_ACTIVITY_CREATION_REQUIRE_GEFLITST_PLANKA_NAME=
# MAIL_TO_ACTIVITY_CREATION_REQUIRE_ZETTLE_ADDRESS=
# MAIL_TO_ACTIVITY_CREATION_REQUIRE_ZETTLE_NAME=
# MAIL_TO_ACTIVITY_CALENDAR_ADDRESS=
# MAIL_TO_ACTIVITY_CALENDAR_NAME=
# MAIL_TO_ORGAN_UPDATE_ADDRESS=
Expand Down
11 changes: 11 additions & 0 deletions module/Activity/src/Form/Activity.php
Original file line number Diff line number Diff line change
Expand Up @@ -152,6 +152,17 @@ public function __construct(Translator $translator)
],
);

$this->add(
[
'name' => 'requireZettle',
'type' => Checkbox::class,
'options' => [
'checked_value' => '1',
'unchecked_value' => '0',
],
],
);

$this->add(
[
'name' => 'categories',
Expand Down
22 changes: 21 additions & 1 deletion module/Activity/src/Model/Activity.php
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@
* company: ?CompanyModel,
* isMyFuture: bool,
* requireGEFLITST: bool,
* requireZettle: bool,
* categories: ImportedActivityCategoryArrayType[],
* signupLists: ImportedSignupListArrayType[],
* }
Expand All @@ -63,6 +64,7 @@
* company: ?int,
* isMyFuture: bool,
* requireGEFLITST: bool,
* requireZettle: bool,
* categories: ImportedActivityCategoryGdprArrayType[],
* signupLists: ImportedSignupListGdprArrayType[],
* }
Expand Down Expand Up @@ -242,7 +244,13 @@ class Activity implements OrganResourceInterface, CreatorResourceInterface
* Whether this activity needs a GEFLITST photographer.
*/
#[Column(type: 'boolean')]
protected bool $requireGEFLITST;
protected bool $requireGEFLITST = false;

/**
* Whether this activity needs a Zettle.
*/
#[Column(type: 'boolean')]
protected bool $requireZettle = false;

public function __construct()
{
Expand Down Expand Up @@ -472,6 +480,16 @@ public function setRequireGEFLITST(bool $requireGEFLITST): void
$this->requireGEFLITST = $requireGEFLITST;
}

public function getRequireZettle(): bool
{
return $this->requireZettle;
}

public function setRequireZettle(bool $requireZettle): void
{
$this->requireZettle = $requireZettle;
}

/**
* @return Collection<array-key, ActivityCategory>
*/
Expand Down Expand Up @@ -523,6 +541,7 @@ public function toArray(): array
'company' => $this->getCompany(),
'isMyFuture' => $this->getIsMyFuture(),
'requireGEFLITST' => $this->getRequireGEFLITST(),
'requireZettle' => $this->getRequireZettle(),
'categories' => $categoriesArrays,
'signupLists' => $signupListsArrays,
];
Expand Down Expand Up @@ -557,6 +576,7 @@ public function toGdprArray(): array
'company' => $this->getCompany()?->getId(),
'isMyFuture' => $this->getIsMyFuture(),
'requireGEFLITST' => $this->getRequireGEFLITST(),
'requireZettle' => $this->getRequireZettle(),
'categories' => $categoriesArrays,
'signupLists' => $signupListsArrays,
];
Expand Down
25 changes: 20 additions & 5 deletions module/Activity/src/Service/Activity.php
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,11 @@

// Send email to GEFLITST if user checked checkbox of GEFLITST
if ($activity->getRequireGEFLITST()) {
$this->requestGEFLITST($activity, $member, $organ);
$this->requestFacility('GEFLITST', $activity, $member, $organ);
}

if ($activity->getRequireZettle()) {
$this->requestFacility('Zettle', $activity, $member, $organ);
}

return true;
Expand Down Expand Up @@ -179,6 +183,7 @@

$activity->setIsMyFuture(boolval($data['isMyFuture']));
$activity->setRequireGEFLITST(boolval($data['requireGEFLITST']));
$activity->setRequireZettle(boolval($data['requireZettle']));

// Not user provided input
$activity->setCreator($user);
Expand Down Expand Up @@ -337,7 +342,11 @@
$em->flush();
}

private function requestGEFLITST(
/**
* @psalm-param 'GEFLITST'|'Zettle' $facilityType
*/
private function requestFacility(
string $facilityType,
ActivityModel $activity,
MemberModel $user,
?OrganModel $organ,
Expand All @@ -346,8 +355,8 @@
$activityTitle = $activity->getName()->getText('en');
$activityTime = $activity->getBeginTime()->format('d-m-Y H:i');

$type = 'activity_creation_require_GEFLITST';
$view = 'email/activity_created_require_GEFLITST';
$type = sprintf('activity_creation_require_%s', $facilityType);
$view = sprintf('email/activity_created_require_%s', $facilityType);

if (null !== $organ) {
$subject = sprintf('%s: %s on %s', $organ->getAbbr(), $activityTitle, $activityTime);
Expand Down Expand Up @@ -440,7 +449,7 @@
$data,
$member,
$organ,
$company,

Check failure on line 452 in module/Activity/src/Service/Activity.php

View workflow job for this annotation

GitHub Actions / Psalm

PossiblyFalseReference

module/Activity/src/Service/Activity.php:452:37: PossiblyFalseReference: Cannot call method getNew on possibly false value (see https://psalm.dev/105)
ActivityModel::STATUS_UPDATE,
);

Expand Down Expand Up @@ -526,7 +535,13 @@
// HTML forms do not know anything about booleans, hence we need to
// convert the strings to something we can use.
array_walk_recursive($proposal, static function (&$v, $k): void {
if (!in_array($k, ['isMyFuture', 'requireGEFLITST', 'onlyGEWIS', 'displaySubscribedNumber'], true)) {
if (
!in_array(
$k,
['isMyFuture', 'requireGEFLITST', 'requireZettle', 'onlyGEWIS', 'displaySubscribedNumber'],
true,
)
) {
return;
}

Expand Down
1 change: 1 addition & 0 deletions module/Activity/test/Mapper/ActivityMapperTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ public function setUp(): void
$this->object->setStatus(Activity::STATUS_APPROVED);
$this->object->setIsMyFuture(false);
$this->object->setRequireGEFLITST(false);
$this->object->setRequireZettle(false);
}

protected function setUpUser(): void
Expand Down
39 changes: 39 additions & 0 deletions module/Activity/view/email/activity_created_require_Zettle.phtml
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
For English, see below.

L.s.<br/><br/>

Er is een nieuwe activiteit aangemaakt op de GEWIS website waarvoor een Zettle nodig is.

<h3><?= $this->escapeHtml($activity->getName()->getText("nl")) ?></h3>

<p><?= $this->escapeHtml($activity->getDescription()->getText("nl")) ?></p>

<br/>

Ze zouden graag een antwoord van je horen. Kun je dat sturen naar '
<strong><?= $this->escapeHtml($requester) ?></strong>'?
Je kunt een antwoord sturen door te reageren op deze email.
<br/><br/>

Met vriendelijke groeten,<br/>
De ApplicatieBeheerCommissie
<hr/>

L.s.<br/><br/>

A new activity has been created on the GEWIS website that needs Zettle for payments.

<h3><?= $this->escapeHtml($activity->getName()->getText("en")) ?></h3>

<p><?= $this->escapeHtml($activity->getDescription()->getText("en")) ?></p>

<br/>

The organ that created this activity would love to have a reply back from you. Can you send this to '
<strong><?= $this->escapeHtml($requester) ?></strong>'?
You can send a response by replying to this email.
<br/><br/>

With kind regards,<br/>
The ApplicatieBeheerCommissie
<hr/>
22 changes: 22 additions & 0 deletions module/Activity/view/partial/create.phtml
Original file line number Diff line number Diff line change
Expand Up @@ -185,6 +185,14 @@ $lang = $this->plugin('translate')->getTranslator()->getLocale();
</label>
<?= $this->formElementErrors($isMyFuture) ?>
</div>
</div>
</div>
<div class="row">
<div class="col-md-12">
<h2><?= $this->translate('Facilities') ?></h2>
<p><?= $this->translate('Choose which facilities you would like for this activity.') ?></p>
</div>
<div class="col-md-6">
<?php
$requireGEFLITST = $form->get('requireGEFLITST')
->setAttribute('id', 'GEFLITST-check');
Expand All @@ -199,6 +207,20 @@ $lang = $this->plugin('translate')->getTranslator()->getLocale();
</label>
<?= $this->formElementErrors($requireGEFLITST) ?>
</div>
<?php
$requireZettle = $form->get('requireZettle')
->setAttribute('id', 'Zettle-check');
?>
<div class="form-group <?= $this->bootstrapElementError($requireZettle) ?>">
<label for="<?= $requireZettle->getAttribute('id') ?>">
<?= $this->formCheckbox($requireZettle) ?>
<?= $this->translate('This activity needs a Zettle for payments') ?>
<span data-toggle="tooltip" data-placement="right"
title="<?= $this->translate('When this is checked, the treasurer will be notified that this activity needs a Zettle.') ?>"
class="fas fa-info-circle" aria-hidden="true"></span>
</label>
<?= $this->formElementErrors($requireZettle) ?>
</div>
</div>
</div>
<script nonce="<?= NONCE_REPLACEMENT_STRING ?>">
Expand Down
26 changes: 18 additions & 8 deletions module/Application/language/en.po

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading
Loading