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 + { +?> +