Finish task#3238 项目挂起再激活的时候给用户选择是否顺延任务起止时间,cost:3 left:0
This commit is contained in:
@@ -1166,11 +1166,18 @@ class project extends control
|
||||
die(js::reload('parent.parent'));
|
||||
}
|
||||
|
||||
$newBegin = date('Y-m-d');
|
||||
$dateDiff = helper::diffDate($newBegin, $project->begin);
|
||||
$newEnd = date('Y-m-d', strtotime($project->end) + $dateDiff * 24 * 3600);
|
||||
|
||||
$this->view->title = $this->view->project->name . $this->lang->colon .$this->lang->project->activate;
|
||||
$this->view->position[] = html::a($this->createLink('project', 'browse', "projectID=$projectID"), $this->view->project->name);
|
||||
$this->view->position[] = $this->lang->project->activate;
|
||||
$this->view->project = $project;
|
||||
$this->view->users = $this->loadModel('user')->getPairs('noletter');
|
||||
$this->view->actions = $this->loadModel('action')->getList('project', $projectID);
|
||||
$this->view->newBegin = $newBegin;
|
||||
$this->view->newEnd = $newEnd;
|
||||
$this->display();
|
||||
}
|
||||
|
||||
|
||||
@@ -52,6 +52,8 @@ $lang->project->other = 'Other:';
|
||||
$lang->project->deleted = 'Deleted';
|
||||
$lang->project->delayed = 'Delayed';
|
||||
$lang->project->product = $lang->project->products;
|
||||
$lang->project->readjustTime = 'Readjust project time for begin and end';
|
||||
$lang->project->readjustTask = 'Readjust task start date and deadline';
|
||||
|
||||
$lang->project->start = 'Start';
|
||||
$lang->project->activate = 'Activate';
|
||||
|
||||
@@ -52,6 +52,8 @@ $lang->project->other = '其他:';
|
||||
$lang->project->deleted = '已删除';
|
||||
$lang->project->delayed = '已延期';
|
||||
$lang->project->product = $lang->project->products;
|
||||
$lang->project->readjustTime = '调整项目起止时间';
|
||||
$lang->project->readjustTask = '顺延任务的起止时间';
|
||||
|
||||
$lang->project->start = '开始';
|
||||
$lang->project->activate = '激活';
|
||||
|
||||
@@ -508,13 +508,54 @@ class projectModel extends model
|
||||
$now = helper::now();
|
||||
$project = fixer::input('post')
|
||||
->setDefault('status', 'doing')
|
||||
->remove('comment')->get();
|
||||
->remove('comment,readjustTime,readjustTask')
|
||||
->get();
|
||||
|
||||
if(!$this->post->readjustTime)
|
||||
{
|
||||
unset($project->begin);
|
||||
unset($project->end);
|
||||
}
|
||||
|
||||
$this->dao->update(TABLE_PROJECT)->data($project)
|
||||
->autoCheck()
|
||||
->where('id')->eq((int)$projectID)
|
||||
->exec();
|
||||
|
||||
/* Readjust task. */
|
||||
if($this->post->readjustTime and $this->post->readjustTask)
|
||||
{
|
||||
$beginTimeStamp = strtotime($project->begin);
|
||||
$tasks = $this->dao->select('id,estStarted,deadline,status')->from(TABLE_TASK)
|
||||
->where('deadline')->ne('0000-00-00')
|
||||
->andWhere('status')->in('wait,doing')
|
||||
->fetchAll();
|
||||
foreach($tasks as $task)
|
||||
{
|
||||
if($task->status == 'wait' and $task->estStarted != '0000-00-00')
|
||||
{
|
||||
$taskDays = helper::diffDate($task->deadline, $task->estStarted);
|
||||
$taskOffset = helper::diffDate($task->estStarted, $oldProject->begin);
|
||||
|
||||
$estStartedTimeStamp = $beginTimeStamp + $taskOffset * 24 * 3600;
|
||||
$estStarted = date('Y-m-d', $estStartedTimeStamp);
|
||||
$deadline = date('Y-m-d', $estStartedTimeStamp + $taskDays * 24 * 3600);
|
||||
|
||||
if($estStarted > $project->end) $estStarted = $project->end;
|
||||
if($deadline > $project->end) $deadline = $project->end;
|
||||
$this->dao->update(TABLE_TASK)->set('estStarted')->eq($estStarted)->set('deadline')->eq($deadline)->where('id')->eq($task->id)->exec();
|
||||
}
|
||||
else
|
||||
{
|
||||
$taskOffset = helper::diffDate($task->deadline, $oldProject->begin);
|
||||
$deadline = date('Y-m-d', $beginTimeStamp + $taskOffset * 24 * 3600);
|
||||
|
||||
if($deadline > $project->end) $deadline = $project->end;
|
||||
$this->dao->update(TABLE_TASK)->set('deadline')->eq($deadline)->where('id')->eq($task->id)->exec();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if(!dao::isError()) return common::createChanges($oldProject, $project);
|
||||
}
|
||||
|
||||
|
||||
@@ -12,6 +12,7 @@
|
||||
?>
|
||||
<?php include '../../common/view/header.html.php';?>
|
||||
<?php include '../../common/view/kindeditor.html.php';?>
|
||||
<?php include '../../common/view/datepicker.html.php';?>
|
||||
<?php js::import($jsRoot . 'misc/date.js');?>
|
||||
<div class='container'>
|
||||
<div id='titlebar'>
|
||||
@@ -24,8 +25,28 @@
|
||||
<form class='form-condensed' method='post' target='hiddenwin'>
|
||||
<table class='table table-form'>
|
||||
<tr>
|
||||
<th class='text-left'><?php echo $lang->comment;?></th>
|
||||
<td><?php echo html::textarea('comment', '', "rows='6' class='form-control'");?></td>
|
||||
<th class='w-80px text-right'><?php echo $lang->project->beginAndEnd;?></th>
|
||||
<td class='w-200px'><?php echo $project->begin . ' ~ ' . $project->end;?></td>
|
||||
<td>
|
||||
<label class="checkbox-inline"><input name="readjustTime" value="1" id="readjustTime" type="checkbox"> <strong><?php echo $lang->project->readjustTime?></strong></label>
|
||||
</td>
|
||||
</tr>
|
||||
<tr id='readjustTimeBox' class='hide'>
|
||||
<th></th>
|
||||
<td colspan='2'>
|
||||
<div class='input-group'>
|
||||
<?php echo html::input('begin', $newBegin, "class='form-control form-date'")?>
|
||||
<span class='input-group-addon'> ~ </span>
|
||||
<?php echo html::input('end', $newEnd, "class='form-control form-date'")?>
|
||||
<span class='input-group-addon'>
|
||||
<label class="checkbox-inline"><input name="readjustTask" value="1" id="readjustTask" type="checkbox"> <strong><?php echo $lang->project->readjustTask?></strong></label>
|
||||
</span>
|
||||
</div>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th class='text-right'><?php echo $lang->comment;?></th>
|
||||
<td colspan='2'><?php echo html::textarea('comment', '', "rows='6' class='form-control'");?></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th></th>
|
||||
@@ -35,4 +56,13 @@
|
||||
</form>
|
||||
<div class='main'><?php include '../../common/view/action.html.php';?></div>
|
||||
</div>
|
||||
<script>
|
||||
$(function()
|
||||
{
|
||||
$('#readjustTime').change(function()
|
||||
{
|
||||
$('#readjustTimeBox').toggle($(this).prop('checked'))
|
||||
})
|
||||
})
|
||||
</script>
|
||||
<?php include '../../common/view/footer.html.php';?>
|
||||
|
||||
Reference in New Issue
Block a user