Merge pull request #18254 from pradpnayak/casetypeselection
[civicrm-core.git] / CRM / Contact / DAO / Relationship.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/Contact/Relationship.xml
8 * DO NOT EDIT. Generated by CRM_Core_CodeGen
929a1c14 9 * (GenCodeChecksum:25faea8225f483ae95cf29af08a8542d)
e501603b 10 */
c3fc2621 11
f41f0342 12/**
c3fc2621 13 * Database access object for the Relationship entity.
f41f0342 14 */
e501603b 15class CRM_Contact_DAO_Relationship extends CRM_Core_DAO {
929a1c14
CW
16 const EXT = 'civicrm';
17 const TABLE_ADDED = '1.1';
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_relationship';
c3fc2621 25
449c4e6b
CW
26 /**
27 * Icon associated with this entity.
28 *
29 * @var string
30 */
31 public static $_icon = 'fa-handshake-o';
32
e501603b 33 /**
f41f0342 34 * Should CiviCRM log any modifications to this table in the civicrm_log table.
e501603b 35 *
c3fc2621 36 * @var bool
e501603b 37 */
fa45b5b9 38 public static $_log = TRUE;
c3fc2621 39
e501603b
TO
40 /**
41 * Relationship ID
42 *
e6ca0a57 43 * @var int
e501603b
TO
44 */
45 public $id;
c3fc2621 46
e501603b
TO
47 /**
48 * id of the first contact
49 *
e6ca0a57 50 * @var int
e501603b
TO
51 */
52 public $contact_id_a;
c3fc2621 53
e501603b
TO
54 /**
55 * id of the second contact
56 *
e6ca0a57 57 * @var int
e501603b
TO
58 */
59 public $contact_id_b;
c3fc2621 60
e501603b
TO
61 /**
62 * id of the relationship
63 *
e6ca0a57 64 * @var int
e501603b
TO
65 */
66 public $relationship_type_id;
c3fc2621 67
e501603b
TO
68 /**
69 * date when the relationship started
70 *
71 * @var date
72 */
73 public $start_date;
c3fc2621 74
e501603b
TO
75 /**
76 * date when the relationship ended
77 *
78 * @var date
79 */
80 public $end_date;
c3fc2621 81
e501603b
TO
82 /**
83 * is the relationship active ?
84 *
e6ca0a57 85 * @var bool
e501603b
TO
86 */
87 public $is_active;
c3fc2621 88
e501603b
TO
89 /**
90 * Optional verbose description for the relationship.
91 *
92 * @var string
93 */
94 public $description;
c3fc2621 95
e501603b 96 /**
f871c3a9 97 * Permission that Contact A has to view/update Contact B
e501603b 98 *
e6ca0a57 99 * @var int
e501603b
TO
100 */
101 public $is_permission_a_b;
c3fc2621 102
e501603b 103 /**
f871c3a9 104 * Permission that Contact B has to view/update Contact A
e501603b 105 *
e6ca0a57 106 * @var int
e501603b
TO
107 */
108 public $is_permission_b_a;
c3fc2621 109
e501603b
TO
110 /**
111 * FK to civicrm_case
112 *
e6ca0a57 113 * @var int
e501603b
TO
114 */
115 public $case_id;
c3fc2621 116
e501603b 117 /**
f41f0342 118 * Class constructor.
e501603b 119 */
c3fc2621 120 public function __construct() {
e501603b
TO
121 $this->__table = 'civicrm_relationship';
122 parent::__construct();
123 }
c3fc2621 124
449c4e6b
CW
125 /**
126 * Returns localized title of this entity.
127 */
128 public static function getEntityTitle() {
129 return ts('Relationships');
130 }
131
e501603b 132 /**
f41f0342 133 * Returns foreign keys and entity references.
e501603b
TO
134 *
135 * @return array
136 * [CRM_Core_Reference_Interface]
137 */
c3fc2621 138 public static function getReferenceColumns() {
346aaaba 139 if (!isset(Civi::$statics[__CLASS__]['links'])) {
fa45b5b9 140 Civi::$statics[__CLASS__]['links'] = static::createReferenceColumns(__CLASS__);
c3fc2621
CW
141 Civi::$statics[__CLASS__]['links'][] = new CRM_Core_Reference_Basic(self::getTableName(), 'contact_id_a', 'civicrm_contact', 'id');
142 Civi::$statics[__CLASS__]['links'][] = new CRM_Core_Reference_Basic(self::getTableName(), 'contact_id_b', 'civicrm_contact', 'id');
143 Civi::$statics[__CLASS__]['links'][] = new CRM_Core_Reference_Basic(self::getTableName(), 'relationship_type_id', 'civicrm_relationship_type', 'id');
144 Civi::$statics[__CLASS__]['links'][] = new CRM_Core_Reference_Basic(self::getTableName(), 'case_id', 'civicrm_case', 'id');
346aaaba 145 CRM_Core_DAO_AllCoreTables::invoke(__CLASS__, 'links_callback', Civi::$statics[__CLASS__]['links']);
e501603b 146 }
346aaaba 147 return Civi::$statics[__CLASS__]['links'];
e501603b 148 }
c3fc2621 149
e501603b
TO
150 /**
151 * Returns all the column names of this table
152 *
153 * @return array
154 */
c3fc2621 155 public static function &fields() {
346aaaba 156 if (!isset(Civi::$statics[__CLASS__]['fields'])) {
c3fc2621
CW
157 Civi::$statics[__CLASS__]['fields'] = [
158 'id' => [
e501603b
TO
159 'name' => 'id',
160 'type' => CRM_Utils_Type::T_INT,
c3fc2621 161 'title' => ts('Relationship ID'),
215b423e 162 'description' => ts('Relationship ID'),
c3fc2621 163 'required' => TRUE,
a36434b9 164 'where' => 'civicrm_relationship.id',
522a26c9 165 'table_name' => 'civicrm_relationship',
166 'entity' => 'Relationship',
167 'bao' => 'CRM_Contact_BAO_Relationship',
6a7e5e5d 168 'localizable' => 0,
a9d0587b 169 'add' => '1.1',
c3fc2621
CW
170 ],
171 'contact_id_a' => [
e501603b
TO
172 'name' => 'contact_id_a',
173 'type' => CRM_Utils_Type::T_INT,
c3fc2621 174 'title' => ts('Contact A'),
215b423e 175 'description' => ts('id of the first contact'),
c3fc2621 176 'required' => TRUE,
a36434b9 177 'where' => 'civicrm_relationship.contact_id_a',
522a26c9 178 'table_name' => 'civicrm_relationship',
179 'entity' => 'Relationship',
180 'bao' => 'CRM_Contact_BAO_Relationship',
6a7e5e5d 181 'localizable' => 0,
e501603b 182 'FKClassName' => 'CRM_Contact_DAO_Contact',
a9d0587b 183 'add' => '1.1',
c3fc2621
CW
184 ],
185 'contact_id_b' => [
e501603b
TO
186 'name' => 'contact_id_b',
187 'type' => CRM_Utils_Type::T_INT,
c3fc2621 188 'title' => ts('Contact B'),
215b423e 189 'description' => ts('id of the second contact'),
c3fc2621 190 'required' => TRUE,
a36434b9 191 'where' => 'civicrm_relationship.contact_id_b',
522a26c9 192 'table_name' => 'civicrm_relationship',
193 'entity' => 'Relationship',
194 'bao' => 'CRM_Contact_BAO_Relationship',
6a7e5e5d 195 'localizable' => 0,
e501603b 196 'FKClassName' => 'CRM_Contact_DAO_Contact',
c3fc2621 197 'html' => [
e501603b 198 'type' => 'EntityRef',
c3fc2621 199 ],
a9d0587b 200 'add' => '1.1',
c3fc2621
CW
201 ],
202 'relationship_type_id' => [
e501603b
TO
203 'name' => 'relationship_type_id',
204 'type' => CRM_Utils_Type::T_INT,
c3fc2621 205 'title' => ts('Relationship Type'),
215b423e 206 'description' => ts('id of the relationship'),
c3fc2621 207 'required' => TRUE,
a36434b9 208 'where' => 'civicrm_relationship.relationship_type_id',
522a26c9 209 'table_name' => 'civicrm_relationship',
210 'entity' => 'Relationship',
211 'bao' => 'CRM_Contact_BAO_Relationship',
6a7e5e5d 212 'localizable' => 0,
e501603b 213 'FKClassName' => 'CRM_Contact_DAO_RelationshipType',
c3fc2621 214 'html' => [
e501603b 215 'type' => 'Select',
c3fc2621 216 ],
a9d0587b 217 'add' => '1.1',
c3fc2621 218 ],
cc1b27ee 219 'relationship_start_date' => [
e501603b
TO
220 'name' => 'start_date',
221 'type' => CRM_Utils_Type::T_DATE,
c3fc2621 222 'title' => ts('Relationship Start Date'),
215b423e 223 'description' => ts('date when the relationship started'),
a36434b9 224 'where' => 'civicrm_relationship.start_date',
522a26c9 225 'table_name' => 'civicrm_relationship',
226 'entity' => 'Relationship',
227 'bao' => 'CRM_Contact_BAO_Relationship',
6a7e5e5d 228 'localizable' => 0,
c3fc2621 229 'html' => [
e501603b 230 'type' => 'Select Date',
425d6064 231 'formatType' => 'activityDate',
c3fc2621 232 ],
a9d0587b 233 'add' => '1.1',
c3fc2621 234 ],
cc1b27ee 235 'relationship_end_date' => [
e501603b
TO
236 'name' => 'end_date',
237 'type' => CRM_Utils_Type::T_DATE,
c3fc2621 238 'title' => ts('Relationship End Date'),
215b423e 239 'description' => ts('date when the relationship ended'),
a36434b9 240 'where' => 'civicrm_relationship.end_date',
522a26c9 241 'table_name' => 'civicrm_relationship',
242 'entity' => 'Relationship',
243 'bao' => 'CRM_Contact_BAO_Relationship',
6a7e5e5d 244 'localizable' => 0,
c3fc2621 245 'html' => [
e501603b 246 'type' => 'Select Date',
425d6064 247 'formatType' => 'activityDate',
c3fc2621 248 ],
a9d0587b 249 'add' => '1.1',
c3fc2621
CW
250 ],
251 'is_active' => [
e501603b
TO
252 'name' => 'is_active',
253 'type' => CRM_Utils_Type::T_BOOLEAN,
c3fc2621 254 'title' => ts('Relationship Is Active'),
215b423e 255 'description' => ts('is the relationship active ?'),
a36434b9 256 'where' => 'civicrm_relationship.is_active',
e501603b 257 'default' => '1',
522a26c9 258 'table_name' => 'civicrm_relationship',
259 'entity' => 'Relationship',
260 'bao' => 'CRM_Contact_BAO_Relationship',
6a7e5e5d 261 'localizable' => 0,
c3fc2621 262 'html' => [
e501603b 263 'type' => 'CheckBox',
c3fc2621 264 ],
a9d0587b 265 'add' => '1.1',
c3fc2621
CW
266 ],
267 'description' => [
e501603b
TO
268 'name' => 'description',
269 'type' => CRM_Utils_Type::T_STRING,
c3fc2621 270 'title' => ts('Relationship Description'),
215b423e 271 'description' => ts('Optional verbose description for the relationship.'),
e501603b
TO
272 'maxlength' => 255,
273 'size' => CRM_Utils_Type::HUGE,
a36434b9 274 'where' => 'civicrm_relationship.description',
522a26c9 275 'table_name' => 'civicrm_relationship',
276 'entity' => 'Relationship',
277 'bao' => 'CRM_Contact_BAO_Relationship',
6a7e5e5d 278 'localizable' => 0,
c3fc2621 279 'html' => [
e501603b 280 'type' => 'Text',
c3fc2621 281 ],
a9d0587b 282 'add' => '1.5',
c3fc2621
CW
283 ],
284 'is_permission_a_b' => [
e501603b 285 'name' => 'is_permission_a_b',
f871c3a9 286 'type' => CRM_Utils_Type::T_INT,
c3fc2621 287 'title' => ts('Contact A has Permission Over Contact B'),
215b423e 288 'description' => ts('Permission that Contact A has to view/update Contact B'),
f871c3a9 289 'required' => TRUE,
a36434b9 290 'where' => 'civicrm_relationship.is_permission_a_b',
45a83e42 291 'default' => '0',
522a26c9 292 'table_name' => 'civicrm_relationship',
293 'entity' => 'Relationship',
294 'bao' => 'CRM_Contact_BAO_Relationship',
6a7e5e5d 295 'localizable' => 0,
c3fc2621 296 'html' => [
f871c3a9 297 'type' => 'Radio',
c3fc2621 298 ],
f871c3a9
AS
299 'pseudoconstant' => [
300 'callback' => 'CRM_Core_SelectValues::getPermissionedRelationshipOptions',
e6ca0a57 301 ],
a9d0587b 302 'add' => '2.1',
c3fc2621
CW
303 ],
304 'is_permission_b_a' => [
e501603b 305 'name' => 'is_permission_b_a',
f871c3a9 306 'type' => CRM_Utils_Type::T_INT,
c3fc2621 307 'title' => ts('Contact B has Permission Over Contact A'),
215b423e 308 'description' => ts('Permission that Contact B has to view/update Contact A'),
f871c3a9 309 'required' => TRUE,
a36434b9 310 'where' => 'civicrm_relationship.is_permission_b_a',
45a83e42 311 'default' => '0',
522a26c9 312 'table_name' => 'civicrm_relationship',
313 'entity' => 'Relationship',
314 'bao' => 'CRM_Contact_BAO_Relationship',
6a7e5e5d 315 'localizable' => 0,
c3fc2621 316 'html' => [
f871c3a9 317 'type' => 'Radio',
c3fc2621 318 ],
f871c3a9
AS
319 'pseudoconstant' => [
320 'callback' => 'CRM_Core_SelectValues::getPermissionedRelationshipOptions',
e6ca0a57 321 ],
a9d0587b 322 'add' => '2.1',
c3fc2621
CW
323 ],
324 'case_id' => [
e501603b
TO
325 'name' => 'case_id',
326 'type' => CRM_Utils_Type::T_INT,
c3fc2621 327 'title' => ts('Relationship Case'),
215b423e 328 'description' => ts('FK to civicrm_case'),
a36434b9 329 'where' => 'civicrm_relationship.case_id',
e501603b 330 'default' => 'NULL',
522a26c9 331 'table_name' => 'civicrm_relationship',
332 'entity' => 'Relationship',
333 'bao' => 'CRM_Contact_BAO_Relationship',
6a7e5e5d 334 'localizable' => 0,
e501603b 335 'FKClassName' => 'CRM_Case_DAO_Case',
a9d0587b 336 'add' => '2.2',
c3fc2621
CW
337 ],
338 ];
346aaaba 339 CRM_Core_DAO_AllCoreTables::invoke(__CLASS__, 'fields_callback', Civi::$statics[__CLASS__]['fields']);
e501603b 340 }
346aaaba 341 return Civi::$statics[__CLASS__]['fields'];
e501603b 342 }
c3fc2621 343
e501603b 344 /**
bd8e0b14 345 * Return a mapping from field-name to the corresponding key (as used in fields()).
e501603b
TO
346 *
347 * @return array
bd8e0b14 348 * Array(string $name => string $uniqueName).
e501603b 349 */
c3fc2621 350 public static function &fieldKeys() {
bd8e0b14
TO
351 if (!isset(Civi::$statics[__CLASS__]['fieldKeys'])) {
352 Civi::$statics[__CLASS__]['fieldKeys'] = array_flip(CRM_Utils_Array::collect('name', self::fields()));
e501603b 353 }
bd8e0b14 354 return Civi::$statics[__CLASS__]['fieldKeys'];
e501603b 355 }
c3fc2621 356
e501603b
TO
357 /**
358 * Returns the names of this table
359 *
360 * @return string
361 */
c3fc2621 362 public static function getTableName() {
e501603b
TO
363 return self::$_tableName;
364 }
c3fc2621 365
e501603b
TO
366 /**
367 * Returns if this table needs to be logged
368 *
c3fc2621 369 * @return bool
e501603b 370 */
c3fc2621 371 public function getLog() {
e501603b
TO
372 return self::$_log;
373 }
c3fc2621 374
e501603b
TO
375 /**
376 * Returns the list of fields that can be imported
377 *
378 * @param bool $prefix
379 *
380 * @return array
381 */
c3fc2621
CW
382 public static function &import($prefix = FALSE) {
383 $r = CRM_Core_DAO_AllCoreTables::getImports(__CLASS__, 'relationship', $prefix, []);
60808919 384 return $r;
e501603b 385 }
c3fc2621 386
e501603b
TO
387 /**
388 * Returns the list of fields that can be exported
389 *
390 * @param bool $prefix
391 *
392 * @return array
393 */
c3fc2621
CW
394 public static function &export($prefix = FALSE) {
395 $r = CRM_Core_DAO_AllCoreTables::getExports(__CLASS__, 'relationship', $prefix, []);
60808919 396 return $r;
e501603b 397 }
c3fc2621 398
e7a6b91a
AS
399 /**
400 * Returns the list of indices
c3fc2621
CW
401 *
402 * @param bool $localize
403 *
404 * @return array
e7a6b91a
AS
405 */
406 public static function indices($localize = TRUE) {
c3fc2621 407 $indices = [];
e7a6b91a
AS
408 return ($localize && !empty($indices)) ? CRM_Core_DAO_AllCoreTables::multilingualize(__CLASS__, $indices) : $indices;
409 }
c3fc2621 410
e501603b 411}