public function getItemsBaseOrdenados() { if (!$this->getPrimaryKey()) { return null; } if ($this->esTipoLista()) { $c = new Criteria(); $c->add(ItemBasePeer::ID_CAMPO, $this->getIdCampo()); $c->addAscendingOrderByColumn(ItemBasePeer::ORDEN); $items = ItemBasePeer::doSelect($c); return $items; } else { return null; } }
public function __toString($to_file = false) { include_once SF_ROOT_DIR . "/lib/symfony/helper/DateHelper.php"; if (!$this->getPrimaryKey()) { return null; } $campo = $this->getItemBase()->getCampo(); $value = null; if (!$campo->esTipoLista()) { if ($campo->esTipoTextoLargo()) { $value = $this->getTextoLargo(); } elseif ($campo->esTipoTextoCorto()) { $value = $this->getTextoCorto(); } elseif ($campo->esTipoDocumento()) { if ($this->getTextoCorto() != "") { $fname = explode("_", basename($this->getTextoCorto())); if (sizeof($fname) > 1) { $fname = substr(basename($this->getTextoCorto()), strlen($fname[0]) + 1); } else { $fname = $fname[0]; } if ($to_file) { $value = $fname; } else { $value = "<a href=\"" . dirname(UsuarioPeer::getRuta()) . "/index.php/formularios/download/?id_item=" . $this->getIdItem() . "&id_formulario=" . $this->getIdFormulario() . "\" target=\"_NEW\">" . $fname . "<a>"; } } else { $value = ""; } } elseif ($campo->esTipoNumero()) { $value = $this->getNumero(); } elseif ($campo->esTipoFecha()) { $value = format_date($this->getFecha(), "D"); } elseif ($campo->esTipoBooleano()) { if ($this->getSiNo()) { $value = sfContext::getInstance()->getI18N()->__("SI"); } else { $value = sfContext::getInstance()->getI18N()->__("NO"); } } elseif ($campo->esTipoSelectPeriodo()) { $value = nombre_periodo($campo->getTipoPeriodo(), $this->getNumero(), $this->getAnio()); } elseif ($campo->esTipoTabla()) { $form = FormularioPeer::retrieveByPk($this->getIdTabla()); if ($form != null) { $value = $form->__toString(); } else { $value = "--"; } } elseif ($campo->esTipoObjeto()) { eval("\$value = " . $campo->getValorObjeto() . "Peer::retrieveByPk(\$this->getIdObjeto());"); if ($value != null) { $value = $value->__toString(); } else { $value = "--"; } } } else { //Obtener los items del mismo formulario cuyo campo id_campo coincida con el de nuestro id_item_base $c = new Criteria(); $c->addAnd(ItemPeer::ID_FORMULARIO, $this->getIdFormulario(), Criteria::EQUAL); $c->addAnd(ItemPeer::SI_NO, 1, Criteria::EQUAL); $c->addJoin(ItemPeer::ID_ITEM_BASE, ItemBasePeer::ID_ITEM_BASE, Criteria::JOIN); $c->addAnd(ItemBasePeer::ID_CAMPO, $this->getItemBase()->getIdCampo(), Criteria::EQUAL); $items_base_seleccionados = ItemBasePeer::doSelect($c); if (sizeof($items_base_seleccionados)) { $value .= !$to_file ? "<ul class=\"sf_admin_checklist\">\n" : ""; foreach ($items_base_seleccionados as $ibs) { $value .= !$to_file ? "<li>" : ""; /****/ if ($campo->esListaTipoRangos()) { //lista de rangos $desde = null; $hasta = null; $unidad = CampoPeer::getHtmlTipoUnidad($campo->getUnidadRangos()); $unidad = $unidad ? " " . $unidad : ''; if ($ibs->getNumeroInferior() && $ibs->getNumeroInferior() != '') { $desde = format_number($ibs->getNumeroInferior()) . $unidad; } if ($ibs->getNumeroSuperior() && $ibs->getNumeroSuperior() != '') { $hasta = format_number($ibs->getNumeroSuperior()) . $unidad; } if ($desde && $hasta) { $value .= __('desde %1% hasta %2%', array('%1%' => $desde, '%2%' => $hasta)); } else { if ($desde) { $value .= __('más de %1%', array('%1%' => $desde)); } elseif ($hasta) { $value .= __('menos de %2%', array('%2%' => $hasta)); } else { $value .= null; } } } else { $value .= $ibs->getTexto(); } /****/ if ($ibs->getTextoAuxiliar()) { $texto_auxiliar = $this->getTextoAuxiliar() ? $this->getTextoAuxiliar() : null; $value .= isset($texto_auxiliar) ? " (" . $texto_auxiliar . ")" : ''; } $value .= !$to_file ? "</li>" : " - "; } $value .= !$to_file ? "</ul>\n" : ""; if (!$to_file) { $value = substr($value, 0, strlen($value) - 3); } } } return $value; }
/** * 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(ItemBasePeer::DATABASE_NAME, Propel::CONNECTION_READ); } $objs = null; if (empty($pks)) { $objs = array(); } else { $criteria = new Criteria(ItemBasePeer::DATABASE_NAME); $criteria->add(ItemBasePeer::ID_ITEM_BASE, $pks, Criteria::IN); $objs = ItemBasePeer::doSelect($criteria, $con); } return $objs; }
/** * Gets an array of ItemBase 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 Campo has previously been saved, it will retrieve * related ItemBases from storage. If this Campo 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 ItemBase[] * @throws PropelException */ public function getItemBases($criteria = null, PropelPDO $con = null) { if ($criteria === null) { $criteria = new Criteria(CampoPeer::DATABASE_NAME); } elseif ($criteria instanceof Criteria) { $criteria = clone $criteria; } if ($this->collItemBases === null) { if ($this->isNew()) { $this->collItemBases = array(); } else { $criteria->add(ItemBasePeer::ID_CAMPO, $this->id_campo); ItemBasePeer::addSelectColumns($criteria); $this->collItemBases = ItemBasePeer::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(ItemBasePeer::ID_CAMPO, $this->id_campo); ItemBasePeer::addSelectColumns($criteria); if (!isset($this->lastItemBaseCriteria) || !$this->lastItemBaseCriteria->equals($criteria)) { $this->collItemBases = ItemBasePeer::doSelect($criteria, $con); } } } $this->lastItemBaseCriteria = $criteria; return $this->collItemBases; }