@extends('layouts.portal') @section('title', ($menu->title ?? __('menus.title')) . ' — ' . config('app.name')) @section('page_title', $menu->title ?? $menu->dietType?->name) @section('page_subtitle', $menu->patient?->full_name . ' · ' . $menu->starts_on?->format('Y-m-d') . ' · ' . $menu->duration_days . ' ' . __('common.days')) @section('page_actions') @unless ($menu->isIssued())
@csrf
@endunless {{ __('common.back') }} @endsection @section('content') {{-- Calorie & macro preview — editable after generation. Daily EER (target_calories) and the protein/carbs/fat split can be nudged by the consultant without regenerating the whole meal structure; the split is entered as percentages and must add up to 100%, mirroring the onsite-consultation wizard's macro sliders. Grams shown here and saved to the menu are recomputed from calories × percent (protein/carbs at 4 kcal/g, fat at 9 kcal/g) — same formulas as NutritionCalculator::macros(). --}} @php $proteinPercent = $menu->target_calories > 0 ? round(($menu->protein_g * 4 / $menu->target_calories) * 100) : 25; $carbsPercent = $menu->target_calories > 0 ? round(($menu->carbs_g * 4 / $menu->target_calories) * 100) : 45; $fatPercent = $menu->target_calories > 0 ? round(($menu->fat_g * 9 / $menu->target_calories) * 100) : 30; @endphp

{{ __('patients.nutrition_preview') }}

@error('macro_percent')

{{ $message }}

@enderror {{-- Read-only view --}}

{{ __('patients.target_calories') }}

{{ number_format($menu->target_calories) }}

@foreach ([['protein', $menu->protein_g, $proteinPercent], ['carbs', $menu->carbs_g, $carbsPercent], ['fat', $menu->fat_g, $fatPercent]] as [$label, $value, $pct])

{{ __('patients.' . $label) }}

{{ $value }}{{ __('common.grams') }}

{{ $pct }}%

@endforeach
{{-- Edit form --}}
{{-- Day by day --}}
@foreach ($menu->structure ?? [] as $index => $day) @php $total = $totals[$index] ?? null; @endphp

{{ __('common.day') }} {{ $day['day'] }} {{ $menu->starts_on?->copy()->addDays($day['day'] - 1)->format('D, d M') }}

@if ($total)
{{ number_format($total['calories']) }} {{ __('common.kcal') }} {{ $total['protein_g'] }}{{ __('common.grams') }} {{ __('patients.protein') }} {{ $total['carbs_g'] }}{{ __('common.grams') }} {{ __('patients.carbs') }} {{ $total['fat_g'] }}{{ __('common.grams') }} {{ __('patients.fat') }}
@endif
@foreach ($day['meals'] as $meal)

{{ __('menus.slots.' . $meal['slot']) }}

{{ $meal['target_calories'] }} {{ __('common.kcal') }}
    @forelse ($meal['items'] as $item) @php // Shows both languages when the saved item has them (every // menu generated since bilingual names were added); falls // back to whichever single name an older/manually-edited // item happens to carry. $itemName = collect([$item['name_en'] ?? null, $item['name_ar'] ?? null]) ->filter() ->unique() ->implode(' / '); if ($itemName === '') { $itemName = $item['name'] ?? (app()->getLocale() === 'ar' ? ($item['name_ar'] ?? null) : ($item['name_en'] ?? null)); } @endphp
  • {{ $itemName }} {{ $item['protein_g'] }}P · {{ $item['carbs_g'] }}C · {{ $item['fat_g'] }}F
    {{ $item['grams'] }}{{ ($item['unit'] ?? null) === 'ml' ? __('common.ml') : __('common.grams') }}
  • @empty
  • {{ __('common.no_results') }}
  • @endforelse
@endforeach
@endforeach
{{-- Email the full menu (targets, per-day totals, every meal with its component breakdown and a calorie bar) straight to the visitor. --}}

{{ __('menus.email_menu') }}

@csrf
@error('email')

{{ $message }}

@enderror
@can('delete', $menu->patient)
@csrf @method('DELETE')
@endcan @endsection