| 1 | <?php |
| 2 | |
| 3 | /** |
| 4 | * @package CRM |
| 5 | * @copyright CiviCRM LLC (c) 2004-2019 |
| 6 | * |
| 7 | * Generated from xml/schema/CRM/Price/LineItem.xml |
| 8 | * DO NOT EDIT. Generated by CRM_Core_CodeGen |
| 9 | * (GenCodeChecksum:90fb6a08063f00282825bb1c567eea1a) |
| 10 | */ |
| 11 | |
| 12 | /** |
| 13 | * Database access object for the LineItem entity. |
| 14 | */ |
| 15 | class CRM_Price_DAO_LineItem extends CRM_Core_DAO { |
| 16 | |
| 17 | /** |
| 18 | * Static instance to hold the table name. |
| 19 | * |
| 20 | * @var string |
| 21 | */ |
| 22 | public static $_tableName = 'civicrm_line_item'; |
| 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 = TRUE; |
| 30 | |
| 31 | /** |
| 32 | * Line Item |
| 33 | * |
| 34 | * @var int |
| 35 | */ |
| 36 | public $id; |
| 37 | |
| 38 | /** |
| 39 | * table which has the transaction |
| 40 | * |
| 41 | * @var string |
| 42 | */ |
| 43 | public $entity_table; |
| 44 | |
| 45 | /** |
| 46 | * entry in table |
| 47 | * |
| 48 | * @var int |
| 49 | */ |
| 50 | public $entity_id; |
| 51 | |
| 52 | /** |
| 53 | * FK to civicrm_contribution |
| 54 | * |
| 55 | * @var int |
| 56 | */ |
| 57 | public $contribution_id; |
| 58 | |
| 59 | /** |
| 60 | * FK to civicrm_price_field |
| 61 | * |
| 62 | * @var int |
| 63 | */ |
| 64 | public $price_field_id; |
| 65 | |
| 66 | /** |
| 67 | * descriptive label for item - from price_field_value.label |
| 68 | * |
| 69 | * @var string |
| 70 | */ |
| 71 | public $label; |
| 72 | |
| 73 | /** |
| 74 | * How many items ordered |
| 75 | * |
| 76 | * @var float |
| 77 | */ |
| 78 | public $qty; |
| 79 | |
| 80 | /** |
| 81 | * price of each item |
| 82 | * |
| 83 | * @var float |
| 84 | */ |
| 85 | public $unit_price; |
| 86 | |
| 87 | /** |
| 88 | * qty * unit_price |
| 89 | * |
| 90 | * @var float |
| 91 | */ |
| 92 | public $line_total; |
| 93 | |
| 94 | /** |
| 95 | * Participant count for field |
| 96 | * |
| 97 | * @var int |
| 98 | */ |
| 99 | public $participant_count; |
| 100 | |
| 101 | /** |
| 102 | * FK to civicrm_price_field_value |
| 103 | * |
| 104 | * @var int |
| 105 | */ |
| 106 | public $price_field_value_id; |
| 107 | |
| 108 | /** |
| 109 | * FK to Financial Type. |
| 110 | * |
| 111 | * @var int |
| 112 | */ |
| 113 | public $financial_type_id; |
| 114 | |
| 115 | /** |
| 116 | * Portion of total amount which is NOT tax deductible. |
| 117 | * |
| 118 | * @var float |
| 119 | */ |
| 120 | public $non_deductible_amount; |
| 121 | |
| 122 | /** |
| 123 | * tax of each item |
| 124 | * |
| 125 | * @var float |
| 126 | */ |
| 127 | public $tax_amount; |
| 128 | |
| 129 | /** |
| 130 | * Class constructor. |
| 131 | */ |
| 132 | public function __construct() { |
| 133 | $this->__table = 'civicrm_line_item'; |
| 134 | parent::__construct(); |
| 135 | } |
| 136 | |
| 137 | /** |
| 138 | * Returns foreign keys and entity references. |
| 139 | * |
| 140 | * @return array |
| 141 | * [CRM_Core_Reference_Interface] |
| 142 | */ |
| 143 | public static function getReferenceColumns() { |
| 144 | if (!isset(Civi::$statics[__CLASS__]['links'])) { |
| 145 | Civi::$statics[__CLASS__]['links'] = static::createReferenceColumns(__CLASS__); |
| 146 | Civi::$statics[__CLASS__]['links'][] = new CRM_Core_Reference_Basic(self::getTableName(), 'contribution_id', 'civicrm_contribution', 'id'); |
| 147 | Civi::$statics[__CLASS__]['links'][] = new CRM_Core_Reference_Basic(self::getTableName(), 'price_field_id', 'civicrm_price_field', 'id'); |
| 148 | Civi::$statics[__CLASS__]['links'][] = new CRM_Core_Reference_Basic(self::getTableName(), 'price_field_value_id', 'civicrm_price_field_value', 'id'); |
| 149 | Civi::$statics[__CLASS__]['links'][] = new CRM_Core_Reference_Basic(self::getTableName(), 'financial_type_id', 'civicrm_financial_type', 'id'); |
| 150 | Civi::$statics[__CLASS__]['links'][] = new CRM_Core_Reference_Dynamic(self::getTableName(), 'entity_id', NULL, 'id', 'entity_table'); |
| 151 | CRM_Core_DAO_AllCoreTables::invoke(__CLASS__, 'links_callback', Civi::$statics[__CLASS__]['links']); |
| 152 | } |
| 153 | return Civi::$statics[__CLASS__]['links']; |
| 154 | } |
| 155 | |
| 156 | /** |
| 157 | * Returns all the column names of this table |
| 158 | * |
| 159 | * @return array |
| 160 | */ |
| 161 | public static function &fields() { |
| 162 | if (!isset(Civi::$statics[__CLASS__]['fields'])) { |
| 163 | Civi::$statics[__CLASS__]['fields'] = [ |
| 164 | 'id' => [ |
| 165 | 'name' => 'id', |
| 166 | 'type' => CRM_Utils_Type::T_INT, |
| 167 | 'title' => ts('Line Item ID'), |
| 168 | 'description' => ts('Line Item'), |
| 169 | 'required' => TRUE, |
| 170 | 'where' => 'civicrm_line_item.id', |
| 171 | 'table_name' => 'civicrm_line_item', |
| 172 | 'entity' => 'LineItem', |
| 173 | 'bao' => 'CRM_Price_BAO_LineItem', |
| 174 | 'localizable' => 0, |
| 175 | ], |
| 176 | 'entity_table' => [ |
| 177 | 'name' => 'entity_table', |
| 178 | 'type' => CRM_Utils_Type::T_STRING, |
| 179 | 'title' => ts('Line Item Entity Type'), |
| 180 | 'description' => ts('table which has the transaction'), |
| 181 | 'required' => TRUE, |
| 182 | 'maxlength' => 64, |
| 183 | 'size' => CRM_Utils_Type::BIG, |
| 184 | 'where' => 'civicrm_line_item.entity_table', |
| 185 | 'table_name' => 'civicrm_line_item', |
| 186 | 'entity' => 'LineItem', |
| 187 | 'bao' => 'CRM_Price_BAO_LineItem', |
| 188 | 'localizable' => 0, |
| 189 | ], |
| 190 | 'entity_id' => [ |
| 191 | 'name' => 'entity_id', |
| 192 | 'type' => CRM_Utils_Type::T_INT, |
| 193 | 'title' => ts('Line Item Entity'), |
| 194 | 'description' => ts('entry in table'), |
| 195 | 'required' => TRUE, |
| 196 | 'where' => 'civicrm_line_item.entity_id', |
| 197 | 'table_name' => 'civicrm_line_item', |
| 198 | 'entity' => 'LineItem', |
| 199 | 'bao' => 'CRM_Price_BAO_LineItem', |
| 200 | 'localizable' => 0, |
| 201 | ], |
| 202 | 'contribution_id' => [ |
| 203 | 'name' => 'contribution_id', |
| 204 | 'type' => CRM_Utils_Type::T_INT, |
| 205 | 'title' => ts('Line Item Contribution'), |
| 206 | 'description' => ts('FK to civicrm_contribution'), |
| 207 | 'where' => 'civicrm_line_item.contribution_id', |
| 208 | 'table_name' => 'civicrm_line_item', |
| 209 | 'entity' => 'LineItem', |
| 210 | 'bao' => 'CRM_Price_BAO_LineItem', |
| 211 | 'localizable' => 0, |
| 212 | 'FKClassName' => 'CRM_Contribute_DAO_Contribution', |
| 213 | ], |
| 214 | 'price_field_id' => [ |
| 215 | 'name' => 'price_field_id', |
| 216 | 'type' => CRM_Utils_Type::T_INT, |
| 217 | 'title' => ts('Line Item Price Field'), |
| 218 | 'description' => ts('FK to civicrm_price_field'), |
| 219 | 'where' => 'civicrm_line_item.price_field_id', |
| 220 | 'table_name' => 'civicrm_line_item', |
| 221 | 'entity' => 'LineItem', |
| 222 | 'bao' => 'CRM_Price_BAO_LineItem', |
| 223 | 'localizable' => 0, |
| 224 | 'FKClassName' => 'CRM_Price_DAO_PriceField', |
| 225 | ], |
| 226 | 'label' => [ |
| 227 | 'name' => 'label', |
| 228 | 'type' => CRM_Utils_Type::T_STRING, |
| 229 | 'title' => ts('Line Item Label'), |
| 230 | 'description' => ts('descriptive label for item - from price_field_value.label'), |
| 231 | 'maxlength' => 255, |
| 232 | 'size' => CRM_Utils_Type::HUGE, |
| 233 | 'where' => 'civicrm_line_item.label', |
| 234 | 'default' => 'NULL', |
| 235 | 'table_name' => 'civicrm_line_item', |
| 236 | 'entity' => 'LineItem', |
| 237 | 'bao' => 'CRM_Price_BAO_LineItem', |
| 238 | 'localizable' => 0, |
| 239 | 'html' => [ |
| 240 | 'type' => 'Text', |
| 241 | ], |
| 242 | ], |
| 243 | 'qty' => [ |
| 244 | 'name' => 'qty', |
| 245 | 'type' => CRM_Utils_Type::T_MONEY, |
| 246 | 'title' => ts('Line Item Quantity'), |
| 247 | 'description' => ts('How many items ordered'), |
| 248 | 'required' => TRUE, |
| 249 | 'precision' => [ |
| 250 | 20, |
| 251 | 2, |
| 252 | ], |
| 253 | 'where' => 'civicrm_line_item.qty', |
| 254 | 'table_name' => 'civicrm_line_item', |
| 255 | 'entity' => 'LineItem', |
| 256 | 'bao' => 'CRM_Price_BAO_LineItem', |
| 257 | 'localizable' => 0, |
| 258 | 'html' => [ |
| 259 | 'type' => 'Text', |
| 260 | ], |
| 261 | ], |
| 262 | 'unit_price' => [ |
| 263 | 'name' => 'unit_price', |
| 264 | 'type' => CRM_Utils_Type::T_MONEY, |
| 265 | 'title' => ts('Unit Price'), |
| 266 | 'description' => ts('price of each item'), |
| 267 | 'required' => TRUE, |
| 268 | 'precision' => [ |
| 269 | 20, |
| 270 | 2, |
| 271 | ], |
| 272 | 'where' => 'civicrm_line_item.unit_price', |
| 273 | 'table_name' => 'civicrm_line_item', |
| 274 | 'entity' => 'LineItem', |
| 275 | 'bao' => 'CRM_Price_BAO_LineItem', |
| 276 | 'localizable' => 0, |
| 277 | 'html' => [ |
| 278 | 'type' => 'Text', |
| 279 | ], |
| 280 | ], |
| 281 | 'line_total' => [ |
| 282 | 'name' => 'line_total', |
| 283 | 'type' => CRM_Utils_Type::T_MONEY, |
| 284 | 'title' => ts('Line Item Total'), |
| 285 | 'description' => ts('qty * unit_price'), |
| 286 | 'required' => TRUE, |
| 287 | 'precision' => [ |
| 288 | 20, |
| 289 | 2, |
| 290 | ], |
| 291 | 'where' => 'civicrm_line_item.line_total', |
| 292 | 'table_name' => 'civicrm_line_item', |
| 293 | 'entity' => 'LineItem', |
| 294 | 'bao' => 'CRM_Price_BAO_LineItem', |
| 295 | 'localizable' => 0, |
| 296 | ], |
| 297 | 'participant_count' => [ |
| 298 | 'name' => 'participant_count', |
| 299 | 'type' => CRM_Utils_Type::T_INT, |
| 300 | 'title' => ts('Line Item Participant Count'), |
| 301 | 'description' => ts('Participant count for field'), |
| 302 | 'where' => 'civicrm_line_item.participant_count', |
| 303 | 'default' => 'NULL', |
| 304 | 'table_name' => 'civicrm_line_item', |
| 305 | 'entity' => 'LineItem', |
| 306 | 'bao' => 'CRM_Price_BAO_LineItem', |
| 307 | 'localizable' => 0, |
| 308 | 'html' => [ |
| 309 | 'type' => 'Text', |
| 310 | ], |
| 311 | ], |
| 312 | 'price_field_value_id' => [ |
| 313 | 'name' => 'price_field_value_id', |
| 314 | 'type' => CRM_Utils_Type::T_INT, |
| 315 | 'title' => ts('Line Item Option'), |
| 316 | 'description' => ts('FK to civicrm_price_field_value'), |
| 317 | 'where' => 'civicrm_line_item.price_field_value_id', |
| 318 | 'default' => 'NULL', |
| 319 | 'table_name' => 'civicrm_line_item', |
| 320 | 'entity' => 'LineItem', |
| 321 | 'bao' => 'CRM_Price_BAO_LineItem', |
| 322 | 'localizable' => 0, |
| 323 | 'FKClassName' => 'CRM_Price_DAO_PriceFieldValue', |
| 324 | ], |
| 325 | 'financial_type_id' => [ |
| 326 | 'name' => 'financial_type_id', |
| 327 | 'type' => CRM_Utils_Type::T_INT, |
| 328 | 'title' => ts('Financial Type'), |
| 329 | 'description' => ts('FK to Financial Type.'), |
| 330 | 'where' => 'civicrm_line_item.financial_type_id', |
| 331 | 'default' => 'NULL', |
| 332 | 'table_name' => 'civicrm_line_item', |
| 333 | 'entity' => 'LineItem', |
| 334 | 'bao' => 'CRM_Price_BAO_LineItem', |
| 335 | 'localizable' => 0, |
| 336 | 'FKClassName' => 'CRM_Financial_DAO_FinancialType', |
| 337 | 'html' => [ |
| 338 | 'type' => 'Select', |
| 339 | ], |
| 340 | 'pseudoconstant' => [ |
| 341 | 'table' => 'civicrm_financial_type', |
| 342 | 'keyColumn' => 'id', |
| 343 | 'labelColumn' => 'name', |
| 344 | ], |
| 345 | ], |
| 346 | 'non_deductible_amount' => [ |
| 347 | 'name' => 'non_deductible_amount', |
| 348 | 'type' => CRM_Utils_Type::T_MONEY, |
| 349 | 'title' => ts('Non-deductible Amount'), |
| 350 | 'description' => ts('Portion of total amount which is NOT tax deductible.'), |
| 351 | 'required' => TRUE, |
| 352 | 'precision' => [ |
| 353 | 20, |
| 354 | 2, |
| 355 | ], |
| 356 | 'where' => 'civicrm_line_item.non_deductible_amount', |
| 357 | 'headerPattern' => '/non?.?deduct/i', |
| 358 | 'dataPattern' => '/^\d+(\.\d{2})?$/', |
| 359 | 'default' => '0.0', |
| 360 | 'table_name' => 'civicrm_line_item', |
| 361 | 'entity' => 'LineItem', |
| 362 | 'bao' => 'CRM_Price_BAO_LineItem', |
| 363 | 'localizable' => 0, |
| 364 | 'html' => [ |
| 365 | 'type' => 'Text', |
| 366 | ], |
| 367 | ], |
| 368 | 'tax_amount' => [ |
| 369 | 'name' => 'tax_amount', |
| 370 | 'type' => CRM_Utils_Type::T_MONEY, |
| 371 | 'title' => ts('Tax Amount'), |
| 372 | 'description' => ts('tax of each item'), |
| 373 | 'precision' => [ |
| 374 | 20, |
| 375 | 2, |
| 376 | ], |
| 377 | 'import' => TRUE, |
| 378 | 'where' => 'civicrm_line_item.tax_amount', |
| 379 | 'headerPattern' => '/tax(.?am(ou)?nt)?/i', |
| 380 | 'dataPattern' => '/^\d+(\.\d{2})?$/', |
| 381 | 'export' => TRUE, |
| 382 | 'table_name' => 'civicrm_line_item', |
| 383 | 'entity' => 'LineItem', |
| 384 | 'bao' => 'CRM_Price_BAO_LineItem', |
| 385 | 'localizable' => 0, |
| 386 | 'html' => [ |
| 387 | 'type' => 'Text', |
| 388 | ], |
| 389 | ], |
| 390 | ]; |
| 391 | CRM_Core_DAO_AllCoreTables::invoke(__CLASS__, 'fields_callback', Civi::$statics[__CLASS__]['fields']); |
| 392 | } |
| 393 | return Civi::$statics[__CLASS__]['fields']; |
| 394 | } |
| 395 | |
| 396 | /** |
| 397 | * Return a mapping from field-name to the corresponding key (as used in fields()). |
| 398 | * |
| 399 | * @return array |
| 400 | * Array(string $name => string $uniqueName). |
| 401 | */ |
| 402 | public static function &fieldKeys() { |
| 403 | if (!isset(Civi::$statics[__CLASS__]['fieldKeys'])) { |
| 404 | Civi::$statics[__CLASS__]['fieldKeys'] = array_flip(CRM_Utils_Array::collect('name', self::fields())); |
| 405 | } |
| 406 | return Civi::$statics[__CLASS__]['fieldKeys']; |
| 407 | } |
| 408 | |
| 409 | /** |
| 410 | * Returns the names of this table |
| 411 | * |
| 412 | * @return string |
| 413 | */ |
| 414 | public static function getTableName() { |
| 415 | return self::$_tableName; |
| 416 | } |
| 417 | |
| 418 | /** |
| 419 | * Returns if this table needs to be logged |
| 420 | * |
| 421 | * @return bool |
| 422 | */ |
| 423 | public function getLog() { |
| 424 | return self::$_log; |
| 425 | } |
| 426 | |
| 427 | /** |
| 428 | * Returns the list of fields that can be imported |
| 429 | * |
| 430 | * @param bool $prefix |
| 431 | * |
| 432 | * @return array |
| 433 | */ |
| 434 | public static function &import($prefix = FALSE) { |
| 435 | $r = CRM_Core_DAO_AllCoreTables::getImports(__CLASS__, 'line_item', $prefix, []); |
| 436 | return $r; |
| 437 | } |
| 438 | |
| 439 | /** |
| 440 | * Returns the list of fields that can be exported |
| 441 | * |
| 442 | * @param bool $prefix |
| 443 | * |
| 444 | * @return array |
| 445 | */ |
| 446 | public static function &export($prefix = FALSE) { |
| 447 | $r = CRM_Core_DAO_AllCoreTables::getExports(__CLASS__, 'line_item', $prefix, []); |
| 448 | return $r; |
| 449 | } |
| 450 | |
| 451 | /** |
| 452 | * Returns the list of indices |
| 453 | * |
| 454 | * @param bool $localize |
| 455 | * |
| 456 | * @return array |
| 457 | */ |
| 458 | public static function indices($localize = TRUE) { |
| 459 | $indices = [ |
| 460 | 'index_entity' => [ |
| 461 | 'name' => 'index_entity', |
| 462 | 'field' => [ |
| 463 | 0 => 'entity_table', |
| 464 | 1 => 'entity_id', |
| 465 | ], |
| 466 | 'localizable' => FALSE, |
| 467 | 'sig' => 'civicrm_line_item::0::entity_table::entity_id', |
| 468 | ], |
| 469 | 'UI_line_item_value' => [ |
| 470 | 'name' => 'UI_line_item_value', |
| 471 | 'field' => [ |
| 472 | 0 => 'entity_table', |
| 473 | 1 => 'entity_id', |
| 474 | 2 => 'contribution_id', |
| 475 | 3 => 'price_field_value_id', |
| 476 | 4 => 'price_field_id', |
| 477 | ], |
| 478 | 'localizable' => FALSE, |
| 479 | 'unique' => TRUE, |
| 480 | 'sig' => 'civicrm_line_item::1::entity_table::entity_id::contribution_id::price_field_value_id::price_field_id', |
| 481 | ], |
| 482 | ]; |
| 483 | return ($localize && !empty($indices)) ? CRM_Core_DAO_AllCoreTables::multilingualize(__CLASS__, $indices) : $indices; |
| 484 | } |
| 485 | |
| 486 | } |