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

commits en pressenter.com.ar commits en pressenter.com.ar
Lun Mar 3 20:04:44 CET 2008


Author: hsanchez
Date: 2008-03-03 17:04:44 -0200 (Mon, 03 Mar 2008)
New Revision: 5487

Added:
   prosistem/alba/trunk/alba/web/css/cart.css
Modified:
   prosistem/alba/trunk/alba/apps/principal/modules/relAlumnoDivision/actions/actions.class.php
   prosistem/alba/trunk/alba/apps/principal/modules/relAlumnoDivision/templates/editSuccess.php
Log:
cambiando pantall de relAlumnoDivision por otra interfaz con AJAX

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-02-27 19:52:59 UTC (rev 5486)
+++ prosistem/alba/trunk/alba/apps/principal/modules/relAlumnoDivision/actions/actions.class.php	2008-03-03 19:04:44 UTC (rev 5487)
@@ -1,5 +1,4 @@
 <?php
-
 /**
  *    This file is part of Alba.
  * 
@@ -61,6 +60,7 @@
 
 
     // Valida si ya esta en la tabla este conjunto de datos ( alumno, division )
+/*
     function validateEdit() {
          if ($this->getRequest()->getMethod() == sfRequest::POST) {
             $rel_alumno_division = $this->getRequestParameter('rel_alumno_division');
@@ -74,62 +74,85 @@
                 return false;
             }
         }
-        
         return true;
     }
+*/
 
+    function executeEdit() {
 
+        //Listado de alumnos
+        $c = new Criteria();
+        $aAlumno = AlumnoPeer::doSelect($c);
+        $this->optionsAlumno = $aAlumno;
 
+        //Listado de division
+        $c = new Criteria();
+        $aDivision = DivisionPeer::doSelect($c);
 
-  public function executeEdit()
-  {
-    $this->rel_alumno_division = $this->getRelAlumnoDivisionOrCreate();
+        $optionsDivision = array();
+        foreach($aDivision as $division) {
+            $optionsDivision[$division->getId()] = $division->__toString();
+        }
+        $this->optionsDivision = $optionsDivision;
+    }
 
-    if ($this->getRequest()->getMethod() == sfRequest::POST)
-    {
-      $this->updateRelAlumnoDivisionFromRequest();
-      $this->saveRelAlumnoDivision($this->rel_alumno_division);
-      $this->setFlash('notice', 'Your modifications have been saved');
 
-      if ($this->getRequestParameter('save_and_add')) {
-        return $this->redirect('relAlumnoDivision/create');
-      }
-      else if ($this->getRequestParameter('save_and_list'))
-      {
-        return $this->redirect('relAlumnoDivision/list');
-      }
-      else
-      {
-        return $this->redirect('relAlumnoDivision/edit?id='.$this->rel_alumno_division->getId());
-      }
+    function executeSave()    {
+        $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) {
+                    foreach($aDivision as $division_id) {
+
+                        //Borro si existe la relacion esta entre esta division y este alumno (Editar)
+                        $c =  new Criteria();
+                        $c->add(RelAlumnoDivisionPeer::FK_ALUMNO_ID, $alumno_id);
+                        $c->add(RelAlumnoDivisionPeer::FK_DIVISION_ID, $division_id);
+                        RelAlumnoDivisionPeer::doDelete($c);
+
+                        // Doy de alta la nueva relacion entre alumno y division
+                        $ad = new RelAlumnosDivision();
+                        $ad->setFkAlumnoId($alumno_id);
+                        $ad->setFkDivisionId($division_id);
+                        $ad->save();
+                        unset($ad);
+                    }
+                }
+            }
+        }
+
+//         return $this->redirect('relAlumnoDivision/edit?id='.$usuarioId);
     }
-    else
-    {
-      $this->labels = $this->getLabels();
-    }
-  }
 
 
+  public function executeDelete(){
 
-  public function executeDelete()
-  {
-    $this->rel_alumno_division = RelAlumnoDivisionPeer::retrieveByPk($this->getRequestParameter('id'));
-    $this->forward404Unless($this->rel_alumno_division);
+    $aAlumno = $this->getRequest()->getParameterHolder()->get('alumno');
+    $division_id = $this->getRequestParameter('division_id');
 
+    $c =  new Criteria();
+    $cton1 = $c->getNewCriterion(RelAlumnoDivisionPeer::FK_DIVISION_ID, $division_id);
+    foreach($aAlumno as $alumno_id) {
+        $cton1->addOr($c->getNewCriterion(RelAlumnoDivisionPeer::FK_DIVISION_ID, $division_id));
+    }
+    $c->add($cton1);
+
     try
     {
-      $this->deleteRelAlumnoDivision($this->rel_alumno_division);
+      RelAlumnoDivisionPeer::doDelete($c);
     }
     catch (PropelException $e)
     {
       $this->getRequest()->setError('delete', 'Could not delete the selected Rel alumno division. Make sure it does not have any associated items.');
-      return $this->forward('relAlumnoDivision', 'list');
+//       return $this->forward('relAlumnoDivision', 'list');
     }
-
-    return $this->redirect('relAlumnoDivision/list');
+//     return $this->redirect('relAlumnoDivision/list');
   }
-
-
-
+    public function executeAsignarAlumno(){
+        print_r($_GET);
+        print_r($_POST);
+    }  
 }
 ?>

Modified: prosistem/alba/trunk/alba/apps/principal/modules/relAlumnoDivision/templates/editSuccess.php
===================================================================
--- prosistem/alba/trunk/alba/apps/principal/modules/relAlumnoDivision/templates/editSuccess.php	2008-02-27 19:52:59 UTC (rev 5486)
+++ prosistem/alba/trunk/alba/apps/principal/modules/relAlumnoDivision/templates/editSuccess.php	2008-03-03 19:04:44 UTC (rev 5487)
@@ -4,28 +4,77 @@
 ?>
 <?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>
 
+<?php //print_r($rel_alumno_division)?>
+<?php //include_partial('relAlumnoDivision/edit_header', array('rel_alumno_division' => $rel_alumno_division)) ?>
 
+<!-- Filtro Alumnos -->
 
-<div id="sf_admin_header">
-<?php include_partial('relAlumnoDivision/edit_header', array('rel_alumno_division' => $rel_alumno_division)) ?>
-</div>
+<?php echo form_tag('relAlumnoDivision/list', array('method' => 'get')) ?>
 
-<div id="sf_admin_content">
-<?php include_partial('relAlumnoDivision/edit_messages', array('rel_alumno_division' => $rel_alumno_division, 'labels' => $labels)) ?>
-<?php include_partial('relAlumnoDivision/edit_form', array('rel_alumno_division' => $rel_alumno_division, 'labels' => $labels)) ?>
+<div id="filtros_alumnos">
+    Filtro Alumnos: 
+    <?php echo input_tag("filtro_nombre_alumnos", '', array (
+  'size' => 20, 'class'=>'text'
+)) ?>
+    <?php echo select_tag('filtro_alumnos', options_for_select(array(
+  'Todos',  'No Asignados',), 0)) ?>
+    </form>
 </div>
 
-<div id="sf_admin_footer">
-<?php include_partial('relAlumnoDivision/edit_footer', array('rel_alumno_division' => $rel_alumno_division)) ?>
+<!-- Alumnos -->
+<?php 
+  foreach ($optionsAlumno as $alumno)  {
+        ?>
+      <div id="<?php echo "alumno_".$alumno->getId()?>" class="alumno" style="position:relative;left:20px;"> <?php echo $alumno->getId() ." - " .$alumno->__toString()?> </div>
+<?php
+      echo draggable_element('alumno_'.$alumno->getId(), array('revert' => true));
+}
+?>
+
+<!-- Filtro Divisiones -->
+<br/>
+<?php echo form_tag('relAlumnoDivision/list', array('method' => 'get')) ?>
+<div id="filtros_secciones">
+    Filtro Divisiones:
+    <?php echo input_tag("filtro_nombre_divisiones", '', array (
+  'size' => 20, 'class'=>'text'
+)) ?>
+    <?php echo select_tag('filtro_divisiones', options_for_select(array(
+  'Todos',  'No Asignados',), 0)) ?>
+    </form>
 </div>
 
+<!-- Divisiones-->
+<table>
+    <tr>
+<?php 
+    $i=0;
+    foreach ($optionsDivision as $indice=>$contenido)  {
+        if ($i>5){
+            echo "</tr>";
+            $i=0;
+            echo "<tr>";
+        }   
+        $i+=1;
+    ?>
+    <td>
+    <?php
+        echo $contenido;?>
+        <div id="division_<?php echo $indice?>" class="cart" style="position:relative;left:20px;"></div>
+        <?php echo drop_receiving_element('division_'.$indice, array(
+        'url'        => 'relAlumnoDivision/asignarAlumno?division_id='.$indice,
+        'accept'     => 'alumno',
+       'update'     => 'division_'.$indice,)) ?> 
+    </td>
+<?php } ?>
+    </tr>
+</table>
 
-
-
 </div>

Added: prosistem/alba/trunk/alba/web/css/cart.css
===================================================================
--- prosistem/alba/trunk/alba/web/css/cart.css	                        (rev 0)
+++ prosistem/alba/trunk/alba/web/css/cart.css	2008-03-03 19:04:44 UTC (rev 5487)
@@ -0,0 +1,39 @@
+div.cart {
+background-color:#B3D4EF;
+border:1px solid #B3D4EF;
+clear:both;
+padding:8px;
+width:90px;
+}
+div#wastebin {
+border:1px solid #EEEEEE;
+padding:5px;
+width:135px;
+}
+div.cart img {
+cursor:move;
+float:left;
+height:32px;
+margin-right:10px;
+width:32px;
+}
+div.cart div {
+clear:left;
+font-weight:normal;
+}
+div.cart-active {
+background-color:#EEEEEE;
+}
+div.wastebin-active {
+background-color:#CCCCCC;
+padding:5px;
+width:135px;
+}
+#cart {
+clear:left;
+height:132px;
+margin:10px 0pt;
+}
+#product_list {
+height:120px;
+}




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