'JS utilities', 'page callback' => 'proyectos_operativos_mcti_proyecto_generales_agrega_talento_js_util', 'access arguments' => array('ver planificador'), 'type' => MENU_CALLBACK, ); $items['proyectos_operativos_mcti_agrega_indicadores_js_util'] = array( 'title' => 'JS utilities', 'page callback' => 'proyectos_operativos_mcti_agrega_indicadores_js_util', 'access arguments' => array('ver planificador'), 'type' => MENU_CALLBACK, ); $items['proyectos_operativos_mcti_proyecto_basico_form_responsables'] = array( 'title' => 'JS utilities', 'page callback' => 'proyectos_operativos_mcti_proyecto_basico_form_responsables_js_util', 'access arguments' => array('ver planificador'), 'type' => MENU_CALLBACK, ); $items['proyectos_operativos_mcti_proyecto_basico_form_cargar_responsables'] = array( 'title' => 'JS utilities', 'page callback' => 'proyectos_operativos_mcti_proyecto_basico_form_cargar_responsables_js_util', 'access arguments' => array('ver planificador'), 'type' => MENU_CALLBACK, ); return $items; } /** * Implementation of hook_theme(). */ function proyectos_operativos_mcti_theme() { $proyectos_operativos_path = drupal_get_path('module', 'proyectos_operativos_mcti') . '/templates'; return array( 'proyectos_operativos_mcti_ficha_proyecto' => array( 'arguments' => array( 'proyecto' => array(), ), 'template' => 'proyectos-operativos-mcti-ficha-proyecto', 'path' => $proyectos_operativos_path, ), ); } /** * Implementation of hook_nodeapi() */ function proyectos_operativos_mcti_nodeapi(&$node, $op, $teaser = NULL, $page = NULL) { switch ($op) { case 'presave': if ($node->type == 'proyectos_operativos') { $zerofill = 5; $num = db_result(db_query("SELECT id FROM {proyectos_operativos} WHERE nid = %d", $node->nid)); $codigo = str_pad($num, $zerofill, '0', STR_PAD_LEFT); $node->field_proyecto_codigo = array(array('value' => $codigo)); $node->title = $codigo; } break; } } /* * Impletations of hook_form_alter() */ function proyectos_operativos_mcti_form_alter(&$form, $form_state, $form_id) { if ($form_id=='views_exposed_form' && $form['#id'] == 'views-exposed-form-ente-planificador-hierarchical-default') {//exclude to filters global $user; $ente = usuario_tiene_ente($user->uid); $ente_planificador = 0; if ($ente && $ente->nid) { $ente_planificador = ente_planificador_leer_ente_planificadores($ente->nid); } if ($ente_planificador->tipo > 1) { $form['ambito']['#access'] = false; $form['#info']['filter-ambito']['label'] = 0; //sector $form['sector']['#access'] = false; $form['#info']['filter-sector']['label'] = 0; } if ($ente_planificador->tipo > 2) { $form['sidp']['#access'] = false; $form['#info']['filter-sidp']['label'] = 0; } } $name_workflow = $form['#wf']->name; if ($form_id == 'workflow_tab_form' && $name_workflow == 'nuevo Proyecto') { drupal_add_js(drupal_get_path('module', 'proyectos_operativos_mcti') . '/js/proyectos_operativos_mcti_datos_basicos.js'); } //mostrar Balance Estimado Nacional de Servicios Energéticos if ($form_id == 'proyectos_operativos_admin_settings') { // formulario datos basicos $form['basicos']['proyectos_operativos_muestra_proyecto_descripcion'] = array( '#type' => 'checkbox', '#title' => t('Recolectar la descripcion del proyecto.'), '#weight' => 0, '#default_value' => variable_get('proyectos_operativos_muestra_proyecto_descripcion', TRUE), ); $form['basicos']['comuna'] = array( '#title' => t('Comunas'), '#type' => 'fieldset', '#prefix' => '
', '#siffix' => '
', ); $form['basicos']['comuna']['proyectos_operativos_muestra_codig_comuna'] = array( '#type' => 'checkbox', '#title' => t('Recolectar el codigo de la comuna.'), '#default_value' => variable_get('proyectos_operativos_muestra_codig_comuna', TRUE), ); $form['basicos']['comuna']['proyectos_operativos_muestra_ubicacin_comuna'] = array( '#type' => 'checkbox', '#title' => t('Recolectar la ubicacion de la comuna.'), '#default_value' => variable_get('proyectos_operativos_muestra_ubicacin_comuna', TRUE), ); $form['basicos']['comuna']['proyectos_operativos_muestra_name_comuna'] = array( '#type' => 'checkbox', '#title' => t('Recolectar el nombre de la comuna.'), '#default_value' => variable_get('proyectos_operativos_muestra_name_comuna', TRUE), ); $form['basicos']['responsables']['proyectos_operativos_muestra_responsables'] = array( '#type' => 'checkbox', '#title' => t('Recolectar los responsables del proyeto.'), '#default_value' => variable_get('proyectos_operativos_muestra_responsables', TRUE), ); $form['basicos']['proyectos_operativos_muestra_causas_abordadas'] = array( '#type' => 'checkbox', '#title' => t('Recolectar las causas abordadas.'), '#weight' => 0, '#default_value' => variable_get('proyectos_operativos_muestra_causas_abordadas', TRUE), ); $form['basicos']['proyectos_operativos_muestra_problemas_abordados'] = array( '#type' => 'checkbox', '#title' => t('Recolectar los problemas abordados.'), '#weight' => 0, '#default_value' => variable_get('proyectos_operativos_muestra_problemas_abordados', TRUE), ); // formulario datos generales $form['generales']['proyectos_operativos_muestra_impacto_ambiental'] = array( '#type' => 'checkbox', '#title' => t('Recolectar el Impacto Ambiental del Proyecto.'), '#default_value' => variable_get('proyectos_operativos_muestra_impacto_ambiental', TRUE), ); $form['generales']['proyectos_operativos_muestra_servicios_balance'] = array( '#type' => 'checkbox', '#title' => t('Recolectar Balance Estimado Nacional de Servicios Energéticos.'), '#default_value' => variable_get('proyectos_operativos_muestra_servicios_balance', TRUE), ); $form['generales']['proyectos_operativos_muestra_programacion_anual'] = array( '#type' => 'checkbox', '#title' => t('Recolectar Programacion Anual por Consumidor.'), '#default_value' => variable_get('proyectos_operativos_muestra_programacion_anual', TRUE), ); } if ($form_id == "proyectos_operativos_proyecto_genera_campos_form") { $node_type = content_types('proyectos_operativos'); $fields = $node_type['fields']; //programacion anual if (variable_get('proyectos_operativos_muestra_impacto_ambiental', TRUE)) { $arreglo['impacto'] = array( 'field_tipo_factores' => 'field_tipo_factores', 'field_factor_impact_multifc' => 'field_factor_impact_multifc', 'field_factor_segun_origen' => 'field_factor_segun_origen', 'field_factor_impact_multiog' => 'field_factor_impact_multiog', 'field_factor_naturaleza' => 'field_factor_naturaleza', 'field_factor_intensidad' => 'field_factor_intensidad', 'field_factor_extension' => 'field_factor_extension', 'field_factor_momento' => 'field_factor_momento', 'field_factor_persistencia' => 'field_factor_persistencia', 'field_factor_reversibilidad' => 'field_factor_reversibilidad', 'field_factor_sinergismo' => 'field_factor_sinergismo', 'field_factor_acumulacion' => 'field_factor_acumulacion', 'field_factor_relacion' =>'field_factor_relacion', 'field_factor_recuperabilidad' => 'field_factor_recuperabilidad', 'field_factor_importancia' => 'field_factor_importancia', 'field_factor_medids_impact' => 'field_factor_medids_impact', ); } if (variable_get('proyectos_operativos_muestra_servicios_balance', TRUE)) { $arreglo['servicios']= array( 'field_balnc_progrmn_anu' => 'field_balnc_progrmn_anu', 'field_balance_fuente' => 'field_balance_fuente', 'field_balanc_tipofuent' => 'field_balanc_tipofuent', 'field_balanc_tipoprod' => 'field_balanc_tipoprod', 'field_balanc_unidmed' => 'field_balanc_unidmed', 'field_balanc_capacid' => 'field_balanc_capacid', 'field_balanc_anho' => 'field_balanc_anho', ); } if (variable_get('proyectos_operativos_muestra_responsables', TRUE)) { $arreglo['responsables']['gerente'] = array( 'field_proyecto_nombre_gere' => 'field_proyecto_nombre_gere', 'field_proyecto_cedul_gere' => 'field_proyecto_cedul_gere', 'field_proyecto_corre_gere' => 'field_proyecto_corre_gere', 'field_proyecto_telef_gere' => 'field_proyecto_telef_gere', ); $arreglo['responsables']['tecnico'] = array( 'field_proyecto_nom_r_tec' => 'field_proyecto_nom_r_tec', 'field_proyecto_ced_r_tec' => 'field_proyecto_ced_r_tec', 'field_proyecto_cor_r_tec' => 'field_proyecto_cor_r_tec', 'field_proyecto_tel_r_tec' => 'field_proyecto_cor_r_tec', 'field_proyecto_und_r_tec' => 'field_proyecto_und_r_tec', ); $arreglo['responsables']['registrador'] = array( 'field_proyecto_nom_r_reg' => 'field_proyecto_nom_r_reg', 'field_proyecto_ced_r_reg' => 'field_proyecto_ced_r_reg', 'field_proyecto_cor_r_reg' => 'field_proyecto_cor_r_reg', 'field_proyecto_tel_r_reg' => 'field_proyecto_tel_r_reg', ); $arreglo['responsables']['administrativo'] = array( 'field_proyecto_nom_r_adm' => 'field_proyecto_nom_r_adm', 'field_proyecto_ced_r_adm' => 'field_proyecto_ced_r_adm', 'field_proyecto_cor_r_adm' => 'field_proyecto_cor_r_adm', 'field_proyecto_tel_r_adm' => 'field_proyecto_tel_r_adm', 'field_proyecto_und_r_adm' => 'field_proyecto_und_r_adm', ); } if (!isset($_SESSION['proyectos_operativos_mostrar_campos'][$form['#node']->nid]) || !count($_SESSION['proyectos_operativos_mostrar_campos'][$form['#node']->nid])) { if (count($fields)) { foreach ($fields as $id => $field) { if (!$field['display_settings']['full']['exclude']) { //programacion anual if (array_key_exists($id, $arreglo['servicios'])) { $arreglo['fields_servicios'][$id] = $field['widget']['label']; } if (array_key_exists($id, $arreglo['impacto'])) { $arreglo['fields_impacto'][$id] = $field['widget']['label']; } if (array_key_exists($id, $arreglo['responsables']['gerente'])) { $arreglo['fields_gerente'][$id] = $field['widget']['label']; } if (array_key_exists($id, $arreglo['responsables']['tecnico'])) { $arreglo['fields_tecnico'][$id] = $field['widget']['label']; } if (array_key_exists($id, $arreglo['responsables']['registrador'])) { $arreglo['fields_registrador'][$id] = $field['widget']['label']; } if (array_key_exists($id, $arreglo['responsables']['administrativo'])) { $arreglo['fields_administrativo'][$id] = $field['widget']['label']; } } elseif (array_key_exists($id, $arreglo['servicios'])) { //programacion anual unset($arreglo['fields_servicios'][$id]); } elseif (array_key_exists($id, $arreglo['impacto']['factor'])) { //programacion anual unset($arreglo['fields_impacto'][$id]); } elseif (array_key_exists($id, $arreglo['responsables']['gerente'])) { //gerente unset($arreglo['fields_gerente'][$id]); } elseif (array_key_exists($id, $arreglo['responsables']['tecnico'])) { //tecnico unset($arreglo['fields_tecnico'][$id]); } elseif (array_key_exists($id, $arreglo['responsables']['registrador'])) { //registrador unset($arreglo['fields_registrador'][$id]); } elseif (array_key_exists($id, $arreglo['responsables']['administrativo'])) { //administrativo unset($arreglo['fields_administrativo'][$id]); } } } } if(count($arreglo['fields_gerente'])) { $form['db']['gerenteg'] = array( '#type' => 'checkboxes', '#options' => $arreglo['fields_gerente'], '#default_value' => array(), '#title' => t('Datos del Gerente'), '#multiple' => TRUE, ); $title_combos['gerenteg']['title'] = t('Datos del Gerente.'); } if(count($arreglo['fields_tecnico'])) { $form['db']['gerentet'] = array( '#type' => 'checkboxes', '#options' => $arreglo['fields_tecnico'], '#default_value' => array(), '#title' => t('Responsable Tecnico'), '#multiple' => TRUE, ); $title_combos['gerentet']['title'] = t('Responsable Tecnico.'); } if (count($arreglo['fields_registrador'])) { $form['db']['gerenter'] = array( '#type' => 'checkboxes', '#options' => $arreglo['fields_registrador'], '#default_value' => array(), '#title' => t('Responsable Registrador'), '#multiple' => TRUE, ); $title_combos['gerenter']['title'] = t('Responsable Registrador.'); } if (count($arreglo['fields_administrativo'])) { $form['db']['gerentea'] = array( '#type' => 'checkboxes', '#options' => $arreglo['fields_administrativo'], '#default_value' => array(), '#title' => t('Responsable administrativo'), '#multiple' => TRUE, ); $title_combos['gerentea']['title'] = t('Responsable Administativo.'); } if (count($arreglo['fields_servicios'])) { ////Balance Estimado Nacional de Servicios Energéticos $form['ip']['servicios'] = array( '#type' => 'checkboxes', '#options' => $arreglo['fields_servicios'], '#default_value' => array(), '#title' => t('Balance Estimado Nacional de Servicios Energéticos'), '#multiple' => TRUE, ); $title_combos['servicios']['title'] = t('Balance Estimado Nacional de Servicios Energéticos'); } if (count($arreglo['fields_impacto'])) { //Impacto Ambiental del Proyecto $form['ip']['impacto'] = array( '#type' => 'checkboxes', '#options' => $arreglo['fields_impacto'], '#default_value' => array(), '#title' => t('Impacto Ambiental del Proyecto'), '#multiple' => TRUE, ); $title_combos['impacto']['title'] = t('Impacto Ambiental del Proyecto'); } $form['#title_combos'] += $title_combos; //$form['#submit'][] = 'proyectos_operativos_proyecto_genera_campos_form_submit'; } // formulario indicadores del proyecto if ($form_id == "proyectos_operativos_proyecto_indicadores_form") { $proyecto_leido = $form['#node']; $node_type = content_types('proyectos_operativos'); $fields = $node_type['fields']; //$form['#proyecto_fields'] = $fields; $field_form = array(); $fields_form = array(); $fields_extra_form = array(); //Programacion anual por consumidor $programacion = variable_get('proyectos_operativos_muestra_programacion_anual', TRUE); $current_year = date("Y"); $years[0] = t('Seleccione'); for ($i = $current_year - 10; $i <= ($current_year + 10); $i++) { $years[$i] = $i; } if ($programacion) { $arreglo['programacion'] = array( 'field_progrmcn_anual_prog' => 'field_progrmcn_anual_prog', 'field_progrmcn_anual_unid' => 'field_progrmcn_anual_unid', 'field_progrmcn_anual_cap' => 'field_progrmcn_anual_cap', 'field_progrmcn_anual_anho' => 'field_progrmcn_anual_anho', ); $form['programacion'] = array( '#type' => 'fieldset', '#title' => t('Programacion Anual por Consumidor'), '#weight' => -1, ); $prefixC = ''; $fields_extra_form1 = array(); foreach ($arreglo['programacion'] as $field_id => $field) { $form['#proyectos_operativos_fields'][] = $field_id; $prefixC .= '' . $fields[$field_id]['widget']['label'] . ''; } $fields_extra_form['programacion'] = $fields_extra_form1; $tamano_array = array(); foreach ($arreglo['programacion'] as $field_id => $field) { $tamano_array[] = count($proyecto_leido->{$field_id}); } $cantidad = max($tamano_array); $prefix = ''; $aux = ''; $aui = ''; for ($i = 0; $i < $cantidad; $i++) { if ($i == 0) { $prefix = '
' . $prefixC . '', ); } elseif ($field == 'field_progrmcn_anual_cap') { $valor = isset($proyecto_leido->{$field_id}[$i]) ? $proyecto_leido->{$field_id}[$i]['value'] : ''; $form['programacion'][$field . '_' . $i] = array( '#type' => 'textfield', '#default_value' => $valor, '#size' => $fields[$field_id]['size'], '#maxlength' => $fields[$field_id]['max_length'], '#prefix' => $prefix, '#suffix' => '', ); } else { $options = optionwidgets_options($fields[$field_id], FALSE); $valor = isset($proyecto_leido->{$field_id}[$i]) ? $proyecto_leido->{$field_id}[$i]['value'] : 0; $form['programacion'][$field . '_' . $i] = array( '#type' => 'select', '#default_value' => $valor, '#options' => $options, '#prefix' => $prefix, '#suffix' => '', ); } $aux = $field_id; $aui = $i; $prefix = ''; } $form['programacion'][$aux . '_' . $aui]['#suffix'] .= '
'; } else { $prefix .= '
'; } foreach ($arreglo['programacion'] as $field_id => $field) { if ($field == 'field_progrmcn_anual_anho') { $valor = isset($proyecto_leido->{$field_id}[$i]) ? $proyecto_leido->{$field_id}[$i]['value'] : ''; $form['programacion'][$field . '_' . $i] = array( '#type' => 'select', '#default_value' => $valor, '#size' => $fields[$field_id]['size'], '#maxlength' => $fields[$field_id]['max_length'], '#required' => $fields[$field_id]['required'], '#options' => $years, '#prefix' => $prefix, '#suffix' => ''; } $form['programacion'][$aux . '_' . $aui]['#suffix'] .= '
'; $form['programacion']['cantidad_programacion'] = array('#type' => 'hidden', '#value' => $cantidad, '#suffix' => '
'); $form['programacion']['agrega_' . 'programacion'] = array( '#type' => 'submit', '#value' => t('Agregar otro campo'), '#weight' => 100, '#ahah' => array( 'path' => 'proyectos_operativos_mcti_agrega_indicadores_js_util/programacion', 'wrapper' => 'programacion-anual-modificar', 'method' => 'replace', 'progress' => array('type' => 'bar', 'message' => t('Please wait...')), ), ); } //Balance Estimado Nacional de Servicios Energéticos if (variable_get('proyectos_operativos_muestra_servicios_balance', TRUE)) { $arreglo['servicios'] = array( 'field_balnc_progrmn_anu' => 'field_balnc_progrmn_anu', 'field_balance_fuente' => 'field_balance_fuente', 'field_balanc_tipofuent' => 'field_balanc_tipofuent', 'field_balanc_tipoprod' => 'field_balanc_tipoprod', 'field_balanc_unidmed' => 'field_balanc_unidmed', 'field_balanc_capacid' => 'field_balanc_capacid', 'field_balanc_anho' => 'field_balanc_anho', ); $form['balance'] = array( '#type' => 'fieldset', '#title' => t('Balance Estimado Nacional de Servicios Energéticos'), '#weight' => -1, ); $prefixC = ''; $fields_extra_form1 = array(); foreach ($arreglo['servicios'] as $field_id => $field) { $form['#proyectos_operativos_fields'][] = $field_id; $prefixC .= '' . $fields[$field_id]['widget']['label'] . ''; } $fields_extra_form['balance'] = $fields_extra_form1; $tamano_array = array(); foreach ($arreglo['servicios'] as $field_id => $field) { $tamano_array[] = count($proyecto_leido->{$field_id}); } $cantidad = max($tamano_array); $prefix = ''; $aux = ''; $aui = ''; for ($i = 0; $i < $cantidad; $i++) { if ($i == 0) { $prefix = '
' . $prefixC . '', ); } elseif ($field == 'field_balanc_capacid') { $valor = isset($proyecto_leido->{$field_id}[$i]) ? $proyecto_leido->{$field_id}[$i]['value'] : ''; $form['balance'][$field . '_' . $i] = array( '#type' => 'textfield', '#default_value' => $valor, '#size' => $fields[$field_id]['size'], '#maxlength' => $fields[$field_id]['max_length'], '#prefix' => $prefix, '#suffix' => '', ); } else { $options = optionwidgets_options($fields[$field_id], FALSE); $valor = isset($proyecto_leido->{$field_id}[$i]) ? $proyecto_leido->{$field_id}[$i]['value'] : 0; $form['balance'][$field . '_' . $i] = array( '#type' => 'select', '#default_value' => $valor, '#options' => $options, '#prefix' => $prefix, '#suffix' => '', ); } $aux = $field_id; $aui = $i; $prefix = ''; } $form['balance'][$aux . '_' . $aui]['#suffix'] .= '
'; } else { $prefix .= '
'; } foreach ($arreglo['servicios'] as $field_id => $field) { if ($field == 'field_balanc_anho') { $valor = isset($proyecto_leido->{$field_id}[$i]) ? $proyecto_leido->{$field_id}[$i]['value'] : ''; $form['balance'][$field . '_' . $i] = array( '#type' => 'select', '#default_value' => $valor, '#maxlength' => $fields[$field_id]['max_length'], '#required' => $fields[$field_id]['required'], '#options' => $years, '#prefix' => $prefix, '#suffix' => ''; } $form['balance'][$aux . '_' . $aui]['#suffix'] .= '
'; $form['balance']['cantidad_balance'] = array('#type' => 'hidden', '#value' => $cantidad, '#suffix' => '
'); $form['balance']['agrega_' . 'balance'] = array( '#type' => 'submit', '#value' => t('Agregar otro campo'), '#weight' => 100, '#ahah' => array( 'path' => 'proyectos_operativos_mcti_agrega_indicadores_js_util/balance', 'wrapper' => 'balance-servicios-modificar', 'method' => 'replace', 'progress' => array('type' => 'bar', 'message' => t('Please wait...')), ), ); } //impacto ambiental del proyecto $arreglo['factor'] = array(); if (variable_get('proyectos_operativos_muestra_impacto_ambiental', TRUE)) { $field_form = array(); $fields_form = array(); $arreglo['factor'] = array( 'field_tipo_factores' => 'field_tipo_factores', 'field_factor_impact_multifc' => 'field_factor_impact_multifc', 'field_factor_segun_origen' => 'field_factor_segun_origen', 'field_factor_impact_multiog' => 'field_factor_impact_multiog', 'field_factor_naturaleza' => 'field_factor_naturaleza', 'field_factor_intensidad' => 'field_factor_intensidad', 'field_factor_extension' => 'field_factor_extension', 'field_factor_momento' => 'field_factor_momento', 'field_factor_persistencia' => 'field_factor_persistencia', 'field_factor_reversibilidad' => 'field_factor_reversibilidad', 'field_factor_sinergismo' => 'field_factor_sinergismo', 'field_factor_acumulacion' => 'field_factor_acumulacion', 'field_factor_relacion' =>'field_factor_relacion', 'field_factor_recuperabilidad' => 'field_factor_recuperabilidad', 'field_factor_importancia' => 'field_factor_importancia', 'field_factor_medids_impact' => 'field_factor_medids_impact', ); $fields_form_factor = array(); if (is_array($fields) && count($fields)) { foreach ($fields as $field_id => $field) { if (array_key_exists($field_id, $arreglo['factor'])) { $field_form[] = $field_id; $fields_form[] = $field_id; $form['#proyectos_operativos_fields'][] = $field_id; } elseif (variable_get('proyectos_operativos_muestra_factor_' . $field_id, FALSE)) { $field_form[] = $field_id; $fields_form[] = $field_id; $form['#proyectos_operativos_fields'][] = $field_id; } } } if (is_array($field_form) && count($field_form)) { module_load_include('inc', 'content', 'includes/content.node_form'); foreach ($field_form as $field_id) { $field = content_fields($field_id, 'proyectos_operativos'); $form['#field_info'][$field_id] = $field; $form += (array) content_field_form($form, $form_state, $field); } } } $submit = array(); foreach ($form['#submit'] as $name) { if ($name == 'proyectos_operativos_proyecto_indicadores_form_submit') { $submit[] = 'proyectos_operativos_mcti_agrega_indicadores_form_submit'; } $submit[] = $name; } $form['#submit'] = $submit; } //formulario datos basicos de los proyectos operativos if ($form_id == "proyectos_operativos_proyecto_basico_form") { global $user; drupal_add_js(drupal_get_path('module', 'proyectos_operativos_mcti') . '/js/proyectos_operativos_mcti_datos_basicos.js'); $node_type = content_types('proyectos_operativos'); $fields = $node_type['fields']; $field_form = array(); $fields_form = array(); $fields_extra_form = array(); $fields_extra_form1 = array(); $form['field_proyecto_codigo']['#access'] = false; //responsables de los proyectos if (variable_get('proyectos_operativos_muestra_responsables', TRUE)) { $arreglo = array(); $fields_extra_form1 = array(); $form['responsables'] = array( '#title' => t(''), '#type' => 'fieldset', '#prefix' => '
', '#suffix' => '
', ); $ente_agregar = $form['#parameters'][3]; $ente_planificador = node_load(1298); if ($proyecto && $proyecto->nid && $proyecto->field_proyecto_ente[0]['nid']) { $ente_planificador = ente_planificador_leer_ente_planificadores($proyecto->field_proyecto_ente[0]['nid']); } else { $ente = usuario_tiene_ente($user->uid); if ($ente && $ente->nid) { $ente_planificador = ente_planificador_leer_ente_planificadores($ente->nid); } elseif($ente_agregar && user_access('admin planificador')) { $ente_planificador = ente_planificador_leer_ente_planificadores($ente_agregar); } } $options[$ente_planificador->nid] = $ente_planificador->title; $form['responsables']['field_proyecto_entes'] = array( '#title' => t('Insitución'), '#type' => 'select', '#options' => $options, '#default_value' => $options, '#prefix' => '
', '#suffix' => '
', ); $arreglo = array(); $tipos = array( 'gerente' => 'gerente', 'tecnico' => 'tecnico', 'registrador' => 'registrador', 'administrativo' => 'administrativo', ); $arreglo['gerente'] = array( 0 => 'field_proyecto_nombre_gere', 1 => 'field_proyecto_cedul_gere', 2 => 'field_proyecto_corre_gere', 3 => 'field_proyecto_telef_gere', ); $arreglo['tecnico'] = array( 0 => 'field_proyecto_nom_r_tec', 1 => 'field_proyecto_ced_r_tec', 2 => 'field_proyecto_cor_r_tec', 3 => 'field_proyecto_tel_r_tec', 4 => 'field_proyecto_und_r_tec', ); $arreglo['registrador'] = array( 0 => 'field_proyecto_nom_r_reg', 1 => 'field_proyecto_ced_r_reg', 2 => 'field_proyecto_cor_r_reg', 3 => 'field_proyecto_tel_r_reg', ); $arreglo['administrativo'] = array( 0 => 'field_proyecto_nom_r_adm', 1 => 'field_proyecto_ced_r_adm', 2 => 'field_proyecto_cor_r_adm', 3 => 'field_proyecto_tel_r_adm', 4 => 'field_proyecto_und_r_adm', ); $fields_form_administrativo = array(); $query["gerente"] = db_query("SELECT DISTINCT(pp.field_proyecto_cedul_gere_value) as field_cedula, pp.field_proyecto_nombre_gere_value as field_nombre, pp.field_proyecto_corre_gere_email as field_email, pp.field_proyecto_telef_gere_value as field_tele FROM {node} as n INNER JOIN {proyectos_operativos} as p ON n.nid=p.nid INNER JOIN {content_type_proyectos_operativos} as pp ON pp.nid = p.nid WHERE n.type='proyectos_operativos' AND p.ente=%d AND n.status=1 AND pp.vid=n.vid ORDER BY pp.field_proyecto_cedul_gere_value DESC", $ente_planificador->nid); $query["tecnico"] = db_query("SELECT DISTINCT(pp.field_proyecto_ced_r_tec_value) as field_cedula, pp.field_proyecto_nom_r_tec_value as field_nombre, pp.field_proyecto_cor_r_tec_email as field_email, pp.field_proyecto_tel_r_tec_value as field_tele, pp.field_proyecto_und_r_tec_value as field_unidad FROM {node} as n INNER JOIN {proyectos_operativos} as p ON n.nid=p.nid INNER JOIN {content_type_proyectos_operativos} as pp ON pp.nid = p.nid WHERE n.type='proyectos_operativos' AND p.ente=%d AND n.status=1 AND pp.vid=n.vid ORDER BY pp.field_proyecto_ced_r_tec_value DESC", $ente_planificador->nid); $query["registrador"] = db_query("SELECT DISTINCT(pp.field_proyecto_ced_r_reg_value) as field_cedula, pp.field_proyecto_nom_r_reg_value as field_nombre, pp.field_proyecto_cor_r_reg_email as field_email, pp.field_proyecto_tel_r_reg_value as field_tele FROM {node} as n INNER JOIN {proyectos_operativos} as p ON n.nid=p.nid INNER JOIN {content_type_proyectos_operativos} as pp ON pp.nid = p.nid WHERE n.type='proyectos_operativos' AND p.ente=%d AND n.status=1 AND pp.vid=n.vid ORDER BY pp.field_proyecto_nom_r_reg_value DESC", $ente_planificador->nid); $query["administrativo"] = db_query("SELECT DISTINCT(pp.field_proyecto_ced_r_adm_value) as field_cedula, field_proyecto_nom_r_adm_value as field_nombre, pp.field_proyecto_cor_r_adm_email as field_email, pp.field_proyecto_tel_r_adm_value as field_tele, pp.field_proyecto_und_r_adm_value as field_unidad FROM {node} as n INNER JOIN {proyectos_operativos} as p ON n.nid=p.nid INNER JOIN {content_type_proyectos_operativos} as pp ON pp.nid = p.nid WHERE n.type='proyectos_operativos' AND p.ente=%d AND n.status=1 AND pp.vid=n.vid ORDER BY pp.field_proyecto_ced_r_adm_value DESC", $ente_planificador->nid); $field_form = array(); $fields_form = array(); $fields_extra_form1 = array(); $fields_extra_form1[] = 'field_proyecto_ente'; foreach ($tipos as $tips => $tip) { $tam = ''; $prefixC = ''; $count = 0; $rows = array(); $options = array(); $options[0] = t('Seleccione'); while ($row = db_fetch_object($query[$tip])) { $options[$row->field_cedula] = $row->field_nombre .'('. $row->field_cedula .')'; $rows[$row->field_cedula] = array( 'name' => $row->field_nombre, 'cedula' => $row->field_cedula, 'email' => $row->field_email, 'phone' => $row->field_tele, 'unidad' => $row->field_unidad, ); } $resposables['responsables'][$tip] = $rows; drupal_add_js($resposables, 'setting'); $options[] = t('Nuevo'); $form['responsables']['default_'.$tip] = array( '#type' => 'select', '#title' => t('Cargar datos del '.$tip), '#default_value' => isset($form['#node']->field_proyecto_ced_r_adm['und'][0]['value']) ? $form['#node']->field_proyecto_ced_r_adm['und'][0]['value'] : 0, '#options' => $options, '#prefix' => '
' . t('Responsable '.$tip ) . '', ); if (count($fields)) { foreach ($arreglo[$tip] as $field_id => $field) { $prefixC .= '' . $fields[$field]['widget']['label'] . ''; } foreach ($arreglo[$tip] as $field_id => $field) { foreach ($form['#node']->{$field} as $id => $campo) { if ($form['#node']->{$field}[$id]['value']) { $default = $form['#node']->{$field}[$id]['value']; } elseif ($form['#node']->{$field}[$id]['email']) { $default = $form['#node']->{$field}[$id]['email']; } else { $default = $form_state['values'][$field]; } } $prefix = ''; if ($count == 0) { $prefix = '
' . $prefixC . '', '#attributes' => array('class' => $tip), ); if($field == 'field_proyecto_cedul_gere' || $field == 'field_proyecto_ced_r_tec' || $field == 'field_proyecto_ced_r_reg' || $field == 'field_proyecto_ced_r_adm') { $form['responsables'][$field]['#attributes']['placeholder'] = t( 'VXXXXXXXX' ); } if($field == 'field_proyecto_telef_gere' || $field == 'field_proyecto_tel_r_tec' || $field == 'field_proyecto_tel_r_reg' || $field == 'field_proyecto_tel_r_adm') { $form['responsables'][$field]['#attributes']['placeholder'] = t( 'xxxx-xxxx-xxx' ); } $aux = $field; $count++; } $form['responsables'][$aux]['#suffix'] .= ''; $form['responsables'][$aux]['#suffix'] .= '
'; } else { $prefix .= ''; } $form['responsables'][$field] = array( '#type' => 'textfield', '#required' => $fields[$field]['required'], '#maxlength' => $fields[$field]['max_length'], '#size' => $fields[$field]['size'], '#weight' => $fields[$field]['weight'], '#description' => $fields[$field]['description'], '#default_value' => $default, '#prefix' => $prefix, '#suffix' => '
'; } } //fin del foreach $form['responsables'][$aux]['#suffix'] .= ''; foreach ($tipos as $tips => $tip) { if (is_array($fields) && count($fields)) { foreach ($fields as $field_id => $field) { foreach ($arreglo[$tip] as $clave => $campo) { if ($campo == $field_id) { $form['#proyectos_operativos_fields'][] = $field_id; $field_form[] = $field_id; $fields_form[] = $field_id; } elseif (variable_get('proyectos_operativos_muestra_gerente_' . $field_id, FALSE)) { $form['#proyectos_operativos_fields'][] = $field_id; $field_form[] = $field_id; $fields_form[] = $field_id; } } } } } $form['#validate'][] = 'proyectos_operativos_mcti_proyecto_basico_form_responsables_validate'; foreach ($form['#submit'] as $id => $name) { if ($name == 'proyectos_operativos_proyecto_basico_form_submit') { $submits[] = 'proyectos_operativos_mcti_proyecto_basico_form_responsables_submit'; } $submits[] = $name; } $form['#submit'] = $submits; }//end responsables //datos de la comuna $field_form = array(); $fields_form = array(); $fields_extra_form1 = array(); $arreglo = array(); $codig_comuna = variable_get('proyectos_operativos_muestra_codig_comuna', TRUE); if ($codig_comuna) { $form['#proyectos_operativos_fields_extra'][] = 'field_proyecto_codigo_comu'; $arreglo['field_proyecto_codigo_comu'] = 'field_proyecto_codigo_comu'; } $ubicacin_comuna = variable_get('proyectos_operativos_muestra_ubicacin_comuna', TRUE); if ($ubicacin_comuna) { $form['#proyectos_operativos_fields_extra'][] = 'field_proyecto_ubicaci_comu'; $arreglo['field_proyecto_ubicaci_comu'] = 'field_proyecto_ubicaci_comu'; } $nombre_comuna = variable_get('proyectos_operativos_muestra_name_comuna', TRUE); if ($nombre_comuna) { $form['#proyectos_operativos_fields_extra'][] = $fields_extra_form1; $arreglo['field_proyecto_nombres_cum'] = 'field_proyecto_nombres_cum'; } if ($codig_comuna || $ubicacin_comuna || $nombre_comuna) { $fields_form_comuna = array(); if (is_array($fields) && count($fields)) { foreach ($fields as $field_id => $field) { if (array_key_exists($field_id, $arreglo)) { $form['#proyectos_operativos_fields'][] = $field_id; $field_form[] = $field_id; $fields_form[] = $field_id; } elseif (variable_get('proyectos_operativos_muestra_comuna_' . $field_id, FALSE)) { $form['#proyectos_operativos_fields'][] = $field_id; $field_form[] = $field_id; $fields_form[] = $field_id; } } } } //localizacion internacional del proyecto $arreglo = array(); $localizacion = variable_get('proyectos_operativos_muestra_ubicaci_interna', TRUE); if ($localizacion) { $arreglo['field_proyecto_ubicaci_inter'] = 'field_proyecto_ubicaci_inter'; if (is_array($fields) && count($fields)) { foreach ($fields as $field_id => $field) { if (array_key_exists($field_id, $arreglo)) { $form['#proyectos_operativos_fields'][] = $field_id; $field_form[] = $field_id; $fields_form[] = $field_id; } elseif (variable_get('proyectos_operativos_muestra_ubicaci_inter_' . $field_id, FALSE)) { $form['#proyectos_operativos_fields'][] = $field_id; $field_form[] = $field_id; $fields_form[] = $field_id; } } } } $descripcion = variable_get('proyectos_operativos_muestra_proyecto_descripcion', TRUE); if ($descripcion) { $arreglo['field_descripcin_proyect'] = 'field_descripcin_proyect'; $form['#proyectos_operativos_fields_extra'][] = 'field_descripcin_proyect'; } $causas = variable_get('proyectos_operativos_muestra_causas_abordadas', TRUE); if ($causas) { $arreglo['field_proyect_cau_abord'] = 'field_proyect_cau_abord'; $form['#proyectos_operativos_fields_extra'][] = 'field_proyect_cau_abord'; } $problemas = variable_get('proyectos_operativos_muestra_problemas_abordados', TRUE); if ($problemas) { $arreglo['field_proyect_probl_abord'] = 'field_proyect_probl_abord'; $form['#proyectos_operativos_fields_extra'][] = 'field_proyect_probl_abord'; } if ($descripcion || $causas || $problemas) { $fields_form_basico = array(); if (is_array($fields) && count($fields)) { foreach ($fields as $field_id => $field) { if (array_key_exists($field_id, $arreglo)) { $form['#proyectos_operativos_fields'][] = $field_id; $field_form[] = $field_id; $fields_form[] = $field_id; } elseif (variable_get('proyectos_operativos_muestra_otros_' . $field_id, FALSE)) { $form['#proyectos_operativos_fields'][] = $field_id; $field_form[] = $field_id; $fields_form[] = $field_id; } } } } //campos causas y problemas abordados con el proyecto if (is_array($field_form) && count($field_form)) { module_load_include('inc', 'content', 'includes/content.node_form'); foreach ($field_form as $field_id) { $field = content_fields($field_id, 'proyectos_operativos'); $form['#field_info'][$field_id] = $field; $form += (array) content_field_form($form, $form_state, $field); } } //Monto Total del Proyecto para el año en curso. $form['field_proyecto_monto_anual']['#pre_render'] = array('proyectos_operativos_mcti_field_proyecto_monto_anual_field_pre_render'); $form['field_proyecto_monto_anual'][0]['#required'] = 0; foreach ($form['#validate'] as $id => $name) { if ($name == 'proyectos_operativos_proyecto_basico_form_validate') { $form['#validate'][$id] = 'proyectos_operativos_mcti_proyecto_basico_form_validate'; } } }//fin del datos basicos if ($form_id == 'views_bulk_operations_form_asignar_proyectos_organismo_page_1') { //modificando el campo usuario a un campo del tipo select $options = array(); global $user; $ente_planificador = node_load($user->entes); $options[0] = 'Seleccione'; $role1 = variable_get('ActorPlanificadorcoordinador1', 0); if ($ente_planificador->tipo == 1 && $role1) { $rol = $role1; } $role2 = variable_get('ActorPlanificadorevisor2', 0); if ($ente_planificador->tipo == 2) { $rol = $role2; } $role3 = variable_get('ActorPlanificadorevisor3', 0); if ($ente_planificador->tipo == 3 && $role3) { $rol = $role3; } $role4 = variable_get('ActorPlanificadorevisor4', 0); if ($ente_planificador->tipo == 4 && $role4) { $rol = $role4; } $title = 0; $op_tt = '!='; $var[0] = $rol; $var[1] = $title; //agregando el campo usuarios if (isset($_GET['title']) && $_GET['title'] != 0) { $op_tt = 'LIKE'; $var[1] = $_GET['title']; } $sql = "SELECT u.name, u.uid, u.nombres, u.apellidos, u.cedula FROM {users} as u INNER JOIN {ente_user_planificador} as e ON u.uid=e.usuario INNER JOIN {ente_planificador} as p ON p.nid=e.nid INNER JOIN {node} as n ON n.nid = p.nid INNER JOIN {users_roles} as r ON r.uid = u.uid WHERE r.rid = %d AND n.title " .$op_tt. " '%s'"; if (isset($_GET['ambito']) && $_GET['ambito'] != 0) { $op_ab = '='; $var[2] = $_GET['ambito']; $sql .= " AND p.ambito " .$op_ab; } $var[3] = 0; if (isset($_GET['sector']) && $_GET['sector'] != 0 ) { $op_st = '='; $var[3] = $_GET['sector']; $sql .= " AND p.sector " .$op_st; } $query = db_query($sql, implode(',', $var)); while ($rows = db_fetch_object($query)) { //datos del usuario a mostrar if ($rows->nombres || $rows->apellidos || $rows->cedula) { $name = $rows->name . ', ' . $rows->nombres . ' ' . $rows->apellidos . '(' . $rows->cedula . ')'; } else { $name = $rows->name; } $options[$rows->uid] = $name; } $form['owner_name'] = array( '#type' => 'select', '#title' => t('Nombre de Usuario que ha de revisar el Proyecto'), '#options' => $options, '#description' => t('Nombre de usuario que se le ha de asignar el proyecto para su revisión.'), ); } if ($form_id == 'proyectos_operativos_proyecto_generales_form') { //modificando el tipo de campo sector $form['field_proyecto_sector']['tids']['#config']['level_labels']['status'] = 1; $form['field_proyecto_sector']['tids']['#config']['level_labels']['labels'][1] = t('Sub-Sector'); //Empleos Generados drupal_add_js(drupal_get_path('module', 'proyectos_operativos_mcti') . '/js/proyectos_operativos_mcti_generales.js'); $form['field_proyecto_efindirecto']['#title'] = t('Empleos Directos Sostenidos Femeninos'); $form['field_proyecto_emdirecto']['#title'] = t('Empleos Directos Nuevos Femeninos'); $form['field_proyecto_efdirecto']['#title'] = t('Empleos Directos Nuevos Masculinos'); $form['field_proyecto_emindirecto']['#title'] = t('Empleos Directos Sostenidos Masculinos'); //total empleos indirectos $arregloI = array( 'field_proyecto_emindirecto' => 'field_proyecto_emindirecto', 'field_proyecto_efindirecto' => 'field_proyecto_efindirecto', ); foreach ($arregloI as $id) { $form[$id]['#pre_render'][] = 'proyectos_operativos_mcti_agregaclaseI_field_pre_render'; } //total de empleos directos $arregloD = array( 'field_proyecto_emdirecto' => 'field_proyecto_emdirecto', 'field_proyecto_efdirecto' => 'field_proyecto_efdirecto', ); foreach ($arregloD as $id) { $form[$id]['#pre_render'][] = 'proyectos_operativos_mcti_agregaclaseD_field_pre_render'; } //total empleos directos femeninos $arregloDf = array( 'field_proyecto_efindirecto' => 'field_proyecto_emindirecto', 'field_proyecto_efdirecto' => 'field_proyecto_efdirecto', ); foreach ($arregloDf as $id) { $form[$id]['#pre_render'][] = 'proyectos_operativos_mcti_agregaclaseDF_field_pre_render'; } //total empleos directos masculinos $arregloDf = array( 'field_proyecto_emindirecto' => 'field_proyecto_efindirecto', 'field_proyecto_emdirecto' => 'field_proyecto_emdirecto', ); foreach ($arregloDf as $id) { $form[$id]['#pre_render'][] = 'proyectos_operativos_mcti_agregaclaseDM_field_pre_render'; } //cargando los valores por defecto. $sumas['empleos']['empleos_estimadosDf'] = 'empleos_estimadosDf'; $sumas['empleos']['empleos_estimadosDm'] = 'empleos_estimadosDm'; $sumas['empleos']['empleos_estimadosD'] = 'empleos_estimadosD'; $sumas['empleos']['empleos_estimadosI'] = 'empleos_estimadosI'; drupal_add_js($sumas, 'setting'); if (variable_get('proyectos_operativos_muestra_beneficiario', TRUE)) { $arreglo = array( 'field_proyecto_beneficiario' => 'field_proyecto_beneficiario', 'field_proyectos_masculino_d' => 'field_proyectos_masculino_d', ); $labels = array( 'field_proyecto_beneficiario' => 'Beneficiario ', 'field_proyectos_masculino_d' => 'Número estimado de beneficiarios masculinos', 'field_proyectos_femenino_i' => 'Número estimado de beneficiarios femeninos', ); if (variable_get('proyectos_operativos_muestra_beneficiarios_indirectos', TRUE)) { $arreglo['field_proyectos_femenino_i'] = 'field_proyectos_femenino_i'; } $prefixC = ''; foreach ($arreglo as $field_id => $field) { $prefixC .= ''.$labels[$field_id].''; } $prefixC .= '' . t('Total') . ''; $node_type = content_types('proyectos_operativos'); $fields = $node_type['fields']; $tamano_array = array(); foreach ($arreglo as $field_id => $field) { $tamano_array[] = count($form['#node']->{$field_id}); } $cantidad_beneficiario = max($tamano_array); for ($i = 0; $i < $cantidad_beneficiario; $i++) { $prefix = ''; if ($i == 0) { $prefix = '*
' . $prefixC . ''; $form['beneficiario'][$aux . '_' . $aui]['#suffix'] .= ''; } $form['beneficiario'][$aux . '_' . $aui]['#suffix'] .= ''; foreach ($arreglo as $field_id => $field) { if ($field_id != 'field_proyecto_beneficiario') { $sumas['beneficiarios']['beneficiarios_' . $field_id] = 'beneficiarios_' . $field_id; $form['beneficiario'][$aux . '_' . $aui]['#suffix'] .= ''; } } $form['beneficiario'][$aux . '_' . $aui]['#suffix'] .= ''; $form['beneficiario'][$aux . '_' . $aui]['#suffix'] .= '
'; } else { $prefix .= '
'; } foreach ($arreglo as $field_id => $field) { $form['beneficiario'][$field_id . '_' . $i]['#prefix'] = $prefix; if ($field_id != 'field_proyecto_beneficiario') { if (!isset($total_arreglo[$field_id])) { $total_arreglo[$field_id] = 0; } $subtotal += (int) $valor; $totales += (int) $valor; $total_arreglo[$field_id] += (int) $valor; } $aux = $field_id; $aui = $i; $prefix = ''; } //total masculino y femenino //excluir los siguientes campos. $form['beneficiario']['field_proyectos_masculino_i'. '_' . $i]['#access'] = false; $form['beneficiario']['field_proyectos_femenino_d'. '_' . $i]['#access'] = false; $form['beneficiario']['field_proyectos_masculino_i'. '_' . $i]['#value'] = 0; $form['beneficiario']['field_proyectos_femenino_d'. '_' . $i]['#value'] = 0; unset($form['beneficiario'][$aux . '_' . $aui]['#suffix']); $form['beneficiario'][$aux . '_' . $aui]['#suffix'] .= '
' . $subtotal . '
' . t('TOTAL DE BENEFICIARIOS') . '
' . $total_arreglo[$field_id] . '
' . $totales . '
'; $form['beneficiario']['agrega_' . 'beneficiario']['#ahah'][ 'path'] = 'proyectos_operativos_mcti_proyecto_generales_agrega_talento_js_util/beneficiario'; foreach ($form['#validate'] as $key => $name) { if ($name == 'proyectos_operativos_proyecto_generales_form_validate'){ $form['#validate'][$key] = 'proyectos_operativos_mcti_proyecto_generales_form_validate'; } } } } } /** * Implementation of proyectos_operativos_proyecto_generales_form_validate(). * Validar formulario de datos generales (proyectos operativos). */ function proyectos_operativos_mcti_proyecto_generales_form_validate($form, &$form_state) { $op = isset($form_state['values']['op']) ? $form_state['values']['op'] : ''; if ($op == t('Cancelar')) { return; } $proyectos_operativos_path = drupal_get_path('module', 'proyectos_operativos'); drupal_add_js($form['#format_number'], 'setting'); drupal_add_js($proyectos_operativos_path . '/js/proyectos_operativos_extra.js'); drupal_add_js($proyectos_operativos_path . '/js/proyectos_operativos_generales.js'); drupal_add_js($form['#sumas'], 'setting'); if (count($form['#proyectos_operativos_fields_extra'])) { foreach($form['#proyectos_operativos_fields_extra'] as $id => $arreglo) { $all_null = TRUE; unset($arreglo[2]); unset($arreglo[3]); $cantidad = $form_state['values']['cantidad_' . $id]; for($i = 0; $i < $cantidad; $i++) { $null = TRUE; $first_campo = FALSE; foreach($arreglo as $campo) { if (!$first_campo) { $first_campo = $campo; } if ($form_state['values'][$campo . '_' . $i] && trim($form_state['values'][$campo . '_' . $i]) != '') { $all_null = FALSE; $null = FALSE; } if ($campo == 'field_proyecto_esfuerzo' || $campo == 'field_proyectos_masculino_d' || $campo == 'field_proyectos_masculino_i' || $campo == 'field_proyectos_femenino_d' || $campo == 'field_proyectos_femenino_i') { $start = $form_state['values'][$campo . '_' . $i]; $value = (int) $start; if ($start != $value) { form_set_error($campo . '_' . $i, t('Solo números enteros son permitidos en el campo %field.' . $start, array('%field' => t($form['#proyecto_fields'][$campo]['widget']['label'])))); } elseif ($value < 0) { form_set_error($campo . '_' . $i, t('Solo números enteros positivos son permitidos en el campo %field.' . $start, array('%field' => t($form['#proyecto_fields'][$campo]['widget']['label'])))); } } } if (!$null) { foreach($arreglo as $campo) { $campos = $form['#proyecto_fields'][$campo]['widget']['label']= 0; if ($campo == 'field_proyectos_masculino_d') { $campos == 'Número estimado de beneficiarios masculinos'; } if ($campo == 'field_proyectos_femenino_i') { $campos == 'Número estimado de beneficiarios femeninos'; } if (trim($form_state['values'][$campo . '_' . $i]) == '') { form_set_error($campo . '_' . $i, t('El campo @campo_name no puede estar vacio', array('@campo_name' => $campos))); } } } } if ($all_null) { form_set_error($first_campo . '_0', t('Debe llenar al menos un campo')); } } } } /** * Guarda los datos de los indicadores */ function proyectos_operativos_mcti_agrega_indicadores_form_submit($form, &$form_state) { //agregando el Balance Estimado Nacional de Servicios Energéticos $op = isset($form_state['values']['op']) ? $form_state['values']['op'] : ''; if ($op != t('Cancelar')) { $tipos = array('programacion', 'balance'); $arreglo['balance'] = array( 'field_balnc_progrmn_anu' => 'field_balnc_progrmn_anu', 'field_balance_fuente' => 'field_balance_fuente', 'field_balanc_tipofuent' => 'field_balanc_tipofuent', 'field_balanc_tipoprod' => 'field_balanc_tipoprod', 'field_balanc_unidmed' => 'field_balanc_unidmed', 'field_balanc_capacid' => 'field_balanc_capacid', 'field_balanc_anho' => 'field_balanc_anho', ); $arreglo['programacion'] = array( 'field_progrmcn_anual_prog' => 'field_progrmcn_anual_prog', 'field_progrmcn_anual_unid' => 'field_progrmcn_anual_unid', 'field_progrmcn_anual_cap' => 'field_progrmcn_anual_cap', 'field_progrmcn_anual_anho' => 'field_progrmcn_anual_anho', ); foreach ($tipos as $keys => $tipo) { $cantidad = $form_state['values']['cantidad_'.$tipo]; for ($i = 0; $i < $cantidad; $i++) { foreach ($arreglo[$tipo] as $campo) { $form_state['values'][$campo][$i] = array('value' => trim($form_state['values'][$campo . '_' . $i])); } } } } } /** * valida las entradas de los responsables del proyecto en el formulario de datos basicos */ function proyectos_operativos_mcti_proyecto_basico_form_responsables_validate($form, &$form_state) { $op = isset($form_state['values']['op']) ? $form_state['values']['op'] : ''; if ($op == t('Cancelar')) { return; } if (trim($form_state['values']['field_proyecto_corre_gere']) && !valid_email_address(trim($form_state['values']['field_proyecto_corre_gere']))) { form_set_error('field_proyecto_corre_gere', t('"%mail" is not a valid email address',array('%mail' => $form_state['values']['field_proyecto_corre_gere']))); } if (trim($form_state['values']['field_proyecto_cor_r_tec']) && !valid_email_address(trim($form_state['values']['field_proyecto_cor_r_tec']))) { form_set_error('field_proyecto_cor_r_tec', t('"%mail" is not a valid email address',array('%mail' => $form_state['values']['field_proyecto_cor_r_tec']))); } if (trim($form_state['values']['field_proyecto_cor_r_reg']) && !valid_email_address(trim($form_state['values']['field_proyecto_cor_r_reg']))) { form_set_error('field_proyecto_cor_r_reg', t('"%mail" is not a valid email address',array('%mail' => $form_state['values']['field_proyecto_cor_r_reg']))); } if (trim($form_state['values']['field_proyecto_cor_r_adm']) && !valid_email_address(trim($form_state['values']['field_proyecto_cor_r_adm']))) { form_set_error('field_proyecto_cor_r_adm', t('"%mail" is not a valid email address',array('%mail' => $form_state['values']['field_proyecto_cor_r_adm']))); } //validacion de la cedula if (!preg_match("/^(V|E){1}([0-9]){8}$/",$form_state['values']['field_proyecto_cedul_gere'])) { form_set_error('field_proyecto_cedul_gere', t('La cédula de identidad %cedula debe tener el formato V00000000 sin puntos.',array('%cedula' => $form_state['values']['field_proyecto_cedul_gere']))); } if (!preg_match("/^(V|E){1}([0-9]){8}$/",$form_state['values']['field_proyecto_ced_r_tec'])) { form_set_error('field_proyecto_ced_r_tec', t('La cédula de identidad %cedula debe tener el formato V00000000 sin puntos.',array('%cedula' => $form_state['values']['field_proyecto_ced_r_tec']))); } if (!preg_match("/^(V|E){1}([0-9]){8}$/",$form_state['values']['field_proyecto_ced_r_reg'])) { form_set_error('field_proyecto_ced_r_reg', t('La cédula de identidad %cedula debe tener el formato V00000000 sin puntos.',array('%cedula' => $form_state['values']['field_proyecto_ced_r_reg']))); } if (!preg_match("/^(V|E){1}([0-9]){8}$/",$form_state['values']['field_proyecto_ced_r_adm'])) { form_set_error('field_proyecto_ced_r_adm', t('La cédula de identidad %cedula debe tener el formato V00000000 sin puntos.',array('%cedula' => $form_state['values']['field_proyecto_ced_r_adm']))); } } /* * Implementation of proyectos_operativos_proyecto_basico_form_validate() * Validar formulario de datos basicos (proyectos operativos). */ function proyectos_operativos_mcti_proyecto_basico_form_validate($form, &$form_state) { $op = isset($form_state['values']['op']) ? $form_state['values']['op'] : ''; if ($op == t('Cancelar')) { return; } $proyectos_operativos_path = drupal_get_path('module', 'proyectos_operativos'); drupal_add_js($proyectos_operativos_path . '/js/proyectos_operativos_extra.js'); drupal_add_js($proyectos_operativos_path . '/js/proyectos_operativos2.js'); //drupal_add_js($form['#format_number'], 'setting'); $form_state['values']['field_proyecto_monto_anual'][0]['value'] = str_replace("", $form['#format_number']['format_number']['thousands_sep'], $form_state['values']['field_proyecto_monto_anual'][0]['value']); $form_state['values']['field_proyecto_monto_anual'][0]['value'] = str_replace(".", $form['#format_number']['format_number']['dec_point'], $form_state['values']['field_proyecto_monto_anual'][0]['value']); $form_state['values']['field_proyecto_total'][0]['value'] = str_replace("", $form['#format_number']['format_number']['thousands_sep'], $form_state['values']['field_proyecto_total'][0]['value']); $form_state['values']['field_proyecto_total'][0]['value'] = str_replace(".", $form['#format_number']['format_number']['dec_point'], $form_state['values']['field_proyecto_total'][0]['value']); // garantizar el formato numerico y no exponencial con numeros grandes if ($form_state['values']['field_proyecto_monto_anual'][0]['value'] != 0) { $form_state['values']['field_proyecto_monto_anual'][0]['value'] = number_format($form_state['values']['field_proyecto_monto_anual'][0]['value'], $form['#format_number']['format_number']['decimals'], '.', ''); } $form_state['values']['field_proyecto_total'][0]['value'] = number_format($form_state['values']['field_proyecto_total'][0]['value'], $form['#format_number']['format_number']['decimals'], '.', ''); if (trim($form_state['values']['field_proyecto_correo'][0]['email']) && !valid_email_address(trim($form_state['values']['field_proyecto_correo'][0]['email']))) { form_set_error('field_proyecto_correo', t('"%mail" is not a valid email address',array('%mail' => $form_state['values']['field_proyecto_correo'][0]['email']))); } if ($form_state['values']['field_proyecto_monto_anual'][0]['value'] < 0) { form_set_error('field_proyecto_monto_anual', t('El monto anual del proyecto no puede ser negativo')); } $start = $form_state['values']['field_proyecto_total'][0]['value']; $value = preg_replace('@[^-0-9]@', '', $start); if ($start != $value) { form_set_error('field_proyecto_total', t('Solo números enteros son permitidos en el monto anual del proyecto.')); } $start = $form_state['values']['field_proyecto_monto_anual'][0]['value']; $value = preg_replace('@[^-0-9]@', '', $start); if ($start != $value) { form_set_error('field_proyecto_monto_anual', t('Solo números enteros son permitidos en el monto total del proyecto')); } if ($form['#count_ae'] && $form['#montos_asignados'] > $value) { form_set_error('field_proyecto_monto_anual', t('El monto anual del proyecto (@monto_proyecto Bs.) es inferior al asignado a las Acciones Específicas (@monto_asignado Bs.)', array('@monto_proyecto' => number_format($value, $form['#format_number']['format_number']['decimals'], $form['#format_number']['format_number']['dec_point'], $form['#format_number']['format_number']['thousands_sep']), '@monto_asignado' => number_format($form['#montos_asignados'], $form['#format_number']['format_number']['decimals'], $form['#format_number']['format_number']['dec_point'], $form['#format_number']['format_number']['thousands_sep'])))); } if ($form_state['values']['field_proyecto_total'][0]['value'] < 0) { form_set_error('field_proyecto_total', t('El monto anual del proyecto no puede ser negativo')); } if ($form_state['values']['field_proyecto_monto_anual'][0]['value'] > $form_state['values']['field_proyecto_total'][0]['value']) { form_set_error('field_proyecto_monto_anual', t('El monto anual debe ser menor o igual al monto total del proyecto')); } //lamentablemente date no valida que from sea menor que to if ($form_state['values']['field_proyecto_fecha_i'][0]['value'] > $form_state['values']['field_proyecto_fecha_f'][0]['value']) { form_set_error('field_proyecto_fecha_i', t('La fecha de inicio debe ser menor a la fecha de culminación')); } //validamos el añofield_proyecto_plurianual $fecha = explode('-', $form_state['values']['field_proyecto_fecha_i'][0]['value']); /* if (is_array($fecha) && count($fecha)) { if ($form['#proyecto_anho'] != $fecha[0]) { form_set_error('field_proyecto_fecha_i',t('El año de inicio del proyecto debe ser igual a @year', array('@year' => $form['#proyecto_anho']))); } } */ if ($form['#count_ae'] && $form['#fechas_validacion']['inicio'] < $form_state['values']['field_proyecto_fecha_i'][0]['value']) { $fecha_dia = explode(' ', $fecha[2]); form_set_error('field_proyecto_fecha_i',t('La fecha de inicio del proyecto (@fecha_inicio) es mayor a la menor fecha de inicio de las Acciones Específicas (@fecha_aei)', array('@fecha_inicio' => $fecha_dia[0] . '-' . $fecha[1] . '-' . $fecha[0], '@fecha_aei' => $form['#fechas_validacion']['inicio_texto']))); } $fecha = explode('-', $form_state['values']['field_proyecto_fecha_f'][0]['value']); /* if (is_array($fecha) && count($fecha)) { if ($form['#proyecto_anho'] != $fecha[0]) { form_set_error('field_proyecto_fecha_f',t('El año de finalización del debe ser igual a @year', array('@year' => $form['#proyecto_anho']))); } } */ if ($form['#count_ae'] && $form['#fechas_validacion']['fin'] > $form_state['values']['field_proyecto_fecha_f'][0]['value']) { $fecha_dia = explode(' ', $fecha[2]); form_set_error('field_proyecto_fecha_f',t('La fecha de culminación del proyecto (@fecha_inicio) es menor a la menor fecha de inicio de las Acciones Específicas (@fecha_aei)', array('@fecha_inicio' => $fecha_dia[0] . '-' . $fecha[1] . '-' . $fecha[0], '@fecha_aei' => $form['#fechas_validacion']['fin_texto']))); } } /** * Agrega los responsables del proyecto */ function proyectos_operativos_mcti_proyecto_basico_form_responsables_submit($form, &$form_state) { $op = isset($form_state['values']['op']) ? $form_state['values']['op'] : ''; if ($op != t('Cancelar')) { $tipos = array('gerente', 'tecnico', 'registrador', 'administrativo', 'ubicacion', 'otros_datos'); $arreglo['gerente'] = array( 0 => 'field_proyecto_nombre_gere', 1 => 'field_proyecto_cedul_gere', 2 => 'field_proyecto_corre_gere', 3 => 'field_proyecto_telef_gere', ); $arreglo['tecnico'] = array( 0 => 'field_proyecto_nom_r_tec', 1 => 'field_proyecto_ced_r_tec', 2 => 'field_proyecto_cor_r_tec', 3 => 'field_proyecto_tel_r_tec', 4 => 'field_proyecto_und_r_tec', ); $arreglo['registrador'] = array( 0 => 'field_proyecto_nom_r_reg', 1 => 'field_proyecto_ced_r_reg', 2 => 'field_proyecto_cor_r_reg', 3 => 'field_proyecto_tel_r_reg', ); $arreglo['administrativo'] = array( 0 => 'field_proyecto_nom_r_adm', 1 => 'field_proyecto_ced_r_adm', 2 => 'field_proyecto_cor_r_adm', 3 => 'field_proyecto_tel_r_adm', 4 => 'field_proyecto_und_r_adm', ); foreach ($tipos as $keys => $tipo) { foreach ($arreglo[$tipo] as $campo) { if (isset($form_state['values'][$campo])) { if ($campo == 'field_proyecto_cor_r_adm' || $campo == 'field_proyecto_cor_r_tec' || $campo == 'field_proyecto_cor_r_reg' || $campo == 'field_proyecto_corre_gere') { $form_state['values'][$campo] = array(array('email' => $form_state['values'][$campo])); } else { $form_state['values'][$campo] = array(array('value' => $form_state['values'][$campo])); } } } } } } /** * Agrega los instituciones responsables */ function proyectos_operativos_proyecto_ente_field_pre_render($element) { global $user; if ($ente) { if (count($element['nid']['nid']['#options'])) { foreach ($element['nid']['nid']['#options'] as $id => $entes){ if ($ente->nid != $id) { unset($element['nid']['nid']['#options'][$id]); } } } } return $element; } /* * Total de empleos Directos */ function proyectos_operativos_mcti_agregaclaseD_field_pre_render($element) { $element[0]['value']['#attributes']['class'] .= ' empleos_estimadosD'; $element[0]['value']['#attributes']['onchange'] .= ";sumaempleos('empleos_estimadosD');"; return $element; } /** * Total empleos directos masculinos */ function proyectos_operativos_mcti_agregaclaseDF_field_pre_render($element) { $element[0]['value']['#attributes']['class'] .= ' empleos_estimadosDf'; $element[0]['value']['#attributes']['onchange'] .= ";sumaempleos('empleos_estimadosDf');"; return $element; } /** * Total de empleos directos masculinos */ function proyectos_operativos_mcti_agregaclaseDM_field_pre_render($element) { $element[0]['value']['#attributes']['class'] .= ' empleos_estimadosDm'; $element[0]['value']['#attributes']['onchange'] .= ";sumaempleos('empleos_estimadosDm');"; return $element; } /** * Total de empleos indirectos */ function proyectos_operativos_mcti_agregaclaseI_field_pre_render($element) { $element[0]['value']['#attributes']['class'] .= ' empleos_estimadosI'; $element[0]['value']['#attributes']['onchange'] .= ";sumaempleos('empleos_estimadosI');"; return $element; } /** * Agrega una clase CSS y ahah a la estructura del campo nid para la institucion de datos basicos */ function proyectos_operativos_mcti_field_proyecto_monto_anual_field_pre_render($element) { $element[0]['value']['#attributes']['disabled'] = 'disabled'; return $element; } /** * Agrega ahah al campo */ function proyectos_operativos_mcti_field_proyecto_monto_total_field_pre_render($element) { $element['value']['NO']['#ahah'] = array( 'event' => 'change', 'path' => 'proyectos_operativos_mcti_proyecto_monto_anual_js/no', 'wrapper' => 'field-proyecto-total-wrraper', 'method' => 'replace', 'progress' => array('type' => 'bar', 'message' => t('Please wait...')), ); $element['value']['SI']['#ahah'] = array( 'event' => 'change', 'path' => 'proyectos_operativos_mcti_proyecto_monto_anual_js/si', 'wrapper' => 'field-proyecto-total-wrraper', 'method' => 'replace', 'progress' => array('type' => 'bar', 'message' => t('Please wait...')), ); // this part may be naughty form_expand_ahah($element['value']['NO']); form_expand_ahah($element['value']['SI']); return $element; } /** * Implementation of hook_action_info(). * asignar los proyectos operativos a los usuarios. */ function proyectos_operativos_mcti_action_info() { return array( 'proyectos_operativos_mcti_action' => array( 'description' => t('Asignar Proyectos para su revision a usuarios'), 'type' => 'node', 'configurable' => true, ), ); } /** * Agrega los datos de la accion */ function proyectos_operativos_mcti_action(&$node, $context) { $owner_name = db_result(db_query("SELECT name FROM {users} WHERE uid = %d", $context['owner_uid'])); $ente_name = db_result(db_query("SELECT title FROM {node} WHERE nid = %d", $context['row']->nid, $context['owner_uid'])); db_query("DELETE FROM {proyectos_operativos_asignados} WHERE nid_node = %d", $context['row']->nid); db_query("INSERT INTO {proyectos_operativos_asignados} (nid_node, uid_users) VALUES(%d, %d)", $context['row']->nid, $context['owner_uid']); drupal_set_message(t('Se asigno el Ente Planificador %ente al usuario %user' , array('%ente'=> $ente_name, '%user' => $owner_name))); } /** * Implementation of a configurable Drupal action. */ function proyectos_operativos_mcti_action_form($context) { module_load_include('inc', 'content', 'includes/content.node_form'); $form = array(); $form['#settings'] = $context['settings']; $form_state = array(); $weight = -100; $fields = array(); // Get the content types of the selected nodes if any. Otherwise, get all types. if (!empty($context['selection']) && isset($context['view'])) { $fields = proyectos_operativos_mcti_action_fields(); } foreach ($fields as $field) { // The field info and widget. $form += (array)$field['form']; if (is_array($form['#node']->{$field['field_name']})) { foreach ($form['#node']->{$field['field_name']} as $v_key => $v_item) { $form[$field['field_name']][$v_key]['#default_value'] = $v_item; } } else { $form[$field['field_name']]['#default_value'] = $form['#node']->{$field['field_name']}; } if (empty($form[$field['field_name']])) continue; } //end foreach return $form; } /** * Defincion de los campos que han de estar disponibles durante la implementacion del hook_action_info */ function proyectos_operativos_mcti_action_fields($type = NULL) { $fields = array(); $fields['owner_name'] = array( 'label' => t('user'), 'form' => array( 'owner_name' => array( '#type' => 'textfield', '#title' => t('Nombre de Usuario'), '#autocomplete_path' => 'user/autocomplete', '#size' => '30', '#maxlength' => '60', '#description' => t('Nombre de usuario al que desea asignar el proyecto'), ), ), ); return $fields; } /** * validando el nombre del usuario */ function proyectos_operativos_mcti_action_validate($form, $form_state) { $count = db_result(db_query("SELECT COUNT(uid) FROM {users} WHERE uid = '%s'", $form_state['values']['owner_name'])); if (intval($count) != 1) { form_set_error('owner_name', t('Please enter a valid username.')); } } /** * implementacion del hook_action_submit() */ function proyectos_operativos_mcti_action_submit($form, $form_state) { // Username can change, so we need to store the ID, not the username. $uid = db_result(db_query("SELECT uid from {users} WHERE uid = '%s'", $form_state['values']['owner_name'])); return array('owner_uid' => $uid); } /* * Creando el permiso para revisar los proyectos */ function proyectos_operativos_mcti_perm() { return array('review proyectos operativos'); } /** * Implementation of hook_views_api(). */ function proyectos_operativos_mcti_views_api() { return array( 'api' => '2.0', 'path' => drupal_get_path('module', 'proyectos_operativos_mcti') . '/includes/views', ); } /** * Implementation of hook_theme_registry_alter(). */ function proyectos_operativos_mcti_theme_registry_alter(&$theme_registry) { if ($theme_registry['proyectos_operativos_proyecto_generales_form']) { $theme_registry['proyectos_operativos_proyecto_generales_form']['function'] = 'theme_proyectos_operativos_mcti_proyecto_generales_form'; } if ($theme_registry['proyectos_operativos_proyecto_indicadores_form']) { $theme_registry['proyectos_operativos_proyecto_indicadores_form']['function'] = 'theme_proyectos_operativos_mcti_proyecto_indicadores_form'; } if ($theme_registry['proyectos_operativos_proyecto_basico_form']) { $theme_registry['proyectos_operativos_proyecto_basico_form']['function'] = 'theme_proyectos_operativos_mcti_proyecto_basico_form'; } } /** * Agrega los nuevos campos en el formulario proyecto en la pestanha generales */ function theme_proyectos_operativos_mcti_proyecto_generales_form($form) { $output = ''; if ($form['#count_ae'] && $form['#montos_asignados'] != $form['#node']->field_proyecto_monto_anual[0]['value']) { $link_acciones = l(t('Modificar Acciones específicas'), 'proyectosopedit/' . $form['#node']->nid . '/ae'); $link_proyecto = l(t('Modificar Monto del Proyecto'), 'proyectosopedit/' . $form['#node']->nid); $format_number = array( 'decimals' => variable_get('proyectos_operativos_number_decimals', 0), 'dec_point' => variable_get('proyectos_operativos_number_dec_point', ','), 'thousands_sep' => variable_get('proyectos_operativos_number_thousands_sep', '.'), ); $mensaje_mostrar = t('Existen @count_ae Acciones Específicas asignadas con un monto total de @montos_asignados Bs, el cual difiere con el monto asignado en el proyecto para el @title_monto_total_proyecto_year (@monto_proyecto). Modifique los montos de las Acciones Específicas en !link_acciones o el monto del proyecto !link_proyecto para poder cerrar el proyecto operativo @nombre_proyecto', array('@count_ae' => $form['#count_ae'], '@montos_asignados' => number_format($form['#montos_asignados'], $format_number['decimals'], $format_number['dec_point'], $format_number['thousands_sep']), '@title_monto_total_proyecto_year' => $form['#proyecto_fields']['field_proyecto_monto_anual']['widget']['label'], '@monto_proyecto' => number_format($form['#node']->field_proyecto_monto_anual[0]['value'], $format_number['decimals'], $format_number['dec_point'], $format_number['thousands_sep']), '!link_acciones' => $link_acciones, '!link_proyecto' => $link_proyecto, '@nombre_proyecto' => $form['#node']->titulo_asignado,)); $output .= '
' . $mensaje_mostrar . '
'; } if ($form['#count_ae'] && $fechas_validacion['inicio'] && $fechas_validacion['fin'] && ($fechas_validacion['inicio_time'] < $fechas_validacion['inicio_current_time'] || $fechas_validacion['fin_current_time'] < $fechas_validacion['fin_time'])) { $link_acciones = l(t('Modificar Acciones específicas'), 'proyectosopedit/' . $form['#node']->nid . '/ae'); $link_proyecto = l(t('Modificar Monto del Proyecto'), 'proyectosopedit/' . $form['#node']->nid); $mensaje_mostrar = t('Existen @count_ae Acciones Específicas asignadas que difieren con la @title_fecha_de_inicio o @title_fecha_de_final del Proyecto. Modifique los montos de las Acciones Específicas en !link_acciones o el monto del proyecto !link_proyecto para poder cerrar el proyecto operativo @nombre_proyecto', array('@count_ae' => $form['#count_ae'], '@title_fecha_de_inicio' => $form['#proyecto_fields']['field_proyecto_fecha_i']['widget']['label'], '@title_fecha_de_final' => $form['#proyecto_fields']['field_proyecto_fecha_f']['widget']['label'], '!link_acciones' => $link_acciones, '!link_proyecto' => $link_proyecto, '@nombre_proyecto' => $form['#node']->titulo_asignado,)); $output .= '
' . $mensaje_mostrar . '
'; } $output .= '
' . t('Clasificación Sectorial del Gasto ONAPRE') . '' . drupal_render($form['field_proyecto_sector']); if (count($form['#fields_form_dg_se'])) { foreach ($form['#fields_form_dg_se'] as $id_c) { $output .= drupal_render($form[$id_c]); } } $output .= '
'; if (variable_get('proyectos_operativos_muestra_talento', TRUE)) { $output .= drupal_render($form['talento']); } if (variable_get('proyectos_operativos_muestra_capacidades', TRUE)) { $output .= drupal_render($form['capacidades']); } $output .= '
' . t('Instituciones') . '' . drupal_render($form['field_proyecto_relacion']); if (count($form['#fields_form_dg_r'])) { foreach($form['#fields_form_dg_r'] as $id_c) { $output .= drupal_render($form[$id_c]); } } $output .= '
'; $output .= '
' . t('Empleos Generados') . '' . t('Nro Estimados de Empleos:'); $output .= ''; $output1 = ''; $arreglo = array( 'field_proyecto_emindirecto' => 'field_proyecto_emindirecto', 'field_proyecto_efindirecto' => 'field_proyecto_efindirecto', ); foreach($arreglo as $empleo) { $output1 .= ''; $form[$empleo][0]['value']['#title'] = ''; $output1 .= ''; } $output1 .= ''; $output1 .= ''; $output1 .= ''; $output1 .= ''; $arreglo = array( 'field_proyecto_efdirecto' => 'field_proyecto_efdirecto', 'field_proyecto_emdirecto' => 'field_proyecto_emdirecto', ); foreach($arreglo as $empleo) { $output1 .= ''; $form[$empleo][0]['value']['#title'] = ''; $output1 .= ''; } $output1 .= ''; $output1 .= ''; $output1 .= ''; $output1 .= ''; $output1 .= ''; $output1 .= ''; $output1 .= ''; $output1 .= ''; $output1 .= ''; $output1 .= ''; $output1 .= ''; $output .= $output1 .'
' . $form[$empleo]['#title'] . '' . drupal_render($form[$empleo]) . '' . t('Total empleos Directos Sostenidos') . '
' . $form[$empleo]['#title'] . '' . drupal_render($form[$empleo]) . '' . t('Total empleos directos Nuevos') . '
' . t('Total de Empleos Masculinos') . '
' . t('Total de Empleos Femeninos') . '
' . t('Total de Empleos Directos') . '
'; if (variable_get('proyectos_operativos_muestra_beneficiario', TRUE)) { $output .= drupal_render($form['beneficiario']); } $output .= '
' . t('Objetivos del Proyecto') . '' . drupal_render($form['field_proyecto_og']) . drupal_render($form['field_proyecto_oe']); if (count($form['#fields_form_dg_o'])) { foreach($form['#fields_form_dg_o'] as $id_c) { $output .= drupal_render($form[$id_c]); } } $output .= '
'; $output .= drupal_render($form); return $output; } /** * Agrega los nuevos campos en el formulario proyecto en la pestanha datos basicos */ function theme_proyectos_operativos_mcti_proyecto_basico_form($form) { $output = ''; $fecha_inicio = $form['#fechas_validacion']['inicio']; if ($form['#count_ae']) { $format_number = array( 'decimals' => variable_get('proyectos_operativos_number_decimals', 0), 'dec_point' => variable_get('proyectos_operativos_number_dec_point', ','), 'thousands_sep' => variable_get('proyectos_operativos_number_thousands_sep', '.'), ); $mensaje_mostrar = t('Existen @count_ae Acciones Específicas asignadas, con un monto total de @montos_asignados Bs asignados. y fechas de Inicio @inicio y fin @fin. Tome en consideración estos valores al momento de modificar los valores de los campos @title_fecha_i, @final title_fecha_f y @title_monto_total_proyecto_year', array('@count_ae' => $form['#count_ae'], '@montos_asignados' => number_format($form['#montos_asignados'], $format_number['decimals'], $format_number['dec_point'], $format_number['thousands_sep']), '@inicio' => $form['#fechas_validacion']['inicio_texto'], '@fin' => $form['#fechas_validacion']['fin_texto'], '@title_fecha_i' => $form['field_proyecto_fecha_i']['#title'], '@final title_fecha_f' => $form['field_proyecto_fecha_f']['#title'], '@title_monto_total_proyecto_year' => $form['field_proyecto_monto_anual']['#title'] )); $output .= '
' . $mensaje_mostrar . '
'; } $output .= '
' . t('Datos Básicos de Identificación del Proyecto'); $output .= '' . drupal_render($form['field_proyecto_titulo']); if (isset($form['field_proyecto_codigo']) && $form['field_proyecto_codigo']['#access']) { $output .= drupal_render($form['field_proyecto_codigo']); } $descripcion = variable_get('proyectos_operativos_muestra_proyecto_descripcion', TRUE); if ($descripcion) { $output .= drupal_render($form['field_descripcin_proyect']); } if (isset($form['field_proyecto_fecha_i']) && $form['field_proyecto_fecha_i']['#access']) { $output .= drupal_render($form['field_proyecto_fecha_i']); } if (isset($form['field_proyecto_fecha_f']) && $form['field_proyecto_fecha_f']['#access']) { $output .= drupal_render($form['field_proyecto_fecha_f']); } if (isset($form['field_proyecto_status']) && $form['field_proyecto_status']['#access']) { $output .= drupal_render($form['field_proyecto_status']); } if (isset($form['field_proyecto_situacion_p']) && $form['field_proyecto_situacion_p']['#access']) { $output .= drupal_render($form['field_proyecto_situacion_p']); } if (isset($form['field_proyecto_plurianual']) && $form['field_proyecto_plurianual']['#access']) { $output .= drupal_render($form['field_proyecto_plurianual']); } if (isset($form['field_proyecto_monto_ant']) && $form['field_proyecto_monto_ant']['#access']) { $output .= drupal_render($form['field_proyecto_monto_ant']); } if (isset($form['field_proyecto_monto_anual']) && $form['field_proyecto_monto_anual']['#access']) { $output .= drupal_render($form['field_proyecto_monto_anual']); } if (isset($form['field_proyecto_monto_prox']) && $form['field_proyecto_monto_prox']['#access']) { $output .= drupal_render($form['field_proyecto_monto_prox']); } if (isset($form['field_proyecto_total']) && $form['field_proyecto_total']['#access']) { $output .= drupal_render($form['field_proyecto_total']); } if (isset($form['field_proyecto_poan']) && $form['field_proyecto_poan']['#access']) { $output .= drupal_render($form['field_proyecto_poan']); } if (is_array($form['#fields_form_ac_d']) && count($form['#fields_form_ac_d'])) { foreach($form['#fields_form_ac_d'] as $id_a) { $output .= drupal_render($form[$id_a]); } } $output .= '
'; $output .= '
' . t('Responsable del Proyecto') . ''; $output .= '
' . check_plain($form['#ente_planificador']->title) . '
'; //responsables del proyecto $responsables_proye = variable_get('proyectos_operativos_muestra_responsables', TRUE); if ($responsables_proye) { $output .= drupal_render($form['responsables']); } $gerentes = variable_get('proyectos_operativos_muestra_gerentes', TRUE); if ($gerentes) { $output .= '
' . t('Gerente del Proyecto') . ''; $output .= '
' . check_plain($form['#ente_planificador']->title) . '
'; if (isset($form['field_proyecto_ente']) && $form['field_proyecto_ente']['#access']) { $output .= drupal_render($form['field_proyecto_ente']); } if (isset($form['field_proyecto_autoridad']) && $form['field_proyecto_autoridad']['#access']) { $output .= drupal_render($form['field_proyecto_autoridad']); } if (isset($form['field_proyecto_lider']) && $form['field_proyecto_lider']['#access']) { $output .= drupal_render($form['field_proyecto_lider']); } if (isset($form['field_proyecto_unidad_a']) && $form['field_proyecto_unidad_a']['#access']) { $output .= drupal_render($form['field_proyecto_unidad_a']); } if (isset($form['field_proyecto_cargo']) && $form['field_proyecto_cargo']['#access']) { $output .= drupal_render($form['field_proyecto_cargo']); } if (isset($form['field_proyecto_telefono']) && $form['field_proyecto_telefono']['#access']) { $output .= drupal_render($form['field_proyecto_telefono']); } if (isset($form['field_proyecto_correo']) && $form['field_proyecto_correo']['#access']) { $output .= drupal_render($form['field_proyecto_correo']); } } $output .= '
'; $pndes = variable_get('proyectos_operativos_muestra_pndes', TRUE); $mcti = variable_get('proyectos_operativos_muestra_mcti', TRUE); $count_ac_p = count($form['#fields_form_ac_p']); $causas = variable_get('proyectos_operativos_muestra_causas_abordadas', TRUE); $problemas = variable_get('proyectos_operativos_muestra_problemas_abordados', TRUE); if ($pndes || $mcti || $count_ac_p || $causas || $problemas) { $output .= '
' . t('Área Estrategica') . ''; if ($pndes) { $output .= drupal_render($form['field_proyecto_pndes']); } if ($mcti) { $output .= drupal_render($form['field_proyecto_mcti']); } if ($count_ac_p) { foreach($form['#fields_form_ac_p'] as $id_a) { $output .= drupal_render($form[$id_a]); } } if($problemas || $causas) { $output .= '
Problemas y causas Abordadas'; if($problemas) { $output .= drupal_render($form['field_proyect_probl_abord']); } if($causas) { $output .= drupal_render($form['field_proyect_cau_abord']); } $output .= '
'; } $output .= '
'; } //area estrategica //ubicacion internacional if (variable_get('proyectos_operativos_muestra_ubicaci_interna', TRUE)) { $output .= '
' . t('Localización del Proyecto') . ''; $output .= '
' . t('Localización Internacional o Nacional') . ''; $output .= drupal_render($form['field_proyecto_ubicaci_inter']); } $output .= '
'; //ubicacion comunal $codig_comuna = variable_get('proyectos_operativos_muestra_codig_comuna', TRUE); $ubicacin_comuna = variable_get('proyectos_operativos_muestra_ubicacin_comuna', TRUE); $nombre_comuna = variable_get('proyectos_operativos_muestra_name_comuna', TRUE); if($codig_comuna || $ubicacin_comuna || $nombre_comuna) { $output .= '
' . t('Localización Comunal') . ''; $output .= drupal_render($form['field_proyecto_codigo_comu']); $output .= drupal_render($form['field_proyecto_nombres_cum']); $output .= drupal_render($form['field_proyecto_ubicaci_comu']); $output .= '
'; } $output .= '
'; $output .= drupal_render($form); return $output; } /** * Agrega los nuevos campos en el formulario proyecto en la pestanha indicadores */ function theme_proyectos_operativos_mcti_proyecto_indicadores_form($form) { $output = ''; if ($form['#count_ae'] && $form['#montos_asignados']!= $form['#node']->field_proyecto_monto_anual[0]['value']) { $format_number = array( 'decimals' => variable_get('proyectos_operativos_number_decimals', 0), 'dec_point' => variable_get('proyectos_operativos_number_dec_point', ','), 'thousands_sep' => variable_get('proyectos_operativos_number_thousands_sep', '.'), ); $link_acciones = l(t('Modificar Acciones específicas'), 'proyectosopedit/' . $form['#node']->nid . '/ae'); $link_proyecto = l(t('Modificar Monto del Proyecto'), 'proyectosopedit/' . $form['#node']->nid); $mensaje_mostrar = t('Existen @count_ae Acciones Específicas asignadas con un monto total de @montos_asignados Bs, el cual difiere con el monto asignado en el proyecto para el @title_monto_total_proyecto_year (@monto_proyecto). Modifique los montos de las Acciones Específicas en !link_acciones o el monto del proyecto !link_proyecto para poder cerrar el proyecto operativo @nombre_proyecto', array('@count_ae' => $form['#count_ae'], '@montos_asignados' => number_format($form['#montos_asignados'], $format_number['decimals'], $format_number['dec_point'], $format_number['thousands_sep']), '@title_monto_total_proyecto_year' => $form['#proyecto_fields']['field_proyecto_monto_anual']['widget']['label'], '@monto_proyecto' => number_format($form['#node']->field_proyecto_monto_anual[0]['value'], $format_number['decimals'], $format_number['dec_point'], $format_number['thousands_sep']), '!link_acciones' => $link_acciones, '!link_proyecto' => $link_proyecto, '@nombre_proyecto' => $form['#node']->titulo_asignado,)); $output .= '
' . $mensaje_mostrar . '
'; } if ($form['#count_ae'] && $fechas_validacion['inicio'] && $fechas_validacion['fin'] && ($fechas_validacion['inicio_time'] < $fechas_validacion['inicio_current_time'] || $fechas_validacion['fin_current_time'] < $fechas_validacion['fin_time'])) { $link_acciones = l(t('Modificar Acciones específicas'), 'proyectosopedit/' . $form['#node']->nid . '/ae'); $link_proyecto = l(t('Modificar Monto del Proyecto'), 'proyectosopedit/' . $form['#node']->nid); $mensaje_mostrar = t('Existen @count_ae Acciones Específicas asignadas que difieren con la @title_fecha_de_inicio o @title_fecha_de_final del Proyecto. Modifique los montos de las Acciones Específicas en !link_acciones o el monto del proyecto !link_proyecto para poder cerrar el proyecto operativo @nombre_proyecto', array('@count_ae' => $form['#count_ae'], '@title_fecha_de_inicio' => $form['#proyecto_fields']['field_proyecto_fecha_i']['widget']['label'], '@title_fecha_de_final' => $form['#proyecto_fields']['field_proyecto_fecha_f']['widget']['label'], '!link_acciones' => $link_acciones, '!link_proyecto' => $link_proyecto, '@nombre_proyecto' => $form['#node']->titulo_asignado,)); $output .= '
' . $mensaje_mostrar . '
'; } if (variable_get('proyectos_operativos_muestra_enunciado_problema', TRUE)) { $output .= '
' . t('Enunciado del Problema') . '' . drupal_render($form['field_proyecto_causas']) . drupal_render($form['field_proyecto_problemas']) . drupal_render($form['field_proyecto_consecuencias']); if (count($form['#fields_form_ip_in'])) { foreach($form['#fields_form_ip_in'] as $id_c) { $output .= drupal_render($form[$id_c]); } } $output .= '
'; } if (variable_get('proyectos_operativos_muestra_justicacion', TRUE)) { $output .= '
' . t('Justificación del Proyecto') . '' . drupal_render($form['field_proyecto_justificacion']); if (count($form['#fields_form_ip_ju'])) { foreach($form['#fields_form_ip_ju'] as $id_c) { $output .= drupal_render($form[$id_c]); } } $output .= '
'; } if (variable_get('proyectos_operativos_muestra_alcance', TRUE)) { $output .= '
' . t('Alcance del Proyecto') . '' . drupal_render($form['field_proyecto_alcance']); if (count($form['#fields_form_ip_al'])) { foreach($form['#fields_form_ip_al'] as $id_c) { $output .= drupal_render($form[$id_c]); } } $output .= '
'; } $sa = variable_get('proyectos_operativos_muestra_sa', TRUE); $so = variable_get('proyectos_operativos_muestra_so', TRUE); if ($sa || $so) { $output .= drupal_render($form['indicador']); } $output .= '
' . t('Indicador del resultado del Proyecto') . '' ; $output .= drupal_render($form['field_proyecto_descripcion_bien']); $output .= drupal_render($form['field_proyecto_so_cuantificacion']); $output .= drupal_render($form['field_proyecto_unidadm']); if (isset($form['field_proyecto_meta_m']) && $form['field_proyecto_meta_f']) { $output .= '
'; $form['field_proyecto_meta_m'][0]['value']['#title'] = ''; $form['field_proyecto_meta_f'][0]['value']['#title'] = ''; $total = $form['field_proyecto_meta_m'][0]['#value']['value'] + $form['field_proyecto_meta_f'][0]['#value']['value']; $output .= ''; $output .= ''; $output .= '
' . $form['field_proyecto_meta_m']['#title'] . '' . $form['field_proyecto_meta_f']['#title'] . '' . t('Total') . '
' . drupal_render($form['field_proyecto_meta_m']) . '' . drupal_render($form['field_proyecto_meta_f']) . '
' . number_format($total, $format_number['decimals'], $format_number['dec_point'], $format_number['thousands_sep']) . '
'; } $output .= '*' . drupal_render($form['field_proyecto_meta_fisica']); if (count($form['#fields_form_ip_re'])) { foreach($form['#fields_form_ip_re'] as $id_c) { $output .= drupal_render($form[$id_c]); } } $output .= '
'; //agregando el efecto hide y show drupal_add_js(drupal_get_path('module', 'proyectos_operativos_mcti') . '/js/proyectos_operativos_mcti_generales.js'); $form['field_tipo_factores']['value']['#attributes'] = array( 'class' => ' field_tipo_factores', 'onchange' => ";ocultarCampo('field_tipo_factores', 'field_factor_impact_multifc');", ); $form['field_factor_segun_origen']['value']['#attributes'] = array( 'class' => ' field_factor_segun_origen', 'onchange' => ";ocultarCampo('field_factor_segun_origen', 'field_factor_impact_multiog');", ); $form['field_factor_impact_multifc']['#prefix'] = '
'; $form['field_factor_impact_multifc']['#suffix'] = '
'; $form['field_factor_impact_multiog']['#prefix'] = '
'; $form['field_factor_impact_multiog']['#suffix'] = '
'; //agregando la sesion Impacto Ambiental del Proyecto $arreglo['impacto']['factor1'] = array( 'field_factor_naturaleza' => 'field_factor_naturaleza', 'field_factor_intensidad' => 'field_factor_intensidad', 'field_factor_momento' => 'field_factor_momento', 'field_factor_persistencia' => 'field_factor_persistencia', 'field_factor_reversibilidad' => 'field_factor_reversibilidad', ); $arreglo['impacto']['factor2'] = array( 'field_factor_extension' => 'field_factor_extension', 'field_factor_sinergismo' => 'field_factor_sinergismo', 'field_factor_acumulacion' => 'field_factor_acumulacion', 'field_factor_relacion' =>'field_factor_relacion', 'field_factor_recuperabilidad' => 'field_factor_recuperabilidad', ); $arreglo['impacto']['factor3'] = array( 'field_factor_importancia' => 'field_factor_importancia', 'field_factor_medids_impact' => 'field_factor_medids_impact', ); $arreglo['impacto']['tipo'] = array( 'field_tipo_factores' => 'field_tipo_factores', 'field_factor_impact_multifc' => 'field_factor_impact_multifc', 'field_factor_segun_origen' => 'field_factor_segun_origen', 'field_factor_impact_multiog' => 'field_factor_impact_multiog', ); if (variable_get('proyectos_operativos_muestra_impacto_ambiental', TRUE)) { $output_fa = ''; $output_fb = ''; $output_fc = ''; $output .= '
' . t('Impacto Ambiental del Proyecto') . ''; if (count($form['#proyectos_operativos_fields'])) { foreach ($form['#proyectos_operativos_fields'] as $key => $id_c) { if (array_key_exists($id_c, $arreglo['impacto']['factor1'])) { $output_fa .= '
'; } if (array_key_exists($id_c, $arreglo['impacto']['factor2'])) { $output_fb .= ''; } if (array_key_exists($id_c, $arreglo['impacto']['factor3'])) { $row = ''; if ($id_c == 'field_factor_medids_impact') { $row = 'colspan = 4'; } $output_fc .= ''; } } $output_fa .= ''; $output_fb .= ''; $output_fc .= ''; foreach ($form['#proyectos_operativos_fields'] as $key => $id_c) { if (array_key_exists($id_c, $arreglo['impacto']['tipo'])) { $output1 .= drupal_render($form[$id_c]); } //eliminando los labels de los campos unset($form[$id_c]['value']['#title']); unset($form[$id_c][0]['value']['#title']); if (array_key_exists($id_c, $arreglo['impacto']['factor1'])) { $output_fa .= ''; } if (array_key_exists($id_c, $arreglo['impacto']['factor2'])) { $output_fb .= ''; } if (array_key_exists($id_c, $arreglo['impacto']['factor3'])) { $row = ''; if ($id_c == 'field_factor_medids_impact') { $row = 'colspan = 4'; } $output_fc .= ''; } } $output_fa .= ''; $output_fb .= ''; $output_fc .= '
'. $form[$id_c]['#title'] .' '. $form[$id_c]['#title'] .''. $form[$id_c]['#title'] .'
'.drupal_render($form[$id_c]).''.drupal_render($form[$id_c]).''.drupal_render($form[$id_c]).'
'; $output2 = $output_fa . $output_fb . $output_fc; $output .= '
' . t('Tipo de impacto') . ''; $output1.= '
'; $output1 .= '
'; $output .= $output1 . '
'; $output .= '
' . t('Caracterización cualitativa de los efectos') . ''; $output .= $output2 . '
'; } $output .= '
'; } //Balance Estimado Nacional de Servicios Energéticos if (variable_get('proyectos_operativos_muestra_servicios_balance', TRUE)) { $output .= '
' . drupal_render($form['balance']) . '
'; } //Programacion anual por consumidor if (variable_get('proyectos_operativos_muestra_programacion_anual', TRUE)) { $output .= '
' . drupal_render($form['programacion']) . '
'; } $output .= drupal_render($form); return $output; } /** * Agrega mas campos */ function proyectos_operativos_mcti_proyecto_generales_agrega_talento_js_util($tipo) { $arreglov['talento'] = array( 'field_proyecto_institucionth' => 'field_proyecto_institucionth', 'field_proyecto_nombres_a' => 'field_proyecto_nombres_a', 'field_proyecto_cargo_th' => 'field_proyecto_cargo_th', 'field_proyecto_rol_th' => 'field_proyecto_rol_th', 'field_proyecto_esfuerzo' => 'field_proyecto_esfuerzo', 'field_proyecto_formacion' => 'field_proyecto_formacion', ); $arreglov['capacidades'] = array( 'field_proyecto_institucion_alc' => 'field_proyecto_institucion_alc', 'field_proyecto_infraestructura' => 'field_proyecto_infraestructura', 'field_proyecto_equipos' => 'field_proyecto_equipos', 'field_proyecto_insumos' => 'field_proyecto_insumos', 'field_proyectos_servicios' => 'field_proyectos_servicios', ); $arreglov['beneficiario'] = array( 'field_proyecto_beneficiario' => 'field_proyecto_beneficiario', 'field_proyectos_masculino_d' => 'field_proyectos_masculino_d', // 'field_proyectos_femenino_d' => 'field_proyectos_femenino_d', // 'field_proyectos_masculino_i' => 'field_proyectos_masculino_i', 'field_proyectos_femenino_i' => 'field_proyectos_femenino_i', ); $labels = array( 'field_proyecto_beneficiario' => 'Beneficiario ', 'field_proyectos_masculino_d' => 'Número estimado de beneficiarios masculinos', 'field_proyectos_femenino_i' => 'Número estimado de beneficiarios femeninos', ); if (array_key_exists($tipo, $arreglov)) { $arreglo = $arreglov[$tipo]; } else { drupal_not_found(); } $cantidad = intval($_POST['cantidad_' . $tipo]) > 0 ? intval($_POST['cantidad_' . $tipo]) : 0; $form_state = array('submitted' => FALSE); $form_build_id = $_POST['form_build_id']; // Add the new element to the stored form. Without adding the element to the // form, Drupal is not aware of this new elements existence and will not // process it. We retreive the cached form, add the element, and resave. $form = form_get_cache($form_build_id, $form_state); $node_type = content_types('proyectos_operativos'); $fields = $node_type['fields']; foreach ($arreglo as $field_id => $field) { $fields_extra_form1[] = $field_id; $prefixC .= '' . $labels[$field_id] . ''; } $sumas['beneficiarios'] = array(); $cantidad++; if ($tipo == 'talento' || $tipo == 'capacidades') { for ($i = 0; $i < $cantidad; $i++) { $prefix = ''; if ($i == 0) { $prefix = '' . $prefixC . '', ); if ($field_id == 'field_proyecto_esfuerzo') { $form[$field_id . '_' . $i]['#element_validate'] = array('proyectos_operativos_number_integer_validate2',); } $aux = $field_id; $aui = $i; $prefix = ''; } $new_form[$aux . '_' . $aui]['#suffix'] .= '
'; } else { $prefix .= '
'; } $aux = ''; $aui = ''; foreach ($arreglo as $field_id => $field) { $new_form[$field_id . '_' . $i] = array( '#type' => 'textfield', '#size' => 10, '#maxlength' => 255, '#prefix' => $prefix, '#suffix' => ''; } $new_form[$aux . '_' . $aui]['#suffix'] .= '
'; $new_form['cantidad_' . $tipo] = array('#type' => 'hidden', '#value' => $cantidad); } elseif ($tipo == 'beneficiario') { $prefixC .= '' . t('Total') . ''; $vid = variable_get('proyectos_operativos_extra_bene', 0); $tree = taxonomy_get_tree($vid); $options = array(); $options[''] = t('Seleccionar'); if ($tree) { foreach ($tree as $term) { $options[$term->name] = $term->name; } } for ($i = 0; $i < $cantidad; $i++) { $subtotal = 0; $prefix = ''; if ($i == 0) { $prefix = '' . $prefixC . '', ); } else { $new_form[$field_id . '_' . $i] = array( '#type' => 'textfield', '#default_value' => $valor, '#size' => 10, '#maxlength' => 255, '#prefix' => $prefix, '#suffix' => '', ); } if ($field_id != 'field_proyecto_beneficiario') { if (!isset($total_arreglo[$field_id])) { $total_arreglo[$field_id] = 0; } $subtotal += (int) $valor; $totales += (int) $valor; $total_arreglo[$field_id] += (int) $valor; $sumas['beneficiarios']['beneficiario_' . $i] = 'beneficiario_' . $i; $new_form[$field_id . '_' . $i]['#element_validate'] = array('proyectos_operativos_number_integer_validate2',); $new_form[$field_id . '_' . $i]['#attributes'] = array('class' => 'number beneficiario_' . $i . ' todosbeneficiarios beneficiarios_' . $field_id, 'onchange' => "sumabeneficiario('beneficiario_$i');sumabeneficiario('todosbeneficiarios');sumabeneficiario('beneficiarios_$field_id');"); } $aux = $field_id; $aui = $i; $prefix = ''; $new_form[$aux . '_' . $aui]['#suffix'] .= ''; } $new_form[$aux . '_' . $aui]['#suffix'] .= ''; foreach ($arreglo as $field_id => $field) { if ($field_id != 'field_proyecto_beneficiario') { $sumas['beneficiarios']['beneficiarios_' . $field_id] = 'beneficiarios_' . $field_id; $new_form[$aux . '_' . $aui]['#suffix'] .= ''; } } $sumas['beneficiarios']['todosbeneficiarios'] = 'todosbeneficiarios'; $sumas['beneficiarios']['empleos_generados'] = 'empleos_generados'; $new_form[$aux . '_' . $aui]['#suffix'] .= ''; $new_form[$aux . '_' . $aui]['#suffix'] .= '
'; } else { $prefix .= '
'; } $aux = ''; $aui = ''; foreach ($arreglo as $field_id => $field) { $_POST[$field_id . '_' . $i] = str_replace($format_number['thousands_sep'], '', $_POST[$field_id . '_' . $i]); $valor = intval($_POST[$field_id . '_' . $i]) > 0 ? intval($_POST[$field_id . '_' . $i]) : 0; if ($field_id == 'field_proyecto_beneficiario') { $new_form[$field_id . '_' . $i] = array( '#type' => 'select', '#default_value' => $valor, '#options' => $options, '#prefix' => $prefix, '#suffix' => ''; } $new_form[$aux . '_' . $aui]['#suffix'] .= '
' . $subtotal . '
' . t('TOTAL DE BENEFICIARIOS') . '
' . $total_arreglo[$field_id] . '
' . $totales . '
'; $new_form['cantidad_' . $tipo] = array('#type' => 'hidden', '#value' => $cantidad); } $form[$tipo] = $new_form; form_set_cache($form_build_id, $form, $form_state); $form += array( '#post' => $_POST, '#programmed' => FALSE, ); // Rebuild the form. $form = form_builder($_POST['form_id'], $form, $form_state); // Render the new output. $new_form = $form[$tipo]; if ($tipo == 'talento' || $tipo == 'capacidades') { for ($i = 0; $i < $cantidad; $i++) { if ($i == 0) { $prefix = '' . $prefixC . '
'; } foreach($arreglo as $field_id => $field) { $new_form[$field_id . '_' . $i] = $form[$tipo][$field_id . '_' . $i]; if ($prefix != '') { $new_form[$field_id . '_' . $i]['#prefix'] = $prefix; } $prefix = ''; $aux = $field_id; $aui = $i; $new_form[$aux . '_' . $aui] = $form[$tipo][$aux . '_' . $aui]; } $new_form[$aux . '_' . $aui] = $form[$tipo][$aux . '_' . $aui]; } $new_form[$aux . '_' . $aui]['#suffix'] .= '
'; $new_form['cantidad_' . $tipo] = array('#type' => 'hidden', '#value' => $cantidad); } $new_form['cantidad_' . $tipo] = $form[$tipo]['cantidad_' . $tipo]; unset($new_form['cantidad_' . $tipo]['#suffix']); unset($new_form['#prefix'], $new_form['#suffix']); // Prevent duplicate wrappers. //unset($new_form['agrega_' . $tipo]); $output = drupal_render($new_form); drupal_add_js($sumas, 'setting'); $output .= drupal_get_js(); print drupal_to_js(array('data' => $output, 'status' => true)); exit(); } /** * Agrega mas campos para indicadores form */ function proyectos_operativos_mcti_agrega_indicadores_js_util($tipo) { $arreglov['balance'] = array( 'field_balnc_progrmn_anu' => 'field_balnc_progrmn_anu', 'field_balance_fuente' => 'field_balance_fuente', 'field_balanc_tipofuent' => 'field_balanc_tipofuent', 'field_balanc_tipoprod' => 'field_balanc_tipoprod', 'field_balanc_unidmed' => 'field_balanc_unidmed', 'field_balanc_capacid' => 'field_balanc_capacid', 'field_balanc_anho' => 'field_balanc_anho', ); $arreglov['programacion'] = array( 'field_progrmcn_anual_prog' => 'field_progrmcn_anual_prog', 'field_progrmcn_anual_unid' => 'field_progrmcn_anual_unid', 'field_progrmcn_anual_cap' => 'field_progrmcn_anual_cap', 'field_progrmcn_anual_anho' => 'field_progrmcn_anual_anho', ); if (array_key_exists($tipo, $arreglov)) { $arreglo = $arreglov[$tipo]; } else { drupal_not_found(); } //anho para las opciones balance y programacion $current_year = date("Y"); $years[0] = t('Seleccione'); for ($i = ($current_year - 10); $i <= ($current_year + 10); $i++) { $years[$i] = $i; } $form_state = array('submitted' => FALSE); $form_build_id = $_POST['form_build_id']; // Add the new element to the stored form. Without adding the element to the // form, Drupal is not aware of this new elements existence and will not // process it. We retreive the cached form, add the element, and resave. $form = form_get_cache($form_build_id, $form_state); $node_type = content_types('proyectos_operativos'); $fields = $node_type['fields']; $prefixC = ''; $fields_extra_form1 = array(); foreach ($arreglo as $field_id => $field) { $fields_extra_form1[] = $field_id; $prefixC .= '' . $fields[$field_id]['widget']['label'] . ''; } $cantidad = intval($_POST['cantidad_'.$tipo]) > 0 ? intval($_POST['cantidad_'.$tipo]) : 0; $cantidad++; $prefix = ''; $aux = ''; $aui = ''; for ($i = 0; $i < $cantidad; $i++) { if ($i == 0) { $prefix = '' . $prefixC . '', ); } elseif (($field_id == 'field_balanc_anho' || $field_id == 'field_progrmcn_anual_anho') && ($tipo == 'balance' || $tipo == 'programacion')) { $new_form[$field_id . '_' . $i] = array( '#type' => 'select', '#maxlength' => $fields[$field_id]['max_length'], '#required' => $fields[$field_id]['required'], '#options' => $years, '#prefix' => $prefix, '#suffix' => '', ); } else { $options = optionwidgets_options($fields[$field_id], FALSE); $new_form[$field_id . '_' . $i] = array( '#type' => 'select', '#options' => $options, '#prefix' => $prefix, '#suffix' => '', ); } $aux = $field_id; $aui = $i; $prefix = ''; } $new_form[$aux . '_' . $aui]['#suffix'] .= '
'; } else { $prefix .= '
'; } foreach ($arreglo as $field_id => $field) { if (($field_id == 'field_progrmcn_anual_cap' || $field_id == 'field_balanc_capacid') && ($tipo == 'balance' || $tipo == 'programacion')) { $new_form[$field_id . '_' . $i] = array( '#type' => 'textfield', '#size' => $fields[$field_id]['size'], '#maxlength' => $fields[$field_id]['max_length'], '#prefix' => $prefix, '#suffix' => ''; } $new_form[$aux . '_' . $aui]['#suffix'] .= '
'; $new_form['cantidad_'.$tipo] = array('#type' => 'hidden', '#value' => $cantidad); $form[$tipo] = $new_form; form_set_cache($form_build_id, $form, $form_state); $form += array( '#post' => $_POST, '#programmed' => FALSE, ); // Rebuild the form. $form = form_builder($_POST['form_id'], $form, $form_state); // Render the new output. $new_form = $form[$tipo]; unset($new_form['#prefix'], $new_form['#suffix']); // Prevent duplicate wrappers. $output = drupal_render($new_form); print drupal_to_js(array('data' => $output, 'status' => true)); exit(); } /** * Carga los datos de los responsables del proyecto */ function proyectos_operativos_mcti_proyecto_basico_form_responsables_js_util($tipo) { $form_state = array( 'submitted' => FALSE, ); $form_build_id = $_POST['form_build_id']; // Add the new element to the stored form. Without adding the element to the // form, Drupal is not aware of this new elements existence and will not // process it. We retreive the cached form, add the element, and resave. $form = form_get_cache($form_build_id, $form_state); $nid = $_POST['field_proyecto_ente']; $node_type = content_types('proyectos_operativos'); $fields = $node_type['fields']; $query_ins = db_query("SELECT nid, title FROM {node} WHERE type='ente_planificador' AND status=1"); while ($row = db_fetch_object($query_ins)) { $instituciones[$row->nid] = $row->title; } $new_form['responsables'] = array( '#title' => t(''), '#type' => 'fieldset', ); /*$new_form['responsables']['field_proyecto_ente'] = array( '#title' => t('Insitución'), '#type' => 'select', '#options' => $instituciones, '#ahah' => array( 'path' => 'proyectos_operativos_mcti_proyecto_basico_form_responsables/responsables', 'wrapper' => 'wrapper-proyectos-resposab', 'method' => 'replace', 'progress' => array('type' => 'throbber', 'message' => t('Please wait...')), ), '#prefix' => '
', '#suffix' => '
', ); */ $arreglo = array(); $tipos = array( 'gerente' => 'gerente', 'tecnico' => 'tecnico', 'registrador' => 'registrador', 'administrativo' => 'administrativo', ); $arreglo['gerente'] = array( 0 => 'field_proyecto_nombre_gere', 1 => 'field_proyecto_cedul_gere', 2 => 'field_proyecto_corre_gere', 3 => 'field_proyecto_telef_gere', ); $arreglo['tecnico'] = array( 0 => 'field_proyecto_nom_r_tec', 1 => 'field_proyecto_ced_r_tec', 2 => 'field_proyecto_cor_r_tec', 3 => 'field_proyecto_tel_r_tec', 4 => 'field_proyecto_und_r_tec', ); $arreglo['registrador'] = array( 0 => 'field_proyecto_nom_r_reg', 1 => 'field_proyecto_ced_r_reg', 2 => 'field_proyecto_cor_r_reg', 3 => 'field_proyecto_tel_r_reg', ); $arreglo['administrativo'] = array( 0 => 'field_proyecto_nom_r_adm', 1 => 'field_proyecto_ced_r_adm', 2 => 'field_proyecto_cor_r_adm', 3 => 'field_proyecto_tel_r_adm', 4 => 'field_proyecto_und_r_adm', ); $query['gerente'] = db_query("SELECT DISTINCT(pp.vid), pp.field_proyecto_nombre_gere_value as field_proyecto_nombre_gere, pp.field_proyecto_cedul_gere_value as field_proyecto_cedul_gere FROM {node} as n INNER JOIN {proyectos_operativos} as p ON n.nid=p.nid INNER JOIN {content_type_proyectos_operativos} as pp ON pp.nid = p.nid WHERE n.type='proyectos_operativos' AND p.ente=%d AND n.vid=pp.vid AND n.status=1 ORDER BY pp.vid asc", $nid); $query['tecnico'] = db_query("SELECT DISTINCT(pp.vid), pp.field_proyecto_nom_r_tec_value as field_proyecto_nom_r_tec, pp.field_proyecto_ced_r_tec_value as field_proyecto_ced_r_tec FROM {node} as n INNER JOIN {proyectos_operativos} as p ON n.nid=p.nid INNER JOIN {content_type_proyectos_operativos} as pp ON pp.nid = p.nid WHERE n.type='proyectos_operativos' AND p.ente=%d AND n.vid=pp.vid AND n.status=1 ORDER BY pp.vid asc", $nid); $query['registrador'] = db_query("SELECT DISTINCT(pp.vid), pp.field_proyecto_nom_r_reg_value as field_proyecto_nom_r_reg, pp.field_proyecto_ced_r_reg_value as field_proyecto_ced_r_reg FROM {node} as n INNER JOIN {proyectos_operativos} as p ON n.nid=p.nid INNER JOIN {content_type_proyectos_operativos} as pp ON pp.nid = p.nid WHERE n.type='proyectos_operativos' AND p.ente=%d AND n.vid=pp.vid AND n.status=1 ORDER BY pp.vid asc", $nid); $query['administrativo'] = db_query("SELECT DISTINCT(pp.vid), pp.field_proyecto_nom_r_adm_value as field_proyecto_nom_r_adm, pp.field_proyecto_ced_r_adm_value as field_proyecto_ced_r_adm FROM {node} as n INNER JOIN {proyectos_operativos} as p ON n.nid=p.nid INNER JOIN {content_type_proyectos_operativos} as pp ON pp.nid = p.nid WHERE n.type='proyectos_operativos' AND p.ente=%d AND n.vid=pp.vid AND n.status=1 ORDER BY pp.vid asc", $nid); foreach ($tipos as $tip) { $options = array(); $options[0] = t('Seleccione'); $count = 0; $prefixC = ''; while ($row = db_fetch_object($query[$tip]) ) { if ($row->$arreglo[$tip][0] != null || $row->$arreglo[$tip][1] != null) { $options[$row->vid] = $row->$arreglo[$tip][0] . '('. $row->$arreglo[$tip][1] .')'; } } $options[$row->vid + 1] = t('Nuevo'); $new_form['responsables']['default_'.$tip] = array( '#type' => 'select', '#title' => t('Cargar datos del '.$tip), '#options' => $options, '#prefix' => '
' . t('Responsable '.$tip ) . '', ); $new_form['responsables']['default_'.$tip]['#prefix'] .= '
'; $new_form['responsables']['default_'.$tip]['#suffix'] .= '
'; if (count($fields)) { foreach ($arreglo[$tip] as $field_id => $field) { $prefixC .= '' . $fields[$field]['widget']['label'] . ''; } foreach ($arreglo[$tip] as $field_id => $field) { $prefix = ''; if ($count == 0) { $prefix = '
' . $prefixC . '', ); $aux = $field; $count++; } $new_form['responsables'][$aux]['#suffix'] .= ''; $new_form['responsables'][$aux]['#suffix'] .= '
'; } else { $prefix .= ''; } $new_form['responsables'][$field] = array( '#type' => 'textfield', '#required' => $fields[$field]['required'], '#maxlength' => $fields[$field]['max_length'], '#size' => $fields[$field]['size'], '#weight' => $fields[$field]['weight'], '#description' => $fields[$field]['description'], '#prefix' => $prefix, '#suffix' => '
'; } } $form[$tipo] = $new_form; form_set_cache($form_build_id, $form, $form_state); $form += array( '#post' => $_POST, '#programmed' => FALSE, ); // Rebuild the form. $form = form_builder($_POST['form_id'], $form, $form_state); // Render the new output. $new_form = $form[$tipo]; unset($new_form['#prefix'], $new_form['#suffix']); // Prevent duplicate wrappers. $output = drupal_render($new_form); print drupal_to_js(array('data' => $output, 'status' => true)); exit(); } /** * Implementation of proyectos_operativos_search_ac_display(). * Muestra la lista de proyectos disponibles. */ function proyectos_operativos_mcti_search_ac_display() { global $user; $current_time = time(); $tipo_plan = 'proyectos_operativos_formular'; $mi_fecha = ente_planificador_user_acceso_proceso($tipo_plan, 2); $fecha = FALSE; $ente_planificador = 0; $ente = usuario_tiene_ente($user->uid); if ($ente && $ente->nid) { $ente_planificador = ente_planificador_leer_ente_planificadores($ente->nid); } if ($mi_fecha[1] + 86399 > $current_time && $mi_fecha[0] < $current_time) { $fecha = TRUE; } if (!$fecha) { muestra_mensaje($tipo_plan, $ente_planificador); } if ($fecha && $ente->nid) { muestra_mensaje($tipo_plan, $ente_planificador, 0); } if ($fecha && (is_numeric($ente_planificador) && user_access('admin all planificador'))) { //usuarios administradores muestra_mensaje($tipo_plan, $ente_planificador, 0); } $rol_macro = variable_get('ActorPlanificadorMacro', 0); if ($fecha && in_array($rol_macro, array_keys($user->roles))) { //es usuario control muestra_mensaje($tipo_plan, $ente_planificador, 0); } $states = array(); $first_state = 0; if (module_exists('workflow')) { $states = _proyectos_operativos_reformula_obtiene_estados(); if ($states['wid']) { $first_state = _workflow_creation_state($states['wid']); } } $output = drupal_get_form('proyectos_operativos_mcti_search_ac_form'); $mi_ambito = db_result(db_query("SELECT ambito FROM {ente_user_planificador} where usuario = %d", $user->uid)); $inputs = array(); $sql = ''; if (!user_access('admin planificador') && $user->entes) { $inputs[] = $user->entes; $inputs[] = variable_get('proyectos_operativos_state_naprobado', NULL); $sql .= "SELECT ac.nid, ac.year, w.sid, n.created, n.title as nombre, u.name, n.uid, e.title AS ente, ctpo.field_proyecto_titulo_value, ent.ambito, ent.sector, ent.organismo, ent.ente_adscrito, ent.sub_ente, ctpo.field_proyecto_sector_value, ctpo.field_proyecto_pndes_value FROM {proyectos_operativos} AS ac INNER JOIN {node} AS n ON n.nid = ac.nid INNER JOIN {users} AS u ON u.uid = n.uid INNER JOIN {node} as e ON e.nid = ac.ente INNER JOIN {workflow_node} AS w ON w.nid = ac.nid INNER JOIN {ente_planificador} AS ent ON ac.ente = ent.nid LEFT JOIN {content_type_proyectos_operativos} AS ctpo ON ctpo.nid = n.nid AND ctpo.vid = n.vid WHERE ac.ente = %d AND w.sid <> %d"; // $sql .= "SELECT ac.nid, ac.year, w.sid, n.created, n.title as nombre, u.name, n.uid, e.title AS ente FROM {proyectos_operativos} AS ac INNER JOIN {node} AS n ON n.nid = ac.nid INNER JOIN {users} AS u ON u.uid = n.uid INNER JOIN {node} as e ON e.nid = ac.ente INNER JOIN {workflow_node} AS w ON w.nid = ac.nid WHERE ac.ente = %d AND w.sid <> %d"; } elseif (user_access('admin planificador')) { $inputs[] = variable_get('proyectos_operativos_state_naprobado', NULL); $sql .= "SELECT ac.nid, ac.year, ac.ente, w.sid, n.created, n.title as nombre, u.name, n.uid, e.title AS enten, ctpo.field_proyecto_titulo_value, ent.ambito, ent.sector, ent.organismo, ent.ente_adscrito, ent.sub_ente, ctpo.field_proyecto_sector_value, ctpo.field_proyecto_pndes_value FROM {proyectos_operativos} AS ac INNER JOIN {node} AS n ON n.nid = ac.nid INNER JOIN {users} AS u ON u.uid = n.uid INNER JOIN {node} as e ON e.nid = ac.ente INNER JOIN {workflow_node} AS w ON w.nid = ac.nid INNER JOIN {ente_planificador} AS ent ON ac.ente = ent.nid LEFT JOIN {content_type_proyectos_operativos} AS ctpo ON ctpo.nid = n.nid AND ctpo.vid = n.vid WHERE w.sid <> %d"; // $sql .= "SELECT ac.nid, ac.year, ac.ente, w.sid, n.created, n.title as nombre, u.name, n.uid, e.title AS enten FROM {proyectos_operativos} AS ac INNER JOIN {node} AS n ON n.nid = ac.nid INNER JOIN {users} AS u ON u.uid = n.uid INNER JOIN {node} as e ON e.nid = ac.ente INNER JOIN {workflow_node} AS w ON w.nid = ac.nid WHERE w.sid <> %d"; $proyectos_operativos_search_ac_ente = isset($_SESSION['proyectos_operativos']) && isset($_SESSION['proyectos_operativos']['ente']) ? $_SESSION['proyectos_operativos']['ente'] : 0; if ($proyectos_operativos_search_ac_ente) { $inputs[] = $proyectos_operativos_search_ac_ente; $sql .= ' AND ac.ente = %d'; } } $proyectos_operativos_search_ac_anho_creacion = isset($_SESSION['proyectos_operativos']) && isset($_SESSION['proyectos_operativos']['anho']) ? $_SESSION['proyectos_operativos']['anho'] : 0; if ($proyectos_operativos_search_ac_anho_creacion) { $sql .= ' AND ac.year = %d'; $inputs[] = $proyectos_operativos_search_ac_anho_creacion; } //ambito $proyectos_operativos_search_ac_ambito = isset($_SESSION['proyectos_operativos']) && isset($_SESSION['proyectos_operativos']['ambito']) ? $_SESSION['proyectos_operativos']['ambito'] : 0; if ($proyectos_operativos_search_ac_ambito) { $sql .= ' AND ent.ambito = %d'; $inputs[] = $proyectos_operativos_search_ac_ambito; if ($supervisor && $nivel1) { $sql .= ' AND ent.ambito = %d'; $inputs[] = $mi_ambito; } } //sectores $proyectos_operativos_search_ac_sectores = isset($_SESSION['proyectos_operativos']) && isset($_SESSION['proyectos_operativos']['sectores']) ? $_SESSION['proyectos_operativos']['sectores'] : 0; if ($proyectos_operativos_search_ac_sectores) { $sql .= ' AND ctpo.field_proyecto_sector_value = %d'; $inputs[] = $proyectos_operativos_search_ac_sectores; } //pndes $proyectos_operativos_search_ac_pndes = isset($_SESSION['proyectos_operativos']) && isset($_SESSION['proyectos_operativos']['pndes']) ? $_SESSION['proyectos_operativos']['pndes'] : 0; if ($proyectos_operativos_search_ac_pndes) { $sql .= ' AND ctpo.field_proyecto_pndes_value = %d'; $inputs[] = $proyectos_operativos_search_ac_pndes; } //ente adscrito $proyectos_operativos_search_ac_ente_adscrito = isset($_SESSION['proyectos_operativos']) && isset($_SESSION['proyectos_operativos']['ente_adscrito']) ? $_SESSION['proyectos_operativos']['ente_adscrito'] : 0; if ($proyectos_operativos_search_ac_ente_adscrito) { $sql .= ' AND ent.ente_adscrito = %d'; $inputs[] = $proyectos_operativos_search_ac_ente_adscrito; if ($enlace_f && $nivel3) { $sql .= ' AND ac.ente = %d'; $inputs[] = $user->ente_adscrito; } } //sub-ente adscrito $proyectos_operativos_search_ac_sub_ente = isset($_SESSION['proyectos_operativos']) && isset($_SESSION['proyectos_operativos']['sub_ente']) ? $_SESSION['proyectos_operativos']['sub_ente'] : 0; if ($proyectos_operativos_search_ac_sub_ente) { $sql .= ' AND ac.ente = %d'; $inputs[] = $proyectos_operativos_search_ac_sub_ente; } $sql .= ' ORDER BY ac.year DESC, ac.ente'; $header = array(); $cab = 6; if (user_access('admin planificador')) { $header[] = array('data' => t('Ente.')); $cab++; } $header[] = array('data' => t('Proyecto')); $header[] = array('data' => t('Año')); $header[] = array('data' => t('Estado')); $header[] = array('data' => t('Fecha de creación')); $header[] = array('data' => t('Autor')); $header[] = array('data' => t('Acción')); $result = db_query($sql, $inputs); $rows = array(); while($ac = db_fetch_object($result)) { $row = array(); if (user_access('admin planificador')) { $row[] = array('data' => l($ac->enten, 'node/' . $ac->ente),); } $nombre_proyecto = $ac->field_proyecto_titulo_value ? $ac->field_proyecto_titulo_value : $ac->nombre; $row[] = array('data' => $nombre_proyecto,); // $row[] = array('data' => $ac->nombre,); $row[] = array('data' => $ac->year,); $estad0 = $ac->sid == $first_state ? t('Ingresado') : $states['states'][$ac->sid]; $row[] = array('data' => $estad0,); $row[] = array('data' => format_date($ac->created),); $row[] = array('data' => l($ac->name, 'user/' . $ac->uid),); $links = array(); drupal_alter('proyecto_obtiene_links', $links, $ac, $fecha); $row[] = array('data' => theme('item_list', $links),); $rows[] = $row; } if (!count($rows)) { $row[] = array('data' => t('No existen Proyectos Operativos'), 'colspan' => $cab); $rows[] = $row; } $output .= theme('table', $header, $rows); if ($fecha) { $links = array(); drupal_alter('proyecto_obtiene_agregar_links', $links); $output .= '
' . theme('item_list', $links) . '
'; } $form['#submit'][] = 'proyectos_operativos_mcti_search_ac_form_submit'; return $output; } /** * Implementation of proyectos_operativos_search_ac_form(). * Formulario de busqueda de proyecto. */ function proyectos_operativos_mcti_search_ac_form($form_state) { $form = array(); global $user; foreach ($user->roles as $id => $name) { if ($name == 'Supervisor') { $supervisor = $id; } if ($name == 'Enlace Revisor') { $enlace_r = $id; } if ($name == 'Enlace Formulador') { $enlace_f = $id; } if ($name == 'Control') { $control = $id; } if ($name == 'Administrador') { $admin = $id; } } $nivel1 = db_result(db_query("SELECT ente_planificador FROM {ente_planificador} where tipo = %d", 1)); $nivel2 = db_result(db_query("SELECT ente_planificador FROM {ente_planificador} where tipo = %d", 2)); $nivel3 = db_result(db_query("SELECT ente_planificador FROM {ente_planificador} where tipo = %d", 3)); $nivel4 = db_result(db_query("SELECT ente_planificador FROM {ente_planificador} where tipo = %d", 4)); if (user_access('admin planificador') || $control || ($supervisor && $nivel1) || ($supervisor && $nivel2)) { $entes = array(); $result = db_query('SELECT e.nid, n.title FROM {ente_planificador} AS e INNER JOIN {node} AS n ON n.nid = e.nid WHERE n.status = 1'); $entes[0] = t('Todos'); while ($ente = db_fetch_object($result)) { $entes[$ente->nid] = $ente->title; } $proyectos_operativos_search_ac_ente = isset($_SESSION['proyectos_operativos']) && isset($_SESSION['proyectos_operativos']['ente']) ? $_SESSION['proyectos_operativos']['ente'] : 0; $form['proyectos_operativos_search_ac_ente'] = array( '#title' => t('Ente Planificador'), '#type' => 'select', '#default_value' => $proyectos_operativos_search_ac_ente, '#options' => $entes, ); } if ($control || ($supervisor && $nivel2) || ($supervisor && $nivel1) || ($supervisor && $nivel3) || ($supervisor && $nivel4) || ($enlace_f && $nivel1) || ($enlace_f && $nivel2) || ($enlace_f && $nivel3) || ($enlace_f && $nivel4) || ($enlace_r && $nivel1) || ($enlace_r && $nivel2) || ($enlace_r && $nivel3)) { $years = array(); $years[0] = t('Todos'); $current_year = date("Y"); for ($i = $current_year - 10; $i <= $current_year; $i++) { $years[$i] = $i; } $proyectos_operativos_search_ac_anho_creacion = isset($_SESSION['proyectos_operativos']) && isset($_SESSION['proyectos_operativos']['anho']) ? $_SESSION['proyectos_operativos']['anho'] : 0; $form['proyectos_operativos_search_ac_anho_creacion'] = array( '#title' => t('Proyectos Operativos para el año'), '#type' => 'select', '#default_value' => $proyectos_operativos_search_ac_anho_creacion, '#options' => $years, ); } if ($control) { $vocabulary = variable_get('ente_planificador_sector_Ambitos', 0); $terms = taxonomy_get_tree($vocabulary); $ambitos[0] = t('Selecione'); foreach ($terms as $term) { if ($term->depth == 0) { //si el termino es padre $ambitos[$term->tid] = $term->name; } } $proyectos_operativos_search_ac_ambito = isset($_SESSION['proyectos_operativos']) && isset($_SESSION['proyectos_operativos']['ambito']) ? $_SESSION['proyectos_operativos']['ambito'] : 0; $form['proyectos_operativos_search_ac_ambito'] = array( '#title' => t('Ambito del ente planificador'), '#type' => 'select', '#default_value' => $proyectos_operativos_search_ac_ambito, '#options' => $ambitos, ); } if ($control || ($supervisor && $nivel2)) { $vocabulary = variable_get('proyectos_operativos_extra_sector', 0); $proyectos_operativos_search_ac_sectores = isset($_SESSION['proyectos_operativos']) && isset($_SESSION['proyectos_operativos']['sectores']) ? $_SESSION['proyectos_operativos']['sectores'] : 0; $form['proyectos_operativos_search_ac_sectores'] = array( '#title' => t('Sector social del Proyecto'), '#type' => 'hierarchical_select', '#config' => array( 'module' => 'hs_content_taxonomy', 'params' => array( 'vid' => variable_get('proyectos_operativos_extra_sector', 0), 'tid' => 0, 'depth' => 2, ), 'level_labels' => array( 'status' => 1, 'labels' => array( 1 => t('Sub-Sector'), ), ), ), '#default_value' => $proyectos_operativos_search_ac_sectores, ); } if ($control || ($supervisor && $nivel2) || ($supervisor && $nivel3) || ($supervisor && $nivel4) || ($enlace_f && $nivel1) || ($enlace_f && $nivel2) || ($enlace_f && $nivel3) || ($enlace_f && $nivel4) || ($enlace_r && $nivel1) || ($enlace_r && $nivel2) || ($enlace_r && $nivel3)) { $vocabulary = variable_get('proyectos_operativos_PNDES', 0); $terms = taxonomy_get_tree($vocabulary); $pndes[0] = t('Selecione'); foreach ($terms as $term) { if ($term->depth == 0) { //si el termino es padre $pndes[$term->tid] = $term->name; } } $proyectos_operativos_search_ac_pndes = isset($_SESSION['proyectos_operativos']) && isset($_SESSION['proyectos_operativos']['pndes']) ? $_SESSION['proyectos_operativos']['pndes'] : 0; $form['proyectos_operativos_search_ac_pndes'] = array( '#title' => t('PNDES'), '#type' => 'select', '#default_value' => $proyectos_operativos_search_ac_pndes, '#options' => $pndes, ); } if ($control || ($supervisor && $nivel2) || ($supervisor && $nivel1) || ($enlace_r && $nivel2)) { $nivel = 3; //Ente adscrito $result = db_query('SELECT e.nid, n.title FROM {ente_planificador} AS e INNER JOIN {node} AS n ON n.nid = e.nid WHERE n.status = 1 AND e.tipo=%d AND e.ente_adscrito != %d', $nivel, 0); $entes_ad[0] = t('Seleccione'); while ($ente = db_fetch_object($result)) { $entes_ad[$ente->nid] = $ente->title; } $proyectos_operativos_search_ac_ente_adscrito = isset($_SESSION['proyectos_operativos']) && isset($_SESSION['proyectos_operativos']['ente_adscrito']) ? $_SESSION['proyectos_operativos']['ente_adscrito'] : 0; $form['proyectos_operativos_search_ac_ente_adscrito'] = array( '#title' => t('Ente adscrito a un organismo publico.'), '#type' => 'select', '#default_value' => $proyectos_operativos_search_ac_ente_adscrito, '#options' => $entes_ad, ); } if ($control || ($supervisor && $nivel1) || ($supervisor && $nivel2) || ($supervisor && $nivel3) || ($enlace_r && $nivel2) || ($enlace_r && $nivel3)) { $nivel = 4; //sub-ente planificador adscrito $result = db_query('SELECT n.nid, n.title FROM {ente_planificador} AS e INNER JOIN {node} AS n ON n.nid = e.nid WHERE n.status = 1 AND e.tipo = %d AND e.sub_ente != %d', $nivel, 0); $sub_entes[0] = t('Seleccione'); while ($ente = db_fetch_object($result)) { $sub_entes[$ente->nid] = $ente->title; } $proyectos_operativos_search_ac_sub_ente = isset($_SESSION['proyectos_operativos']) && isset($_SESSION['proyectos_operativos']['sub_ente']) ? $_SESSION['proyectos_operativos']['sub_ente'] : 0; $form['proyectos_operativos_search_ac_sub_ente'] = array( '#title' => t('Ente adscrito a otro ente adscrito.'), '#type' => 'select', '#default_value' => $proyectos_operativos_search_ac_sub_ente, '#options' => $sub_entes, ); } $form['buttons'] = array( '#prefix' => '
', '#suffix' => '
', ); $form['buttons']['submit'] = array( '#type' => 'submit', '#value' => t('Buscar'), ); $form['#submit'][] = 'proyectos_operativos_mcti_search_ac_form_submit'; return $form; } /** * Implementation of proyectos_operativos_mcti_search_ac_form_submit(). * cambia el filtro de busqueda de proyectos. */ function proyectos_operativos_mcti_search_ac_form_submit($form, &$form_state) { $_SESSION['proyectos_operativos'] = array(); if ($form_state['values']['proyectos_operativos_search_ac_ambito']) { $_SESSION['proyectos_operativos']['ambito'] = $form_state['values']['proyectos_operativos_search_ac_ambito']; } if ($form_state['values']['proyectos_operativos_search_ac_sectores']) { $_SESSION['proyectos_operativos']['sectores'] = $form_state['values']['proyectos_operativos_search_ac_sectores']; } if ($form_state['values']['proyectos_operativos_search_ac_pndes']) { $_SESSION['proyectos_operativos']['pndes'] = $form_state['values']['proyectos_operativos_search_ac_pndes']; } if ($form_state['values']['proyectos_operativos_search_ac_ente_adscrito']) { $_SESSION['proyectos_operativos']['ente_adscrito'] = $form_state['values']['proyectos_operativos_search_ac_ente_adscrito']; } if ($form_state['values']['proyectos_operativos_search_ac_sub_ente']) { $_SESSION['proyectos_operativos']['sub_ente'] = $form_state['values']['proyectos_operativos_search_ac_sub_ente']; } } /** * Implementation of hook_menu_alter */ function proyectos_operativos_mcti_menu_alter(&$items) { //$items['proyectos_operativos']['page callback'] = 'proyectos_operativos_mcti_search_ac_display'; $items['proyectosopedit/%proyectosop/ficha']['page callback'] = '_proyectos_operativos_mcti_proyecto_ficha_proyecto'; $items['proyectosop/%proyectosop/ficha']['page callback'] = '_proyectos_operativos_mcti_proyecto_ficha_proyecto'; } /** * Implementation of _proyectos_operativos_proyecto_financieros(). * Ver datos financieros (proyectos operativos). */ function _proyectos_operativos_mcti_proyecto_ficha_proyecto($proyecto = 0) { drupal_set_title(t('Ficha del Proyecto')); return theme('proyectos_operativos_mcti_ficha_proyecto', $proyecto); }