public function testModification() { $florence_eleve = EleveQuery::create()->findOneByLogin('Florence Michu'); $saisie = AbsenceEleveSaisieQuery::create()->filterByDebutAbs(DIMANCHE_s41j7.' 08:00:00')->findOne(); $traitements = AbsenceEleveTraitementQuery::create()->useAbsenceEleveTypeQuery()->filterByNom('Infirmerie')->endUse()->find(); $traitement_1 = $traitements->getFirst(); $traitement_2 = $traitements->get(1); $j_traitement_saisie = $traitement_1->getJTraitementSaisieEleves()->getFirst(); try { $j_traitement_saisie->setAbsenceEleveTraitement($traitement_2); $this->fail('Une exception doit être soulevée lors de cette modification'); } catch (Exception $e) { $this->assertTrue(true); } try { $j_traitement_saisie->setAbsenceEleveSaisie($saisie); $this->fail('Une exception doit être soulevée lors de cette modification'); } catch (Exception $e) { $this->assertTrue(true); } try { $j_traitement_saisie->setATraitementId($traitement_2->getId()); $this->fail('Une exception doit être soulevée lors de cette modification'); } catch (Exception $e) { $this->assertTrue(true); } try { $j_traitement_saisie->setASaisieId($saisie->getId()); $this->fail('Une exception doit être soulevée lors de cette modification'); } catch (Exception $e) { $this->assertTrue(true); } }
/** * Check the soft_delete behavior for this model * @return boolean true if the soft_delete behavior is enabled */ public static function isSoftDeleteEnabled() { return AbsenceEleveTraitementQuery::isSoftDeleteEnabled(); }
$affichage = isset($_POST["affichage"]) ? $_POST["affichage"] : (isset($_GET["affichage"]) ? $_GET["affichage"] : NULL); $menu = isset($_POST["menu"]) ? $_POST["menu"] : (isset($_GET["menu"]) ? $_GET["menu"] : Null); $imprime = isset($_POST["imprime"]) ? $_POST["imprime"] : (isset($_GET["imprime"]) ? $_GET["imprime"] : Null); $ne_pas_afficher_traitements_saisies_rattachees = isset($_POST["ne_pas_afficher_traitements_saisies_rattachees"]) ? $_POST["ne_pas_afficher_traitements_saisies_rattachees"] : "n"; //============================================== $style_specifique[] = "mod_abs2/lib/abs_style"; $style_specifique[] = "lib/DHTMLcalendar/calendarstyle"; $javascript_specifique[] = "lib/DHTMLcalendar/calendar"; $javascript_specifique[] = "lib/DHTMLcalendar/lang/calendar-fr"; $javascript_specifique[] = "lib/DHTMLcalendar/calendar-setup"; if (!$menu) { $titre_page = "Les absences"; } $utilisation_jsdivdrag = "non"; $_SESSION['cacher_header'] = "y"; $query = AbsenceEleveTraitementQuery::create(); if (isFiltreRechercheParam('filter_traitement_id')) { $query->filterById(getFiltreRechercheParam('filter_traitement_id')); } if (isFiltreRechercheParam('filter_utilisateur')) { $query->useUtilisateurProfessionnelQuery()->filterByNom('%' . getFiltreRechercheParam('filter_utilisateur') . '%', Criteria::LIKE)->endUse(); } if (isFiltreRechercheParam('filter_eleve')) { $query->useJTraitementSaisieEleveQuery()->useAbsenceEleveSaisieQuery()->useEleveQuery()->filterByNomOrPrenomLike(getFiltreRechercheParam('filter_eleve'))->endUse()->endUse()->endUse(); } // filtre classe // $classe = ClasseQuery::create()->filterByNom("6 D")->findOne(); //$id_classe = 14; //$classe = ClasseQuery::create()->findPk($id_classe); if (isFiltreRechercheParam('filter_classe')) { if (in_array('SANS', getFiltreRechercheParam('filter_classe'))) {
header("Location: ../logout.php?auto=1"); die; } //On vérifie si le module est activé if (getSettingValue("active_module_absence") != '2') { die("Le module n'est pas activé."); } if ($utilisateur->getStatut() != "cpe" && $utilisateur->getStatut() != "scolarite") { die("acces interdit"); } //récupération des paramètres de la requète $id_traitement = isset($_POST["id_traitement"]) ? $_POST["id_traitement"] : (isset($_GET["id_traitement"]) ? $_GET["id_traitement"] : NULL); $modif = isset($_POST["modif"]) ? $_POST["modif"] : (isset($_GET["modif"]) ? $_GET["modif"] : null); $menu = isset($_POST["menu"]) ? $_POST["menu"] : (isset($_GET["menu"]) ? $_GET["menu"] : Null); $message_enregistrement = ''; $traitement = AbsenceEleveTraitementQuery::create()->findPk($id_traitement); if ($traitement == null) { $message_enregistrement .= '<span style="color:red">Modification impossible : traitement non trouvée.</span>'; include "visu_traitement.php"; die; } //debug_var(); if ($modif == 'type') { $traitement->setAbsenceEleveType(AbsenceEleveTypeQuery::create()->findPk($_POST["id_type"])); } elseif ($modif == 'commentaire') { $traitement->setCommentaire($_POST["commentaire"]); } elseif ($modif == 'justification') { $traitement->setAbsenceEleveJustification(AbsenceEleveJustificationQuery::create()->findPk($_POST["id_justification"])); } elseif ($modif == 'motif') { $traitement->setAbsenceEleveMotif(AbsenceEleveMotifQuery::create()->findPk($_POST["id_motif"])); } elseif ($modif == 'enlever_saisie') {
public function testThinCheckAndUpdateSynchroAbsenceAgregationTable() { //on purge les decompte pour florence $florence_eleve = EleveQuery::create()->findOneByLogin('Florence Michu'); AbsenceAgregationDecompteQuery::create()->filterByEleve($florence_eleve)->delete(); $this->assertFalse($florence_eleve->checkSynchroAbsenceAgregationTable(new DateTime(VENDREDI_s40j5.' 00:00:00'),new DateTime(MARDI_s41j2.' 23:59:59'))); $florence_eleve->thinCheckAndUpdateSynchroAbsenceAgregationTable(new DateTime(VENDREDI_s40j5.' 00:00:00'),new DateTime(MARDI_s41j2.' 23:59:59')); $this->assertTrue($florence_eleve->checkSynchroAbsenceAgregationTable(new DateTime(VENDREDI_s40j5.' 00:00:00'),new DateTime(MARDI_s41j2.' 23:59:59'))); AbsenceAgregationDecompteQuery::create()->filterByEleve($florence_eleve)->delete(); $florence_eleve->thinCheckAndUpdateSynchroAbsenceAgregationTable(); $this->assertTrue($florence_eleve->checkSynchroAbsenceAgregationTable()); AbsenceAgregationDecompteQuery::create()->filterByEleve($florence_eleve)->delete(); $florence_eleve->thinCheckAndUpdateSynchroAbsenceAgregationTable(new DateTime(VENDREDI_s40j5.' 00:00:00'),new DateTime(VENDREDI_s42j5.' 23:59:59')); $this->assertTrue($florence_eleve->checkSynchroAbsenceAgregationTable(new DateTime(VENDREDI_s40j5.' 00:00:00'),new DateTime(VENDREDI_s42j5.' 23:59:59'))); AbsenceAgregationDecompteQuery::create()->filterByEleve($florence_eleve)->filterByManquementObligationPresence(true)->filterByNonJustifiee(false)->delete(); $this->assertFalse($florence_eleve->checkSynchroAbsenceAgregationTable(new DateTime(VENDREDI_s40j5.' 00:00:00'),new DateTime(VENDREDI_s42j5.' 23:59:59'))); $florence_eleve->thinCheckAndUpdateSynchroAbsenceAgregationTable(new DateTime(VENDREDI_s40j5.' 00:00:00'),new DateTime(VENDREDI_s42j5.' 23:59:59')); $this->assertTrue($florence_eleve->checkSynchroAbsenceAgregationTable(new DateTime(VENDREDI_s40j5.' 00:00:00'),new DateTime(VENDREDI_s42j5.' 23:59:59'))); AbsenceAgregationDecompteQuery::create()->filterByEleve($florence_eleve)->filterByManquementObligationPresence(true)->filterByNonJustifiee(false)->delete(); $this->assertFalse($florence_eleve->checkSynchroAbsenceAgregationTable(new DateTime(VENDREDI_s40j5.' 00:00:00'),new DateTime(VENDREDI_s42j5.' 23:59:59'))); $florence_eleve->thinCheckAndUpdateSynchroAbsenceAgregationTable(new DateTime(VENDREDI_s40j5.' 00:00:00'),new DateTime(VENDREDI_s42j5.' 23:59:59')); $this->assertTrue($florence_eleve->checkSynchroAbsenceAgregationTable(new DateTime(VENDREDI_s40j5.' 00:00:00'),new DateTime(VENDREDI_s42j5.' 23:59:59'))); //on va modifier une saisie à la main $tomorow = new DateTime(); $tomorow->modify("+1 day"); mysqli_query($GLOBALS["mysqli"], "update a_saisies set updated_at = '".$tomorow->format('Y-m-d H:i:s')."' where id = ".$florence_eleve->getAbsenceEleveSaisiesDuJour(VENDREDI_s40j5)->getFirst()->getId()); $this->assertFalse($florence_eleve->checkSynchroAbsenceAgregationTable(new DateTime(VENDREDI_s40j5.' 00:00:00'),new DateTime(VENDREDI_s42j5.' 23:59:59'))); $this->assertFalse($florence_eleve->checkSynchroAbsenceAgregationTable()); mysqli_query($GLOBALS["mysqli"], "update a_saisies set updated_at = now() where id = ".$florence_eleve->getAbsenceEleveSaisiesDuJour(VENDREDI_s40j5)->getFirst()->getId()); $florence_eleve->thinCheckAndUpdateSynchroAbsenceAgregationTable(new DateTime(VENDREDI_s40j5.' 00:00:00'),new DateTime(VENDREDI_s42j5.' 23:59:59')); $this->assertTrue($florence_eleve->checkSynchroAbsenceAgregationTable(new DateTime(VENDREDI_s40j5.' 00:00:00'),new DateTime(VENDREDI_s42j5.' 23:59:59'))); $this->assertTrue($florence_eleve->checkSynchroAbsenceAgregationTable()); //on va modifier une version de saisie à la main $tomorow = new DateTime(); $tomorow->modify("+1 day"); mysqli_query($GLOBALS["mysqli"], "update a_saisies_version set updated_at = '".$tomorow->format('Y-m-d H:i:s')."' where eleve_id = ".$florence_eleve->getId()); $this->assertFalse($florence_eleve->checkSynchroAbsenceAgregationTable(new DateTime(VENDREDI_s40j5.' 00:00:00'),new DateTime(VENDREDI_s42j5.' 23:59:59'))); $this->assertFalse($florence_eleve->checkSynchroAbsenceAgregationTable()); mysqli_query($GLOBALS["mysqli"], "update a_saisies_version set updated_at = now() where eleve_id = ".$florence_eleve->getId()); $florence_eleve->thinCheckAndUpdateSynchroAbsenceAgregationTable(new DateTime(VENDREDI_s40j5.' 00:00:00'),new DateTime(VENDREDI_s42j5.' 23:59:59')); $this->assertTrue($florence_eleve->checkSynchroAbsenceAgregationTable(new DateTime(VENDREDI_s40j5.' 00:00:00'),new DateTime(VENDREDI_s42j5.' 23:59:59'))); $this->assertTrue($florence_eleve->checkSynchroAbsenceAgregationTable()); //on va modifier un traitement à la main $tomorow = new DateTime(); $tomorow->modify("+1 day"); $saisie = $florence_eleve->getAbsenceEleveSaisiesDuJour(SAMEDI_s40j6)->getFirst(); $traitement_id = AbsenceEleveTraitementQuery::create()->filterByAbsenceEleveSaisie($saisie)->findOne()->getId(); mysqli_query($GLOBALS["mysqli"], "update a_traitements set updated_at = '".$tomorow->format('Y-m-d H:i:s')."' where id = ".$traitement_id); $this->assertFalse($florence_eleve->checkSynchroAbsenceAgregationTable(new DateTime(VENDREDI_s40j5.' 00:00:00'),new DateTime(VENDREDI_s42j5.' 23:59:59'))); $this->assertFalse($florence_eleve->checkSynchroAbsenceAgregationTable()); mysqli_query($GLOBALS["mysqli"], "update a_traitements set updated_at = now() where id = ".$traitement_id); $florence_eleve->thinCheckAndUpdateSynchroAbsenceAgregationTable(new DateTime(VENDREDI_s40j5.' 00:00:00'),new DateTime(VENDREDI_s42j5.' 23:59:59')); $this->assertTrue($florence_eleve->checkSynchroAbsenceAgregationTable(new DateTime(VENDREDI_s40j5.' 00:00:00'),new DateTime(VENDREDI_s42j5.' 23:59:59'))); $this->assertTrue($florence_eleve->checkSynchroAbsenceAgregationTable()); //on va modifier à la main une saisie sleep(1); $traitement_id = AbsenceEleveTraitementQuery::create()->filterByAbsenceEleveSaisie($saisie)->findOne()->getId(); mysqli_query($GLOBALS["mysqli"], "update a_traitements set updated_at = now() where id = ".$traitement_id); $this->assertFalse($florence_eleve->checkSynchroAbsenceAgregationTable(new DateTime(VENDREDI_s40j5.' 00:00:00'),new DateTime(VENDREDI_s42j5.' 23:59:59'))); $this->assertFalse($florence_eleve->checkSynchroAbsenceAgregationTable()); $florence_eleve->thinCheckAndUpdateSynchroAbsenceAgregationTable(); $this->assertTrue($florence_eleve->checkSynchroAbsenceAgregationTable(new DateTime(VENDREDI_s40j5.' 00:00:00'),new DateTime(DIMANCHE_s41j7.' 23:59:59'))); $this->assertTrue($florence_eleve->checkSynchroAbsenceAgregationTable()); }
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(); }
/** * Récupère les données d'un élève à afficher * @param objet $eleve Un élève issu de getEleves() * @param date $date_debut * @param date $date_fin * @param objet $justifie_col Collection Propel avec les justifications * @param bool $donneeBrut * @return array Une ligne du tableau à afficher * @see getEleves() */ function traiteEleve($eleve,$date_debut, $date_fin, $justifie_col, $donneeBrut, $erreur=FALSE) { $eleve_id = $eleve->getId(); $donnees= array(); $donnees[$eleve_id] = array(); $propel_eleve = EleveQuery::create()->filterById($eleve_id)->findOne(); $eleveNbAbs['demi_journees'] = $propel_eleve->getDemiJourneesAbsence($date_debut, $date_fin)->count(); $eleveNbAbs['retards'] = $propel_eleve->getRetards($date_debut, $date_fin)->count(); if ($eleveNbAbs['demi_journees'] > 0 || $eleveNbAbs['retards'] > 0 ) { $eleveNbAbs['non_justifiees'] = $propel_eleve->getDemiJourneesNonJustifieesAbsence($date_debut, $date_fin)->count(); $eleveNbAbs['justifiees'] = $eleveNbAbs['demi_journees'] - $eleveNbAbs['non_justifiees']; $donnees[$eleve_id]['nom'] = $eleve->getNom(); $donnees[$eleve_id]['prenom'] = $eleve->getPrenom(); $donnees[$eleve_id]['classe'] = $eleve->getClasse(); $donnees[$eleve_id]['classe'] = $eleve->getClasseNom(); $donnees[$eleve_id]['nbre_lignes_total'] = 0; $donnees[$eleve_id]['demi_journees'] = $eleveNbAbs['demi_journees']; $donnees[$eleve_id]['justifiees'] = $eleveNbAbs['justifiees']; $donnees[$eleve_id]['non_justifiees'] = $eleveNbAbs['non_justifiees']; $donnees[$eleve_id]['retards'] = $eleveNbAbs['retards']; //Récupérer le décompte des traitements pour chaque élève $totalDemi=0; foreach ($justifie_col as $justifie) { // Décompte en données brutes if ($donneeBrut == TRUE) { $propel_traitEleve = AbsenceEleveTraitementQuery::create()->filterByAJustificationId($justifie->getid()) ->useJTraitementSaisieEleveQuery() ->useAbsenceEleveSaisieQuery() ->filterByEleveId($eleve_id) ->filterByPlageTemps($date_debut,$date_fin ) ->endUse() ->endUse() ; $traiteEleve_col = $propel_traitEleve; $donnees[$eleve_id]['traitement'][] = $traiteEleve_col->distinct()->count(); } else { // Décompte en 1/2 journées $abs_saisie_col_filtrees = $eleve->getAbsenceEleveSaisiesDecompteDemiJournees($date_debut, $date_fin); $justif_collection = new PropelCollection(); foreach ($abs_saisie_col_filtrees as $saisie) { foreach ($saisie->getAbsenceEleveTraitements() as $traitement) { if ($traitement->getAJustificationId() == $justifie->getid()) { $justif_collection->add($saisie); } } } require_once(dirname(__FILE__)."/../orm//helpers/AbsencesEleveSaisieHelper.php"); $dm = AbsencesEleveSaisieHelper::compte_demi_journee($justif_collection, $date_debut, $date_fin); $donnees[$eleve_id]['traitement'][] = $dm->count(); $totalDemi += $dm->count(); } } $donnees[$eleve_id]['totalDemi']=$totalDemi; } unset ($eleveNbAbs, $traiteEleve_col, $propel_eleve, $propel_traitEleveDemi, $traiteEleveDemi, $traiteEleveDemi_col, $propel_traitEleve); if ($erreur && isset ($donnees[$eleve_id]['justifiees']) && ($donnees[$eleve_id]['justifiees']==$donnees[$eleve_id]['totalDemi'])) { $donnees[$eleve_id] = array(); } return $donnees; }
/** * Gets the number of AbsenceEleveTraitement objects related by a many-to-many relationship * to the current object by way of the j_traitements_saisies cross-reference table. * * @param Criteria $criteria Optional query object to filter the query * @param boolean $distinct Set to true to force count distinct * @param PropelPDO $con Optional connection object * * @return int the number of related AbsenceEleveTraitement objects */ public function countAbsenceEleveTraitements($criteria = null, $distinct = false, PropelPDO $con = null) { if(null === $this->collAbsenceEleveTraitements || null !== $criteria) { if ($this->isNew() && null === $this->collAbsenceEleveTraitements) { return 0; } else { $query = AbsenceEleveTraitementQuery::create(null, $criteria); if($distinct) { $query->distinct(); } return $query ->filterByAbsenceEleveSaisie($this) ->count($con); } } else { return count($this->collAbsenceEleveTraitements); } }
public function testHaveToPaginateWithMany() { $query = AbsenceEleveTraitementQuery::create()->joinWith('AbsenceEleveType'); $traitement_col = $query->paginate(0, 2); $this->assertEquals(2, $traitement_col->getResults()->count()); }
/** * 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(AbsenceEleveTraitementPeer::DATABASE_NAME, Propel::CONNECTION_WRITE); } $con->beginTransaction(); try { $deleteQuery = AbsenceEleveTraitementQuery::create() ->filterByPrimaryKey($this->getPrimaryKey()); $ret = $this->preDelete($con); // soft_delete behavior if (!empty($ret) && AbsenceEleveTraitementQuery::isSoftDeleteEnabled()) { $this->keepUpdateDateUnchanged(); $this->setDeletedAt(time()); $this->save($con); $this->postDelete($con); $con->commit(); AbsenceEleveTraitementPeer::removeInstanceFromPool($this); return; } if ($ret) { $deleteQuery->delete($con); $this->postDelete($con); $con->commit(); $this->setDeleted(true); } else { $con->commit(); } } catch (Exception $e) { $con->rollBack(); throw $e; } }
/** * If this collection has already been initialized with * an identical criteria, it returns the collection. * Otherwise if this AbsenceEleveType is new, it will return * an empty collection; or if this AbsenceEleveType has previously * been saved, it will retrieve related AbsenceEleveTraitements 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 AbsenceEleveType. * * @param Criteria $criteria optional Criteria object to narrow the query * @param PropelPDO $con optional connection object * @param string $join_behavior optional join type to use (defaults to Criteria::LEFT_JOIN) * @return PropelCollection|array AbsenceEleveTraitement[] List of AbsenceEleveTraitement objects */ public function getAbsenceEleveTraitementsJoinModifieParUtilisateur($criteria = null, $con = null, $join_behavior = Criteria::LEFT_JOIN) { $query = AbsenceEleveTraitementQuery::create(null, $criteria); $query->joinWith('ModifieParUtilisateur', $join_behavior); return $this->getAbsenceEleveTraitements($query, $con); }
/** * If this collection has already been initialized with * an identical criteria, it returns the collection. * Otherwise if this UtilisateurProfessionnel is new, it will return * an empty collection; or if this UtilisateurProfessionnel has previously * been saved, it will retrieve related ModifiedAbsenceEleveTraitements 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 UtilisateurProfessionnel. * * @param Criteria $criteria optional Criteria object to narrow the query * @param PropelPDO $con optional connection object * @param string $join_behavior optional join type to use (defaults to Criteria::LEFT_JOIN) * @return PropelCollection|array AbsenceEleveTraitement[] List of AbsenceEleveTraitement objects */ public function getModifiedAbsenceEleveTraitementsJoinAbsenceEleveJustification($criteria = null, $con = null, $join_behavior = Criteria::LEFT_JOIN) { $query = AbsenceEleveTraitementQuery::create(null, $criteria); $query->joinWith('AbsenceEleveJustification', $join_behavior); return $this->getModifiedAbsenceEleveTraitements($query, $con); }
public function testPeerCheckSynchroAbsenceAgregationTable() { AbsenceAgregationDecompteQuery::create()->deleteAll(); foreach (EleveQuery::create()->find() as $eleve) { $eleve->updateAbsenceAgregationTable(); } $this->assertTrue(AbsenceAgregationDecomptePeer::checkSynchroAbsenceAgregationTable(null, null, 0),'Doit renvoyer true quand tout est à jour'); //on va tester sur les date (dates plus large que la mise à jour, il va manquer des demi-journées AbsenceAgregationDecompteQuery::create()->deleteAll(); foreach (EleveQuery::create()->find() as $eleve) { $eleve->updateAbsenceAgregationTable(new DateTime(VENDREDI_s40j5.' 00:00:00'),new DateTime(MARDI_s41j2.' 23:59:59')); } $this->assertTrue(AbsenceAgregationDecomptePeer::checkSynchroAbsenceAgregationTable(new DateTime(VENDREDI_s40j5.' 00:00:00'),new DateTime(MARDI_s41j2.' 23:59:59'), 0)); $this->assertFalse(AbsenceAgregationDecomptePeer::checkSynchroAbsenceAgregationTable(new DateTime(VENDREDI_s40j5.' 00:00:00'),new DateTime(MERCREDI_s41j3.' 23:59:59'), 0)); $this->assertFalse(AbsenceAgregationDecomptePeer::checkSynchroAbsenceAgregationTable(new DateTime(VENDREDI_s40j5.' 00:00:00'),new DateTime(MERCREDI_s41j3.' 23:59:59'), 1)); $this->assertTrue(AbsenceAgregationDecomptePeer::checkSynchroAbsenceAgregationTable(new DateTime(VENDREDI_s40j5.' 00:00:00'),new DateTime(MERCREDI_s41j3.' 23:59:59'), 10)); //on va supprimer les marqueurs de calcul AbsenceAgregationDecompteQuery::create()->deleteAll(); foreach (EleveQuery::create()->find() as $eleve) { $eleve->updateAbsenceAgregationTable(new DateTime(VENDREDI_s40j5.' 00:00:00'),new DateTime(DIMANCHE_s41j7.' 23:59:59')); } AbsenceAgregationDecompteQuery::create()->filterByMarqueurFinMiseAJour()->delete(); $this->assertFalse(AbsenceAgregationDecomptePeer::checkSynchroAbsenceAgregationTable(new DateTime(VENDREDI_s40j5.' 00:00:00'),new DateTime(MARDI_s41j2.' 23:59:59'), 0)); $this->assertFalse(AbsenceAgregationDecomptePeer::checkSynchroAbsenceAgregationTable(new DateTime(VENDREDI_s40j5.' 00:00:00'),new DateTime(MARDI_s41j2.' 23:59:59'), 0)); $this->assertFalse(AbsenceAgregationDecomptePeer::checkSynchroAbsenceAgregationTable(new DateTime(VENDREDI_s40j5.' 00:00:00'),new DateTime(MARDI_s41j2.' 23:59:59'), 1)); $this->assertTrue(AbsenceAgregationDecomptePeer::checkSynchroAbsenceAgregationTable(new DateTime(VENDREDI_s40j5.' 00:00:00'),new DateTime(MARDI_s41j2.' 23:59:59'), 10)); //on va modifier une saisie à la main $tomorow = new DateTime(); $tomorow->modify("+1 day"); $florence_eleve = EleveQuery::create()->findOneByLogin('Florence Michu'); $saisie_id = $florence_eleve->getAbsenceEleveSaisiesDuJour(VENDREDI_s40j5)->getFirst()->getId(); mysqli_query($GLOBALS["mysqli"], "update a_saisies set updated_at = '".$tomorow->format('Y-m-d H:i:s')."' where id = ".$saisie_id); $this->assertTrue(AbsenceAgregationDecomptePeer::checkSynchroAbsenceAgregationTable(new DateTime(SAMEDI_s40j6.' 00:00:00'),new DateTime(MARDI_s41j2.' 23:59:59'), 0)); $this->assertFalse(AbsenceAgregationDecomptePeer::checkSynchroAbsenceAgregationTable(new DateTime(VENDREDI_s40j5.' 00:00:00'),new DateTime(MARDI_s41j2.' 23:59:59'), 0)); $this->assertFalse(AbsenceAgregationDecomptePeer::checkSynchroAbsenceAgregationTable(new DateTime(VENDREDI_s40j5.' 00:00:00'),new DateTime(MARDI_s41j2.' 23:59:59'), 1)); $this->assertFalse(AbsenceAgregationDecomptePeer::checkSynchroAbsenceAgregationTable(new DateTime(VENDREDI_s40j5.' 00:00:00'),new DateTime(MARDI_s41j2.' 23:59:59'), 10)); mysqli_query($GLOBALS["mysqli"], "update a_saisies set updated_at = now() where id = ".$saisie_id); //on va modifier à la main une saisie, un traitement et une version de saisie AbsenceAgregationDecompteQuery::create()->deleteAll(); foreach (EleveQuery::create()->find() as $eleve) { $eleve->updateAbsenceAgregationTable(new DateTime(VENDREDI_s40j5.' 00:00:00'),new DateTime(SAMEDI_s42j6.' 23:59:59')); } sleep(1); $saisie_id = $florence_eleve->getAbsenceEleveSaisiesDuJour(SAMEDI_s40j6)->getFirst()->getId(); mysqli_query($GLOBALS["mysqli"], "update a_saisies set updated_at = now() where id = ".$saisie_id); $this->assertFalse(AbsenceAgregationDecomptePeer::checkSynchroAbsenceAgregationTable(new DateTime(VENDREDI_s40j5.' 00:00:00'),new DateTime(DIMANCHE_s41j7.' 23:59:59'),0)); $this->assertFalse(AbsenceAgregationDecomptePeer::checkSynchroAbsenceAgregationTable(new DateTime(VENDREDI_s40j5.' 00:00:00'),new DateTime(DIMANCHE_s41j7.' 23:59:59'),10)); $this->assertFalse(AbsenceAgregationDecomptePeer::checkSynchroAbsenceAgregationTable(null, null, 0)); mysqli_query($GLOBALS["mysqli"], "update a_saisies set updated_at = now()-10 where id = ".$saisie_id); $this->assertTrue(AbsenceAgregationDecomptePeer::checkSynchroAbsenceAgregationTable(new DateTime(VENDREDI_s40j5.' 00:00:00'),new DateTime(DIMANCHE_s41j7.' 23:59:59'),0)); $this->assertTrue(AbsenceAgregationDecomptePeer::checkSynchroAbsenceAgregationTable(null, null, 0)); mysqli_query($GLOBALS["mysqli"], "update a_saisies set deleted_at = now() where id = ".$saisie_id); $this->assertFalse(AbsenceAgregationDecomptePeer::checkSynchroAbsenceAgregationTable(new DateTime(VENDREDI_s40j5.' 00:00:00'),new DateTime(DIMANCHE_s41j7.' 23:59:59'),0)); $this->assertFalse(AbsenceAgregationDecomptePeer::checkSynchroAbsenceAgregationTable(new DateTime(VENDREDI_s40j5.' 00:00:00'),new DateTime(DIMANCHE_s41j7.' 23:59:59'),10)); $this->assertFalse(AbsenceAgregationDecomptePeer::checkSynchroAbsenceAgregationTable(null, null, 0)); mysqli_query($GLOBALS["mysqli"], "update a_saisies set deleted_at = now()-10 where id = ".$saisie_id); $this->assertTrue(AbsenceAgregationDecomptePeer::checkSynchroAbsenceAgregationTable(new DateTime(VENDREDI_s40j5.' 00:00:00'),new DateTime(DIMANCHE_s41j7.' 23:59:59'),0)); $this->assertTrue(AbsenceAgregationDecomptePeer::checkSynchroAbsenceAgregationTable(null, null, 0)); $traitement_id = AbsenceEleveTraitementQuery::create()->filterByAbsenceEleveSaisie($florence_eleve->getAbsenceEleveSaisiesDuJour(SAMEDI_s40j6)->getFirst())->findOne()->getId(); mysqli_query($GLOBALS["mysqli"], "update a_traitements set updated_at = now() where id = ".$traitement_id); $this->assertFalse(AbsenceAgregationDecomptePeer::checkSynchroAbsenceAgregationTable(new DateTime(VENDREDI_s40j5.' 00:00:00'),new DateTime(DIMANCHE_s41j7.' 23:59:59'),0)); $this->assertFalse(AbsenceAgregationDecomptePeer::checkSynchroAbsenceAgregationTable(new DateTime(VENDREDI_s40j5.' 00:00:00'),new DateTime(DIMANCHE_s41j7.' 23:59:59'),10)); $this->assertFalse(AbsenceAgregationDecomptePeer::checkSynchroAbsenceAgregationTable(null, null, 0)); mysqli_query($GLOBALS["mysqli"], "update a_traitements set updated_at = now()-10 where id = ".$traitement_id); $this->assertTrue(AbsenceAgregationDecomptePeer::checkSynchroAbsenceAgregationTable(new DateTime(VENDREDI_s40j5.' 00:00:00'),new DateTime(DIMANCHE_s41j7.' 23:59:59'),0)); $this->assertTrue(AbsenceAgregationDecomptePeer::checkSynchroAbsenceAgregationTable(null, null, 0)); mysqli_query($GLOBALS["mysqli"], "update a_traitements set deleted_at = now() where id = ".$traitement_id); $this->assertFalse(AbsenceAgregationDecomptePeer::checkSynchroAbsenceAgregationTable(new DateTime(VENDREDI_s40j5.' 00:00:00'),new DateTime(DIMANCHE_s41j7.' 23:59:59'),0)); $this->assertFalse(AbsenceAgregationDecomptePeer::checkSynchroAbsenceAgregationTable(new DateTime(VENDREDI_s40j5.' 00:00:00'),new DateTime(DIMANCHE_s41j7.' 23:59:59'),10)); $this->assertFalse(AbsenceAgregationDecomptePeer::checkSynchroAbsenceAgregationTable(null, null, 0)); mysqli_query($GLOBALS["mysqli"], "update a_traitements set deleted_at = now()-10 where id = ".$traitement_id); $this->assertTrue(AbsenceAgregationDecomptePeer::checkSynchroAbsenceAgregationTable(new DateTime(VENDREDI_s40j5.' 00:00:00'),new DateTime(DIMANCHE_s41j7.' 23:59:59'),0)); $this->assertTrue(AbsenceAgregationDecomptePeer::checkSynchroAbsenceAgregationTable(null, null, 0)); $saisie_version_id = AbsenceEleveSaisieVersionQuery::create()->filterByAbsenceEleveSaisie($florence_eleve->getAbsenceEleveSaisiesDuJour(VENDREDI_s40j5)->getFirst())->findOne()->getId(); mysqli_query($GLOBALS["mysqli"], "update a_saisies_version set updated_at = now() where id = ".$saisie_version_id); $this->assertFalse(AbsenceAgregationDecomptePeer::checkSynchroAbsenceAgregationTable(new DateTime(VENDREDI_s40j5.' 00:00:00'),new DateTime(DIMANCHE_s41j7.' 23:59:59'),0)); $this->assertFalse(AbsenceAgregationDecomptePeer::checkSynchroAbsenceAgregationTable(new DateTime(VENDREDI_s40j5.' 00:00:00'),new DateTime(DIMANCHE_s41j7.' 23:59:59'),10)); $this->assertFalse(AbsenceAgregationDecomptePeer::checkSynchroAbsenceAgregationTable(null, null, 0)); mysqli_query($GLOBALS["mysqli"], "update a_saisies_version set updated_at = now()-10 where id = ".$saisie_version_id); $this->assertTrue(AbsenceAgregationDecomptePeer::checkSynchroAbsenceAgregationTable(new DateTime(VENDREDI_s40j5.' 00:00:00'),new DateTime(DIMANCHE_s41j7.' 23:59:59'),0)); $this->assertTrue(AbsenceAgregationDecomptePeer::checkSynchroAbsenceAgregationTable(null, null, 0)); mysqli_query($GLOBALS["mysqli"], "update a_saisies_version set deleted_at = now() where id = ".$saisie_version_id); $this->assertFalse(AbsenceAgregationDecomptePeer::checkSynchroAbsenceAgregationTable(new DateTime(VENDREDI_s40j5.' 00:00:00'),new DateTime(DIMANCHE_s41j7.' 23:59:59'),0)); $this->assertFalse(AbsenceAgregationDecomptePeer::checkSynchroAbsenceAgregationTable(new DateTime(VENDREDI_s40j5.' 00:00:00'),new DateTime(DIMANCHE_s41j7.' 23:59:59'),10)); $this->assertFalse(AbsenceAgregationDecomptePeer::checkSynchroAbsenceAgregationTable(null, null, 0)); mysqli_query($GLOBALS["mysqli"], "update a_saisies_version set deleted_at = now()-10 where id = ".$saisie_version_id); $this->assertTrue(AbsenceAgregationDecomptePeer::checkSynchroAbsenceAgregationTable(new DateTime(VENDREDI_s40j5.' 00:00:00'),new DateTime(DIMANCHE_s41j7.' 23:59:59'),0)); $this->assertTrue(AbsenceAgregationDecomptePeer::checkSynchroAbsenceAgregationTable(null, null, 0)); //on test sur un marqueur d'appel effectué, ça ne doit pas avoir d'incidence sur la table d'agrégation $saisie_id = AbsenceEleveSaisieQuery::create()->filterByFinAbs(DIMANCHE_s41j7.' 09:00:00')->findOne()->getId(); mysqli_query($GLOBALS["mysqli"], "update a_saisies set updated_at = now() where id = ".$saisie_id); $this->assertTrue(AbsenceAgregationDecomptePeer::checkSynchroAbsenceAgregationTable(new DateTime(VENDREDI_s40j5.' 00:00:00'),new DateTime(DIMANCHE_s41j7.' 23:59:59'),0)); $this->assertTrue(AbsenceAgregationDecomptePeer::checkSynchroAbsenceAgregationTable(new DateTime(VENDREDI_s40j5.' 00:00:00'),new DateTime(DIMANCHE_s41j7.' 23:59:59'),10)); $this->assertTrue(AbsenceAgregationDecomptePeer::checkSynchroAbsenceAgregationTable(null, null, 0)); mysqli_query($GLOBALS["mysqli"], "update a_saisies set updated_at = now()-10 where id = ".$saisie_id); $this->assertTrue(AbsenceAgregationDecomptePeer::checkSynchroAbsenceAgregationTable(new DateTime(VENDREDI_s40j5.' 00:00:00'),new DateTime(DIMANCHE_s41j7.' 23:59:59'),0)); $this->assertTrue(AbsenceAgregationDecomptePeer::checkSynchroAbsenceAgregationTable(null, null, 0)); $saisie_version_id = AbsenceEleveSaisieVersionQuery::create()->filterByAbsenceEleveSaisie(AbsenceEleveSaisieQuery::create()->filterByFinAbs(DIMANCHE_s41j7.' 09:00:00')->findOne())->findOne()->getId(); mysqli_query($GLOBALS["mysqli"], "update a_saisies_version set updated_at = now() where id = ".$saisie_version_id); $this->assertTrue(AbsenceAgregationDecomptePeer::checkSynchroAbsenceAgregationTable(new DateTime(VENDREDI_s40j5.' 00:00:00'),new DateTime(DIMANCHE_s41j7.' 23:59:59'),0)); $this->assertTrue(AbsenceAgregationDecomptePeer::checkSynchroAbsenceAgregationTable(new DateTime(VENDREDI_s40j5.' 00:00:00'),new DateTime(DIMANCHE_s41j7.' 23:59:59'),10)); $this->assertTrue(AbsenceAgregationDecomptePeer::checkSynchroAbsenceAgregationTable(null, null, 0)); mysqli_query($GLOBALS["mysqli"], "update a_saisies_version set updated_at = now()-10 where id = ".$saisie_version_id); $this->assertTrue(AbsenceAgregationDecomptePeer::checkSynchroAbsenceAgregationTable(new DateTime(VENDREDI_s40j5.' 00:00:00'),new DateTime(DIMANCHE_s41j7.' 23:59:59'),0)); $this->assertTrue(AbsenceAgregationDecomptePeer::checkSynchroAbsenceAgregationTable(null, null, 0)); $saisie = AbsenceEleveSaisieQuery::create()->filterByDebutAbs(SAMEDI_s42j6.' 08:00:00')->findOne(); $traitement = $saisie->getAbsenceEleveTraitements()->getFirst(); mysqli_query($GLOBALS["mysqli"], "update a_traitements set updated_at = now() where id = ".$traitement->getId()); $this->assertTrue(AbsenceAgregationDecomptePeer::checkSynchroAbsenceAgregationTable(new DateTime(VENDREDI_s40j5.' 00:00:00'),new DateTime(SAMEDI_s42j6.' 23:59:59'),0)); $this->assertTrue(AbsenceAgregationDecomptePeer::checkSynchroAbsenceAgregationTable(new DateTime(VENDREDI_s40j5.' 00:00:00'),new DateTime(SAMEDI_s42j6.' 23:59:59'),10)); $this->assertTrue(AbsenceAgregationDecomptePeer::checkSynchroAbsenceAgregationTable(null, null, 0)); mysqli_query($GLOBALS["mysqli"], "update a_traitements set updated_at = now()-10 where id = ".$traitement->getId()); $this->assertTrue(AbsenceAgregationDecomptePeer::checkSynchroAbsenceAgregationTable(new DateTime(VENDREDI_s40j5.' 00:00:00'),new DateTime(SAMEDI_s42j6.' 23:59:59'),0)); $this->assertTrue(AbsenceAgregationDecomptePeer::checkSynchroAbsenceAgregationTable(null, null, 0)); //on va tester le passage à l'heure d'été AbsenceAgregationDecompteQuery::create()->deleteAll(); foreach (EleveQuery::create()->find() as $eleve) { $eleve->updateAbsenceAgregationTable(new DateTime(DIMANCHE_ETE.' 00:00:00'),new DateTime(DIMANCHE_ETE.' 23:59:59')); } $this->assertTrue(AbsenceAgregationDecomptePeer::checkSynchroAbsenceAgregationTable(new DateTime(DIMANCHE_ETE.' 00:00:00'),new DateTime(DIMANCHE_ETE.' 23:59:59'), 1)); }
/** * Get the associated AbsenceEleveTraitement object * * @param PropelPDO Optional Connection object. * @return AbsenceEleveTraitement The associated AbsenceEleveTraitement object. * @throws PropelException */ public function getAbsenceEleveTraitement(PropelPDO $con = null) { if ($this->aAbsenceEleveTraitement === null && ($this->a_traitement_id !== null)) { $this->aAbsenceEleveTraitement = AbsenceEleveTraitementQuery::create()->findPk($this->a_traitement_id, $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->aAbsenceEleveTraitement->addJTraitementSaisieEleves($this); */ } return $this->aAbsenceEleveTraitement; }
/** * Code to execute before every DELETE statement * * @param PropelPDO $con The connection object used by the query */ protected function basePreDelete(PropelPDO $con) { // soft_delete behavior if (AbsenceEleveTraitementQuery::isSoftDeleteEnabled() && $this->localSoftDelete) { return $this->softDelete($con); } else { return $this->hasWhereClause() ? $this->forceDelete($con) : $this->forceDeleteAll($con); } return $this->preDelete($con); }
/** * Gets a collection of AbsenceEleveTraitement objects related by a many-to-many relationship * to the current object by way of the j_traitements_saisies cross-reference table. * * ajout d'un join pour recuperer les types en meme temps que les traitements * * If the $criteria is not null, it is used to always fetch the results from the database. * Otherwise the results are fetched from the database the first time, then cached. * Next time the same method is called without $criteria, the cached collection is returned. * If this AbsenceEleveSaisie is new, it will return * an empty collection or the current collection; the criteria is ignored on a new object. * * @param Criteria $criteria Optional query object to filter the query * @param PropelPDO $con Optional connection object * * @return PropelCollection|array AbsenceEleveTraitement[] List of AbsenceEleveTraitement objects */ public function getAbsenceEleveTraitements($criteria = null, PropelPDO $con = null) { if(null === $this->collAbsenceEleveTraitements || null !== $criteria) { if ($this->isNew() && null === $this->collAbsenceEleveTraitements) { // return empty collection $this->initAbsenceEleveTraitements(); } else { if ($this->collJTraitementSaisieEleves === null || null !== $criteria) { if (null !== $criteria) { return AbsenceEleveTraitementQuery::create(null, $criteria) ->filterByAbsenceEleveSaisie($this) ->find($con); } else { //on utilise du sql directement pour optimiser la requete //WARNING WARNING WARNING WARNING //si le modele change ca va bugger, il faut utiliser la requete AbsenceEleveTraitementQuery en dessous //le sql a ete generer en activant les logs propel et en recuperant le sql de la requete plus bas $sql = "SELECT /* comment_getAbsenceEleveTraitements */ a_traitements.ID, a_traitements.UTILISATEUR_ID, a_traitements.A_TYPE_ID, a_traitements.A_MOTIF_ID, a_traitements.A_JUSTIFICATION_ID, a_traitements.COMMENTAIRE, a_traitements.MODIFIE_PAR_UTILISATEUR_ID, a_traitements.CREATED_AT, a_traitements.UPDATED_AT, a_traitements.DELETED_AT, a_types.ID, a_types.NOM, a_types.JUSTIFICATION_EXIGIBLE, a_types.SOUS_RESPONSABILITE_ETABLISSEMENT, a_types.MANQUEMENT_OBLIGATION_PRESENCE, a_types.RETARD_BULLETIN, a_types.MODE_INTERFACE, a_types.COMMENTAIRE, a_types.ID_LIEU, a_types.SORTABLE_RANK, a_types.CREATED_AT, a_types.UPDATED_AT, a_notifications.ID, a_notifications.UTILISATEUR_ID, a_notifications.A_TRAITEMENT_ID, a_notifications.TYPE_NOTIFICATION, a_notifications.EMAIL, a_notifications.TELEPHONE, a_notifications.ADR_ID, a_notifications.COMMENTAIRE, a_notifications.STATUT_ENVOI, a_notifications.DATE_ENVOI, a_notifications.ERREUR_MESSAGE_ENVOI, a_notifications.CREATED_AT, a_notifications.UPDATED_AT, a_justifications.ID, a_justifications.NOM, a_justifications.COMMENTAIRE, a_justifications.SORTABLE_RANK, a_justifications.CREATED_AT, a_justifications.UPDATED_AT FROM `a_traitements` INNER JOIN j_traitements_saisies ON (a_traitements.ID=j_traitements_saisies.A_TRAITEMENT_ID) LEFT JOIN a_types ON (a_traitements.A_TYPE_ID=a_types.ID) LEFT JOIN a_notifications ON (a_traitements.ID=a_notifications.A_TRAITEMENT_ID) LEFT JOIN a_justifications ON (a_traitements.A_JUSTIFICATION_ID=a_justifications.ID) WHERE j_traitements_saisies.A_SAISIE_ID='".$this->getId()."' and a_traitements.DELETED_AT IS null"; $con = Propel::getConnection(AbsenceEleveTraitementPeer::DATABASE_NAME, Propel::CONNECTION_READ); $stmt = $con->prepare($sql); $stmt->execute(); $this->collAbsenceEleveTraitements = AbsenceEleveSaisie::getTraitementFormatter()->format($stmt); // Cette requete est celle faite avec l'objet query, utile si on veut récupérer le sql pour la requete manuelle ci-dessus // $this->collAbsenceEleveTraitements = AbsenceEleveTraitementQuery::create() // ->setComment('comment_getAbsenceEleveTraitements') // ->useJTraitementSaisieEleveQuery()->filterByASaisieId($this->getId())->endUse() // ->leftJoinWith('AbsenceEleveType') // ->leftJoinWith('AbsenceEleveNotification') // ->leftJoinWith('AbsenceEleveJustification') // ->find(); // DEBUG // foreach ($this->collAbsenceEleveTraitements as $traitement) { // echo $this->getId().'sql $traitement->isTypeHydrated() : '.$traitement->isTypeHydrated().'<br/>'; // echo $this->getId().'sql $traitement->isNotificationHydrated() : '.$traitement->isNotificationHydrated().'<br/>'; // echo $this->getId().'sql $traitement->isJustificationHydrated() : '.$traitement->isJustificationHydrated().'<br/>'; // } } } else { $this->collAbsenceEleveTraitements = new PropelObjectCollection(); $this->collAbsenceEleveTraitements->setModel('AbsenceEleveTraitement'); foreach ($this->collJTraitementSaisieEleves as $jTraitementSaisieEleve) { if ($jTraitementSaisieEleve->getAbsenceEleveTraitement() !== null && $jTraitementSaisieEleve->getAbsenceEleveTraitement()->getDeletedAt()==Null) { $this->collAbsenceEleveTraitements->append($jTraitementSaisieEleve->getAbsenceEleveTraitement()); } } // DEBUG // foreach ($this->collAbsenceEleveTraitements as $traitement) { // echo $this->getId().'collJ $traitement->isTypeHydrated() : '.$traitement->isTypeHydrated().'<br/>'; // echo $this->getId().'collJ $traitement->isNotificationHydrated() : '.$traitement->isNotificationHydrated().'<br/>'; // echo $this->getId().'collJ $traitement->isJustificationHydrated() : '.$traitement->isJustificationHydrated().'<br/>'; // } } } } return $this->collAbsenceEleveTraitements; }