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