export astreintes actives et exports
This commit is contained in:
@@ -376,6 +376,10 @@ app_timer_delete:
|
||||
path: /timer/delete/{id}
|
||||
defaults: { _controller: App\Controller\TimerController:delete }
|
||||
|
||||
app_timer_export_activepenalty:
|
||||
path: /timer/export
|
||||
defaults: { _controller: App\Controller\TimerController:export }
|
||||
|
||||
#== Customer ======================================================================================================
|
||||
app_customer_report:
|
||||
path: /customer/report/{key}
|
||||
|
@@ -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",
|
||||
|
@@ -58,6 +58,7 @@
|
||||
<div class="card-body">
|
||||
{{ form_row(form.task) }}
|
||||
{{ form_row(form.description) }}
|
||||
{{ form_row(form.activepenalty) }}
|
||||
{{ form_row(form.start) }}
|
||||
{{ form_row(form.end) }}
|
||||
{{ form_row(form.duration) }}
|
||||
|
7
src/schedule-2.0/templates/Timer/export.csv.twig
Normal file
7
src/schedule-2.0/templates/Timer/export.csv.twig
Normal file
@@ -0,0 +1,7 @@
|
||||
{% block body %}
|
||||
Astreintes Actives
|
||||
Tâche;Active;Utilisateur;Début;Fin;Durée;Description;
|
||||
{% for timer in timers %}
|
||||
{{timer.taskname}};{{timer.activepenalty}};{{timer.user}};{{timer.start|date("d/m/Y H:i")}};{{timer.end|date("d/m/Y H:i")}};{{timer.duration|date("H:i")}};{{timer.description}};
|
||||
{% endfor %}
|
||||
{% endblock %}
|
@@ -16,7 +16,7 @@ SUIVI HORAIRE
|
||||
<div id="timer" class="card">
|
||||
|
||||
<div class="card-header">
|
||||
<a class="btn btn-success" style="float:right" href={{ path('app_timer_view') }}>Voir le calendrier</a>
|
||||
<a class="btn btn-success" style="float:right" href={{ path('app_timer_submit') }}>Créer un Timer</a>
|
||||
Lancer un Timer :
|
||||
<select class="select2entity" id="timer-task" name="timer-task">
|
||||
<option> Tâche </option>
|
||||
@@ -36,7 +36,8 @@ SUIVI HORAIRE
|
||||
</table>
|
||||
</div>
|
||||
|
||||
<a class="btn btn-success" href={{ path('app_timer_submit') }}>Créer un Timer</a>
|
||||
<a class="btn btn-success" href={{ path('app_timer_view') }}>Voir le calendrier</a>
|
||||
<a class="btn btn-success" href={{ path('app_timer_view') }}>Exporter Astreintes actives</a>
|
||||
<p></p>
|
||||
<div class="dataTable_wrapper">
|
||||
<table class="table table-striped table-bordered table-hover small" id="dataTables" style="width:100%">
|
||||
@@ -54,7 +55,10 @@ SUIVI HORAIRE
|
||||
{%for timer in timers %}
|
||||
<tr>
|
||||
<td>{{ timer.task.displayname }}</td>
|
||||
<td>{{ timer.description }}</td>
|
||||
<td>
|
||||
<span class="font-weight-bold">{{ timer.activepenalty ? "Astreinte active" : "" }}</span>
|
||||
<p>{{ timer.description }}</p>
|
||||
</td>
|
||||
<td>{{ timer.start|date("d/m/Y H:i") }}</td>
|
||||
<td>{{ timer.end|date("d/m/Y H:i") }}</td>
|
||||
<td>{{ timer.duration|date("H:i") }}</td>
|
||||
|
Reference in New Issue
Block a user