correction synchro breakday
This commit is contained in:
parent
eabb7067a7
commit
50188f1851
|
@ -91,12 +91,28 @@ class BreakdayCommand extends Command
|
||||||
$end->modify("last day of this month");
|
$end->modify("last day of this month");
|
||||||
$end->modify("next sunday");
|
$end->modify("next sunday");
|
||||||
|
|
||||||
$response=$this->api("POST",$url."/getBreakdays",json_encode(["key"=>$key,"username"=>$user->getUsername()]));
|
// On récupère la première journée de pointage de l'utilisateur
|
||||||
|
$qb = $this->em->createQueryBuilder()
|
||||||
|
->select('tallyday')
|
||||||
|
->from('App:Tallyday','tallyday')
|
||||||
|
->Where('tallyday.user=:user')
|
||||||
|
->setParameter('user',$user)
|
||||||
|
->orderBy('tallyday.dateof', 'ASC')
|
||||||
|
->setMaxResults(1);
|
||||||
|
|
||||||
|
$datas = $qb->getQuery()->getResult();
|
||||||
|
if(empty($datas)) continue;
|
||||||
|
$firstday=$datas[0]->getDateof();
|
||||||
|
$this->writeln("FIRST DAY = ".$firstday->format("d/m/Y"));
|
||||||
|
|
||||||
|
$response=$this->api("POST",$url."/getBreakdays",json_encode(["key"=>$key,"username"=>$user->getUsername()]));
|
||||||
if($response&&$response->code=="200") {
|
if($response&&$response->code=="200") {
|
||||||
while($start<=$end) {
|
while($start<=$end) {
|
||||||
$havebreakday=false;
|
$havebreakday=false;
|
||||||
if($start->format("w")!=0&&$start->format("w")!=6) {
|
$havebreakdayAM=false;
|
||||||
|
$havebreakdayPM=false;
|
||||||
|
|
||||||
|
if($start->format("w")!=0&&$start->format("w")!=6&&$start>=$firstday) {
|
||||||
foreach($response->body->events as $event) {
|
foreach($response->body->events as $event) {
|
||||||
if($event->eventallday) {
|
if($event->eventallday) {
|
||||||
$manip=clone $start;
|
$manip=clone $start;
|
||||||
|
@ -208,6 +224,7 @@ class BreakdayCommand extends Command
|
||||||
}
|
}
|
||||||
|
|
||||||
$havebreakday=true;
|
$havebreakday=true;
|
||||||
|
$havebreakdayAM=true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
|
@ -259,6 +276,7 @@ class BreakdayCommand extends Command
|
||||||
}
|
}
|
||||||
|
|
||||||
$havebreakday=true;
|
$havebreakday=true;
|
||||||
|
$havebreakdayPM=true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -274,6 +292,31 @@ class BreakdayCommand extends Command
|
||||||
$this->em->flush();
|
$this->em->flush();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
else {
|
||||||
|
// Si congés matin mais par l'après midi on supprime un congés potentiel de l'aprés midi
|
||||||
|
if($havebreakdayAM && !$havebreakdayPM) {
|
||||||
|
$manip=clone $start;
|
||||||
|
$manip->setTime(13,30);
|
||||||
|
$tallydays=$this->em->getRepository("App:Tallyday")->findBy(["user"=>$user,"dateof"=>$start,"datestart"=>$manip,"validatemaster"=>false,"isbreakday"=>true]);
|
||||||
|
foreach($tallydays as $tallyday) {
|
||||||
|
$this->em->remove($tallyday);
|
||||||
|
$this->em->flush();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Si congés aprèsmidi mais pas le matin on supprime un congés potentiel du matin
|
||||||
|
if(!$havebreakdayAM && $havebreakdayPM) {
|
||||||
|
$manip=clone $start;
|
||||||
|
$manip->setTime(8,30);
|
||||||
|
$tallydays=$this->em->getRepository("App:Tallyday")->findBy(["user"=>$user,"dateof"=>$start,"datestart"=>$manip,"validatemaster"=>false,"isbreakday"=>true]);
|
||||||
|
foreach($tallydays as $tallyday) {
|
||||||
|
|
||||||
|
$this->em->remove($tallyday);
|
||||||
|
$this->em->flush();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
$start->add(new \DateInterval('P1D'));
|
$start->add(new \DateInterval('P1D'));
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue