diff --git a/src/new/src/PSC/Shop/EntityBundle/Entity/Orderpos.php b/src/new/src/PSC/Shop/EntityBundle/Entity/Orderpos.php index fc12a2763..3a1102a2f 100755 --- a/src/new/src/PSC/Shop/EntityBundle/Entity/Orderpos.php +++ b/src/new/src/PSC/Shop/EntityBundle/Entity/Orderpos.php @@ -114,6 +114,12 @@ class Orderpos private $uploadFinish; #[ORM\OneToMany(targetEntity: 'Upload', mappedBy: 'orderPos')] protected $uploads; + + /** + * null = ausstehend, 1 = freigegeben, -1 = abgelehnt + */ + #[ORM\Column(name: 'external_approval_status', type: 'integer', nullable: true)] + private ?int $externalApprovalStatus = null; /** * @var Product */ @@ -1030,4 +1036,14 @@ class Orderpos { $this->uploads = $uploads; } + + public function getExternalApprovalStatus(): ?int + { + return $this->externalApprovalStatus; + } + + public function setExternalApprovalStatus(?int $status): void + { + $this->externalApprovalStatus = $status; + } } diff --git a/src/new/src/PSC/Shop/EntityBundle/Entity/Product.php b/src/new/src/PSC/Shop/EntityBundle/Entity/Product.php index d02481413..716993411 100755 --- a/src/new/src/PSC/Shop/EntityBundle/Entity/Product.php +++ b/src/new/src/PSC/Shop/EntityBundle/Entity/Product.php @@ -666,6 +666,14 @@ class Product #[ORM\Column(name: 'confirmOne', type: 'boolean')] protected $confirmOne; + /** + * Externe Freigabe erforderlich + * + * @var boolean + */ + #[ORM\Column(name: 'confirmExternal', type: 'boolean', options: ['default' => false])] + protected $confirmExternal = false; + /** * Lager aktiviert Produkt * @@ -2650,6 +2658,16 @@ class Product $this->confirm = $confirm; } + public function isConfirmExternal(): bool + { + return (bool) $this->confirmExternal; + } + + public function setConfirmExternal(bool $confirmExternal): void + { + $this->confirmExternal = $confirmExternal; + } + /** * @return int */ diff --git a/src/new/src/PSC/Shop/OrderBundle/Controller/ExternalApprovalController.php b/src/new/src/PSC/Shop/OrderBundle/Controller/ExternalApprovalController.php new file mode 100644 index 000000000..bb3c01f0d --- /dev/null +++ b/src/new/src/PSC/Shop/OrderBundle/Controller/ExternalApprovalController.php @@ -0,0 +1,75 @@ +getRepository(Orderpos::class)->findOneBy(['uuid' => $uuid]); + + if (!$orderpos) { + throw $this->createNotFoundException('Position nicht gefunden.'); + } + + if ($request->isMethod('POST')) { + $action = $request->request->get('action'); + + if ($action === 'approve') { + $orderpos->setExternalApprovalStatus(1); + } elseif ($action === 'reject') { + $orderpos->setExternalApprovalStatus(-1); + } + + $em->flush(); + + return $this->redirectToRoute('psc_shop_order_external_approval_show', ['uuid' => $uuid]); + } + + return $this->render('@PSCShopOrder/external_approval/show.html.twig', [ + 'orderpos' => $orderpos, + ]); + } + + #[Route(path: '/{uuid}/download/{uploadUuid}', name: 'psc_shop_order_external_approval_download', methods: ['GET'])] + public function download(string $uuid, string $uploadUuid, EntityManagerInterface $em): Response + { + /** @var Orderpos|null $orderpos */ + $orderpos = $em->getRepository(Orderpos::class)->findOneBy(['uuid' => $uuid]); + + if (!$orderpos) { + throw $this->createNotFoundException(); + } + + /** @var Upload|null $upload */ + $upload = $em->getRepository(Upload::class)->findOneBy(['uuid' => $uploadUuid]); + + if (!$upload || $upload->getOrderPos()->getUuid() !== $uuid) { + throw $this->createNotFoundException(); + } + + $absolutePath = $this->getParameter('kernel.project_dir') . '/../old/public/' . $upload->getPath(); + + if (!file_exists($absolutePath)) { + throw $this->createNotFoundException('Datei nicht gefunden.'); + } + + $response = new BinaryFileResponse($absolutePath); + $response->setContentDisposition(ResponseHeaderBag::DISPOSITION_ATTACHMENT, $upload->getName()); + + return $response; + } +} diff --git a/src/new/src/PSC/Shop/OrderBundle/Resources/config/routing.yml b/src/new/src/PSC/Shop/OrderBundle/Resources/config/routing.yml index 7ca449f31..2ac5aa327 100755 --- a/src/new/src/PSC/Shop/OrderBundle/Resources/config/routing.yml +++ b/src/new/src/PSC/Shop/OrderBundle/Resources/config/routing.yml @@ -3,8 +3,14 @@ psc_shop_order_backend: type: attribute prefix: /backend/order +psc_shop_order: + resource: "@PSCShopOrderBundle/Controller" + type: attribute + prefix: /order + + psc_shop_order_api: resource: "@PSCShopOrderBundle/Api" prefix: /api - type: attribute \ No newline at end of file + type: attribute diff --git a/src/new/src/PSC/Shop/OrderBundle/Resources/views/external_approval/show.html.twig b/src/new/src/PSC/Shop/OrderBundle/Resources/views/external_approval/show.html.twig new file mode 100644 index 000000000..788fe3785 --- /dev/null +++ b/src/new/src/PSC/Shop/OrderBundle/Resources/views/external_approval/show.html.twig @@ -0,0 +1,161 @@ + + +
+ + +Bestellposition #{{ orderpos.uuid }}
+Freigegeben
+Diese Position wurde freigegeben.
+Abgelehnt
+Diese Position wurde abgelehnt.
+Ausstehend
+Diese Position wartet auf Ihre Freigabe.
+Bestellungen dieses Produkts müssen von einem Verantwortlichen freigegeben werden.
+ {{ form_errors(form.confirm) }} +Die Freigabe gilt als erteilt, sobald eine der ausgewählten Personen zugestimmt hat.
+ {{ form_errors(form.confirmOne) }} +Bestellungen dieses Produkts müssen von einer externen Person freigegeben werden.
+ {{ form_errors(form.confirmExternal) }} +Strg (Windows) bzw. Cmd (Mac) gedrückt halten, um mehrere Personen auszuwählen.
+