<?php 
class Rep_balance_model_thn extends CI_Model {
	
	function get_data($periode) {
		$date = new DateTime($periode);
		$resultM = $date->format('m');
		$resultY = $date->format('Y');
		
		
			
			
		$q = $this->db->query("select MONTHNAME(STR_TO_DATE(a1.bulan, '%m')) as bulan, a1.bulan as bln, sum(a1.besarnya) total, a1.jenis_trans from (select month(a.tanggaltransaksi) bulan, 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 
			and year(a.tanggaltransaksi)='".$resultY."'
			
            UNION ALL
            
select month(a.tanggaltransaksi) bulan, 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 
			and year(a.tanggaltransaksi)='".$resultY."') a1 GROUP BY a1.bulan, a1.jenis_trans  ORDER BY a1.bulan ASC, a1.jenis_trans DESC
		");
		
		return $q->result_array();
	}
	
}