Commit 431e0785175105191048bcd3304d4d3712bb3b6f

Authored by Etienne Pallier
2 parents 80e70df8 26369079
Exists in master and in 1 other branch dev

Merge dev branch into master branch (vv3.7.9.52b)

src/Model/Entity/Emprunt.php
1 1 <?php
2 2 namespace App\Model\Entity;
3 3  
  4 +
4 5 use Cake\ORM\Entity;
5 6  
  7 +const DEBUG = true;
  8 +
  9 +
6 10 /**
7 11 * Emprunt Entity.
8 12 *
... ... @@ -49,11 +53,21 @@ class Emprunt extends Entity {
49 53 //return "un";
50 54 $today = new \DateTime('now');
51 55 //echo $today->format('d/m/y');
52   - $date_emprunt = new \DateTime(strtr($this->_properties['date_emprunt'],'/','-')) ; //->format('d/m/y');
  56 + //$date_emprunt = new \DateTime(strtr($this->_properties['date_emprunt'],'/','-')) ; //->format('d/m/y');
  57 + $date_emprunt = new \DateTime(strtr($this->date_emprunt,'/','-')) ; //->format('d/m/y');
  58 +
53 59 // on ajoute 23h59m59s à date_retour pour autoriser le retour jqa la fin de la journée
54   - $date_retour = new \DateTime(strtr($this->_properties['date_retour_emprunt'],'/','-'));
  60 + //$date_retour = new \DateTime(strtr($this->_properties['date_retour_emprunt'],'/','-'));
  61 + $date_retour = new \DateTime(strtr($this->date_retour_emprunt,'/','-'));
  62 + if (DEBUG) {
  63 + debug($today->format('d/m/yy'));
  64 + debug($date_emprunt->format('d/m/yy'));
  65 + debug($date_retour->format('d/m/yy'));
  66 + }
55 67 $date_retour->add(new \DateInterval('PT23H59M59S')); //->format('d/m/y');
  68 + if (DEBUG) debug($date_retour->format('d/m/yy'));
56 69 $delay = $today->diff($date_emprunt)->days;
  70 + if (DEBUG) debug("delay $delay");
57 71 if ($today < $date_emprunt) {
58 72 $status = "A VENIR";
59 73 $delay = "dans " . ($delay==0?1:$delay);
... ... @@ -65,6 +79,7 @@ class Emprunt extends Entity {
65 79 else {
66 80 $status = "TERMINÉ";
67 81 $delay = $today->diff($date_retour)->days;
  82 + if (DEBUG) debug("delay $delay");
68 83 }
69 84 $delay = "depuis " . ($delay==0?1:$delay);
70 85 }
... ...
src/Template/Emprunts/view.ctp
... ... @@ -108,6 +108,7 @@ $status = $entity-&gt;status_from_dates;
108 108 */
109 109  
110 110 // Champ virtuel (calculé) statut
  111 + //debug($status);
111 112 $style_red = 'style="color: red"';
112 113 //$displayElement(__('Statut'), "$status ($delay jour(s))", $status=="EN COURS" ? $style_red : '');
113 114 $displayElement(__('Statut'), "$status[0] ($status[1] jour(s))", $status[0]=="EN COURS" ? $style_red : '');
... ...