Working on fixing issues with payments made on invoice page.
authorSteve Sutton <steve@gaslightmedia.com>
Thu, 25 Jul 2019 14:06:13 +0000 (10:06 -0400)
committerSteve Sutton <steve@gaslightmedia.com>
Thu, 25 Jul 2019 14:06:13 +0000 (10:06 -0400)
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
models/admin/member/billing.php
views/admin/billing/editInvoiceType.html
views/admin/billing/invoices.html
views/admin/billing/makePaymentAdjustmentAjax.html
views/admin/billing/payments.html

index d64f5f3..e63f102 100644 (file)
@@ -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'],
index 4b72227..38fcb0c 100644 (file)
@@ -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,
index fe9a142..d4fff52 100644 (file)
                 'errorText' => 'Recurrence is Required',
                 'dataError' => $data.fieldFail.recurrence
             ]}
+            {if $data.fieldData.recurring.value}
+                {$ui['required'] = true}
+            {/if}
             {include file='ui/f6/select.html'}
 
 
index 4ee87c0..17c8ffd 100644 (file)
                 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(
-                        '<div id="glmBillingPayment" class="medium reveal" data-reveal data-close-on-click="false"></div>'
-                    );
-                    var elem = new Foundation.Reveal($('#glmBillingPayment'));
-                });
             });
             return false;
         });
index a8951a9..245cd84 100644 (file)
@@ -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;
index afec833..f667aa8 100644 (file)
@@ -58,7 +58,7 @@
 
 <br clear="all">
 
-<p>Total found: <span class="label">{$numbDisplayed}</span></p>
+<p>Total found: <span class="label">{$numbDisplayed|default:'0'}</span></p>
 {if $paging}
     <input type="Submit" name="pageSelect" value="Previous {$limit} Accounts" class="button button-secondary glm-button"{if !$prevStart} disabled{/if}>
     <input type="Submit" name="pageSelect" value="Next {$limit} Accounts" class="button button-secondary glm-button"{if !$nextStart} disabled{/if}>