Add comment blocks
[civicrm-core.git] / CRM / Core / DAO / Discount.php
CommitLineData
e501603b
TO
1<?php
2/*
3+--------------------------------------------------------------------+
4| CiviCRM version 4.7 |
5+--------------------------------------------------------------------+
0f03f337 6| Copyright CiviCRM LLC (c) 2004-2017 |
e501603b
TO
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
0f03f337 29 * @copyright CiviCRM LLC (c) 2004-2017
e501603b
TO
30 *
31 * Generated from xml/schema/CRM/Core/Discount.xml
32 * DO NOT EDIT. Generated by CRM_Core_CodeGen
437fafcf 33 * (GenCodeChecksum:b82536086f7f2111cddc36452c9aeb9e)
e501603b
TO
34 */
35require_once 'CRM/Core/DAO.php';
36require_once 'CRM/Utils/Type.php';
37class CRM_Core_DAO_Discount extends CRM_Core_DAO {
38 /**
39 * static instance to hold the table name
40 *
41 * @var string
42 */
43 static $_tableName = 'civicrm_discount';
e501603b
TO
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 * primary key
53 *
54 * @var int unsigned
55 */
56 public $id;
57 /**
58 * physical tablename for entity being joined to discount, e.g. civicrm_event
59 *
60 * @var string
61 */
62 public $entity_table;
63 /**
64 * FK to entity table specified in entity_table column.
65 *
66 * @var int unsigned
67 */
68 public $entity_id;
69 /**
70 * FK to civicrm_price_set
71 *
72 * @var int unsigned
73 */
74 public $price_set_id;
75 /**
76 * Date when discount starts.
77 *
78 * @var date
79 */
80 public $start_date;
81 /**
82 * Date when discount ends.
83 *
84 * @var date
85 */
86 public $end_date;
87 /**
88 * class constructor
89 *
90 * @return civicrm_discount
91 */
92 function __construct() {
93 $this->__table = 'civicrm_discount';
94 parent::__construct();
95 }
96 /**
97 * Returns foreign keys and entity references
98 *
99 * @return array
100 * [CRM_Core_Reference_Interface]
101 */
102 static function getReferenceColumns() {
346aaaba
TO
103 if (!isset(Civi::$statics[__CLASS__]['links'])) {
104 Civi::$statics[__CLASS__]['links'] = static ::createReferenceColumns(__CLASS__);
105 Civi::$statics[__CLASS__]['links'][] = new CRM_Core_Reference_Basic(self::getTableName() , 'price_set_id', 'civicrm_price_set', 'id');
106 Civi::$statics[__CLASS__]['links'][] = new CRM_Core_Reference_Dynamic(self::getTableName() , 'entity_id', NULL, 'id', 'entity_table');
107 CRM_Core_DAO_AllCoreTables::invoke(__CLASS__, 'links_callback', Civi::$statics[__CLASS__]['links']);
e501603b 108 }
346aaaba 109 return Civi::$statics[__CLASS__]['links'];
e501603b
TO
110 }
111 /**
112 * Returns all the column names of this table
113 *
114 * @return array
115 */
116 static function &fields() {
346aaaba
TO
117 if (!isset(Civi::$statics[__CLASS__]['fields'])) {
118 Civi::$statics[__CLASS__]['fields'] = array(
e501603b
TO
119 'id' => array(
120 'name' => 'id',
121 'type' => CRM_Utils_Type::T_INT,
122 'title' => ts('Discount ID') ,
123 'description' => 'primary key',
124 'required' => true,
125 ) ,
126 'entity_table' => array(
127 'name' => 'entity_table',
128 'type' => CRM_Utils_Type::T_STRING,
129 'title' => ts('Entity Table') ,
130 'description' => 'physical tablename for entity being joined to discount, e.g. civicrm_event',
131 'maxlength' => 64,
132 'size' => CRM_Utils_Type::BIG,
133 ) ,
134 'entity_id' => array(
135 'name' => 'entity_id',
136 'type' => CRM_Utils_Type::T_INT,
137 'title' => ts('Entity ID') ,
138 'description' => 'FK to entity table specified in entity_table column.',
139 'required' => true,
140 ) ,
141 'participant_discount_name' => array(
142 'name' => 'price_set_id',
143 'type' => CRM_Utils_Type::T_INT,
144 'title' => ts('Discount Name') ,
145 'description' => 'FK to civicrm_price_set',
146 'required' => true,
147 'export' => true,
148 'where' => 'civicrm_discount.price_set_id',
149 'headerPattern' => '',
150 'dataPattern' => '',
151 'FKClassName' => 'CRM_Price_DAO_PriceSet',
152 ) ,
153 'start_date' => array(
154 'name' => 'start_date',
155 'type' => CRM_Utils_Type::T_DATE,
156 'title' => ts('Discount Start Date') ,
157 'description' => 'Date when discount starts.',
158 ) ,
159 'end_date' => array(
160 'name' => 'end_date',
161 'type' => CRM_Utils_Type::T_DATE,
162 'title' => ts('Discount End Date') ,
163 'description' => 'Date when discount ends.',
164 ) ,
165 );
346aaaba 166 CRM_Core_DAO_AllCoreTables::invoke(__CLASS__, 'fields_callback', Civi::$statics[__CLASS__]['fields']);
e501603b 167 }
346aaaba 168 return Civi::$statics[__CLASS__]['fields'];
e501603b
TO
169 }
170 /**
bd8e0b14 171 * Return a mapping from field-name to the corresponding key (as used in fields()).
e501603b
TO
172 *
173 * @return array
bd8e0b14 174 * Array(string $name => string $uniqueName).
e501603b
TO
175 */
176 static function &fieldKeys() {
bd8e0b14
TO
177 if (!isset(Civi::$statics[__CLASS__]['fieldKeys'])) {
178 Civi::$statics[__CLASS__]['fieldKeys'] = array_flip(CRM_Utils_Array::collect('name', self::fields()));
e501603b 179 }
bd8e0b14 180 return Civi::$statics[__CLASS__]['fieldKeys'];
e501603b
TO
181 }
182 /**
183 * Returns the names of this table
184 *
185 * @return string
186 */
187 static function getTableName() {
188 return self::$_tableName;
189 }
190 /**
191 * Returns if this table needs to be logged
192 *
193 * @return boolean
194 */
195 function getLog() {
196 return self::$_log;
197 }
198 /**
199 * Returns the list of fields that can be imported
200 *
201 * @param bool $prefix
202 *
203 * @return array
204 */
205 static function &import($prefix = false) {
60808919
TO
206 $r = CRM_Core_DAO_AllCoreTables::getImports(__CLASS__, 'discount', $prefix, array());
207 return $r;
e501603b
TO
208 }
209 /**
210 * Returns the list of fields that can be exported
211 *
212 * @param bool $prefix
213 *
214 * @return array
215 */
216 static function &export($prefix = false) {
60808919
TO
217 $r = CRM_Core_DAO_AllCoreTables::getExports(__CLASS__, 'discount', $prefix, array());
218 return $r;
e501603b
TO
219 }
220}