Corrected all views to the structure

This commit is contained in:
Christian Wolf 2019-06-03 14:39:09 +02:00
parent eb704af915
commit 65ccfe23f7
10 changed files with 89 additions and 95 deletions

View File

@ -306,7 +306,7 @@ abstract class AbstractCommonClubsModel
return $factory->loadElements($allConstraints, $sorting); return $factory->loadElements($allConstraints, $sorting);
} }
else else
$factory->loadElements($condition, $sorting); return $factory->loadElements($condition, $sorting);
} }
protected function filterPackData($values) protected function filterPackData($values)

View File

@ -63,7 +63,7 @@ class CommonClubsModelClub extends AbstractCommonClubsModel
public function getOffers() public function getOffers()
{ {
$assocs = $this->fetchAssociatedElements(new CommonClubsModelFactoryOfferassocs(), 'clubid'); $assocs = $this->fetchAssociatedElements(new CommonClubsModelFactoryOfferassoc(), 'clubid');
$offersFactory = new CommonClubsModelFactoryOffer(); $offersFactory = new CommonClubsModelFactoryOffer();
$allOffers = $offersFactory->loadElements(); $allOffers = $offersFactory->loadElements();

View File

@ -3,7 +3,7 @@
// No direct access. // No direct access.
defined('_JEXEC') or die; defined('_JEXEC') or die;
class CommonClubsModelFactoryOfferassocs extends AbstractCommonClubsModelFactory class CommonClubsModelFactoryOfferassoc extends AbstractCommonClubsModelFactory
{ {
protected function fetchAttributes() protected function fetchAttributes()
{ {

View File

@ -7,7 +7,7 @@ class CommonClubsModelOfferassoc extends AbstractCommonClubsModel
{ {
protected function getFactory() protected function getFactory()
{ {
return new CommonClubsModelFactoryOfferassocs(); return new CommonClubsModelFactoryOfferassoc();
} }
/** /**

View File

@ -9,6 +9,7 @@ defined('_JEXEC') or die;
<form method="post" action="<?php echo $this->address; ?>"> <form method="post" action="<?php echo $this->address; ?>">
<input type='hidden' name='id' value='<?php echo $this->object->getId(); ?>'> <input type='hidden' name='id' value='<?php echo $this->object->getId(); ?>'>
<h2>Stammdaten</h2>
<table> <table>
<tr> <tr>
<td>Bezeichnung</td> <td>Bezeichnung</td>
@ -66,15 +67,6 @@ defined('_JEXEC') or die;
<?php if(! $this->isNew): ?> <?php if(! $this->isNew): ?>
<tr>
<td>Angebote</td>
<td>
<?php foreach($this->offers as $o): ?>
<input type='checkbox' name='offers' value='<?php echo $o['offer']->getId(); ?>' <?php if($o['mark']) echo 'checked="checked"';?>>
<?php echo htmlentities($o['offer']->getName()); ?><br />
<?php endforeach; ?>
</td>
</tr>
<tr> <tr>
<td>ID</td> <td>ID</td>
<td><?php echo $this->object->getId(); ?></td> <td><?php echo $this->object->getId(); ?></td>
@ -82,6 +74,45 @@ defined('_JEXEC') or die;
<?php endif; ?> <?php endif; ?>
</table> </table>
<?php if(! $this->isNew): ?>
<h2>Angebote</h2>
<?php foreach($this->object->getOffers() as $oconf): ?>
<input type='checkbox' name='offers' value='<?php echo $oconf['offer']->getId(); ?>' <?php if($oconf['valid']) echo 'checked="checked"';?>>
<?php echo htmlentities($oconf['offer']->getName()); ?><br />
<?php endforeach; ?>
<h2>Posten</h2>
<table width='100%' class='table table-stiped, table-hover'>
<tr>
<th width='20%'>Rolle</th>
<th width='25%'>Name</th>
<th width='10%'>Stadt</th>
<th width='5%' style='text-align: center;'>Admin?</th>
<th></th>
<th width='5%'>ID</th>
</tr>
<?php foreach($this->object->getUsers() as $ua): ?>
<tr>
<td><?php echo htmlentities($ua->getPosition()->getName()); ?></td>
<td><?php echo htmlentities($ua->getUser()->getName()); ?></td>
<td><?php echo htmlentities($ua->getUser()->getCity()); ?></td>
<td style='text-align: center;'><?php if($ua->isAdmin()) echo "<span class='icon-checkmark'></span>"; ?></td>
<td>
<a href='#'><span class='icon-edit'></span></a>
<a href='#'><span class='icon-delete'></span></a>
</td>
<td><?php echo $ua->getId(); ?></td>
</tr>
<?php endforeach; ?>
</table>
<p><a href='#'><span class='icon-new'></span> Neuen Posten einf&uuml;gen</a></p>
<?php endif; ?>
<input type='submit' value='Speichern'> <br /><a href='<?php echo Route::_('index.php?option=com_clubs&view=clubs'); ?>'>Zur&uuml;ck zur &Uuml;bersicht</a> <input type='submit' value='Speichern'> <br /><a href='<?php echo Route::_('index.php?option=com_clubs&view=clubs'); ?>'>Zur&uuml;ck zur &Uuml;bersicht</a>
</form> </form>
<div style='width: 100vw; height: 100vh; position: fixed; left: 0pt; top: 0pt; z-index: 1000; border-style: solid; display: none;'><!-- Set body css 'overflow: fixed;' to avoid scolling in the backgound -->
<div style='background-color: gray; width: 100vw; height: 100vh; position: absolute; left: 0pt; top: 0pt; z-index: 1000; opacity: 0.5;'></div>
<div style='background-color: red; width: 70vw; height: 60vh; position: absolute; left: 15vw; top: 20vh; z-index: 1001; border-style: solid; visibility: visible; overflow: visible;'>Ein Test</div>
</div>

View File

@ -11,39 +11,26 @@ class ClubsViewClub extends AbstractClubsViewSingle
{ {
function display($tpl = null) function display($tpl = null)
{ {
ToolbarHelper::title('Club-Management - Verein'); ToolbarHelper::title('Club-Management - Verein', 'cube');
$this->prepareDisplay(); $this->prepareDisplay();
$userFactory = new CommonClubsModelFactoryUser(); $userFactory = new CommonClubsModelFactoryUser();
$this->users = $userFactory->loadElements(); $this->users = $userFactory->loadElements();
if($this->isNew)
{
}
else
{
// $offers = ClubsOffer::loadOffers();
// $currentOffers = $this->object->getOffers();
// $this->offers = array_map(function($offer) use ($currentOffers){
// $mark = False;
// return array('offer'=>$offer, 'mark'=>$mark);
// }, $offers);
}
parent::display($tpl); parent::display($tpl);
} }
protected function getViewName() protected function getControllerName()
{ {
return 'club'; return 'club';
} }
protected function getElementController()
protected function getFactory()
{ {
return new ClubsControllerClub(); return new CommonClubsModelFactoryClub();
} }
} }

View File

@ -11,19 +11,20 @@ class ClubsViewOffer extends AbstractClubsViewSingle
{ {
function display($tpl = null) function display($tpl = null)
{ {
ToolbarHelper::title('Club-Management - Angebot', 'file');
ToolbarHelper::title('Club-Management - Angebot');
parent::display($tpl); parent::display($tpl);
} }
protected function getViewName() protected function getFactory()
{
return new CommonClubsModelFactoryOffer();
}
protected function getControllerName()
{ {
return 'offer'; return 'offer';
} }
protected function getElementController()
{
return new ClubsControllerOffer();
}
} }

View File

@ -9,19 +9,20 @@ JLoader::register("ClubsControllerPosition", JPATH_ROOT . "/administrator/compon
class ClubsViewPosition extends AbstractClubsViewSingle class ClubsViewPosition extends AbstractClubsViewSingle
{ {
protected function getViewName()
function display($tpl = null)
{
ToolbarHelper::title('Club-Management - Position', 'users');
parent::display($tpl);
}
protected function getControllerName()
{ {
return 'position'; return 'position';
} }
protected function getElementController() protected function getFactory()
{ {
return new ClubsControllerPosition(); return new CommonClubsModelFactoryPosition();
} }
function display($tpl = null)
{
ToolbarHelper::title('Club-Management - Position');
parent::display($tpl);
}
} }

View File

@ -8,11 +8,11 @@ defined('_JEXEC') or die;
?> ?>
<form method="post" action="<?php echo $this->address; ?>"> <form method="post" action="<?php echo $this->address; ?>">
<input type='hidden' name='id' value='<?php echo $this->user->getId(); ?>'> <input type='hidden' name='id' value='<?php echo $this->object->getId(); ?>'>
<table> <table>
<tr> <tr>
<td>Username</td> <td>Username</td>
<td><input type='text' name='user' value='<?php echo htmlentities($this->user->getUser()); ?>'></td> <td><input type='text' name='user' value='<?php echo htmlentities($this->object->getUserName()); ?>'></td>
</tr> </tr>
<tr> <tr>
<td>Passwort</td> <td>Passwort</td>
@ -24,33 +24,33 @@ defined('_JEXEC') or die;
</tr> </tr>
<tr> <tr>
<td>Bürgerlicher Name</td> <td>Bürgerlicher Name</td>
<td><input type='text' name='name' value='<?php echo htmlentities($this->user->getName()); ?>'></td> <td><input type='text' name='name' value='<?php echo htmlentities($this->object->getName()); ?>'></td>
</tr> </tr>
<tr> <tr>
<td>Adresse</td> <td>Adresse</td>
<td> <td>
<textarea rows="4" name='address'><?php echo (htmlentities($this->user->getAddress())); ?></textarea> <textarea rows="4" name='address'><?php echo (htmlentities($this->object->getAddress())); ?></textarea>
</tr> </tr>
<tr> <tr>
<td>Stadt</td> <td>Stadt</td>
<td><input type='text' name='city' value='<?php echo htmlentities($this->user->getCity()); ?>'></td> <td><input type='text' name='city' value='<?php echo htmlentities($this->object->getCity()); ?>'></td>
</tr> </tr>
<tr> <tr>
<td>E-Mail</td> <td>E-Mail</td>
<td><input type='text' name='mail' value='<?php echo htmlentities($this->user->getMail()); ?>'></td> <td><input type='text' name='mail' value='<?php echo htmlentities($this->object->getMail()); ?>'></td>
</tr> </tr>
<tr> <tr>
<td>Telefon</td> <td>Telefon</td>
<td><input type='text' name='phone' value='<?php echo htmlentities($this->user->getPhone()); ?>'></td> <td><input type='text' name='phone' value='<?php echo htmlentities($this->object->getPhone()); ?>'></td>
</tr> </tr>
<tr> <tr>
<td>Handy</td> <td>Handy</td>
<td><input type='text' name='mobile' value='<?php echo htmlentities($this->user->getMobile()); ?>'></td> <td><input type='text' name='mobile' value='<?php echo htmlentities($this->object->getMobile()); ?>'></td>
</tr> </tr>
<?php if(! $this->isNew): ?> <?php if(! $this->isNew): ?>
<tr> <tr>
<td>ID</td> <td>ID</td>
<td><?php echo $this->user->getId(); ?></td> <td><?php echo $this->object->getId(); ?></td>
</tr> </tr>
<?php endif; ?> <?php endif; ?>
</table> </table>

View File

@ -1,54 +1,28 @@
<?php <?php
use Joomla\CMS\MVC\View\HtmlView;
use Joomla\CMS\Toolbar\ToolbarHelper; use Joomla\CMS\Toolbar\ToolbarHelper;
use Joomla\CMS\Factory;
use Joomla\CMS\Router\Route;
// No direct access. // No direct access.
defined('_JEXEC') or die; defined('_JEXEC') or die;
class ClubsViewUser extends HtmlView class ClubsViewUser extends AbstractClubsViewSingle
{ {
public function display($tpl = null) public function display($tpl = null)
{ {
$input = Factory::getApplication()->input; ToolbarHelper::title('Club-Management - Person', 'user');
$id = $input->get->get('id');
if($id === 'new')
{
$this->address = Route::_('index.php?option=com_clubs&task=user.new');
$this->user = ClubsUser::createUser();
$this->isNew = true;
}
else if(is_numeric($id))
{
$this->address = Route::_('index.php?option=com_clubs&task=user.change');
$this->user = ClubsUser::loadUser((int) $id);
$this->isNew = false;
}
else
throw new Exception('Need a user id.');
if($input->get->get('data', null, 'json') != null)
{
// Restore previous data
$dataurl = $input->get->get('data', null, 'json');
$data = json_decode($dataurl, true);
$this->user->setUser($data['user'], true);
$this->user->setName($data['name']);
$this->user->setAddress($data['address']);
$this->user->setCity($data['city']);
$this->user->setMail($data['mail']);
$this->user->setPhone($data['phone']);
$this->user->setMobile($data['mobile']);
}
ToolbarHelper::title('Club-Management - Person');
parent::display($tpl); parent::display($tpl);
} }
protected function getControllerName()
{
return 'user';
}
protected function getFactory()
{
return new CommonClubsModelFactoryUser();
}
} }