Merge pull request #22558 from eileenmcnaughton/coleman
[civicrm-core.git] / CRM / Contribute / DAO / PremiumsProduct.php
1 <?php
2
3 /**
4 * @package CRM
5 * @copyright CiviCRM LLC https://civicrm.org/licensing
6 *
7 * Generated from xml/schema/CRM/Contribute/PremiumsProduct.xml
8 * DO NOT EDIT. Generated by CRM_Core_CodeGen
9 * (GenCodeChecksum:46c21503a7dd4e0e8dc4b2221ae8bd0a)
10 */
11
12 /**
13 * Database access object for the PremiumsProduct entity.
14 */
15 class CRM_Contribute_DAO_PremiumsProduct extends CRM_Core_DAO {
16 const EXT = 'civicrm';
17 const TABLE_ADDED = '1.4';
18 const COMPONENT = 'CiviContribute';
19
20 /**
21 * Static instance to hold the table name.
22 *
23 * @var string
24 */
25 public static $_tableName = 'civicrm_premiums_product';
26
27 /**
28 * Should CiviCRM log any modifications to this table in the civicrm_log table.
29 *
30 * @var bool
31 */
32 public static $_log = TRUE;
33
34 /**
35 * Contribution ID
36 *
37 * @var int|string|null
38 * (SQL type: int unsigned)
39 * Note that values will be retrieved from the database as a string.
40 */
41 public $id;
42
43 /**
44 * Foreign key to premiums settings record.
45 *
46 * @var int|string
47 * (SQL type: int unsigned)
48 * Note that values will be retrieved from the database as a string.
49 */
50 public $premiums_id;
51
52 /**
53 * Foreign key to each product object.
54 *
55 * @var int|string
56 * (SQL type: int unsigned)
57 * Note that values will be retrieved from the database as a string.
58 */
59 public $product_id;
60
61 /**
62 * @var int|string
63 * (SQL type: int unsigned)
64 * Note that values will be retrieved from the database as a string.
65 */
66 public $weight;
67
68 /**
69 * FK to Financial Type.
70 *
71 * @var int|string|null
72 * (SQL type: int unsigned)
73 * Note that values will be retrieved from the database as a string.
74 */
75 public $financial_type_id;
76
77 /**
78 * Class constructor.
79 */
80 public function __construct() {
81 $this->__table = 'civicrm_premiums_product';
82 parent::__construct();
83 }
84
85 /**
86 * Returns localized title of this entity.
87 *
88 * @param bool $plural
89 * Whether to return the plural version of the title.
90 */
91 public static function getEntityTitle($plural = FALSE) {
92 return $plural ? ts('Product Premiums') : ts('Product Premium');
93 }
94
95 /**
96 * Returns foreign keys and entity references.
97 *
98 * @return array
99 * [CRM_Core_Reference_Interface]
100 */
101 public static function getReferenceColumns() {
102 if (!isset(Civi::$statics[__CLASS__]['links'])) {
103 Civi::$statics[__CLASS__]['links'] = static::createReferenceColumns(__CLASS__);
104 Civi::$statics[__CLASS__]['links'][] = new CRM_Core_Reference_Basic(self::getTableName(), 'premiums_id', 'civicrm_premiums', 'id');
105 Civi::$statics[__CLASS__]['links'][] = new CRM_Core_Reference_Basic(self::getTableName(), 'product_id', 'civicrm_product', 'id');
106 Civi::$statics[__CLASS__]['links'][] = new CRM_Core_Reference_Basic(self::getTableName(), 'financial_type_id', 'civicrm_financial_type', 'id');
107 CRM_Core_DAO_AllCoreTables::invoke(__CLASS__, 'links_callback', Civi::$statics[__CLASS__]['links']);
108 }
109 return Civi::$statics[__CLASS__]['links'];
110 }
111
112 /**
113 * Returns all the column names of this table
114 *
115 * @return array
116 */
117 public static function &fields() {
118 if (!isset(Civi::$statics[__CLASS__]['fields'])) {
119 Civi::$statics[__CLASS__]['fields'] = [
120 'id' => [
121 'name' => 'id',
122 'type' => CRM_Utils_Type::T_INT,
123 'title' => ts('Premium Product ID'),
124 'description' => ts('Contribution ID'),
125 'required' => TRUE,
126 'where' => 'civicrm_premiums_product.id',
127 'table_name' => 'civicrm_premiums_product',
128 'entity' => 'PremiumsProduct',
129 'bao' => 'CRM_Contribute_DAO_PremiumsProduct',
130 'localizable' => 0,
131 'html' => [
132 'type' => 'Number',
133 ],
134 'readonly' => TRUE,
135 'add' => '1.4',
136 ],
137 'premiums_id' => [
138 'name' => 'premiums_id',
139 'type' => CRM_Utils_Type::T_INT,
140 'title' => ts('Premium ID'),
141 'description' => ts('Foreign key to premiums settings record.'),
142 'required' => TRUE,
143 'where' => 'civicrm_premiums_product.premiums_id',
144 'table_name' => 'civicrm_premiums_product',
145 'entity' => 'PremiumsProduct',
146 'bao' => 'CRM_Contribute_DAO_PremiumsProduct',
147 'localizable' => 0,
148 'FKClassName' => 'CRM_Contribute_DAO_Premium',
149 'html' => [
150 'label' => ts("Premium"),
151 ],
152 'add' => '1.4',
153 ],
154 'product_id' => [
155 'name' => 'product_id',
156 'type' => CRM_Utils_Type::T_INT,
157 'title' => ts('Product ID'),
158 'description' => ts('Foreign key to each product object.'),
159 'required' => TRUE,
160 'where' => 'civicrm_premiums_product.product_id',
161 'table_name' => 'civicrm_premiums_product',
162 'entity' => 'PremiumsProduct',
163 'bao' => 'CRM_Contribute_DAO_PremiumsProduct',
164 'localizable' => 0,
165 'FKClassName' => 'CRM_Contribute_DAO_Product',
166 'html' => [
167 'label' => ts("Product"),
168 ],
169 'add' => '1.4',
170 ],
171 'weight' => [
172 'name' => 'weight',
173 'type' => CRM_Utils_Type::T_INT,
174 'title' => ts('Order'),
175 'required' => TRUE,
176 'where' => 'civicrm_premiums_product.weight',
177 'table_name' => 'civicrm_premiums_product',
178 'entity' => 'PremiumsProduct',
179 'bao' => 'CRM_Contribute_DAO_PremiumsProduct',
180 'localizable' => 0,
181 'add' => '2.0',
182 ],
183 'financial_type_id' => [
184 'name' => 'financial_type_id',
185 'type' => CRM_Utils_Type::T_INT,
186 'title' => ts('Financial Type ID'),
187 'description' => ts('FK to Financial Type.'),
188 'where' => 'civicrm_premiums_product.financial_type_id',
189 'default' => NULL,
190 'table_name' => 'civicrm_premiums_product',
191 'entity' => 'PremiumsProduct',
192 'bao' => 'CRM_Contribute_DAO_PremiumsProduct',
193 'localizable' => 0,
194 'FKClassName' => 'CRM_Financial_DAO_FinancialType',
195 'html' => [
196 'label' => ts("Financial Type"),
197 ],
198 'pseudoconstant' => [
199 'table' => 'civicrm_financial_type',
200 'keyColumn' => 'id',
201 'labelColumn' => 'name',
202 ],
203 'add' => '4.3',
204 ],
205 ];
206 CRM_Core_DAO_AllCoreTables::invoke(__CLASS__, 'fields_callback', Civi::$statics[__CLASS__]['fields']);
207 }
208 return Civi::$statics[__CLASS__]['fields'];
209 }
210
211 /**
212 * Return a mapping from field-name to the corresponding key (as used in fields()).
213 *
214 * @return array
215 * Array(string $name => string $uniqueName).
216 */
217 public static function &fieldKeys() {
218 if (!isset(Civi::$statics[__CLASS__]['fieldKeys'])) {
219 Civi::$statics[__CLASS__]['fieldKeys'] = array_flip(CRM_Utils_Array::collect('name', self::fields()));
220 }
221 return Civi::$statics[__CLASS__]['fieldKeys'];
222 }
223
224 /**
225 * Returns the names of this table
226 *
227 * @return string
228 */
229 public static function getTableName() {
230 return self::$_tableName;
231 }
232
233 /**
234 * Returns if this table needs to be logged
235 *
236 * @return bool
237 */
238 public function getLog() {
239 return self::$_log;
240 }
241
242 /**
243 * Returns the list of fields that can be imported
244 *
245 * @param bool $prefix
246 *
247 * @return array
248 */
249 public static function &import($prefix = FALSE) {
250 $r = CRM_Core_DAO_AllCoreTables::getImports(__CLASS__, 'premiums_product', $prefix, []);
251 return $r;
252 }
253
254 /**
255 * Returns the list of fields that can be exported
256 *
257 * @param bool $prefix
258 *
259 * @return array
260 */
261 public static function &export($prefix = FALSE) {
262 $r = CRM_Core_DAO_AllCoreTables::getExports(__CLASS__, 'premiums_product', $prefix, []);
263 return $r;
264 }
265
266 /**
267 * Returns the list of indices
268 *
269 * @param bool $localize
270 *
271 * @return array
272 */
273 public static function indices($localize = TRUE) {
274 $indices = [];
275 return ($localize && !empty($indices)) ? CRM_Core_DAO_AllCoreTables::multilingualize(__CLASS__, $indices) : $indices;
276 }
277
278 }