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