사이트·관리자 봉투 물류 기능(수불·통계·레포트·재고·발주)과 DB·메뉴·E2E를 운영 반영한다.
통계 분석(전년대비·월별·계절별), 수급계획·LOT 수불, 지정판매소·실사·메뉴 링크 등을 포함한다. Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
@@ -1,73 +1,184 @@
|
||||
<?= view('components/print_header', ['printTitle' => '기간별 판매현황']) ?>
|
||||
<section class="border-b border-gray-300 p-2 shrink-0 bg-control-panel">
|
||||
<?php
|
||||
declare(strict_types=1);
|
||||
|
||||
/** @var list<array<string,mixed>> $lines */
|
||||
/** @var string $startDate */
|
||||
/** @var string $endDate */
|
||||
/** @var int $saIdx */
|
||||
/** @var string $catFilter */
|
||||
/** @var string $mode */
|
||||
/** @var list<object> $agencies */
|
||||
/** @var array<string,string> $catLabels */
|
||||
/** @var bool $hasBsFee */
|
||||
/** @var string $lgName */
|
||||
/** @var string $agencyLabel */
|
||||
/** @var string $catLabelFilter */
|
||||
/** @var list<string> $printExtraLines */
|
||||
|
||||
$byDaily = ($mode ?? 'daily') === 'daily';
|
||||
|
||||
$exportParams = array_filter([
|
||||
'start_date' => $startDate ?? '',
|
||||
'end_date' => $endDate ?? '',
|
||||
'sa_idx' => (int) ($saIdx ?? 0),
|
||||
'cat' => (string) ($catFilter ?? ''),
|
||||
'mode' => $byDaily ? '' : 'period',
|
||||
'export' => '1',
|
||||
], static fn ($v): bool => $v !== '' && $v !== null);
|
||||
$excelUrl = mgmt_url('reports/period-sales?' . http_build_query($exportParams));
|
||||
|
||||
$fmtFee = static function (float $v) use ($hasBsFee): string {
|
||||
if (! $hasBsFee) {
|
||||
return '—';
|
||||
}
|
||||
|
||||
return number_format((int) round($v));
|
||||
};
|
||||
|
||||
$rowClass = static function (string $kind): string {
|
||||
return match ($kind) {
|
||||
'day_sub_all' => 'bg-gray-100 font-semibold',
|
||||
'day_sub_bag' => 'bg-sky-50 font-semibold text-sky-900',
|
||||
'day_sub_fs' => 'bg-violet-50 font-semibold text-violet-900',
|
||||
'foot_all' => 'bg-red-50 font-bold text-red-700',
|
||||
'foot_bag' => 'bg-blue-50 font-bold text-blue-700',
|
||||
'foot_fs' => 'bg-purple-50 font-bold text-purple-800',
|
||||
default => '',
|
||||
};
|
||||
};
|
||||
?>
|
||||
<?= view('components/print_header', [
|
||||
'printTitle' => '기간별 판매현황',
|
||||
'printExtraLines' => $printExtraLines ?? [],
|
||||
]) ?>
|
||||
|
||||
<section class="border-b border-gray-300 p-2 shrink-0 bg-control-panel no-print">
|
||||
<div class="flex flex-wrap items-center justify-between gap-y-2">
|
||||
<span class="text-sm font-bold text-gray-700">기간별 판매현황</span>
|
||||
<button onclick="window.print()" class="no-print border border-btn-print-border text-gray-600 px-3 py-1 rounded-sm text-sm hover:bg-gray-50 transition">인쇄</button>
|
||||
<div class="flex flex-wrap gap-2">
|
||||
<button type="button" onclick="window.print()" class="border border-btn-print-border text-gray-600 px-3 py-1 rounded-sm text-sm hover:bg-gray-50 transition">인쇄</button>
|
||||
<a href="<?= esc($excelUrl, 'attr') ?>" class="inline-flex items-center border border-green-600 text-green-700 px-3 py-1 rounded-sm text-sm hover:bg-green-50 transition">엑셀저장</a>
|
||||
</div>
|
||||
</div>
|
||||
</section>
|
||||
<section class="p-2 bg-white border-b border-gray-200">
|
||||
<form method="GET" action="<?= mgmt_url('reports/period-sales') ?>" class="flex flex-wrap items-center gap-2">
|
||||
<label class="text-sm text-gray-600">시작일</label>
|
||||
<input type="date" name="start_date" value="<?= esc($startDate ?? '') ?>" class="border border-gray-300 rounded px-2 py-1 text-sm"/>
|
||||
<label class="text-sm text-gray-600">~</label>
|
||||
<input type="date" name="end_date" value="<?= esc($endDate ?? '') ?>" class="border border-gray-300 rounded px-2 py-1 text-sm"/>
|
||||
<button type="submit" class="bg-btn-search text-white px-4 py-1 rounded-sm text-sm">조회</button>
|
||||
|
||||
<section class="p-3 bg-white border-b border-gray-200 no-print">
|
||||
<form method="GET" action="<?= mgmt_url('reports/period-sales') ?>" class="flex flex-wrap items-end gap-3 text-sm">
|
||||
<div>
|
||||
<label class="block text-gray-600 mb-0.5">시작일</label>
|
||||
<input type="date" name="start_date" value="<?= esc($startDate ?? '') ?>" class="border border-gray-300 rounded px-2 py-1 text-sm"/>
|
||||
</div>
|
||||
<div>
|
||||
<label class="block text-gray-600 mb-0.5">종료일</label>
|
||||
<input type="date" name="end_date" value="<?= esc($endDate ?? '') ?>" class="border border-gray-300 rounded px-2 py-1 text-sm"/>
|
||||
</div>
|
||||
<div>
|
||||
<label class="block text-gray-600 mb-0.5">대행소</label>
|
||||
<select name="sa_idx" class="border border-gray-300 rounded px-2 py-1 text-sm min-w-[12rem] max-w-[20rem]">
|
||||
<option value="0">전체</option>
|
||||
<?php foreach ($agencies ?? [] as $agency): ?>
|
||||
<?php $aid = (int) ($agency->sa_idx ?? 0); ?>
|
||||
<option value="<?= esc((string) $aid) ?>" <?= (int) ($saIdx ?? 0) === $aid ? 'selected' : '' ?>>
|
||||
<?= esc(trim((string) ($agency->sa_name ?? ''))) ?>
|
||||
</option>
|
||||
<?php endforeach; ?>
|
||||
</select>
|
||||
</div>
|
||||
<div>
|
||||
<label class="block text-gray-600 mb-0.5">구분</label>
|
||||
<select name="cat" class="border border-gray-300 rounded px-2 py-1 text-sm min-w-[10rem]">
|
||||
<option value="" <?= ($catFilter ?? '') === '' ? 'selected' : '' ?>>전체</option>
|
||||
<?php foreach (($catLabels ?? []) as $ck => $lab): ?>
|
||||
<option value="<?= esc($ck, 'attr') ?>" <?= ($catFilter ?? '') === $ck ? 'selected' : '' ?>><?= esc($lab) ?></option>
|
||||
<?php endforeach; ?>
|
||||
</select>
|
||||
</div>
|
||||
<div>
|
||||
<label class="block text-gray-600 mb-0.5">집계 방식</label>
|
||||
<select name="mode" class="border border-gray-300 rounded px-2 py-1 text-sm min-w-[9rem]">
|
||||
<option value="daily" <?= $byDaily ? 'selected' : '' ?>>일자별</option>
|
||||
<option value="period" <?= ! $byDaily ? 'selected' : '' ?>>기간별</option>
|
||||
</select>
|
||||
</div>
|
||||
<button type="submit" class="bg-btn-search text-white px-4 py-1.5 rounded-sm text-sm">조회</button>
|
||||
</form>
|
||||
</section>
|
||||
|
||||
<div class="border border-gray-300 overflow-auto mt-2">
|
||||
<table class="w-full data-table">
|
||||
<thead>
|
||||
<tr>
|
||||
<th>봉투코드</th>
|
||||
<th>봉투명</th>
|
||||
<th>판매수량</th>
|
||||
<th>판매금액</th>
|
||||
<th>반품수량</th>
|
||||
<th>반품금액</th>
|
||||
<th>합계수량</th>
|
||||
<th>합계금액</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody class="text-right">
|
||||
<?php
|
||||
$grandSaleQty = 0;
|
||||
$grandSaleAmount = 0;
|
||||
$grandReturnQty = 0;
|
||||
$grandReturnAmount = 0;
|
||||
?>
|
||||
<?php foreach ($result as $row): ?>
|
||||
<?php
|
||||
$grandSaleQty += (int) $row->sale_qty;
|
||||
$grandSaleAmount += (int) $row->sale_amount;
|
||||
$grandReturnQty += (int) $row->return_qty;
|
||||
$grandReturnAmount += (int) $row->return_amount;
|
||||
?>
|
||||
<tr>
|
||||
<td class="text-center font-mono"><?= esc($row->bs_bag_code) ?></td>
|
||||
<td class="text-left pl-2"><?= esc($row->bs_bag_name) ?></td>
|
||||
<td><?= number_format((int) $row->sale_qty) ?></td>
|
||||
<td><?= number_format((int) $row->sale_amount) ?></td>
|
||||
<td><?= number_format((int) $row->return_qty) ?></td>
|
||||
<td><?= number_format((int) $row->return_amount) ?></td>
|
||||
<td class="font-bold"><?= number_format((int) $row->sale_qty - (int) $row->return_qty) ?></td>
|
||||
<td class="font-bold"><?= number_format((int) $row->sale_amount - (int) $row->return_amount) ?></td>
|
||||
</tr>
|
||||
<?php endforeach; ?>
|
||||
<?php if (empty($result)): ?>
|
||||
<tr><td colspan="8" class="text-center text-gray-400 py-4">조회된 데이터가 없습니다.</td></tr>
|
||||
<?php endif; ?>
|
||||
</tbody>
|
||||
<tfoot class="bg-gray-50 font-bold text-right">
|
||||
<tr>
|
||||
<td colspan="2" class="text-center">합계</td>
|
||||
<td><?= number_format($grandSaleQty) ?></td>
|
||||
<td><?= number_format($grandSaleAmount) ?></td>
|
||||
<td><?= number_format($grandReturnQty) ?></td>
|
||||
<td><?= number_format($grandReturnAmount) ?></td>
|
||||
<td><?= number_format($grandSaleQty - $grandReturnQty) ?></td>
|
||||
<td><?= number_format($grandSaleAmount - $grandReturnAmount) ?></td>
|
||||
</tr>
|
||||
</tfoot>
|
||||
</table>
|
||||
</div>
|
||||
<section class="p-3 bg-white">
|
||||
<style>
|
||||
@media print {
|
||||
.period-sales-screen-title { display: none !important; }
|
||||
}
|
||||
</style>
|
||||
<div class="mb-2 text-center period-sales-screen-title no-print">
|
||||
<h1 class="text-lg font-bold m-0">기간별 판매현황<?= $byDaily ? ' [일집계]' : ' [기간집계]' ?></h1>
|
||||
<p class="text-sm text-gray-700 m-1"><?= esc(trim(($lgName ?? '') . ' · ' . ($startDate ?? '') . ' ~ ' . ($endDate ?? '') . ' · 대행소: ' . ($agencyLabel ?? '') . ' · 구분: ' . ($catLabelFilter ?? ''))) ?></p>
|
||||
<p class="text-xs text-gray-500 m-0">집계: <?= $byDaily ? '일자별' : '기간별' ?> · (단위: 매 / 원)</p>
|
||||
</div>
|
||||
|
||||
<div class="border border-gray-300 overflow-auto">
|
||||
<table class="w-full data-table text-sm" id="period-sales-table">
|
||||
<thead>
|
||||
<tr>
|
||||
<?php if ($byDaily): ?>
|
||||
<th rowspan="2" class="align-middle whitespace-nowrap">일자</th>
|
||||
<?php endif; ?>
|
||||
<th rowspan="2" class="align-middle text-left pl-2">품목</th>
|
||||
<th colspan="4" class="text-center border-l border-gray-300">판매</th>
|
||||
<th colspan="2" class="text-center border-l border-gray-300">반품</th>
|
||||
<th colspan="4" class="text-center border-l border-gray-300">계</th>
|
||||
</tr>
|
||||
<tr>
|
||||
<th class="text-right border-l border-gray-300">수량</th>
|
||||
<th class="text-right">판매금액</th>
|
||||
<th class="text-right">수수료</th>
|
||||
<th class="text-right">징수액</th>
|
||||
<th class="text-right border-l border-gray-300">수량</th>
|
||||
<th class="text-right">금액</th>
|
||||
<th class="text-right border-l border-gray-300">수량</th>
|
||||
<th class="text-right">판매금액</th>
|
||||
<th class="text-right">수수료</th>
|
||||
<th class="text-right">징수액</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody class="text-right">
|
||||
<?php
|
||||
$emptyColspan = $byDaily ? 12 : 11;
|
||||
?>
|
||||
<?php foreach ($lines ?? [] as $ln): ?>
|
||||
<?php
|
||||
$kind = (string) ($ln['kind'] ?? 'data');
|
||||
$trCls = $rowClass($kind);
|
||||
$isData = $kind === 'data';
|
||||
$rs = (int) ($ln['ymd_rowspan'] ?? 0);
|
||||
?>
|
||||
<tr class="<?= esc($trCls, 'attr') ?>">
|
||||
<?php if ($byDaily): ?>
|
||||
<?php if ($isData && $rs > 0): ?>
|
||||
<td rowspan="<?= $rs ?>" class="text-center align-top whitespace-nowrap tabular-nums pt-1"><?= esc((string) ($ln['ymd'] ?? '')) ?></td>
|
||||
<?php elseif (str_starts_with($kind, 'foot_')): ?>
|
||||
<td class="bg-inherit"></td>
|
||||
<?php endif; ?>
|
||||
<?php endif; ?>
|
||||
<td class="text-left pl-2"><?= esc((string) ($ln['name'] ?? '')) ?></td>
|
||||
<td class="border-l border-gray-200 tabular-nums"><?= number_format((int) ($ln['s_qty'] ?? 0)) ?></td>
|
||||
<td class="tabular-nums"><?= number_format((int) round((float) ($ln['s_amt'] ?? 0))) ?></td>
|
||||
<td class="tabular-nums"><?= $fmtFee((float) ($ln['s_fee'] ?? 0)) ?></td>
|
||||
<td class="tabular-nums"><?= number_format((int) round((float) ($ln['s_levy'] ?? 0))) ?></td>
|
||||
<td class="border-l border-gray-200 tabular-nums"><?= number_format((int) ($ln['r_qty'] ?? 0)) ?></td>
|
||||
<td class="tabular-nums"><?= number_format((int) round((float) ($ln['r_amt'] ?? 0))) ?></td>
|
||||
<td class="border-l border-gray-200 tabular-nums"><?= number_format((int) ($ln['t_qty'] ?? 0)) ?></td>
|
||||
<td class="tabular-nums"><?= number_format((int) round((float) ($ln['t_amt'] ?? 0))) ?></td>
|
||||
<td class="tabular-nums"><?= $fmtFee((float) ($ln['t_fee'] ?? 0)) ?></td>
|
||||
<td class="tabular-nums"><?= number_format((int) round((float) ($ln['t_levy'] ?? 0))) ?></td>
|
||||
</tr>
|
||||
<?php endforeach; ?>
|
||||
<?php if (($lines ?? []) === []): ?>
|
||||
<tr>
|
||||
<td colspan="<?= (int) $emptyColspan ?>" class="text-center text-gray-400 py-6">조회된 데이터가 없습니다.</td>
|
||||
</tr>
|
||||
<?php endif; ?>
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
</section>
|
||||
|
||||
Reference in New Issue
Block a user