diff --git a/application/default/controllers/ReviewController.php b/application/default/controllers/ReviewController.php index 238c0571..eced0f8d 100644 --- a/application/default/controllers/ReviewController.php +++ b/application/default/controllers/ReviewController.php @@ -142,153 +142,6 @@ class ReviewController extends Zend_Controller_Action $rs = $this->db->query($sql); $row = $rs->fetch(); $this->view->review = $row; - } - - $submit = $this->_request->getParam('submit'); - - $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'))); - - if(!empty($submit)){ - - $redirectlink='/review/review/uuid/'.$uuid.'/'; - - if($md['status']>4) - { - $this->messenger->addMessage('该数据已经通过评审,不能再发表评审意见,如需提交问题,请联系数据管理员'); - $this->_redirect($redirectlink); - } - if($md['status']<1) - { - $this->messenger->addMessage('已被数据中心接收的数据才可以进行评审'); - $this->_redirect($redirectlink); - } - - $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) - { - $this->messenger->addMessage('您已经对该元数据发表过评审了'); - $this->_redirect($redirectlink); - } - }else{ - $this->messenger->addMessage('读取用户信息失败,请刷新页面后重试 :('); - $this->_redirect($redirectlink); - } - - if(empty($conclusion)) - { - $this->messenger->addMessage('请选择评审意见'); - $this->_redirect($redirectlink); - } - if( !is_numeric($conclusion) || !in_array($conclusion,array(-1,1,2,3)) ) - { - $this->messenger->addMessage('参数有误,请刷新页面 :('); - $this->_redirect($redirectlink); - } - if(empty($mdcomment) ) - { - $this->messenger->addMessage('请填写元数据意见后再发布 :('); - $this->_redirect($redirectlink); - } - if(!empty($_FILES['Filedata']['name'])) - { - $files=new files(); - $msg = $files -> upload($this->view->config->upload,$_FILES['Filedata'],'reviewatt'); - - if(empty($msg['error'])) - { - $filename = $msg['db_path']; - $filesize = $msg['file_size']; - $filedesc = $this->_request->getParam('filedesc'); - $filetype = $this->_request->getParam('dir'); - - $sql = "insert into attachments (filename,filetype,filedesc,userid,filesize) values ('$filename','reviewatt','$filedesc','$userid','$filesize') RETURNING id"; - $sth = $this->db->prepare($sql); - $sth->execute(); - $att = $sth->fetch(PDO::FETCH_ASSOC); - $attid = $att['id']; - - }else{ - $this->messenger->addMessage('附件上传失败:'.$msg['error']); - @unlink($filename); - $this->_redirect($redirectlink); - } - } - - 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( - 'userid' => $userid, - 'uuid' => $uuid, - 'mdcomment' => $mdcomment, - 'ts_created' => 'now()', - 'datacomment' => $datacomment, - 'editorcomment' => $editorcomment, - 'conclusion' => $conclusion - ); - - - $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(); - $review = $sth->fetch(PDO::FETCH_ASSOC); - $reviewid=$review['id']; - - if(!empty($_FILES['Filedata']['name'])) - { - $sql = "insert into mdreviewattach (attachid,reviewid) values ('$attid','$reviewid')"; - $this->db->exec($sql); - } - - $this->messenger->addMessage('提交成功'); - $this->_redirect($redirectlink); - - }catch (Exception $e){ - - $this->messenger->addMessage('提交失败,请重试'.$sql.'aa'.$review['id'].$e->getMessage()); - $this->_redirect($redirectlink); - - } } }//reviewAction() @@ -340,6 +193,7 @@ class ReviewController extends Zend_Controller_Action $this->_helper->layout->disableLayout(); $this->_helper->viewRenderer->setNoRender(); + $do = $this->_request->getParam('do'); $conclusion = $this->_request->getParam('conclusion'); $mdcomment = $this->replace(trim($this->_request->getParam('mdcomment'))); $datacomment = $this->replace(trim($this->_request->getParam('datacomment'))); @@ -392,7 +246,7 @@ class ReviewController extends Zend_Controller_Action } if(empty($mdcomment) ) { - echo '
请填写元数据意见后再存草稿 :(
'; + echo '
请填写元数据意见 :(
'; exit(); } @@ -419,6 +273,11 @@ class ReviewController extends Zend_Controller_Action 'status' => -1 ); + if($do=='submit') + { + $data['status'] = 0; + } + $sql = "select id from mdexpertreview where id='$userid' and uuid='$uuid'"; $rs = $this->db->query($sql); @@ -444,8 +303,29 @@ class ReviewController extends Zend_Controller_Action $sth = $this->db->prepare($sql); if($sth->execute()) { - echo '
保存成功!
'; - exit(); + if($_POST['atts']) + { + $review = $sth->fetch(PDO::FETCH_ASSOC); + $reviewid=$review['id']; + try{ + foreach($_POST['atts'] as $v) + { + $sql = "insert into mdreviewattach (attachid,reviewid) values ('$v','$reviewid')"; + $this->db->exec($sql); + } + echo '
保存成功!'; + if($data['status']>=0) + { + echo ''; + } + echo "
"; + exit(); + }catch(Exception $e){ + echo '
保存草稿出错,请稍后再试!
'; + exit(); + } + } + }else{ echo '
保存草稿出错,请稍后再试!
'; exit(); diff --git a/application/default/controllers/UploadController.php b/application/default/controllers/UploadController.php index c73d563f..2ff95b09 100644 --- a/application/default/controllers/UploadController.php +++ b/application/default/controllers/UploadController.php @@ -9,9 +9,9 @@ class UploadController extends Zend_Controller_Action { function indexAction() { $this->_helper->layout()->disableLayout(); $this->_helper->viewRenderer->setNoRender(); + try{ $auth = Zend_Auth::getInstance(); - if($auth->hasIdentity()) { $user = $auth->getIdentity(); @@ -19,7 +19,8 @@ class UploadController extends Zend_Controller_Action { } if(empty($userid)||!is_numeric($userid)){ - echo "请先登录"; + $msg['error'] = "请先登录"; + echo Zend_Json::encode($msg); exit(); } @@ -28,30 +29,106 @@ class UploadController extends Zend_Controller_Action { if(empty($msg['error'])) { + $msg['error']=""; $filename = $msg['db_path']; $filesize = $msg['file_size']; $filedesc = $this->_request->getParam('filedesc'); $filetype = $this->_request->getParam('dir'); $realname = $msg['realname']; + $sql = "insert into attachments (filename,filetype,filedesc,userid,filesize,realname) values ('$filename','reviewatt','$filedesc','$userid','$filesize','$realname') RETURNING id"; $sth = $this->db->prepare($sql); $sth->execute(); $att = $sth->fetch(PDO::FETCH_ASSOC); $msg['attid'] = $attid = $att['id']; + $msg['html'] = $realname.'[已完成]
'; echo Zend_Json::encode($msg); exit(); }else{ - $this->messenger->addMessage('附件上传失败:'.$msg['error']); + $msg['error'] = '附件上传失败:'.$msg['error']; @unlink($filename); - $this->_redirect($redirectlink); + echo Zend_Json::encode($msg); + exit(); } }catch(Exception $e){ - echo "错误:".$e->getMessage(); + $msg['error'] = "错误:".$e->getMessage(); + echo Zend_Json::encode($msg); exit(); } - } + }//indexAction() + + /* + 获得单个文件的信息 + return array row + */ + public function getFileinfo($id){ + $sql = "select * from attachments where id='$id'"; + $re= $this->db->query($sql); + $row= $re->fetch(); + return $row; + } + + function delreviewattAction(){ + $this->_helper->layout()->disableLayout(); + $this->_helper->viewRenderer->setNoRender(); + + $id = $this->_request->getParam('id'); + $basepath = $this->view->config->upload; + $info = $this->getFileinfo($id); + $filepath = $basepath.$info['filename']; + + try{ + $auth = Zend_Auth::getInstance(); + if($auth->hasIdentity()) + { + $user = $auth->getIdentity(); + $userid = $user->id; + $sql = "delete from attachments where id='$id' and userid='$userid'"; + if($this->db->exec($sql)) + { + @unlink($filepath); + } + } + }catch(Exception $e){} + //不输出任何错误 + }//删除评审附件 + + function getattsAction(){ + + $this->_helper->layout()->disableLayout(); + $this->_helper->viewRenderer->setNoRender(); + + $id = $this->_request->getParam('id'); + + if($id!='') + { + $auth = Zend_Auth::getInstance(); + if($auth->hasIdentity()) + { + $user = $auth->getIdentity(); + $userid = $user->id; + $sql = "select att.realname,att.id from attachments att + left join mdreviewattach ratt on att.id=ratt.attachid + where ratt.reviewid=$id and att.userid=$userid"; + $rs = $this->db->query($sql); + $atts = $rs->fetchAll(); + foreach($atts as $k=>$v) + { + $atts[$k]['html']=$v['realname'].'[已完成]
'; + } + echo Zend_Json::encode($atts); + exit(); + }else + { + exit(); + } + }else{ + exit(); + } + //不输出错误 + }//获取附件 } \ No newline at end of file diff --git a/application/default/views/scripts/review/review.phtml b/application/default/views/scripts/review/review.phtml index 0644f142..5cb51f58 100755 --- a/application/default/views/scripts/review/review.phtml +++ b/application/default/views/scripts/review/review.phtml @@ -4,8 +4,10 @@ $this->headTitle('数据查看'); $this->headTitle()->setSeparator(' - '); $this->headLink()->appendStylesheet('/css/mdreview.css'); + $this->headLink()->appendStylesheet('/static/js/uploadify/uploadify.css'); $this->headScript()->appendFile('/js/jquery-1.6.4.min.js'); - $this->headScript()->appendFile('/js/pubfunc.js'); + $this->headScript()->appendFile('/static/js/uploadify/swfobject.js'); + $this->headScript()->appendFile('/static/js/uploadify/jquery.uploadify.v2.1.4.min.js'); $this->breadcrumb('首页'); $this->breadcrumb(''.$this->config->title->review.''); $this->breadcrumb('评审元数据'); @@ -73,28 +75,36 @@

- 评审附件:
-
+ 评审附件: +

+ + 查看可上传的附件类型

+

- +

-

- + +

+

+ review['status']<0) { echo '

您保存的草稿已经加载
'; } ?>

-

- -

+

+ +

+ -