@extends('layouts.app')
@section('page_title','My Profile')
@section('page_subtitle','Update your personal details, Canadian payroll deposit details and password.')
@section('content')
@php($provinces = config('hr_canada.provinces'))
@php($payrollFrequencies = config('hr_canada.payroll_frequencies'))
<div class="card"><form method="POST" action="{{ route('user.profile.update') }}">@csrf @method('PUT')
    <div class="grid grid-3"><div class="stat"><span class="muted">Role</span><strong>{{ strtoupper($user->role) }}</strong></div><div class="stat"><span class="muted">Department</span><strong>{{ $user->department?->name ?? '-' }}</strong></div><div class="stat"><span class="muted">Designation</span><strong>{{ $user->designation?->name ?? '-' }}</strong></div></div>
    <div class="form-row">
        <div class="field"><label>Name</label><input class="input" name="name" value="{{ $user->name }}" required></div>
        <div class="field"><label>Email</label><input class="input" value="{{ $user->email }}" disabled></div>
        <div class="field"><label>Phone</label><input class="input" name="phone" value="{{ $user->phone }}" placeholder="+1 204 555 0101"></div>
        <div class="field"><label>Gender</label><input class="input" name="gender" value="{{ $user->gender }}"></div>
        <div class="field"><label>Date of Birth</label><input class="input" type="date" name="date_of_birth" value="{{ optional($user->date_of_birth)->format('Y-m-d') }}"></div>
        <div class="field"><label>Emergency Contact</label><input class="input" name="emergency_contact" value="{{ $user->emergency_contact }}"></div>
        <div class="field"><label>Province/Territory</label><select name="province"><option value="">Select</option>@foreach($provinces as $code => $province)<option value="{{ $code }}" @selected($user->province===$code)>{{ $code }} - {{ $province }}</option>@endforeach</select></div>
        <div class="field"><label>Postal Code</label><input class="input" name="postal_code" value="{{ $user->postal_code }}" placeholder="R3C 4T3"></div>
        <div class="field"><label>SIN Last 4 Digits</label><input class="input" name="sin_last4" maxlength="4" value="{{ $user->sin_last4 }}"></div>
        <div class="field"><label>Tax Province/Territory</label><select name="tax_province"><option value="">Select</option>@foreach($provinces as $code => $province)<option value="{{ $code }}" @selected($user->tax_province===$code)>{{ $code }} - {{ $province }}</option>@endforeach</select></div>
        <div class="field"><label>Work Authorization</label><input class="input" name="work_authorization_status" value="{{ $user->work_authorization_status }}"></div>
        <div class="field"><label>Payroll Frequency</label><select name="payroll_frequency">@foreach($payrollFrequencies as $frequency)<option value="{{ $frequency }}" @selected(($user->payroll_frequency ?? 'biweekly')===$frequency)>{{ ucfirst(str_replace('_',' ', $frequency)) }}</option>@endforeach</select></div>
        <div class="field"><label>Bank Name</label><input class="input" name="bank_name" value="{{ $user->bank_name }}"></div>
        <div class="field"><label>Institution Number</label><input class="input" name="bank_institution_number" value="{{ $user->bank_institution_number }}" placeholder="003"></div>
        <div class="field"><label>Transit Number</label><input class="input" name="bank_transit_number" value="{{ $user->bank_transit_number }}" placeholder="00001"></div>
        <div class="field"><label>Account Number</label><input class="input" name="bank_account" value="{{ $user->bank_account }}"></div>
        <div class="field"><label>New Password</label><input class="input" type="password" name="password"></div>
        <div class="field"><label>Confirm New Password</label><input class="input" type="password" name="password_confirmation"></div>
    </div>
    <div class="field"><label>Address</label><input class="input" name="address" value="{{ $user->address }}" placeholder="Street, city, province, Canada"></div>
    <button class="btn">Update Profile</button>
</form></div>
@endsection
