<style type="text/css" media="all">
/*
* Splitter container. Set this to the desired width and height
* of the combined left and right panes.
*/
#MySplitter {
height: 300px;
width: 600px;
border: 4px solid #cca;
/* No padding allowed */
}
/*
* Top element of the splitter. Use pixel units for the
* min-height and max-height; the splitter plugin parses them to
* determine the splitter movement limits. Set the height to
* the desired initial height of the element; the plugin changes
* the height of this element dynamically.
*/
#TopPane {
background: #6C91C0;
overflow: auto;
/* Initial/min/max height for this pane */
height: 20px;
min-height: 10px;
max-height: 150px;
/* No margin or border allowed */
}
#MidPane {
background: #CDCDCD;
overflow: auto;
/* Initial/min/max height for this pane */
height: 120px;
min-height: 10px;
max-height: 150px;
/* No margin or border allowed */
}
/*
* Bottom element of the splitter; the plugin changes the top
* position and height of this element dynamically.
*/
#BottomPane {
background: #ffd;
overflow: auto;
height: 400px;
min-height: 10px;
max-height: 400px;
/* No margin or border allowed */
}
#FooterPane {
background: #6C91C0;
overflow: auto;
/* Initial/min/max height for this pane */
height: 300px;
min-height: 10px;
max-height: 150px;
/* No margin or border allowed */
}
/*
* Splitter bar style; the .active class is added when the
* mouse is over the splitter or the splitter is focused
* via the keyboard taborder or an accessKey.
*/
#MySplitter .hsplitbar {
height: 6px;
background: #cca url(hgrabber.gif) no-repeat center;
/* No margin, border, or padding allowed */
}
#MySplitter .hsplitbar.active, #MySplitter .hsplitbar:hover {
background: #e88 url(hgrabber.gif) no-repeat center;
}
</style>
<script type="text/javascript">
$().ready(function() {
$("#MySplitter").splitter({
type: "h",
sizeTop: true, /* use height set in stylesheet */
accessKey: "P"
});
});
</script>
<?php
include 'lib/koneksi.php';
$mysql = mysql_connect($dbconf['host'],$dbconf['dbuser'],$dbconf['dbpass']);
$link = mysql_select_db($dbconf['dbname'],$mysql);
$dbnya =$dbconf['dbname'];
$koneksi = new mysqli($dbconf['host'],$dbconf['dbuser'],$dbconf['dbpass'],$dbconf['dbname']);
$namatabeltemp = 'temppembelian';
?>
<h1>Transaksi Pembelian</h1>
<div id="TopPane">
</div>
<div id="MidPane">
[b]<?php[/b]
[b]if ($_POST['kode']) {[/b]
[b] $kode = $_POST['kode'];[/b]
[b] $sqlsearch = "SELECT tbarang.id_barang, tbarang.nama_barang, tstock.harga_beli FROM tbarang, tstock WHERE tbarang.kode_barang=".$kode." AND tstock.id_barang=tbarang.id_barang";[/b]
[b] $query = $koneksi->query($sqlsearch);[/b]
[b] if ($query) {[/b]
[b] $data=$query->fetch_array(MYSQL_ASSOC);[/b]
[b] $nama=$data['nama_barang'];[/b]
[b] $harga=$data['harga_beli'];[/b]
[b] $id=$data['id_barang'];[/b]
[b] $stat='';[/b]
[b] }[/b]
[b]} else {[/b]
[b] $nama='';[/b]
[b] $harga='';[/b]
[b] $kode='';[/b]
[b] $stat='disabled';[/b]
[b]}[/b]
[b]?>[/b]
[b]<table style="margin:10px 10px;">[/b]
[b] <tr>[/b]
[b] <td width="300px">[/b]
[b] <form method="POST" action="<?php $_SERVER['PHP_SELF'].'?hal=pembelian'?>" >[/b]
[b] <label>Kode</label><input type="text" name="kode" value="<?php echo $kode; ?>"><br>[/b]
[b] <label>Nama</label><input type="text" name="nama" value="<?php echo $nama; ?>" disabled ><br>[/b]
[b] <label>Harga Beli</label><input type="text" name="harga" value="<?php echo $harga; ?>" disabled ><br>[/b]
[b] </form>[/b]
</td>
<td valign="top" width="100px">
<a href="./page/transaksi/pembelian/ref.php?width=500&height=500" class="thickbox">Referensi</a>
</td>
<td>
<form method="POST" action="<?php $_SERVER['PHP_SELF'].'?hal=pembelian'?>" >
<label>Diskon</label><input type="text" name="diskon" value="0"><br>
<label>QTY</label><input type="text" name="qty" value="0"><br>
<input type="hidden" name="id" value="<?php echo $id; ?>">
<input type="hidden" name="codes" value="<?php echo $kode; ?>">
<input type="hidden" name="harganya" value="<?php echo $harga; ?>">
<input type="submit" name="insert" value="insert" <?php echo $stat; ?>>
</form>
</td>
</tr>
</table>
</div>
<div id="BottomPane">
<p>
<div style="margin:10px">
<?php
$kode = $_POST['codes'];
$nama = $_POST['id'];
$diskon = $_POST['diskon'];
$qty = $_POST['qty'];
$harganya = $_POST['harganya'];
if ($diskon=='0' OR $diskon==null ) {
$jumlah = $harganya * $qty;
}else{
$jumlah = ($harganya * $qty )-$diskon;
}
function cektabel($tablename) {
GLOBAL $dbnya;
$result = mysql_list_tables($dbnya);
$num_rows = mysql_num_rows($result);
for ($i = 0; $i < $num_rows; $i++) {
if(mysql_tablename($result, $i) == $tablename) {
return true;
break;
}
}
return false;
}
if(cektabel($namatabeltemp)){
$allowsave ='';
} else {
$allowsave ='disabled';
}
if ($_POST['insert']) {
if ($qty == '0' OR $qty == null) {
?>
<script language="javascript">
alert("Nilai QTY Tidak sesuai");
</script>
<script language="javascript" src="./lib/js/jquery.js"></script>
<script language="javascript" src="./lib/js/thickbox.js"></script>
<link href="./themes/thickbox.css" rel="stylesheet" type="text/css" />
<?php
}else{
$sqlinsert = "insert into ".$namatabeltemp." (nama_barang,diskon,qty,jumlah) VALUES ('".$nama."','".$diskon."','".$qty."','".$jumlah."')";
if (cektabel($namatabeltemp)) {
$queryinsert = mysql_query($sqlinsert);
}else{
$sqltmp = "CREATE TABLE ".$namatabeltemp."
(
id_temp INT(15) UNSIGNED NOT NULL auto_increment,
nama_barang VARCHAR(100) NOT NULL,
diskon INT(10) NOT NULL,
qty INT(10) NOT NULL,
jumlah INT(250) NOT NULL,
PRIMARY KEY(id_temp)
)";
$querytemp = mysql_query($sqltmp);
if ($querytemp) {
$queryinsert = mysql_query($sqlinsert);
$allowsave ='';
}
}
}
} else {
?>
<script language="javascript" src="./lib/js/jquery.js"></script>
<script language="javascript" src="./lib/js/thickbox.js"></script>
<link href="./themes/thickbox.css" rel="stylesheet" type="text/css" />
<?php
}
//VIEW DATA
$sqlview = "SELECT ".$namatabeltemp.".id_temp, tbarang.kode_barang, tbarang.nama_barang,tstock.harga_beli, ".$namatabeltemp.".diskon,
".$namatabeltemp.".qty,".$namatabeltemp.".jumlah FROM ".$namatabeltemp.",tbarang,tstock WHERE tbarang.id_barang=".$namatabeltemp.".nama_barang AND tstock.id_barang=".$namatabeltemp.".nama_barang";
$link = new mysqli($dbconf['host'],$dbconf['dbuser'],$dbconf['dbpass'],$dbconf['dbname']);
$self = $_SERVER['PHP_SELF'].'?hal=pendapatanlain';
$delete = '//page/transaksi/pembelian/deltemp.php';
$update = array('url'=>'page/transaksi/pembelian/updatetemp.php','lebar'=>'500','tinggi'=>'520');
$pg = new paginasi($link,$sqlview,$self,300,3);
$paging = $pg->paging();
$list = new generatorTable($paging,$update,$delete);
$list->showTable();
$pg->showPaging();
if(cektabel($namatabeltemp)){
$sqljumlah = "SELECT SUM(jumlah) as 'jumlahnya', SUM(diskon) as 'diskonnya' FROM ".$namatabeltemp." ";
$qjumlah = $koneksi->query($sqljumlah)->fetch_array(MYSQL_ASSOC);
echo 'Jumlah Diskon :<b>'.$qjumlah['diskonnya'].'</b>, Jumlah Nilai Pembelian:<b>'.$qjumlah['jumlahnya'].'</b>';
}
?>
</div>
</p>
</div>
<div id="FooterPane">
<!-- CRAZY -->
<div>
<form method="POST" action="./page/transaksi/pembelian/action.php">
<table cellspacing="10px">
<tr>
<td width="290px"><b><label>Nomor Bukti</label></b>
<input type="text" name="no_bukti"><br>
</td>
<td><b>Tanggal</b>
<select name="tgl">
<option selected value="<?php echo date(d) ?>"><?php echo date(d) ?></option>
<?php for($i=1;$i<=31;$i++) {
echo "<option value='".$i."'>".$i."</option>";
}
?>
</select>
<b>Bulan</b>
<select name="bulan">
<option selected value="<?php echo date('m') ?>"><?php echo date('m') ?></option>
<?php for($b=1;$b<=12;$b++) {
echo "<option value='".$b."'>".$b."</option>";
}
?>
</select>
<b>Tahun</b>
<select name="tahun">
<option selected value="<?php echo date('Y') ?>"><?php echo date('Y') ?></option>
<?php for($t=2000;$t<=2030;$t++) {
echo "<option value='".$t."'>".$t."</option>";
}
?>
</select>
</td>
</tr>
<tr>
<td>
<b><label>Nama Supplier</label></b>
<select name="supplier">
<option selected value="">-SEMUA-</option>
<?php
$sql1 = "SELECT * FROM tsupplier";
$query1 = $koneksi->query($sql1);
while ($row = $query1->fetch_array(MYSQL_ASSOC)) {
echo '<option value="'.$row['id_supplier'].'">'.$row['nama_supplier'].'</option>';
}
?>
</select>
</td>
<td>
<b><label>Nomor Nota</label></b>
<input type="text" name="no_nota"><br>
</td>
</tr>
</table>
<div style="margin-left:10px;">
<input type="submit" name="simpan" value="simpan" <?php echo $allowsave; ?>>
<input type=hidden name="tabel" value="<?php echo $namatabeltemp ?>">
<input type=hidden name="id" value="<?php echo $nama ?>">
<input type=hidden name="diskonnya" value="<?php echo $qjumlah['diskonnya'] ?>">
<input type=submit name="reset" value="Reset" <?php echo $allowsave; ?>>
</div>
</form>
</div>
<!-- CRAZY -->
<div class="footermenu">
<ul>
<li><a href="#"style=" border: 1px solid #666666; background-color:#000 ">PDF</a></li>
<li><a href="index.php"style=" border: 1px solid #666666; background-color:#000 ">Tutup</a></li>
</ul>
</div>
</div>
saya mau tanya bagaimana cara agar ketika saya mengimputkan kode, maka pada textbox berikutnya akan tampil
hasil berdasarkan kode yang diinputkan. berikut penggalan kodenya
<?php
if ($_POST['kode']) {
$kode = $_POST['kode'];
$sqlsearch = "SELECT tbarang.id_barang, tbarang.nama_barang, tstock.harga_beli FROM tbarang, tstock WHERE tbarang.kode_barang=".$kode." AND tstock.id_barang=tbarang.id_barang";
$query = $koneksi->query($sqlsearch);
if ($query) {
$data=$query->fetch_array(MYSQL_ASSOC);
$nama=$data['nama_barang'];
$harga=$data['harga_beli'];
$id=$data['id_barang'];
$stat='';
}
} else {
$nama='';
$harga='';
$kode='';
$stat='disabled';
}
?>
<table style="margin:10px 10px;">
<tr>
<td width="300px">
<form method="POST" action="<?php $_SERVER['PHP_SELF'].'?hal=pembelian'?>" >
<label>Kode</label><input type="text" name="kode" value="<?php echo $kode; ?>"><br>
<label>Nama</label><input type="text" name="nama" value="<?php echo $nama; ?>" disabled ><br>
<label>Harga Beli</label><input type="text" name="harga" value="<?php echo $harga; ?>" disabled ><br>
</form>
</td>
<td valign="top" width="100px">
<a href="./page/transaksi/pembelian/ref.php?width=500&height=500" class="thickbox">Referensi</a>
</td>
<td>
<form method="POST" action="<?php $_SERVER['PHP_SELF'].'?hal=pembelian'?>" >
<label>Diskon</label><input type="text" name="diskon" value="0"><br>
<label>QTY</label><input type="text" name="qty" value="0"><br>
<input type="hidden" name="id" value="<?php echo $id; ?>">
<input type="hidden" name="codes" value="<?php echo $kode; ?>">
<input type="hidden" name="harganya" value="<?php echo $harga; ?>">
<input type="submit" name="insert" value="insert" <?php echo $stat; ?>>
</form>
</td>
</tr>
</table>