Modification of single places is now functional.

This commit is contained in:
Christian Wolf 2019-06-27 16:33:56 +02:00
parent 2da8da6b37
commit b61df340e8
8 changed files with 153 additions and 41 deletions

View File

@ -10,6 +10,7 @@ class CommonClubsModelFactoryPlace extends AbstractCommonClubsModelFactory
return array( return array(
new CommonClubsModelColumnString('name', new CommonClubsControllerMappingString('Bezeichnung')), new CommonClubsModelColumnString('name', new CommonClubsControllerMappingString('Bezeichnung')),
new CommonClubsModelColumnRef('club', 'CommonClubsModelClub', 'clubid', new CommonClubsControllerMappingRef('Club', new CommonClubsModelFactoryClub())), new CommonClubsModelColumnRef('club', 'CommonClubsModelClub', 'clubid', new CommonClubsControllerMappingRef('Club', new CommonClubsModelFactoryClub())),
new CommonClubsModelColumnString('address', new CommonClubsControllerMappingString('Adresse')),
new CommonClubsModelColumnInt('area', new CommonClubsControllerMappingInt('Fläche', false)) new CommonClubsModelColumnInt('area', new CommonClubsControllerMappingInt('Fläche', false))
); );
} }

View File

@ -25,6 +25,11 @@ class CommonClubsModelPlace extends AbstractCommonClubsModel
return $this->getValues()['area']; return $this->getValues()['area'];
} }
public function getAddress()
{
return $this->getValues()['address'];
}
public function setName($name) public function setName($name)
{ {
$this->setValue('name', $name); $this->setValue('name', $name);
@ -40,4 +45,9 @@ class CommonClubsModelPlace extends AbstractCommonClubsModel
$this->setValue('club', $club); $this->setValue('club', $club);
} }
public function setAddress($address)
{
$this->setValue('address', $address);
}
} }

View File

@ -248,6 +248,7 @@ class ClubsHelperControllerClub extends AbstractClubsHelperController
$this->registerFcn('iban', 'editIban'); $this->registerFcn('iban', 'editIban');
$this->registerFcn('bic', 'editBic'); $this->registerFcn('bic', 'editBic');
$this->registerFcn('offers', 'editOffers'); $this->registerFcn('offers', 'editOffers');
$this->registerFcn('place', 'editPlace');
} }
protected function editName($user, $post) protected function editName($user, $post)
@ -358,6 +359,41 @@ class ClubsHelperControllerClub extends AbstractClubsHelperController
throw new InvalidUserDataException('Es gab ein Problem mit der Eingabe. Bitte Seite neu laden und Daten erneut eintragen.'); throw new InvalidUserDataException('Es gab ein Problem mit der Eingabe. Bitte Seite neu laden und Daten erneut eintragen.');
} }
} }
protected function editPlace($user, $post)
{
$factory = new CommonClubsModelFactoryPlace();
$place = $factory->loadById($this->id);
$name = trim($post->getString('name'));
$address = $post->getString('address');
$area = $post->getInt('area');
$validator = new ClubsHelperValidator();
$this->checkLen($name, 5, "Der Name des Saals muss mindestens aus 5 Zeichen bestehen.");
$this->checkLen($address, 10, 'Die Adresse muss mindestens 10 Zeichen lang sein.');
$addr = '';
if(!$validator->validateAddress($address, $addr))
{
throw new InvalidUserDataException('Die Adresse muss mindestens aus 2 Zeilen bestehen.');
}
if($area < 0)
throw new InvalidUserDataException('Die Fläche darf nicht negativ sein.');
if($area == 0)
$area = null;
if($area > 2500)
throw new InvalidUserDataException('Die Fläche erscheint zu groß zu sein. Wenden Sie sich bitte ggf an den Support.');
// TODO ACL needed
$place->setName($name);
$place->setAddress($addr);
$place->setArea($area);
$place->save();
}
} }
class ClubsControllerParts extends BaseController class ClubsControllerParts extends BaseController

View File

@ -42,7 +42,8 @@ table.clubs > tbody > tr > th
} }
.clubs_content_row .clubs-hidden, .clubs_content_row .clubs-hidden,
h1 .clubs-hidden h1 .clubs-hidden,
.clubs-hidden
{ {
display: none; display: none;
} }
@ -63,3 +64,11 @@ form.clubs-part
{ {
display: inline-block; display: inline-block;
} }
div.clubs-address
{
line-height: 135%;
margin: 5px 0px;
display: inline-block;
}

View File

@ -0,0 +1,71 @@
<?php
// No direct access.
defined('_JEXEC') or die;
class ClubsPartClubPlace extends ClubsHelperParts
{
protected function getPartName()
{
return 'club.place';
}
protected function getEditContent()
{
throw new Exception();
}
protected function getEditMarkup()
{
$factory = new CommonClubsModelFactoryPlace();
$place = $factory->loadById($this->id);
$content = ob_get_contents();
ob_clean();
try
{
?>
<div>Name:</div>
<div><input type="text" name='name' value='<?php echo htmlentities($place->getName()); ?>'></div>
<div>Adresse:</div>
<div><textarea rows="4" name='address'><?php echo htmlentities($place->getAddress()); ?></textarea></div>
<div>Fl&auml;che:</div>
<div><input type='text' name='area' value='<?php echo $place->getArea(); ?>'> qm</div>
<?php
}
finally
{
$ret = ob_get_contents();
ob_clean();
echo $content;
}
return $ret;
}
protected function getViewContent()
{
$factory = new CommonClubsModelFactoryPlace();
$place = $factory->loadById($this->id);
$ret = '<b>';
$ret .= htmlentities($place->getName());
$ret .= '</b><br />';
$ret .= '<div class="clubs-address"><i>';
$ret .= nl2br(htmlentities($place->getAddress()));
$ret .= '</i></div>';
$area = $place->getArea();
if($area !== null)
{
$ret .= '<br />Fl&auml;che: ';
$ret .= htmlentities($area);
$ret .= ' qm';
}
return $ret;
}
}

View File

@ -48,35 +48,23 @@ class ClubsPartClubPlaces extends ClubsHelperParts
$factory = new CommonClubsModelFactoryClub(); $factory = new CommonClubsModelFactoryClub();
$club = $factory->loadById($this->id); $club = $factory->loadById($this->id);
$offers = $club->getOffers(); $places = $club->getPlaces();
$hasOffers = false; $hasPlaces = count($places) > 0;
$first = true;
foreach($offers as $o) foreach($places as $p)
{ {
if($o['valid']) $ret .= "<div class='clubs_content_row'><b>";
{ $ret .= htmlentities($p->getName());
$iconCls = 'ok'; $ret .= "</b><br /><i>";
$hasOffers = true; $ret .= 'Adresse';
} $ret .= "</i>";
else if($p->getArea() !== null)
{ $ret .= '<br />Fl&auml;che: ' . htmlentities($p->getArea()) . 'qm';
$iconCls = 'cancel-2'; $ret .= "</div>\n";
}
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)
if(! $hasPlaces)
{ {
// Reset to info string // Reset to info string
$ret = '<i>Der Verein hat keine R&auml;ume eingetragen.</i>'; $ret = '<i>Der Verein hat keine R&auml;ume eingetragen.</i>';

View File

@ -106,23 +106,18 @@ $clubid = $this->club->getId();
<div class='clubs_row'> <div class='clubs_row'>
<div class='clubs_title_row'>R&auml;umlichkeiten</div> <div class='clubs_title_row'>R&auml;umlichkeiten</div>
<?php if(count($this->club->getPlaces()) > 0): ?> <?php if(count($this->club->getPlaces()) > 0): ?>
<?php foreach($this->club->getPlaces() as $p): ?> <?php
<div class='clubs_content_row'> foreach($this->club->getPlaces() as $p)
<b><?php echo htmlentities($p->getName()); ?></b><br /> {
<i>Adresse</i> $partHandler = new ClubsPartClubPlace($p->getId());
<?php //echo nl2br(htmlentities($p->getAddress())); ?> echo "<div class='clubs_content_row'>";
<?php echo $p->getArea() === null ? '' : '<br />Fl&auml;che: ' . htmlentities($p->getArea()) . 'qm'; ?> echo $partHandler->getViewPart();
</div> echo '</div>';
<?php endforeach; ?> }
?>
<?php else: ?> <?php else: ?>
Der Verein hat keine Angebote festgelegt. <div class='message-empty <?php echo count($this->club->getPlaces()) == 0 ? '' : 'clubs-hidden'; ?>'>Der Verein hat keine Angebote festgelegt.</div>
<?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>

View File

@ -99,6 +99,8 @@ class ClubsViewPart extends HtmlView
return new ClubsPartClubBic($id); return new ClubsPartClubBic($id);
case 'offers': case 'offers':
return new ClubsPartClubOffers($id); return new ClubsPartClubOffers($id);
case 'place':
return new ClubsPartClubPlace($id);
default: default:
throw new Exception('Internal Error'); throw new Exception('Internal Error');