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