Group FEWO | Upload Image FEWO | POS

Gruppen für die FEWO
Upload Images bei den Gruppen + vor und nach
Pos Sortierungen bei den Images
Einbau in den Frontend
Silder Bilder zuweisen  pre + page + post

git-svn-id: http://78.47.251.156/svn/dev/sterntours-3@3367 f459cee4-fb09-11de-96c3-f9c5f16c3c76
This commit is contained in:
adametz 2018-02-03 20:36:35 +00:00
parent ff986cd437
commit 1293c19bc6
25 changed files with 1249 additions and 37 deletions

View file

@ -0,0 +1,45 @@
{% extends 'admin.html.twig' %}
{% form_theme form 'default/form/theme.html.twig' %}
{% block body %}
<section class="clearfix">
<div class="content-copy">
<h1>Bild für Gruppe "{{ lodgingGroup.name }}" anlegen / bearbeiten</h1>
<form class="st-booking-form" method="post" enctype="multipart/form-data">
{{ form_errors(form) }}
<div class="form-box">
{% if is_new %}
{{ form_row(form.file, {label: 'Bild'}) }}
{% else %}
<div>
<img src="{{ asset('uploads/images/' ~ image_file_name) }}" alt="{{ image.description }}" style="width:456px;height:151px;" >
</div>
{% endif %}
{{ form_row(form.fileName, {label: 'Name'}) }}
{{ form_row(form.pos, {label: 'Position'}) }}
{{ form_row(form.comp, {label: 'Comnp'}) }}
{{ form_row(form.description, {label: 'Beschreibung'}) }}
<div class="col-md-12 col-sm-12 col-xs-12">
<button type="submit" value="SEND" id="submit"
class="btn btn-primary btn-lg border-radius"
>
Speichern
</button>
</div>
</div><!-- end form-box -->
{{ form_widget(form._token) }}
</form>
<a href="{{ '/admin/fewo/lodging/group/' ~ lodgingGroup.id }}"
class="btn btn-primary"
rel="nofollow"
>
Zurück
</a>
</div>
</section><!-- end section -->
{% endblock body %}

View file

@ -0,0 +1,35 @@
{% extends 'admin.html.twig' %}
{% form_theme form 'default/form/theme.html.twig' %}
{% block body %}
<section class="clearfix">
<div class="content-copy">
<h1>Mehrere Bilder für Gruppe "{{ lodgingGroup.name }}" hochladen</h1>
<form class="st-booking-form" method="post" enctype="multipart/form-data">
{{ form_errors(form) }}
<div class="form-box">
{{ form(form) }}
<br/>
<div class="col-md-12 col-sm-12 col-xs-12">
<button type="submit" value="SEND" id="submit"
class="btn btn-primary btn-lg border-radius"
>
Speichern
</button>
</div>
</div>
</form>
<a href="{{ '/admin/fewo/lodging/group/' ~ lodgingGroup.id }}"
class="btn btn-primary"
rel="nofollow"
>
Zurück
</a>
</div>
</section>
{% endblock body %}

View file

@ -19,6 +19,7 @@
</div>
{% endif %}
{{ form_row(form.fileName, {label: 'Name'}) }}
{{ form_row(form.pos, {label: 'Position'}) }}
{{ form_row(form.description, {label: 'Beschreibung'}) }}
<div class="col-md-12 col-sm-12 col-xs-12">

View file

@ -0,0 +1,140 @@
{% extends 'admin.html.twig' %}
{% form_theme form 'default/form/theme.html.twig' %}
{% block body %}
<section class="clearfix">
<div class="content-copy">
<h1>Gruppe {{ lodgingGroup.name }} bearbeiten</h1>
<form class="st-booking-form" method="post">
{{ form_errors(form) }}
<div id="message"></div>
<div class="form-box">
{{ form_row(form.name, {'label': 'Name'}) }}
<br><br>
<h3>Bilder vor</h3>
{% if lodgingGroup.images is not empty %}
<table class="table">
<thead>
<tr>
<th>Bild</th>
<th>Pos</th>
<th>Name</th>
<th>Beschreibung</th>
<th></th>
</tr>
</thead>
<tbody>
{% for image in lodgingGroup.images %}
{% if image.comp == 'pre' %}
<tr>
<td><img src="{{ asset('uploads/images/' ~ image.file) }}" alt="{{ image.description }}" style="width:228px;height:75px;" ></td>
<td>{{ image.pos }}</td>
<td>{{ image.fileName }}</td>
<td>{{ image.description }}</td>
<td>
<a href="{{ '/admin/fewo/lodgings/group/' ~ lodgingGroup.id ~ '/images/' ~ image.id }}"
class="btn btn-primary"
>
Bearbeiten
</a>
<a href="{{ '/admin/fewo/lodgings/group/' ~ lodgingGroup.id ~ '/images/' ~ image.id ~ '/delete' }}"
class="btn btn-primary"
>
Löschen
</a>
</td>
</tr>
{% endif %}
{% endfor %}
</tbody>
</table>
{% else %}
<h4>Keine Bilder vorhanden</h4>
{% endif %}
<a href="{{ '/admin/fewo/lodgings/group/pre/' ~ lodgingGroup.id ~ '/images/new' }}" class="btn btn-primary">
Hinzufügen
</a>
<a href="/admin/fewo/lodgings/group/pre/{{ lodgingGroup.id }}/images/multi-upload" class="btn btn-primary">
Mehrere Bilder hochladen
</a>
<br><br>
<h3>Bilder nach</h3>
{% if lodgingGroup.images is not empty %}
<table class="table">
<thead>
<tr>
<th>Bild</th>
<th>Pos</th>
<th>Name</th>
<th>Beschreibung</th>
<th></th>
</tr>
</thead>
<tbody>
{% for image in lodgingGroup.images %}
{% if image.comp == 'post' %}
<tr>
<td><img src="{{ asset('uploads/images/' ~ image.file) }}" alt="{{ image.description }}" style="width:228px;height:75px;" ></td>
<td>{{ image.pos }}</td>
<td>{{ image.fileName }}</td>
<td>{{ image.description }}</td>
<td>
<a href="{{ '/admin/fewo/lodgings/group/' ~ lodgingGroup.id ~ '/images/' ~ image.id }}"
class="btn btn-primary"
>
Bearbeiten
</a>
<a href="{{ '/admin/fewo/lodgings/group/' ~ lodgingGroup.id ~ '/images/' ~ image.id ~ '/delete' }}"
class="btn btn-primary"
>
Löschen
</a>
</td>
</tr>
{% endif %}
{% endfor %}
</tbody>
</table>
{% else %}
<h4>Keine Bilder vorhanden</h4>
{% endif %}
<a href="{{ '/admin/fewo/lodgings/group/post/' ~ lodgingGroup.id ~ '/images/new' }}" class="btn btn-primary">
Hinzufügen
</a>
<a href="/admin/fewo/lodgings/group/post/{{ lodgingGroup.id }}/images/multi-upload" class="btn btn-primary">
Mehrere Bilder hochladen
</a>
<br><br>
<div class="col-md-12 col-sm-12 col-xs-12">
<button type="submit" value="SEND" id="submit"
class="btn btn-primary btn-lg border-radius"
>
Speichern
</button>
</div>
</div><!-- end form-box -->
{{ form_rest(form) }}
</form>
<a href="/admin/fewo/lodgings"
class="btn btn-primary"
rel="nofollow"
>
Zurück
</a>
</div>
</section><!-- end section -->
{% endblock body %}

View file

@ -18,20 +18,20 @@
</thead>
<tbody>
{% if lodgings is not empty %}
{% for lodging in lodgings %}
{% if lodgingGroups is not empty %}
{% for lodgingGroup in lodgingGroups %}
<tr>
<td>{{ lodging.id }}</td>
<td>{{ lodging.name }}</td>
<td>{{ lodging.type }}</td>
<td>- ({{ lodgingGroup.id }}) -</td>
<td>{{ lodgingGroup.name }}</td>
<td>Gruppe</td>
<td>
<a href="{{ '/admin/fewo/lodgings/' ~ lodging.id }}"
<a href="{{ '/admin/fewo/lodging/group/' ~ lodgingGroup.id }}"
class="btn btn-primary"
rel="nofollow"
>
Bearbeiten
</a>
<a href="{{ '/admin/fewo/lodgings/' ~ lodging.id ~ '/delete' }}"
<a href="{{ '/admin/fewo/lodging/group/' ~ lodgingGroup.id ~ '/delete' }}"
class="btn btn-primary"
rel="nofollow"
>
@ -39,6 +39,31 @@
</a>
</td>
</tr>
{% if lodgingGroup.lodgings is not empty %}
{% for lodging in lodgingGroup.lodgings %}
<tr>
<td>{{ lodging.id }}</td>
<td>{{ lodging.name }}</td>
<td>{{ lodging.type }}</td>
<td>
<a href="{{ '/admin/fewo/lodgings/' ~ lodging.id }}"
class="btn btn-primary"
rel="nofollow"
>
Bearbeiten
</a>
<a href="{{ '/admin/fewo/lodgings/' ~ lodging.id ~ '/delete' }}"
class="btn btn-primary"
rel="nofollow"
>
Löschen
</a>
</td>
</tr>
{% endfor %}
{% endif %}
{% endfor %}
{% else %}
<h2>Keine Objekte verfügbar</h2>
@ -55,6 +80,17 @@
</td>
</tr>
<tr>
<td>
<a href="/admin/fewo/lodgings/group/new"
class="btn btn-primary"
rel="nofollow"
>
Gruppe hinzufügen
</a>
</td>
</tr>
</tbody>
</table>
</div>

View file

@ -15,6 +15,7 @@
<div class="form-box">
{{ form_row(form.name, {'label': 'Name'}) }}
{{ form_row(form.group, {'label': 'Gruppe'}) }}
{{ form_row(form.type, {'label': 'Typ'}) }}
{{ form_row(form.description, {'label': 'Beschreibung'}) }}
{{ form_row(form.equipment, {'label': 'Ausstattung'}) }}
@ -43,6 +44,7 @@
<thead>
<tr>
<th>Bild</th>
<th>Pos</th>
<th>Name</th>
<th>Beschreibung</th>
<th></th>
@ -52,6 +54,7 @@
{% for image in lodging.images %}
<tr>
<td><img src="{{ asset('uploads/images/' ~ image.file) }}" alt="{{ image.description }}" style="width:228px;height:75px;" ></td>
<td>{{ image.pos }}</td>
<td>{{ image.fileName }}</td>
<td>{{ image.description }}</td>
<td>

View file

@ -43,9 +43,16 @@
<td class="{{ cell_class }}">
{% if dayState.isReserved and not dayState.isReservationEnd %}
<a href="{{ '/admin/fewo/lodgings/' ~ lodging.id ~ '/reservations/' ~ dayState.reservation.id }}">
{{ dayState.day }}
</a>
{% if dayState.reservation.id is defined %}
<a href="/admin/fewo/lodgings/{{ lodging.id }}/reservations/{{ dayState.reservation.id }}">
{{ dayState.day }}
</a>
{% else %}
ID
{% endif %}
{% elseif dayState.isBookable and not is_past_date %}
<a href="/admin/fewo/lodgings/{{ lodging.id }}/reservations/new/{{ dayState.day < 10 ? '0':'' }}{{dayState.day}}{{ calendar_month['monthNumber'] < 10 ? '0':'' }}{{calendar_month['monthNumber']}}{{calendar_month['year']}}">
{{ dayState.day }}

View file

@ -0,0 +1,39 @@
{% extends 'admin.html.twig' %}
{% form_theme form 'default/form/theme.html.twig' %}
{% block body %}
<section class="clearfix">
<div class="content-copy">
<h1>Neue Gruppe anlegen</h1>
<form class="st-booking-form" method="post">
{{ form_errors(form) }}
<div id="message"></div>
<div class="form-box">
{{ form_row(form.name, {label: 'Name'}) }}
<div class="col-md-12 col-sm-12 col-xs-12">
<button type="submit" value="SEND" id="submit"
class="btn btn-primary btn-lg border-radius"
>
Speichern
</button>
</div>
</div><!-- end form-box -->
{{ form_rest(form) }}
</form>
<a href="/admin/fewo/lodgings"
class="btn btn-primary"
rel="nofollow"
>
Zurück
</a>
</div>
</section><!-- end section -->
{% endblock body %}

View file

@ -0,0 +1,30 @@
{# @var lodging \AppBundle\Entity\FewoLodging #}
<div class="col-md-4 col-sm-4">
<div class="travel-wrapper get-box-link">
<div class="item text-left">
<div class="item-img">
<div class="lb">
{% if lodging.page.boxStar is not empty %}
<div class="cstar_left">{{ lodging.page.boxStar|raw }}</div>
{% endif %}
{% if lodging.page.travelProgram is not empty and lodging.page.travelProgram.lowestPrice > 0 %}
<div class="cprice">ab {{ lodging.page.travelProgram.lowestPrice|number_format }} € p.P.</div>
{% endif %}
{% if lodging.page.boxDiscount is not empty %}
<div class="cdiscount">{{ lodging.page.boxDiscount|raw }}</div>
{% endif %}
</div>
{% include 'default/components/pageBoxImage.html.twig' with {page: lodging.page} %}
</div>
<div class="box_mid">
<div class="hl5">{{ lodging.page.title }}</div>
<p>{{ lodging.page.boxBody ?? lodging.page.description }}</p>
</div>
<a class="item-button is-box-link dobble_line" href="{{ lodging.page.urlPath }}" title="{{ lodging.page.title }}">
<span>{{ lodging.page.title }}</span>
</a>
</div>
</div>
</div>

View file

@ -12,7 +12,10 @@
{# END WORKAROUND #}
{% elseif page is defined %}
{{ render(controller('AppBundle:Component:searchSidebarWidget', {page: page})) }}
{# #HACK Dont display the search in FEWO #}
{% if page.title != 'Ferienwohnungen' %}
{{ render(controller('AppBundle:Component:searchSidebarWidget', {page: page})) }}
{% endif %}
{% endif %}
{% else %}
{{ search_sidebar_widget_block|raw }}
@ -22,7 +25,7 @@
{% if show_nav_sidebar_widget ?? true and page is defined %}
{% if nav_sidebar_widget_block is null %}
{{ render(controller('AppBundle:Component:navSidebarWidget', {page: page})) }}
{% else %}
{% else %}
{{ nav_sidebar_widget_block|raw }}
{% endif %}
{% endif %}

View file

@ -24,17 +24,14 @@
<div id="myCarousel" class="carousel slide fewo">
<!-- Indicators -->
<ol class="carousel-indicators">
{% for lodging_image in fewo_lodging.images %}
<li data-target="#myCarousel" data-slide-to="{{ loop.index-1 }}" {% if loop.first %}class="active"{% endif %}></li>
{% for lodging_image in slider_imgs %}
<li data-target="#myCarousel" data-slide-to="{{ loop.index-1 }}" {% if loop.first %}class="active"{% endif %}></li>
{% endfor %}
</ol>
<!-- Wrapper for Slides -->
<div class="carousel-inner">
{% for lodging_image in fewo_lodging.images %}
{# @var lodging_image \AppBundle\Entity\FewoLodgingImage #}
{% for lodging_image in slider_imgs %}
<div class="item{% if loop.first %} active{% endif %}">
<!-- Set the first background image using inline CSS below. -->
{# TODO #}
<div class="fill" style="background-image:url({{ asset('uploads/images/' ~ lodging_image.file) }});">
<span class="image-title">{{ lodging_image.fileName }}</span>
</div>

View file

@ -8,16 +8,22 @@
{% block body %}
<section class="clearfix">
<h1>{{ page.pagetitle|default(page.title) }}</h1>
{#{% for i in 0..page.children|length//3 %}#}
<div class="row">
{% for child_page in page.children if child_page.status == 1 %}
{% if lodgingGroups is not empty %}
{% for lodgingGroup in lodgingGroups %}
<h1>{{ lodgingGroup.name }}</h1>
{% include 'default/components/pageBox.html.twig' %}
<div class="row">
{% if lodgingGroup.lodgings is not empty %}
{% for lodging in lodgingGroup.lodgings %}
{% include 'default/components/pageLodgingBox.html.twig' %}
{% endfor %}
{% endif %}
</div>
{% endfor %}
{% endif %}
{% endfor %}
</div>
</section>
<section class="clearfix">

View file

@ -10,16 +10,20 @@ namespace AppBundle\Controller;
use AppBundle\AppBundle;
use AppBundle\Entity\FewoBookingRequest;
use AppBundle\Entity\FewoLodging;
use AppBundle\Entity\FewoLodgingGroup;
use AppBundle\Entity\FewoPrice;
use AppBundle\Entity\FewoReservation;
use AppBundle\Entity\FewoSeason;
use AppBundle\Entity\FewoLodgingImage;
use AppBundle\Entity\FewoLodgingGroupImage;
use AppBundle\Form\FewoBookingRequestType;
use AppBundle\Form\FewoLodgingType;
use AppBundle\Form\FewoLodgingTypeGroup;
use AppBundle\Form\FewoPriceType;
use AppBundle\Form\FewoReservationType;
use AppBundle\Form\FewoSeasonType;
use AppBundle\Form\FewoLodgingImageType;
use AppBundle\Form\FewoLodgingGroupImageType;
use AppBundle\Service\FileManager;
use AppBundle\Util;
use Doctrine\Bundle\DoctrineCacheBundle\Tests\Functional\FileSystemCacheTest;
@ -73,12 +77,12 @@ class AdminController extends Controller
*/
public function adminFewoLodgingsAction(Request $request)
{
$fewoLodgingRepo = $this->getEntityManager()->getRepository('AppBundle:FewoLodging');
$lodgings = $fewoLodgingRepo->findAll();
$fewoLodgingGroupRepo = $this->getEntityManager()->getRepository('AppBundle:FewoLodgingGroup');
$lodgingGroups = $fewoLodgingGroupRepo->findAll();
return $this->render('default/admin/lodgings.html.twig', [
'lodgings' => $lodgings,
'lodgingGroups' => $lodgingGroups,
]);
}
@ -88,7 +92,6 @@ class AdminController extends Controller
public function adminFewoNewLodgingAction(Request $request)
{
$lodging = null;
if ($request->getMethod() != 'POST')
{
$lodging = new FewoLodging();
@ -120,6 +123,85 @@ class AdminController extends Controller
]);
}
/**
* @Route("/admin/fewo/lodgings/group/new")
*/
public function adminFewoGroupNewLodgingAction(Request $request)
{
$lodgingGroup = null;
if ($request->getMethod() != 'POST')
{
$lodgingGroup = new FewoLodgingGroup();
}
$form = $this->createForm(FewoLodgingTypeGroup::class, $lodgingGroup, [
]);
// todo if(form == null)...
if ($request->getMethod() == 'POST')
{
$form->handleRequest($request);
$lodgingGroup = $form->getData();
}
if ($request->getMethod() == 'POST' && $form->isValid())
{
$em = $this->getEntityManager();
$em->persist($lodgingGroup);
$em->flush();
return $this->redirect('/admin/fewo/lodgings');
}
return $this->render('default/admin/lodgingsGroupNew.html.twig', [
'form' => $form->createView(),
]);
}
/**
* @Route("/admin/fewo/lodging/group/{lodgingGroupId}", requirements={"lodgingGroupId": "\d+"})
*/
public function adminFewoEditLodgingGroupAction(Request $request, $lodgingGroupId)
{
$em = $this->getEntityManager();
$fewoLodgingGroupRepo = $em->getRepository('AppBundle:FewoLodgingGroup');
$lodgingGroup = null;
$lodgingGroup = $fewoLodgingGroupRepo->find($lodgingGroupId);
$form = $this->createForm(FewoLodgingTypeGroup::class, $lodgingGroup, [
//options
]);
if($request->getMethod() == 'POST')
{
$form->handleRequest($request);
}
if ($request->getMethod() == 'POST' && $form->isValid())
{
$em->flush();
return $this->redirect('/admin/fewo/lodgings');
}
return $this->render('default/admin/lodgingGroupEdit.html.twig', [
'form' => $form->createView(),
'lodgingGroup' => $lodgingGroup,
]);
}
private function getSeasons(FewoLodging $lodging)
{
$seasons = [];
@ -222,6 +304,25 @@ class AdminController extends Controller
return $this->redirect('/admin/fewo/lodgings');
}
/**
* @Route("/admin/fewo/lodging/group/{lodgingGroupId}/delete", requirements={"lodgingGroupId": "\d+"})
*/
public function adminFewoDeleteLodgingGroupAction(Request $request, $lodgingGroupId)
{
$em = $this->getEntityManager();
$fewoLodgingGroupRepo = $em->getRepository('AppBundle:FewoLodgingGroup');
$lodgingGroup = $fewoLodgingGroupRepo->find($lodgingGroupId);
if($lodgingGroup != null)
{
$em->remove($lodgingGroup);
$em->flush();
}
return $this->redirect('/admin/fewo/lodgings');
}
// todo, WEG
/**
@ -770,6 +871,8 @@ class AdminController extends Controller
return $this->redirect('/admin/fewo/seasons');
}
/* ---- FILES LODGING ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- */
/* ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- */
/**
* @Route("/admin/fewo/lodgings/{lodgingId}/images/multi-upload", requirements={"lodgingId": "\d+"})
@ -794,9 +897,11 @@ class AdminController extends Controller
$uploader = $this->container->get('app.image_uploader');
foreach ($form->getData() as $uploadedFile)
{
$image = new FewoLodgingImage();
$image->setFile($uploadedFile);
$image->setLodging($lodging);
$image->setPos(0);
$image->setFileName('');
$image->setDescription('');
$em->persist($image);
@ -865,6 +970,7 @@ class AdminController extends Controller
if ($request->getMethod() != 'POST' && $image == null)
{
$image = new FewoLodgingImage();
$image->setPos(0);
}
$form = $this->createForm(FewoLodgingImageType::class, $image);
@ -919,4 +1025,169 @@ class AdminController extends Controller
return $this->redirect('/admin/fewo/lodgings/'.$lodgingId);
}
/* ---- FILES GROUP ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- */
/* ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- */
/**
* @Route("/admin/fewo/lodgings/group/{comp}/{lodgingGroupId}/images/multi-upload", requirements={"comp": "pre|post", "lodgingGroupId": "\d+"})
*/
public function adminFewoGroupImageMultiUploadAction(Request $request, $comp, $lodgingGroupId)
{
$em = $this->getEntityManager();
$lodgingGroup = $em->getRepository('AppBundle:FewoLodgingGroup')->find($lodgingGroupId);
if (!$lodgingGroup)
{
throw new HttpException(404, 'Unbekannte lodgingGroup-ID: '. $lodgingGroupId);
}
$form = $this->createForm(FileType::class, null, [
'multiple' => true
]);
if ($request->getMethod() == 'POST')
{
$form->handleRequest($request);
if ($form->isValid())
{
$uploader = $this->container->get('app.image_uploader');
foreach ($form->getData() as $uploadedFile)
{
$image = new FewoLodgingGroupImage();
$image->setFile($uploadedFile);
$image->setLodgingGroup($lodgingGroup);
$image->setComp($comp);
$image->setPos(0);
$image->setFileName('');
$image->setDescription('');
$em->persist($image);
$em->flush();
}
return $this->redirect('/admin/fewo/lodging/group/'. $lodgingGroup->getId());
}
}
return $this->render('default/admin/fewoGroupImageMultiUpload.html.twig', [
'form' => $form->createView(),
'lodgingGroup' => $lodgingGroup,
'comp' => $comp,
]);
}
/**
* @Route("/admin/fewo/lodgings/group/{comp}/{lodgingGroupId}/images/new", requirements={"comp": "pre|post", "lodgingGroupId": "\d+"})
*/
public function adminFewoGroupNewImageAction(Request $request, $comp, $lodgingGroupId)
{
$lodgingGroup = $this->getEntityManager()->getRepository('AppBundle:FewoLodgingGroup')->find($lodgingGroupId);
if (!$lodgingGroup)
{
throw new HttpException(404, 'Unbekannte lodgingGroup-ID: '. $lodgingGroupId);
}
return $this->processGroupImageForm($request, null, $comp, $lodgingGroup);
}
/**
* @Route("/admin/fewo/lodgings/group/{lodgingGroupId}/images/{imageId}", requirements={"lodgingGroupId": "\d+", "imageId": "\d+"})
*/
public function adminFewoGroupEditImageAction(Request $request, $lodgingGroupId, $imageId)
{
/** @var FewoLodgingGroupImage $image */
$image = $this->getEntityManager()->getRepository('AppBundle:FewoLodgingGroupImage')->find($imageId);
if (!$image || $image->getLodgingGroup()->getId() != $lodgingGroupId)
{
throw new HttpException(404, 'Unbekannte FewoLodgingGroupImage-ID oder lodgingGroup-ID passt nicht: '.
$imageId .' / '. $lodgingGroupId);
}
return $this->processGroupImageForm($request, $image);
}
/**
* @param Request $request
* @param FewoLodgingGroupImage $image
* @param FewoLodgingGroup|null $lodgingGroup
*
* @return \Symfony\Component\HttpFoundation\RedirectResponse|\Symfony\Component\HttpFoundation\Response
*/
public function processGroupImageForm(Request $request, $image, $comp = null, $lodgingGroup = null)
{
$em = $this->getEntityManager();
if ($image == null)
{
$isNew = true;
}
else
{
$isNew = false;
$lodgingGroup = $image->getLodgingGroup();
$imageFileName = $image->getFile();
}
if ($request->getMethod() != 'POST' && $image == null)
{
$image = new FewoLodgingGroupImage();
$image->setComp($comp);
$image->setPos(0);
}
$form = $this->createForm(FewoLodgingGroupImageType::class, $image);
if ($request->getMethod() == 'POST')
{
$form->handleRequest($request);
}
if ($request->getMethod() == 'POST' && $form->isValid())
{
$image = $form->getData();
if ($isNew)
{
$image->setLodgingGroup($lodgingGroup);
$image->setComp($comp);
}
else
{
$image->setFile($imageFileName);
}
$em->persist($image);
$em->flush();
return $this->redirect('/admin/fewo/lodging/group/'. ($lodgingGroup->getId()));
}
return $this->render('default/admin/fewoGroupImage.html.twig', [
'form' => $form->createView(),
'lodgingGroup' => $lodgingGroup,
'is_new' => $isNew,
'image_file_name' => $isNew ? null : $imageFileName,
'image' => $image,
]);
}
/**
* @Route("/admin/fewo/lodgings/group/{lodgingGroupId}/images/{imageId}/delete", requirements={"lodgingGroupId": "\d+", "imageId": "\d+"})
*/
public function adminFewoGroupDeleteImageAction(Request $request, $lodgingGroupId, $imageId)
{
$em = $this->getEntityManager();
$fewoLodgingGroupImageRepo = $em->getRepository('AppBundle:FewoLodgingGroupImage');
$image = $fewoLodgingGroupImageRepo->find($imageId);
if($image != null)
{
$em->remove($image);
$em->flush();
}
return $this->redirect('/admin/fewo/lodging/group/'.$lodgingGroupId);
}
}

View file

@ -9,6 +9,7 @@ namespace AppBundle\Controller;
use AppBundle\Entity\Page;
use AppBundle\Entity\SunstarTravelProgram;
use AppBundle\Entity\FewoLodgingGroup;
use AppBundle\Form\TtSearchRequestType;
use AppBundle\Listener\KernelControllerListener;
use Doctrine\ORM\EntityManager;
@ -55,9 +56,14 @@ class CmsController extends Controller
$settings = [];
}
$fewoLodgingGroupRepo = $this->getEntityManager()->getRepository('AppBundle:FewoLodgingGroup');
$lodgingGroups = $fewoLodgingGroupRepo->findAll();
return $this->render('default/pages/cms/overview.html.twig', array_merge($settings, [
'base_dir' => realpath($this->getParameter('kernel.root_dir').'/..').DIRECTORY_SEPARATOR,
'page' => $page,
'lodgingGroups' => $lodgingGroups,
]));
}
@ -143,10 +149,29 @@ class CmsController extends Controller
$calendar = $paddedCalendar;
}
$imgs = array();
$imgs_pre = array();
$imgs_post = array();
$lodgingGroup = $lodging->getGroup();
foreach ($lodgingGroup->getImages() as $image) {
if($image->getComp() == 'pre'){
$imgs_pre[] = $image;
}
if($image->getComp() == 'post'){
$imgs_post[] = $image;
}
}
foreach ($lodging->getImages() as $image) {
$imgs[] = $image;
}
return $this->render('default/pages/cms/fewoTravelProgram.html.twig', [
'base_dir' => realpath($this->getParameter('kernel.root_dir').'/..').DIRECTORY_SEPARATOR,
'page' => $page,
'fewo_lodging' => $lodging,
'slider_imgs' => array_merge ($imgs_pre, $imgs, $imgs_post),
//'lodging' => $lodging, //so wurde es im AdminController aufgerufen
'calendar' => $calendar,
'show_search_sidebar_widget' => false,

View file

@ -33,6 +33,16 @@ class FewoLodging
private $name;
/**
* @var \AppBundle\Entity\FewoLodgingGroup
*
* @ORM\ManyToOne(targetEntity="FewoLodgingGroup")
* @ORM\JoinColumns({
* @ORM\JoinColumn(name="group_id", referencedColumnName="id")
* })
*/
private $group;
/**
* @var \AppBundle\Entity\FewoLodgingType
*
* @ORM\ManyToOne(targetEntity="FewoLodgingType")
@ -119,6 +129,7 @@ class FewoLodging
/**
* @ORM\OneToMany(targetEntity="FewoLodgingImage", mappedBy="lodging", cascade={"persist", "remove"})
* @ORM\OrderBy({"pos" = "ASC"})
*/
private $images;
@ -428,6 +439,31 @@ class FewoLodging
return $this->calendarVisible;
}
/**
* Set type
*
* @param \AppBundle\Entity\FewoLodgingGroup $group
*
* @return FewoLodging
*/
public function setGroup(\AppBundle\Entity\FewoLodgingGroup $group = null)
{
$this->group = $group;
return $this;
}
/**
* Get type
*
* @return \AppBundle\Entity\FewoLodgingGroup
*/
public function getGroup()
{
return $this->group;
}
/**
* Set type
*

View file

@ -0,0 +1,141 @@
<?php
namespace AppBundle\Entity;
use AppBundle\AppBundle;
use Symfony\Component\Validator\Constraints as Assert;
use Doctrine\ORM\Mapping as ORM;
/**
* @ORM\Table
* @ORM\Entity
*/
class FewoLodgingGroup
{
/**
* @var integer
*
* @ORM\Column(name="id", type="integer")
* @ORM\Id
* @ORM\GeneratedValue(strategy="IDENTITY")
*/
private $id;
/**
* @var string
*
* @ORM\Column(name="name", type="string", length=255, nullable=true)
*/
private $name;
/**
* @ORM\OneToMany(targetEntity="FewoLodging", mappedBy="group", cascade={"persist", "remove"})
*/
private $lodgings;
//------------------------------------------------------------------------------------------------------------------
// Bilder
/**
* @ORM\OneToMany(targetEntity="FewoLodgingGroupImage", mappedBy="lodgingGroup", cascade={"persist", "remove"})
* @ORM\OrderBy({"pos" = "ASC"})
*/
private $images;
/**
* Constructor
*/
public function __construct()
{
$this->images = new \Doctrine\Common\Collections\ArrayCollection();
}
/**
* Get id
*
* @return integer
*/
public function getId()
{
return $this->id;
}
/**
* Get lodgings
*
* @return \Doctrine\Common\Collections\Collection
*/
public function getLodgings()
{
return $this->lodgings;
}
/**
* Add image
*
* @param \AppBundle\Entity\FewoLodgingGroupImage $image
*
* @return FewoLodging
*/
public function addImage(\AppBundle\Entity\FewoLodgingGroupImage $image)
{
$this->images[] = $image;
return $this;
}
/**
* Remove image
*
* @param \AppBundle\Entity\FewoLodgingGroupImage $image
*/
public function removeImage(\AppBundle\Entity\FewoLodgingGroupImage $image)
{
$this->images->removeElement($image);
}
/**
* Get images
*
* @return \Doctrine\Common\Collections\Collection
*/
public function getImages()
{
return $this->images;
}
/**
* Set name
*
* @param string $name
*
* @return FewoLodgingType
*/
public function setName($name)
{
$this->name = $name;
return $this;
}
/**
* Get name
*
* @return string
*/
public function getName()
{
return $this->name;
}
function __toString()
{
return $this->name;
}
}

View file

@ -0,0 +1,234 @@
<?php
namespace AppBundle\Entity;
use Symfony\Component\Validator\Constraints as Assert;
use Doctrine\ORM\Mapping as ORM;
/**
* @ORM\Table
* @ORM\Entity
*/
class FewoLodgingGroupImage
{
/**
* @var integer
*
* @ORM\Column(name="id", type="integer")
* @ORM\Id
* @ORM\GeneratedValue(strategy="IDENTITY")
*/
private $id;
/**
* @var string
*
* @ORM\Column(name="full_file_name", type="string", length=255, nullable=false)
* @Assert\Image(maxSize="15000000", mimeTypes={"image/jpeg", "image/png"})
*/
private $file;
/**
* @var string
*
* @ORM\Column(name="file_name", type="string", length=255, nullable=false)
* @Assert\NotBlank
*/
private $fileName;
/**
* @var string
*
* @ORM\Column(name="comp", type="string", length=4, nullable=true)
* @Assert\NotBlank
*/
private $comp;
/**
* @var string
*
* @ORM\Column(name="pos", type="integer", nullable=false)
* @Assert\NotBlank
*/
private $pos;
/**
* @var string
*
* @ORM\Column(name="description", type="string", length=255, nullable=true)
*/
private $description;
/**
* @var \AppBundle\Entity\FewoLodgingGroup
*
* @ORM\ManyToOne(targetEntity="FewoLodgingGroup", inversedBy="images")
* @ORM\JoinColumns({
* @ORM\JoinColumn(name="group_id", referencedColumnName="id", onDelete="SET NULL")
* })
*/
private $lodgingGroup;
/**
* Get id
*
* @return integer
*/
public function getId()
{
return $this->id;
}
/**
* Set file
*
* @param string $file
*
* @return FewoLodgingGroupImage
*/
public function setFile($file)
{
$this->file = $file;
return $this;
}
/**
* Get file
*
* @return string
*/
public function getFile()
{
return $this->file;
}
/**
* Set description
*
* @param string $description
*
* @return FewoLodgingGroupImage
*/
public function setDescription($description)
{
$this->description = $description;
return $this;
}
/**
* Get description
*
* @return string
*/
public function getDescription()
{
return $this->description;
}
/**
* Set comp
*
* @param string $comp
*
* @return FewoLodgingGroupImage
*/
public function setComp($comp)
{
$this->comp = $comp;
return $this;
}
/**
* Get comp
*
* @return string
*/
public function getComp()
{
return $this->comp;
}
/**
* Set pos
*
* @param string $pos
*
* @return FewoLodgingGroupImage
*/
public function setPos($pos)
{
$this->pos = $pos;
return $this;
}
/**
* Get pos
*
* @return string
*/
public function getPos()
{
return $this->pos;
}
/**
* Set lodgingGroup
*
* @param \AppBundle\Entity\FewoLodgingGroup $lodgingGroup
*
* @return FewoLodgingGroupImage
*/
public function setLodgingGroup(\AppBundle\Entity\FewoLodgingGroup $lodgingGroup = null)
{
$this->lodgingGroup = $lodgingGroup;
return $this;
}
/**
* Get lodgingGroup
*
* @return \AppBundle\Entity\FewoLodgingGroup
*/
public function getLodgingGroup()
{
return $this->lodgingGroup;
}
function __toString()
{
return $this->file;
}
/**
* Set fileName
*
* @param string $fileName
*
* @return FewoLodgingGroupImage
*/
public function setFileName($fileName)
{
$this->fileName = $fileName;
return $this;
}
/**
* Get fileName
*
* @return string
*/
public function getFileName()
{
return $this->fileName;
}
}

View file

@ -36,6 +36,14 @@ class FewoLodgingImage
*/
private $fileName;
/**
* @var string
*
* @ORM\Column(name="pos", type="integer", nullable=false)
* @Assert\NotBlank
*/
private $pos;
/**
* @var string
*
@ -88,6 +96,31 @@ class FewoLodgingImage
return $this->file;
}
/**
* Set pos
*
* @param string $pos
*
* @return FewoLodgingImage
*/
public function setPos($pos)
{
$this->pos = $pos;
return $this;
}
/**
* Get pos
*
* @return string
*/
public function getPos()
{
return $this->pos;
}
/**
* Set description
*

View file

@ -0,0 +1,49 @@
<?php
namespace AppBundle\Form;
use Symfony\Component\Form\AbstractType;
use Symfony\Component\Form\Extension\Core\Type\FileType;
use Symfony\Component\Form\FormBuilderInterface;
use Symfony\Component\OptionsResolver\OptionsResolver;
use Symfony\Component\Form\Extension\Core\Type\HiddenType;
class FewoLodgingGroupImageType extends AbstractType
{
/**
* {@inheritdoc}
*/
public function buildForm(FormBuilderInterface $builder, array $options)
{
$builder
->add('file', FileType::class, [
'data_class' => null
])
->add('pos')
->add('comp', HiddenType::class, ['required' => false])
->add('fileName')
->add('description')
;
}
/**
* {@inheritdoc}
*/
public function configureOptions(OptionsResolver $resolver)
{
$resolver->setDefaults(array(
'data_class' => 'AppBundle\Entity\FewoLodgingGroupImage'
));
}
/**
* {@inheritdoc}
*/
public function getBlockPrefix()
{
return 'appbundle_fewolodginggroupimage';
}
}

View file

@ -18,6 +18,7 @@ class FewoLodgingImageType extends AbstractType
->add('file', FileType::class, [
'data_class' => null
])
->add('pos')
->add('fileName')
->add('description')
;

View file

@ -54,7 +54,14 @@ class FewoLodgingType extends AbstractType
'required' => true,
])
//->add('calendarVisible')
->add('type', EntityType::class, [
->add('group', EntityType::class, [
'placeholder' => '(Bitte wählen) *',
'class' => 'AppBundle\Entity\FewoLodgingGroup',
'constraints' => [
new NotNull()
]
])
->add('type', EntityType::class, [
'placeholder' => '(Bitte wählen) *',
'class' => 'AppBundle\Entity\FewoLodgingType',
'constraints' => [

View file

@ -0,0 +1,57 @@
<?php
namespace AppBundle\Form;
use Doctrine\Common\Collections\Collection;
use Symfony\Bridge\Doctrine\Form\Type\EntityType;
use Symfony\Component\Form\AbstractType;
use Symfony\Component\Form\Extension\Core\Type\CheckboxType;
use Symfony\Component\Form\Extension\Core\Type\ChoiceType;
use Symfony\Component\Form\Extension\Core\Type\CollectionType;
use Symfony\Component\Form\Extension\Core\Type\TextareaType;
use Symfony\Component\Form\Extension\Core\Type\TextType;
use Symfony\Component\Form\FormBuilderInterface;
use Symfony\Component\Form\FormEvent;
use Symfony\Component\Form\FormEvents;
use Symfony\Component\OptionsResolver\OptionsResolver;
use Symfony\Component\Validator\Constraints\Choice;
use Symfony\Component\Validator\Constraints\NotNull;
use AppBundle\Entity\FewoSeason;
class FewoLodgingTypeGroup extends AbstractType
{
/**
* {@inheritdoc}
*/
public function buildForm(FormBuilderInterface $builder, array $options)
{
$builder
->add('name', null, [
'required' => true,
])
;
}
/**
* {@inheritdoc}
*/
public function configureOptions(OptionsResolver $resolver)
{
$resolver->setDefaults(array(
'data_class' => 'AppBundle\Entity\FewoLodgingGroup'
));
}
/**
* {@inheritdoc}
*/
public function getBlockPrefix()
{
return 'appbundle_fewolodgingtypegroup';
}
}

View file

@ -7,6 +7,7 @@ use Symfony\Component\HttpFoundation\File\UploadedFile;
use Doctrine\ORM\Event\LifecycleEventArgs;
use Doctrine\ORM\Event\PreUpdateEventArgs;
use AppBundle\Entity\FewoLodgingImage;
use AppBundle\Entity\FewoLodgingGroupImage;
use AppBundle\Service\FileManager;
class DoctrineFileListener
@ -42,7 +43,8 @@ class DoctrineFileListener
private function uploadFile($entity)
{
if (!$entity instanceof FewoLodgingImage)
if (!$entity instanceof FewoLodgingImage && !$entity instanceof FewoLodgingGroupImage)
{
return;
}
@ -66,11 +68,16 @@ class DoctrineFileListener
private function deleteFile($entity)
{
if(!$entity instanceof FewoLodgingImage)
if($entity instanceof FewoLodgingImage)
{
return;
$this->uploader->delete($entity);
}
$this->uploader->delete($entity);
if($entity instanceof FewoLodgingGroupImage)
{
$this->uploader->deleteGroup($entity);
}
}
}

View file

@ -72,6 +72,7 @@ class KernelControllerListener
$qb->where($qb->expr()->eq('p.lvl', $i));
$qb->andWhere($qb->expr()->eq('p.slug', ':slug'));
$qb->setParameter('slug', $slug);
if ($node != null)
{
$qb->andWhere($qb->expr()->between('p.lft', $node->getLft(), $node->getRgt()));
@ -100,7 +101,6 @@ class KernelControllerListener
return;
}
}
if (!$node)
{
// Search for a redirect entry
@ -114,9 +114,9 @@ class KernelControllerListener
return;
}
}
if ($node)
{
if ($node->getStatus() == 0)
{
throw new NotFoundHttpException('Inactive page');

View file

@ -2,6 +2,7 @@
namespace AppBundle\Service;
use AppBundle\Entity\FewoLodgingImage;
use AppBundle\Entity\FewoLodgingGroupImage;
use Symfony\Component\HttpFoundation\File\UploadedFile;
use Symfony\Component\Filesystem\Filesystem;
@ -20,6 +21,7 @@ class FileManager
public function upload(UploadedFile $file)
{
$baseFileName = md5(uniqid());
$fileName = $baseFileName.'.'.$file->guessExtension();
$file->move($this->getTargetDir(), $fileName);
@ -86,6 +88,13 @@ class FileManager
$filesystem->remove($this->getTargetDir().'/'.$image->getFile());
}
public function deleteGroup(FewoLodgingGroupImage $image)
{
$filesystem = new Filesystem();
$filesystem->remove($this->getTargetDir().'/'.$image->getFile());
}
public function getTargetDir()
{
return $this->targetDir;