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

class Bulkload_model extends CI_Model {

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

        function loadcategory($data){
                    
            return $this->db->insert('CATEGORIES', $data);
                
        }
        
        function loadproduct($data){
            return $this->db->insert('PRODUCTS', $data);
        }

        function loadstock($data){
            return $this->db->insert('STOCKCURRENT', $data);
        }

        
        function getcategoryid($catname){
            
            $this->db->select('ID');
            $this->db->where("NAME LIKE '$catname'");
                    $q = $this->db->get('CATEGORIES')->result();
                    if($q)
                    {
                    return $q[0]->ID;
                    }
                else {
                    return null;
                }
                
        }
        
        function getproductid($code){
            $this->db->select('ID');
//            $this->db->like('CODE', $code);
            $this->db->where("CODE='$code'");
            $q = $this->db->get('PRODUCTS')->result();
            if($q) {
                return $q[0]->ID;
            } else {
                return null;
            }
        }
        
        function getproductcode($code){
            $this->db->select('ID');
            $this->db->where("CODE='$code'");
            $q = $this->db->get('PRODUCTS')->result();
            if($q) {
                return $q[0]->ID;
            } else {
                return '';
            }
        }
        
}