Public Member Functions | |
draw () |
Definition at line 35 of file Invoice.php.
draw | ( | ) |
Draw item line
Reimplemented from Mage_Sales_Model_Order_Pdf_Items_Abstract.
Definition at line 41 of file Invoice.php.
00042 { 00043 $order = $this->getOrder(); 00044 $item = $this->getItem(); 00045 $pdf = $this->getPdf(); 00046 $page = $this->getPage(); 00047 00048 $this->_setFontRegular(); 00049 $items = $this->getChilds($item); 00050 00051 $_prevOptionId = ''; 00052 $drawItems = array(); 00053 00054 foreach ($items as $_item) { 00055 $line = array(); 00056 00057 if ($attributes = $this->getSelectionAttributes($_item)) { 00058 $optionId = $attributes['option_id']; 00059 } 00060 else { 00061 $optionId = 0; 00062 } 00063 00064 if (!isset($drawItems[$optionId])) { 00065 $drawItems[$optionId] = array( 00066 'lines' => array(), 00067 'height' => 10 00068 ); 00069 } 00070 00071 if ($_item->getOrderItem()->getParentItem()) { 00072 if ($_prevOptionId != $attributes['option_id']) { 00073 $line[0] = array( 00074 'font' => 'italic', 00075 'text' => $attributes['option_label'], 00076 'feed' => 35 00077 ); 00078 00079 $drawItems[$optionId] = array( 00080 'lines' => array($line), 00081 'height' => 10 00082 ); 00083 00084 $line = array(); 00085 00086 $_prevOptionId = $attributes['option_id']; 00087 } 00088 } 00089 00090 /* in case Product name is longer than 80 chars - it is written in a few lines */ 00091 if ($_item->getOrderItem()->getParentItem()) { 00092 $feed = 40; 00093 $name = $this->getValueHtml($_item); 00094 } else { 00095 $feed = 35; 00096 $name = $_item->getName(); 00097 } 00098 $text = array(); 00099 foreach (Mage::helper('core/string')->str_split($name, 55, true, true) as $part) { 00100 $text[] = $part; 00101 } 00102 00103 $line[] = array( 00104 'text' => $text, 00105 'feed' => $feed 00106 ); 00107 00108 // draw SKUs 00109 if (!$_item->getOrderItem()->getParentItem()) { 00110 $text = array(); 00111 foreach (Mage::helper('core/string')->str_split($item->getSku(), 30) as $part) { 00112 $text[] = $part; 00113 } 00114 $line[] = array( 00115 'text' => $text, 00116 'feed' => 240 00117 ); 00118 } 00119 00120 // draw prices 00121 if ($this->canShowPriceInfo($_item)) { 00122 $price = $order->formatPriceTxt($_item->getPrice()); 00123 $line[] = array( 00124 'text' => $price, 00125 'feed' => 395, 00126 'font' => 'bold', 00127 'align' => 'right' 00128 ); 00129 $line[] = array( 00130 'text' => $_item->getQty()*1, 00131 'feed' => 435, 00132 'font' => 'bold', 00133 ); 00134 00135 $tax = $order->formatPriceTxt($_item->getTaxAmount()); 00136 $line[] = array( 00137 'text' => $tax, 00138 'feed' => 495, 00139 'font' => 'bold', 00140 'align' => 'right' 00141 ); 00142 00143 $row_total = $order->formatPriceTxt($_item->getRowTotal()); 00144 $line[] = array( 00145 'text' => $row_total, 00146 'feed' => 565, 00147 'font' => 'bold', 00148 'align' => 'right' 00149 ); 00150 } 00151 00152 $drawItems[$optionId]['lines'][] = $line; 00153 } 00154 00155 if ($item->getOrderItem()->getProductOptions()) { 00156 $options = $item->getOrderItem()->getProductOptions(); 00157 if (isset($options['options'])) { 00158 foreach ($options['options'] as $option) { 00159 $lines = array(); 00160 $text = array(); 00161 foreach (Mage::helper('core/string')->str_split(strip_tags($option['label']), 60, false, true) as $_option) { 00162 $text[] = $_option; 00163 } 00164 00165 $lines = array(array( 00166 'text' => $text, 00167 'font' => 'italic', 00168 'feed' => 35 00169 )); 00170 00171 if ($option['value']) { 00172 $text = array(); 00173 $_printValue = isset($option['print_value']) ? $option['print_value'] : strip_tags($option['value']); 00174 $values = explode(', ', $_printValue); 00175 foreach ($values as $value) { 00176 foreach (Mage::helper('core/string')->str_split($value, 70, true, true) as $_value) { 00177 $text[] = $_value; 00178 } 00179 } 00180 00181 $lines[] = array( 00182 'text' => $text, 00183 'feed' => 40 00184 ); 00185 } 00186 00187 $drawItems[] = array( 00188 'lines' => $lines, 00189 'height' => 10 00190 ); 00191 } 00192 } 00193 } 00194 00195 $page = $pdf->drawLineBlocks($page, $drawItems, array('table_header' => true)); 00196 00197 $this->setPage($page); 00198 }