switch task inactives ref #61

This commit is contained in:
2021-03-04 10:17:13 +01:00
parent 5343d61401
commit 94fa9d1f0b
4 changed files with 53 additions and 33 deletions

View File

@@ -262,6 +262,10 @@ app_task_activeproject:
path: /master/task/activeproject path: /master/task/activeproject
defaults: { _controller: App\Controller\TaskController:activeproject } defaults: { _controller: App\Controller\TaskController:activeproject }
app_task_activetask:
path: /master/task/activetask
defaults: { _controller: App\Controller\TaskController:activetask }
#== Event ==================================================================================================== #== Event ====================================================================================================
app_event: app_event:
path: /user/event path: /user/event

View File

@@ -31,13 +31,13 @@ class TaskController extends AbstractController
"services" => $services, "services" => $services,
"useheader" => true, "useheader" => true,
"usesidebar" => true, "usesidebar" => true,
"fgprint" => true, "fgprint" => true,
]); ]);
return new PdfResponse( return new PdfResponse(
$this->knpSnappy->getOutputFromHtml($render,["orientation"=>"Landscape"]), $this->knpSnappy->getOutputFromHtml($render,["orientation"=>"Landscape"]),
'taches.pdf' 'taches.pdf'
); );
} }
else { else {
return $this->render($this->render.'list.html.twig',[ return $this->render($this->render.'list.html.twig',[
@@ -61,30 +61,30 @@ class TaskController extends AbstractController
// Récupération des data du formulaire // Récupération des data du formulaire
$form->handleRequest($request); $form->handleRequest($request);
// Sur erreur // Sur erreur
$this->getErrorForm(null,$form,$request,$data,"submit"); $this->getErrorForm(null,$form,$request,$data,"submit");
// Sur validation // Sur validation
if ($form->get('submit')->isClicked() && $form->isValid()) { if ($form->get('submit')->isClicked() && $form->isValid()) {
$data = $form->getData(); $data = $form->getData();
$em->persist($data); $em->persist($data);
$em->flush(); $em->flush();
// Retour à la liste // Retour à la liste
return $this->redirectToRoute($this->route); return $this->redirectToRoute($this->route);
} }
// Affichage du formulaire // Affichage du formulaire
return $this->render($this->render.'edit.html.twig', [ return $this->render($this->render.'edit.html.twig', [
'useheader' => true, 'useheader' => true,
'usesidebar' => true, 'usesidebar' => true,
$this->data => $data, $this->data => $data,
'mode' => 'submit', 'mode' => 'submit',
'form' => $form->createView() 'form' => $form->createView()
]); ]);
} }
public function update($id,Request $request) public function update($id,Request $request)
{ {
// Initialisation de l'enregistrement // Initialisation de l'enregistrement
@@ -99,43 +99,43 @@ class TaskController extends AbstractController
// Sur erreur // Sur erreur
$this->getErrorForm(null,$form,$request,$data,"update"); $this->getErrorForm(null,$form,$request,$data,"update");
// Sur validation // Sur validation
if ($form->get('submit')->isClicked() && $form->isValid()) { if ($form->get('submit')->isClicked() && $form->isValid()) {
$data = $form->getData(); $data = $form->getData();
$em->persist($data); $em->persist($data);
$em->flush(); $em->flush();
// Retour à la liste // Retour à la liste
return $this->redirectToRoute($this->route); return $this->redirectToRoute($this->route);
} }
// Affichage du formulaire // Affichage du formulaire
if($request->query->get('fgprint')) { if($request->query->get('fgprint')) {
$render = $this->renderView($this->render.'edit.html.twig', [ $render = $this->renderView($this->render.'edit.html.twig', [
'useheader' => true, 'useheader' => true,
'usesidebar' => true, 'usesidebar' => true,
$this->data => $data, $this->data => $data,
'mode' => 'update', 'mode' => 'update',
'form' => $form->createView(), 'form' => $form->createView(),
"fgprint" => true, "fgprint" => true,
]); ]);
return new PdfResponse( return new PdfResponse(
$this->knpSnappy->getOutputFromHtml($render), $this->knpSnappy->getOutputFromHtml($render),
'tache.pdf' 'tache.pdf'
); );
} }
else { else {
return $this->render($this->render.'edit.html.twig', [ return $this->render($this->render.'edit.html.twig', [
'useheader' => true, 'useheader' => true,
'usesidebar' => true, 'usesidebar' => true,
$this->data => $data, $this->data => $data,
'mode' => 'update', 'mode' => 'update',
'form' => $form->createView() 'form' => $form->createView()
]); ]);
} }
} }
public function delete($id,Request $request) public function delete($id,Request $request)
{ {
@@ -161,13 +161,18 @@ class TaskController extends AbstractController
// Retour à la liste // Retour à la liste
return $this->redirectToRoute($this->route); return $this->redirectToRoute($this->route);
} }
} }
public function activeproject() { public function activeproject() {
$this->get('session')->set('activeproject',!$this->get('session')->get('activeproject')); $this->get('session')->set('activeproject',!$this->get('session')->get('activeproject'));
return $this->redirectToRoute($this->route); return $this->redirectToRoute($this->route);
} }
public function activetask() {
$this->get('session')->set('activetask',!$this->get('session')->get('activetask'));
return $this->redirectToRoute($this->route);
}
public function activeoffer() { public function activeoffer() {
$this->get('session')->set('activeoffer',!$this->get('session')->get('activeoffer')); $this->get('session')->set('activeoffer',!$this->get('session')->get('activeoffer'));
return $this->redirectToRoute($this->route); return $this->redirectToRoute($this->route);
@@ -189,5 +194,5 @@ class TaskController extends AbstractController
$request->getSession()->getFlashBag()->add("error", $error->getMessage()); $request->getSession()->getFlashBag()->add("error", $error->getMessage());
} }
} }
} }
} }

View File

@@ -33,7 +33,7 @@ class sessionListener {
$haverole=true; $haverole=true;
} }
} }
return $haverole; return $haverole;
} }
@@ -67,11 +67,12 @@ class sessionListener {
// Initialisation de la session // Initialisation de la session
if($regen) { if($regen) {
$session->set('activeproject',true); $session->set('activeproject',true);
$session->set('activetask',true);
$session->set('activeoffer',true); $session->set('activeoffer',true);
$session->set('activeholiday',true); $session->set('activeholiday',true);
$session->set('activetimer',true); $session->set('activetimer',true);
$session->set('nbmonth',3); $session->set('nbmonth',3);
if($curentuser!="anon.") { if($curentuser!="anon.") {
if(in_array("ROLE_USER",$roles)) if(in_array("ROLE_USER",$roles))
$session->set('iduser',$curentuser->getId()); $session->set('iduser',$curentuser->getId());
@@ -86,7 +87,7 @@ class sessionListener {
$session->set('idproject',"all"); $session->set('idproject',"all");
$session->set('idservice',"all"); $session->set('idservice',"all");
} }
$tbusers=[]; $tbusers=[];
$users=$this->em->getRepository('App:User')->findAll(); $users=$this->em->getRepository('App:User')->findAll();
foreach($users as $user) { foreach($users as $user) {
@@ -99,7 +100,7 @@ class sessionListener {
} }
} }
$session->set('users',$tbusers); $session->set('users',$tbusers);
$tbprojects=[]; $tbprojects=[];
$projects=$this->em->getRepository('App:Project')->findBy(["active"=>true]); $projects=$this->em->getRepository('App:Project')->findBy(["active"=>true]);
foreach($projects as $project) { foreach($projects as $project) {
@@ -110,7 +111,7 @@ class sessionListener {
array_push($tbprojects,$tmp); array_push($tbprojects,$tmp);
} }
$session->set('projects',$tbprojects); $session->set('projects',$tbprojects);
$tbservices=[]; $tbservices=[];
$services=$this->em->getRepository('App:Service')->findAll(); $services=$this->em->getRepository('App:Service')->findAll();
foreach($services as $service) { foreach($services as $service) {
@@ -120,8 +121,8 @@ class sessionListener {
]; ];
array_push($tbservices,$tmp); array_push($tbservices,$tmp);
} }
$session->set('services',$tbservices); $session->set('services',$tbservices);
} }
} }
} }

View File

@@ -13,7 +13,7 @@
thead { thead {
display: table-header-group; display: table-header-group;
} }
tr { page-break-inside: avoid; } tr { page-break-inside: avoid; }
{%endif%} {%endif%}
{% endblock %} {% endblock %}
@@ -30,6 +30,11 @@
<label class="custom-control-label" for="switchactive">Projet Actif</label> <label class="custom-control-label" for="switchactive">Projet Actif</label>
</div> </div>
<div class="custom-control custom-switch float-right" style="margin-right:20px">
<input type="checkbox" class="custom-control-input" id="switchactivetask" {% if app.session.get('activetask') %} checked {% endif %}>
<label class="custom-control-label" for="switchactivetask">Tâche Active</label>
</div>
<p></p> <p></p>
{%for service in services %} {%for service in services %}
@@ -44,7 +49,7 @@
{% endif %} {% endif %}
{% set haveproject=true %} {% set haveproject=true %}
{% endif %} {% endif %}
{% endfor %} {% endfor %}
{% if haveproject and havetask %} {% if haveproject and havetask %}
@@ -75,6 +80,7 @@
{% for project in service.projects %} {% for project in service.projects %}
{% if app.session.get('activeproject')==project.active and (app.session.get('idproject')=="all" or app.session.get('idproject')==project.id) %} {% if app.session.get('activeproject')==project.active and (app.session.get('idproject')=="all" or app.session.get('idproject')==project.id) %}
{% for task in project.tasks %} {% for task in project.tasks %}
{% if app.session.get('activetask')==task.active %}
{% set totvalidate=task.validate %} {% set totvalidate=task.validate %}
{% set totplanified=task.validate %} {% set totplanified=task.validate %}
{% for event in task.events %} {% for event in task.events %}
@@ -107,6 +113,7 @@
<td class="text-right">{{(task.quantity-totplanified)|number_format(2, '.', ' ')}}</td> <td class="text-right">{{(task.quantity-totplanified)|number_format(2, '.', ' ')}}</td>
<td class="text-center" style="background-color:{{task.color}}; color:#ffffff">{{task.color}}</td> <td class="text-center" style="background-color:{{task.color}}; color:#ffffff">{{task.color}}</td>
</tr> </tr>
{% endif %}
{% endfor %} {% endfor %}
{% endif %} {% endif %}
{% endfor %} {% endfor %}
@@ -131,17 +138,20 @@
order: [[ 1, "asc" ]] order: [[ 1, "asc" ]]
}); });
{%else%} {%else%}
$('#dataTables').removeClass("table table-striped table-bordered table-hover small dataTable no-footer"); $('#dataTables').removeClass("table table-striped table-bordered table-hover small dataTable no-footer");
{% endif %} {% endif %}
}); });
$('#switchactive').change(function() { $('#switchactive').change(function() {
window.location="{{ path('app_task_activeproject' )}}"; window.location="{{ path('app_task_activeproject' )}}";
}); });
$('#switchactivetask').change(function() {
window.location="{{ path('app_task_activetask' )}}";
});
function myprint() { function myprint() {
href=document.location.href; href=document.location.href;
document.location.href=href+"?fgprint=true"; document.location.href=href+"?fgprint=true";
} }
{% endblock %} {% endblock %}