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_Creditmemo 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 $items = $this->getChilds($item);
00049 $_prevOptionId = '';
00050 $drawItems = array();
00051 $leftBound = 35;
00052 $rightBound = 565;
00053
00054 foreach ($items as $_item) {
00055 $x = $leftBound;
00056 $line = array();
00057
00058 if ($attributes = $this->getSelectionAttributes($_item)) {
00059 $optionId = $attributes['option_id'];
00060 }
00061 else {
00062 $optionId = 0;
00063 }
00064
00065 if (!isset($drawItems[$optionId])) {
00066 $drawItems[$optionId] = array(
00067 'lines' => array(),
00068 'height' => 10
00069 );
00070 }
00071
00072
00073 if ($_item->getOrderItem()->getParentItem()) {
00074 if ($_prevOptionId != $attributes['option_id']) {
00075 $line[0] = array(
00076 'font' => 'italic',
00077 'text' => $attributes['option_label'],
00078 'feed' => $x
00079 );
00080
00081 $drawItems[$optionId] = array(
00082 'lines' => array($line),
00083 'height' => 10
00084 );
00085
00086 $line = array();
00087 $_prevOptionId = $attributes['option_id'];
00088 }
00089 }
00090
00091
00092 if ($_item->getOrderItem()->getParentItem()) {
00093 $feed = $x + 5;
00094 $name = $this->getValueHtml($_item);
00095 } else {
00096 $feed = $x;
00097 $name = $_item->getName();
00098 }
00099
00100 $line[] = array(
00101 'text' => Mage::helper('core/string')->str_split($name, 60, true, true),
00102 'feed' => $feed
00103 );
00104
00105 $x += 220;
00106
00107
00108 if (!$_item->getOrderItem()->getParentItem()) {
00109 $text = array();
00110 foreach (Mage::helper('core/string')->str_split($item->getSku(), 30) as $part) {
00111 $text[] = $part;
00112 }
00113 $line[] = array(
00114 'text' => $text,
00115 'feed' => $x
00116 );
00117 }
00118
00119 $x += 100;
00120
00121
00122 if ($this->canShowPriceInfo($_item)) {
00123
00124 $text = $order->formatPriceTxt($_item->getRowTotal());
00125 $line[] = array(
00126 'text' => $text,
00127 'feed' => $x,
00128 'font' => 'bold',
00129 'align' => 'right',
00130 'width' => 50
00131 );
00132 $x += 50;
00133
00134
00135 $text = $order->formatPriceTxt(-$_item->getDiscountAmount());
00136 $line[] = array(
00137 'text' => $text,
00138 'feed' => $x,
00139 'font' => 'bold',
00140 'align' => 'right',
00141 'width' => 50
00142 );
00143 $x += 50;
00144
00145
00146 $text = $_item->getQty() * 1;
00147 $line[] = array(
00148 'text' => $_item->getQty()*1,
00149 'feed' => $x,
00150 'font' => 'bold',
00151 'align' => 'center',
00152 'width' => 30
00153 );
00154 $x += 30;
00155
00156
00157 $text = $order->formatPriceTxt($_item->getTaxAmount());
00158 $line[] = array(
00159 'text' => $text,
00160 'feed' => $x,
00161 'font' => 'bold',
00162 'align' => 'right',
00163 'width' => 45
00164 );
00165 $x += 45;
00166
00167
00168 $text = $order->formatPriceTxt($_item->getRowTotal()+$_item->getTaxAmount()-$_item->getDiscountAmount());
00169 $line[] = array(
00170 'text' => $text,
00171 'feed' => $rightBound,
00172 'font' => 'bold',
00173 'align' => 'right',
00174 );
00175 }
00176
00177 $drawItems[$optionId]['lines'][] = $line;
00178
00179 }
00180
00181 if ($item->getOrderItem()->getProductOptions()) {
00182 $options = $item->getOrderItem()->getProductOptions();
00183 if (isset($options['options'])) {
00184 foreach ($options['options'] as $option) {
00185 $lines = array();
00186 $text = array();
00187 foreach (Mage::helper('core/string')->str_split(strip_tags($option['label']), 60, false, true) as $_option) {
00188 $text[] = $_option;
00189 }
00190
00191 $lines = array(array(
00192 'text' => $text,
00193 'font' => 'italic',
00194 'feed' => $leftBound
00195 ));
00196
00197 if ($option['value']) {
00198 $text = array();
00199 $_printValue = isset($option['print_value']) ? $option['print_value'] : strip_tags($option['value']);
00200 $values = explode(', ', $_printValue);
00201 foreach ($values as $value) {
00202 foreach (Mage::helper('core/string')->str_split($value, 50, true, true) as $_value) {
00203 $text[] = $_value;
00204 }
00205 }
00206
00207 $lines[] = array(
00208 'text' => $text,
00209 'feed' => $leftBound + 5
00210 );
00211 }
00212
00213 $drawItems[] = array(
00214 'lines' => $lines,
00215 'height' => 10
00216 );
00217 }
00218 }
00219 }
00220
00221 $page = $pdf->drawLineBlocks($page, $drawItems, array('table_header' => true));
00222 $this->setPage($page);
00223 }
00224 }