Ajout export commandes
This commit is contained in:
@@ -416,6 +416,10 @@ export_full_worked_days:
|
||||
path: /export/export_full_worked_days
|
||||
defaults: { _controller: App\Controller\ExportController:export_full_worked_days }
|
||||
|
||||
export_offers:
|
||||
path: /export/export_offers
|
||||
defaults: { _controller: App\Controller\ExportController:export_offers }
|
||||
|
||||
|
||||
#== API ===========================================================================================================
|
||||
app_api:
|
||||
|
@@ -434,6 +434,44 @@ class ExportController extends AbstractController
|
||||
|
||||
return $response;
|
||||
}
|
||||
public function export_offers(Request $request,$access=null): Response {
|
||||
$em = $this->getDoctrine()->getManager();
|
||||
$projects=$em->getRepository("App:Project")->findAll();
|
||||
//Construction du tableau des projets
|
||||
$tbprojects=[];
|
||||
foreach($projects as $project) {
|
||||
// Filtre par Customer
|
||||
if($access=="customer") {
|
||||
if($project->getCustomer()->getKeypass()!=$key)
|
||||
continue;
|
||||
}
|
||||
|
||||
// Filtre par Service
|
||||
if($this->get('session')->get('idservice')!="all") {
|
||||
if($project->getService()->getId()!=$this->get('session')->get('idservice'))
|
||||
continue;
|
||||
}
|
||||
|
||||
// Filtre par project
|
||||
if($this->get('session')->get('idproject')!="all") {
|
||||
if($project->getId()!=$this->get('session')->get('idproject'))
|
||||
continue;
|
||||
}
|
||||
$tbproject["name"] = $project->getname();
|
||||
$tbproject["customer"] = $project->getCustomer()->getName();
|
||||
$tbproject["offers"] = $project->getOffers();
|
||||
|
||||
$tbprojects[$project->getId()]=$tbproject;
|
||||
}
|
||||
|
||||
|
||||
$csv = $this->renderView('Export/export_offers.csv.twig', ["projects" => $tbprojects]);
|
||||
$response = new Response($csv);
|
||||
$response->headers->set('Content-Type', 'text/csv; charset=utf-8');
|
||||
$response->headers->set('Content-Disposition', 'attachment; filename="export_offers.csv"');
|
||||
|
||||
return $response;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
8
src/schedule-2.0/templates/Export/export_offers.csv.twig
Normal file
8
src/schedule-2.0/templates/Export/export_offers.csv.twig
Normal file
@@ -0,0 +1,8 @@
|
||||
{% block body %}
|
||||
Client;Projet;Proposition;Ref;Qt;PU;Total;
|
||||
{% for project in projects %}
|
||||
{% for offer in project.offers %}
|
||||
{{ project.customer }};{{project.name}};{{offer.name}};{{offer.ref}};{{offer.quantity}};{{offer.pu}};{{offer.total}}
|
||||
{% endfor %}
|
||||
{% endfor %}
|
||||
{% endblock %}
|
@@ -33,4 +33,14 @@ EXPORTS DE DONNEES
|
||||
</div>
|
||||
</div>
|
||||
<p></p>
|
||||
<div class="card">
|
||||
<div class="card-header">
|
||||
<a class="btn btn-success" href={{ path('export_offers') }}>Export des commandes</a>
|
||||
</div>
|
||||
<div class="card-body">
|
||||
<p>Exporter la liste des commandes</p>
|
||||
<p>Filtres utiles : Nombres de mois, Projet, Service</p>
|
||||
</div>
|
||||
</div>
|
||||
<p></p>
|
||||
{% endblock %}
|
Reference in New Issue
Block a user