From 134bc82c7ca91560bf580ee2e8e0125e8b9e6bcd Mon Sep 17 00:00:00 2001 From: Coleman Watts Date: Mon, 23 Dec 2013 15:18:14 -0800 Subject: [PATCH] CRM-14023 CRM-14015 - Add apis for Financial Types & Accounts --- CRM/Admin/Page/Extensions.php | 1 - CRM/Core/xml/Menu/Admin.xml | 1 - CRM/Financial/Form/FinancialAccount.php | 7 +- CRM/Financial/Page/FinancialAccount.php | 4 +- CRM/Financial/Page/FinancialType.php | 4 +- api/v3/FinancialAccount.php | 77 +++++++++++++++++++ api/v3/FinancialType.php | 77 +++++++++++++++++++ js/view/crm.designer.js | 2 +- .../CRM/Financial/Page/FinancialAccount.tpl | 8 +- .../CRM/Financial/Page/FinancialType.tpl | 7 +- 10 files changed, 172 insertions(+), 16 deletions(-) create mode 100644 api/v3/FinancialAccount.php create mode 100644 api/v3/FinancialType.php diff --git a/CRM/Admin/Page/Extensions.php b/CRM/Admin/Page/Extensions.php index 134f82aecf..8563e8efd4 100644 --- a/CRM/Admin/Page/Extensions.php +++ b/CRM/Admin/Page/Extensions.php @@ -97,7 +97,6 @@ class CRM_Admin_Page_Extensions extends CRM_Core_Page_Basic { 'name' => ts('Disable'), 'url' => 'civicrm/admin/extensions', 'qs' => 'action=disable&id=%%id%%&key=%%key%%', - 'ref' => 'disable-action', 'title' => ts('Disable'), ), CRM_Core_Action::DELETE => array( diff --git a/CRM/Core/xml/Menu/Admin.xml b/CRM/Core/xml/Menu/Admin.xml index 187a8796f5..c24d3ded1c 100644 --- a/CRM/Core/xml/Menu/Admin.xml +++ b/CRM/Core/xml/Menu/Admin.xml @@ -299,7 +299,6 @@ civicrm/admin/weight - This should never be seen CRM_Utils_Weight::fixOrder diff --git a/CRM/Financial/Form/FinancialAccount.php b/CRM/Financial/Form/FinancialAccount.php index 0bc6795e5d..84d60c285f 100644 --- a/CRM/Financial/Form/FinancialAccount.php +++ b/CRM/Financial/Form/FinancialAccount.php @@ -67,8 +67,11 @@ class CRM_Financial_Form_FinancialAccount extends CRM_Contribute_Form { && !CRM_Financial_BAO_FinancialAccount::getARAccounts($this->_id, array_search('Asset', $financialAccountType))) { $this->_isARFlag = TRUE; if ($this->_action & CRM_Core_Action::DELETE) { - CRM_Core_Session::setStatus(ts("The selected financial account cannot be deleted because at least one Accounts Receivable type account is required (to ensure that accounting transactions are in balance)."), - '', 'error'); + $msg = ts("The selected financial account cannot be deleted because at least one Accounts Receivable type account is required (to ensure that accounting transactions are in balance)."); + if (CRM_Utils_Array::value('snippet', $_REQUEST) == 'json') { + CRM_Core_Page_AJAX::returnJsonResponse($msg); + } + CRM_Core_Session::setStatus($msg, '', 'error'); CRM_Utils_System::redirect(CRM_Utils_System::url('civicrm/admin/financial/financialAccount', "reset=1&action=browse")); } diff --git a/CRM/Financial/Page/FinancialAccount.php b/CRM/Financial/Page/FinancialAccount.php index 5b90a3d1f4..9a2892e482 100644 --- a/CRM/Financial/Page/FinancialAccount.php +++ b/CRM/Financial/Page/FinancialAccount.php @@ -70,12 +70,12 @@ class CRM_Financial_Page_FinancialAccount extends CRM_Core_Page_Basic { ), CRM_Core_Action::DISABLE => array( 'name' => ts('Disable'), - 'ref' => 'disable-action', + 'ref' => 'crm-enable-disable', 'title' => ts('Disable Financial Type'), ), CRM_Core_Action::ENABLE => array( 'name' => ts('Enable'), - 'ref' => 'enable-action', + 'ref' => 'crm-enable-disable', 'title' => ts('Enable Financial Type'), ), CRM_Core_Action::DELETE => array( diff --git a/CRM/Financial/Page/FinancialType.php b/CRM/Financial/Page/FinancialType.php index d00c6c6dbe..08628f7ff0 100644 --- a/CRM/Financial/Page/FinancialType.php +++ b/CRM/Financial/Page/FinancialType.php @@ -76,12 +76,12 @@ class CRM_Financial_Page_FinancialType extends CRM_Core_Page_Basic { ), CRM_Core_Action::DISABLE => array( 'name' => ts('Disable'), - 'ref' => 'disable-action', + 'ref' => 'crm-enable-disable', 'title' => ts('Disable Financial Type'), ), CRM_Core_Action::ENABLE => array( 'name' => ts('Enable'), - 'ref' => 'enable-action', + 'ref' => 'crm-enable-disable', 'title' => ts('Enable Financial Type'), ), CRM_Core_Action::DELETE => array( diff --git a/api/v3/FinancialAccount.php b/api/v3/FinancialAccount.php new file mode 100644 index 0000000000..beb43bff20 --- /dev/null +++ b/api/v3/FinancialAccount.php @@ -0,0 +1,77 @@ + {foreach from=$rows item=row} - - {$row.name} - {$row.description} - {$row.accounting_code} + + {$row.name} + {$row.description} + {$row.accounting_code} {$row.financial_account_type_id}{if $row.account_type_code} ({$row.account_type_code}){/if} {if $row.is_deductible eq 1} {ts}Yes{/ts} {else} {ts}No{/ts} {/if} {if $row.is_reserved eq 1} {ts}Yes{/ts} {else} {ts}No{/ts} {/if} diff --git a/templates/CRM/Financial/Page/FinancialType.tpl b/templates/CRM/Financial/Page/FinancialType.tpl index 80bc323f30..64879a4da6 100644 --- a/templates/CRM/Financial/Page/FinancialType.tpl +++ b/templates/CRM/Financial/Page/FinancialType.tpl @@ -40,6 +40,7 @@ {strip} {* handle enable/disable actions*} {include file="CRM/common/enableDisableApi.tpl"} + {include file="CRM/common/jsortable.tpl"} {include file="CRM/common/crmeditable.tpl"} @@ -52,9 +53,9 @@ {foreach from=$rows item=row} - - - + + + -- 2.25.1
{$row.name}{$row.description}
{$row.name}{$row.description} {$row.financial_account} {if $row.is_deductible eq 1} {ts}Yes{/ts} {else} {ts}No{/ts} {/if} {if $row.is_reserved eq 1} {ts}Yes{/ts} {else} {ts}No{/ts} {/if}