* finish task #7643,
This commit is contained in:
@@ -11,3 +11,8 @@ $config->program->editor->suspend = array('id' => 'comment', 'tools' => 'simple
|
||||
|
||||
$config->program->list = new stdclass();
|
||||
$config->program->list->exportFields = 'id,name,code,template,category,status,begin,end,budget,PM,end,desc';
|
||||
|
||||
$config->program->create = new stdclass();
|
||||
$config->program->edit = new stdclass();
|
||||
$config->program->create->requiredFields = 'name,code,begin,end';
|
||||
$config->program->edit->requiredFields = 'name,code,begin,end';
|
||||
|
||||
+15
-10
@@ -44,6 +44,8 @@ class program extends control
|
||||
{
|
||||
if(common::hasPriv('program', 'createGuide')) $this->lang->pageActions = html::a($this->createLink('program', 'createGuide'), "<i class='icon icon-sm icon-plus'></i> " . $this->lang->program->create, '', "class='btn btn-primary' data-toggle=modal");
|
||||
|
||||
$this->app->session->set('programList', $this->app->getURI(true));
|
||||
|
||||
$programType = $this->cookie->programType ? $this->cookie->programType : 'bylist';
|
||||
|
||||
$this->app->loadClass('pager', $static = true);
|
||||
@@ -155,30 +157,33 @@ class program extends control
|
||||
/**
|
||||
* Edit a program.
|
||||
*
|
||||
* @param int $projectID
|
||||
* @param int $programID
|
||||
* @access public
|
||||
* @return void
|
||||
*/
|
||||
public function edit($projectID = 0)
|
||||
public function edit($programID = 0)
|
||||
{
|
||||
$project = $this->project->getByID($projectID);
|
||||
$program = $this->project->getByID($programID);
|
||||
|
||||
if($_POST)
|
||||
{
|
||||
$changes = $this->project->update($projectID);
|
||||
$changes = $this->program->update($programID);
|
||||
if(dao::isError()) $this->send(array('result' => 'fail', 'message' => $this->processErrors(dao::getError())));
|
||||
if($changes)
|
||||
{
|
||||
$actionID = $this->loadModel('action')->create('project', $projectID, 'edited');
|
||||
$actionID = $this->loadModel('action')->create('program', $programID, 'edited');
|
||||
$this->action->logHistory($actionID, $changes);
|
||||
}
|
||||
$this->send(array('result' => 'success', 'message' => $this->lang->saveSuccess, 'locate' => inlink('browse')));
|
||||
|
||||
$url = $this->session->programList ? $this->session->programList : inlink('browse');
|
||||
$this->send(array('result' => 'success', 'message' => $this->lang->saveSuccess, 'locate' => $url));
|
||||
}
|
||||
|
||||
$this->view->pmUsers = $this->loadModel('user')->getPairs('noclosed|nodeleted|pmfirst', $project->PM);
|
||||
$this->view->title = $this->lang->project->edit;
|
||||
$this->view->position[] = $this->lang->project->edit;
|
||||
$this->view->project = $project;
|
||||
$this->view->pmUsers = $this->loadModel('user')->getPairs('noclosed|nodeleted|pmfirst', $program->PM);
|
||||
$this->view->title = $this->lang->program->edit;
|
||||
$this->view->position[] = $this->lang->program->edit;
|
||||
$this->view->program = $program;
|
||||
$this->view->parents = $this->program->getParentPairs();
|
||||
$this->view->groups = $this->loadModel('group')->getPairs();
|
||||
$this->display();
|
||||
}
|
||||
|
||||
+146
-4
@@ -75,7 +75,6 @@ class programModel extends model
|
||||
|
||||
public function create()
|
||||
{
|
||||
$this->lang->project->team = $this->lang->project->teamname;
|
||||
$project = fixer::input('post')
|
||||
->setDefault('status', 'wait')
|
||||
->add('type', 'program')
|
||||
@@ -85,14 +84,14 @@ class programModel extends model
|
||||
->setDefault('team', substr($this->post->name,0, 30))
|
||||
->join('whitelist', ',')
|
||||
->cleanInt('budget')
|
||||
->stripTags($this->config->project->editor->create['id'], $this->config->allowedTags)
|
||||
->stripTags($this->config->program->editor->create['id'], $this->config->allowedTags)
|
||||
->remove('products, workDays, delta, branch, uid, plans')
|
||||
->get();
|
||||
|
||||
$project = $this->loadModel('file')->processImgURL($project, $this->config->project->editor->create['id'], $this->post->uid);
|
||||
$project = $this->loadModel('file')->processImgURL($project, $this->config->program->editor->create['id'], $this->post->uid);
|
||||
$this->dao->insert(TABLE_PROJECT)->data($project)
|
||||
->autoCheck()
|
||||
->batchcheck($this->config->project->create->requiredFields, 'notempty')
|
||||
->batchcheck($this->config->program->create->requiredFields, 'notempty')
|
||||
->check('name', 'unique', "deleted='0'")
|
||||
->check('code', 'unique', "deleted='0'")
|
||||
->exec();
|
||||
@@ -156,6 +155,56 @@ class programModel extends model
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Update program.
|
||||
*
|
||||
* @param int $programID
|
||||
* @access public
|
||||
* @return array
|
||||
*/
|
||||
public function update($programID)
|
||||
{
|
||||
$programID = (int)$programID;
|
||||
$oldProgram = $this->dao->findById($programID)->from(TABLE_PROJECT)->fetch();
|
||||
|
||||
$program = fixer::input('post')
|
||||
->setIF($this->post->begin == '0000-00-00', 'begin', '')
|
||||
->setIF($this->post->end == '0000-00-00', 'end', '')
|
||||
->setIF($this->post->acl != 'custom', 'whitelist', '')
|
||||
->setIF($this->post->acl == 'custom' and !isset($_POST['whitelist']), 'whitelist', '')
|
||||
->setDefault('team', $this->post->name)
|
||||
->join('whitelist', ',')
|
||||
->stripTags($this->config->program->editor->edit['id'], $this->config->allowedTags)
|
||||
->remove('products, branch, uid, plans')
|
||||
->get();
|
||||
$program = $this->loadModel('file')->processImgURL($program, $this->config->program->editor->edit['id'], $this->post->uid);
|
||||
|
||||
$this->dao->update(TABLE_PROJECT)->data($program)
|
||||
->autoCheck($skipFields = 'begin,end')
|
||||
->batchcheck($this->config->program->edit->requiredFields, 'notempty')
|
||||
->checkIF($program->begin != '', 'begin', 'date')
|
||||
->checkIF($program->end != '', 'end', 'date')
|
||||
->checkIF($program->end != '', 'end', 'gt', $program->begin)
|
||||
->check('name', 'unique', "id!=$programID and deleted='0'")
|
||||
->check('code', 'unique', "id!=$programID and deleted='0'")
|
||||
->where('id')->eq($programID)
|
||||
->limit(1)
|
||||
->exec();
|
||||
|
||||
if(!dao::isError())
|
||||
{
|
||||
$this->file->updateObjectID($this->post->uid, $programID, 'project');
|
||||
if($program->acl != 'open' and ($program->acl != $oldProject->acl or $program->whitelist != $oldProgram->whitelist))
|
||||
{
|
||||
$this->loadModel('user')->updateUserView($programID, 'program');
|
||||
}
|
||||
|
||||
if($oldProgram->parent != $program->parent) $this->moveNode($programID, $program->parent, $oldProgram->path, $oldProgram->grade);
|
||||
|
||||
return common::createChanges($oldProgram, $program);
|
||||
}
|
||||
}
|
||||
|
||||
public function getSwapper($programs, $programID, $currentModule, $currentMethod, $extra = '')
|
||||
{
|
||||
$this->loadModel('project');
|
||||
@@ -177,6 +226,14 @@ class programModel extends model
|
||||
return $output;
|
||||
}
|
||||
|
||||
/**
|
||||
* Judge an action is clickable or not.
|
||||
*
|
||||
* @param object $project
|
||||
* @param string $action
|
||||
* @access public
|
||||
* @return bool
|
||||
*/
|
||||
public static function isClickable($project, $action)
|
||||
{
|
||||
$action = strtolower($action);
|
||||
@@ -190,11 +247,25 @@ class programModel extends model
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get program products
|
||||
*
|
||||
* @param int $program
|
||||
* @access public
|
||||
* @return array
|
||||
*/
|
||||
public function getProducts($program)
|
||||
{
|
||||
return $this->dao->select('*')->from(TABLE_PRODUCT)->where('project')->eq($program)->fetchAll('id');
|
||||
}
|
||||
|
||||
/**
|
||||
* Check has content for program
|
||||
*
|
||||
* @param int $programID
|
||||
* @access public
|
||||
* @return bool
|
||||
*/
|
||||
public function checkHasContent($programID)
|
||||
{
|
||||
$count = 0;
|
||||
@@ -219,6 +290,13 @@ class programModel extends model
|
||||
return $count > 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set program tree path.
|
||||
*
|
||||
* @param int $programID
|
||||
* @access public
|
||||
* @return bool
|
||||
*/
|
||||
public function setTreePath($programID)
|
||||
{
|
||||
$program = $this->dao->select('*')->from(TABLE_PROJECT)->where('id')->eq($programID)->fetch();
|
||||
@@ -234,5 +312,69 @@ class programModel extends model
|
||||
$path['grade'] = $parent->grade + 1;
|
||||
}
|
||||
$this->dao->update(TABLE_PROJECT)->set('path')->eq($path['path'])->set('grade')->eq($path['grade'])->where('id')->eq($program->id)->exec();
|
||||
return !dao::isError();
|
||||
}
|
||||
|
||||
/**
|
||||
* Get program parent pairs
|
||||
*
|
||||
* @access public
|
||||
* @return array
|
||||
*/
|
||||
public function getParentPairs()
|
||||
{
|
||||
$stmt = $this->dao->select('id,name,parent,path,grade')->from(TABLE_PROJECT)->where('isCat')->eq(1)->andWhere('deleted')->eq(0)->orderBy('grade, `order`')->query();
|
||||
|
||||
$pairs = array();
|
||||
$pairs[0] = '/';
|
||||
while($program = $stmt->fetch())
|
||||
{
|
||||
if($program->grade == 1)
|
||||
{
|
||||
$pairs[$program->id] = '/' . $program->name;
|
||||
continue;
|
||||
}
|
||||
|
||||
$programName = '/' . $program->name;
|
||||
$pairs[$program->id] = isset($pairs[$program->parent]) ? $pairs[$program->parent] . $programName : $programName;
|
||||
}
|
||||
|
||||
return $pairs;
|
||||
}
|
||||
|
||||
/**
|
||||
* Move project node.
|
||||
*
|
||||
* @param int $programID
|
||||
* @param int $parentID
|
||||
* @param string $oldPath
|
||||
* @param int $oldGrade
|
||||
* @access public
|
||||
* @return bool
|
||||
*/
|
||||
public function moveNode($programID, $parentID, $oldPath, $oldGrade)
|
||||
{
|
||||
$parent = $this->dao->select('id,parent,path,grade')->from(TABLE_PROJECT)->where('id')->eq($parentID)->fetch();
|
||||
|
||||
$childNodes = $this->dao->select('id,parent,path,grade')->from(TABLE_PROJECT)
|
||||
->where('path')->like("{$oldPath}%")
|
||||
->andWhere('deleted')->eq(0)
|
||||
->andWhere('template')->ne('')
|
||||
->orderBy('grade')
|
||||
->fetchAll();
|
||||
/* Process child node path and grade field. */
|
||||
foreach($childNodes as $childNode)
|
||||
{
|
||||
$path = substr($childNode->path, strpos($childNode->path, ",{$programID},"));
|
||||
$grade = $oldGrade - $childNode->grade + 1;
|
||||
if($parent)
|
||||
{
|
||||
$path = rtrim($parent->path, ',') . $path;
|
||||
$grade = $parent->grade + $grade;
|
||||
}
|
||||
$this->dao->update(TABLE_PROJECT)->set('path')->eq($path)->set('grade')->eq($grade)->where('id')->eq($childNode->id)->exec();
|
||||
}
|
||||
|
||||
return !dao::isError();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,11 +1,11 @@
|
||||
<?php
|
||||
/**
|
||||
* The create view of project module of ZenTaoPMS.
|
||||
* The edit view of program module of ZenTaoPMS.
|
||||
*
|
||||
* @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 project
|
||||
* @package program
|
||||
* @version $Id: create.html.php 4728 2013-05-03 06:14:34Z chencongzhi520@gmail.com $
|
||||
* @link http://www.zentao.net
|
||||
*/
|
||||
@@ -20,47 +20,52 @@
|
||||
</div>
|
||||
<form class='form-indicator main-form form-ajax' method='post' target='hiddenwin' id='dataform'>
|
||||
<table class='table table-form'>
|
||||
<tr>
|
||||
<th class='w-120px'><?php echo $lang->program->parent;?></th>
|
||||
<td class="col-main"><?php echo html::select('parent', $parents, $program->parent, "class='form-control chosen'");?></td>
|
||||
<td></td><td></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th class='w-120px'><?php echo $lang->program->name;?></th>
|
||||
<td class="col-main"><?php echo html::input('name', $project->name, "class='form-control' required");?></td>
|
||||
<td class="col-main"><?php echo html::input('name', $program->name, "class='form-control' required");?></td>
|
||||
<td></td><td></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th><?php echo $lang->program->code;?></th>
|
||||
<td><?php echo html::input('code', $project->code, "class='form-control' required");?></td><td></td><td></td>
|
||||
<td><?php echo html::input('code', $program->code, "class='form-control' required");?></td><td></td><td></td>
|
||||
</tr>
|
||||
<?php if($project->template == 'cmmi'):?>
|
||||
<?php if($program->template == 'cmmi'):?>
|
||||
<tr>
|
||||
<th><?php echo $lang->program->category;?></th>
|
||||
<td><?php echo html::select('category', $lang->program->categoryList, $project->category, "class='form-control'");?></td><td></td><td></td>
|
||||
<td><?php echo html::select('category', $lang->program->categoryList, $program->category, "class='form-control'");?></td><td></td><td></td>
|
||||
</tr>
|
||||
<?php endif;?>
|
||||
<tr>
|
||||
<th><?php echo $lang->program->PM;?></th>
|
||||
<td><?php echo html::select('PM', $pmUsers, $project->PM, "class='form-control chosen'");?></td>
|
||||
<td><?php echo html::select('PM', $pmUsers, $program->PM, "class='form-control chosen'");?></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th><?php echo $lang->program->budget;?></th>
|
||||
<td><?php echo html::input('budget', $project->budget, "class='form-control'");?></td>
|
||||
<td style='float:left'><?php echo html::select('budgetUnit', $lang->program->unitList, $project->budgetUnit, "class='form-control'");?></td><td></td>
|
||||
<td><?php echo html::input('budget', $program->budget, "class='form-control'");?></td>
|
||||
<td style='float:left'><?php echo html::select('budgetUnit', $lang->program->unitList, $program->budgetUnit, "class='form-control'");?></td><td></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th><?php echo $lang->program->dateRange;?></th>
|
||||
<td>
|
||||
<div class='input-group'>
|
||||
<?php echo html::input('begin', $project->begin, "class='form-control form-date' onchange='computeWorkDays();' placeholder='" . $lang->program->begin . "' required");?>
|
||||
<?php echo html::input('begin', $program->begin, "class='form-control form-date' onchange='computeWorkDays();' placeholder='" . $lang->program->begin . "' required");?>
|
||||
<span class='input-group-addon'><?php echo $lang->program->to;?></span>
|
||||
<?php echo html::input('end', $project->end, "class='form-control form-date' onchange='computeWorkDays();' placeholder='" . $lang->program->end . "' required");?>
|
||||
<?php echo html::input('end', $program->end, "class='form-control form-date' onchange='computeWorkDays();' placeholder='" . $lang->program->end . "' required");?>
|
||||
</div>
|
||||
</td>
|
||||
<td colspan='2'></td>
|
||||
</tr>
|
||||
<?php if($project->template == 'scrum'):?>
|
||||
<?php if($program->template == 'scrum'):?>
|
||||
<tr>
|
||||
<th><?php echo $lang->project->days;?></th>
|
||||
<td>
|
||||
<div class='input-group'>
|
||||
<?php echo html::input('days', $project->days, "class='form-control'");?>
|
||||
<?php echo html::input('days', $program->days, "class='form-control'");?>
|
||||
<span class='input-group-addon'><?php echo $lang->project->day;?></span>
|
||||
</div>
|
||||
</td><td></td><td></td>
|
||||
@@ -68,30 +73,30 @@
|
||||
<?php endif;?>
|
||||
<tr>
|
||||
<th><?php echo $lang->program->realStarted;?></th>
|
||||
<td><?php echo html::input('realStarted', $project->realStarted, "class='form-control form-date'");?></td><td></td><td></td>
|
||||
<td><?php echo html::input('realStarted', $program->realStarted, "class='form-control form-date'");?></td><td></td><td></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th><?php echo $lang->project->teamname;?></th>
|
||||
<td><?php echo html::input('team', $project->team, "class='form-control'");?></td><td></td><td></td>
|
||||
<td><?php echo html::input('team', $program->team, "class='form-control'");?></td><td></td><td></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th><?php echo $lang->program->desc;?></th>
|
||||
<td colspan='3'>
|
||||
<?php echo $this->fetch('user', 'ajaxPrintTemplates', 'type=project&link=desc');?>
|
||||
<?php echo html::textarea('desc', $project->desc, "rows='6' class='form-control kindeditor' hidefocus='true'");?>
|
||||
<?php echo $this->fetch('user', 'ajaxPrintTemplates', 'type=program&link=desc');?>
|
||||
<?php echo html::textarea('desc', $program->desc, "rows='6' class='form-control kindeditor' hidefocus='true'");?>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th><?php echo $lang->program->privway;?></th>
|
||||
<td colspan='3'><?php echo html::radio('privway', $lang->program->privwayList, $project->privway, '', 'block');?></td>
|
||||
<td colspan='3'><?php echo html::radio('privway', $lang->program->privwayList, $program->privway, '', 'block');?></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th><?php echo $lang->project->acl;?></th>
|
||||
<td colspan='3'><?php echo nl2br(html::radio('acl', $lang->program->aclList, $project->acl, "onclick='setWhite(this.value);'", 'block'));?></td>
|
||||
<td colspan='3'><?php echo nl2br(html::radio('acl', $lang->program->aclList, $program->acl, "onclick='setWhite(this.value);'", 'block'));?></td>
|
||||
</tr>
|
||||
<tr id='whitelistBox' <?php if($project->acl != 'custom') echo "class='hidden'";?>>
|
||||
<tr id='whitelistBox' <?php if($program->acl != 'custom') echo "class='hidden'";?>>
|
||||
<th><?php echo $lang->project->whitelist;?></th>
|
||||
<td colspan='3'><?php echo html::checkbox('whitelist', $groups, $project->whitelist, '', '', 'inline');?></td>
|
||||
<td colspan='3'><?php echo html::checkbox('whitelist', $groups, $program->whitelist, '', '', 'inline');?></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td colspan='4' class='text-center form-actions'>
|
||||
|
||||
Reference in New Issue
Block a user