Merge pull request #14249 from yashodha/959_dev
[civicrm-core.git] / CRM / Core / DAO / Discount.php
CommitLineData
e501603b 1<?php
c3fc2621 2
e501603b
TO
3/**
4 * @package CRM
6b83d5bd 5 * @copyright CiviCRM LLC (c) 2004-2019
e501603b
TO
6 *
7 * Generated from xml/schema/CRM/Core/Discount.xml
8 * DO NOT EDIT. Generated by CRM_Core_CodeGen
e6ca0a57 9 * (GenCodeChecksum:a414d91af17f5a6cfd69e3a0fc8fb8ca)
e501603b 10 */
c3fc2621 11
f41f0342 12/**
c3fc2621 13 * Database access object for the Discount entity.
f41f0342 14 */
e501603b 15class CRM_Core_DAO_Discount extends CRM_Core_DAO {
c3fc2621 16
e501603b 17 /**
f41f0342 18 * Static instance to hold the table name.
e501603b
TO
19 *
20 * @var string
21 */
fa45b5b9 22 public static $_tableName = 'civicrm_discount';
c3fc2621 23
e501603b 24 /**
f41f0342 25 * Should CiviCRM log any modifications to this table in the civicrm_log table.
e501603b 26 *
c3fc2621 27 * @var bool
e501603b 28 */
fa45b5b9 29 public static $_log = TRUE;
c3fc2621 30
e501603b
TO
31 /**
32 * primary key
33 *
e6ca0a57 34 * @var int
e501603b
TO
35 */
36 public $id;
c3fc2621 37
e501603b
TO
38 /**
39 * physical tablename for entity being joined to discount, e.g. civicrm_event
40 *
41 * @var string
42 */
43 public $entity_table;
c3fc2621 44
e501603b
TO
45 /**
46 * FK to entity table specified in entity_table column.
47 *
e6ca0a57 48 * @var int
e501603b
TO
49 */
50 public $entity_id;
c3fc2621 51
e501603b
TO
52 /**
53 * FK to civicrm_price_set
54 *
e6ca0a57 55 * @var int
e501603b
TO
56 */
57 public $price_set_id;
c3fc2621 58
e501603b
TO
59 /**
60 * Date when discount starts.
61 *
62 * @var date
63 */
64 public $start_date;
c3fc2621 65
e501603b
TO
66 /**
67 * Date when discount ends.
68 *
69 * @var date
70 */
71 public $end_date;
c3fc2621 72
e501603b 73 /**
f41f0342 74 * Class constructor.
e501603b 75 */
c3fc2621 76 public function __construct() {
e501603b
TO
77 $this->__table = 'civicrm_discount';
78 parent::__construct();
79 }
c3fc2621 80
e501603b 81 /**
f41f0342 82 * Returns foreign keys and entity references.
e501603b
TO
83 *
84 * @return array
85 * [CRM_Core_Reference_Interface]
86 */
c3fc2621 87 public static function getReferenceColumns() {
346aaaba 88 if (!isset(Civi::$statics[__CLASS__]['links'])) {
fa45b5b9 89 Civi::$statics[__CLASS__]['links'] = static::createReferenceColumns(__CLASS__);
c3fc2621
CW
90 Civi::$statics[__CLASS__]['links'][] = new CRM_Core_Reference_Basic(self::getTableName(), 'price_set_id', 'civicrm_price_set', 'id');
91 Civi::$statics[__CLASS__]['links'][] = new CRM_Core_Reference_Dynamic(self::getTableName(), 'entity_id', NULL, 'id', 'entity_table');
346aaaba 92 CRM_Core_DAO_AllCoreTables::invoke(__CLASS__, 'links_callback', Civi::$statics[__CLASS__]['links']);
e501603b 93 }
346aaaba 94 return Civi::$statics[__CLASS__]['links'];
e501603b 95 }
c3fc2621 96
e501603b
TO
97 /**
98 * Returns all the column names of this table
99 *
100 * @return array
101 */
c3fc2621 102 public static function &fields() {
346aaaba 103 if (!isset(Civi::$statics[__CLASS__]['fields'])) {
c3fc2621
CW
104 Civi::$statics[__CLASS__]['fields'] = [
105 'id' => [
e501603b
TO
106 'name' => 'id',
107 'type' => CRM_Utils_Type::T_INT,
c3fc2621 108 'title' => ts('Discount ID'),
215b423e 109 'description' => ts('primary key'),
c3fc2621 110 'required' => TRUE,
a36434b9 111 'where' => 'civicrm_discount.id',
522a26c9 112 'table_name' => 'civicrm_discount',
113 'entity' => 'Discount',
114 'bao' => 'CRM_Core_BAO_Discount',
6a7e5e5d 115 'localizable' => 0,
c3fc2621
CW
116 ],
117 'entity_table' => [
e501603b
TO
118 'name' => 'entity_table',
119 'type' => CRM_Utils_Type::T_STRING,
c3fc2621 120 'title' => ts('Entity Table'),
215b423e 121 'description' => ts('physical tablename for entity being joined to discount, e.g. civicrm_event'),
e501603b
TO
122 'maxlength' => 64,
123 'size' => CRM_Utils_Type::BIG,
a36434b9 124 'where' => 'civicrm_discount.entity_table',
522a26c9 125 'table_name' => 'civicrm_discount',
126 'entity' => 'Discount',
127 'bao' => 'CRM_Core_BAO_Discount',
6a7e5e5d 128 'localizable' => 0,
c3fc2621
CW
129 ],
130 'entity_id' => [
e501603b
TO
131 'name' => 'entity_id',
132 'type' => CRM_Utils_Type::T_INT,
c3fc2621 133 'title' => ts('Entity ID'),
215b423e 134 'description' => ts('FK to entity table specified in entity_table column.'),
c3fc2621 135 'required' => TRUE,
a36434b9 136 'where' => 'civicrm_discount.entity_id',
522a26c9 137 'table_name' => 'civicrm_discount',
138 'entity' => 'Discount',
139 'bao' => 'CRM_Core_BAO_Discount',
6a7e5e5d 140 'localizable' => 0,
c3fc2621
CW
141 ],
142 'participant_discount_name' => [
e501603b
TO
143 'name' => 'price_set_id',
144 'type' => CRM_Utils_Type::T_INT,
c3fc2621 145 'title' => ts('Discount Name'),
215b423e 146 'description' => ts('FK to civicrm_price_set'),
c3fc2621 147 'required' => TRUE,
e501603b 148 'where' => 'civicrm_discount.price_set_id',
a36434b9 149 'export' => TRUE,
522a26c9 150 'table_name' => 'civicrm_discount',
151 'entity' => 'Discount',
152 'bao' => 'CRM_Core_BAO_Discount',
6a7e5e5d 153 'localizable' => 0,
e501603b 154 'FKClassName' => 'CRM_Price_DAO_PriceSet',
c3fc2621
CW
155 ],
156 'start_date' => [
e501603b
TO
157 'name' => 'start_date',
158 'type' => CRM_Utils_Type::T_DATE,
c3fc2621 159 'title' => ts('Discount Start Date'),
215b423e 160 'description' => ts('Date when discount starts.'),
a36434b9 161 'where' => 'civicrm_discount.start_date',
522a26c9 162 'table_name' => 'civicrm_discount',
163 'entity' => 'Discount',
164 'bao' => 'CRM_Core_BAO_Discount',
6a7e5e5d 165 'localizable' => 0,
c3fc2621
CW
166 ],
167 'end_date' => [
e501603b
TO
168 'name' => 'end_date',
169 'type' => CRM_Utils_Type::T_DATE,
c3fc2621 170 'title' => ts('Discount End Date'),
215b423e 171 'description' => ts('Date when discount ends.'),
a36434b9 172 'where' => 'civicrm_discount.end_date',
522a26c9 173 'table_name' => 'civicrm_discount',
174 'entity' => 'Discount',
175 'bao' => 'CRM_Core_BAO_Discount',
6a7e5e5d 176 'localizable' => 0,
c3fc2621
CW
177 ],
178 ];
346aaaba 179 CRM_Core_DAO_AllCoreTables::invoke(__CLASS__, 'fields_callback', Civi::$statics[__CLASS__]['fields']);
e501603b 180 }
346aaaba 181 return Civi::$statics[__CLASS__]['fields'];
e501603b 182 }
c3fc2621 183
e501603b 184 /**
bd8e0b14 185 * Return a mapping from field-name to the corresponding key (as used in fields()).
e501603b
TO
186 *
187 * @return array
bd8e0b14 188 * Array(string $name => string $uniqueName).
e501603b 189 */
c3fc2621 190 public static function &fieldKeys() {
bd8e0b14
TO
191 if (!isset(Civi::$statics[__CLASS__]['fieldKeys'])) {
192 Civi::$statics[__CLASS__]['fieldKeys'] = array_flip(CRM_Utils_Array::collect('name', self::fields()));
e501603b 193 }
bd8e0b14 194 return Civi::$statics[__CLASS__]['fieldKeys'];
e501603b 195 }
c3fc2621 196
e501603b
TO
197 /**
198 * Returns the names of this table
199 *
200 * @return string
201 */
c3fc2621 202 public static function getTableName() {
e501603b
TO
203 return self::$_tableName;
204 }
c3fc2621 205
e501603b
TO
206 /**
207 * Returns if this table needs to be logged
208 *
c3fc2621 209 * @return bool
e501603b 210 */
c3fc2621 211 public function getLog() {
e501603b
TO
212 return self::$_log;
213 }
c3fc2621 214
e501603b
TO
215 /**
216 * Returns the list of fields that can be imported
217 *
218 * @param bool $prefix
219 *
220 * @return array
221 */
c3fc2621
CW
222 public static function &import($prefix = FALSE) {
223 $r = CRM_Core_DAO_AllCoreTables::getImports(__CLASS__, 'discount', $prefix, []);
60808919 224 return $r;
e501603b 225 }
c3fc2621 226
e501603b
TO
227 /**
228 * Returns the list of fields that can be exported
229 *
230 * @param bool $prefix
231 *
232 * @return array
233 */
c3fc2621
CW
234 public static function &export($prefix = FALSE) {
235 $r = CRM_Core_DAO_AllCoreTables::getExports(__CLASS__, 'discount', $prefix, []);
60808919 236 return $r;
e501603b 237 }
c3fc2621 238
e7a6b91a
AS
239 /**
240 * Returns the list of indices
c3fc2621
CW
241 *
242 * @param bool $localize
243 *
244 * @return array
e7a6b91a
AS
245 */
246 public static function indices($localize = TRUE) {
c3fc2621
CW
247 $indices = [
248 'index_entity' => [
e7a6b91a 249 'name' => 'index_entity',
c3fc2621 250 'field' => [
e7a6b91a
AS
251 0 => 'entity_table',
252 1 => 'entity_id',
c3fc2621
CW
253 ],
254 'localizable' => FALSE,
e7a6b91a 255 'sig' => 'civicrm_discount::0::entity_table::entity_id',
c3fc2621
CW
256 ],
257 'index_entity_option_id' => [
e7a6b91a 258 'name' => 'index_entity_option_id',
c3fc2621 259 'field' => [
e7a6b91a
AS
260 0 => 'entity_table',
261 1 => 'entity_id',
262 2 => 'price_set_id',
c3fc2621
CW
263 ],
264 'localizable' => FALSE,
e7a6b91a 265 'sig' => 'civicrm_discount::0::entity_table::entity_id::price_set_id',
c3fc2621
CW
266 ],
267 ];
e7a6b91a
AS
268 return ($localize && !empty($indices)) ? CRM_Core_DAO_AllCoreTables::multilingualize(__CLASS__, $indices) : $indices;
269 }
c3fc2621 270
e501603b 271}