Started to work on places 1:n relation

The current class structure might be incapable to solve this efficiently
This commit is contained in:
Christian Wolf 2019-06-26 19:30:34 +02:00
parent 45d3e09c7e
commit af506435ac
2 changed files with 93 additions and 0 deletions

View File

@ -0,0 +1,87 @@
<?php
// No direct access.
defined('_JEXEC') or die;
class ClubsPartClubPlaces extends ClubsHelperParts
{
protected function getPartName()
{
return 'club.places';
}
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>&nbsp; ";
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 R&auml;ume eingetragen.</i>';
}
return $ret;
}
}

View File

@ -117,6 +117,12 @@ $clubid = $this->club->getId();
<?php else: ?> <?php else: ?>
Der Verein hat keine Angebote festgelegt. Der Verein hat keine Angebote festgelegt.
<?php endif; ?> <?php endif; ?>
<div class='clubs_content_row'>
<?php
$partHandler = new ClubsPartClubPlaces($clubid);
echo $partHandler->getViewPart();
?>
</div>
<div class='clubs_content_row'><a href='<?php echo ""; ?>'><span class='icon-new'></span>&nbsp; Neue Assoziation anlegen</a></div> <div class='clubs_content_row'><a href='<?php echo ""; ?>'><span class='icon-new'></span>&nbsp; Neue Assoziation anlegen</a></div>
</div> </div>