From 9bb38380849bdc65cd6cf83122afcd8cb92829e7 Mon Sep 17 00:00:00 2001 From: Steve Sutton Date: Fri, 24 Feb 2017 17:00:54 -0500 Subject: [PATCH] WIP Edit and Add forms Edit and Add page is working. Have to go over some fields like contact_id and the member reference with Chuck though. --- models/admin/registrations/accounts.php | 98 ++++++++++++++++--------- views/admin/registrations/account.html | 2 + views/admin/registrations/edit.html | 34 ++++++++- 3 files changed, 99 insertions(+), 35 deletions(-) diff --git a/models/admin/registrations/accounts.php b/models/admin/registrations/accounts.php index c294731..2f8d2d5 100644 --- a/models/admin/registrations/accounts.php +++ b/models/admin/registrations/accounts.php @@ -87,22 +87,26 @@ class GlmMembersAdmin_registrations_accounts extends GlmDataRegistrationsAccount public function modelAction($actionData = false) { - $option = 'list'; - $numbAccounts = 0; - $hasAccounts = false; - $paging = true; - $prevStart = false; - $nextStart = false; - $start = 1; - $limit = 20; // Set to the number of listings per page - $fromDate = false; - $toDate = false; - $filterArchived = false; - $filterPending = false; - $accounts = false; - $view = 'account.html'; - $account = false; - $haveAccount = false; + $option = 'list'; + $numbAccounts = 0; + $hasAccounts = false; + $paging = true; + $prevStart = false; + $nextStart = false; + $start = 1; + $limit = 20; // Set to the number of listings per page + $fromDate = false; + $toDate = false; + $filterArchived = false; + $filterPending = false; + $accounts = false; + $view = 'account'; + $account = false; + $haveAccount = false; + $accountUpdated = false; + $accountUpdateError = false; + $accountAdded = false; + $accountAddError = false; // Get any provided option if (isset($_REQUEST['option'])) { @@ -123,15 +127,22 @@ class GlmMembersAdmin_registrations_accounts extends GlmDataRegistrationsAccount switch ( $option ) { case 'add': - $view = 'edit.html'; + $view = 'edit'; $account = $this->newEntry(); break; case 'insert': + $view = 'edit'; + $account = $this->insertEntry(); + if ( $account['status'] ) { + $accountAdded = true; + } else { + $accountAddError = true; + } break; case 'edit': - $view = 'edit.html'; + $view = 'edit'; $account = $this->editEntry( $this->accountID ); if ( $account['status'] ) { $haveAccount = true; @@ -140,6 +151,20 @@ class GlmMembersAdmin_registrations_accounts extends GlmDataRegistrationsAccount break; case 'update': + $account = $this->updateEntry( $this->accountID ); + + if ( $account['status'] ) { + $accountUpdated = true; + // Retrieve the Edit Entry again + $account = $this->editEntry( $this->accountID ); + if ( $account['status'] ) { + $haveAccount = true; + } + } else { + $accountUpdateError = true; + } + + $view = 'edit'; break; case 'delete': @@ -148,32 +173,37 @@ class GlmMembersAdmin_registrations_accounts extends GlmDataRegistrationsAccount default: $accounts = $this->getList(); $hasAccounts = ( $accounts !== false && count( $accounts > 0 ) ) ? true: false; - $view = 'account.html'; + $view = 'account'; break; } // Compile template data $templateData = array( - 'hasAccounts' => $hasAccounts, - 'numAccounts' => count($accounts), - 'accounts' => $accounts, - 'account' => $account, - 'limit' => $limit, - 'prevStart' => $prevStart, - 'nextStart' => $nextStart, - 'paging' => $paging, - 'fromDate' => $fromDate, - 'toDate' => $toDate, - 'filterArchived' => $filterArchived, - 'filterPending' => $filterPending, - 'accountID' => $this->accountID, - 'haveAccount' => $haveAccount, + 'hasAccounts' => $hasAccounts, + 'numAccounts' => count($accounts), + 'accounts' => $accounts, + 'account' => $account, + 'limit' => $limit, + 'prevStart' => $prevStart, + 'nextStart' => $nextStart, + 'paging' => $paging, + 'fromDate' => $fromDate, + 'toDate' => $toDate, + 'filterArchived' => $filterArchived, + 'filterPending' => $filterPending, + 'accountID' => $this->accountID, + 'haveAccount' => $haveAccount, + 'accountUpdated' => $accountUpdated, + 'accountUpdateError' => $accountUpdateError, + 'option' => $option, + 'accountAdded' => $accountAdded, + 'accountAddError' => $accountAddError, ); // Return status, any suggested view, and any data to controller return array( 'status' => true, 'modelRedirect' => false, - 'view' => 'admin/registrations/' . $view, + 'view' => 'admin/registrations/' . $view . '.html', 'data' => $templateData ); diff --git a/views/admin/registrations/account.html b/views/admin/registrations/account.html index e1d0f51..96524b0 100644 --- a/views/admin/registrations/account.html +++ b/views/admin/registrations/account.html @@ -2,6 +2,8 @@

Account List Page

+ Add A New Account +
diff --git a/views/admin/registrations/edit.html b/views/admin/registrations/edit.html index 3708596..87287f6 100644 --- a/views/admin/registrations/edit.html +++ b/views/admin/registrations/edit.html @@ -1,8 +1,31 @@ {include file='admin/registrations/header.html'} -

Account Edit Page

+ Return to Account List + + {if $option == 'edit' || $option == 'update'} + Delete this Account +

Edit Account + {else} +

Add new Account + {/if} +     + {if $accountUpdated}Account Updated{/if} + {if $accountUpdateError}Account Update Error{/if} + {if $accountAdded}Account Added{/if} + {if $accountAddError}Account Add Error{/if} +

+ + + {if $haveAccount} + + + {else} + + {/if} + + {if $haveAccount} {/if} @@ -415,7 +438,16 @@ + + +
+ {include file='admin/footer.html'} -- 2.17.1