From f1645e6cac2210eb668dfc17d470ac550bb8083c Mon Sep 17 00:00:00 2001 From: Steve Sutton Date: Wed, 3 Jan 2018 12:04:47 -0500 Subject: [PATCH] Adding custom fields into export. And use select for state and country For the add and edit attend form on front registration page adding state and country drop down selects. Adding custom fields into the export. --- classes/data/dataRegRequestRegistrant.php | 4 +- js/frontRegApp.js | 15 +- js/views/front/regRequestRegistrant.js | 9 +- js/views/front/registrantForm.js | 6 + models/admin/ajax/account.php | 8 +- models/admin/ajax/registrantsListExport.php | 80 ++++++---- models/admin/registrations/events.php | 17 +- models/front/registrations/registration.php | 5 +- views/admin/ajax/registrantsListExport.html | 10 ++ .../admin/ajax/registrantsListExportCsv.html | 2 + .../admin/registrations/eventRegistrants.html | 3 + views/front/registrations/registration.html | 148 +++++++++++------- 12 files changed, 188 insertions(+), 119 deletions(-) diff --git a/classes/data/dataRegRequestRegistrant.php b/classes/data/dataRegRequestRegistrant.php index d3fdeb2..10d325b 100644 --- a/classes/data/dataRegRequestRegistrant.php +++ b/classes/data/dataRegRequestRegistrant.php @@ -359,9 +359,7 @@ class GlmDataRegistrationsRequestRegistrant extends GlmDataAbstract if ( isset( $customData ) && is_array( $customData ) && !empty( $customData ) ) { $fields = $customData['form']; foreach ( $fields as $cField ) { - $custom_data[] = array( - $cField['field_name'] => $cField['stored'] - ); + $custom_data[$cField['field_name']] = $cField['stored']; } $registrants[$registrantKey]['custom_data'] = $custom_data; } diff --git a/js/frontRegApp.js b/js/frontRegApp.js index b6670e3..2cb20e3 100644 --- a/js/frontRegApp.js +++ b/js/frontRegApp.js @@ -859,18 +859,15 @@ app.Views.Front.RegRequestRegistrant = Backbone.View.extend({ // render the view render: function(){ - // console.log( 'regReguestRegistrantView.render called' ); - this.$el.html( this.template( this.model.toJSON() ) ); this.$emailInput = this.$('.editEmail'); this.$('.reg-edit-form').hide(); + // setup the state and country select + this.$('.reg_state').val(this.model.get('state')); + this.$('.reg_country').val(this.model.get('country')); // Call the custom fields ajax app.setCustomFieldsForm(this.model.get('reg_event'), this.model.id, '.attendee-cf-' + this.model.id); - // console.log('call setCustomFieldsForm' ); - // if ( this.customFieldFormData ) { - // this.$('.attendee-cf-' + this.model.get('id')).html( this.customFieldFormData ); - // } return this; }, @@ -1138,6 +1135,12 @@ app.Views.Front.RegistrantForm = Backbone.View.extend({ // They should not be able to edit the record. this.$('.add_reg_fname').val(account.fname); this.$('.add_reg_lname').val(account.lname); + this.$('.add_reg_addr1').val(account.addr1); + this.$('.add_reg_addr2').val(account.addr2); + this.$('.add_reg_city').val(account.city); + this.$('.add_reg_state').val(account.state); + this.$('.add_reg_zip').val(account.zip); + this.$('.add_reg_country').val(account.country); // lock the form // this.lockForm(); diff --git a/js/views/front/regRequestRegistrant.js b/js/views/front/regRequestRegistrant.js index d3dc7d7..f3c6bfb 100644 --- a/js/views/front/regRequestRegistrant.js +++ b/js/views/front/regRequestRegistrant.js @@ -113,18 +113,15 @@ app.Views.Front.RegRequestRegistrant = Backbone.View.extend({ // render the view render: function(){ - // console.log( 'regReguestRegistrantView.render called' ); - this.$el.html( this.template( this.model.toJSON() ) ); this.$emailInput = this.$('.editEmail'); this.$('.reg-edit-form').hide(); + // setup the state and country select + this.$('.reg_state').val(this.model.get('state')); + this.$('.reg_country').val(this.model.get('country')); // Call the custom fields ajax app.setCustomFieldsForm(this.model.get('reg_event'), this.model.id, '.attendee-cf-' + this.model.id); - // console.log('call setCustomFieldsForm' ); - // if ( this.customFieldFormData ) { - // this.$('.attendee-cf-' + this.model.get('id')).html( this.customFieldFormData ); - // } return this; }, diff --git a/js/views/front/registrantForm.js b/js/views/front/registrantForm.js index 2b2e115..85c9fb7 100644 --- a/js/views/front/registrantForm.js +++ b/js/views/front/registrantForm.js @@ -60,6 +60,12 @@ app.Views.Front.RegistrantForm = Backbone.View.extend({ // They should not be able to edit the record. this.$('.add_reg_fname').val(account.fname); this.$('.add_reg_lname').val(account.lname); + this.$('.add_reg_addr1').val(account.addr1); + this.$('.add_reg_addr2').val(account.addr2); + this.$('.add_reg_city').val(account.city); + this.$('.add_reg_state').val(account.state); + this.$('.add_reg_zip').val(account.zip); + this.$('.add_reg_country').val(account.country); // lock the form // this.lockForm(); diff --git a/models/admin/ajax/account.php b/models/admin/ajax/account.php index faf80a1..3762262 100644 --- a/models/admin/ajax/account.php +++ b/models/admin/ajax/account.php @@ -233,7 +233,7 @@ class GlmMembersAdmin_ajax_account extends GlmDataRegistrationsAccount if ( $email = filter_var( $_REQUEST['email'], FILTER_VALIDATE_EMAIL ) ) { $accountData = $this->wpdb->get_row( $this->wpdb->prepare( - "SELECT id,fname,lname,validated + "SELECT id,fname,lname,addr1,addr2,city,state,zip,country,validated FROM " . GLM_MEMBERS_REGISTRATIONS_PLUGIN_DB_PREFIX . "account WHERE email = %s", $email @@ -249,6 +249,12 @@ class GlmMembersAdmin_ajax_account extends GlmDataRegistrationsAccount 'email' => $email, 'fname' => $accountData['fname'], 'lname' => $accountData['lname'], + 'addr1' => $accountData['addr1'], + 'addr2' => $accountData['addr2'], + 'city' => $accountData['city'], + 'state' => $accountData['state'], + 'zip' => $accountData['zip'], + 'country' => $accountData['country'], 'validated' => $accountData['validated'], ); } else { diff --git a/models/admin/ajax/registrantsListExport.php b/models/admin/ajax/registrantsListExport.php index 7599e07..f969327 100644 --- a/models/admin/ajax/registrantsListExport.php +++ b/models/admin/ajax/registrantsListExport.php @@ -81,22 +81,23 @@ class GlmMembersAdmin_ajax_registrantsListExport extends GlmDataRegistrationsReq // When processing registrant info records, also get primary contact data $this->postProcessPrimaryContact = true; - $where = ' true '; - $categories = false; - $haveRegistrants = false; - $list = false; - $success = false; - $filterPending = false; - $filterArchived = false; - $haveFilter = false; - $numbDisplayed = false; - $lastDisplayed = false; - $paging = true; - $prevStart = false; - $nextStart = false; - $start = 1; - $limit = 20; // Set to the number of listings per page - $namesList = false; + $where = ' true '; + $categories = false; + $haveRegistrants = false; + $list = false; + $success = false; + $filterPending = false; + $filterArchived = false; + $haveFilter = false; + $numbDisplayed = false; + $lastDisplayed = false; + $paging = true; + $prevStart = false; + $nextStart = false; + $start = 1; + $limit = 20; // Set to the number of listings per page + $namesList = false; + $customFieldHeaders = false; // Check selected fields $select = array( @@ -114,6 +115,7 @@ class GlmMembersAdmin_ajax_registrantsListExport extends GlmDataRegistrationsReq 'exportTime' => $this->checkFlag('exportTime'), 'exportRate' => $this->checkFlag('exportRate'), 'exportStatus' => $this->checkFlag('exportStatus'), + 'exportCustom' => $this->checkFlag('exportCustom'), ); // Get registration event ID if supplied @@ -157,8 +159,23 @@ class GlmMembersAdmin_ajax_registrantsListExport extends GlmDataRegistrationsReq $where = implode( ' AND ', $whereParts ); // $list = $this->getList($where, "lname"); - $listResult = $this->getFullRegistrantsData($regEventID, $where, 1, false); + $listResult = $this->getFullRegistrantsData($regEventID, $where, false, false); $list = $listResult['list']; + $customFieldsPluginActive = apply_filters( 'glm-members-customfields-plugin-active', false ); + $customFieldHeaders = false; + // Go through the $listResult to pull out the custom fields if available and if plugin is on + if ( $customFieldsPluginActive && $listResult['list'] ) { + $index = 1; + foreach ( $list as $attendee ) { + if ( $attendee['custom_data'] ) { + if ( $index === 1 ) { + $customFieldHeaders = array_keys( $attendee['custom_data'] ); + } + } + break; + } + } + // echo '
$customFieldHeaders: ' . print_r( $customFieldHeaders, true ) . '
'; // echo '
$list: ' . print_r( $list, true ) . '
'; // exit; @@ -177,20 +194,21 @@ class GlmMembersAdmin_ajax_registrantsListExport extends GlmDataRegistrationsReq // Compile template data $templateData = array( - 'select' => $select, - 'haveRegistrants' => $haveRegistrants, - 'registrants' => $list, - 'registrantCount' => $registrantCount, - 'categories' => $categories, - 'haveFilter' => $haveFilter, - 'numbDisplayed' => $numbDisplayed, - 'lastDisplayed' => $lastDisplayed, - 'paging' => $paging, - 'prevStart' => $prevStart, - 'nextStart' => $nextStart, - 'start' => $start, - 'limit' => $limit, - 'namesList' => $namesList + 'select' => $select, + 'haveRegistrants' => $haveRegistrants, + 'registrants' => $list, + 'registrantCount' => $registrantCount, + 'categories' => $categories, + 'haveFilter' => $haveFilter, + 'numbDisplayed' => $numbDisplayed, + 'lastDisplayed' => $lastDisplayed, + 'paging' => $paging, + 'prevStart' => $prevStart, + 'nextStart' => $nextStart, + 'start' => $start, + 'limit' => $limit, + 'namesList' => $namesList, + 'customFieldHeaders' => $customFieldHeaders, ); $view = 'admin/ajax/registrantsListExport.html'; diff --git a/models/admin/registrations/events.php b/models/admin/registrations/events.php index ef98636..e789738 100644 --- a/models/admin/registrations/events.php +++ b/models/admin/registrations/events.php @@ -288,23 +288,8 @@ class GlmMembersAdmin_registrations_events extends GlmDataRegistrationsRegEvent $listResult = $Registrants->getFullRegistrantsData($regEventID, $where, $start, $limit); // echo '
$listResult: ' . print_r( $listResult['list'], true ) . '
'; - $customFields = false; - // Go through the $listResult to pull out the custom fields if available and if plugin is on - if ( $customFieldsPluginActive && $listResult['list'] ) { - foreach ( $listResult['list'] as $row ) { - if ( $row['custom_data'] ) { - foreach ( $row['custom_data'] as $cFields ) { - $customFields[] = array_keys( $cFields ); - } - } - break; - } - } - // echo '
$customFields: ' . print_r( $customFields, true ) . '
'; - - // Get count of registrants listed - $registrantCount = $listResult['totalCount'];; + $registrantCount = $listResult['totalCount']; // If the number of registrants is less than a page, don't do paging if ($registrantCount <= $limit) { diff --git a/models/front/registrations/registration.php b/models/front/registrations/registration.php index c552671..d3fe1f7 100644 --- a/models/front/registrations/registration.php +++ b/models/front/registrations/registration.php @@ -344,6 +344,7 @@ } // - End loop through events. } + // Compile template data $templateData = array( 'customfieldActive' => apply_filters( 'glm-members-customfields-plugin-active', false ), @@ -365,7 +366,9 @@ 'regUrl' => GLM_MEMBERS_REGISTRATIONS_SITE_BASE_URL.$this->config['settings']['canonical_reg_page'].'/', 'loggedIn' => ( isset( $_SESSION['LoginAccount'] ) ) ? $_SESSION['LoginAccount']: false, 'assetUrl' => GLM_MEMBERS_REGISTRATIONS_PLUGIN_ASSETS_URL, - 'reg_bulletin' => $misc['reg_bulletin'] + 'reg_bulletin' => $misc['reg_bulletin'], + 'states_list' => $this->config['states'], + 'country_list' => $this->config['countries'], ); // echo "
".print_r($templateData,1)."
"; diff --git a/views/admin/ajax/registrantsListExport.html b/views/admin/ajax/registrantsListExport.html index 3235479..b1d7a40 100644 --- a/views/admin/ajax/registrantsListExport.html +++ b/views/admin/ajax/registrantsListExport.html @@ -25,6 +25,11 @@ {if $select.exportTime}Date/Time{/if} {if $select.exportRate}Rate{/if} {if $select.exportStatus}Status{/if} + {if $select.exportCustom && $customFieldHeaders} + {foreach $customFieldHeaders as $header} + {$header} + {/foreach} + {/if} @@ -45,6 +50,11 @@ {if $select.exportTime}{$m.event_time_reformatted}{/if} {if $select.exportRate}{$m.rate_name}{/if} {if $select.exportStatus}{$m.request_status_name}{/if} + {if $select.exportCustom && $customFieldHeaders} + {foreach $m.custom_data as $cData} + {$cData} + {/foreach} + {/if} {/foreach} diff --git a/views/admin/ajax/registrantsListExportCsv.html b/views/admin/ajax/registrantsListExportCsv.html index 5594ecb..a60ba03 100644 --- a/views/admin/ajax/registrantsListExportCsv.html +++ b/views/admin/ajax/registrantsListExportCsv.html @@ -12,6 +12,7 @@ {if $select.exportTime}"Date/Time",{/if} {if $select.exportRate}"Rate",{/if} {if $select.exportStatus}"Status"{/if} +{if $select.exportCustom && $customFieldHeaders}{foreach $customFieldHeaders as $header},"{$header}"{/foreach}{/if} {foreach $registrants as $m} {if $select.exportId}"{$m.id}",{/if} @@ -27,5 +28,6 @@ {if $select.exportTime}"{$m.event_time_reformatted}",{/if} {if $select.exportRate}"{$m.rate_name}",{/if} {if $select.exportStatus}"{$m.request_status_name}"{/if} +{if $select.exportCustom && $customFieldHeaders}{foreach $m.custom_data as $cData},"{$cData}"{/foreach}{/if} {/foreach} {else}No {$terms.reg_term_attendee_plur_cap} Selected{/if} diff --git a/views/admin/registrations/eventRegistrants.html b/views/admin/registrations/eventRegistrants.html index 16000b6..ced4aaa 100644 --- a/views/admin/registrations/eventRegistrants.html +++ b/views/admin/registrations/eventRegistrants.html @@ -121,6 +121,9 @@ Date/Time
Rate
Status
+ {if apply_filters('glm-members-customfields-plugin-active', false)} + Custom Fields
+ {/if} diff --git a/views/front/registrations/registration.html b/views/front/registrations/registration.html index 4c23429..81b85fc 100644 --- a/views/front/registrations/registration.html +++ b/views/front/registrations/registration.html @@ -45,7 +45,7 @@ {/if} - {if $regEvent.locations.name || $regEvent.locations.address} + {if isset( $regEvent.locations ) && ( $regEvent.locations.name || $regEvent.locations.address )}
{$regEvent.locations.name} {if $regEvent.locations.address} @@ -62,7 +62,7 @@ {if $regEvent.contact_email}
Email: {$regEvent.contact_email}
{/if}
{/if} - {if $regEvent.locations.lat && $regEvent.locations.lon} + {if isset( $regEvent.locations ) && ( $regEvent.locations.lat && $regEvent.locations.lon )}
(map loads here)
@@ -106,36 +106,36 @@

Event Description

{$regEvent.eventDescr} -
+
{if $regEvent.eventDescr|count_characters:true > 280}
Read More
{/if}
- + {/if} {if $regEvent.descr}

Registration Details

{$regEvent.descr} -
+
{if $regEvent.descr|count_characters:true > 280}
Read More
{/if} - + {/if} {if $regEvent.terms}

Terms & Condtions

{$regEvent.terms} -
+
{if $regEvent.terms|count_characters:true > 280}
Read More
{/if} - + {/if} {literal} @@ -254,7 +254,16 @@
State
-
+
+ +
Zip/Postal Code
@@ -262,7 +271,16 @@
Country
-
+
+ +
{/literal}{if $regEvent.time_specific.value} @@ -321,7 +339,16 @@
State
-
+
+ +
Zip/Postal Code
@@ -329,7 +356,16 @@
Country
-
+
+ +
{/literal}{if $regEvent.time_specific.value} @@ -458,53 +494,55 @@ jQuery(function($){ regEvent.setClassRegistrants( {$regJSON} ); var glmApp = new app.Views.Front.App(); - $("#glm-reg-detail-map-button").click(function() { - var map_container = "#glm-reg-map-container"; - var map = "#glm-reg-map"; - var mapNewH = 0; - var mapOverflow = 'hidden'; - var mapBtnTxt = 'view map'; + {if $regEvent.locations} + $("#glm-reg-detail-map-button").click(function() { + var map_container = "#glm-reg-map-container"; + var map = "#glm-reg-map"; + var mapNewH = 0; + var mapOverflow = 'hidden'; + var mapBtnTxt = 'view map'; - if ($(map_container).height() == 0) { - mapNewH = 250; - mapV = 'visible'; - mapBtnTxt = 'hide map' - } - $(map_container).animate({ - overflow: mapOverflow, - height: mapNewH - }, 250, "swing", function() { + if ($(map_container).height() == 0) { + mapNewH = 250; + mapV = 'visible'; + mapBtnTxt = 'hide map' + } + $(map_container).animate({ + overflow: mapOverflow, + height: mapNewH + }, 250, "swing", function() { + }); + $(this).html(mapBtnTxt); }); - $(this).html(mapBtnTxt); - }); - {if $regEvent.locations.lat !=0 && $regEvent.locations.lon != 0} - var eventlocation = new google.maps.LatLng({$regEvent.locations.lat}, {$regEvent.locations.lon}); - {else} - var eventlocation = new google.maps.LatLng({$settings.maps_default_lat}, {$settings.maps_default_lon}); - {/if} - function initMap() { - // Set default - Need to make this configurable - var map = new google.maps.Map(document.getElementById('glm-reg-map'), { - zoom: {$settings.maps_default_zoom}, - center: eventlocation, - disableDefaultUI: false, - mapTypeId: google.maps.MapTypeId.MAP, - }); - - // Create a marker for this event {if $regEvent.locations.lat !=0 && $regEvent.locations.lon != 0} - var marker = new google.maps.Marker({ - map: map, - position: new google.maps.LatLng({$regEvent.locations.lat}, {$regEvent.locations.lon}), - draggable: false, - animation: google.maps.Animation.DROP, - title: '' - }); - {/if} + var eventlocation = new google.maps.LatLng({$regEvent.locations.lat}, {$regEvent.locations.lon}); + {else} + var eventlocation = new google.maps.LatLng({$settings.maps_default_lat}, {$settings.maps_default_lon}); + {/if} + function initMap() { + // Set default - Need to make this configurable + var map = new google.maps.Map(document.getElementById('glm-reg-map'), { + zoom: {$settings.maps_default_zoom}, + center: eventlocation, + disableDefaultUI: false, + mapTypeId: google.maps.MapTypeId.MAP, + }); + + // Create a marker for this event + {if $regEvent.locations.lat !=0 && $regEvent.locations.lon != 0} + var marker = new google.maps.Marker({ + map: map, + position: new google.maps.LatLng({$regEvent.locations.lat}, {$regEvent.locations.lon}), + draggable: false, + animation: google.maps.Animation.DROP, + title: '' + }); + {/if} - } - google.maps.event.addDomListener(window, 'load', initMap); + } + google.maps.event.addDomListener(window, 'load', initMap); + {/if} jQuery("#MemberDrivingDirectionsForm").submit(function(){ var place = jQuery("#MemberLocation").val().replace( new RegExp( " ", "g" ), '+' ); var lat = jQuery("#MemberLat").val(); @@ -537,7 +575,7 @@ jQuery(function($){ $(descr).css("overflow", "hidden"); }) } - + }); }); -- 2.17.1