laporan file dan spd pada dbh
This commit is contained in:
@@ -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);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,206 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Controllers;
|
||||
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\Support\Facades\Http;
|
||||
use Illuminate\Support\Facades\DB;
|
||||
use Illuminate\Support\Facades\Auth;
|
||||
use Maatwebsite\Excel\Facades\Excel;
|
||||
use App\Models\LaporanFile;
|
||||
use App\Models\User;
|
||||
use PhpOffice\PhpSpreadsheet\Spreadsheet;
|
||||
use PhpOffice\PhpSpreadsheet\Writer\Xlsx;
|
||||
use Illuminate\Support\Facades\URL;
|
||||
use Illuminate\Support\Facades\File;
|
||||
|
||||
class LaporanFileController extends Controller
|
||||
{
|
||||
public function __construct(){
|
||||
$this->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!";
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -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);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user