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

class Fixed_Assets_Model extends CI_Model {
	 function __construct(){
		 parent::__construct();
		 }
    function fixed_assets_type_list(){
	$this->db->select('*');	
	$this->db->from('fixed_assets_type');
	$this->db->where('fa_type_status',1);
	$query=$this->db->get();
	return $query->result_array();
		}		 
	function save_fixed_assets(&$data,$fxd_ass_id=false)
	{
		if (!$fxd_ass_id)
		{
			$this->db->insert('fixed_asset',$data);
		}else {
			$this->db->where('fxd_ass_id', $fxd_ass_id);
			return $this->db->update('fixed_asset',$data);
		}
	}
	function get_fixed_asset_list()
	{
		$this->db->select('fixed_asset.*');
		$this->db->select('fixed_assets_type.*');
		$this->db->select('fixed_assets_master.*');
		$this->db->from('fixed_asset');
		$this->db->join('fixed_assets_type','fixed_asset.fa_type_id=fixed_assets_type.fa_type_id','left');
		$this->db->join('fixed_assets_master','fixed_assets_master.fam_id=fixed_assets_type.fam_id','left');
		$query=$this->db->get();
		return $query->result_array();
	}
	function get_fixed_asset_details($fxd_ass_id)
	{
	$this->db->select('*');
	$this->db->from('fixed_asset');	
	$this->db->where('fxd_ass_id',$fxd_ass_id);
	$query=$this->db->get();
	return $query->row_array();
	}
	
	function get_fixed_asset_vehical(){
		$this->db->select('fixed_asset.fxd_ass_id,fixed_asset.fxd_ass_name');
		$this->db->from('fixed_asset');
		$this->db->join('fixed_assets_type','fixed_assets_type.fa_type_id=fixed_asset.fa_type_id','left');
		$this->db->where('fixed_asset.fxd_ass_status',1);
		$this->db->where('fixed_assets_type.fa_type_id',1);
		$this->db->where('fixed_assets_type.fa_type_status',1);
		$query=$this->db->get();
		return $query->result_array();
		}
}