[REF] Update fetchAll function signature to match parent function
[civicrm-core.git] / CRM / Price / Form / DeleteSet.php
1 <?php
2 /*
3 +--------------------------------------------------------------------+
4 | Copyright CiviCRM LLC. All rights reserved. |
5 | |
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 +--------------------------------------------------------------------+
10 */
11
12 /**
13 *
14 * @package CRM
15 * @copyright CiviCRM LLC https://civicrm.org/licensing
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 /**
24 * The set id.
25 *
26 * @var int
27 */
28 protected $_sid;
29
30 /**
31 * The title of the set being deleted.
32 *
33 * @var string
34 */
35 protected $_title;
36
37 /**
38 * Set up variables to build the form.
39 *
40 * @return void
41 */
42 public function preProcess() {
43 $this->_sid = $this->get('sid');
44
45 $this->_title = CRM_Core_DAO::getFieldValue('CRM_Price_DAO_PriceSet',
46 $this->_sid, 'title'
47 );
48 }
49
50 /**
51 * Build the form object.
52 *
53 * @return void
54 */
55 public function buildQuickForm() {
56 $this->assign('title', $this->_title);
57 $this->addButtons([
58 [
59 'type' => 'next',
60 'name' => ts('Delete Price Set'),
61 'isDefault' => TRUE,
62 ],
63 [
64 'type' => 'cancel',
65 'name' => ts('Cancel'),
66 ],
67 ]);
68 }
69
70 /**
71 * Process the form when submitted.
72 *
73 * @return void
74 */
75 public function postProcess() {
76 if (CRM_Price_BAO_PriceSet::deleteSet($this->_sid)) {
77 CRM_Core_Session::setStatus(ts('The Price Set \'%1\' has been deleted.',
78 [1 => $this->_title], ts('Deleted'), 'success'
79 ));
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.',
83 [1 => $this->_title]
84 ), 'Unable to Delete', 'error');
85 }
86 }
87
88 }