Merge pull request #9704 from seamuslee001/CRM-19871
[civicrm-core.git] / CRM / Price / DAO / PriceField.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/Price/PriceField.xml
32 * DO NOT EDIT. Generated by CRM_Core_CodeGen
33 * (GenCodeChecksum:966d70f0e4bc5a6726beff4a9b43952c)
34 */
35 require_once 'CRM/Core/DAO.php';
36 require_once 'CRM/Utils/Type.php';
37 /**
38 * CRM_Price_DAO_PriceField constructor.
39 */
40 class CRM_Price_DAO_PriceField extends CRM_Core_DAO {
41 /**
42 * Static instance to hold the table name.
43 *
44 * @var string
45 */
46 static $_tableName = 'civicrm_price_field';
47 /**
48 * Should CiviCRM log any modifications to this table in the civicrm_log table.
49 *
50 * @var boolean
51 */
52 static $_log = true;
53 /**
54 * Price Field
55 *
56 * @var int unsigned
57 */
58 public $id;
59 /**
60 * FK to civicrm_price_set
61 *
62 * @var int unsigned
63 */
64 public $price_set_id;
65 /**
66 * Variable name/programmatic handle for this field.
67 *
68 * @var string
69 */
70 public $name;
71 /**
72 * Text for form field label (also friendly name for administering this field).
73 *
74 * @var string
75 */
76 public $label;
77 /**
78 *
79 * @var string
80 */
81 public $html_type;
82 /**
83 * Enter a quantity for this field?
84 *
85 * @var boolean
86 */
87 public $is_enter_qty;
88 /**
89 * Description and/or help text to display before this field.
90 *
91 * @var text
92 */
93 public $help_pre;
94 /**
95 * Description and/or help text to display after this field.
96 *
97 * @var text
98 */
99 public $help_post;
100 /**
101 * Order in which the fields should appear
102 *
103 * @var int
104 */
105 public $weight;
106 /**
107 * Should the price be displayed next to the label for each option?
108 *
109 * @var boolean
110 */
111 public $is_display_amounts;
112 /**
113 * number of options per line for checkbox and radio
114 *
115 * @var int unsigned
116 */
117 public $options_per_line;
118 /**
119 * Is this price field active
120 *
121 * @var boolean
122 */
123 public $is_active;
124 /**
125 * Is this price field required (value must be > 1)
126 *
127 * @var boolean
128 */
129 public $is_required;
130 /**
131 * If non-zero, do not show this field before the date specified
132 *
133 * @var datetime
134 */
135 public $active_on;
136 /**
137 * If non-zero, do not show this field after the date specified
138 *
139 * @var datetime
140 */
141 public $expire_on;
142 /**
143 * Optional scripting attributes for field
144 *
145 * @var string
146 */
147 public $javascript;
148 /**
149 * Implicit FK to civicrm_option_group with name = 'visibility'
150 *
151 * @var int unsigned
152 */
153 public $visibility_id;
154 /**
155 * Class constructor.
156 */
157 function __construct() {
158 $this->__table = 'civicrm_price_field';
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() , 'price_set_id', 'civicrm_price_set', 'id');
171 CRM_Core_DAO_AllCoreTables::invoke(__CLASS__, 'links_callback', Civi::$statics[__CLASS__]['links']);
172 }
173 return Civi::$statics[__CLASS__]['links'];
174 }
175 /**
176 * Returns all the column names of this table
177 *
178 * @return array
179 */
180 static function &fields() {
181 if (!isset(Civi::$statics[__CLASS__]['fields'])) {
182 Civi::$statics[__CLASS__]['fields'] = array(
183 'id' => array(
184 'name' => 'id',
185 'type' => CRM_Utils_Type::T_INT,
186 'title' => ts('Price Field ID') ,
187 'description' => 'Price Field',
188 'required' => true,
189 'table_name' => 'civicrm_price_field',
190 'entity' => 'PriceField',
191 'bao' => 'CRM_Price_BAO_PriceField',
192 ) ,
193 'price_set_id' => array(
194 'name' => 'price_set_id',
195 'type' => CRM_Utils_Type::T_INT,
196 'title' => ts('Price Set') ,
197 'description' => 'FK to civicrm_price_set',
198 'required' => true,
199 'table_name' => 'civicrm_price_field',
200 'entity' => 'PriceField',
201 'bao' => 'CRM_Price_BAO_PriceField',
202 'FKClassName' => 'CRM_Price_DAO_PriceSet',
203 ) ,
204 'name' => array(
205 'name' => 'name',
206 'type' => CRM_Utils_Type::T_STRING,
207 'title' => ts('Name') ,
208 'description' => 'Variable name/programmatic handle for this field.',
209 'required' => true,
210 'maxlength' => 255,
211 'size' => CRM_Utils_Type::HUGE,
212 'table_name' => 'civicrm_price_field',
213 'entity' => 'PriceField',
214 'bao' => 'CRM_Price_BAO_PriceField',
215 'html' => array(
216 'type' => 'Text',
217 ) ,
218 ) ,
219 'label' => array(
220 'name' => 'label',
221 'type' => CRM_Utils_Type::T_STRING,
222 'title' => ts('Label') ,
223 'description' => 'Text for form field label (also friendly name for administering this field).',
224 'required' => true,
225 'maxlength' => 255,
226 'size' => CRM_Utils_Type::HUGE,
227 'table_name' => 'civicrm_price_field',
228 'entity' => 'PriceField',
229 'bao' => 'CRM_Price_BAO_PriceField',
230 'html' => array(
231 'type' => 'Text',
232 ) ,
233 ) ,
234 'html_type' => array(
235 'name' => 'html_type',
236 'type' => CRM_Utils_Type::T_STRING,
237 'title' => ts('Html Type') ,
238 'required' => true,
239 'maxlength' => 12,
240 'size' => CRM_Utils_Type::TWELVE,
241 'table_name' => 'civicrm_price_field',
242 'entity' => 'PriceField',
243 'bao' => 'CRM_Price_BAO_PriceField',
244 'html' => array(
245 'type' => 'Select',
246 ) ,
247 'pseudoconstant' => array(
248 'callback' => 'CRM_Price_BAO_PriceField::htmlTypes',
249 )
250 ) ,
251 'is_enter_qty' => array(
252 'name' => 'is_enter_qty',
253 'type' => CRM_Utils_Type::T_BOOLEAN,
254 'title' => ts('Price Field Quantity Required?') ,
255 'description' => 'Enter a quantity for this field?',
256 'table_name' => 'civicrm_price_field',
257 'entity' => 'PriceField',
258 'bao' => 'CRM_Price_BAO_PriceField',
259 'html' => array(
260 'type' => 'CheckBox',
261 ) ,
262 ) ,
263 'help_pre' => array(
264 'name' => 'help_pre',
265 'type' => CRM_Utils_Type::T_TEXT,
266 'title' => ts('Price Field Pre Text') ,
267 'description' => 'Description and/or help text to display before this field.',
268 'rows' => 4,
269 'cols' => 80,
270 'table_name' => 'civicrm_price_field',
271 'entity' => 'PriceField',
272 'bao' => 'CRM_Price_BAO_PriceField',
273 'html' => array(
274 'type' => 'TextArea',
275 ) ,
276 ) ,
277 'help_post' => array(
278 'name' => 'help_post',
279 'type' => CRM_Utils_Type::T_TEXT,
280 'title' => ts('Price Field Post Text') ,
281 'description' => 'Description and/or help text to display after this field.',
282 'rows' => 4,
283 'cols' => 80,
284 'table_name' => 'civicrm_price_field',
285 'entity' => 'PriceField',
286 'bao' => 'CRM_Price_BAO_PriceField',
287 'html' => array(
288 'type' => 'TextArea',
289 ) ,
290 ) ,
291 'weight' => array(
292 'name' => 'weight',
293 'type' => CRM_Utils_Type::T_INT,
294 'title' => ts('Order') ,
295 'description' => 'Order in which the fields should appear',
296 'default' => '1',
297 'table_name' => 'civicrm_price_field',
298 'entity' => 'PriceField',
299 'bao' => 'CRM_Price_BAO_PriceField',
300 'html' => array(
301 'type' => 'Select',
302 ) ,
303 ) ,
304 'is_display_amounts' => array(
305 'name' => 'is_display_amounts',
306 'type' => CRM_Utils_Type::T_BOOLEAN,
307 'title' => ts('Price Field Show Amounts?') ,
308 'description' => 'Should the price be displayed next to the label for each option?',
309 'default' => '1',
310 'table_name' => 'civicrm_price_field',
311 'entity' => 'PriceField',
312 'bao' => 'CRM_Price_BAO_PriceField',
313 'html' => array(
314 'type' => 'CheckBox',
315 ) ,
316 ) ,
317 'options_per_line' => array(
318 'name' => 'options_per_line',
319 'type' => CRM_Utils_Type::T_INT,
320 'title' => ts('Price Field Options per Row') ,
321 'description' => 'number of options per line for checkbox and radio',
322 'default' => '1',
323 'table_name' => 'civicrm_price_field',
324 'entity' => 'PriceField',
325 'bao' => 'CRM_Price_BAO_PriceField',
326 'html' => array(
327 'type' => 'Text',
328 ) ,
329 ) ,
330 'is_active' => array(
331 'name' => 'is_active',
332 'type' => CRM_Utils_Type::T_BOOLEAN,
333 'title' => ts('Price Field Is Active?') ,
334 'description' => 'Is this price field active',
335 'default' => '1',
336 'table_name' => 'civicrm_price_field',
337 'entity' => 'PriceField',
338 'bao' => 'CRM_Price_BAO_PriceField',
339 'html' => array(
340 'type' => 'CheckBox',
341 ) ,
342 ) ,
343 'is_required' => array(
344 'name' => 'is_required',
345 'type' => CRM_Utils_Type::T_BOOLEAN,
346 'title' => ts('Price Field is Required?') ,
347 'description' => 'Is this price field required (value must be > 1)',
348 'default' => '1',
349 'table_name' => 'civicrm_price_field',
350 'entity' => 'PriceField',
351 'bao' => 'CRM_Price_BAO_PriceField',
352 'html' => array(
353 'type' => 'CheckBox',
354 ) ,
355 ) ,
356 'active_on' => array(
357 'name' => 'active_on',
358 'type' => CRM_Utils_Type::T_DATE + CRM_Utils_Type::T_TIME,
359 'title' => ts('Price Field Start Date') ,
360 'description' => 'If non-zero, do not show this field before the date specified',
361 'default' => 'NULL',
362 'table_name' => 'civicrm_price_field',
363 'entity' => 'PriceField',
364 'bao' => 'CRM_Price_BAO_PriceField',
365 'html' => array(
366 'type' => 'CheckBox',
367 ) ,
368 ) ,
369 'expire_on' => array(
370 'name' => 'expire_on',
371 'type' => CRM_Utils_Type::T_DATE + CRM_Utils_Type::T_TIME,
372 'title' => ts('Price Field End Date') ,
373 'description' => 'If non-zero, do not show this field after the date specified',
374 'default' => 'NULL',
375 'table_name' => 'civicrm_price_field',
376 'entity' => 'PriceField',
377 'bao' => 'CRM_Price_BAO_PriceField',
378 'html' => array(
379 'type' => 'Select Date',
380 ) ,
381 ) ,
382 'javascript' => array(
383 'name' => 'javascript',
384 'type' => CRM_Utils_Type::T_STRING,
385 'title' => ts('Price Field Javascript') ,
386 'description' => 'Optional scripting attributes for field',
387 'maxlength' => 255,
388 'size' => CRM_Utils_Type::HUGE,
389 'table_name' => 'civicrm_price_field',
390 'entity' => 'PriceField',
391 'bao' => 'CRM_Price_BAO_PriceField',
392 'html' => array(
393 'type' => 'Text',
394 ) ,
395 ) ,
396 'visibility_id' => array(
397 'name' => 'visibility_id',
398 'type' => CRM_Utils_Type::T_INT,
399 'title' => ts('Price Field Visibility') ,
400 'description' => 'Implicit FK to civicrm_option_group with name = \'visibility\'',
401 'default' => '1',
402 'table_name' => 'civicrm_price_field',
403 'entity' => 'PriceField',
404 'bao' => 'CRM_Price_BAO_PriceField',
405 'html' => array(
406 'type' => 'Select',
407 ) ,
408 'pseudoconstant' => array(
409 'optionGroupName' => 'visibility',
410 'optionEditPath' => 'civicrm/admin/options/visibility',
411 )
412 ) ,
413 );
414 CRM_Core_DAO_AllCoreTables::invoke(__CLASS__, 'fields_callback', Civi::$statics[__CLASS__]['fields']);
415 }
416 return Civi::$statics[__CLASS__]['fields'];
417 }
418 /**
419 * Return a mapping from field-name to the corresponding key (as used in fields()).
420 *
421 * @return array
422 * Array(string $name => string $uniqueName).
423 */
424 static function &fieldKeys() {
425 if (!isset(Civi::$statics[__CLASS__]['fieldKeys'])) {
426 Civi::$statics[__CLASS__]['fieldKeys'] = array_flip(CRM_Utils_Array::collect('name', self::fields()));
427 }
428 return Civi::$statics[__CLASS__]['fieldKeys'];
429 }
430 /**
431 * Returns the names of this table
432 *
433 * @return string
434 */
435 static function getTableName() {
436 return CRM_Core_DAO::getLocaleTableName(self::$_tableName);
437 }
438 /**
439 * Returns if this table needs to be logged
440 *
441 * @return boolean
442 */
443 function getLog() {
444 return self::$_log;
445 }
446 /**
447 * Returns the list of fields that can be imported
448 *
449 * @param bool $prefix
450 *
451 * @return array
452 */
453 static function &import($prefix = false) {
454 $r = CRM_Core_DAO_AllCoreTables::getImports(__CLASS__, 'price_field', $prefix, array());
455 return $r;
456 }
457 /**
458 * Returns the list of fields that can be exported
459 *
460 * @param bool $prefix
461 *
462 * @return array
463 */
464 static function &export($prefix = false) {
465 $r = CRM_Core_DAO_AllCoreTables::getExports(__CLASS__, 'price_field', $prefix, array());
466 return $r;
467 }
468 }