diff --git a/homepage/participo/attendance.php b/homepage/participo/attendance.php new file mode 100644 index 0000000..def7efb --- /dev/null +++ b/homepage/participo/attendance.php @@ -0,0 +1,213 @@ +id = (int)$id; + $this->userId = (int)$userId; + $this->date = DateTime::createFromFormat("Y-m-d", $date); + } + /** + * create an Attendance from an assoziative array + * + * @param array $member + * @return Attendance + */ + static function constructFromArray($member){ + return new Attendance($member['id'], $member['userId'], $member['date']); + } + /** + * request a users attendances from the database + * + * @param PDO $db + * @param int/string $userId + * @return array with attendances + */ + static function getUsersAttendance($db, $userId){ + $userId = (int)$userId; + $query = "SELECT `id`, `date` FROM `cwsvjudo`.`anwesenheit` WHERE `userId` = :userId"; + $response = dbQuery($db, $query, [':userId'=>['value'=>$userId, 'data_type'=>PDO::PARAM_INT]]); + $attendances = []; + foreach($response as $r){ + $attendances[] = new Attendance($r['id'], $userId, $r['date']); + } + return $attendances; + } + /** + * html table with users attendances + * + * @param PDO $db + * @param string/int $userId + * @return string with html code of the attendance table + */ + static function userAttendanceHtmlTable($db, $userId){ + $htmlTableString = ""; + $htmlTableString .= "
| ".$e['Datum']." | ".$e['Veranstaltung']." |
", - 'imgUrl' => "/ressourcen/graphiken/icons/terminKalender.svg", - 'actions' => [ - AppCardAction::fromArray(['caption'=>"Planer", 'link'=>"/pages/desktop/wkParticipo"]), - ], - ])->htmlCode(). - AppCard::fromArray([ - 'link' => "infoZettel", - 'title' => "Infozettel", - 'description'=> "Online-Variante der Infozettel und Newsletter", - 'imgUrl' => "images/info.svg", - 'actions' => [ - AppCardAction::fromArray(['caption'=>"Info", 'link'=>"infoZettel"]), - ], - ])->htmlCode() -); -?> -