public function executeCreate_tree(sfWebRequest $request)
 {
     $request->setRequestFormat('json');
     $title = $request->getParameter('item_title');
     $user = $this->getUser()->getAttribute('s_current_user', null);
     if ($user != null) {
         try {
             $conn = Propel::getConnection();
             $conn->beginTransaction();
             $tree_bean = new TreeSc();
             $tree_bean->setName($title);
             $tree_bean->setUserId($user->getId());
             $tree_bean->setConfigureFlag('');
             $tree_bean->setConfigureDesign('');
             $tree_bean->setFlag(1);
             $tree_bean->save();
             $tree_user_bean = new TreeUser();
             $tree_user_bean->setUserId($tree_bean->getUserId());
             $tree_user_bean->setTreeId($tree_bean->getId());
             $tree_user_bean->save();
             $conn->commit();
             $this->message = 'success';
             $this->treepk = $tree_bean->getId();
             $this->title = $tree_bean->getName();
             return sfView::SUCCESS;
         } catch (Exception $e) {
             $this->message = $e->getMessage();
             return sfView::ERROR;
         }
     } else {
         $this->message = 'session expired';
         return sfView::ERROR;
     }
 }
 public function executeCreate_mirror_tree(sfWebRequest $request)
 {
     $tree_id = $request->getParameter('idTree');
     $user = $this->getUser()->getAttribute(sfConfig::get('app_session_current_user'), null);
     if ($user != null) {
         $tree_current = TreeScPeer::retrieveByPK($tree_id);
         if (is_object($tree_current)) {
             try {
                 $conn = Propel::getConnection();
                 $conn->beginTransaction();
                 $tree_bean = new TreeSc();
                 $tree_bean->setName($tree_current->getName());
                 $tree_bean->setUserId($tree_current->getUserId());
                 $tree_bean->setConfigureFlag($tree_current->getConfigureFlag());
                 $tree_bean->setConfigureDesign($tree_current->getConfigureDesign());
                 $tree_bean->setCreateAt(time());
                 $tree_bean->setUpdateAt(time());
                 $tree_bean->setFlag($tree_current->getFlag());
                 $tree_bean->setProduccion('not');
                 $tree_bean->setGrupoTrabajoId($tree_current->getGrupoTrabajoId());
                 $tree_bean->setPeriodoId($tree_current->getPeriodoId());
                 $tree_bean->save();
                 $tree_user_bean = new TreeUser();
                 $tree_user_bean->setUserId($tree_bean->getUserId());
                 $tree_user_bean->setTreeId($tree_bean->getId());
                 $tree_user_bean->save();
                 $criterio = new Criteria();
                 $criterio->add(IndicatorsScPeer::TREE_ID, $tree_current->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 IndicatorsSc();
                     $indicator_bean->setTitulo($row->getTitulo());
                     $indicator_bean->setDescripcion($row->getDescripcion());
                     $indicator_bean->setValorMinimo($row->getValorMinimo());
                     $indicator_bean->setValorDeseado($row->getValorDeseado());
                     $indicator_bean->setValorOptimo($row->getValorOptimo());
                     $indicator_bean->setResponsableId($row->getResponsableId());
                     $indicator_bean->setTreeId($tree_bean->getId());
                     $indicator_bean->setEmailResponsable($row->getEmailResponsable());
                     $indicator_bean->setUltimoNodo($row->getUltimoNodo());
                     $indicator_bean->setDetNetworkAttributeId($row->getDetNetworkAttributeId());
                     $indicator_bean->setUsernameInNetwork($row->getUsernameInNetwork());
                     $indicator_bean->setGaFecIni($row->getGaFecIni());
                     $indicator_bean->setGaFecFin($row->getGaFecFin());
                     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);
                     }
                     $indicator_bean->setFlag($row->getFlag());
                     $indicator_bean->setConectoresConfigure($row->getConectoresConfigure());
                     $indicator_bean->save();
                     $relation = array('array' => '' . $row->getId() . '-' . $indicator_bean->getId() . '');
                     $list_relation[] = $relation;
                 }
                 //  $conn->rollBack();
                 $tree_current->setFlag(2);
                 $tree_current->save();
                 $conn->commit();
                 $conn = Propel::close();
                 $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;
     }
 }