/app/code/core/Mage/Downloadable/Model/Sales/Order/Pdf/Items/Invoice.php

https://bitbucket.org/kdms/sh-magento · PHP · 170 lines · 107 code · 14 blank · 49 comment · 5 complexity · 55d630928d3b789ff5cd8d951d034431 MD5 · raw file

  1. <?php
  2. /**
  3. * Magento Enterprise Edition
  4. *
  5. * NOTICE OF LICENSE
  6. *
  7. * This source file is subject to the Magento Enterprise Edition License
  8. * that is bundled with this package in the file LICENSE_EE.txt.
  9. * It is also available through the world-wide-web at this URL:
  10. * http://www.magentocommerce.com/license/enterprise-edition
  11. * If you did not receive a copy of the license and are unable to
  12. * obtain it through the world-wide-web, please send an email
  13. * to license@magentocommerce.com so we can send you a copy immediately.
  14. *
  15. * DISCLAIMER
  16. *
  17. * Do not edit or add to this file if you wish to upgrade Magento to newer
  18. * versions in the future. If you wish to customize Magento for your
  19. * needs please refer to http://www.magentocommerce.com for more information.
  20. *
  21. * @category Mage
  22. * @package Mage_Downloadable
  23. * @copyright Copyright (c) 2012 Magento Inc. (http://www.magentocommerce.com)
  24. * @license http://www.magentocommerce.com/license/enterprise-edition
  25. */
  26. /**
  27. * Order Invoice Downloadable Pdf Items renderer
  28. *
  29. * @category Mage
  30. * @package Mage_Downloadable
  31. * @author Magento Core Team <core@magentocommerce.com>
  32. */
  33. class Mage_Downloadable_Model_Sales_Order_Pdf_Items_Invoice
  34. extends Mage_Downloadable_Model_Sales_Order_Pdf_Items_Abstract
  35. {
  36. /**
  37. * Draw item line
  38. *
  39. */
  40. public function draw()
  41. {
  42. $order = $this->getOrder();
  43. $item = $this->getItem();
  44. $pdf = $this->getPdf();
  45. $page = $this->getPage();
  46. $lines = array();
  47. // draw Product name
  48. $lines[0] = array(array(
  49. 'text' => Mage::helper('core/string')->str_split($item->getName(), 35, true, true),
  50. 'feed' => 35,
  51. ));
  52. // draw SKU
  53. $lines[0][] = array(
  54. 'text' => Mage::helper('core/string')->str_split($this->getSku($item), 17),
  55. 'feed' => 290,
  56. 'align' => 'right'
  57. );
  58. // draw QTY
  59. $lines[0][] = array(
  60. 'text' => $item->getQty() * 1,
  61. 'feed' => 435,
  62. 'align' => 'right'
  63. );
  64. // draw item Prices
  65. $i = 0;
  66. $prices = $this->getItemPricesForDisplay();
  67. $feedPrice = 395;
  68. $feedSubtotal = $feedPrice + 170;
  69. foreach ($prices as $priceData){
  70. if (isset($priceData['label'])) {
  71. // draw Price label
  72. $lines[$i][] = array(
  73. 'text' => $priceData['label'],
  74. 'feed' => $feedPrice,
  75. 'align' => 'right'
  76. );
  77. // draw Subtotal label
  78. $lines[$i][] = array(
  79. 'text' => $priceData['label'],
  80. 'feed' => $feedSubtotal,
  81. 'align' => 'right'
  82. );
  83. $i++;
  84. }
  85. // draw Price
  86. $lines[$i][] = array(
  87. 'text' => $priceData['price'],
  88. 'feed' => $feedPrice,
  89. 'font' => 'bold',
  90. 'align' => 'right'
  91. );
  92. // draw Subtotal
  93. $lines[$i][] = array(
  94. 'text' => $priceData['subtotal'],
  95. 'feed' => $feedSubtotal,
  96. 'font' => 'bold',
  97. 'align' => 'right'
  98. );
  99. $i++;
  100. }
  101. // draw Tax
  102. $lines[0][] = array(
  103. 'text' => $order->formatPriceTxt($item->getTaxAmount()),
  104. 'feed' => 495,
  105. 'font' => 'bold',
  106. 'align' => 'right'
  107. );
  108. // custom options
  109. $options = $this->getItemOptions();
  110. if ($options) {
  111. foreach ($options as $option) {
  112. // draw options label
  113. $lines[][] = array(
  114. 'text' => Mage::helper('core/string')->str_split(strip_tags($option['label']), 40, true, true),
  115. 'font' => 'italic',
  116. 'feed' => 35
  117. );
  118. if ($option['value']) {
  119. if (isset($option['print_value'])) {
  120. $_printValue = $option['print_value'];
  121. } else {
  122. $_printValue = strip_tags($option['value']);
  123. }
  124. $values = explode(', ', $_printValue);
  125. foreach ($values as $value) {
  126. $lines[][] = array(
  127. 'text' => Mage::helper('core/string')->str_split($value, 30, true, true),
  128. 'feed' => 40
  129. );
  130. }
  131. }
  132. }
  133. }
  134. // downloadable Items
  135. $_purchasedItems = $this->getLinks()->getPurchasedItems();
  136. // draw Links title
  137. $lines[][] = array(
  138. 'text' => Mage::helper('core/string')->str_split($this->getLinksTitle(), 70, true, true),
  139. 'font' => 'italic',
  140. 'feed' => 35
  141. );
  142. // draw Links
  143. foreach ($_purchasedItems as $_link) {
  144. $lines[][] = array(
  145. 'text' => Mage::helper('core/string')->str_split($_link->getLinkTitle(), 50, true, true),
  146. 'feed' => 40
  147. );
  148. }
  149. $lineBlock = array(
  150. 'lines' => $lines,
  151. 'height' => 20
  152. );
  153. $page = $pdf->drawLineBlocks($page, array($lineBlock), array('table_header' => true));
  154. $this->setPage($page);
  155. }
  156. }