From 45d3e09c7e34a6755e579eb5e1b0282dc66c153e Mon Sep 17 00:00:00 2001 From: Christian Wolf Date: Wed, 26 Jun 2019 19:21:17 +0200 Subject: [PATCH] Allowed changing of club's offers --- src/site/controllers/parts.json.php | 25 +++++--- src/site/parts/club/offers.php | 87 ++++++++++++++++++++++++++++ src/site/views/club/tmpl/default.php | 33 +++++------ src/site/views/part/view.html.php | 2 + 4 files changed, 119 insertions(+), 28 deletions(-) create mode 100644 src/site/parts/club/offers.php diff --git a/src/site/controllers/parts.json.php b/src/site/controllers/parts.json.php index 9d2d861..1ef6993 100644 --- a/src/site/controllers/parts.json.php +++ b/src/site/controllers/parts.json.php @@ -247,9 +247,10 @@ class ClubsHelperControllerClub extends AbstractClubsHelperController $this->registerFcn('mail', 'editMail'); $this->registerFcn('iban', 'editIban'); $this->registerFcn('bic', 'editBic'); + $this->registerFcn('offers', 'editOffers'); } - public function editName($user, $post) + protected function editName($user, $post) { $name = trim($post->getString('value')); $this->checkLen($name, 6, 'Der Name des Vereins muss mindestens 6 Zeichen lang sein.'); @@ -260,7 +261,7 @@ class ClubsHelperControllerClub extends AbstractClubsHelperController $this->club->save(); } - public function editAddress($user, $post) + protected function editAddress($user, $post) { $address = trim($post->getString('value')); $this->checkLen($address, 10, 'Die Adresse muss mindestens 10 Zeichen lang sein.'); @@ -278,7 +279,7 @@ class ClubsHelperControllerClub extends AbstractClubsHelperController $this->club->save(); } - public function editCity($user, $post) + protected function editCity($user, $post) { $city = trim($post->getString('value')); $this->checkLen($city, 4, 'Die Stadt muss aus mindestens 4 Zeichen bestehen.'); @@ -289,7 +290,7 @@ class ClubsHelperControllerClub extends AbstractClubsHelperController $this->club->save(); } - public function editHomepage($user, $post) + protected function editHomepage($user, $post) { $homepage = trim($post->getString('value')); $validator = new ClubsHelperValidator(); @@ -302,7 +303,7 @@ class ClubsHelperControllerClub extends AbstractClubsHelperController $this->club->save(); } - public function editMail($user, $post) + protected function editMail($user, $post) { $mail = trim($post->getString('value')); $this->checkLen($mail, 8, "Die Mail-Adresse muss aus mindestens 8 Zeichen bestehen."); @@ -315,7 +316,7 @@ class ClubsHelperControllerClub extends AbstractClubsHelperController $this->club->save(); } - public function editIban($user, $post) + protected function editIban($user, $post) { $iban = trim($post->getString('value')); $this->checkLen($iban, 10, 'Die IBAN muss aus mindestens 10 Zeichen bestehen.'); @@ -331,7 +332,7 @@ class ClubsHelperControllerClub extends AbstractClubsHelperController $this->club->save(); } - public function editBic($user, $post) + protected function editBic($user, $post) { $bic = trim($post->getString('value')); $this->checkLen($bic, 6, 'Die BIC muss aus mindestens 6 Zeichen bestehen.'); @@ -342,7 +343,15 @@ class ClubsHelperControllerClub extends AbstractClubsHelperController $this->club->save(); } - + protected function editOffers($user, $post) + { + $ids = $post->getInt('offers'); + + // TODO ACL needed + + $this->club->setOfferIds($ids); + $this->club->save(); + } } class ClubsControllerParts extends BaseController diff --git a/src/site/parts/club/offers.php b/src/site/parts/club/offers.php new file mode 100644 index 0000000..44015dc --- /dev/null +++ b/src/site/parts/club/offers.php @@ -0,0 +1,87 @@ +loadById($this->id); + + $offers = $club->getOffers(); + $first = true; + + foreach($offers as $o) + { + if(!$first) + $ret .= '
'; + + $checked = $o['valid'] ? ' checked' : ''; + $ret .= "getId()}'$checked>"; + $ret .= htmlentities($o['offer']->getName()); + + $first = false; + } + + return $ret; + + } + + protected function getViewContent() + { + $ret = ''; + + $factory = new CommonClubsModelFactoryClub(); + $club = $factory->loadById($this->id); + + $offers = $club->getOffers(); + $hasOffers = false; + $first = true; + + foreach($offers as $o) + { + 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 .= ''; + } + + if(!$hasOffers) + { + // Reset to info string + $ret = 'Der Verein hat keine Angebote festgelegt.'; + } + + return $ret; + } +} diff --git a/src/site/views/club/tmpl/default.php b/src/site/views/club/tmpl/default.php index d61d130..d5dd63b 100644 --- a/src/site/views/club/tmpl/default.php +++ b/src/site/views/club/tmpl/default.php @@ -79,10 +79,14 @@ $clubid = $this->club->getId(); +