Version Notes
First release
Download this release
Release Info
Developer | FireGento Team |
Extension | FireGento_Pdf |
Version | 1.0.0 |
Comparing to | |
See all releases |
Version 1.0.0
- app/code/community/FireGento/Pdf/Helper/Data.php +98 -0
- app/code/community/FireGento/Pdf/Model/Abstract.php +952 -0
- app/code/community/FireGento/Pdf/Model/Creditmemo.php +186 -0
- app/code/community/FireGento/Pdf/Model/Engine/Invoice/Default.php +185 -0
- app/code/community/FireGento/Pdf/Model/Invoice.php +103 -0
- app/code/community/FireGento/Pdf/Model/Items/Bundle.php +209 -0
- app/code/community/FireGento/Pdf/Model/Items/Default.php +138 -0
- app/code/community/FireGento/Pdf/Model/Items/Grouped.php +50 -0
- app/code/community/FireGento/Pdf/Model/Items/Shipment/Bundle.php +187 -0
- app/code/community/FireGento/Pdf/Model/Items/Shipment/Default.php +108 -0
- app/code/community/FireGento/Pdf/Model/Observer.php +110 -0
- app/code/community/FireGento/Pdf/Model/Shipment.php +171 -0
- app/code/community/FireGento/Pdf/Model/System/Config/Source/Engine.php +74 -0
- app/code/community/FireGento/Pdf/Model/System/Config/Source/Logo.php +57 -0
- app/code/community/FireGento/Pdf/Model/System/Config/Source/Payment.php +60 -0
- app/code/community/FireGento/Pdf/Model/System/Config/Source/Shipping.php +60 -0
- app/code/community/FireGento/Pdf/controllers/Sales/OrderController.php +86 -0
- app/code/community/FireGento/Pdf/etc/config.xml +76 -0
- app/code/community/FireGento/Pdf/etc/system.xml +145 -0
- app/etc/modules/FireGento_Pdf.xml +9 -0
- app/locale/de_DE/FireGento_Pdf.csv +69 -0
- package.xml +18 -0
app/code/community/FireGento/Pdf/Helper/Data.php
ADDED
@@ -0,0 +1,98 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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 |
+
* Dummy data helper for translation issues.
|
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_Helper_Data extends Mage_Core_Helper_Abstract
|
35 |
+
{
|
36 |
+
/**
|
37 |
+
* Return the order id or false if order id should not be displayed on document.
|
38 |
+
*
|
39 |
+
* @param Mage_Sales_Model_Order $order
|
40 |
+
* @param string $mode
|
41 |
+
* @return mixed
|
42 |
+
*/
|
43 |
+
public function putOrderId(Mage_Sales_Model_Order $order, $mode = 'invoice')
|
44 |
+
{
|
45 |
+
switch ($mode) {
|
46 |
+
case 'invoice':
|
47 |
+
if (Mage::getStoreConfigFlag(Mage_Sales_Model_Order_Pdf_Abstract::XML_PATH_SALES_PDF_INVOICE_PUT_ORDER_ID, $order->getStoreId())) {
|
48 |
+
return $order->getRealOrderId();
|
49 |
+
}
|
50 |
+
break;
|
51 |
+
|
52 |
+
case 'shipment':
|
53 |
+
if (Mage::getStoreConfigFlag(Mage_Sales_Model_Order_Pdf_Abstract::XML_PATH_SALES_PDF_SHIPMENT_PUT_ORDER_ID, $order->getStoreId())) {
|
54 |
+
return $order->getRealOrderId();
|
55 |
+
}
|
56 |
+
break;
|
57 |
+
|
58 |
+
case 'creditmemo':
|
59 |
+
if (Mage::getStoreConfigFlag(Mage_Sales_Model_Order_Pdf_Abstract::XML_PATH_SALES_PDF_CREDITMEMO_PUT_ORDER_ID, $order->getStoreId())) {
|
60 |
+
return $order->getRealOrderId();
|
61 |
+
}
|
62 |
+
break;
|
63 |
+
}
|
64 |
+
return false;
|
65 |
+
}
|
66 |
+
|
67 |
+
/**
|
68 |
+
* Return scaled image sizes based on an path to an image file.
|
69 |
+
*
|
70 |
+
* @param string $image Url to image file.
|
71 |
+
* @param int $maxWidth
|
72 |
+
* @param int $maxHeight
|
73 |
+
* @return array with 2 elements - width and height.
|
74 |
+
*/
|
75 |
+
public function getScaledImageSize($image, $maxWidth, $maxHeight)
|
76 |
+
{
|
77 |
+
list($width, $height) = getimagesize($image);
|
78 |
+
|
79 |
+
if ($height > $maxHeight or $width > $maxWidth) {
|
80 |
+
// Calculate max variance to match dimensions.
|
81 |
+
$widthVar = $width / $maxWidth;
|
82 |
+
$heightVar = $height / $maxHeight;
|
83 |
+
|
84 |
+
// Calculate scale factor to match dimensions.
|
85 |
+
if ($widthVar > $heightVar) {
|
86 |
+
$scale = $maxWidth / $width;
|
87 |
+
} else {
|
88 |
+
$scale = $maxHeight / $height;
|
89 |
+
}
|
90 |
+
|
91 |
+
// Calculate new dimensions.
|
92 |
+
$height = round($height * $scale);
|
93 |
+
$width = round($width * $scale);
|
94 |
+
}
|
95 |
+
|
96 |
+
return array($width, $height);
|
97 |
+
}
|
98 |
+
}
|
app/code/community/FireGento/Pdf/Model/Abstract.php
ADDED
@@ -0,0 +1,952 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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 |
+
* Abstract pdf 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 |
+
abstract class FireGento_Pdf_Model_Abstract extends Mage_Sales_Model_Order_Pdf_Abstract
|
35 |
+
{
|
36 |
+
public $margin = array('left' => 45, 'right' => 540);
|
37 |
+
public $colors = array();
|
38 |
+
public $mode;
|
39 |
+
public $encoding;
|
40 |
+
public $pagecounter;
|
41 |
+
|
42 |
+
protected $imprint;
|
43 |
+
|
44 |
+
public function __construct()
|
45 |
+
{
|
46 |
+
parent::__construct();
|
47 |
+
|
48 |
+
$this->encoding = 'UTF-8';
|
49 |
+
|
50 |
+
$this->colors['black'] = new Zend_Pdf_Color_GrayScale(0);
|
51 |
+
$this->colors['grey1'] = new Zend_Pdf_Color_GrayScale(0.9);
|
52 |
+
|
53 |
+
// get the default imprint
|
54 |
+
$this->imprint = Mage::getStoreConfig('general/imprint');
|
55 |
+
}
|
56 |
+
|
57 |
+
/**
|
58 |
+
* ...
|
59 |
+
*
|
60 |
+
* @param Zend_Pdf_Page $page Current page object of Zend_Pdf
|
61 |
+
* @param array $draw
|
62 |
+
* @param array $pageSettings
|
63 |
+
* @return Zend_Pdf_Page
|
64 |
+
*/
|
65 |
+
public function drawLineBlocks(Zend_Pdf_Page $page, array $draw, array $pageSettings = array())
|
66 |
+
{
|
67 |
+
foreach ($draw as $itemsProp) {
|
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'])) {
|
75 |
+
$shift = 0;
|
76 |
+
foreach ($lines as $line) {
|
77 |
+
$maxHeight = 0;
|
78 |
+
foreach ($line as $column) {
|
79 |
+
$lineSpacing = !empty($column['height']) ? $column['height'] : $height;
|
80 |
+
if (!is_array($column['text'])) {
|
81 |
+
$column['text'] = array($column['text']);
|
82 |
+
}
|
83 |
+
$top = 0;
|
84 |
+
foreach ($column['text'] as $part) {
|
85 |
+
$top += $lineSpacing;
|
86 |
+
}
|
87 |
+
|
88 |
+
$maxHeight = $top > $maxHeight ? $top : $maxHeight;
|
89 |
+
}
|
90 |
+
$shift += $maxHeight;
|
91 |
+
}
|
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 = 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 |
+
}
|
107 |
+
else {
|
108 |
+
$fontStyle = empty($column['font']) ? 'regular' : $column['font'];
|
109 |
+
switch ($fontStyle) {
|
110 |
+
case 'bold':
|
111 |
+
$font = $this->_setFontBold($page, $fontSize);
|
112 |
+
break;
|
113 |
+
case 'italic':
|
114 |
+
$font = $this->_setFontItalic($page, $fontSize);
|
115 |
+
break;
|
116 |
+
default:
|
117 |
+
$font = $this->_setFontRegular($page, $fontSize);
|
118 |
+
break;
|
119 |
+
}
|
120 |
+
}
|
121 |
+
|
122 |
+
if (!is_array($column['text'])) {
|
123 |
+
$column['text'] = array($column['text']);
|
124 |
+
}
|
125 |
+
|
126 |
+
$lineSpacing = !empty($column['height']) ? $column['height'] : $height;
|
127 |
+
$top = 0;
|
128 |
+
foreach ($column['text'] as $part) {
|
129 |
+
$feed = $column['feed'];
|
130 |
+
$textAlign = empty($column['align']) ? 'left' : $column['align'];
|
131 |
+
$width = empty($column['width']) ? 0 : $column['width'];
|
132 |
+
switch ($textAlign) {
|
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;
|
141 |
+
case 'center':
|
142 |
+
if ($width) {
|
143 |
+
$feed = $this->getAlignCenter($part, $feed, $width, $font, $fontSize);
|
144 |
+
}
|
145 |
+
break;
|
146 |
+
}
|
147 |
+
$page->drawText($part, $feed, $this->y-$top, 'UTF-8');
|
148 |
+
$top += $lineSpacing;
|
149 |
+
}
|
150 |
+
|
151 |
+
$maxHeight = $top > $maxHeight ? $top : $maxHeight;
|
152 |
+
}
|
153 |
+
$this->y -= $maxHeight;
|
154 |
+
}
|
155 |
+
}
|
156 |
+
|
157 |
+
return $page;
|
158 |
+
}
|
159 |
+
|
160 |
+
/**
|
161 |
+
* Set pdf mode.
|
162 |
+
*
|
163 |
+
* @param string $mode
|
164 |
+
* @return FireGento_Pdf_Model_Abstract
|
165 |
+
*/
|
166 |
+
public function setMode($mode)
|
167 |
+
{
|
168 |
+
$this->mode = $mode;
|
169 |
+
return $this;
|
170 |
+
}
|
171 |
+
|
172 |
+
/**
|
173 |
+
* Return pdf mode.
|
174 |
+
*
|
175 |
+
* @return string
|
176 |
+
*/
|
177 |
+
public function getMode()
|
178 |
+
{
|
179 |
+
return $this->mode;
|
180 |
+
}
|
181 |
+
|
182 |
+
/**
|
183 |
+
* Set next line position
|
184 |
+
*
|
185 |
+
* @param int $height Line-Height
|
186 |
+
* @return void
|
187 |
+
*/
|
188 |
+
protected function Ln($height = 15)
|
189 |
+
{
|
190 |
+
$this->y -= $height;
|
191 |
+
}
|
192 |
+
|
193 |
+
/**
|
194 |
+
* Insert sender address bar.
|
195 |
+
*
|
196 |
+
* @param Zend_Pdf_Page $page Current page object of Zend_Pdf
|
197 |
+
* @return void
|
198 |
+
*/
|
199 |
+
protected function _insertSenderAddessBar(&$page)
|
200 |
+
{
|
201 |
+
if (Mage::getStoreConfig('sales_pdf/firegento_pdf/sender_address_bar') != '') {
|
202 |
+
$this->_setFontRegular($page, 6);
|
203 |
+
$page->drawText(trim(Mage::getStoreConfig('sales_pdf/firegento_pdf/sender_address_bar')), $this->margin['left'], $this->y, $this->encoding);
|
204 |
+
}
|
205 |
+
}
|
206 |
+
|
207 |
+
/**
|
208 |
+
* Insert logo
|
209 |
+
*
|
210 |
+
* @param Zend_Pdf_Page $page Current page object of Zend_Pdf
|
211 |
+
* @param mixed $store
|
212 |
+
* @return void
|
213 |
+
*/
|
214 |
+
protected function insertLogo(&$page, $store = null)
|
215 |
+
{
|
216 |
+
$maxwidth = ($this->margin['right'] - $this->margin['left']);
|
217 |
+
$maxheight = 100;
|
218 |
+
|
219 |
+
$image = Mage::getStoreConfig('sales/identity/logo', $store);
|
220 |
+
if ($image and file_exists(Mage::getBaseDir('media', $store) . '/sales/store/logo/' . $image)) {
|
221 |
+
$image = Mage::getBaseDir('media', $store) . '/sales/store/logo/' . $image;
|
222 |
+
|
223 |
+
list ($width, $height) = Mage::helper('firegento_pdf')->getScaledImageSize($image, $maxwidth, $maxheight);
|
224 |
+
|
225 |
+
if (is_file($image)) {
|
226 |
+
$image = Zend_Pdf_Image::imageWithPath($image);
|
227 |
+
|
228 |
+
$logoPosition = Mage::getStoreConfig('sales_pdf/firegento_pdf/logo_position', $store);
|
229 |
+
|
230 |
+
switch($logoPosition) {
|
231 |
+
case 'center':
|
232 |
+
$startLogoAt = $this->margin['left'] + ( ($this->margin['right'] - $this->margin['left']) / 2 ) - $width / 2;
|
233 |
+
break;
|
234 |
+
case 'right':
|
235 |
+
$startLogoAt = $this->margin['right'] - $width;
|
236 |
+
break;
|
237 |
+
default:
|
238 |
+
$startLogoAt = $this->margin['left'];
|
239 |
+
}
|
240 |
+
|
241 |
+
$position['x1'] = $startLogoAt;
|
242 |
+
$position['y1'] = 720;
|
243 |
+
$position['x2'] = $position['x1'] + $width;
|
244 |
+
$position['y2'] = $position['y1'] + $height;
|
245 |
+
|
246 |
+
$page->drawImage($image, $position['x1'], $position['y1'], $position['x2'], $position['y2']);
|
247 |
+
}
|
248 |
+
}
|
249 |
+
}
|
250 |
+
|
251 |
+
/**
|
252 |
+
* Insert billing address
|
253 |
+
*
|
254 |
+
* @param object $page Current page object of Zend_Pdf
|
255 |
+
* @param object $order Order object
|
256 |
+
* @return void
|
257 |
+
*/
|
258 |
+
protected function insertBillingAddress(&$page, $order)
|
259 |
+
{
|
260 |
+
$this->_setFontRegular($page, 9);
|
261 |
+
$billing = $this->_formatAddress($order->getBillingAddress()->format('pdf'));
|
262 |
+
foreach ($billing as $line) {
|
263 |
+
$page->drawText(trim(strip_tags($line)), $this->margin['left'], $this->y, $this->encoding);
|
264 |
+
$this->Ln(12);
|
265 |
+
}
|
266 |
+
}
|
267 |
+
|
268 |
+
/**
|
269 |
+
* Insert Header
|
270 |
+
*
|
271 |
+
* @param Zend_Pdf_Page $page Current page object of Zend_Pdf
|
272 |
+
* @param object $order Order object
|
273 |
+
* @param object $document Document object
|
274 |
+
* @return void
|
275 |
+
*/
|
276 |
+
protected function insertHeader(&$page, $order, $document)
|
277 |
+
{
|
278 |
+
$page->setFillColor($this->colors['black']);
|
279 |
+
|
280 |
+
$mode = $this->getMode();
|
281 |
+
|
282 |
+
$this->_setFontBold($page, 15);
|
283 |
+
|
284 |
+
$page->drawText(Mage::helper('firegento_pdf')->__( ($mode == 'invoice') ? 'Invoice' : 'Creditmemo' ), $this->margin['left'], $this->y, $this->encoding);
|
285 |
+
|
286 |
+
$this->_setFontRegular($page);
|
287 |
+
|
288 |
+
$this->y += 80;
|
289 |
+
$rightoffset = 180;
|
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 |
+
if ($order->getCustomerId() != '') {
|
303 |
+
$page->drawText(Mage::helper('firegento_pdf')->__('Customer number:'), ($this->margin['right'] - $rightoffset), $this->y, $this->encoding);
|
304 |
+
$this->Ln();
|
305 |
+
$yPlus += 15;
|
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 |
+
// Draw shipping method.
|
327 |
+
$putShippingMethod = ($mode == 'invoice' && Mage::getStoreConfig('sales_pdf/invoice/shipping_method_position') == FireGento_Pdf_Model_System_Config_Source_Shipping::POSITION_HEADER);
|
328 |
+
if ($putShippingMethod) {
|
329 |
+
$page->drawText(Mage::helper('firegento_pdf')->__('Shipping method:'), ($this->margin['right'] - $rightoffset), $this->y, $this->encoding);
|
330 |
+
$this->Ln();
|
331 |
+
$yPlus += 15;
|
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'] - $rightoffset - $this->widthForStringUsingFontSize($incrementId, $font, 10)), $this->y, $this->encoding);
|
341 |
+
$this->Ln();
|
342 |
+
|
343 |
+
if ($putOrderId) {
|
344 |
+
$page->drawText($putOrderId, ($this->margin['right'] - $rightoffset - $this->widthForStringUsingFontSize($putOrderId, $font, 10)), $this->y, $this->encoding);
|
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.$order->getCustomerId();
|
354 |
+
} else {
|
355 |
+
$customerid = $order->getCustomerId();
|
356 |
+
}
|
357 |
+
|
358 |
+
$page->drawText($customerid, ($this->margin['right'] - $rightoffset - $this->widthForStringUsingFontSize($customerid, $font, 10)), $this->y, $this->encoding);
|
359 |
+
$this->Ln();
|
360 |
+
}else{
|
361 |
+
$page->drawText('-', ($this->margin['right'] - $rightoffset - $this->widthForStringUsingFontSize('-', $font, 10)), $this->y, $this->encoding);
|
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'] - $rightoffset - $this->widthForStringUsingFontSize($customerIP, $font, 10)), $this->y, $this->encoding);
|
369 |
+
$this->Ln();
|
370 |
+
}
|
371 |
+
|
372 |
+
$documentDate = Mage::helper('core')->formatDate($document->getCreatedAtDate(), 'medium', false);
|
373 |
+
$page->drawText($documentDate, ($this->margin['right'] - $rightoffset - $this->widthForStringUsingFontSize($documentDate, $font, 10)), $this->y, $this->encoding);
|
374 |
+
$this->Ln();
|
375 |
+
|
376 |
+
if ($putPaymentMethod) {
|
377 |
+
$paymentMethod = $order->getPayment()->getMethodInstance()->getTitle();
|
378 |
+
$page->drawText($paymentMethod, ($this->margin['right'] - $rightoffset - $this->widthForStringUsingFontSize($paymentMethod, $font, 10)), $this->y, $this->encoding);
|
379 |
+
$this->Ln();
|
380 |
+
}
|
381 |
+
|
382 |
+
if ($putShippingMethod) {
|
383 |
+
$shippingMethod = $order->getShippingDescription();
|
384 |
+
$page->drawText($shippingMethod, ($this->margin['right'] - $rightoffset - $this->widthForStringUsingFontSize($shippingMethod, $font, 10)), $this->y, $this->encoding);
|
385 |
+
$this->Ln();
|
386 |
+
}
|
387 |
+
}
|
388 |
+
|
389 |
+
/**
|
390 |
+
* Return the order id or false if order id should not be displayed on document.
|
391 |
+
*
|
392 |
+
* @param $order
|
393 |
+
* @return mixed
|
394 |
+
*/
|
395 |
+
protected function _putOrderId($order)
|
396 |
+
{
|
397 |
+
return Mage::helper('firegento_pdf')->putOrderId($order, $this->mode);
|
398 |
+
}
|
399 |
+
|
400 |
+
/**
|
401 |
+
* Generate new PDF page.
|
402 |
+
*
|
403 |
+
* @param array $settings Page settings
|
404 |
+
* @return Zend_Pdf_Page
|
405 |
+
*/
|
406 |
+
public function newPage(array $settings = array())
|
407 |
+
{
|
408 |
+
$pdf = $this->_getPdf();
|
409 |
+
|
410 |
+
$page = $pdf->newPage(Zend_Pdf_Page::SIZE_A4);
|
411 |
+
$this->pagecounter++;
|
412 |
+
$pdf->pages[] = $page;
|
413 |
+
|
414 |
+
$this->_addFooter($page, Mage::app()->getStore());
|
415 |
+
|
416 |
+
$this->y = 800;
|
417 |
+
$this->_setFontRegular($page, 9);
|
418 |
+
|
419 |
+
return $page;
|
420 |
+
}
|
421 |
+
|
422 |
+
/**
|
423 |
+
* ...
|
424 |
+
*
|
425 |
+
* @param Varien_Object $item
|
426 |
+
* @param Zend_Pdf_Page $page Current page object of Zend_Pdf
|
427 |
+
* @param Mage_Sales_Model_Order $order
|
428 |
+
* @param int $position
|
429 |
+
* @return Zend_Pdf_Page
|
430 |
+
*/
|
431 |
+
protected function _drawItem(Varien_Object $item, Zend_Pdf_Page $page, Mage_Sales_Model_Order $order, $position = 1)
|
432 |
+
{
|
433 |
+
$type = $item->getOrderItem()->getProductType();
|
434 |
+
|
435 |
+
$renderer = $this->_getRenderer($type);
|
436 |
+
$renderer->setOrder($order);
|
437 |
+
$renderer->setItem($item);
|
438 |
+
$renderer->setPdf($this);
|
439 |
+
$renderer->setPage($page);
|
440 |
+
$renderer->setRenderedModel($this);
|
441 |
+
|
442 |
+
$renderer->draw($position);
|
443 |
+
return $renderer->getPage();
|
444 |
+
}
|
445 |
+
|
446 |
+
/**
|
447 |
+
* Insert Totals Block
|
448 |
+
*
|
449 |
+
* @param object $page Current page object of Zend_Pdf
|
450 |
+
* @param object $source Fields of footer
|
451 |
+
* @return void
|
452 |
+
*/
|
453 |
+
protected function insertTotals($page, $source)
|
454 |
+
{
|
455 |
+
$this->y -=15;
|
456 |
+
|
457 |
+
$order = $source->getOrder();
|
458 |
+
|
459 |
+
$total_tax = 0;
|
460 |
+
$shippingTaxRate = 0;
|
461 |
+
$shippingTaxAmount = $order->getShippingTaxAmount();
|
462 |
+
|
463 |
+
if($shippingTaxAmount > 0) {
|
464 |
+
$shippingTaxRate = $order->getShippingTaxAmount()*100/($order->getShippingInclTax()-$order->getShippingTaxAmount());
|
465 |
+
}
|
466 |
+
|
467 |
+
$groupedTax = array();
|
468 |
+
|
469 |
+
$items['items'] = array();
|
470 |
+
foreach ($source->getAllItems() as $item) {
|
471 |
+
if ($item->getOrderItem()->getParentItem()) {
|
472 |
+
continue;
|
473 |
+
}
|
474 |
+
$items['items'][] = $item->getOrderItem()->toArray();
|
475 |
+
}
|
476 |
+
|
477 |
+
array_push($items['items'], array(
|
478 |
+
'row_invoiced' => $order->getShippingInvoiced(),
|
479 |
+
'tax_inc_subtotal' => false,
|
480 |
+
'tax_percent' => $shippingTaxRate,
|
481 |
+
'tax_amount' => $shippingTaxAmount
|
482 |
+
));
|
483 |
+
|
484 |
+
foreach ($items['items'] as $item) {
|
485 |
+
$_percent = null;
|
486 |
+
if (!isset($item['tax_amount'])) $item['tax_amount'] = 0;
|
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'])&&$_percent){
|
497 |
+
if (!array_key_exists((int)$_percent, $groupedTax)) {
|
498 |
+
$groupedTax[$_percent] = $item['tax_amount'];
|
499 |
+
} else {
|
500 |
+
$groupedTax[$_percent] += $item['tax_amount'];
|
501 |
+
}
|
502 |
+
}
|
503 |
+
}
|
504 |
+
|
505 |
+
$totals = $this->_getTotalsList($source);
|
506 |
+
|
507 |
+
$lineBlock = array(
|
508 |
+
'lines' => array(),
|
509 |
+
'height' => 20
|
510 |
+
);
|
511 |
+
|
512 |
+
foreach ($totals as $total) {
|
513 |
+
$fontSize = (isset($total['font_size']) ? $total['font_size'] : 7);
|
514 |
+
if ($fontSize < 9) {
|
515 |
+
$fontSize = 9;
|
516 |
+
}
|
517 |
+
$fontWeight = (isset($total['font_weight']) ? $total['font_weight'] : 'regular');
|
518 |
+
|
519 |
+
switch($total['source_field']) {
|
520 |
+
case 'tax_amount':
|
521 |
+
foreach ($groupedTax as $taxRate => $taxValue) {
|
522 |
+
if (empty($taxValue)) {
|
523 |
+
continue;
|
524 |
+
}
|
525 |
+
|
526 |
+
$lineBlock['lines'][] = array(
|
527 |
+
array(
|
528 |
+
'text' => Mage::helper('firegento_pdf')->__('Additional tax %s', $source->getStore()->roundPrice(number_format($taxRate, 0)).'%'),
|
529 |
+
'feed' => $this->margin['left'] + 320,
|
530 |
+
'align' => 'left',
|
531 |
+
'font_size' => $fontSize,
|
532 |
+
'font' => $fontWeight
|
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));
|
674 |
+
return $page;
|
675 |
+
}
|
676 |
+
|
677 |
+
/**
|
678 |
+
* Insert Notes
|
679 |
+
*
|
680 |
+
* @param Zend_Pdf_Page $page Current Page Object of Zend_PDF
|
681 |
+
* @param Mage_Sales_Model_Order $order
|
682 |
+
* @param Mage_Sales_Model_Abstract $model
|
683 |
+
* @return void
|
684 |
+
*/
|
685 |
+
protected function _insertNote($page, &$order, &$model)
|
686 |
+
{
|
687 |
+
$fontSize = 10;
|
688 |
+
$font = $this->_setFontRegular($page, $fontSize);
|
689 |
+
$this->y = $this->y - 60;
|
690 |
+
|
691 |
+
$notes = array();
|
692 |
+
|
693 |
+
$result = new Varien_Object();
|
694 |
+
$result->setNotes($notes);
|
695 |
+
Mage::dispatchEvent('firegento_pdf_' . $this->getMode() . '_insert_note', array('order' => $order, $this->getMode() => $model, 'result' => $result));
|
696 |
+
$notes = array_merge($notes, $result->getNotes());
|
697 |
+
|
698 |
+
if ($this->getMode() === 'invoice') {
|
699 |
+
$notes[] = Mage::helper('firegento_pdf')->__('Invoice date is equal to delivery date.');
|
700 |
+
}
|
701 |
+
|
702 |
+
// Get free text notes.
|
703 |
+
$note = Mage::getStoreConfig('sales_pdf/' . $this->getMode() . '/note');
|
704 |
+
if (!empty($note)) {
|
705 |
+
$tmpNotes = explode("\n", $note);
|
706 |
+
$notes = array_merge($notes, $tmpNotes);
|
707 |
+
}
|
708 |
+
|
709 |
+
// Draw notes on PDF.
|
710 |
+
foreach ($notes as $note) {
|
711 |
+
// prepare the text so that it fits to the paper
|
712 |
+
$note = $this->_prepareText($note, $page, $font, $fontSize);
|
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);
|
720 |
+
}
|
721 |
+
$page->drawText($tmpNote, $this->margin['left'], $this->y + 30, $this->encoding);
|
722 |
+
$this->Ln(15);
|
723 |
+
}
|
724 |
+
}
|
725 |
+
return $page;
|
726 |
+
}
|
727 |
+
|
728 |
+
protected function _addFooter(&$page, $store = null)
|
729 |
+
{
|
730 |
+
// get the imprint of the store if a store is set
|
731 |
+
if (!empty($store)) {
|
732 |
+
$this->imprint = Mage::getStoreConfig('general/imprint', $store->getStoreId());
|
733 |
+
}
|
734 |
+
|
735 |
+
// Add footer if GermanSetup is installed.
|
736 |
+
if ($this->imprint && Mage::getStoreConfig('sales_pdf/firegento_pdf/show_footer') == 1) {
|
737 |
+
$this->y = 110;
|
738 |
+
$this->_insertFooter($page);
|
739 |
+
|
740 |
+
// Add page counter.
|
741 |
+
$this->y = 110;
|
742 |
+
$this->_insertPageCounter($page);
|
743 |
+
}
|
744 |
+
}
|
745 |
+
|
746 |
+
/**
|
747 |
+
* Insert footer
|
748 |
+
*
|
749 |
+
* @param Zend_Pdf_Page $page Current page object of Zend_Pdf
|
750 |
+
* @return void
|
751 |
+
*/
|
752 |
+
protected function _insertFooter(&$page)
|
753 |
+
{
|
754 |
+
$page->setLineColor($this->colors['black']);
|
755 |
+
$page->setLineWidth(0.5);
|
756 |
+
$page->drawLine($this->margin['left'] - 20, $this->y - 5, $this->margin['right'] + 30, $this->y - 5);
|
757 |
+
|
758 |
+
$this->Ln(15);
|
759 |
+
$this->_insertFooterAddress($page);
|
760 |
+
|
761 |
+
$fields = array(
|
762 |
+
'telephone' => Mage::helper('firegento_pdf')->__('Telephone:'),
|
763 |
+
'fax' => Mage::helper('firegento_pdf')->__('Fax:'),
|
764 |
+
'email' => Mage::helper('firegento_pdf')->__('E-Mail:'),
|
765 |
+
'web' => Mage::helper('firegento_pdf')->__('Web:')
|
766 |
+
);
|
767 |
+
$this->_insertFooterBlock($page, $fields, 70, 40, 140);
|
768 |
+
|
769 |
+
$fields = array(
|
770 |
+
'bank_name' => Mage::helper('firegento_pdf')->__('Bank name:'),
|
771 |
+
'bank_account' => Mage::helper('firegento_pdf')->__('Account:'),
|
772 |
+
'bank_code_number' => Mage::helper('firegento_pdf')->__('Bank number:'),
|
773 |
+
'bank_account_owner' => Mage::helper('firegento_pdf')->__('Account owner:'),
|
774 |
+
'swift' => Mage::helper('firegento_pdf')->__('SWIFT:'),
|
775 |
+
'iban' => Mage::helper('firegento_pdf')->__('IBAN:')
|
776 |
+
);
|
777 |
+
$this->_insertFooterBlock($page, $fields, 215, 50, 140);
|
778 |
+
|
779 |
+
$fields = array(
|
780 |
+
'tax_number' => Mage::helper('firegento_pdf')->__('Tax number:'),
|
781 |
+
'vat_id' => Mage::helper('firegento_pdf')->__('VAT-ID:'),
|
782 |
+
'register_number' => Mage::helper('firegento_pdf')->__('Register number:'),
|
783 |
+
'ceo' => Mage::helper('firegento_pdf')->__('CEO:')
|
784 |
+
);
|
785 |
+
$this->_insertFooterBlock($page, $fields, 355, 60, $this->margin['right'] - 355 - 10);
|
786 |
+
}
|
787 |
+
|
788 |
+
/**
|
789 |
+
* Insert footer block
|
790 |
+
*
|
791 |
+
* @param Zend_Pdf_Page $page Current page object of Zend_Pdf
|
792 |
+
* @param array $fields Fields of footer
|
793 |
+
* @param int $colposition Starting colposition
|
794 |
+
* @param int $valadjust Margin between label and value
|
795 |
+
* @param int $colwidth the width of this footer block - text will be wrapped if it is broader than this width
|
796 |
+
* @return void
|
797 |
+
*/
|
798 |
+
protected function _insertFooterBlock(&$page, $fields, $colposition = 0, $valadjust = 30, $colwidth = null)
|
799 |
+
{
|
800 |
+
$fontSize = 7;
|
801 |
+
$font = $this->_setFontRegular($page, $fontSize);
|
802 |
+
$y = $this->y;
|
803 |
+
|
804 |
+
$valposition = $colposition + $valadjust;
|
805 |
+
|
806 |
+
if (is_array($fields)) {
|
807 |
+
foreach ($fields as $field => $label) {
|
808 |
+
if (empty($this->imprint[$field])) {
|
809 |
+
continue;
|
810 |
+
}
|
811 |
+
// draw the label
|
812 |
+
$page->drawText($label, $this->margin['left'] + $colposition, $y, $this->encoding);
|
813 |
+
// prepare the value: wrap it if necessary
|
814 |
+
$val = $this->imprint[$field];
|
815 |
+
$width = $colwidth;
|
816 |
+
if (!empty($colwidth)) {
|
817 |
+
// calculate the maximum width for the value
|
818 |
+
$width = $this->margin['left'] + $colposition + $colwidth - ($this->margin['left'] + $valposition);
|
819 |
+
}
|
820 |
+
$tmpVal = $this->_prepareText($val, $page, $font, $fontSize, $width);
|
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 |
+
}
|
826 |
+
}
|
827 |
+
}
|
828 |
+
}
|
829 |
+
|
830 |
+
/**
|
831 |
+
* Insert addess of store owner
|
832 |
+
*
|
833 |
+
* @param Zend_Pdf_Page $page Current page object of Zend_Pdf
|
834 |
+
* @param mixed $store
|
835 |
+
* @return void
|
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 |
+
}
|
856 |
+
}
|
857 |
+
}
|
858 |
+
|
859 |
+
/**
|
860 |
+
* Insert page counter
|
861 |
+
*
|
862 |
+
* @param Zend_Pdf_Page $page Current page object of Zend_Pdf
|
863 |
+
* @return void
|
864 |
+
*/
|
865 |
+
protected function _insertPageCounter(&$page)
|
866 |
+
{
|
867 |
+
$font = $this->_setFontRegular($page, 9);
|
868 |
+
$page->drawText(Mage::helper('firegento_pdf')->__('Page').' '.$this->pagecounter, $this->margin['right'] - 23 - $this->widthForStringUsingFontSize($this->pagecounter, $font, 9), $this->y, $this->encoding);
|
869 |
+
}
|
870 |
+
|
871 |
+
/**
|
872 |
+
* Set default font
|
873 |
+
*
|
874 |
+
* @param Zend_Pdf_Page $object Current page object of Zend_Pdf
|
875 |
+
* @param string|int $size Font size
|
876 |
+
* @return Zend_Pdf_Resource_Font
|
877 |
+
*/
|
878 |
+
protected function _setFontRegular($object, $size = 10)
|
879 |
+
{
|
880 |
+
$font = Zend_Pdf_Font::fontWithName(Zend_Pdf_Font::FONT_HELVETICA);
|
881 |
+
$object->setFont($font, $size);
|
882 |
+
return $font;
|
883 |
+
}
|
884 |
+
|
885 |
+
/**
|
886 |
+
* Set bold font
|
887 |
+
*
|
888 |
+
* @param Zend_Pdf_Page $object Current page object of Zend_Pdf
|
889 |
+
* @param string|int $size Font size
|
890 |
+
* @return Zend_Pdf_Resource_Font
|
891 |
+
*/
|
892 |
+
protected function _setFontBold($object, $size = 10)
|
893 |
+
{
|
894 |
+
$font = Zend_Pdf_Font::fontWithName(Zend_Pdf_Font::FONT_HELVETICA_BOLD);
|
895 |
+
$object->setFont($font, $size);
|
896 |
+
return $font;
|
897 |
+
}
|
898 |
+
|
899 |
+
/**
|
900 |
+
* Set italic font
|
901 |
+
*
|
902 |
+
* @param Zend_Pdf_Page $object Current page object of Zend_Pdf
|
903 |
+
* @param string|int $size Font size
|
904 |
+
* @return Zend_Pdf_Resource_Font
|
905 |
+
*/
|
906 |
+
protected function _setFontItalic($object, $size = 10)
|
907 |
+
{
|
908 |
+
$font = Zend_Pdf_Font::fontWithName(Zend_Pdf_Font::FONT_HELVETICA_ITALIC);
|
909 |
+
$object->setFont($font, $size);
|
910 |
+
return $font;
|
911 |
+
}
|
912 |
+
|
913 |
+
/**
|
914 |
+
* Prepares the text so that it fits to the given page's width.
|
915 |
+
*
|
916 |
+
* @param $text the text which should be prepared
|
917 |
+
* @param $page the page on which the text will be rendered
|
918 |
+
* @param $font the font with which the text will be rendered
|
919 |
+
* @param $fontSize the font size with which the text will be rendered
|
920 |
+
* @param $width [optional] the width for the given text, defaults to the page width
|
921 |
+
*
|
922 |
+
* @return string the given text wrapped by new line characters
|
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
|
929 |
+
if (empty($width)) {
|
930 |
+
$width = $page->getWidth() - $this->margin['left'] - ($page->getWidth() - $this->margin['right']);
|
931 |
+
}
|
932 |
+
$textChunks = explode(' ', $text);
|
933 |
+
foreach ($textChunks as $textChunk) {
|
934 |
+
if ($this->widthForStringUsingFontSize($currentLine . ' ' . $textChunk, $font, $fontSize) < $width) {
|
935 |
+
// do not add whitespace on first line
|
936 |
+
if (!empty($currentLine)) {
|
937 |
+
$currentLine .= ' ';
|
938 |
+
}
|
939 |
+
$currentLine .= $textChunk;
|
940 |
+
} else {
|
941 |
+
// text is too broad, so add new line character
|
942 |
+
$lines .= $currentLine . "\n";
|
943 |
+
$currentLine = $textChunk;
|
944 |
+
}
|
945 |
+
}
|
946 |
+
// append the last line
|
947 |
+
$lines .= $currentLine;
|
948 |
+
return $lines;
|
949 |
+
}
|
950 |
+
|
951 |
+
}
|
952 |
+
|
app/code/community/FireGento/Pdf/Model/Creditmemo.php
ADDED
@@ -0,0 +1,186 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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_Creditmemo extends FireGento_Pdf_Model_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 |
+
}
|
186 |
+
|
app/code/community/FireGento/Pdf/Model/Engine/Invoice/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 |
+
* Default invoice rendering engine.
|
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_Invoice_Default extends FireGento_Pdf_Model_Abstract
|
35 |
+
{
|
36 |
+
|
37 |
+
public function __construct()
|
38 |
+
{
|
39 |
+
parent::__construct();
|
40 |
+
$this->setMode('invoice');
|
41 |
+
}
|
42 |
+
|
43 |
+
/**
|
44 |
+
* Return PDF document
|
45 |
+
*
|
46 |
+
* @param array $invoices
|
47 |
+
* @return Zend_Pdf
|
48 |
+
*/
|
49 |
+
public function getPdf($invoices = array())
|
50 |
+
{
|
51 |
+
$this->_beforeGetPdf();
|
52 |
+
$this->_initRenderer('invoice');
|
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 ($invoices as $invoice) {
|
64 |
+
if ($invoice->getStoreId()) {
|
65 |
+
Mage::app()->getLocale()->emulate($invoice->getStoreId());
|
66 |
+
Mage::app()->setCurrentStore($invoice->getStoreId());
|
67 |
+
}
|
68 |
+
$page = $this->newPage();
|
69 |
+
|
70 |
+
$order = $invoice->getOrder();
|
71 |
+
|
72 |
+
/* add logo */
|
73 |
+
$this->insertLogo($page, $invoice->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 header */
|
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 |
+
|
99 |
+
foreach ($invoice->getAllItems() as $item) {
|
100 |
+
if ($item->getOrderItem()->getParentItem()) {
|
101 |
+
continue;
|
102 |
+
}
|
103 |
+
|
104 |
+
if ($this->y < 100) {
|
105 |
+
$page = $this->newPage(array());
|
106 |
+
}
|
107 |
+
|
108 |
+
$position++;
|
109 |
+
$page = $this->_drawItem($item, $page, $order, $position);
|
110 |
+
}
|
111 |
+
|
112 |
+
/* add line after items */
|
113 |
+
$page->drawLine($this->margin['left'], $this->y + 5, $this->margin['right'], $this->y + 5);
|
114 |
+
|
115 |
+
/* add totals */
|
116 |
+
$page = $this->insertTotals($page, $invoice);
|
117 |
+
|
118 |
+
/* add note */
|
119 |
+
$this->_insertNote($page, $order, $invoice);
|
120 |
+
}
|
121 |
+
|
122 |
+
$this->_afterGetPdf();
|
123 |
+
|
124 |
+
return $pdf;
|
125 |
+
}
|
126 |
+
|
127 |
+
/**
|
128 |
+
* Insert Table Header for Items
|
129 |
+
*
|
130 |
+
* @param Zend_Pdf_Page $page Current Page Object of Zend_PDF
|
131 |
+
*
|
132 |
+
* @return void
|
133 |
+
*/
|
134 |
+
protected function insertTableHeader(&$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/Invoice.php
ADDED
@@ -0,0 +1,103 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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 |
+
class FireGento_Pdf_Model_Invoice
|
38 |
+
{
|
39 |
+
|
40 |
+
/**
|
41 |
+
* The actual PDF engine responsible for rendering the file.
|
42 |
+
* @var Mage_Sales_Model_Order_Pdf_Abstract
|
43 |
+
*/
|
44 |
+
private $_engine;
|
45 |
+
|
46 |
+
protected function getEngine()
|
47 |
+
{
|
48 |
+
if (!$this->_engine) {
|
49 |
+
$modelClass = Mage::getStoreConfig('sales_pdf/firegento_pdf/engine');
|
50 |
+
$engine = Mage::getModel($modelClass);
|
51 |
+
|
52 |
+
if (!$engine) {
|
53 |
+
// Fallback to Magento standard invoice layout.
|
54 |
+
$engine = new Mage_Sales_Model_Order_Pdf_Invoice();
|
55 |
+
}
|
56 |
+
|
57 |
+
$this->_engine = $engine;
|
58 |
+
}
|
59 |
+
|
60 |
+
return $this->_engine;
|
61 |
+
}
|
62 |
+
|
63 |
+
public function getPdf($invoices = array())
|
64 |
+
{
|
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 |
+
}
|
app/code/community/FireGento/Pdf/Model/Items/Bundle.php
ADDED
@@ -0,0 +1,209 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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 |
+
* Bundle item 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_Items_Bundle extends Mage_Bundle_Model_Sales_Order_Pdf_Items_Invoice
|
35 |
+
{
|
36 |
+
/**
|
37 |
+
* Draw item line.
|
38 |
+
*
|
39 |
+
* @param int $position
|
40 |
+
* @return void
|
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 |
+
|
49 |
+
$fontSize = 9;
|
50 |
+
|
51 |
+
$this->_setFontRegular();
|
52 |
+
$items = $this->getChilds($item);
|
53 |
+
|
54 |
+
$_prevOptionId = '';
|
55 |
+
$drawItems = array();
|
56 |
+
|
57 |
+
foreach ($items as $_item) {
|
58 |
+
$line = array();
|
59 |
+
|
60 |
+
$attributes = $this->getSelectionAttributes($_item);
|
61 |
+
if (is_array($attributes)) {
|
62 |
+
$optionId = $attributes['option_id'];
|
63 |
+
}
|
64 |
+
else {
|
65 |
+
$optionId = 0;
|
66 |
+
}
|
67 |
+
|
68 |
+
if (!isset($drawItems[$optionId])) {
|
69 |
+
$drawItems[$optionId] = array(
|
70 |
+
'lines' => array(),
|
71 |
+
'height' => 15
|
72 |
+
);
|
73 |
+
}
|
74 |
+
|
75 |
+
if ($_item->getOrderItem()->getParentItem()) {
|
76 |
+
if ($_prevOptionId != $attributes['option_id']) {
|
77 |
+
$line[0] = array(
|
78 |
+
'font' => 'italic',
|
79 |
+
'text' => Mage::helper('core/string')->str_split($attributes['option_label'], 45, true, true),
|
80 |
+
'feed' => $pdf->margin['left'] + 120,
|
81 |
+
'font_size' => $fontSize
|
82 |
+
);
|
83 |
+
|
84 |
+
$drawItems[$optionId] = array(
|
85 |
+
'lines' => array($line),
|
86 |
+
'height' => 15
|
87 |
+
);
|
88 |
+
|
89 |
+
$line = array();
|
90 |
+
|
91 |
+
$_prevOptionId = $attributes['option_id'];
|
92 |
+
}
|
93 |
+
}
|
94 |
+
|
95 |
+
// draw SKUs
|
96 |
+
if (!$_item->getOrderItem()->getParentItem()) {
|
97 |
+
$text = array();
|
98 |
+
foreach (Mage::helper('core/string')->str_split($item->getSku(), 17) as $part) {
|
99 |
+
$text[] = $part;
|
100 |
+
}
|
101 |
+
|
102 |
+
// draw Position Number
|
103 |
+
$line[]= array(
|
104 |
+
'text' => $position,
|
105 |
+
'feed' => $pdf->margin['left'] + 10,
|
106 |
+
'align' => 'right',
|
107 |
+
'font_size' => $fontSize
|
108 |
+
);
|
109 |
+
|
110 |
+
$line[] = array(
|
111 |
+
'text' => $text,
|
112 |
+
'feed' => $pdf->margin['left'] + 25,
|
113 |
+
'font_size' => $fontSize
|
114 |
+
);
|
115 |
+
}
|
116 |
+
|
117 |
+
/* in case Product name is longer than 80 chars - it is written in a few lines */
|
118 |
+
if ($_item->getOrderItem()->getParentItem()) {
|
119 |
+
$feed = 40;
|
120 |
+
$name = $this->getValueHtml($_item);
|
121 |
+
} else {
|
122 |
+
$feed = 35;
|
123 |
+
$name = $_item->getName();
|
124 |
+
}
|
125 |
+
$line[] = array(
|
126 |
+
'text' => Mage::helper('core/string')->str_split($name, 35, true, true),
|
127 |
+
'feed' => $pdf->margin['left'] + 120,
|
128 |
+
'font_size' => $fontSize
|
129 |
+
);
|
130 |
+
|
131 |
+
// draw prices
|
132 |
+
if ($this->canShowPriceInfo($_item)) {
|
133 |
+
$price = $order->formatPriceTxt($_item->getPrice());
|
134 |
+
$line[] = array(
|
135 |
+
'text' => $price,
|
136 |
+
'feed' => $pdf->margin['right'] - 160,
|
137 |
+
'align' => 'right',
|
138 |
+
'font_size' => $fontSize
|
139 |
+
);
|
140 |
+
$line[] = array(
|
141 |
+
'text' => $_item->getQty()*1,
|
142 |
+
'feed' => $pdf->margin['right'] - 120,
|
143 |
+
'align' => 'right',
|
144 |
+
'font_size' => $fontSize
|
145 |
+
);
|
146 |
+
|
147 |
+
$tax = $order->formatPriceTxt($_item->getTaxAmount());
|
148 |
+
$line[] = array(
|
149 |
+
'text' => $tax,
|
150 |
+
'feed' => $pdf->margin['right'] - 60,
|
151 |
+
'align' => 'right',
|
152 |
+
'font_size' => $fontSize
|
153 |
+
);
|
154 |
+
|
155 |
+
$row_total = $order->formatPriceTxt($_item->getRowTotal());
|
156 |
+
$line[] = array(
|
157 |
+
'text' => $row_total,
|
158 |
+
'feed' => $pdf->margin['right'] - 10,
|
159 |
+
'align' => 'right',
|
160 |
+
'font_size' => $fontSize
|
161 |
+
);
|
162 |
+
}
|
163 |
+
|
164 |
+
$drawItems[$optionId]['lines'][] = $line;
|
165 |
+
}
|
166 |
+
|
167 |
+
// custom options
|
168 |
+
$options = $item->getOrderItem()->getProductOptions();
|
169 |
+
if ($options) {
|
170 |
+
if (isset($options['options'])) {
|
171 |
+
foreach ($options['options'] as $option) {
|
172 |
+
$lines = array();
|
173 |
+
$lines[][] = array(
|
174 |
+
'text' => Mage::helper('core/string')->str_split(strip_tags($option['label']), 40, true, true),
|
175 |
+
'font' => 'italic',
|
176 |
+
'feed' => 35
|
177 |
+
);
|
178 |
+
|
179 |
+
if ($option['value']) {
|
180 |
+
$text = array();
|
181 |
+
$_printValue = isset($option['print_value'])
|
182 |
+
? $option['print_value']
|
183 |
+
: strip_tags($option['value']);
|
184 |
+
$values = explode(', ', $_printValue);
|
185 |
+
foreach ($values as $value) {
|
186 |
+
foreach (Mage::helper('core/string')->str_split($value, 30, true, true) as $_value) {
|
187 |
+
$text[] = $_value;
|
188 |
+
}
|
189 |
+
}
|
190 |
+
|
191 |
+
$lines[][] = array(
|
192 |
+
'text' => $text,
|
193 |
+
'feed' => 40
|
194 |
+
);
|
195 |
+
}
|
196 |
+
|
197 |
+
$drawItems[] = array(
|
198 |
+
'lines' => $lines,
|
199 |
+
'height' => 15
|
200 |
+
);
|
201 |
+
}
|
202 |
+
}
|
203 |
+
}
|
204 |
+
|
205 |
+
$page = $pdf->drawLineBlocks($page, $drawItems, array('table_header' => true));
|
206 |
+
|
207 |
+
$this->setPage($page);
|
208 |
+
}
|
209 |
+
}
|
app/code/community/FireGento/Pdf/Model/Items/Default.php
ADDED
@@ -0,0 +1,138 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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 |
+
* Default item 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_Items_Default extends Mage_Sales_Model_Order_Pdf_Items_Invoice_Default
|
35 |
+
{
|
36 |
+
/**
|
37 |
+
* Draw item line.
|
38 |
+
*
|
39 |
+
* @param int $position
|
40 |
+
* @return void
|
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 |
+
// 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) {
|
85 |
+
// draw options label
|
86 |
+
$lines[][] = array(
|
87 |
+
'text' => Mage::helper('core/string')->str_split(strip_tags($option['label']), 40, false, true),
|
88 |
+
'font' => 'bold',
|
89 |
+
'feed' => $pdf->margin['left'] + 120
|
90 |
+
);
|
91 |
+
|
92 |
+
// draw options value
|
93 |
+
if ($option['value']) {
|
94 |
+
$_printValue = isset($option['print_value']) ? $option['print_value'] : strip_tags($option['value']);
|
95 |
+
$values = explode(', ', $_printValue);
|
96 |
+
foreach ($values as $value) {
|
97 |
+
$lines[][] = array(
|
98 |
+
'text' => Mage::helper('core/string')->str_split($value, 60, true, true),
|
99 |
+
'feed' => $pdf->margin['left'] + 120
|
100 |
+
);
|
101 |
+
}
|
102 |
+
}
|
103 |
+
}
|
104 |
+
}
|
105 |
+
|
106 |
+
// draw Price
|
107 |
+
$lines[0][] = array(
|
108 |
+
'text' => $order->formatPriceTxt($item->getPrice()),
|
109 |
+
'feed' => $pdf->margin['right'] - 160,
|
110 |
+
'align' => 'right',
|
111 |
+
'font_size' => $fontSize
|
112 |
+
);
|
113 |
+
|
114 |
+
// draw Tax
|
115 |
+
$lines[0][] = array(
|
116 |
+
'text' => $order->formatPriceTxt($item->getTaxAmount()),
|
117 |
+
'feed' => $pdf->margin['right'] - 60,
|
118 |
+
'align' => 'right',
|
119 |
+
'font_size' => $fontSize
|
120 |
+
);
|
121 |
+
|
122 |
+
// draw Subtotal
|
123 |
+
$lines[0][] = array(
|
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' => $lines,
|
132 |
+
'height' => 15
|
133 |
+
);
|
134 |
+
|
135 |
+
$page = $pdf->drawLineBlocks($page, array($lineBlock), array('table_header' => true));
|
136 |
+
$this->setPage($page);
|
137 |
+
}
|
138 |
+
}
|
app/code/community/FireGento/Pdf/Model/Items/Grouped.php
ADDED
@@ -0,0 +1,50 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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 |
+
* Default item model rewrite.
|
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 |
+
*/
|
30 |
+
class FireGento_Pdf_Model_Items_Grouped extends Mage_Sales_Model_Order_Pdf_Items_Invoice_Grouped
|
31 |
+
{
|
32 |
+
/**
|
33 |
+
* Draw item line.
|
34 |
+
*
|
35 |
+
* @param int $position
|
36 |
+
* @return void
|
37 |
+
*/
|
38 |
+
public function draw($position = 1)
|
39 |
+
{
|
40 |
+
$type = $this->getItem()->getOrderItem()->getRealProductType();
|
41 |
+
$renderer = $this->getRenderedModel()->getRenderer($type);
|
42 |
+
$renderer->setOrder($this->getOrder());
|
43 |
+
$renderer->setItem($this->getItem());
|
44 |
+
$renderer->setPdf($this->getPdf());
|
45 |
+
$renderer->setPage($this->getPage());
|
46 |
+
|
47 |
+
$renderer->draw($position);
|
48 |
+
$this->setPage($renderer->getPage());
|
49 |
+
}
|
50 |
+
}
|
app/code/community/FireGento/Pdf/Model/Items/Shipment/Bundle.php
ADDED
@@ -0,0 +1,187 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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_Items_Shipment_Bundle extends Mage_Bundle_Model_Sales_Order_Pdf_Items_Shipment
|
33 |
+
{
|
34 |
+
/**
|
35 |
+
* Draw item line.
|
36 |
+
*
|
37 |
+
* @return void
|
38 |
+
*/
|
39 |
+
public function draw()
|
40 |
+
{
|
41 |
+
$item = $this->getItem();
|
42 |
+
$pdf = $this->getPdf();
|
43 |
+
$page = $this->getPage();
|
44 |
+
|
45 |
+
$this->_setFontRegular();
|
46 |
+
|
47 |
+
$shipItems = $this->getChilds($item);
|
48 |
+
$items = array_merge(array($item->getOrderItem()), $item->getOrderItem()->getChildrenItems());
|
49 |
+
|
50 |
+
$_prevOptionId = '';
|
51 |
+
$drawItems = array();
|
52 |
+
|
53 |
+
foreach ($items as $_item) {
|
54 |
+
$line = array();
|
55 |
+
|
56 |
+
$attributes = $this->getSelectionAttributes($_item);
|
57 |
+
if (is_array($attributes)) {
|
58 |
+
$optionId = $attributes['option_id'];
|
59 |
+
}
|
60 |
+
else {
|
61 |
+
$optionId = 0;
|
62 |
+
}
|
63 |
+
|
64 |
+
if (!isset($drawItems[$optionId])) {
|
65 |
+
$drawItems[$optionId] = array(
|
66 |
+
'lines' => array(),
|
67 |
+
'height' => 15
|
68 |
+
);
|
69 |
+
}
|
70 |
+
|
71 |
+
if ($_item->getParentItem()) {
|
72 |
+
if ($_prevOptionId != $attributes['option_id']) {
|
73 |
+
$line[0] = array(
|
74 |
+
'font' => 'italic',
|
75 |
+
'text' => Mage::helper('core/string')->str_split($attributes['option_label'], 60, true, true),
|
76 |
+
'feed' => 150
|
77 |
+
);
|
78 |
+
|
79 |
+
$drawItems[$optionId] = array(
|
80 |
+
'lines' => array($line),
|
81 |
+
'height' => 15
|
82 |
+
);
|
83 |
+
|
84 |
+
$line = array();
|
85 |
+
|
86 |
+
$_prevOptionId = $attributes['option_id'];
|
87 |
+
}
|
88 |
+
}
|
89 |
+
|
90 |
+
// draw SKUs
|
91 |
+
if (!$_item->getParentItem()) {
|
92 |
+
$text = array();
|
93 |
+
foreach (Mage::helper('core/string')->str_split($_item->getSku(), 20) as $part) {
|
94 |
+
$text[] = $part;
|
95 |
+
}
|
96 |
+
$line[] = array(
|
97 |
+
'text' => $text,
|
98 |
+
'feed' => 45,
|
99 |
+
'width' => 85
|
100 |
+
);
|
101 |
+
}
|
102 |
+
|
103 |
+
// draw Name
|
104 |
+
if ($_item->getParentItem()) {
|
105 |
+
#$feed = 155;
|
106 |
+
$name = $this->getValueHtml($_item);
|
107 |
+
} else {
|
108 |
+
#$feed = 150;
|
109 |
+
$name = $_item->getName();
|
110 |
+
}
|
111 |
+
$text = array();
|
112 |
+
foreach (Mage::helper('core/string')->str_split($name, 60, true, true) as $part) {
|
113 |
+
$text[] = $part;
|
114 |
+
}
|
115 |
+
$line[] = array(
|
116 |
+
'text' => $text,
|
117 |
+
'feed' => 150,
|
118 |
+
'align' => 'left',
|
119 |
+
'width' => 375
|
120 |
+
);
|
121 |
+
|
122 |
+
if (($this->isShipmentSeparately() && $_item->getParentItem())
|
123 |
+
|| (!$this->isShipmentSeparately() && !$_item->getParentItem())
|
124 |
+
) {
|
125 |
+
if (isset($shipItems[$_item->getId()])) {
|
126 |
+
$qty = $shipItems[$_item->getId()]->getQty()*1;
|
127 |
+
} else if ($_item->getIsVirtual()) {
|
128 |
+
$qty = Mage::helper('bundle')->__('N/A');
|
129 |
+
} else {
|
130 |
+
$qty = 0;
|
131 |
+
}
|
132 |
+
} else {
|
133 |
+
$qty = '';
|
134 |
+
}
|
135 |
+
|
136 |
+
$line[] = array(
|
137 |
+
'text' => $qty,
|
138 |
+
'feed' => 505,
|
139 |
+
'align' => 'left',
|
140 |
+
'width' => 10
|
141 |
+
);
|
142 |
+
|
143 |
+
$drawItems[$optionId]['lines'][] = $line;
|
144 |
+
}
|
145 |
+
|
146 |
+
// custom options
|
147 |
+
$options = $item->getOrderItem()->getProductOptions();
|
148 |
+
if ($options) {
|
149 |
+
if (isset($options['options'])) {
|
150 |
+
foreach ($options['options'] as $option) {
|
151 |
+
$lines = array();
|
152 |
+
$lines[][] = array(
|
153 |
+
'text' => Mage::helper('core/string')->str_split(strip_tags($option['label']), 70, true, true),
|
154 |
+
'font' => 'italic',
|
155 |
+
'feed' => 60
|
156 |
+
);
|
157 |
+
|
158 |
+
if ($option['value']) {
|
159 |
+
$text = array();
|
160 |
+
$_printValue = isset($option['print_value'])
|
161 |
+
? $option['print_value']
|
162 |
+
: strip_tags($option['value']);
|
163 |
+
$values = explode(', ', $_printValue);
|
164 |
+
foreach ($values as $value) {
|
165 |
+
foreach (Mage::helper('core/string')->str_split($value, 50, true, true) as $_value) {
|
166 |
+
$text[] = $_value;
|
167 |
+
}
|
168 |
+
}
|
169 |
+
|
170 |
+
$lines[][] = array(
|
171 |
+
'text' => $text,
|
172 |
+
'feed' => 65
|
173 |
+
);
|
174 |
+
}
|
175 |
+
|
176 |
+
$drawItems[] = array(
|
177 |
+
'lines' => $lines,
|
178 |
+
'height' => 15
|
179 |
+
);
|
180 |
+
}
|
181 |
+
}
|
182 |
+
}
|
183 |
+
|
184 |
+
$page = $pdf->drawLineBlocks($page, $drawItems, array('table_header' => true));
|
185 |
+
$this->setPage($page);
|
186 |
+
}
|
187 |
+
}
|
app/code/community/FireGento/Pdf/Model/Items/Shipment/Default.php
ADDED
@@ -0,0 +1,108 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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 default item 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_Items_Shipment_Default extends Mage_Sales_Model_Order_Pdf_Items_Shipment_Default
|
35 |
+
{
|
36 |
+
/**
|
37 |
+
* Draw item line.
|
38 |
+
*
|
39 |
+
* @return void
|
40 |
+
*/
|
41 |
+
public function draw()
|
42 |
+
{
|
43 |
+
$item = $this->getItem();
|
44 |
+
$pdf = $this->getPdf();
|
45 |
+
$page = $this->getPage();
|
46 |
+
$lines = array();
|
47 |
+
|
48 |
+
$fontSize = 9;
|
49 |
+
|
50 |
+
// draw SKU
|
51 |
+
$lines[0] = array(array(
|
52 |
+
'text' => Mage::helper('core/string')->str_split($this->getSku($item), 20),
|
53 |
+
'feed' => 45,
|
54 |
+
'width' => 85,
|
55 |
+
'font_size' => $fontSize
|
56 |
+
));
|
57 |
+
|
58 |
+
// draw Product name
|
59 |
+
$lines[0][] = array(
|
60 |
+
'text' => Mage::helper('core/string')->str_split($item->getName(), 70, true, true),
|
61 |
+
'feed' => 150,
|
62 |
+
'align' => 'left',
|
63 |
+
'width' => 375,
|
64 |
+
'font_size' => $fontSize
|
65 |
+
);
|
66 |
+
|
67 |
+
// draw QTY
|
68 |
+
$lines[0][] = array(
|
69 |
+
'text' => $item->getQty()*1,
|
70 |
+
'feed' => 505,
|
71 |
+
'align' => 'left',
|
72 |
+
'width' => 10,
|
73 |
+
'font_size' => $fontSize
|
74 |
+
);
|
75 |
+
|
76 |
+
$options = $this->getItemOptions();
|
77 |
+
if ($options) {
|
78 |
+
foreach ($options as $option) {
|
79 |
+
// draw options label
|
80 |
+
$lines[][] = array(
|
81 |
+
'text' => Mage::helper('core/string')->str_split(strip_tags($option['label']), 40, false, true),
|
82 |
+
'font' => 'bold',
|
83 |
+
'feed' => $pdf->margin['left'] + 120
|
84 |
+
);
|
85 |
+
|
86 |
+
// draw options value
|
87 |
+
if ($option['value']) {
|
88 |
+
$_printValue = isset($option['print_value']) ? $option['print_value'] : strip_tags($option['value']);
|
89 |
+
$values = explode(', ', $_printValue);
|
90 |
+
foreach ($values as $value) {
|
91 |
+
$lines[][] = array(
|
92 |
+
'text' => Mage::helper('core/string')->str_split($value, 60, true, true),
|
93 |
+
'feed' => $pdf->margin['left'] + 120
|
94 |
+
);
|
95 |
+
}
|
96 |
+
}
|
97 |
+
}
|
98 |
+
}
|
99 |
+
|
100 |
+
$lineBlock = array(
|
101 |
+
'lines' => $lines,
|
102 |
+
'height' => 15
|
103 |
+
);
|
104 |
+
|
105 |
+
$page = $pdf->drawLineBlocks($page, array($lineBlock), array('table_header' => true));
|
106 |
+
$this->setPage($page);
|
107 |
+
}
|
108 |
+
}
|
app/code/community/FireGento/Pdf/Model/Observer.php
ADDED
@@ -0,0 +1,110 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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 |
+
* FireGento Pdf observer.
|
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_Observer
|
35 |
+
{
|
36 |
+
/**
|
37 |
+
* Add notes to invoice document.
|
38 |
+
*
|
39 |
+
* @param Varien_Event_Observer $observer
|
40 |
+
* @return FireGento_Pdf_Model_Observer
|
41 |
+
*/
|
42 |
+
public function addInvoiceNotes(Varien_Event_Observer $observer)
|
43 |
+
{
|
44 |
+
$this->addInvoiceMaturity($observer);
|
45 |
+
$this->addPaymentMethod($observer);
|
46 |
+
$this->addShippingMethod($observer);
|
47 |
+
return $this;
|
48 |
+
}
|
49 |
+
|
50 |
+
/**
|
51 |
+
* Add maturity to invoice notes.
|
52 |
+
*
|
53 |
+
* @param Varien_Event_Observer $observer
|
54 |
+
* @return FireGento_Pdf_Model_Observer
|
55 |
+
*/
|
56 |
+
public function addInvoiceMaturity(Varien_Event_Observer $observer)
|
57 |
+
{
|
58 |
+
$result = $observer->getResult();
|
59 |
+
$notes = $result->getNotes();
|
60 |
+
|
61 |
+
$maturity = Mage::getStoreConfig('sales_pdf/invoice/maturity');
|
62 |
+
if (!empty($maturity) || 0 < $maturity) {
|
63 |
+
$maturity = Mage::helper('firegento_pdf')->__('Invoice maturity: %s days', Mage::getStoreConfig('sales_pdf/invoice/maturity'));
|
64 |
+
} elseif ('0' === $maturity) {
|
65 |
+
$maturity = Mage::helper('firegento_pdf')->__('Invoice is payable immediately');
|
66 |
+
}
|
67 |
+
|
68 |
+
$notes[] = $maturity;
|
69 |
+
$result->setNotes($notes);
|
70 |
+
return $this;
|
71 |
+
}
|
72 |
+
|
73 |
+
/**
|
74 |
+
* Add payment method to invoice notes.
|
75 |
+
*
|
76 |
+
* @param Varien_Event_Observer $observer
|
77 |
+
* @return FireGento_Pdf_Model_Observer
|
78 |
+
*/
|
79 |
+
public function addPaymentMethod(Varien_Event_Observer $observer)
|
80 |
+
{
|
81 |
+
if (Mage::getStoreConfig('sales_pdf/invoice/payment_method_position') != FireGento_Pdf_Model_System_Config_Source_Payment::POSITION_NOTE) {
|
82 |
+
return $this;
|
83 |
+
}
|
84 |
+
|
85 |
+
$result = $observer->getResult();
|
86 |
+
$notes = $result->getNotes();
|
87 |
+
$notes[] = Mage::helper('firegento_pdf')->__('Payment method: %s', $observer->getOrder()->getPayment()->getMethodInstance()->getTitle());
|
88 |
+
$result->setNotes($notes);
|
89 |
+
return $this;
|
90 |
+
}
|
91 |
+
|
92 |
+
/**
|
93 |
+
* Add shipping method to invoice notes.
|
94 |
+
*
|
95 |
+
* @param Varien_Event_Observer $observer
|
96 |
+
* @return FireGento_Pdf_Model_Observer
|
97 |
+
*/
|
98 |
+
public function addShippingMethod(Varien_Event_Observer $observer)
|
99 |
+
{
|
100 |
+
if (Mage::getStoreConfig('sales_pdf/invoice/shipping_method_position') != FireGento_Pdf_Model_System_Config_Source_Shipping::POSITION_NOTE) {
|
101 |
+
return $this;
|
102 |
+
}
|
103 |
+
|
104 |
+
$result = $observer->getResult();
|
105 |
+
$notes = $result->getNotes();
|
106 |
+
$notes[] = Mage::helper('firegento_pdf')->__('Shipping method: %s', $observer->getOrder()->getShippingDescription());
|
107 |
+
$result->setNotes($notes);
|
108 |
+
return $this;
|
109 |
+
}
|
110 |
+
}
|
app/code/community/FireGento/Pdf/Model/Shipment.php
ADDED
@@ -0,0 +1,171 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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_Shipment extends FireGento_Pdf_Model_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 < 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 |
+
}
|
171 |
+
|
app/code/community/FireGento/Pdf/Model/System/Config/Source/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_Engine
|
35 |
+
{
|
36 |
+
/**
|
37 |
+
* Config xpath to pdf engine node
|
38 |
+
*
|
39 |
+
*/
|
40 |
+
const XML_PATH_PDF_ENGINE = 'global/pdf/firegento_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_invoice_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/Logo.php
ADDED
@@ -0,0 +1,57 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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 |
+
* Logo position 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_Logo
|
35 |
+
{
|
36 |
+
/**
|
37 |
+
* Return array of possible positions.
|
38 |
+
*
|
39 |
+
* @return array
|
40 |
+
*/
|
41 |
+
public function toOptionArray()
|
42 |
+
{
|
43 |
+
$positions = array(
|
44 |
+
'left' => Mage::helper('firegento_pdf')->__('Left'),
|
45 |
+
'center' => Mage::helper('firegento_pdf')->__('Center'),
|
46 |
+
'right' => Mage::helper('firegento_pdf')->__('Right'),
|
47 |
+
);
|
48 |
+
$options = array();
|
49 |
+
foreach ($positions as $k => $v) {
|
50 |
+
$options[] = array(
|
51 |
+
'value' => $k,
|
52 |
+
'label' => $v
|
53 |
+
);
|
54 |
+
}
|
55 |
+
return $options;
|
56 |
+
}
|
57 |
+
}
|
app/code/community/FireGento/Pdf/Model/System/Config/Source/Payment.php
ADDED
@@ -0,0 +1,60 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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 |
+
* Payment method position 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_Payment
|
35 |
+
{
|
36 |
+
const POSITION_HEADER = 'header';
|
37 |
+
const POSITION_NOTE = 'note';
|
38 |
+
|
39 |
+
/**
|
40 |
+
* Return array of possible positions.
|
41 |
+
*
|
42 |
+
* @return array
|
43 |
+
*/
|
44 |
+
public function toOptionArray()
|
45 |
+
{
|
46 |
+
$positions = array(
|
47 |
+
'' => Mage::helper('firegento_pdf')->__('Hide payment method'),
|
48 |
+
self::POSITION_HEADER => Mage::helper('firegento_pdf')->__('Header'),
|
49 |
+
self::POSITION_NOTE => Mage::helper('firegento_pdf')->__('Notes area')
|
50 |
+
);
|
51 |
+
$options = array();
|
52 |
+
foreach ($positions as $k => $v) {
|
53 |
+
$options[] = array(
|
54 |
+
'value' => $k,
|
55 |
+
'label' => $v
|
56 |
+
);
|
57 |
+
}
|
58 |
+
return $options;
|
59 |
+
}
|
60 |
+
}
|
app/code/community/FireGento/Pdf/Model/System/Config/Source/Shipping.php
ADDED
@@ -0,0 +1,60 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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 |
+
* Shipping method position 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_Shipping
|
35 |
+
{
|
36 |
+
const POSITION_HEADER = 'header';
|
37 |
+
const POSITION_NOTE = 'note';
|
38 |
+
|
39 |
+
/**
|
40 |
+
* Return array of possible positions.
|
41 |
+
*
|
42 |
+
* @return array
|
43 |
+
*/
|
44 |
+
public function toOptionArray()
|
45 |
+
{
|
46 |
+
$positions = array(
|
47 |
+
'' => Mage::helper('firegento_pdf')->__('Hide shipping method'),
|
48 |
+
self::POSITION_HEADER => Mage::helper('firegento_pdf')->__('Header'),
|
49 |
+
self::POSITION_NOTE => Mage::helper('firegento_pdf')->__('Notes area')
|
50 |
+
);
|
51 |
+
$options = array();
|
52 |
+
foreach ($positions as $k => $v) {
|
53 |
+
$options[] = array(
|
54 |
+
'value' => $k,
|
55 |
+
'label' => $v
|
56 |
+
);
|
57 |
+
}
|
58 |
+
return $options;
|
59 |
+
}
|
60 |
+
}
|
app/code/community/FireGento/Pdf/controllers/Sales/OrderController.php
ADDED
@@ -0,0 +1,86 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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 |
+
* Sales orders controller
|
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 |
+
|
35 |
+
require_once 'Mage/Sales/controllers/OrderController.php';
|
36 |
+
|
37 |
+
class FireGento_Pdf_Sales_OrderController extends Mage_Sales_OrderController
|
38 |
+
{
|
39 |
+
/**
|
40 |
+
* Print PDF Invoice Action
|
41 |
+
*
|
42 |
+
* @return void
|
43 |
+
*/
|
44 |
+
public function printInvoiceAction()
|
45 |
+
{
|
46 |
+
$invoiceId = (int)$this->getRequest()->getParam('invoice_id');
|
47 |
+
if ($invoiceId) {
|
48 |
+
$invoice = Mage::getModel('sales/order_invoice')->load($invoiceId);
|
49 |
+
$order = $invoice->getOrder();
|
50 |
+
} else {
|
51 |
+
$orderId = (int)$this->getRequest()->getParam('order_id');
|
52 |
+
$order = Mage::getModel('sales/order')->load($orderId);
|
53 |
+
}
|
54 |
+
|
55 |
+
if ($this->_canViewOrder($order)) {
|
56 |
+
if (isset($orderId)) {
|
57 |
+
// Create a pdf file from all invoices of requested order.
|
58 |
+
$invoices = Mage::getResourceModel('sales/order_invoice_collection')
|
59 |
+
->addAttributeToSelect('*')
|
60 |
+
->addAttributeToFilter('order_id', $orderId)
|
61 |
+
->load();
|
62 |
+
} else {
|
63 |
+
// Create a single invoice pdf.
|
64 |
+
$invoices = array($invoice);
|
65 |
+
}
|
66 |
+
|
67 |
+
// Store current area and set to adminhtml for invoice generation.
|
68 |
+
$currentArea = Mage::getDesign()->getArea();
|
69 |
+
Mage::getDesign()->setArea('adminhtml');
|
70 |
+
|
71 |
+
$pdf = Mage::getModel('sales/order_pdf_invoice')->getPdf($invoices);
|
72 |
+
$this->_prepareDownloadResponse('invoice' . Mage::getSingleton('core/date')->date('Y-m-d_H-i-s') .
|
73 |
+
'.pdf', $pdf->render(), 'application/pdf');
|
74 |
+
|
75 |
+
// Restore area.
|
76 |
+
Mage::getDesign()->setArea($currentArea);
|
77 |
+
|
78 |
+
} else {
|
79 |
+
if (Mage::getSingleton('customer/session')->isLoggedIn()) {
|
80 |
+
$this->_redirect('*/*/history');
|
81 |
+
} else {
|
82 |
+
$this->_redirect('sales/guest/form');
|
83 |
+
}
|
84 |
+
}
|
85 |
+
}
|
86 |
+
}
|
app/code/community/FireGento/Pdf/etc/config.xml
ADDED
@@ -0,0 +1,76 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?xml version="1.0"?>
|
2 |
+
<config>
|
3 |
+
<modules>
|
4 |
+
<FireGento_Pdf>
|
5 |
+
<version>1.0.0</version>
|
6 |
+
</FireGento_Pdf>
|
7 |
+
</modules>
|
8 |
+
<global>
|
9 |
+
<helpers>
|
10 |
+
<firegento_pdf>
|
11 |
+
<class>FireGento_Pdf_Helper</class>
|
12 |
+
</firegento_pdf>
|
13 |
+
</helpers>
|
14 |
+
<models>
|
15 |
+
<firegento_pdf>
|
16 |
+
<class>FireGento_Pdf_Model</class>
|
17 |
+
</firegento_pdf>
|
18 |
+
<sales>
|
19 |
+
<rewrite>
|
20 |
+
<order_pdf_invoice>FireGento_Pdf_Model_Invoice</order_pdf_invoice>
|
21 |
+
<order_pdf_creditmemo>FireGento_Pdf_Model_Creditmemo</order_pdf_creditmemo>
|
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>
|
29 |
+
<firegento_pdf>
|
30 |
+
<class>firegento_pdf/observer</class>
|
31 |
+
<method>addInvoiceNotes</method>
|
32 |
+
</firegento_pdf>
|
33 |
+
</observers>
|
34 |
+
</firegento_pdf_invoice_insert_note>
|
35 |
+
</events>
|
36 |
+
<pdf>
|
37 |
+
<!-- fix totals order -->
|
38 |
+
<totals>
|
39 |
+
<tax>
|
40 |
+
<sort_order>650</sort_order>
|
41 |
+
</tax>
|
42 |
+
</totals>
|
43 |
+
</pdf>
|
44 |
+
</global>
|
45 |
+
<frontend>
|
46 |
+
<translate>
|
47 |
+
<modules>
|
48 |
+
<FireGento_Pdf>
|
49 |
+
<files>
|
50 |
+
<firegento_pdf>FireGento_Pdf.csv</firegento_pdf>
|
51 |
+
</files>
|
52 |
+
</FireGento_Pdf>
|
53 |
+
</modules>
|
54 |
+
</translate>
|
55 |
+
<routers>
|
56 |
+
<sales>
|
57 |
+
<args>
|
58 |
+
<modules>
|
59 |
+
<firegento_pdf before="Mage_Sales">FireGento_Pdf_Sales</firegento_pdf>
|
60 |
+
</modules>
|
61 |
+
</args>
|
62 |
+
</sales>
|
63 |
+
</routers>
|
64 |
+
</frontend>
|
65 |
+
<adminhtml>
|
66 |
+
<translate>
|
67 |
+
<modules>
|
68 |
+
<FireGento_Pdf>
|
69 |
+
<files>
|
70 |
+
<firegento_pdf>FireGento_Pdf.csv</firegento_pdf>
|
71 |
+
</files>
|
72 |
+
</FireGento_Pdf>
|
73 |
+
</modules>
|
74 |
+
</translate>
|
75 |
+
</adminhtml>
|
76 |
+
</config>
|
app/code/community/FireGento/Pdf/etc/system.xml
ADDED
@@ -0,0 +1,145 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?xml version="1.0"?>
|
2 |
+
<!--
|
3 |
+
/**
|
4 |
+
* This file is part of the FIREGENTO project.
|
5 |
+
*
|
6 |
+
* FireGento_GermanSetup is free software; you can redistribute it and/or
|
7 |
+
* modify it under the terms of the GNU General Public License version 3 as
|
8 |
+
* published by the Free Software Foundation.
|
9 |
+
*
|
10 |
+
* This script is distributed in the hope that it will be useful, but WITHOUT
|
11 |
+
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
|
12 |
+
* FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
|
13 |
+
*
|
14 |
+
* PHP version 5
|
15 |
+
*
|
16 |
+
* @category FireGento
|
17 |
+
* @package FireGento_Pdf
|
18 |
+
* @author FireGento Team <team@firegento.com>
|
19 |
+
* @copyright 2013 FireGento Team (http://www.firegento.de). All rights served.
|
20 |
+
* @license http://opensource.org/licenses/gpl-3.0 GNU General Public License, version 3 (GPLv3)
|
21 |
+
* @version $Id:$
|
22 |
+
* @since 0.1.0
|
23 |
+
*/
|
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>
|
34 |
+
<sort_order>3</sort_order>
|
35 |
+
<show_in_default>1</show_in_default>
|
36 |
+
<show_in_website>1</show_in_website>
|
37 |
+
<show_in_store>1</show_in_store>
|
38 |
+
<comment>Days after the invoice is due. Leave this field blank to hide the message on the invoice.</comment>
|
39 |
+
</maturity>
|
40 |
+
<payment_method_position translate="label comment">
|
41 |
+
<label>Show Payment Method</label>
|
42 |
+
<frontend_type>select</frontend_type>
|
43 |
+
<source_model>firegento_pdf/system_config_source_payment</source_model>
|
44 |
+
<sort_order>4</sort_order>
|
45 |
+
<show_in_default>1</show_in_default>
|
46 |
+
<show_in_website>1</show_in_website>
|
47 |
+
<show_in_store>1</show_in_store>
|
48 |
+
<comment>Position of payment method on invoice.</comment>
|
49 |
+
</payment_method_position>
|
50 |
+
<shipping_method_position translate="label comment">
|
51 |
+
<label>Show Shipping Method</label>
|
52 |
+
<frontend_type>select</frontend_type>
|
53 |
+
<source_model>firegento_pdf/system_config_source_shipping</source_model>
|
54 |
+
<sort_order>5</sort_order>
|
55 |
+
<show_in_default>1</show_in_default>
|
56 |
+
<show_in_website>1</show_in_website>
|
57 |
+
<show_in_store>1</show_in_store>
|
58 |
+
<comment>Position of shipping method on invoice.</comment>
|
59 |
+
</shipping_method_position>
|
60 |
+
<note translate="label comment">
|
61 |
+
<label>Note</label>
|
62 |
+
<frontend_type>textarea</frontend_type>
|
63 |
+
<sort_order>6</sort_order>
|
64 |
+
<show_in_default>1</show_in_default>
|
65 |
+
<show_in_website>1</show_in_website>
|
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>
|
76 |
+
<sort_order>5</sort_order>
|
77 |
+
<show_in_default>1</show_in_default>
|
78 |
+
<show_in_website>1</show_in_website>
|
79 |
+
<show_in_store>1</show_in_store>
|
80 |
+
<comment>Printed on every shipment.</comment>
|
81 |
+
</note>
|
82 |
+
</fields>
|
83 |
+
</shipment>
|
84 |
+
<creditmemo>
|
85 |
+
<fields>
|
86 |
+
<note translate="label comment">
|
87 |
+
<label>Note</label>
|
88 |
+
<frontend_type>textarea</frontend_type>
|
89 |
+
<sort_order>5</sort_order>
|
90 |
+
<show_in_default>1</show_in_default>
|
91 |
+
<show_in_website>1</show_in_website>
|
92 |
+
<show_in_store>1</show_in_store>
|
93 |
+
<comment>Printed on every credit memo.</comment>
|
94 |
+
</note>
|
95 |
+
</fields>
|
96 |
+
</creditmemo>
|
97 |
+
<firegento_pdf translate="label">
|
98 |
+
<label>PDF Creation</label>
|
99 |
+
<frontend_type>text</frontend_type>
|
100 |
+
<sort_order>0</sort_order>
|
101 |
+
<show_in_default>1</show_in_default>
|
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>
|
117 |
+
<sort_order>10</sort_order>
|
118 |
+
<show_in_default>1</show_in_default>
|
119 |
+
<show_in_website>1</show_in_website>
|
120 |
+
<show_in_store>1</show_in_store>
|
121 |
+
</sender_address_bar>
|
122 |
+
<show_footer translate="label">
|
123 |
+
<label>Show Footer</label>
|
124 |
+
<frontend_type>select</frontend_type>
|
125 |
+
<source_model>adminhtml/system_config_source_yesno</source_model>
|
126 |
+
<sort_order>20</sort_order>
|
127 |
+
<show_in_default>1</show_in_default>
|
128 |
+
<show_in_website>1</show_in_website>
|
129 |
+
<show_in_store>1</show_in_store>
|
130 |
+
</show_footer>
|
131 |
+
<logo_position translate="label">
|
132 |
+
<label>Logo Position</label>
|
133 |
+
<frontend_type>select</frontend_type>
|
134 |
+
<source_model>firegento_pdf/system_config_source_logo</source_model>
|
135 |
+
<sort_order>30</sort_order>
|
136 |
+
<show_in_default>1</show_in_default>
|
137 |
+
<show_in_website>1</show_in_website>
|
138 |
+
<show_in_store>1</show_in_store>
|
139 |
+
</logo_position>
|
140 |
+
</fields>
|
141 |
+
</firegento_pdf>
|
142 |
+
</groups>
|
143 |
+
</sales_pdf>
|
144 |
+
</sections>
|
145 |
+
</config>
|
app/etc/modules/FireGento_Pdf.xml
ADDED
@@ -0,0 +1,9 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?xml version="1.0"?>
|
2 |
+
<config>
|
3 |
+
<modules>
|
4 |
+
<FireGento_Pdf>
|
5 |
+
<active>true</active>
|
6 |
+
<codePool>community</codePool>
|
7 |
+
</FireGento_Pdf>
|
8 |
+
</modules>
|
9 |
+
</config>
|
app/locale/de_DE/FireGento_Pdf.csv
ADDED
@@ -0,0 +1,69 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
"Invoice maturity: %s days","Fälligkeit der Rechnung: %s Tage"
|
2 |
+
"Invoice Maturity","Fälligkeit der Rechnung"
|
3 |
+
"Days after the invoice is due. Leave this field blank to hide the message on the invoice.","Tage nach denen die Rechnung fällig ist. Feld leer lassen, um den Text auf der Rechnung zu verbergen."
|
4 |
+
"Invoice is payable immediately","Die Rechnung ist sofort fällig"
|
5 |
+
"Invoice date is equal to delivery date.","Rechnungsdatum ist gleich dem Lieferdatum."
|
6 |
+
"Payment method:","Zahlungsart:"
|
7 |
+
"Shipping method:","Versandart:"
|
8 |
+
"Payment method: %s","Zahlungsart: %s"
|
9 |
+
"Shipping method: %s","Versandart: %s"
|
10 |
+
"Page","Seite"
|
11 |
+
"Telephone:","Telefon:"
|
12 |
+
"Fax:","Fax:"
|
13 |
+
"E-Mail:","E-Mail:"
|
14 |
+
"Web:","Web:"
|
15 |
+
"Bank name:","Kreditinstitut:"
|
16 |
+
"Account:","Kontonummer:"
|
17 |
+
"Bank number:","BLZ:"
|
18 |
+
"Account owner:","Kontoinhaber:"
|
19 |
+
"SWIFT:","SWIFT:"
|
20 |
+
"IBAN:","IBAN:"
|
21 |
+
"Tax number:","Steuernummer:"
|
22 |
+
"VAT-ID:","USt.Nr.:"
|
23 |
+
"Register number:","HRB Nummer:"
|
24 |
+
"CEO:","Geschäftsführer:"
|
25 |
+
"Pos","Pos."
|
26 |
+
"No.","Artikelnummer"
|
27 |
+
"Description","Beschreibung"
|
28 |
+
"Price (excl. tax)","Preis (Netto)"
|
29 |
+
"Amount","Betrag"
|
30 |
+
"Tax","MwSt."
|
31 |
+
"Total","Summe"
|
32 |
+
"Invoice","Rechnung"
|
33 |
+
"Creditmemo","Gutschrift"
|
34 |
+
"Order number:","Bestellnummer:"
|
35 |
+
"Invoice number:","Rechnungsnummer:"
|
36 |
+
"Shipment number:","Lieferscheinnummer:"
|
37 |
+
"Creditmemo number:","Gutschriftsnummer:"
|
38 |
+
"Customer number:","Kundennummer:"
|
39 |
+
"Customer IP:","Kunden IP:"
|
40 |
+
"Invoice date:","Rechnungsdatum:"
|
41 |
+
"Shipping date:","Versanddatum:"
|
42 |
+
"Date:","Datum:"
|
43 |
+
"Additional tax %s","Zusätzliche Steuern %s"
|
44 |
+
"Subtotal:","Zwischensumme:"
|
45 |
+
"Shipping:","Versand:"
|
46 |
+
"Grand Total:","Gesamtsumme:"
|
47 |
+
"Guestorder","Gastbestellung"
|
48 |
+
"PDF Engine","PDF Engine"
|
49 |
+
"Note","Notiz"
|
50 |
+
"Printed on every invoice.","Wird auf jeder Rechnung gedruckt."
|
51 |
+
"Printed on every shipment.","Wird auf jedem Lieferschein gedruckt."
|
52 |
+
"Printed on every credit memo.","Wird auf jeder Gutschrift gedruckt."
|
53 |
+
"PDF Creation","PDF Erstellung"
|
54 |
+
"Sender Address Bar","Absenderadresse"
|
55 |
+
"Show Footer","Zeige Footer"
|
56 |
+
"Logo Position","Logo Position"
|
57 |
+
"Left","Links"
|
58 |
+
"Center","Mittig"
|
59 |
+
"Right","Rechts"
|
60 |
+
"Standard Magento","Standard Magento"
|
61 |
+
"Standard Germany","Standard Deutschland"
|
62 |
+
"Show Payment Method","Zahlungsart andrucken"
|
63 |
+
"Hide payment method","Nicht andrucken"
|
64 |
+
"Header","Dokumenten-Kopf"
|
65 |
+
"Notes area","Notizbereich"
|
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."
|
package.xml
ADDED
@@ -0,0 +1,18 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?xml version="1.0"?>
|
2 |
+
<package>
|
3 |
+
<name>FireGento_Pdf</name>
|
4 |
+
<version>1.0.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>First release</notes>
|
12 |
+
<authors><author><name>FireGento Team</name><user>firegento</user><email>team@firegento.com</email></author></authors>
|
13 |
+
<date>2013-06-01</date>
|
14 |
+
<time>10:11:41</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="Abstract.php" hash="ca9d79d74763732906fe294816ef642a"/><file name="Creditmemo.php" hash="60f852ac54d8d9d1303e511c61fa9754"/><dir name="Engine"><dir name="Invoice"><file name="Default.php" hash="5ba50d6e1c72e91ec308f7e196fd6330"/></dir></dir><file name="Invoice.php" hash="75a7ec8f8ba8b505da13750eb6615135"/><dir name="Items"><file name="Bundle.php" hash="5baecc71b3d44fa7a113a63008bbf10a"/><file name="Default.php" hash="fdf793d9437e01ea402acee98bb4a0b5"/><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="44b98508c96e7d09da81eb156329d694"/><dir name="System"><dir name="Config"><dir name="Source"><file name="Engine.php" hash="a74e6c93635fcfe078f787d4ac1282a5"/><file name="Logo.php" hash="37485e2799c9394434cc49d72ed239e4"/><file name="Payment.php" hash="2c443eb8bf897148debeccf638f39849"/><file name="Shipping.php" hash="76bf4c6afbb18bf2d2172707509125df"/></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="65306ab3d0fded2dc8d917f95fd5824f"/><file name="system.xml" hash="4af14b38509ec75dfac8d10f5b734d3a"/></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="988e48f0b179d0723909433ad6b833e0"/></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>
|