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_Sales_Model_Order_Pdf_Creditmemo extends Mage_Sales_Model_Order_Pdf_Abstract
36: {
37: 38: 39: 40: 41: 42:
43: protected function (Zend_Pdf_Page $page)
44: {
45: $this->_setFontRegular($page, 10);
46: $page->setFillColor(new Zend_Pdf_Color_RGB(0.93, 0.92, 0.92));
47: $page->setLineColor(new Zend_Pdf_Color_GrayScale(0.5));
48: $page->setLineWidth(0.5);
49: $page->drawRectangle(25, $this->y, 570, $this->y - 30);
50: $this->y -= 10;
51: $page->setFillColor(new Zend_Pdf_Color_RGB(0, 0, 0));
52:
53:
54: $lines[0][] = array(
55: 'text' => Mage::helper('sales')->__('Products'),
56: 'feed' => 35,
57: );
58:
59: $lines[0][] = array(
60: 'text' => Mage::helper('core/string')->str_split(Mage::helper('sales')->__('SKU'), 12, true, true),
61: 'feed' => 255,
62: 'align' => 'right'
63: );
64:
65: $lines[0][] = array(
66: 'text' => Mage::helper('core/string')->str_split(Mage::helper('sales')->__('Total (ex)'), 12, true, true),
67: 'feed' => 330,
68: 'align' => 'right',
69:
70: );
71:
72: $lines[0][] = array(
73: 'text' => Mage::helper('core/string')->str_split(Mage::helper('sales')->__('Discount'), 12, true, true),
74: 'feed' => 380,
75: 'align' => 'right',
76:
77: );
78:
79: $lines[0][] = array(
80: 'text' => Mage::helper('core/string')->str_split(Mage::helper('sales')->__('Qty'), 12, true, true),
81: 'feed' => 445,
82: 'align' => 'right',
83:
84: );
85:
86: $lines[0][] = array(
87: 'text' => Mage::helper('core/string')->str_split(Mage::helper('sales')->__('Tax'), 12, true, true),
88: 'feed' => 495,
89: 'align' => 'right',
90:
91: );
92:
93: $lines[0][] = array(
94: 'text' => Mage::helper('core/string')->str_split(Mage::helper('sales')->__('Total (inc)'), 12, true, true),
95: 'feed' => 565,
96: 'align' => 'right'
97: );
98:
99: $lineBlock = array(
100: 'lines' => $lines,
101: 'height' => 10
102: );
103:
104: $this->drawLineBlocks($page, array($lineBlock), array('table_header' => true));
105: $page->setFillColor(new Zend_Pdf_Color_GrayScale(0));
106: $this->y -= 20;
107: }
108:
109: 110: 111: 112: 113: 114:
115: public function getPdf($creditmemos = array())
116: {
117: $this->_beforeGetPdf();
118: $this->_initRenderer('creditmemo');
119:
120: $pdf = new Zend_Pdf();
121: $this->_setPdf($pdf);
122: $style = new Zend_Pdf_Style();
123: $this->_setFontBold($style, 10);
124:
125: foreach ($creditmemos as $creditmemo) {
126: if ($creditmemo->getStoreId()) {
127: Mage::app()->getLocale()->emulate($creditmemo->getStoreId());
128: Mage::app()->setCurrentStore($creditmemo->getStoreId());
129: }
130: $page = $this->newPage();
131: $order = $creditmemo->getOrder();
132:
133: $this->insertLogo($page, $creditmemo->getStore());
134:
135: $this->insertAddress($page, $creditmemo->getStore());
136:
137: $this->insertOrder(
138: $page,
139: $order,
140: Mage::getStoreConfigFlag(self::XML_PATH_SALES_PDF_CREDITMEMO_PUT_ORDER_ID, $order->getStoreId())
141: );
142:
143: $this->insertDocumentNumber(
144: $page,
145: Mage::helper('sales')->__('Credit Memo # ') . $creditmemo->getIncrementId()
146: );
147:
148: $this->_drawHeader($page);
149:
150: foreach ($creditmemo->getAllItems() as $item){
151: if ($item->getOrderItem()->getParentItem()) {
152: continue;
153: }
154:
155: $this->_drawItem($item, $page, $order);
156: $page = end($pdf->pages);
157: }
158:
159: $this->insertTotals($page, $creditmemo);
160: }
161: $this->_afterGetPdf();
162: if ($creditmemo->getStoreId()) {
163: Mage::app()->getLocale()->revert();
164: }
165: return $pdf;
166: }
167:
168: 169: 170: 171: 172: 173:
174: public function newPage(array $settings = array())
175: {
176: $page = parent::newPage($settings);
177: if (!empty($settings['table_header'])) {
178: $this->_drawHeader($page);
179: }
180: return $page;
181: }
182: }
183: