Commit 26369079480505eb00692931cb34985306b86e37

Authored by Etienne Pallier
1 parent a259e5c9
Exists in master and in 1 other branch dev

debug

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 : '');
... ...