Update dan Bugs Fix

This commit is contained in:
Pusdatin BPKD Jkt
2022-09-12 11:49:56 +07:00
parent 145f9d4c48
commit 35b4c72eb3
11 changed files with 130 additions and 126 deletions
+25 -18
View File
@@ -34,26 +34,33 @@ class ItemSearchController extends Controller
public function skpd(Request $request)
{
$tropd = [];
if($request->has('q')){
$ta = $request->ta;
$search = strtoupper($request->q);
if($request->has('realisasi-belanja')){
$sqlStr = "SELECT DISTINCT x.KODE_SKPD AS ID,x.KODE_SKPD||' | '||x.NAMA_SKPD as name
FROM SAMASA.BELANJA_REALISASI x
LEFT JOIN NEWSIPKD.TROPD y ON x.KODE_SKPD = y.C_OPD
WHERE TAHUN_ANGGARAN = $ta AND
NAMA_SKPD LIKE '%$search%' ";
$ta = $request->ta;
$search = strtoupper($request->q);
if($request->has('realisasi-belanja')){
$sqlStr = "SELECT DISTINCT x.KODE_SKPD AS ID,x.KODE_SKPD||' | '||x.NAMA_SKPD as name
FROM SAMASA.BELANJA_REALISASI x
LEFT JOIN NEWSIPKD.TROPD y ON x.KODE_SKPD = y.C_OPD
WHERE TAHUN_ANGGARAN = $ta ";
if (getRole()=="sbpk"){
$sqlStr.= " AND y.C_WIL_SP2DPROSES=".Auth::user()->wilayah;
}
$tropd = DB::select(DB::raw($sqlStr." ORDER BY x.KODE_SKPD "));
}else{
$select = DB::raw("C_OPD AS ID,C_OPD||' | '||N_OPD as name");
$tropd = Tropd::select($select)
->where('N_OPD', 'LIKE', "%$search%")
->get();
if (getRole()=="sbpk"){
$sqlStr.= " AND y.C_WIL_SP2DPROSES=".Auth::user()->wilayah;
}
if($request->has('q')){
$search = strtolower($request->q);
$sqlStr.= " AND LOWER(x.NAMA_SKPD) LIKE '%$search%' ";
}
$tropd = DB::select(DB::raw($sqlStr." ORDER BY x.KODE_SKPD "));
}else{
$select = DB::raw("C_OPD AS ID,C_OPD||' | '||N_OPD as name");
$tropd = Tropd::select($select);
if($request->has('q')){
$search = strtolower($request->q);
$tropd->whereRaw("LOWER(x.NAMA_SKPD) LIKE '%$search%'");
}
$tropd->orderBy("C_OPD");
$tropd->get();
}
return response()->json($tropd);
}