1 <?php /* vim: set binary expandtab tabstop=4 shiftwidth=4 textwidth=80 foldmethod=marker:
2 -------------------------------------------------------------------------------
5 -------------------------------------------------------------------------------
6 This file is part of YATTA!.
8 YATTA! is free software; you can redistribute it and/or modify it under
9 the terms of the GNU General Public License as published by the Free
10 Software Foundation; either version 2 of the License, or (at your option)
13 YATTA! is distributed in the hope that it will be useful, but WITHOUT
14 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
15 FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
17 You should have received a copy of the GNU General Public License; if not,
18 write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330,
19 Boston, MA 02111-1307 USA
20 -------------------------------------------------------------------------------
21 Creado: jue mar 4 19:33:38 ART 2004
22 Autor: Martin Marrese <mmarre@mecon.gov.ar>
23 -------------------------------------------------------------------------------
25 -----------------------------------------------------------------------------*/
28 require_once 'MECON/HTML/QuickForm.php';
29 require_once 'MECON/HTML/Tabla.php';
30 require_once 'MECON/HTML/Error.php';
31 require_once 'MECON/HTML/Link.php';
32 require_once 'MECON/HTML/Image.php';
33 require_once 'MECON/HTML/Link.php';
36 require_once 'YATTA/CuotaDB.php';
40 //Obtengo los datos del get y del post {{{
41 $accion = (@$_REQUEST['accion']) ? $_REQUEST['accion'] : 'nuevo';
43 if (@$_REQUEST['_login']) {
44 $login = $_REQUEST['_login'];
46 elseif (@$_REQUEST['login']) {
47 $login = $_REQUEST['login'];
54 //Obtengo los datos del servidor {{{
55 $CUOTA =& new YATTA_CuotaDB();
57 $CUOTA->login = $login;
58 $res = $CUOTA->buscar($DB, MECON_DBO_OR, 'login');
59 if (PEAR::isError($res)) {
60 trigger_error('Error: ' . $res->getMessage() . "\n", E_USER_ERROR);
66 //Creo los objetos necesarios {{{
67 $FORM =& new MECON_HTML_QuickForm('admin_cuotas_abm', 'post',
69 $FORM->renderer->updateAttributes('width="400"');
72 //Armo el formulario {{{
74 $FORM->addElement('hidden', 'login', $login);
76 $FORM->addElement('hidden', 'accion', $accion.'2');
77 $FORM->addElement('header', 'cabecera', 'Datos de la cuota');
78 $login =& $FORM->addElement('text', 'login', 'Login', array('size'=>'30'));
79 $tamanio =& $FORM->addElement('text', 'tamanio', 'Tamaño', array('size'=>'3'));
80 $group[] =& HTML_QuickForm::createElement('submit', 'aceptar' , 'Aceptar');
81 $group[] =& HTML_QuickForm::createElement('submit', 'cancelar', 'Cancelar');
82 $FORM->addGroup($group,'botones');
84 if (@$accion == 'modificar') {
85 $login->setValue($CUOTA->login);
86 $tamanio->setValue($CUOTA->cuota);
87 $group[0]->setValue('Modificar');
88 $group[0]->setName('modificar');
89 $FORM->addRule ('login', 'El login del usuario es obligatorio.', 'required');
90 $FORM->addRule ('tamanio', 'El tamaño es obligatorio.', 'required');
92 elseif (@$accion == 'eliminar') {
93 $login->setValue($CUOTA->login);
94 $tamanio->setValue($CUOTA->cuota);
95 $group[0]->setValue('Eliminar');
96 $group[0]->setName('eliminar');
100 $FORM->addRule ('login', 'El login del usuario es obligatorio.', 'required');
101 $FORM->addRule ('tamanio', 'El tamaño es obligatorio.', 'required');
105 //Valido el formulario {{{
106 if ($FORM->validate()) {
107 $f_botones = $FORM->getSubmitValue('botones');
109 if (@$f_botones['cancelar']) {
110 header ('location: admin_cuotas');
115 elseif (@$f_botones['aceptar']) {
116 $CUOTA->login = $login->getValue();
117 $CUOTA->cuota = $tamanio->getValue();
118 $res = $CUOTA->guardar($DB, true);
122 elseif (@$f_botones['modificar']) {
123 $CUOTA->login = $login->getValue();
124 $CUOTA->cuota = $tamanio->getValue();
125 $res = $CUOTA->guardar($DB, false);
129 elseif (@$f_botones['eliminar']) {
130 $res = $CUOTA->borrar($DB);
133 if (PEAR::isError($res)) {
134 trigger_error('Error: ' . $res->getMessage() . "\n", E_USER_ERROR);
137 header ('location: admin_cuotas');
143 //Agrego la info al marco y la muestro {{{
144 $MARCO->addStyleSheet('css/yatta.css');
145 $MARCO->addBody($FORM);