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