<?php 
class Rep_balance_model_all extends CI_Model {
	
	function get_data($periode) {
		
		$date = new DateTime($periode);
		$resultM = $date->format('m');
		$resultY = $date->format('Y');
		
		
			
			
		$q = $this->db->query("select a1.tahun, sum(a1.besarnya) total, a1.jenis_trans from (select year(a.tanggaltransaksi) tahun, a.besarnya, SUBSTRING(a.no, 1, 2) as jenis_trans
			from trans_uang_keluar a, ref_list_uang_keluar b 
			where a.kodedesk = b.kodedesk 
			and a.kodesub = b.kodesub 
			
            UNION ALL
            
select year(a.tanggaltransaksi) tahun, a.besarnya, SUBSTRING(a.no, 1, 2) as jenis_trans
			from trans_uang_masuk a, ref_list_uang_masuk b 
			where a.kodedesk = b.kodedesk 
			and a.kodesub = b.kodesub) a1 GROUP BY a1.tahun, a1.jenis_trans  ORDER BY a1.tahun ASC, a1.jenis_trans DESC
		");
		
		return $q->result_array();
		
		
	}
	
}