1: <?php
2: 3: 4: 5: 6: 7: 8: 9: 10: 11: 12: 13: 14: 15: 16: 17: 18: 19: 20: 21: 22: 23: 24: 25:
26:
27: 28: 29: 30: 31: 32: 33:
34: class Mage_Bundle_Model_Sales_Order_Pdf_Items_Invoice extends Mage_Bundle_Model_Sales_Order_Pdf_Items_Abstract
35: {
36: 37: 38: 39:
40: public function draw()
41: {
42: $order = $this->getOrder();
43: $item = $this->getItem();
44: $pdf = $this->getPdf();
45: $page = $this->getPage();
46:
47: $this->_setFontRegular();
48: $items = $this->getChilds($item);
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->getOrderItem()->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'], 45, true, true),
76: 'feed' => 35
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:
91: if ($_item->getOrderItem()->getParentItem()) {
92: $feed = 40;
93: $name = $this->getValueHtml($_item);
94: } else {
95: $feed = 35;
96: $name = $_item->getName();
97: }
98: $line[] = array(
99: 'text' => Mage::helper('core/string')->str_split($name, 35, true, true),
100: 'feed' => $feed
101: );
102:
103:
104: if (!$_item->getOrderItem()->getParentItem()) {
105: $text = array();
106: foreach (Mage::helper('core/string')->str_split($item->getSku(), 17) as $part) {
107: $text[] = $part;
108: }
109: $line[] = array(
110: 'text' => $text,
111: 'feed' => 255
112: );
113: }
114:
115:
116: if ($this->canShowPriceInfo($_item)) {
117: $price = $order->formatPriceTxt($_item->getPrice());
118: $line[] = array(
119: 'text' => $price,
120: 'feed' => 395,
121: 'font' => 'bold',
122: 'align' => 'right'
123: );
124: $line[] = array(
125: 'text' => $_item->getQty()*1,
126: 'feed' => 435,
127: 'font' => 'bold',
128: );
129:
130: $tax = $order->formatPriceTxt($_item->getTaxAmount());
131: $line[] = array(
132: 'text' => $tax,
133: 'feed' => 495,
134: 'font' => 'bold',
135: 'align' => 'right'
136: );
137:
138: $row_total = $order->formatPriceTxt($_item->getRowTotal());
139: $line[] = array(
140: 'text' => $row_total,
141: 'feed' => 565,
142: 'font' => 'bold',
143: 'align' => 'right'
144: );
145: }
146:
147: $drawItems[$optionId]['lines'][] = $line;
148: }
149:
150:
151: $options = $item->getOrderItem()->getProductOptions();
152: if ($options) {
153: if (isset($options['options'])) {
154: foreach ($options['options'] as $option) {
155: $lines = array();
156: $lines[][] = array(
157: 'text' => Mage::helper('core/string')->str_split(strip_tags($option['label']), 40, true, true),
158: 'font' => 'italic',
159: 'feed' => 35
160: );
161:
162: if ($option['value']) {
163: $text = array();
164: $_printValue = isset($option['print_value'])
165: ? $option['print_value']
166: : strip_tags($option['value']);
167: $values = explode(', ', $_printValue);
168: foreach ($values as $value) {
169: foreach (Mage::helper('core/string')->str_split($value, 30, true, true) as $_value) {
170: $text[] = $_value;
171: }
172: }
173:
174: $lines[][] = array(
175: 'text' => $text,
176: 'feed' => 40
177: );
178: }
179:
180: $drawItems[] = array(
181: 'lines' => $lines,
182: 'height' => 15
183: );
184: }
185: }
186: }
187:
188: $page = $pdf->drawLineBlocks($page, $drawItems, array('table_header' => true));
189:
190: $this->setPage($page);
191: }
192: }
193: