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>

Membuat Laporan Periode dengan PHP MYSQL

Select * from siswa where tgl_lulus between 'tgl1' and  'tgl2';


Langkah - langkah Membuat Laporan Periode dengan PHP MYSQL :

1. Buat database dan table


2. Buat Koneksi database ke php dengan nama file :  Koneksi.php


3.  Buat Laporan Pencarian / Periode Tanggal



4. Selamat Belajar, Semoga Bermanfaat



Membuat Aplikasi Tabungan Siswa menggunakan PHP MYSQL












Langkah Membuat Aplikasi Tabungan Siswa menggunakan PHP MYSQL :

1. Buatlah Database dengan nama Kas_siswa

2. Buat Tablenya : siswa, setoran,penarikan


3.  Buatlah Trigger Setoran dan Penarikan



Fungsi Trigger diatas adalah untuk update Stock di table SISWA pada saat terjadi Setoran dan penarikan tabungan

4. Listing Program

koneksi.php

<?php
$host='localhost';
$user='root';
$pass='';
$db='kas_siswa';
mysql_connect($host,$user,$pass) or die ("Tidak dapat terkoneksi " . mysql_error());
mysql_select_db($db) or die ("Database tidak ditemukan " . mysql_error());
?>

input_setoran.php

<!DOCTYPE html>
<html>
<head>
<title>Setoran</title>
</head>
<body>
<center>
<br>
<form action="simpan_setoran.php" method="POST">
<table width="400" border="0" align="center" cellpadding="1"
                cellspacing="1" bordercolor="#00FF00" bgcolor="#33CC00">
<tr bgcolor="#CCFFCC">
<td height="50" colspan="3"><div align="center">INPUT DATA SETORAN </div></td>
</tr>
<tr bgcolor="#FFFFFF">
<td height="40">Id_setor</td>
<td>:<input type="text" name="id_setor" readonly></td>
</tr>
<tr bgcolor="#FFFFFF">
<td height="40">Tanggal_setor</td>
<td>:<input type="date" name="tgl_setor" value="<?php echo date('Y-m-d'); ?>"></td>
</tr>
<tr bgcolor="#FFFFFF">
<td height="40">nis</td>
<td>:
<select name="nis">
<option>--Pilih NIS--</option>
<?php
include 'koneksi.php';
$query=mysql_query("SELECT * FROM siswa");
while ($datsiswa=mysql_fetch_array($query)) {
echo '<option value="'.$datsiswa['nis'].'">'.$datsiswa['nis'].'  '.$datsiswa['nama'].'</option>';
}
?>
</select>
</td>
</tr>

<tr bgcolor="#FFFFFF">
<td height="40">Jumlah setor</td>
<td>: <input type="text" name="jml_setor"></td>
</tr>
<tr bgcolor="#FFFFFF">
<td height="50" colspan="3"><div align="center">
<input type="submit" name="Submit" value="Simpan Data"></div>
</td>
</tr>
</table>
</form>
</div>
</center>
</body>
</html>

simpan_setoran.php

<?php
include ("koneksi.php");
        $id_setor=$_POST['id_setor'];
        $tgl_setor=$_POST['tgl_setor'];
$nis=$_POST['nis'];
$jml_setor=$_POST['jml_setor'];

$simpan="insert into setoran values('$id_setor','$tgl_setor','$nis',$jml_setor)"; 
mysql_query($simpan);
echo "data berhasil disimpan ";
echo "<a href=tampil_setor.php>back</a>";
?>


input _penarikan.php

<!DOCTYPE html>
<html>
<head>
<title>Penarikan</title>
</head>
<body>
<center>
<br>
<form action="simpan_penarikan.php" method="POST">
<table width="400" border="0" align="center" cellpadding="1"
                cellspacing="1" bordercolor="#00FF00" bgcolor="#33CC00">
<tr bgcolor="#CCFFCC">
<td height="50" colspan="3"><div align="center">INPUT DATA PENARIKAN </div></td>
</tr>
<tr bgcolor="#FFFFFF">
<td height="40">Id Tarik</td>
<td>:<input type="text" name="id_tarik" readonly></td>
</tr>
<tr bgcolor="#FFFFFF">
<td height="40">Tanggal Penarikan</td>
<td>:<input type="date" name="tgl_tarik" value="<?php echo date('Y-m-d'); ?>"></td>
</tr>
<tr bgcolor="#FFFFFF">
<td height="40">nis</td>
<td>:
<select name="nis">
<option>--Pilih NIS--</option>
<?php
include 'koneksi.php';
$query=mysql_query("SELECT * FROM siswa");
while ($datsiswa=mysql_fetch_array($query)) {
echo '<option value="'.$datsiswa['nis'].'">'.$datsiswa['nis'].'  '.$datsiswa['nama'].'</option>';
}
?>
</select>
</td>
</tr>

<tr bgcolor="#FFFFFF">
<td height="40">Jumlah Tarik</td>
<td>: <input type="text" name="jml_tarik"></td>
</tr>
<tr bgcolor="#FFFFFF">
<td height="50" colspan="3"><div align="center">
<input type="submit" name="Submit" value="Simpan Data"></div>
</td>
</tr>
</table>
</form>
</div>
</center>
</body>
</html>

simpan_penarikan.php

<?php
include ("koneksi.php");
        $id_tarik=$_POST['id_tarik'];
        $tgl_tarik=$_POST['tgl_tarik'];
$nis=$_POST['nis'];
$jml_tarik=$_POST['jml_tarik'];

$simpan="insert into penarikan values('$id_tarik','$tgl_tarik','$nis',$jml_tarik)"; 
mysql_query($simpan);
echo "data berhasil disimpan ";
echo "<a href=tampil_setor.php>back</a>";
?>


index.php

<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8" />
<title>Menu Utama</title>
<link href="style.css" rel="stylesheet" />
</head>
<body>

<nav>
<ul>
<li><a href="#">Beranda</a></li>
<li><a href="#">Nasabah</a>
<ul>
<li><a href="input_siswa.php">Input Data</a></li>
<li><a href="laporan_saldo.php">Laporan</a></li>
</ul>
</li>
<li><a href="#">Transaksi</a>
<ul>
<li><a href="input_setoran.php">Setoran</a></li>
<li><a href="input_penarikan.php">Penarikan</a></li>
<li><a href="#">Laporan</a>
<ul>
<li><a href="lap_setoran.php">Lap.Setor</a></li>
<li><a href="lap_penarikan.php">Lap.penarikan</a></li>
</ul>
</li>
</ul>
</li>

<li><a href="#">Tentang</a>
    <ul>
<li><a href="#">Kontak</a></li>
<li><a href="#">Blog</a></li>
</ul>
</li>
</ul>
</nav>
</body>
</html>

style.php

body, div, h1, h2, h3, h4, h5, h6, p, ul, ol, li, dl, dt, dd, img, form, fieldset, input, textarea, blockquote {
margin: 0; padding: 0; border: 0;
}

body {
background: #fff;
font-family: Helvetica, sans-serif; font-size: 18px; line-height: 24px;
}

nav {
margin: 100px auto;
text-align: center;
}

nav ul ul {
display: none;
}

nav ul li:hover > ul {
display: block;
}


nav ul {
background: #53bd84;
padding: 0 20px;
border-radius: 10px; 
list-style: none;
position: relative;
display: inline-table;
}
nav ul:after {
content: ""; clear: both; display: block;
}

nav ul li {
float: left;
}
nav ul li:hover {
background: #666;
}
nav ul li:hover a {
color: #fff;
}

nav ul li a {
display: block; padding: 25px 40px;
color: #fff; text-decoration: none;
}


nav ul ul {
background: #53bd84; border-radius: 0px; padding: 0;
position: absolute; top: 100%;
}
nav ul ul li {
float: none;
border-top: 1px solid #53bd84;
border-bottom: 1px solid #53bd84; position: relative;
}
nav ul ul li a {
padding: 15px 40px;
color: #fff;
}
nav ul ul li a:hover {
background: #666;
}

nav ul ul ul {
position: absolute; left: 100%; top:0;
}