<?php
$sql['get_minmax_tahun_transaksi'] = "
   SELECT
      YEAR(MIN(transTanggal)) - 5 AS minTahun,
      YEAR(MAX(transTanggal)) + 5 AS maxTahun
   FROM
      transaksi
";

$sql['get_laporan_all'] = "
   SELECT 
      kelJnsOrderBy, 
      kellapId,
      kellapJnsId,
      kelJnsNama,
      nama_kel_lap,     
      `status`,
     IFNULL(SUM(nilai),0) AS nilai
   FROM(
   SELECT 
         kelJnsOrderBy, 
         kellapId,
         kellapJnsId,
         kelJnsNama,
         kellapNama AS nama_kel_lap,     
         kellapIsTambah AS `status`,
      (SELECT bbSaldoAkhir FROM buku_besar_his WHERE bbCoaId = coakellapCoaId AND bbTanggal<='%s' ORDER BY bbhisId DESC LIMIT 0,1) AS nilai
      FROM kelompok_laporan_ref
      LEFT JOIN kelompok_jenis_laporan_ref ON kellapJnsId = kelJnsId
      LEFT JOIN coa_kelompok_laporan_ref ON coakellapIdKellap = kellapId
            WHERE 
            kelJnsPrntId = '14'
      ORDER BY kellapIsTambah, kelJnsOrderBy, kellapJnsId
   ) a %s
   GROUP BY kellapId
";

?>
