-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathexcel.php
115 lines (112 loc) · 4.21 KB
/
excel.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
<?php
header("Content-Type: application/vnd.ms-excel; charset=utf-8");
header("Content-Disposition: attachment; filename=data-laporan-".date('Y-m-d').".xls"); //File name extension was wrong
header("Expires: 0");
header("Cache-Control: must-revalidate, post-check=0, pre-check=0");
header("Cache-Control: private",false);
require 'config.php';
include $view;
$lihat = new view($config);
$bulan_tes =array(
'01'=>"Januari",
'02'=>"Februari",
'03'=>"Maret",
'04'=>"April",
'05'=>"Mei",
'06'=>"Juni",
'07'=>"Juli",
'08'=>"Agustus",
'09'=>"September",
'10'=>"Oktober",
'11'=>"November",
'12'=>"Desember"
);
?>
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Document</title>
</head>
<body>
<!-- view barang -->
<!-- view barang -->
<div class="modal-view">
<h3 style="text-align:center;">
<?php if(!empty($_GET['cari'])){ ?>
Data Laporan Penjualan <?= $bulan_tes[$_GET['bln']];?> <?= $_GET['thn'];?>
<?php }elseif(!empty($_GET['hari'])){?>
Data Laporan Penjualan <?= $_GET['tgl'];?>
<?php }else{?>
Data Laporan Penjualan <?= $bulan_tes[date('m')];?> <?= date('Y');?>
<?php }?>
</h3>
<table border="1" width="100%" cellpadding="3" cellspacing="4">
<thead>
<tr bgcolor="yellow">
<th> No</th>
<th> ID Barang</th>
<th> Nama Barang</th>
<th style="width:10%;"> Jumlah</th>
<th style="width:10%;"> Modal</th>
<th style="width:10%;"> Total</th>
<th> Kasir</th>
<th> Tanggal Input</th>
</tr>
</thead>
<tbody>
<?php
$no=1;
if(!empty($_GET['cari'])){
$periode = $_GET['bln'].'-'.$_GET['thn'];
$no=1;
$jumlah = 0;
$bayar = 0;
$hasil = $lihat -> periode_jual($periode);
}elseif(!empty($_GET['hari'])){
$hari = $_GET['tgl'];
$no=1;
$jumlah = 0;
$bayar = 0;
$hasil = $lihat -> hari_jual($hari);
}else{
$hasil = $lihat -> jual();
}
?>
<?php
$bayar = 0;
$jumlah = 0;
$modal = 0;
foreach($hasil as $isi){
$bayar += $isi['total'];
$modal += $isi['harga_beli'] * $isi['jumlah'];
$jumlah += $isi['jumlah'];
?>
<tr>
<td><?php echo $no;?></td>
<td><?php echo $isi['id_barang'];?></td>
<td><?php echo $isi['nama_barang'];?></td>
<td><?php echo $isi['jumlah'];?> </td>
<td>Rp.<?php echo number_format($isi['harga_beli']* $isi['jumlah']);?>,-</td>
<td>Rp.<?php echo number_format($isi['total']);?>,-</td>
<td><?php echo $isi['nm_member'];?></td>
<td><?php echo $isi['tanggal_input'];?></td>
</tr>
<?php $no++; }?>
<tr>
<td>-</td>
<td>-</td>
<td><b>Total Terjual</b></td>
<td><b><?php echo $jumlah;?></b></td>
<td><b>Rp.<?php echo number_format($modal);?>,-</b></td>
<td><b>Rp.<?php echo number_format($bayar);?>,-</b></td>
<td><b>Keuntungan</b></td>
<td><b>
Rp.<?php echo number_format($bayar-$modal);?>,-</b></td>
</tr>
</tbody>
</table>
</div>
</body>
</html>