Merge pull request #17980 from eileenmcnaughton/dupe
[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:8169fc2f338afc4a163214c0018030be)
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 public static function getEntityTitle() {
162 return ts('Batches');
163 }
164
165 /**
166 * Returns foreign keys and entity references.
167 *
168 * @return array
169 * [CRM_Core_Reference_Interface]
170 */
171 public static function getReferenceColumns() {
172 if (!isset(Civi::$statics[__CLASS__]['links'])) {
173 Civi::$statics[__CLASS__]['links'] = static::createReferenceColumns(__CLASS__);
174 Civi::$statics[__CLASS__]['links'][] = new CRM_Core_Reference_Basic(self::getTableName(), 'created_id', 'civicrm_contact', 'id');
175 Civi::$statics[__CLASS__]['links'][] = new CRM_Core_Reference_Basic(self::getTableName(), 'modified_id', 'civicrm_contact', 'id');
176 Civi::$statics[__CLASS__]['links'][] = new CRM_Core_Reference_Basic(self::getTableName(), 'saved_search_id', 'civicrm_saved_search', 'id');
177 CRM_Core_DAO_AllCoreTables::invoke(__CLASS__, 'links_callback', Civi::$statics[__CLASS__]['links']);
178 }
179 return Civi::$statics[__CLASS__]['links'];
180 }
181
182 /**
183 * Returns all the column names of this table
184 *
185 * @return array
186 */
187 public static function &fields() {
188 if (!isset(Civi::$statics[__CLASS__]['fields'])) {
189 Civi::$statics[__CLASS__]['fields'] = [
190 'id' => [
191 'name' => 'id',
192 'type' => CRM_Utils_Type::T_INT,
193 'title' => ts('Batch ID'),
194 'description' => ts('Unique Address ID'),
195 'required' => TRUE,
196 'where' => 'civicrm_batch.id',
197 'table_name' => 'civicrm_batch',
198 'entity' => 'Batch',
199 'bao' => 'CRM_Batch_BAO_Batch',
200 'localizable' => 0,
201 'add' => '3.3',
202 ],
203 'name' => [
204 'name' => 'name',
205 'type' => CRM_Utils_Type::T_STRING,
206 'title' => ts('Batch Name'),
207 'description' => ts('Variable name/programmatic handle for this batch.'),
208 'maxlength' => 64,
209 'size' => CRM_Utils_Type::BIG,
210 'where' => 'civicrm_batch.name',
211 'table_name' => 'civicrm_batch',
212 'entity' => 'Batch',
213 'bao' => 'CRM_Batch_BAO_Batch',
214 'localizable' => 0,
215 'html' => [
216 'type' => 'Text',
217 ],
218 'add' => '3.3',
219 ],
220 'title' => [
221 'name' => 'title',
222 'type' => CRM_Utils_Type::T_STRING,
223 'title' => ts('Batch Title'),
224 'description' => ts('Friendly Name.'),
225 'maxlength' => 255,
226 'size' => CRM_Utils_Type::HUGE,
227 'where' => 'civicrm_batch.title',
228 'table_name' => 'civicrm_batch',
229 'entity' => 'Batch',
230 'bao' => 'CRM_Batch_BAO_Batch',
231 'localizable' => 1,
232 'html' => [
233 'type' => 'Text',
234 ],
235 'add' => '4.2',
236 ],
237 'description' => [
238 'name' => 'description',
239 'type' => CRM_Utils_Type::T_TEXT,
240 'title' => ts('Batch Description'),
241 'description' => ts('Description of this batch set.'),
242 'rows' => 4,
243 'cols' => 80,
244 'where' => 'civicrm_batch.description',
245 'table_name' => 'civicrm_batch',
246 'entity' => 'Batch',
247 'bao' => 'CRM_Batch_BAO_Batch',
248 'localizable' => 1,
249 'html' => [
250 'type' => 'TextArea',
251 ],
252 'add' => '3.3',
253 ],
254 'created_id' => [
255 'name' => 'created_id',
256 'type' => CRM_Utils_Type::T_INT,
257 'title' => ts('Batch Created By'),
258 'description' => ts('FK to Contact ID'),
259 'where' => 'civicrm_batch.created_id',
260 'table_name' => 'civicrm_batch',
261 'entity' => 'Batch',
262 'bao' => 'CRM_Batch_BAO_Batch',
263 'localizable' => 0,
264 'FKClassName' => 'CRM_Contact_DAO_Contact',
265 'add' => '3.3',
266 ],
267 'created_date' => [
268 'name' => 'created_date',
269 'type' => CRM_Utils_Type::T_DATE + CRM_Utils_Type::T_TIME,
270 'title' => ts('Batch Created Date'),
271 'description' => ts('When was this item created'),
272 'where' => 'civicrm_batch.created_date',
273 'table_name' => 'civicrm_batch',
274 'entity' => 'Batch',
275 'bao' => 'CRM_Batch_BAO_Batch',
276 'localizable' => 0,
277 'html' => [
278 'type' => 'Select Date',
279 'formatType' => 'activityDateTime',
280 ],
281 'add' => '3.3',
282 ],
283 'modified_id' => [
284 'name' => 'modified_id',
285 'type' => CRM_Utils_Type::T_INT,
286 'title' => ts('Batch Modified By'),
287 'description' => ts('FK to Contact ID'),
288 'where' => 'civicrm_batch.modified_id',
289 'table_name' => 'civicrm_batch',
290 'entity' => 'Batch',
291 'bao' => 'CRM_Batch_BAO_Batch',
292 'localizable' => 0,
293 'FKClassName' => 'CRM_Contact_DAO_Contact',
294 'add' => '3.3',
295 ],
296 'modified_date' => [
297 'name' => 'modified_date',
298 'type' => CRM_Utils_Type::T_DATE + CRM_Utils_Type::T_TIME,
299 'title' => ts('Batch Modified Date'),
300 'description' => ts('When was this item created'),
301 'where' => 'civicrm_batch.modified_date',
302 'table_name' => 'civicrm_batch',
303 'entity' => 'Batch',
304 'bao' => 'CRM_Batch_BAO_Batch',
305 'localizable' => 0,
306 'add' => '3.3',
307 ],
308 'saved_search_id' => [
309 'name' => 'saved_search_id',
310 'type' => CRM_Utils_Type::T_INT,
311 'title' => ts('Batch Smart Group'),
312 'description' => ts('FK to Saved Search ID'),
313 'where' => 'civicrm_batch.saved_search_id',
314 'table_name' => 'civicrm_batch',
315 'entity' => 'Batch',
316 'bao' => 'CRM_Batch_BAO_Batch',
317 'localizable' => 0,
318 'FKClassName' => 'CRM_Contact_DAO_SavedSearch',
319 'html' => [
320 'type' => 'EntityRef',
321 ],
322 'add' => '4.1',
323 ],
324 'status_id' => [
325 'name' => 'status_id',
326 'type' => CRM_Utils_Type::T_INT,
327 'title' => ts('Batch Status'),
328 'description' => ts('fk to Batch Status options in civicrm_option_values'),
329 'required' => TRUE,
330 'where' => 'civicrm_batch.status_id',
331 'table_name' => 'civicrm_batch',
332 'entity' => 'Batch',
333 'bao' => 'CRM_Batch_BAO_Batch',
334 'localizable' => 0,
335 'html' => [
336 'type' => 'Select',
337 ],
338 'pseudoconstant' => [
339 'optionGroupName' => 'batch_status',
340 'optionEditPath' => 'civicrm/admin/options/batch_status',
341 ],
342 'add' => '4.2',
343 ],
344 'type_id' => [
345 'name' => 'type_id',
346 'type' => CRM_Utils_Type::T_INT,
347 'title' => ts('Batch Type'),
348 'description' => ts('fk to Batch Type options in civicrm_option_values'),
349 'where' => 'civicrm_batch.type_id',
350 'table_name' => 'civicrm_batch',
351 'entity' => 'Batch',
352 'bao' => 'CRM_Batch_BAO_Batch',
353 'localizable' => 0,
354 'html' => [
355 'type' => 'Select',
356 ],
357 'pseudoconstant' => [
358 'optionGroupName' => 'batch_type',
359 'optionEditPath' => 'civicrm/admin/options/batch_type',
360 ],
361 'add' => '4.2',
362 ],
363 'mode_id' => [
364 'name' => 'mode_id',
365 'type' => CRM_Utils_Type::T_INT,
366 'title' => ts('Batch Mode'),
367 'description' => ts('fk to Batch mode options in civicrm_option_values'),
368 'where' => 'civicrm_batch.mode_id',
369 'table_name' => 'civicrm_batch',
370 'entity' => 'Batch',
371 'bao' => 'CRM_Batch_BAO_Batch',
372 'localizable' => 0,
373 'html' => [
374 'type' => 'Select',
375 ],
376 'pseudoconstant' => [
377 'optionGroupName' => 'batch_mode',
378 'optionEditPath' => 'civicrm/admin/options/batch_mode',
379 ],
380 'add' => '4.2',
381 ],
382 'total' => [
383 'name' => 'total',
384 'type' => CRM_Utils_Type::T_MONEY,
385 'title' => ts('Batch Total'),
386 'description' => ts('Total amount for this batch.'),
387 'precision' => [
388 20,
389 2,
390 ],
391 'where' => 'civicrm_batch.total',
392 'table_name' => 'civicrm_batch',
393 'entity' => 'Batch',
394 'bao' => 'CRM_Batch_BAO_Batch',
395 'localizable' => 0,
396 'html' => [
397 'type' => 'Text',
398 ],
399 'add' => '4.2',
400 ],
401 'item_count' => [
402 'name' => 'item_count',
403 'type' => CRM_Utils_Type::T_INT,
404 'title' => ts('Batch Number of Items'),
405 'description' => ts('Number of items in a batch.'),
406 'where' => 'civicrm_batch.item_count',
407 'table_name' => 'civicrm_batch',
408 'entity' => 'Batch',
409 'bao' => 'CRM_Batch_BAO_Batch',
410 'localizable' => 0,
411 'html' => [
412 'type' => 'Text',
413 ],
414 'add' => '4.2',
415 ],
416 'payment_instrument_id' => [
417 'name' => 'payment_instrument_id',
418 'type' => CRM_Utils_Type::T_INT,
419 'title' => ts('Batch Payment Method'),
420 'description' => ts('fk to Payment Instrument options in civicrm_option_values'),
421 'where' => 'civicrm_batch.payment_instrument_id',
422 'table_name' => 'civicrm_batch',
423 'entity' => 'Batch',
424 'bao' => 'CRM_Batch_BAO_Batch',
425 'localizable' => 0,
426 'html' => [
427 'type' => 'Select',
428 ],
429 'pseudoconstant' => [
430 'optionGroupName' => 'payment_instrument',
431 'optionEditPath' => 'civicrm/admin/options/payment_instrument',
432 ],
433 'add' => '4.3',
434 ],
435 'exported_date' => [
436 'name' => 'exported_date',
437 'type' => CRM_Utils_Type::T_DATE + CRM_Utils_Type::T_TIME,
438 'title' => ts('Batch Exported Date'),
439 'where' => 'civicrm_batch.exported_date',
440 'table_name' => 'civicrm_batch',
441 'entity' => 'Batch',
442 'bao' => 'CRM_Batch_BAO_Batch',
443 'localizable' => 0,
444 'add' => '4.3',
445 ],
446 'data' => [
447 'name' => 'data',
448 'type' => CRM_Utils_Type::T_LONGTEXT,
449 'title' => ts('Batch Data'),
450 'description' => ts('cache entered data'),
451 'where' => 'civicrm_batch.data',
452 'table_name' => 'civicrm_batch',
453 'entity' => 'Batch',
454 'bao' => 'CRM_Batch_BAO_Batch',
455 'localizable' => 0,
456 'add' => '4.4',
457 ],
458 ];
459 CRM_Core_DAO_AllCoreTables::invoke(__CLASS__, 'fields_callback', Civi::$statics[__CLASS__]['fields']);
460 }
461 return Civi::$statics[__CLASS__]['fields'];
462 }
463
464 /**
465 * Return a mapping from field-name to the corresponding key (as used in fields()).
466 *
467 * @return array
468 * Array(string $name => string $uniqueName).
469 */
470 public static function &fieldKeys() {
471 if (!isset(Civi::$statics[__CLASS__]['fieldKeys'])) {
472 Civi::$statics[__CLASS__]['fieldKeys'] = array_flip(CRM_Utils_Array::collect('name', self::fields()));
473 }
474 return Civi::$statics[__CLASS__]['fieldKeys'];
475 }
476
477 /**
478 * Returns the names of this table
479 *
480 * @return string
481 */
482 public static function getTableName() {
483 return CRM_Core_DAO::getLocaleTableName(self::$_tableName);
484 }
485
486 /**
487 * Returns if this table needs to be logged
488 *
489 * @return bool
490 */
491 public function getLog() {
492 return self::$_log;
493 }
494
495 /**
496 * Returns the list of fields that can be imported
497 *
498 * @param bool $prefix
499 *
500 * @return array
501 */
502 public static function &import($prefix = FALSE) {
503 $r = CRM_Core_DAO_AllCoreTables::getImports(__CLASS__, 'batch', $prefix, []);
504 return $r;
505 }
506
507 /**
508 * Returns the list of fields that can be exported
509 *
510 * @param bool $prefix
511 *
512 * @return array
513 */
514 public static function &export($prefix = FALSE) {
515 $r = CRM_Core_DAO_AllCoreTables::getExports(__CLASS__, 'batch', $prefix, []);
516 return $r;
517 }
518
519 /**
520 * Returns the list of indices
521 *
522 * @param bool $localize
523 *
524 * @return array
525 */
526 public static function indices($localize = TRUE) {
527 $indices = [
528 'UI_name' => [
529 'name' => 'UI_name',
530 'field' => [
531 0 => 'name',
532 ],
533 'localizable' => FALSE,
534 'unique' => TRUE,
535 'sig' => 'civicrm_batch::1::name',
536 ],
537 ];
538 return ($localize && !empty($indices)) ? CRM_Core_DAO_AllCoreTables::multilingualize(__CLASS__, $indices) : $indices;
539 }
540
541 }