-
Notifications
You must be signed in to change notification settings - Fork 62
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
extended filename patterns, fixes #215
- Loading branch information
Ole Schaefer
committed
Mar 11, 2015
1 parent
f741a1e
commit e6b6b17
Showing
6 changed files
with
360 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
44 changes: 44 additions & 0 deletions
44
src/app/code/community/FireGento/Pdf/controllers/Adminhtml/Sales/CreditmemoController.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
<?php | ||
|
||
require('Mage/Adminhtml/controllers/Sales/CreditmemoController.php'); | ||
|
||
class FireGento_Pdf_Adminhtml_Sales_CreditmemoController | ||
extends Mage_Adminhtml_Sales_CreditmemoController | ||
{ | ||
public function pdfcreditmemosAction() | ||
{ | ||
$creditmemosIds = $this->getRequest()->getPost('creditmemo_ids'); | ||
if (sizeof($creditmemosIds) > 1) { | ||
$invoices = Mage::getResourceModel('sales/order_creditmemo_collection') | ||
->addAttributeToSelect('*') | ||
->addAttributeToFilter('entity_id', array('in' => $creditmemosIds)) | ||
->load(); | ||
if (!isset($pdf)) { | ||
$pdf = Mage::getModel('sales/order_pdf_creditmemo')->getPdf($invoices); | ||
} else { | ||
$pages = Mage::getModel('sales/order_pdf_creditmemo')->getPdf($invoices); | ||
$pdf->pages = array_merge($pdf->pages, $pages->pages); | ||
} | ||
return $this->_prepareDownloadResponse( | ||
Mage::helper('firegento_pdf') | ||
->getExportFilenameForMultipleDocuments('creditmemo'), | ||
$pdf->render(), 'application/pdf' | ||
); | ||
} else if (sizeof($creditmemosIds) == 1) { | ||
$creditmemoId = $creditmemosIds[0]; | ||
if ($invoice = Mage::getModel('sales/order_creditmemo') | ||
->load($creditmemoId) | ||
) { | ||
$pdf = Mage::getModel('sales/order_pdf_creditmemo') | ||
->getPdf(array($invoice)); | ||
return $this->_prepareDownloadResponse( | ||
Mage::helper('firegento_pdf') | ||
->getExportFilename('creditmemo', $invoice), | ||
$pdf->render(), 'application/pdf' | ||
); | ||
} | ||
} | ||
|
||
$this->_redirect('*/*/'); | ||
} | ||
} |
44 changes: 44 additions & 0 deletions
44
src/app/code/community/FireGento/Pdf/controllers/Adminhtml/Sales/InvoiceController.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
<?php | ||
|
||
require('Mage/Adminhtml/controllers/Sales/InvoiceController.php'); | ||
|
||
class FireGento_Pdf_Adminhtml_Sales_InvoiceController | ||
extends Mage_Adminhtml_Sales_InvoiceController | ||
{ | ||
public function pdfinvoicesAction() | ||
{ | ||
$invoicesIds = $this->getRequest()->getPost('invoice_ids'); | ||
if (sizeof($invoicesIds) > 1) { | ||
$invoices = Mage::getResourceModel('sales/order_invoice_collection') | ||
->addAttributeToSelect('*') | ||
->addAttributeToFilter('entity_id', array('in' => $invoicesIds)) | ||
->load(); | ||
if (!isset($pdf)) { | ||
$pdf = Mage::getModel('sales/order_pdf_invoice')->getPdf($invoices); | ||
} else { | ||
$pages = Mage::getModel('sales/order_pdf_invoice')->getPdf($invoices); | ||
$pdf->pages = array_merge($pdf->pages, $pages->pages); | ||
} | ||
return $this->_prepareDownloadResponse( | ||
Mage::helper('firegento_pdf') | ||
->getExportFilenameForMultipleDocuments('invoice'), | ||
$pdf->render(), 'application/pdf' | ||
); | ||
} else if (sizeof($invoicesIds) == 1) { | ||
$invoiceId = $invoicesIds[0]; | ||
if ($invoice = Mage::getModel('sales/order_invoice') | ||
->load($invoiceId) | ||
) { | ||
$pdf = Mage::getModel('sales/order_pdf_invoice') | ||
->getPdf(array($invoice)); | ||
return $this->_prepareDownloadResponse( | ||
Mage::helper('firegento_pdf') | ||
->getExportFilename('invoice', $invoice), | ||
$pdf->render(), 'application/pdf' | ||
); | ||
} | ||
} | ||
|
||
$this->_redirect('*/*/'); | ||
} | ||
} |
151 changes: 151 additions & 0 deletions
151
src/app/code/community/FireGento/Pdf/controllers/Adminhtml/Sales/OrderController.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,151 @@ | ||
<?php | ||
|
||
require('Mage/Adminhtml/controllers/Sales/OrderController.php'); | ||
|
||
class FireGento_Pdf_Adminhtml_Sales_OrderController | ||
extends Mage_Adminhtml_Sales_OrderController | ||
{ | ||
public function pdfinvoicesAction() | ||
{ | ||
$orderIds = $this->getRequest()->getPost('order_ids'); | ||
$flag = false; | ||
if (!empty($orderIds)) { | ||
$invoice = null; | ||
foreach ($orderIds as $orderId) { | ||
$invoices = Mage::getResourceModel('sales/order_invoice_collection') | ||
->setOrderFilter($orderId) | ||
->load(); | ||
if ($invoices->getSize() == 1) { | ||
$invoice = $invoices->getFirstItem(); | ||
} | ||
if ($invoices->getSize() > 0) { | ||
$flag = true; | ||
if (!isset($pdf)) { | ||
$pdf = Mage::getModel('sales/order_pdf_invoice')->getPdf($invoices); | ||
} else { | ||
$pages = Mage::getModel('sales/order_pdf_invoice')->getPdf($invoices); | ||
$pdf->pages = array_merge($pdf->pages, $pages->pages); | ||
// there is more than one invoice | ||
$invoice = null; | ||
} | ||
} | ||
} | ||
if ($flag) { | ||
if ($invoice != null) { | ||
return $this->_prepareDownloadResponse( | ||
Mage::helper('firegento_pdf') | ||
->getExportFilename('invoice', $invoice), | ||
$pdf->render(), 'application/pdf' | ||
); | ||
} | ||
return $this->_prepareDownloadResponse( | ||
Mage::helper('firegento_pdf') | ||
->getExportFilenameForMultipleDocuments('invoice'), | ||
$pdf->render(), 'application/pdf' | ||
); | ||
} else { | ||
$this->_getSession()->addError( | ||
$this->__('There are no printable documents related to selected orders.') | ||
); | ||
$this->_redirect('*/*/'); | ||
} | ||
} | ||
$this->_redirect('*/*/'); | ||
} | ||
|
||
public function pdfshipmentsAction() | ||
{ | ||
$orderIds = $this->getRequest()->getPost('order_ids'); | ||
$flag = false; | ||
if (!empty($orderIds)) { | ||
$shipment = null; | ||
foreach ($orderIds as $orderId) { | ||
$shipments = Mage::getResourceModel('sales/order_shipment_collection') | ||
->setOrderFilter($orderId) | ||
->load(); | ||
if ($shipments->getSize() == 1) { | ||
$shipment = $shipments->getFirstItem(); | ||
} | ||
if ($shipments->getSize() > 0) { | ||
$flag = true; | ||
if (!isset($pdf)) { | ||
$pdf = Mage::getModel('sales/order_pdf_shipment')->getPdf($shipments); | ||
} else { | ||
$pages = Mage::getModel('sales/order_pdf_shipment')->getPdf($shipments); | ||
$pdf->pages = array_merge($pdf->pages, $pages->pages); | ||
// there is more than one invoice | ||
$shipment = null; | ||
} | ||
} | ||
} | ||
if ($flag) { | ||
if ($shipment != null) { | ||
return $this->_prepareDownloadResponse( | ||
Mage::helper('firegento_pdf') | ||
->getExportFilename('shipment', $shipment), | ||
$pdf->render(), 'application/pdf' | ||
); | ||
} | ||
return $this->_prepareDownloadResponse( | ||
Mage::helper('firegento_pdf') | ||
->getExportFilenameForMultipleDocuments('shipment'), | ||
$pdf->render(), 'application/pdf' | ||
); | ||
} else { | ||
$this->_getSession()->addError( | ||
$this->__('There are no printable documents related to selected orders.') | ||
); | ||
$this->_redirect('*/*/'); | ||
} | ||
} | ||
$this->_redirect('*/*/'); | ||
} | ||
|
||
public function pdfcreditmemosAction() | ||
{ | ||
$orderIds = $this->getRequest()->getPost('order_ids'); | ||
$flag = false; | ||
if (!empty($orderIds)) { | ||
$creditmemo = null; | ||
foreach ($orderIds as $orderId) { | ||
$creditmemos = Mage::getResourceModel('sales/order_creditmemo_collection') | ||
->setOrderFilter($orderId) | ||
->load(); | ||
if ($creditmemos->getSize() == 1) { | ||
$creditmemo = $creditmemos->getFirstItem(); | ||
} | ||
if ($creditmemos->getSize() > 0) { | ||
$flag = true; | ||
if (!isset($pdf)) { | ||
$pdf = Mage::getModel('sales/order_pdf_creditmemo')->getPdf($creditmemos); | ||
} else { | ||
$pages = Mage::getModel('sales/order_pdf_creditmemo')->getPdf($creditmemos); | ||
$pdf->pages = array_merge($pdf->pages, $pages->pages); | ||
// there is more than one invoice | ||
$creditmemo = null; | ||
} | ||
} | ||
} | ||
if ($flag) { | ||
if ($creditmemo != null) { | ||
return $this->_prepareDownloadResponse( | ||
Mage::helper('firegento_pdf') | ||
->getExportFilename('creditmemo', $creditmemo), | ||
$pdf->render(), 'application/pdf' | ||
); | ||
} | ||
return $this->_prepareDownloadResponse( | ||
Mage::helper('firegento_pdf') | ||
->getExportFilenameForMultipleDocuments('creditmemo'), | ||
$pdf->render(), 'application/pdf' | ||
); | ||
} else { | ||
$this->_getSession()->addError( | ||
$this->__('There are no printable documents related to selected orders.') | ||
); | ||
$this->_redirect('*/*/'); | ||
} | ||
} | ||
$this->_redirect('*/*/'); | ||
} | ||
} |
44 changes: 44 additions & 0 deletions
44
src/app/code/community/FireGento/Pdf/controllers/Adminhtml/Sales/ShipmentController.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
<?php | ||
|
||
require('Mage/Adminhtml/controllers/Sales/ShipmentController.php'); | ||
|
||
class FireGento_Pdf_Adminhtml_Sales_ShipmentController | ||
extends Mage_Adminhtml_Sales_ShipmentController | ||
{ | ||
public function pdfshipmentsAction() | ||
{ | ||
$shipmentIds = $this->getRequest()->getPost('shipment_ids'); | ||
if (sizeof($shipmentIds) > 1) { | ||
$shipments = Mage::getResourceModel('sales/order_shipment_collection') | ||
->addAttributeToSelect('*') | ||
->addAttributeToFilter('entity_id', array('in' => $shipmentIds)) | ||
->load(); | ||
if (!isset($pdf)) { | ||
$pdf = Mage::getModel('sales/order_pdf_shipment')->getPdf($shipments); | ||
} else { | ||
$pages = Mage::getModel('sales/order_pdf_shipment')->getPdf($shipments); | ||
$pdf->pages = array_merge($pdf->pages, $pages->pages); | ||
} | ||
return $this->_prepareDownloadResponse( | ||
Mage::helper('firegento_pdf') | ||
->getExportFilenameForMultipleDocuments('shipment'), | ||
$pdf->render(), 'application/pdf' | ||
); | ||
} else if (sizeof($shipmentIds) == 1) { | ||
$shipmentId = $shipmentIds[0]; | ||
if ($shipment = Mage::getModel('sales/order_shipment') | ||
->load($shipmentId) | ||
) { | ||
$pdf = Mage::getModel('sales/order_pdf_invoice') | ||
->getPdf(array($shipment)); | ||
return $this->_prepareDownloadResponse( | ||
Mage::helper('firegento_pdf') | ||
->getExportFilename('shipment', $shipment), | ||
$pdf->render(), 'application/pdf' | ||
); | ||
} | ||
} | ||
|
||
$this->_redirect('*/*/'); | ||
} | ||
} |
Oops, something went wrong.