diff --git a/src/schedule-2.0/config/routes.yaml b/src/schedule-2.0/config/routes.yaml index 8418d61..eb0afd7 100644 --- a/src/schedule-2.0/config/routes.yaml +++ b/src/schedule-2.0/config/routes.yaml @@ -347,6 +347,23 @@ app_validationholiday_activeholiday: path: /validator/validateholiday/activeholiday defaults: { _controller: App\Controller\ValidationController:activeholiday } +#== Validationtimer ==================================================================================================== +app_validationtimer: + path: /validator/validationtimer + defaults: { _controller: App\Controller\ValidationController:validationtimer } + +app_validationtimer_validate: + path: /validator/validatetimer + defaults: { _controller: App\Controller\ValidationController:validatetimer } + +app_validationtimer_devalidate: + path: /validator/devalidatetimer + defaults: { _controller: App\Controller\ValidationController:devalidatetimer } + +app_validationtimer_activetimer: + path: /validator/validateholiday/activetimer + defaults: { _controller: App\Controller\ValidationController:activetimer } + #== Timer ==================================================================================================== app_timer: path: /timer diff --git a/src/schedule-2.0/src/Controller/TimerController.php b/src/schedule-2.0/src/Controller/TimerController.php index a0f52d2..c9391d2 100644 --- a/src/schedule-2.0/src/Controller/TimerController.php +++ b/src/schedule-2.0/src/Controller/TimerController.php @@ -217,7 +217,8 @@ class TimerController extends AbstractController $tbtimers = []; foreach ($timers as $timer) { $isactive = $timer->getActivePenalty(); - if ($isactive) { + $isadditional = $timer->getAdditionalHour(); + if ($isactive || $isadditional) { $tbtimer["id"] = $timer->getId(); $tbtimer["taskname"] = $timer->getTask()->getDisplayname(); $tbtimer["user"] = $timer->getUser()->getUsername(); @@ -225,6 +226,7 @@ class TimerController extends AbstractController $tbtimer["end"] = $timer->getId(); $tbtimer["duration"] = $timer->getDuration(); $tbtimer["activepenalty"] = $timer->getActivePenalty(); + $tbtimer["additionalhour"] = $timer->getAdditionalHour(); $tbtimer["description"] = $timer->getDescription(); array_push($tbtimers, $tbtimer); } diff --git a/src/schedule-2.0/src/Controller/ValidationController.php b/src/schedule-2.0/src/Controller/ValidationController.php index f8cc772..ebac3f1 100755 --- a/src/schedule-2.0/src/Controller/ValidationController.php +++ b/src/schedule-2.0/src/Controller/ValidationController.php @@ -548,6 +548,138 @@ class ValidationController extends AbstractController $this->get('session')->set('activeholiday',!$this->get('session')->get('activeholiday')); return $this->redirectToRoute("app_validationholiday"); - } + } + + public function validationtimer(Request $request) + { + $em = $this->getDoctrine()->getManager(); + + $iduser=$this->get("session")->get("iduser"); + if($iduser=="all") { + $users=$em->getRepository("App:User")->findAll(); + } + else { + $users=$em->getRepository("App:User")->findBy(["id"=>$iduser]); + } + + $tbtimers=[]; + foreach($users as $user) { + if(in_array("ROLE_USER",$user->getRoles())) { + // Filtre par Service + if($this->get('session')->get('idservice')!="all") { + if($user->getService()->getId()!=$this->get('session')->get('idservice')) + continue; + } + + $tmp=[ + "id" => $user->getId(), + "user" => $user, + "timers" => [], + "timerstodevalidate" => [], + ]; + + // Timers à valider ou à dévalider + $timers = $em + ->createQueryBuilder('timer') + ->select('timer') + ->from('App:Timer','timer') + ->from('App:Task','task') + ->Where('timer.user=:user') + ->andWhere('timer.validate=:validate') + ->andWhere('task=timer.task') + ->setParameter('user',$user->getId()) + ->setParameter('validate',!($this->get("session")->get("activetimer"))) + ->getQuery()->getResult(); + foreach($timers as $timer) { + + $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["additionalhour"] = $timer->getAdditionalHour(); + $tbtimer["description"] = $timer->getDescription(); + + $tbtimer = [ + "id"=>$timer->getId(), + "taskname"=>$timer->getTask()->getDisplayname(), + "user"=>$timer->getUser()->getUsername(), + "start"=>$timer->getId(), + "end"=>$timer->getId(), + "duration"=>$timer->getDuration(), + "activepenalty"=>$timer->getActivePenalty(), + "additionalhour"=>$timer->getAdditionalHour(), + "description"=>$timer->getDescription(), + "validate"=>$timer->getValidate(), + ]; + + array_push($tmp["timers"],$tbtimer); + } + array_push($tbtimers,$tmp); + } + } + if($request->query->get('fgprint')) { + $render = $this->renderView('Validation/validationtimer.html.twig',[ + "useheader" => true, + "usesidebar" => ($this->getUser()), + "users" => $tbtimers, + "fgprint" => $request->query->get('fgprint'), + ]); + + return new PdfResponse( + $this->knpSnappy->getOutputFromHtml($render), + 'validationhoraires.pdf' + ); + } + else { + return $this->render('Validation/validationtimer.html.twig',[ + "useheader" => true, + "usesidebar" => ($this->getUser()), + "users" => $tbtimers + ]); + + } + } + + public function validatetimer(Request $request){ + $em = $this->getDoctrine()->getManager(); + + // Récupération des variables envoyées en post + $id = $request->request->get('id'); + $timer=$em->getRepository("App:Timer")->find($id); + if($timer) { + $timer->setValidate(true); + $em->persist($timer); + $em->flush(); + $iduser=$this->get("session")->get("iduser"); + $idtimer=$timer->getId(); + } + + $output=[]; + return new Response(json_encode($output)); + } + + public function devalidatetimer(Request $request){ + $em = $this->getDoctrine()->getManager(); + + // Récupération des variables envoyées en post + $id = $request->request->get('id'); + $timer=$em->getRepository("App:Timer")->find($id); + if($timer) { + $timer->setValidate(false); + $em->persist($timer); + $em->flush(); + } + + $output=[]; + return new Response(json_encode($output)); + } + public function activetimer() { + $this->get('session')->set('activetimer',!$this->get('session')->get('activetimer')); + + return $this->redirectToRoute("app_validationtimer"); + } } diff --git a/src/schedule-2.0/src/Entity/Timer.php b/src/schedule-2.0/src/Entity/Timer.php index cbc721c..4b49086 100644 --- a/src/schedule-2.0/src/Entity/Timer.php +++ b/src/schedule-2.0/src/Entity/Timer.php @@ -55,17 +55,30 @@ class Timer */ private $task; + /** + * @ORM\Column(name="activepenalty", type="boolean") + * + */ + private $activepenalty; + + /** + * @ORM\Column(name="additionalhour", type="boolean") + * + */ + private $additionalhour; + /** - * @ORM\Column(name="activepenalty", type="boolean") + * @ORM\Column(name="validate", type="boolean") * */ - private $activepenalty; + private $validate; public function __construct() { $this->start = new \DateTime(); $this->end = new \DateTime(); $this->duration = new \DateTime(); + $this->validate = false; } public function getId(): ?int @@ -157,4 +170,28 @@ class Timer return $this; } + public function getAdditionalHour(): ?bool + { + return $this->additionalhour; + } + + public function setAdditionalHour(bool $additionalhour): self + { + $this->additionalhour = $additionalhour; + + return $this; + } + + public function getValidate(): ?bool + { + return $this->validate; + } + + public function setValidate(bool $validate): self + { + $this->validate = $validate; + + return $this; + } + } diff --git a/src/schedule-2.0/src/Form/TimerType.php b/src/schedule-2.0/src/Form/TimerType.php index 5692d08..c66a809 100644 --- a/src/schedule-2.0/src/Form/TimerType.php +++ b/src/schedule-2.0/src/Form/TimerType.php @@ -65,6 +65,12 @@ class TimerType extends AbstractType "choices" => ["Non"=>false, "Oui"=>true] ] ); + $builder->add("additionalhour", + ChoiceType::class,[ + "label" => "Heures supplémentaires", + "choices" => ["Non"=>false, "Oui"=>true] + ] + ); $builder->add('start', DateTimeType::class, [ diff --git a/src/schedule-2.0/templates/Timer/edit.html.twig b/src/schedule-2.0/templates/Timer/edit.html.twig index e7e1e2b..e04ef34 100644 --- a/src/schedule-2.0/templates/Timer/edit.html.twig +++ b/src/schedule-2.0/templates/Timer/edit.html.twig @@ -59,6 +59,7 @@ {{ form_row(form.task) }} {{ form_row(form.description) }} {{ form_row(form.activepenalty) }} + {{ form_row(form.additionalhour) }} {{ form_row(form.start) }} {{ form_row(form.end) }} {{ form_row(form.duration) }} diff --git a/src/schedule-2.0/templates/Timer/export.csv.twig b/src/schedule-2.0/templates/Timer/export.csv.twig index f01b24a..da9542e 100644 --- a/src/schedule-2.0/templates/Timer/export.csv.twig +++ b/src/schedule-2.0/templates/Timer/export.csv.twig @@ -1,7 +1,7 @@ {% block body %} Astreintes Actives -Tâche;Active;Utilisateur;Début;Fin;Durée;Description; +Tâche;Astr.Act;H.Supp;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}}; +{{timer.taskname}};{{timer.activepenalty}};{{timer.additionalhour}};{{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 %} \ No newline at end of file diff --git a/src/schedule-2.0/templates/Timer/list.html.twig b/src/schedule-2.0/templates/Timer/list.html.twig index 814e36d..cbe2a89 100644 --- a/src/schedule-2.0/templates/Timer/list.html.twig +++ b/src/schedule-2.0/templates/Timer/list.html.twig @@ -37,7 +37,7 @@ SUIVI HORAIRE Voir le calendrier -Exporter Astreintes actives +Exporter Astreintes actives et heures supplémentaires

@@ -57,6 +57,7 @@ SUIVI HORAIRE diff --git a/src/schedule-2.0/templates/Validation/validationtimer.html.twig b/src/schedule-2.0/templates/Validation/validationtimer.html.twig new file mode 100644 index 0000000..85963e7 --- /dev/null +++ b/src/schedule-2.0/templates/Validation/validationtimer.html.twig @@ -0,0 +1,159 @@ +{% extends "base.html.twig" %} + +{% block localstyle %} + {% if fgprint is defined and fgprint %} + table { font-size:10px;} + th,td { + border: 1px solid #37474F; + } + thead { + display: table-header-group; + } + tr { page-break-inside: avoid; } + .homecard {width: 100% } + {%endif%} + +{% endblock %} + +{% block body %} +

+ VALIDATION HORAIRES +

+ +
+ + +
+
+ +
+
+
+ {% if not app.session.get('activetimer') %} + Horaires à Dévalider + {% else %} + Horaires à Valider + {% endif %} +
+ +
+
+
{{ timer.task.displayname }} {{ timer.activepenalty ? "Astreinte active" : "" }} + {{ timer.additionalhour ? "Heures supplémentaires" : "" }}

{{ timer.description }}

{{ timer.start|date("d/m/Y H:i") }}
+ + + + + + + + + + + {% for user in users %} + {% for timer in user.timers %} + + + + + + + + + + + + + + + + {% endfor %} + {% endfor %} +
UtilisateurTâcheDescriptionDébutFinDurée
+ {% if timer.validate %} + + {% else %} + + {% endif %} + + {{ user.user.displayname }} + + {{ timer.taskname }} + + {{ timer.activepenalty ? "Astreinte active" : "" }} + {{ timer.additionalhour ? "Heures supplémentaires" : "" }} +

{{ timer.description }}

+
+ {{ timer.start|date("d/m/Y H:i") }} + + {{ timer.end|date("d/m/Y H:i") }} + + {{ timer.duration|date("H:i") }} +
+
+ + + +{% endblock %} + +{% block localjavascript %} + $(document).ready(function() { + {% if not fgprint is defined or not fgprint %} + $('.table ').DataTable({ + columnDefs: [ { "targets": "no-sort", "orderable": false }, { "targets": "no-string", "type" : "num" } ], + responsive: true, + iDisplayLength: 100, + order: [[ 1, "asc" ]] + }); + {%else%} + $('#dataTables').removeClass("table table-striped table-bordered table-hover small dataTable no-footer"); + {% endif %} + }); + + function myprint() { + href=document.location.href; + document.location.href=href+"?fgprint=true"; + } + + function validate(id) { + $.ajax({ + type: "POST", + data: { + id: id, + }, + url: "{{ path('app_validationtimer_validate') }}", + success: function (response) { + response=JSON.parse(response); + if(response.return=="KO") { + alert(response.error); + } + else { + $("#row-"+id).remove(); + } + } + }); + } + + function devalidate(id) { + $.ajax({ + type: "POST", + data: { + id: id, + }, + url: "{{ path('app_validationtimer_devalidate') }}", + success: function (response) { + response=JSON.parse(response); + if(response.return=="KO") { + alert(response.error); + } + else { + $("#row-"+id).remove(); + } + } + }); + } + + $('#switchactive').change(function() { + window.location="{{ path('app_validationtimer_activetimer' )}}"; + }); + +{% endblock %} diff --git a/src/schedule-2.0/templates/base.html.twig b/src/schedule-2.0/templates/base.html.twig index f72918d..f0f3a73 100644 --- a/src/schedule-2.0/templates/base.html.twig +++ b/src/schedule-2.0/templates/base.html.twig @@ -367,7 +367,7 @@
  • - Mes Congés + Mes Congés
  • @@ -378,15 +378,21 @@
  • - Validation + Validation Calendrier + +
  • + +
  • + + Validation Congés
  • - - Validation Congés + + Validation Horaires -
  • + {% endif %}