Commit | Line | Data |
---|---|---|
e501603b TO |
1 | <?php |
2 | /* | |
3 | +--------------------------------------------------------------------+ | |
4 | | CiviCRM version 4.7 | | |
5 | +--------------------------------------------------------------------+ | |
0f03f337 | 6 | | Copyright CiviCRM LLC (c) 2004-2017 | |
e501603b TO |
7 | +--------------------------------------------------------------------+ |
8 | | This file is a part of CiviCRM. | | |
9 | | | | |
10 | | CiviCRM is free software; you can copy, modify, and distribute it | | |
11 | | under the terms of the GNU Affero General Public License | | |
12 | | Version 3, 19 November 2007 and the CiviCRM Licensing Exception. | | |
13 | | | | |
14 | | CiviCRM is distributed in the hope that it will be useful, but | | |
15 | | WITHOUT ANY WARRANTY; without even the implied warranty of | | |
16 | | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. | | |
17 | | See the GNU Affero General Public License for more details. | | |
18 | | | | |
19 | | You should have received a copy of the GNU Affero General Public | | |
20 | | License and the CiviCRM Licensing Exception along | | |
21 | | with this program; if not, contact CiviCRM LLC | | |
22 | | at info[AT]civicrm[DOT]org. If you have questions about the | | |
23 | | GNU Affero General Public License or the licensing of CiviCRM, | | |
24 | | see the CiviCRM license FAQ at http://civicrm.org/licensing | | |
25 | +--------------------------------------------------------------------+ | |
26 | */ | |
27 | /** | |
28 | * @package CRM | |
0f03f337 | 29 | * @copyright CiviCRM LLC (c) 2004-2017 |
e501603b TO |
30 | * |
31 | * Generated from xml/schema/CRM/Contribute/Contribution.xml | |
32 | * DO NOT EDIT. Generated by CRM_Core_CodeGen | |
e7a6b91a | 33 | * (GenCodeChecksum:59c3615cae90b0580f7d77aa8343b21f) |
e501603b TO |
34 | */ |
35 | require_once 'CRM/Core/DAO.php'; | |
36 | require_once 'CRM/Utils/Type.php'; | |
f41f0342 | 37 | /** |
38 | * CRM_Contribute_DAO_Contribution constructor. | |
39 | */ | |
e501603b TO |
40 | class CRM_Contribute_DAO_Contribution extends CRM_Core_DAO { |
41 | /** | |
f41f0342 | 42 | * Static instance to hold the table name. |
e501603b TO |
43 | * |
44 | * @var string | |
45 | */ | |
46 | static $_tableName = 'civicrm_contribution'; | |
e501603b | 47 | /** |
f41f0342 | 48 | * Should CiviCRM log any modifications to this table in the civicrm_log table. |
e501603b TO |
49 | * |
50 | * @var boolean | |
51 | */ | |
52 | static $_log = true; | |
53 | /** | |
54 | * Contribution ID | |
55 | * | |
56 | * @var int unsigned | |
57 | */ | |
58 | public $id; | |
59 | /** | |
60 | * FK to Contact ID | |
61 | * | |
62 | * @var int unsigned | |
63 | */ | |
64 | public $contact_id; | |
65 | /** | |
66 | * FK to Financial Type for (total_amount - non_deductible_amount). | |
67 | * | |
68 | * @var int unsigned | |
69 | */ | |
70 | public $financial_type_id; | |
71 | /** | |
72 | * The Contribution Page which triggered this contribution | |
73 | * | |
74 | * @var int unsigned | |
75 | */ | |
76 | public $contribution_page_id; | |
77 | /** | |
78 | * FK to Payment Instrument | |
79 | * | |
80 | * @var int unsigned | |
81 | */ | |
82 | public $payment_instrument_id; | |
83 | /** | |
84 | * Date contribution was received - not necessarily the creation date of the record | |
85 | * | |
86 | * @var datetime | |
87 | */ | |
88 | public $receive_date; | |
89 | /** | |
90 | * Portion of total amount which is NOT tax deductible. Equal to total_amount for non-deductible financial types. | |
91 | * | |
92 | * @var float | |
93 | */ | |
94 | public $non_deductible_amount; | |
95 | /** | |
96 | * Total amount of this contribution. Use market value for non-monetary gifts. | |
97 | * | |
98 | * @var float | |
99 | */ | |
100 | public $total_amount; | |
101 | /** | |
102 | * actual processor fee if known - may be 0. | |
103 | * | |
104 | * @var float | |
105 | */ | |
106 | public $fee_amount; | |
107 | /** | |
108 | * actual funds transfer amount. total less fees. if processor does not report actual fee during transaction, this is set to total_amount. | |
109 | * | |
110 | * @var float | |
111 | */ | |
112 | public $net_amount; | |
113 | /** | |
114 | * unique transaction id. may be processor id, bank id + trans id, or account number + check number... depending on payment_method | |
115 | * | |
116 | * @var string | |
117 | */ | |
118 | public $trxn_id; | |
119 | /** | |
120 | * unique invoice id, system generated or passed in | |
121 | * | |
122 | * @var string | |
123 | */ | |
124 | public $invoice_id; | |
125 | /** | |
126 | * 3 character string, value from config setting or input via user. | |
127 | * | |
128 | * @var string | |
129 | */ | |
130 | public $currency; | |
131 | /** | |
132 | * when was gift cancelled | |
133 | * | |
134 | * @var datetime | |
135 | */ | |
136 | public $cancel_date; | |
137 | /** | |
138 | * | |
139 | * @var text | |
140 | */ | |
141 | public $cancel_reason; | |
142 | /** | |
143 | * when (if) receipt was sent. populated automatically for online donations w/ automatic receipting | |
144 | * | |
145 | * @var datetime | |
146 | */ | |
147 | public $receipt_date; | |
148 | /** | |
149 | * when (if) was donor thanked | |
150 | * | |
151 | * @var datetime | |
152 | */ | |
153 | public $thankyou_date; | |
154 | /** | |
155 | * Origin of this Contribution. | |
156 | * | |
157 | * @var string | |
158 | */ | |
159 | public $source; | |
160 | /** | |
161 | * | |
162 | * @var text | |
163 | */ | |
164 | public $amount_level; | |
165 | /** | |
166 | * Conditional foreign key to civicrm_contribution_recur id. Each contribution made in connection with a recurring contribution carries a foreign key to the recurring contribution record. This assumes we can track these processor initiated events. | |
167 | * | |
168 | * @var int unsigned | |
169 | */ | |
170 | public $contribution_recur_id; | |
171 | /** | |
172 | * | |
173 | * @var boolean | |
174 | */ | |
175 | public $is_test; | |
176 | /** | |
177 | * | |
178 | * @var boolean | |
179 | */ | |
180 | public $is_pay_later; | |
181 | /** | |
182 | * | |
183 | * @var int unsigned | |
184 | */ | |
185 | public $contribution_status_id; | |
186 | /** | |
187 | * Conditional foreign key to civicrm_address.id. We insert an address record for each contribution when we have associated billing name and address data. | |
188 | * | |
189 | * @var int unsigned | |
190 | */ | |
191 | public $address_id; | |
192 | /** | |
193 | * | |
194 | * @var string | |
195 | */ | |
196 | public $check_number; | |
197 | /** | |
198 | * The campaign for which this contribution has been triggered. | |
199 | * | |
200 | * @var int unsigned | |
201 | */ | |
202 | public $campaign_id; | |
203 | /** | |
204 | * unique credit note id, system generated or passed in | |
205 | * | |
206 | * @var string | |
207 | */ | |
208 | public $creditnote_id; | |
209 | /** | |
210 | * Total tax amount of this contribution. | |
211 | * | |
212 | * @var float | |
213 | */ | |
214 | public $tax_amount; | |
215 | /** | |
216 | * Stores the date when revenue should be recognized. | |
217 | * | |
218 | * @var datetime | |
219 | */ | |
220 | public $revenue_recognition_date; | |
221 | /** | |
f41f0342 | 222 | * Class constructor. |
e501603b TO |
223 | */ |
224 | function __construct() { | |
225 | $this->__table = 'civicrm_contribution'; | |
226 | parent::__construct(); | |
227 | } | |
228 | /** | |
f41f0342 | 229 | * Returns foreign keys and entity references. |
e501603b TO |
230 | * |
231 | * @return array | |
232 | * [CRM_Core_Reference_Interface] | |
233 | */ | |
234 | static function getReferenceColumns() { | |
346aaaba TO |
235 | if (!isset(Civi::$statics[__CLASS__]['links'])) { |
236 | Civi::$statics[__CLASS__]['links'] = static ::createReferenceColumns(__CLASS__); | |
237 | Civi::$statics[__CLASS__]['links'][] = new CRM_Core_Reference_Basic(self::getTableName() , 'contact_id', 'civicrm_contact', 'id'); | |
238 | Civi::$statics[__CLASS__]['links'][] = new CRM_Core_Reference_Basic(self::getTableName() , 'financial_type_id', 'civicrm_financial_type', 'id'); | |
239 | Civi::$statics[__CLASS__]['links'][] = new CRM_Core_Reference_Basic(self::getTableName() , 'contribution_page_id', 'civicrm_contribution_page', 'id'); | |
240 | Civi::$statics[__CLASS__]['links'][] = new CRM_Core_Reference_Basic(self::getTableName() , 'contribution_recur_id', 'civicrm_contribution_recur', 'id'); | |
241 | Civi::$statics[__CLASS__]['links'][] = new CRM_Core_Reference_Basic(self::getTableName() , 'address_id', 'civicrm_address', 'id'); | |
242 | Civi::$statics[__CLASS__]['links'][] = new CRM_Core_Reference_Basic(self::getTableName() , 'campaign_id', 'civicrm_campaign', 'id'); | |
243 | CRM_Core_DAO_AllCoreTables::invoke(__CLASS__, 'links_callback', Civi::$statics[__CLASS__]['links']); | |
e501603b | 244 | } |
346aaaba | 245 | return Civi::$statics[__CLASS__]['links']; |
e501603b TO |
246 | } |
247 | /** | |
248 | * Returns all the column names of this table | |
249 | * | |
250 | * @return array | |
251 | */ | |
252 | static function &fields() { | |
346aaaba TO |
253 | if (!isset(Civi::$statics[__CLASS__]['fields'])) { |
254 | Civi::$statics[__CLASS__]['fields'] = array( | |
e501603b TO |
255 | 'contribution_id' => array( |
256 | 'name' => 'id', | |
257 | 'type' => CRM_Utils_Type::T_INT, | |
258 | 'title' => ts('Contribution ID') , | |
259 | 'description' => 'Contribution ID', | |
260 | 'required' => true, | |
261 | 'import' => true, | |
262 | 'where' => 'civicrm_contribution.id', | |
263 | 'headerPattern' => '', | |
264 | 'dataPattern' => '', | |
265 | 'export' => true, | |
522a26c9 | 266 | 'table_name' => 'civicrm_contribution', |
267 | 'entity' => 'Contribution', | |
268 | 'bao' => 'CRM_Contribute_BAO_Contribution', | |
6a7e5e5d | 269 | 'localizable' => 0, |
e501603b TO |
270 | ) , |
271 | 'contribution_contact_id' => array( | |
272 | 'name' => 'contact_id', | |
273 | 'type' => CRM_Utils_Type::T_INT, | |
274 | 'title' => ts('Contact ID') , | |
275 | 'description' => 'FK to Contact ID', | |
276 | 'required' => true, | |
277 | 'import' => true, | |
278 | 'where' => 'civicrm_contribution.contact_id', | |
279 | 'headerPattern' => '/contact(.?id)?/i', | |
280 | 'dataPattern' => '/^\d+$/', | |
281 | 'export' => true, | |
522a26c9 | 282 | 'table_name' => 'civicrm_contribution', |
283 | 'entity' => 'Contribution', | |
284 | 'bao' => 'CRM_Contribute_BAO_Contribution', | |
6a7e5e5d | 285 | 'localizable' => 0, |
e501603b TO |
286 | 'FKClassName' => 'CRM_Contact_DAO_Contact', |
287 | 'html' => array( | |
288 | 'type' => 'EntityRef', | |
289 | ) , | |
290 | ) , | |
291 | 'financial_type_id' => array( | |
292 | 'name' => 'financial_type_id', | |
293 | 'type' => CRM_Utils_Type::T_INT, | |
294 | 'title' => ts('Financial Type') , | |
295 | 'description' => 'FK to Financial Type for (total_amount - non_deductible_amount).', | |
3123273f | 296 | 'export' => true, |
e501603b TO |
297 | 'where' => 'civicrm_contribution.financial_type_id', |
298 | 'headerPattern' => '', | |
299 | 'dataPattern' => '', | |
522a26c9 | 300 | 'table_name' => 'civicrm_contribution', |
301 | 'entity' => 'Contribution', | |
302 | 'bao' => 'CRM_Contribute_BAO_Contribution', | |
6a7e5e5d | 303 | 'localizable' => 0, |
e501603b TO |
304 | 'FKClassName' => 'CRM_Financial_DAO_FinancialType', |
305 | 'html' => array( | |
306 | 'type' => 'Select', | |
307 | ) , | |
308 | 'pseudoconstant' => array( | |
309 | 'table' => 'civicrm_financial_type', | |
310 | 'keyColumn' => 'id', | |
311 | 'labelColumn' => 'name', | |
312 | ) | |
313 | ) , | |
314 | 'contribution_page_id' => array( | |
315 | 'name' => 'contribution_page_id', | |
316 | 'type' => CRM_Utils_Type::T_INT, | |
317 | 'title' => ts('Contribution Page ID') , | |
318 | 'description' => 'The Contribution Page which triggered this contribution', | |
319 | 'import' => true, | |
320 | 'where' => 'civicrm_contribution.contribution_page_id', | |
321 | 'headerPattern' => '', | |
322 | 'dataPattern' => '', | |
323 | 'export' => true, | |
522a26c9 | 324 | 'table_name' => 'civicrm_contribution', |
325 | 'entity' => 'Contribution', | |
326 | 'bao' => 'CRM_Contribute_BAO_Contribution', | |
6a7e5e5d | 327 | 'localizable' => 0, |
e501603b TO |
328 | 'FKClassName' => 'CRM_Contribute_DAO_ContributionPage', |
329 | 'html' => array( | |
330 | 'type' => 'Select', | |
331 | ) , | |
332 | 'pseudoconstant' => array( | |
333 | 'table' => 'civicrm_contribution_page', | |
334 | 'keyColumn' => 'id', | |
335 | 'labelColumn' => 'title', | |
336 | ) | |
337 | ) , | |
338 | 'payment_instrument_id' => array( | |
339 | 'name' => 'payment_instrument_id', | |
340 | 'type' => CRM_Utils_Type::T_INT, | |
9d5c7f14 | 341 | 'title' => ts('Payment Method ID') , |
e501603b | 342 | 'description' => 'FK to Payment Instrument', |
9d5c7f14 | 343 | 'export' => true, |
344 | 'where' => 'civicrm_contribution.payment_instrument_id', | |
345 | 'headerPattern' => '/^payment|(p(ayment\s)?instrument)$/i', | |
346 | 'dataPattern' => '', | |
522a26c9 | 347 | 'table_name' => 'civicrm_contribution', |
348 | 'entity' => 'Contribution', | |
349 | 'bao' => 'CRM_Contribute_BAO_Contribution', | |
6a7e5e5d | 350 | 'localizable' => 0, |
e501603b TO |
351 | 'html' => array( |
352 | 'type' => 'Select', | |
353 | ) , | |
354 | 'pseudoconstant' => array( | |
355 | 'optionGroupName' => 'payment_instrument', | |
356 | 'optionEditPath' => 'civicrm/admin/options/payment_instrument', | |
357 | ) | |
358 | ) , | |
359 | 'receive_date' => array( | |
360 | 'name' => 'receive_date', | |
361 | 'type' => CRM_Utils_Type::T_DATE + CRM_Utils_Type::T_TIME, | |
362 | 'title' => ts('Date Received') , | |
363 | 'description' => 'Date contribution was received - not necessarily the creation date of the record', | |
364 | 'import' => true, | |
365 | 'where' => 'civicrm_contribution.receive_date', | |
366 | 'headerPattern' => '/receive(.?date)?/i', | |
367 | 'dataPattern' => '/^\d{4}-?\d{2}-?\d{2} ?(\d{2}:?\d{2}:?(\d{2})?)?$/', | |
368 | 'export' => true, | |
522a26c9 | 369 | 'table_name' => 'civicrm_contribution', |
370 | 'entity' => 'Contribution', | |
371 | 'bao' => 'CRM_Contribute_BAO_Contribution', | |
6a7e5e5d | 372 | 'localizable' => 0, |
e501603b TO |
373 | 'html' => array( |
374 | 'type' => 'Select Date', | |
24317d89 | 375 | 'formatType' => 'activityDateTime', |
e501603b TO |
376 | ) , |
377 | ) , | |
378 | 'non_deductible_amount' => array( | |
379 | 'name' => 'non_deductible_amount', | |
380 | 'type' => CRM_Utils_Type::T_MONEY, | |
381 | 'title' => ts('Non-deductible Amount') , | |
382 | 'description' => 'Portion of total amount which is NOT tax deductible. Equal to total_amount for non-deductible financial types.', | |
383 | 'precision' => array( | |
384 | 20, | |
385 | 2 | |
386 | ) , | |
387 | 'import' => true, | |
388 | 'where' => 'civicrm_contribution.non_deductible_amount', | |
389 | 'headerPattern' => '/non?.?deduct/i', | |
390 | 'dataPattern' => '/^\d+(\.\d{2})?$/', | |
391 | 'export' => true, | |
522a26c9 | 392 | 'table_name' => 'civicrm_contribution', |
393 | 'entity' => 'Contribution', | |
394 | 'bao' => 'CRM_Contribute_BAO_Contribution', | |
6a7e5e5d | 395 | 'localizable' => 0, |
e501603b TO |
396 | 'html' => array( |
397 | 'type' => 'Text', | |
398 | ) , | |
399 | ) , | |
400 | 'total_amount' => array( | |
401 | 'name' => 'total_amount', | |
402 | 'type' => CRM_Utils_Type::T_MONEY, | |
403 | 'title' => ts('Total Amount') , | |
404 | 'description' => 'Total amount of this contribution. Use market value for non-monetary gifts.', | |
405 | 'required' => true, | |
406 | 'precision' => array( | |
407 | 20, | |
408 | 2 | |
409 | ) , | |
410 | 'import' => true, | |
411 | 'where' => 'civicrm_contribution.total_amount', | |
412 | 'headerPattern' => '/^total|(.?^am(ou)?nt)/i', | |
413 | 'dataPattern' => '/^\d+(\.\d{2})?$/', | |
414 | 'export' => true, | |
522a26c9 | 415 | 'table_name' => 'civicrm_contribution', |
416 | 'entity' => 'Contribution', | |
417 | 'bao' => 'CRM_Contribute_BAO_Contribution', | |
6a7e5e5d | 418 | 'localizable' => 0, |
e501603b TO |
419 | 'html' => array( |
420 | 'type' => 'Text', | |
421 | ) , | |
422 | ) , | |
423 | 'fee_amount' => array( | |
424 | 'name' => 'fee_amount', | |
425 | 'type' => CRM_Utils_Type::T_MONEY, | |
426 | 'title' => ts('Fee Amount') , | |
427 | 'description' => 'actual processor fee if known - may be 0.', | |
428 | 'precision' => array( | |
429 | 20, | |
430 | 2 | |
431 | ) , | |
432 | 'import' => true, | |
433 | 'where' => 'civicrm_contribution.fee_amount', | |
434 | 'headerPattern' => '/fee(.?am(ou)?nt)?/i', | |
435 | 'dataPattern' => '/^\d+(\.\d{2})?$/', | |
436 | 'export' => true, | |
522a26c9 | 437 | 'table_name' => 'civicrm_contribution', |
438 | 'entity' => 'Contribution', | |
439 | 'bao' => 'CRM_Contribute_BAO_Contribution', | |
6a7e5e5d | 440 | 'localizable' => 0, |
e501603b TO |
441 | 'html' => array( |
442 | 'type' => 'Text', | |
443 | ) , | |
444 | ) , | |
445 | 'net_amount' => array( | |
446 | 'name' => 'net_amount', | |
447 | 'type' => CRM_Utils_Type::T_MONEY, | |
448 | 'title' => ts('Net Amount') , | |
449 | 'description' => 'actual funds transfer amount. total less fees. if processor does not report actual fee during transaction, this is set to total_amount.', | |
450 | 'precision' => array( | |
451 | 20, | |
452 | 2 | |
453 | ) , | |
454 | 'import' => true, | |
455 | 'where' => 'civicrm_contribution.net_amount', | |
456 | 'headerPattern' => '/net(.?am(ou)?nt)?/i', | |
457 | 'dataPattern' => '/^\d+(\.\d{2})?$/', | |
458 | 'export' => true, | |
522a26c9 | 459 | 'table_name' => 'civicrm_contribution', |
460 | 'entity' => 'Contribution', | |
461 | 'bao' => 'CRM_Contribute_BAO_Contribution', | |
6a7e5e5d | 462 | 'localizable' => 0, |
e501603b TO |
463 | 'html' => array( |
464 | 'type' => 'Text', | |
465 | ) , | |
466 | ) , | |
467 | 'trxn_id' => array( | |
468 | 'name' => 'trxn_id', | |
469 | 'type' => CRM_Utils_Type::T_STRING, | |
470 | 'title' => ts('Transaction ID') , | |
471 | 'description' => 'unique transaction id. may be processor id, bank id + trans id, or account number + check number... depending on payment_method', | |
472 | 'maxlength' => 255, | |
473 | 'size' => CRM_Utils_Type::HUGE, | |
474 | 'import' => true, | |
475 | 'where' => 'civicrm_contribution.trxn_id', | |
476 | 'headerPattern' => '/tr(ansactio|x)n(.?id)?/i', | |
477 | 'dataPattern' => '', | |
478 | 'export' => true, | |
522a26c9 | 479 | 'table_name' => 'civicrm_contribution', |
480 | 'entity' => 'Contribution', | |
481 | 'bao' => 'CRM_Contribute_BAO_Contribution', | |
6a7e5e5d | 482 | 'localizable' => 0, |
e501603b TO |
483 | 'html' => array( |
484 | 'type' => 'Text', | |
485 | ) , | |
486 | ) , | |
487 | 'invoice_id' => array( | |
488 | 'name' => 'invoice_id', | |
489 | 'type' => CRM_Utils_Type::T_STRING, | |
490 | 'title' => ts('Invoice ID') , | |
491 | 'description' => 'unique invoice id, system generated or passed in', | |
492 | 'maxlength' => 255, | |
493 | 'size' => CRM_Utils_Type::HUGE, | |
494 | 'import' => true, | |
495 | 'where' => 'civicrm_contribution.invoice_id', | |
496 | 'headerPattern' => '/invoice(.?id)?/i', | |
497 | 'dataPattern' => '', | |
498 | 'export' => true, | |
522a26c9 | 499 | 'table_name' => 'civicrm_contribution', |
500 | 'entity' => 'Contribution', | |
501 | 'bao' => 'CRM_Contribute_BAO_Contribution', | |
6a7e5e5d | 502 | 'localizable' => 0, |
e501603b TO |
503 | 'html' => array( |
504 | 'type' => 'Text', | |
505 | ) , | |
506 | ) , | |
507 | 'currency' => array( | |
508 | 'name' => 'currency', | |
509 | 'type' => CRM_Utils_Type::T_STRING, | |
510 | 'title' => ts('Currency') , | |
511 | 'description' => '3 character string, value from config setting or input via user.', | |
512 | 'maxlength' => 3, | |
513 | 'size' => CRM_Utils_Type::FOUR, | |
514 | 'import' => true, | |
515 | 'where' => 'civicrm_contribution.currency', | |
516 | 'headerPattern' => '/cur(rency)?/i', | |
517 | 'dataPattern' => '/^[A-Z]{3}$/i', | |
518 | 'export' => true, | |
519 | 'default' => 'NULL', | |
522a26c9 | 520 | 'table_name' => 'civicrm_contribution', |
521 | 'entity' => 'Contribution', | |
522 | 'bao' => 'CRM_Contribute_BAO_Contribution', | |
6a7e5e5d | 523 | 'localizable' => 0, |
e501603b TO |
524 | 'html' => array( |
525 | 'type' => 'Select', | |
526 | ) , | |
527 | 'pseudoconstant' => array( | |
528 | 'table' => 'civicrm_currency', | |
529 | 'keyColumn' => 'name', | |
530 | 'labelColumn' => 'full_name', | |
531 | 'nameColumn' => 'name', | |
532 | ) | |
533 | ) , | |
534 | 'cancel_date' => array( | |
535 | 'name' => 'cancel_date', | |
536 | 'type' => CRM_Utils_Type::T_DATE + CRM_Utils_Type::T_TIME, | |
537 | 'title' => ts('Cancel Date') , | |
538 | 'description' => 'when was gift cancelled', | |
539 | 'import' => true, | |
540 | 'where' => 'civicrm_contribution.cancel_date', | |
541 | 'headerPattern' => '/cancel(.?date)?/i', | |
542 | 'dataPattern' => '/^\d{4}-?\d{2}-?\d{2} ?(\d{2}:?\d{2}:?(\d{2})?)?$/', | |
543 | 'export' => true, | |
522a26c9 | 544 | 'table_name' => 'civicrm_contribution', |
545 | 'entity' => 'Contribution', | |
546 | 'bao' => 'CRM_Contribute_BAO_Contribution', | |
6a7e5e5d | 547 | 'localizable' => 0, |
e501603b TO |
548 | 'html' => array( |
549 | 'type' => 'Select Date', | |
24317d89 | 550 | 'formatType' => 'activityDateTime', |
e501603b TO |
551 | ) , |
552 | ) , | |
553 | 'cancel_reason' => array( | |
554 | 'name' => 'cancel_reason', | |
555 | 'type' => CRM_Utils_Type::T_TEXT, | |
556 | 'title' => ts('Cancel Reason') , | |
557 | 'import' => true, | |
558 | 'where' => 'civicrm_contribution.cancel_reason', | |
559 | 'headerPattern' => '/(cancel.?)?reason/i', | |
560 | 'dataPattern' => '', | |
561 | 'export' => true, | |
522a26c9 | 562 | 'table_name' => 'civicrm_contribution', |
563 | 'entity' => 'Contribution', | |
564 | 'bao' => 'CRM_Contribute_BAO_Contribution', | |
6a7e5e5d | 565 | 'localizable' => 0, |
e501603b TO |
566 | 'html' => array( |
567 | 'type' => 'Text', | |
568 | ) , | |
569 | ) , | |
570 | 'receipt_date' => array( | |
571 | 'name' => 'receipt_date', | |
572 | 'type' => CRM_Utils_Type::T_DATE + CRM_Utils_Type::T_TIME, | |
573 | 'title' => ts('Receipt Date') , | |
574 | 'description' => 'when (if) receipt was sent. populated automatically for online donations w/ automatic receipting', | |
575 | 'import' => true, | |
576 | 'where' => 'civicrm_contribution.receipt_date', | |
577 | 'headerPattern' => '/receipt(.?date)?/i', | |
578 | 'dataPattern' => '/^\d{4}-?\d{2}-?\d{2} ?(\d{2}:?\d{2}:?(\d{2})?)?$/', | |
579 | 'export' => true, | |
522a26c9 | 580 | 'table_name' => 'civicrm_contribution', |
581 | 'entity' => 'Contribution', | |
582 | 'bao' => 'CRM_Contribute_BAO_Contribution', | |
6a7e5e5d | 583 | 'localizable' => 0, |
e501603b TO |
584 | 'html' => array( |
585 | 'type' => 'Select Date', | |
24317d89 | 586 | 'formatType' => 'activityDateTime', |
e501603b TO |
587 | ) , |
588 | ) , | |
589 | 'thankyou_date' => array( | |
590 | 'name' => 'thankyou_date', | |
591 | 'type' => CRM_Utils_Type::T_DATE + CRM_Utils_Type::T_TIME, | |
592 | 'title' => ts('Thank-you Date') , | |
593 | 'description' => 'when (if) was donor thanked', | |
594 | 'import' => true, | |
595 | 'where' => 'civicrm_contribution.thankyou_date', | |
596 | 'headerPattern' => '/thank(s|(.?you))?(.?date)?/i', | |
597 | 'dataPattern' => '/^\d{4}-?\d{2}-?\d{2} ?(\d{2}:?\d{2}:?(\d{2})?)?$/', | |
598 | 'export' => true, | |
522a26c9 | 599 | 'table_name' => 'civicrm_contribution', |
600 | 'entity' => 'Contribution', | |
601 | 'bao' => 'CRM_Contribute_BAO_Contribution', | |
6a7e5e5d | 602 | 'localizable' => 0, |
e501603b TO |
603 | 'html' => array( |
604 | 'type' => 'Select Date', | |
24317d89 | 605 | 'formatType' => 'activityDateTime', |
e501603b TO |
606 | ) , |
607 | ) , | |
608 | 'contribution_source' => array( | |
609 | 'name' => 'source', | |
610 | 'type' => CRM_Utils_Type::T_STRING, | |
611 | 'title' => ts('Contribution Source') , | |
612 | 'description' => 'Origin of this Contribution.', | |
613 | 'maxlength' => 255, | |
614 | 'size' => CRM_Utils_Type::HUGE, | |
615 | 'import' => true, | |
616 | 'where' => 'civicrm_contribution.source', | |
617 | 'headerPattern' => '/source/i', | |
618 | 'dataPattern' => '', | |
619 | 'export' => true, | |
522a26c9 | 620 | 'table_name' => 'civicrm_contribution', |
621 | 'entity' => 'Contribution', | |
622 | 'bao' => 'CRM_Contribute_BAO_Contribution', | |
6a7e5e5d | 623 | 'localizable' => 0, |
e501603b TO |
624 | 'html' => array( |
625 | 'type' => 'Text', | |
626 | ) , | |
627 | ) , | |
628 | 'amount_level' => array( | |
629 | 'name' => 'amount_level', | |
630 | 'type' => CRM_Utils_Type::T_TEXT, | |
631 | 'title' => ts('Amount Label') , | |
632 | 'import' => true, | |
633 | 'where' => 'civicrm_contribution.amount_level', | |
634 | 'headerPattern' => '', | |
635 | 'dataPattern' => '', | |
636 | 'export' => true, | |
522a26c9 | 637 | 'table_name' => 'civicrm_contribution', |
638 | 'entity' => 'Contribution', | |
639 | 'bao' => 'CRM_Contribute_BAO_Contribution', | |
6a7e5e5d | 640 | 'localizable' => 0, |
e501603b TO |
641 | 'html' => array( |
642 | 'type' => 'Text', | |
643 | ) , | |
644 | ) , | |
645 | 'contribution_recur_id' => array( | |
646 | 'name' => 'contribution_recur_id', | |
647 | 'type' => CRM_Utils_Type::T_INT, | |
648 | 'title' => ts('Recurring Contribution ID') , | |
649 | 'description' => 'Conditional foreign key to civicrm_contribution_recur id. Each contribution made in connection with a recurring contribution carries a foreign key to the recurring contribution record. This assumes we can track these processor initiated events.', | |
3123273f | 650 | 'export' => true, |
651 | 'where' => 'civicrm_contribution.contribution_recur_id', | |
652 | 'headerPattern' => '', | |
653 | 'dataPattern' => '', | |
522a26c9 | 654 | 'table_name' => 'civicrm_contribution', |
655 | 'entity' => 'Contribution', | |
656 | 'bao' => 'CRM_Contribute_BAO_Contribution', | |
6a7e5e5d | 657 | 'localizable' => 0, |
e501603b TO |
658 | 'FKClassName' => 'CRM_Contribute_DAO_ContributionRecur', |
659 | ) , | |
660 | 'is_test' => array( | |
661 | 'name' => 'is_test', | |
662 | 'type' => CRM_Utils_Type::T_BOOLEAN, | |
663 | 'title' => ts('Test') , | |
664 | 'import' => true, | |
665 | 'where' => 'civicrm_contribution.is_test', | |
666 | 'headerPattern' => '', | |
667 | 'dataPattern' => '', | |
668 | 'export' => true, | |
522a26c9 | 669 | 'table_name' => 'civicrm_contribution', |
670 | 'entity' => 'Contribution', | |
671 | 'bao' => 'CRM_Contribute_BAO_Contribution', | |
6a7e5e5d | 672 | 'localizable' => 0, |
e501603b TO |
673 | 'html' => array( |
674 | 'type' => 'CheckBox', | |
675 | ) , | |
676 | ) , | |
677 | 'is_pay_later' => array( | |
678 | 'name' => 'is_pay_later', | |
679 | 'type' => CRM_Utils_Type::T_BOOLEAN, | |
680 | 'title' => ts('Is Pay Later') , | |
681 | 'import' => true, | |
682 | 'where' => 'civicrm_contribution.is_pay_later', | |
683 | 'headerPattern' => '', | |
684 | 'dataPattern' => '', | |
685 | 'export' => true, | |
522a26c9 | 686 | 'table_name' => 'civicrm_contribution', |
687 | 'entity' => 'Contribution', | |
688 | 'bao' => 'CRM_Contribute_BAO_Contribution', | |
6a7e5e5d | 689 | 'localizable' => 0, |
e501603b TO |
690 | 'html' => array( |
691 | 'type' => 'CheckBox', | |
692 | ) , | |
693 | ) , | |
694 | 'contribution_status_id' => array( | |
695 | 'name' => 'contribution_status_id', | |
696 | 'type' => CRM_Utils_Type::T_INT, | |
697 | 'title' => ts('Contribution Status ID') , | |
698 | 'import' => true, | |
699 | 'where' => 'civicrm_contribution.contribution_status_id', | |
700 | 'headerPattern' => '/status/i', | |
701 | 'dataPattern' => '', | |
702 | 'export' => true, | |
703 | 'default' => '1', | |
522a26c9 | 704 | 'table_name' => 'civicrm_contribution', |
705 | 'entity' => 'Contribution', | |
706 | 'bao' => 'CRM_Contribute_BAO_Contribution', | |
6a7e5e5d | 707 | 'localizable' => 0, |
e501603b TO |
708 | 'html' => array( |
709 | 'type' => 'Select', | |
710 | ) , | |
711 | 'pseudoconstant' => array( | |
712 | 'optionGroupName' => 'contribution_status', | |
713 | 'optionEditPath' => 'civicrm/admin/options/contribution_status', | |
714 | ) | |
715 | ) , | |
3123273f | 716 | 'contribution_address_id' => array( |
e501603b TO |
717 | 'name' => 'address_id', |
718 | 'type' => CRM_Utils_Type::T_INT, | |
719 | 'title' => ts('Contribution Address') , | |
720 | 'description' => 'Conditional foreign key to civicrm_address.id. We insert an address record for each contribution when we have associated billing name and address data.', | |
3123273f | 721 | 'export' => true, |
722 | 'where' => 'civicrm_contribution.address_id', | |
723 | 'headerPattern' => '', | |
724 | 'dataPattern' => '', | |
522a26c9 | 725 | 'table_name' => 'civicrm_contribution', |
726 | 'entity' => 'Contribution', | |
727 | 'bao' => 'CRM_Contribute_BAO_Contribution', | |
6a7e5e5d | 728 | 'localizable' => 0, |
e501603b TO |
729 | 'FKClassName' => 'CRM_Core_DAO_Address', |
730 | ) , | |
7bc1d4da | 731 | 'contribution_check_number' => array( |
e501603b TO |
732 | 'name' => 'check_number', |
733 | 'type' => CRM_Utils_Type::T_STRING, | |
734 | 'title' => ts('Check Number') , | |
735 | 'maxlength' => 255, | |
736 | 'size' => 6, | |
737 | 'import' => true, | |
738 | 'where' => 'civicrm_contribution.check_number', | |
739 | 'headerPattern' => '/check(.?number)?/i', | |
740 | 'dataPattern' => '', | |
741 | 'export' => true, | |
522a26c9 | 742 | 'table_name' => 'civicrm_contribution', |
743 | 'entity' => 'Contribution', | |
744 | 'bao' => 'CRM_Contribute_BAO_Contribution', | |
6a7e5e5d | 745 | 'localizable' => 0, |
e501603b TO |
746 | 'html' => array( |
747 | 'type' => 'Text', | |
748 | ) , | |
749 | ) , | |
750 | 'contribution_campaign_id' => array( | |
751 | 'name' => 'campaign_id', | |
752 | 'type' => CRM_Utils_Type::T_INT, | |
753 | 'title' => ts('Campaign') , | |
754 | 'description' => 'The campaign for which this contribution has been triggered.', | |
755 | 'import' => true, | |
756 | 'where' => 'civicrm_contribution.campaign_id', | |
757 | 'headerPattern' => '', | |
758 | 'dataPattern' => '', | |
759 | 'export' => true, | |
522a26c9 | 760 | 'table_name' => 'civicrm_contribution', |
761 | 'entity' => 'Contribution', | |
762 | 'bao' => 'CRM_Contribute_BAO_Contribution', | |
6a7e5e5d | 763 | 'localizable' => 0, |
e501603b TO |
764 | 'FKClassName' => 'CRM_Campaign_DAO_Campaign', |
765 | 'html' => array( | |
766 | 'type' => 'Select', | |
767 | ) , | |
768 | 'pseudoconstant' => array( | |
769 | 'table' => 'civicrm_campaign', | |
770 | 'keyColumn' => 'id', | |
771 | 'labelColumn' => 'title', | |
772 | ) | |
773 | ) , | |
774 | 'creditnote_id' => array( | |
775 | 'name' => 'creditnote_id', | |
776 | 'type' => CRM_Utils_Type::T_STRING, | |
777 | 'title' => ts('Credit Note ID') , | |
778 | 'description' => 'unique credit note id, system generated or passed in', | |
779 | 'maxlength' => 255, | |
780 | 'size' => CRM_Utils_Type::HUGE, | |
781 | 'import' => true, | |
782 | 'where' => 'civicrm_contribution.creditnote_id', | |
783 | 'headerPattern' => '/creditnote(.?id)?/i', | |
784 | 'dataPattern' => '', | |
785 | 'export' => true, | |
522a26c9 | 786 | 'table_name' => 'civicrm_contribution', |
787 | 'entity' => 'Contribution', | |
788 | 'bao' => 'CRM_Contribute_BAO_Contribution', | |
6a7e5e5d | 789 | 'localizable' => 0, |
e501603b TO |
790 | 'html' => array( |
791 | 'type' => 'Text', | |
792 | ) , | |
793 | ) , | |
794 | 'tax_amount' => array( | |
795 | 'name' => 'tax_amount', | |
796 | 'type' => CRM_Utils_Type::T_MONEY, | |
797 | 'title' => ts('Tax Amount') , | |
798 | 'description' => 'Total tax amount of this contribution.', | |
799 | 'precision' => array( | |
800 | 20, | |
801 | 2 | |
802 | ) , | |
803 | 'import' => true, | |
804 | 'where' => 'civicrm_contribution.tax_amount', | |
805 | 'headerPattern' => '/tax(.?am(ou)?nt)?/i', | |
806 | 'dataPattern' => '/^\d+(\.\d{2})?$/', | |
807 | 'export' => true, | |
522a26c9 | 808 | 'table_name' => 'civicrm_contribution', |
809 | 'entity' => 'Contribution', | |
810 | 'bao' => 'CRM_Contribute_BAO_Contribution', | |
6a7e5e5d | 811 | 'localizable' => 0, |
e501603b TO |
812 | 'html' => array( |
813 | 'type' => 'Text', | |
814 | ) , | |
815 | ) , | |
816 | 'revenue_recognition_date' => array( | |
817 | 'name' => 'revenue_recognition_date', | |
818 | 'type' => CRM_Utils_Type::T_DATE + CRM_Utils_Type::T_TIME, | |
819 | 'title' => ts('Revenue Recognition Date') , | |
820 | 'description' => 'Stores the date when revenue should be recognized.', | |
821 | 'import' => true, | |
822 | 'where' => 'civicrm_contribution.revenue_recognition_date', | |
823 | 'headerPattern' => '/revenue(.?date)?/i', | |
824 | 'dataPattern' => '/^\d{4}-?\d{2}-?\d{2} ?(\d{2}:?\d{2}:?(\d{2})?)?$/', | |
825 | 'export' => true, | |
522a26c9 | 826 | 'table_name' => 'civicrm_contribution', |
827 | 'entity' => 'Contribution', | |
828 | 'bao' => 'CRM_Contribute_BAO_Contribution', | |
6a7e5e5d | 829 | 'localizable' => 0, |
e501603b TO |
830 | 'html' => array( |
831 | 'type' => 'Select Date', | |
24317d89 | 832 | 'formatType' => 'activityDateTime', |
e501603b TO |
833 | ) , |
834 | ) , | |
835 | ); | |
346aaaba | 836 | CRM_Core_DAO_AllCoreTables::invoke(__CLASS__, 'fields_callback', Civi::$statics[__CLASS__]['fields']); |
e501603b | 837 | } |
346aaaba | 838 | return Civi::$statics[__CLASS__]['fields']; |
e501603b TO |
839 | } |
840 | /** | |
bd8e0b14 | 841 | * Return a mapping from field-name to the corresponding key (as used in fields()). |
e501603b TO |
842 | * |
843 | * @return array | |
bd8e0b14 | 844 | * Array(string $name => string $uniqueName). |
e501603b TO |
845 | */ |
846 | static function &fieldKeys() { | |
bd8e0b14 TO |
847 | if (!isset(Civi::$statics[__CLASS__]['fieldKeys'])) { |
848 | Civi::$statics[__CLASS__]['fieldKeys'] = array_flip(CRM_Utils_Array::collect('name', self::fields())); | |
e501603b | 849 | } |
bd8e0b14 | 850 | return Civi::$statics[__CLASS__]['fieldKeys']; |
e501603b TO |
851 | } |
852 | /** | |
853 | * Returns the names of this table | |
854 | * | |
855 | * @return string | |
856 | */ | |
857 | static function getTableName() { | |
858 | return self::$_tableName; | |
859 | } | |
860 | /** | |
861 | * Returns if this table needs to be logged | |
862 | * | |
863 | * @return boolean | |
864 | */ | |
865 | function getLog() { | |
866 | return self::$_log; | |
867 | } | |
868 | /** | |
869 | * Returns the list of fields that can be imported | |
870 | * | |
871 | * @param bool $prefix | |
872 | * | |
873 | * @return array | |
874 | */ | |
875 | static function &import($prefix = false) { | |
60808919 TO |
876 | $r = CRM_Core_DAO_AllCoreTables::getImports(__CLASS__, 'contribution', $prefix, array()); |
877 | return $r; | |
e501603b TO |
878 | } |
879 | /** | |
880 | * Returns the list of fields that can be exported | |
881 | * | |
882 | * @param bool $prefix | |
883 | * | |
884 | * @return array | |
885 | */ | |
886 | static function &export($prefix = false) { | |
60808919 TO |
887 | $r = CRM_Core_DAO_AllCoreTables::getExports(__CLASS__, 'contribution', $prefix, array()); |
888 | return $r; | |
e501603b | 889 | } |
e7a6b91a AS |
890 | /** |
891 | * Returns the list of indices | |
892 | */ | |
893 | public static function indices($localize = TRUE) { | |
894 | $indices = array( | |
895 | 'UI_contrib_payment_instrument_id' => array( | |
896 | 'name' => 'UI_contrib_payment_instrument_id', | |
897 | 'field' => array( | |
898 | 0 => 'payment_instrument_id', | |
899 | ) , | |
900 | 'localizable' => false, | |
901 | 'sig' => 'civicrm_contribution::0::payment_instrument_id', | |
902 | ) , | |
903 | 'index_total_amount_receive_date' => array( | |
904 | 'name' => 'index_total_amount_receive_date', | |
905 | 'field' => array( | |
906 | 0 => 'total_amount', | |
907 | 1 => 'receive_date', | |
908 | ) , | |
909 | 'localizable' => false, | |
910 | 'sig' => 'civicrm_contribution::0::total_amount::receive_date', | |
911 | ) , | |
912 | 'index_source' => array( | |
913 | 'name' => 'index_source', | |
914 | 'field' => array( | |
915 | 0 => 'source', | |
916 | ) , | |
917 | 'localizable' => false, | |
918 | 'sig' => 'civicrm_contribution::0::source', | |
919 | ) , | |
920 | 'UI_contrib_trxn_id' => array( | |
921 | 'name' => 'UI_contrib_trxn_id', | |
922 | 'field' => array( | |
923 | 0 => 'trxn_id', | |
924 | ) , | |
925 | 'localizable' => false, | |
926 | 'unique' => true, | |
927 | 'sig' => 'civicrm_contribution::1::trxn_id', | |
928 | ) , | |
929 | 'UI_contrib_invoice_id' => array( | |
930 | 'name' => 'UI_contrib_invoice_id', | |
931 | 'field' => array( | |
932 | 0 => 'invoice_id', | |
933 | ) , | |
934 | 'localizable' => false, | |
935 | 'unique' => true, | |
936 | 'sig' => 'civicrm_contribution::1::invoice_id', | |
937 | ) , | |
938 | 'index_contribution_status' => array( | |
939 | 'name' => 'index_contribution_status', | |
940 | 'field' => array( | |
941 | 0 => 'contribution_status_id', | |
942 | ) , | |
943 | 'localizable' => false, | |
944 | 'sig' => 'civicrm_contribution::0::contribution_status_id', | |
945 | ) , | |
946 | 'received_date' => array( | |
947 | 'name' => 'received_date', | |
948 | 'field' => array( | |
949 | 0 => 'receive_date', | |
950 | ) , | |
951 | 'localizable' => false, | |
952 | 'sig' => 'civicrm_contribution::0::receive_date', | |
953 | ) , | |
954 | 'check_number' => array( | |
955 | 'name' => 'check_number', | |
956 | 'field' => array( | |
957 | 0 => 'check_number', | |
958 | ) , | |
959 | 'localizable' => false, | |
960 | 'sig' => 'civicrm_contribution::0::check_number', | |
961 | ) , | |
962 | 'index_creditnote_id' => array( | |
963 | 'name' => 'index_creditnote_id', | |
964 | 'field' => array( | |
965 | 0 => 'creditnote_id', | |
966 | ) , | |
967 | 'localizable' => false, | |
968 | 'sig' => 'civicrm_contribution::0::creditnote_id', | |
969 | ) , | |
970 | ); | |
971 | return ($localize && !empty($indices)) ? CRM_Core_DAO_AllCoreTables::multilingualize(__CLASS__, $indices) : $indices; | |
972 | } | |
e501603b | 973 | } |