Browse Source

Merge branch 'develop' into vuejs

François Drouhard 2 years ago
parent
commit
2e35281f79

+ 13 - 1
src/Service/EnSalle.php

@@ -14,8 +14,20 @@ class EnSalle implements RuntimeExtensionInterface
             return false;
         }
         $interval = new \DateInterval('P20D');
-        $dateLimite= $dateSortie->add($interval);
+        $dateLimite = $dateSortie->add($interval);
         $date = new \DateTime('now');
         return ( $date <= $dateLimite && $date >= $dateSortie);
     }
+
+    public function bientotEnSalle(?\DateTimeImmutable $dateSortie): bool
+    {
+        if (!$dateSortie) {
+            return false;
+        }
+        $interval = new \DateInterval('P15D');
+        $interval->invert = 1;
+        $dateLimite = $dateSortie->add($interval);
+        $date = new \DateTime('now');
+        return ( $date >= $dateLimite && $date < $dateSortie );
+    }
 }

+ 3 - 2
src/Twig/TwigEnSalle.php

@@ -12,12 +12,13 @@ class TwigEnSalle extends AbstractExtension
     {
         return array(
             new TwigFunction('estEnSalle', array(EnSalle::class, 'enSalle')),
+            new TwigFunction('bientotEnSalle', array(EnSalle::class, 'bientotEnSalle'))
         );
     }
 
-    public function getName() : string
+    /*public function getName() : string
     {
         return 'estEnSalle';
-    }
+    }*/
 
 }

+ 2 - 1
templates/videotheque/liste_tableaux.html.twig

@@ -83,7 +83,8 @@
 						<a href="{{ path('videotheque_voirfilm', {'id': film.id}) }}"><span data-bs-toggle="tooltip" data-placement="right" title="{{ film.information }}">{{ film.titre }}</span></a>
 						{% if film.new %}<span class="badge bg-success">New</span>{% endif %}
 						{% if estEnSalle(film.dateSortie) %}<span class="badge text-bg-success">En salle</span>{% endif %}
-						{% if film.nbComs %}<span class="badge bg-info rounded-pill" data-bs-toggle="tooltip" title="{{ film.nbComs }} commentaire(s)">{{ film.nbComs }}</span>{% endif %}
+						{% if bientotEnSalle(film.dateSortie) %}<span class="badge text-bg-info">Bientot</span>{% endif %}
+					{% if film.nbComs %}<span class="badge text-bg-warning rounded-pill" data-bs-toggle="tooltip" title="{{ film.nbComs }} commentaire(s)">{{ film.nbComs }}</span>{% endif %}
 
 					</td>
 					<td>

+ 2 - 1
templates/videotheque/liste_vignettes.html.twig

@@ -120,7 +120,8 @@
 						<div class="">
 							{% if film.new %}<span class="badge text-bg-secondary">New</span>{% endif %}
 							{% if estEnSalle(film.dateSortie) %}<span class="badge text-bg-success">En salle</span>{% endif %}
-						</div>
+							{% if bientotEnSalle(film.dateSortie) %}<span class="badge text-bg-info">Bientot</span>{% endif %}
+					</div>
 					</div>
 					<div class="">
 					{%  if film.authered is defined %}

+ 5 - 0
templates/videotheque/voirfilm.html.twig

@@ -65,6 +65,11 @@
         <i class="fa fa-film"></i> EN SALLE
     </div>
     {% endif %}
+    {% if bientotEnSalle(film.dateSortie) %}
+    <div class="text-center alert alert-info" role="alert">
+        <i class="fa fa-clock-o"></i> BIENTOT EN SALLE
+    </div>
+    {% endif %}
   
     <div class="row">
         <div class="col">