';
$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['#fechas_validacion']['inicio']) && ($form_state['values']['field_proyecto_fecha_i'][0]['value']) && $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['#fechas_validacion']['fin']) && ($form_state['values']['field_proyecto_fecha_f'][0]['value']) && $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 .= '';
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 .= '';
$output .= '';
if (variable_get('proyectos_operativos_muestra_beneficiario', TRUE)) {
$output .= drupal_render($form['beneficiario']);
}
$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 .= '
';
$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 .= '
';
$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();
}
/**
* 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);
}
/**
* Buscar valores por defecto para los responsable.
*/
function proyectos_operativos_mcti_search_responsable($tipo, $ente_planificador) {
if ($tipo == 'gerente') {
$query = 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);
}
else if ($tipo == 'tecnico') {
$query = 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);
}
else if ($tipo == 'registrador') {
$query = 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);
}
else if ($tipo == 'administrativo') {
$query = 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);
}
return $query;
}