public function setup() { $this->setWidgets(array('idEspaiextern' => new sfWidgetFormInputHidden(), 'Poble' => new sfWidgetFormChoice(array('choices' => PoblacionsPeer::select())), 'Nom' => new sfWidgetFormInput(array(), array('style' => 'width:400px;')), 'Adreca' => new sfWidgetFormInput(array(), array('style' => 'width:400px;')), 'Contacte' => new sfWidgetFormInput(array(), array('style' => 'width:400px;')))); $this->setValidators(array('idEspaiextern' => new sfValidatorChoice(array('choices' => array($this->getObject()->getIdespaiextern()), 'empty_value' => $this->getObject()->getIdespaiextern(), 'required' => false)), 'Poble' => new sfValidatorPropelChoice(array('model' => 'Poblacions', 'column' => 'idPoblacio')), 'Nom' => new sfValidatorString(), 'Adreca' => new sfValidatorString(), 'Contacte' => new sfValidatorString(array('required' => false)))); $this->widgetSchema->setNameFormat('espais_externs[%s]'); $this->errorSchema = new sfValidatorErrorSchema($this->validatorSchema); $this->widgetSchema->setFormFormatterName('Span'); $this->widgetSchema->setLabels(array('Poble' => 'Població: ', 'Nom' => 'Entitat: ', 'Adreca' => 'Adreça: ', 'Contacte' => 'Contacte: ')); }
public function getPobleString() { $OP = PoblacionsPeer::retrieveByPK($this->getPoble()); $nom = "n/d"; if ($OP instanceof Poblacions) { $nom = $OP->getNom(); } return $nom; }
public function getPoblacions() { $OP = PoblacionsPeer::retrieveByPK($this->getPoble()); if ($OP instanceof Poblacions) { return $OP; } else { return new Poblacions(); } }
function getPoblacioString() { $poblacio = $this->getPoblaciotext(); if (!empty($poblacio)) { return $this->getPoblaciotext(); } else { $OP = PoblacionsPeer::retrieveByPK($this->getPoblacio()); if ($OP instanceof Poblacions) { $poblacio = $OP->getNom(); return $poblacio; } else { return "Desconeguda"; } } }
public function setup() { //Carrego el nivell de l'usuari a la taula,. Si l'estic veient per força n'he de tenir. $OUS = UsuarisSitesPeer::initialize($this->getObject()->getUsuariId(), $this->getObject()->getSiteId(), false)->getObject(); if ($OUS->isNew()) { $NIVELL = NivellsPeer::REGISTRAT; } else { $NIVELL = $OUS->getNivellId(); } $years = range(date('Y') - 100, date('Y') + 0); $this->setWidgets(array('UsuariID' => new sfWidgetFormInputHidden(), 'Nivells_idNivells' => new sfWidgetFormChoice(array('choices' => NivellsPeer::getSelect()), array()), 'DNI' => new sfWidgetFormInputText(array(), array('style' => 'width:200px')), 'Passwd' => new sfWidgetFormInputPassword(array('always_render_empty' => false), array('always_render_empty' => false, 'style' => 'width:200px')), 'Nom' => new sfWidgetFormInputText(array(), array('style' => 'width:200px')), 'Cog1' => new sfWidgetFormInputText(array(), array('style' => 'width:200px')), 'Cog2' => new sfWidgetFormInputText(array(), array('style' => 'width:200px')), 'Email' => new sfWidgetFormInputText(array(), array('style' => 'width:200px')), 'Adreca' => new sfWidgetFormInputText(array(), array('style' => 'width:200px')), 'CodiPostal' => new sfWidgetFormInputText(array(), array('style' => 'width:200px')), 'Poblacio' => new sfWidgetFormChoice(array('choices' => PoblacionsPeer::select())), 'Poblaciotext' => new sfWidgetFormInputText(array(), array('style' => 'width:200px')), 'Telefon' => new sfWidgetFormInputText(array(), array('style' => 'width:200px')), 'Mobil' => new sfWidgetFormInputText(array(), array('style' => 'width:200px')), 'Entitat' => new sfWidgetFormInputText(array(), array('style' => 'width:200px')), 'Habilitat' => new sfWidgetFormChoice(array('choices' => array(1 => 'Sí', 0 => 'No')), array()), 'Actualitzacio' => new sfWidgetFormInputHidden(array(), array()), 'site_id' => new sfWidgetFormInputHidden(array(), array()), 'actiu' => new sfWidgetFormInputHidden(array(), array()), 'facebook_id' => new sfWidgetFormInputHidden(array(), array()), 'data_naixement' => new sfWidgetFormDate(array('years' => array_combine($years, $years), 'format' => '%day%/%month%/%year%'), array('style' => 'width:60px;')))); $this->setDefault('Nivells_idNivells', $NIVELL); $C = new Criteria(); $C->addAscendingOrderByColumn(PoblacionsPeer::NOM); $this->setValidators(array('UsuariID' => new sfValidatorPropelChoice(array('model' => 'Usuaris', 'column' => 'UsuariID', 'required' => false)), 'Nivells_idNivells' => new sfValidatorPropelChoice(array('model' => 'Nivells', 'column' => 'idNivells')), 'Passwd' => new sfValidatorString(array('max_length' => 20, 'required' => true)), 'Nom' => new sfValidatorString(array('required' => true)), 'Cog1' => new sfValidatorString(array('required' => true)), 'Cog2' => new sfValidatorString(array('required' => false)), 'Email' => new sfValidatorEmail(array('required' => true)), 'Adreca' => new sfValidatorString(array('required' => false)), 'CodiPostal' => new sfValidatorInteger(array('required' => false)), 'Poblacio' => new sfValidatorPropelChoice(array('model' => 'Poblacions', 'criteria' => $C, 'column' => 'idPoblacio', 'required' => false)), 'Poblaciotext' => new sfValidatorString(array('required' => false)), 'Telefon' => new sfValidatorString(array('required' => false)), 'Mobil' => new sfValidatorString(array('required' => false)), 'Entitat' => new sfValidatorString(array('required' => false)), 'Habilitat' => new sfValidatorBoolean(array('required' => false)), 'Actualitzacio' => new sfValidatorDate(array('required' => false), array()), 'site_id' => new sfValidatorPass(array(), array()), 'actiu' => new sfValidatorInteger(array('required' => false), array()), 'facebook_id' => new sfValidatorInteger(array('required' => false), array()), 'data_naixement' => new sfValidatorDate(array('required' => false), array()))); $this->setValidator('DNI', new sfValidatorCallback(array('callback' => array('UsuarisForm', 'ComprovaDNI'), 'arguments' => array('idU' => $this->getObject()->getUsuariId(), 'ADMIN' => $this->getOption('ADMIN')), 'required' => true))); $this->widgetSchema->setLabels(array('Nivells_idNivells' => 'Nivell: ', 'DNI' => 'DNI: ', 'Passwd' => 'Contrasenya: ', 'Nom' => 'Nom: ', 'Cog1' => 'Primer cognom: ', 'Cog2' => 'Segon cognom: ', 'Email' => 'Correu electrònic: ', 'Adreca' => 'Adreça postal: ', 'CodiPostal' => 'Codi postal: ', 'Poblacio' => 'Població: ', 'Poblaciotext' => 'Població: ', 'Telefon' => 'Telèfon: ', 'Mobil' => 'Mòbil: ', 'Entitat' => 'Entitat: ', 'Habilitat' => 'Habilitat: ', 'data_naixement' => 'Data Naixement: ')); $this->widgetSchema->setNameFormat('usuaris[%s]'); $this->errorSchema = new sfValidatorErrorSchema($this->validatorSchema); }
/** * Selects a collection of Usuaris objects pre-filled with all related objects except Nivells. * * @param Criteria $criteria * @param PropelPDO $con * @param String $join_behavior the type of joins to use, defaults to Criteria::LEFT_JOIN * @return array Array of Usuaris objects. * @throws PropelException Any exceptions caught during processing will be * rethrown wrapped into a PropelException. */ public static function doSelectJoinAllExceptNivells(Criteria $criteria, $con = null, $join_behavior = Criteria::LEFT_JOIN) { $criteria = clone $criteria; // Set the correct dbName if it has not been overridden // $criteria->getDbName() will return the same object if not set to another value // so == check is okay and faster if ($criteria->getDbName() == Propel::getDefaultDB()) { $criteria->setDbName(self::DATABASE_NAME); } UsuarisPeer::addSelectColumns($criteria); $startcol2 = UsuarisPeer::NUM_COLUMNS - UsuarisPeer::NUM_LAZY_LOAD_COLUMNS; PoblacionsPeer::addSelectColumns($criteria); $startcol3 = $startcol2 + (PoblacionsPeer::NUM_COLUMNS - PoblacionsPeer::NUM_LAZY_LOAD_COLUMNS); $criteria->addJoin(UsuarisPeer::POBLACIO, PoblacionsPeer::IDPOBLACIO, $join_behavior); // symfony_behaviors behavior foreach (sfMixer::getCallables(self::getMixerPreSelectHook(__FUNCTION__)) as $sf_hook) { call_user_func($sf_hook, 'BaseUsuarisPeer', $criteria, $con); } $stmt = BasePeer::doSelect($criteria, $con); $results = array(); while ($row = $stmt->fetch(PDO::FETCH_NUM)) { $key1 = UsuarisPeer::getPrimaryKeyHashFromRow($row, 0); if (null !== ($obj1 = UsuarisPeer::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 { $cls = UsuarisPeer::getOMClass(false); $obj1 = new $cls(); $obj1->hydrate($row); UsuarisPeer::addInstanceToPool($obj1, $key1); } // if obj1 already loaded // Add objects for joined Poblacions rows $key2 = PoblacionsPeer::getPrimaryKeyHashFromRow($row, $startcol2); if ($key2 !== null) { $obj2 = PoblacionsPeer::getInstanceFromPool($key2); if (!$obj2) { $cls = PoblacionsPeer::getOMClass(false); $obj2 = new $cls(); $obj2->hydrate($row, $startcol2); PoblacionsPeer::addInstanceToPool($obj2, $key2); } // if $obj2 already loaded // Add the $obj1 (Usuaris) to the collection in $obj2 (Poblacions) $obj2->addUsuaris($obj1); } // if joined row is not null $results[] = $obj1; } $stmt->closeCursor(); return $results; }
/** * Funció qeu amb un llistat d'activitats, ens mostra quantes van a cada poble. * @param $A_ACTIVITATS (Llistat amb ID activitats) * @return SELECT AMB VALORS * */ public static function getPoblacionsActivitatsHospici($A_ACTIVITATS) { $C = new Criteria(); $C->add(self::ACTIVITATID, $A_ACTIVITATS, CRITERIA::IN); $C->addJoin(self::ACTIVITATID, HorarisPeer::ACTIVITATS_ACTIVITATID); $C->addJoin(HorarisPeer::HORARISID, HorarisespaisPeer::HORARIS_HORARISID); $C->addJoin(HorarisespaisPeer::ESPAIS_ESPAIID, EspaisPeer::ESPAIID); $C->addJoin(EspaisPeer::SITE_ID, SitesPeer::SITE_ID); $C->addJoin(SitesPeer::POBLE, PoblacionsPeer::IDPOBLACIO); $C->addGroupByColumn(self::ACTIVITATID); $C2 = new Criteria(); $C2->add(self::ACTIVITATID, $A_ACTIVITATS, CRITERIA::IN); $C2->addJoin(self::ACTIVITATID, HorarisPeer::ACTIVITATS_ACTIVITATID); $C2->addJoin(HorarisPeer::HORARISID, HorarisespaisPeer::HORARIS_HORARISID); $C2->addJoin(HorarisespaisPeer::IDESPAIEXTERN, EspaisExternsPeer::IDESPAIEXTERN); $C2->addJoin(EspaisexternsPeer::POBLE, PoblacionsPeer::IDPOBLACIO); $C2->addGroupByColumn(self::ACTIVITATID); $RET = array(); $SOL = array(); $RET[0] = array('NOM' => "Tots els pobles...", 'COUNT' => 0); foreach (PoblacionsPeer::doSelect($C) as $OP) { if (!isset($RET[$OP->getIdpoblacio()])) { $RET[$OP->getIdpoblacio()] = array('NOM' => $OP->getNom(), 'COUNT' => 0); } $RET[$OP->getIdpoblacio()]['COUNT'] += 1; $RET[0]['COUNT'] += 1; } foreach (PoblacionsPeer::doSelect($C2) as $OP) { if (!isset($RET[$OP->getIdpoblacio()])) { $RET[$OP->getIdpoblacio()] = array('NOM' => $OP->getNom(), 'COUNT' => 0); } $RET[$OP->getIdpoblacio()]['COUNT'] += 1; $RET[0]['COUNT'] += 1; } foreach ($RET as $K => $V) { $SOL[$K] = $V['NOM'] . " ({$V['COUNT']})"; } return $SOL; }
public static function getPoblacionsCursosHospici($a_cursos) { $C = new Criteria(); $C->add(self::ACTIU, true); $C->add(self::IDCURSOS, $a_cursos, CRITERIA::IN); $C->addJoin(CursosPeer::SITE_ID, SitesPeer::SITE_ID); $C->addJoin(PoblacionsPeer::IDPOBLACIO, SitesPeer::POBLE); $RET = array(); $SOL = array(); $RET[0] = array('NOM' => "Tots els pobles...", 'COUNT' => 0); foreach (PoblacionsPeer::doSelect($C) as $OP) { if (!isset($RET[$OP->getIdpoblacio()])) { $RET[$OP->getIdpoblacio()] = array('NOM' => $OP->getNom(), 'COUNT' => 0); } $RET[$OP->getIdpoblacio()]['COUNT'] += 1; $RET[0]['COUNT'] += 1; } foreach ($RET as $K => $V) { $SOL[$K] = $V['NOM'] . " ({$V['COUNT']})"; } return $SOL; }
public function getPoblacioString() { $OP = PoblacionsPeer::retrieveByPK($this->getPoblacio()); if ($OP instanceof Poblacions) { return $OP->getNom(); } else { return "n/d"; } }
/** * Get the associated Poblacions object * * @param PropelPDO Optional Connection object. * @return Poblacions The associated Poblacions object. * @throws PropelException */ public function getPoblacions(PropelPDO $con = null) { if ($this->aPoblacions === null && $this->poblacio !== null) { $this->aPoblacions = PoblacionsPeer::retrieveByPk($this->poblacio); /* 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->aPoblacions->addUsuariss($this); */ } return $this->aPoblacions; }
/** * 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 = PoblacionsPeer::getFieldNames($keyType); if (array_key_exists($keys[0], $arr)) { $this->setIdpoblacio($arr[$keys[0]]); } if (array_key_exists($keys[1], $arr)) { $this->setNom($arr[$keys[1]]); } if (array_key_exists($keys[2], $arr)) { $this->setComarca($arr[$keys[2]]); } if (array_key_exists($keys[3], $arr)) { $this->setCodipostal($arr[$keys[3]]); } if (array_key_exists($keys[4], $arr)) { $this->setSiteId($arr[$keys[4]]); } if (array_key_exists($keys[5], $arr)) { $this->setActiu($arr[$keys[5]]); } }
/** * 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(PoblacionsPeer::DATABASE_NAME, Propel::CONNECTION_READ); } $objs = null; if (empty($pks)) { $objs = array(); } else { $criteria = new Criteria(PoblacionsPeer::DATABASE_NAME); $criteria->add(PoblacionsPeer::IDPOBLACIO, $pks, Criteria::IN); $objs = PoblacionsPeer::doSelect($criteria, $con); } return $objs; }
$LACT = $LLISTAT_ACTIVITATS; foreach ($LACT as $OA) { if ($OA instanceof Activitats) { $CATEGORIA = $OA->getNomTipusActivitat(); $url = url_for('@hospici_detall_activitat?idA=' . $OA->getActivitatid() . '&titol=' . $OA->getNomForUrl()); $NOM = $OA->getTMig(); $ORGANITZA = $OA->getNomSite(); $POBLACIO = SitesPeer::getPoblacioSite($OA->getSiteid()); $HORARIS = $OA->getHorarisText(); $DATA_INICI = '<b><span style="color:green">' . generaHorarisCompactat($OA) . '</span></b><br />' . $OA->getHorarisText(); } elseif ($OA instanceof Activitatsexternes) { $CATEGORIA = $OA->getCategoriaNom(); $url = $OA->getUrl(); $NOM = $OA->getTitol(); $ORGANITZA = $OA->getEntitat(); $POBLACIO = PoblacionsPeer::toString($OA->getPoblacio()); $DATA_INICI = '<b><span style="color:green">' . generaHorarisCompactat($OA) . '</span></b><br />' . $OA->getHora('H:i'); } $NOM = '<a id="link" style="font-size:14px;" href="' . $url . '">' . $NOM . ' </a><span style="font-size:10px; color:gray;"></span>'; ?> <tr> <td style="width:80px; vertical-align:top;"><?php echo $DATA_INICI; ?> </td> <td style="vertical-align: top;"><?php echo $NOM; ?> <br />
/** * Captura les dades de biblioteques per afegir-les a l'Hospici. * * */ public function executeImportData(sfWebRequest $request) { //Carreguem l'arxiu de coincidències amb els tipus d'activitats de la biblioteca $XML_T = simplexml_load_file('./documents/RelacioTipusActivitatsBiblioteques.txt'); $TAA = array(); foreach ($XML_T->t as $T) { $TAA[(string) $T->ext] = (string) $T->ccg; } $RET = array('NOVES' => 0, 'TROBADES' => 0); $XML = simplexml_load_file("http://www.bibgirona.cat/api/vhospici/events/event_items.xml?page=1&per_page=10"); $total = (int) $XML->info->paginesTotals; for ($i = 1; $i < $total; $i++) { $XML = simplexml_load_file("http://www.bibgirona.cat/api/vhospici/events/event_items.xml?page={$i}&per_page=10"); foreach ($XML->caixa as $C) { //Canviem el lloc pel que toca de la nostra bdd. Si no el trobem hi posem "altres" list($lloc, $entitat) = explode(' - ', $C->espais); if ($lloc == 'Vilobí dOnyar') { $lloc = 'Vilobí d\'Onyar'; } elseif ($lloc == 'La Jonquera') { $lloc = 'Jonquera, la'; } $SQL = new Criteria(); $SQL->add(PoblacionsPeer::NOM, '%' . $lloc . '%', Criteria::LIKE); $OP = PoblacionsPeer::doSelectOne($SQL); if (!$OP instanceof Poblacions) { $OP = PoblacionsPeer::retrieveByPK(1); } $idA = ActivitatsExternesPeer::ExisteixActivitat($OP->getIdPoblacio(), $C->data_inicial, $C->hora_inici, $C->url); if ($idA == 0) { $OA = new ActivitatsExternes(); $RET['NOVES']++; } else { $OA = ActivitatsExternesPeer::retrieveByPK($idA); $RET['TROBADES']++; } $OA->setTitol($C->titol); $OA->setDescripcio($C->text); $OA->setDatainicial($C->data_inicial); $OA->setDatafinal($C->data_fi); $OA->setHora($C->hora_inici); $OA->setUrl($C->url); $OA->setPoblacio($OP->getIdpoblacio()); $OA->setAdreca($entitat); $OA->setEntitat('Biblioteca ' . $entitat); $OA->setCategoria($TAA[(string) $C->tipus_activitat]); $OA->setActiu(true); $OA->save(); } } echo 'Noves: ' . $RET['NOVES'] . '<br />' . 'Trobades: ' . $RET['TROBADES']; return sfView::NONE; }