+<?php /* vim: set binary expandtab tabstop=4 shiftwidth=4 textwidth=80 foldmethod=marker:
+-------------------------------------------------------------------------------
+ Ministerio de Economía
+ YATTA!
+-------------------------------------------------------------------------------
+This file is part of YATTA!.
+
+YATTA! is free software; you can redistribute it and/or modify it under
+the terms of the GNU General Public License as published by the Free
+Software Foundation; either version 2 of the License, or (at your option)
+any later version.
+
+YATTA! is distributed in the hope that it will be useful, but WITHOUT
+ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
+FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
+
+You should have received a copy of the GNU General Public License; if not,
+write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330,
+Boston, MA 02111-1307 USA
+-------------------------------------------------------------------------------
+Creado: jue mar 4 19:33:38 ART 2004
+Autor: Martin Marrese <mmarre@mecon.gov.ar>
+-------------------------------------------------------------------------------
+$Id$
+-----------------------------------------------------------------------------*/
+//Require Once {{{
+//HTML {{{
+require_once 'MECON/HTML/QuickForm.php';
+require_once 'MECON/HTML/Tabla.php';
+require_once 'MECON/HTML/Error.php';
+require_once 'MECON/HTML/Link.php';
+require_once 'MECON/HTML/Image.php';
+require_once 'MECON/HTML/Link.php';
+//}}}
+//YATTA {{{
+require_once 'YATTA/CuotaDB.php';
+//}}}
+//}}}
+
+//Obtengo los datos del get y del post {{{
+$accion = (@$_REQUEST['accion']) ? $_REQUEST['accion'] : 'nuevo';
+
+if (@$_REQUEST['_login']) {
+ $login = $_REQUEST['_login'];
+}
+elseif (@$_REQUEST['login']) {
+ $login = $_REQUEST['login'];
+}
+else {
+ $login = null;
+}
+//}}}
+
+//Obtengo los datos del servidor {{{
+$CUOTA =& new YATTA_CuotaDB();
+if ($login) {
+ $CUOTA->login = $login;
+ $res = $CUOTA->buscar($DB, MECON_DBO_OR, 'login');
+ if (PEAR::isError($res)) {
+ trigger_error('Error: ' . $res->getMessage() . "\n", E_USER_ERROR);
+ }
+ $CUOTA->cargar($res);
+}
+//}}}
+
+//Creo los objetos necesarios {{{
+$FORM =& new MECON_HTML_QuickForm('admin_cuotas_abm', 'post',
+ 'admin_cuotas-abm');
+$FORM->renderer->updateAttributes('width="400"');
+//}}}
+
+//Armo el formulario {{{
+if (@$id) {
+ $FORM->addElement('hidden', 'login', $login);
+}
+$FORM->addElement('hidden', 'accion', $accion.'2');
+$FORM->addElement('header', 'cabecera', 'Datos de la cuota');
+$login =& $FORM->addElement('text', 'login', 'Login', array('size'=>'30'));
+$tamanio =& $FORM->addElement('text', 'tamanio', 'Tamaño', array('size'=>'3'));
+$group[] =& HTML_QuickForm::createElement('submit', 'aceptar' , 'Aceptar');
+$group[] =& HTML_QuickForm::createElement('submit', 'cancelar', 'Cancelar');
+$FORM->addGroup($group,'botones');
+
+if (@$accion == 'modificar') {
+ $login->setValue($CUOTA->login);
+ $tamanio->setValue($CUOTA->cuota);
+ $group[0]->setValue('Modificar');
+ $group[0]->setName('modificar');
+ $FORM->addRule ('login', 'El login del usuario es obligatorio.', 'required');
+ $FORM->addRule ('tamanio', 'El tamaño es obligatorio.', 'required');
+}
+elseif (@$accion == 'eliminar') {
+ $login->setValue($CUOTA->login);
+ $tamanio->setValue($CUOTA->cuota);
+ $group[0]->setValue('Eliminar');
+ $group[0]->setName('eliminar');
+ $FORM->freeze();
+}
+else {
+ $FORM->addRule ('login', 'El login del usuario es obligatorio.', 'required');
+ $FORM->addRule ('tamanio', 'El tamaño es obligatorio.', 'required');
+}
+//}}}
+
+//Valido el formulario {{{
+if ($FORM->validate()) {
+ $f_botones = $FORM->getSubmitValue('botones');
+ //Cancelar {{{
+ if (@$f_botones['cancelar']) {
+ header ('location: admin_cuotas');
+ exit;
+ }
+ //}}}
+ //Aceptar {{{
+ elseif (@$f_botones['aceptar']) {
+ $CUOTA->login = $login->getValue();
+ $CUOTA->cuota = $tamanio->getValue();
+ $res = $CUOTA->guardar($DB, true);
+ }
+ //}}}
+ //Modificar {{{
+ elseif (@$f_botones['modificar']) {
+ $CUOTA->login = $login->getValue();
+ $CUOTA->cuota = $tamanio->getValue();
+ $res = $CUOTA->guardar($DB, false);
+ }
+ //}}}
+ //Eliminar {{{
+ elseif (@$f_botones['eliminar']) {
+ $res = $CUOTA->borrar($DB);
+ }
+ //}}}
+ if (PEAR::isError($res)) {
+ trigger_error('Error: ' . $res->getMessage() . "\n", E_USER_ERROR);
+ }
+ else {
+ header ('location: admin_cuotas');
+ }
+ exit;
+}
+//}}}
+
+//Agrego la info al marco y la muestro {{{
+$MARCO->addStyleSheet('css/yatta.css');
+$MARCO->addBody($FORM);
+$MARCO->display();
+//}}}
+?>