-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcetak.php
126 lines (109 loc) · 4.1 KB
/
cetak.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
<?php
include "./koneksi.php";
session_start();
if( empty( $_SESSION['iduser'] ) ){
$_SESSION['err'] = '<strong>ERROR!</strong> Anda harus login terlebih dahulu.';
header('Location: ./');
die();
} else {
$nis = $_REQUEST['nis'];
if(isset($_REQUEST['submit'])){
//cetak nota pembayaran sesuai NIS dan BULAN
$submit = $_REQUEST['submit'];
$kls = $_REQUEST['kls'];
$bln = $_REQUEST['bln'];
//print: $nis, $nama, $kls, $bln, $tgl_bayar, $jml
$sql = mysqli_query($konek, "SELECT s.nama,p.tgl_bayar,p.jumlah FROM santri s INNER JOIN pembayaran p ON s.nis = p.nis AND p.nis='$nis'");
list($nama,$tgl_bayar,$jml) = mysqli_fetch_array($sql);
$printTestText = "NIS : ".$nis."\n";
$printTestText .= "NAMA : ".$nama."\n";
$printTestText .= "KELAS : ".$kls."\n\n";
$printTestText .= "========================================\n";
$printTestText .= str_pad($tgl_bayar,20);
$printTestText .= str_pad($bln,3);
$printTestText .= str_pad($jml,10," ",STR_PAD_LEFT)."\n";
$printTestText .= "========================================\n";
$printTestText .= "\n";
$printTestText .= "\n";
$printTestText .= str_pad("--= TERIMA KASIH =--",40," ",STR_PAD_BOTH)."\n";
$printTestText .= "\n";
$handle = printer_open('PDFcreator'); //nama printer
printer_set_option($handle, PRINTER_MODE, "TEXT"); //mode printer: RAW, TEXT
printer_write($handle, $printTestText);
printer_close($handle);
echo '<script>window.close();</script>';
} else {
//cetak seluruh pembayaran sesuai NIS
?>
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1">
<meta name="description" content="">
<meta name="author" content="">
<title>phpBayar</title>
<!-- Bootstrap core CSS -->
<link href="css/bootstrap.min.css" rel="stylesheet">
<style type="text/css">
body {
min-height: 200px;
padding-top: 50px;
}
@media print {
.noprint {
display: none;
}
}
</style>
</head>
<body>
<div class="container">
<?php
echo '<h3>Bukti Pembayaran SPP</h3>';
$qsantri = mysqli_query($konek, "SELECT * FROM santri WHERE nis='$nis'");
list($nis,$nama,$idbalai) = mysqli_fetch_array($qsantri);
echo '<div class="row">';
echo '<div class="col-sm-6"><table class="table table-bordered">';
echo '<tr><td colspan="2">Nomor Induk</td><td colspan="3">'.$nis.'</td></tr>';
echo '<tr><td colspan="2">Nama Santri</td><td colspan="3">'.$nama.'</td></tr>';
echo '<tr class="info"><th width="50">#</th><th width="100">Kelas</th><th>Bulan</th><th>Tanggal Bayar</th><th>Jumlah</th>';
echo '</tr>';
//tampilkan histori pembayaran, jika ada
$qbayar = mysqli_query($konek, "SELECT kelas,bulan,tgl_bayar,jumlah FROM pembayaran WHERE nis='$nis' ORDER BY tgl_bayar DESC");
if(mysqli_num_rows($qbayar) > 0){
$no = 1;
while(list($kelas,$bulan,$tgl,$jumlah) = mysqli_fetch_array($qbayar)){
echo '<tr><td>'.$no.'</td>';
echo '<td>'.$kelas.'</td>';
echo '<td>'.$bulan.'</td>';
echo '<td>'.$tgl.'</td>';
echo '<td>'.$jumlah.'</td>';
echo '</tr>';
$no++;
}
} else {
echo '<tr><td colspan="6"><em>Belum ada data!</em></td></tr>';
}
echo '</table></div></div>';
?>
<a class="noprint btn btn-default" onclick="fnCetak()">Cetak</a>
</div> <!-- /container -->
<!-- Bootstrap core JavaScript, Placed at the end of the document so the pages load faster -->
<script src="js/jquery.min.js"></script>
<script src="js/bootstrap.min.js"></script>
<script type="text/javascript">
$(".force-logout").alert().delay(3000).slideUp('slow', function(){
window.location = "./logout.php";
});
function fnCetak() {
window.print();
}
</script>
</body>
</html>
<?php
}
}
?>