Kaskus

Tech

clonningdashAvatar border
TS
clonningdash
Input Data sekaligus dalam 1 proses
Langsung aja gan ane pengen tanya gimana caranya input sekaligus data dalam 1 proses ?

berikut code nya gan
Code:
<?php
require_once('auth.php');
?>
<html>
<head>
<title>Belajar</title>
<!-- Bootstrap Core CSS -->
<link href="css/bootstrap.min.css" rel="stylesheet">

<!-- Custom CSS -->
<link href="css/business-frontpage.css" rel="stylesheet">
[removed][removed]
[removed][removed]
<link href="src/facebox.css" media="screen" rel="stylesheet" type="text/css" />
[removed][removed]
[removed][removed]
[removed]
jQuery(document).ready(function($) {
$('a[rel*=facebox]').facebox({
loadingImage : 'src/loading.gif',
closeImage : 'src/closelabel.png'
})
})
[removed]

<?php
require_once('auth.php');
?>
<?php
function createRandomPassword() {
$chars = "003232303232023232023456789";
srand((double)microtime()*1000000);
$i = 0;
$pass = '' ;
while ($i <= 7) {

$num = rand() % 33;

$tmp = substr($chars, $num, 1);

$pass = $pass . $tmp;

$i++;

}
return $pass;
}
$finalcode='RS-'.createRandomPassword();
?>
</head>
<body>
<nav class="navbar navbar-inverse navbar-fixed-top" role="navigation">
<div class="container">
<!-- Brand and toggle get grouped for better mobile display -->
<div class="navbar-header">
<button type="button" class="navbar-toggle" data-toggle="collapse" data-target="#bs-example-navbar-collapse-1">
<span class="sr-only">Toggle navigation</span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
</button>
<a class="navbar-brand" href="index.php"></a>
</div>

<!-- Collect the nav links, forms, and other content for toggling -->
<div class="collapse navbar-collapse" id="bs-example-navbar-collapse-1">
<ul class="nav navbar-nav">
<li>
<a href="index.php">Dashboard</a>
</li>
<li class="active">
<a href="sales.php?id=cash&invoice=<?php echo $finalcode ?>">Transaksi Tunai</a>
</li>
<li>
<a href="products.php">Barang</a>
</li>
<li>
<a href="customer.php">Pelanggan</a>
</li>
<li>
<a href="salesreport.php?d1=0&d2=0">Pembukuan</a>
</li>
<li>
<a href="supplier.php">Distributor</a>
</li>
<li>
<a href="purchaseslist.php">Pembelian</a>
</li>
<li>
<a href="mekanik.php">Mekanik</a>
</li>

<li>
<a href="../index.php">
Keluar <i class="entypo-logout right"></i>
</a>
</li>
</ul>
</div>
<!-- /.navbar-collapse -->
</div>
<!-- /.container -->
</nav>
<body>
<div class="container">
<div class="row">
<div class="col-sm-8">
<form method="POST">
<input type="text" name="plat_nomor"/>
<input id="btn" type="submit" tabindex="3" value="Masuk" id="btn" />

</form>
<a class="btn btn-primary" id="addd" href="index.php" style="float: none;margin-top:1%;margin-bottom:1%;">Kembali</a>
<form action="incoming.php" method="post" >
<input type="hidden" name="pt" value="<?php echo $_GET['id']; ?>" />
<input type="hidden" name="invoice" value="<?php echo $_GET['invoice']; ?>" />
<?php
include('../connect.php');
error_reporting(0);
$id = $_POST['plat_nomor'];
$result = $db->prepare("SELECT * FROM customer WHERE plat_nomor='$id'");
$result->bindParam(':userid', $id);
$result->execute();
for($i=0; $row = $result->fetch(); $i++){
?>
<input type="text"class="form-control" name="plat_nomor" value="<?php echo $row['plat_nomor']; ?>">
<?php
}
?>
<select name="product" style="width: 520px;">
<?php
include('../connect.php');
$result = $db->prepare("SELECT * FROM products");
$result->bindParam(':userid', $res);
$result->execute();
for($i=0; $row = $result->fetch(); $i++){
?>
<option value="<?php echo $row['product_code']; ?>"><?php echo $row['product_name']; ?> - Rp. <?php echo number_format ($row['price']); ?></option>
<?php
}
?>
</select>
<br>
<p>Jumlah :</p>
<input type="text" name="qty" value="" placeholder="Jumlah" autocomplete="off"/>
<select name="product" style="width: 520px;">
<?php
include('../connect.php');
$result = $db->prepare("SELECT * FROM products");
$result->bindParam(':userid', $res);
$result->execute();
for($i=0; $row = $result->fetch(); $i++){
?>
<option value="<?php echo $row['product_code']; ?>"><?php echo $row['product_name']; ?> - Rp. <?php echo number_format ($row['price']); ?></option>
<?php
}
?>
</select>
<br>
<p>Jumlah :</p>
<input type="text" name="qty" value="" placeholder="Jumlah" autocomplete="off"/>
<p>Diskon : </p>
<input type="text" name="discount" value="0" autocomplete="off" />
<input type="submit" name="submit" value="Simpan" style="width: 123px;" />
</form>
<table class="table table-bordered datatable" id="table-1">
<thead>
<tr>
<th> Kode Barang </th>
<th> Nama Barang </th>
<th> Unit </th>
<th> Harga </th>
<th> Potongan Harga </th>
<th> Total </th>
<th> Tindakan </th>
</tr>
</thead>
<tbody>

<?php
$id=$_GET['invoice'];
include('../connect.php');
$result = $db->prepare("SELECT * FROM sales_order WHERE invoice= :userid");
$result->bindParam(':userid', $id);
$result->execute();
for($i=0; $row = $result->fetch(); $i++){
?>
<tr class="record">
<td><?php echo $row['product']; ?></td>
<td><?php echo $row['name']; ?></td>
<td><?php echo $row['qty']; ?></td>
<td>
<?php
$ppp=$row['price'];
echo formatMoney($ppp, true);
?>
</td>
<td>
<?php
$ddd=$row['discount'];
echo formatMoney($ddd, true);
?>
</td>
<td>
<?php
$dfdf=$row['amount'];
echo formatMoney($dfdf, true);
?>
</td>
<td><a href="delete.php?id=<?php echo $row['transaction_id']; ?>&invoice=<?php echo $_GET['invoice']; ?>&dle=<?php echo $_GET['id']; ?>&qty=<?php echo $row['qty'];?>&code=<?php echo $row['product'];?>"> Hapus </a></td>
</tr>
<?php
}
?>
<tr>
<td colspan="5"><strong style="font-size: 12px; color: #222222;">Total:</strong></td>
<td colspan="2"><strong style="font-size: 12px; color: #222222;">
<?php
function formatMoney($number, $fractional=false) {
if ($fractional) {
$number = sprintf('%.2f', $number);
}
while (true) {
$replaced = preg_replace('/(-?\d+)(\d\d\d)/', '$1,$2', $number);
if ($replaced != $number) {
$number = $replaced;
} else {
break;
}
}
return $number;
}
$sdsd=$_GET['invoice'];
$resultas = $db->prepare("SELECT sum(amount) FROM sales_order WHERE invoice= :a");
$resultas->bindParam(':a', $sdsd);
$resultas->execute();
for($i=0; $rowas = $resultas->fetch(); $i++){
$fgfg=$rowas['sum(amount)'];
echo formatMoney($fgfg, true);
}
?>
</strong></td>
</tr>

</tbody>
</table><br>
<a class="btn btn-primary" rel="facebox" id="cccc" href="checkout.php?pt=<?php echo $_GET['id']?>&invoice=<?php echo $_GET['invoice']?>&total=<?php echo $fgfg ?>&cashier=<?php echo $_SESSION['SESS_FIRST_NAME']?>">Bayar</a>
<div class="clearfix"></div>
</div>
</div>
</div>
<!-- jQuery -->
[removed][removed]

<!-- Bootstrap Core JavaScript -->
[removed][removed]

</body>
</html>


Code:
<?php
session_start();
include('../connect.php');
$b =$_POST['product'];
$a = $_POST['invoice'];
$c = $_POST['qty'];
$w = $_POST['pt'];
$plat_nomor = $_POST['plat_nomor'];
$nama = $_POST['nama'];
$jenis_motor = $_POST['jenis_motor'];
$discount = $_POST['discount'];
$result = $db->prepare("SELECT * FROM products WHERE product_code= :userid");
$result->bindParam(':userid', $b);
$result->execute();
for($i=0; $row = $result->fetch(); $i++){
$asasa=$row['price'];
$name=$row['product_name'];
$wait = "no";
}

//edit qty
$sql = "UPDATE products
SET qty=qty-?
WHERE product_code=?";
$q = $db->prepare($sql);
$q->execute(array($c,$b));
$fffffff=$asasa-$discount;
$d=$fffffff*$c;
// query
$sql = "INSERT INTO sales_order (invoice,product,qty,amount,name,price,discount,wait,plat_nomor) VALUES (:a,:b,:c,:d,:e,:f,:g,:h,:m)";
$q = $db->prepare($sql);
$q->execute(array(':a'=>$a,':b'=>$b,':c'=>$c,':d'=>$d,':e'=>$name,':f'=>$asasa,':g'=>$discount,':h'=>'yes',':m'=>$plat_nomor));
header("location: sales.php?id=$w&invoice=$a");


?>

itu code nya gan

Maaf berantakan lagi nyoba2 sambil ngotak ngatik kepengen bisa soalnya
0
1.7K
1
GuestAvatar border
Komentar yang asik ya
Mari bergabung, dapatkan informasi dan teman baru!
Website, Webmaster, Webdeveloper
Website, Webmaster, Webdeveloper
KASKUS Official
23.5KThread5.3KAnggota
Urutkan
Terlama
GuestAvatar border
Komentar yang asik ya
Ikuti KASKUS di
© 2025 KASKUS, PT Darta Media Indonesia. All rights reserved.