Commit 94e21fe87f3efc22e4889602821601b04906df04
1 parent
cccac752
Exists in
master
and in
3 other branches
Version: 2.4.6.9
Date garantie (materiel) + bugfixes calcul date (suivi) Demande (terminé) : https://projects.irap.omp.eu/issues/3804 Version majeure en cours (2.4): https://projects.irap.omp.eu/versions/107 ROADMAP: https://projects.irap.omp.eu/projects/labinvent/roadmap
Showing
8 changed files
with
181 additions
and
44 deletions
Show diff stats
README-LABINVENT.md
... | ... | @@ -51,9 +51,11 @@ Logiciel testé et validé sur les configurations suivantes : |
51 | 51 | VERSION ACTUELLE |
52 | 52 | |
53 | 53 | Date: 23/06/2016 |
54 | -Version: 2.4.6.8 | |
54 | +Version: 2.4.6.9 | |
55 | 55 | |
56 | -Bugfixes calcul frequence (suivi) | |
56 | +Date garantie (materiel) + bugfixes calcul date (suivi) | |
57 | + | |
58 | +Demande (terminé) : https://projects.irap.omp.eu/issues/3804 | |
57 | 59 | |
58 | 60 | Version majeure en cours (2.4): https://projects.irap.omp.eu/versions/107 |
59 | 61 | ... | ... |
src/Controller/MaterielsController.php
... | ... | @@ -1265,5 +1265,33 @@ class MaterielsController extends AppController |
1265 | 1265 | |
1266 | 1266 | } |
1267 | 1267 | |
1268 | - | |
1268 | + // called from Javascript (Ajax) | |
1269 | + public function getDateGarantie($dateORjour, $dureeORmois, $uniteORannee, $duree = null, $unite = null) { | |
1270 | + | |
1271 | + if($duree != null && $unite != null) { | |
1272 | + $date = $dateORjour.'-'.$dureeORmois.'-'.$uniteORannee; | |
1273 | + } else { | |
1274 | + $date = $dateORjour; | |
1275 | + $duree = $dureeORmois; | |
1276 | + $unite = $uniteORannee; | |
1277 | + } | |
1278 | + | |
1279 | + $date_next = date_create_from_format('d-m-Y', $date); | |
1280 | + | |
1281 | + switch($unite) { | |
1282 | + case "Mois": | |
1283 | + date_add($date_next, date_interval_create_from_date_string($duree.' months')); | |
1284 | + break; | |
1285 | + case "Ans": | |
1286 | + date_add($date_next, date_interval_create_from_date_string($duree.' years')); | |
1287 | + break; | |
1288 | + } | |
1289 | + | |
1290 | + $this->set ('date', date_format($date_next, 'd-m-Y')); | |
1291 | + | |
1292 | + | |
1293 | + $this->viewBuilder()->layout = 'ajax'; | |
1294 | + } | |
1295 | + | |
1296 | + | |
1269 | 1297 | } | ... | ... |
src/Controller/SuivisController.php
... | ... | @@ -257,50 +257,34 @@ class SuivisController extends AppController |
257 | 257 | } |
258 | 258 | |
259 | 259 | // called from Javascript (Ajax) |
260 | - public function getNextDate($dateORjour, $frequenceORmois, $typeFrequenceORannee, $frequence, $typeFrequence) { | |
260 | + public function getNextDate($dateORjour, $frequenceORmois, $typeFrequenceORannee, $frequence = null, $typeFrequence = null) { | |
261 | 261 | |
262 | - if(isset($frequence) && isset($typeFrequence)) { | |
262 | + if($frequence != null && $typeFrequence != null) { | |
263 | 263 | $date = $dateORjour.'-'.$frequenceORmois.'-'.$typeFrequenceORannee; |
264 | - | |
265 | - $date_next = date_create_from_format('d-m-Y', $date); | |
266 | - | |
267 | - switch($typeFrequence) { | |
268 | - case "Jours": | |
269 | - date_add($date_next, date_interval_create_from_date_string($frequence.' days')); | |
270 | - break; | |
271 | - case "Semaines": | |
272 | - date_add($date_next, date_interval_create_from_date_string((7*$frequence).' days')); | |
273 | - break; | |
274 | - case "Mois": | |
275 | - date_add($date_next, date_interval_create_from_date_string($frequence.' months')); | |
276 | - break; | |
277 | - case "Ans": | |
278 | - date_add($date_next, date_interval_create_from_date_string($frequence.' years')); | |
279 | - break; | |
280 | - } | |
281 | 264 | } else { |
282 | 265 | $date = $dateORjour; |
283 | - | |
284 | - $date_next = date_create_from_format('d-m-Y', $date); | |
285 | - | |
286 | - switch($typeFrequenceORannee) { | |
287 | - case "Jours": | |
288 | - date_add($date_next, date_interval_create_from_date_string($frequenceORmois.' days')); | |
289 | - break; | |
290 | - case "Semaines": | |
291 | - date_add($date_next, date_interval_create_from_date_string((7*$frequenceORmois).' days')); | |
292 | - break; | |
293 | - case "Mois": | |
294 | - date_add($date_next, date_interval_create_from_date_string($frequenceORmois.' months')); | |
295 | - break; | |
296 | - case "Ans": | |
297 | - date_add($date_next, date_interval_create_from_date_string($frequenceORmois.' years')); | |
298 | - break; | |
299 | - } | |
266 | + $frequence = $frequenceORmois; | |
267 | + $typeFrequence = $typeFrequenceORannee; | |
300 | 268 | } |
301 | 269 | |
270 | + $date_next = date_create_from_format('d-m-Y', $date); | |
271 | + | |
272 | + switch($typeFrequence) { | |
273 | + case "Jours": | |
274 | + date_add($date_next, date_interval_create_from_date_string($frequence.' days')); | |
275 | + break; | |
276 | + case "Semaines": | |
277 | + date_add($date_next, date_interval_create_from_date_string((7*$frequence).' days')); | |
278 | + break; | |
279 | + case "Mois": | |
280 | + date_add($date_next, date_interval_create_from_date_string($frequence.' months')); | |
281 | + break; | |
282 | + case "Ans": | |
283 | + date_add($date_next, date_interval_create_from_date_string($frequence.' years')); | |
284 | + break; | |
285 | + } | |
302 | 286 | |
303 | - $this->set ('date', date_format($date_next, 'd-m-Y')); | |
287 | + $this->set ('date', date_format($date_next, 'd-m-Y')); | |
304 | 288 | |
305 | 289 | |
306 | 290 | $this->viewBuilder()->layout = 'ajax'; | ... | ... |
src/Template/Layout/default.ctp
... | ... | @@ -94,7 +94,7 @@ $cakeDescription = 'Labinvent 2'; |
94 | 94 | </i></td> |
95 | 95 | <td id="version"> |
96 | 96 | <!-- VERSION M.m.f.b (version (M)ajeure, version (m)ineure, numero de nouvelle (f)onctionnalite, numero de (b)ugfix) --> |
97 | - <font color="black">VERSION 2.4.6.8 (23/06/2016)</font> | |
97 | + <font color="black">VERSION 2.4.6.9 (23/06/2016)</font> | |
98 | 98 | </td> |
99 | 99 | </tr> |
100 | 100 | </table> | ... | ... |
src/Template/Materiels/add.ctp
... | ... | @@ -80,6 +80,33 @@ else { |
80 | 80 | echo $this->Form->input('date_acquisition', ['type' => 'text', 'label' => 'Date de la commande', 'class' => 'datepicker', 'placeholder' => 'Cliquez pour sélectionner une date', 'default' => $Date_acquisition]); |
81 | 81 | echo $this->Form->input('date_reception', ['type' => 'text', 'label' => 'Date de réception', 'class' => 'datepicker', 'placeholder' => 'A éditer lors de la réception uniquement.', 'empty' => true, 'default' => $Date_reception]); |
82 | 82 | |
83 | + | |
84 | + | |
85 | + echo '<table id="tableAlignementFrequence"><tr><td>'; | |
86 | + echo $this->Form->input('duree_garantie', [ | |
87 | + 'type' => 'text', | |
88 | + 'label' => 'Durée garantie', | |
89 | + 'style' => 'width: 100px', | |
90 | + 'templates' => ['inputContainer' => '<div class="A">{{content}}</div>'], | |
91 | + 'placeholder' => '' | |
92 | + ]); | |
93 | + echo '</td><td>'; | |
94 | + echo $this->Form->input ('unite_duree_garantie', [ | |
95 | + 'label' => false, | |
96 | + 'templates' => ['inputContainer' => '<div class="typeFrequence">{{content}}</div>'], | |
97 | + 'options' => ['Mois' => 'Mois', 'Ans' => 'Ans'], | |
98 | + 'default' => 'Ans' | |
99 | + ]); | |
100 | + echo '</td></tr></table>'; | |
101 | + echo $this->Form->input('date_fin_garantie', [ | |
102 | + 'type' => 'text', | |
103 | + 'label' => 'Date fin de garantie', | |
104 | + 'placeholder' => 'Cliquez pour selectionner une date', | |
105 | + 'class' => 'datepicker', | |
106 | + 'default' => NULL | |
107 | + ]); | |
108 | + | |
109 | + | |
83 | 110 | echo $this->Form->input('numero_serie', ['label' => 'Numéro de série']); |
84 | 111 | echo $this->Form->input('groupes_thematique_id', ['label' => $configuration->nom_groupe_thematique, 'options' => $groupesThematiques, 'default' => $Groupes_thematique_id]); |
85 | 112 | echo $this->Form->input('groupes_metier_id', ['label' => $configuration->nom_groupe_metier, 'options' => $groupesMetiers, 'default' => $Groupes_metier_id]); |
... | ... | @@ -218,4 +245,35 @@ $(document).ready(function () { |
218 | 245 | }); |
219 | 246 | |
220 | 247 | |
248 | + /** | |
249 | + * Event calcul date fin de garantie | |
250 | + */ | |
251 | + $(document).ready(function () { | |
252 | + $("#duree-garantie").bind("change", function (event) { | |
253 | + if($("#date-reception").val() != "" && $("#duree-garantie").val() != "") { | |
254 | + var url = document.URL; | |
255 | + var reg=new RegExp("(materiels).*$","g"); | |
256 | + var dateUrl = url.replace(reg, "Materiels/getDateGarantie/"); | |
257 | + $.ajax({ | |
258 | + url: dateUrl + $("#date-reception").val() + "/" + $("#duree-garantie").val() + "/" + $("#unite-duree-garantie").val() | |
259 | + }).done(function(data) { | |
260 | + $("#date-fin-garantie").val(data) | |
261 | + }); | |
262 | + } | |
263 | + }); | |
264 | + $("#unite-duree-garantie").bind("change", function (event) { | |
265 | + if($("#date-reception").val() != "" && $("#duree-garantie").val() != "") { | |
266 | + var url = document.URL; | |
267 | + var reg=new RegExp("(materiels).*$","g"); | |
268 | + var dateUrl = url.replace(reg, "Materiels/getDateGarantie/"); | |
269 | + $.ajax({ | |
270 | + url: dateUrl + $("#date-reception").val() + "/" + $("#duree-garantie").val() + "/" + $("#unite-duree-garantie").val() | |
271 | + }).done(function(data) { | |
272 | + $("#date-fin-garantie").val(data) | |
273 | + }); | |
274 | + } | |
275 | + }); | |
276 | + }); | |
277 | + | |
278 | + | |
221 | 279 | </script> | ... | ... |
src/Template/Materiels/edit.ctp
... | ... | @@ -21,7 +21,6 @@ if ($IS_VALIDATED) |
21 | 21 | 'materiel_technique', |
22 | 22 | 'site_id', |
23 | 23 | 'date_acquisition', |
24 | - 'date_reception', | |
25 | 24 | 'organisme_id', |
26 | 25 | 'prix_ht' |
27 | 26 | ), |
... | ... | @@ -134,6 +133,32 @@ if ($IS_VALIDATED) |
134 | 133 | 'disabled' => $isReadonlyField('date_reception', $myReadonlyFields), |
135 | 134 | 'empty' => true]); |
136 | 135 | |
136 | + | |
137 | + echo '<table id="tableAlignementFrequence"><tr><td>'; | |
138 | + echo $this->Form->input('duree_garantie', [ | |
139 | + 'type' => 'text', | |
140 | + 'style' => 'width: 100px', | |
141 | + 'label' => 'Durée garantie', | |
142 | + 'templates' => ['inputContainer' => '<div class="A">{{content}}</div>'], | |
143 | + 'placeholder' => '' | |
144 | + ]); | |
145 | + echo '</td><td>'; | |
146 | + echo $this->Form->input ('unite_duree_garantie', [ | |
147 | + 'label' => false, | |
148 | + 'templates' => ['inputContainer' => '<div class="typeFrequence">{{content}}</div>'], | |
149 | + 'options' => ['Mois' => 'Mois', 'Ans' => 'Ans'], | |
150 | + 'default' => 'Ans' | |
151 | + ]); | |
152 | + echo '</td></tr></table>'; | |
153 | + echo $this->Form->input('date_fin_garantie', [ | |
154 | + 'type' => 'text', | |
155 | + 'label' => 'Date fin de garantie', | |
156 | + 'placeholder' => 'Cliquez pour selectionner une date', | |
157 | + 'class' => 'datepicker', | |
158 | + 'default' => NULL | |
159 | + ]); | |
160 | + | |
161 | + | |
137 | 162 | if(in_array($role, ['Administration Plus', 'Super Administrateur'])) { |
138 | 163 | echo $this->Form->input('status', ['label' => 'Statut', 'options' => [ |
139 | 164 | 'CREATED' => 'CREATED', |
... | ... | @@ -336,5 +361,37 @@ $(document).ready(function () { |
336 | 361 | }); |
337 | 362 | }); |
338 | 363 | }); |
339 | - | |
364 | + | |
365 | + | |
366 | + /** | |
367 | + * Event calcul date fin de garantie | |
368 | + */ | |
369 | + $(document).ready(function () { | |
370 | + $("#duree-garantie").bind("change", function (event) { | |
371 | + if($("#date-reception").val() != "" && $("#duree-garantie").val() != "") { | |
372 | + var url = document.URL; | |
373 | + var reg=new RegExp("(materiels).*$","g"); | |
374 | + var dateUrl = url.replace(reg, "Materiels/getDateGarantie/"); | |
375 | + $.ajax({ | |
376 | + url: dateUrl + $("#date-reception").val() + "/" + $("#duree-garantie").val() + "/" + $("#unite-duree-garantie").val() | |
377 | + }).done(function(data) { | |
378 | + $("#date-fin-garantie").val(data) | |
379 | + }); | |
380 | + } | |
381 | + }); | |
382 | + $("#unite-duree-garantie").bind("change", function (event) { | |
383 | + if($("#date-reception").val() != "" && $("#duree-garantie").val() != "") { | |
384 | + var url = document.URL; | |
385 | + var reg=new RegExp("(materiels).*$","g"); | |
386 | + var dateUrl = url.replace(reg, "Materiels/getDateGarantie/"); | |
387 | + $.ajax({ | |
388 | + url: dateUrl + $("#date-reception").val() + "/" + $("#duree-garantie").val() + "/" + $("#unite-duree-garantie").val() | |
389 | + }).done(function(data) { | |
390 | + $("#date-fin-garantie").val(data) | |
391 | + }); | |
392 | + } | |
393 | + }); | |
394 | + }); | |
395 | + | |
396 | + | |
340 | 397 | </script> | ... | ... |
src/Template/Materiels/view.ctp
... | ... | @@ -190,7 +190,7 @@ |
190 | 190 | $displayElement(__('Domaine'), $materiel->has('sur_category') ? h($materiel->sur_category->nom) : ''); |
191 | 191 | $displayElement(__('Catégorie'), $materiel->has('category') ? h($materiel->category->nom) : ''); |
192 | 192 | $displayElement(__('Sous-Catégorie'), $materiel->has('sous_category') ? h($materiel->sous_category->nom) : ''); |
193 | - $displayElement(__('Date de reception'), h($materiel->date_reception)); | |
193 | + | |
194 | 194 | if(h($materiel->etiquette) == 0) { |
195 | 195 | $etiq="Non"; |
196 | 196 | }else { |
... | ... | @@ -200,6 +200,11 @@ |
200 | 200 | $displayElement(__($configuration->nom_groupe_thematique), $materiel->has('groupes_thematique') ? $this->Html->link($materiel->groupes_thematique->nom, ['controller' => 'GroupesThematiques', 'action' => 'view', $materiel->groupes_thematique->id]) : ''); |
201 | 201 | $displayElement(__($configuration->nom_groupe_metier), $materiel->has('groupes_metier') ? $this->Html->link($materiel->groupes_metier->nom, ['controller' => 'GroupesMetiers', 'action' => 'view', $materiel->groupes_metier->id]) : ''); |
202 | 202 | $displayElement(__('Date d\'achat'), h($materiel->date_acquisition)); |
203 | + | |
204 | + $displayElement(__('Date de reception'), h($materiel->date_reception)); | |
205 | + $displayElement(__('Duree garantie'), h($materiel->duree_garantie).' '.h($materiel->unite_duree_garantie)); | |
206 | + $displayElement(__('Date fin de garantie'), h($materiel->date_fin_garantie)); | |
207 | + | |
203 | 208 | $displayElement(__('Statut'), h($materiel->status)); |
204 | 209 | if($materiel->status == 'ARCHIVED') { |
205 | 210 | $displayElement(__('Date d\'archivage'), h($materiel->date_archivage)); | ... | ... |