<?php
/**
 * Maho
 *
 * @category    design
 * @package     rwd_default
 * @copyright   Copyright (c) 2006-2020 Magento, Inc. (https://magento.com)
 * @copyright   Copyright (c) 2021-2022 The OpenMage Contributors (https://openmage.org)
 * @copyright   Copyright (c) 2024 Maho (https://mahocommerce.com)
 * @license     https://opensource.org/licenses/afl-3.0.php  Academic Free License (AFL 3.0)
 */
?>
<?php  $_order = $this->getOrder() ?>
<p class="order-links">
    <?php  if ($_order->getTracksCollection()->count()) : ?>
        <a href="#" onclick="popWin('<?= $this->helper('shipping')->getTrackingPopupUrlBySalesModel($_order) ?>','trackorder','width=800,height=600,top=0,left=0,resizable=yes,scrollbars=yes'); return false;" title="<?= Mage::helper('core')->quoteEscape($this->__('Track all shipment(s)')) ?>"><?= $this->__('Track all shipments') ?></a> <span class="separator">|</span>
    <?php endif ?>
    <a href="<?= $this->getPrintAllShipmentsUrl($_order) ?>" onclick="this.target='_blank'" class="link-print"><?= $this->__('Print All Shipments') ?></a>
</p>
<?php foreach ($_order->getShipmentsCollection() as $_shipment): ?>
<h2 class="sub-title"><?= $this->__('Shipment #') ?><?= $_shipment->getIncrementId() ?> <span class="separator">|</span> <a href="<?= $this->getPrintShipmentUrl($_shipment) ?>" onclick="this.target='_blank'" class="link-print"><?= $this->__('Print Shipment') ?></a></h2>
<?php $tracks = $_shipment->getTracksCollection(); ?>
<?php  if ($tracks->count()): ?>
    <table class="data-table tracking-table linearize-table" id="my-tracking-table-<?= $_shipment->getId() ?>">
        <tbody>
            <tr>
                <td colspan="2">
                    <a href="#" onclick="popWin('<?= $this->helper('shipping')->getTrackingPopupUrlBySalesModel($_shipment) ?>','trackshipment','width=800,height=600,top=0,left=0,resizable=yes,scrollbars=yes'); return false;" title="<?= Mage::helper('core')->quoteEscape($this->__('Track this shipment')) ?>"><?= $this->__('Track this shipment') ?></a>
                </td>
            </tr>
            <tr>
                <th class="label"><?= $this->__('Tracking Number(s):') ?></th>
                <td>&nbsp;
                <?php
                $i = 1;
                $_size = $tracks->count();
                foreach($tracks as $track): ?>
                <?php if($track->isCustom()): ?>
                    <?= $this->escapeHtml($track->getNumber()) ?>
                <?php else: ?>
                    <a href="#" onclick="popWin('<?= $this->helper('shipping')->getTrackingPopupUrlBySalesModel($track) ?>','trackorder','width=800,height=600,left=0,top=0,resizable=yes,scrollbars=yes')" ><?= $this->escapeHtml($track->getNumber()) ?></a>
                <?php endif ?>
                <?php if($i!=$_size): ?>, <?php endif ?>
                <?php $i++;
                endforeach; ?>
                </td>
            </tr>
        </tbody>
    </table>
<?php endif ?>
<h3 class="table-caption"><?= $this->__('Items Shipped') ?></h3>
<table class="data-table" id="my-shipment-table-<?= $_shipment->getId() ?>">
    <col />
    <col width="1" />
    <col width="1" />
    <thead>
        <tr>
            <th><?= $this->__('Product Name') ?></th>
            <th><?= $this->__('SKU') ?></th>
            <th class="a-center"><span class="nobr"><?= $this->__('Qty Shipped') ?></span></th>
        </tr>
    </thead>
    <?php $_items = $_shipment->getAllItems(); ?>
    <?php $_count = count($_items) ?>
    <?php foreach ($_items as $_item): ?>
    <?php if ($_item->getOrderItem()->getParentItem()) continue; ?>
    <tbody>
        <?= $this->getItemHtml($_item) ?>
    </tbody>
    <?php endforeach ?>
</table>
<?= $this->getCommentsHtml($_shipment) ?>
<?php endforeach ?>
