From 01239d8e930361a107cd7f24bdb95b103500ef75 Mon Sep 17 00:00:00 2001 From: Steve Sutton Date: Wed, 25 Apr 2018 10:35:36 -0400 Subject: [PATCH] Billing renewal form now deals with adding employees. Can now add an employee from the admin billing renewal form. --- classes/billingSupport.php | 8 ++--- classes/data/dataAccounts.php | 12 +++++-- models/admin/member/billing.php | 8 ++++- views/admin/billing/renew.html | 62 ++++++++++++++++++++++++++++----- 4 files changed, 74 insertions(+), 16 deletions(-) diff --git a/classes/billingSupport.php b/classes/billingSupport.php index 7a6e3ad..f671429 100644 --- a/classes/billingSupport.php +++ b/classes/billingSupport.php @@ -897,14 +897,14 @@ class GlmBillingSupport // echo '
$main_billing_account: ' . print_r( $main_billing_account, true ) . '
'; $Employees = new GlmDataEmployees( $this->wpdb, $this->config ); $employees = $Employees->getList( "T.account = " . $main_billing_account['id'] ); - echo '
$employees: ' . print_r( $employees, true ) . '
'; + // echo '
$employees: ' . print_r( $employees, true ) . '
'; if ( isset( $employees ) && is_array( $employees ) ) { foreach ( $employees as $emp ) { $invoice = false; $billing_account_id = $emp['employee']; $billing_account = $this->getAccountById( $billing_account_id ); - echo '
$billing_account: ' . print_r( $billing_account, true ) . '
'; + // echo '
$billing_account: ' . print_r( $billing_account, true ) . '
'; // If we don't have an account for this member then one // Needs to be created. $ref_dest = $this->wpdb->get_var( @@ -915,7 +915,7 @@ class GlmBillingSupport $emp['employee_name'] ) ); - echo '
$ref_dest: ' . print_r( $ref_dest, true ) . '
'; + // echo '
$ref_dest: ' . print_r( $ref_dest, true ) . '
'; if ( !$billing_account ) { // Get the Member Name if ( $member_name ) { @@ -939,7 +939,7 @@ class GlmBillingSupport if ( $billing_account && $ref_dest ) { // Need also to get the members type to look up which invoice_type to use $invoice_type_id = $this->getMembersInvoiceTypeByRefDest( $ref_dest ); - echo '
$invoice_type_id: ' . print_r( $invoice_type_id, true ) . '
'; + // echo '
$invoice_type_id: ' . print_r( $invoice_type_id, true ) . '
'; if ( $invoice_type_id ) { $invoice = $this->getInvoiceTypeById( $invoice_type_id ); $accounts[$billing_account_id] = array( diff --git a/classes/data/dataAccounts.php b/classes/data/dataAccounts.php index 100650f..5a4ac4d 100644 --- a/classes/data/dataAccounts.php +++ b/classes/data/dataAccounts.php @@ -146,6 +146,13 @@ class GlmDataAccounts extends GlmDataAbstract 'required' => true, ), + 'invoice_type' => array( + 'field' => 'invoice_type', + 'type' => 'integer', + 'use' => 'a', + 'required' => false, + ), + // Anniversary Date 'anniversary_date' => array( 'field' => 'anniversary_date', @@ -328,14 +335,15 @@ class GlmDataAccounts extends GlmDataAbstract 'id' => $fSave['id'], 'name' => $fSave['ref_name'], 'anniversary_date' => $fSave['anniversary_date'], + 'invoice_type' => $fSave['invoice_type'], ); - $memberList = $this->getList($where, $order, $fieldVals, $idField, $start, $limit); + $accountList = $this->getList($where, $order, $fieldVals, $idField, $start, $limit); // Restore the fields list $this->fields = $fSave; - return $memberList; + return $accountList; } } diff --git a/models/admin/member/billing.php b/models/admin/member/billing.php index 726c838..c3de638 100644 --- a/models/admin/member/billing.php +++ b/models/admin/member/billing.php @@ -127,6 +127,7 @@ class GlmMembersAdmin_member_billing // extends GlmDataBilling $account_status = false; $accounts = false; $errors = false; + $invoiceTypes = false; // For lockedToMember. $lockedToMember = false; @@ -211,7 +212,7 @@ class GlmMembersAdmin_member_billing // extends GlmDataBilling // Get a list of this accounts employees. If they have any. $employees = $BillingSupport->getListOfAccountEmployees( $this->memberID ); - echo '
$employees: ' . print_r( $employees, true ) . '
'; + // echo '
$employees: ' . print_r( $employees, true ) . '
'; // Load DataClass for Management. require_once GLM_MEMBERS_BILLING_PLUGIN_CLASS_PATH . '/data/dataManagement.php'; @@ -225,6 +226,10 @@ class GlmMembersAdmin_member_billing // extends GlmDataBilling // Need to get the accounts $Accounts = new GlmDataAccounts( $this->wpdb, $this->config ); $accounts = $Accounts->getSimpleAccountList( "T.boss <> true AND T.boss IS NOT NULL AND T.invoice_type != 0", 'ref_name' ); + // echo '
$accounts: ' . print_r( $accounts, true ) . '
'; + + $invoiceTypes = $BillingSupport->getAllPayableInvoiceTypes(); + // echo '
$invoiceTypes: ' . print_r( $invoiceTypes, true ) . '
'; break; @@ -664,6 +669,7 @@ class GlmMembersAdmin_member_billing // extends GlmDataBilling 'payable_types' => $payable_types, 'account_status' => $account_status, 'accounts' => $accounts, + 'invoiceTypes' => $invoiceTypes, ); // Return status, any suggested view, and any data to controller. diff --git a/views/admin/billing/renew.html b/views/admin/billing/renew.html index 5ab1fec..9fd53b8 100644 --- a/views/admin/billing/renew.html +++ b/views/admin/billing/renew.html @@ -71,13 +71,13 @@ -
+
Associated Members/Employees
- +
{foreach $employees as $employee}
@@ -128,7 +128,9 @@