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