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

class Model_action_type extends CI_Model {

	public function create_works($data)
	{
		$this->db->insert('action_type_workflow',$data);

		return $this->db->insert_id();
	}

	public function fetch_works($id = null)
	{
		$this->db->select('a.*');
		if($id) $this->db->where('a.id',$id);
		$this->db->where('a.is_delete',0);
		$query = $this->db->get('action_type_workflow a');
		return ($query->num_rows() > 0)?$query->result():null; 
	}

	public function removeWorkflow($id)
	{
		$this->db->set('is_delete',1);
		$this->db->where('id',$id);
		$this->db->update('action_type_workflow');
	}
	
	public function fetchActionList()
	{
		$this->db->where('is_delete',0);
		$query = $this->db->get('_ref__action_type');

		return ($query->num_rows() > 0)?$query->result():null;
	}

	public function createActionType($input)
	{
		$this->db->insert('_ref__action_type',$input);
		return $this->db->insert_id();
	}

	public function updateWorkflow($id,$name)
	{
		$this->db->set('name',$name);
		$this->db->where('id',$id);
		$this->db->update('action_type_workflow');
	}
}
?>