public function executeEspejo_reportes($tree_id, $list_data_indicador, $fecha_update)
 {
     // $tree_id = $request->getParameter('idTree');
     // $user = $this->getUser()->getAttribute(sfConfig::get('app_session_current_user'),null);
     if ($tree_id != 0) {
         $tree_espejo = TreeScPeer::retrieveByPK($tree_id);
         if (is_object($tree_espejo)) {
             try {
                 $conn = Propel::getConnection();
                 $conn->beginTransaction();
                 $tree_bean = new TmpTreeSc();
                 $tree_bean->setConfigureFlag($tree_espejo->getConfigureFlag());
                 $tree_bean->setFlag("ok");
                 $tree_bean->save();
                 $criterio = new Criteria();
                 $criterio->add(IndicatorsScPeer::TREE_ID, $tree_espejo->getId());
                 $criterio->add(IndicatorsScPeer::FLAG, '%habilitado%', Criteria::LIKE);
                 $criterio->addAscendingOrderByColumn(IndicatorsScPeer::ID);
                 $list_indicadores = IndicatorsScPeer::doSelect($criterio);
                 $list_relation = null;
                 foreach ($list_indicadores as $row) {
                     $indicator_bean = new TmpDataReports();
                     $indicator_bean->setIndicadorId($row->getId());
                     $indicator_bean->setValorMinimo($row->getValorMinimo());
                     $indicator_bean->setValorDeseado($row->getValorDeseado());
                     $indicator_bean->setValorOptimo($row->getValorOptimo());
                     $indicator_bean->setTreeId($tree_bean->getId());
                     $indicator_bean->setUltimoNodo($row->getUltimoNodo());
                     $indicator_bean->setUpdateAt($fecha_update);
                     $indicator_bean->setFlag("ok");
                     if ($row->getPreviousId() == 0) {
                         $indicator_bean->setPreviousId(0);
                     } else {
                         $id_relation = $this->return_relation_id($list_relation, $row->getPreviousId());
                         $indicator_bean->setPreviousId($id_relation);
                     }
                     if ($row->getParents() != "") {
                         $parents = $this->return_parent_relation($list_relation, $row->getParents());
                         $indicator_bean->setParents($parents);
                     }
                     //preguntar si es ultmo idicador
                     //->getUltimoNodo()
                     //si es ultimo nodo tengo que pasar la data actual
                     //a  data que se esta creando ->
                     $indicator_bean->setConectoresConfigure($row->getConectoresConfigure());
                     $indicator_bean->save();
                     //actualizo el valor actual entregado
                     $relation = array('array' => '' . $row->getId() . '-' . $indicator_bean->getId() . '');
                     $list_relation[] = $relation;
                 }
                 foreach ($list_data_indicador as $obj_data) {
                     $criteria = new Criteria();
                     $id = $this->return_relation_id($list_relation, $obj_data->getIndicadorId());
                     $criteria->add(TmpDataReportsPeer::ID, $id);
                     $obj_update_tmp = TmpDataReportsPeer::doSelectOne($criteria);
                     $obj_update_tmp->setData($obj_data->getData());
                     $obj_update_tmp->save();
                 }
                 $conn->commit();
                 $conn = Propel::close();
                 // VOY A DEVOLVER UN ARREGLO CON DOS VALORES 1) ID DEL TREE TEMPORAL, 2) LA LISTA DE LA RELACION
                 $result = array('array' => $tree_bean->getId(), "lista" => $list_relation);
                 return $result;
                 //$this->list_relation = $list_relation;
                 //$this->redirect('@edit_strategy?id_tree='.$tree_bean->getId());
             } catch (Exception $e) {
                 $conn->rollBack();
                 // $this->message = $e->getMessage();
                 $conn = Propel::close();
                 return sfView::ERROR;
             }
         } else {
             // $this->message = 'tree not definitive';
             $conn = Propel::close();
             return sfView::ERROR;
         }
     } else {
         //   $this->message = 'session expired';
         $conn = Propel::close();
         return sfView::ERROR;
     }
 }
 /**
  * Performs the work of inserting or updating the row in the database.
  *
  * If the object is new, it inserts it; otherwise an update is performed.
  * All related objects are also updated in this method.
  *
  * @param      PropelPDO $con
  * @return     int The number of rows affected by this insert/update and any referring fk objects' save() operations.
  * @throws     PropelException
  * @see        save()
  */
 protected function doSave(PropelPDO $con)
 {
     $affectedRows = 0;
     // initialize var to track total num of affected rows
     if (!$this->alreadyInSave) {
         $this->alreadyInSave = true;
         // We call the save method on the following object(s) if they
         // were passed to this object by their coresponding set
         // method.  This object relates to these object(s) by a
         // foreign key reference.
         if ($this->aTmpTreeSc !== null) {
             if ($this->aTmpTreeSc->isModified() || $this->aTmpTreeSc->isNew()) {
                 $affectedRows += $this->aTmpTreeSc->save($con);
             }
             $this->setTmpTreeSc($this->aTmpTreeSc);
         }
         if ($this->isNew()) {
             $this->modifiedColumns[] = TmpDataReportsPeer::ID;
         }
         // If this object has been modified, then save it to the database.
         if ($this->isModified()) {
             if ($this->isNew()) {
                 $pk = TmpDataReportsPeer::doInsert($this, $con);
                 $affectedRows += 1;
                 // we are assuming that there is only 1 row per doInsert() which
                 // should always be true here (even though technically
                 // BasePeer::doInsert() can insert multiple rows).
                 $this->setId($pk);
                 //[IMV] update autoincrement primary key
                 $this->setNew(false);
             } else {
                 $affectedRows += TmpDataReportsPeer::doUpdate($this, $con);
             }
             $this->resetModified();
             // [HL] After being saved an object is no longer 'modified'
         }
         $this->alreadyInSave = false;
     }
     return $affectedRows;
 }