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