db933908a9bc0f8d56b45b86438a6b88cb102247
[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:c40733f5ba2ac9d433e25758534a7f2e)
34 */
35 require_once 'CRM/Core/DAO.php';
36 require_once 'CRM/Utils/Type.php';
37 class CRM_Contribute_DAO_ContributionProduct extends CRM_Core_DAO {
38 /**
39 * static instance to hold the table name
40 *
41 * @var string
42 */
43 static $_tableName = 'civicrm_contribution_product';
44 /**
45 * static value to see if we should log any modifications to
46 * this table in the civicrm_log table
47 *
48 * @var boolean
49 */
50 static $_log = true;
51 /**
52 *
53 * @var int unsigned
54 */
55 public $id;
56 /**
57 *
58 * @var int unsigned
59 */
60 public $product_id;
61 /**
62 *
63 * @var int unsigned
64 */
65 public $contribution_id;
66 /**
67 * Option value selected if applicable - e.g. color, size etc.
68 *
69 * @var string
70 */
71 public $product_option;
72 /**
73 *
74 * @var int
75 */
76 public $quantity;
77 /**
78 * Optional. Can be used to record the date this product was fulfilled or shipped.
79 *
80 * @var date
81 */
82 public $fulfilled_date;
83 /**
84 * Actual start date for a time-delimited premium (subscription, service or membership)
85 *
86 * @var date
87 */
88 public $start_date;
89 /**
90 * Actual end date for a time-delimited premium (subscription, service or membership)
91 *
92 * @var date
93 */
94 public $end_date;
95 /**
96 *
97 * @var text
98 */
99 public $comment;
100 /**
101 * FK to Financial Type(for membership price sets only).
102 *
103 * @var int unsigned
104 */
105 public $financial_type_id;
106 /**
107 * class constructor
108 *
109 * @return civicrm_contribution_product
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 ) ,
144 'product_id' => array(
145 'name' => 'product_id',
146 'type' => CRM_Utils_Type::T_INT,
147 'title' => ts('Product ID') ,
148 'required' => true,
149 ) ,
150 'contribution_id' => array(
151 'name' => 'contribution_id',
152 'type' => CRM_Utils_Type::T_INT,
153 'title' => ts('Contribution ID') ,
154 'required' => true,
155 'FKClassName' => 'CRM_Contribute_DAO_Contribution',
156 ) ,
157 'product_option' => array(
158 'name' => 'product_option',
159 'type' => CRM_Utils_Type::T_STRING,
160 'title' => ts('Product Option') ,
161 'description' => 'Option value selected if applicable - e.g. color, size etc.',
162 'maxlength' => 255,
163 'size' => CRM_Utils_Type::HUGE,
164 'export' => true,
165 'where' => 'civicrm_contribution_product.product_option',
166 'headerPattern' => '',
167 'dataPattern' => '',
168 ) ,
169 'quantity' => array(
170 'name' => 'quantity',
171 'type' => CRM_Utils_Type::T_INT,
172 'title' => ts('Quantity') ,
173 'export' => true,
174 'where' => 'civicrm_contribution_product.quantity',
175 'headerPattern' => '',
176 'dataPattern' => '',
177 ) ,
178 'fulfilled_date' => array(
179 'name' => 'fulfilled_date',
180 'type' => CRM_Utils_Type::T_DATE,
181 'title' => ts('Fulfilled Date') ,
182 'description' => 'Optional. Can be used to record the date this product was fulfilled or shipped.',
183 'export' => true,
184 'where' => 'civicrm_contribution_product.fulfilled_date',
185 'headerPattern' => '',
186 'dataPattern' => '',
187 ) ,
188 'contribution_start_date' => array(
189 'name' => 'start_date',
190 'type' => CRM_Utils_Type::T_DATE,
191 'title' => ts('Start date for premium') ,
192 'description' => 'Actual start date for a time-delimited premium (subscription, service or membership)',
193 'export' => true,
194 'where' => 'civicrm_contribution_product.start_date',
195 'headerPattern' => '',
196 'dataPattern' => '',
197 ) ,
198 'contribution_end_date' => array(
199 'name' => 'end_date',
200 'type' => CRM_Utils_Type::T_DATE,
201 'title' => ts('End date for premium') ,
202 'description' => 'Actual end date for a time-delimited premium (subscription, service or membership)',
203 'export' => true,
204 'where' => 'civicrm_contribution_product.end_date',
205 'headerPattern' => '',
206 'dataPattern' => '',
207 ) ,
208 'comment' => array(
209 'name' => 'comment',
210 'type' => CRM_Utils_Type::T_TEXT,
211 'title' => ts('Premium comment') ,
212 ) ,
213 'financial_type_id' => array(
214 'name' => 'financial_type_id',
215 'type' => CRM_Utils_Type::T_INT,
216 'title' => ts('Financial Type') ,
217 'description' => 'FK to Financial Type(for membership price sets only).',
218 'default' => 'NULL',
219 'FKClassName' => 'CRM_Financial_DAO_FinancialType',
220 'pseudoconstant' => array(
221 'table' => 'civicrm_financial_type',
222 'keyColumn' => 'id',
223 'labelColumn' => 'name',
224 )
225 ) ,
226 );
227 CRM_Core_DAO_AllCoreTables::invoke(__CLASS__, 'fields_callback', Civi::$statics[__CLASS__]['fields']);
228 }
229 return Civi::$statics[__CLASS__]['fields'];
230 }
231 /**
232 * Return a mapping from field-name to the corresponding key (as used in fields()).
233 *
234 * @return array
235 * Array(string $name => string $uniqueName).
236 */
237 static function &fieldKeys() {
238 if (!isset(Civi::$statics[__CLASS__]['fieldKeys'])) {
239 Civi::$statics[__CLASS__]['fieldKeys'] = array_flip(CRM_Utils_Array::collect('name', self::fields()));
240 }
241 return Civi::$statics[__CLASS__]['fieldKeys'];
242 }
243 /**
244 * Returns the names of this table
245 *
246 * @return string
247 */
248 static function getTableName() {
249 return self::$_tableName;
250 }
251 /**
252 * Returns if this table needs to be logged
253 *
254 * @return boolean
255 */
256 function getLog() {
257 return self::$_log;
258 }
259 /**
260 * Returns the list of fields that can be imported
261 *
262 * @param bool $prefix
263 *
264 * @return array
265 */
266 static function &import($prefix = false) {
267 $r = CRM_Core_DAO_AllCoreTables::getImports(__CLASS__, 'contribution_product', $prefix, array());
268 return $r;
269 }
270 /**
271 * Returns the list of fields that can be exported
272 *
273 * @param bool $prefix
274 *
275 * @return array
276 */
277 static function &export($prefix = false) {
278 $r = CRM_Core_DAO_AllCoreTables::getExports(__CLASS__, 'contribution_product', $prefix, array());
279 return $r;
280 }
281 }