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