Merge pull request #11434 from JO0st/CRM-21580
[civicrm-core.git] / CRM / Batch / DAO / Batch.php
1 <?php
2
3 /**
4 * @package CRM
5 * @copyright CiviCRM LLC (c) 2004-2017
6 *
7 * Generated from xml/schema/CRM/Batch/Batch.xml
8 * DO NOT EDIT. Generated by CRM_Core_CodeGen
9 * (GenCodeChecksum:a9d49cd47b4a388ca88aa2af363f952d)
10 */
11
12 /**
13 * Database access object for the Batch entity.
14 */
15 class CRM_Batch_DAO_Batch extends CRM_Core_DAO {
16
17 /**
18 * Static instance to hold the table name.
19 *
20 * @var string
21 */
22 static $_tableName = 'civicrm_batch';
23
24 /**
25 * Should CiviCRM log any modifications to this table in the civicrm_log table.
26 *
27 * @var bool
28 */
29 static $_log = FALSE;
30
31 /**
32 * Unique Address ID
33 *
34 * @var int unsigned
35 */
36 public $id;
37
38 /**
39 * Variable name/programmatic handle for this batch.
40 *
41 * @var string
42 */
43 public $name;
44
45 /**
46 * Friendly Name.
47 *
48 * @var string
49 */
50 public $title;
51
52 /**
53 * Description of this batch set.
54 *
55 * @var text
56 */
57 public $description;
58
59 /**
60 * FK to Contact ID
61 *
62 * @var int unsigned
63 */
64 public $created_id;
65
66 /**
67 * When was this item created
68 *
69 * @var datetime
70 */
71 public $created_date;
72
73 /**
74 * FK to Contact ID
75 *
76 * @var int unsigned
77 */
78 public $modified_id;
79
80 /**
81 * When was this item created
82 *
83 * @var datetime
84 */
85 public $modified_date;
86
87 /**
88 * FK to Saved Search ID
89 *
90 * @var int unsigned
91 */
92 public $saved_search_id;
93
94 /**
95 * fk to Batch Status options in civicrm_option_values
96 *
97 * @var int unsigned
98 */
99 public $status_id;
100
101 /**
102 * fk to Batch Type options in civicrm_option_values
103 *
104 * @var int unsigned
105 */
106 public $type_id;
107
108 /**
109 * fk to Batch mode options in civicrm_option_values
110 *
111 * @var int unsigned
112 */
113 public $mode_id;
114
115 /**
116 * Total amount for this batch.
117 *
118 * @var float
119 */
120 public $total;
121
122 /**
123 * Number of items in a batch.
124 *
125 * @var int unsigned
126 */
127 public $item_count;
128
129 /**
130 * fk to Payment Instrument options in civicrm_option_values
131 *
132 * @var int unsigned
133 */
134 public $payment_instrument_id;
135
136 /**
137 * @var datetime
138 */
139 public $exported_date;
140
141 /**
142 * cache entered data
143 *
144 * @var longtext
145 */
146 public $data;
147
148 /**
149 * Class constructor.
150 */
151 public function __construct() {
152 $this->__table = 'civicrm_batch';
153 parent::__construct();
154 }
155
156 /**
157 * Returns foreign keys and entity references.
158 *
159 * @return array
160 * [CRM_Core_Reference_Interface]
161 */
162 public static function getReferenceColumns() {
163 if (!isset(Civi::$statics[__CLASS__]['links'])) {
164 Civi::$statics[__CLASS__]['links'] = static ::createReferenceColumns(__CLASS__);
165 Civi::$statics[__CLASS__]['links'][] = new CRM_Core_Reference_Basic(self::getTableName(), 'created_id', 'civicrm_contact', 'id');
166 Civi::$statics[__CLASS__]['links'][] = new CRM_Core_Reference_Basic(self::getTableName(), 'modified_id', 'civicrm_contact', 'id');
167 Civi::$statics[__CLASS__]['links'][] = new CRM_Core_Reference_Basic(self::getTableName(), 'saved_search_id', 'civicrm_saved_search', 'id');
168 CRM_Core_DAO_AllCoreTables::invoke(__CLASS__, 'links_callback', Civi::$statics[__CLASS__]['links']);
169 }
170 return Civi::$statics[__CLASS__]['links'];
171 }
172
173 /**
174 * Returns all the column names of this table
175 *
176 * @return array
177 */
178 public static function &fields() {
179 if (!isset(Civi::$statics[__CLASS__]['fields'])) {
180 Civi::$statics[__CLASS__]['fields'] = [
181 'id' => [
182 'name' => 'id',
183 'type' => CRM_Utils_Type::T_INT,
184 'title' => ts('Batch ID'),
185 'description' => 'Unique Address ID',
186 'required' => TRUE,
187 'table_name' => 'civicrm_batch',
188 'entity' => 'Batch',
189 'bao' => 'CRM_Batch_BAO_Batch',
190 'localizable' => 0,
191 ],
192 'name' => [
193 'name' => 'name',
194 'type' => CRM_Utils_Type::T_STRING,
195 'title' => ts('Batch Name'),
196 'description' => 'Variable name/programmatic handle for this batch.',
197 'maxlength' => 64,
198 'size' => CRM_Utils_Type::BIG,
199 'table_name' => 'civicrm_batch',
200 'entity' => 'Batch',
201 'bao' => 'CRM_Batch_BAO_Batch',
202 'localizable' => 0,
203 'html' => [
204 'type' => 'Text',
205 ],
206 ],
207 'title' => [
208 'name' => 'title',
209 'type' => CRM_Utils_Type::T_STRING,
210 'title' => ts('Batch Title'),
211 'description' => 'Friendly Name.',
212 'maxlength' => 255,
213 'size' => CRM_Utils_Type::HUGE,
214 'table_name' => 'civicrm_batch',
215 'entity' => 'Batch',
216 'bao' => 'CRM_Batch_BAO_Batch',
217 'localizable' => 1,
218 'html' => [
219 'type' => 'Text',
220 ],
221 ],
222 'description' => [
223 'name' => 'description',
224 'type' => CRM_Utils_Type::T_TEXT,
225 'title' => ts('Batch Description'),
226 'description' => 'Description of this batch set.',
227 'rows' => 4,
228 'cols' => 80,
229 'table_name' => 'civicrm_batch',
230 'entity' => 'Batch',
231 'bao' => 'CRM_Batch_BAO_Batch',
232 'localizable' => 1,
233 'html' => [
234 'type' => 'TextArea',
235 ],
236 ],
237 'created_id' => [
238 'name' => 'created_id',
239 'type' => CRM_Utils_Type::T_INT,
240 'title' => ts('Batch Created By'),
241 'description' => 'FK to Contact ID',
242 'table_name' => 'civicrm_batch',
243 'entity' => 'Batch',
244 'bao' => 'CRM_Batch_BAO_Batch',
245 'localizable' => 0,
246 'FKClassName' => 'CRM_Contact_DAO_Contact',
247 ],
248 'created_date' => [
249 'name' => 'created_date',
250 'type' => CRM_Utils_Type::T_DATE + CRM_Utils_Type::T_TIME,
251 'title' => ts('Batch Created Date'),
252 'description' => 'When was this item created',
253 'table_name' => 'civicrm_batch',
254 'entity' => 'Batch',
255 'bao' => 'CRM_Batch_BAO_Batch',
256 'localizable' => 0,
257 'html' => [
258 'type' => 'Select Date',
259 ],
260 ],
261 'modified_id' => [
262 'name' => 'modified_id',
263 'type' => CRM_Utils_Type::T_INT,
264 'title' => ts('Batch Modified By'),
265 'description' => 'FK to Contact ID',
266 'table_name' => 'civicrm_batch',
267 'entity' => 'Batch',
268 'bao' => 'CRM_Batch_BAO_Batch',
269 'localizable' => 0,
270 'FKClassName' => 'CRM_Contact_DAO_Contact',
271 ],
272 'modified_date' => [
273 'name' => 'modified_date',
274 'type' => CRM_Utils_Type::T_DATE + CRM_Utils_Type::T_TIME,
275 'title' => ts('Batch Modified Date'),
276 'description' => 'When was this item created',
277 'table_name' => 'civicrm_batch',
278 'entity' => 'Batch',
279 'bao' => 'CRM_Batch_BAO_Batch',
280 'localizable' => 0,
281 ],
282 'saved_search_id' => [
283 'name' => 'saved_search_id',
284 'type' => CRM_Utils_Type::T_INT,
285 'title' => ts('Batch Smart Group'),
286 'description' => 'FK to Saved Search ID',
287 'table_name' => 'civicrm_batch',
288 'entity' => 'Batch',
289 'bao' => 'CRM_Batch_BAO_Batch',
290 'localizable' => 0,
291 'FKClassName' => 'CRM_Contact_DAO_SavedSearch',
292 'html' => [
293 'type' => 'EntityRef',
294 ],
295 ],
296 'status_id' => [
297 'name' => 'status_id',
298 'type' => CRM_Utils_Type::T_INT,
299 'title' => ts('Batch Status'),
300 'description' => 'fk to Batch Status options in civicrm_option_values',
301 'required' => TRUE,
302 'table_name' => 'civicrm_batch',
303 'entity' => 'Batch',
304 'bao' => 'CRM_Batch_BAO_Batch',
305 'localizable' => 0,
306 'html' => [
307 'type' => 'Select',
308 ],
309 'pseudoconstant' => [
310 'optionGroupName' => 'batch_status',
311 'optionEditPath' => 'civicrm/admin/options/batch_status',
312 ]
313 ],
314 'type_id' => [
315 'name' => 'type_id',
316 'type' => CRM_Utils_Type::T_INT,
317 'title' => ts('Batch Type'),
318 'description' => 'fk to Batch Type options in civicrm_option_values',
319 'table_name' => 'civicrm_batch',
320 'entity' => 'Batch',
321 'bao' => 'CRM_Batch_BAO_Batch',
322 'localizable' => 0,
323 'html' => [
324 'type' => 'Select',
325 ],
326 'pseudoconstant' => [
327 'optionGroupName' => 'batch_type',
328 'optionEditPath' => 'civicrm/admin/options/batch_type',
329 ]
330 ],
331 'mode_id' => [
332 'name' => 'mode_id',
333 'type' => CRM_Utils_Type::T_INT,
334 'title' => ts('Batch Mode'),
335 'description' => 'fk to Batch mode options in civicrm_option_values',
336 'table_name' => 'civicrm_batch',
337 'entity' => 'Batch',
338 'bao' => 'CRM_Batch_BAO_Batch',
339 'localizable' => 0,
340 'html' => [
341 'type' => 'Select',
342 ],
343 'pseudoconstant' => [
344 'optionGroupName' => 'batch_mode',
345 'optionEditPath' => 'civicrm/admin/options/batch_mode',
346 ]
347 ],
348 'total' => [
349 'name' => 'total',
350 'type' => CRM_Utils_Type::T_MONEY,
351 'title' => ts('Batch Total'),
352 'description' => 'Total amount for this batch.',
353 'precision' => [
354 20,
355 2
356 ],
357 'table_name' => 'civicrm_batch',
358 'entity' => 'Batch',
359 'bao' => 'CRM_Batch_BAO_Batch',
360 'localizable' => 0,
361 'html' => [
362 'type' => 'Text',
363 ],
364 ],
365 'item_count' => [
366 'name' => 'item_count',
367 'type' => CRM_Utils_Type::T_INT,
368 'title' => ts('Batch Number of Items'),
369 'description' => 'Number of items in a batch.',
370 'table_name' => 'civicrm_batch',
371 'entity' => 'Batch',
372 'bao' => 'CRM_Batch_BAO_Batch',
373 'localizable' => 0,
374 'html' => [
375 'type' => 'Text',
376 ],
377 ],
378 'payment_instrument_id' => [
379 'name' => 'payment_instrument_id',
380 'type' => CRM_Utils_Type::T_INT,
381 'title' => ts('Batch Payment Method'),
382 'description' => 'fk to Payment Instrument options in civicrm_option_values',
383 'table_name' => 'civicrm_batch',
384 'entity' => 'Batch',
385 'bao' => 'CRM_Batch_BAO_Batch',
386 'localizable' => 0,
387 'html' => [
388 'type' => 'Select',
389 ],
390 'pseudoconstant' => [
391 'optionGroupName' => 'payment_instrument',
392 'optionEditPath' => 'civicrm/admin/options/payment_instrument',
393 ]
394 ],
395 'exported_date' => [
396 'name' => 'exported_date',
397 'type' => CRM_Utils_Type::T_DATE + CRM_Utils_Type::T_TIME,
398 'title' => ts('Batch Exported Date'),
399 'table_name' => 'civicrm_batch',
400 'entity' => 'Batch',
401 'bao' => 'CRM_Batch_BAO_Batch',
402 'localizable' => 0,
403 ],
404 'data' => [
405 'name' => 'data',
406 'type' => CRM_Utils_Type::T_LONGTEXT,
407 'title' => ts('Batch Data'),
408 'description' => 'cache entered data',
409 'table_name' => 'civicrm_batch',
410 'entity' => 'Batch',
411 'bao' => 'CRM_Batch_BAO_Batch',
412 'localizable' => 0,
413 ],
414 ];
415 CRM_Core_DAO_AllCoreTables::invoke(__CLASS__, 'fields_callback', Civi::$statics[__CLASS__]['fields']);
416 }
417 return Civi::$statics[__CLASS__]['fields'];
418 }
419
420 /**
421 * Return a mapping from field-name to the corresponding key (as used in fields()).
422 *
423 * @return array
424 * Array(string $name => string $uniqueName).
425 */
426 public static function &fieldKeys() {
427 if (!isset(Civi::$statics[__CLASS__]['fieldKeys'])) {
428 Civi::$statics[__CLASS__]['fieldKeys'] = array_flip(CRM_Utils_Array::collect('name', self::fields()));
429 }
430 return Civi::$statics[__CLASS__]['fieldKeys'];
431 }
432
433 /**
434 * Returns the names of this table
435 *
436 * @return string
437 */
438 public static function getTableName() {
439 return CRM_Core_DAO::getLocaleTableName(self::$_tableName);
440 }
441
442 /**
443 * Returns if this table needs to be logged
444 *
445 * @return bool
446 */
447 public function getLog() {
448 return self::$_log;
449 }
450
451 /**
452 * Returns the list of fields that can be imported
453 *
454 * @param bool $prefix
455 *
456 * @return array
457 */
458 public static function &import($prefix = FALSE) {
459 $r = CRM_Core_DAO_AllCoreTables::getImports(__CLASS__, 'batch', $prefix, []);
460 return $r;
461 }
462
463 /**
464 * Returns the list of fields that can be exported
465 *
466 * @param bool $prefix
467 *
468 * @return array
469 */
470 public static function &export($prefix = FALSE) {
471 $r = CRM_Core_DAO_AllCoreTables::getExports(__CLASS__, 'batch', $prefix, []);
472 return $r;
473 }
474
475 /**
476 * Returns the list of indices
477 *
478 * @param bool $localize
479 *
480 * @return array
481 */
482 public static function indices($localize = TRUE) {
483 $indices = [
484 'UI_name' => [
485 'name' => 'UI_name',
486 'field' => [
487 0 => 'name',
488 ],
489 'localizable' => FALSE,
490 'unique' => TRUE,
491 'sig' => 'civicrm_batch::1::name',
492 ],
493 ];
494 return ($localize && !empty($indices)) ? CRM_Core_DAO_AllCoreTables::multilingualize(__CLASS__, $indices) : $indices;
495 }
496
497 }