Commit 391cf5dc authored by Mat's avatar Mat

today: affichage des légumes triés

parent 3c9f0a3a
...@@ -43,12 +43,15 @@ class MembreController extends MasterController ...@@ -43,12 +43,15 @@ class MembreController extends MasterController
$offreOne = $this->getDoctrine()->getManager() $offreOne = $this->getDoctrine()->getManager()
->getRepository('PotageBundle:Offre') ->getRepository('PotageBundle:Offre')
->findOneByReference($tokenInside['offre_ref']); ->findOneByReference($tokenInside['offre_ref']);
$legumesSorted = $this->getOffreLegumesSorted($offreOne);
} else { } else {
$token = null; $token = null;
$tokenInside =null; $tokenInside =null;
$offreOne = null; $offreOne = null;
$legumesSorted = null;
} }
...@@ -58,6 +61,7 @@ class MembreController extends MasterController ...@@ -58,6 +61,7 @@ class MembreController extends MasterController
'token' => $token, 'token' => $token,
'tokenInside' => $tokenInside, 'tokenInside' => $tokenInside,
'offreOne' => $offreOne, 'offreOne' => $offreOne,
'legumesSorted' => $legumesSorted,
)); ));
} }
...@@ -82,6 +86,8 @@ class MembreController extends MasterController ...@@ -82,6 +86,8 @@ class MembreController extends MasterController
$offreOne = $this->getDoctrine()->getManager() $offreOne = $this->getDoctrine()->getManager()
->getRepository('PotageBundle:Offre') ->getRepository('PotageBundle:Offre')
->findOneByReference($offre_ref); ->findOneByReference($offre_ref);
$legumesSorted = $this->getOffreLegumesSorted($offreOne);
if ($offreOne === null) { if ($offreOne === null) {
return $this->redirectToRoute('potage_today'); return $this->redirectToRoute('potage_today');
...@@ -93,6 +99,7 @@ class MembreController extends MasterController ...@@ -93,6 +99,7 @@ class MembreController extends MasterController
'token' => null, 'token' => null,
'tokenInside' => null, 'tokenInside' => null,
'offreOne' => $offreOne, 'offreOne' => $offreOne,
'legumesSorted' => $legumesSorted,
)); ));
} }
...@@ -137,5 +144,27 @@ class MembreController extends MasterController ...@@ -137,5 +144,27 @@ class MembreController extends MasterController
return $groupes; return $groupes;
} }
/**
* Retourne un tableau d'objets OffreLégumes triés
*
* @param Offre $offre
* @return array
*/
private function getOffreLegumesSorted(Offre $offre)
{
$sort = explode(",", $offre->getSorted());
foreach ($sort as $k => $v)
{
foreach ($offre->getOffreLegumes() as $legume)
{
if ($legume->getId() === intval($v))
{
$legumesSorted[$k] = $legume;
}
}
}
return $legumesSorted;
}
} }
...@@ -87,7 +87,7 @@ ...@@ -87,7 +87,7 @@
{% elseif is_granted('ROLE_ADMIN') %} {% elseif is_granted('ROLE_ADMIN') %}
Maraîcher Maraîcher
{% else %} {% else %}
Membre Mangeur
{% endif %} {% endif %}
</span> </span>
</a> </a>
......
...@@ -30,7 +30,7 @@ ...@@ -30,7 +30,7 @@
<h3>Expire le {{ offreOne.endedAt|date('d M Y à H:i A') }}</h3> <h3>Expire le {{ offreOne.endedAt|date('d M Y à H:i A') }}</h3>
<div id="offre" class="grid"> <div id="offre" class="grid">
{% for legume in offreOne.offreLegumes %} {% for legume in legumesSorted %}
<div class="item image legume" <div class="item image legume"
data-legume-id="{{ legume.id }}" data-legume-id="{{ legume.id }}"
style="background-image: url('{{ asset('uploads/images/legumes/') }}{{ legume.image }}');"> style="background-image: url('{{ asset('uploads/images/legumes/') }}{{ legume.image }}');">
......
...@@ -334,30 +334,28 @@ span.posted:first-letter { ...@@ -334,30 +334,28 @@ span.posted:first-letter {
text-align: center; text-align: center;
} }
/**/ /*
body#today, * Background photo
body#today_one, */
body[id^='today'],
body#homepage { body#homepage {
background-image: url("img/serre_bg.jpg"); background-image: url("img/serre_bg.jpg");
background-position: center; background-position: center;
background-size: cover; background-size: cover;
background-attachment: fixed; background-attachment: fixed;
} }
body#today .bloc, body[id^='today'] .bloc,
body#today_one .bloc,
body#homepage .bloc { body#homepage .bloc {
background-color: #ffffffad; background-color: #ffffffad;
padding: 1em 2em; padding: 1em 2em;
} }
body#today .bloc.welcome, body[id^='today'] .bloc.welcome,
body#today_one .bloc.welcome,
body#homepage .bloc.welcome { body#homepage .bloc.welcome {
background-color: #000000ad; background-color: #000000ad;
color: white; color: white;
margin-top: 21em; margin-top: 21em;
} }
body#today footer#footer .footer, body[id^='today'] footer#footer .footer,
body#today_one footer#footer .footer,
body#homepage footer#footer .footer { body#homepage footer#footer .footer {
background-color: white; background-color: white;
} }
...@@ -365,15 +363,12 @@ body#homepage footer#footer .footer { ...@@ -365,15 +363,12 @@ body#homepage footer#footer .footer {
/* /*
* La page today * La page today
*/ */
body#today_one { body[id^='today'] #offre.grid {
}
body#today_one #offre.grid {
display: flex; display: flex;
flex-flow: row wrap; flex-flow: row wrap;
margin: 2em -2em; margin: 2em -2em;
} }
#today_one #offre.grid div.item { body[id^='today'] #offre.grid div.item {
flex: 1 0 10%; flex: 1 0 10%;
position: relative; position: relative;
min-width: 175px; min-width: 175px;
...@@ -382,12 +377,12 @@ body#today_one #offre.grid { ...@@ -382,12 +377,12 @@ body#today_one #offre.grid {
background-size: cover; background-size: cover;
background-color: #242424; background-color: #242424;
} }
#today_one #offre.grid div.item:hover { body[id^='today'] #offre.grid div.item:hover {
z-index: 1; z-index: 1;
box-shadow: 0 0 30px 0 black; box-shadow: 0 0 30px 0 black;
} }
#today_one #offre.grid div.item .overlay { body[id^='today'] #offre.grid div.item .overlay {
position: absolute; position: absolute;
top: 0; bottom: 0; left: 0; right: 0; top: 0; bottom: 0; left: 0; right: 0;
padding: 1em; padding: 1em;
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment