누계 데이터 출력 추가.
This commit is contained in:
@ -254,10 +254,11 @@ if (!$authInfo) {
|
||||
|
||||
<?php $i++;
|
||||
} // endforeach
|
||||
$sumData = getBakeryInvenSummaryData($searchDate);
|
||||
?>
|
||||
</tbody>
|
||||
<!-- 합계 데이터 출력 -->
|
||||
<tfoot>
|
||||
<!-- 합계 데이터 출력 -->
|
||||
<tr>
|
||||
<td colspan="3" class="text-center">합계</th>
|
||||
<td class="text-end" id="total_prev_stock"><?=number_format($t_prev_stock)?></th>
|
||||
@ -272,6 +273,21 @@ if (!$authInfo) {
|
||||
<td class="text-end" id="total_payment_amount"><?=number_format($t_payment_amount)?></th>
|
||||
<td class="text-end" id="total_current_stock"><?=number_format($t_current_stock)?></th>
|
||||
</tr>
|
||||
<!-- 누계 데이터 출력 -->
|
||||
<tr>
|
||||
<td colspan="3" class="text-center">누계</th>
|
||||
<td class="text-end" id="summary_prev_stock"><?=number_format($sumData['total_previous_stock'])?></th>
|
||||
<td class="text-end" id="summary_production"><?=number_format($sumData['total_production'])?></th>
|
||||
<td class="text-end" id="summary_inhouse_use"><?=number_format($sumData['total_inhouse_use'])?></th>
|
||||
<td class="text-end" id="summary_recycling"><?=number_format($sumData['total_recycling'])?></th>
|
||||
<td class="text-end" id="summary_disposal"><?=number_format($sumData['total_disposal'])?></th>
|
||||
<td class="text-end" id="summary_sales"><?=number_format($sumData['total_sales'])?></th>
|
||||
<td class="text-end" id="summary_unit_price"></th>
|
||||
<td class="text-end" id="summary_sales_amount"><?=number_format($sumData['total_sales_amount'])?></th>
|
||||
<td class="text-end" id="summary_menu_discount"><?=number_format($sumData['total_menu_discount'])?></th>
|
||||
<td class="text-end" id="summary_payment_amount"><?=number_format($sumData['total_payment_amount'])?></th>
|
||||
<td class="text-end" id="summary_current_stock"></th>
|
||||
</tr>
|
||||
</tfoot>
|
||||
</table>
|
||||
</div>
|
||||
|
||||
@ -384,7 +384,53 @@ function get_total_count($db_name) {
|
||||
return sql_fetch($query); // 결과 없으면 false 반환
|
||||
}
|
||||
|
||||
// 누계 구하기
|
||||
function getBakeryInvenSummaryData($date, $ord_by = "b.product_name ASC") {
|
||||
global $fg;
|
||||
|
||||
// 해당 월의 시작일과 종료일 계산
|
||||
$month_start = date('Y-m-01', strtotime($date));
|
||||
$month_end = $date;
|
||||
|
||||
// 전월 마지막 날짜 계산
|
||||
$prev_month_last_day = date('Y-m-t', strtotime($month_start . ' -1 month'));
|
||||
|
||||
// 전월 current_stock 조회
|
||||
$prev_query = "
|
||||
SELECT SUM(current_stock) AS total_previous_stock
|
||||
FROM {$fg['bakery_inventory_table']} AS a
|
||||
LEFT JOIN {$fg['bakery_product_table']} AS b
|
||||
ON a.barcode = b.barcode
|
||||
WHERE b.used = 1
|
||||
AND a.date = '{$prev_month_last_day}'
|
||||
";
|
||||
$prev_result = sql_fetch($prev_query);
|
||||
$total_previous_stock = $prev_result['total_previous_stock'] ?? '';
|
||||
|
||||
// 현재 월 누적 합산 조회
|
||||
$query = "
|
||||
SELECT
|
||||
SUM(a.production) AS total_production,
|
||||
SUM(a.inhouse_use) AS total_inhouse_use,
|
||||
SUM(a.recycling) AS total_recycling,
|
||||
SUM(a.disposal) AS total_disposal,
|
||||
SUM(a.sales) AS total_sales,
|
||||
SUM(a.sales_amount) AS total_sales_amount,
|
||||
SUM(a.menu_discount) AS total_menu_discount,
|
||||
SUM(a.payment_amount) AS total_payment_amount
|
||||
FROM {$fg['bakery_inventory_table']} AS a
|
||||
LEFT JOIN {$fg['bakery_product_table']} AS b
|
||||
ON a.barcode = b.barcode
|
||||
WHERE b.used = 1
|
||||
AND a.date BETWEEN '{$month_start}' AND '{$month_end}'
|
||||
";
|
||||
$result = sql_fetch($query);
|
||||
|
||||
// previous_stock 추가
|
||||
$result['total_previous_stock'] = $total_previous_stock;
|
||||
|
||||
return $result;
|
||||
}
|
||||
|
||||
// 전체 품명 불러오기
|
||||
function getBakeryProductList($ord_by = "ASC") {
|
||||
|
||||
Reference in New Issue
Block a user