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'])) {
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;
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':
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
);
{include file='admin/registrations/header.html'}
-<h3>Account Edit Page</h3>
+ <a href="{$thisUrl}?page={$thisPage}&glm_action=accounts" class="button button-secondary glm-button glm-right">Return to Account List</a>
+
+ {if $option == 'edit' || $option == 'update'}
+ <a id="deleteAccountButton" class="button button-secondary glm-button glm-right">Delete this Account</a>
+ <h2>Edit Account
+ {else}
+ <h2>Add new Account
+ {/if}
+
+ {if $accountUpdated}<span class="glm-notice glm-flash-updated">Account Updated</span>{/if}
+ {if $accountUpdateError}<span class="glm-error glm-flash-updated">Account Update Error</span>{/if}
+ {if $accountAdded}<span class="glm-notice glm-flash-updated">Account Added</span>{/if}
+ {if $accountAddError}<span class="glm-error glm-flash-updated">Account Add Error</span>{/if}
+ </h2>
+
<form action="{$thisUrl}?page={$thisPage}" method="post" id="searchForm">
+ <input type="hidden" name="glm_action" value="accounts">
+ {if $haveAccount}
+ <input type="hidden" name="option" value="update">
+ <input type="hidden" name="account" value="{$account.fieldData.id}">
+ {else}
+ <input type="hidden" name="option" value="insert">
+ {/if}
+ <input type="hidden" name="contact_id" value="0">
+ <input type="hidden" name="registered_by" value="0">
<table id="glm-table-account" class="glm-admin-table glm-account-table">
{if $haveAccount} <input type="hidden" name="account" value="{$accountID}"> {/if}
</tr>
</table>
+
+ <input id="updateAccount" type="submit" value="{if $haveAccount}Update Account{else}Save New Account{/if}">
+
</form>
+ <script>
+ jQuery(document).ready(function($) {
+ $(".glm-flash-updated").fadeOut(500).fadeIn(500).fadeOut(500).fadeIn(500).fadeOut(500).fadeIn(500).fadeOut(500).fadeIn(500).fadeOut(500);
+ });
+
+ </script>
{include file='admin/footer.html'}