From 5037b0945efd15357ee43851b3515c7a979ddb7e Mon Sep 17 00:00:00 2001 From: Matthieu Lamalle Date: Wed, 16 Dec 2020 16:33:57 +0100 Subject: [PATCH 1/4] =?UTF-8?q?ajout=20export=20jours=20factur=C3=A9s=20#5?= =?UTF-8?q?6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/schedule-2.0/config/routes.yaml | 4 ++ .../src/Controller/ExportController.php | 53 +++++++++++++++++++ .../Export/export_month_charged_days.csv.twig | 6 +++ .../templates/Export/list.html.twig | 10 ++++ 4 files changed, 73 insertions(+) create mode 100644 src/schedule-2.0/templates/Export/export_month_charged_days.csv.twig diff --git a/src/schedule-2.0/config/routes.yaml b/src/schedule-2.0/config/routes.yaml index 870f7b1..bde9a61 100644 --- a/src/schedule-2.0/config/routes.yaml +++ b/src/schedule-2.0/config/routes.yaml @@ -428,6 +428,10 @@ export_offers: path: /export/export_offers defaults: { _controller: App\Controller\ExportController:export_offers } +export_month_charged_days: + path: /export/export_month_charged_days + defaults: { _controller: App\Controller\ExportController:export_month_charged_days } + #== Export ====================================================================================================== app_stat_view: diff --git a/src/schedule-2.0/src/Controller/ExportController.php b/src/schedule-2.0/src/Controller/ExportController.php index c5958ab..58d6e54 100644 --- a/src/schedule-2.0/src/Controller/ExportController.php +++ b/src/schedule-2.0/src/Controller/ExportController.php @@ -473,5 +473,58 @@ class ExportController extends AbstractController return $response; } + public function export_month_charged_days(Request $request,$access=null): Response { + $em = $this->getDoctrine()->getManager(); + $nbmonth=$this->get("session")->get("nbmonth"); + + $tbevents=[]; + // On formate le tableau des event + $start=new \Datetime('first day of this month'); + $start->sub(new \DateInterval('P'.$nbmonth.'M')); + $start->setTime(0,0,0); + $end = new \Datetime('first day of this month'); + $end->add(new \DateInterval('P1M')); + $end->setTime(23,59,0); + + $events = $em + ->createQueryBuilder('event') + ->select('event') + ->from('App:Event','event') + ->Where('event.start>=:start AND event.end <:end') + ->setParameter('start',$start) + ->setParameter('end',$end) + ->getQuery()->getResult(); + + foreach($events as $event) { + if (!isset($tbevents[$event->getStart()->format("m")])) { + $tbevents[$event->getStart()->format("m")]["f"]=0; + $tbevents[$event->getStart()->format("m")]["nf"]=0; + } + if ($event->getTask()->getNature()->getName() == "Prestation") { + if (!isset($tbevents[$event->getStart()->format("m")])){ + + $tbevents[$event->getStart()->format("m")]['f'] = $event->getDuration(); + }else{ + $tbevents[$event->getStart()->format("m")]['f'] += $event->getDuration(); + } + } + + if ($event->getTask()->getNature()->getName() != "Prestation") { + if (!isset($tbevents[$event->getStart()->format("m")])){ + $tbevents[$event->getStart()->format("m")]['nf'] = $event->getDuration(); + }else{ + $tbevents[$event->getStart()->format("m")]['nf'] += $event->getDuration(); + } + } + + } + + $csv = $this->renderView('Export/export_month_charged_days.csv.twig', ["events" => $tbevents]); + $response = new Response($csv); + $response->headers->set('Content-Type', 'text/csv; charset=utf-8'); + $response->headers->set('Content-Disposition', 'attachment; filename="export_month_charged_days.csv"'); + + return $response; + } } diff --git a/src/schedule-2.0/templates/Export/export_month_charged_days.csv.twig b/src/schedule-2.0/templates/Export/export_month_charged_days.csv.twig new file mode 100644 index 0000000..9a68e2e --- /dev/null +++ b/src/schedule-2.0/templates/Export/export_month_charged_days.csv.twig @@ -0,0 +1,6 @@ +{% block body %} +Mois;Jours_facturés;Jour_non_facturés +{% for month, event in events %} +{{month}};{{event.f}};{{event.nf}} +{% endfor %} +{% endblock %} diff --git a/src/schedule-2.0/templates/Export/list.html.twig b/src/schedule-2.0/templates/Export/list.html.twig index 9d52def..284d40e 100644 --- a/src/schedule-2.0/templates/Export/list.html.twig +++ b/src/schedule-2.0/templates/Export/list.html.twig @@ -43,4 +43,14 @@ EXPORTS DE DONNEES

+
+ +
+

Exporter la liste du nombre de jours facturés et non-facturés par mois

+

Filtres utiles : Nombre de mois

+
+
+

{% endblock %} \ No newline at end of file From 2ba143e5a2775e0a64dfe72a51d8904b890cc621 Mon Sep 17 00:00:00 2001 From: Matthieu Lamalle Date: Thu, 17 Dec 2020 10:53:52 +0100 Subject: [PATCH 2/4] =?UTF-8?q?Ajout=20notion=20de=20t=C3=A2che=20active,?= =?UTF-8?q?=20et=20affichage=20uniquement=20des=20taches=20active=20lors?= =?UTF-8?q?=20de=20la=20cr=C3=A9ation=20d'=C3=A9v=C3=A9nements=20#55?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../src/Controller/TaskController.php | 1 + src/schedule-2.0/src/Entity/Task.php | 19 ++++++++++++++++++- src/schedule-2.0/src/Form/TaskType.php | 7 +++++++ .../templates/Event/list.html.twig | 2 ++ .../templates/Task/edit.html.twig | 1 + .../templates/Task/list.html.twig | 2 ++ 6 files changed, 31 insertions(+), 1 deletion(-) diff --git a/src/schedule-2.0/src/Controller/TaskController.php b/src/schedule-2.0/src/Controller/TaskController.php index fb27118..6828d2f 100755 --- a/src/schedule-2.0/src/Controller/TaskController.php +++ b/src/schedule-2.0/src/Controller/TaskController.php @@ -55,6 +55,7 @@ class TaskController extends AbstractController $data = new Entity(); $defaultnature = $em->getRepository("App:Nature")->findOneBy(['name' => 'Prestation']); $data->setNature($defaultnature); + $data->setActive(true); // Création du formulaire $form = $this->createForm(Form::class,$data,array("mode"=>"submit")); diff --git a/src/schedule-2.0/src/Entity/Task.php b/src/schedule-2.0/src/Entity/Task.php index 3a9f470..89577f4 100644 --- a/src/schedule-2.0/src/Entity/Task.php +++ b/src/schedule-2.0/src/Entity/Task.php @@ -70,7 +70,11 @@ class Task * @ORM\OneToMany(targetEntity="Penalty", mappedBy="task", cascade={"persist"}, orphanRemoval=false) */ private $penaltys; - + /** + * @ORM\Column(name="active", type="boolean") + * + */ + private $active; /** * Calculate Displayname */ @@ -227,6 +231,19 @@ class Task return $this; } + + public function getActive(): ?bool + { + return $this->active; + } + + public function setActive(bool $active): self + { + $this->active = $active; + + return $this; + } + /** * @return Collection|Penalty[] diff --git a/src/schedule-2.0/src/Form/TaskType.php b/src/schedule-2.0/src/Form/TaskType.php index e861bfd..bbf56f9 100644 --- a/src/schedule-2.0/src/Form/TaskType.php +++ b/src/schedule-2.0/src/Form/TaskType.php @@ -56,6 +56,13 @@ class TaskType extends AbstractType "choice_label" => "name", ] ); + + $builder->add("active", + ChoiceType::class,[ + "label" => "Actif", + "choices" => ["Non"=>false, "Oui"=>true] + ] + ); $builder->add('color', TextType::class, [ diff --git a/src/schedule-2.0/templates/Event/list.html.twig b/src/schedule-2.0/templates/Event/list.html.twig index e9dbf6d..1996800 100644 --- a/src/schedule-2.0/templates/Event/list.html.twig +++ b/src/schedule-2.0/templates/Event/list.html.twig @@ -99,7 +99,9 @@ {% for project in projects|sort((a, b) => a.displayname <=> b.displayname) %} {% for task in project.tasks|sort((a, b) => a.displayname <=> b.displayname) %} + {% if task.active %} + {% endif %} {% endfor %} {% endfor %} diff --git a/src/schedule-2.0/templates/Task/edit.html.twig b/src/schedule-2.0/templates/Task/edit.html.twig index 2bf54ae..7d6b4fb 100755 --- a/src/schedule-2.0/templates/Task/edit.html.twig +++ b/src/schedule-2.0/templates/Task/edit.html.twig @@ -54,6 +54,7 @@ {{ form_row(form.name) }} {{ form_row(form.project) }} {{ form_row(form.nature) }} + {{ form_row(form.active) }} {{ form_row(form.quantity) }} {{ form_row(form.color) }} diff --git a/src/schedule-2.0/templates/Task/list.html.twig b/src/schedule-2.0/templates/Task/list.html.twig index a53d1ad..188522e 100644 --- a/src/schedule-2.0/templates/Task/list.html.twig +++ b/src/schedule-2.0/templates/Task/list.html.twig @@ -63,6 +63,7 @@ Nature Projet Tâche + Actif Estimation Validé Planifié @@ -99,6 +100,7 @@ {{task.nature.name}} {{task.project.name}} {{task.name}} + {{task.active ? "actif":"non-actif"}} {{task.quantity|number_format(2, '.', ' ')}} {{(totvalidate*-1)|number_format(2, '.', ' ')}} {{((totplanified-totvalidate)*-1)|number_format(2, '.', ' ')}} From cdb2537d3f0196f22c46440732d7dddd9f9ed86e Mon Sep 17 00:00:00 2001 From: Matthieu Lamalle Date: Thu, 17 Dec 2020 11:04:01 +0100 Subject: [PATCH 3/4] update migration script --- src/schedule-2.0/scripts/migration/migration.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/schedule-2.0/scripts/migration/migration.php b/src/schedule-2.0/scripts/migration/migration.php index 17ae0d2..dd95208 100644 --- a/src/schedule-2.0/scripts/migration/migration.php +++ b/src/schedule-2.0/scripts/migration/migration.php @@ -174,10 +174,10 @@ while($row=$queryold->fetch()) { $nature=$row["task_nature"]; if($row["task_id"]<=-70) $nature=-200; if($row["task_id"]==-85 || $row["task_id"]==-70) $nature=-190; - $q="INSERT IGNORE INTO task (id, name, color, quantity, validate, project_id, nature_id ) VALUES (?,?,?,?,?,?,?)"; + $q="INSERT IGNORE INTO task (id, name, color, quantity, validate, project_id, nature_id, active) VALUES (?,?,?,?,?,?,?,?)"; $quantity=($row["task_quantity"]==0?null:$row["task_quantity"]); $query=$bddnew->prepare($q); - $query->execute([$row["task_id"],$row["task_name"],"#".$row["task_color"],$quantity,$row["task_validate"],$row["task_project"],$nature ]); + $query->execute([$row["task_id"],$row["task_name"],"#".$row["task_color"],$quantity,$row["task_validate"],$row["task_project"],$nature, 1]); } writeligne(""); From 6acf4276966b6046ae05ff1584d423ff2f8627ae Mon Sep 17 00:00:00 2001 From: Arnaud Fornerot Date: Thu, 4 Feb 2021 16:13:35 +0100 Subject: [PATCH 4/4] correctif sur autosubmit des users --- src/schedule-2.0/config/routes.yaml | 4 ++++ src/schedule-2.0/src/Controller/HomeController.php | 8 ++++++++ .../src/Controller/SecurityController.php | 13 ++++++++++--- src/schedule-2.0/templates/Home/customer.html.twig | 8 ++++++++ src/schedule-2.0/templates/base.html.twig | 2 +- 5 files changed, 31 insertions(+), 4 deletions(-) create mode 100644 src/schedule-2.0/templates/Home/customer.html.twig diff --git a/src/schedule-2.0/config/routes.yaml b/src/schedule-2.0/config/routes.yaml index bde9a61..7c92a17 100644 --- a/src/schedule-2.0/config/routes.yaml +++ b/src/schedule-2.0/config/routes.yaml @@ -399,6 +399,10 @@ app_timer_delete: #== Customer ====================================================================================================== +app_customer_home: + path: /customer + defaults: { _controller: App\Controller\HomeController:customer } + app_customer_report: path: /customer/report/{key} defaults: { _controller: App\Controller\ReportController:report, access: 'customer' } diff --git a/src/schedule-2.0/src/Controller/HomeController.php b/src/schedule-2.0/src/Controller/HomeController.php index 01cfb4a..3b30e2d 100755 --- a/src/schedule-2.0/src/Controller/HomeController.php +++ b/src/schedule-2.0/src/Controller/HomeController.php @@ -25,6 +25,14 @@ class HomeController extends AbstractController */ } + public function customer() + { + return $this->render('Home/customer.html.twig',[ + "useheader" => true, + "usesidebar" => false, + ]); + } + public function selectmonth(Request $request) { $nbmonth = $request->request->get('nbmonth'); diff --git a/src/schedule-2.0/src/Controller/SecurityController.php b/src/schedule-2.0/src/Controller/SecurityController.php index f1282d5..ed74e8d 100755 --- a/src/schedule-2.0/src/Controller/SecurityController.php +++ b/src/schedule-2.0/src/Controller/SecurityController.php @@ -97,7 +97,7 @@ class SecurityController extends AbstractController $user->setPassword("CASPWD-".$username); $user->setSalt("CASPWD-".$username); - $user->setRole("ROLE_USER"); + $user->setRoles(["ROLE_VISITOR"]); $em->persist($user); $em->flush(); @@ -125,8 +125,15 @@ class SecurityController extends AbstractController // Redirection if($redirect) return $this->redirect($redirect); - else - return $this->redirect($this->generateUrl('app_home')); + else { + $roles=$user->getRoles(); + if(!in_array("ROLE_VISITOR",$roles)) + return $this->redirect($this->generateUrl('app_home')); + else { + dump("here"); + return $this->redirect($this->generateUrl('app_customer_home')); + } + } } diff --git a/src/schedule-2.0/templates/Home/customer.html.twig b/src/schedule-2.0/templates/Home/customer.html.twig new file mode 100644 index 0000000..603e35b --- /dev/null +++ b/src/schedule-2.0/templates/Home/customer.html.twig @@ -0,0 +1,8 @@ +{% extends "base.html.twig" %} + +{% block body %} + +
Merci d'utiliser l'URL qui vous a été communiquée pour visualiser votre rapport.
+ +{% endblock %} + diff --git a/src/schedule-2.0/templates/base.html.twig b/src/schedule-2.0/templates/base.html.twig index 4579789..919b4cc 100644 --- a/src/schedule-2.0/templates/base.html.twig +++ b/src/schedule-2.0/templates/base.html.twig @@ -216,7 +216,7 @@