Files
sippd_sambas/eforum/apps/php/index.php
T
2026-01-30 13:07:53 +07:00

102 lines
4.6 KiB
PHP

<?php
/*******************************************************************
Module : /apps/php/index.php
Desc. : PHP - Halaman Utama Desktop
Created By : Siau Pheng ([email protected]).
Created Date : May 24th, 2010.
Last Modified : August 30th, 2020.
(c) 2010 - 2020, 3FONIA Software; WWW.3FONIA.COM.
*******************************************************************/
require_once(__DIR__."/../../../../vendor/autoload.php");
use siaupheng\fonia3\DB\MySQL;
use siaupheng\fonia3\Web\Param;
use siaupheng\fonia3\Web\Form;
use siaupheng\fonia3\Web\Register;
$db = $db ?? new MySQL();
$ajson = [];
$data = Param::Get("data");
if ( $data == "pagu-info" || $data == "pagu-chart" ) {
if ($_SESSION['__WEB_USER']['Level']==2) {
$tot_pagu = 0;
$db->Query("SELECT SUM(Rupiah2) Pagu FROM mus_usulan_desa WHERE Tahun='".$_SESSION['__WEB_APP']['RENC_THN']."' AND KecID IN (".$_SESSION['__WEB_USER']['AK_KEC'].") AND ((JU<3 AND Prio IN (1,2,3,4,5)) OR (JU=3))");
if ($db->Next()) $tot_pagu = $db->Row("Pagu");
$db->Query("SELECT L.K_Lokasi K_Kec,L.N_Lokasi N_Kec,U.Pagu FROM (SELECT KelID,SUM(Rupiah2) Pagu FROM mus_usulan_desa WHERE Tahun='".$_SESSION['__WEB_APP']['RENC_THN']."' AND KecID IN (".$_SESSION['__WEB_USER']['AK_KEC'].") AND ((JU<3 AND Prio IN (1,2,3,4,5)) OR (JU=3)) GROUP BY KelID) U LEFT JOIN para_lokasi L ON (L.LokasiID=U.KelID) ORDER BY L.K_Lokasi");
} else {
$tot_pagu = 0;
$db->Query("SELECT SUM(Rupiah2) Pagu FROM mus_usulan_desa WHERE Tahun='".$_SESSION['__WEB_APP']['RENC_THN']."' AND ((JU<3 AND Prio IN (1,2,3,4,5)) OR (JU=3))");
if ($db->Next()) $tot_pagu = $db->Row("Pagu");
$db->Query("SELECT L.K_Lokasi K_Kec,L.N_Lokasi N_Kec,U.Pagu FROM (SELECT KecID,SUM(Rupiah2) Pagu FROM mus_usulan_desa WHERE Tahun='".$_SESSION['__WEB_APP']['RENC_THN']."' AND ((JU<3 AND Prio IN (1,2,3,4,5)) OR (JU=3)) GROUP BY KecID) U LEFT JOIN para_lokasi L ON (L.LokasiID=U.KecID) ORDER BY L.K_Lokasi");
}
}
if ( $data == "pagu-info" ) {
$pagu_info = '<h4 class="text-end">Rekapitulasi Usulan Forum OPD '.$_SESSION['__WEB_APP']['RENC_THN'].'</h4>';
$pagu_info .= '<table class="table table-striped">';
$pagu_info .= '<thead><tr role="row"><th>'.($_SESSION['__WEB_USER']['Level']==7?"Indikator":($_SESSION['__WEB_USER']['Level']==2?"Kelurahan / Desa":"Kecamatan")).'</th><th>Total Anggaran</th></tr></thead><tbody>';
while ($db->Next()){
$pagu_info .= sprintf('<tr role="row"><td class="left">%s</td><td class="right">%s</td></tr>', $db->Row("N_Kec"), rupiah2($db->Row("Pagu")));
}
$pagu_info .= '</tbody></table>';
$ajson['html'] = $pagu_info;
} else if ( $data == "pagu-chart" ) {
$ajson['datasets'] = array();
$ajson['labels'] = array();
$atmp = array(); $acol = array();
$atmp[] = 100;
$col_r = mt_rand( 0, 255 );
$col_g = mt_rand( 0, 255 );
$col_b = mt_rand( 0, 255 );
$acol[] = "rgb(".$col_r.",".$col_g.",".$col_b.")";
$ajson['labels'][] = "Belum Ada Usulan";
if ($db->RecordCount()>0) {
$atmp = array();
$acol = array();
$ajson['labels'] = array();
}
while ($db->Next()){
$atmp[] = round($db->Row("Pagu") / $tot_pagu * 100, 2);
$col_r = mt_rand( 0, 255 );
$col_g = mt_rand( 0, 255 );
$col_b = mt_rand( 0, 255 );
$acol[] = "rgb(".$col_r.",".$col_g.",".$col_b.")";
$ajson['labels'][] = $db->Row("N_Kec");
}
$ajson['datasets'][] = array('data'=>$atmp, 'backgroundColor'=>$acol);
} else if ( $data == "default" ) {
$aapp = $_SESSION['__WEB_APP'];
$ajson['content'] = '
<div class="row">
<div class="col-sm-12 col-md-6 d-flex align-items-stretch">
<div class="card w-100 h-100"><div class="card-body d-flex flex-column" id="divHome1">
<div class="my-auto text-center"><img class="img-fluid" src="'.$aapp['WEB_PATH'].'assets/images/logo300.png" title="'.$aapp['REG_NAME'].'" style="width:25%">
<p class="mt-2">'.$aapp['REG_ADDRESS'].'<br>
'.$aapp['REG_CITY'].' '.$aapp['REG_POSTCODE'].'</p>
<p class="mt-3 mb-3"><i>Register ID : '.Register::reg_id().'</i></p>
<p>'.$aapp['APP_NAMES'].'<br>'.$aapp['APP_NAME'].' Ver. '.$aapp['APP_VER'].'<br>
Updated : '.$aapp['APP_UPDATED'].'</p></div>
</div></div>
</div>
<div class="col-sm-12 col-md-6 d-flex align-items-stretch">
<div class="card w-100 h-100"><div class="card-body d-flex flex-column" id="divHome2">
<div class="chart-wrapper pb-2">
<canvas id="pieChart"></canvas>
</div>
</div></div>
</div>
</div>
';
}
send_json($ajson);
?>