Rev 996 | Blame | Last modification | View Log | RSS feed
<?php
// ATTENTION ! Classe compatible uniquement avec nouveau format de bdd du cel //
/**
* PHP Version 5
*
* @category PHP
* @package jrest
* @author David Delon <delon@tela-botanica.org>
* @copyright 2010 Tela-Botanica
* @license http://www.cecill.info/licences/Licence_CeCILL_V2-fr.txt Licence CECILL
* @version SVN: <svn_id>
* @link /doc/
*/
/**
*
* in=utf8
* out=iso3859
*
* Liste des Nouvelles observations par departement
* A voir avec David mais ne devrait plus être utilisé
* ou fait autrement
*
*/
class InventoryByDept extends Cel {
var $extendSpreadsheetProductor;
function InventoryByDept($config) {
parent::__construct($config);
// Pas d'heritage multiple en php :(
$this->extendSpreadsheetProductor = new SpreadsheetProductor();
$this->extendSpreadsheetProductor->initSpreadsheet();
}
//TODO : faire une fonction qui prend en paramètre un departement
function getRessource(){
$requete_obs = "SELECT ce_zone_geo, ce_utilisateur, courriel_utilisateur, ordre, nom_sel, nom_sel_nn, nom_ret, nom_ret_nn, nt, famille, zone_geo, date_observation," .
" lieudit, station, milieu, commentaire, transmission FROM cel_obs ".
"WHERE ce_zone_geo != '000null' AND ce_zone_geo != '' AND transmission = 1 AND nt!=0 ORDER BY ce_zone_geo, nom_ret LIMIT 50";
$resultat_obs = $this->executerRequete($requete_obs);
// Creating a workbook
$workbook = new Spreadsheet_Excel_Writer();
// Creating a worksheet
$worksheet = $workbook->addWorksheet('Liste');
$worksheet->write(0,0,'Departement');
$worksheet->write(0,1,'Nom saisi');
$worksheet->write(0,2,'Numero nomenclatural');
$worksheet->write(0,3,'Nom retenu');
$worksheet->write(0,4,'Numero nomenclatural nom retenu');
$worksheet->write(0,5,'Numero taxonomique');
$worksheet->write(0,6,'Famille');
$worksheet->write(0,7,'Commune');
$worksheet->write(0,8,'Date Observation');
$worksheet->write(0,9,'Lieu dit');
$worksheet->write(0,10,'Station');
$worksheet->write(0,11,'Milieu');
$worksheet->write(0,12,'Commentaire');
$worksheet->write(0,13,'Observateur');
$i=1;
$observations = array();
$chercheur_infos_taxon = null;
if (is_array($resultat_obs)) {
$observations = &$resultat_obs;
$chercheur_infos_taxon = new RechercheInfosTaxonBeta($this->config);
}
foreach ($observations as $obs) {
$code_departement = $this->convertirCodeZoneGeoVersDepartement($obs['ce_zone_geo']);
$taxon_deja_vu = $chercheur_infos_taxon->taxonEstPresentDansDepartement($obs['nt'], $code_departement);
if (!$taxon_deja_vu) {
// Denullifiage
foreach($obs as $k=>$v) {
if (($v=="null") || ($v=="000null")) {
$obs[$k]="";
}
else {
$obs[$k]=utf8_decode($v);
}
}
if ($obs['date_observation']!="0000-00-00 00:00:00") {
list($year,$month,$day)= explode('-',$obs['date_observation']);
list($day)= explode(' ',$day);
$obs['date_observation']=$day."/".$month."/".$year;
}
else {
$obs['date_observation']="00/00/0000";
}
$worksheet->write($i,0,$code_departement);
$worksheet->write($i,1,$obs['nom_sel']);
$worksheet->write($i,2,$obs['nom_sel_nn']);
$worksheet->write($i,3,$obs['nom_ret']);
$worksheet->write($i,4,$obs['nom_ret_nn']);
$worksheet->write($i,5,$obs['nt']);
$worksheet->write($i,6,$obs['famille']);
$worksheet->write($i,7,$obs['zone_geo']);
$worksheet->write($i,8,$obs['date_observation']);
$worksheet->write($i,9,$obs['lieudit']);
$worksheet->write($i,10,$obs['station']);
$worksheet->write($i,11,$obs['milieu']);
$worksheet->write($i,12,$obs['commentaire']);
$worksheet->write($i,13,$obs['courriel_utilisateur']);
$i++;
}
}
// sending HTTP headers
$workbook->send('liste.xls');
$workbook->close();
exit();
}
}
/* +--Fin du code ---------------------------------------------------------------------------------------+
* $Log$
* Revision 1.1 2008-11-13 11:29:12 ddelon
* Reecriture gwt-ext
*
* Revision 1.2 2008-01-30 08:57:28 ddelon
* fin mise en place mygwt
*
* Revision 1.1 2007-06-06 13:31:16 ddelon
* v0.09
*
* Revision 1.3 2007-05-22 12:54:09 ddelon
* Securisation acces utilisateur
*
*
*
*/
?>