<mj-section css-class="common-summary common-summary-address">
	<mj-column css-class="item payment">
		<mj-text padding="inherit">
			<h3><?= $enc->html( $this->translate( 'controller/jobs', 'Billing address' ), $enc::TRUST ) ?></h3>
			<?php foreach( $this->summaryBasket->getAddress( 'payment' ) as $addr ) : ?>
				<div class="content">
					<?= preg_replace( ["/\n+/m", '/ +/'], ['<br/>', ' '], trim( $enc->html( sprintf(
						/// Address format with company (%1$s), salutation (%2$s), title (%3$s), first name (%4$s), last name (%5$s),
						/// address part one (%6$s, e.g street), address part two (%7$s, e.g house number), address part three (%8$s, e.g additional information),
						/// postal/zip code (%9$s), city (%10$s), state (%11$s), country (%12$s), language (%13$s),
						/// e-mail (%14$s), phone (%15$s), facsimile/telefax (%16$s), web site (%17$s), vatid (%18$s)
						$this->translate( 'controller/jobs', '%1$s
%2$s %3$s %4$s %5$s
%6$s %7$s
%8$s
%9$s %10$s
%11$s
%12$s
%13$s
%14$s
%15$s
%16$s
%17$s
%18$s
'
						),
						$addr->getCompany(),
						$this->translate( 'mshop/code', $addr->getSalutation() ),
						$addr->getTitle(),
						$addr->getFirstName(),
						$addr->getLastName(),
						$addr->getAddress1(),
						$addr->getAddress2(),
						$addr->getAddress3(),
						$addr->getPostal(),
						$addr->getCity(),
						$addr->getState(),
						$this->translate( 'country', $addr->getCountryId() ),
						$this->translate( 'language', $addr->getLanguageId() ),
						$addr->getEmail(),
						$addr->getTelephone(),
						$addr->getTelefax(),
						$addr->getWebsite(),
						$addr->getVatID()
					) ) ) ) ?>
				</div>
			<?php endforeach ?>
		</mj-text>
	</mj-column>
	<mj-column css-class="item delivery">
		<mj-text padding="inherit">
			<h3><?= $enc->html( $this->translate( 'controller/jobs', 'Delivery address' ), $enc::TRUST ) ?></h3>
			<?php if( ( $addresses = $this->summaryBasket->getAddress( 'delivery' ) ) !== [] ) : ?>
				<?php foreach( $addresses as $addr ) : ?>
					<div class="content">
						<?= preg_replace( ["/\n+/m", '/ +/'], ['<br/>', ' '], trim( $enc->html( sprintf(
							/// Address format with company (%1$s), salutation (%2$s), title (%3$s), first name (%4$s), last name (%5$s),
							/// address part one (%6$s, e.g street), address part two (%7$s, e.g house number), address part three (%8$s, e.g additional information),
							/// postal/zip code (%9$s), city (%10$s), state (%11$s), country (%12$s), language (%13$s),
							/// e-mail (%14$s), phone (%15$s), facsimile/telefax (%16$s), web site (%17$s), vatid (%18$s)
							$this->translate( 'controller/jobs', '%1$s
%2$s %3$s %4$s %5$s
%6$s %7$s
%8$s
%9$s %10$s
%11$s
%12$s
%13$s
%14$s
%15$s
%16$s
%17$s
%18$s
'
							),
							$addr->getCompany(),
							$this->translate( 'mshop/code', $addr->getSalutation() ),
							$addr->getTitle(),
							$addr->getFirstName(),
							$addr->getLastName(),
							$addr->getAddress1(),
							$addr->getAddress2(),
							$addr->getAddress3(),
							$addr->getPostal(),
							$addr->getCity(),
							$addr->getState(),
							$this->translate( 'country', $addr->getCountryId() ),
							$this->translate( 'language', $addr->getLanguageId() ),
							$addr->getEmail(),
							$addr->getTelephone(),
							$addr->getTelefax(),
							$addr->getWebsite(),
							$addr->getVatID()
						) ) ) ) ?>
					</div>
				<?php endforeach ?>
			<?php else : ?>
				<div class="content">
					<?= $enc->html( $this->translate( 'controller/jobs', 'like billing address' ), $enc::TRUST ) ?>
				</div>
			<?php endif ?>
		</mj-text>
	</mj-column>
</mj-section>

<mj-section css-class="common-summary common-summary-service">
	<mj-column css-class="item payment">
		<mj-text padding="inherit">
			<h3><?= $enc->html( $this->translate( 'controller/jobs', 'payment' ), $enc::TRUST ) ?></h3>
			<?php foreach( $this->summaryBasket->getService( 'payment' ) as $service ) : ?>
				<div class="content">
					<h4><?= $enc->html( $service->getName() ) ?></h4>
					<?php if( !( $attributes = $service->getAttributeItems() )->isEmpty() ) : ?>
						<ul class="attr-list">

							<?php foreach( $attributes as $attribute ) : ?>
								<?php if( in_array( $attribute->getType(), ['', 'hidden', 'tx'] ) ) : ?>
									<li class="<?= $enc->attr( 'payment-' . $attribute->getCode() ) ?>">
										<span class="name"><?= $enc->html( $attribute->getName() ?: $this->translate( 'controller/jobs', $attribute->getCode() ) ) ?>:</span>

										<?php switch( $attribute->getValue() ) : case 'array': case 'object': ?>
											<?php foreach( (array) $attribute->getValue() as $value ) : ?>
												<span class="value"><?= $enc->html( $value ) ?></span>
											<?php endforeach ?>
										<?php break; default: ?>
											<span class="value"><?= $enc->html( $attribute->getValue() ) ?></span>
										<?php endswitch ?>
									</li>
								<?php endif ?>
							<?php endforeach ?>

						</ul>
					<?php endif ?>
				</div>
			<?php endforeach ?>
		</mj-text>
	</mj-column>
	<mj-column css-class="item delivery">
		<mj-text padding="inherit">
			<h3><?= $enc->html( $this->translate( 'controller/jobs', 'delivery' ), $enc::TRUST ) ?></h3>
			<?php foreach( $this->summaryBasket->getService( 'delivery' ) as $service ) : ?>
				<div class="content">
					<h4><?= $enc->html( $service->getName() ) ?></h4>
					<?php if( !( $attributes = $service->getAttributeItems() )->isEmpty() ) : ?>
						<ul class="attr-list">

							<?php foreach( $attributes as $attribute ) : ?>
								<?php if( strpos( $attribute->getType(), 'hidden' ) === false ) : ?>
									<li class="<?= $enc->attr( 'delivery-' . $attribute->getCode() ) ?>">
										<span class="name"><?= $enc->html( $attribute->getName() ?: $this->translate( 'controller/jobs', $attribute->getCode() ) ) ?>:</span>

										<?php switch( $attribute->getValue() ) : case 'array': case 'object': ?>
											<?php foreach( (array) $attribute->getValue() as $value ) : ?>
												<span class="value"><?= $enc->html( $value ) ?></span>
											<?php endforeach ?>
										<?php break; default: ?>
											<span class="value"><?= $enc->html( $attribute->getValue() ) ?></span>
										<?php endswitch ?>
									</li>
								<?php endif ?>
							<?php endforeach ?>

						</ul>
					<?php endif ?>
				</div>
			<?php endforeach ?>
		</mj-text>
	</mj-column>
</mj-section>

<mj-section css-class="common-summary common-summary-additional">
	<mj-column css-class="item coupon">
		<mj-text padding="inherit">
			<h3><?= $enc->html( $this->translate( 'controller/jobs', 'Coupon codes' ), $enc::TRUST ) ?></h3>
			<div class="content">
				<?php if( !( $coupons = $this->summaryBasket->getCoupons() )->isEmpty() ) : ?>
					<ul class="attr-list">
						<?php foreach( $coupons as $code => $products ) : ?>
							<li class="attr-item"><?= $enc->html( $code ) ?></li>
						<?php endforeach ?>
					</ul>
				<?php endif ?>
			</div>
		</mj-text>
	</mj-column>
	<mj-column css-class="item customerref">
		<mj-text padding="inherit">
			<h3><?= $enc->html( $this->translate( 'controller/jobs', 'Your reference' ), $enc::TRUST ) ?></h3>
			<div class="content">
				<?= $enc->attr( $this->summaryBasket->getCustomerReference() ) ?>
			</div>
		</mj-text>
	</mj-column>
	<mj-column css-class="item comment">
		<mj-text padding="inherit">
			<h3><?= $enc->html( $this->translate( 'controller/jobs', 'Your comment' ), $enc::TRUST ) ?></h3>
			<div class="content">
				<?= $enc->html( $this->summaryBasket->getComment() ) ?>
			</div>
		</mj-text>
	</mj-column>
</mj-section>

<mj-section css-class="common-summary common-summary-detail">
	<mj-column>
		<mj-table css-class="basket">
			<tr class="header">
				<th class="status"></th>
				<th class="label"><?= $enc->html( $this->translate( 'controller/jobs', 'Name' ), $enc::TRUST ) ?></th>
				<th class="quantity"><?= $enc->html( $this->translate( 'controller/jobs', 'Qty' ), $enc::TRUST ) ?></th>
				<th class="price"><?= $enc->html( $this->translate( 'controller/jobs', 'Sum' ), $enc::TRUST ) ?></th>
			</tr>
			<?php $totalQty = 0 ?>
			<?php foreach( $this->summaryBasket->getProducts() as $product ) : $totalQty += $product->getQuantity() ?>
				<tr class="body product">
					<td class="status">
						<?php if( ( $status = $product->getStatusDelivery() ) >= 0 ) : $key = 'stat:' . $status ?>
							<?= $enc->html( $this->translate( 'mshop/code', $key ) ) ?>
						<?php endif ?>
					</td>
					<td class="label">
						<?php $params = array_merge( $this->param(), ['d_name' => $product->getName( 'url' ), 'd_prodid' => $product->getParentProductId() ?: $product->getProductId(), 'd_pos' => ''] ) ?>
						<span class="product-name"><?= $enc->html( $product->getName(), $enc::TRUST ) ?></span>
						<p class="code">
							<span class="name"><?= $enc->html( $this->translate( 'controller/jobs', 'Article no.' ), $enc::TRUST ) ?>: </span>
							<span class="value"><?= $product->getProductCode() ?></span>
						</p>
						<?php if( ( $desc = $product->getDescription() ) !== '' ) : ?>
							<p class="product-description"><?= $enc->html( $desc ) ?></p>
						<?php endif ?>
						<?php foreach( ['variant', 'config', 'custom'] as $attrType ) : ?>
							<?php if( !( $attributes = $product->getAttributeItems( $attrType ) )->isEmpty() ) : ?>
								<ul class="attr-list attr-type-<?= $enc->attr( $attrType ) ?>">
									<?php foreach( $attributes as $attribute ) : ?>
										<li class="attr-item attr-code-<?= $enc->attr( $attribute->getCode() ) ?>">
											<span class="name"><?= $enc->html( $this->translate( 'controller/jobs', $attribute->getCode() ) ) ?>:</span>
											<span class="value">
												<?php if( $attribute->getQuantity() > 1 ) : ?>
													<?= $enc->html( $attribute->getQuantity() ) ?>×
												<?php endif ?>
												<?= $enc->html( $attrType !== 'custom' && $attribute->getName() ? $attribute->getName() : $attribute->getValue() ) ?>
											</span>
										</li>
									<?php endforeach ?>
								</ul>
							<?php endif ?>
						<?php endforeach ?>
						<?php if( $this->orderItem->getStatusPayment() >= \Aimeos\MShop\Order\Item\Base::PAY_RECEIVED
								&& ( $product->getStatusPayment() < 0 || $product->getStatusPayment() >= \Aimeos\MShop\Order\Item\Base::PAY_RECEIVED )
								&& ( $attribute = $product->getAttributeItem( 'download', 'hidden' ) ) ) : ?>
							<ul class="attr-list attr-list-hidden">
								<li class="attr-item attr-code-<?= $enc->attr( $attribute->getCode() ) ?>">
									<span class="name"><?= $enc->html( $this->translate( 'controller/jobs', $attribute->getCode() ) ) ?></span>
									<span class="value">
										<a href="<?= $enc->attr( $this->link( 'client/html/account/download/url', ['dl_id' => $attribute->getId()], ['absoluteUri' => 1] ) ) ?>" >
											<?= $enc->html( $attribute->getName() ) ?>
										</a>
									</span>
								</li>
							</ul>
						<?php endif ?>
						<?php if( ( $timeframe = $product->getTimeframe() ) !== '' ) : ?>
							<p class="timeframe">
								<span class="name"><?= $enc->html( $this->translate( 'controller/jobs', 'Delivery within' ) ) ?>: </span>
								<span class="value"><?= $enc->html( $timeframe ) ?></span>
							</p>
						<?php endif ?>
					</td>
					<td class="quantity">
						<?= $enc->html( $product->getQuantity() ) ?>
					</td>
					<td class="price">
						<?= $enc->html( sprintf( $pricefmt, $this->number( $product->getPrice()->getValue() * $product->getQuantity(), $product->getPrice()->getPrecision() ), $this->translate( 'currency', $product->getPrice()->getCurrencyId() ) ) ) ?>
					</td>
				</tr>
			<?php endforeach ?>

			<?php foreach( $this->summaryBasket->getService( 'delivery' ) as $service ) : ?>
				<?php if( $service->getPrice()->getValue() > 0 ) : $priceItem = $service->getPrice() ?>
					<tr class="body delivery">
						<td class="status"></td>
						<td class="label"><?= $enc->html( $service->getName() ) ?></td>
						<td class="quantity">1</td>
						<td class="price"><?= $enc->html( sprintf( $pricefmt, $this->number( $priceItem->getValue(), $priceItem->getPrecision() ), $this->translate( 'currency', $priceItem->getCurrencyId() ) ) ) ?></td>
					</tr>
				<?php endif ?>
			<?php endforeach ?>

			<?php foreach( $this->summaryBasket->getService( 'payment' ) as $service ) : ?>
				<?php if( $service->getPrice()->getValue() > 0 ) : $priceItem = $service->getPrice() ?>
					<tr class="body payment">
						<td class="status"></td>
						<td class="label"><?= $enc->html( $service->getName() ) ?></td>
						<td class="quantity">1</td>
						<td class="price"><?= $enc->html( sprintf( $pricefmt, $this->number( $priceItem->getValue(), $priceItem->getPrecision() ), $this->translate( 'currency', $priceItem->getCurrencyId() ) ) ) ?></td>
					</tr>
				<?php endif ?>
			<?php endforeach ?>

			<?php if( $this->summaryBasket->getPrice()->getCosts() > 0 || $this->summaryBasket->getPrice()->getTaxFlag() === false ) : ?>
				<tr class="footer subtotal">
					<td class="status"></td>
					<td class="label"><?= $enc->html( $this->translate( 'controller/jobs', 'Sub-total' ) ) ?></td>
					<td class="quantity"></td>
					<td class="price"><?= $enc->html( sprintf( $pricefmt, $this->number( $this->summaryBasket->getPrice()->getValue(), $this->summaryBasket->getPrice()->getPrecision() ), $this->translate( 'currency', $this->summaryBasket->getPrice()->getCurrencyId() ) ) ) ?></td>
				</tr>
			<?php endif ?>

			<?php if( ( $costs = $this->summaryBasket->getCosts() ) > 0 ) : ?>
				<tr class="footer delivery">
					<td class="status"></td>
					<td class="label"><?= $enc->html( $this->translate( 'controller/jobs', '+ Shipping' ) ) ?></td>
					<td class="quantity"></td>
					<td class="price"><?= $enc->html( sprintf( $pricefmt, $this->number( $costs, $this->summaryBasket->getPrice()->getPrecision() ), $this->translate( 'currency', $this->summaryBasket->getPrice()->getCurrencyId() ) ) ) ?></td>
				</tr>
			<?php endif ?>

			<?php if( ( $costs = $this->summaryBasket->getCosts( 'payment' ) ) > 0 ) : ?>
				<tr class="footer payment">
					<td class="status"></td>
					<td class="label"><?= $enc->html( $this->translate( 'controller/jobs', '+ Payment costs' ) ) ?></td>
					<td class="quantity"></td>
					<td class="price"><?= $enc->html( sprintf( $pricefmt, $this->number( $costs, $this->summaryBasket->getPrice()->getPrecision() ), $this->translate( 'currency', $this->summaryBasket->getPrice()->getCurrencyId() ) ) ) ?></td>
				</tr>
			<?php endif ?>

			<?php if( $this->summaryBasket->getPrice()->getTaxFlag() === true ) : ?>
				<tr class="footer total">
					<td class="status"></td>
					<td class="label"><?= $enc->html( $this->translate( 'controller/jobs', 'Total' ) ) ?></td>
					<td class="quantity"><?= $enc->html( $totalQty ) ?></td>
					<td class="price"><?= $enc->html( sprintf( $pricefmt, $this->number( $this->summaryBasket->getPrice()->getValue() + $this->summaryBasket->getPrice()->getCosts(), $this->summaryBasket->getPrice()->getPrecision() ), $this->translate( 'currency', $this->summaryBasket->getPrice()->getCurrencyId() ) ) ) ?></td>
				</tr>
			<?php endif ?>

			<?php foreach( $this->summaryBasket->getTaxes() as $taxName => $map ) : ?>
				<?php foreach( $map as $taxRate => $priceItem ) : ?>
					<?php if( ( $taxValue = $priceItem->getTaxValue() ) > 0 ) : ?>
						<tr class="footer tax">
							<td class="status"></td>
							<td class="label"><?= $enc->html( sprintf( $priceItem->getTaxFlag() ? $this->translate( 'controller/jobs', 'Incl. %1$s%% %2$s' ) : $this->translate( 'controller/jobs', '+ %1$s%% %2$s' ), $this->number( $taxRate ), $this->translate( 'controller/jobs', $taxName ) ) ) ?></td>
							<td class="quantity"></td>
							<td class="price"><?= $enc->html( sprintf( $pricefmt, $this->number( $taxValue, $priceItem->getPrecision() ), $this->translate( 'currency', $priceItem->getCurrencyId() ) ) ) ?></td>
						</tr>
					<?php endif ?>
				<?php endforeach ?>
			<?php endforeach ?>

			<?php if( $this->summaryBasket->getPrice()->getTaxFlag() === false ) : ?>
				<tr class="footer total">
					<td class="status"></td>
					<td class="label"><?= $enc->html( $this->translate( 'controller/jobs', 'Total' ) ) ?></td>
					<td class="quantity"><?= $enc->html( $totalQty ) ?></td>
					<td class="price"><?= $enc->html( sprintf( $pricefmt, $this->number( $this->summaryBasket->getPrice()->getValue() + $this->summaryBasket->getPrice()->getCosts() + $this->summaryBasket->getPrice()->getTaxValue(), $this->summaryBasket->getPrice()->getPrecision() ), $this->translate( 'currency', $this->summaryBasket->getPrice()->getCurrencyId() ) ) ) ?></td>
				</tr>
			<?php endif ?>

			<?php if( $this->summaryBasket->getPrice()->getRebate() > 0 ) : ?>
				<tr class="footer rebate">
					<td class="status"></td>
					<td class="label"><?= $enc->html( $this->translate( 'controller/jobs', 'Included rebates' ) ) ?></td>
					<td class="quantity"></td>
					<td class="price"><?= $enc->html( sprintf( $pricefmt, $this->number( $this->summaryBasket->getPrice()->getRebate(), $this->summaryBasket->getPrice()->getPrecision() ), $this->translate( 'currency', $this->summaryBasket->getPrice()->getCurrencyId() ) ) ) ?></td>
				</tr>
			<?php endif ?>
		</mj-table>
	</mj-column>
</mj-section>
