49 lines
1.5 KiB
PHP
49 lines
1.5 KiB
PHP
|
|
<?php
|
||
|
|
|
||
|
|
namespace App\Http\Controllers\HR;
|
||
|
|
|
||
|
|
use App\Http\Controllers\Controller;
|
||
|
|
use App\Services\HR\BusinessIncomePaymentService;
|
||
|
|
use Illuminate\Contracts\View\View;
|
||
|
|
use Illuminate\Http\Request;
|
||
|
|
use Illuminate\Http\Response;
|
||
|
|
|
||
|
|
class BusinessIncomePaymentController extends Controller
|
||
|
|
{
|
||
|
|
private const ALLOWED_PAYROLL_USERS = ['이경호', '전진선', '김보곤'];
|
||
|
|
|
||
|
|
public function __construct(
|
||
|
|
private BusinessIncomePaymentService $service
|
||
|
|
) {}
|
||
|
|
|
||
|
|
/**
|
||
|
|
* 사업소득자 임금대장 페이지
|
||
|
|
*/
|
||
|
|
public function index(Request $request): View|Response
|
||
|
|
{
|
||
|
|
if ($request->header('HX-Request')) {
|
||
|
|
return response('', 200)->header('HX-Redirect', route('hr.business-income-payments.index'));
|
||
|
|
}
|
||
|
|
|
||
|
|
if (! in_array(auth()->user()->name, self::ALLOWED_PAYROLL_USERS)) {
|
||
|
|
return view('hr.payrolls.restricted');
|
||
|
|
}
|
||
|
|
|
||
|
|
$year = $request->integer('year') ?: now()->year;
|
||
|
|
$month = $request->integer('month') ?: now()->month;
|
||
|
|
|
||
|
|
$earners = $this->service->getActiveEarners();
|
||
|
|
$payments = $this->service->getPayments($year, $month);
|
||
|
|
$paymentsByUser = $payments->keyBy('user_id');
|
||
|
|
$stats = $this->service->getMonthlyStats($year, $month);
|
||
|
|
|
||
|
|
return view('hr.business-income-payments.index', [
|
||
|
|
'earners' => $earners,
|
||
|
|
'paymentsByUser' => $paymentsByUser,
|
||
|
|
'stats' => $stats,
|
||
|
|
'year' => $year,
|
||
|
|
'month' => $month,
|
||
|
|
]);
|
||
|
|
}
|
||
|
|
}
|