Merge pull request #14367 from MegaphoneJon/financial-58
[civicrm-core.git] / CRM / Pledge / DAO / PledgePayment.php
CommitLineData
e501603b 1<?php
c3fc2621 2
e501603b
TO
3/**
4 * @package CRM
6b83d5bd 5 * @copyright CiviCRM LLC (c) 2004-2019
e501603b
TO
6 *
7 * Generated from xml/schema/CRM/Pledge/PledgePayment.xml
8 * DO NOT EDIT. Generated by CRM_Core_CodeGen
a8fdb24e 9 * (GenCodeChecksum:7dfb4f8000b79fa8b1abab1de3712fc1)
e501603b 10 */
c3fc2621 11
f41f0342 12/**
c3fc2621 13 * Database access object for the PledgePayment entity.
f41f0342 14 */
e501603b 15class CRM_Pledge_DAO_PledgePayment extends CRM_Core_DAO {
c3fc2621 16
e501603b 17 /**
f41f0342 18 * Static instance to hold the table name.
e501603b
TO
19 *
20 * @var string
21 */
fa45b5b9 22 public static $_tableName = 'civicrm_pledge_payment';
c3fc2621 23
e501603b 24 /**
f41f0342 25 * Should CiviCRM log any modifications to this table in the civicrm_log table.
e501603b 26 *
c3fc2621 27 * @var bool
e501603b 28 */
fa45b5b9 29 public static $_log = TRUE;
c3fc2621 30
e501603b 31 /**
e6ca0a57 32 * @var int
e501603b
TO
33 */
34 public $id;
c3fc2621 35
e501603b
TO
36 /**
37 * FK to Pledge table
38 *
e6ca0a57 39 * @var int
e501603b
TO
40 */
41 public $pledge_id;
c3fc2621 42
e501603b
TO
43 /**
44 * FK to contribution table.
45 *
e6ca0a57 46 * @var int
e501603b
TO
47 */
48 public $contribution_id;
c3fc2621 49
e501603b
TO
50 /**
51 * Pledged amount for this payment (the actual contribution amount might be different).
52 *
53 * @var float
54 */
55 public $scheduled_amount;
c3fc2621 56
e501603b
TO
57 /**
58 * Actual amount that is paid as the Pledged installment amount.
59 *
60 * @var float
61 */
62 public $actual_amount;
c3fc2621 63
e501603b
TO
64 /**
65 * 3 character string, value from config setting or input via user.
66 *
67 * @var string
68 */
69 public $currency;
c3fc2621 70
e501603b
TO
71 /**
72 * The date the pledge payment is supposed to happen.
73 *
74 * @var datetime
75 */
76 public $scheduled_date;
c3fc2621 77
e501603b
TO
78 /**
79 * The date that the most recent payment reminder was sent.
80 *
81 * @var datetime
82 */
83 public $reminder_date;
c3fc2621 84
e501603b
TO
85 /**
86 * The number of payment reminders sent.
87 *
e6ca0a57 88 * @var int
e501603b
TO
89 */
90 public $reminder_count;
c3fc2621 91
e501603b 92 /**
e6ca0a57 93 * @var int
e501603b
TO
94 */
95 public $status_id;
c3fc2621 96
e501603b 97 /**
f41f0342 98 * Class constructor.
e501603b 99 */
c3fc2621 100 public function __construct() {
e501603b
TO
101 $this->__table = 'civicrm_pledge_payment';
102 parent::__construct();
103 }
c3fc2621 104
e501603b 105 /**
f41f0342 106 * Returns foreign keys and entity references.
e501603b
TO
107 *
108 * @return array
109 * [CRM_Core_Reference_Interface]
110 */
c3fc2621 111 public static function getReferenceColumns() {
346aaaba 112 if (!isset(Civi::$statics[__CLASS__]['links'])) {
fa45b5b9 113 Civi::$statics[__CLASS__]['links'] = static::createReferenceColumns(__CLASS__);
c3fc2621
CW
114 Civi::$statics[__CLASS__]['links'][] = new CRM_Core_Reference_Basic(self::getTableName(), 'pledge_id', 'civicrm_pledge', 'id');
115 Civi::$statics[__CLASS__]['links'][] = new CRM_Core_Reference_Basic(self::getTableName(), 'contribution_id', 'civicrm_contribution', 'id');
346aaaba 116 CRM_Core_DAO_AllCoreTables::invoke(__CLASS__, 'links_callback', Civi::$statics[__CLASS__]['links']);
e501603b 117 }
346aaaba 118 return Civi::$statics[__CLASS__]['links'];
e501603b 119 }
c3fc2621 120
e501603b
TO
121 /**
122 * Returns all the column names of this table
123 *
124 * @return array
125 */
c3fc2621 126 public static function &fields() {
346aaaba 127 if (!isset(Civi::$statics[__CLASS__]['fields'])) {
c3fc2621
CW
128 Civi::$statics[__CLASS__]['fields'] = [
129 'pledge_payment_id' => [
e501603b
TO
130 'name' => 'id',
131 'type' => CRM_Utils_Type::T_INT,
c3fc2621
CW
132 'title' => ts('Payment ID'),
133 'required' => TRUE,
134 'import' => TRUE,
e501603b 135 'where' => 'civicrm_pledge_payment.id',
c3fc2621 136 'export' => TRUE,
522a26c9 137 'table_name' => 'civicrm_pledge_payment',
138 'entity' => 'PledgePayment',
139 'bao' => 'CRM_Pledge_BAO_PledgePayment',
6a7e5e5d 140 'localizable' => 0,
c3fc2621
CW
141 ],
142 'pledge_id' => [
e501603b
TO
143 'name' => 'pledge_id',
144 'type' => CRM_Utils_Type::T_INT,
c3fc2621 145 'title' => ts('Pledge'),
215b423e 146 'description' => ts('FK to Pledge table'),
c3fc2621 147 'required' => TRUE,
a36434b9 148 'where' => 'civicrm_pledge_payment.pledge_id',
522a26c9 149 'table_name' => 'civicrm_pledge_payment',
150 'entity' => 'PledgePayment',
151 'bao' => 'CRM_Pledge_BAO_PledgePayment',
6a7e5e5d 152 'localizable' => 0,
e501603b 153 'FKClassName' => 'CRM_Pledge_DAO_Pledge',
c3fc2621
CW
154 ],
155 'contribution_id' => [
e501603b
TO
156 'name' => 'contribution_id',
157 'type' => CRM_Utils_Type::T_INT,
c3fc2621 158 'title' => ts('Contribution'),
215b423e 159 'description' => ts('FK to contribution table.'),
a36434b9 160 'where' => 'civicrm_pledge_payment.contribution_id',
522a26c9 161 'table_name' => 'civicrm_pledge_payment',
162 'entity' => 'PledgePayment',
163 'bao' => 'CRM_Pledge_BAO_PledgePayment',
6a7e5e5d 164 'localizable' => 0,
e501603b 165 'FKClassName' => 'CRM_Contribute_DAO_Contribution',
c3fc2621
CW
166 ],
167 'pledge_payment_scheduled_amount' => [
e501603b
TO
168 'name' => 'scheduled_amount',
169 'type' => CRM_Utils_Type::T_MONEY,
c3fc2621 170 'title' => ts('Scheduled Amount'),
215b423e 171 'description' => ts('Pledged amount for this payment (the actual contribution amount might be different).'),
c3fc2621
CW
172 'required' => TRUE,
173 'precision' => [
e501603b 174 20,
fb607354 175 2,
c3fc2621
CW
176 ],
177 'import' => TRUE,
e501603b 178 'where' => 'civicrm_pledge_payment.scheduled_amount',
c3fc2621 179 'export' => TRUE,
522a26c9 180 'table_name' => 'civicrm_pledge_payment',
181 'entity' => 'PledgePayment',
182 'bao' => 'CRM_Pledge_BAO_PledgePayment',
6a7e5e5d 183 'localizable' => 0,
c3fc2621
CW
184 ],
185 'pledge_payment_actual_amount' => [
e501603b
TO
186 'name' => 'actual_amount',
187 'type' => CRM_Utils_Type::T_MONEY,
c3fc2621 188 'title' => ts('Actual Amount'),
215b423e 189 'description' => ts('Actual amount that is paid as the Pledged installment amount.'),
c3fc2621 190 'precision' => [
e501603b 191 20,
fb607354 192 2,
c3fc2621
CW
193 ],
194 'import' => TRUE,
e501603b 195 'where' => 'civicrm_pledge_payment.actual_amount',
c3fc2621 196 'export' => TRUE,
522a26c9 197 'table_name' => 'civicrm_pledge_payment',
198 'entity' => 'PledgePayment',
199 'bao' => 'CRM_Pledge_BAO_PledgePayment',
6a7e5e5d 200 'localizable' => 0,
c3fc2621
CW
201 ],
202 'currency' => [
e501603b
TO
203 'name' => 'currency',
204 'type' => CRM_Utils_Type::T_STRING,
c3fc2621 205 'title' => ts('Currency'),
215b423e 206 'description' => ts('3 character string, value from config setting or input via user.'),
e501603b
TO
207 'maxlength' => 3,
208 'size' => CRM_Utils_Type::FOUR,
a36434b9 209 'where' => 'civicrm_pledge_payment.currency',
e501603b 210 'default' => 'NULL',
522a26c9 211 'table_name' => 'civicrm_pledge_payment',
212 'entity' => 'PledgePayment',
213 'bao' => 'CRM_Pledge_BAO_PledgePayment',
6a7e5e5d 214 'localizable' => 0,
c3fc2621 215 'html' => [
e501603b 216 'type' => 'Select',
c3fc2621
CW
217 ],
218 'pseudoconstant' => [
e501603b
TO
219 'table' => 'civicrm_currency',
220 'keyColumn' => 'name',
221 'labelColumn' => 'full_name',
222 'nameColumn' => 'name',
a8fdb24e 223 'abbrColumn' => 'symbol',
e6ca0a57 224 ],
c3fc2621
CW
225 ],
226 'pledge_payment_scheduled_date' => [
e501603b
TO
227 'name' => 'scheduled_date',
228 'type' => CRM_Utils_Type::T_DATE + CRM_Utils_Type::T_TIME,
c3fc2621 229 'title' => ts('Scheduled Date'),
215b423e 230 'description' => ts('The date the pledge payment is supposed to happen.'),
c3fc2621
CW
231 'required' => TRUE,
232 'import' => TRUE,
e501603b 233 'where' => 'civicrm_pledge_payment.scheduled_date',
c3fc2621 234 'export' => TRUE,
522a26c9 235 'table_name' => 'civicrm_pledge_payment',
236 'entity' => 'PledgePayment',
237 'bao' => 'CRM_Pledge_BAO_PledgePayment',
6a7e5e5d 238 'localizable' => 0,
267fb11a
SL
239 'html' => [
240 'type' => 'Select Date',
241 'formatType' => 'activityDate',
242 ],
c3fc2621
CW
243 ],
244 'pledge_payment_reminder_date' => [
e501603b
TO
245 'name' => 'reminder_date',
246 'type' => CRM_Utils_Type::T_DATE + CRM_Utils_Type::T_TIME,
c3fc2621 247 'title' => ts('Last Reminder'),
215b423e 248 'description' => ts('The date that the most recent payment reminder was sent.'),
c3fc2621 249 'import' => TRUE,
e501603b 250 'where' => 'civicrm_pledge_payment.reminder_date',
c3fc2621 251 'export' => TRUE,
522a26c9 252 'table_name' => 'civicrm_pledge_payment',
253 'entity' => 'PledgePayment',
254 'bao' => 'CRM_Pledge_BAO_PledgePayment',
6a7e5e5d 255 'localizable' => 0,
c3fc2621
CW
256 ],
257 'pledge_payment_reminder_count' => [
e501603b
TO
258 'name' => 'reminder_count',
259 'type' => CRM_Utils_Type::T_INT,
c3fc2621 260 'title' => ts('Reminders Sent'),
215b423e 261 'description' => ts('The number of payment reminders sent.'),
c3fc2621 262 'import' => TRUE,
e501603b 263 'where' => 'civicrm_pledge_payment.reminder_count',
c3fc2621 264 'export' => TRUE,
45a83e42 265 'default' => '0',
522a26c9 266 'table_name' => 'civicrm_pledge_payment',
267 'entity' => 'PledgePayment',
268 'bao' => 'CRM_Pledge_BAO_PledgePayment',
6a7e5e5d 269 'localizable' => 0,
c3fc2621
CW
270 ],
271 'pledge_payment_status_id' => [
e501603b
TO
272 'name' => 'status_id',
273 'type' => CRM_Utils_Type::T_INT,
c3fc2621
CW
274 'title' => ts('Payment Status'),
275 'import' => TRUE,
e501603b 276 'where' => 'civicrm_pledge_payment.status_id',
c3fc2621 277 'export' => FALSE,
522a26c9 278 'table_name' => 'civicrm_pledge_payment',
279 'entity' => 'PledgePayment',
280 'bao' => 'CRM_Pledge_BAO_PledgePayment',
6a7e5e5d 281 'localizable' => 0,
c3fc2621 282 'pseudoconstant' => [
e501603b
TO
283 'optionGroupName' => 'contribution_status',
284 'optionEditPath' => 'civicrm/admin/options/contribution_status',
e6ca0a57 285 ],
c3fc2621
CW
286 ],
287 ];
346aaaba 288 CRM_Core_DAO_AllCoreTables::invoke(__CLASS__, 'fields_callback', Civi::$statics[__CLASS__]['fields']);
e501603b 289 }
346aaaba 290 return Civi::$statics[__CLASS__]['fields'];
e501603b 291 }
c3fc2621 292
e501603b 293 /**
bd8e0b14 294 * Return a mapping from field-name to the corresponding key (as used in fields()).
e501603b
TO
295 *
296 * @return array
bd8e0b14 297 * Array(string $name => string $uniqueName).
e501603b 298 */
c3fc2621 299 public static function &fieldKeys() {
bd8e0b14
TO
300 if (!isset(Civi::$statics[__CLASS__]['fieldKeys'])) {
301 Civi::$statics[__CLASS__]['fieldKeys'] = array_flip(CRM_Utils_Array::collect('name', self::fields()));
e501603b 302 }
bd8e0b14 303 return Civi::$statics[__CLASS__]['fieldKeys'];
e501603b 304 }
c3fc2621 305
e501603b
TO
306 /**
307 * Returns the names of this table
308 *
309 * @return string
310 */
c3fc2621 311 public static function getTableName() {
e501603b
TO
312 return self::$_tableName;
313 }
c3fc2621 314
e501603b
TO
315 /**
316 * Returns if this table needs to be logged
317 *
c3fc2621 318 * @return bool
e501603b 319 */
c3fc2621 320 public function getLog() {
e501603b
TO
321 return self::$_log;
322 }
c3fc2621 323
e501603b
TO
324 /**
325 * Returns the list of fields that can be imported
326 *
327 * @param bool $prefix
328 *
329 * @return array
330 */
c3fc2621
CW
331 public static function &import($prefix = FALSE) {
332 $r = CRM_Core_DAO_AllCoreTables::getImports(__CLASS__, 'pledge_payment', $prefix, []);
60808919 333 return $r;
e501603b 334 }
c3fc2621 335
e501603b
TO
336 /**
337 * Returns the list of fields that can be exported
338 *
339 * @param bool $prefix
340 *
341 * @return array
342 */
c3fc2621
CW
343 public static function &export($prefix = FALSE) {
344 $r = CRM_Core_DAO_AllCoreTables::getExports(__CLASS__, 'pledge_payment', $prefix, []);
60808919 345 return $r;
e501603b 346 }
c3fc2621 347
e7a6b91a
AS
348 /**
349 * Returns the list of indices
c3fc2621
CW
350 *
351 * @param bool $localize
352 *
353 * @return array
e7a6b91a
AS
354 */
355 public static function indices($localize = TRUE) {
c3fc2621
CW
356 $indices = [
357 'index_contribution_pledge' => [
e7a6b91a 358 'name' => 'index_contribution_pledge',
c3fc2621 359 'field' => [
e7a6b91a
AS
360 0 => 'contribution_id',
361 1 => 'pledge_id',
c3fc2621
CW
362 ],
363 'localizable' => FALSE,
e7a6b91a 364 'sig' => 'civicrm_pledge_payment::0::contribution_id::pledge_id',
c3fc2621
CW
365 ],
366 'index_status' => [
e7a6b91a 367 'name' => 'index_status',
c3fc2621 368 'field' => [
e7a6b91a 369 0 => 'status_id',
c3fc2621
CW
370 ],
371 'localizable' => FALSE,
e7a6b91a 372 'sig' => 'civicrm_pledge_payment::0::status_id',
c3fc2621
CW
373 ],
374 ];
e7a6b91a
AS
375 return ($localize && !empty($indices)) ? CRM_Core_DAO_AllCoreTables::multilingualize(__CLASS__, $indices) : $indices;
376 }
c3fc2621 377
e501603b 378}