Merge pull request #22558 from eileenmcnaughton/coleman
[civicrm-core.git] / CRM / Contribute / DAO / ContributionProduct.php
1 <?php
2
3 /**
4 * @package CRM
5 * @copyright CiviCRM LLC https://civicrm.org/licensing
6 *
7 * Generated from xml/schema/CRM/Contribute/ContributionProduct.xml
8 * DO NOT EDIT. Generated by CRM_Core_CodeGen
9 * (GenCodeChecksum:55d9ad3d7acb1129577589352f6010cd)
10 */
11
12 /**
13 * Database access object for the ContributionProduct entity.
14 */
15 class CRM_Contribute_DAO_ContributionProduct extends CRM_Core_DAO {
16 const EXT = 'civicrm';
17 const TABLE_ADDED = '1.4';
18 const COMPONENT = 'CiviContribute';
19
20 /**
21 * Static instance to hold the table name.
22 *
23 * @var string
24 */
25 public static $_tableName = 'civicrm_contribution_product';
26
27 /**
28 * Should CiviCRM log any modifications to this table in the civicrm_log table.
29 *
30 * @var bool
31 */
32 public static $_log = TRUE;
33
34 /**
35 * @var int|string|null
36 * (SQL type: int unsigned)
37 * Note that values will be retrieved from the database as a string.
38 */
39 public $id;
40
41 /**
42 * @var int|string
43 * (SQL type: int unsigned)
44 * Note that values will be retrieved from the database as a string.
45 */
46 public $product_id;
47
48 /**
49 * @var int|string
50 * (SQL type: int unsigned)
51 * Note that values will be retrieved from the database as a string.
52 */
53 public $contribution_id;
54
55 /**
56 * Option value selected if applicable - e.g. color, size etc.
57 *
58 * @var string|null
59 * (SQL type: varchar(255))
60 * Note that values will be retrieved from the database as a string.
61 */
62 public $product_option;
63
64 /**
65 * @var int|string|null
66 * (SQL type: int)
67 * Note that values will be retrieved from the database as a string.
68 */
69 public $quantity;
70
71 /**
72 * Optional. Can be used to record the date this product was fulfilled or shipped.
73 *
74 * @var string|null
75 * (SQL type: date)
76 * Note that values will be retrieved from the database as a string.
77 */
78 public $fulfilled_date;
79
80 /**
81 * Actual start date for a time-delimited premium (subscription, service or membership)
82 *
83 * @var string|null
84 * (SQL type: date)
85 * Note that values will be retrieved from the database as a string.
86 */
87 public $start_date;
88
89 /**
90 * Actual end date for a time-delimited premium (subscription, service or membership)
91 *
92 * @var string|null
93 * (SQL type: date)
94 * Note that values will be retrieved from the database as a string.
95 */
96 public $end_date;
97
98 /**
99 * @var string|null
100 * (SQL type: text)
101 * Note that values will be retrieved from the database as a string.
102 */
103 public $comment;
104
105 /**
106 * FK to Financial Type(for membership price sets only).
107 *
108 * @var int|string|null
109 * (SQL type: int unsigned)
110 * Note that values will be retrieved from the database as a string.
111 */
112 public $financial_type_id;
113
114 /**
115 * Class constructor.
116 */
117 public function __construct() {
118 $this->__table = 'civicrm_contribution_product';
119 parent::__construct();
120 }
121
122 /**
123 * Returns localized title of this entity.
124 *
125 * @param bool $plural
126 * Whether to return the plural version of the title.
127 */
128 public static function getEntityTitle($plural = FALSE) {
129 return $plural ? ts('Contribution Products') : ts('Contribution Product');
130 }
131
132 /**
133 * Returns foreign keys and entity references.
134 *
135 * @return array
136 * [CRM_Core_Reference_Interface]
137 */
138 public static function getReferenceColumns() {
139 if (!isset(Civi::$statics[__CLASS__]['links'])) {
140 Civi::$statics[__CLASS__]['links'] = static::createReferenceColumns(__CLASS__);
141 Civi::$statics[__CLASS__]['links'][] = new CRM_Core_Reference_Basic(self::getTableName(), 'product_id', 'civicrm_product', 'id');
142 Civi::$statics[__CLASS__]['links'][] = new CRM_Core_Reference_Basic(self::getTableName(), 'contribution_id', 'civicrm_contribution', 'id');
143 Civi::$statics[__CLASS__]['links'][] = new CRM_Core_Reference_Basic(self::getTableName(), 'financial_type_id', 'civicrm_financial_type', 'id');
144 CRM_Core_DAO_AllCoreTables::invoke(__CLASS__, 'links_callback', Civi::$statics[__CLASS__]['links']);
145 }
146 return Civi::$statics[__CLASS__]['links'];
147 }
148
149 /**
150 * Returns all the column names of this table
151 *
152 * @return array
153 */
154 public static function &fields() {
155 if (!isset(Civi::$statics[__CLASS__]['fields'])) {
156 Civi::$statics[__CLASS__]['fields'] = [
157 'id' => [
158 'name' => 'id',
159 'type' => CRM_Utils_Type::T_INT,
160 'title' => ts('Contribution Product ID'),
161 'required' => TRUE,
162 'where' => 'civicrm_contribution_product.id',
163 'table_name' => 'civicrm_contribution_product',
164 'entity' => 'ContributionProduct',
165 'bao' => 'CRM_Contribute_DAO_ContributionProduct',
166 'localizable' => 0,
167 'html' => [
168 'type' => 'Number',
169 ],
170 'readonly' => TRUE,
171 'add' => '1.4',
172 ],
173 'product_id' => [
174 'name' => 'product_id',
175 'type' => CRM_Utils_Type::T_INT,
176 'title' => ts('Product ID'),
177 'required' => TRUE,
178 'where' => 'civicrm_contribution_product.product_id',
179 'table_name' => 'civicrm_contribution_product',
180 'entity' => 'ContributionProduct',
181 'bao' => 'CRM_Contribute_DAO_ContributionProduct',
182 'localizable' => 0,
183 'FKClassName' => 'CRM_Contribute_DAO_Product',
184 'add' => '1.4',
185 ],
186 'contribution_id' => [
187 'name' => 'contribution_id',
188 'type' => CRM_Utils_Type::T_INT,
189 'title' => ts('Contribution ID'),
190 'required' => TRUE,
191 'where' => 'civicrm_contribution_product.contribution_id',
192 'table_name' => 'civicrm_contribution_product',
193 'entity' => 'ContributionProduct',
194 'bao' => 'CRM_Contribute_DAO_ContributionProduct',
195 'localizable' => 0,
196 'FKClassName' => 'CRM_Contribute_DAO_Contribution',
197 'html' => [
198 'label' => ts("Contribution"),
199 ],
200 'add' => '1.4',
201 ],
202 'product_option' => [
203 'name' => 'product_option',
204 'type' => CRM_Utils_Type::T_STRING,
205 'title' => ts('Product Option'),
206 'description' => ts('Option value selected if applicable - e.g. color, size etc.'),
207 'maxlength' => 255,
208 'size' => CRM_Utils_Type::HUGE,
209 'where' => 'civicrm_contribution_product.product_option',
210 'export' => TRUE,
211 'table_name' => 'civicrm_contribution_product',
212 'entity' => 'ContributionProduct',
213 'bao' => 'CRM_Contribute_DAO_ContributionProduct',
214 'localizable' => 0,
215 'add' => '1.4',
216 ],
217 'quantity' => [
218 'name' => 'quantity',
219 'type' => CRM_Utils_Type::T_INT,
220 'title' => ts('Quantity'),
221 'where' => 'civicrm_contribution_product.quantity',
222 'export' => TRUE,
223 'table_name' => 'civicrm_contribution_product',
224 'entity' => 'ContributionProduct',
225 'bao' => 'CRM_Contribute_DAO_ContributionProduct',
226 'localizable' => 0,
227 'add' => '1.4',
228 ],
229 'fulfilled_date' => [
230 'name' => 'fulfilled_date',
231 'type' => CRM_Utils_Type::T_DATE,
232 'title' => ts('Fulfilled Date'),
233 'description' => ts('Optional. Can be used to record the date this product was fulfilled or shipped.'),
234 'where' => 'civicrm_contribution_product.fulfilled_date',
235 'export' => TRUE,
236 'table_name' => 'civicrm_contribution_product',
237 'entity' => 'ContributionProduct',
238 'bao' => 'CRM_Contribute_DAO_ContributionProduct',
239 'localizable' => 0,
240 'html' => [
241 'type' => 'Select Date',
242 'formatType' => 'activityDate',
243 ],
244 'add' => '1.4',
245 ],
246 'contribution_start_date' => [
247 'name' => 'start_date',
248 'type' => CRM_Utils_Type::T_DATE,
249 'title' => ts('Start date for premium'),
250 'description' => ts('Actual start date for a time-delimited premium (subscription, service or membership)'),
251 'where' => 'civicrm_contribution_product.start_date',
252 'export' => TRUE,
253 'table_name' => 'civicrm_contribution_product',
254 'entity' => 'ContributionProduct',
255 'bao' => 'CRM_Contribute_DAO_ContributionProduct',
256 'localizable' => 0,
257 'add' => '1.4',
258 ],
259 'contribution_end_date' => [
260 'name' => 'end_date',
261 'type' => CRM_Utils_Type::T_DATE,
262 'title' => ts('End date for premium'),
263 'description' => ts('Actual end date for a time-delimited premium (subscription, service or membership)'),
264 'where' => 'civicrm_contribution_product.end_date',
265 'export' => TRUE,
266 'table_name' => 'civicrm_contribution_product',
267 'entity' => 'ContributionProduct',
268 'bao' => 'CRM_Contribute_DAO_ContributionProduct',
269 'localizable' => 0,
270 'add' => '1.4',
271 ],
272 'comment' => [
273 'name' => 'comment',
274 'type' => CRM_Utils_Type::T_TEXT,
275 'title' => ts('Premium comment'),
276 'where' => 'civicrm_contribution_product.comment',
277 'table_name' => 'civicrm_contribution_product',
278 'entity' => 'ContributionProduct',
279 'bao' => 'CRM_Contribute_DAO_ContributionProduct',
280 'localizable' => 0,
281 'add' => '1.4',
282 ],
283 'financial_type_id' => [
284 'name' => 'financial_type_id',
285 'type' => CRM_Utils_Type::T_INT,
286 'title' => ts('Financial Type ID'),
287 'description' => ts('FK to Financial Type(for membership price sets only).'),
288 'where' => 'civicrm_contribution_product.financial_type_id',
289 'default' => NULL,
290 'table_name' => 'civicrm_contribution_product',
291 'entity' => 'ContributionProduct',
292 'bao' => 'CRM_Contribute_DAO_ContributionProduct',
293 'localizable' => 0,
294 'FKClassName' => 'CRM_Financial_DAO_FinancialType',
295 'html' => [
296 'label' => ts("Financial Type"),
297 ],
298 'pseudoconstant' => [
299 'table' => 'civicrm_financial_type',
300 'keyColumn' => 'id',
301 'labelColumn' => 'name',
302 ],
303 'add' => '4.3',
304 ],
305 ];
306 CRM_Core_DAO_AllCoreTables::invoke(__CLASS__, 'fields_callback', Civi::$statics[__CLASS__]['fields']);
307 }
308 return Civi::$statics[__CLASS__]['fields'];
309 }
310
311 /**
312 * Return a mapping from field-name to the corresponding key (as used in fields()).
313 *
314 * @return array
315 * Array(string $name => string $uniqueName).
316 */
317 public static function &fieldKeys() {
318 if (!isset(Civi::$statics[__CLASS__]['fieldKeys'])) {
319 Civi::$statics[__CLASS__]['fieldKeys'] = array_flip(CRM_Utils_Array::collect('name', self::fields()));
320 }
321 return Civi::$statics[__CLASS__]['fieldKeys'];
322 }
323
324 /**
325 * Returns the names of this table
326 *
327 * @return string
328 */
329 public static function getTableName() {
330 return self::$_tableName;
331 }
332
333 /**
334 * Returns if this table needs to be logged
335 *
336 * @return bool
337 */
338 public function getLog() {
339 return self::$_log;
340 }
341
342 /**
343 * Returns the list of fields that can be imported
344 *
345 * @param bool $prefix
346 *
347 * @return array
348 */
349 public static function &import($prefix = FALSE) {
350 $r = CRM_Core_DAO_AllCoreTables::getImports(__CLASS__, 'contribution_product', $prefix, []);
351 return $r;
352 }
353
354 /**
355 * Returns the list of fields that can be exported
356 *
357 * @param bool $prefix
358 *
359 * @return array
360 */
361 public static function &export($prefix = FALSE) {
362 $r = CRM_Core_DAO_AllCoreTables::getExports(__CLASS__, 'contribution_product', $prefix, []);
363 return $r;
364 }
365
366 /**
367 * Returns the list of indices
368 *
369 * @param bool $localize
370 *
371 * @return array
372 */
373 public static function indices($localize = TRUE) {
374 $indices = [];
375 return ($localize && !empty($indices)) ? CRM_Core_DAO_AllCoreTables::multilingualize(__CLASS__, $indices) : $indices;
376 }
377
378 }