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 | * $Id$ |
17 | * | |
18 | */ | |
19 | ||
20 | /** | |
21 | * This class is to build the form for Deleting Group | |
22 | */ | |
23 | class CRM_Price_Form_DeleteField extends CRM_Core_Form { | |
24 | ||
25 | /** | |
fe482240 | 26 | * The field id. |
6a488035 TO |
27 | * |
28 | * @var int | |
29 | */ | |
30 | protected $_fid; | |
31 | ||
32 | /** | |
fe482240 | 33 | * The title of the group being deleted. |
6a488035 TO |
34 | * |
35 | * @var string | |
36 | */ | |
37 | protected $_title; | |
38 | ||
39 | /** | |
fe482240 | 40 | * Set up variables to build the form. |
6a488035 | 41 | * |
6a488035 | 42 | * @return void |
b44e3f84 | 43 | * @access protected |
95ea96be | 44 | */ |
79d7553f | 45 | public function preProcess() { |
6a488035 TO |
46 | $this->_fid = $this->get('fid'); |
47 | ||
9da8dc8c | 48 | $this->_title = CRM_Core_DAO::getFieldValue('CRM_Price_DAO_PriceField', |
6a488035 TO |
49 | $this->_fid, |
50 | 'label', 'id' | |
51 | ); | |
52 | ||
53 | $this->assign('title', $this->_title); | |
54 | ||
55 | CRM_Utils_System::setTitle(ts('Confirm Price Field Delete')); | |
56 | } | |
57 | ||
58 | /** | |
fe482240 | 59 | * Build the form object. |
6a488035 | 60 | * |
6a488035 | 61 | * @return void |
6a488035 TO |
62 | */ |
63 | public function buildQuickForm() { | |
be2fb01f CW |
64 | $this->addButtons([ |
65 | [ | |
c5c263ca AH |
66 | 'type' => 'next', |
67 | 'name' => ts('Delete Price Field'), | |
68 | 'isDefault' => TRUE, | |
be2fb01f CW |
69 | ], |
70 | [ | |
c5c263ca AH |
71 | 'type' => 'cancel', |
72 | 'name' => ts('Cancel'), | |
be2fb01f CW |
73 | ], |
74 | ]); | |
6a488035 TO |
75 | } |
76 | ||
77 | /** | |
fe482240 | 78 | * Process the form when submitted. |
6a488035 | 79 | * |
6a488035 | 80 | * @return void |
6a488035 TO |
81 | */ |
82 | public function postProcess() { | |
9da8dc8c | 83 | if (CRM_Price_BAO_PriceField::deleteField($this->_fid)) { |
be2fb01f | 84 | CRM_Core_Session::setStatus(ts('The Price Field \'%1\' has been deleted.', [1 => $this->_title]), '', 'success'); |
6a488035 TO |
85 | } |
86 | } | |
96025800 | 87 | |
6a488035 | 88 | } |