From b61df340e859ce6d2727990b18b2fcc5c533854c Mon Sep 17 00:00:00 2001 From: Christian Wolf Date: Thu, 27 Jun 2019 16:33:56 +0200 Subject: [PATCH] Modification of single places is now functional. --- src/admin/common/models/factory/place.php | 1 + src/admin/common/models/place.php | 10 ++++ src/site/controllers/parts.json.php | 36 ++++++++++++ src/site/css/clubs.css | 11 +++- src/site/parts/club/place.php | 71 +++++++++++++++++++++++ src/site/parts/club/places.php | 38 +++++------- src/site/views/club/tmpl/default.php | 25 ++++---- src/site/views/part/view.html.php | 2 + 8 files changed, 153 insertions(+), 41 deletions(-) create mode 100644 src/site/parts/club/place.php diff --git a/src/admin/common/models/factory/place.php b/src/admin/common/models/factory/place.php index a24565d..3abc989 100644 --- a/src/admin/common/models/factory/place.php +++ b/src/admin/common/models/factory/place.php @@ -10,6 +10,7 @@ class CommonClubsModelFactoryPlace extends AbstractCommonClubsModelFactory return array( new CommonClubsModelColumnString('name', new CommonClubsControllerMappingString('Bezeichnung')), new CommonClubsModelColumnRef('club', 'CommonClubsModelClub', 'clubid', new CommonClubsControllerMappingRef('Club', new CommonClubsModelFactoryClub())), + new CommonClubsModelColumnString('address', new CommonClubsControllerMappingString('Adresse')), new CommonClubsModelColumnInt('area', new CommonClubsControllerMappingInt('Fläche', false)) ); } diff --git a/src/admin/common/models/place.php b/src/admin/common/models/place.php index 0b55d8b..1bc905a 100644 --- a/src/admin/common/models/place.php +++ b/src/admin/common/models/place.php @@ -25,6 +25,11 @@ class CommonClubsModelPlace extends AbstractCommonClubsModel return $this->getValues()['area']; } + public function getAddress() + { + return $this->getValues()['address']; + } + public function setName($name) { $this->setValue('name', $name); @@ -40,4 +45,9 @@ class CommonClubsModelPlace extends AbstractCommonClubsModel $this->setValue('club', $club); } + public function setAddress($address) + { + $this->setValue('address', $address); + } + } \ No newline at end of file diff --git a/src/site/controllers/parts.json.php b/src/site/controllers/parts.json.php index 91329f7..fcce37e 100644 --- a/src/site/controllers/parts.json.php +++ b/src/site/controllers/parts.json.php @@ -248,6 +248,7 @@ class ClubsHelperControllerClub extends AbstractClubsHelperController $this->registerFcn('iban', 'editIban'); $this->registerFcn('bic', 'editBic'); $this->registerFcn('offers', 'editOffers'); + $this->registerFcn('place', 'editPlace'); } protected function editName($user, $post) @@ -358,6 +359,41 @@ class ClubsHelperControllerClub extends AbstractClubsHelperController throw new InvalidUserDataException('Es gab ein Problem mit der Eingabe. Bitte Seite neu laden und Daten erneut eintragen.'); } } + + protected function editPlace($user, $post) + { + $factory = new CommonClubsModelFactoryPlace(); + $place = $factory->loadById($this->id); + + $name = trim($post->getString('name')); + $address = $post->getString('address'); + $area = $post->getInt('area'); + + $validator = new ClubsHelperValidator(); + + $this->checkLen($name, 5, "Der Name des Saals muss mindestens aus 5 Zeichen bestehen."); + + $this->checkLen($address, 10, 'Die Adresse muss mindestens 10 Zeichen lang sein.'); + $addr = ''; + if(!$validator->validateAddress($address, $addr)) + { + throw new InvalidUserDataException('Die Adresse muss mindestens aus 2 Zeilen bestehen.'); + } + + if($area < 0) + throw new InvalidUserDataException('Die Fläche darf nicht negativ sein.'); + if($area == 0) + $area = null; + if($area > 2500) + throw new InvalidUserDataException('Die Fläche erscheint zu groß zu sein. Wenden Sie sich bitte ggf an den Support.'); + + // TODO ACL needed + + $place->setName($name); + $place->setAddress($addr); + $place->setArea($area); + $place->save(); + } } class ClubsControllerParts extends BaseController diff --git a/src/site/css/clubs.css b/src/site/css/clubs.css index 8a63510..fe7f417 100644 --- a/src/site/css/clubs.css +++ b/src/site/css/clubs.css @@ -42,7 +42,8 @@ table.clubs > tbody > tr > th } .clubs_content_row .clubs-hidden, -h1 .clubs-hidden +h1 .clubs-hidden, +.clubs-hidden { display: none; } @@ -63,3 +64,11 @@ form.clubs-part { display: inline-block; } + +div.clubs-address +{ + line-height: 135%; + margin: 5px 0px; + display: inline-block; +} + diff --git a/src/site/parts/club/place.php b/src/site/parts/club/place.php new file mode 100644 index 0000000..9c22c5a --- /dev/null +++ b/src/site/parts/club/place.php @@ -0,0 +1,71 @@ +loadById($this->id); + + $content = ob_get_contents(); + ob_clean(); + + try + { +?> +
Name:
+
+
Adresse:
+
+
Fläche:
+
qm
+loadById($this->id); + + $ret = ''; + $ret .= htmlentities($place->getName()); + $ret .= '
'; + + $ret .= '
'; + $ret .= nl2br(htmlentities($place->getAddress())); + $ret .= '
'; + + $area = $place->getArea(); + if($area !== null) + { + $ret .= '
Fläche: '; + $ret .= htmlentities($area); + $ret .= ' qm'; + } + + return $ret; + } +} diff --git a/src/site/parts/club/places.php b/src/site/parts/club/places.php index e902267..a3fca35 100644 --- a/src/site/parts/club/places.php +++ b/src/site/parts/club/places.php @@ -48,35 +48,23 @@ class ClubsPartClubPlaces extends ClubsHelperParts $factory = new CommonClubsModelFactoryClub(); $club = $factory->loadById($this->id); - $offers = $club->getOffers(); - $hasOffers = false; - $first = true; + $places = $club->getPlaces(); + $hasPlaces = count($places) > 0; - foreach($offers as $o) + foreach($places as $p) { - if($o['valid']) - { - $iconCls = 'ok'; - $hasOffers = true; - } - else - { - $iconCls = 'cancel-2'; - } - - if(!$first) - $ret .= '
'; - $first = false; - - $ret .= "  "; - if($o['valid']) - $ret .= ''; - $ret .= htmlentities($o['offer']->getName()); - if($o['valid']) - $ret .= ''; + $ret .= "
"; + $ret .= htmlentities($p->getName()); + $ret .= "
"; + $ret .= 'Adresse'; + $ret .= ""; + if($p->getArea() !== null) + $ret .= '
Fläche: ' . htmlentities($p->getArea()) . 'qm'; + $ret .= "
\n"; } - if(!$hasOffers) + + if(! $hasPlaces) { // Reset to info string $ret = 'Der Verein hat keine Räume eingetragen.'; diff --git a/src/site/views/club/tmpl/default.php b/src/site/views/club/tmpl/default.php index 14ae95f..ea9f879 100644 --- a/src/site/views/club/tmpl/default.php +++ b/src/site/views/club/tmpl/default.php @@ -106,23 +106,18 @@ $clubid = $this->club->getId();
Räumlichkeiten
club->getPlaces()) > 0): ?> -club->getPlaces() as $p): ?> -
- getName()); ?>
- Adresse - getAddress())); ?> - getArea() === null ? '' : '
Fläche: ' . htmlentities($p->getArea()) . 'qm'; ?> -
- +club->getPlaces() as $p) +{ + $partHandler = new ClubsPartClubPlace($p->getId()); + echo "
"; + echo $partHandler->getViewPart(); + echo '
'; +} +?> -Der Verein hat keine Angebote festgelegt. +
'>Der Verein hat keine Angebote festgelegt.
-
- getViewPart(); - ?> -
diff --git a/src/site/views/part/view.html.php b/src/site/views/part/view.html.php index 418129a..62a4e5d 100644 --- a/src/site/views/part/view.html.php +++ b/src/site/views/part/view.html.php @@ -99,6 +99,8 @@ class ClubsViewPart extends HtmlView return new ClubsPartClubBic($id); case 'offers': return new ClubsPartClubOffers($id); + case 'place': + return new ClubsPartClubPlace($id); default: throw new Exception('Internal Error');