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 @@ +
+ \ 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){ ?>