<?php
function kompass_print_gruppen_members(array $memberList)
{
	?>
	<p style="width: 100%; text-align: right">
		<input type="text" id="searchInput"
		       onkeyup="searchTable('myTable', this)"
		       placeholder="<?=__('Filter member', BDP_LV_PLUGIN_SLUG); ?>">
	</p>
	<table class="wp-list-table widefat fixed striped table-view-list" id="myTable">
		<thead>
			<tr>
				<th scope="col" class="manage-column column-name"><?= __('Name', BDP_LV_PLUGIN_SLUG); ?></th>
				<th style="width: 100px;" class="manage-column column-name"><?= __('Actions', BDP_LV_PLUGIN_SLUG); ?></th>
			</tr>
		</thead>

		<tbody>
			<?php
			foreach ($memberList as $curMember) {
				?>
				<tr>
				<td> <?=  $curMember->vorname . ' ' . $curMember->nachname ?>
					<br />
					<?php kompass_gruppen_printTelephonNumbers($curMember); ?>
					<br />
				    <?= __('Allergies:', BDP_LV_PLUGIN_SLUG) . ' ' .
				        ($curMember->allergien != '' ? $curMember->allergien : '---'); ?>

				</td>
				<td>
                    <a href= <?= admin_url('admin.php?page=kompass-groups') . '&action=show-member&member-id=' .$curMember->id; ?>">
				        <?= __('Show details', BDP_LV_PLUGIN_SLUG); ?></a>
					<br />

					<a href="admin.php?page=bdp-kompass-limit-login-attempts&action=removeFromList">
						<?= __('Send E-Mail', BDP_LV_PLUGIN_SLUG); ?></a>
					<br />

					<?php
						if ( current_user_can( 'delete_teilis' ) ) {
						?>
							<a href="admin.php?page=bdp-kompass-limit-login-attempts&action=removeFromList">
								<?= __('Delete', BDP_LV_PLUGIN_SLUG); ?></a>
							<?php
						}
						?>
					</td>
				</tr>
				<?php
			}
			?>
		</tbody>
	</table>
	<?php
}

function kompass_gruppen_printTelephonNumbers(stdClass $curMember)
{
	kompass_print_telephone_link($curMember->telefon_1);
	if ($curMember->telefon_2 != '') {
		echo ' // ';
		kompass_print_telephone_link( $curMember->telefon_2 );
	}
}