diff --git a/.env b/.env index 5e4a80f..0b234e8 100644 --- a/.env +++ b/.env @@ -51,7 +51,7 @@ PATH_URL=https://esyweb.local STRIPE_PK=pk_test_51SUA22173W4aeFB1nO6oFfDZ12HOTffDKtCshhZ8rkUg6kUO2ZaQC0tK72rhE79Tr8treeHX9KMcZtvcQZ0X8VSm00Q6GQ365V STRIPE_SK=sk_test_51SUA22173W4aeFB16EB2LxGI0hNvNJzFshDI98zRImWBIhSfzqOGAz5TlPxSpUWbj3x4COm6kmSsaal9FpQR1A7M0022DvjbbR STRIPE_WEBHOOKS_SIGN=whsec_0DOZJAwgMwkcHl2RWXI8h8YItj9q7v3A -DEV_URL=https://f584469e204f.ngrok-free.app +DEV_URL=https://265fcc9dd2a6.ngrok-free.app VAPID_PK=DsOg7jToRSD-VpNSV1Gt3YAhSwz4l-nqeu7yFvzbSxg VAPID_PC=BKz0kdcsG6kk9KxciPpkfP8kEDAd408inZecij5kBDbQ1ZGZSNwS4KZ8FerC28LFXvgSqpDXtor3ePo0zBCdNqo diff --git a/composer.json b/composer.json index 5a4e58d..f2f5446 100644 --- a/composer.json +++ b/composer.json @@ -16,6 +16,7 @@ "doctrine/doctrine-bundle": "^2.18.1", "doctrine/doctrine-migrations-bundle": "^3.6.0", "doctrine/orm": "^3.5.7", + "docusealco/docuseal-php": "^1.0", "endroid/qr-code": ">=6.0.9", "exbil/mailcow-php-api": ">=0.14.2", "fpdf/fpdf": ">=1.86", diff --git a/composer.lock b/composer.lock index a3cbb9a..7ba6202 100644 --- a/composer.lock +++ b/composer.lock @@ -4,7 +4,7 @@ "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies", "This file is @generated automatically" ], - "content-hash": "64d249aa5dd90b9e31a7e0f42b311e18", + "content-hash": "d9f711e9feb3143e77672af962c889c8", "packages": [ { "name": "async-aws/core", @@ -2026,6 +2026,42 @@ }, "time": "2025-10-26T09:35:14+00:00" }, + { + "name": "docusealco/docuseal-php", + "version": "1.0.5", + "source": { + "type": "git", + "url": "https://github.com/docusealco/docuseal-php.git", + "reference": "f12a490e95bdb13ef61f46b72dffcdc646d8b0a4" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/docusealco/docuseal-php/zipball/f12a490e95bdb13ef61f46b72dffcdc646d8b0a4", + "reference": "f12a490e95bdb13ef61f46b72dffcdc646d8b0a4", + "shasum": "" + }, + "type": "library", + "autoload": { + "psr-4": { + "Docuseal\\": "src/" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "DocuSeal" + } + ], + "description": "PHP bindings for DocuSeal API", + "support": { + "issues": "https://github.com/docusealco/docuseal-php/issues", + "source": "https://github.com/docusealco/docuseal-php/tree/1.0.5" + }, + "time": "2025-09-14T21:27:12+00:00" + }, { "name": "egulias/email-validator", "version": "4.0.4", diff --git a/migrations/Version20251123175729.php b/migrations/Version20251123175729.php new file mode 100644 index 0000000..525905f --- /dev/null +++ b/migrations/Version20251123175729.php @@ -0,0 +1,32 @@ +addSql('ALTER TABLE ag_main ADD is_signed BOOLEAN DEFAULT NULL'); + } + + 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 ag_main DROP is_signed'); + } +} diff --git a/migrations/Version20251123180010.php b/migrations/Version20251123180010.php new file mode 100644 index 0000000..b3b1dda --- /dev/null +++ b/migrations/Version20251123180010.php @@ -0,0 +1,32 @@ +addSql('ALTER TABLE ag_main ADD submiter_id VARCHAR(255) DEFAULT NULL'); + } + + 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 ag_main DROP submiter_id'); + } +} diff --git a/src/Controller/Admin/AdminController.php b/src/Controller/Admin/AdminController.php index d356344..20906d1 100644 --- a/src/Controller/Admin/AdminController.php +++ b/src/Controller/Admin/AdminController.php @@ -34,6 +34,7 @@ use Psr\EventDispatcher\EventDispatcherInterface; use Symfony\Bundle\FrameworkBundle\Controller\AbstractController; use Symfony\Component\HttpFoundation\File\UploadedFile; use Symfony\Component\HttpFoundation\JsonResponse; +use Symfony\Component\HttpFoundation\RedirectResponse; use Symfony\Component\HttpFoundation\Request; use Symfony\Component\HttpFoundation\Response; use Symfony\Component\HttpKernel\KernelInterface; @@ -240,16 +241,62 @@ class AdminController extends AbstractController #[Route(path: '/admin/ag', name: 'admin_ag', options: ['sitemap' => false], methods: ['GET'])] public function adminAg(UploaderHelper $uploaderHelper,KernelInterface $kernel,EntityManagerInterface $entityManager,Request $request,MainRepository $mainRepository): Response { + + if($request->query->has('idValidateSign')) { + /** @var Main $main */ + $main = $mainRepository->find($request->query->get('idValidateSign')); + $docuseal = new \Docuseal\Api('pgAU116mCFmeF7WQSezHqxtZW8V1fgo31u5d2FXoaKe', 'https://signature.esy-web.dev/api'); + $sub = $docuseal->getSubmitter($main->getSubmiterId()); + $link = $sub['documents'][0]['url']; + $content = file_get_contents($link); + $fileName = 'ag_sign_ecosplay_' . $main->getAgDateAt()->format('Ymd') . '.pdf'; + $tempFilePath = sys_get_temp_dir() . DIRECTORY_SEPARATOR . $fileName; + file_put_contents($tempFilePath, $content); + $file = new UploadedFile($tempFilePath,$fileName,"application/pdf",0,true); + $main->setAg($file); + $main->setUpdateAt(new \DateTimeImmutable()); + $main->setIsSigned(true); + $entityManager->persist($main); + $entityManager->flush(); + return $this->redirectToRoute('admin_ag'); + } if($request->query->has('idSign')) { /** @var Main $main */ $main = $mainRepository->find($request->query->get('id')); $url = $uploaderHelper->asset($main,'ag'); - if($_ENV['APP_ENV'] == "prod") - $url = $request->getContentTypeFormat().$url; - else - $url = $_ENV['DEV_URL'].$url; - dd($url); + if($_ENV['APP_ENV'] == "prod") { + $url = $request->getContentTypeFormat() . $url; + $urlRoot = $request->getContentTypeFormat(); + } else { + $url = $_ENV['DEV_URL'] . $url; + $urlRoot = $_ENV['DEV_URL']; + } + $docuseal = new \Docuseal\Api('pgAU116mCFmeF7WQSezHqxtZW8V1fgo31u5d2FXoaKe', 'https://signature.esy-web.dev/api'); + $content = $docuseal->createSubmissionFromPdf([ + 'name' => 'AG E-COSPLAY '.$main->getAgDateAt()->format('d/m/Y'), + 'documents' => [ + [ + 'name' => 'ag-ecosplay-'.$main->getAgDateAt()->format('d-m-Y'), + 'file' => $url + ] + ], + 'completed_redirect_url' => $urlRoot.$this->generateUrl('admin_ag',['idValidateSign'=>$main->getId()]), + 'submitters' => [ + [ + 'role' => 'First Party', + 'email' => 'contact@e-cosplay.fr' + ] + ] + ]); + $slug = $content['submitters'][0]['id']; + $main->setSubmiterId($slug); + $entityManager->persist($main); + $entityManager->flush(); + $path = $content['submitters'][0]['embed_src']; + $r = new RedirectResponse($path); + $r->setStatusCode(302); + return $r; } if($request->query->has('idGenerate')) { /** @var Main $main */ diff --git a/src/Entity/Ag/Main.php b/src/Entity/Ag/Main.php index 272859e..3045394 100644 --- a/src/Entity/Ag/Main.php +++ b/src/Entity/Ag/Main.php @@ -82,6 +82,12 @@ class Main private ?string $agOriginalName = null; #[ORM\Column(nullable: true)] private ?\DateTimeImmutable $updateAt; + + #[ORM\Column(nullable: true)] + private ?bool $isSigned = null; + + #[ORM\Column(nullable: true)] + private ?string $submiterId = null; /** * @return File|null */ @@ -411,4 +417,28 @@ class Main { $this->agSize = $agSize; } + + public function isSigned(): ?bool + { + return $this->isSigned; + } + + public function setIsSigned(?bool $isSigned): static + { + $this->isSigned = $isSigned; + + return $this; + } + + public function getSubmiterId(): ?string + { + return $this->submiterId; + } + + public function setSubmiterId(string $submiterId): static + { + $this->submiterId = $submiterId; + + return $this; + } } diff --git a/templates/admin/ag.twig b/templates/admin/ag.twig index ee51433..2f46683 100644 --- a/templates/admin/ag.twig +++ b/templates/admin/ag.twig @@ -75,12 +75,21 @@ {% else %} -
+ {% if ag.isSigned == true %} + + {% else %} + + {% endif %} {% endif %} {% endfor %}