From 9a545bdc3c6f40ab06a8922c438610fe998c25ac Mon Sep 17 00:00:00 2001 From: Steve Sutton Date: Mon, 9 Apr 2018 05:42:03 -0400 Subject: [PATCH] WIP updating renewal form on front end. Updating front end renewal form. --- models/admin/member/billing.php | 25 ++++--- models/front/billing/renew.php | 63 ++++++++++++++-- views/front/billing/renew.html | 128 +------------------------------- 3 files changed, 74 insertions(+), 142 deletions(-) diff --git a/models/admin/member/billing.php b/models/admin/member/billing.php index 5a84bbc..2fbdd8f 100644 --- a/models/admin/member/billing.php +++ b/models/admin/member/billing.php @@ -222,7 +222,6 @@ class GlmMembersAdmin_member_billing // extends GlmDataBilling case 'renewMembership': $error = false; $view = 'renewMembership'; - // $messages[] = '
$_REQUEST: ' . print_r( $_REQUEST, true ) . '
'; $member_invoice_id = $BillingSupport->getMembersInvoiceTypeByRefDest( $this->memberID ); if ( $member_invoice_id ) { @@ -288,13 +287,14 @@ class GlmMembersAdmin_member_billing // extends GlmDataBilling switch ( $payment_option ) { case 'pay_by_credit_card': // Do the Payment Processing. - $errors = $BillingSupport->processMemberRenewal( $accountID, $invoice_id, $invoice_data['amount'], $invoice_data['employees'] ); - // echo '
$errors: ' . print_r( $errors, true ) . '
'; - if ( $errors ) { - // $messages[] = '
$errors: ' . print_r( $errors, true ) . '
'; - if ( count( $errors ) > 0 ) { + $processErrors = $BillingSupport->processMemberRenewal( $accountID, $invoice_id, $invoice_data['amount'], $invoice_data['employees'] ); + // echo '
$processErrors: ' . print_r( $processErrors, true ) . '
'; + if ( $processErrors ) { + // $messages[] = '
$processErrors: ' . print_r( $processErrors, true ) . '
'; + if ( count( $processErrors ) > 0 ) { + $error = true; $BillingSupport->removeInvoiceById( $invoice_id ); - foreach ( $errors as $error ) { + foreach ( $processErrors as $error ) { $messages[] = ''.$error.''; } } @@ -324,11 +324,14 @@ class GlmMembersAdmin_member_billing // extends GlmDataBilling break; } - // Now need to show the invoice. - $view = 'viewInvoice'; + // If there's no error reported then show the invoice + if ( !$error ) { + // Now need to show the invoice. + $view = 'viewInvoice'; - // Get the invoice. - $invoiceHtml = $BillingSupport->viewInvoice( $invoice_id ); + // Get the invoice. + $invoiceHtml = $BillingSupport->viewInvoice( $invoice_id ); + } } diff --git a/models/front/billing/renew.php b/models/front/billing/renew.php index bf8e9cd..1312969 100644 --- a/models/front/billing/renew.php +++ b/models/front/billing/renew.php @@ -213,7 +213,6 @@ class GlmMembersFront_billing_renew // extends GlmDataBilling case 'renewMembership': $error = false; $view = 'renewMembership'; - // $messages[] = '
$_REQUEST: ' . print_r( $_REQUEST, true ) . '
'; $member_invoice_id = $BillingSupport->getMembersInvoiceTypeByRefDest( $this->memberID ); if ( $member_invoice_id ) { @@ -231,7 +230,7 @@ class GlmMembersFront_billing_renew // extends GlmDataBilling 'due_date' => date( 'Y-m-d' ), 'member_invoice' => $member_invoice, 'employee_data' => $employees, - 'employees' => $_REQUEST['employees'] + 'employees' => isset( $_REQUEST['employees'] ) ? $_REQUEST['employees'] : array(), ); if ( !$invoice_data ) { $error = true; @@ -247,7 +246,11 @@ class GlmMembersFront_billing_renew // extends GlmDataBilling // If there's any errors then re-show the form. if ( $error ) { - // TODO: Here we'll need to remove the invoice created if any. + // Remove the invoice created. + if ( $invoice_id ) { + $BillingSupport->removeInvoiceById( $invoice_id ); + } + $view = 'renew'; // Get list of payable invoice_types @@ -269,9 +272,57 @@ class GlmMembersFront_billing_renew // extends GlmDataBilling // Need to see if there's an account for this member. $account = $Accounts->editEntry( $accountID ); } else { - // Do the Payment Processing. - $errors = $BillingSupport->processMemberRenewal( $accountID, $invoice_id, $invoice_data['amount'], $invoice_data['employees'] ); - // echo '
$errors: ' . print_r( $errors, true ) . '
'; + // Look at the payment option given + $payment_option = filter_var( $_REQUEST['payment_option'], FILTER_SANITIZE_STRING ); + + switch ( $payment_option ) { + case 'pay_by_credit_card': + // Do the Payment Processing. + $processErrors = $BillingSupport->processMemberRenewal( $accountID, $invoice_id, $invoice_data['amount'], $invoice_data['employees'] ); + // echo '
$processErrors: ' . print_r( $processErrors, true ) . '
'; + if ( $processErrors ) { + // $messages[] = '
$processErrors: ' . print_r( $processErrors, true ) . '
'; + if ( count( $processErrors ) > 0 ) { + $error = true; + $BillingSupport->removeInvoiceById( $invoice_id ); + foreach ( $processErrors as $error ) { + $messages[] = ''.$error.''; + } + } + $view = 'renew'; + + // Get list of payable invoice_types + $payable_types = $BillingSupport->getAllPayableInvoiceTypes(); + + $member_invoice_id = $BillingSupport->getMembersInvoiceTypeByRefDest( $this->memberID ); + if ( $member_invoice_id ) { + $member_invoice = $BillingSupport->getInvoiceTypeById( $member_invoice_id ); + } + + // Get a list of this accounts employees. If they have any. + $employees = $BillingSupport->getListOfAccountEmployees( $this->memberID ); + + // Load DataClass for Management. + require_once GLM_MEMBERS_BILLING_PLUGIN_CLASS_PATH . '/data/dataManagement.php'; + $Management = new GlmDataBillingManagement( $this->wpdb, $this->config ); + $management = $Management->getEntry( 1 ); + + // Need to see if there's an account for this member. + $account = $Accounts->editEntry( $accountID ); + } + break; + case 'pay_by_check': + break; + } + + // If there's no error reported then show the invoice + if ( !$error ) { + // Now need to show the invoice. + $view = 'viewInvoice'; + + // Get the invoice. + $invoiceHtml = $BillingSupport->viewInvoice( $invoice_id ); + } } diff --git a/views/front/billing/renew.html b/views/front/billing/renew.html index 5ba2666..b243419 100644 --- a/views/front/billing/renew.html +++ b/views/front/billing/renew.html @@ -44,7 +44,7 @@ {if $employees}
- Employees to Renew + Associated Members/Employees
{foreach $employees as $employee} @@ -67,130 +67,8 @@
-
-
- First Name -
-
- -
-
-
-
- Last Name -
-
- -
-
-
-
- Address -
-
- -
-
-
-
- City -
-
- -
-
-
-
- State / Province -
-
- -
-
-
-
- Zip -
-
- -
-
- -
-
- Name on Card -
-
- -
-
-
-
- Card Type -
-
- -
-
-
-
- Card Number -
-
- -
-
-
-
- Card Expiration -
-
- -
-
-
-
- C V V -
-
- -
-
+{* Include the Payment Form template *} +{include file='common/billing/paymentForm.html'} -- 2.17.1