diff --git a/app/code/community/FireGento/Pdf/Block/Adminhtml/ColumnOrder.php b/app/code/community/FireGento/Pdf/Block/Adminhtml/ColumnOrder.php
new file mode 100644
index 0000000..9bf5a55
--- /dev/null
+++ b/app/code/community/FireGento/Pdf/Block/Adminhtml/ColumnOrder.php
@@ -0,0 +1,114 @@
+
+ * @copyright 2013 FireGento Team (http://www.firegento.de). All rights served.
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
+ */
+class Firegento_Pdf_Block_Adminhtml_ColumnOrder
+ extends Mage_Adminhtml_Block_System_Config_Form_Field
+{
+ protected $sortableListHtml = '';
+
+ protected function _getElementHtml(Varien_Data_Form_Element_Abstract $element)
+ {
+ return '
+
+
' . $this->__('Define the order by moving the following items using your mouse:') . '
+
+ ' . $this->_getSortableListHtml($element) . '
+
+
+
+ ';
+ }
+
+ protected function _getSortableListHtml(Varien_Data_Form_Element_Abstract $element)
+ {
+ $availableItems = array(
+ 'price_incl_tax' => array('width' => 60, 'label' => $this->__('Price (incl. tax)')),
+ 'price' => array('width' => 60, 'label' => $this->__('Price')),
+ 'qty' => array('width' => 40, 'label' => $this->__('Qty')),
+ 'subtotal_incl_tax' => array('width' => 70, 'label' => $this->__('Subtotal (incl. tax)')),
+ 'subtotal' => array('width' => 50, 'label' => $this->__('Subtotal')),
+ 'tax' => array('width' => 50, 'label' => $this->__('Tax amount')),
+ 'tax_rate' => array('width' => 50, 'label' => $this->__('Tax rate')),
+ );
+ $activeItems = array();
+ foreach (explode(',', $element->getValue()) as $item) {
+ $item = trim($item);
+ if (array_key_exists($item, $availableItems)) {
+ $activeItems[$item] = $availableItems[$item];
+ unset($availableItems[$item]);
+ }
+ }
+
+ $this->_addListItems($activeItems);
+ $this->sortableListHtml .= '
+
+
+ ' . $this->__('not to be listed') . '
+ ';
+ $this->_addListItems($availableItems);
+
+ return $this->sortableListHtml;
+ }
+
+ protected function _addListItems($items)
+ {
+ foreach ($items as $name=>$item) {
+ $this->sortableListHtml .= sprintf(
+ '%s',
+ $name,
+ $name,
+ $item['width'],
+ $item['label']
+ );
+ }
+ return $this;
+ }
+}
\ No newline at end of file
diff --git a/app/code/community/FireGento/Pdf/Model/Creditmemo.php b/app/code/community/FireGento/Pdf/Model/Creditmemo.php
index c9286a7..07409a6 100644
--- a/app/code/community/FireGento/Pdf/Model/Creditmemo.php
+++ b/app/code/community/FireGento/Pdf/Model/Creditmemo.php
@@ -31,156 +31,35 @@
* @version $Id:$
* @since 0.1.0
*/
-class FireGento_Pdf_Model_Creditmemo extends FireGento_Pdf_Model_Abstract
+class FireGento_Pdf_Model_Creditmemo
{
- public function __construct()
- {
- parent::__construct();
- $this->setMode('creditmemo');
- }
-
/**
- * Return PDF document
- *
- * @param array $creditmemos
- * @return Zend_Pdf
+ * The actual PDF engine responsible for rendering the file.
+ * @var Mage_Sales_Model_Order_Pdf_Abstract
*/
- public function getPdf($creditmemos = array())
- {
- $this->_beforeGetPdf();
- $this->_initRenderer('creditmemo');
-
- $pdf = new Zend_Pdf();
- $this->_setPdf($pdf);
-
- $style = new Zend_Pdf_Style();
- $this->_setFontBold($style, 10);
-
- // pagecounter is 0 at the beginning, because it is incremented in newPage()
- $this->pagecounter = 0;
-
- foreach ($creditmemos as $creditmemo) {
- if ($creditmemo->getStoreId()) {
- Mage::app()->getLocale()->emulate($creditmemo->getStoreId());
- Mage::app()->setCurrentStore($creditmemo->getStoreId());
- }
- $page = $this->newPage();
+ private $_engine;
- $order = $creditmemo->getOrder();
-
- // Add logo
- $this->insertLogo($page, $creditmemo->getStore());
-
- // Add billing address
- $this->y = 692;
- $this->insertBillingAddress($page, $order);
-
- // Add sender address
- $this->y = 705;
- $this->_insertSenderAddessBar($page);
-
- // Add head
- $this->y = 592;
- $this->insertHeader($page, $order, $creditmemo);
-
- // Add footer
- $this->_addFooter($page, $creditmemo->getStore());
-
- /* Add table head */
- $this->_setFontRegular($page, 9);
- $this->y = 562;
- $this->_drawHeader($page);
-
- $this->y -=20;
-
- $position = 0;
+ protected function getEngine()
+ {
+ if (!$this->_engine) {
+ $modelClass = Mage::getStoreConfig('sales_pdf/creditmemo/engine');
+ $engine = Mage::getModel($modelClass);
- /* Add body */
- foreach ($creditmemo->getAllItems() as $item){
- if ($item->getOrderItem()->getParentItem()) {
- continue;
- }
- /* Draw item */
- $position++;
- $this->_drawItem($item, $page, $order, $position);
- $page = end($pdf->pages);
+ if (!$engine) {
+ // Fallback to Magento standard creditmemo layout.
+ $engine = new Mage_Sales_Model_Order_Pdf_Creditmemo();
}
- /* add line after items */
- $page->drawLine($this->margin['left'], $this->y + 5, $this->margin['right'], $this->y + 5);
-
- /* Add totals */
- $page = $this->insertTotals($page, $creditmemo);
-
- /* add note */
- $page = $this->_insertNote($page, $order, $creditmemo);
+ $this->_engine = $engine;
}
- $this->_afterGetPdf();
-
- if ($creditmemo->getStoreId()) {
- Mage::app()->getLocale()->revert();
- }
- return $pdf;
+ return $this->_engine;
}
- /**
- * Draw table header for product items
- *
- * @param Zend_Pdf_Page $page
- * @return void
- */
- protected function _drawHeader(Zend_Pdf_Page $page)
- {
- $page->setFillColor($this->colors['grey1']);
- $page->setLineColor($this->colors['grey1']);
- $page->setLineWidth(1);
- $page->drawRectangle($this->margin['left'], $this->y, $this->margin['right'], $this->y - 15);
-
- $page->setFillColor($this->colors['black']);
- $font = $this->_setFontRegular($page, 9);
-
- $this->y -= 11;
- $page->drawText(Mage::helper('firegento_pdf')->__('Pos'), $this->margin['left'] + 3, $this->y, $this->encoding);
- $page->drawText(Mage::helper('firegento_pdf')->__('No.'), $this->margin['left'] + 25, $this->y, $this->encoding);
- $page->drawText(Mage::helper('firegento_pdf')->__('Description'), $this->margin['left'] + 120, $this->y, $this->encoding);
-
- $singlePrice = Mage::helper('firegento_pdf')->__('Price (excl. tax)');
- $page->drawText($singlePrice, $this->margin['right'] - 153 - $this->widthForStringUsingFontSize($singlePrice, $font, 9), $this->y, $this->encoding);
-
- $page->drawText(Mage::helper('firegento_pdf')->__('Qty'), $this->margin['left'] + 360, $this->y, $this->encoding);
-
- $taxLabel = Mage::helper('firegento_pdf')->__('Tax');
- $page->drawText($taxLabel, $this->margin['right'] - 65 - $this->widthForStringUsingFontSize($taxLabel, $font, 9), $this->y, $this->encoding);
-
- $totalLabel = Mage::helper('firegento_pdf')->__('Total');
- $page->drawText($totalLabel, $this->margin['right'] - 10 - $this->widthForStringUsingFontSize($totalLabel, $font, 10), $this->y, $this->encoding);
- }
-
- /**
- * Initialize renderer process.
- *
- * @param string $type
- * @return void
- */
- protected function _initRenderer($type)
+ public function getPdf($creditmemos = array())
{
- parent::_initRenderer($type);
-
- $this->_renderers['default'] = array(
- 'model' => 'firegento_pdf/items_default',
- 'renderer' => null
- );
- $this->_renderers['grouped'] = array(
- 'model' => 'firegento_pdf/items_grouped',
- 'renderer' => null
- );
- $this->_renderers['bundle'] = array(
- 'model' => 'firegento_pdf/items_bundle',
- 'renderer' => null
- );
+ return $this->getEngine()->getPdf($creditmemos);
}
}
-
diff --git a/app/code/community/FireGento/Pdf/Model/Abstract.php b/app/code/community/FireGento/Pdf/Model/Engine/Abstract.php
similarity index 66%
rename from app/code/community/FireGento/Pdf/Model/Abstract.php
rename to app/code/community/FireGento/Pdf/Model/Engine/Abstract.php
index ab36e00..9f415b1 100644
--- a/app/code/community/FireGento/Pdf/Model/Abstract.php
+++ b/app/code/community/FireGento/Pdf/Model/Engine/Abstract.php
@@ -31,7 +31,7 @@
* @version $Id:$
* @since 0.1.0
*/
-abstract class FireGento_Pdf_Model_Abstract extends Mage_Sales_Model_Order_Pdf_Abstract
+abstract class FireGento_Pdf_Model_Engine_Abstract extends Mage_Sales_Model_Order_Pdf_Abstract
{
public $margin = array('left' => 45, 'right' => 540);
public $colors = array();
@@ -68,7 +68,7 @@ public function drawLineBlocks(Zend_Pdf_Page $page, array $draw, array $pageSett
if (!isset($itemsProp['lines']) || !is_array($itemsProp['lines'])) {
Mage::throwException(Mage::helper('sales')->__('Invalid draw line data. Please define "lines" array'));
}
- $lines = $itemsProp['lines'];
+ $lines = $itemsProp['lines'];
$height = isset($itemsProp['height']) ? $itemsProp['height'] : 10;
if (empty($itemsProp['shift'])) {
@@ -92,19 +92,18 @@ public function drawLineBlocks(Zend_Pdf_Page $page, array $draw, array $pageSett
$itemsProp['shift'] = $shift;
}
- if ($this->y - $itemsProp['shift'] < 100) {
+ if ($this->y - $itemsProp['shift'] < 50 || (Mage::getStoreConfig('sales_pdf/firegento_pdf/show_footer') == 1 && $this->y - $itemsProp['shift'] < 100)) {
$page = $this->newPage($pageSettings);
}
foreach ($lines as $line) {
$maxHeight = 0;
foreach ($line as $column) {
- $fontSize = empty($column['font_size']) ? 7 : $column['font_size'];
+ $fontSize = empty($column['font_size']) ? 7 : $column['font_size'];
if (!empty($column['font_file'])) {
$font = Zend_Pdf_Font::fontWithPath($column['font_file']);
$page->setFont($font, $fontSize);
- }
- else {
+ } else {
$fontStyle = empty($column['font']) ? 'regular' : $column['font'];
switch ($fontStyle) {
case 'bold':
@@ -133,8 +132,7 @@ public function drawLineBlocks(Zend_Pdf_Page $page, array $draw, array $pageSett
case 'right':
if ($width) {
$feed = $this->getAlignRight($part, $feed, $width, $font, $fontSize);
- }
- else {
+ } else {
$feed = $feed - $this->widthForStringUsingFontSize($part, $font, $fontSize);
}
break;
@@ -144,7 +142,7 @@ public function drawLineBlocks(Zend_Pdf_Page $page, array $draw, array $pageSett
}
break;
}
- $page->drawText($part, $feed, $this->y-$top, 'UTF-8');
+ $page->drawText($part, $feed, $this->y - $top, 'UTF-8');
$top += $lineSpacing;
}
@@ -227,9 +225,9 @@ protected function insertLogo(&$page, $store = null)
$logoPosition = Mage::getStoreConfig('sales_pdf/firegento_pdf/logo_position', $store);
- switch($logoPosition) {
+ switch ($logoPosition) {
case 'center':
- $startLogoAt = $this->margin['left'] + ( ($this->margin['right'] - $this->margin['left']) / 2 ) - $width / 2;
+ $startLogoAt = $this->margin['left'] + (($this->margin['right'] - $this->margin['left']) / 2) - $width / 2;
break;
case 'right':
$startLogoAt = $this->margin['right'] - $width;
@@ -281,109 +279,124 @@ protected function insertHeader(&$page, $order, $document)
$this->_setFontBold($page, 15);
- $page->drawText(Mage::helper('firegento_pdf')->__( ($mode == 'invoice') ? 'Invoice' : 'Creditmemo' ), $this->margin['left'], $this->y, $this->encoding);
+ if ($mode == 'invoice') {
+ $title = 'Invoice';
+ } else if ($mode == 'shipment') {
+ $title = 'Shipment';
+ } else {
+ $title = 'Creditmemo';
+ }
+ $page->drawText(Mage::helper('firegento_pdf')->__($title), $this->margin['left'], $this->y, $this->encoding);
$this->_setFontRegular($page);
$this->y += 80;
- $rightoffset = 180;
-
- $page->drawText(Mage::helper('firegento_pdf')->__( ($mode == 'invoice') ? 'Invoice number:' : 'Creditmemo number:' ), ($this->margin['right'] - $rightoffset), $this->y, $this->encoding);
- $this->Ln();
- $yPlus = 15;
-
- $putOrderId = $this->_putOrderId($order);
- if ($putOrderId) {
- $page->drawText(Mage::helper('firegento_pdf')->__('Order number:'), ($this->margin['right'] - $rightoffset), $this->y, $this->encoding);
- $this->Ln();
- $yPlus += 15;
- }
+ $labelRightOffset = 180;
- if ($order->getCustomerId() != '') {
- $page->drawText(Mage::helper('firegento_pdf')->__('Customer number:'), ($this->margin['right'] - $rightoffset), $this->y, $this->encoding);
- $this->Ln();
- $yPlus += 15;
- }
-
- if (!Mage::getStoreConfigFlag('sales/general/hide_customer_ip', $order->getStoreId())) {
- $page->drawText(Mage::helper('firegento_pdf')->__('Customer IP:'), ($this->margin['right'] - $rightoffset), $this->y, $this->encoding);
- $this->Ln();
- $yPlus += 15;
- }
-
- $page->drawText(Mage::helper('firegento_pdf')->__(($mode == 'invoice') ? 'Invoice date:' : 'Date:'), ($this->margin['right'] - $rightoffset), $this->y, $this->encoding);
- $this->Ln();
- $yPlus += 15;
+ $valueRightOffset = 10;
+ $font = $this->_setFontRegular($page, 10);
+ $width = 80;
+ $numberOfLines = 0;
- // Draw payment method.
- $putPaymentMethod = ($mode == 'invoice' && Mage::getStoreConfig('sales_pdf/invoice/payment_method_position') == FireGento_Pdf_Model_System_Config_Source_Payment::POSITION_HEADER);
- if ($putPaymentMethod) {
- $page->drawText(Mage::helper('firegento_pdf')->__('Payment method:'), ($this->margin['right'] - $rightoffset), $this->y, $this->encoding);
- $this->Ln();
- $yPlus += 15;
- }
- // Draw shipping method.
- $putShippingMethod = ($mode == 'invoice' && Mage::getStoreConfig('sales_pdf/invoice/shipping_method_position') == FireGento_Pdf_Model_System_Config_Source_Shipping::POSITION_HEADER);
- if ($putShippingMethod) {
- $page->drawText(Mage::helper('firegento_pdf')->__('Shipping method:'), ($this->margin['right'] - $rightoffset), $this->y, $this->encoding);
- $this->Ln();
- $yPlus += 15;
+ // Invoice/shipment/creditmemo Number
+ if ($mode == 'invoice') {
+ $numberTitle = 'Invoice number:';
+ } else if ($mode == 'shipment') {
+ $numberTitle = 'Shipment number:';
+ } else {
+ $numberTitle = 'Creditmemo number:';
}
-
- $this->y += $yPlus;
-
- $rightoffset = 10;
- $font = $this->_setFontRegular($page, 10);
+ $page->drawText(Mage::helper('firegento_pdf')->__($numberTitle), ($this->margin['right'] - $labelRightOffset), $this->y, $this->encoding);
$incrementId = $document->getIncrementId();
- $page->drawText($incrementId, ($this->margin['right'] - $rightoffset - $this->widthForStringUsingFontSize($incrementId, $font, 10)), $this->y, $this->encoding);
+ $page->drawText($incrementId, ($this->margin['right'] - $valueRightOffset - $this->widthForStringUsingFontSize($incrementId, $font, 10)), $this->y, $this->encoding);
$this->Ln();
+ $numberOfLines++;
+ // Order Number
+ $putOrderId = $this->_putOrderId($order);
if ($putOrderId) {
- $page->drawText($putOrderId, ($this->margin['right'] - $rightoffset - $this->widthForStringUsingFontSize($putOrderId, $font, 10)), $this->y, $this->encoding);
+ $page->drawText(Mage::helper('firegento_pdf')->__('Order number:'), ($this->margin['right'] - $labelRightOffset), $this->y, $this->encoding);
+ $page->drawText($putOrderId, ($this->margin['right'] - $valueRightOffset - $this->widthForStringUsingFontSize($putOrderId, $font, 10)), $this->y, $this->encoding);
$this->Ln();
+ $numberOfLines++;
}
+ // Customer Number
+ $page->drawText(Mage::helper('firegento_pdf')->__('Customer number:'), ($this->margin['right'] - $labelRightOffset), $this->y, $this->encoding);
+ $numberOfLines++;
+
if ($order->getCustomerId() != '') {
$prefix = Mage::getStoreConfig('sales_pdf/invoice/customeridprefix');
if (!empty($prefix)) {
- $customerid = $prefix.$order->getCustomerId();
+ $customerid = $prefix . $order->getCustomerId();
} else {
$customerid = $order->getCustomerId();
}
- $page->drawText($customerid, ($this->margin['right'] - $rightoffset - $this->widthForStringUsingFontSize($customerid, $font, 10)), $this->y, $this->encoding);
+ $page->drawText($customerid, ($this->margin['right'] - $valueRightOffset - $this->widthForStringUsingFontSize($customerid, $font, 10)), $this->y, $this->encoding);
$this->Ln();
- }else{
- $page->drawText('-', ($this->margin['right'] - $rightoffset - $this->widthForStringUsingFontSize('-', $font, 10)), $this->y, $this->encoding);
+ $numberOfLines++;
+ } else {
+ $page->drawText('-', ($this->margin['right'] - $valueRightOffset - $this->widthForStringUsingFontSize('-', $font, 10)), $this->y, $this->encoding);
$this->Ln();
+ $numberOfLines++;
}
+ // Customer IP
if (!Mage::getStoreConfigFlag('sales/general/hide_customer_ip', $order->getStoreId())) {
+ $page->drawText(Mage::helper('firegento_pdf')->__('Customer IP:'), ($this->margin['right'] - $labelRightOffset), $this->y, $this->encoding);
$customerIP = $order->getData('remote_ip');
$font = $this->_setFontRegular($page, 10);
- $page->drawText($customerIP, ($this->margin['right'] - $rightoffset - $this->widthForStringUsingFontSize($customerIP, $font, 10)), $this->y, $this->encoding);
+ $page->drawText($customerIP, ($this->margin['right'] - $valueRightOffset - $this->widthForStringUsingFontSize($customerIP, $font, 10)), $this->y, $this->encoding);
$this->Ln();
+ $numberOfLines++;
}
+ $page->drawText(Mage::helper('firegento_pdf')->__(($mode == 'invoice') ? 'Invoice date:' : 'Date:'), ($this->margin['right'] - $labelRightOffset), $this->y, $this->encoding);
$documentDate = Mage::helper('core')->formatDate($document->getCreatedAtDate(), 'medium', false);
- $page->drawText($documentDate, ($this->margin['right'] - $rightoffset - $this->widthForStringUsingFontSize($documentDate, $font, 10)), $this->y, $this->encoding);
+ $page->drawText($documentDate, ($this->margin['right'] - $valueRightOffset - $this->widthForStringUsingFontSize($documentDate, $font, 10)), $this->y, $this->encoding);
$this->Ln();
+ $numberOfLines++;
+
+ // Payment method.
+ $putPaymentMethod = ($mode == 'invoice' && Mage::getStoreConfig('sales_pdf/invoice/payment_method_position') == FireGento_Pdf_Model_System_Config_Source_Payment::POSITION_HEADER);
if ($putPaymentMethod) {
- $paymentMethod = $order->getPayment()->getMethodInstance()->getTitle();
- $page->drawText($paymentMethod, ($this->margin['right'] - $rightoffset - $this->widthForStringUsingFontSize($paymentMethod, $font, 10)), $this->y, $this->encoding);
+ $page->drawText(Mage::helper('firegento_pdf')->__('Payment method:'), ($this->margin['right'] - $labelRightOffset), $this->y, $this->encoding);
+ $paymentMethodArray = $this->_prepareText($order->getPayment()->getMethodInstance()->getTitle(), $page, $font, 10, $width);
+ $page->drawText(array_shift($paymentMethodArray), ($this->margin['right'] - $valueRightOffset - $width), $this->y, $this->encoding);
$this->Ln();
+ $numberOfLines++;
+ $paymentMethodArray = $this->_prepareText(implode(" ", $paymentMethodArray), $page, $font, 10, 2 * $width);
+ foreach ($paymentMethodArray as $methodString) {
+ $page->drawText($methodString, $this->margin['right'] - $labelRightOffset, $this->y, $this->encoding);
+ $this->Ln();
+ $numberOfLines++;
+ }
+
}
+ // Shipping method.
+ $putShippingMethod = ($mode == 'invoice' && Mage::getStoreConfig('sales_pdf/invoice/shipping_method_position') == FireGento_Pdf_Model_System_Config_Source_Shipping::POSITION_HEADER);
if ($putShippingMethod) {
- $shippingMethod = $order->getShippingDescription();
- $page->drawText($shippingMethod, ($this->margin['right'] - $rightoffset - $this->widthForStringUsingFontSize($shippingMethod, $font, 10)), $this->y, $this->encoding);
+ $page->drawText(Mage::helper('firegento_pdf')->__('Shipping method:'), ($this->margin['right'] - $labelRightOffset), $this->y, $this->encoding);
+ $shippingMethodArray = $this->_prepareText($order->getShippingDescription(), $page, $font, 10, $width);
+ $page->drawText(array_shift($shippingMethodArray), ($this->margin['right'] - $valueRightOffset - $width), $this->y, $this->encoding);
$this->Ln();
+ $numberOfLines++;
+ $shippingMethodArray = $this->_prepareText(implode(" ", $shippingMethodArray), $page, $font, 10, 2 * $width);
+ foreach ($shippingMethodArray as $methodString) {
+ $page->drawText($methodString, $this->margin['right'] - $labelRightOffset, $this->y, $this->encoding);
+ $this->Ln();
+ $numberOfLines++;
+ }
+
}
+ $this->y -= ($numberOfLines*2);
}
/**
@@ -452,7 +465,7 @@ protected function _drawItem(Varien_Object $item, Zend_Pdf_Page $page, Mage_Sale
*/
protected function insertTotals($page, $source)
{
- $this->y -=15;
+ $this->y -= 15;
$order = $source->getOrder();
@@ -460,8 +473,8 @@ protected function insertTotals($page, $source)
$shippingTaxRate = 0;
$shippingTaxAmount = $order->getShippingTaxAmount();
- if($shippingTaxAmount > 0) {
- $shippingTaxRate = $order->getShippingTaxAmount()*100/($order->getShippingInclTax()-$order->getShippingTaxAmount());
+ if ($shippingTaxAmount > 0) {
+ $shippingTaxRate = $order->getShippingTaxAmount() * 100 / ($order->getShippingInclTax() - $order->getShippingTaxAmount());
}
$groupedTax = array();
@@ -475,10 +488,10 @@ protected function insertTotals($page, $source)
}
array_push($items['items'], array(
- 'row_invoiced' => $order->getShippingInvoiced(),
+ 'row_invoiced' => $order->getShippingInvoiced(),
'tax_inc_subtotal' => false,
- 'tax_percent' => $shippingTaxRate,
- 'tax_amount' => $shippingTaxAmount
+ 'tax_percent' => $shippingTaxRate,
+ 'tax_amount' => $shippingTaxAmount
));
foreach ($items['items'] as $item) {
@@ -487,13 +500,13 @@ protected function insertTotals($page, $source)
if (!isset($item['row_invoiced'])) $item['row_invoiced'] = 0;
if (!isset($item['price'])) $item['price'] = 0;
if (!isset($item['tax_inc_subtotal'])) $item['tax_inc_subtotal'] = 0;
- if (((float)$item['tax_amount'] > 0)&&((float)$item['row_invoiced'] > 0)) {
- $_percent = round($item["tax_percent"],0);
+ if (((float)$item['tax_amount'] > 0) && ((float)$item['row_invoiced'] > 0)) {
+ $_percent = round($item["tax_percent"], 0);
}
if (!array_key_exists('tax_inc_subtotal', $item) || $item['tax_inc_subtotal']) {
$total_tax += $item['tax_amount'];
}
- if (($item['tax_amount'])&&$_percent){
+ if (($item['tax_amount']) && $_percent) {
if (!array_key_exists((int)$_percent, $groupedTax)) {
$groupedTax[$_percent] = $item['tax_amount'];
} else {
@@ -505,169 +518,31 @@ protected function insertTotals($page, $source)
$totals = $this->_getTotalsList($source);
$lineBlock = array(
- 'lines' => array(),
+ 'lines' => array(),
'height' => 20
);
foreach ($totals as $total) {
- $fontSize = (isset($total['font_size']) ? $total['font_size'] : 7);
- if ($fontSize < 9) {
- $fontSize = 9;
- }
- $fontWeight = (isset($total['font_weight']) ? $total['font_weight'] : 'regular');
-
- switch($total['source_field']) {
- case 'tax_amount':
- foreach ($groupedTax as $taxRate => $taxValue) {
- if (empty($taxValue)) {
- continue;
- }
-
- $lineBlock['lines'][] = array(
- array(
- 'text' => Mage::helper('firegento_pdf')->__('Additional tax %s', $source->getStore()->roundPrice(number_format($taxRate, 0)).'%'),
- 'feed' => $this->margin['left'] + 320,
- 'align' => 'left',
- 'font_size' => $fontSize,
- 'font' => $fontWeight
- ),
- array(
- 'text' => $order->formatPriceTxt($taxValue),
- 'feed' => $this->margin['right'] - 10,
- 'align' => 'right',
- 'font_size' => $fontSize,
- 'font' => $fontWeight
- ),
- );
- }
- break;
-
- case 'subtotal':
- $amount = $source->getDataUsingMethod($total['source_field']);
- $displayZero = (isset($total['display_zero']) ? $total['display_zero'] : 0);
-
- if ($amount != 0 || $displayZero) {
- $amount = $order->formatPriceTxt($amount);
-
- if (isset($total['amount_prefix']) && $total['amount_prefix']) {
- $amount = "{$total['amount_prefix']}{$amount}";
- }
-
- $label = Mage::helper('sales')->__($total['title']) . ':';
-
- $lineBlock['lines'][] = array(
- array(
- 'text' => $label,
- 'feed' => $this->margin['left'] + 320,
- 'align' => 'left',
- 'font_size' => $fontSize,
- 'font' => $fontWeight
- ),
- array(
- 'text' => $amount,
- 'feed' => $this->margin['right'] - 10,
- 'align' => 'right',
- 'font_size' => $fontSize,
- 'font' => $fontWeight
- ),
- );
- }
- break;
-
- case 'shipping_amount':
- $amount = $source->getDataUsingMethod($total['source_field']);
- $displayZero = (isset($total['display_zero']) ? $total['display_zero'] : 0);
-
- if ($amount != 0 || $displayZero) {
- $amount = $order->formatPriceTxt($amount);
-
- if (isset($total['amount_prefix']) && $total['amount_prefix']) {
- $amount = "{$total['amount_prefix']}{$amount}";
- }
-
- $label = Mage::helper('sales')->__($total['title']) . ':';
-
- $lineBlock['lines'][] = array(
- array(
- 'text' => Mage::helper('firegento_pdf')->__('Shipping:'),
- 'feed' => $this->margin['left'] + 320,
- 'align' => 'left',
- 'font_size' => $fontSize,
- 'font' => $fontWeight
- ),
- array(
- 'text' => $amount,
- 'feed' => $this->margin['right'] - 10,
- 'align' => 'right',
- 'font_size' => $fontSize,
- 'font' => $fontWeight
- ),
- );
- }
- break;
-
- case 'grand_total':
- $amount = $source->getDataUsingMethod($total['source_field']);
- $displayZero = (isset($total['display_zero']) ? $total['display_zero'] : 0);
-
- if ($amount != 0 || $displayZero) {
- $amount = $order->formatPriceTxt($amount);
-
- if (isset($total['amount_prefix']) && $total['amount_prefix']) {
- $amount = "{$total['amount_prefix']}{$amount}";
- }
-
- $label = Mage::helper('sales')->__($total['title']) . ':';
-
- $lineBlock['lines'][] = array(
- array(
- 'text' => $label,
- 'feed' => $this->margin['left'] + 320,
- 'align' => 'left',
- 'font_size' => $fontSize,
- 'font' => $fontWeight
- ),
- array(
- 'text' => $amount,
- 'feed' => $this->margin['right'] - 10,
- 'align' => 'right',
- 'font_size' => $fontSize,
- 'font' => $fontWeight
- ),
- );
- }
- break;
-
- default:
- $amount = $source->getDataUsingMethod($total['source_field']);
- $displayZero = (isset($total['display_zero']) ? $total['display_zero'] : 0);
-
- if ($amount != 0 || $displayZero) {
- $amount = $order->formatPriceTxt($amount);
-
- if (isset($total['amount_prefix']) && $total['amount_prefix']) {
- $amount = "{$total['amount_prefix']}{$amount}";
- }
-
- $label = Mage::helper('sales')->__($total['title']) . ':';
-
- $lineBlock['lines'][] = array(
- array(
- 'text' => $label,
- 'feed' => $this->margin['left'] + 320,
- 'align' => 'left',
- 'font_size' => $fontSize,
- 'font' => $fontWeight
- ),
- array(
- 'text' => $amount,
- 'feed' => $this->margin['right'] - 10,
- 'align' => 'right',
- 'font_size' => $fontSize,
- 'font' => $fontWeight
- ),
- );
- }
+ $total->setOrder($order)->setSource($source);
+
+ if ($total->canDisplay()) {
+ $total->setFontSize(10);
+ foreach ($total->getTotalsForDisplay() as $totalData) {
+ $lineBlock['lines'][] = array(
+ array(
+ 'text' => $totalData['label'],
+ 'feed' => 470,
+ 'align' => 'right',
+ 'font_size' => $totalData['font_size']
+ ),
+ array(
+ 'text' => $totalData['amount'],
+ 'feed' => 540,
+ 'align' => 'right',
+ 'font_size' => $totalData['font_size']
+ ),
+ );
+ }
}
}
$page = $this->drawLineBlocks($page, array($lineBlock));
@@ -709,11 +584,9 @@ protected function _insertNote($page, &$order, &$model)
// Draw notes on PDF.
foreach ($notes as $note) {
// prepare the text so that it fits to the paper
- $note = $this->_prepareText($note, $page, $font, $fontSize);
- $tmpNotes = explode("\n", $note);
- foreach ($tmpNotes as $tmpNote) {
+ foreach ($this->_prepareText($note, $page, $font, 10) as $tmpNote) {
// create a new page if necessary
- if ($this->y < 100) {
+ if ($this->y < 50 || (Mage::getStoreConfig('sales_pdf/firegento_pdf/show_footer') == 1 && $this->y < 100)) {
$page = $this->newPage(array());
$this->y = $this->y - 60;
$font = $this->_setFontRegular($page, $fontSize);
@@ -817,9 +690,7 @@ protected function _insertFooterBlock(&$page, $fields, $colposition = 0, $valadj
// calculate the maximum width for the value
$width = $this->margin['left'] + $colposition + $colwidth - ($this->margin['left'] + $valposition);
}
- $tmpVal = $this->_prepareText($val, $page, $font, $fontSize, $width);
- $tmpVals = explode("\n", $tmpVal);
- foreach ($tmpVals as $tmpVal) {
+ foreach ($this->_prepareText($val, $page, $font, $fontSize, $width) as $tmpVal) {
$page->drawText($tmpVal, $this->margin['left'] + $valposition, $y, $this->encoding);
$y -= 12;
}
@@ -836,20 +707,20 @@ protected function _insertFooterBlock(&$page, $fields, $colposition = 0, $valadj
*/
protected function _insertFooterAddress(&$page, $store = null)
{
- $address = $this->imprint['company_first']."\n";
+ $address = $this->imprint['company_first'] . "\n";
if (array_key_exists('company_second', $this->imprint)) {
$address .= $this->imprint['company_second'] . "\n";
}
- $address .= $this->imprint['street']."\n";
- $address .= $this->imprint['zip']." ";
- $address .= $this->imprint['city']."\n";
+ $address .= $this->imprint['street'] . "\n";
+ $address .= $this->imprint['zip'] . " ";
+ $address .= $this->imprint['city'] . "\n";
$this->_setFontRegular($page, 7);
$y = $this->y;
foreach (explode("\n", $address) as $value) {
- if ($value!=='') {
+ if ($value !== '') {
$page->drawText(trim(strip_tags($value)), $this->margin['left'] - 20, $y, $this->encoding);
$y -= 12;
}
@@ -865,7 +736,7 @@ protected function _insertFooterAddress(&$page, $store = null)
protected function _insertPageCounter(&$page)
{
$font = $this->_setFontRegular($page, 9);
- $page->drawText(Mage::helper('firegento_pdf')->__('Page').' '.$this->pagecounter, $this->margin['right'] - 23 - $this->widthForStringUsingFontSize($this->pagecounter, $font, 9), $this->y, $this->encoding);
+ $page->drawText(Mage::helper('firegento_pdf')->__('Page') . ' ' . $this->pagecounter, $this->margin['right'] - 23 - $this->widthForStringUsingFontSize($this->pagecounter, $font, 9), $this->y, $this->encoding);
}
/**
@@ -923,6 +794,9 @@ protected function _setFontItalic($object, $size = 10)
*/
protected function _prepareText($text, $page, $font, $fontSize, $width = null)
{
+ if (empty($text)) {
+ return array();
+ }
$lines = '';
$currentLine = '';
// calculate the page's width with respect to the margins
@@ -945,8 +819,6 @@ protected function _prepareText($text, $page, $font, $fontSize, $width = null)
}
// append the last line
$lines .= $currentLine;
- return $lines;
+ return explode("\n", $lines);
}
-
-}
-
+}
\ No newline at end of file
diff --git a/app/code/community/FireGento/Pdf/Model/Engine/Creditmemo/Default.php b/app/code/community/FireGento/Pdf/Model/Engine/Creditmemo/Default.php
new file mode 100644
index 0000000..8bd210f
--- /dev/null
+++ b/app/code/community/FireGento/Pdf/Model/Engine/Creditmemo/Default.php
@@ -0,0 +1,185 @@
+
+ * @copyright 2013 FireGento Team (http://www.firegento.de). All rights served.
+ * @license http://opensource.org/licenses/gpl-3.0 GNU General Public License, version 3 (GPLv3)
+ * @version $Id:$
+ * @since 0.1.0
+ */
+/**
+ * Creditmemo model rewrite.
+ *
+ * @category FireGento
+ * @package FireGento_Pdf
+ * @author FireGento Team
+ * @copyright 2013 FireGento Team (http://www.firegento.de). All rights served.
+ * @license http://opensource.org/licenses/gpl-3.0 GNU General Public License, version 3 (GPLv3)
+ * @version $Id:$
+ * @since 0.1.0
+ */
+class FireGento_Pdf_Model_Engine_Creditmemo_Default extends FireGento_Pdf_Model_Engine_Abstract
+{
+
+ public function __construct()
+ {
+ parent::__construct();
+ $this->setMode('creditmemo');
+ }
+
+ /**
+ * Return PDF document
+ *
+ * @param array $creditmemos
+ * @return Zend_Pdf
+ */
+ public function getPdf($creditmemos = array())
+ {
+ $this->_beforeGetPdf();
+ $this->_initRenderer('creditmemo');
+
+ $pdf = new Zend_Pdf();
+ $this->_setPdf($pdf);
+
+ $style = new Zend_Pdf_Style();
+ $this->_setFontBold($style, 10);
+
+ // pagecounter is 0 at the beginning, because it is incremented in newPage()
+ $this->pagecounter = 0;
+
+ foreach ($creditmemos as $creditmemo) {
+ if ($creditmemo->getStoreId()) {
+ Mage::app()->getLocale()->emulate($creditmemo->getStoreId());
+ Mage::app()->setCurrentStore($creditmemo->getStoreId());
+ }
+ $page = $this->newPage();
+
+ $order = $creditmemo->getOrder();
+
+ // Add logo
+ $this->insertLogo($page, $creditmemo->getStore());
+
+ // Add billing address
+ $this->y = 692;
+ $this->insertBillingAddress($page, $order);
+
+ // Add sender address
+ $this->y = 705;
+ $this->_insertSenderAddessBar($page);
+
+ // Add head
+ $this->y = 592;
+ $this->insertHeader($page, $order, $creditmemo);
+
+ // Add footer
+ $this->_addFooter($page, $creditmemo->getStore());
+
+ /* Add table head */
+ $this->_setFontRegular($page, 9);
+ $this->y = 562;
+ $this->_drawHeader($page);
+
+ $this->y -=20;
+
+ $position = 0;
+
+ /* Add body */
+ foreach ($creditmemo->getAllItems() as $item){
+ if ($item->getOrderItem()->getParentItem()) {
+ continue;
+ }
+ /* Draw item */
+ $position++;
+ $this->_drawItem($item, $page, $order, $position);
+ $page = end($pdf->pages);
+ }
+
+ /* add line after items */
+ $page->drawLine($this->margin['left'], $this->y + 5, $this->margin['right'], $this->y + 5);
+
+ /* Add totals */
+ $page = $this->insertTotals($page, $creditmemo);
+
+ /* add note */
+ $page = $this->_insertNote($page, $order, $creditmemo);
+ }
+
+ $this->_afterGetPdf();
+
+ if ($creditmemo->getStoreId()) {
+ Mage::app()->getLocale()->revert();
+ }
+ return $pdf;
+ }
+
+ /**
+ * Draw table header for product items
+ *
+ * @param Zend_Pdf_Page $page
+ * @return void
+ */
+ protected function _drawHeader(Zend_Pdf_Page $page)
+ {
+ $page->setFillColor($this->colors['grey1']);
+ $page->setLineColor($this->colors['grey1']);
+ $page->setLineWidth(1);
+ $page->drawRectangle($this->margin['left'], $this->y, $this->margin['right'], $this->y - 15);
+
+ $page->setFillColor($this->colors['black']);
+ $font = $this->_setFontRegular($page, 9);
+
+ $this->y -= 11;
+ $page->drawText(Mage::helper('firegento_pdf')->__('Pos'), $this->margin['left'] + 3, $this->y, $this->encoding);
+ $page->drawText(Mage::helper('firegento_pdf')->__('No.'), $this->margin['left'] + 25, $this->y, $this->encoding);
+ $page->drawText(Mage::helper('firegento_pdf')->__('Description'), $this->margin['left'] + 120, $this->y, $this->encoding);
+
+ $singlePrice = Mage::helper('firegento_pdf')->__('Price (excl. tax)');
+ $page->drawText($singlePrice, $this->margin['right'] - 153 - $this->widthForStringUsingFontSize($singlePrice, $font, 9), $this->y, $this->encoding);
+
+ $page->drawText(Mage::helper('firegento_pdf')->__('Qty'), $this->margin['left'] + 360, $this->y, $this->encoding);
+
+ $taxLabel = Mage::helper('firegento_pdf')->__('Tax');
+ $page->drawText($taxLabel, $this->margin['right'] - 65 - $this->widthForStringUsingFontSize($taxLabel, $font, 9), $this->y, $this->encoding);
+
+ $totalLabel = Mage::helper('firegento_pdf')->__('Total');
+ $page->drawText($totalLabel, $this->margin['right'] - 10 - $this->widthForStringUsingFontSize($totalLabel, $font, 10), $this->y, $this->encoding);
+ }
+
+ /**
+ * Initialize renderer process.
+ *
+ * @param string $type
+ * @return void
+ */
+ protected function _initRenderer($type)
+ {
+ parent::_initRenderer($type);
+
+ $this->_renderers['default'] = array(
+ 'model' => 'firegento_pdf/items_default',
+ 'renderer' => null
+ );
+ $this->_renderers['grouped'] = array(
+ 'model' => 'firegento_pdf/items_grouped',
+ 'renderer' => null
+ );
+ $this->_renderers['bundle'] = array(
+ 'model' => 'firegento_pdf/items_bundle',
+ 'renderer' => null
+ );
+ }
+
+}
diff --git a/app/code/community/FireGento/Pdf/Model/Engine/Invoice/Default.php b/app/code/community/FireGento/Pdf/Model/Engine/Invoice/Default.php
index 6042f41..28c3240 100644
--- a/app/code/community/FireGento/Pdf/Model/Engine/Invoice/Default.php
+++ b/app/code/community/FireGento/Pdf/Model/Engine/Invoice/Default.php
@@ -31,7 +31,7 @@
* @version $Id:$
* @since 0.1.0
*/
-class FireGento_Pdf_Model_Engine_Invoice_Default extends FireGento_Pdf_Model_Abstract
+class FireGento_Pdf_Model_Engine_Invoice_Default extends FireGento_Pdf_Model_Engine_Abstract
{
public function __construct()
@@ -84,15 +84,12 @@ public function getPdf($invoices = array())
$this->y = 592;
$this->insertHeader($page, $order, $invoice);
- // Add footer
- $this->_addFooter($page, $invoice->getStore());
/* add table header */
$this->_setFontRegular($page, 9);
- $this->y = 562;
$this->insertTableHeader($page);
- $this->y -=20;
+ $this->y -= 20;
$position = 0;
@@ -100,8 +97,7 @@ public function getPdf($invoices = array())
if ($item->getOrderItem()->getParentItem()) {
continue;
}
-
- if ($this->y < 100) {
+ if ($this->y < 50 || (Mage::getStoreConfig('sales_pdf/firegento_pdf/show_footer') == 1 && $this->y < 100)) {
$page = $this->newPage(array());
}
@@ -116,7 +112,11 @@ public function getPdf($invoices = array())
$page = $this->insertTotals($page, $invoice);
/* add note */
- $this->_insertNote($page, $order, $invoice);
+ $page = $this->_insertNote($page, $order, $invoice);
+
+ // Add footer
+ $this->_addFooter($page, $invoice->getStore());
+
}
$this->_afterGetPdf();
@@ -142,20 +142,58 @@ protected function insertTableHeader(&$page)
$font = $this->_setFontRegular($page, 9);
$this->y -= 11;
- $page->drawText(Mage::helper('firegento_pdf')->__('Pos'), $this->margin['left'] + 3, $this->y, $this->encoding);
- $page->drawText(Mage::helper('firegento_pdf')->__('No.'), $this->margin['left'] + 25, $this->y, $this->encoding);
- $page->drawText(Mage::helper('firegento_pdf')->__('Description'), $this->margin['left'] + 120, $this->y, $this->encoding);
-
- $singlePrice = Mage::helper('firegento_pdf')->__('Price (excl. tax)');
- $page->drawText($singlePrice, $this->margin['right'] - 153 - $this->widthForStringUsingFontSize($singlePrice, $font, 9), $this->y, $this->encoding);
-
- $page->drawText(Mage::helper('firegento_pdf')->__('Qty'), $this->margin['left'] + 360, $this->y, $this->encoding);
-
- $taxLabel = Mage::helper('firegento_pdf')->__('Tax');
- $page->drawText($taxLabel, $this->margin['right'] - 65 - $this->widthForStringUsingFontSize($taxLabel, $font, 9), $this->y, $this->encoding);
-
- $totalLabel = Mage::helper('firegento_pdf')->__('Total');
- $page->drawText($totalLabel, $this->margin['right'] - 10 - $this->widthForStringUsingFontSize($totalLabel, $font, 10), $this->y, $this->encoding);
+ $page->drawText(Mage::helper('firegento_pdf')->__('Pos'), $this->margin['left'] + 3, $this->y, $this->encoding);
+ $page->drawText(Mage::helper('firegento_pdf')->__('No.'), $this->margin['left'] + 25, $this->y, $this->encoding);
+ $page->drawText(Mage::helper('firegento_pdf')->__('Description'), $this->margin['left'] + 120, $this->y, $this->encoding);
+
+ $columns = array();
+ $columns['price'] = array(
+ 'label' => Mage::helper('firegento_pdf')->__('Price'),
+ '_width' => 60
+ );
+ $columns['price_incl_tax'] = array(
+ 'label' => Mage::helper('firegento_pdf')->__('Price (incl. tax)'),
+ '_width' => 60
+ );
+ $columns['qty'] = array(
+ 'label' => Mage::helper('firegento_pdf')->__('Qty'),
+ '_width' => 40
+ );
+ $columns['tax'] = array(
+ 'label' => Mage::helper('firegento_pdf')->__('Tax'),
+ '_width' => 50
+ );
+ $columns['tax_rate'] = array(
+ 'label' => Mage::helper('firegento_pdf')->__('Tax rate'),
+ '_width' => 50
+ );
+ $columns['subtotal'] = array(
+ 'label' => Mage::helper('firegento_pdf')->__('Total'),
+ '_width' => 50
+ );
+ $columns['subtotal_incl_tax'] = array(
+ 'label' => Mage::helper('firegento_pdf')->__('Total (incl. tax)'),
+ '_width' => 70
+ );
+ // draw price, tax, and subtotal in specified order
+ $columnsOrder = explode(',', Mage::getStoreConfig('sales_pdf/invoice/item_price_column_order'));
+ // draw starting from right
+ $columnsOrder = array_reverse($columnsOrder);
+ $columnOffset = 0;
+ foreach ($columnsOrder as $columnName) {
+ $columnName = trim($columnName);
+ if (array_key_exists($columnName, $columns)) {
+ $column = $columns[$columnName];
+ $labelWidth = $this->widthForStringUsingFontSize($column['label'], $font, 9);
+ $page->drawText(
+ $column['label'],
+ $this->margin['right'] - $columnOffset - $labelWidth,
+ $this->y,
+ $this->encoding
+ );
+ $columnOffset += $column['_width'];
+ }
+ }
}
/**
diff --git a/app/code/community/FireGento/Pdf/Model/Engine/Shipment/Default.php b/app/code/community/FireGento/Pdf/Model/Engine/Shipment/Default.php
new file mode 100644
index 0000000..6e7343d
--- /dev/null
+++ b/app/code/community/FireGento/Pdf/Model/Engine/Shipment/Default.php
@@ -0,0 +1,170 @@
+
+ * @copyright 2013 FireGento Team (http://www.firegento.de). All rights served.
+ * @license http://opensource.org/licenses/gpl-3.0 GNU General Public License, version 3 (GPLv3)
+ * @version $Id:$
+ * @since 0.1.0
+ */
+/**
+ * Shipment model rewrite.
+ *
+ * @category FireGento
+ * @package FireGento_Pdf
+ * @author FireGento Team
+ * @copyright 2013 FireGento Team (http://www.firegento.de). All rights served.
+ * @license http://opensource.org/licenses/gpl-3.0 GNU General Public License, version 3 (GPLv3)
+ * @version $Id:$
+ * @since 0.1.0
+ */
+class FireGento_Pdf_Model_Engine_Shipment_Default extends FireGento_Pdf_Model_Engine_Abstract
+{
+
+ public function __construct()
+ {
+ parent::__construct();
+ $this->setMode('shipment');
+ }
+
+ /**
+ * Return PDF document
+ *
+ * @param array $shipments
+ * @return Zend_Pdf
+ */
+ public function getPdf($shipments = array())
+ {
+ $this->_beforeGetPdf();
+ $this->_initRenderer('shipment');
+
+ $pdf = new Zend_Pdf();
+ $this->_setPdf($pdf);
+
+ $style = new Zend_Pdf_Style();
+ $this->_setFontBold($style, 10);
+
+ // pagecounter is 0 at the beginning, because it is incremented in newPage()
+ $this->pagecounter = 0;
+
+ foreach ($shipments as $shipment) {
+ if ($shipment->getStoreId()) {
+ Mage::app()->getLocale()->emulate($shipment->getStoreId());
+ Mage::app()->setCurrentStore($shipment->getStoreId());
+ }
+ $page = $this->newPage();
+
+ $order = $shipment->getOrder();
+
+ /* add logo */
+ $this->insertLogo($page, $shipment->getStore());
+
+ // Add shipping address
+ $this->y = 692;
+ $this->insertShippingAddress($page, $order);
+
+ /* add sender address */
+ $this->y = 705;
+ $this->_insertSenderAddessBar($page);
+
+ /* add header */
+ $this->y = 592;
+ $this->insertHeader($page, $order, $shipment);
+
+ // Add footer
+ $this->_addFooter($page, $shipment->getStore());
+
+ /* add table header */
+ $this->_setFontRegular($page, 9);
+ $this->y = 562;
+ $this->insertTableHeader($page);
+
+ $this->y -=20;
+
+ $position = 0;
+
+ foreach ($shipment->getAllItems() as $item) {
+ if ($item->getOrderItem()->getParentItem()) {
+ continue;
+ }
+
+ if ($this->y < 50 || (Mage::getStoreConfig('sales_pdf/firegento_pdf/show_footer') == 1 && $this->y < 100)) {
+ $page = $this->newPage(array());
+ }
+
+ $position++;
+ $page = $this->_drawItem($item, $page, $order, $position);
+ }
+
+ /* add note */
+ $page = $this->_insertNote($page, $order, $shipment);
+ }
+
+ $this->_afterGetPdf();
+
+ return $pdf;
+ }
+
+ protected function insertTableHeader(&$page)
+ {
+ $page->setFillColor($this->colors['grey1']);
+ $page->setLineColor($this->colors['grey1']);
+ $page->setLineWidth(1);
+ $page->drawRectangle($this->margin['left'], $this->y, $this->margin['right'] - 10, $this->y - 15);
+
+ $page->setFillColor($this->colors['black']);
+ $font = $this->_setFontRegular($page, 9);
+
+ $this->y -= 11;
+ $page->drawText(Mage::helper('firegento_pdf')->__('No.'), $this->margin['left'], $this->y, $this->encoding);
+ $page->drawText(Mage::helper('firegento_pdf')->__('Description'), $this->margin['left'] + 105, $this->y, $this->encoding);
+
+ $page->drawText(Mage::helper('firegento_pdf')->__('Qty'), $this->margin['left'] + 450, $this->y, $this->encoding);
+ }
+
+ protected function insertShippingAddress(&$page, $order)
+ {
+ $this->_setFontRegular($page, 9);
+
+ $billing = $this->_formatAddress($order->getShippingAddress()->format('pdf'));
+
+ foreach ($billing as $line) {
+ $page->drawText(trim(strip_tags($line)), $this->margin['left'], $this->y, $this->encoding);
+ $this->Ln(12);
+ }
+ }
+
+ /**
+ * Initialize renderer process.
+ *
+ * @param string $type
+ * @return void
+ */
+ protected function _initRenderer($type)
+ {
+ parent::_initRenderer($type);
+
+ $this->_renderers['default'] = array(
+ 'model' => 'firegento_pdf/items_shipment_default',
+ 'renderer' => null
+ );
+ $this->_renderers['bundle'] = array(
+ 'model' => 'firegento_pdf/items_shipment_bundle',
+ 'renderer' => null
+ );
+ }
+
+}
diff --git a/app/code/community/FireGento/Pdf/Model/Invoice.php b/app/code/community/FireGento/Pdf/Model/Invoice.php
index 196d1cb..f4df73b 100644
--- a/app/code/community/FireGento/Pdf/Model/Invoice.php
+++ b/app/code/community/FireGento/Pdf/Model/Invoice.php
@@ -46,7 +46,7 @@ class FireGento_Pdf_Model_Invoice
protected function getEngine()
{
if (!$this->_engine) {
- $modelClass = Mage::getStoreConfig('sales_pdf/firegento_pdf/engine');
+ $modelClass = Mage::getStoreConfig('sales_pdf/invoice/engine');
$engine = Mage::getModel($modelClass);
if (!$engine) {
@@ -65,39 +65,4 @@ public function getPdf($invoices = array())
return $this->getEngine()->getPdf($invoices);
}
- public function widthForStringUsingFontSize($string, $font, $fontSize)
- {
- return $this->getEngine()->widthForStringUsingFontSize($string, $font, $fontSize);
- }
-
- public function getAlignRight($string, $x, $columnWidth, Zend_Pdf_Resource_Font $font, $fontSize, $padding = 5)
- {
- return $this->getEngine()->getAlignRight($string, $x, $columnWidth, $font, $fontSize);
- }
-
- public function getAlignCenter($string, $x, $columnWidth, Zend_Pdf_Resource_Font $font, $fontSize)
- {
- return $this->getEngine()->getAlignCenter($string, $x, $columnWidth, $font, $fontSize);
- }
-
- public function insertDocumentNumber(Zend_Pdf_Page $page, $text)
- {
- return $this->getEngine()->insertDocumentNumber($page, $text);
- }
-
- public function getRenderer($type)
- {
- return $this->getEngine()->getRenderer($type);
- }
-
- public function newPage(array $settings = array())
- {
- return $this->getEngine()->newPage($settings);
- }
-
- public function drawLineBlocks(Zend_Pdf_Page $page, array $draw, array $pageSettings = array())
- {
- return $this->getEngine()->drawLineBlocks($page, $draw, $pageSettings);
- }
-
}
diff --git a/app/code/community/FireGento/Pdf/Model/Items/Default.php b/app/code/community/FireGento/Pdf/Model/Items/Default.php
index 0f204b0..4d7e13e 100644
--- a/app/code/community/FireGento/Pdf/Model/Items/Default.php
+++ b/app/code/community/FireGento/Pdf/Model/Items/Default.php
@@ -41,44 +41,36 @@ class FireGento_Pdf_Model_Items_Default extends Mage_Sales_Model_Order_Pdf_Items
*/
public function draw($position = 1)
{
- $order = $this->getOrder();
- $item = $this->getItem();
- $pdf = $this->getPdf();
- $page = $this->getPage();
- $lines = array();
+ $order = $this->getOrder();
+ $item = $this->getItem();
+ $pdf = $this->getPdf();
+ $page = $this->getPage();
+ $lines = array();
$fontSize = 9;
// draw Position Number
- $lines[0]= array(array(
- 'text' => $position,
- 'feed' => $pdf->margin['left'] + 10,
+ $lines[0] = array(array(
+ 'text' => $position,
+ 'feed' => $pdf->margin['left'] + 10,
'align' => 'right',
'font_size' => $fontSize
));
// draw SKU
$lines[0][] = array(
- 'text' => Mage::helper('core/string')->str_split($this->getSku($item), 17),
- 'feed' => $pdf->margin['left'] + 25,
+ 'text' => Mage::helper('core/string')->str_split($this->getSku($item), 17),
+ 'feed' => $pdf->margin['left'] + 25,
'font_size' => $fontSize
);
// draw Product name
- $lines[0][]= array(
+ $lines[0][] = array(
'text' => Mage::helper('core/string')->str_split($item->getName(), 40, true, true),
'feed' => $pdf->margin['left'] + 120,
'font_size' => $fontSize
);
- // draw QTY
- $lines[0][] = array(
- 'text' => $item->getQty() * 1,
- 'feed' => $pdf->margin['right'] - 120,
- 'align' => 'right',
- 'font_size' => $fontSize
- );
-
$options = $this->getItemOptions();
if ($options) {
foreach ($options as $option) {
@@ -103,36 +95,98 @@ public function draw($position = 1)
}
}
- // draw Price
- $lines[0][] = array(
- 'text' => $order->formatPriceTxt($item->getPrice()),
- 'feed' => $pdf->margin['right'] - 160,
+ $columns = array();
+ // prepare qty
+ $columns['qty'] = array(
+ 'text' => $item->getQty() * 1,
'align' => 'right',
- 'font_size' => $fontSize
+ 'font_size' => $fontSize,
+ '_width' => 40
);
- // draw Tax
- $lines[0][] = array(
- 'text' => $order->formatPriceTxt($item->getTaxAmount()),
- 'feed' => $pdf->margin['right'] - 60,
+ // prepare price
+ $columns['price'] = array(
+ 'text' => $order->formatPriceTxt($item->getPrice()),
'align' => 'right',
- 'font_size' => $fontSize
+ 'font_size' => $fontSize,
+ '_width' => 60
);
- // draw Subtotal
- $lines[0][] = array(
+ // prepare price_incl_tax
+ $columns['price_incl_tax'] = array(
+ 'text' => $order->formatPriceTxt($item->getPriceInclTax()),
+ 'align' => 'right',
+ 'font_size' => $fontSize,
+ '_width' => 60
+ );
+
+ // prepare tax
+ $columns['tax'] = array(
+ 'text' => $order->formatPriceTxt($item->getTaxAmount()),
+ 'align' => 'right',
+ 'font_size' => $fontSize,
+ '_width' => 50
+ );
+
+ // prepare tax_rate
+ $columns['tax_rate'] = array(
+ 'text' => round($item->getOrderItem()->getTaxPercent(), 2) . '%',
+ 'align' => 'right',
+ 'font_size' => $fontSize,
+ '_width' => 50
+ );
+
+ // prepare subtotal
+ $columns['subtotal'] = array(
+ 'text' => $order->formatPriceTxt($item->getPrice() * $item->getQty() * 1),
+ 'align' => 'right',
+ 'font_size' => $fontSize,
+ '_width' => 50
+ );
+
+ // prepare subtotal_incl_tax
+ $columns['subtotal_incl_tax'] = array(
'text' => $order->formatPriceTxt(($item->getPrice() * $item->getQty() * 1) + $item->getTaxAmount()),
- 'feed' => $pdf->margin['right'] - 10,
'align' => 'right',
- 'font_size' => $fontSize
+ 'font_size' => $fontSize,
+ '_width' => 70
);
+ // draw columns in specified order
+ $columnsOrder = explode(',', Mage::getStoreConfig('sales_pdf/invoice/item_price_column_order'));
+ // draw starting from right
+ $columnsOrder = array_reverse($columnsOrder);
+ $columnOffset = 0;
+ foreach ($columnsOrder as $columnName) {
+ $columnName = trim($columnName);
+ if (array_key_exists($columnName, $columns)) {
+ $column = $columns[$columnName];
+ $column['feed'] = $pdf->margin['right'] - $columnOffset;
+ $columnOffset += $column['_width'];
+ unset($column['_width']);
+ $lines[0][] = $column;
+ }
+ }
+
+ if (Mage::getStoreConfig('sales_pdf/invoice/show_item_discount') && 0 < $item->getDiscountAmount()) {
+ // print discount
+ $text = Mage::helper('firegento_pdf')->__(
+ 'You get a discount of %s.',
+ $order->formatPriceTxt($item->getDiscountAmount())
+ );
+ $lines[][] = array(
+ 'text' => $text,
+ 'align' => 'right',
+ 'feed' => $pdf->margin['right'] - $columnOffset
+ );
+ }
+
$lineBlock = array(
- 'lines' => $lines,
+ 'lines' => $lines,
'height' => 15
);
$page = $pdf->drawLineBlocks($page, array($lineBlock), array('table_header' => true));
$this->setPage($page);
}
-}
+}
\ No newline at end of file
diff --git a/app/code/community/FireGento/Pdf/Model/Shipment.php b/app/code/community/FireGento/Pdf/Model/Shipment.php
index b51c82b..055d328 100644
--- a/app/code/community/FireGento/Pdf/Model/Shipment.php
+++ b/app/code/community/FireGento/Pdf/Model/Shipment.php
@@ -31,141 +31,35 @@
* @version $Id:$
* @since 0.1.0
*/
-class FireGento_Pdf_Model_Shipment extends FireGento_Pdf_Model_Abstract
+class FireGento_Pdf_Model_Shipment
{
- public function __construct()
- {
- parent::__construct();
- $this->setMode('shipment');
- }
-
/**
- * Return PDF document
- *
- * @param array $shipments
- * @return Zend_Pdf
+ * The actual PDF engine responsible for rendering the file.
+ * @var Mage_Sales_Model_Order_Pdf_Abstract
*/
- public function getPdf($shipments = array())
- {
- $this->_beforeGetPdf();
- $this->_initRenderer('shipment');
-
- $pdf = new Zend_Pdf();
- $this->_setPdf($pdf);
-
- $style = new Zend_Pdf_Style();
- $this->_setFontBold($style, 10);
-
- // pagecounter is 0 at the beginning, because it is incremented in newPage()
- $this->pagecounter = 0;
-
- foreach ($shipments as $shipment) {
- if ($shipment->getStoreId()) {
- Mage::app()->getLocale()->emulate($shipment->getStoreId());
- Mage::app()->setCurrentStore($shipment->getStoreId());
- }
- $page = $this->newPage();
-
- $order = $shipment->getOrder();
-
- /* add logo */
- $this->insertLogo($page, $shipment->getStore());
-
- // Add shipping address
- $this->y = 692;
- $this->insertShippingAddress($page, $order);
-
- /* add sender address */
- $this->y = 705;
- $this->_insertSenderAddessBar($page);
-
- /* add header */
- $this->y = 592;
- $this->insertHeader($page, $order, $shipment);
-
- // Add footer
- $this->_addFooter($page, $shipment->getStore());
-
- /* add table header */
- $this->_setFontRegular($page, 9);
- $this->y = 562;
- $this->insertTableHeader($page);
-
- $this->y -=20;
-
- $position = 0;
-
- foreach ($shipment->getAllItems() as $item) {
- if ($item->getOrderItem()->getParentItem()) {
- continue;
- }
+ private $_engine;
- if ($this->y < 100) {
- $page = $this->newPage(array());
- }
+ protected function getEngine()
+ {
+ if (!$this->_engine) {
+ $modelClass = Mage::getStoreConfig('sales_pdf/shipment/engine');
+ $engine = Mage::getModel($modelClass);
- $position++;
- $page = $this->_drawItem($item, $page, $order, $position);
+ if (!$engine) {
+ // Fallback to Magento standard shipment layout.
+ $engine = new Mage_Sales_Model_Order_Pdf_Shipment();
}
- /* add note */
- $page = $this->_insertNote($page, $order, $shipment);
+ $this->_engine = $engine;
}
- $this->_afterGetPdf();
-
- return $pdf;
- }
-
- protected function insertTableHeader(&$page)
- {
- $page->setFillColor($this->colors['grey1']);
- $page->setLineColor($this->colors['grey1']);
- $page->setLineWidth(1);
- $page->drawRectangle($this->margin['left'], $this->y, $this->margin['right'] - 10, $this->y - 15);
-
- $page->setFillColor($this->colors['black']);
- $font = $this->_setFontRegular($page, 9);
-
- $this->y -= 11;
- $page->drawText(Mage::helper('firegento_pdf')->__('No.'), $this->margin['left'], $this->y, $this->encoding);
- $page->drawText(Mage::helper('firegento_pdf')->__('Description'), $this->margin['left'] + 105, $this->y, $this->encoding);
-
- $page->drawText(Mage::helper('firegento_pdf')->__('Qty'), $this->margin['left'] + 450, $this->y, $this->encoding);
+ return $this->_engine;
}
- protected function insertShippingAddress(&$page, $order)
- {
- $this->_setFontRegular($page, 9);
-
- $billing = $this->_formatAddress($order->getShippingAddress()->format('pdf'));
-
- foreach ($billing as $line) {
- $page->drawText(trim(strip_tags($line)), $this->margin['left'], $this->y, $this->encoding);
- $this->Ln(12);
- }
- }
-
- /**
- * Initialize renderer process.
- *
- * @param string $type
- * @return void
- */
- protected function _initRenderer($type)
+ public function getPdf($shipments = array())
{
- parent::_initRenderer($type);
-
- $this->_renderers['default'] = array(
- 'model' => 'firegento_pdf/items_shipment_default',
- 'renderer' => null
- );
- $this->_renderers['bundle'] = array(
- 'model' => 'firegento_pdf/items_shipment_bundle',
- 'renderer' => null
- );
+ return $this->getEngine()->getPdf($shipments);
}
}
-
diff --git a/app/code/community/FireGento/Pdf/Model/System/Config/Source/Creditmemo/Engine.php b/app/code/community/FireGento/Pdf/Model/System/Config/Source/Creditmemo/Engine.php
new file mode 100644
index 0000000..8243bb5
--- /dev/null
+++ b/app/code/community/FireGento/Pdf/Model/System/Config/Source/Creditmemo/Engine.php
@@ -0,0 +1,74 @@
+
+ * @copyright 2013 FireGento Team (http://www.firegento.de). All rights served.
+ * @license http://opensource.org/licenses/gpl-3.0 GNU General Public License, version 3 (GPLv3)
+ * @version $Id:$
+ * @since 0.1.0
+ */
+/**
+ * Pdf creation engine source model.
+ *
+ * @category FireGento
+ * @package FireGento_Pdf
+ * @author FireGento Team
+ * @copyright 2013 FireGento Team (http://www.firegento.de). All rights served.
+ * @license http://opensource.org/licenses/gpl-3.0 GNU General Public License, version 3 (GPLv3)
+ * @version $Id:$
+ * @since 0.1.0
+ */
+class FireGento_Pdf_Model_System_Config_Source_Creditmemo_Engine
+{
+ /**
+ * Config xpath to pdf engine node
+ *
+ */
+ const XML_PATH_PDF_ENGINE = 'global/pdf/firegento_creditmemo_engines';
+
+ /**
+ * Return array of possible engines.
+ *
+ * @return array
+ */
+ public function toOptionArray()
+ {
+ // load default engines shipped with Mage_Sales and FireGento_Pdf
+ $engines = array(
+ '' => Mage::helper('firegento_pdf')->__('Standard Magento'),
+ 'firegento_pdf/engine_creditmemo_default' => Mage::helper('firegento_pdf')->__('Standard Germany')
+ );
+
+ // load additional engines provided by third party extensions
+ $engineNodes = Mage::app()->getConfig()->getNode(self::XML_PATH_PDF_ENGINE);
+ if ($engineNodes && $engineNodes->hasChildren()) {
+ foreach ($engineNodes->children() as $engineName => $engineNode) {
+ $className = (string)$engineNode->class;
+ $engineLabel = Mage::helper('firegento_pdf')->__((string)$engineNode->label);
+ $engines[$className] = $engineLabel;
+ }
+ }
+
+ $options = array();
+ foreach ($engines as $k => $v) {
+ $options[] = array(
+ 'value' => $k,
+ 'label' => $v
+ );
+ }
+ return $options;
+ }
+}
diff --git a/app/code/community/FireGento/Pdf/Model/System/Config/Source/Engine.php b/app/code/community/FireGento/Pdf/Model/System/Config/Source/Invoice/Engine.php
similarity index 94%
rename from app/code/community/FireGento/Pdf/Model/System/Config/Source/Engine.php
rename to app/code/community/FireGento/Pdf/Model/System/Config/Source/Invoice/Engine.php
index 6c1c76c..f0d4ed0 100644
--- a/app/code/community/FireGento/Pdf/Model/System/Config/Source/Engine.php
+++ b/app/code/community/FireGento/Pdf/Model/System/Config/Source/Invoice/Engine.php
@@ -31,13 +31,13 @@
* @version $Id:$
* @since 0.1.0
*/
-class FireGento_Pdf_Model_System_Config_Source_Engine
+class FireGento_Pdf_Model_System_Config_Source_Invoice_Engine
{
/**
* Config xpath to pdf engine node
*
*/
- const XML_PATH_PDF_ENGINE = 'global/pdf/firegento_engines';
+ const XML_PATH_PDF_ENGINE = 'global/pdf/firegento_invoice_engines';
/**
* Return array of possible engines.
diff --git a/app/code/community/FireGento/Pdf/Model/System/Config/Source/Shipment/Engine.php b/app/code/community/FireGento/Pdf/Model/System/Config/Source/Shipment/Engine.php
new file mode 100644
index 0000000..83cf51c
--- /dev/null
+++ b/app/code/community/FireGento/Pdf/Model/System/Config/Source/Shipment/Engine.php
@@ -0,0 +1,74 @@
+
+ * @copyright 2013 FireGento Team (http://www.firegento.de). All rights served.
+ * @license http://opensource.org/licenses/gpl-3.0 GNU General Public License, version 3 (GPLv3)
+ * @version $Id:$
+ * @since 0.1.0
+ */
+/**
+ * Pdf creation engine source model.
+ *
+ * @category FireGento
+ * @package FireGento_Pdf
+ * @author FireGento Team
+ * @copyright 2013 FireGento Team (http://www.firegento.de). All rights served.
+ * @license http://opensource.org/licenses/gpl-3.0 GNU General Public License, version 3 (GPLv3)
+ * @version $Id:$
+ * @since 0.1.0
+ */
+class FireGento_Pdf_Model_System_Config_Source_Shipment_Engine
+{
+ /**
+ * Config xpath to pdf engine node
+ *
+ */
+ const XML_PATH_PDF_ENGINE = 'global/pdf/firegento_shipment_engines';
+
+ /**
+ * Return array of possible engines.
+ *
+ * @return array
+ */
+ public function toOptionArray()
+ {
+ // load default engines shipped with Mage_Sales and FireGento_Pdf
+ $engines = array(
+ '' => Mage::helper('firegento_pdf')->__('Standard Magento'),
+ 'firegento_pdf/engine_shipment_default' => Mage::helper('firegento_pdf')->__('Standard Germany')
+ );
+
+ // load additional engines provided by third party extensions
+ $engineNodes = Mage::app()->getConfig()->getNode(self::XML_PATH_PDF_ENGINE);
+ if ($engineNodes && $engineNodes->hasChildren()) {
+ foreach ($engineNodes->children() as $engineName => $engineNode) {
+ $className = (string)$engineNode->class;
+ $engineLabel = Mage::helper('firegento_pdf')->__((string)$engineNode->label);
+ $engines[$className] = $engineLabel;
+ }
+ }
+
+ $options = array();
+ foreach ($engines as $k => $v) {
+ $options[] = array(
+ 'value' => $k,
+ 'label' => $v
+ );
+ }
+ return $options;
+ }
+}
diff --git a/app/code/community/FireGento/Pdf/Model/Tax/Sales/Pdf/Grandtotal.php b/app/code/community/FireGento/Pdf/Model/Tax/Sales/Pdf/Grandtotal.php
new file mode 100644
index 0000000..268c219
--- /dev/null
+++ b/app/code/community/FireGento/Pdf/Model/Tax/Sales/Pdf/Grandtotal.php
@@ -0,0 +1,99 @@
+
+ * @copyright 2013 FireGento Team (http://www.firegento.de). All rights served.
+ * @license http://opensource.org/licenses/gpl-3.0 GNU General Public License, version 3 (GPLv3)
+ */
+/**
+ * Shipment bundle item model.
+ *
+ * @category FireGento
+ * @package FireGento_Pdf
+ * @author FireGento Team
+ * @copyright 2013 FireGento Team (http://www.firegento.de). All rights served.
+ * @license http://opensource.org/licenses/gpl-3.0 GNU General Public License, version 3 (GPLv3)
+ * @version $Id:$
+ * @since 0.1.0
+ */
+class FireGento_Pdf_Model_Tax_Sales_Pdf_Grandtotal extends Mage_Tax_Model_Sales_Pdf_Grandtotal
+{
+
+ CONST NO_SUM_ON_DETAILS = 'tax/sales_display/no_sum_on_details';
+
+ /**
+ * Check if tax amount should be included to grandtotals block
+ * array(
+ * $index => array(
+ * 'amount' => $amount,
+ * 'label' => $label,
+ * 'font_size'=> $font_size
+ * )
+ * )
+ * @return array
+ */
+ public function getTotalsForDisplay()
+ {
+ $store = $this->getOrder()->getStore();
+ $config = Mage::getSingleton('tax/config');
+ $noDisplaySumOnDetails = Mage::getStoreConfig(self::NO_SUM_ON_DETAILS, $store);
+ if (!$config->displaySalesTaxWithGrandTotal($store)) {
+ return parent::getTotalsForDisplay();
+ }
+ $amount = $this->getOrder()->formatPriceTxt($this->getAmount());
+ $amountExclTax = $this->getAmount() - $this->getSource()->getTaxAmount();
+ $amountExclTax = ($amountExclTax > 0) ? $amountExclTax : 0;
+ $amountExclTax = $this->getOrder()->formatPriceTxt($amountExclTax);
+ $tax = $this->getOrder()->formatPriceTxt($this->getSource()->getTaxAmount());
+ $fontSize = $this->getFontSize() ? $this->getFontSize() : 7;
+
+ $totals = array(array(
+ 'amount' => $this->getAmountPrefix() . $amountExclTax,
+ 'label' => Mage::helper('tax')->__('Grand Total (Excl. Tax)') . ':',
+ 'font_size' => $fontSize
+ ));
+
+ /**
+ * if display_sales_full_summary = 1
+ * display each tax group
+ * if no_sum_on_details is = 1 display tax total additionally
+ * else display only tax total
+ */
+ if ($config->displaySalesFullSummary($store)) {
+ $totals = array_merge($totals, $this->getFullTaxInfo());
+ if (!$noDisplaySumOnDetails) {
+ $totals[] = array(
+ 'amount' => $this->getAmountPrefix() . $tax,
+ 'label' => Mage::helper('tax')->__('Tax') . ':',
+ 'font_size' => $fontSize
+ );
+ }
+ } else {
+ $totals[] = array(
+ 'amount' => $this->getAmountPrefix() . $tax,
+ 'label' => Mage::helper('tax')->__('Tax') . ':',
+ 'font_size' => $fontSize
+ );
+ }
+
+ $totals[] = array(
+ 'amount' => $this->getAmountPrefix() . $amount,
+ 'label' => Mage::helper('tax')->__('Grand Total (Incl. Tax)') . ':',
+ 'font_size' => $fontSize
+ );
+ return $totals;
+ }
+}
\ No newline at end of file
diff --git a/app/code/community/FireGento/Pdf/etc/config.xml b/app/code/community/FireGento/Pdf/etc/config.xml
index 7228c49..6fb5ca8 100644
--- a/app/code/community/FireGento/Pdf/etc/config.xml
+++ b/app/code/community/FireGento/Pdf/etc/config.xml
@@ -2,10 +2,15 @@
- 1.0.0
+ 1.1.0
+
+
+ FireGento_Pdf_Block
+
+
FireGento_Pdf_Helper
@@ -22,7 +27,19 @@
FireGento_Pdf_Model_Shipment
+
+
+ FireGento_Pdf_Model_Tax_Sales_Pdf_Grandtotal
+
+
+
+
+
+ FireGento_Pdf
+
+
+
@@ -73,4 +90,23 @@
+
+
+
+
+ price_incl_tax,qty,tax,subtotal_incl_tax
+
+
+
+
+
+
+
+
+
+
+ 0
+
+
+
diff --git a/app/code/community/FireGento/Pdf/etc/system.xml b/app/code/community/FireGento/Pdf/etc/system.xml
index 7404bac..16baf03 100644
--- a/app/code/community/FireGento/Pdf/etc/system.xml
+++ b/app/code/community/FireGento/Pdf/etc/system.xml
@@ -24,10 +24,36 @@
-->
+
+
+
+
+
+
+ select
+ adminhtml/system_config_source_yesno
+ 70
+ 1
+ 1
+ 1
+
+
+
+
+
+
+
+ select
+ firegento_pdf/system_config_source_invoice_engine
+ 0
+ 1
+ 1
+ 1
+
text
@@ -66,10 +92,36 @@
1
Printed on every invoice.
+
+
+ firegento_pdf/adminhtml_columnOrder
+ 5
+ 1
+ 1
+ 1
+
+
+
+ select
+ adminhtml/system_config_source_yesno
+ 10
+ 1
+ 1
+ 1
+
+
+
+ select
+ firegento_pdf/system_config_source_shipment_engine
+ 0
+ 1
+ 1
+ 1
+
textarea
@@ -83,6 +135,15 @@
+
+
+ select
+ firegento_pdf/system_config_source_creditmemo_engine
+ 0
+ 1
+ 1
+ 1
+
textarea
@@ -102,15 +163,6 @@
1
1
-
-
- select
- firegento_pdf/system_config_source_engine
- 0
- 1
- 1
- 1
-
text
diff --git a/app/code/community/FireGento/Pdf/sql/firegento_pdf_setup/upgrade-1.0.0-1.1.0.php b/app/code/community/FireGento/Pdf/sql/firegento_pdf_setup/upgrade-1.0.0-1.1.0.php
new file mode 100644
index 0000000..33d4c3c
--- /dev/null
+++ b/app/code/community/FireGento/Pdf/sql/firegento_pdf_setup/upgrade-1.0.0-1.1.0.php
@@ -0,0 +1,44 @@
+
+ * @copyright 2013 FireGento Team (http://www.firegento.de). All rights served.
+ * @license http://opensource.org/licenses/gpl-3.0 GNU General Public License, version 3 (GPLv3)
+ * @version $Id:$
+ * @since 0.1.0
+ */
+/**
+ * Invoice model rewrite.
+ *
+ * The invoice model serves as a proxy to the actual PDF engine as set via
+ * backend configuration.
+ *
+ * @category FireGento
+ * @package FireGento_Pdf
+ * @author FireGento Team
+ * @copyright 2013 FireGento Team (http://www.firegento.de). All rights served.
+ * @license http://opensource.org/licenses/gpl-3.0 GNU General Public License, version 3 (GPLv3)
+ * @version $Id:$
+ * @since 0.1.0
+ */
+
+/* @var $this Mage_Eav_Model_Entity_Setup */
+$installer = $this;
+$installer->startSetup();
+
+$installer->deleteConfigData('sales_pdf/firegento_pdf/engine');
+
+$installer->endSetup();
diff --git a/app/locale/de_DE/FireGento_Pdf.csv b/app/locale/de_DE/FireGento_Pdf.csv
index 30a2ef2..77342f6 100644
--- a/app/locale/de_DE/FireGento_Pdf.csv
+++ b/app/locale/de_DE/FireGento_Pdf.csv
@@ -66,4 +66,14 @@
"Position of payment method on invoice.","Position der Zahlungart auf der Rechnung."
"Show Shipping Method","Versandart andrucken"
"Hide shipping method","Nicht andrucken"
-"Position of shipping method on invoice.","Position der Versandart auf der Rechnung."
\ No newline at end of file
+"Position of shipping method on invoice.","Position der Versandart auf der Rechnung."
+"not to be listed","nicht aufzulisten"
+"Show Item Discount","Rabatt auf Artikelebene anzeigen"
+"You get a discount of %s.","Sie erhalten einen Rabatt von %s."
+"Tax amount","Steuerbetrag"
+"Price (incl. tax)","Preis (Brutto)"
+"Subtotal (incl. tax)","Zwischensumme (Brutto)"
+"Order of price columns of items","Reihenfolge der Spalten in der Artikelliste"
+"Define the order by moving the following items using your mouse:","Legen Sie die Reihenfolge durch Verschieben der Einträge mit der Maus fest:"
+"Tax rate","Steuersatz"
+"Total (incl. tax)","Gesamt (brutto)"
\ No newline at end of file