<?php
if(!@$sessionKey) {
    $sessionKey = request()->cookie('sessionKey');
}
$point = App\Models\Point::getOrCreateOnlyTopLevelPointOfCategory($note, 'TYPICAL_DAY_LIFESTYLE', $sessionKey, true);
$contentData = [
    "lines" => [
        [
            "S" => '',
            "I" => '',
            "P" => '',
        ]
    ],
    "estimated_daily_calories" => [
        "S" => '',
        "P" => '',
    ],
    "estimated_daily_protein_grams" => [
        "S" => '',
        "P" => '',
    ],
    "estimated_daily_vegetable_servings" => [
        "S" => '',
        "P" => '',
    ],
    "estimated_daily_hours_of_sleep" => [
        "S" => '',
        "P" => '',
    ]
];
if ($point->lastChildReview && $point->lastChildReview->data) {
    $point->lastChildReview->data = json_decode($point->lastChildReview->data, true);
    $contentData = $point->lastChildReview->data;
}
?>
<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">
            <thead class="bg-light">
            <tr>
                <th class="border-bottom-0 text-secondary">Subjective</th>
                <th class="border-bottom-0 text-secondary w-50">Impression & Plan</th>
            </tr>
            </thead>
            <tbody>
            @foreach(@$contentData["lines"] as $line)
                <tr>
                    <td><pre class="m-0">{{$line['S']}}&nbsp;</pre></td>
                    <td>
                        <div class="d-flex align-items-baseline">
                            @if(@$line['I'])
                                <b class="mr-2">{{$line['I']}}</b>
                            @endif
                            <pre class="m-0">{{$line['P']}}&nbsp;</pre>
                        </div>
                    </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>
