<h2 class="text-center form-header"><?php echo $period; ?></h2>
<table>
<thead>
<tr><td colspan="2"><i class="fa fa-arrow-circle-o-left" aria-hidden="true" onclick="date='<?php echo $prev; ?>'; rebuilding();"></i></td><td colspan="3"><h3><?php echo $year; ?></h3></td><td colspan="2"><i class="fa fa-arrow-circle-o-right" aria-hidden="true" onclick="date='<?php echo $next; ?>'; rebuilding();"></i></td></tr>
  <tr class="day">
    <td><?php echo $monday; ?></td>
    <td><?php echo $tuesday; ?></td>
    <td><?php echo $wednesday; ?></td>
    <td><?php echo $thursday; ?></td>
    <td><?php echo $friday; ?></td>
    <td><?php echo $saturday; ?></td>
    <td><?php echo $sunday; ?></td>
  </tr>
</thead>
<tbody>
  <?php foreach ($mes as $row) { ?>
    <tr>
    <?php foreach ($row as $tdata) {
      if(isset($tdata['day'])){
?>
      <td  onclick="chooseDay('<?php echo $tdata['date']."','".$tdata['next_day']; ?>');" class="nice-date
        <?php if($tdata['spots'] < $tdata['quantity']) { echo 'no-spots'; } ?>
        <?php if($tdata['date'] == $today){ echo 'nice-today'; } ?>
        <?php if($tdata['is_start']){ echo 'is-start'; } ?>
        <?php if($tdata['is_end']){ echo 'is-end'; } ?>">
        <div <?php if($tdata['input']){echo "class='select'";}?> >
          <?php echo isset($tdata['day'])? $tdata['day'] : ''; ?>
          <p class="tooltip-calendar"><?php if($tdata['spots'] < $tdata['quantity']) { echo $reserved; } else { echo isset($tdata['price'])? $tdata['price'] : '';}?></p>
          </div>
      </td>
    <?php }else{ ?>
      <td style="background:transparent; cursor: not-allowed;"></td>
    <?php } ?>
    <?php } ?>
    </tr>
    <?php } ?>
</tbody>
</table>