143 lines
4.2 KiB
PHP
143 lines
4.2 KiB
PHP
<?php
|
|
|
|
namespace App\Http\Controllers;
|
|
|
|
use App\Http\Controllers\Controller;
|
|
use App\Models\Tropd;
|
|
use App\Models\Program;
|
|
use App\Models\Kegiatan;
|
|
use App\Models\SubKegiatan;
|
|
use App\Models\Rsk;
|
|
use App\Models\Sps_pendapatan;
|
|
use App\Models\Siesetpembayaran;
|
|
use App\Models\Sp2d;
|
|
use Illuminate\Http\Request;
|
|
use Illuminate\Support\Facades\DB;
|
|
|
|
class ItemSearchController extends Controller
|
|
{
|
|
/**
|
|
* Display a listing of the resource.
|
|
*
|
|
* @return \Illuminate\Http\Response
|
|
*/
|
|
public function index()
|
|
{
|
|
//
|
|
}
|
|
|
|
public function skpd(Request $request)
|
|
{
|
|
$tropd = [];
|
|
|
|
if($request->has('q')){
|
|
$search = strtoupper($request->q);
|
|
$select = DB::raw("C_OPD AS ID,C_OPD||' | '||N_OPD as name");
|
|
$tropd = Tropd::select($select)
|
|
->where('N_OPD', 'LIKE', "%$search%")
|
|
->get();
|
|
}
|
|
return response()->json($tropd);
|
|
}
|
|
|
|
public function prog(Request $request)
|
|
{
|
|
$tropd = [];
|
|
|
|
if($request->has('q')){
|
|
$search = strtoupper($request->q);
|
|
$select = DB::raw("C_PROGRAM AS ID,C_PROGRAM||' | '||N_PROGRAM as name");
|
|
$tropd = Program::select($select)
|
|
->where('N_PROGRAM', 'LIKE', "%$search%")
|
|
->get();
|
|
}
|
|
return response()->json($tropd);
|
|
}
|
|
|
|
public function keg(Request $request)
|
|
{
|
|
$tropd = [];
|
|
|
|
if($request->has('q')){
|
|
$search = strtoupper($request->q);
|
|
$select = DB::raw("C_GIAT AS ID,C_GIAT||' | '||N_GIAT as name");
|
|
$tropd = Kegiatan::select($select)
|
|
->where('N_GIAT', 'LIKE', "%$search%")
|
|
->get();
|
|
}
|
|
return response()->json($tropd);
|
|
}
|
|
|
|
public function sk(Request $request)
|
|
{
|
|
$tropd = [];
|
|
|
|
if($request->has('q')){
|
|
$search = strtoupper($request->q);
|
|
$select = DB::raw("C_SUBGIAT AS ID,C_SUBGIAT||' | '||N_SUBGIAT as name");
|
|
$tropd = SubKegiatan::select($select)
|
|
->where('N_SUBGIAT', 'LIKE', "%$search%")
|
|
->get();
|
|
}
|
|
return response()->json($tropd);
|
|
}
|
|
|
|
public function rsk(Request $request)
|
|
{
|
|
$tropd = [];
|
|
|
|
if($request->has('q')){
|
|
$search = strtoupper($request->q);
|
|
$select = DB::raw("I_ID AS ID,I_ID||' | '||N_RSK as name");
|
|
$tropd = Rsk::select($select)
|
|
->where('N_RSK', 'LIKE', "%$search%")
|
|
->get();
|
|
}
|
|
return response()->json($tropd);
|
|
}
|
|
|
|
public function sps(Request $request)
|
|
{
|
|
$sps = [];
|
|
if($request->has('q')){
|
|
$search = strtolower($request->q);
|
|
$ta = $request->ta;
|
|
$jenis = $request->jenis;
|
|
$select = DB::raw("ID,KODE_REKENING||' | '||NAMA_REKENING as name");
|
|
$sps = Sps_pendapatan::select($select)
|
|
->whereRaw("TAHUN=$ta AND SKPD_ID = 980 AND (LOWER(KODE_REKENING) LIKE '%$search%' OR LOWER(NAMA_REKENING) LIKE '%$search%')");
|
|
|
|
if ($jenis == "dbh"){
|
|
$sps->whereRaw(" (SUBSTR(KODE_REKENING,1,12)='4.2.01.01.01') ");
|
|
}else if($jenis == "dak"){
|
|
$sps->whereRaw(" (SUBSTR(KODE_REKENING,1,12)='4.2.01.01.03' AND SUBSTR(KODE_REKENING,1,12)='4.2.01.01.04') ");
|
|
}
|
|
$sps->orderby("KODE_REKENING");
|
|
$sps = $sps->get();
|
|
}
|
|
return response()->json($sps);
|
|
}
|
|
|
|
public function sts(Request $request)
|
|
{
|
|
$no_skprd = $request->no_skprd;
|
|
$select = DB::raw("NO_SKPRD,TGL_VALIDASI,KODE_BAS,NILAI_BAYAR,TRBAS.N_AKUN");
|
|
$sts = Siesetpembayaran::select($select)
|
|
->join("TRBAS","SI_ESET_PEMBAYARAN.KODE_BAS","=","TRBAS.C_AKUN")
|
|
->where("NO_SKPRD", $no_skprd)
|
|
->first();
|
|
|
|
$sts["tgl_validasi"] = date("Y-m-d",strtotime($sts["tgl_validasi"]));
|
|
$sts["nilai_bayar"] = separateNumberIndo($sts["nilai_bayar"]);
|
|
|
|
return response()->json($sts);
|
|
}
|
|
|
|
public function sp2d(Request $request)
|
|
{
|
|
$no_sp2d = $request->no_sp2d;
|
|
$sp2d = Sp2d::where(["I_SP2DNO_DOK"=>$no_sp2d,"C_SP2D_SAH"=>1])->first();
|
|
return response()->json($sp2d);
|
|
}
|
|
}
|