/**
  * Executes index action
  *
  * @param sfRequest $request A request object
  */
 public function executeStrategy(sfWebRequest $request)
 {
     $user = $this->getUser()->getAttribute(sfConfig::get('app_session_current_user'), null);
     $id_tree = $request->getParameter('id_tree');
     if ($user != null) {
         $criterio = new Criteria();
         $criterio->add(TreeScPeer::USER_ID, $user->getId());
         $criterio->add(TreeScPeer::ID, $id_tree);
         $criterio->add(TreeScPeer::FLAG, 1);
         $tree = TreeScPeer::doSelectOne($criterio);
         $criterio->clear();
         if (is_object($tree)) {
             $criterio->add(IndicatorsScPeer::TREE_ID, $tree->getId());
             $criterio->add(IndicatorsScPeer::FLAG, '%habilitado%', Criteria::LIKE);
             $criterio->addAscendingOrderByColumn(IndicatorsScPeer::PREVIOUS_ID);
             $list_indicadores = IndicatorsScPeer::doSelect($criterio);
             $criterio->clear();
             $criterio->add(GrupoTrabajoScPeer::OWNER_ID, $user->getId());
             $list_grupos = GrupoTrabajoScPeer::doSelect($criterio);
             $criterio->clear();
             $criterio->add(PeriodoScPeer::FLAG, '%activo%', Criteria::LIKE);
             $list_periodo = PeriodoScPeer::doSelect($criterio);
             $this->lista_indicadores = $list_indicadores;
             $this->lista_grupos = $list_grupos;
             $this->lista_periodos = $list_periodo;
             $this->tree = $tree;
         } else {
             return sfView::ERROR;
         }
         return sfView::SUCCESS;
     } else {
         return sfView::ERROR;
     }
 }
 /**
  * Executes index action
  *
  * @param sfRequest $request A request object
  */
 public function executeList(sfWebRequest $request)
 {
     $user = $this->getUser()->getAttribute('s_current_user', null);
     if ($user != null) {
         $criterio = new Criteria();
         $criterio->add(TreeScPeer::USER_ID, $user->getId());
         $criterio->add(TreeScPeer::FLAG, 1);
         $list_tree = TreeScPeer::doSelect($criterio);
         $this->list = $list_tree;
         return sfView::SUCCESS;
     } else {
         return sfView::ERROR;
     }
 }
 public function TreeExists($value = null, $type_search = "name")
 {
     if ($value != null) {
         //$criterio_busqueda = new Criteria();
         if ($type_search == "id") {
             $tree = TreeScPeer::retrieveByPK($value);
             if (is_object($tree)) {
                 return array("success" => true, "message" => "{TreeExists}-success", "object" => $tree);
             } else {
                 return array("success" => false, "message" => "{TreeExists}-objeto no encontrado");
             }
         } else {
             return array("success" => false, "message" => "{TreeExists}-parametro invalido!");
         }
     } else {
         return array("success" => false, "message" => "{TreeExists}-parametro invalido");
     }
 }
 public function returnCol_model($user, $indicator)
 {
     $criterio_busqueda = new Criteria();
     $criterio_busqueda->add(TreeScPeer::ID, $indicator[1]);
     $tree = TreeScPeer::doSelectOne($criterio_busqueda);
     $criterio_busqueda->clear();
     $criterio_busqueda->add(DataIndicadoresPeer::USER_ID, $user->getId());
     //    $criterio_busqueda->add(DataIndicadoresPeer::PERIODO_ID,$tree->getPeriodoId());
     $criterio_busqueda->add(DataIndicadoresPeer::INDICADOR_ID, $indicator[0]);
     $list = DataIndicadoresPeer::doSelect($criterio_busqueda);
     $var = "[";
     $var = $var . "{name:'name',index:'name', width:180, sorttype:'text',editable: false},{";
     $cantidad = 1;
     foreach ($list as $data) {
         $var = $var . "name:'f" . $cantidad . "',index:'f" . $cantidad . "',width:100,editable: true , editrules:{required:true,number:true} },";
         $var = $var . "{name:'idfecha" . $cantidad . "',index:'idfecha" . $cantidad . "',width:100,editable: true,hidden:true },{";
         $cantidad++;
     }
     $var = substr($var, 0, strlen($var) - 2) . ']';
     return $var;
 }
 public function executeIndex(sfWebRequest $request)
 {
     //validacion de session
     $userBean = $this->getUser()->getAttribute(sfConfig::get('app_session_current_user'), null);
     if ($userBean != null) {
         /*se realizan consultas para manejar los botones de inicio*/
         /*cantidad de Estrategias activas*/
         $criteria = new Criteria();
         $criteria->add(TreeScPeer::USER_ID, 1);
         $criteria->add(TreeScPeer::FLAG, 1);
         $count = TreeScPeer::doCount($criteria);
         /*cantidad de grupos activos*/
         $criteria->clear();
         $criteria->add(GrupoTrabajoScPeer::OWNER_ID, $userBean->getId());
         $cantidadGrupos = GrupoTrabajoScPeer::doCount($criteria);
         $this->count = $count;
         $this->countGroup = $cantidadGrupos;
         return sfView::SUCCESS;
     } else {
         return sfView::ERROR;
     }
 }
 public function executeUndo_tree_ajax(sfWebRequest $request)
 {
     $request->setRequestFormat('json');
     $id_tree = $request->getParameter('treeId');
     $production = $request->getParameter('production');
     $user = $this->getUser()->getAttribute(sfConfig::get('app_session_current_user'), null);
     if ($user != null) {
         $tree = TreeScPeer::retrieveByPK($id_tree);
         if (is_object($tree)) {
             //si es el dueño del arbol
             if ($tree->getUserId() == $user->getId()) {
                 $tree->setFlag(1);
                 if ($production == 'production') {
                     $tree->setProduccion('production');
                 }
                 $tree->save();
                 return sfView::SUCCESS;
             } else {
                 $this->message = 'owner not found';
                 return sfView::ERROR;
             }
         } else {
             $this->message = 'objet not found';
             return sfView::ERROR;
         }
     } else {
         $this->message = 'session expird';
         return sfView::ERROR;
     }
 }
 /**
  * Retrieve multiple objects by pkey.
  *
  * @param      array $pks List of primary keys
  * @param      PropelPDO $con the connection to use
  * @throws     PropelException Any exceptions caught during processing will be
  *		 rethrown wrapped into a PropelException.
  */
 public static function retrieveByPKs($pks, PropelPDO $con = null)
 {
     if ($con === null) {
         $con = Propel::getConnection(TreeScPeer::DATABASE_NAME, Propel::CONNECTION_READ);
     }
     $objs = null;
     if (empty($pks)) {
         $objs = array();
     } else {
         $criteria = new Criteria(TreeScPeer::DATABASE_NAME);
         $criteria->add(TreeScPeer::ID, $pks, Criteria::IN);
         $objs = TreeScPeer::doSelect($criteria, $con);
     }
     return $objs;
 }
 private function fn_EliminarTree($treeId)
 {
     $criteria = new Criteria();
     $criteria->add(TreeScPeer::ID, $treeId);
     TreeScPeer::doDelete($criteria);
 }
 public function executeAccept_group(sfWebRequest $request)
 {
     $invitacion_id = $request->getParameter('invitacion');
     $token_seguridad = $request->getParameter('token');
     $email_token = $request->getParameter('email');
     $user_token = $request->getParameter('account');
     /*vamos a aceptar permanecer a un grupo
        aca realizo validacion en 5 capas
           1 reviso que la session de usuario exista
           2 que la el valor obtenido en la consulta sea un object(que la consulta sql resulte con el registro solicitado)
           3 el token de la solicitud sea correcto
           4 el email sea correcto
           5 que el usuario id sea correcto (este es id del usuario que envio la solicitud en md5)
       */
     $user = $this->getUser()->getAttribute(sfConfig::get('app_session_current_user'), null);
     if ($user != null) {
         $solicitud = SolicitudGrupoTrabajoScPeer::retrieveByPK($invitacion_id);
         if (is_object($solicitud)) {
             if ($token_seguridad == $solicitud->getToken()) {
                 if ($email_token == md5($user->getEmail())) {
                     if ($user_token == md5($solicitud->getUserId())) {
                         $solicitud->setRespondido(1);
                         $solicitud->setFlag(json_encode(array("estado" => false, "respuesta" => true)));
                         $solicitud->setUpdateAt(time());
                         $solicitud->save();
                         //falta cambiar los indicadores que esten relacionados al grupo
                         /*vamos a obtener todos los arboles que esten relacionados con el grupo
                           depues vamos a obtener todos los indicadores donde el usuario se encuentre
                           asignado y vamos a aumetar el ID en cada registro que encontremos*/
                         //admemas vamos hacer lo mismo en las asignaciones para tener un mejor indexacion
                         //a la hora de hacer las consultas.
                         $criterio_tree = new Criteria();
                         $criterio_tree->add(TreeScPeer::GRUPO_TRABAJO_ID, $solicitud->getGrupoId());
                         $list_tree = TreeScPeer::doSelect($criterio_tree);
                         foreach ($list_tree as $row) {
                             $con = Propel::getConnection();
                             $criterio_busqueda = new Criteria();
                             $criterio_busqueda->add(IndicatorsScPeer::EMAIL_RESPONSABLE, '%' . $solicitud->getEmail() . '%', Criteria::LIKE);
                             $criterio_busqueda->add(IndicatorsScPeer::TREE_ID, $row->getId());
                             $criterio_update = new Criteria();
                             $criterio_update->add(IndicatorsScPeer::RESPONSABLE_ID, $user->getId());
                             BasePeer::doUpdate($criterio_busqueda, $criterio_update, $con);
                             $con = Propel::close();
                         }
                         $con = Propel::getConnection();
                         $criterio_asignaciones = new Criteria();
                         $criterio_asignaciones->add(AsignacionScPeer::GRUPO_ID, $solicitud->getGrupoId());
                         $criterio_asignaciones->add(AsignacionScPeer::EMAIL, '%' . $user->getEmail() . '%', Criteria::LIKE);
                         $criterio_update = new Criteria();
                         $criterio_update->add(AsignacionScPeer::USER_ID, $user->getId());
                         BasePeer::doUpdate($criterio_asignaciones, $criterio_update, $con);
                         $con = Propel::close();
                         $grupo_trabajo = new DetalleGrupoTrabajoSc();
                         $grupo_trabajo->setEmail($user->getEmail());
                         $grupo_trabajo->setUserId($user->getId());
                         $grupo_trabajo->setGrupoId($solicitud->getGrupoId());
                         $grupo_trabajo->save();
                         $this->redirect('@list_working_groups');
                     } else {
                         return sfView::ERROR;
                     }
                 } else {
                     return sfView::ERROR;
                 }
             } else {
                 return sfView::ERROR;
             }
         } else {
             return sfView::ERROR;
         }
     } else {
         return sfView::ERROR;
     }
 }
 /**
  * Selects a collection of AsignacionSc objects pre-filled with all related objects except UserSc.
  *
  * @param      Criteria  $criteria
  * @param      PropelPDO $con
  * @param      String    $join_behavior the type of joins to use, defaults to Criteria::LEFT_JOIN
  * @return     array Array of AsignacionSc objects.
  * @throws     PropelException Any exceptions caught during processing will be
  *		 rethrown wrapped into a PropelException.
  */
 public static function doSelectJoinAllExceptUserSc(Criteria $criteria, $con = null, $join_behavior = Criteria::LEFT_JOIN)
 {
     $criteria = clone $criteria;
     // Set the correct dbName if it has not been overridden
     // $criteria->getDbName() will return the same object if not set to another value
     // so == check is okay and faster
     if ($criteria->getDbName() == Propel::getDefaultDB()) {
         $criteria->setDbName(self::DATABASE_NAME);
     }
     AsignacionScPeer::addSelectColumns($criteria);
     $startcol2 = AsignacionScPeer::NUM_COLUMNS - AsignacionScPeer::NUM_LAZY_LOAD_COLUMNS;
     GrupoTrabajoScPeer::addSelectColumns($criteria);
     $startcol3 = $startcol2 + (GrupoTrabajoScPeer::NUM_COLUMNS - GrupoTrabajoScPeer::NUM_LAZY_LOAD_COLUMNS);
     TreeScPeer::addSelectColumns($criteria);
     $startcol4 = $startcol3 + (TreeScPeer::NUM_COLUMNS - TreeScPeer::NUM_LAZY_LOAD_COLUMNS);
     IndicatorsScPeer::addSelectColumns($criteria);
     $startcol5 = $startcol4 + (IndicatorsScPeer::NUM_COLUMNS - IndicatorsScPeer::NUM_LAZY_LOAD_COLUMNS);
     $criteria->addJoin(AsignacionScPeer::GRUPO_ID, GrupoTrabajoScPeer::ID, $join_behavior);
     $criteria->addJoin(AsignacionScPeer::TREE_ID, TreeScPeer::ID, $join_behavior);
     $criteria->addJoin(AsignacionScPeer::INDICADOR_ID, IndicatorsScPeer::ID, $join_behavior);
     // symfony_behaviors behavior
     foreach (sfMixer::getCallables(self::getMixerPreSelectHook(__FUNCTION__)) as $sf_hook) {
         call_user_func($sf_hook, 'BaseAsignacionScPeer', $criteria, $con);
     }
     $stmt = BasePeer::doSelect($criteria, $con);
     $results = array();
     while ($row = $stmt->fetch(PDO::FETCH_NUM)) {
         $key1 = AsignacionScPeer::getPrimaryKeyHashFromRow($row, 0);
         if (null !== ($obj1 = AsignacionScPeer::getInstanceFromPool($key1))) {
             // We no longer rehydrate the object, since this can cause data loss.
             // See http://propel.phpdb.org/trac/ticket/509
             // $obj1->hydrate($row, 0, true); // rehydrate
         } else {
             $cls = AsignacionScPeer::getOMClass(false);
             $obj1 = new $cls();
             $obj1->hydrate($row);
             AsignacionScPeer::addInstanceToPool($obj1, $key1);
         }
         // if obj1 already loaded
         // Add objects for joined GrupoTrabajoSc rows
         $key2 = GrupoTrabajoScPeer::getPrimaryKeyHashFromRow($row, $startcol2);
         if ($key2 !== null) {
             $obj2 = GrupoTrabajoScPeer::getInstanceFromPool($key2);
             if (!$obj2) {
                 $cls = GrupoTrabajoScPeer::getOMClass(false);
                 $obj2 = new $cls();
                 $obj2->hydrate($row, $startcol2);
                 GrupoTrabajoScPeer::addInstanceToPool($obj2, $key2);
             }
             // if $obj2 already loaded
             // Add the $obj1 (AsignacionSc) to the collection in $obj2 (GrupoTrabajoSc)
             $obj2->addAsignacionSc($obj1);
         }
         // if joined row is not null
         // Add objects for joined TreeSc rows
         $key3 = TreeScPeer::getPrimaryKeyHashFromRow($row, $startcol3);
         if ($key3 !== null) {
             $obj3 = TreeScPeer::getInstanceFromPool($key3);
             if (!$obj3) {
                 $cls = TreeScPeer::getOMClass(false);
                 $obj3 = new $cls();
                 $obj3->hydrate($row, $startcol3);
                 TreeScPeer::addInstanceToPool($obj3, $key3);
             }
             // if $obj3 already loaded
             // Add the $obj1 (AsignacionSc) to the collection in $obj3 (TreeSc)
             $obj3->addAsignacionSc($obj1);
         }
         // if joined row is not null
         // Add objects for joined IndicatorsSc rows
         $key4 = IndicatorsScPeer::getPrimaryKeyHashFromRow($row, $startcol4);
         if ($key4 !== null) {
             $obj4 = IndicatorsScPeer::getInstanceFromPool($key4);
             if (!$obj4) {
                 $cls = IndicatorsScPeer::getOMClass(false);
                 $obj4 = new $cls();
                 $obj4->hydrate($row, $startcol4);
                 IndicatorsScPeer::addInstanceToPool($obj4, $key4);
             }
             // if $obj4 already loaded
             // Add the $obj1 (AsignacionSc) to the collection in $obj4 (IndicatorsSc)
             $obj4->addAsignacionSc($obj1);
         }
         // if joined row is not null
         $results[] = $obj1;
     }
     $stmt->closeCursor();
     return $results;
 }
 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;
     }
 }
 /**
  * Populates the object using an array.
  *
  * This is particularly useful when populating an object from one of the
  * request arrays (e.g. $_POST).  This method goes through the column
  * names, checking to see whether a matching key exists in populated
  * array. If so the setByName() method is called for that column.
  *
  * You can specify the key type of the array by additionally passing one
  * of the class type constants BasePeer::TYPE_PHPNAME, BasePeer::TYPE_STUDLYPHPNAME,
  * BasePeer::TYPE_COLNAME, BasePeer::TYPE_FIELDNAME, BasePeer::TYPE_NUM.
  * The default key type is the column's phpname (e.g. 'AuthorId')
  *
  * @param      array  $arr     An array to populate the object from.
  * @param      string $keyType The type of keys the array uses.
  * @return     void
  */
 public function fromArray($arr, $keyType = BasePeer::TYPE_PHPNAME)
 {
     $keys = TreeScPeer::getFieldNames($keyType);
     if (array_key_exists($keys[0], $arr)) {
         $this->setId($arr[$keys[0]]);
     }
     if (array_key_exists($keys[1], $arr)) {
         $this->setName($arr[$keys[1]]);
     }
     if (array_key_exists($keys[2], $arr)) {
         $this->setDescripcion($arr[$keys[2]]);
     }
     if (array_key_exists($keys[3], $arr)) {
         $this->setUserId($arr[$keys[3]]);
     }
     if (array_key_exists($keys[4], $arr)) {
         $this->setGrupoTrabajoId($arr[$keys[4]]);
     }
     if (array_key_exists($keys[5], $arr)) {
         $this->setPeriodoId($arr[$keys[5]]);
     }
     if (array_key_exists($keys[6], $arr)) {
         $this->setResponsableId($arr[$keys[6]]);
     }
     if (array_key_exists($keys[7], $arr)) {
         $this->setEmailResponsable($arr[$keys[7]]);
     }
     if (array_key_exists($keys[8], $arr)) {
         $this->setValorMinimo($arr[$keys[8]]);
     }
     if (array_key_exists($keys[9], $arr)) {
         $this->setValorDeseado($arr[$keys[9]]);
     }
     if (array_key_exists($keys[10], $arr)) {
         $this->setConfigureFlag($arr[$keys[10]]);
     }
     if (array_key_exists($keys[11], $arr)) {
         $this->setFlag($arr[$keys[11]]);
     }
     if (array_key_exists($keys[12], $arr)) {
         $this->setCreateAt($arr[$keys[12]]);
     }
     if (array_key_exists($keys[13], $arr)) {
         $this->setUpdateAt($arr[$keys[13]]);
     }
     if (array_key_exists($keys[14], $arr)) {
         $this->setConfigureDesign($arr[$keys[14]]);
     }
     if (array_key_exists($keys[15], $arr)) {
         $this->setProduccion($arr[$keys[15]]);
     }
 }
 public function executeDelete_tree(sfWebRequest $request)
 {
     $tree_id = $request->getParameter('treePk');
     $tree = TreeScPeer::retrieveByPK($tree_id);
     if (is_object($tree)) {
         $tree->setFlag(2);
         $tree->save();
         return sfView::SUCCESS;
     } else {
         return sfView::ERROR;
     }
 }
 /**
  * Get the associated TreeSc object
  *
  * @param      PropelPDO Optional Connection object.
  * @return     TreeSc The associated TreeSc object.
  * @throws     PropelException
  */
 public function getTreeSc(PropelPDO $con = null)
 {
     if ($this->aTreeSc === null && $this->tree_id !== null) {
         $this->aTreeSc = TreeScPeer::retrieveByPk($this->tree_id);
         /* The following can be used additionally to
         		   guarantee the related object contains a reference
         		   to this object.  This level of coupling may, however, be
         		   undesirable since it could result in an only partially populated collection
         		   in the referenced object.
         		   $this->aTreeSc->addTreeUsers($this);
         		 */
     }
     return $this->aTreeSc;
 }
 /**
  * If this collection has already been initialized with
  * an identical criteria, it returns the collection.
  * Otherwise if this PeriodoSc is new, it will return
  * an empty collection; or if this PeriodoSc has previously
  * been saved, it will retrieve related TreeScs from storage.
  *
  * This method is protected by default in order to keep the public
  * api reasonable.  You can provide public methods for those you
  * actually need in PeriodoSc.
  */
 public function getTreeScsJoinUserScRelatedByResponsableId($criteria = null, $con = null, $join_behavior = Criteria::LEFT_JOIN)
 {
     if ($criteria === null) {
         $criteria = new Criteria(PeriodoScPeer::DATABASE_NAME);
     } elseif ($criteria instanceof Criteria) {
         $criteria = clone $criteria;
     }
     if ($this->collTreeScs === null) {
         if ($this->isNew()) {
             $this->collTreeScs = array();
         } else {
             $criteria->add(TreeScPeer::PERIODO_ID, $this->id);
             $this->collTreeScs = TreeScPeer::doSelectJoinUserScRelatedByResponsableId($criteria, $con, $join_behavior);
         }
     } else {
         // the following code is to determine if a new query is
         // called for.  If the criteria is the same as the last
         // one, just return the collection.
         $criteria->add(TreeScPeer::PERIODO_ID, $this->id);
         if (!isset($this->lastTreeScCriteria) || !$this->lastTreeScCriteria->equals($criteria)) {
             $this->collTreeScs = TreeScPeer::doSelectJoinUserScRelatedByResponsableId($criteria, $con, $join_behavior);
         }
     }
     $this->lastTreeScCriteria = $criteria;
     return $this->collTreeScs;
 }
 public function executeAjax_mostrar_indicators(sfWebRequest $request)
 {
     $user = $this->getUser()->getAttribute(sfConfig::get('app_session_current_user'), null);
     $id_indicators = $request->getParameter('indicators_id');
     if ($user != null) {
         //busco el la cabecera desde donde se armara el arbol
         $criterio = new Criteria();
         $criterio->add(IndicatorsScPeer::ID, $id_indicators);
         $obj_indicators = IndicatorsScPeer::doSelectOne($criterio);
         $id_tree = $obj_indicators->getTreeId();
         // saco el id del arbol
         $id_indicators = $obj_indicators->getId();
         //saco el id del indicador
         $criterio->clear();
         $criterio->add(IndicatorsScPeer::TREE_ID, $id_tree);
         $list_indicators_by_tree = IndicatorsScPeer::doSelect($criterio);
         // obtengo la lista de indicadores por arbol
         $criterio->clear();
         //obtengo el arbol
         $criterio->add(TreeScPeer::ID, $id_tree);
         $tree = TreeScPeer::doSelectOne($criterio);
         $criterio->clear();
         //realizo el metodo
         $this->tree = $tree;
         $criterio->add(IndicatorsScPeer::TREE_ID, $tree->getId());
         $criterio->add(IndicatorsScPeer::FLAG, '%habilitado%', Criteria::LIKE);
         $criterio->addAscendingOrderByColumn(IndicatorsScPeer::PREVIOUS_ID);
         $list_indicadores = IndicatorsScPeer::doSelect($criterio);
         $this->lista_indicadores = $list_indicadores;
         //variables
         $cont = 0;
         $indice;
         $recurso = new practil_lib();
         $array = array();
         $array_general = array();
         //recorro la lista de los indicadores
         foreach ($list_indicadores as $obj) {
             if ($cont == 0) {
                 $indice = $id_indicators;
             }
             if ($obj->getPreviousId() == $indice) {
                 //obtengo el codigo del previuos
                 $array_general[] = $obj->getId();
             }
         }
         // $array = $recurso->add_ids_indicators_to_array($array_general, $array);
         $flat = true;
         while ($flat) {
             foreach ($list_indicadores as $obj2) {
                 for ($j = 0; $j < count($array_general); $j++) {
                     $indice = $array_general[$j];
                     print_r($obj2->getPreviousId());
                     if ($obj2->getPreviousId() == $indice) {
                         //obtengo el codigo del previuos
                         print_r("entro");
                         $array_general[] = $obj->getId();
                     }
                 }
             }
             $flat = false;
         }
         print_r("salio");
         $this->arreglo = $array_general;
         return sfView::SUCCESS;
     } else {
         return sfView::ERROR;
     }
 }
 /**
  * Executes index action
  *
  * @param sfRequest $request A request object
  */
 public function executeIndex(sfWebRequest $request)
 {
     $user = $this->getUser()->getAttribute(sfConfig::get('app_session_current_user'), null);
     /* primero vamos a ver en que cantidad de arboles estoy relacionado para armar los tabs
      * y si en caso este relacionado mandar los valores correspondientes del primer arbol
      * para harmar el primer tabs .... los siguientes se armaran por ajax
      */
     $criterio_busqueda = new Criteria();
     $criterio_busqueda->add(IndicatorsScPeer::RESPONSABLE_ID, $user->getId());
     $criterio_busqueda->add(IndicatorsScPeer::FLAG, '%habilitado%', Criteria::LIKE);
     $criterio_busqueda->add(TreeScPeer::PRODUCCION, '%production%', Criteria::LIKE);
     $criterio_busqueda->add(TreeScPeer::FLAG, 1);
     $criterio_busqueda->addJoin(TreeScPeer::ID, IndicatorsScPeer::TREE_ID);
     $criterio_busqueda->addGroupByColumn(TreeScPeer::ID);
     $list_tree = TreeScPeer::doSelect($criterio_busqueda);
     if (count($list_tree) > 0) {
         $criterio_busqueda->clear();
         $criterio_busqueda->add(IndicatorsScPeer::RESPONSABLE_ID, $user->getId());
         $criterio_busqueda->add(IndicatorsScPeer::ULTIMO_NODO, 1);
         $criterio_busqueda->add(IndicatorsScPeer::TREE_ID, $list_tree[0]->getId());
         $criterio_busqueda->addSelectColumn(IndicatorsScPeer::ID);
         $criterio_busqueda->addSelectColumn(IndicatorsScPeer::TREE_ID);
         $list_first_indicador = IndicatorsScPeer::doSelectStmt($criterio_busqueda);
         $this->list_first_indicador = $list_first_indicador;
     }
     $this->list_tree = $list_tree;
     $this->user = $user;
     ///////////////////////////////////////////////////////////////////////////////////
     /* $criterio = new Criteria();
         $criterio->add(DataIndicadoresPeer::INDICADOR_ID,24);
         $criterio->addDescendingOrderByColumn(DataIndicadoresPeer::CREATE_AT);
         $data = DataIndicadoresPeer::doSelectOne($criterio);
     
         $ultima_de_fecha_registro = new DateTime($data->getCreateAt());
         $ultima_de_fecha_registro = $ultima_de_fecha_registro->format('Y-m-d');
         $array = explode('-', $ultima_de_fecha_registro);
     
         $fecha_actual = mktime(0,0,0,date('m'),date("d"),date('Y'));
         $fecha_actual = date('Y-m-d',$fecha_actual);
     
        /* if($fecha_proyectada<=$fecha_actual){}
        $periodo = 1;
         //semanal
         if($periodo==1){
               $fecha_proyectada = mktime(0,0,0,$array[1],$array[2]+7,$array[0]);
               $fecha_proyectada = date('Y-m-d',$fecha_proyectada);
          //cada quincena
         }elseif($periodo==2){
                 //si el dia de ultimo registro en menos a quince
                 //busco el 15 de ese mes    
                 if($array[2]<15){                       
                     //la fecha programada es:
                    $fecha_proyectada= $this->obtener_fecha_por_dia(15);
                 }else{             
                    $fecha_proyectada= $this->obtener_fecha_por_dia(1);
                 }
          //cada mes
         }else{
             $fecha_proyectada = mktime(0,0,0,date('m')+1,1,date('Y'));
             $fecha_proyectada = date('Y-m-d',$fecha_proyectada);
         }
     */
 }