<?php 
class Parts_model extends CI_Model {
	public function _consruct(){
		parent::_construct();
	}

public function add_Parts($PartsData){
		$qry = $this->db->insert('parts',$PartsData);

		if ($this->db->trans_status() === TRUE)
		{
			$this->db->trans_commit();
			return TRUE;
		}else
		{
			$this->db->trans_rollback();
			return false;
		}
	}

public function getPartsData($Parts_id='',$view=''){

		$cond  = (!empty($view))?" status IN ($view) ":" status != '2' ";
		$cond .= (!empty($Parts_id))?" AND id='$Parts_id' ":"";

		$PartsData = $this->db->query("SELECT * FROM parts WHERE $cond Order by id DESC");

		if(!empty($PartsData)){
			return (empty($Parts_id))?$PartsData->result():$PartsData->row();
		}
		return 0;
	}

public function update_Parts($id,$PartsData)
	{


		$this->db->where('id',$id);
		$qry = $this->db->update('parts',$PartsData);
		return true;


	}

	function changeStatus($Parts_id = '', $status = '0'){

 		if(empty($Parts_id)){
 			return 0;
 		}
 		$status = $this->db->update('parts',array('status'=>$status),array('id'=>$Parts_id));
 		return $status;
 	}





}