<style>
  #admin_calendar {
    margin: auto;
  }
  #admin_calendar h2 {
    color: #1785c7;
  }
  #admin_calendar thead {
    border: 1px solid;
  }
  #admin_calendar thead tr {
    background: #f1f1f1;
    font-size: 15px;
    border-top: 1px solid;
  }
  #admin_calendar thead tr:last-child td {
      border-left: 1px solid;
  }
  #admin_calendar thead td {
    min-width: 14%;
    max-width: 88px;
    text-align: center;
    font-weight: bold;
  }
  #admin_calendar thead td i {
    font-size: 22px;
    cursor: pointer;
  }
  #admin_calendar thead td i:hover {
    color: pink;
  }
  #admin_calendar thead tr:first-child td:first-child {
    text-align: right;
  }
  #admin_calendar thead tr:first-child td:last-child {
    text-align: left;
  }
  #admin_calendar div {
    float: left;
    font-size: 25px;
    padding: 0 10px
  }
  #admin_calendar tbody td {
    background: #f1f1f1;
    border: 1px solid #757575;
    text-align: center;
  }
  #admin_calendar tbody td p {
    width: 100%;
    float: left;
  }
  #admin_calendar tbody td:nth-child(1n+6),
  #admin_calendar thead tr:last-child td:nth-child(1n+6) {
    background: #ffe97e;
  }
  .nice-date:hover {
    cursor: pointer;
    background: #51802c!important;
  }
  .nice-date:hover {
    color: #fff;
  }
  td.nice-date.no-spots.nice-today span,
  td.nice-date.no-spots.nice-today p {
      color: rebeccapurple!important;
      font-weight: bold;
  }
  .no-spots {
    border: 1px solid #666666!important;
    background: #f56b6b!important;
      color: #fff;
  }
  .nice-today {
    background: #64ff64!important;
    color: #fff;
  }
  .nice-today:hover {
    background: orange!important;
  }
    .select {
        color:#fff;
    }
  #admin_calendar tbody td.select-td{
    background: #75a74d !important;
    color: #fff;
  }

</style>
<table id="admin_calendar">
<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"><h2><?php echo $year; ?></h2></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>
    <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'] <= 0) { echo 'no-spots'; } ?>
      <?php if($tdata['date'] == $today){ echo 'nice-today'; } ?>
      <?php if($tdata['input']){echo "select-td";}?>
      <?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'] : ''; ?>
          </div><span <?php if($tdata['is_pay']){ echo  "onclick='getDay(".'"'.$tdata['date'].'"'.")'"; } ?> >
          <?php echo isset($tdata['spots'])? $tdata['spots'] : ''; ?>
          </span>
        <p><?php echo isset($tdata['price'])? $tdata['price'] : ''; ?></p>
      <div class="is-start-bg"></div>
      </td>
    <?php }else{ ?>
      <td style="background:grey; cursor: not-allowed;"></td>
    <?php } ?>
    <?php } ?>
    </tr>
    <?php } ?>
</tbody>
</table>
