<?php
include_once "library/inc.sesadmin.php";
if($_GET) {
if(empty($_GET['NoBeli'])){
echo "<b>Data yang dihapus tidak ada</b>";
}
else {
# Ambil Data dari Tabel pembelian_item, pembelian, barang
$dataSql = "SELECT pembelian_item.jumlah, pembelian_item.kd_barang,pembelian.no_pembelian, barang.kd_barang, barang.stok FROM pembelian_item, pembelian, barang
WHERE pembelian_item.no_pembelian= pembelian.no_pembelian AND pembelian_item.kd_barang = barang.kd_barang AND pembelian_item.no_pembelian='".$_GET['NoBeli']."'";
$dataQry = mysql_query($dataSql, $koneksidb) or die ("Error ambil data".mysql_error());
$dataRow = mysql_fetch_array($dataQry);
# Kurangi stok barang
mysql_query("UPDATE barang SET stok= stok - $dataRow[jumlah] WHERE kd_barang='$dataRow[kd_barang]'", $koneksidb)
or die ("Gagal query Update".mysql_error());
# Hapus Data pembelian dan pembelian item
$sqlDelete = "DELETE FROM pembelian WHERE no_pembelian='".$_GET['NoBeli']."'";
$qryDelete = mysql_query($sqlDelete, $koneksidb) or die ("Error hapus data".mysql_error());
if($qryDelete){
$sql2Delete = "DELETE FROM pembelian_item WHERE no_pembelian='".$_GET['NoBeli']."'";
$qry2Delete = mysql_query($sql2Delete, $koneksidb) or die ("Error hapus data 2".mysql_error());
echo "<meta http-equiv='refresh' content='0; url=?page=Daftar-Pembelian'>";
}
}
}
?>
<h4> Tambah Mata Kuliah </h4>
<form method=post action=?menu=create_makul>
<table border=1>
<tr>
<td> ID Mata Kuliah </td>
<td> : </td>
<td>
<?php
// Koneksi
//mysql_connect("localhost","root","");
//mysql_select_db("db_ebsof");
include "koneksi/koneksi.php";
$result = mysql_query("select * from mak1");
$jsArray = "var prdName = new Array();\n";
echo '<select name="prdId" onchange="changeValue(this.value)">';
echo '<option>-------</option>';
while ($row = mysql_fetch_array($result)) {
echo '<option value="' . $row['id_makul'] . '">' . $row['id_makul'] . '</option>';
$jsArray .= "prdName['" . $row['id_makul'] . "'] = {name:'" . addslashes($row['makul']) . "',desc:'".addslashes($row['sks'])."'};\n";
}
echo '</select>' ;
echo $makul;
?>
</td>
</td>
</tr>
<tr>
<td> Mata Kuliah </td>
<td> : </td>
<td> <input type="text" name="makul" id="makul"/> </td>
</tr>
</td>
</tr>
<tr>
<td> SKS </td>
<td> : </td>
<td> <input type="text" name="sks" id="sks"/> </td>
</tr>
<script type="text/javascript">
<?php echo $jsArray; ?>
function changeValue(id){
document.getElementById('makul').value = prdName[id].name;
document.getElementById('sks').value = prdName[id].desc;
};
</script>
<tr>
<td> Hari </td>
<td> : </td>
<td> <input type=text name=hari maxlength=100> </td>
</tr>
<tr>
<td> Jam Tayang </td>
<td> : </td>
<?
$gula=date('H:i');
$gula1=time('h:m:s');
?>
<td> <input type=text name=gula value= <?php echo "$gula"; ?>></td>
</tr>
<tr>
<td> Pengajar </td>
<td> : </td>
<td> <select name=id_pengajar>
<?php
$makul = $_GET['makul'];
include "koneksi/koneksi.php";
$sql = mysql_query("select nip from mak where makul='$makul' order by nip");
while ($data = mysql_fetch_array($sql)){
echo "<option value='$data[nip]'> $data[nip] </option>";
}
?>
</select>
</td>
</tr>
<tr>
<td colspan=3> <input type=submit value=Simpan> <input type=submit value=Batal onClick=history.back()> </td>
</tr>
</table>
</form>
<html>
<body>
<form name="myForm" action="daftar_proses.php" method="POST" onkeypress="send(event)" onsubmit="return daftar()">
<input Type="RADIO" NAME="gender" VALUE="Pria" checked=true>Ya
<input Type="RADIO" NAME="gender" VALUE="Wanita">tidak<BR/>
<select name="privinsi" onclick="ilang7()">
<option value="0" style="font-size: 12px">Provinsi</option>
<option value="1" style="font-size: 12px" >DKI Jakarta</option>
<option value="2" style="font-size: 12px" >Riau</option>
</select>
<select name="kota">
<option value="0" style="font-size: 12px">Kota/Kabupaten</option>
<option value="0" style="font-size: 12px">Jakarta</option>
<option value="0" style="font-size: 12px">Kepulauan Seribu</option>
</select>
</body>
</html>