Membuat Laporan Penjualan per periode Tanggal
<!DOCTYPE html>
<html>
<head>
<title>Penjualan Barang</title>
<script>
$( function() {
$( "#datepicker" ).datepicker({ dateFormat: 'yy-mm-dd' });
$( "#datepicker2" ).datepicker({ dateFormat: 'yy-mm-dd' });
} );
</script>
<link rel="stylesheet" type="text/css" href="style.css">
</head>
<body>
<center>
<h1>Data Penjualan</h1>
<form action="tambah_jual.php" method="POST"><input type="submit" name="submit" value="Tambah Data Penjualan">
</form>
<br>
<?php
include "koneksi.php";
$sql = mysql_query("SELECT * FROM penjualan");
$z="0";
if (isset($_POST['cari'])) {
$tgl1=$_POST['tgl1'];
$tgl2=$_POST['tgl2'];
$cari = mysql_query("SELECT * FROM penjualan INNER JOIN barang ON penjualan.id_brg=barang.id_brg WHERE tgl_jual BETWEEN '$tgl1' AND '$tgl2'");
$z="1";
if (mysql_num_rows($cari)<1) {
$cari = mysql_query("SELECT * FROM penjualan INNER JOIN barang ON penjualan.id_brg=barang.id_brg");
}
}
?>
<form action="" method="post">
<b>Laporan Penjualan per Periode(Tanggal) </b><br />
<p>Dari Tanggal: <input type="text" id="datepicker" name="tgl1">
Sampai Tanggal: <input type="text" id="datepicker2" name="tgl2">
<input type="submit" value="cari" name="cari"></p>
</form>
<table border="1" width="100%" cellpadding="10" cellspacing="0">
<tr bgcolor="#CCFFCC">
<th width="5%">No</th>
<th>ID PENJUALAN</th>
<th>TGL JUAL</th>
<th>ID BARANG</th>
<th>NAMA BARANG</th>
<th>JUMLAH JUAL(Q)</th>
<th>HARGA JUAL</th>
<th>SUB TOTAL(Rp.)</th>
<th>AKSI</th>
</tr>
<?php
if ($z=="1") {
?>
<?php
include 'koneksi.php';
$no=1;
$totjual=0;
$query=mysql_query("SELECT * FROM penjualan INNER JOIN barang ON penjualan.id_brg=barang.id_brg");
if($query=== FALSE) {
die(mysql_error());
}
while ($data=mysql_fetch_array($cari)) {
?>
<tr>
<td><?php echo $no; ?></td>
<td><?php echo $data['id_jual']; ?> </td>
<td><?php echo $data['tgl_jual'];?></td>
<td><?php echo $data['id_brg']; ?></td>
<td><?php echo $data['nm_brg']; ?></td>
<td><?php echo $data['jml_jual']; ?></td>
<td><?php echo $data['hrg_jual']; ?></td>
<?php
$jml_jual = $data['jml_jual'];
$hrg_jual = $data['hrg_jual'];
$sbjual= $jml_jual*$hrg_jual;?>
<td><?php echo $sbjual; ?></td>
<?php $totjual = $totjual+$sbjual; ?>
<td style="text-align: center;">
<a href="?page=edit_jual&id_jual=<?php echo $data['id_jual']; ?>">Edit </a></div> |
<a href="hapus_jual.php?id_jual=<?php echo $data['id_jual']; ?>" onclick="return confirm('Yakin Akan Dihapus??')">Hapus</a>
</td>
</tr>
<?php $no++; } ?>
<?php } else { ?>
<?php
include 'koneksi.php';
$no=1;
$totjual=0;
$query=mysql_query("SELECT * FROM penjualan INNER JOIN barang ON penjualan.id_brg=barang.id_brg");
if($query=== FALSE) {
die(mysql_error());
}
while ($data=mysql_fetch_array($query)) {
?>
<tr>
<td><?php echo $no; ?></td>
<td><?php echo $data['id_jual']; ?> </td>
<td><?php echo $data['tgl_jual'];?></td>
<td><?php echo $data['id_brg']; ?></td>
<td><?php echo $data['nm_brg']; ?></td>
<td><?php echo $data['jml_jual']; ?></td>
<td><?php echo $data['hrg_jual']; ?></td>
<?php
$jml_jual = $data['jml_jual'];
$hrg_jual = $data['hrg_jual'];
$sbjual= $jml_jual*$hrg_jual;?>
<td><?php echo $sbjual; ?></td>
<?php $totjual = $totjual+$sbjual; ?>
<td style="text-align: center;">
<a href="?page=edit_jual&id_jual=<?php echo $data['id_jual']; ?>">Edit </a></div> |
<a href="hapus_jual.php?id_jual=<?php echo $data['id_jual']; ?>" onclick="return confirm('Yakin Akan Dihapus??')">Hapus</a>
</td>
</tr>
<?php
$no++; }
}
?>
</table>
<?php echo "<p align=right>Total Penjualan Adalah Rp. ","<b>",$totjual,"</b></p>"; ?>
</center>
</div>
</body>
</html>
Langganan:
Posting Komentar (Atom)
Tidak ada komentar:
Posting Komentar