Allowed changing of club's offers
This commit is contained in:
parent
3f96022176
commit
45d3e09c7e
@ -247,9 +247,10 @@ class ClubsHelperControllerClub extends AbstractClubsHelperController
|
|||||||
$this->registerFcn('mail', 'editMail');
|
$this->registerFcn('mail', 'editMail');
|
||||||
$this->registerFcn('iban', 'editIban');
|
$this->registerFcn('iban', 'editIban');
|
||||||
$this->registerFcn('bic', 'editBic');
|
$this->registerFcn('bic', 'editBic');
|
||||||
|
$this->registerFcn('offers', 'editOffers');
|
||||||
}
|
}
|
||||||
|
|
||||||
public function editName($user, $post)
|
protected function editName($user, $post)
|
||||||
{
|
{
|
||||||
$name = trim($post->getString('value'));
|
$name = trim($post->getString('value'));
|
||||||
$this->checkLen($name, 6, 'Der Name des Vereins muss mindestens 6 Zeichen lang sein.');
|
$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();
|
$this->club->save();
|
||||||
}
|
}
|
||||||
|
|
||||||
public function editAddress($user, $post)
|
protected function editAddress($user, $post)
|
||||||
{
|
{
|
||||||
$address = trim($post->getString('value'));
|
$address = trim($post->getString('value'));
|
||||||
$this->checkLen($address, 10, 'Die Adresse muss mindestens 10 Zeichen lang sein.');
|
$this->checkLen($address, 10, 'Die Adresse muss mindestens 10 Zeichen lang sein.');
|
||||||
@ -278,7 +279,7 @@ class ClubsHelperControllerClub extends AbstractClubsHelperController
|
|||||||
$this->club->save();
|
$this->club->save();
|
||||||
}
|
}
|
||||||
|
|
||||||
public function editCity($user, $post)
|
protected function editCity($user, $post)
|
||||||
{
|
{
|
||||||
$city = trim($post->getString('value'));
|
$city = trim($post->getString('value'));
|
||||||
$this->checkLen($city, 4, 'Die Stadt muss aus mindestens 4 Zeichen bestehen.');
|
$this->checkLen($city, 4, 'Die Stadt muss aus mindestens 4 Zeichen bestehen.');
|
||||||
@ -289,7 +290,7 @@ class ClubsHelperControllerClub extends AbstractClubsHelperController
|
|||||||
$this->club->save();
|
$this->club->save();
|
||||||
}
|
}
|
||||||
|
|
||||||
public function editHomepage($user, $post)
|
protected function editHomepage($user, $post)
|
||||||
{
|
{
|
||||||
$homepage = trim($post->getString('value'));
|
$homepage = trim($post->getString('value'));
|
||||||
$validator = new ClubsHelperValidator();
|
$validator = new ClubsHelperValidator();
|
||||||
@ -302,7 +303,7 @@ class ClubsHelperControllerClub extends AbstractClubsHelperController
|
|||||||
$this->club->save();
|
$this->club->save();
|
||||||
}
|
}
|
||||||
|
|
||||||
public function editMail($user, $post)
|
protected function editMail($user, $post)
|
||||||
{
|
{
|
||||||
$mail = trim($post->getString('value'));
|
$mail = trim($post->getString('value'));
|
||||||
$this->checkLen($mail, 8, "Die Mail-Adresse muss aus mindestens 8 Zeichen bestehen.");
|
$this->checkLen($mail, 8, "Die Mail-Adresse muss aus mindestens 8 Zeichen bestehen.");
|
||||||
@ -315,7 +316,7 @@ class ClubsHelperControllerClub extends AbstractClubsHelperController
|
|||||||
$this->club->save();
|
$this->club->save();
|
||||||
}
|
}
|
||||||
|
|
||||||
public function editIban($user, $post)
|
protected function editIban($user, $post)
|
||||||
{
|
{
|
||||||
$iban = trim($post->getString('value'));
|
$iban = trim($post->getString('value'));
|
||||||
$this->checkLen($iban, 10, 'Die IBAN muss aus mindestens 10 Zeichen bestehen.');
|
$this->checkLen($iban, 10, 'Die IBAN muss aus mindestens 10 Zeichen bestehen.');
|
||||||
@ -331,7 +332,7 @@ class ClubsHelperControllerClub extends AbstractClubsHelperController
|
|||||||
$this->club->save();
|
$this->club->save();
|
||||||
}
|
}
|
||||||
|
|
||||||
public function editBic($user, $post)
|
protected function editBic($user, $post)
|
||||||
{
|
{
|
||||||
$bic = trim($post->getString('value'));
|
$bic = trim($post->getString('value'));
|
||||||
$this->checkLen($bic, 6, 'Die BIC muss aus mindestens 6 Zeichen bestehen.');
|
$this->checkLen($bic, 6, 'Die BIC muss aus mindestens 6 Zeichen bestehen.');
|
||||||
@ -342,7 +343,15 @@ class ClubsHelperControllerClub extends AbstractClubsHelperController
|
|||||||
$this->club->save();
|
$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
|
class ClubsControllerParts extends BaseController
|
||||||
|
87
src/site/parts/club/offers.php
Normal file
87
src/site/parts/club/offers.php
Normal file
@ -0,0 +1,87 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
// No direct access.
|
||||||
|
defined('_JEXEC') or die;
|
||||||
|
|
||||||
|
class ClubsPartClubOffers extends ClubsHelperParts
|
||||||
|
{
|
||||||
|
protected function getPartName()
|
||||||
|
{
|
||||||
|
return 'club.offers';
|
||||||
|
}
|
||||||
|
|
||||||
|
protected function getEditContent()
|
||||||
|
{
|
||||||
|
throw new Exception();
|
||||||
|
}
|
||||||
|
|
||||||
|
protected function getEditMarkup()
|
||||||
|
{
|
||||||
|
$ret = '';
|
||||||
|
|
||||||
|
$factory = new CommonClubsModelFactoryClub();
|
||||||
|
$club = $factory->loadById($this->id);
|
||||||
|
|
||||||
|
$offers = $club->getOffers();
|
||||||
|
$first = true;
|
||||||
|
|
||||||
|
foreach($offers as $o)
|
||||||
|
{
|
||||||
|
if(!$first)
|
||||||
|
$ret .= '<br />';
|
||||||
|
|
||||||
|
$checked = $o['valid'] ? ' checked' : '';
|
||||||
|
$ret .= "<input type='checkbox' name='offers[]' value='{$o['offer']->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 .= '<br />';
|
||||||
|
$first = false;
|
||||||
|
|
||||||
|
$ret .= "<span class='icon-$iconCls'></span> ";
|
||||||
|
if($o['valid'])
|
||||||
|
$ret .= '<b>';
|
||||||
|
$ret .= htmlentities($o['offer']->getName());
|
||||||
|
if($o['valid'])
|
||||||
|
$ret .= '</b>';
|
||||||
|
}
|
||||||
|
|
||||||
|
if(!$hasOffers)
|
||||||
|
{
|
||||||
|
// Reset to info string
|
||||||
|
$ret = '<i>Der Verein hat keine Angebote festgelegt.</i>';
|
||||||
|
}
|
||||||
|
|
||||||
|
return $ret;
|
||||||
|
}
|
||||||
|
}
|
@ -79,10 +79,14 @@ $clubid = $this->club->getId();
|
|||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
<!--
|
||||||
<div class='clubs_row'>
|
<div class='clubs_row'>
|
||||||
<div class='clubs_title_row'>Gemeinnützigkeit</div>
|
<div class='clubs_title_row'>Gemeinnützigkeit</div>
|
||||||
<div class='clubs_content_row'><span class='icon-<?php echo $this->club->isCharitable() ? 'ok' : 'cancel'; ?>'></span> Der Verein ist <?php echo $this->club->isCharitable() ? '' : '<b>nicht</b>'; ?> gemeinnützig.</div>
|
<div class='clubs_content_row'>
|
||||||
|
<span class='icon-<?php echo $this->club->isCharitable() ? 'ok' : 'cancel'; ?>'></span> Der Verein ist <?php echo $this->club->isCharitable() ? '' : '<b>nicht</b>'; ?> gemeinnützig.
|
||||||
</div>
|
</div>
|
||||||
|
</div>
|
||||||
|
-->
|
||||||
|
|
||||||
<!--<div class='clubs_row'>
|
<!--<div class='clubs_row'>
|
||||||
<div class='clubs_title_row'>Telefon</div>
|
<div class='clubs_title_row'>Telefon</div>
|
||||||
@ -92,29 +96,16 @@ $clubid = $this->club->getId();
|
|||||||
<div class='clubs_row'>
|
<div class='clubs_row'>
|
||||||
<div class='clubs_title_row'>Angebote</div>
|
<div class='clubs_title_row'>Angebote</div>
|
||||||
<div class='clubs_content_row'>
|
<div class='clubs_content_row'>
|
||||||
<?php if($this->hasOffers):
|
<?php
|
||||||
|
$partHandler = new ClubsPartClubOffers($clubid);
|
||||||
// Put all options there
|
echo $partHandler->getViewPart();
|
||||||
foreach($this->club->getOffers() as $o):
|
?>
|
||||||
?>
|
|
||||||
<span class='icon-<?php echo $o['valid'] ? 'ok' : 'cancel-2'; ?>'></span>
|
|
||||||
<?php if($o['valid']) echo '<b>'; ?>
|
|
||||||
<?php echo htmlentities($o['offer']->getName()); ?><br />
|
|
||||||
<?php if($o['valid']) echo '</b>'; ?>
|
|
||||||
<?php
|
|
||||||
endforeach;
|
|
||||||
|
|
||||||
else:
|
|
||||||
|
|
||||||
// No options specified in the database
|
|
||||||
?>Der Verein hat keine Angebote festgelegt.<?php
|
|
||||||
endif; ?>
|
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<?php if(count($this->club->getPlaces()) > 0): ?>
|
|
||||||
<div class='clubs_row'>
|
<div class='clubs_row'>
|
||||||
<div class='clubs_title_row'>Räumlichkeiten</div>
|
<div class='clubs_title_row'>Räumlichkeiten</div>
|
||||||
|
<?php if(count($this->club->getPlaces()) > 0): ?>
|
||||||
<?php foreach($this->club->getPlaces() as $p): ?>
|
<?php foreach($this->club->getPlaces() as $p): ?>
|
||||||
<div class='clubs_content_row'>
|
<div class='clubs_content_row'>
|
||||||
<b><?php echo htmlentities($p->getName()); ?></b><br />
|
<b><?php echo htmlentities($p->getName()); ?></b><br />
|
||||||
@ -123,9 +114,11 @@ endif; ?>
|
|||||||
<?php echo $p->getArea() === null ? '' : '<br />Fläche: ' . htmlentities($p->getArea()) . 'qm'; ?>
|
<?php echo $p->getArea() === null ? '' : '<br />Fläche: ' . htmlentities($p->getArea()) . 'qm'; ?>
|
||||||
</div>
|
</div>
|
||||||
<?php endforeach; ?>
|
<?php endforeach; ?>
|
||||||
|
<?php else: ?>
|
||||||
|
Der Verein hat keine Angebote festgelegt.
|
||||||
|
<?php endif; ?>
|
||||||
<div class='clubs_content_row'><a href='<?php echo ""; ?>'><span class='icon-new'></span> Neue Assoziation anlegen</a></div>
|
<div class='clubs_content_row'><a href='<?php echo ""; ?>'><span class='icon-new'></span> Neue Assoziation anlegen</a></div>
|
||||||
</div>
|
</div>
|
||||||
<?php endif; ?>
|
|
||||||
|
|
||||||
<div class='clubs_row'>
|
<div class='clubs_row'>
|
||||||
<div class='clubs_title_row'>Präsident</div>
|
<div class='clubs_title_row'>Präsident</div>
|
||||||
|
@ -97,6 +97,8 @@ class ClubsViewPart extends HtmlView
|
|||||||
return new ClubsPartClubIban($id);
|
return new ClubsPartClubIban($id);
|
||||||
case 'bic':
|
case 'bic':
|
||||||
return new ClubsPartClubBic($id);
|
return new ClubsPartClubBic($id);
|
||||||
|
case 'offers':
|
||||||
|
return new ClubsPartClubOffers($id);
|
||||||
|
|
||||||
default:
|
default:
|
||||||
throw new Exception('Internal Error');
|
throw new Exception('Internal Error');
|
||||||
|
Loading…
Reference in New Issue
Block a user