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
defaults: { _controller: App\Controller\TaskController:activeproject }
app_task_activetask:
path: /master/task/activetask
defaults: { _controller: App\Controller\TaskController:activetask }
#== Event ====================================================================================================
app_event:
path: /user/event

View File

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

View File

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

View File

@@ -13,7 +13,7 @@
thead {
display: table-header-group;
}
tr { page-break-inside: avoid; }
tr { page-break-inside: avoid; }
{%endif%}
{% endblock %}
@@ -30,6 +30,11 @@
<label class="custom-control-label" for="switchactive">Projet Actif</label>
</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>
{%for service in services %}
@@ -44,7 +49,7 @@
{% endif %}
{% set haveproject=true %}
{% endif %}
{% endif %}
{% endfor %}
{% if haveproject and havetask %}
@@ -75,6 +80,7 @@
{% 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) %}
{% for task in project.tasks %}
{% if app.session.get('activetask')==task.active %}
{% set totvalidate=task.validate %}
{% set totplanified=task.validate %}
{% for event in task.events %}
@@ -107,6 +113,7 @@
<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>
</tr>
{% endif %}
{% endfor %}
{% endif %}
{% endfor %}
@@ -131,17 +138,20 @@
order: [[ 1, "asc" ]]
});
{%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 %}
});
$('#switchactive').change(function() {
window.location="{{ path('app_task_activeproject' )}}";
});
$('#switchactivetask').change(function() {
window.location="{{ path('app_task_activetask' )}}";
});
function myprint() {
href=document.location.href;
document.location.href=href+"?fgprint=true";
}
{% endblock %}
}
{% endblock %}