<?php
/**
 * Maho
 *
 * @category    design
 * @package     default_default
 * @copyright   Copyright (c) 2006-2020 Magento, Inc. (https://magento.com)
 * @copyright   Copyright (c) 2021-2024 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 /** @var Mage_Adminhtml_Block_Sales_Order_Create_Sidebar_Abstract $this */ ?>
<div class="create-order-sidebar-block" id="sidebar_data_<?= $this->getDataId() ?>">
    <div class="head">
        <h5><?= $this->getHeaderText() ?> <span class="normal">(<?= $this->getItemCount() ?>)</span></h5>
        <a href="#" title="<?= Mage::helper('sales')->__('Refresh') ?>" onclick="order.loadArea('sidebar_<?= $this->getDataId() ?>', 'sidebar_data_<?= $this->getDataId() ?>');return false;">
            <img src="<?= $this->getSkinUrl('images/fam_refresh.gif') ?>" alt="<?= Mage::helper('sales')->__('Refresh') ?>" width="16" height="16"/>
        </a>
    </div>
    <div class="content">
        <div class="auto-scroll">
        <?php if($this->getItemCount()): ?>
        <table style="width:100%">
            <col />
            <?php if ($this->canDisplayItemQty()): ?>
            <col width="20" />
            <?php endif ?>
            <?php if($this->canDisplayPrice()): ?>
            <col width="60" />
            <?php endif ?>
            <?php if($this->canRemoveItems()): ?>
            <col width="16" />
            <?php endif ?>
            <col width="16" />
            <tr>
                <th><?= Mage::helper('sales')->__('Item') ?></th>
                <?php if ($this->canDisplayItemQty()): ?>
                <th class="a-center"><?= Mage::helper('sales')->__('Qty') ?></th>
                <?php endif ?>
                <?php if($this->canDisplayPrice()): ?>
                <th><?= Mage::helper('sales')->__('Price') ?></th>
                <?php endif ?>
                <?php if($this->canRemoveItems()): ?>
                <th class="a-center"><img src="<?= $this->getSkinUrl('images/fam_bin.gif') ?>" alt="<?= Mage::helper('sales')->__('Remove') ?>" title="<?= Mage::helper('sales')->__('Remove') ?>" width="16" height="16"/></th>
                <?php endif ?>
                <th class="a-center"><img src="<?= $this->getSkinUrl('images/fam_package_go.gif') ?>" alt="<?= Mage::helper('sales')->__('Add To Order') ?>" title="<?= Mage::helper('sales')->__('Add To Order') ?>" width="16" height="16"/></th>
            </tr>
            <?php foreach ($this->getItems() as $_item): ?>
            <tr>
                <td><?= $this->escapeHtml($_item->getName()) ?></td>
                <?php if ($this->canDisplayItemQty()): ?>
                <td class="a-center">
                    <?php if ($_item->getProduct()->getTypeId() != Mage_Catalog_Model_Product_Type_Grouped::TYPE_CODE): ?>
                        <?= $_item->getQty()*1 ? $_item->getQty()*1 : 1 ?>
                    <?php endif ?>
                </td>
                <?php endif ?>
                <?php if($this->canDisplayPrice()): ?>
                <td><?= $this->convertPrice($_item->getPrice()) ?></td>
                <?php endif ?>
                <?php if($this->canRemoveItems()): ?>
                <td class="a-center"><input type="checkbox" name="sidebar[remove][<?= $this->getItemId($_item) ?>]" value="<?= $this->getDataId() ?>" title="<?= Mage::helper('sales')->__('Remove') ?>"/></td>
                <?php endif ?>
                <td class="a-center">
                    <?php if ($_item->getTypeId() == Mage_Catalog_Model_Product_Type_Grouped::TYPE_CODE && $this->getDataId() == 'wishlist'): ?>
                        <a href="#" onclick="order.sidebarConfigureProduct('<?= 'sidebar_wishlist' ?>', <?= $this->getProductId($_item) ?>, <?= $this->getItemId($_item) ?>); return false;"><img src="<?= $this->getSkinUrl('images/grouped_to_order_icon.png') ?>" class="v-middle" alt="<?= Mage::helper('sales')->__('Configure and Add to Order') ?>" title="<?= Mage::helper('sales')->__('Configure and Add to Order') ?>" width="16" height="16"/></a>
                    <?php elseif ($_item->getTypeId() == Mage_Catalog_Model_Product_Type_Grouped::TYPE_CODE): ?>
                        <a href="#" onclick="order.sidebarConfigureProduct('<?= 'sidebar' ?>', <?= $this->getProductId($_item) ?>); return false;"><img src="<?= $this->getSkinUrl('images/grouped_to_order_icon.png') ?>" class="v-middle" alt="<?= Mage::helper('sales')->__('Configure and Add to Order') ?>" title="<?= Mage::helper('sales')->__('Configure and Add to Order') ?>" width="16" height="16"/></a>
                    <?php else: ?>
                        <input type="checkbox" name="sidebar[<?= $this->getSidebarStorageAction() ?>][<?= $this->getIdentifierId($_item) ?>]" value="<?= $this->canDisplayItemQty() ? $_item->getQty()*1 : 1 ?>" title="<?= Mage::helper('sales')->__('Add To Order') ?>"/>
                    <?php endif ?>
                </td>
            </tr>
            <?php endforeach ?>
        </table>
        <?php else: ?>
            <p class="center"><?= Mage::helper('sales')->__('No items') ?></p>
        <?php endif ?>
        </div>
        <?php if ($this->getItemCount() && $this->canRemoveItems()): ?>
        <?= $this->getChildHtml('empty_customer_cart_button') ?>
        <?php endif ?>
    </div>
</div>
