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