From f3acc51fb91f0164ead9eacc0ecd937a846dc026 Mon Sep 17 00:00:00 2001 From: Chuck Scott Date: Tue, 13 Feb 2018 15:16:10 -0500 Subject: [PATCH] Continuing on final front-end testing and cleanup Added use of terms in cartSummary.html. Fixed missing date for "First Event Time" in reg event dashboard. Fixed warnings and undefines in list.html - Need to stop using recurrences for this! Fixed undefined for "locations" in registration.html. Fixed layout and text problems with level headed in registration registration.html Commented out payment methods from plugin.ini: Comp Code, Call from Merchant, Paypal Updated defaults for payment methods in dataRegEvent.php Now checking for admin users when selecting payment methods in regCartSupport.php Reorganized Payment Method selection and better method checking in checkout.html Fixed possible problem with default payment method selection Edited description comment for Credit Card fields in create_database...sql --- classes/data/dataRegEvent.php | 6 +- classes/regCartSupport.php | 8 +- config/plugin.ini | 22 +-- models/front/registrations/checkout.php | 23 ++- .../front/registrations/checkoutProcess.php | 85 ++++++---- .../create_database_V0.0.25.sql | 4 +- views/admin/registrations/eventDashboard.html | 4 +- views/front/registrations/cartSummary.html | 24 +-- views/front/registrations/checkout.html | 148 ++++++++++-------- views/front/registrations/list.html | 8 +- views/front/registrations/registration.html | 10 +- 11 files changed, 195 insertions(+), 147 deletions(-) diff --git a/classes/data/dataRegEvent.php b/classes/data/dataRegEvent.php index e4109f2..3203d97 100644 --- a/classes/data/dataRegEvent.php +++ b/classes/data/dataRegEvent.php @@ -259,11 +259,11 @@ class GlmDataRegistrationsRegEvent extends GlmDataAbstract 'field' => 'payment_methods', 'type' => 'bitmap', 'bitmap' => $this->config['payment_method'], - 'default' => 68, + 'default' => 64, 'use' => 'a' ), - // Bitmap of restricted (admin use only) payment methods for this event - see paymenttrue_method + // Bitmap of payment methods for use with admin users in the front-end 'restricted_payment_methods' => array ( 'field' => 'restricted_payment_methods', 'type' => 'bitmap', @@ -363,7 +363,7 @@ class GlmDataRegistrationsRegEvent extends GlmDataAbstract // echo '
$eventData: ' . print_r( $eventData, true ) . '
'; - // Add to the registration event arraytrue + // Add to the registration event array $result_data['intro'] = $eventData['intro']; $result_data['eventDescr'] = $eventData['descr']; $result_data['image'] = $eventData['image']; diff --git a/classes/regCartSupport.php b/classes/regCartSupport.php index d04883d..2bbe205 100644 --- a/classes/regCartSupport.php +++ b/classes/regCartSupport.php @@ -230,9 +230,13 @@ class GlmRegCartSupport if ($this->cart['events']) { foreach ($this->cart['events'] as $eventKey => $event) { - // Get accepted payment methods + // Get accepted payment methods. If admin user use restricted payment methods $e = $RegEvent->getEntry($event['reg_event']); - $this->cart['events'][$eventKey]['payment_methods'] = $e['payment_methods']; + if (is_user_logged_in() && apply_filters('glm_members_menu_members', true)) { + $this->cart['events'][$eventKey]['payment_methods'] = $e['restricted_payment_methods']; + } else { + $this->cart['events'][$eventKey]['payment_methods'] = $e['payment_methods']; + } // If custom fields add-on is installed - get custom fields data if (apply_filters('glm-members-customfields-plugin-active', false)) { diff --git a/config/plugin.ini b/config/plugin.ini index c110be1..57ed5b7 100644 --- a/config/plugin.ini +++ b/config/plugin.ini @@ -31,20 +31,22 @@ registration_account_option_numb['Member'] = 3 ; Payment Method - Use as Bitmap Index or List ; payment_method[1] = 'No Charge' -payment_method[2] = 'Comp Code' +payment_method[2] = 'Pay On Arrival' payment_method[3] = 'Cash' payment_method[4] = 'Check' -payment_method[5] = 'Call from Merchant' +; payment_method[5] = 'Call from Merchant' payment_method[6] = 'Credit Card' -payment_method[7] = 'PayPal' +; payment_method[7] = 'PayPal' +payment_method [10] = 'Payment Pending' payment_method_numb['NoCharge'] = 1 -payment_method_numb['CompCode'] = 2 +payment_method_numb['OnArrival'] = 2 payment_method_numb['Cash'] = 3 payment_method_numb['Check'] = 4 -payment_method_numb['CallFromMerchant'] = 5 +; payment_method_numb['CallFromMerchant'] = 5 payment_method_numb['CreditCard'] = 6 -payment_method_numb['PayPal'] = 7 +; payment_method_numb['PayPal'] = 7 +payment_method_numb['Pending'] = 10 ; Default payment method is Credit Card default_payment_method = 6 @@ -201,8 +203,8 @@ submission_status[10] = 'COMPLETE' submission_status[20] = 'UNPAID' submission_status[30] = 'CC_PEND' submission_status[40] = 'CC_DECL' -submission_status[50] = 'CHECK_PEND' -submission_status[60] = 'AT_EVENT' +submission_status[50] = 'PAYMENT_PEND' +submission_status[60] = 'ON ARRIVAL' submission_status[70] = 'ADMIN HOLD' submission_status[80] = 'FAILED' submission_status[99] = 'CANCELED' @@ -212,8 +214,8 @@ submission_status_numb['COMPLETE'] = 10 submission_status_numb['UNPAID'] = 20 submission_status_numb['CC_PEND'] = 30 submission_status_numb['CC_DECL'] = 40 -submission_status_numb['CHECK_PEND'] = 50 -submission_status_numb['AT_EVENT'] = 60 +submission_status_numb['PAYMENT_PEND'] = 50 +submission_status_numb['ON_ARRIVAL'] = 60 submission_status_numb['ADMIN_HOLD'] = 70 submission_status_numb['FAILED'] = 80 submission_status_numb['CANCELED'] = 99 diff --git a/models/front/registrations/checkout.php b/models/front/registrations/checkout.php index c95c452..7f7dd4e 100644 --- a/models/front/registrations/checkout.php +++ b/models/front/registrations/checkout.php @@ -254,18 +254,31 @@ class GlmMembersFront_registrations_checkout extends GlmRegCartSupport $Management = new GlmDataRegistrationsManagement($this->wpdb, $this->config); $management = $Management->getEntry(1); - // Get accepted pay methods and block out any not selected for an event + // Get all payment methods and assume they might all be available $availPaymentMethods = $management['reg_payment_methods']['bitmap']; + foreach ($availPaymentMethods as $methKey=>$methVal) { + $availPaymentMethods[$methKey]['default'] = true; + } + + // For each event in cart, check each payment method. Only methods enabled in all events are available. foreach ($this->cart['events'] as $event) { foreach ($event['payment_methods']['bitmap'] as $payMethodKey=>$payMethodVal) { - if (!$payMethodVal['default']) { - $availPaymentMethods[$payMethodKey]['default'] = 0; + + // If this one isn't set for event, remove it from the list + if (!$payMethodVal['default'] && isset($availPaymentMethods[$payMethodKey])) { + unset($availPaymentMethods[$payMethodKey]); } } } - // Set default payment method - $payMethod = $this->config['default_payment_method']; + // If there's only one payment method, make that the selcted method + if (count($availPaymentMethods) == 1) { + $payMethod = key($availPaymentMethods); + + // Otherwise use default payment method - Note that it might not be available. + } else { + $payMethod = $this->config['default_payment_method']; + } // Get any payment method specified or selected on checkout attempt if (isset($actionData['payMethod'])) { diff --git a/models/front/registrations/checkoutProcess.php b/models/front/registrations/checkoutProcess.php index 5feedc6..fb58242 100644 --- a/models/front/registrations/checkoutProcess.php +++ b/models/front/registrations/checkoutProcess.php @@ -314,27 +314,79 @@ class GlmMembersFront_registrations_checkoutProcess extends GlmRegCartSupport $payMethod = false; } + // Check if Billing data source fields + $billPrefix = 'bill_'; + if (isset($_REQUEST['billing_same']) && $_REQUEST['billing_same']) { + $billPrefix = ''; + } + $billing = array( + 'fname' => $regAccount['fieldData'][$billPrefix.'fname'], + 'lname' => $regAccount['fieldData'][$billPrefix.'lname'], + 'addr1' => $regAccount['fieldData'][$billPrefix.'addr1'], + 'addr2' => $regAccount['fieldData'][$billPrefix.'addr2'], + 'city' => $regAccount['fieldData'][$billPrefix.'city'], + 'state' => $regAccount['fieldData'][$billPrefix.'state']['value'], + 'country' => $regAccount['fieldData'][$billPrefix.'country']['value'], + 'zip' => $regAccount['fieldData'][$billPrefix.'zip'], + 'phone' => $regAccount['fieldData'][$billPrefix.'phone'], + 'email' => $regAccount['fieldData']['email'] + ); + // Execute selected payment method switch ($payMethod) { + /* + submission_status_numb['CART'] = 0 + submission_status_numb['COMPLETE'] = 10 + submission_status_numb['UNPAID'] = 20 + submission_status_numb['CC_PEND'] = 30 + submission_status_numb['CC_DECL'] = 40 + submission_status_numb['PAYMENT_PEND'] = 50 + submission_status_numb['ON_ARRIVAL'] = 60 + submission_status_numb['ADMIN_HOLD'] = 70 + submission_status_numb['FAILED'] = 80 + submission_status_numb['CANCELED'] = 99 + */ + // No Charge case $this->config['payment_method_numb']['NoCharge']: + $cartStatus = $this->config['submission_status_numb']['COMPLETE']; break; - // Comp Code - case $this->config['payment_method_numb']['CompCode']: + // Pay on Arrival + case $this->config['payment_method_numb']['OnArrival']: + $cartStatus = $this->config['submission_status_numb']['PAYMENT_PEND']; break; // Cash case $this->config['payment_method_numb']['Cash']: + $cartStatus = $this->config['submission_status_numb']['COMPLETE']; break; // Check case $this->config['payment_method_numb']['Check']: + + // Get the check input + $cardData = array( + 'cc_name' => filter_input(INPUT_POST, 'cc_name', FILTER_SANITIZE_STRING), // Name on Check + 'cc_numb' => filter_input(INPUT_POST, 'cc_numb', FILTER_SANITIZE_NUMBER_INT) // Check Number + ); + + // Check all credit card input + if ( + $cardData['cc_name'] && $cardData['cc_name'] != '' && // Name on Check + $cardData['cc_numb'] && $cardData['cc_numb'] > 0 // Check Number + ) { + $cartStatus = $this->config['submission_status_numb']['COMPLETE']; + } else { + $messages[] = 'You did not supply all required check information.'; + } + break; - // Call From Merchant - case $this->config['payment_method_numb']['CallFromMerchant']: + // Payment Pending + case $this->config['payment_method_numb']['Pending']: + $cartStatus = $this->config['submission_status_numb']['PAYMENT_PEND']; break; // Credit Card @@ -411,24 +463,6 @@ class GlmMembersFront_registrations_checkoutProcess extends GlmRegCartSupport $messages[] = 'You did not supply all required credit card information.'; } - // Billing data - $billPrefix = 'bill_'; - if (isset($_REQUEST['billing_same']) && $_REQUEST['billing_same']) { - $billPrefix = ''; - } - $billing = array( - 'fname' => $regAccount['fieldData'][$billPrefix.'fname'], - 'lname' => $regAccount['fieldData'][$billPrefix.'lname'], - 'addr1' => $regAccount['fieldData'][$billPrefix.'addr1'], - 'addr2' => $regAccount['fieldData'][$billPrefix.'addr2'], - 'city' => $regAccount['fieldData'][$billPrefix.'city'], - 'state' => $regAccount['fieldData'][$billPrefix.'state']['value'], - 'country' => $regAccount['fieldData'][$billPrefix.'country']['value'], - 'zip' => $regAccount['fieldData'][$billPrefix.'zip'], - 'phone' => $regAccount['fieldData'][$billPrefix.'phone'], - 'email' => $regAccount['fieldData']['email'] - ); - if (count($messages) == 0) { // Determine the directory of the payment processor to load and instatiate it. @@ -445,7 +479,7 @@ class GlmMembersFront_registrations_checkoutProcess extends GlmRegCartSupport 'ccnumb' => $cardData['cc_numb'], // Card Number 'ccexp' => $cardData['cc_exp'], // Expiration Date 'cccode' => $cardData['cc_cvv'], // CCV - security code - 'invoice' => 0101010101 // Invoice # is session ID (or some part thereof) + 'invoice' => 'reg-'.$_SESSION['glm_reg_cart_id'] // Invoice # is "reg-" plus cart ID ); // Now try to run the card processor @@ -458,10 +492,6 @@ class GlmMembersFront_registrations_checkoutProcess extends GlmRegCartSupport // set $ccConfirmation -/**** NEED TO FIX INVOICE # ABOVE ****/ - - - } break; @@ -476,6 +506,7 @@ class GlmMembersFront_registrations_checkoutProcess extends GlmRegCartSupport break; } +exit; /* * Update the reg_request reccord: account id, billing, payment, status, etc... diff --git a/setup/databaseScripts/create_database_V0.0.25.sql b/setup/databaseScripts/create_database_V0.0.25.sql index 08d1c80..5e078c5 100644 --- a/setup/databaseScripts/create_database_V0.0.25.sql +++ b/setup/databaseScripts/create_database_V0.0.25.sql @@ -455,8 +455,8 @@ CREATE TABLE {prefix}reg_request ( total_discounts DOUBLE PRECISION NULL, -- Total of all comps and discounts registrants SMALLINT NULL, -- Total number of registrants in this cart cc_type TINYINT NULL, -- Credit Card type (if used) - See credit_card in plugin.ini - cc_name TINYTEXT NULL, - cc_numb TINYTEXT NULL, + cc_name TINYTEXT NULL, -- Name on Credit Card or Name on Check + cc_numb TINYTEXT NULL, -- Credit Card Number or Check Number cc_exp TINYTEXT NULL, cc_cvv TINYTEXT NULL, cc_conf TINYTEXT NULL, -- Confirmation code back from card processor diff --git a/views/admin/registrations/eventDashboard.html b/views/admin/registrations/eventDashboard.html index 936bbcf..65f8948 100644 --- a/views/admin/registrations/eventDashboard.html +++ b/views/admin/registrations/eventDashboard.html @@ -19,7 +19,7 @@

First {$terms.reg_term_event_cap} Time:

- {$regEvent.first_datetime.datetime} + {$regEventFirstTime.datetime}
@@ -27,7 +27,7 @@

Last {$terms.reg_term_event_cap} Time:

- {$regEvent.last_datetime.datetime} + {$regEventLastTime.datetime}
diff --git a/views/front/registrations/cartSummary.html b/views/front/registrations/cartSummary.html index 98d869f..bc1e5cd 100644 --- a/views/front/registrations/cartSummary.html +++ b/views/front/registrations/cartSummary.html @@ -1,4 +1,4 @@ - +{debug} {if $summaryType=="adminRequest"} {assign var="summaryColumnsItem" value="small-7 "} {assign var="summaryColumnsCharge" value="small-5 "} @@ -8,7 +8,6 @@ {/if}
{foreach $cart.events as $event} -{debug}
@@ -24,7 +23,7 @@
- {$terms.reg_term_attendee_plur_cap}: {$event.eventRegistrants} +
@@ -37,24 +36,12 @@ {foreach $class.rates as $rate}
- {$terms.reg_term_registration_cap} Level: {$class.class_name} + {$terms.reg_term_registration_cap} {$terms.reg_term_level_cap}: {$class.class_name}
{if $rate.rateBaseCharge > 0}{$rate.base_rate_money}{/if}
- - {if $rate.rateBaseCharge > 0} - - {/if} - {foreach $rate.registrants as $registrant}
@@ -69,11 +56,6 @@ (included) {/if}
- - -
{if $registrant.event_attendee_custom_form} diff --git a/views/front/registrations/checkout.html b/views/front/registrations/checkout.html index 7d9f2cd..2c87310 100644 --- a/views/front/registrations/checkout.html +++ b/views/front/registrations/checkout.html @@ -132,76 +132,90 @@
{if $cart.totalCharges > 0} -
-
-

Payment Information

- {foreach $payMethods as $payMethod} - {if $payMethod.default} - - {$pmName = array_search($payMethod.value, $payMethodsNumb)} - {$pmNumb = $payMethodsNumb.{$pmName}} -
- {if $payMethods.{$payMethod.value}.default} - - {if $pmName == "CompCode"} -
-
-
Enter code{if $regAccount.fieldRequired.comp_code} *{/if}
-
- -
-
+
+
+

Payment Information

+
+ {foreach $payMethods as $payMethod} + + {$pmName = array_search($payMethod.value, $payMethodsNumb)} + {$pmNumb = $payMethodsNumb.{$pmName}} +   {$payMethods.{$pmNumb}.name}     + {/foreach} +
+ {foreach $payMethods as $payMethod} + + {$pmName = array_search($payMethod.value, $payMethodsNumb)} + {$pmNumb = $payMethodsNumb.{$pmName}} + + {if $pmName == "NoCharge"} + {* Nothing here for now *} + {else if $pmName == "OnArrival"} + {* Nothing here for now *} + {else if $pmName == "Cash"} + {* Nothing here for now *} + {else if $pmName == "Check"} +
+
+
Name on Check{if $regAccount.fieldRequired.cc_name} *{/if}
+
+
- {else if $pmName == "CreditCard"} - -
-
-
Name on Card{if $regAccount.fieldRequired.cc_name} *{/if}
-
- -
-
-
-
Card Type{if $regAccount.fieldRequired.cc_type} *{/if}
-
- -
-
-
-
Card Number{if $regAccount.fieldRequired.cc_numb} *{/if}
-
- -
-
-
-
Card Expiration{if $regAccount.fieldRequired.cc_exp} *{/if}
-
- -
-
-
-
CVV{if $regAccount.fieldRequired.cc_cvv} *{/if}
-
- -
-
+
+
+
Check Number{if $regAccount.fieldRequired.cc_numb} *{/if}
+
+ +
+
+
+ {else if $pmName == "CreditCard"} +
+
+
Name on Card{if $regAccount.fieldRequired.cc_name} *{/if}
+
+
- {else} -
- +
+
+
Card Type{if $regAccount.fieldRequired.cc_type} *{/if}
+
+ +
+
+
+
Card Number{if $regAccount.fieldRequired.cc_numb} *{/if}
+
+ +
+
+
+
Card Expiration{if $regAccount.fieldRequired.cc_exp} *{/if}
+
+
- {/if} - {/if} - - {/if} {* default is set *} - {/foreach} +
+
+
CVV{if $regAccount.fieldRequired.cc_cvv} *{/if}
+
+ +
+
+
+ {else} +
+ +
+ {/if} + + {/foreach}
{/if} {* / total charges > 0 *} diff --git a/views/front/registrations/list.html b/views/front/registrations/list.html index babe832..94e9201 100644 --- a/views/front/registrations/list.html +++ b/views/front/registrations/list.html @@ -18,9 +18,11 @@ {foreach $regEvents as $event} {assign var=first value = $event.times|@key} {assign var=first_date value = $event.times.$first.start_time.timestamp} - {assign var=last value = $event.reg_time|@end} - {assign var=last_date value = $event.end_datetime} - {assign var=time_specific value = $event.time_specific.value} + + {* these are not in use - !!!Also need to stop using Recurrences here!!!! *} + {* assign var=last value = $event.reg_time|@end *} + {* assign var=last_date value = $event.end_datetime *} + {* assign var=time_specific value = $event.time_specific.value *} diff --git a/views/front/registrations/registration.html b/views/front/registrations/registration.html index 5c4cac2..968ecb0 100644 --- a/views/front/registrations/registration.html +++ b/views/front/registrations/registration.html @@ -85,7 +85,7 @@

Attend any time during event

<% _.each(reg_time, function(rTime){ %> <% if ( rTime.attendee_max > 0 ) { %> -

Maximum Registrants: <%= rTime.attendee_max %>
+

Maximum {/literal}{$terms.reg_term_attendee_plur_cap}{literal}: <%= rTime.attendee_max %>
Currently Available: <%= rTime.attendees_available %>

<% } %> <% }); %> @@ -157,13 +157,13 @@ <%= name %> <% if( reg_rate_base_price ){ %> -
Base Rate: $<%= reg_rate_base_price %>
+
Base Rate: $<%= reg_rate_base_price %>
<% } %> <% if( reg_rate_per_reg ){ %> -
Per Registrant: $<%= reg_rate_per_reg %>
+
Per {/literal}{$terms.reg_term_attendee_cap}{literal}: $<%= reg_rate_per_reg %>
<% } %> <% if( registrant_credits ){ %> -
Per Registrant: $<%= registrant_credits %>
+
{/literal}{$terms.reg_term_attendee_plur_cap}{literal} Included: <%= registrant_credits %>
<% } %>
@@ -527,7 +527,7 @@ jQuery(function($){ regEvent.setClassRegistrants( {$regJSON} ); var glmApp = new app.Views.Front.App(); - {if $regEvent.locations} + {if isset($regEvent.locations) && $regEvent.locations} $("#glm-reg-detail-map-button").click(function() { var map_container = "#glm-reg-map-container"; var map = "#glm-reg-map"; -- 2.17.1