first commit

This commit is contained in:
2026-10-29 13:34:31 +07:00
commit 45e4595c57
255 changed files with 35457 additions and 0 deletions
@@ -0,0 +1,142 @@
<?php
/*******************************************************************
PHP Class : /Controller/Report/Gel/BulansaldoController
Description : Laporan Neraca Saldo Bulanan
Created By : Siau Pheng ([email protected]).
Created Date : July 12th, 2008.
Last Modified : October 24th, 2026.
(c) 3FONIA Software; WWW.3FONIA.COM.
*******************************************************************/
declare(strict_types=1);
namespace App\Controller\Report\Gel;
use App\Utils\Gel;
use flight\Engine;
use flight\database\SimplePdo;
use flight\Session;
use Webapp\Data\Xlsx;
use Webapp\Printer\PrintHTML;
use Webapp\Web\Form;
use Webapp\Web\Param;
class BulansaldoController {
private string $reg_name;
private Gel $gel;
protected Engine $app;
protected SimplePdo $db;
public function __construct(Engine $app, SimplePdo $db, Session $session) {
$this->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' => '
<div class="row mb-1">
<label class="col-sm-6 col-lg-4 col-form-label" for="Tipe">Tipe Laporan</label>
<div class="col">'.$ttipe.'</div>
</div>
<div class="row mb-1">
<label class="col-sm-6 col-lg-4 col-form-label" for="Bulan">Periode Laporan</label>
<div class="col"><div class="input-group">'.$tbulan.$ttahun.'</div></div>
</div>'
]);
}
}