Debuging issue with Foundation 6 reveals and forms.
authorSteve Sutton <steve@gaslightmedia.com>
Wed, 24 Jul 2019 20:49:40 +0000 (16:49 -0400)
committerSteve Sutton <steve@gaslightmedia.com>
Wed, 24 Jul 2019 20:49:40 +0000 (16:49 -0400)
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
models/admin/member/billing.php
views/admin/billing/accountReveals.html
views/admin/billing/editAccountAjax.html
views/admin/billing/invoices.html
views/admin/billing/makePaymentAdjustmentAjax.html
views/admin/billing/makePaymentAjax.html

index c29168b..2aa1cbb 100644 (file)
@@ -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'
             )
         );
 
index 4eebc46..4b72227 100644 (file)
@@ -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;
index 7776791..04b3412 100644 (file)
             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,
             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,
index 728fc36..fb15b91 100644 (file)
-<button class="close-button" data-close aria-label="Close" type="button">
-    <span aria-hidden="true">&times;</span>
-</button>
+<div id="glmBillingInfoFormWrap">
+    <button class="close-button" data-close aria-label="Close" type="button">
+        <span aria-hidden="true">&times;</span>
+    </button>
 
-<h2>{$account.fieldData.ref_name}</h2>
+    <h2>{$account.fieldData.ref_name}</h2>
 
-{$data = $account}
+    {$data = $account}
 
-<div class="glm-billing-form">
-    <form id="billingInfoForm" action="{$ajaxUrl}?action=glm_members_admin_ajax" method="post" data-abide novalidate>
+    <div class="glm-billing-form">
+        <form id="billingInfoForm" action="{$ajaxUrl}?action=glm_members_admin_ajax" method="post" data-abide novalidate>
 
-        <input type="hidden" name="glm_action" value="ajaxBillingInfo" />
+            <input type="hidden" name="glm_action" value="ajaxBillingInfo" />
 
-        <input type="hidden" name="member" value="{$memberID}" />
-        <input type="hidden" name="ref_dest" value="{$memberID}" />
-        <input type="hidden" name="option" value="account" />
+            <input type="hidden" name="member" value="{$memberID}" />
+            <input type="hidden" name="ref_dest" value="{$memberID}" />
+            <input type="hidden" name="option" value="account" />
 
-        {if $settings.member_types_enabled}
-            <input type="hidden" name="invoice_type" value="{$account.fieldData.invoice_type}" />
-        {/if}
-        {if $lockedToMember}
-            <input type="hidden" name="anniversary_date" value="{$account.fieldData.anniversary_date.date}" />
-            <input type="hidden" name="renewal_date" value="{$account.fieldData.renewal_date.date}" />
-            <input type="hidden" name="account_number" value="{$account.fieldData.account_number}" />
-        {/if}
-
-        {if $accountID}
-            <input type="hidden" name="id" value="{$accountID}">
-        {/if}
-        {if !$settings.account_number_enabled}<input type="hidden" name="account_number" value="{$account.fieldData.account_number}" />{/if}
+            {if $settings.member_types_enabled}
+                <input type="hidden" name="invoice_type" value="{$account.fieldData.invoice_type}" />
+            {/if}
+            {if $lockedToMember}
+                <input type="hidden" name="anniversary_date" value="{$account.fieldData.anniversary_date.date}" />
+                <input type="hidden" name="renewal_date" value="{$account.fieldData.renewal_date.date}" />
+                <input type="hidden" name="account_number" value="{$account.fieldData.account_number}" />
+            {/if}
 
-        {include file='ui/f6/errorCallout.html'}
+            {if $accountID}
+                <input type="hidden" name="id" value="{$accountID}">
+            {/if}
+            {if !$settings.account_number_enabled}<input type="hidden" name="account_number" value="{$account.fieldData.account_number}" />{/if}
 
-        <fieldset class="fieldset cell small-12">
-            <legend>Account Information</legend>
+            {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'}
+            <fieldset class="fieldset cell small-12">
+                <legend>Account Information</legend>
 
+                {* 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'}
+                    <div class="glm-billing-field">
+                        <div class="glm-billing-label{if $account.fieldRequired.boss} glm-required{/if}">Boss</div>
+                        <div class="glm-billing-input{if $account.fieldFail.boss} glm-form-bad-input{/if}" data-tabid="glm-name">
+                            <input id="billing-boss" type="checkbox" name="boss"{if $account.fieldData.boss.value} checked{/if}>
+                        {if $account.fieldFail.boss}<p>{$account.fieldFail.boss}</p>{/if}<br>
+                        </div>
+                    </div>
+
+                    <div id="glm-emp-list" class="glm-billing-field">
+                        <div class="glm-billing-label">
+                            <strong>Associated Members/Employees</strong>
+                        </div>
+                        <div class="glm-billing-input">
+                            <input id="glm-billing-member-list" placeholder="Lookup Member">
+                            <div id="glm-billing-employees">
+                                {if $employees}
+                                    {foreach $employees as $employee}
+                                        <div class="glm-billing-employee">
+                                            <input type="hidden" name="employees[{$employee.employee}]" value="1">
+                                            {$employee.employee_name}
+                                            <span class="glm-billing-employee-del dashicons dashicons-trash glm-right"></span>
+                                        </div>
+                                    {/foreach}
+                                {/if}
+                            </div>
+                        </div>
+                    </div>
 
                 {/if}
 
-                {* Anniversary Date *}
+            </fieldset>
+
+            <fieldset class="fieldset cell small-12">
+                <legend>Billing Information</legend>
+
+                {* 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'}
 
-                <div class="glm-billing-field">
-                    <div class="glm-billing-label{if $account.fieldRequired.boss} glm-required{/if}">Boss</div>
-                    <div class="glm-billing-input{if $account.fieldFail.boss} glm-form-bad-input{/if}" data-tabid="glm-name">
-                        <input id="billing-boss" type="checkbox" name="boss"{if $account.fieldData.boss.value} checked{/if}>
-                    {if $account.fieldFail.boss}<p>{$account.fieldFail.boss}</p>{/if}<br>
-                    </div>
-                </div>
+                {if $settings.billing_contact_name_enabled}
 
-                <div id="glm-emp-list" class="glm-billing-field">
-                    <div class="glm-billing-label">
-                        <strong>Associated Members/Employees</strong>
-                    </div>
-                    <div class="glm-billing-input">
-                        <input id="glm-billing-member-list" placeholder="Lookup Member">
-                        <div id="glm-billing-employees">
-                            {if $employees}
-                                {foreach $employees as $employee}
-                                    <div class="glm-billing-employee">
-                                        <input type="hidden" name="employees[{$employee.employee}]" value="1">
-                                        {$employee.employee_name}
-                                        <span class="glm-billing-employee-del dashicons dashicons-trash glm-right"></span>
-                                    </div>
-                                {/foreach}
-                            {/if}
-                        </div>
-                    </div>
-                </div>
+                    {* 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}
 
-        </fieldset>
-
-        <fieldset class="fieldset cell small-12">
-            <legend>Billing Information</legend>
-
-            {* 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}
+                    <input type="hidden" name="billing_county" value="{$account.fieldData.billing_county.value}">
+                {/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}
-                <input type="hidden" name="billing_county" value="{$account.fieldData.billing_county.value}">
-            {/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'}
-
-        </fieldset>
-
-        {include file='ui/f6/errorCallout.html'}
-
-        <button class="button button-primary" type="submit" style="margin-top: 0;">{if $haveAccount}Save{else}Create{/if} Account</button>
-
-        <button class="button glm-right" data-close aria-label="Cancel" type="button">
-            <span>Cancel</span>
-        </button>
-
-    </form>
-</div>
+                {* 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'}
 
-<script>
-jQuery(document).ready(function($){
+                {* 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'}
 
-    var accounts = [ {foreach $accounts as $m} { label: "{$m.ref_name|unescape:'html'|replace:'"':''}", value: "{$m.ref_name|unescape:'html'|replace:'"':''}", id: '{$m.id}' }, {/foreach} ];
-    var isBoss = {if $account.fieldData.boss.value}true{else}false{/if};
+            </fieldset>
 
-    // Setup autocomplete for both inputs
-    $('#glm-billing-member-list').autocomplete({
-        source: accounts,
-        select: function( event, ui ){
-            addEmployee( ui.item );
-            $('#glm-billing-member-list').val( '' );
-            return false;
-        },
-        change: function( event, ui) {
-            if( ui.item == null ) {
+            {include file='ui/f6/errorCallout.html'}
+
+            <button class="button button-primary" type="submit" style="margin-top: 0;">{if $haveAccount}Save{else}Create{/if} Account</button>
+
+            <button class="button glm-right" data-close aria-label="Cancel" type="button">
+                <span>Cancel</span>
+            </button>
+
+        </form>
+    </div>
+
+    <script>
+    jQuery(document).ready(function($){
+
+        var accounts = [ {foreach $accounts as $m} { label: "{$m.ref_name|unescape:'html'|replace:'"':''}", value: "{$m.ref_name|unescape:'html'|replace:'"':''}", id: '{$m.id}' }, {/foreach} ];
+        var isBoss = {if $account.fieldData.boss.value}true{else}false{/if};
+
+        // Setup autocomplete for both inputs
+        $('#glm-billing-member-list').autocomplete({
+            source: accounts,
+            select: function( event, ui ){
+                addEmployee( ui.item );
                 $('#glm-billing-member-list').val( '' );
                 return false;
-            }
-        },
-    });
+            },
+            change: function( event, ui) {
+                if( ui.item == null ) {
+                    $('#glm-billing-member-list').val( '' );
+                    return false;
+                }
+            },
+        });
 
-    function addEmployee( employee ) {
-        var html = '<div class="glm-billing-employee">';
-        html += '<input type="hidden" name="employees[' + employee.id + ']" value="1">';
-        html += employee.label;
-        html += '<span class="glm-billing-employee-del dashicons dashicons-trash glm-right"></span>';
-        html += '</div>';
-        $('#glm-billing-employees').append(html);
-    }
-
-    // If the boss flag in unchecked then hide the employees box and
-    // disable the employees inputs.
-    $('#billing-boss').change(function(){
-        if ( $(this).is(':checked') ) {
-            isBoss = true;
-        } else {
-            isBoss = false;
+        function addEmployee( employee ) {
+            var html = '<div class="glm-billing-employee">';
+            html += '<input type="hidden" name="employees[' + employee.id + ']" value="1">';
+            html += employee.label;
+            html += '<span class="glm-billing-employee-del dashicons dashicons-trash glm-right"></span>';
+            html += '</div>';
+            $('#glm-billing-employees').append(html);
         }
-        setupEmployeesPart();
-    });
-    function setupEmployeesPart() {
-        if ( isBoss ) {
-            $('#glm-emp-list').show();
-            $('input[name^="employees"]').each(function(){
-                $(this).removeAttr('disabled');
-            });
-        } else {
-            $('#glm-emp-list').hide();
-            $('input[name^="employees"]').each(function(){
-                $(this).prop('disabled', true);
-            });
+
+        // If the boss flag in unchecked then hide the employees box and
+        // disable the employees inputs.
+        $('#billing-boss').change(function(){
+            if ( $(this).is(':checked') ) {
+                isBoss = true;
+            } else {
+                isBoss = false;
+            }
+            setupEmployeesPart();
+        });
+        function setupEmployeesPart() {
+            if ( isBoss ) {
+                $('#glm-emp-list').show();
+                $('input[name^="employees"]').each(function(){
+                    $(this).removeAttr('disabled');
+                });
+            } else {
+                $('#glm-emp-list').hide();
+                $('input[name^="employees"]').each(function(){
+                    $(this).prop('disabled', true);
+                });
+            }
         }
-    }
-    setupEmployeesPart();
+        setupEmployeesPart();
 
 
-    $('#glm-billing-employees').on('click', '.glm-billing-employee-del', function(){
-        $(this).parent('.glm-billing-employee').remove();
-    });
+        $('#glm-billing-employees').on('click', '.glm-billing-employee-del', function(){
+            $(this).parent('.glm-billing-employee').remove();
+        });
 
-    // Setup the date picker for the input field with the name anniversary_date
-    $('input[name="anniversary_date"]').datepicker({
-        dateFormat: 'mm/dd/yy'
-    });
-    // Setup the date picker for the input field with the name renewal_date
-    $('input[name="renewal_date"]').datepicker({
-        dateFormat: 'mm/dd/yy'
-    });
+        // Setup the date picker for the input field with the name anniversary_date
+        $('input[name="anniversary_date"]').datepicker({
+            dateFormat: 'mm/dd/yy'
+        });
+        // Setup the date picker for the input field with the name renewal_date
+        $('input[name="renewal_date"]').datepicker({
+            dateFormat: 'mm/dd/yy'
+        });
 
-    // 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);
-
-    //$('#billingInfoForm')
-    var abide = new Foundation.Abide($('#billingInfoForm'));
-    $(document)
-    .on('invalid.zf.abide', function(ev,elem){
-        elem.focus();
-        return false;
-    })
-    // .on('forminvalid.zf.abide', function(ev,frm){
-    //     console.log( 'form id '+ev.target.id+' is invalid' );
-    // })
-    .on('submit', function(ev){
-        ev.preventDefault();
-        var validForm = $('#billingInfoForm').foundation('validateForm');
-        console.log('ValidForm: ',validForm);
-        var data = $('#billingInfoForm').serialize();
-        console.log('data: ', data);
-        console.log('Submit for form id '+ev.target.id+' intercepted');
-        $.ajax({
-            url: '{$ajaxUrl}?action=glm_members_admin_ajax&' + data,
-            cache: false,
-            beforeSend: startAjax,
-            complete: completeAjax,
-        }).done(function(rsp){
-            console.log( 'rsp:', rsp );
-            if ( rsp.status == '1' ) {
-                var $sucessModal = $('#billingInfoSuccess');
-                $sucessModal.foundation('open').trigger('resizeme.zp.reveal');
-
-                // Update the anchor label
-                var id = rsp.fieldData.id;
-                var ref_name = rsp.fieldData.ref_name;
-                console.log('name: ', ref_name);
-                $('#account-ref-dest-' + id).text( ref_name );
-            } else {
-                return false;
-            }
-        }).fail(function(){
-            console.log( 'error' );
+        // 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);
+
+        //$('#billingInfoForm')
+        var abide = new Foundation.Abide($('#billingInfoForm'));
+        $('#billingInfoForm')
+        .on('submit', function(ev){
+            ev.preventDefault();
+            var validForm = $('#billingInfoForm').foundation('validateForm');
+            //console.log('ValidForm: ',validForm);
+            var data = $('#billingInfoForm').serialize();
+            //console.log('data: ', data);
+            //console.log('Submit for form id '+ev.target.id+' intercepted');
+            $.ajax({
+                url: '{$ajaxUrl}?action=glm_members_admin_ajax&' + data,
+                cache: false,
+                beforeSend: startAjax,
+                complete: completeAjax,
+            }).done(function(rsp){
+                //console.log( 'rsp:', rsp );
+                if ( rsp.status == '1' ) {
+                    var $sucessModal = $('#billingInfoSuccess');
+                    $sucessModal.foundation('open').trigger('resizeme.zp.reveal');
+
+                    // Update the anchor label
+                    var id = rsp.fieldData.id;
+                    var ref_name = rsp.fieldData.ref_name;
+                    // kill this abide form
+                    $('#billingInfoForm').foundation('_destroy');
+                    //console.log('name: ', ref_name);
+                    //$('#account-ref-dest-' + id).text( ref_name );
+                } else {
+                    return false;
+                }
+            }).fail(function(){
+                //console.log( 'error' );
+            });
+            return false;
         });
-        return false;
+        function startAjax(){
+            $('#glmLoading').show();
+        }
+        function completeAjax(){
+            $('#glmLoading').hide();
+        };
     });
-    function startAjax(){
-        $('#glmLoading').show();
-    }
-    function completeAjax(){
-        $('#glmLoading').hide();
-    };
-});
-</script>
+    </script>
+</div>
index 8a4b7ba..4ee87c0 100644 (file)
                     <td> {$t.transaction_time.datetime} </td>
                     <td> {$t.due_date.date} </td>
                     <td> {$t.amount_total} </td>
-                    <td> {$t.balance} </td>
+                    <td> <span id="balance-{$t.id}">{$t.balance}</span> </td>
                 </tr>
                 <tr id="invoice-container-{$t.id}" class="glm-invoice-links hide-for-large {if $t@iteration is div by 2} alternate{/if}">
                     <td colspan="7">
                                 &nbsp;
                             {else}
                                 <a class="send-invoice-link" href="#"
-                                    data-id="{$t.id}"
+                                    id="send-invoice-{$t.id}"
                                     data-member="{$t.member_id}"
                                     data-account="{$t.account.value}"
                                     data-member_name="{$t.member_name}"
                                     >Send Invoice</a> |
                                 {if $billing_settings.uptravel_payment_form}
-                                    <a class="make-a-payment" data-member="{$t.member_id}" href="{$thisUrl}?page=glm-members-admin-menu-member&glm_action=billing&option=makepaymentadjustment&member={$t.member_id}">Make A Payment</a> |
+                                    <a
+                                        class="make-a-payment"
+                                        id="make-a-payment-{$t.id}"
+                                        data-member="{$t.member_id}"
+                                        href="{$thisUrl}?page=glm-members-admin-menu-member&glm_action=billing&option=makepaymentadjustment&member={$t.member_id}">Make A Payment</a> |
                                 {else}
-                                    <a class="pay-invoice" data-member="{$t.member_id}" href="{$thisUrl}?page=glm-members-admin-menu-member&glm_action=billing&option=makepayment&member={$t.member_id}">Pay Invoice</a> |
+                                    <a
+                                        class="pay-invoice"
+                                        id="pay-invoice-{$t.id}"
+                                        data-member="{$t.member_id}"
+                                        href="{$thisUrl}?page=glm-members-admin-menu-member&glm_action=billing&option=makepayment&member={$t.member_id}">Pay Invoice</a> |
                                 {/if}
                             {/if}
                         </span>
                 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 45a5fd3..a8951a9 100644 (file)
@@ -17,7 +17,7 @@
     {/if}
 
     {if $invoices}
-        <form id="billingPaymentForm" action="{$ajaxUrl}?action=glm_members_admin_ajax" method="post" data-abide novalidate data-validate-on-blur="true">
+        <form id="billingPaymentForm" action="#" method="post" data-abide novalidate data-validate-on-blur="true">
             <input type="hidden" name="glm_action" value="ajaxBillingInfo" />
 
             <input type="hidden" name="page" value="{$thisPage}" />
@@ -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;
     });
index d846069..d14ba6b 100644 (file)
@@ -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);