Exemplo n.º 1
0
 /**
  * This is run before each unit test; it empties the database.
  */
 protected function setUp()
 {
     GepiDataPopulator::depopulate($this->con);
     mysqli_query($GLOBALS["mysqli"], 'delete from setting');
     mysqli_query($GLOBALS["mysqli"], 'delete from droits');
     mysqli_query($GLOBALS["mysqli"], 'delete from droits_aid');
     mysqli_query($GLOBALS["mysqli"], 'delete from aid_productions');
     mysqli_query($GLOBALS["mysqli"], 'delete from edt_setting');
     mysqli_query($GLOBALS["mysqli"], 'delete from lettres_tcs');
     mysqli_query($GLOBALS["mysqli"], 'delete from etiquettes_formats');
     mysqli_query($GLOBALS["mysqli"], 'delete from lettres_types');
     mysqli_query($GLOBALS["mysqli"], 'delete from lettres_cadres');
     mysqli_query($GLOBALS["mysqli"], 'delete from ct_types_documents');
     mysqli_query($GLOBALS["mysqli"], 'delete from absences_motifs');
     mysqli_query($GLOBALS["mysqli"], 'delete from model_bulletin');
     mysqli_query($GLOBALS["mysqli"], 'delete from absences_actions');
     $fd = fopen(dirname(__FILE__) ."/../../../../sql/data_gepi.sql", "r");
     if (!$fd) {
         echo "Erreur : fichier sql/data_gepi.sql non trouve\n";
         die;
     }
     while (!feof($fd)) {
         $query = fgets($fd, 5000);
         $query = trim($query);
         if((substr($query,-1)==";")&&(substr($query,0,3)!="-- ")) {
             $reg = mysqli_query($GLOBALS["mysqli"], $query);
             if (!$reg) {
                 echo "ERROR : '$query' \n";
                 echo "Erreur retournée : ".mysqli_error($GLOBALS["mysqli"])."\n";
                 $result_ok = 'no';
             }
         }
     }
     fclose($fd);
      
     loadSettings();
     
     AbsenceEleveSaisiePeer::disableAgregation();
     AbsenceEleveTraitementPeer::disableAgregation();
     
     parent::setUp();
 }
	/**
	 * Delete or soft delete all records, depending on AbsenceEleveTraitementPeer::$softDelete
	 *
	 * @param			 PropelPDO $con the connection to use
	 * @return		 int	The number of affected rows (if supported by underlying database driver).
	 * @throws		 PropelException Any exceptions caught during processing will be
	 *							rethrown wrapped into a PropelException.
	 */
	public static function doDeleteAll(PropelPDO $con = null)
	{
		if (AbsenceEleveTraitementPeer::isSoftDeleteEnabled()) {
			return AbsenceEleveTraitementPeer::doSoftDeleteAll($con);
		} else {
			return AbsenceEleveTraitementPeer::doForceDeleteAll($con);
		}
	}
Exemplo n.º 3
0
 public function testDelete()
 {
     $florence_eleve = EleveQuery::create()->findOneByLogin('Florence Michu');
     $florence_eleve->updateAbsenceAgregationTable();
     AbsenceEleveSaisiePeer::enableAgregation();
     AbsenceEleveTraitementPeer::enableAgregation();
     $traitement = new AbsenceEleveTraitement();
     $traitement->setAbsenceEleveType(AbsenceEleveTypeQuery::create()->filterByNom('Infirmerie')->findOne());
     $traitement->save();
     $traitement->addAbsenceEleveSaisie($florence_eleve->getAbsenceEleveSaisiesDuJour(VENDREDI_s40j5)->getFirst());
     $traitement->save();
     $decompte = AbsenceAgregationDecompteQuery::create()->filterByEleve($florence_eleve)->filterByDateDemiJounee(VENDREDI_s40j5)->findOne();
     $this->assertFalse($decompte->getManquementObligationPresence());
     $j_traitement_saisie = $traitement->getJTraitementSaisieEleves()->getFirst();
     $j_traitement_saisie->delete();
     $decompte->reload();
     $this->assertTrue($decompte->getManquementObligationPresence());
     
             
     AbsenceEleveTraitementPeer::disableAgregation();
     AbsenceEleveSaisiePeer::disableAgregation();
 }
Exemplo n.º 4
0
    public function testDelete()
    {
        $florence_eleve = EleveQuery::create()->findOneByLogin('Florence Michu');

        $traitement = AbsenceEleveTraitementQuery::create()->useJTraitementSaisieEleveQuery()
        ->useAbsenceEleveSaisieQuery()->filterByDebutAbs(JEUDI_s42j4.' 08:00:00')
        ->endUse()->endUse()->findOne();
        //on va vérifier que le delete change bien le update_ad
        $old_updated_at = $traitement->getUpdatedAt('U');
        $traitement->delete();
        $traitement = AbsenceEleveTraitementQuery::create()->useJTraitementSaisieEleveQuery()
        ->useAbsenceEleveSaisieQuery()->filterByDebutAbs(JEUDI_s42j4.' 08:00:00')
        ->endUse()->endUse()->findOne();
        $this->assertNull($traitement);
        $traitement = AbsenceEleveTraitementQuery::create()->includeDeleted()->useJTraitementSaisieEleveQuery()
        ->useAbsenceEleveSaisieQuery()->filterByDebutAbs(JEUDI_s42j4.' 08:00:00')
        ->endUse()->endUse()->findOne();
        $this->assertNotNull($traitement);
        $traitement->unDelete();

        AbsenceEleveTraitementPeer::enableAgregation();
        $traitement->setAbsenceEleveType(AbsenceEleveTypeQuery::create()->filterByNom('Infirmerie')->findOne());
        $traitement->save();
        $decompte = AbsenceAgregationDecompteQuery::create()->filterByEleve($florence_eleve)->filterByDateDemiJounee(JEUDI_s42j4)->findOne();
        $this->assertFalse($decompte->getManquementObligationPresence());
        $traitement->delete();
        $decompte->reload();
        $this->assertTrue($decompte->getManquementObligationPresence());
        AbsenceEleveTraitementPeer::disableAgregation();
    }
	/**
	 * Method to invalidate the instance pool of all tables related to a_justifications
	 * by a foreign key with ON DELETE CASCADE
	 */
	public static function clearRelatedInstancePool()
	{
		// Invalidate objects in AbsenceEleveTraitementPeer instance pool,
		// since one or more of them may be deleted by ON DELETE CASCADE/SETNULL rule.
		AbsenceEleveTraitementPeer::clearInstancePool();
	}
Exemplo n.º 6
0
	/**
	 * Bypass the soft_delete behavior and force a hard delete of the current object
	 */
	public function forceDelete(PropelPDO $con = null)
	{
		if($isSoftDeleteEnabled = AbsenceEleveTraitementPeer::isSoftDeleteEnabled()) {
			AbsenceEleveTraitementPeer::disableSoftDelete();
		}
		$this->delete($con);
		if ($isSoftDeleteEnabled) {
			AbsenceEleveTraitementPeer::enableSoftDelete();
		}
	}
Exemplo n.º 7
0
	/**
	 * Disables agrégation
	 */
	public static function disableAgregation()
	{
		self::$isAgregationEnabled = false;
	}
	/**
	 * Bypass the soft_delete behavior and force a hard delete of all the rows
	 *
	 * @param			PropelPDO $con an optional connection object
	 *
	 * @return		int Number of deleted rows
	 */
	public function forceDeleteAll(PropelPDO $con = null)
	{
		return AbsenceEleveTraitementPeer::doForceDeleteAll($con);}
	/**
	 * Selects a collection of JTraitementSaisieEleve objects pre-filled with all related objects except AbsenceEleveSaisie.
	 *
	 * @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 JTraitementSaisieEleve objects.
	 * @throws     PropelException Any exceptions caught during processing will be
	 *		 rethrown wrapped into a PropelException.
	 */
	public static function doSelectJoinAllExceptAbsenceEleveSaisie(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);
		}

		JTraitementSaisieElevePeer::addSelectColumns($criteria);
		$startcol2 = JTraitementSaisieElevePeer::NUM_HYDRATE_COLUMNS;

		AbsenceEleveTraitementPeer::addSelectColumns($criteria);
		$startcol3 = $startcol2 + AbsenceEleveTraitementPeer::NUM_HYDRATE_COLUMNS;

		$criteria->addJoin(JTraitementSaisieElevePeer::A_TRAITEMENT_ID, AbsenceEleveTraitementPeer::ID, $join_behavior);


		$stmt = BasePeer::doSelect($criteria, $con);
		$results = array();

		while ($row = $stmt->fetch(PDO::FETCH_NUM)) {
			$key1 = JTraitementSaisieElevePeer::getPrimaryKeyHashFromRow($row, 0);
			if (null !== ($obj1 = JTraitementSaisieElevePeer::getInstanceFromPool($key1))) {
				// We no longer rehydrate the object, since this can cause data loss.
				// See http://www.propelorm.org/ticket/509
				// $obj1->hydrate($row, 0, true); // rehydrate
			} else {
				$cls = JTraitementSaisieElevePeer::getOMClass(false);

				$obj1 = new $cls();
				$obj1->hydrate($row);
				JTraitementSaisieElevePeer::addInstanceToPool($obj1, $key1);
			} // if obj1 already loaded

				// Add objects for joined AbsenceEleveTraitement rows

				$key2 = AbsenceEleveTraitementPeer::getPrimaryKeyHashFromRow($row, $startcol2);
				if ($key2 !== null) {
					$obj2 = AbsenceEleveTraitementPeer::getInstanceFromPool($key2);
					if (!$obj2) {
	
						$cls = AbsenceEleveTraitementPeer::getOMClass(false);

					$obj2 = new $cls();
					$obj2->hydrate($row, $startcol2);
					AbsenceEleveTraitementPeer::addInstanceToPool($obj2, $key2);
				} // if $obj2 already loaded

				// Add the $obj1 (JTraitementSaisieEleve) to the collection in $obj2 (AbsenceEleveTraitement)
				$obj2->addJTraitementSaisieEleve($obj1);

			} // if joined row is not null

			$results[] = $obj1;
		}
		$stmt->closeCursor();
		return $results;
	}
Exemplo n.º 10
0
	/**
	 * Code to be run after persisting the object
	 * @param PropelPDO $con
	 */
	public function postSave(PropelPDO $con = null) { 
		if (AbsenceEleveTraitementPeer::isAgregationEnabled()) {
		    $this->updateAgregationTable();
		}
	}