3 class TourController extends ControllerBase implements ControllerInterface
5 public function allowUnauthenticated()
10 public function getNavigation()
12 if (empty($_SESSION['userid']))
16 $list[] = ['title' => 'Home',
17 'url' => Application::url()];
18 $list[] = ['title' => 'Status',
19 'url' => Application::url('tour', 'index', $this->tour)];
20 if ($this->tour && $this->tour->isAdmin() && $this->tour->isPlanned())
21 $list[] = ['title' => 'Neu einladen',
22 'url' => Application::url('tour', 'invite', $this->tour)];
23 if ($this->tour && $this->tour->isAdmin() && $this->tour->isPlanned())
24 $list[] = ['title' => 'Termine',
25 'url' => Application::url('tour', 'dates', $this->tour)];
26 if ($this->tour && $this->tour->isPlanned())
27 $list[] = ['title' => 'Planung',
28 'url' => Application::url('tour', 'plan', $this->tour)];
29 if ($this->tour && $this->tour->isAdmin())
30 $list[] = ['title' => 'Matrix',
31 'url' => Application::url('tour', 'matrix', $this->tour)];
32 $list[] = ['title' => 'Notizen',
33 'url' => Application::url('tour', 'notes', $this->tour)];
34 $list[] = ['title' => 'Zwischenziele',
35 'url' => Application::url('tour', 'pov', $this->tour)];
36 if ($this->tour && $this->tour->isAdmin()) {
37 $list[] = ['title' => 'Administration',
38 'url' => Application::url('tour', 'admin', $this->tour)];
39 $list[] = ['title' => 'Logbuch',
40 'url' => Application::url('tour', 'log', $this->tour)];
46 public function indexAction($request, $response)
48 if (empty($this->tour))
49 return $response->setLocation($this->app->getBaseURL());
51 $data = $this->tour->getBaseData();
52 $data->information_html = Wiki::renderHTML($data->information);
54 Application::get()->addJavascriptCode("load_dates();");
56 $vars = array_merge(get_object_vars($data),
57 ['admin' => $this->tour->isAdmin(),
58 'notes' => $this->tour->getNotes(),
59 'members' => $this->tour->getMembers()]);
61 $response->setData(Template::render('tour/index', $vars));
64 public function adminAction($request, $response)
66 if (empty($this->tour))
67 return $response->setLocation($this->app->getBaseURL());
69 if (!$this->tour->isAdmin())
70 throw new Exception("Keine Berechtigung");
72 $form = new Form('tourplan');
73 $form->add(new FormElement('text', ['name' => 'name',
75 'help' => 'z.B. Sauerland 2019',
76 'value' => $this->tour->get('name')]));
77 $form->add(new FormElement('text', ['name' => 'urlkey',
79 'help' => 'Keine Leer- oder Sonderzeichen, z.B. sl2019',
80 'value' => $this->tour->get('key')]));
81 $form->add(new FormElement('number', ['name' => 'year',
85 'value' => $this->tour->get('year')]));
86 $form->add(new FormElement('number', ['name' => 'duration',
87 'title' => 'Dauer in Tagen',
89 'value' => $this->tour->get('duration')]));
91 $sql = "SELECT id AS value, name AS text FROM tour_status ORDER BY priority";
92 $form->add(new FormElement('select', ['name' => 'tour_status_id',
93 'title' => 'Tour-Status',
94 'selected' => $this->tour->get('tour_status_id'),
95 'options' => $this->db->fetchObjectList($sql)]));
97 foreach ($this->tour->getDates() as $row)
98 $options[] = new Storage(['value' => $row->id, 'text' => $row->start_datum]);
100 $form->add(new FormElement('select', ['name' => 'tour_date_id',
102 'empty' => '-- bitte wählen --',
103 'selected' => $this->tour->get('tour_date_id'),
104 'options' => $options]));
106 $form->add(new FormElement('textarea', ['name' => 'information',
107 'title' => 'Tourinformationen',
108 'help' => 'MoinMoin-typische Syntax erlaubt',
110 'value' => $this->tour->get('information')]));
113 foreach ($this->tour->getMembers(false) as $row)
114 $options[] = new Storage(['value' => $row->id, 'text' => $row->name]);
116 if (count($options)) {
117 $adminform = new Form('touradmin');
118 $adminform->add(new FormElement('select', ['name' => 'tour_member_id',
119 'title' => 'Weiterer Tourleiter',
120 'empty' => '-- Bitte wählen --',
121 'options' => $options]));
122 $adminformstr = $adminform->toString();
127 $adminlist = $this->tour->getMembers(true);
129 $response->setData(Template::render('tour/admin', ['form' => $form->toString(),
130 'adminform' => $adminformstr,
131 'adminlist' => $adminlist]));
134 public function ajaxAdmin($request, $response, $data)
136 if (empty($this->tour))
137 return $response->setLocation($this->app->getBaseURL());
139 if (!$this->tour->isAdmin())
140 throw new Exception("Keine Berechtigung");
142 foreach (['name', 'urlkey', 'year', 'duration'] as $name)
143 if (!strlen($data[$name]))
144 throw new Exception('Nicht alle Pflichtfelder ausgefüllt');
146 if (!preg_match('/^[a-zA-Z0-9_\.-]+$/', $data['urlkey']))
147 throw new Exception('Sonderzeichen nicht im URL-Key erlaubt');
149 $status_plan = new Tour_Status('plan', 'key');
151 $ok = $this->db->update('tour', ['key' => $data['urlkey'],
152 'name' => $data['name'],
153 'year' => intval($data['year']),
154 'duration' => intval($data['duration']),
155 'tour_status_id' => $data['tour_status_id'],
156 'tour_date_id' => strlen($data['tour_date_id']) ? intval($data['tour_date_id']) : NULL,
157 'information' => strlen($data['information']) ? $data['information'] : NULL,
158 ], 'id='.$this->tour->id());
161 throw new Exception('Tour-Daten konnten nicht aktualisiert werden');
164 public function ajaxTouradmin($request, $response, $data)
166 if (empty($this->tour))
167 return $response->setLocation($this->app->getBaseURL());
169 if (!$this->tour->isAdmin())
170 throw new Exception("Keine Berechtigung");
172 $this->db->update('tour_member', ['admin' => true], 'id='.$data['tour_member_id']);
174 $sql = sprintf("SELECT name FROM sys_user JOIN tour_member ON member_id = sys_user.id WHERE tour_member.id = %d",
175 $data['tour_member_id']);
176 Tour_Log::add($this->tour->id(), sprintf("%s als Leiter hinzugefügt", $this->db->fetchValue($sql)));
179 public function ajaxDeladmin($request, $response, $data)
181 if (empty($this->tour))
182 return $response->setLocation($this->app->getBaseURL());
184 if (!$this->tour->isAdmin())
185 throw new Exception("Keine Berechtigung");
187 $this->db->update('tour_member', ['admin' => false], 'id='.$data['id']);
189 $sql = sprintf("SELECT name FROM sys_user JOIN tour_member ON member_id = sys_user.id WHERE tour_member.id = %d",
191 Tour_Log::add($this->tour->id(), sprintf("%s als Leiter gelöscht", $this->db->fetchValue($sql)));
194 protected function formatDates()
196 if (empty($this->tour))
197 throw new Exception('Keine Tour ausgewählt');
199 $ok = new Tour_Date_Status('ok', 'key');
200 $maybe = new Tour_Date_Status('maybe', 'key');
201 $not = new Tour_Date_Status('nope', 'key');
205 (SELECT count(*) FROM tour_date_member WHERE tour_date_id = tour_date.id AND tour_date_status_id = {$ok->id()}) AS sum_ok,
206 (SELECT count(*) FROM tour_date_member WHERE tour_date_id = tour_date.id AND tour_date_status_id = {$maybe->id()}) AS sum_maybe,
207 (SELECT count(*) FROM tour_date_member WHERE tour_date_id = tour_date.id AND tour_date_status_id = {$not->id()}) AS sum_not,
210 WHERE tour_id = {$this->tour->id()}
214 $list = $this->db->fetchObjectList($sql);
216 foreach ($list as &$row) {
217 $dt = new DateTime($row->start_date);
218 $row->year = $dt->format('Y');
219 $row->start_short = $dt->format('d.m.');
220 $dt->add(new DateInterval('P'.$this->tour->get('duration').'D'));
221 $row->end_short = $dt->format('d.m.');
223 if ($row->sum_ok >= 4)
225 elseif ($row->sum_ok >= 3 && $row->sum_not == 0)
231 return Template::render('tour/datelist', ['tour_date_id' => $this->tour->get('tour_date_id'),
235 public function ajaxDates($request, $response, $data)
237 if (empty($this->tour))
238 throw new Exception('Keine Tour ausgewählt');
240 $response->setData(['table' => $this->formatDates()]);
243 public function datesAction($request, $response)
245 if (empty($this->tour))
246 return $response->setLocation($this->app->getBaseURL());
248 $plan = new Tour_Status('plan', 'key');
251 if ($this->tour->isAdmin() && $this->tour->get('tour_status_id') == $plan->id()) {
252 $form = new Form('newdate');
253 $form->setTitle('Neuer Termin');
254 $form->add(new FormElement('date', ['name' => 'start_date',
255 'placeholder' => '2019-01-12',
257 $formstr = '<hr>'.$form->toString();
260 Application::get()->addJavascriptCode("load_dates();");
262 $response->setData(Template::render('tour/dates', ['admin' => $this->tour->isAdmin(),
263 'form' => $formstr]));
266 public function planAction($request, $response)
268 if (empty($this->tour))
269 return $response->setLocation($this->app->getBaseURL());
271 $plan = new Tour_Status('plan', 'key');
272 if ($this->tour->get('tour_status_id') != $plan->id())
273 return $response->setLocation(Application::url('tour', 'index', $this->tour));
275 $list = $this->tour->getAvailability($_SESSION['userid']);
277 $sql = sprintf("SELECT comment FROM tour_member WHERE tour_id = %d AND member_id = %d",
278 $this->tour->id(), $_SESSION['userid']);
279 $comment = $this->db->fetchValue($sql);
281 $form = new Form('tourmember');
282 $form->setTitle('Allgemeiner Status');
283 $form->add(new FormElement('text', ['name' => 'comment',
284 'help' => 'z.B. kein fahrbereites Motorrad',
285 'value' => $comment]));
286 $formstr = '<hr>'.$form->toString();
288 $response->setData(Template::render('tour/plan', ['list' => $list,
289 'form' => $formstr]));
292 public function ajaxTourmember($request, $response, $data)
294 if (empty($this->tour))
295 throw new Exception("Keine Tour angegeben");
297 $ok = $this->db->update('tour_member', ['comment' => strlen($data['comment']) ? $data['comment'] : NULL],
298 sprintf('tour_id = %d AND member_id = %d', $this->tour->id(), $_SESSION['userid']));
300 if (strlen($data['comment']))
301 Tour_Log::add($this->tour->id(), sprintf("Neuer Status %s", $data['comment']));
303 Tour_Log::add($this->tour->id(), "Status gelöscht");
306 public function inviteAction($request, $response)
308 if (empty($this->tour))
309 throw new Exception("Keine Tour angegeben");
311 $user = new Sys_User();
312 $userlist = $user->getUserList($this->tour->id());
314 $response->setData(Template::render('tour/invite', ['list' => $userlist]));
317 public function ajaxTogglestatus($request, $response, $data)
319 if (empty($this->tour))
320 throw new Exception("Keine Tour angegeben");
322 if (empty($data['user']))
323 $uid = $_SESSION['userid'];
324 elseif ($this->tour->isAdmin())
325 $uid = $data['user'];
327 $uid = $_SESSION['userid'];
329 $this->tour->toggleDateStatus($data['id'], $uid);
333 tour_date_status.key AS status_key,
334 tour_date_status.name AS status_text
335 FROM tour_date_member
336 LEFT JOIN tour_date_status ON tour_date_status_id = tour_date_status.id
337 LEFT JOIN tour_member ON tour_member_id = tour_member.id
338 WHERE tour_date_id = %d AND tour_member.member_id = %d
340 $sql = sprintf($sql, $data['id'], $uid);
342 $response->setData($this->db->fetchAssoc($sql));
345 public function ajaxInvite($request, $response, $data)
347 if (empty($this->tour))
348 throw new Exception("Keine Tour angegeben");
350 if (!$this->tour->isAdmin())
351 throw new Exception("Keine Berechtigung");
353 $this->tour->inviteMember($data['sys_user_id']);
355 $user = new Sys_User($data['sys_user_id']);
356 Tour_Log::add($this->tour->id(), sprintf("%s eingeladen", $user->get('name')));
359 public function ajaxNewdate($request, $response, $data)
361 if (empty($this->tour))
362 throw new Exception("Keine Tour angegeben");
364 if (!$this->tour->isAdmin())
365 throw new Exception("Keine Berechtigung");
369 if (preg_match('/^(\d+)-(\d+)-(\d+)$/', $data['start_date'], $match))
370 $start_date = $data['start_date'];
371 elseif (preg_match('/^(\d+).(\d+).(\d+)$/', $data['start_date'], $match))
372 $start_date = sprintf('%d-%d-%d', $match[3], $match[2], $match[1]);
374 throw new Exception('Kein Datum angegeben');
376 $ok = $this->db->insertInto('tour_date', ['tour_id' => $this->tour->id(),
377 'start_date' => $start_date]);
380 $response->setError('Fehler beim Speichern');
383 protected function formatPovList()
385 if (empty($this->tour))
386 throw new Exception("Keine Tour angegeben");
393 WHERE tour_id = {$this->tour->id()}
394 ORDER BY seqnum, destination
397 $list = $this->db->fetchObjectList($sql);
399 foreach ($list as &$row) {
400 $dt = new DateTime($row->start_date);
401 $row->year = $dt->format('Y');
402 $row->start_short = $dt->format('d.m.');
403 $dt->add(new DateInterval('P'.$this->tour->get('duration').'D'));
404 $row->end_short = $dt->format('d.m.');
407 return Template::render('tour/povlist', ['is_planned' => $this->tour->isPlanned(),
411 public function ajaxPov($request, $response, $data)
413 if (empty($this->tour))
414 throw new Exception('Keine Tour ausgewählt');
416 $response->setData(['table' => $this->formatPovList()]);
419 public function povAction($request, $response)
421 if (empty($this->tour))
422 return $response->setLocation($this->app->getBaseURL());
424 $plan = new Tour_Status('plan', 'key');
425 if ($this->tour->get('tour_status_id') == $plan->id()) {
426 $form = new Form('newpov');
427 $form->setTitle('Neues Zwischenziel');
428 $form->add(new FormElement('text', ['name' => 'destination',
430 $formstr = '<hr>'.$form->toString();
433 Application::get()->addJavascriptCode("load_pov();");
435 $response->setData(Template::render('tour/pov', ['form' => $formstr]));
438 public function ajaxNewpov($request, $response, $data)
440 if (empty($this->tour))
441 throw new Exception('Keine Tour ausgewählt');
443 $plan = new Tour_Status('plan', 'key');
444 if ($this->tour->get('tour_status_id') != $plan->id())
445 throw new Exception("Nicht mehr in der Planungsphase");
447 $sql = sprintf("SELECT max(seqnum) FROM tour_pov WHERE tour_id = %d",
449 $max = intval($this->db->fetchValue($sql));
451 $ok = $this->db->insertInto('tour_pov', ['tour_id' => $this->tour->id(),
452 'seqnum' => $max + 1,
453 'destination' => $data['destination']]);
456 $response->setError('Fehler beim Speichern');
458 Tour_Log::add($this->tour->id(), sprintf("Zwischenziel %s hinzugefügt", $data['destination']));
461 public function ajaxPovmove($request, $response, $data)
463 if (empty($this->tour))
464 throw new Exception('Keine Tour ausgewählt');
466 $sql = sprintf("SELECT seqnum FROM tour_pov WHERE tour_id = %d AND id = %d",
467 $this->tour->id(), $data['pov']);
468 $seqnum = $this->db->fetchvalue($sql);
470 if ($seqnum === false)
471 return $response->setError('Zwischenziel nicht gefunden');
473 if ($data['direction'] == 'up') {
474 $sql = sprintf("SELECT id,seqnum FROM tour_pov WHERE tour_id = %d AND seqnum < %d ORDER BY seqnum DESC LIMIT 1",
475 $this->tour->id(), $seqnum);
476 } elseif ($data['direction'] == 'down') {
477 $sql = sprintf("SELECT id,seqnum FROM tour_pov WHERE tour_id = %d AND seqnum > %d ORDER BY seqnum ASC LIMIT 1",
478 $this->tour->id(), $seqnum);
480 return $response->setError("Unknown direction");
482 $other = $this->db->fetchObject($sql);
484 $this->db->execute(sprintf("UPDATE tour_pov SET seqnum = %d WHERE id = %d", $seqnum, $other->id));
485 $this->db->execute(sprintf("UPDATE tour_pov SET seqnum = %d WHERE id = %d", $other->seqnum, $data['pov']));
490 public function ajaxPovdel($request, $response, $data)
492 if (empty($this->tour))
493 throw new Exception('Keine Tour ausgewählt');
495 $sql = sprintf("SELECT destination FROM tour_pov WHERE tour_id = %d AND id = %d",
496 $this->tour->id(), $data['pov']);
497 $destination = $this->db->fetchvalue($sql);
499 if ($destination === false)
500 return $response->setError('Zwischenziel nicht gefunden');
502 $ok = $this->db->execute(sprintf("DELETE FROM tour_pov WHERE id = %d", $data['pov']));
505 throw new Exception("Zwischenziel konne nicht gelöscht werden");
507 Tour_Log::add($this->tour->id(), sprintf("Zwischenziel %s gelöscht", $destination));
510 public function matrixAction($request, $response)
512 if (empty($this->tour))
513 return $response->setLocation($this->app->getBaseURL());
515 $info = $this->tour->getAvailabilityMatrix();
517 $response->setData(Template::render('tour/matrix', ['is_planned' => $this->tour->isPlanned(),
518 'user' => $info['user'],
519 'list' => $info['list']]));
522 public function newmemberAction($request, $response)
524 if (!$this->app->isAdmin() && empty($this->tour))
525 return $response->setLocation($this->app->getBaseURL());
527 $form = new Form('newbiker');
528 $form->setTitle('Neuer Biker');
529 $form->add(new FormElement('text', ['name' => 'name',
532 $form->add(new FormElement('text', ['name' => 'email',
535 $form->add(new FormElement('text', ['name' => 'mobile',
536 'title' => 'Mobiltelefon',
537 'help' => 'Nur sichtbar für Tour-Mitglieder',
538 'placeholder' => '0150-1234567',
541 $formstr = '<hr>'.$form->toString();
543 if (!empty($this->tour))
544 Application::get()->addJavascriptCode("load_dates();");
546 $response->setData($formstr);
549 public function ajaxNewbiker($request, $response, $data)
551 if (!strlen($data['name']))
552 throw new Exception("Name muß ausgfüllt werden");
554 if (!strlen($data['email']))
555 throw new Exception("E-Mail muß ausgfüllt werden");
557 $ok = $this->db->insertInto('sys_user', ['name' => $data['name'],
558 'email' => strtolower($data['email']),
561 'mobile' => strlen($data['mobile']) ? $data['mobile'] : NULL]);
563 if ($ok && !empty($this->tour)) {
564 $id = $this->db->lastInsertId();
566 $ok = $this->db->insertInto('tour_member', ['tour_id' => $this->tour->id(),
567 'member_id' => $id]);
569 throw new Exception('Teilnehmer konnte nicht gesetzt werden');
571 $user = new Sys_User($id);
572 Tour_Log::add($this->tour->id(), sprintf("%s hinzugefügt", $user->get('name')));
578 public function newAction($request, $response)
580 if (!$this->app->isAdmin())
581 throw new Exception("Nur Administratoren können Touren anlegen");
583 $user = new Sys_User();
584 $userlist = $user->getUserList();
587 foreach ($userlist as $row)
588 $options[] = new Storage(['value' => $row->id, 'text' => $row->name]);
590 $form = new Form('newtour');
591 $form->setTitle('Neue Tour anlegen');
592 $form->add(new FormElement('text', ['name' => 'name',
594 'help' => 'z.B. Sauerland 2019',
596 $form->add(new FormElement('text', ['name' => 'urlkey',
597 'title' => 'URL-Key',
598 'help' => 'Keine Leer- oder Sonderzeichen, z.B. sl2019',
600 $form->add(new FormElement('number', ['name' => 'year',
605 $form->add(new FormElement('number', ['name' => 'duration',
609 $form->add(new FormElement('select', ['name' => 'leader',
610 'title' => 'Tourleiter',
611 'empty' => '-- Bitte wählen --',
612 'options' => $options]));
614 $response->setData(Template::render('page/formpage', ['form' => $form->toString()]));
617 public function ajaxNewtour($request, $response, $data)
619 if (!$this->app->isAdmin())
620 throw new Exception("Nur Administratoren können Touren anlegen");
622 foreach (['name', 'urlkey', 'year', 'duration', 'leader'] as $name)
623 if (!strlen($data[$name]))
624 throw new Exception('Alle Felder müssen ausgefüllt sein');
626 if (!preg_match('/^[a-zA-Z0-9_\.-]+$/', $data['urlkey']))
627 throw new Exception('Sonderzeichen nicht im URL-Key erlaubt');
629 $status_plan = new Tour_Status('plan', 'key');
631 $ok = $this->db->insertInto('tour', ['key' => $data['urlkey'],
632 'name' => $data['name'],
633 'year' => intval($data['year']),
634 'duration' => intval($data['duration']),
635 'tour_status_id' => $status_plan->id(),
639 throw new Exception('Neue Tour konnte nicht gespeichert werden');
641 $tour_id = $this->db->lastInsertId();
643 Tour_Log::add($tour_id, sprintf("Tour %s angelegt", $data['name']));
645 $ok = $this->db->insertInto('tour_member', ['tour_id' => $tour_id,
647 'member_id' => $data['leader']]);
649 throw new Exception('Tourleiter konnte nicht gesetzt werden');
651 $user = new Sys_User($data['leader']);
652 Tour_Log::add($tour_id, sprintf("%s als Leiter hinzugefügt", $user->get('name')));
655 public function notesAction($request, $response)
657 if (empty($this->tour))
658 throw new Exception("Keine Tour angegeben");
660 $list = $this->tour->getNotes(true);
662 $response->setData(Template::render('tour/notes', ['list' => $list]));
665 public function ajaxNotedel($request, $response, $data)
667 if (empty($this->tour))
668 throw new Exception('Keine Tour ausgewählt');
670 $sql = sprintf("SELECT id FROM tour_note WHERE id = %d AND tour_id = %d AND sys_user_id = %d",
671 $data['id'], $this->tour->id(), $_SESSION['userid']);
673 if (!$this->db->fetchValue($sql))
674 return $response->setError('Notiz nicht gefunden');
676 $this->db->update('tour_note', ['deleted' => true], 'id='.intval($data['id']));
679 public function logAction($request, $response)
681 if (empty($this->tour))
682 throw new Exception("Keine Tour angegeben");
684 if (!$this->tour->isAdmin())
685 throw new Exception("Keine Berechtigung");
690 extract(day from logdate) || '.' || extract(month from logdate) || '.' || extract(year from logdate) AS date,
695 JOIN sys_user ON tour_log.sys_user_id = sys_user.id
696 WHERE tour_id = {$this->tour->id()}
697 ORDER BY logdate DESC, tour_log.sys_edit DESC
699 $list = $this->db->fetchObjectList($sql);
701 $response->setData(Template::render('tour/log', ['list' => $list]));
704 public function notenewAction($request, $response)
706 if (empty($this->tour))
707 throw new Exception("Keine Tour angegeben");
709 $form = new Form('newnote');
710 $form->setTitle('Neue Notiz');
711 $form->setAction(Application::url('tour', 'preview', $this->tour));
712 $form->setSecondButton('Preview');
713 $form->setDescription(Template::render('wikisyntax', []));
714 $form->add(new FormElement('textarea', ['name' => 'note',
716 'help' => 'MoinMoin-typische Syntax erlaubt',
720 $response->setData(Template::render('page/formpage', ['form' => $form->toString()]));
723 public function previewAction($request, $response)
725 if (!$request->isPost())
726 throw new Exception("Only POST requests allowed here");
728 if (empty($this->tour))
729 throw new Exception("Keine Tour angegeben");
731 $data = $request->getPost();
733 $form = new Form('newnote');
734 $form->setTitle('Neue Notiz');
735 $form->setAction(Application::url('tour', 'preview', $this->tour));
736 $form->setSecondButton('Preview');
737 $form->setDescription(Template::render('wikisyntax', []));
738 $form->add(new FormElement('textarea', ['name' => 'note',
740 'help' => 'MoinMoin-typische Syntax erlaubt',
742 'value' => $data['note']]));
744 $preview = Template::render('tour/notepreview', ['text' => Wiki::renderHTML($data['note'])]);
745 $response->setData(Template::render('page/formpage', ['form' => $form->toString()
749 public function ajaxNotenew($request, $response, $data)
751 if (empty($this->tour))
752 throw new Exception('Keine Tour ausgewählt');
754 if (!strlen($data['note']))
755 throw new Exception('Kein Text angegeben');
757 $data = ['tour_id' => $this->tour->id(),
758 'note' => trim($data['note'])];
760 $this->db->insertInto('tour_note', $data);