app = $app; $this->db = $db; $this->reg_name = $session->get('WEB_APP')['REG_NAME']; $this->gel = new Gel($app); } private function prepare() { $apre = [ 'tipe' => Param::Int("Tipe"), // 1: rekap, 2: bulanan 'bulan' => Param::Int("Bulan"), 'tahun' => Param::Int("Tahun"), ]; $tgl_akhir = tgl_akhbln("01-".isi_nol($apre['bulan'],2)."-".(string) $apre['tahun']); // generate report header $apre['periode'] = '01-'.($apre['tipe'] === 2 ? isi_nol($apre['bulan'],2) : '01').'-'.(string) $apre['tahun'].' s/d '.$tgl_akhir; // hitung total saldo rekening dari gel_rekap $tjml = "R.Open"; for ($i=1; $i<=$apre['bulan']; $i++) $tjml .= "+R.Muta_".isi_nol($i, 2); $tjml = ($apre['tipe'] === 1) ? $tjml : "R.Muta_".isi_nol($apre['bulan'], 2); $apre['query'] = $this->db->runQuery("SELECT R.Kode_Rek, A.Nama_Rek, ".$tjml." Jumlah FROM (SELECT * FROM gel_rekap WHERE Tahun=?) R LEFT JOIN gel_acc A ON (R.Kode_Rek=A.Kode_Rek) WHERE ".$tjml."<>0 ORDER BY R.Kode_Rek", [$apre['tahun']]); return $apre; } public function print() { $apre = $this->prepare(); $pre = new PrintHTML($this->app); $pre->add_title([strtoupper($this->reg_name), "NERACA SALDO", "Periode : ".$apre['periode']]); $pre->add_field("No.",10,"C"); $pre->add_field("Kode",20,"C"); $pre->add_field("Nama Rekening",150,"L"); $pre->add_field("Debit",50,"R","rupiah"); $pre->add_field("Kredit",50,"R","rupiah"); $pre->show_titles(); $pre->show_headers(); $nomor = 0; $tot_debit = 0; $tot_kredit = 0; while ($row = $apre['query']->fetch(SimplePdo::FETCH_ASSOC)) { $ndebit = ($row['Jumlah'] > 0) ? $row['Jumlah'] : 0; $nkredit = ($row['Jumlah'] < 0) ? abs($row['Jumlah']) : 0; $tot_debit += $ndebit; $tot_kredit += $nkredit; $pre->add_row([ ++$nomor, $row['Kode_Rek'], $row['Nama_Rek'], $ndebit, $nkredit ]); } $pre->add_span([ ["TOTAL SALDO",3,"L,B"],[$tot_debit,1,"R,B","rupiah"],[$tot_kredit,1,"R,B","rupiah"] ]); $pre->add_stamp(1, true); $pre->show(); } public function excel() { $apre = $this->prepare(); $xls = new Xlsx($this->app); $xls->set_meta([ 'title' => "Data Neraca Saldo", 'desc' => "Export Data Neraca Saldo" ]); $xls->add_title([ $this->reg_name, "NERACA SALDO", "Periode : ".$apre['periode'] ]); $xls->add_field("No.", 5, "@integer"); $xls->add_field("Kode", 10, "@text"); $xls->add_field("Nama Rekening", 40, "@text"); $xls->add_field("Debit", 20, "#,##0.00"); $xls->add_field("Kredit", 20, "#,##0.00"); $xls->add_sheet("".str_replace("s/d","-",$apre['periode'])); $xls->show_titles(); $xls->show_headers(); $nomor = 0; $tot_debit = 0; $tot_kredit = 0; while ($row = $apre['query']->fetch(SimplePdo::FETCH_ASSOC)) { $ndebit = ($row['Jumlah'] > 0) ? $row['Jumlah'] : 0; $nkredit = ($row['Jumlah'] < 0) ? abs($row['Jumlah']) : 0; $tot_debit += $ndebit; $tot_kredit += $nkredit; $xls->add_row([ ++$nomor, $row['Kode_Rek'], $row['Nama_Rek'], $ndebit, $nkredit ]); } $xls->add_row_bold([ "", "", "TOTAL SALDO", $tot_debit, $tot_kredit ]); $xls->add_stamp(1, true); $xls->download("Data Neraca Saldo ".str_replace("s/d","-",$apre['periode']).".xlsx"); unset($xls); } public function index() { $form = new Form($this->app); $ttipe = $form->radio("_", "Tipe", 1, true, false, [1=>"Akumulasi", 2=>"Bulanan"]); $tbulan = $form->option("_", "Bulan", date("n"), true, false, bulan_array()); $ttahun = $form->option("_", "Tahun", date("Y"), true, false, $this->gel->Tahun_Array()); $this->app->json([ 'html' => '