ne pas importer de breakday les weekend (fixes #7)

This commit is contained in:
afornerot 2022-05-16 14:53:47 +02:00
parent 3759996f19
commit 4ec5dceb14
1 changed files with 122 additions and 120 deletions

View File

@ -97,140 +97,45 @@ class BreakdayCommand extends Command
if($response&&$response->code=="200") {
while($start<=$end) {
$havebreakday=false;
foreach($response->body->events as $event) {
if($event->eventallday) {
$manip=clone $start;
$manip->setTime(8,0);
if(new \Datetime($event->eventstart)<=$manip && $manip < new \Datetime($event->eventend) ) {
$this->writeln($start->format("d/m/Y")." >> tallybreakday full day");
// On s'assure que la journée n'a pas été validé master
$tallyday=$this->em->getRepository("App:Tallyday")->findOneBy(["user"=>$user,"dateof"=>$start,"validatemaster"=>true]);
if(!$tallyday) {
// Les pointages de la journée qui ne sont des congès sont supprimés
$tallydays=$this->em->getRepository("App:Tallyday")->findBy(["user"=>$user,"dateof"=>$start,"isbreakday"=>false]);
foreach($tallydays as $tallyday) {
$this->em->remove($tallyday);
$this->em->flush();
}
// Les breakday am sont supprimés
$manip=clone $start;
$manip->setTime(8,30);
$tallydays=$this->em->getRepository("App:Tallyday")->findBy(["user"=>$user,"dateof"=>$start,"datestart"=>$manip,"isbreakday"=>true]);
foreach($tallydays as $tallyday) {
$this->em->remove($tallyday);
$this->em->flush();
}
// Les breakday pm sont supprimés
$manip=clone $start;
$manip->setTime(13,30);
$tallydays=$this->em->getRepository("App:Tallyday")->findBy(["user"=>$user,"dateof"=>$start,"datestart"=>$manip,"isbreakday"=>true]);
foreach($tallydays as $tallyday) {
$this->em->remove($tallyday);
$this->em->flush();
}
// Le breakday est généré s'il n'existe pas
$manip=clone $start;
$manip->setTime(10,00);
$tallyday=$this->em->getRepository("App:Tallyday")->findOneBy(["user"=>$user,"dateof"=>$start,"datestart"=>$manip,"isbreakday"=>true]);
if(!$tallyday) {
$data = new Tallyday();
$data->setDateof($start);
$data->setUser($user);
$data->setValidateuser(false);
$data->setValidatemaster(false);
$data->setIsbreakday(true);
$data->setName($event->taskname);
$data->setDatestart(clone $manip);
$manip->add(new \DateInterval("PT7H"));
$data->setDateend(clone $manip);
$this->em->persist($data);
$this->em->flush();
}
$havebreakday=true;
}
}
}
else {
$manip=clone $start;
$manip->setTime(10,0);
if(new \Datetime($event->eventstart)<=$manip && $manip < new \Datetime($event->eventend) ) {
$this->writeln($start->format("d/m/Y")." >> tallybreakday AM");
// On s'assure que la journée n'a pas été validé master
$tallyday=$this->em->getRepository("App:Tallyday")->findOneBy(["user"=>$user,"dateof"=>$start,"validatemaster"=>true]);
if(!$tallyday) {
// Les pointages du matin qui ne sont des congès sont supprimés
$tallydays=$this->em->getRepository("App:Tallyday")->findAM($user,$start,false);
foreach($tallydays as $tallyday) {
$this->em->remove($tallyday);
$this->em->flush();
}
// Les breakday fullday sont supprimés
$manip=clone $start;
$manip->setTime(10,0);
$tallydays=$this->em->getRepository("App:Tallyday")->findBy(["user"=>$user,"dateof"=>$start,"datestart"=>$manip,"isbreakday"=>true]);
foreach($tallydays as $tallyday) {
$this->em->remove($tallyday);
$this->em->flush();
}
// Le breakday est généré s'il n'existe pas
$manip=clone $start;
$manip->setTime(8,30);
$tallyday=$this->em->getRepository("App:Tallyday")->findOneBy(["user"=>$user,"dateof"=>$start,"datestart"=>$manip,"isbreakday"=>true]);
if(!$tallyday) {
$data = new Tallyday();
$data->setDateof($start);
$data->setUser($user);
$data->setValidateuser(false);
$data->setValidatemaster(false);
$data->setIsbreakday(true);
$data->setName("AM = ".$event->taskname);
$data->setDatestart(clone $manip);
$manip->add(new \DateInterval("PT3H"));
$manip->add(new \DateInterval("PT30M"));
$data->setDateend(clone $manip);
$this->em->persist($data);
$this->em->flush();
}
$havebreakday=true;
}
}
else {
if($start->format("w")!=0&&$start->format("w")!=6) {
foreach($response->body->events as $event) {
if($event->eventallday) {
$manip=clone $start;
$manip->setTime(15,0);
$manip->setTime(8,0);
if(new \Datetime($event->eventstart)<=$manip && $manip < new \Datetime($event->eventend) ) {
$this->writeln($start->format("d/m/Y")." >> tallybreakday PM");
$this->writeln($start->format("d/m/Y")." >> tallybreakday full day");
// On s'assure que la journée n'a pas été validé master
$tallyday=$this->em->getRepository("App:Tallyday")->findOneBy(["user"=>$user,"dateof"=>$start,"validatemaster"=>true]);
if(!$tallyday) {
// Les pointages de l'aprés midi qui ne sont des congès sont supprimés
$tallydays=$this->em->getRepository("App:Tallyday")->findPM($user,$start,false);
// Les pointages de la journée qui ne sont des congès sont supprimés
$tallydays=$this->em->getRepository("App:Tallyday")->findBy(["user"=>$user,"dateof"=>$start,"isbreakday"=>false]);
foreach($tallydays as $tallyday) {
$this->em->remove($tallyday);
$this->em->flush();
}
// Les breakday fullday sont supprimés
// Les breakday am sont supprimés
$manip=clone $start;
$manip->setTime(10,0);
$manip->setTime(8,30);
$tallydays=$this->em->getRepository("App:Tallyday")->findBy(["user"=>$user,"dateof"=>$start,"datestart"=>$manip,"isbreakday"=>true]);
foreach($tallydays as $tallyday) {
$this->em->remove($tallyday);
$this->em->flush();
}
// Le breakday est généré s'il n'existe pas
// Les breakday pm sont supprimés
$manip=clone $start;
$manip->setTime(13,30);
$tallydays=$this->em->getRepository("App:Tallyday")->findBy(["user"=>$user,"dateof"=>$start,"datestart"=>$manip,"isbreakday"=>true]);
foreach($tallydays as $tallyday) {
$this->em->remove($tallyday);
$this->em->flush();
}
// Le breakday est généré s'il n'existe pas
$manip=clone $start;
$manip->setTime(10,00);
$tallyday=$this->em->getRepository("App:Tallyday")->findOneBy(["user"=>$user,"dateof"=>$start,"datestart"=>$manip,"isbreakday"=>true]);
if(!$tallyday) {
$data = new Tallyday();
@ -239,7 +144,55 @@ class BreakdayCommand extends Command
$data->setValidateuser(false);
$data->setValidatemaster(false);
$data->setIsbreakday(true);
$data->setName("PM = ".$event->taskname);
$data->setName($event->taskname);
$data->setDatestart(clone $manip);
$manip->add(new \DateInterval("PT7H"));
$data->setDateend(clone $manip);
$this->em->persist($data);
$this->em->flush();
}
$havebreakday=true;
}
}
}
else {
$manip=clone $start;
$manip->setTime(10,0);
if(new \Datetime($event->eventstart)<=$manip && $manip < new \Datetime($event->eventend) ) {
$this->writeln($start->format("d/m/Y")." >> tallybreakday AM");
// On s'assure que la journée n'a pas été validé master
$tallyday=$this->em->getRepository("App:Tallyday")->findOneBy(["user"=>$user,"dateof"=>$start,"validatemaster"=>true]);
if(!$tallyday) {
// Les pointages du matin qui ne sont des congès sont supprimés
$tallydays=$this->em->getRepository("App:Tallyday")->findAM($user,$start,false);
foreach($tallydays as $tallyday) {
$this->em->remove($tallyday);
$this->em->flush();
}
// Les breakday fullday sont supprimés
$manip=clone $start;
$manip->setTime(10,0);
$tallydays=$this->em->getRepository("App:Tallyday")->findBy(["user"=>$user,"dateof"=>$start,"datestart"=>$manip,"isbreakday"=>true]);
foreach($tallydays as $tallyday) {
$this->em->remove($tallyday);
$this->em->flush();
}
// Le breakday est généré s'il n'existe pas
$manip=clone $start;
$manip->setTime(8,30);
$tallyday=$this->em->getRepository("App:Tallyday")->findOneBy(["user"=>$user,"dateof"=>$start,"datestart"=>$manip,"isbreakday"=>true]);
if(!$tallyday) {
$data = new Tallyday();
$data->setDateof($start);
$data->setUser($user);
$data->setValidateuser(false);
$data->setValidatemaster(false);
$data->setIsbreakday(true);
$data->setName("AM = ".$event->taskname);
$data->setDatestart(clone $manip);
$manip->add(new \DateInterval("PT3H"));
@ -248,10 +201,59 @@ class BreakdayCommand extends Command
$this->em->persist($data);
$this->em->flush();
}
$havebreakday=true;
}
}
}
else {
$manip=clone $start;
$manip->setTime(15,0);
if(new \Datetime($event->eventstart)<=$manip && $manip < new \Datetime($event->eventend) ) {
$this->writeln($start->format("d/m/Y")." >> tallybreakday PM");
// On s'assure que la journée n'a pas été validé master
$tallyday=$this->em->getRepository("App:Tallyday")->findOneBy(["user"=>$user,"dateof"=>$start,"validatemaster"=>true]);
if(!$tallyday) {
// Les pointages de l'aprés midi qui ne sont des congès sont supprimés
$tallydays=$this->em->getRepository("App:Tallyday")->findPM($user,$start,false);
foreach($tallydays as $tallyday) {
$this->em->remove($tallyday);
$this->em->flush();
}
// Les breakday fullday sont supprimés
$manip=clone $start;
$manip->setTime(10,0);
$tallydays=$this->em->getRepository("App:Tallyday")->findBy(["user"=>$user,"dateof"=>$start,"datestart"=>$manip,"isbreakday"=>true]);
foreach($tallydays as $tallyday) {
$this->em->remove($tallyday);
$this->em->flush();
}
// Le breakday est généré s'il n'existe pas
$manip=clone $start;
$manip->setTime(13,30);
$tallyday=$this->em->getRepository("App:Tallyday")->findOneBy(["user"=>$user,"dateof"=>$start,"datestart"=>$manip,"isbreakday"=>true]);
if(!$tallyday) {
$data = new Tallyday();
$data->setDateof($start);
$data->setUser($user);
$data->setValidateuser(false);
$data->setValidatemaster(false);
$data->setIsbreakday(true);
$data->setName("PM = ".$event->taskname);
$data->setDatestart(clone $manip);
$manip->add(new \DateInterval("PT3H"));
$manip->add(new \DateInterval("PT30M"));
$data->setDateend(clone $manip);
$this->em->persist($data);
$this->em->flush();
}
$havebreakday=true;
}
}
}
}
}
}