From 28dea4bb818ff8e65ae308da7efd37dc847f4ee6 Mon Sep 17 00:00:00 2001 From: afornerot Date: Thu, 22 Sep 2022 10:35:57 +0200 Subject: [PATCH] correction fuseau & affichage rapport mensuel --- .../src/Repository/TallydayRepository.php | 32 +++++++++++++------ .../templates/Tallyday/month.html.twig | 11 ++++--- 2 files changed, 29 insertions(+), 14 deletions(-) diff --git a/src/ninebadge-1.0/src/Repository/TallydayRepository.php b/src/ninebadge-1.0/src/Repository/TallydayRepository.php index 3c99723..6d46a04 100644 --- a/src/ninebadge-1.0/src/Repository/TallydayRepository.php +++ b/src/ninebadge-1.0/src/Repository/TallydayRepository.php @@ -65,29 +65,42 @@ class TallydayRepository extends ServiceEntityRepository } public function getCapitaltimeinterval($user,$getnovalidate=false) { - $datenow=new \DateTime('00:00'); + + // Calculer les jours travaillés sur la base du fuseau Paris + date_default_timezone_set("Europe/Paris"); $datas = $this->_em->getRepository('App:Tallyday')->findBy(["user"=>$user],["datestart"=>"DESC"]); $tbdays=[]; - $ework = new \DateTime('00:00'); - + $datenow=new \DateTime('00:00'); foreach($datas as $data) { if($data->getDateof()<$datenow) { $iddayweek=$data->getDateof()->format("w"); if($iddayweek>=1&&$iddayweek<=5) { if(!in_array($data->getDateof(),$tbdays)) array_push($tbdays,$data->getDateof()); } + if($data->getDateof()==$datenow&&($getnovalidate||$data->getValidateuser()||$data->getValidatemaster())) { + $iddayweek=$data->getDateof()->format("w"); + if($iddayweek>=1&&$iddayweek<=5) { + if(!in_array($data->getDateof(),$tbdays)) array_push($tbdays,$data->getDateof()); + } + } + } + } + + + // Cumuler les temps de travail sans fuseau + date_default_timezone_set("UTC"); + $datenow=new \DateTime('00:00'); + $ework = clone $datenow; + foreach($datas as $data) { + if($data->getDateof()<$datenow) { $ework->add($data->getTimeday()); } if($data->getDateof()==$datenow&&($getnovalidate||$data->getValidateuser()||$data->getValidatemaster())) { - $iddayweek=$data->getDateof()->format("w"); - if($iddayweek>=1&&$iddayweek<=5) { - if(!in_array($data->getDateof(),$tbdays)) array_push($tbdays,$data->getDateof()); - } $ework->add($data->getTimeday()); } } - + // Enlever du temps travailler les heures sup payé $timeextra=$this->_em->getRepository("App:Timeextra")->getTimeextrauser($user, new \DateTime()); if($timeextra[1]) { @@ -96,11 +109,12 @@ class TallydayRepository extends ServiceEntityRepository // Nbday worked $nbdaywork=count($tbdays); - $etowork = new \DateTime('00:00'); + $etowork = clone $datenow; $etowork->add(new \DateInterval("PT".($nbdaywork*7)."H")); $interval = $etowork->diff($ework); + date_default_timezone_set("Europe/Paris"); return $interval; } diff --git a/src/ninebadge-1.0/templates/Tallyday/month.html.twig b/src/ninebadge-1.0/templates/Tallyday/month.html.twig index ce7add6..5fcd45f 100644 --- a/src/ninebadge-1.0/templates/Tallyday/month.html.twig +++ b/src/ninebadge-1.0/templates/Tallyday/month.html.twig @@ -104,13 +104,14 @@ td { {{validate.dateof|date("W")}} - {% if loop.first %} - {% for i in 2..(validate.dateof|date("N")) %} - - {% endfor %} - {%endif %} {% endif %} + {% if loop.first and validate.dateof|date("l")!="Monday"%} + {% for i in 2..(validate.dateof|date("N")) %} + + {% endfor %} + {%endif %} +
{{validate.dateof|date("d/m")}}