Skip to content
Snippets Groups Projects
Commit 2157e78f authored by Owen Bush's avatar Owen Bush
Browse files

Add more info to registants list

parent 0bffc851
No related branches found
No related tags found
No related merge requests found
show_capacity: true show_capacity: true
limit: 10 limit: 10
date_format: 'F jS, Y h:iA'
email_notifications: true email_notifications: true
registration_notification_enabled: true registration_notification_enabled: true
registration_notification_subject: 'You''ve Successfully Registered' registration_notification_subject: 'You''ve Successfully Registered'
......
...@@ -8,6 +8,9 @@ recurring_events_registration.registrant.config: ...@@ -8,6 +8,9 @@ recurring_events_registration.registrant.config:
limit: limit:
type: integer type: integer
label: 'The items per page to show on registrant listing' label: 'The items per page to show on registrant listing'
date_format:
type: string
label: 'The formatting of dates when displaying registrants'
email_notifications: email_notifications:
type: boolean type: boolean
label: 'Whether to enable email notifications' label: 'Whether to enable email notifications'
......
...@@ -4,6 +4,8 @@ namespace Drupal\recurring_events_registration\Form; ...@@ -4,6 +4,8 @@ namespace Drupal\recurring_events_registration\Form;
use Drupal\Core\Form\ConfigFormBase; use Drupal\Core\Form\ConfigFormBase;
use Drupal\Core\Form\FormStateInterface; use Drupal\Core\Form\FormStateInterface;
use Drupal\Core\Url;
use Drupal\Core\Link;
/** /**
* Class RegistrantSettingsForm. * Class RegistrantSettingsForm.
...@@ -41,6 +43,7 @@ class RegistrantSettingsForm extends ConfigFormBase { ...@@ -41,6 +43,7 @@ class RegistrantSettingsForm extends ConfigFormBase {
$this->config('recurring_events_registration.registrant.config') $this->config('recurring_events_registration.registrant.config')
->set('show_capacity', $form_state->getValue('show_capacity')) ->set('show_capacity', $form_state->getValue('show_capacity'))
->set('limit', $form_state->getValue('limit')) ->set('limit', $form_state->getValue('limit'))
->set('date_format', $form_state->getValue('date_format'))
->set('email_notifications', $form_state->getValue('email_notifications')) ->set('email_notifications', $form_state->getValue('email_notifications'))
->set('registration_notification_enabled', $form_state->getValue('registration_notification')) ->set('registration_notification_enabled', $form_state->getValue('registration_notification'))
->set('registration_notification_subject', $form_state->getValue('registration_notification_subject')) ->set('registration_notification_subject', $form_state->getValue('registration_notification_subject'))
...@@ -88,13 +91,13 @@ class RegistrantSettingsForm extends ConfigFormBase { ...@@ -88,13 +91,13 @@ class RegistrantSettingsForm extends ConfigFormBase {
'#default_value' => $config->get('show_capacity'), '#default_value' => $config->get('show_capacity'),
]; ];
$form['view'] = [ $form['display'] = [
'#type' => 'details', '#type' => 'details',
'#title' => $this->t('Viewing Registrants'), '#title' => $this->t('Registrant Display'),
'#open' => TRUE, '#open' => TRUE,
]; ];
$form['view']['limit'] = [ $form['display']['limit'] = [
'#type' => 'number', '#type' => 'number',
'#title' => $this->t('Registrant Items'), '#title' => $this->t('Registrant Items'),
'#required' => TRUE, '#required' => TRUE,
...@@ -102,6 +105,19 @@ class RegistrantSettingsForm extends ConfigFormBase { ...@@ -102,6 +105,19 @@ class RegistrantSettingsForm extends ConfigFormBase {
'#default_value' => $config->get('limit'), '#default_value' => $config->get('limit'),
]; ];
$php_date_url = Url::fromUri('https://secure.php.net/manual/en/function.date.php');
$php_date_link = Link::fromTextAndUrl($this->t('PHP date/time format'), $php_date_url);
$form['display']['date_format'] = [
'#type' => 'textfield',
'#title' => $this->t('Registrant Date Format'),
'#required' => TRUE,
'#description' => $this->t('Enter the @link used when listing registrants. Default is F jS, Y h:iA.', [
'@link' => $php_date_link->toString(),
]),
'#default_value' => $config->get('date_format'),
];
$form['notifications'] = [ $form['notifications'] = [
'#type' => 'details', '#type' => 'details',
'#title' => $this->t('Email Notifications'), '#title' => $this->t('Email Notifications'),
......
...@@ -57,6 +57,9 @@ class RegistrantListBuilder extends EntityListBuilder { ...@@ -57,6 +57,9 @@ class RegistrantListBuilder extends EntityListBuilder {
*/ */
public function buildHeader() { public function buildHeader() {
$header['id'] = $this->t('Registrant ID'); $header['id'] = $this->t('Registrant ID');
$header['series'] = $this->t('Series');
$header['instance'] = $this->t('Instance');
$header['type'] = $this->t('Type');
foreach ($this->getCustomFields() as $machine_name => $field) { foreach ($this->getCustomFields() as $machine_name => $field) {
$header[$machine_name] = $field; $header[$machine_name] = $field;
} }
...@@ -70,7 +73,13 @@ class RegistrantListBuilder extends EntityListBuilder { ...@@ -70,7 +73,13 @@ class RegistrantListBuilder extends EntityListBuilder {
*/ */
public function buildRow(EntityInterface $entity) { public function buildRow(EntityInterface $entity) {
/* @var $entity \Drupal\recurring_events_registration\Entity\Registrant */ /* @var $entity \Drupal\recurring_events_registration\Entity\Registrant */
$series = $entity->getEventSeries();
$instance = $entity->getEventInstance();
$row['id'] = $entity->id(); $row['id'] = $entity->id();
$row['series'] = $series->toLink($series->title->value);
$row['instance'] = $instance->toLink($instance->date->start_date->format($this->config->get('recurring_events_registration.registrant.config')->get('date_format')));
$row['type'] = $entity->getRegistrationType() == 'series' ? $this->t('Series') : $this->t('Instance');
foreach ($this->getCustomFields() as $machine_name => $field) { foreach ($this->getCustomFields() as $machine_name => $field) {
$row[$machine_name] = $entity->get($machine_name)->value; $row[$machine_name] = $entity->get($machine_name)->value;
} }
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment