From 8e8b2a281fc97b1ae5ad53c8f3eed7ee58fbfeb1 Mon Sep 17 00:00:00 2001 From: Steve Sutton Date: Fri, 14 Dec 2018 16:49:30 -0500 Subject: [PATCH] WIP payment form Starting to clean up the member only side. If they aren't allowed billing. Also need to work on the payment form under members to get it simplified to what uptra will need. --- models/admin/billing/reports.php | 5 +- setup/adminHooks.php | 172 +++++++++--------- views/admin/billing/makePayment.html | 1 + .../admin/billing/memberBillingSubHeader.html | 16 +- views/common/billing/paymentForm.html | 37 ++-- 5 files changed, 129 insertions(+), 102 deletions(-) diff --git a/models/admin/billing/reports.php b/models/admin/billing/reports.php index e7559a6..f6a656b 100644 --- a/models/admin/billing/reports.php +++ b/models/admin/billing/reports.php @@ -280,8 +280,9 @@ class GlmMembersAdmin_billing_reports extends GlmDataTransactions ) ORDER BY name"; // echo '
$sql: ' . print_r( $sql, true ) . '
'; - $accounts = $this->wpdb->get_results( $sql, ARRAY_A ); - $paging = false; + $accounts = $this->wpdb->get_results( $sql, ARRAY_A ); + $totalAccounts = count( $accounts ); + $paging = false; break; default: break; diff --git a/setup/adminHooks.php b/setup/adminHooks.php index 991d6a8..e023b5f 100644 --- a/setup/adminHooks.php +++ b/setup/adminHooks.php @@ -25,93 +25,101 @@ * * Also note that parameters will be in the context of the main admin controller constructor. */ -add_filter( - 'glm-member-db-dashboard-member-widgets', - function( $member = null ){ - return $this->controller( 'dashboard', 'billing', $member ); - }, - 9, - 1 -); - -/** - * Setup cron task request to run billingFlagExpiredUsers - * - * Run only once per day. Everyday. - */ -add_filter( - 'glm_associate_cron_request', - function( $cron_task ){ - $new_cron = array( - array( - 'menu' => 'ajax', - 'action' => 'billingFlagExpiredUsers', - 'daysOfWeek' => false, - 'times' => array( 5 ), - 'params' => array() - ) +if (isset($this->config['loggedInUser']) && isset($this->config['loggedInUser']['contactUser']) && $this->config['loggedInUser']['contactUser']) { + $memberBillingEnabled = $this->config['settings']['member_billing_enabled']; + if ( $memberBillingEnabled ) { + add_filter( + 'glm-member-db-dashboard-member-widgets', + function( $member = null ){ + return $this->controller( 'dashboard', 'billing', $member ); + }, + 9, + 1 ); - return array_merge( $cron_task, $new_cron ); } -); +} -add_filter( - 'glm_associate_cron_request', - function( $cron_task ){ - $new_cron = array( - array( - 'menu' => 'ajax', - 'action' => 'billingFixActiveUsers', - 'daysOfWeek' => false, - 'times' => array( 6 ), - 'params' => array() - ) - ); - return array_merge( $cron_task, $new_cron ); - } -); +$renewalDayStatic = $this->config['settings']['renewal_day_static']; +if ( !$renewalDayStatic ) { + /** + * Setup cron task request to run billingFlagExpiredUsers + * + * Run only once per day. Everyday. + */ + add_filter( + 'glm_associate_cron_request', + function( $cron_task ){ + $new_cron = array( + array( + 'menu' => 'ajax', + 'action' => 'billingFlagExpiredUsers', + 'daysOfWeek' => false, + 'times' => array( 5 ), + 'params' => array() + ) + ); + return array_merge( $cron_task, $new_cron ); + } + ); -/** - * Setup cron task request to run billingSetupQueue - * - * Run only once per day. Everyday. - */ -add_filter( - 'glm_associate_cron_request', - function( $cron_task ) { - $new_cron = array( - array( - 'menu' => 'ajax', - 'action' => 'billingSetupQueue', - 'daysOfWeek' => false, - 'times' => array( 3 ), - 'params' => array() - ) - ); - return array_merge( $cron_task, $new_cron ); - } -); + add_filter( + 'glm_associate_cron_request', + function( $cron_task ){ + $new_cron = array( + array( + 'menu' => 'ajax', + 'action' => 'billingFixActiveUsers', + 'daysOfWeek' => false, + 'times' => array( 6 ), + 'params' => array() + ) + ); + return array_merge( $cron_task, $new_cron ); + } + ); -/** - * Setup cron task request to run billingRunQueue - * - * Run only once per day. Everyday. - */ -add_filter( - 'glm_associate_cron_request', - function( $cron_task ) { - $new_cron = array( - array( - 'menu' => 'ajax', - 'action' => 'billingRunQueue', - 'daysOfWeek' => false, - 'times' => array( 4 ), - 'params' => array() - ) - ); - return array_merge( $cron_task, $new_cron ); - } -); + /** + * Setup cron task request to run billingSetupQueue + * + * Run only once per day. Everyday. + */ + add_filter( + 'glm_associate_cron_request', + function( $cron_task ) { + $new_cron = array( + array( + 'menu' => 'ajax', + 'action' => 'billingSetupQueue', + 'daysOfWeek' => false, + 'times' => array( 3 ), + 'params' => array() + ) + ); + return array_merge( $cron_task, $new_cron ); + } + ); + + /** + * Setup cron task request to run billingRunQueue + * + * Run only once per day. Everyday. + */ + add_filter( + 'glm_associate_cron_request', + function( $cron_task ) { + $new_cron = array( + array( + 'menu' => 'ajax', + 'action' => 'billingRunQueue', + 'daysOfWeek' => false, + 'times' => array( 4 ), + 'params' => array() + ) + ); + return array_merge( $cron_task, $new_cron ); + } + ); +} /** * Filter returning the html for the billing field form (contact) diff --git a/views/admin/billing/makePayment.html b/views/admin/billing/makePayment.html index 38a036a..9c0d945 100644 --- a/views/admin/billing/makePayment.html +++ b/views/admin/billing/makePayment.html @@ -49,6 +49,7 @@ {* Include the Payment Form template *} +{* Only if payments types are setup *} {include file='common/billing/paymentForm.html'} diff --git a/views/admin/billing/memberBillingSubHeader.html b/views/admin/billing/memberBillingSubHeader.html index 33439eb..d991ff6 100644 --- a/views/admin/billing/memberBillingSubHeader.html +++ b/views/admin/billing/memberBillingSubHeader.html @@ -33,11 +33,17 @@ class="">Membership Renewal {/if} -
  • - Pay Invoices -
  • + {if isset( $settings.renewal_day_static ) && $settings.renewal_day_static} +
  • + Make A Payment +
  • + {else} +
  • + Pay Invoices +
  • + {/if} diff --git a/views/common/billing/paymentForm.html b/views/common/billing/paymentForm.html index e0e0d06..f1911d4 100644 --- a/views/common/billing/paymentForm.html +++ b/views/common/billing/paymentForm.html @@ -2,22 +2,33 @@
    Billing Information -
    -
    - First Name -
    -
    - + {if $settings.billing_contact_name_enabled} +
    +
    + Billing Contact Name +
    +
    + +
    -
    -
    -
    - Last Name + {else} +
    +
    + First Name +
    +
    + +
    -
    - +
    +
    + Last Name +
    +
    + +
    -
    + {/if}
    Address -- 2.17.1