```
✨ feat(Devis): Ajoute options, dates début/fin et améliore affichage PDF
Ajoute les champs date de début et fin au devis. Permet l'ajout d'options au devis. Améliore l'affichage du PDF.
```
This commit is contained in:
@@ -5,6 +5,7 @@ namespace App\Controller\Dashboard;
|
||||
use App\Entity\CustomerAddress;
|
||||
use App\Entity\Devis;
|
||||
use App\Entity\DevisLine;
|
||||
use App\Entity\DevisOptions;
|
||||
use App\Event\Signature\DevisSend;
|
||||
use App\Form\NewDevisType;
|
||||
use App\Logger\AppLogger;
|
||||
@@ -12,9 +13,11 @@ use App\Repository\AccountRepository;
|
||||
use App\Repository\CustomerAddressRepository;
|
||||
use App\Repository\CustomerRepository;
|
||||
use App\Repository\DevisRepository;
|
||||
use App\Repository\OptionsRepository;
|
||||
use App\Repository\ProductRepository;
|
||||
use App\Service\Pdf\DevisPdfService;
|
||||
use App\Service\Signature\Client;
|
||||
use DateTimeImmutable;
|
||||
use Doctrine\ORM\EntityManagerInterface;
|
||||
use Knp\Bundle\PaginatorBundle\KnpPaginatorBundle;
|
||||
use Knp\Component\Pager\PaginatorInterface;
|
||||
@@ -40,6 +43,7 @@ class DevisController extends AbstractController
|
||||
AppLogger $appLogger,
|
||||
PaginatorInterface $paginator,
|
||||
Request $request,
|
||||
KernelInterface $kernel,
|
||||
|
||||
): Response {
|
||||
|
||||
@@ -77,7 +81,7 @@ class DevisController extends AbstractController
|
||||
]);
|
||||
}
|
||||
#[Route(path: '/crm/devis/add', name: 'app_crm_devis_add', options: ['sitemap' => false], methods: ['GET','POST'])]
|
||||
public function devisAdd(Client $client,EventDispatcherInterface $eventDispatcher,KernelInterface $kernel,CustomerAddressRepository $customerAddress,ProductRepository $productRepository,EntityManagerInterface $entityManager,CustomerRepository $customerRepository,DevisRepository $devisRepository, AppLogger $appLogger,Request $request): Response
|
||||
public function devisAdd(Client $client,OptionsRepository $optionsRepository,EventDispatcherInterface $eventDispatcher,KernelInterface $kernel,CustomerAddressRepository $customerAddress,ProductRepository $productRepository,EntityManagerInterface $entityManager,CustomerRepository $customerRepository,DevisRepository $devisRepository, AppLogger $appLogger,Request $request): Response
|
||||
{
|
||||
$devisNumber ="DEVIS-".sprintf('%05d',$devisRepository->count()+1);
|
||||
$appLogger->record('VIEW', 'Consultation de la création d\'un devis');
|
||||
@@ -90,9 +94,12 @@ class DevisController extends AbstractController
|
||||
|
||||
$form = $this->createForm(NewDevisType::class,$devis);
|
||||
if($request->isMethod('POST')){
|
||||
|
||||
$devis->setStartAt( new DateTimeImmutable($_POST['new_devis']['startAt']));
|
||||
$devis->setEndAt( new DateTimeImmutable($_POST['new_devis']['endAt']));
|
||||
$devis->setBillAddress($customerAddress->find($_POST['devis']['bill_address']));
|
||||
$devis->setAddressShip($customerAddress->find($_POST['devis']['ship_address']));
|
||||
$devis->setCustomer($customerRepository->find($_POST['new_devis']['customer']));
|
||||
$devis->setCustomer($customerRepository->find($_POST['new_devis']['customer']));
|
||||
foreach ($_POST['lines'] as $cd=>$line) {
|
||||
$rLine = new DevisLine();
|
||||
$rLine->setDevi($devis);
|
||||
@@ -101,16 +108,22 @@ class DevisController extends AbstractController
|
||||
$rLine->setDay($line['days']);
|
||||
$rLine->setPriceHt(floatval($line['price_ht']));
|
||||
$rLine->setPriceHtSup(floatval($line['price_sup_ht']));
|
||||
$rLine->setStartAt(\DateTimeImmutable::createFromFormat('Y-m-d',$line['date_start']));
|
||||
$rLine->setEndAt(\DateTimeImmutable::createFromFormat('Y-m-d',$line['date_end']));
|
||||
$entityManager->persist($rLine);
|
||||
}
|
||||
foreach ($_POST['options'] as $line) {
|
||||
$rLineOptions = new DevisOptions();
|
||||
$rLineOptions->setDevis($devis);
|
||||
$rLineOptions->setOption($optionsRepository->find($line['product_id']));
|
||||
$rLineOptions->setPriceHt(floatval($line['price_ht']));
|
||||
$entityManager->persist($rLineOptions);
|
||||
}
|
||||
$entityManager->persist($devis);
|
||||
|
||||
$entityManager->flush();
|
||||
|
||||
$docusealService = new DevisPdfService($kernel, $devis, true);
|
||||
$contentDocuseal = $docusealService->generate();
|
||||
|
||||
|
||||
$tmpPathDocuseal = sys_get_temp_dir() . '/docuseal_' . uniqid() . '.pdf';
|
||||
file_put_contents($tmpPathDocuseal, $contentDocuseal);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user