diff --git a/lib/base/front/.front.class.php.swp b/lib/base/front/.front.class.php.swp
new file mode 100644
index 0000000000..a32e554e9b
Binary files /dev/null and b/lib/base/front/.front.class.php.swp differ
diff --git a/module/program/control.php b/module/program/control.php
index c325feda14..3245fcd1f1 100644
--- a/module/program/control.php
+++ b/module/program/control.php
@@ -729,6 +729,7 @@ class program extends control
public function PRJBrowse($programID = 0, $browseType = 'doing', $param = 0, $orderBy = 'order_desc', $recTotal = 0, $recPerPage = 15, $pageID = 1)
{
$this->lang->navGroup->program = 'project';
+ $this->app->session->set('PRJBrowse', $this->app->getURI(true));
/* Load pager and get tasks. */
$this->app->loadClass('pager', $static = true);
@@ -806,7 +807,7 @@ class program extends control
{
$this->send(array('result' => 'success', 'message' => $this->lang->saveSuccess, 'locate' => inlink('PGMBrowse')));
}
- $this->send(array('result' => 'success', 'message' => $this->lang->saveSuccess, 'locate' => inlink('PRJBrowse', array('programID' => $programID, 'browseType' => 'doing'))));
+ $this->send(array('result' => 'success', 'message' => $this->lang->saveSuccess, 'locate' => inlink('PRJBrowse', array('programID' => $programID, 'browseType' => 'all'))));
}
$name = '';
@@ -859,22 +860,22 @@ class program extends control
public function PRJEdit($projectID = 0)
{
$this->lang->navGroup->program = 'project';
- $project = $this->program->getPRJByID($projectID);
if($_POST)
{
- $changes = $this->program->update($projectID);
+ $changes = $this->program->PRJUpdate($projectID);
if(dao::isError()) $this->send(array('result' => 'fail', 'message' => $this->processErrors(dao::getError())));
if($changes)
{
- $actionID = $this->loadModel('action')->create('program', $projectID, 'edited');
+ $actionID = $this->loadModel('action')->create('project', $projectID, 'edited');
$this->action->logHistory($actionID, $changes);
}
- $url = $this->session->PRJList ? $this->session->PRJList : inlink('browse');
+ $url = $this->session->PRJBrowse ? $this->session->PRJBrowse : inLink('PRJBrowse');
$this->send(array('result' => 'success', 'message' => $this->lang->saveSuccess, 'locate' => $url));
}
+ $project = $this->program->getPRJByID($projectID);
$parents = $this->program->getParentPairs();
unset($parents[$projectID]);
diff --git a/module/program/js/prjcreate.js b/module/program/js/prjcreate.js
index 7ae0d41625..17b94bc80f 100644
--- a/module/program/js/prjcreate.js
+++ b/module/program/js/prjcreate.js
@@ -6,6 +6,7 @@ $(function()
if($(this).prop('checked'))
{
$('#end').val('').attr('disabled', 'disabled');
+ $('#days').val('');
}
else
{
diff --git a/module/program/js/prjedit.js b/module/program/js/prjedit.js
new file mode 100644
index 0000000000..e4f2b4f37a
--- /dev/null
+++ b/module/program/js/prjedit.js
@@ -0,0 +1,15 @@
+$(function()
+{
+ $('#longTime').change(function()
+ {
+ if($(this).prop('checked'))
+ {
+ $('#end').val('').attr('disabled', 'disabled');
+ $('#days').val('');
+ }
+ else
+ {
+ $('#end').removeAttr('disabled');
+ }
+ });
+});
diff --git a/module/program/lang/zh-cn.php b/module/program/lang/zh-cn.php
index 34b545dc81..1bc6de5683 100644
--- a/module/program/lang/zh-cn.php
+++ b/module/program/lang/zh-cn.php
@@ -81,6 +81,10 @@ $lang->program->templateList['waterfall'] = "瀑布";
$lang->program->PRJCategoryList['single'] = "单产品项目";
$lang->program->PRJCategoryList['multiple'] = "多产品项目";
+$lang->program->PRJLifeTimeList['short'] = "短期";
+$lang->program->PRJLifeTimeList['long'] = "长期";
+$lang->program->PRJLifeTimeList['ops'] = "运维";
+
$lang->program->featureBar['all'] = '所有';
$lang->program->featureBar['doing'] = '进行中';
$lang->program->featureBar['wait'] = '未开始';
diff --git a/module/program/model.php b/module/program/model.php
index 8c30797392..d9fe293dbe 100644
--- a/module/program/model.php
+++ b/module/program/model.php
@@ -766,10 +766,9 @@ class programModel extends model
*/
public function printPRJCommonAction()
{
- $output = "
";
+ $output = "
";
$output .= '';
$output .= "
";
@@ -795,7 +794,6 @@ class programModel extends model
$currentProjectName = $this->lang->program->common;
if($projectID)
{
- setCookie("lastproject", $projectID, $this->config->cookieLife, $this->config->webRoot, '', false, true);
$currentProject = $this->project->getById($projectID);
$currentProjectName = $currentProject->name;
}
@@ -1044,7 +1042,11 @@ class programModel extends model
*/
public function getPRJByID($projectID)
{
- return $this->dao->findById($projectID)->from(TABLE_PROJECT)->fetch();
+ if(!$projectID) return false;
+
+ $project = $this->dao->findById($projectID)->from(TABLE_PROJECT)->fetch();
+ if($project->end == '0000-00-00') $project->end = '';
+ return $project;
}
/**
@@ -1182,7 +1184,8 @@ class programModel extends model
$project = fixer::input('post')
->setDefault('status', 'wait')
->add('type', 'project')
- ->add('lifetime', 'short')
+ ->setIF($this->post->longTime == 1, 'end', '')
+ ->setIF($this->post->longTime == 1, 'days', 0)
->setIF($this->post->acl != 'custom', 'whitelist', '')
->setDefault('openedBy', $this->app->user->account)
->setDefault('end', '')
@@ -1191,11 +1194,12 @@ class programModel extends model
->join('whitelist', ',')
->cleanInt('budget')
->stripTags($this->config->program->editor->prjcreate['id'], $this->config->allowedTags)
+ ->remove('longTime')
->get();
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. */
@@ -1208,10 +1212,13 @@ class programModel extends model
}
}
+ $requiredFields = $this->config->program->PRJCreate->requiredFields;
+ if($this->post->longTime) $requiredFields = trim(str_replace(',end,', ',', ",{$requiredFields},"), ',');
+
$project = $this->loadModel('file')->processImgURL($project, $this->config->program->editor->prjcreate['id'], $this->post->uid);
$this->dao->insert(TABLE_PROJECT)->data($project)
->autoCheck()
- ->batchcheck($this->config->program->PRJCreate->requiredFields, 'notempty')
+ ->batchcheck($requiredFields, 'notempty')
->check('name', 'unique', "deleted='0'")
->check('code', 'unique', "deleted='0'")
->exec();
@@ -1244,33 +1251,80 @@ class programModel extends model
{
$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->PRJ = $projectID;
+ $groupPriv->account = $this->app->user->account;
+ $groupPriv->group = $PRJAdminID;
+ $groupPriv->PRJ = $projectID;
$this->dao->insert(TABLE_USERGROUP)->data($groupPriv)->exec();
}
- if($project->model == 'waterfall')
- {
- $product = new stdclass();
- $product->name = $project->name;
- $product->PRJ = $projectID;
- $product->status = 'normal';
- $product->createdBy = $this->app->user->account;
- $product->createdDate = helper::now();
-
- $this->dao->insert(TABLE_PRODUCT)->data($product)->exec();
-
- $productID = $this->dao->lastInsertId();
- $this->dao->update(TABLE_PRODUCT)->set('`order`')->eq($productID * 5)->where('id')->eq($productID)->exec();
-
- $data = new stdclass();
- $data->project = $projectID;
- $data->product = $productID;
- $this->dao->insert(TABLE_PROJECTPRODUCT)->data($data)->exec();
- }
-
return $projectID;
}
}
+
+ /**
+ * Update project.
+ *
+ * @param int $projectID
+ * @access public
+ * @return array
+ */
+ public function PRJUpdate($projectID = 0)
+ {
+ $oldProject = $this->dao->findById($projectID)->from(TABLE_PROJECT)->fetch();
+
+ $project = fixer::input('post')
+ ->setDefault('team', substr($this->post->name, 0, 30))
+ ->setIF($this->post->longTime == 1, 'end', '')
+ ->setIF($this->post->longTime == 1, 'days', 0)
+ ->setIF($this->post->begin == '0000-00-00', 'begin', '')
+ ->setIF($this->post->end == '0000-00-00', 'end', '')
+ ->join('whitelist', ',')
+ ->stripTags($this->config->program->editor->prjedit['id'], $this->config->allowedTags)
+ ->remove('longTime')
+ ->get();
+
+ if($project->parent)
+ {
+ $parentProgram = $this->dao->select('*')->from(TABLE_PROGRAM)->where('id')->eq($project->parent)->fetch();
+
+ if($parentProgram)
+ {
+ /* Child project begin cannot less than parent. */
+ if($project->begin < $parentProgram->begin) dao::$errors['begin'] = sprintf($this->lang->program->PRJBeginGreateChild, $parentProgram->begin);
+
+ /* When parent set end then child project end cannot greater than parent. */
+ if($parentProgram->end != '0000-00-00' and $project->end > $parentProgram->end) dao::$errors['end'] = sprintf($this->lang->program->PRJEndLetterChild, $parentProgram->end);
+
+ if(dao::isError()) return false;
+ }
+ }
+
+ $project = $this->loadModel('file')->processImgURL($project, $this->config->program->editor->prjedit['id'], $this->post->uid);
+ $requiredFields = $this->config->program->PRJEdit->requiredFields;
+ if($this->post->longTime) $requiredFields = trim(str_replace(',end,', ',', ",{$requiredFields},"), ',');
+
+ $this->dao->update(TABLE_PROJECT)->data($project)
+ ->autoCheck($skipFields = 'begin,end')
+ ->batchcheck($requiredFields, 'notempty')
+ ->checkIF($project->begin != '', 'begin', 'date')
+ ->checkIF($project->end != '', 'end', 'date')
+ ->checkIF($project->end != '', 'end', 'gt', $project->begin)
+ ->check('name', 'unique', "id!=$projectID and deleted='0'")
+ ->check('code', 'unique', "id!=$projectID and deleted='0'")
+ ->where('id')->eq($projectID)
+ ->exec();
+
+ if(!dao::isError())
+ {
+ $this->file->updateObjectID($this->post->uid, $projectID, 'project');
+ if($project->acl != 'open' and ($project->acl != $oldProject->acl or $project->whitelist != $oldProject->whitelist))
+ {
+ $this->loadModel('user')->updateUserView($projectID, 'project');
+ }
+
+ if($oldProject->parent != $project->parent) $this->processNode($projectID, $project->parent, $oldProject->path, $oldProject->grade);
+
+ return common::createChanges($oldProject, $project);
+ }
+ }
}
diff --git a/module/program/view/prjcreate.html.php b/module/program/view/prjcreate.html.php
index 89201379fd..06f8941bd7 100644
--- a/module/program/view/prjcreate.html.php
+++ b/module/program/view/prjcreate.html.php
@@ -16,6 +16,7 @@
+project->weekend);?>
@@ -43,6 +44,12 @@
program->PRJCode;?> |
| | |
+
+
+ | program->PRJCategory;?> |
+ program->PRJLifeTimeList, '', "class='form-control'");?> | | |
+
+
| program->PRJCategory;?> |
@@ -96,13 +103,6 @@
project->teamname;?> |
| | |
-
- | project->status;?> |
- |
- |
- |
- |
-
printExtendFields('', 'table');?>
| program->PRJDesc;?> |
@@ -113,7 +113,7 @@
| program->auth;?> |
- program->PRJAuthList, $privway, '', 'block');?> |
+ program->PRJAuthList, $privway, '', 'block');?> |
| project->acl;?> |
diff --git a/module/program/view/prjedit.html.php b/module/program/view/prjedit.html.php
index 990790b9a3..24d9b71243 100644
--- a/module/program/view/prjedit.html.php
+++ b/module/program/view/prjedit.html.php
@@ -38,6 +38,12 @@
program->PRJCode;?> |
code, "class='form-control' required");?> | | |
+ model == 'scrum'):?>
+
+ | program->PRJCategory;?> |
+ program->PRJLifeTimeList, $project->lifetime, "class='form-control'");?> | | |
+
+
model == 'waterfall'):?>
| program->PRJCategory;?> |
@@ -65,15 +71,16 @@
|
@@ -86,7 +93,9 @@
project->day;?>
- | |
+
+ |
+ |