merge heihedata branch r3812 to r3821 for trunk

This commit is contained in:
wlx 2013-07-22 11:27:11 +00:00
parent 3bfb53767a
commit ccdb4f2fbc
17 changed files with 2927 additions and 2152 deletions

View File

@ -56,12 +56,12 @@ table thead tr th {background:#EBF2F6;}
<td><a href="/data/<?= $item['uuid'] ?>"><?= $item['title'] ?></a></td>
<td><?= $item['doi'] ?></td>
<td>
<?php if(empty($item['ts_submitted'])) {?>
<a href="/admin/data/doi/ac/edit/uuid/<?= $item['uuid']?>">编辑</a>
<a href="/admin/data/doi/ac/convert/uuid/<?= $item['uuid']?>">导出</a>
<?php } ?>
<a href="javascript:void(0);" rel="/admin/data/doi/ac/verified/uuid/<?= $item['uuid']?>" class="verified_btn">验证</a>
<?php if(empty($item['ts_published'])) {?>
<a href="javascript:void(0);" onclick="onedel(<?= $item['id']?>)" id="delbtn_<?= $item['id']?>">删除</a>
<?php } ?>
</td>
</tr>
<?php endforeach; ?>

View File

@ -54,6 +54,7 @@ ftp.password=westdcforsmall
download.max=5 //最多同时申请下载个数
page.max=10 //每页显示条目数
offline.template=../data/offline.pdf
offline.heihetemplate=../data/heihe.pdf
offline.security=../data/security.pdf
offline.water_template=../data/water_offline.pdf
offline.font=../data/simhei.ttf

View File

@ -26,16 +26,16 @@ class DataController extends Zend_Controller_Action
$state=$this->db->query('select c.code,name,name_zh,count(*) from category c,categorycode cc where c.code=cc.code group by c.code,cc.name,cc.name_zh');
$this->view->category=$state->fetchAll();
//关键词
$state=$this->db->query("select keyword,count(*) from keyword where keytype='place' group by keyword order by count desc limit 20");
$state=$this->db->query("select keyword,count(*) from keyword right join normalmetadata on keyword.id=normalmetadata.id where keytype='place' group by keyword order by count desc limit 20");
$k1=$state->fetchAll();
$state=$this->db->query("select keyword,count(*) from keyword where keytype='theme' group by keyword order by count desc limit 20");
$state=$this->db->query("select keyword,count(*) from keyword right join normalmetadata on keyword.id=normalmetadata.id where keytype='theme' group by keyword order by count desc limit 20");
//$state=$this->db->query("select k.keyword,count(k.keyword) from keyword k left join normalmetadata m on k.id=m.id where k.keytype='theme' and (m.uuid in (select uuid from dataorder group by uuid order by count(uuid) desc limit 20)) group by k.keyword order by count(k.keyword) desc limit 20");
$k2=$state->fetchAll();
$state=$this->db->query("select keyword,count(*) from keyword where keytype='discipline' group by keyword order by count desc limit 20");
$state=$this->db->query("select keyword,count(*) from keyword right join normalmetadata on keyword.id=normalmetadata.id where keytype='discipline' group by keyword order by count desc limit 20");
$k3=$state->fetchAll();
$state=$this->db->query("select keyword,count(*) from keyword where keytype='stratum' group by keyword order by count desc limit 20");
$state=$this->db->query("select keyword,count(*) from keyword right join normalmetadata on keyword.id=normalmetadata.id where keytype='stratum' group by keyword order by count desc limit 20");
$k4=$state->fetchAll();
$state=$this->db->query("select keyword,count(*) from keyword where keytype='temporal' group by keyword order by count desc limit 20");
$state=$this->db->query("select keyword,count(*) from keyword right join normalmetadata on keyword.id=normalmetadata.id where keytype='temporal' group by keyword order by count desc limit 20");
//$state=$this->db->query("select k.keyword,count(k.keyword) from keyword k left join normalmetadata m on k.id=m.id where k.keytype='temporal' and (m.uuid in (select uuid from dataorder group by uuid order by count(uuid) desc limit 20)) group by k.keyword order by count(k.keyword) desc limit 20");
$k5=$state->fetchAll();
$this->view->keywords=array('place'=>$k1,'theme'=>$k2,'discipline'=>$k3,'stratum'=>$k4,'temporal'=>$k5);
@ -205,7 +205,7 @@ class DataController extends Zend_Controller_Action
if (empty($page)) $page=1;
$limit=10;
$offset=$limit*($page-1);
$sql='select keyword,count(*),keytype from keyword ';
$sql='select keyword,count(*),keytype from keyword right join normalmetadata on keyword.id=normalmetadata.id ';
if (!empty($keytype) && ($keytype=='place' || $keytype=='theme' || $keytype=='discipline'||$keytype=='temporal')) $sql.=" where keytype='".$keytype."'";
$sql.=' group by keyword,keytype order by keytype,keyword,count desc';
$state=$this->db->query($sql);
@ -1450,68 +1450,84 @@ class DataController extends Zend_Controller_Action
function orderAction()
{
$this->view->pageID = "account-dataorder";
$uuid=$this->_request->getParam('uuid');
$ac = $this->_request->getParam('ac');
include_once("helper/view.php");
$uuid = $this->_request->getParam('uuid');
$del = $this->_request->getParam('del');
$apply = $this->_request->getParam('apply');
$finish = $this->_request->getParam('finish');
$cancel = $this->_request->getParam('cancel');
$wsn = $this->_request->getParam('wsn');
$pdf = $this->_request->getParam('pdf');
$ac = $this->_request->getParam('ac');
//if (empty($uuid)) $this->_redirect('/data');
$userid=Zend_Auth::getInstance()->getIdentity()->id;
include_once("helper/view.php");
$userid = view::User('id');
//添加到数据篮
if ($uuid)
{
//处理数据入库
//离线申请的数据不应该重复因此需要在数据库限制还是在WEB端限制
//在数据库中控制只保证uuid,userid,status唯一就可以?
//存在历史遗留问题,原来的数据并不能保证唯一
//status: 1 开始进入离线申请申请程序中
// 2 填写并提交离线申请表
// 3 邮寄离线申请表
// 4 收到离线申请表
// 5 处理离线申请表
// 10:离线申请完成?
// -1: 取消了在线下载进程
//首先判断离线申请的数据数量是否超过系统限制
$sql="select count(*) as datacount from dataorder where (ts_approved is null) and userid=? and status>0 and status<3";
$r=$this->db->fetchRow($this->db->quoteInto($sql,$userid));
//保证添加的离线数据申请未申请
$sql="select count(*) as datacount from dataorder where (ts_approved is null) and userid='$userid' and uuid=? and status in (1,2,3,4)";
$r1=$this->db->fetchRow($this->db->quoteInto($sql,$uuid));
//保证添加的离线数据是正式发布的数据
$sql="select count(*) as mdcount from normalmetadata where uuid=?";
$r2=$this->db->fetchRow($this->db->quoteInto($sql,$uuid));
if ($r['datacount']<$this->view->config->download->max && $r1['datacount']<1 && $r2['mdcount']>0) {
$sql="insert into dataorder (uuid,ts_created,userid,status) values(?,now(),?,?)";
$this->db->query($sql,array($uuid,$userid,1));
//成功信息提示
$sql=$this->db->quoteInto("select title,uuid from metadata where uuid=?",$uuid);
$this->view->md=$this->db->fetchRow($sql);
} else {
if ($r1['datacount']>=1)
$this->view->msg=view::Msg('alert-error',"错误:您申请的数据已经在数据蓝中!",0);
elseif ($r2['mdcount']==0)
$this->view->msg=view::Msg('alert-error',"错误:您申请的数据不存在。",0);
else
$this->view->msg=view::Msg('alert-error',"错误:您正在进行的离线申请的数据数已经超过系统允许的最大值,请在完成本次离线申请后再进行操作!",0);
$order = new order\Order();
$orderListener = new order\listener\OrderListener();
@$order->events()->attachAggregate($orderListener);
$state = $order->addOrder($uuid);
if($state !== true)
{
if(!is_array($state))
{
$this->view->msg = \view::Msg('alert-error',$state);
}else{
if($state['datetype'] == "wsn")
{
\view::Post($this,"此数据提供下载选择功能,请等待页面跳转至数据选择页面","/data/order/wsn/$uuid");
}else{
$this->view->msg = \view::Msg('alert-error',"无法申请:此元数据的数据类型未知");
}
}
}else{
$this->view->msg = \view::Msg('alert-success',"添加成功!您可以继续浏览数据或是继续提交申请表");
}
if (empty($ac)) $ac='offline1';
} elseif ($del) {
//删除数据申请
$sql=$this->db->quoteInto("delete from dataorder where userid=".$userid." and status in (1,2) and id=?",$del);
$this->db->query($sql);
}
//删除申请
elseif ($del) {
$order = new order\Order();
$state = $order->del($del);
if($state !== true)
{
$this->view->msg = \view::Msg('alert-error',$state);
}else{
$this->view->msg = \view::Msg('alert-success',"数据申请取消成功");
}
$this->_redirect('/data/order');
} elseif ($apply) {
if ($apply=='all') {
$sql=$this->db->quoteInto("update dataorder set status=2 where status=1 and userid=?",$userid);
$this->db->query($sql);
} else {
$sql="update dataorder set status=2 where status=1 and userid=? and id=?";
$this->db->query($sql,array($userid,(int)$apply));
}
//提交申请
elseif ($apply) {
if($apply == "all" || !is_numeric($apply))
{
$apply = -1;
}
$order = new order\Order();
$state = $order->apply($apply);
if($state !== true)
{
$this->view->msg = \view::Msg('alert-error',$state);
}else{
$this->view->msg = \view::Msg('alert-success',"提交成功您可以点击“提交离线申请”来生成PDF申请表");
}
if (empty($ac)) $ac='offline2';
} elseif ($finish) {
}
//完成
elseif ($finish) {
if ($finish=='all') {
$sql=$this->db->quoteInto("update dataorder set ts_approved=now() where status=0 and userid=?",$userid);
$this->db->query($sql);
@ -1523,7 +1539,16 @@ class DataController extends Zend_Controller_Action
$sql="update ftpuser set datacount=datacount-1 where userid=? and datacount>0";
$this->db->query($sql,array($userid));
}
} elseif ($cancel) {
}
elseif($wsn)
{
$this->_helper->viewRenderer('order-wsn');
return true;
}
elseif ($cancel) {
if ($cancel=='all') {
$sql=$this->db->quoteInto("update dataorder set ts_approved=now(),status=-1 where status=0 and userid=?",$userid);
$this->db->query($sql);
@ -1536,33 +1561,41 @@ class DataController extends Zend_Controller_Action
$this->db->query($sql,array($userid));
}
if (empty($ac)) $ac='offline2';
} elseif ($pdf) {
}
//生成PDF离线申请文件
elseif ($pdf) {
//用户信息可以从SESSION中读取离线申请信息
//$sql="select * from users where id=?";
$sql="select m.title||'('||m.filesize::text||'MB)' as title,m.ts_published,date_part('year',doi.ts_published) as publish_year,m.citation,m.suppinfo,
array_to_string(ARRAY(
select r.reference from mdref mr left join reference r on mr.refid=r.id
where mr.reftype=3 and mr.uuid=d.uuid order by mr.place),'\n'::text) as reference,
array_to_string(array(
select fund.fund_type||':'||fund.title||'(编号:'||fund.fund_id||')'
from fund left join mdfund on fund.id=mdfund.fid where mdfund.uuid=d.uuid),'\n'::text) as fund,
doi.doi as datadoi,doi.authors,doi.publisher,doi.title as doititle,doi.author_en,doi.publisher_en,doi.title_en
from dataorder d left join metadata m on d.uuid=m.uuid left join datadoi doi on doi.uuid=d.uuid
where d.status=2 and d.userid=? order by d.ts_created desc
";
$rows=$this->db->fetchAll($sql,array($userid));
if ($rows) {
$this->view->data2=$rows;
$this->view->form=new OfflinePdfForm();
$order = new order\Order();
$rows = $order->getOrderItemForPdf();
$this->view->projectType = $order->projectType;
if ($rows) {
$this->_helper->viewRenderer('pdf');
$this->view->data2 = $rows;
if ($this->_request->isPost()) {
$formData = $this->_request->getPost();
$this->view->formData = $formData = $this->_request->getPost();
$s = $order->checkPdfOrderField($formData);
if($s !== true)
{
$this->view->error = \view::Msg('alert-error',$s);
return true;
}
$datalist='';
foreach($rows as $i=>$row) $datalist.=($i+1).". ".$row['title'].";";
$formData['datalist']=$datalist;
if ($this->view->form->isValid($formData)) {
foreach($rows as $i=>$row)
{
$datalist.=($i+1).". ".$row['title'].";";
}
$formData['datalist'] = $datalist;
if (@$formData['save']) {
//保存
//根据pdflink字段以判断是否已经提交
@ -1579,11 +1612,19 @@ where d.status=2 and d.userid=? order by d.ts_created desc
$this->_helper->layout->disableLayout();
$this->_helper->viewRenderer->setNoRender();
//生成PDF
$sql="select m.title||'('||m.filesize::text||'MB)' as title from dataorder d right join normalmetadata m on d.uuid=m.uuid where d.status=2 and d.userid=?";
$list=$this->db->fetchAll($sql,array($userid));
foreach($list as $i=>$row) @$formData['heihelist'].=($i+1).". ".$row['title'].";";
$sql="select m.title||'('||m.filesize::text||'MB)' as title from dataorder d right join normalmetadata m on d.uuid=m.uuid where d.uuid not in (select uuid from normalmetadata) and d.status=2 and d.userid=?";
$list=$this->db->fetchAll($sql,array($userid));
foreach($list as $i=>$row) @$formData['westdclist'].=($i+1).". ".$row['title'].";";
$pdf = new ApplicantPDF();
$pdf->template=$this->view->config->offline->template;
$pdf->heihetemplate=$this->view->config->offline->heihetemplate;
$formData['project'].='['.$formData['project_title'].' | '.$formData['project_type'].' | '.$formData['project_id'].']';
$pdf->data = $formData;
$pdf->drawWestdc();
if (isset($formData['westdclist'])) $pdf->drawWestdc();
if (isset($formData['heihelist'])) $pdf->drawHeihe();
$pdf->addRef($rows);
$pdf->addSecurity($this->view->config->offline->security);
header("Content-Disposition: inline; filename=westdc-data-apply.pdf");
@ -1595,11 +1636,19 @@ where d.status=2 and d.userid=? order by d.ts_created desc
} elseif ($formData['submit']) {
//提交
//生成PDF
$sql="select m.title||'('||m.filesize::text||'MB)' as title from dataorder d right join normalmetadata m on d.uuid=m.uuid where d.status=2 and d.userid=?";
$list=$this->db->fetchAll($sql,array($userid));
foreach($list as $i=>$row) @$formData['heihelist'].=($i+1).". ".$row['title'].";";
$sql="select m.title||'('||m.filesize::text||'MB)' as title from dataorder d right join normalmetadata m on d.uuid=m.uuid where d.uuid not in (select uuid from normalmetadata) and d.status=2 and d.userid=?";
$list=$this->db->fetchAll($sql,array($userid));
foreach($list as $i=>$row) @$formData['westdclist'].=($i+1).". ".$row['title'].";";
$pdf = new ApplicantPDF();
$pdf->template=$this->view->config->offline->template;
$pdf->heihetemplate=$this->view->config->offline->heihetemplate;
$pdf->data = $formData;
$pdf->data['project'].='['.$formData['project_title'].' | '.$formData['project_type'].' | '.$formData['project_id'].']';
$pdf->drawWestdc();
if (isset($formData['westdclist'])) $pdf->drawWestdc();
if (isset($formData['heihelist'])) $pdf->drawHeihe();
$pdf->addRef($rows);
$pdf->addSecurity($this->view->config->offline->security);
$fn=$formData['realname'].date('YmdHis').".pdf";
@ -1622,6 +1671,7 @@ where d.status=2 and d.userid=? order by d.ts_created desc
//发送用户邮件进行信息提示和说明
//$mail = new Zend_Mail('utf-8');
$data = array(
"user"=>$formData['realname'],
"datalist"=>str_replace(";","\n",$datalist)
@ -1638,11 +1688,10 @@ where d.status=2 and d.userid=? order by d.ts_created desc
$this->_helper->viewRenderer('order');
//跳转到/data/order并提示帮助信息告知用户已经发送EMAIL
$this->view->msg=view::Msg('alert-success',"提示信息:您的离线申请已经提交,系统已经发送一封邮件给您,请打印出申请表、签字后拍照或扫描并email给数据中心服务组可以采用邮寄方式),具体信息请参考邮件说明。",0);
$this->view->msg=view::Msg('alert-success',"提示信息:您的离线申请已经提交,系统已经发送一封邮件给您,请打印出申请表、签字后扫描为pdf并email给数据中心服务组仍可以采用邮寄方式具体信息请参考邮件说明。",0);
if (empty($ac)) $ac='offline3';
//$this->_redirect('/data/order');
}
}
} else {
$sql="select u.* from users u left join offlineapp o on u.id=o.userid where u.id=?";
$row=$this->db->fetchRow($sql,array($userid));
@ -1654,7 +1703,7 @@ where d.status=2 and d.userid=? order by d.ts_created desc
$formData['address']=$row->address;
$formData['purpose']=$row->project;
$formData['id']=$row->id;*/
$this->view->form->populate($row);
$this->view->formData = $row;
}
} else
$this->view->msg=view::Msg('alert-error',"错误:您还没有提交任何离线申请的数据,或您的数据申请已经提交(等待处理过程中)!",0);

View File

@ -59,7 +59,7 @@ echo '通过时间';
<?php foreach($this->paginator as $order) : ?>
<tr>
<td><?php echo date('Y-m-d H:i:s',strtotime($order['ts_created'])); ?></td>
<td><a href="<?php echo $order['uuid']; ?>"><?php echo $order['title']; ?></a></td>
<td><a href="/data/<?php echo $order['uuid']; ?>"><?php echo $order['title']; ?></a></td>
<td>
<?php
if ($this->tabID=='order-offline1') {
@ -72,7 +72,7 @@ if ($this->tabID=='order-offline1') {
echo ' <a class="btn" href="/data/order/cancel/'.$order['id'].'">取消</a>';
break;
case 3:
echo "请打印签字然后扫描或拍照申请表并email或邮寄";
echo "请打印签字扫描为pdf并email或邮寄";
break;
default:
break;
@ -80,7 +80,7 @@ if ($this->tabID=='order-offline1') {
} elseif ($this->tabID=='order-offline3') {
switch($order['status']) {
case 3:
echo "请打印签字然后扫描或拍照申请表并email或邮寄";
echo "请打印签字扫描为pdf并email或邮寄";
break;
case 4:
echo "已收到申请,请等待审批。日期:";echo date('Y-m-d',strtotime($order['ts_received']));

View File

@ -34,8 +34,89 @@
<div class="alert"><?php echo $msg; ?></div>
<?php endforeach;endif; ?>
<?php if ($this->msg) : ?>
<div class="alert"><p><?php echo $this->msg; ?></div>
<?php echo $this->msg; ?>
<?php endif; ?>
<?php echo $this->form;?>
<?php if ($this->error) : ?>
<?php echo $this->error; ?>
<?php endif; ?>
<form id="OfflinePdf" enctype="application/x-www-form-urlencoded" class="form-horizontal" action="" method="post">
<div class="control-group">
<label class="control-label" name="realname">真实姓名</label>
<div class="controls">
<input type="text" name="realname" id="realname" value="<?= empty($this->formData['realname']) ? "":$this->formData['realname']?>" helper="formText"> </div>
</div>
<div class="control-group">
<label class="control-label" name="email">E-Mail</label>
<div class="controls">
<input type="text" name="email" id="email" value="<?= empty($this->formData['email']) ? "":$this->formData['email']?>" helper="formText"> </div>
</div>
<div class="control-group">
<label class="control-label" name="phone">电话</label>
<div class="controls">
<input type="text" name="phone" id="phone" value="<?= empty($this->formData['phone']) ? "":$this->formData['phone']?>" helper="formText"> </div>
</div>
<div class="control-group">
<label class="control-label" name="unit">单位</label>
<div class="controls">
<input type="text" name="unit" id="unit" value="<?= empty($this->formData['unit']) ? "":$this->formData['unit']?>" helper="formText" class="input-block-level"> </div>
</div>
<div class="control-group">
<label class="control-label" name="address">联系地址</label>
<div class="controls">
<input type="text" name="address" id="address" value="<?= empty($this->formData['address']) ? "":$this->formData['address']?>" helper="formText" class="input-block-level"> </div>
</div>
<div class="control-group">
<label class="control-label" name="postcode">邮编</label>
<div class="controls">
<input type="text" name="postcode" id="postcode" value="<?= empty($this->formData['postcode']) ? "":$this->formData['postcode']?>" helper="formText"> </div>
</div>
<div class="control-group">
<label class="control-label" name="project_id">项目编号</label>
<div class="controls">
<input type="text" name="project_id" id="project_id" value="<?= empty($this->formData['project_id']) ? "":$this->formData['project_id']?>" helper="formText"> </div>
</div>
<div class="control-group">
<label class="control-label" name="project_type">项目类型</label>
<div class="controls">
<select name="project_type" id="project_type" helper="formSelect">
<option value="" label="请选择项目类型" <?= empty($this->formData['project_type']) ? 'selected="selected"':"" ?>>请选择项目类型</option>
<?php foreach($this->projectType as $k=>$v) {?>
<option value="<?= $v ?>" <?= $this->formData['project_type'] == $v ? 'selected="selected"':"" ?>><?= $k ?></option>
<?php }?>
</select>
</div>
</div>
<div class="control-group">
<label class="control-label" name="project_title">项目名称</label>
<div class="controls">
<input type="text" name="project_title" id="project_title" value="<?= empty($this->formData['project_title']) ? "":$this->formData['project_title']?>" helper="formText" class="input-block-level"> </div>
</div>
<div class="control-group">
<label class="control-label" name="project">用途<br/>(请详细描述使用目的)</label>
<div class="controls">
<textarea name="project" id="project" helper="formTextarea" rows="3" class="input-block-level" cols="80">
<?= empty($this->formData['project']) ? "":$this->formData['project']?>
</textarea> </div>
</div>
<div class="control-group">
<div class="controls">
<input type="hidden" name="id" value="8018" helper="formHidden" id="id">
<input type="submit" name="save" id="savebutton" value="预览PDF" class="btn">
<input type="submit" name="submit" id="submitbutton" value="提交申请到数据中心" class="btn btn-primary">
</div>
</div>
</form>
</div><!--/span-->
</div>

View File

@ -21,7 +21,7 @@ $this->nav[] = array('link'=>"/heihe/offline",'title'=>'离线数据浏览');
<img class="media-object" src="/service/thumb/id/<?php echo $md['id'];?>">
</a>
<div class="media-body">
<h4 class="media-heading"><a href="/heihe/<?php echo $md['uuid'];?>"><?php echo $this->escape($md['title']);?></a></h4>
<h4 class="media-heading"><a href="/heihe/view/uuid/<?php echo $md['uuid'];?>"><?php echo $this->escape($md['title']);?></a></h4>
<div class="summary"><?php echo str_replace(array("\r\n", "\n", "\r"),'<br />',mb_strlen($md['description'])>400?$this->escape(mb_substr($md['description'],0,400,'UTF-8').'...'):$this->escape($md['description']));?></div>
</div>
</div>

View File

@ -21,7 +21,7 @@ $this->nav[] = array('link'=>"/heihe/offline",'title'=>'在线数据浏览');
<img class="media-object" src="/service/thumb/id/<?php echo $md['id'];?>">
</a>
<div class="media-body">
<h4 class="media-heading"><a href="/heihe/<?php echo $md['uuid'];?>"><?php echo $this->escape($md['title']);?></a></h4>
<h4 class="media-heading"><a href="/heihe/view/uuid/<?php echo $md['uuid'];?>"><?php echo $this->escape($md['title']);?></a></h4>
<div class="summary"><?php echo str_replace(array("\r\n", "\n", "\r"),'<br />',mb_strlen($md['description'])>400?$this->escape(mb_substr($md['description'],0,400,'UTF-8').'...'):$this->escape($md['description']));?></div>
</div>
</div>

View File

@ -5,36 +5,70 @@ require_once('fpdi/fpdi.php');
class ApplicantPDF extends FPDI
{
public $template;//模板文件的路径
public $heihetemplate;//模板文件的路径
public $data;//包含具体的数据,数组
public $fontsize=10;
function __construct()
{
parent::__construct();
$this->AddUniGBhwFont('ugb','AdobeSongStd-Light-Acro');
}
function drawWestdc()
{
$pagecount = $this->setSourceFile($this->template);
$tplidx = $this->importPage(1);
$this->addPage();
$this->useTemplate($tplidx);
$this->AddUniGBhwFont('ugb','AdobeSongStd-Light-Acro');
$this->SetFont('ugb','',$this->fontsize);
$this->setXY(71,44);
$this->setXY(74,43);
$this->Write($this->fontsize,$this->data['realname']);
$this->SetXY(34,55);
$this->MultiCell (166, 4, str_replace(";","\n",$this->data['datalist']));
$this->MultiCell (166, 4, str_replace(";","\n",$this->data['westdclist']));
$this->setXY(30,100);
$this->MultiCell(166,4,trim($this->data['project']));
//$this->setXY(34,239);
//$this->Write($this->fontsize,$this->data['realname']);
$this->setXY(32,225);
$this->setXY(32,223);
$this->Write($this->fontsize,$this->data['unit']);
$this->setXY(112,225);
$this->setXY(112,223);
$this->Write($this->fontsize,$this->data['email']);
$this->setXY(174,225);
$this->setXY(174,223);
$this->Write($this->fontsize,$this->data['postcode']);
$this->setXY(32,231);
$this->setXY(32,230);
$this->Write($this->fontsize,$this->data['address']);
$this->setXY(112,231);
$this->setXY(112,230);
$this->Write($this->fontsize,$this->data['phone']);
$t=date("Y-m-d");
$this->setXY(174,231);
$this->setXY(174,230);
$this->Write($this->fontsize,$t);
}
function drawHeihe()
{
$pagecount = $this->setSourceFile($this->heihetemplate);
$tplidx = $this->importPage(1);
$this->addPage();
$this->useTemplate($tplidx);
$this->SetFont('ugb','',$this->fontsize);
$this->setXY(88,43);
$this->Write($this->fontsize,$this->data['realname']);
$this->SetXY(34,55);
$this->MultiCell (166, 4, str_replace(";","\n",$this->data['heihelist']));
$this->setXY(30,100);
$this->MultiCell(166,4,trim($this->data['project']));
//$this->setXY(34,239);
//$this->Write($this->fontsize,$this->data['realname']);
$this->setXY(32,223);
$this->Write($this->fontsize,$this->data['unit']);
$this->setXY(112,223);
$this->Write($this->fontsize,$this->data['email']);
$this->setXY(174,223);
$this->Write($this->fontsize,$this->data['postcode']);
$this->setXY(32,230);
$this->Write($this->fontsize,$this->data['address']);
$this->setXY(112,230);
$this->Write($this->fontsize,$this->data['phone']);
$t=date("Y-m-d");
$this->setXY(174,230);
$this->Write($this->fontsize,$t);
}
function addRef($mds)

View File

@ -0,0 +1,94 @@
<?php
namespace data;
class Favorite extends Zend_Controller_Plugin_Abstract
{
public $db; //传入PDO对象.
private $auth = NULL; //Zend_Auth 对象
//使用到的公共变量
public $tbl_metadata = "metadata"; //元数据
public $tbl_favorite = "favorite"; //用户收藏表
public $fav_max;
function __construct($db)
{
if(empty($db))
{
$this->db = \Zend_Registry::get('db');
}else{
$this->db = $db;
}
$this->config = \Zend_Registry::get('config');
$this->fav_max = empty($this->config->favorite->limit) ? 50 : $this->config->favorite->limit ;
}
function like($uuid,$uid = 0)
{
if(empty($uid))
{
$uid = \view::User('id');
}
if(!is_numeric($uid))
{
$uid = \view::User('id');
}
if(!preg_match("/^[0-9A-Za-z]{8}-[0-9A-Za-z]{4}-[0-9A-Za-z]{4}-[0-9A-Za-z]{4}-[0-9A-Za-z]{12}$/",$uuid))
{
return "参数错误";
}
if($this->checkUserFavNum($uid))
{
if($this->checkAlreadyLike($uuid,$uid))
{
$sql = "INSERT INTO {$this->tbl_favorite} (uid,uuid) VALUES ($uid,'$uuid')";
if($this->db->exec($sql))
{
return true;
}else{
return "收藏失败,请重试";
}
}else{
return "您已经收藏过此数据";
}
}else{
return "您的收藏量已达到系统允许的上限";
}
}
//检查是否达到允许的收藏上限
public function checkUserFavNum($uid)
{
$sql = "SELECT count(id) as c FROM {$this->tbl_favorite} WHERE uid=$uid";
$rs = $this->db->query($sql);
$row = $rs->fetch();
if($row['c'] >= $this->fav_max)
{
return false;
}else{
return true;
}
}
//检查是否已经搜藏过
public function checkAlreadyLike($uuid,$uid)
{
$sql = "SELECT * FROM {$this->tbl_favorite} WHERE uid=$uid AND uuid='$uuid'";
$rs = $this->db->query($sql);
$row = $rs->fetch();
if(isset($row['uuid']) && !empty($row['uuid']))
{
return false;
}else{
return true;
}
}
}

View File

@ -0,0 +1,293 @@
<?php
namespace order;
include_once("helper/view.php");
class Order
{
private $db;
private $config;
protected $events = NULL;
public $projectType = array(
"国家973计划项目课题" => "国家973计划项目课题",
"国家863计划课题"=>"国家863计划课题",
"国家级科技支撑课题" => "国家级科技支撑课题",
"国家级科技重大专项" => "国家级科技重大专项",
"国家级国家重大工程" => "国家级国家重大工程",
"国家级国家自然科学基金" => "国家级国家自然科学基金",
"国际合作项目"=>"国际合作项目",
"省部级项目" => "省部级项目",
"其他项目工程" => "其他项目工程",
); //申请中的项目类型
function __construct($db = NULL)
{
if(empty($db))
{
$this->db = \Zend_Registry::get('db');
}else{
$this->db = $db;
}
$this->config = \Zend_Registry::get('config');
}
public function events(\Zend_EventManager_EventCollection $events = NULL)
{
if ($events !== NULL) {
$this->events = $events;
} elseif ($this->events === NULL) {
$this->events = new \Zend_EventManager_EventManager(__CLASS__);
}
return $this->events;
}
/*************
status:
1 开始进入离线申请申请程序中
2 填写并提交离线申请表
3 邮寄离线申请表
4 收到离线申请表
5 处理离线申请表
10:离线申请完成?
-1: 取消了在线下载进程
**************/
//添加到数据篮
public function addOrder($uuid,$uid = 0){
if(empty($uid))
{
$uid = \view::User('id');
}
if(!is_numeric($uid))
{
$uid = \view::User('id');
}
if(!preg_match("/^[0-9A-Za-z]{8}-[0-9A-Za-z]{4}-[0-9A-Za-z]{4}-[0-9A-Za-z]{4}-[0-9A-Za-z]{12}$/",$uuid))
{
return "参数错误";
}
$results = $this->events()->trigger('submit', $this, compact('uuid','uid'));
$data = $results->bottom();
if($data !== true)
{
return $data;
}
$results = $this->events()->trigger('checksource', $this, compact('uuid'));
$data = $results->bottom();
if($data !== true)
{
return array("datetype"=>$data,"uuid"=>$uuid);
}
if($this->pushToDataorder($uuid,$uid) === true)
{
return true;
}else{
return "操作中出现错误,请重试";
}
}//addOrder
//放到数据篮中
public function pushToDataorder($uuid,$uid = 0)
{
if(empty($uid))
{
$uid = \view::User('id');
}
$sql="insert into dataorder (uuid,ts_created,userid,status) values(?,now(),?,?)";
$rs = $this->db->query($sql,array($uuid,$uid,1));
if($rs)
{
return true;
}else{
return false;
}
}//pushToDataorder
//提交
public function apply($id,$uid = 0)
{
if(!is_numeric($id) || !is_numeric($uid))
{
return "参数错误";
}
if(empty($uid))
{
$uid = \view::User('id');
}
if($id == -1)
{
$sql = $this->db->quoteInto("update dataorder set status=2 where status=1 and userid=?",$uid);
if($this->db->exec($sql))
{
return true;
}else{
return "处理中遇到问题,请重试";
}
}
if($id > 0)
{
$sql = $this->db->quoteInto("update dataorder set status=2 where status=1 and userid=$uid and id=?",$id);
if($this->db->exec($sql))
{
return true;
}else{
return "处理中遇到问题,请重试";
}
}
return "参数错误";
}//apply()
//删除
public function del($id,$uid = 0)
{
if(!is_numeric($id) || !is_numeric($uid))
{
return "参数错误";
}
if(empty($uid))
{
$uid = \view::User('id');
}
if($id > 0)
{
$sql = $this->db->quoteInto("delete from dataorder where userid=$uid and status in (1,2) and id=?",$id);
if($this->db->exec($sql))
{
return true;
}else{
return "处理中遇到错误,请重试";
}
}
return "参数错误";
}
//发送邮件
public function SendEmail(){
}
//生成pdf
public function pdf($uid = 0)
{
}
//获得要生成pdf的信息
public function getOrderItemForPdf($uid = 0)
{
if(empty($uid))
{
$uid = \view::User('id');
}
$sql = "select m.title||'('||m.filesize::text||'MB)' as title,m.ts_published,date_part('year',doi.ts_published) as publish_year,m.citation,m.suppinfo,
array_to_string(ARRAY(
select r.reference from mdref mr left join reference r on mr.refid=r.id
where mr.reftype=3 and mr.uuid=d.uuid order by mr.place),'\n'::text) as reference,
array_to_string(array(
select fund.fund_type||':'||fund.title||'(编号:'||fund.fund_id||')'
from fund left join mdfund on fund.id=mdfund.fid where mdfund.uuid=d.uuid order by mdfund.place),'\n'::text) as fund,
doi.doi as datadoi,doi.authors,doi.publisher,doi.title as doititle,doi.author_en,doi.publisher_en,doi.title_en
from dataorder d left join metadata m on d.uuid=m.uuid left join datadoi doi on doi.uuid=d.uuid
where d.status=2 and d.userid=? order by d.ts_created desc
";
$rows = $this->db->fetchAll($sql,array($uid));
return $rows;
}
public function makePdf($formData,$userid = 0)
{
}
public function PdfOrderSave($formData,$uid = 0)
{
}
//checkPdfOrderField 检查PDF申请表的信息
public function checkPdfOrderField($formData)
{
if(empty($formData['realname']))
{
return "请输入真实姓名";
}
if(empty($formData['email']))
{
return "请输入Email";
}
if (!preg_match('/^\w+([-+.]\w+)*@\w+([-.]\w+)*\.\w+([-.]\w+)*$/',$formData['email']))
{
return "请输入正确的电子邮件地址";
}
if(empty($formData['phone']))
{
return "请输入联系电话";
}
if(empty($formData['unit']))
{
return "请输入单位";
}
if(empty($formData['address']))
{
return "请输入地址";
}
if(empty($formData['postcode']) || !is_numeric($formData['postcode']))
{
return "请输入邮政编码";
}
if(empty($formData['project_id']))
{
return "请输入项目编号";
}
if(empty($formData['project_type']))
{
return "请选择项目类型";
}
if(empty($formData['project_title']))
{
return "请填写项目标题";
}
if(empty($formData['project']))
{
return "请填写用途";
}
return true;
}//checkPdfOrderField
}

View File

@ -0,0 +1,14 @@
<?php
namespace order\listener;
//接口 需要实现的Listener中的方法
interface OrderEvents
{
//申请提交事件
public function submit(\Zend_EventManager_Event $e);
//检查数据来源事件
//区别是直接下载的数据或是wsn来源的数据
//wsn来源的数据需要用户在提交申请的时候选择要下载的内容
public function checksource(\Zend_EventManager_Event $e);
}

View File

@ -0,0 +1,37 @@
<?php
namespace order\listener;
//侦听
class OrderListener implements \Zend_EventManager_ListenerAggregate
{
private $db;
function __construct($db = NULL)
{
if(empty($db))
{
$this->db = \Zend_Registry::get('db');
}else{
$this->db = $db;
}
$this->config = \Zend_Registry::get('config');
}
public function attach(\Zend_EventManager_EventCollection $events)
{
$this->attachOnOrder($events);
}
public function detach(\Zend_EventManager_EventCollection $events)
{
}
public function attachOnOrder(\Zend_EventManager_EventCollection $events)
{
$mountedClass = new \order\mount\OrderOperate();
$events->attach('submit', array($mountedClass, 'submit'), 100);
$events->attach('checksource',array($mountedClass,'checksource'),100);
}
}

View File

@ -0,0 +1,134 @@
<?php
namespace order\mount;
include_once("helper/view.php");
//事件中存在的操作
class OrderOperate implements \order\listener\OrderEvents
{
private $db;
private $config;
//!!!!!!important!!!!!
//不同项目使用时是否要修改此项??
public $tbl_metadata = "normalmetadata";
public $tbl_dataorder = "dataorder";
function __construct($db = NULL)
{
if(empty($db))
{
$this->db = \Zend_Registry::get('db');
}else{
$this->db = $db;
}
$this->config = \Zend_Registry::get('config');
}
//提交申请
public function submit(\Zend_EventManager_Event $e)
{
$uuid = $e->getParam('uuid');
$uid = $e->getParam('uid');
try{
if($this->checkOrderUUID($uuid) !== false)
{
return "此数据尚未正式发布,还不能申请";
}
if($this->checkOrderNum(true,$uid) === false)
{
return "您的数据篮中存放的数据已达到可申请的数量";
}
if($this->checkOrderHas($uuid,$uid))
{
return "此数据已经在数据篮中";
}
}catch(Exception $e)
{
\view::Dump($e->getMessage());
}
return true;
}
//检查元数据是否已发布(存在于metadata表中)
public function checkOrderUUID($uuid)
{
$sql = "select count(*) as mdcount from {$this->tbl_metadata} where uuid=?";
$rs = $this->db->fetchRow($this->db->quoteInto($sql,$uuid));
if($rs['mdcount'] == 0)
{
return true;
}else{
return false;
}
}
//检查用户是否已经提交了该数据的申请
public function checkOrderHas($uuid,$uid = 0)
{
if(empty($uid))
{
$uid = \view::User('id');
}
$sql = "select count(*) as datacount from {$this->tbl_dataorder} where (ts_approved is null) and userid=$uid and uuid=? and status in (1,2,3,4)";
$rs = $this->db->fetchRow($this->db->quoteInto($sql,$uuid));
if($rs['datacount']>=1)
{
return true;
}else{
return false;
}
}//CheckOrderHas()
//检查用户已经在数据篮中的申请的数量
// 已经超过返回 true
public function checkOrderNum($bool = true,$uid = 0)
{
if(empty($uid))
{
$uid = \view::User('id');
}
$sql = "select count(*) as datacount from {$this->tbl_dataorder} where (ts_approved is null) and userid=? and status>0 and status<3";
$rs = $this->db->fetchRow($this->db->quoteInto($sql,$uid));
if($bool === true)
{
if($rs['datacount'] <= $this->config->download->max - 1)
{
return true;
}else{
return false;
}
}else{
return $rs['datacount'];
}
}//checkOrderNum
//检查数据来源
public function checksource(\Zend_EventManager_Event $e)
{
$uuid = $e->getParam('uuid');
$sql = "SELECT * FROM wsn_metadata WHERE uuid='$uuid'";
$rs = $this->db->query($sql);
$row = $rs->fetch();
if(isset($row['uuid']) && !empty($row['uuid']))
{
return "wsn";
}else{
return true;
}
}
}

BIN
data/heihe.pdf Normal file

Binary file not shown.

Binary file not shown.

View File

@ -1,5 +1,43 @@
var method = {};
//收藏数据
method.like = function(uuid,btn){
text = $(btn).text();
current_event = $(btn).attr('onclick');
$.ajax({
type:"GET",
url:"/data/like/",
data:'uuid=' + uuid,
success:function(data){
if (typeof(data)=='object')
{
if(typeof(data.error) !== 'undefined')
{
Alert(data.error);return false;
}else{
Alert("收藏成功!");
}
}
else{
Alert('出现错误,请稍后再试');
}
},
beforeSend:function(){
$(btn).removeAttr('onclick');
$(btn).html('<img src="/images/ajax-load-small.gif" />');
},
timeout: 15000,
error: function(){
Alert('处理中出现错误,请刷新页面后重试');
},
complete:function(){
$(btn).attr('onclick',current_event);
$(btn).html(text);
}
});
}
//文件列表
method.filelist = {
get : function(uuid){
html ='<div id="window-outter">'