PageRenderTime 42ms CodeModel.GetById 19ms RepoModel.GetById 0ms app.codeStats 1ms

/app/code/core/Mage/Bundle/Model/Sales/Order/Pdf/Items/Creditmemo.php

https://github.com/guiohm/magento-french
PHP | 221 lines | 150 code | 26 blank | 45 comment | 13 complexity | 7bb22bbba660a74505c529e8c167efa2 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_Bundle
  23. * @copyright Copyright (c) 2009 Irubin Consulting Inc. DBA Varien (http://www.varien.com)
  24. * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
  25. */
  26. /**
  27. * Sales Order Creditmemo Pdf default items renderer
  28. *
  29. * @category Mage
  30. * @package Mage_Sales
  31. * @author Magento Core Team <core@magentocommerce.com>
  32. */
  33. class Mage_Bundle_Model_Sales_Order_Pdf_Items_Creditmemo extends Mage_Bundle_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. $items = $this->getChilds($item);
  46. $_prevOptionId = '';
  47. $drawItems = array();
  48. $leftBound = 35;
  49. $rightBound = 565;
  50. foreach ($items as $_item) {
  51. $x = $leftBound;
  52. $line = array();
  53. $attributes = $this->getSelectionAttributes($_item);
  54. if (is_array($attributes)) {
  55. $optionId = $attributes['option_id'];
  56. }
  57. else {
  58. $optionId = 0;
  59. }
  60. if (!isset($drawItems[$optionId])) {
  61. $drawItems[$optionId] = array(
  62. 'lines' => array(),
  63. 'height' => 10
  64. );
  65. }
  66. // draw selection attributes
  67. if ($_item->getOrderItem()->getParentItem()) {
  68. if ($_prevOptionId != $attributes['option_id']) {
  69. $line[0] = array(
  70. 'font' => 'italic',
  71. 'text' => Mage::helper('core/string')->str_split($attributes['option_label'],60, true, true),
  72. 'feed' => $x
  73. );
  74. $drawItems[$optionId] = array(
  75. 'lines' => array($line),
  76. 'height' => 10
  77. );
  78. $line = array();
  79. $_prevOptionId = $attributes['option_id'];
  80. }
  81. }
  82. // draw product titles
  83. if ($_item->getOrderItem()->getParentItem()) {
  84. $feed = $x + 5;
  85. $name = $this->getValueHtml($_item);
  86. } else {
  87. $feed = $x;
  88. $name = $_item->getName();
  89. }
  90. $line[] = array(
  91. 'text' => Mage::helper('core/string')->str_split($name, 60, true, true),
  92. 'feed' => $feed
  93. );
  94. $x += 220;
  95. // draw SKUs
  96. if (!$_item->getOrderItem()->getParentItem()) {
  97. $text = array();
  98. foreach (Mage::helper('core/string')->str_split($item->getSku(), 30) as $part) {
  99. $text[] = $part;
  100. }
  101. $line[] = array(
  102. 'text' => $text,
  103. 'feed' => $x
  104. );
  105. }
  106. $x += 100;
  107. // draw prices
  108. if ($this->canShowPriceInfo($_item)) {
  109. // draw Total(ex)
  110. $text = $order->formatPriceTxt($_item->getRowTotal());
  111. $line[] = array(
  112. 'text' => $text,
  113. 'feed' => $x,
  114. 'font' => 'bold',
  115. 'align' => 'right',
  116. 'width' => 50
  117. );
  118. $x += 50;
  119. // draw Discount
  120. $text = $order->formatPriceTxt(-$_item->getDiscountAmount());
  121. $line[] = array(
  122. 'text' => $text,
  123. 'feed' => $x,
  124. 'font' => 'bold',
  125. 'align' => 'right',
  126. 'width' => 50
  127. );
  128. $x += 50;
  129. // draw QTY
  130. $text = $_item->getQty() * 1;
  131. $line[] = array(
  132. 'text' => $_item->getQty()*1,
  133. 'feed' => $x,
  134. 'font' => 'bold',
  135. 'align' => 'center',
  136. 'width' => 30
  137. );
  138. $x += 30;
  139. // draw Tax
  140. $text = $order->formatPriceTxt($_item->getTaxAmount());
  141. $line[] = array(
  142. 'text' => $text,
  143. 'feed' => $x,
  144. 'font' => 'bold',
  145. 'align' => 'right',
  146. 'width' => 45
  147. );
  148. $x += 45;
  149. // draw Total(inc)
  150. $text = $order->formatPriceTxt($_item->getRowTotal()+$_item->getTaxAmount()-$_item->getDiscountAmount());
  151. $line[] = array(
  152. 'text' => $text,
  153. 'feed' => $rightBound,
  154. 'font' => 'bold',
  155. 'align' => 'right',
  156. );
  157. }
  158. $drawItems[$optionId]['lines'][] = $line;
  159. }
  160. // custom options
  161. $options = $item->getOrderItem()->getProductOptions();
  162. if ($options) {
  163. if (isset($options['options'])) {
  164. foreach ($options['options'] as $option) {
  165. $lines = array();
  166. $lines[][] = array(
  167. 'text' => Mage::helper('core/string')->str_split(strip_tags($option['label']), 70, true, true),
  168. 'font' => 'italic',
  169. 'feed' => $leftBound
  170. );
  171. if ($option['value']) {
  172. $text = array();
  173. $_printValue = isset($option['print_value']) ? $option['print_value'] : strip_tags($option['value']);
  174. $values = explode(', ', $_printValue);
  175. foreach ($values as $value) {
  176. foreach (Mage::helper('core/string')->str_split($value, 50, true, true) as $_value) {
  177. $text[] = $_value;
  178. }
  179. }
  180. $lines[][] = array(
  181. 'text' => $text,
  182. 'feed' => $leftBound + 5
  183. );
  184. }
  185. $drawItems[] = array(
  186. 'lines' => $lines,
  187. 'height' => 10
  188. );
  189. }
  190. }
  191. }
  192. $page = $pdf->drawLineBlocks($page, $drawItems, array('table_header' => true));
  193. $this->setPage($page);
  194. }
  195. }