Conjunto 0cf8c36 en sipes


Ignorar:
Fecha y hora:
21/08/2017 15:54:47 (hace 7 años)
Autor:
Sipes Apn <root@…>
Branches:
stable
Children:
ca4bae1
Parents:
604b644
Mensaje:

se modifico el manejador para el filtro del anho del proyecto en vidtas

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  
    5757     ),
    5858     'argument' => array(
    59        'handler' => 'views_handler_argument_string',
     59       'handler' => 'views_handler_argument_numeric',
    6060     ),
    6161   );
     
    145145       //proyectos
    146146       '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',
    148149       ),
    149150       'handler_field_proyecto_year' => array(
  • 0.3-modules/proyectos_operativos_mcti/includes/views/views_handler_filter_proyecto_year.inc

    r303fae2 r0cf8c36  
    2626  *
    2727  * @author Cenditel Merida - Ing. Jose Puentes
     28  * @author Cenditel Merida - Phd. Juan Vizcarrondo (update)
    2829  * @date 2014-11-19 // (a&#241;o-mes-dia)
     30  * @date 2017-08-21 // (a&#241;o-mes-dia)
    2931  * @version 0.2 // (0.1)
    3032  *
     
    3436 * Generar filtro por el año del proyecto en views
    3537 */
    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,
     38class 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)'),
    4851    );
    4952  }
    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);
    5961    }
    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);
    6764    }
    6865  }
     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  }
    6972}
Nota: Vea TracChangeset para ayuda en el uso del visor de conjuntos de cambios.