Problema Drupal 7 (Insertando Modulo)
Publicado por Carlos (7 intervenciones) el 06/03/2012 16:17:55
Hola a Todos, Cuando Voy a la opcion "Mi Cuenta Corriente" de mi pagina web me dice que no tengo una cuenta corriente, y me da la opcion de registrar una llevandome a "Registrar Cuenta Corriente"
es ahi cuando me aparece el siguiente error:
Notice: Undefined index: step in actionForm() (line 21 of C:\Drupal\apps\drupal\htdocs\modules\php\php.module(74) : eval()'d code).
*** LOS CODIGOS SON LOS MISMOS QUE USO EN DRUPAL 5, AHORA ESTOY LLEVANDO TODO A DRUPAL 7
Los codifos son los siguientes:
MI CUENTA CORRIENTE
REFISTRAR CUENTA CORRIENTE
es ahi cuando me aparece el siguiente error:
Notice: Undefined index: step in actionForm() (line 21 of C:\Drupal\apps\drupal\htdocs\modules\php\php.module(74) : eval()'d code).
*** LOS CODIGOS SON LOS MISMOS QUE USO EN DRUPAL 5, AHORA ESTOY LLEVANDO TODO A DRUPAL 7
Los codifos son los siguientes:
MI CUENTA CORRIENTE
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
<?php
global $user;
function actionForm($form_values = NULL) {
$form = array(
'#redirect' => false,
'#multistep' => true,
'#prefix' => '<div id="customer-transactions">',
'#suffix' => '</div>',
);
$format = 'Y-m-d H:i';
$date_from_str= date("d-n-Y", strtotime("-3 months"));
list($d, $m, $y) = split('[/.-]', $date_from_str);
$form['date_from'] = array(
'#type' => 'date',
'#title' => t('Fecha emisión desde'),
'#date_format' => $format,
'#default_value' => array('year' => $y, 'month' => $m, 'day' => $d),
);
$form['date_to'] = array(
'#type' => 'date',
'#title' => t('Fecha emisión hasta'),
'#date_format' => $format,
);
$form['service_id'] = array(
'#type' => 'select',
'#title' => t('Servicio'),
'#default_value' => '--Todas--',
'#options' => array(
'' => t('--Todos los servicios--'),
'1' => t('Energia'),
'2' => t('Agua Potable'),
'3' => t('Telefono'),
'4' => t('Apross '),
'5' => t('Internet'),
'10' => t('Credito Hipotecario'),
'25' => t('Premed'),
),
);
$form['submit'] = array('#type' => 'submit', '#value' => t('Buscar'));
$form['hidden'] = array('#type' => 'value', '#value' => 'is_it_here');
if (isset($form_values)) {
$form['msg'] = array('#value' => _get_data($form_values));
}
else {
$form['msg'] = array('#value' => _get_data());
}
return $form;
}
function actionForm_validate($form_id, $form_values) {
/*
if ($form_values['name'] == '') {
form_set_error('', t('Debe ingresar un nombre para realizar la búsqueda'));
}
*/
}
function get_correct_date($date_str, $default) {
if (empty($date_str))
$date_str = date("Y-m-d", strtotime($default));
else {
list($d, $m, $y) = split('[/.-]', $date_str);
if ( checkdate($m, $d, $y) )
$date_str = date("Y-m-d", mktime(0, 0, 0, $m, $d, $y));
else
$date_str = date("Y-m-d", strtotime($default));
}
return $date_str;
}
function _get_data($form_values = array()) {
global $user;
$date_from_str = isset($form_values['date_from'])? implode('-', $form_values['date_from']) : '';
$date_to_str = isset($form_values['date_to'])? implode('-', $form_values['date_to']) : '';
$date_from=urlencode(get_correct_date($date_from_str, "-3 months"));
$date_to=urlencode(get_correct_date($date_to_str, "now"));
$service_id=urlencode($form_values['service_id']);
$customer_id = $user->customer_id;
$base_api = 'http://200.43.54.146:88/coop-api/';
$base_api_url = $base_api . 'customer_transactions/byCustomer/';
$url=$base_api_url . $customer_id . '/' . $date_from . '/' . $date_to . '/' . $service_id;
$result = drupal_http_request($url);
return $result->data;
}
if (!empty($user->customer_id))
return drupal_get_form('actionForm');
else
print l('No tiene una cuenta corriente asociada. Haga clic aqui para configurarla', 'reg-cc');
?>
REFISTRAR CUENTA CORRIENTE
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
<?php
define('WIZARD_IDENTIFYCUSTOMER', 1);
define('WIZARD_ASKQUESTIONS', 2);
define('WIZARD_FINAL_STEP', 3);
global $user;
function actionForm($form_values = NULL) {
$form = array(
'#redirect' => false,
'#multistep' => true,
'#prefix' => '<div id="user-registration">',
'#suffix' => '</div>',
);
if (!isset($form_values)) {
$step = 1;
}
else {
$step = $form_values['step'] + 1;
}
$form['step'] = array(
'#type' => 'hidden',
'#value' => $step,
);
$form['msg'] = array(
'#value' => 'Paso: ' . $step . ' de ' . WIZARD_FINAL_STEP,
'#prefix' => '<div id="form-step">',
'#suffix' => '</div>',
);
switch ($step) {
case WIZARD_IDENTIFYCUSTOMER:
$form['title'] = array(
'#value' => 'Necesitamos conocer su nro. de socio para relacionarlo con su cuenta corriente.',
'#prefix' => '<div id="form-title">',
'#suffix' => '</div>',
);
$form['customer_id'] = array(
'#type' => 'textfield',
'#title' => t('Numero de socio'),
'#size' =>10,
'#maxlength' => 12,
'#required' => 1,
);
$msg = 'Aceptar';
$form['submit'] = array( '#type' => 'submit', '#value' => $msg, );
break;
case WIZARD_ASKQUESTIONS:
$form['title'] = array(
'#value' => 'A fin de asegurar su identidad, le pedimos que responda las siguientes preguntas.',
'#prefix' => '<div id="form-title">',
'#suffix' => '</div>',
);
$customer_id =urlencode($form_values['customer_id']);
$lastInvoice = _getlastInvoice($customer_id);
$doc = simplexml_load_string($lastInvoice);
$path= $doc->xpath('//@BillingAccountID');
$cpe = (string)$path[0];
$path= $doc->xpath('//@BillNumber');
$fact= (string)$path[0];
$path= $doc->xpath('//@BillID');
$cpe_a1 = substr($path[0], 0, 5);
$fact_a1 = substr($path[0], -5, 5);
$path= $doc->xpath('//@UtilityID');
$cpe_a2 = substr($path[0], 0, 5);
$fact_a2 = strrev(substr($path[0], -5, 5));
$path= $doc->xpath('//@ServiceDesc');
$serv = (string)$path[0];
$path= $doc->xpath('//@DueDate');
$dueDate= substr($path[0], 0, 10);
$title_q1 = 'Código de pago electrónico del servicio ' . $serv;
$title_q2 = 'Ultimos digitos del nro. de factura ' . trim($serv) . ', con vencimiento ' . $dueDate;
$q1[0] = $cpe;
$q1[1] = $cpe_a1;
$q1[2] = $cpe_a2;
$q2[0] = substr($fact, -5, 5);
$q2[1] = $fact_a1;
$q2[2] = $fact_a2;
shuffle($q1);
shuffle($q2);
$form['cpe'] = array(
'#type' => 'radios',
'#options' => array ($q1[0]=> $q1[0], $q1[1] => $q1[1], $q1[2] => $q1[2]),
'#title' => t($title_q1),
'#default_value' => '',
'#required' => 1,
);
$form['fact'] = array(
'#type' => 'radios',
'#options' => array ($q2[0]=> $q2[0], $q2[1] => $q2[1], $q2[2] => $q2[2]),
'#title' => t($title_q2),
'#default_value' => '',
'#required' => 1,
);
$form['customer_id'] = array('#type' => 'hidden', '#value' => $customer_id , );
$msg = 'Aceptar';
$form['submit'] = array( '#type' => 'submit', '#value' => $msg, );
break;
case WIZARD_FINAL_STEP:
$customer_id =urlencode($form_values['customer_id']);
$lastInvoice = _getlastInvoice($customer_id);
$doc = simplexml_load_string($lastInvoice);
$path= $doc->xpath('//@BillingAccountID');
$cpe = (string)$path[0];
$path= $doc->xpath('//@BillNumber');
$fact= (string)$path[0];
$fact = substr($fact, -5, 5);
if ($cpe == $form_values['cpe'] && $fact == $form_values['fact']) {
global $user;
$extra_data = array('customer_id' => $customer_id);
user_save($user, $extra_data);
// user_multiple_role_edit($user->uid, 'add_role', 3);
$notify = 'Completó con éxito la registración.';
$msg = 'Ir a mi cuenta corriente';
define('WIZARD_FINISH_REDIRECT', 'cc');
$form['rd'] = array('#type' => 'hidden', '#value' => 'cc', );
} else {
$notify = 'No se pudo comprobar su identidad.';
$msg = 'Finalizar';
define('WIZARD_FINISH_REDIRECT', 'user');
$form['rd'] = array('#type' => 'hidden', '#value' => 'user', );
}
$form['title'] = array(
'#value' => $notify,
'#prefix' => '<div id="form-title">',
'#suffix' => '</div>',
);
$form['submit'] = array( '#type' => 'submit', '#value' => $msg, );
break;
}
($step == WIZARD_FINAL_STEP)? $form['#redirect'] = NULL : $form['#redirect'] = FALSE;
return $form;
}
function actionForm_submit($form_id, $form_values) {
return WIZARD_FINISH_REDIRECT;
}
function actionForm_validate($form_id, $form_values) {
$step = $form_values['step'] ;
switch ($step) {
case WIZARD_IDENTIFYCUSTOMER:
if (!ctype_digit($form_values['customer_id'])) {
form_set_error('', t('Debe ingresar nro. de socio'));
}
break;
}
return;
}
function _getlastInvoice($customer_id) {
global $user;
$base_api = 'http://200.43.54.146:88/coop-api/';
$base_api_url = $base_api . 'CustomerTransactions/lastInvoice/';
$url=$base_api_url . $customer_id;
$result = drupal_http_request($url);
return $result->data;
}
/*
$dest = drupal_get_destination();
if (!$user->uid) {
drupal_goto('user/login',$dest);
}
*/
if (empty($user->customer_id))
return drupal_get_form('actionForm');
else
drupal_goto('cc');
?>
Valora esta pregunta


0