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:
35: class Mage_Downloadable_Model_Sales_Order_Pdf_Items_Invoice
36: extends Mage_Downloadable_Model_Sales_Order_Pdf_Items_Abstract
37: {
38: 39: 40: 41:
42: public function draw()
43: {
44: $order = $this->getOrder();
45: $item = $this->getItem();
46: $pdf = $this->getPdf();
47: $page = $this->getPage();
48: $lines = array();
49:
50:
51: $lines[0] = array(array(
52: 'text' => Mage::helper('core/string')->str_split($item->getName(), 35, true, true),
53: 'feed' => 35,
54: ));
55:
56:
57: $lines[0][] = array(
58: 'text' => Mage::helper('core/string')->str_split($this->getSku($item), 17),
59: 'feed' => 290,
60: 'align' => 'right'
61: );
62:
63:
64: $lines[0][] = array(
65: 'text' => $item->getQty() * 1,
66: 'feed' => 435,
67: 'align' => 'right'
68: );
69:
70:
71: $i = 0;
72: $prices = $this->getItemPricesForDisplay();
73: $feedPrice = 395;
74: $feedSubtotal = $feedPrice + 170;
75: foreach ($prices as $priceData){
76: if (isset($priceData['label'])) {
77:
78: $lines[$i][] = array(
79: 'text' => $priceData['label'],
80: 'feed' => $feedPrice,
81: 'align' => 'right'
82: );
83:
84: $lines[$i][] = array(
85: 'text' => $priceData['label'],
86: 'feed' => $feedSubtotal,
87: 'align' => 'right'
88: );
89: $i++;
90: }
91:
92: $lines[$i][] = array(
93: 'text' => $priceData['price'],
94: 'feed' => $feedPrice,
95: 'font' => 'bold',
96: 'align' => 'right'
97: );
98:
99: $lines[$i][] = array(
100: 'text' => $priceData['subtotal'],
101: 'feed' => $feedSubtotal,
102: 'font' => 'bold',
103: 'align' => 'right'
104: );
105: $i++;
106: }
107:
108:
109: $lines[0][] = array(
110: 'text' => $order->formatPriceTxt($item->getTaxAmount()),
111: 'feed' => 495,
112: 'font' => 'bold',
113: 'align' => 'right'
114: );
115:
116:
117: $options = $this->getItemOptions();
118: if ($options) {
119: foreach ($options as $option) {
120:
121: $lines[][] = array(
122: 'text' => Mage::helper('core/string')->str_split(strip_tags($option['label']), 40, true, true),
123: 'font' => 'italic',
124: 'feed' => 35
125: );
126:
127: if ($option['value']) {
128: if (isset($option['print_value'])) {
129: $_printValue = $option['print_value'];
130: } else {
131: $_printValue = strip_tags($option['value']);
132: }
133: $values = explode(', ', $_printValue);
134: foreach ($values as $value) {
135: $lines[][] = array(
136: 'text' => Mage::helper('core/string')->str_split($value, 30, true, true),
137: 'feed' => 40
138: );
139: }
140: }
141: }
142: }
143:
144:
145: $_purchasedItems = $this->getLinks()->getPurchasedItems();
146:
147:
148: $lines[][] = array(
149: 'text' => Mage::helper('core/string')->str_split($this->getLinksTitle(), 70, true, true),
150: 'font' => 'italic',
151: 'feed' => 35
152: );
153:
154:
155: foreach ($_purchasedItems as $_link) {
156: $lines[][] = array(
157: 'text' => Mage::helper('core/string')->str_split($_link->getLinkTitle(), 50, true, true),
158: 'feed' => 40
159: );
160: }
161:
162: $lineBlock = array(
163: 'lines' => $lines,
164: 'height' => 20
165: );
166:
167: $page = $pdf->drawLineBlocks($page, array($lineBlock), array('table_header' => true));
168: $this->setPage($page);
169: }
170: }
171: