Merge pull request #16610 from mattwire/settingstrait_datepicker
[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:ebb8b8950e36872fffdc5ffcf1fc426f)
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 ],
141 'product_id' => [
142 'name' => 'product_id',
143 'type' => CRM_Utils_Type::T_INT,
144 'title' => ts('Product ID'),
145 'required' => TRUE,
146 'where' => 'civicrm_contribution_product.product_id',
147 'table_name' => 'civicrm_contribution_product',
148 'entity' => 'ContributionProduct',
149 'bao' => 'CRM_Contribute_DAO_ContributionProduct',
150 'localizable' => 0,
151 ],
152 'contribution_id' => [
153 'name' => 'contribution_id',
154 'type' => CRM_Utils_Type::T_INT,
155 'title' => ts('Contribution ID'),
156 'required' => TRUE,
157 'where' => 'civicrm_contribution_product.contribution_id',
158 'table_name' => 'civicrm_contribution_product',
159 'entity' => 'ContributionProduct',
160 'bao' => 'CRM_Contribute_DAO_ContributionProduct',
161 'localizable' => 0,
162 'FKClassName' => 'CRM_Contribute_DAO_Contribution',
163 ],
164 'product_option' => [
165 'name' => 'product_option',
166 'type' => CRM_Utils_Type::T_STRING,
167 'title' => ts('Product Option'),
168 'description' => ts('Option value selected if applicable - e.g. color, size etc.'),
169 'maxlength' => 255,
170 'size' => CRM_Utils_Type::HUGE,
171 'where' => 'civicrm_contribution_product.product_option',
172 'export' => TRUE,
173 'table_name' => 'civicrm_contribution_product',
174 'entity' => 'ContributionProduct',
175 'bao' => 'CRM_Contribute_DAO_ContributionProduct',
176 'localizable' => 0,
177 ],
178 'quantity' => [
179 'name' => 'quantity',
180 'type' => CRM_Utils_Type::T_INT,
181 'title' => ts('Quantity'),
182 'where' => 'civicrm_contribution_product.quantity',
183 'export' => TRUE,
184 'table_name' => 'civicrm_contribution_product',
185 'entity' => 'ContributionProduct',
186 'bao' => 'CRM_Contribute_DAO_ContributionProduct',
187 'localizable' => 0,
188 ],
189 'fulfilled_date' => [
190 'name' => 'fulfilled_date',
191 'type' => CRM_Utils_Type::T_DATE,
192 'title' => ts('Fulfilled Date'),
193 'description' => ts('Optional. Can be used to record the date this product was fulfilled or shipped.'),
194 'where' => 'civicrm_contribution_product.fulfilled_date',
195 'export' => TRUE,
196 'table_name' => 'civicrm_contribution_product',
197 'entity' => 'ContributionProduct',
198 'bao' => 'CRM_Contribute_DAO_ContributionProduct',
199 'localizable' => 0,
200 'html' => [
201 'type' => 'Select Date',
202 'formatType' => 'activityDate',
203 ],
204 ],
205 'contribution_start_date' => [
206 'name' => 'start_date',
207 'type' => CRM_Utils_Type::T_DATE,
208 'title' => ts('Start date for premium'),
209 'description' => ts('Actual start date for a time-delimited premium (subscription, service or membership)'),
210 'where' => 'civicrm_contribution_product.start_date',
211 'export' => TRUE,
212 'table_name' => 'civicrm_contribution_product',
213 'entity' => 'ContributionProduct',
214 'bao' => 'CRM_Contribute_DAO_ContributionProduct',
215 'localizable' => 0,
216 ],
217 'contribution_end_date' => [
218 'name' => 'end_date',
219 'type' => CRM_Utils_Type::T_DATE,
220 'title' => ts('End date for premium'),
221 'description' => ts('Actual end date for a time-delimited premium (subscription, service or membership)'),
222 'where' => 'civicrm_contribution_product.end_date',
223 'export' => TRUE,
224 'table_name' => 'civicrm_contribution_product',
225 'entity' => 'ContributionProduct',
226 'bao' => 'CRM_Contribute_DAO_ContributionProduct',
227 'localizable' => 0,
228 ],
229 'comment' => [
230 'name' => 'comment',
231 'type' => CRM_Utils_Type::T_TEXT,
232 'title' => ts('Premium comment'),
233 'where' => 'civicrm_contribution_product.comment',
234 'table_name' => 'civicrm_contribution_product',
235 'entity' => 'ContributionProduct',
236 'bao' => 'CRM_Contribute_DAO_ContributionProduct',
237 'localizable' => 0,
238 ],
239 'financial_type_id' => [
240 'name' => 'financial_type_id',
241 'type' => CRM_Utils_Type::T_INT,
242 'title' => ts('Financial Type'),
243 'description' => ts('FK to Financial Type(for membership price sets only).'),
244 'where' => 'civicrm_contribution_product.financial_type_id',
245 'default' => 'NULL',
246 'table_name' => 'civicrm_contribution_product',
247 'entity' => 'ContributionProduct',
248 'bao' => 'CRM_Contribute_DAO_ContributionProduct',
249 'localizable' => 0,
250 'FKClassName' => 'CRM_Financial_DAO_FinancialType',
251 'pseudoconstant' => [
252 'table' => 'civicrm_financial_type',
253 'keyColumn' => 'id',
254 'labelColumn' => 'name',
255 ],
256 ],
257 ];
258 CRM_Core_DAO_AllCoreTables::invoke(__CLASS__, 'fields_callback', Civi::$statics[__CLASS__]['fields']);
259 }
260 return Civi::$statics[__CLASS__]['fields'];
261 }
262
263 /**
264 * Return a mapping from field-name to the corresponding key (as used in fields()).
265 *
266 * @return array
267 * Array(string $name => string $uniqueName).
268 */
269 public static function &fieldKeys() {
270 if (!isset(Civi::$statics[__CLASS__]['fieldKeys'])) {
271 Civi::$statics[__CLASS__]['fieldKeys'] = array_flip(CRM_Utils_Array::collect('name', self::fields()));
272 }
273 return Civi::$statics[__CLASS__]['fieldKeys'];
274 }
275
276 /**
277 * Returns the names of this table
278 *
279 * @return string
280 */
281 public static function getTableName() {
282 return self::$_tableName;
283 }
284
285 /**
286 * Returns if this table needs to be logged
287 *
288 * @return bool
289 */
290 public function getLog() {
291 return self::$_log;
292 }
293
294 /**
295 * Returns the list of fields that can be imported
296 *
297 * @param bool $prefix
298 *
299 * @return array
300 */
301 public static function &import($prefix = FALSE) {
302 $r = CRM_Core_DAO_AllCoreTables::getImports(__CLASS__, 'contribution_product', $prefix, []);
303 return $r;
304 }
305
306 /**
307 * Returns the list of fields that can be exported
308 *
309 * @param bool $prefix
310 *
311 * @return array
312 */
313 public static function &export($prefix = FALSE) {
314 $r = CRM_Core_DAO_AllCoreTables::getExports(__CLASS__, 'contribution_product', $prefix, []);
315 return $r;
316 }
317
318 /**
319 * Returns the list of indices
320 *
321 * @param bool $localize
322 *
323 * @return array
324 */
325 public static function indices($localize = TRUE) {
326 $indices = [];
327 return ($localize && !empty($indices)) ? CRM_Core_DAO_AllCoreTables::multilingualize(__CLASS__, $indices) : $indices;
328 }
329
330 }