✨ feat(EcheanceEventSusbriber): Génère et enregistre le PDF d'échéance.
⚙️ chore(vich_uploader.yaml): Ajoute la configuration pour l'upload des échéances. ✅ feat(CustomerSplit): Ajoute les champs pour gérer l'upload du fichier d'échéance.
This commit is contained in:
@@ -64,6 +64,13 @@ vich_uploader:
|
||||
inject_on_load: false
|
||||
delete_on_update: true
|
||||
delete_on_remove: true
|
||||
echeance:
|
||||
uri_prefix: /storage/echeance
|
||||
upload_destination: '%kernel.project_dir%/public/storage/echeance'
|
||||
namer: Vich\UploaderBundle\Naming\SmartUniqueNamer # Replaced namer
|
||||
inject_on_load: false
|
||||
delete_on_update: true
|
||||
delete_on_remove: true
|
||||
#mappings:
|
||||
# products:
|
||||
# uri_prefix: /images/products
|
||||
|
||||
43
migrations/Version20251009094128.php
Normal file
43
migrations/Version20251009094128.php
Normal file
@@ -0,0 +1,43 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace DoctrineMigrations;
|
||||
|
||||
use Doctrine\DBAL\Schema\Schema;
|
||||
use Doctrine\Migrations\AbstractMigration;
|
||||
|
||||
/**
|
||||
* Auto-generated Migration: Please modify to your needs!
|
||||
*/
|
||||
final class Version20251009094128 extends AbstractMigration
|
||||
{
|
||||
public function getDescription(): string
|
||||
{
|
||||
return '';
|
||||
}
|
||||
|
||||
public function up(Schema $schema): void
|
||||
{
|
||||
// this up() migration is auto-generated, please modify it to your needs
|
||||
$this->addSql('ALTER TABLE customer_split ADD ech_file_name VARCHAR(255) DEFAULT NULL');
|
||||
$this->addSql('ALTER TABLE customer_split ADD ech_dimensions JSON DEFAULT NULL');
|
||||
$this->addSql('ALTER TABLE customer_split ADD ech_size VARCHAR(255) DEFAULT NULL');
|
||||
$this->addSql('ALTER TABLE customer_split ADD ech_mine_type VARCHAR(255) DEFAULT NULL');
|
||||
$this->addSql('ALTER TABLE customer_split ADD ech_original_name VARCHAR(255) DEFAULT NULL');
|
||||
$this->addSql('ALTER TABLE customer_split ADD update_at TIMESTAMP(0) WITHOUT TIME ZONE DEFAULT NULL');
|
||||
$this->addSql('COMMENT ON COLUMN customer_split.update_at IS \'(DC2Type:datetime_immutable)\'');
|
||||
}
|
||||
|
||||
public function down(Schema $schema): void
|
||||
{
|
||||
// this down() migration is auto-generated, please modify it to your needs
|
||||
$this->addSql('CREATE SCHEMA public');
|
||||
$this->addSql('ALTER TABLE customer_split DROP ech_file_name');
|
||||
$this->addSql('ALTER TABLE customer_split DROP ech_dimensions');
|
||||
$this->addSql('ALTER TABLE customer_split DROP ech_size');
|
||||
$this->addSql('ALTER TABLE customer_split DROP ech_mine_type');
|
||||
$this->addSql('ALTER TABLE customer_split DROP ech_original_name');
|
||||
$this->addSql('ALTER TABLE customer_split DROP update_at');
|
||||
}
|
||||
}
|
||||
@@ -7,8 +7,11 @@ use Doctrine\Common\Collections\ArrayCollection;
|
||||
use Doctrine\Common\Collections\Collection;
|
||||
use Doctrine\DBAL\Types\Types;
|
||||
use Doctrine\ORM\Mapping as ORM;
|
||||
use Symfony\Component\HttpFoundation\File\File;
|
||||
use Vich\UploaderBundle\Mapping\Annotation as Vich;
|
||||
|
||||
#[ORM\Entity(repositoryClass: CustomerSplitRepository::class)]
|
||||
#[Vich\Uploadable()]
|
||||
class CustomerSplit
|
||||
{
|
||||
#[ORM\Id]
|
||||
@@ -43,6 +46,23 @@ class CustomerSplit
|
||||
#[ORM\Column(length: 255,nullable: true)]
|
||||
private ?string $submissionId = null;
|
||||
|
||||
#[Vich\UploadableField(mapping: 'echeance',fileNameProperty: 'echFileName', size: 'echSize', mimeType: 'echMineType', originalName: 'echOriginalName',dimensions: 'echDimensions')]
|
||||
private ?File $ech = null;
|
||||
|
||||
#[ORM\Column(nullable: true)]
|
||||
private ?string $echFileName = null;
|
||||
#[ORM\Column(nullable: true)]
|
||||
private ?array $echDimensions = [];
|
||||
#[ORM\Column(length: 255,nullable: true)]
|
||||
private ?string $echSize = null;
|
||||
#[ORM\Column(length: 255,nullable: true)]
|
||||
private ?string $echMineType = null;
|
||||
#[ORM\Column(length: 255,nullable: true)]
|
||||
private ?string $echOriginalName = null;
|
||||
|
||||
#[ORM\Column(nullable: true)]
|
||||
private ?\DateTimeImmutable $updateAt;
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
$this->customerSplitLines = new ArrayCollection();
|
||||
@@ -166,4 +186,116 @@ class CustomerSplit
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return \DateTimeImmutable|null
|
||||
*/
|
||||
public function getUpdateAt(): ?\DateTimeImmutable
|
||||
{
|
||||
return $this->updateAt;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return File|null
|
||||
*/
|
||||
public function getEch(): ?File
|
||||
{
|
||||
return $this->ech;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return array|null
|
||||
*/
|
||||
public function getEchDimensions(): ?array
|
||||
{
|
||||
return $this->echDimensions;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string|null
|
||||
*/
|
||||
public function getEchFileName(): ?string
|
||||
{
|
||||
return $this->echFileName;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string|null
|
||||
*/
|
||||
public function getEchMineType(): ?string
|
||||
{
|
||||
return $this->echMineType;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string|null
|
||||
*/
|
||||
public function getEchOriginalName(): ?string
|
||||
{
|
||||
return $this->echOriginalName;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string|null
|
||||
*/
|
||||
public function getEchSize(): ?string
|
||||
{
|
||||
return $this->echSize;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param \DateTimeImmutable|null $updateAt
|
||||
*/
|
||||
public function setUpdateAt(?\DateTimeImmutable $updateAt): void
|
||||
{
|
||||
$this->updateAt = $updateAt;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param File|null $ech
|
||||
*/
|
||||
public function setEch(?File $ech): void
|
||||
{
|
||||
$this->ech = $ech;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param array|null $echDimensions
|
||||
*/
|
||||
public function setEchDimensions(?array $echDimensions): void
|
||||
{
|
||||
$this->echDimensions = $echDimensions;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string|null $echFileName
|
||||
*/
|
||||
public function setEchFileName(?string $echFileName): void
|
||||
{
|
||||
$this->echFileName = $echFileName;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string|null $echMineType
|
||||
*/
|
||||
public function setEchMineType(?string $echMineType): void
|
||||
{
|
||||
$this->echMineType = $echMineType;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string|null $echOriginalName
|
||||
*/
|
||||
public function setEchOriginalName(?string $echOriginalName): void
|
||||
{
|
||||
$this->echOriginalName = $echOriginalName;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string|null $echSize
|
||||
*/
|
||||
public function setEchSize(?string $echSize): void
|
||||
{
|
||||
$this->echSize = $echSize;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -4,15 +4,19 @@ namespace App\Service\Echeance;
|
||||
|
||||
use App\Service\Docuseal\SignClient;
|
||||
use App\Service\Pdf\EchPdfDetails;
|
||||
use Doctrine\ORM\EntityManagerInterface;
|
||||
use Symfony\Component\EventDispatcher\Attribute\AsEventListener;
|
||||
use Symfony\Component\HttpFoundation\File\UploadedFile;
|
||||
use Symfony\Component\HttpKernel\KernelInterface;
|
||||
use Symfony\Component\Uid\Uuid;
|
||||
|
||||
#[AsEventListener(event: EventEcheanceCreated::class, method: 'onEventEcheanceCreated')]
|
||||
class EcheanceEventSusbriber
|
||||
{
|
||||
public function __construct(
|
||||
private readonly SignClient $signClient,
|
||||
private readonly KernelInterface $kernel
|
||||
private readonly KernelInterface $kernel,
|
||||
private readonly EntityManagerInterface $entityManager,
|
||||
){
|
||||
}
|
||||
|
||||
@@ -21,7 +25,17 @@ class EcheanceEventSusbriber
|
||||
|
||||
$pdf = new EchPdfDetails($this->kernel,$ech);
|
||||
$pdf->generated();
|
||||
$content = $pdf->Output('I');
|
||||
dd($content);
|
||||
$content = $pdf->Output('S');
|
||||
|
||||
$tmpname = Uuid::v4().".pdf";
|
||||
$dir = sys_get_temp_dir().'/'.$tmpname;
|
||||
file_put_contents($dir,$content);
|
||||
$upload = new UploadedFile($dir,"ech-".$ech->getNum().".pdf","application/pdf",0,true);
|
||||
$ech->setEch($upload);
|
||||
$ech->setUpdateAt(new \DateTimeImmutable("now"));
|
||||
|
||||
$this->entityManager->persist($ech);
|
||||
$this->entityManager->flush();
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user