<?php
$month_list = array(
    'January' => 'J',
    'February' => 'F',
    'March' => 'M',
    'April' => 'A',
    'May' => 'M',
    'June' => 'J',
    'July' => 'J',
    'August' => 'A',
    'September' => 'S',
    'October' => 'O',
    'November' => 'N',
    'December' => 'D'
);
//echo debug($contracts);
?>
<table class="contracts">
    <colgroup>
        <col span="1">
        <?php foreach ($years as $year) : ?>
            <col span="12" class="yearCol">
        <?php endforeach; ?>
    </colgroup>
    <tr>
        <th></th>
        <?php foreach ($years as $year) : ?>
            <th colspan="12"><?php echo $year ?></th>
        <?php endforeach; ?>
    </tr>
    <tr>
        <th>Customer</th>
        <?php foreach ($years as $year) : ?>
            <?php foreach ($month_list as $month => $abrev) : ?>
                <th><?php echo $abrev ?></th>
            <?php endforeach; ?>
        <?php endforeach; ?>
    </tr>
    <?php if (!is_null($contracts)) : ?>
        <?php foreach ($contracts as $contract) : ?>
            <tr>
                <td class="customer"><?php echo $contract['Contract']['customerName'] ?></td>
                <?php foreach ($years as $year) : ?>
                    <?php if (isset($contract['Rate'][$year])) : ?>
                        <?php foreach ($month_list as $month => $abrev) : ?>
                            <?php $active = ($contract['Rate'][$year][$month] !== '0.00' ? TRUE : FALSE) ?>
                            <td class="<?php echo ($active === TRUE ? 'active' : '') ?>"><?php echo ($active === TRUE ? '&nbsp;' : '') ?></td>
                        <?php endforeach; ?>
                    <?php else : ?>
                        <td colspan="12">&nbsp;</td>
                    <?php endif; ?>
                <?php endforeach; ?>
            </tr>
        <?php endforeach; ?>
    <?php endif; ?>
</table>