* Add risk browse method.
This commit is contained in:
@@ -197,7 +197,7 @@ if(!defined('TABLE_LANG')) define('TABLE_LANG', '`' . $config->db->prefix
|
||||
if(!defined('TABLE_STAGE')) define('TABLE_STAGE', '`' . $config->db->prefix . 'stage`');
|
||||
if(!defined('TABLE_DESIGN')) define('TABLE_DESIGN', '`' . $config->db->prefix . 'design`');
|
||||
if(!defined('TABLE_DESIGNSPEC')) define('TABLE_DESIGNSPEC', '`' . $config->db->prefix . 'designspec`');
|
||||
if(!defined('TABLE_RISK')) define('TABLE_DESIGN', '`' . $config->db->prefix . 'risk`');
|
||||
if(!defined('TABLE_RISK')) define('TABLE_RISK', '`' . $config->db->prefix . 'risk`');
|
||||
|
||||
$config->objectTables['product'] = TABLE_PRODUCT;
|
||||
$config->objectTables['story'] = TABLE_STORY;
|
||||
|
||||
@@ -0,0 +1,6 @@
|
||||
<?php
|
||||
$config->risk->editor = new stdclass();
|
||||
$config->risk->editor->create = array('id' => 'prevention,remedy', 'tools' => 'simpleTools');
|
||||
|
||||
$config->risk->create = new stdclass();
|
||||
$config->risk->create->requiredFields = 'name';
|
||||
+35
-1
@@ -1,13 +1,47 @@
|
||||
<?php
|
||||
class risk extends control
|
||||
{
|
||||
public function browse()
|
||||
public function browse($orderBy = 'id_desc', $recTotal = 0, $recPerPage = 20, $pageID = 1)
|
||||
{
|
||||
/* Load pager. */
|
||||
$this->app->loadClass('pager', $static = true);
|
||||
if($this->app->getViewType() == 'mhtml') $recPerPage = 10;
|
||||
$pager = pager::init($recTotal, $recPerPage, $pageID);
|
||||
|
||||
$this->view->title = $this->lang->risk->common . $this->lang->colon . $this->lang->risk->browse;
|
||||
$this->view->position[] = $this->lang->risk->browse;
|
||||
$this->view->risks = $this->risk->getList($orderBy, $pager);
|
||||
$this->view->orderBy = $orderBy;
|
||||
$this->view->pager = $pager;
|
||||
$this->view->users = $this->loadModel('user')->getPairs('noletter');
|
||||
|
||||
$this->display();
|
||||
}
|
||||
|
||||
public function create()
|
||||
{
|
||||
if($_POST)
|
||||
{
|
||||
$riskID = $this->risk->create();
|
||||
|
||||
$response['result'] = 'success';
|
||||
$response['message'] = $this->lang->saveSuccess;
|
||||
if(!$riskID)
|
||||
{
|
||||
$response['result'] = 'fail';
|
||||
$response['message'] = dao::getError();
|
||||
$this->send($response);
|
||||
}
|
||||
|
||||
$this->loadModel('action')->create('risk', $riskID, 'Opened');
|
||||
$response['locate'] = inlink('browse');
|
||||
$this->send($response);
|
||||
}
|
||||
|
||||
$this->view->users = $this->loadModel('user')->getPairs();
|
||||
$this->view->title = $this->lang->risk->common . $this->lang->colon . $this->lang->risk->create;
|
||||
$this->view->position[] = $this->lang->risk->create;
|
||||
|
||||
$this->display();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -5,17 +5,66 @@ $lang->risk->create = '添加风险';
|
||||
$lang->risk->browse = '浏览列表';
|
||||
|
||||
/* Fields */
|
||||
$lang->risk->common = '风险';
|
||||
$lang->risk->source = '来源';
|
||||
$lang->risk->id = '编号';
|
||||
$lang->risk->name = '风险名称';
|
||||
$lang->risk->category = '类型';
|
||||
$lang->risk->strategy = '策略';
|
||||
$lang->risk->status = '状态';
|
||||
$lang->risk->impact = '影响程度';
|
||||
$lang->risk->probability = '发生概率';
|
||||
$lang->risk->riskindex = '风险系数';
|
||||
$lang->risk->pri = '优先级';
|
||||
$lang->risk->prevention = '处理措施';
|
||||
$lang->risk->remedy = '应急措施';
|
||||
$lang->risk->identifiedDate = '识别日期';
|
||||
$lang->risk->plannedClosedDate = '计划关闭日期';
|
||||
$lang->risk->assignedTo = '指派给';
|
||||
$lang->risk->createdBy = '由谁创建';
|
||||
$lang->risk->createdDate = '创建日期';
|
||||
|
||||
$lang->risk->sourceList[''] = '';
|
||||
$lang->risk->sourceList['business'] = '业务部门';
|
||||
$lang->risk->sourceList['team'] = '项目组';
|
||||
$lang->risk->sourceList['logistic'] = '项目保障科室';
|
||||
$lang->risk->sourceList['manage'] = '管理层';
|
||||
$lang->risk->sourceList['sourcing'] = '供应商-采购';
|
||||
$lang->risk->sourceList['outsourcing'] = '供应商-外包';
|
||||
$lang->risk->sourceList['customer'] = '外部客户';
|
||||
$lang->risk->sourceList['others'] = '其他';
|
||||
|
||||
$lang->risk->categoryList[''] = '';
|
||||
$lang->risk->categoryList['technical'] = '技术类';
|
||||
$lang->risk->categoryList['manage'] = '管理类';
|
||||
$lang->risk->categoryList['business'] = '业务类';
|
||||
$lang->risk->categoryList['requirement'] = '需求类';
|
||||
$lang->risk->categoryList['resource'] = '资源类';
|
||||
$lang->risk->categoryList['others'] = '其他';
|
||||
|
||||
$lang->risk->impactList[1] = 1;
|
||||
$lang->risk->impactList[2] = 2;
|
||||
$lang->risk->impactList[3] = 3;
|
||||
$lang->risk->impactList[4] = 4;
|
||||
$lang->risk->impactList[5] = 5;
|
||||
|
||||
$lang->risk->probabilityList[1] = 1;
|
||||
$lang->risk->probabilityList[2] = 2;
|
||||
$lang->risk->probabilityList[3] = 3;
|
||||
$lang->risk->probabilityList[4] = 4;
|
||||
$lang->risk->probabilityList[5] = 5;
|
||||
|
||||
$lang->risk->priList['high'] = '高';
|
||||
$lang->risk->priList['middle'] = '中';
|
||||
$lang->risk->priList['low'] = '低';
|
||||
|
||||
$lang->risk->statusList['active'] = '开放';
|
||||
$lang->risk->statusList['closed'] = '关闭';
|
||||
$lang->risk->statusList['hangup'] = '挂起';
|
||||
$lang->risk->statusList['canceled'] = '取消';
|
||||
|
||||
$lang->risk->strategyList[''] = '';
|
||||
$lang->risk->strategyList['avoidance'] = '规避';
|
||||
$lang->risk->strategyList['mitigation'] = '缓解';
|
||||
$lang->risk->strategyList['transference'] = '转移';
|
||||
$lang->risk->strategyList['acceptance'] = '接受';
|
||||
|
||||
@@ -0,0 +1,83 @@
|
||||
<?php
|
||||
class riskModel extends model
|
||||
{
|
||||
public function create()
|
||||
{
|
||||
$risk = fixer::input('post')
|
||||
->add('program', $this->session->program)
|
||||
->add('createdBy', $this->app->user->account)
|
||||
->add('createdDate', helper::today())
|
||||
->stripTags($this->config->risk->editor->create['id'], $this->config->allowedTags)
|
||||
->remove('uid')
|
||||
->get();
|
||||
|
||||
$risk = $this->loadModel('file')->processImgURL($risk, $this->config->risk->editor->create['id'], $this->post->uid);
|
||||
$this->dao->insert(TABLE_RISK)->data($risk)->autoCheck()->batchCheck($this->config->risk->create->requiredFields, 'notempty')->exec();
|
||||
|
||||
if(!dao::isError()) return $this->dao->lastInsertID();
|
||||
return false;
|
||||
}
|
||||
|
||||
public function batchCreate()
|
||||
{
|
||||
$data = fixer::input('post')->get();
|
||||
|
||||
$this->loadModel('action');
|
||||
foreach($data->name as $i => $name)
|
||||
{
|
||||
if(!$name) continue;
|
||||
|
||||
$risk = new stdclass();
|
||||
$risk->name = $name;
|
||||
$risk->percent = $data->percent[$i];
|
||||
$risk->type = $data->type[$i];
|
||||
$risk->createdBy = $this->app->user->account;
|
||||
$risk->createdDate = helper::today();
|
||||
|
||||
$this->dao->insert(TABLE_RISK)->data($risk)->autoCheck()->exec();
|
||||
|
||||
$riskID = $this->dao->lastInsertID();
|
||||
$this->action->create('risk', $riskID, 'Opened');
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
public function update($riskID)
|
||||
{
|
||||
$oldStage = $this->dao->select('*')->from(TABLE_RISK)->where('id')->eq((int)$riskID)->fetch();
|
||||
|
||||
$risk = fixer::input('post')
|
||||
->add('editedBy', $this->app->user->account)
|
||||
->add('editedDate', helper::today())
|
||||
->get();
|
||||
|
||||
$this->dao->update(TABLE_RISK)->data($risk)->autoCheck()->where('id')->eq((int)$riskID)->exec();
|
||||
|
||||
if(!dao::isError()) return common::createChanges($oldStage, $risk);
|
||||
return false;
|
||||
}
|
||||
|
||||
public function getList($orderBy = 'id_desc', $pager = null)
|
||||
{
|
||||
return $this->dao->select('*')->from(TABLE_RISK)
|
||||
->where('deleted')->eq(0)
|
||||
->andWhere('program')->eq($this->session->program)
|
||||
->orderBy($orderBy)
|
||||
->page($pager)
|
||||
->fetchAll('id');
|
||||
}
|
||||
|
||||
public function getPairs()
|
||||
{
|
||||
return $this->dao->select('id, name')->from(TABLE_RISK)
|
||||
->where('deleted')->eq(0)
|
||||
->andWhere('program')->eq($this->session->program)
|
||||
->fetchPairs();
|
||||
}
|
||||
|
||||
public function getByID($riskID)
|
||||
{
|
||||
return $this->dao->select('*')->from(TABLE_RISK)->where('id')->eq((int)$riskID)->fetch();
|
||||
}
|
||||
}
|
||||
@@ -9,5 +9,52 @@
|
||||
<?php common::printLink('risk', 'create', "", "<i class='icon icon-plus'></i>" . $lang->risk->create, '', "class='btn btn-primary'");?>
|
||||
</div>
|
||||
</div>
|
||||
<div id="mainContent" class="main-table">
|
||||
<?php if(empty($risks)):?>
|
||||
<div class="table-empty-tip">
|
||||
<p>
|
||||
<span class="text-muted"><?php echo $lang->noData;?></span>
|
||||
<?php if(common::hasPriv('risk', 'create')):?>
|
||||
<?php echo html::a($this->createLink('risk', 'create'), "<i class='icon icon-plus'></i> " . $lang->risk->create, '', "class='btn btn-info'");?>
|
||||
<?php endif;?>
|
||||
</p>
|
||||
</div>
|
||||
<?php else:?>
|
||||
<table class="table has-sort-head" id='riskList'>
|
||||
<?php $vars = "orderBy=%s&recTotal={$pager->recTotal}&recPerPage={$pager->recPerPage}";?>
|
||||
<thead>
|
||||
<tr>
|
||||
<th class='text-left w-60px'><?php common::printOrderLink('id', $orderBy, $vars, $lang->risk->id);?></th>
|
||||
<th class='text-left'><?php common::printOrderLink('name', $orderBy, $vars, $lang->risk->name);?></th>
|
||||
<th class='w-100px'><?php common::printOrderLink('strategy', $orderBy, $vars, $lang->risk->strategy);?></th>
|
||||
<th class='w-120px'><?php common::printOrderLink('status', $orderBy, $vars, $lang->risk->status);?></th>
|
||||
<th class='w-120px'><?php common::printOrderLink('identifiedDate', $orderBy, $vars, $lang->risk->identifiedDate);?></th>
|
||||
<th class='w-100px'><?php common::printOrderLink('riskindex', $orderBy, $vars, $lang->risk->riskindex);?></th>
|
||||
<th class='w-100px'><?php common::printOrderLink('pri', $orderBy, $vars, $lang->risk->pri);?></th>
|
||||
<th class='w-120px'><?php common::printOrderLink('assignedTo', $orderBy, $vars, $lang->risk->assignedTo);?></th>
|
||||
<th class='w-120px'><?php common::printOrderLink('category', $orderBy, $vars, $lang->risk->category);?></th>
|
||||
<th class='w-120px'><?php echo $lang->actions;?></th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
<?php foreach($risks as $risk):?>
|
||||
<tr>
|
||||
<td><?php echo printf('%03d', $risk->id);?></td>
|
||||
<td><?php echo $risk->name;?></td>
|
||||
<td><?php echo zget($lang->risk->strategyList, $risk->strategy);?></td>
|
||||
<td><?php echo zget($lang->risk->statusList, $risk->status);?></td>
|
||||
<td><?php echo $risk->identifiedDate;?></td>
|
||||
<td><?php echo $risk->riskindex;?></td>
|
||||
<td><?php echo zget($lang->risk->priList, $risk->pri)?></td>
|
||||
<td><?php echo zget($users, $risk->assignedTo);?></td>
|
||||
<td><?php echo zget($lang->risk->categoryList, $risk->category);?></td>
|
||||
<td></td>
|
||||
</tr>
|
||||
<?php endforeach;?>
|
||||
</tbody>
|
||||
</table>
|
||||
<div class='table-footer'>
|
||||
</div>
|
||||
<?php endif;?>
|
||||
</div>
|
||||
<?php include "../../common/view/footer.html.php"?>
|
||||
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
<?php include '../../common/view/header.html.php';?>
|
||||
<?php include '../../common/view/kindeditor.html.php';?>
|
||||
<div id="mainContent" class="main-content fade">
|
||||
<div class="center-block">
|
||||
<div class="main-header">
|
||||
@@ -7,28 +8,57 @@
|
||||
<form class="load-indicator main-form form-ajax" method='post' enctype='multipart/form-data' id='dataform'>
|
||||
<table class="table table-form">
|
||||
<tbody>
|
||||
<tr>
|
||||
<th><?php echo $lang->risk->source;?></th>
|
||||
<td><?php echo html::select('source', $lang->risk->sourceList, '', "class='form-control chosen'");?></td>
|
||||
<td></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th><?php echo $lang->risk->name;?></th>
|
||||
<td><?php echo html::input('name', '', "class='form-control'");?></td>
|
||||
<td></td>
|
||||
<td></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th><?php echo $lang->risk->percent;?></th>
|
||||
<td>
|
||||
<div class='input-group'>
|
||||
<?php echo html::input('percent', '', "class='form-control'");?>
|
||||
<span class='input-group-addon'>%</span>
|
||||
</div>
|
||||
</td>
|
||||
<th><?php echo $lang->risk->category;?></th>
|
||||
<td><?php echo html::select('category', $lang->risk->categoryList, '', "class='form-control chosen'");?></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th><?php echo $lang->risk->type;?></th>
|
||||
<td><?php echo html::select('type', $lang->risk->typeList, '', "class='form-control chosen'");?></td>
|
||||
<th><?php echo $lang->risk->strategy;?></th>
|
||||
<td><?php echo html::select('strategy', $lang->risk->strategyList, '', "class='form-control chosen'");?></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td></td>
|
||||
<td colspan='3' class='form-actions'>
|
||||
<th><?php echo $lang->risk->impact;?></th>
|
||||
<td><?php echo html::select('impact', $lang->risk->impactList, 3, "class='form-control chosen'");?></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th><?php echo $lang->risk->probability;?></th>
|
||||
<td><?php echo html::select('probability', $lang->risk->probabilityList, 3, "class='form-control chosen'");?></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th><?php echo $lang->risk->riskindex;?></th>
|
||||
<td><?php echo html::input('riskindex', '', "class='form-control'");?></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th><?php echo $lang->risk->pri;?></th>
|
||||
<td><?php echo html::select('pri', $lang->risk->priList, '', "class='form-control chosen'");?></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th><?php echo $lang->risk->plannedClosedDate;?></th>
|
||||
<td><?php echo html::input('plannedClosedDate', '', "class='form-control form-date'");?></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th><?php echo $lang->risk->assignedTo;?></th>
|
||||
<td><?php echo html::select('assignedTo', $users, '', "class='form-control chosen'");?></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th><?php echo $lang->risk->prevention;?></th>
|
||||
<td colspan='2'><?php echo html::textarea('prevention', '', "class='form-control'");?></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th><?php echo $lang->risk->remedy;?></th>
|
||||
<td colspan='2'><?php echo html::textarea('remedy', '', "class='form-control'");?></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td colspan='3' class='form-actions text-center'>
|
||||
<?php echo html::submitButton() . html::backButton();?>
|
||||
</td>
|
||||
</tr>
|
||||
|
||||
Reference in New Issue
Block a user