[Alba-desarrollo] SVN Alba r4347 - in
prosistem/alba/trunk/alba/apps/principal: lib
modules/horarioescolar/templates
modules/horarioescolar/validate modules/turnos/validate
commits en pressenter.com.ar
commits en pressenter.com.ar
Mie Feb 28 22:20:01 CET 2007
Author: josx
Date: 2007-02-28 18:19:57 -0300 (Wed, 28 Feb 2007)
New Revision: 4347
Added:
prosistem/alba/trunk/alba/apps/principal/lib/albaHorasValidator.class.=
php
Modified:
prosistem/alba/trunk/alba/apps/principal/lib/albaCUITValidator.class.p=
hp
prosistem/alba/trunk/alba/apps/principal/modules/horarioescolar/templa=
tes/_turnos_select.php
prosistem/alba/trunk/alba/apps/principal/modules/horarioescolar/valida=
te/edit.yml
prosistem/alba/trunk/alba/apps/principal/modules/turnos/validate/edit.=
yml
Log:
Agregue validacion para fk_turnos_id en horarioescolar, validadcion para =
horas en turnos y horarioescolar
Modified: prosistem/alba/trunk/alba/apps/principal/lib/albaCUITValidator.=
class.php
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D
--- prosistem/alba/trunk/alba/apps/principal/lib/albaCUITValidator.class.=
php 2007-02-28 20:20:23 UTC (rev 4346)
+++ prosistem/alba/trunk/alba/apps/principal/lib/albaCUITValidator.class.=
php 2007-02-28 21:19:57 UTC (rev 4347)
@@ -22,8 +22,8 @@
* albaCUITValidator Valida el CUIT
*
* @package alba
- * @author H=E9ctor Sanchez <hsanchez en pressenter.com.ar>
- * @author Jos=E9 Luis Di Biase <josx en interorganic.com.ar>
+ * @author H=C3=A9ctor Sanchez <hsanchez en pressenter.com.ar>
+ * @author Jos=C3=A9 Luis Di Biase <josx en interorganic.com.ar>
* @author Fernando Toledo <ftoledo en pressenter.com.ar> =20
* @version SVN: $Id$
* @filesource
Added: prosistem/alba/trunk/alba/apps/principal/lib/albaHorasValidator.cl=
ass.php
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D
--- prosistem/alba/trunk/alba/apps/principal/lib/albaHorasValidator.class=
.php 2007-02-28 20:20:23 UTC (rev 4346)
+++ prosistem/alba/trunk/alba/apps/principal/lib/albaHorasValidator.class=
.php 2007-02-28 21:19:57 UTC (rev 4347)
@@ -0,0 +1,144 @@
+<?php
+
+/**
+ * This file is part of Alba.
+ *=20
+ * 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-1=
301 USA
+ */
+
+
+/**
+ * Validador de Horas
+ *
+ * @package alba
+ * @author Jos=C3=A9 Luis Di Biase <josx en interorganic.com.ar>
+ * @author H=C3=A9ctor Sanchez <hsanchez en pressenter.com.ar>
+ * @author Fernando Toledo <ftoledo en pressenter.com.ar>
+ * @version SVN: $Id$
+ * @filesource
+ * @license GPL
+ */
+
+class albaHorasValidator extends sfValidator
+{
+ /**
+ * Execute this validator.
+ *
+ * @param mixed A file or parameter value/array.
+ * @param error An error message reference.
+ *
+ * @return bool true, if this validator executes successfully, otherwi=
se false.
+ */
+ public function execute (&$value, &$error)
+ {
+ =20
+ $value1 =3D $this->getValidHour($value);
+ if (!$value1)
+ {
+ $error =3D $this->getParameter('hora_error');
+ return false;
+ }
+
+ // Is there a compare to do?
+ $compareHourParam =3D $this->getParameter('compare');
+ $compareHour =3D $this->getContext()->getRequest()->getParameter($co=
mpareHourParam);
+
+ // If the compare date is given
+ if ($compareHour)
+ {
+ $operator =3D trim($this->getParameter('operator', '=3D=3D'), '\'"=
');
+ $value2 =3D $this->getValidHour($compareHour);
+
+
+// print_R($value);
+// echo "<br>";
+// print_R($value1);
+// echo "<br>";echo "<br>";
+// print_R($compareHour);
+// echo "<br>";
+// print_R($value2);
+// echo "<br>";echo "<br>";
+// die;
+
+
+
+ // If the check date is valid, compare it. Otherwise ignore the co=
mparison
+ if ($value2)
+ {
+ $valid =3D false;
+ switch ($operator)
+ {
+ case '>':
+ $valid =3D $value1 > $value2;
+ break;
+ case '>=3D':
+ $valid =3D $value1 >=3D $value2;
+ break;
+ case '=3D=3D':
+ $valid =3D $value1 =3D=3D $value2;
+ break; =20
+ case '<=3D':
+ $valid =3D $value1 <=3D $value2;
+ break;
+ case '<':
+ $valid =3D $value1 < $value2;
+ break;
+
+ default:
+ throw new sfValidatorException(sprintf('Invalid hora compari=
son operator "%s"', $operator));
+ }
+
+ if (!$valid)
+ {
+ $error =3D $this->getParameter('compare_error');
+ return false;
+ }
+ }
+ }
+
+ return true;
+ }
+
+ /**
+ * Converts the given time into a Unix timestamp.
+ *=20
+ * Returns null if the time is invalid.
+ *=20
+ * @param $value Date to convert.
+ * @param $culture Language culture to use.
+ */
+ private function getValidHour($value)
+ {
+ if(strlen($value['minute'])=3D=3D1) $value['minute'] =3D "0".$value[=
'minute'];
+ $hora =3D $value['hour'].":".$value['minute']." ".$value['ampm'];
+ return strtotime($hora);
+ }
+
+ /**
+ * Initializes the validator.
+ */
+ public function initialize($context, $parameters =3D null)
+ {
+ // Initialize parent
+ parent::initialize($context, $parameters);
+
+ // Set defaults
+ $this->getParameterHolder()->set('hora_error', 'Hora Inválida=
');
+ $this->getParameterHolder()->set('compare_error', 'Falló la c=
omparacion');
+ $this->getParameterHolder()->add($parameters);
+
+ return true;
+ }
+}
Property changes on: prosistem/alba/trunk/alba/apps/principal/lib/albaHor=
asValidator.class.php
___________________________________________________________________
Name: svn:keywords
+ Id Date Author Rev URL
Modified: prosistem/alba/trunk/alba/apps/principal/modules/horarioescolar=
/templates/_turnos_select.php
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D
--- prosistem/alba/trunk/alba/apps/principal/modules/horarioescolar/templ=
ates/_turnos_select.php 2007-02-28 20:20:23 UTC (rev 4346)
+++ prosistem/alba/trunk/alba/apps/principal/modules/horarioescolar/templ=
ates/_turnos_select.php 2007-02-28 21:19:57 UTC (rev 4347)
@@ -1,3 +1,8 @@
+<div class=3D"content<?php if ($sf_request->hasError('horarioescolar{fk_=
turnos_id}')): ?> form-error<?php endif; ?>">
+<?php if ($sf_request->hasError('horarioescolar{fk_turnos_id}')): ?>
+ <?php echo form_error('horarioescolar{fk_turnos_id}', array('class' =
=3D> 'form-error-msg')) ?>
+<?php endif; ?>
+</div>
<?
$aTurnos =3D array();
$c =3D new Criteria();
Modified: prosistem/alba/trunk/alba/apps/principal/modules/horarioescolar=
/validate/edit.yml
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D
--- prosistem/alba/trunk/alba/apps/principal/modules/horarioescolar/valid=
ate/edit.yml 2007-02-28 20:20:23 UTC (rev 4346)
+++ prosistem/alba/trunk/alba/apps/principal/modules/horarioescolar/valid=
ate/edit.yml 2007-02-28 21:19:57 UTC (rev 4347)
@@ -2,9 +2,11 @@
post: =20
- "horarioescolar{hora_inicio}"
- "horarioescolar{hora_fin}"
- - "horarioescolar{dia}" =20
- - "horarioescolar{nombre}" =20
- - "horarioescolar{descripcion}" =20
+ - "horarioescolar{dia}"
+ - "horarioescolar{nombre}" =20
+ - "horarioescolar{descripcion}"
+ - "horarioescolar{fk_turnos_id}"
+ - "horarioescolar{fk_horarioescolartipo_id}"
=20
fillin:
enabled: on
@@ -13,10 +15,12 @@
horarioescolar{hora_inicio}:
required: Yes
required_msg: El campo hora inicio es obligatorio
+ validators: horaInicio
=20
horarioescolar{hora_fin}:
required: Yes
required_msg: El campo hora fin es obligatorio
+ validators: horaFin
=20
horarioescolar{dia}:
required: Yes
@@ -32,6 +36,14 @@
required_msg: El campo nombre es obligatorio
validators: caracteresMaximos128
=20
+ horarioescolar{fk_turnos_id}:
+ required: Yes
+ required_msg: El campo turnos es obligatorio
+
+ horarioescolar{fk_horarioescolartipo_id}:
+ required: Yes
+ required_msg: El campo tipo de horario escolar es obligatorio
+
=20
caracteresMaximos255:
class: sfStringValidator
@@ -53,4 +65,18 @@
min: 0
min_error: El número debe ser positivo
=20
- =20
\ No newline at end of file
+horaInicio:
+ class: albaHorasValidator
+ param:
+ hora_error: El campo debe ser una hora
+ compare: horarioescolar[hora_fin]
+ operator: <
+ compare_error: La hora de inicio debe ser anterior a la hora de fi=
n
+ =20
+horaFin:
+ class: albaHorasValidator
+ param:
+ hora_error: EL campo debe ser una hora
+ compare: horarioescolar[hora_inicio]
+ operator: >
+ compare_error: La hora de fin debe ser posterior a la hora de in=
icio
Modified: prosistem/alba/trunk/alba/apps/principal/modules/turnos/validat=
e/edit.yml
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D
--- prosistem/alba/trunk/alba/apps/principal/modules/turnos/validate/edit=
.yml 2007-02-28 20:20:23 UTC (rev 4346)
+++ prosistem/alba/trunk/alba/apps/principal/modules/turnos/validate/edit=
.yml 2007-02-28 21:19:57 UTC (rev 4347)
@@ -12,10 +12,12 @@
turnos{hora_inicio}:
required: Yes
required_msg: El campo hora inicio es obligatorio
+ validators: horaInicio
=20
turnos{hora_fin}:
required: Yes
required_msg: El campo hora fin es obligatorio
+ validators: horaFin
=20
turnos{descripcion}:
required: Yes
@@ -27,3 +29,19 @@
param:
max: 255
max_error: La maxima cantidad de caracteres permitida es de 255
+
+horaInicio:
+ class: albaHorasValidator
+ param:
+ hora_error: El campo debe ser una hora
+ compare: turnos[hora_fin]
+ operator: <
+ compare_error: La hora de inicio debe ser anterior a la hora de fi=
n
+ =20
+horaFin:
+ class: albaHorasValidator
+ param:
+ hora_error: EL campo debe ser una hora
+ compare: turnos[hora_inicio]
+ operator: >
+ compare_error: La hora de fin debe ser posterior a la hora de in=
icio
Más información sobre la lista de distribución Alba-desarrollo