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