<?php
if (!defined('BASEPATH')) exit('No direct script access allowed');
class supplier_vendor_management_model extends CI_Model {
    public function __construct() {
        parent::__construct();
        $this->vendor 	= TBL_INVENTORY_VENDOR;
    }
    
    public function list_all() {       
        $this->db->where('status !=', 2);
        $this->db->order_by('id', 'desc');
        return $this->db->get($this->vendor)->result();
    }
    
    public  function insert($data){  
        $this->db->insert($this->vendor, $data);  
        return $this->db->insert_id();
    }   
    
    public function update($data, $id){
        $this->db->where('id', $id);
        $this->db->update($this->vendor, $data);
        return $this->db->affected_rows();
    }
    
    public function get_by_id($id) {
        $this->db->where('id', $id);
        return $this->db->get($this->vendor)->row();
    }
   
    /*public function item_name_exists($category_id = '', $id = '',$name = '') {
        $this->db->where('category_id', $category_id);
        if($id != '')
            $this->db->where('id !=', $id);
       
        $this->db->where('item_name', $name);
        $this->db->where('status !=', 2);
        if($this->db->get($this->vendor)->num_rows())
            return 1;
        else 
            return 0;
    }*/
	
    public function get_last_insert_id() {
        $this->db->select('id');
        $this->db->where('status !=',2);
        $this->db->limit(1);
        $this->db->order_by('id','desc');
        return $this->db->get($this->vendor)->row();
    }
    
}
?>