* @package datatable * @version $Id$ * @link http://www.zentao.net */ ?> config->$module)) $this->loadModel($module); if($this->session->hasProduct == 0 and (strpos($this->config->datatable->noProductModule, ",$module,") !== false)) { $productIndex = array_search('product', $this->config->$module->datatable->defaultField); if($productIndex) unset($this->config->$module->datatable->defaultField[$productIndex]); if(isset($this->config->$module->datatable->fieldList['product'])) unset($this->config->$module->datatable->fieldList['product']); } if($this->session->currentProductType === 'normal') unset($this->config->$module->datatable->fieldList['branch']); foreach($this->config->$module->datatable->fieldList as $field => $items) { if($field === 'branch') { if($this->session->currentProductType === 'branch') $this->config->$module->datatable->fieldList[$field]['title'] = $this->lang->datatable->branch; if($this->session->currentProductType === 'platform') $this->config->$module->datatable->fieldList[$field]['title'] = $this->lang->datatable->platform; continue; } $title = zget($this->lang->$module, $items['title'], zget($this->lang, $items['title'], $items['title'])); $this->config->$module->datatable->fieldList[$field]['title'] = $title; } if($this->config->edition != 'open') { $fields = $this->loadModel('workflowfield')->getList($module); foreach($fields as $field) { if($field->buildin) continue; $this->config->$module->datatable->fieldList[$field->field]['title'] = $field->name; $this->config->$module->datatable->fieldList[$field->field]['width'] = '120'; $this->config->$module->datatable->fieldList[$field->field]['fixed'] = 'no'; $this->config->$module->datatable->fieldList[$field->field]['required'] = 'no'; } } return $this->config->$module->datatable->fieldList; } /** * Get save setting field. * * @param string $module * @access public * @return object */ public function getSetting($module) { $method = $this->app->getMethodName(); $datatableId = $module . ucfirst($method); $mode = isset($this->config->datatable->$datatableId->mode) ? $this->config->datatable->$datatableId->mode : 'table'; $key = $mode == 'datatable' ? 'cols' : 'tablecols'; $module = zget($this->config->datatable->moduleAlias, "$module-$method", $module); if(!isset($this->config->$module)) $this->loadModel($module); if(isset($this->config->datatable->$datatableId->$key)) $setting = json_decode($this->config->datatable->$datatableId->$key); $fieldList = $this->getFieldList($module); if(empty($setting)) { $setting = $this->config->$module->datatable->defaultField; $order = 1; foreach($setting as $key => $value) { $id = $value; $set = new stdclass();; $set->order = $order++; $set->id = $id; $set->show = true; $set->width = $fieldList[$id]['width']; $set->fixed = $fieldList[$id]['fixed']; $set->title = $fieldList[$id]['title']; $set->sort = isset($fieldList[$id]['sort']) ? $fieldList[$id]['sort'] : 'yes'; $set->name = isset($fieldList[$id]['name']) ? $fieldList[$id]['name'] : ''; if(isset($fieldList[$id]['minWidth'])) $set->minWidth = $fieldList[$id]['minWidth']; if(isset($fieldList[$id]['maxWidth'])) $set->maxWidth = $fieldList[$id]['maxWidth']; if(isset($fieldList[$id]['pri'])) $set->pri = $fieldList[$id]['pri']; $setting[$key] = $set; } } else { foreach($setting as $key => $set) { if(!isset($fieldList[$set->id])) { unset($setting[$key]); continue; } if($this->session->currentProductType === 'normal' and $set->id === 'branch') { unset($setting[$key]); continue; } if($set->id == 'actions') $set->width = $fieldList[$set->id]['width']; $set->title = $fieldList[$set->id]['title']; $set->sort = isset($fieldList[$set->id]['sort']) ? $fieldList[$set->id]['sort'] : 'yes'; } } usort($setting, array('datatableModel', 'sortCols')); return $setting; } /** * Sort cols. * * @param int $a * @param int $b * @static * @access public * @return int */ public static function sortCols($a, $b) { if(!isset($a->order)) return 0; return $a->order - $b->order; } /** * Print table head. * * @param object $col * @param string $orderBy * @param string $vars * @param bool $checkBox * @access public * @return void */ public function printHead($col, $orderBy, $vars, $checkBox = true) { $id = $col->id; if($col->show) { $fixed = $col->fixed == 'no' ? 'true' : 'false'; $width = is_numeric($col->width) ? "{$col->width}px" : $col->width; $title = isset($col->title) ? "title='$col->title'" : ''; $title = (isset($col->name) and $col->name) ? "title='$col->name'" : $title; if($id == 'id' and (int)$width < 90) $width = '90px'; $align = $id == 'actions' ? 'text-center' : ''; $align = in_array($id, array('budget', 'teamCount', 'estimate', 'consume', 'consumed', 'left')) ? 'text-right' : $align; $style = ''; $data = ''; $data .= "data-width='$width'"; $style .= "width:$width;"; if(isset($col->minWidth)) { $data .= "data-minWidth='{$col->minWidth}px'"; $style .= "min-width:{$col->minWidth}px;"; } if(isset($col->maxWidth)) { $data .= "data-maxWidth='{$col->maxWidth}px'"; $style .= "max-width:{$col->maxWidth}px;"; } if(isset($col->pri)) $data .= "data-pri='{$col->pri}'"; echo "