[Alba-desarrollo] SVN Alba r5494 - in prosistem/alba/trunk/alba/apps/principal/modules/relAlumnoDivision: actions templates

commits en pressenter.com.ar commits en pressenter.com.ar
Vie Mar 7 16:15:08 CET 2008


Author: josx
Date: 2008-03-07 13:15:08 -0200 (Fri, 07 Mar 2008)
New Revision: 5494

Added:
   prosistem/alba/trunk/alba/apps/principal/modules/relAlumnoDivision/templates/_listado_alumnos_division.php
   prosistem/alba/trunk/alba/apps/principal/modules/relAlumnoDivision/templates/asignarAlumnoSuccess.php
Modified:
   prosistem/alba/trunk/alba/apps/principal/modules/relAlumnoDivision/actions/actions.class.php
   prosistem/alba/trunk/alba/apps/principal/modules/relAlumnoDivision/templates/_listado_divisiones.php
   prosistem/alba/trunk/alba/apps/principal/modules/relAlumnoDivision/templates/busquedaDivisionSuccess.php
   prosistem/alba/trunk/alba/apps/principal/modules/relAlumnoDivision/templates/editSuccess.php
Log:
Ahora ya graba y listacorrectamente las relaciones entre alumnos y divisiones. Falta mejorar mucho la grafica.

Modified: prosistem/alba/trunk/alba/apps/principal/modules/relAlumnoDivision/actions/actions.class.php
===================================================================
--- prosistem/alba/trunk/alba/apps/principal/modules/relAlumnoDivision/actions/actions.class.php	2008-03-04 21:22:22 UTC (rev 5493)
+++ prosistem/alba/trunk/alba/apps/principal/modules/relAlumnoDivision/actions/actions.class.php	2008-03-07 15:15:08 UTC (rev 5494)
@@ -155,21 +155,20 @@
         }
 
 */
-        $aDivision = DivisionPeer::doSelect($criteria);
-        $this->optionsDivision = $aDivision;
+        $this->optionsDivision = $this->getDivisionesDeEstablecimiento($criteria);
+        $this->alumnoDivision = $this->getAlumnosPorDivision();
     }
 
 
+    function getDivisionesDeEstablecimiento($c = null ) {
+        $optionsDivision = array();
+        if($c == null) {
+            $c = new Criteria();
+        }
 
-    function executeEdit() {
-
-        //Listado de alumnos
-        $c = new Criteria();
-        $aAlumno = AlumnoPeer::doSelect($c);
-        $this->optionsAlumno = $aAlumno;
-
-        //Listado de division
-        $c = new Criteria();
+        //Listado de division del establecimiento
+        $c->add(AnioPeer::FK_ESTABLECIMIENTO_ID, $this->getUser()->getAttribute('fk_establecimiento_id'));
+        $c->addJoin(AnioPeer::ID, DivisionPeer::FK_ANIO_ID);
         $aDivision = DivisionPeer::doSelect($c);
         $this->division = $aDivision;
 
@@ -177,15 +176,51 @@
         foreach($aDivision as $division) {
             $optionsDivision[$division->getId()] = $division->__toString();
         }
-        $this->optionsDivision = $optionsDivision;
+        return $optionsDivision;
 
     }
 
 
-    function executeSave()    {
-        $aAlumno = $this->getRequest()->getParameterHolder()->get('alumno');
-        $aDivision = $this->getRequest()->getParameterHolder()->get('division');
+    function executeEdit() {
+        //Listado de alumnos
+        $c = new Criteria();
+        $aAlumno = AlumnoPeer::doSelect($c);
+        $this->optionsAlumno = $aAlumno;
 
+        $this->optionsDivision = $this->getDivisionesDeEstablecimiento();
+        $this->alumnoDivision = $this->getAlumnosPorDivision();
+    }
+
+
+
+    function getAlumnosPorDivision() {
+    // Alumnos por division
+        $aAlumnoDivision = array();
+        $c = new Criteria();
+        $c->clearSelectColumns();
+        $c->addSelectColumn(AlumnoPeer::NOMBRE);
+        $c->addSelectColumn(AlumnoPeer::APELLIDO);
+        $c->addSelectColumn(DivisionPeer::ID);
+        $c->addSelectColumn(AlumnoPeer::ID);
+        $c->add(AnioPeer::FK_ESTABLECIMIENTO_ID, $this->getUser()->getAttribute('fk_establecimiento_id'));
+        $c->addJoin(AnioPeer::ID, DivisionPeer::FK_ANIO_ID);
+        $c->addJoin(RelAlumnoDivisionPeer::FK_DIVISION_ID, DivisionPeer::ID);
+        $c->addJoin(AlumnoPeer::ID, RelAlumnoDivisionPeer::FK_ALUMNO_ID);
+        $alumnosDivisiones = BasePeer::doSelect($c);
+        foreach($alumnosDivisiones as $alumnoDivision) {
+            if(!array_key_exists($alumnoDivision[2], $aAlumnoDivision)) {
+                $aAlumnoDivision["{$alumnoDivision['2']}"] = array();
+            }
+            array_push( $aAlumnoDivision["{$alumnoDivision['2']}"], (object) array(  'nombre' => $alumnoDivision[1].", ".$alumnoDivision[0], 'id' =>  $alumnoDivision[3])); 
+        }
+        return $aAlumnoDivision;
+    }
+
+
+    function save($aAlumno, $aDivision)    {
+//         $aAlumno = $this->getRequest()->getParameterHolder()->get('alumno');
+//         $aDivision = $this->getRequest()->getParameterHolder()->get('division');
+
         if(count($aAlumno) > 0) {
             if(count($aDivision) > 0) {
                 foreach($aAlumno as $alumno_id) {
@@ -198,7 +233,7 @@
                         RelAlumnoDivisionPeer::doDelete($c);
 
                         // Doy de alta la nueva relacion entre alumno y division
-                        $ad = new RelAlumnosDivision();
+                        $ad = new RelAlumnoDivision();
                         $ad->setFkAlumnoId($alumno_id);
                         $ad->setFkDivisionId($division_id);
                         $ad->save();
@@ -236,8 +271,18 @@
 //     return $this->redirect('relAlumnoDivision/list');
   }
     public function executeAsignarAlumno(){
-        print_r($_GET);
-        print_r($_POST);
-    }  
+        $division_id = $this->getRequestParameter('division_id');
+        $tmp = split('_', $this->getRequestParameter('id', ''));
+        $alumno_id = $tmp[1];
+        $this->save(array($alumno_id), array($division_id));
+
+        $aAlumno = $this->getAlumnosPorDivision();
+        if(array_key_exists($division_id, $aAlumno)) {
+            $this->alumnos = $aAlumno[$division_id];
+        } else {
+            $this->alumnos = array();
+        }
+
+    }
 }
 ?>

Added: prosistem/alba/trunk/alba/apps/principal/modules/relAlumnoDivision/templates/_listado_alumnos_division.php
===================================================================
--- prosistem/alba/trunk/alba/apps/principal/modules/relAlumnoDivision/templates/_listado_alumnos_division.php	                        (rev 0)
+++ prosistem/alba/trunk/alba/apps/principal/modules/relAlumnoDivision/templates/_listado_alumnos_division.php	2008-03-07 15:15:08 UTC (rev 5494)
@@ -0,0 +1,5 @@
+<?php 
+    foreach ($alumnos as $alumno) { 
+         echo $alumno->nombre."<br>";
+    } 
+?>

Modified: prosistem/alba/trunk/alba/apps/principal/modules/relAlumnoDivision/templates/_listado_divisiones.php
===================================================================
--- prosistem/alba/trunk/alba/apps/principal/modules/relAlumnoDivision/templates/_listado_divisiones.php	2008-03-04 21:22:22 UTC (rev 5493)
+++ prosistem/alba/trunk/alba/apps/principal/modules/relAlumnoDivision/templates/_listado_divisiones.php	2008-03-07 15:15:08 UTC (rev 5494)
@@ -15,11 +15,21 @@
     ?>
     <td>
     <?php echo $contenido;?>
-        <div id="division_<?php echo $indice?>" class="cart" style="position:relative;left:20px;"></div>
+        <div id="division_<?php echo $indice?>" class="cart" style="position:relative;left:20px;">
+
+<?php 
+    if (array_key_exists($indice, $alumnoDivision)) {
+        include_partial('relAlumnoDivision/listado_alumnos_division', array('alumnos' => $alumnoDivision[$indice]));
+    }
+?>
+
+        </div>
         <?php echo drop_receiving_element('division_'.$indice, array(
-        'url'        => 'relAlumnoDivision/asignarAlumno?division_id='.$indice,
+        'url'        => 'relAlumnoDivision?action=asignarAlumno&division_id='.$indice,
         'accept'     => 'alumno',
-       'update'     => 'division_'.$indice,)) ?> 
+        'script'     => true,
+        'update'     => 'division_'.$indice,
+        'method'     => 'get')) ?> 
     </td>
 <?php } ?>
     </tr>

Added: prosistem/alba/trunk/alba/apps/principal/modules/relAlumnoDivision/templates/asignarAlumnoSuccess.php
===================================================================
--- prosistem/alba/trunk/alba/apps/principal/modules/relAlumnoDivision/templates/asignarAlumnoSuccess.php	                        (rev 0)
+++ prosistem/alba/trunk/alba/apps/principal/modules/relAlumnoDivision/templates/asignarAlumnoSuccess.php	2008-03-07 15:15:08 UTC (rev 5494)
@@ -0,0 +1 @@
+<?php include_partial('relAlumnoDivision/listado_alumnos_division', array('alumnos' => $alumnos)); ?>

Modified: prosistem/alba/trunk/alba/apps/principal/modules/relAlumnoDivision/templates/busquedaDivisionSuccess.php
===================================================================
--- prosistem/alba/trunk/alba/apps/principal/modules/relAlumnoDivision/templates/busquedaDivisionSuccess.php	2008-03-04 21:22:22 UTC (rev 5493)
+++ prosistem/alba/trunk/alba/apps/principal/modules/relAlumnoDivision/templates/busquedaDivisionSuccess.php	2008-03-07 15:15:08 UTC (rev 5494)
@@ -1 +1 @@
-<?php include_partial('relAlumnoDivision/listado_divisiones', array('optionsDivision' => $optionsDivision)) ?>
+<?php include_partial('relAlumnoDivision/listado_divisiones', array('optionsDivision' => $optionsDivision, 'alumnoDivision' => $alumnoDivision )); ?>

Modified: prosistem/alba/trunk/alba/apps/principal/modules/relAlumnoDivision/templates/editSuccess.php
===================================================================
--- prosistem/alba/trunk/alba/apps/principal/modules/relAlumnoDivision/templates/editSuccess.php	2008-03-04 21:22:22 UTC (rev 5493)
+++ prosistem/alba/trunk/alba/apps/principal/modules/relAlumnoDivision/templates/editSuccess.php	2008-03-07 15:15:08 UTC (rev 5494)
@@ -1,16 +1,8 @@
-<?php
-// auto-generated by sfPropelAdmin
-// date: 2008/02/26 13:13:15
-?>
 <?php use_helper('Object', 'Validation', 'ObjectAdmin', 'I18N', 'Date') ?>
 <?php use_stylesheet('/sf/sf_admin/css/main') ?>
 <?php use_stylesheet('cart') ?>
-
 <div id="sf_admin_container">
-
-<h1><?php echo __('Asignar alumno a grado y secci&oacute;n', 
-array()) ?></h1>
-
+<h1><?php echo __('Asignar alumno a grado y secci&oacute;n', array()) ?></h1>
 <!-- Filtro Alumnos -->
 <?php echo form_remote_tag(array(
     'update'   => 'alumnos',
@@ -61,10 +53,6 @@
 )); echo $value ? $value : '&nbsp;' ?>
 
 
-<!-- 
-<?php echo select_tag('filtro_divisiones', options_for_select(array('Todos',  'No Asignados',), 0)) ?>
--->
-
     </div>
         <ul class="sf_admin_actions">
             <li><?php echo submit_tag(__('Buscar'), array ( 'class' => 'sf_admin_action_save',)) ?></li>
@@ -74,7 +62,7 @@
 
 <!-- Divisiones-->
 <div id="divisiones">
-<?php include_partial('relAlumnoDivision/listado_divisiones', array('optionsDivision' => $optionsDivision)) ?>
+<?php include_partial('relAlumnoDivision/listado_divisiones', array('optionsDivision' => $optionsDivision, 'alumnoDivision' => $alumnoDivision )) ?>
 </div>
 
 </div>
\ No newline at end of file




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