00001 <?php
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034
00035 class Mage_Bundle_Model_Sales_Order_Pdf_Items_Shipment extends Mage_Bundle_Model_Sales_Order_Pdf_Items_Abstract
00036 {
00037
00038
00039
00040
00041 public function draw()
00042 {
00043 $order = $this->getOrder();
00044 $item = $this->getItem();
00045 $pdf = $this->getPdf();
00046 $page = $this->getPage();
00047
00048 $this->_setFontRegular();
00049
00050 $shipItems = $this->getChilds($item);
00051 $items = array_merge(array($item->getOrderItem()), $item->getOrderItem()->getChildrenItems());
00052
00053 $_prevOptionId = '';
00054 $drawItems = array();
00055
00056 foreach ($items as $_item) {
00057 $line = array();
00058
00059 if ($attributes = $this->getSelectionAttributes($_item)) {
00060 $optionId = $attributes['option_id'];
00061 }
00062 else {
00063 $optionId = 0;
00064 }
00065
00066 if (!isset($drawItems[$optionId])) {
00067 $drawItems[$optionId] = array(
00068 'lines' => array(),
00069 'height' => 10
00070 );
00071 }
00072
00073 if ($_item->getParentItem()) {
00074 if ($_prevOptionId != $attributes['option_id']) {
00075 $line[0] = array(
00076 'font' => 'italic',
00077 'text' => $attributes['option_label'],
00078 'feed' => 60
00079 );
00080
00081 $drawItems[$optionId] = array(
00082 'lines' => array($line),
00083 'height' => 10
00084 );
00085
00086 $line = array();
00087 }
00088 }
00089
00090 if (($this->isShipmentSeparately() && $_item->getParentItem()) || (!$this->isShipmentSeparately() && !$_item->getParentItem())) {
00091 if (isset($shipItems[$_item->getId()])) {
00092 $qty = $shipItems[$_item->getId()]->getQty()*1;
00093 } else if ($_item->getIsVirtual()) {
00094 $qty = Mage::helper('bundle')->__('N/A');
00095 } else {
00096 $qty = 0;
00097 }
00098 } else {
00099 $qty = '';
00100 }
00101
00102 $line[] = array(
00103 'text' => $qty,
00104 'feed' => 35
00105 );
00106
00107
00108 if ($_item->getParentItem()) {
00109 $feed = 65;
00110 $name = $this->getValueHtml($_item);
00111 } else {
00112 $feed = 60;
00113 $name = $_item->getName();
00114 }
00115 $text = array();
00116 foreach (Mage::helper('core/string')->str_split($name, 60, true, true) as $part) {
00117 $text[] = $part;
00118 }
00119 $line[] = array(
00120 'text' => $text,
00121 'feed' => $feed
00122 );
00123
00124
00125 $text = array();
00126 foreach (Mage::helper('core/string')->str_split($_item->getSku(), 30) as $part) {
00127 $text[] = $part;
00128 }
00129 $line[] = array(
00130 'text' => $text,
00131 'feed' => 440
00132 );
00133
00134 $drawItems[$optionId]['lines'][] = $line;
00135 }
00136
00137 if ($item->getOrderItem()->getProductOptions()) {
00138 $options = $item->getOrderItem()->getProductOptions();
00139 if (isset($options['options'])) {
00140 foreach ($options['options'] as $option) {
00141 $lines = array();
00142 $text = array();
00143 foreach (Mage::helper('core/string')->str_split(strip_tags($option['label']), 60, false, true) as $_option) {
00144 $text[] = $_option;
00145 }
00146
00147 $lines = array(array(
00148 'text' => $text,
00149 'font' => 'italic',
00150 'feed' => 60
00151 ));
00152
00153 if ($option['value']) {
00154 $text = array();
00155 $_printValue = isset($option['print_value']) ? $option['print_value'] : strip_tags($option['value']);
00156 $values = explode(', ', $_printValue);
00157 foreach ($values as $value) {
00158 foreach (Mage::helper('core/string')->str_split($value, 70, true, true) as $_value) {
00159 $text[] = $_value;
00160 }
00161 }
00162
00163 $lines[] = array(
00164 'text' => $text,
00165 'feed' => 65
00166 );
00167 }
00168
00169 $drawItems[] = array(
00170 'lines' => $lines,
00171 'height' => 10
00172 );
00173 }
00174 }
00175 }
00176
00177 $page = $pdf->drawLineBlocks($page, $drawItems, array('table_header' => true));
00178 $this->setPage($page);
00179 }
00180 }