Regina Schaukrug: 2. Fortsetzung: Termine

Beitrag lesen

problematische Seite

Aber auch dein Kalender hat der Fehler, der @Rolf B genannt hat, der 31.12.2018 ist in der KW 1 und nicht wie bei dir und mir in KW 53

Korrigiert. Tests:

Also, das Gestalten der Tabelle und das Einfügen der Termine, verschiedene Ansichten wie Tages oder Wochenansicht überlasse ich jetzt mal Dir, weil ich Deine Datenbasis nicht kenne.

<?php

class MonthCalendar
{
    public $locale             = ''; # show https://msdn.microsoft.com/en-us/library/39cwe7zf(v=vs.90).aspx
                                     # show https://msdn.microsoft.com/en-us/library/cdax410z(v=vs.90).aspx
                                     # Linux: show results from `locale -a`
                                     # Linux: show /etc/locale.gen, edit and use `sudo locale-gen`
                                          
    public $maxDayNamesLength  = 2;      # 1 | 2 | 3 | 99   
    
    public $datum              = false;
    public $htmlCalendarId     = 'Calendar';
    public $htmlCalendarClass  = 'Calendar';
    public $htmlThisDayId      = 'ThisDay';
    public $htmlHolidayClass   = 'Holyday';
    public $htmlPartialHolidayClass   = 'PartialHolyday';
    public $htmlSondayClass    = 'Son';
    public $htmlSaturdayClass  = 'Sat';
    public $yearNextSymbol     = '⇨';
    public $yearBeforeSymbol   = '⇦';
    public $monthNextSymbol    = '→';
    public $monthBeforeSymbol  = '←';
    public $arMonthList;
    public $arWeekdayList;
    public $daysSprintf        = '%02d';
    public $daysLinkSprintf    = 'calendar.php?y=%04d&amp;m=%02d&amp;d=%02d';
    public $outsideDaysShow    = '&nbsp;';
    public $showYear           = true;
    public $showMonth          = true;
    public $showWeekNr         = true;


    public function __construct() {
        $this -> datum  = mktime( 0,0,0, date('n'), 1, date('Y') );
        if ($this -> locale) {
            $this -> setLocale ( $this -> locale );
        }
    }
    
    private function getMonthNames() {
        for ( $i=1; $i<13; $i++ ) {
            $d = mkTime( 0, 0, 0, $i, 1, 1971 );
            $names[$i] = strftime( '%B', $d );
        }
        $names[0] = false;
        return $names;
    }
    
    private function getWeakDayNames() {
        for ( $i = 1; $i < 8; $i++ ) {
            $d = mkTime(0, 0, 0, 1, 3+$i, 1971);
            $names[$i] = mb_substr( strftime( '%A', $d ) , 0, $this -> maxDayNamesLength);
        }
        $names[0] = $names[7];
        return $names;
    }
    
    public function setLocale( $locale ) {
        if (false === setlocale( LC_TIME, $locale ) ) {
            trigger_error("Ungültige Locale-Einstellung: $locale", E_USER_NOTICE);
        }
        $this -> arMonthList = $this -> getMonthNames();
        $this -> arWeekdayList = $this -> getWeakDayNames();        
    }
    
    public function setYear($y) {
        $i = intval($y);
        $t = mktime(1, 1, 1, 12, 31, $y);
        if ( $t && $i == $y ) {
            $m = date('n', $this -> datum );
            $this -> datum = mktime( 0, 0, 0, $m, 1, $y );
            return true;
        } else {
            trigger_error("Ungültiges Jahr: $y" );
            return false;
        }
    }

    public function setMonth($m) {
        $i = intval($m);
        if ($m > 0 && $m <= 12 && $i == $m ) {
            $y = date('y', $this -> datum );
            if ( mktime( 0,0,0, $m, 1, $y ) ) {
                $this -> datum = mktime( 0,0,0, $m, 1, $y );
                return true;
            } else {
                trigger_error("UngültigesDatum");
            }
        } else {
            return false;
        }
    }

    public function setYearNext () {
        $y = date( 'Y', $this -> datum ) + 1;
        $m = date( 'n', $this -> datum );
        if ( mktime( 0,0,0, $m, 1, $y ) ) {
            $this -> datum = mktime( 0,0,0, $m, 1, $y );
            return true;
        } else {
            trigger_error("Ungültiges Jahr: " . $y );
            return false;
        }
    }

    public function setYearBefore () {
        $y = date( 'Y', $this -> datum ) - 1;
        $m = date( 'n', $this -> datum );
        if ( mktime( 0,0,0, $m, 1, $y ) ) {
            $this -> datum = mktime( 0,0,0, $m, 1, $y );
            return true;
        } else {
            trigger_error("Ungültiges Jahr: " . $y );
            return false;
        }
    }

    public function setMonthNext () {
        $y = date( 'Y', $this -> datum );
        $m = date( 'n', $this -> datum ) + 1;
        if  ( mktime( 0,0,0, $m, 1, $y ) ) {
            $this -> datum = mktime( 0,0,0, $m, 1, $y );
            return true;
        } else {
            trigger_error("UngültigesDatum");
            return false;
        }
    }

    public function setMonthBefore () {
        $y = date( 'Y', $this -> datum );
        $m = date( 'n', $this -> datum ) - 1;
        if  ( mktime( 0,0,0, $m, 1, $y ) ) {
            $this -> datum = mktime( 0,0                ,0, $m, 1, $y );
            return true;
        } else {
            trigger_error("UngültigesDatum");
            return false;
        }
    }

    public function getCalendar() {

        if ( $this -> htmlCalendarId ) {
            $htmlCalendarId = ' id="' . $this -> htmlCalendarId .'"';
        }
        if ( $this -> htmlCalendarClass ) {
            $htmlCalendarClass=' class="' . $this -> htmlCalendarClass .'"';
        }
        if ( $this -> showWeekNr ) {
            $headerCols=8;
        } else {
            $headerCols=6;
        }

        $year  = date( 'Y', $this -> datum );
        $month = date( 'n', $this -> datum );

        $out = '
            <table' . $htmlCalendarId . $htmlCalendarClass . '>
                <thead>';

        if ( $this -> showYear ) {
            $out .= '
                    <tr class="CalendarYearRow">
                        <th>' . $this -> yearBeforeSymbol . '</th>
                        <th colspan=' .  ( $headerCols - 2 )  . '>' . $year . '</th>
                        <th>' . $this -> yearNextSymbol . '</th>
                    </tr>';
        }

        if ( $this -> showMonth ) {
            $out .= '
                    <tr class="CalendarMountRow">
                        <th>' . $this -> monthBeforeSymbol . '</th>
                        <th colspan=' .  ($headerCols - 2)  . '>' . $this  ->  arMonthList[$month] . '</th>
                        <th>' . $this -> monthNextSymbol . '</th>
                    </tr>';
        }

        $out .= '
                    <tr class="CalendarWeekDayRow">';

        if ( $this -> showWeekNr ) {
            $out .= '
                        <th class="weeksColumn"></th>';
        }

        $out .= '
                        <th>' . $this -> arWeekdayList[1] . '</th>
                        <th>' . $this -> arWeekdayList[2] . '</th>
                        <th>' . $this -> arWeekdayList[3] . '</th>
                        <th>' . $this -> arWeekdayList[4] . '</th>
                        <th>' . $this -> arWeekdayList[5] . '</th>
                        <th>' . $this -> arWeekdayList[6] . '</th>
                        <th>' . $this -> arWeekdayList[7] . '</th>
                    </tr>';

        $firstWeekDay    = date( 'N', $this -> datum );
        $WeekNumber      = date( 'W', $this -> datum );
        $lastDayofMounth = date( 't', $this -> datum );

        # Nicht zugehörige Tage:
        $out .= '
                    <tr>';
        if ( $this -> showWeekNr ) {
            $out .= '
                        <th class="weeksColumn">' . sprintf($this -> daysSprintf, $WeekNumber) . '</th>';
        }

        $counter = 0;
        for ($i = 1; $i<$firstWeekDay; $i++) {
        $out .= '
                        <td class="outsideDay">' . $this -> outsideDaysShow . '</td>';
            $counter++;
        }

        # zugehörige Tage:
        for ($i=1; $i <= $lastDayofMounth; $i++) {
            if ( ! $this -> daysLinkSprintf ) {
                $link='';
                $endlink='';
            } else {

                $link = '<a href="' . sprintf ($this -> daysLinkSprintf, date( 'Y', $this -> datum ), date( 'n', $this -> datum ), $i ) . '">';
                $endlink = '</a>';
            }

            if ( 6 == ( $counter + 8 ) % 7 ) {
                $class = 'class="' . $this -> htmlSaturdayClass .'" ';
            } else if ( 0 == ( $counter + 8 ) % 7 ) {
                $class = 'class="' . $this -> htmlSondayClass .'" ';
            } else if ( date('Y') == $year && date('n') == $month && date('j') == $i  ) {
                $class = 'class="today" ';
            } else {
                $class = '';
            }

            $out .= '
                        <td ' . $class . 'data-Datum="' . sprintf( '%04d-%02d-%02d', date( 'Y', $this->datum ), date( 'm', $this->datum ), $i ) .   '">' . $link . sprintf( $this -> daysSprintf, $i ) . $endlink . '</td>';
            $counter++;
            if ($i < $lastDayofMounth && 0 == ( $counter ) % 7 ) {
                $out .= '
                    </tr>
                    <tr>';

                if ( $this -> showWeekNr ) {
					$WeekNumber = date('W', strtotime(date( 'Y-m-', $this->datum ) . ( $i + 1 ) ) );
					$out .= '
                        <th class="weeksColumn" title="' . ( $i + 1 ) . '">' . sprintf($this -> daysSprintf, $WeekNumber) . '</th>';                    
                }

            }
        }
        # Nicht zugehörige Tage:
            while (0 != $counter % 7) {
                    $out .= '
                        <td class="outsideDay">' . $this -> outsideDaysShow . '</td>';
                    $counter++;
            }
        $out .= '
                    </tr>
                </tbody>
            </table>
';
        return $out;
    }

    public function printCalendar() {
        echo $this -> getCalendar(), "\n";
    }
}
0 117

KW als Spalte einfügen

Barksalot
  • php
  1. 1
    Regina Schaukrug
    1. 0
      Barksalot
      1. 0
        Regina Schaukrug
        1. 0
          Barksalot
          1. 1
            Regina Schaukrug
            1. 0
              Barksalot
              1. 1
                Regina Schaukrug
                1. 0
                  Barksalot
              2. 0
                Rolf B
                • php
                • programmiertechnik
                1. 0
                  Barksalot
                  1. 0
                    Rolf B
                    1. 0
                      beatovich
                2. 0
                  Barksalot
                  1. 0
                    Rolf B
                    1. 0
                      Barksalot
                      1. 0
                        Rolf B
                      2. 1
                        Rolf B
                        1. 0
                          Barksalot
                      3. 0

                        Hier mal meine Vorgehensweise

                        Regina Schaukrug
                        1. 0

                          (Fortsetzung)

                          Regina Schaukrug
                        2. 0

                          2. Fortsetzung: Termine

                          Regina Schaukrug
                          1. 0
                            Barksalot
                            1. 0
                              Regina Schaukrug
                              1. 0
                                Barksalot
                                1. 0
                                  Regina Schaukrug
                                  1. 0
                                    Barksalot
                                    1. 0
                                      Regina Schaukrug
                                      1. 0
                                        Barksalot
                                        1. 0
                                          Regina Schaukrug
                                    2. 0
                                      Rolf B
                              2. 0
                                beatovich
                                1. 0
                                  Regina Schaukrug
                                  1. 0
                                    beatovich
                              3. 0
                                Regina Schaukrug
                              4. 0
                                Rolf B
                  2. 2
                    Rolf B
                  3. 2
                    Rolf B
                    1. 0
                      MudGuard
                      1. 0
                        Rolf B
                        1. 0
                          dedlfix
                      2. 0
                        Regina Schaukrug
                    2. 0
                      Barksalot
                      1. 0
                        Regina Schaukrug
                        1. 0
                          Barksalot
                          1. 0
                            Regina Schaukrug
                            1. 0
                              Barksalot
                      2. 0
                        Rolf B
                        1. 0
                          Barksalot
                          1. 0
                            Rolf B
                            1. 0
                              Barksalot
                              1. 0
                                Regina Schaukrug
                                1. 0
                                  Barksalot
                                  1. 0
                                    Regina Schaukrug
                                    1. 0
                                      Barksalot
                                      1. 0
                                        Regina Schaukrug
                                        1. 0
                                          Barksalot
                                          1. 0
                                            Regina Schaukrug
                                            1. 0
                                              Barksalot
                                              1. 0
                                                Regina Schaukrug
                                                1. 0
                                                  Barksalot
                                                  1. 0
                                                    Regina Schaukrug
                                                    1. 0
                                                      Barksalot
                                                      1. 0
                                                        Regina Schaukrug
                                                        1. 0
                                                          Barksalot
                                                          1. 0
                                                            Regina Schaukrug
                                                            1. 0
                                                              Barksalot
                                                              1. 0

                                                                Anmerkung zu $mysqli: KW als Spalte einfügen

                                                                Barksalot
                                                                1. 0
                                                                  Regina Schaukrug
                                                                  1. 0
                                                                    Barksalot
                                                                    1. 0
                                                                      Regina Schaukrug
                                                                      1. 0
                                                                        Barksalot
                                                                        1. 0
                                                                          Rolf B
                                                                        2. 0
                                                                          Regina Schaukrug
                                                                          1. 0
                                                                            Barksalot
                                                                            1. 0
                                                                              Regina Schaukrug
                                                                              1. 0
                                                                                Barksalot
                                                                                1. 0
                                                                                  Regina Schaukrug
                                                                                  1. 0
                                                                                    Barksalot
                                                                                2. 0
                                                                                  Barksalot
                                                                                  1. 0
                                                                                    Rolf B
                                                                                    1. 0
                                                                                      Barksalot
                                                                                      1. 1
                                                                                        Regina Schaukrug
                                                                                        1. 0
                                                                                          Barksalot
                                                                                          1. 0
                                                                                            Rolf B
                                                                                      2. 0
                                                                                        Rolf B
                                                                                        1. 0
                                                                                          Barksalot
                                                                                  2. 0
                                                                                    Regina Schaukrug
                                                                                    1. 0
                                                                                      Barksalot
                                                                                      1. 0
                                                                                        Regina Schaukrug
                                                                                        1. 0
                                                                                          Barksalot
                                                                                          1. 0
                                                                                            Regina Schaukrug
                                                                                            1. 0
                                                                                              Barksalot
                                                                                              1. 0
                                                                                                Rolf B
                                                                                              2. 0
                                                                                                Regina Schaukrug
                                                                2. 0
                                                                  Rolf B
                                                                  1. 0
                                                                    Barksalot
                                                                    1. 0
                                                                      Rolf B
                3. 0
                  pl
                  • perl
                  • programmiertechnik
                  1. 0
                    Rolf B
                    1. 0
                      pl
                    2. 0
                      pl
          2. 0

            Einträge anordnen

            Barksalot
            1. 0
              pl
              1. 0
                Barksalot
                1. 0
                  Rolf B
                  1. 0
                    pl
  2. 1

    Danke!

    Barksalot
    1. 1
      Rolf B
      1. 0
        Barksalot
        1. 0
          Rolf B
          1. 0

            Grundsatzdiskussion bind ./. fetch_assoc und prepare ./. mysqli_real_escape_string

            Regina Schaukrug
            1. 0
              Rolf B
              1. 0
                Barksalot
                1. 0
                  Regina Schaukrug
                  1. 0
                    Rolf B
                    1. 0

                      Humor...

                      Regina Schaukrug
                      • menschelei