<?php
include 'renderer.php';

class Members extends Renderer {
    public function __construct(?string $templateName = null) {
        parent::__construct($templateName);
        $members = $this->getMemberList();
        $tableBody = '<tbody>';
        foreach ($members as $row) {
            $tableBody .= '<tr>'
                    . '<td>' . $row['id'] . '</td>'
                    . '<td>' . $row['last_name'] . ', ' . $row['first_name'] . '</td>'
                    . '<td>' . $row['email'] . '</td>'
                    . '<td>' . $row['last_payment'] . '</td>'
                    . '<td>' . $row['membership_start'] . '</td>'
                    . '<td>' . $row['status_text'] . '</td>'
                    . '<td><a href="editmember?id=' . $row['id'] . '">Bearbeiten</a>&nbsp;'
                    . '<a href="payings?id=' . $row['id'] . '">Zahlungen</a></td>' 
                    . '</tr>';
        }
        $tableBody .= '</tbody>';
        $this->content['memberlist'] = $tableBody;
    }
}
