diff --git a/app/Http/Controllers/ItemSearchController.php b/app/Http/Controllers/ItemSearchController.php index 59007c7..967f381 100644 --- a/app/Http/Controllers/ItemSearchController.php +++ b/app/Http/Controllers/ItemSearchController.php @@ -4,6 +4,7 @@ namespace App\Http\Controllers; use App\Http\Controllers\Controller; use App\Models\Tropd; +use App\Models\Trbas; use App\Models\Program; use App\Models\Kegiatan; use App\Models\SubKegiatan; @@ -242,4 +243,22 @@ class ItemSearchController extends Controller } return response()->json($sk); } + + public function rek_dana(Request $request) + { + $search = strtolower($request->q); + $ta = $request->ta; + + $select = DB::raw("C_AKUN AS IDX,C_AKUN||' | '||N_AKUN as NAME"); + $trbas = Trbas::select($select)->whereRaw("C_TAHUN_BERAKHIR>=$ta AND C_AKUN LIKE '4.2.01.01%' AND LENGTH(C_AKUN)>=17"); + + if (!empty($search)){ + $trbas->whereRaw(" (LOWER(C_AKUN) LIKE '%$search%' OR LOWER(N_AKUN) LIKE '%$search%') "); + } + + $trbas->orderby("C_AKUN"); + $trbas = $trbas->get(); + + return response()->json($trbas); + } } diff --git a/app/Http/Controllers/LaporanFileController.php b/app/Http/Controllers/LaporanFileController.php new file mode 100644 index 0000000..ec6767f --- /dev/null +++ b/app/Http/Controllers/LaporanFileController.php @@ -0,0 +1,206 @@ +siteTitle = "Laporan File"; + parent::__construct(); + $this->setIconTitle("fa fa-reply"); + } + + public function index() + { + return view('laporan_file.index'); + } + + public function create() + { + $this->setSubtitle("Tambah Data"); + return view('laporan_file.create'); + } + + public function store(Request $request) + { + try{ + $date = date("Ymd"); + DB::beginTransaction(); + + $req = $request->all(); + $LaporanExists = LaporanFile::where("nama_laporan",$req["nama_laporan"])->count(); + if ($LaporanExists > 0) + { + return redirect(URL::to("/laporan-file")) + ->with('error','Data nama laporan '.$req["nama_laporan"].' sudah ada!'); + } + + $this->validate($request, [ + 'file' => 'required|mimes:pdf', + ]); + + $data["tahun"] = $req["ta"]; + $data["kode_rekening"] = $req["opt_kode_rekening"]; + $data["kode_skpd"] = Auth::user()->nrk; + $data["nama_skpd"] = Auth::user()->name; + $data["nama_laporan"] = $req["nama_laporan"]; + $file = $request->file('file'); + if ($file){ + $fileName = $file->getClientOriginalName(); + $ext = $file->getClientOriginalExtension(); + $NewFileName = $req["nama_laporan"].".".$ext; + $tujuan_upload = config('constants.upload_path_laporan'); + File::isDirectory($tujuan_upload) or File::makeDirectory($tujuan_upload, 0777, true, true); + $file->move($tujuan_upload, $NewFileName); + $data["nama_file"] = $NewFileName; + } + LaporanFile::create($data); + + DB::commit(); + return redirect(URL::to("/laporan-file"))->with('success','Laporan berhasil dibuat!'); + }catch(\Exception $e){ + DB::rollBack(); + return redirect(URL::to("/laporan-file"))->with('error',$e->getMessage()); + } + } + + public function edit(LaporanFile $laporanFile) + { + $this->setSubtitle("Ubah Data"); + return view('laporan_file.edit',compact('laporanFile')); + } + + public function update(Request $request, LaporanFile $laporanFile) + { + try{ + + DB::beginTransaction(); + + $req = $request->all(); + $LaporanExists = LaporanFile::where("nama_laporan",$req["nama_laporan"])->where("id","<>",$laporanFile->id)->count(); + if ($LaporanExists > 0) + { + return redirect(URL::to("/laporan-file")) + ->with('error','Data nama laporan '.$req["nama_laporan"].' sudah ada!'); + } + + $data["tahun"] = $req["ta"]; + $data["kode_rekening"] = $req["opt_kode_rekening"]; + $data["kode_skpd"] = Auth::user()->nrk; + $data["nama_skpd"] = Auth::user()->name; + $data["nama_laporan"] = $req["nama_laporan"]; + $file = $request->file('file'); + $tujuan_upload = config('constants.upload_path_laporan'); + if ($file){ + $fileName = $file->getClientOriginalName(); + $ext = $file->getClientOriginalExtension(); + $NewFileName = $req["nama_laporan"].".".$ext; + File::isDirectory($tujuan_upload) or File::makeDirectory($tujuan_upload, 0777, true, true); + $file->move($tujuan_upload, $NewFileName); + $data["nama_file"] = $NewFileName; + }else{ + $arrName = explode(".",$laporanFile->nama_file); + $ext = end($arrName); + rename($tujuan_upload.$laporanFile->nama_file, $tujuan_upload.$req["nama_laporan"].".".$ext); + $data["nama_file"] = $req["nama_laporan"].".".$ext; + } + $laporanFile->update($data); + + DB::commit(); + + return redirect(URL::to("/laporan-file"))->with('success','Laporan berhasil diubah.'); + }catch(Throwable $e){ + + DB::rollBack(); + return redirect(URL::to("/laporan-file"))->with('error','Laporan gagal diubah!'); + } + } + + public function datatable(Request $request) + { + $post = $request->all(); + $offset = $post["start"]; + $limit = $post["length"]; + $kode_rekening = isset($post["kode_rekening"])?$post["kode_rekening"]:""; + $ta = $post["ta"]; + $src = isset($post["search"]["value"]) ? strtolower($post["search"]["value"]):""; + + $data = LaporanFile::where("tahun",$ta); + if (getRole()=="skpd"){ + $data->where("kode_skpd",Auth::user()->nrk); + } + + if($kode_rekening){ + $data->where("kode_rekening", $kode_rekening); + } + + if (!empty($src)) + { + $src = strtolower($src); + //$data->whereRaw("( LOWER(simtrad4_uraian) like '%".$src."%' OR LOWER(simtrad4_sp2d_bun) like '%".$src."%' OR LOWER(rkud_no_sts) like '%".$src."%')"); + } + $dataFilter = $data->count(); + $dataTotal = LaporanFile::where("tahun",$ta); + if (getRole()=="skpd"){ + $dataTotal->where("kode_skpd",Auth::user()->nrk); + } + + return response()->json([ + "recordsTotal" => $dataTotal->count(), + "recordsFiltered" => $dataFilter, + "data"=> $data->orderBy("created_at","ASC")->skip($offset)->take($limit)->get() + ]); + } + + public function destroy(LaporanFile $laporanFile) + { + try{ + DB::beginTransaction(); + $alamatFile = config('constants.upload_path_laporan').$laporanFile->nama_file; + if (file_exists($alamatFile)){ + unlink($alamatFile); + } + $laporanFile->delete(); + DB::commit(); + return redirect(URL::to("/laporan-file"))->with('success','Data Laporan berhasil dihapus!'); + + }catch(Throwable $e){ + + DB::rollBack(); + return redirect(URL::to("/laporan-file"))->with('error','Data Laporan gagal dihapus.'); + } + } + + public function show(LaporanFile $laporanFile) + { + $this->setSubtitle("Detail Data"); + return view('laporan_file.show',compact("laporanFile")); + } + + public function download($kode) + { + $laporanFile = LaporanFile::where("id", $kode)->firstorNew(); + $headers = [ + 'Content-Type' => 'application/pdf', + 'Content-Disposition' => 'attachment;filename='.$laporanFile->nama_file + ]; + if ($laporanFile){ + return response()->download(config('constants.upload_path_laporan').$laporanFile->nama_file); + }else{ + echo "File tidak ditemukan!"; + } + } + +} \ No newline at end of file diff --git a/app/Http/Controllers/RealisasiBelanjaController.php b/app/Http/Controllers/RealisasiBelanjaController.php index 42464d8..487e2da 100644 --- a/app/Http/Controllers/RealisasiBelanjaController.php +++ b/app/Http/Controllers/RealisasiBelanjaController.php @@ -268,14 +268,14 @@ class RealisasiBelanjaController extends Controller $vwAKB = json_decode(json_encode($vwAKB[0]), true); $BelanjaRealisasiKontrak = BelanjaRealisasiKontrak::where("belanja_realisasi_id",$id)->get(); - /*$vwSPD = DB::select(DB::raw( - "SELECT x.I_SPDNO_DOK, x.D_SPDNO, sum(z.V_SPP) AS JML - FROM NEWSIPKD.TMSPD x - LEFT JOIN NEWSIPKD.TMSPPRINCIBLJ y ON x.I_ID = y.I_IDSPD - LEFT JOIN NEWSIPKD.TMSPPRINCIBLJRSK z ON y.I_IDSPP = z.I_IDSPP - WHERE z.I_IDRSK=".$BelanjaRealisasi->kode_rsk."GROUP BY x.I_SPDNO_DOK, x.D_SPDNO ORDER BY x.D_SPDNO " - )); */ - $vwSPD = BelanjaRealisasiSPD::where("id_rsk", $BelanjaRealisasi->kode_rsk)->get(); + $vwSPD = []; + if ($BelanjaRealisasi->jenis_dana == "DBH" && $BelanjaRealisasi->sub_jenis_dana != "CHT") + { + $vwSPD = BelanjaRealisasi::getSPD($BelanjaRealisasi->kode_sub_kegiatan,$BelanjaRealisasi->id_skpd); + }else{ + $vwSPD = BelanjaRealisasiSPD::where("id_rsk", $BelanjaRealisasi->kode_rsk)->get(); + } + $vwSP2D = DB::select(DB::raw('SELECT x.I_ID as IDSP2D, x.I_SP2DNO_DOK, TO_CHAR(x.D_SP2D_SAH,\'DD-MM-YYYY\') AS D_SP2D_SAH, sum(y.V_SPP) as V_SPP FROM NEWSIPKD.TMSP2D x @@ -304,8 +304,10 @@ class RealisasiBelanjaController extends Controller $idSPS = isset($post["id_sps"])?$post["id_sps"]:""; $fReview = isset($post["f_review"])?$post["f_review"]:""; - $sqlStr = "SELECT x.* FROM BELANJA_REALISASI x + $sqlStr = "SELECT x.*,z1.name as nama_subjenis_dana + FROM BELANJA_REALISASI x LEFT JOIN NEWSIPKD.TROPD z ON x.KODE_SKPD = z.C_OPD + LEFT JOIN MST_JENIS_DANA z1 ON x.sub_jenis_dana = z1.id WHERE x.tahun_anggaran='$ta'"; if (getRole()=="skpd"){ @@ -554,30 +556,9 @@ class RealisasiBelanjaController extends Controller public function ubahSPD(Request $request, $id) { $req = $request->all(); - /* $SPDs = DB::select(DB::raw( - "SELECT x.I_SPDNO_DOKx, x.D_SPDNO, sum(z.V_SPP) AS JML - FROM NEWSIPKD.TMSPD x - LEFT JOIN NEWSIPKD.TMSPPRINCIBLJ y ON x.I_ID = y.I_IDSPD - LEFT JOIN NEWSIPKD.TMSPPRINCIBLJRSK z ON y.I_IDSPP = z.I_IDSPP - WHERE z.I_IDRSK=".$id." GROUP BY x.I_SPDNO_DOK, x.D_SPDNO ORDER BY x.D_SPDNO " - )); */ $detailRSK = DB::select(DB::raw("SELECT * FROM SAMASA.VW_DPA_RSK WHERE I_ID = $id")); $detailRSK = json_decode(json_encode($detailRSK[0]),true); - $SPDs = DB::select(DB::raw( - "SELECT a.I_SPDNO_DOK, a.D_SPDNO, b.JML - FROM NEWSIPKD.TMSPD a - INNER JOIN ( - SELECT I_IDSPD, SUM(V_SPD) AS JML - FROM NEWSIPKD.TMSPDRINCIBLJ x - LEFT JOIN NEWSIPKD.TMDPASUBGIAT y - ON x.I_IDSUBGIAT = y.I_ID - WHERE y.C_SUBGIAT = '".$detailRSK["c_subgiat"]."' - AND y.I_IDOPD = '".$detailRSK["i_idopd"]."' - GROUP BY I_IDSPD - ) b - ON a.I_ID = b.I_IDSPD - WHERE a.C_ANGG_TAHUN = ".getTA() - )); + $SPDs = BelanjaRealisasi::getSPD($detailRSK["c_subgiat"],$detailRSK["i_idopd"]); $redirect = URL::to($req["redirect"]); @@ -592,13 +573,13 @@ class RealisasiBelanjaController extends Controller $SPDs = (array) $SPDs; foreach($itemSPD as $rowSPD) { - $check = array_search($rowSPD, array_column($SPDs, "i_spdno_dok")); + $check = array_search($rowSPD, array_column($SPDs, "no_spd")); if ($check > -1) { $data["id_rsk"] = $id; - $data["no_spd"] = $SPDs[$check]->i_spdno_dok; - $data["tgl"] = $SPDs[$check]->d_spdno; - $data["jumlah"] = $SPDs[$check]->jml; + $data["no_spd"] = $SPDs[$check]->no_spd; + $data["tgl"] = $SPDs[$check]->tgl; + $data["jumlah"] = $SPDs[$check]->jumlah; BelanjaRealisasiSPD::create($data); } diff --git a/app/Models/BelanjaRealisasi.php b/app/Models/BelanjaRealisasi.php index 95ee10c..680307c 100644 --- a/app/Models/BelanjaRealisasi.php +++ b/app/Models/BelanjaRealisasi.php @@ -5,6 +5,7 @@ use App\Traits\Uuids; use Illuminate\Database\Eloquent\Factories\HasFactory; use Illuminate\Database\Eloquent\Model; use Yajra\Oci8\Eloquent\OracleEloquent as Eloquent; +use Illuminate\Support\Facades\DB; class BelanjaRealisasi extends Eloquent { @@ -43,4 +44,23 @@ class BelanjaRealisasi extends Eloquent "id_sps", "f_view_sbpk" ]; + + public function getSPD($subgiat,$skpd) + { + return DB::select(DB::raw( + "SELECT a.I_SPDNO_DOK as NO_SPD, a.D_SPDNO as TGL, b.JML as jumlah + FROM NEWSIPKD.TMSPD a + INNER JOIN ( + SELECT I_IDSPD, SUM(V_SPD) AS JML + FROM NEWSIPKD.TMSPDRINCIBLJ x + LEFT JOIN NEWSIPKD.TMDPASUBGIAT y + ON x.I_IDSUBGIAT = y.I_ID + WHERE y.C_SUBGIAT = '".$subgiat."' + AND y.I_IDOPD = '".$skpd."' + GROUP BY I_IDSPD + ) b + ON a.I_ID = b.I_IDSPD + WHERE a.C_ANGG_TAHUN = ".getTA()." ORDER BY a.D_SPDNO" + )); + } } diff --git a/app/Models/LaporanFile.php b/app/Models/LaporanFile.php new file mode 100644 index 0000000..a4e7044 --- /dev/null +++ b/app/Models/LaporanFile.php @@ -0,0 +1,24 @@ + "uploadFiles/", 'upload_path_kontrak' => "uploadFiles/kontrak/", 'upload_path_sts' => "uploadFiles/sts/", + 'upload_path_laporan' => "uploadFiles/laporan/", 'download_path' => "downloadFiles/", 'options' => [ 'option_attachment' => '13', diff --git a/database/migrations/2022_10_25_111330_create_laporan_table.php b/database/migrations/2022_10_25_111330_create_laporan_table.php index 0aaad5d..f2aea63 100644 --- a/database/migrations/2022_10_25_111330_create_laporan_table.php +++ b/database/migrations/2022_10_25_111330_create_laporan_table.php @@ -13,8 +13,15 @@ class CreateLaporanTable extends Migration */ public function up() { - Schema::create('laporan', function (Blueprint $table) { - $table->id(); + Schema::create('laporan_file', function (Blueprint $table) { + $table->uuid('id')->primary(); + $table->string("tahun",4); + $table->date("tgl_upload")->default(\DB::raw('CURRENT_TIMESTAMP')); + $table->string("kode_rekening",50); + $table->string("kode_skpd",50); + $table->string("nama_skpd",255); + $table->string("nama_laporan",50); + $table->string("nama_file",50); $table->timestamps(); }); } @@ -26,6 +33,6 @@ class CreateLaporanTable extends Migration */ public function down() { - Schema::dropIfExists('laporan'); + Schema::dropIfExists('laporan_file'); } } diff --git a/public/js/app.js b/public/js/app.js index 422669f..d12ba28 100644 --- a/public/js/app.js +++ b/public/js/app.js @@ -232,7 +232,8 @@ $('.prog_search').select2({ }; }, cache: true - } + }, + dropdownParent: $('#modal-default') }); $('.keg_search').select2({ @@ -382,6 +383,31 @@ $('.sps_search').select2({ } }); +let callKodeRekening = ()=>{ + $('.kode_rekening').select2({ + placeholder: 'Pilih Kode Rekening', + allowClear: true, + ajax: { + url: Url+'/item-search-rekening?ta='+ta, + dataType: 'json', + delay: 250, + processResults: function (data) { + return { + results: $.map(data, function (item) { + return { + text: item.name, + id: item.idx + } + }) + }; + }, + cache: true, + } + }); +} + +callKodeRekening(); + $(document).on("click",".modalButton",function (e){ $("#overlayLoader").removeClass("d-flex"); $("#overlayLoader").addClass("d-flex"); diff --git a/resources/views/laporan_file/create.blade.php b/resources/views/laporan_file/create.blade.php new file mode 100644 index 0000000..e335b31 --- /dev/null +++ b/resources/views/laporan_file/create.blade.php @@ -0,0 +1,6 @@ +
+ @csrf + @include('laporan_file.form') +
+ \ No newline at end of file diff --git a/resources/views/laporan_file/edit.blade.php b/resources/views/laporan_file/edit.blade.php new file mode 100644 index 0000000..a0af1a0 --- /dev/null +++ b/resources/views/laporan_file/edit.blade.php @@ -0,0 +1,9 @@ +
id") }}" method="POST" autocomplete="off" enctype="multipart/form-data"> + @csrf + @method("PUT") + @include('laporan_file.form') +
+ \ No newline at end of file diff --git a/resources/views/laporan_file/form.blade.php b/resources/views/laporan_file/form.blade.php new file mode 100644 index 0000000..0a8350f --- /dev/null +++ b/resources/views/laporan_file/form.blade.php @@ -0,0 +1,32 @@ +
+
+
+ + +
+
+
+
+ + +
+
+
+
+ + +
+
+
+
+ + +
+
+
+ +
+
+ \ No newline at end of file diff --git a/resources/views/laporan_file/index.blade.php b/resources/views/laporan_file/index.blade.php new file mode 100644 index 0000000..5ca97e1 --- /dev/null +++ b/resources/views/laporan_file/index.blade.php @@ -0,0 +1,188 @@ +@php + $siteBreadcumb = [ + ["url"=>"/laporan-file","label"=>$siteTitle], + ]; +@endphp + +@extends('layouts.app') + +@section('styles') + + + + + +@endsection + +@section('card_header') +
+

{{ $sitesubTitle }}

+
+ @if(auth()->user()->can('Create DBH Realisasi Pendapatan')) + Tambah Data + @endif +
+
+@stop + +@section('content') +
+ @csrf +
+
+
+ + +
+
+
+
+ + +
+
+
+
+ + + + + + + + + + + + + +
NoTgl UploadNama LaporanKode RekeningKode SKPDNama SKPDAksi
+@stop +@section('scripts') + + + + + + + + + + + + + + + + + +@endsection \ No newline at end of file diff --git a/resources/views/partials/menu.blade.php b/resources/views/partials/menu.blade.php index 058bb58..00945dc 100644 --- a/resources/views/partials/menu.blade.php +++ b/resources/views/partials/menu.blade.php @@ -90,6 +90,12 @@ + @if ($role == "admin" || $role == "superadmin") diff --git a/resources/views/realisasi_belanja/form_input_spd.blade.php b/resources/views/realisasi_belanja/form_input_spd.blade.php index f389126..968abbc 100644 --- a/resources/views/realisasi_belanja/form_input_spd.blade.php +++ b/resources/views/realisasi_belanja/form_input_spd.blade.php @@ -15,10 +15,10 @@ - i_spdno_dok, array_column($selected, "no_spd")) > -1?"checked":"" }}> - {{ $spd->i_spdno_dok }} - {{ date("d-m-Y",strtotime($spd->d_spdno)) }} - {{ separateNumberIndo($spd->jml) }} + no_spd, array_column($selected, "no_spd")) > -1?"checked":"" }}> + {{ $spd->no_spd }} + {{ date("d-m-Y",strtotime($spd->tgl)) }} + {{ separateNumberIndo($spd->jumlah) }} diff --git a/resources/views/realisasi_belanja/index.blade.php b/resources/views/realisasi_belanja/index.blade.php index 9e4149c..7bdb728 100644 --- a/resources/views/realisasi_belanja/index.blade.php +++ b/resources/views/realisasi_belanja/index.blade.php @@ -119,6 +119,7 @@ "Volume Realisasi", "Unit Realisasi", "SPD", + "Jenis", "Aksi" ); @@ -272,6 +273,7 @@ { "data": "volume_satuan_realisasi", "className":"text-center", "defaultContent":"0", "width":50 }, { "data": "unit_satuan_realisasi", "className":"text-center", "defaultContent":"-", "width":50 }, { "data": null}, + { "data": "jenis_dana", "className":"text-center"}, { "data": null} ], "rowCallback": function(nRow, aData, iDisplayIndex, iDisplayIndexFull, oSettings) { @@ -293,8 +295,9 @@ $("td:eq(6)", nRow).html(separateNumberIndo(aData["volume_satuan"])); $("td:eq(8)", nRow).html(realisasi); $("td:eq(9)", nRow).html(separateNumberIndo(aData["volume_satuan_realisasi"])); - $("td:eq(11)", nRow).html("+aData["jml_spd"]+""':'aData["jml_spd"]' ?>); - $("td:eq(12)", nRow).html(` + $("td:eq(11)", nRow).html("+aData["jml_spd"]+""':'aData["jml_spd"]' ?>); + $("td:eq(12)", nRow).html(aData["jenis_dana"]+"::"+aData["nama_subjenis_dana"]); + $("td:eq(13)", nRow).html(`
@csrf @method('DELETE') diff --git a/routes/web.php b/routes/web.php index b34dd5a..4d35a59 100644 --- a/routes/web.php +++ b/routes/web.php @@ -9,6 +9,7 @@ use App\Http\Controllers\JadwalSalurdanaController; use App\Http\Controllers\RealisasiPendapatanController; use App\Http\Controllers\RealisasiBelanjaController; use App\Http\Controllers\LaporanController; +use App\Http\Controllers\LaporanFileController; use App\Http\Controllers\Admin\MstPenggunaController; use App\Http\Controllers\Admin\MappingDbhSkpdController; use App\Http\Controllers\Admin\RolessController; @@ -123,6 +124,7 @@ Route::group(['middleware' => 'auth'], function () { Route::get('item-search-jenisbelanja', [ItemSearchController::class,'jenisBelanja']); Route::get('item-search-subjenisbelanja', [ItemSearchController::class,'subjenisBelanja']); Route::get('item-search-subjenisdana', [ItemSearchController::class,'subjenisDana']); + Route::get('item-search-rekening', [ItemSearchController::class,'rek_dana']); Route::post('role-list', [MstPenggunaController::class,'roleList']); Route::get('logout', [AuthController::class, 'logout'])->name('logout'); @@ -132,4 +134,11 @@ Route::group(['middleware' => 'auth'], function () { }); Route::resource('notif', NotifikasiController::class); Route::get('tahun-anggaran/{ta}', [HomeController::class, 'ta']); + + // PENDAPATAN ================================================== + Route::group(['prefix' => 'laporan-file'], function () { + Route::post('/datatable', [LaporanFileController::class,'datatable']); + Route::get('/{kode}/download', [LaporanFileController::class,'download']); + }); + Route::resource('laporan-file', LaporanFileController::class); }); \ No newline at end of file