Current file: /root/works/bitsis/oxokuatro/CRE/creuRoja.php
Legend: executed not executed dead code

  Coverage
  Classes Functions / Methods Lines
Total
0.00%0.00%
0.00% 0 / 1
66.67%66.67%
66.67% 4 / 6 CRAP
84.44%84.44%
84.44% 38 / 45
 
creuRoja
0.00%0.00%
0.00% 0 / 1
66.67%66.67%
66.67% 4 / 6
84.44%84.44%
84.44% 38 / 45
 __construct()
100.00%100.00%
100.00% 1 / 1 1
100.00%100.00%
100.00% 10 / 10
 get_beach($beach_id)
0.00%0.00%
0.00% 0 / 1 2
0.00%0.00%
0.00% 0 / 1
 beaches_list()
100.00%100.00%
100.00% 1 / 1 2
100.00%100.00%
100.00% 8 / 8
 estat_platja($id_beach)
100.00%100.00%
100.00% 1 / 1 1
100.00%100.00%
100.00% 5 / 5
 informacio_platja($params)
100.00%100.00%
100.00% 1 / 1 2
100.00%100.00%
100.00% 15 / 15
 SetEstat_Platja($beach_id,$estat)
0.00%0.00%
0.00% 0 / 1 6
0.00%0.00%
0.00% 0 / 6


       1                 : <?php                                                                                                                                                         
       2                 :                                                                                                                                                               
       3                 : include_once ("WSFW/lib/wsfw_db.php");                                                                                                                        
       4                 : include_once ("WSFW/wsfw_client.php");                                                                                                                        
       5                 : include_once ("lib/Panoramio.php");                                                                                                                           
       6                 :                                                                                                                                                               
       7                 : class creuRoja{                                                                                                                                               
       8                 :                                                                                                                                                               
       9                 :     private $db;                                                                                                                                              
      10                 :     private $ibiza_travel;                                                                                                                                    
      11                 :     private $panoramio;                                                                                                                                       
      12                 :                                                                                                                                                                   
      13                 :     function __construct(){                                                                                                                                   
      14               6 :         $this->db = new WSFW_Db('localhost', '3306', 'root', '1212lk12', 'evsplatges');                                                                       
      15               6 :         $this->ibiza_travel = new WSFW_Client(array(                                                                                                          
      16               6 :             "url" => 'http://webservice.ibiza.travel/soap/index.php?wsdl',                                                                                    
      17               6 :             "protocol" => "Soap")                                                                                                                             
      18               6 :         );                                                                                                                                                    
      19               6 :         $this->panoramio = new WSFW_Client(array(                                                                                                             
      20               6 :             "url" => 'http://www.panoramio.com/map/get_panoramas.php',                                                                                        
      21               6 :             "protocol" => 'Panoramio')                                                                                                                        
      22               6 :         );                                                                                                                                                    
      23               6 :     }                                                                                                                                                         
      24                 :                                                                                                                                                               
      25                 :     // donat un identificador propi de platja de ibizatravel, retorna tota la informacio associada a aquesta                                                  
      26                 :     function get_beach($beach_id) {                                                                                                                           
      27               0 :         return $this->ibiza_travel->call("beach.get", array("beach_id"=>$beach_id, "lang_id"=>"es", "id" => "mj554sk90"));                                    
      28                 :     }                                                                                                                                                         
      29                 :                                                                                                                                                                   
      30                 :     // retorna tota la informacio de totes les platges incloent el estat i la data de la ultima lectura                                                       
      31                 :     function beaches_list() {                                                                                                                                 
      32               1 :         $data = $this->ibiza_travel->call("ibizatravel.beaches_list", array("lang_id"=>"es", "id" => "mj554sk90"));                                           
      33               1 :         $beach_list = array();                                                                                                                                
      34               1 :         foreach ($data as $beach_data) {                                                                                                                      
      35               1 :             $beach_data['estat']=$this->estat_platja($beach_data['beach_id']);                                                                                
      36               1 :             $beach_data['foto']="";                                                                                                                           
      37               1 :             array_push($beach_list, $beach_data);                                                                                                             
      38               1 :         }                                                                                                                                                     
      39               1 :         return $beach_list;                                                                                                                                   
      40                 :     }                                                                                                                                                         
      41                 :                                                                                                                                                               
      42                 :     // reb el id de la platja de CIE no la propia que te a la bbdd local i retorna el esta de la platja i la data de l'ultima lectura                         
      43                 :     function estat_platja($id_beach){                                                                                                                         
      44                 :         //$cs=array ("max(fecha) as Data","estado"); $tabla="lecturas,playas";$busqueda="lecturas.id_beach=playas.id_beach AND lecturas.id_beach='$beach_id'";
      45               5 :                 $idp=$this->db->select_unico(array("idp"),"playas","beach_id='$id_beach'");                                                                   
      46               5 :                 $id=$idp['idp'];                                                                                                                              
      47               5 :                 $cs=array ("max(fecha) as Data","estado"); $tabla="lecturas,playas";$busqueda="lecturas.idp='$id'";                                           
      48               5 :         $beach=$this->db->select_unico($cs, $tabla, $busqueda); //function select_unico ($campos, $tabla, $condicion)                                         
      49               5 :         return $beach;                                                                                                                                        
      50                 :     }                                                                                                                                                         
      51                 :                                                                                                                                                               
      52                 :     //donat un nom de platja retorna un array associatiu amb tota la informacio                                                                                
      53                 :     function informacio_platja($params) {                                                                                                                     
      54               4 :         $params = objectToArray($params);                                                                                                                     
      55               4 :         $data = $this->ibiza_travel->call("beach.get", array("beach_id" =>$params['beach_id'],"lang_id"=>"es", "id" => "mj554sk90"));                         
      56                 :         //return $data; OK FUNCIONA                                                                                                                           
      57                 :                                                                                                                                                                               
      58               4 :                 $info=$data;                                                                                                                                  
      59                 :                                                                                                                                                                               
      60               4 :                 $info['estat']=$this->estat_platja($params['beach_id']);                                                                                      
      61                 :                                                                                                                                                                               
      62                 :                                                                                                                                                                               
      63               4 :         $data = $this->panoramio->call(null, array(                                                                                                           
      64               4 :             "set" => "full",                                                                                                                                  
      65               4 :             "from" => "0",                                                                                                                                    
      66               4 :             "to" => "1",                                                                                                                                      
      67               4 :             "minx" => $info["lat"]-0.5,                                                                                                                       
      68               4 :             "miny" => $info["lon"]-0.5,                                                                                                                       
      69               4 :             "maxx" => $info["lat"]+0.5,                                                                                                                       
      70               4 :             "maxy" => $info["lon"]+0.5,                                                                                                                       
      71               4 :         ));                                                                                                                                                   
      72               4 :         if ($data["count"]) $info["foto"] = $data["photos"][0];                                                                                               
      73                 :                                                                                                                                                               
      74               4 :                 return $info;                                                                                                                                 
      75                 :     }                                                                                                                                                         
      76                 :                                                                                                                                                               
      77                 :     // inserta una nova lectura d'una platja concreta i l'estat en que esta(V-vers,A-groc,R-vermell)                                                          
      78                 :     function SetEstat_Platja($beach_id,$estat) {                                                                                                              
      79               0 :         $cs=array ("id_beach"); $tabla="playas";$busqueda="id_beach=$beach_id";                                                                               
      80               0 :         $platja=$this->db->select_unico($cs, $tabla, $busqueda, null, null);                                                                                  
      81               0 :         $campos=array('id_beach'=>$beach_id,'estat'=>$estat);                                                                                                 
      82               0 :         if ($platja) $this->db->insert("lecturas", $campos);                                                                                                  
      83               0 :         else echo "No existeix aquest identificador de platja";  // no existeix l'identificador de platja                                                     
      84               0 :     }                                                                                                                                                         
      85                 :                                                                                                                                                               
      86                 : }                                                                                                                                                             
      87                 :                                                                                                                                                               
      88                 : ?>                                                                                                                                                            

Generated by PHP_CodeCoverage 1.0.3 using PHP 5.3.3-7 and PHPUnit 3.5.5 at Tue Jan 25 2:17:13 CET 2011.