<?php
include_once './models/services/FrameService.php';
include_once './models/services/ModelService.php';
include_once './models/services/BrandService.php';
include_once './models/services/GeometryService.php';

include_once 'menu.php';

$brandService = new BrandService();
$brands = $brandService->getAllBrands ();
?>
<div id="stackreach">
<?php
foreach ($brands as $brand)
{

    echo '<table border="1"><tr><td colspan="100%">' . $brand->name . '</td></tr>';

    $geometryService = new GeometryService();
    $geometries = $geometryService->getAllGeometriesByBrand ($brand->id);

    foreach ($geometries as $geometry)
    {

        $modelService = new ModelService();
        $models = $modelService->getAllModelsByGeometry ($geometry->id);

        $frameService = new FrameService();
        $frames = $frameService->getAllFramesByGeometry ($geometry->id);
        $cnt = count ($frames);

        echo '<tr><td rowspan="' . $cnt . '">';
        foreach ($models as $model)
        {
            echo "$model->name<br/>";
        }
        echo "</td>";

        foreach ($frames as $frame)
        {
            ?><td><?= $frame->size_name ?>
                </td><td><?= $frame->stack ?>
                </td><td><?= $frame->reach ?>
                </td><td><?= $frame->trail ?>
                </td><td><?= $frame->front_center ?>
                </td><td><?= $frame->head_tube ?>
                </td><td><?= $frame->internal_headset ?>
                </td><td><?= $frame->sta_min ?>
                </td><td><?= $frame->sta_max ?>
                </td><td><?= $frame->is_650 ?>
                </td></tr><tr><?php
        }
        echo "</tr>";
    }
}
?>
    </table>
</div>
