<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
require_once('core_model.php');
class Warehouse_Model extends Core_Model {
 
  public $table_config=array(
      'mater_table'=>'warehouses',
      'master_table_primary_id'=>'id',
      'master_table_seconrary_id'=>'',
      'item_table'=>'',
      'item_table_primary_id'=>'',
      'item_table_seconrary_id'=>'',
      'sub_item_table'=>'',
      'sub_item_table_primary_id'=>'',
      'sub_item_table_seconrary_id'=>'',
      );
  
  function __construct() 
  {
    /* Call the Model constructor */
    parent::__construct($this->table_config);
  }

	function save_warehouse(&$warehouse_data,$warehouse_id=false)
	{
		if (!$warehouse_id)
		{
			$this->save_master_table($warehouse_data);
		}else {
			$this->update_master_table_by_primary_id($warehouse_id,$warehouse_data);
		}
	}
	function get_all_warehouse() {
	    return $this->get_result_mater_record_data();
	}
	public function get_warehouse_info($id)
	 {
	     return $this->get_row_array_mater_record_data_by_primary_id($id);
	 }
	public function delete_warehouse($warehouse_id)
	{
	    return $this->delete_master_table_by_primary_id($warehouse_id);
	}
	public function disable_warehouse($warehouse_id)
	{
		$data = array(
			'status' => 0
		);	
	    $this->update_master_table_by_primary_id($warehouse_id,$data);
	}
	public function enable_warehouse($warehouse_id)
	{
		$data = array(
			'status' => 1
		);	
		 $this->update_master_table_by_primary_id($warehouse_id,$data);
	}
}