This commit is contained in:
王怡栋
2021-08-12 09:29:30 +08:00
12 changed files with 91 additions and 17 deletions
+1
View File
@@ -14,6 +14,7 @@ class productEntry extends Entry
$control->view($productID);
$data = $this->getData();
if(!$data or (isset($data->status) and $data->message == '404 Not found')) return $this->send404();
if(isset($data->status) and $data->status == 'success') return $this->send(200, $this->format($data->data->product, 'createdDate:time'));
if(isset($data->status) and $data->status == 'fail') return $this->sendError(400, $data->message);
+1
View File
@@ -14,6 +14,7 @@ class projectEntry extends entry
$control->view($projectID);
$data = $this->getData();
if(!$data or (isset($data->status) and $data->message == '404 Not found')) return $this->send404();
if(isset($data->status) and $data->status == 'success') return $this->send(200, $this->format($data->data->project, 'openedDate:time,lastEditedDate:time,closedDate:time,canceledDate:time'));
if(isset($data->status) and $data->status == 'fail') return $this->sendError(400, $data->message);
+1 -1
View File
@@ -9,7 +9,7 @@ class entry extends baseEntry
{
parent::__construct();
if(!isset($this->app->user)) $this->sendError(401, 'Unauthorized');
if(!isset($this->app->user) or $this->app->user->account == 'guest') $this->sendError(401, 'Unauthorized');
$this->dao = $this->loadModel('common')->dao;
}
+1 -1
View File
@@ -2292,7 +2292,7 @@ class execution extends control
$this->view->title = $title;
$this->view->position = $position;
$this->view->execution = $execution;
$this->view->execution = $execution;
$this->view->users = $users;
$this->view->deptUsers = $deptUsers;
$this->view->roles = $roles;
+1 -2
View File
@@ -491,8 +491,7 @@ class personnelModel extends model
}
elseif($objectType == 'project')
{
$parentID = $this->dao->select('parent')->from(TABLE_PROJECT)->where('id')->eq($objectID)->fetch('parent');
$objects = $this->loadModel('project')->getPairsByProgram($parentID);
$objects = $this->loadModel('project')->getPairsByProgram();
}
elseif($objectType == 'product')
{
+6 -1
View File
@@ -687,7 +687,12 @@ class product extends control
{
$productID = (int)$productID;
$product = $this->product->getStatByID($productID);
if(!$product) die(js::error($this->lang->notFound) . js::locate('back'));
if(!$product)
{
if(defined('RUN_MODE') && RUN_MODE == 'api') return $this->send(array('status' => 'fail', 'message' => '404 Not found'));
die(js::error($this->lang->notFound) . js::locate('back'));
}
$product->desc = $this->loadModel('file')->setImgSize($product->desc);
$this->product->setMenu($productID);
+17 -6
View File
@@ -560,9 +560,13 @@ class project extends control
*/
public function view($projectID = 0)
{
$projectID = $this->project->saveState((int)$projectID, $this->project->getPairsByProgram());
$project = $this->project->getById($projectID);
if(empty($project) || strpos('scrum,waterfall', $project->model) === false) die(js::error($this->lang->notFound) . js::locate('back'));
if(!defined('RUN_MODE') || RUN_MODE != 'api') $projectID = $this->project->saveState((int)$projectID, $this->project->getPairsByProgram());
$project = $this->project->getById($projectID);
if(empty($project) || strpos('scrum,waterfall', $project->model) === false)
{
if(defined('RUN_MODE') && RUN_MODE == 'api') return $this->send(array('status' => 'fail', 'message' => '404 Not found'));
die(js::error($this->lang->notFound) . js::locate('back'));
}
$this->project->setMenu($projectID);
@@ -1171,10 +1175,11 @@ class project extends control
*
* @param int $projectID
* @param int $dept
* @param int $copyProjectID
* @access public
* @return void
*/
public function manageMembers($projectID, $dept = '')
public function manageMembers($projectID, $dept = '', $copyProjectID = 0)
{
/* Load model. */
$this->loadModel('user');
@@ -1187,7 +1192,7 @@ class project extends control
$this->project->manageMembers($projectID);
$this->loadModel('action')->create('team', $projectID, 'ManagedTeam');
$link = $this->createLink('project', 'manageMembers', "projectID=$projectID");
$link = $this->createLink('project', 'team', "projectID=$projectID");
return $this->send(array('message' => $this->lang->saveSuccess, 'result' => 'success', 'locate' => $link));
}
@@ -1196,6 +1201,9 @@ class project extends control
$roles = $this->user->getUserRoles(array_keys($users));
$deptUsers = $dept === '' ? array() : $this->dept->getDeptUserPairs($dept);
$currentMembers = $this->project->getTeamMembers($projectID);
$members2Import = $this->project->getMembers2Import($copyProjectID, array_keys($currentMembers));
$this->view->title = $this->lang->project->manageMembers . $this->lang->colon . $project->name;
$this->view->position[] = $this->lang->project->manageMembers;
@@ -1205,7 +1213,10 @@ class project extends control
$this->view->roles = $roles;
$this->view->dept = $dept;
$this->view->depts = array('' => '') + $this->dept->getOptionMenu();
$this->view->currentMembers = $this->project->getTeamMembers($projectID);
$this->view->currentMembers = $currentMembers;
$this->view->members2Import = $members2Import;
$this->view->teams2Import = array('' => '') + $this->loadModel('personnel')->getCopyObjects($projectID, 'project');
$this->view->copyProjectID = $copyProjectID;
$this->display();
}
+14
View File
@@ -34,3 +34,17 @@ function setDeptUsers(obj)
link = createLink('project', 'manageMembers', 'projectID=' + projectID + '&dept=' + dept); // Create manageMembers link.
location.href=link;
}
/**
* Chose team to copy.
*
* @param object $obj
* @access public
* @return void
*/
function choseTeam2Copy(obj)
{
team = $(obj).val();
link = createLink('project', 'manageMembers', 'projectID=' + projectID + '&dept=&team2Import=' + team);
location.href=link;
}
+20
View File
@@ -1594,6 +1594,26 @@ class projectModel extends model
return array('' => '') + $members;
}
/**
* Get members of a project who can be imported.
*
* @param int $projectID
* @param array $currentMembers
* @access public
* @return array
*/
public function getMembers2Import($projectID, $currentMembers)
{
if($projectID == 0) return array();
return $this->dao->select('account, role, hours')
->from(TABLE_TEAM)
->where('root')->eq($projectID)
->andWhere('type')->in('project')
->andWhere('account')->notIN($currentMembers)
->fetchAll('account');
}
/**
* Get project stats.
*
@@ -9,6 +9,10 @@
<div class='input-group space w-200px'>
<span class='input-group-addon'><?php echo $lang->execution->selectDept?></span>
<?php echo html::select('dept', $depts, $dept, "class='form-control chosen' onchange='setDeptUsers(this)' data-placeholder='{$lang->execution->selectDeptTitle}'");?>
<?php if(count($teams2Import) != 1):?>
<span class='input-group-addon'><?php echo $lang->execution->copyTeam?></span>
<?php echo html::select('execution', $teams2Import, $copyProjectID, "class='form-control chosen' onchange='choseTeam2Copy(this)' data-placeholder='{$lang->execution->copyTeamTitle}'");?>
<?php endif;?>
</div>
</div>
</div>
@@ -47,6 +51,23 @@
<?php $i ++; $memberCount ++;?>
<?php endforeach;?>
<?php foreach($members2Import as $member2Import):?>
<tr class='addedItem'>
<td><?php echo html::select("accounts[]", $users, $member2Import->account, "class='form-control chosen' onchange='setRole(this.value, $i)'");?></td>
<td><input type='text' name='roles[]' id='role<?php echo $i;?>' class='form-control' value='<?php echo $member2Import->role;?>' /></td>
<td><input type='text' name='days[]' id='days<?php echo $i;?>' class='form-control' value='<?php echo $project->days?>'/></td>
<td>
<input type='text' name='hours[]' id='hours<?php echo $i;?>' class='form-control' value='<?php echo $member2Import->hours;?>' />
</td>
<td><?php echo html::radio("limited[$i]", $lang->team->limitedList, 'no');?></td>
<td class='c-actions text-center'>
<a href='javascript:;' onclick='addItem(this)' class='btn btn-link'><i class='icon-plus'></i></a>
<a href='javascript:;' onclick='deleteItem(this)' class='btn btn-link'><i class='icon icon-close'></i></a>
</td>
</tr>
<?php $i ++; $memberCount ++;?>
<?php endforeach;?>
<?php foreach($deptUsers as $deptAccount => $userName):?>
<?php if(!isset($users[$deptAccount])) continue;?>
<tr class='addedItem'>
+7 -5
View File
@@ -1280,7 +1280,6 @@ class storyModel extends model
->setDefault('lastEditedDate', $now)
->setDefault('status', $oldStory->status)
->setIF($this->post->result == 'revert', 'version', $this->post->preVersion)
->setIF($this->post->result == 'revert', 'status', 'active')
->removeIF($this->post->result != 'reject', 'closedReason, duplicateStory, childStories')
->removeIF($this->post->result == 'reject' and $this->post->closedReason != 'duplicate', 'duplicateStory')
->removeIF($this->post->result == 'reject' and $this->post->closedReason != 'subdivided', 'childStories')
@@ -1299,7 +1298,7 @@ class storyModel extends model
$reviewedBy = explode(',', trim($story->reviewedBy, ','));
if(!array_diff(array_keys($reviewerList), $reviewedBy))
{
$status = $this->setStatusByReviewRules($reviewerList);
$status = $this->post->result == 'revert' ? 'active' : $this->setStatusByReviewRules($reviewerList);
$story->status = $status ? $status : $oldStory->status;
if($story->status == 'closed')
{
@@ -4497,9 +4496,12 @@ class storyModel extends model
$comment = isset($_POST['comment']) ? $this->post->comment : '';
$actionID = !empty($result) ? $this->loadModel('action')->create('story', $story->id, 'Reviewed', $comment, ucfirst($result) . $reasonParam) : '';
if($story->status == 'closed') $this->action->create('story', $story->id, 'ReviewClosed');
if($story->status == 'active') $this->action->create('story', $story->id, 'PassReviewed');
if(!array_diff(array_keys($reviewers), $reviewedBy) and ($story->status == 'draft' || $story->status == 'changed')) $this->action->create('story', $story->id, 'ClarifyReviewed');
if(ucfirst($result) != 'Revert')
{
if($story->status == 'closed') $this->action->create('story', $story->id, 'ReviewClosed');
if($story->status == 'active') $this->action->create('story', $story->id, 'PassReviewed');
if(!array_diff(array_keys($reviewers), $reviewedBy) and ($story->status == 'draft' || $story->status == 'changed')) $this->action->create('story', $story->id, 'ClarifyReviewed');
}
return $actionID;
}
+1 -1
View File
@@ -211,7 +211,7 @@
<?php if($isShowReviewer):?>
<tr>
<th><?php echo $lang->story->reviewers;?></th>
<td><?php echo html::select('reviewer[]', array('' => '') + $users, $reviewers, 'class="form-control chosen" multiple')?></td>
<td><?php echo html::select('reviewer[]', $users, $reviewers, 'class="form-control chosen" multiple')?></td>
</tr>
<?php endif;?>
<?php if($story->status == 'closed'):?>