first commit
This commit is contained in:
@@ -0,0 +1,149 @@
|
||||
<?php
|
||||
|
||||
/*******************************************************************
|
||||
|
||||
PHP Class : /Controller/Report/Gel/HarianjurnalController
|
||||
Description : Laporan Jurnal Harian
|
||||
Created By : Siau Pheng ([email protected]).
|
||||
Created Date : December 16th, 2008.
|
||||
Last Modified : October 22nd, 2026.
|
||||
|
||||
(c) 3FONIA Software; WWW.3FONIA.COM.
|
||||
|
||||
*******************************************************************/
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace App\Controller\Report\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 HarianjurnalController {
|
||||
|
||||
private string $reg_name;
|
||||
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'];
|
||||
}
|
||||
|
||||
private function prepare() {
|
||||
$apre = [
|
||||
'id_tipe' => Param::Int("TipeID"),
|
||||
'tgl_from' => Param::Get("Tgl_From"),
|
||||
'tgl_to' => Param::Get("Tgl_To"),
|
||||
];
|
||||
|
||||
$apre['nama_tipe'] = ($apre['id_tipe'] > 0) ? ($this->db->fetchField("SELECT Nama_Tipe FROM gel_tipe WHERE TipeID=?", [$apre['id_tipe']]) ?? '') : '';
|
||||
|
||||
// generate report header
|
||||
$apre['periode'] = $apre['tgl_from'] . ($apre['tgl_from'] !== $apre['tgl_to'] ? ' s/d '.$apre['tgl_to'] : '');
|
||||
|
||||
$tsql = ''; $asql = [tgl_sql2str($apre['tgl_from']), tgl_sql2str($apre['tgl_to'])];
|
||||
if ($apre['id_tipe'] > 0) {
|
||||
$tsql .= " AND TipeID=?";
|
||||
array_push($asql, $apre['id_tipe']);
|
||||
}
|
||||
|
||||
$apre['query'] = $this->db->runQuery("SELECT D.Kode_Jurnal, D.Kode_Rek, A.Nama_Rek, J.Catatan, IF(D.DK='D',D.Jumlah,0) Debit, IF(D.DK='K',D.Jumlah*-1,0) Kredit FROM (SELECT * FROM gel_jurnal_detail WHERE Tgl_Ref BETWEEN ? AND ?".$tsql.") D LEFT JOIN gel_jurnal J ON (D.Kode_Jurnal=J.Kode_Jurnal) LEFT JOIN gel_acc A ON (D.Kode_Rek=A.Kode_Rek) ORDER BY D.Kode_Jurnal, D.DK", $asql);
|
||||
return $apre;
|
||||
}
|
||||
|
||||
public function print() {
|
||||
$apre = $this->prepare();
|
||||
|
||||
$pre = new PrintHTML($this->app);
|
||||
$pre->add_title([strtoupper($this->reg_name), "JURNAL HARIAN", "Periode : ".$apre['periode']]);
|
||||
|
||||
$pre->add_field("Kode Jurnal",20,"C");
|
||||
$pre->add_field("Kode",15,"C");
|
||||
$pre->add_field("Nama Rekening",100,"L");
|
||||
$pre->add_field("Deskripsi",150,"L");
|
||||
$pre->add_field("Debit",20,"R","rupiah");
|
||||
$pre->add_field("Kredit",20,"R","rupiah");
|
||||
|
||||
if ($apre['id_tipe'] > 0) $pre->add_sub_title("Tipe Jurnal : ".$apre['nama_tipe']);
|
||||
|
||||
$pre->show_titles();
|
||||
$pre->show_headers();
|
||||
|
||||
$tot_debit = 0; $tot_kredit = 0;
|
||||
while ($row = $apre['query']->fetch(SimplePdo::FETCH_ASSOC)) {
|
||||
$tot_debit += $row['Debit'];
|
||||
$tot_kredit += $row['Kredit'];
|
||||
|
||||
$pre->add_row([ $row['Kode_Jurnal'], $row['Kode_Rek'], $row['Nama_Rek'], $row['Catatan'], $row['Debit'], $row['Kredit'] ]);
|
||||
}
|
||||
$pre->add_span([ ["TOTAL",4,"R,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 Jurnal Harian",
|
||||
'desc' => "Export Data Jurnal Harian"
|
||||
]);
|
||||
$xls->add_title([ $this->reg_name, "DATA JURNAL HARIAN", "Periode : ".$apre['periode'] ]);
|
||||
|
||||
$xls->add_field("Kode Jurnal", 12, "@text");
|
||||
$xls->add_field("Kode", 10, "@text");
|
||||
$xls->add_field("Nama Rekening", 30, "@text");
|
||||
$xls->add_field("Deskripsi", 40, "@text");
|
||||
$xls->add_field("Debit", 15, "#,##0.00");
|
||||
$xls->add_field("Kredit", 15, "#,##0.00");
|
||||
$xls->add_sheet("".str_replace("s/d","-",$apre['periode']));
|
||||
|
||||
if ($apre['id_tipe'] > 0) $xls->add_sub_title("Tipe Jurnal : ".$apre['nama_tipe']);
|
||||
|
||||
$xls->show_titles();
|
||||
$xls->show_headers();
|
||||
|
||||
$tot_debit = 0; $tot_kredit = 0;
|
||||
while ($row = $apre['query']->fetch(SimplePdo::FETCH_ASSOC)) {
|
||||
$tot_debit += $row['Debit'];
|
||||
$tot_kredit += $row['Kredit'];
|
||||
|
||||
$xls->add_row([ $row['Kode_Jurnal'], $row['Kode_Rek'], $row['Nama_Rek'], $row['Catatan'], $row['Debit'], $row['Kredit'] ]);
|
||||
}
|
||||
$xls->add_row_bold([ "", "", "TOTAL", "", $tot_debit, $tot_kredit ]);
|
||||
|
||||
$xls->add_stamp(1, true);
|
||||
$xls->download("Data Jurnal Harian ".str_replace("s/d","-",$apre['periode']).".xlsx");
|
||||
unset($xls);
|
||||
}
|
||||
|
||||
public function index() {
|
||||
$form = new Form($this->app);
|
||||
$ttipe = $form->option_db("_", "TipeID", 0, true, false, "gel_tipe", ["TipeID","Nama_Tipe"], "Aktif=1", [0,"SEMUA TIPE"]);
|
||||
$tfrom = $form->datebox("_", "Tgl_From", tgl_ymd(), true, false);
|
||||
$tto = $form->datebox("_", "Tgl_To", tgl_ymd(), true, false);
|
||||
$this->app->json([ 'html' => '
|
||||
<div class="row mb-1">
|
||||
<label class="col-sm-6 col-lg-4 col-form-label" for="TipeID">Tipe Jurnal</label>
|
||||
<div class="col">'.$ttipe.'</div>
|
||||
</div>
|
||||
<div class="row mb-1">
|
||||
<label class="col-sm-6 col-lg-4 col-form-label" for="Tgl_From">Dari Tanggal</label>
|
||||
<div class="col-sm-6 col-lg-6">'.$tfrom.'</div>
|
||||
</div>
|
||||
<div class="row mb-1">
|
||||
<label class="col-sm-6 col-lg-4 col-form-label" for="Tgl_To">Sampai Tanggal</label>
|
||||
<div class="col-sm-6 col-lg-6">'.$tto.'</div>
|
||||
</div>'
|
||||
]);
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user