Skip to content

Commit

Permalink
show renotify checkbox only if event starts within 7 days
Browse files Browse the repository at this point in the history
  • Loading branch information
mrothauer committed Jun 27, 2024
1 parent ed16ba0 commit 8eb1927
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 5 deletions.
5 changes: 4 additions & 1 deletion src/Controller/EventsController.php
Original file line number Diff line number Diff line change
Expand Up @@ -400,6 +400,9 @@ public function edit($eventUid)

$worknewsTable = FactoryLocator::get('Table')->get('Worknews');
$this->set('worknewsCount', $worknewsTable->getSubscribers($event->workshop_uid)->count());

$eventStartInLessThan7Days = $event->datumstart->isWithinNext('7 days');
$this->set('eventStartInLessThan7Days', $eventStartInLessThan7Days);

$patchedEntities = $this->_edit([$event], true);
$patchedEntity = $patchedEntities['events'][0];
Expand Down Expand Up @@ -452,7 +455,7 @@ private function _edit($events, $isEditMode)
$addressString = $data['strasse'] . ', ' . $data['zip'] . ' ' . $data['ort'] . ', ' . $data['land'];
$geoService = new GeoService();
$coordinates = $geoService->getLatLngFromGeoCodingService($addressString);
$data['lat'] = $coordinates['lat'];
$data['lat'] = $coordinates['lat'];
$data['lng'] = $coordinates['lng'];
}
if (!empty($data['use_custom_coordinates'])) {
Expand Down
12 changes: 8 additions & 4 deletions templates/Events/edit.php
Original file line number Diff line number Diff line change
Expand Up @@ -168,11 +168,15 @@
echo $this->Form->control($i.'.status', ['type' => 'select', 'options' => $loggedUser?->isAdmin() ? Configure::read('AppConfig.status') : Configure::read('AppConfig.status2')]).'<br />';

if ($isEditMode && $worknewsCount > 0) {
$worknewsString = 'Ich habe diesen Termin überarbeitet und möchte, dass alle ' . $worknewsCount . ' Termin-Abonnenten darüber nochmals informiert werden.';
if ($worknewsCount == 1) {
$worknewsString = 'Ich habe diesen Termin überarbeitet und möchte, dass ' . $worknewsCount . ' Termin-Abonnent darüber nochmals informiert wird.';
if (!$eventStartInLessThan7Days) {
$worknewsString = 'Das Informieren der Termin-Abonennten (' . $worknewsCount . ') ist nicht möglich, da der Termin in mehr als 7 Tagen stattfindet.';
} else {
$worknewsString = 'Ich habe diesen Termin überarbeitet und möchte, dass alle ' . $worknewsCount . ' Termin-Abonnenten darüber nochmals informiert werden.';
if ($worknewsCount == 1) {
$worknewsString = 'Ich habe diesen Termin überarbeitet und möchte, dass ' . $worknewsCount . ' Termin-Abonnent darüber nochmals informiert wird.';
}
}
echo $this->Form->control($i.'.renotify', ['type' => 'checkbox', 'label' => $worknewsString]).'<br />';
echo $this->Form->control($i.'.renotify', ['type' => 'checkbox', 'label' => $worknewsString, 'disabled' => !$eventStartInLessThan7Days]).'<br />';
}

$i++;
Expand Down

0 comments on commit 8eb1927

Please sign in to comment.