DAOs with singular/plural options for entity titles
[civicrm-core.git] / CRM / Member / DAO / MembershipStatus.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/Member/MembershipStatus.xml
8 * DO NOT EDIT. Generated by CRM_Core_CodeGen
7b66c3b5 9 * (GenCodeChecksum:6bdad135e9f0e94f085296d68ca59253)
e501603b 10 */
c3fc2621 11
f41f0342 12/**
c3fc2621 13 * Database access object for the MembershipStatus entity.
f41f0342 14 */
e501603b 15class CRM_Member_DAO_MembershipStatus extends CRM_Core_DAO {
929a1c14
CW
16 const EXT = 'civicrm';
17 const TABLE_ADDED = '1.5';
c3fc2621 18
e501603b 19 /**
f41f0342 20 * Static instance to hold the table name.
e501603b
TO
21 *
22 * @var string
23 */
fa45b5b9 24 public static $_tableName = 'civicrm_membership_status';
c3fc2621 25
e501603b 26 /**
f41f0342 27 * Should CiviCRM log any modifications to this table in the civicrm_log table.
e501603b 28 *
c3fc2621 29 * @var bool
e501603b 30 */
fa45b5b9 31 public static $_log = TRUE;
c3fc2621 32
e501603b
TO
33 /**
34 * Membership Id
35 *
e6ca0a57 36 * @var int
e501603b
TO
37 */
38 public $id;
c3fc2621 39
e501603b
TO
40 /**
41 * Name for Membership Status
42 *
43 * @var string
44 */
45 public $name;
c3fc2621 46
e501603b
TO
47 /**
48 * Label for Membership Status
49 *
50 * @var string
51 */
52 public $label;
c3fc2621 53
e501603b
TO
54 /**
55 * Event when this status starts.
56 *
57 * @var string
58 */
59 public $start_event;
c3fc2621 60
e501603b
TO
61 /**
62 * Unit used for adjusting from start_event.
63 *
64 * @var string
65 */
66 public $start_event_adjust_unit;
c3fc2621 67
e501603b
TO
68 /**
69 * Status range begins this many units from start_event.
70 *
71 * @var int
72 */
73 public $start_event_adjust_interval;
c3fc2621 74
e501603b
TO
75 /**
76 * Event after which this status ends.
77 *
78 * @var string
79 */
80 public $end_event;
c3fc2621 81
e501603b
TO
82 /**
83 * Unit used for adjusting from the ending event.
84 *
85 * @var string
86 */
87 public $end_event_adjust_unit;
c3fc2621 88
e501603b
TO
89 /**
90 * Status range ends this many units from end_event.
91 *
92 * @var int
93 */
94 public $end_event_adjust_interval;
c3fc2621 95
e501603b
TO
96 /**
97 * Does this status aggregate to current members (e.g. New, Renewed, Grace might all be TRUE... while Unrenewed, Lapsed, Inactive would be FALSE).
98 *
e6ca0a57 99 * @var bool
e501603b
TO
100 */
101 public $is_current_member;
c3fc2621 102
e501603b
TO
103 /**
104 * Is this status for admin/manual assignment only.
105 *
e6ca0a57 106 * @var bool
e501603b
TO
107 */
108 public $is_admin;
c3fc2621 109
e501603b 110 /**
e501603b
TO
111 * @var int
112 */
113 public $weight;
c3fc2621 114
e501603b
TO
115 /**
116 * Assign this status to a membership record if no other status match is found.
117 *
e6ca0a57 118 * @var bool
e501603b
TO
119 */
120 public $is_default;
c3fc2621 121
e501603b
TO
122 /**
123 * Is this membership_status enabled.
124 *
e6ca0a57 125 * @var bool
e501603b
TO
126 */
127 public $is_active;
c3fc2621 128
e501603b
TO
129 /**
130 * Is this membership_status reserved.
131 *
e6ca0a57 132 * @var bool
e501603b
TO
133 */
134 public $is_reserved;
c3fc2621 135
e501603b 136 /**
f41f0342 137 * Class constructor.
e501603b 138 */
c3fc2621 139 public function __construct() {
e501603b
TO
140 $this->__table = 'civicrm_membership_status';
141 parent::__construct();
142 }
c3fc2621 143
449c4e6b
CW
144 /**
145 * Returns localized title of this entity.
7b66c3b5
AH
146 *
147 * @param bool $plural
148 * Whether to return the plural version of the title.
449c4e6b 149 */
7b66c3b5
AH
150 public static function getEntityTitle($plural = FALSE) {
151 return $plural ? ts('Membership Statuses') : ts('Membership Status');
449c4e6b
CW
152 }
153
e501603b
TO
154 /**
155 * Returns all the column names of this table
156 *
157 * @return array
158 */
c3fc2621 159 public static function &fields() {
346aaaba 160 if (!isset(Civi::$statics[__CLASS__]['fields'])) {
c3fc2621
CW
161 Civi::$statics[__CLASS__]['fields'] = [
162 'id' => [
e501603b
TO
163 'name' => 'id',
164 'type' => CRM_Utils_Type::T_INT,
c3fc2621 165 'title' => ts('Membership Status ID'),
215b423e 166 'description' => ts('Membership Id'),
c3fc2621 167 'required' => TRUE,
a36434b9 168 'where' => 'civicrm_membership_status.id',
522a26c9 169 'table_name' => 'civicrm_membership_status',
170 'entity' => 'MembershipStatus',
171 'bao' => 'CRM_Member_BAO_MembershipStatus',
6a7e5e5d 172 'localizable' => 0,
a9d0587b 173 'add' => '1.5',
c3fc2621
CW
174 ],
175 'membership_status' => [
e501603b
TO
176 'name' => 'name',
177 'type' => CRM_Utils_Type::T_STRING,
c3fc2621 178 'title' => ts('Membership Status'),
215b423e 179 'description' => ts('Name for Membership Status'),
e501603b
TO
180 'maxlength' => 128,
181 'size' => CRM_Utils_Type::HUGE,
c3fc2621 182 'import' => TRUE,
e501603b 183 'where' => 'civicrm_membership_status.name',
c3fc2621 184 'export' => TRUE,
522a26c9 185 'table_name' => 'civicrm_membership_status',
186 'entity' => 'MembershipStatus',
187 'bao' => 'CRM_Member_BAO_MembershipStatus',
6a7e5e5d 188 'localizable' => 0,
a9d0587b 189 'add' => '1.5',
c3fc2621
CW
190 ],
191 'label' => [
e501603b
TO
192 'name' => 'label',
193 'type' => CRM_Utils_Type::T_STRING,
c3fc2621 194 'title' => ts('Label'),
215b423e 195 'description' => ts('Label for Membership Status'),
e501603b
TO
196 'maxlength' => 128,
197 'size' => CRM_Utils_Type::HUGE,
a36434b9 198 'where' => 'civicrm_membership_status.label',
522a26c9 199 'table_name' => 'civicrm_membership_status',
200 'entity' => 'MembershipStatus',
201 'bao' => 'CRM_Member_BAO_MembershipStatus',
6a7e5e5d 202 'localizable' => 1,
3a0ba1c5 203 'html' => [
204 'type' => 'Text',
205 ],
a9d0587b 206 'add' => '3.2',
c3fc2621
CW
207 ],
208 'start_event' => [
e501603b
TO
209 'name' => 'start_event',
210 'type' => CRM_Utils_Type::T_STRING,
c3fc2621 211 'title' => ts('Start Event'),
215b423e 212 'description' => ts('Event when this status starts.'),
e501603b
TO
213 'maxlength' => 12,
214 'size' => CRM_Utils_Type::TWELVE,
a36434b9 215 'where' => 'civicrm_membership_status.start_event',
522a26c9 216 'table_name' => 'civicrm_membership_status',
217 'entity' => 'MembershipStatus',
218 'bao' => 'CRM_Member_BAO_MembershipStatus',
6a7e5e5d 219 'localizable' => 0,
c3fc2621 220 'html' => [
e501603b 221 'type' => 'Select',
c3fc2621
CW
222 ],
223 'pseudoconstant' => [
e501603b 224 'callback' => 'CRM_Core_SelectValues::eventDate',
e6ca0a57 225 ],
a9d0587b 226 'add' => '1.5',
c3fc2621
CW
227 ],
228 'start_event_adjust_unit' => [
e501603b
TO
229 'name' => 'start_event_adjust_unit',
230 'type' => CRM_Utils_Type::T_STRING,
c3fc2621 231 'title' => ts('Start Event Adjust Unit'),
215b423e 232 'description' => ts('Unit used for adjusting from start_event.'),
e501603b
TO
233 'maxlength' => 8,
234 'size' => CRM_Utils_Type::EIGHT,
a36434b9 235 'where' => 'civicrm_membership_status.start_event_adjust_unit',
522a26c9 236 'table_name' => 'civicrm_membership_status',
237 'entity' => 'MembershipStatus',
238 'bao' => 'CRM_Member_BAO_MembershipStatus',
6a7e5e5d 239 'localizable' => 0,
c3fc2621 240 'html' => [
e501603b 241 'type' => 'Select',
c3fc2621
CW
242 ],
243 'pseudoconstant' => [
e501603b 244 'callback' => 'CRM_Core_SelectValues::unitList',
e6ca0a57 245 ],
a9d0587b 246 'add' => '1.5',
c3fc2621
CW
247 ],
248 'start_event_adjust_interval' => [
e501603b
TO
249 'name' => 'start_event_adjust_interval',
250 'type' => CRM_Utils_Type::T_INT,
c3fc2621 251 'title' => ts('Start Event Adjust Interval'),
215b423e 252 'description' => ts('Status range begins this many units from start_event.'),
a36434b9 253 'where' => 'civicrm_membership_status.start_event_adjust_interval',
522a26c9 254 'table_name' => 'civicrm_membership_status',
255 'entity' => 'MembershipStatus',
256 'bao' => 'CRM_Member_BAO_MembershipStatus',
6a7e5e5d 257 'localizable' => 0,
a9d0587b 258 'add' => '1.5',
c3fc2621
CW
259 ],
260 'end_event' => [
e501603b
TO
261 'name' => 'end_event',
262 'type' => CRM_Utils_Type::T_STRING,
c3fc2621 263 'title' => ts('End Event'),
215b423e 264 'description' => ts('Event after which this status ends.'),
e501603b
TO
265 'maxlength' => 12,
266 'size' => CRM_Utils_Type::TWELVE,
a36434b9 267 'where' => 'civicrm_membership_status.end_event',
522a26c9 268 'table_name' => 'civicrm_membership_status',
269 'entity' => 'MembershipStatus',
270 'bao' => 'CRM_Member_BAO_MembershipStatus',
6a7e5e5d 271 'localizable' => 0,
c3fc2621 272 'html' => [
e501603b 273 'type' => 'Select',
c3fc2621
CW
274 ],
275 'pseudoconstant' => [
e501603b 276 'callback' => 'CRM_Core_SelectValues::eventDate',
e6ca0a57 277 ],
a9d0587b 278 'add' => '1.5',
c3fc2621
CW
279 ],
280 'end_event_adjust_unit' => [
e501603b
TO
281 'name' => 'end_event_adjust_unit',
282 'type' => CRM_Utils_Type::T_STRING,
c3fc2621 283 'title' => ts('End Event Adjust Unit'),
215b423e 284 'description' => ts('Unit used for adjusting from the ending event.'),
e501603b
TO
285 'maxlength' => 8,
286 'size' => CRM_Utils_Type::EIGHT,
a36434b9 287 'where' => 'civicrm_membership_status.end_event_adjust_unit',
522a26c9 288 'table_name' => 'civicrm_membership_status',
289 'entity' => 'MembershipStatus',
290 'bao' => 'CRM_Member_BAO_MembershipStatus',
6a7e5e5d 291 'localizable' => 0,
c3fc2621 292 'html' => [
e501603b 293 'type' => 'Select',
c3fc2621
CW
294 ],
295 'pseudoconstant' => [
e501603b 296 'callback' => 'CRM_Core_SelectValues::unitList',
e6ca0a57 297 ],
a9d0587b 298 'add' => '1.5',
c3fc2621
CW
299 ],
300 'end_event_adjust_interval' => [
e501603b
TO
301 'name' => 'end_event_adjust_interval',
302 'type' => CRM_Utils_Type::T_INT,
c3fc2621 303 'title' => ts('End Event Adjust Interval'),
215b423e 304 'description' => ts('Status range ends this many units from end_event.'),
a36434b9 305 'where' => 'civicrm_membership_status.end_event_adjust_interval',
522a26c9 306 'table_name' => 'civicrm_membership_status',
307 'entity' => 'MembershipStatus',
308 'bao' => 'CRM_Member_BAO_MembershipStatus',
6a7e5e5d 309 'localizable' => 0,
a9d0587b 310 'add' => '1.5',
c3fc2621
CW
311 ],
312 'is_current_member' => [
e501603b
TO
313 'name' => 'is_current_member',
314 'type' => CRM_Utils_Type::T_BOOLEAN,
c3fc2621 315 'title' => ts('Current Membership?'),
215b423e 316 'description' => ts('Does this status aggregate to current members (e.g. New, Renewed, Grace might all be TRUE... while Unrenewed, Lapsed, Inactive would be FALSE).'),
a36434b9 317 'where' => 'civicrm_membership_status.is_current_member',
522a26c9 318 'table_name' => 'civicrm_membership_status',
319 'entity' => 'MembershipStatus',
320 'bao' => 'CRM_Member_BAO_MembershipStatus',
6a7e5e5d 321 'localizable' => 0,
a9d0587b 322 'add' => '1.5',
c3fc2621
CW
323 ],
324 'is_admin' => [
e501603b
TO
325 'name' => 'is_admin',
326 'type' => CRM_Utils_Type::T_BOOLEAN,
3a0ba1c5 327 'title' => ts('Administrator Only?'),
215b423e 328 'description' => ts('Is this status for admin/manual assignment only.'),
a36434b9 329 'where' => 'civicrm_membership_status.is_admin',
522a26c9 330 'table_name' => 'civicrm_membership_status',
331 'entity' => 'MembershipStatus',
332 'bao' => 'CRM_Member_BAO_MembershipStatus',
6a7e5e5d 333 'localizable' => 0,
3a0ba1c5 334 'html' => [
335 'type' => 'CheckBox',
336 ],
a9d0587b 337 'add' => '1.5',
c3fc2621
CW
338 ],
339 'weight' => [
e501603b
TO
340 'name' => 'weight',
341 'type' => CRM_Utils_Type::T_INT,
c3fc2621 342 'title' => ts('Order'),
a36434b9 343 'where' => 'civicrm_membership_status.weight',
522a26c9 344 'table_name' => 'civicrm_membership_status',
345 'entity' => 'MembershipStatus',
346 'bao' => 'CRM_Member_BAO_MembershipStatus',
6a7e5e5d 347 'localizable' => 0,
a9d0587b 348 'add' => '1.5',
c3fc2621
CW
349 ],
350 'is_default' => [
e501603b
TO
351 'name' => 'is_default',
352 'type' => CRM_Utils_Type::T_BOOLEAN,
c3fc2621 353 'title' => ts('Default Status?'),
215b423e 354 'description' => ts('Assign this status to a membership record if no other status match is found.'),
a36434b9 355 'where' => 'civicrm_membership_status.is_default',
522a26c9 356 'table_name' => 'civicrm_membership_status',
357 'entity' => 'MembershipStatus',
358 'bao' => 'CRM_Member_BAO_MembershipStatus',
6a7e5e5d 359 'localizable' => 0,
3a0ba1c5 360 'html' => [
361 'type' => 'CheckBox',
362 ],
a9d0587b 363 'add' => '1.5',
c3fc2621
CW
364 ],
365 'is_active' => [
e501603b
TO
366 'name' => 'is_active',
367 'type' => CRM_Utils_Type::T_BOOLEAN,
c3fc2621 368 'title' => ts('Is Active'),
215b423e 369 'description' => ts('Is this membership_status enabled.'),
a36434b9 370 'where' => 'civicrm_membership_status.is_active',
e501603b 371 'default' => '1',
522a26c9 372 'table_name' => 'civicrm_membership_status',
373 'entity' => 'MembershipStatus',
374 'bao' => 'CRM_Member_BAO_MembershipStatus',
6a7e5e5d 375 'localizable' => 0,
3a0ba1c5 376 'html' => [
377 'type' => 'CheckBox',
378 ],
a9d0587b 379 'add' => '1.5',
c3fc2621
CW
380 ],
381 'is_reserved' => [
e501603b
TO
382 'name' => 'is_reserved',
383 'type' => CRM_Utils_Type::T_BOOLEAN,
c3fc2621 384 'title' => ts('Is Reserved'),
215b423e 385 'description' => ts('Is this membership_status reserved.'),
a36434b9 386 'where' => 'civicrm_membership_status.is_reserved',
45a83e42 387 'default' => '0',
522a26c9 388 'table_name' => 'civicrm_membership_status',
389 'entity' => 'MembershipStatus',
390 'bao' => 'CRM_Member_BAO_MembershipStatus',
6a7e5e5d 391 'localizable' => 0,
3a0ba1c5 392 'html' => [
393 'type' => 'CheckBox',
394 ],
a9d0587b 395 'add' => '2.1',
c3fc2621
CW
396 ],
397 ];
346aaaba 398 CRM_Core_DAO_AllCoreTables::invoke(__CLASS__, 'fields_callback', Civi::$statics[__CLASS__]['fields']);
e501603b 399 }
346aaaba 400 return Civi::$statics[__CLASS__]['fields'];
e501603b 401 }
c3fc2621 402
e501603b 403 /**
bd8e0b14 404 * Return a mapping from field-name to the corresponding key (as used in fields()).
e501603b
TO
405 *
406 * @return array
bd8e0b14 407 * Array(string $name => string $uniqueName).
e501603b 408 */
c3fc2621 409 public static function &fieldKeys() {
bd8e0b14
TO
410 if (!isset(Civi::$statics[__CLASS__]['fieldKeys'])) {
411 Civi::$statics[__CLASS__]['fieldKeys'] = array_flip(CRM_Utils_Array::collect('name', self::fields()));
e501603b 412 }
bd8e0b14 413 return Civi::$statics[__CLASS__]['fieldKeys'];
e501603b 414 }
c3fc2621 415
e501603b
TO
416 /**
417 * Returns the names of this table
418 *
419 * @return string
420 */
c3fc2621 421 public static function getTableName() {
e501603b
TO
422 return CRM_Core_DAO::getLocaleTableName(self::$_tableName);
423 }
c3fc2621 424
e501603b
TO
425 /**
426 * Returns if this table needs to be logged
427 *
c3fc2621 428 * @return bool
e501603b 429 */
c3fc2621 430 public function getLog() {
e501603b
TO
431 return self::$_log;
432 }
c3fc2621 433
e501603b
TO
434 /**
435 * Returns the list of fields that can be imported
436 *
437 * @param bool $prefix
438 *
439 * @return array
440 */
c3fc2621
CW
441 public static function &import($prefix = FALSE) {
442 $r = CRM_Core_DAO_AllCoreTables::getImports(__CLASS__, 'membership_status', $prefix, []);
60808919 443 return $r;
e501603b 444 }
c3fc2621 445
e501603b
TO
446 /**
447 * Returns the list of fields that can be exported
448 *
449 * @param bool $prefix
450 *
451 * @return array
452 */
c3fc2621
CW
453 public static function &export($prefix = FALSE) {
454 $r = CRM_Core_DAO_AllCoreTables::getExports(__CLASS__, 'membership_status', $prefix, []);
60808919 455 return $r;
e501603b 456 }
c3fc2621 457
e7a6b91a
AS
458 /**
459 * Returns the list of indices
c3fc2621
CW
460 *
461 * @param bool $localize
462 *
463 * @return array
e7a6b91a
AS
464 */
465 public static function indices($localize = TRUE) {
c3fc2621 466 $indices = [];
e7a6b91a
AS
467 return ($localize && !empty($indices)) ? CRM_Core_DAO_AllCoreTables::multilingualize(__CLASS__, $indices) : $indices;
468 }
c3fc2621 469
e501603b 470}