00001 <?php
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025 require_once FASTFRAME_ROOT . 'lib/FastFrame/Model.php';
00026
00027
00028
00029
00030
00031 define('TYPE_TEXT', 1);
00032 define('TYPE_TEXTAREA', 2);
00033 define('TYPE_DATE', 3);
00034 define('TYPE_DATETIME', 4);
00035 define('TYPE_CHECKBOX', 5);
00036
00037
00038
00039
00050
00051 class FF_Model_CustomField extends FF_Model {
00052
00053
00058 var $categoryId;
00059
00064 var $description;
00065
00070 var $type;
00071
00072
00073
00074
00081 function reset()
00082 {
00083 $this->id = null;
00084 $this->categoryId = null;
00085 $this->description = null;
00086 $this->type = null;
00087 }
00088
00089
00090
00091
00100 function importFromArray($in_data)
00101 {
00102 $this->setId($in_data['id']);
00103 $this->setCategoryId($in_data['category_id']);
00104 $this->setDescription($in_data['description']);
00105 $this->setType($in_data['type']);
00106 }
00107
00108
00109
00110
00119 function exportToArray()
00120 {
00121 $a_data = array();
00122 $a_data['id'] = $this->getId();
00123 $a_data['category_id'] = $this->getCategoryId();
00124 $a_data['description'] = $this->getDescription();
00125 $a_data['type'] = $this->getType();
00126 return $a_data;
00127 }
00128
00129
00130
00131
00142 function saveData($in_fields, $in_ticketId, &$in_result)
00143 {
00144 $this->o_dataAccess->removeDataForTicket($in_ticketId);
00145 foreach ((array) $in_fields as $s_fieldId => $s_data) {
00146 if (!FastFrame::isEmpty($s_data)) {
00147
00148 if (is_array($s_data)) {
00149 $s_data = mktime(@$s_data['H'], @$s_data['i'], 0, $s_data['M'], $s_data['d'], $s_data['Y']);
00150 }
00151
00152 $this->o_dataAccess->saveData($s_fieldId, $in_ticketId, $s_data, $in_result);
00153 }
00154 }
00155 }
00156
00157
00158
00159
00166 function getCategoriesWithField()
00167 {
00168 return $this->o_dataAccess->getCategoriesWithField();
00169 }
00170
00171
00172
00173
00184 function getFieldsByCategory($in_catId, $in_ticketId = null)
00185 {
00186 return $this->o_dataAccess->getFieldsByCategory($in_catId, $in_ticketId);
00187 }
00188
00189
00190
00191
00192 function getCategoryId()
00193 {
00194 return $this->categoryId;
00195 }
00196
00197
00198
00199
00200 function setCategoryId($in_value)
00201 {
00202 $this->categoryId = $in_value;
00203 }
00204
00205
00206
00207
00208 function getDescription()
00209 {
00210 return $this->description;
00211 }
00212
00213
00214
00215
00216 function setDescription($in_value)
00217 {
00218 $this->description = $in_value;
00219 }
00220
00221
00222
00223
00224 function getTypeOptions()
00225 {
00226 return array(TYPE_TEXT => _('Text'), TYPE_TEXTAREA => _('Text Area'),
00227 TYPE_DATE => _('Date'), TYPE_DATETIME => _('Date & Time'),
00228 TYPE_CHECKBOX => _('Checkbox'));
00229 }
00230
00231
00232
00233
00234 function getType($in_asString = false)
00235 {
00236 if ($in_asString) {
00237 switch($this->type) {
00238 case TYPE_TEXT:
00239 return _('Text');
00240 break;
00241 case TYPE_TEXTAREA:
00242 return _('Text Area');
00243 break;
00244 case TYPE_DATE:
00245 return _('Date');
00246 break;
00247 case TYPE_DATETIME:
00248 return _('Date & Time');
00249 break;
00250 case TYPE_CHECKBOX:
00251 return _('Checkbox');
00252 break;
00253 default:
00254 return _('Unknown');
00255 break;
00256 }
00257 }
00258 else {
00259 return $this->type;
00260 }
00261 }
00262
00263
00264
00265
00266 function setType($in_value)
00267 {
00268 $this->type = $in_value;
00269 }
00270
00271
00272
00273
00280 function _initDataAccess()
00281 {
00282 $this->o_dataAccess =& FF_DataAccess::factory('CustomField');
00283 }
00284
00285
00286 }
00287 ?>