Public Member Functions | |
draw () |
Definition at line 35 of file Creditmemo.php.
draw | ( | ) |
Draw item line
Reimplemented from Mage_Downloadable_Model_Sales_Order_Pdf_Items_Abstract.
Definition at line 37 of file Creditmemo.php.
00038 { 00039 $order = $this->getOrder(); 00040 $item = $this->getItem(); 00041 $pdf = $this->getPdf(); 00042 $page = $this->getPage(); 00043 00044 // Mage::getModel('sales/order_pdf_items_creditmemo_default') 00045 // ->setOrder($this->getOrder()) 00046 // ->setItem($this->getItem()) 00047 // ->setPdf($this->getPdf()) 00048 // ->setPage($this->getPage()) 00049 // ->draw(); 00050 00051 $shift = array(0, 10, 0); 00052 $leftBound = 35; 00053 $rightBound = 565; 00054 00055 // draw name 00056 $this->_setFontRegular(); 00057 $x = $leftBound; 00058 foreach (Mage::helper('core/string')->str_split($item->getName(), $x, true, true) as $key => $part) { 00059 $page->drawText($part, $x, $pdf->y - $shift[0], 'UTF-8'); 00060 $shift[0] += 10; 00061 } 00062 // draw options 00063 $options = $this->getItemOptions(); 00064 if (isset($options)) { 00065 foreach ($options as $option) { 00066 // draw options label 00067 $this->_setFontItalic(); 00068 foreach (Mage::helper('core/string')->str_split(strip_tags($option['label']), $x, false, true) as $_option) { 00069 $page->drawText($_option, $x, $pdf->y - $shift[0], 'UTF-8'); 00070 $shift[0] += 10; 00071 } 00072 // draw options value 00073 $this->_setFontRegular(); 00074 $_printValue = isset($option['print_value']) ? $option['print_value'] : strip_tags($option['value']); 00075 foreach (Mage::helper('core/string')->str_split($_printValue, $x, true, true) as $_value) { 00076 $page->drawText($_value, $x + 5, $pdf->y - $shift[0], 'UTF-8'); 00077 $shift[0] += 10; 00078 } 00079 } 00080 } 00081 // draw product description 00082 foreach ($this->_parseDescription() as $description){ 00083 $page->drawText(strip_tags($description), $x + 5, $pdf->y - $shift[1], 'UTF-8'); 00084 $shift[1] += 10; 00085 } 00086 $x += 220; 00087 00088 // draw SKU 00089 foreach (Mage::helper('core/string')->str_split($this->getSku($item), 25) as $key => $part) { 00090 $page->drawText($part, $x, $pdf->y - $shift[2], 'UTF-8'); 00091 $shift[2] += 10; 00092 } 00093 $x += 100; 00094 00095 $font = $this->_setFontBold(); 00096 00097 // draw Total(ex) 00098 $text = $order->formatPriceTxt($item->getRowTotal()); 00099 $page->drawText($text, $pdf->getAlignRight($text, $x, 50, $font, 7), $pdf->y, 'UTF-8'); 00100 $x += 50; 00101 00102 // draw Discount 00103 $text = $order->formatPriceTxt(-$item->getDiscountAmount()); 00104 $page->drawText($text, $pdf->getAlignRight($text, $x, 50, $font, 7), $pdf->y, 'UTF-8'); 00105 $x += 50; 00106 00107 // draw QTY 00108 $text = $item->getQty() * 1; 00109 $page->drawText($text, $pdf->getAlignCenter($text, $x, 30, $font, 7), $pdf->y, 'UTF-8'); 00110 $x += 30; 00111 00112 // draw Tax 00113 $text = $order->formatPriceTxt($item->getTaxAmount()); 00114 $page->drawText($text, $pdf->getAlignRight($text, $x, 45, $font, 7, 10), $pdf->y, 'UTF-8'); 00115 $x += 45; 00116 00117 // draw Total(inc) 00118 $text = $order->formatPriceTxt($item->getRowTotal() + $item->getTaxAmount() - $item->getDiscountAmount()); 00119 $page->drawText($text, $pdf->getAlignRight($text, $x, $rightBound - $x, $font, 7, 0), $pdf->y, 'UTF-8'); 00120 00121 // draw Links Section Title 00122 $this->_setFontItalic(); 00123 $pdf->y -= 10; 00124 $x = $leftBound; 00125 $_purchasedItems = $this->getLinks()->getPurchasedItems(); 00126 $page->drawText($this->getLinksTitle(), $x, $pdf->y, 'UTF-8'); 00127 00128 // draw Links 00129 $this->_setFontRegular(); 00130 foreach ($_purchasedItems as $_link) { 00131 $pdf->y -= 10; 00132 // $text = $_link->getLinkTitle() . ' ('.$_link->getNumberOfDownloadsUsed() . ' / ' . ($_link->getNumberOfDownloadsBought()?$_link->getNumberOfDownloadsBought():'U').')'; 00133 $text = $_link->getLinkTitle(); 00134 $page->drawText($text, $x+10, $pdf->y, 'UTF-8'); 00135 } 00136 $pdf->y -= 15; 00137 }