Exemple #1
0
 public function testGetPdfInitRenderer()
 {
     $this->_pdfConfigMock->expects($this->once())->method('getRenderersPerProduct')->with('invoice')->will($this->returnValue(['product_type_one' => 'Renderer_Type_One_Product_One', 'product_type_two' => 'Renderer_Type_One_Product_Two']));
     $this->_model->getPdf([]);
     $renderers = new \ReflectionProperty($this->_model, '_renderers');
     $renderers->setAccessible(true);
     $this->assertSame(['product_type_one' => ['model' => 'Renderer_Type_One_Product_One', 'renderer' => null], 'product_type_two' => ['model' => 'Renderer_Type_One_Product_Two', 'renderer' => null]], $renderers->getValue($this->_model));
 }
 /**
  * Print invoices for selected orders
  *
  * @param AbstractCollection $collection
  * @return ResponseInterface|ResultInterface
  */
 protected function massAction(AbstractCollection $collection)
 {
     $invoicesCollection = $this->collectionFactory->create()->setOrderFilter(['in' => $collection->getAllIds()]);
     if (!$invoicesCollection->getSize()) {
         $this->messageManager->addError(__('There are no printable documents related to selected orders.'));
         return $this->resultRedirectFactory->create()->setPath($this->getComponentRefererUrl());
     }
     return $this->fileFactory->create(sprintf('packingslip%s.pdf', $this->dateTime->date('Y-m-d_H-i-s')), $this->pdfInvoice->getPdf($invoicesCollection->getItems())->render(), DirectoryList::VAR_DIR, 'application/pdf');
 }
 /**
  * Save collection items to pdf invoices
  *
  * @param AbstractCollection $collection
  * @return ResponseInterface
  * @throws \Exception
  */
 public function massAction(AbstractCollection $collection)
 {
     return $this->fileFactory->create(sprintf('invoice%s.pdf', $this->dateTime->date('Y-m-d_H-i-s')), $this->pdfInvoice->getPdf($collection)->render(), DirectoryList::VAR_DIR, 'application/pdf');
 }
Exemple #4
-6
 /**
  * Print all documents for selected orders
  *
  * @param AbstractCollection $collection
  * @return ResponseInterface|\Magento\Backend\Model\View\Result\Redirect
  *
  * @SuppressWarnings(PHPMD.CyclomaticComplexity)
  */
 protected function massAction(AbstractCollection $collection)
 {
     $orderIds = $collection->getAllIds();
     $shipments = $this->shipmentCollectionFactory->create()->setOrderFilter(['in' => $orderIds]);
     $invoices = $this->invoiceCollectionFactory->create()->setOrderFilter(['in' => $orderIds]);
     $creditmemos = $this->creditmemoCollectionFactory->create()->setOrderFilter(['in' => $orderIds]);
     $documents = [];
     if ($invoices->getSize()) {
         $documents[] = $this->pdfInvoice->getPdf($invoices);
     }
     if ($shipments->getSize()) {
         $documents[] = $this->pdfShipment->getPdf($shipments);
     }
     if ($creditmemos->getSize()) {
         $documents[] = $this->pdfCreditmemo->getPdf($creditmemos);
     }
     if (empty($documents)) {
         $this->messageManager->addError(__('There are no printable documents related to selected orders.'));
         return $this->resultRedirectFactory->create()->setPath($this->getComponentRefererUrl());
     }
     $pdf = array_shift($documents);
     foreach ($documents as $document) {
         $pdf->pages = array_merge($pdf->pages, $document->pages);
     }
     return $this->fileFactory->create(sprintf('docs%s.pdf', $this->dateTime->date('Y-m-d_H-i-s')), $pdf->render(), DirectoryList::VAR_DIR, 'application/pdf');
 }