* 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
+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();