3 +--------------------------------------------------------------------+
5 +--------------------------------------------------------------------+
6 | Copyright CiviCRM LLC (c) 2004-2019 |
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-2019
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_Product';
62 * (reference) of action links
64 public function &links() {
65 if (!(self
::$_links)) {
67 CRM_Core_Action
::UPDATE
=> [
69 'url' => 'civicrm/admin/contribute/managePremiums',
70 'qs' => 'action=update&id=%%id%%&reset=1',
71 'title' => ts('Edit Premium'),
73 CRM_Core_Action
::PREVIEW
=> [
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
=> [
80 'name' => ts('Disable'),
81 'ref' => 'crm-enable-disable',
82 'title' => ts('Disable Premium'),
84 CRM_Core_Action
::ENABLE
=> [
85 'name' => ts('Enable'),
86 'ref' => 'crm-enable-disable',
87 'title' => ts('Enable Premium'),
89 CRM_Core_Action
::DELETE
=> [
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() {
108 $id = $this->getIdAndAction();
110 // what action to take ?
111 if (!($this->_action
& CRM_Core_Action
::BROWSE
)) {
112 $this->edit($this->_action
, $id, TRUE);
114 // finally browse the custom groups
118 return CRM_Core_Page
::run();
122 * Browse all custom data groups.
124 public function browse() {
125 // get all custom groups sorted by weight
127 $dao = new CRM_Contribute_DAO_Product();
128 $dao->orderBy('name');
131 while ($dao->fetch()) {
132 $premiums[$dao->id
] = [];
133 CRM_Core_DAO
::storeValues($dao, $premiums[$dao->id
]);
134 // form all action links
135 $action = array_sum(array_keys($this->links()));
137 if ($dao->is_active
) {
138 $action -= CRM_Core_Action
::ENABLE
;
141 $action -= CRM_Core_Action
::DISABLE
;
144 $premiums[$dao->id
]['action'] = CRM_Core_Action
::formLink(self
::links(),
149 'premium.manage.row',
154 if (!empty($dao->financial_type_id
)) {
155 $premiums[$dao->id
]['financial_type'] = CRM_Core_PseudoConstant
::getLabel('CRM_Contribute_BAO_Product', 'financial_type_id', $dao->financial_type_id
);
158 $this->assign('rows', $premiums);
162 * Get name of edit form.
165 * Classname of edit form.
167 public function editForm() {
168 return 'CRM_Contribute_Form_ManagePremiums';
172 * Get edit form name.
177 public function editName() {
178 return 'Manage Premiums';
189 public function userContext($mode = NULL) {
190 return 'civicrm/admin/contribute/managePremiums';