| 1 | <?php |
| 2 | |
| 3 | /** |
| 4 | * @package CRM |
| 5 | * @copyright CiviCRM LLC (c) 2004-2020 |
| 6 | * |
| 7 | * Generated from xml/schema/CRM/Contribute/Product.xml |
| 8 | * DO NOT EDIT. Generated by CRM_Core_CodeGen |
| 9 | * (GenCodeChecksum:8036ec1084e88e8fcd65e69072592388) |
| 10 | */ |
| 11 | |
| 12 | /** |
| 13 | * Database access object for the Product entity. |
| 14 | */ |
| 15 | class CRM_Contribute_DAO_Product extends CRM_Core_DAO { |
| 16 | |
| 17 | /** |
| 18 | * Static instance to hold the table name. |
| 19 | * |
| 20 | * @var string |
| 21 | */ |
| 22 | public static $_tableName = 'civicrm_product'; |
| 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 | * @var int |
| 33 | */ |
| 34 | public $id; |
| 35 | |
| 36 | /** |
| 37 | * Required product/premium name |
| 38 | * |
| 39 | * @var string |
| 40 | */ |
| 41 | public $name; |
| 42 | |
| 43 | /** |
| 44 | * Optional description of the product/premium. |
| 45 | * |
| 46 | * @var text |
| 47 | */ |
| 48 | public $description; |
| 49 | |
| 50 | /** |
| 51 | * Optional product sku or code. |
| 52 | * |
| 53 | * @var string |
| 54 | */ |
| 55 | public $sku; |
| 56 | |
| 57 | /** |
| 58 | * Store comma-delimited list of color, size, etc. options for the product. |
| 59 | * |
| 60 | * @var text |
| 61 | */ |
| 62 | public $options; |
| 63 | |
| 64 | /** |
| 65 | * Full or relative URL to uploaded image - fullsize. |
| 66 | * |
| 67 | * @var string |
| 68 | */ |
| 69 | public $image; |
| 70 | |
| 71 | /** |
| 72 | * Full or relative URL to image thumbnail. |
| 73 | * |
| 74 | * @var string |
| 75 | */ |
| 76 | public $thumbnail; |
| 77 | |
| 78 | /** |
| 79 | * Sell price or market value for premiums. For tax-deductible contributions, this will be stored as non_deductible_amount in the contribution record. |
| 80 | * |
| 81 | * @var float |
| 82 | */ |
| 83 | public $price; |
| 84 | |
| 85 | /** |
| 86 | * 3 character string, value from config setting or input via user. |
| 87 | * |
| 88 | * @var string |
| 89 | */ |
| 90 | public $currency; |
| 91 | |
| 92 | /** |
| 93 | * FK to Financial Type. |
| 94 | * |
| 95 | * @var int |
| 96 | */ |
| 97 | public $financial_type_id; |
| 98 | |
| 99 | /** |
| 100 | * Minimum contribution required to be eligible to select this premium. |
| 101 | * |
| 102 | * @var float |
| 103 | */ |
| 104 | public $min_contribution; |
| 105 | |
| 106 | /** |
| 107 | * Actual cost of this product. Useful to determine net return from sale or using this as an incentive. |
| 108 | * |
| 109 | * @var float |
| 110 | */ |
| 111 | public $cost; |
| 112 | |
| 113 | /** |
| 114 | * Disabling premium removes it from the premiums_premium join table below. |
| 115 | * |
| 116 | * @var bool |
| 117 | */ |
| 118 | public $is_active; |
| 119 | |
| 120 | /** |
| 121 | * Rolling means we set start/end based on current day, fixed means we set start/end for current year or month |
| 122 | * (e.g. 1 year + fixed -> we would set start/end for 1/1/06 thru 12/31/06 for any premium chosen in 2006) |
| 123 | * |
| 124 | * @var string |
| 125 | */ |
| 126 | public $period_type; |
| 127 | |
| 128 | /** |
| 129 | * Month and day (MMDD) that fixed period type subscription or membership starts. |
| 130 | * |
| 131 | * @var int |
| 132 | */ |
| 133 | public $fixed_period_start_day; |
| 134 | |
| 135 | /** |
| 136 | * @var string |
| 137 | */ |
| 138 | public $duration_unit; |
| 139 | |
| 140 | /** |
| 141 | * Number of units for total duration of subscription, service, membership (e.g. 12 Months). |
| 142 | * |
| 143 | * @var int |
| 144 | */ |
| 145 | public $duration_interval; |
| 146 | |
| 147 | /** |
| 148 | * Frequency unit and interval allow option to store actual delivery frequency for a subscription or service. |
| 149 | * |
| 150 | * @var string |
| 151 | */ |
| 152 | public $frequency_unit; |
| 153 | |
| 154 | /** |
| 155 | * Number of units for delivery frequency of subscription, service, membership (e.g. every 3 Months). |
| 156 | * |
| 157 | * @var int |
| 158 | */ |
| 159 | public $frequency_interval; |
| 160 | |
| 161 | /** |
| 162 | * Class constructor. |
| 163 | */ |
| 164 | public function __construct() { |
| 165 | $this->__table = 'civicrm_product'; |
| 166 | parent::__construct(); |
| 167 | } |
| 168 | |
| 169 | /** |
| 170 | * Returns foreign keys and entity references. |
| 171 | * |
| 172 | * @return array |
| 173 | * [CRM_Core_Reference_Interface] |
| 174 | */ |
| 175 | public static function getReferenceColumns() { |
| 176 | if (!isset(Civi::$statics[__CLASS__]['links'])) { |
| 177 | Civi::$statics[__CLASS__]['links'] = static::createReferenceColumns(__CLASS__); |
| 178 | Civi::$statics[__CLASS__]['links'][] = new CRM_Core_Reference_Basic(self::getTableName(), 'financial_type_id', 'civicrm_financial_type', 'id'); |
| 179 | CRM_Core_DAO_AllCoreTables::invoke(__CLASS__, 'links_callback', Civi::$statics[__CLASS__]['links']); |
| 180 | } |
| 181 | return Civi::$statics[__CLASS__]['links']; |
| 182 | } |
| 183 | |
| 184 | /** |
| 185 | * Returns all the column names of this table |
| 186 | * |
| 187 | * @return array |
| 188 | */ |
| 189 | public static function &fields() { |
| 190 | if (!isset(Civi::$statics[__CLASS__]['fields'])) { |
| 191 | Civi::$statics[__CLASS__]['fields'] = [ |
| 192 | 'id' => [ |
| 193 | 'name' => 'id', |
| 194 | 'type' => CRM_Utils_Type::T_INT, |
| 195 | 'title' => ts('Product ID'), |
| 196 | 'required' => TRUE, |
| 197 | 'where' => 'civicrm_product.id', |
| 198 | 'table_name' => 'civicrm_product', |
| 199 | 'entity' => 'Product', |
| 200 | 'bao' => 'CRM_Contribute_BAO_Product', |
| 201 | 'localizable' => 0, |
| 202 | ], |
| 203 | 'product_name' => [ |
| 204 | 'name' => 'name', |
| 205 | 'type' => CRM_Utils_Type::T_STRING, |
| 206 | 'title' => ts('Product Name'), |
| 207 | 'description' => ts('Required product/premium name'), |
| 208 | 'required' => TRUE, |
| 209 | 'maxlength' => 255, |
| 210 | 'size' => CRM_Utils_Type::HUGE, |
| 211 | 'where' => 'civicrm_product.name', |
| 212 | 'export' => TRUE, |
| 213 | 'table_name' => 'civicrm_product', |
| 214 | 'entity' => 'Product', |
| 215 | 'bao' => 'CRM_Contribute_BAO_Product', |
| 216 | 'localizable' => 1, |
| 217 | ], |
| 218 | 'description' => [ |
| 219 | 'name' => 'description', |
| 220 | 'type' => CRM_Utils_Type::T_TEXT, |
| 221 | 'title' => ts('Description'), |
| 222 | 'description' => ts('Optional description of the product/premium.'), |
| 223 | 'where' => 'civicrm_product.description', |
| 224 | 'table_name' => 'civicrm_product', |
| 225 | 'entity' => 'Product', |
| 226 | 'bao' => 'CRM_Contribute_BAO_Product', |
| 227 | 'localizable' => 1, |
| 228 | ], |
| 229 | 'sku' => [ |
| 230 | 'name' => 'sku', |
| 231 | 'type' => CRM_Utils_Type::T_STRING, |
| 232 | 'title' => ts('SKU'), |
| 233 | 'description' => ts('Optional product sku or code.'), |
| 234 | 'maxlength' => 50, |
| 235 | 'size' => CRM_Utils_Type::BIG, |
| 236 | 'where' => 'civicrm_product.sku', |
| 237 | 'export' => TRUE, |
| 238 | 'table_name' => 'civicrm_product', |
| 239 | 'entity' => 'Product', |
| 240 | 'bao' => 'CRM_Contribute_BAO_Product', |
| 241 | 'localizable' => 0, |
| 242 | ], |
| 243 | 'options' => [ |
| 244 | 'name' => 'options', |
| 245 | 'type' => CRM_Utils_Type::T_TEXT, |
| 246 | 'title' => ts('Options'), |
| 247 | 'description' => ts('Store comma-delimited list of color, size, etc. options for the product.'), |
| 248 | 'where' => 'civicrm_product.options', |
| 249 | 'table_name' => 'civicrm_product', |
| 250 | 'entity' => 'Product', |
| 251 | 'bao' => 'CRM_Contribute_BAO_Product', |
| 252 | 'localizable' => 1, |
| 253 | ], |
| 254 | 'image' => [ |
| 255 | 'name' => 'image', |
| 256 | 'type' => CRM_Utils_Type::T_STRING, |
| 257 | 'title' => ts('Image'), |
| 258 | 'description' => ts('Full or relative URL to uploaded image - fullsize.'), |
| 259 | 'maxlength' => 255, |
| 260 | 'size' => CRM_Utils_Type::HUGE, |
| 261 | 'where' => 'civicrm_product.image', |
| 262 | 'table_name' => 'civicrm_product', |
| 263 | 'entity' => 'Product', |
| 264 | 'bao' => 'CRM_Contribute_BAO_Product', |
| 265 | 'localizable' => 0, |
| 266 | ], |
| 267 | 'thumbnail' => [ |
| 268 | 'name' => 'thumbnail', |
| 269 | 'type' => CRM_Utils_Type::T_STRING, |
| 270 | 'title' => ts('Thumbnail'), |
| 271 | 'description' => ts('Full or relative URL to image thumbnail.'), |
| 272 | 'maxlength' => 255, |
| 273 | 'size' => CRM_Utils_Type::HUGE, |
| 274 | 'where' => 'civicrm_product.thumbnail', |
| 275 | 'table_name' => 'civicrm_product', |
| 276 | 'entity' => 'Product', |
| 277 | 'bao' => 'CRM_Contribute_BAO_Product', |
| 278 | 'localizable' => 0, |
| 279 | ], |
| 280 | 'price' => [ |
| 281 | 'name' => 'price', |
| 282 | 'type' => CRM_Utils_Type::T_MONEY, |
| 283 | 'title' => ts('Price'), |
| 284 | 'description' => ts('Sell price or market value for premiums. For tax-deductible contributions, this will be stored as non_deductible_amount in the contribution record.'), |
| 285 | 'precision' => [ |
| 286 | 20, |
| 287 | 2, |
| 288 | ], |
| 289 | 'where' => 'civicrm_product.price', |
| 290 | 'table_name' => 'civicrm_product', |
| 291 | 'entity' => 'Product', |
| 292 | 'bao' => 'CRM_Contribute_BAO_Product', |
| 293 | 'localizable' => 0, |
| 294 | ], |
| 295 | 'currency' => [ |
| 296 | 'name' => 'currency', |
| 297 | 'type' => CRM_Utils_Type::T_STRING, |
| 298 | 'title' => ts('Currency'), |
| 299 | 'description' => ts('3 character string, value from config setting or input via user.'), |
| 300 | 'maxlength' => 3, |
| 301 | 'size' => CRM_Utils_Type::FOUR, |
| 302 | 'where' => 'civicrm_product.currency', |
| 303 | 'default' => 'NULL', |
| 304 | 'table_name' => 'civicrm_product', |
| 305 | 'entity' => 'Product', |
| 306 | 'bao' => 'CRM_Contribute_BAO_Product', |
| 307 | 'localizable' => 0, |
| 308 | 'html' => [ |
| 309 | 'type' => 'Select', |
| 310 | ], |
| 311 | 'pseudoconstant' => [ |
| 312 | 'table' => 'civicrm_currency', |
| 313 | 'keyColumn' => 'name', |
| 314 | 'labelColumn' => 'full_name', |
| 315 | 'nameColumn' => 'name', |
| 316 | 'abbrColumn' => 'symbol', |
| 317 | ], |
| 318 | ], |
| 319 | 'financial_type_id' => [ |
| 320 | 'name' => 'financial_type_id', |
| 321 | 'type' => CRM_Utils_Type::T_INT, |
| 322 | 'title' => ts('Financial Type'), |
| 323 | 'description' => ts('FK to Financial Type.'), |
| 324 | 'where' => 'civicrm_product.financial_type_id', |
| 325 | 'default' => 'NULL', |
| 326 | 'table_name' => 'civicrm_product', |
| 327 | 'entity' => 'Product', |
| 328 | 'bao' => 'CRM_Contribute_BAO_Product', |
| 329 | 'localizable' => 0, |
| 330 | 'FKClassName' => 'CRM_Financial_DAO_FinancialType', |
| 331 | 'pseudoconstant' => [ |
| 332 | 'table' => 'civicrm_financial_type', |
| 333 | 'keyColumn' => 'id', |
| 334 | 'labelColumn' => 'name', |
| 335 | ], |
| 336 | ], |
| 337 | 'min_contribution' => [ |
| 338 | 'name' => 'min_contribution', |
| 339 | 'type' => CRM_Utils_Type::T_MONEY, |
| 340 | 'title' => ts('Minimum Contribution'), |
| 341 | 'description' => ts('Minimum contribution required to be eligible to select this premium.'), |
| 342 | 'precision' => [ |
| 343 | 20, |
| 344 | 2, |
| 345 | ], |
| 346 | 'where' => 'civicrm_product.min_contribution', |
| 347 | 'table_name' => 'civicrm_product', |
| 348 | 'entity' => 'Product', |
| 349 | 'bao' => 'CRM_Contribute_BAO_Product', |
| 350 | 'localizable' => 0, |
| 351 | ], |
| 352 | 'cost' => [ |
| 353 | 'name' => 'cost', |
| 354 | 'type' => CRM_Utils_Type::T_MONEY, |
| 355 | 'title' => ts('Cost'), |
| 356 | 'description' => ts('Actual cost of this product. Useful to determine net return from sale or using this as an incentive.'), |
| 357 | 'precision' => [ |
| 358 | 20, |
| 359 | 2, |
| 360 | ], |
| 361 | 'where' => 'civicrm_product.cost', |
| 362 | 'table_name' => 'civicrm_product', |
| 363 | 'entity' => 'Product', |
| 364 | 'bao' => 'CRM_Contribute_BAO_Product', |
| 365 | 'localizable' => 0, |
| 366 | ], |
| 367 | 'is_active' => [ |
| 368 | 'name' => 'is_active', |
| 369 | 'type' => CRM_Utils_Type::T_BOOLEAN, |
| 370 | 'title' => ts('Is Active'), |
| 371 | 'description' => ts('Disabling premium removes it from the premiums_premium join table below.'), |
| 372 | 'required' => TRUE, |
| 373 | 'where' => 'civicrm_product.is_active', |
| 374 | 'table_name' => 'civicrm_product', |
| 375 | 'entity' => 'Product', |
| 376 | 'bao' => 'CRM_Contribute_BAO_Product', |
| 377 | 'localizable' => 0, |
| 378 | ], |
| 379 | 'period_type' => [ |
| 380 | 'name' => 'period_type', |
| 381 | 'type' => CRM_Utils_Type::T_STRING, |
| 382 | 'title' => ts('Period Type'), |
| 383 | 'description' => ts('Rolling means we set start/end based on current day, fixed means we set start/end for current year or month |
| 384 | (e.g. 1 year + fixed -> we would set start/end for 1/1/06 thru 12/31/06 for any premium chosen in 2006) '), |
| 385 | 'maxlength' => 8, |
| 386 | 'size' => CRM_Utils_Type::EIGHT, |
| 387 | 'where' => 'civicrm_product.period_type', |
| 388 | 'default' => 'rolling', |
| 389 | 'table_name' => 'civicrm_product', |
| 390 | 'entity' => 'Product', |
| 391 | 'bao' => 'CRM_Contribute_BAO_Product', |
| 392 | 'localizable' => 0, |
| 393 | 'html' => [ |
| 394 | 'type' => 'Select', |
| 395 | ], |
| 396 | 'pseudoconstant' => [ |
| 397 | 'callback' => 'CRM_Core_SelectValues::periodType', |
| 398 | ], |
| 399 | ], |
| 400 | 'fixed_period_start_day' => [ |
| 401 | 'name' => 'fixed_period_start_day', |
| 402 | 'type' => CRM_Utils_Type::T_INT, |
| 403 | 'title' => ts('Fixed Period Start Day'), |
| 404 | 'description' => ts('Month and day (MMDD) that fixed period type subscription or membership starts.'), |
| 405 | 'where' => 'civicrm_product.fixed_period_start_day', |
| 406 | 'default' => '0101', |
| 407 | 'table_name' => 'civicrm_product', |
| 408 | 'entity' => 'Product', |
| 409 | 'bao' => 'CRM_Contribute_BAO_Product', |
| 410 | 'localizable' => 0, |
| 411 | ], |
| 412 | 'duration_unit' => [ |
| 413 | 'name' => 'duration_unit', |
| 414 | 'type' => CRM_Utils_Type::T_STRING, |
| 415 | 'title' => ts('Duration Unit'), |
| 416 | 'maxlength' => 8, |
| 417 | 'size' => CRM_Utils_Type::EIGHT, |
| 418 | 'where' => 'civicrm_product.duration_unit', |
| 419 | 'default' => 'year', |
| 420 | 'table_name' => 'civicrm_product', |
| 421 | 'entity' => 'Product', |
| 422 | 'bao' => 'CRM_Contribute_BAO_Product', |
| 423 | 'localizable' => 0, |
| 424 | 'html' => [ |
| 425 | 'type' => 'Select', |
| 426 | ], |
| 427 | 'pseudoconstant' => [ |
| 428 | 'callback' => 'CRM_Core_SelectValues::getPremiumUnits', |
| 429 | ], |
| 430 | ], |
| 431 | 'duration_interval' => [ |
| 432 | 'name' => 'duration_interval', |
| 433 | 'type' => CRM_Utils_Type::T_INT, |
| 434 | 'title' => ts('Duration Interval'), |
| 435 | 'description' => ts('Number of units for total duration of subscription, service, membership (e.g. 12 Months).'), |
| 436 | 'where' => 'civicrm_product.duration_interval', |
| 437 | 'table_name' => 'civicrm_product', |
| 438 | 'entity' => 'Product', |
| 439 | 'bao' => 'CRM_Contribute_BAO_Product', |
| 440 | 'localizable' => 0, |
| 441 | ], |
| 442 | 'frequency_unit' => [ |
| 443 | 'name' => 'frequency_unit', |
| 444 | 'type' => CRM_Utils_Type::T_STRING, |
| 445 | 'title' => ts('Frequency Unit'), |
| 446 | 'description' => ts('Frequency unit and interval allow option to store actual delivery frequency for a subscription or service.'), |
| 447 | 'maxlength' => 8, |
| 448 | 'size' => CRM_Utils_Type::EIGHT, |
| 449 | 'where' => 'civicrm_product.frequency_unit', |
| 450 | 'default' => 'month', |
| 451 | 'table_name' => 'civicrm_product', |
| 452 | 'entity' => 'Product', |
| 453 | 'bao' => 'CRM_Contribute_BAO_Product', |
| 454 | 'localizable' => 0, |
| 455 | 'html' => [ |
| 456 | 'type' => 'Select', |
| 457 | ], |
| 458 | 'pseudoconstant' => [ |
| 459 | 'callback' => 'CRM_Core_SelectValues::getPremiumUnits', |
| 460 | ], |
| 461 | ], |
| 462 | 'frequency_interval' => [ |
| 463 | 'name' => 'frequency_interval', |
| 464 | 'type' => CRM_Utils_Type::T_INT, |
| 465 | 'title' => ts('Frequency Interval'), |
| 466 | 'description' => ts('Number of units for delivery frequency of subscription, service, membership (e.g. every 3 Months).'), |
| 467 | 'where' => 'civicrm_product.frequency_interval', |
| 468 | 'table_name' => 'civicrm_product', |
| 469 | 'entity' => 'Product', |
| 470 | 'bao' => 'CRM_Contribute_BAO_Product', |
| 471 | 'localizable' => 0, |
| 472 | ], |
| 473 | ]; |
| 474 | CRM_Core_DAO_AllCoreTables::invoke(__CLASS__, 'fields_callback', Civi::$statics[__CLASS__]['fields']); |
| 475 | } |
| 476 | return Civi::$statics[__CLASS__]['fields']; |
| 477 | } |
| 478 | |
| 479 | /** |
| 480 | * Return a mapping from field-name to the corresponding key (as used in fields()). |
| 481 | * |
| 482 | * @return array |
| 483 | * Array(string $name => string $uniqueName). |
| 484 | */ |
| 485 | public static function &fieldKeys() { |
| 486 | if (!isset(Civi::$statics[__CLASS__]['fieldKeys'])) { |
| 487 | Civi::$statics[__CLASS__]['fieldKeys'] = array_flip(CRM_Utils_Array::collect('name', self::fields())); |
| 488 | } |
| 489 | return Civi::$statics[__CLASS__]['fieldKeys']; |
| 490 | } |
| 491 | |
| 492 | /** |
| 493 | * Returns the names of this table |
| 494 | * |
| 495 | * @return string |
| 496 | */ |
| 497 | public static function getTableName() { |
| 498 | return CRM_Core_DAO::getLocaleTableName(self::$_tableName); |
| 499 | } |
| 500 | |
| 501 | /** |
| 502 | * Returns if this table needs to be logged |
| 503 | * |
| 504 | * @return bool |
| 505 | */ |
| 506 | public function getLog() { |
| 507 | return self::$_log; |
| 508 | } |
| 509 | |
| 510 | /** |
| 511 | * Returns the list of fields that can be imported |
| 512 | * |
| 513 | * @param bool $prefix |
| 514 | * |
| 515 | * @return array |
| 516 | */ |
| 517 | public static function &import($prefix = FALSE) { |
| 518 | $r = CRM_Core_DAO_AllCoreTables::getImports(__CLASS__, 'product', $prefix, []); |
| 519 | return $r; |
| 520 | } |
| 521 | |
| 522 | /** |
| 523 | * Returns the list of fields that can be exported |
| 524 | * |
| 525 | * @param bool $prefix |
| 526 | * |
| 527 | * @return array |
| 528 | */ |
| 529 | public static function &export($prefix = FALSE) { |
| 530 | $r = CRM_Core_DAO_AllCoreTables::getExports(__CLASS__, 'product', $prefix, []); |
| 531 | return $r; |
| 532 | } |
| 533 | |
| 534 | /** |
| 535 | * Returns the list of indices |
| 536 | * |
| 537 | * @param bool $localize |
| 538 | * |
| 539 | * @return array |
| 540 | */ |
| 541 | public static function indices($localize = TRUE) { |
| 542 | $indices = []; |
| 543 | return ($localize && !empty($indices)) ? CRM_Core_DAO_AllCoreTables::multilingualize(__CLASS__, $indices) : $indices; |
| 544 | } |
| 545 | |
| 546 | } |