Merge pull request #11336 from eileenmcnaughton/live
[civicrm-core.git] / CRM / Batch / DAO / Batch.php
CommitLineData
e501603b 1<?php
c3fc2621 2
e501603b
TO
3/**
4 * @package CRM
8c9251b3 5 * @copyright CiviCRM LLC (c) 2004-2018
e501603b
TO
6 *
7 * Generated from xml/schema/CRM/Batch/Batch.xml
8 * DO NOT EDIT. Generated by CRM_Core_CodeGen
59ccff56 9 * (GenCodeChecksum:a9d49cd47b4a388ca88aa2af363f952d)
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 */
22 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 */
c3fc2621
CW
29 static $_log = FALSE;
30
e501603b
TO
31 /**
32 * Unique Address ID
33 *
34 * @var int unsigned
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 *
62 * @var int unsigned
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 *
76 * @var int unsigned
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 *
90 * @var int unsigned
91 */
92 public $saved_search_id;
c3fc2621 93
e501603b
TO
94 /**
95 * fk to Batch Status options in civicrm_option_values
96 *
97 * @var int unsigned
98 */
99 public $status_id;
c3fc2621 100
e501603b
TO
101 /**
102 * fk to Batch Type options in civicrm_option_values
103 *
104 * @var int unsigned
105 */
106 public $type_id;
c3fc2621 107
e501603b
TO
108 /**
109 * fk to Batch mode options in civicrm_option_values
110 *
111 * @var int unsigned
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 *
125 * @var int unsigned
126 */
127 public $item_count;
c3fc2621 128
e501603b
TO
129 /**
130 * fk to Payment Instrument options in civicrm_option_values
131 *
132 * @var int unsigned
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
e501603b 156 /**
f41f0342 157 * Returns foreign keys and entity references.
e501603b
TO
158 *
159 * @return array
160 * [CRM_Core_Reference_Interface]
161 */
c3fc2621 162 public static function getReferenceColumns() {
346aaaba
TO
163 if (!isset(Civi::$statics[__CLASS__]['links'])) {
164 Civi::$statics[__CLASS__]['links'] = static ::createReferenceColumns(__CLASS__);
c3fc2621
CW
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');
346aaaba 168 CRM_Core_DAO_AllCoreTables::invoke(__CLASS__, 'links_callback', Civi::$statics[__CLASS__]['links']);
e501603b 169 }
346aaaba 170 return Civi::$statics[__CLASS__]['links'];
e501603b 171 }
c3fc2621 172
e501603b
TO
173 /**
174 * Returns all the column names of this table
175 *
176 * @return array
177 */
c3fc2621 178 public static function &fields() {
346aaaba 179 if (!isset(Civi::$statics[__CLASS__]['fields'])) {
c3fc2621
CW
180 Civi::$statics[__CLASS__]['fields'] = [
181 'id' => [
e501603b
TO
182 'name' => 'id',
183 'type' => CRM_Utils_Type::T_INT,
c3fc2621 184 'title' => ts('Batch ID'),
e501603b 185 'description' => 'Unique Address ID',
c3fc2621 186 'required' => TRUE,
522a26c9 187 'table_name' => 'civicrm_batch',
188 'entity' => 'Batch',
189 'bao' => 'CRM_Batch_BAO_Batch',
6a7e5e5d 190 'localizable' => 0,
c3fc2621
CW
191 ],
192 'name' => [
e501603b
TO
193 'name' => 'name',
194 'type' => CRM_Utils_Type::T_STRING,
c3fc2621 195 'title' => ts('Batch Name'),
e501603b
TO
196 'description' => 'Variable name/programmatic handle for this batch.',
197 'maxlength' => 64,
198 'size' => CRM_Utils_Type::BIG,
522a26c9 199 'table_name' => 'civicrm_batch',
200 'entity' => 'Batch',
201 'bao' => 'CRM_Batch_BAO_Batch',
6a7e5e5d 202 'localizable' => 0,
c3fc2621 203 'html' => [
e501603b 204 'type' => 'Text',
c3fc2621
CW
205 ],
206 ],
207 'title' => [
e501603b
TO
208 'name' => 'title',
209 'type' => CRM_Utils_Type::T_STRING,
c3fc2621 210 'title' => ts('Batch Title'),
e501603b 211 'description' => 'Friendly Name.',
59ccff56
PN
212 'maxlength' => 255,
213 'size' => CRM_Utils_Type::HUGE,
522a26c9 214 'table_name' => 'civicrm_batch',
215 'entity' => 'Batch',
216 'bao' => 'CRM_Batch_BAO_Batch',
6a7e5e5d 217 'localizable' => 1,
c3fc2621 218 'html' => [
e501603b 219 'type' => 'Text',
c3fc2621
CW
220 ],
221 ],
222 'description' => [
e501603b
TO
223 'name' => 'description',
224 'type' => CRM_Utils_Type::T_TEXT,
c3fc2621 225 'title' => ts('Batch Description'),
e501603b
TO
226 'description' => 'Description of this batch set.',
227 'rows' => 4,
228 'cols' => 80,
522a26c9 229 'table_name' => 'civicrm_batch',
230 'entity' => 'Batch',
231 'bao' => 'CRM_Batch_BAO_Batch',
6a7e5e5d 232 'localizable' => 1,
c3fc2621 233 'html' => [
e501603b 234 'type' => 'TextArea',
c3fc2621
CW
235 ],
236 ],
237 'created_id' => [
e501603b
TO
238 'name' => 'created_id',
239 'type' => CRM_Utils_Type::T_INT,
c3fc2621 240 'title' => ts('Batch Created By'),
e501603b 241 'description' => 'FK to Contact ID',
522a26c9 242 'table_name' => 'civicrm_batch',
243 'entity' => 'Batch',
244 'bao' => 'CRM_Batch_BAO_Batch',
6a7e5e5d 245 'localizable' => 0,
e501603b 246 'FKClassName' => 'CRM_Contact_DAO_Contact',
c3fc2621
CW
247 ],
248 'created_date' => [
e501603b
TO
249 'name' => 'created_date',
250 'type' => CRM_Utils_Type::T_DATE + CRM_Utils_Type::T_TIME,
c3fc2621 251 'title' => ts('Batch Created Date'),
e501603b 252 'description' => 'When was this item created',
522a26c9 253 'table_name' => 'civicrm_batch',
254 'entity' => 'Batch',
255 'bao' => 'CRM_Batch_BAO_Batch',
6a7e5e5d 256 'localizable' => 0,
c3fc2621 257 'html' => [
e501603b 258 'type' => 'Select Date',
c3fc2621
CW
259 ],
260 ],
261 'modified_id' => [
e501603b
TO
262 'name' => 'modified_id',
263 'type' => CRM_Utils_Type::T_INT,
c3fc2621 264 'title' => ts('Batch Modified By'),
e501603b 265 'description' => 'FK to Contact ID',
522a26c9 266 'table_name' => 'civicrm_batch',
267 'entity' => 'Batch',
268 'bao' => 'CRM_Batch_BAO_Batch',
6a7e5e5d 269 'localizable' => 0,
e501603b 270 'FKClassName' => 'CRM_Contact_DAO_Contact',
c3fc2621
CW
271 ],
272 'modified_date' => [
e501603b
TO
273 'name' => 'modified_date',
274 'type' => CRM_Utils_Type::T_DATE + CRM_Utils_Type::T_TIME,
c3fc2621 275 'title' => ts('Batch Modified Date'),
e501603b 276 'description' => 'When was this item created',
522a26c9 277 'table_name' => 'civicrm_batch',
278 'entity' => 'Batch',
279 'bao' => 'CRM_Batch_BAO_Batch',
6a7e5e5d 280 'localizable' => 0,
c3fc2621
CW
281 ],
282 'saved_search_id' => [
e501603b
TO
283 'name' => 'saved_search_id',
284 'type' => CRM_Utils_Type::T_INT,
c3fc2621 285 'title' => ts('Batch Smart Group'),
e501603b 286 'description' => 'FK to Saved Search ID',
522a26c9 287 'table_name' => 'civicrm_batch',
288 'entity' => 'Batch',
289 'bao' => 'CRM_Batch_BAO_Batch',
6a7e5e5d 290 'localizable' => 0,
e501603b 291 'FKClassName' => 'CRM_Contact_DAO_SavedSearch',
c3fc2621 292 'html' => [
e501603b 293 'type' => 'EntityRef',
c3fc2621
CW
294 ],
295 ],
296 'status_id' => [
e501603b
TO
297 'name' => 'status_id',
298 'type' => CRM_Utils_Type::T_INT,
c3fc2621 299 'title' => ts('Batch Status'),
e501603b 300 'description' => 'fk to Batch Status options in civicrm_option_values',
c3fc2621 301 'required' => TRUE,
522a26c9 302 'table_name' => 'civicrm_batch',
303 'entity' => 'Batch',
304 'bao' => 'CRM_Batch_BAO_Batch',
6a7e5e5d 305 'localizable' => 0,
c3fc2621 306 'html' => [
e501603b 307 'type' => 'Select',
c3fc2621
CW
308 ],
309 'pseudoconstant' => [
e501603b
TO
310 'optionGroupName' => 'batch_status',
311 'optionEditPath' => 'civicrm/admin/options/batch_status',
c3fc2621
CW
312 ]
313 ],
314 'type_id' => [
e501603b
TO
315 'name' => 'type_id',
316 'type' => CRM_Utils_Type::T_INT,
c3fc2621 317 'title' => ts('Batch Type'),
e501603b 318 'description' => 'fk to Batch Type options in civicrm_option_values',
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_type',
328 'optionEditPath' => 'civicrm/admin/options/batch_type',
c3fc2621
CW
329 ]
330 ],
331 'mode_id' => [
e501603b
TO
332 'name' => 'mode_id',
333 'type' => CRM_Utils_Type::T_INT,
c3fc2621 334 'title' => ts('Batch Mode'),
e501603b 335 'description' => 'fk to Batch mode options in civicrm_option_values',
522a26c9 336 'table_name' => 'civicrm_batch',
337 'entity' => 'Batch',
338 'bao' => 'CRM_Batch_BAO_Batch',
6a7e5e5d 339 'localizable' => 0,
c3fc2621 340 'html' => [
e501603b 341 'type' => 'Select',
c3fc2621
CW
342 ],
343 'pseudoconstant' => [
e501603b
TO
344 'optionGroupName' => 'batch_mode',
345 'optionEditPath' => 'civicrm/admin/options/batch_mode',
c3fc2621
CW
346 ]
347 ],
348 'total' => [
e501603b
TO
349 'name' => 'total',
350 'type' => CRM_Utils_Type::T_MONEY,
c3fc2621 351 'title' => ts('Batch Total'),
e501603b 352 'description' => 'Total amount for this batch.',
c3fc2621 353 'precision' => [
e501603b
TO
354 20,
355 2
c3fc2621 356 ],
522a26c9 357 'table_name' => 'civicrm_batch',
358 'entity' => 'Batch',
359 'bao' => 'CRM_Batch_BAO_Batch',
6a7e5e5d 360 'localizable' => 0,
c3fc2621 361 'html' => [
e501603b 362 'type' => 'Text',
c3fc2621
CW
363 ],
364 ],
365 'item_count' => [
e501603b
TO
366 'name' => 'item_count',
367 'type' => CRM_Utils_Type::T_INT,
c3fc2621 368 'title' => ts('Batch Number of Items'),
e501603b 369 'description' => 'Number of items in a batch.',
522a26c9 370 'table_name' => 'civicrm_batch',
371 'entity' => 'Batch',
372 'bao' => 'CRM_Batch_BAO_Batch',
6a7e5e5d 373 'localizable' => 0,
c3fc2621 374 'html' => [
e501603b 375 'type' => 'Text',
c3fc2621
CW
376 ],
377 ],
378 'payment_instrument_id' => [
e501603b
TO
379 'name' => 'payment_instrument_id',
380 'type' => CRM_Utils_Type::T_INT,
c3fc2621 381 'title' => ts('Batch Payment Method'),
e501603b 382 'description' => 'fk to Payment Instrument options in civicrm_option_values',
522a26c9 383 'table_name' => 'civicrm_batch',
384 'entity' => 'Batch',
385 'bao' => 'CRM_Batch_BAO_Batch',
6a7e5e5d 386 'localizable' => 0,
c3fc2621 387 'html' => [
e501603b 388 'type' => 'Select',
c3fc2621
CW
389 ],
390 'pseudoconstant' => [
e501603b
TO
391 'optionGroupName' => 'payment_instrument',
392 'optionEditPath' => 'civicrm/admin/options/payment_instrument',
c3fc2621
CW
393 ]
394 ],
395 'exported_date' => [
e501603b
TO
396 'name' => 'exported_date',
397 'type' => CRM_Utils_Type::T_DATE + CRM_Utils_Type::T_TIME,
c3fc2621 398 'title' => ts('Batch Exported Date'),
522a26c9 399 'table_name' => 'civicrm_batch',
400 'entity' => 'Batch',
401 'bao' => 'CRM_Batch_BAO_Batch',
6a7e5e5d 402 'localizable' => 0,
c3fc2621
CW
403 ],
404 'data' => [
e501603b
TO
405 'name' => 'data',
406 'type' => CRM_Utils_Type::T_LONGTEXT,
c3fc2621 407 'title' => ts('Batch Data'),
e501603b 408 'description' => 'cache entered data',
522a26c9 409 'table_name' => 'civicrm_batch',
410 'entity' => 'Batch',
411 'bao' => 'CRM_Batch_BAO_Batch',
6a7e5e5d 412 'localizable' => 0,
c3fc2621
CW
413 ],
414 ];
346aaaba 415 CRM_Core_DAO_AllCoreTables::invoke(__CLASS__, 'fields_callback', Civi::$statics[__CLASS__]['fields']);
e501603b 416 }
346aaaba 417 return Civi::$statics[__CLASS__]['fields'];
e501603b 418 }
c3fc2621 419
e501603b 420 /**
bd8e0b14 421 * Return a mapping from field-name to the corresponding key (as used in fields()).
e501603b
TO
422 *
423 * @return array
bd8e0b14 424 * Array(string $name => string $uniqueName).
e501603b 425 */
c3fc2621 426 public static function &fieldKeys() {
bd8e0b14
TO
427 if (!isset(Civi::$statics[__CLASS__]['fieldKeys'])) {
428 Civi::$statics[__CLASS__]['fieldKeys'] = array_flip(CRM_Utils_Array::collect('name', self::fields()));
e501603b 429 }
bd8e0b14 430 return Civi::$statics[__CLASS__]['fieldKeys'];
e501603b 431 }
c3fc2621 432
e501603b
TO
433 /**
434 * Returns the names of this table
435 *
436 * @return string
437 */
c3fc2621 438 public static function getTableName() {
e501603b
TO
439 return CRM_Core_DAO::getLocaleTableName(self::$_tableName);
440 }
c3fc2621 441
e501603b
TO
442 /**
443 * Returns if this table needs to be logged
444 *
c3fc2621 445 * @return bool
e501603b 446 */
c3fc2621 447 public function getLog() {
e501603b
TO
448 return self::$_log;
449 }
c3fc2621 450
e501603b
TO
451 /**
452 * Returns the list of fields that can be imported
453 *
454 * @param bool $prefix
455 *
456 * @return array
457 */
c3fc2621
CW
458 public static function &import($prefix = FALSE) {
459 $r = CRM_Core_DAO_AllCoreTables::getImports(__CLASS__, 'batch', $prefix, []);
60808919 460 return $r;
e501603b 461 }
c3fc2621 462
e501603b
TO
463 /**
464 * Returns the list of fields that can be exported
465 *
466 * @param bool $prefix
467 *
468 * @return array
469 */
c3fc2621
CW
470 public static function &export($prefix = FALSE) {
471 $r = CRM_Core_DAO_AllCoreTables::getExports(__CLASS__, 'batch', $prefix, []);
60808919 472 return $r;
e501603b 473 }
c3fc2621 474
e7a6b91a
AS
475 /**
476 * Returns the list of indices
c3fc2621
CW
477 *
478 * @param bool $localize
479 *
480 * @return array
e7a6b91a
AS
481 */
482 public static function indices($localize = TRUE) {
c3fc2621
CW
483 $indices = [
484 'UI_name' => [
e7a6b91a 485 'name' => 'UI_name',
c3fc2621 486 'field' => [
e7a6b91a 487 0 => 'name',
c3fc2621
CW
488 ],
489 'localizable' => FALSE,
490 'unique' => TRUE,
e7a6b91a 491 'sig' => 'civicrm_batch::1::name',
c3fc2621
CW
492 ],
493 ];
e7a6b91a
AS
494 return ($localize && !empty($indices)) ? CRM_Core_DAO_AllCoreTables::multilingualize(__CLASS__, $indices) : $indices;
495 }
c3fc2621 496
e501603b 497}