Postingan lainnya
Kelas Premium!
Belajar bikin website dari nol sekarang
Gunakan kupon "lebihcepat" untuk diskon 25%!
bagaimana koding menampilkan cetak laporan?
saya sudah membuat koding laporan penjualan. namun ketika dijalankan masih error. dimana ya letak salah nya?
sebelumnya terimakasih.
ini koding laporan_penjualan.php
<?php
include '../../../../helper/connection.php';
?>
<?php
session_start();
if(!$_SESSION['username'] && !$_SESSION['password'] && $_SESSION['tipe_user'] != "Admin")
{
echo "
<script type='text/javascript'>
alert('Anda harus login terlebih dahulu!')
window.location='../../../index.php';
</script>";
}
else
{
?>
<!doctype html>
<html lang="en">
<head>
<!-- Required meta tags -->
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
<!-- Bootstrap CSS -->
<link rel="stylesheet" href="../../../assets/vendor/bootstrap/css/bootstrap.min.css">
<link href="../../../assets/vendor/fonts/circular-std/style.css" rel="stylesheet">
<link rel="stylesheet" href="../../../assets/libs/css/style.css">
<link rel="stylesheet" href="../../../assets/vendor/fonts/fontawesome/css/fontawesome-all.css">
<link rel="stylesheet" href="../../../assets/vendor/charts/chartist-bundle/chartist.css">
<link rel="stylesheet" href="../../../assets/vendor/charts/morris-bundle/morris.css">
<link rel="stylesheet" href="../../../assets/vendor/fonts/material-design-iconic-font/css/materialdesignicons.min.css">
<link rel="stylesheet" href="../../../assets/vendor/charts/c3charts/c3.css">
<link rel="stylesheet" href="../../../assets/vendor/fonts/flag-icon-css/flag-icon.min.css">
<link href='../../../../images/logo.png' rel='SHORTCUT ICON' />
<title>Admin | Toko Naga Mas</title>
</head>
<body>
<!-- ============================================================== -->
<!-- main wrapper -->
<!-- ============================================================== -->
<div class="dashboard-main-wrapper">
<!-- ============================================================== -->
<!-- navbar -->
<!-- ============================================================== -->
<div class="dashboard-header">
<nav class="navbar navbar-expand-lg bg-white fixed-top">
<a class="navbar-brand" href="../../../dashboard.php">Toko Naga Mas</a>
<button class="navbar-toggler" type="button" data-toggle="collapse" data-target="#navbarSupportedContent"
aria-controls="navbarSupportedContent" aria-expanded="false" aria-label="Toggle navigation">
<span class="navbar-toggler-icon"></span>
</button>
<div class="collapse navbar-collapse " id="navbarSupportedContent">
<ul class="navbar-nav ml-auto navbar-right-top">
<li class="nav-item">
</li>
<li class="nav-item dropdown nav-user">
<a class="nav-link nav-user-img" href="#" id="navbarDropdownMenuLink2" data-toggle="dropdown"
aria-haspopup="true" aria-expanded="false"><img src="../../../assets/images/avatar-1.jpg"
alt="" class="user-avatar-md rounded-circle"> Admin <i class="fas fa-angle-down"></i></a>
<div class="dropdown-menu dropdown-menu-right nav-user-dropdown" aria-labelledby="navbarDropdownMenuLink2">
<a class="dropdown-item" href="../../../process/logout.php"><i class="fas fa-power-off mr-2"></i>Logout</a>
</div>
</li>
</ul>
</div>
</nav>
</div>
<!-- ============================================================== -->
<!-- end navbar -->
<!-- ============================================================== -->
<!-- ============================================================== -->
<!-- left sidebar -->
<!-- ============================================================== -->
<div class="nav-left-sidebar sidebar-dark">
<div class="menu-list">
<nav class="navbar navbar-expand-lg navbar-light">
<a class="d-xl-none d-lg-none" href="#">Dashboard</a>
<button class="navbar-toggler" type="button" data-toggle="collapse" data-target="#navbarNav"
aria-controls="navbarNav" aria-expanded="false" aria-label="Toggle navigation">
<span class="navbar-toggler-icon"></span>
</button>
<div class="collapse navbar-collapse" id="navbarNav">
<ul class="navbar-nav flex-column">
<li class="nav-divider">
Menu
</li>
<li class="nav-item ">
<a class="nav-link" href="../../../dashboard.php" aria-expanded="false" data-target="#submenu-1"
aria-controls="submenu-1"><i class="fa fa-fw fa-user-circle"></i>Dashboard
<span class="badge badge-success">6</span></a>
</li>
<li class="nav-item">
<a class="nav-link active" href="#" data-toggle="collapse" aria-expanded="true"
data-target="#submenu-5" aria-controls="submenu-5"><i class="fas fa-fw fa-table"></i>Tables</a>
<div id="submenu-5" class="collapse submenu show" style="">
<ul class="nav flex-column">
<li class="nav-item active">
<a class="nav-link" href="../susu/table_susu.php">Data Susu</a>
</li>
<li class="nav-item">
<a class="nav-link" href="../merek/table_merek.php">Data Merk</a>
</li>
<li class="nav-item">
<a class="nav-link" href="../customer/table_customer.php">Data Customer</a>
</li>
<li class="nav-item">
<a class="nav-link" href="../kategori/table_kategori.php">Data Kategori</a>
</li>
<li class="nav-item">
<a class="nav-link" href="../transaksi/table_transaksi.php">Data Transaksi</a>
</li>
<li class="nav-item">
<a class="nav-link" href="../user/table_user.php">Data User</a>
</li>
<li class="nav-item">
<a class="nav-link" href="../laporan/laporan_penjualan.php">Laporan</a>
</li>
</ul>
</div>
</li>
</ul>
</div>
</nav>
</div>
</div>
<!-- ============================================================== -->
<!-- end left sidebar -->
<!-- ============================================================== -->
<!-- ============================================================== -->
<!-- wrapper -->
<!-- ============================================================== -->
<div class="dashboard-wrapper">
<div class="dashboard-ecommerce">
<div class="container-fluid dashboard-content ">
<!-- ============================================================== -->
<!-- pageheader -->
<!-- ============================================================== -->
<div class="row">
<div class="col-xl-12 col-lg-12 col-md-12 col-sm-12 col-12">
<div class="page-header">
<h2 class="pageheader-title">Laporan</h2>
<div class="page-breadcrumb">
<nav aria-label="breadcrumb">
<ol class="breadcrumb">
<li class="breadcrumb-item"><a href="#" class="breadcrumb-link">Tables</a></li>
<li class="breadcrumb-item active" aria-current="page">Laporan Penjualan</li>
</ol>
</nav>
</div>
</div>
</div>
</div>
<div class="col-xl-12">
<div class="card">
<h5 class="card-header">Laporan Penjualan</h5>
<div class="card-body">
<div class="col-md-12">
<form method="POST" class="form-inline">
<div class="form-group">
<input type="date" id="tgl1" class="form-control" name="tgl1">
</div>
<div class="form-group">
<label> Sampai </label>
<input type="date" id="tgl2" class="form-control" name="tgl2">
</div>
<div class="form-group">
<button id="formbtn" name="prosess" class="btn btn-primary"><i class="fa fa-play-circle-o"></i> Prosess</button>
<button class="btn btn-success" name="semua"><i class="fa fa-play-circle-o"></i> Semua Data</button>
</div>
</form>
</div>
</div>
<hr/>
<div class="row">
<div class="col-md-12">
<div class="panel panel-default">
<div class="panel-heading" align="center">
<?php if (isset($_POST['prosess'])): ?>
<a href="laporan/cetaklaporanpenjualan.php?tgl1=<?php echo $_POST['tgl1']; ?>&tgl2=<?php echo $_POST['tgl2']; ?>" target="_BLANK" class="btn btn-info"><i class="fa fa-print"></i> Cetak</a>
<?php endif ?>
<?php if (isset($_POST['semua'])): ?>
<a href="laporan/cetaklaporanpenjualan.php?semua" target="_BLANK" class="btn btn-info"><i class="fa fa-print"></i> Cetak</a>
<?php endif ?>
<?php if (!isset($_POST['prosess']) && !isset($_POST['semua'])): ?>
<a href="#" class="btn btn-info" disabled="disabled"><i class="fa fa-print"></i> Cetak</a>
<?php endif ?>
</div>
<div class="panel-body">
<table class="table table-bordered table-hover">
<thead>
<tr class="active">
<th>No</th>
<th>Kode Susu</th>
<th>Tgl Transaksi</th>
<th>Nama Susu</th>
<th>Jumlah</th>
<th>Harga</th>
<th>Total</th>
</tr>
</thead>
<tbody>
<?php
if (isset($_POST['prosess'])) {
$total = $laporan->hitung_total_penjualan_bulan($_POST['tgl1'],$_POST['tgl2']);
$cek = $laporan->cek_penjualan_bulan($_POST['tgl1'],$_POST['tgl2']);
if ($cek === false) {
echo "<tr><td colspan='8' align='center'>Data Kosong</td></tr>";
}
else{
$lapbl = $laporan->tampil_penjualan_bulan($_POST['tgl1'],$_POST['tgl2']);
foreach ($lapbl as $index => $data) {
?>
<tr>
<td><?php echo $index + 1; ?></td>
<td><?php echo $data['kd_susu']; ?></td>
<td><?php echo date_format(date_create($data['tgl_transaksi']),'d-m-Y'); ?></td>
<td><?php echo $data['nm_susu']; ?></td>
<td><?php echo $data['jumlah']; ?></td>
<td>Rp. <?php echo number_format($data['harga']); ?></td>
<td>Rp. <?php echo number_format($data['total']); ?></td>
</tr>
<?php
}
?>
<?php
}?>
<tr>
<td colspan="7" align="center">TOTAL</td>
<td>Rp. <?php echo number_format($total); ?></td>
</tr>
<?php
}
elseif (isset($_POST['semua'])) {
$total = $laporan->hitung_total_penjualan();
$cek = $laporan->cek_penjualan();
if ($cek === false) {
echo "<tr><td colspan='8' align='center'>Data Kosong</td></tr>";
}
else{
$lap = $laporan->tampil_penjualan();
foreach ($lap as $index => $data) {
?>
<tr>
<td><?php echo $index + 1; ?></td>
<td><?php echo $data['kd_susu']; ?></td>
<td><?php echo date_format(date_create($data['tgl_transaksi']),'d-m-Y'); ?></td>
<td><?php echo $data['nm_susu']; ?></td>
<td><?php echo $data['jumlah']; ?></td>
<td>Rp. <?php echo number_format($data['harga']); ?></td>
<td>Rp. <?php echo number_format($data['total']); ?></td>
</tr>
<?php
}
?>
<?php
}?>
<tr>
<td colspan="7" align="center">TOTAL</td>
<td>Rp. <?php echo number_format($total); ?></td>
</tr>
<?php
}
else{
?>
<tr>
<td colspan="8" align="center">Pilih Opsi Tampil</td>
</tr>
<tr>
<td colspan="7" align="center">TOTAL</td>
<td></td>
</tr>
<?php
}
?>
</tbody>
</table>
</div>
</div>
</div>
</div>
<!-- ============================================================== -->
<!-- footer -->
<!-- ============================================================== -->
<div class="footer">
<div class="container-fluid">
<div class="row">
<div class="col-xl-6 col-lg-6 col-md-6 col-sm-12 col-12">
Copyright © 2021 Toko Naga Mas All rights reserved.
</div>
<div class="col-xl-6 col-lg-6 col-md-6 col-sm-12 col-12">
</div>
</div>
</div>
</div>
<!-- ============================================================== -->
<!-- end footer -->
<!-- ============================================================== -->
</div>
<!-- ============================================================== -->
<!-- end wrapper -->
<!-- ============================================================== -->
</div>
<!-- ============================================================== -->
<!-- end main wrapper -->
<!-- ============================================================== -->
<!-- Optional JavaScript -->
<!-- jquery 3.3.1 -->
<script src="../../../assets/vendor/jquery/jquery-3.3.1.min.js"></script>
<!-- bootstap bundle js -->
<script src="../../../assets/vendor/bootstrap/js/bootstrap.bundle.js"></script>
<!-- slimscroll js -->
<script src="../../../assets/vendor/slimscroll/jquery.slimscroll.js"></script>
<!-- main js -->
<script src="../../../assets/libs/js/main-js.js"></script>
<!-- chart chartist js -->
<script src="../../../assets/vendor/charts/chartist-bundle/chartist.min.js"></script>
<!-- sparkline js -->
<script src="../../../assets/vendor/charts/sparkline/jquery.sparkline.js"></script>
<!-- morris js -->
<script src="../../../assets/vendor/charts/morris-bundle/raphael.min.js"></script>
<script src="../../../assets/vendor/charts/morris-bundle/morris.js"></script>
<!-- chart c3 js -->
<script src="../../../assets/vendor/charts/c3charts/c3.min.js"></script>
<script src="../../../assets/vendor/charts/c3charts/d3-5.4.0.min.js"></script>
<script src="../../../assets/vendor/charts/c3charts/C3chartjs.js"></script>
<script src="../../../assets/libs/js/dashboard-ecommerce.js"></script>
<script src="https://code.jquery.com/jquery-3.3.1.js"></script>
<script src="https://cdn.datatables.net/1.10.19/js/jquery.dataTables.min.js"></script>
<script src="https://cdn.datatables.net/1.10.19/js/dataTables.bootstrap4.min.js"></script>
<script>
$(document).ready(function () {
$('#tabell').DataTable();
});
</script>
</body>
</html>
<?php } ?>
sementara ini koding cetaklaporanpenjualan.php
<style type="text/css">
*{
font-family: Arial;
font-size: 12px;
margin:0px;
padding:0px;
}
@page {
margin-left:3cm 2cm 2cm 2cm;
}
.container{
margin-top: 10px;
width: 800px;
margin-left: auto;
margin-right: auto;
}
table.grid{
width:20.4cm ;
font-size: 9pt;
border-collapse:collapse;
}
table.grid th{
padding-top:1mm;
padding-bottom:1mm;
}
table.grid th{
background: #F0F0F0;
border: 0.2mm solid #000;
text-align:center;
padding-left:0.2cm;
}
table.grid tr td{
padding-top:0.5mm;
padding-bottom:0.5mm;
padding-left:2mm;
border:0.2mm solid #000;
}
h1{
font-size: 18pt;
}
h2{
font-size: 14pt;
}
h3{
font-size: 10pt;
}
.header{
display: block;
width:20.4cm ;
margin-bottom: 0.3cm;
text-align: center;
margin-top: 10px;
}
.attr{
font-size:9pt;
width: 100%;
padding-top:2pt;
padding-bottom:2pt;
border-top: 0.2mm solid #000;
border-bottom: 0.2mm solid #000;
}
.pagebreak {
width:20cm ;
page-break-after: always;
margin-bottom:10px;
}
.akhir {
width:20cm ;
}
.page {
font-size:13px;
padding-top: 20px;
}
.footer{
padding-top: 20px;
margin-left: 600px;
}
</style>
<?php
include '../laporan/class.php';
if (isset($_GET['tgl1']) && isset($_GET['tgl2'])) {
$dat = $cetaklaporan->laporan_penjualan_bulan($_GET['tgl1'],$_GET['tgl2']);
}else{
$dat = $cetaklaporan->laporan_semua_penjualan();
}
$judul_H = "CETAK BUKTI PENJUALAN <br>";
$tgl = date('d-m-Y');
function myheader($judul_H){
echo "<div class='header'>
<h2>".$judul_H."</h2>
</div>
<table class='grid'>
<tr>
<th width='3%'>No</th>
<th>Kode Susu</th>
<th>Tgl Transaksi</th>
<th>Nama Susu</th>
<th>Jumlah</th>
<th>Harga</th>
<th>Total</th>
</tr>";
}
function myfooter(){
echo "</table>";
}
echo "<div class='container' align='center'>";
$page =1;
$gtotal ="";
foreach ($dat as $index => $data) {
$no = $index + 1;
$total = $data['harga']*$data['jumlah'];
$gtotal = $gtotal + $total;
if(($no % 25) == 1){
if($index + 1 > 1){
myfooter();
echo "<div class='pagebreak'>
<div class='page' align='center'>Hal - $page</div>
</div>";
$page++;
}
myheader($judul_H);
}
echo "<tr>
<td align='center'>$no</td>
<td align='center'>$data[kd_susu]</td>
<td align='left'>".date_format(date_create($data['tgl_transaksi']),'d-m-Y')."</td>
<td align='center'>$data[nm_susu]</td>
<td align='center'>$data[jumlah]</td>
<td align='left'>Rp. ".number_format($data['harga'])."</td>
<td align='left'>Rp. ".number_format($total)."</td>
</tr>";
}
echo "<tr><td colspan='7' align='center'><b>Total</b></td><td><b>Rp. ".number_format($gtotal)."</td></tr>";
myfooter();
echo "<div class='footer'>
<div>$kota, ".date('d-m-Y')."</div>
<div style='margin-top:90px; margin-right:5px;'>$pemilik</div>
</div>";
echo "<div class='page' align='center'>Hal - ".$page."</div>";
echo "</div>";
?>
<script type="text/javascript">
window.print();
</script>
Tanggapan
Errornya seperti apa? Bisa di lampirkan screenshot nya mungkin, Agar mudah dianalisa
2 Jawaban:
<div>Coba kamu perhatikan kembali kecocokan antara nama kolum yang kamu buat . tiap komponen apa yang kamu beri nama pada form , hrus sesuai . jng sampai berbeda . nanti akan munculnya eror </div>
<div>kayak gini gan error nya<br><figure data-trix-attachment="{"contentType":"image/jpeg","filename":"w.jpg","filesize":56971,"height":372,"url":"https://i.ibb.co/DWLZLdP/w.jpg","width":1360}" data-trix-content-type="image/jpeg" data-trix-attributes="{"presentation":"gallery"}" class="attachment attachment--preview attachment--jpg"><img src="https://i.ibb.co/DWLZLdP/w.jpg" width="1360" height="372"><figcaption class="attachment__caption"><span class="attachment__name">w.jpg</span></figcaption></figure></div>