From e9ccaf83c4bed7ee6c1d48791bffd382f92595dc Mon Sep 17 00:00:00 2001 From: Steve Sutton Date: Thu, 14 Mar 2019 15:12:25 -0400 Subject: [PATCH] Updating payment type on new accounts When creating on the new invoice page. --- models/admin/billing/invoices.php | 26 +++++++++++++++++++++++++- 1 file changed, 25 insertions(+), 1 deletion(-) diff --git a/models/admin/billing/invoices.php b/models/admin/billing/invoices.php index cda9c6f..f281205 100644 --- a/models/admin/billing/invoices.php +++ b/models/admin/billing/invoices.php @@ -249,7 +249,6 @@ class GlmMembersAdmin_billing_invoices extends GlmDataInvoices // Set transaction_time to current time. $_REQUEST['transaction_time'] = date('Y-m-d H:i:s'); $_REQUEST['due_date'] = date('Y-m-d', strtotime($_REQUEST['due_date'])); - // echo '
' . print_r( $_REQUEST, true ) . '
'; $invoices = $this->insertEntry(); // TODO: Need to check to see if we received a good response @@ -305,6 +304,31 @@ class GlmMembersAdmin_billing_invoices extends GlmDataInvoices array( '%s' ), array( '%d' ) ); + // Check the billing account and see if it needs to have invoice_type set. + $invoice_type_id = $this->wpdb->get_var( + $this->wpdb->prepare( + "SELECT invoice_type + FROM " . GLM_MEMBERS_BILLING_PLUGIN_DB_PREFIX . "accounts + WHERE id = %d", + $_REQUEST['account'] + ) + ); + if ( !$invoice_type_id ) { + // Then setup the invoice_type id + $this->wpdb->update( + GLM_MEMBERS_BILLING_PLUGIN_DB_PREFIX . 'accounts', + array( + 'invoice_type' => $line_item, + 'email_invoice' => true + ), + array( 'id' => $_REQUEST['account'] ), + array( + '%d', + '%d' + ), + array( '%d' ) + ); + } } } } -- 2.17.1