From: Steve Sutton Date: Fri, 26 Jul 2019 20:04:32 +0000 (-0400) Subject: Working on pay invoice part X-Git-Url: http://cvs2.gaslightmedia.com/gitweb/index.cgi?a=commitdiff_plain;h=9657552d5782b30a854143cb7bcfd4f063b47645;p=WP-Plugins%2Fglm-member-db-billing.git Working on pay invoice part Also updated the invoice type table so it closes open tr when going out of the table. Removed billing from setting and management sections. --- diff --git a/models/admin/billing/invoices.php b/models/admin/billing/invoices.php index a520add..0b150ed 100644 --- a/models/admin/billing/invoices.php +++ b/models/admin/billing/invoices.php @@ -162,6 +162,7 @@ class GlmMembersAdmin_billing_invoices extends GlmDataInvoices // Special case for option 'send_invoice' if ( $option == 'send_invoice' ) { + // trigger_error( 'A hit on invoices.php for option send_invoice', E_USER_NOTICE ); $BillingSupport = new GlmBillingSupport( $this->wpdb, $this->config ); $invoice_id = false; diff --git a/models/admin/member/billing.php b/models/admin/member/billing.php index e38c064..37ba373 100644 --- a/models/admin/member/billing.php +++ b/models/admin/member/billing.php @@ -200,7 +200,10 @@ class GlmMembersAdmin_member_billing // extends GlmDataBilling $this->memberID ) ); - $account_status = apply_filters( 'glm-billing-get-account-status', '', $accountID ); + + if ( $accountID ) { + $account_status = apply_filters( 'glm-billing-get-account-status', '', $accountID ); + } switch ( $option ) { case 'createInvoice': @@ -1007,21 +1010,28 @@ class GlmMembersAdmin_member_billing // extends GlmDataBilling case 'list': $view = 'statements'; - require_once GLM_MEMBERS_BILLING_PLUGIN_CLASS_PATH . '/data/dataAccounts.php'; - $account = $Accounts->editEntry( $accountID ); - if ( isset( $_REQUEST['all'] ) && $all = filter_var( $_REQUEST['all'], FILTER_VALIDATE_BOOLEAN ) ) { - $allStatements = true; + if ( $accountID ) { + require_once GLM_MEMBERS_BILLING_PLUGIN_CLASS_PATH . '/data/dataAccounts.php'; + $account = $Accounts->editEntry( $accountID ); + if ( isset( $_REQUEST['all'] ) && $all = filter_var( $_REQUEST['all'], FILTER_VALIDATE_BOOLEAN ) ) { + $allStatements = true; + } } break; - } - - // Get the list of invoices for this member. - $statements = $BillingSupport->getStatementsByRefDest( $this->memberID, $allStatements ); - if ( $statements ) { - $transactions = $statements['transactions']; - $account_data = $statements['account_data']; - $balance_due = $statements['balance_due']; - $hasBillingAccount = true; + } // End of Switch $option + + // Get member statements if the member has a billing account. + if ( $accountID ) { + // Get the list of invoices for this member. + $statements = $BillingSupport->getStatementsByRefDest( $this->memberID, $allStatements ); + if ( $statements ) { + $transactions = $statements['transactions']; + $account_data = $statements['account_data']; + $balance_due = $statements['balance_due']; + $hasBillingAccount = true; + } + } else { + $statements = false; } // Compile template data diff --git a/setup/adminTabs.php b/setup/adminTabs.php index a90ccdb..0517ef3 100644 --- a/setup/adminTabs.php +++ b/setup/adminTabs.php @@ -34,46 +34,46 @@ */ if ( current_user_can( 'glm_members_members' ) ) { - add_filter('glm-member-db-add-tab-for-management', - function($addOnTabs) { - $newTabs = array( - array( - 'text' => 'Billing', - 'menu' => 'management', - 'action' => 'billing' - ) - ); - $addOnTabs = array_merge($addOnTabs, $newTabs); - return $addOnTabs; - } - ); + // add_filter('glm-member-db-add-tab-for-management', + // function($addOnTabs) { + // $newTabs = array( + // array( + // 'text' => 'Billing', + // 'menu' => 'management', + // 'action' => 'billing' + // ) + // ); + // $addOnTabs = array_merge($addOnTabs, $newTabs); + // return $addOnTabs; + // } + // ); - add_filter( 'glm-member-db-add-tab-for-settings', - function( $addOnTabs ) { - $newTabs = array( - array( - 'text' => 'Billing', - 'menu' => 'settings', - 'action' => 'billing', - ) - ); - $addOnTabs = array_merge( $addOnTabs, $newTabs ); - return $addOnTabs; - } - ); + // add_filter( 'glm-member-db-add-tab-for-settings', + // function( $addOnTabs ) { + // $newTabs = array( + // array( + // 'text' => 'Billing', + // 'menu' => 'settings', + // 'action' => 'billing', + // ) + // ); + // $addOnTabs = array_merge( $addOnTabs, $newTabs ); + // return $addOnTabs; + // } + // ); - add_filter( 'glm-member-db-add-tab-for-billing', - function( $addOnTabs ){ - $newTabs = array( - array( - 'text' => 'Invoices', - 'menu' => 'billing', - 'action' => 'billing', - 'option' => 'list', - ) - ); - } - ); + // add_filter( 'glm-member-db-add-tab-for-billing', + // function( $addOnTabs ){ + // $newTabs = array( + // array( + // 'text' => 'Invoices', + // 'menu' => 'billing', + // 'action' => 'billing', + // 'option' => 'list', + // ) + // ); + // } + // ); add_filter( 'glm-member-db-add-tab-for-member', diff --git a/views/admin/billing/editPayment.html b/views/admin/billing/editPayment.html index 024ff92..6eb2457 100644 --- a/views/admin/billing/editPayment.html +++ b/views/admin/billing/editPayment.html @@ -1,144 +1,258 @@ +{* Payment Form *} + +{* Header *} {include file='admin/billing/header.html'} -
+{* Grid Start *} +{$ui = [ + 'nowrap' => false, + 'backgroundColor' => '', + 'sectionColor' => '' +]} +{include file='ui/f6/grid-start.html'} + +{* Payment Updated *} +{$ui = [ + 'label' => 'Payment Updated', + 'active' => $paymentUpdated, + 'type' => 'success' +]} +{include file='ui/f6/callout.html'} + +{* Payment Update Error *} +{$ui = [ + 'label' => 'Payment Update Error', + 'active' => $paymentUpdateError, + 'type' => 'alert' +]} +{include file='ui/f6/callout.html'} + +{* Payment Added *} +{$ui = [ + 'label' => 'Payment Added', + 'active' => $paymentAdded, + 'type' => 'success' +]} +{include file='ui/f6/callout.html'} + +{* Payment Insert Error *} +{$ui = [ + 'label' => 'Payment Insert Error', + 'active' => $paymentInsertError, + 'type' => 'alert' +]} +{include file='ui/f6/callout.html'} + +
+ {* Form Start *} + {$ui = [ + 'id' => 'billing-payment-form', + 'action' => "{$thisUrl}?page={$thisPage}&glm_action=payments", + 'method' => 'post', + 'file' => false, + 'validate' => true, + 'validateFocusMsg' => true + ]} + {include file='ui/f6/form-start.html'} - {if $paymentUpdated}Payment Updated{/if} - {if $paymentUpdateError}Payment Update Error{/if} - {if $paymentInsertError}Payment Insert Error{/if} - {if $paymentAdded}Payment Added{/if} +
+ Payment + +
+ + -
-
- {if $payment_id} {else} {/if} -
-
- Lookup Member Invoices By Account -
-
- - -
-
-
-
- Select Invoices -
-
-
-
-
-
- Amount -
-
-
$0.00
+ + {* Lookup Member Invoices By Account *} +
+
+
+ +
+
+ + +
+
+ Member is Required +
-
-
- Payment Method -
-
- + + {* Select Invoices *} +
+
+
+ +
+
+
+
-
-
- Payment Notes -
-
- + + {* Amount *} +
+
+
+ +
+
+
$0.00
+
- - -
- - -
+ // 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); + +}); + + +{* FGooter *} {include file='admin/billing/footer.html'} diff --git a/views/admin/billing/invoiceTypes.html b/views/admin/billing/invoiceTypes.html index c8c2b13..838223a 100644 --- a/views/admin/billing/invoiceTypes.html +++ b/views/admin/billing/invoiceTypes.html @@ -15,7 +15,7 @@

Cancel

- +
diff --git a/views/admin/billing/invoices.html b/views/admin/billing/invoices.html index 17c8ffd..5a20fe5 100644 --- a/views/admin/billing/invoices.html +++ b/views/admin/billing/invoices.html @@ -120,6 +120,7 @@ {else} - + Send an invoice to
@@ -206,6 +207,23 @@ $('#glmLoading').hide(); }; + + // Pay Invoice link + $('.pay-invoice').on('click', function(e){ + e.preventDefault(); + var member = $(this).data('member'); + var $modalPayment = $('#glmBillingPayment'); + $.ajax({ + url: '{$ajaxUrl}?action=glm_members_admin_ajax&glm_action=ajaxBillingInfo&option=makepayment&member=' + member, + cache: false, + beforeSend: startAjax, + complete: completeAjax, + }).done(function(resp){ + $modalPayment.html(resp).foundation('open').trigger('resizeme.zp.reveal'); + }); + return false; + }); + $('.make-a-payment').on('click', function(e){ e.preventDefault(); var member = $(this).data('member'); @@ -255,7 +273,7 @@ var account_id = $(this).data( 'account' ); var member_name = $(this).data( 'member_name' ); - $('#invoice_id').val( invoice_id ); + $('#send_invoice_id').val( invoice_id ); $('#member_id').val( member_id ); $('#account_id').val( account_id ); $('#member_name').html( '' + member_name + '' ); diff --git a/views/admin/billing/makePaymentAjax.html b/views/admin/billing/makePaymentAjax.html index d14ba6b..f5c6266 100644 --- a/views/admin/billing/makePaymentAjax.html +++ b/views/admin/billing/makePaymentAjax.html @@ -15,65 +15,252 @@ {/foreach} {/if} + {* Form Start *} + {$ui = [ + 'id' => 'billingPaymentForm', + 'action' => "{$ajaxUrl}?action = glm_members_admin_ajax", + 'method' => 'post', + 'file' => false, + 'validate' => true, + 'validateFocusMsg' => true + ]} + {include file='ui/f6/form-start.html'} -
- {* *} - - - - - - + {* *} + + + + + + - {include file='ui/f6/errorCallout.html'} - + {include file='ui/f6/errorCallout.html'} + - {if $invoices} -

Payment Information

+ {if $invoices} +

Payment Information

-
-
Select Invoice
-
- {if $invoices} - {foreach $invoices as $invoice} - - {/foreach} - {/if} +
+ Invoices + + {* Select Invoice *} +
+
+
+ +
+
+ {if $invoices} + {foreach $invoices as $invoice} + + {/foreach} + {/if} +
+ {* Amount *} +
+
+
+ +
+
+
+
+
+
+ +
+ +
+ Billing Information + + {* Set the $data to account data abstract object *} + {$data = $account} + + {if $settings.billing_contact_name_enabled} + {* Billing Contact Name *} + {$ui = [ + 'value' => $data.fieldData.billing_contact_name, + 'field' => 'billing_contact_name', + 'label' => 'Billing Contact Name', + 'required' => $data.fieldRequired.billing_contact_name, + 'errorText' => 'Billing Contact Name is Required', + 'dataError' => $data.fieldFail.billing_contact_name + ]} + {include file='ui/f6/text.html'} + {else} + {* First Name *} + {$ui = [ + 'value' => $data.fieldData.billing_fname, + 'field' => 'billing_fname', + 'label' => 'First Name', + 'required' => $data.fieldRequired.billing_fname, + 'errorText' => 'First Name is Required', + 'dataError' => $data.fieldFail.billing_fname + ]} + {include file='ui/f6/text.html'} + + {* Last Name *} + {$ui = [ + 'value' => $data.fieldData.billing_lname, + 'field' => 'billing_lname', + 'label' => 'Last Name', + 'required' => $data.fieldRequired.billing_lname, + 'errorText' => 'Last Name is Required', + 'dataError' => $data.fieldFail.billing_lname + ]} + {include file='ui/f6/text.html'} + {/if} + + {* Address *} + {$ui = [ + 'value' => $data.fieldData.billing_addr1, + 'field' => 'billing_addr1', + 'label' => 'Address', + 'required' => $data.fieldRequired.billing_addr1, + 'errorText' => 'Address is Required', + 'dataError' => $data.fieldFail.billing_addr1 + ]} + {include file='ui/f6/text.html'} + + {* City *} + {$ui = [ + 'value' => $data.fieldData.billing_city, + 'field' => 'billing_city', + 'label' => 'City', + 'required' => $data.fieldRequired.billing_city, + 'errorText' => 'City is Required', + 'dataError' => $data.fieldFail.billing_city + ]} + {include file='ui/f6/text.html'} + + {* State / Province *} + {$ui = [ + 'value' => $data.fieldData.billing_state.value, + 'field' => 'billing_state', + 'label' => 'State / Province', + 'list' => $data.fieldData.billing_state.list, + 'l_label' => 'name', + 'l_value' => 'value', + 'l_blank' => true, + 'required' => $data.fieldRequired.billing_state, + 'errorText' => 'State / Province is Required', + 'dataError' => $data.fieldFail.billing_state + ]} + {include file='ui/f6/select.html'} + + {* Zip *} + {$ui = [ + 'value' => $data.fieldData.billing_zip, + 'field' => 'billing_zip', + 'label' => 'Zip', + 'required' => $data.fieldRequired.billing_zip, + 'errorText' => 'Zip is Required', + 'dataError' => $data.fieldFail.billing_zip + ]} + {include file='ui/f6/text.html'} + + {* Email Address *} + {$ui = [ + 'value' => $data.fieldData.email, + 'field' => 'billing_email', + 'label' => 'Email Address', + 'required' => $data.fieldRequired.email, + 'errorText' => 'Billing Email is Required', + 'dataError' => $data.fieldFail.email + ]} + {include file='ui/f6/text.html'} + +
+ +
+ Payment Information + + {* TODO: Check $billing_settings.payment_methods *} + {if !$lockedToMember}
-
Amount
+
+ Select Payment Option +
-
+ {if in_array( 'Credit Card', $management.payment_methods.names)} + + {/if} + {if in_array( 'Check', $management.payment_methods.names)} + + {/if} + {if in_array( 'Mark Paid', $management.payment_methods.names)} + + {/if}
+ {/if} + + {if isset( $account.fieldData.payment_profile_card ) && $account.fieldData.payment_profile_card} +
+
+ +
+
+ {/if} - {* Include the Payment Form template *} - {* Only if payments types are setup *} - {include file='common/billing/paymentForm.html'} + {* Name on Card *} + {$ui = [ + 'value' => $smarty.request.cc_name|default:'', + 'field' => 'cc_name', + 'label' => 'Name on Card', + 'required' => true, + 'errorText' => 'Name on Card is Required', + 'dataError' => '' + ]} + {include file='ui/f6/text.html'} - + {* Card Type *} + {$ui = [ + 'value' => $smarty.request.cc_type|default:'', + 'field' => 'cc_type', + 'label' => 'Card Type', + 'list' => $management.cc_accepts.names, + 'l_blank' => true, + 'required' => true, + 'errorText' => 'Card Type is Required', + 'dataError' => '' + ]} + {include file='ui/f6/select.html'} - +
+ {* Include the Payment Form template *} + {* Only if payments types are setup *} + {* include file='common/billing/paymentForm.html' *} - {include file='ui/f6/errorCallout.html'} + - {else} - You don't have any unpaid invoices! - {/if} + + + + {include file='ui/f6/errorCallout.html'} + + {else} + You don't have any unpaid invoices! + {/if} - + {* Form End *} + {include file='ui/f6/form-end.html'}
ID