<div class="section">
    <div class="row">
        <div class="small-6 columns">
            <h2><i class="fa fa-file"></i> Month Totals <small><?php echo $this->date ?></small></h2>
        </div>
        <div class="small-6 columns text-right">
            <ul class="button-group round">
                <li><a class="button small secondary" href="
                    <?php
                        switch ($this->month)
                        {
                            case 01:
                                echo $this->link(array('reports','payroll',$this->previousYear, $this->previousMonth));
                                break;
                            default:
                                echo $this->link(array('reports','payroll',$this->year, $this->previousMonth));
                        }
                    ?>
                    "><i class="fa fa-caret-left"></i> Previous</a></li>
                <li><a class="button small secondary" href="
                    <?php
                        switch ($this->month)
                        {
                            case 12:
                                echo $this->link(array('reports','payroll',$this->nextYear, $this->nextMonth));
                                break;
                            default:
                                echo $this->link(array('reports','payroll',$this->year, $this->nextMonth));
                        }
                    ?>
                    ">Next <i class="fa fa-caret-right"></i></a></li>
                <li><a class="button small" target="_blank" href="<?php echo $this->link(array('reports','payrollprint',$this->year,$this->month)) ?>"><i class='fa fa-print'></i> Print</a></li>
            </ul>
        </div>
    </div>
    <div class="row">
        <div class="small-12 columns">
            <style>
                table {
                    border:1px solid #ccc;
                }

                th {
                    border:1px solid #ccc;
                    padding:0px;
                    margin:0px;
                    background-color: #eaeaea;
                }

                td {
                    border:1px solid #ccc;
                    padding:0px;
                    margin:0px;
                }

                .scroll {
                    overflow-x:scroll;
                    overflow-y:visible;
                }

            </style>
            <div class="">
                <table>
                    <thead>
                    <tr>
                       <th style="width:150px;"></th>
                       <?php
                           foreach($this->codes as $codeKey=>$codeName)
                           {
                                echo "<th>$codeName</th>";
                           }
                       ?>
                       <th>Total</th>
                    </tr>
                    </thead>
                    <tbody>

                    <?php
                    $grandTotal = 0;
                    foreach($this->report as $account)
                    {
                        echo "<tr>";
                        echo "<td style='border-bottom:1px solid #ccc;'><b>".$account['userInfo']['lastName'].", ".$account['userInfo']['firstName']."</b></td>";

                        foreach($account['totals'] as $totals)
                        {
                            echo "<td class='text-center' style='border-bottom:1px solid #ccc;'>";
                            if($totals == 0)
                            {
                                echo " - ";
                            }
                            else
                            {
                                echo $totals;
                            }

                            echo "</td>";
                        }


                        $accountTotal = 0;
                        foreach($account['totals'] as $key => $value)
                        {
                            $accountTotal = $accountTotal + $value;
                            $grandTotal = $grandTotal + $value;
                        }

                        echo "<td class='text-center'><b>$accountTotal</b></td>";
                        echo "</tr>";
                    }
                    $codeCount = count($account['totals'])+2;
                    echo "
                        <tr>
                            <td class='text-center' colspan=\"$codeCount\"><b>Total Pay Period Hours:</b> $grandTotal </td>
                        </tr>
                    ";

                    ?>
                    </tbody>
                </table>
            </div>
        </div>
    </div>
</div>
<div id="yearForm" class="reveal-modal small" data-reveal aria-labelledby="Change Year" aria-hidden="true" role="dialog">
    <h2 id="modalTitle">Select a Year</h2>
    <?php echo $this->yearForm ?>
    <a class="close-reveal-modal" aria-label="Close">&#215;</a>
</div>