Commit faf8170b20b5b5f678085f6ef4b5fdeeac2442fa
1 parent
66b80e1a
Exists in
master
and in
2 other branches
Bugfix et Améliorations Export CSV
Showing
3 changed files
with
50 additions
and
26 deletions
Show diff stats
README.md
... | ... | @@ -53,11 +53,11 @@ Logiciel testé et validé sur les configurations suivantes : |
53 | 53 | |
54 | 54 | VERSION ACTUELLE |
55 | 55 | |
56 | -Date: 04/06/2019 | |
57 | -Version: 2.12.26 | |
56 | +Date: 05/06/2019 | |
57 | +Version: 2.12.27 | |
58 | 58 | Author: EP |
59 | 59 | Commentaire: |
60 | - Bugfix et Améliorations Emprunt | |
60 | + Bugfix et Améliorations Export CSV | |
61 | 61 | |
62 | 62 | IMPORTANT : |
63 | 63 | - Pour connaitre la version actuelle, taper "./VERSION" |
... | ... | @@ -93,6 +93,12 @@ La liste ci-dessous n'est plus à jour, elle est désormais en ligne ici : https |
93 | 93 | |
94 | 94 | ----------------------------------------------------------------------------------------------------------- |
95 | 95 | |
96 | +05/06/2019 Version: 2.12.27 (EP) | |
97 | + Bugfix et Améliorations Export CSV | |
98 | + | |
99 | +04/06/2019 Version: 2.12.26 (EP) | |
100 | + Bugfix et Améliorations Emprunt | |
101 | + | |
96 | 102 | 03/06/2019 Version: 2.12.24-25 (EP) |
97 | 103 | LDAP CACHED v3 |
98 | 104 | ... | ... |
src/Controller/MaterielsController.php
... | ... | @@ -2281,6 +2281,7 @@ class MaterielsController extends AppController |
2281 | 2281 | |
2282 | 2282 | $contain = ['Fournisseurs']; |
2283 | 2283 | |
2284 | + // EXPORT SELECTED materiels only | |
2284 | 2285 | if ($this->request->getData('export') !== null) { |
2285 | 2286 | $this->myDebug("IN EXPORT"); |
2286 | 2287 | $what = $this->request->getData('what'); |
... | ... | @@ -2298,22 +2299,27 @@ class MaterielsController extends AppController |
2298 | 2299 | } |
2299 | 2300 | |
2300 | 2301 | $this->myDebug($selectedMateriels); |
2302 | + // Si la liste de materiels cochés est vide, ne rien faire | |
2303 | + if (empty($selectedMateriels)) { | |
2304 | + if ($what != '' && $what != 'search') return $this->redirect(['action' => 'index', $what]); | |
2305 | + else if ($what == 'search') return $this->redirect('javascript:window.history.go(-3)'); | |
2306 | + else return $this->redirect(['action' => 'index']); | |
2307 | + } | |
2301 | 2308 | |
2309 | + //if (sizeof($selectedMateriels) > 0) { | |
2310 | + $materiels = $this->Materiels->find('all') | |
2311 | + ->where(['Materiels.id' => $selectedMateriels[0]]) | |
2312 | + ->contain($contain); | |
2302 | 2313 | |
2303 | - if (sizeof($selectedMateriels) > 0) { | |
2304 | - | |
2305 | - $materiels = $this->Materiels->find('all') | |
2306 | - ->where(['Materiels.id' => $selectedMateriels[0]]) | |
2307 | - ->contain($contain); | |
2308 | - | |
2309 | - for ($j = 0; $j < sizeof($selectedMateriels); $j ++) { | |
2310 | - $materiels->orWhere([ | |
2311 | - 'Materiels.id' => $selectedMateriels[$j] | |
2312 | - ]); | |
2313 | - } | |
2314 | - | |
2315 | - $this->myDebug($materiels); | |
2314 | + for ($j = 0; $j < sizeof($selectedMateriels); $j ++) { | |
2315 | + $materiels->orWhere([ | |
2316 | + 'Materiels.id' => $selectedMateriels[$j] | |
2317 | + ]); | |
2316 | 2318 | } |
2319 | + //$this->myDebug($materiels); | |
2320 | + //} | |
2321 | + | |
2322 | + // EXPORT ALL materiels | |
2317 | 2323 | } else if ($this->request->getData('exportAll') !== null) { |
2318 | 2324 | $this->myDebug("IN EXPORTALL"); |
2319 | 2325 | |
... | ... | @@ -2335,9 +2341,10 @@ class MaterielsController extends AppController |
2335 | 2341 | 'contain' => $contain |
2336 | 2342 | ]); |
2337 | 2343 | } |
2338 | - | |
2339 | 2344 | $this->myDebug("what is " . $what); |
2340 | 2345 | $this->myDebug("statut is " . $status); |
2346 | + | |
2347 | + // OTHER CASE 3 | |
2341 | 2348 | } else if (isset($this->request->getAttribute('params')['pass'][0])) { |
2342 | 2349 | $this->myDebug("OTHER CASE 3"); |
2343 | 2350 | $what = $this->request->getAttribute('params')['pass'][0]; |
... | ... | @@ -2345,6 +2352,8 @@ class MaterielsController extends AppController |
2345 | 2352 | if ($what == 'search') { |
2346 | 2353 | $materiels = $this->request->getSession()->read("result"); |
2347 | 2354 | } |
2355 | + | |
2356 | + // OTHER CASE 4 | |
2348 | 2357 | } else { |
2349 | 2358 | $this->myDebug("OTHER CASE 4"); |
2350 | 2359 | $materiels = $this->Materiels->find('all', [ |
... | ... | @@ -2355,8 +2364,14 @@ class MaterielsController extends AppController |
2355 | 2364 | ]); |
2356 | 2365 | } |
2357 | 2366 | |
2358 | - $this->myDebug("Nb matos = " . count($materiels)); | |
2359 | - $this->myDebug($materiels, true); | |
2367 | + | |
2368 | + // NOW, CREATE THE CSV file from $materiels | |
2369 | + | |
2370 | + $this->myDebug("Nb matos = " .$materiels->count()); | |
2371 | + //$this->myDebug("Nb matos = " . count($materiels)); | |
2372 | + | |
2373 | + //$this->myDebug($materiels, true); | |
2374 | + $this->myDebug($materiels); | |
2360 | 2375 | |
2361 | 2376 | ini_set('max_execution_time', 600); |
2362 | 2377 | |
... | ... | @@ -2413,9 +2428,12 @@ class MaterielsController extends AppController |
2413 | 2428 | "Email responsable" |
2414 | 2429 | ]; |
2415 | 2430 | |
2431 | + // 1) Write HEADER row | |
2416 | 2432 | fputcsv($csv_file, $header_row, ';'); |
2417 | 2433 | |
2434 | + // 2) Write DATA rows, 1 by 1 | |
2418 | 2435 | foreach ($materiels as $result) { |
2436 | + $this->myDebug($result); | |
2419 | 2437 | $row = [ |
2420 | 2438 | //utf8_encode($result->id), |
2421 | 2439 | $result->designation |
... | ... | @@ -2443,7 +2461,7 @@ class MaterielsController extends AppController |
2443 | 2461 | array_push($row, $result->numero_laboratoire); |
2444 | 2462 | array_push($row, $result->description); |
2445 | 2463 | |
2446 | - if ($organismes[$result->organisme_id] !== null) { | |
2464 | + if ( !is_null($result->organisme_id) && !is_null($organismes[$result->organisme_id] ) ) { | |
2447 | 2465 | array_push($row, $organismes[$result->organisme_id]); |
2448 | 2466 | } else { |
2449 | 2467 | array_push($row, ""); | ... | ... |
src/Template/Materiels/view.ctp
... | ... | @@ -539,10 +539,10 @@ $bStyle = 'margin:0'; |
539 | 539 | <tr> |
540 | 540 | <th class="actions"><?=__('')?></th> |
541 | 541 | <th><?=__('N°')?></th> |
542 | - <th><?=__('Type d\'intervention')?></th> | |
542 | + <th><?=__('Type')?></th> | |
543 | 543 | <th><?=__('Intitulé')?></th> |
544 | - <th><?=__('Date debut / Frequence')?></th> | |
545 | - <th><?=__('Date fin / Repetition')?></th> | |
544 | + <th><?=__('Date début / Fréquence')?></th> | |
545 | + <th><?=__('Date fin / Répétition')?></th> | |
546 | 546 | <th><?=__('Statut')?></th> |
547 | 547 | </tr> |
548 | 548 | <?php foreach ($materiel->suivis as $suivi) :?> |
... | ... | @@ -621,10 +621,10 @@ $bStyle = 'margin:0'; |
621 | 621 | <th class="actions"><?=__('')?></th> |
622 | 622 | <th><?=__('N°')?></th> |
623 | 623 | <th><?=__('Emprunteur')?></th> |
624 | - <th><?=__('Type d\'Emprunt')?></th> | |
624 | + <th><?=__("Type")?></th> | |
625 | 625 | <th><?=__('Lieu')?></th> |
626 | - <th><?=__('Date de l\'emprunt')?></th> | |
627 | - <th><?=__('Date de retour')?></th> | |
626 | + <th><?=__('Date emprunt')?></th> | |
627 | + <th><?=__('Date retour')?></th> | |
628 | 628 | </tr> |
629 | 629 | <?php |
630 | 630 | ... | ... |