* Finish task #7850,#7854.

This commit is contained in:
Yagami
2020-09-17 16:39:53 +08:00
parent 0a438c628d
commit fc036c5d99
14 changed files with 892 additions and 159 deletions
+1 -1
View File
@@ -135,7 +135,7 @@ $lang->dividerMenu = ',admin,';
$lang->program = new stdclass();
$lang->program->menu = new stdclass();
$lang->program->menu->index = '主页|program|pgmindex|';
$lang->program->menu->browse = '项目集|program|pgmbrowse|';
$lang->program->menu->browse = array('link' => '项目集|program|pgmbrowse|', 'alias' => 'pgmcreate,pgmedit');
/* Product menu. */
$lang->productlist = new stdclass();
+11 -11
View File
@@ -1,18 +1,18 @@
<?php
$config->program = new stdclass();
$config->program->editor = new stdclass();
$config->program->editor->create = array('id' => 'desc', 'tools' => 'simpleTools');
$config->program->editor->edit = array('id' => 'desc', 'tools' => 'simpleTools');
$config->program->editor->close = array('id' => 'comment', 'tools' => 'simpleTools');
$config->program->editor->start = array('id' => 'comment', 'tools' => 'simpleTools');
$config->program->editor->activate = array('id' => 'comment', 'tools' => 'simpleTools');
$config->program->editor->finish = array('id' => 'comment', 'tools' => 'simpleTools');
$config->program->editor->suspend = array('id' => 'comment', 'tools' => 'simpleTools');
$config->program->editor->pgmcreate = array('id' => 'desc', 'tools' => 'simpleTools');
$config->program->editor->pgmedit = array('id' => 'desc', 'tools' => 'simpleTools');
$config->program->editor->pgmclose = array('id' => 'comment', 'tools' => 'simpleTools');
$config->program->editor->pgmstart = array('id' => 'comment', 'tools' => 'simpleTools');
$config->program->editor->pgmactivate = array('id' => 'comment', 'tools' => 'simpleTools');
$config->program->editor->pgmfinish = array('id' => 'comment', 'tools' => 'simpleTools');
$config->program->editor->pgmsuspend = array('id' => 'comment', 'tools' => 'simpleTools');
$config->program->list = new stdclass();
$config->program->list->exportFields = 'id,name,code,template,category,status,begin,end,budget,PM,end,desc';
$config->program->create = new stdclass();
$config->program->edit = new stdclass();
$config->program->create->requiredFields = 'name,code,begin,end';
$config->program->edit->requiredFields = 'name,code,begin,end';
$config->program->PGMCreate = new stdclass();
$config->program->PGMEdit = new stdclass();
$config->program->PGMCreate->requiredFields = 'name,code,begin,end';
$config->program->PGMEdit->requiredFields = 'name,code,begin,end';
+76 -50
View File
@@ -52,10 +52,10 @@ class program extends control
* @access public
* @return void
*/
public function PGMBrowse($status = 'doing', $orderBy = 'order_desc', $recTotal = 0, $recPerPage = 50, $pageID = 1)
public function PGMBrowse($status = 'all', $orderBy = 'order_desc', $recTotal = 0, $recPerPage = 50, $pageID = 1)
{
$this->lang->navGroup->program = 'program';
if(common::hasPriv('program', 'createGuide')) $this->lang->pageActions = html::a($this->createLink('program', 'createGuide'), "<i class='icon icon-sm icon-plus'></i> " . $this->lang->program->create, '', "class='btn btn-primary' data-toggle=modal");
if(common::hasPriv('program', 'pgmcreate')) $this->lang->pageActions = html::a($this->createLink('program', 'pgmcreate'), "<i class='icon icon-sm icon-plus'></i> " . $this->lang->program->PGMCreate, '', "class='btn btn-primary'");
$this->app->session->set('programList', $this->app->getURI(true));
@@ -104,62 +104,66 @@ class program extends control
* @access public
* @return void
*/
public function create($template = 'waterfall', $parentProgramID = 0, $copyProgramID = '')
public function PGMCreate($parentProgramID = 0)
{
$this->lang->navGroup->program = 'program';
if($_POST)
{
$projectID = $this->program->create();
$projectID = $this->program->PGMCreate();
if(dao::isError()) $this->send(array('result' => 'fail', 'message' => $this->processErrors(dao::getError())));
$this->loadModel('action')->create('program', $projectID, 'opened');
$this->send(array('result' => 'success', 'message' => $this->lang->saveSuccess, 'locate' => inlink('browse', array('status' => 'wait', 'orderBy' => 'order_desc'))));
$this->send(array('result' => 'success', 'message' => $this->lang->saveSuccess, 'locate' => inlink('pgmbrowse', array('status' => 'wait', 'orderBy' => 'order_desc'))));
}
$name = '';
$code = '';
$team = '';
$whitelist = '';
$acl = 'open';
$privway = 'extend';
$this->view->title = $this->lang->program->PGMCreate;
$this->view->position[] = $this->lang->program->PGMCreate;
if($parentProgramID)
{
$parentProgram = $this->dao->select('*')->from(TABLE_PROJECT)->where('id')->eq($parentProgramID)->fetch();
if($this->program->checkHasContent($parentProgramID))
{
echo js::alert($this->lang->program->cannotCreateChild);
die(js::locate('back'));
}
if(empty($template)) $template = $parentProgram->template;
}
if($copyProgramID)
{
$copyProgram = $this->dao->select('*')->from(TABLE_PROJECT)->where('id')->eq($copyProgramID)->fetch();
$name = $copyProgram->name;
$code = $copyProgram->code;
$team = $copyProgram->team;
$acl = $copyProgram->acl;
$privway = $copyProgram->privway;
$whitelist = $copyProgram->whitelist;
if(empty($template)) $template = $copyProgram->template;
}
$this->view->title = $this->lang->program->create;
$this->view->position[] = $this->lang->program->create;
$this->view->groups = $this->loadModel('group')->getPairs();
$this->view->pmUsers = $this->loadModel('user')->getPairs('noclosed|nodeleted|pmfirst');
$this->view->programs = array('' => '') + $this->program->getPairsByTemplate($template);
$this->view->template = $template;
$this->view->name = $name;
$this->view->code = $code;
$this->view->team = $team;
$this->view->acl = $acl;
$this->view->privway = $privway;
$this->view->whitelist = $whitelist;
$this->view->parentProgram = $parentProgramID ? $parentProgram : '';
$this->view->copyProgramID = $copyProgramID;
$this->view->parentProgram = $parentProgramID ? $this->dao->select('*')->from(TABLE_PROGRAM)->where('id')->eq($parentProgramID)->fetch() : '';
$this->view->parents = $this->program->getParentPairs();
$this->display();
}
/**
* Edit a program.
*
* @param int $programID
* @access public
* @return void
*/
public function PGMEdit($programID = 0)
{
$this->lang->navGroup->program = 'program';
$program = $this->project->getByID($programID);
if($_POST)
{
$changes = $this->program->PGMUpdate($programID);
if(dao::isError()) $this->send(array('result' => 'fail', 'message' => $this->processErrors(dao::getError())));
if($changes)
{
$actionID = $this->loadModel('action')->create('program', $programID, 'edited');
$this->action->logHistory($actionID, $changes);
}
$url = $this->session->PRJList ? $this->session->PRJList : inlink('pgmbrowse');
$this->send(array('result' => 'success', 'message' => $this->lang->saveSuccess, 'locate' => $url));
}
$parents = $this->program->getParentPairs();
unset($parents[$programID]);
$this->view->title = $this->lang->program->PGMEdit;
$this->view->position[] = $this->lang->program->PGMEdit;
$this->view->pmUsers = $this->loadModel('user')->getPairs('noclosed|nodeleted|pmfirst', $program->PM);
$this->view->program = $program;
$this->view->parents = $parents;
$this->view->groups = $this->loadModel('group')->getPairs();
$this->display();
}
@@ -188,18 +192,40 @@ class program extends control
$this->send(array('result' => 'success', 'message' => $this->lang->saveSuccess, 'locate' => $url));
}
$parents = $this->program->getParentPairs($program->template);
$parents = $this->program->getParentPairs();
unset($parents[$programID]);
$this->view->pmUsers = $this->loadModel('user')->getPairs('noclosed|nodeleted|pmfirst', $program->PM);
$this->view->title = $this->lang->program->edit;
$this->view->position[] = $this->lang->program->edit;
$this->view->title = $this->lang->program->PGMEdit;
$this->view->position[] = $this->lang->program->PGMEdit;
$this->view->program = $program;
$this->view->parents = $parents;
$this->view->groups = $this->loadModel('group')->getPairs();
$this->display();
}
/**
* Delete a program.
*
* @param int $projectID
* @param varchar $confirm
* @access public
* @return void
*/
public function PGMDelete($programID, $confirm = 'no')
{
$childrenCount = $this->dao->select('count(*) as count')->from(TABLE_PROGRAM)->where('parent')->eq($programID)->andWhere('deleted')->eq(0)->fetch('count');
if($childrenCount) die(js::alert($this->lang->program->hasChildren));
$program = $this->dao->select('*')->from(TABLE_PROGRAM)->where('id')->eq($programID)->fetch();
if($confirm == 'no') die(js::confirm(sprintf($this->lang->program->confirmDelete, $program->name), $this->createLink('program', 'delete', "programID=$programID&confirm=yes")));
$this->dao->update(TABLE_PROGRAM)->set('deleted')->eq(1)->where('id')->eq($programID)->exec();
$this->loadModel('action')->create('program', $programID, 'deleted', '', $extra = ACTIONMODEL::CAN_UNDELETED);
die(js::reload('parent'));
}
/**
* Browse groups.
*
+1
View File
@@ -0,0 +1 @@
#mainMenu .pull-left .checkbox-primary {display: inline-block; margin-left: 10px;}
+15 -5
View File
@@ -22,7 +22,7 @@ $lang->program->PRJExport = '导出';
$lang->program->PRJManageGroupMember = '维护分组用户';
/* Fields. */
$lang->program->PRJCommon = '项目';
$lang->program->common = '项目';
$lang->program->stage = '阶段';
$lang->program->PRJName = '项目名称';
$lang->program->PRJTemplate = '项目模板';
@@ -43,7 +43,7 @@ $lang->program->bygrid = '看板';
$lang->program->bylist = '列表';
$lang->program->mine = '我参与的';
$lang->program->setPlanduration = '设置工期';
$lang->program->privway = '权限控制';
$lang->program->auth = '权限控制';
$lang->program->durationEstimation = '工作量估算';
$lang->program->PRJProgress = '项目进度';
$lang->program->teamCount = '投入人数';
@@ -86,8 +86,8 @@ $lang->program->PRJAclList['open'] = "默认设置(有项目视图权限,
$lang->program->PRJAclList['private'] = "私有项目(只有项目团队成员才能访问)";
$lang->program->PRJAclList['custom'] = "自定义白名单(团队成员和白名单的成员可以访问)";
$lang->program->PRJPrivwayList['extend'] = '继承(取项目权限与组织权限的并集)';
$lang->program->PRJPrivwayList['reset'] = '重新定义(只取项目权限)';
$lang->program->PRJAuthList['extend'] = '继承(取项目权限与组织权限的并集)';
$lang->program->PRJAuthList['reset'] = '重新定义(只取项目权限)';
$lang->program->statusList['wait'] = '未开始';
$lang->program->statusList['doing'] = '进行中';
@@ -160,4 +160,14 @@ $lang->program->PGMAllInput = '项目集总投入';
$lang->program->PGMTeamCount = '项目集成员';
$lang->program->PGMLongTime = '长期项目';
$lang->program->noPGM = '暂时没有项目集';
$lang->program->noPGM = '暂时没有项目集';
$lang->program->PGMShowClosed = '显示已关闭';
$lang->program->PGMAclList['open'] = "默认设置(有项目视图权限,即可访问)";
$lang->program->PGMAclList['private'] = "私有项目(只有项目团队成员才能访问)";
$lang->program->PGMAclList['custom'] = "自定义白名单(团队成员和白名单的成员可以访问)";
$lang->program->PGMAuthList['extend'] = '继承(取项目权限与组织权限的并集)';
$lang->program->PGMAuthList['reset'] = '重新定义(只取项目权限)';
$lang->program->PGMFeatureBar['all'] = '所有';
+226 -44
View File
@@ -14,7 +14,7 @@ class programModel extends model
*/
public function getList($status = 'all', $orderBy = 'id_desc', $pager = NULL, $includeCat = false, $mine = false)
{
return $this->dao->select('*')->from(TABLE_PROJECT)
return $this->dao->select('*')->from(TABLE_PROGRAM)
->where('type')->eq('program')
->andWhere('deleted')->eq(0)
->beginIF(!$this->app->user->admin)->andWhere('id')->in($this->app->user->view->programs)->fi()
@@ -37,7 +37,7 @@ class programModel extends model
*/
public function getPairs()
{
return $this->dao->select('id, name')->from(TABLE_PROJECT)
return $this->dao->select('id, name')->from(TABLE_PROGRAM)
->where('type')->eq('program')
->andWhere('deleted')->eq(0)
->beginIF(!$this->app->user->admin)->andWhere('id')->in($this->app->user->view->programs)->fi()
@@ -53,7 +53,7 @@ class programModel extends model
*/
public function getPairsByTemplate($model)
{
return $this->dao->select('id, name')->from(TABLE_PROJECT)
return $this->dao->select('id, name')->from(TABLE_PROGRAM)
->where('type')->eq('program')
->andWhere('model')->eq($model)
->andWhere('deleted')->eq(0)
@@ -75,7 +75,7 @@ class programModel extends model
public function getProgramOverview($queryType = 'byStatus', $param = 'all', $orderBy = 'id_desc', $limit = 15)
{
$queryType = strtolower($queryType);
$programs = $this->dao->select('*')->from(TABLE_PROJECT)
$programs = $this->dao->select('*')->from(TABLE_PROGRAM)
->where('type')->eq('program')
->andWhere('deleted')->eq(0)
->beginIF(!$this->app->user->admin)->andWhere('id')->in($this->app->user->view->programs)->fi()
@@ -188,7 +188,7 @@ class programModel extends model
if(empty($programs)) return array();
$programIdList = array_keys($programs);
$programs = $this->dao->select('*')->from(TABLE_PROJECT)
$programs = $this->dao->select('*')->from(TABLE_PROGRAM)
->where('id')->in($programIdList)
->orderBy($orderBy)
->limit($itemCounts)
@@ -218,6 +218,18 @@ class programModel extends model
return $programs;
}
/**
* Get children by program id.
*
* @param int $programID
* @access private
* @return void
*/
public function getChildren($programID = 0)
{
return $this->dao->select('count(*) as count')->from(TABLE_PROGRAM)->where('parent')->eq($programID)->fetch('count');
}
/**
* Show accessDenied response.
*
@@ -236,6 +248,167 @@ class programModel extends model
die(js::locate('back'));
}
/**
* Create a program.
*
* @access private
* @return void
*/
public function PGMCreate()
{
$program = fixer::input('post')
->setDefault('status', 'wait')
->add('type', 'program')
->setIF($this->post->acl != 'custom', 'whitelist', '')
->setDefault('openedBy', $this->app->user->account)
->setDefault('end', '')
->setDefault('parent', 0)
->setDefault('openedDate', helper::now())
->setDefault('team', substr($this->post->name, 0, 30))
->join('whitelist', ',')
->cleanInt('budget')
->stripTags($this->config->program->editor->pgmcreate['id'], $this->config->allowedTags)
->remove('workDays, delta, branch, uid')
->get();
if($program->parent)
{
$parentProgram = $this->dao->select('*')->from(TABLE_PROGRAM)->where('id')->eq($program->parent)->fetch();
if($parentProgram)
{
/* Child program begin cannot less than parent. */
if($program->begin < $parentProgram->begin) dao::$errors['begin'] = sprintf($this->lang->program->beginLetterParent, $parentProgram->begin);
/* When parent set end then child program end cannot greater than parent. */
if($parentProgram->end != '0000-00-00' and $program->end > $parentProgram->end) dao::$errors['end'] = sprintf($this->lang->program->endGreaterParent, $parentProgram->end);
/* When parent set end then child program cannot set longTime. */
if(empty($program->end) and $this->post->longTime and $parentProgram->end != '0000-00-00') dao::$errors['end'] = sprintf($this->lang->program->endGreaterParent, $parentProgram->end);
if(dao::isError()) return false;
}
}
$program = $this->loadModel('file')->processImgURL($program, $this->config->program->editor->pgmcreate['id'], $this->post->uid);
$this->dao->insert(TABLE_PROGRAM)->data($program)
->autoCheck()
->batchcheck($this->config->program->PGMCreate->requiredFields, 'notempty')
->check('name', 'unique', "deleted='0'")
->check('code', 'unique', "deleted='0'")
->exec();
/* Add the creater to the team. */
if(!dao::isError())
{
$programID = $this->dao->lastInsertId();
$today = helper::today();
//if($project->acl != 'open') $this->loadModel('user')->updateUserView($programID, 'program');
$this->dao->update(TABLE_PROGRAM)->set('`order`')->eq($programID * 5)->where('id')->eq($programID)->exec(); // Save order.
$this->file->updateObjectID($this->post->uid, $programID, 'project');
$this->setTreePath($programID);
/* Add program admin.*/
$groupPriv = $this->dao->select('t1.*')->from(TABLE_USERGROUP)->alias('t1')
->leftJoin(TABLE_GROUP)->alias('t2')->on('t1.group = t2.id')
->where('t1.account')->eq($this->app->user->account)
->andWhere('t2.role')->eq('PRJadmin')
->fetch();
if(!empty($groupPriv))
{
$newProgram = $groupPriv->program . ",$programID";
$this->dao->update(TABLE_USERGROUP)->set('program')->eq($newProgram)->where('account')->eq($groupPriv->account)->andWhere('`group`')->eq($groupPriv->group)->exec();
}
else
{
$PRJadminID = $this->dao->select('id')->from(TABLE_GROUP)->where('role')->eq('PRJadmin')->fetch('id');
$groupPriv = new stdclass();
$groupPriv->account = $this->app->user->account;
$groupPriv->group = $PRJadminID;
$groupPriv->program = $programID;
$this->dao->insert(TABLE_USERGROUP)->data($groupPriv)->exec();
}
return $programID;
}
}
/**
* Update program.
*
* @param int $programID
* @access public
* @return array
*/
public function PGMUpdate($programID)
{
$programID = (int)$programID;
$oldProgram = $this->dao->findById($programID)->from(TABLE_PROGRAM)->fetch();
$program = fixer::input('post')
->setDefault('team', $this->post->name)
->setDefault('end', '')
->setIF($this->post->begin == '0000-00-00', 'begin', '')
->setIF($this->post->end == '0000-00-00', 'end', '')
->setIF($this->post->acl != 'custom', 'whitelist', '')
->setIF($this->post->acl == 'custom' and !isset($_POST['whitelist']), 'whitelist', '')
->join('whitelist', ',')
->stripTags($this->config->program->editor->pgmedit['id'], $this->config->allowedTags)
->remove('uid')
->get();
$program = $this->loadModel('file')->processImgURL($program, $this->config->program->editor->pgmedit['id'], $this->post->uid);
$children = $this->getChildren($programID);
if($children > 0)
{
$minChildBegin = $this->dao->select('min(begin) as minBegin')->from(TABLE_PROGRAM)->where('id')->ne($programID)->andWhere('deleted')->eq(0)->andWhere('path')->like("%,{$programID},%")->fetch('minBegin');
$maxChildEnd = $this->dao->select('max(end) as maxEnd')->from(TABLE_PROGRAM)->where('id')->ne($programID)->andWhere('deleted')->eq(0)->andWhere('path')->like("%,{$programID},%")->andWhere('end')->ne('0000-00-00')->fetch('maxEnd');
if($minChildBegin and $program->begin > $minChildBegin) dao::$errors['begin'] = sprintf($this->lang->program->beginGreateChild, $minChildBegin);
if($maxChildEnd and $program->end < $maxChildEnd and !$this->post->longTime) dao::$errors['end'] = sprintf($this->lang->program->endLetterChild, $maxChildEnd);
$longTimeCount = $this->dao->select('count(*) as count')->from(TABLE_PROGRAM)->where('id')->ne($programID)->andWhere('deleted')->eq(0)->andWhere('path')->like("%,{$programID},%")->andWhere('end')->eq('0000-00-00')->fetch('count');
if(!empty($program->end) and $longTimeCount != 0) dao::$errors['end'] = $this->lang->program->childLongTime;
}
if($program->parent)
{
$parentProgram = $this->dao->select('*')->from(TABLE_PROGRAM)->where('id')->eq($program->parent)->fetch();
if($parentProgram)
{
if($program->begin < $parentProgram->begin) dao::$errors['begin'] = sprintf($this->lang->program->beginLetterParent, $parentProgram->begin);
if($parentProgram->end != '0000-00-00' and $program->end > $parentProgram->end) dao::$errors['end'] = sprintf($this->lang->program->endGreaterParent, $parentProgram->end);
if(empty($program->end) and $this->post->longTime and $parentProgram->end != '0000-00-00') dao::$errors['end'] = sprintf($this->lang->program->endGreaterParent, $parentProgram->end);
}
}
if(dao::isError()) return false;
$this->dao->update(TABLE_PROGRAM)->data($program)
->autoCheck($skipFields = 'begin,end')
->batchcheck($this->config->program->PGMEdit->requiredFields, 'notempty')
->checkIF($program->begin != '', 'begin', 'date')
->checkIF($program->end != '', 'end', 'date')
->checkIF($program->end != '', 'end', 'gt', $program->begin)
->check('name', 'unique', "id!=$programID and deleted='0'")
->check('code', 'unique', "id!=$programID and deleted='0'")
->where('id')->eq($programID)
->limit(1)
->exec();
if(!dao::isError())
{
$this->file->updateObjectID($this->post->uid, $programID, 'project');
if($program->acl != 'open' and ($program->acl != $oldProgram->acl or $program->whitelist != $oldProgram->whitelist))
{
$this->loadModel('user')->updateUserView($programID, 'program');
}
if($oldProgram->parent != $program->parent) $this->processNode($programID, $program->parent, $oldProgram->parent, $oldProgram->path, $oldProgram->grade);
return common::createChanges($oldProgram, $program);
}
}
/**
* Create a program.
*
@@ -260,7 +433,7 @@ class programModel extends model
if($project->parent)
{
$parentProgram = $this->dao->select('*')->from(TABLE_PROJECT)->where('id')->eq($project->parent)->fetch();
$parentProgram = $this->dao->select('*')->from(TABLE_PROGRAM)->where('id')->eq($project->parent)->fetch();
if($parentProgram)
{
/* Child project begin cannot less than parent. */
@@ -278,7 +451,7 @@ class programModel extends model
if($this->post->longTime) $requiredFields = trim(str_replace(',end,', ',', ",{$requiredFields},"), ',');
$project = $this->loadModel('file')->processImgURL($project, $this->config->program->editor->create['id'], $this->post->uid);
$this->dao->insert(TABLE_PROJECT)->data($project)
$this->dao->insert(TABLE_PROGRAM)->data($project)
->autoCheck()
->batchcheck($requiredFields, 'notempty')
->check('name', 'unique', "deleted='0'")
@@ -293,10 +466,10 @@ class programModel extends model
if($project->acl != 'open') $this->loadModel('user')->updateUserView($programID, 'program');
/* Save order. */
$this->dao->update(TABLE_PROJECT)->set('`order`')->eq($programID * 5)->where('id')->eq($programID)->exec();
$this->dao->update(TABLE_PROGRAM)->set('`order`')->eq($programID * 5)->where('id')->eq($programID)->exec();
$this->file->updateObjectID($this->post->uid, $programID, 'project');
if($project->parent > 0) $this->dao->update(TABLE_PROJECT)->set('isCat')->eq(1)->where('id')->eq($project->parent)->exec();
if($project->parent > 0) $this->dao->update(TABLE_PROGRAM)->set('isCat')->eq(1)->where('id')->eq($project->parent)->exec();
$this->setTreePath($programID);
/* Add program admin.*/
@@ -337,7 +510,7 @@ class programModel extends model
$data = new stdclass();
$data->project = $programID;
$data->product = $productID;
$this->dao->insert(TABLE_PROJECTPRODUCT)->data($data)->exec();
$this->dao->insert(TABLE_PROGRAMPRODUCT)->data($data)->exec();
}
return $programID;
@@ -354,7 +527,7 @@ class programModel extends model
public function update($programID)
{
$programID = (int)$programID;
$oldProgram = $this->dao->findById($programID)->from(TABLE_PROJECT)->fetch();
$oldProgram = $this->dao->findById($programID)->from(TABLE_PROGRAM)->fetch();
$program = fixer::input('post')
->setDefault('team', $this->post->name)
@@ -375,19 +548,19 @@ class programModel extends model
if(!empty($program->isCat))
{
$minChildBegin = $this->dao->select('min(begin) as minBegin')->from(TABLE_PROJECT)->where('id')->ne($programID)->andWhere('deleted')->eq(0)->andWhere('path')->like("%,{$programID},%")->fetch('minBegin');
$maxChildEnd = $this->dao->select('max(end) as maxEnd')->from(TABLE_PROJECT)->where('id')->ne($programID)->andWhere('deleted')->eq(0)->andWhere('path')->like("%,{$programID},%")->andWhere('end')->ne('0000-00-00')->fetch('maxEnd');
$minChildBegin = $this->dao->select('min(begin) as minBegin')->from(TABLE_PROGRAM)->where('id')->ne($programID)->andWhere('deleted')->eq(0)->andWhere('path')->like("%,{$programID},%")->fetch('minBegin');
$maxChildEnd = $this->dao->select('max(end) as maxEnd')->from(TABLE_PROGRAM)->where('id')->ne($programID)->andWhere('deleted')->eq(0)->andWhere('path')->like("%,{$programID},%")->andWhere('end')->ne('0000-00-00')->fetch('maxEnd');
if($minChildBegin and $program->begin > $minChildBegin) dao::$errors['begin'] = sprintf($this->lang->program->beginGreateChild, $minChildBegin);
if($maxChildEnd and $program->end < $maxChildEnd and !$this->post->longTime) dao::$errors['end'] = sprintf($this->lang->program->endLetterChild, $maxChildEnd);
$longTimeCount = $this->dao->select('count(*) as count')->from(TABLE_PROJECT)->where('id')->ne($programID)->andWhere('deleted')->eq(0)->andWhere('path')->like("%,{$programID},%")->andWhere('end')->eq('0000-00-00')->fetch('count');
$longTimeCount = $this->dao->select('count(*) as count')->from(TABLE_PROGRAM)->where('id')->ne($programID)->andWhere('deleted')->eq(0)->andWhere('path')->like("%,{$programID},%")->andWhere('end')->eq('0000-00-00')->fetch('count');
if(!empty($program->end) and $longTimeCount != 0) dao::$errors['end'] = $this->lang->program->childLongTime;
}
if($program->parent)
{
$parentProgram = $this->dao->select('*')->from(TABLE_PROJECT)->where('id')->eq($program->parent)->fetch();
$parentProgram = $this->dao->select('*')->from(TABLE_PROGRAM)->where('id')->eq($program->parent)->fetch();
if($parentProgram)
{
if($program->begin < $parentProgram->begin) dao::$errors['begin'] = sprintf($this->lang->program->beginLetterParent, $parentProgram->begin);
@@ -400,7 +573,7 @@ class programModel extends model
$requiredFields = $this->config->program->edit->requiredFields;
if($this->post->longTime) $requiredFields = trim(str_replace(',end,', ',', ",{$requiredFields},"), ',');
$this->dao->update(TABLE_PROJECT)->data($program)
$this->dao->update(TABLE_PROGRAM)->data($program)
->autoCheck($skipFields = 'begin,end')
->batchcheck($requiredFields, 'notempty')
->checkIF($program->begin != '', 'begin', 'date')
@@ -420,7 +593,7 @@ class programModel extends model
$this->loadModel('user')->updateUserView($programID, 'program');
}
if($oldProgram->parent != $program->parent) $this->moveNode($programID, $program->parent, $oldProgram->path, $oldProgram->grade);
if($oldProgram->parent != $program->parent) $this->processNode($programID, $program->parent, $oldProgram->path, $oldProgram->grade);
return common::createChanges($oldProgram, $program);
}
@@ -472,18 +645,18 @@ class programModel extends model
if(empty($program)) return true;
if(!empty($program->isCat) and $action == 'group') return false;
if(!empty($program->isCat) and $action == 'managemembers') return false;
if(!empty($program->isCat) and $action == 'start') return false;
if(!empty($program->isCat) and $action == 'activate') return false;
if(!empty($program->isCat) and $action == 'suspend') return false;
if(!empty($program->isCat) and $action == 'close') return false;
if($program->type == 'program' and $action == 'pgmgroup') return false;
if($program->type == 'program' and $action == 'pgmmanagemembers') return false;
if($program->type == 'program' and $action == 'pgmstart') return false;
if($program->type == 'program' and $action == 'pgmactivate') return false;
if($program->type == 'program' and $action == 'pgmsuspend') return false;
if($program->type == 'program' and $action == 'pgmclose') return false;
if($action == 'start') return $program->status == 'wait' or $program->status == 'suspended';
if($action == 'finish') return $program->status == 'wait' or $program->status == 'doing';
if($action == 'close') return $program->status != 'closed';
if($action == 'suspend') return $program->status == 'wait' or $program->status == 'doing';
if($action == 'activate') return $program->status == 'done';
if($action == 'pgmstart') return $program->status == 'wait' or $program->status == 'suspended';
if($action == 'pgmfinish') return $program->status == 'wait' or $program->status == 'doing';
if($action == 'pgmclose') return $program->status != 'closed';
if($action == 'pgmsuspend') return $program->status == 'wait' or $program->status == 'doing';
if($action == 'pgmactivate') return $program->status == 'done';
return true;
}
@@ -498,8 +671,8 @@ class programModel extends model
public function checkHasContent($programID)
{
$count = 0;
$count += (int)$this->dao->select('count(*) as count')->from(TABLE_PROJECT)->where('program')->eq($programID)->fetch('count');
$count += (int)$this->dao->select('count(*) as count')->from(TABLE_TASK)->where('program')->eq($programID)->fetch('count');
$count += (int)$this->dao->select('count(*) as count')->from(TABLE_PROGRAM)->where('parent')->eq($programID)->fetch('count');
$count += (int)$this->dao->select('count(*) as count')->from(TABLE_TASK)->where('PRJ')->eq($programID)->fetch('count');
return $count > 0;
}
@@ -513,7 +686,7 @@ class programModel extends model
*/
public function checkHasChildren($programID)
{
$count = $this->dao->select('count(*) as count')->from(TABLE_PROJECT)->where('parent')->eq($programID)->fetch('count');
$count = $this->dao->select('count(*) as count')->from(TABLE_PROGRAM)->where('parent')->eq($programID)->fetch('count');
return $count > 0;
}
@@ -526,35 +699,35 @@ class programModel extends model
*/
public function setTreePath($programID)
{
$program = $this->dao->select('*')->from(TABLE_PROJECT)->where('id')->eq($programID)->fetch();
$program = $this->dao->select('*')->from(TABLE_PROGRAM)->where('id')->eq($programID)->fetch();
$path['path'] = ",{$program->id},";
$path['grade'] = 1;
if($program->parent)
{
$parent = $this->dao->select('*')->from(TABLE_PROJECT)->where('id')->eq($program->parent)->fetch();
$parent = $this->dao->select('*')->from(TABLE_PROGRAM)->where('id')->eq($program->parent)->fetch();
$path['path'] = $parent->path . "{$program->id},";
$path['grade'] = $parent->grade + 1;
}
$this->dao->update(TABLE_PROJECT)->set('path')->eq($path['path'])->set('grade')->eq($path['grade'])->where('id')->eq($program->id)->exec();
$this->dao->update(TABLE_PROGRAM)->set('path')->eq($path['path'])->set('grade')->eq($path['grade'])->where('id')->eq($program->id)->exec();
return !dao::isError();
}
/**
* Get program parent pairs
*
* @param string $model
* @access public
* @return array
*/
public function getParentPairs($template = '')
public function getParentPairs($model = '')
{
$modules = $this->dao->select('id,name,parent,path,grade')->from(TABLE_PROJECT)
->where('isCat')->eq(1)
$modules = $this->dao->select('id,name,parent,path,grade')->from(TABLE_PROGRAM)
->where('type')->eq('program')
->andWhere('deleted')->eq(0)
->andWhere('template')->ne('')
->beginIF($template)->andWhere('template')->eq($template)->fi()
->beginIF($model)->andWhere('model')->eq($model)->fi()
->orderBy('grade desc, `order`')
->fetchAll('id');
@@ -602,16 +775,25 @@ class programModel extends model
* @access public
* @return bool
*/
public function moveNode($programID, $parentID, $oldPath, $oldGrade)
public function processNode($programID, $parentID, $oldParentID, $oldPath, $oldGrade)
{
$parent = $this->dao->select('id,parent,path,grade')->from(TABLE_PROJECT)->where('id')->eq($parentID)->fetch();
$parent = $this->dao->select('id,parent,path,grade')->from(TABLE_PROGRAM)->where('id')->eq($parentID)->fetch();
$childNodes = $this->dao->select('id,parent,path,grade')->from(TABLE_PROJECT)
$childNodes = $this->dao->select('id,parent,path,grade')->from(TABLE_PROGRAM)
->where('path')->like("{$oldPath}%")
->andWhere('deleted')->eq(0)
->andWhere('template')->ne('')
->orderBy('grade')
->fetchAll();
/* Process old and new program parent field.*/
$newChildren = $this->getChildren($parentID);
$oldChildren = $this->getChildren($oldParentID);
$newParent = $newChildren > 0 ? -1 : 0;
$oldParent = $oldChildren > 0 ? -1 : 0;
$this->dao->update(TABLE_PROGRAM)->set('parent')->eq($newParent)->where('id')->eq($parentID)->exec();
$this->dao->update(TABLE_PROGRAM)->set('parent')->eq($oldParent)->where('id')->eq($oldParentID)->exec();
/* Process child node path and grade field. */
foreach($childNodes as $childNode)
{
@@ -622,7 +804,7 @@ class programModel extends model
$path = rtrim($parent->path, ',') . $path;
$grade = $parent->grade + $grade;
}
$this->dao->update(TABLE_PROJECT)->set('path')->eq($path)->set('grade')->eq($grade)->where('id')->eq($childNode->id)->exec();
$this->dao->update(TABLE_PROGRAM)->set('path')->eq($path)->set('grade')->eq($grade)->where('id')->eq($childNode->id)->exec();
}
return !dao::isError();
+4 -4
View File
@@ -9,11 +9,11 @@
</th>
<th class='w-100px'><?php common::printOrderLink('code', $orderBy, $vars, $lang->program->PGMCode);?></th>
<th class='table-nest-title'><?php common::printOrderLink('name', $orderBy, $vars, $lang->program->PGMName);?></th>
<th class='w-80px'><?php common::printOrderLink('status', $orderBy, $vars, $lang->program->status);?></th>
<th class='w-80px'><?php common::printOrderLink('status', $orderBy, $vars, $lang->program->PGMStatus);?></th>
<th class='w-100px'><?php common::printOrderLink('begin', $orderBy, $vars, $lang->program->begin);?></th>
<th class='w-100px'><?php common::printOrderLink('end', $orderBy, $vars, $lang->program->end);?></th>
<th class='w-100px'><?php common::printOrderLink('budget', $orderBy, $vars, $lang->program->budget);?></th>
<th class='w-100px'><?php common::printOrderLink('PM', $orderBy, $vars, $lang->program->PM);?></th>
<th class='w-100px'><?php common::printOrderLink('budget', $orderBy, $vars, $lang->program->PGMBudget);?></th>
<th class='w-100px'><?php common::printOrderLink('PM', $orderBy, $vars, $lang->program->PGMPM);?></th>
<th class='text-center w-240px'><?php echo $lang->actions;?></th>
<?php if($canOrder):?>
<th class='w-60px sort-default'><?php common::printOrderLink('order', $orderBy, $vars, $lang->project->orderAB);?></th>
@@ -66,7 +66,7 @@
<?php common::printIcon('program', 'suspend', "programID=$program->id", $program, 'list', '', '', 'iframe', true);?>
<?php common::printIcon('program', 'close', "programID=$program->id", $program, 'list', '', '', 'iframe', true);?>
<?php if(common::hasPriv('program', 'edit')) echo html::a($this->createLink("program", "edit", "programID=$program->id"), "<i class='icon-edit'></i>", '', "class='btn' title='{$lang->edit}'");?>
<?php common::printIcon('program', 'create', "template=&programID=$program->id", '', 'list', 'treemap-alt', '', '', '', '', $this->lang->program->children);?>
<?php common::printIcon('program', 'create', "template=&programID=$program->id", '', 'list', 'treemap-alt', '', '', '', '', $this->lang->program->PGMChildren);?>
<?php if(common::hasPriv('program', 'delete')) echo html::a($this->createLink("program", "delete", "programID=$program->id"), "<i class='icon-trash'></i>", 'hiddenwin', "class='btn' title='{$lang->delete}'");?>
</td>
<?php if($canOrder):?>
+10 -33
View File
@@ -16,41 +16,29 @@
<div id='mainContent' class='main-content'>
<div class='center-block'>
<div class='main-header'>
<h2><?php echo $lang->program->edit;?></h2>
<h2><?php echo $lang->program->PGMEdit;?></h2>
</div>
<form class='form-indicator main-form form-ajax' method='post' target='hiddenwin' id='dataform'>
<table class='table table-form'>
<tr>
<th class='w-120px'><?php echo $lang->program->parent;?></th>
<th class='w-120px'><?php echo $lang->program->PGMParent;?></th>
<td class="col-main"><?php echo html::select('parent', $parents, $program->parent, "class='form-control chosen'");?></td>
<td></td><td></td>
</tr>
<tr>
<th class='w-120px'><?php echo $lang->program->name;?></th>
<th class='w-120px'><?php echo $lang->program->PGMName;?></th>
<td class="col-main"><?php echo html::input('name', $program->name, "class='form-control' required");?></td>
<td>
<div class="checkbox-primary">
<input type="checkbox" name="isCat" value="1" id="isCat" <?php if($program->isCat) echo "checked";?>>
<label for="isCat"><?php echo $lang->program->parent;?></label>
</div>
</td><td></td>
</tr>
<tr>
<th><?php echo $lang->program->code;?></th>
<th><?php echo $lang->program->PGMCode;?></th>
<td><?php echo html::input('code', $program->code, "class='form-control' required");?></td><td></td><td></td>
</tr>
<?php if($program->template == 'waterfall'):?>
<tr>
<th><?php echo $lang->program->category;?></th>
<td><?php echo html::select('category', $lang->program->categoryList, $program->category, "class='form-control'");?></td><td></td><td></td>
</tr>
<?php endif;?>
<tr>
<th><?php echo $lang->program->PM;?></th>
<th><?php echo $lang->program->PGMPM;?></th>
<td><?php echo html::select('PM', $pmUsers, $program->PM, "class='form-control chosen'");?></td>
</tr>
<tr>
<th><?php echo $lang->program->budget;?></th>
<th><?php echo $lang->program->PGMBudget;?></th>
<td><?php echo html::input('budget', $program->budget, "class='form-control'");?></td>
<td style='float:left'><?php echo html::select('budgetUnit', $lang->program->unitList, $program->budgetUnit, "class='form-control'");?></td><td></td>
</tr>
@@ -71,17 +59,6 @@
</td>
<td colspan='2'></td>
</tr>
<?php if($program->template == 'scrum'):?>
<tr>
<th><?php echo $lang->project->days;?></th>
<td>
<div class='input-group'>
<?php echo html::input('days', $program->days, "class='form-control'");?>
<span class='input-group-addon'><?php echo $lang->project->day;?></span>
</div>
</td><td></td><td></td>
</tr>
<?php endif;?>
<tr>
<th><?php echo $lang->program->realBegan;?></th>
<td><?php echo html::input('realBegan', $program->realBegan, "class='form-control form-date'");?></td><td></td><td></td>
@@ -91,19 +68,19 @@
<td><?php echo html::input('team', $program->team, "class='form-control'");?></td><td></td><td></td>
</tr>
<tr>
<th><?php echo $lang->program->desc;?></th>
<th><?php echo $lang->program->PGMDesc;?></th>
<td colspan='3'>
<?php echo $this->fetch('user', 'ajaxPrintTemplates', 'type=program&link=desc');?>
<?php echo html::textarea('desc', $program->desc, "rows='6' class='form-control kindeditor' hidefocus='true'");?>
</td>
</tr>
<tr>
<th><?php echo $lang->program->privway;?></th>
<td colspan='3'><?php echo html::radio('privway', $lang->program->privwayList, $program->privway, '', 'block');?></td>
<th><?php echo $lang->program->auth;?></th>
<td colspan='3'><?php echo html::radio('privway', $lang->program->PGMAuthList, $program->auth, '', 'block');?></td>
</tr>
<tr>
<th><?php echo $lang->project->acl;?></th>
<td colspan='3'><?php echo nl2br(html::radio('acl', $lang->program->aclList, $program->acl, "onclick='setWhite(this.value);'", 'block'));?></td>
<td colspan='3'><?php echo nl2br(html::radio('acl', $lang->program->PGMAclList, $program->acl, "onclick='setWhite(this.value);'", 'block'));?></td>
</tr>
<tr id='whitelistBox' <?php if($program->acl != 'custom') echo "class='hidden'";?>>
<th><?php echo $lang->project->whitelist;?></th>
+6 -11
View File
@@ -20,38 +20,33 @@
<?php endif;?>
<div id='mainMenu' class='clearfix'>
<div class="btn-toolBar pull-left">
<?php foreach($lang->program->featureBar as $key => $label):?>
<?php foreach($lang->program->PGMFeatureBar as $key => $label):?>
<?php $active = $status == $key ? 'btn-active-text' : '';?>
<?php $label = "<span class='text'>$label</span>";?>
<?php if($status == $key) $label .= " <span class='label label-light label-badge'>{$pager->recTotal}</span>";?>
<?php echo html::a(inlink('browse', "status=$key&orderBy=$orderBy"), $label, '', "class='btn btn-link $active'");?>
<?php echo html::a(inlink('pgmbrowse', "status=$key&orderBy=$orderBy"), $label, '', "class='btn btn-link $active'");?>
<?php endforeach;?>
<?php echo html::checkbox('mine', array('1' => $lang->program->mine), '', $this->cookie->mine ? 'checked=checked' : '');?>
<?php echo html::checkbox('showClosed', array('1' => $lang->program->PGMShowClosed), '', $this->cookie->showClosed ? 'checked=checked' : '');?>
</div>
<div class='pull-right'>
<div class='btn-group'>
<?php echo html::a('javascript:setProgramType("bygrid")', "<i class='icon icon-cards-view'></i>", '', "title={$lang->program->bygrid} class='btn btn-icon " . ($programType == 'bygrid' ? 'text-primary' : '') . "'");?>
<?php echo html::a('javascript:setProgramType("bylist")', "<i class='icon icon-bars'></i>", '', "title={$lang->program->bylist} class='btn btn-icon " . ($programType == 'bylist' ? 'text-primary' : '') . "'");?>
</div>
<?php common::printLink('program', 'export', "status=$status&orderBy=$orderBy", "<i class='icon-export muted'> </i>" . $lang->export, '', "class='btn btn-link export'")?>
<?php if(isset($lang->pageActions)) echo $lang->pageActions;?>
</div>
</div>
<div id='mainContent' class='main-row'>
<?php if(empty($programs)):?>
<div class="table-empty-tip">
<p><span class="text-muted"><?php echo $lang->program->noPGM;?></span> <?php common::printLink('program', 'createguide', '', "<i class='icon icon-plus'></i> " . $lang->program->create, '', "class='btn btn-info' data-toggle=modal");?></p>
<p><span class="text-muted"><?php echo $lang->program->noPGM;?></span> <?php common::printLink('program', 'pgmcreate', '', "<i class='icon icon-plus'></i> " . $lang->program->PGMCreate, '', "class='btn btn-info'");?></p>
</div>
<?php else:?>
<div class='main-col'>
<?php
if($programType == 'bygrid')
{
include 'browsebygrid.html.php';
include 'pgmbrowsebygrid.html.php';
}
else
{
include 'browsebylist.html.php';
include 'pgmbrowsebylist.html.php';
}
?>
</div>
@@ -0,0 +1,163 @@
<div class='row cell' id='cards'>
<?php foreach ($programs as $programID => $program):?>
<div class='col' data-id='<?php echo $programID?>'>
<div class='panel' data-url='<?php echo $this->createLink('program', 'index', "programID=$program->id", '', '', $program->id);?>'>
<div class='panel-heading'>
<strong class='program-name' title='<?php echo $program->name;?>'><?php echo $program->name;?></strong>
<?php if($program->template === 'waterfall'): ?>
<span class='program-type-label label label-warning label-outline'><?php echo $lang->program->waterfall; ?></span>
<?php else: ?>
<span class='program-type-label label label-info label-outline'><?php echo $lang->program->scrum; ?></span>
<?php endif; ?>
<nav class='panel-actions nav nav-default'>
<li class='dropdown'>
<a href='javascript:;' data-toggle='dropdown' class='panel-action'><i class='icon icon-ellipsis-v'></i></a>
<ul class='dropdown-menu pull-right'>
<li><?php common::printIcon('program', 'group', "programID=$program->id", $program, 'button', 'group');?></li>
<li><?php common::printIcon('program', 'manageMembers', "programID=$program->id", $program, 'button', 'persons');?></li>
<li><?php common::printicon('program', 'activate', "programid=$program->id", $program, 'button', '', '', 'iframe', true);?></li>
<li><?php if(common::hasPriv('program', 'edit')) echo html::a($this->createLink("program", "edit", "programID=$program->id"), "<i class='icon-edit'></i> " . $lang->edit, '', "");?></li>
<li><?php common::printIcon('program', 'start', "programID=$program->id", $program, 'button', '', '', 'iframe', true);?></li>
<li><?php common::printIcon('program', 'suspend', "programID=$program->id", $program, 'button', '', '', 'iframe', true);?></li>
<li><?php common::printIcon('program', 'close', "programID=$program->id", $program, 'button', '', '', 'iframe', true);?></li>
<li><?php if(common::hasPriv('program', 'delete')) echo html::a($this->createLink("program", "delete", "programID=$program->id"), "<i class='icon-trash'></i> " . $lang->delete, 'hiddenwin', "");?></li>
</ul>
</li>
</nav>
</div>
<div class='panel-body'>
<div class='program-infos'>
<span><i class='icon icon-group'></i> <?php printf($lang->program->membersUnit, $program->teamCount); ?></span>
<span><i class='icon icon-clock'></i> <?php printf($lang->program->hoursUnit, $program->estimate); ?></span>
<span><i class='icon icon-cost'></i> <?php echo $program->budget . '' . zget($lang->program->unitList, $program->budgetUnit);?></span>
</div>
<?php if($program->template === 'waterfall'): ?>
<div class='program-detail program-stages'>
<p class='text-muted'><?php echo $lang->program->ongoingStage; ?></p>
<?php
$programProjects = array();
foreach($program->projects as $project)
{
if(!$project->parent) $programProjects[] = $project;
}
?>
<?php if(empty($programProjects)): ?>
<div class='label label-outline'><?php echo zget($lang->project->statusList, $program->status);?></div>
<?php else: ?>
<div class='program-stages-container scrollbar-hover'>
<div class='program-stages-row'>
<?php foreach ($programProjects as $project): ?>
<div class='program-stage-item is-<?php echo $project->status;?><?php if($project->status !== 'wait') echo ' is-going'; ?>'>
<div><?php echo $project->name; ?></div>
</div>
<?php endforeach; ?>
</div>
</div>
<?php endif; ?>
</div>
<?php else: ?>
<?php $project = $program->projects ? current($program->projects) : '';?>
<div class='program-detail program-iteration'>
<p class='text-muted'><?php echo $lang->program->lastIteration; ?></p>
<?php if($project):?>
<div class='row'>
<div class='col-xs-5'><?php echo $project->name; ?></div>
<div class='col-xs-7'>
<div class="progress progress-text-left">
<div class="progress-bar progress-bar-success" role="progressbar" aria-valuenow="<?php echo $project->hours->progress;?>" aria-valuemin="0" aria-valuemax="100" style="width: <?php echo $project->hours->progress;?>%">
<span class="progress-text"><?php echo $project->hours->progress;?>%</span>
</div>
</div>
</div>
</div>
<?php endif; ?>
</div>
<?php endif; ?>
</div>
</div>
</div>
<?php endforeach;?>
<div class='col-xs-12' id='cardsFooter'>
<?php $pager->show('right', 'pagerjs');?>
</div>
</div>
<style>
#mainMenu {padding-left: 10px; padding-right: 10px;}
#cards {margin: 0 10px;}
#cards > .col {width: 20%;}
#cards .panel {margin: 10px 0; border: 1px solid #DCDCDC; border-radius: 2px; box-shadow: none; height: 146px; cursor: pointer;}
#cards .panel:hover {border-color: #006AF1; box-shadow: 0 0 10px 0 rgba(0,0,100,.25);}
#cards .panel-heading {padding: 12px 24px 10px 16px;}
#cards .panel-body {padding: 0 16px 16px;}
#cards .panel-actions {padding: 7px 0;}
#cards .panel-actions .dropdown-menu > li > a {padding-left: 5px; text-align: left;}
#cards .panel-actions .dropdown-menu > li > a > i {opacity: .5; display: inline-block; margin-right: 4px; width: 18px; text-align: center;}
#cards .panel-actions .dropdown-menu > li > a:hover > i {opacity: 1;}
#cards .program-type-label {padding: 1px 2px;}
#cards .program-name {font-size: 16px; font-weight: normal; display: inline-block; max-width: 80%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; vertical-align: middle;}
#cards .program-infos {font-size: 12px;}
#cards .program-infos > span {display: inline-block; line-height: 12px;}
#cards .program-infos > span > .icon {font-size: 12px; display: inline-block; position: relative; top: -1px}
#cards .program-infos > span + span {margin-left: 15px;}
#cards .program-detail {position: absolute; bottom: 16px; left: 16px; right: 16px; font-size: 12px;}
#cards .program-detail > p {margin-bottom: 8px;}
#cards .program-detail .progress {height: 4px;}
#cards .program-detail .progress-text-left .progress-text {width: 50px; left: -50px;}
#cards .pager {margin: 0; float: right;}
#cards .pager .btn {border: none}
#cards .program-stages-container {margin: 0 -16px -16px -16px; padding: 0 4px; height: 46px; overflow-x: auto; position: relative;}
#cards .program-stages:after {content: ' '; width: 30px; display: block; right: -16px; top: 16px; bottom: -6px; z-index: 1; background: linear-gradient(to right, rgba(255,255,255,0) 0%, rgba(255,255,255,1) 100%); position: absolute;}
#cards .program-stages-row {position: relative; height: 30px; z-index: 0;}
#cards .program-stage-item {white-space: nowrap; position: absolute; top: 0; min-width: 48px; padding-top: 13px; color: #838A9D;}
#cards .program-stage-item > div {white-space: nowrap; overflow: visible; text-align: center; text-overflow: ellipsis;}
#cards .program-stage-item:before {content: ' '; display: block; width: 8px; height: 8px; border-radius: 50%; background: #D1D1D1; position: absolute; left: 50%; margin-left: -4px; top: 0; z-index: 1;}
#cards .program-stage-item + .program-stage-item:after {content: ' '; display: block; left: -50%; right: 50%; height: 2px; background-color: #D1D1D1; top: 3px; position: absolute; z-index: 0;}
#cards .program-stage-item.is-going {color: #333;}
#cards .program-stage-item.is-going::before {background-color: #0C64EB;}
</style>
<script>
$(function()
{
/* Auto resize cards size */
var minCardWidth = 280;
var $cards = $('#cards');
var resizeCards = function()
{
var cardsWidth = $cards.width();
var bestColsSize = 1;
while((cardsWidth / (bestColsSize + 1)) > minCardWidth)
{
bestColsSize++;
}
$cards.children('.col').css('width', (100 / bestColsSize) + '%');
};
resizeCards();
$(window).on('resize', resizeCards);
/* Auto resize stages */
$cards.find('.program-stages-container').each(function()
{
var $container = $(this);
var $row = $container.children();
var totalWidth = 0;
$row.children().each(function()
{
var $item = $(this);
$item.css('left', totalWidth);
totalWidth += $item.width();
});
$row.css('minWidth', totalWidth);
});
/* Make cards clickable */
$cards.on('click', '.panel', function(e)
{
if(!$(e.target).closest('.panel-actions').length)
{
window.location.href = $(this).data('url');
}
});
});
</script>
@@ -0,0 +1,124 @@
<?php $canOrder = (common::hasPriv('program', 'updateOrder') and strpos($orderBy, 'order') !== false)?>
<form class='main-table' id='programForm' method='post' data-ride='table' data-nested='true' data-expand-nest-child='false' data-checkable='false'>
<table class='table has-sort-head table-fixed table-nested' id='programList'>
<?php $vars = "status=$status&orderBy=%s&recTotal={$pager->recTotal}&recPerPage={$pager->recPerPage}&pageID={$pager->pageID}";?>
<thead>
<tr>
<th class='c-id w-80px'>
<?php common::printOrderLink('id', $orderBy, $vars, $lang->idAB);?>
</th>
<th class='w-100px'><?php common::printOrderLink('code', $orderBy, $vars, $lang->program->PGMCode);?></th>
<th class='table-nest-title'><?php common::printOrderLink('name', $orderBy, $vars, $lang->program->PGMName);?></th>
<th class='w-90px'><?php common::printOrderLink('status', $orderBy, $vars, $lang->program->PGMStatus);?></th>
<th class='w-100px'><?php common::printOrderLink('begin', $orderBy, $vars, $lang->program->begin);?></th>
<th class='w-100px'><?php common::printOrderLink('end', $orderBy, $vars, $lang->program->end);?></th>
<th class='w-100px'><?php common::printOrderLink('budget', $orderBy, $vars, $lang->program->PGMBudget);?></th>
<th class='w-100px'><?php common::printOrderLink('PM', $orderBy, $vars, $lang->program->PGMPM);?></th>
<th class='text-center w-200px'><?php echo $lang->actions;?></th>
<?php if($canOrder):?>
<th class='w-60px sort-default'><?php common::printOrderLink('order', $orderBy, $vars, $lang->project->orderAB);?></th>
<?php endif;?>
</tr>
</thead>
<tbody id='programTableList'>
<?php foreach($programs as $program):?>
<?php
$trClass = '';
$trAttrs = "data-id='$program->id' data-order='$program->order' data-parent='$program->parent'";
if($program->type == 'program')
{
$trAttrs .= " data-nested='true'";
if($program->parent == '0') $trClass .= ' is-top-level table-nest-child-hide';
else $trClass .= ' is-top-level table-nest-hide';
}
if($program->parent)
{
if($program->type != 'program') $trClass .= ' is-nest-child';
$trClass .= ' table-nest-hide';
$trAttrs .= " data-nest-parent='$program->parent' data-nest-path='$program->path'";
}
elseif($program->type != 'program')
{
$trClass .= ' no-nest';
}
$trAttrs .= " class='$trClass'";
?>
<tr <?php echo $trAttrs;?>>
<td class='c-id'>
<?php printf('%03d', $program->id);?>
</td>
<td class='text-left'><?php echo $program->code;?></td>
<td class='text-left pgm-title table-nest-title' title='<?php echo $program->name?>'>
<span class="table-nest-icon icon<?php if($program->type == 'program') echo ' table-nest-toggle' ?>"></span>
<?php echo $program->type == 'program' ? $program->name : html::a($this->createLink('program', 'index', "programID=$program->id", '', '', $program->id), $program->name);?>
</td>
<td class='c-status'><span class="status-program status-<?php echo $program->status?>"><?php echo zget($lang->project->statusList, $program->status, '');?></span></td>
<td class='text-center'><?php echo $program->begin;?></td>
<td class='text-center'><?php echo $program->end == '0000-00-00' ? '' : $program->end;?></td>
<td class='text-left'><?php echo $program->budget . ' ' . zget($lang->program->unitList, $program->budgetUnit);?></td>
<td><?php echo zget($users, $program->PM);?></td>
<td class='text-center c-actions'>
<?php common::printIcon('program', 'pgmgroup', "programID=$program->id", $program, 'list', 'group');?>
<?php common::printIcon('program', 'pgmmanageMembers', "programID=$program->id", $program, 'list', 'persons');?>
<?php common::printIcon('program', 'pgmactivate', "programID=$program->id", $program, 'list', 'magic', '', 'iframe', true);?>
<?php common::printIcon('program', 'pgmclose', "programID=$program->id", $program, 'list', 'off', '', 'iframe', true);?>
<?php if(common::hasPriv('program', 'pgmedit')) echo html::a($this->createLink("program", "pgmedit", "programID=$program->id"), "<i class='icon-edit'></i>", '', "class='btn' title='{$lang->edit}'");?>
<?php common::printIcon('program', 'pgmcreate', "programID=$program->id", '', 'list', 'treemap-alt', '', '', '', '', $this->lang->program->PGMChildren);?>
<?php if(common::hasPriv('program', 'pgmdelete')) echo html::a($this->createLink("program", "pgmdelete", "programID=$program->id"), "<i class='icon-trash'></i>", 'hiddenwin', "class='btn' title='{$lang->delete}'");?>
</td>
<?php if($canOrder):?>
<td class='sort-handler text-center'><i class="icon icon-move"></i></td>
<?php endif;?>
</tr>
<?php endforeach;?>
</tbody>
</table>
<div class='table-footer'>
<?php $pager->show('right', 'pagerjs');?>
</div>
</form>
<style>
.w-240px {width:240px;}
#programTableList.sortable-sorting > tr {opacity: 0.7}
#programTableList.sortable-sorting > tr.drag-row {opacity: 1;}
#programTableList > tr.drop-not-allowed {opacity: 0.1!important}
</style>
<script>
$(function()
{
var $list = $('#programTableList');
$list.addClass('sortable').sortable(
{
reverse: orderBy === 'order_desc',
selector: 'tr',
dragCssClass: 'drag-row',
trigger: $list.find('.sort-handler').length ? '.sort-handler' : null,
canMoveHere: function($ele, $target)
{
return $ele.data('parent') === $target.data('parent');
},
start: function(e)
{
e.targets.filter('[data-parent!="' + e.element.attr('data-parent') + '"]').addClass('drop-not-allowed');
},
finish: function(e)
{
var orders = {};
e.list.each(function()
{
orders[$(this.item).data('id')] = this.order;
});
$.post(createLink('project', 'updateOrder'), {'projects' : orders, 'orderBy' : orderBy});
var $thead = $list.closest('table').children('thead');
$thead.find('.headerSortDown, .headerSortUp').removeClass('headerSortDown headerSortUp').addClass('header');
$thead.find('th.sort-default .header').removeClass('header').addClass('headerSortDown');
e.element.addClass('drop-success');
setTimeout(function(){e.element.removeClass('drop-success');}, 800);
$list.children('.drop-not-allowed').removeClass('drop-not-allowed');
}
});
});
</script>
+162
View File
@@ -0,0 +1,162 @@
<?php
/**
* The create view of project module of ZenTaoPMS.
*
* @copyright Copyright 2009-2015 青岛易软天创网络科技有限公司(QingDao Nature Easy Soft Network Technology Co,LTD, www.cnezsoft.com)
* @license ZPL (http://zpl.pub/page/zplv12.html)
* @author Chunsheng Wang <chunsheng@cnezsoft.com>
* @package project
* @version $Id: create.html.php 4728 2013-05-03 06:14:34Z chencongzhi520@gmail.com $
* @link http://www.zentao.net
*/
?>
<?php if(isset($tips)):?>
<?php $defaultURL = $this-> createLink('project', 'task', 'projectID=' . $projectID);?>
<?php include '../../common/view/header.lite.html.php';?>
<body>
<div class='modal-dialog mw-500px' id='tipsModal'>
<div class='modal-header'>
<a href='<?php echo $defaultURL;?>' class='close'><i class="icon icon-close"></i></a>
<h4 class='modal-title' id='myModalLabel'><?php echo $lang->project->tips;?></h4>
</div>
<div class='modal-body'>
<?php echo $tips;?>
</div>
</div>
</body>
</html>
<?php exit;?>
<?php endif;?>
<?php include '../../common/view/header.html.php';?>
<?php include '../../common/view/kindeditor.html.php';?>
<?php js::import($jsRoot . 'misc/date.js');?>
<?php js::set('weekend', $config->project->weekend);?>
<?php js::set('holders', $lang->project->placeholder);?>
<?php js::set('errorSameProducts', $lang->project->errorSameProducts);?>
<div id='mainContent' class='main-content'>
<div class='center-block'>
<div class='main-header'>
<h2><?php echo $lang->program->PGMCreate;?></h2>
</div>
<form class='form-indicator main-form form-ajax' method='post' target='hiddenwin' id='dataform'>
<table class='table table-form'>
<tr>
<th><?php echo $lang->program->PGMParent;?></th>
<td><?php echo html::select('parent', $parents, isset($parentProgram->id) ? $parentProgram->id : '', "class='form-control chosen'");?>
<td></td>
</tr>
<tr>
<th class='w-120px'><?php echo $lang->program->PGMName;?></th>
<td class="col-main"><?php echo html::input('name', '', "class='form-control' required");?></td>
<td></td>
</tr>
<tr>
<th><?php echo $lang->program->PGMCode;?></th>
<td><?php echo html::input('code', '', "class='form-control' required");?></td><td></td><td></td>
</tr>
<tr>
<th><?php echo $lang->program->PGMPM;?></th>
<td><?php echo html::select('PM', $pmUsers, '', "class='form-control chosen'");?></td>
</tr>
<tr>
<th><?php echo $lang->program->PGMBudget;?></th>
<td>
<div class='input-group'>
<?php echo html::input('budget', '', "class='form-control'");?>
<span class='input-group-addon'></span>
<?php echo html::select('budgetUnit', $lang->program->unitList, empty($parentProgram->budgetUnit) ? 'yuan' : $parentProgram->budgetUnit, "class='form-control'");?>
</div>
</td>
<td class='muted'><?php if($parentProgram) printf($lang->program->parentBudget, $parentProgram->budget . zget($lang->program->unitList, $parentProgram->budgetUnit, ''));?></td>
</tr>
<tr>
<th><?php echo $lang->program->dateRange;?></th>
<td>
<div class='input-group'>
<?php echo html::input('begin', date('Y-m-d'), "class='form-control form-date' placeholder='" . $lang->program->begin . "' required");?>
<span class='input-group-addon'><?php echo $lang->program->to;?></span>
<?php echo html::input('end', '', "class='form-control form-date' placeholder='" . $lang->program->end . "' required");?>
<?php if(empty($parentProgram) or $parentProgram->end == '0000-00-00'):?>
<span class='input-group-addon hidden' id='longTimeBox'>
<div class="checkbox-primary">
<input type="checkbox" name="longTime" value="1" id="longTime">
<label for="longTime"><?php echo $lang->program->longTime;?></label>
</div>
</span>
<?php endif;?>
</div>
</td>
<td class='muted'><?php if($parentProgram) printf($lang->program->parentBeginEnd, $parentProgram->begin, $parentProgram->end == '0000-00-00' ? '' : $parentProgram->end);?></td>
</tr>
<tr>
<th><?php echo $lang->project->teamname;?></th>
<td><?php echo html::input('team', '', "class='form-control'");?></td><td></td><td></td>
</tr>
<tr class='hide'>
<th><?php echo $lang->project->status;?></th>
<td><?php echo html::hidden('status', 'wait');?></td>
<td></td>
<td></td>
<td></td>
</tr>
<?php $this->printExtendFields('', 'table');?>
<tr>
<th><?php echo $lang->program->PGMDesc;?></th>
<td colspan='3'>
<?php echo $this->fetch('user', 'ajaxPrintTemplates', 'type=project&link=desc');?>
<?php echo html::textarea('desc', '', "rows='6' class='form-control kindeditor' hidefocus='true'");?>
</td>
</tr>
<tr>
<th><?php echo $lang->program->auth;?></th>
<td colspan='3'><?php echo html::radio('auth', $lang->program->PGMAuthList, 'extend', '', 'block');?></td>
</tr>
<tr>
<th><?php echo $lang->project->acl;?></th>
<td colspan='3'><?php echo nl2br(html::radio('acl', $lang->program->PGMAclList, 'open', "onclick='setWhite(this.value);'", 'block'));?></td>
</tr>
<tr id='whitelistBox' class='hidden'>
<th><?php echo $lang->project->whitelist;?></th>
<td colspan='3'><?php echo html::checkbox('whitelist', $groups, $whitelist, '', '', 'inline');?></td>
</tr>
<tr>
<td colspan='4' class='text-center form-actions'>
<?php echo html::submitButton();?>
<?php echo html::backButton();?>
</td>
</tr>
</table>
</form>
</div>
</div>
<div class='modal fade modal-scroll-inside' id='copyProjectModal'>
<div class='modal-dialog mw-900px'>
<div class='modal-header'>
<button type='button' class='close' data-dismiss='modal'><i class="icon icon-close"></i></button>
<h4 class='modal-title' id='myModalLabel'><?php echo $lang->project->copyTitle;?></h4>
</div>
<div class='modal-body'>
<?php if(count($programs) == 1):?>
<div class='alert with-icon'>
<i class='icon-exclamation-sign'></i>
<div class='content'><?php echo $lang->project->copyNoProject;?></div>
</div>
<?php else:?>
<div id='copyProjects' class='row'>
<?php foreach ($programs as $id => $name):?>
<?php if(empty($id)):?>
<?php if($copyProgramID != 0):?>
<div class='col-md-4 col-sm-6'><a href='javascript:;' data-id='' class='cancel'><?php echo html::icon($lang->icons['cancel']) . ' ' . $lang->project->cancelCopy;?></a></div>
<?php endif;?>
<?php else: ?>
<div class='col-md-4 col-sm-6'><a href='javascript:;' data-id='<?php echo $id;?>' class='nobr <?php echo ($copyProgramID == $id) ? ' active' : '';?>'><?php echo html::icon($lang->icons['project'], 'text-muted') . ' ' . $name;?></a></div>
<?php endif; ?>
<?php endforeach;?>
</div>
<?php endif;?>
</div>
</div>
</div>
<?php js::set('parentProgramID', isset($parentProgram->id) ? $parentProgram->id : 0);?>
<?php include '../../common/view/footer.html.php';?>
+93
View File
@@ -0,0 +1,93 @@
<?php
/**
* The edit view of program module of ZenTaoPMS.
*
* @copyright Copyright 2009-2015 青岛易软天创网络科技有限公司(QingDao Nature Easy Soft Network Technology Co,LTD, www.cnezsoft.com)
* @license ZPL (http://zpl.pub/page/zplv12.html)
* @author Chunsheng Wang <chunsheng@cnezsoft.com>
* @package program
* @version $Id: create.html.php 4728 2013-05-03 06:14:34Z chencongzhi520@gmail.com $
* @link http://www.zentao.net
*/
?>
<?php include '../../common/view/header.html.php';?>
<?php include '../../common/view/kindeditor.html.php';?>
<?php js::set('weekend', $config->project->weekend);?>
<div id='mainContent' class='main-content'>
<div class='center-block'>
<div class='main-header'>
<h2><?php echo $lang->program->PGMEdit;?></h2>
</div>
<form class='form-indicator main-form form-ajax' method='post' target='hiddenwin' id='dataform'>
<table class='table table-form'>
<tr>
<th class='w-120px'><?php echo $lang->program->PGMParent;?></th>
<td class="col-main"><?php echo html::select('parent', $parents, $program->parent, "class='form-control chosen'");?></td>
<td></td><td></td>
</tr>
<tr>
<th class='w-120px'><?php echo $lang->program->PGMName;?></th>
<td class="col-main"><?php echo html::input('name', $program->name, "class='form-control' required");?></td>
</tr>
<tr>
<th><?php echo $lang->program->PGMCode;?></th>
<td><?php echo html::input('code', $program->code, "class='form-control' required");?></td><td></td><td></td>
</tr>
<tr>
<th><?php echo $lang->program->PGMPM;?></th>
<td><?php echo html::select('PM', $pmUsers, $program->PM, "class='form-control chosen'");?></td>
</tr>
<tr>
<th><?php echo $lang->program->PGMBudget;?></th>
<td><?php echo html::input('budget', $program->budget, "class='form-control'");?></td>
<td style='float:left'><?php echo html::select('budgetUnit', $lang->program->unitList, $program->budgetUnit, "class='form-control'");?></td><td></td>
</tr>
<tr>
<th><?php echo $lang->program->dateRange;?></th>
<td>
<div class='input-group'>
<?php echo html::input('begin', $program->begin, "class='form-control form-date' placeholder='" . $lang->program->begin . "' required");?>
<span class='input-group-addon'><?php echo $lang->program->to;?></span>
<?php echo html::input('end', $program->end == '0000-00-00' ? '' : $program->end, "class='form-control form-date' placeholder='" . $lang->program->end . "' required");?>
</div>
</td>
<td colspan='2'></td>
</tr>
<tr>
<th><?php echo $lang->program->realBegan;?></th>
<td><?php echo html::input('realBegan', $program->realBegan, "class='form-control form-date'");?></td><td></td><td></td>
</tr>
<tr>
<th><?php echo $lang->project->teamname;?></th>
<td><?php echo html::input('team', $program->team, "class='form-control'");?></td><td></td><td></td>
</tr>
<tr>
<th><?php echo $lang->program->PGMDesc;?></th>
<td colspan='3'>
<?php echo $this->fetch('user', 'ajaxPrintTemplates', 'type=program&link=desc');?>
<?php echo html::textarea('desc', $program->desc, "rows='6' class='form-control kindeditor' hidefocus='true'");?>
</td>
</tr>
<tr>
<th><?php echo $lang->program->auth;?></th>
<td colspan='3'><?php echo html::radio('auth', $lang->program->PGMAuthList, $program->auth, '', 'block');?></td>
</tr>
<tr>
<th><?php echo $lang->project->acl;?></th>
<td colspan='3'><?php echo nl2br(html::radio('acl', $lang->program->PGMAclList, $program->acl, "onclick='setWhite(this.value);'", 'block'));?></td>
</tr>
<tr id='whitelistBox' <?php if($program->acl != 'custom') echo "class='hidden'";?>>
<th><?php echo $lang->project->whitelist;?></th>
<td colspan='3'><?php echo html::checkbox('whitelist', $groups, $program->whitelist, '', '', 'inline');?></td>
</tr>
<tr>
<td colspan='4' class='text-center form-actions'>
<?php echo html::submitButton();?>
<?php echo html::backButton();?>
</td>
</tr>
</table>
</form>
</div>
</div>
<?php include '../../common/view/footer.html.php';?>