[Alba-desarrollo] SVN Alba r4760 - in prosistem/alba/trunk/alba: apps/principal/modules/alumno/templates lib/model

commits en pressenter.com.ar commits en pressenter.com.ar
Vie Jun 22 16:50:45 CEST 2007


Author: hsanchez
Date: 2007-06-22 11:50:43 -0300 (Fri, 22 Jun 2007)
New Revision: 4760

Modified:
   prosistem/alba/trunk/alba/apps/principal/modules/alumno/templates/_division.php
   prosistem/alba/trunk/alba/lib/model/DivisionPeer.php
Log:
Corrigiendo el orden de las divisiones Ticket: #183

Modified: prosistem/alba/trunk/alba/apps/principal/modules/alumno/templates/_division.php
===================================================================
--- prosistem/alba/trunk/alba/apps/principal/modules/alumno/templates/_division.php	2007-06-20 16:55:03 UTC (rev 4759)
+++ prosistem/alba/trunk/alba/apps/principal/modules/alumno/templates/_division.php	2007-06-22 14:50:43 UTC (rev 4760)
@@ -3,12 +3,11 @@
         $establecimiento_id = $sf_user->getAttribute('fk_establecimiento_id');
         $criteria = new Criteria();
         $criteria->add(AnioPeer::FK_ESTABLECIMIENTO_ID, $establecimiento_id);
-        $divisiones = DivisionPeer::doSelectJoinAnio($criteria);
+        $divisiones = DivisionPeer::doSelectJoinAnioByOrden($criteria);
         $optionsDivision[]  = "";
         foreach($divisiones as $division) {
             $optionsDivision[$division->getId()] = $division->getAnio()->getDescripcion()." ".$division->getDescripcion();
         }
-        asort($optionsDivision);
         echo select_tag('filters[division]', options_for_select($optionsDivision, isset($filters['division']) ? $filters['division'] : ''));
 
 ?>

Modified: prosistem/alba/trunk/alba/lib/model/DivisionPeer.php
===================================================================
--- prosistem/alba/trunk/alba/lib/model/DivisionPeer.php	2007-06-20 16:55:03 UTC (rev 4759)
+++ prosistem/alba/trunk/alba/lib/model/DivisionPeer.php	2007-06-22 14:50:43 UTC (rev 4760)
@@ -20,4 +20,55 @@
  */	
 class DivisionPeer extends BaseDivisionPeer {
 
+
+	public static function doSelectJoinAnioByOrden(Criteria $c, $con = null)
+	{
+		$c = clone $c;
+	    if ($c->getDbName() == Propel::getDefaultDB()) {
+			$c->setDbName(self::DATABASE_NAME);
+		}
+
+		DivisionPeer::addSelectColumns($c);
+		$startcol = (DivisionPeer::NUM_COLUMNS - DivisionPeer::NUM_LAZY_LOAD_COLUMNS) + 1;
+		AnioPeer::addSelectColumns($c);
+
+		$c->addJoin(DivisionPeer::FK_ANIO_ID, AnioPeer::ID);
+        $c->addAscendingOrderByColumn(AnioPeer::DESCRIPCION);           
+        $c->addAscendingOrderByColumn(DivisionPeer::ORDEN);           
+        $c->addAscendingOrderByColumn(DivisionPeer::DESCRIPCION);           
+		$rs = BasePeer::doSelect($c, $con);
+        $results = array();
+
+		while($rs->next()) {
+
+			$omClass = DivisionPeer::getOMClass();
+
+			$cls = Propel::import($omClass);
+			$obj1 = new $cls();
+			$obj1->hydrate($rs);
+
+			$omClass = AnioPeer::getOMClass();
+
+			$cls = Propel::import($omClass);
+			$obj2 = new $cls();
+			$obj2->hydrate($rs, $startcol);
+
+			$newObject = true;
+			foreach($results as $temp_obj1) {
+				$temp_obj2 = $temp_obj1->getAnio(); 				
+                if ($temp_obj2->getPrimaryKey() === $obj2->getPrimaryKey()) {
+					$newObject = false;
+					$temp_obj2->addDivision($obj1);
+                    break;
+				}
+			}
+			if ($newObject) {
+				$obj2->initDivisions();
+				$obj2->addDivision($obj1);
+            }
+			$results[] = $obj1;
+		}
+		return $results;
+	}
+
 } // DivisionPeer




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