Changeset 2160 for sandbox/workflow/trunk/inc
- Timestamp:
- 03/04/10 13:29:43 (14 years ago)
- Location:
- sandbox/workflow/trunk/inc
- Files:
-
- 2 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 ?> -
sandbox/workflow/trunk/inc/smarty/wf_plugins/function.wf_autocomplete_input.php
r1935 r2160 28 28 $defaultValues = array( 29 29 'minLength' => 1, 30 'style' => "width: 200px" 30 'style' => "width: 200px", 31 'mode' => "POPULATE_ON_LOAD" 31 32 ); 32 33 $extractParams = array( … … 38 39 'idValue', 39 40 'textValue', 40 'style' 41 'style', 42 'mode' 41 43 ); 42 44 … … 79 81 $extraParams = json_encode($extraParams); 80 82 83 /* se o componente for do tipo padrão (POPULATE_ON_LOAD), não necessita de função para onkeyup */ 84 if ($mode == 'POPULATE_ON_LOAD'){ 85 $inputElement = <<<EOF 86 <input id="$name_input" name="$name_input" type="text" value="$textValue" style="$style" onfocus="checkDataLoaded('$name');" onblur="setTimeout('selectAutocompleteElement(\'$name\')', 500);"/> 87 EOF; 88 } 89 elseif ($mode == 'REPOPULATE_ON_CHANGE'){ 90 $inputElement = <<<EOF 91 <input id="$name_input" name="$name_input" type="text" value="$textValue" style="$style" onblur="setTimeout('selectAutocompleteElement(\'$name\')', 500);" onkeyup="updateCacheRequestsTimeout('$name', '$ajaxClass', '$ajaxMethod', this.value, '$mode')"/> 92 EOF; 93 } 94 95 /* Cria todos os elementos HTML necessários para o componente */ 81 96 $output = <<<EOF 82 97 <input id="$name" name="$name" type="hidden"/> 83 <input id="$name_input" name="$name_input" type="text" value="$textValue" style="$style" onfocus="checkDataLoaded('$name');" onblur="setTimeout('selectAutocompleteElement(\'$name\')', 500);"/>98 $inputElement 84 99 <span id="$name_response"></span> 85 100 <div id="$name_list" class="autocomplete" style="display: none;"></div> 86 <script>autocompleteSelect('$name', '$ajaxClass', '$ajaxMethod', $sep$methodParam$sep, $extraParams);</script>101 <script>autocompleteSelect('$name', '$ajaxClass', '$ajaxMethod', $sep$methodParam$sep, '$mode', $extraParams);</script> 87 102 EOF; 88 103 return $output;
Note: See TracChangeset
for help on using the changeset viewer.