Conjunto 0cf8c36 en sipes
- Fecha y hora:
- 21/08/2017 15:54:47 (hace 7 años)
- Branches:
- stable
- Children:
- ca4bae1
- Parents:
- 604b644
- Ubicación:
- 0.3-modules/proyectos_operativos_mcti/includes/views
- Ficheros:
-
- 2 editados
Leyenda
- No modificado
- Añadido
- Eliminado
-
0.3-modules/proyectos_operativos_mcti/includes/views/proyectos_operativos_mcti.views.inc
r303fae2 r0cf8c36 57 57 ), 58 58 'argument' => array( 59 'handler' => 'views_handler_argument_ string',59 'handler' => 'views_handler_argument_numeric', 60 60 ), 61 61 ); … … 145 145 //proyectos 146 146 'views_handler_filter_proyecto_year' => array( 147 'parent' => 'views_handler_filter_many_to_one', 147 'file' => 'views_handler_filter_proyecto_year.inc', 148 'parent' => 'views_handler_filter_numeric', 148 149 ), 149 150 'handler_field_proyecto_year' => array( -
0.3-modules/proyectos_operativos_mcti/includes/views/views_handler_filter_proyecto_year.inc
r303fae2 r0cf8c36 26 26 * 27 27 * @author Cenditel Merida - Ing. Jose Puentes 28 * @author Cenditel Merida - Phd. Juan Vizcarrondo (update) 28 29 * @date 2014-11-19 // (año-mes-dia) 30 * @date 2017-08-21 // (año-mes-dia) 29 31 * @version 0.2 // (0.1) 30 32 * … … 34 36 * Generar filtro por el año del proyecto en views 35 37 */ 36 class views_handler_filter_proyecto_year extends views_handler_filter_many_to_one { 37 function get_value_options() { } 38 function value_form(&$form, &$form_state) { 39 $years = array(); 40 $years[0] = t('Todos'); 41 $current_year = date("Y"); 42 for($i = $current_year - 10; $i <= $current_year; $i++) { 43 $years[$i] = $i; 44 } 45 $form['value']['year'] = array( 46 '#type' =>'select', 47 '#options' => $years, 38 class views_handler_filter_proyecto_year extends views_handler_filter_numeric { 39 function option_definition() { 40 $options = parent::option_definition(); 41 $options['proyect_year'] = array('default' => FALSE); 42 return $options; 43 } 44 function options_form(&$form, &$form_state) { 45 parent::options_form($form, $form_state); 46 $form['proyect_year'] = array( 47 '#type' => 'checkbox', 48 '#title' => t('Use project year'), 49 '#default_value' => $this->options['proyect_year'], 50 '#description' => t('use project year, when check use current project. if use values in operators these will be add project year (eg value = 2 AND operators Is less than, then year < project_year + 2)'), 48 51 ); 49 52 } 50 function query() { 51 $aid = explode('_',$this->field); 52 $aid = $aid[1]; 53 $this->ensure_my_table(); 54 $field = "$this->table_alias.$this->real_field"; 55 $upper = ''; 56 $operation_attribute = "="; 57 if($this->operator == 'not in') { 58 $operation_attribute = '<>'; 53 function op_between($field) { 54 $year = $this->options['proyect_year'] ? variable_get('proyectos_operativos_anho_creacion', 0) : 0; 55 $is_null = $this->check_for_null($field); 56 $min = $year? $year - $this->value['min'] : $this->value['min']; 57 $max = $year + $this->value['max']; 58 if ($this->operator == 'between') { 59 $this->query->add_where($this->options['group'], "$field >= %d $is_null", $min); 60 $this->query->add_where($this->options['group'], "$field <= %d $is_null", $max); 59 61 } 60 if(!is_array($this->value)) { 61 $this->value = array($this->value); 62 } 63 foreach ($this->value as &$value) { 64 if ($value) { 65 $this->query->add_where($this->options['group'], "$upper(%s) %s %d", $field, $operation_attribute, $value); 66 } 62 else { 63 $this->query->add_where($this->options['group'], "$field <= %d OR $field >= %d $is_null", $min, $max); 67 64 } 68 65 } 66 function op_simple($field) { 67 $year = $this->options['proyect_year'] ? variable_get('proyectos_operativos_anho_creacion', 0) : 0; 68 $value = $year + $this->value['value']; 69 $is_null = $this->check_for_null($field); 70 $this->query->add_where($this->options['group'], "$field $this->operator %d $is_null", $value); 71 } 69 72 }
Nota: Vea TracChangeset
para ayuda en el uso del visor de conjuntos de cambios.