Merge pull request #18396 from swastikpareek/issue-1987-fix-template
[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:4831cb4c7e0611db0f4312f6522d2c20)
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
19 /**
20 * Static instance to hold the table name.
21 *
22 * @var string
23 */
24 public static $_tableName = 'civicrm_premiums_product';
25
26 /**
27 * Should CiviCRM log any modifications to this table in the civicrm_log table.
28 *
29 * @var bool
30 */
31 public static $_log = TRUE;
32
33 /**
34 * Contribution ID
35 *
36 * @var int
37 */
38 public $id;
39
40 /**
41 * Foreign key to premiums settings record.
42 *
43 * @var int
44 */
45 public $premiums_id;
46
47 /**
48 * Foreign key to each product object.
49 *
50 * @var int
51 */
52 public $product_id;
53
54 /**
55 * @var int
56 */
57 public $weight;
58
59 /**
60 * FK to Financial Type.
61 *
62 * @var int
63 */
64 public $financial_type_id;
65
66 /**
67 * Class constructor.
68 */
69 public function __construct() {
70 $this->__table = 'civicrm_premiums_product';
71 parent::__construct();
72 }
73
74 /**
75 * Returns localized title of this entity.
76 */
77 public static function getEntityTitle() {
78 return ts('Premiums Products');
79 }
80
81 /**
82 * Returns foreign keys and entity references.
83 *
84 * @return array
85 * [CRM_Core_Reference_Interface]
86 */
87 public static function getReferenceColumns() {
88 if (!isset(Civi::$statics[__CLASS__]['links'])) {
89 Civi::$statics[__CLASS__]['links'] = static::createReferenceColumns(__CLASS__);
90 Civi::$statics[__CLASS__]['links'][] = new CRM_Core_Reference_Basic(self::getTableName(), 'premiums_id', 'civicrm_premiums', 'id');
91 Civi::$statics[__CLASS__]['links'][] = new CRM_Core_Reference_Basic(self::getTableName(), 'product_id', 'civicrm_product', 'id');
92 Civi::$statics[__CLASS__]['links'][] = new CRM_Core_Reference_Basic(self::getTableName(), 'financial_type_id', 'civicrm_financial_type', 'id');
93 CRM_Core_DAO_AllCoreTables::invoke(__CLASS__, 'links_callback', Civi::$statics[__CLASS__]['links']);
94 }
95 return Civi::$statics[__CLASS__]['links'];
96 }
97
98 /**
99 * Returns all the column names of this table
100 *
101 * @return array
102 */
103 public static function &fields() {
104 if (!isset(Civi::$statics[__CLASS__]['fields'])) {
105 Civi::$statics[__CLASS__]['fields'] = [
106 'id' => [
107 'name' => 'id',
108 'type' => CRM_Utils_Type::T_INT,
109 'title' => ts('Premium Product ID'),
110 'description' => ts('Contribution ID'),
111 'required' => TRUE,
112 'where' => 'civicrm_premiums_product.id',
113 'table_name' => 'civicrm_premiums_product',
114 'entity' => 'PremiumsProduct',
115 'bao' => 'CRM_Contribute_DAO_PremiumsProduct',
116 'localizable' => 0,
117 'add' => '1.4',
118 ],
119 'premiums_id' => [
120 'name' => 'premiums_id',
121 'type' => CRM_Utils_Type::T_INT,
122 'title' => ts('Premium'),
123 'description' => ts('Foreign key to premiums settings record.'),
124 'required' => TRUE,
125 'where' => 'civicrm_premiums_product.premiums_id',
126 'table_name' => 'civicrm_premiums_product',
127 'entity' => 'PremiumsProduct',
128 'bao' => 'CRM_Contribute_DAO_PremiumsProduct',
129 'localizable' => 0,
130 'FKClassName' => 'CRM_Contribute_DAO_Premium',
131 'add' => '1.4',
132 ],
133 'product_id' => [
134 'name' => 'product_id',
135 'type' => CRM_Utils_Type::T_INT,
136 'title' => ts('Product'),
137 'description' => ts('Foreign key to each product object.'),
138 'required' => TRUE,
139 'where' => 'civicrm_premiums_product.product_id',
140 'table_name' => 'civicrm_premiums_product',
141 'entity' => 'PremiumsProduct',
142 'bao' => 'CRM_Contribute_DAO_PremiumsProduct',
143 'localizable' => 0,
144 'FKClassName' => 'CRM_Contribute_DAO_Product',
145 'add' => '1.4',
146 ],
147 'weight' => [
148 'name' => 'weight',
149 'type' => CRM_Utils_Type::T_INT,
150 'title' => ts('Order'),
151 'required' => TRUE,
152 'where' => 'civicrm_premiums_product.weight',
153 'table_name' => 'civicrm_premiums_product',
154 'entity' => 'PremiumsProduct',
155 'bao' => 'CRM_Contribute_DAO_PremiumsProduct',
156 'localizable' => 0,
157 'add' => '2.0',
158 ],
159 'financial_type_id' => [
160 'name' => 'financial_type_id',
161 'type' => CRM_Utils_Type::T_INT,
162 'title' => ts('Financial Type'),
163 'description' => ts('FK to Financial Type.'),
164 'where' => 'civicrm_premiums_product.financial_type_id',
165 'default' => 'NULL',
166 'table_name' => 'civicrm_premiums_product',
167 'entity' => 'PremiumsProduct',
168 'bao' => 'CRM_Contribute_DAO_PremiumsProduct',
169 'localizable' => 0,
170 'FKClassName' => 'CRM_Financial_DAO_FinancialType',
171 'pseudoconstant' => [
172 'table' => 'civicrm_financial_type',
173 'keyColumn' => 'id',
174 'labelColumn' => 'name',
175 ],
176 'add' => '4.3',
177 ],
178 ];
179 CRM_Core_DAO_AllCoreTables::invoke(__CLASS__, 'fields_callback', Civi::$statics[__CLASS__]['fields']);
180 }
181 return Civi::$statics[__CLASS__]['fields'];
182 }
183
184 /**
185 * Return a mapping from field-name to the corresponding key (as used in fields()).
186 *
187 * @return array
188 * Array(string $name => string $uniqueName).
189 */
190 public static function &fieldKeys() {
191 if (!isset(Civi::$statics[__CLASS__]['fieldKeys'])) {
192 Civi::$statics[__CLASS__]['fieldKeys'] = array_flip(CRM_Utils_Array::collect('name', self::fields()));
193 }
194 return Civi::$statics[__CLASS__]['fieldKeys'];
195 }
196
197 /**
198 * Returns the names of this table
199 *
200 * @return string
201 */
202 public static function getTableName() {
203 return self::$_tableName;
204 }
205
206 /**
207 * Returns if this table needs to be logged
208 *
209 * @return bool
210 */
211 public function getLog() {
212 return self::$_log;
213 }
214
215 /**
216 * Returns the list of fields that can be imported
217 *
218 * @param bool $prefix
219 *
220 * @return array
221 */
222 public static function &import($prefix = FALSE) {
223 $r = CRM_Core_DAO_AllCoreTables::getImports(__CLASS__, 'premiums_product', $prefix, []);
224 return $r;
225 }
226
227 /**
228 * Returns the list of fields that can be exported
229 *
230 * @param bool $prefix
231 *
232 * @return array
233 */
234 public static function &export($prefix = FALSE) {
235 $r = CRM_Core_DAO_AllCoreTables::getExports(__CLASS__, 'premiums_product', $prefix, []);
236 return $r;
237 }
238
239 /**
240 * Returns the list of indices
241 *
242 * @param bool $localize
243 *
244 * @return array
245 */
246 public static function indices($localize = TRUE) {
247 $indices = [];
248 return ($localize && !empty($indices)) ? CRM_Core_DAO_AllCoreTables::multilingualize(__CLASS__, $indices) : $indices;
249 }
250
251 }