<?php

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

class Searchmaterials extends CI_Controller {

    function __construct() {
        parent::__construct();
    }

    //FOR AUTOCOMPLETE TO GET MATERIAL FROM TABLE
    function getmaterialautocomplete() {
        $term = $this->input->post('term', TRUE);
        $this->load->model('inventory/products_model');
        $rows = $this->products_model->getmaterialautocomplete($term);
        $keywords = array();
        foreach ($rows as $row)
            array_push($keywords, $row->NAME);
        echo json_encode($keywords);
    }
    function materialautocomplete() {
        $term = $this->input->post('term', TRUE);
        $this->load->model('inventory/products_model');
        $rows = $this->products_model->materialautocomplete($term);
        $keywords = array();
        foreach ($rows as $row)
            array_push($keywords, $row->NAME);
        echo json_encode($keywords);
    }
    //FOR AUTOCOMPLETE TO GET MATERIALS REFERENCE NUMBER FROM TABLE
    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 getmatreferenceautocomplete() {
        $term = $this->input->post('term', TRUE);
        $this->load->model('inventory/products_model');
        $rows = $this->products_model->getmatreferenceautocomplete($term);
        $keywords = array();
        foreach ($rows as $row)
            array_push($keywords, $row->REFERENCE);
        echo json_encode($keywords);
    }
}