From: Steve Sutton Date: Tue, 30 Jan 2018 21:59:46 +0000 (-0500) Subject: Update the edit invoice page for member account selection. X-Git-Tag: v1.0.0^2~172 X-Git-Url: http://cvs2.gaslightmedia.com/gitweb/?a=commitdiff_plain;h=94390b84f5b47be2a28fb7f39b61d94653c5ecbf;p=WP-Plugins%2Fglm-member-db-billing.git Update the edit invoice page for member account selection. When selecting a member account it will update the due date to that members new anniversary date. --- diff --git a/classes/data/dataAccounts.php b/classes/data/dataAccounts.php index e7666f5..88f2fb2 100644 --- a/classes/data/dataAccounts.php +++ b/classes/data/dataAccounts.php @@ -239,6 +239,19 @@ class GlmDataAccounts extends GlmDataAbstract */ public function entryPostProcessing($r, $a) { + // Setup the accounts anniversary date + if ( $r['anniversary_date'] ) { + // Need to find the next (current) date for this account's + // anniversary + $anniversary_date = new DateTime( $r['anniversary_date']['mysql_date'] ); + if ( $r['anniversary_date']['timestamp'] > time() ) { + $r['next_anniversary_date'] = $r['anniversary_date']['date']; + } else { + // Add one year to the anniversary date + $anniversary_date->modify('+1 year'); + $r['next_anniversary_date'] = $anniversary_date->format('m-d-Y'); + } + } return $r; } diff --git a/views/admin/billing/editInvoice.html b/views/admin/billing/editInvoice.html index bc75fd3..652bf1e 100644 --- a/views/admin/billing/editInvoice.html +++ b/views/admin/billing/editInvoice.html @@ -23,10 +23,10 @@ Member Account
- {foreach $accounts as $account} - + {/foreach}
@@ -36,7 +36,7 @@ Due Date
- +
@@ -266,6 +266,13 @@ jQuery(document).ready(function($){ // Setup the date picker for the input field with the name due_date $('input[name="due_date"]').datepicker(); + /** + * Change event listener for member account select. + */ + $('#member-account').change(function(){ + $('#invoice_due_date').val( $(this).find('option:selected').data('anniversary') ); + }); + // Flash certain elements for a short time after display $(".glm-flash-updated").fadeOut(500).fadeIn(500).fadeOut(500).fadeIn(500).fadeOut(500).fadeIn(500).fadeOut(500).fadeIn(500).fadeOut(500);