From: Steve Sutton Date: Tue, 3 Apr 2018 15:36:57 +0000 (-0400) Subject: Updating payment page for admin. X-Git-Tag: v1.0.0^2~80 X-Git-Url: http://cvs2.gaslightmedia.com/gitweb/?a=commitdiff_plain;h=f61508081b636125ba29b99989c1e51ba2d7b72a;p=WP-Plugins%2Fglm-member-db-billing.git Updating payment page for admin. Adding lookup for account invoices. Mark each invoice as paid. --- diff --git a/classes/billingSupport.php b/classes/billingSupport.php index 1903541..4d67f73 100644 --- a/classes/billingSupport.php +++ b/classes/billingSupport.php @@ -181,7 +181,7 @@ class GlmBillingSupport * @access public * @return payment id */ - public function createPayment( $account, $payment ) + public function createPayment( $account, $payment, $payment_method = '', $payment_data = '' ) { // Insert the payment $this->wpdb->insert( @@ -190,8 +190,8 @@ class GlmBillingSupport 'transaction_time' => date('Y-m-d H:i:s'), 'account' => $account, 'amount' => $payment, - 'payment_method' => '', - 'payment_data' => '', + 'payment_method' => $payment_method, + 'payment_data' => $payment_data, ), array( '%s', @@ -1135,7 +1135,7 @@ class GlmBillingSupport // Determine the directory of the payment processor to load and instantiate it. if ( $ccProcessor && isset( $this->config['proc_dir'][$ccProcessor] ) ) { - require_once GLM_MEMBERS_BILLING_PLUGIN_LIB_PATH.'/paymentProcessors/'.$this->config['proc_dir'][$ccProcessor].'/paymentGateway.php'; + require_once GLM_MEMBERS_BILLING_PLUGIN_LIB_PATH . '/paymentProcessors/' . $this->config['proc_dir'][$ccProcessor] . '/paymentGateway.php'; $CcProcessor = new PaymentGateway( $account ); } @@ -1148,7 +1148,7 @@ class GlmBillingSupport 'ccnumb' => $cardData['cc_numb'], // Card Number 'ccexp' => $cardData['cc_exp'], // Expiration Date 'cccode' => $cardData['cc_cvv'], // CCV - security code - 'invoice' => 'billing-'//.$invoice_id // Invoice # is "reg-" plus cart ID + 'invoice' => 'billing-'//.$invoice_id // Invoice # is "reg-" plus cart ID ); // Now try to run the card processor @@ -1159,7 +1159,7 @@ class GlmBillingSupport $result = array( 'status' => 1, 'errors' => array(), - 'ccResult' => $ccResult + 'ccResult' => $ccResult, ); } @@ -1195,7 +1195,7 @@ class GlmBillingSupport $_REQUEST['transaction_time'] = date( 'Y-m-d H:i:s' ); // Create new payment. - $payment_id = $this->createPayment( $account_id, $amount ); + $payment_id = $this->createPayment( $account_id, $amount, 'Credit Card' ); // Record the payment. $this->recordPayment( $payment_id, $account_id, $amount, $invoice_id ); @@ -1245,7 +1245,7 @@ class GlmBillingSupport $_REQUEST['transaction_time'] = date( 'Y-m-d H:i:s' ); // Create new payment. - $payment_id = $this->createPayment( $account_id, $amount ); + $payment_id = $this->createPayment( $account_id, $amount, 'Credit Card' ); // Record the payment. $this->recordPayment( $payment_id, $account_id, $amount, $invoices ); diff --git a/models/admin/billing/payments.php b/models/admin/billing/payments.php index 04e23f8..d4a2353 100644 --- a/models/admin/billing/payments.php +++ b/models/admin/billing/payments.php @@ -142,12 +142,19 @@ class GlmMembersAdmin_billing_payments extends GlmDataPayments // Support class $BillingSupport = new GlmBillingSupport( $this->wpdb, $this->config ); - // Set transaction_time to current time. - $_REQUEST['transaction_time'] = date('Y-m-d H:i:s'); - // grab data for the payments - $payments = $this->insertEntry(); - $this->payment_id = $payments['fieldData']['id']; - $BillingSupport->recordPayment( $this->payment_id, $_REQUEST['account'], $payments['fieldData']['amount'] ); + // Make sure there's an amount + if ( $amount = filter_var( $_REQUEST['amount'], FILTER_VALIDATE_FLOAT ) ) { + $invoices = filter_var( $_REQUEST['invoices'], FILTER_VALIDATE_INT, array( 'flags' => FILTER_REQUIRE_ARRAY ) ); + // echo '
$amount: ' . print_r( $amount, true ) . '
'; + // echo '
$_REQUEST: ' . print_r( $_REQUEST, true ) . '
'; + // Set transaction_time to current time. + $_REQUEST['transaction_time'] = date('Y-m-d H:i:s'); + // grab data for the payments + $payments = $this->insertEntry(); + $this->payment_id = $payments['fieldData']['id']; + $BillingSupport->recordPayment( $this->payment_id, $_REQUEST['account'], $amount, $invoices ); + $paymentsAdded = true; + } $view = 'editPayment'; break; diff --git a/views/admin/billing/editPayment.html b/views/admin/billing/editPayment.html index b0d7ad3..b280bc8 100644 --- a/views/admin/billing/editPayment.html +++ b/views/admin/billing/editPayment.html @@ -2,52 +2,60 @@ {include file='admin/billing/paymentHeader.html'} -{if $paymentUpdated}Notification Updated{/if} -{if $paymentUpdateError}Notification Update Error{/if} -{if $paymentInsertError}Notification Insert Error{/if} -{if $paymentAdded}Notification Added{/if} +{if $paymentUpdated}Payment Updated{/if} +{if $paymentUpdateError}Payment Update Error{/if} +{if $paymentInsertError}Payment Insert Error{/if} +{if $paymentAdded}Payment Added{/if}
+ {if $payment_id} - - + + {else} - + {/if} -
-
- Lookup Member Invoices By Account -
-
- - -
-
-
-
- Select Invoices -
-
-
-
-
-
- Amount -
-
-
- -
-
-
-
- Notes -
-
- -
-
+
+
+ Lookup Member Invoices By Account +
+
+ + +
+
+
+
+ Select Invoices +
+
+
+
+
+
+ Amount +
+
+
$0.00
+
+
+
+
+ Payment Method +
+
+ +
+
+
+
+ Payment Notes +
+
+ +
+
@@ -62,6 +70,33 @@ jQuery(document).ready(function($){ {/foreach} ] + function updateInvoiceList( invoices ) { + // Clear the invoices + $('#glm-payment-invoices').html(''); + for ( var i = 0; i < invoices.length; i++ ) { + $('#glm-payment-invoices').append( '
' ); + } + } + + function getPageTotal(){ + // Caclulate the total for this page. + var page_total = parseFloat( '0.00' ); + $('.glm-invoice-item').each(function(){ + var isChecked = $(this).prop('checked'); + if ( isChecked ) { + page_total = page_total + parseFloat( $(this).data('amount') ); + } + }); + $('#total_amount').html( '$' + page_total ); + $('#total_payment_amount').val( page_total ); + } + + $('#glm-payment-invoices').on( 'click', '.glm-invoice-item', function(){ + getPageTotal(); + }); + // Setup autocomplete $('#account_name').autocomplete({ source: availableAccounts, @@ -76,13 +111,16 @@ jQuery(document).ready(function($){ account: ui.item.id }, success: function( results ) { - console.log( results ); + updateInvoiceList( results ); + //console.log( results ); }, }); }, change: function( event, ui) { if( ui.item == null ) { $('#member-account').val( '' ); + $('#glm-payment-invoices').html(''); + getPageTotal(); } }, });