Merge pull request #12364 from JMAConsulting/dev-core-210
[civicrm-core.git] / CRM / Contribute / DAO / ContributionSoft.php
1 <?php
2
3 /**
4 * @package CRM
5 * @copyright CiviCRM LLC (c) 2004-2018
6 *
7 * Generated from xml/schema/CRM/Contribute/ContributionSoft.xml
8 * DO NOT EDIT. Generated by CRM_Core_CodeGen
9 * (GenCodeChecksum:e183ac4d1412bc227a1be7975cc67b0a)
10 */
11
12 /**
13 * Database access object for the ContributionSoft entity.
14 */
15 class CRM_Contribute_DAO_ContributionSoft extends CRM_Core_DAO {
16
17 /**
18 * Static instance to hold the table name.
19 *
20 * @var string
21 */
22 static $_tableName = 'civicrm_contribution_soft';
23
24 /**
25 * Should CiviCRM log any modifications to this table in the civicrm_log table.
26 *
27 * @var bool
28 */
29 static $_log = TRUE;
30
31 /**
32 * Soft Contribution ID
33 *
34 * @var int unsigned
35 */
36 public $id;
37
38 /**
39 * FK to contribution table.
40 *
41 * @var int unsigned
42 */
43 public $contribution_id;
44
45 /**
46 * FK to Contact ID
47 *
48 * @var int unsigned
49 */
50 public $contact_id;
51
52 /**
53 * Amount of this soft contribution.
54 *
55 * @var float
56 */
57 public $amount;
58
59 /**
60 * 3 character string, value from config setting or input via user.
61 *
62 * @var string
63 */
64 public $currency;
65
66 /**
67 * FK to civicrm_pcp.id
68 *
69 * @var int unsigned
70 */
71 public $pcp_id;
72
73 /**
74 * @var boolean
75 */
76 public $pcp_display_in_roll;
77
78 /**
79 * @var string
80 */
81 public $pcp_roll_nickname;
82
83 /**
84 * @var string
85 */
86 public $pcp_personal_note;
87
88 /**
89 * Soft Credit Type ID.Implicit FK to civicrm_option_value where option_group = soft_credit_type.
90 *
91 * @var int unsigned
92 */
93 public $soft_credit_type_id;
94
95 /**
96 * Class constructor.
97 */
98 public function __construct() {
99 $this->__table = 'civicrm_contribution_soft';
100 parent::__construct();
101 }
102
103 /**
104 * Returns foreign keys and entity references.
105 *
106 * @return array
107 * [CRM_Core_Reference_Interface]
108 */
109 public static function getReferenceColumns() {
110 if (!isset(Civi::$statics[__CLASS__]['links'])) {
111 Civi::$statics[__CLASS__]['links'] = static ::createReferenceColumns(__CLASS__);
112 Civi::$statics[__CLASS__]['links'][] = new CRM_Core_Reference_Basic(self::getTableName(), 'contribution_id', 'civicrm_contribution', 'id');
113 Civi::$statics[__CLASS__]['links'][] = new CRM_Core_Reference_Basic(self::getTableName(), 'contact_id', 'civicrm_contact', 'id');
114 Civi::$statics[__CLASS__]['links'][] = new CRM_Core_Reference_Basic(self::getTableName(), 'pcp_id', 'civicrm_pcp', 'id');
115 CRM_Core_DAO_AllCoreTables::invoke(__CLASS__, 'links_callback', Civi::$statics[__CLASS__]['links']);
116 }
117 return Civi::$statics[__CLASS__]['links'];
118 }
119
120 /**
121 * Returns all the column names of this table
122 *
123 * @return array
124 */
125 public static function &fields() {
126 if (!isset(Civi::$statics[__CLASS__]['fields'])) {
127 Civi::$statics[__CLASS__]['fields'] = [
128 'contribution_soft_id' => [
129 'name' => 'id',
130 'type' => CRM_Utils_Type::T_INT,
131 'title' => ts('Soft Contribution ID'),
132 'description' => 'Soft Contribution ID',
133 'required' => TRUE,
134 'import' => TRUE,
135 'where' => 'civicrm_contribution_soft.id',
136 'headerPattern' => '',
137 'dataPattern' => '',
138 'export' => TRUE,
139 'table_name' => 'civicrm_contribution_soft',
140 'entity' => 'ContributionSoft',
141 'bao' => 'CRM_Contribute_BAO_ContributionSoft',
142 'localizable' => 0,
143 ],
144 'contribution_id' => [
145 'name' => 'contribution_id',
146 'type' => CRM_Utils_Type::T_INT,
147 'title' => ts('Soft Contribution - Contribution'),
148 'description' => 'FK to contribution table.',
149 'required' => TRUE,
150 'table_name' => 'civicrm_contribution_soft',
151 'entity' => 'ContributionSoft',
152 'bao' => 'CRM_Contribute_BAO_ContributionSoft',
153 'localizable' => 0,
154 'FKClassName' => 'CRM_Contribute_DAO_Contribution',
155 ],
156 'contribution_soft_contact_id' => [
157 'name' => 'contact_id',
158 'type' => CRM_Utils_Type::T_INT,
159 'title' => ts('Contact ID'),
160 'description' => 'FK to Contact ID',
161 'required' => TRUE,
162 'import' => TRUE,
163 'where' => 'civicrm_contribution_soft.contact_id',
164 'headerPattern' => '/contact(.?id)?/i',
165 'dataPattern' => '/^\d+$/',
166 'export' => TRUE,
167 'table_name' => 'civicrm_contribution_soft',
168 'entity' => 'ContributionSoft',
169 'bao' => 'CRM_Contribute_BAO_ContributionSoft',
170 'localizable' => 0,
171 'FKClassName' => 'CRM_Contact_DAO_Contact',
172 ],
173 'amount' => [
174 'name' => 'amount',
175 'type' => CRM_Utils_Type::T_MONEY,
176 'title' => ts('Soft Contribution Amount'),
177 'description' => 'Amount of this soft contribution.',
178 'required' => TRUE,
179 'precision' => [
180 20,
181 2
182 ],
183 'import' => TRUE,
184 'where' => 'civicrm_contribution_soft.amount',
185 'headerPattern' => '/total(.?am(ou)?nt)?/i',
186 'dataPattern' => '/^\d+(\.\d{2})?$/',
187 'export' => TRUE,
188 'table_name' => 'civicrm_contribution_soft',
189 'entity' => 'ContributionSoft',
190 'bao' => 'CRM_Contribute_BAO_ContributionSoft',
191 'localizable' => 0,
192 ],
193 'currency' => [
194 'name' => 'currency',
195 'type' => CRM_Utils_Type::T_STRING,
196 'title' => ts('Soft Contribution Currency'),
197 'description' => '3 character string, value from config setting or input via user.',
198 'maxlength' => 3,
199 'size' => CRM_Utils_Type::FOUR,
200 'default' => 'NULL',
201 'table_name' => 'civicrm_contribution_soft',
202 'entity' => 'ContributionSoft',
203 'bao' => 'CRM_Contribute_BAO_ContributionSoft',
204 'localizable' => 0,
205 'html' => [
206 'type' => 'Select',
207 ],
208 'pseudoconstant' => [
209 'table' => 'civicrm_currency',
210 'keyColumn' => 'name',
211 'labelColumn' => 'full_name',
212 'nameColumn' => 'name',
213 ]
214 ],
215 'pcp_id' => [
216 'name' => 'pcp_id',
217 'type' => CRM_Utils_Type::T_INT,
218 'title' => ts('Soft Contribution PCP'),
219 'description' => 'FK to civicrm_pcp.id',
220 'default' => 'NULL',
221 'table_name' => 'civicrm_contribution_soft',
222 'entity' => 'ContributionSoft',
223 'bao' => 'CRM_Contribute_BAO_ContributionSoft',
224 'localizable' => 0,
225 'FKClassName' => 'CRM_PCP_DAO_PCP',
226 'pseudoconstant' => [
227 'table' => 'civicrm_pcp',
228 'keyColumn' => 'id',
229 'labelColumn' => 'title',
230 ]
231 ],
232 'pcp_display_in_roll' => [
233 'name' => 'pcp_display_in_roll',
234 'type' => CRM_Utils_Type::T_BOOLEAN,
235 'title' => ts('Soft Contribution Display on PCP'),
236 'default' => '0',
237 'table_name' => 'civicrm_contribution_soft',
238 'entity' => 'ContributionSoft',
239 'bao' => 'CRM_Contribute_BAO_ContributionSoft',
240 'localizable' => 0,
241 ],
242 'pcp_roll_nickname' => [
243 'name' => 'pcp_roll_nickname',
244 'type' => CRM_Utils_Type::T_STRING,
245 'title' => ts('Soft Contribution PCP Nickname'),
246 'maxlength' => 255,
247 'size' => CRM_Utils_Type::HUGE,
248 'default' => 'NULL',
249 'table_name' => 'civicrm_contribution_soft',
250 'entity' => 'ContributionSoft',
251 'bao' => 'CRM_Contribute_BAO_ContributionSoft',
252 'localizable' => 0,
253 ],
254 'pcp_personal_note' => [
255 'name' => 'pcp_personal_note',
256 'type' => CRM_Utils_Type::T_STRING,
257 'title' => ts('Soft Contribution PCP Note'),
258 'maxlength' => 255,
259 'size' => CRM_Utils_Type::HUGE,
260 'default' => 'NULL',
261 'table_name' => 'civicrm_contribution_soft',
262 'entity' => 'ContributionSoft',
263 'bao' => 'CRM_Contribute_BAO_ContributionSoft',
264 'localizable' => 0,
265 'html' => [
266 'type' => 'TextArea',
267 ],
268 ],
269 'soft_credit_type_id' => [
270 'name' => 'soft_credit_type_id',
271 'type' => CRM_Utils_Type::T_INT,
272 'title' => ts('Soft Credit Type'),
273 'description' => 'Soft Credit Type ID.Implicit FK to civicrm_option_value where option_group = soft_credit_type.',
274 'default' => 'NULL',
275 'table_name' => 'civicrm_contribution_soft',
276 'entity' => 'ContributionSoft',
277 'bao' => 'CRM_Contribute_BAO_ContributionSoft',
278 'localizable' => 0,
279 'pseudoconstant' => [
280 'optionGroupName' => 'soft_credit_type',
281 'optionEditPath' => 'civicrm/admin/options/soft_credit_type',
282 ]
283 ],
284 ];
285 CRM_Core_DAO_AllCoreTables::invoke(__CLASS__, 'fields_callback', Civi::$statics[__CLASS__]['fields']);
286 }
287 return Civi::$statics[__CLASS__]['fields'];
288 }
289
290 /**
291 * Return a mapping from field-name to the corresponding key (as used in fields()).
292 *
293 * @return array
294 * Array(string $name => string $uniqueName).
295 */
296 public static function &fieldKeys() {
297 if (!isset(Civi::$statics[__CLASS__]['fieldKeys'])) {
298 Civi::$statics[__CLASS__]['fieldKeys'] = array_flip(CRM_Utils_Array::collect('name', self::fields()));
299 }
300 return Civi::$statics[__CLASS__]['fieldKeys'];
301 }
302
303 /**
304 * Returns the names of this table
305 *
306 * @return string
307 */
308 public static function getTableName() {
309 return self::$_tableName;
310 }
311
312 /**
313 * Returns if this table needs to be logged
314 *
315 * @return bool
316 */
317 public function getLog() {
318 return self::$_log;
319 }
320
321 /**
322 * Returns the list of fields that can be imported
323 *
324 * @param bool $prefix
325 *
326 * @return array
327 */
328 public static function &import($prefix = FALSE) {
329 $r = CRM_Core_DAO_AllCoreTables::getImports(__CLASS__, 'contribution_soft', $prefix, []);
330 return $r;
331 }
332
333 /**
334 * Returns the list of fields that can be exported
335 *
336 * @param bool $prefix
337 *
338 * @return array
339 */
340 public static function &export($prefix = FALSE) {
341 $r = CRM_Core_DAO_AllCoreTables::getExports(__CLASS__, 'contribution_soft', $prefix, []);
342 return $r;
343 }
344
345 /**
346 * Returns the list of indices
347 *
348 * @param bool $localize
349 *
350 * @return array
351 */
352 public static function indices($localize = TRUE) {
353 $indices = [
354 'index_id' => [
355 'name' => 'index_id',
356 'field' => [
357 0 => 'pcp_id',
358 ],
359 'localizable' => FALSE,
360 'sig' => 'civicrm_contribution_soft::0::pcp_id',
361 ],
362 ];
363 return ($localize && !empty($indices)) ? CRM_Core_DAO_AllCoreTables::multilingualize(__CLASS__, $indices) : $indices;
364 }
365
366 }