From 76786652b2180f22a586eb10f3011bcb99a07891 Mon Sep 17 00:00:00 2001 From: Steve Sutton Date: Thu, 5 Oct 2017 14:43:21 -0400 Subject: [PATCH] Bring in edit form for registrant Not sure about this placement though. Might have to move it out. --- css/front.css | 18 +++++++++++++++ js/frontRegApp.js | 6 ++--- js/models/front/regRequestRegistrant.js | 1 + js/views/front/regRequestRegistrant.js | 5 ++--- models/front/registrations/registration.php | 25 ++++++++++++++++++++- views/front/registrations/registration.html | 25 +++++++++++++++++++++ 6 files changed, 73 insertions(+), 7 deletions(-) diff --git a/css/front.css b/css/front.css index fe5d0aa..b03bc59 100644 --- a/css/front.css +++ b/css/front.css @@ -192,3 +192,21 @@ div.glm-reg-register input.error { #reg-select-time { width: 150px; } +.reg-edit-form { + display: none; +} +.reg-edit-form .reg_fname, +.reg-edit-form .reg_lname, +.reg-edit-form .reg_addr1, +.reg-edit-form .reg_addr2, +.reg-edit-form .reg_city, +.reg-edit-form .reg_state, +.reg-edit-form .reg_zip, +.reg-edit-form .reg_country { + width: 46%; + margin-right: 1rem; + float: left; +} +.reg-edit-form .reg_email { + width: 96%; +} diff --git a/js/frontRegApp.js b/js/frontRegApp.js index e1dbbd5..8159b58 100644 --- a/js/frontRegApp.js +++ b/js/frontRegApp.js @@ -226,6 +226,7 @@ app.Models.Front.RegRequestRegistrant = Backbone.Model.extend({ reg_class: 0, event_name: '', reg_time: 0, + reg_time_text: '', event_datetime: '', reg_request: 0, reg_request_event: 0, @@ -931,14 +932,13 @@ app.Views.Front.RegRequestRegistrant = Backbone.View.extend({ events: { 'click .glm-reg-level-registrant-delete': 'deleteOne', - 'click .glm-registrant-edit': 'editRegistrant', + //'click .glm-registrant-edit': 'editRegistrant', }, editRegistrant: function(){ console.log( 'Edit called' ); console.log( this.model ); - // this.editRegAccountView = new app.Views.Front.RegistrantForm({model: this.model}); - + this.$('.reg-edit-form').show(); }, render: function(){ diff --git a/js/models/front/regRequestRegistrant.js b/js/models/front/regRequestRegistrant.js index d8ef556..605d14f 100644 --- a/js/models/front/regRequestRegistrant.js +++ b/js/models/front/regRequestRegistrant.js @@ -7,6 +7,7 @@ app.Models.Front.RegRequestRegistrant = Backbone.Model.extend({ reg_class: 0, event_name: '', reg_time: 0, + reg_time_text: '', event_datetime: '', reg_request: 0, reg_request_event: 0, diff --git a/js/views/front/regRequestRegistrant.js b/js/views/front/regRequestRegistrant.js index 07a670c..ff36513 100644 --- a/js/views/front/regRequestRegistrant.js +++ b/js/views/front/regRequestRegistrant.js @@ -12,14 +12,13 @@ app.Views.Front.RegRequestRegistrant = Backbone.View.extend({ events: { 'click .glm-reg-level-registrant-delete': 'deleteOne', - 'click .glm-registrant-edit': 'editRegistrant', + //'click .glm-registrant-edit': 'editRegistrant', }, editRegistrant: function(){ console.log( 'Edit called' ); console.log( this.model ); - // this.editRegAccountView = new app.Views.Front.RegistrantForm({model: this.model}); - + this.$('.reg-edit-form').show(); }, render: function(){ diff --git a/models/front/registrations/registration.php b/models/front/registrations/registration.php index 4496517..0623890 100644 --- a/models/front/registrations/registration.php +++ b/models/front/registrations/registration.php @@ -147,7 +147,7 @@ 'terms' => $regEvent['terms'], ); - echo '
$event: ' . print_r( $event, true ) . '
'; + // echo '
$event: ' . print_r( $event, true ) . '
'; break; } @@ -198,6 +198,21 @@ foreach ( $class['rates'] as $rate ) { if ( isset( $rate['registrants'] ) && is_array( $rate['registrants'] ) ) { foreach ( $rate['registrants'] as $registrant ) { + $accountData = array(); + // If there's an account id get data for the account. + if ( isset( $registrant['account'] ) && filter_var( $registrant['account'], FILTER_VALIDATE_INT ) ) { + $accountData = $this->wpdb->get_row( + $this->wpdb->prepare( + "SELECT fname,lname,email,addr1,addr2,city,state,zip,country + FROM " . GLM_MEMBERS_REGISTRATIONS_PLUGIN_DB_PREFIX . "account + WHERE id = %d", + $registrant['account'] + ), + ARRAY_A + ); + // echo '
$accountData:  ' . print_r( $accountData , true ) . '
'; + } + // Need to know the class id for the registrant $classId = $this->wpdb->get_var( $this->wpdb->prepare( @@ -218,6 +233,13 @@ ); $registrant['class_id'] = $classId; $registrant['email'] = $email; + $registrant['addr1'] = $accountData['addr1']; + $registrant['addr2'] = $accountData['addr2']; + $registrant['city'] = $accountData['city']; + $registrant['state'] = $accountData['state']; + $registrant['zip'] = $accountData['zip']; + $registrant['country'] = $accountData['country']; + // echo '
$registrant: ' . print_r( $registrant, true ) . '
'; $registrants[] = $registrant; } } @@ -227,6 +249,7 @@ } } } + // echo '
$registrants: ' . print_r( $registrants, true ) . '
'; // Compile template data $templateData = array( diff --git a/views/front/registrations/registration.html b/views/front/registrations/registration.html index 07096f2..7d3c694 100644 --- a/views/front/registrations/registration.html +++ b/views/front/registrations/registration.html @@ -155,6 +155,31 @@ {/literal}
-- 2.17.1