<?php

use App\Models\Point;

/** @var \App\Models\Client $patient */

$aerobicActivity = Point::getOnlyPointOfCategory($patient, 'AEROBIC_ACTIVITY');
$strengthTraining = Point::getOnlyPointOfCategory($patient, 'STRENGTH_TRAINING');
$neat = Point::getOnlyPointOfCategory($patient, 'NEAT');

$points = [
    ["category" => 'AEROBIC_ACTIVITY', "name" => 'Aerobic Activity', "point" => $aerobicActivity],
    ["category" => 'STRENGTH_TRAINING', "name" => 'Strength Training', "point" => $strengthTraining],
    ["category" => 'NEAT', "name" => 'Non-Exercise Activity Time (NEAT)', "point" => $neat],
];
?>

<?php if(!count($points)): ?>
    <span>-</span>
<?php endif ?>
<table class="table table-bordered table-sm mb-0 table-cage">
<?php foreach ($points as $p): ?>
<?php $point = $p['point']; ?>
<?php if(!!$point): ?>
<?php $review = $point->lastChildReview; ?>
<?php if ($review && @($review->data)) $review->data = json_decode($review->data); ?>
<tr>
    <td class="width-300px">
        <?= $p['name'] ?>
    </td>
    <td class="width-300px">
        <?php if(!!$review): ?>
            <div class="pl-3 inline-html-container">
                <?php $review = $review->data; ?>
                <?php include(resource_path('views/app/patient/segment-templates/_child_review/exercise/' . $p['category'] . '/view-review.php')); ?>
            </div>
        <?php endif; ?>
    </td>
    <td></td>
</tr>
<?php endif; ?>
<?php endforeach; ?>
</table>
