| Line 1... |
Line 1... |
| 1 |
<?php
|
1 |
<?php
|
| 2 |
|
- |
|
| 3 |
/**
|
- |
|
| 4 |
* @category PHP
|
- |
|
| 5 |
* @package jrest
|
- |
|
| 6 |
* @author Raphaël Droz <raphael@tela-botania.org>
|
- |
|
| 7 |
* @copyright 2013 Tela-Botanica
|
2 |
// declare(encoding='UTF-8');
|
| 8 |
* @license http://www.cecill.info/licences/Licence_CeCILL_V2-fr.txt Licence CECILL
|
- |
|
| 9 |
* @license GPL v3 <http://www.gnu.org/licenses/gpl.txt>
|
- |
|
| 10 |
*/
|
- |
|
| 11 |
|
- |
|
| 12 |
/**
|
3 |
/**
|
| 13 |
* Service d'export de données d'observation du CEL au format XLS
|
4 |
* Service d'export de données d'observation du CEL au format XLS.
|
| 14 |
*
|
5 |
*
|
| 15 |
* Format du service :
|
6 |
* Format du service :
|
| 16 |
* POST /ExportXLS
|
7 |
* POST /ExportXLS
|
| 17 |
* POST /ExportXLS/<Utilisateur>
|
8 |
* POST /ExportXLS/<Utilisateur>
|
| 18 |
* TODO: GET /ExportXLS/<Utilisateur> [ sans "range" ? ]
|
9 |
* TODO: GET /ExportXLS/<Utilisateur> [ sans "range" ? ]
|
| 19 |
*
|
10 |
*
|
| 20 |
* Les données POST acceptées sont:
|
11 |
* Les données POST acceptées sont:
|
| 21 |
* range (obligatoire): un range d'id_observation sous la forme d'entier ou d'intervalles d'entiers
|
12 |
* range (obligatoire): un range d'id_observation sous la forme d'entier ou d'intervalles d'entiers
|
| 22 |
* séparés par des virgules ou bien '*' (pour toutes)
|
13 |
* séparés par des virgules ou bien '*' (pour toutes)
|
| 23 |
* TODO: limit
|
14 |
* TODO: limit
|
| 24 |
* TODO: départ
|
15 |
* TODO: départ
|
| 25 |
* TODO: sets (ou colonnes, ou extended)
|
16 |
* TODO: sets (ou colonnes, ou extended)
|
| 26 |
* TODO: + les critères supportés par fabriquerSousRequeteRecherche()
|
17 |
* TODO: + les critères supportés par fabriquerSousRequeteRecherche()
|
| 27 |
*
|
18 |
*
|
| 28 |
* Si <Utilisateur> est fourni, celui-ci doit être authentifié
|
19 |
* Si <Utilisateur> est fourni, celui-ci doit être authentifié
|
| 29 |
* TODO: export des données public et non-sensible d'un utilisateur
|
20 |
* TODO: export des données public et non-sensible d'un utilisateur
|
| 30 |
*
|
21 |
*
|
| 31 |
* Si <Utilisateur> est fourni, le observations seront le résultat de l'intersection des 2 contraintes
|
22 |
* Si <Utilisateur> est fourni, le observations seront le résultat de l'intersection des 2 contraintes
|
| 32 |
*
|
23 |
*
|
| - |
|
24 |
* @internal Mininum PHP version : 5.2
|
| - |
|
25 |
* @category CEL
|
| - |
|
26 |
* @package Services
|
| - |
|
27 |
* @subpackage Observations
|
| - |
|
28 |
* @version 0.1
|
| - |
|
29 |
* @author Mathias CHOUET <mathias@tela-botanica.org>
|
| - |
|
30 |
* @author Raphaël Droz <raphael@tela-botania.org>
|
| - |
|
31 |
* @author Jean-Pascal MILCENT <jpm@tela-botanica.org>
|
| - |
|
32 |
* @author Aurelien PERONNET <aurelien@tela-botanica.org>
|
| - |
|
33 |
* @license GPL v3 <http://www.gnu.org/licenses/gpl.txt>
|
| - |
|
34 |
* @license CECILL v2 <http://www.cecill.info/licences/Licence_CeCILL_V2-en.txt>
|
| - |
|
35 |
* @copyright 1999-2014 Tela Botanica <accueil@tela-botanica.org>
|
| 33 |
*/
|
36 |
*/
|
| 34 |
set_include_path(get_include_path() . PATH_SEPARATOR . dirname(dirname(realpath(__FILE__))) . '/lib');
|
37 |
set_include_path(get_include_path() . PATH_SEPARATOR . dirname(dirname(realpath(__FILE__))) . '/lib');
|
| 35 |
// TERM
|
- |
|
| 36 |
ini_set('html_errors', 0);
|
38 |
ini_set('html_errors', 0);
|
| 37 |
ini_set('xdebug.cli_color', 2);
|
39 |
ini_set('xdebug.cli_color', 2);
|
| 38 |
require_once('lib/PHPExcel/Classes/PHPExcel.php');
|
40 |
require_once 'lib/PHPExcel/Classes/PHPExcel.php';
|
| 39 |
require_once('lib/FormateurGroupeColonne.php');
|
41 |
require_once 'lib/FormateurGroupeColonne.php';
|
| Line 40... |
Line 42... |
| 40 |
|
42 |
|
| Line 41... |
Line 43... |
| 41 |
class ExportXLS extends Cel {
|
43 |
class ExportXLS extends Cel {
|
| 42 |
|
44 |
|
| 43 |
private $id_utilisateur = NULL;
|
- |
|
| 44 |
private $parametres_defaut = array("range" => "*",
|
45 |
private $id_utilisateur = NULL;
|
| 45 |
"format" => "CSV");
|
46 |
private $parametres_defaut = array('range' => '*', 'format' => 'CSV');
|
| 46 |
|
47 |
|
| 47 |
private $filtres_autorises = array(
|
48 |
private $filtres_autorises = array(
|
| 48 |
'id_utilisateur' => 'id_utilisateur',
|
49 |
'id_utilisateur' => 'id_utilisateur',
|
| 49 |
'utilisateur' => 'courriel_utilisateur',
|
50 |
'utilisateur' => 'courriel_utilisateur',
|
| 50 |
'commune' => 'zone_geo',
|
51 |
'commune' => 'zone_geo',
|
| 51 |
'dept' => 'departement',
|
52 |
'dept' => 'departement',
|
| 52 |
'projet' => 'mots_cles',
|
53 |
'projet' => 'mots_cles',
|
| 53 |
'num_taxon' => 'nt',
|
54 |
'num_taxon' => 'nt',
|
| 54 |
'date_debut' => 'date_debut',
|
55 |
'date_debut' => 'date_debut',
|
| 55 |
'date_fin' => 'date_fin',
|
56 |
'date_fin' => 'date_fin',
|
| Line 56... |
Line 57... |
| 56 |
'taxon' => 'taxon'
|
57 |
'taxon' => 'taxon'
|
| 57 |
);
|
58 |
);
|
| 58 |
|
59 |
|
| 59 |
function ExportXLS($config) {
|
60 |
public function __construct($config) {
|
| 60 |
parent::__construct($config);
|
61 |
parent::__construct($config);
|
| 61 |
}
|
62 |
}
|
| 62 |
|
63 |
|
| 63 |
function getRessource() {
|
64 |
public function getRessource() {
|
| 64 |
return $this->getElement(array());
|
65 |
return $this->getElement(array());
|
| 65 |
}
|
66 |
}
|
| 66 |
|
67 |
|
| 67 |
function getElement($uid) {
|
68 |
public function getElement($uid) {
|
| 68 |
$parametres_format = $this->traiterParametresFormat($uid, $_GET);
|
69 |
$parametres_format = $this->traiterParametresFormat($uid, $_GET);
|
| 69 |
$filtres = $this->traiterFiltres($_GET);
|
70 |
$filtres = $this->traiterFiltres($_GET);
|
| 70 |
$this->export($parametres_format, $filtres);
|
71 |
$this->export($parametres_format, $filtres);
|
| 71 |
exit;
|
72 |
exit();
|
| 72 |
}
|
73 |
}
|
| 73 |
|
74 |
|
| 74 |
function traiterParametresFormat($uid, $params) {
|
75 |
private function traiterParametresFormat($uid, $params) {
|
| 75 |
$parametres = $this->parametres_defaut;
|
76 |
$parametres = $this->parametres_defaut;
|
| 76 |
if(isset($params['format'])) {
|
77 |
if (isset($params['format'])) {
|
| 77 |
if($params['format'] == 'csv') $parametres['format'] = 'CSV';
|
78 |
if($params['format'] == 'csv') $parametres['format'] = 'CSV';
|
| 78 |
if($params['format'] == 'xls') $parametres['format'] = 'Excel5';
|
79 |
if($params['format'] == 'xls') $parametres['format'] = 'Excel5';
|
| 79 |
if($params['format'] == 'xlsx') $parametres['format'] = 'Excel2007';
|
80 |
if($params['format'] == 'xlsx') $parametres['format'] = 'Excel2007';
|
| 80 |
if($params['format'] == 'pdf') $parametres['format'] = 'pdf';
|
81 |
if($params['format'] == 'pdf') $parametres['format'] = 'pdf';
|
| 81 |
}
|
82 |
}
|
| 82 |
// TODO: $params['part'] pour le multi-part
|
83 |
// TODO: $params['part'] pour le multi-part
|
| 83 |
$parametres['widget'] = isset($params['widget']) ? $params['widget'] : 'CEL';
|
84 |
$parametres['widget'] = isset($params['widget']) ? $params['widget'] : 'CEL';
|
| 84 |
$parametres['debut'] = isset($params['debut']) ? intval($params['debut']) : 0;
|
85 |
$parametres['debut'] = isset($params['debut']) ? intval($params['debut']) : 0;
|
| 85 |
$parametres['limite'] = isset($params['limite']) ? intval($params['limite']) : 0;
|
86 |
$parametres['limite'] = isset($params['limite']) ? intval($params['limite']) : 0;
|
| 86 |
$parametres['id_utilisateur'] = $this->traiterIdUtilisateur($uid);
|
87 |
$parametres['id_utilisateur'] = $this->traiterIdUtilisateur($uid);
|
| 87 |
$parametres['groupe_champs'] = isset($params['colonnes']) ? $params['colonnes'] : 'standard,avance';
|
88 |
$parametres['groupe_champs'] = isset($params['colonnes']) ? $params['colonnes'] : 'standard,avance';
|
| 88 |
|
89 |
|
| 89 |
return $parametres;
|
90 |
return $parametres;
|
| 90 |
}
|
91 |
}
|
| 91 |
|
92 |
|
| 92 |
function traiterIdUtilisateur($uid) {
|
93 |
private function traiterIdUtilisateur($uid) {
|
| 93 |
$id_utilisateur = null;
|
94 |
$id_utilisateur = null;
|
| 94 |
// TODO: controleUtilisateur()
|
95 |
// TODO: controleUtilisateur()
|
| 95 |
if(isset($uid[0])) {
|
96 |
if (isset($uid[0])) {
|
| 96 |
$id_utilisateur = intval($uid[0]);
|
97 |
$id_utilisateur = intval($uid[0]);
|
| 97 |
}
|
98 |
}
|
| 98 |
return $id_utilisateur;
|
99 |
return $id_utilisateur;
|
| 99 |
}
|
100 |
}
|
| 100 |
|
101 |
|
| 101 |
function traiterFiltres($params) {
|
102 |
private function traiterFiltres($params) {
|
| 102 |
$obs_ids = $this->traiterObsIds($params);
|
103 |
$obs_ids = $this->traiterObsIds($params);
|
| 103 |
$filtres = array();
|
- |
|
| 104 |
if(!$obs_ids || count($obs_ids) == 1 && $obs_ids[0] == '*') {
|
104 |
$filtres = array();
|
| 105 |
unset($filtres['sql_brut']);
|
105 |
if (!$obs_ids || count($obs_ids) == 1 && $obs_ids[0] == '*') {
|
| 106 |
}
|
106 |
unset($filtres['sql_brut']);
|
| 107 |
else {
|
107 |
} else {
|
| 108 |
$filtres = Array('sql_brut' =>
|
108 |
$filtres = Array('sql_brut' =>
|
| 109 |
sprintf('id_observation IN (%s)', implode(',', $obs_ids)));
|
109 |
sprintf('id_observation IN (%s)', implode(',', $obs_ids)));
|
| 110 |
}
|
110 |
}
|
| 111 |
foreach($params as $cle => $valeur) {
|
111 |
foreach ($params as $cle => $valeur) {
|
| 112 |
if(trim($valeur) != '' && isset($this->filtres_autorises[$cle])) {
|
112 |
if (trim($valeur) != '' && isset($this->filtres_autorises[$cle])) {
|
| 113 |
$filtres[$this->filtres_autorises[$cle]] = $valeur;
|
113 |
$filtres[$this->filtres_autorises[$cle]] = $valeur;
|
| 114 |
}
|
114 |
}
|
| 115 |
}
|
- |
|
| 116 |
return $filtres;
|
115 |
}
|
| 117 |
}
|
116 |
return $filtres;
|
| 118 |
|
117 |
}
|
| 119 |
|
118 |
|
| 120 |
function traiterObsIds($params) {
|
119 |
private function traiterObsIds($params) {
|
| 121 |
$obs_ids = Array('*');
|
120 |
$obs_ids = Array('*');
|
| 122 |
if (isset($params['range']) && trim($params['range']) != '*') {
|
121 |
if (isset($params['range']) && trim($params['range']) != '*') {
|
| 123 |
// trim() car: `POST http://url<<<"range=*"`
|
122 |
// trim() car: `POST http://url<<<"range=*"`
|
| 124 |
$obs_ids = self::rangeToList(trim($params['range']));
|
123 |
$obs_ids = self::rangeToList(trim($params['range']));
|
| Line 125... |
Line 124... |
| 125 |
}
|
124 |
}
|
| 126 |
return $obs_ids;
|
125 |
return $obs_ids;
|
| 127 |
}
|
126 |
}
|
| 128 |
|
127 |
|
| 129 |
/*
|
128 |
/*
|
| 130 |
* $param: Tableau associatif, indexes supportés:
|
129 |
* $param: Tableau associatif, indexes supportés:
|
| 131 |
* - widget: le nom du widget d'origine (utilisé pour les méta-données du tableur)
|
130 |
* - widget: le nom du widget d'origine (utilisé pour les méta-données du tableur)
|
| Line 132... |
Line 131... |
| 132 |
*
|
131 |
*
|
| 133 |
*/
|
132 |
*/
|
| 134 |
function export(Array $parametres_format = Array(),Array $filtres = array()) {
|
133 |
private function export(Array $parametres_format = Array(),Array $filtres = array()) {
|
| 135 |
$chercheur_observations = new RechercheObservation($this->config);
|
134 |
$chercheur_observations = new RechercheObservation($this->config);
|
| 136 |
|
135 |
|
| 137 |
$observations = $chercheur_observations
|
136 |
$observations = $chercheur_observations
|
| 138 |
->rechercherObservations($parametres_format['id_utilisateur'], $filtres, $parametres_format['debut'], $parametres_format['limite'], TRUE)
|
137 |
->rechercherObservations($parametres_format['id_utilisateur'], $filtres, $parametres_format['debut'], $parametres_format['limite'], TRUE)
|
| 139 |
->get();
|
138 |
->get();
|
| 140 |
// debug //echo ($chercheur_observations->requete_selection_observations);
|
139 |
// debug //echo ($chercheur_observations->requete_selection_observations);
|
| Line 141... |
Line 140... |
| 141 |
// XXX: malheureusement l'instance de JRest n'est pas accessible ici
|
140 |
// XXX: malheureusement l'instance de JRest n'est pas accessible ici
|
| 142 |
if(!$observations) {
|
141 |
if (!$observations) {
|
| - |
|
142 |
header('HTTP/1.0 204 No Content');
|
| - |
|
143 |
exit();
|
| 143 |
header('HTTP/1.0 204 No Content');
|
144 |
}
|
| Line 144... |
Line 145... |
| 144 |
exit;
|
145 |
|
| 145 |
}
|
146 |
if ($parametres_format['format'] == 'pdf') {
|
| 146 |
|
147 |
if (count($observations) > 300) {
|
| 147 |
if($parametres_format['format'] == 'pdf') {
|
148 |
die('too much');
|
| 148 |
if(count($observations) > 300) die('too much');
|
149 |
}
|
| 149 |
require_once('GenerateurPDF.php');
|
150 |
require_once('GenerateurPDF.php');
|
| 150 |
|
151 |
|
| Line 151... |
Line 152... |
| 151 |
$pdf = new GenerateurPDF();
|
152 |
$pdf = new GenerateurPDF();
|
| 152 |
$pdf->export($observations);
|
153 |
$pdf->export($observations);
|
| 153 |
//$pdf->export1($observations);
|
154 |
//$pdf->export1($observations);
|
| Line 171... |
Line 172... |
| 171 |
$no_ligne++;
|
172 |
$no_ligne++;
|
| 172 |
}
|
173 |
}
|
| Line 173... |
Line 174... |
| 173 |
|
174 |
|
| 174 |
$this->envoyerFeuille($objPHPExcel, $parametres_format);
|
175 |
$this->envoyerFeuille($objPHPExcel, $parametres_format);
|
| 175 |
}
|
176 |
}
|
| 176 |
|
177 |
|
| 177 |
private function envoyerFeuille($objPHPExcel, $parametres_format) {
|
178 |
private function envoyerFeuille($objPHPExcel, $parametres_format) {
|
| 178 |
header("Content-Type: application/vnd.ms-excel");
|
179 |
header('Content-Type: application/vnd.ms-excel');
|
| 179 |
header("Content-Disposition: attachment; filename=\"liste.xls\"; charset=utf-8");
|
180 |
header('Content-Disposition: attachment; filename="liste.xls"; charset=utf-8');
|
| 180 |
header("Cache-Control: max-age=0");
|
181 |
header('Cache-Control: max-age=0');
|
| 181 |
|
182 |
|
| 182 |
// csv|xls|xlsx => CSV|Excel5|Excel2007
|
183 |
// csv|xls|xlsx => CSV|Excel5|Excel2007
|
| 183 |
// Note: le format Excel2007 utilise un fichier temporaire
|
184 |
// Note: le format Excel2007 utilise un fichier temporaire
|
| 184 |
$generateur = PHPExcel_IOFactory::createWriter($objPHPExcel, $parametres_format['format']);
|
185 |
$generateur = PHPExcel_IOFactory::createWriter($objPHPExcel, $parametres_format['format']);
|
| 185 |
$generateur->save('php://output');
|
186 |
$generateur->save('php://output');
|
| 186 |
exit;
|
187 |
exit;
|
| 187 |
}
|
188 |
}
|
| 188 |
|
189 |
|
| 189 |
public function traiterLigneObservation(&$obs, &$colonnes, &$feuille, $no_ligne) {
|
190 |
private function traiterLigneObservation(&$obs, &$colonnes, &$feuille, $no_ligne) {
|
| 190 |
$no_colonne = 0;
|
191 |
$no_colonne = 0;
|
| 191 |
foreach($colonnes as $abbrev => $colonne) {
|
192 |
foreach ($colonnes as $abbrev => $colonne) {
|
| 192 |
$valeur = null;
|
193 |
$valeur = null;
|
| - |
|
194 |
if ($colonne['extra'] == 2 || ! is_null($colonne['dyna'])) {
|
| - |
|
195 |
continue;
|
| 193 |
if($colonne['extra'] == 2 || ! is_null($colonne['dyna'])) continue;
|
196 |
}
|
| 194 |
|
197 |
|
| 195 |
// valeur direct depuis cel_obs ?
|
198 |
// valeur direct depuis cel_obs ?
|
| - |
|
199 |
if (isset($obs[$abbrev])) {
|
| - |
|
200 |
$valeur = $obs[$abbrev];
|
| Line 196... |
Line 201... |
| 196 |
if(isset($obs[$abbrev])) $valeur = $obs[$abbrev];
|
201 |
}
|
| 197 |
|
202 |
|
| 198 |
// pré-processeur de la champs
|
203 |
// pré-processeur de la champs
|
| 199 |
if(function_exists($colonne['fonction'])) {
|
204 |
if (function_exists($colonne['fonction'])) {
|
| 200 |
$valeur = $colonne['fonction']($valeur);
|
205 |
$valeur = $colonne['fonction']($valeur);
|
| 201 |
} elseif(method_exists('FormateurGroupeColonne', $colonne['fonction'])) {
|
206 |
} else if (method_exists('FormateurGroupeColonne', $colonne['fonction'])) {
|
| 202 |
$valeur = call_user_func(array('FormateurGroupeColonne', $colonne['fonction']), $valeur);
|
207 |
$valeur = call_user_func(array('FormateurGroupeColonne', $colonne['fonction']), $valeur);
|
| 203 |
} elseif(method_exists(__CLASS__, $colonne['fonction'])) {
|
208 |
} else if (method_exists(__CLASS__, $colonne['fonction'])) {
|
| 204 |
$valeur = call_user_func(array(__CLASS__, $colonne['fonction']), $valeur);
|
209 |
$valeur = call_user_func(array(__CLASS__, $colonne['fonction']), $valeur);
|
| 205 |
} elseif($colonne['fonction']) {
|
- |
|
| 206 |
die("méthode {$colonne['fonction']} introuvable");
|
- |
|
| 207 |
}
|
210 |
} else if ($colonne['fonction']) {
|
| 208 |
// fonction pour obtenir des champs (étendus)
|
211 |
die("méthode {$colonne['fonction']} introuvable");
|
| 209 |
elseif(function_exists($colonne['fonction_data'])) {
|
- |
|
| 210 |
$valeur = $colonne['fonction_data']($obs);
|
212 |
} else if (function_exists($colonne['fonction_data'])) { // fonction pour obtenir des champs (étendus)
|
| 211 |
}
|
213 |
$valeur = $colonne['fonction_data']($obs);
|
| 212 |
elseif(method_exists(__CLASS__, $colonne['fonction_data'])) {
|
214 |
} else if (method_exists(__CLASS__, $colonne['fonction_data'])) {
|
| 213 |
$valeur = call_user_func(array(__CLASS__, $colonne['fonction_data']), $obs);
|
215 |
$valeur = call_user_func(array(__CLASS__, $colonne['fonction_data']), $obs);
|
| 214 |
}
|
216 |
}
|
| 215 |
|
217 |
|
| 216 |
// // cette section devrait être vide:
|
218 |
// // cette section devrait être vide:
|
| 217 |
// // cas particuliers ingérable avec l'architecture actuelle:
|
219 |
// // cas particuliers ingérable avec l'architecture actuelle:
|
| 218 |
if(false && $abbrev == 'date_observation' && $valeur == "0000-00-00") {
|
220 |
if (false && $abbrev == 'date_observation' && $valeur == "0000-00-00") {
|
| 219 |
/* blah */
|
221 |
/* blah */
|
| 220 |
}
|
222 |
}
|
| 221 |
if($abbrev == 'images') {
|
223 |
if ($abbrev == 'images') {
|
| 222 |
$valeur = FormateurGroupeColonne::getImages($obs, $this->id_utilisateur, $this);
|
224 |
$valeur = FormateurGroupeColonne::getImages($obs, $this->id_utilisateur, $this);
|
| 223 |
}
|
225 |
}
|
| 224 |
if($abbrev == 'nom-commun') {
|
226 |
if ($abbrev == 'nom-commun') {
|
| Line 225... |
Line 227... |
| 225 |
$valeur = FormateurGroupeColonne::getNomCommun_v4($obs, $this);
|
227 |
$valeur = FormateurGroupeColonne::getNomCommun_v4($obs, $this);
|
| 226 |
}
|
228 |
}
|
| 227 |
|
229 |
|
| 228 |
// // fin de section "cas particuliers"
|
230 |
// // fin de section "cas particuliers"
|
| 229 |
$feuille->setCellValueByColumnAndRow($no_colonne, $no_ligne, $valeur);
|
231 |
$feuille->setCellValueByColumnAndRow($no_colonne, $no_ligne, $valeur);
|
| 230 |
$no_colonne++;
|
232 |
$no_colonne++;
|
| 231 |
}
|
233 |
}
|
| 232 |
}
|
234 |
}
|
| 233 |
|
235 |
|
| 234 |
private function gerenerFeuilleImportFormatee($parametres_format) {
|
236 |
private function gerenerFeuilleImportFormatee($parametres_format) {
|
| 235 |
$objPHPExcel = new PHPExcel();
|
237 |
$objPHPExcel = new PHPExcel();
|
| 236 |
|
238 |
|
| 237 |
$objPHPExcel->getProperties()->setCreator($parametres_format['widget']) // ou $uid ?
|
239 |
$objPHPExcel->getProperties()->setCreator($parametres_format['widget']) // ou $uid ?
|
| 238 |
->setLastModifiedBy("XX") // TODO: $uid
|
240 |
->setLastModifiedBy("XX") // TODO: $uid
|
| 239 |
->setTitle("Export des observation du carnet en ligne") // TODO
|
- |
|
| 240 |
->setSubject("Export") // TODO
|
- |
|
| 241 |
->setDescription("Export");
|
241 |
->setTitle("Export des observation du carnet en ligne") // TODO
|
| 242 |
//->setKeywords("office PHPExcel php")
|
242 |
->setSubject("Export") // TODO
|
| 243 |
//->setCategory("Test result file")
|
243 |
->setDescription("Export");
|
| 244 |
|
244 |
|
| 245 |
$objPHPExcel->getActiveSheet()->setTitle("Observations");
|
245 |
$objPHPExcel->getActiveSheet()->setTitle("Observations");
|
| 246 |
return $objPHPExcel;
|
246 |
return $objPHPExcel;
|
| 247 |
}
|
247 |
}
|
| 248 |
|
248 |
|
| 249 |
private function formaterColonnesFeuille(&$feuille, &$colonnes, $parametres_format) {
|
249 |
private function formaterColonnesFeuille(&$feuille, &$colonnes, $parametres_format) {
|
| - |
|
250 |
$colid = 0;
|
| - |
|
251 |
foreach ($colonnes as $colonne) {
|
| 250 |
$colid = 0;
|
252 |
if ($colonne['extra'] == 2) {
|
| 251 |
foreach($colonnes as $colonne) {
|
253 |
continue;
|
| 252 |
if($colonne['extra'] == 2) continue;
|
254 |
}
|
| 253 |
|
255 |
|
| 254 |
$feuille->setCellValueByColumnAndRow($colid, 1, $colonne['nom']);
|
256 |
$feuille->setCellValueByColumnAndRow($colid, 1, $colonne['nom']);
|
| 255 |
if($colonne['extra'] == 1) {
|
257 |
if ($colonne['extra'] == 1) {
|
| 256 |
$feuille->getStyleByColumnAndRow($colid, 1)->getBorders()->applyFromArray(
|
258 |
$feuille->getStyleByColumnAndRow($colid, 1)->getBorders()->applyFromArray(
|
| 257 |
array(
|
259 |
array(
|
| 258 |
'allborders' => array(
|
260 |
'allborders' => array(
|
| 259 |
'style' => PHPExcel_Style_Border::BORDER_DASHDOT,
|
261 |
'style' => PHPExcel_Style_Border::BORDER_DASHDOT,
|
| 260 |
'color' => array('rgb' => PHPExcel_Style_Color::COLOR_BLUE)
|
262 |
'color' => array('rgb' => PHPExcel_Style_Color::COLOR_BLUE)
|
| 261 |
)
|
263 |
)
|
| 262 |
)
|
264 |
)
|
| 263 |
);
|
265 |
);
|
| 264 |
}
|
266 |
}
|
| 265 |
if(! $colonne['importable']) {
|
267 |
if (! $colonne['importable']) {
|
| 266 |
$feuille->getStyleByColumnAndRow($colid, 1)->getFill()->applyFromArray(
|
268 |
$feuille->getStyleByColumnAndRow($colid, 1)->getFill()->applyFromArray(
|
| 267 |
array(
|
269 |
array(
|
| 268 |
'type' => PHPExcel_Style_Fill::FILL_SOLID,
|
270 |
'type' => PHPExcel_Style_Fill::FILL_SOLID,
|
| 269 |
'color' => array('rgb' => PHPExcel_Style_Color::COLOR_YELLOW)
|
271 |
'color' => array('rgb' => PHPExcel_Style_Color::COLOR_YELLOW)
|
| 270 |
)
|
- |
|
| 271 |
);
|
272 |
)
|
| 272 |
}
|
273 |
);
|
| 273 |
|
274 |
}
|
| Line 274... |
Line 275... |
| 274 |
$colid++;
|
275 |
$colid++;
|
| Line 282... |
Line 283... |
| 282 |
*/
|
283 |
*/
|
| 283 |
static function rangeToList($in = '') {
|
284 |
static function rangeToList($in = '') {
|
| 284 |
$inSets = explode(',', $in);
|
285 |
$inSets = explode(',', $in);
|
| 285 |
$outSets = array();
|
286 |
$outSets = array();
|
| Line 286... |
Line 287... |
| 286 |
|
287 |
|
| 287 |
foreach($inSets as $inSet) {
|
288 |
foreach ($inSets as $inSet) {
|
| 288 |
list($start,$end) = explode('-', $inSet . '-' . $inSet);
|
289 |
list($start,$end) = explode('-', $inSet . '-' . $inSet);
|
| 289 |
// ignore les ranges trop importants
|
290 |
// ignore les ranges trop importants
|
| - |
|
291 |
if ($start > 10000000 || $end > 10000000 || abs($start-$end) > 10000) {
|
| - |
|
292 |
continue;
|
| 290 |
if($start > 10000000 || $end > 10000000 || abs($start-$end) > 10000) continue;
|
293 |
}
|
| 291 |
$outSets = array_merge($outSets,range($start,$end));
|
294 |
$outSets = array_merge($outSets,range($start,$end));
|
| 292 |
}
|
295 |
}
|
| 293 |
$outSets = array_unique($outSets);
|
296 |
$outSets = array_unique($outSets);
|
| 294 |
$outSets = array_filter($outSets, 'is_numeric');
|
297 |
$outSets = array_filter($outSets, 'is_numeric');
|