Merge pull request #19075 from colemanw/searchable
[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:ccb85ff70ce8a536ac4a941628455d8d)
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 'add' => '2.1',
129 ],
130 'entity_table' => [
131 'name' => 'entity_table',
132 'type' => CRM_Utils_Type::T_STRING,
133 'title' => ts('Entity Table'),
134 'description' => ts('physical tablename for entity being joined to discount, e.g. civicrm_event'),
135 'maxlength' => 64,
136 'size' => CRM_Utils_Type::BIG,
137 'where' => 'civicrm_discount.entity_table',
138 'table_name' => 'civicrm_discount',
139 'entity' => 'Discount',
140 'bao' => 'CRM_Core_BAO_Discount',
141 'localizable' => 0,
142 'add' => '2.1',
143 ],
144 'entity_id' => [
145 'name' => 'entity_id',
146 'type' => CRM_Utils_Type::T_INT,
147 'title' => ts('Entity ID'),
148 'description' => ts('FK to entity table specified in entity_table column.'),
149 'required' => TRUE,
150 'where' => 'civicrm_discount.entity_id',
151 'table_name' => 'civicrm_discount',
152 'entity' => 'Discount',
153 'bao' => 'CRM_Core_BAO_Discount',
154 'localizable' => 0,
155 'add' => '2.1',
156 ],
157 'participant_discount_name' => [
158 'name' => 'price_set_id',
159 'type' => CRM_Utils_Type::T_INT,
160 'title' => ts('Discount Name'),
161 'description' => ts('FK to civicrm_price_set'),
162 'required' => TRUE,
163 'where' => 'civicrm_discount.price_set_id',
164 'export' => TRUE,
165 'table_name' => 'civicrm_discount',
166 'entity' => 'Discount',
167 'bao' => 'CRM_Core_BAO_Discount',
168 'localizable' => 0,
169 'FKClassName' => 'CRM_Price_DAO_PriceSet',
170 'pseudoconstant' => [
171 'table' => 'civicrm_price_set',
172 'keyColumn' => 'id',
173 'labelColumn' => 'title',
174 ],
175 'add' => '4.3',
176 ],
177 'start_date' => [
178 'name' => 'start_date',
179 'type' => CRM_Utils_Type::T_DATE,
180 'title' => ts('Discount Start Date'),
181 'description' => ts('Date when discount starts.'),
182 'where' => 'civicrm_discount.start_date',
183 'table_name' => 'civicrm_discount',
184 'entity' => 'Discount',
185 'bao' => 'CRM_Core_BAO_Discount',
186 'localizable' => 0,
187 'add' => '2.1',
188 ],
189 'end_date' => [
190 'name' => 'end_date',
191 'type' => CRM_Utils_Type::T_DATE,
192 'title' => ts('Discount End Date'),
193 'description' => ts('Date when discount ends.'),
194 'where' => 'civicrm_discount.end_date',
195 'table_name' => 'civicrm_discount',
196 'entity' => 'Discount',
197 'bao' => 'CRM_Core_BAO_Discount',
198 'localizable' => 0,
199 'add' => '2.1',
200 ],
201 ];
202 CRM_Core_DAO_AllCoreTables::invoke(__CLASS__, 'fields_callback', Civi::$statics[__CLASS__]['fields']);
203 }
204 return Civi::$statics[__CLASS__]['fields'];
205 }
206
207 /**
208 * Return a mapping from field-name to the corresponding key (as used in fields()).
209 *
210 * @return array
211 * Array(string $name => string $uniqueName).
212 */
213 public static function &fieldKeys() {
214 if (!isset(Civi::$statics[__CLASS__]['fieldKeys'])) {
215 Civi::$statics[__CLASS__]['fieldKeys'] = array_flip(CRM_Utils_Array::collect('name', self::fields()));
216 }
217 return Civi::$statics[__CLASS__]['fieldKeys'];
218 }
219
220 /**
221 * Returns the names of this table
222 *
223 * @return string
224 */
225 public static function getTableName() {
226 return self::$_tableName;
227 }
228
229 /**
230 * Returns if this table needs to be logged
231 *
232 * @return bool
233 */
234 public function getLog() {
235 return self::$_log;
236 }
237
238 /**
239 * Returns the list of fields that can be imported
240 *
241 * @param bool $prefix
242 *
243 * @return array
244 */
245 public static function &import($prefix = FALSE) {
246 $r = CRM_Core_DAO_AllCoreTables::getImports(__CLASS__, 'discount', $prefix, []);
247 return $r;
248 }
249
250 /**
251 * Returns the list of fields that can be exported
252 *
253 * @param bool $prefix
254 *
255 * @return array
256 */
257 public static function &export($prefix = FALSE) {
258 $r = CRM_Core_DAO_AllCoreTables::getExports(__CLASS__, 'discount', $prefix, []);
259 return $r;
260 }
261
262 /**
263 * Returns the list of indices
264 *
265 * @param bool $localize
266 *
267 * @return array
268 */
269 public static function indices($localize = TRUE) {
270 $indices = [
271 'index_entity' => [
272 'name' => 'index_entity',
273 'field' => [
274 0 => 'entity_table',
275 1 => 'entity_id',
276 ],
277 'localizable' => FALSE,
278 'sig' => 'civicrm_discount::0::entity_table::entity_id',
279 ],
280 'index_entity_option_id' => [
281 'name' => 'index_entity_option_id',
282 'field' => [
283 0 => 'entity_table',
284 1 => 'entity_id',
285 2 => 'price_set_id',
286 ],
287 'localizable' => FALSE,
288 'sig' => 'civicrm_discount::0::entity_table::entity_id::price_set_id',
289 ],
290 ];
291 return ($localize && !empty($indices)) ? CRM_Core_DAO_AllCoreTables::multilingualize(__CLASS__, $indices) : $indices;
292 }
293
294 }