Subversion Repositories eFlore/Applications.cel

Rev

Go to most recent revision | Blame | Last modification | View Log | RSS feed

<?php

// In utf8
// Out iso3859

// Liste des Nouvelles observations par departement


Class InventoryByDept extends DBAccessor {


        var $config;
        var $extendSpreadsheetProductor;
        
        
        function InventoryByDept($config) {

                $this->config=$config;
                // Pas d'heritage multiple en php :(
                
                $this->extendSpreadsheetProductor = new SpreadsheetProductor();
                $this->extendSpreadsheetProductor->initSpreadsheet();
             
        }
        

        function getRessource(){
                
                        $DB=$this->connectDB($this->config,'database_cel');
                        
                        
                        $query="SELECT id_location, identifiant, ordre, nom_sel, num_nom_sel, nom_ret, num_nom_ret, num_taxon, famille, location, date_observation," .
                           " lieudit, station, milieu, commentaire, transmission  FROM cel_inventory ". 
                                        "where id_location!='000null' and transmission=1 and num_taxon!=0 order by round(id_location), nom_ret";
                                        
                    $res =& $DB->query($query);
    
                if (DB::isError($res)) {
                die($res->getMessage());
                }
                
                // 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');
        
    
                $DB2=$this->connectDB($this->config);
    
                $i=1;
                        while ($row =& $res->fetchrow(DB_FETCHMODE_ASSOC)) {

                                        $query2="SELECT ecd_ce_taxon FROM eflore_zg, eflore_chorologie_donnee WHERE ecd_ce_taxon =".$row['num_taxon']." and ezg_code=".$row['id_location']." and ecd_ce_zone_geo=ezg_id_zone_geo and  ezg_id_projet_zg =ecd_ce_version_projet_zg and ecd_ce_version_projet_taxon=25";

                                        $res2 =& $DB2->query($query2);
    
    
                                if (DB::isError($res2)) {
                                die($res2->getMessage());
                                }
                                        
                                        if ($res2->numRows() == 0) {                                    
                                                
                                                // 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['id_location']);
                                        $worksheet->write($i,1,$row['nom_sel']);
                                $worksheet->write($i,2,$row['num_nom_sel']);
                                $worksheet->write($i,3,$row['nom_ret']);
                                $worksheet->write($i,4,$row['num_nom_ret']);
                                $worksheet->write($i,5,$row['num_taxon']);
                                $worksheet->write($i,6,$row['famille']);
                                $worksheet->write($i,7,$row['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['identifiant']);
                                
                                $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
*
*
* 
*/

?>