[Alba-desarrollo] SVN Alba r5016 - in prosistem/alba/trunk/alba/apps/principal: lib modules/alumno/actions modules/alumno/templates modules/alumno/validate modules/docente/validate modules/responsable/validate

commits en pressenter.com.ar commits en pressenter.com.ar
Mar Ago 28 03:07:39 CEST 2007


Author: josx
Date: 2007-08-27 22:07:34 -0300 (Mon, 27 Aug 2007)
New Revision: 5016

Added:
   prosistem/alba/trunk/alba/apps/principal/lib/albaDocumentoValidator.class.php
Modified:
   prosistem/alba/trunk/alba/apps/principal/modules/alumno/actions/actions.class.php
   prosistem/alba/trunk/alba/apps/principal/modules/alumno/templates/editSuccess.php
   prosistem/alba/trunk/alba/apps/principal/modules/alumno/validate/edit.yml
   prosistem/alba/trunk/alba/apps/principal/modules/docente/validate/edit.yml
   prosistem/alba/trunk/alba/apps/principal/modules/responsable/validate/edit.yml
Log:
Se agrego la validacion de los documento, sacando los puntos en responsable, alumno y docente

Added: prosistem/alba/trunk/alba/apps/principal/lib/albaDocumentoValidator.class.php
===================================================================
--- prosistem/alba/trunk/alba/apps/principal/lib/albaDocumentoValidator.class.php	2007-08-27 22:10:36 UTC (rev 5015)
+++ prosistem/alba/trunk/alba/apps/principal/lib/albaDocumentoValidator.class.php	2007-08-28 01:07:34 UTC (rev 5016)
@@ -0,0 +1,73 @@
+<?php
+/**
+ *    This file is part of Alba.
+ * 
+ *    Alba 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.
+ *
+ *    Alba 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
+ *    along with Alba; if not, write to the Free Software
+ *    Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
+ */
+
+
+/**
+ * albaDocumentoValidator Valida documento
+ *
+ * @package    alba
+ * @author     Héctor Sanchez <hsanchez en pressenter.com.ar>
+ * @author     José Luis Di Biase <josx en interorganic.com.ar>
+ * @author     Fernando Toledo <ftoledo en pressenter.com.ar>  
+ * @version    SVN: $Id: albaDNIValidator.class.php 4347 2007-02-28 21:19:57Z josx $
+ * @filesource
+ * @license GPL
+ */
+
+class albaDocumentoValidator extends sfValidator {
+    
+    function initialize($context, $parameters = null) 
+    {
+        // initialize parent
+        parent::initialize($context);
+        // set defaults
+        $this->getParameterHolder()->set('documento_error', 'Documento Invalido');
+        $this->getParameterHolder()->set('nombre_campo1', null);
+        $this->getParameterHolder()->set('nombre_campo2', null);
+        $this->getParameterHolder()->add($parameters);
+
+        return true;
+    }
+    
+    public function execute(&$value, &$error)
+    {
+        $value_sin_puntos = str_replace(".", "", $value); // reemplaza si existen puntos en el documento
+
+        if((!is_numeric($value_sin_puntos)) OR ($this->getParameterHolder()->get('nombre_campo1') == null)) { //verifica si es un valor numerico
+            $error = $this->getParameterHolder()->get('documento_error');
+            return false;
+        }        
+
+        // Esto quizas no deberia estar aqui
+        // graba en el request el valor sin puntos
+         if($this->getParameterHolder()->get('nombre_campo1') != null AND $this->getParameterHolder()->get('nombre_campo2') != null) {
+             $temp = $this->getContext()->getRequest()->getParameter($this->getParameterHolder()->get('nombre_campo1'));
+             $idx = $this->getParameterHolder()->get('nombre_campo2');
+             $temp["$idx"] = str_replace(".", "", $temp["$idx"]); // esto se hace nuevamente por algun problema muy raro que no permite asignarle $value_sin_puntos
+//           $temp["$idx"] = $b;
+//           var_dump($temp);die;
+             sfContext::getInstance()->getRequest()->setParameter($this->getParameterHolder()->get('nombre_campo1'), $temp);
+         } else {
+             sfContext::getInstance()->getRequest()->setParameter($this->getParameterHolder()->get('nombre_campo1'), $value_sin_puntos);
+         }
+
+        return true;
+    }
+}
+?>
\ No newline at end of file


Property changes on: prosistem/alba/trunk/alba/apps/principal/lib/albaDocumentoValidator.class.php
___________________________________________________________________
Name: svn:keywords
   + "Id Author URL Date Rev"

Modified: prosistem/alba/trunk/alba/apps/principal/modules/alumno/actions/actions.class.php
===================================================================
--- prosistem/alba/trunk/alba/apps/principal/modules/alumno/actions/actions.class.php	2007-08-27 22:10:36 UTC (rev 5015)
+++ prosistem/alba/trunk/alba/apps/principal/modules/alumno/actions/actions.class.php	2007-08-28 01:07:34 UTC (rev 5016)
@@ -112,7 +112,6 @@
       $this->alumno = $this->getAlumnoOrCreate();
 
       $this->updateAlumnoFromRequest();
-
       $this->saveAlumno($this->alumno);
 
       $this->setFlash('notice', 'Your modifications have been saved');

Modified: prosistem/alba/trunk/alba/apps/principal/modules/alumno/templates/editSuccess.php
===================================================================
--- prosistem/alba/trunk/alba/apps/principal/modules/alumno/templates/editSuccess.php	2007-08-27 22:10:36 UTC (rev 5015)
+++ prosistem/alba/trunk/alba/apps/principal/modules/alumno/templates/editSuccess.php	2007-08-28 01:07:34 UTC (rev 5016)
@@ -18,7 +18,6 @@
 <?php endif;?>
 
 <?php use_helper('Object', 'Validation', 'ObjectAdmin', 'I18N', 'Date') ?>
-
 <h1><?php echo __(' ',array()) ?></h1>
 <div id="sf_admin_container">
 

Modified: prosistem/alba/trunk/alba/apps/principal/modules/alumno/validate/edit.yml
===================================================================
--- prosistem/alba/trunk/alba/apps/principal/modules/alumno/validate/edit.yml	2007-08-27 22:10:36 UTC (rev 5015)
+++ prosistem/alba/trunk/alba/apps/principal/modules/alumno/validate/edit.yml	2007-08-28 01:07:34 UTC (rev 5016)
@@ -115,11 +115,11 @@
 
 
 validarNumero:
-    class: sfNumberValidator
+    class: albaDocumentoValidator
     param:
-        nan_error: Por favor ingrese un valor n&uacute;merico       
-        min: 0
-        min_error: El n&uacute;mero debe ser positivo
+        documento_error: El Documento ingresado es invalido
+        nombre_campo1: alumno
+        nombre_campo2: nro_documento
 
 validaFecha:
     class:  albaDateValidator

Modified: prosistem/alba/trunk/alba/apps/principal/modules/docente/validate/edit.yml
===================================================================
--- prosistem/alba/trunk/alba/apps/principal/modules/docente/validate/edit.yml	2007-08-27 22:10:36 UTC (rev 5015)
+++ prosistem/alba/trunk/alba/apps/principal/modules/docente/validate/edit.yml	2007-08-28 01:07:34 UTC (rev 5016)
@@ -109,11 +109,12 @@
 
 
 validarNumero:
-    class: sfNumberValidator
+    class: albaDocumentoValidator
     param:
-        nan_error: Por favor ingrese un valor n&uacute;merico       
-        min: 0
-        min_error: El n&uacute;mero debe ser positivo
+        documento_error: El Documento ingresado es invalido
+        nombre_campo1: docente
+        nombre_campo2: nro_documento
+                                
 
 validaFecha:
     class:  albaDateValidator

Modified: prosistem/alba/trunk/alba/apps/principal/modules/responsable/validate/edit.yml
===================================================================
--- prosistem/alba/trunk/alba/apps/principal/modules/responsable/validate/edit.yml	2007-08-27 22:10:36 UTC (rev 5015)
+++ prosistem/alba/trunk/alba/apps/principal/modules/responsable/validate/edit.yml	2007-08-28 01:07:34 UTC (rev 5016)
@@ -100,12 +100,12 @@
 
 
 validarNumero:
-    class: sfNumberValidator
+    class: albaDocumentoValidator
     param:
-        nan_error: Por favor ingrese un valor n&uacute;merico       
-        min: 0
-        min_error: El n&uacute;mero debe ser positivo
-
+        documento_error: El Documento ingresado es invalido
+        nombre_campo1: responsable
+        nombre_campo2: nro_documento
+                               
 validaFecha:
     class:  sfStringValidator
     param: 




Más información sobre la lista de distribución Alba-desarrollo