Compare commits

..

No commits in common. "5416f122d51624f49889801db7d46c3b5a4d78d2" and "e180def44b250a551d3ba25c318f5ad724a43922" have entirely different histories.

3 changed files with 29 additions and 22 deletions

View File

@ -935,17 +935,17 @@ class TallydayController extends AbstractController
$f->add($interval); $f->add($interval);
$f->sub(new \DateInterval('PT7H')); $f->sub(new \DateInterval('PT7H'));
$f->add($capital); $f->add($capital);
$interval = $e->diff($f);
$newcapital = $interval->format("%R").(($interval->days*24) + $interval->h).":".sprintf("%02s",$interval->i);
} }
// Si la journée n'est pas encore validé : on ajoute la journée à la simulation // Si la journée n'est pas encore validé : on ajoute la journée à la simulation
else if($data && (!$data->getValidateuser()||!$data->getValidateuser())) { else if($data && (!$data->getValidateuser()||!$data->getValidateuser())) {
$interval=$em->getRepository("App:Tallyday")->getCapitaltimeinterval($this->getUser(),true); $f = new \DateTime('00:00');
$newcapital = $interval->format("%R").(($interval->days*24) + $interval->h).":".sprintf("%02s",$interval->i); $f->add($interval);
$f->sub(new \DateInterval('PT7H'));
$f->add($capital);
} }
$interval = $e->diff($f);
$newcapital = $interval->format("%R").(($interval->days*24) + $interval->h).":".sprintf("%02s",$interval->i);
return new JsonResponse([ return new JsonResponse([
'success' => true, 'success' => true,

View File

@ -69,7 +69,7 @@ class Tallyday
$f = clone $e; $f = clone $e;
if($this->datestart && $this->dateend) if($this->datestart && $this->dateend)
$e->add(date_diff($this->datestart, $this->dateend)); $e->add(date_diff($this->dateend, $this->datestart));
return $f->diff($e); return $f->diff($e);

View File

@ -51,36 +51,43 @@ class TallydayRepository extends ServiceEntityRepository
return $datas; return $datas;
} }
public function getCapitaltimeinterval($user,$getnovalidate=false) { public function getCapitaltimeinterval($user) {
$datenow=new \DateTime('00:00'); $datenow=new \DateTime('00:00');
$datas = $this->_em->getRepository('App:Tallyday')->findBy(["user"=>$user],["datestart"=>"DESC"]); $datas = $this->_em->getRepository('App:Tallyday')->findBy(["user"=>$user],["datestart"=>"DESC"]);
$tbdays=[]; $tbweek=[];
$ework = new \DateTime('00:00'); $ework = new \DateTime('00:00');
$idweeknow=$datenow->format("Y").$datenow->format("W");
$lastdayvalidate=false;
foreach($datas as $data) { foreach($datas as $data) {
if($data->getDateof()<$datenow) { if($data->getDateof()<$datenow) {
$iddayweek=$data->getDateof()->format("w"); $idweek=$data->getDateof()->format("Y").$data->getDateof()->format("W");
if($iddayweek>=1&&$iddayweek<=5) { if(!in_array($idweek,$tbweek)&&$idweek!=$idweeknow) array_push($tbweek,$idweek);
if(!in_array($data->getDateof(),$tbdays)) array_push($tbdays,$data->getDateof());
}
$ework->add($data->getTimeday()); $ework->add($data->getTimeday());
} }
if($data->getDateof()==$datenow&&($getnovalidate||$data->getValidateuser()||$data->getValidatemaster())) { if($data->getDateof()==$datenow&&($data->getValidateuser()||$data->getValidatemaster())) {
$iddayweek=$data->getDateof()->format("w"); $lastdayvalidate=true;
if($iddayweek>=1&&$iddayweek<=5) { $idweek=$data->getDateof()->format("Y").$data->getDateof()->format("W");
if(!in_array($data->getDateof(),$tbdays)) array_push($tbdays,$data->getDateof()); if(!in_array($idweek,$tbweek)&&$idweek!=$idweeknow) array_push($tbweek,$idweek);
}
$ework->add($data->getTimeday()); $ework->add($data->getTimeday());
} }
} }
// Nbday worked // Nbday worked
$nbdaywork=count($tbdays); $nbdaywork=count($tbweek)*5;
if($datenow->format("w")==6||$datenow->format("w")==7)
$nbdaywork+=5;
else {
$nbdaywork+=$datenow->format("w");
if(!$lastdayvalidate) $nbdaywork--;
}
if($nbdaywork<0) $nbdaywork=0;
$etowork = new \DateTime('00:00'); $etowork = new \DateTime('00:00');
$etowork->add(new \DateInterval("PT".($nbdaywork*7)."H")); $etowork->sub(new \DateInterval("PT".($nbdaywork*7)."H"));
$interval = $etowork->diff($ework); $interval = $ework->diff($etowork);
return $interval; return $interval;
} }