Basic implementation event signup
This commit is contained in:
101
modules/event-participants/Views/event-edit-form.php
Normal file
101
modules/event-participants/Views/event-edit-form.php
Normal file
@ -0,0 +1,101 @@
|
||||
<?php
|
||||
|
||||
use Bdp\Modules\EventParticipants\Models\Event as Event;
|
||||
|
||||
function kompass_print_event_edit_form(?int $event_id = null)
|
||||
{
|
||||
$event = null;
|
||||
if (null === $event_id) {
|
||||
$page = 'kompass-events&action=create-event';
|
||||
|
||||
} else {
|
||||
$page = 'kompass-events&action=update-event&event-id=' . $event_id;
|
||||
$event = Event::loadById($event_id);
|
||||
}
|
||||
|
||||
$events_settings = BDP_LV_PLUGIN_SLUG . '-events-settings';
|
||||
|
||||
add_settings_section(
|
||||
'events_settings',
|
||||
__('Edit event', BDP_LV_PLUGIN_SLUG),
|
||||
'kompass_prepare_form',
|
||||
$events_settings,
|
||||
['page' => $page]
|
||||
);
|
||||
|
||||
add_settings_field(
|
||||
'event_settings_1',
|
||||
__('Event Name', BDP_LV_PLUGIN_SLUG),
|
||||
'kompass_print_textbox',
|
||||
$events_settings,
|
||||
'events_settings',
|
||||
['setting' => 'event_name', 'style' => 'width: 1024px', 'value' => null !== $event ? $event->event_name : '']);
|
||||
|
||||
add_settings_field(
|
||||
'event_settings_2',
|
||||
__('Start date', BDP_LV_PLUGIN_SLUG),
|
||||
'kompass_print_datebox',
|
||||
$events_settings,
|
||||
'events_settings',
|
||||
['setting' => 'startdatum', 'style' => 'width: 256px', 'value' => null !== $event ? $event->startdatum : '']);
|
||||
|
||||
add_settings_field(
|
||||
'event_settings_3',
|
||||
__('End date', BDP_LV_PLUGIN_SLUG),
|
||||
'kompass_print_datebox',
|
||||
$events_settings,
|
||||
'events_settings',
|
||||
['setting' => 'enddatum', 'style' => 'width: 256px', 'value' => null !== $event ? $event->enddatum : '']);
|
||||
|
||||
add_settings_field(
|
||||
'event_settings_7',
|
||||
__('Maximum participants', BDP_LV_PLUGIN_SLUG),
|
||||
'kompass_print_textbox',
|
||||
$events_settings,
|
||||
'events_settings',
|
||||
['setting' => 'max_participants', 'style' => 'width: 256px', 'type' => 'number', 'value' => null !== $event ? $event->max_participants : 100] );
|
||||
|
||||
add_settings_field(
|
||||
'event_settings_8',
|
||||
__('Maximum volunteers', BDP_LV_PLUGIN_SLUG),
|
||||
'kompass_print_textbox',
|
||||
$events_settings,
|
||||
'events_settings',
|
||||
['setting' => 'max_volunteers', 'style' => 'width: 256px', 'type' => 'number', 'value' => null !== $event ? $event->max_volunteers : 50] );
|
||||
|
||||
add_settings_field(
|
||||
'event_settings_4',
|
||||
__('Reduced amount', BDP_LV_PLUGIN_SLUG),
|
||||
'kompass_print_textbox',
|
||||
$events_settings,
|
||||
'events_settings',
|
||||
['setting' => 'amount_reduced', 'style' => 'width: 256px', 'type' => 'number', 'value' => null !== $event ? $event->amount_reduced : 25, 'appendix' => 'Euro']);
|
||||
|
||||
add_settings_field(
|
||||
'event_settings_5',
|
||||
__('Default amount', BDP_LV_PLUGIN_SLUG),
|
||||
'kompass_print_textbox',
|
||||
$events_settings,
|
||||
'events_settings',
|
||||
['setting' => 'amount_default', 'style' => 'width: 256px', 'type' => 'number', 'value' => null !== $event ? $event->amount_default : 60, 'appendix' => 'Euro']);
|
||||
|
||||
add_settings_field(
|
||||
'event_settings_6',
|
||||
__('Additional social amount', BDP_LV_PLUGIN_SLUG),
|
||||
'kompass_print_textbox',
|
||||
$events_settings,
|
||||
'events_settings',
|
||||
['setting' => 'amount_social', 'style' => 'width: 256px', 'type' => 'number', 'value' => null !== $event ? $event->amount_social : 100, 'appendix' => 'Euro<br />' . __('This amount gets added to the selected amount')] );
|
||||
|
||||
add_settings_field(
|
||||
'event_settings_9',
|
||||
__('Contributing Tribes', BDP_LV_PLUGIN_SLUG),
|
||||
'kompass_print_textbox',
|
||||
$events_settings,
|
||||
'events_settings',
|
||||
['setting' => 'contributing_tribes', 'style' => 'width: 256px', 'lines' => 5, 'value' => str_replace(',', PHP_EOL, null !== $event ? $event->contributing_tribes : ''), 'appendix' => '<br />' . __('Please one line per row', BDP_LV_PLUGIN_SLUG)] );
|
||||
|
||||
do_settings_sections($events_settings);
|
||||
submit_button();
|
||||
echo '</form>';
|
||||
}
|
12
modules/event-participants/Views/event-group-controll.php
Normal file
12
modules/event-participants/Views/event-group-controll.php
Normal file
@ -0,0 +1,12 @@
|
||||
<?php
|
||||
function kompass_print_event_control_header(int $event_id, string $active_tab = 'tab1')
|
||||
{
|
||||
$baseUrl = 'admin.php?page=kompass-events&action=show-event&event-id=' . $event_id. '&tab=';
|
||||
return '<h2 class="nav-tab-wrapper">'.
|
||||
'<a href="' . $baseUrl . 'tab1" class="nav-tab ' . ( $active_tab == 'tab1' ? 'nav-tab-active' : '') . '">' .
|
||||
__('Participants by groups', BDP_LV_PLUGIN_SLUG) .
|
||||
'</a>'.
|
||||
'<a href="' . $baseUrl . 'tab2" class="nav-tab ' . ( $active_tab == 'tab2' ? 'nav-tab-active' : '') . '">' .
|
||||
__('Participants by tribes', BDP_LV_PLUGIN_SLUG) .
|
||||
'</a></h2>';
|
||||
}
|
53
modules/event-participants/Views/events-overview.php
Normal file
53
modules/event-participants/Views/events-overview.php
Normal file
@ -0,0 +1,53 @@
|
||||
<?php
|
||||
|
||||
use Bdp\Modules\EventParticipants\Controllers\MainController;
|
||||
|
||||
function kompass_print_events_overview() {
|
||||
global $dbHandler;
|
||||
?>
|
||||
<h2>Veranstaltungsübersicht</h2>
|
||||
<table class="wp-list-table widefat fixed striped table-view-list" id="myTable">
|
||||
<thead>
|
||||
<tr>
|
||||
<th scope="col" class="manage-column column-name"><?= __('Event Name', BDP_LV_PLUGIN_SLUG); ?></th>
|
||||
<th scope="col" class="manage-column column-name"><?= __('Count participants', BDP_LV_PLUGIN_SLUG); ?></th>
|
||||
<th class="manage-column column-name"><?= __('Actions', BDP_LV_PLUGIN_SLUG); ?></th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
<?php
|
||||
|
||||
foreach ($dbHandler->readFromDb( MainController::KOMPASS_EVENTS_EVENTS, ['archived' => false]) as $event_data) {
|
||||
$event = \Bdp\Modules\EventParticipants\Models\Event::loadById($event_data->id);
|
||||
$participant_count = 0;
|
||||
$amount = 0;
|
||||
foreach ($event->groups as $group => $participants) {
|
||||
$participant_count += count($participants);
|
||||
foreach ($participants as $group_participant) {
|
||||
$amount += $group_participant->beitrag;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
echo '<tr>';
|
||||
echo '<td><a href="' . admin_url('admin.php?page=kompass-events&action=show-event&event-id=' . $event->id ) . '">' . $event->event_name .'</a></td>';
|
||||
echo '<td>' . $participant_count . '<br />' . number_format($amount, 2, ',') . ' Euro<br />';
|
||||
echo number_format($participant_count > 0 ? $amount / $participant_count : 0, 2, ',') . ' Euro / Teili </td>';
|
||||
echo '<td> ' .
|
||||
'<a href="' . admin_url('admin.php?page=kompass-events&action=edit-event&event-id=' . $event->id ) . '">' . __('Edit', BDP_LV_PLUGIN_SLUG) . '</a><br />' .
|
||||
($event->signup_allowed ?
|
||||
'<a href="' . admin_url('admin.php?page=kompass-events&action=close-event&event-id=' . $event->id ) . '">' . __('Deny registration', BDP_LV_PLUGIN_SLUG) . '</a>' :
|
||||
'<a href="' . admin_url('admin.php?page=kompass-events&action=open-event&event-id=' . $event->id ) . '">' . __('Allow registration', BDP_LV_PLUGIN_SLUG) . '</a>') .
|
||||
'<br />' .
|
||||
'<a href="' . admin_url('admin.php?page=kompass-events&action=archive-event&event-id=' . $event->id ) . '">' . __('Move to Archive', BDP_LV_PLUGIN_SLUG) . '</a></td>';
|
||||
echo '</tr>';
|
||||
}
|
||||
?>
|
||||
</tbody>
|
||||
</table><br /><br />
|
||||
|
||||
|
||||
<a class="button" href=" <?= admin_url('admin.php?page=kompass-events') . '&action=new-event'; ?>"><?= __( 'New Event', BDP_LV_PLUGIN_SLUG ); ?></a>
|
||||
|
||||
<?php
|
||||
}
|
@ -0,0 +1,80 @@
|
||||
<?php
|
||||
namespace Bdp\Modules\EventParticipants\Views;
|
||||
|
||||
use Bdp\Libs\FileAccess;
|
||||
use Bdp\Modules\EventParticipants\Controllers\MainController as GruppenController;
|
||||
use Bdp\Modules\EventParticipants\Models\Event;
|
||||
use Bdp\Modules\EventParticipants\Models\EventGroup;
|
||||
|
||||
function registrationForm(int $eventId, string $targetPage) : string
|
||||
{
|
||||
global $dbHandler;
|
||||
|
||||
$event = Event::loadById($eventId);
|
||||
|
||||
if (!$event->signup_allowed) {
|
||||
return '<h2>Derzeit ist keine Anmeldung für diese Veranstaltung möglich.</h2>';
|
||||
}
|
||||
$registerForm = file_get_contents(dirname(__FILE__) . '/../Templates/register-form.php');
|
||||
|
||||
$registerForm = str_replace(
|
||||
'{{altersstufe}}',
|
||||
file_get_contents(dirname(__FILE__) . '/../Templates/Partials/Registration/altersstufe.php'),
|
||||
$registerForm
|
||||
);
|
||||
|
||||
$registerForm = str_replace(
|
||||
'{{persönliche daten eltern}}',
|
||||
file_get_contents(dirname(__FILE__) . '/../Templates/Partials/Registration/ansprechpartner.php'),
|
||||
$registerForm
|
||||
);
|
||||
|
||||
$registerForm = str_replace(
|
||||
'{{persönliche daten}}',
|
||||
file_get_contents(dirname(__FILE__) . '/../Templates/Partials/Registration/kontaktdaten.php'),
|
||||
$registerForm
|
||||
);
|
||||
|
||||
$registerForm = str_replace(
|
||||
'{{anreise}}',
|
||||
file_get_contents(dirname(__FILE__) . '/../Templates/Partials/Registration/anreise.php'),
|
||||
$registerForm
|
||||
);
|
||||
|
||||
$registerForm = str_replace(
|
||||
'{{gruppe}}',
|
||||
file_get_contents(dirname(__FILE__) . '/../Templates/Partials/Registration/gruppe.php'),
|
||||
$registerForm
|
||||
);
|
||||
|
||||
$registerForm = str_replace(
|
||||
'{{beitrag}}',
|
||||
file_get_contents(dirname(__FILE__) . '/../Templates/Partials/Registration/beitrag.php'),
|
||||
$registerForm
|
||||
);
|
||||
|
||||
$registerForm = str_replace(
|
||||
'{{fotoerlaubnis}}',
|
||||
file_get_contents(dirname(__FILE__) . '/../Templates/Partials/Registration/fotoerlaubnis.php'),
|
||||
$registerForm
|
||||
);
|
||||
|
||||
$registerForm = str_replace(
|
||||
'{{allergien}}',
|
||||
file_get_contents(dirname(__FILE__) . '/../Templates/Partials/Registration/allergien.php'),
|
||||
$registerForm
|
||||
);
|
||||
|
||||
$registerForm = str_replace('{{startdate}}', $event->startdatum, $registerForm);
|
||||
$registerForm = str_replace('{{enddate}}', $event->enddatum, $registerForm);
|
||||
$registerForm = str_replace('{{amount_reduced}}', $event->amount_reduced, $registerForm);
|
||||
$registerForm = str_replace('{{amount_default}}', $event->amount_default, $registerForm);
|
||||
$registerForm = str_replace('{{amount_social}}', $event->amount_social, $registerForm);
|
||||
|
||||
|
||||
$registerForm = str_replace('{{URL}}', $targetPage, $registerForm);
|
||||
$registerForm = str_replace('{{eventId}}', $eventId, $registerForm);
|
||||
$registerForm = str_replace('{{BDP_LV_PLUGIN_URL}}', BDP_LV_PLUGIN_URL, $registerForm);
|
||||
return $registerForm;
|
||||
|
||||
}
|
Reference in New Issue
Block a user