fixing route external
This commit is contained in:
parent
565eccff18
commit
5146dd0e84
@ -37,7 +37,7 @@ class PitStopController extends Controller
|
||||
}
|
||||
|
||||
public function pitstop(){
|
||||
$masterPitStop = MasterPitStopPraAkre::where('statusenabled', true)->get();
|
||||
$masterPitStop = MasterPitStopPraAkre::where('statusenabled', true)->orderBy('id', 'asc')->get();
|
||||
$data = [
|
||||
'title' => 'PitStop',
|
||||
'masterPitStop' => $masterPitStop
|
||||
@ -76,8 +76,15 @@ class PitStopController extends Controller
|
||||
]);
|
||||
}
|
||||
|
||||
public function progressExternalDetail(Request $request, $tipe)
|
||||
public function progressExternalDetail(Request $request, $tipe = null)
|
||||
{
|
||||
// NOTE:
|
||||
// - `/{tipe}` breaks for values containing "/" because many servers/frameworks decode `%2F` early.
|
||||
// - Support both route param and query param (?tipe=...) for backward compatibility.
|
||||
if ($tipe === null) {
|
||||
$tipe = $request->query('tipe');
|
||||
}
|
||||
|
||||
$tipe = urldecode((string) $tipe);
|
||||
$tipe = trim($tipe);
|
||||
abort_if($tipe === '', 404);
|
||||
@ -204,11 +211,11 @@ class PitStopController extends Controller
|
||||
->where('m.statusenabled', true);
|
||||
})
|
||||
->select([
|
||||
DB::raw("coalesce(nullif(pl.tipe, ''), '-') as tipe"),
|
||||
DB::raw("coalesce(nullif(btrim(pl.tipe), ''), '-') as tipe"),
|
||||
DB::raw('pl.id as pegawai_id'),
|
||||
DB::raw("count(distinct m.id) as lulus_count"),
|
||||
])
|
||||
->groupBy(DB::raw("coalesce(nullif(pl.tipe, ''), '-')"), 'pl.id');
|
||||
->groupBy(DB::raw("coalesce(nullif(btrim(pl.tipe), ''), '-')"), 'pl.id');
|
||||
|
||||
$tipeAgg = DB::connection('pgsql')
|
||||
->query()
|
||||
@ -295,15 +302,15 @@ class PitStopController extends Controller
|
||||
$join->on(DB::raw('m.id::text'), '=', 'p.masterpitstop_id')
|
||||
->where('m.statusenabled', true);
|
||||
})
|
||||
->where(DB::raw("coalesce(nullif(pl.tipe, ''), '-')"), '=', $tipe)
|
||||
->where(DB::raw("coalesce(nullif(btrim(pl.tipe), ''), '-')"), '=', $tipe)
|
||||
->select([
|
||||
'pl.id',
|
||||
'pl.nama',
|
||||
'pl.nik',
|
||||
DB::raw("coalesce(nullif(pl.tipe, ''), '-') as tipe"),
|
||||
DB::raw("coalesce(nullif(btrim(pl.tipe), ''), '-') as tipe"),
|
||||
DB::raw("count(distinct m.id) filter (where p.status='lulus') as lulus_count"),
|
||||
])
|
||||
->groupBy('pl.id', 'pl.nama', 'pl.nik', DB::raw("coalesce(nullif(pl.tipe, ''), '-')"))
|
||||
->groupBy('pl.id', 'pl.nama', 'pl.nik', DB::raw("coalesce(nullif(btrim(pl.tipe), ''), '-')"))
|
||||
->orderBy('pl.nama')
|
||||
->limit($limit)
|
||||
->get();
|
||||
@ -526,11 +533,11 @@ class PitStopController extends Controller
|
||||
->where('m.statusenabled', true);
|
||||
})
|
||||
->select([
|
||||
DB::raw("coalesce(nullif(pl.tipe, ''), '-') as tipe"),
|
||||
DB::raw("coalesce(nullif(btrim(pl.tipe), ''), '-') as tipe"),
|
||||
DB::raw('pl.id as pegawai_id'),
|
||||
DB::raw("count(distinct m.id) as lulus_count"),
|
||||
])
|
||||
->groupBy(DB::raw("coalesce(nullif(pl.tipe, ''), '-')"), 'pl.id');
|
||||
->groupBy(DB::raw("coalesce(nullif(btrim(pl.tipe), ''), '-')"), 'pl.id');
|
||||
|
||||
$tipeAgg = DB::connection('pgsql')
|
||||
->query()
|
||||
@ -578,7 +585,7 @@ class PitStopController extends Controller
|
||||
$join->on(DB::raw('m.id::text'), '=', 'p.masterpitstop_id')
|
||||
->where('m.statusenabled', true);
|
||||
})
|
||||
->where(DB::raw("coalesce(nullif(pl.tipe, ''), '-')"), '=', $tipe)
|
||||
->where(DB::raw("coalesce(nullif(btrim(pl.tipe), ''), '-')"), '=', $tipe)
|
||||
->select([
|
||||
'pl.id',
|
||||
DB::raw("coalesce(pl.nama, '-') as nama"),
|
||||
@ -1029,11 +1036,11 @@ class PitStopController extends Controller
|
||||
->where('m.statusenabled', true);
|
||||
})
|
||||
->select([
|
||||
DB::raw("coalesce(nullif(pl.tipe, ''), '-') as tipe"),
|
||||
DB::raw("coalesce(nullif(btrim(pl.tipe), ''), '-') as tipe"),
|
||||
DB::raw('pl.id as pegawai_id'),
|
||||
DB::raw("count(distinct m.id) as lulus_count"),
|
||||
])
|
||||
->groupBy(DB::raw("coalesce(nullif(pl.tipe, ''), '-')"), 'pl.id');
|
||||
->groupBy(DB::raw("coalesce(nullif(btrim(pl.tipe), ''), '-')"), 'pl.id');
|
||||
|
||||
$tipeAgg = DB::connection('pgsql')
|
||||
->query()
|
||||
@ -1059,7 +1066,7 @@ class PitStopController extends Controller
|
||||
->where('m.statusenabled', true);
|
||||
})
|
||||
->select([
|
||||
DB::raw("coalesce(nullif(pl.tipe, ''), '-') as tipe"),
|
||||
DB::raw("coalesce(nullif(btrim(pl.tipe), ''), '-') as tipe"),
|
||||
'pl.id',
|
||||
DB::raw("coalesce(pl.nama, '-') as nama"),
|
||||
DB::raw("coalesce(pl.nik, '-') as nik"),
|
||||
@ -1075,8 +1082,8 @@ class PitStopController extends Controller
|
||||
and px.id is null
|
||||
), '') as belum_steps"),
|
||||
])
|
||||
->groupBy(DB::raw("coalesce(nullif(pl.tipe, ''), '-')"), 'pl.id', 'pl.nama', 'pl.nik')
|
||||
->orderBy(DB::raw("coalesce(nullif(pl.tipe, ''), '-')"))
|
||||
->groupBy(DB::raw("coalesce(nullif(btrim(pl.tipe), ''), '-')"), 'pl.id', 'pl.nama', 'pl.nik')
|
||||
->orderBy(DB::raw("coalesce(nullif(btrim(pl.tipe), ''), '-')"))
|
||||
->orderBy('pl.nama')
|
||||
->get();
|
||||
|
||||
@ -1214,7 +1221,7 @@ class PitStopController extends Controller
|
||||
$join->on(DB::raw('m.id::text'), '=', 'p.masterpitstop_id')
|
||||
->where('m.statusenabled', true);
|
||||
})
|
||||
->where(DB::raw("coalesce(nullif(pl.tipe, ''), '-')"), '=', $tipe)
|
||||
->where(DB::raw("coalesce(nullif(btrim(pl.tipe), ''), '-')"), '=', $tipe)
|
||||
->select([
|
||||
'pl.id',
|
||||
DB::raw("coalesce(pl.nama, '-') as nama"),
|
||||
@ -1431,11 +1438,12 @@ class PitStopController extends Controller
|
||||
]);
|
||||
}
|
||||
|
||||
public function dataProgressExternalByTipe(Request $request, $tipe)
|
||||
public function dataProgressExternalByTipe(Request $request, $tipe = null)
|
||||
{
|
||||
$tipe = urldecode((string) $tipe);
|
||||
$tipe = trim($tipe);
|
||||
abort_if($tipe === '', 404);
|
||||
// Support both route param and query param (?tipe=...) so tipe containing "/" works reliably.
|
||||
if ($tipe === null) {
|
||||
$tipe = $request->query('tipe');
|
||||
}
|
||||
|
||||
$draw = $this->dtInt($request->input('draw'), 1);
|
||||
$start = $this->dtInt($request->input('start'), 0);
|
||||
@ -1445,6 +1453,17 @@ class PitStopController extends Controller
|
||||
|
||||
$search = trim((string) data_get($request->all(), 'search.value', ''));
|
||||
|
||||
$tipe = urldecode((string) $tipe);
|
||||
$tipe = trim($tipe);
|
||||
if ($tipe === '') {
|
||||
return response()->json([
|
||||
'draw' => $draw,
|
||||
'recordsTotal' => 0,
|
||||
'recordsFiltered' => 0,
|
||||
'data' => [],
|
||||
]);
|
||||
}
|
||||
|
||||
$totalSteps = (int) MasterPitStopPraAkre::where('statusenabled', true)->count();
|
||||
|
||||
$baseNoSearch = DB::connection('pgsql')
|
||||
@ -1457,7 +1476,7 @@ class PitStopController extends Controller
|
||||
$join->on(DB::raw('m.id::text'), '=', 'p.masterpitstop_id')
|
||||
->where('m.statusenabled', true);
|
||||
})
|
||||
->where(DB::raw("coalesce(nullif(pl.tipe, ''), '-')"), '=', $tipe)
|
||||
->where(DB::raw("coalesce(nullif(btrim(pl.tipe), ''), '-')"), '=', $tipe)
|
||||
->select([
|
||||
'pl.id',
|
||||
DB::raw("coalesce(pl.nama, '-') as nama"),
|
||||
@ -1600,7 +1619,7 @@ class PitStopController extends Controller
|
||||
'pl.id',
|
||||
DB::raw("coalesce(pl.nama, '-') as nama"),
|
||||
DB::raw("coalesce(pl.nik, '-') as identitas"),
|
||||
DB::raw("coalesce(nullif(pl.tipe, ''), '-') as unit_name"),
|
||||
DB::raw("coalesce(nullif(btrim(pl.tipe), ''), '-') as unit_name"),
|
||||
DB::raw("count(distinct m.id) as lulus_count"),
|
||||
DB::raw("coalesce((
|
||||
select count(*)
|
||||
@ -1623,7 +1642,7 @@ class PitStopController extends Controller
|
||||
and px.id is null
|
||||
), '') as belum_steps"),
|
||||
])
|
||||
->groupBy('pl.id', 'pl.nama', 'pl.nik', DB::raw("coalesce(nullif(pl.tipe, ''), '-')"));
|
||||
->groupBy('pl.id', 'pl.nama', 'pl.nik', DB::raw("coalesce(nullif(btrim(pl.tipe), ''), '-')"));
|
||||
|
||||
$union = $internal->unionAll($external);
|
||||
|
||||
@ -2079,7 +2098,7 @@ class PitStopController extends Controller
|
||||
DB::raw("'luar' as tipe_karyawan"),
|
||||
'pl.id',
|
||||
DB::raw("coalesce(pl.nama, '-') as nama"),
|
||||
DB::raw("coalesce(nullif(pl.tipe, ''), '-') as unit_name"),
|
||||
DB::raw("coalesce(nullif(btrim(pl.tipe), ''), '-') as unit_name"),
|
||||
DB::raw("count(distinct m.id) as lulus_count"),
|
||||
DB::raw("coalesce((
|
||||
select count(*)
|
||||
@ -2102,7 +2121,7 @@ class PitStopController extends Controller
|
||||
and px.id is null
|
||||
), '') as belum_steps"),
|
||||
])
|
||||
->groupBy('pl.id', 'pl.nama', 'pl.nik', DB::raw("coalesce(nullif(pl.tipe, ''), '-')"));
|
||||
->groupBy('pl.id', 'pl.nama', 'pl.nik', DB::raw("coalesce(nullif(btrim(pl.tipe), ''), '-')"));
|
||||
|
||||
$union = $internal->unionAll($external);
|
||||
|
||||
|
||||
@ -165,7 +165,7 @@
|
||||
<table class="table align-middle table-row-dashed fs-6 gy-3">
|
||||
<thead>
|
||||
<tr class="text-muted fw-semibold fs-7 text-uppercase gs-0">
|
||||
<th>Nama Step</th>
|
||||
<th>Nama Pitstop</th>
|
||||
<th>Nilai</th>
|
||||
<th class="text-end">Waktu</th>
|
||||
</tr>
|
||||
|
||||
@ -80,7 +80,7 @@
|
||||
<table class="table align-middle table-row-dashed fs-6 gy-3">
|
||||
<thead>
|
||||
<tr class="text-muted fw-semibold fs-7 text-uppercase gs-0">
|
||||
<th>Nama Step</th>
|
||||
<th>Nama Pitstop</th>
|
||||
<th>Nilai</th>
|
||||
<th style="width: 240px">Pemberi Nilai</th>
|
||||
<th class="text-end">Waktu</th>
|
||||
@ -168,7 +168,8 @@
|
||||
lengthMenu: [10, 20, 50, 100],
|
||||
order: [[2, 'desc']],
|
||||
ajax: {
|
||||
url: `/data/progress-external/${encodeURIComponent(tipe)}`,
|
||||
// Jangan pakai path param: tipe bisa mengandung "/" yang membuat route param rusak.
|
||||
url: `/data/progress-external/by-tipe?tipe=${encodeURIComponent(tipe)}`,
|
||||
type: 'GET',
|
||||
},
|
||||
columns: [
|
||||
|
||||
@ -161,7 +161,7 @@
|
||||
<table class="table align-middle table-row-dashed fs-6 gy-3">
|
||||
<thead>
|
||||
<tr class="text-muted fw-semibold fs-7 text-uppercase gs-0">
|
||||
<th>Nama Step</th>
|
||||
<th>Nama Pitstop</th>
|
||||
<th>Nilai</th>
|
||||
<th style="width: 240px">Pemberi Nilai</th>
|
||||
<th class="text-end">Waktu</th>
|
||||
@ -347,8 +347,9 @@
|
||||
orderable: false,
|
||||
searchable: false,
|
||||
render: function (data, type, row) {
|
||||
const tipe = escapeHtml(row.tipe ?? '-');
|
||||
return `<a class="btn btn-sm btn-light-primary" href="/pitstop/progress-external/${encodeURIComponent(tipe)}">Detail</a>`;
|
||||
// Hindari path param: nilai `tipe` bisa mengandung "/" sehingga route param bisa gagal.
|
||||
const tipeRaw = String(row.tipe ?? '-');
|
||||
return `<a class="btn btn-sm btn-light-primary" href="/pitstop/progress-external?tipe=${encodeURIComponent(tipeRaw)}">Detail</a>`;
|
||||
},
|
||||
},
|
||||
],
|
||||
|
||||
@ -80,7 +80,7 @@
|
||||
<table class="table align-middle table-row-dashed fs-6 gy-3">
|
||||
<thead>
|
||||
<tr class="text-muted fw-semibold fs-7 text-uppercase gs-0">
|
||||
<th>Nama Step</th>
|
||||
<th>Nama Pitstop</th>
|
||||
<th>Nilai</th>
|
||||
<th style="width: 240px">Pemberi Nilai</th>
|
||||
<th class="text-end">Waktu</th>
|
||||
|
||||
@ -22,9 +22,12 @@ Route::middleware(['auth'])->group(function(){
|
||||
Route::get('/monitoring-pra-akreditasi/excel-external', [PitStopController::class, 'monitoringExcelExternal']);
|
||||
|
||||
Route::get('/pitstop/progress-unit/{unit_id}', [PitStopController::class, 'progressUnitDetail']);
|
||||
// Use query param (?tipe=...) to safely handle values containing "/" (encoded slashes may break route params)
|
||||
Route::get('/pitstop/progress-external', [PitStopController::class, 'progressExternalDetail']);
|
||||
Route::get('/pitstop/progress-external/{tipe}', [PitStopController::class, 'progressExternalDetail']);
|
||||
Route::get('/data/progress-Internal', [PitStopController::class, 'dataProgress']);
|
||||
Route::get('/data/progress-Internal/{unit_id}', [PitStopController::class, 'dataProgressUnit']);
|
||||
Route::get('/data/progress-external/by-tipe', [PitStopController::class, 'dataProgressExternalByTipe']);
|
||||
Route::get('/data/progress-external/{tipe}', [PitStopController::class, 'dataProgressExternalByTipe']);
|
||||
Route::get('/data/progress-all-karyawan', [PitStopController::class, 'dataProgressAllKaryawan']);
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user