From 019f6be7f6b730e1a43feb7a6d7af7ec0e4f16c6 Mon Sep 17 00:00:00 2001 From: Pusdatin BPKD Jkt Date: Thu, 29 Sep 2022 14:45:14 +0700 Subject: [PATCH] Data SPD --- .../RealisasiBelanjaController.php | 60 +++++++++++++++++-- app/Models/BelanjaRealisasiSPD.php | 20 +++++++ ...527_create_belanja_realisasi_spd_table.php | 35 +++++++++++ .../form_input_spd.blade.php | 57 ++++++++++++++++++ .../views/realisasi_belanja/submit.blade.php | 15 +++-- routes/web.php | 2 + 6 files changed, 180 insertions(+), 9 deletions(-) create mode 100644 app/Models/BelanjaRealisasiSPD.php create mode 100644 database/migrations/2022_09_29_110527_create_belanja_realisasi_spd_table.php create mode 100644 resources/views/realisasi_belanja/form_input_spd.blade.php diff --git a/app/Http/Controllers/RealisasiBelanjaController.php b/app/Http/Controllers/RealisasiBelanjaController.php index 5e2d526..1ca42a8 100644 --- a/app/Http/Controllers/RealisasiBelanjaController.php +++ b/app/Http/Controllers/RealisasiBelanjaController.php @@ -11,6 +11,7 @@ use App\Models\BelanjaRealisasi; use App\Models\BelanjaRealisasiDetail; use App\Models\BelanjaRealisasiKontrak; use App\Models\BelanjaRealisasiBast; +use App\Models\BelanjaRealisasiSPD; use App\Models\TempRealisasiBelanja; use App\Models\VwAkbSpdRealRsk; use App\Models\VwJenisBelanja; @@ -255,17 +256,17 @@ class RealisasiBelanjaController extends Controller FROM NEWSIPKD.VW_AKB_SPD_REALISASI_RSK WHERE I_IDRSK = ".$BelanjaRealisasi->kode_rsk." GROUP BY I_IDRSK " )); - $vwAKB = json_decode(json_encode($vwAKB[0]), true); + $vwAKB = json_decode(json_encode($vwAKB[0]), true); $BelanjaRealisasiKontrak = BelanjaRealisasiKontrak::where("belanja_realisasi_id",$id)->get(); - $vwSPD = DB::select(DB::raw( + /*$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(); $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 @@ -526,6 +527,57 @@ class RealisasiBelanjaController extends Controller return $jmlRealisasi[0]->jml; } + public function ubahSPD(Request $request, $id) + { + $req = $request->all(); + $SPDs = 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=".$id." GROUP BY x.I_SPDNO_DOK, x.D_SPDNO ORDER BY x.D_SPDNO " + )); + $redirect = URL::to($req["redirect"]); + + if ($request->isMethod('post')) { + try{ + DB::beginTransaction(); + + $itemSPD = isset($req["spd"])?$req["spd"]:[]; + if (count($itemSPD)>0) + { + BelanjaRealisasiSPD::where("id_rsk",$id)->delete(); + $SPDs = (array) $SPDs; + foreach($itemSPD as $rowSPD) + { + $check = array_search($rowSPD, array_column($SPDs, "i_spdno_dok")); + 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; + + BelanjaRealisasiSPD::create($data); + } + } + + DB::commit(); + return redirect($redirect)->with('success','Data SPD berhasil di input!'); + }else{ + return redirect($redirect)->with('error', "Data SPD belum dipilih!"); + } + + }catch(\Exception $e){ + throw new \Exception($e->getMessage()); + DB::rollBack(); + return redirect($redirect)->with('error',$e->getMessage()); + } + } + + return view('realisasi_belanja.form_input_spd',compact("SPDs","id","redirect")); + } + public function inputRealisasi(Request $request, $id) { $req = $request->all(); diff --git a/app/Models/BelanjaRealisasiSPD.php b/app/Models/BelanjaRealisasiSPD.php new file mode 100644 index 0000000..8bba9ce --- /dev/null +++ b/app/Models/BelanjaRealisasiSPD.php @@ -0,0 +1,20 @@ +id(); + $table->integer('id_rsk'); + $table->string('no_spd', 50); + $table->date('tgl'); + $table->decimal('jumlah', 19, 2); + $table->timestamps(); + }); + } + + /** + * Reverse the migrations. + * + * @return void + */ + public function down() + { + Schema::dropIfExists('belanja_realisasi_spd'); + } +} diff --git a/resources/views/realisasi_belanja/form_input_spd.blade.php b/resources/views/realisasi_belanja/form_input_spd.blade.php new file mode 100644 index 0000000..fcff3ac --- /dev/null +++ b/resources/views/realisasi_belanja/form_input_spd.blade.php @@ -0,0 +1,57 @@ +
+ @csrf +
+ + +
+ + + + + + + + + + + + + + + + + +
NoNomor SPDTanggalJumlah
{{ $spd->i_spdno_dok }}{{ date("d-m-Y",strtotime($spd->d_spdno)) }}{{ separateNumberIndo($spd->jml) }}
+
+
+ +
+
+
+ \ No newline at end of file diff --git a/resources/views/realisasi_belanja/submit.blade.php b/resources/views/realisasi_belanja/submit.blade.php index c625956..b9bb52a 100644 --- a/resources/views/realisasi_belanja/submit.blade.php +++ b/resources/views/realisasi_belanja/submit.blade.php @@ -114,17 +114,22 @@ foreach($vwSPD as $key=>$spd){ ?> {{ $key+1 }} - {{ $spd->i_spdno_dok }} - {{ date("d-m-Y",strtotime($spd->d_spdno)) }} - {{ separateNumberIndo($spd->jml) }} + {{ $spd->no_spd }} + {{ date("d-m-Y",strtotime($spd->tgl)) }} + {{ separateNumberIndo($spd->jumlah) }} - jml); } ?> + jumlah); } ?> diff --git a/routes/web.php b/routes/web.php index cd640f6..2b3f698 100644 --- a/routes/web.php +++ b/routes/web.php @@ -103,6 +103,8 @@ Route::group(['middleware' => 'auth'], function () { Route::delete('/{idKontrak}/bast', [RealisasiBelanjaController::class,'destroyBast']); Route::get('/{idKontrak}/bast/add', [RealisasiBelanjaController::class,'bastCreate']); Route::post('/{idKontrak}/bast/add', [RealisasiBelanjaController::class,'bastCreate']); + Route::get('/{id}/ubah-spd', [RealisasiBelanjaController::class,'ubahSPD']); + Route::post('/{id}/ubah-spd', [RealisasiBelanjaController::class,'ubahSPD']); }); Route::resource('realisasi-belanja', RealisasiBelanjaController::class);