BAB IV IMPLEMENTASI SISTEM
C. Implementasi Proses
7. Proses Lihat Laporan
a) Proses Lihat Laporan Stok Barang
Proses ini digunakan untuk melihat laporan stok barang yang
tercatat di sistem. Pemanggilan program jika hanya untuk melihat
laporan menggunakan printit(FALSE). Tetapi untuk pemanggilan
program untuk mencetak laporan menggunakan printit(TRUE).
Berikut kode programnya.
PUBLIC SUB header(prn AS Boolean) PRINT #hFile, "<html>"
PRINT #hFile, " <tr><td colspan='8'> </td></tr>" PRINT #hFile, "<head><title>Laporan Stok
Barang</title></head>"
PRINT #hFile, "<body topmargin='0' leftmargin='0'" IF prn = TRUE THEN PRINT #hFile, "
onload='window.print()'" PRINT #hFile, ">"
PRINT #hFile, "<table border='1' width='1000'
cellpadding='1' cellspacing='0' align='center'>" PRINT #hFile, " <tr>"
PRINT #hFile, " <td colspan='8' align='center'>" PRINT #hFile, " <h3>Laporan Stok Barang</h3>" PRINT #hFile, " </td>"
PRINT #hFile, " </tr>"
PRINT #hFile, " <tr><td colspan='8'> </td></tr>" PRINT #hFile, " <tr>"
PRINT #hFile, " <td width='7%' align='center'>Id Barang</td>"
PRINT #hFile, " <td width='15%' align='center'>Nama barang</td>"
PRINT #hFile, " <td width='18%'
align='center'>Keterangan</td>"
PRINT #hFile, " <td width='5%' align='center'>Warna</td>" PRINT #hFile, " <td width='5%' align='center'>Harga</td>" PRINT #hFile, " <td width='10%'
align='center'>Kadaluarsa</td>" PRINT #hFile, " <td width='5%'
align='center'>Jumlah</td>" PRINT #hFile, " <td width='10%' align='center'>Supplier</td>" PRINT #hFile, " </tr>"
END
PUBLIC SUB content(p1 AS String, p2 AS String, p3 AS String, p4 AS String, p5 AS String, p6 AS String, p7 AS String, p8 AS String) DIM a AS String DIM b AS String DIM d AS String a = Right(p5, 3) b = Right(Left(p5, -3), 3) d = Left(p5, -6) PRINT #hFile, " <tr>"
PRINT #hFile, " <td align='center'>" & p1 & "</td>" PRINT #hFile, " <td>" & p2 & "</td>"
PRINT #hFile, " <td>" & p3 & "</td>"
PRINT #hFile, " <td align='center'>" & p4 & "</td>" IF d <> NULL THEN
PRINT #hFile, " <td align='right'>" & d & "." & b & "." & a & "</td>"
ELSE
IF b <> NULL THEN
PRINT #hFile, " <td align='right'>" & b & "." & a & "</td>"
ELSE
PRINT #hFile, " <td align='right'>" & a & "</td>" ENDIF
ENDIF
PRINT #hFile, " <td align='center'>" &Format(CDate(p6), "dd mmm yyyy") & "</td>"
ELSE
PRINT #hFile, " <td align='center'>" & p6 & "</td>" ENDIF
PRINT #hFile, " <td align='center'>" & p7 & "</td>" PRINT #hFile, " <td>" & p8 & "</td>"
PRINT #hFile, " </tr>" END
PUBLIC SUB footer()
PRINT #hFile, "</table>"
sl = MdlVal.db.Exec("select * from user where id_user='" & FrmPasswd.TxtNo.Text & "'")
PRINT #hFile, "<br><br>"
PRINT #hFile, "<table border='0' width='1000'
cellpadding='1' cellspacing='0' align='center'>" PRINT #hFile, " <tr>"
PRINT #hFile, " <td><font size='2'>Dicetak oleh: <i>" & sl!nm_user & "<i/></font></td>"
PRINT #hFile, " <td align='right'><font size='2'>Tanggal: <i>" & Format$(Date(Now), "dd mmm yyyy") & "<i/></font></td>" PRINT #hFile, " </tr>"
PRINT #hFile, "</table>" PRINT #hFile, "</body>" PRINT #hFile, "</html>" END
PUBLIC SUB printit(prn AS Boolean) DIM i AS Float
WITH MdlVal.rs2 = .db.exec("select id_brg, nm_brg, ket, warna,
harga, v_date, jml_brg, nm_supplier from barang, supplier
where kd_supply=id_supplier order by nm_brg asc") IF .rs2.count <> 0 THEN
IF Exist(flname0) THEN KILL flname0 OPEN flname0 FOR WRITE CREATE AS #hFile 'print headers here
header(prn) i = 0
WHILE i < .rs2.count 'print all data here
content(CStr(.rs2!id_brg), CStr(.rs2!nm_brg), CStr(.rs2!ket), CStr(.rs2!warna), CStr(.rs2!harga), CStr(.rs2!v_date), CStr(.rs2!jml_brg), CStr(.rs2!nm_supplier))
i = i + 1 .rs2.MoveNext WEND
'print footer here footer
CLOSE #hFile
'show the report !
FrmLaporan.SetPath(flname0) FrmLaporan.ShowModal
FrmLaporan.nil = 0 ENDIF
END WITH END
b) Proses Lihat Laporan Penjualan Harian
Proses ini digunakan untuk melihat laporan penjualan harian.
Pemanggilan program jika hanya untuk melihat laporan menggunakan
printit(FALSE).Tetapi untuk pemanggilan program untuk
mencetak laporan menggunakan printit(TRUE). Berikut kode
programnya.
PUBLIC SUB header(prn AS Boolean) PRINT #hFile, "<html>"
PRINT #hFile, " <tr><td colspan='7'> </td></tr>" PRINT #hFile, "<head><title>Laporan Penjualan</title>
</head>"
PRINT #hFile, "<body topmargin='0' leftmargin='0'" IF prn = TRUE THEN PRINT #hFile, "
onload='window.print()'" PRINT #hFile, ">"
PRINT #hFile, "<table border='1' width='800' cellpadding='1' cellspacing='0' align='center'>"
PRINT #hFile, " <tr>"
PRINT #hFile, " <td colspan='7' align='center'>"
PRINT #hFile, " <font size='4'><b>Laporan Penjualan</b> </font>"
PRINT #hFile, " </td>" PRINT #hFile, " </tr>"
PRINT #hFile, " <tr><td colspan='7' align='center'><b> Tanggal: " & TxtTgl.Text & "</b></td></tr>" PRINT #hFile, " <tr>"
PRINT #hFile, " <td width='10%' align='center'> <b>Waktu</b></td>"
PRINT #hFile, " <td width='10%' align='center'><b>ID barang</b></td>"
PRINT #hFile, " <td width='20%' align='center'><b>Nama barang</b></td>"
PRINT #hFile, " <td width='30%' align='center'> <b>Keterangan</b></td>"
PRINT #hFile, " <td width='10%' align='center'> <b>Kasir</b></td>"
PRINT #hFile, " <td width='10%' align='center'><b>Jml jual</b></td>"
PRINT #hFile, " <td width='10%' align='center'><b>Tot harga</b></td>"
PRINT #hFile, " </tr>" END
PUBLIC SUB content(p0 AS String, p1 AS String, p2 AS String, p3 AS String, p4 AS String, p5 AS String, p6 AS String) DIM a AS String DIM b AS String DIM d AS String a = Right(p6, 3) b = Right(Left(p6, -3), 3) d = Left(p6, -6) PRINT #hFile, " <tr>"
PRINT #hFile, " <td align='center'>" & p0 & "</td>" PRINT #hFile, " <td align='center'>" & p1 & "</td>" PRINT #hFile, " <td>" & p2 & "</td>" 'Nm brg
PRINT #hFile, " <td>" & p3 & "</td>" 'Ket PRINT #hFile, " <td>" & p4 & "</td>" 'Kasir
PRINT #hFile, " <td align='center'>" & p5 & "</td>" IF d <> NULL THEN
PRINT #hFile, " <td align='right'>" & d & "." & b & "." & a & "</td>"
ELSE
IF b <> NULL THEN
PRINT #hFile, " <td align='right'>" & b & "." & a & "</td>" 'tot harga
ELSE
PRINT #hFile, " <td align='right'>" & a & "</td>" ENDIF
ENDIF
PRINT #hFile, " </tr>" END
PUBLIC SUB footer()
PRINT #hFile, "</table>"
sl = MdlVal.db.Exec("select * from user where id_user='" & FrmPasswd.TxtNo.Text & "'")
PRINT #hFile, "<br><br>"
PRINT #hFile, "<table border='0' width='800' cellpadding='1' cellspacing='0' align='center'>"
PRINT #hFile, " <tr>"
PRINT #hFile, " <td><font size='2'>Dicetak oleh: <i>" & sl!nm_user & "<i/></font></td>"
PRINT #hFile, " <td align='right'><font size='2'>Tanggal: <i>" & Format$(Date(Now), "dd mmm yyyy") &
"<i/></font></td>" PRINT #hFile, " </tr>" PRINT #hFile, "</table>" PRINT #hFile, "</body>" PRINT #hFile, "</html>" END
PUBLIC SUB printit(prn AS Boolean) DIM i AS Float
DIM tot AS Long DIM a AS String DIM b AS String DIM c AS String DIM d AS String tot = 0
WITH MdlVal.rs2 = .db.exec("select waktu, id_brg, nm_brg, ket, nm_user, jml_jual_brg, harga,
((jml_jual_brg*harga)-((jml_jual_brg*harga)*(discount/100))) total from jual, barang, user where id_user=kd_kasir and kd_brg=id_brg and waktu like '" & "%" & tgl1 & "%" & "' order by waktu asc") IF .rs2.count <> 0 THEN
IF Exist(flname) THEN KILL flname OPEN flname FOR WRITE CREATE AS #hFile 'print headers here
header(prn) i = 0
WHILE i < .rs2.count 'print all data here
content(Right(CStr(.rs2!waktu), -10), CStr(.rs2!id_brg), CStr(.rs2!nm_brg), CStr(.rs2!ket), CStr(.rs2!nm_user), CStr(.rs2!jml_jual_brg), Left(CStr(.rs2!total), -5)) i = i + 1
tot = tot + .rs2!total .rs2.MoveNext WEND c = tot a = Right(c, 3) b = Right(Left(c, -3), 3) d = Left(c, -6) IF d <> NULL THEN
PRINT #hFile, " <tr><td colspan='7' align='right'><b>Total Harga Keseluruhan Penjualan: Rp. " & d & "." & b & "." & a & " </td></tr>"
ELSE
IF b <> NULL THEN
PRINT #hFile, " <tr><td colspan='7' align='right'><b>Total Harga Keseluruhan Penjualan: Rp. " & b & "." & a &
" </td></tr>" ELSE
PRINT #hFile, " <tr><td colspan='7' align='right'><b>Total Harga Keseluruhan Penjualan: Rp. " & a &
" </td></tr>" ENDIF ENDIF footer CLOSE #hFile FrmLaporan.SetPath(flname) FrmLaporan.ShowModal FrmLaporan.nil = 1 ELSE
message.Info("Data Penjualan Kosong!") ENDIF
END WITH CATCH
message.Error("Kesalahan sistem. Harap hubungi programer\n" & error.Text & " " & error.Where) END
c) Proses Lihat Laporan Penjualan Bulanan
Proses ini digunakan untuk melihat laporan penjualan harian.
Pemanggilan program jika hanya untuk melihat laporan
menggunakan
printit1(FALSE).Tetapi untuk pemanggilan
program untuk mencetak laporan menggunakan printit1(TRUE).
Berikut kode programnya.
PUBLIC SUB header1(prn AS Boolean) PRINT #hFile, "<html>"
PRINT #hFile, " <tr><td colspan='5'> </td></tr>" PRINT #hFile, "<head><title>Laporan Penjualan</title>
</head>"
PRINT #hFile, "<body topmargin='0' leftmargin='0'" IF prn = TRUE THEN PRINT #hFile, " onload=
'window.print()'" PRINT #hFile, ">"
PRINT #hFile, "<table border='1' width='800' cellpadding='1' cellspacing='0' align='center'>"
PRINT #hFile, " <tr>"
PRINT #hFile, " <td colspan='5' align='center'>"
PRINT #hFile, " <font size='4'><b>Laporan Penjualan</b> </font>"
PRINT #hFile, " </td>" PRINT #hFile, " </tr>"
PRINT #hFile, " <tr><td colspan='5' align='center'> <b>Bulan: " & CmbBln.Text & " Tahun: " & CmbThBln.Text & "</b></td></tr>"
PRINT #hFile, " <tr>"
PRINT #hFile, " <td width='10%' align='center'><b>ID barang</b></td>"
PRINT #hFile, " <td width='20%' align='center'><b>Nama barang</b></td>"
PRINT #hFile, " <td width='30%' align='center'> <b>Keterangan</b></td>"
PRINT #hFile, " <td width='10%' align='center'><b>Jumlah jual</b></td>"
PRINT #hFile, " <td width='10%' align='center'><b>Total harga</b></td>"
PRINT #hFile, " </tr>" END
PUBLIC SUB content1(p1 AS String, p2 AS String, p3 AS String, p4 AS String, p5 AS String) DIM a AS String DIM b AS String DIM d AS String a = Right(p5, 3) b = Right(Left(p5, -3), 3) d = Left(p5, -6)
PRINT #hFile, " <tr>"
PRINT #hFile, " <td align='center'>" & p1 & "</td>" 'id brg PRINT #hFile, " <td>" & p2 & "</td>" 'Nm brg
PRINT #hFile, " <td>" & p3 & "</td>" 'Ket
PRINT #hFile, " <td align='center'>" & p4 & "</td>" IF d <> NULL THEN
PRINT #hFile, " <td align='right'>" & d & "." & b & "." & a & "</td>" 'tot harga
ELSE
IF b <> NULL THEN
PRINT #hFile, " <td align='right'>" & b & "." & a & "</td>" ELSE
PRINT #hFile, " <td align='right'>" & a & "</td>" 'tot harga
ENDIF ENDIF
PRINT #hFile, " </tr>" END
PUBLIC SUB footer1()
PRINT #hFile, "</table>"
sl = MdlVal.db.Exec("select * from user where id_user='" & FrmPasswd.TxtNo.Text & "'")
PRINT #hFile, "<br><br>"
PRINT #hFile, "<table border='0' width='800' cellpadding='1' cellspacing='0' align='center'>"
PRINT #hFile, " <tr>"
PRINT #hFile, " <td><font size='2'>Dicetak oleh: <i>" & sl!nm_user & "<i/></font></td>"
PRINT #hFile, " <td align='right'><font size='2'>Tanggal: <i>" & Format$(Date(Now), "dd mmm yyyy") &
"<i/></font></td>" PRINT #hFile, " </tr>" PRINT #hFile, "</table>" PRINT #hFile, "</body>" PRINT #hFile, "</html>" END
PUBLIC SUB printit1(prn AS Boolean) DIM i AS Float
DIM tot AS Long DIM a AS String DIM b AS String DIM c AS String DIM d AS String tot = 0
WITH MdlVal.rs2 = .db.exec("select id_brg, nm_brg, ket, sum(jml_jual_brg) jumlah, harga*sum(jml_jual_brg)
total_harga from jual, barang, user where id_user=kd_kasir and kd_brg=id_brg and waktu like '" & "%" & CmbBln.ToolTip & "/" & "%%" & "/" & CmbThBln.Text & "%" & "' group by nm_brg order by nm_brg asc")
IF .rs2.count <> 0 THEN
IF Exist(flname1) THEN KILL flname1 OPEN flname1 FOR WRITE CREATE AS #hFile 'print headers here
header1(prn) i = 0
WHILE i < .rs2.count 'print all data here
content1(CStr(.rs2!id_brg), CStr(.rs2!nm_brg), CStr(.rs2!ket), CStr(.rs2!jumlah), CStr(.rs2!total_harga))
i = i + 1
tot = tot + .rs2!total_harga .rs2.MoveNext WEND c = tot a = Right(c, 3) b = Right(Left(c, -3), 3) d = Left(c, -6) PRINT b IF d <> NULL THEN
PRINT #hFile, " <tr><td colspan='5' align='right'><b>Total Harga Keseluruhan Penjualan: Rp. " & d & "." & b & "." & a & " </td></tr>"
ELSE
PRINT #hFile, " <tr><td colspan='5' align='right'><b>Total Harga Keseluruhan Penjualan: Rp. " & b & "." & a &
" </td></tr>" ENDIF
'print footer here footer1
CLOSE #hFile
'show the report !
FrmLaporan.SetPath(flname1) FrmLaporan.ShowModal
ELSE
message.Info("Data Penjualan Kosong!") ENDIF
END WITH CATCH
message.Error("Kesalahan sistem. Harap hubungi programer\n" & error.Text & " " & error.Where) END
d) Proses Lihat Laporan Penjualan Tahunan
Proses ini digunakan untuk melihat laporan penjualan harian.
Pemanggilan program jika hanya untuk melihat laporan
menggunakan
printit2(FALSE).Tetapi untuk pemanggilan
program untuk mencetak laporan menggunakan printit2(TRUE).
Berikut kode programnya.
PUBLIC SUB header2(prn AS Boolean) PRINT #hFile, "<html>"
PRINT #hFile, "<head><title>Laporan Penjualan</title> </head>"
PRINT #hFile, "<body topmargin='0' leftmargin='0'"
IF prn = TRUE THEN PRINT #hFile, " onload='window.print()'" PRINT #hFile, ">"
PRINT #hFile, "<table border='1' width='800' cellpadding='1' cellspacing='0' align='center'>"
PRINT #hFile, " <tr>"
PRINT #hFile, " <td colspan='5' align='center'>" PRINT #hFile, " <font size='4'><b>Laporan
Penjualan</b></font>" PRINT #hFile, " </td>" PRINT #hFile, " </tr>"
PRINT #hFile, " <tr><td colspan='5' align='center'> <b>Tahun: "
& CmbThn.Text & "</b></td></tr>" PRINT #hFile, " <tr>"
PRINT #hFile, " <td width='10%' align='center'><b>ID barang</b></td>"
PRINT #hFile, " <td width='20%' align='center'><b>Nama barang</b></td>"
PRINT #hFile, " <td width='30%' align='center'> <b>Keterangan</b></td>"
PRINT #hFile, " <td width='10%' align='center'><b>Jumlah jual</b></td>"
PRINT #hFile, " <td width='10%' align='center'><b>Total harga</b></td>"
PRINT #hFile, " </tr>" END
PUBLIC SUB content2(p1 AS String, p2 AS String, p3 AS String, p4 AS String, p5 AS String) DIM a AS String DIM b AS String DIM d AS String a = Right(p5, 3) b = Right(Left(p5, -3), 3) d = Left(p5, -6) PRINT #hFile, " <tr>"
PRINT #hFile, " <td align='center'>" & p1 & "</td>" PRINT #hFile, " <td>" & p2 & "</td>" 'Nm brg
PRINT #hFile, " <td>" & p3 & "</td>" 'Ket
PRINT #hFile, " <td align='center'>" & p4 & "</td>" IF d <> NULL THEN
PRINT #hFile, " <td align='right'>" & d & "." & b & "." & a & "</td>" 'tot harga
ELSE
PRINT #hFile, " <td align='right'>" & b & "." & a & "</td>" ENDIF
PRINT #hFile, " </tr>" END
PUBLIC SUB footer2()
PRINT #hFile, "</table>"
sl = MdlVal.db.Exec("select * from user where id_user='" & FrmPasswd.TxtNo.Text & "'")
PRINT #hFile, "<br><br>"
PRINT #hFile, "<table border='0' width='800' cellpadding='1' cellspacing='0' align='center'>"
PRINT #hFile, " <tr>"
PRINT #hFile, " <td><font size='2'>Dicetak oleh: <i>" & sl!nm_user & "<i/></font></td>"
PRINT #hFile, " <td align='right'><font size='2'>Tanggal: <i>" & Format$(Date(Now), "dd mmm yyyy") &
"<i/></font></td>" PRINT #hFile, " </tr>" PRINT #hFile, "</table>" PRINT #hFile, "</body>" PRINT #hFile, "</html>" END
PUBLIC SUB printit2(prn AS Boolean) DIM i AS Float
DIM tot AS Long DIM a AS String DIM b AS String DIM c AS String DIM d AS String
WITH MdlVal.rs2 = .db.exec("select id_brg, nm_brg, ket, sum(jml_jual_brg) jumlah, harga*sum(jml_jual_brg)
total_harga from jual, barang, user where id_user=kd_kasir and kd_brg=id_brg and waktu like '" & "%" & CmbThn.Text & "%" & "' group by nm_brg order by nm_brg asc")
IF .rs2.count <> 0 THEN
IF Exist(flname2) THEN KILL flname2 OPEN flname2 FOR WRITE CREATE AS #hFile 'print headers here
header2(prn) i = 0
WHILE i < .rs2.count 'print all data here
content2(CStr(.rs2!id_brg), CStr(.rs2!nm_brg), CStr(.rs2!ket), CStr(.rs2!jumlah), CStr(.rs2!total_harga))
i = i + 1
tot = tot + .rs2!total_harga .rs2.MoveNext WEND c = tot a = Right(c, 3) b = Right(Left(c, -3), 3) d = Left(c, -6) IF d <> NULL THEN
PRINT #hFile, " <tr><td colspan='5' align='right'><b>Total Harga Keseluruhan Penjualan: Rp. " & d & "." & b & "." & a & " </td></tr>"
ELSE
PRINT #hFile, " <tr><td colspan='5' align='right'><b>Total Harga Keseluruhan Penjualan: Rp. " & b & "." & a &
" </td></tr>"