From: Steve Sutton Date: Mon, 29 Jul 2019 19:07:20 +0000 (-0400) Subject: Finishing the pay invoice part from invoices. X-Git-Url: http://cvs2.gaslightmedia.com/gitweb/?a=commitdiff_plain;h=092e3b0dd698576a7f02aa3c94b8f065bc4558b7;p=WP-Plugins%2Fglm-member-db-billing.git Finishing the pay invoice part from invoices. Remove the Anniversary date column. --- diff --git a/models/admin/billing/invoiceTypes.php b/models/admin/billing/invoiceTypes.php index c2e00d0..fa2638a 100644 --- a/models/admin/billing/invoiceTypes.php +++ b/models/admin/billing/invoiceTypes.php @@ -117,7 +117,7 @@ class GlmMembersAdmin_billing_invoiceTypes extends GlmDataInvoiceTypes wp_enqueue_style( 'Foundation6', GLM_MEMBERS_PLUGIN_URL . '/css/foundation-6.min.css' ); wp_enqueue_script( 'Foundation6', GLM_MEMBERS_PLUGIN_URL . '/js/foundation-6.min.js' ); - // Check for region id + // Check for id $id = 0; if ( isset( $_REQUEST['id'] ) ) { $id = filter_var( $_REQUEST['id'], FILTER_VALIDATE_INT ); @@ -177,8 +177,6 @@ class GlmMembersAdmin_billing_invoiceTypes extends GlmDataInvoiceTypes // Get a current list of members $invoiceTypes = $this->getList(); - // echo '
$invoiceTypes: ' . print_r( $invoiceTypes, true ) . '
'; - // If we have list entries - even if it's an empty list $success = true; $haveInvoiceTypes = false; @@ -195,6 +193,23 @@ class GlmMembersAdmin_billing_invoiceTypes extends GlmDataInvoiceTypes // Sort results by higherarchy (Parent/Child and Alpha) $invoiceTypes = $this->sortParentChild( $invoiceTypes ); + $parents = array_filter( $invoiceTypes, function($iType){ + if ( $iType['parent']['value'] === 0 ) { + return true; + } else { + return false; + } + } ); + if ( !empty( $id ) ) { + $parents = array_filter( $parents, function($iType) use ($id) { + if ( $iType['id'] != $id ) { + return true; + } else { + return false; + } + } ); + } + // Get list of Member Types $MemberType = new GlmDataMemberTypes( $this->wpdb, $this->config ); $memberTypes = $MemberType->getList(); @@ -211,7 +226,7 @@ class GlmMembersAdmin_billing_invoiceTypes extends GlmDataInvoiceTypes ); } - + // echo '
$invoiceTypes: ' . print_r( $invoiceTypes, true ) . '
'; // Compile template data $templateData = array( @@ -219,6 +234,7 @@ class GlmMembersAdmin_billing_invoiceTypes extends GlmDataInvoiceTypes 'enable_members' => $enable_members, 'haveInvoiceTypes' => $haveInvoiceTypes, 'invoiceTypes' => $invoiceTypes, + 'parents' => $parents, 'recurrenceTypes' => $this->config['recurrence'], 'memberTypes' => $memberTypes, 'invoiceType' => $invoiceType, diff --git a/models/admin/member/billing.php b/models/admin/member/billing.php index 37ba373..1ece124 100644 --- a/models/admin/member/billing.php +++ b/models/admin/member/billing.php @@ -882,11 +882,6 @@ class GlmMembersAdmin_member_billing // extends GlmDataBilling } else { $paymentSuccess = true; } - if ( $this->ajaxSide ) { - header( 'Content-type:application/json;charset=utf-8', true ); - echo json_encode( $errors, true ); - exit; - } break; case 'pay_by_check': @@ -907,6 +902,25 @@ class GlmMembersAdmin_member_billing // extends GlmDataBilling break; } + if ( $this->ajaxSide && !$errors ) { + if ( !empty( $invoices ) ) { + $invoiceData = array_map( array( $BillingSupport, 'getInvoiceById' ), $invoices ); + } + $return = array( + 'payment_id' => $payment_id, + 'invoices' => $invoiceData + ); + header( 'Content-type:application/json;charset=utf-8', true ); + echo json_encode( $return, true ); + exit; + } elseif ( $this->ajaxSide && $errors ) { + $return = array( + 'status' => false, + ); + header( 'Content-type:application/json;charset=utf-8', true ); + echo json_encode( $return, true ); + exit; + } if ( !$errors ) { $view = 'statements'; @@ -993,8 +1007,6 @@ 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( array( $BillingSupport, 'getInvoiceById' ), $invoices ); } diff --git a/views/admin/billing/accounts.html b/views/admin/billing/accounts.html index 06b76de..25821a3 100644 --- a/views/admin/billing/accounts.html +++ b/views/admin/billing/accounts.html @@ -35,7 +35,6 @@ Boss/Employees {/if} Billing Email - Anniversary Date Renewal Date @@ -49,11 +48,10 @@ {if $t.boss.value}Yes{/if} {/if} {$t.email} - {$t.anniversary_date.date} {$t.renewal_date.date} - +
Accounts Export @@ -36,7 +36,6 @@ Member Name Billing Email - Anniversary Date Renewal Date @@ -46,11 +45,10 @@ {$t.ref_name} {$t.email} - {$t.anniversary_date.date} {$t.renewal_date.date} - + @@ -69,7 +67,7 @@ {if $t.boss.value} - +
{foreach $t.employees as $emp}
{$emp.ref_name}
diff --git a/views/admin/billing/makePaymentAdjustmentAjax.html b/views/admin/billing/makePaymentAdjustmentAjax.html index 245cd84..d35642f 100644 --- a/views/admin/billing/makePaymentAdjustmentAjax.html +++ b/views/admin/billing/makePaymentAdjustmentAjax.html @@ -120,7 +120,6 @@ 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. if ( rsp.invoices.length > 0 ) { // Loop over the invoices and update the ones if found on this page. for ( var i in rsp.invoices ) { diff --git a/views/admin/billing/makePaymentAjax.html b/views/admin/billing/makePaymentAjax.html index f5c6266..ec6c368 100644 --- a/views/admin/billing/makePaymentAjax.html +++ b/views/admin/billing/makePaymentAjax.html @@ -35,7 +35,6 @@ - {include file='ui/f6/errorCallout.html'} {if $invoices} @@ -221,6 +220,8 @@ 'value' => $smarty.request.cc_name|default:'', 'field' => 'cc_name', 'label' => 'Name on Card', + 'class' => 'glm-billing-card glm-billing-credit', + 'inputClass' => 'ccard', 'required' => true, 'errorText' => 'Name on Card is Required', 'dataError' => '' @@ -229,17 +230,64 @@ {* Card Type *} {$ui = [ - 'value' => $smarty.request.cc_type|default:'', - 'field' => 'cc_type', - 'label' => 'Card Type', - 'list' => $management.cc_accepts.names, - 'l_blank' => true, - 'required' => true, - 'errorText' => 'Card Type is Required', - 'dataError' => '' + 'value' => $smarty.request.cc_type|default:'', + 'field' => 'cc_type', + 'label' => 'Card Type', + 'list' => $management.cc_accepts.names, + 'l_blank' => true, + 'class' => 'glm-billing-card glm-billing-credit', + 'inputClass' => 'ccard', + 'required' => true, + 'errorText' => 'Card Type is Required', + 'dataError' => '' ]} {include file='ui/f6/select.html'} + {* Card Number *} + {$ui = [ + 'value' => $smarty.request.cc_numb|default:'', + 'field' => 'cc_numb', + 'label' => 'Card Number', + 'pattern' => 'card', + 'class' => 'glm-billing-card glm-billing-credit', + 'inputClass' => 'ccard', + 'required' => true, + 'errorText' => 'Card Number is Required and must be valid number', + 'dataError' => '' + ]} + {include file='ui/f6/text.html'} + + {* Card Expiration *} + {$ui = [ + 'value' => $smarty.request.cc_exp|default:'', + 'field' => 'cc_exp', + 'label' => 'Card Expiration', + 'placeholder' => 'MM/YY', + 'pattern' => '^\d{2}/\d{2}$', + 'class' => 'glm-billing-card glm-billing-credit', + 'inputClass' => 'ccard', + 'required' => true, + 'errorText' => 'Card Expiration is Required', + 'dataError' => '' + ]} + {include file='ui/f6/text.html'} + + {* C V V *} + {$ui = [ + 'value' => $smarty.request.cc_cvv|default:'', + 'field' => 'cc_cvv', + 'label' => 'C V V', + 'pattern' => 'cvv', + 'class' => 'glm-billing-card glm-billing-credit', + 'inputClass' => 'ccard', + 'required' => true, + 'errorText' => 'C V V is Required', + 'dataError' => '' + ]} + {include file='ui/f6/text.html'} + + + {* Include the Payment Form template *} @@ -302,12 +350,26 @@ jQuery(document).ready(function($){ beforeSend: startAjax, complete: completeAjax, }).done(function(rsp){ - // if ( rsp.status == '1' ) { - // var $sucessModal = $('#billingInfoSuccess'); - // $sucessModal.foundation('open').trigger('resizeme.zp.reveal'); - // } else { - // return false; - // + console.log('rsp: ', rsp); + var $sucessModal = $('#billingSuccess'); + $sucessModal.foundation('open').trigger('resizeme.zp.reveal'); + if ( rsp.status == false ) { + console.log( 'Error:' ); + } + 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 false; }).fail(function(){ }); @@ -364,6 +426,51 @@ jQuery(document).ready(function($){ getPageTotal(); }); + $('.payment_option').change(function(){ + var payment_option = $('.payment_option:checked').val(); + if ( payment_option == 'pay_by_check' ) { + {if $billing_settings.proc_methods == 4} + $('.sq-payment-form').hide(); + paymentForm.destroy(); + {else} + $('.glm-billing-credit').hide(); + $('.ccard').prop('disabled', true); + $('#billing-payment-button').prop( 'onclick', null ); + {/if} + } else if ( payment_option == 'mark_paid' ) { + {if $billing_settings.proc_methods == 4} + $('.sq-payment-form').hide(); + paymentForm.destroy(); + $('#billing-payment-button').prop( 'onclick', null ); + {else} + $('.glm-billing-credit').hide(); + $('.ccard').prop('disabled', true); + {/if} + } else { + {if $billing_settings.proc_methods == 4} + if ( confirm( 'This will reload the page' ) ) { + $('.sq-payment-form').show(); + window.location.reload(); + } else { + $('.payment_option[value=mark_paid]').prop( 'checked', true ); + } + {else} + $('.glm-billing-credit').show(); + $('.ccard').prop('disabled', false); + {/if} + } + }); + + $('#glm-billing-use-saved-card').change(function(){ + var isChecked = $(this).prop( 'checked' ); + if ( isChecked ) { + $('.glm-billing-card').hide(); + $('.ccard').prop('disabled', true); + } else { + $('.glm-billing-card').show(); + $('.ccard').prop('disabled', false); + } + }); // 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); diff --git a/views/admin/billing/settings.html b/views/admin/billing/settings.html index b07f9cc..02472dc 100644 --- a/views/admin/billing/settings.html +++ b/views/admin/billing/settings.html @@ -206,7 +206,7 @@ 'label' => 'All Members Renew same day each year', 'required' => $data.fieldRequired.renewal_day_static, 'errorText' => 'All Members Renew same day each year is Required', - 'helpText' => 'All Member renewal on the same day each billing period (yearly)', + 'tip' => 'All Member renewal on the same day each billing period (yearly)', 'dataError' => $data.fieldFail.renewal_day_static ]} {include file='ui/f6/checkbox.html'} @@ -253,7 +253,7 @@ 'pattern' => 'number', 'required' => $data.fieldRequired.days_before_renewal, 'errorText' => 'Days Before Renewal Date is Required to be a number', - 'helpText' => 'Days before Renewal Date to Allow Membership Renewal. Based on 1 year after renewal date.', + 'tip' => 'Days before Renewal Date to Allow Membership Renewal. Based on 1 year after renewal date.', 'dataError' => $data.fieldFail.days_before_renewal ]} {include file='ui/f6/text.html'} @@ -266,7 +266,7 @@ 'pattern' => 'number', 'required' => $data.fieldRequired.days_after_expired, 'errorText' => 'Days After Renewal Date is Required to be a number', - 'helpText' => 'Days after Renewal Date to Expire Membership. Based on 1 year after renewal date.', + 'tip' => 'Days after Renewal Date to Expire Membership. Based on 1 year after renewal date.', 'dataError' => $data.fieldFail.days_after_expired ]} {include file='ui/f6/text.html'}