3 +--------------------------------------------------------------------+
4 | Copyright CiviCRM LLC. All rights reserved. |
6 | This work is published under the GNU AGPLv3 license with some |
7 | permitted exceptions and without any warranty. For full license |
8 | and copyright information, see https://civicrm.org/licensing |
9 +--------------------------------------------------------------------+
15 * @copyright CiviCRM LLC https://civicrm.org/licensing
19 * Page for displaying list of Premiums.
21 class CRM_Contribute_Page_ManagePremiums
extends CRM_Core_Page_Basic
{
23 public $useLivePageJS = TRUE;
26 * The action links that we need to display for the browse screen.
30 public static $_links = NULL;
38 public function getBAOName() {
39 return 'CRM_Contribute_BAO_Product';
46 * (reference) of action links
48 public function &links() {
49 if (!(self
::$_links)) {
51 CRM_Core_Action
::UPDATE
=> [
53 'url' => 'civicrm/admin/contribute/managePremiums',
54 'qs' => 'action=update&id=%%id%%&reset=1',
55 'title' => ts('Edit Premium'),
57 CRM_Core_Action
::PREVIEW
=> [
58 'name' => ts('Preview'),
59 'url' => 'civicrm/admin/contribute/managePremiums',
60 'qs' => 'action=preview&id=%%id%%',
61 'title' => ts('Preview Premium'),
63 CRM_Core_Action
::DISABLE
=> [
64 'name' => ts('Disable'),
65 'ref' => 'crm-enable-disable',
66 'title' => ts('Disable Premium'),
68 CRM_Core_Action
::ENABLE
=> [
69 'name' => ts('Enable'),
70 'ref' => 'crm-enable-disable',
71 'title' => ts('Enable Premium'),
73 CRM_Core_Action
::DELETE
=> [
74 'name' => ts('Delete'),
75 'url' => 'civicrm/admin/contribute/managePremiums',
76 'qs' => 'action=delete&id=%%id%%',
77 'title' => ts('Delete Premium'),
87 * This method is called after the page is created. It checks for the
88 * type of action and executes that action.
89 * Finally it calls the parent's run method.
91 public function run() {
92 $id = $this->getIdAndAction();
94 // what action to take ?
95 if (!($this->_action
& CRM_Core_Action
::BROWSE
)) {
96 $this->edit($this->_action
, $id, TRUE);
98 // finally browse the custom groups
102 return CRM_Core_Page
::run();
106 * Browse all custom data groups.
108 public function browse() {
109 // get all custom groups sorted by weight
111 $dao = new CRM_Contribute_DAO_Product();
112 $dao->orderBy('name');
115 while ($dao->fetch()) {
116 $premiums[$dao->id
] = [];
117 CRM_Core_DAO
::storeValues($dao, $premiums[$dao->id
]);
118 // form all action links
119 $action = array_sum(array_keys($this->links()));
121 if ($dao->is_active
) {
122 $action -= CRM_Core_Action
::ENABLE
;
125 $action -= CRM_Core_Action
::DISABLE
;
128 $premiums[$dao->id
]['action'] = CRM_Core_Action
::formLink(self
::links(),
133 'premium.manage.row',
138 if (!empty($dao->financial_type_id
)) {
139 $premiums[$dao->id
]['financial_type'] = CRM_Core_PseudoConstant
::getLabel('CRM_Contribute_BAO_Product', 'financial_type_id', $dao->financial_type_id
);
142 $this->assign('rows', $premiums);
146 * Get name of edit form.
149 * Classname of edit form.
151 public function editForm() {
152 return 'CRM_Contribute_Form_ManagePremiums';
156 * Get edit form name.
161 public function editName() {
162 return 'Manage Premiums';
173 public function userContext($mode = NULL) {
174 return 'civicrm/admin/contribute/managePremiums';