From: Steve Sutton Date: Fri, 7 Dec 2018 21:55:41 +0000 (-0500) Subject: WIP for edit invoices X-Git-Url: http://cvs2.gaslightmedia.com/gitweb/?a=commitdiff_plain;h=fa8666bf01b8cbfeab0f55949331cf0c9332eccb;p=WP-Plugins%2Fglm-member-db-billing.git WIP for edit invoices Getting line items. --- diff --git a/models/admin/billing/invoices.php b/models/admin/billing/invoices.php index 2f04706..4a3e053 100644 --- a/models/admin/billing/invoices.php +++ b/models/admin/billing/invoices.php @@ -93,6 +93,7 @@ class GlmMembersAdmin_billing_invoices extends GlmDataInvoices $option = 'list'; $this->invoice_id = false; + $lineItems = false; $haveInvoices = false; $invoiceUpdated = false; $invoiceUpdateError = false; @@ -177,6 +178,33 @@ class GlmMembersAdmin_billing_invoices extends GlmDataInvoices break; + case 'edit': + // Should have an id here + if ( isset( $_REQUEST['id'] ) ) { + $BillingSupport = new GlmBillingSupport( $this->wpdb, $this->config ); + $this->invoice_id = filter_var( $_REQUEST['id'], FILTER_VALIDATE_INT ); + $invoices = $this->editEntry( $this->invoice_id ); + // echo '
$invoices: ' . print_r( $invoices, true ) . '
'; + $view = 'editInvoice'; + $InvoiceTypesObj = new GlmDataInvoiceTypes( $this->wpdb, $this->config ); + $invoiceTypes = $InvoiceTypesObj->getList(); + $lineItems = $BillingSupport->getLineItemsForInvoice( $this->invoice_id ); + // Sort the types by parent child + $invoiceTypes = $InvoiceTypesObj->sortParentChild($invoiceTypes); + if ( isset( $invoiceTypes ) ) { + foreach ( $invoiceTypes as $invoiceType ) { + $invTypes[$invoiceType['id']] = array( + 'id' => $invoiceType['id'], + 'name' => $invoiceType['name'], + 'amount' => $invoiceType['amount'], + ); + } + $invoiceTypeJSON = json_encode( $invTypes, JSON_NUMERIC_CHECK ); + } + + } // show error? + break; + case 'add': $invoices = $this->newEntry(); // Set the view file to editInvoice @@ -324,23 +352,23 @@ class GlmMembersAdmin_billing_invoices extends GlmDataInvoices } break; - case 'edit': - $invoices = $this->editEntry($this->invoice_id); - - // If we have a good invoices - if ($invoices['status']) { - $haveTransactions = true; - } - - // If we're locked to a member as a contact user and the invoices member doesn't equal the contact member - if ($lockedToMember && $invoices['fieldData']['ref_dest_id'] != $lockedToMember) { - $haveTransactions = false; - $invoices = false; - } - - // Set the view file to editInvoice - $view = 'editInvoice'; - break; + // case 'edit': + // $invoices = $this->editEntry($this->invoice_id); + // + // // If we have a good invoices + // if ($invoices['status']) { + // $haveTransactions = true; + // } + // + // // If we're locked to a member as a contact user and the invoices member doesn't equal the contact member + // if ($lockedToMember && $invoices['fieldData']['ref_dest_id'] != $lockedToMember) { + // $haveTransactions = false; + // $invoices = false; + // } + // + // // Set the view file to editInvoice + // $view = 'editInvoice'; + // break; case 'update': @@ -536,6 +564,7 @@ class GlmMembersAdmin_billing_invoices extends GlmDataInvoices 'option' => $option, 'invoice_id' => $this->invoice_id, 'invoices' => $invoices, + 'lineItems' => $lineItems, 'nonAccountMembers' => $nonAccountMembers, 'haveInvoices' => $haveInvoices, 'invoiceUpdated' => $invoiceUpdated, diff --git a/todo.txt b/todo.txt index d726948..386e8e2 100644 --- a/todo.txt +++ b/todo.txt @@ -14,6 +14,9 @@ Invoicing: [x] -- Filter by county and category or member type [x]-Create labels [ ] -Send Email (invoices) +[ ] Pro - Rate an invoice +[ ] Ability to edit an invoice +[ ] Ability to delete an invoice Reports: -Open Accounts diff --git a/views/admin/billing/editInvoice.html b/views/admin/billing/editInvoice.html index 0be2545..540a74e 100644 --- a/views/admin/billing/editInvoice.html +++ b/views/admin/billing/editInvoice.html @@ -12,12 +12,14 @@ {if $invoice_id} + {else} {/if}
+ {if !$invoice_id}
Billing Account @@ -28,6 +30,7 @@ New Account
+ {/if}
Due Date diff --git a/views/admin/billing/invoices.html b/views/admin/billing/invoices.html index bd4172d..b34448d 100644 --- a/views/admin/billing/invoices.html +++ b/views/admin/billing/invoices.html @@ -73,7 +73,7 @@ {else} {/if} - {$t.id} + {$t.id} {$t.member_name} {foreach $t.line_items as $item}