Adding ability to add new billing account from the billing side.
Using same form as the edit billing info from billing side.
Auto complete for the new member name.
New invoice page updates:
Don't show the account number field if it's not active in the settings.
Change the add line items to buttons not links.
$invoiceTypes = $InvoiceTypesObj->getList();
// Need to see if there's an account for this member.
- $accountID = $this->wpdb->get_var(
- $this->wpdb->prepare(
- "SELECT id
- FROM " . GLM_MEMBERS_BILLING_PLUGIN_DB_PREFIX . "accounts
- WHERE ref_dest = %d",
- $this->memberID
- )
- );
+ if ( $this->memberID ) {
+ $accountID = $this->wpdb->get_var(
+ $this->wpdb->prepare(
+ "SELECT id
+ FROM " . GLM_MEMBERS_BILLING_PLUGIN_DB_PREFIX . "accounts
+ WHERE ref_dest = %d",
+ $this->memberID
+ )
+ );
+ }
// Grab the employee data
if ( $accountID ) {
}
// Check to see if we're adding an account or editing one.
+ // This only happens if there's a member.
+ // If this is a new Account Form from Billing then there isn't a member assigned yet.
if ( isset( $_REQUEST['ref_name'] ) ) {
$_REQUEST['anniversary_date'] = date('Y-m-d', strtotime($_REQUEST['anniversary_date']));
// if there's no id then add account.
$accountAdded = true;
// If account is added then get the id
$accountID = $account['fieldData']['id'];
+ if ( $this->ajaxSide ) {
+ // trigger_error( 'Account Ajax Hit', E_USER_NOTICE );
+ header( 'Content-type:application/json;charset=utf-8', true );
+ echo json_encode( $account, true );
+ exit;
+ }
}
} else {
$account = $Accounts->updateEntry( $_REQUEST['id'] );
}
}
-
$sql_for_employee_list = "T.boss <> true";
// Grab the employee data
if ( $accountID ) {
$accountID = 0;
$account = $Accounts->newEntry();
// Set the ref_name from memberData
- $account['fieldData']['ref_name'] = $memberData['name'];
+ if ( isset( $memberData ) && isset( $memberData['name'] ) ) {
+ $account['fieldData']['ref_name'] = $memberData['name'];
+ }
$haveAccount = false;
}
} else {
$haveAccount = true;
}
+ // Set the view file.
$view = 'editAccount';
if ( $this->ajaxSide ) {
$view = 'editAccountAjax';
var member = $(this).data('member');
var $modal = $('#glmBillingInfo');
$modal.on('closed.zf.reveal', function(){
- console.log('Info reveal closed');
$('glmBillingInfoFormWrap').remove();
});
});
return false;
});
+ $('#AddAccountButton').on('click', function(e) {
+ e.preventDefault();
+ var availableNonAccountMembers = [];
+ var member = $(this).data('member');
+ var $modal = $('#glmBillingInfo');
+ $modal.on('closed.zf.reveal', function(){
+ $('glmBillingInfoFormWrap').remove();
+ });
+
+ $.ajax({
+ url: '{$ajaxUrl}?action=glm_members_admin_ajax&glm_action=ajaxBillingInfo&option=account',
+ cache: false,
+ beforeSend: startAjax,
+ complete: completeAjax,
+ })
+ .done(function(resp){
+ $modal.html(resp).foundation('open').trigger('resizeme.zp.reveal');
+ updateNonAccountMemberList();
+ });
+ return false;
+ });
+
+ /**
+ * Ajax call to get the list of members without accounts.
+ */
+ function updateNonAccountMemberList() {
+ $.ajax({
+ url: '{$ajaxUrl}',
+ cache: false,
+ type: 'GET',
+ data: 'action=glm_members_admin_ajax&glm_action=billingAccount&option=listNonAccounts',
+ encode: true,
+ dataType: 'json'
+ }).done(function(msg){
+ availableNonAccountMembers = [];
+ for ( index in msg ) {
+ var obj = msg[index];
+ availableNonAccountMembers.push( { label: obj.name, value: obj.name, id: obj.id } );
+ }
+ // also need to update the source for the autocomplete
+ $('#ref_name').autocomplete({
+ source: availableNonAccountMembers,
+ appendTo: '#glmBillingInfoFormWrap',
+ select: function( event, ui ) {
+ $('input[name=ref_dest]').val( ui.item.id );
+ $('input[name=member]').val( ui.item.id );
+ },
+ change: function( event, ui ) {
+ $(this).val(( ui.item ? ui.item.label : ""));
+ }
+ });
+ });
+ }
$('.account-member-statements').on('click', function(e){
e.preventDefault();
<h3 class="subheader">Accounts</h3>
+<div id="AddAccountButton" class="button primary">Add New Account</div>
<div id="exportAccountsButton" class="button secondary">Accounts Export</div>
{* Search Form *}
]}
{include file='ui/f6/text.html'}
-
{if !$lockedToMember}
{if $settings.account_number_enabled}
{include file='ui/f6/checkbox.html'}
<div class="cell small-12 medium-4">
- <a id="newLineItemButton" class="glm-billing-add-line-item">Add Line Item</a><br>
- <a id="newCustomLineItemButton" class="glm-billing-add-line-item">Create New Line Item</a>
+ <a id="newLineItemButton" class="glm-billing-add-line-item button secondary">Add Line Item + </a><br>
+ <a id="newCustomLineItemButton" class="glm-billing-add-line-item button secondary">Create New Line Item + </a>
</div>
<div id="invoice-line-items" class="cell small-12 medium-8"> </div>
<div class="cell small-12 large-8">
<label class="glm-required">Member Name (lookup)</label>
<input id="glm_member_name" type="text" name="ref_name" value="">
</div>
- <div class="cell small-12">
- <label class="glm-required">Account Number</label>
- <input type="text" name="account_number" value="">
- </div>
+ {if $settings.account_number_enabled}
+ <div class="cell small-12">
+ <label class="glm-required">Account Number</label>
+ <input type="text" name="account_number" value="">
+ </div>
+ {else}
+ <input type="hidden" name="account_number" value="">
+ {/if}
{if !$settings.member_types_enabled}
<div class="cell small-12">
<label class="glm-required">Payment Types</label>
valid = valid && checkRequired( ref_name, accountTips, 'Name is required!' );
valid = valid && checkRequired( invoice_type, accountTips, 'Payment Type is required!' );
- valid = valid && checkRequired( account_number, accountTips, 'Account Number is required!' );
+ {if $settings.account_number_enabled}
+ valid = valid && checkRequired( account_number, accountTips, 'Account Number is required!' );
+ {/if}
valid = valid && checkRequired( anniversary_date, accountTips, 'Anniversary Date is required!' );
valid = valid && checkRequired( email, accountTips, 'Email is required!' );
valid = valid && checkRegexp( email, emailRegex, 'Use valid email!', accountTips );
<div>
<a class="button secondary" href="#" id="exportAccountsButton">Accounts Export</a>
+ <div id="AddAccountButton" class="button primary">Add New Account</div>
<a class="button primary" href="{$thisUrl}?page=glm-members-admin-menu-billing&glm_action=invoices&option=add">Create Invoice</a>
<a class="button success" href="{$thisUrl}?page=glm-members-admin-menu-billing&glm_action=payments&option=add">Make Payment</a>
</div>