<?php if ($this->textOnly): ?>
<?php ### THIS IS FOR TEXT ONLY EMAILS ### ?>
<?php foreach ($this->items as $item ): ?>
<?php echo $item['name']; ?><?php if (!empty($item['attributes'])): ?> (<?php $i=0; foreach ($item['attributes'] as $name => $value): ?><?php echo ($i++==0 ? '' : ', ').$this->attributeLabel($name); ?>: <?= $this->attributeValue($name, $value) ?><?php endforeach; ?>)<?php endif; ?>: <?php echo $item['quantity']; ?> x <?php echo $item['price']; ?> = <?php echo $item['total']; ?>

<?php endforeach; ?>
--------------------
<?php echo $GLOBALS['TL_LANG']['MSC']['subTotalLabel']; ?>: <?php echo $this->subtotal; ?>

<?php foreach ($this->surcharges as $surcharge): ?>
<?php echo $surcharge['label']; ?>: <?php echo $surcharge['price']; ?> = <?php echo $surcharge['total_price']; ?>

<?php endforeach; ?>
<?php echo $GLOBALS['TL_LANG']['MSC']['grandTotalLabel']; ?>: <?php echo $this->total; ?>
<?php else: ?>
<?php ### THIS IS HTML EMAILS AND EVERYTHING ELSE ### ?>
<?php if(!empty($this->actions)): ?>
<form action="<?php echo $this->action; ?>" id="<?php echo $this->formId; ?>" method="post">
<div class="formbody">
<input type="hidden" name="FORM_SUBMIT" value="<?php echo $this->formSubmit; ?>">
<input type="hidden" name="REQUEST_TOKEN" value="{{request_token}}">
<?php endif; ?>

<?php if ($this->collection->hasErrors()): ?>
<p class="error"><?php echo implode('</p><p class="error">', $this->collection->getErrors()); ?></p>
<?php endif; ?>
<style type="text/css">
.tw-100 {width: 100%}
</style>
<div class="table-responsive">
<table class="tw-100 bg-white table border">
<?php foreach($this->items as $item): $i=0; ?>
    <tr class="<?php echo $item['rowClass']; ?>"><?php if(!$this->isNotification): ?>
        <td class="col_<?php echo $i++; ?> col_first image" style="width: 120px !important;"><?php echo $this->getGallery('images', $item['item'])->generateMainImage(); ?></td><?php endif; ?>
        <td class="col_<?php echo $i++; ?><?php if($this->isNotification) echo ' col_first'; ?> name">
            <?php if($this->linkProducts && $item['href']): ?><a href="<?php echo $item['href']; ?>"><?php echo $item['name']; ?><br />{{iflng::sl}}Šifra izdelka{{iflng}}{{ifnlng::sl}}SKU{{ifnlng}}: <?php echo $item['sku']; ?></a><?php else: ?><?php echo $item['name']; ?><br />{{iflng::sl}}Šifra izdelka{{iflng}}{{ifnlng::sl}}SKU{{ifnlng}}: <?php echo $item['sku']; ?><?php endif; ?>
            <?php if(!empty($item['attributes'])): ?>
            <ul>
                <?php foreach($item['attributes'] as $name => $value): ?>
                <li><strong><?= $this->attributeLabel($name) ?>:</strong> <?= $this->attributeValue($name, $value, ['html'=>true, 'item'=>$item['item']]) ?></li>
                <?php endforeach; ?>
            </ul>
            <?php endif; ?>
        </td>
        <td class="col_<?php echo $i++; ?> quantity" style="width: 170px; min-width: 170px !important;">
        <?php if($this->isEditable): ?>
        <div class="input-group spinner" data-trigger="spinner">
            <div class="input-group-prepend">
            <span class="input-group-text form-control"><a href="javascript:;" class="spin-down" data-spin="down"><i class="fas fa-minus"></i></a></span>
            </div>
            <input name="quantity[<?php echo $item['id']; ?>]" type="text" class="text form-control" value="<?php echo $item['quantity']; ?>" data-rule="quantity" maxlength="10">
            <div class="input-group-append">
            <span class="input-group-text form-control"><a href="javascript:;" class="spin-up" data-spin="up"><i class="fas fa-plus"></i></a></span>
            </div>
          </div>
        <?php else: ?>
            <?php echo $item['quantity']; ?> x
        <?php endif; ?>
        </td>
        <td class="text-right col_<?php echo $i++; ?> price"><?php echo $item['price']; ?></td>
        <td class="text-right col_<?php echo $i++; if(!$this->isEditable && $this->total_tax_ids < 2) echo ' col_last'; ?> price total"><?php echo $item['total']; ?></td><?php if ($this->total_tax_ids > 1): ?>
        <td class="text-center col_<?php echo $i++; if(!$this->isEditable) echo ' col_last'; ?> tax">Oznaka DDV<br><?php echo $item['tax_id']; ?></td><?php endif; if($this->isEditable): ?>
        <td class="text-center <?php echo $i++; ?> col_last actions" style="width: 30px !important;">
            <a href="<?php echo $item['remove_href']; ?>" class="remove" title="<?php echo $item['remove_title']; ?>"><i class="far fa-trash-alt"></i><?php // echo $item['remove_link']; ?></a>
            <!--<br><?php if ($item['edit_href']): ?><a href="<?php echo $item['edit_href']; ?>" class="edit" title="<?php echo $item['edit_title']; ?>"><i class="fas fa-pen"></i><?php // echo $item['edit_link']; ?></a><?php endif; ?>-->
        </td><?php endif; ?>
    </tr><?php if($item['item']->hasErrors()): ?>
    <tr class="<?php echo $item['rowClass']; ?>">
        <td colspan="<?php echo $i; ?>"><p class="error"><?php echo implode('</p><p class="error">', $item['item']->getErrors()); ?></p></td>
    </tr>
<?php endif; ?>
<?php endforeach; ?>
    <tr class="text-right foot_0 foot_first subtotal border">
        <?php $i=0; if(!$this->isNotification): ?>
        <td class="col_<?php echo $i++; ?> col_first">&nbsp;</td><?php endif; ?>
        <td class="col_<?php echo $i++; $i++; ?><?php if($this->isNotification) echo ' col_first'; ?> name" colspan="2"><?php echo $GLOBALS['TL_LANG']['MSC']['subTotalLabel']; ?>:</td>
        <td class="col_<?php echo $i++; ?> price">&nbsp;</td>
        <td class="col_<?php echo $i++; if(!$this->isEditable && $this->total_tax_ids < 2) echo ' col_last'; ?> price total"><?php echo $this->subtotal; ?></td><?php if ($this->total_tax_ids > 1): ?>
        <td class="col_<?php echo $i++; if(!$this->isEditable) echo ' col_last'; ?> tax">&nbsp;</td><?php endif; if($this->isEditable): ?>
        <td class="col_<?php echo $i++; ?> col_last remove">&nbsp;</td><?php endif; ?>
    </tr>
    <?php foreach ($this->surcharges as $surcharge): $i=0; ?>
    <tr class="text-right <?php echo $surcharge['rowClass']; ?>">
        <?php if(!$this->isNotification): ?>
        <td class="col_<?php echo $i++; ?> col_first">&nbsp;</td><?php endif; ?>
        <td class="col_<?php echo $i++; $i++; ?><?php if($this->isNotification) echo ' col_first'; ?> name" colspan="2"><?php echo $surcharge['label']; ?>:</td>
        <td class="col_<?php echo $i++; ?> price"><?php echo $surcharge['price']; ?></td>
        <td class="col_<?php echo $i++; if(!$this->isEditable && $this->total_tax_ids < 2) echo ' col_last'; ?> price total"><?php echo $surcharge['total_price']; ?></td><?php if ($this->total_tax_ids > 1): ?>
        <td class="col_<?php echo $i++; if(!$this->isEditable) echo ' col_last'; ?> tax"><?php echo $surcharge['tax_id']; ?></td><?php endif; if($this->isEditable): ?>
        <td class="col_<?php echo $i++; ?> col_last remove">&nbsp;</td><?php endif; ?>
    </tr>
    <?php endforeach; ?>
    <tr class="text-right foot_<?php echo count($this->surcharges)+1; ?> foot_last total">
        <?php $i=0; if(!$this->isNotification): ?>
        <td class="col_<?php echo $i++; ?> col_first">&nbsp;</td><?php endif; ?>
        <td class="col_<?php echo $i++; $i++ ?><?php if($this->isNotification) echo ' col_first'; ?> name" colspan="2"><strong><?php echo $GLOBALS['TL_LANG']['MSC']['grandTotalLabel']; ?>:</strong></td>
        <td class="col_<?php echo $i++; ?> price">&nbsp;</td>
        <td class="col_<?php echo $i++; if(!$this->isEditable && $this->total_tax_ids < 2) echo ' col_last'; ?> price total"><strong><?php echo $this->total; ?></strong></td><?php if ($this->total_tax_ids > 1): ?>
        <td class="col_<?php echo $i++; if(!$this->isEditable) echo ' col_last'; ?> tax">&nbsp;</td><?php endif; if($this->isEditable): ?>
        <td class="col_<?php echo $i++; ?> col_last remove">&nbsp;</td><?php endif; ?>
    </tr>
</table>
</div>
<?php if(!empty($this->actions)): ?>
</div>
<div class="submit_container w-100 btn-group justify-content-end">
<?php foreach($this->actions as $action) echo $action->generate($this->collection).' '; ?>
</div>
</form>
<?php endif; ?>

<?php if (!$this->isEditable && count($this->downloads)): ?>
<div class="downloads">
<h2><?php echo $GLOBALS['TL_LANG']['MSC']['downloadsLabel']; ?></h2>
<ul class="list-group">
<?php foreach ($this->downloads as $download): ?>
<li class="list-group-item <?php echo $download['downloadable'] ? 'available' : 'unavailable'; ?>"><?php if ($download['downloadable'] && $download['href']): ?><a href="<?php echo $download['href']; ?>"><?php endif; echo $download['title']; if ($download['downloadable'] && $download['href']): ?></a><?php endif; echo $download['remaining']; ?></li>
<?php endforeach; ?>
</ul>
</div>
<?php endif; ?>

<?php endif; ?>
