1: <?php
2: /**
3: * Magento
4: *
5: * NOTICE OF LICENSE
6: *
7: * This source file is subject to the Open Software License (OSL 3.0)
8: * that is bundled with this package in the file LICENSE.txt.
9: * It is also available through the world-wide-web at this URL:
10: * http://opensource.org/licenses/osl-3.0.php
11: * If you did not receive a copy of the license and are unable to
12: * obtain it through the world-wide-web, please send an email
13: * to license@magentocommerce.com so we can send you a copy immediately.
14: *
15: * DISCLAIMER
16: *
17: * Do not edit or add to this file if you wish to upgrade Magento to newer
18: * versions in the future. If you wish to customize Magento for your
19: * needs please refer to http://www.magentocommerce.com for more information.
20: *
21: * @category Mage
22: * @package Mage_Sales
23: * @copyright Copyright (c) 2012 Magento Inc. (http://www.magentocommerce.com)
24: * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
25: */
26:
27: /**
28: * Sales Order Invoice Pdf default items renderer
29: *
30: * @category Mage
31: * @package Mage_Sales
32: * @author Magento Core Team <core@magentocommerce.com>
33: */
34: class Mage_Sales_Model_Order_Pdf_Items_Invoice_Default extends Mage_Sales_Model_Order_Pdf_Items_Abstract
35: {
36: /**
37: * Draw item line
38: */
39: public function draw()
40: {
41: $order = $this->getOrder();
42: $item = $this->getItem();
43: $pdf = $this->getPdf();
44: $page = $this->getPage();
45: $lines = array();
46:
47: // draw Product name
48: $lines[0] = array(array(
49: 'text' => Mage::helper('core/string')->str_split($item->getName(), 35, true, true),
50: 'feed' => 35,
51: ));
52:
53: // draw SKU
54: $lines[0][] = array(
55: 'text' => Mage::helper('core/string')->str_split($this->getSku($item), 17),
56: 'feed' => 290,
57: 'align' => 'right'
58: );
59:
60: // draw QTY
61: $lines[0][] = array(
62: 'text' => $item->getQty() * 1,
63: 'feed' => 435,
64: 'align' => 'right'
65: );
66:
67: // draw item Prices
68: $i = 0;
69: $prices = $this->getItemPricesForDisplay();
70: $feedPrice = 395;
71: $feedSubtotal = $feedPrice + 170;
72: foreach ($prices as $priceData){
73: if (isset($priceData['label'])) {
74: // draw Price label
75: $lines[$i][] = array(
76: 'text' => $priceData['label'],
77: 'feed' => $feedPrice,
78: 'align' => 'right'
79: );
80: // draw Subtotal label
81: $lines[$i][] = array(
82: 'text' => $priceData['label'],
83: 'feed' => $feedSubtotal,
84: 'align' => 'right'
85: );
86: $i++;
87: }
88: // draw Price
89: $lines[$i][] = array(
90: 'text' => $priceData['price'],
91: 'feed' => $feedPrice,
92: 'font' => 'bold',
93: 'align' => 'right'
94: );
95: // draw Subtotal
96: $lines[$i][] = array(
97: 'text' => $priceData['subtotal'],
98: 'feed' => $feedSubtotal,
99: 'font' => 'bold',
100: 'align' => 'right'
101: );
102: $i++;
103: }
104:
105: // draw Tax
106: $lines[0][] = array(
107: 'text' => $order->formatPriceTxt($item->getTaxAmount()),
108: 'feed' => 495,
109: 'font' => 'bold',
110: 'align' => 'right'
111: );
112:
113: // custom options
114: $options = $this->getItemOptions();
115: if ($options) {
116: foreach ($options as $option) {
117: // draw options label
118: $lines[][] = array(
119: 'text' => Mage::helper('core/string')->str_split(strip_tags($option['label']), 40, true, true),
120: 'font' => 'italic',
121: 'feed' => 35
122: );
123:
124: if ($option['value']) {
125: if (isset($option['print_value'])) {
126: $_printValue = $option['print_value'];
127: } else {
128: $_printValue = strip_tags($option['value']);
129: }
130: $values = explode(', ', $_printValue);
131: foreach ($values as $value) {
132: $lines[][] = array(
133: 'text' => Mage::helper('core/string')->str_split($value, 30, true, true),
134: 'feed' => 40
135: );
136: }
137: }
138: }
139: }
140:
141: $lineBlock = array(
142: 'lines' => $lines,
143: 'height' => 20
144: );
145:
146: $page = $pdf->drawLineBlocks($page, array($lineBlock), array('table_header' => true));
147: $this->setPage($page);
148: }
149: }
150: