Files
sam-manage/app/Http/Controllers/Finance/FundScheduleController.php
김보곤 92f07a570f fix:자금계획일정 HTMX 부분 로드 시 스크립트 미실행 오류 수정
HX-Redirect 처리 추가로 전체 페이지 리로드하여 @push('scripts') 정상 실행

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-02-05 08:18:05 +09:00

110 lines
3.1 KiB
PHP

<?php
namespace App\Http\Controllers\Finance;
use App\Http\Controllers\Controller;
use App\Models\Finance\BankAccount;
use App\Models\Finance\FundSchedule;
use App\Services\FundScheduleService;
use Illuminate\Contracts\View\View;
use Illuminate\Http\Response;
class FundScheduleController extends Controller
{
public function __construct(
private FundScheduleService $fundScheduleService
) {}
/**
* 자금계획일정 목록 (캘린더 뷰)
*/
public function index(): View|Response
{
if (request()->header('HX-Request')) {
return response('', 200)->header('HX-Redirect', route('finance.fund-schedules.index', request()->only('year', 'month')));
}
// 현재 연월
$year = (int) request('year', now()->year);
$month = (int) request('month', now()->month);
// 월별 일정 데이터
$calendarData = $this->fundScheduleService->getCalendarData($year, $month);
// 월별 요약
$summary = $this->fundScheduleService->getMonthlySummary($year, $month);
// 계좌 목록 (필터용)
$accounts = BankAccount::active()->ordered()->get(['id', 'bank_name', 'account_number']);
return view('finance.fund-schedules.index', compact(
'year',
'month',
'calendarData',
'summary',
'accounts'
));
}
/**
* 자금계획일정 등록 폼
*/
public function create(): View
{
$accounts = BankAccount::active()->ordered()->get(['id', 'bank_name', 'account_number', 'account_name']);
$types = FundSchedule::getTypeOptions();
$statuses = FundSchedule::getStatusOptions();
$recurrenceOptions = FundSchedule::getRecurrenceOptions();
// 기본 날짜 (쿼리스트링에서)
$defaultDate = request('date', now()->toDateString());
return view('finance.fund-schedules.create', compact(
'accounts',
'types',
'statuses',
'recurrenceOptions',
'defaultDate'
));
}
/**
* 자금계획일정 수정 폼
*/
public function edit(int $id): View
{
$schedule = $this->fundScheduleService->getScheduleById($id);
if (! $schedule) {
abort(404, '일정을 찾을 수 없습니다.');
}
$accounts = BankAccount::active()->ordered()->get(['id', 'bank_name', 'account_number', 'account_name']);
$types = FundSchedule::getTypeOptions();
$statuses = FundSchedule::getStatusOptions();
$recurrenceOptions = FundSchedule::getRecurrenceOptions();
return view('finance.fund-schedules.edit', compact(
'schedule',
'accounts',
'types',
'statuses',
'recurrenceOptions'
));
}
/**
* 자금계획일정 상세
*/
public function show(int $id): View
{
$schedule = $this->fundScheduleService->getScheduleById($id);
if (! $schedule) {
abort(404, '일정을 찾을 수 없습니다.');
}
return view('finance.fund-schedules.show', compact('schedule'));
}
}