<?php

if (!defined('BASEPATH'))
    exit('No direct script access allowed');

class Searchproducts extends CI_Controller {

    function __construct() {
        parent::__construct();
    }
    //FOR AUTOCOMPLETE TO GET PRODUCTS FROM TABLE
    function getproductsautocomplete() {
        $term = $this->input->post('term', TRUE);
        $this->load->model('inventory/products_model');
        $rows = $this->products_model->getproductsautocomplete($term);
        $keywords = array();
        foreach ($rows as $row)
            array_push($keywords, $row->NAME);
        echo json_encode($keywords);
    }
       //FOR AUTOCOMPLETE TO GET PRODUCTS FROM TABLE
    function getproductsautocompleteforpblocation() {
        $term = $this->input->post('term', TRUE);
        $this->load->model('inventory/products_model');
        $rows = $this->products_model->getproductsautocompleteforpblocation($term);
        $keywords = array();
        foreach ($rows as $row)
            array_push($keywords, $row->NAME);
        echo json_encode($keywords);
    }
    function getreferenceautocomplete() {
        $term = $this->input->post('term', TRUE);
        $this->load->model('inventory/products_model');
        $rows = $this->products_model->getreferenceautocomplete($term);
        $keywords = array();
        foreach ($rows as $row)
            array_push($keywords, $row->REFERENCE);
        echo json_encode($keywords);
    }
    function getauxiparentproductsautocomplete() {
        $term = $this->input->post('term', TRUE);
        $this->load->model('inventory/products_model');
        $rows = $this->products_model->getauxiparentproductsautocomplete($term);
        $keywords = array();
        foreach ($rows as $row)
            array_push($keywords, $row->NAME);
        echo json_encode($keywords);
    }
    function getauxiproductsautocomplete() {
        $term = $this->input->post('term', TRUE);
        $this->load->model('inventory/products_model');
        $rows = $this->products_model->getauxiproductsautocomplete($term);
        $keywords = array();
        foreach ($rows as $row)
            array_push($keywords, $row->NAME);
        echo json_encode($keywords);
        }
   function getitemsautocomplete() {
        $term = $this->input->post('term', TRUE);
        $this->load->model('inventory/products_model');
        $rows = $this->products_model->getitemsautocomplete($term);
        $keywords = array();
        foreach ($rows as $row)
            array_push($keywords, $row->NAME);
        echo json_encode($keywords);
    }
}