--- /dev/null
+<?php /* vim: set binary expandtab tabstop=4 shiftwidth=4 textwidth=80:
+-------------------------------------------------------------------------------
+ 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:23:27 ART 2004
+Autor: Martin Marrese <mmarre@mecon.gov.ar>
+-------------------------------------------------------------------------------
+$Id$
+-----------------------------------------------------------------------------*/
+
+require_once 'MECON/DBO.php';
+require_once 'PEAR.php';
+require_once 'SAMURAI/Perm.php';
+
+/**
+ * Clase para el manejo de las cuotas especiales.
+ *
+ * @access public
+ */
+class YATTA_CuotaDB extends MECON_DBO {
+
+ /**
+ * Login del usuario.
+ *
+ * @var string $login
+ * @access public
+ */
+ var $login = null;
+
+ /**
+ * Cuota del usuario.
+ *
+ * @var int $cuota
+ * @access public
+ */
+ var $cuota = null;
+
+ /**
+ * Carga el objeto con los datos que se pasan por parametro.
+ *
+ * @param DB $db DB o DB_Result a usar para la carga.
+ *
+ * @return mixed
+ * @access public
+ */
+ function cargar($db = null)
+ {
+ // Si es un resultado, obtengo los elemento.
+ if (is_a($db, 'db_result')) {
+ $this->predefinirAtributos();
+ $res = $db->fetchRow(DB_FETCHMODE_ASSOC);
+ // Si hay error lo devuelve.
+ if (DB::isError($res)) {
+ return $res;
+ }
+ elseif (!$res) {
+ return false;
+ }
+ $this->login = $res['login'];
+ $this->cuota = $res['cuota'];
+ return true;
+ }
+ return false;
+ }
+
+ /**
+ * Borra el objeto de una base de datos.
+ *
+ * @param DB $db Base de datos de donde borrar el objeto.
+ *
+ * @return mixed
+ * @access public
+ */
+ function borrar($db = null)
+ {
+ return $db->query ("DELETE FROM yatta.cuotas
+ WHERE login = ". $db->quote($this->login));
+ }
+
+ /**
+ * Busca los datos en la base.
+ *
+ * @param DB $db Conexion a la base de datos.
+ * @param string $operador Indica como deben concatenarse las condiciones de busqueda
+ * @param string $orden Indica de que manera deben ordenarse los resultados de la busqueda
+ *
+ * @return mixed
+ * @access public
+ */
+ function buscar($db = null, $operador = MECON_DBO_OR, $orden = null)
+ {
+ // Armo el WHERE.
+ $where = array();
+ if (!is_null($this->login)) {
+ $where[] = 'c.login LIKE '. $db->quote("%$this->login%");
+ }
+ if (!is_null($this->cuota)) {
+ $where[] = 'c.cuota = '. $this->cuota;
+ }
+ if ($where) {
+ $where = 'WHERE '. join ("$operador", $where);
+ }
+ else {
+ $where = '';
+ }
+ // Armo el ORDER BY.
+ if (is_string($orden))
+ {
+ $orden = array($orden);
+ }
+ if ($orden)
+ {
+ $orden = 'ORDER BY '.join(',',$orden);
+ }
+ else {
+ $orden = '';
+ }
+
+ return $db->query(
+ "SELECT c.login AS login, c.cuota AS cuota
+ FROM yatta.cuotas AS c
+ $where
+ $orden");
+ }
+
+ /**
+ * Guarda los datos en la base.
+ *
+ * @param DB $db Conexion a la base de datos.
+ * @param bool $nuevo Indica si se trata de un nuevo registro en la base.
+ *
+ * @return mixed
+ * @access public
+ */
+ function guardar($db = null, $nuevo = true)
+ {
+ //Debo verificar que el login que me pasaron tenga permisos en samurai.
+ $tmp =& new SAMURAI_Perm ($this->login, YATTA_PERM, $db);
+
+ if (!$tmp->tiene()) {
+ return new PEAR_Error (
+ 'El usuario tiene que tener permisos en yatta.'
+ );
+ }
+
+ if ($nuevo) {
+ $datos = array (
+ 'login' => $this->login,
+ 'cuota' => $this->cuota
+ );
+ return $db->autoExecute('yatta.cuotas', $datos,
+ DB_AUTOQUERY_INSERT);
+ }
+ else {
+ $datos = array (
+ 'login' => $this->login,
+ 'cuota' => $this->cuota
+ );
+ return $db->autoExecute('yatta.cuotas', $datos,
+ DB_AUTOQUERY_UPDATE, 'login = '. $db->quote($this->login));
+ }
+ }
+
+ /**
+ * Hace un reset de los atributos.
+ *
+ * @return void
+ * @access public
+ */
+ function predefinirAtributos() {
+ $this->login = null;
+ $this->cuota = null;
+ }
+}
+?>
\ No newline at end of file
),//}}}
//SECCION 3 {{{
array (
- 'nombre' => 'Administración Servidores',
+ 'nombre' => 'Administración',
'imagenComun' => 'general_admin.gif',
'link' => 'admin_servidores',
'permisos' => array (YATTA_PERM_ADMINISTRADOR),
-// 'tipoMenu' => 'vertical',
- 'subhijos' => array ('admin_servidores-abm'),
-// 'hijos' => array (
-// array ( 'nombre' => 'Servidores',
-// 'imagenComun' => 'general_admin.gif',
-// 'imagenMouseOn' => '', // --> Opcional
-// 'imagenSelect' => '', // --> Opcional
-// 'link' => 'admin_servidores',
-// 'permisos' => array (YATTA_PERM_ADMINISTRADOR),
-// 'subhijos' => array ( <Links Subhijos> ),
-// ),
-// ),
+ 'tipoMenu' => 'vertical',
+ 'hijos' => array (
+ array ( 'nombre' => 'Cuotas Excepcionales',
+ 'imagenComun' => 'general_admin.gif',
+ 'link' => 'admin_cuotas',
+ 'permisos' => array (YATTA_PERM_ADMINISTRADOR),
+ 'subhijos' => array ('admin_cuotas-abm'),
+ ),
+ array ( 'nombre' => 'Servidores',
+ 'imagenComun' => 'general_admin.gif',
+ 'link' => 'admin_servidores',
+ 'permisos' => array (YATTA_PERM_ADMINISTRADOR),
+ 'subhijos' => array ('admin_servidores-abm'),
+ ),
+ ),
),//}}}
), //}}}
);
--- /dev/null
+<?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();
+//}}}
+?>
--- /dev/null
+<?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:22:05 ART 2004
+Autor: Martin Marrese <mmarre@mecon.gov.ar>
+-------------------------------------------------------------------------------
+$Id$
+-----------------------------------------------------------------------------*/
+//Require Once {{{
+//HTML {{{
+require_once 'MECON/HTML/TablaDB.php';
+require_once 'MECON/HTML/Image.php';
+require_once 'MECON/HTML/Link.php';
+//}}}
+//YATTA {{{
+require_once 'YATTA/CuotaDB.php';
+//}}}
+//}}}
+
+//Obtengo los datos de los servidores {{{
+$CUOTA =& new YATTA_CuotaDB();
+$res = $CUOTA->buscar ($DB, MECON_DBO_OR, 'login');
+//}}}
+
+//Agrego la informacion a la tabla {{{
+$TABLADB = new MECON_HTML_TablaDB ('Cuotas', 'width="400"');
+
+$TABLADB->addLink('nuevo', new MECON_HTML_Link('admin_cuotas-abm',
+ 'Nueva Cuota'));
+
+$TABLADB->addRow(array('Listado de Cuotas'),
+ 'cabecera colspan="4" align="left"');
+
+$TABLADB->addRow(array('Login', 'Cuota (MB)', 'Modif.', 'Elim.'),'titulo');
+
+$pager = $TABLADB->addPager($res, null, new MECON_HTML_Link ('admin_cuotas'
+ , null));
+
+$TABLADB->addRowsIcon('modificar', array ('login'), new MECON_HTML_Link
+ ('admin_cuotas-abm', null, array('accion' => 'modificar')));
+
+$TABLADB->addRowsIcon('borrar', array ('login'), new MECON_HTML_Link
+ ('admin_cuotas-abm', null, array('accion' => 'eliminar')));
+
+$TABLADB->addRows($pager, array ('login', 'cuota'));
+
+$TABLADB->updateColAttributes(0, 'width="45%"');
+$TABLADB->updateColAttributes(1, 'width="45%"');
+$TABLADB->updateColAttributes(2, 'width="5%"');
+$TABLADB->updateColAttributes(3, 'width="5%"');
+//}}}
+
+//Agrego la info al marco y la muestro {{{
+$MARCO->addStyleSheet('css/yatta.css');
+$MARCO->addBody($TABLADB);
+$MARCO->display();
+//}}}
+?>