<?php
/**
 * Copyright © Magento, Inc. All rights reserved.
 * See COPYING.txt for license details.
 */

// @codingStandardsIgnoreFile

?>
<?php /* @var $block \Magento\Sales\Block\Adminhtml\Order\Create\Sidebar\AbstractSidebar */ ?>
<div class="create-order-sidebar-block" id="sidebar_data_<?= /* @escapeNotVerified */ $block->getDataId() ?>">
    <div class="head sidebar-title-block">
        <a href="#" class="action-refresh"
           title="<?= $block->escapeHtml(__('Refresh')) ?>"
           onclick="order.loadArea('sidebar_<?= /* @escapeNotVerified */ $block->getDataId() ?>', 'sidebar_data_<?= /* @escapeNotVerified */ $block->getDataId() ?>');return false;">
            <span><?= /* @escapeNotVerified */ __('Refresh') ?></span>
        </a>
        <h5 class="create-order-sidebar-label">
            <?= /* @escapeNotVerified */ $block->getHeaderText() ?>
            <span class="normal">(<?= /* @escapeNotVerified */ $block->getItemCount() ?>)</span>
        </h5>
    </div>
    <div class="content">
        <div class="auto-scroll">
        <?php if ($block->getItemCount()): ?>
        <table class="admin__table-primary">
            <thead>
                <tr>
                    <th class="col-item"><?= /* @escapeNotVerified */ __('Item') ?></th>

                    <?php if ($block->canDisplayItemQty()): ?>
                        <th class="col-qty"><?= /* @escapeNotVerified */ __('Qty') ?></th>
                    <?php endif; ?>

                    <?php if ($block->canDisplayPrice()): ?>
                        <th class="col-price"><?= /* @escapeNotVerified */ __('Price') ?></th>
                    <?php endif; ?>

                    <?php if ($block->canRemoveItems()): ?>
                        <th class="col-remove">
                            <span title="<?= $block->escapeHtml(__('Remove')) ?>"
                                  class="icon icon-remove">
                                <span><?= /* @escapeNotVerified */ __('Remove') ?></span>
                            </span>
                        </th>
                    <?php endif; ?>

                    <th class="col-add">
                        <span title="<?= $block->escapeHtml(__('Add To Order')) ?>"
                              class="icon icon-add">
                            <span><?= /* @escapeNotVerified */ __('Add To Order') ?></span>
                        </span>
                    </th>
                </tr>
            </thead>

            <tbody>
                <?php foreach ($block->getItems() as $_item): ?>
                    <tr>
                        <td class="col-item"><?= $block->escapeHtml($_item->getName()) ?></td>

                        <?php if ($block->canDisplayItemQty()): ?>
                            <td class="col-qty">
                                <?= /* @escapeNotVerified */ $block->getItemQty($_item) ?>
                            </td>
                        <?php endif; ?>

                        <?php if ($block->canDisplayPrice()): ?>
                            <td class="col-price">
                                <?php if ($block->getDataId() == 'cart'): ?>
                                    <?= /* @noEscape */ $block->getItemPrice($_item->getProduct()) ?>
                                <?php else: ?>
                                    <?= /* @noEscape */ $block->getItemPrice($_item) ?>
                                <?php endif; ?>
                            </td>
                        <?php endif; ?>

                        <?php if ($block->canRemoveItems()): ?>
                            <td class="col-remove">
                                <div class="admin__field-option">
                                    <input id="sidebar-remove-<?= /* @escapeNotVerified */ $block->getSidebarStorageAction() ?>-<?= /* @escapeNotVerified */ $block->getItemId($_item) ?>"
                                           type="checkbox"
                                           class="admin__control-checkbox"
                                           name="sidebar[remove][<?= /* @escapeNotVerified */ $block->getItemId($_item) ?>]"
                                           value="<?= /* @escapeNotVerified */ $block->getDataId() ?>"
                                           title="<?= $block->escapeHtml(__('Remove')) ?>" />
                                    <label class="admin__field-label"
                                           for="sidebar-remove-<?= /* @escapeNotVerified */ $block->getSidebarStorageAction() ?>-<?= /* @escapeNotVerified */ $block->getItemId($_item) ?>">
                                    </label>
                                </div>
                            </td>
                        <?php endif; ?>

                        <td class="col-add">
                            <div class="admin__field-option">
                                <?php if ($block->isConfigurationRequired($_item->getTypeId()) && $block->getDataId() == 'wishlist'): ?>
                                    <a href="#"
                                       class="icon icon-configure"
                                       title="<?= $block->escapeHtml(__('Configure and Add to Order')) ?>"
                                       onclick="order.sidebarConfigureProduct('<?= 'sidebar_wishlist' ?>', <?= /* @escapeNotVerified */ $block->getProductId($_item) ?>, <?= /* @escapeNotVerified */ $block->getItemId($_item) ?>); return false;">
                                        <span><?= /* @escapeNotVerified */ __('Configure and Add to Order') ?></span>
                                    </a>
                                <?php elseif ($block->isConfigurationRequired($_item->getTypeId())): ?>
                                    <a href="#"
                                       class="icon icon-configure"
                                       title="<?= $block->escapeHtml(__('Configure and Add to Order')) ?>"
                                       onclick="order.sidebarConfigureProduct('<?= 'sidebar' ?>', <?= /* @escapeNotVerified */ $block->getProductId($_item) ?>); return false;">
                                        <span><?= /* @escapeNotVerified */ __('Configure and Add to Order') ?></span>
                                    </a>
                                <?php else: ?>
                                    <input id="sidebar-<?= /* @escapeNotVerified */ $block->getSidebarStorageAction() ?>-<?= /* @escapeNotVerified */ $block->getIdentifierId($_item) ?>"
                                           type="checkbox"
                                           class="admin__control-checkbox"
                                           name="sidebar[<?= /* @escapeNotVerified */ $block->getSidebarStorageAction() ?>][<?= /* @escapeNotVerified */ $block->getIdentifierId($_item) ?>]"
                                           value="<?= /* @escapeNotVerified */ $block->canDisplayItemQty() ? $_item->getQty()*1 : 1 ?>"
                                           title="<?= $block->escapeHtml(__('Add To Order')) ?>"/>
                                    <label class="admin__field-label"
                                           for="sidebar-<?= /* @escapeNotVerified */ $block->getSidebarStorageAction() ?>-<?= /* @escapeNotVerified */ $block->getIdentifierId($_item) ?>">
                                    </label>
                                <?php endif; ?>
                            </div>
                        </td>
                    </tr>
                <?php endforeach; ?>
            </tbody>
        </table>
        <?php else: ?>
            <span class="no-items"><?= /* @escapeNotVerified */ __('No items') ?></span>
        <?php endif ?>
        </div>
        <?php if ($block->getItemCount() && $block->canRemoveItems()): ?>
            <?= $block->getChildHtml('empty_customer_cart_button') ?>
        <?php endif; ?>
    </div>
</div>
