Controller
<?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;
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->ezds_string = $ezds_string;
$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("/ticket/create", name="ticket_create")
*/
public function create(
UrlGeneratorInterface $urlgenerator,
EZDS_Ezged $ezds_ezged,
EZDS_Query $ezds_query,
Request $request,
$annee = "",
$mois = "",
EZDS_journee $journee,
EZDS_String $ezds_string,
EZDS_Session $ezds_session
) {
$ezds_session->initFromEzGED();
$data = [
"lib" => "",
"journees" => $journee->getDataFactures(2024, 11),
];
if ($request->isMethod('POST')) {
$save = true;
$data["lib"] = $request->request->get('lib');
$data["password"] = $request->request->get('password');
/*if (!filter_var($data["email"], FILTER_VALIDATE_EMAIL)) {
$this->addFlash("error", "Email incorrect");
$save = false;
}*/
if ($save) {
// Connexion - update bdd
$this->em->getConnection()->insert(
'ez_ticket',
[
'EZ_TICKET_LIB' => $data["lib"],
'EZ_TICKET_ETATID' => 1,
//'EZ_TICKET_CREATEDAT' => date("Y-m-d")
]
);
$ticketid = $this->em->getConnection()->lastInsertId();
return $this->redirect($urlgenerator->generate('ticket_edit', ["ticketid" => $ezds_string->encrypt($ticketid)], UrlGeneratorInterface::ABSOLUTE_URL));
}
}
return $this->render('@override/journee/create.html.twig', [
"data" => $data,
]);
}
/**
* @Route("/ticket/edit/{ticketid}", name="ticket_edit")
*/
public function edit($ticketid)
{
$ticketid = $this->ezds_string->decrypt($ticketid);
$ticket = $this->em->getConnection()->fetchAllAssociative("SELECT * FROM ez_ticket WHERE EZ_TICKET_ID = ?", [$ticketid]);
dd($ticket[0]);
}
}
Template override/journee/create.html.twig
{% extends 'tailwindcss.html.twig' %}
{% block body %}
{% for message in app.flashes('success') %}
<div class="p-4 mb-4 text-sm text-green-800 rounded-lg bg-green-50 dark:bg-gray-800 dark:text-green-400" role="alert">
<span class="font-medium">Success alert!</span> {{ message }}.
</div>
{% endfor %}
{% for message in app.flashes('error') %}
<div class="p-4 mb-4 text-sm text-red-800 rounded-lg bg-red-50 dark:bg-gray-800 dark:text-red-400" role="alert">
<span class="font-medium">Danger alert!</span> {{ message }}.
</div>
{% endfor %}
<div class="mt-4">
<form class="max-w-sm mx-auto" method="post">
<div class="mb-5">
<label for="lib" class="block mb-2 text-sm font-medium text-gray-900 dark:text-white">Titre</label>
<input name="lib" value="{{ data.lib }}" type="text" id="lib" class="bg-gray-50 border border-gray-300 text-gray-900 text-sm rounded-lg focus:ring-blue-500 focus:border-blue-500 block w-full p-2.5 dark:bg-gray-700 dark:border-gray-600 dark:placeholder-gray-400 dark:text-white dark:focus:ring-blue-500 dark:focus:border-blue-500" placeholder="" required />
</div>
<button type="submit" class="text-white bg-blue-700 hover:bg-blue-800 focus:ring-4 focus:outline-none focus:ring-blue-300 font-medium rounded-lg text-sm w-full sm:w-auto px-5 py-2.5 text-center dark:bg-blue-600 dark:hover:bg-blue-700 dark:focus:ring-blue-800">Submit</button>
</form>
</div>
{% endblock %}
{% block javascript %}
{% endblock %}