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