This commit is contained in:
		@@ -9,7 +9,20 @@ exports.getSearch = async function(req, res) {
 | 
				
			|||||||
  let query = req.query.query;
 | 
					  let query = req.query.query;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  // fetch inventory items from database based on search query
 | 
					  // fetch inventory items from database based on search query
 | 
				
			||||||
  const results = await Item.findAll({
 | 
					  const item_results = await Item.findAll({
 | 
				
			||||||
 | 
					    where: {
 | 
				
			||||||
 | 
					      name: {
 | 
				
			||||||
 | 
					        [Op.like]: '%' + query + '%',
 | 
				
			||||||
 | 
					      }
 | 
				
			||||||
 | 
					    },
 | 
				
			||||||
 | 
					    limit: 10,
 | 
				
			||||||
 | 
					    order: [
 | 
				
			||||||
 | 
					      ['updatedAt', 'DESC'],
 | 
				
			||||||
 | 
					    ],
 | 
				
			||||||
 | 
					  });
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					  // fetch licenses from database based on search query
 | 
				
			||||||
 | 
					  const license_results = await License.findAll({
 | 
				
			||||||
    where: {
 | 
					    where: {
 | 
				
			||||||
      name: {
 | 
					      name: {
 | 
				
			||||||
        [Op.like]: '%' + query + '%',
 | 
					        [Op.like]: '%' + query + '%',
 | 
				
			||||||
@@ -23,6 +36,7 @@ exports.getSearch = async function(req, res) {
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
  res.render('search.twig', {
 | 
					  res.render('search.twig', {
 | 
				
			||||||
    query: query,
 | 
					    query: query,
 | 
				
			||||||
    results: results,
 | 
					    item_results: item_results,
 | 
				
			||||||
 | 
					    license_results: license_results,
 | 
				
			||||||
  });
 | 
					  });
 | 
				
			||||||
};
 | 
					};
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -11,8 +11,10 @@
 | 
				
			|||||||
  </div>
 | 
					  </div>
 | 
				
			||||||
</header>
 | 
					</header>
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					{% if item_results|len > 0 %}
 | 
				
			||||||
  <section id="search-results" class="row">
 | 
					  <section id="search-results" class="row">
 | 
				
			||||||
    <div class="columns twelve">
 | 
					    <div class="columns twelve">
 | 
				
			||||||
 | 
					      <h3>Hardware components:</h3>
 | 
				
			||||||
      <table class="u-full-width">
 | 
					      <table class="u-full-width">
 | 
				
			||||||
        <thead>
 | 
					        <thead>
 | 
				
			||||||
          <tr>
 | 
					          <tr>
 | 
				
			||||||
@@ -22,7 +24,7 @@
 | 
				
			|||||||
          </tr>
 | 
					          </tr>
 | 
				
			||||||
        </thead>
 | 
					        </thead>
 | 
				
			||||||
        <tbody>
 | 
					        <tbody>
 | 
				
			||||||
        {% for item in results %}
 | 
					          {% for item in item_results %}
 | 
				
			||||||
            <tr>
 | 
					            <tr>
 | 
				
			||||||
              <td><a href="/item/{{ item.id }}">{{ item.name }}</a></td>
 | 
					              <td><a href="/item/{{ item.id }}">{{ item.name }}</a></td>
 | 
				
			||||||
              <td>{{ item.type }}</td>
 | 
					              <td>{{ item.type }}</td>
 | 
				
			||||||
@@ -33,5 +35,32 @@
 | 
				
			|||||||
      </table>
 | 
					      </table>
 | 
				
			||||||
    </div>
 | 
					    </div>
 | 
				
			||||||
  </section>
 | 
					  </section>
 | 
				
			||||||
 | 
					{% endif %}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					{% if license_results|len > 0 %}
 | 
				
			||||||
 | 
					  <section id="search-results" class="row">
 | 
				
			||||||
 | 
					    <div class="columns twelve">
 | 
				
			||||||
 | 
					      <h3>Software licenses:</h3>
 | 
				
			||||||
 | 
					      <table class="u-full-width">
 | 
				
			||||||
 | 
					        <thead>
 | 
				
			||||||
 | 
					          <tr>
 | 
				
			||||||
 | 
					            <th>Name</th>
 | 
				
			||||||
 | 
					            <th>Vendor</th>
 | 
				
			||||||
 | 
					            <th>Updated at</th>
 | 
				
			||||||
 | 
					          </tr>
 | 
				
			||||||
 | 
					        </thead>
 | 
				
			||||||
 | 
					        <tbody>
 | 
				
			||||||
 | 
					          {% for license in license_results %}
 | 
				
			||||||
 | 
					            <tr>
 | 
				
			||||||
 | 
					              <td><a href="/item/{{ license.id }}">{{ license.name }}</a></td>
 | 
				
			||||||
 | 
					              <td>{{ license.manufacturer }}</td>
 | 
				
			||||||
 | 
					              <td>{{ license.updatedAt | date("m/d/Y h:i:s A") }}</td>
 | 
				
			||||||
 | 
					            </tr>
 | 
				
			||||||
 | 
					          {% endfor %}
 | 
				
			||||||
 | 
					        </tbody>
 | 
				
			||||||
 | 
					      </table>
 | 
				
			||||||
 | 
					    </div>
 | 
				
			||||||
 | 
					  </section>
 | 
				
			||||||
 | 
					{% endif %}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
{% endblock %}
 | 
					{% endblock %}
 | 
				
			||||||
 
 | 
				
			|||||||
		Reference in New Issue
	
	Block a user