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