diff --git a/application/admin/controllers/HeiheController.php b/application/admin/controllers/HeiheController.php index be7a29da..6a3a9af1 100644 --- a/application/admin/controllers/HeiheController.php +++ b/application/admin/controllers/HeiheController.php @@ -272,15 +272,92 @@ class Admin_HeiheController extends Zend_Controller_Action return true; }//ac == showexpert 查看跟踪专家 - if($ac == "unsubmit") + if($ac == "upload") { + $this->_helper->layout->setLayout('layout-iframe'); + $this->_helper->viewRenderer('project-upload'); - }//ac == unsubmit 未提交 - - if($ac == "submit") - { + $submit = $this->_getParam('submit'); + + $pid = $this->_getParam('pid'); - }//ac == submit 已提交 + if(empty($pid) || !is_numeric($pid)) + { + $this->view->error = "参数错误"; + return true; + } + + $this->view->pid = $pid; + + $auth = Zend_Auth::getInstance(); + if($auth->hasIdentity()) + { + $user = $auth->getIdentity(); + $uid = $user->id; + } + + if(!empty($submit) && empty($this->view->error)) + { + + $files=new files(); + $msg = $files -> upload($this->view->config->upload,$_FILES['Filedata'],'heihe'); + + if(empty($msg['error'])) + { + $msg['error']=""; + $filename = $msg['db_path']; + $filesize = $msg['file_size']; + $filedesc = $this->_request->getParam('filedesc'); + $filetype = $msg['file_type']; + $realname = $msg['realname']; + + if(!empty($row['attachid'])) + { + $sql = "SELECT * FROM attachments WHERE id={$row['attachid']}"; + $sth = $this->db->query($sql); + $attach = $sth->fetch(); + $this->db->exec("DELETE FROM attachments WHERE id={$row['attachid']} AND filetype='heihe'"); + @unlink($this->view->config->upload.$attach['filename']); + } + + $sql = " INSERT INTO attachments (filename,filetype,filedesc,userid,filesize,realname) values + ('$filename','heihe','$filedesc','$uid','$filesize','$realname') RETURNING id"; + $sth = $this->db->prepare($sql); + $sth->execute(); + $att = $sth->fetch(PDO::FETCH_ASSOC); + $msg['attid'] = $attid = $att['id']; + + $sql = "UPDATE heiheproject SET attachid=$attid WHERE id=$pid"; + $sth = $this->db->exec($sql); + + if($sth) + { + $this->view->message = "上传成功"; + }else{ + @unlink($filename); + $this->view->error = '附件上传失败:写入附件表出错'; + return true; + } + }else{ + @unlink($filename); + $this->view->error = "附件上传失败".$msg['error']; + return true; + } + } + + $sql = "SELECT * FROM heiheproject WHERE id=$pid"; + $sth = $this->db->query($sql); + $row = $sth->fetch(); + + if(!empty($row['attachid'])) + { + $sql = "SELECT * FROM attachments WHERE id = {$row['attachid']}"; + $sth = $this->db->query($sql); + $this->view->att = $sth->fetch(); + } + + return true; + }//ac == upload }//projectsAction() diff --git a/application/admin/views/scripts/heihe/project-upload.phtml b/application/admin/views/scripts/heihe/project-upload.phtml new file mode 100644 index 00000000..736708fd --- /dev/null +++ b/application/admin/views/scripts/heihe/project-upload.phtml @@ -0,0 +1,46 @@ +headTitle($this->config->title->site); + $this->headTitle('上传计划'); + $this->headTitle()->setSeparator(' - '); + $this->headLink()->appendStylesheet('/css/admin.css'); + $this->breadcrumb()->setSeparator(' > '); + $this->headScript()->appendFile('/js/jquery-1.7.min.js'); + $this->headScript()->appendFile('/js/jquery.colorbox-min.js'); + $this->headLink()->appendStylesheet('/css/colorbox.css'); + $this->headLink()->appendStylesheet('/css/author.css'); + $this->headScript()->appendFile('/static/js/uploadify/swfobject.js'); + $this->headScript()->appendFile('/static/js/uploadify/jquery.uploadify.v2.1.4.min.js'); + $this->headLink()->appendStylesheet('/static/js/uploadify/uploadify.css'); +?> +error)) +{ + echo $this->error; + echo ""; +}else{?> + message)) + { + echo "

".$this->message."

"; + }?> + att)) + { + echo '
+
'; + } + ?> +
+
+

注:只能选择一个文件,如果重新上传,将自动替换之前上传的文件
+ + + +

+
+
+ + diff --git a/application/admin/views/scripts/heihe/project.phtml b/application/admin/views/scripts/heihe/project.phtml index fd16cba9..fc4823dc 100644 --- a/application/admin/views/scripts/heihe/project.phtml +++ b/application/admin/views/scripts/heihe/project.phtml @@ -41,7 +41,8 @@

编号: | 负责人: | 开始时间: | 状态:

邀请跟踪专家 |  - 查看跟踪专家 + 查看跟踪专家 |  + 上传计划