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