<?php
  $String = '<table class="Monatsansicht" summary="Monatsuebersicht">
              <tr>
                <td class="Monatsname" colspan="7">'.getNameOfMonthFromNumberOfMonth($Month).'</td>
              </tr>
              <tr>
                <th class="Wochentagsname">'.$L_Mo.'</th>
                <th class="Wochentagsname">'.$L_Tu.'</th>
                <th class="Wochentagsname">'.$L_We.'</th>
                <th class="Wochentagsname">'.$L_Th.'</th>
                <th class="Wochentagsname">'.$L_Fr.'</th>
                <th class="Wochentagsname">'.$L_Sa.'</th>
                <th class="Wochentagsname">'.$L_Su.'</th>
              </tr>
            <tr>';
  ob_start();
  $FirstDayOfTheWeek = getWeekdayFromDate(1, $Month, $Year);
  $TimestampOfToday = getTimestampFromDate(date("d"), date("m"), date("y"));
  $Day = 1;
  $Cell = 1;
  $getDaysOfAMonth = getDaysOfAMonth($Month, $Year);

  for ($z=1; $z<=6; $z++)
  {
    for ($s=1; $s<=7; $s++)
    {
      if (($Cell < $FirstDayOfTheWeek) OR ($Day > $getDaysOfAMonth)) {$String .= "<td>\n</td>";}
      else
      {
        $Timestamp = getTimestampFromDate($Day, $Month, $Year);
        $NumberOfGigsAtSameDay = getNumberOfGigsAtSameDay($Timestamp);
        if ($NumberOfGigsAtSameDay>0)
        {
          $GigStatusDesTages = CheckGigStatusDesTages($Timestamp);
          if ($NumberOfGigsAtSameDay==1) $ToolTip = getTooltip($Timestamp);
          $GigID = getGigVarFromGigDate ($Timestamp, 'GigID');
          if ($NumberOfGigsAtSameDay>1) $GigStatusDesTages = 'DoubleDates';
        }
        else
        {
          $GigStatusDesTages = 'Normal';
          $ToolTip = '';
          $GigID = '';
        }
        $String .= '<td';
        $String .= ' class="'.$GigStatusDesTages.'"';
        if ( $GigStatusDesTages!="DoubleDates" )
        {
          $String .= ' title="'.$ToolTip.'"';
        }
        $String .= '>';
        if ($Timestamp == $TimestampOfToday) $String .= '<div class="Today">';
        $String .= '<span class="'.WochentagsNameVonDatum ($Day, $Month, $Year).'">';

        // Wochentags-Zahl mit Link
        if ( $UserIsUser AND $GigStatusDesTages == "Normal")
        {
          $String .= $Day;
        }
        else
        {
          $String .= '<a href="index.php?submenue=calendar&amp;content=';
          if ( $GigStatusDesTages=="DoubleDates" ) { $String .= 'backend_selectGig&amp;timestamp='.$Timestamp.'"'; }
          else
          {
           if ( $UserIsUser ) { $String .= 'backend_showGig'; }
           else
           {
             if ( $GigStatusDesTages == "Normal" ) { $String .= 'backend_addGig&amp;job=add&amp;timestamp='.$Timestamp.''; }
             else $String .= 'backend_addGig&amp;job=edit';
           }
           $String .= '&amp;id='.$GigID.'" title="'.$ToolTip.'"';
          }
          $String .= '>'.$Day.'</a>';
        }

        $String .= "</span>";
        if ($Timestamp == $TimestampOfToday) {$String .= "</div>"; }
        $String .= "</td>\n";
        $Day++;
      }
      if ($s == "7")
      {
        if ($z < "6")
        {
          $String .= "</tr><tr>";
        }
        else
        {
          $String .= "</tr>";
        }
      }
      $Cell++;
    }
  }
  ob_end_flush();
  $String .= "</table>";

?>
