From 98badc3f77de923ec2350af6987a45f6839a91c5 Mon Sep 17 00:00:00 2001 From: Steve Sutton Date: Thu, 25 Apr 2019 16:50:43 -0400 Subject: [PATCH] Working on payment form front and in member section Working on payment form front end. Working on payment (pay invoice) admin form. --- models/admin/ajax/billingAccount.php | 3 +- models/admin/billing/invoices.php | 10 +- models/admin/member/billing.php | 42 +++-- models/front/billing/paymentForm.php | 11 -- views/admin/billing/invoices.html | 2 +- views/admin/billing/invoicing.html | 8 +- views/admin/billing/makePayment.html | 5 +- views/admin/billing/paymentReceipt.html | 209 +++++++++++++----------- views/admin/billing/reports.html | 8 +- views/admin/settings/billing.html | 11 +- views/common/billing/paymentForm.html | 18 +- views/front/billing/paymentForm.html | 38 +++-- 12 files changed, 213 insertions(+), 152 deletions(-) diff --git a/models/admin/ajax/billingAccount.php b/models/admin/ajax/billingAccount.php index 7829f9d..b0820d1 100644 --- a/models/admin/ajax/billingAccount.php +++ b/models/admin/ajax/billingAccount.php @@ -170,7 +170,6 @@ class GlmMembersAdmin_ajax_billingAccount extends GlmDataAccounts 'status' => true, 'member_id' => (int)$account['ref_dest'], 'account_id' => (int)$account['id'], - 'invoice_type' => (int)$invoiceTypeId, 'invoice' => $invoice, ); } else { @@ -187,6 +186,6 @@ class GlmMembersAdmin_ajax_billingAccount extends GlmDataAccounts header( 'Content-type:application/json;charset=utf-8', true ); echo json_encode( $return, true ); - exit(); + exit; } } diff --git a/models/admin/billing/invoices.php b/models/admin/billing/invoices.php index eee71a4..eb09b0e 100644 --- a/models/admin/billing/invoices.php +++ b/models/admin/billing/invoices.php @@ -369,9 +369,9 @@ class GlmMembersAdmin_billing_invoices extends GlmDataInvoices $invoiceTypes = $InvoiceTypesObj->getList(); $invoiceTypes = $InvoiceTypesObj->sortParentChild($invoiceTypes); // Need to get the accounts - $Accounts = new GlmDataAccounts( $this->wpdb, $this->config ); + $Accounts = new GlmDataAccounts( $this->wpdb, $this->config ); $billingAccount = $Accounts->newEntry(); - $accounts = $Accounts->getSimpleAccountList( '', 'ref_name' ); + $accounts = $Accounts->getSimpleAccountList( '', 'ref_name' ); // Need a list of members that don't have an account. $nonAccountMembers = $this->wpdb->get_results( @@ -386,9 +386,9 @@ class GlmMembersAdmin_billing_invoices extends GlmDataInvoices if ( isset( $invoiceTypes ) ) { foreach ( $invoiceTypes as $invoiceType ) { $invTypes[$invoiceType['id']] = array( - 'id' => $invoiceType['id'], - 'name' => $invoiceType['name'], - 'amount' => $invoiceType['amount'], + 'id' => $invoiceType['id'], + 'name' => $invoiceType['name'], + 'amount' => $invoiceType['amount'], ); } $invoiceTypeJSON = json_encode( $invTypes, true ); diff --git a/models/admin/member/billing.php b/models/admin/member/billing.php index 494b20c..b54a233 100644 --- a/models/admin/member/billing.php +++ b/models/admin/member/billing.php @@ -835,12 +835,20 @@ class GlmMembersAdmin_member_billing // extends GlmDataBilling $account = $Accounts->editEntry( $accountID ); // Get unpaid invoices - $invoices = $BillingSupport->getUnPaidInvoicesByAccount( $account['fieldData']['id'] ); - if ( !empty( $invoices ) ) { - foreach ( $invoices as &$invoice ) { - $invoice['due_date'] = date( 'n/d/Y', strtotime( $invoice['due_date'] ) ); - } - } + // $invoices = $BillingSupport->getUnPaidInvoicesByAccount( $account['fieldData']['id'] ); + $Invoices = new GlmDataInvoices( $this->wpdb, $this->config ); + $where_params = array( 'true' ); + $where_params[] = "( paid <> true OR paid IS NULL )"; + $where_params[] = "account = $accountID"; + $where = implode( ' AND ', $where_params ); + $Invoices->line_items_post = true; + $invoices = $Invoices->getList( $where ); + $Invoices->line_items_post = false; + // if ( !empty( $invoices ) ) { + // foreach ( $invoices as &$invoice ) { + // $invoice['due_date'] = date( 'n/d/Y', strtotime( $invoice['due_date'] ) ); + // } + // } $cc_accepts = $this->config['billing_settings']['cc_accepts']; @@ -895,12 +903,20 @@ class GlmMembersAdmin_member_billing // extends GlmDataBilling $account = $Accounts->editEntry( $accountID ); // Get unpaid invoices - $invoices = $BillingSupport->getUnPaidInvoicesByAccount( $account['fieldData']['id'] ); - if ( !empty( $invoices ) ) { - foreach ( $invoices as &$invoice ) { - $invoice['due_date'] = date( 'n/d/Y', strtotime( $invoice['due_date'] ) ); - } - } + // $invoices = $BillingSupport->getUnPaidInvoicesByAccount( $account['fieldData']['id'] ); + // if ( !empty( $invoices ) ) { + // foreach ( $invoices as &$invoice ) { + // $invoice['due_date'] = date( 'n/d/Y', strtotime( $invoice['due_date'] ) ); + // } + // } + $Invoices = new GlmDataInvoices( $this->wpdb, $this->config ); + $where_params = array( 'true' ); + $where_params[] = "( paid <> true OR paid IS NULL )"; + $where_params[] = "account = $accountID"; + $where = implode( ' AND ', $where_params ); + $Invoices->line_items_post = true; + $invoices = $Invoices->getList( $where ); + $Invoices->line_items_post = false; $cc_accepts = $this->config['billing_settings']['cc_accepts']; @@ -995,6 +1011,8 @@ class GlmMembersAdmin_member_billing // extends GlmDataBilling 'paymentMethods' => $this->config['alt_payment_method'], 'renewalFormSession' => $renewalFormSession, 'nextInvoiceDate' => $nextInvoiceDate, + 'pluginJsUrl' => GLM_MEMBERS_BILLING_PLUGIN_URL . '/js', + 'pluginCssUrl' => GLM_MEMBERS_BILLING_PLUGIN_URL . '/css', ); // Return status, any suggested view, and any data to controller. diff --git a/models/front/billing/paymentForm.php b/models/front/billing/paymentForm.php index ed133f1..8bde08e 100644 --- a/models/front/billing/paymentForm.php +++ b/models/front/billing/paymentForm.php @@ -182,10 +182,6 @@ class GlmMembersFront_billing_paymentForm // extends GlmDataBilling case 'paymentProcess': $error = false; $view = 'paymentFormProcess'; - // echo '
$_REQUEST: ' . print_r( $_REQUEST, true ) . '
'; - - // Here we need to get the chosen Membership plan and adjust the invoice with a new line_item if needed. - $selectedPaymentType = filter_var( $_REQUEST['member_renewing'], FILTER_VALIDATE_INT ); if ( isset( $_REQUEST['invoice_number'] ) ) { $invoiceId = filter_var( $_REQUEST['invoice_number'], FILTER_VALIDATE_INT ); @@ -194,9 +190,7 @@ class GlmMembersFront_billing_paymentForm // extends GlmDataBilling } // Pull member invoice $memberInvoice = $BillingSupport->getInvoiceById( $invoiceId ); - // echo '
$memberInvoice: ' . print_r( $memberInvoice, true ) . '
'; $memberInvoiceLineItems = $BillingSupport->getLineItemsForInvoice( $invoiceId ); - // echo '
$memberInvoiceLineItems: ' . print_r( $memberInvoiceLineItems, true ) . '
'; if ( isset( $memberInvoiceLineItems ) && is_array( $memberInvoiceLineItems ) && !empty( $memberInvoiceLineItems ) ) { foreach ( $memberInvoiceLineItems as $lineItem ) { if ( $lineItem['recurring'] ) { @@ -204,10 +198,6 @@ class GlmMembersFront_billing_paymentForm // extends GlmDataBilling } } } - // If there's new invoice type then we need to update the invoice - if ( $invoicePaymentType != $selectedPaymentType ) { - - } // Check for account_number // If given then this is from unregistered user. @@ -232,7 +222,6 @@ class GlmMembersFront_billing_paymentForm // extends GlmDataBilling case 'pay_by_credit_card': // Do the Payment Processing. $processErrors = $BillingSupport->processOnlinePayment( $accountId, $invoiceId, $_REQUEST['total_renew_amount'] ); - // echo '
$processErrors: ' . print_r( $processErrors, true ) . '
'; if ( $processErrors ) { if ( isset( $processErrors ) && is_array( $processErrors ) && count( $processErrors ) > 0 ) { diff --git a/views/admin/billing/invoices.html b/views/admin/billing/invoices.html index dff03eb..8215625 100644 --- a/views/admin/billing/invoices.html +++ b/views/admin/billing/invoices.html @@ -58,7 +58,7 @@ - + diff --git a/views/admin/billing/invoicing.html b/views/admin/billing/invoicing.html index 988f4e0..724a5b9 100644 --- a/views/admin/billing/invoicing.html +++ b/views/admin/billing/invoicing.html @@ -88,7 +88,9 @@ - + {if isset( $settings.account_number_enabled ) && $settings.account_number_enabled} + + {/if} @@ -101,7 +103,9 @@ {$t.member_name} - + {if isset( $settings.account_number_enabled ) && $settings.account_number_enabled} + + {/if} diff --git a/views/admin/billing/makePayment.html b/views/admin/billing/makePayment.html index 1489ec4..eee6ab1 100644 --- a/views/admin/billing/makePayment.html +++ b/views/admin/billing/makePayment.html @@ -34,7 +34,10 @@ {foreach $invoices as $invoice} {/foreach} {/if} diff --git a/views/admin/billing/paymentReceipt.html b/views/admin/billing/paymentReceipt.html index 2564c83..cafd504 100644 --- a/views/admin/billing/paymentReceipt.html +++ b/views/admin/billing/paymentReceipt.html @@ -4,121 +4,134 @@ margin: 20px; 50px; } #container-table .line-items { - border-collapse: collapse; + border-collapse: collapse !important; + margin: 0 !important; + padding: 0 !important; } body { width: auto !important; } -
Invoice #Invoice # Member Name Invoice For Time
Member Name Account Number Account Number Payment Type Balance Due
{$t.account_number} {$t.account_number} {$t.payment_type} {$t.balance_due|string_format:"%.2f"}
- - - - - - - - - - - - - - -
{if $settings.company_logo}{/if} -

RECEIPT

-
- {* Billing Invoice Settings *} - {$settings.company_name}
- {if $settings.company_name2}{$settings.company_name2}
{/if} - {if $settings.company_addr1}{$settings.company_addr1}
{/if} - {if $settings.company_addr2}{$settings.company_addr2}
{/if} - {if $settings.company_city}{$settings.company_city} {$settings.company_state}, {$settings.company_zip}
{/if} - {if $settings.company_phone}{$settings.company_phone}
{/if} - {if $settings.company_email}{$settings.company_email}
{/if} -
- - - - - - - - - - - - - - - - - -
Invoice Date: {$invoice.transaction_time|date_format:"%D"}
Due Date: {$invoice.due_date|date_format:"%D"}
Account #: {$account.id}
Invoice #: {$invoice.id}
-
-

Bill To:

- {if $account.ref_name}{$account.ref_name}
{/if} - {if $account.billing_addr1}{$account.billing_addr1}
{/if} - {if $account.billing_addr2}{$account.billing_addr2}
{/if} - {if $account.billing_city}{$account.billing_city} {$account.billing_state}, {$account.billing_zip}
{/if} - {if $account.billing_phone}{$account.billing_phone}
{/if} - - {* Billing Settings *} -
 
- - +
+
+ + + + + + + + + + + + + - - - {if $settings.receipt_text} - - - - {/if} - - {* Footer of invoice *} -
{if $settings.company_logo}{/if} +

RECEIPT

+
+ {* Billing Invoice Settings *} + {$settings.company_name}
+ {if $settings.company_name2}{$settings.company_name2}
{/if} + {if $settings.company_addr1}{$settings.company_addr1}
{/if} + {if $settings.company_addr2}{$settings.company_addr2}
{/if} + {if $settings.company_city}{$settings.company_city} {$settings.company_state}, {$settings.company_zip}
{/if} + {if $settings.company_phone}{$settings.company_phone}
{/if} + {if $settings.company_email}{$settings.company_email}
{/if} +
+ - - - - - + + - + + - - - {foreach $line_items as $item} - {if isset($item.account) && $item.account == "0"} - - - {else} - - - {/if} - - - + + + +
Member NameDate DescriptionRate Invoice Date: {$invoice.transaction_time|date_format:"%D"}

Due Date: {$invoice.due_date|date_format:"%D"}
N/AN/A{$item.account.ref_name}{$item.account.anniversary_date|date_format:"%m/%d/%y"} {$item.name}${$item.amount|string_format:"%.2f"} Invoice #: {$invoice.id}
+
+

Bill To:

+ {if $account.ref_name}{$account.ref_name}
{/if} + {if $account.billing_addr1}{$account.billing_addr1}
{/if} + {if $account.billing_addr2}{$account.billing_addr2}
{/if} + {if $account.billing_city}{$account.billing_city} {$account.billing_state}, {$account.billing_zip}
{/if} + {if $account.billing_phone}{$account.billing_phone}
{/if} + + {* Billing Settings *} +
+ + + + + + + + + {foreach $line_items as $item} + + + + + {/foreach} + +
DescriptionRate
{$item.name}${$item.amount|string_format:"%.2f"}
+ + + - {/foreach} {foreach $payments as $payment} - - - + {/foreach} - +
Payment Receipt:
  {$payment.transaction_time|date_format:"%m/%d/%y"}  {$payment.payment_method} {if $payment.amount >= 0}-{/if} ${abs($payment.amount)|string_format:"%.2f"}{if $payment.amount >= 0}-{/if} ${abs($payment.amount)|string_format:"%.2f"}

+ - + - -
Total Amount DueTotal Amount Due ${$invoice.balance|string_format:"%.2f"}
-
 
- {$settings.receipt_text} -
 
+
+ + + {if $settings.receipt_text} + + + {$settings.receipt_text} + + + {/if} + + +
Print Payment Receipt
+ + + {* Footer of invoice *} + + + + + diff --git a/views/admin/billing/reports.html b/views/admin/billing/reports.html index 826343e..13b6ea3 100644 --- a/views/admin/billing/reports.html +++ b/views/admin/billing/reports.html @@ -84,7 +84,9 @@ Member Name - Account Number + {if isset( $settings.account_number_enabled ) && $settings.account_number_enabled} + Account Number + {/if} Payment Type Balance Due @@ -96,7 +98,9 @@ {$t.member_name} - {$t.account_number} + {if isset( $settings.account_number_enabled ) && $settings.account_number_enabled} + {$t.account_number} + {/if} {$t.payment_type} {if $t.balance_due == 'N/A'} diff --git a/views/admin/settings/billing.html b/views/admin/settings/billing.html index 4fe4e52..bca0c61 100644 --- a/views/admin/settings/billing.html +++ b/views/admin/settings/billing.html @@ -157,7 +157,16 @@ Receipt Text - + {wp_editor( + $billingSettings.fieldData.receipt_text|escape:quotes, + 'receipt_text', + json_decode('{ + "media_buttons": false, + "quicktags": false, + "textarea_name": "receipt_text", + "editor_height": 200 + }', true) + )} {if $billingSettings.fieldFail.receipt_text}

{$billingSettings.fieldFail.receipt_text}

{/if}
diff --git a/views/common/billing/paymentForm.html b/views/common/billing/paymentForm.html index 4d193cc..bce7184 100644 --- a/views/common/billing/paymentForm.html +++ b/views/common/billing/paymentForm.html @@ -79,22 +79,22 @@
- Payment Options + Payment Information + + {* TODO: Check $billing_settings.payment_methods *} + {if !$lockedToMember}
Select Payment Option
- {* debug *}
- {* TODO: Check $billing_settings.payment_methods *} - {if !$lockedToMember} - {/if}
+ {/if} {if isset( $account.fieldData.payment_profile_card ) && $account.fieldData.payment_profile_card}
@@ -217,8 +217,12 @@ jQuery(document).ready(function($){ $('.ccard').prop('disabled', true); {/if} } else if ( payment_option == 'mark_paid' ) { - $('.glm-billing-credit').hide(); - $('.ccard').prop('disabled', true); + {if $billing_settings.proc_methods == 4} + $('.sq-payment-form').hide(); + {else} + $('.glm-billing-credit').hide(); + $('.ccard').prop('disabled', true); + {/if} } else { {if $billing_settings.proc_methods == 4} $('.sq-payment-form').show(); diff --git a/views/front/billing/paymentForm.html b/views/front/billing/paymentForm.html index 5c9f1fb..6c04421 100644 --- a/views/front/billing/paymentForm.html +++ b/views/front/billing/paymentForm.html @@ -105,6 +105,11 @@ jQuery(document).ready(function($){ alert( 'Not a valid Account #' ); $('#invoice_number').val(''); $('#membername').html(''); + $('#member_renewing').data( 'amount', '' ); + $('#member_renewing').val( '' ); + $('#billing-total-due').hide(); + $('#billing-member-name').hide(); + getPageTotal(); } else { // Set the account and member inputs $('#account_id').val( msg.account_id ); @@ -112,19 +117,32 @@ jQuery(document).ready(function($){ if ( msg.invoice.paid.value == "1" ) { $('#invoice_number').val(''); $('#membername').html(''); + $('#member_renewing').data( 'amount', '' ); + $('#member_renewing').val( '' ); alert( 'This invoice has already been paid!' ); + getPageTotal(); + $('#billing-total-due').hide(); + $('#billing-member-name').hide(); return false; } - if ( msg.invoice_type ) { - console.log( 'invoice_type', msg.invoice_type ); - $('#member_renewing').data( 'amount', msg.invoice.amount_total ); - $('#member_renewing').val( msg.invoice_type ); - $('#invoice_type_id_' + msg.invoice_type ).attr('checked', true); - $('#billing-msg-center').hide(); - $('#membername').html(msg.invoice.member_name); - $('#billing-total-due').show(); - $('#billing-member-name').show(); - getPageTotal(); + if ( msg.status ) { + // console.log( 'invoice_type', msg.invoice_type ); + $('#member_renewing').data( 'amount', msg.invoice.amount_total ); + $('#member_renewing').val( msg.invoice_type ); + // $('#invoice_type_id_' + msg.invoice_type ).attr('checked', true); + $('#billing-msg-center').hide(); + $('#membername').html(msg.invoice.member_name); + $('#billing-total-due').show(); + $('#billing-member-name').show(); + getPageTotal(); + } else { + $('#invoice_number').val(''); + $('#membername').html(''); + $('#member_renewing').data( 'amount', '' ); + $('#member_renewing').val( '' ); + $('#billing-total-due').hide(); + $('#billing-member-name').hide(); + getPageTotal(); } } }); -- 2.17.1