Commits

dgea...@gmail.com <  committed ae386ce

  • Participants
  • Parent commits 25a7788

Comments (0)

Files changed (2)

File assets/ejo.js

                                             document.getElementById("items").selectedIndex == document.getElementById("items").options.length-1;
   document.getElementById("ult").disabled = document.getElementById("alf").checked ||
                                             document.getElementById("items").selectedIndex == document.getElementById("items").options.length-1;
-  document.getElementById("jerarquia").value = aItems.join("$");
-  document.getElementById("relacion").value = aRelaciones.join("$");
+  document.getElementById("jerarquia").value = JSON.stringify(aItems);
+  document.getElementById("relacion").value = JSON.stringify(aRelaciones);
   
 //  limpiar("ArbolItems","Descripcion");
 //  document.getElementById("Descripcion").style.visibility = "hidden";

File controllers/ItemController.php

     $relaciones = $modelR->findAll();
     if (isset($_POST['jerarquia']) && isset($_POST['relacion'])) {
       $aRelaciones = array();
-      $aRelacion = explode("$", $_POST['relacion']);
-      $aJerarquia = explode("$", $_POST['jerarquia']);
+      $aRelacion = json_decode($_POST['relacion']);
+      $aJerarquia = json_decode($_POST['jerarquia']);
       $aPrincipales = array();
       $sSQL = "DELETE FROM $this->_relationsTable;";
       Yii::app()->db->createCommand($sSQL)->execute();
 
-      for ($i = 0; $i < count($aRelacion); $i++) {
-        $aItem = explode(",", $aRelacion[$i]);
+      foreach ($aRelacion as $i=>$aItem) {
         $sSQL = "INSERT INTO $this->_relationsTable (itmAncestro, itmCodigo) VALUES ({$aItem[0]},{$aItem[1]});";
         Yii::app()->db->createCommand($sSQL)->execute();
         $aRelaciones[] = $aItem;
       }
 
-      for ($i = 0; $i < count($aJerarquia); $i++) {
-        $aItem = explode(",", $aJerarquia[$i]);
+      foreach ($aJerarquia as $i => $aItem) {
         $sSQL = "UPDATE $this->_mainTable SET itmOrden = ({$i}+1) WHERE itmCodigo = {$aItem[0]};";
         Yii::app()->db->createCommand($sSQL)->execute();
       }