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

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

https://bitbucket.org/kdms/sh-magento
PHP | 100 lines | 52 code | 8 blank | 40 comment | 2 complexity | 2f82d5f30b5a79f9b42845ea0a62d992 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_Sales
  23. * @copyright Copyright (c) 2012 Magento Inc. (http://www.magentocommerce.com)
  24. * @license http://www.magentocommerce.com/license/enterprise-edition
  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. public function draw()
  39. {
  40. $item = $this->getItem();
  41. $pdf = $this->getPdf();
  42. $page = $this->getPage();
  43. $lines = array();
  44. // draw Product name
  45. $lines[0] = array(array(
  46. 'text' => Mage::helper('core/string')->str_split($item->getName(), 60, true, true),
  47. 'feed' => 100,
  48. ));
  49. // draw QTY
  50. $lines[0][] = array(
  51. 'text' => $item->getQty()*1,
  52. 'feed' => 35
  53. );
  54. // draw SKU
  55. $lines[0][] = array(
  56. 'text' => Mage::helper('core/string')->str_split($this->getSku($item), 25),
  57. 'feed' => 565,
  58. 'align' => 'right'
  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' => 110
  69. );
  70. // draw options value
  71. if ($option['value']) {
  72. $_printValue = isset($option['print_value'])
  73. ? $option['print_value']
  74. : strip_tags($option['value']);
  75. $values = explode(', ', $_printValue);
  76. foreach ($values as $value) {
  77. $lines[][] = array(
  78. 'text' => Mage::helper('core/string')->str_split($value, 50, true, true),
  79. 'feed' => 115
  80. );
  81. }
  82. }
  83. }
  84. }
  85. $lineBlock = array(
  86. 'lines' => $lines,
  87. 'height' => 20
  88. );
  89. $page = $pdf->drawLineBlocks($page, array($lineBlock), array('table_header' => true));
  90. $this->setPage($page);
  91. }
  92. }