89 lines
		
	
	
		
			3.4 KiB
		
	
	
	
		
			PHP
		
	
	
	
	
	
			
		
		
	
	
			89 lines
		
	
	
		
			3.4 KiB
		
	
	
	
		
			PHP
		
	
	
	
	
	
<?php
 | 
						|
 | 
						|
use Bdp\Modules\Gruppen\Controllers\MainController as GruppenController;
 | 
						|
 | 
						|
function kompass_print_gruppen_overview()
 | 
						|
{
 | 
						|
	global $dbHandler;
 | 
						|
	?>
 | 
						|
 | 
						|
	<form method="post" action="admin.php?page=kompass-groups">
 | 
						|
		<p style="width: 100%; text-align: right">
 | 
						|
			<input type="hidden" name="action" value="searchmember">
 | 
						|
			<input type="text" name="member_name" style="width: 500px;"
 | 
						|
			       placeholder="<?=__('Search member', BDP_LV_PLUGIN_SLUG); ?>" />
 | 
						|
            <input type="submit" class="button" value="<?= __('Search', BDP_LV_PLUGIN_SLUG); ?>" />
 | 
						|
		</p>
 | 
						|
	</form>
 | 
						|
 | 
						|
 | 
						|
	<table class="wp-list-table widefat fixed striped table-view-list" id="myTable">
 | 
						|
		<thead>
 | 
						|
		<tr>
 | 
						|
			<th scope="col" class="manage-column column-name"><?= __('Group Name', BDP_LV_PLUGIN_SLUG); ?></th>
 | 
						|
			<th scope="col" class="manage-column column-name"><?= __('Number Members', 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 ($dbHandler->readFromDb( GruppenController::KOMPASS_STAMMESGRUPPEN_GRUPPEN) as $currentGruppe) {
 | 
						|
            $participantCount = $dbHandler->countSqlRows(GruppenController::KOMPASS_STAMMESGRUPPEN_TEILIS, ['gruppe_id' => $currentGruppe->id]);
 | 
						|
			echo '<tr>';
 | 
						|
			echo '<td>' . $currentGruppe->gruppen_name  .'</td>';
 | 
						|
			echo '<td>' . $participantCount . '</td>';
 | 
						|
			echo '<td> ' . kompass_get_group_actions($currentGruppe->id, $participantCount ) .'</td>';
 | 
						|
			echo '</tr>';
 | 
						|
		}
 | 
						|
		?>
 | 
						|
		</tbody>
 | 
						|
	</table>
 | 
						|
 | 
						|
	<?php
 | 
						|
	echo '<p>';
 | 
						|
	if ( current_user_can( 'send_mails' ) ) {
 | 
						|
		echo '<a class="button" href="' . admin_url('admin.php?page=kompass-groups') . '&action=compose-mail&group-id=0">' .
 | 
						|
		     __( 'Mail to multiple groups', BDP_LV_PLUGIN_SLUG ) . '</a>  ';
 | 
						|
	}
 | 
						|
 | 
						|
	if (current_user_can('create_teilis')) {
 | 
						|
        echo '<a class="button" href="' . admin_url('admin.php?page=kompass-groups') . '&action=new-member">' .
 | 
						|
		     __( 'New Member', BDP_LV_PLUGIN_SLUG ) . '</a>  ';
 | 
						|
	}
 | 
						|
 | 
						|
    if ( current_user_can( 'delete_teilis' ) ) {
 | 
						|
    ?>
 | 
						|
        <a class="button" href="admin.php?page=kompass-groups&action=create_group_form">
 | 
						|
            <?= __('Create Group', BDP_LV_PLUGIN_SLUG); ?></a>
 | 
						|
        <?php
 | 
						|
    }
 | 
						|
	echo '</p>';
 | 
						|
}
 | 
						|
 | 
						|
function kompass_get_group_actions(int $groupId, int $participantCount) : string
 | 
						|
{
 | 
						|
    $elements = [];
 | 
						|
    if ($participantCount > 0) {
 | 
						|
        $elements[] = '<a href="' . admin_url('admin.php?page=kompass-groups') . '&action=show-members&group-id=' .$groupId .'">' .
 | 
						|
                      __('Show Members', BDP_LV_PLUGIN_SLUG) . '</a>';
 | 
						|
        if (current_user_can('send_mails')) {
 | 
						|
	        $elements[] = '<a href="' . admin_url('admin.php?page=kompass-groups') . '&action=compose-mail&group-id=' .$groupId .'">' .
 | 
						|
	                      __( 'Mail to group', BDP_LV_PLUGIN_SLUG ) . '</a>';
 | 
						|
        }
 | 
						|
    } else {
 | 
						|
	    if (current_user_can('delete_groups')) {
 | 
						|
		    $elements[] = '<a href="' . admin_url('admin.php?page=kompass-groups') . '&action=delete-group&group-id=' .$groupId .'">' .
 | 
						|
                         __('Delete', BDP_LV_PLUGIN_SLUG) . '</a>';
 | 
						|
	    }
 | 
						|
    }
 | 
						|
 | 
						|
    if (current_user_can('edit_groups')) {
 | 
						|
	    $elements[] = '<a href="' . admin_url('admin.php?page=kompass-groups') . '&action=edit-group&group-id=' .$groupId .'">' .
 | 
						|
                         __('Edit', BDP_LV_PLUGIN_SLUG) . '</a>';
 | 
						|
    }
 | 
						|
 | 
						|
    return implode('<br />' , $elements);
 | 
						|
 | 
						|
}
 |