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_Creditmemo 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: $items = $this->getChilds($item);
48: $_prevOptionId = '';
49: $drawItems = array();
50: $leftBound = 35;
51: $rightBound = 565;
52:
53: foreach ($items as $_item) {
54: $x = $leftBound;
55: $line = array();
56:
57: $attributes = $this->getSelectionAttributes($_item);
58: if (is_array($attributes)) {
59: $optionId = $attributes['option_id'];
60: }
61: else {
62: $optionId = 0;
63: }
64:
65: if (!isset($drawItems[$optionId])) {
66: $drawItems[$optionId] = array(
67: 'lines' => array(),
68: 'height' => 15
69: );
70: }
71:
72:
73: if ($_item->getOrderItem()->getParentItem()) {
74: if ($_prevOptionId != $attributes['option_id']) {
75: $line[0] = array(
76: 'font' => 'italic',
77: 'text' => Mage::helper('core/string')->str_split($attributes['option_label'], 38, true, true),
78: 'feed' => $x
79: );
80:
81: $drawItems[$optionId] = array(
82: 'lines' => array($line),
83: 'height' => 15
84: );
85:
86: $line = array();
87: $_prevOptionId = $attributes['option_id'];
88: }
89: }
90:
91:
92: if ($_item->getOrderItem()->getParentItem()) {
93: $feed = $x + 5;
94: $name = $this->getValueHtml($_item);
95: } else {
96: $feed = $x;
97: $name = $_item->getName();
98: }
99:
100: $line[] = array(
101: 'text' => Mage::helper('core/string')->str_split($name, 35, true, true),
102: 'feed' => $feed
103: );
104:
105: $x += 220;
106:
107:
108: if (!$_item->getOrderItem()->getParentItem()) {
109: $text = array();
110: foreach (Mage::helper('core/string')->str_split($item->getSku(), 17) as $part) {
111: $text[] = $part;
112: }
113: $line[] = array(
114: 'text' => $text,
115: 'feed' => $x
116: );
117: }
118:
119: $x += 100;
120:
121:
122: if ($this->canShowPriceInfo($_item)) {
123:
124: $text = $order->formatPriceTxt($_item->getRowTotal());
125: $line[] = array(
126: 'text' => $text,
127: 'feed' => $x,
128: 'font' => 'bold',
129: 'align' => 'right',
130: 'width' => 50
131: );
132: $x += 50;
133:
134:
135: $text = $order->formatPriceTxt(-$_item->getDiscountAmount());
136: $line[] = array(
137: 'text' => $text,
138: 'feed' => $x,
139: 'font' => 'bold',
140: 'align' => 'right',
141: 'width' => 50
142: );
143: $x += 50;
144:
145:
146: $text = $_item->getQty() * 1;
147: $line[] = array(
148: 'text' => $_item->getQty()*1,
149: 'feed' => $x,
150: 'font' => 'bold',
151: 'align' => 'center',
152: 'width' => 30
153: );
154: $x += 30;
155:
156:
157: $text = $order->formatPriceTxt($_item->getTaxAmount());
158: $line[] = array(
159: 'text' => $text,
160: 'feed' => $x,
161: 'font' => 'bold',
162: 'align' => 'right',
163: 'width' => 45
164: );
165: $x += 45;
166:
167:
168: $text = $order->formatPriceTxt(
169: $_item->getRowTotal() + $_item->getTaxAmount() - $_item->getDiscountAmount()
170: );
171: $line[] = array(
172: 'text' => $text,
173: 'feed' => $rightBound,
174: 'font' => 'bold',
175: 'align' => 'right',
176: );
177: }
178:
179: $drawItems[$optionId]['lines'][] = $line;
180:
181: }
182:
183:
184: $options = $item->getOrderItem()->getProductOptions();
185: if ($options) {
186: if (isset($options['options'])) {
187: foreach ($options['options'] as $option) {
188: $lines = array();
189: $lines[][] = array(
190: 'text' => Mage::helper('core/string')->str_split(strip_tags($option['label']), 40, true, true),
191: 'font' => 'italic',
192: 'feed' => $leftBound
193: );
194:
195: if ($option['value']) {
196: $text = array();
197: $_printValue = isset($option['print_value'])
198: ? $option['print_value']
199: : strip_tags($option['value']);
200: $values = explode(', ', $_printValue);
201: foreach ($values as $value) {
202: foreach (Mage::helper('core/string')->str_split($value, 30, true, true) as $_value) {
203: $text[] = $_value;
204: }
205: }
206:
207: $lines[][] = array(
208: 'text' => $text,
209: 'feed' => $leftBound + 5
210: );
211: }
212:
213: $drawItems[] = array(
214: 'lines' => $lines,
215: 'height' => 15
216: );
217: }
218: }
219: }
220:
221: $page = $pdf->drawLineBlocks($page, $drawItems, array('table_header' => true));
222: $this->setPage($page);
223: }
224: }
225: