public function getCamposFormularioEmpresaTabla($solo_en_lista = false) { $c = new Criteria(); $c->addJoin(CampoPeer::ID_CAMPO, RelCampoTablaPeer::ID_CAMPO, Criteria::JOIN); $c->addJoin(RelCampoTablaPeer::ID_TABLA, TablaPeer::ID_TABLA, Criteria::JOIN); $cr1 = $c->getNewCriterion(TablaPeer::ID_EMPRESA, $this->getIdEmpresa(), Criteria::EQUAL); $cr2 = $c->getNewCriterion(CampoPeer::ES_GENERAL, true, Criteria::EQUAL); $cr1->addAnd($cr2); $c->addOr($cr1); $c->addAscendingOrderByColumn(CampoPeer::ORDEN); $campos_generales_empresa = CampoPeer::doSelect($c); $cb = new Criteria(); $cb->addJoin(CampoPeer::ID_CAMPO, RelCampoTablaPeer::ID_CAMPO); $cb->add(RelCampoTablaPeer::ID_TABLA, $this->getIdTabla()); if ($solo_en_lista) { $c->addAnd(CampoPeer::EN_LISTA, true, Criteria::EQUAL); } $cb->addAscendingOrderByColumn(CampoPeer::ORDEN); $campos_tabla = CampoPeer::doSelect($cb); $campos = array_merge($campos_generales_empresa, $campos_tabla); return $campos; }
public function getCamposFormularioOrdenadosGenerales() { $c = new Criteria(); $c->addJoin(CampoPeer::ID_CAMPO, RelCampoTablaPeer::ID_CAMPO, Criteria::JOIN); $c->addJoin(RelCampoTablaPeer::ID_TABLA, TablaPeer::ID_TABLA, Criteria::JOIN); $c->addAnd(TablaPeer::ID_EMPRESA, $this->getIdEmpresa(), Criteria::EQUAL); $c->addAnd(CampoPeer::ES_GENERAL, true); $c->addAscendingOrderByColumn(CampoPeer::ORDEN); $campos = CampoPeer::doSelect($c); return $campos; }
/** * Gets an array of Campo objects which contain a foreign key that references this object. * * If this collection has already been initialized with an identical Criteria, it returns the collection. * Otherwise if this Empresa has previously been saved, it will retrieve * related Campos from storage. If this Empresa is new, it will return * an empty collection or the current collection, the criteria is ignored on a new object. * * @param PropelPDO $con * @param Criteria $criteria * @return array Campo[] * @throws PropelException */ public function getCampos($criteria = null, PropelPDO $con = null) { if ($criteria === null) { $criteria = new Criteria(EmpresaPeer::DATABASE_NAME); } elseif ($criteria instanceof Criteria) { $criteria = clone $criteria; } if ($this->collCampos === null) { if ($this->isNew()) { $this->collCampos = array(); } else { $criteria->add(CampoPeer::ID_EMPRESA, $this->id_empresa); CampoPeer::addSelectColumns($criteria); $this->collCampos = CampoPeer::doSelect($criteria, $con); } } else { // criteria has no effect for a new object if (!$this->isNew()) { // 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(CampoPeer::ID_EMPRESA, $this->id_empresa); CampoPeer::addSelectColumns($criteria); if (!isset($this->lastCampoCriteria) || !$this->lastCampoCriteria->equals($criteria)) { $this->collCampos = CampoPeer::doSelect($criteria, $con); } } } $this->lastCampoCriteria = $criteria; return $this->collCampos; }
/** * 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(CampoPeer::DATABASE_NAME, Propel::CONNECTION_READ); } $objs = null; if (empty($pks)) { $objs = array(); } else { $criteria = new Criteria(CampoPeer::DATABASE_NAME); $criteria->add(CampoPeer::ID_CAMPO, $pks, Criteria::IN); $objs = CampoPeer::doSelect($criteria, $con); } return $objs; }
public function executeEdit() { if ($this->getRequestParameter('layout', '')) { $this->setLayout('popup'); } $this->tablaFicheros = TablaPeer::getTablaFicheros(); $this->id_formulario_proviene = $this->getRequestParameter('id_formulario_proviene', null); $this->id_tabla_proviene = $this->getRequestParameter('id_tabla_proviene', null); $this->formulario = $this->getFormularioOrCreate(); $this->items = $this->formulario->getArrayItems(); if ($this->getRequest()->getMethod() == sfRequest::POST) { //GENERAMOS EL ID DEL FORMULARIO PARA QUE LO PUEDA COGER LA TAREA AL GUARDALA if ($this->formulario->getIdFormulario() == 0) { $this->saveFormulario($this->formulario); } $this->updateFormularioFromRequest(); $this->saveFormulario($this->formulario); $this->getUser()->setFlash('notice', 'Las modificaciones se han guardado'); if ($this->getRequestParameter('save_and_add')) { if ($this->id_formulario_proviene != null) { return $this->redirect('formularios/create/?id_tabla=' . $this->formulario->getIdTabla() . "&id_formulario_proviene=" . $this->id_formulario_proviene); } else { return $this->redirect('formularios/create/?id_tabla=' . $this->formulario->getIdTabla()); } } else { if ($this->getRequestParameter('save_and_list')) { /*$ruta=sfContext::getInstance()->getUser()->getAttribute('ruta_legedia',null);*/ $ruta = UsuarioPeer::getRuta(); if ($this->id_formulario_proviene != null) { return $this->redirect('formularios/edit?id_formulario=' . $this->id_formulario_proviene); } else { $dir = $ruta . "/formularios/list/?filters[id_empresa]=" . $this->formulario->getTabla()->getIdEmpresa() . "&filters[id_tabla]=" . $this->formulario->getIdTabla() . "&filter=filter"; header("location: {$dir}"); } exit; //return $this->redirect('formularios/list'); } else { if ($this->id_formulario_proviene != null) { return $this->redirect('formularios/edit?id_formulario=' . $this->id_formulario_proviene); } else { $pre = str_replace('formularios/edit', 'notificaciones/inscribir/id_fichero/', Notificaciones::selfURL()); if (isset($_POST['modelo']) && isset($_POST['sistema']) && isset($_POST['tip'])) { header('Location: ' . $pre . $this->formulario->getIdFormulario() . '?model=' . $_POST['modelo'] . '&type=' . $_POST['tip'] . '&system=' . $_POST['sistema'] . '&redirect=1'); } elseif (isset($_POST['modelo']) && isset($_POST['sistema'])) { header('Location: ' . $pre . $this->formulario->getIdFormulario() . '?model=' . $_POST['modelo'] . '&system=' . $_POST['sistema'] . '&redirect=1'); } else { //echo "--".$this->formulario->getIdFormulario();exit(); return $this->redirect('formularios/edit?id_formulario=' . $this->formulario->getIdFormulario()); } } } } } else { $this->tablas_auxiliares = array(); if ($this->formulario->getIdFormulario() != 0) { //Obtengo si hay un campo de tipo Tabla cuya tabla sea esta y tenga el mostrar_en_padre $c = new Criteria(); $c->AddJoin(CampoPeer::ID_CAMPO, RelCampoTablaPeer::ID_CAMPO, Criteria::JOIN); $c->AddJoin(RelCampoTablaPeer::ID_TABLA, TablaPeer::ID_TABLA, Criteria::JOIN); $id_empresa = sfContext::getInstance()->getUser()->getAttribute('idempresa', 0); $c->addAnd(TablaPeer::ID_EMPRESA, $id_empresa, Criteria::EQUAL); $c->addAnd(CampoPeer::TIPO, CampoPeer::ID_TABLA, Criteria::EQUAL); $c->addAnd(CampoPeer::MOSTRAR_EN_PADRE, 1, Criteria::EQUAL); $c->addAnd(CampoPeer::VALOR_TABLA, $this->formulario->getIdTabla(), Criteria::EQUAL); $campos_rel = CampoPeer::doSelect($c); foreach ($campos_rel as $campo_rel) { //DEL CAMPO OBTENEMOS LA TABLA $tablas_rel = $campo_rel->getRelCampoTablas(); $tabla_rel = $tablas_rel[0]; unset($tablas_rel); $c = $this->getCriterio(); $c->addJoin(FormularioPeer::ID_FORMULARIO, ItemPeer::ID_FORMULARIO, Criteria::JOIN); $c->addJoin(ItemPeer::ID_ITEM_BASE, ItemBasePeer::ID_ITEM_BASE, Criteria::JOIN); $c->addAnd(ItemBasePeer::ID_CAMPO, $campo_rel->getIdCampo(), Criteria::EQUAL); $c->addAnd(ItemPeer::ID_TABLA, $this->formulario->getIdFormulario(), Criteria::EQUAL); $c->addAnd(FormularioPeer::ID_TABLA, $tabla_rel->getIdTabla(), Criteria::EQUAL); $this->processSort(false); $this->addSortCriteria($c); $c->setDistinct(); $pager = new sfPropelPager('Formulario', sfConfig::get('app_listas_formularios')); $pager->setPeerMethod('doSelectJoinTabla'); $pager->setCriteria($c); $pager->setPage($this->getRequestParameter('page', 1)); $pager->init(); $this->tablas_auxiliares[] = array("forms" => $pager, "id_tabla" => $tabla_rel->getIdTabla()); } } $this->labels = $this->getLabels(); } }