Subversion Repositories eFlore/Applications.cel

Rev

Rev 416 | Go to most recent revision | Blame | Compare with Previous | Last modification | View Log | RSS feed

<?php

// in : utf8
// out : utf8

// Liste les date de releves par utilisateur


Class InventoryDateList extends DBAccessor {


        var $config;
        
        function InventoryDateList($config) {

                $this->config=$config;
        }
        

        function getElement($uid){
                

                        // uid[0] : utilisateur obligatoire
                        // uid[1] : si absent : valeur 'all' (annee)
                        // uid[2] : si absent : valeur 'all' (mois)
                        // uid[3] : si absent : valeur 'all' (jour)

                   // Controle detournement utilisateur 
                    session_start();
                    
                        $this->controleUtilisateur($uid[0]);
                
                        $DB=$this->connectDB($this->config,'database_cel');
                        
                        $select = "date_observation" ;
                         
                        if (!isset($uid[1]) || $uid[1]=="" || $uid[1]=="all" ) {
                                $uid[1]="all";
                                if ($select=="") $select="year(date_observation) ";
                        }
                        else {
                                $query_year=" AND year(date_observation)='".$DB->escapeSimple($uid[1])."' ";
                        }
                        
                        
                        if (!isset($uid[2]) || $uid[2]=="" || $uid[2]=="all" ) {
                                $uid[2]="all";
                                if ($select=="") $select="month(date_observation) ";
                        }
                        else {
                                $query_month=" AND month(date_observation)='".$DB->escapeSimple($uid[2])."' ";
                        }

                        if (!isset($uid[3]) || $uid[3]=="" || $uid[3]=="all" ) {
                                $uid[3]="all";
                                if ($select=="") $select="day(date_observation) ";
                        }
                        else {
                                $query_day=" AND day(date_observation)='".$DB->escapeSimple($uid[3])."' ";
                        }
                        
                
                        $value=array();
        
                
                
                        $query="SELECT DISTINCT ".
                                $select. " AS id" .
                                " FROM cel_inventory WHERE identifiant='".$DB->escapeSimple($uid[0])."' " .
                        $query_year.
                        $query_month.
                        $query_day.
                                " ORDER BY ".$select;           
                                
                
                    $res =& $DB->query($query);
                    
                if (DB::isError($res)) {
                die($res->getMessage());
                }
                while ($row =& $res->fetchrow(DB_FETCHMODE_ASSOC)) {
                         $value[]=array($row['id']);
            }
                
                        $output = json_encode($value);
                        print($output);
                        
                        return true;    


        }
        


}


/* +--Fin du code ---------------------------------------------------------------------------------------+
* $Log$
* Revision 1.4  2008-01-30 08:57:28  ddelon
* fin mise en place mygwt
*
* Revision 1.3  2007-05-22 12:54:09  ddelon
* Securisation acces utilisateur
*
*
* 
*/


 
?>