<?php
/**
 * Copyright © 2013-2017 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_<?php /* @escapeNotVerified */ echo $block->getDataId() ?>">
    <div class="head sidebar-title-block">
        <a href="#" class="action-refresh"
           title="<?php echo $block->escapeHtml(__('Refresh')); ?>"
           onclick="order.loadArea('sidebar_<?php /* @escapeNotVerified */ echo $block->getDataId() ?>', 'sidebar_data_<?php /* @escapeNotVerified */ echo $block->getDataId() ?>');return false;">
            <span><?php /* @escapeNotVerified */ echo __('Refresh'); ?></span>
        </a>
        <h5 class="create-order-sidebar-label">
            <?php /* @escapeNotVerified */ echo $block->getHeaderText() ?>
            <span class="normal">(<?php /* @escapeNotVerified */ echo $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"><?php /* @escapeNotVerified */ echo __('Item') ?></th>

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

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

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

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

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

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

                        <?php if ($block->canDisplayPrice()): ?>
                            <td class="col-price"><?php /* @escapeNotVerified */ echo $block->convertPrice($_item->getPrice()) ?></td>
                        <?php endif; ?>

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