correction fuseau & affichage rapport mensuel
This commit is contained in:
parent
2878f31113
commit
ed91a16b2b
|
@ -137,6 +137,8 @@ class TallydayController extends AbstractController
|
|||
$users = $em->getRepository("App:User")->findBy([],["firstname"=>"ASC","lastname"=>"ASC"]);
|
||||
foreach($users as $user) {
|
||||
if($user->hasRole("ROLE_USER")) {
|
||||
|
||||
|
||||
$dates[$user->getId()] = [
|
||||
"id"=>$user->getId(),
|
||||
"avatar"=>$user->getAvatar(),
|
||||
|
|
|
@ -65,38 +65,29 @@ class TallydayRepository extends ServiceEntityRepository
|
|||
}
|
||||
|
||||
public function getCapitaltimeinterval($user,$getnovalidate=false) {
|
||||
|
||||
// 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=[];
|
||||
$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;
|
||||
$ework = new \DateTime('00:00', new \DateTimeZone('UTC'));
|
||||
$i=0;
|
||||
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());
|
||||
}
|
||||
|
||||
$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());
|
||||
}
|
||||
}
|
||||
|
@ -109,12 +100,12 @@ class TallydayRepository extends ServiceEntityRepository
|
|||
|
||||
// Nbday worked
|
||||
$nbdaywork=count($tbdays);
|
||||
$etowork = clone $datenow;
|
||||
|
||||
$etowork = new \DateTime('00:00', new \DateTimeZone('UTC'));
|
||||
$etowork->add(new \DateInterval("PT".($nbdaywork*7)."H"));
|
||||
|
||||
$interval = $etowork->diff($ework);
|
||||
|
||||
date_default_timezone_set("Europe/Paris");
|
||||
return $interval;
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue