b278f6cfaefb9d5621337af07a8593a9b5c22150
[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:79de7abf1bfa670fa9cf3d43e6818bc9)
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 ) ,
147 'product_id' => array(
148 'name' => 'product_id',
149 'type' => CRM_Utils_Type::T_INT,
150 'title' => ts('Product ID') ,
151 'required' => true,
152 'table_name' => 'civicrm_contribution_product',
153 'entity' => 'ContributionProduct',
154 'bao' => 'CRM_Contribute_DAO_ContributionProduct',
155 ) ,
156 'contribution_id' => array(
157 'name' => 'contribution_id',
158 'type' => CRM_Utils_Type::T_INT,
159 'title' => ts('Contribution ID') ,
160 'required' => true,
161 'table_name' => 'civicrm_contribution_product',
162 'entity' => 'ContributionProduct',
163 'bao' => 'CRM_Contribute_DAO_ContributionProduct',
164 'FKClassName' => 'CRM_Contribute_DAO_Contribution',
165 ) ,
166 'product_option' => array(
167 'name' => 'product_option',
168 'type' => CRM_Utils_Type::T_STRING,
169 'title' => ts('Product Option') ,
170 'description' => 'Option value selected if applicable - e.g. color, size etc.',
171 'maxlength' => 255,
172 'size' => CRM_Utils_Type::HUGE,
173 'export' => true,
174 'where' => 'civicrm_contribution_product.product_option',
175 'headerPattern' => '',
176 'dataPattern' => '',
177 'table_name' => 'civicrm_contribution_product',
178 'entity' => 'ContributionProduct',
179 'bao' => 'CRM_Contribute_DAO_ContributionProduct',
180 ) ,
181 'quantity' => array(
182 'name' => 'quantity',
183 'type' => CRM_Utils_Type::T_INT,
184 'title' => ts('Quantity') ,
185 'export' => true,
186 'where' => 'civicrm_contribution_product.quantity',
187 'headerPattern' => '',
188 'dataPattern' => '',
189 'table_name' => 'civicrm_contribution_product',
190 'entity' => 'ContributionProduct',
191 'bao' => 'CRM_Contribute_DAO_ContributionProduct',
192 ) ,
193 'fulfilled_date' => array(
194 'name' => 'fulfilled_date',
195 'type' => CRM_Utils_Type::T_DATE,
196 'title' => ts('Fulfilled Date') ,
197 'description' => 'Optional. Can be used to record the date this product was fulfilled or shipped.',
198 'export' => true,
199 'where' => 'civicrm_contribution_product.fulfilled_date',
200 'headerPattern' => '',
201 'dataPattern' => '',
202 'table_name' => 'civicrm_contribution_product',
203 'entity' => 'ContributionProduct',
204 'bao' => 'CRM_Contribute_DAO_ContributionProduct',
205 ) ,
206 'contribution_start_date' => array(
207 'name' => 'start_date',
208 'type' => CRM_Utils_Type::T_DATE,
209 'title' => ts('Start date for premium') ,
210 'description' => 'Actual start date for a time-delimited premium (subscription, service or membership)',
211 'export' => true,
212 'where' => 'civicrm_contribution_product.start_date',
213 'headerPattern' => '',
214 'dataPattern' => '',
215 'table_name' => 'civicrm_contribution_product',
216 'entity' => 'ContributionProduct',
217 'bao' => 'CRM_Contribute_DAO_ContributionProduct',
218 ) ,
219 'contribution_end_date' => array(
220 'name' => 'end_date',
221 'type' => CRM_Utils_Type::T_DATE,
222 'title' => ts('End date for premium') ,
223 'description' => 'Actual end date for a time-delimited premium (subscription, service or membership)',
224 'export' => true,
225 'where' => 'civicrm_contribution_product.end_date',
226 'headerPattern' => '',
227 'dataPattern' => '',
228 'table_name' => 'civicrm_contribution_product',
229 'entity' => 'ContributionProduct',
230 'bao' => 'CRM_Contribute_DAO_ContributionProduct',
231 ) ,
232 'comment' => array(
233 'name' => 'comment',
234 'type' => CRM_Utils_Type::T_TEXT,
235 'title' => ts('Premium comment') ,
236 'table_name' => 'civicrm_contribution_product',
237 'entity' => 'ContributionProduct',
238 'bao' => 'CRM_Contribute_DAO_ContributionProduct',
239 ) ,
240 'financial_type_id' => array(
241 'name' => 'financial_type_id',
242 'type' => CRM_Utils_Type::T_INT,
243 'title' => ts('Financial Type') ,
244 'description' => 'FK to Financial Type(for membership price sets only).',
245 'default' => 'NULL',
246 'table_name' => 'civicrm_contribution_product',
247 'entity' => 'ContributionProduct',
248 'bao' => 'CRM_Contribute_DAO_ContributionProduct',
249 'FKClassName' => 'CRM_Financial_DAO_FinancialType',
250 'pseudoconstant' => array(
251 'table' => 'civicrm_financial_type',
252 'keyColumn' => 'id',
253 'labelColumn' => 'name',
254 )
255 ) ,
256 );
257 CRM_Core_DAO_AllCoreTables::invoke(__CLASS__, 'fields_callback', Civi::$statics[__CLASS__]['fields']);
258 }
259 return Civi::$statics[__CLASS__]['fields'];
260 }
261 /**
262 * Return a mapping from field-name to the corresponding key (as used in fields()).
263 *
264 * @return array
265 * Array(string $name => string $uniqueName).
266 */
267 static function &fieldKeys() {
268 if (!isset(Civi::$statics[__CLASS__]['fieldKeys'])) {
269 Civi::$statics[__CLASS__]['fieldKeys'] = array_flip(CRM_Utils_Array::collect('name', self::fields()));
270 }
271 return Civi::$statics[__CLASS__]['fieldKeys'];
272 }
273 /**
274 * Returns the names of this table
275 *
276 * @return string
277 */
278 static function getTableName() {
279 return self::$_tableName;
280 }
281 /**
282 * Returns if this table needs to be logged
283 *
284 * @return boolean
285 */
286 function getLog() {
287 return self::$_log;
288 }
289 /**
290 * Returns the list of fields that can be imported
291 *
292 * @param bool $prefix
293 *
294 * @return array
295 */
296 static function &import($prefix = false) {
297 $r = CRM_Core_DAO_AllCoreTables::getImports(__CLASS__, 'contribution_product', $prefix, array());
298 return $r;
299 }
300 /**
301 * Returns the list of fields that can be exported
302 *
303 * @param bool $prefix
304 *
305 * @return array
306 */
307 static function &export($prefix = false) {
308 $r = CRM_Core_DAO_AllCoreTables::getExports(__CLASS__, 'contribution_product', $prefix, array());
309 return $r;
310 }
311 }