Création de la gestion des catégorie
This commit is contained in:
@@ -20,6 +20,7 @@ use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
|
||||
use Symfony\Component\EventDispatcher\EventDispatcherInterface;
|
||||
use Symfony\Component\HttpFoundation\File\UploadedFile;
|
||||
use Symfony\Component\HttpFoundation\Request;
|
||||
use Symfony\Component\HttpFoundation\RequestStack;
|
||||
use Symfony\Component\HttpFoundation\Response;
|
||||
use Symfony\Component\HttpKernel\KernelInterface;
|
||||
use Symfony\Component\Routing\Attribute\Route;
|
||||
@@ -29,16 +30,16 @@ use Symfony\Contracts\HttpClient\HttpClientInterface;
|
||||
class FlowController extends AbstractController
|
||||
{
|
||||
public function __construct(
|
||||
private readonly AppLogger $appLogger,
|
||||
private readonly OrderSessionRepository $orderSessionRepository,
|
||||
private readonly HttpClientInterface $client,
|
||||
private readonly DevisRepository $devisRepository,
|
||||
private readonly ProductRepository $productRepository,
|
||||
private readonly OptionsRepository $optionsRepository,
|
||||
private readonly PrestaireRepository $prestaireRepository,
|
||||
private readonly KernelInterface $kernel,
|
||||
private readonly Client $signatureClient,
|
||||
private readonly EventDispatcherInterface $eventDispatcher
|
||||
private readonly AppLogger $appLogger,
|
||||
private readonly OrderSessionRepository $orderSessionRepository,
|
||||
private readonly HttpClientInterface $client,
|
||||
private readonly DevisRepository $devisRepository,
|
||||
private readonly ProductRepository $productRepository,
|
||||
private readonly OptionsRepository $optionsRepository,
|
||||
private readonly PrestaireRepository $prestaireRepository,
|
||||
private readonly KernelInterface $kernel,
|
||||
private readonly Client $signatureClient,
|
||||
private readonly EventDispatcherInterface $eventDispatcher, private readonly RequestStack $requestStack
|
||||
) {
|
||||
}
|
||||
|
||||
@@ -107,21 +108,34 @@ class FlowController extends AbstractController
|
||||
|
||||
return $this->redirectToRoute('app_crm_flow_view', ['id' => $session->getId()]);
|
||||
}
|
||||
#[Route('/allow/rv', name: 'app_crm_flow_allow_rv', methods: ['GET'])]
|
||||
public function allowRv(\Doctrine\ORM\EntityManagerInterface $em): Response
|
||||
{
|
||||
$ids = $this->requestStack->getMainRequest()->query->get('idS');
|
||||
/** @var Devis $devisItem */
|
||||
$devisItem = $this->devisRepository->find($ids);
|
||||
sleep(5);
|
||||
|
||||
$session = $devisItem->getOrderSession();
|
||||
|
||||
// 10. DocuSeal Submission
|
||||
$this->signatureClient->createSubmissionDevis($devisItem);
|
||||
|
||||
// 11. Send Email
|
||||
$this->eventDispatcher->dispatch(new DevisSend($devisItem));
|
||||
|
||||
// 10. Update Session
|
||||
$session->setState('allow');
|
||||
$em->flush();
|
||||
|
||||
$this->addFlash('success', 'La réservation a été validée et le devis ' . $devisItem->getNum() . ' a été créé.');
|
||||
return $this->redirectToRoute('app_crm_flow');
|
||||
|
||||
}
|
||||
#[Route('/allow/{id}', name: 'app_crm_flow_allow', methods: ['GET'])]
|
||||
public function allow(\App\Entity\OrderSession $session, \Doctrine\ORM\EntityManagerInterface $em): Response
|
||||
{
|
||||
$devis = $session->getDevis();
|
||||
if($devis instanceof Devis) {
|
||||
foreach ($devis->getDevisLines() as $line) {
|
||||
$em->remove($line);
|
||||
}
|
||||
foreach ($devis->getDevisLines() as $line) {
|
||||
$em->remove($line);
|
||||
}
|
||||
$em->remove($devis);
|
||||
$em->flush();
|
||||
}
|
||||
|
||||
// 1. Create Devis
|
||||
$devis = new Devis();
|
||||
$devisNumber = "DEVIS-" . sprintf('%05d', $this->devisRepository->count() + 1);
|
||||
@@ -257,35 +271,7 @@ class FlowController extends AbstractController
|
||||
$em->persist($devis);
|
||||
$em->flush();
|
||||
|
||||
// 9. Generate PDFs
|
||||
try {
|
||||
// DocuSeal
|
||||
$docusealService = new DevisPdfService($this->kernel, $devis, $this->productRepository, true);
|
||||
$this->savePdfFile($devis, $docusealService->generate(), 'dc_', 'setDevisDocuSealFile');
|
||||
|
||||
// Internal
|
||||
$devisService = new DevisPdfService($this->kernel, $devis, $this->productRepository, false);
|
||||
$this->savePdfFile($devis, $devisService->generate(), 'devis_', 'setDevisFile');
|
||||
|
||||
$em->flush();
|
||||
|
||||
// 10. DocuSeal Submission
|
||||
$this->signatureClient->createSubmissionDevis($devis);
|
||||
|
||||
// 11. Send Email
|
||||
$this->eventDispatcher->dispatch(new DevisSend($devis));
|
||||
|
||||
} catch (\Exception $e) {
|
||||
$this->appLogger->record('ERROR', 'Erreur génération PDF Devis auto: ' . $e->getMessage());
|
||||
}
|
||||
|
||||
// 10. Update Session
|
||||
$session->setState('allow');
|
||||
$em->flush();
|
||||
|
||||
$this->addFlash('success', 'La réservation a été validée et le devis ' . $devis->getNum() . ' a été créé.');
|
||||
|
||||
return $this->redirectToRoute('app_crm_flow_allow',['id']);
|
||||
return $this->redirectToRoute('app_crm_flow_allow_rv',['id' => $devis->getId(),'idS'=>$devis->getId()]);
|
||||
}
|
||||
|
||||
#[Route('/delete/{id}', name: 'app_crm_flow_delete', methods: ['GET'])]
|
||||
|
||||
Reference in New Issue
Block a user