Merge pull request #21351 from colemanw/spreadsheetFormats
[civicrm-core.git] / CRM / Member / DAO / MembershipPayment.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/Member/MembershipPayment.xml
8 * DO NOT EDIT. Generated by CRM_Core_CodeGen
2562d09a 9 * (GenCodeChecksum:cb00d5477470230f8ab9b18bc56ca910)
e501603b 10 */
c3fc2621 11
f41f0342 12/**
c3fc2621 13 * Database access object for the MembershipPayment entity.
f41f0342 14 */
e501603b 15class CRM_Member_DAO_MembershipPayment extends CRM_Core_DAO {
929a1c14
CW
16 const EXT = 'civicrm';
17 const TABLE_ADDED = '1.5';
d31fb4e3 18 const COMPONENT = 'CiviMember';
c3fc2621 19
e501603b 20 /**
f41f0342 21 * Static instance to hold the table name.
e501603b
TO
22 *
23 * @var string
24 */
fa45b5b9 25 public static $_tableName = 'civicrm_membership_payment';
c3fc2621 26
e501603b 27 /**
f41f0342 28 * Should CiviCRM log any modifications to this table in the civicrm_log table.
e501603b 29 *
c3fc2621 30 * @var bool
e501603b 31 */
fa45b5b9 32 public static $_log = TRUE;
c3fc2621 33
e501603b 34 /**
e6ca0a57 35 * @var int
e501603b
TO
36 */
37 public $id;
c3fc2621 38
e501603b
TO
39 /**
40 * FK to Membership table
41 *
e6ca0a57 42 * @var int
e501603b
TO
43 */
44 public $membership_id;
c3fc2621 45
e501603b
TO
46 /**
47 * FK to contribution table.
48 *
e6ca0a57 49 * @var int
e501603b
TO
50 */
51 public $contribution_id;
c3fc2621 52
e501603b 53 /**
f41f0342 54 * Class constructor.
e501603b 55 */
c3fc2621 56 public function __construct() {
e501603b
TO
57 $this->__table = 'civicrm_membership_payment';
58 parent::__construct();
59 }
c3fc2621 60
449c4e6b
CW
61 /**
62 * Returns localized title of this entity.
7b66c3b5
AH
63 *
64 * @param bool $plural
65 * Whether to return the plural version of the title.
449c4e6b 66 */
7b66c3b5
AH
67 public static function getEntityTitle($plural = FALSE) {
68 return $plural ? ts('Membership Payments') : ts('Membership Payment');
449c4e6b
CW
69 }
70
e501603b 71 /**
f41f0342 72 * Returns foreign keys and entity references.
e501603b
TO
73 *
74 * @return array
75 * [CRM_Core_Reference_Interface]
76 */
c3fc2621 77 public static function getReferenceColumns() {
346aaaba 78 if (!isset(Civi::$statics[__CLASS__]['links'])) {
fa45b5b9 79 Civi::$statics[__CLASS__]['links'] = static::createReferenceColumns(__CLASS__);
c3fc2621
CW
80 Civi::$statics[__CLASS__]['links'][] = new CRM_Core_Reference_Basic(self::getTableName(), 'membership_id', 'civicrm_membership', 'id');
81 Civi::$statics[__CLASS__]['links'][] = new CRM_Core_Reference_Basic(self::getTableName(), 'contribution_id', 'civicrm_contribution', 'id');
346aaaba 82 CRM_Core_DAO_AllCoreTables::invoke(__CLASS__, 'links_callback', Civi::$statics[__CLASS__]['links']);
e501603b 83 }
346aaaba 84 return Civi::$statics[__CLASS__]['links'];
e501603b 85 }
c3fc2621 86
e501603b
TO
87 /**
88 * Returns all the column names of this table
89 *
90 * @return array
91 */
c3fc2621 92 public static function &fields() {
346aaaba 93 if (!isset(Civi::$statics[__CLASS__]['fields'])) {
c3fc2621
CW
94 Civi::$statics[__CLASS__]['fields'] = [
95 'id' => [
e501603b
TO
96 'name' => 'id',
97 'type' => CRM_Utils_Type::T_INT,
c3fc2621
CW
98 'title' => ts('Membership Payment ID'),
99 'required' => TRUE,
a36434b9 100 'where' => 'civicrm_membership_payment.id',
522a26c9 101 'table_name' => 'civicrm_membership_payment',
102 'entity' => 'MembershipPayment',
103 'bao' => 'CRM_Member_BAO_MembershipPayment',
6a7e5e5d 104 'localizable' => 0,
2cbbebe8
A
105 'html' => [
106 'type' => 'Number',
107 ],
1fe423d6 108 'readonly' => TRUE,
a9d0587b 109 'add' => '1.5',
c3fc2621
CW
110 ],
111 'membership_id' => [
e501603b
TO
112 'name' => 'membership_id',
113 'type' => CRM_Utils_Type::T_INT,
2cbbebe8 114 'title' => ts('Membership ID'),
215b423e 115 'description' => ts('FK to Membership table'),
c3fc2621 116 'required' => TRUE,
a36434b9 117 'where' => 'civicrm_membership_payment.membership_id',
522a26c9 118 'table_name' => 'civicrm_membership_payment',
119 'entity' => 'MembershipPayment',
120 'bao' => 'CRM_Member_BAO_MembershipPayment',
6a7e5e5d 121 'localizable' => 0,
e501603b 122 'FKClassName' => 'CRM_Member_DAO_Membership',
2cbbebe8
A
123 'html' => [
124 'label' => ts("Membership"),
125 ],
a9d0587b 126 'add' => '1.5',
c3fc2621
CW
127 ],
128 'contribution_id' => [
e501603b
TO
129 'name' => 'contribution_id',
130 'type' => CRM_Utils_Type::T_INT,
2cbbebe8 131 'title' => ts('Contribution ID'),
215b423e 132 'description' => ts('FK to contribution table.'),
a36434b9 133 'where' => 'civicrm_membership_payment.contribution_id',
522a26c9 134 'table_name' => 'civicrm_membership_payment',
135 'entity' => 'MembershipPayment',
136 'bao' => 'CRM_Member_BAO_MembershipPayment',
6a7e5e5d 137 'localizable' => 0,
e501603b 138 'FKClassName' => 'CRM_Contribute_DAO_Contribution',
2cbbebe8
A
139 'html' => [
140 'label' => ts("Contribution"),
141 ],
a9d0587b 142 'add' => '2.0',
c3fc2621
CW
143 ],
144 ];
346aaaba 145 CRM_Core_DAO_AllCoreTables::invoke(__CLASS__, 'fields_callback', Civi::$statics[__CLASS__]['fields']);
e501603b 146 }
346aaaba 147 return Civi::$statics[__CLASS__]['fields'];
e501603b 148 }
c3fc2621 149
e501603b 150 /**
bd8e0b14 151 * Return a mapping from field-name to the corresponding key (as used in fields()).
e501603b
TO
152 *
153 * @return array
bd8e0b14 154 * Array(string $name => string $uniqueName).
e501603b 155 */
c3fc2621 156 public static function &fieldKeys() {
bd8e0b14
TO
157 if (!isset(Civi::$statics[__CLASS__]['fieldKeys'])) {
158 Civi::$statics[__CLASS__]['fieldKeys'] = array_flip(CRM_Utils_Array::collect('name', self::fields()));
e501603b 159 }
bd8e0b14 160 return Civi::$statics[__CLASS__]['fieldKeys'];
e501603b 161 }
c3fc2621 162
e501603b
TO
163 /**
164 * Returns the names of this table
165 *
166 * @return string
167 */
c3fc2621 168 public static function getTableName() {
e501603b
TO
169 return self::$_tableName;
170 }
c3fc2621 171
e501603b
TO
172 /**
173 * Returns if this table needs to be logged
174 *
c3fc2621 175 * @return bool
e501603b 176 */
c3fc2621 177 public function getLog() {
e501603b
TO
178 return self::$_log;
179 }
c3fc2621 180
e501603b
TO
181 /**
182 * Returns the list of fields that can be imported
183 *
184 * @param bool $prefix
185 *
186 * @return array
187 */
c3fc2621
CW
188 public static function &import($prefix = FALSE) {
189 $r = CRM_Core_DAO_AllCoreTables::getImports(__CLASS__, 'membership_payment', $prefix, []);
60808919 190 return $r;
e501603b 191 }
c3fc2621 192
e501603b
TO
193 /**
194 * Returns the list of fields that can be exported
195 *
196 * @param bool $prefix
197 *
198 * @return array
199 */
c3fc2621
CW
200 public static function &export($prefix = FALSE) {
201 $r = CRM_Core_DAO_AllCoreTables::getExports(__CLASS__, 'membership_payment', $prefix, []);
60808919 202 return $r;
e501603b 203 }
c3fc2621 204
e7a6b91a
AS
205 /**
206 * Returns the list of indices
c3fc2621
CW
207 *
208 * @param bool $localize
209 *
210 * @return array
e7a6b91a
AS
211 */
212 public static function indices($localize = TRUE) {
c3fc2621
CW
213 $indices = [
214 'UI_contribution_membership' => [
e7a6b91a 215 'name' => 'UI_contribution_membership',
c3fc2621 216 'field' => [
e7a6b91a
AS
217 0 => 'contribution_id',
218 1 => 'membership_id',
c3fc2621
CW
219 ],
220 'localizable' => FALSE,
221 'unique' => TRUE,
e7a6b91a 222 'sig' => 'civicrm_membership_payment::1::contribution_id::membership_id',
c3fc2621
CW
223 ],
224 ];
e7a6b91a
AS
225 return ($localize && !empty($indices)) ? CRM_Core_DAO_AllCoreTables::multilingualize(__CLASS__, $indices) : $indices;
226 }
c3fc2621 227
e501603b 228}