Conjunto de cambios 92f109b en sipes para 0.3-modules/ente_planificador_sector


Ignorar:
Fecha y hora:
09/06/2016 11:31:50 (hace 8 años)
Autor:
eramirez <eramirez@…>
Branches:
stable, version-3.0
Children:
a7e2cc0
Parents:
7d9e4be
Mensaje:

se modifico lo referente a las fechas de los procesos

Fichero:
1 editado

Leyenda

No modificado
Añadido
Eliminado
  • 0.3-modules/ente_planificador_sector/ente_planificador_sector.module

    r3b8331b r92f109b  
    475475    }
    476476    //recorer todos los ambitos
    477                 $tid = variable_get('ente_planificador_sector_Ambitos', 0);
    478         $terms = taxonomy_get_tree($tid);
     477    $tid = variable_get('ente_planificador_sector_Ambitos', 0);
     478    $terms = taxonomy_get_tree($tid);
    479479    foreach ($terms as $term) {           
    480480      $row = array();
    481481      if ($term->depth == 0) { //si el termino es padre (AMBITO)
    482                 $fechas[0] = variable_get('ente_planificador_' . $type_node . '_all_from_' . $term->tid, $now);
    483                 $fechas[1] = variable_get('ente_planificador_' . $type_node . '_all_until_' . $term->tid, $now);
     482        $fechas[0] = variable_get('ente_planificador_' . $type_node . '_all_from_' . $term->tid, $now);
     483        $fechas[1] = variable_get('ente_planificador_' . $type_node . '_all_until_' . $term->tid, $now);
    484484        $FIPM = $fechas[0];
    485485        $FFPM = $fechas[1];
     
    502502      $fechas_display = FALSE;
    503503    }
    504                 $aux = "";
     504    $aux = "";
    505505    if (module_exists('proyectos_operativos_mail')) {
    506506      $aux = l(t("Enviar Correo Electrónico a los entes planificadores por Ambito Social."), 'fechas_planificacion/notificacion/envia_email/ambito/' . $type_node);
    507                 }
     507    }
    508508    if (user_access('admin planificador')) {
    509509      $FIPMA = variable_get('ente_planificador_' . $type_node . '_admin_from', $now);
     
    919919    //anadiendo el campo nivel de planificacion
    920920    $nivel_planificacion = ente_planificador_sector_nivel_planificacion();
    921         //SOLO DEJE A UN ENTE SER ENTE PLANIFICADOR MACRO
    922         if (db_result(db_query("SELECT nid FROM {ente_planificador} where tipo = '1'")) > 0) {
    923         unset($nivel_planificacion[1]);
    924         }
     921    //SOLO DEJE A UN ENTE SER ENTE PLANIFICADOR MACRO
     922    if (db_result(db_query("SELECT nid FROM {ente_planificador} where tipo = '1'")) > 0) {
     923      unset($nivel_planificacion[1]);
     924    }
    925925    $default = array(0);
    926926    if ($form['#node']->nid) {
     
    930930      $default = $entes->tipo;
    931931    }
    932                 $form['nivel'] = array(
     932    $form['nivel'] = array(
    933933      '#type' => 'fieldset',
    934                         '#prefix' => '<div id="ente-planificador-sector-wrapper">',
    935                         '#suffix' => '</div>',
     934      '#prefix' => '<div id="ente-planificador-sector-wrapper">',
     935      '#suffix' => '</div>',
    936936    );         
    937                 $form['tipo'] = array(
     937    $form['tipo'] = array(
    938938      '#type' => 'select',
    939939      '#title' => t('Nivel de Planificación'),
     
    943943      '#required' => TRUE,
    944944      '#weight' => -1,
    945                         '#ahah' => array(
     945      '#ahah' => array(
    946946        'event' => 'change',
    947947        'path' => 'ente_planificador_sector_util',
     
    949949        'method' => 'replace',
    950950        'progress' => array('type' => 'bar', 'message' => t('Please wait...')),
    951                         ),
    952                         '#prefix' => '<div id="nivel">',
    953                         '#suffix' => '</div>',
     951      ),
     952      '#prefix' => '<div id="nivel">',
     953      '#suffix' => '</div>',
    954954    );
    955955       
    956                 //anadiendo el campo sector
    957                 $options = array();
     956    //anadiendo el campo sector
     957    $options = array();
    958958    if ($form['#node']->nid) {
    959959      $nid = $form['#node']->nid;
     
    970970      }
    971971    }
     972    $parent = 0;
     973    $parent = taxonomy_get_parents($default);
     974
     975    $form['nivel']['ambito'] = array(
     976      '#type' => 'hidden',
     977      '#value' => key($parent),
     978    );
    972979    $form['nivel']['sector'] = array(
    973980      '#type' => 'select',
     
    976983      '#required' => TRUE,
    977984      '#options' => $options,
    978                         '#prefix' => '<div id="sector_ente_planificador">',
    979                         '#suffix' => '</div>',
     985      '#prefix' => '<div id="sector_ente_planificador">',
     986      '#suffix' => '</div>',
    980987    );
    981                 //anadiendo el campo organismos_publicos
    982                 $options = array();
     988    //anadiendo el campo organismos_publicos
     989    $options = array();
    983990    $options[0] = "seleccione";
    984991    $tid = variable_get('ente_planificador_sector_organismos', 0);
    985992    $terms = taxonomy_get_tree($tid);
    986                 $default = 0;
     993    $default = 0;
    987994    if ($form['#node']->nid) {
    988                         $default = db_result(db_query("SELECT organismo FROM {ente_planificador} WHERE nid = %d", $form['#node']->nid));
    989                 }
     995      $default = db_result(db_query("SELECT organismo FROM {ente_planificador} WHERE nid = %d", $form['#node']->nid));
     996    }
    990997    foreach ($terms as $term) {
    991998      $options[$term->tid] = $term->name;
    992999    }
    993                 $form['nivel']['ente_adscrito'] = array(
     1000    $form['nivel']['ente_adscrito'] = array(
    9941001      '#type' => 'select',
    9951002      '#title' => t('Organismo Publico al que se esta adscrito'),
     
    9971004      '#required' => TRUE,
    9981005      '#options' => $options,
    999                         '#prefix' => '<div id="organismo">',
    1000                         '#suffix' => '</div>',
     1006      '#prefix' => '<div id="organismo">',
     1007      '#suffix' => '</div>',
    10011008    );
    1002                 //anadiendo el campo sub-ente
    1003           $options = array();
    1004                 $options['0']= "seleccione";
    1005                 $result = db_query("SELECT n.nid, n.title FROM {node} AS n INNER JOIN {ente_planificador} AS e ON n.nid = e.nid WHERE e.ente_adscrito != 0");
    1006                 while ($rows = db_fetch_object($result)) {
    1007                         $options[$rows->nid] = $rows->title;
    1008                 }
    1009                 $default = 0;
     1009    //anadiendo el campo sub-ente
     1010    $options = array();
     1011    $options['0']= "seleccione";
     1012    $result = db_query("SELECT n.nid, n.title FROM {node} AS n INNER JOIN {ente_planificador} AS e ON n.nid = e.nid WHERE e.ente_adscrito != 0");
     1013    while ($rows = db_fetch_object($result)) {
     1014      $options[$rows->nid] = $rows->title;
     1015    }
     1016    $default = 0;
    10101017    if ($form['#node']->nid) {
    1011                         $default = db_result(db_query("SELECT sub_ente FROM {ente_planificador} WHERE nid = %d", $form['#node']->nid));
    1012                 }
    1013                 $form['nivel']['sub_ente'] = array(
     1018      $default = db_result(db_query("SELECT sub_ente FROM {ente_planificador} WHERE nid = %d", $form['#node']->nid));
     1019    }
     1020    $form['nivel']['sub_ente'] = array(
    10141021      '#type' => 'select',
    10151022      '#title' => t('Ente al cual se esta adscrito'),
     
    10171024      '#required' => TRUE,
    10181025      '#options' => $options,
    1019                         '#prefix' => '<div id="sub_ente">',
    1020                         '#suffix' => '</div>',
     1026      '#prefix' => '<div id="sub_ente">',
     1027      '#suffix' => '</div>',
    10211028    ); 
    1022   }
    1023   /*if ($form_id == 'ente_planificador_datos_basicos_forma') {
    1024                 //anadiendo el campo sector
    1025                 $options = array();
    1026     $tid = variable_get('ente_planificador_sector_Ambitos', 0);
    1027     $terms = taxonomy_get_tree($tid);
    1028     $options['0']= "seleccione";
    1029     foreach ($terms as $term) {
    1030       if ($term->depth == 1) { //si el termino es padre
    1031         $options[$term->tid] .= $term->name;
    1032       }
    1033     }
    1034     $ente_planificador = NULL;
    1035     $nid = $form['ente_planificador_nid']['#default_value'];
    1036     if (is_numeric($nid)) {
    1037       $ente_planificador = ente_planificador_leer_ente_planificadores($nid);
    1038     }
    1039     if ($ente_planificador && $ente_planificador->tipo == 2) {
    1040       $form['nivel'] = array(
    1041         '#type' => 'fieldset',
    1042                           '#prefix' => '<div id="ente-planificador-sector-wrapper">',
    1043                           '#suffix' => '</div>',
    1044       );
    1045       $form['nivel']['sector'] = array(
    1046         '#type' => 'select',
    1047         '#title' => t('Sector Social'),
    1048         '#default_value' => $ente_planificador->sector,
    1049         '#required' => TRUE,
    1050         '#options' => $options,
    1051                         '#prefix' => '<div id="sector_ente_planificador">',
    1052                         '#suffix' => '</div>',
    1053       );
    1054       $form['#submit'][] = 'ente_planificador_sector_datos_basicos_forma_submit';
    1055     }
    1056   }*/
    1057 }
    1058 
    1059 /**
    1060  *
    1061  *
    1062 function ente_planificador_sector_datos_basicos_forma_submit($form, &$form_state) {
    1063   $terms = taxonomy_get_parents($form_state['values']['sector']);
    1064   foreach ($terms as $tid => $term) {
    1065                 $tid = $term->tid;
    1066         }
    1067         $node_load = node_load($form_state['values']['ente_planificador_nid']);
    1068         if ($tid) {
    1069           $node_load->ambito = $tid;
    1070           $node_load->sector = $form_state['values']['sector'];
    1071           $node_load->revision = 1;
    1072           node_save($node_load);
    1073         }
    1074 }*/
     1029  }
     1030}
    10751031
    10761032/*
     
    14181374        }
    14191375      }
     1376      else {
     1377        if (isset($node->sector)) {
     1378          $parent = taxonomy_get_parents($node->sector);
     1379          $node->ambito = key($parent);
     1380        }
     1381      }
    14201382    }
    14211383    if ($op == 'view') {
     
    14271389          '#suffix'=>'</p>',     
    14281390        );
    1429                         }
    1430       if ($node->sector) {
     1391      }
     1392      if ($node->tipo > 1 && $node->sector && $node->ambito) {
    14311393        $tid = check_plain($node->sector);
    14321394        $term = taxonomy_get_term($tid);
     
    14371399          '#suffix'=>'</p>',     
    14381400        );
    1439         $terms = taxonomy_get_parents($tid);
    1440         foreach ($terms as $tid => $term) {
    1441                                         $name = $term->name;
    1442                                 }
     1401        $term = taxonomy_get_term($node->ambito);
    14431402        $node->content['ambito']  = array(
    14441403          '#prefix'=>'<p align="left">',
    1445           '#value' => "<b>" . t('Ambito:') . "</b> " . $name . "<br>",
     1404          '#value' => "<b>" . t('Ambito:') . "</b> " . $term->name . "<br>",
    14461405          '#weight' => 1,
    14471406          '#suffix'=>'</p>',     
     
    16271586 */
    16281587function ente_planificador_sector_js_util() {
    1629         $tipo = 'nivel';
     1588  $tipo = 'nivel';
    16301589  $form_state = array('submitted' => FALSE);
    16311590  $form_build_id = $_POST['form_build_id'];
     
    16341593  // process it. We retreive the cached form, add the element, and resave.
    16351594  $form = form_get_cache($form_build_id, $form_state);
    1636         if ($_POST['tipo'] != 1) {     
    1637                 $new_form['nivel'] = array(     
    1638             '#type' => 'fieldset',     
    1639         );
    1640         }              
     1595  if ($_POST['tipo'] != 1) {   
     1596    $new_form['nivel'] = array(
     1597      '#type' => 'fieldset',   
     1598    );
     1599  }     
    16411600  if ($_POST['tipo'] == 2) {
    1642                 $options = array();
    1643                 $tid = variable_get('ente_planificador_sector_Ambitos', 0);
     1601    $options = array();
     1602    $tid = variable_get('ente_planificador_sector_Ambitos', 0);
    16441603    $terms = taxonomy_get_tree($tid);
    16451604    $options['0']= "seleccione";
     
    16491608      }
    16501609    }
    1651                 $new_form['nivel']['sector'] = array(
     1610    $new_form['nivel']['sector'] = array(
    16521611      '#title' => t('Sector Social'),
    1653         '#type' => 'select',
     1612      '#type' => 'select',
    16541613      '#required' => TRUE,
    16551614      '#options' => $options,
    1656                         '#prefix' => '<div id="sector_ente_planificador">',
    1657                         '#suffix' => '</div>',
     1615      '#prefix' => '<div id="sector_ente_planificador">',
     1616      '#suffix' => '</div>',
    16581617    );
    1659                 $form[$tipo]['sector'] = $new_form['sector'];
    1660         }
    1661         if ($_POST['tipo'] == 3) {
    1662           $options = array();
    1663                 $options[0] = "seleccione";
     1618    $form[$tipo]['sector'] = $new_form['sector'];
     1619  }
     1620  if ($_POST['tipo'] == 3) {
     1621    $options = array();
     1622    $options[0] = "seleccione";
    16641623    $tid = variable_get('ente_planificador_sector_organismos', 0);
    16651624    $terms = taxonomy_get_tree($tid);
     
    16671626      $options[$term->tid] = $term->name;
    16681627    }
    1669                 $new_form['nivel']['ente_adscrito'] = array(
    1670           '#type' => 'select',
    1671           '#title' => t('Organismo Publico al que se esta adscrito'),
    1672           '#required' => TRUE,
    1673           '#options' => $options,
    1674                         '#prefix' => '<div id="organismo">',
    1675                   '#suffix' => '</div>',
    1676           );
    1677                 $form[$tipo]['ente_adscrito'] = $new_form['ente_adscrito'];
    1678         }
    1679         if ($_POST['tipo'] == 4) {
    1680           $options = array();
    1681                 $options['0']= "seleccione";
    1682                 $result = db_query("SELECT n.nid, n.title FROM {node} AS n INNER JOIN {ente_planificador} AS e ON n.nid = e.nid WHERE e.ente_adscrito != 0");
    1683                 while ($rows = db_fetch_object($result)) {
    1684                         $options[$rows->nid] = $rows->title;
    1685                 }
    1686                 $new_form['nivel']['sub_ente'] = array(
    1687           '#type' => 'select',
    1688           '#title' => t('Ente al cual se esta adscrito'),
    1689           '#required' => TRUE,
    1690           '#options' => $options,
    1691                         '#prefix' => '<div id="sub_ente">',
    1692                 '#suffix' => '</div>',
    1693                 );
    1694                 $form[$tipo]['sub_ente'] = $new_form['sub_ente'];
    1695         }
     1628    $new_form['nivel']['ente_adscrito'] = array(
     1629      '#type' => 'select',
     1630      '#title' => t('Organismo Publico al que se esta adscrito'),
     1631      '#required' => TRUE,
     1632      '#options' => $options,
     1633      '#prefix' => '<div id="organismo">',
     1634      '#suffix' => '</div>',
     1635    );
     1636    $form[$tipo]['ente_adscrito'] = $new_form['ente_adscrito'];
     1637  }
     1638  if ($_POST['tipo'] == 4) {
     1639    $options = array();
     1640    $options['0']= "seleccione";
     1641    $result = db_query("SELECT n.nid, n.title FROM {node} AS n INNER JOIN {ente_planificador} AS e ON n.nid = e.nid WHERE e.ente_adscrito != 0");
     1642    while ($rows = db_fetch_object($result)) {
     1643      $options[$rows->nid] = $rows->title;
     1644    }
     1645    $new_form['nivel']['sub_ente'] = array(
     1646      '#type' => 'select',
     1647      '#title' => t('Ente al cual se esta adscrito'),
     1648      '#required' => TRUE,
     1649      '#options' => $options,
     1650      '#prefix' => '<div id="sub_ente">',
     1651      '#suffix' => '</div>',
     1652    );
     1653    $form[$tipo]['sub_ente'] = $new_form['sub_ente'];
     1654  }
    16961655  $form[$tipo] = $new_form;
    16971656  form_set_cache($form_build_id, $form, $form_state);
     
    17051664  $new_form = $form[$tipo];
    17061665  unset($new_form['#prefix'], $new_form['#suffix']); // Prevent duplicate wrappers.
    1707 
    17081666
    17091667  // Rebuild the form.
     
    17421700        }
    17431701      }
     1702      elseif(isset($user->ambito_user)  && $ente_planificador->tipo == 1 && !(in_array($rol_macro, array_keys($user->roles)))) {
     1703        $term = taxonomy_get_term($user->ambito_user);
     1704        $FIPMI = variable_get('ente_planificador_' . $type_proceso . '_all_from_' . $term->tid, $now);
     1705        $FIPMF = variable_get('ente_planificador_' . $type_proceso . '_all_until_' . $term->tid, $now);
     1706      }
    17441707    }
    17451708    if (is_numeric($ente_planificador) || user_access('admin all planificador')) { //si es el administrador se aplica la fecha especial
     
    17751738  if ($type_proceso) {
    17761739    if (is_object($ente_planificador)) {
    1777       $sector = taxonomy_get_term($ente_planificador->sector);
    1778       $ambito = taxonomy_get_term($ente_planificador->ambito);
    1779       $mi_fecha = array(
    1780         variable_get('ente_planificador_' . $type_proceso . '_all_from_' . $ambito->tid, $now),
    1781         variable_get('ente_planificador_' . $type_proceso . '_all_until_' . $ambito->tid, $now),
    1782       );
    1783       if ($expire) {
    1784         $new_mensaje = t("Registrar y/o modificar los Proyectos Operativos para el Ambito %ambito en el Sector %sector no se encuentra disponible, se podra realizar desde el %fechaI hasta %fechaF", array('%ambito' => strtoupper($ambito->name), '%sector' => strtoupper($sector->name), '%fechaI' => format_date($mi_fecha[0]), '%fechaF' => format_date($mi_fecha[1])));
    1785       }
    1786       else {
    1787         $new_mensaje = t("Se podrá registrar y/o modificar los Proyectos Operativos para el Ambito %ambito en el Sector %sector desde el %fechaI hasta %fechaF", array('%ambito' => strtoupper($ambito->name), '%sector' => strtoupper($sector->name), '%fechaI' => format_date($mi_fecha[0]), '%fechaF' => format_date($mi_fecha[1])));
     1740      if ($ente_planificador->ambito) {
     1741        $sector = taxonomy_get_term($ente_planificador->sector);
     1742        $ambito = taxonomy_get_term($ente_planificador->ambito);
     1743        $mi_fecha = array(
     1744          variable_get('ente_planificador_' . $type_proceso . '_all_from_' . $ambito->tid, $now),
     1745          variable_get('ente_planificador_' . $type_proceso . '_all_until_' . $ambito->tid, $now),
     1746        );
     1747        if ($expire) {
     1748          $new_mensaje = t("Registrar y/o modificar los Proyectos Operativos para el Ambito %ambito en el Sector %sector no se encuentra disponible, se podra realizar desde el %fechaI hasta %fechaF", array('%ambito' => strtoupper($ambito->name), '%sector' => strtoupper($sector->name), '%fechaI' => format_date($mi_fecha[0]), '%fechaF' => format_date($mi_fecha[1])));
     1749        }
     1750        else {
     1751          $new_mensaje = t("Se podra registrar y/o modificar los Proyectos Operativos para el Ambito %ambito en el Sector %sector desde el %fechaI hasta %fechaF", array('%ambito' => strtoupper($ambito->name), '%sector' => strtoupper($sector->name), '%fechaI' => format_date($mi_fecha[0]), '%fechaF' => format_date($mi_fecha[1])));
     1752        }
     1753      }
     1754      elseif(isset($user->ambito_user)  && $ente_planificador->tipo == 1 && !(in_array($rol_macro, array_keys($user->roles)))) {
     1755        if (empty($user->ambito_user)) {
     1756          drupal_set_message(t('Especifique el ambito del usuario supervisor.'), 'warning');         
     1757        }
     1758        $ambito = taxonomy_get_term($user->ambito_user);
     1759        $FIPMI = variable_get('ente_planificador_' . $type_proceso . '_all_from_' . $ambito->tid, $now);
     1760        $FIPMF = variable_get('ente_planificador_' . $type_proceso . '_all_until_' . $ambito->tid, $now);
     1761
     1762        if ($expire) {
     1763          $new_mensaje = t("Registrar y/o modificar los Proyectos Operativos para el Ambito %ambito no se encuentra disponible, se podra realizar desde el %fechaI hasta %fechaF", array('%ambito' => strtoupper($ambito->name), '%fechaI' => format_date($FIPMI), '%fechaF' => format_date($FIPMF)));
     1764        }
     1765        else {
     1766          $new_mensaje = t("Se podra registrar y/o modificar los Proyectos Operativos para el Ambito %ambito desde el %fechaI hasta %fechaF", array('%ambito' => strtoupper($ambito->name), '%fechaI' => format_date($FIPMI), '%fechaF' => format_date($FIPMF)));
     1767        }
    17881768      }
    17891769    }
Nota: Vea TracChangeset para ayuda en el uso del visor de conjuntos de cambios.