Merge pull request #12004 from samuelsov/dev/core#30#2
[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 'table_name' => 'civicrm_contribution_soft',
237 'entity' => 'ContributionSoft',
238 'bao' => 'CRM_Contribute_BAO_ContributionSoft',
239 'localizable' => 0,
240 ],
241 'pcp_roll_nickname' => [
242 'name' => 'pcp_roll_nickname',
243 'type' => CRM_Utils_Type::T_STRING,
244 'title' => ts('Soft Contribution PCP Nickname'),
245 'maxlength' => 255,
246 'size' => CRM_Utils_Type::HUGE,
247 'default' => 'NULL',
248 'table_name' => 'civicrm_contribution_soft',
249 'entity' => 'ContributionSoft',
250 'bao' => 'CRM_Contribute_BAO_ContributionSoft',
251 'localizable' => 0,
252 ],
253 'pcp_personal_note' => [
254 'name' => 'pcp_personal_note',
255 'type' => CRM_Utils_Type::T_STRING,
256 'title' => ts('Soft Contribution PCP Note'),
257 'maxlength' => 255,
258 'size' => CRM_Utils_Type::HUGE,
259 'default' => 'NULL',
260 'table_name' => 'civicrm_contribution_soft',
261 'entity' => 'ContributionSoft',
262 'bao' => 'CRM_Contribute_BAO_ContributionSoft',
263 'localizable' => 0,
264 'html' => [
265 'type' => 'TextArea',
266 ],
267 ],
268 'soft_credit_type_id' => [
269 'name' => 'soft_credit_type_id',
270 'type' => CRM_Utils_Type::T_INT,
271 'title' => ts('Soft Credit Type'),
272 'description' => 'Soft Credit Type ID.Implicit FK to civicrm_option_value where option_group = soft_credit_type.',
273 'default' => 'NULL',
274 'table_name' => 'civicrm_contribution_soft',
275 'entity' => 'ContributionSoft',
276 'bao' => 'CRM_Contribute_BAO_ContributionSoft',
277 'localizable' => 0,
278 'pseudoconstant' => [
279 'optionGroupName' => 'soft_credit_type',
280 'optionEditPath' => 'civicrm/admin/options/soft_credit_type',
281 ]
282 ],
283 ];
284 CRM_Core_DAO_AllCoreTables::invoke(__CLASS__, 'fields_callback', Civi::$statics[__CLASS__]['fields']);
285 }
286 return Civi::$statics[__CLASS__]['fields'];
287 }
288
289 /**
290 * Return a mapping from field-name to the corresponding key (as used in fields()).
291 *
292 * @return array
293 * Array(string $name => string $uniqueName).
294 */
295 public static function &fieldKeys() {
296 if (!isset(Civi::$statics[__CLASS__]['fieldKeys'])) {
297 Civi::$statics[__CLASS__]['fieldKeys'] = array_flip(CRM_Utils_Array::collect('name', self::fields()));
298 }
299 return Civi::$statics[__CLASS__]['fieldKeys'];
300 }
301
302 /**
303 * Returns the names of this table
304 *
305 * @return string
306 */
307 public static function getTableName() {
308 return self::$_tableName;
309 }
310
311 /**
312 * Returns if this table needs to be logged
313 *
314 * @return bool
315 */
316 public function getLog() {
317 return self::$_log;
318 }
319
320 /**
321 * Returns the list of fields that can be imported
322 *
323 * @param bool $prefix
324 *
325 * @return array
326 */
327 public static function &import($prefix = FALSE) {
328 $r = CRM_Core_DAO_AllCoreTables::getImports(__CLASS__, 'contribution_soft', $prefix, []);
329 return $r;
330 }
331
332 /**
333 * Returns the list of fields that can be exported
334 *
335 * @param bool $prefix
336 *
337 * @return array
338 */
339 public static function &export($prefix = FALSE) {
340 $r = CRM_Core_DAO_AllCoreTables::getExports(__CLASS__, 'contribution_soft', $prefix, []);
341 return $r;
342 }
343
344 /**
345 * Returns the list of indices
346 *
347 * @param bool $localize
348 *
349 * @return array
350 */
351 public static function indices($localize = TRUE) {
352 $indices = [
353 'index_id' => [
354 'name' => 'index_id',
355 'field' => [
356 0 => 'pcp_id',
357 ],
358 'localizable' => FALSE,
359 'sig' => 'civicrm_contribution_soft::0::pcp_id',
360 ],
361 ];
362 return ($localize && !empty($indices)) ? CRM_Core_DAO_AllCoreTables::multilingualize(__CLASS__, $indices) : $indices;
363 }
364
365 }