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