Esempio n. 1
0
 public function setInactiu()
 {
     $this->setActiu(false);
     $C = new Criteria();
     $C->add(HorarisespaisPeer::IDESPAIEXTERN, $this->getIdespaiextern());
     foreach (HorarisespaisPeer::doSelect() as $OHE) {
         $OHE->setInactiu();
     }
 }
 public static function criteriaHorari_EspaiExtern($idH, $C, $idS)
 {
     //Agafem la relació amb un horari que té un espai extern.
     $C = HorarisespaisPeer::getCriteriaActiu($C, $idS);
     $C = EspaisExternsPeer::getCriteriaActiu($C, $idS);
     $C->add(HorarisespaisPeer::HORARIS_HORARISID, $idH);
     $C->add(HorarisespaisPeer::ESPAIS_ESPAIID, null);
     $C->addJoin(HorarisespaisPeer::IDESPAIEXTERN, EspaisExternsPeer::IDESPAIEXTERN);
     return EspaisExternsPeer::doSelect($C);
 }
Esempio n. 3
0
 public function getArrayHorarisEspaisMaterial()
 {
     $RET = array();
     $C = new Criteria();
     $C = HorarisespaisPeer::getCriteriaActiu($C, $this->getSiteId());
     //      $C->add( HorarisespaisPeer::IDESPAIEXTERN, null);
     $C->addGroupByColumn(HorarisespaisPeer::MATERIAL_IDMATERIAL);
     $LHE = $this->getHorarisespaiss($C);
     foreach ($LHE as $HE) {
         $OM = MaterialPeer::retrieveByPK($HE->getMaterialIdmaterial());
         if ($OM instanceof Material) {
             $RET[$OM->getIdmaterial()] = array('material' => $OM->getIdmaterial(), 'nom' => $OM->toString(), 'generic' => $OM->getMaterialgenericIdmaterialgeneric());
         }
     }
     return $RET;
 }
Esempio n. 4
0
 /**
  * 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 = MaterialPeer::doSelect($criteria, $con);
     foreach ($objects as $obj) {
         // delete related Cessiomaterial objects
         $criteria = new Criteria(CessiomaterialPeer::DATABASE_NAME);
         $criteria->add(CessiomaterialPeer::MATERIAL_IDMATERIAL, $obj->getIdmaterial());
         $affectedRows += CessiomaterialPeer::doDelete($criteria, $con);
         // delete related Horarisespais objects
         $criteria = new Criteria(HorarisespaisPeer::DATABASE_NAME);
         $criteria->add(HorarisespaisPeer::MATERIAL_IDMATERIAL, $obj->getIdmaterial());
         $affectedRows += HorarisespaisPeer::doDelete($criteria, $con);
     }
     return $affectedRows;
 }
Esempio n. 5
0
 /**
  * If this collection has already been initialized with
  * an identical criteria, it returns the collection.
  * Otherwise if this Horaris is new, it will return
  * an empty collection; or if this Horaris has previously
  * been saved, it will retrieve related Horarisespaiss from storage.
  *
  * This method is protected by default in order to keep the public
  * api reasonable.  You can provide public methods for those you
  * actually need in Horaris.
  */
 public function getHorarisespaissJoinEspais($criteria = null, $con = null, $join_behavior = Criteria::LEFT_JOIN)
 {
     if ($criteria === null) {
         $criteria = new Criteria(HorarisPeer::DATABASE_NAME);
     } elseif ($criteria instanceof Criteria) {
         $criteria = clone $criteria;
     }
     if ($this->collHorarisespaiss === null) {
         if ($this->isNew()) {
             $this->collHorarisespaiss = array();
         } else {
             $criteria->add(HorarisespaisPeer::HORARIS_HORARISID, $this->horarisid);
             $this->collHorarisespaiss = HorarisespaisPeer::doSelectJoinEspais($criteria, $con, $join_behavior);
         }
     } else {
         // 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(HorarisespaisPeer::HORARIS_HORARISID, $this->horarisid);
         if (!isset($this->lastHorarisespaisCriteria) || !$this->lastHorarisespaisCriteria->equals($criteria)) {
             $this->collHorarisespaiss = HorarisespaisPeer::doSelectJoinEspais($criteria, $con, $join_behavior);
         }
     }
     $this->lastHorarisespaisCriteria = $criteria;
     return $this->collHorarisespaiss;
 }
Esempio n. 6
0
 /**
  * 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 = EspaisExternsPeer::doSelect($criteria, $con);
     foreach ($objects as $obj) {
         // delete related Horarisespais objects
         $criteria = new Criteria(HorarisespaisPeer::DATABASE_NAME);
         $criteria->add(HorarisespaisPeer::IDESPAIEXTERN, $obj->getIdespaiextern());
         $affectedRows += HorarisespaisPeer::doDelete($criteria, $con);
     }
     return $affectedRows;
 }
Esempio n. 7
0
 private static function criteriaOcupatEspais($datai, $dataf, $hi, $hf, $idS, $idG = null, $idH = null, $idC = null)
 {
     //Mirem les activitats que usen material aquests dies.
     $C = new Criteria();
     $C = self::getCriteriaActiu($C, $idS);
     $C = HorarisPeer::getCriteriaActiu($C, $idS);
     $C = HorarisespaisPeer::getCriteriaActiu($C, $idS);
     $C->addJoin(HorarisPeer::HORARISID, HorarisespaisPeer::HORARIS_HORARISID);
     $C->addJoin(HorarisespaisPeer::MATERIAL_IDMATERIAL, MaterialPeer::IDMATERIAL);
     if (!is_null($idG)) {
         $C->add(MaterialPeer::MATERIALGENERIC_IDMATERIALGENERIC, $idG);
     }
     if (!is_null($idH)) {
         $C->add(HorarisPeer::HORARISID, $idH, Criteria::NOT_EQUAL);
     }
     $C1 = self::getCriteriaSolapament($C, $datai, $dataf, HorarisPeer::DIA, HorarisPeer::DIA);
     $C2 = self::getCriteriaSolapament($C, $hi, $hf, HorarisPeer::HORAPRE, HorarisPeer::HORAPOST);
     $C1->addAnd($C2);
     $C->addAnd($C1);
     return $C;
 }
 /**
  * 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 = HorarisespaisPeer::getFieldNames($keyType);
     if (array_key_exists($keys[0], $arr)) {
         $this->setIdhorarisespais($arr[$keys[0]]);
     }
     if (array_key_exists($keys[1], $arr)) {
         $this->setMaterialIdmaterial($arr[$keys[1]]);
     }
     if (array_key_exists($keys[2], $arr)) {
         $this->setEspaisEspaiid($arr[$keys[2]]);
     }
     if (array_key_exists($keys[3], $arr)) {
         $this->setIdespaiextern($arr[$keys[3]]);
     }
     if (array_key_exists($keys[4], $arr)) {
         $this->setHorarisHorarisid($arr[$keys[4]]);
     }
     if (array_key_exists($keys[5], $arr)) {
         $this->setSiteId($arr[$keys[5]]);
     }
     if (array_key_exists($keys[6], $arr)) {
         $this->setActiu($arr[$keys[6]]);
     }
 }
Esempio n. 9
0
$titol = $DESCRIPCIO->getTMig();
$imatge = $DESCRIPCIO->getImatge();
$pdf = $DESCRIPCIO->getPdf();
$descripcio = $DESCRIPCIO->getDMig();
if (!empty($titol)) {
    echo '<TABLE class="BOX">';
    echo '<TR>';
    if (!empty($imatge)) {
        echo '<TD class="FOTO">' . image_tag('noticies/' . $imatge, array('class' => 'IMG_FOTO')) . '</TD>';
    }
    echo '<TD class="NOTICIA">';
    if ($DESCRIPCIO instanceof Activitats) {
        echo '	<DIV class="DATA">';
        $RET = array();
        foreach ($DESCRIPCIO->getHorarisActius($IDS) as $H) {
            $LOHE = $H->getHorarisespaiss(HorarisespaisPeer::getCriteriaActiu(new Criteria(), $IDS));
            $noms = array();
            foreach ($LOHE as $OHE) {
                $noms[] = $OHE->getNomEspai();
            }
            $RET[generaData($H->getDia('Y-m-d')) . ' a les ' . $H->getHoraInici('H:i')] = implode(',', $noms);
        }
        foreach ($RET as $K => $R) {
            echo $K . ' ( ' . $R . ' )<br />';
        }
        echo '  </DIV>';
    }
    echo '<DIV class="TITOL">' . $titol . '</DIV>';
    echo '<DIV>' . $descripcio . '</DIV>';
    echo '<DIV class="PEU">';
    echo '<br />';
Esempio n. 10
0
 /**
  * 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(HorarisespaisPeer::DATABASE_NAME, Propel::CONNECTION_READ);
     }
     $objs = null;
     if (empty($pks)) {
         $objs = array();
     } else {
         $criteria = new Criteria(HorarisespaisPeer::DATABASE_NAME);
         $criteria->add(HorarisespaisPeer::IDHORARISESPAIS, $pks, Criteria::IN);
         $objs = HorarisespaisPeer::doSelect($criteria, $con);
     }
     return $objs;
 }
Esempio n. 11
0
 public static function save($HORARIS, $DBDD, $EXTRES, $idS)
 {
     //Carreguem l'horari que estem tractant i guardarem els espais que usa.
     $A_H = array();
     $A_HE = array();
     if ($HORARIS['HorarisID'] > 0) {
         $OH = HorarisPeer::retrieveByPK($HORARIS['HorarisID']);
         if ($OH instanceof Horaris) {
             $A_H = array($HORARIS['HorarisID']);
         }
         foreach ($OH->getHorarisespaiss() as $HE) {
             $A_HE[] = $HE->getIdhorarisespais();
         }
     }
     //Per cada un dels dies que ha entrat, creem un horari
     foreach ($DBDD['DIES'] as $D) {
         //Carreguem algun dels horaris que estem editant i el sobreescriurem sinó li donem un número nou
         $idH = array_pop($A_H);
         //Si estem fent una substitució, recarreguem, sinó en creem un de nou
         $OH = !is_null($idH) ? HorarisPeer::retrieveByPK($idH) : new Horaris();
         $OH->setActivitatsActivitatid($HORARIS['Activitats_ActivitatID']);
         $OH->setHorainici($DBDD['HoraIn']);
         $OH->setHorapre($DBDD['HoraPre']);
         $OH->setHorapost($DBDD['HoraPost']);
         $OH->setHorafi($DBDD['HoraFi']);
         $OH->setAvis($HORARIS['Avis']);
         $OH->setEspectadors($HORARIS['Espectadors']);
         $OH->setPlaces($HORARIS['Places']);
         $OH->setDia($D);
         $OH->setActiu(true);
         $OH->setSiteid($idS);
         $OH->save();
         //Guardem l'Horari en si
         //Si no hi ha espais, vol dir que és un espai extern. Llavors només guardarem el material.
         if (empty($EXTRES['ESPAISOUT'])) {
             $idEE = $EXTRES['ESPAIEXTERN']->getObject()->getIdespaiextern();
             foreach ($EXTRES['MATERIALOUT'] as $K => $idM) {
                 $idHE = array_pop($A_HE);
                 $OHE = !is_null($idHE) ? HorarisespaisPeer::retrieveByPK($idHE) : new Horarisespais();
                 $OHE->setMaterialIdmaterial($idM['material']);
                 $OHE->setEspaisEspaiid(null);
                 $OHE->setHorarisHorarisid($OH->getHorarisid());
                 //Amb l'identificador de l'horari que hem creat
                 $OHE->setIdespaiextern($idEE);
                 $OHE->setActiu(true);
                 $OHE->setSiteid($idS);
                 $OHE->save();
             }
             if (empty($EXTRES['MATERIALOUT'])) {
                 $idHE = array_pop($A_HE);
                 $OHE = !is_null($idHE) ? HorarisespaisPeer::retrieveByPK($idHE) : new Horarisespais();
                 $OHE->setMaterialIdmaterial(null);
                 $OHE->setEspaisEspaiid(null);
                 $OHE->setHorarisHorarisid($OH->getHorarisid());
                 //Amb l'identificador de l'horari que hem creat
                 $OHE->setIdespaiextern($idEE);
                 $OHE->setActiu(true);
                 $OHE->setSiteid($idS);
                 $OHE->save();
             }
             //Han entrat espais i guardem amb el material corresponent
         } else {
             foreach ($EXTRES['ESPAISOUT'] as $K => $idE) {
                 foreach ($EXTRES['MATERIALOUT'] as $K => $idM) {
                     $idHE = array_pop($A_HE);
                     $OHE = !is_null($idHE) ? HorarisespaisPeer::retrieveByPK($idHE) : new Horarisespais();
                     $OHE->setMaterialIdmaterial($idM['material']);
                     $OHE->setEspaisEspaiid($idE);
                     $OHE->setHorarisHorarisid($OH->getHorarisid());
                     //Amb l'identificador de l'horari que hem creat
                     $OHE->setIdespaiextern(null);
                     $OHE->setActiu(true);
                     $OHE->setSiteid($idS);
                     $OHE->save();
                 }
                 if (empty($EXTRES['MATERIALOUT'])) {
                     $idHE = array_pop($A_HE);
                     $OHE = !is_null($idHE) ? HorarisespaisPeer::retrieveByPK($idHE) : new Horarisespais();
                     $OHE->setMaterialIdmaterial(null);
                     $OHE->setEspaisEspaiid($idE);
                     $OHE->setHorarisHorarisid($OH->getHorarisid());
                     //Amb l'identificador de l'horari que hem creat
                     $OHE->setIdespaiextern(null);
                     $OHE->setActiu(true);
                     $OHE->setSiteid($idS);
                     $OHE->save();
                 }
             }
         }
     }
     //Acabem d'eliminar els que sobrin
     if (!empty($A_H)) {
         foreach ($A_H as $idH) {
             HorarisPeer::retrieveByPK($idH)->setInactiu();
         }
     }
     if (!empty($A_HE)) {
         foreach ($A_HE as $idHE) {
             HorarisespaisPeer::retrieveByPK($idHE)->setInactiu();
         }
     }
 }
Esempio n. 12
0
 /**
  * Method to invalidate the instance pool of all tables related to material
  * by a foreign key with ON DELETE CASCADE
  */
 public static function clearRelatedInstancePool()
 {
     // invalidate objects in HorarisespaisPeer instance pool, since one or more of them may be deleted by ON DELETE CASCADE rule.
     HorarisespaisPeer::clearInstancePool();
 }