string = $string; parent::__construct( $context, $registry, $taxData, $filesystem, $filterManager, $resource, $resourceCollection, $data, $serializer ); } /** * Draw item line * * @return void * @SuppressWarnings(PHPMD.CyclomaticComplexity) * @SuppressWarnings(PHPMD.NPathComplexity) * @SuppressWarnings(PHPMD.ExcessiveMethodLength) */ public function draw() { $item = $this->getItem(); $pdf = $this->getPdf(); $page = $this->getPage(); $this->_setFontRegular(); $shipItems = $this->getChildren($item); $items = array_merge([$item->getOrderItem()], $item->getOrderItem()->getChildrenItems()); $prevOptionId = ''; $drawItems = []; foreach ($items as $childItem) { $line = []; $attributes = $this->getSelectionAttributes($childItem); if (is_array($attributes)) { $optionId = $attributes['option_id']; } else { $optionId = 0; } if (!isset($drawItems[$optionId])) { $drawItems[$optionId] = ['lines' => [], 'height' => 15]; } if ($childItem->getParentItem()) { if ($prevOptionId != $attributes['option_id']) { $line[0] = [ 'font' => 'italic', 'text' => $this->string->split($attributes['option_label'], 60, true, true), 'feed' => 60, ]; $drawItems[$optionId] = ['lines' => [$line], 'height' => 15]; $line = []; $prevOptionId = $attributes['option_id']; } } if ($this->isShipmentSeparately() && $childItem->getParentItem() || !$this->isShipmentSeparately() && !$childItem->getParentItem() ) { if (isset($shipItems[$childItem->getId()])) { $qty = $shipItems[$childItem->getId()]->getQty() * 1; } elseif ($childItem->getIsVirtual()) { $qty = __('N/A'); } else { $qty = 0; } } else { $qty = ''; } $line[] = ['text' => $qty, 'feed' => 35]; // draw Name if ($childItem->getParentItem()) { $feed = 65; $name = $this->getValueHtml($childItem); } else { $feed = 60; $name = $childItem->getName(); } $text = []; foreach ($this->string->split($name, 60, true, true) as $part) { $text[] = $part; } $line[] = ['text' => $text, 'feed' => $feed]; // draw SKUs $text = []; foreach ($this->string->split($childItem->getSku(), 25) as $part) { $text[] = $part; } $line[] = ['text' => $text, 'feed' => 440]; $drawItems[$optionId]['lines'][] = $line; } // custom options $options = $item->getOrderItem()->getProductOptions(); if ($options) { if (isset($options['options'])) { foreach ($options['options'] as $option) { $lines = []; $lines[][] = [ 'text' => $this->string->split( $this->filterManager->stripTags($option['label']), 70, true, true ), 'font' => 'italic', 'feed' => 60, ]; if ($option['value']) { $text = []; $printValue = isset( $option['print_value'] ) ? $option['print_value'] : $this->filterManager->stripTags( $option['value'] ); $values = explode(', ', $printValue); foreach ($values as $value) { foreach ($this->string->split($value, 50, true, true) as $subValue) { $text[] = $subValue; } } $lines[][] = ['text' => $text, 'feed' => 65]; } $drawItems[] = ['lines' => $lines, 'height' => 15]; } } } $page = $pdf->drawLineBlocks($page, $drawItems, ['table_header' => true]); $this->setPage($page); } }