fix:정산관리 필터를 기간 범위 고정 방식으로 변경 (체크박스 제거, 컴팩트 1줄 레이아웃)

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
김보곤
2026-02-20 14:04:21 +09:00
parent 11c685bda7
commit 4d6081beb6
2 changed files with 65 additions and 120 deletions

View File

@@ -32,41 +32,30 @@ public function index(Request $request): View|Response
$initialTab = $request->input('tab', 'commission');
// 수당 정산 탭 데이터 (기본 탭이므로 즉시 로드)
$year = $request->input('year', now()->year);
$month = $request->input('month', now()->month);
$dateRange = $request->boolean('date_range');
// 수당 정산 탭 데이터 (기간 범위 방식)
$year = (int) $request->input('start_year', now()->year);
$month = (int) $request->input('start_month', now()->month);
$endYear = (int) $request->input('end_year', $year);
$endMonth = (int) $request->input('end_month', $month);
$filters = [
'scheduled_start_year' => $year,
'scheduled_start_month' => $month,
'scheduled_end_year' => $endYear,
'scheduled_end_month' => $endMonth,
'start_year' => $year,
'start_month' => $month,
'end_year' => $endYear,
'end_month' => $endMonth,
'status' => $request->input('status'),
'payment_type' => $request->input('payment_type'),
'partner_id' => $request->input('partner_id'),
'commission_type' => $request->input('commission_type'),
'search' => $request->input('search'),
'date_range' => $dateRange,
];
if ($dateRange) {
$filters['scheduled_start_year'] = (int) $request->input('start_year', $year);
$filters['scheduled_start_month'] = (int) $request->input('start_month', $month);
$filters['scheduled_end_year'] = (int) $request->input('end_year', $year);
$filters['scheduled_end_month'] = (int) $request->input('end_month', $month);
$filters['start_year'] = $filters['scheduled_start_year'];
$filters['start_month'] = $filters['scheduled_start_month'];
$filters['end_year'] = $filters['scheduled_end_year'];
$filters['end_month'] = $filters['scheduled_end_month'];
} else {
$filters['scheduled_year'] = $year;
$filters['scheduled_month'] = $month;
}
$commissions = $this->service->getCommissions($filters);
$stats = $dateRange
? $this->service->getSettlementStatsForRange(
$filters['scheduled_start_year'], $filters['scheduled_start_month'],
$filters['scheduled_end_year'], $filters['scheduled_end_month']
)
: $this->service->getSettlementStats($year, $month);
$stats = $this->service->getSettlementStatsForRange($year, $month, $endYear, $endMonth);
$partners = SalesPartner::with('user')
->active()
@@ -96,9 +85,11 @@ public function index(Request $request): View|Response
*/
public function commissionStats(Request $request): View
{
$year = $request->input('year', now()->year);
$month = $request->input('month', now()->month);
$stats = $this->service->getSettlementStats($year, $month);
$year = (int) $request->input('start_year', now()->year);
$month = (int) $request->input('start_month', now()->month);
$endYear = (int) $request->input('end_year', $year);
$endMonth = (int) $request->input('end_month', $month);
$stats = $this->service->getSettlementStatsForRange($year, $month, $endYear, $endMonth);
return view('finance.settlement.partials.commission.stats-cards', compact('stats', 'year', 'month'));
}
@@ -108,29 +99,23 @@ public function commissionStats(Request $request): View
*/
public function commissionTable(Request $request): View
{
$year = $request->input('year', now()->year);
$month = $request->input('month', now()->month);
$dateRange = $request->boolean('date_range');
$year = (int) $request->input('start_year', now()->year);
$month = (int) $request->input('start_month', now()->month);
$endYear = (int) $request->input('end_year', $year);
$endMonth = (int) $request->input('end_month', $month);
$filters = [
'scheduled_start_year' => $year,
'scheduled_start_month' => $month,
'scheduled_end_year' => $endYear,
'scheduled_end_month' => $endMonth,
'status' => $request->input('status'),
'payment_type' => $request->input('payment_type'),
'partner_id' => $request->input('partner_id'),
'commission_type' => $request->input('commission_type'),
'search' => $request->input('search'),
'date_range' => $dateRange,
];
if ($dateRange) {
$filters['scheduled_start_year'] = (int) $request->input('start_year', $year);
$filters['scheduled_start_month'] = (int) $request->input('start_month', $month);
$filters['scheduled_end_year'] = (int) $request->input('end_year', $year);
$filters['scheduled_end_month'] = (int) $request->input('end_month', $month);
} else {
$filters['scheduled_year'] = $year;
$filters['scheduled_month'] = $month;
}
$commissions = $this->service->getCommissions($filters);
return view('finance.settlement.partials.commission.table', compact('commissions'));

View File

@@ -1,69 +1,41 @@
{{-- 수당 정산 필터 --}}
<div class="bg-white rounded-lg shadow-sm p-4 mb-6">
<div class="bg-white rounded-lg shadow-sm px-4 py-3 mb-4">
<form id="filter-form" method="GET" action="{{ route('finance.settlement') }}">
<input type="hidden" name="tab" value="commission">
<div class="flex flex-wrap items-end gap-3">
{{-- 기간설정 체크박스 --}}
<div class="flex items-center self-end pb-2">
<label class="flex items-center gap-1.5 cursor-pointer select-none">
<input type="checkbox" name="date_range" value="1"
{{ !empty($filters['date_range']) ? 'checked' : '' }}
onchange="toggleDateRange(this.checked)"
class="rounded border-gray-300 text-emerald-600 focus:ring-emerald-500">
<span class="text-xs font-medium text-gray-600 whitespace-nowrap">기간설정</span>
</label>
</div>
{{-- 단일 / (기본) --}}
<div id="single-date" class="{{ !empty($filters['date_range']) ? 'hidden' : '' }} flex items-end gap-3">
<div class="w-[100px]">
<label class="block text-xs font-medium text-gray-500 mb-1">년도</label>
<select name="year" class="w-full rounded-lg border-gray-300 text-sm focus:border-emerald-500 focus:ring-emerald-500">
@for ($y = now()->year - 2; $y <= now()->year + 1; $y++)
<option value="{{ $y }}" {{ $year == $y ? 'selected' : '' }}>{{ $y }}</option>
@endfor
</select>
</div>
<div class="w-[80px]">
<label class="block text-xs font-medium text-gray-500 mb-1"></label>
<select name="month" class="w-full rounded-lg border-gray-300 text-sm focus:border-emerald-500 focus:ring-emerald-500">
@for ($m = 1; $m <= 12; $m++)
<option value="{{ $m }}" {{ $month == $m ? 'selected' : '' }}>{{ $m }}</option>
@endfor
</select>
</div>
</div>
{{-- 기간 범위 (체크 표시) --}}
<div id="range-date" class="{{ !empty($filters['date_range']) ? '' : 'hidden' }} flex items-end gap-2">
<div class="w-[100px]">
<label class="block text-xs font-medium text-gray-500 mb-1">시작 년도</label>
<select name="start_year" class="w-full rounded-lg border-gray-300 text-sm focus:border-emerald-500 focus:ring-emerald-500">
<div class="flex flex-wrap items-end gap-x-4 gap-y-2">
{{-- 시작 기간 --}}
<div class="flex items-end gap-1.5">
<div>
<label class="block text-[11px] text-gray-400 mb-0.5">시작</label>
<select name="start_year" class="h-8 rounded border-gray-300 text-sm pl-2 pr-7 focus:border-emerald-500 focus:ring-emerald-500">
@for ($y = now()->year - 2; $y <= now()->year + 1; $y++)
<option value="{{ $y }}" {{ ($filters['start_year'] ?? $year) == $y ? 'selected' : '' }}>{{ $y }}</option>
@endfor
</select>
</div>
<div class="w-[70px]">
<label class="block text-xs font-medium text-gray-500 mb-1">시작 </label>
<select name="start_month" class="w-full rounded-lg border-gray-300 text-sm focus:border-emerald-500 focus:ring-emerald-500">
<div>
<select name="start_month" class="h-8 rounded border-gray-300 text-sm pl-2 pr-7 focus:border-emerald-500 focus:ring-emerald-500">
@for ($m = 1; $m <= 12; $m++)
<option value="{{ $m }}" {{ ($filters['start_month'] ?? $month) == $m ? 'selected' : '' }}>{{ $m }}</option>
@endfor
</select>
</div>
<span class="text-gray-400 pb-2">~</span>
<div class="w-[100px]">
<label class="block text-xs font-medium text-gray-500 mb-1"> 년도</label>
<select name="end_year" class="w-full rounded-lg border-gray-300 text-sm focus:border-emerald-500 focus:ring-emerald-500">
</div>
<span class="text-gray-300 pb-1 text-sm">~</span>
{{-- 종료 기간 --}}
<div class="flex items-end gap-1.5">
<div>
<label class="block text-[11px] text-gray-400 mb-0.5">종료</label>
<select name="end_year" class="h-8 rounded border-gray-300 text-sm pl-2 pr-7 focus:border-emerald-500 focus:ring-emerald-500">
@for ($y = now()->year - 2; $y <= now()->year + 1; $y++)
<option value="{{ $y }}" {{ ($filters['end_year'] ?? $year) == $y ? 'selected' : '' }}>{{ $y }}</option>
@endfor
</select>
</div>
<div class="w-[70px]">
<label class="block text-xs font-medium text-gray-500 mb-1"> </label>
<select name="end_month" class="w-full rounded-lg border-gray-300 text-sm focus:border-emerald-500 focus:ring-emerald-500">
<div>
<select name="end_month" class="h-8 rounded border-gray-300 text-sm pl-2 pr-7 focus:border-emerald-500 focus:ring-emerald-500">
@for ($m = 1; $m <= 12; $m++)
<option value="{{ $m }}" {{ ($filters['end_month'] ?? $month) == $m ? 'selected' : '' }}>{{ $m }}</option>
@endfor
@@ -71,9 +43,12 @@ class="rounded border-gray-300 text-emerald-600 focus:ring-emerald-500">
</div>
</div>
<div class="w-[calc(50%-6px)] sm:w-auto sm:min-w-[100px]">
<label class="block text-xs font-medium text-gray-500 mb-1">상태</label>
<select name="status" class="w-full rounded-lg border-gray-300 text-sm focus:border-emerald-500 focus:ring-emerald-500">
<div class="w-px h-6 bg-gray-200 self-end mb-1"></div>
{{-- 상태 --}}
<div>
<label class="block text-[11px] text-gray-400 mb-0.5">상태</label>
<select name="status" class="h-8 rounded border-gray-300 text-sm pl-2 pr-7 focus:border-emerald-500 focus:ring-emerald-500">
<option value="">전체</option>
<option value="pending" {{ ($filters['status'] ?? '') == 'pending' ? 'selected' : '' }}>대기</option>
<option value="approved" {{ ($filters['status'] ?? '') == 'approved' ? 'selected' : '' }}>승인</option>
@@ -82,18 +57,20 @@ class="rounded border-gray-300 text-emerald-600 focus:ring-emerald-500">
</select>
</div>
<div class="w-[calc(50%-6px)] sm:w-auto sm:min-w-[100px]">
<label class="block text-xs font-medium text-gray-500 mb-1">입금구분</label>
<select name="payment_type" class="w-full rounded-lg border-gray-300 text-sm focus:border-emerald-500 focus:ring-emerald-500">
{{-- 입금구분 --}}
<div>
<label class="block text-[11px] text-gray-400 mb-0.5">입금구분</label>
<select name="payment_type" class="h-8 rounded border-gray-300 text-sm pl-2 pr-7 focus:border-emerald-500 focus:ring-emerald-500">
<option value="">전체</option>
<option value="deposit" {{ ($filters['payment_type'] ?? '') == 'deposit' ? 'selected' : '' }}>1</option>
<option value="balance" {{ ($filters['payment_type'] ?? '') == 'balance' ? 'selected' : '' }}>2</option>
</select>
</div>
<div class="w-[calc(50%-6px)] sm:w-auto sm:min-w-[120px]">
<label class="block text-xs font-medium text-gray-500 mb-1">영업파트너</label>
<select name="partner_id" class="w-full rounded-lg border-gray-300 text-sm focus:border-emerald-500 focus:ring-emerald-500">
{{-- 영업파트너 --}}
<div>
<label class="block text-[11px] text-gray-400 mb-0.5">파트너</label>
<select name="partner_id" class="h-8 rounded border-gray-300 text-sm pl-2 pr-7 focus:border-emerald-500 focus:ring-emerald-500">
<option value="">전체</option>
@foreach ($partners as $partner)
<option value="{{ $partner->id }}" {{ ($filters['partner_id'] ?? '') == $partner->id ? 'selected' : '' }}>
@@ -103,34 +80,17 @@ class="rounded border-gray-300 text-emerald-600 focus:ring-emerald-500">
</select>
</div>
<div class="flex items-end gap-1 w-full sm:w-auto">
{{-- 조회 / 초기화 --}}
<div class="flex items-end gap-1 ml-auto">
<button type="submit"
class="flex-1 sm:flex-none px-4 py-2 bg-emerald-600 hover:bg-emerald-700 text-white text-sm rounded-lg transition-colors">
class="h-8 px-5 bg-emerald-600 hover:bg-emerald-700 text-white text-sm rounded transition-colors">
조회
</button>
<a href="{{ route('finance.settlement') }}"
class="px-3 py-2 bg-gray-200 hover:bg-gray-300 text-gray-700 text-sm rounded-lg transition-colors">
class="h-8 px-3 inline-flex items-center bg-gray-100 hover:bg-gray-200 text-gray-600 text-sm rounded transition-colors">
초기화
</a>
</div>
</div>
</form>
</div>
<script>
function toggleDateRange(checked) {
document.getElementById('single-date').classList.toggle('hidden', checked);
document.getElementById('range-date').classList.toggle('hidden', !checked);
// 단일 모드 select 비활성화 (폼 전송 시 제외)
document.querySelectorAll('#single-date select').forEach(s => s.disabled = checked);
document.querySelectorAll('#range-date select').forEach(s => s.disabled = !checked);
}
// 초기 상태 설정
document.addEventListener('DOMContentLoaded', function() {
const checked = document.querySelector('input[name="date_range"]')?.checked || false;
document.querySelectorAll('#single-date select').forEach(s => s.disabled = checked);
document.querySelectorAll('#range-date select').forEach(s => s.disabled = !checked);
});
</script>