Inserted data into frontend from models for some views

This commit is contained in:
Christian Wolf 2019-06-17 13:56:37 +02:00
parent 759f04d34f
commit 5179ea9de5
8 changed files with 128 additions and 101 deletions

View File

@ -125,6 +125,11 @@ class CommonClubsModelUser extends AbstractCommonClubsModel
return $this->fetchAssociatedElements(new CommonClubsModelFactoryUserassoc(), 'userid');
}
public function getPresidentClubs()
{
return $this->fetchAssociatedElements(new CommonClubsModelFactoryClub(), 'president');
}
public function isPasswordSuitable($password)
{
if(strlen($password) < 8)

View File

@ -1,46 +1,61 @@
<?php
use Joomla\CMS\Router\Route;
// No direct access.
defined('_JEXEC') or die;
?>
<h1><?php echo $this->clubname; ?></h1>
<h1><?php echo htmlentities($this->club->getName()); ?></h1>
<div class='clubs_row'>
<div class='clubs_title_row'>Adresse</div>
<div class='clubs_content_row'><?php echo nl2br(htmlentities($this->address)); ?></div>
<div class='clubs_content_row'><?php echo nl2br(htmlentities($this->club->getAddress())); ?></div>
</div>
<div class='clubs_row'>
<div class='clubs_title_row'>Internet</div>
<div class='clubs_content_row'><?php echo htmlentities($this->internet); ?></div>
<div class='clubs_title_row'>Stadt</div>
<div class='clubs_content_row'><?php echo htmlentities($this->club->getCity()); ?></div>
</div>
<div class='clubs_row'>
<div class='clubs_title_row'>Kontaktperson</div>
<div class='clubs_content_row'><?php echo htmlentities($this->contactperson); ?></div>
<div class='clubs_title_row'>Homepage</div>
<div class='clubs_content_row'><a href='<?php echo htmlentities($this->club->getHomepage()); ?>' target='_blank'><?php echo htmlentities($this->club->getHomepage()); ?></a></div>
</div>
<div class='clubs_row'>
<div class='clubs_title_row'>Mail-Adresse</div>
<div class='clubs_content_row'><a href='mailto:<?php echo htmlentities($this->email); ?>'><?php echo htmlentities($this->email); ?></a></div>
<div class='clubs_content_row'><a href='mailto:<?php echo htmlentities($this->club->getMail()); ?>'><?php echo htmlentities($this->club->getMail()); ?></a></div>
</div>
<div class='clubs_row'>
<div class='clubs_title_row'>Telefon</div>
<div class='clubs_content_row'><?php echo htmlentities($this->phone); ?></div>
<div class='clubs_title_row'>IBAN / BIC</div>
<div class='clubs_content_row'><?php echo htmlentities($this->club->getIban()); ?> / <?php echo htmlentities($this->club->getBic()); ?></div>
</div>
<div class='clubs_row'>
<div class='clubs_title_row'>Gemeinn&uuml;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&uuml;tzig.</div>
</div>
<!--<div class='clubs_row'>
<div class='clubs_title_row'>Telefon</div>
<div class='clubs_content_row'><?php echo htmlentities('$this->phone'); ?></div>
</div>-->
<div class='clubs_row'>
<div class='clubs_title_row'>Angebote</div>
<div class='clubs_content_row'>
<?php if($this->hasOptions):
<?php if($this->hasOffers):
// Put all options there
foreach($this->options as $k=>$v):
foreach($this->club->getOffers() as $o):
?>
<input type="checkbox" disabled="disabled" <?php if(isset($v)) echo 'checked="checked"'; ?>> <?php echo htmlentities($k); ?><br />
<span class='icon-<?php echo $o['valid'] ? 'ok' : 'cancel-2'; ?>'></span>&nbsp;
<?php if($o['valid']) echo '<b>'; ?>
<?php echo htmlentities($o['offer']->getName()); ?><br />
<?php if($o['valid']) echo '</b>'; ?>
<?php
endforeach;
@ -52,47 +67,54 @@ endif; ?>
</div>
</div>
<?php if(count($this->trainingPlaces) > 0): ?>
<?php if(count($this->club->getPlaces()) > 0): ?>
<div class='clubs_row'>
<div class='clubs_title_row'>R&auml;umlichkeiten</div>
<?php foreach($this->trainingPlaces as $p): ?>
<div class='clubs_content_row'>
<?php echo htmlentities($p['name']); ?><br />
<?php echo htmlentities($p['street']); ?><br />
<?php echo htmlentities($p['plz'] . " " . $p['city']); ?>
</div>
<?php foreach($this->club->getPlaces() as $p): ?>
<div class='clubs_content_row'>
<b><?php echo htmlentities($p->getName()); ?></b><br />
<i>Adresse</i>
<?php //echo nl2br(htmlentities($p->getAddress())); ?>
<?php echo $p->getArea() === null ? '' : '<br />Fl&auml;che: ' . htmlentities($p->getArea()) . 'qm'; ?>
</div>
<?php endforeach; ?>
<div class='clubs_content_row'><a href='<?php echo ""; ?>'><span class='icon-new'></span>&nbsp; Neue Assoziation anlegen</a></div>
</div>
<?php endif; ?>
<?php if(count($this->persons) > 0) : ?>
<div class='clubs_row'>
<div class='clubs_title_row'>Pr&auml;sident</div>
<div class='clubs_content_row'>
<a href='<?php echo Route::_("index.php?view=user&userid={$this->club->getPresident()->getId()}"); ?>'>
<?php echo htmlentities("{$this->club->getPresident()->getName()} ({$this->club->getPresident()->getCity()})"); ?>
</a>
</div>
</div>
<?php if(count($this->club->getUsers()) > 0) : ?>
<div class='clubs_row'>
<div class='clubs_title_row'>Assoziierte Personen</div>
<div class='clubs_content_row'>
<ul>
<?php foreach($this->persons as $p): ?>
<li>
<a href='?option=com_clubs&view=user&id=<?php echo $p['id']; ?>'><?php echo htmlentities($p['name']); ?></a>:
<?php echo htmlentities($p['position']); ?>
<?php if ($p['modify']) echo ' (Club-Admin)'; ?>
<?php if($this->canModify): ?>
<a href='?option=com_clubs&view=clubassoc&assoc=<?php echo $p['assoc']; ?>'>&Auml;ndern</a>
<a href='?option=com_clubs&task=club.delassoc&assoc=<?php echo $p['assoc']; ?>'>L&ouml;schen</a>
<?php endif; ?>
</li>
<?php endforeach; ?>
<?php foreach($this->club->getUsers() as $uassoc): ?>
<li>
<a href='?option=com_clubs&view=user&id=<?php echo $uassoc->getUser()->getId(); ?>'>
<?php echo htmlentities($uassoc->getUser()->getName()); ?>
</a>:
<?php echo htmlentities($uassoc->getPosition()->getName()); ?>
<?php if ($uassoc->isAdmin()) echo ' (Club-Admin)'; ?>
<!--<?php //if($this->canModify): ?>
<a href='?option=com_clubs&view=clubassoc&assoc=<?php //echo $p['assoc']; ?>'>&Auml;ndern</a>
<a href='?option=com_clubs&task=club.delassoc&assoc=<?php //echo $p['assoc']; ?>'>L&ouml;schen</a>-->
<?php //endif; ?>
</li>
<?php endforeach; ?>
</ul>
<?php if($this->canModify): ?>
<a href='<?php echo $this->urlNewPerson; ?>'>Neue Assoziation anlegen</a>
<?php endif; ?>
<?php //if($this->canModify): ?>
<a href='<?php echo ""; ?>'><span class='icon-new'></span>&nbsp; Neue Assoziation anlegen</a>
<?php //endif; ?>
</div>
</div>
<?php endif; ?>
<?php if($this->canModify): ?>
<div class='clubs_row'>
<a href="?option=com_clubs&view=clubdata&clubid=<?php echo $this->clubid; ?>">Stammdaten anpassen</a><br />
<a href="?option=com_clubs&view=clubplaces&clubid=<?php echo $this->clubid; ?>">R&auml;umlichkeiten anpassen</a><br />
</div>
<?php endif; ?>

View File

@ -1,8 +1,7 @@
<?php
use Joomla\CMS\MVC\View\HtmlView;
use Joomla\CMS\Factory;
use Joomla\CMS\Uri\Uri;
use Joomla\CMS\MVC\View\HtmlView;
// No direct access.
defined('_JEXEC') or die;
@ -12,47 +11,19 @@ class ClubsViewClub extends HtmlView
public function display($tpl = null)
{
// FIXME Insert code from DB
$this->clubid = 43;
$this->clubname = "Testclub";
$this->address = "Strasse 1\n66123 Ort";
$this->contactperson = "Max Mustermann";
$this->email = "me@club.de";
$this->phone = "012345";
$this->internet = "http://wichtig.de";
$input = Factory::getApplication()->input;
$id = $input->getInt('clubid', -1);
$this->options = array("Step" => NULL, "JMD" => 1, "Divers." => NULL);
$this->hasOptions = false;
foreach($this->options as $o)
if(isset($o))
$clubFactory = new CommonClubsModelFactoryClub();
$this->club = $clubFactory->loadById($id);
$this->hasOffers = false;
foreach($this->club->getOffers() as $o)
if($o['valid'])
{
$this->hasOptions = true;
$this->hasOffers = true;
break;
}
$this->trainingPlaces = array();
// $this->trainingPlaces[] = array('name'=>'Schule', 'street'=>'Straße', 'city'=>'SB', 'plz'=>'12345');
// $this->trainingPlaces[] = array('name'=>'Schule', 'street'=>'Straße', 'city'=>'SB', 'plz'=>'12345');
$this->persons = array();
$this->persons[] = array('name'=>'Max', 'position'=>'Präsident', 'id'=>3, 'assoc'=>6, 'modify'=>true);
$this->persons[] = array('name'=>'Max', 'position'=>'Präsident', 'id'=>3, 'assoc'=>7, 'modify'=>false);
$this->canModify = true;
// ?option=com_clubs&view=searchperson&data=<?php echo urlencode('{"clubid":' . $this->clubid . "}");
$dataValue = array();
$dataValue['clubid'] = $this->clubid;
$dataAbort = array(
'urlAbort' => (Uri::getInstance()->toString()),
'urlSelect' => '?option=com_clubs&view=clubassoc&person=%u',
'data' => json_encode($dataValue)
);
$this->urlNewPerson = htmlentities("?option=com_clubs&view=searchperson&" . http_build_query($dataAbort));
Factory::getDocument()->addStyleSheet(Uri::base(true) . "components/com_clubs/css/clubs.css");
parent::display($tpl);
}
}

View File

@ -8,3 +8,22 @@ defined('_JEXEC') or die;
<pre>
Ort Verein Adresse Ansprechpartner Email
</pre>
<table width='100%'>
<tr>
<th>Ort</th>
<th>Verein</th>
<th>Adresse</th>
<th>Vorsitzener</th>
<th>E-Mail-Adresse</th>
</tr>
<?php foreach ($this->clubs as $club): ?>
<tr>
<td><?php echo htmlentities($club->getCity()); ?></td>
<td><?php echo htmlentities($club->getName()); ?></td>
<td><?php echo nl2br(htmlentities($club->getAddress())); ?></td>
<td><?php echo htmlentities($club->getPresident()->getName()); ?></td>
<td><a href='mailto:<?php echo htmlentities($club->getMail()); ?>'><?php echo htmlentities($club->getMail()); ?></a></td>
</tr>
<?php endforeach; ?>
</table>

View File

@ -0,0 +1,6 @@
<?xml version="1.0" encoding="utf-8"?>
<metadata>
<layout title="Liste der Vereine">
<message>Liste aller aktiven Vereine des Verbands</message>
</layout>
</metadata>

View File

@ -7,4 +7,12 @@ defined('_JEXEC') or die;
class ClubsViewClubs extends HtmlView
{
public function display($tpl = null)
{
$clubFactory = new CommonClubsModelFactoryClub();
$this->clubs = $clubFactory->loadElements();
parent::display($tpl);
}
}

View File

@ -1,5 +1,7 @@
<?php
use Joomla\CMS\Router\Route;
// No direct access.
defined('_JEXEC') or die;
@ -49,10 +51,16 @@ defined('_JEXEC') or die;
<ul>
<?php
/*foreach ($this->me->getPositions() as $userassoc) {
?>
<li><a href='?option=com_clubs&view=club&clubid=<?php echo $c['id']; ?>'><?php echo htmlentities($c['name']); ?></a></li>
<?php
}*/
foreach ($this->clubsPresident as $pc):
$link = Route::_("index.php?view=club&clubid={$pc->getId()}");
?>
<li><a href='<?php echo $link; ?>'>Vorsitzender im Verein "<?php echo htmlentities($pc->getName()); ?>"</a></li>
<?php endforeach; ?>
<?php foreach ($this->positions as $pos):
$link = Route::_("index.php?view=club&clubid={$pos->getClub()->getId()}");
?>
<li><a href='<?php echo $link; ?>'><?php echo htmlentities($pos->getPosition()->getName()); ?> im Verein "<?php echo htmlentities($pos->getClub()->getName()); ?>"</a></li>
<?php endforeach; ?>
</ul>

View File

@ -10,25 +10,13 @@ class ClubsViewMyPage extends HtmlView
public function display($tpl = null)
{
// FIXME
$this->clubs = array();
$c = array();
$c['name'] = "Ein Test-Club";
$c['city'] = "Saarbrücken";
$c['id'] = 2;
$this->clubs[] = $c;
$c = array();
$c['name'] = "Ein zweiter Test-Club";
$c['city'] = "Saarlouis";
$c['id'] = 4;
$this->clubs[] = $c;
$userFactory = new CommonClubsModelFactoryUser();
$users = $userFactory->loadElements();
$this->me = $users[0];
$this->clubsPresident = $this->me->getPresidentClubs();
$this->positions = $this->me->getPositions();
parent::display($tpl);
}
}