public function executeAjax_mostrar_sub_tree(sfWebRequest $request) { $user = $this->getUser()->getAttribute(sfConfig::get('app_session_current_user'), null); $tree_id = $request->getParameter('tree'); if ($user != null) { $criterio_indicadores = new Criteria(); $criterio_indicadores->add(IndicatorsScPeer::FLAG, '%habilitado%', Criteria::LIKE); $criterio_indicadores->add(IndicatorsScPeer::RESPONSABLE_ID, $user->getId()); $criterio_indicadores->add(IndicatorsScPeer::TREE_ID, $tree_id); $criterio_indicadores->add(TreeScPeer::FLAG, 1); $criterio_indicadores->add(TreeScPeer::PRODUCCION, '%production%', Criteria::LIKE); $criterio_indicadores->addJoin(TreeScPeer::ID, IndicatorsScPeer::TREE_ID); $criterio_indicadores->addAscendingOrderByColumn(IndicatorsScPeer::PREVIOUS_ID); $list = IndicatorsScPeer::doSelect($criterio_indicadores); $array = null; foreach ($list as $row) { $success = $this->validate_exist($array, $row->getId()); if ($success) { $array[] = array($row->getId(), 0, $row->getTitulo()); $lista_aux = $this->return_array_children($row->getId()); if ($lista_aux != null) { foreach ($lista_aux as $value) { $array[] = array($value->getId(), $value->getPreviousId(), $value->getTitulo()); } } } } $this->tree = TreeScPeer::retrieveByPK($tree_id); $this->array = $array; } else { $this->array = null; } }
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 executeAjax_mostrar_sub_tree(sfWebRequest $request) { $user = $this->getUser()->getAttribute(sfConfig::get('app_session_current_user'), null); $tree_id = $request->getParameter('tree'); if ($user != null) { $criterio_indicadores = new Criteria(); $criterio_indicadores->add(IndicatorsScPeer::FLAG, '%habilitado%', Criteria::LIKE); $criterio_indicadores->add(IndicatorsScPeer::RESPONSABLE_ID, $user->getId()); $criterio_indicadores->add(IndicatorsScPeer::TREE_ID, $tree_id); $criterio_indicadores->add(TreeScPeer::FLAG, 1); $criterio_indicadores->add(TreeScPeer::PRODUCCION, '%production%', Criteria::LIKE); $criterio_indicadores->addJoin(TreeScPeer::ID, IndicatorsScPeer::TREE_ID); $criterio_indicadores->addAscendingOrderByColumn(IndicatorsScPeer::PREVIOUS_ID); $list = IndicatorsScPeer::doSelect($criterio_indicadores); $array = null; foreach ($list as $row) { $success = $this->validate_exist($array, $row->getId()); if ($success) { $array[] = array($row->getId(), 0, $row->getTitulo(), $row->getValorMinimo(), $row->getValorDeseado(), $row->getValorActualEntregado(), $row->getConectoresConfigure()); $lista_aux = $this->return_array_children($row->getId()); if ($lista_aux != null) { foreach ($lista_aux as $value) { $array[] = array($value->getId(), $value->getPreviousId(), $value->getTitulo(), $value->getValorMinimo(), $value->getValorDeseado(), $value->getValorActualEntregado(), $value->getConectoresConfigure()); } } } } $this->tree = TreeScPeer::retrieveByPK($tree_id); /* con esto obtengo la fecha de proyeccion actual */ $criteria = new Criteria(); $criteria->add(IndicatorsScPeer::TREE_ID, $tree_id); $criteria->addJoin(IndicatorsScPeer::ID, DataIndicadoresPeer::INDICADOR_ID); $criteria->addDescendingOrderByColumn(DataIndicadoresPeer::CREATE_AT); $proyeccion = DataIndicadoresPeer::doSelectOne($criteria); $this->fechaProyeccion = $proyeccion->getCreateAt(); $this->array = $array; } else { $this->array = null; } }
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; } }
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; } }
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; } }