From 88aaef93f2026696d4b6ffac3c8d49f163af6d04 Mon Sep 17 00:00:00 2001 From: Steve Sutton Date: Thu, 5 Apr 2018 16:37:38 -0400 Subject: [PATCH] Billing updates for renewal form processing. Updating the text on the renewal form for Membership Renewal. adding payment option for pay by check. showing the invoice after the submit is done. change name of submit button to Submit Membership Renewal. adding table layout for the renewal form sections for choosing the member type and employees so prices line up. Fix the issue with incorrect class was being pulled for employees. Also updated the employee list so if they don't have a payable member type then they won't show up in the renewal form. --- classes/billingSupport.php | 26 ++-- css/admin.css | 18 ++- models/admin/member/billing.php | 65 +++++---- views/admin/billing/invoiceStore.html | 26 ++-- .../admin/billing/memberBillingSubHeader.html | 2 +- views/admin/billing/renew.html | 131 ++++++++++++++---- 6 files changed, 192 insertions(+), 76 deletions(-) diff --git a/classes/billingSupport.php b/classes/billingSupport.php index 21b796e..c98e70b 100644 --- a/classes/billingSupport.php +++ b/classes/billingSupport.php @@ -696,11 +696,14 @@ class GlmBillingSupport ), ARRAY_A ); - foreach ( $line_items as &$item ) { + foreach ( $line_items as $key => &$item ) { $index = (int)$item['recurrence']; if ( $item['recurring'] && $this->config['recurrence'][$index] ) { $item['recurrence_string'] = $this->config['recurrence'][$index]; } + if ( $account_id = filter_var( $item['account'], FILTER_VALIDATE_INT ) ) { + $line_items[$key]['account'] = $this->getAccountById( $account_id ); + } } return $line_items; } @@ -892,17 +895,17 @@ class GlmBillingSupport } if ( $billing_account ) { // Need also to get the members type to look up which invoice_type to use - $invoice_type_id = $this->getMembersInvoiceTypeByRefDest( $member_id ); + $invoice_type_id = $this->getMembersInvoiceTypeByRefDest( $ref_dest ); if ( $invoice_type_id ) { $invoice = $this->getInvoiceTypeById( $invoice_type_id ); + $accounts[$billing_account['id']] = array( + 'id' => $billing_account['id'], + 'ref_dest' => $billing_account['ref_dest'], + 'ref_name' => $billing_account['ref_name'], + 'invoice' => $invoice, + 'email' => $billing_account['email'] + ); } - $accounts[$billing_account['id']] = array( - 'id' => $billing_account['id'], - 'ref_dest' => $billing_account['ref_dest'], - 'ref_name' => $billing_account['ref_name'], - 'invoice' => $invoice, - 'email' => $billing_account['email'] - ); } } } @@ -962,6 +965,7 @@ class GlmBillingSupport array( 'invoice_id' => $invoice_id, 'line_item_type' => $new_member_invoice_type['id'], + 'account' => $account_id, 'name' => $new_member_invoice_type['name'], 'amount' => $new_member_invoice_type['amount'], 'due_date' => $due_date, @@ -979,6 +983,7 @@ class GlmBillingSupport array( 'invoice_id' => $invoice_id, 'line_item_type' => $employee_data[(int)$acc_id]['invoice']['id'], + 'account' => $acc_id, 'name' => $employee_data[(int)$acc_id]['invoice']['name'], 'amount' => $employee_data[(int)$acc_id]['invoice']['amount'], 'due_date' => $due_date, @@ -1008,6 +1013,7 @@ class GlmBillingSupport // Make sure the required parts of $data exists. if ( !isset( $data['invoice_id'] ) || !isset( $data['line_item_type'] ) + || !isset( $data['account'] ) || !isset( $data['name'] ) || !isset( $data['amount'] ) || !isset( $data['due_date'] ) @@ -1023,6 +1029,7 @@ class GlmBillingSupport array( 'invoice' => $invoice_id, 'line_item_type' => $line_item_type, + 'account' => $account, 'name' => $name, 'amount' => $amount, 'quantity' => 1, @@ -1036,6 +1043,7 @@ class GlmBillingSupport array( '%d', // invoice '%d', // line_item_type (invoiceType id) + '%d', // account '%s', // name '%s', // amount '%d', // quantity diff --git a/css/admin.css b/css/admin.css index 62a38f9..e1ccd23 100644 --- a/css/admin.css +++ b/css/admin.css @@ -40,7 +40,7 @@ width: 100%; font-weight; bold; padding: 0; - margin: 3px 0 0 0; + margin: 7px 0 0 0; } .glm-billing-left-half { width: 49%; @@ -99,3 +99,19 @@ box-shadow: 0 0 8px #88D5E9; border: 1px solid #88D5E9; } +.glm-billing-input table { + width: 100%; +} +.glm-billing-input .price { + width: 50px; + text-align: right; +} +.glm-billing-form fieldset legend { + font-size: 1rem; + font-weight: bold; + margin-top: 2rem; +} + +.glm-billing-form input[type=submit] { + margin-top: 20px; +} diff --git a/models/admin/member/billing.php b/models/admin/member/billing.php index 8d2f6e1..cd85405 100644 --- a/models/admin/member/billing.php +++ b/models/admin/member/billing.php @@ -282,38 +282,53 @@ class GlmMembersAdmin_member_billing // 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 ) . '
'; - if ( $errors ) { - // $messages[] = '
$errors: ' . print_r( $errors, true ) . '
'; - if ( count( $errors ) > 0 ) { - $BillingSupport->removeInvoiceById( $invoice_id ); - foreach ( $errors as $error ) { - $messages[] = ''.$error.''; + // 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. + $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 ) { + $BillingSupport->removeInvoiceById( $invoice_id ); + foreach ( $errors as $error ) { + $messages[] = ''.$error.''; + } } - } - $view = 'renew'; + $view = 'renew'; - // Get list of payable invoice_types - $payable_types = $BillingSupport->getAllPayableInvoiceTypes(); + // 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 ); - } + $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 ); + // 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 ); + // 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 ); + // Need to see if there's an account for this member. + $account = $Accounts->editEntry( $accountID ); + } + break; + case 'pay_by_check': + break; } + + // Now need to show the invoice. + $view = 'viewInvoice'; + + // Get the invoice. + $invoiceHtml = $BillingSupport->viewInvoice( $invoice_id ); } diff --git a/views/admin/billing/invoiceStore.html b/views/admin/billing/invoiceStore.html index ac1d4b0..a1757d0 100644 --- a/views/admin/billing/invoiceStore.html +++ b/views/admin/billing/invoiceStore.html @@ -65,41 +65,41 @@ - - + + - + - + {foreach $line_items as $item} - - + + - + - + {/foreach} {foreach $payments as $payment} - + - + {/foreach} - + - + @@ -122,6 +122,7 @@ {/if} {* Footer of invoice *} + {if !$invoice.paid} @@ -171,4 +172,5 @@
DateQtyMember NameAnniversary   Description RateAmount


{$invoice.transaction_time|date_format:"%D"}{$item.quantity}{$item.account.ref_name}{$item.account.anniversary_date|date_format:"%m/%d/%y"}  {$item.name}{if $item.recurring && $item.recurrence_string} ( {$item.recurrence_string} ){/if}{$item.name} ${$item.amount|string_format:"%.2f"}${$item.total|string_format:"%.2f"}
{$payment.transaction_time|date_format:"%D"}      Payment  - ${$payment.amount|string_format:"%.2f"}


Total Amount DueTotal Amount Due ${$invoice.balance|string_format:"%.2f"}
 
Please return Coupon Below with Payment
+ {/if} diff --git a/views/admin/billing/memberBillingSubHeader.html b/views/admin/billing/memberBillingSubHeader.html index 431590f..63f8c69 100644 --- a/views/admin/billing/memberBillingSubHeader.html +++ b/views/admin/billing/memberBillingSubHeader.html @@ -24,7 +24,7 @@
  • Renew + class="">Membership Renewal
  • {/if}
  • diff --git a/views/admin/billing/renew.html b/views/admin/billing/renew.html index b16a465..6a4861d 100644 --- a/views/admin/billing/renew.html +++ b/views/admin/billing/renew.html @@ -28,19 +28,35 @@ Membership Class
    - {if $settings.allow_membership_choice} - {foreach $payable_types as $type} - - {/foreach} - {else} - - {$member_invoice.name} {$member_invoice.amount} - {/if} + + {if $settings.allow_membership_choice} + {foreach $payable_types as $type} + + + + + + {/foreach} + {else} + + + + + {/if} +
    + + + + + ${$type.amount} +
    + + {$member_invoice.name} + + ${$member_invoice.amount} +
    {/if} @@ -48,28 +64,52 @@ {if $employees}
    - Employees to Renew + Associated Members/Employees
    - {foreach $employees as $employee} - - {/foreach} + + {foreach $employees as $employee} + + + + + + + {/foreach} +
    + + + + + {$employee.invoice.name} + + ${$employee.invoice.amount} +
    {/if}
    - Total Due + Total Due
    -
    + + + + + +
      +
    +
    +
    + Billing Information +
    First Name @@ -126,24 +166,41 @@
    +
    + +
    + Payment Options +
    +
    + Select Payment Option +
    +
    + + +
    +
    + +
    Name on Card
    -
    + +
    Card Type
    - {foreach $management.cc_accepts.names as $cardId => $cardName}
    -
    +
    Card Number
    -
    +
    Card Expiration
    -
    +
    C V V
    - +
    + + + @@ -208,6 +271,18 @@ jQuery(document).ready(function($){ $('#billing-amount').val( $(this).find('option:selected').data( 'amount') ); }); + $('.payment_option').change(function(){ + var payment_option = $('.payment_option:checked').val(); + console.log( 'payment_option: ', payment_option ); + if ( payment_option == 'pay_by_check' ) { + $('.glm-billing-credit').hide(); + $('.ccard').prop('disabled', true); + } else { + $('.glm-billing-credit').show(); + $('.ccard').prop('disabled', false); + } + }); + function getPageTotal(){ // Calculate the total for this page. -- 2.17.1