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; }
protected function updateCampoFromRequest() { $campo = $this->getRequestParameter('campo'); $this->campo->setEsGeneral(isset($campo['es_general']) ? true : false); $this->campo->setEsNombre(isset($campo['es_nombre']) ? true : false); $this->campo->setObligatorio(isset($campo['obligatorio']) ? true : false); $this->campo->setMismaFila(isset($campo['misma_fila']) ? true : false); $this->campo->setEnLista(isset($campo['en_lista']) ? true : false); if (isset($campo['id_empresa'])) { $this->campo->setIdEmpresa($campo['id_empresa'] ? $campo['id_empresa'] : null); } if (isset($campo['nombre'])) { $this->campo->setNombre($campo['nombre']); } if (isset($campo['descripcion'])) { $this->campo->setDescripcion($campo['descripcion']); } if (isset($campo['tipo'])) { $this->campo->setTipo(isset($campo['tipo']) ? $campo['tipo'] : CampoPeer::getDefaultId()); } $this->campo->setSeleccionMultiple(isset($campo['seleccion_multiple']) ? true : false); $this->campo->setDesplegable(isset($campo['desplegable']) ? true : false); if (isset($campo['tipo_items'])) { $this->campo->setTipoItems($campo['tipo_items'] ? $campo['tipo_items'] : CampoPeer::getDefaultIdTipoItems()); } if (isset($campo['unidad_rangos'])) { $this->campo->setUnidadRangos($campo['unidad_rangos'] ? $campo['unidad_rangos'] : null); } if (isset($campo['tipo_periodo'])) { $this->campo->setTipoPeriodo($campo['tipo_periodo'] ? $campo['tipo_periodo'] : null); } if (isset($campo['tipo_tabla'])) { $this->campo->setValorTabla($campo['tipo_tabla'] ? $campo['tipo_tabla'] : null); } //Si el tipo es otra tabla, significa que se ha de mostrar en el padre, si es fecha significa que es ALARMA $this->campo->setMostrarEnPadre(isset($campo['mostrar_en_padre']) ? true : false); if (isset($campo['tipo_objeto'])) { $this->campo->setValorObjeto($campo['tipo_objeto'] ? $campo['tipo_objeto'] : null); } switch ($this->campo->getTipo()) { case CampoPeer::ID_TEXTO_CORTO: $this->campo->setTamano($campo['tamano_texto_corto'] ? $campo['tamano_texto_corto'] : null); break; case CampoPeer::ID_TEXTO_LARGO: $this->campo->setTamano($campo['tamano_texto_largo'] ? $campo['tamano_texto_largo'] : null); break; case CampoPeer::ID_NUMERO: $this->campo->setTamano($campo['tamano_numero'] ? $campo['tamano_numero'] : null); break; } switch ($this->campo->getTipo()) { case CampoPeer::ID_TEXTO_CORTO: $this->campo->setDefecto($campo['defecto_texto_corto']); break; case CampoPeer::ID_TEXTO_LARGO: $this->campo->setDefecto($campo['defecto_texto_largo']); break; case CampoPeer::ID_BOOLEANO: $this->campo->setDefecto($campo['defecto_sino']); break; case CampoPeer::ID_LISTA: $this->campo->setDefecto($campo['defecto_lista']); break; case CampoPeer::ID_TABLA: $this->campo->setDefecto($campo['defecto_tabla']); break; case CampoPeer::ID_OBJETO: $this->campo->setDefecto($campo['defecto_objeto']); break; case CampoPeer::ID_NUMERO: $this->campo->setDefecto($campo['defecto_numero']); break; case CampoPeer::ID_FECHA: $this->campo->setDefecto($campo['defecto_fecha']); break; } }
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; }
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; }
/** * Returns the number of related Campo objects. * * @param Criteria $criteria * @param boolean $distinct * @param PropelPDO $con * @return int Count of related Campo objects. * @throws PropelException */ public function countCampos(Criteria $criteria = null, $distinct = false, PropelPDO $con = null) { if ($criteria === null) { $criteria = new Criteria(EmpresaPeer::DATABASE_NAME); } else { $criteria = clone $criteria; } if ($distinct) { $criteria->setDistinct(); } $count = null; if ($this->collCampos === null) { if ($this->isNew()) { $count = 0; } else { $criteria->add(CampoPeer::ID_EMPRESA, $this->id_empresa); $count = CampoPeer::doCount($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 count of the collection. $criteria->add(CampoPeer::ID_EMPRESA, $this->id_empresa); if (!isset($this->lastCampoCriteria) || !$this->lastCampoCriteria->equals($criteria)) { $count = CampoPeer::doCount($criteria, $con); } else { $count = count($this->collCampos); } } else { $count = count($this->collCampos); } } return $count; }
<?php $nombre = CampoPeer::getNombreTipoItem($campo->getTipoItems()); echo $nombre ? $nombre : "-"; ?> </div> </div> <?php if ($campo->esListaTipoRangos()) { ?> <div class="form-row"> <?php echo label_for('campo[unidad_rangos]', __($labels['campo{unidad_rangos}']) . ":", ''); ?> <div class="content"> <?php $nombre = CampoPeer::getNombreTipoUnidad($campo->getUnidadRangos()); echo $nombre ? $nombre : "-"; ?> </div> </div> <?php } ?> <?php } ?> </fieldset> <?php include_partial('show_campo_actions', array('campo' => $campo, 'tabla' => $tabla));
/** * Selects a collection of ItemBase objects pre-filled with all related objects. * * @param Criteria $c * @param PropelPDO $con * @param String $join_behavior the type of joins to use, defaults to Criteria::LEFT_JOIN * @return array Array of ItemBase objects. * @throws PropelException Any exceptions caught during processing will be * rethrown wrapped into a PropelException. */ public static function doSelectJoinAll(Criteria $c, $con = null, $join_behavior = Criteria::LEFT_JOIN) { foreach (sfMixer::getCallables('BaseItemBasePeer:doSelectJoinAll:doSelectJoinAll') as $callable) { call_user_func($callable, 'BaseItemBasePeer', $c, $con); } $c = clone $c; // Set the correct dbName if it has not been overridden if ($c->getDbName() == Propel::getDefaultDB()) { $c->setDbName(self::DATABASE_NAME); } ItemBasePeer::addSelectColumns($c); $startcol2 = ItemBasePeer::NUM_COLUMNS - ItemBasePeer::NUM_LAZY_LOAD_COLUMNS; CampoPeer::addSelectColumns($c); $startcol3 = $startcol2 + (CampoPeer::NUM_COLUMNS - CampoPeer::NUM_LAZY_LOAD_COLUMNS); $c->addJoin(array(ItemBasePeer::ID_CAMPO), array(CampoPeer::ID_CAMPO), $join_behavior); $stmt = BasePeer::doSelect($c, $con); $results = array(); while ($row = $stmt->fetch(PDO::FETCH_NUM)) { $key1 = ItemBasePeer::getPrimaryKeyHashFromRow($row, 0); if (null !== ($obj1 = ItemBasePeer::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 { $omClass = ItemBasePeer::getOMClass(); $cls = substr('.' . $omClass, strrpos('.' . $omClass, '.') + 1); $obj1 = new $cls(); $obj1->hydrate($row); ItemBasePeer::addInstanceToPool($obj1, $key1); } // if obj1 already loaded // Add objects for joined Campo rows $key2 = CampoPeer::getPrimaryKeyHashFromRow($row, $startcol2); if ($key2 !== null) { $obj2 = CampoPeer::getInstanceFromPool($key2); if (!$obj2) { $omClass = CampoPeer::getOMClass(); $cls = substr('.' . $omClass, strrpos('.' . $omClass, '.') + 1); $obj2 = new $cls(); $obj2->hydrate($row, $startcol2); CampoPeer::addInstanceToPool($obj2, $key2); } // if obj2 loaded // Add the $obj1 (ItemBase) to the collection in $obj2 (Campo) $obj2->addItemBase($obj1); } // if joined row not null $results[] = $obj1; } $stmt->closeCursor(); return $results; }
public static function getCampoCodAgencia() { $c = TablaPeer::getCriterioAlcance(); $id_empresa = sfContext::getInstance()->getUser()->getAttribute('idempresa', 0); $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, $id_empresa, Criteria::EQUAL); $c->addAnd(TablaPeer::ES_FICHEROS, true, Criteria::EQUAL); $c->addAnd(CampoPeer::ES_COD_AGENCIA, true, Criteria::EQUAL); $campo = CampoPeer::doSelectOne($c); if ($campo instanceof Campo) { return $campo->getIdCampo(); } else { return 0; } }
public static function ItemBaseToTexto($item, $campo) { //use_helper('Number'); if (!$item) { return null; } if (!$item->getPrimaryKey()) { return null; } if (!$campo) { $campo = $item->getCampo(); } $value = null; if ($campo->esTipoLista()) { if ($campo->esListaTipoRangos()) { //lista de rangos $desde = null; $hasta = null; $unidad = CampoPeer::getHtmlTipoUnidad($campo->getUnidadRangos()); $unidad = $unidad ? " " . $unidad : ''; if ($item->getNumeroInferior() && $item->getNumeroInferior() != '') { $desde = $item->getNumeroInferior() . $unidad; } if ($item->getNumeroSuperior() && $item->getNumeroSuperior() != '') { $hasta = $item->getNumeroSuperior() . $unidad; } if ($desde && $hasta) { //$value = __('desde %1% hasta %2%' , array('%1%' => $desde , '%2%' => $hasta)); $value = sprintf('desde %s hasta %s', $desde, $hasta); } else { if ($desde) { //$value = __('más de %1%' , array('%1%' => $desde)); $value = sprintf('mas de %s', $desde); } elseif ($hasta) { //$value = __('menos de %2%' , array('%2%' => $hasta)); $value = sprintf('menos de %s', $hasta); } else { $value = null; } } } else { $value = $item->getTexto(); } } return $value; }
?> " /><?php echo ' ' . __('Inscripción de modificación de fichero <strong>M</strong>') . '<br />'; ?> <input type="text" name="bajas" size="1" maxlength="2" style="text-align: right" value="<?php if (strpos($respuesta, '<tot_bajas>') !== false) { echo $bajas[1]; } else { echo '0'; } ?> " /><?php echo ' ' . __('Inscripción de supresión de fichero <strong>S</strong>') . '<br />'; echo '<label style="margin-top:1%; margin-left:2%; margin-bottom: 1%; color:black">' . __('Código Inscripción') . '</label> '; if (strpos($respuesta, '<tot_altas>') === false) { $id_campo_codigo_agencia = CampoPeer::getCampoCodAgencia(); $c = new Criteria(); $c->addJoin(ItemPeer::ID_ITEM_BASE, ItemBasePeer::ID_ITEM_BASE, Criteria::JOIN); $c->addAnd(ItemPeer::ID_FORMULARIO, $id_fichero, Criteria::EQUAL); $c->addAnd(ItemBasePeer::ID_CAMPO, $id_campo_codigo_agencia, Criteria::EQUAL); $val_item = ItemPeer::doSelectOne($c); $codigo_agencia = $val_item->getTextoCorto(); echo input_tag('cod_ins', $codigo_agencia, array('style' => 'margin-top:1%; margin-bottom: 1%')) . '<br />'; } else { echo input_tag('cod_ins', '', array('style' => 'margin-top:1%; margin-bottom: 1%')) . '<br />'; } } else { echo '<fieldset style="margin-top:7px">' . strtoupper($notificacion->tipo) . __(' DE FICHERO') . '</fieldset>'; } ?> </div>
function nombre_periodo($duracion_periodo_meses = 1, $numero_periodo = null, $anio = null) { $resultado = null; if (isset($anio)) { if ($duracion_periodo_meses == 1) { if ($numero_periodo) { $mi_date = new Date(); $mi_date->setMonth($numero_periodo); $mi_date->setYear($anio); $resultado = format_date($mi_date->getTimestamp(), 'MMMM yyyy'); } else { $resultado = $anio; } } else { $lista_posiciones = array('1' => __('primer'), '2' => __('segundo'), '3' => __('tercer'), '4' => __('cuarto'), '5' => __('quinto'), '6' => __('sexto')); $tipos_periodo = CampoPeer::getTiposPeriodo(); $periodo = __('%posicion% %periodo%', array('%posicion%' => isset($lista_posiciones[$numero_periodo]) ? $lista_posiciones[$numero_periodo] : '', '%periodo%' => isset($tipos_periodo[$duracion_periodo_meses]) ? $tipos_periodo[$duracion_periodo_meses] : '')); if (isset($numero_periodo) && $numero_periodo != '') { $resultado = __('%periodo% de %year%', array('%periodo%' => $periodo, '%year%' => $anio)); } else { $resultado = $anio; } } } return $resultado; }
/** * Selects a collection of RelCampoTabla objects pre-filled with all related objects except Tabla. * * @param Criteria $c * @param PropelPDO $con * @param String $join_behavior the type of joins to use, defaults to Criteria::LEFT_JOIN * @return array Array of RelCampoTabla objects. * @throws PropelException Any exceptions caught during processing will be * rethrown wrapped into a PropelException. */ public static function doSelectJoinAllExceptTabla(Criteria $c, $con = null, $join_behavior = Criteria::LEFT_JOIN) { $c = clone $c; // Set the correct dbName if it has not been overridden // $c->getDbName() will return the same object if not set to another value // so == check is okay and faster if ($c->getDbName() == Propel::getDefaultDB()) { $c->setDbName(self::DATABASE_NAME); } RelCampoTablaPeer::addSelectColumns($c); $startcol2 = RelCampoTablaPeer::NUM_COLUMNS - RelCampoTablaPeer::NUM_LAZY_LOAD_COLUMNS; CampoPeer::addSelectColumns($c); $startcol3 = $startcol2 + (CampoPeer::NUM_COLUMNS - CampoPeer::NUM_LAZY_LOAD_COLUMNS); $c->addJoin(array(RelCampoTablaPeer::ID_CAMPO), array(CampoPeer::ID_CAMPO), $join_behavior); $stmt = BasePeer::doSelect($c, $con); $results = array(); while ($row = $stmt->fetch(PDO::FETCH_NUM)) { $key1 = RelCampoTablaPeer::getPrimaryKeyHashFromRow($row, 0); if (null !== ($obj1 = RelCampoTablaPeer::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 { $omClass = RelCampoTablaPeer::getOMClass(); $cls = substr('.' . $omClass, strrpos('.' . $omClass, '.') + 1); $obj1 = new $cls(); $obj1->hydrate($row); RelCampoTablaPeer::addInstanceToPool($obj1, $key1); } // if obj1 already loaded // Add objects for joined Campo rows $key2 = CampoPeer::getPrimaryKeyHashFromRow($row, $startcol2); if ($key2 !== null) { $obj2 = CampoPeer::getInstanceFromPool($key2); if (!$obj2) { $omClass = CampoPeer::getOMClass(); $cls = substr('.' . $omClass, strrpos('.' . $omClass, '.') + 1); $obj2 = new $cls(); $obj2->hydrate($row, $startcol2); CampoPeer::addInstanceToPool($obj2, $key2); } // if $obj2 already loaded // Add the $obj1 (RelCampoTabla) to the collection in $obj2 (Campo) $obj2->addRelCampoTabla($obj1); } // if joined row is not null $results[] = $obj1; } $stmt->closeCursor(); return $results; }
/** * Selects a collection of Tarea objects pre-filled with all related objects except Empresa. * * @param Criteria $c * @param PropelPDO $con * @param String $join_behavior the type of joins to use, defaults to Criteria::LEFT_JOIN * @return array Array of Tarea objects. * @throws PropelException Any exceptions caught during processing will be * rethrown wrapped into a PropelException. */ public static function doSelectJoinAllExceptEmpresa(Criteria $c, $con = null, $join_behavior = Criteria::LEFT_JOIN) { $c = clone $c; // Set the correct dbName if it has not been overridden // $c->getDbName() will return the same object if not set to another value // so == check is okay and faster if ($c->getDbName() == Propel::getDefaultDB()) { $c->setDbName(self::DATABASE_NAME); } TareaPeer::addSelectColumns($c); $startcol2 = TareaPeer::NUM_COLUMNS - TareaPeer::NUM_LAZY_LOAD_COLUMNS; FormularioPeer::addSelectColumns($c); $startcol3 = $startcol2 + (FormularioPeer::NUM_COLUMNS - FormularioPeer::NUM_LAZY_LOAD_COLUMNS); CampoPeer::addSelectColumns($c); $startcol4 = $startcol3 + (CampoPeer::NUM_COLUMNS - CampoPeer::NUM_LAZY_LOAD_COLUMNS); UsuarioPeer::addSelectColumns($c); $startcol5 = $startcol4 + (UsuarioPeer::NUM_COLUMNS - UsuarioPeer::NUM_LAZY_LOAD_COLUMNS); ParametroPeer::addSelectColumns($c); $startcol6 = $startcol5 + (ParametroPeer::NUM_COLUMNS - ParametroPeer::NUM_LAZY_LOAD_COLUMNS); $c->addJoin(array(TareaPeer::ID_FORMULARIO), array(FormularioPeer::ID_FORMULARIO), $join_behavior); $c->addJoin(array(TareaPeer::ID_CAMPO), array(CampoPeer::ID_CAMPO), $join_behavior); $c->addJoin(array(TareaPeer::ID_USUARIO), array(UsuarioPeer::ID_USUARIO), $join_behavior); $c->addJoin(array(TareaPeer::ID_ESTADO_TAREA), array(ParametroPeer::ID_PARAMETRO), $join_behavior); $stmt = BasePeer::doSelect($c, $con); $results = array(); while ($row = $stmt->fetch(PDO::FETCH_NUM)) { $key1 = TareaPeer::getPrimaryKeyHashFromRow($row, 0); if (null !== ($obj1 = TareaPeer::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 { $omClass = TareaPeer::getOMClass(); $cls = substr('.' . $omClass, strrpos('.' . $omClass, '.') + 1); $obj1 = new $cls(); $obj1->hydrate($row); TareaPeer::addInstanceToPool($obj1, $key1); } // if obj1 already loaded // Add objects for joined Formulario rows $key2 = FormularioPeer::getPrimaryKeyHashFromRow($row, $startcol2); if ($key2 !== null) { $obj2 = FormularioPeer::getInstanceFromPool($key2); if (!$obj2) { $omClass = FormularioPeer::getOMClass(); $cls = substr('.' . $omClass, strrpos('.' . $omClass, '.') + 1); $obj2 = new $cls(); $obj2->hydrate($row, $startcol2); FormularioPeer::addInstanceToPool($obj2, $key2); } // if $obj2 already loaded // Add the $obj1 (Tarea) to the collection in $obj2 (Formulario) $obj2->addTarea($obj1); } // if joined row is not null // Add objects for joined Campo rows $key3 = CampoPeer::getPrimaryKeyHashFromRow($row, $startcol3); if ($key3 !== null) { $obj3 = CampoPeer::getInstanceFromPool($key3); if (!$obj3) { $omClass = CampoPeer::getOMClass(); $cls = substr('.' . $omClass, strrpos('.' . $omClass, '.') + 1); $obj3 = new $cls(); $obj3->hydrate($row, $startcol3); CampoPeer::addInstanceToPool($obj3, $key3); } // if $obj3 already loaded // Add the $obj1 (Tarea) to the collection in $obj3 (Campo) $obj3->addTarea($obj1); } // if joined row is not null // Add objects for joined Usuario rows $key4 = UsuarioPeer::getPrimaryKeyHashFromRow($row, $startcol4); if ($key4 !== null) { $obj4 = UsuarioPeer::getInstanceFromPool($key4); if (!$obj4) { $omClass = UsuarioPeer::getOMClass(); $cls = substr('.' . $omClass, strrpos('.' . $omClass, '.') + 1); $obj4 = new $cls(); $obj4->hydrate($row, $startcol4); UsuarioPeer::addInstanceToPool($obj4, $key4); } // if $obj4 already loaded // Add the $obj1 (Tarea) to the collection in $obj4 (Usuario) $obj4->addTarea($obj1); } // if joined row is not null // Add objects for joined Parametro rows $key5 = ParametroPeer::getPrimaryKeyHashFromRow($row, $startcol5); if ($key5 !== null) { $obj5 = ParametroPeer::getInstanceFromPool($key5); if (!$obj5) { $omClass = ParametroPeer::getOMClass(); $cls = substr('.' . $omClass, strrpos('.' . $omClass, '.') + 1); $obj5 = new $cls(); $obj5->hydrate($row, $startcol5); ParametroPeer::addInstanceToPool($obj5, $key5); } // if $obj5 already loaded // Add the $obj1 (Tarea) to the collection in $obj5 (Parametro) $obj5->addTarea($obj1); } // if joined row is not null $results[] = $obj1; } $stmt->closeCursor(); return $results; }
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(); } }
public function executeDuplicate() { $empresa = $this->getEmpresaOrCreate(); //DUPLICAR LA EMPRESA $miempresa = new Empresa(); $empresa->copyInto($miempresa); $miempresa->setNombre("Copia de " . $empresa->getNombre()); $miempresa->save(); $tablas_equiv = array(); $campos_cambiar = array(); //DUPLICAMOS TABLAS $tablas = $empresa->getTablas(); foreach ($tablas as $tabla) { $mitabla = new Tabla(); $tabla->copyInto($mitabla); $mitabla->setIdEmpresa($miempresa->getIdEmpresa()); $mitabla->save(); //GUARDAMOS LAS EQUIVALENCIAS DE LAS TABLAS PARA LUEGO CAMBIAR LAS RELACIONES $tablas_equiv[$tabla->getIdtabla()] = $mitabla->getIdTabla(); $campos = $tabla->getRelCampoTablasJoinCampo(); foreach ($campos as $camp) { $campo = $camp->getCampo(); $items = $campo->getItemBases(); $micampo = new Campo(); $campo->copyInto($micampo); $micampo->setIdEmpresa($miempresa->getIdEmpresa()); $micampo->save(); if ($micampo->getTipo() == CampoPeer::ID_TABLA) { $campos_cambiar[] = $micampo->getIdCampo(); } //DUPLICAMOS ITEMS foreach ($items as $item) { $miitem = new ItemBase(); $item->copyInto($miitem); $miitem->setIdCampo($micampo->getIdCampo()); $miitem->save(); } $micamp = new RelCampoTabla(); $micamp->setIdCampo($micampo->getIdCampo()); $micamp->setIdTabla($mitabla->getIdTabla()); $micamp->save(); } } //AHORA CAMBIAMOS LOS ENLACES A LAS TABLAS foreach ($campos_cambiar as $camp) { $campo = CampoPeer::retrieveByPk($camp); $campo->setValorTabla($tablas_equiv[$campo->getValorTabla()]); $campo->save(); } return $this->redirect('tablas/list'); }
</td> <td align="center"><?php $value = null; if ($campo->getObligatorio()) { $value = image_tag('/images/icons/tick.png', array('alt' => __('ok'), 'title' => __('ok'))); } echo $value; ?> </td> <td><?php $nombre = $campo->__toString(); echo link_to($nombre ? $nombre : '-', 'formulario_modelo/show_campo/' . $direccion); ?> </td> <td><?php echo __(CampoPeer::getNombreTipo($campo->getTipo())); ?> </td> <td><?php echo $campo->getDescripcion(); ?> </td> <!-- <td><?php $value = null; if ($campo->getEsGeneral()) { $value = image_tag('/images/icons/tick.png', array('alt' => __('ok'), 'title' => __('ok'))); } else { $lista_rel = $campo->getRelCampoTablas(); $value = "<ul class='sf_admin_lista'>"; foreach ($lista_rel as $rel) {
/** * 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; }
/** * Get the associated Campo object * * @param PropelPDO Optional Connection object. * @return Campo The associated Campo object. * @throws PropelException */ public function getCampo(PropelPDO $con = null) { if ($this->aCampo === null && $this->id_campo !== null) { $c = new Criteria(CampoPeer::DATABASE_NAME); $c->add(CampoPeer::ID_CAMPO, $this->id_campo); $this->aCampo = CampoPeer::doSelectOne($c, $con); /* 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->aCampo->addTareas($this); */ } return $this->aCampo; }
?> form-error<?php } ?> "> <?php if ($sf_request->hasError('campo{tipo_periodo}')) { ?> <?php echo form_error('campo{tipo_periodo}', array('class' => 'form-error-msg')); ?> <?php } ?> <?php $lista_periodos = CampoPeer::getTiposPeriodo(); $opciones = options_for_select($lista_periodos, $campo->getTipoPeriodo(), array()); $value = select_tag('campo[tipo_periodo]', $opciones, array('control_name' => 'campo[tipo_periodo]')); echo $value ? $value : '-'; ?> <div class="sf_edit_help"><?php echo __('Indique el tipo de periodicidad'); ?> </div> </div> </div> <div class="form-row" id="capa_tabla" <?php if (!$campo->esTipoTabla()) { echo "style=\"display:none;\"";
public function esListaTipoRangos() { return CampoPeer::esListaTipoRangos($this->getTipoItems()); }
/** * 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 = CampoPeer::getFieldNames($keyType); if (array_key_exists($keys[0], $arr)) { $this->setIdCampo($arr[$keys[0]]); } if (array_key_exists($keys[1], $arr)) { $this->setIdEmpresa($arr[$keys[1]]); } if (array_key_exists($keys[2], $arr)) { $this->setEsGeneral($arr[$keys[2]]); } if (array_key_exists($keys[3], $arr)) { $this->setEsNombre($arr[$keys[3]]); } if (array_key_exists($keys[4], $arr)) { $this->setNombre($arr[$keys[4]]); } if (array_key_exists($keys[5], $arr)) { $this->setDescripcion($arr[$keys[5]]); } if (array_key_exists($keys[6], $arr)) { $this->setTipo($arr[$keys[6]]); } if (array_key_exists($keys[7], $arr)) { $this->setMismaFila($arr[$keys[7]]); } if (array_key_exists($keys[8], $arr)) { $this->setEnLista($arr[$keys[8]]); } if (array_key_exists($keys[9], $arr)) { $this->setDesplegable($arr[$keys[9]]); } if (array_key_exists($keys[10], $arr)) { $this->setSeleccionMultiple($arr[$keys[10]]); } if (array_key_exists($keys[11], $arr)) { $this->setTipoItems($arr[$keys[11]]); } if (array_key_exists($keys[12], $arr)) { $this->setUnidadRangos($arr[$keys[12]]); } if (array_key_exists($keys[13], $arr)) { $this->setTipoPeriodo($arr[$keys[13]]); } if (array_key_exists($keys[14], $arr)) { $this->setValorTabla($arr[$keys[14]]); } if (array_key_exists($keys[15], $arr)) { $this->setMostrarEnPadre($arr[$keys[15]]); } if (array_key_exists($keys[16], $arr)) { $this->setValorObjeto($arr[$keys[16]]); } if (array_key_exists($keys[17], $arr)) { $this->setDefecto($arr[$keys[17]]); } if (array_key_exists($keys[18], $arr)) { $this->setObligatorio($arr[$keys[18]]); } if (array_key_exists($keys[19], $arr)) { $this->setEsCodAgencia($arr[$keys[19]]); } if (array_key_exists($keys[20], $arr)) { $this->setTamano($arr[$keys[20]]); } if (array_key_exists($keys[21], $arr)) { $this->setOrden($arr[$keys[21]]); } if (array_key_exists($keys[22], $arr)) { $this->setEsInconsistente($arr[$keys[22]]); } if (array_key_exists($keys[23], $arr)) { $this->setBorrado($arr[$keys[23]]); } }