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