feat: [hr] 근태등록 + 휴가관리 통합 시스템 구현
- Leave 모델 확장: 6개 유형 추가 (출장/재택/외근/조퇴/지각사유서/결근사유서) - LeaveService: 유형별 결재양식 자동 선택, 유형별 Attendance 반영 분기 - ApprovalService: 콜백 3개 결재양식코드로 확장 - AttendanceIntegratedController: 통합 화면 컨트롤러 - 통합 UI: 근태현황/신청결재/연차잔여 3탭 + 신규 신청 드롭다운 - AttendanceRequest 모델/서비스/컨트롤러/뷰 삭제 (Leave로 일원화) - AttendanceService: deductLeaveBalance 제거 (Leave 시스템으로 일원화)
This commit is contained in:
@@ -1,93 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models\HR;
|
||||
|
||||
use App\Models\User;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use Illuminate\Database\Eloquent\Relations\BelongsTo;
|
||||
use Illuminate\Database\Eloquent\SoftDeletes;
|
||||
|
||||
class AttendanceRequest extends Model
|
||||
{
|
||||
use SoftDeletes;
|
||||
|
||||
protected $table = 'attendance_requests';
|
||||
|
||||
protected $fillable = [
|
||||
'tenant_id',
|
||||
'user_id',
|
||||
'request_type',
|
||||
'start_date',
|
||||
'end_date',
|
||||
'reason',
|
||||
'status',
|
||||
'approved_by',
|
||||
'approved_at',
|
||||
'reject_reason',
|
||||
'json_details',
|
||||
];
|
||||
|
||||
protected $casts = [
|
||||
'tenant_id' => 'int',
|
||||
'user_id' => 'int',
|
||||
'approved_by' => 'int',
|
||||
'start_date' => 'date',
|
||||
'end_date' => 'date',
|
||||
'approved_at' => 'datetime',
|
||||
'json_details' => 'array',
|
||||
];
|
||||
|
||||
public const TYPE_MAP = [
|
||||
'vacation' => '휴가',
|
||||
'businessTrip' => '출장',
|
||||
'remote' => '재택',
|
||||
'fieldWork' => '외근',
|
||||
];
|
||||
|
||||
public const STATUS_MAP = [
|
||||
'pending' => '대기',
|
||||
'approved' => '승인',
|
||||
'rejected' => '반려',
|
||||
];
|
||||
|
||||
public const STATUS_COLORS = [
|
||||
'pending' => 'amber',
|
||||
'approved' => 'emerald',
|
||||
'rejected' => 'red',
|
||||
];
|
||||
|
||||
public function user(): BelongsTo
|
||||
{
|
||||
return $this->belongsTo(User::class, 'user_id');
|
||||
}
|
||||
|
||||
public function approver(): BelongsTo
|
||||
{
|
||||
return $this->belongsTo(User::class, 'approved_by');
|
||||
}
|
||||
|
||||
public function getTypeLabelAttribute(): string
|
||||
{
|
||||
return self::TYPE_MAP[$this->request_type] ?? $this->request_type;
|
||||
}
|
||||
|
||||
public function getStatusLabelAttribute(): string
|
||||
{
|
||||
return self::STATUS_MAP[$this->status] ?? $this->status;
|
||||
}
|
||||
|
||||
public function getStatusColorAttribute(): string
|
||||
{
|
||||
return self::STATUS_COLORS[$this->status] ?? 'gray';
|
||||
}
|
||||
|
||||
public function scopeForTenant($query, ?int $tenantId = null)
|
||||
{
|
||||
$tenantId = $tenantId ?? session('selected_tenant_id');
|
||||
if ($tenantId) {
|
||||
return $query->where($this->table.'.tenant_id', $tenantId);
|
||||
}
|
||||
|
||||
return $query;
|
||||
}
|
||||
}
|
||||
@@ -58,6 +58,45 @@ class Leave extends Model
|
||||
'family' => '경조사',
|
||||
'maternity' => '출산',
|
||||
'parental' => '육아',
|
||||
'business_trip' => '출장',
|
||||
'remote' => '재택근무',
|
||||
'field_work' => '외근',
|
||||
'early_leave' => '조퇴',
|
||||
'late_reason' => '지각사유서',
|
||||
'absent_reason' => '결근사유서',
|
||||
];
|
||||
|
||||
// 그룹 상수
|
||||
public const VACATION_TYPES = ['annual', 'half_am', 'half_pm', 'sick', 'family', 'maternity', 'parental'];
|
||||
|
||||
public const ATTENDANCE_REQUEST_TYPES = ['business_trip', 'remote', 'field_work', 'early_leave'];
|
||||
|
||||
public const REASON_REPORT_TYPES = ['late_reason', 'absent_reason'];
|
||||
|
||||
// 유형 → 결재양식코드 매핑
|
||||
public const FORM_CODE_MAP = [
|
||||
'annual' => 'leave', 'half_am' => 'leave', 'half_pm' => 'leave',
|
||||
'sick' => 'leave', 'family' => 'leave', 'maternity' => 'leave', 'parental' => 'leave',
|
||||
'business_trip' => 'attendance_request', 'remote' => 'attendance_request',
|
||||
'field_work' => 'attendance_request', 'early_leave' => 'attendance_request',
|
||||
'late_reason' => 'reason_report', 'absent_reason' => 'reason_report',
|
||||
];
|
||||
|
||||
// 유형 → 근태상태 매핑 (승인 시 Attendance에 반영할 상태)
|
||||
public const ATTENDANCE_STATUS_MAP = [
|
||||
'annual' => 'vacation', 'half_am' => 'vacation', 'half_pm' => 'vacation',
|
||||
'sick' => 'vacation', 'family' => 'vacation', 'maternity' => 'vacation', 'parental' => 'vacation',
|
||||
'business_trip' => 'businessTrip', 'remote' => 'remote', 'field_work' => 'fieldWork',
|
||||
'early_leave' => null,
|
||||
'late_reason' => null,
|
||||
'absent_reason' => null,
|
||||
];
|
||||
|
||||
// 그룹별 라벨
|
||||
public const GROUP_LABELS = [
|
||||
'vacation' => '휴가',
|
||||
'attendance_request' => '근태신청',
|
||||
'reason_report' => '사유서',
|
||||
];
|
||||
|
||||
public const STATUS_MAP = [
|
||||
|
||||
Reference in New Issue
Block a user