<?
$calendar = $this->calendar;
$prevPath = $this->prevPath;
$nextPath = $this->nextPath;
$dayPath = $this->dayPath;
$eventPath = $this->eventPath;
?>
<table class="table-condensed">
    <thead>
        <tr>
            <th class="prev">
                <a href="<?=$this->uri($prevPath, array('start' => $calendar['prev']['startDay']))?>"><i class="icon-large icon-chevron-left highlight"></i></a>
            </th>
            <th class="switch" colspan="5"><a href="<?=$this->uri($prevPath, array('start' => $calendar['today']['startDay']))?>"><?=$calendar['monthName']?> <?=$calendar['yearName']?></a></th>
            <th class="next">
                <a href="<?=$this->uri($prevPath, array('start' => $calendar['next']['startDay']))?>"><i class="icon-large icon-chevron-right highlight"></i></a>
            </th>
        </tr>
        <tr>
            <?foreach($calendar['weekNames'] as $weekname):?>
            <th class="dow"><?=$weekname?></th>
            <?endforeach;?>
        </tr>
    </thead>
    <tbody>
        <?foreach($calendar['days'] as $week):?>
        <tr>
            <?foreach($week as $day):?>
            <td  title="<?=$day['datedb']?>" class="day <?=$day['isAdd'] ? "old" : ''?> <?=$day['datedb'] < $calendar['today']['datedb'] ? 'passed' : ''?> <?=$day['datedb'] == $calendar['today']['datedb'] ? 'today' : ''?> <?=isset($day['Events']) ? 'has-event' : ''?>">
                <?if(isset($day['Events'])):?>
                    <?if(count($day['Events']) <= 1):?>
                    <a href="<?=$this->uri('/event/' . $day['Events'][0]['urlName'])?>"><?=$day['day']?></a>
                    <?else:?>
                    <a href="<?=$this->uri('/events/list/?afterStartDay=' . $day['datedb'] . '&beforeStartDay=' . $day['datedb'])?>"><?=$day['day']?></a>
                    <?endif?>
                <?else:?>
                    <?if($day['datedb'] == $calendar['today']['datedb']):?>
                        <span class="today"><?=$day['day']?></span>
                    <?else:?>
                        <?=$day['day']?>
                    <?endif?>
                <?endif?>
            </td>
            <?endforeach;?>
        </tr>
        <?endforeach;?>
    </tbody>
</table>
