{% extends "base.html" %} {% load static %} {% load i18n %} {% load inventree_extras %} {% block page_title %} {% inventree_title %} | {% trans "Search Results" %} {% endblock %} {% block content %}

{% trans "Search Results" %}

{% include "search_form.html" with query_text=query %}
{% if query %} {% else %}

{% trans "Enter a search query" %}

{% endif %}
{% endblock %} {% block js_ready %} {{ block.super }} function addItemTitle(title) { // Add header block to the results list $('#search-item-list').append( `
  • ${title}
  • ` ); } function addItem(label, title, icon, options) { // Add a search itme to the action list $('#search-item-list').append( `
  • ${title}
  • ` ); // Add a results table $('#search-result-list').append( `
  • ${title}

  • ` ); // Hide the results table $(`#search-result-${label}`).hide(); // Add callback when the action is clicked $(`#search-item-${label}`).click(function() { // Hide all childs $('#search-result-list').children('li').each(function() { $(this).hide(); }); // Show the one we want $(`#search-result-${label}`).fadeIn(); // Remove css class from all action items $("#search-item-list").children('li').each(function() { $(this).removeClass('index-action-selected'); }); // Add css class to the action we are interested in $(`#search-item-${label}`).addClass('index-action-selected'); }); // Connect a callback to the table $(`#table-${label}`).on('load-success.bs.table', function() { var count = $(`#table-${label}`).bootstrapTable('getData').length; $(`#badge-${label}`).html(count); if (count > 0) { $(`#badge-${label}`).addClass('badge-orange'); } }); } {% if roles.part.view %} addItemTitle('{% trans "Part" %}'); addItem('part', '{% trans "Parts" %}', 'fa-shapes'); loadPartTable("#table-part", "{% url 'api-part-list' %}", { params: { original_search: "{{ query }}", }, checkbox: false, disableFilters: true, } ); addItem('category', '{% trans "Part Categories" %}', 'fa-sitemap'); loadPartCategoryTable($("#table-category"), { params: { original_search: "{{ query }}", } }); addItem('manufacturer-part', '{% trans "Manufacturer Parts" %}', 'fa-toolbox'); loadManufacturerPartTable( "#table-manufacturer-part", "{% url 'api-manufacturer-part-list' %}", { params: { original_search: "{{ query }}", part_detail: true, supplier_detail: true, manufacturer_detail: true }, } ); addItem('supplier-part', '{% trans "Supplier Parts" %}', 'fa-pallet'); loadSupplierPartTable( "#table-supplier-part", "{% url 'api-supplier-part-list' %}", { params: { original_search: "{{ query }}", part_detail: true, supplier_detail: true, manufacturer_detail: true }, } ); {% endif %} {% if roles.build.view %} addItemTitle('{% trans "Build" %}'); addItem('build-order', '{% trans "Build Orders" %}', 'fa-tools'); loadBuildTable('#table-build-order', { params: { original_search: '{{ query }}', } }); {% endif %} {% if roles.stock.view %} addItemTitle('{% trans "Stock" %}'); addItem('stock', '{% trans "Stock Items" %}', 'fa-boxes'); loadStockTable($('#table-stock'), { filterKey: 'stocksearch', url: "{% url 'api-stock-list' %}", params: { original_search: "{{ query }}", part_detail: true, location_detail: true } }); addItem('location', '{% trans "Stock Locations" %}', 'fa-map-marker-alt'); loadStockLocationTable($("#table-location"), { filterKey: 'locationsearch', params: { original_search: "{{ query }}", }, }); {% endif %} {% if roles.purchase_order.view or roles.sales_order.view %} addItemTitle('{% trans "Company" %}'); addItem('manufacturer', '{% trans "Manufacturers" %}', 'fa-industry'); loadCompanyTable('#table-manufacturer', "{% url 'api-company-list' %}", { params: { original_search: "{{ query }}", is_manufacturer: "true", } }); {% if roles.purchase_order.view %} addItem('supplier', '{% trans "Suppliers" %}', 'fa-building'); loadCompanyTable('#table-supplier', "{% url 'api-company-list' %}", { params: { original_search: "{{ query }}", is_supplier: "true", } }); addItem('purchase-order', '{% trans "Purchase Orders" %}', 'fa-shopping-cart'); loadPurchaseOrderTable('#table-purchase-order', { params: { original_search: '{{ query }}', } }); {% endif %} {% if roles.sales_order.view %} addItem('customer', '{% trans "Customers" %}', 'fa-user-tie'); loadCompanyTable('#table-customer', "{% url 'api-company-list' %}", { params: { original_search: "{{ query }}", is_customer: "true", } }); addItem('sales-orders', '{% trans "Sales Orders" %}', 'fa-truck'); loadSalesOrderTable('#table-sales-orders', { params: { original_search: '{{ query }}', } }); {% endif %} {% endif %} {% endblock %}