Merge pull request #9595 from totten/master-extbatch-env
[civicrm-core.git] / CRM / Grant / DAO / Grant.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/Grant/Grant.xml
32 * DO NOT EDIT. Generated by CRM_Core_CodeGen
33 * (GenCodeChecksum:38ec42e92df1109ae3a0fe337852fbd5)
34 */
35 require_once 'CRM/Core/DAO.php';
36 require_once 'CRM/Utils/Type.php';
37 /**
38 * CRM_Grant_DAO_Grant constructor.
39 */
40 class CRM_Grant_DAO_Grant extends CRM_Core_DAO {
41 /**
42 * Static instance to hold the table name.
43 *
44 * @var string
45 */
46 static $_tableName = 'civicrm_grant';
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 * Unique Grant id
55 *
56 * @var int unsigned
57 */
58 public $id;
59 /**
60 * Contact ID of contact record given grant belongs to.
61 *
62 * @var int unsigned
63 */
64 public $contact_id;
65 /**
66 * Date on which grant application was received by donor.
67 *
68 * @var date
69 */
70 public $application_received_date;
71 /**
72 * Date on which grant decision was made.
73 *
74 * @var date
75 */
76 public $decision_date;
77 /**
78 * Date on which grant money transfer was made.
79 *
80 * @var date
81 */
82 public $money_transfer_date;
83 /**
84 * Date on which grant report is due.
85 *
86 * @var date
87 */
88 public $grant_due_date;
89 /**
90 * Yes/No field stating whether grant report was received by donor.
91 *
92 * @var boolean
93 */
94 public $grant_report_received;
95 /**
96 * Type of grant. Implicit FK to civicrm_option_value in grant_type option_group.
97 *
98 * @var int unsigned
99 */
100 public $grant_type_id;
101 /**
102 * Requested grant amount, in default currency.
103 *
104 * @var float
105 */
106 public $amount_total;
107 /**
108 * Requested grant amount, in original currency (optional).
109 *
110 * @var float
111 */
112 public $amount_requested;
113 /**
114 * Granted amount, in default currency.
115 *
116 * @var float
117 */
118 public $amount_granted;
119 /**
120 * 3 character string, value from config setting or input via user.
121 *
122 * @var string
123 */
124 public $currency;
125 /**
126 * Grant rationale.
127 *
128 * @var text
129 */
130 public $rationale;
131 /**
132 * Id of Grant status.
133 *
134 * @var int unsigned
135 */
136 public $status_id;
137 /**
138 * FK to Financial Type.
139 *
140 * @var int unsigned
141 */
142 public $financial_type_id;
143 /**
144 * Class constructor.
145 */
146 function __construct() {
147 $this->__table = 'civicrm_grant';
148 parent::__construct();
149 }
150 /**
151 * Returns foreign keys and entity references.
152 *
153 * @return array
154 * [CRM_Core_Reference_Interface]
155 */
156 static function getReferenceColumns() {
157 if (!isset(Civi::$statics[__CLASS__]['links'])) {
158 Civi::$statics[__CLASS__]['links'] = static ::createReferenceColumns(__CLASS__);
159 Civi::$statics[__CLASS__]['links'][] = new CRM_Core_Reference_Basic(self::getTableName() , 'contact_id', 'civicrm_contact', 'id');
160 Civi::$statics[__CLASS__]['links'][] = new CRM_Core_Reference_Basic(self::getTableName() , 'financial_type_id', 'civicrm_financial_type', 'id');
161 CRM_Core_DAO_AllCoreTables::invoke(__CLASS__, 'links_callback', Civi::$statics[__CLASS__]['links']);
162 }
163 return Civi::$statics[__CLASS__]['links'];
164 }
165 /**
166 * Returns all the column names of this table
167 *
168 * @return array
169 */
170 static function &fields() {
171 if (!isset(Civi::$statics[__CLASS__]['fields'])) {
172 Civi::$statics[__CLASS__]['fields'] = array(
173 'grant_id' => array(
174 'name' => 'id',
175 'type' => CRM_Utils_Type::T_INT,
176 'title' => ts('Grant ID') ,
177 'description' => 'Unique Grant id',
178 'required' => true,
179 'import' => true,
180 'where' => 'civicrm_grant.id',
181 'headerPattern' => '',
182 'dataPattern' => '',
183 'export' => true,
184 ) ,
185 'grant_contact_id' => array(
186 'name' => 'contact_id',
187 'type' => CRM_Utils_Type::T_INT,
188 'title' => ts('Contact ID') ,
189 'description' => 'Contact ID of contact record given grant belongs to.',
190 'required' => true,
191 'export' => true,
192 'where' => 'civicrm_grant.contact_id',
193 'headerPattern' => '',
194 'dataPattern' => '',
195 'FKClassName' => 'CRM_Contact_DAO_Contact',
196 'html' => array(
197 'type' => 'EntityRef',
198 ) ,
199 ) ,
200 'application_received_date' => array(
201 'name' => 'application_received_date',
202 'type' => CRM_Utils_Type::T_DATE,
203 'title' => ts('Application received date') ,
204 'description' => 'Date on which grant application was received by donor.',
205 'export' => true,
206 'where' => 'civicrm_grant.application_received_date',
207 'headerPattern' => '',
208 'dataPattern' => '',
209 ) ,
210 'decision_date' => array(
211 'name' => 'decision_date',
212 'type' => CRM_Utils_Type::T_DATE,
213 'title' => ts('Decision date') ,
214 'description' => 'Date on which grant decision was made.',
215 'import' => true,
216 'where' => 'civicrm_grant.decision_date',
217 'headerPattern' => '',
218 'dataPattern' => '',
219 'export' => true,
220 'html' => array(
221 'type' => 'Select Date',
222 ) ,
223 ) ,
224 'grant_money_transfer_date' => array(
225 'name' => 'money_transfer_date',
226 'type' => CRM_Utils_Type::T_DATE,
227 'title' => ts('Grant Money transfer date') ,
228 'description' => 'Date on which grant money transfer was made.',
229 'import' => true,
230 'where' => 'civicrm_grant.money_transfer_date',
231 'headerPattern' => '',
232 'dataPattern' => '',
233 'export' => true,
234 'html' => array(
235 'type' => 'Select Date',
236 ) ,
237 ) ,
238 'grant_due_date' => array(
239 'name' => 'grant_due_date',
240 'type' => CRM_Utils_Type::T_DATE,
241 'title' => ts('Grant Due Date') ,
242 'description' => 'Date on which grant report is due.',
243 'html' => array(
244 'type' => 'Select Date',
245 ) ,
246 ) ,
247 'grant_report_received' => array(
248 'name' => 'grant_report_received',
249 'type' => CRM_Utils_Type::T_BOOLEAN,
250 'title' => ts('Grant report received') ,
251 'description' => 'Yes/No field stating whether grant report was received by donor.',
252 'import' => true,
253 'where' => 'civicrm_grant.grant_report_received',
254 'headerPattern' => '',
255 'dataPattern' => '',
256 'export' => true,
257 'html' => array(
258 'type' => 'CheckBox',
259 ) ,
260 ) ,
261 'grant_type_id' => array(
262 'name' => 'grant_type_id',
263 'type' => CRM_Utils_Type::T_INT,
264 'title' => ts('Grant Type') ,
265 'description' => 'Type of grant. Implicit FK to civicrm_option_value in grant_type option_group.',
266 'required' => true,
267 'export' => true,
268 'where' => 'civicrm_grant.grant_type_id',
269 'headerPattern' => '',
270 'dataPattern' => '',
271 'html' => array(
272 'type' => 'Select',
273 ) ,
274 'pseudoconstant' => array(
275 'optionGroupName' => 'grant_type',
276 'optionEditPath' => 'civicrm/admin/options/grant_type',
277 )
278 ) ,
279 'amount_total' => array(
280 'name' => 'amount_total',
281 'type' => CRM_Utils_Type::T_MONEY,
282 'title' => ts('Total Amount') ,
283 'description' => 'Requested grant amount, in default currency.',
284 'required' => true,
285 'precision' => array(
286 20,
287 2
288 ) ,
289 'import' => true,
290 'where' => 'civicrm_grant.amount_total',
291 'headerPattern' => '',
292 'dataPattern' => '/^\d+(\.\d{2})?$/',
293 'export' => true,
294 'html' => array(
295 'type' => 'Text',
296 ) ,
297 ) ,
298 'amount_requested' => array(
299 'name' => 'amount_requested',
300 'type' => CRM_Utils_Type::T_MONEY,
301 'title' => ts('Amount Requested') ,
302 'description' => 'Requested grant amount, in original currency (optional).',
303 'precision' => array(
304 20,
305 2
306 ) ,
307 'html' => array(
308 'type' => 'Text',
309 ) ,
310 ) ,
311 'amount_granted' => array(
312 'name' => 'amount_granted',
313 'type' => CRM_Utils_Type::T_MONEY,
314 'title' => ts('Amount granted') ,
315 'description' => 'Granted amount, in default currency.',
316 'precision' => array(
317 20,
318 2
319 ) ,
320 'import' => true,
321 'where' => 'civicrm_grant.amount_granted',
322 'headerPattern' => '',
323 'dataPattern' => '/^\d+(\.\d{2})?$/',
324 'export' => true,
325 'html' => array(
326 'type' => 'Text',
327 ) ,
328 ) ,
329 'currency' => array(
330 'name' => 'currency',
331 'type' => CRM_Utils_Type::T_STRING,
332 'title' => ts('Grant Currency') ,
333 'description' => '3 character string, value from config setting or input via user.',
334 'required' => true,
335 'maxlength' => 3,
336 'size' => CRM_Utils_Type::FOUR,
337 'html' => array(
338 'type' => 'Select',
339 ) ,
340 'pseudoconstant' => array(
341 'table' => 'civicrm_currency',
342 'keyColumn' => 'name',
343 'labelColumn' => 'full_name',
344 'nameColumn' => 'name',
345 )
346 ) ,
347 'rationale' => array(
348 'name' => 'rationale',
349 'type' => CRM_Utils_Type::T_TEXT,
350 'title' => ts('Grant Rationale') ,
351 'description' => 'Grant rationale.',
352 'rows' => 4,
353 'cols' => 60,
354 'import' => true,
355 'where' => 'civicrm_grant.rationale',
356 'headerPattern' => '',
357 'dataPattern' => '',
358 'export' => true,
359 'html' => array(
360 'type' => 'TextArea',
361 ) ,
362 ) ,
363 'grant_status_id' => array(
364 'name' => 'status_id',
365 'type' => CRM_Utils_Type::T_INT,
366 'title' => ts('Grant Status') ,
367 'description' => 'Id of Grant status.',
368 'required' => true,
369 'import' => true,
370 'where' => 'civicrm_grant.status_id',
371 'headerPattern' => '',
372 'dataPattern' => '',
373 'export' => false,
374 'html' => array(
375 'type' => 'Select',
376 ) ,
377 'pseudoconstant' => array(
378 'optionGroupName' => 'grant_status',
379 'optionEditPath' => 'civicrm/admin/options/grant_status',
380 )
381 ) ,
382 'financial_type_id' => array(
383 'name' => 'financial_type_id',
384 'type' => CRM_Utils_Type::T_INT,
385 'title' => ts('Financial Type') ,
386 'description' => 'FK to Financial Type.',
387 'default' => 'NULL',
388 'FKClassName' => 'CRM_Financial_DAO_FinancialType',
389 'pseudoconstant' => array(
390 'table' => 'civicrm_financial_type',
391 'keyColumn' => 'id',
392 'labelColumn' => 'name',
393 )
394 ) ,
395 );
396 CRM_Core_DAO_AllCoreTables::invoke(__CLASS__, 'fields_callback', Civi::$statics[__CLASS__]['fields']);
397 }
398 return Civi::$statics[__CLASS__]['fields'];
399 }
400 /**
401 * Return a mapping from field-name to the corresponding key (as used in fields()).
402 *
403 * @return array
404 * Array(string $name => string $uniqueName).
405 */
406 static function &fieldKeys() {
407 if (!isset(Civi::$statics[__CLASS__]['fieldKeys'])) {
408 Civi::$statics[__CLASS__]['fieldKeys'] = array_flip(CRM_Utils_Array::collect('name', self::fields()));
409 }
410 return Civi::$statics[__CLASS__]['fieldKeys'];
411 }
412 /**
413 * Returns the names of this table
414 *
415 * @return string
416 */
417 static function getTableName() {
418 return self::$_tableName;
419 }
420 /**
421 * Returns if this table needs to be logged
422 *
423 * @return boolean
424 */
425 function getLog() {
426 return self::$_log;
427 }
428 /**
429 * Returns the list of fields that can be imported
430 *
431 * @param bool $prefix
432 *
433 * @return array
434 */
435 static function &import($prefix = false) {
436 $r = CRM_Core_DAO_AllCoreTables::getImports(__CLASS__, 'grant', $prefix, array());
437 return $r;
438 }
439 /**
440 * Returns the list of fields that can be exported
441 *
442 * @param bool $prefix
443 *
444 * @return array
445 */
446 static function &export($prefix = false) {
447 $r = CRM_Core_DAO_AllCoreTables::getExports(__CLASS__, 'grant', $prefix, array());
448 return $r;
449 }
450 }