Postingan lainnya
Error declare tampil range tanggal
Maaf mas...mohon pencerahannya, sy coba membuat laporan cetak dengan range laporan range tanggal, tapi sy coba muncul error ini Fatal error: Cannot redeclare tampil_tgl() (previously declared in C:\xampp\htdocs\up4\fungsi\cetak.php:12) in C:\xampp\htdocs\up4\fungsi\cetak.php on line 17 .
//fungsi
<?php
function tampil_tgl($tgl1, $tgl2) {
$db = $this->mysqli->koneksi;
$sql = "SELECT pengeluaran.kode_brg, unit, nama_brg, jumlah, satuan, tgl_keluar FROM pengeluaran INNER JOIN stokbarang ON pengeluaran.kode_brg = stokbarang.kode_brg WHERE tgl_keluar BETWEEN '$tgl1' AND '$tgl2'";
$query = $db->query($sql) or die ($db->error);
return $query;
}
?>
//perintah button
<div id="cetakpdf" class="modal fade" role="dialog">
<div class="modal-dialog">
<div class="modal-content">
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal">×</button>
</div>
<div class="modal-body">
<form action="cetakmaterial.php" method="post" target="_blank">
<table>
<tr>
<td>
<div class="form-group"> Dari Tanggal</div>
</td>
<td align="center" width="5%">
<div class="form-group">:</div>
</td>
<td>
<div class="form-group">
<input type="date" class="form-control" name="tgl_a" required="">
</div>
</td>
</tr>
<tr>
<td>
<div class="form-group"> Sampai Tanggal</div>
</td>
<td align="center" width="5%">
<div class="form-group">:</div>
</td>
<td>
<div class="form-group">
<input type="date" class="form-control" name="tgl_b" required="">
</div>
</td>
</tr>
</tr>
<tr>
<td></td>
<td></td>
<td>
<input type="submit" name="cetakbarang" class="btn btn-primary btn-sm" value="Cetak">
</td>
</tr>
</table>
</form>
</div>
</div>
</div>
</div>
//CETAKPDF
<?php ob_start();
include "../fungsi/fungsi.php";
include "../fungsi/koneksi.php";
include "../fungsi/cetak.php";
?>
<style type="text/css">
table.page_header {width: 1020px; border: none; background-color: #3C8DBC; color: #fff; border-bottom: solid 1mm #AAAADD; padding: 2mm }
table.page_footer {width: 1020px; border: none; background-color: #3C8DBC; border-top: solid 1mm #AAAADD; padding: 2mm}
h1 {color: #000033}
h2 {color: #000055}
h3 {color: #000077}
</style>
<style type="text/css">
.tabel2 {
border-collapse: collapse;
margin-left: 20px;
}
.tabel2 th, .tabel2 td {
padding: 5px 5px;
border: 1px solid #959595;
}
div.kanan {
width:300px;
float:right;
margin-left:250px;
margin-top:-140px;
}
div.kiri {
width:300px;
float:left;
margin-left:20px;
display:inline;
}
</style>
<table>
<tr>
<th rowspan="3"><img src="../gambar/logopemkot.png" style="width:100px;height:140px" /></th>
<td align="center" style="width: 520px;"><font style="font-size: 18px"><b>PEMERINTAH KOTA JAWA TIMUR <br> CV. ABADI JAYA</b></font>
<br><br>Jl. DIPONEGORO <br> Telp : (XXX) xxxxxx | Fax : (XXX) xxxxxx</td>
<th rowspan="3"><img src="../gambar/logousb.png" style="width:100px;height:140px" /></th>
</tr>
</table>
<hr>
<p align="center" style="font-weight: bold; font-size: 18px;"><u>LAPORAN PENGELUARAN BARANG</u></p>
<table class="tabel2">
<thead>
<tr>
<td style="text-align: center; "><b>No.</b></td>
<td style="text-align: center; "><b>Tanggal Keluar</b></td>
<td style="text-align: center; "><b>Unit Pelayanan</b></td>
<td style="text-align: center; "><b>Kode Barang</b></td>
<td style="text-align: center; "><b>Nama Barang</b></td>
<td style="text-align: center; "><b>Satuan</b></td>
<td style="text-align: center; "><b>Jumlah</b></td>
</tr>
</thead>
<tbody>
<?php
include "../fungsi/koneksi.php";
include "../fungsi/cetak.php";
$i = 1;
if(@$_POST['cetakbarang']) {
$tampil = $kode_brg->tampil_tgl(@$_POST['tgl_a'], @$_POST['tgl_b']);
}
while($data=mysqli_fetch_array($query))
{
?>
<tr>
<td style="text-align: center; width=15px;"><?php echo $i; ?></td>
<td style="text-align: center; width=70px;"><?php echo tanggal_indo($data['tgl_keluar']); ?></td>
<td style="text-align: center; width=70px;"><?php echo $data['unit']; ?></td>
<td style="text-align: center; width=120px;"><?php echo $data['kode_brg']; ?></td>
<td style="text-align: center; width=120px;"><?php echo $data['nama_brg']; ?></td>
<td style="text-align: center; width=70px;"><?php echo $data['satuan']; ?></td>
<td style="text-align: center; width=50px;"><?php echo $data['jumlah']; ?></td>
</tr>
<?php
$i++;
}
?>
</tbody>
</table>
<?php
$content = ob_get_clean();
include '../assets/html2pdf/html2pdf.class.php';
try
{
$html2pdf = new HTML2PDF('P', 'A4', 'en', false, 'UTF-8', array(10, 10, 4, 10));
$html2pdf->pdf->SetDisplayMode('fullpage');
$html2pdf->writeHTML($content);
$html2pdf->Output('laporan_pengeluaran_barang.pdf');
}
catch(HTML2PDF_exception $e) {
echo $e;
exit;
}
?>
0
2 Jawaban:
Itu artinya kamu sudah deklarasikan fungsi cetak, jd gk perlu di deklarasikan lagi. Hapus dibagian ini <pre> include "../fungsi/koneksi.php"; include "../fungsi/cetak.php"; </pre>
1
Jawaban Terpilih
kalo mau aman pake <pre> include_once('namafile.php'); </pre>
1