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

// @codingStandardsIgnoreFile

/** @var $block \Magento\Backend\Block\GlobalSearch */
?>
<div class="search-global" data-mage-init='{"globalSearch": {}}'>
    <form action="#" id="form-search">
        <div class="search-global-field">
            <label class="search-global-label" for="search-global"></label>
            <input
                    type="text"
                    class="search-global-input"
                    id="search-global"
                    name="query"
                    data-mage-init='<?php echo $block->escapeHtml($this->helper('Magento\Framework\Json\Helper\Data')->jsonEncode($block->getWidgetInitOptions()))?>'>
            <button
                type="submit"
                class="search-global-action"
                title="<?php /* @escapeNotVerified */ echo __('Search') ?>"
                ></button>
        </div>
    </form>
    <script data-template="search-suggest" type="text/x-magento-template">
        <ul class="search-global-menu">
        <li class="item">
            <a id="searchPreviewProducts" href="<?php /* @escapeNotVerified */ echo $block->getURL('catalog/product/index/'); ?>?search=<%- data.term%>" class="title">"<%- data.term%>" in Products</a>
        </li>
        <li class="item">
            <a id="searchPreviewOrders" href="<?php /* @escapeNotVerified */ echo $block->getURL('sales/order/index/'); ?>?search=<%- data.term%>" class="title">"<%- data.term%>" in Orders</a>
        </li>
        <li class="item">
            <a id="searchPreviewCustomers" href="<?php /* @escapeNotVerified */ echo $block->getURL('customer/index/index/'); ?>?search=<%- data.term%>" class="title">"<%- data.term%>" in Customers</a>
        </li>
        <li class="item">
            <a id="searchPreviewPages" href="<?php /* @escapeNotVerified */ echo $block->getURL('cms/page/index/'); ?>?search=<%- data.term%>" class="title">"<%- data.term%>" in Pages</a>
        </li>
            <% if (data.items.length) { %>
            <% _.each(data.items, function(value){ %>
            <li class="item"
                <%- data.optionData(value) %>
                >
                <a href="<%- value.url %>" class="title"><%- value.name %></a>
                <span class="type"><%- value.type %></span>
                <%- value.description || "" %>
            </li>
            <% }); %>
        <% } else { %>
            <li>
                <span class="mage-suggest-no-records">
                    <?php /* @escapeNotVerified */ echo __('No records found.') ?>
                </span>
            </li>
        <% } %>
        </ul>
    </script>
</div>
