diff --git a/application/default/controllers/DataController.php b/application/default/controllers/DataController.php index 0ef9793e..ebc6e99f 100755 --- a/application/default/controllers/DataController.php +++ b/application/default/controllers/DataController.php @@ -522,7 +522,7 @@ class DataController extends Zend_Controller_Action * 根据id或uuid来查看元数据 * id为一组数字,uuid为唯一标识符 */ - function viewAction() + function viewAction() { $id = (int)$this->_request->getParam('id'); $sql="select m.*,s.status,g.id as gid,t.filename from normalmetadata m left join mdstatus s on m.uuid=s.uuid @@ -621,6 +621,12 @@ class DataController extends Zend_Controller_Action //数据附件 $sql = $this->db->quoteInto("select m.id,a.realname from mdattach m left join attachments a on m.id=a.id where m.uuid=?",$uuid); $this->view->attachments = $this->db->fetchAll($sql); + //数据版本 + $sql = "SELECT count(id) as c FROM mdversion WHERE uuid=? AND changelog IS NOT NULL"; + $sth = $this->db->prepare($sql); + $sth->execute(array($uuid)); + $row = $sth->fetch(); + $this->view->version = $row; //自动跳转 $sql="select s.* from datasource d left join source s on d.sourceid=s.id where d.uuid=?"; $row=$this->db->fetchRow($this->db->quoteInto($sql,$uuid)); @@ -632,6 +638,45 @@ class DataController extends Zend_Controller_Action } } //viewAction + /* + getversionAction() 获取数据版本 + */ + function getversionAction(){ + + $ac = $this->_getParam('ac'); + $uuid = $this->_getParam('uuid'); + + if($ac == 'list') + { + $this->_helper->layout->disableLayout(); + $this->_helper->viewRenderer->setNoRender(); + + $sql = "SELECT v.changelog,v.ts_created,u.username FROM mdversion v + LEFT JOIN users u ON v.userid=u.id + WHERE v.uuid=? AND v.changelog IS NOT NULL + ORDER BY v.ts_created DESC"; + $sth = $this->db->prepare($sql); + $sth->execute(array($uuid)); + $rows = $sth->fetchAll(); + + if($rows) + { + foreach($rows as $k=>$v) + { + $rows[$k]['ts_created'] = date("Y-m-d H:i",strtotime($v['ts_created'])); + } + $data = array("list"=>$rows); + $this->jsonexit($data); + return true; + }else{ + $data = array("error"=>"处理中出现错误"); + $this->jsonexit($data); + return true; + } + } + + }//getversionAction() + function replace($string){ $patterns = array("/\"/i","/\'/i"); $replacements = array("“","‘"); @@ -1265,7 +1310,7 @@ class DataController extends Zend_Controller_Action $this->_helper->viewRenderer->setNoRender(); //生成PDF $pdf = new ApplicantPDF(); - $pdf->template=$this->view->config->offline->template; + $pdf->template=$this->view->config->offline->template; $formData['project'].='['.$formData['project_title'].' | '.$formData['project_type'].' | '.$formData['project_id'].']'; $pdf->data = $formData; $pdf->drawWestdc(); @@ -1281,8 +1326,8 @@ class DataController extends Zend_Controller_Action //提交 //生成PDF $pdf = new ApplicantPDF(); - $pdf->template=$this->view->config->offline->template; - $pdf->data = $formData; + $pdf->template=$this->view->config->offline->template; + $pdf->data = $formData; $pdf->data['project'].='['.$formData['project_title'].' | '.$formData['project_type'].' | '.$formData['project_id'].']'; $pdf->drawWestdc(); $pdf->addRef($rows); @@ -1632,5 +1677,10 @@ class DataController extends Zend_Controller_Action ->setHeader('Pragma','public') ->setBody($content); } + + public function jsonexit($data){ + $this->getResponse()->setHeader('Content-Type', 'application/json')->appendBody(json_encode($data,JSON_NUMERIC_CHECK)); + return true; + } } diff --git a/application/default/views/scripts/data/view.phtml b/application/default/views/scripts/data/view.phtml index a7c103d9..2a109edc 100755 --- a/application/default/views/scripts/data/view.phtml +++ b/application/default/views/scripts/data/view.phtml @@ -150,6 +150,9 @@ endforeach;
'+data.list[v].changelog+'
'+data.list[v].ts_created+' by '+data.list[v].username+'