source: sipes/0.3-modules/ente_planificador_sector/includes/views/views_handler_filter_ente_organismo.inc @ 303fae2

stableversion-3.0
Last change on this file since 303fae2 was 303fae2, checked in by José Gregorio Puentes <jpuentes@…>, 9 años ago

se agregaron los modulos

  • Propiedad mode establecida a 100755
File size: 5.0 KB
Línea 
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_organismo_publ.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&#241;o-mes-dia)
29  * @version 0.2 // (0.1)
30  *
31  */
32
33/**
34 * Generar filtro por organismo Prublico en views
35 */
36class views_handler_filter_ente_organismo extends views_handler_filter_many_to_one {
37  function get_value_options() { }
38  function value_form(&$form, &$form_state) {
39    global $user;
40    //$ente_planificador = node_load($user->entes);
41    $options[0] = "Seleccione";
42    $nivel = 2;
43    $result = db_query("SELECT n.nid, n.title FROM {node} AS n INNER JOIN {ente_planificador_hierarchical} AS e ON n.nid = e.nid WHERE level = %d", $nivel);
44    while ($row = db_fetch_object($result)) {
45      $options[$row->nid] = $row->title;
46    }
47    $form['value']['organismo'] = array(
48      '#type' =>'select',
49      '#options' => $options,
50    );
51  }
52
53  /**
54   * Provide the basic form which calls through to subforms.
55   * If overridden, it is best to call through to the parent,
56   * or to at least make sure all of the functions in this form
57   * are called.
58   */
59  function options_form(&$form, &$form_state) {
60    if ($this->can_expose()) {
61      $this->show_expose_button($form, $form_state);
62    }
63    $form['op_val_start'] = array('#value' => '<div class="clear-block">');
64    $this->show_operator_form($form, $form_state);
65    $this->show_value_form($form, $form_state);
66    $this->value_submit($form, $form_state);
67    $form['op_val_end'] = array('#value' => '</div>');
68    if ($this->can_expose()) {
69      $this->show_expose_form($form, $form_state);
70    }
71    //excluyendo el campo
72    if ($this->options['exposed'] == 1) {
73      $roles = user_roles();
74      $form['fieldset_roles'] = array(
75        '#type' => 'fieldset',
76        '#title' => t('Excluir Filtros'),
77        '#weight' => 0,
78      );
79      $form['fieldset_roles']['roles_exclude_organismo'] = array(
80        '#type' => 'checkboxes',
81        '#weight' => 0,
82        '#title' => t('Excluir Filtros por roles de la Presentacion'),
83        '#options' => $roles,
84        '#default_value' => variable_get('roles_exclude_organismo', 0),
85        '#description' => t('Seleccione los roles para escluir los filtros.'),
86      );
87      /*$opciones['0']= "Seleccione";
88      $opciones = entes_planificadores_obtiene_tipos();
89      $form['fieldset_roles']['nivel_planificacion'] = array(
90        '#title' => t('Nivel del ente Planificador al que se le ha de presentar el filtro'),
91        '#type' =>'select',
92        '#options' => $opciones,
93        '#default_value' => $this->options['fieldset_roles']['nivel_planificacion'],
94      );*/
95    }
96  }
97 
98 /**
99   * Perform any necessary changes to the form values prior to storage.
100   * There is no need for this function to actually store the data.
101   */
102  function value_submit($form, &$form_state) {
103    if (isset($form_state['values']['options']['fieldset_roles']['roles_exclude_organismo'])) {
104      variable_set('roles_exclude_organismo', $form_state['values']['options']['fieldset_roles']['roles_exclude_organismo']);
105    }
106    /*if (isset($form_state['values']['options']['fieldset_roles']['nivel_planificacion'])) {
107      variable_set('nivel_planificacion_'.$form_state['values']['options']['identifier'], $form_state['values']['options']['fieldset_roles']['nivel_planificacion']);
108    }*/
109  }
110
111  function query() {
112    $aid = explode('_',$this->field);
113    $aid = $aid[1];
114    $this->ensure_my_table();
115    $field = "organismo";
116    $upper = '';
117    $operation_attribute = "=";
118    if($this->operator == 'not in') {
119      $operation_attribute = '<>';
120    }
121    if(!is_array($this->value)) {
122      $this->value = array($this->value);
123    }
124    foreach ($this->value as &$value) {
125      if ($value) {
126        $this->query->add_where($this->options['group'], "$upper(%s) %s  %d", $field, $operation_attribute, $value);
127      }
128    }
129  }
130}
Nota: Vea TracBrowser para ayuda de uso del navegador del repositorio.