$option = 'list';
$this->invoice_id = false;
+ $lineItems = false;
$haveInvoices = false;
$invoiceUpdated = false;
$invoiceUpdateError = false;
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 '<pre>$invoices: ' . print_r( $invoices, true ) . '</pre>';
+ $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
}
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':
'option' => $option,
'invoice_id' => $this->invoice_id,
'invoices' => $invoices,
+ 'lineItems' => $lineItems,
'nonAccountMembers' => $nonAccountMembers,
'haveInvoices' => $haveInvoices,
'invoiceUpdated' => $invoiceUpdated,