Commit | Line | Data |
---|---|---|
6a488035 TO |
1 | <?php |
2 | /* | |
3 | +--------------------------------------------------------------------+ | |
bc77d7c0 | 4 | | Copyright CiviCRM LLC. All rights reserved. | |
6a488035 | 5 | | | |
bc77d7c0 TO |
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 | | |
6a488035 | 9 | +--------------------------------------------------------------------+ |
d25dd0ee | 10 | */ |
6a488035 TO |
11 | |
12 | /** | |
13 | * | |
14 | * @package CRM | |
ca5cec67 | 15 | * @copyright CiviCRM LLC https://civicrm.org/licensing |
6a488035 TO |
16 | */ |
17 | ||
18 | /** | |
19 | * This class is to build the form for Deleting Set | |
20 | */ | |
21 | class CRM_Price_Form_DeleteSet extends CRM_Core_Form { | |
22 | ||
23 | /** | |
fe482240 | 24 | * The set id. |
6a488035 TO |
25 | * |
26 | * @var int | |
27 | */ | |
28 | protected $_sid; | |
29 | ||
30 | /** | |
fe482240 | 31 | * The title of the set being deleted. |
6a488035 TO |
32 | * |
33 | * @var string | |
34 | */ | |
35 | protected $_title; | |
36 | ||
37 | /** | |
fe482240 | 38 | * Set up variables to build the form. |
6a488035 TO |
39 | * |
40 | * @return void | |
95ea96be | 41 | */ |
79d7553f | 42 | public function preProcess() { |
6a488035 TO |
43 | $this->_sid = $this->get('sid'); |
44 | ||
9da8dc8c | 45 | $this->_title = CRM_Core_DAO::getFieldValue('CRM_Price_DAO_PriceSet', |
6a488035 TO |
46 | $this->_sid, 'title' |
47 | ); | |
48 | } | |
49 | ||
50 | /** | |
fe482240 | 51 | * Build the form object. |
6a488035 | 52 | * |
355ba699 | 53 | * @return void |
6a488035 TO |
54 | */ |
55 | public function buildQuickForm() { | |
56 | $this->assign('title', $this->_title); | |
be2fb01f CW |
57 | $this->addButtons([ |
58 | [ | |
c5c263ca AH |
59 | 'type' => 'next', |
60 | 'name' => ts('Delete Price Set'), | |
61 | 'isDefault' => TRUE, | |
be2fb01f CW |
62 | ], |
63 | [ | |
c5c263ca AH |
64 | 'type' => 'cancel', |
65 | 'name' => ts('Cancel'), | |
be2fb01f CW |
66 | ], |
67 | ]); | |
6a488035 TO |
68 | } |
69 | ||
70 | /** | |
fe482240 | 71 | * Process the form when submitted. |
6a488035 TO |
72 | * |
73 | * @return void | |
6a488035 TO |
74 | */ |
75 | public function postProcess() { | |
9da8dc8c | 76 | if (CRM_Price_BAO_PriceSet::deleteSet($this->_sid)) { |
6a488035 | 77 | CRM_Core_Session::setStatus(ts('The Price Set \'%1\' has been deleted.', |
be2fb01f | 78 | [1 => $this->_title], ts('Deleted'), 'success' |
353ffa53 | 79 | )); |
6a488035 TO |
80 | } |
81 | else { | |
82 | CRM_Core_Session::setStatus(ts('The Price Set \'%1\' has not been deleted! You must delete all price fields in this set prior to deleting the set.', | |
be2fb01f | 83 | [1 => $this->_title] |
353ffa53 | 84 | ), 'Unable to Delete', 'error'); |
6a488035 TO |
85 | } |
86 | } | |
96025800 | 87 | |
6a488035 | 88 | } |