Ejemplo n.º 1
0
 /**
  * Auto Generate Documents
  *
  * @param \Extcode\Cart\Domain\Model\Order\Item $orderItem
  * @param $pluginSettings
  *
  * @return void
  */
 public function autoGenerateDocuments(\Extcode\Cart\Domain\Model\Order\Item $orderItem, $pluginSettings)
 {
     if ($pluginSettings['autoGenerateDocuments']) {
         foreach ($pluginSettings['autoGenerateDocuments'] as $documentType => $documentData) {
             $getterForNumber = 'get' . ucfirst($documentType) . 'Number';
             $setterForNumber = 'set' . ucfirst($documentType) . 'Number';
             $setterForDate = 'set' . ucfirst($documentType) . 'Date';
             if (!$orderItem->{$getterForNumber}()) {
                 $documentNumber = $this->getNumber($pluginSettings, $documentType);
                 $orderItem->{$setterForNumber}($documentNumber);
                 $orderItem->{$setterForDate}(new \DateTime());
             }
             $this->generatePdfDocument($orderItem, $documentType);
         }
         $this->orderItemRepository->update($orderItem);
         $this->persistenceManager->persistAll();
     }
 }
Ejemplo n.º 2
0
 /**
  * Generate Invoice Document Action
  *
  * @param \Extcode\Cart\Domain\Model\Order\Item $orderItem
  * @param string $pdfType
  *
  * @return void
  */
 public function generatePdfDocumentAction(\Extcode\Cart\Domain\Model\Order\Item $orderItem, $pdfType)
 {
     if ($pdfType == 'invoice') {
         if (!$orderItem->getInvoiceNumber()) {
             $invoiceNumber = $this->generateInvoiceNumber($orderItem);
             $orderItem->setInvoiceNumber($invoiceNumber);
             $orderItem->setInvoiceDate(new \DateTime());
             $this->addFlashMessage('Invoice Number was generated.', $messageTitle = '', $severity = \TYPO3\CMS\Core\Messaging\AbstractMessage::OK, $storeInSession = true);
             $this->itemRepository->update($orderItem);
             $this->persistenceManager->persistAll();
         }
     }
     $this->generatePdfDocument($orderItem, $pdfType);
     $this->itemRepository->update($orderItem);
     $this->persistenceManager->persistAll();
     $msg = ucfirst($pdfType) . '-PDF-Document was generated.';
     $this->addFlashMessage($msg);
     $this->redirect('show', null, null, ['orderItem' => $orderItem]);
 }