From e89952eb971c859dfbc4ca269be9fd5bbc946026 Mon Sep 17 00:00:00 2001 From: Steve Sutton Date: Fri, 19 Jul 2019 16:14:54 -0400 Subject: [PATCH] Move Management into billing Use responsive navigation. medium up is dropdown small is drilldown. --- classes/billingSupport.php | 3 +- classes/data/dataAccounts.php | 1 + models/admin/ajax/ajaxNotificationPreview.php | 76 ++++++++++ models/admin/billing/accounts.php | 1 - models/admin/billing/invoicing.php | 18 ++- models/admin/billing/notifications.php | 20 +++ setup/standardTemplateParams.php | 7 +- setup/validActions.php | 1 + views/admin/billing/accountReveals.html | 13 ++ views/admin/billing/editAccount.html | 5 +- views/admin/billing/editAccountAjax.html | 2 +- views/admin/billing/editInvoiceType.html | 2 + views/admin/billing/editNotificationType.html | 2 + views/admin/billing/header.html | 136 +++++++++++++----- views/admin/billing/invoiceTypes.html | 1 + views/admin/billing/invoices.html | 64 ++++++--- views/admin/billing/invoicing.html | 16 ++- views/admin/billing/invoicingSubHeader.html | 1 + .../billing/makePaymentAdjustmentAjax.html | 12 +- views/admin/billing/notifications.html | 39 ++++- views/admin/billing/preview.html | 3 + views/admin/billing/reports.html | 20 ++- views/admin/billing/reportsSubHeader.html | 1 + views/admin/billing/statements.html | 2 +- 24 files changed, 365 insertions(+), 81 deletions(-) create mode 100644 models/admin/ajax/ajaxNotificationPreview.php create mode 100644 views/admin/billing/preview.html diff --git a/classes/billingSupport.php b/classes/billingSupport.php index 071836c..c29168b 100644 --- a/classes/billingSupport.php +++ b/classes/billingSupport.php @@ -1093,6 +1093,7 @@ class GlmBillingSupport || !isset( $invoice_data['member_invoice'] ) || !isset( $invoice_data['employee_data'] ) ) { + echo '
$invoice_data: ' . print_r( $invoice_data, true ) . '
'; return false; } extract( $invoice_data ); @@ -1140,7 +1141,7 @@ class GlmBillingSupport 'recurrence' => $new_member_invoice_type['recurrence'], ) ); - // echo '
$invoice_id: ' . print_r( $invoice_id, true ) . '
'; + echo '
$invoice_id: ' . print_r( $invoice_id, true ) . '
'; if ( $invoice_id ) { if ( isset( $employees ) && is_array( $employees ) ) { // Add line items for each employee. diff --git a/classes/data/dataAccounts.php b/classes/data/dataAccounts.php index 00e7292..9a254f8 100644 --- a/classes/data/dataAccounts.php +++ b/classes/data/dataAccounts.php @@ -469,6 +469,7 @@ class GlmDataAccounts extends GlmDataAbstract 'anniversary_date' => $fSave['anniversary_date'], 'invoice_type' => $fSave['invoice_type'], ); + $this->fields['invoice_type']['type'] = 'integer'; $accountList = $this->getList($where, $order, $fieldVals, $idField, $start, $limit); diff --git a/models/admin/ajax/ajaxNotificationPreview.php b/models/admin/ajax/ajaxNotificationPreview.php new file mode 100644 index 0000000..a524265 --- /dev/null +++ b/models/admin/ajax/ajaxNotificationPreview.php @@ -0,0 +1,76 @@ + + * @license http://www.gaslightmedia.com Gaslightmedia + * @version 0.1 + */ + +require_once GLM_MEMBERS_BILLING_PLUGIN_PATH . '/models/admin/billing/notifications.php'; + +/** + * Steve Note + * + * You can get to this using the following URL. + * + * + {host}/wp-admin/admin-ajax.php?action=glm_members_admin_ajax&glm_action=runQueue + * + * You should be able to do this as POST or GET and should be able to add and read additional parameters. + * I added a "mystuff" parameter to the URL above and it does output from the code in the + * modelAction() function below. + * + * To add another model under models/admin/ajax all you need to do is create it and add it to the + * setup/validActions.php file. + * + */ + +/** + * This class handles the work of creating new invoices based on. + * 1) Member Type of member matching a paid invoiceType + * 2) Member renewal date past + * 3) Member has Billing Account + * 4) Member has no active Invoice + * 5) Renewal date is within the next 30 Days + * + */ +class GlmMembersAdmin_ajax_ajaxNotificationPreview extends GlmMembersAdmin_billing_notifications +{ + + /** + * WordPress Database Object + * + * @var $wpdb + * @access public + */ + public $wpdb; + /** + * Plugin Configuration Data + * + * @var $config + * @access public + */ + public $config; + + public $ajaxSide = true; + + public function __construct ( $wpdb, $config ) + { + + // Save WordPress Database object + $this->wpdb = $wpdb; + + // Save plugin configuration object + $this->config = $config; + + } + + +} diff --git a/models/admin/billing/accounts.php b/models/admin/billing/accounts.php index 9e39dfe..39c6e65 100644 --- a/models/admin/billing/accounts.php +++ b/models/admin/billing/accounts.php @@ -501,7 +501,6 @@ class GlmMembersAdmin_billing_accounts extends GlmDataAccounts 'filterExpired' => $filterExpired, 'filterActive' => $filterActive, 'filterArchived' => $filterArchived, - 'pluginAssetsUrl' => GLM_MEMBERS_BILLING_PLUGIN_BASE_URL . '/assets/' ); // Return status, any suggested view, and any data to controller diff --git a/models/admin/billing/invoicing.php b/models/admin/billing/invoicing.php index d44c0be..65b54b0 100644 --- a/models/admin/billing/invoicing.php +++ b/models/admin/billing/invoicing.php @@ -182,17 +182,22 @@ class GlmMembersAdmin_billing_invoicing //extends GlmDataAccounts // echo '
$wParts: ' . print_r( $wParts, true ) . '
'; if ( $option2 ) { + $successCounter = 0; // $where used in all places. - $where = implode( ' AND ', $wParts ); - // echo '
$where: ' . print_r( $where, true ) . '
'; - $accounts = $Accounts->getSimpleAccountList( $where ); + $where = implode( ' AND ', $wParts ); + $accounts = $Accounts->getSimpleAccountList( $where ); + $successMsg = ''; foreach ( $accounts as $account ) { + + echo '
$account: ' . print_r( $account, true ) . '
'; + // Get the invoice type $invoiceType = $BillingSupport->getInvoiceTypeById( $account['invoice_type'] ); + echo '
$invoiceType: ' . print_r( $invoiceType, true ) . '
'; // Create the invoice for this member account - $BillingSupport->createMemberInvoiceWithEmployees( + $newInvoiceId = $BillingSupport->createMemberInvoiceWithEmployees( array( 'account_id' => $account['id'], 'renew_type_id' => $account['invoice_type'], @@ -203,8 +208,11 @@ class GlmMembersAdmin_billing_invoicing //extends GlmDataAccounts 'employees' => array(), ) ); + if ( $newInvoiceId ) { + $successCounter++; + } } - $successMsg = 'Invoices Created'; + $successMsg .= "$successCounter Invoices Created"; } break; diff --git a/models/admin/billing/notifications.php b/models/admin/billing/notifications.php index 394fbb4..aca1492 100644 --- a/models/admin/billing/notifications.php +++ b/models/admin/billing/notifications.php @@ -148,6 +148,26 @@ class GlmMembersAdmin_billing_notifications extends GlmDataNotificationTypes switch( $option ) { + case 'preview': + $view = 'preview'; + // Compile template data + $templateData = array( + 'id' => $id, + 'contact' => array( + 'fname' => 'Test', + 'lname' => 'Person', + ) + ); + // Return status, suggested view, and data to controller + return array( + 'status' => $success, + 'menuItemRedirect' => false, + 'modelRedirect' => false, + 'view' => 'admin/billing/' . $view . '.html', + 'data' => $templateData + ); + break; + case 'add': /** * add: diff --git a/setup/standardTemplateParams.php b/setup/standardTemplateParams.php index d91438f..7f09750 100644 --- a/setup/standardTemplateParams.php +++ b/setup/standardTemplateParams.php @@ -23,10 +23,11 @@ */ // Common to both admin and front-end -$smarty->templateAssign('glmPluginName', GLM_MEMBERS_BILLING_PLUGIN_NAME ); +$smarty->templateAssign( 'glmPluginName', GLM_MEMBERS_BILLING_PLUGIN_NAME ); +$smarty->templateAssign( 'pluginAssetsUrl', GLM_MEMBERS_BILLING_PLUGIN_BASE_URL . '/assets/' ); if ( current_user_can( 'glm_members_management' ) ) { - $smarty->templateAssign('glmMemberManager', true); + $smarty->templateAssign( 'glmMemberManager', true ); } else { - $smarty->templateAssign('glmMemberManager', false); + $smarty->templateAssign( 'glmMemberManager', false ); } diff --git a/setup/validActions.php b/setup/validActions.php index f75376a..7d76bc2 100644 --- a/setup/validActions.php +++ b/setup/validActions.php @@ -78,6 +78,7 @@ $glmMembersBillingAddOnValidActions = array( 'billingFixActiveUsers' => GLM_MEMBERS_BILLING_PLUGIN_SLUG, 'ajaxBillingInfo' => GLM_MEMBERS_BILLING_PLUGIN_SLUG, 'ajaxBillingSettings' => GLM_MEMBERS_BILLING_PLUGIN_SLUG, + 'ajaxNotificationPreview' => GLM_MEMBERS_BILLING_PLUGIN_SLUG, ), 'management' => array( 'billing' => GLM_MEMBERS_BILLING_PLUGIN_SLUG, diff --git a/views/admin/billing/accountReveals.html b/views/admin/billing/accountReveals.html index f01b7f6..7776791 100644 --- a/views/admin/billing/accountReveals.html +++ b/views/admin/billing/accountReveals.html @@ -16,6 +16,19 @@ +{* Reveal for Payment Success *} +
+

Payment Complete!

+
+

Successfully saved your data!

+ +
+ +
{* Reveal for Billing Statements *}
+Cancel + {include file='ui/f6/errorCallout.html'} diff --git a/views/admin/billing/editNotificationType.html b/views/admin/billing/editNotificationType.html index 4ecd3eb..ed5c2b1 100644 --- a/views/admin/billing/editNotificationType.html +++ b/views/admin/billing/editNotificationType.html @@ -229,6 +229,8 @@ + Cancel + diff --git a/views/admin/billing/header.html b/views/admin/billing/header.html index 234a966..4991737 100644 --- a/views/admin/billing/header.html +++ b/views/admin/billing/header.html @@ -2,42 +2,104 @@

Billing

- {*