示例#1
0
 /**
  * Returns the output code of the table with events that should be visible to user
  * 
  * @param String $eventInfoPage: an identifier for the page with event information
  * @param String $eventActionsPage: a page that processes signing in/out of the event and other user actions
  * @param int $userID
  * @param Array $events
  * @return string
  */
 public static function outputEventListForUser($eventInfoPage, $eventActionsPage, $userID, $events)
 {
     $columns = array('title_long', 'date_time', 'duration_min', 'eventType', 'location', 'max_participants');
     // GW 150129: Für die Anzahl der freien Plätze mußte die Spalte 'max_participants' hinzugefügt werden,
     // weil nur real existierende Spalten geholt werden können. Die Spalte wird später umbenannt in EVENT_FREE_SEATS
     // und die Spalte dann mit dem Ergebnis der Berechnung der freien Plätze gefüllt
     //echo "<pre>";var_dump($events);echo "</pre>";
     $output = "<table id = 'events_list' class='my_classes' style = 'width: 100%;'>";
     $already = false;
     $onetime = false;
     // Header
     foreach (Event::$eventParamsNames as $key => $value) {
         if (in_array($value, $columns)) {
             /*
             if ($value=="eventType") // Erste Zeile schmaler. GW 140923; 
                 $output .= "<th class='thinner'>$key</th>";
             else
                 $output .= "<th>$key</th>";
             */
             if ($value == "eventType") {
                 // 1. Typ // Erste Zeile schmaler. GW 140923;
                 $output .= "<th class='thinner'>" . $key . "</th>";
             } else {
                 if ($value == "title_long") {
                     // 2. Schulungsthema // Zweite Spalte breiter, alle anderen schmaler. GW 141118;
                     $output .= "<th class='title_long'>" . $key . "</th>";
                 } else {
                     if ($value == "duration_min") {
                         // 3. Dauer
                         $output .= "<th class='duration_min'>" . $key . "</th>";
                     } else {
                         if ($value == "max_participants") {
                             $output .= "<th>" . EVENT_FREE_SEATS . "</th>";
                         } else {
                             // 4. Zeit
                             $output .= "<th>" . $key . "</th>";
                         }
                     }
                 }
             }
             // 5. Location und 6. Aktion: nichts!
         }
     }
     $output .= "<th>" . LOCATION . "</th>";
     $output .= "<th>" . EVENT_LIST_ACTION . "</th></tr>";
     // / Header
     // Events
     foreach ($events as $eventRow) {
         /*
         $courseID = getCourseByTopic($eventRow["topicID"]);
         $certificate_date = getCertificateDate($userID, $courseID);
         $output .= "<tr>";
         $output .= "<td>userID: ".$userID."<td>";
         $output .= "<td>topicID: ".$eventRow["topicID"]."<td>";
         $output .= "<td>courseID: ".$courseID."<td>";
         $output .= "<td>certificate_date: ".$certificate_date."<td>";
         $output .= "<td>rep_freq_d: ".$eventRow["repetition_frequency_days"]."</td>";
         $output .= "</tr>";
         */
         //$active = isTopicActive($userID, $eventRow['topicID'], $eventRow['repetition_frequency_days']);
         $courseID = EventDatabaseManager::getCourseByTopic($eventRow['topicID']);
         $certificate_date = EventDatabaseManager::getCertificateDate($userID, $courseID);
         $rep_date = strtotime($certificate_date . " +" . $eventRow['repetition_frequency_days'] . " days");
         //print_r(date('Y.m.d',$rep_date).'...........'.date('Y.m.d').'===');
         if (isset($certificate_date) && time() < $rep_date) {
             if ($already == false) {
                 $alreadyoutput .= "<tr><td colspan='7'><center><strong>Already Done</strong></center></td></tr><tr>";
                 $alreadytrue;
             }
             $eventID = $eventRow['eventID'];
             $show_elearning_link = 0;
             $eventRow['seats_left'] = $eventRow['max_participants'] - $eventRow['booked_participants'];
             foreach ($eventRow as $key => $value) {
                 if ($key == "eventType" && $value == strtolower("eLearning")) {
                     $show_elearning_link = 1;
                 }
                 if (in_array($key, $columns)) {
                     if ($key == 'title_long') {
                         $alreadyoutput .= "<td><a href = '?page_id={$eventInfoPage}&eventID={$eventID}'>{$value}</a></td> \n";
                     } else {
                         if ($key == 'addressID') {
                             $value = $eventRow['address'];
                         } else {
                             if ($key == 'date_time') {
                                 $value = Utils::getTime($value);
                             } else {
                                 if ($key == 'max_participants' && $show_elearning_link == 1) {
                                     $value = "";
                                 } else {
                                     if ($key == 'max_participants' && $show_elearning_link != 1) {
                                         $value = $eventRow['seats_left'];
                                     } else {
                                         if ($key == 'eventType') {
                                             $value = Event::$eventTypes[$value];
                                         }
                                     }
                                 }
                             }
                         }
                         $alreadyoutput .= "<td> {$value} </td> \n";
                     }
                 }
             }
             $participantsStatus = getParticipantsStatus($userID, $eventID);
             if ($show_elearning_link == 1) {
                 // Button "Start"
                 $contentLink = eventDatabaseManager::getContentLink($eventID);
                 $class = "class='sign_in_link'";
                 $action = "<a href = '" . $contentLink . "' {$class}>START</a>";
             } else {
                 $action = View::eventActionOutput($eventActionsPage, $participantsStatus, $eventID);
             }
             $alreadyoutput .= "<td>{$action}</td></tr>";
         } else {
             if ($onetime === false) {
                 $output .= "<tr><td colspan='7'><center><strong>Due Courses</strong></td></tr><tr>";
                 $onetime = true;
             }
             $eventID = $eventRow['eventID'];
             $show_elearning_link = 0;
             $eventRow['seats_left'] = $eventRow['max_participants'] - $eventRow['booked_participants'];
             foreach ($eventRow as $key => $value) {
                 if ($key == "eventType" && $value == strtolower("eLearning")) {
                     $show_elearning_link = 1;
                 }
                 if (in_array($key, $columns)) {
                     if ($key == 'title_long') {
                         $output .= "<td><a href = '?page_id={$eventInfoPage}&eventID={$eventID}'>{$value}</a></td> \n";
                     } else {
                         if ($key == 'addressID') {
                             $value = $eventRow['address'];
                         } else {
                             if ($key == 'date_time') {
                                 $value = Utils::getTime($value);
                             } else {
                                 if ($key == 'max_participants' && $show_elearning_link == 1) {
                                     $value = "";
                                 } else {
                                     if ($key == 'max_participants' && $show_elearning_link != 1) {
                                         $value = $eventRow['seats_left'];
                                     } else {
                                         if ($key == 'eventType') {
                                             $value = Event::$eventTypes[$value];
                                         }
                                     }
                                 }
                             }
                         }
                         $output .= "<td> {$value} </td> \n";
                     }
                 }
                 // GW 140924
             }
             $participantsStatus = getParticipantsStatus($userID, $eventID);
             if ($show_elearning_link == 1) {
                 // Button "Start"
                 $contentLink = eventDatabaseManager::getContentLink($eventID);
                 $class = "class='sign_in_link'";
                 $action = "<a href = '" . $contentLink . "' {$class}>START</a>";
             } else {
                 $action = View::eventActionOutput($eventActionsPage, $participantsStatus, $eventID);
             }
             $output .= "<td>{$action}</td></tr>";
         }
     }
     return $output . $alreadyoutput . "</table>";
 }
示例#2
0
function isTopicActive($userID, $topicID, $repetitionFrequency)
{
    $str = "";
    $str = $userID . "  " . $topicID . "  " . $repetitionFrequency . " -> ";
    $courseID = EventDatabaseManager::getCourseByTopic($topicID);
    $certificate_date = EventDatabaseManager::getCertificateDate($userID, $courseID);
    $rep_date = strtotime($certificate_date . " +" . $repetitionFrequency . " days");
    $rep_date = date("d.m.Y", time());
    $str .= $rep_date . "<br>";
    $str = "";
    if ($certificate_date) {
        return 'done';
    } else {
        if ($repetitionFrequency == 0) {
            // RepFreq = 0 -> keine Wiedervorlage
            $str .= " <span style=\"background: green; color: white;\">0:keine&nbsp;WV</span>";
        } else {
            if (strtotime($certificate_date . " +" . $repetitionFrequency . " days") - strtotime('today') < 0) {
                // vergangen
                $str .= " <span style=\"background: red; color: white;\">V:zu&nbsp;bearb.</span>";
            }
            if (strtotime($certificate_date . " +" . $repetitionFrequency . " days") - strtotime('today') >= 0) {
                // heute oder zukunft
                $str .= " <span style=\"background: green; color: white;\">Z:erledigt</span>";
            }
        }
    }
    return $str;
}