142 lines
4.5 KiB
PHP
142 lines
4.5 KiB
PHP
<?php
|
|
|
|
namespace App\Http\Controllers\Admin;
|
|
use App\Http\Controllers\Controller;
|
|
use Illuminate\Http\Request;
|
|
use Session;
|
|
use App\Models\Tropd;
|
|
use App\Models\User;
|
|
use Hash;
|
|
use Illuminate\Support\Facades\DB;
|
|
use App\Models\AkbSpb23;
|
|
use App\Models\AkbPendapatan;
|
|
|
|
class PengaturanController extends Controller
|
|
{
|
|
public function __construct(){
|
|
$this->siteTitle = "Pengaturan";
|
|
parent::__construct();
|
|
}
|
|
|
|
public function index()
|
|
{
|
|
$this->setIconTitle("fa fa-cog");
|
|
return view('admin.pengaturan.index');
|
|
}
|
|
|
|
public function rekonAnggaran()
|
|
{
|
|
try{
|
|
DB::beginTransaction();
|
|
|
|
DB::statement(
|
|
"UPDATE BELANJA_REALISASI t1
|
|
SET t1.JUMLAH_ANGGARAN = (
|
|
SELECT V_ANGG_TAPD FROM VW_DPA_RSK t2
|
|
WHERE t1.KODE_RSK = t2.I_ID
|
|
) WHERE t1.TAHUN_ANGGARAN = ".getTA()
|
|
);
|
|
DB::statement("UPDATE BELANJA_REALISASI SET ALOKASI_ANGGARAN = JUMLAH_ANGGARAN WHERE JENIS_DANA IN ('DBH','DAK')");
|
|
|
|
DB::commit();
|
|
|
|
return response()->json([
|
|
"success" => true,
|
|
"message" => "Data anggaran berhasil disesuaikan!"
|
|
]);
|
|
|
|
}catch(Throwable $e){
|
|
|
|
DB::rollBack();
|
|
return response()->json([
|
|
"success" => false,
|
|
"message" => "Data anggaran gagal disesuaikan!"
|
|
]);
|
|
}
|
|
}
|
|
|
|
public function adjustAKBPendapatan()
|
|
{
|
|
try{
|
|
DB::beginTransaction();
|
|
|
|
$dataAKBPendapatan = AkbSpb23::getAkbPendapatan();
|
|
foreach($dataAKBPendapatan as $rowAKBPendapatan){
|
|
AkbPendapatan::updateOrCreate([
|
|
"tahun"=>getTA(),
|
|
"skpd_id"=>$rowAKBPendapatan->unitkerja_id,
|
|
"kode_rekening"=>$rowAKBPendapatan->rek_kode
|
|
],[
|
|
"nama_rekening"=>$rowAKBPendapatan->rek_nama,
|
|
"pagu"=>$rowAKBPendapatan->nilai,
|
|
"bulan1"=>$rowAKBPendapatan->bulan1,
|
|
"bulan2"=>$rowAKBPendapatan->bulan2,
|
|
"bulan3"=>$rowAKBPendapatan->bulan3,
|
|
"bulan4"=>$rowAKBPendapatan->bulan4,
|
|
"bulan5"=>$rowAKBPendapatan->bulan5,
|
|
"bulan6"=>$rowAKBPendapatan->bulan6,
|
|
"bulan7"=>$rowAKBPendapatan->bulan7,
|
|
"bulan8"=>$rowAKBPendapatan->bulan8,
|
|
"bulan9"=>$rowAKBPendapatan->bulan9,
|
|
"bulan10"=>$rowAKBPendapatan->bulan10,
|
|
"bulan11"=>$rowAKBPendapatan->bulan11,
|
|
"bulan12"=>$rowAKBPendapatan->bulan12
|
|
]);
|
|
}
|
|
|
|
DB::commit();
|
|
|
|
return response()->json([
|
|
"success" => true,
|
|
"message" => "Data AKB berhasil disesuaikan!"
|
|
]);
|
|
|
|
}catch(Throwable $e){
|
|
|
|
DB::rollBack();
|
|
return response()->json([
|
|
"success" => false,
|
|
"message" => "Data AKB gagal disesuaikan!"
|
|
]);
|
|
}
|
|
}
|
|
public function updateuser()
|
|
{
|
|
try{
|
|
DB::beginTransaction();
|
|
|
|
$SKPD = Tropd::where("c_tahun_berakhir",">=",getTA())->orderBy('I_ID','ASC')->get();
|
|
foreach($SKPD as $rowSKPD){
|
|
$user = User::where("nrk",$rowSKPD["c_opd"])->count();
|
|
if ($user == 0 ){
|
|
// var_dump($rowSKPD["c_opd"]);
|
|
// exit;
|
|
$user = new User;
|
|
$user->name = $rowSKPD["n_opd"];
|
|
$user->nrk = $rowSKPD["c_opd"];
|
|
$user->password = Hash::make($rowSKPD["c_opd"]);
|
|
$user->role_name = "skpd";
|
|
$user->save();
|
|
$user->assignRole('skpd');
|
|
}
|
|
}
|
|
|
|
DB::commit();
|
|
|
|
return response()->json([
|
|
"success" => true,
|
|
"message" => "Data User berhasil disesuaikan!"
|
|
]);
|
|
|
|
}catch(Throwable $e){
|
|
|
|
DB::rollBack();
|
|
return response()->json([
|
|
"success" => false,
|
|
"message" => "Data User gagal disesuaikan!"
|
|
]);
|
|
}
|
|
}
|
|
|
|
}
|