From c5804acdcf292d1950cb911dffe3873d0b6344c4 Mon Sep 17 00:00:00 2001 From: Steve Sutton Date: Tue, 9 Jan 2018 11:15:24 -0500 Subject: [PATCH] Updating the Register Account form and adding to checkout summary. Update the form to use foundation grid. Update the model to do an update of the account used for the registration. --- .../front/registrations/checkoutProcess.php | 131 ++++++++------- models/front/registrations/register.php | 157 +++++++++--------- views/front/registrations/register.html | 118 ++++++++----- views/front/registrations/summary.html | 109 +++++++++++- 4 files changed, 336 insertions(+), 179 deletions(-) diff --git a/models/front/registrations/checkoutProcess.php b/models/front/registrations/checkoutProcess.php index e32f254..3dbeee3 100644 --- a/models/front/registrations/checkoutProcess.php +++ b/models/front/registrations/checkoutProcess.php @@ -414,16 +414,16 @@ class GlmMembersFront_registrations_checkoutProcess extends GlmRegCartSupport $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'] + '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) { @@ -435,14 +435,14 @@ class GlmMembersFront_registrations_checkoutProcess extends GlmRegCartSupport } $payment = array( - 'name' => $this->config['settings']['reg_org_name'], // Name of venue - 'charge' => $this->cart['totalCharges'], // Total charges this venue - 'cctype' => $cardData['cc_type'], // Card Type - 'ccname' => $cardData['cc_name'], // Name on Card - 'ccnumb' => $cardData['cc_numb'], // Card Number - 'ccexp' => $cardData['cc_exp'], // Expriation Date - 'cccode' => $cardData['cc_cvv'], // CCV - security code - 'invoice' => 0101010101 // Invoice # is session ID (or some part thereof) + 'name' => $this->config['settings']['reg_org_name'], // Name of venue + 'charge' => $this->cart['totalCharges'], // Total charges this venue + 'cctype' => $cardData['cc_type'], // Card Type + 'ccname' => $cardData['cc_name'], // Name on Card + '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) ); // Now try to run the card processor @@ -490,18 +490,18 @@ class GlmMembersFront_registrations_checkoutProcess extends GlmRegCartSupport $reqData = array_merge( $reqData, array( - 'bill_fname' => $billing['fname'], - 'bill_lname' => $billing['lname'], - 'bill_org' => $regAccount['fieldData']['org'], - 'bill_title' => $regAccount['fieldData']['title'], - 'bill_addr1' => $billing['addr1'], - 'bill_addr2' => $billing['addr2'], - 'bill_city' => $billing['city'], - 'bill_state' => $billing['state'], - 'bill_zip' => $billing['zip'], - 'bill_country' => $billing['country'], - 'bill_phone' => $billing['phone'], - 'bill_phone' => $regAccount['fieldData']['email'] + 'bill_fname' => $billing['fname'], + 'bill_lname' => $billing['lname'], + 'bill_org' => $regAccount['fieldData']['org'], + 'bill_title' => $regAccount['fieldData']['title'], + 'bill_addr1' => $billing['addr1'], + 'bill_addr2' => $billing['addr2'], + 'bill_city' => $billing['city'], + 'bill_state' => $billing['state'], + 'bill_zip' => $billing['zip'], + 'bill_country' => $billing['country'], + 'bill_phone' => $billing['phone'], + 'bill_phone' => $regAccount['fieldData']['email'] ) ); $reqFormat = array_merge( @@ -528,12 +528,12 @@ class GlmMembersFront_registrations_checkoutProcess extends GlmRegCartSupport $reqData = array_merge( $reqData, array( - 'date_submitted' => $now, - 'pay_method' => $payMethod, - 'status' => $cartStatus, - 'total' => $payment['charge'], - 'total_discounts' => $this->cart['totalDiscounts'], - 'registrants' => $this->cart['totalRegistrants'] + 'date_submitted' => $now, + 'pay_method' => $payMethod, + 'status' => $cartStatus, + 'total' => $payment['charge'], + 'total_discounts' => $this->cart['totalDiscounts'], + 'registrants' => $this->cart['totalRegistrants'] ) ); $reqFormat = array_merge( @@ -556,12 +556,12 @@ class GlmMembersFront_registrations_checkoutProcess extends GlmRegCartSupport // User Trace data $trace = array( - 'DateTime' => date('r'), - 'UserAddr' => $_SERVER['REMOTE_ADDR'], // IP address of user's computer - 'URI' => $_SERVER['REQUEST_URI'], // URI submitted to checkout - 'UserAgent' => $_SERVER['HTTP_USER_AGENT'], // User's browser user agent string - 'Referrer' => $_SERVER['HTTP_REFERER'], // Page user came from, should be our checkout page - 'Method' => $_SERVER['REQUEST_METHOD'] // Request method: GET, POST, ... + 'DateTime' => date('r'), + 'UserAddr' => $_SERVER['REMOTE_ADDR'], // IP address of user's computer + 'URI' => $_SERVER['REQUEST_URI'], // URI submitted to checkout + 'UserAgent' => $_SERVER['HTTP_USER_AGENT'], // User's browser user agent string + 'Referrer' => $_SERVER['HTTP_REFERER'], // Page user came from, should be our checkout page + 'Method' => $_SERVER['REQUEST_METHOD'] // Request method: GET, POST, ... ); $reqData['user_trace_info'] = serialize($trace); $reqFormat[] = '%s'; @@ -575,11 +575,11 @@ class GlmMembersFront_registrations_checkoutProcess extends GlmRegCartSupport $reqData = array_merge( $reqData, array( - 'cc_type' => $payment['cctype'], - 'cc_name' => $payment['ccname'], - 'cc_numb' => $cc_numb_store, - 'cc_exp' => $payment['ccexp'], - 'cc_conf' => $ccConfirmation, + 'cc_type' => $payment['cctype'], + 'cc_name' => $payment['ccname'], + 'cc_numb' => $cc_numb_store, + 'cc_exp' => $payment['ccexp'], + 'cc_conf' => $ccConfirmation, ) ); $reqFormat = array_merge( @@ -641,13 +641,13 @@ class GlmMembersFront_registrations_checkoutProcess extends GlmRegCartSupport $view = 'checkout'; $templateData = array( - 'request' => array('page' => 'checkout'), - 'haveMessages' => count($messages), - 'messages' => $messages, - 'regAccount' => $regAccount, - 'regPayment' => $regPayment, - 'payMethod' => $payMethod, - 'cardData' => $cardData, + 'request' => array('page' => 'checkout'), + 'haveMessages' => count($messages), + 'messages' => $messages, + 'regAccount' => $regAccount, + 'regPayment' => $regPayment, + 'payMethod' => $payMethod, + 'cardData' => $cardData, ); return array( 'status' => true, @@ -664,12 +664,12 @@ class GlmMembersFront_registrations_checkoutProcess extends GlmRegCartSupport // Produce HTML for storage and checkout page and add to request $summaryData = array( - 'cart' => $this->cart, - 'request' => $request, - 'account' => $account, - 'payMethodsNumb' => $this->config['payment_method_numb'], - 'status' => $this->config['submission_status'], - 'misc' => $misc + 'cart' => $this->cart, + 'request' => $request, + 'account' => $account, + 'payMethodsNumb' => $this->config['payment_method_numb'], + 'status' => $this->config['submission_status'], + 'misc' => $misc ); $summary = $this->generateHTML($summaryData, 'front/registrations/summaryStore.html'); $updated = $this->wpdb->update( @@ -710,10 +710,13 @@ class GlmMembersFront_registrations_checkoutProcess extends GlmRegCartSupport // Compile template data $templateData = array( - 'guestAccount' => $guestAccount, - 'requestId' => $requestId, - 'summaryCheck' => $summaryCheck, - 'misc' => $misc + 'guestAccount' => $guestAccount, + 'requestId' => $requestId, + 'summaryCheck' => $summaryCheck, + 'misc' => $misc, + 'reg_account_id' => $accountId, + 'states_list' => $this->config['states'], + 'country_list' => $this->config['countries'], ); // Return status, any suggested view, and any data to controller diff --git a/models/front/registrations/register.php b/models/front/registrations/register.php index be7e494..765c403 100644 --- a/models/front/registrations/register.php +++ b/models/front/registrations/register.php @@ -1,7 +1,7 @@ date('Y-m-d'), + 'active' => 1, + 'email' => $email, + 'password' => password_hash($password, PASSWORD_DEFAULT), + 'fname' => $fname, + 'lname' => $lname, + 'addr1' => $addr1, + 'addr2' => $addr2, + 'city' => $city, + 'state' => $state, + 'zip' => $zip, + 'country' => $country, + ); + $account_id = (isset($_REQUEST['reg_account_id'])) ? filter_var( $_REQUEST['reg_account_id'], FILTER_VALIDATE_INT ): ''; + $this->wpdb->update( + GLM_MEMBERS_REGISTRATIONS_PLUGIN_DB_PREFIX . 'account', + $accountData, + array( 'id' => $account_id), + '%s', + '%d' + ); + // Add the user to the php session + $_SESSION['LoginAccount'] = array( + 'id' => $account_id, + 'email' => $email, + 'fname' => $fname, + 'lname' => $lname, + ); + // Redirect to the start of registrations. + $modelRedirect = 'index'; + $_REQUEST['page'] = 'list'; + break; case 'submit': - // Filter the form variables for use in db insert. - $email = filter_var( $_REQUEST['email'], FILTER_VALIDATE_EMAIL ); - $password = filter_var( $_REQUEST['password'], FILTER_SANITIZE_STRING ); - $fname = filter_var( $_REQUEST['fname'], FILTER_SANITIZE_STRING ); - $lname = filter_var( $_REQUEST['lname'], FILTER_SANITIZE_STRING ); - $addr1 = filter_var( $_REQUEST['addr1'], FILTER_SANITIZE_STRING ); - $addr2 = filter_var( $_REQUEST['addr2'], FILTER_SANITIZE_STRING ); - $city = filter_var( $_REQUEST['city'], FILTER_SANITIZE_STRING ); - $state = filter_var( $_REQUEST['state'], FILTER_SANITIZE_STRING ); - $zip = filter_var( $_REQUEST['zip'], FILTER_SANITIZE_STRING ); - $country = filter_var( $_REQUEST['country'], FILTER_SANITIZE_STRING ); - if ( $email ) { - // Check to see if we have an account with that email already. - $accountId = $this->wpdb->get_var( - $this->wpdb->prepare( - "SELECT id - FROM " . GLM_MEMBERS_REGISTRATIONS_PLUGIN_DB_PREFIX . "account - WHERE email = %s", - $email - ) - ); - if ( $accountId ) { - // Already an account with that email address - $emailError = 'Already an account with that email address!'; - // Setup $reg variable for the template form data. - $reg = array( - 'fname' => $fname, - 'lname' => $lname, - 'addr1' => $addr1, - 'addr2' => $addr2, - 'city' => $city, - 'state' => $state, - 'zip' => $zip, - 'country' => $country, - ); - break; - } - // If they reach here then create a new account record - $this->wpdb->insert( - GLM_MEMBERS_REGISTRATIONS_PLUGIN_DB_PREFIX . 'account', - array( - 'date_created' => date('Y-m-d'), - 'active' => 1, - 'email' => $email, - 'password' => password_hash($password, PASSWORD_DEFAULT), - 'fname' => $fname, - 'lname' => $lname, - 'addr1' => $addr1, - 'addr2' => $addr2, - 'city' => $city, - 'state' => $state, - 'zip' => $zip, - 'country' => $country, - ), - '%s' - ); - $accountId = $this->wpdb->insert_id; - // Add the user to the php session - $_SESSION['LoginAccount'] = array( - 'id' => $accountId, - 'email' => $email, - 'fname' => $fname, - 'lname' => $lname, - ); - // Redirect to the start of registrations. - $modelRedirect = 'index'; - $_REQUEST['page'] = 'list'; - } + $this->wpdb->insert( + GLM_MEMBERS_REGISTRATIONS_PLUGIN_DB_PREFIX . 'account', + array( + 'date_created' => date('Y-m-d'), + 'active' => 1, + 'email' => $email, + 'password' => password_hash($password, PASSWORD_DEFAULT), + 'fname' => $fname, + 'lname' => $lname, + 'addr1' => $addr1, + 'addr2' => $addr2, + 'city' => $city, + 'state' => $state, + 'zip' => $zip, + 'country' => $country, + ), + '%s' + ); + $accountId = $this->wpdb->insert_id; + // Add the user to the php session + $_SESSION['LoginAccount'] = array( + 'id' => $accountId, + 'email' => $email, + 'fname' => $fname, + 'lname' => $lname, + ); + // Redirect to the start of registrations. + $modelRedirect = 'index'; + $_REQUEST['page'] = 'list'; break; default: break; @@ -134,11 +141,13 @@ // Compile template data $templateData = array( - 'page' => 'register', - 'reg' => $reg, - 'emailError' => $emailError, - 'regUrl' => GLM_MEMBERS_REGISTRATIONS_SITE_BASE_URL.$this->config['settings']['canonical_reg_page'].'/', - 'loggedIn' => ( isset( $_SESSION['LoginAccount'] ) ) ? $_SESSION['LoginAccount']: false, + 'page' => 'register', + 'reg' => $reg, + 'emailError' => $emailError, + 'regUrl' => GLM_MEMBERS_REGISTRATIONS_SITE_BASE_URL.$this->config['settings']['canonical_reg_page'].'/', + 'loggedIn' => ( isset( $_SESSION['LoginAccount'] ) ) ? $_SESSION['LoginAccount']: false, + 'states_list' => $this->config['states'], + 'country_list' => $this->config['countries'], ); // Return status, any suggested view, and any data to controller return array( diff --git a/views/front/registrations/register.html b/views/front/registrations/register.html index 326be46..e81db52 100644 --- a/views/front/registrations/register.html +++ b/views/front/registrations/register.html @@ -4,61 +4,99 @@ -
-
-
+
+
-

Register New Account

-
-
+

Register New Account

+
+
* Required Fields
+
+
+
+
-
-
+ +
-
-
+
+
-
+ +
-
-
-
+
+
+
+
-
-
-
+
+ +
-
-
-
+
+
+
+
-
-
-
+
+
-
-
-
+
+
+
+
-
-
-
+
+
-
-
-
+
+
-
-
-
+
+
+
+
-
-
+
+
+
+
-
+
diff --git a/views/front/registrations/summary.html b/views/front/registrations/summary.html index 2cc3961..26b7899 100644 --- a/views/front/registrations/summary.html +++ b/views/front/registrations/summary.html @@ -19,8 +19,115 @@
{/if} +{if $guestAccount} + Please take the time now to create an account. + +
+ + + + +
+
+ +

Register New Account

+
+
* Required Fields
+
+
+
+ +
+
+ +
+
+
+
+ +
+
+ + +
+
+
+
+ +
+
+ +
+
+
+
+ +
+
+ +
+
+ +
+
+
+
+ +
+
+
+
+ +
+
+ +
+
+ +
+ {/if} +
-