<?xml version="1.0" encoding="UTF-8"?>
<templates xml:space="preserve">

<t t-name="GlobalSearch" owl="1">
        <div>
            <div class="sh_search_container form-row align-items-center">
                <div class="sh_search_input">
					<div class="input-group">
<!-- 					    <div> -->
<!-- 					    <button class="fa fa-qrcode" t-on-click="on2BarcodeBtnClick"></button> -->
<!-- 					    </div> -->
						<div class="input-group-prepend">
<!-- 							<div class="input-group-text"> -->
<!-- 								<button class="fa fa-qrcode icon-button" t-on-click="on2BarcodeBtnClick"> -->
								<button class="icon-button" t-on-click="on2BarcodeBtnClick">
								<img src="/sf_global_search/static/src/img/barcode.png" style="width: 20px; height: 20px;"/></button>
						</div>
						<input type="text" placeholder="Searching ..." t-on-keydown="onSearchResultsNavigate" class="usermenu_search_input form-control"/>
						<div class="input-group-prepend">
							<button class="clear_Search" t-on-click="_on_click_clear_Search">X</button>
						</div>
					</div>
				</div>
                <div class="sh_search_results col-md-10 ml-auto mr-auto"/>
            </div>
        </div>
    </t>

     <t t-name="MenuSearchResults" >
        <t t-set="count" t-value="0" />

        <t t-foreach="results" t-as="result">
            <t t-set="is_menu" t-value="_checkIsMenu(result)" />
            <t t-set="menu" t-value="_linkInfo(result)" />
            <t t-if="is_menu">
                <a t-attf-class="dropdown-item col-12 ml-auto mr-auto" target="_blank" t-attf-href="#menu_id=#{menu.id}&amp;action_id=#{menu.action}"><span t-esc="menu.name" /></a>
            </t>
            <t t-else="">
                <t t-if="count==0">
                    <t t-set="menu_model" t-value="menu.model_name" />
                    <t t-set="count" t-value="1" />
                    <p class="search_company_detail">
                        <t t-set="company_name" t-value="_getcompanyInfo(result)" />
                        <t t-if="show_company"> <t t-esc="company_name" /> : </t>
                        <t t-esc="menu_model" />
                    </p>
                </t>

                <t t-if="menu.model_name == menu_model">
                    <t t-set="field_name" t-value="_getFieldInfo(result)" />

                    <t t-if="show_company &amp; company_name!=_getcompanyInfo(result)">
                        <t t-set="company_name" t-value="_getcompanyInfo(result)" />
                        <p class="search_company_detail"><t t-esc="company_name" /> : <t t-esc="menu_model" /></p>
                    </t>

                    <a t-attf-class="dropdown-item col-12 ml-auto mr-auto" t-raw="field_name" target="_blank" t-attf-href="/mail/view?model=#{menu.model}&amp;res_id=#{menu.id}" />
                </t>
                <t t-else="">
                    <t t-set="menu_model" t-value="menu.model_name" />
                    <p class="search_company_detail">
                        <t t-set="company_name" t-value="_getcompanyInfo(result)" />
                        <t t-if="show_company"> <t t-esc="company_name" /> : </t>
                        <t t-esc="menu_model" />
                    </p>
                    <t t-set="field_name" t-value="_getFieldInfo(result)" />
                    <a t-attf-class="dropdown-item col-12 ml-auto mr-auto" t-raw="field_name" target="_blank" t-attf-href="/mail/view?model=#{menu.model}&amp;res_id=#{menu.id}" />
                </t>
            </t>
        </t>
    </t> 
</templates>
