Tugas Roki Framework
Tugas Roki Framework
NIM : C1857201039
MATA KULIAH : PEMROGRAMAN FRAMEWORK
2. Halaman Awal
3. Halaman Daftar Siswa
if ($query->num_rows!==0) {
echo "<form method='post' action='./model/proses.php'>";
echo "<tr><th colspan='6'>Yang ditandai :
<button type='submit' class='btn btn-warning'
name='acc_absen2'>Konfirmasi</button>
<button type='submit' class='btn btn-danger'
name='dec_absen2'/>Tolak</button>
</th></tr>";
echo "<div class='table-responsive'>
<table class='table table-striped'>
<thead>
<tr>
<th>No</th>
<th>Nama Siswa</th>
<th>Keterangan</th>
<th>Hari, Tanggal</th>
<th>Pukul</th>
<th>Aksi</th>
</tr>
</thead>
<tbody>";
$no=0;
while ($get_absen=$query->fetch_assoc()) {
$id_absen = $get_absen['id_absen'];
$id_user = $get_absen['id_user'];
$name = $get_absen['name_user'];
$date = "$get_absen[nama_hri], $get_absen[nama_tgl] $get_absen[nama_bln]
".date("Y");
if ($get_absen['st_jam_msk']==="Menunggu") {
$type = "in";
$status = "Absen masuk";
$time = $get_absen['jam_msk'];
}elseif ($get_absen['st_jam_klr']==="Menunggu") {
$type = "out";
$status = "Absen keluar";
$time = $get_absen['jam_klr'];
}
$no++;
echo "<tr>
<td>
<input type='checkbox' name='id_absen[]' value='$id_absen,$type'/>
<b>$no</b>
</td>
<td>$name</td>
<td><strong><i>$status</i></strong></td>
<td>$date</td>
<td>$time</td>
<td>
<button type='button' class='btn btn-warning'
onclick=\"window.location.href='./model/proses.php?
acc_absen=$id_absen&type=$type';\">Konfirmasi</button>
<button type='button' class='btn btn-danger'
onclick=\"window.location.href='./model/proses.php?
dec_absen=$id_absen&type=$type';\">Tolak</button>
</td>
</tr>";
}
echo "</form></tbody></table></div>";
$conn->close();
} else {
echo "<div class='alert alert-danger'><strong>Tidak ada permintaan
Absen.</strong></div>";
}
?>
Add_siswa.php
<h3 class="page-header">Tambah Siswa Baru</h3>
<?php
if (isset($_GET['st'])) {
if ($_GET['st']==1) {
echo "<div class='alert alert-
warning'><strong>Berhasil Ditambahkan.</strong></div>";
} elseif ($_GET['st']==2) {
echo "<div class='alert alert-
danger'><strong>Gagal Menambahkan.</strong></div>";
} elseif ($_GET['st']==3) {
echo "<div class='alert alert-
danger'><strong>Maaf Email sudah digunakan.</strong></div>";
} elseif ($_GET['st']==4) {
echo "<div class='alert alert-danger'><strong>Semua kolom wajib di
isi.</strong></div>";
} elseif ($_GET['st']==5) {
echo "<div class='alert alert-danger'><strong>Katasandi tidak
cocok!</strong></div>";
} elseif ($_GET['st']==6) {
echo "<div class='alert alert-danger'><strong>NIS sudah
terdaftar!</strong></div>";
}
}
?>
<form class="form-horizontal" role="form" style="width:80%" onSubmit="return
validasi()" name="formulir" method="post" action="./model/proses.php">
<div class="form-group">
<label class="control-label col-sm-2" for="name">NIS:</label>
<div class="col-sm-10">
<input type="number" class="form-control" name="nis" placeholder="Masukan
NIS" required>
</div>
</div>
<div class="form-group">
<label class="control-label col-sm-2" for="name">Nama Lengkap:</label>
<div class="col-sm-10">
<input type="text" class="form-control" name="nama" placeholder="Masukan
Nama Lengkap" required>
</div>
</div>
<div class="form-group">
<label class="control-label col-sm-2" for="jk">Jenis Kelamin:</label>
<div class="col-sm-10">
<label class="radio-inline"><input type="radio"
name="jk" id="jk" value="L">Laki-laki</label>
<label class="radio-inline"><input type="radio"
name="jk" id="jk" value="P" >Perempuan</label>
</div>
</div>
<div class="form-group">
<label class="control-label col-sm-2" for="sekolah">Nama Sekolah:</label>
<div class="col-sm-10">
<input type="text" class="form-control" name="sklh" placeholder="Masukan
Nama Sekolah" required>
</div>
</div>
<div class="form-group">
<label class="control-label col-sm-2" for="email">Email:</label>
<div class="col-sm-10">
<input type="email" class="form-control" name="email" placeholder="Masukan
email" required>
</div>
</div>
<div class="form-group">
<fieldset>
<label class="control-label col-sm-2">Katasandi:</label>
<div class="col-sm-10">
<input type="password" class="form-control" name="pwd"
placeholder="Masukan katasandi" id="password" required>
</div>
</div>
<div class="form-group">
<label class="control-label col-sm-2"></label>
<div class="col-sm-10">
<input type="password" class="form-control" name="pwd_cek"
placeholder="Ulangi katasandi" id="confirm_password" required>
</div>
</fieldset>
</div>
<div class="form-group">
<div class="col-sm-offset-2 col-sm-10">
<button type="submit" class="btn btn-default"
name="add_siswa">Simpan</button>
<button type="reset" class="btn btn-warning" name="add_siswa">Reset</button>
</div>
</div>
</form>
Catatan.php
<h3 class='page-header'>Catatan Kegiatan Siswa PKL</h3>
<div class='table-responsive'>
<?php
if (isset($_GET['id_siswa'])) {
if ($_GET['id_siswa']!=="") {
$id_user=$_GET['id_siswa'];
include './view/note.php';
} else {
header("location:catatan");
}
} else {
$sql = "SELECT*FROM detail_user ORDER
BY sklh_user ASC";
if ($conn->query($sql)->num_rows!==0) {
echo "<table class='table table-striped'
style='width:50%'>
<thead>
<tr>
<th>No</th>
<th>Nama
Siswa</th>
<th>Asal
Sekolah</th>
<th>Aksi</th>
</tr>
</thead>
<tbody>";
$query_siswa = $conn->query($sql);
$no=0;
while ($get_siswa = $query_siswa-
>fetch_assoc()) {
$id_siswa =
$get_siswa['id_user'];
$name =
$get_siswa['name_user'];
$school =
$get_siswa['sklh_user'];
$no++;
echo "<tr>
<td>$no</td>
<td>$name</td>
<td>$school</td>
<td><a
href='catatan&id_siswa=$id_siswa' title='Catatan $name'>Lihat Catatan</a></td>
</tr>";
}
$conn->close();
echo "</tbody></table>";
} else {
echo "<div class='alert alert-
danger'><strong>Tidak ada Siswa untuk ditampilkan</strong></div>";
}
}
?>
</div>
detail_absen.php
<h3 class='page-header'>Detail Absensi Siswa PKL</h3>
<div class='table-responsive'>
<?php
if (isset($_GET['id_siswa'])) {
if ($_GET['id_siswa']!=="") {
$id_user=$_GET['id_siswa'];
include './view/detail_absen.php';
} else {
header("location:absensi");
}
} else {
$sql = "SELECT*FROM detail_user ORDER
BY sklh_user ASC";
$query = $conn->query($sql);
if ($query->num_rows!==0) {
echo "<table class='table table-striped'
style='width:50%'>
<thead>
<tr>
<th>No</th>
<th>Nama
Siswa</th>
<th>Asal
Sekolah</th>
<th>Aksi</th>
</tr>
</thead>
<tbody>";
$no=0;
while ($get_siswa = $query-
>fetch_assoc()) {
$id_siswa =
$get_siswa['id_user'];
$name =
$get_siswa['name_user'];
$school =
$get_siswa['sklh_user'];
$no++;
echo "<tr>
<td>$no</td>
<td>$name</td>
<td>$school</td>
<td><a
href='absensi&id_siswa=$id_siswa' title='Absensi $name'>Lihat Absensi</a></td>
</tr>";
}
echo "</tbody></table>";
$conn->close();
} else {
echo "<div class='alert alert-
danger'><strong>Tidak ada Siswa untuk ditampilkan</strong></div>";
}
}
?>
</div>
edit_siswa.php
<?php
$id_siswa = mysqli_real_escape_string($conn, $_GET['id_siswa']);
$sql_sw = "SELECT*FROM detail_user NATURAL LEFT JOIN user WHERE
id_user= '$id_siswa'";
if ($get_sw = $conn->query($sql_sw)->fetch_assoc()) {
extract($get_sw);
?>
<form class="form-horizontal" role="form" style="width:80%" onSubmit="return
validasi()" name="formulir" method="post" action="./model/proses.php">
<input type="hidden" name="id_user" value="<?php echo $id_user; ?>" />
<div class="form-group">
<label class="control-label col-sm-2" for="name">NIS:</label>
<div class="col-sm-10">
<input type="number" value="<?php echo $nis_user; ?>" class="form-control"
name="nis" placeholder="Masukan NIS" required>
</div>
</div>
<div class="form-group">
<label class="control-label col-sm-2" for="name">Nama Lengkap:</label>
<div class="col-sm-10">
<input type="text" value="<?php echo $name_user; ?>" class="form-control"
name="nama" placeholder="Masukan Nama Lengkap" required>
</div>
</div>
<div class="form-group">
<label class="control-label col-sm-2" for="jk">Jenis Kelamin:</label>
<div class="col-sm-10">
<?php
$jk = array("Laki-laki","Perempuan");
$jk_vl = array("L","P");
$sum = count($jk_vl)-1;
for ($i=0; $i<= $sum ; $i++) {
if ($jk_user == "$jk_vl[$i]") {
$checked = "checked";
} else {
$checked = "";
}
echo '<label class="radio-inline"><input type="radio" name="jk" id="jk"
value="'.$jk_vl[$i].'" '.$checked.'>'.$jk[$i].'</label>';
}
?>
</div>
</div>
<div class="form-group">
<label class="control-label col-sm-2" for="sekolah">Nama Sekolah:</label>
<div class="col-sm-10">
<input type="text" value="<?php echo $sklh_user; ?>" class="form-control"
name="sklh" placeholder="Masukan Nama Sekolah" required>
</div>
</div>
<div class="form-group">
<label class="control-label col-sm-2" for="email">Email:</label>
<div class="col-sm-10">
<strong><?php echo $email_user; ?></strong>
</div>
</div>
<div class="form-group">
<fieldset>
<label class="control-label col-sm-2">Katasandi:</label>
<div class="col-sm-10">
<a href="katasandi&id=<?php echo $id_user; ?>">Ubah katasandi</a>
<!-- <input type="password" class="form-control" name="pwd"
placeholder="Masukan katasandi" id="password" required>
</div>
</div>
<div class="form-group">
<label class="control-label col-sm-2"></label>
<div class="col-sm-10">
<input type="password" class="form-control" name="pwd_cek"
placeholder="Ulangi katasandi" id="confirm_password" required> -->
</div>
</fieldset>
</div>
<div class="form-group">
<div class="col-sm-offset-2 col-sm-10">
<button type="submit" class="btn btn-default"
name="edit_siswa">Simpan</button>
<button type="button" onclick="hapusSiswa(<?php echo $id_user; ?>)"
class="btn btn-danger" name="">Hapus Siswa</button>
</div>
</div>
</form>
<?php
} else {
echo "Data tidak ditemukan";
}
?>
index.php
<?php
/**
*
* Absensi Siswa Prakerin
* codinger-mini.blogpsot.com
* fb.me/rizal.ofdraw
*
*/
echo "<script>window.alert('Waaahh.. Bandel ya !!
');window.location=('../home');</script>";
?>
katasandi.php
<h3 class='page-header'>Ganti katasandi</h3>
<div class="col-md-6">
<?php
if (isset($_GET['st'])) {
if ($_GET['st']==1) {
echo "<div class='alert alert-warning'><strong>Berhasil
Disimpan.</strong></div>";
} elseif ($_GET['st']==2) {
echo "<div class='alert alert-danger'><strong>Gagal
Menyimpan.</strong></div>";
} elseif ($_GET['st']==3) {
echo "<div class='alert alert-success'><strong>Katasandi lama
salah.</strong></div>";
} elseif ($_GET['st']==4) {
echo "<div class='alert alert-danger'><strong>Kolom tidak boleh
kosong.</strong></div>";
} elseif ($_GET['st']==5) {
echo "<div class='alert alert-danger'><strong>Konfirmasi katasandi
tidaksama.</strong></div>";
}
}
$id = mysqli_real_escape_string($conn, $_GET['id']);
if ($id == $_SESSION['id']) {
$sql_gu = "SELECT*FROM detail_pb NATURAL LEFT JOIN user WHERE
id_user='$id'";
} else {
$sql_gu = "SELECT*FROM detail_user NATURAL LEFT JOIN user WHERE
id_user='$id'";
}
$query = $conn->query($sql_gu);
if ($get_u = $query->fetch_assoc()) {
extract($get_u);
?>
<!-- Horizontal Form -->
<div class="box box-info">
<br />
<!-- form start -->
<form class="form-horizontal" method="post" action="./model/proses.php">
<input type="hidden" value="<?php echo $id; ?>" name="id">
<div class="box-body">
<div class="form-group">
<label for="inputPassword3" class="col-sm-2 control-label">Pengguna</label>
<div class="col-sm-10">
<strong class="form-control"><?php echo "$name_user - $email_user";
?></strong>
</div>
</div>
<div class="form-group">
<label for="inputPassword3" class="col-sm-2 control-label">Katasandi
baru</label>
<div class="col-sm-10">
<input type="password" name="new-pwd" class="form-control" id="masuk"
placeholder="*************" required>
</div>
</div>
<div class="form-group">
<label for="inputPassword3" class="col-sm-2 control-label">Ulangi
katasandi</label>
<div class="col-sm-10">
<input type="password" name="new-pwd-cek" class="form-control"
id="masuk_lagi" placeholder="*************" required>
</div>
</div>
</div><!-- /.box-body -->
<div class="box-footer">
<button type="submit" name="change-pwd" class="btn btn-info pull-
right">Ubah</button>
</div><!-- /.box-footer -->
</form>
<?php
if ($id !== $_SESSION['id']) {
echo '<br /><a href="./siswa&id_siswa="'.$id.'">Kembali ke profil Siswa</a>
';
}
?>
</div><!-- /.box -->
<?php
} else {
echo "<div class='alert alert-danger'><strong>User tidak
ditemukan.</strong></div>";
}
?>
<script src="./lib/jquery.min.js"></script>
<script>
$(document).ready(function(){
$('#masuk_lagi').keyup(function(){
var passpertama=$('#masuk').val();
var passkedua=$('#masuk_lagi').val();
if($('#masuk').val() != $('#masuk_lagi').val()){
$('#masuk_lagi').css('background','#F2DEDE');
$('#masuk').css('background','#F2DEDE');
} else if(passpertama == passkedua){
$('#masuk_lagi').css('background','#FCF8E3');
$('#masuk').css('background','#FCF8E3');
}
});
});
</script>
req_catatan.php
<h3 class="page-header">Konfirmasi Catatan Kegiatan Siswa</h3>
<?php
$sql = "SELECT*FROM catatan NATURAL LEFT JOIN bulan NATURAL JOIN
hari NATURAL JOIN tanggal NATURAL JOIN detail_user WHERE
status_cat='Menunggu'";
$query = $conn->query($sql);
// Notifikasi Absen
if (isset($_GET['ab'])) {
if ($_GET['ab']==1) {
echo "<div class='alert alert-
warning'><strong>Catatan telah dikonfirmasi.</strong></div>";
} elseif($_GET['ab']==2) {
echo "<div class='alert alert-
danger'><strong>Gagal, Silahkan Coba Kembali!</strong></div>";
} elseif($_GET['ab']==3) {
echo "<div class='alert alert-warning'><strong>Catatan berhasil
ditolak.</strong></div>";
}
}
if ($query->num_rows!==0) {
echo "<div class='table-responsive'>
<table class='table table-striped'>
<thead>
<tr>
<th>No</th>
<th>Nama Siswa</th>
<th>Hari, Tanggal</th>
<th width='40%'>Kegiatan</th>
<th>Aksi</th>
</tr>
</thead>
<tbody>";
$no=0;
while ($get_note=$query->fetch_assoc()) {
$id_note = $get_note['id_cat'];
$id_user = $get_note['id_user'];
$name = $get_note['name_user'];
$note = nl2br(htmlentities($get_note['isi_cat']));
$date = "$get_note[nama_hri], $get_note[nama_tgl] $get_note[nama_bln]
".date("Y");
$no++;
echo "<tr>
<td>$no</td>
<td>$name</td>
<td>$date</td>
<td>$note</td>
<td>
<button type='button' class='btn btn-warning'
onclick=\"window.location.href='./model/proses.php?
acc_note=$id_note';\">Konfirmasi</button>
<button type='button' class='btn btn-danger'
onclick=\"window.location.href='./model/proses.php?dec_note=$id_note';\">Tolak</
button>
</td>
</tr>";
}
echo "</tbody></table></div>";
$conn->close();
} else {
echo "<div class='alert alert-danger'><strong>Tidak ada permintaan
Catatan.</strong></div>";
}
?>
siswa.php
<h3 class='page-header'>Daftar Siswa PKL</h3>
<?php
if (isset($_GET['st'])) {
if ($_GET['st']==1) {
echo "<div class='alert alert-warning'><strong>Berhasil
Disimpan.</strong></div>";
} elseif ($_GET['st']==2) {
echo "<div class='alert alert-danger'><strong>Gagal
Menyimpan.</strong></div>";
} elseif ($_GET['st']==3) {
echo "<div class='alert alert-success'><strong>Berhasil
dihapus.</strong></div>";
} elseif ($_GET['st']==4) {
echo "<div class='alert alert-danger'><strong>Data tidak boleh
kosong.</strong></div>";
} elseif ($_GET['st']==5) {
echo "<div class='alert alert-danger'><strong>Gagal
dihapus.</strong></div>";
}
}
?>
<div class='table-resfponsive'>
<?php
if (isset($_GET['id_siswa'])) {
if ($_GET['id_siswa']!=="") {
$id_user=$_GET['id_siswa'];
include './view/adm/edit_siswa.php';
} else {
header("location:siswa");
}
} else {
$limit = 10;
$start = 1;
$slice = 9;
$self_server = "./siswa";
$q = "SELECT * FROM detail_user ORDER BY id_user ASC";
$r = $conn->query($q);
$totalrows = $r->num_rows;
if(!isset($_GET['pn']) || !is_numeric($_GET['pn'])){
$page = 1;
} else {
$page = $_GET['pn'];
}
if ($r->num_rows!==0) {
echo "<table class='table table-striped' style='width:70%'>
<thead>
<tr>
<th>No</th>
<th>Nama Siswa</th>
<th>Asal Sekolah</th>
<th>Aksi</th>
</tr>
</thead>
<tbody>";
$query_siswa = $conn->query($q);
$no=0;
while ($get_siswa = $query_siswa->fetch_assoc()) {
$id_siswa = $get_siswa['id_user'];
$name = $get_siswa['name_user'];
$school = $get_siswa['sklh_user'];
$no++;
echo "<tr>
<td>$no</td>
<td>$name</td>
<td><strong>$school</strong></td>
<td><a href='siswa&id_siswa=$id_siswa' title='Edit $name'>Edit
info</a> • <a style='cursor:pointer' onclick='hapusSiswa($id_siswa)' >Hapus
Siswa</a></td>
</tr>";
}
// $conn->close();
echo "</tbody></table>";
} else {
echo "<hr />";
}
} else {
echo "<div class='alert alert-danger'><strong>Terjadi
kesalahan.</strong></div>";
}