3 +--------------------------------------------------------------------+
4 | CiviCRM version 4.7 |
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
35 * Page for displaying list of Premiums.
37 class CRM_Contribute_Page_ManagePremiums
extends CRM_Core_Page_Basic
{
39 public $useLivePageJS = TRUE;
42 * The action links that we need to display for the browse screen.
46 static $_links = NULL;
54 public function getBAOName() {
55 return 'CRM_Contribute_BAO_ManagePremiums';
62 * (reference) of action links
64 public function &links() {
65 if (!(self
::$_links)) {
66 self
::$_links = array(
67 CRM_Core_Action
::UPDATE
=> array(
69 'url' => 'civicrm/admin/contribute/managePremiums',
70 'qs' => 'action=update&id=%%id%%&reset=1',
71 'title' => ts('Edit Premium'),
73 CRM_Core_Action
::PREVIEW
=> array(
74 'name' => ts('Preview'),
75 'url' => 'civicrm/admin/contribute/managePremiums',
76 'qs' => 'action=preview&id=%%id%%',
77 'title' => ts('Preview Premium'),
79 CRM_Core_Action
::DISABLE
=> array(
80 'name' => ts('Disable'),
81 'ref' => 'crm-enable-disable',
82 'title' => ts('Disable Premium'),
84 CRM_Core_Action
::ENABLE
=> array(
85 'name' => ts('Enable'),
86 'ref' => 'crm-enable-disable',
87 'title' => ts('Enable Premium'),
89 CRM_Core_Action
::DELETE
=> array(
90 'name' => ts('Delete'),
91 'url' => 'civicrm/admin/contribute/managePremiums',
92 'qs' => 'action=delete&id=%%id%%',
93 'title' => ts('Delete Premium'),
103 * This method is called after the page is created. It checks for the
104 * type of action and executes that action.
105 * Finally it calls the parent's run method.
107 public function run() {
109 // get the requested action
110 $action = CRM_Utils_Request
::retrieve('action', 'String',
111 // default to 'browse'
112 $this, FALSE, 'browse'
115 // assign vars to templates
116 $this->assign('action', $action);
117 $id = CRM_Utils_Request
::retrieve('id', 'Positive',
121 // what action to take ?
122 if ($action & (CRM_Core_Action
::UPDATE | CRM_Core_Action
::ADD | CRM_Core_Action
::PREVIEW
)) {
123 $this->edit($action, $id, TRUE);
125 // finally browse the custom groups
129 return parent
::run();
133 * Browse all custom data groups.
135 public function browse() {
136 // get all custom groups sorted by weight
138 $dao = new CRM_Contribute_DAO_Product();
139 $dao->orderBy('name');
142 while ($dao->fetch()) {
143 $premiums[$dao->id
] = array();
144 CRM_Core_DAO
::storeValues($dao, $premiums[$dao->id
]);
145 // form all action links
146 $action = array_sum(array_keys($this->links()));
148 if ($dao->is_active
) {
149 $action -= CRM_Core_Action
::ENABLE
;
152 $action -= CRM_Core_Action
::DISABLE
;
155 $premiums[$dao->id
]['action'] = CRM_Core_Action
::formLink(self
::links(),
157 array('id' => $dao->id
),
160 'premium.manage.row',
165 if (!empty($dao->financial_type_id
)) {
166 require_once 'CRM/Core/DAO.php';
167 $premiums[$dao->id
]['financial_type_id'] = CRM_Core_DAO
::getFieldValue('CRM_Financial_DAO_FinancialType', $dao->financial_type_id
, 'name');
170 $this->assign('rows', $premiums);
174 * Get name of edit form.
177 * Classname of edit form.
179 public function editForm() {
180 return 'CRM_Contribute_Form_ManagePremiums';
184 * Get edit form name.
189 public function editName() {
190 return 'Manage Premiums';
201 public function userContext($mode = NULL) {
202 return 'civicrm/admin/contribute/managePremiums';