penyesuaian pada Daftar Peserta Psikotest masih ada data yang tidak tampil
Build and publish Docker image / build (push) Successful in 12s
Build and publish Docker image / build (push) Successful in 12s
This commit is contained in:
1 parent
6a8e7fcbcb
commit
24383d9ed1
1 file changed
+208
-9
+208
-9
@@ -1,11 +1,210 @@
|
||||
<?php
|
||||
require __DIR__ . '/bootstrap.php'; require_admin();
|
||||
$search = substr(trim($_GET['q'] ?? ''),0,100); $stage = (string)($_GET['stage'] ?? '');
|
||||
$where = ' WHERE 1=1'; $params = []; $types = '';
|
||||
if ($search !== '') { $where .= ' AND (p.nama LIKE ? OR p.email LIKE ? OR p.posisi LIKE ?)'; $params = array_fill(0,3,'%'.$search.'%'); $types = 'sss'; }
|
||||
if (array_key_exists($stage, STAGES)) { $where .= ' AND p.kode=?'; $params[] = (int)$stage; $types .= 'i'; }
|
||||
$total = (int)one('SELECT COUNT(*) n FROM in_daper p'.$where,$types,$params)['n'];
|
||||
$pages = max(1,(int)ceil($total/25)); $page = max(1,min($pages,(int)($_GET['page'] ?? 1))); $offset=($page-1)*25;
|
||||
$list = rows('SELECT p.id,p.nama,p.email,p.nowa,p.posisi,p.level,p.kode,p.cek,p.ts,COALESCE(j.score,0) score FROM in_daper p LEFT JOIN (SELECT idap,SUM(CASE WHEN cek=\'10\' THEN 10 ELSE 0 END) score FROM in_jawab GROUP BY idap) j ON j.idap=p.id'.$where.' ORDER BY p.ts DESC,p.id DESC LIMIT 25 OFFSET '.$offset,$types,$params);
|
||||
require __DIR__ . '/bootstrap.php';
|
||||
require_admin();
|
||||
|
||||
$search = substr(trim($_GET['q'] ?? ''), 0, 100);
|
||||
$stage = (string) ($_GET['stage'] ?? '');
|
||||
|
||||
// Siapkan filter untuk jumlah data dan daftar peserta.
|
||||
$where = ' WHERE 1=1';
|
||||
$params = [];
|
||||
$types = '';
|
||||
|
||||
if ($search !== '') {
|
||||
$where .= ' AND (p.nama LIKE ? OR p.email LIKE ? OR p.posisi LIKE ?)';
|
||||
$params = array_fill(0, 3, '%' . $search . '%');
|
||||
$types = 'sss';
|
||||
}
|
||||
|
||||
if (array_key_exists($stage, STAGES)) {
|
||||
$where .= ' AND p.kode = ?';
|
||||
$params[] = (int) $stage;
|
||||
$types .= 'i';
|
||||
}
|
||||
|
||||
// Tampilkan 25 peserta per halaman.
|
||||
$total = (int) one(
|
||||
'SELECT COUNT(*) n FROM in_daper p' . $where,
|
||||
$types,
|
||||
$params
|
||||
)['n'];
|
||||
|
||||
$pages = max(1, (int) ceil($total / 25));
|
||||
$page = max(1, min($pages, (int) ($_GET['page'] ?? 1)));
|
||||
$offset = ($page - 1) * 25;
|
||||
|
||||
$sql = "
|
||||
SELECT
|
||||
p.id,
|
||||
p.nama,
|
||||
p.email,
|
||||
p.nowa,
|
||||
p.posisi,
|
||||
p.level,
|
||||
p.kode,
|
||||
p.cek,
|
||||
p.ts,
|
||||
COALESCE(j.score, 0) score
|
||||
FROM in_daper p
|
||||
LEFT JOIN (
|
||||
SELECT
|
||||
idap,
|
||||
SUM(CASE WHEN cek = '10' THEN 10 ELSE 0 END) score
|
||||
FROM in_jawab
|
||||
GROUP BY idap
|
||||
) j ON j.idap = p.id
|
||||
";
|
||||
$sql .= $where;
|
||||
$sql .= ' ORDER BY p.ts DESC, p.id DESC LIMIT 25 OFFSET ' . $offset;
|
||||
|
||||
$list = rows($sql, $types, $params);
|
||||
|
||||
page_start('Daftar Peserta Psikotest', 'participants');
|
||||
?><section class="card"><div class="card-heading"><div><h2>Semua peserta <span class="count"><?=$total?></span></h2><p>Pantau progres tes dan hasil seleksi kandidat.</p></div><a class="button" href="participant-new.php">+ Tambah peserta</a></div><form class="filters" method="get"><input aria-label="Cari peserta" name="q" placeholder="Cari nama, email, atau posisi…" value="<?=e($search)?>"><select name="stage" aria-label="Tahap seleksi"><option value="">Semua tahap seleksi</option><?php foreach(STAGES as $k=>$v): ?><option value="<?=$k?>" <?=$stage===(string)$k?'selected':''?>><?=e($v)?></option><?php endforeach; ?></select><button class="button secondary">Terapkan</button></form><div class="table-wrap"><table><thead><tr><th>Peserta</th><th>Posisi dilamar</th><th>Progres tes</th><th>Seleksi</th><th>Skor</th><th></th></tr></thead><tbody><?php foreach($list as $p): ?><tr><td><div class="person"><span class="avatar"><?=e(substr($p['nama'],0,1))?></span><div><strong><?=e($p['nama'])?></strong><small><?=e($p['email'])?></small></div></div></td><td><?=e($p['posisi'])?></td><td><span class="badge <?=(int)$p['level']>=4?'success':''?>"><?=(int)$p['level']>=4?'Selesai':((int)$p['level']===0?'Belum mulai':'Fase '.(int)$p['level'].' / 4')?></span></td><td><?=e(STAGES[(int)$p['kode']] ?? 'Kode '.$p['kode'])?></td><td><?php if((int)$p['cek']===1): ?><strong><?=(int)$p['score']?></strong><small><?=(int)$p['score']>=threshold()?'Lulus skor':'Di bawah ambang'?></small><?php else: ?><span class="muted">Belum dinilai</span><?php endif; ?></td><td><a class="button secondary compact" href="idap_jawab.php?id=<?=(int)$p['id']?>">Lihat hasil ↗</a></td></tr><?php endforeach; ?><?php if(!$list): ?><tr><td colspan="6" class="empty">Tidak ada peserta yang sesuai pencarian.</td></tr><?php endif; ?></tbody></table></div><div class="pagination"><span><?=$total?> peserta · Halaman <?=$page?> dari <?=$pages?></span><div><?php if($page>1): ?><a class="button secondary compact" href="?<?=e(http_build_query(['q'=>$search,'stage'=>$stage,'page'=>$page-1]))?>">← Sebelumnya</a><?php endif; ?><?php if($page<$pages): ?><a class="button secondary compact" href="?<?=e(http_build_query(['q'=>$search,'stage'=>$stage,'page'=>$page+1]))?>">Selanjutnya →</a><?php endif; ?></div></div></section><?php page_end(); ?>
|
||||
?>
|
||||
|
||||
<section class="card">
|
||||
<div class="card-heading">
|
||||
<div>
|
||||
<h2>Semua peserta <span class="count"><?= $total ?></span></h2>
|
||||
<p>Pantau progres tes dan hasil seleksi kandidat.</p>
|
||||
</div>
|
||||
<a class="button" href="participant-new.php">+ Tambah peserta</a>
|
||||
</div>
|
||||
|
||||
<form class="filters" method="get">
|
||||
<input
|
||||
aria-label="Cari peserta"
|
||||
name="q"
|
||||
placeholder="Cari nama, email, atau posisi…"
|
||||
value="<?= e($search) ?>"
|
||||
>
|
||||
<select name="stage" aria-label="Tahap seleksi">
|
||||
<option value="">Semua tahap seleksi</option>
|
||||
<?php foreach (STAGES as $stageCode => $stageLabel): ?>
|
||||
<option
|
||||
value="<?= $stageCode ?>"
|
||||
<?= $stage === (string) $stageCode ? 'selected' : '' ?>
|
||||
>
|
||||
<?= e($stageLabel) ?>
|
||||
</option>
|
||||
<?php endforeach; ?>
|
||||
</select>
|
||||
<button class="button secondary">Terapkan</button>
|
||||
</form>
|
||||
|
||||
<div class="table-wrap">
|
||||
<table>
|
||||
<thead>
|
||||
<tr>
|
||||
<th>Peserta</th>
|
||||
<th>Date Add</th>
|
||||
<th>No. Handphone</th>
|
||||
<th>Posisi dilamar</th>
|
||||
<th>Progres tes</th>
|
||||
<th>Seleksi</th>
|
||||
<th>Skor</th>
|
||||
<th></th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
<?php foreach ($list as $participant): ?>
|
||||
<?php
|
||||
$level = (int) $participant['level'];
|
||||
$phone = trim((string) ($participant['nowa'] ?? ''));
|
||||
|
||||
if ($level >= 4) {
|
||||
$progressLabel = 'Selesai';
|
||||
} elseif ($level === 0) {
|
||||
$progressLabel = 'Belum mulai';
|
||||
} else {
|
||||
$progressLabel = 'Fase ' . $level . ' / 4';
|
||||
}
|
||||
?>
|
||||
<tr>
|
||||
<td>
|
||||
<div class="person">
|
||||
<span class="avatar">
|
||||
<?= e(substr($participant['nama'], 0, 1)) ?>
|
||||
</span>
|
||||
<div>
|
||||
<strong><?= e($participant['nama']) ?></strong>
|
||||
<small><?= e($participant['email']) ?></small>
|
||||
</div>
|
||||
</div>
|
||||
</td>
|
||||
<td><?= e($participant['ts'] ?? '—') ?></td>
|
||||
<td><?= e($phone !== '' ? $participant['nowa'] : '—') ?></td>
|
||||
<td><?= e($participant['posisi']) ?></td>
|
||||
<td>
|
||||
<span class="badge <?= $level >= 4 ? 'success' : '' ?>">
|
||||
<?= e($progressLabel) ?>
|
||||
</span>
|
||||
</td>
|
||||
<td>
|
||||
<?= e(STAGES[(int) $participant['kode']] ?? 'Kode ' . $participant['kode']) ?>
|
||||
</td>
|
||||
<td>
|
||||
<?php if ((int) $participant['cek'] === 1): ?>
|
||||
<strong><?= (int) $participant['score'] ?></strong>
|
||||
<small>
|
||||
<?= (int) $participant['score'] >= threshold() ? 'Lulus skor' : 'Di bawah ambang' ?>
|
||||
</small>
|
||||
<?php else: ?>
|
||||
<span class="muted">Belum dinilai</span>
|
||||
<?php endif; ?>
|
||||
</td>
|
||||
<td>
|
||||
<a
|
||||
class="button secondary compact"
|
||||
href="idap_jawab.php?id=<?= (int) $participant['id'] ?>"
|
||||
>
|
||||
Lihat hasil ↗
|
||||
</a>
|
||||
</td>
|
||||
</tr>
|
||||
<?php endforeach; ?>
|
||||
|
||||
<?php if (!$list): ?>
|
||||
<tr>
|
||||
<td colspan="8" class="empty">
|
||||
Tidak ada peserta yang sesuai pencarian.
|
||||
</td>
|
||||
</tr>
|
||||
<?php endif; ?>
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
|
||||
<div class="pagination">
|
||||
<span><?= $total ?> peserta · Halaman <?= $page ?> dari <?= $pages ?></span>
|
||||
<div>
|
||||
<?php if ($page > 1): ?>
|
||||
<?php
|
||||
$previousUrl = '?' . http_build_query([
|
||||
'q' => $search,
|
||||
'stage' => $stage,
|
||||
'page' => $page - 1,
|
||||
]);
|
||||
?>
|
||||
<a class="button secondary compact" href="<?= e($previousUrl) ?>">
|
||||
← Sebelumnya
|
||||
</a>
|
||||
<?php endif; ?>
|
||||
|
||||
<?php if ($page < $pages): ?>
|
||||
<?php
|
||||
$nextUrl = '?' . http_build_query([
|
||||
'q' => $search,
|
||||
'stage' => $stage,
|
||||
'page' => $page + 1,
|
||||
]);
|
||||
?>
|
||||
<a class="button secondary compact" href="<?= e($nextUrl) ?>">
|
||||
Selanjutnya →
|
||||
</a>
|
||||
<?php endif; ?>
|
||||
</div>
|
||||
</div>
|
||||
</section>
|
||||
|
||||
<?php page_end(); ?>
|
||||
Reference in new issue
Block a user