/**
	 * Returns a new JNotificationResponsableEleveQuery object.
	 *
	 * @param     string $modelAlias The alias of a model in the query
	 * @param     Criteria $criteria Optional Criteria to build the query from
	 *
	 * @return    JNotificationResponsableEleveQuery
	 */
	public static function create($modelAlias = null, $criteria = null)
	{
		if ($criteria instanceof JNotificationResponsableEleveQuery) {
			return $criteria;
		}
		$query = new JNotificationResponsableEleveQuery();
		if (null !== $modelAlias) {
			$query->setModelAlias($modelAlias);
		}
		if ($criteria instanceof Criteria) {
			$query->mergeWith($criteria);
		}
		return $query;
	}
Example #2
0
	/**
	 * Sets a collection of AbsenceEleveNotification objects related by a many-to-many relationship
	 * to the current object by way of the j_notifications_resp_pers cross-reference table.
	 * It will also schedule objects for deletion based on a diff between old objects (aka persisted)
	 * and new objects from the given Propel collection.
	 *
	 * @param      PropelCollection $absenceEleveNotifications A Propel collection.
	 * @param      PropelPDO $con Optional connection object
	 */
	public function setAbsenceEleveNotifications(PropelCollection $absenceEleveNotifications, PropelPDO $con = null)
	{
		$jNotificationResponsableEleves = JNotificationResponsableEleveQuery::create()
			->filterByAbsenceEleveNotification($absenceEleveNotifications)
			->filterByResponsableEleve($this)
			->find($con);

		$this->absenceEleveNotificationsScheduledForDeletion = $this->getJNotificationResponsableEleves()->diff($jNotificationResponsableEleves);
		$this->collJNotificationResponsableEleves = $jNotificationResponsableEleves;

		foreach ($absenceEleveNotifications as $absenceEleveNotification) {
			// Fix issue with collection modified by reference
			if ($absenceEleveNotification->isNew()) {
				$this->doAddAbsenceEleveNotification($absenceEleveNotification);
			} else {
				$this->addAbsenceEleveNotification($absenceEleveNotification);
			}
		}

		$this->collAbsenceEleveNotifications = $absenceEleveNotifications;
	}
 foreach ($responsablesToAdd as $responsableToAdd) {
     $clone = $notification->copy();
     //no deep copy
     $clone->save();
     $id = $clone->getId();
     //this is done to avoid a bug in deepcopy
     $notification->copyInto($clone, true);
     // deep copy
     $clone->setId($id);
     $clone->setNew(false);
     $clone->setEmail($responsableToAdd->getMel());
     $clone->setTelephone($responsableToAdd->getTelPort());
     $clone->setAdresseId($responsableToAdd->getAdresseId());
     $clone->save();
     // On supprime les anciens responsables de la notification initiale
     $responsables = JNotificationResponsableEleveQuery::create()->filterByAbsenceEleveNotification($clone)->find();
     foreach ($responsables as $responsable) {
         $responsable->delete();
     }
     $clone->addResponsableEleve($responsableToAdd);
     $clone->setStatutEnvoi(AbsenceEleveNotificationPeer::STATUT_ENVOI_ETAT_INITIAL);
     $clone->setDateEnvoi(null);
     $clone->setErreurMessageEnvoi(null);
     $clone->save();
     $message_enregistrement .= '<span style="color:green">Nouvelle notification <a href="./visu_notification.php?id_notification=' . $clone->getId();
     if ($menu) {
         $message_enregistrement .= '&menu=false';
     }
     $message_enregistrement .= '">' . $clone->getId() . '</a> créée pour ' . $responsableToAdd->getCivilite() . ' ' . $responsableToAdd->getPrenom() . ' ' . $responsableToAdd->getNom() . '</span> <br />';
 }
 include "visu_notification.php";
	/**
	 * 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(JNotificationResponsableElevePeer::DATABASE_NAME, Propel::CONNECTION_WRITE);
		}

		$con->beginTransaction();
		try {
			$deleteQuery = JNotificationResponsableEleveQuery::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;
		}
	}