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

https://bitbucket.org/acidel/buykoala · PHP · 141 lines · 80 code · 15 blank · 46 comment · 2 complexity · ff73a64fc9824ef9151476169daffe04 MD5 · raw file

  1. <?php
  2. /**
  3. * Magento
  4. *
  5. * NOTICE OF LICENSE
  6. *
  7. * This source file is subject to the Open Software License (OSL 3.0)
  8. * that is bundled with this package in the file LICENSE.txt.
  9. * It is also available through the world-wide-web at this URL:
  10. * http://opensource.org/licenses/osl-3.0.php
  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) 2011 Magento Inc. (http://www.magentocommerce.com)
  24. * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
  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 extends Mage_Downloadable_Model_Sales_Order_Pdf_Items_Abstract
  34. {
  35. /**
  36. * Draw item line
  37. *
  38. */
  39. public function draw()
  40. {
  41. $order = $this->getOrder();
  42. $item = $this->getItem();
  43. $pdf = $this->getPdf();
  44. $page = $this->getPage();
  45. $lines = array();
  46. // draw Product name
  47. $lines[0] = array(array(
  48. 'text' => Mage::helper('core/string')->str_split($item->getName(), 64, true, true),
  49. 'feed' => 35,
  50. ));
  51. // draw SKU
  52. $lines[0][] = array(
  53. 'text' => Mage::helper('core/string')->str_split($this->getSku($item), 25),
  54. 'feed' => 255
  55. );
  56. // draw QTY
  57. $lines[0][] = array(
  58. 'text' => $item->getQty()*1,
  59. 'feed' => 435
  60. );
  61. // draw Price
  62. $lines[0][] = array(
  63. 'text' => $order->formatPriceTxt($item->getPrice()),
  64. 'feed' => 395,
  65. 'font' => 'bold',
  66. 'align' => 'right'
  67. );
  68. // draw Tax
  69. $lines[0][] = array(
  70. 'text' => $order->formatPriceTxt($item->getTaxAmount()),
  71. 'feed' => 495,
  72. 'font' => 'bold',
  73. 'align' => 'right'
  74. );
  75. // draw Subtotal
  76. $lines[0][] = array(
  77. 'text' => $order->formatPriceTxt($item->getRowTotal()),
  78. 'feed' => 565,
  79. 'font' => 'bold',
  80. 'align' => 'right'
  81. );
  82. // custom options
  83. $options = $this->getItemOptions();
  84. if ($options) {
  85. foreach ($options as $option) {
  86. // draw options label
  87. $lines[][] = array(
  88. 'text' => Mage::helper('core/string')->str_split(strip_tags($option['label']), 70, true, true),
  89. 'font' => 'italic',
  90. 'feed' => 35
  91. );
  92. if ($option['value']) {
  93. $_printValue = isset($option['print_value']) ? $option['print_value'] : strip_tags($option['value']);
  94. $values = explode(', ', $_printValue);
  95. foreach ($values as $value) {
  96. $lines[][] = array(
  97. 'text' => Mage::helper('core/string')->str_split($value, 50, true, true),
  98. 'feed' => 40
  99. );
  100. }
  101. }
  102. }
  103. }
  104. // downloadable Items
  105. $_purchasedItems = $this->getLinks()->getPurchasedItems();
  106. // draw Links title
  107. $lines[][] = array(
  108. 'text' => Mage::helper('core/string')->str_split($this->getLinksTitle(), 70, true, true),
  109. 'font' => 'italic',
  110. 'feed' => 35
  111. );
  112. // draw Links
  113. foreach ($_purchasedItems as $_link) {
  114. $lines[][] = array(
  115. 'text' => Mage::helper('core/string')->str_split($_link->getLinkTitle(), 50, true, true),
  116. 'feed' => 40
  117. );
  118. }
  119. $lineBlock = array(
  120. 'lines' => $lines,
  121. 'height' => 10
  122. );
  123. $page = $pdf->drawLineBlocks($page, array($lineBlock), array('table_header' => true));
  124. $this->setPage($page);
  125. }
  126. }