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