This commit is contained in:
holan20180123
2020-08-25 09:40:17 +08:00
52 changed files with 920 additions and 285 deletions
+5 -2
View File
@@ -175,11 +175,14 @@ class program extends control
$this->send(array('result' => 'success', 'message' => $this->lang->saveSuccess, 'locate' => $url));
}
$parents = $this->program->getParentPairs();
unset($parents[$programID]);
$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->parents = $parents;
$this->view->groups = $this->loadModel('group')->getPairs();
$this->display();
}
@@ -694,7 +697,7 @@ class program extends control
public function ajaxGetDropMenu($programID, $module, $method, $extra)
{
$this->loadModel('project');
$this->view->link = $this->createLink('program', 'index', "programID=$programID");
$this->view->link = $this->createLink('program', 'index', "programID=$programID", '', '', $programID);
$this->view->programID = $programID;
$this->view->module = $module;
$this->view->method = $method;
+2
View File
@@ -112,3 +112,5 @@ $lang->program->cannotCreateChild = '该项目已经有实际的内容,无法
$lang->program->hasChildren = '该项目有子项目存在,不能删除。';
$lang->program->confirmDelete = "您确定删除项目[%s]吗?";
$lang->program->emptyPM = '暂无';
$lang->program->cannotChangeToCat = "该项目已经有实际的内容,无法修改为父项目";
$lang->program->cannotCancelCat = "该项目下已经有子项目,无法取消父项目标记";
+48 -11
View File
@@ -327,6 +327,11 @@ class programModel extends model
->get();
$program = $this->loadModel('file')->processImgURL($program, $this->config->program->editor->edit['id'], $this->post->uid);
if(!empty($program->isCat) and $this->checkHasContent($programID)) dao::$errors['isCat'] = $this->lang->program->cannotChangeToCat;
if(empty($program->isCat) and $this->checkHasChildren($programID)) dao::$errors['isCat'] = $this->lang->program->cannotCancelCat;
if(dao::isError()) return false;
$this->dao->update(TABLE_PROJECT)->data($program)
->autoCheck($skipFields = 'begin,end')
->batchcheck($this->config->program->edit->requiredFields, 'notempty')
@@ -397,6 +402,8 @@ class programModel extends model
{
$action = strtolower($action);
if(empty($program)) return true;
if($action == 'start') return $program->status == 'wait' or $program->status == 'suspended';
if($action == 'finish') return $program->status == 'wait' or $program->status == 'doing';
if($action == 'close') return $program->status != 'closed';
@@ -437,6 +444,19 @@ class programModel extends model
return $count > 0;
}
/**
* Check has children project.
*
* @param int $programID
* @access public
* @return bool
*/
public function checkHasChildren($programID)
{
$count = $this->dao->select('count(*) as count')->from(TABLE_PROJECT)->where('parent')->eq($programID)->fetch('count');
return $count > 0;
}
/**
* Set program tree path.
*
@@ -470,23 +490,40 @@ class programModel extends model
*/
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();
$modules = $this->dao->select('id,name,parent,path,grade')->from(TABLE_PROJECT)->where('isCat')->eq(1)->andWhere('deleted')->eq(0)->orderBy('grade desc, `order`')->fetchAll('id');
$pairs = array();
$pairs[0] = '/';
while($program = $stmt->fetch())
$treeMenu = array();
foreach($modules as $module)
{
if($program->grade == 1)
$moduleName = '/';
$parentModules = explode(',', $module->path);
foreach($parentModules as $parentModuleID)
{
$pairs[$program->id] = '/' . $program->name;
continue;
if(empty($parentModuleID)) continue;
if(empty($modules[$parentModuleID])) continue;
$moduleName .= $modules[$parentModuleID]->name . '/';
}
$moduleName = str_replace('|', '¦', rtrim($moduleName, '/'));
$moduleName .= "|$module->id\n";
$programName = '/' . $program->name;
$pairs[$program->id] = isset($pairs[$program->parent]) ? $pairs[$program->parent] . $programName : $programName;
if(!isset($treeMenu[$module->parent])) $treeMenu[$module->parent] = '';
$treeMenu[$module->parent] .= $moduleName;
if(isset($treeMenu[$module->id]) and !empty($treeMenu[$module->id])) $treeMenu[$module->parent] .= $treeMenu[$module->id];
}
return $pairs;
ksort($treeMenu);
$topMenu = array_shift($treeMenu);
$topMenu = explode("\n", trim($topMenu));
$lastMenu[] = '/';
foreach($topMenu as $menu)
{
if(strpos($menu, '|') === false) continue;
list($label, $moduleID) = explode('|', $menu);
$lastMenu[$moduleID] = str_replace('¦', '|', $label);
}
return $lastMenu;
}
/**
@@ -513,7 +550,7 @@ class programModel extends model
foreach($childNodes as $childNode)
{
$path = substr($childNode->path, strpos($childNode->path, ",{$programID},"));
$grade = $oldGrade - $childNode->grade + 1;
$grade = $childNode->grade - $oldGrade + 1;
if($parent)
{
$path = rtrim($parent->path, ',') . $path;
+1 -1
View File
@@ -2,7 +2,7 @@
<div class='row cell' id='cards'>
<?php foreach ($programs as $programID => $program):?>
<div class='col' data-id='<?php echo $programID?>'>
<div class='panel' data-url='<?php echo $this->createLink('program', 'index', "programID=$program->id");?>'>
<div class='panel' data-url='<?php echo $this->createLink('program', 'index', "programID=$program->id", '', '', $program->id);?>'>
<div class='panel-heading'>
<strong class='program-name' title='<?php echo $program->name;?>'><?php echo $program->name;?></strong>
<?php if($program->template === 'cmmi'): ?>
+1 -1
View File
@@ -28,7 +28,7 @@
</td>
<td class='text-left'><?php echo $program->code;?></td>
<td class='text-left pgm-title' title='<?php echo $program->name?>'>
<?php echo html::a(inlink('index', "programID=$program->id"), $program->name);?>
<?php echo html::a($this->createLink('program', 'index', "programID=$program->id", '', '', $program->id), $program->name);?>
</td>
<td class='c-status'><span class="status-program status-<?php echo $program->status?>"><?php echo zget($lang->project->statusList, $program->status, '');?></span></td>
<td class='text-center'><?php echo $program->begin;?></td>
+6 -1
View File
@@ -28,7 +28,12 @@
<tr>
<th class='w-120px'><?php echo $lang->program->name;?></th>
<td class="col-main"><?php echo html::input('name', $program->name, "class='form-control' required");?></td>
<td></td><td></td>
<td>
<div class="checkbox-primary">
<input type="checkbox" name="isCat" value="1" id="isCat" <?php if($program->isCat) echo "checked";?>>
<label for="isCat"><?php echo $lang->program->parent;?></label>
</div>
</td><td></td>
</tr>
<tr>
<th><?php echo $lang->program->code;?></th>