Gruppen können angelegt und bearbeitet werden
Teili können angelegt werden
This commit is contained in:
64
modules/Gruppen/Views/CreateGroupForm.php
Normal file
64
modules/Gruppen/Views/CreateGroupForm.php
Normal file
@ -0,0 +1,64 @@
|
||||
<?php
|
||||
|
||||
use Bdp\Modules\Gruppen\Controllers\MainController as GruppenController;
|
||||
|
||||
function kompass_edit_group_form(int $groupId)
|
||||
{
|
||||
global $dbHandler;
|
||||
$page = BDP_LV_PLUGIN_SLUG . '-create-group';
|
||||
$group = $dbHandler->readFromDb(GruppenController::KOMPASS_STAMMESGRUPPEN_GRUPPEN, ['id' => $groupId]);
|
||||
|
||||
add_settings_section(
|
||||
'custom_settings_section',
|
||||
__('Edit Group', BDP_LV_PLUGIN_SLUG),
|
||||
'kompass_prepare_form',
|
||||
$page,
|
||||
[
|
||||
'action' => 'update-group',
|
||||
'page' => 'kompass-groups',
|
||||
'group_id' => $groupId
|
||||
]
|
||||
);
|
||||
|
||||
_kompass_group_display_elements($page, $group[0]);
|
||||
do_settings_sections(BDP_LV_PLUGIN_SLUG . '-create-group');
|
||||
kompass_close_form(__('Update', BDP_LV_PLUGIN_SLUG));
|
||||
}
|
||||
|
||||
function kompass_create_group_form()
|
||||
{
|
||||
global $dbHandler;
|
||||
$page = BDP_LV_PLUGIN_SLUG . '-create-group';
|
||||
|
||||
add_settings_section(
|
||||
'custom_settings_section',
|
||||
__('Create Group', BDP_LV_PLUGIN_SLUG),
|
||||
'kompass_prepare_form',
|
||||
$page,
|
||||
[
|
||||
'action' => 'create-group',
|
||||
'page' => 'kompass-groups'
|
||||
]
|
||||
);
|
||||
_kompass_group_display_elements($page);
|
||||
|
||||
do_settings_sections(BDP_LV_PLUGIN_SLUG . '-create-group');
|
||||
kompass_close_form(__('Create', BDP_LV_PLUGIN_SLUG));
|
||||
}
|
||||
|
||||
function _kompass_group_display_elements(string $page, stdClass $currentGroup = null)
|
||||
{
|
||||
$value = '';
|
||||
if (null !== $currentGroup) {
|
||||
$value = $currentGroup->gruppen_name;
|
||||
}
|
||||
|
||||
add_settings_field(
|
||||
'kompass_group_field_1',
|
||||
__('Group Name', BDP_LV_PLUGIN_SLUG),
|
||||
'kompass_print_textbox',
|
||||
$page,
|
||||
'custom_settings_section',
|
||||
['setting' => 'kompass_groups_group_name',
|
||||
'value' => $value, 'style' => 'width: 512px']);
|
||||
}
|
131
modules/Gruppen/Views/CreateMemberForm.php
Normal file
131
modules/Gruppen/Views/CreateMemberForm.php
Normal file
@ -0,0 +1,131 @@
|
||||
<?php
|
||||
|
||||
use Bdp\Modules\Gruppen\Controllers\MainController as GruppenController;
|
||||
|
||||
function kompass_edit_group_member_form(int $groupId)
|
||||
{
|
||||
global $dbHandler;
|
||||
$page = BDP_LV_PLUGIN_SLUG . '-create-group';
|
||||
$group = $dbHandler->readFromDb(GruppenController::KOMPASS_STAMMESGRUPPEN_GRUPPEN, ['id' => $groupId]);
|
||||
|
||||
add_settings_section(
|
||||
'custom_settings_section',
|
||||
__('Edit Group', BDP_LV_PLUGIN_SLUG),
|
||||
'kompass_prepare_form',
|
||||
$page,
|
||||
[
|
||||
'action' => 'update-group',
|
||||
'page' => 'kompass-groups',
|
||||
'group_id' => $groupId
|
||||
]
|
||||
);
|
||||
|
||||
_kompass_group_display_elements($page, $group[0]);
|
||||
do_settings_sections(BDP_LV_PLUGIN_SLUG . '-create-group');
|
||||
kompass_close_form(__('Update', BDP_LV_PLUGIN_SLUG));
|
||||
}
|
||||
|
||||
function kompass_create_group_member_form(array $prefilledData = [])
|
||||
{
|
||||
global $dbHandler;
|
||||
$page = BDP_LV_PLUGIN_SLUG . '-create-member';
|
||||
|
||||
add_settings_section(
|
||||
'custom_settings_section',
|
||||
__('Add Member', BDP_LV_PLUGIN_SLUG),
|
||||
'kompass_prepare_form',
|
||||
$page,
|
||||
[
|
||||
'action' => 'create-member',
|
||||
'page' => 'kompass-groups'
|
||||
]
|
||||
);
|
||||
_kompass_group_member_display_elements($page, $prefilledData);
|
||||
|
||||
do_settings_sections($page);
|
||||
kompass_close_form(__('Add member', BDP_LV_PLUGIN_SLUG));
|
||||
}
|
||||
|
||||
function _kompass_group_member_display_elements(string $page, array $prefilledElements = [])
|
||||
{
|
||||
|
||||
$value = $prefilledElements['kompass_group_member_firstname'] ?? '';
|
||||
add_settings_field(
|
||||
'kompass_group_member_field_1',
|
||||
__('First Name', BDP_LV_PLUGIN_SLUG),
|
||||
'kompass_print_textbox',
|
||||
$page,
|
||||
'custom_settings_section',
|
||||
['setting' => 'kompass_group_member_firstname',
|
||||
'value' => $value, 'style' => 'width: 512px']);
|
||||
|
||||
$value = $prefilledElements['kompass_group_member_lastname'] ?? '';
|
||||
add_settings_field(
|
||||
'kompass_group_member_field_2',
|
||||
__('Last Name', BDP_LV_PLUGIN_SLUG),
|
||||
'kompass_print_textbox',
|
||||
$page,
|
||||
'custom_settings_section',
|
||||
['setting' => 'kompass_group_member_lastname',
|
||||
'value' => $value, 'style' => 'width: 512px']);
|
||||
|
||||
$value = $prefilledElements['kompass_group_member_birthday'] ?? '';
|
||||
add_settings_field(
|
||||
'kompass_group_member_field_3',
|
||||
__('Birthday', BDP_LV_PLUGIN_SLUG),
|
||||
'kompass_print_datebox',
|
||||
$page,
|
||||
'custom_settings_section',
|
||||
['setting' => 'kompass_group_member_birthday',
|
||||
'value' => $value, 'style' => 'width: 512px']);
|
||||
|
||||
$value = $prefilledElements['kompass_group_member_parents'] ?? '';
|
||||
add_settings_field(
|
||||
'kompass_group_member_field_4',
|
||||
__('Contact person', BDP_LV_PLUGIN_SLUG),
|
||||
'kompass_print_textbox',
|
||||
$page,
|
||||
'custom_settings_section',
|
||||
['setting' => 'kompass_group_member_parents',
|
||||
'value' => $value, 'style' => 'width: 512px']);
|
||||
|
||||
$value = $prefilledElements['kompass_group_member_email_1'] ?? '';
|
||||
add_settings_field(
|
||||
'kompass_group_member_field_5',
|
||||
__('E-Mail', BDP_LV_PLUGIN_SLUG),
|
||||
'kompass_print_textbox',
|
||||
$page,
|
||||
'custom_settings_section',
|
||||
['setting' => 'kompass_group_member_email_1',
|
||||
'value' => $value, 'style' => 'width: 512px']);
|
||||
|
||||
$value = $prefilledElements['kompass_group_member_email_2'] ?? '';
|
||||
add_settings_field(
|
||||
'kompass_group_member_field_6',
|
||||
__('Alternative E-Mail', BDP_LV_PLUGIN_SLUG),
|
||||
'kompass_print_textbox',
|
||||
$page,
|
||||
'custom_settings_section',
|
||||
['setting' => 'kompass_group_member_email_2',
|
||||
'value' => $value, 'style' => 'width: 512px']);
|
||||
|
||||
$value = $prefilledElements['kompass_group_member_phone_1'] ?? '';
|
||||
add_settings_field(
|
||||
'kompass_group_member_field_7',
|
||||
__('Telephone', BDP_LV_PLUGIN_SLUG),
|
||||
'kompass_print_textbox',
|
||||
$page,
|
||||
'custom_settings_section',
|
||||
['setting' => 'kompass_group_member_phone_1',
|
||||
'value' => $value, 'style' => 'width: 512px']);
|
||||
|
||||
$value = $prefilledElements['kompass_group_member_phone_2'] ?? '';
|
||||
add_settings_field(
|
||||
'kompass_group_member_field_8',
|
||||
__('Alternative Telephone', BDP_LV_PLUGIN_SLUG),
|
||||
'kompass_print_textbox',
|
||||
$page,
|
||||
'custom_settings_section',
|
||||
['setting' => 'kompass_group_member_phone_2',
|
||||
'value' => $value, 'style' => 'width: 512px']);
|
||||
}
|
@ -11,7 +11,8 @@ function kompass_print_gruppen_overview()
|
||||
<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 for member', BDP_LV_PLUGIN_SLUG); ?>" />
|
||||
placeholder="<?=__('Search member', BDP_LV_PLUGIN_SLUG); ?>" />
|
||||
<input type="submit" class="button" value="<?= __('Search', BDP_LV_PLUGIN_SLUG); ?>" />
|
||||
</p>
|
||||
</form>
|
||||
|
||||
@ -28,15 +29,60 @@ function kompass_print_gruppen_overview()
|
||||
<?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>' . $dbHandler->countSqlRows(GruppenController::KOMPASS_STAMMESGRUPPEN_TEILIS, ['gruppe_id' => $currentGruppe->id]) .'</td>';
|
||||
echo '<td><a href="admin.php?page=bdp-kompass-limit-login-attempts&action=removeFromList">' .
|
||||
__('Show Members', BDP_LV_PLUGIN_SLUG) . '</a></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);
|
||||
|
||||
}
|
||||
|
@ -29,7 +29,7 @@ function kompass_print_gruppen_members(array $memberList)
|
||||
|
||||
</td>
|
||||
<td>
|
||||
<a href="admin.php?page=bdp-kompass-limit-login-attempts&action=removeFromList">
|
||||
<a href= <?= admin_url('admin.php?page=kompass-groups') . '&action=show-member&member-id=' .$curMember->id; ?>">
|
||||
<?= __('Show details', BDP_LV_PLUGIN_SLUG); ?></a>
|
||||
<br />
|
||||
|
||||
|
Reference in New Issue
Block a user