3 +--------------------------------------------------------------------+
4 | CiviCRM version 4.6 |
5 +--------------------------------------------------------------------+
6 | Copyright CiviCRM LLC (c) 2004-2015 |
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-2015
37 * Page for displaying list of financial types
39 class CRM_Financial_Page_FinancialAccount
extends CRM_Core_Page_Basic
{
41 public $useLivePageJS = TRUE;
43 * The action links that we need to display for the browse screen.
47 static $_links = NULL;
55 public function getBAOName() {
56 return 'CRM_Financial_BAO_FinancialAccount';
63 * (reference) of action links
65 public function &links() {
66 if (!(self
::$_links)) {
67 self
::$_links = array(
68 CRM_Core_Action
::UPDATE
=> array(
70 'url' => 'civicrm/admin/financial/financialAccount',
71 'qs' => 'action=update&id=%%id%%&reset=1',
72 'title' => ts('Edit Financial Type'),
74 CRM_Core_Action
::DISABLE
=> array(
75 'name' => ts('Disable'),
76 'ref' => 'crm-enable-disable',
77 'title' => ts('Disable Financial Type'),
79 CRM_Core_Action
::ENABLE
=> array(
80 'name' => ts('Enable'),
81 'ref' => 'crm-enable-disable',
82 'title' => ts('Enable Financial Type'),
84 CRM_Core_Action
::DELETE
=> array(
85 'name' => ts('Delete'),
86 'url' => 'civicrm/admin/financial/financialAccount',
87 'qs' => 'action=delete&id=%%id%%',
88 'title' => ts('Delete Financial Type'),
98 * This method is called after the page is created. It checks for the
99 * type of action and executes that action.
100 * Finally it calls the parent's run method.
104 public function run() {
105 // get the requested action
106 $action = CRM_Utils_Request
::retrieve('action', 'String', $this, FALSE, 'browse'); // default to 'browse'
108 // assign vars to templates
109 $this->assign('action', $action);
110 $id = CRM_Utils_Request
::retrieve('id', 'Positive', $this, FALSE, 0);
112 // what action to take ?
113 if ($action & (CRM_Core_Action
::UPDATE | CRM_Core_Action
::ADD
)) {
114 $this->edit($action, $id);
118 return parent
::run();
122 * Browse all custom data groups.
127 public function browse() {
128 // get all custom groups sorted by weight
129 $contributionType = array();
130 $dao = new CRM_Financial_DAO_FinancialAccount();
131 $dao->orderBy('financial_account_type_id, name');
133 $financialAccountType = CRM_Core_PseudoConstant
::get('CRM_Financial_DAO_FinancialAccount', 'financial_account_type_id');
135 while ($dao->fetch()) {
136 $contributionType[$dao->id
] = array();
137 CRM_Core_DAO
::storeValues($dao, $contributionType[$dao->id
]);
138 $contributionType[$dao->id
]['financial_account_type_id'] = $financialAccountType[$dao->financial_account_type_id
];
139 // form all action links
140 $action = array_sum(array_keys($this->links()));
142 // update enable/disable links depending on if it is is_reserved or is_active
143 if ($dao->is_reserved
) {
147 if ($dao->is_active
) {
148 $action -= CRM_Core_Action
::ENABLE
;
151 $action -= CRM_Core_Action
::DISABLE
;
155 $contributionType[$dao->id
]['action'] = CRM_Core_Action
::formLink(self
::links(), $action,
156 array('id' => $dao->id
),
159 'financialAccount.manage.action',
164 $this->assign('rows', $contributionType);
168 * Get name of edit form.
171 * Classname of edit form.
173 public function editForm() {
174 return 'CRM_Financial_Form_FinancialAccount';
178 * Get edit form name.
183 public function editName() {
184 return 'Financial Types';
195 public function userContext($mode = NULL) {
196 return 'civicrm/admin/financial/financialAccount';