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_Shipment extends Mage_Bundle_Model_Sales_Order_Pdf_Items_Abstract
35: {
36: 37: 38: 39:
40: public function draw()
41: {
42: $item = $this->getItem();
43: $pdf = $this->getPdf();
44: $page = $this->getPage();
45:
46: $this->_setFontRegular();
47:
48: $shipItems = $this->getChilds($item);
49: $items = array_merge(array($item->getOrderItem()), $item->getOrderItem()->getChildrenItems());
50:
51: $_prevOptionId = '';
52: $drawItems = array();
53:
54: foreach ($items as $_item) {
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: if ($_item->getParentItem()) {
73: if ($_prevOptionId != $attributes['option_id']) {
74: $line[0] = array(
75: 'font' => 'italic',
76: 'text' => Mage::helper('core/string')->str_split($attributes['option_label'], 60, true, true),
77: 'feed' => 60
78: );
79:
80: $drawItems[$optionId] = array(
81: 'lines' => array($line),
82: 'height' => 15
83: );
84:
85: $line = array();
86:
87: $_prevOptionId = $attributes['option_id'];
88: }
89: }
90:
91: if (($this->isShipmentSeparately() && $_item->getParentItem())
92: || (!$this->isShipmentSeparately() && !$_item->getParentItem())
93: ) {
94: if (isset($shipItems[$_item->getId()])) {
95: $qty = $shipItems[$_item->getId()]->getQty()*1;
96: } else if ($_item->getIsVirtual()) {
97: $qty = Mage::helper('bundle')->__('N/A');
98: } else {
99: $qty = 0;
100: }
101: } else {
102: $qty = '';
103: }
104:
105: $line[] = array(
106: 'text' => $qty,
107: 'feed' => 35
108: );
109:
110:
111: if ($_item->getParentItem()) {
112: $feed = 65;
113: $name = $this->getValueHtml($_item);
114: } else {
115: $feed = 60;
116: $name = $_item->getName();
117: }
118: $text = array();
119: foreach (Mage::helper('core/string')->str_split($name, 60, true, true) as $part) {
120: $text[] = $part;
121: }
122: $line[] = array(
123: 'text' => $text,
124: 'feed' => $feed
125: );
126:
127:
128: $text = array();
129: foreach (Mage::helper('core/string')->str_split($_item->getSku(), 25) as $part) {
130: $text[] = $part;
131: }
132: $line[] = array(
133: 'text' => $text,
134: 'feed' => 440
135: );
136:
137: $drawItems[$optionId]['lines'][] = $line;
138: }
139:
140:
141: $options = $item->getOrderItem()->getProductOptions();
142: if ($options) {
143: if (isset($options['options'])) {
144: foreach ($options['options'] as $option) {
145: $lines = array();
146: $lines[][] = array(
147: 'text' => Mage::helper('core/string')->str_split(strip_tags($option['label']), 70, true, true),
148: 'font' => 'italic',
149: 'feed' => 60
150: );
151:
152: if ($option['value']) {
153: $text = array();
154: $_printValue = isset($option['print_value'])
155: ? $option['print_value']
156: : strip_tags($option['value']);
157: $values = explode(', ', $_printValue);
158: foreach ($values as $value) {
159: foreach (Mage::helper('core/string')->str_split($value, 50, true, true) as $_value) {
160: $text[] = $_value;
161: }
162: }
163:
164: $lines[][] = array(
165: 'text' => $text,
166: 'feed' => 65
167: );
168: }
169:
170: $drawItems[] = array(
171: 'lines' => $lines,
172: 'height' => 15
173: );
174: }
175: }
176: }
177:
178: $page = $pdf->drawLineBlocks($page, $drawItems, array('table_header' => true));
179: $this->setPage($page);
180: }
181: }
182: