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

class Model_recurring_deduction extends CI_Model {

	//max id need to be max from both table because same forms
	public function fetchDeduction($staff_id = null, $latest = false, $profiling_id = null)
	{
		$this->db->select('a.*');
		if($staff_id) $this->db->where('a.user_id',$staff_id);
		if($profiling_id) $this->db->where('a.profiling_id',$profiling_id);

		$this->db->where('is_delete',0);
		$query = $this->db->get('user__recur_deduction a');

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

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

	public function editDeduction($input,$id)
	{
		$this->db->set($input);
		$this->db->where('id',$id);
		$this->db->update('user__recur_deduction');
	}
}
?>