| 1 | <?php |
| 2 | /* |
| 3 | +--------------------------------------------------------------------+ |
| 4 | | CiviCRM version 4.7 | |
| 5 | +--------------------------------------------------------------------+ |
| 6 | | Copyright CiviCRM LLC (c) 2004-2016 | |
| 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-2016 |
| 30 | * |
| 31 | * Generated from xml/schema/CRM/Price/LineItem.xml |
| 32 | * DO NOT EDIT. Generated by CRM_Core_CodeGen |
| 33 | * (GenCodeChecksum:5a4cae4554717aae5dd6af5572acd572) |
| 34 | */ |
| 35 | require_once 'CRM/Core/DAO.php'; |
| 36 | require_once 'CRM/Utils/Type.php'; |
| 37 | class CRM_Price_DAO_LineItem extends CRM_Core_DAO { |
| 38 | /** |
| 39 | * static instance to hold the table name |
| 40 | * |
| 41 | * @var string |
| 42 | */ |
| 43 | static $_tableName = 'civicrm_line_item'; |
| 44 | /** |
| 45 | * static instance to hold the field values |
| 46 | * |
| 47 | * @var array |
| 48 | */ |
| 49 | static $_fields = null; |
| 50 | /** |
| 51 | * static instance to hold the FK relationships |
| 52 | * |
| 53 | * @var string |
| 54 | */ |
| 55 | static $_links = null; |
| 56 | /** |
| 57 | * static value to see if we should log any modifications to |
| 58 | * this table in the civicrm_log table |
| 59 | * |
| 60 | * @var boolean |
| 61 | */ |
| 62 | static $_log = true; |
| 63 | /** |
| 64 | * Line Item |
| 65 | * |
| 66 | * @var int unsigned |
| 67 | */ |
| 68 | public $id; |
| 69 | /** |
| 70 | * table which has the transaction |
| 71 | * |
| 72 | * @var string |
| 73 | */ |
| 74 | public $entity_table; |
| 75 | /** |
| 76 | * entry in table |
| 77 | * |
| 78 | * @var int unsigned |
| 79 | */ |
| 80 | public $entity_id; |
| 81 | /** |
| 82 | * FK to civicrm_contribution |
| 83 | * |
| 84 | * @var int unsigned |
| 85 | */ |
| 86 | public $contribution_id; |
| 87 | /** |
| 88 | * FK to civicrm_price_field |
| 89 | * |
| 90 | * @var int unsigned |
| 91 | */ |
| 92 | public $price_field_id; |
| 93 | /** |
| 94 | * descriptive label for item - from price_field_value.label |
| 95 | * |
| 96 | * @var string |
| 97 | */ |
| 98 | public $label; |
| 99 | /** |
| 100 | * How many items ordered |
| 101 | * |
| 102 | * @var float |
| 103 | */ |
| 104 | public $qty; |
| 105 | /** |
| 106 | * price of each item |
| 107 | * |
| 108 | * @var float |
| 109 | */ |
| 110 | public $unit_price; |
| 111 | /** |
| 112 | * qty * unit_price |
| 113 | * |
| 114 | * @var float |
| 115 | */ |
| 116 | public $line_total; |
| 117 | /** |
| 118 | * Participant count for field |
| 119 | * |
| 120 | * @var int unsigned |
| 121 | */ |
| 122 | public $participant_count; |
| 123 | /** |
| 124 | * FK to civicrm_price_field_value |
| 125 | * |
| 126 | * @var int unsigned |
| 127 | */ |
| 128 | public $price_field_value_id; |
| 129 | /** |
| 130 | * FK to Financial Type. |
| 131 | * |
| 132 | * @var int unsigned |
| 133 | */ |
| 134 | public $financial_type_id; |
| 135 | /** |
| 136 | * Tax-deductible portion of the amount |
| 137 | * |
| 138 | * @var float |
| 139 | */ |
| 140 | public $deductible_amount; |
| 141 | /** |
| 142 | * tax of each item |
| 143 | * |
| 144 | * @var float |
| 145 | */ |
| 146 | public $tax_amount; |
| 147 | /** |
| 148 | * class constructor |
| 149 | * |
| 150 | * @return civicrm_line_item |
| 151 | */ |
| 152 | function __construct() { |
| 153 | $this->__table = 'civicrm_line_item'; |
| 154 | parent::__construct(); |
| 155 | } |
| 156 | /** |
| 157 | * Returns foreign keys and entity references |
| 158 | * |
| 159 | * @return array |
| 160 | * [CRM_Core_Reference_Interface] |
| 161 | */ |
| 162 | static function getReferenceColumns() { |
| 163 | if (!self::$_links) { |
| 164 | self::$_links = static ::createReferenceColumns(__CLASS__); |
| 165 | self::$_links[] = new CRM_Core_Reference_Basic(self::getTableName() , 'contribution_id', 'civicrm_contribution', 'id'); |
| 166 | self::$_links[] = new CRM_Core_Reference_Basic(self::getTableName() , 'price_field_id', 'civicrm_price_field', 'id'); |
| 167 | self::$_links[] = new CRM_Core_Reference_Basic(self::getTableName() , 'price_field_value_id', 'civicrm_price_field_value', 'id'); |
| 168 | self::$_links[] = new CRM_Core_Reference_Basic(self::getTableName() , 'financial_type_id', 'civicrm_financial_type', 'id'); |
| 169 | self::$_links[] = new CRM_Core_Reference_Dynamic(self::getTableName() , 'entity_id', NULL, 'id', 'entity_table'); |
| 170 | } |
| 171 | return self::$_links; |
| 172 | } |
| 173 | /** |
| 174 | * Returns all the column names of this table |
| 175 | * |
| 176 | * @return array |
| 177 | */ |
| 178 | static function &fields() { |
| 179 | if (!(self::$_fields)) { |
| 180 | self::$_fields = array( |
| 181 | 'id' => array( |
| 182 | 'name' => 'id', |
| 183 | 'type' => CRM_Utils_Type::T_INT, |
| 184 | 'title' => ts('Line Item ID') , |
| 185 | 'description' => 'Line Item', |
| 186 | 'required' => true, |
| 187 | ) , |
| 188 | 'entity_table' => array( |
| 189 | 'name' => 'entity_table', |
| 190 | 'type' => CRM_Utils_Type::T_STRING, |
| 191 | 'title' => ts('Line Item Entity Type') , |
| 192 | 'description' => 'table which has the transaction', |
| 193 | 'required' => true, |
| 194 | 'maxlength' => 64, |
| 195 | 'size' => CRM_Utils_Type::BIG, |
| 196 | ) , |
| 197 | 'entity_id' => array( |
| 198 | 'name' => 'entity_id', |
| 199 | 'type' => CRM_Utils_Type::T_INT, |
| 200 | 'title' => ts('Line Item Entity') , |
| 201 | 'description' => 'entry in table', |
| 202 | 'required' => true, |
| 203 | ) , |
| 204 | 'contribution_id' => array( |
| 205 | 'name' => 'contribution_id', |
| 206 | 'type' => CRM_Utils_Type::T_INT, |
| 207 | 'title' => ts('Line Item Contribution') , |
| 208 | 'description' => 'FK to civicrm_contribution', |
| 209 | 'FKClassName' => 'CRM_Contribute_DAO_Contribution', |
| 210 | ) , |
| 211 | 'price_field_id' => array( |
| 212 | 'name' => 'price_field_id', |
| 213 | 'type' => CRM_Utils_Type::T_INT, |
| 214 | 'title' => ts('Line Item Price Field') , |
| 215 | 'description' => 'FK to civicrm_price_field', |
| 216 | 'FKClassName' => 'CRM_Price_DAO_PriceField', |
| 217 | ) , |
| 218 | 'label' => array( |
| 219 | 'name' => 'label', |
| 220 | 'type' => CRM_Utils_Type::T_STRING, |
| 221 | 'title' => ts('Line Item Label') , |
| 222 | 'description' => 'descriptive label for item - from price_field_value.label', |
| 223 | 'maxlength' => 255, |
| 224 | 'size' => CRM_Utils_Type::HUGE, |
| 225 | 'default' => 'NULL', |
| 226 | 'html' => array( |
| 227 | 'type' => 'Text', |
| 228 | ) , |
| 229 | ) , |
| 230 | 'qty' => array( |
| 231 | 'name' => 'qty', |
| 232 | 'type' => CRM_Utils_Type::T_MONEY, |
| 233 | 'title' => ts('Line Item Quantity') , |
| 234 | 'description' => 'How many items ordered', |
| 235 | 'required' => true, |
| 236 | 'precision' => array( |
| 237 | 20, |
| 238 | 2 |
| 239 | ) , |
| 240 | 'html' => array( |
| 241 | 'type' => 'Text', |
| 242 | ) , |
| 243 | ) , |
| 244 | 'unit_price' => array( |
| 245 | 'name' => 'unit_price', |
| 246 | 'type' => CRM_Utils_Type::T_MONEY, |
| 247 | 'title' => ts('Unit Price') , |
| 248 | 'description' => 'price of each item', |
| 249 | 'required' => true, |
| 250 | 'precision' => array( |
| 251 | 20, |
| 252 | 2 |
| 253 | ) , |
| 254 | 'html' => array( |
| 255 | 'type' => 'Text', |
| 256 | ) , |
| 257 | ) , |
| 258 | 'line_total' => array( |
| 259 | 'name' => 'line_total', |
| 260 | 'type' => CRM_Utils_Type::T_MONEY, |
| 261 | 'title' => ts('Line Item Total') , |
| 262 | 'description' => 'qty * unit_price', |
| 263 | 'required' => true, |
| 264 | 'precision' => array( |
| 265 | 20, |
| 266 | 2 |
| 267 | ) , |
| 268 | ) , |
| 269 | 'participant_count' => array( |
| 270 | 'name' => 'participant_count', |
| 271 | 'type' => CRM_Utils_Type::T_INT, |
| 272 | 'title' => ts('Line Item Participant Count') , |
| 273 | 'description' => 'Participant count for field', |
| 274 | 'default' => 'NULL', |
| 275 | 'html' => array( |
| 276 | 'type' => 'Text', |
| 277 | ) , |
| 278 | ) , |
| 279 | 'price_field_value_id' => array( |
| 280 | 'name' => 'price_field_value_id', |
| 281 | 'type' => CRM_Utils_Type::T_INT, |
| 282 | 'title' => ts('Line Item Option') , |
| 283 | 'description' => 'FK to civicrm_price_field_value', |
| 284 | 'default' => 'NULL', |
| 285 | 'FKClassName' => 'CRM_Price_DAO_PriceFieldValue', |
| 286 | ) , |
| 287 | 'financial_type_id' => array( |
| 288 | 'name' => 'financial_type_id', |
| 289 | 'type' => CRM_Utils_Type::T_INT, |
| 290 | 'title' => ts('Financial Type') , |
| 291 | 'description' => 'FK to Financial Type.', |
| 292 | 'default' => 'NULL', |
| 293 | 'FKClassName' => 'CRM_Financial_DAO_FinancialType', |
| 294 | 'html' => array( |
| 295 | 'type' => 'Select', |
| 296 | ) , |
| 297 | 'pseudoconstant' => array( |
| 298 | 'table' => 'civicrm_financial_type', |
| 299 | 'keyColumn' => 'id', |
| 300 | 'labelColumn' => 'name', |
| 301 | ) |
| 302 | ) , |
| 303 | 'deductible_amount' => array( |
| 304 | 'name' => 'deductible_amount', |
| 305 | 'type' => CRM_Utils_Type::T_MONEY, |
| 306 | 'title' => ts('Deductible Amount') , |
| 307 | 'description' => 'Tax-deductible portion of the amount', |
| 308 | 'required' => true, |
| 309 | 'precision' => array( |
| 310 | 20, |
| 311 | 2 |
| 312 | ) , |
| 313 | 'default' => '0.0', |
| 314 | 'html' => array( |
| 315 | 'type' => 'Text', |
| 316 | ) , |
| 317 | ) , |
| 318 | 'tax_amount' => array( |
| 319 | 'name' => 'tax_amount', |
| 320 | 'type' => CRM_Utils_Type::T_MONEY, |
| 321 | 'title' => ts('Tax Amount') , |
| 322 | 'description' => 'tax of each item', |
| 323 | 'precision' => array( |
| 324 | 20, |
| 325 | 2 |
| 326 | ) , |
| 327 | 'import' => true, |
| 328 | 'where' => 'civicrm_line_item.tax_amount', |
| 329 | 'headerPattern' => '/tax(.?am(ou)?nt)?/i', |
| 330 | 'dataPattern' => '/^\d+(\.\d{2})?$/', |
| 331 | 'export' => true, |
| 332 | 'html' => array( |
| 333 | 'type' => 'Text', |
| 334 | ) , |
| 335 | ) , |
| 336 | ); |
| 337 | } |
| 338 | return self::$_fields; |
| 339 | } |
| 340 | /** |
| 341 | * Return a mapping from field-name to the corresponding key (as used in fields()). |
| 342 | * |
| 343 | * @return array |
| 344 | * Array(string $name => string $uniqueName). |
| 345 | */ |
| 346 | static function &fieldKeys() { |
| 347 | if (!isset(Civi::$statics[__CLASS__]['fieldKeys'])) { |
| 348 | Civi::$statics[__CLASS__]['fieldKeys'] = array_flip(CRM_Utils_Array::collect('name', self::fields())); |
| 349 | } |
| 350 | return Civi::$statics[__CLASS__]['fieldKeys']; |
| 351 | } |
| 352 | /** |
| 353 | * Returns the names of this table |
| 354 | * |
| 355 | * @return string |
| 356 | */ |
| 357 | static function getTableName() { |
| 358 | return self::$_tableName; |
| 359 | } |
| 360 | /** |
| 361 | * Returns if this table needs to be logged |
| 362 | * |
| 363 | * @return boolean |
| 364 | */ |
| 365 | function getLog() { |
| 366 | return self::$_log; |
| 367 | } |
| 368 | /** |
| 369 | * Returns the list of fields that can be imported |
| 370 | * |
| 371 | * @param bool $prefix |
| 372 | * |
| 373 | * @return array |
| 374 | */ |
| 375 | static function &import($prefix = false) { |
| 376 | $r = CRM_Core_DAO_AllCoreTables::getImports(__CLASS__, 'line_item', $prefix, array()); |
| 377 | return $r; |
| 378 | } |
| 379 | /** |
| 380 | * Returns the list of fields that can be exported |
| 381 | * |
| 382 | * @param bool $prefix |
| 383 | * |
| 384 | * @return array |
| 385 | */ |
| 386 | static function &export($prefix = false) { |
| 387 | $r = CRM_Core_DAO_AllCoreTables::getExports(__CLASS__, 'line_item', $prefix, array()); |
| 388 | return $r; |
| 389 | } |
| 390 | } |