From d5a4881e017011266029b36402873e27488a63c9 Mon Sep 17 00:00:00 2001 From: Steve Sutton Date: Mon, 15 Jul 2019 16:50:22 -0400 Subject: [PATCH] WIP invoice Types Redo invoice types. Instead of a jquery popup form to add edit them. Using a new page to edit them using a foundation abide form. --- classes/data/dataInvoiceTypes.php | 7 +- models/admin/billing/invoiceTypes.php | 113 ++++++--- models/admin/member/billing.php | 5 +- views/admin/billing/editAccountAjax.html | 6 +- views/admin/billing/editInvoiceType.html | 182 ++++++++++++++ views/admin/billing/editNotificationType.html | 59 ++--- views/admin/billing/invoiceTypes.html | 237 +----------------- views/admin/billing/notifications.html | 85 ------- views/admin/billing/settings.html | 44 ++-- views/admin/billing/statements.html | 147 +++++------ 10 files changed, 388 insertions(+), 497 deletions(-) create mode 100644 views/admin/billing/editInvoiceType.html diff --git a/classes/data/dataInvoiceTypes.php b/classes/data/dataInvoiceTypes.php index 07b6e49..738a5ef 100644 --- a/classes/data/dataInvoiceTypes.php +++ b/classes/data/dataInvoiceTypes.php @@ -117,9 +117,10 @@ class GlmDataInvoiceTypes extends GlmDataAbstract // Invoice Type Name 'name' => array( - 'field' => 'name', - 'type' => 'text', - 'use' => 'a', + 'field' => 'name', + 'type' => 'text', + 'required' => true, + 'use' => 'a', ), // Parent - for adding, deleting and editing, has selection tables diff --git a/models/admin/billing/invoiceTypes.php b/models/admin/billing/invoiceTypes.php index b68c5d9..405ea4d 100644 --- a/models/admin/billing/invoiceTypes.php +++ b/models/admin/billing/invoiceTypes.php @@ -49,7 +49,7 @@ class GlmMembersAdmin_billing_invoiceTypes extends GlmDataInvoiceTypes * @return object Class object * */ - public function __construct ($wpdb, $config) + public function __construct ( $wpdb, $config ) { // Save WordPress Database object @@ -97,15 +97,21 @@ class GlmMembersAdmin_billing_invoiceTypes extends GlmDataInvoiceTypes * produce output. * */ - public function modelAction ($actionData = false) + public function modelAction ( $actionData = false ) { - $success = true; - $haveInvoiceTypes = false; - $invoiceTypes = false; - $error = false; - $enable_members = $this->config['settings']['enable_members']; - $memberTypes = false; + $success = true; + $haveInvoiceTypes = false; + $invoiceTypes = false; + $error = false; + $enable_members = $this->config['settings']['enable_members']; + $memberTypes = false; + $view = 'invoiceTypes'; + $invoiceType = false; + $invoiceTypeUpdated = false; + $invoiceTypeUpdateError = false; + $invoiceTypeAdded = false; + $invoiceTypeInsertError = false; // Enqueue GLMA Foundation wp_enqueue_style( 'Foundation6', GLM_MEMBERS_PLUGIN_URL . '/css/foundation-6.min.css' ); @@ -113,32 +119,56 @@ class GlmMembersAdmin_billing_invoiceTypes extends GlmDataInvoiceTypes // Check for region id $id = 0; - if (isset($_REQUEST['id'])) { - $id = $_REQUEST['id']-0; + if ( isset( $_REQUEST['id'] ) ) { + $id = filter_var( $_REQUEST['id'], FILTER_VALIDATE_INT ); } // echo '
$_REQUEST: ' . print_r( $_REQUEST, true ) . '
'; // If there's an action option - if (isset($_REQUEST['option'])) { - - switch($_REQUEST['option']) { - - case 'addNew': - $this->insertEntry(); - break; - - case 'update': - if ($id > 0) { - $this->updateEntry($id); + if ( isset( $_REQUEST['option'] ) ) { + + switch( $_REQUEST['option'] ) { + + case 'add': + $invoiceType = $this->newEntry(); + $view = 'editInvoiceType'; + break; + + case 'addNew': + $invoiceType = $this->insertEntry(); + if ( $invoiceType['status'] ) { + $invoiceTypeUpdated = true; + $invoiceType = $this->editEntry( $id ); + } else { + $invoiceTypeUpdateError = true; + } + $view = 'editInvoiceType'; + break; + + case 'edit': + $invoiceType = $this->editEntry( $id ); + $view = 'editInvoiceType'; + break; + + case 'update': + if ( $id > 0 ) { + $invoiceType = $this->updateEntry( $id ); + if ( $invoiceType['status'] ) { + $invoiceTypeUpdated = true; + $invoiceType = $this->editEntry( $id ); + } else { + $invoiceTypeUpdateError = true; } - break; + } + $view = 'editInvoiceType'; + break; - case 'delete': - if ($id > 0) { - $this->deleteEntry($id, true); - } - break; + case 'delete': + if ( $id > 0 ) { + $this->deleteEntry( $id, true ); + } + break; } @@ -152,28 +182,26 @@ class GlmMembersAdmin_billing_invoiceTypes extends GlmDataInvoiceTypes // If we have list entries - even if it's an empty list $success = true; $haveInvoiceTypes = false; - if ($invoiceTypes !== false) { + if ( $invoiceTypes !== false ) { $success = true; // If we have any entries - if (count($invoiceTypes) > 0) { + if ( count( $invoiceTypes ) > 0 ) { $haveInvoiceTypes = true; } } // Sort results by higherarchy (Parent/Child and Alpha) - $invoiceTypes = $this->sortParentChild($invoiceTypes); - // echo '
$invoiceTypes: ' . print_r( $invoiceTypes, true ) . '
'; + $invoiceTypes = $this->sortParentChild( $invoiceTypes ); // Get list of Member Types $MemberType = new GlmDataMemberTypes( $this->wpdb, $this->config ); $memberTypes = $MemberType->getList(); - // echo '
$memberTypes: ' . print_r( $memberTypes, true ) . '
'; // If we had a fatal error, redirect to the error page - if ($error) { + if ( $error ) { return array( 'status' => $success, 'menuItemRedirect' => 'error', @@ -187,12 +215,17 @@ class GlmMembersAdmin_billing_invoiceTypes extends GlmDataInvoiceTypes // Compile template data $templateData = array( - 'action' => $_REQUEST['glm_action'], - 'enable_members' => $enable_members, - 'haveInvoiceTypes' => $haveInvoiceTypes, - 'invoiceTypes' => $invoiceTypes, - 'recurrenceTypes' => $this->config['recurrence'], - 'memberTypes' => $memberTypes, + 'action' => $_REQUEST['glm_action'], + 'enable_members' => $enable_members, + 'haveInvoiceTypes' => $haveInvoiceTypes, + 'invoiceTypes' => $invoiceTypes, + 'recurrenceTypes' => $this->config['recurrence'], + 'memberTypes' => $memberTypes, + 'invoiceType' => $invoiceType, + 'invoiceTypeUpdated' => $invoiceTypeUpdated, + 'invoiceTypeUpdateError' => $invoiceTypeUpdateError, + 'invoiceTypeAdded' => $invoiceTypeAdded, + 'invoiceTypeInsertError' => $invoiceTypeInsertError, ); // Return status, suggested view, and data to controller @@ -200,7 +233,7 @@ class GlmMembersAdmin_billing_invoiceTypes extends GlmDataInvoiceTypes 'status' => $success, 'menuItemRedirect' => false, 'modelRedirect' => false, - 'view' => 'admin/billing/invoiceTypes.html', + 'view' => 'admin/billing/'.$view.'.html', 'data' => $templateData ); diff --git a/models/admin/member/billing.php b/models/admin/member/billing.php index c1ac133..4eebc46 100644 --- a/models/admin/member/billing.php +++ b/models/admin/member/billing.php @@ -998,23 +998,22 @@ class GlmMembersAdmin_member_billing // extends GlmDataBilling case 'list': $view = 'statements'; + require_once GLM_MEMBERS_BILLING_PLUGIN_CLASS_PATH . '/data/dataAccounts.php'; + $account = $Accounts->editEntry( $accountID ); if ( isset( $_REQUEST['all'] ) && $all = filter_var( $_REQUEST['all'], FILTER_VALIDATE_BOOLEAN ) ) { $allStatements = true; } - // echo '
$test: ' . print_r( $test, true ) . '
'; break; } // Get the list of invoices for this member. $statements = $BillingSupport->getStatementsByRefDest( $this->memberID, $allStatements ); - // echo '
$statements: ' . print_r( $statements, true ) . '
'; if ( $statements ) { $transactions = $statements['transactions']; $account_data = $statements['account_data']; $balance_due = $statements['balance_due']; $hasBillingAccount = true; } - // echo '
$account_data: ' . print_r( $account_data, true ) . '
'; // Compile template data $templateData = array( diff --git a/views/admin/billing/editAccountAjax.html b/views/admin/billing/editAccountAjax.html index 597ccb1..96d3cf7 100644 --- a/views/admin/billing/editAccountAjax.html +++ b/views/admin/billing/editAccountAjax.html @@ -2,11 +2,7 @@ -{if $accountUpdated}Account Updated{/if} -{if $accountUpdateError}Account Update Error{/if} -{if $accountInsertError}Account Insert Error{/if} -{if $accountAdded}Account Added{/if} - +

{$account.fieldData.ref_name}

{$data = $account} diff --git a/views/admin/billing/editInvoiceType.html b/views/admin/billing/editInvoiceType.html new file mode 100644 index 0000000..ba938d4 --- /dev/null +++ b/views/admin/billing/editInvoiceType.html @@ -0,0 +1,182 @@ +{include file='admin/billing/header.html'} + +
+ + {* Set $data to $invoiceType *} + {* This is for using the UI elements *} + {$data = $invoiceType} + + {* Invoice Type Updated *} + {$ui = [ + 'label' => 'Invoice Type Updated', + 'active' => $invoiceTypeUpdated, + 'type' => 'success' + ]} + {include file="ui/f6/callout.html"} + + {* Invoice Type Added *} + {$ui = [ + 'label' => 'Invoice Type Added', + 'active' => $invoiceTypeAdded, + 'type' => 'success' + ]} + {include file="ui/f6/callout.html"} + + {* Invoice Type Update Error *} + {$ui = [ + 'label' => 'Invoice Type Update Error', + 'active' => $invoiceTypeUpdateError, + 'type' => 'alert' + ]} + {include file="ui/f6/callout.html"} + + {* Invoice Type Insert Error *} + {$ui = [ + 'label' => 'Invoice Type Added', + 'active' => $invoiceTypeAdded, + 'type' => 'success' + ]} + {include file="ui/f6/callout.html"} + +
+ + {if isset($data.fieldData.id)} + + + {else} + + {/if} + +
+ +
+ Invoice Type + +
+ + {* Invoice Type Name *} + {$ui = [ + 'value' => $data.fieldData.name, + 'field' => 'name', + 'label' => 'Invoice Type Name', + 'required' => $data.fieldRequired.name, + 'errorText' => 'Invoice Type Name is Required', + 'dataError' => $data.fieldFail.name + ]} + {include file='ui/f6/text.html'} + + {* Parent *} + {$ui = [ + 'value' => $data.fieldData.parent.value, + 'field' => 'parent', + 'label' => 'Parent', + 'list' => $invoiceTypes, + 'l_label' => 'name', + 'l_value' => 'id', + 'l_blank' => true, + 'required' => $data.fieldRequired.parent, + 'errorText' => 'Parent is Required', + 'dataError' => $data.fieldFail.parent + ]} + {include file='ui/f6/select.html'} + + {* Member Type *} + {$ui = [ + 'value' => $data.fieldData.member_type.value, + 'field' => 'member_type', + 'label' => 'Member Type', + 'list' => $memberTypes, + 'l_label' => 'name', + 'l_value' => 'id', + 'l_blank' => true, + 'required' => $data.fieldRequired.member_type, + 'errorText' => 'Member Type is Required', + 'dataError' => $data.fieldFail.member_type + ]} + {include file='ui/f6/select.html'} + + {* Amount *} + {$ui = [ + 'value' => $data.fieldData.amount, + 'field' => 'amount', + 'label' => 'Amount', + 'pattern' => 'number', + 'required' => $data.fieldRequired.amount, + 'errorText' => 'Amount is Required', + 'dataError' => $data.fieldFail.amount + ]} + {include file='ui/f6/text.html'} + + {* Dynamic Amount *} + {$ui = [ + 'value' => $data.fieldData.dynamic_amount.value, + 'field' => 'dynamic_amount', + 'label' => 'Dynamic Amount', + 'required' => $data.fieldRequired.dynamic_amount, + 'errortext' => 'Dynamic Amount is Required', + 'helpText' => 'Ask for the amount on Invoice Form', + 'dataError' => $data.fieldFail.dynamic_amount + ]} + {include file='ui/f6/checkbox.html'} + + {* Recurring *} + {$ui = [ + 'value' => $data.fieldData.recurring.value, + 'field' => 'recurring', + 'label' => 'Recurring', + 'required' => $data.fieldRequired.recurring, + 'errortext' => 'Recurring is Required', + 'dataError' => $data.fieldFail.recurring + ]} + {include file='ui/f6/checkbox.html'} + + {* Recurrence *} + {$ui = [ + 'value' => $data.fieldData.recurrence, + 'field' => 'recurrence', + 'label' => 'Recurrence', + 'list' => $recurrenceTypes, + 'l_blank' => true, + 'required' => $data.fieldRequired.recurrence, + 'errorText' => 'Recurrence is Required', + 'dataError' => $data.fieldFail.recurrence + ]} + {include file='ui/f6/select.html'} + + + {* Code *} + {$ui = [ + 'value' => $data.fieldData.qcode, + 'field' => 'qcode', + 'label' => 'Code', + 'required' => $data.fieldRequired.qcode, + 'errorText' => 'Code is Required', + 'dataError' => $data.fieldFail.qcode + ]} + {include file='ui/f6/text.html'} + + {* Category *} + {$ui = [ + 'value' => $data.fieldData.category, + 'field' => 'category', + 'label' => 'Category', + 'required' => $data.fieldRequired.category, + 'errorText' => 'Category is Required', + 'dataError' => $data.fieldFail.category + ]} + {include file='ui/f6/text.html'} + +
+ + +
+ + + +
+
+ + + +{include file='admin/footer.html'} diff --git a/views/admin/billing/editNotificationType.html b/views/admin/billing/editNotificationType.html index 0801ae1..f9ca292 100644 --- a/views/admin/billing/editNotificationType.html +++ b/views/admin/billing/editNotificationType.html @@ -13,41 +13,36 @@ {$data = $notification} {* Notification Updated *} - {if $notificationUpdated} -
- -

Notification Updated

-
- {/if} + {$ui = [ + 'label' => 'Notification Updated', + 'active' => $notificationUpdated, + 'type' => 'success' + ]} + {include file="ui/f6/callout.html"} + {* Notification Added *} - {if $notificationAdded} -
- -

Notification Added

-
- {/if} + {$ui = [ + 'label' => 'Notification Added', + 'active' => $notificationAdded, + 'type' => 'success' + ]} + {include file="ui/f6/callout.html"} + {* Notification Update Error *} - {if $notificationUpdateError} -
- -

Notification Update Error

-
- {/if} + {$ui = [ + 'label' => 'Notification Update Error', + 'active' => $notificationUpdateError, + 'type' => 'alert' + ]} + {include file="ui/f6/callout.html"} + {* Notification Insert Error *} - {if $notificationInsertError} -
- -

Notification Insert Error

-
- {/if} + {$ui = [ + 'label' => 'Notification Added', + 'active' => $notificationAdded, + 'type' => 'success' + ]} + {include file="ui/f6/callout.html"}
{if $notification_id} diff --git a/views/admin/billing/invoiceTypes.html b/views/admin/billing/invoiceTypes.html index 85f715d..8103f55 100644 --- a/views/admin/billing/invoiceTypes.html +++ b/views/admin/billing/invoiceTypes.html @@ -5,96 +5,7 @@

InvoiceTypes

{* Add InvoiceTypes Button and Dialog Box *} -
Add a Invoice Type
-
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Invoice Type Name - -
Parent - -
Member Type - -
Amount:Numbers only
(999.99)
- -
Dynamic Amount: - - - Ask for the amount on Invoice Forms -
Recurring: - - -
Recurrence: - -
Code: - -
Category: - -
-

* Required

- Cancel - - -
+ Add a Invoice Type {* Add InvoiceTypes Button *}
@@ -105,99 +16,6 @@
- {* Edit InvoiceTypes Dialog Box *} -
-
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Invoice Type Name: - -
Parent: - -
Member Type - -
Amount:Numbers only
(999.99)
- -
Dynamic Amount: - - - Ask for the amount on Invoice Forms -
Recurring: - - -
Recurrence: - -
Code: - -
Category: - -
-

* Required

- Cancel - -
-
- - @@ -222,17 +40,7 @@ @@ -253,7 +61,7 @@ -
{$t.id} - {$t.name} + {$t.name} {$t.amount}