[303fae2] | 1 | <?php |
---|
| 2 | |
---|
| 3 | /** |
---|
| 4 | * |
---|
| 5 | * Sistema Automatizado para la Planificación Estratégico-Situacional en la Administración Pública Venezolana |
---|
| 6 | * @file handler_field_ente_sector.inc |
---|
| 7 | * Drupal part Module to install ente planificador module |
---|
| 8 | * Copyright 2011 Sistema Automatizado para la Planificación Estratégico-Situacional en la Administración Pública Venezolana (CENDITEL) |
---|
| 9 | * |
---|
| 10 | * This program is free software; you can redistribute it and/or modify |
---|
| 11 | * it under the terms of the GNU General Public License as published by |
---|
| 12 | * the Free Software Foundation; either version 2 of the License, or |
---|
| 13 | * (at your option) any later version. |
---|
| 14 | * |
---|
| 15 | * This program is distributed in the hope that it will be useful, |
---|
| 16 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
---|
| 17 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
---|
| 18 | * GNU General Public License for more details. |
---|
| 19 | * |
---|
| 20 | * You should have received a copy of the GNU General Public License |
---|
| 21 | * along with this program; if not, write to the Free Software |
---|
| 22 | * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA |
---|
| 23 | * |
---|
| 24 | * Probado con un servidor Apache 2.0, |
---|
| 25 | * Postgresql version 7.4.7 y 8.1 mysql 5.0.32 y PHP version 4.3.11 y 5.2.0-8 |
---|
| 26 | * |
---|
| 27 | * @author Cenditel Merida - Ing. Jose Puentes |
---|
| 28 | * @date 2014-11-19 // (año-mes-dia) |
---|
| 29 | * @version 0.2 // (0.1) |
---|
| 30 | * |
---|
| 31 | */ |
---|
| 32 | |
---|
| 33 | /** |
---|
| 34 | * Generar filtro por sector en views |
---|
| 35 | */ |
---|
| 36 | class views_handler_filter_user_ente extends views_handler_filter_many_to_one { |
---|
| 37 | function get_value_options() { } |
---|
| 38 | function value_form(&$form, &$form_state) { |
---|
| 39 | $tid = variable_get('ente_planificador_sector_Ambitos', 0); |
---|
| 40 | $terms = taxonomy_get_tree($tid); |
---|
| 41 | $options['0']= "seleccione"; |
---|
| 42 | foreach($terms as $term) { |
---|
| 43 | if($term->depth == 1) { //si el termino es padre |
---|
| 44 | $options[$term->tid] .= $term->name; |
---|
| 45 | } |
---|
| 46 | } |
---|
| 47 | $form['value']['sector'] = array( |
---|
| 48 | '#type' =>'select', |
---|
| 49 | '#options' => $options, |
---|
| 50 | // '#default_value' => $this->value['sector'], |
---|
| 51 | ); |
---|
| 52 | } |
---|
| 53 | function query() { |
---|
| 54 | $aid = explode('_',$this->field); |
---|
| 55 | $aid = $aid[1]; |
---|
| 56 | $this->ensure_my_table(); |
---|
| 57 | $field = "$this->table_alias.$this->real_field"; |
---|
| 58 | $upper = ''; |
---|
| 59 | $operation_attribute = "="; |
---|
| 60 | if($this->operator == 'not in') { |
---|
| 61 | $operation_attribute = '<>'; |
---|
| 62 | } |
---|
| 63 | if(!is_array($this->value)) { |
---|
| 64 | $this->value = array($this->value); |
---|
| 65 | } |
---|
| 66 | foreach ($this->value as &$value) { |
---|
| 67 | if ($value) { |
---|
| 68 | $this->query->add_where($this->options['group'], "$upper(%s) %s %d", $field, $operation_attribute, $value); |
---|
| 69 | } |
---|
| 70 | } |
---|
| 71 | } |
---|
| 72 | } |
---|