Develop realisasi belanja
This commit is contained in:
@@ -8,6 +8,7 @@ use Illuminate\Support\Facades\DB;
|
||||
use Illuminate\Support\Facades\Auth;
|
||||
use Maatwebsite\Excel\Facades\Excel;
|
||||
use App\Models\DbhBelanjaRealisasi;
|
||||
use App\Models\DbhBelanjaRealisasiDetail;
|
||||
use App\Models\TempRealisasiBelanja;
|
||||
use App\Models\UnitSatuan;
|
||||
use App\Imports\RealisasiBelanjaImport;
|
||||
@@ -55,7 +56,14 @@ class RealisasiBelanjaController extends Controller
|
||||
$src = isset($post["search"])?$post["search"]["value"]:"";
|
||||
|
||||
$dataFilter=0;
|
||||
$data = DbhBelanjaRealisasi::orderBy("id","ASC");
|
||||
$data = DB::select(DB::raw('SELECT * FROM DBH_BELANJA_REALISASI x
|
||||
LEFT JOIN (
|
||||
SELECT DBH_BELANJA_REALISASI_ID,SUM(JUMLAH_REALISASI) AS jml_realisasi,
|
||||
sum(VOLUME_SATUAN_REALISASI) AS vol_realisasi, unit_satuan_realisasi
|
||||
FROM SAMASA.DBH_BELANJA_REALISASI_DETAIL
|
||||
GROUP BY DBH_BELANJA_REALISASI_ID,UNIT_SATUAN_REALISASI
|
||||
) y ON x.ID = y.DBH_BELANJA_REALISASI_ID'));
|
||||
|
||||
if (!empty($src)){
|
||||
$data->whereRaw("(LOWER(jenis_belanja) LIKE '%".strtolower($src)."%'
|
||||
OR LOWER(sub_jenis_belanja) LIKE '%".strtolower($src)."%'
|
||||
@@ -66,13 +74,14 @@ class RealisasiBelanjaController extends Controller
|
||||
OR LOWER(nama_rsk) LIKE '%".strtolower($src)."%'
|
||||
OR LOWER(nama_rekening) LIKE '%".strtolower($src)."%')");
|
||||
}
|
||||
$dataFilter = $data->count();
|
||||
|
||||
$dataFilter = count($data);
|
||||
$dataTotal = DbhBelanjaRealisasi::count();
|
||||
|
||||
return response()->json([
|
||||
"recordsTotal" => $dataTotal,
|
||||
"recordsFiltered" => $dataFilter,
|
||||
"data"=> $data->skip($offset)->take($limit)->get()
|
||||
"data"=> $data
|
||||
]);
|
||||
}
|
||||
|
||||
@@ -82,13 +91,13 @@ class RealisasiBelanjaController extends Controller
|
||||
DB::beginTransaction();
|
||||
$realisasi_belanja->delete();
|
||||
DB::commit();
|
||||
return redirect()->route('realisasi-pendapatan.index')
|
||||
return redirect('dbh/realisasi-pendapatan')
|
||||
->with('success','Data Realisasi Pendapatan berhasil dihapus!');
|
||||
|
||||
}catch(Throwable $e){
|
||||
|
||||
DB::rollBack();
|
||||
return redirect()->route('realisasi-pendapatan.index')
|
||||
return redirect('dbh/realisasi-pendapatan')
|
||||
->with('error','Data Realisasi Pendapatan gagal dihapus.');
|
||||
}
|
||||
}
|
||||
@@ -126,11 +135,11 @@ class RealisasiBelanjaController extends Controller
|
||||
TempRealisasiBelanja::truncate();
|
||||
Excel::import(new RealisasiBelanjaImport, $tujuan_upload."/".$file->getClientOriginalName());
|
||||
DB::commit();
|
||||
return redirect('upload-realisasi-belanja')->with('success','Data Rencana belanja berhasil diupload, Silahkan validasi data!');
|
||||
return redirect('dbh/upload-realisasi-belanja')->with('success','Data Rencana belanja berhasil diupload, Silahkan validasi data!');
|
||||
}catch(\Exception $e){
|
||||
throw new \Exception($e->getMessage());
|
||||
DB::rollBack();
|
||||
return redirect('upload-realisasi-belanja')->with('error',$e->getMessage());
|
||||
return redirect('dbh/upload-realisasi-belanja')->with('error',$e->getMessage());
|
||||
}
|
||||
}
|
||||
$this->siteTitle = "Rencana Belanja";
|
||||
@@ -206,11 +215,11 @@ class RealisasiBelanjaController extends Controller
|
||||
}
|
||||
TempRealisasiBelanja::truncate();
|
||||
DB::commit();
|
||||
return redirect('upload-realisasi-belanja')->with('success','Data Realisasi belanja berhasil diupload.');
|
||||
return redirect('/dbh/upload-realisasi-belanja')->with('success','Data Realisasi belanja berhasil diupload.');
|
||||
}catch(\Exception $e){
|
||||
throw new \Exception($e->getMessage());
|
||||
DB::rollBack();
|
||||
return redirect('upload-realisasi-belanja')->with('error',$e->getMessage());
|
||||
return redirect('/dbh/upload-realisasi-belanja')->with('error',$e->getMessage());
|
||||
}
|
||||
return view('realisasi_belanja.upload');
|
||||
}
|
||||
@@ -219,14 +228,17 @@ class RealisasiBelanjaController extends Controller
|
||||
{
|
||||
$DbhBelanjaRealisasi = DbhBelanjaRealisasi::where("id", $id)->firstOrNew();
|
||||
$req = $request->all();
|
||||
$redirect = isset($req["redirect_link"])?$req["redirect_link"]:"realisasi-belanja";
|
||||
$redirect = isset($req["redirect_link"])?$req["redirect_link"]:"/dbh/realisasi-belanja";
|
||||
if ($request->isMethod('post')) {
|
||||
try{
|
||||
DB::beginTransaction();
|
||||
$data["volume_satuan_realisasi"] = $req["vol_realisasi"];
|
||||
$data["unit_satuan_realisasi"] = $req["unit_realisasi"];
|
||||
$data["realisasi_by"] = Auth::user()->id;
|
||||
$DbhBelanjaRealisasi->update($data);
|
||||
$DbhBelanjaRealisasiDetail["dbh_belanja_realisasi_id"] = $id;
|
||||
$DbhBelanjaRealisasiDetail["volume_satuan_realisasi"] = $req["vol_realisasi"];
|
||||
$DbhBelanjaRealisasiDetail["unit_satuan_realisasi"] = $req["unit_realisasi"];
|
||||
$DbhBelanjaRealisasiDetail["jumlah_realisasi"] = replaceMoney($req["jml_realisasi"]);
|
||||
$DbhBelanjaRealisasiDetail["no_sp2d"] = $req["no_sp2d"];
|
||||
$DbhBelanjaRealisasiDetail["created_by"] = Auth::user()->id;
|
||||
DbhBelanjaRealisasiDetail::create($DbhBelanjaRealisasiDetail);
|
||||
DB::commit();
|
||||
|
||||
return redirect($redirect)->with('success','Data Realisasi berhasil di input!');
|
||||
@@ -240,4 +252,39 @@ class RealisasiBelanjaController extends Controller
|
||||
$unitSatuan = UnitSatuan::orderBy("id")->get();
|
||||
return view('realisasi_belanja.form_input_realisasi',compact("DbhBelanjaRealisasi", "unitSatuan","redirect"));
|
||||
}
|
||||
|
||||
public function datatableInputRealisasi(Request $request)
|
||||
{
|
||||
$post = $request->all();
|
||||
$offset = $post["start"];
|
||||
$limit = $post["length"];
|
||||
$src = isset($post["search"])?$post["search"]["value"]:"";
|
||||
|
||||
$dataFilter=0;
|
||||
$data = DbhBelanjaRealisasiDetail::where(["DBH_BELANJA_REALISASI_ID"=>$request->id])->orderBy("id","ASC");
|
||||
$dataFilter = $data->count();
|
||||
$dataTotal = DbhBelanjaRealisasiDetail::count();
|
||||
|
||||
return response()->json([
|
||||
"recordsTotal" => $dataTotal,
|
||||
"recordsFiltered" => $dataFilter,
|
||||
"data"=> $data->skip($offset)->take($limit)->get()
|
||||
]);
|
||||
}
|
||||
|
||||
public function deleteDetail($id)
|
||||
{
|
||||
$data = DbhBelanjaRealisasiDetail::where('id', $id)->firstorNew();
|
||||
try{
|
||||
DB::beginTransaction();
|
||||
$data->delete();
|
||||
DB::commit();
|
||||
return redirect('/dbh/realisasi-belanja/'.$data->dbh_belanja_realisasi_id."/submit")->with('success','Data detail Realisasi belanja berhasil dihapus!');
|
||||
|
||||
}catch(Throwable $e){
|
||||
|
||||
DB::rollBack();
|
||||
return redirect('/dbh/realisasi-belanja/'.$data->dbh_belanja_realisasi_id."/submit")->with('error','Data detail Realisasi belanja gagal dihapus.');
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user