config=$config; // Pas d'heritage multiple en php :( $this->extendSpreadsheetProductor = new SpreadsheetProductor(); $this->extendSpreadsheetProductor->initSpreadsheet(); } function getElement($uid){ // Controle detournement utilisateur if(!isset($_SESSION)) {session_start();} $this->controleUtilisateur($uid[0]); $DB=$this->connectDB($this->config,'database_cel'); $criteres = array() ; if(isset($uid[1])) { $criteres = explode("&", $uid[1]) ; } $query="SELECT id, identifiant, ordre, nom_sel, num_nom_sel, nom_ret, num_nom_ret, num_taxon, famille, location, id_location, date_observation," . " lieudit, station, milieu, commentaire, transmission, coord_x, coord_y, ref_geo FROM cel_inventory WHERE identifiant='".$DB->escapeSimple($uid[0])."' AND " ; foreach($criteres as $pair) { $nom_valeur = explode("=",$pair) ; if(sizeof($nom_valeur) != 0) { if($nom_valeur[0] == 'limite') { $limite = $DB->escapeSimple($nom_valeur[1]) ; } elseif($nom_valeur[0] == 'numero_page') { $numero_page = $DB->escapeSimple($nom_valeur[1]) ; } elseif($nom_valeur[0] == 'annee') { $query .= "year(date_observation) = '".$DB->escapeSimple($nom_valeur[1])."'" ; $query .= ' AND ' ; } elseif($nom_valeur[0] == 'mois') { $query .= "month(date_observation) = '".$DB->escapeSimple($nom_valeur[1])."'" ; $query .= ' AND ' ; } elseif($nom_valeur[0] == 'jour') { $query .= "day(date_observation) = '".$DB->escapeSimple($nom_valeur[1])."'" ; $query .= ' AND ' ; } elseif($nom_valeur[0] == 'mots_cles') { $liste_mc = explode(";",$nom_valeur[1]); $query .= '(' ; foreach($liste_mc as $mot) { if(trim($mot) != '') { $query .= "mots_cles LIKE '%".$DB->escapeSimple($mot)."%' OR " ; } } $query = rtrim($query,' OR '); $query .= ') AND ' ; } elseif ($nom_valeur[0] == 'nom_taxon') { $nom_valeur[1] = str_replace("*","%",$nom_valeur[1]); $query .= "(nom_sel LIKE '%".$DB->escapeSimple($nom_valeur[1]). "%' OR identifiant LIKE '%".$DB->escapeSimple($nom_valeur[1]). "%' OR ordre LIKE '%".$DB->escapeSimple($nom_valeur[1]). "%' OR nom_sel LIKE '%".$DB->escapeSimple($nom_valeur[1]). "%' OR num_nom_sel LIKE '%".$DB->escapeSimple($nom_valeur[1]). "%' OR nom_ret LIKE '%".$DB->escapeSimple($nom_valeur[1]). "%' OR num_nom_ret LIKE '%".$DB->escapeSimple($nom_valeur[1]). "%' OR num_taxon LIKE '%".$DB->escapeSimple($nom_valeur[1]). "%' OR location LIKE '%".$DB->escapeSimple($nom_valeur[1]). "%' OR id_location LIKE '%".$DB->escapeSimple($nom_valeur[1]). "%' OR date_observation LIKE '%".$DB->escapeSimple($nom_valeur[1]). "%' OR lieudit LIKE '%".$DB->escapeSimple($nom_valeur[1]). "%' OR station LIKE '%".$DB->escapeSimple($nom_valeur[1]). "%' OR milieu LIKE '%".$DB->escapeSimple($nom_valeur[1]). "%' OR commentaire LIKE '%".$DB->escapeSimple($nom_valeur[1]). "%' OR transmission LIKE '%".$DB->escapeSimple($nom_valeur[1]). "%' OR coord_x LIKE '%".$DB->escapeSimple($nom_valeur[1]). "%' OR coord_y LIKE '%".$DB->escapeSimple($nom_valeur[1]). "%')"; //"%' OR famille LIKE '%".$DB->escapeSimple($nom_valeur[1]). } else { if(trim($nom_valeur[0]) != '') { $query .= $nom_valeur[0]." = '".$DB->escapeSimple($nom_valeur[1])."'" ; $query .= ' AND ' ; } } } } $query = rtrim($query,' AND ') ; $query .=" ORDER BY ordre "; $res =& $DB->query($query); if (DB::isError($res)) { die($res->getMessage()); } // Creating a workbook $workbook = new Spreadsheet_Excel_Writer(); $workbook->send('liste.xls'); // Creating a worksheet $worksheet = $workbook->addWorksheet('Liste'); $worksheet->write(0,0,'Espece'); $worksheet->write(0,1,'Numero nomenclatural'); $worksheet->write(0,2,'Nom retenu'); $worksheet->write(0,3,'Numero nomenclatural nom retenu'); $worksheet->write(0,4,'Numero taxonomique'); $worksheet->write(0,5,'Famille'); $worksheet->write(0,6,'Commune'); $worksheet->write(0,7,'Identifiant Commune'); $worksheet->write(0,8,'Date'); $worksheet->write(0,9,'Lieu-dit'); $worksheet->write(0,10,'Station'); $worksheet->write(0,11,'Milieu'); $worksheet->write(0,12,'Notes'); $worksheet->write(0,13,'Latitude'); $worksheet->write(0,14,'Longitude'); $worksheet->write(0,15,'Referentiel Geographique'); $worksheet->write(0,16,'Ordre'); $worksheet->write(0,17,'Identifiant'); $i=1; while ($row =& $res->fetchrow(DB_FETCHMODE_ASSOC)) { // Denullifiage foreach($row as $k=>$v) { if (($v=="null") || ($v=="000null")) { $row[$k]=""; } else { $row[$k]=utf8_decode($v); } } if ($row['date_observation']!="0000-00-00 00:00:00") { list($year,$month,$day)= split ('-',$row['date_observation']); list($day)= split (' ',$day); $row['date_observation']=$day."/".$month."/".$year; } else { $row['date_observation']="00/00/0000"; } $worksheet->write($i,0,$row['nom_sel']); $worksheet->write($i,1,$row['num_nom_sel']); $worksheet->write($i,2,$row['nom_ret']); $worksheet->write($i,3,$row['num_nom_ret']); $worksheet->write($i,4,$row['num_taxon']); $worksheet->write($i,5,$row['famille']); $worksheet->write($i,6,$row['location']); $worksheet->write($i,7,$row['id_location']); $worksheet->write($i,8,$row['date_observation']); $worksheet->write($i,9,$row['lieudit']); $worksheet->write($i,10,$row['station']); $worksheet->write($i,11,$row['milieu']); $worksheet->write($i,12,$row['commentaire']); $worksheet->write($i,13,$row['coord_x']); $worksheet->write($i,14,$row['coord_y']); $worksheet->write($i,15,$row['ref_geo']); $worksheet->write($i,16,$row['ordre']); $worksheet->write($i,17,$row['id']); $i++; } $workbook->close(); exit(); } } /* +--Fin du code ---------------------------------------------------------------------------------------+ * $Log$ * Revision 1.7 2008-11-13 11:29:12 ddelon * Reecriture gwt-ext * * Revision 1.6 2008-01-30 08:57:28 ddelon * fin mise en place mygwt * * Revision 1.5 2007-06-06 13:31:16 ddelon * v0.09 * * Revision 1.4 2007-05-22 12:54:09 ddelon * Securisation acces utilisateur * * * */ ?>