JourneeController.php
<?php
namespace Override\\Controller;
use App\\Service\\EZDS_Date;
use App\\Service\\EZDS_Document;
use App\\Service\\EZDS_Ezged;
use App\\Service\\EZDS_Log;
use App\\Service\\EZDS_Parametre;
use App\\Service\\EZDS_Pdf;
use App\\Service\\EZDS_Pdo;
use App\\Service\\EZDS_Query;
use App\\Service\\EZDS_Session;
use App\\Service\\EZDS_String;
use App\\Service\\EZDS_User;
use Override\\Service\\EZDS_Custom;
use Override\\Service\\EZDS_journee;
use Symfony\\Bundle\\FrameworkBundle\\Controller\\AbstractController;
use Symfony\\Component\\HttpFoundation\\Request;
use Symfony\\Component\\HttpFoundation\\Response;
use Symfony\\Component\\Routing\\Annotation\\Route;
use Doctrine\\ORM\\EntityManagerInterface;
use Symfony\\Component\\DependencyInjection\\Container;
use Symfony\\Component\\HttpFoundation\\RequestStack;
use Symfony\\Component\\Routing\\Generator\\UrlGeneratorInterface;
use PhpOffice\\PhpSpreadsheet\\Spreadsheet;
use PhpOffice\\PhpSpreadsheet\\Style\\Alignment;
use PhpOffice\\PhpSpreadsheet\\Writer\\Csv;
use PhpOffice\\PhpSpreadsheet\\Writer\\Ods;
use PhpOffice\\PhpSpreadsheet\\Writer\\Xlsx;
use PhpOffice\\PhpSpreadsheet\\Cell\\DataType;
class JourneeController extends AbstractController
{
private $ezds_string;
private $ezds_query;
private $requestStack;
private $em;
private $project_dir;
private $stockage_dir;
private $realip;
private $ezds_custom;
public function __construct(EZDS_Custom $ezds_custom, EZDS_String $ezds_string, EntityManagerInterface $em, EZDS_Query $ezds_query, Container $container, RequestStack $requestStack)
{
$this->em = $em;
$this->ezds_custom = $ezds_custom;
$this->project_dir = $container->getParameter('kernel.project_dir');
$this->stockage_dir = $this->project_dir . "/override/var/tmp/client";
@mkdir($this->stockage_dir);
// --- Init realip
$this->realip = "127.0.0.1";
if (!empty($_SERVER['REMOTE_ADDR']) && $_SERVER['REMOTE_ADDR'] != "::1") {
$this->realip = $_SERVER['REMOTE_ADDR'];
}
}
/**
* @Route("/journee/jour1", name="journee_jour10")
* @Route("/journee/jour1/{annee}", name="journee_jour12")
* @Route("/journee/jour1/{annee}/{mois}", name="journee_jour11")
*/
public function jour1(Request $request, $annee = "", $mois = "", EZDS_journee $journee)
{
$data = $journee->getDataFactures($annee, $mois);
return $this->render('@override/journee/jour1.html.twig', [
'data' => $data,
]);
}
/**
* @Route("/journee/jour2", name="journee_jour2")
*/
public function jour2()
{
$result = $this->em->getConnection()->fetchAllAssociative(
"select * from ez_facture_fournisseur where EZ_FACTURE_FOURNISSEUR_ID = ? AND toto = ?", [
122, 2
]);
dd($result);
echo "JOUR2";
exit();
}
}
EZDS_journee.php
<?php
namespace Override\\Service;
use Doctrine\\ORM\\EntityManagerInterface;
class EZDS_journee
{
private $em;
public function __construct(EntityManagerInterface $em) {
$this->em = $em;
return $this;
}
public function getDataFactures($annee, $mois){
$data = [
"annee" => $annee,
"mois" => $mois,
"legendes" => [],
"data" => [],
];
$result = $this->em->getConnection()->fetchAllAssociative("select * from ez_facture_fournisseur WHERE EZ_FACTURE_FOURNISSEUR_DATE_PIECE > ?", [0]);
if ( count($result)>0){
foreach( $result as $row ){
$annee_facture = substr($row["EZ_FACTURE_FOURNISSEUR_DATE_PIECE"], 0, 4);
if ( !isset($data["legendes"][$annee_facture])){
$data["legendes"][$annee_facture] = $annee_facture;
}
if ( !isset($data["data"][$annee_facture])){
$data["data"][$annee_facture] = 0;
}
if ( isset($row["EZ_FACTURE_FOURNISSEUR_MONTANT_TTC"]) ){
$data["data"][$annee_facture] = $data["data"][$annee_facture] + $row["EZ_FACTURE_FOURNISSEUR_MONTANT_TTC"];
}
$data["data"][$annee_facture] += isset($row["EZ_FACTURE_FOURNISSEUR_MONTANT_TTC"])?$row["EZ_FACTURE_FOURNISSEUR_MONTANT_TTC"]:0;
}
}
return $data;
}
}
_tableau.html.twig
<div class="relative overflow-x-auto">
<table class="w-full text-sm text-left rtl:text-right text-gray-500 dark:text-gray-400">
<thead class="text-xs text-gray-700 uppercase bg-gray-50 dark:bg-gray-700 dark:text-gray-400">
<tr>
{% for i in data.legendes %}
<th scope="col" class="px-6 py-3">
{{ i }}
</th>
{% endfor %}
</tr>
</thead>
<tbody>
<tr class="bg-white border-b dark:bg-gray-800 dark:border-gray-700">
{% for i in data.data %}
<th scope="row" class="px-6 py-4 font-medium text-gray-900 whitespace-nowrap dark:text-white">
{{ i|number_format(2, '.', ' ') }} €
</th>
{% endfor %}
</tr>
</tbody>
</table>
</div>
jour1.html.twig
{% extends 'tailwindcss.html.twig' %}
{% block body %}
Nous sommes
{% if data.mois is defined %}
{{ data.mois }}
{% endif %}
{% if data.annee is defined %}
{{ data.annee }}
{% endif %}
{{ include('@override/journee/_tableau.html.twig', { data: data }) }}
{% endblock %}
{% block javascript %}
{% endblock %}