Version Notes
Refactoring, New Feature configurable engines for shipment,creditmemo
Download this release
Release Info
Developer | FireGento Team |
Extension | FireGento_Pdf |
Version | 1.1.0 |
Comparing to | |
See all releases |
Code changes from version 1.0.0 to 1.1.0
- app/code/community/FireGento/Pdf/Block/Adminhtml/ColumnOrder.php +114 -0
- app/code/community/FireGento/Pdf/Model/Creditmemo.php +16 -137
- app/code/community/FireGento/Pdf/Model/{Abstract.php → Engine/Abstract.php} +126 -254
- app/code/community/FireGento/Pdf/Model/Engine/Creditmemo/Default.php +185 -0
- app/code/community/FireGento/Pdf/Model/Engine/Invoice/Default.php +60 -22
- app/code/community/FireGento/Pdf/Model/Engine/Shipment/Default.php +170 -0
- app/code/community/FireGento/Pdf/Model/Invoice.php +1 -36
- app/code/community/FireGento/Pdf/Model/Items/Default.php +89 -35
- app/code/community/FireGento/Pdf/Model/Shipment.php +16 -122
- app/code/community/FireGento/Pdf/Model/System/Config/Source/Creditmemo/Engine.php +74 -0
- app/code/community/FireGento/Pdf/Model/System/Config/Source/{Engine.php → Invoice/Engine.php} +2 -2
- app/code/community/FireGento/Pdf/Model/System/Config/Source/Shipment/Engine.php +74 -0
- app/code/community/FireGento/Pdf/Model/Tax/Sales/Pdf/Grandtotal.php +99 -0
- app/code/community/FireGento/Pdf/etc/config.xml +37 -1
- app/code/community/FireGento/Pdf/etc/system.xml +61 -9
- app/code/community/FireGento/Pdf/sql/firegento_pdf_setup/upgrade-1.0.0-1.1.0.php +44 -0
- app/locale/de_DE/FireGento_Pdf.csv +11 -1
- package.xml +5 -5
app/code/community/FireGento/Pdf/Block/Adminhtml/ColumnOrder.php
ADDED
@@ -0,0 +1,114 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Firegento
|
4 |
+
*
|
5 |
+
* @category Block
|
6 |
+
* @package FireGento_Pdf
|
7 |
+
* @author FireGento Team <team@firegento.com>
|
8 |
+
* @copyright 2013 FireGento Team (http://www.firegento.de). All rights served.
|
9 |
+
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
|
10 |
+
*/
|
11 |
+
class Firegento_Pdf_Block_Adminhtml_ColumnOrder
|
12 |
+
extends Mage_Adminhtml_Block_System_Config_Form_Field
|
13 |
+
{
|
14 |
+
protected $sortableListHtml = '';
|
15 |
+
|
16 |
+
protected function _getElementHtml(Varien_Data_Form_Element_Abstract $element)
|
17 |
+
{
|
18 |
+
return '
|
19 |
+
<style>.orderable_config li {list-style: disc inside; cursor:move;}</style>
|
20 |
+
<p>' . $this->__('Define the order by moving the following items using your mouse:') . '<p>
|
21 |
+
<ul id="' . $element->getHtmlId() . '_list" class="orderable_config">
|
22 |
+
' . $this->_getSortableListHtml($element) . '
|
23 |
+
</ul>
|
24 |
+
<input type="hidden" value="' . $element->getValue() . '" name="' . $element->getName() . '" id="' . $element->getHtmlId() . '">
|
25 |
+
<script type="text/javascript">
|
26 |
+
Sortable.create("' . $element->getHtmlId() . '_list", {
|
27 |
+
onUpdate: function() {
|
28 |
+
var inheritCheckbox = $("' . $element->getHtmlId() . '_inherit");
|
29 |
+
if (inheritCheckbox) {
|
30 |
+
inheritCheckbox.checked=false;
|
31 |
+
}
|
32 |
+
var newOrder="";
|
33 |
+
$A(this.element.children).each(function(item){
|
34 |
+
var current = $(item).attributes["data-column"].value;
|
35 |
+
if ("disabled" == current) {
|
36 |
+
$("' . $element->getHtmlId() . '").value = newOrder;
|
37 |
+
} else {
|
38 |
+
if (0 < newOrder.length) {
|
39 |
+
newOrder+=",";
|
40 |
+
}
|
41 |
+
newOrder+=current;
|
42 |
+
}
|
43 |
+
});
|
44 |
+
validateSortableWidth();
|
45 |
+
}
|
46 |
+
});
|
47 |
+
validateSortableWidth = function () {
|
48 |
+
var newWidth=0;
|
49 |
+
console.log("Calculation columns width");
|
50 |
+
$A($("' . $element->getHtmlId() . '_list").children).each(function(item){
|
51 |
+
var current = $(item).attributes["data-column"].value;
|
52 |
+
if ($(item.attributes["data-width"])) {
|
53 |
+
newWidth += parseInt($(item).attributes["data-width"].value);
|
54 |
+
} else if ("disabled" == current) {
|
55 |
+
console.log(newWidth);
|
56 |
+
if (240 < newWidth) {
|
57 |
+
$("' . $element->getHtmlId() . '_warning").innerHTML = "' . $this->__('Caution: Your columns may overlap!') . '";
|
58 |
+
$("' . $element->getHtmlId() . '_warning").show();
|
59 |
+
} else {
|
60 |
+
$("' . $element->getHtmlId() . '_warning").hide();
|
61 |
+
}
|
62 |
+
}
|
63 |
+
});
|
64 |
+
};
|
65 |
+
validateSortableWidth();
|
66 |
+
</script>
|
67 |
+
';
|
68 |
+
}
|
69 |
+
|
70 |
+
protected function _getSortableListHtml(Varien_Data_Form_Element_Abstract $element)
|
71 |
+
{
|
72 |
+
$availableItems = array(
|
73 |
+
'price_incl_tax' => array('width' => 60, 'label' => $this->__('Price (incl. tax)')),
|
74 |
+
'price' => array('width' => 60, 'label' => $this->__('Price')),
|
75 |
+
'qty' => array('width' => 40, 'label' => $this->__('Qty')),
|
76 |
+
'subtotal_incl_tax' => array('width' => 70, 'label' => $this->__('Subtotal (incl. tax)')),
|
77 |
+
'subtotal' => array('width' => 50, 'label' => $this->__('Subtotal')),
|
78 |
+
'tax' => array('width' => 50, 'label' => $this->__('Tax amount')),
|
79 |
+
'tax_rate' => array('width' => 50, 'label' => $this->__('Tax rate')),
|
80 |
+
);
|
81 |
+
$activeItems = array();
|
82 |
+
foreach (explode(',', $element->getValue()) as $item) {
|
83 |
+
$item = trim($item);
|
84 |
+
if (array_key_exists($item, $availableItems)) {
|
85 |
+
$activeItems[$item] = $availableItems[$item];
|
86 |
+
unset($availableItems[$item]);
|
87 |
+
}
|
88 |
+
}
|
89 |
+
|
90 |
+
$this->_addListItems($activeItems);
|
91 |
+
$this->sortableListHtml .= '<li id="pdf-column-disabled" data-column="disabled" style="list-style:none">
|
92 |
+
<div id="' . $element->getHtmlId() . '_warning" style="display:none" class="validation-advice"></div>
|
93 |
+
<br />
|
94 |
+
' . $this->__('not to be listed') . '
|
95 |
+
</li>';
|
96 |
+
$this->_addListItems($availableItems);
|
97 |
+
|
98 |
+
return $this->sortableListHtml;
|
99 |
+
}
|
100 |
+
|
101 |
+
protected function _addListItems($items)
|
102 |
+
{
|
103 |
+
foreach ($items as $name=>$item) {
|
104 |
+
$this->sortableListHtml .= sprintf(
|
105 |
+
'<li id="pdf-column-%s" data-column="%s" data-width="%s">%s</li>',
|
106 |
+
$name,
|
107 |
+
$name,
|
108 |
+
$item['width'],
|
109 |
+
$item['label']
|
110 |
+
);
|
111 |
+
}
|
112 |
+
return $this;
|
113 |
+
}
|
114 |
+
}
|
app/code/community/FireGento/Pdf/Model/Creditmemo.php
CHANGED
@@ -31,156 +31,35 @@
|
|
31 |
* @version $Id:$
|
32 |
* @since 0.1.0
|
33 |
*/
|
34 |
-
class FireGento_Pdf_Model_Creditmemo
|
35 |
{
|
36 |
|
37 |
-
public function __construct()
|
38 |
-
{
|
39 |
-
parent::__construct();
|
40 |
-
$this->setMode('creditmemo');
|
41 |
-
}
|
42 |
-
|
43 |
/**
|
44 |
-
*
|
45 |
-
*
|
46 |
-
* @param array $creditmemos
|
47 |
-
* @return Zend_Pdf
|
48 |
*/
|
49 |
-
|
50 |
-
{
|
51 |
-
$this->_beforeGetPdf();
|
52 |
-
$this->_initRenderer('creditmemo');
|
53 |
-
|
54 |
-
$pdf = new Zend_Pdf();
|
55 |
-
$this->_setPdf($pdf);
|
56 |
-
|
57 |
-
$style = new Zend_Pdf_Style();
|
58 |
-
$this->_setFontBold($style, 10);
|
59 |
-
|
60 |
-
// pagecounter is 0 at the beginning, because it is incremented in newPage()
|
61 |
-
$this->pagecounter = 0;
|
62 |
-
|
63 |
-
foreach ($creditmemos as $creditmemo) {
|
64 |
-
if ($creditmemo->getStoreId()) {
|
65 |
-
Mage::app()->getLocale()->emulate($creditmemo->getStoreId());
|
66 |
-
Mage::app()->setCurrentStore($creditmemo->getStoreId());
|
67 |
-
}
|
68 |
-
$page = $this->newPage();
|
69 |
|
70 |
-
|
71 |
-
|
72 |
-
|
73 |
-
$
|
74 |
-
|
75 |
-
// Add billing address
|
76 |
-
$this->y = 692;
|
77 |
-
$this->insertBillingAddress($page, $order);
|
78 |
-
|
79 |
-
// Add sender address
|
80 |
-
$this->y = 705;
|
81 |
-
$this->_insertSenderAddessBar($page);
|
82 |
-
|
83 |
-
// Add head
|
84 |
-
$this->y = 592;
|
85 |
-
$this->insertHeader($page, $order, $creditmemo);
|
86 |
-
|
87 |
-
// Add footer
|
88 |
-
$this->_addFooter($page, $creditmemo->getStore());
|
89 |
-
|
90 |
-
/* Add table head */
|
91 |
-
$this->_setFontRegular($page, 9);
|
92 |
-
$this->y = 562;
|
93 |
-
$this->_drawHeader($page);
|
94 |
-
|
95 |
-
$this->y -=20;
|
96 |
-
|
97 |
-
$position = 0;
|
98 |
|
99 |
-
|
100 |
-
|
101 |
-
|
102 |
-
continue;
|
103 |
-
}
|
104 |
-
/* Draw item */
|
105 |
-
$position++;
|
106 |
-
$this->_drawItem($item, $page, $order, $position);
|
107 |
-
$page = end($pdf->pages);
|
108 |
}
|
109 |
|
110 |
-
|
111 |
-
$page->drawLine($this->margin['left'], $this->y + 5, $this->margin['right'], $this->y + 5);
|
112 |
-
|
113 |
-
/* Add totals */
|
114 |
-
$page = $this->insertTotals($page, $creditmemo);
|
115 |
-
|
116 |
-
/* add note */
|
117 |
-
$page = $this->_insertNote($page, $order, $creditmemo);
|
118 |
}
|
119 |
|
120 |
-
$this->
|
121 |
-
|
122 |
-
if ($creditmemo->getStoreId()) {
|
123 |
-
Mage::app()->getLocale()->revert();
|
124 |
-
}
|
125 |
-
return $pdf;
|
126 |
}
|
127 |
|
128 |
-
|
129 |
-
* Draw table header for product items
|
130 |
-
*
|
131 |
-
* @param Zend_Pdf_Page $page
|
132 |
-
* @return void
|
133 |
-
*/
|
134 |
-
protected function _drawHeader(Zend_Pdf_Page $page)
|
135 |
-
{
|
136 |
-
$page->setFillColor($this->colors['grey1']);
|
137 |
-
$page->setLineColor($this->colors['grey1']);
|
138 |
-
$page->setLineWidth(1);
|
139 |
-
$page->drawRectangle($this->margin['left'], $this->y, $this->margin['right'], $this->y - 15);
|
140 |
-
|
141 |
-
$page->setFillColor($this->colors['black']);
|
142 |
-
$font = $this->_setFontRegular($page, 9);
|
143 |
-
|
144 |
-
$this->y -= 11;
|
145 |
-
$page->drawText(Mage::helper('firegento_pdf')->__('Pos'), $this->margin['left'] + 3, $this->y, $this->encoding);
|
146 |
-
$page->drawText(Mage::helper('firegento_pdf')->__('No.'), $this->margin['left'] + 25, $this->y, $this->encoding);
|
147 |
-
$page->drawText(Mage::helper('firegento_pdf')->__('Description'), $this->margin['left'] + 120, $this->y, $this->encoding);
|
148 |
-
|
149 |
-
$singlePrice = Mage::helper('firegento_pdf')->__('Price (excl. tax)');
|
150 |
-
$page->drawText($singlePrice, $this->margin['right'] - 153 - $this->widthForStringUsingFontSize($singlePrice, $font, 9), $this->y, $this->encoding);
|
151 |
-
|
152 |
-
$page->drawText(Mage::helper('firegento_pdf')->__('Qty'), $this->margin['left'] + 360, $this->y, $this->encoding);
|
153 |
-
|
154 |
-
$taxLabel = Mage::helper('firegento_pdf')->__('Tax');
|
155 |
-
$page->drawText($taxLabel, $this->margin['right'] - 65 - $this->widthForStringUsingFontSize($taxLabel, $font, 9), $this->y, $this->encoding);
|
156 |
-
|
157 |
-
$totalLabel = Mage::helper('firegento_pdf')->__('Total');
|
158 |
-
$page->drawText($totalLabel, $this->margin['right'] - 10 - $this->widthForStringUsingFontSize($totalLabel, $font, 10), $this->y, $this->encoding);
|
159 |
-
}
|
160 |
-
|
161 |
-
/**
|
162 |
-
* Initialize renderer process.
|
163 |
-
*
|
164 |
-
* @param string $type
|
165 |
-
* @return void
|
166 |
-
*/
|
167 |
-
protected function _initRenderer($type)
|
168 |
{
|
169 |
-
|
170 |
-
|
171 |
-
$this->_renderers['default'] = array(
|
172 |
-
'model' => 'firegento_pdf/items_default',
|
173 |
-
'renderer' => null
|
174 |
-
);
|
175 |
-
$this->_renderers['grouped'] = array(
|
176 |
-
'model' => 'firegento_pdf/items_grouped',
|
177 |
-
'renderer' => null
|
178 |
-
);
|
179 |
-
$this->_renderers['bundle'] = array(
|
180 |
-
'model' => 'firegento_pdf/items_bundle',
|
181 |
-
'renderer' => null
|
182 |
-
);
|
183 |
}
|
184 |
|
185 |
}
|
186 |
-
|
31 |
* @version $Id:$
|
32 |
* @since 0.1.0
|
33 |
*/
|
34 |
+
class FireGento_Pdf_Model_Creditmemo
|
35 |
{
|
36 |
|
|
|
|
|
|
|
|
|
|
|
|
|
37 |
/**
|
38 |
+
* The actual PDF engine responsible for rendering the file.
|
39 |
+
* @var Mage_Sales_Model_Order_Pdf_Abstract
|
|
|
|
|
40 |
*/
|
41 |
+
private $_engine;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
42 |
|
43 |
+
protected function getEngine()
|
44 |
+
{
|
45 |
+
if (!$this->_engine) {
|
46 |
+
$modelClass = Mage::getStoreConfig('sales_pdf/creditmemo/engine');
|
47 |
+
$engine = Mage::getModel($modelClass);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
48 |
|
49 |
+
if (!$engine) {
|
50 |
+
// Fallback to Magento standard creditmemo layout.
|
51 |
+
$engine = new Mage_Sales_Model_Order_Pdf_Creditmemo();
|
|
|
|
|
|
|
|
|
|
|
|
|
52 |
}
|
53 |
|
54 |
+
$this->_engine = $engine;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
55 |
}
|
56 |
|
57 |
+
return $this->_engine;
|
|
|
|
|
|
|
|
|
|
|
58 |
}
|
59 |
|
60 |
+
public function getPdf($creditmemos = array())
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
61 |
{
|
62 |
+
return $this->getEngine()->getPdf($creditmemos);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
63 |
}
|
64 |
|
65 |
}
|
|
app/code/community/FireGento/Pdf/Model/{Abstract.php → Engine/Abstract.php}
RENAMED
@@ -31,7 +31,7 @@
|
|
31 |
* @version $Id:$
|
32 |
* @since 0.1.0
|
33 |
*/
|
34 |
-
abstract class
|
35 |
{
|
36 |
public $margin = array('left' => 45, 'right' => 540);
|
37 |
public $colors = array();
|
@@ -68,7 +68,7 @@ abstract class FireGento_Pdf_Model_Abstract extends Mage_Sales_Model_Order_Pdf_A
|
|
68 |
if (!isset($itemsProp['lines']) || !is_array($itemsProp['lines'])) {
|
69 |
Mage::throwException(Mage::helper('sales')->__('Invalid draw line data. Please define "lines" array'));
|
70 |
}
|
71 |
-
$lines
|
72 |
$height = isset($itemsProp['height']) ? $itemsProp['height'] : 10;
|
73 |
|
74 |
if (empty($itemsProp['shift'])) {
|
@@ -92,19 +92,18 @@ abstract class FireGento_Pdf_Model_Abstract extends Mage_Sales_Model_Order_Pdf_A
|
|
92 |
$itemsProp['shift'] = $shift;
|
93 |
}
|
94 |
|
95 |
-
if ($this->y - $itemsProp['shift'] < 100) {
|
96 |
$page = $this->newPage($pageSettings);
|
97 |
}
|
98 |
|
99 |
foreach ($lines as $line) {
|
100 |
$maxHeight = 0;
|
101 |
foreach ($line as $column) {
|
102 |
-
$fontSize
|
103 |
if (!empty($column['font_file'])) {
|
104 |
$font = Zend_Pdf_Font::fontWithPath($column['font_file']);
|
105 |
$page->setFont($font, $fontSize);
|
106 |
-
}
|
107 |
-
else {
|
108 |
$fontStyle = empty($column['font']) ? 'regular' : $column['font'];
|
109 |
switch ($fontStyle) {
|
110 |
case 'bold':
|
@@ -133,8 +132,7 @@ abstract class FireGento_Pdf_Model_Abstract extends Mage_Sales_Model_Order_Pdf_A
|
|
133 |
case 'right':
|
134 |
if ($width) {
|
135 |
$feed = $this->getAlignRight($part, $feed, $width, $font, $fontSize);
|
136 |
-
}
|
137 |
-
else {
|
138 |
$feed = $feed - $this->widthForStringUsingFontSize($part, $font, $fontSize);
|
139 |
}
|
140 |
break;
|
@@ -144,7 +142,7 @@ abstract class FireGento_Pdf_Model_Abstract extends Mage_Sales_Model_Order_Pdf_A
|
|
144 |
}
|
145 |
break;
|
146 |
}
|
147 |
-
$page->drawText($part, $feed, $this->y
|
148 |
$top += $lineSpacing;
|
149 |
}
|
150 |
|
@@ -227,9 +225,9 @@ abstract class FireGento_Pdf_Model_Abstract extends Mage_Sales_Model_Order_Pdf_A
|
|
227 |
|
228 |
$logoPosition = Mage::getStoreConfig('sales_pdf/firegento_pdf/logo_position', $store);
|
229 |
|
230 |
-
switch($logoPosition) {
|
231 |
case 'center':
|
232 |
-
$startLogoAt = $this->margin['left'] + (
|
233 |
break;
|
234 |
case 'right':
|
235 |
$startLogoAt = $this->margin['right'] - $width;
|
@@ -281,109 +279,124 @@ abstract class FireGento_Pdf_Model_Abstract extends Mage_Sales_Model_Order_Pdf_A
|
|
281 |
|
282 |
$this->_setFontBold($page, 15);
|
283 |
|
284 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
285 |
|
286 |
$this->_setFontRegular($page);
|
287 |
|
288 |
$this->y += 80;
|
289 |
-
$
|
290 |
-
|
291 |
-
$page->drawText(Mage::helper('firegento_pdf')->__( ($mode == 'invoice') ? 'Invoice number:' : 'Creditmemo number:' ), ($this->margin['right'] - $rightoffset), $this->y, $this->encoding);
|
292 |
-
$this->Ln();
|
293 |
-
$yPlus = 15;
|
294 |
-
|
295 |
-
$putOrderId = $this->_putOrderId($order);
|
296 |
-
if ($putOrderId) {
|
297 |
-
$page->drawText(Mage::helper('firegento_pdf')->__('Order number:'), ($this->margin['right'] - $rightoffset), $this->y, $this->encoding);
|
298 |
-
$this->Ln();
|
299 |
-
$yPlus += 15;
|
300 |
-
}
|
301 |
|
302 |
-
|
303 |
-
|
304 |
-
|
305 |
-
|
306 |
-
}
|
307 |
-
|
308 |
-
if (!Mage::getStoreConfigFlag('sales/general/hide_customer_ip', $order->getStoreId())) {
|
309 |
-
$page->drawText(Mage::helper('firegento_pdf')->__('Customer IP:'), ($this->margin['right'] - $rightoffset), $this->y, $this->encoding);
|
310 |
-
$this->Ln();
|
311 |
-
$yPlus += 15;
|
312 |
-
}
|
313 |
-
|
314 |
-
$page->drawText(Mage::helper('firegento_pdf')->__(($mode == 'invoice') ? 'Invoice date:' : 'Date:'), ($this->margin['right'] - $rightoffset), $this->y, $this->encoding);
|
315 |
-
$this->Ln();
|
316 |
-
$yPlus += 15;
|
317 |
|
318 |
-
// Draw payment method.
|
319 |
-
$putPaymentMethod = ($mode == 'invoice' && Mage::getStoreConfig('sales_pdf/invoice/payment_method_position') == FireGento_Pdf_Model_System_Config_Source_Payment::POSITION_HEADER);
|
320 |
-
if ($putPaymentMethod) {
|
321 |
-
$page->drawText(Mage::helper('firegento_pdf')->__('Payment method:'), ($this->margin['right'] - $rightoffset), $this->y, $this->encoding);
|
322 |
-
$this->Ln();
|
323 |
-
$yPlus += 15;
|
324 |
-
}
|
325 |
|
326 |
-
//
|
327 |
-
|
328 |
-
|
329 |
-
|
330 |
-
$
|
331 |
-
|
|
|
332 |
}
|
333 |
-
|
334 |
-
$this->y += $yPlus;
|
335 |
-
|
336 |
-
$rightoffset = 10;
|
337 |
-
$font = $this->_setFontRegular($page, 10);
|
338 |
|
339 |
$incrementId = $document->getIncrementId();
|
340 |
-
$page->drawText($incrementId, ($this->margin['right'] - $
|
341 |
$this->Ln();
|
|
|
342 |
|
|
|
|
|
343 |
if ($putOrderId) {
|
344 |
-
$page->drawText(
|
|
|
345 |
$this->Ln();
|
|
|
346 |
}
|
347 |
|
|
|
|
|
|
|
|
|
348 |
if ($order->getCustomerId() != '') {
|
349 |
|
350 |
$prefix = Mage::getStoreConfig('sales_pdf/invoice/customeridprefix');
|
351 |
|
352 |
if (!empty($prefix)) {
|
353 |
-
$customerid = $prefix
|
354 |
} else {
|
355 |
$customerid = $order->getCustomerId();
|
356 |
}
|
357 |
|
358 |
-
$page->drawText($customerid, ($this->margin['right'] - $
|
359 |
$this->Ln();
|
360 |
-
|
361 |
-
|
|
|
362 |
$this->Ln();
|
|
|
363 |
}
|
364 |
|
|
|
365 |
if (!Mage::getStoreConfigFlag('sales/general/hide_customer_ip', $order->getStoreId())) {
|
|
|
366 |
$customerIP = $order->getData('remote_ip');
|
367 |
$font = $this->_setFontRegular($page, 10);
|
368 |
-
$page->drawText($customerIP, ($this->margin['right'] - $
|
369 |
$this->Ln();
|
|
|
370 |
}
|
371 |
|
|
|
372 |
$documentDate = Mage::helper('core')->formatDate($document->getCreatedAtDate(), 'medium', false);
|
373 |
-
$page->drawText($documentDate, ($this->margin['right'] - $
|
374 |
$this->Ln();
|
|
|
|
|
375 |
|
|
|
|
|
376 |
if ($putPaymentMethod) {
|
377 |
-
$
|
378 |
-
$
|
|
|
379 |
$this->Ln();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
380 |
}
|
381 |
|
|
|
|
|
382 |
if ($putShippingMethod) {
|
383 |
-
$
|
384 |
-
$
|
|
|
385 |
$this->Ln();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
386 |
}
|
|
|
387 |
}
|
388 |
|
389 |
/**
|
@@ -452,7 +465,7 @@ abstract class FireGento_Pdf_Model_Abstract extends Mage_Sales_Model_Order_Pdf_A
|
|
452 |
*/
|
453 |
protected function insertTotals($page, $source)
|
454 |
{
|
455 |
-
$this->y -=15;
|
456 |
|
457 |
$order = $source->getOrder();
|
458 |
|
@@ -460,8 +473,8 @@ abstract class FireGento_Pdf_Model_Abstract extends Mage_Sales_Model_Order_Pdf_A
|
|
460 |
$shippingTaxRate = 0;
|
461 |
$shippingTaxAmount = $order->getShippingTaxAmount();
|
462 |
|
463 |
-
if($shippingTaxAmount > 0) {
|
464 |
-
$shippingTaxRate = $order->getShippingTaxAmount()*100/($order->getShippingInclTax()
|
465 |
}
|
466 |
|
467 |
$groupedTax = array();
|
@@ -475,10 +488,10 @@ abstract class FireGento_Pdf_Model_Abstract extends Mage_Sales_Model_Order_Pdf_A
|
|
475 |
}
|
476 |
|
477 |
array_push($items['items'], array(
|
478 |
-
'row_invoiced'
|
479 |
'tax_inc_subtotal' => false,
|
480 |
-
'tax_percent'
|
481 |
-
'tax_amount'
|
482 |
));
|
483 |
|
484 |
foreach ($items['items'] as $item) {
|
@@ -487,13 +500,13 @@ abstract class FireGento_Pdf_Model_Abstract extends Mage_Sales_Model_Order_Pdf_A
|
|
487 |
if (!isset($item['row_invoiced'])) $item['row_invoiced'] = 0;
|
488 |
if (!isset($item['price'])) $item['price'] = 0;
|
489 |
if (!isset($item['tax_inc_subtotal'])) $item['tax_inc_subtotal'] = 0;
|
490 |
-
if (((float)$item['tax_amount'] > 0)&&((float)$item['row_invoiced'] > 0)) {
|
491 |
-
$_percent = round($item["tax_percent"],0);
|
492 |
}
|
493 |
if (!array_key_exists('tax_inc_subtotal', $item) || $item['tax_inc_subtotal']) {
|
494 |
$total_tax += $item['tax_amount'];
|
495 |
}
|
496 |
-
if (($item['tax_amount'])
|
497 |
if (!array_key_exists((int)$_percent, $groupedTax)) {
|
498 |
$groupedTax[$_percent] = $item['tax_amount'];
|
499 |
} else {
|
@@ -505,169 +518,31 @@ abstract class FireGento_Pdf_Model_Abstract extends Mage_Sales_Model_Order_Pdf_A
|
|
505 |
$totals = $this->_getTotalsList($source);
|
506 |
|
507 |
$lineBlock = array(
|
508 |
-
'lines'
|
509 |
'height' => 20
|
510 |
);
|
511 |
|
512 |
foreach ($totals as $total) {
|
513 |
-
$
|
514 |
-
|
515 |
-
|
516 |
-
|
517 |
-
|
518 |
-
|
519 |
-
|
520 |
-
|
521 |
-
|
522 |
-
|
523 |
-
|
524 |
-
|
525 |
-
|
526 |
-
|
527 |
-
|
528 |
-
|
529 |
-
|
530 |
-
|
531 |
-
|
532 |
-
|
533 |
-
),
|
534 |
-
array(
|
535 |
-
'text' => $order->formatPriceTxt($taxValue),
|
536 |
-
'feed' => $this->margin['right'] - 10,
|
537 |
-
'align' => 'right',
|
538 |
-
'font_size' => $fontSize,
|
539 |
-
'font' => $fontWeight
|
540 |
-
),
|
541 |
-
);
|
542 |
-
}
|
543 |
-
break;
|
544 |
-
|
545 |
-
case 'subtotal':
|
546 |
-
$amount = $source->getDataUsingMethod($total['source_field']);
|
547 |
-
$displayZero = (isset($total['display_zero']) ? $total['display_zero'] : 0);
|
548 |
-
|
549 |
-
if ($amount != 0 || $displayZero) {
|
550 |
-
$amount = $order->formatPriceTxt($amount);
|
551 |
-
|
552 |
-
if (isset($total['amount_prefix']) && $total['amount_prefix']) {
|
553 |
-
$amount = "{$total['amount_prefix']}{$amount}";
|
554 |
-
}
|
555 |
-
|
556 |
-
$label = Mage::helper('sales')->__($total['title']) . ':';
|
557 |
-
|
558 |
-
$lineBlock['lines'][] = array(
|
559 |
-
array(
|
560 |
-
'text' => $label,
|
561 |
-
'feed' => $this->margin['left'] + 320,
|
562 |
-
'align' => 'left',
|
563 |
-
'font_size' => $fontSize,
|
564 |
-
'font' => $fontWeight
|
565 |
-
),
|
566 |
-
array(
|
567 |
-
'text' => $amount,
|
568 |
-
'feed' => $this->margin['right'] - 10,
|
569 |
-
'align' => 'right',
|
570 |
-
'font_size' => $fontSize,
|
571 |
-
'font' => $fontWeight
|
572 |
-
),
|
573 |
-
);
|
574 |
-
}
|
575 |
-
break;
|
576 |
-
|
577 |
-
case 'shipping_amount':
|
578 |
-
$amount = $source->getDataUsingMethod($total['source_field']);
|
579 |
-
$displayZero = (isset($total['display_zero']) ? $total['display_zero'] : 0);
|
580 |
-
|
581 |
-
if ($amount != 0 || $displayZero) {
|
582 |
-
$amount = $order->formatPriceTxt($amount);
|
583 |
-
|
584 |
-
if (isset($total['amount_prefix']) && $total['amount_prefix']) {
|
585 |
-
$amount = "{$total['amount_prefix']}{$amount}";
|
586 |
-
}
|
587 |
-
|
588 |
-
$label = Mage::helper('sales')->__($total['title']) . ':';
|
589 |
-
|
590 |
-
$lineBlock['lines'][] = array(
|
591 |
-
array(
|
592 |
-
'text' => Mage::helper('firegento_pdf')->__('Shipping:'),
|
593 |
-
'feed' => $this->margin['left'] + 320,
|
594 |
-
'align' => 'left',
|
595 |
-
'font_size' => $fontSize,
|
596 |
-
'font' => $fontWeight
|
597 |
-
),
|
598 |
-
array(
|
599 |
-
'text' => $amount,
|
600 |
-
'feed' => $this->margin['right'] - 10,
|
601 |
-
'align' => 'right',
|
602 |
-
'font_size' => $fontSize,
|
603 |
-
'font' => $fontWeight
|
604 |
-
),
|
605 |
-
);
|
606 |
-
}
|
607 |
-
break;
|
608 |
-
|
609 |
-
case 'grand_total':
|
610 |
-
$amount = $source->getDataUsingMethod($total['source_field']);
|
611 |
-
$displayZero = (isset($total['display_zero']) ? $total['display_zero'] : 0);
|
612 |
-
|
613 |
-
if ($amount != 0 || $displayZero) {
|
614 |
-
$amount = $order->formatPriceTxt($amount);
|
615 |
-
|
616 |
-
if (isset($total['amount_prefix']) && $total['amount_prefix']) {
|
617 |
-
$amount = "{$total['amount_prefix']}{$amount}";
|
618 |
-
}
|
619 |
-
|
620 |
-
$label = Mage::helper('sales')->__($total['title']) . ':';
|
621 |
-
|
622 |
-
$lineBlock['lines'][] = array(
|
623 |
-
array(
|
624 |
-
'text' => $label,
|
625 |
-
'feed' => $this->margin['left'] + 320,
|
626 |
-
'align' => 'left',
|
627 |
-
'font_size' => $fontSize,
|
628 |
-
'font' => $fontWeight
|
629 |
-
),
|
630 |
-
array(
|
631 |
-
'text' => $amount,
|
632 |
-
'feed' => $this->margin['right'] - 10,
|
633 |
-
'align' => 'right',
|
634 |
-
'font_size' => $fontSize,
|
635 |
-
'font' => $fontWeight
|
636 |
-
),
|
637 |
-
);
|
638 |
-
}
|
639 |
-
break;
|
640 |
-
|
641 |
-
default:
|
642 |
-
$amount = $source->getDataUsingMethod($total['source_field']);
|
643 |
-
$displayZero = (isset($total['display_zero']) ? $total['display_zero'] : 0);
|
644 |
-
|
645 |
-
if ($amount != 0 || $displayZero) {
|
646 |
-
$amount = $order->formatPriceTxt($amount);
|
647 |
-
|
648 |
-
if (isset($total['amount_prefix']) && $total['amount_prefix']) {
|
649 |
-
$amount = "{$total['amount_prefix']}{$amount}";
|
650 |
-
}
|
651 |
-
|
652 |
-
$label = Mage::helper('sales')->__($total['title']) . ':';
|
653 |
-
|
654 |
-
$lineBlock['lines'][] = array(
|
655 |
-
array(
|
656 |
-
'text' => $label,
|
657 |
-
'feed' => $this->margin['left'] + 320,
|
658 |
-
'align' => 'left',
|
659 |
-
'font_size' => $fontSize,
|
660 |
-
'font' => $fontWeight
|
661 |
-
),
|
662 |
-
array(
|
663 |
-
'text' => $amount,
|
664 |
-
'feed' => $this->margin['right'] - 10,
|
665 |
-
'align' => 'right',
|
666 |
-
'font_size' => $fontSize,
|
667 |
-
'font' => $fontWeight
|
668 |
-
),
|
669 |
-
);
|
670 |
-
}
|
671 |
}
|
672 |
}
|
673 |
$page = $this->drawLineBlocks($page, array($lineBlock));
|
@@ -709,11 +584,9 @@ abstract class FireGento_Pdf_Model_Abstract extends Mage_Sales_Model_Order_Pdf_A
|
|
709 |
// Draw notes on PDF.
|
710 |
foreach ($notes as $note) {
|
711 |
// prepare the text so that it fits to the paper
|
712 |
-
|
713 |
-
$tmpNotes = explode("\n", $note);
|
714 |
-
foreach ($tmpNotes as $tmpNote) {
|
715 |
// create a new page if necessary
|
716 |
-
if ($this->y < 100) {
|
717 |
$page = $this->newPage(array());
|
718 |
$this->y = $this->y - 60;
|
719 |
$font = $this->_setFontRegular($page, $fontSize);
|
@@ -817,9 +690,7 @@ abstract class FireGento_Pdf_Model_Abstract extends Mage_Sales_Model_Order_Pdf_A
|
|
817 |
// calculate the maximum width for the value
|
818 |
$width = $this->margin['left'] + $colposition + $colwidth - ($this->margin['left'] + $valposition);
|
819 |
}
|
820 |
-
|
821 |
-
$tmpVals = explode("\n", $tmpVal);
|
822 |
-
foreach ($tmpVals as $tmpVal) {
|
823 |
$page->drawText($tmpVal, $this->margin['left'] + $valposition, $y, $this->encoding);
|
824 |
$y -= 12;
|
825 |
}
|
@@ -836,20 +707,20 @@ abstract class FireGento_Pdf_Model_Abstract extends Mage_Sales_Model_Order_Pdf_A
|
|
836 |
*/
|
837 |
protected function _insertFooterAddress(&$page, $store = null)
|
838 |
{
|
839 |
-
$address = $this->imprint['company_first']."\n";
|
840 |
|
841 |
if (array_key_exists('company_second', $this->imprint)) {
|
842 |
$address .= $this->imprint['company_second'] . "\n";
|
843 |
}
|
844 |
|
845 |
-
$address .= $this->imprint['street']."\n";
|
846 |
-
$address .= $this->imprint['zip']." ";
|
847 |
-
$address .= $this->imprint['city']."\n";
|
848 |
|
849 |
$this->_setFontRegular($page, 7);
|
850 |
$y = $this->y;
|
851 |
foreach (explode("\n", $address) as $value) {
|
852 |
-
if ($value!=='') {
|
853 |
$page->drawText(trim(strip_tags($value)), $this->margin['left'] - 20, $y, $this->encoding);
|
854 |
$y -= 12;
|
855 |
}
|
@@ -865,7 +736,7 @@ abstract class FireGento_Pdf_Model_Abstract extends Mage_Sales_Model_Order_Pdf_A
|
|
865 |
protected function _insertPageCounter(&$page)
|
866 |
{
|
867 |
$font = $this->_setFontRegular($page, 9);
|
868 |
-
$page->drawText(Mage::helper('firegento_pdf')->__('Page').' '
|
869 |
}
|
870 |
|
871 |
/**
|
@@ -923,6 +794,9 @@ abstract class FireGento_Pdf_Model_Abstract extends Mage_Sales_Model_Order_Pdf_A
|
|
923 |
*/
|
924 |
protected function _prepareText($text, $page, $font, $fontSize, $width = null)
|
925 |
{
|
|
|
|
|
|
|
926 |
$lines = '';
|
927 |
$currentLine = '';
|
928 |
// calculate the page's width with respect to the margins
|
@@ -945,8 +819,6 @@ abstract class FireGento_Pdf_Model_Abstract extends Mage_Sales_Model_Order_Pdf_A
|
|
945 |
}
|
946 |
// append the last line
|
947 |
$lines .= $currentLine;
|
948 |
-
return $lines;
|
949 |
}
|
950 |
-
|
951 |
-
}
|
952 |
-
|
31 |
* @version $Id:$
|
32 |
* @since 0.1.0
|
33 |
*/
|
34 |
+
abstract class FireGento_Pdf_Model_Engine_Abstract extends Mage_Sales_Model_Order_Pdf_Abstract
|
35 |
{
|
36 |
public $margin = array('left' => 45, 'right' => 540);
|
37 |
public $colors = array();
|
68 |
if (!isset($itemsProp['lines']) || !is_array($itemsProp['lines'])) {
|
69 |
Mage::throwException(Mage::helper('sales')->__('Invalid draw line data. Please define "lines" array'));
|
70 |
}
|
71 |
+
$lines = $itemsProp['lines'];
|
72 |
$height = isset($itemsProp['height']) ? $itemsProp['height'] : 10;
|
73 |
|
74 |
if (empty($itemsProp['shift'])) {
|
92 |
$itemsProp['shift'] = $shift;
|
93 |
}
|
94 |
|
95 |
+
if ($this->y - $itemsProp['shift'] < 50 || (Mage::getStoreConfig('sales_pdf/firegento_pdf/show_footer') == 1 && $this->y - $itemsProp['shift'] < 100)) {
|
96 |
$page = $this->newPage($pageSettings);
|
97 |
}
|
98 |
|
99 |
foreach ($lines as $line) {
|
100 |
$maxHeight = 0;
|
101 |
foreach ($line as $column) {
|
102 |
+
$fontSize = empty($column['font_size']) ? 7 : $column['font_size'];
|
103 |
if (!empty($column['font_file'])) {
|
104 |
$font = Zend_Pdf_Font::fontWithPath($column['font_file']);
|
105 |
$page->setFont($font, $fontSize);
|
106 |
+
} else {
|
|
|
107 |
$fontStyle = empty($column['font']) ? 'regular' : $column['font'];
|
108 |
switch ($fontStyle) {
|
109 |
case 'bold':
|
132 |
case 'right':
|
133 |
if ($width) {
|
134 |
$feed = $this->getAlignRight($part, $feed, $width, $font, $fontSize);
|
135 |
+
} else {
|
|
|
136 |
$feed = $feed - $this->widthForStringUsingFontSize($part, $font, $fontSize);
|
137 |
}
|
138 |
break;
|
142 |
}
|
143 |
break;
|
144 |
}
|
145 |
+
$page->drawText($part, $feed, $this->y - $top, 'UTF-8');
|
146 |
$top += $lineSpacing;
|
147 |
}
|
148 |
|
225 |
|
226 |
$logoPosition = Mage::getStoreConfig('sales_pdf/firegento_pdf/logo_position', $store);
|
227 |
|
228 |
+
switch ($logoPosition) {
|
229 |
case 'center':
|
230 |
+
$startLogoAt = $this->margin['left'] + (($this->margin['right'] - $this->margin['left']) / 2) - $width / 2;
|
231 |
break;
|
232 |
case 'right':
|
233 |
$startLogoAt = $this->margin['right'] - $width;
|
279 |
|
280 |
$this->_setFontBold($page, 15);
|
281 |
|
282 |
+
if ($mode == 'invoice') {
|
283 |
+
$title = 'Invoice';
|
284 |
+
} else if ($mode == 'shipment') {
|
285 |
+
$title = 'Shipment';
|
286 |
+
} else {
|
287 |
+
$title = 'Creditmemo';
|
288 |
+
}
|
289 |
+
$page->drawText(Mage::helper('firegento_pdf')->__($title), $this->margin['left'], $this->y, $this->encoding);
|
290 |
|
291 |
$this->_setFontRegular($page);
|
292 |
|
293 |
$this->y += 80;
|
294 |
+
$labelRightOffset = 180;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
295 |
|
296 |
+
$valueRightOffset = 10;
|
297 |
+
$font = $this->_setFontRegular($page, 10);
|
298 |
+
$width = 80;
|
299 |
+
$numberOfLines = 0;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
300 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
301 |
|
302 |
+
// Invoice/shipment/creditmemo Number
|
303 |
+
if ($mode == 'invoice') {
|
304 |
+
$numberTitle = 'Invoice number:';
|
305 |
+
} else if ($mode == 'shipment') {
|
306 |
+
$numberTitle = 'Shipment number:';
|
307 |
+
} else {
|
308 |
+
$numberTitle = 'Creditmemo number:';
|
309 |
}
|
310 |
+
$page->drawText(Mage::helper('firegento_pdf')->__($numberTitle), ($this->margin['right'] - $labelRightOffset), $this->y, $this->encoding);
|
|
|
|
|
|
|
|
|
311 |
|
312 |
$incrementId = $document->getIncrementId();
|
313 |
+
$page->drawText($incrementId, ($this->margin['right'] - $valueRightOffset - $this->widthForStringUsingFontSize($incrementId, $font, 10)), $this->y, $this->encoding);
|
314 |
$this->Ln();
|
315 |
+
$numberOfLines++;
|
316 |
|
317 |
+
// Order Number
|
318 |
+
$putOrderId = $this->_putOrderId($order);
|
319 |
if ($putOrderId) {
|
320 |
+
$page->drawText(Mage::helper('firegento_pdf')->__('Order number:'), ($this->margin['right'] - $labelRightOffset), $this->y, $this->encoding);
|
321 |
+
$page->drawText($putOrderId, ($this->margin['right'] - $valueRightOffset - $this->widthForStringUsingFontSize($putOrderId, $font, 10)), $this->y, $this->encoding);
|
322 |
$this->Ln();
|
323 |
+
$numberOfLines++;
|
324 |
}
|
325 |
|
326 |
+
// Customer Number
|
327 |
+
$page->drawText(Mage::helper('firegento_pdf')->__('Customer number:'), ($this->margin['right'] - $labelRightOffset), $this->y, $this->encoding);
|
328 |
+
$numberOfLines++;
|
329 |
+
|
330 |
if ($order->getCustomerId() != '') {
|
331 |
|
332 |
$prefix = Mage::getStoreConfig('sales_pdf/invoice/customeridprefix');
|
333 |
|
334 |
if (!empty($prefix)) {
|
335 |
+
$customerid = $prefix . $order->getCustomerId();
|
336 |
} else {
|
337 |
$customerid = $order->getCustomerId();
|
338 |
}
|
339 |
|
340 |
+
$page->drawText($customerid, ($this->margin['right'] - $valueRightOffset - $this->widthForStringUsingFontSize($customerid, $font, 10)), $this->y, $this->encoding);
|
341 |
$this->Ln();
|
342 |
+
$numberOfLines++;
|
343 |
+
} else {
|
344 |
+
$page->drawText('-', ($this->margin['right'] - $valueRightOffset - $this->widthForStringUsingFontSize('-', $font, 10)), $this->y, $this->encoding);
|
345 |
$this->Ln();
|
346 |
+
$numberOfLines++;
|
347 |
}
|
348 |
|
349 |
+
// Customer IP
|
350 |
if (!Mage::getStoreConfigFlag('sales/general/hide_customer_ip', $order->getStoreId())) {
|
351 |
+
$page->drawText(Mage::helper('firegento_pdf')->__('Customer IP:'), ($this->margin['right'] - $labelRightOffset), $this->y, $this->encoding);
|
352 |
$customerIP = $order->getData('remote_ip');
|
353 |
$font = $this->_setFontRegular($page, 10);
|
354 |
+
$page->drawText($customerIP, ($this->margin['right'] - $valueRightOffset - $this->widthForStringUsingFontSize($customerIP, $font, 10)), $this->y, $this->encoding);
|
355 |
$this->Ln();
|
356 |
+
$numberOfLines++;
|
357 |
}
|
358 |
|
359 |
+
$page->drawText(Mage::helper('firegento_pdf')->__(($mode == 'invoice') ? 'Invoice date:' : 'Date:'), ($this->margin['right'] - $labelRightOffset), $this->y, $this->encoding);
|
360 |
$documentDate = Mage::helper('core')->formatDate($document->getCreatedAtDate(), 'medium', false);
|
361 |
+
$page->drawText($documentDate, ($this->margin['right'] - $valueRightOffset - $this->widthForStringUsingFontSize($documentDate, $font, 10)), $this->y, $this->encoding);
|
362 |
$this->Ln();
|
363 |
+
$numberOfLines++;
|
364 |
+
|
365 |
|
366 |
+
// Payment method.
|
367 |
+
$putPaymentMethod = ($mode == 'invoice' && Mage::getStoreConfig('sales_pdf/invoice/payment_method_position') == FireGento_Pdf_Model_System_Config_Source_Payment::POSITION_HEADER);
|
368 |
if ($putPaymentMethod) {
|
369 |
+
$page->drawText(Mage::helper('firegento_pdf')->__('Payment method:'), ($this->margin['right'] - $labelRightOffset), $this->y, $this->encoding);
|
370 |
+
$paymentMethodArray = $this->_prepareText($order->getPayment()->getMethodInstance()->getTitle(), $page, $font, 10, $width);
|
371 |
+
$page->drawText(array_shift($paymentMethodArray), ($this->margin['right'] - $valueRightOffset - $width), $this->y, $this->encoding);
|
372 |
$this->Ln();
|
373 |
+
$numberOfLines++;
|
374 |
+
$paymentMethodArray = $this->_prepareText(implode(" ", $paymentMethodArray), $page, $font, 10, 2 * $width);
|
375 |
+
foreach ($paymentMethodArray as $methodString) {
|
376 |
+
$page->drawText($methodString, $this->margin['right'] - $labelRightOffset, $this->y, $this->encoding);
|
377 |
+
$this->Ln();
|
378 |
+
$numberOfLines++;
|
379 |
+
}
|
380 |
+
|
381 |
}
|
382 |
|
383 |
+
// Shipping method.
|
384 |
+
$putShippingMethod = ($mode == 'invoice' && Mage::getStoreConfig('sales_pdf/invoice/shipping_method_position') == FireGento_Pdf_Model_System_Config_Source_Shipping::POSITION_HEADER);
|
385 |
if ($putShippingMethod) {
|
386 |
+
$page->drawText(Mage::helper('firegento_pdf')->__('Shipping method:'), ($this->margin['right'] - $labelRightOffset), $this->y, $this->encoding);
|
387 |
+
$shippingMethodArray = $this->_prepareText($order->getShippingDescription(), $page, $font, 10, $width);
|
388 |
+
$page->drawText(array_shift($shippingMethodArray), ($this->margin['right'] - $valueRightOffset - $width), $this->y, $this->encoding);
|
389 |
$this->Ln();
|
390 |
+
$numberOfLines++;
|
391 |
+
$shippingMethodArray = $this->_prepareText(implode(" ", $shippingMethodArray), $page, $font, 10, 2 * $width);
|
392 |
+
foreach ($shippingMethodArray as $methodString) {
|
393 |
+
$page->drawText($methodString, $this->margin['right'] - $labelRightOffset, $this->y, $this->encoding);
|
394 |
+
$this->Ln();
|
395 |
+
$numberOfLines++;
|
396 |
+
}
|
397 |
+
|
398 |
}
|
399 |
+
$this->y -= ($numberOfLines*2);
|
400 |
}
|
401 |
|
402 |
/**
|
465 |
*/
|
466 |
protected function insertTotals($page, $source)
|
467 |
{
|
468 |
+
$this->y -= 15;
|
469 |
|
470 |
$order = $source->getOrder();
|
471 |
|
473 |
$shippingTaxRate = 0;
|
474 |
$shippingTaxAmount = $order->getShippingTaxAmount();
|
475 |
|
476 |
+
if ($shippingTaxAmount > 0) {
|
477 |
+
$shippingTaxRate = $order->getShippingTaxAmount() * 100 / ($order->getShippingInclTax() - $order->getShippingTaxAmount());
|
478 |
}
|
479 |
|
480 |
$groupedTax = array();
|
488 |
}
|
489 |
|
490 |
array_push($items['items'], array(
|
491 |
+
'row_invoiced' => $order->getShippingInvoiced(),
|
492 |
'tax_inc_subtotal' => false,
|
493 |
+
'tax_percent' => $shippingTaxRate,
|
494 |
+
'tax_amount' => $shippingTaxAmount
|
495 |
));
|
496 |
|
497 |
foreach ($items['items'] as $item) {
|
500 |
if (!isset($item['row_invoiced'])) $item['row_invoiced'] = 0;
|
501 |
if (!isset($item['price'])) $item['price'] = 0;
|
502 |
if (!isset($item['tax_inc_subtotal'])) $item['tax_inc_subtotal'] = 0;
|
503 |
+
if (((float)$item['tax_amount'] > 0) && ((float)$item['row_invoiced'] > 0)) {
|
504 |
+
$_percent = round($item["tax_percent"], 0);
|
505 |
}
|
506 |
if (!array_key_exists('tax_inc_subtotal', $item) || $item['tax_inc_subtotal']) {
|
507 |
$total_tax += $item['tax_amount'];
|
508 |
}
|
509 |
+
if (($item['tax_amount']) && $_percent) {
|
510 |
if (!array_key_exists((int)$_percent, $groupedTax)) {
|
511 |
$groupedTax[$_percent] = $item['tax_amount'];
|
512 |
} else {
|
518 |
$totals = $this->_getTotalsList($source);
|
519 |
|
520 |
$lineBlock = array(
|
521 |
+
'lines' => array(),
|
522 |
'height' => 20
|
523 |
);
|
524 |
|
525 |
foreach ($totals as $total) {
|
526 |
+
$total->setOrder($order)->setSource($source);
|
527 |
+
|
528 |
+
if ($total->canDisplay()) {
|
529 |
+
$total->setFontSize(10);
|
530 |
+
foreach ($total->getTotalsForDisplay() as $totalData) {
|
531 |
+
$lineBlock['lines'][] = array(
|
532 |
+
array(
|
533 |
+
'text' => $totalData['label'],
|
534 |
+
'feed' => 470,
|
535 |
+
'align' => 'right',
|
536 |
+
'font_size' => $totalData['font_size']
|
537 |
+
),
|
538 |
+
array(
|
539 |
+
'text' => $totalData['amount'],
|
540 |
+
'feed' => 540,
|
541 |
+
'align' => 'right',
|
542 |
+
'font_size' => $totalData['font_size']
|
543 |
+
),
|
544 |
+
);
|
545 |
+
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
546 |
}
|
547 |
}
|
548 |
$page = $this->drawLineBlocks($page, array($lineBlock));
|
584 |
// Draw notes on PDF.
|
585 |
foreach ($notes as $note) {
|
586 |
// prepare the text so that it fits to the paper
|
587 |
+
foreach ($this->_prepareText($note, $page, $font, 10) as $tmpNote) {
|
|
|
|
|
588 |
// create a new page if necessary
|
589 |
+
if ($this->y < 50 || (Mage::getStoreConfig('sales_pdf/firegento_pdf/show_footer') == 1 && $this->y < 100)) {
|
590 |
$page = $this->newPage(array());
|
591 |
$this->y = $this->y - 60;
|
592 |
$font = $this->_setFontRegular($page, $fontSize);
|
690 |
// calculate the maximum width for the value
|
691 |
$width = $this->margin['left'] + $colposition + $colwidth - ($this->margin['left'] + $valposition);
|
692 |
}
|
693 |
+
foreach ($this->_prepareText($val, $page, $font, $fontSize, $width) as $tmpVal) {
|
|
|
|
|
694 |
$page->drawText($tmpVal, $this->margin['left'] + $valposition, $y, $this->encoding);
|
695 |
$y -= 12;
|
696 |
}
|
707 |
*/
|
708 |
protected function _insertFooterAddress(&$page, $store = null)
|
709 |
{
|
710 |
+
$address = $this->imprint['company_first'] . "\n";
|
711 |
|
712 |
if (array_key_exists('company_second', $this->imprint)) {
|
713 |
$address .= $this->imprint['company_second'] . "\n";
|
714 |
}
|
715 |
|
716 |
+
$address .= $this->imprint['street'] . "\n";
|
717 |
+
$address .= $this->imprint['zip'] . " ";
|
718 |
+
$address .= $this->imprint['city'] . "\n";
|
719 |
|
720 |
$this->_setFontRegular($page, 7);
|
721 |
$y = $this->y;
|
722 |
foreach (explode("\n", $address) as $value) {
|
723 |
+
if ($value !== '') {
|
724 |
$page->drawText(trim(strip_tags($value)), $this->margin['left'] - 20, $y, $this->encoding);
|
725 |
$y -= 12;
|
726 |
}
|
736 |
protected function _insertPageCounter(&$page)
|
737 |
{
|
738 |
$font = $this->_setFontRegular($page, 9);
|
739 |
+
$page->drawText(Mage::helper('firegento_pdf')->__('Page') . ' ' . $this->pagecounter, $this->margin['right'] - 23 - $this->widthForStringUsingFontSize($this->pagecounter, $font, 9), $this->y, $this->encoding);
|
740 |
}
|
741 |
|
742 |
/**
|
794 |
*/
|
795 |
protected function _prepareText($text, $page, $font, $fontSize, $width = null)
|
796 |
{
|
797 |
+
if (empty($text)) {
|
798 |
+
return array();
|
799 |
+
}
|
800 |
$lines = '';
|
801 |
$currentLine = '';
|
802 |
// calculate the page's width with respect to the margins
|
819 |
}
|
820 |
// append the last line
|
821 |
$lines .= $currentLine;
|
822 |
+
return explode("\n", $lines);
|
823 |
}
|
824 |
+
}
|
|
|
|
app/code/community/FireGento/Pdf/Model/Engine/Creditmemo/Default.php
ADDED
@@ -0,0 +1,185 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* This file is part of the FIREGENTO project.
|
4 |
+
*
|
5 |
+
* FireGento_GermanSetup is free software; you can redistribute it and/or
|
6 |
+
* modify it under the terms of the GNU General Public License version 3 as
|
7 |
+
* published by the Free Software Foundation.
|
8 |
+
*
|
9 |
+
* This script is distributed in the hope that it will be useful, but WITHOUT
|
10 |
+
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
|
11 |
+
* FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
|
12 |
+
*
|
13 |
+
* PHP version 5
|
14 |
+
*
|
15 |
+
* @category FireGento
|
16 |
+
* @package FireGento_Pdf
|
17 |
+
* @author FireGento Team <team@firegento.com>
|
18 |
+
* @copyright 2013 FireGento Team (http://www.firegento.de). All rights served.
|
19 |
+
* @license http://opensource.org/licenses/gpl-3.0 GNU General Public License, version 3 (GPLv3)
|
20 |
+
* @version $Id:$
|
21 |
+
* @since 0.1.0
|
22 |
+
*/
|
23 |
+
/**
|
24 |
+
* Creditmemo model rewrite.
|
25 |
+
*
|
26 |
+
* @category FireGento
|
27 |
+
* @package FireGento_Pdf
|
28 |
+
* @author FireGento Team <team@firegento.com>
|
29 |
+
* @copyright 2013 FireGento Team (http://www.firegento.de). All rights served.
|
30 |
+
* @license http://opensource.org/licenses/gpl-3.0 GNU General Public License, version 3 (GPLv3)
|
31 |
+
* @version $Id:$
|
32 |
+
* @since 0.1.0
|
33 |
+
*/
|
34 |
+
class FireGento_Pdf_Model_Engine_Creditmemo_Default extends FireGento_Pdf_Model_Engine_Abstract
|
35 |
+
{
|
36 |
+
|
37 |
+
public function __construct()
|
38 |
+
{
|
39 |
+
parent::__construct();
|
40 |
+
$this->setMode('creditmemo');
|
41 |
+
}
|
42 |
+
|
43 |
+
/**
|
44 |
+
* Return PDF document
|
45 |
+
*
|
46 |
+
* @param array $creditmemos
|
47 |
+
* @return Zend_Pdf
|
48 |
+
*/
|
49 |
+
public function getPdf($creditmemos = array())
|
50 |
+
{
|
51 |
+
$this->_beforeGetPdf();
|
52 |
+
$this->_initRenderer('creditmemo');
|
53 |
+
|
54 |
+
$pdf = new Zend_Pdf();
|
55 |
+
$this->_setPdf($pdf);
|
56 |
+
|
57 |
+
$style = new Zend_Pdf_Style();
|
58 |
+
$this->_setFontBold($style, 10);
|
59 |
+
|
60 |
+
// pagecounter is 0 at the beginning, because it is incremented in newPage()
|
61 |
+
$this->pagecounter = 0;
|
62 |
+
|
63 |
+
foreach ($creditmemos as $creditmemo) {
|
64 |
+
if ($creditmemo->getStoreId()) {
|
65 |
+
Mage::app()->getLocale()->emulate($creditmemo->getStoreId());
|
66 |
+
Mage::app()->setCurrentStore($creditmemo->getStoreId());
|
67 |
+
}
|
68 |
+
$page = $this->newPage();
|
69 |
+
|
70 |
+
$order = $creditmemo->getOrder();
|
71 |
+
|
72 |
+
// Add logo
|
73 |
+
$this->insertLogo($page, $creditmemo->getStore());
|
74 |
+
|
75 |
+
// Add billing address
|
76 |
+
$this->y = 692;
|
77 |
+
$this->insertBillingAddress($page, $order);
|
78 |
+
|
79 |
+
// Add sender address
|
80 |
+
$this->y = 705;
|
81 |
+
$this->_insertSenderAddessBar($page);
|
82 |
+
|
83 |
+
// Add head
|
84 |
+
$this->y = 592;
|
85 |
+
$this->insertHeader($page, $order, $creditmemo);
|
86 |
+
|
87 |
+
// Add footer
|
88 |
+
$this->_addFooter($page, $creditmemo->getStore());
|
89 |
+
|
90 |
+
/* Add table head */
|
91 |
+
$this->_setFontRegular($page, 9);
|
92 |
+
$this->y = 562;
|
93 |
+
$this->_drawHeader($page);
|
94 |
+
|
95 |
+
$this->y -=20;
|
96 |
+
|
97 |
+
$position = 0;
|
98 |
+
|
99 |
+
/* Add body */
|
100 |
+
foreach ($creditmemo->getAllItems() as $item){
|
101 |
+
if ($item->getOrderItem()->getParentItem()) {
|
102 |
+
continue;
|
103 |
+
}
|
104 |
+
/* Draw item */
|
105 |
+
$position++;
|
106 |
+
$this->_drawItem($item, $page, $order, $position);
|
107 |
+
$page = end($pdf->pages);
|
108 |
+
}
|
109 |
+
|
110 |
+
/* add line after items */
|
111 |
+
$page->drawLine($this->margin['left'], $this->y + 5, $this->margin['right'], $this->y + 5);
|
112 |
+
|
113 |
+
/* Add totals */
|
114 |
+
$page = $this->insertTotals($page, $creditmemo);
|
115 |
+
|
116 |
+
/* add note */
|
117 |
+
$page = $this->_insertNote($page, $order, $creditmemo);
|
118 |
+
}
|
119 |
+
|
120 |
+
$this->_afterGetPdf();
|
121 |
+
|
122 |
+
if ($creditmemo->getStoreId()) {
|
123 |
+
Mage::app()->getLocale()->revert();
|
124 |
+
}
|
125 |
+
return $pdf;
|
126 |
+
}
|
127 |
+
|
128 |
+
/**
|
129 |
+
* Draw table header for product items
|
130 |
+
*
|
131 |
+
* @param Zend_Pdf_Page $page
|
132 |
+
* @return void
|
133 |
+
*/
|
134 |
+
protected function _drawHeader(Zend_Pdf_Page $page)
|
135 |
+
{
|
136 |
+
$page->setFillColor($this->colors['grey1']);
|
137 |
+
$page->setLineColor($this->colors['grey1']);
|
138 |
+
$page->setLineWidth(1);
|
139 |
+
$page->drawRectangle($this->margin['left'], $this->y, $this->margin['right'], $this->y - 15);
|
140 |
+
|
141 |
+
$page->setFillColor($this->colors['black']);
|
142 |
+
$font = $this->_setFontRegular($page, 9);
|
143 |
+
|
144 |
+
$this->y -= 11;
|
145 |
+
$page->drawText(Mage::helper('firegento_pdf')->__('Pos'), $this->margin['left'] + 3, $this->y, $this->encoding);
|
146 |
+
$page->drawText(Mage::helper('firegento_pdf')->__('No.'), $this->margin['left'] + 25, $this->y, $this->encoding);
|
147 |
+
$page->drawText(Mage::helper('firegento_pdf')->__('Description'), $this->margin['left'] + 120, $this->y, $this->encoding);
|
148 |
+
|
149 |
+
$singlePrice = Mage::helper('firegento_pdf')->__('Price (excl. tax)');
|
150 |
+
$page->drawText($singlePrice, $this->margin['right'] - 153 - $this->widthForStringUsingFontSize($singlePrice, $font, 9), $this->y, $this->encoding);
|
151 |
+
|
152 |
+
$page->drawText(Mage::helper('firegento_pdf')->__('Qty'), $this->margin['left'] + 360, $this->y, $this->encoding);
|
153 |
+
|
154 |
+
$taxLabel = Mage::helper('firegento_pdf')->__('Tax');
|
155 |
+
$page->drawText($taxLabel, $this->margin['right'] - 65 - $this->widthForStringUsingFontSize($taxLabel, $font, 9), $this->y, $this->encoding);
|
156 |
+
|
157 |
+
$totalLabel = Mage::helper('firegento_pdf')->__('Total');
|
158 |
+
$page->drawText($totalLabel, $this->margin['right'] - 10 - $this->widthForStringUsingFontSize($totalLabel, $font, 10), $this->y, $this->encoding);
|
159 |
+
}
|
160 |
+
|
161 |
+
/**
|
162 |
+
* Initialize renderer process.
|
163 |
+
*
|
164 |
+
* @param string $type
|
165 |
+
* @return void
|
166 |
+
*/
|
167 |
+
protected function _initRenderer($type)
|
168 |
+
{
|
169 |
+
parent::_initRenderer($type);
|
170 |
+
|
171 |
+
$this->_renderers['default'] = array(
|
172 |
+
'model' => 'firegento_pdf/items_default',
|
173 |
+
'renderer' => null
|
174 |
+
);
|
175 |
+
$this->_renderers['grouped'] = array(
|
176 |
+
'model' => 'firegento_pdf/items_grouped',
|
177 |
+
'renderer' => null
|
178 |
+
);
|
179 |
+
$this->_renderers['bundle'] = array(
|
180 |
+
'model' => 'firegento_pdf/items_bundle',
|
181 |
+
'renderer' => null
|
182 |
+
);
|
183 |
+
}
|
184 |
+
|
185 |
+
}
|
app/code/community/FireGento/Pdf/Model/Engine/Invoice/Default.php
CHANGED
@@ -31,7 +31,7 @@
|
|
31 |
* @version $Id:$
|
32 |
* @since 0.1.0
|
33 |
*/
|
34 |
-
class FireGento_Pdf_Model_Engine_Invoice_Default extends
|
35 |
{
|
36 |
|
37 |
public function __construct()
|
@@ -84,15 +84,12 @@ class FireGento_Pdf_Model_Engine_Invoice_Default extends FireGento_Pdf_Model_Abs
|
|
84 |
$this->y = 592;
|
85 |
$this->insertHeader($page, $order, $invoice);
|
86 |
|
87 |
-
// Add footer
|
88 |
-
$this->_addFooter($page, $invoice->getStore());
|
89 |
|
90 |
/* add table header */
|
91 |
$this->_setFontRegular($page, 9);
|
92 |
-
$this->y = 562;
|
93 |
$this->insertTableHeader($page);
|
94 |
|
95 |
-
$this->y -=20;
|
96 |
|
97 |
$position = 0;
|
98 |
|
@@ -100,8 +97,7 @@ class FireGento_Pdf_Model_Engine_Invoice_Default extends FireGento_Pdf_Model_Abs
|
|
100 |
if ($item->getOrderItem()->getParentItem()) {
|
101 |
continue;
|
102 |
}
|
103 |
-
|
104 |
-
if ($this->y < 100) {
|
105 |
$page = $this->newPage(array());
|
106 |
}
|
107 |
|
@@ -116,7 +112,11 @@ class FireGento_Pdf_Model_Engine_Invoice_Default extends FireGento_Pdf_Model_Abs
|
|
116 |
$page = $this->insertTotals($page, $invoice);
|
117 |
|
118 |
/* add note */
|
119 |
-
$this->_insertNote($page, $order, $invoice);
|
|
|
|
|
|
|
|
|
120 |
}
|
121 |
|
122 |
$this->_afterGetPdf();
|
@@ -142,20 +142,58 @@ class FireGento_Pdf_Model_Engine_Invoice_Default extends FireGento_Pdf_Model_Abs
|
|
142 |
$font = $this->_setFontRegular($page, 9);
|
143 |
|
144 |
$this->y -= 11;
|
145 |
-
$page->drawText(Mage::helper('firegento_pdf')->__('Pos'),
|
146 |
-
$page->drawText(Mage::helper('firegento_pdf')->__('No.'),
|
147 |
-
$page->drawText(Mage::helper('firegento_pdf')->__('Description'),
|
148 |
-
|
149 |
-
$
|
150 |
-
$
|
151 |
-
|
152 |
-
|
153 |
-
|
154 |
-
$
|
155 |
-
|
156 |
-
|
157 |
-
|
158 |
-
$
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
159 |
}
|
160 |
|
161 |
/**
|
31 |
* @version $Id:$
|
32 |
* @since 0.1.0
|
33 |
*/
|
34 |
+
class FireGento_Pdf_Model_Engine_Invoice_Default extends FireGento_Pdf_Model_Engine_Abstract
|
35 |
{
|
36 |
|
37 |
public function __construct()
|
84 |
$this->y = 592;
|
85 |
$this->insertHeader($page, $order, $invoice);
|
86 |
|
|
|
|
|
87 |
|
88 |
/* add table header */
|
89 |
$this->_setFontRegular($page, 9);
|
|
|
90 |
$this->insertTableHeader($page);
|
91 |
|
92 |
+
$this->y -= 20;
|
93 |
|
94 |
$position = 0;
|
95 |
|
97 |
if ($item->getOrderItem()->getParentItem()) {
|
98 |
continue;
|
99 |
}
|
100 |
+
if ($this->y < 50 || (Mage::getStoreConfig('sales_pdf/firegento_pdf/show_footer') == 1 && $this->y < 100)) {
|
|
|
101 |
$page = $this->newPage(array());
|
102 |
}
|
103 |
|
112 |
$page = $this->insertTotals($page, $invoice);
|
113 |
|
114 |
/* add note */
|
115 |
+
$page = $this->_insertNote($page, $order, $invoice);
|
116 |
+
|
117 |
+
// Add footer
|
118 |
+
$this->_addFooter($page, $invoice->getStore());
|
119 |
+
|
120 |
}
|
121 |
|
122 |
$this->_afterGetPdf();
|
142 |
$font = $this->_setFontRegular($page, 9);
|
143 |
|
144 |
$this->y -= 11;
|
145 |
+
$page->drawText(Mage::helper('firegento_pdf')->__('Pos'), $this->margin['left'] + 3, $this->y, $this->encoding);
|
146 |
+
$page->drawText(Mage::helper('firegento_pdf')->__('No.'), $this->margin['left'] + 25, $this->y, $this->encoding);
|
147 |
+
$page->drawText(Mage::helper('firegento_pdf')->__('Description'), $this->margin['left'] + 120, $this->y, $this->encoding);
|
148 |
+
|
149 |
+
$columns = array();
|
150 |
+
$columns['price'] = array(
|
151 |
+
'label' => Mage::helper('firegento_pdf')->__('Price'),
|
152 |
+
'_width' => 60
|
153 |
+
);
|
154 |
+
$columns['price_incl_tax'] = array(
|
155 |
+
'label' => Mage::helper('firegento_pdf')->__('Price (incl. tax)'),
|
156 |
+
'_width' => 60
|
157 |
+
);
|
158 |
+
$columns['qty'] = array(
|
159 |
+
'label' => Mage::helper('firegento_pdf')->__('Qty'),
|
160 |
+
'_width' => 40
|
161 |
+
);
|
162 |
+
$columns['tax'] = array(
|
163 |
+
'label' => Mage::helper('firegento_pdf')->__('Tax'),
|
164 |
+
'_width' => 50
|
165 |
+
);
|
166 |
+
$columns['tax_rate'] = array(
|
167 |
+
'label' => Mage::helper('firegento_pdf')->__('Tax rate'),
|
168 |
+
'_width' => 50
|
169 |
+
);
|
170 |
+
$columns['subtotal'] = array(
|
171 |
+
'label' => Mage::helper('firegento_pdf')->__('Total'),
|
172 |
+
'_width' => 50
|
173 |
+
);
|
174 |
+
$columns['subtotal_incl_tax'] = array(
|
175 |
+
'label' => Mage::helper('firegento_pdf')->__('Total (incl. tax)'),
|
176 |
+
'_width' => 70
|
177 |
+
);
|
178 |
+
// draw price, tax, and subtotal in specified order
|
179 |
+
$columnsOrder = explode(',', Mage::getStoreConfig('sales_pdf/invoice/item_price_column_order'));
|
180 |
+
// draw starting from right
|
181 |
+
$columnsOrder = array_reverse($columnsOrder);
|
182 |
+
$columnOffset = 0;
|
183 |
+
foreach ($columnsOrder as $columnName) {
|
184 |
+
$columnName = trim($columnName);
|
185 |
+
if (array_key_exists($columnName, $columns)) {
|
186 |
+
$column = $columns[$columnName];
|
187 |
+
$labelWidth = $this->widthForStringUsingFontSize($column['label'], $font, 9);
|
188 |
+
$page->drawText(
|
189 |
+
$column['label'],
|
190 |
+
$this->margin['right'] - $columnOffset - $labelWidth,
|
191 |
+
$this->y,
|
192 |
+
$this->encoding
|
193 |
+
);
|
194 |
+
$columnOffset += $column['_width'];
|
195 |
+
}
|
196 |
+
}
|
197 |
}
|
198 |
|
199 |
/**
|
app/code/community/FireGento/Pdf/Model/Engine/Shipment/Default.php
ADDED
@@ -0,0 +1,170 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* This file is part of the FIREGENTO project.
|
4 |
+
*
|
5 |
+
* FireGento_GermanSetup is free software; you can redistribute it and/or
|
6 |
+
* modify it under the terms of the GNU General Public License version 3 as
|
7 |
+
* published by the Free Software Foundation.
|
8 |
+
*
|
9 |
+
* This script is distributed in the hope that it will be useful, but WITHOUT
|
10 |
+
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
|
11 |
+
* FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
|
12 |
+
*
|
13 |
+
* PHP version 5
|
14 |
+
*
|
15 |
+
* @category FireGento
|
16 |
+
* @package FireGento_Pdf
|
17 |
+
* @author FireGento Team <team@firegento.com>
|
18 |
+
* @copyright 2013 FireGento Team (http://www.firegento.de). All rights served.
|
19 |
+
* @license http://opensource.org/licenses/gpl-3.0 GNU General Public License, version 3 (GPLv3)
|
20 |
+
* @version $Id:$
|
21 |
+
* @since 0.1.0
|
22 |
+
*/
|
23 |
+
/**
|
24 |
+
* Shipment model rewrite.
|
25 |
+
*
|
26 |
+
* @category FireGento
|
27 |
+
* @package FireGento_Pdf
|
28 |
+
* @author FireGento Team <team@firegento.com>
|
29 |
+
* @copyright 2013 FireGento Team (http://www.firegento.de). All rights served.
|
30 |
+
* @license http://opensource.org/licenses/gpl-3.0 GNU General Public License, version 3 (GPLv3)
|
31 |
+
* @version $Id:$
|
32 |
+
* @since 0.1.0
|
33 |
+
*/
|
34 |
+
class FireGento_Pdf_Model_Engine_Shipment_Default extends FireGento_Pdf_Model_Engine_Abstract
|
35 |
+
{
|
36 |
+
|
37 |
+
public function __construct()
|
38 |
+
{
|
39 |
+
parent::__construct();
|
40 |
+
$this->setMode('shipment');
|
41 |
+
}
|
42 |
+
|
43 |
+
/**
|
44 |
+
* Return PDF document
|
45 |
+
*
|
46 |
+
* @param array $shipments
|
47 |
+
* @return Zend_Pdf
|
48 |
+
*/
|
49 |
+
public function getPdf($shipments = array())
|
50 |
+
{
|
51 |
+
$this->_beforeGetPdf();
|
52 |
+
$this->_initRenderer('shipment');
|
53 |
+
|
54 |
+
$pdf = new Zend_Pdf();
|
55 |
+
$this->_setPdf($pdf);
|
56 |
+
|
57 |
+
$style = new Zend_Pdf_Style();
|
58 |
+
$this->_setFontBold($style, 10);
|
59 |
+
|
60 |
+
// pagecounter is 0 at the beginning, because it is incremented in newPage()
|
61 |
+
$this->pagecounter = 0;
|
62 |
+
|
63 |
+
foreach ($shipments as $shipment) {
|
64 |
+
if ($shipment->getStoreId()) {
|
65 |
+
Mage::app()->getLocale()->emulate($shipment->getStoreId());
|
66 |
+
Mage::app()->setCurrentStore($shipment->getStoreId());
|
67 |
+
}
|
68 |
+
$page = $this->newPage();
|
69 |
+
|
70 |
+
$order = $shipment->getOrder();
|
71 |
+
|
72 |
+
/* add logo */
|
73 |
+
$this->insertLogo($page, $shipment->getStore());
|
74 |
+
|
75 |
+
// Add shipping address
|
76 |
+
$this->y = 692;
|
77 |
+
$this->insertShippingAddress($page, $order);
|
78 |
+
|
79 |
+
/* add sender address */
|
80 |
+
$this->y = 705;
|
81 |
+
$this->_insertSenderAddessBar($page);
|
82 |
+
|
83 |
+
/* add header */
|
84 |
+
$this->y = 592;
|
85 |
+
$this->insertHeader($page, $order, $shipment);
|
86 |
+
|
87 |
+
// Add footer
|
88 |
+
$this->_addFooter($page, $shipment->getStore());
|
89 |
+
|
90 |
+
/* add table header */
|
91 |
+
$this->_setFontRegular($page, 9);
|
92 |
+
$this->y = 562;
|
93 |
+
$this->insertTableHeader($page);
|
94 |
+
|
95 |
+
$this->y -=20;
|
96 |
+
|
97 |
+
$position = 0;
|
98 |
+
|
99 |
+
foreach ($shipment->getAllItems() as $item) {
|
100 |
+
if ($item->getOrderItem()->getParentItem()) {
|
101 |
+
continue;
|
102 |
+
}
|
103 |
+
|
104 |
+
if ($this->y < 50 || (Mage::getStoreConfig('sales_pdf/firegento_pdf/show_footer') == 1 && $this->y < 100)) {
|
105 |
+
$page = $this->newPage(array());
|
106 |
+
}
|
107 |
+
|
108 |
+
$position++;
|
109 |
+
$page = $this->_drawItem($item, $page, $order, $position);
|
110 |
+
}
|
111 |
+
|
112 |
+
/* add note */
|
113 |
+
$page = $this->_insertNote($page, $order, $shipment);
|
114 |
+
}
|
115 |
+
|
116 |
+
$this->_afterGetPdf();
|
117 |
+
|
118 |
+
return $pdf;
|
119 |
+
}
|
120 |
+
|
121 |
+
protected function insertTableHeader(&$page)
|
122 |
+
{
|
123 |
+
$page->setFillColor($this->colors['grey1']);
|
124 |
+
$page->setLineColor($this->colors['grey1']);
|
125 |
+
$page->setLineWidth(1);
|
126 |
+
$page->drawRectangle($this->margin['left'], $this->y, $this->margin['right'] - 10, $this->y - 15);
|
127 |
+
|
128 |
+
$page->setFillColor($this->colors['black']);
|
129 |
+
$font = $this->_setFontRegular($page, 9);
|
130 |
+
|
131 |
+
$this->y -= 11;
|
132 |
+
$page->drawText(Mage::helper('firegento_pdf')->__('No.'), $this->margin['left'], $this->y, $this->encoding);
|
133 |
+
$page->drawText(Mage::helper('firegento_pdf')->__('Description'), $this->margin['left'] + 105, $this->y, $this->encoding);
|
134 |
+
|
135 |
+
$page->drawText(Mage::helper('firegento_pdf')->__('Qty'), $this->margin['left'] + 450, $this->y, $this->encoding);
|
136 |
+
}
|
137 |
+
|
138 |
+
protected function insertShippingAddress(&$page, $order)
|
139 |
+
{
|
140 |
+
$this->_setFontRegular($page, 9);
|
141 |
+
|
142 |
+
$billing = $this->_formatAddress($order->getShippingAddress()->format('pdf'));
|
143 |
+
|
144 |
+
foreach ($billing as $line) {
|
145 |
+
$page->drawText(trim(strip_tags($line)), $this->margin['left'], $this->y, $this->encoding);
|
146 |
+
$this->Ln(12);
|
147 |
+
}
|
148 |
+
}
|
149 |
+
|
150 |
+
/**
|
151 |
+
* Initialize renderer process.
|
152 |
+
*
|
153 |
+
* @param string $type
|
154 |
+
* @return void
|
155 |
+
*/
|
156 |
+
protected function _initRenderer($type)
|
157 |
+
{
|
158 |
+
parent::_initRenderer($type);
|
159 |
+
|
160 |
+
$this->_renderers['default'] = array(
|
161 |
+
'model' => 'firegento_pdf/items_shipment_default',
|
162 |
+
'renderer' => null
|
163 |
+
);
|
164 |
+
$this->_renderers['bundle'] = array(
|
165 |
+
'model' => 'firegento_pdf/items_shipment_bundle',
|
166 |
+
'renderer' => null
|
167 |
+
);
|
168 |
+
}
|
169 |
+
|
170 |
+
}
|
app/code/community/FireGento/Pdf/Model/Invoice.php
CHANGED
@@ -46,7 +46,7 @@ class FireGento_Pdf_Model_Invoice
|
|
46 |
protected function getEngine()
|
47 |
{
|
48 |
if (!$this->_engine) {
|
49 |
-
$modelClass = Mage::getStoreConfig('sales_pdf/
|
50 |
$engine = Mage::getModel($modelClass);
|
51 |
|
52 |
if (!$engine) {
|
@@ -65,39 +65,4 @@ class FireGento_Pdf_Model_Invoice
|
|
65 |
return $this->getEngine()->getPdf($invoices);
|
66 |
}
|
67 |
|
68 |
-
public function widthForStringUsingFontSize($string, $font, $fontSize)
|
69 |
-
{
|
70 |
-
return $this->getEngine()->widthForStringUsingFontSize($string, $font, $fontSize);
|
71 |
-
}
|
72 |
-
|
73 |
-
public function getAlignRight($string, $x, $columnWidth, Zend_Pdf_Resource_Font $font, $fontSize, $padding = 5)
|
74 |
-
{
|
75 |
-
return $this->getEngine()->getAlignRight($string, $x, $columnWidth, $font, $fontSize);
|
76 |
-
}
|
77 |
-
|
78 |
-
public function getAlignCenter($string, $x, $columnWidth, Zend_Pdf_Resource_Font $font, $fontSize)
|
79 |
-
{
|
80 |
-
return $this->getEngine()->getAlignCenter($string, $x, $columnWidth, $font, $fontSize);
|
81 |
-
}
|
82 |
-
|
83 |
-
public function insertDocumentNumber(Zend_Pdf_Page $page, $text)
|
84 |
-
{
|
85 |
-
return $this->getEngine()->insertDocumentNumber($page, $text);
|
86 |
-
}
|
87 |
-
|
88 |
-
public function getRenderer($type)
|
89 |
-
{
|
90 |
-
return $this->getEngine()->getRenderer($type);
|
91 |
-
}
|
92 |
-
|
93 |
-
public function newPage(array $settings = array())
|
94 |
-
{
|
95 |
-
return $this->getEngine()->newPage($settings);
|
96 |
-
}
|
97 |
-
|
98 |
-
public function drawLineBlocks(Zend_Pdf_Page $page, array $draw, array $pageSettings = array())
|
99 |
-
{
|
100 |
-
return $this->getEngine()->drawLineBlocks($page, $draw, $pageSettings);
|
101 |
-
}
|
102 |
-
|
103 |
}
|
46 |
protected function getEngine()
|
47 |
{
|
48 |
if (!$this->_engine) {
|
49 |
+
$modelClass = Mage::getStoreConfig('sales_pdf/invoice/engine');
|
50 |
$engine = Mage::getModel($modelClass);
|
51 |
|
52 |
if (!$engine) {
|
65 |
return $this->getEngine()->getPdf($invoices);
|
66 |
}
|
67 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
68 |
}
|
app/code/community/FireGento/Pdf/Model/Items/Default.php
CHANGED
@@ -41,44 +41,36 @@ class FireGento_Pdf_Model_Items_Default extends Mage_Sales_Model_Order_Pdf_Items
|
|
41 |
*/
|
42 |
public function draw($position = 1)
|
43 |
{
|
44 |
-
$order
|
45 |
-
$item
|
46 |
-
$pdf
|
47 |
-
$page
|
48 |
-
$lines
|
49 |
|
50 |
$fontSize = 9;
|
51 |
|
52 |
// draw Position Number
|
53 |
-
$lines[0]= array(array(
|
54 |
-
'text'
|
55 |
-
'feed'
|
56 |
'align' => 'right',
|
57 |
'font_size' => $fontSize
|
58 |
));
|
59 |
|
60 |
// draw SKU
|
61 |
$lines[0][] = array(
|
62 |
-
'text'
|
63 |
-
'feed'
|
64 |
'font_size' => $fontSize
|
65 |
);
|
66 |
|
67 |
// draw Product name
|
68 |
-
$lines[0][]= array(
|
69 |
'text' => Mage::helper('core/string')->str_split($item->getName(), 40, true, true),
|
70 |
'feed' => $pdf->margin['left'] + 120,
|
71 |
'font_size' => $fontSize
|
72 |
);
|
73 |
|
74 |
-
// draw QTY
|
75 |
-
$lines[0][] = array(
|
76 |
-
'text' => $item->getQty() * 1,
|
77 |
-
'feed' => $pdf->margin['right'] - 120,
|
78 |
-
'align' => 'right',
|
79 |
-
'font_size' => $fontSize
|
80 |
-
);
|
81 |
-
|
82 |
$options = $this->getItemOptions();
|
83 |
if ($options) {
|
84 |
foreach ($options as $option) {
|
@@ -103,36 +95,98 @@ class FireGento_Pdf_Model_Items_Default extends Mage_Sales_Model_Order_Pdf_Items
|
|
103 |
}
|
104 |
}
|
105 |
|
106 |
-
|
107 |
-
|
108 |
-
|
109 |
-
'
|
110 |
'align' => 'right',
|
111 |
-
'font_size' => $fontSize
|
|
|
112 |
);
|
113 |
|
114 |
-
//
|
115 |
-
$
|
116 |
-
'text'
|
117 |
-
'feed' => $pdf->margin['right'] - 60,
|
118 |
'align' => 'right',
|
119 |
-
'font_size' => $fontSize
|
|
|
120 |
);
|
121 |
|
122 |
-
//
|
123 |
-
$
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
124 |
'text' => $order->formatPriceTxt(($item->getPrice() * $item->getQty() * 1) + $item->getTaxAmount()),
|
125 |
-
'feed' => $pdf->margin['right'] - 10,
|
126 |
'align' => 'right',
|
127 |
-
'font_size' => $fontSize
|
|
|
128 |
);
|
129 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
130 |
$lineBlock = array(
|
131 |
-
'lines'
|
132 |
'height' => 15
|
133 |
);
|
134 |
|
135 |
$page = $pdf->drawLineBlocks($page, array($lineBlock), array('table_header' => true));
|
136 |
$this->setPage($page);
|
137 |
}
|
138 |
-
}
|
41 |
*/
|
42 |
public function draw($position = 1)
|
43 |
{
|
44 |
+
$order = $this->getOrder();
|
45 |
+
$item = $this->getItem();
|
46 |
+
$pdf = $this->getPdf();
|
47 |
+
$page = $this->getPage();
|
48 |
+
$lines = array();
|
49 |
|
50 |
$fontSize = 9;
|
51 |
|
52 |
// draw Position Number
|
53 |
+
$lines[0] = array(array(
|
54 |
+
'text' => $position,
|
55 |
+
'feed' => $pdf->margin['left'] + 10,
|
56 |
'align' => 'right',
|
57 |
'font_size' => $fontSize
|
58 |
));
|
59 |
|
60 |
// draw SKU
|
61 |
$lines[0][] = array(
|
62 |
+
'text' => Mage::helper('core/string')->str_split($this->getSku($item), 17),
|
63 |
+
'feed' => $pdf->margin['left'] + 25,
|
64 |
'font_size' => $fontSize
|
65 |
);
|
66 |
|
67 |
// draw Product name
|
68 |
+
$lines[0][] = array(
|
69 |
'text' => Mage::helper('core/string')->str_split($item->getName(), 40, true, true),
|
70 |
'feed' => $pdf->margin['left'] + 120,
|
71 |
'font_size' => $fontSize
|
72 |
);
|
73 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
74 |
$options = $this->getItemOptions();
|
75 |
if ($options) {
|
76 |
foreach ($options as $option) {
|
95 |
}
|
96 |
}
|
97 |
|
98 |
+
$columns = array();
|
99 |
+
// prepare qty
|
100 |
+
$columns['qty'] = array(
|
101 |
+
'text' => $item->getQty() * 1,
|
102 |
'align' => 'right',
|
103 |
+
'font_size' => $fontSize,
|
104 |
+
'_width' => 40
|
105 |
);
|
106 |
|
107 |
+
// prepare price
|
108 |
+
$columns['price'] = array(
|
109 |
+
'text' => $order->formatPriceTxt($item->getPrice()),
|
|
|
110 |
'align' => 'right',
|
111 |
+
'font_size' => $fontSize,
|
112 |
+
'_width' => 60
|
113 |
);
|
114 |
|
115 |
+
// prepare price_incl_tax
|
116 |
+
$columns['price_incl_tax'] = array(
|
117 |
+
'text' => $order->formatPriceTxt($item->getPriceInclTax()),
|
118 |
+
'align' => 'right',
|
119 |
+
'font_size' => $fontSize,
|
120 |
+
'_width' => 60
|
121 |
+
);
|
122 |
+
|
123 |
+
// prepare tax
|
124 |
+
$columns['tax'] = array(
|
125 |
+
'text' => $order->formatPriceTxt($item->getTaxAmount()),
|
126 |
+
'align' => 'right',
|
127 |
+
'font_size' => $fontSize,
|
128 |
+
'_width' => 50
|
129 |
+
);
|
130 |
+
|
131 |
+
// prepare tax_rate
|
132 |
+
$columns['tax_rate'] = array(
|
133 |
+
'text' => round($item->getOrderItem()->getTaxPercent(), 2) . '%',
|
134 |
+
'align' => 'right',
|
135 |
+
'font_size' => $fontSize,
|
136 |
+
'_width' => 50
|
137 |
+
);
|
138 |
+
|
139 |
+
// prepare subtotal
|
140 |
+
$columns['subtotal'] = array(
|
141 |
+
'text' => $order->formatPriceTxt($item->getPrice() * $item->getQty() * 1),
|
142 |
+
'align' => 'right',
|
143 |
+
'font_size' => $fontSize,
|
144 |
+
'_width' => 50
|
145 |
+
);
|
146 |
+
|
147 |
+
// prepare subtotal_incl_tax
|
148 |
+
$columns['subtotal_incl_tax'] = array(
|
149 |
'text' => $order->formatPriceTxt(($item->getPrice() * $item->getQty() * 1) + $item->getTaxAmount()),
|
|
|
150 |
'align' => 'right',
|
151 |
+
'font_size' => $fontSize,
|
152 |
+
'_width' => 70
|
153 |
);
|
154 |
|
155 |
+
// draw columns in specified order
|
156 |
+
$columnsOrder = explode(',', Mage::getStoreConfig('sales_pdf/invoice/item_price_column_order'));
|
157 |
+
// draw starting from right
|
158 |
+
$columnsOrder = array_reverse($columnsOrder);
|
159 |
+
$columnOffset = 0;
|
160 |
+
foreach ($columnsOrder as $columnName) {
|
161 |
+
$columnName = trim($columnName);
|
162 |
+
if (array_key_exists($columnName, $columns)) {
|
163 |
+
$column = $columns[$columnName];
|
164 |
+
$column['feed'] = $pdf->margin['right'] - $columnOffset;
|
165 |
+
$columnOffset += $column['_width'];
|
166 |
+
unset($column['_width']);
|
167 |
+
$lines[0][] = $column;
|
168 |
+
}
|
169 |
+
}
|
170 |
+
|
171 |
+
if (Mage::getStoreConfig('sales_pdf/invoice/show_item_discount') && 0 < $item->getDiscountAmount()) {
|
172 |
+
// print discount
|
173 |
+
$text = Mage::helper('firegento_pdf')->__(
|
174 |
+
'You get a discount of %s.',
|
175 |
+
$order->formatPriceTxt($item->getDiscountAmount())
|
176 |
+
);
|
177 |
+
$lines[][] = array(
|
178 |
+
'text' => $text,
|
179 |
+
'align' => 'right',
|
180 |
+
'feed' => $pdf->margin['right'] - $columnOffset
|
181 |
+
);
|
182 |
+
}
|
183 |
+
|
184 |
$lineBlock = array(
|
185 |
+
'lines' => $lines,
|
186 |
'height' => 15
|
187 |
);
|
188 |
|
189 |
$page = $pdf->drawLineBlocks($page, array($lineBlock), array('table_header' => true));
|
190 |
$this->setPage($page);
|
191 |
}
|
192 |
+
}
|
app/code/community/FireGento/Pdf/Model/Shipment.php
CHANGED
@@ -31,141 +31,35 @@
|
|
31 |
* @version $Id:$
|
32 |
* @since 0.1.0
|
33 |
*/
|
34 |
-
class FireGento_Pdf_Model_Shipment
|
35 |
{
|
36 |
|
37 |
-
public function __construct()
|
38 |
-
{
|
39 |
-
parent::__construct();
|
40 |
-
$this->setMode('shipment');
|
41 |
-
}
|
42 |
-
|
43 |
/**
|
44 |
-
*
|
45 |
-
*
|
46 |
-
* @param array $shipments
|
47 |
-
* @return Zend_Pdf
|
48 |
*/
|
49 |
-
|
50 |
-
{
|
51 |
-
$this->_beforeGetPdf();
|
52 |
-
$this->_initRenderer('shipment');
|
53 |
-
|
54 |
-
$pdf = new Zend_Pdf();
|
55 |
-
$this->_setPdf($pdf);
|
56 |
-
|
57 |
-
$style = new Zend_Pdf_Style();
|
58 |
-
$this->_setFontBold($style, 10);
|
59 |
-
|
60 |
-
// pagecounter is 0 at the beginning, because it is incremented in newPage()
|
61 |
-
$this->pagecounter = 0;
|
62 |
-
|
63 |
-
foreach ($shipments as $shipment) {
|
64 |
-
if ($shipment->getStoreId()) {
|
65 |
-
Mage::app()->getLocale()->emulate($shipment->getStoreId());
|
66 |
-
Mage::app()->setCurrentStore($shipment->getStoreId());
|
67 |
-
}
|
68 |
-
$page = $this->newPage();
|
69 |
-
|
70 |
-
$order = $shipment->getOrder();
|
71 |
-
|
72 |
-
/* add logo */
|
73 |
-
$this->insertLogo($page, $shipment->getStore());
|
74 |
-
|
75 |
-
// Add shipping address
|
76 |
-
$this->y = 692;
|
77 |
-
$this->insertShippingAddress($page, $order);
|
78 |
-
|
79 |
-
/* add sender address */
|
80 |
-
$this->y = 705;
|
81 |
-
$this->_insertSenderAddessBar($page);
|
82 |
-
|
83 |
-
/* add header */
|
84 |
-
$this->y = 592;
|
85 |
-
$this->insertHeader($page, $order, $shipment);
|
86 |
-
|
87 |
-
// Add footer
|
88 |
-
$this->_addFooter($page, $shipment->getStore());
|
89 |
-
|
90 |
-
/* add table header */
|
91 |
-
$this->_setFontRegular($page, 9);
|
92 |
-
$this->y = 562;
|
93 |
-
$this->insertTableHeader($page);
|
94 |
-
|
95 |
-
$this->y -=20;
|
96 |
-
|
97 |
-
$position = 0;
|
98 |
-
|
99 |
-
foreach ($shipment->getAllItems() as $item) {
|
100 |
-
if ($item->getOrderItem()->getParentItem()) {
|
101 |
-
continue;
|
102 |
-
}
|
103 |
|
104 |
-
|
105 |
-
|
106 |
-
|
|
|
|
|
107 |
|
108 |
-
|
109 |
-
|
|
|
110 |
}
|
111 |
|
112 |
-
|
113 |
-
$page = $this->_insertNote($page, $order, $shipment);
|
114 |
}
|
115 |
|
116 |
-
$this->
|
117 |
-
|
118 |
-
return $pdf;
|
119 |
-
}
|
120 |
-
|
121 |
-
protected function insertTableHeader(&$page)
|
122 |
-
{
|
123 |
-
$page->setFillColor($this->colors['grey1']);
|
124 |
-
$page->setLineColor($this->colors['grey1']);
|
125 |
-
$page->setLineWidth(1);
|
126 |
-
$page->drawRectangle($this->margin['left'], $this->y, $this->margin['right'] - 10, $this->y - 15);
|
127 |
-
|
128 |
-
$page->setFillColor($this->colors['black']);
|
129 |
-
$font = $this->_setFontRegular($page, 9);
|
130 |
-
|
131 |
-
$this->y -= 11;
|
132 |
-
$page->drawText(Mage::helper('firegento_pdf')->__('No.'), $this->margin['left'], $this->y, $this->encoding);
|
133 |
-
$page->drawText(Mage::helper('firegento_pdf')->__('Description'), $this->margin['left'] + 105, $this->y, $this->encoding);
|
134 |
-
|
135 |
-
$page->drawText(Mage::helper('firegento_pdf')->__('Qty'), $this->margin['left'] + 450, $this->y, $this->encoding);
|
136 |
}
|
137 |
|
138 |
-
|
139 |
-
{
|
140 |
-
$this->_setFontRegular($page, 9);
|
141 |
-
|
142 |
-
$billing = $this->_formatAddress($order->getShippingAddress()->format('pdf'));
|
143 |
-
|
144 |
-
foreach ($billing as $line) {
|
145 |
-
$page->drawText(trim(strip_tags($line)), $this->margin['left'], $this->y, $this->encoding);
|
146 |
-
$this->Ln(12);
|
147 |
-
}
|
148 |
-
}
|
149 |
-
|
150 |
-
/**
|
151 |
-
* Initialize renderer process.
|
152 |
-
*
|
153 |
-
* @param string $type
|
154 |
-
* @return void
|
155 |
-
*/
|
156 |
-
protected function _initRenderer($type)
|
157 |
{
|
158 |
-
|
159 |
-
|
160 |
-
$this->_renderers['default'] = array(
|
161 |
-
'model' => 'firegento_pdf/items_shipment_default',
|
162 |
-
'renderer' => null
|
163 |
-
);
|
164 |
-
$this->_renderers['bundle'] = array(
|
165 |
-
'model' => 'firegento_pdf/items_shipment_bundle',
|
166 |
-
'renderer' => null
|
167 |
-
);
|
168 |
}
|
169 |
|
170 |
}
|
171 |
-
|
31 |
* @version $Id:$
|
32 |
* @since 0.1.0
|
33 |
*/
|
34 |
+
class FireGento_Pdf_Model_Shipment
|
35 |
{
|
36 |
|
|
|
|
|
|
|
|
|
|
|
|
|
37 |
/**
|
38 |
+
* The actual PDF engine responsible for rendering the file.
|
39 |
+
* @var Mage_Sales_Model_Order_Pdf_Abstract
|
|
|
|
|
40 |
*/
|
41 |
+
private $_engine;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
42 |
|
43 |
+
protected function getEngine()
|
44 |
+
{
|
45 |
+
if (!$this->_engine) {
|
46 |
+
$modelClass = Mage::getStoreConfig('sales_pdf/shipment/engine');
|
47 |
+
$engine = Mage::getModel($modelClass);
|
48 |
|
49 |
+
if (!$engine) {
|
50 |
+
// Fallback to Magento standard shipment layout.
|
51 |
+
$engine = new Mage_Sales_Model_Order_Pdf_Shipment();
|
52 |
}
|
53 |
|
54 |
+
$this->_engine = $engine;
|
|
|
55 |
}
|
56 |
|
57 |
+
return $this->_engine;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
58 |
}
|
59 |
|
60 |
+
public function getPdf($shipments = array())
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
61 |
{
|
62 |
+
return $this->getEngine()->getPdf($shipments);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
63 |
}
|
64 |
|
65 |
}
|
|
app/code/community/FireGento/Pdf/Model/System/Config/Source/Creditmemo/Engine.php
ADDED
@@ -0,0 +1,74 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* This file is part of the FIREGENTO project.
|
4 |
+
*
|
5 |
+
* FireGento_GermanSetup is free software; you can redistribute it and/or
|
6 |
+
* modify it under the terms of the GNU General Public License version 3 as
|
7 |
+
* published by the Free Software Foundation.
|
8 |
+
*
|
9 |
+
* This script is distributed in the hope that it will be useful, but WITHOUT
|
10 |
+
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
|
11 |
+
* FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
|
12 |
+
*
|
13 |
+
* PHP version 5
|
14 |
+
*
|
15 |
+
* @category FireGento
|
16 |
+
* @package FireGento_Pdf
|
17 |
+
* @author FireGento Team <team@firegento.com>
|
18 |
+
* @copyright 2013 FireGento Team (http://www.firegento.de). All rights served.
|
19 |
+
* @license http://opensource.org/licenses/gpl-3.0 GNU General Public License, version 3 (GPLv3)
|
20 |
+
* @version $Id:$
|
21 |
+
* @since 0.1.0
|
22 |
+
*/
|
23 |
+
/**
|
24 |
+
* Pdf creation engine source model.
|
25 |
+
*
|
26 |
+
* @category FireGento
|
27 |
+
* @package FireGento_Pdf
|
28 |
+
* @author FireGento Team <team@firegento.com>
|
29 |
+
* @copyright 2013 FireGento Team (http://www.firegento.de). All rights served.
|
30 |
+
* @license http://opensource.org/licenses/gpl-3.0 GNU General Public License, version 3 (GPLv3)
|
31 |
+
* @version $Id:$
|
32 |
+
* @since 0.1.0
|
33 |
+
*/
|
34 |
+
class FireGento_Pdf_Model_System_Config_Source_Creditmemo_Engine
|
35 |
+
{
|
36 |
+
/**
|
37 |
+
* Config xpath to pdf engine node
|
38 |
+
*
|
39 |
+
*/
|
40 |
+
const XML_PATH_PDF_ENGINE = 'global/pdf/firegento_creditmemo_engines';
|
41 |
+
|
42 |
+
/**
|
43 |
+
* Return array of possible engines.
|
44 |
+
*
|
45 |
+
* @return array
|
46 |
+
*/
|
47 |
+
public function toOptionArray()
|
48 |
+
{
|
49 |
+
// load default engines shipped with Mage_Sales and FireGento_Pdf
|
50 |
+
$engines = array(
|
51 |
+
'' => Mage::helper('firegento_pdf')->__('Standard Magento'),
|
52 |
+
'firegento_pdf/engine_creditmemo_default' => Mage::helper('firegento_pdf')->__('Standard Germany')
|
53 |
+
);
|
54 |
+
|
55 |
+
// load additional engines provided by third party extensions
|
56 |
+
$engineNodes = Mage::app()->getConfig()->getNode(self::XML_PATH_PDF_ENGINE);
|
57 |
+
if ($engineNodes && $engineNodes->hasChildren()) {
|
58 |
+
foreach ($engineNodes->children() as $engineName => $engineNode) {
|
59 |
+
$className = (string)$engineNode->class;
|
60 |
+
$engineLabel = Mage::helper('firegento_pdf')->__((string)$engineNode->label);
|
61 |
+
$engines[$className] = $engineLabel;
|
62 |
+
}
|
63 |
+
}
|
64 |
+
|
65 |
+
$options = array();
|
66 |
+
foreach ($engines as $k => $v) {
|
67 |
+
$options[] = array(
|
68 |
+
'value' => $k,
|
69 |
+
'label' => $v
|
70 |
+
);
|
71 |
+
}
|
72 |
+
return $options;
|
73 |
+
}
|
74 |
+
}
|
app/code/community/FireGento/Pdf/Model/System/Config/Source/{Engine.php → Invoice/Engine.php}
RENAMED
@@ -31,13 +31,13 @@
|
|
31 |
* @version $Id:$
|
32 |
* @since 0.1.0
|
33 |
*/
|
34 |
-
class
|
35 |
{
|
36 |
/**
|
37 |
* Config xpath to pdf engine node
|
38 |
*
|
39 |
*/
|
40 |
-
const XML_PATH_PDF_ENGINE = 'global/pdf/
|
41 |
|
42 |
/**
|
43 |
* Return array of possible engines.
|
31 |
* @version $Id:$
|
32 |
* @since 0.1.0
|
33 |
*/
|
34 |
+
class FireGento_Pdf_Model_System_Config_Source_Invoice_Engine
|
35 |
{
|
36 |
/**
|
37 |
* Config xpath to pdf engine node
|
38 |
*
|
39 |
*/
|
40 |
+
const XML_PATH_PDF_ENGINE = 'global/pdf/firegento_invoice_engines';
|
41 |
|
42 |
/**
|
43 |
* Return array of possible engines.
|
app/code/community/FireGento/Pdf/Model/System/Config/Source/Shipment/Engine.php
ADDED
@@ -0,0 +1,74 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* This file is part of the FIREGENTO project.
|
4 |
+
*
|
5 |
+
* FireGento_GermanSetup is free software; you can redistribute it and/or
|
6 |
+
* modify it under the terms of the GNU General Public License version 3 as
|
7 |
+
* published by the Free Software Foundation.
|
8 |
+
*
|
9 |
+
* This script is distributed in the hope that it will be useful, but WITHOUT
|
10 |
+
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
|
11 |
+
* FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
|
12 |
+
*
|
13 |
+
* PHP version 5
|
14 |
+
*
|
15 |
+
* @category FireGento
|
16 |
+
* @package FireGento_Pdf
|
17 |
+
* @author FireGento Team <team@firegento.com>
|
18 |
+
* @copyright 2013 FireGento Team (http://www.firegento.de). All rights served.
|
19 |
+
* @license http://opensource.org/licenses/gpl-3.0 GNU General Public License, version 3 (GPLv3)
|
20 |
+
* @version $Id:$
|
21 |
+
* @since 0.1.0
|
22 |
+
*/
|
23 |
+
/**
|
24 |
+
* Pdf creation engine source model.
|
25 |
+
*
|
26 |
+
* @category FireGento
|
27 |
+
* @package FireGento_Pdf
|
28 |
+
* @author FireGento Team <team@firegento.com>
|
29 |
+
* @copyright 2013 FireGento Team (http://www.firegento.de). All rights served.
|
30 |
+
* @license http://opensource.org/licenses/gpl-3.0 GNU General Public License, version 3 (GPLv3)
|
31 |
+
* @version $Id:$
|
32 |
+
* @since 0.1.0
|
33 |
+
*/
|
34 |
+
class FireGento_Pdf_Model_System_Config_Source_Shipment_Engine
|
35 |
+
{
|
36 |
+
/**
|
37 |
+
* Config xpath to pdf engine node
|
38 |
+
*
|
39 |
+
*/
|
40 |
+
const XML_PATH_PDF_ENGINE = 'global/pdf/firegento_shipment_engines';
|
41 |
+
|
42 |
+
/**
|
43 |
+
* Return array of possible engines.
|
44 |
+
*
|
45 |
+
* @return array
|
46 |
+
*/
|
47 |
+
public function toOptionArray()
|
48 |
+
{
|
49 |
+
// load default engines shipped with Mage_Sales and FireGento_Pdf
|
50 |
+
$engines = array(
|
51 |
+
'' => Mage::helper('firegento_pdf')->__('Standard Magento'),
|
52 |
+
'firegento_pdf/engine_shipment_default' => Mage::helper('firegento_pdf')->__('Standard Germany')
|
53 |
+
);
|
54 |
+
|
55 |
+
// load additional engines provided by third party extensions
|
56 |
+
$engineNodes = Mage::app()->getConfig()->getNode(self::XML_PATH_PDF_ENGINE);
|
57 |
+
if ($engineNodes && $engineNodes->hasChildren()) {
|
58 |
+
foreach ($engineNodes->children() as $engineName => $engineNode) {
|
59 |
+
$className = (string)$engineNode->class;
|
60 |
+
$engineLabel = Mage::helper('firegento_pdf')->__((string)$engineNode->label);
|
61 |
+
$engines[$className] = $engineLabel;
|
62 |
+
}
|
63 |
+
}
|
64 |
+
|
65 |
+
$options = array();
|
66 |
+
foreach ($engines as $k => $v) {
|
67 |
+
$options[] = array(
|
68 |
+
'value' => $k,
|
69 |
+
'label' => $v
|
70 |
+
);
|
71 |
+
}
|
72 |
+
return $options;
|
73 |
+
}
|
74 |
+
}
|
app/code/community/FireGento/Pdf/Model/Tax/Sales/Pdf/Grandtotal.php
ADDED
@@ -0,0 +1,99 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* This file is part of the FIREGENTO project.
|
4 |
+
*
|
5 |
+
* FireGento_GermanSetup is free software; you can redistribute it and/or
|
6 |
+
* modify it under the terms of the GNU General Public License version 3 as
|
7 |
+
* published by the Free Software Foundation.
|
8 |
+
*
|
9 |
+
* This script is distributed in the hope that it will be useful, but WITHOUT
|
10 |
+
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
|
11 |
+
* FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
|
12 |
+
*
|
13 |
+
* PHP version 5
|
14 |
+
*
|
15 |
+
* @category FireGento
|
16 |
+
* @package FireGento_Pdf
|
17 |
+
* @author FireGento Team <team@firegento.com>
|
18 |
+
* @copyright 2013 FireGento Team (http://www.firegento.de). All rights served.
|
19 |
+
* @license http://opensource.org/licenses/gpl-3.0 GNU General Public License, version 3 (GPLv3)
|
20 |
+
*/
|
21 |
+
/**
|
22 |
+
* Shipment bundle item model.
|
23 |
+
*
|
24 |
+
* @category FireGento
|
25 |
+
* @package FireGento_Pdf
|
26 |
+
* @author FireGento Team <team@firegento.com>
|
27 |
+
* @copyright 2013 FireGento Team (http://www.firegento.de). All rights served.
|
28 |
+
* @license http://opensource.org/licenses/gpl-3.0 GNU General Public License, version 3 (GPLv3)
|
29 |
+
* @version $Id:$
|
30 |
+
* @since 0.1.0
|
31 |
+
*/
|
32 |
+
class FireGento_Pdf_Model_Tax_Sales_Pdf_Grandtotal extends Mage_Tax_Model_Sales_Pdf_Grandtotal
|
33 |
+
{
|
34 |
+
|
35 |
+
CONST NO_SUM_ON_DETAILS = 'tax/sales_display/no_sum_on_details';
|
36 |
+
|
37 |
+
/**
|
38 |
+
* Check if tax amount should be included to grandtotals block
|
39 |
+
* array(
|
40 |
+
* $index => array(
|
41 |
+
* 'amount' => $amount,
|
42 |
+
* 'label' => $label,
|
43 |
+
* 'font_size'=> $font_size
|
44 |
+
* )
|
45 |
+
* )
|
46 |
+
* @return array
|
47 |
+
*/
|
48 |
+
public function getTotalsForDisplay()
|
49 |
+
{
|
50 |
+
$store = $this->getOrder()->getStore();
|
51 |
+
$config = Mage::getSingleton('tax/config');
|
52 |
+
$noDisplaySumOnDetails = Mage::getStoreConfig(self::NO_SUM_ON_DETAILS, $store);
|
53 |
+
if (!$config->displaySalesTaxWithGrandTotal($store)) {
|
54 |
+
return parent::getTotalsForDisplay();
|
55 |
+
}
|
56 |
+
$amount = $this->getOrder()->formatPriceTxt($this->getAmount());
|
57 |
+
$amountExclTax = $this->getAmount() - $this->getSource()->getTaxAmount();
|
58 |
+
$amountExclTax = ($amountExclTax > 0) ? $amountExclTax : 0;
|
59 |
+
$amountExclTax = $this->getOrder()->formatPriceTxt($amountExclTax);
|
60 |
+
$tax = $this->getOrder()->formatPriceTxt($this->getSource()->getTaxAmount());
|
61 |
+
$fontSize = $this->getFontSize() ? $this->getFontSize() : 7;
|
62 |
+
|
63 |
+
$totals = array(array(
|
64 |
+
'amount' => $this->getAmountPrefix() . $amountExclTax,
|
65 |
+
'label' => Mage::helper('tax')->__('Grand Total (Excl. Tax)') . ':',
|
66 |
+
'font_size' => $fontSize
|
67 |
+
));
|
68 |
+
|
69 |
+
/**
|
70 |
+
* if display_sales_full_summary = 1
|
71 |
+
* display each tax group
|
72 |
+
* if no_sum_on_details is = 1 display tax total additionally
|
73 |
+
* else display only tax total
|
74 |
+
*/
|
75 |
+
if ($config->displaySalesFullSummary($store)) {
|
76 |
+
$totals = array_merge($totals, $this->getFullTaxInfo());
|
77 |
+
if (!$noDisplaySumOnDetails) {
|
78 |
+
$totals[] = array(
|
79 |
+
'amount' => $this->getAmountPrefix() . $tax,
|
80 |
+
'label' => Mage::helper('tax')->__('Tax') . ':',
|
81 |
+
'font_size' => $fontSize
|
82 |
+
);
|
83 |
+
}
|
84 |
+
} else {
|
85 |
+
$totals[] = array(
|
86 |
+
'amount' => $this->getAmountPrefix() . $tax,
|
87 |
+
'label' => Mage::helper('tax')->__('Tax') . ':',
|
88 |
+
'font_size' => $fontSize
|
89 |
+
);
|
90 |
+
}
|
91 |
+
|
92 |
+
$totals[] = array(
|
93 |
+
'amount' => $this->getAmountPrefix() . $amount,
|
94 |
+
'label' => Mage::helper('tax')->__('Grand Total (Incl. Tax)') . ':',
|
95 |
+
'font_size' => $fontSize
|
96 |
+
);
|
97 |
+
return $totals;
|
98 |
+
}
|
99 |
+
}
|
app/code/community/FireGento/Pdf/etc/config.xml
CHANGED
@@ -2,10 +2,15 @@
|
|
2 |
<config>
|
3 |
<modules>
|
4 |
<FireGento_Pdf>
|
5 |
-
<version>1.
|
6 |
</FireGento_Pdf>
|
7 |
</modules>
|
8 |
<global>
|
|
|
|
|
|
|
|
|
|
|
9 |
<helpers>
|
10 |
<firegento_pdf>
|
11 |
<class>FireGento_Pdf_Helper</class>
|
@@ -22,7 +27,19 @@
|
|
22 |
<order_pdf_shipment>FireGento_Pdf_Model_Shipment</order_pdf_shipment>
|
23 |
</rewrite>
|
24 |
</sales>
|
|
|
|
|
|
|
|
|
|
|
25 |
</models>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
26 |
<events>
|
27 |
<firegento_pdf_invoice_insert_note>
|
28 |
<observers>
|
@@ -73,4 +90,23 @@
|
|
73 |
</modules>
|
74 |
</translate>
|
75 |
</adminhtml>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
76 |
</config>
|
2 |
<config>
|
3 |
<modules>
|
4 |
<FireGento_Pdf>
|
5 |
+
<version>1.1.0</version>
|
6 |
</FireGento_Pdf>
|
7 |
</modules>
|
8 |
<global>
|
9 |
+
<blocks>
|
10 |
+
<firegento_pdf>
|
11 |
+
<class>FireGento_Pdf_Block</class>
|
12 |
+
</firegento_pdf>
|
13 |
+
</blocks>
|
14 |
<helpers>
|
15 |
<firegento_pdf>
|
16 |
<class>FireGento_Pdf_Helper</class>
|
27 |
<order_pdf_shipment>FireGento_Pdf_Model_Shipment</order_pdf_shipment>
|
28 |
</rewrite>
|
29 |
</sales>
|
30 |
+
<tax>
|
31 |
+
<rewrite>
|
32 |
+
<sales_pdf_grandtotal>FireGento_Pdf_Model_Tax_Sales_Pdf_Grandtotal</sales_pdf_grandtotal>
|
33 |
+
</rewrite>
|
34 |
+
</tax>
|
35 |
</models>
|
36 |
+
<resources>
|
37 |
+
<firegento_pdf_setup>
|
38 |
+
<setup>
|
39 |
+
<module>FireGento_Pdf</module>
|
40 |
+
</setup>
|
41 |
+
</firegento_pdf_setup>
|
42 |
+
</resources>
|
43 |
<events>
|
44 |
<firegento_pdf_invoice_insert_note>
|
45 |
<observers>
|
90 |
</modules>
|
91 |
</translate>
|
92 |
</adminhtml>
|
93 |
+
<default>
|
94 |
+
<sales_pdf>
|
95 |
+
<invoice>
|
96 |
+
<engine></engine>
|
97 |
+
<item_price_column_order>price_incl_tax,qty,tax,subtotal_incl_tax</item_price_column_order>
|
98 |
+
</invoice>
|
99 |
+
<shipment>
|
100 |
+
<engine></engine>
|
101 |
+
</shipment>
|
102 |
+
<creditmemo>
|
103 |
+
<engine></engine>
|
104 |
+
</creditmemo>
|
105 |
+
</sales_pdf>
|
106 |
+
<tax>
|
107 |
+
<sales_display>
|
108 |
+
<no_sum_on_details>0</no_sum_on_details>
|
109 |
+
</sales_display>
|
110 |
+
</tax>
|
111 |
+
</default>
|
112 |
</config>
|
app/code/community/FireGento/Pdf/etc/system.xml
CHANGED
@@ -24,10 +24,36 @@
|
|
24 |
-->
|
25 |
<config>
|
26 |
<sections>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
27 |
<sales_pdf>
|
28 |
<groups>
|
29 |
<invoice>
|
30 |
<fields>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
31 |
<maturity translate="label comment">
|
32 |
<label>Invoice Maturity</label>
|
33 |
<frontend_type>text</frontend_type>
|
@@ -66,10 +92,36 @@
|
|
66 |
<show_in_store>1</show_in_store>
|
67 |
<comment>Printed on every invoice.</comment>
|
68 |
</note>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
69 |
</fields>
|
70 |
</invoice>
|
71 |
<shipment>
|
72 |
<fields>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
73 |
<note translate="label comment">
|
74 |
<label>Note</label>
|
75 |
<frontend_type>textarea</frontend_type>
|
@@ -83,6 +135,15 @@
|
|
83 |
</shipment>
|
84 |
<creditmemo>
|
85 |
<fields>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
86 |
<note translate="label comment">
|
87 |
<label>Note</label>
|
88 |
<frontend_type>textarea</frontend_type>
|
@@ -102,15 +163,6 @@
|
|
102 |
<show_in_website>1</show_in_website>
|
103 |
<show_in_store>1</show_in_store>
|
104 |
<fields>
|
105 |
-
<engine translate="label">
|
106 |
-
<label>PDF Engine</label>
|
107 |
-
<frontend_type>select</frontend_type>
|
108 |
-
<source_model>firegento_pdf/system_config_source_engine</source_model>
|
109 |
-
<sort_order>0</sort_order>
|
110 |
-
<show_in_default>1</show_in_default>
|
111 |
-
<show_in_website>1</show_in_website>
|
112 |
-
<show_in_store>1</show_in_store>
|
113 |
-
</engine>
|
114 |
<sender_address_bar translate="label">
|
115 |
<label>Sender Address Bar</label>
|
116 |
<frontend_type>text</frontend_type>
|
24 |
-->
|
25 |
<config>
|
26 |
<sections>
|
27 |
+
<tax>
|
28 |
+
<groups>
|
29 |
+
<sales_display>
|
30 |
+
<fields>
|
31 |
+
<no_sum_on_details translate="label">
|
32 |
+
<label>Don't display Tax Total if display Summary is on</label>
|
33 |
+
<frontend_type>select</frontend_type>
|
34 |
+
<source_model>adminhtml/system_config_source_yesno</source_model>
|
35 |
+
<sort_order>70</sort_order>
|
36 |
+
<show_in_default>1</show_in_default>
|
37 |
+
<show_in_website>1</show_in_website>
|
38 |
+
<show_in_store>1</show_in_store>
|
39 |
+
</no_sum_on_details>
|
40 |
+
</fields>
|
41 |
+
</sales_display>
|
42 |
+
</groups>
|
43 |
+
</tax>
|
44 |
<sales_pdf>
|
45 |
<groups>
|
46 |
<invoice>
|
47 |
<fields>
|
48 |
+
<engine translate="label">
|
49 |
+
<label>PDF Engine</label>
|
50 |
+
<frontend_type>select</frontend_type>
|
51 |
+
<source_model>firegento_pdf/system_config_source_invoice_engine</source_model>
|
52 |
+
<sort_order>0</sort_order>
|
53 |
+
<show_in_default>1</show_in_default>
|
54 |
+
<show_in_website>1</show_in_website>
|
55 |
+
<show_in_store>1</show_in_store>
|
56 |
+
</engine>
|
57 |
<maturity translate="label comment">
|
58 |
<label>Invoice Maturity</label>
|
59 |
<frontend_type>text</frontend_type>
|
92 |
<show_in_store>1</show_in_store>
|
93 |
<comment>Printed on every invoice.</comment>
|
94 |
</note>
|
95 |
+
<item_price_column_order translate="label comment">
|
96 |
+
<label>Order of price columns of items</label>
|
97 |
+
<frontend_model>firegento_pdf/adminhtml_columnOrder</frontend_model>
|
98 |
+
<sort_order>5</sort_order>
|
99 |
+
<show_in_default>1</show_in_default>
|
100 |
+
<show_in_website>1</show_in_website>
|
101 |
+
<show_in_store>1</show_in_store>
|
102 |
+
</item_price_column_order>
|
103 |
+
<show_item_discount translate="label">
|
104 |
+
<label>Show Item Discount</label>
|
105 |
+
<frontend_type>select</frontend_type>
|
106 |
+
<source_model>adminhtml/system_config_source_yesno</source_model>
|
107 |
+
<sort_order>10</sort_order>
|
108 |
+
<show_in_default>1</show_in_default>
|
109 |
+
<show_in_website>1</show_in_website>
|
110 |
+
<show_in_store>1</show_in_store>
|
111 |
+
</show_item_discount>
|
112 |
</fields>
|
113 |
</invoice>
|
114 |
<shipment>
|
115 |
<fields>
|
116 |
+
<engine translate="label">
|
117 |
+
<label>PDF Engine</label>
|
118 |
+
<frontend_type>select</frontend_type>
|
119 |
+
<source_model>firegento_pdf/system_config_source_shipment_engine</source_model>
|
120 |
+
<sort_order>0</sort_order>
|
121 |
+
<show_in_default>1</show_in_default>
|
122 |
+
<show_in_website>1</show_in_website>
|
123 |
+
<show_in_store>1</show_in_store>
|
124 |
+
</engine>
|
125 |
<note translate="label comment">
|
126 |
<label>Note</label>
|
127 |
<frontend_type>textarea</frontend_type>
|
135 |
</shipment>
|
136 |
<creditmemo>
|
137 |
<fields>
|
138 |
+
<engine translate="label">
|
139 |
+
<label>PDF Engine</label>
|
140 |
+
<frontend_type>select</frontend_type>
|
141 |
+
<source_model>firegento_pdf/system_config_source_creditmemo_engine</source_model>
|
142 |
+
<sort_order>0</sort_order>
|
143 |
+
<show_in_default>1</show_in_default>
|
144 |
+
<show_in_website>1</show_in_website>
|
145 |
+
<show_in_store>1</show_in_store>
|
146 |
+
</engine>
|
147 |
<note translate="label comment">
|
148 |
<label>Note</label>
|
149 |
<frontend_type>textarea</frontend_type>
|
163 |
<show_in_website>1</show_in_website>
|
164 |
<show_in_store>1</show_in_store>
|
165 |
<fields>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
166 |
<sender_address_bar translate="label">
|
167 |
<label>Sender Address Bar</label>
|
168 |
<frontend_type>text</frontend_type>
|
app/code/community/FireGento/Pdf/sql/firegento_pdf_setup/upgrade-1.0.0-1.1.0.php
ADDED
@@ -0,0 +1,44 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* This file is part of the FIREGENTO project.
|
4 |
+
*
|
5 |
+
* FireGento_GermanSetup is free software; you can redistribute it and/or
|
6 |
+
* modify it under the terms of the GNU General Public License version 3 as
|
7 |
+
* published by the Free Software Foundation.
|
8 |
+
*
|
9 |
+
* This script is distributed in the hope that it will be useful, but WITHOUT
|
10 |
+
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
|
11 |
+
* FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
|
12 |
+
*
|
13 |
+
* PHP version 5
|
14 |
+
*
|
15 |
+
* @category FireGento
|
16 |
+
* @package FireGento_Pdf
|
17 |
+
* @author FireGento Team <team@firegento.com>
|
18 |
+
* @copyright 2013 FireGento Team (http://www.firegento.de). All rights served.
|
19 |
+
* @license http://opensource.org/licenses/gpl-3.0 GNU General Public License, version 3 (GPLv3)
|
20 |
+
* @version $Id:$
|
21 |
+
* @since 0.1.0
|
22 |
+
*/
|
23 |
+
/**
|
24 |
+
* Invoice model rewrite.
|
25 |
+
*
|
26 |
+
* The invoice model serves as a proxy to the actual PDF engine as set via
|
27 |
+
* backend configuration.
|
28 |
+
*
|
29 |
+
* @category FireGento
|
30 |
+
* @package FireGento_Pdf
|
31 |
+
* @author FireGento Team <team@firegento.com>
|
32 |
+
* @copyright 2013 FireGento Team (http://www.firegento.de). All rights served.
|
33 |
+
* @license http://opensource.org/licenses/gpl-3.0 GNU General Public License, version 3 (GPLv3)
|
34 |
+
* @version $Id:$
|
35 |
+
* @since 0.1.0
|
36 |
+
*/
|
37 |
+
|
38 |
+
/* @var $this Mage_Eav_Model_Entity_Setup */
|
39 |
+
$installer = $this;
|
40 |
+
$installer->startSetup();
|
41 |
+
|
42 |
+
$installer->deleteConfigData('sales_pdf/firegento_pdf/engine');
|
43 |
+
|
44 |
+
$installer->endSetup();
|
app/locale/de_DE/FireGento_Pdf.csv
CHANGED
@@ -66,4 +66,14 @@
|
|
66 |
"Position of payment method on invoice.","Position der Zahlungart auf der Rechnung."
|
67 |
"Show Shipping Method","Versandart andrucken"
|
68 |
"Hide shipping method","Nicht andrucken"
|
69 |
-
"Position of shipping method on invoice.","Position der Versandart auf der Rechnung."
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
66 |
"Position of payment method on invoice.","Position der Zahlungart auf der Rechnung."
|
67 |
"Show Shipping Method","Versandart andrucken"
|
68 |
"Hide shipping method","Nicht andrucken"
|
69 |
+
"Position of shipping method on invoice.","Position der Versandart auf der Rechnung."
|
70 |
+
"not to be listed","nicht aufzulisten"
|
71 |
+
"Show Item Discount","Rabatt auf Artikelebene anzeigen"
|
72 |
+
"You get a discount of %s.","Sie erhalten einen Rabatt von %s."
|
73 |
+
"Tax amount","Steuerbetrag"
|
74 |
+
"Price (incl. tax)","Preis (Brutto)"
|
75 |
+
"Subtotal (incl. tax)","Zwischensumme (Brutto)"
|
76 |
+
"Order of price columns of items","Reihenfolge der Spalten in der Artikelliste"
|
77 |
+
"Define the order by moving the following items using your mouse:","Legen Sie die Reihenfolge durch Verschieben der Einträge mit der Maus fest:"
|
78 |
+
"Tax rate","Steuersatz"
|
79 |
+
"Total (incl. tax)","Gesamt (brutto)"
|
package.xml
CHANGED
@@ -1,18 +1,18 @@
|
|
1 |
<?xml version="1.0"?>
|
2 |
<package>
|
3 |
<name>FireGento_Pdf</name>
|
4 |
-
<version>1.
|
5 |
<stability>stable</stability>
|
6 |
<license>OSL 3.0</license>
|
7 |
<channel>community</channel>
|
8 |
<extends/>
|
9 |
<summary>FireGento PDF overwrites standard PDF layouts for invoices, shipments and creditmemos.</summary>
|
10 |
<description>FireGento PDF overwrites standard PDF layouts for invoices, shipments and creditmemos. Anyway, you can still use the standard Magento layout, because the extension is highly configurable.</description>
|
11 |
-
<notes>
|
12 |
<authors><author><name>FireGento Team</name><user>firegento</user><email>team@firegento.com</email></author></authors>
|
13 |
-
<date>2013-06-
|
14 |
-
<time>
|
15 |
-
<contents><target name="magecommunity"><dir name="FireGento"><dir name="Pdf"><dir name="Helper"><file name="Data.php" hash="b197385beacefb9726be15e99f87c21f"/></dir><dir name="Model"><file name="
|
16 |
<compatible/>
|
17 |
<dependencies><required><php><min>5.2.0</min><max>6.0.0</max></php></required></dependencies>
|
18 |
</package>
|
1 |
<?xml version="1.0"?>
|
2 |
<package>
|
3 |
<name>FireGento_Pdf</name>
|
4 |
+
<version>1.1.0</version>
|
5 |
<stability>stable</stability>
|
6 |
<license>OSL 3.0</license>
|
7 |
<channel>community</channel>
|
8 |
<extends/>
|
9 |
<summary>FireGento PDF overwrites standard PDF layouts for invoices, shipments and creditmemos.</summary>
|
10 |
<description>FireGento PDF overwrites standard PDF layouts for invoices, shipments and creditmemos. Anyway, you can still use the standard Magento layout, because the extension is highly configurable.</description>
|
11 |
+
<notes>Refactoring, New Feature configurable engines for shipment,creditmemo</notes>
|
12 |
<authors><author><name>FireGento Team</name><user>firegento</user><email>team@firegento.com</email></author></authors>
|
13 |
+
<date>2013-06-02</date>
|
14 |
+
<time>12:21:10</time>
|
15 |
+
<contents><target name="magecommunity"><dir name="FireGento"><dir name="Pdf"><dir name="Block"><dir name="Adminhtml"><file name="ColumnOrder.php" hash="4dbebc7685846af767772570ba519b28"/></dir></dir><dir name="Helper"><file name="Data.php" hash="b197385beacefb9726be15e99f87c21f"/></dir><dir name="Model"><file name="Creditmemo.php" hash="0f1a2f2b90692389380d2ff4a1d3cbd5"/><dir name="Engine"><file name="Abstract.php" hash="bd9c55df833866f99143080765081f31"/><dir name="Creditmemo"><file name="Default.php" hash="6af5cb1af74026f5fc397233ed091178"/></dir><dir name="Invoice"><file name="Default.php" hash="beec3d9d07269bfce5875606de8397f4"/></dir><dir name="Shipment"><file name="Default.php" hash="15130cdef17063840a71a44557517fd4"/></dir></dir><file name="Invoice.php" hash="7f25849c158cc12aadbb4cf12c7eee43"/><dir name="Items"><file name="Bundle.php" hash="5baecc71b3d44fa7a113a63008bbf10a"/><file name="Default.php" hash="6d3442d9f93f8264f9117969f90cb0d8"/><file name="Grouped.php" hash="eb59e0bbeac4750beb30af5e4fdc56e3"/><dir name="Shipment"><file name="Bundle.php" hash="7fac91000132878ad98f1d3479fc2456"/><file name="Default.php" hash="8c24b8474bcc734274e392e6791e6aa2"/></dir></dir><file name="Observer.php" hash="6d2d144bd5fcd2a3246d67687ca71b53"/><file name="Shipment.php" hash="5ded7f40fc967fc6dd21b2e63a217041"/><dir name="System"><dir name="Config"><dir name="Source"><dir name="Creditmemo"><file name="Engine.php" hash="807d8e600610e7c6495dd25c5a45126f"/></dir><dir name="Invoice"><file name="Engine.php" hash="acf338e9568cb9506afdc86f3b9fffc9"/></dir><file name="Logo.php" hash="37485e2799c9394434cc49d72ed239e4"/><file name="Payment.php" hash="2c443eb8bf897148debeccf638f39849"/><dir name="Shipment"><file name="Engine.php" hash="9bc9a545b630821ea4fff269d79ae2b5"/></dir><file name="Shipping.php" hash="76bf4c6afbb18bf2d2172707509125df"/></dir></dir></dir><dir name="Tax"><dir name="Sales"><dir name="Pdf"><file name="Grandtotal.php" hash="65cb26d2123c2722edd9729426b91e2e"/></dir></dir></dir></dir><dir name="controllers"><dir name="Sales"><file name="OrderController.php" hash="38df8d94fe6035b99a543f8212db58d1"/></dir></dir><dir name="etc"><file name="config.xml" hash="97bd1bcdf35f74fa086082b34475097a"/><file name="system.xml" hash="6ac19114cd85dd490c362d5a37cec63f"/></dir><dir name="sql"><dir name="firegento_pdf_setup"><file name="upgrade-1.0.0-1.1.0.php" hash="5b1aefa82aff01baf9a873a5305c4a57"/></dir></dir></dir></dir></target><target name="mageetc"><dir name="modules"><file name="FireGento_Pdf.xml" hash="b50e6c2f168aff9a4fb983240f1d8941"/></dir></target><target name="magelocale"><dir><dir name="de_DE"><file name="FireGento_Pdf.csv" hash="3453e2a0543feecfd3d0e8c7542f9795"/></dir></dir></target></contents>
|
16 |
<compatible/>
|
17 |
<dependencies><required><php><min>5.2.0</min><max>6.0.0</max></php></required></dependencies>
|
18 |
</package>
|