#416 后台添加了计划上传功能

This commit is contained in:
Li Jianxuan 2012-11-22 01:52:39 +00:00
parent 25cda6e78b
commit 8e635ed9c5
4 changed files with 135 additions and 7 deletions

View File

@ -272,15 +272,92 @@ class Admin_HeiheController extends Zend_Controller_Action
return true; return true;
}//ac == showexpert 查看跟踪专家 }//ac == showexpert 查看跟踪专家
if($ac == "unsubmit") if($ac == "upload")
{ {
$this->_helper->layout->setLayout('layout-iframe');
$this->_helper->viewRenderer('project-upload');
}//ac == unsubmit 未提交 $submit = $this->_getParam('submit');
if($ac == "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() }//projectsAction()

View File

@ -0,0 +1,46 @@
<?php
$this->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');
?>
<?php
if(!empty($this->error))
{
echo $this->error;
echo "<script>setTimeout('parent.$.fn.colorbox.close();',2000);</script>";
}else{?>
<?php if(!empty($this->message))
{
echo "<p>".$this->message."</p>";
}?>
<?php
if(!empty($this->att))
{
echo '<div id="datalist">
<ul>'.
'<li>'.$this->att['realname']."(". round(($this->att['filesize'])/1024,2) .'KB) 【<a href="/service/attach/id/'.$this->att['id'].'">下载</a></li>'
.'</ul></div>';
}
?>
<div id="wapper">
<form id="fileUpdate" action="/admin/heihe/project/ac/upload/pid/<?= $this->pid ?>" method="post" enctype="multipart/form-data">
<p>注:只能选择一个文件,如果重新上传,将自动替换之前上传的文件<br />
<input id="file_upload" name="Filedata" type="file" />
<input type="hidden" name="submit" value="1" />
<input type="submit" class="btn btn-small btn-green" value="上传" />
</p>
</form>
</div>
<?php
}
?>

View File

@ -41,7 +41,8 @@
<p>编号:<label><?= $item['code'];?></label> | 负责人:<?= $item['name'];?> | 开始时间:<?= $item['pstart'];?> | 状态:<?= $item['status'];?></p> <p>编号:<label><?= $item['code'];?></label> | 负责人:<?= $item['name'];?> | 开始时间:<?= $item['pstart'];?> | 状态:<?= $item['status'];?></p>
<p> <p>
<a href="javascript:void(0);" onclick="$('#inviteFrom_<?= $item['id'];?>').toggle();">邀请跟踪专家</a> |  <a href="javascript:void(0);" onclick="$('#inviteFrom_<?= $item['id'];?>').toggle();">邀请跟踪专家</a> | 
<a class="iframe" href="/admin/heihe/project/ac/showexpert/id/<?= $item['id'];?>">查看跟踪专家</a> <a class="iframe" href="/admin/heihe/project/ac/showexpert/id/<?= $item['id'];?>">查看跟踪专家</a> | 
<a href="/admin/heihe/project/ac/upload/pid/<?= $item['id']?>" class="iframe">上传计划</a>
</p> </p>
<p id="inviteFrom_<?= $item['id'];?>" style="display:none;"> <p id="inviteFrom_<?= $item['id'];?>" style="display:none;">
<input type="text" id="expert_name_<?= $item['id'];?>" value="<?= $this->input_NameDefaultVal ?>" <input type="text" id="expert_name_<?= $item['id'];?>" value="<?= $this->input_NameDefaultVal ?>"

View File

@ -964,6 +964,10 @@ class HeiheController extends DataController
} }
} }
$sql = "SELECT * FROM heiheproject WHERE id=$pid";
$sth = $this->db->query($sql);
$row = $sth->fetch();
$sql = "SELECT * FROM attachments WHERE id = {$row['attachid']}"; $sql = "SELECT * FROM attachments WHERE id = {$row['attachid']}";
$sth = $this->db->query($sql); $sth = $this->db->query($sql);
$this->view->att = $sth->fetch(); $this->view->att = $sth->fetch();