public function getNomUsuari() { $C = new Criteria(); $C->addJoin(CessioPeer::USUARI_ID, UsuarisPeer::USUARIID); $C = CessioPeer::getCriteriaActiu($C, $this->getSiteId()); $C = UsuarisPeer::getCriteriaActiu($C, $this->getSiteId()); $C->add(CessioPeer::USUARI_ID, $this->getUsuariId()); $OU = UsuarisPeer::doSelectOne($C); if ($OU instanceof Usuaris) { return $OU->getNomComplet(); } else { return 'n/d'; } }
/** * This is a method for emulating ON DELETE CASCADE for DBs that don't support this * feature (like MySQL or SQLite). * * This method is not very speedy because it must perform a query first to get * the implicated records and then perform the deletes by calling those Peer classes. * * This method should be used within a transaction if possible. * * @param Criteria $criteria * @param PropelPDO $con * @return int The number of affected rows (if supported by underlying database driver). */ protected static function doOnDeleteCascade(Criteria $criteria, PropelPDO $con) { // initialize var to track total num of affected rows $affectedRows = 0; // first find the objects that are implicated by the $criteria $objects = UsuarisPeer::doSelect($criteria, $con); foreach ($objects as $obj) { // delete related AppDocumentsPermisos objects $criteria = new Criteria(AppDocumentsPermisosPeer::DATABASE_NAME); $criteria->add(AppDocumentsPermisosPeer::IDUSUARI, $obj->getUsuariid()); $affectedRows += AppDocumentsPermisosPeer::doDelete($criteria, $con); // delete related AppDocumentsPermisosDir objects $criteria = new Criteria(AppDocumentsPermisosDirPeer::DATABASE_NAME); $criteria->add(AppDocumentsPermisosDirPeer::IDUSUARI, $obj->getUsuariid()); $affectedRows += AppDocumentsPermisosDirPeer::doDelete($criteria, $con); // delete related Cessio objects $criteria = new Criteria(CessioPeer::DATABASE_NAME); $criteria->add(CessioPeer::USUARI_ID, $obj->getUsuariid()); $affectedRows += CessioPeer::doDelete($criteria, $con); // delete related Factures objects $criteria = new Criteria(FacturesPeer::DATABASE_NAME); $criteria->add(FacturesPeer::VALIDAUSUARI, $obj->getUsuariid()); $affectedRows += FacturesPeer::doDelete($criteria, $con); // delete related Matricules objects $criteria = new Criteria(MatriculesPeer::DATABASE_NAME); $criteria->add(MatriculesPeer::USUARIS_USUARIID, $obj->getUsuariid()); $affectedRows += MatriculesPeer::doDelete($criteria, $con); // delete related Missatges objects $criteria = new Criteria(MissatgesPeer::DATABASE_NAME); $criteria->add(MissatgesPeer::USUARIS_USUARIID, $obj->getUsuariid()); $affectedRows += MissatgesPeer::doDelete($criteria, $con); // delete related Personal objects $criteria = new Criteria(PersonalPeer::DATABASE_NAME); $criteria->add(PersonalPeer::IDUSUARI, $obj->getUsuariid()); $affectedRows += PersonalPeer::doDelete($criteria, $con); // delete related Reservaespais objects $criteria = new Criteria(ReservaespaisPeer::DATABASE_NAME); $criteria->add(ReservaespaisPeer::USUARIS_USUARIID, $obj->getUsuariid()); $affectedRows += ReservaespaisPeer::doDelete($criteria, $con); // delete related UsuarisApps objects $criteria = new Criteria(UsuarisAppsPeer::DATABASE_NAME); $criteria->add(UsuarisAppsPeer::USUARI_ID, $obj->getUsuariid()); $affectedRows += UsuarisAppsPeer::doDelete($criteria, $con); // delete related UsuarisMenus objects $criteria = new Criteria(UsuarisMenusPeer::DATABASE_NAME); $criteria->add(UsuarisMenusPeer::USUARI_ID, $obj->getUsuariid()); $affectedRows += UsuarisMenusPeer::doDelete($criteria, $con); // delete related UsuarisSites objects $criteria = new Criteria(UsuarisSitesPeer::DATABASE_NAME); $criteria->add(UsuarisSitesPeer::USUARI_ID, $obj->getUsuariid()); $affectedRows += UsuarisSitesPeer::doDelete($criteria, $con); // delete related Usuarisllistes objects $criteria = new Criteria(UsuarisllistesPeer::DATABASE_NAME); $criteria->add(UsuarisllistesPeer::USUARIS_USUARISID, $obj->getUsuariid()); $affectedRows += UsuarisllistesPeer::doDelete($criteria, $con); } return $affectedRows; }
public function executeGCessio(sfWebRequest $request) { $this->setLayout('gestio'); $this->IDS = $this->getUser()->getSessionPar('idS'); //Netegem cerca if ($request->getParameter('accio') == 'C') { $this->CERCA = $this->getUser()->setSessionPar('cerca', array('text' => '', 'select' => '')); $this->PAGINA = $this->getUser()->setSessionPar('pagina', 1); } $this->PAGINA = $this->getUser()->ParReqSesForm($request, 'PAGINA', 1); //Inicialitzem el formulari de cerca $this->CERCA = $this->getUser()->ParReqSesForm($request, 'cerca', array('text' => '', 'select' => '')); $this->FCerca = new CercaTextChoiceForm(); $this->FCerca->setChoice(array(1 => 'Cedit', 0 => 'Retornat')); $this->FCerca->bind($this->CERCA); $this->MODE = ""; $this->ERROR_OCUPAT = ""; $this->IDC = $request->getParameter('IDC', 0); if ($request->isMethod('POST') || $request->isMethod('GET')) { $accio = $request->getParameter('accio'); if ($request->hasParameter('BCERCA')) { $accio = ' '; } if ($request->hasParameter('BNOU_CESSIO')) { $accio = 'NC'; } if ($request->hasParameter('BESCULL_MATERIAL')) { $accio = 'EM'; } if ($request->hasParameter('B_SAVE_CESSIO')) { $accio = 'SC'; } if ($request->hasParameter('BDELETE_CESSIO')) { $accio = 'DC'; } if ($request->hasParameter('BSAVE_RETORN')) { $accio = 'SR'; } } switch ($accio) { case 'C': $this->getUser()->addLogAction('inside', 'gCessio'); $this->CERCA['select'] = 1; break; //Nova Cessió //Nova Cessió case 'NC': $this->FCessio = CessioPeer::inicialitza(0, $this->IDS); $this->MODE = 'NOU_CESSIO'; break; //Escull el material //Escull el material case 'EM': $RCESSIO = $request->getParameter('cessio'); $this->FCessio = CessioPeer::inicialitza($RCESSIO['cessio_id'], $this->IDS); $this->FCessio->bind($RCESSIO); if ($this->FCessio->isValid()) { $this->FCessio->save(); $this->LoadEscullMaterial($this->FCessio->getObject()); } else { $this->MODE = 'EDICIO_CESSIO'; $this->MISSATGE = array('Hi ha hagut algun error guardant la cessió'); } break; //Edita Cessio //Edita Cessio case 'EC': $this->FCessio = CessioPeer::inicialitza($this->IDC, $this->IDS); $this->MODE = 'EDICIO_CESSIO'; break; //Edita Retorn //Edita Retorn case 'ER': $this->FCessio = CessioPeer::inicialitza($this->IDC, $this->IDS, true); $OC = $this->FCessio->getObject(); if (!$OC->isNew()) { $OC->setRetornat(true); } $this->MODE = 'EDICIO_RETORN'; break; //Guarda cessió //Guarda cessió case 'SC': $RMATERIAL = $request->getParameter('material'); $RMATERIALNOINV = $request->getParameter('material_no_inventariat'); $this->FCessio = CessioPeer::inicialitza($this->IDC, $this->IDS); $ERROR = CessiomaterialPeer::update($RMATERIAL, $this->FCessio, $this->IDS); if (!empty($ERROR)) { $this->FCessio = CessioPeer::inicialitza($this->IDC, $this->IDS); $OCESSIO = $this->FCessio->getObject(); $this->LoadEscullMaterial($OCESSIO, $RMATERIAL, $RMATERIALNOINV, true); $this->MISSATGE = array(); foreach ($ERROR as $idM => $text) { $RET = MaterialPeer::OnOcupatMaterialHores($idM, $OCESSIO->getDatacessio(), $OCESSIO->getDataRetorn(), '00:00', '24:00', $this->IDS, null, null, null); foreach ($RET as $idM => $O) { if ($O instanceof Cessio) { $this->MISSATGE[] = 'El material ' . $text . ' està en ús a la cessió ' . $O->getNom(); } elseif ($O instanceof Horaris) { $this->MISSATGE[] = 'El material ' . $text . ' està en ús en activitats el dia ' . $O->getDia() . ' a les ' . $O->getHorainici(); } } } } else { if ($request->hasParameter('material_no_inventariat')) { $this->FCessio->getObject()->setMaterialNoInventariat($RMATERIALNOINV); $this->FCessio->getObject()->save(); } $this->getUser()->addLogAction($accio, 'gCessio', $this->FCessio->getObject()); myUser::addLogTimeline('alta', 'cessio', $this->getUser()->getSessionPar('idU'), $this->IDS, $this->FCessio->getObject()->getCessioId()); $this->MODE = 'FINALITZAT'; } break; //Esborra cessió //Esborra cessió case 'DC': $OC = CessioPeer::retrieveByPK($this->getUser()->getSessionPar('IDC')); $this->getUser()->addLogAction($accio, 'gCessio', $OC); myUser::addLogTimeline('baixa', 'cessio', $this->getUser()->getSessionPar('idU'), $this->IDS, $OC); $OC->setActiu(false)->save(); break; //Guarda retorn //Guarda retorn case 'SR': $RCESSIO = $request->getParameter('cessio'); $OCESSIO = CessioPeer::retrieveByPK($RCESSIO['cessio_id']); $this->FCessio = new CessiomaterialRetornForm($OCESSIO); $this->FCessio->bind($RCESSIO); if ($this->FCessio->isValid()) { $this->FCessio->save(); $this->getUser()->addLogAction($accio, 'gCessio', $this->FCessio->getObject()); myUser::addLogTimeline('retorn', 'cessio', $this->getUser()->getSessionPar('idU'), $this->IDS, $RCESSIO['cessio_id']); $this->redirect('gestio/gCessio?accio=C'); } $this->MODE = 'EDICIO_RETORN'; break; case 'PRINT': $OCESSIO = CessioPeer::retrieveByPK($request->getParameter('IDC')); $pdf = CessioPeer::printDocument($OCESSIO); $pdf->output(); return sfView::NONE; break; } $this->CESSIONS = CessioPeer::getCessions($this->PAGINA, $this->CERCA['select'], $this->CERCA['text'], $this->IDS); }
/** * Get the associated Cessio object * * @param PropelPDO Optional Connection object. * @return Cessio The associated Cessio object. * @throws PropelException */ public function getCessio(PropelPDO $con = null) { if ($this->aCessio === null && $this->cessio_id !== null) { $this->aCessio = CessioPeer::retrieveByPk($this->cessio_id); /* 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->aCessio->addCessiomaterials($this); */ } return $this->aCessio; }
/** * Indica on està ocupat el material en un intèrval de temps * */ public static function OnOcupatMaterialHores($idM, $datai, $dataf, $hi, $hf, $idS, $idG = null, $idH = null, $idC = null) { //Busquem primer l'horari en el que està ocupat. //Altrament busquem la cessió en la que està ocupat //Agafo les activitats que tenen material ocupat una data determinada. $CESSIO = array(); $C = self::criteriaOcupatCessio($datai, $dataf, $hi, $hf, $idS, $idG, $idH, $idC); foreach (CessioPeer::doSelect($C) as $OC) { $CESSIO[$idM] = $OC; } $C = self::criteriaOcupatEspais($datai, $dataf, $hi, $hf, $idS, $idG, $idH, $idC); foreach (HorarisPeer::doSelect($C) as $OH) { $CESSIO[$idM] = $OH; } return $CESSIO; }
/** * 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(CessioPeer::DATABASE_NAME, Propel::CONNECTION_READ); } $objs = null; if (empty($pks)) { $objs = array(); } else { $criteria = new Criteria(CessioPeer::DATABASE_NAME); $criteria->add(CessioPeer::CESSIO_ID, $pks, Criteria::IN); $objs = CessioPeer::doSelect($criteria, $con); } return $objs; }
/** * 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 = CessioPeer::getFieldNames($keyType); if (array_key_exists($keys[0], $arr)) { $this->setCessioId($arr[$keys[0]]); } if (array_key_exists($keys[1], $arr)) { $this->setActiu($arr[$keys[1]]); } if (array_key_exists($keys[2], $arr)) { $this->setSiteId($arr[$keys[2]]); } if (array_key_exists($keys[3], $arr)) { $this->setUsuariId($arr[$keys[3]]); } if (array_key_exists($keys[4], $arr)) { $this->setNom($arr[$keys[4]]); } if (array_key_exists($keys[5], $arr)) { $this->setDni($arr[$keys[5]]); } if (array_key_exists($keys[6], $arr)) { $this->setRepresentant($arr[$keys[6]]); } if (array_key_exists($keys[7], $arr)) { $this->setMotiu($arr[$keys[7]]); } if (array_key_exists($keys[8], $arr)) { $this->setCondicions($arr[$keys[8]]); } if (array_key_exists($keys[9], $arr)) { $this->setMaterialNoInventariat($arr[$keys[9]]); } if (array_key_exists($keys[10], $arr)) { $this->setDataCessio($arr[$keys[10]]); } if (array_key_exists($keys[11], $arr)) { $this->setDataRetorn($arr[$keys[11]]); } if (array_key_exists($keys[12], $arr)) { $this->setEstat($arr[$keys[12]]); } if (array_key_exists($keys[13], $arr)) { $this->setRetornat($arr[$keys[13]]); } if (array_key_exists($keys[14], $arr)) { $this->setEstatRetornat($arr[$keys[14]]); } if (array_key_exists($keys[15], $arr)) { $this->setDataRetornat($arr[$keys[15]]); } }
/** * Returns the number of related Cessio objects. * * @param Criteria $criteria * @param boolean $distinct * @param PropelPDO $con * @return int Count of related Cessio objects. * @throws PropelException */ public function countCessios(Criteria $criteria = null, $distinct = false, PropelPDO $con = null) { if ($criteria === null) { $criteria = new Criteria(UsuarisPeer::DATABASE_NAME); } else { $criteria = clone $criteria; } if ($distinct) { $criteria->setDistinct(); } $count = null; if ($this->collCessios === null) { if ($this->isNew()) { $count = 0; } else { $criteria->add(CessioPeer::USUARI_ID, $this->usuariid); $count = CessioPeer::doCount($criteria, false, $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(CessioPeer::USUARI_ID, $this->usuariid); if (!isset($this->lastCessioCriteria) || !$this->lastCessioCriteria->equals($criteria)) { $count = CessioPeer::doCount($criteria, false, $con); } else { $count = count($this->collCessios); } } else { $count = count($this->collCessios); } } return $count; }
/** * Selects a collection of Cessiomaterial objects pre-filled with all related objects except Material. * * @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 Cessiomaterial objects. * @throws PropelException Any exceptions caught during processing will be * rethrown wrapped into a PropelException. */ public static function doSelectJoinAllExceptMaterial(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); } CessiomaterialPeer::addSelectColumns($criteria); $startcol2 = CessiomaterialPeer::NUM_COLUMNS - CessiomaterialPeer::NUM_LAZY_LOAD_COLUMNS; CessioPeer::addSelectColumns($criteria); $startcol3 = $startcol2 + (CessioPeer::NUM_COLUMNS - CessioPeer::NUM_LAZY_LOAD_COLUMNS); $criteria->addJoin(CessiomaterialPeer::CESSIO_ID, CessioPeer::CESSIO_ID, $join_behavior); // symfony_behaviors behavior foreach (sfMixer::getCallables(self::getMixerPreSelectHook(__FUNCTION__)) as $sf_hook) { call_user_func($sf_hook, 'BaseCessiomaterialPeer', $criteria, $con); } $stmt = BasePeer::doSelect($criteria, $con); $results = array(); while ($row = $stmt->fetch(PDO::FETCH_NUM)) { $key1 = CessiomaterialPeer::getPrimaryKeyHashFromRow($row, 0); if (null !== ($obj1 = CessiomaterialPeer::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 = CessiomaterialPeer::getOMClass(false); $obj1 = new $cls(); $obj1->hydrate($row); CessiomaterialPeer::addInstanceToPool($obj1, $key1); } // if obj1 already loaded // Add objects for joined Cessio rows $key2 = CessioPeer::getPrimaryKeyHashFromRow($row, $startcol2); if ($key2 !== null) { $obj2 = CessioPeer::getInstanceFromPool($key2); if (!$obj2) { $cls = CessioPeer::getOMClass(false); $obj2 = new $cls(); $obj2->hydrate($row, $startcol2); CessioPeer::addInstanceToPool($obj2, $key2); } // if $obj2 already loaded // Add the $obj1 (Cessiomaterial) to the collection in $obj2 (Cessio) $obj2->addCessiomaterial($obj1); } // if joined row is not null $results[] = $obj1; } $stmt->closeCursor(); return $results; }