diff --git a/module/program/config.php b/module/program/config.php index e0fb96fdb9..b6b804238a 100644 --- a/module/program/config.php +++ b/module/program/config.php @@ -28,3 +28,101 @@ $config->program->PRJCreate = new stdclass(); $config->program->PRJEdit = new stdclass(); $config->program->PRJCreate->requiredFields = 'name,code,begin,end'; $config->program->PRJEdit->requiredFields = 'name,code,begin,end'; + +$config->program->sortFields = new stdclass(); +$config->program->sortFields->idAB = 'id'; +$config->program->sortFields->PRJCode = 'code'; +$config->program->sortFields->PRJModel = 'model'; +$config->program->sortFields->begin = 'begin'; +$config->program->sortFields->end = 'end'; +$config->program->sortFields->PRJStatus = 'status'; +$config->program->sortFields->PRJBudget = 'budget'; + + +global $lang; +$config->program->datatable = new stdclass(); +$config->program->datatable->defaultField = array('idAB', 'PRJCode', 'PRJName', 'PRJModel', 'PRJPM', 'begin', 'end', 'PRJStatus', 'PRJBudget', 'teamCount','PRJEstimate','PRJConsume', 'PRJProgress', 'actions'); + +$config->program->datatable->fieldList['idAB']['title'] = 'idAB'; +$config->program->datatable->fieldList['idAB']['fixed'] = 'left'; +$config->program->datatable->fieldList['idAB']['width'] = '60'; +$config->program->datatable->fieldList['idAB']['required'] = 'yes'; + +$config->program->datatable->fieldList['PRJCode']['title'] = 'PRJCode'; +$config->program->datatable->fieldList['PRJCode']['fixed'] = 'left'; +$config->program->datatable->fieldList['PRJCode']['width'] = '80'; +$config->program->datatable->fieldList['PRJCode']['required'] = 'yes'; + +$config->program->datatable->fieldList['PRJName']['title'] = 'PRJName'; +$config->program->datatable->fieldList['PRJName']['fixed'] = 'left'; +$config->program->datatable->fieldList['PRJName']['width'] = 'auto'; +$config->program->datatable->fieldList['PRJName']['required'] = 'yes'; +$config->program->datatable->fieldList['PRJName']['sort'] = 'no'; + +$config->program->datatable->fieldList['PRJModel']['title'] = 'PRJModel'; +$config->program->datatable->fieldList['PRJModel']['fixed'] = 'left'; +$config->program->datatable->fieldList['PRJModel']['width'] = '80'; +$config->program->datatable->fieldList['PRJModel']['required'] = 'yes'; + +$config->program->datatable->fieldList['PRJPM']['title'] = 'PRJPM'; +$config->program->datatable->fieldList['PRJPM']['fixed'] = 'no'; +$config->program->datatable->fieldList['PRJPM']['width'] = '100'; +$config->program->datatable->fieldList['PRJPM']['required'] = 'yes'; +$config->program->datatable->fieldList['PRJPM']['sort'] = 'no'; + +$config->program->datatable->fieldList['begin']['title'] = 'begin'; +$config->program->datatable->fieldList['begin']['fixed'] = 'no'; +$config->program->datatable->fieldList['begin']['width'] = '120'; +$config->program->datatable->fieldList['begin']['required'] = 'no'; + +$config->program->datatable->fieldList['end']['title'] = 'end'; +$config->program->datatable->fieldList['end']['fixed'] = 'no'; +$config->program->datatable->fieldList['end']['width'] = '120'; +$config->program->datatable->fieldList['end']['required'] = 'no'; + +$config->program->datatable->fieldList['PRJStatus']['title'] = 'PRJStatus'; +$config->program->datatable->fieldList['PRJStatus']['fixed'] = 'no'; +$config->program->datatable->fieldList['PRJStatus']['width'] = '80'; +$config->program->datatable->fieldList['PRJStatus']['required'] = 'yes'; + +$config->program->datatable->fieldList['PRJBudget']['title'] = 'PRJBudget'; +$config->program->datatable->fieldList['PRJBudget']['fixed'] = 'no'; +$config->program->datatable->fieldList['PRJBudget']['width'] = '100'; +$config->program->datatable->fieldList['PRJBudget']['required'] = 'yes'; + +$config->program->datatable->fieldList['teamCount']['title'] = 'teamCount'; +$config->program->datatable->fieldList['teamCount']['fixed'] = 'no'; +$config->program->datatable->fieldList['teamCount']['width'] = '80'; +$config->program->datatable->fieldList['teamCount']['required'] = 'no'; +$config->program->datatable->fieldList['teamCount']['sort'] = 'no'; + +$config->program->datatable->fieldList['PRJEstimate']['title'] = 'PRJEstimate'; +$config->program->datatable->fieldList['PRJEstimate']['fixed'] = 'no'; +$config->program->datatable->fieldList['PRJEstimate']['width'] = '80'; +$config->program->datatable->fieldList['PRJEstimate']['required'] = 'no'; +$config->program->datatable->fieldList['PRJEstimate']['sort'] = 'no'; + +$config->program->datatable->fieldList['PRJConsume']['title'] = 'PRJConsume'; +$config->program->datatable->fieldList['PRJConsume']['fixed'] = 'no'; +$config->program->datatable->fieldList['PRJConsume']['width'] = '80'; +$config->program->datatable->fieldList['PRJConsume']['required'] = 'no'; +$config->program->datatable->fieldList['PRJConsume']['sort'] = 'no'; + + +$config->program->datatable->fieldList['PRJProgress']['title'] = 'PRJProgress'; +$config->program->datatable->fieldList['PRJProgress']['fixed'] = 'right'; +$config->program->datatable->fieldList['PRJProgress']['width'] = '80'; +$config->program->datatable->fieldList['PRJProgress']['required'] = 'no'; +$config->program->datatable->fieldList['PRJProgress']['sort'] = 'no'; + +$config->program->datatable->fieldList['PRJSurplus']['title'] = 'PRJSurplus'; +$config->program->datatable->fieldList['PRJSurplus']['fixed'] = 'no'; +$config->program->datatable->fieldList['PRJSurplus']['width'] = '80'; +$config->program->datatable->fieldList['PRJSurplus']['required'] = 'no'; +$config->program->datatable->fieldList['PRJSurplus']['sort'] = 'no'; + + +$config->program->datatable->fieldList['actions']['title'] = 'actions'; +$config->program->datatable->fieldList['actions']['fixed'] = 'right'; +$config->program->datatable->fieldList['actions']['width'] = '220'; +$config->program->datatable->fieldList['actions']['required'] = 'yes'; diff --git a/module/program/control.php b/module/program/control.php index 364354e8d9..8a7c39a01c 100644 --- a/module/program/control.php +++ b/module/program/control.php @@ -609,6 +609,7 @@ class program extends control $this->lang->program->switcherMenu = $this->program->getPGMCommonAction() . $this->program->getPGMSwitcher($programID); $this->program->setPGMViewMenu($programID); + $this->loadModel('datatable'); $this->app->session->set('PRJBrowse', $this->app->getURI(true)); /* Load pager and get tasks. */ @@ -616,7 +617,9 @@ class program extends control $pager = new pager($recTotal, $recPerPage, $pageID); $programTitle = $this->loadModel('setting')->getItem('owner=' . $this->app->user->account . '&module=program&key=PRJProgramTitle'); - $projectStats = $this->program->getPRJStats($programID, $browseType, 0, $orderBy, $pager, $programTitle); + $order = explode('_', $orderBy); + $sortField = zget($this->config->program->sortFields, $order[0], 'id') . '_' . $order[1]; + $projectStats = $this->program->getPRJStats($programID, $browseType, 0, $sortField, $pager, $programTitle); $this->view->title = $this->lang->program->PRJBrowse; $this->view->position[] = $this->lang->program->PRJBrowse; @@ -801,6 +804,7 @@ class program extends control { $this->lang->navGroup->program = 'project'; $this->app->session->set('PRJBrowse', $this->app->getURI(true)); + $this->loadModel('datatable'); /* Load pager and get tasks. */ $this->app->loadClass('pager', $static = true); @@ -808,7 +812,9 @@ class program extends control $queryID = ($browseType == 'bysearch') ? (int)$param : 0; $programTitle = $this->loadModel('setting')->getItem('owner=' . $this->app->user->account . '&module=program&key=PRJProgramTitle'); - $projectStats = $this->program->getPRJStats($programID, $browseType, $queryID, $orderBy, $pager, $programTitle); + $order = explode('_', $orderBy); + $sortField = zget($this->config->program->sortFields, $order[0], 'id') . '_' . $order[1]; + $projectStats = $this->program->getPRJStats($programID, $browseType, $queryID, $sortField, $pager, $programTitle); $this->view->title = $this->lang->program->PRJBrowse; $this->view->position[] = $this->lang->program->PRJBrowse; diff --git a/module/program/js/prjbrowse.js b/module/program/js/prjbrowse.js index 71ed8d3cbd..d6c443350a 100644 --- a/module/program/js/prjbrowse.js +++ b/module/program/js/prjbrowse.js @@ -6,13 +6,6 @@ $(function() $.cookie('PRJMine', PRJMine, {expires:config.cookieLife, path:config.webRoot}); window.location.reload(); }); - - $('#projectTableList').on('sort.sortable', function(e, data) - { - var list = ''; - for(i = 0; i < data.list.length; i++) list += $(data.list[i].item).attr('data-id') + ','; - $.post(createLink('program', 'PRJUpdateOrder'), {'projects' : list, 'orderBy' : orderBy}); - }); }); $('#project' + programID).addClass('active'); diff --git a/module/program/model.php b/module/program/model.php index 0202873aa3..d2421854de 100644 --- a/module/program/model.php +++ b/module/program/model.php @@ -1215,4 +1215,92 @@ class programModel extends model } return $stats; } + + /** + * Print datatable cell. + * + * @param object $col + * @param object $project + * @param array $users + * @param int $programID + * @access public + * @return void + */ + public function printCell($col, $project, $users, $programID = 0) + { + $canOrder = common::hasPriv('program', 'PRJOrderUpdate'); + $account = $this->app->user->account; + $id = $col->id; + + if($col->show) + { + $class = "c-$id"; + $title = ''; + + if($id == 'idAB') $class .= ' cell-id'; + + if($id == 'PRJName') + { + $class .= ' text-left'; + $title = "title='{$project->name}'"; + } + + echo "