<?php

class Data_pemeriksaan_tindakan_model extends CI_Model {
	
	private $_error = "";
	private $_table_name = "data_pemeriksaan_tindakan";
	private $_table_sql = "data_pemeriksaan_tindakan d_pt";

	public function tabel_tindakan($context)
	{		
		$pemeriksaan_id = $context['pemeriksaan_id'];

		$this->db->select('d_pt.*, 
			a_kt.value AS kategori_value');		
		$this->db->from($this->_table_sql);
		$this->db->join('data_tindakan d_t', 'd_t.id=d_pt.tindakan_id', 'left');	
		$this->db->join('asset_kategori_tindakan a_kt', 'a_kt.id=d_t.kategori', 'left');	
		$this->db->where('pemeriksaan_id', $pemeriksaan_id);

		return $this->db->get()->result();
	}

	//--------------------------------------------------------------------------------------------

	public function mysql_get_error()
	{
		$error = $this->db->error();

		switch ($error['code']) 
		{
			case '1062':
			$error_detail = 'Data sudah ada';
			break;

			default:
			$error_detail = "$error[code]: $error[message]";
			break;
		}

		return $error_detail;		
	}

}	