Updated user view in order to show referenced clubs

This commit is contained in:
Christian Wolf 2019-06-05 16:58:23 +02:00
parent 60abc189ec
commit 40b88859cd
9 changed files with 92 additions and 25 deletions

View File

@ -16,6 +16,7 @@ abstract class AbstractClubsViewSingle extends HtmlView
*/
protected $object;
protected $isNew;
protected $id;
private $prepared = FALSE;
@ -50,6 +51,8 @@ abstract class AbstractClubsViewSingle extends HtmlView
$this->object->unpack($jsonData);
}
$this->id = $id;
}
public function display($tpl = null)

View File

@ -14,9 +14,9 @@ class CommonClubsModelColumnRef extends AbstractCommonClubsModelColumn
protected $className;
public function __construct($alias, $className, $column=null)
public function __construct($alias, $className, $column, $filter)
{
parent::__construct($alias, $column);
parent::__construct($alias, $filter, $column);
if(empty($className))
throw new Exception('Classname must be non-empty.');

View File

@ -8,15 +8,15 @@ class CommonClubsModelFactoryClub extends AbstractCommonClubsModelFactory
public function fetchAttributes()
{
return array(
new CommonClubsModelColumnString('name'),
new CommonClubsModelColumnString('address'),
new CommonClubsModelColumnString('city'),
new CommonClubsModelColumnString('homepage'),
new CommonClubsModelColumnString('mail'),
new CommonClubsModelColumnString('iban'),
new CommonClubsModelColumnString('bic'),
new CommonClubsModelColumnInt('charitable'),
new CommonClubsModelColumnRef('president', 'CommonClubsModelUser')
new CommonClubsModelColumnString('name', new CommonClubsControllerMappingString('Clubname')),
new CommonClubsModelColumnString('address', new CommonClubsControllerMappingString('Adresse')),
new CommonClubsModelColumnString('city', new CommonClubsControllerMappingString('Stadt')),
new CommonClubsModelColumnString('homepage', new CommonClubsControllerMappingString('Homepaage', false)),
new CommonClubsModelColumnString('mail', new CommonClubsControllerMappingString('E-Mail')),
new CommonClubsModelColumnString('iban', new CommonClubsControllerMappingCmd('IBAN')),
new CommonClubsModelColumnString('bic', new CommonClubsControllerMappingCmd('BIC')),
new CommonClubsModelColumnInt('charitable', new CommonClubsControllerMappingInt('Gemeinnützigkeit')),
new CommonClubsModelColumnRef('president', 'CommonClubsModelUser', 'president', new CommonClubsControllerMappingRef('Vorsitzender', new CommonClubsModelFactoryUser()))
);
}

View File

@ -8,8 +8,8 @@ class CommonClubsModelFactoryOfferassoc extends AbstractCommonClubsModelFactory
protected function fetchAttributes()
{
return array(
new CommonClubsModelColumnRef('club', 'CommonClubsModelClub', true, 'clubid'),
new CommonClubsModelColumnRef('offer', 'CommonClubsModelOffer', true, 'offerid')
new CommonClubsModelColumnRef('club', 'CommonClubsModelClub', 'clubid', new CommonClubsControllerMappingRef('Club', new CommonClubsModelFactoryClub())),
new CommonClubsModelColumnRef('offer', 'CommonClubsModelOffer', 'offerid', new CommonClubsControllerMappingRef('Angebot', new CommonClubsModelFactoryOffer()))
);
}

View File

@ -8,9 +8,9 @@ class CommonClubsModelFactoryPlace extends AbstractCommonClubsModelFactory
public function fetchAttributes()
{
return array(
new CommonClubsModelColumnString('name'),
new CommonClubsModelColumnRef('club', 'CommonClubsModelClub', true, 'clubid'),
new CommonClubsModelColumnInt('area', false)
new CommonClubsModelColumnString('name', new CommonClubsControllerMappingString('Bezeichnung')),
new CommonClubsModelColumnRef('club', 'CommonClubsModelClub', 'clubid', new CommonClubsControllerMappingRef('Club', new CommonClubsModelFactoryClub())),
new CommonClubsModelColumnInt('area', new CommonClubsControllerMappingInt('Fläche', false))
);
}

View File

@ -8,14 +8,14 @@ class CommonClubsModelFactoryUserassoc extends AbstractCommonClubsModelFactory
protected function fetchAttributes()
{
return array(
new CommonClubsModelColumnRef('user', 'CommonClubsModelUser', true, 'userid'),
new CommonClubsModelColumnRef('club', 'CommonClubsModelClub', true, 'clubid'),
new CommonClubsModelColumnRef('position', 'CommonClubsModelPosition', true, 'positionid'),
new CommonClubsModelColumnInt('admin'),
new CommonClubsModelColumnString('address', false),
new CommonClubsModelColumnString('mail', false),
new CommonClubsModelColumnString('phone', false),
new CommonClubsModelColumnString('state')
new CommonClubsModelColumnRef('user', 'CommonClubsModelUser', 'userid', new CommonClubsControllerMappingRef('User', new CommonClubsModelFactoryUser())),
new CommonClubsModelColumnRef('club', 'CommonClubsModelClub', 'clubid', new CommonClubsControllerMappingRef('Club', new CommonClubsModelFactoryClub())),
new CommonClubsModelColumnRef('position', 'CommonClubsModelPosition', 'positionid', new CommonClubsControllerMappingRef('Position', new CommonClubsModelFactoryPosition())),
new CommonClubsModelColumnInt('admin', new CommonClubsControllerMappingInt('Admin')),
new CommonClubsModelColumnString('address', new CommonClubsControllerMappingString('Adresse', false)),
new CommonClubsModelColumnString('mail', new CommonClubsControllerMappingString('E-Mail', false)),
new CommonClubsModelColumnString('phone', new CommonClubsControllerMappingString('Telefonnummer', false)),
new CommonClubsModelColumnString('state', new CommonClubsControllerMappingString('Status'))
// -> `state` enum('regular', 'vacant', 'temporary') NOT NULL DEFAULT 'vacant',
);
}

View File

@ -8,6 +8,7 @@ defined('_JEXEC') or die;
?>
<form method="post" action="<?php echo $this->address; ?>">
<h2>Stammdaten</h2>
<input type='hidden' name='id' value='<?php echo $this->object->getId(); ?>'>
<table>
<tr>
@ -55,5 +56,26 @@ defined('_JEXEC') or die;
<?php endif; ?>
</table>
<?php if(! $this->isNew): ?>
<h2>Verkn&uuml;pfungen</h2>
<?php if(sizeof($this->jobs) == 0): ?>
<p>Es wurden keine Verkn&uuml;pfungen zu der Person gefunden.</p>
<?php else: ?>
<table class='table table-stiped, table-hover'>
<tr>
<th>Posten</th>
<th>Verein</th>
<th>Stadt</th>
</tr>
<?php foreach($this->jobs as $job): ?>
<tr>
<td><?php echo htmlentities($job['position']); ?></td>
<td><a href='<?php echo $job['url']; ?>' target='_blank'><?php echo htmlentities($job['club']); ?></a></td>
<td><?php echo htmlentities($job['city']); ?></td>
</tr>
<?php endforeach; ?>
</table>
<?php endif; ?>
<?php endif; ?>
<input type='submit' value='Speichern'> <br /><a href='<?php echo Route::_('index.php?option=com_clubs&view=users'); ?>'>Zur&uuml;ck zur &Uuml;bersicht</a>
</form>

View File

@ -1,6 +1,7 @@
<?php
use Joomla\CMS\Toolbar\ToolbarHelper;
use Joomla\CMS\Router\Route;
// No direct access.
defined('_JEXEC') or die;
@ -10,6 +11,48 @@ class ClubsViewUser extends AbstractClubsViewSingle
public function display($tpl = null)
{
$this->prepareDisplay();
if($this->isNew)
{
$this->jobs = array();
}
else
{
$factory = new CommonClubsModelFactoryUser();
$user = $factory->loadById($this->id);
$positions = $user->getPositions();
$clubFactory = new CommonClubsModelFactoryClub();
$clubsPresident = $clubFactory->loadElements("main.president = {$this->id}");
$jobs = array();
foreach($clubsPresident as $club)
{
$job = array(
'club' => $club->getName(),
'city' => $club->getCity(),
'position' => 'Vorsitzender',
'url' => Route::_("index.php?option=com_clubs&view=club&id={$club->getId()}")
);
$jobs[] = $job;
}
foreach($positions as $p)
{
$c = $p->getClub();
$job = array(
'club' => $c->getName(),
'city' => $c->getCity(),
'position' => $p->getPosition()->getName(),
'url' => Route::_("index.php?option=com_clubs&view=club&id={$c->getId()}")
);
$jobs[] = $job;
}
$this->jobs = $jobs;
}
ToolbarHelper::title('Club-Management - Person', 'user');
parent::display($tpl);
}

View File

@ -1,6 +1,5 @@
<?php
use Joomla\CMS\Router\Route;
// No direct access.
defined('_JEXEC') or die;