From fbbc135a97a6e5f3453dc4b769b08ed961146d2e Mon Sep 17 00:00:00 2001 From: Steve Sutton Date: Tue, 21 May 2019 16:12:35 -0400 Subject: [PATCH] Send Invoice from invoices billing page. Working on the send invoice part. --- models/admin/billing/invoices.php | 106 ++++++++++++++++-------------- views/admin/billing/invoices.html | 9 +-- 2 files changed, 60 insertions(+), 55 deletions(-) diff --git a/models/admin/billing/invoices.php b/models/admin/billing/invoices.php index f26d6e6..c87876f 100644 --- a/models/admin/billing/invoices.php +++ b/models/admin/billing/invoices.php @@ -141,6 +141,61 @@ class GlmMembersAdmin_billing_invoices extends GlmDataInvoices $option = $_REQUEST['option']; } + // Special case for option 'delete' + if ( $option == 'delete' ) { + $BillingSupport = new GlmBillingSupport( $this->wpdb, $this->config ); + if ( isset( $_REQUEST['invoice_id'] ) && $invoice_id = filter_var( $_REQUEST['invoice_id'], FILTER_VALIDATE_INT ) ) { + $deleteNumber = $BillingSupport->removeInvoiceById( $invoice_id ); + } + + if ( $deleteNumber ) { + $invoiceDeleted = true; + } else { + $invoiceDeleteError = true; + } + } + + // Special case for option 'send_invoice' + if ( $option == 'send_invoice' ) { + $BillingSupport = new GlmBillingSupport( $this->wpdb, $this->config ); + + $invoice_id = false; + $member_id = false; + $account_id = false; + + $type = $this->config['transaction_numb']['Invoice']; + + // Get invoice method for a member account + if ( isset( $_REQUEST['invoice_id'] ) ) { + $invoice_id = filter_var( $_REQUEST['invoice_id'], FILTER_VALIDATE_INT ); + } + if ( isset( $_REQUEST['member_id'] ) ) { + $member_id = filter_var( $_REQUEST['member_id'], FILTER_VALIDATE_INT ); + } + if ( isset( $_REQUEST['account_id'] ) ) { + $account_id = filter_var( $_REQUEST['account_id'], FILTER_VALIDATE_INT ); + } + + if ( $invoice_id && $member_id && $account_id ) { + $Notifications = new GlmNotifications( $this->wpdb, $this->config ); + $invoice = $BillingSupport->getInvoiceById( $invoice_id ); + $invoice_total = $invoice['balance']; + $data = array( + 'type' => $type, + 'type_id' => $invoice_id, + 'account' => $account_id, + 'amount' => $invoice_total, + 'payment' => 0, + ); + $notices = $Notifications->getNotificationsWithSendByAction( $type ); + foreach ( $notices as $notice ) { + $Notifications->sendEmailNotification( $notice['id'], $account_id, $data ); + } + } + echo '
$_REQUEST: ' . print_r( $_REQUEST, true ) . '
'; + $invoiceSent = true; + } + // Do selected option switch ($option) { @@ -533,57 +588,6 @@ class GlmMembersAdmin_billing_invoices extends GlmDataInvoices break; - case 'delete': - $BillingSupport = new GlmBillingSupport( $this->wpdb, $this->config ); - if ( isset( $_REQUEST['invoice_id'] ) && $invoice_id = filter_var( $_REQUEST['invoice_id'], FILTER_VALIDATE_INT ) ) { - $deleteNumber = $BillingSupport->removeInvoiceById( $invoice_id ); - } - - if ( $deleteNumber ) { - $invoiceDeleted = true; - } else { - $invoiceDeleteError = true; - } - - case 'send_invoice': - $BillingSupport = new GlmBillingSupport( $this->wpdb, $this->config ); - - $invoice_id = false; - $member_id = false; - $account_id = false; - - $type = $this->config['transaction_numb']['Invoice']; - - // Get invoice method for a member account - if ( isset( $_REQUEST['invoice_id'] ) ) { - $invoice_id = filter_var( $_REQUEST['invoice_id'], FILTER_VALIDATE_INT ); - } - if ( isset( $_REQUEST['member_id'] ) ) { - $member_id = filter_var( $_REQUEST['member_id'], FILTER_VALIDATE_INT ); - } - if ( isset( $_REQUEST['account_id'] ) ) { - $account_id = filter_var( $_REQUEST['account_id'], FILTER_VALIDATE_INT ); - } - - if ( $invoice_id && $member_id && $account_id ) { - $Notifications = new GlmNotifications( $this->wpdb, $this->config ); - $invoice = $BillingSupport->getInvoiceById( $invoice_id ); - $invoice_total = $invoice['balance']; - $data = array( - 'type' => $type, - 'type_id' => $invoice_id, - 'account' => $account_id, - 'amount' => $invoice_total, - 'payment' => 0, - ); - $notices = $Notifications->getNotificationsWithSendByAction( $type ); - foreach ( $notices as $notice ) { - $Notifications->sendEmailNotification( $notice['id'], $account_id, $data ); - } - } - // echo '
$_REQUEST: ' . print_r( $_REQUEST, true ) . '
'; - $invoiceSent = true; - case 'list': default: diff --git a/views/admin/billing/invoices.html b/views/admin/billing/invoices.html index 4a62b8e..2c26f58 100644 --- a/views/admin/billing/invoices.html +++ b/views/admin/billing/invoices.html @@ -31,7 +31,7 @@
- +