<?php

use App\Models\Client;
use App\Models\Point;
use App\Models\Note;
use App\Models\Segment;
/** @var Client $patient */
/** @var Note $note */
/** @var Segment $segment */

?>

@if($points && count($points))

    <div class="d-flex border-bottom">
        <span class="mr-2 min-width-110px font-weight-bold">
            Typical Day / Lifestyle
        </span>
        <div class="flex-grow-1">

            <?php

            $point = $points[0];

            if(!@$note) {
                $note = $patient->coreNote;
            }

            $contentData = $parsed = false;

            if ($point->lastChildReview && $point->lastChildReview->data) {
                $point->lastChildReview->data = json_decode($point->lastChildReview->data, true);
                $contentData = $parsed = $point->lastChildReview->data;
            }

            if ($contentData) {
                ?>
                <div class="events-none form-read-mode">
                    <p class="mb-2 font-weight-bold">Typical Day</p>

                    @if(@$contentData["lines"] && count($contentData["lines"]))
                        <table class="table table-sm table-bordered mb-3">
                            <tbody>
                            @foreach(@$contentData["lines"] as $line)
                                <tr>
                                    <td><pre class="m-0">{{$line['S']}}&nbsp;</pre></td>
                                </tr>
                            @endforeach
                            </tbody>
                        </table>
                    @endif

                    <p class="mb-2 font-weight-bold">Daily Aggregates</p>

                    <table class="table table-sm table-bordered mb-2">
                        <thead class="bg-light">
                        <tr>
                            <th class="border-bottom-0 text-secondary width-200px">Subject</th>
                            <th class="border-bottom-0 text-secondary">Current</th>
                            <th class="border-bottom-0 text-secondary w-50">Target</th>
                        </tr>
                        </thead>
                        <tbody>
                        <tr>
                            <td class="pl-1 align-middle bg-light">Est. Daily Calories</td>
                            <td><pre class="m-0">{{@$contentData["estimated_daily_calories"]["S"]}}</pre></td>
                            <td><pre class="m-0">{{@$contentData["estimated_daily_calories"]["P"]}}</pre></td>
                        </tr>
                        <tr>
                            <td class="pl-1 align-middle bg-light">Est. Daily Protein Grams</td>
                            <td><pre class="m-0">{{@$contentData["estimated_daily_protein_grams"]["S"]}}</pre></td>
                            <td><pre class="m-0">{{@$contentData["estimated_daily_protein_grams"]["P"]}}</pre></td>
                        </tr>
                        <tr>
                            <td class="pl-1 align-middle bg-light">Est. Daily Vegetable Servings</td>
                            <td><pre class="m-0">{{@$contentData["estimated_daily_vegetable_servings"]["S"]}}</pre></td>
                            <td><pre class="m-0">{{@$contentData["estimated_daily_vegetable_servings"]["P"]}}</pre></td>
                        </tr>
                        <tr>
                            <td class="pl-1 align-middle bg-light">Est. Daily Hours Of Sleep</td>
                            <td><pre class="m-0">{{@$contentData["estimated_daily_hours_of_sleep"]["S"]}}</pre></td>
                            <td><pre class="m-0">{{@$contentData["estimated_daily_hours_of_sleep"]["P"]}}</pre></td>
                        </tr>
                        </tbody>
                    </table>
                </div>
                <?php
            } else {
                echo '<div class="text-secondary">-</div>';
            }

            ?>

        </div>
    </div>

@endif
