From 89dec5b455d801403f9c18df83cac55ba9be43cd Mon Sep 17 00:00:00 2001 From: Steve Sutton Date: Wed, 24 Jul 2019 16:49:40 -0400 Subject: [PATCH] Debuging issue with Foundation 6 reveals and forms. Cannot use $(document).on('submit') event for the foundation abide stuff. When used in reveals it is hitting the form submit more than once. It is adding to it everytime. --- classes/billingSupport.php | 2 + models/admin/member/billing.php | 13 +- views/admin/billing/accountReveals.html | 8 + views/admin/billing/editAccountAjax.html | 809 +++++++++--------- views/admin/billing/invoices.html | 23 +- .../billing/makePaymentAdjustmentAjax.html | 14 +- views/admin/billing/makePaymentAjax.html | 2 +- 7 files changed, 450 insertions(+), 421 deletions(-) diff --git a/classes/billingSupport.php b/classes/billingSupport.php index c29168b..2aa1cbb 100644 --- a/classes/billingSupport.php +++ b/classes/billingSupport.php @@ -289,11 +289,13 @@ class GlmBillingSupport 'invoice' => $invoice, 'payment' => $payment, 'amount' => $amount, + 'transaction_time' => date('Y-m-d H:i:s') ), array( '%d', '%d', '%s', + '%d' ) ); diff --git a/models/admin/member/billing.php b/models/admin/member/billing.php index 4eebc46..4b72227 100644 --- a/models/admin/member/billing.php +++ b/models/admin/member/billing.php @@ -682,6 +682,7 @@ class GlmMembersAdmin_member_billing // extends GlmDataBilling $accountUpdated = true; } 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; @@ -989,9 +990,17 @@ class GlmMembersAdmin_member_billing // extends GlmDataBilling $payment_id = false; } if ( $this->ajaxSide ) { + // 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 ); + } + $return = array( + 'payment_id' => $payment_id, + 'invoices' => $invoiceData + ); header( 'Content-type:application/json;charset=utf-8', true ); - // echo json_encode( $_REQUEST, true ); - echo json_encode( $payment_id, true ); + echo json_encode( $return, true ); exit; } break; diff --git a/views/admin/billing/accountReveals.html b/views/admin/billing/accountReveals.html index 7776791..04b3412 100644 --- a/views/admin/billing/accountReveals.html +++ b/views/admin/billing/accountReveals.html @@ -52,6 +52,10 @@ e.preventDefault(); var member = $(this).data('member'); var $modal = $('#glmBillingInfo'); + $modal.on('closed.zf.reveal', function(){ + console.log('Info reveal closed'); + $('glmBillingInfoFormWrap').remove(); + }); $.ajax({ url: '{$ajaxUrl}?action=glm_members_admin_ajax&glm_action=ajaxBillingInfo&option=account&member=' + member, @@ -69,6 +73,10 @@ e.preventDefault(); var member = $(this).data('member'); var $modalStm = $('#glmBillingStatements'); + $modalStm.on('closed.zf.reveal', function(){ + console.log('Statement reveal closed'); + $(this).html(' Cleared '); + }); $.ajax({ url: '{$ajaxUrl}?action=glm_members_admin_ajax&glm_action=ajaxBillingInfo&option=list&member=' + member, diff --git a/views/admin/billing/editAccountAjax.html b/views/admin/billing/editAccountAjax.html index 728fc36..fb15b91 100644 --- a/views/admin/billing/editAccountAjax.html +++ b/views/admin/billing/editAccountAjax.html @@ -1,475 +1,472 @@ - +
+ -

{$account.fieldData.ref_name}

+

{$account.fieldData.ref_name}

-{$data = $account} + {$data = $account} -
-
+
+ - + - - - + + + - {if $settings.member_types_enabled} - - {/if} - {if $lockedToMember} - - - - {/if} - - {if $accountID} - - {/if} - {if !$settings.account_number_enabled}{/if} + {if $settings.member_types_enabled} + + {/if} + {if $lockedToMember} + + + + {/if} - {include file='ui/f6/errorCallout.html'} + {if $accountID} + + {/if} + {if !$settings.account_number_enabled}{/if} -
- Account Information + {include file='ui/f6/errorCallout.html'} - {* Name *} - {$ui = [ - 'value' => $data.fieldData.ref_name, - 'field' => 'ref_name', - 'label' => 'Name', - 'placeholder' => 'Name', - 'required' => $data.fieldRequired.ref_name, - 'errorText' => 'Name is Required' - ]} - {include file='ui/f6/text.html'} +
+ Account Information + {* Name *} + {$ui = [ + 'value' => $data.fieldData.ref_name, + 'field' => 'ref_name', + 'label' => 'Name', + 'placeholder' => 'Name', + 'required' => $data.fieldRequired.ref_name, + 'errorText' => 'Name is Required' + ]} + {include file='ui/f6/text.html'} - {if !$lockedToMember} - {if $settings.account_number_enabled} - {* Account Number *} + {if !$lockedToMember} + {if $settings.account_number_enabled} + + {* Account Number *} + {$ui = [ + 'value' => $data.fieldData.account_number, + 'field' => 'account_number', + 'label' => 'Account Number', + 'placeholder' => 'Account Number', + 'required' => $data.fieldRequired.account_number, + 'errorText' => 'Account Number is Required' + ]} + {include file='ui/f6/text.html'} + + {/if} + + {if !$settings.member_types_enabled} + + {* Payment Type *} + {$ui = [ + 'value' => $data.fieldData.invoice_type.value, + 'field' => 'invoice_type', + 'label' => 'Payment Type', + 'list' => $data.fieldData.invoice_type.list, + 'l_label' => 'name', + 'l_value' => 'value', + 'l_blank' => false, + 'required' => $data.fieldRequired.invoice_type, + 'errorText' => 'Payment Type is Required' + ]} + {include file='ui/f6/select.html'} + + {/if} + + {if $settings.invoice_methods_enabled} + + {* Payment Methods *} + {$ui = [ + 'value' => [ + 'email_invoice' => $data.fieldData.invoice_type.value, + 'usmail_invoice' => $data.fieldData.usmail_invoice.value, + 'fax_invoice' => $data.fieldData.fax_invoice.value + ], + 'field' => 'invoice_type', + 'list' => ['email_invoice' => 'By Email','usmail_invoice' => 'By US Email','fax_invoice' => 'By Fax'], + 'label' => 'Invoice Delivery Methods', + 'required' => false, + 'errorText' => 'At least one Invoice Delivery Method is Required' + ]} + {include file='ui/f6/multicheckboxes.html'} + + {/if} + + {* Anniversary Date *} {$ui = [ - 'value' => $data.fieldData.account_number, - 'field' => 'account_number', - 'label' => 'Account Number', - 'placeholder' => 'Account Number', - 'required' => $data.fieldRequired.account_number, - 'errorText' => 'Account Number is Required' + 'value' => $data.fieldData.anniversary_date.date, + 'field' => 'anniversary_date', + 'label' => 'Anniversary Date', + 'placeholder' => 'Anniversary Date', + 'required' => $data.fieldRequired.anniversary_date, + 'errorText' => 'Anniversary Date is Required' ]} {include file='ui/f6/text.html'} - {/if} - - {if !$settings.member_types_enabled} - - {* Payment Type *} + {* Renewal Date *} {$ui = [ - 'value' => $data.fieldData.invoice_type.value, - 'field' => 'invoice_type', - 'label' => 'Payment Type', - 'list' => $data.fieldData.invoice_type.list, - 'l_label' => 'name', - 'l_value' => 'value', - 'l_blank' => false, - 'required' => $data.fieldRequired.invoice_type, - 'errorText' => 'Payment Type is Required' + 'value' => $data.fieldData.renewal_date.date, + 'field' => 'renewal_date', + 'label' => 'Renewal Date', + 'placeholder' => 'Renewal Date', + 'required' => $data.fieldRequired.renewal_date, + 'errorText' => 'Renewal Date is Required' ]} - {include file='ui/f6/select.html'} + {include file='ui/f6/text.html'} {/if} - {if $settings.invoice_methods_enabled} + {if $settings.allow_employees} - {* Payment Methods *} - {$ui = [ - 'value' => [ - 'email_invoice' => $data.fieldData.invoice_type.value, - 'usmail_invoice' => $data.fieldData.usmail_invoice.value, - 'fax_invoice' => $data.fieldData.fax_invoice.value - ], - 'field' => 'invoice_type', - 'list' => ['email_invoice' => 'By Email','usmail_invoice' => 'By US Email','fax_invoice' => 'By Fax'], - 'label' => 'Invoice Delivery Methods', - 'required' => false, - 'errorText' => 'At least one Invoice Delivery Method is Required' - ]} - {include file='ui/f6/multicheckboxes.html'} +
+
Boss
+
+ + {if $account.fieldFail.boss}

{$account.fieldFail.boss}

{/if}
+
+
+ +
+
+ Associated Members/Employees +
+
+ +
+ {if $employees} + {foreach $employees as $employee} +
+ + {$employee.employee_name} + +
+ {/foreach} + {/if} +
+
+
{/if} - {* Anniversary Date *} +
+ +
+ Billing Information + + {* Billing Email *} {$ui = [ - 'value' => $data.fieldData.anniversary_date.date, - 'field' => 'anniversary_date', - 'label' => 'Anniversary Date', - 'placeholder' => 'Anniversary Date', - 'required' => $data.fieldRequired.anniversary_date, - 'errorText' => 'Anniversary Date is Required' + 'value' => $data.fieldData.email, + 'field' => 'email', + 'label' => 'Billing Email', + 'placeholder' => 'Billing Email', + 'required' => $data.fieldRequired.email, + 'errorText' => 'Billing Email is Required' ]} {include file='ui/f6/text.html'} - {* Renewal Date *} + {* Billing Company *} {$ui = [ - 'value' => $data.fieldData.renewal_date.date, - 'field' => 'renewal_date', - 'label' => 'Renewal Date', - 'placeholder' => 'Renewal Date', - 'required' => $data.fieldRequired.renewal_date, - 'errorText' => 'Renewal Date is Required' + 'value' => $data.fieldData.billing_company, + 'field' => 'billing_company', + 'label' => 'Billing Company', + 'placeholder' => 'Billing Company', + 'required' => $data.fieldRequired.billing_company, + 'errorText' => 'Billing Company is Required' ]} {include file='ui/f6/text.html'} - {/if} - - {if $settings.allow_employees} + {* Billing Position *} + {$ui = [ + 'value' => $data.fieldData.billing_position, + 'field' => 'billing_position', + 'label' => 'Billing Position', + 'placeholder' => 'Billing Position', + 'required' => $data.fieldRequired.billing_position, + 'errorText' => 'Billing Position is Required' + ]} + {include file='ui/f6/text.html'} -
-
Boss
-
- - {if $account.fieldFail.boss}

{$account.fieldFail.boss}

{/if}
-
-
+ {if $settings.billing_contact_name_enabled} -
-
- Associated Members/Employees -
-
- -
- {if $employees} - {foreach $employees as $employee} -
- - {$employee.employee_name} - -
- {/foreach} - {/if} -
-
-
+ {* Billing Contact Name *} + {$ui = [ + 'value' => $data.fieldData.billing_contact_name, + 'field' => 'billing_contact_name', + 'label' => 'Billing Contact Name', + 'placeholder' => 'Billing Contact Name', + 'required' => $data.fieldRequired.billing_contact_name, + 'errorText' => 'Billing Contact Name is Required' + ]} + {include file='ui/f6/text.html'} + {else} + {* Billing First Name *} + {$ui = [ + 'value' => $data.fieldData.billing_fname, + 'field' => 'billing_fname', + 'label' => 'Billing First Name', + 'placeholder' => 'Billing First Name', + 'required' => $data.fieldRequired.billing_fname, + 'errorText' => 'Billing First Name is Required' + ]} + {include file='ui/f6/text.html'} - {/if} + {* Billing Last Name *} + {$ui = [ + 'value' => $data.fieldData.billing_lname, + 'field' => 'billing_lname', + 'label' => 'Billing Last Name', + 'placeholder' => 'Billing Last Name', + 'required' => $data.fieldRequired.billing_lname, + 'errorText' => 'Billing Last Name is Required' + ]} + {include file='ui/f6/text.html'} + {/if} -
- -
- Billing Information - - {* Billing Email *} - {$ui = [ - 'value' => $data.fieldData.email, - 'field' => 'email', - 'label' => 'Billing Email', - 'placeholder' => 'Billing Email', - 'required' => $data.fieldRequired.email, - 'errorText' => 'Billing Email is Required' - ]} - {include file='ui/f6/text.html'} - - {* Billing Company *} - {$ui = [ - 'value' => $data.fieldData.billing_company, - 'field' => 'billing_company', - 'label' => 'Billing Company', - 'placeholder' => 'Billing Company', - 'required' => $data.fieldRequired.billing_company, - 'errorText' => 'Billing Company is Required' - ]} - {include file='ui/f6/text.html'} - - {* Billing Position *} - {$ui = [ - 'value' => $data.fieldData.billing_position, - 'field' => 'billing_position', - 'label' => 'Billing Position', - 'placeholder' => 'Billing Position', - 'required' => $data.fieldRequired.billing_position, - 'errorText' => 'Billing Position is Required' - ]} - {include file='ui/f6/text.html'} - - {if $settings.billing_contact_name_enabled} - - {* Billing Contact Name *} + {* Billing Address 1 *} {$ui = [ - 'value' => $data.fieldData.billing_contact_name, - 'field' => 'billing_contact_name', - 'label' => 'Billing Contact Name', - 'placeholder' => 'Billing Contact Name', - 'required' => $data.fieldRequired.billing_contact_name, - 'errorText' => 'Billing Contact Name is Required' + 'value' => $data.fieldData.billing_addr1, + 'field' => 'billing_addr1', + 'label' => 'Billing Address 1', + 'placeholder' => 'Billing Address 1', + 'required' => $data.fieldRequired.billing_addr1, + 'errorText' => 'Billing Address 1 is Required' ]} {include file='ui/f6/text.html'} - {else} - {* Billing First Name *} + + {* Billing Address 2 *} {$ui = [ - 'value' => $data.fieldData.billing_fname, - 'field' => 'billing_fname', - 'label' => 'Billing First Name', - 'placeholder' => 'Billing First Name', - 'required' => $data.fieldRequired.billing_fname, - 'errorText' => 'Billing First Name is Required' + 'value' => $data.fieldData.billing_addr2, + 'field' => 'billing_addr2', + 'label' => 'Billing Address 2', + 'placeholder' => 'Billing Address 2', + 'required' => $data.fieldRequired.billing_addr2, + 'errorText' => 'Billing Address 2 is Required' ]} {include file='ui/f6/text.html'} - {* Billing Last Name *} + {* Billing City *} {$ui = [ - 'value' => $data.fieldData.billing_lname, - 'field' => 'billing_lname', - 'label' => 'Billing Last Name', - 'placeholder' => 'Billing Last Name', - 'required' => $data.fieldRequired.billing_lname, - 'errorText' => 'Billing Last Name is Required' + 'value' => $data.fieldData.billing_city, + 'field' => 'billing_city', + 'label' => 'Billing City', + 'placeholder' => 'Billing City', + 'required' => $data.fieldRequired.billing_city, + 'errorText' => 'Billing City is Required' ]} {include file='ui/f6/text.html'} - {/if} - {* Billing Address 1 *} - {$ui = [ - 'value' => $data.fieldData.billing_addr1, - 'field' => 'billing_addr1', - 'label' => 'Billing Address 1', - 'placeholder' => 'Billing Address 1', - 'required' => $data.fieldRequired.billing_addr1, - 'errorText' => 'Billing Address 1 is Required' - ]} - {include file='ui/f6/text.html'} - - {* Billing Address 2 *} - {$ui = [ - 'value' => $data.fieldData.billing_addr2, - 'field' => 'billing_addr2', - 'label' => 'Billing Address 2', - 'placeholder' => 'Billing Address 2', - 'required' => $data.fieldRequired.billing_addr2, - 'errorText' => 'Billing Address 2 is Required' - ]} - {include file='ui/f6/text.html'} - - {* Billing City *} - {$ui = [ - 'value' => $data.fieldData.billing_city, - 'field' => 'billing_city', - 'label' => 'Billing City', - 'placeholder' => 'Billing City', - 'required' => $data.fieldRequired.billing_city, - 'errorText' => 'Billing City is Required' - ]} - {include file='ui/f6/text.html'} - - {if $settings.billing_county_enabled} - {* Billing County *} + {if $settings.billing_county_enabled} + {* Billing County *} + {$ui = [ + 'value' => $data.fieldData.billing_county.value, + 'field' => 'billing_county', + 'label' => 'Billing County', + 'list' => $data.fieldData.billing_county.list, + 'l_label' => 'name', + 'l_value' => 'value', + 'l_blank' => false, + 'required' => $data.fieldRequired.billing_county, + 'errorText' => 'Billing County is Required' + ]} + {include file='ui/f6/select.html'} + {else} + + {/if} + + {* Billing State *} {$ui = [ - 'value' => $data.fieldData.billing_county.value, - 'field' => 'billing_county', - 'label' => 'Billing County', - 'list' => $data.fieldData.billing_county.list, + 'value' => $data.fieldData.billing_state.value, + 'field' => 'billing_state', + 'label' => 'Billing State', + 'list' => $data.fieldData.billing_state.list, 'l_label' => 'name', 'l_value' => 'value', 'l_blank' => false, - 'required' => $data.fieldRequired.billing_county, - 'errorText' => 'Billing County is Required' + 'required' => $data.fieldRequired.billing_state, + 'errorText' => 'Billing State is Required' ]} {include file='ui/f6/select.html'} - {else} - - {/if} - {* Billing State *} - {$ui = [ - 'value' => $data.fieldData.billing_state.value, - 'field' => 'billing_state', - 'label' => 'Billing State', - 'list' => $data.fieldData.billing_state.list, - 'l_label' => 'name', - 'l_value' => 'value', - 'l_blank' => false, - 'required' => $data.fieldRequired.billing_state, - 'errorText' => 'Billing State is Required' - ]} - {include file='ui/f6/select.html'} - - {* Billing Zip *} - {$ui = [ - 'value' => $data.fieldData.billing_zip, - 'field' => 'billing_zip', - 'label' => 'Billing Zip', - 'placeholder' => 'Billing Zip', - 'required' => $data.fieldRequired.billing_zip, - 'errorText' => 'Billing Zip is Required' - ]} - {include file='ui/f6/text.html'} - - {* Billing Country *} - {$ui = [ - 'value' => $data.fieldData.billing_country, - 'field' => 'billing_country', - 'label' => 'Billing Country', - 'placeholder' => 'Billing Country', - 'required' => $data.fieldRequired.billing_country, - 'errorText' => 'Billing Country is Required' - ]} - {include file='ui/f6/text.html'} - - {* Billing Phone *} - {$ui = [ - 'value' => $data.fieldData.billing_phone, - 'field' => 'billing_phone', - 'label' => 'Billing Phone', - 'placeholder' => 'Billing Phone', - 'required' => $data.fieldRequired.billing_phone, - 'errorText' => 'Billing Phone is Required' - ]} - {include file='ui/f6/text.html'} - - {* Billing Fax *} - {$ui = [ - 'value' => $data.fieldData.billing_fax, - 'field' => 'billing_fax', - 'label' => 'Billing Fax', - 'placeholder' => 'Billing Fax', - 'required' => $data.fieldRequired.billing_fax, - 'errorText' => 'Billing Fax is Required' - ]} - {include file='ui/f6/text.html'} - -
- - {include file='ui/f6/errorCallout.html'} - - - - - - -
+ {* Billing Zip *} + {$ui = [ + 'value' => $data.fieldData.billing_zip, + 'field' => 'billing_zip', + 'label' => 'Billing Zip', + 'placeholder' => 'Billing Zip', + 'required' => $data.fieldRequired.billing_zip, + 'errorText' => 'Billing Zip is Required' + ]} + {include file='ui/f6/text.html'} + + {* Billing Country *} + {$ui = [ + 'value' => $data.fieldData.billing_country, + 'field' => 'billing_country', + 'label' => 'Billing Country', + 'placeholder' => 'Billing Country', + 'required' => $data.fieldRequired.billing_country, + 'errorText' => 'Billing Country is Required' + ]} + {include file='ui/f6/text.html'} + + {* Billing Phone *} + {$ui = [ + 'value' => $data.fieldData.billing_phone, + 'field' => 'billing_phone', + 'label' => 'Billing Phone', + 'placeholder' => 'Billing Phone', + 'required' => $data.fieldRequired.billing_phone, + 'errorText' => 'Billing Phone is Required' + ]} + {include file='ui/f6/text.html'} - + +
diff --git a/views/admin/billing/invoices.html b/views/admin/billing/invoices.html index 8a4b7ba..4ee87c0 100644 --- a/views/admin/billing/invoices.html +++ b/views/admin/billing/invoices.html @@ -100,7 +100,7 @@ {$t.transaction_time.datetime} {$t.due_date.date} {$t.amount_total} - {$t.balance} + {$t.balance} @@ -119,15 +119,23 @@   {else} Send Invoice | {if $billing_settings.uptravel_payment_form} - Make A Payment | + Make A Payment | {else} - Pay Invoice | + Pay Invoice | {/if} {/if} @@ -209,6 +217,13 @@ 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 45a5fd3..a8951a9 100644 --- a/views/admin/billing/makePaymentAdjustmentAjax.html +++ b/views/admin/billing/makePaymentAdjustmentAjax.html @@ -17,7 +17,7 @@ {/if} {if $invoices} -
+ @@ -106,13 +106,7 @@ jQuery(document).ready(function($){ {* Form validation using abide *} var abide = new Foundation.Abide($('#billingPaymentForm')); - $(document) - .on('invalid.zf.abide', function(ev,elem){ - return false; - // $('#billingPaymentForm').foundation('requiredCheck', elem); - }) - // .on('forminvalid.zf.abide', function(ev,frm){ - // }) + $('#billingPaymentForm') .on('submit', function(ev){ ev.preventDefault(); var validForm = $('#billingPaymentForm').foundation('validateForm'); @@ -126,10 +120,14 @@ jQuery(document).ready(function($){ if ( rsp ) { 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 ); + return true; } else { return false; } }).fail(function(){ + return false; }); return false; }); diff --git a/views/admin/billing/makePaymentAjax.html b/views/admin/billing/makePaymentAjax.html index d846069..d14ba6b 100644 --- a/views/admin/billing/makePaymentAjax.html +++ b/views/admin/billing/makePaymentAjax.html @@ -98,7 +98,7 @@ jQuery(document).ready(function($){ {* Form validation using abide *} var abide = new Foundation.Abide($('#billingPaymentForm')); - $(document) + $('#billingPaymentForm') .on('invalid.zf.abide', function(ev,elem){ return false; // $('#billingPaymentForm').foundation('requiredCheck', elem); -- 2.17.1