Files
firstgarden-web-gnu/adm/shop_admin/sale1year.php

124 lines
4.7 KiB
PHP

<?php
$sub_menu = '500110';
include_once('./_common.php');
auth_check($auth[$sub_menu], "r");
$g4['title'] = "$fr_year ~ $to_year 연간 매출현황"; /*레이블 중복 인식과 페이지와의 연결 때문에 year로 바꿈 김혜련 2013-04-04*/
include_once (G4_ADMIN_PATH.'/admin.head.php');
function print_line($save)
{
?>
<tr>
<td><a href="./sale1month.php?fr_month=<?php echo $save['od_date']; ?>01&amp;to_month=<?php echo $save['od_date']; ?>12"><?php echo $save['od_date']; ?></a></td>
<td><?php echo number_format($save['ordercount']); ?></td>
<td><?php echo number_format($save['orderamount']); ?></td>
<td><?php echo number_format($save['ordercancel'] + $save['dc']); ?></td>
<td><?php echo number_format($save['receiptbank']); ?></td>
<td><?php echo number_format($save['receiptcard']); ?></td>
<td><?php echo number_format($save['receiptpoint']); ?></td>
<td><?php echo number_format($save['receiptcancel']); ?></td>
<td><?php echo number_format($save['misu']); ?></td>
</tr>
<?php
}
$sql = " select od_id,
SUBSTRING(od_time,1,4) as od_date,
od_send_cost,
od_settle_case,
od_receipt_amount,
od_receipt_point,
od_cart_amount,
od_cancel_amount,
(od_cart_amount + od_send_cost + od_send_cost2 - od_cart_coupon - od_coupon - od_send_coupon - od_receipt_amount - od_cancel_amount) as misu,
(od_cart_coupon + od_coupon + od_send_coupon) as couponamount
from {$g4['shop_order_table']}
where SUBSTRING(od_time,1,4) between '$fr_year' and '$to_year'
order by od_time desc ";
$result = sql_query($sql);
?>
<section id="ssale_year" class="cbox">
<h2>연간 매출 집계 목록</h2>
<table>
<thead>
<tr>
<th scope="col">주문년도</th>
<th scope="col">주문수</th>
<th scope="col">주문합계</th>
<th scope="col">쿠폰</th>
<th scope="col">계좌입금</th>
<th scope="col">카드입금</th>
<th scope="col">포인트입금</th>
<th scope="col">주문취소</th>
<th scope="col">미수금</th>
</tr>
</thead>
<tbody>
<?php
unset($save);
unset($tot);
for ($i=0; $row=sql_fetch_array($result); $i++)
{
if ($i == 0)
$save['od_date'] = $row['od_date'];
if ($save['od_date'] != $row['od_date']) {
print_line($save);
unset($save);
$save['od_date'] = $row['od_date'];
}
$save['ordercount']++;
$save['orderamount'] += $row['od_cart_amount'];
$save['ordercancel'] += $row['od_cancel_amount'];
$save['ordercoupon'] += $row['couponamount'];
if($row['od_settle_case'] == '무통장' || $row['od_settle_case'] == '가상계좌' || $row['od_settle_case'] == '계좌이체')
$save['receiptbank'] += $row['od_receipt_amount'];
if($row['od_settle_case'] == '신용카드')
$save['receiptcard'] += $row['od_receipt_amount'];
$save['receiptpoint'] += $row['od_receipt_point'];
$save['misu'] += $row['misu'];
$tot['ordercount']++;
$tot['orderamount'] += $row['od_cart_amount'];
$tot['ordercancel'] += $row1['od_cancel_amount'];
$tot['ordercoupon'] += $row['couponamount'];
if($row['od_settle_case'] == '무통장' || $row['od_settle_case'] == '가상계좌' || $row['od_settle_case'] == '계좌이체')
$tot['receiptbank'] += $row['od_receipt_amount'];
if($row['od_settle_case'] == '신용카드')
$tot['receiptcard'] += $row['od_receipt_amount'];
$tot['receiptpoint'] += $row['od_receipt_point'];
$tot['misu'] += $row['misu'];
}
if ($i == 0) {
echo '<tr><td colspan="9" calss="empty_table">자료가 없습니다.</td></tr>';
} else {
print_line($save);
}
?>
</tbody>
<tfoot>
<tr>
<td>합 계</td>
<td><?php echo number_format($tot['ordercount']); ?></td>
<td><?php echo number_format($tot['orderamount']); ?></td>
<td><?php echo number_format($tot['ordercoupon']); ?></td>
<td><?php echo number_format($tot['receiptbank']); ?></td>
<td><?php echo number_format($tot['receiptcard']); ?></td>
<td><?php echo number_format($tot['receiptpoint']); ?></td>
<td><?php echo number_format($tot['ordercancel']); ?></td>
<td><?php echo number_format($tot['misu']); ?></td>
</tr>
</tfoot>
</table>
</section>
<?php
include_once (G4_ADMIN_PATH.'/admin.tail.php');
?>