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