3 +--------------------------------------------------------------------+
4 | CiviCRM version 4.4 |
5 +--------------------------------------------------------------------+
6 | Copyright CiviCRM LLC (c) 2004-2013 |
7 +--------------------------------------------------------------------+
8 | This file is a part of CiviCRM. |
10 | CiviCRM is free software; you can copy, modify, and distribute it |
11 | under the terms of the GNU Affero General Public License |
12 | Version 3, 19 November 2007 and the CiviCRM Licensing Exception. |
14 | CiviCRM is distributed in the hope that it will be useful, but |
15 | WITHOUT ANY WARRANTY; without even the implied warranty of |
16 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. |
17 | See the GNU Affero General Public License for more details. |
19 | You should have received a copy of the GNU Affero General Public |
20 | License and the CiviCRM Licensing Exception along |
21 | with this program; if not, contact CiviCRM LLC |
22 | at info[AT]civicrm[DOT]org. If you have questions about the |
23 | GNU Affero General Public License or the licensing of CiviCRM, |
24 | see the CiviCRM license FAQ at http://civicrm.org/licensing |
25 +--------------------------------------------------------------------+
31 * @copyright CiviCRM LLC (c) 2004-2013
37 * Page for displaying list of financial types
39 class CRM_Financial_Page_FinancialAccount
extends CRM_Core_Page_Basic
{
41 * The action links that we need to display for the browse screen
46 static $_links = null;
51 * @return string Classname of BAO.
53 function getBAOName() {
54 return 'CRM_Financial_BAO_FinancialAccount';
60 * @return array (reference) of action links
63 if (!(self
::$_links)) {
64 self
::$_links = array(
65 CRM_Core_Action
::UPDATE
=> array(
67 'url' => 'civicrm/admin/financial/financialAccount',
68 'qs' => 'action=update&id=%%id%%&reset=1',
69 'title' => ts('Edit Financial Type'),
71 CRM_Core_Action
::DISABLE
=> array(
72 'name' => ts('Disable'),
73 'ref' => 'crm-enable-disable',
74 'title' => ts('Disable Financial Type'),
76 CRM_Core_Action
::ENABLE
=> array(
77 'name' => ts('Enable'),
78 'ref' => 'crm-enable-disable',
79 'title' => ts('Enable Financial Type'),
81 CRM_Core_Action
::DELETE
=> array(
82 'name' => ts('Delete'),
83 'url' => 'civicrm/admin/financial/financialAccount',
84 'qs' => 'action=delete&id=%%id%%',
85 'title' => ts('Delete Financial Type'),
95 * This method is called after the page is created. It checks for the
96 * type of action and executes that action.
97 * Finally it calls the parent's run method.
104 // get the requested action
105 $action = CRM_Utils_Request
::retrieve('action', 'String', $this, false, 'browse'); // default to 'browse'
107 // assign vars to templates
108 $this->assign('action', $action);
109 $id = CRM_Utils_Request
::retrieve('id', 'Positive', $this, false, 0);
111 // what action to take ?
112 if ($action & (CRM_Core_Action
::UPDATE | CRM_Core_Action
::ADD
)) {
113 $this->edit($action, $id) ;
117 return parent
::run();
121 * Browse all custom data groups.
129 CRM_Core_Resources
::singleton()->addScriptFile('civicrm', 'js/crm.livePage.js');
130 // get all custom groups sorted by weight
131 $contributionType = array();
132 $dao = new CRM_Financial_DAO_FinancialAccount();
133 $dao->orderBy('financial_account_type_id, name');
135 $financialAccountType = CRM_Core_PseudoConstant
::get('CRM_Financial_DAO_FinancialAccount', 'financial_account_type_id');
137 while ($dao->fetch()) {
138 $contributionType[$dao->id
] = array();
139 CRM_Core_DAO
::storeValues( $dao, $contributionType[$dao->id
]);
140 $contributionType[$dao->id
]['financial_account_type_id'] = $financialAccountType[$dao->financial_account_type_id
];
141 // form all action links
142 $action = array_sum(array_keys($this->links()));
144 // update enable/disable links depending on if it is is_reserved or is_active
145 if ($dao->is_reserved
) {
149 if ($dao->is_active
) {
150 $action -= CRM_Core_Action
::ENABLE
;
153 $action -= CRM_Core_Action
::DISABLE
;
157 $contributionType[$dao->id
]['action'] = CRM_Core_Action
::formLink(self
::links(), $action,
158 array('id' => $dao->id
),
161 'financialAccount.manage.action',
166 $this->assign('rows', $contributionType);
170 * Get name of edit form
172 * @return string Classname of edit form.
174 function editForm() {
175 return 'CRM_Financial_Form_FinancialAccount';
181 * @return string name of this page.
183 function editName() {
184 return 'Financial Types';
190 * @return string user context.
192 function userContext($mode = null) {
193 return 'civicrm/admin/financial/financialAccount';