* Adjust code.

This commit is contained in:
leiyong
2020-12-07 17:55:45 +08:00
parent 834aa60d87
commit 83ed1f2423
14 changed files with 131 additions and 107 deletions
+55 -39
View File
@@ -11,41 +11,55 @@
*/
class durationestimation extends control
{
public function index($programID)
/**
* Project duration estimation.
*
* @param int $projectID
* @access public
* @return void
*/
public function index($projectID)
{
$workestimation = $this->loadModel('workestimation')->getBudget($programID);
if(!$workestimation)
$workestimation = $this->loadModel('workestimation')->getBudget($projectID);
if(empty($workestimation))
{
echo js::alert($this->lang->durationestimation->setWorkestimation);
die(js::locate($this->createLink('workestimation', 'index', "currentProgram=$programID")));
die(js::locate($this->createLink('workestimation', 'index', "projectID=$projectID")));
}
$this->loadModel('programplan');
$program = $this->loadModel('project')->getById($programID);
$this->app->loadLang('programplan');
$project = $this->loadModel('program')->getPRJByID($projectID);
$stages = $this->loadModel('stage')->getStages();
$title = $this->lang->durationestimation->common . $this->lang->colon . $program->name;
$this->view->estimationList = $this->durationestimation->getListByProgram($programID);
if(empty($this->view->estimationList)) $this->locate(inlink('create', "currentProgram=$programID"));
$estimationList = $this->durationestimation->getListByProject($projectID);
if(empty($estimationList)) $this->locate(inlink('create', "projectID=$projectID"));
$this->view->title = $this->lang->durationestimation->common . $this->lang->colon . $project->name;
$this->view->position[] = $this->lang->durationestimation->common;
$this->view->workestimation = $workestimation;
$this->view->title = $title;
$this->view->program = $program;
$this->view->stages = $stages;
$this->view->estimationList = $estimationList;
$this->view->project = $project;
$this->view->stages = $stages;
$this->display();
}
public function create($programID = 0)
/**
* Save the project duration estimate.
*
* @param int $projectID
* @access public
* @return void
*/
public function create($projectID = 0)
{
$workestimation = $this->loadModel('workestimation')->getBudget($programID);
if(!$workestimation)
$workestimation = $this->loadModel('workestimation')->getBudget($projectID);
if(empty($workestimation))
{
echo js::alert($this->lang->durationestimation->setWorkestimation);
die(js::locate($this->createLink('workestimation', 'index', "currentProgram=$programID")));
die(js::locate($this->createLink('workestimation', 'index', "projectID=$projectID")));
}
$this->loadModel('programplan');
$this->app->loadLang('programplan');
if(!empty($_POST))
{
$total = 0;
@@ -54,49 +68,51 @@ class durationestimation extends control
$workloadTotal = $this->config->durationestimation->workloadTotal;
if($total != $workloadTotal) $this->send(array('result' => 'fail', 'message' => $this->lang->durationestimation->workloadError));
$this->durationestimation->save($programID);
$this->durationestimation->save($projectID);
if(dao::isError()) $this->send(array('result' => 'fail', 'message' => dao::getError()));
$this->send(array('result' => 'success', 'message' => $this->lang->saveSuccess, 'locate' => inlink('index', "currentProgram={$programID}")));
$this->send(array('result' => 'success', 'message' => $this->lang->saveSuccess, 'locate' => inlink('index', "projectID={$projectID}")));
}
$this->view->estimationList = $this->durationestimation->getListByProgram($programID);
$project = $this->loadModel('program')->getPRJByID($projectID);
$this->view->title = $this->lang->durationestimation->common . $this->lang->colon . $project->name;
$this->view->position[] = $this->lang->durationestimation->common;
$this->view->project = $project;
$this->view->stages = $this->loadModel('stage')->getStages();
$this->view->estimationList = $this->durationestimation->getListByProject($projectID);
$this->view->workestimation = $workestimation;
$program = $this->loadModel('project')->getById($programID);
$title = $this->lang->durationestimation->common . $this->lang->colon . $program->name;
$this->view->title = $title;
$this->view->program = $program;
$this->view->stages = $this->loadModel('stage')->getStages();
$this->display();
}
/**
* ajaxGetDuration
*
* @param int $program
* @param int $workload
* @param int $worktimeRate
* @param int $people
* Calculate the end time of the duration.
*
* @param int $projectID
* @param int $stage
* @param int $workload
* @param int $worktimeRate
* @param int $people
* @param string $startDate
* @access public
* @return void
*/
public function ajaxGetDuration($program, $stage, $workload, $worktimeRate, $people, $startDate)
public function ajaxGetDuration($projectID, $stage, $workload, $worktimeRate, $people, $startDate)
{
$startDate = str_replace('_', '-', $startDate);
if($startDate == '0000-00-00') $this->send(array('result' => 'success', 'endDate' => '0000-00-00'));
$estimation = $this->loadModel('workestimation')->getBudget($program);
$estimation = $this->loadModel('workestimation')->getBudget($projectID);
$duration = $estimation->duration * $workload / 100;
$divisor = ($people == 0 || $estimation->dayHour == 0) ? 0 : $worktimeRate / 100 * $people * $estimation->dayHour;
$duration = $divisor == 0 ? 0 : $duration / $divisor;
if(!$divisor) $this->send(array('result' => 'fail'));
$holidays = array();
$workDays = array();
$holidays = array();
$workDays = array();
$i = 0;
$this->loadModel('project');
$startedTime = strtotime($startDate);
+2 -2
View File
@@ -30,7 +30,7 @@ $().ready(function()
$(':input').change(function()
{
var that = $(this);
programID = program.id;
projectID = project.id;
stage = $(this).parents('tr').find('[name*=stage]').val();
workload = $(this).parents('tr').find('[name*=workload]').val();
worktimeRate = $(this).parents('tr').find('[name*=worktimeRate]').val();
@@ -39,7 +39,7 @@ $().ready(function()
if(startDate) startDate = startDate.replace(/-/g, '_');
if(isNaN(workload) || isNaN(worktimeRate) || isNaN(people) || startDate == '') return false;
url = createLink('durationestimation', 'ajaxGetDuration', 'program=' + programID + '&stage=' + stage + '&workload=' + workload + '&worktimeRate=' + worktimeRate + '&people=' + people + '&startDate=' + startDate),
url = createLink('durationestimation', 'ajaxGetDuration', 'projectID=' + projectID + '&stage=' + stage + '&workload=' + workload + '&worktimeRate=' + worktimeRate + '&people=' + people + '&startDate=' + startDate),
$.getJSON(
url,
function(response)
+29 -15
View File
@@ -1,35 +1,49 @@
<?php
/**
* The model file of durationestimation module of ChanzhiEPS.
* The model file of durationestimation of ZentaoPMS.
*
* @copyright Copyright 2009-2010 QingDao Nature Easy Soft Network Technology Co,LTD (www.cnezsoft.com)
* @license ZPL (http://zpl.pub/page/zplv11.html)
* @author Xiying Guan <guanxiying@xirangit.com>
* @package durationestimation
* @version $Id$
* @link http://www.chanzhi.org
* @link http://www.zentao.net
*/
class durationestimationModel extends model
{
public function getListByProgram($program)
/**
* Get the project duration estimate.
*
* @param int $projectID
* @access public
* @return void
*/
public function getListByProject($projectID)
{
return $this->dao->select('*')->from(TABLE_DURATIONESTIMATION)->where('PRJ')->eq($program)->fetchAll('stage');
return $this->dao->select('*')->from(TABLE_DURATIONESTIMATION)->where('PRJ')->eq($projectID)->fetchAll('stage');
}
public function save($program)
/**
* Save the project duration estimate.
*
* @param int $projectID
* @access public
* @return void
*/
public function save($projectID)
{
$this->dao->delete()->from(TABLE_DURATIONESTIMATION)->where('PRJ')->eq($program);
$this->dao->delete()->from(TABLE_DURATIONESTIMATION)->where('PRJ')->eq($projectID);
foreach($this->post->stage as $i => $stage)
{
$estimation = new stdclass;
$estimation->PRJ = $program;
$estimation->stage = $stage;
$estimation->workload = $this->post->workload[$i];
$estimation->worktimeRate = $this->post->worktimeRate[$i];
$estimation->people = $this->post->people[$i];
$estimation->startDate = $this->post->startDate[$i];
$estimation->endDate = $this->post->endDate[$i];
$this->dao->insert(TABLE_DURATIONESTIMATION)->data($estimation)->exec();
$data = new stdclass;
$data->PRJ = $projectID;
$data->stage = $stage;
$data->workload = $this->post->workload[$i];
$data->worktimeRate = $this->post->worktimeRate[$i];
$data->people = $this->post->people[$i];
$data->startDate = $this->post->startDate[$i];
$data->endDate = $this->post->endDate[$i];
$this->dao->insert(TABLE_DURATIONESTIMATION)->data($data)->exec();
}
return !dao::isError();
@@ -1,5 +1,5 @@
<?php include '../../common/view/header.html.php';?>
<?php js::set('program', $program);?>
<?php js::set('project', $project);?>
<?php js::set('estimation', $workestimation);?>
<div id='mainContent' class='main-content'>
<form class='main-form form-ajax' method='post' id='stageForm' enctype='multipart/form-data'>
@@ -1,6 +1,4 @@
<?php include '../../common/view/header.html.php';?>
<?php js::set('program', $program);?>
<?php js::set('estimation', $workestimation);?>
<div id='mainContent' class='main-content'>
<form class='main-form form-ajax' method='post' id='planForm' enctype='multipart/form-data'>
<table class='table table-list table-bordered'>
@@ -23,8 +21,8 @@
<?php echo $plan->name;?>
<?php echo html::hidden('stage[]', $plan->id);?>
</td>
<td> <?php echo zget($estimation, 'workload', ''); ?>% </td>
<td> <?php echo zget($estimation, 'worktimeRate', '');?>% </td>
<td><?php echo zget($estimation, 'workload', ''); ?>% </td>
<td><?php echo zget($estimation, 'worktimeRate', '');?>% </td>
<td><?php echo zget($estimation, 'people', '');?></td>
<td><?php echo zget($estimation, 'startDate', '');?></td>
<td><?php echo zget($estimation, 'endDate', '');?></td>
@@ -35,14 +33,11 @@
<tfoot>
<tr>
<td colspan='6' class='form-actions text-center'>
<?php echo html::a(inlink('create', "program={$program->id}"), $lang->durationestimation->setting, '', "class='btn btn-primary'");?>
<?php echo html::a(inlink('create', "projectID={$project->id}"), $lang->durationestimation->setting, '', "class='btn btn-primary'");?>
</td>
</tr>
</tfoot>
</table>
</table>
<?php js::set('i', $i);?>
</form>
</div>
<?php include '../../common/view/footer.html.php';?>
+7 -7
View File
@@ -1,12 +1,12 @@
<?php
/**
* The control file of workestimation of ChanzhiEPS.
* The control file of workestimation module of ZenTaoPMS.
*
* @copyright Copyright 2009-2010 QingDao Nature Easy Soft Network Technology Co,LTD (www.cnezsoft.com)
* @license ZPL (http://zpl.pub/page/zplv11.html)
* @author Xiying Guan <guanxiying@xirangit.com>
* @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 workestimation
* @version $Id$
* @version $Id
* @link http://www.zentao.net
*/
class workestimation extends control
@@ -28,7 +28,7 @@ class workestimation extends control
$this->send(array('result' => 'fail', 'message' => dao::getError()));
}
$scale = $this->workestimation->getProgramScale($projectID);
$scale = $this->workestimation->getProjectScale($projectID);
$budget = $this->workestimation->getBudget($projectID);
if(!isset($this->config->project)) $this->config->project = new stdclass();
if(empty($budget))
@@ -44,7 +44,7 @@ class workestimation extends control
$this->view->title = $this->lang->workestimation->common;
$this->view->position[] = $this->lang->workestimation->common;
$this->view->hourPoint = $this->config->custom->hourPoint;
$this->view->programScale = $scale;
$this->view->scale = $scale;
$this->view->budget = $budget;
$this->display();
}
+2 -2
View File
@@ -11,8 +11,8 @@ $lang->workestimation->dayHour = 'Daily Man-hours';
$lang->workestimation->hour = 'Man-hour';
$lang->workestimation->consumed = 'Cost Man-hours';
$lang->workestimation->programScaleTip = "Actual scale of current project: <strong>%s{$lang->hourCommon}</strong> <a href='###' id='useScale' class='btn btn-xs'> uses </span>";
$lang->workestimation->tips = 'Estimate the duration of the project only after the estimate of the workload has been completed';
$lang->workestimation->scaleTip = "Actual scale of current project: <strong>%s{$lang->hourCommon}</strong> <a href='###' id='useScale' class='btn btn-xs'> uses </span>";
$lang->workestimation->tips = 'Estimate the duration of the project only after the estimate of the workload has been completed';
$lang->workestimation->placeholder = new stdclass();
$lang->workestimation->placeholder->scale = '';
+2 -2
View File
@@ -11,8 +11,8 @@ $lang->workestimation->dayHour = 'Daily Man-hours';
$lang->workestimation->hour = 'Man-hour';
$lang->workestimation->consumed = 'Cost Man-hours';
$lang->workestimation->programScaleTip = "Actual scale of current project: <strong>%s{$lang->hourCommon}</strong> <a href='###' id='useScale' class='btn btn-xs'> uses </span>";
$lang->workestimation->tips = 'Estimate the duration of the project only after the estimate of the workload has been completed';
$lang->workestimation->scaleTip = "Actual scale of current project: <strong>%s{$lang->hourCommon}</strong> <a href='###' id='useScale' class='btn btn-xs'> uses </span>";
$lang->workestimation->tips = 'Estimate the duration of the project only after the estimate of the workload has been completed';
$lang->workestimation->placeholder = new stdclass();
$lang->workestimation->placeholder->scale = '';
+2 -2
View File
@@ -11,8 +11,8 @@ $lang->workestimation->dayHour = 'Daily Man-hours';
$lang->workestimation->hour = 'Man-hour';
$lang->workestimation->consumed = 'Cost Man-hours';
$lang->workestimation->programScaleTip = "Actual scale of current project: <strong>%s{$lang->hourCommon}</strong> <a href='###' id='useScale' class='btn btn-xs'> uses </span>";
$lang->workestimation->tips = 'Estimate the duration of the project only after the estimate of the workload has been completed';
$lang->workestimation->scaleTip = "Actual scale of current project: <strong>%s{$lang->hourCommon}</strong> <a href='###' id='useScale' class='btn btn-xs'> uses </span>";
$lang->workestimation->tips = 'Estimate the duration of the project only after the estimate of the workload has been completed';
$lang->workestimation->placeholder = new stdclass();
$lang->workestimation->placeholder->scale = '';
+2 -2
View File
@@ -11,8 +11,8 @@ $lang->workestimation->dayHour = 'Daily Man-hours';
$lang->workestimation->hour = 'Man-hour';
$lang->workestimation->consumed = 'Cost Man-hours';
$lang->workestimation->programScaleTip = "Actual scale of current project: <strong>%s{$lang->hourCommon}</strong> <a href='###' id='useScale' class='btn btn-xs'> uses </span>";
$lang->workestimation->tips = 'Estimate the duration of the project only after the estimate of the workload has been completed';
$lang->workestimation->scaleTip = "Actual scale of current project: <strong>%s{$lang->hourCommon}</strong> <a href='###' id='useScale' class='btn btn-xs'> uses </span>";
$lang->workestimation->tips = 'Estimate the duration of the project only after the estimate of the workload has been completed';
$lang->workestimation->placeholder = new stdclass();
$lang->workestimation->placeholder->scale = '';
+2 -2
View File
@@ -11,8 +11,8 @@ $lang->workestimation->dayHour = '每日工时';
$lang->workestimation->hour = '工时';
$lang->workestimation->consumed = '已消耗工时';
$lang->workestimation->programScaleTip = "当前项目实际规模:<strong>%s{$lang->hourCommon}</strong> <a href='###' id='useScale' class='btn btn-xs'>使用</span>";
$lang->workestimation->tips = '完成工作量估算后,才能进行工期估算';
$lang->workestimation->scaleTip = "当前项目实际规模:<strong>%s{$lang->hourCommon}</strong> <a href='###' id='useScale' class='btn btn-xs'>使用</span>";
$lang->workestimation->tips = '完成工作量估算后,才能进行工期估算';
$lang->workestimation->placeholder = new stdclass();
$lang->workestimation->placeholder->scale = '';
+2 -2
View File
@@ -11,8 +11,8 @@ $lang->workestimation->dayHour = '每日工時';
$lang->workestimation->hour = '工時';
$lang->workestimation->consumed = '已消耗工時';
$lang->workestimation->programScaleTip = "當前項目實際規模:<strong>%s{$lang->hourCommon}</strong> <a href='###' id='useScale' class='btn btn-xs'>使用</span>";
$lang->workestimation->tips = '完成工作量估算後,才能進行工期估算';
$lang->workestimation->scaleTip = "當前項目實際規模:<strong>%s{$lang->hourCommon}</strong> <a href='###' id='useScale' class='btn btn-xs'>使用</span>";
$lang->workestimation->tips = '完成工作量估算後,才能進行工期估算';
$lang->workestimation->placeholder = new stdclass();
$lang->workestimation->placeholder->scale = '';
+20 -21
View File
@@ -1,12 +1,12 @@
<?php
/**
* The model file of workestimation module of ChanzhiEPS.
* The model file of workestimation module of ZenTaoPMS.
*
* @copyright Copyright 2009-2010 QingDao Nature Easy Soft Network Technology Co,LTD (www.cnezsoft.com)
* @license ZPL (http://zpl.pub/page/zplv11.html)
* @author Xiying Guan <guanxiying@xirangit.com>
* @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 workestimation
* @version $Id$
* @version $Id
* @link http://www.zentao.net
*/
class workestimationModel extends model
@@ -14,45 +14,44 @@ class workestimationModel extends model
/**
* Get a budget.
*
* @param int $program
* @param int $projectID
* @access public
* @return array
*/
public function getBudget($program)
public function getBudget($projectID)
{
return $this->dao->select('*')->from(TABLE_WORKESTIMATION)->where('PRJ')->eq($program)->fetch();
return $this->dao->select('*')->from(TABLE_WORKESTIMATION)->where('PRJ')->eq($projectID)->fetch();
}
/**
* Get program scale.
* Get project scale.
*
* @param int $program
* @param int $projectID
* @access public
* @return int
*/
public function getProgramScale($program)
public function getProjectScale($projectID)
{
$products = $this->loadModel('product')->getPairs('', $program);
$products = $this->loadModel('product')->getProductPairsByProject($projectID);
$productIdList = array_keys($products);
return $this->dao->select('cast(sum(estimate) as decimal(10,2)) as scale')->from(TABLE_STORY)->where('product')->in($productIdList)->andWhere('type')->eq('requirement')->fetch('scale');
return $this->dao->select('cast(sum(estimate) as decimal(10,2)) as scale')->from(TABLE_STORY)->where('product')->in($productIdList)->andWhere('type')->eq('requirement')->andWhere('deleted')->eq(0)->fetch('scale');
}
/**
/*
* Save a budget.
*
* @param int $program
* @param int $projectID
* @access public
* @return bool
*/
public function save($program)
public function save($projectID)
{
$postBudget = fixer::input('post')->get();
$postBudget->PRJ = $program;
$data = fixer::input('post')->setDefault('PRJ', $projectID)->get();
$budget = $this->getBudget($program);
if(!empty($budget)) $postBudget->id = $budget->id;
$budget = $this->getBudget($projectID);
if(!empty($budget)) $data->id = $budget->id;
$this->dao->replace(TABLE_WORKESTIMATION)->data($postBudget)
$this->dao->replace(TABLE_WORKESTIMATION)->data($data)
->batchCheck($this->config->workestimation->index->requiredFields, 'notempty')
->exec();
+2 -2
View File
@@ -28,7 +28,7 @@
<span class='input-group-addon unify-padding'><?php echo $lang->hourCommon;?></span>
</div>
</td>
<td><?php if(isset($budget->duration) and $budget->duration) printf($lang->workestimation->programScaleTip, $programScale);?></td>
<td><?php if(isset($budget->duration) and $budget->duration) printf($lang->workestimation->scaleTip, $scale);?></td>
<td></td>
<td></td>
</tr>
@@ -95,7 +95,7 @@ $(function()
{
$('#useScale').click(function()
{
$('#scale').val('<?php echo $programScale;?>').keyup();
$('#scale').val('<?php echo $scale;?>').keyup();
});
$(':input').keyup(function()