Update tambah tombol Penyesuaian perubahan AKB Perubahan
This commit is contained in:
@@ -5,6 +5,8 @@ use App\Http\Controllers\Controller;
|
||||
use Illuminate\Http\Request;
|
||||
use Session;
|
||||
use Illuminate\Support\Facades\DB;
|
||||
use App\Models\AkbSpb23;
|
||||
use App\Models\AkbPendapatan;
|
||||
|
||||
class PengaturanController extends Controller
|
||||
{
|
||||
@@ -49,4 +51,50 @@ class PengaturanController extends Controller
|
||||
]);
|
||||
}
|
||||
}
|
||||
|
||||
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!"
|
||||
]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -10,7 +10,8 @@ use Illuminate\Support\Facades\Auth;
|
||||
class AkbPendapatan extends Eloquent
|
||||
{
|
||||
use HasFactory;
|
||||
protected $connection = 'oracle';
|
||||
protected $connection = 'Samasa';
|
||||
protected $table = 'SAMASA.AKB_PENDAPATAN';
|
||||
|
||||
protected $guarded = [];
|
||||
public $timestamps = false;
|
||||
}
|
||||
|
||||
@@ -0,0 +1,49 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use Yajra\Oci8\Eloquent\OracleEloquent as Eloquent;
|
||||
use Illuminate\Support\Facades\DB;
|
||||
|
||||
class AkbSpb23 extends Eloquent
|
||||
{
|
||||
use HasFactory;
|
||||
protected $connection = 'mysql';
|
||||
|
||||
public function getAkbPendapatan()
|
||||
{
|
||||
$sqlstr = "select
|
||||
D.tahun,
|
||||
D.unitkerja_id,
|
||||
D.komisi as unitkerja_komisi,
|
||||
D.kode_wilayah as unitkerja_wilayah,
|
||||
D.kode as Unitkerja_Kode,
|
||||
D.kode_permen as Unitkerja_kodepermen,
|
||||
D.nama as Unitkerja_nama,
|
||||
C.rekening_id as rek_id,
|
||||
C.kode as rek_kode,
|
||||
C.nama as rek_nama,
|
||||
B.nilai,
|
||||
coalesce(A.bulan1, 0) as bulan1,
|
||||
coalesce(A.bulan2, 0) as bulan2,
|
||||
coalesce(A.bulan3, 0) as bulan3,
|
||||
coalesce(A.bulan4, 0) as bulan4,
|
||||
coalesce(A.bulan5, 0) as bulan5,
|
||||
coalesce(A.bulan6, 0) as bulan6,
|
||||
coalesce(A.bulan7, 0) as bulan7,
|
||||
coalesce(A.bulan8, 0) as bulan8,
|
||||
coalesce(A.bulan9, 0) as bulan9,
|
||||
coalesce(A.bulan10, 0) as bulan10,
|
||||
coalesce(A.bulan11, 0) as bulan11,
|
||||
coalesce(A.bulan12, 0) as bulan12
|
||||
from next_pendapatan B
|
||||
left join next_pendapatan_proyeksi A on A.pendapatan_id = B.pendapatan_id
|
||||
join hist2_rekening C on B.rekening_id = C.rekening_id and C.tahun = ".getTA()."
|
||||
join hist_unitkerja D on B.unitkerja_id = D.unitkerja_id and D.tahun = ".getTA()."
|
||||
ORDER BY C.kode";
|
||||
|
||||
return DB::connection("mysql")->select(DB::raw($sqlstr));
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user