Merge pull request #9973 from lcdservices/CRM-19469
[civicrm-core.git] / CRM / Contribute / DAO / ContributionProduct.php
1 <?php
2 /*
3 +--------------------------------------------------------------------+
4 | CiviCRM version 4.7 |
5 +--------------------------------------------------------------------+
6 | Copyright CiviCRM LLC (c) 2004-2017 |
7 +--------------------------------------------------------------------+
8 | This file is a part of CiviCRM. |
9 | |
10 | CiviCRM is free software; you can copy, modify, and distribute it |
11 | under the terms of the GNU Affero General Public License |
12 | Version 3, 19 November 2007 and the CiviCRM Licensing Exception. |
13 | |
14 | CiviCRM is distributed in the hope that it will be useful, but |
15 | WITHOUT ANY WARRANTY; without even the implied warranty of |
16 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. |
17 | See the GNU Affero General Public License for more details. |
18 | |
19 | You should have received a copy of the GNU Affero General Public |
20 | License and the CiviCRM Licensing Exception along |
21 | with this program; if not, contact CiviCRM LLC |
22 | at info[AT]civicrm[DOT]org. If you have questions about the |
23 | GNU Affero General Public License or the licensing of CiviCRM, |
24 | see the CiviCRM license FAQ at http://civicrm.org/licensing |
25 +--------------------------------------------------------------------+
26 */
27 /**
28 * @package CRM
29 * @copyright CiviCRM LLC (c) 2004-2017
30 *
31 * Generated from xml/schema/CRM/Contribute/ContributionProduct.xml
32 * DO NOT EDIT. Generated by CRM_Core_CodeGen
33 * (GenCodeChecksum:8ef29c5c92b3ffb2a678bd4c585a3d0e)
34 */
35 require_once 'CRM/Core/DAO.php';
36 require_once 'CRM/Utils/Type.php';
37 /**
38 * CRM_Contribute_DAO_ContributionProduct constructor.
39 */
40 class CRM_Contribute_DAO_ContributionProduct extends CRM_Core_DAO {
41 /**
42 * Static instance to hold the table name.
43 *
44 * @var string
45 */
46 static $_tableName = 'civicrm_contribution_product';
47 /**
48 * Should CiviCRM log any modifications to this table in the civicrm_log table.
49 *
50 * @var boolean
51 */
52 static $_log = true;
53 /**
54 *
55 * @var int unsigned
56 */
57 public $id;
58 /**
59 *
60 * @var int unsigned
61 */
62 public $product_id;
63 /**
64 *
65 * @var int unsigned
66 */
67 public $contribution_id;
68 /**
69 * Option value selected if applicable - e.g. color, size etc.
70 *
71 * @var string
72 */
73 public $product_option;
74 /**
75 *
76 * @var int
77 */
78 public $quantity;
79 /**
80 * Optional. Can be used to record the date this product was fulfilled or shipped.
81 *
82 * @var date
83 */
84 public $fulfilled_date;
85 /**
86 * Actual start date for a time-delimited premium (subscription, service or membership)
87 *
88 * @var date
89 */
90 public $start_date;
91 /**
92 * Actual end date for a time-delimited premium (subscription, service or membership)
93 *
94 * @var date
95 */
96 public $end_date;
97 /**
98 *
99 * @var text
100 */
101 public $comment;
102 /**
103 * FK to Financial Type(for membership price sets only).
104 *
105 * @var int unsigned
106 */
107 public $financial_type_id;
108 /**
109 * Class constructor.
110 */
111 function __construct() {
112 $this->__table = 'civicrm_contribution_product';
113 parent::__construct();
114 }
115 /**
116 * Returns foreign keys and entity references.
117 *
118 * @return array
119 * [CRM_Core_Reference_Interface]
120 */
121 static function getReferenceColumns() {
122 if (!isset(Civi::$statics[__CLASS__]['links'])) {
123 Civi::$statics[__CLASS__]['links'] = static ::createReferenceColumns(__CLASS__);
124 Civi::$statics[__CLASS__]['links'][] = new CRM_Core_Reference_Basic(self::getTableName() , 'contribution_id', 'civicrm_contribution', 'id');
125 Civi::$statics[__CLASS__]['links'][] = new CRM_Core_Reference_Basic(self::getTableName() , 'financial_type_id', 'civicrm_financial_type', 'id');
126 CRM_Core_DAO_AllCoreTables::invoke(__CLASS__, 'links_callback', Civi::$statics[__CLASS__]['links']);
127 }
128 return Civi::$statics[__CLASS__]['links'];
129 }
130 /**
131 * Returns all the column names of this table
132 *
133 * @return array
134 */
135 static function &fields() {
136 if (!isset(Civi::$statics[__CLASS__]['fields'])) {
137 Civi::$statics[__CLASS__]['fields'] = array(
138 'id' => array(
139 'name' => 'id',
140 'type' => CRM_Utils_Type::T_INT,
141 'title' => ts('Contribution Product ID') ,
142 'required' => true,
143 'table_name' => 'civicrm_contribution_product',
144 'entity' => 'ContributionProduct',
145 'bao' => 'CRM_Contribute_DAO_ContributionProduct',
146 'localizable' => 0,
147 ) ,
148 'product_id' => array(
149 'name' => 'product_id',
150 'type' => CRM_Utils_Type::T_INT,
151 'title' => ts('Product ID') ,
152 'required' => true,
153 'table_name' => 'civicrm_contribution_product',
154 'entity' => 'ContributionProduct',
155 'bao' => 'CRM_Contribute_DAO_ContributionProduct',
156 'localizable' => 0,
157 ) ,
158 'contribution_id' => array(
159 'name' => 'contribution_id',
160 'type' => CRM_Utils_Type::T_INT,
161 'title' => ts('Contribution ID') ,
162 'required' => true,
163 'table_name' => 'civicrm_contribution_product',
164 'entity' => 'ContributionProduct',
165 'bao' => 'CRM_Contribute_DAO_ContributionProduct',
166 'localizable' => 0,
167 'FKClassName' => 'CRM_Contribute_DAO_Contribution',
168 ) ,
169 'product_option' => array(
170 'name' => 'product_option',
171 'type' => CRM_Utils_Type::T_STRING,
172 'title' => ts('Product Option') ,
173 'description' => 'Option value selected if applicable - e.g. color, size etc.',
174 'maxlength' => 255,
175 'size' => CRM_Utils_Type::HUGE,
176 'export' => true,
177 'where' => 'civicrm_contribution_product.product_option',
178 'headerPattern' => '',
179 'dataPattern' => '',
180 'table_name' => 'civicrm_contribution_product',
181 'entity' => 'ContributionProduct',
182 'bao' => 'CRM_Contribute_DAO_ContributionProduct',
183 'localizable' => 0,
184 ) ,
185 'quantity' => array(
186 'name' => 'quantity',
187 'type' => CRM_Utils_Type::T_INT,
188 'title' => ts('Quantity') ,
189 'export' => true,
190 'where' => 'civicrm_contribution_product.quantity',
191 'headerPattern' => '',
192 'dataPattern' => '',
193 'table_name' => 'civicrm_contribution_product',
194 'entity' => 'ContributionProduct',
195 'bao' => 'CRM_Contribute_DAO_ContributionProduct',
196 'localizable' => 0,
197 ) ,
198 'fulfilled_date' => array(
199 'name' => 'fulfilled_date',
200 'type' => CRM_Utils_Type::T_DATE,
201 'title' => ts('Fulfilled Date') ,
202 'description' => 'Optional. Can be used to record the date this product was fulfilled or shipped.',
203 'export' => true,
204 'where' => 'civicrm_contribution_product.fulfilled_date',
205 'headerPattern' => '',
206 'dataPattern' => '',
207 'table_name' => 'civicrm_contribution_product',
208 'entity' => 'ContributionProduct',
209 'bao' => 'CRM_Contribute_DAO_ContributionProduct',
210 'localizable' => 0,
211 ) ,
212 'contribution_start_date' => array(
213 'name' => 'start_date',
214 'type' => CRM_Utils_Type::T_DATE,
215 'title' => ts('Start date for premium') ,
216 'description' => 'Actual start date for a time-delimited premium (subscription, service or membership)',
217 'export' => true,
218 'where' => 'civicrm_contribution_product.start_date',
219 'headerPattern' => '',
220 'dataPattern' => '',
221 'table_name' => 'civicrm_contribution_product',
222 'entity' => 'ContributionProduct',
223 'bao' => 'CRM_Contribute_DAO_ContributionProduct',
224 'localizable' => 0,
225 ) ,
226 'contribution_end_date' => array(
227 'name' => 'end_date',
228 'type' => CRM_Utils_Type::T_DATE,
229 'title' => ts('End date for premium') ,
230 'description' => 'Actual end date for a time-delimited premium (subscription, service or membership)',
231 'export' => true,
232 'where' => 'civicrm_contribution_product.end_date',
233 'headerPattern' => '',
234 'dataPattern' => '',
235 'table_name' => 'civicrm_contribution_product',
236 'entity' => 'ContributionProduct',
237 'bao' => 'CRM_Contribute_DAO_ContributionProduct',
238 'localizable' => 0,
239 ) ,
240 'comment' => array(
241 'name' => 'comment',
242 'type' => CRM_Utils_Type::T_TEXT,
243 'title' => ts('Premium comment') ,
244 'table_name' => 'civicrm_contribution_product',
245 'entity' => 'ContributionProduct',
246 'bao' => 'CRM_Contribute_DAO_ContributionProduct',
247 'localizable' => 0,
248 ) ,
249 'financial_type_id' => array(
250 'name' => 'financial_type_id',
251 'type' => CRM_Utils_Type::T_INT,
252 'title' => ts('Financial Type') ,
253 'description' => 'FK to Financial Type(for membership price sets only).',
254 'default' => 'NULL',
255 'table_name' => 'civicrm_contribution_product',
256 'entity' => 'ContributionProduct',
257 'bao' => 'CRM_Contribute_DAO_ContributionProduct',
258 'localizable' => 0,
259 'FKClassName' => 'CRM_Financial_DAO_FinancialType',
260 'pseudoconstant' => array(
261 'table' => 'civicrm_financial_type',
262 'keyColumn' => 'id',
263 'labelColumn' => 'name',
264 )
265 ) ,
266 );
267 CRM_Core_DAO_AllCoreTables::invoke(__CLASS__, 'fields_callback', Civi::$statics[__CLASS__]['fields']);
268 }
269 return Civi::$statics[__CLASS__]['fields'];
270 }
271 /**
272 * Return a mapping from field-name to the corresponding key (as used in fields()).
273 *
274 * @return array
275 * Array(string $name => string $uniqueName).
276 */
277 static function &fieldKeys() {
278 if (!isset(Civi::$statics[__CLASS__]['fieldKeys'])) {
279 Civi::$statics[__CLASS__]['fieldKeys'] = array_flip(CRM_Utils_Array::collect('name', self::fields()));
280 }
281 return Civi::$statics[__CLASS__]['fieldKeys'];
282 }
283 /**
284 * Returns the names of this table
285 *
286 * @return string
287 */
288 static function getTableName() {
289 return self::$_tableName;
290 }
291 /**
292 * Returns if this table needs to be logged
293 *
294 * @return boolean
295 */
296 function getLog() {
297 return self::$_log;
298 }
299 /**
300 * Returns the list of fields that can be imported
301 *
302 * @param bool $prefix
303 *
304 * @return array
305 */
306 static function &import($prefix = false) {
307 $r = CRM_Core_DAO_AllCoreTables::getImports(__CLASS__, 'contribution_product', $prefix, array());
308 return $r;
309 }
310 /**
311 * Returns the list of fields that can be exported
312 *
313 * @param bool $prefix
314 *
315 * @return array
316 */
317 static function &export($prefix = false) {
318 $r = CRM_Core_DAO_AllCoreTables::getExports(__CLASS__, 'contribution_product', $prefix, array());
319 return $r;
320 }
321 /**
322 * Returns the list of indices
323 */
324 public static function indices($localize = TRUE) {
325 $indices = array();
326 return ($localize && !empty($indices)) ? CRM_Core_DAO_AllCoreTables::multilingualize(__CLASS__, $indices) : $indices;
327 }
328 }