<?php
// src/Controller/AideController.php
namespace App\Controller;
use App\Entity\CategorieArticleAide;
use App\Entity\ArticleAide;
use App\Entity\Ticket;
use App\Form\TicketType;
use App\Entity\CommentaireTicket;
use App\Form\CommentaireTicketType;
use App\Entity\ValiditeService;
use Symfony\Component\HttpFoundation\Response;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\Routing\Annotation\Route;
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
/**
* @Route("/{_locale}/n_dk5_dok")
*/
class ManagementController extends AbstractController
{
/**
* @Route("/", name="management_index")
*/
public function indexAction()
{
$em = $this->getDoctrine()->getManager();
return $this->render('management/index.html.twig', [
]);
}
/**
* @Route("/tickets", name="management.tickets")
*/
public function ticketsAction()
{
$em = $this->getDoctrine()->getManager();
$tickets = $em->getRepository(Ticket::class)
->listeTicket();
return $this->render('management/tickets.html.twig', [
'tickets' => $tickets
]);
}
/**
* @Route("/display-ticket/{id}", name="management.display_ticket")
* @return \Symfony\Component\HttpFoundation\Response
*/
public function displayTicketAction(Request $request, Ticket $ticket)
{
$em = $this->getDoctrine()
->getManager();
$boutique = $ticket->getBoutique();
$user = $this->getUser();
$commentaires = $em->getRepository(CommentaireTicket::class)
->findByTicket($ticket->getId());
$commentaireTicket = new CommentaireTicket;
$user = $this->getUser();
$form = $this->createForm(CommentaireTicketType::class, $commentaireTicket);
$ok_soumission = '';
$error = '';
if($request->getMethod() == 'POST'){
$form->handleRequest($request);
if($form->isValid()){
$commentaireTicket->setTicket($ticket);
$commentaireTicket->setUser($user);
$em->persist($commentaireTicket);
$em->flush();
$commentaires = $em->getRepository(CommentaireTicket::class)
->findByTicket($ticket->getId());
$ok_soumission =" Votre message a été pris en compte";
$commentaireTicket = new CommentaireTicket;
$form = $this->createForm(CommentaireTicketType::class, $commentaireTicket);
} else {
$error =" Veillez corrigez vos erreurs";
}
}
return $this->render('management/display_ticket.html.twig', [
'boutique' => $boutique,
'ticket' => $ticket,
'form' => $form->createView(),
'commentaires' => $commentaires
]);
}
/**
* @Route("/sales", name="management.sales")
* @return \Symfony\Component\HttpFoundation\Response
*/
public function salesAction(Request $request)
{
$em = $this->getDoctrine()
->getManager();
$user = $this->getUser();
$sales = $em->getRepository(ValiditeService::class)
->lastSales();
return $this->render('management/sales.html.twig', [
'sales' => $sales
]);
}
}