Ignore:
Timestamp:
03/04/10 13:29:43 (14 years ago)
Author:
pedroerp
Message:

Ticket #950 - Merged 2108:2139 /trunk/workflow em /sandbox/workflow/trunk

File:
1 edited

Legend:

Unmodified
Added
Removed
  • sandbox/workflow/trunk/inc/local/classes/class.wf_location.php

    r795 r2160  
    7272                        c.id_city AS id_city, 
    7373                        c.city_name AS city_name, 
     74                        c.is_district, 
    7475                        s.id_state AS id_state, 
    7576                        s.state_name AS state_name, 
     
    125126         * Busca as cidades de um estado 
    126127         * @param int $state_id Numero ID do estado 
    127          * @return mixed (array ou boolean) 
    128          * @access public 
    129          */ 
    130         function getCitiesFromState($state_id) 
    131         { 
    132                 if (!is_numeric($state_id)) 
     128         * @param bool $include_districts True, busca cidades e distritos. False, busca apenas cidades. 
     129         * @return mixed (array ou boolean) 
     130         * @access public 
     131         */ 
     132        function getCitiesFromState($state_id, $include_districts = true) 
     133        { 
     134                if (!is_numeric($state_id) || !is_bool($include_districts)) 
    133135                        return false; 
    134136 
     
    137139                        return $this->citiesFromState[$state_id]; 
    138140 
     141                $where = ""; 
     142                if(!$include_districts){ 
     143                        $where = " AND c.is_district = 'F' "; 
     144                } 
     145 
    139146                $sql = 
    140147                "SELECT 
    141148                        c.id_city AS id_city, 
    142                         c.city_name AS city_name 
     149                        c.city_name AS city_name, 
     150                        c.is_district 
    143151                FROM 
    144152                        phpgw_cc_state s, 
     
    147155                        c.id_state = s.id_state AND 
    148156                        s.id_country = 'BR' AND 
    149                         c.id_state = ? 
     157                        c.id_state = ? " . $where . " 
    150158                ORDER BY 
    151159                        city_name"; 
     
    160168        } 
    161169    /** 
    162          * Busca os estados brasileiros 
    163          * @return mixed (array ou boolean) 
    164          * @access public 
    165          */ 
    166         function getStates() 
    167         { 
    168                 $sql = 
    169                 "SELECT 
    170                         id_state, 
    171                         state_name 
    172                 FROM 
    173                         phpgw_cc_state 
    174                 WHERE 
    175                         id_country = 'BR' 
     170         * Busca as cidades por parte do nome, sem considerar maiúsculas e/ou minúsculas e nem acentuação (retorna 10 resultados) 
     171         * @param string Parte do nome da cidade 
     172         * @param int $state_id Numero ID do estado 
     173         * @param bool $include_districts True, busca cidades e distritos. False, busca apenas cidades. 
     174         * @return mixed (array ou boolean) 
     175         * @access public 
     176         */ 
     177        function getCitiesByKey($key, $state_id = 0, $include_districts = true) 
     178        { 
     179                if (!is_string($key) || !is_numeric($state_id) || !is_bool($include_districts)) 
     180                        return false; 
     181 
     182                $where = ""; 
     183                if($state_id > 0){ 
     184                        $where = " AND c.id_state = " . $state_id; 
     185                } 
     186 
     187                if(!$include_districts){ 
     188                        $where = " AND c.is_district = 'F' "; 
     189                } 
     190 
     191                $sql = 
     192                "SELECT 
     193                        c.id_city AS id_city, 
     194                        c.city_name AS city_name, 
     195                        s.id_state AS id_state, 
     196                        s.state_name AS state_name, 
     197                        s.state_symbol AS state_symbol 
     198                FROM 
     199                        phpgw_cc_state s, 
     200                        phpgw_cc_city c 
     201                WHERE 
     202                        c.id_state = s.id_state AND 
     203                        s.id_country = 'BR' AND 
     204                        TO_ASCII(c.city_name) ILIKE TO_ASCII('" . $key . "%') 
     205                        " . $where . " 
    176206                ORDER BY 
    177                         state_name"; 
     207                        city_name 
     208                LIMIT 10"; 
    178209 
    179210                $result = $this->db->query($sql); 
     
    184215                return $output; 
    185216        } 
     217        /** 
     218         * Busca os estados brasileiros 
     219         * @return mixed (array ou boolean) 
     220         * @access public 
     221         */ 
     222        function getStates() 
     223        { 
     224                $sql = 
     225                "SELECT 
     226                        id_state, 
     227                        state_name 
     228                FROM 
     229                        phpgw_cc_state 
     230                WHERE 
     231                        id_country = 'BR' 
     232                ORDER BY 
     233                        state_name"; 
     234 
     235                $result = $this->db->query($sql); 
     236                $output = array(); 
     237                while ($row = $result->fetchRow()) 
     238                        $output[] = $row; 
     239 
     240                return $output; 
     241        } 
    186242} 
    187243?> 
Note: See TracChangeset for help on using the changeset viewer.