Exemplo n.º 1
0
  	/**
	 *
	 * Retourne la date de debut de periode
	 *
	 * @param      string $format The date/time format string (either date()-style or strftime()-style).
	 *							If format is NULL, then the raw DateTime object will be returned.
	 *
	 * @return DateTime $date ou null si non précisé
	 */
	public function getDateDebut($format = null) {
	    if(null === $this->dateDebut) {
		    if ($this->isNew()) {
			    //do nothing
		    } else {
			    $dateDebut = null;
			    if ($this->getNumPeriode() == 1) {
				//on essaye de récupérer la date de début dans le calendrier des périodes
				$edt_periode = EdtCalendrierPeriodeQuery::create()->filterByNumeroPeriode($this->getNumPeriode())->orderByDebutCalendrierTs()->findOne();
				if ($edt_periode != null) {
				    $dateDebut = $edt_periode->getJourdebutCalendrier(null);
				} else {
				    //c'est la premiere periode
				    //on va renvoyer par default le début de l'année scolaire
				    include_once(dirname(__FILE__).'/../../../helpers/EdtHelper.php');
				    $dateDebut = EdtHelper::getPremierJourAnneeScolaire($this->getDateFin());
				}
			    } else {
				//on renvoi la date de fin de la periode precedente
				$periode_prec = PeriodeNoteQuery::create()->filterByIdClasse($this->getIdClasse())->filterByNumPeriode($this->getNumPeriode() - 1)->findOne();
				if ($periode_prec != null) {
				    $dateDebut = $periode_prec->getDateFin(null);
				}
				//on prend le lendemain
				if ($dateDebut !== null) {
				    $dateDebut->modify("+24 hours");
				}
			    }
			    if ($dateDebut !== null) {
				//on commence la periode a 00:00
				$dateDebut->setTime(0,0,0);
			    }
			    $this->dateDebut = $dateDebut;
		    }
	    }
	    if ($this->dateDebut === null) {
		    //on initialise a un timestamp de 0  pour ne pas faire de nouveau la recherche
		    $this->dateDebut == new DateTime('@0');
		    return null;
	    } else if ($this->dateDebut->format('U') == 0) {
		    return null;
	    }

	    if ($format === null) {
		    //we return a DateTime object.
		    return $this->dateDebut;
	    } elseif (strpos($format, '%') !== false) {
		    return strftime($format, $this->dateDebut->format('U'));
	    } else {
		    return $this->dateDebut->format($format);
	    }
	}
Exemplo n.º 2
0
	/**
	 * Get the associated EdtCalendrierPeriode object
	 *
	 * @param      PropelPDO Optional Connection object.
	 * @return     EdtCalendrierPeriode The associated EdtCalendrierPeriode object.
	 * @throws     PropelException
	 */
	public function getEdtCalendrierPeriode(PropelPDO $con = null)
	{
		if ($this->aEdtCalendrierPeriode === null && (($this->id_calendrier !== "" && $this->id_calendrier !== null))) {
			$this->aEdtCalendrierPeriode = EdtCalendrierPeriodeQuery::create()->findPk($this->id_calendrier, $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->aEdtCalendrierPeriode->addEdtEmplacementCourss($this);
			 */
		}
		return $this->aEdtCalendrierPeriode;
	}
Exemplo n.º 3
0
	/**
	 * Removes this object from datastore and sets delete attribute.
	 *
	 * @param      PropelPDO $con
	 * @return     void
	 * @throws     PropelException
	 * @see        BaseObject::setDeleted()
	 * @see        BaseObject::isDeleted()
	 */
	public function delete(PropelPDO $con = null)
	{
		if ($this->isDeleted()) {
			throw new PropelException("This object has already been deleted.");
		}

		if ($con === null) {
			$con = Propel::getConnection(EdtCalendrierPeriodePeer::DATABASE_NAME, Propel::CONNECTION_WRITE);
		}

		$con->beginTransaction();
		try {
			$deleteQuery = EdtCalendrierPeriodeQuery::create()
				->filterByPrimaryKey($this->getPrimaryKey());
			$ret = $this->preDelete($con);
			if ($ret) {
				$deleteQuery->delete($con);
				$this->postDelete($con);
				$con->commit();
				$this->setDeleted(true);
			} else {
				$con->commit();
			}
		} catch (Exception $e) {
			$con->rollBack();
			throw $e;
		}
	}
	/**
	 * Returns a new EdtCalendrierPeriodeQuery object.
	 *
	 * @param     string $modelAlias The alias of a model in the query
	 * @param     Criteria $criteria Optional Criteria to build the query from
	 *
	 * @return    EdtCalendrierPeriodeQuery
	 */
	public static function create($modelAlias = null, $criteria = null)
	{
		if ($criteria instanceof EdtCalendrierPeriodeQuery) {
			return $criteria;
		}
		$query = new EdtCalendrierPeriodeQuery();
		if (null !== $modelAlias) {
			$query->setModelAlias($modelAlias);
		}
		if ($criteria instanceof Criteria) {
			$query->mergeWith($criteria);
		}
		return $query;
	}
Exemplo n.º 5
0
  /**
   * Renvoie la liste des creneaux de la journee
   *
   * @return PropelObjectCollection EdtCreneau
   */
    public static function retrieveAllEdtCalendrierPeriodesOrderByTime(){
	    if (self::$_all_periodes == null) {
		self::$_all_periodes = EdtCalendrierPeriodeQuery::create()->addAscendingOrderByColumn(EdtCalendrierPeriodePeer::JOURDEBUT_CALENDRIER)->find();
	    }
	    return clone self::$_all_periodes;
    }