Merge pull request #19525 from eileenmcnaughton/member_soft
[civicrm-core.git] / CRM / Core / DAO / Discount.php
1 <?php
2
3 /**
4 * @package CRM
5 * @copyright CiviCRM LLC https://civicrm.org/licensing
6 *
7 * Generated from xml/schema/CRM/Core/Discount.xml
8 * DO NOT EDIT. Generated by CRM_Core_CodeGen
9 * (GenCodeChecksum:d6ec5d0b6786067f47617e39acbbbd3c)
10 */
11
12 /**
13 * Database access object for the Discount entity.
14 */
15 class CRM_Core_DAO_Discount extends CRM_Core_DAO {
16 const EXT = 'civicrm';
17 const TABLE_ADDED = '2.1';
18
19 /**
20 * Static instance to hold the table name.
21 *
22 * @var string
23 */
24 public static $_tableName = 'civicrm_discount';
25
26 /**
27 * Should CiviCRM log any modifications to this table in the civicrm_log table.
28 *
29 * @var bool
30 */
31 public static $_log = TRUE;
32
33 /**
34 * primary key
35 *
36 * @var int
37 */
38 public $id;
39
40 /**
41 * physical tablename for entity being joined to discount, e.g. civicrm_event
42 *
43 * @var string
44 */
45 public $entity_table;
46
47 /**
48 * FK to entity table specified in entity_table column.
49 *
50 * @var int
51 */
52 public $entity_id;
53
54 /**
55 * FK to civicrm_price_set
56 *
57 * @var int
58 */
59 public $price_set_id;
60
61 /**
62 * Date when discount starts.
63 *
64 * @var date
65 */
66 public $start_date;
67
68 /**
69 * Date when discount ends.
70 *
71 * @var date
72 */
73 public $end_date;
74
75 /**
76 * Class constructor.
77 */
78 public function __construct() {
79 $this->__table = 'civicrm_discount';
80 parent::__construct();
81 }
82
83 /**
84 * Returns localized title of this entity.
85 *
86 * @param bool $plural
87 * Whether to return the plural version of the title.
88 */
89 public static function getEntityTitle($plural = FALSE) {
90 return $plural ? ts('Discounts') : ts('Discount');
91 }
92
93 /**
94 * Returns foreign keys and entity references.
95 *
96 * @return array
97 * [CRM_Core_Reference_Interface]
98 */
99 public static function getReferenceColumns() {
100 if (!isset(Civi::$statics[__CLASS__]['links'])) {
101 Civi::$statics[__CLASS__]['links'] = static::createReferenceColumns(__CLASS__);
102 Civi::$statics[__CLASS__]['links'][] = new CRM_Core_Reference_Basic(self::getTableName(), 'price_set_id', 'civicrm_price_set', 'id');
103 Civi::$statics[__CLASS__]['links'][] = new CRM_Core_Reference_Dynamic(self::getTableName(), 'entity_id', NULL, 'id', 'entity_table');
104 CRM_Core_DAO_AllCoreTables::invoke(__CLASS__, 'links_callback', Civi::$statics[__CLASS__]['links']);
105 }
106 return Civi::$statics[__CLASS__]['links'];
107 }
108
109 /**
110 * Returns all the column names of this table
111 *
112 * @return array
113 */
114 public static function &fields() {
115 if (!isset(Civi::$statics[__CLASS__]['fields'])) {
116 Civi::$statics[__CLASS__]['fields'] = [
117 'id' => [
118 'name' => 'id',
119 'type' => CRM_Utils_Type::T_INT,
120 'title' => ts('Discount ID'),
121 'description' => ts('primary key'),
122 'required' => TRUE,
123 'where' => 'civicrm_discount.id',
124 'table_name' => 'civicrm_discount',
125 'entity' => 'Discount',
126 'bao' => 'CRM_Core_BAO_Discount',
127 'localizable' => 0,
128 'html' => [
129 'type' => 'Number',
130 ],
131 'add' => '2.1',
132 ],
133 'entity_table' => [
134 'name' => 'entity_table',
135 'type' => CRM_Utils_Type::T_STRING,
136 'title' => ts('Entity Table'),
137 'description' => ts('physical tablename for entity being joined to discount, e.g. civicrm_event'),
138 'maxlength' => 64,
139 'size' => CRM_Utils_Type::BIG,
140 'where' => 'civicrm_discount.entity_table',
141 'table_name' => 'civicrm_discount',
142 'entity' => 'Discount',
143 'bao' => 'CRM_Core_BAO_Discount',
144 'localizable' => 0,
145 'add' => '2.1',
146 ],
147 'entity_id' => [
148 'name' => 'entity_id',
149 'type' => CRM_Utils_Type::T_INT,
150 'title' => ts('Entity ID'),
151 'description' => ts('FK to entity table specified in entity_table column.'),
152 'required' => TRUE,
153 'where' => 'civicrm_discount.entity_id',
154 'table_name' => 'civicrm_discount',
155 'entity' => 'Discount',
156 'bao' => 'CRM_Core_BAO_Discount',
157 'localizable' => 0,
158 'add' => '2.1',
159 ],
160 'participant_discount_name' => [
161 'name' => 'price_set_id',
162 'type' => CRM_Utils_Type::T_INT,
163 'title' => ts('Price Set ID'),
164 'description' => ts('FK to civicrm_price_set'),
165 'required' => TRUE,
166 'where' => 'civicrm_discount.price_set_id',
167 'export' => TRUE,
168 'table_name' => 'civicrm_discount',
169 'entity' => 'Discount',
170 'bao' => 'CRM_Core_BAO_Discount',
171 'localizable' => 0,
172 'FKClassName' => 'CRM_Price_DAO_PriceSet',
173 'html' => [
174 'label' => ts("Price Set"),
175 ],
176 'pseudoconstant' => [
177 'table' => 'civicrm_price_set',
178 'keyColumn' => 'id',
179 'labelColumn' => 'title',
180 ],
181 'add' => '4.3',
182 ],
183 'start_date' => [
184 'name' => 'start_date',
185 'type' => CRM_Utils_Type::T_DATE,
186 'title' => ts('Discount Start Date'),
187 'description' => ts('Date when discount starts.'),
188 'where' => 'civicrm_discount.start_date',
189 'table_name' => 'civicrm_discount',
190 'entity' => 'Discount',
191 'bao' => 'CRM_Core_BAO_Discount',
192 'localizable' => 0,
193 'add' => '2.1',
194 ],
195 'end_date' => [
196 'name' => 'end_date',
197 'type' => CRM_Utils_Type::T_DATE,
198 'title' => ts('Discount End Date'),
199 'description' => ts('Date when discount ends.'),
200 'where' => 'civicrm_discount.end_date',
201 'table_name' => 'civicrm_discount',
202 'entity' => 'Discount',
203 'bao' => 'CRM_Core_BAO_Discount',
204 'localizable' => 0,
205 'add' => '2.1',
206 ],
207 ];
208 CRM_Core_DAO_AllCoreTables::invoke(__CLASS__, 'fields_callback', Civi::$statics[__CLASS__]['fields']);
209 }
210 return Civi::$statics[__CLASS__]['fields'];
211 }
212
213 /**
214 * Return a mapping from field-name to the corresponding key (as used in fields()).
215 *
216 * @return array
217 * Array(string $name => string $uniqueName).
218 */
219 public static function &fieldKeys() {
220 if (!isset(Civi::$statics[__CLASS__]['fieldKeys'])) {
221 Civi::$statics[__CLASS__]['fieldKeys'] = array_flip(CRM_Utils_Array::collect('name', self::fields()));
222 }
223 return Civi::$statics[__CLASS__]['fieldKeys'];
224 }
225
226 /**
227 * Returns the names of this table
228 *
229 * @return string
230 */
231 public static function getTableName() {
232 return self::$_tableName;
233 }
234
235 /**
236 * Returns if this table needs to be logged
237 *
238 * @return bool
239 */
240 public function getLog() {
241 return self::$_log;
242 }
243
244 /**
245 * Returns the list of fields that can be imported
246 *
247 * @param bool $prefix
248 *
249 * @return array
250 */
251 public static function &import($prefix = FALSE) {
252 $r = CRM_Core_DAO_AllCoreTables::getImports(__CLASS__, 'discount', $prefix, []);
253 return $r;
254 }
255
256 /**
257 * Returns the list of fields that can be exported
258 *
259 * @param bool $prefix
260 *
261 * @return array
262 */
263 public static function &export($prefix = FALSE) {
264 $r = CRM_Core_DAO_AllCoreTables::getExports(__CLASS__, 'discount', $prefix, []);
265 return $r;
266 }
267
268 /**
269 * Returns the list of indices
270 *
271 * @param bool $localize
272 *
273 * @return array
274 */
275 public static function indices($localize = TRUE) {
276 $indices = [
277 'index_entity' => [
278 'name' => 'index_entity',
279 'field' => [
280 0 => 'entity_table',
281 1 => 'entity_id',
282 ],
283 'localizable' => FALSE,
284 'sig' => 'civicrm_discount::0::entity_table::entity_id',
285 ],
286 'index_entity_option_id' => [
287 'name' => 'index_entity_option_id',
288 'field' => [
289 0 => 'entity_table',
290 1 => 'entity_id',
291 2 => 'price_set_id',
292 ],
293 'localizable' => FALSE,
294 'sig' => 'civicrm_discount::0::entity_table::entity_id::price_set_id',
295 ],
296 ];
297 return ($localize && !empty($indices)) ? CRM_Core_DAO_AllCoreTables::multilingualize(__CLASS__, $indices) : $indices;
298 }
299
300 }