/app/code/local/Mage/Sales/Model/Order/Pdf/Items/Shipment/Default.php

https://bitbucket.org/nharland/wikl.nl · PHP · 99 lines · 49 code · 9 blank · 41 comment · 2 complexity · 50d7025a89fd7219d19ec5af54d3fad4 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_Sales
  23. * @copyright Copyright (c) 2010 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. * Sales Order Shipment Pdf default items renderer
  28. *
  29. * @category Mage
  30. * @package Mage_Sales
  31. * @author Magento Core Team <core@magentocommerce.com>
  32. */
  33. class Mage_Sales_Model_Order_Pdf_Items_Shipment_Default extends Mage_Sales_Model_Order_Pdf_Items_Abstract
  34. {
  35. /**
  36. * Draw item line
  37. *
  38. */
  39. public function draw()
  40. {
  41. $item = $this->getItem();
  42. $pdf = $this->getPdf();
  43. $page = $this->getPage();
  44. $lines = array();
  45. // draw Product name
  46. $lines[0] = array(array(
  47. 'text' => Mage::helper('core/string')->str_split($item->getName(), 60, true, true),
  48. 'feed' => 60,
  49. ));
  50. // draw QTY
  51. $lines[0][] = array(
  52. 'text' => $item->getQty()*1,
  53. 'feed' => 35
  54. );
  55. // draw SKU
  56. $lines[0][] = array(
  57. 'text' => Mage::helper('core/string')->str_split($this->getSku($item), 25),
  58. 'feed' => 440
  59. );
  60. // Custom options
  61. $options = $this->getItemOptions();
  62. if ($options) {
  63. foreach ($options as $option) {
  64. // draw options label
  65. $lines[][] = array(
  66. 'text' => Mage::helper('core/string')->str_split(strip_tags($option['label']), 70, true, true),
  67. 'font' => 'italic',
  68. 'feed' => 60
  69. );
  70. // draw options value
  71. if ($option['value']) {
  72. $_printValue = isset($option['print_value']) ? $option['print_value'] : strip_tags($option['value']);
  73. $values = explode(', ', $_printValue);
  74. foreach ($values as $value) {
  75. $lines[][] = array(
  76. 'text' => Mage::helper('core/string')->str_split($value, 50, true, true),
  77. 'feed' => 65
  78. );
  79. }
  80. }
  81. }
  82. }
  83. $lineBlock = array(
  84. 'lines' => $lines,
  85. 'height' => 10
  86. );
  87. $page = $pdf->drawLineBlocks($page, array($lineBlock), array('table_header' => true));
  88. $this->setPage($page);
  89. }
  90. }