Beta2 bug fix. 31237 Option to display current amount instead of percentage
[com.zyxware.civiwci.git] / CRM / Wci / DAO / ProgressBar.php
1 <?php
2 /*
3 +--------------------------------------------------------------------+
4 | CiviCRM version 4.4 |
5 +--------------------------------------------------------------------+
6 | Copyright CiviCRM LLC (c) 2004-2013 |
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 *
29 * @package CRM
30 * @copyright CiviCRM LLC (c) 2004-2013
31 */
32 class CRM_Wci_DAO_ProgressBar extends CRM_Core_DAO
33 {
34 /**
35 * static instance to hold the table name
36 *
37 * @var string
38 * @static
39 */
40 static $_tableName = 'civicrm_wci_progress_bar';
41 /**
42 * static instance to hold the field values
43 *
44 * @var array
45 * @static
46 */
47 static $_fields = null;
48 /**
49 * static instance to hold the keys used in $_fields for each field.
50 *
51 * @var array
52 * @static
53 */
54 static $_fieldKeys = null;
55 /**
56 * static instance to hold the FK relationships
57 *
58 * @var string
59 * @static
60 */
61 static $_links = null;
62 /**
63 * static instance to hold the values that can
64 * be imported
65 *
66 * @var array
67 * @static
68 */
69 static $_import = null;
70 /**
71 * static instance to hold the values that can
72 * be exported
73 *
74 * @var array
75 * @static
76 */
77 static $_export = null;
78 /**
79 * static value to see if we should log any modifications to
80 * this table in the civicrm_log table
81 *
82 * @var boolean
83 * @static
84 */
85 static $_log = true;
86 /**
87 * Progress bar Id
88 *
89 * @var int unsigned
90 */
91 public $id;
92 /**
93 * Name of progress bar
94 *
95 * @var string
96 */
97 public $name;
98 /**
99 * Arbitrary starting amount
100 *
101 * @var float
102 */
103 public $starting_amount;
104 function __construct()
105 {
106 $this->__table = 'civicrm_wci_progress_bar';
107 parent::__construct();
108 }
109 /**
110 * return foreign keys and entity references
111 *
112 * @static
113 * @access public
114 * @return array of CRM_Core_EntityReference
115 */
116 static function getReferenceColumns()
117 {
118 return self::$_links;
119 }
120 /**
121 * returns all the column names of this table
122 *
123 * @access public
124 * @return array
125 */
126 static function &fields()
127 {
128 if (!(self::$_fields)) {
129 self::$_fields = array(
130 'progress_bar_id' => array(
131 'name' => 'id',
132 'type' => CRM_Utils_Type::T_INT,
133 'title' => ts('WCI Progress Bar Id', array('domain' => 'org.civicrm.wci')) ,
134 'required' => true,
135 ) ,
136 'name' => array(
137 'name' => 'name',
138 'type' => CRM_Utils_Type::T_STRING,
139 'title' => ts('Progress Bar Name', array('domain' => 'org.civicrm.wci')) ,
140 'required' => true,
141 'maxlength' => 64,
142 ) ,
143 'starting_amount' => array(
144 'name' => 'starting_amount',
145 'type' => CRM_Utils_Type::T_FLOAT,
146 'required' => false,
147 ) ,
148 'goal_amount' => array(
149 'name' => 'goal_amount',
150 'type' => CRM_Utils_Type::T_FLOAT,
151 'required' => false,
152 ) ,
153 );
154 }
155 return self::$_fields;
156 }
157 /**
158 * Returns an array containing, for each field, the arary key used for that
159 * field in self::$_fields.
160 *
161 * @access public
162 * @return array
163 */
164 static function &fieldKeys()
165 {
166 if (!(self::$_fieldKeys)) {
167 self::$_fieldKeys = array(
168 'id' => 'progress_bar_id',
169 'name' => 'name',
170 'starting_amount' => 'starting_amount',
171 'goal_amount' => 'goal_amount',
172 );
173 }
174 return self::$_fieldKeys;
175 }
176 /**
177 * returns the names of this table
178 *
179 * @access public
180 * @static
181 * @return string
182 */
183 static function getTableName()
184 {
185 return self::$_tableName;
186 }
187 /**
188 * returns if this table needs to be logged
189 *
190 * @access public
191 * @return boolean
192 */
193 function getLog()
194 {
195 return self::$_log;
196 }
197 /**
198 * returns the list of fields that can be imported
199 *
200 * @access public
201 * return array
202 * @static
203 */
204 static function &import($prefix = false)
205 {
206 if (!(self::$_import)) {
207 self::$_import = array();
208 $fields = self::fields();
209 foreach($fields as $name => $field) {
210 if (CRM_Utils_Array::value('import', $field)) {
211 if ($prefix) {
212 self::$_import['wci_progress_bar'] = & $fields[$name];
213 } else {
214 self::$_import[$name] = & $fields[$name];
215 }
216 }
217 }
218 }
219 return self::$_import;
220 }
221 /**
222 * returns the list of fields that can be exported
223 *
224 * @access public
225 * return array
226 * @static
227 */
228 static function &export($prefix = false)
229 {
230 if (!(self::$_export)) {
231 self::$_export = array();
232 $fields = self::fields();
233 foreach($fields as $name => $field) {
234 if (CRM_Utils_Array::value('export', $field)) {
235 if ($prefix) {
236 self::$_export['wci_progress_bar'] = & $fields[$name];
237 } else {
238 self::$_export[$name] = & $fields[$name];
239 }
240 }
241 }
242 }
243 return self::$_export;
244 }
245 }