*/
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;
}
Member Account
</div>
<div class="glm-columns glm-small-12 glm-large-9">
- <select name="account" required>
+ <select id="member-account" name="account" required>
<option value="">Select an Account</option>
{foreach $accounts as $account}
- <option value="{$account.id}">{$account.ref_name}</option>
+ <option value="{$account.id}" data-anniversary="{$account.next_anniversary_date}">{$account.ref_name}</option>
{/foreach}
</select>
</div>
Due Date
</div>
<div class="glm-columns glm-small-12 glm-large-9">
- <input type="text" name="due_date" required>
+ <input id="invoice_due_date" type="text" name="due_date" required>
</div>
</div>
<div class="glm-row">
// 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);