Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Ported Invoice PDF to Order PDF #297

Open
wants to merge 2 commits into
base: development
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
42 changes: 42 additions & 0 deletions src/app/code/community/FireGento/Pdf/Helper/Data.php
Original file line number Diff line number Diff line change
Expand Up @@ -29,21 +29,32 @@
class FireGento_Pdf_Helper_Data extends Mage_Core_Helper_Abstract
{
const XML_PATH_FIREGENTO_PDF_LOGO_POSITION = 'sales_pdf/firegento_pdf/logo_position';

const XML_PATH_SALES_PDF_ORDER_SHOW_CUSTOMER_NUMBER = 'sales_pdf/order/show_customer_number';
const XML_PATH_SALES_PDF_INVOICE_SHOW_CUSTOMER_NUMBER = 'sales_pdf/invoice/show_customer_number';
const XML_PATH_SALES_PDF_SHIPMENT_SHOW_CUSTOMER_NUMBER = 'sales_pdf/shipment/show_customer_number';
const XML_PATH_SALES_PDF_CREDITMEMO_SHOW_CUSTOMER_NUMBER = 'sales_pdf/creditmemo/show_customer_number';

const XML_PATH_SALES_PDF_ORDER_SHOW_CUSTOMER_VATNUMBER = 'sales_pdf/order/show_customer_vatnumber';
const XML_PATH_SALES_PDF_INVOICE_SHOW_CUSTOMER_VATNUMBER = 'sales_pdf/invoice/show_customer_vatnumber';
const XML_PATH_SALES_PDF_SHIPMENT_SHOW_CUSTOMER_VATNUMBER = 'sales_pdf/shipment/show_customer_vatnumber';
const XML_PATH_SALES_PDF_CREDITMEMO_SHOW_CUSTOMER_VATNUMBER = 'sales_pdf/creditmemo/show_customer_vatnumber';

const XML_PATH_SALES_PDF_ORDER_GUEST_ORDER_CUSTOMER_NUMBER = 'sales_pdf/order/guestorder_customer_number';
const XML_PATH_SALES_PDF_INVOICE_GUEST_ORDER_CUSTOMER_NUMBER = 'sales_pdf/invoice/guestorder_customer_number';
const XML_PATH_SALES_PDF_SHIPMENT_GUEST_ORDER_CUSTOMER_NUMBER = 'sales_pdf/shipment/guestorder_customer_number';
const XML_PATH_SALES_PDF_CREDITMEMO_GUEST_ORDER_CUSTOMER_NUMBER = 'sales_pdf/creditmemo/guestorder_customer_number';

const XML_PATH_SALES_PDF_ORDER_FILENAME_EXPORT_PATTERN = 'sales_pdf/order/filename_export_pattern';
const XML_PATH_SALES_PDF_INVOICE_FILENAME_EXPORT_PATTERN = 'sales_pdf/invoice/filename_export_pattern';
const XML_PATH_SALES_PDF_SHIPMENT_FILENAME_EXPORT_PATTERN = 'sales_pdf/shipment/filename_export_pattern';
const XML_PATH_SALES_PDF_CREDITMEMO_FILENAME_EXPORT_PATTERN = 'sales_pdf/creditmemo/filename_export_pattern';

const XML_PATH_SALES_PDF_INVOICE_ORDER_EXPORT_PATTERN_FOR_MULTIPLE_DOCUMENTS = 'sales_pdf/order/filename_export_pattern_for_multiple_documents';
const XML_PATH_SALES_PDF_INVOICE_FILENAME_EXPORT_PATTERN_FOR_MULTIPLE_DOCUMENTS = 'sales_pdf/invoice/filename_export_pattern_for_multiple_documents';
const XML_PATH_SALES_PDF_SHIPMENT_FILENAME_EXPORT_PATTERN_FOR_MULTIPLE_DOCUMENTS = 'sales_pdf/shipment/filename_export_pattern_for_multiple_documents';
const XML_PATH_SALES_PDF_CREDITMEMO_FILENAME_EXPORT_PATTERN_FOR_MULTIPLE_DOCUMENTS = 'sales_pdf/creditmemo/filename_export_pattern_for_multiple_documents';

const XML_PATH_SALES_PDF_FIREGENTO_PDF_PAGE_SIZE = 'sales_pdf/firegento_pdf/page_size';

const XML_PATH_REGULAR_FONT = 'sales_pdf/firegento_pdf_fonts/regular_font';
Expand Down Expand Up @@ -125,21 +136,30 @@ public function isLogoFullWidth($store)
public function showCustomerNumber($mode = 'invoice', $store)
{
switch ($mode) {
case 'order':
return Mage::getStoreConfigFlag(
self::XML_PATH_SALES_PDF_ORDER_SHOW_CUSTOMER_NUMBER,
$store
);
break;
case 'invoice':
return Mage::getStoreConfigFlag(
self::XML_PATH_SALES_PDF_INVOICE_SHOW_CUSTOMER_NUMBER,
$store
);
break;
case 'shipment':
return Mage::getStoreConfigFlag(
self::XML_PATH_SALES_PDF_SHIPMENT_SHOW_CUSTOMER_NUMBER,
$store
);
break;
case 'creditmemo':
return Mage::getStoreConfigFlag(
self::XML_PATH_SALES_PDF_CREDITMEMO_SHOW_CUSTOMER_NUMBER,
$store
);
break;
}

return true; // backwards compatibility
Expand All @@ -156,21 +176,30 @@ public function showCustomerNumber($mode = 'invoice', $store)
public function showCustomerVATNumber($mode = 'invoice', $store)
{
switch ($mode) {
case 'order':
return Mage::getStoreConfigFlag(
self::XML_PATH_SALES_PDF_ORDER_SHOW_CUSTOMER_VATNUMBER,
$store
);
break;
case 'invoice':
return Mage::getStoreConfigFlag(
self::XML_PATH_SALES_PDF_INVOICE_SHOW_CUSTOMER_VATNUMBER,
$store
);
break;
case 'shipment':
return Mage::getStoreConfigFlag(
self::XML_PATH_SALES_PDF_SHIPMENT_SHOW_CUSTOMER_VATNUMBER,
$store
);
break;
case 'creditmemo':
return Mage::getStoreConfigFlag(
self::XML_PATH_SALES_PDF_CREDITMEMO_SHOW_CUSTOMER_VATNUMBER,
$store
);
break;
}

return true; // backwards compatibility
Expand All @@ -187,6 +216,11 @@ public function showCustomerVATNumber($mode = 'invoice', $store)
public function getGuestorderCustomerNo($mode = 'invoice', $store)
{
switch ($mode) {
case 'order':
return trim(Mage::getStoreConfigFlag(
self::XML_PATH_SALES_PDF_ORDER_GUEST_ORDER_CUSTOMER_NUMBER,
$store
));
case 'invoice':
return trim(Mage::getStoreConfigFlag(
self::XML_PATH_SALES_PDF_INVOICE_GUEST_ORDER_CUSTOMER_NUMBER,
Expand Down Expand Up @@ -249,6 +283,10 @@ public function getScaledImageSize($image, $maxWidth, $maxHeight)
public function getExportPattern($type)
{
switch ($type) {
case 'order':
return Mage::getStoreConfig(
self::XML_PATH_SALES_PDF_ORDER_FILENAME_EXPORT_PATTERN
);
case 'invoice':
return Mage::getStoreConfig(
self::XML_PATH_SALES_PDF_INVOICE_FILENAME_EXPORT_PATTERN
Expand Down Expand Up @@ -276,6 +314,10 @@ public function getExportPattern($type)
public function getExportPatternForMultipleDocuments($type)
{
switch ($type) {
case 'order':
return Mage::getStoreConfig(
self::XML_PATH_SALES_PDF_ORDER_FILENAME_EXPORT_PATTERN_FOR_MULTIPLE_DOCUMENTS
);
case 'invoice':
return Mage::getStoreConfig(
self::XML_PATH_SALES_PDF_INVOICE_FILENAME_EXPORT_PATTERN_FOR_MULTIPLE_DOCUMENTS
Expand Down
18 changes: 8 additions & 10 deletions src/app/code/community/FireGento/Pdf/Model/Engine/Abstract.php
Original file line number Diff line number Diff line change
Expand Up @@ -475,11 +475,18 @@ protected function insertHeader(&$page, $order, $document)

if ($mode == 'invoice') {
$title = 'Invoice';
$numberTitle = 'Invoice number:';
} elseif ($mode == 'shipment') {
$title = 'Packingslip';
} else {
$numberTitle = 'Shipment number:';
} elseif($mode == 'creditmemo') {
$title = 'Creditmemo';
$numberTitle = 'Creditmemo number:';
} else {
$title = 'Order';
$numberTitle = 'Order number:';
}

$page->drawText(Mage::helper('firegento_pdf')->__($title),
$this->margin['left'], $this->y, $this->encoding);

Expand All @@ -493,15 +500,6 @@ protected function insertHeader(&$page, $order, $document)
$width = 80;
$numberOfLines = 0;


// Invoice/shipment/creditmemo Number
if ($mode == 'invoice') {
$numberTitle = 'Invoice number:';
} elseif ($mode == 'shipment') {
$numberTitle = 'Shipment number:';
} else {
$numberTitle = 'Creditmemo number:';
}
$page->drawText(
Mage::helper('firegento_pdf')->__($numberTitle),
($this->margin['right'] - $labelRightOffset), $this->y,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -94,14 +94,13 @@ public function getPdf($creditmemos = array())

// Add footer
$this->_addFooter($page, $creditmemo->getStore());

if ($creditmemo->getStoreId()) {
Mage::app()->getLocale()->revert();
}
}

$this->_afterGetPdf();

if ($creditmemo->getStoreId()) {
Mage::app()->getLocale()->revert();
}
return $pdf;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -98,10 +98,6 @@ public function getPdf($invoices = array())

// Add footer
$this->_addFooter($page, $invoice->getStore());

if ($invoice->getStoreId()) {
Mage::app()->getLocale()->revert();
}
}

$this->_afterGetPdf();
Expand Down
Loading