<?php $criteriaT = new Criteria(); $criteriaT->add(TurnoPeer::FK_CICLOLECTIVO_ID, $sf_user->getAttribute('fk_ciclolectivo_id')); $turnos = TurnoPeer::doSelect($criteriaT); $optionsTurnos = array(); $optionsTurnos[""] = "--Seleccione un Turno--"; foreach ($turnos as $turno) { $optionsTurnos[$turno->getId()] = $turno->getDescripcion(); } asort($optionsTurnos); echo select_tag('division[fk_turno_id]', options_for_select($optionsTurnos, $division->getFkTurnoId()));
public function countTurnos(Criteria $criteria = null, $distinct = false, PropelPDO $con = null) { if ($criteria === null) { $criteria = new Criteria(CiclolectivoPeer::DATABASE_NAME); } else { $criteria = clone $criteria; } if ($distinct) { $criteria->setDistinct(); } $count = null; if ($this->collTurnos === null) { if ($this->isNew()) { $count = 0; } else { $criteria->add(TurnoPeer::FK_CICLOLECTIVO_ID, $this->id); $count = TurnoPeer::doCount($criteria, $con); } } else { if (!$this->isNew()) { $criteria->add(TurnoPeer::FK_CICLOLECTIVO_ID, $this->id); if (!isset($this->lastTurnoCriteria) || !$this->lastTurnoCriteria->equals($criteria)) { $count = TurnoPeer::doCount($criteria, $con); } else { $count = count($this->collTurnos); } } else { $count = count($this->collTurnos); } } return $count; }
public function fromArray($arr, $keyType = BasePeer::TYPE_PHPNAME) { $keys = TurnoPeer::getFieldNames($keyType); if (array_key_exists($keys[0], $arr)) { $this->setId($arr[$keys[0]]); } if (array_key_exists($keys[1], $arr)) { $this->setFkCiclolectivoId($arr[$keys[1]]); } if (array_key_exists($keys[2], $arr)) { $this->setHoraInicio($arr[$keys[2]]); } if (array_key_exists($keys[3], $arr)) { $this->setHoraFin($arr[$keys[3]]); } if (array_key_exists($keys[4], $arr)) { $this->setDescripcion($arr[$keys[4]]); } }
/** * Retrieve multiple objects by pkey. * * @param array $pks List of primary keys * @param PropelPDO $con the connection to use * @return Turno[] * @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(TurnoPeer::DATABASE_NAME, Propel::CONNECTION_READ); } $objs = null; if (empty($pks)) { $objs = array(); } else { $criteria = new Criteria(TurnoPeer::DATABASE_NAME); $criteria->add(TurnoPeer::ID, $pks, Criteria::IN); $objs = TurnoPeer::doSelect($criteria, $con); } return $objs; }
public function executeGrabarTurnosYPeriodos() { $ciclolectivo = $this->getRequestParameter('ciclolectivo'); if (is_numeric($ciclolectivo['id'])) { $this->ciclolectivo = CiclolectivoPeer::retrieveByPk($ciclolectivo['id']); if (isset($ciclolectivo['descripcion'])) { $this->ciclolectivo->setDescripcion($ciclolectivo['descripcion']); } if (isset($ciclolectivo['fecha_fin'])) { if ($ciclolectivo['fecha_fin']) { list($d, $m, $y) = sfContext::getInstance()->getI18N()->getDateForCulture($ciclolectivo['fecha_fin'], $this->getUser()->getCulture()); $this->ciclolectivo->setFechaFin("{$y}-{$m}-{$d}"); } } if (isset($ciclolectivo['fecha_inicio'])) { if ($ciclolectivo['fecha_inicio']) { list($d, $m, $y) = sfContext::getInstance()->getI18N()->getDateForCulture($ciclolectivo['fecha_inicio'], $this->getUser()->getCulture()); $this->ciclolectivo->setFechaInicio("{$y}-{$m}-{$d}"); } } $this->ciclolectivo->save(); } $aTurnos = $this->getRequestParameter('turnos'); if (is_array($aTurnos)) { foreach ($aTurnos as $turnos) { $horaInicio = $this->_add_zeros($turnos['hora_inicio']['hour'], 2) . ":" . $this->_add_zeros($turnos['hora_inicio']['minute'], 2) . " " . $turnos['hora_inicio']['ampm']; $horaFin = $this->_add_zeros($turnos['hora_fin']['hour'], 2) . ":" . $this->_add_zeros($turnos['hora_fin']['minute'], 2) . " " . $turnos['hora_fin']['ampm']; if ($turnos['descripcion'] and $horaInicio != $horaFin) { if (isset($turnos['id']) and is_numeric($turnos['id'])) { $this->turnos = TurnoPeer::retrieveByPk($turnos['id']); } else { $this->turnos = new Turno(); } if (isset($turnos['descripcion'])) { $this->turnos->setDescripcion($turnos['descripcion']); } $this->turnos->setHoraInicio($horaInicio); $this->turnos->setHoraFin($horaFin); $this->turnos->setFkCiclolectivoId($ciclolectivo['id']); $this->turnos->save(); } } } $aPeriodo = $this->getRequestParameter('periodo'); if (is_array($aPeriodo)) { foreach ($aPeriodo as $periodo) { if ($periodo['descripcion'] and ($periodo['fecha_inicio'] or $periodo['fecha_fin'])) { if (isset($periodo['id']) and is_numeric($periodo['id'])) { $this->periodo = PeriodoPeer::retrieveByPk($periodo['id']); } else { $this->periodo = new Periodo(); } if (isset($periodo['descripcion'])) { $this->periodo->setDescripcion($periodo['descripcion']); } if (isset($periodo['calcular'])) { $this->periodo->setCalcular($periodo['calcular']); } else { $this->periodo->setCalcular(false); } if (isset($periodo['formula'])) { $this->periodo->setFormula($periodo['formula']); } if (isset($periodo['fecha_inicio'])) { if ($periodo['fecha_inicio']) { list($d, $m, $y) = sfContext::getInstance()->getI18N()->getDateForCulture($periodo['fecha_inicio'], $this->getUser()->getCulture()); $this->periodo->setFechaInicio("{$y}-{$m}-{$d}"); } } if (isset($periodo['fecha_fin'])) { if ($periodo['fecha_fin']) { list($d, $m, $y) = sfContext::getInstance()->getI18N()->getDateForCulture($periodo['fecha_fin'], $this->getUser()->getCulture()); $this->periodo->setFechaFin("{$y}-{$m}-{$d}"); } } $this->periodo->setFkCiclolectivoId($ciclolectivo['id']); $this->periodo->save(); } } } return $this->redirect('ciclolectivo/agregarTurnosYPeriodos?id=' . $ciclolectivo['id']); }
/** * 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 = TurnoPeer::getFieldNames($keyType); if (array_key_exists($keys[0], $arr)) { $this->setId($arr[$keys[0]]); } if (array_key_exists($keys[1], $arr)) { $this->setNombre($arr[$keys[1]]); } if (array_key_exists($keys[2], $arr)) { $this->setCreatedAt($arr[$keys[2]]); } if (array_key_exists($keys[3], $arr)) { $this->setUpdatedAt($arr[$keys[3]]); } }
/** * Find object by primary key using raw SQL to go fast. * Bypass doSelect() and the object formatter by using generated code. * * @param mixed $key Primary key to use for the query * @param PropelPDO $con A connection object * * @return Turno A model object, or null if the key is not found * @throws PropelException */ protected function findPkSimple($key, $con) { $sql = 'SELECT `ID`, `NOMBRE`, `CREATED_AT`, `UPDATED_AT` FROM `siga_turno` WHERE `ID` = :p0'; try { $stmt = $con->prepare($sql); $stmt->bindValue(':p0', $key, PDO::PARAM_INT); $stmt->execute(); } catch (Exception $e) { Propel::log($e->getMessage(), Propel::LOG_ERR); throw new PropelException(sprintf('Unable to execute SELECT statement [%s]', $sql), $e); } $obj = null; if ($row = $stmt->fetch(PDO::FETCH_NUM)) { $obj = new Turno(); $obj->hydrate($row); TurnoPeer::addInstanceToPool($obj, (string) $key); } $stmt->closeCursor(); return $obj; }
<?php $aTurnos = array(); $c = new Criteria(); $c->add(TurnoPeer::FK_CICLOLECTIVO_ID, $sf_user->getAttribute('fk_ciclolectivo_id')); $sqlTurnos = TurnoPeer::doSelect($c); foreach ($sqlTurnos as $turnos) { $aTurnos[$turnos->getId()] = $turnos->getDescripcion(); } echo select_tag("horarioescolar[fk_turno_id]", options_for_select($aTurnos, $horarioescolar->getFkTurnoId()));
public static function doSelectJoinAllExceptOrientacion(Criteria $c, $con = null, $join_behavior = Criteria::LEFT_JOIN) { $c = clone $c; if ($c->getDbName() == Propel::getDefaultDB()) { $c->setDbName(self::DATABASE_NAME); } DivisionPeer::addSelectColumns($c); $startcol2 = DivisionPeer::NUM_COLUMNS - DivisionPeer::NUM_LAZY_LOAD_COLUMNS; AnioPeer::addSelectColumns($c); $startcol3 = $startcol2 + (AnioPeer::NUM_COLUMNS - AnioPeer::NUM_LAZY_LOAD_COLUMNS); TurnoPeer::addSelectColumns($c); $startcol4 = $startcol3 + (TurnoPeer::NUM_COLUMNS - TurnoPeer::NUM_LAZY_LOAD_COLUMNS); $c->addJoin(array(DivisionPeer::FK_ANIO_ID), array(AnioPeer::ID), $join_behavior); $c->addJoin(array(DivisionPeer::FK_TURNO_ID), array(TurnoPeer::ID), $join_behavior); $stmt = BasePeer::doSelect($c, $con); $results = array(); while ($row = $stmt->fetch(PDO::FETCH_NUM)) { $key1 = DivisionPeer::getPrimaryKeyHashFromRow($row, 0); if (null !== ($obj1 = DivisionPeer::getInstanceFromPool($key1))) { } else { $omClass = DivisionPeer::getOMClass(); $cls = substr('.' . $omClass, strrpos('.' . $omClass, '.') + 1); $obj1 = new $cls(); $obj1->hydrate($row); DivisionPeer::addInstanceToPool($obj1, $key1); } $key2 = AnioPeer::getPrimaryKeyHashFromRow($row, $startcol2); if ($key2 !== null) { $obj2 = AnioPeer::getInstanceFromPool($key2); if (!$obj2) { $omClass = AnioPeer::getOMClass(); $cls = substr('.' . $omClass, strrpos('.' . $omClass, '.') + 1); $obj2 = new $cls(); $obj2->hydrate($row, $startcol2); AnioPeer::addInstanceToPool($obj2, $key2); } $obj2->addDivision($obj1); } $key3 = TurnoPeer::getPrimaryKeyHashFromRow($row, $startcol3); if ($key3 !== null) { $obj3 = TurnoPeer::getInstanceFromPool($key3); if (!$obj3) { $omClass = TurnoPeer::getOMClass(); $cls = substr('.' . $omClass, strrpos('.' . $omClass, '.') + 1); $obj3 = new $cls(); $obj3->hydrate($row, $startcol3); TurnoPeer::addInstanceToPool($obj3, $key3); } $obj3->addDivision($obj1); } $results[] = $obj1; } $stmt->closeCursor(); return $results; }
public function getTurno(PropelPDO $con = null) { if ($this->aTurno === null && $this->fk_turno_id !== null) { $c = new Criteria(TurnoPeer::DATABASE_NAME); $c->add(TurnoPeer::ID, $this->fk_turno_id); $this->aTurno = TurnoPeer::doSelectOne($c, $con); } return $this->aTurno; }
/** * 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 BasePeer::TYPE_PHPNAME * * @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 = TurnoPeer::getFieldNames($keyType); if (array_key_exists($keys[0], $arr)) { $this->setId($arr[$keys[0]]); } if (array_key_exists($keys[1], $arr)) { $this->setEstado($arr[$keys[1]]); } if (array_key_exists($keys[2], $arr)) { $this->setNoTurno($arr[$keys[2]]); } if (array_key_exists($keys[3], $arr)) { $this->setJugadorMesaId($arr[$keys[3]]); } if (array_key_exists($keys[4], $arr)) { $this->setMano($arr[$keys[4]]); } }
public static function doSelectJoinAllExceptHorarioescolartipo(Criteria $c, $con = null, $join_behavior = Criteria::LEFT_JOIN) { $c = clone $c; if ($c->getDbName() == Propel::getDefaultDB()) { $c->setDbName(self::DATABASE_NAME); } HorarioescolarPeer::addSelectColumns($c); $startcol2 = HorarioescolarPeer::NUM_COLUMNS - HorarioescolarPeer::NUM_LAZY_LOAD_COLUMNS; EventoPeer::addSelectColumns($c); $startcol3 = $startcol2 + (EventoPeer::NUM_COLUMNS - EventoPeer::NUM_LAZY_LOAD_COLUMNS); EstablecimientoPeer::addSelectColumns($c); $startcol4 = $startcol3 + (EstablecimientoPeer::NUM_COLUMNS - EstablecimientoPeer::NUM_LAZY_LOAD_COLUMNS); TurnoPeer::addSelectColumns($c); $startcol5 = $startcol4 + (TurnoPeer::NUM_COLUMNS - TurnoPeer::NUM_LAZY_LOAD_COLUMNS); $c->addJoin(array(HorarioescolarPeer::FK_EVENTO_ID), array(EventoPeer::ID), $join_behavior); $c->addJoin(array(HorarioescolarPeer::FK_ESTABLECIMIENTO_ID), array(EstablecimientoPeer::ID), $join_behavior); $c->addJoin(array(HorarioescolarPeer::FK_TURNO_ID), array(TurnoPeer::ID), $join_behavior); $stmt = BasePeer::doSelect($c, $con); $results = array(); while ($row = $stmt->fetch(PDO::FETCH_NUM)) { $key1 = HorarioescolarPeer::getPrimaryKeyHashFromRow($row, 0); if (null !== ($obj1 = HorarioescolarPeer::getInstanceFromPool($key1))) { } else { $omClass = HorarioescolarPeer::getOMClass(); $cls = substr('.' . $omClass, strrpos('.' . $omClass, '.') + 1); $obj1 = new $cls(); $obj1->hydrate($row); HorarioescolarPeer::addInstanceToPool($obj1, $key1); } $key2 = EventoPeer::getPrimaryKeyHashFromRow($row, $startcol2); if ($key2 !== null) { $obj2 = EventoPeer::getInstanceFromPool($key2); if (!$obj2) { $omClass = EventoPeer::getOMClass(); $cls = substr('.' . $omClass, strrpos('.' . $omClass, '.') + 1); $obj2 = new $cls(); $obj2->hydrate($row, $startcol2); EventoPeer::addInstanceToPool($obj2, $key2); } $obj2->addHorarioescolar($obj1); } $key3 = EstablecimientoPeer::getPrimaryKeyHashFromRow($row, $startcol3); if ($key3 !== null) { $obj3 = EstablecimientoPeer::getInstanceFromPool($key3); if (!$obj3) { $omClass = EstablecimientoPeer::getOMClass(); $cls = substr('.' . $omClass, strrpos('.' . $omClass, '.') + 1); $obj3 = new $cls(); $obj3->hydrate($row, $startcol3); EstablecimientoPeer::addInstanceToPool($obj3, $key3); } $obj3->addHorarioescolar($obj1); } $key4 = TurnoPeer::getPrimaryKeyHashFromRow($row, $startcol4); if ($key4 !== null) { $obj4 = TurnoPeer::getInstanceFromPool($key4); if (!$obj4) { $omClass = TurnoPeer::getOMClass(); $cls = substr('.' . $omClass, strrpos('.' . $omClass, '.') + 1); $obj4 = new $cls(); $obj4->hydrate($row, $startcol4); TurnoPeer::addInstanceToPool($obj4, $key4); } $obj4->addHorarioescolar($obj1); } $results[] = $obj1; } $stmt->closeCursor(); return $results; }