<html>
<head>
</head>
<body>
<?
include "config/koneksi.php";
$start_time = strtotime("2010-01-27");
$end_time = strtotime("2019-09-26");
$current_time = time();
if($current_time < $start_time || $current_time > $end_time){
echo "Maaf, waktu untuk pengisian atau pengeditan KRS sudah berakhir";
echo " <p><input type='button' value='kembali' onclick=self.history.back()>";
session_start();
include "config/koneksi.php";
}else{
$was = mysql_query("SELECT * FROM mhs WHERE KDPRODI = '$_SESSION[NIMHS]'");
while($pada = mysql_fetch_array($was)){
$PRODI_MHS=$_SESSION['KDPRODI'];
}
$bln_sekarang=date("m");
$operator = '!=';
if($bln_sekarang < 6){ //genap
$operator = '=';
}
$sql =mysql_query ("select * from jadwal1 inner join makul on makul.KDMKM=jadwal1.KDMKM where jadwal1.SEMESTER % 2 $operator 0 and makul.KDPRODI = '$PRODI_MHS' order by jadwal1.SEMESTER asc");
while($k=mysql_fetch_array($sql)){
$kode[]=$k['KDMKM'];
$nama[]=$k['NAKMK'];
$hari[]=$k['HARI'];
$jam[]=$k['JAM'];
$sks[] = $k['SKSMK'];
$semester[]=$k['SEMESTER'];
$ruang[]=$k['KDRUANG'];
$kelas[]=$k['kdkelas'];
$nmbu[]=$k['BU'];
$kdwp[]=$k['KDWP'];
}
?>
<html>
<head>
<title>Check Box KRS</title>
<script>
<?php
echo "var jumlah = ".count($kode).";\n";
echo "var sks = new Array();\n";
//mengambil sks matakuliah dan memasukkan ke array javascript
for($j=0;$j<count($kode);$j++){
echo "sks['".$kode[$j]."'] = ".$sks[$j].";\n";
}
?>
function hitungtotal(){
jum = 0;
for(i=0;i<jumlah;i++){
id = "mk"+i;
td1 = "k1"+i;
td2 = "k2"+i;
td3 = "k3"+i;
td4 = "k4"+i;
td5 = "k5"+i;
td6 = "k6"+i;
td7 = "k7"+i;
td8 = "k8"+i;td9 = "k9"+i;
if(document.getElementById(id).checked){
kode = document.getElementById(id).value
jum = jum + sks[kode];
//untuk mengubah warna latar tabel apabila diceklist
document.getElementById(td1).style.backgroundColor = "#";
document.getElementById(td2).style.backgroundColor = "#";
document.getElementById(td3).style.backgroundColor = "#";
document.getElementById(td4).style.backgroundColor = "#";
document.getElementById(td5).style.backgroundColor = "#";
document.getElementById(td6).style.backgroundColor = "#";
document.getElementById(td7).style.backgroundColor = "#";
document.getElementById(td8).style.backgroundColor = "#";
document.getElementById(td9).style.backgroundColor = "#";
}else {
document.getElementById(td1).style.backgroundColor = "white";
document.getElementById(td2).style.backgroundColor = "white";
document.getElementById(td3).style.backgroundColor = "white";
document.getElementById(td4).style.backgroundColor = "white";
document.getElementById(td5).style.backgroundColor = "white";
document.getElementById(td6).style.backgroundColor = "white";
document.getElementById(td7).style.backgroundColor = "white";
document.getElementById(td8).style.backgroundColor = "white";
document.getElementById(td9).style.backgroundColor = "white";
}
}
//menampilkan total jumlah SKS yang diambil
document.getElementById("jsks").innerHTML = jum;
}
</script>
</head>
<body>
<?php
$query="SELECT * from mhs inner join prodi on mhs.KDPRODI=prodi.KDPRODI where NIMHS='".$_SESSION['NIMHS']."'";
$result=mysql_query($query);
$data=mysql_fetch_array($result);
$bln_sekarang=date("m");
if($bln_sekarang >05 and $bln_sekarang<=12){
$thn_sekarang .="2";
$sem="Gasal";
}else{
$thn_sekarang .="1";
$sem="Genap";
}
echo"<table width=\"500\" cellspacing=5 border=\"0\"><tr><td rowspan=\"5\" valign=\"top\" align=\"justify\">
<tr>
<td>Nama</td><td>: $data[NMMHS]</td>";
echo "<td>NIM</td><td>: $data[NIMHS]</td></tr>";
$tahun=date("Y");
$th1=$tahun+1;
echo"<tr><td>Semester</td><td>: $data[KDSEMES]/ $sem </td>
<td>Tahun akademik</td><td>: $tahun/$th1</td></tr>
<tr><td>Program Studi</td><td>: $data[PRODI]</td>
";
$dosen=mysql_query("select * from mhs inner join dosen on mhs.NIDN=dosen.NIDN where NIMHS='$_SESSION[NIMHS]'");
while ($dos=mysql_fetch_array($dosen)){
$dosennya=$dos['NMDOS'];
echo "<td>Dosen Wali</td><td> : $dosennya </td></tr>";
}
$ip = mysql_query("select * from nilai WHERE NIMHS = '$_SESSION[NIMHS]'");
while($l = mysql_fetch_array($ip)){
$ipnya = $l['IPS'];
if($ipnya>=3){
$sks_dptdiambil="24 sks";
}
elseif($ipnya>=2.5 and $ipnya<3){
$sks_dptdiambil="21 sks";
}
elseif($ipnya>=2 and $ipnya<2.5){
$sks_dptdiambil="18 sks";
}
elseif($ipnya>=1.5 and $ipnya<2){
$sks_dptdiambil="15 sks";
}
else{
$sks_dptdiambil="12 sks";
}
echo "<tr>";
echo "<td >Ip Sebelumnya</td><td>: $ipnya</td>";
echo "<td >Jumlah SKS Y.A.D</td><td>: $sks_dptdiambil";
echo "</td></tr></table>";
}
?>
<p><form name="formkrs" method="POST" action="index1.php?hal=inputkrs">
<table border=1 width="96%" style="border-collapse:collapse" bordercolor="#999999">
<tr><td bgcolor="#999999" ><b>Kode</b></td>
<td bgcolor="#999999" ><b>Nama Mata Kuliah</b></td>
<td bgcolor="#999999" ><b>W/P</b></td>
<td bgcolor="#999999" align="center"><b>SKS</b></td>
<td bgcolor="#999999" ><b>HARI</b></td>
<td bgcolor="#999999" align="center"><b>JAM</b></td>
<td bgcolor="#999999" align="center"><b>KELAS</b></td>
<td bgcolor="#999999" align="center"><b>RUANG</b></td>
<td bgcolor="#999999" align="center"><b>SEMESTER</b></td>
<td bgcolor="#999999" align="center"><b>B/U</b></td>
<td bgcolor="#999999" align="center"><b>Ambil</b></td></tr>
<?php
//menampilkan matakuliah ke dalam tabel
for($i=0;$i<count($kode);$i++){
echo '<tr bgcolor="white"><td id="k1'.$i.'">'.$kode[$i].'</td>';
echo '<td id="k2'.$i.'">'.$nama[$i].'</td>';
echo '<td align="center" id="k2'.$i.'">'.$kdwp[$i].'</td>';
echo '<td align="center" id="k3'.$i.'">'.$sks[$i].'</td>';
echo '<td id="k4'.$i.'" align="center">'.$hari[$i].'</td>';
echo '<td align="center" id="k5'.$i.'">'.$jam[$i].'</td>';
//echo '<td align="center" id="k6'.$i.'">'.$nidn[$i].'</td>';
echo '<td align="center" id="k6'.$i.'">'.$kelas[$i].'</td>';
echo '<td align="center" id="k7'.$i.'">'.$ruang[$i].'</td>';
echo '<td align="center" id="k8'.$i.'">'.$semester[$i].'</td>'; ?>
<td>
<select name="nmbu[]" >
<option value=""> -- </option>
<? $pt = mysql_query("SELECT * FROM mkbu");
while($rpt=mysql_fetch_array($pt)){
echo "<option value=\"$rpt[BU]\">$rpt[BU]</option>";
}
?>
</select> </td>
<? //echo "<td align='center' id=k3$i>".$prodi[$i]."</td>";
//<td id="k4'.$i.'"><input type="checkbox" name="mk[]" onclick="hitungtotal()" value="'.$kode[$i].'" id="mk'.$i.'"/></td>
echo '<td align="center" id="k9'.$i.'"><input type="checkbox" name="mk[]"
onclick="hitungtotal()" value="'.$kode[$i].'" id="mk'.$i.'"/></tr>';
}
?>
<tr><td colspan=9 >JUMLAH YANG DIAMBIL</td><td align="center">
<span id=jsks></span></td></tr>
</table>
<br/>
<input name="kirim" type="submit" value="Kirim KRS">
<? } ?></form>
</body>
</html>
<?php
session_start();
include "config/koneksi.php";
$tahun= date("Y");
$NIMHS==$_SESSION['NIMHS'];
$was = mysql_query("SELECT * FROM mhs WHERE NIMHS = '$_SESSION[NIMHS]'");
$pada = mysql_fetch_array($was);
$semester = $pada['KDSEMES'];
$NMMHS = $pada['NMMHS'];
$mk = mysql_query("SELECT * FROM krs1 WHERE NIMHS = '$_SESSION[NIMHS]'");
$cek = mysql_query("SELECT * FROM krs1 WHERE NIMHS='$NIMHS' and KDSEMES='$semester' and tahun='$tahun' ");
if(mysql_num_rows($cek) > 0 ){
die("<br/>Anda sudah melakukan pengisian KRS pada semester ini !! <br>
Jika ingin mengisi ulang KRS semester ini, hapus dahulu KRS semester ini !! <br><br/>
<input type='button' value='kembali' onclick=self.history.back()>");
}
if((!empty($_POST['nmbu'])) and (!empty($_POST['mk']))){
$nmbu_ = $_POST['nmbu'];
$hitnmbu = count($nmbu);
$mk_ = $_POST['mk'];
$hitmk = count($mk_);
}
if((empty($_POST['nmbu'])) and (empty($_POST['mk']))){
echo "<script>alert('Maaf, mohon lengkapi input yang tersedia !');history.go(-1);</script>";
}else{
$lolos = true;
}
if($lolos){
for($x=0;$x<$hitnmbu;$x++){
if(!empty($nmbu_[$x])){
mysql_query("insert into krs1 (NIMHS,NMMHS,kodekuliah,SKSMK,BU,KDSEMES,tahun) values ('$NIMHS','$NMMHS','$mk_[$x]','$sks','$nmbu_[$x]','$semester','$tahun')");
}
}
}
echo"NIM : $NIMHS<br>";
echo"Semester : $semester<br>";
echo"Tahun : $tahun<br>";
?>
Berikut KRS yang anda ambil :
<table border=1 width=400 style="border-collapse:collapse" bordercolor="#999999">
<tr><td><b>No</b></td>
<td><b>Kode</b></td>
<td><b>Nama Mata Kuliah</b></td>
<td><b>MK B/U</b></td>
<td><b>SKS</b></td>
<?
$tampilkrs=mysql_query("SELECT * FROM krs1, makul where NIMHS = '$_SESSION[NIMHS]' AND krs1.kodekuliah = makul.KDMKM and krs1.KDSEMES='$semester' and krs1.tahun='$tahun'");
$jum = 0;
$i = 1;
$jummk = 0;
while ($k=mysql_fetch_array($tampilkrs)){
echo "<tr><td>$i</td>";
echo "<td>".$k['KDMKM']."</td>";
echo "<td>".$k['NAKMK']."</td>";
echo "<td align='center'>".$k['BU']."</td>";
echo "<td align='center'>".$k['SKSMK']."</td>";
$jummk = $jummk + $k['KDMKM'];
$jum = $jum + $k['SKSMK'];
$i++;
}
echo "<tr><td></td><td></td><td colspan=2>Jumlah KRS yang diambil</td><td align='center'>$jum</td></tr>";
mysql_query("insert into jumlah(NIMHS,JUMSKS,KDSEMES,tahun) values ('$NIMHS','$jum','$semester','$tahun')");
?>
</table>