';
$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 .= '';
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 .= '
' . $mensaje_mostrar . '
';
}
$output .= '';
$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 .= '
';
$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' => '