* submit getprogrammaxend control layer.
This commit is contained in:
+15
-23
@@ -221,52 +221,44 @@ class project extends control
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取项目选中项目或项目集对象的信息
|
||||
* Ajax: Get selected object's information.
|
||||
*
|
||||
* @param str $objectType
|
||||
* @param int $objectID
|
||||
* @param int $selectedProgramID
|
||||
* @param string $objectType
|
||||
* @param string $objectID
|
||||
* @param string $selectedProgramID
|
||||
*
|
||||
* @access public
|
||||
* @return void
|
||||
*/
|
||||
public function ajaxGetObjectInfo($objectType, $objectID, $selectedProgramID)
|
||||
public function ajaxGetObjectInfo(string $objectType, string $objectID, string $selectedProgramID)
|
||||
{
|
||||
/* Get the available budget for the program. */
|
||||
if($selectedProgramID)
|
||||
{
|
||||
$selectedProgram = $this->loadModel('program')->getByID($selectedProgramID);
|
||||
$selectedProgramID = (int)$selectedProgramID;
|
||||
$selectedProgram = $this->loadModel('program')->getByID($selectedProgramID);
|
||||
if($selectedProgram->budget) $availableBudget = $this->program->getBudgetLeft($selectedProgram);
|
||||
}
|
||||
|
||||
/* Get the available budget and program time range. */
|
||||
if(!empty($objectID))
|
||||
{
|
||||
$objectID = (int)$objectID;
|
||||
$object = $objectType == 'project' ? $this->project->getByID($objectID) : $this->loadModel('program')->getByID($objectID);
|
||||
$object = $objectType == 'project' ? $this->project->getByID($objectID) : $this->loadModel('program')->getByID($objectID);
|
||||
|
||||
if(isset($availableBudget)) $availableBudget = $object->parent == $selectedProgramID ? $availableBudget + (int)$object->budget : $availableBudget;
|
||||
|
||||
if($objectType == 'program')
|
||||
{
|
||||
$minChildBegin = $this->dao->select('`begin` as minBegin')->from(TABLE_PROGRAM)->where('id')->ne($objectID)->andWhere('deleted')->eq(0)->andWhere('path')->like("%,{$objectID},%")->orderBy('begin_asc')->fetch('minBegin');
|
||||
$maxChildEnd = $this->dao->select('`end` as maxEnd')->from(TABLE_PROGRAM)->where('id')->ne($objectID)->andWhere('deleted')->eq(0)->andWhere('path')->like("%,{$objectID},%")->andWhere('end')->ne('0000-00-00')->orderBy('end_desc')->fetch('maxEnd');
|
||||
$minChildBegin = $this->project->getProgramMinBegin($objectID);
|
||||
$maxChildEnd = $this->project->getProgramMaxEnd($objectID);
|
||||
}
|
||||
}
|
||||
|
||||
/* Build the selected drop-down data. */
|
||||
$data = array();
|
||||
if(isset($selectedProgram))
|
||||
{
|
||||
$data['selectedProgramBegin'] = $selectedProgram->begin;
|
||||
$data['selectedProgramEnd'] = $selectedProgram->end;
|
||||
$data['budgetUnit'] = $selectedProgram->budgetUnit;
|
||||
$data['selectedProgramPath'] = explode(',', $selectedProgram->path);
|
||||
}
|
||||
|
||||
if($objectType == 'program')
|
||||
{
|
||||
$withProgram = $this->config->systemMode == 'ALM' ? true : false;
|
||||
$allProducts = array(0 => '') + $this->program->getProductPairs($selectedProgramID, 'all', 'noclosed', '', 0, $withProgram);
|
||||
$data['allProducts'] = html::select("products[]", $allProducts, '', "class='form-control chosen' onchange='loadBranches(this)'");
|
||||
$data['plans'] = html::select('plans[][][]', '', '', 'class=\'form-control chosen\' multiple');
|
||||
}
|
||||
$data = $this->projectZen->buildSelectForm($selectedProgramID, $selectedProgram);
|
||||
|
||||
/* Finish task #64882.Get the path of the last selected program. */
|
||||
if(!empty($objectID)) $data['objectPath'] = explode(',', $object->path);
|
||||
|
||||
@@ -3081,4 +3081,45 @@ class projectModel extends model
|
||||
|
||||
return !dao::isError();
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取项目集的最小开始时间
|
||||
* Get program min begin
|
||||
*
|
||||
* @param int $objectID
|
||||
*
|
||||
* @access public
|
||||
* @return object
|
||||
*/
|
||||
public function getProgramMinBegin(int $objectID): object
|
||||
{
|
||||
$a = $this->dao->select('`begin` as minBegin')->from(TABLE_PROGRAM)
|
||||
->where('id')->ne($objectID)
|
||||
->andWhere('deleted')->eq(0)
|
||||
->andWhere('path')->like("%,{$objectID},%")
|
||||
->orderBy('begin_asc')
|
||||
->fetch('minBegin');
|
||||
return $a;
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取项目集的最大结束时间
|
||||
* get program max end
|
||||
*
|
||||
* @param int $objectID
|
||||
*
|
||||
* @access public
|
||||
* @return object
|
||||
*/
|
||||
public function getProgramMaxEnd(int $objectID): object
|
||||
{
|
||||
return $this->dao->select('`end` as maxEnd')->from(TABLE_PROGRAM)
|
||||
->where('id')->ne($objectID)
|
||||
->andWhere('deleted')->eq(0)
|
||||
->andWhere('path')->like("%,{$objectID},%")
|
||||
->andWhere('end')->ne('0000-00-00')
|
||||
->orderBy('end_desc')
|
||||
->fetch('maxEnd');
|
||||
}
|
||||
}
|
||||
|
||||
+28
@@ -0,0 +1,28 @@
|
||||
#!/usr/bin/env php
|
||||
<?php
|
||||
include dirname(__FILE__, 5) . "/test/lib/init.php";
|
||||
su('admin');
|
||||
|
||||
$project = zdTable('project')->config('project')->gen(6);
|
||||
|
||||
/**
|
||||
|
||||
title=测试 projectModel->getProgramMaxEnd();
|
||||
cid=1
|
||||
pid=1
|
||||
*/
|
||||
|
||||
global $tester;
|
||||
|
||||
$tester->loadModel('project');
|
||||
$project1 = $tester->project->getProgramMaxEnd(1);
|
||||
$project2 = $tester->project->getProgramMaxEnd(3);
|
||||
$project3 = $tester->project->getProgramMaxEnd(6);
|
||||
|
||||
a($project1);die;
|
||||
r($project1) && p() && e(); //获取一级项目集最小开始时间
|
||||
r($project1) && p() && e(); //获取一级项目集最大结束时间
|
||||
r($project2) && p() && e(); //获取二级项目集最小开始时间
|
||||
r($project2) && p() && e(); //获取二级项目集最大结束时间
|
||||
r($project3) && p() && e(); //获取三级项目集最小开始时间
|
||||
r($project3) && p() && e(); //获取三级项目集最大结束时间
|
||||
@@ -0,0 +1,28 @@
|
||||
title: zt_project
|
||||
author: liuhong
|
||||
version: "1.0"
|
||||
fields:
|
||||
- field: id
|
||||
range: 1-6
|
||||
- field: project
|
||||
range: 0
|
||||
- field: model
|
||||
range: ', , ,scrum, ,scrum,scrum'
|
||||
- field: type
|
||||
range: 'program,program,project,program,project,project'
|
||||
- field: status
|
||||
range: 'wait,doing,closed,suspended'
|
||||
- field: parent
|
||||
range: 0, 1, 2, 0, 3, 0
|
||||
- field: grade
|
||||
range: 1, 2, 3, 1, 2, 1
|
||||
- field: path
|
||||
range: '`,1,`, `,1,2,`, `,1,2,3,`, `,4,`, `,4,5,`, `,6,`'
|
||||
- field: name
|
||||
range: '项目集1, 项目集1-1, 项目1-1-2, 项目集3, 项目3-4, 无迭代无产品项目6'
|
||||
- field: code
|
||||
range: 'program1, program1-1, project1-1-2, program3, project3-4, project6'
|
||||
- field: begin
|
||||
range: "'2023-05-01', '2023-05-07', '2023-05-20', '2023-04-04', '2023-05-01', '2023-05-08'"
|
||||
- field: end
|
||||
range: "'2023-06-01', '2023-05-19', '2023-06-12', '2023-07-03', '2023-06-03', '2023-05-08'"
|
||||
@@ -917,4 +917,35 @@ class projectZen extends project
|
||||
$this->project->setMenu($projectID);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 构建项目集下拉列表数据
|
||||
* build Select Form for program
|
||||
*
|
||||
* @param int $selectedProgramID
|
||||
* @param object $selectedProgram
|
||||
*
|
||||
* @access protected
|
||||
* @return array
|
||||
*/
|
||||
protected function buildSelectForm(int $selectedProgramID, object $selectedProgram): array
|
||||
{
|
||||
if(isset($selectedProgram))
|
||||
{
|
||||
$data['selectedProgramBegin'] = $selectedProgram->begin;
|
||||
$data['selectedProgramEnd'] = $selectedProgram->end;
|
||||
$data['budgetUnit'] = $selectedProgram->budgetUnit;
|
||||
$data['selectedProgramPath'] = explode(',', $selectedProgram->path);
|
||||
}
|
||||
|
||||
if($objectType == 'program')
|
||||
{
|
||||
$withProgram = $this->config->systemMode == 'ALM' ? true : false;
|
||||
$allProducts = array(0 => '') + $this->program->getProductPairs($selectedProgramID, 'all', 'noclosed', '', 0, $withProgram);
|
||||
$data['allProducts'] = html::select("products[]", $allProducts, '', "class='form-control chosen' onchange='loadBranches(this)'");
|
||||
$data['plans'] = html::select('plans[][][]', '', '', 'class=\'form-control chosen\' multiple');
|
||||
}
|
||||
|
||||
return $data;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user