Boletín de pedido de libros

<? function formulario_pedido_libros($form_values=NULL) { $form['subject'] = array( '#type' => 'hidden', '#value' => ''); $form['libro'] = array( '#type' => 'select', '#title' => t('Libro'), '#options' => array('Historia de la hormigas (P.Huber)', 'Historia Natural de las Hormigas(R.A.F.Rèaumur)', 'La Inteligencia de las Hormigas (Büchner y Romanes)', 'Cinco ensayos de mirmecología (W.M.Wheeler)'), '#id' => 'lib'); $form['cantidad'] = array( '#type' => […]



<? function formulario_pedido_libros($form_values=NULL) { $form['subject'] = array( '#type' => 'hidden',
'#value' => '');
$form['libro'] = array(
'#type' => 'select',
'#title' => t('Libro'),
'#options' => array('Historia de la hormigas (P.Huber)',
'Historia Natural de las Hormigas(R.A.F.Rèaumur)',
'La Inteligencia de las Hormigas (Büchner y Romanes)', 'Cinco ensayos de mirmecología (W.M.Wheeler)'),
'#id' => 'lib');

$form['cantidad'] = array(
'#type' => 'textfield',
'#title' => t('Cantidad'),
'#default_value' => '1',
'#size' => '2',
'#id' => 'cant');

$form['anadir']= array(
'#type' => 'markup',
'#value' => '


');

$form['lista'] = array(
'#type' => 'select',
'#title' => t('Libros seleccionados'),
'#size' => '5',
'#options' => array('----------------------'),
'#multiple' => 'multiple',
'#id' => 'lista');

$form['recogida'] = array(
'#type' => 'select',
'#title' => t('Modo de recepción'),
'#size' => '1',
'#options' => array('Lo recibo por correo (5€)','Lo recojo en persona (en Jeréz)','Lo recojo en persona (en Barcelona)','Lo recojo en persona (en Vigo)','Lo recojo en persona (en Pontevedra)'),
'#id' => 'recogida');

$form['importe'] = array(
'#type' => 'textfield',
'#title' => t('Importe total ingresado'),
'#default_value' => '0',
'#size' => '4');
$form['fecha'] = array(
'#type' => 'textfield',
'#title' => t('Fecha del ingreso'),
'#size' => '10');
$form['socio'] = array(
'#type' => 'select',
'#title' => t('Socio'),
'#size' => '1',
'#options' => array('SI','NO'),
'#id' => 'socio');
$form['nombre'] = array(
'#type' => 'textfield',
'#title' => t('Nombre y apellidos'));
$form['direccion'] = array(
'#type' => 'textfield',
'#title' => t('Dirección Postal (calle o plaza, ciudad, código postal)'));
$form['tlf'] = array(
'#type' => 'textfield',
'#title' => t('Teléfono de contacto'));
$form['email'] = array(
'#type' => 'textfield',
'#title' => t('Email'));
$form['enviar']= array(
'#type' => 'markup',
'#value' => '');
// el siguiente elemento necesario para que funcione el anterior, pero no sé por qué
$form['submit'] = array('#type' => 'submit', '#value' => 'Next','#prefix'=>'

','#sufix'=>'

');

return $form;
}
function formulario_pedido_libros_submit($form_id, $form_values){
$mens="Formulario enviado desde la web.\n\n";
$mens=$mens."Nombre: ".$form_values['nombre']."\n";
$mens=$mens."Dirección: ".$form_values['direccion'];
$mens=$mens."\nTlf: ".$form_values['tlf']."\n";
$mens=$mens."Email: ".$form_values['email']."\n";
$mens=$mens."Fecha ingreso: ".$form_values['fecha']."\n";
$mens=$mens."Importe: ".$form_values['importe']."\n";
$mens=$mens."Socio: ".$form_values['socio']."\n";
$mens=$mens.$form_values['recogida']."\n";

foreach($form_values['lista'] as $dato)
$mens=$mens."\n".$dato;

if($form_values['subject']=='')
drupal_mail(null,'aim.educacion@mirmiberica.org','Pedido libros - '.$form_values['nombre'],$mens);

return "node/120";
}
return drupal_get_form('formulario_pedido_libros');



<? function formulario_pedido_libros($form_values=NULL) { $form['subject'] = array( '#type' => 'hidden',
'#value' => '');
$form['libro'] = array(
'#type' => 'select',
'#title' => t('Libro'),
'#options' => array('Historia de la hormigas (P.Huber)',
'Historia Natural de las Hormigas(R.A.F.Rèaumur)',
'La Inteligencia de las Hormigas (Büchner y Romanes)', 'Cinco ensayos de mirmecología (W.M.Wheeler)'),
'#id' => 'lib');

$form['cantidad'] = array(
'#type' => 'textfield',
'#title' => t('Cantidad'),
'#default_value' => '1',
'#size' => '2',
'#id' => 'cant');

$form['anadir']= array(
'#type' => 'markup',
'#value' => '


');

$form['lista'] = array(
'#type' => 'select',
'#title' => t('Libros seleccionados'),
'#size' => '5',
'#options' => array('----------------------'),
'#multiple' => 'multiple',
'#id' => 'lista');

$form['recogida'] = array(
'#type' => 'select',
'#title' => t('Modo de recepción'),
'#size' => '1',
'#options' => array('Lo recibo por correo (5€)','Lo recojo en persona (en Jeréz)','Lo recojo en persona (en Barcelona)','Lo recojo en persona (en Vigo)','Lo recojo en persona (en Pontevedra)'),
'#id' => 'recogida');

$form['importe'] = array(
'#type' => 'textfield',
'#title' => t('Importe total ingresado'),
'#default_value' => '0',
'#size' => '4');
$form['fecha'] = array(
'#type' => 'textfield',
'#title' => t('Fecha del ingreso'),
'#size' => '10');
$form['socio'] = array(
'#type' => 'select',
'#title' => t('Socio'),
'#size' => '1',
'#options' => array('SI','NO'),
'#id' => 'socio');
$form['nombre'] = array(
'#type' => 'textfield',
'#title' => t('Nombre y apellidos'));
$form['direccion'] = array(
'#type' => 'textfield',
'#title' => t('Dirección Postal (calle o plaza, ciudad, código postal)'));
$form['tlf'] = array(
'#type' => 'textfield',
'#title' => t('Teléfono de contacto'));
$form['email'] = array(
'#type' => 'textfield',
'#title' => t('Email'));
$form['enviar']= array(
'#type' => 'markup',
'#value' => '');
// el siguiente elemento necesario para que funcione el anterior, pero no sé por qué
$form['submit'] = array('#type' => 'submit', '#value' => 'Next','#prefix'=>'

','#sufix'=>'

');

return $form;
}
function formulario_pedido_libros_submit($form_id, $form_values){
$mens="Formulario enviado desde la web.\n\n";
$mens=$mens."Nombre: ".$form_values['nombre']."\n";
$mens=$mens."Dirección: ".$form_values['direccion'];
$mens=$mens."\nTlf: ".$form_values['tlf']."\n";
$mens=$mens."Email: ".$form_values['email']."\n";
$mens=$mens."Fecha ingreso: ".$form_values['fecha']."\n";
$mens=$mens."Importe: ".$form_values['importe']."\n";
$mens=$mens."Socio: ".$form_values['socio']."\n";
$mens=$mens.$form_values['recogida']."\n";

foreach($form_values['lista'] as $dato)
$mens=$mens."\n".$dato;

if($form_values['subject']=='')
drupal_mail(null,'aim.educacion@mirmiberica.org','Pedido libros - '.$form_values['nombre'],$mens);

return "node/120";
}
return drupal_get_form('formulario_pedido_libros');