From 24876e7db1c178f5f1a4f417342cfedd264778e5 Mon Sep 17 00:00:00 2001 From: Steve Sutton Date: Thu, 25 Jul 2019 10:06:13 -0400 Subject: [PATCH] Working on fixing issues with payments made on invoice page. When paying invoices from the invoice page the abide .on('submit') events need to be setup on the $('#formId') instead of the $(document). Failure to do this will result in many submits because it keeps adding to the document. --- classes/notifications.php | 18 ++++++++++++++++++ models/admin/member/billing.php | 2 +- views/admin/billing/editInvoiceType.html | 3 +++ views/admin/billing/invoices.html | 7 ------- .../billing/makePaymentAdjustmentAjax.html | 15 ++++++++++++++- views/admin/billing/payments.html | 2 +- 6 files changed, 37 insertions(+), 10 deletions(-) diff --git a/classes/notifications.php b/classes/notifications.php index d64f5f3..e63f102 100644 --- a/classes/notifications.php +++ b/classes/notifications.php @@ -129,6 +129,22 @@ class GlmNotifications $viewFile = 'admin/notifications/notification.html'; if ( !$test ) { + $defaultContactData = array( + 'org' => '', + 'business_fname' => '', + 'business_lname' => '', + 'title' => '', + 'business_addr1' => '', + 'business_addr2' => '', + 'business_city' => '', + 'business_state' => array( 'value' => '' ), + 'business_zip' => '', + 'business_email' => '', + 'business_phone' => '', + 'office_phone' => '', + 'business_mobile' => '', + 'fax' => '', + ); // Get Contact Data $contactData = apply_filters( 'glm-member-db-contacts-get-contact-data-by-refdest', $account['ref_dest'] ); if ( !$contactData ) { @@ -150,6 +166,8 @@ class GlmNotifications ); } + $contactData = array_merge( $defaultContactData, $contactData ); + $account_data = array( 'account' => array( 'name' => $account['ref_name'], diff --git a/models/admin/member/billing.php b/models/admin/member/billing.php index 4b72227..38fcb0c 100644 --- a/models/admin/member/billing.php +++ b/models/admin/member/billing.php @@ -993,7 +993,7 @@ class GlmMembersAdmin_member_billing // extends GlmDataBilling // TODO: get invoices (array) of data and send back // Need to know which invoices were effected with payment. if ( !empty( $invoices ) ) { - $invoiceData = array_map( $BillingSupport->getInvoiceById, $invoices ); + $invoiceData = array_map( array( $BillingSupport, 'getInvoiceById' ), $invoices ); } $return = array( 'payment_id' => $payment_id, diff --git a/views/admin/billing/editInvoiceType.html b/views/admin/billing/editInvoiceType.html index fe9a142..d4fff52 100644 --- a/views/admin/billing/editInvoiceType.html +++ b/views/admin/billing/editInvoiceType.html @@ -161,6 +161,9 @@ 'errorText' => 'Recurrence is Required', 'dataError' => $data.fieldFail.recurrence ]} + {if $data.fieldData.recurring.value} + {$ui['required'] = true} + {/if} {include file='ui/f6/select.html'} diff --git a/views/admin/billing/invoices.html b/views/admin/billing/invoices.html index 4ee87c0..17c8ffd 100644 --- a/views/admin/billing/invoices.html +++ b/views/admin/billing/invoices.html @@ -217,13 +217,6 @@ complete: completeAjax, }).done(function(resp){ $modalPayment.html(resp).foundation('open').trigger('resizeme.zp.reveal'); - $modalPayment.on('closed.zf.reveal', function(){ - $('#glmBillingPayment').foundation('_destroy'); - $('.glm-foundation-6-ui').append( - '
' - ); - var elem = new Foundation.Reveal($('#glmBillingPayment')); - }); }); return false; }); diff --git a/views/admin/billing/makePaymentAdjustmentAjax.html b/views/admin/billing/makePaymentAdjustmentAjax.html index a8951a9..245cd84 100644 --- a/views/admin/billing/makePaymentAdjustmentAjax.html +++ b/views/admin/billing/makePaymentAdjustmentAjax.html @@ -121,7 +121,20 @@ jQuery(document).ready(function($){ var $sucessModal = $('#billingSuccess'); $sucessModal.foundation('open').trigger('resizeme.zp.reveal'); // TODO: Need to refresh the page or the section for this invoice. - console.log( 'rsp:', rsp ); + if ( rsp.invoices.length > 0 ) { + // Loop over the invoices and update the ones if found on this page. + for ( var i in rsp.invoices ) { + // Update the balance due + $('#balance-' + rsp.invoices[i].id ).html( rsp.invoices[i].balance ); + // If the invoices is marked 'Paid' then remove the make payment + // or pay invoices links and the send invoices line + if ( rsp.invoices[i].paid ) { + $('#make-a-payment-' + rsp.invoices[i].id).remove(); + $('#pay-invoice-' + rsp.invoices[i].id).remove(); + $('#send-invoice-' + rsp.invoices[i].id).remove(); + } + } + } return true; } else { return false; diff --git a/views/admin/billing/payments.html b/views/admin/billing/payments.html index afec833..f667aa8 100644 --- a/views/admin/billing/payments.html +++ b/views/admin/billing/payments.html @@ -58,7 +58,7 @@
-

Total found: {$numbDisplayed}

+

Total found: {$numbDisplayed|default:'0'}

{if $paging} -- 2.17.1