增加了ajax存草稿的功能,增加了评审意见发布的逻辑判断和评审意见列表的逻辑判断

This commit is contained in:
Li Jianxuan 2011-10-31 03:10:26 +00:00
parent 2789ecb9b2
commit b148db6d60
2 changed files with 207 additions and 73 deletions

View File

@ -138,10 +138,10 @@ class ReviewController extends Zend_Controller_Action
{ {
$user = $auth->getIdentity(); $user = $auth->getIdentity();
$userid = $user->id; $userid = $user->id;
$sql = "select id from mdreview where userid='$userid' and uuid='$uuid'"; $sql = "select * from mdreview where userid='$userid' and uuid='$uuid'";
$rs = $this->db->query($sql); $rs = $this->db->query($sql);
$row = $rs->fetch(); $row = $rs->fetch();
$this->view->pms = $row['id']; $this->view->review = $row;
} }
$submit = $this->_request->getParam('submit'); $submit = $this->_request->getParam('submit');
@ -171,10 +171,10 @@ class ReviewController extends Zend_Controller_Action
{ {
$user = $auth->getIdentity(); $user = $auth->getIdentity();
$userid = $user->id; $userid = $user->id;
$sql = "select id,userid from mdreview where userid='$userid' and uuid='$uuid'"; $sql = "select id,userid,status from mdreview where userid='$userid' and uuid='$uuid'";
$rs = $this->db->query($sql); $rs = $this->db->query($sql);
$row = $rs->fetch(); $row = $rs->fetch();
if($row['id']!='') if($row['id']!='' && $row['status']>-1)
{ {
$this->messenger->addMessage('您已经对该元数据发表过评审了'); $this->messenger->addMessage('您已经对该元数据发表过评审了');
$this->_redirect($redirectlink); $this->_redirect($redirectlink);
@ -226,6 +226,17 @@ class ReviewController extends Zend_Controller_Action
try{ try{
if($row['status']<0)
{
$sql = "delete from mdreview where id='{$row['id']}'";
if($this->db->exec($sql)<1)
{
$this->messenger->addMessage('处理出错,请重试');
@unlink($filename);
$this->_redirect($redirectlink);
}
}
$data = array( $data = array(
'userid' => $userid, 'userid' => $userid,
'uuid' => $uuid, 'uuid' => $uuid,
@ -289,7 +300,7 @@ class ReviewController extends Zend_Controller_Action
$sql = "select r.uuid,r.userid,r.ts_created,u.realname,r.mdcomment,r.conclusion from mdreview r $sql = "select r.uuid,r.userid,r.ts_created,u.realname,r.mdcomment,r.conclusion from mdreview r
left join users u on u.id=r.userid left join users u on u.id=r.userid
where r.uuid='$uuid'"; where r.uuid='$uuid' and r.status>-1";
$rs = $this->db->query($sql); $rs = $this->db->query($sql);
$rows = $rs->fetchAll(); $rows = $rs->fetchAll();
@ -329,7 +340,121 @@ class ReviewController extends Zend_Controller_Action
$this->_helper->layout->disableLayout(); $this->_helper->layout->disableLayout();
$this->_helper->viewRenderer->setNoRender(); $this->_helper->viewRenderer->setNoRender();
echo "保存成功!"; $conclusion = $this->_request->getParam('conclusion');
$mdcomment = $this->replace(trim($this->_request->getParam('mdcomment')));
$datacomment = $this->replace(trim($this->_request->getParam('datacomment')));
$editorcomment = $this->replace(trim($this->_request->getParam('editorcomment')));
$uuid = $this->_request->getParam('uuid');
$sql=$this->db->quoteInto("select m.id,m.uuid,m.title,m.description,m.title_en,r.status from metadata m
left join mdstatus r on r.uuid=m.uuid
where m.uuid=?",$uuid);
$md = $this->db->fetchRow($sql);
if($md['status']>4)
{
echo '<div class="box box-info">该数据已经通过评审,不能再发表评审意见,如需提交问题,请联系数据管理员</div>';
exit();
}
if($md['status']<1)
{
echo '<div class="box box-info">已被数据中心接收的数据才可以进行评审</div>';
exit();
}
$auth = Zend_Auth::getInstance();
if($auth->hasIdentity())
{
$user = $auth->getIdentity();
$userid = $user->id;
$sql = "select id,userid,status from mdreview where userid='$userid' and uuid='$uuid'";
$rs = $this->db->query($sql);
$row = $rs->fetch();
if($row['id']!='' && $row['status']>-1)
{
echo '<div class="box box-info">您已经对该元数据发表过评审了</div>';
exit();
}
}else{
echo '<div class="box box-info">读取用户信息失败,请刷新页面后重试 :(</div>';
exit();
}
if(empty($conclusion))
{
echo '<div class="box box-info">请选择评审意见</div>';
exit();
}
if(!is_numeric($conclusion) || !in_array($conclusion,array(-1,1,2,3)))
{
echo '<div class="box box-info">参数有误,请刷新页面 :(</div>';
exit();
}
if(empty($mdcomment) )
{
echo '<div class="box box-info">请填写元数据意见后再存草稿 :(</div>';
exit();
}
try{
if($row['status']<0)
{
$sql = "delete from mdreview where id='{$row['id']}'";
if($this->db->exec($sql)<1)
{
echo '<div class="box box-error">处理出错,请重试</div>';
exit();
}
}
$data = array(
'userid' => $userid,
'uuid' => $uuid,
'mdcomment' => $mdcomment,
'ts_created' => 'now()',
'datacomment' => $datacomment,
'editorcomment' => $editorcomment,
'conclusion' => $conclusion,
'status' => -1
);
$sql = "select id from mdexpertreview where id='$userid' and uuid='$uuid'";
$rs = $this->db->query($sql);
$row = $rs->fetch();
if($row['id']!='')
{
$data['is_expert'] = 'true';
}
$keys = array();
$values = array();
foreach ($data as $k=>$v)
{
$keys[]=$k;
$values[]=$v;
}
$keys = join(",",$keys);
$values = "'".join("','",$values)."'";
$sql = "insert into mdreview ($keys) values ($values) RETURNING id";
$sth = $this->db->prepare($sql);
$sth->execute();
echo '<div class="box box-success">保存成功!</div>';
exit();
}catch (Exception $e){
echo '<div class="box box-error">保存失败,请重试!</div>';
exit();
}
}// saveAction 存草稿 ajax }// saveAction 存草稿 ajax

View File

@ -43,7 +43,7 @@
<?php <?php
if($auth->hasIdentity()) if($auth->hasIdentity())
{ {
if(empty($this->pms)) if(empty($this->review['id']) || $this->review['status']<0)
{ {
if($md['status']==5) if($md['status']==5)
{ {
@ -54,22 +54,22 @@
<input type="hidden" name="submit" value="1" /> <input type="hidden" name="submit" value="1" />
<p> <p>
评审意见(必选)<br /> 评审意见(必选)<br />
<input type="radio" name="conclusion" value="1" <?php if($this->conclusion == 1) echo 'checked="checked"'; ?> />修改后再审 <input type="radio" name="conclusion" value="1" <?php if($this->review['conclusion'] == 1) echo 'checked="checked"'; ?> />修改后再审
<input type="radio" name="conclusion" value="2" <?php if($this->conclusion == 2) echo 'checked="checked"'; ?> />修改后发布 <input type="radio" name="conclusion" value="2" <?php if($this->review['conclusion'] == 2) echo 'checked="checked"'; ?> />修改后发布
<input type="radio" name="conclusion" value="3" <?php if($this->conclusion == 3) echo 'checked="checked"'; ?> />发布 <input type="radio" name="conclusion" value="3" <?php if($this->review['conclusion'] == 3) echo 'checked="checked"'; ?> />发布
<input type="radio" name="conclusion" value="-1" <?php if($this->conclusion == -1) echo 'checked="checked"'; ?> />退稿 <input type="radio" name="conclusion" value="-1" <?php if($this->review['conclusion'] == -1) echo 'checked="checked"'; ?> />退稿
</p> </p>
<p> <p>
元数据意见(必填)<br/> 元数据意见(必填)<br/>
<textarea id="mdcomment" class="medium full" name="mdcomment"><?php echo $this->keyword.$this->mdcomment;?></textarea> <textarea id="mdcomment" class="medium full" name="mdcomment"><?php echo $this->review['mdcomment'];?></textarea>
</p> </p>
<p> <p>
对数据的意见:<br/> 对数据的意见:<br/>
<textarea id="datacomment" class="small full" name="datacomment"><?php echo $this->datacomment;?></textarea> <textarea id="datacomment" class="small full" name="datacomment"><?php echo $this->review['datacomment'];?></textarea>
</p> </p>
<p> <p>
给数据中心的意见:<br/> 给数据中心的意见:<br/>
<textarea id="editorcomment" class="small full" name="editorcomment"><?php echo $this->editorcomment;?></textarea> <textarea id="editorcomment" class="small full" name="editorcomment"><?php echo $this->review['editorcomment'];?></textarea>
</p> </p>
<p> <p>
评审附件:<br/> 评审附件:<br/>
@ -82,37 +82,45 @@
<button class="btn btn-small" type="button" id="save">存草稿</button> <button class="btn btn-small" type="button" id="save">存草稿</button>
<button class="btn btn-small" type="reset" id="reset" onclick="return confirm('是否确定重置已经填写的意见?')">重置</button> <button class="btn btn-small" type="reset" id="reset" onclick="return confirm('是否确定重置已经填写的意见?')">重置</button>
</p> </p>
<p id="infobox">
<?php
if($this->review['status']<0)
{
echo '<div class="box box-info">您保存的草稿已经加载</div>';
}
?>
</p>
<p>
<label>注:评审意见提交之后不可更改,存草稿功能不能保存附件,请妥善保存附件。</label>
</p>
</form> </form>
<?php <?php
} }
}else }else
{ {
echo "您已经对此数据作出过评审"; echo '<div class="box box-info">您已经对此数据作出过评审</div>';
} }
} else { } else {
echo '发表评审意见,请先<a href="/account/login/?href=/review/review/uuid/'.$md['uuid'].'">登录</a>'; echo '<div class="box box-info">发表评审意见,请先<a href="/account/login/?href=/review/review/uuid/'.$md['uuid'].'">登录</a></div>';
} }
?> ?>
</div>
</div>
<?php if ($this->msg or $this->messages) :?> <?php if ($this->msg or $this->messages) :?>
<div id="message"> <div class="box box-success">
<?php if ($this->msg) : ?> <?php if ($this->msg) : ?>
<p><?php echo $this->msg; ?></p> <?php echo $this->msg; ?>
<?php endif; if ($this->messages): foreach($this->messages as $msg): ?> <?php endif; if ($this->messages):?>
<p><?php echo $msg; ?></p> <ol>
<?php endforeach;endif; ?> <?php foreach($this->messages as $msg): ?>
<li><?php echo $msg; ?></li>
<?php endforeach;?>
</ol>
<?php endif; ?>
<script></script> <script></script>
</div> </div>
<?php endif; ?> <?php endif; ?>
</div>
</div>
</div> </div>
@ -143,8 +151,9 @@ function savereview(){
url:url, url:url,
data:date, data:date,
success:function(html){ success:function(html){
$('#save').html(html); $('#infobox').html(html);
setTimeout("$('#save').html('存草稿');$('#save').removeAttr('disabled');",2000) $('#save').html('存草稿');
setTimeout("$('#save').removeAttr('disabled');$('.box').remove();",3000)
}, },
beforeSend:function(){ beforeSend:function(){
$('#save').attr('disabled','disabled'); $('#save').attr('disabled','disabled');