- Timestamp:
- 03/04/10 13:29:43 (14 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
sandbox/workflow/trunk/inc/local/classes/class.wf_location.php
r795 r2160 72 72 c.id_city AS id_city, 73 73 c.city_name AS city_name, 74 c.is_district, 74 75 s.id_state AS id_state, 75 76 s.state_name AS state_name, … … 125 126 * Busca as cidades de um estado 126 127 * @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)) 133 135 return false; 134 136 … … 137 139 return $this->citiesFromState[$state_id]; 138 140 141 $where = ""; 142 if(!$include_districts){ 143 $where = " AND c.is_district = 'F' "; 144 } 145 139 146 $sql = 140 147 "SELECT 141 148 c.id_city AS id_city, 142 c.city_name AS city_name 149 c.city_name AS city_name, 150 c.is_district 143 151 FROM 144 152 phpgw_cc_state s, … … 147 155 c.id_state = s.id_state AND 148 156 s.id_country = 'BR' AND 149 c.id_state = ? 157 c.id_state = ? " . $where . " 150 158 ORDER BY 151 159 city_name"; … … 160 168 } 161 169 /** 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 . " 176 206 ORDER BY 177 state_name"; 207 city_name 208 LIMIT 10"; 178 209 179 210 $result = $this->db->query($sql); … … 184 215 return $output; 185 216 } 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 } 186 242 } 187 243 ?>
Note: See TracChangeset
for help on using the changeset viewer.