Commit b65c2ed76f6b44f114a21b3536df54531d75c0b6
1 parent
c4d53d09
Exists in
master
and in
3 other branches
bugfix sur saisie date
Showing
4 changed files
with
23 additions
and
7 deletions
Show diff stats
README-LABINVENT.md
src/Model/Table/MaterielsTable.php
... | ... | @@ -101,22 +101,32 @@ class MaterielsTable extends AppTable |
101 | 101 | public function validationDefault(Validator $validator) |
102 | 102 | { |
103 | 103 | $dateValide = function ($entity) { |
104 | + // $entity format is like '02/01/2018' | |
105 | + //debug($entity); | |
106 | + | |
104 | 107 | // (1) La date saisie doit contenir 2 tirets (dd-mm-yy) : |
105 | 108 | $components1 = explode('-', $entity); |
106 | 109 | $components2 = explode('/', $entity); |
107 | 110 | if ( count($components1)!=3 && count($components2)!=3 ) return false; |
108 | 111 | $entity = str_replace('/', '-', $entity); |
109 | 112 | $components = explode('-', $entity); |
113 | + //debug($components); | |
110 | 114 | if ( count($components)!=3 ) return false; |
111 | 115 | // (2) La date saisie doit etre JJ-MM-AA ou JJ-MM-AAAA : |
112 | 116 | // day |
117 | + /* | |
118 | + debug(strlen($components[0])); | |
119 | + debug(strlen($components[1])); | |
120 | + debug(strlen($components[2])); | |
121 | + */ | |
113 | 122 | if (strlen($components[0]) != 2) return false; |
114 | 123 | // month |
115 | 124 | if (strlen($components[1]) != 2) return false; |
116 | 125 | // year |
117 | - if (strlen($components[2]) != 2 && strlen($components[2]) != 4) return false; | |
126 | + //if (strlen($components[2]) != 2 && strlen($components[2]) != 4) { | |
127 | + if (strlen($components[2]) != 4) return false; | |
118 | 128 | // (2) L'année ne doit pas être 1970 (c'est un bug) |
119 | - //TODO: | |
129 | + //?? TODO: | |
120 | 130 | // (3) La date saisie ne doit pas être dans le futur (elle doit etre < ou = today) : |
121 | 131 | $time = Time::now(); // On récupère la date et l'heure actuelles |
122 | 132 | $today = (new date("$time->year-$time->month-$time->day"))->format('Ymd'); // On extrait la date on la formate en un format comparable de type 20171231 |
... | ... | @@ -126,6 +136,9 @@ class MaterielsTable extends AppTable |
126 | 136 | return false; |
127 | 137 | } |
128 | 138 | $dateEntity = (new date("$timeEntity->year-$timeEntity->month-$timeEntity->day"))->format('Ymd'); |
139 | + //debug($today); | |
140 | + //debug($dateEntity); | |
141 | + //exit; | |
129 | 142 | //return ($today >= $dateEntity); |
130 | 143 | return ($dateEntity <= $today); |
131 | 144 | }; |
... | ... | @@ -272,9 +285,10 @@ class MaterielsTable extends AppTable |
272 | 285 | $configuration = TableRegistry::get('Configurations')->find() |
273 | 286 | ->where([ |
274 | 287 | 'id =' => 1 |
275 | - ]) | |
276 | - ->first(); | |
288 | + ])->first(); | |
289 | + | |
277 | 290 | $checkAtLeastOneChecked = function ($entity) { |
291 | + //debug($entity); exit; | |
278 | 292 | return ($entity->materiel_administratif || $entity->materiel_technique); |
279 | 293 | }; |
280 | 294 | // return if price >= $configuration->prix_inventaire_administratif € then must be checked as "administratif" | ... | ... |
src/Template/Layout/default.ctp
... | ... | @@ -119,7 +119,7 @@ $cakeDescription = 'Labinvent 2'; |
119 | 119 | </i></td> |
120 | 120 | <td id="version"> |
121 | 121 | <!-- VERSION M.m.f.b (version (M)ajeure, version (m)ineure, numero de nouvelle (f)onctionnalite, numero de (b)ugfix) --> |
122 | - <font color="black">VERSION 2.8.0.8 (29/01/2018)</font> <br /> <font | |
122 | + <font color="black">VERSION 2.8.0.9 (29/01/2018)</font> <br /> <font | |
123 | 123 | color="black"><a |
124 | 124 | href="<?php |
125 | 125 | ... | ... |
src/Template/Materiels/edit.ctp
... | ... | @@ -183,6 +183,7 @@ if ($IS_VALIDATED && $materiel->numero_serie) |
183 | 183 | echo $this->Form->input('date_acquisition', [ |
184 | 184 | 'type' => 'text', |
185 | 185 | 'label' => 'Date de la commande', |
186 | + 'dateFormat' => 'dd-MM-yyyy', | |
186 | 187 | 'class' => 'datepicker', |
187 | 188 | 'placeholder' => 'Cliquez pour sélectionner une date', |
188 | 189 | 'disabled' => $isReadonlyField('date_acquisition', $myReadonlyFields) |
... | ... | @@ -190,6 +191,7 @@ if ($IS_VALIDATED && $materiel->numero_serie) |
190 | 191 | echo $this->Form->input('date_reception', [ |
191 | 192 | 'type' => 'text', |
192 | 193 | 'label' => 'Date de réception', |
194 | + 'dateFormat' => 'dd-MM-yyyy', | |
193 | 195 | 'class' => 'datepicker', |
194 | 196 | 'placeholder' => 'A éditer lors de la réception uniquement.', |
195 | 197 | 'disabled' => $isReadonlyField('date_reception', $myReadonlyFields), |
... | ... | @@ -395,7 +397,7 @@ echo $this->element('menu_form', [ |
395 | 397 | <?=$this->Html->script('jquery-1.8.12')?> |
396 | 398 | <?=$this->Html->script('script')?> |
397 | 399 | <?=$this->Html->script('DatepickerConfig')?> |
398 | -<?//$this->Html->script('Verifications_dates_materiels.js')?> | |
400 | +<?php //=$this->Html->script('Verifications_dates_materiels.js') ?> | |
399 | 401 | |
400 | 402 | <script type="text/javascript"> |
401 | 403 | ... | ... |