@extends('layouts.admin') @section('title', '宿舍管理') @push('breadcrumb') @endpush @push('styles') @endpush @section('content')
新增宿舍
@csrf
房東代理公司(康德美/信義人力資源),宿舍卡片按此分色
公司付給業主的宿舍月租,會計頁可每月再改
此宿舍每月收取的租金收入,會計頁可每月再改
@forelse ($dormitories as $dorm) @php $workers = $dorm->workers ?? collect(); $maleWorkers = $workers->where('gender', '男')->values(); $femaleWorkers = $workers->where('gender', '女')->values(); $maleCount = $maleWorkers->count(); $femaleCount = $femaleWorkers->count(); $occupied = $workers->count(); $capacity = (int) $dorm->capacity; $available = $capacity - $occupied; $showMale = $dorm->gender_limit !== '女'; $showFemale = $dorm->gender_limit !== '男'; $isMixedOccupancy = $maleCount > 0 && $femaleCount > 0; // 代理公司分色(康德美=藍,信義=綠,未指定=灰)— 以宿舍設定的代理公司為準,與入住工人無關 $companyLabel = $dorm->agency_company ?: '未指定代理公司'; $companyClass = match (true) { str_contains((string) $dorm->agency_company, '康德美') => 'company-kangdemei', str_contains((string) $dorm->agency_company, '信義') => 'company-xinyi', default => 'company-none', }; // 已收租金收據(所有年月,卡片上顯示最新年的統計;popup 內按年查) $paidPeriods = $dorm->rentExpenses ->sortBy([['year', 'desc'], ['month', 'desc']]) ->map(fn ($e) => ['year' => $e->year, 'month' => $e->month, 'amount' => $e->amount, 'note' => $e->note]); $paidThisYear = $paidPeriods->where('year', now()->year); @endphp
{{-- 第一行:左側信息,右側租金和按鈕 --}}
@if($showMale) @endif @if($showFemale) @endif
{{ $dorm->address }}
{{ $companyLabel }} @if($paidThisYear->isNotEmpty()) 今年已收 {{ $paidThisYear->count() }} 個月 @else 收租記錄 @endif
@if($dorm->monthly_rent !== null) 租金: ${{ number_format($dorm->monthly_rent, 2) }} @else 未定 @endif
@if(auth()->user()->isAdmin())
@csrf @method('DELETE')
@endif
{{-- 第二行:左側 Pie Chart + 人數,右側姓名列表 --}}
@if($showMale)
男 {{ $maleCount }}
@endif @if($showFemale)
女 {{ $femaleCount }}
@endif
@if($showMale && $showFemale && $isMixedOccupancy)
@if($occupied === 0)
尚無入住
@else
@foreach($maleWorkers as $worker) @endforeach
@foreach($femaleWorkers as $worker) @endforeach
@endif
@else
@if($occupied === 0)
尚無入住
@else @foreach($workers as $worker) @endforeach @endif
@endif
@empty

目前尚未建立宿舍資料

請從左側表單新增宿舍

@endforelse
@endsection @push('scripts') @endpush @push('styles') @endpush @once @push('scripts') @endpush @endonce