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

class Expenditure_model extends CI_Model {

	function __construct()
    {
     parent::__construct();		
	
    }
	
	//pull all penalties for members in the give corporation
	//SELECT * FROM saccoManager.penalties WHERE user_id IN(SELECT user_id FROM saccoManager.users WHERE corporation_id=2);
	function get_all_projects($corp_id)
	{
		$projectsQuery = "SELECT * FROM saccoManager.expenditure WHERE authorisor IN(SELECT user_id FROM saccoManager.users WHERE corporation_id = {$corp_id});";
		
		$query = $this->db->query($projectsQuery);
		
		if($query->result_array())
		 {
		 	return $query->result_array();
		 }
		 else
		 {
			 return NULL;
		 }
		
	}
	
	
	function get_payment_per_investment($investment_id)
	{
		$sqlQuery = "SELECT * FROM investment_payments WHERE investment_id = $investment_id";
		
		$query = $this->db->query($sqlQuery);
		
		if($query->result_array())
		 {
		 	return $query->result_array();
		 }
		 else
		 {
			 return NULL;
		 }
	}
	
}

?>