export astreintes actives et exports
This commit is contained in:
@@ -204,6 +204,41 @@ class TimerController extends AbstractController
|
||||
return $this->redirectToRoute($this->route);
|
||||
}
|
||||
}
|
||||
|
||||
public function export(Request $request,$access=null): Response
|
||||
{
|
||||
|
||||
$em = $this->getDoctrine()->getManager();
|
||||
|
||||
$iduser = $this->get("session")->get("iduser");
|
||||
$user = $em->getRepository("App:User")->find($iduser);
|
||||
$tasks = $em->getRepository("App:Task")->findAll();
|
||||
$timers = $em->getRepository("App:Timer")->findBy(["user"=>$iduser]);
|
||||
$tbtimers = [];
|
||||
foreach ($timers as $timer) {
|
||||
$isactive = $timer->getActivePenalty();
|
||||
if ($isactive) {
|
||||
$tbtimer["id"] = $timer->getId();
|
||||
$tbtimer["taskname"] = $timer->getTask()->getDisplayname();
|
||||
$tbtimer["user"] = $timer->getUser()->getUsername();
|
||||
$tbtimer["start"] = $timer->getId();
|
||||
$tbtimer["end"] = $timer->getId();
|
||||
$tbtimer["duration"] = $timer->getDuration();
|
||||
$tbtimer["activepenalty"] = $timer->getActivePenalty();
|
||||
$tbtimer["description"] = $timer->getDescription();
|
||||
array_push($tbtimers, $tbtimer);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
$csv = $this->renderView('Timer/export.csv.twig', ["timers" => $tbtimers]);
|
||||
$response = new Response($csv);
|
||||
$response->headers->set('Content-Type', 'text/csv; charset=utf-8');
|
||||
$response->headers->set('Content-Disposition', 'attachment; filename="export.csv"');
|
||||
|
||||
return $response;
|
||||
}
|
||||
|
||||
protected function getErrorForm($id,$form,$request,$data,$mode) {
|
||||
if ($form->get('submit')->isClicked()&&$mode=="delete") {
|
||||
}
|
||||
|
@@ -55,6 +55,12 @@ class Timer
|
||||
*/
|
||||
private $task;
|
||||
|
||||
/**
|
||||
* @ORM\Column(name="activepenalty", type="boolean")
|
||||
*
|
||||
*/
|
||||
private $activepenalty;
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
$this->start = new \DateTime();
|
||||
@@ -139,4 +145,16 @@ class Timer
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function getActivePenalty(): ?bool
|
||||
{
|
||||
return $this->activepenalty;
|
||||
}
|
||||
|
||||
public function setActivePenalty(bool $activepenalty): self
|
||||
{
|
||||
$this->activepenalty = $activepenalty;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
}
|
||||
|
@@ -59,6 +59,13 @@ class TimerType extends AbstractType
|
||||
]
|
||||
);
|
||||
|
||||
$builder->add("activepenalty",
|
||||
ChoiceType::class,[
|
||||
"label" => "Astreinte active",
|
||||
"choices" => ["Non"=>false, "Oui"=>true]
|
||||
]
|
||||
);
|
||||
|
||||
$builder->add('start',
|
||||
DateTimeType::class, [
|
||||
"label" =>"Début",
|
||||
|
Reference in New Issue
Block a user