From 258cb93ee6cdaf3f606716ae79d344537e2f7fd4 Mon Sep 17 00:00:00 2001 From: Chuck Scott Date: Mon, 11 Dec 2017 09:27:10 -0500 Subject: [PATCH] Added Custom Fields support for admin events. --- models/admin/registrations/events.php | 14 +- models/front/registrations/checkout.php | 2 +- .../front/registrations/checkoutProcess.php | 39 +++ views/admin/registrations/eventDashboard.html | 3 + views/admin/registrations/eventEdit.html | 14 +- .../registrations/eventEditCustomFields.html | 74 ++++++ .../admin/registrations/eventEditLevels.html | 5 +- views/front/registrations/checkout.html | 223 +++++++++--------- 8 files changed, 250 insertions(+), 124 deletions(-) create mode 100644 views/admin/registrations/eventEditCustomFields.html diff --git a/models/admin/registrations/events.php b/models/admin/registrations/events.php index d9f3909..bb571aa 100644 --- a/models/admin/registrations/events.php +++ b/models/admin/registrations/events.php @@ -156,6 +156,18 @@ class GlmMembersAdmin_registrations_events extends GlmDataRegistrationsRegEvent switch ($option) { + case 'eventCustomFields': + + require_once GLM_MEMBERS_REGISTRATIONS_PLUGIN_CLASS_PATH.'/data/dataRegClass.php'; + $RegClasses = new GlmDataRegistrationsRegClass($this->wpdb, $this->config); + $classes = $RegClasses->getList("T.reg_event = $regEventID"); + + $regEvent = $this->getEntry($regEventID); + + $view = 'eventEditCustomFields'; + + break; + case 'configureEvent': $scripts = array( @@ -543,7 +555,7 @@ class GlmMembersAdmin_registrations_events extends GlmDataRegistrationsRegEvent 'regEventJSON' => $regEventJSON, 'regClassesJSON' => $regClassesJSON, 'regTimesJSON' => $regTimesJSON, - 'eventCustomFieldsUid' => GLM_MEMBERS_REGISTRATIONS_PLUGIN_SLUG.'-customfields-reg-event-edit-'.$regEventID + 'classes' => $classes ); // echo "
".print_r($templateData,1)."
"; diff --git a/models/front/registrations/checkout.php b/models/front/registrations/checkout.php index 5fc0e37..d3049c2 100644 --- a/models/front/registrations/checkout.php +++ b/models/front/registrations/checkout.php @@ -292,7 +292,7 @@ class GlmMembersFront_registrations_checkout extends GlmRegCartSupport 'misc' => $misc, 'checkoutPageText' => $misc['checkout_page_text'], 'globalTerms' => $misc['reg_terms'], - 'eventCustomFieldsUid' => GLM_MEMBERS_REGISTRATIONS_PLUGIN_SLUG.'-customfields-reg-event-edit-' + 'eventCustomFieldsFidPrefix' => GLM_MEMBERS_REGISTRATIONS_PLUGIN_SLUG.'-customfields-reg-event-' ); // echo "
".print_r($templateData,1)."
"; diff --git a/models/front/registrations/checkoutProcess.php b/models/front/registrations/checkoutProcess.php index 84e7b5f..17ecfda 100644 --- a/models/front/registrations/checkoutProcess.php +++ b/models/front/registrations/checkoutProcess.php @@ -217,6 +217,43 @@ class GlmMembersFront_registrations_checkoutProcess extends GlmRegCartSupport } + /* + * Custom Fields + */ + + // Process and store any custom fields for events + if (apply_filters('glm-members-customfields-active', false)) { + + // For each event, see if there's any custom fields + foreach ($this->cart['events'] as $eventKey=>$eventData) { + + $formResult = false; + + // Build form ID for the custom form that's requested once at checkout for this event + $fid = 'glm_reg_customfields_reg_event_'.$eventData['reg_event']; + + // If there's any form fields (if not - assume no form) + if (apply_filters('glm-members-customfields-have-fields', false, $fid)) { + + // Attempt to process the custom form fields and ask for the data to be stored - use reg_request_event id for record # + $formResult = apply_filters('glm-members-customfields-form-submit', false, $fid, $eventData['id'], true ); + + } + +echo "Form Result:
".print_r($formResult,1)."
"; + + // Save the results in the cart event data + $this->cart['events'][$eventKey]['customForm'] = $formResult; + + } + } + +echo "
".print_r($this->cart['events'],1)."
"; + + +wp_die("KILLING WORDPRESS FOR TESTING IN checkoutProcess.php"); + + /* * Policies accepted? */ @@ -578,6 +615,8 @@ class GlmMembersFront_registrations_checkoutProcess extends GlmRegCartSupport $request = $Request->getEntry($this->cart['request']['id']); $account = $Account->getEntry($request['account']); + + if (count($messages) == 0) { // Produce HTML for storage and checkout page and add to request diff --git a/views/admin/registrations/eventDashboard.html b/views/admin/registrations/eventDashboard.html index 4eb4518..c871cec 100644 --- a/views/admin/registrations/eventDashboard.html +++ b/views/admin/registrations/eventDashboard.html @@ -6,6 +6,9 @@ Event Dashboard Edit Registration Settings Registration Levels & Charges +{if apply_filters('glm-members-customfields-active', false)} + Additional Fields +{/if} {if $haveMessages} diff --git a/views/admin/registrations/eventEdit.html b/views/admin/registrations/eventEdit.html index 1fd83cc..542f25e 100644 --- a/views/admin/registrations/eventEdit.html +++ b/views/admin/registrations/eventEdit.html @@ -1,7 +1,7 @@ {include file='admin/registrations/eventHeader.html'}

- Registrations Event Edit + {$regEvent.fieldData.event_name}     {if $regEventUpdated}Registration Event Updated{/if} {if $regEventUpdateError}Registration Event Update Error{/if} @@ -25,6 +25,9 @@ Event Dashboard Edit Registration Settings Registration Levels & Charges +{if apply_filters('glm-members-customfields-active', false)} + Additional Fields +{/if}

@@ -225,15 +228,6 @@ {/if}
- {if apply_filters('glm-members-customfields-active', false)} - - Custom Fields - -

These are additional fields of information that will be requested for each registrant.

- {apply_filters('glm-members-customfields-edit', '', $eventCustomFieldsUid)} - - - {/if} diff --git a/views/admin/registrations/eventEditCustomFields.html b/views/admin/registrations/eventEditCustomFields.html new file mode 100644 index 0000000..f5e343a --- /dev/null +++ b/views/admin/registrations/eventEditCustomFields.html @@ -0,0 +1,74 @@ +{include file='admin/registrations/eventHeader.html'} + +

+ {$regEvent.event_name} + +     + {if $regEventUpdated}Registration Event Updated{/if} + {if $regEventUpdateError}Registration Event Update Error{/if} + {if $regEventAdded}Registration Event Added{/if} + +

+ +
+ +{if $haveMessages} +
+ Please Note: +
    + {foreach $messages as $m} +
  • {$m}
  • + {/foreach} +
+
+{/if} + + + + +{if apply_filters('glm-members-customfields-active', false)} +


+ + {* Per Event Form for this event *} +

Per submission including this event

+

These are additional fields of information that will be requested for this event in each submission.

+

+ {assign var="eventFid" value="glm_reg_customfields_reg_event_`$regEventID`"} + {apply_filters('glm-members-customfields-edit', '', $eventFid)} +

+ + {* Per Attendee Form for this event *} +


+

Each attendee for this event

+

These are additional fields of information that will be requested for each registrant for this event.

+

+ {assign var="attendeeFid" value="glm_reg_customfields_reg_attendee_`$regEventID`"} + {apply_filters('glm-members-customfields-edit', '', $attendeeFid)} +

+ + {* Per Attendee form for each class (level) for this event *} +


+ {foreach $classes as $class} +

Each attendee for level: {$class.name}

+

These are additional fields of information that will be requested for each registrant for this event.

+

+ {assign var="levelFid" value="glm_reg_customfields_reg_event_`$regEventID`_level_`$class.id`"} + {apply_filters('glm-members-customfields-edit', '', $levelFid)} +

+


+ {/foreach} + +{/if} + + + +
+ +{include file='admin/footer.html'} + diff --git a/views/admin/registrations/eventEditLevels.html b/views/admin/registrations/eventEditLevels.html index 124009d..de6f2e1 100644 --- a/views/admin/registrations/eventEditLevels.html +++ b/views/admin/registrations/eventEditLevels.html @@ -1,7 +1,7 @@ {include file='admin/registrations/eventHeader.html'}

- Registrations Event Edit + {$regEvent.event_name}     {if $regEventUpdated}Registration Event Updated{/if} @@ -27,6 +27,9 @@ Event Dashboard Edit Registration Settings Registration Levels & Charges +{if apply_filters('glm-members-customfields-active', false)} + Additional Fields +{/if}

{* Event Registration App - Backbone.js *} diff --git a/views/front/registrations/checkout.html b/views/front/registrations/checkout.html index 25a7727..6236262 100644 --- a/views/front/registrations/checkout.html +++ b/views/front/registrations/checkout.html @@ -1,9 +1,9 @@ {include file='front/registrations/header.html'} {if $checkoutPageText} -
- {$checkoutPageText} -
+
+ {$checkoutPageText} +
{/if} {if $haveMessages} @@ -280,22 +280,21 @@ {/if} {* / total charges > 0 *} {if apply_filters('glm-members-customfields-active', false)} -
-
-

Additional information we need to collect

{foreach $cart.events as $event} + {assign var="fid" value="glm_reg_customfields_reg_event_`$event.reg_event`"} {* assemble the uid with the current event ID *} + {if apply_filters('glm-members-customfields-have-fields', false, $fid)} +
+
+

Additional information for event: {$event.event_name}

-
{$event.event_name}:
- {apply_filters('glm-members-customfields-form-display', $eventCustomFieldsUid.{$event.id}, {$cart.id}, false)} - - GLM_MEMBERS_REGISTRATIONS_PLUGIN_SLUG.'-customfields-reg-event-edit-'.$regEventID - + {apply_filters('glm-members-customfields-form-display', '', $fid, $cartId, 'checkoutForm', false)}
- {/foreach}
+ {/if} + {/foreach} {/if}
@@ -334,128 +333,125 @@ You have one more step to complete your registration!
- - - -
Please wait while we process your registration request. If you don't see a new page, your registration request may not have been processed.
-
-

Something may have gone wrong.

-

- It may be that your registration request was received and processed and you didn't receive our response yet. - If you still don't see a response in a while, try returning to the cart using the button above. - If still don't see any response, please check your E-Mail to see if you have been sent a confirmation. -

-

- In any case, we will never process your request more than once. If you can return to the cart, it should say if - your request was recieved and processed. If not, you may try the checkout process again or come back later. -

-

Registration Summary

- + + +
Please wait while we process your registration request. If you don't see a new page, your registration request may not have been processed.
+
+

Something may have gone wrong.

+

+ It may be that your registration request was received and processed and you didn't receive our response yet. + If you still don't see a response in a while, try returning to the cart using the button above. + If still don't see any response, please check your E-Mail to see if you have been sent a confirmation. +

+

+ In any case, we will never process your request more than once. If you can return to the cart, it should say if + your request was recieved and processed. If not, you may try the checkout process again or come back later. +

+
+ +

Registration Summary

+
- + - - - - - - - + + + + + + + - + {foreach $cart.events as $event} - - - + + + {foreach $event.classes as $class} - - - + + + {foreach $class.rates as $rate} {if $rate.rateBaseCharge || $rate.registrant_credits} - - - - + + + + {/if} {foreach $rate.registrants as $registrant} - - - - - - - + + + + + + + {assign var="acct" value=$cart.accounts.{$registrant.account}} {if $acct.validated.value} - - - - + + + + {else} {if $acct.addr1 != '' || $acct.phone != '' || $acct.email != ''} - - - - + + + + {/if} {/if} {/foreach} {/foreach} {/foreach} {/foreach} - - - - - - - + + + + + + + {/if} {* / if have cart *} -
RegisteringRegistrantDate/TimeDiscountRate
RegisteringRegistrantDate/TimeDiscountRate
Event: {$event.event_name}
Event: {$event.event_name}
    {$class.class_name}
    {$class.class_name}
-         {$rate.rate_name} - - Base Rate ({$rate.registrant_credits} registrants included) - - {if $rate.rateBaseCharge}{$rate.rateBaseCharge|number_format:2}{/if} -
+         {$rate.rate_name} + - Base Rate ({$rate.registrant_credits} registrants included) + + {if $rate.rateBaseCharge}{$rate.rateBaseCharge|number_format:2}{/if} +
 {$registrant.fname} {$registrant.lname}{$registrant.timeReformatted} - {if $registrant.registrantDiscounts > 0} - {$registrant.registrantDiscounts|number_format:2} - {else} -   - {/if} - - {if $registrant.registrantRate > 0} - {$registrant.registrantRate|number_format:2} - {else} - (included) - {/if} -
 {$registrant.fname} {$registrant.lname}{$registrant.timeReformatted} + {if $registrant.registrantDiscounts > 0} + {$registrant.registrantDiscounts|number_format:2} + {else} +   + {/if} + + {if $registrant.registrantRate > 0} + {$registrant.registrantRate|number_format:2} + {else} + (included) + {/if} +
  - {if $acct.email != ''}E-Mail: {$acct.email}
{/if} - (Account information is restricted) -
  + {if $acct.email != ''}E-Mail: {$acct.email}
{/if} + (Account information is restricted) +
  - {if $acct.org != ''} {$acct.title}, {$acct.org}
{/if} - {if $acct.addr1 != ''} {$acct.addr1}
{/if} - {if $acct.addr2 != ''} {$acct.addr2}
{/if} - {if $acct.city != ''} {$acct.city}, {$acct.state.value} {$acct.zip}
{/if} - {if $acct.country.name != ''} {$acct.country.name}
{/if} - {if $acct.phone != ''} Phone: {$acct.phone}
{/if} - {if $acct.fax != ''} Fax: {$acct.fax}
{/if} - {if $acct.email != ''} E-Mail: {$acct.email} {/if} -
  + {if $acct.org != ''} {$acct.title}, {$acct.org}
{/if} + {if $acct.addr1 != ''} {$acct.addr1}
{/if} + {if $acct.addr2 != ''} {$acct.addr2}
{/if} + {if $acct.city != ''} {$acct.city}, {$acct.state.value} {$acct.zip}
{/if} + {if $acct.country.name != ''} {$acct.country.name}
{/if} + {if $acct.phone != ''} Phone: {$acct.phone}
{/if} + {if $acct.fax != ''} Fax: {$acct.fax}
{/if} + {if $acct.email != ''} E-Mail: {$acct.email} {/if} +
 Total registrants: {$cart.totalRegistrants} - {if $cart.totalDiscounts > 0} - ${$cart.totalDiscounts|number_format:2} - {else} -   - {/if} - ${$cart.totalCharges|number_format:2}
 Total registrants: {$cart.totalRegistrants} + {if $cart.totalDiscounts > 0} + ${$cart.totalDiscounts|number_format:2} + {else} +   + {/if} + ${$cart.totalCharges|number_format:2}
- - -
-
+