merge heihedata branch from r4161 to r4168.

This commit is contained in:
wlx 2014-01-07 12:56:16 +00:00
parent 6db4162f06
commit bdfc8dca5f
6 changed files with 438 additions and 243 deletions

View File

@ -1055,9 +1055,15 @@ class Admin_DownController extends Zend_Controller_Action
//设置当前活动sheet的名称 //设置当前活动sheet的名称
$objActSheet->setTitle('离线服务记录'); $objActSheet->setTitle('离线服务记录');
if (date('m')==1)
{
$ym=(date('Y')-1).'-12-1';
} else {
$ym=date('Y-').(date('m')-1).'-1';
}
$sql="select o.username,o.unit,o.phone,o.address,o.postcode,o.project,regexp_replace(o.datalist,'\(.+?MB\)','','g') as datalist,date(o.ts_approved) as date,o.email,o.project_id,o.project_type,o.project_title,sum(m.filesize) as filesize $sql="select o.username,o.unit,o.phone,o.address,o.postcode,o.project,regexp_replace(o.datalist,'\(.+?MB\)','','g') as datalist,date(o.ts_approved) as date,o.email,o.project_id,o.project_type,o.project_title,sum(m.filesize) as filesize
from offlineapp o left join dataorder d on o.id=d.offlineappid left join metadata m on d.uuid=m.uuid from offlineapp o left join dataorder d on o.id=d.offlineappid left join metadata m on d.uuid=m.uuid
where o.ts_approved>='".date('Y-').(date('m')-1)."-1' and o.ts_approved<'".date('Y-m')."-1' and o.pdflink is not null and o.ts_approved is not null and d.status=5 group by o.id order by o. ts_approved where o.ts_approved>='".$ym."' and o.ts_approved<'".date('Y-m')."-1' and o.pdflink is not null and o.ts_approved is not null and d.status=5 group by o.id order by o. ts_approved
"; ";
$re = $this->db->query($sql); $re = $this->db->query($sql);
$rows = $re->fetchAll(); $rows = $re->fetchAll();
@ -1086,7 +1092,7 @@ class Admin_DownController extends Zend_Controller_Action
$objActSheet->setTitle('在线服务记录'); $objActSheet->setTitle('在线服务记录');
$sql="select o.username,o.unit,o.phone,o.address,o.postcode,o.project,date(o.ts_created) as date,o.email,o.project_id,o.project_type,o.project_title,m.filesize,m.title $sql="select o.username,o.unit,o.phone,o.address,o.postcode,o.project,date(o.ts_created) as date,o.email,o.project_id,o.project_type,o.project_title,m.filesize,m.title
from onlineapp o left join dataorder d on o.id=d.onlineappid left join metadata m on d.uuid=m.uuid from onlineapp o left join dataorder d on o.id=d.onlineappid left join metadata m on d.uuid=m.uuid
where o.ts_created>='".date('Y-').(date('m')-1)."-1' and o.ts_created<'".date('Y-m')."-1' and d.status=0 order by o. ts_created where o.ts_created>='".$ym."' and o.ts_created<'".date('Y-m')."-1' and d.status=0 order by o. ts_created
"; ";
$re = $this->db->query($sql); $re = $this->db->query($sql);
$rows = $re->fetchAll(); $rows = $re->fetchAll();

View File

@ -1,7 +1,6 @@
<ul class="nav nav-pills nav-stacked well"> <ul class="nav nav-pills nav-stacked well">
<span class="label"><h4>申请管理与在线下载记录</h4></span> <span class="label"><h4>申请管理与在线下载记录</h4></span>
<li><a href="/admin/down/offlineapp">离线数据申请管理</a></li> <li><a href="/admin/down/offlineapp">离线数据申请管理</a></li>
<li><a href="/admin/down/offlineapps">离线数据申请管理(新)</a></li>
<li><a href="/admin/down/offline">离线数据服务记录</a></li> <li><a href="/admin/down/offline">离线数据服务记录</a></li>
<li><a href="/admin/down/fixoffline">手动同步离线申请用户与网站帐号</a></li> <li><a href="/admin/down/fixoffline">手动同步离线申请用户与网站帐号</a></li>
<li><a href="/admin/down/online">在线数据下载记录从20110908开始</a></li> <li><a href="/admin/down/online">在线数据下载记录从20110908开始</a></li>

View File

@ -2,75 +2,85 @@
$this->headTitle($this->config->title->site); $this->headTitle($this->config->title->site);
$this->headTitle('后台管理'); $this->headTitle('后台管理');
$this->headTitle()->setSeparator(' - '); $this->headTitle()->setSeparator(' - ');
$this->headLink()->appendStylesheet('/css/admin.css');
$this->breadcrumb('<a href="/">首页</a>'); $this->breadcrumb('<a href="/">首页</a>');
$this->breadcrumb('<a href="/admin">后台首页</a>'); $this->breadcrumb('<a href="/admin">后台首页</a>');
$this->breadcrumb('<a href="/admin/down">申请管理</a>'); $this->breadcrumb('<a href="/admin/down">申请管理</a>');
$this->headScript()->appendFile('/js/jquery-1.7.min.js'); $this->Theme->AppendPlus($this,'colorbox');
$this->headScript()->appendFile('/js/jquery.colorbox-min.js'); $this->Theme->AppendPlus($this,'uploadify');
$this->headLink()->appendStylesheet('/css/author.css');
$this->headLink()->appendStylesheet('/css/colorbox.css');
$this->breadcrumb('离线数据申请管理</a>'); $this->breadcrumb('离线数据申请管理</a>');
$this->breadcrumb()->setSeparator(' > '); $this->breadcrumb()->setSeparator(' > ');
?> ?>
<div id="leftPanel"> <style>
<?= $this->partial('down/left.phtml'); ?> table thead tr th {background:#EBF2F6;color:#444;}
</div> .high{background:#444;color:#FFF;}
<div id="rightPanel"> </style>
<?php if ($this->msg or $this->messages) :?> <div class="row-fluid">
<div id="message"> <div class="span3">
<?php if ($this->msg) : ?> <?= $this->partial('down/left.phtml'); ?>
<p><?php echo $this->msg; ?></p>
<?php endif; if ($this->messages): foreach($this->messages as $msg): ?>
<p><?php echo $msg; ?></p>
<?php endforeach;endif; ?>
</div>
<?php endif; ?>
<div class="right_title">离线数据服务记录</div>
<a href="/admin/down/offline/add/1">添加新的离线服务记录</a> | <a href="/admin/down/offline/down/1">下载所有离线服务记录</a> | <a href="/admin/down/offline/update/1" onclick="return confirm('该操作需要较长时间,请不要中途刷新页面,是否确定继续?')">自动匹配离线下载用户与网站用户</a> | <a href="/admin/down/offline/emaillist/1">下载服务用户邮箱列表</a>
| <a href="/admin/down/offline/monthreport/1">下载上月服务记录(科技部上报)</a>
<div>
<div class="input-append">
<form id="datasearch" class="search_form" action="">
<input type="text" id="keyword" name="q" value="<?php if(!empty($this->q)) echo $this->q; ?>" />
<input type="hidden" name="order" value="<?php if(!empty($this->search_order)) echo $this->search_order; ?>" />
<input type="hidden" name="sort" value="<?php if(!empty($this->search_sort)) echo $this->search_sort; ?>" />
<button type="submit" class="btn" id="search_btn">搜索</button>
</form>
</div> </div>
</div> <div class="span9">
<?php if ($this->msg or $this->messages) :?>
<div id="message">
<?php if ($this->msg) : ?>
<p><?php echo $this->msg; ?></p>
<?php endif; if ($this->messages): foreach($this->messages as $msg): ?>
<p><?php echo $msg; ?></p>
<?php endforeach;endif; ?>
</div>
<?php endif; ?>
<h4>离线数据服务记录</h4>
<div class="pull-left">
<a href="/admin/down/offline/add/1" class="btn btn-info">添加新的离线服务记录</a>
<a href="/admin/down/offline/down/1" class="btn btn-info">下载所有离线服务记录</a>
<a href="/admin/down/offline/update/1" class="btn btn-info" onclick="return confirm('该操作需要较长时间,请不要中途刷新页面,是否确定继续?')">自动匹配离线下载用户与网站用户</a>
<a href="/admin/down/offline/emaillist/1" class="btn btn-info">下载服务用户邮箱列表</a>
<a href="/admin/down/offline/monthreport/1" class="btn btn-info">下载上月服务记录(科技部上报)</a>
</div>
<div class="input-append pull-right">
<form id="datasearch" class="search_form" action="">
<input type="text" id="keyword" name="q" value="<?php if(!empty($this->q)) echo $this->q; ?>" />
<input type="hidden" name="order" value="<?php if(!empty($this->search_order)) echo $this->search_order; ?>" />
<input type="hidden" name="sort" value="<?php if(!empty($this->search_sort)) echo $this->search_sort; ?>" />
<button type="submit" class="btn" id="search_btn">搜索</button>
</form>
</div>
<?php if (count($this->paginator)): ?> <?php if (count($this->paginator)): ?>
<table> <table class="table table-bordered table-hover">
<thead><tr> <thead>
<th width='70'>姓名</th> <tr>
<th width='150'>单位</th> <th width="52">姓名</th>
<th width='150'>地址</th> <th>单位</th>
<th width='50'>邮编</th> <th>地址</th>
<th width='300'>用途</th> <th>邮编</th>
<th width='300'>数据清单</th> <th>用途</th>
<th width='120'>申请时间</th> <th>数据清单</th>
<th width='100'>操作</th> <th>申请时间</th>
<th>操作</th>
</tr></thead> </tr></thead>
<tbody> <tbody>
<?php $autoindex=0;?> <?php $autoindex=0;?>
<?php foreach ($this->paginator as $item): ?> <?php foreach ($this->paginator as $item): ?>
<?php $autoindex++;?> <?php $autoindex++;?>
<tr class="<?php if($autoindex%2 == 0) echo 'even'; else echo 'odd'; ?>"> <tr class="<?php if($autoindex%2 == 0) echo 'even'; else echo 'odd'; ?>">
<td><a href="/admin/user/show/id/<?php echo $item['userid'];?>"><img src="/images/user.gif" /></a> <a href="/admin/down/user/show/<?php echo $item['userid'];?>"><?= $item['username']?></a> </td> <td><a href="/admin/down/user/show/<?php echo $item['userid'];?>"><?= $item['username']?></a></td>
<td><?= $item['unit']; ?></td> <td><?= $item['unit']; ?></td>
<td><?= $item['address']; ?></td> <td><?= $item['address']; ?></td>
<td><?= $item['postcode']; ?></td> <td><?= $item['postcode']; ?></td>
<td><textarea readonly="readonly" style="width:300px;height:100px;border:none;font-size:12px;<?php if($autoindex%2 == 0) echo 'background:#CCCCCC;'; else echo 'background:#FFF;'; ?>"><?= $item['project'].'['.$item['project_title'].' | '.$item['project_type'].' | '.$item['project_id'].']'; ?></textarea></td> <td><textarea readonly="readonly" style="width:280px;height:100px;border:none;font-size:12px;"><?= $item['project'].'['.$item['project_title'].' | '.$item['project_type'].' | '.$item['project_id'].']'; ?></textarea></td>
<td><textarea readonly="readonly" style="width:300px;height:100px;border:none;font-size:12px;<?php if($autoindex%2 == 0) echo 'background:#CCCCCC;'; else echo 'background:#FFF;'; ?>"><?= $item['datalist']; ?></textarea></td> <td><textarea readonly="readonly" style="width:280px;height:100px;border:none;font-size:12px;"><?= $item['datalist']; ?></textarea></td>
<td><?= date('Y-m-d',strtotime($item['ts_created'])); ?></td> <td><?= date('Y-m-d',strtotime($item['ts_created'])); ?></td>
<td> <td>
<a href="/admin/down/offline/edit/<?= $item['id']; ?><?php if(empty($this->page)) "" ; else echo "/page/".$this->page; ?>">编辑</a> | <a href="/admin/down/offline/edit/<?= $item['id']; ?><?php if(empty($this->page)) "" ; else echo "/page/".$this->page; ?>">编辑</a> |
<a href="/admin/down/offline/delete/<?= $item['id']; ?>" title="该操作将删除此记录并且删除与此记录有关的申请记录!请谨慎操作" onclick="return confirm('请仅删除测试用途的离线服务记录!')">删除</a> | <a href="/admin/down/offline/delete/<?= $item['id']; ?>" title="该操作将删除此记录并且删除与此记录有关的申请记录!请谨慎操作" onclick="return confirm('请仅删除测试用途的离线服务记录!')">删除</a> |
<a href="/admin/down/offlineapp/view/<?= $item['id']; ?>">PDF</a> | <a href="/admin/down/offlineapp/view/<?= $item['id']; ?>">PDF</a> |
<a href="/admin/down/offline/show/<?= $item['id']; ?>">详细</a> | <a href="/admin/down/offline/show/<?= $item['id']; ?>">详细</a> |
<a href="javascript:action('finish',<?= $item['id']; ?>);" onclick="return confirm('确定确定重新通过该申请?')">重新通过</a> <a href="javascript:action('finish',<?= $item['id']; ?>);" onclick="return confirm('确定确定重新通过该申请?')">重新通过</a> |
<a href="javascript:void(0);" onclick="upload.showUploadForm(<?= $item['id'] ?>);">上传签字申请表</a>
<?php if(!empty($item['applicationform'])) { ?>
| <a href="/admin/down/applicationform/ac/view/?link=<?= urlencode($item['applicationform'])?>">查看签字申请表</a>
<?php }?>
</td> </td>
</tr> </tr>
<?php endforeach; ?> <?php endforeach; ?>
@ -78,6 +88,64 @@
<?php endif; ?> <?php endif; ?>
<div class="pagenavi"><?= $this->paginator; ?></div> <div class="pagenavi"><?= $this->paginator; ?></div>
</div> </div>
</div><!-- row -->
<div id="upload-form" class="modal hide fade" tabindex="-1" aria-hidden="true">
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal" aria-hidden="true">×</button>
<h3 id="myModalLabel">申请表上传</h3>
</div>
<div class="modal-body">
<form id="application-form">
<div id="fsUploadProgress">允许上传30M以内的 PDF 文件</div>
<input type="file" name="Filedata" id="file_upload" />
</form>
</div>
<div class="modal-footer">
<button class="btn" data-dismiss="modal" aria-hidden="true">取消上传</button>
<button class="btn btn-primary">上传完成</button>
</div>
</div>
<script>
//var param = {};
//var upload_count = 0;
var uploader;
var param;
$(function() {
$('#file_upload').uploadify({
'swf' : '/js/lib/uploadify/uploadify.swf',
'uploader' : '/admin/down/uploadapplicationform',
'multi' : false,
'auto' : true,
'fileTypeExts' : '*.pdf; *.jpg',
'onUploadSuccess' : function(file, data, response) {
upload.onsuccess(file, data, response);
},
'onUploadStart' : function(file) {
$('#file_upload').uploadify('settings','formData',param);
}
});
});
var upload = {
onsuccess : function(file, data, response){
_data = $.parseJSON(data);
if(!$.isEmptyObject(_data.error))
{
alert(_data.error);
}else{
$('#upload-form').modal('hide');
window.location = window.location;
}
},
showUploadForm : function(id){
$('#upload-form').modal('show');
param = {
"PHPSESSID" : "<?php echo session_id(); ?>",
'orderid' : id
};
}
};
</script>
<script> <script>
function action(name,id){ function action(name,id){
var url; var url;

View File

@ -2,55 +2,58 @@
$this->headTitle($this->config->title->site); $this->headTitle($this->config->title->site);
$this->headTitle('后台管理'); $this->headTitle('后台管理');
$this->headTitle()->setSeparator(' - '); $this->headTitle()->setSeparator(' - ');
$this->headLink()->appendStylesheet('/css/admin.css');
$this->breadcrumb('<a href="/">首页</a>'); $this->breadcrumb('<a href="/">首页</a>');
$this->breadcrumb('<a href="/admin">后台首页</a>'); $this->breadcrumb('<a href="/admin">后台首页</a>');
$this->breadcrumb('<a href="/admin/down">申请管理</a>'); $this->breadcrumb('<a href="/admin/down">申请管理</a>');
$this->Theme->AppendPlus($this,'colorbox'); $this->Theme->AppendPlus($this,'colorbox');
$this->Theme->AppendPlus($this,'uploadify'); $this->Theme->AppendPlus($this,'uploadify');
$this->headLink()->appendStylesheet('/css/author.css');
$this->breadcrumb('离线数据申请管理</a>'); $this->breadcrumb('离线数据申请管理</a>');
$this->breadcrumb()->setSeparator(' > '); $this->breadcrumb()->setSeparator(' > ');
?> ?>
<div id="leftPanel"> <div class="row-fluid">
<?= $this->partial('down/left.phtml'); ?> <div class="span3">
</div> <?= $this->partial('down/left.phtml'); ?>
<div id="rightPanel"> </div>
<div class="span9">
<?php if ($this->msg or $this->messages) :?>
<div id="message">
<?php if ($this->msg) : ?>
<p><?php echo $this->msg; ?></p>
<?php endif; if ($this->messages): foreach($this->messages as $msg): ?>
<p><?php echo $msg; ?></p>
<?php endforeach;endif; ?>
</div>
<?php endif; ?>
<?php if ($this->msg or $this->messages) :?> <h4>离线数据申请管理</h4>
<div id="message">
<?php if ($this->msg) : ?> <div style="overflow:hidden">
<p><?php echo $this->msg; ?></p> <div class="pull-left">
<?php endif; if ($this->messages): foreach($this->messages as $msg): ?> <a href="/admin/down/offlineapp/reset/-1" onclick="return confirm('是否重置该申请?')" class="btn btn-info">重置1年前的所有未收到申请表的记录</a>
<p><?php echo $msg; ?></p> <a href="/admin/down/offlineapp/status/4" class="btn btn-info">已收到的申请</a>
<?php endforeach;endif; ?> <a href="/admin/down/offlineapp/status/-1" class="btn btn-info">已拒绝的申请</a>
</div> <a href="/admin/down/offlineapp/ac/pending" class="btn btn-info">待处理的申请</a>
<?php endif; ?> <a href="/admin/down/offline" class="btn btn-info">已通过的申请(离线服务记录)</a>
</div>
<div class="right_title">离线数据申请管理</div>
<div class="input-append pull-right">
<a href="/admin/down/offlineapp/reset/-1" onclick="return confirm('是否重置该申请?')">重置1年前的所有未收到申请表的记录</a> <form id="datasearch" class="search_form" action="">
| <a href="/admin/down/offlineapp/status/4">已收到的申请</a> <input type="text" id="keyword" name="q" value="<?php if(!empty($this->q)) echo $this->q; ?>" />
| <a href="/admin/down/offlineapp/status/-1">已拒绝的申请</a> <input type="hidden" name="order" value="<?php if(!empty($this->search_order)) echo $this->search_order; ?>" />
| <a href="/admin/down/offlineapp/ac/pending">待处理的申请</a> <input type="hidden" name="sort" value="<?php if(!empty($this->search_sort)) echo $this->search_sort; ?>" />
| <a href="/admin/down/offline">已通过的申请(离线服务记录)</a> <button type="submit" class="btn" id="search_btn">搜索</button>
<div class="search"> </form>
<form action="/admin/down/offlineapp" method="get"> </div>
<input name="search" value="1" type="hidden"> </div>
<ul>
<li><input name="q" value="" type="text" placeholder="搜索关键字"></li> <div id="datalist" style="overflow:hidden">
<li><input class="searchbtn" value="搜索" type="submit"></li>
</ul>
</form>
</div>
<div id="datalist">
<?php <?php
if (count($this->paginator)): if (count($this->paginator)):
echo "<ul>"; echo '<ul class="unstyled">';
$autoindex=0; $autoindex=0;
foreach ($this->paginator as $item): foreach ($this->paginator as $item):
$autoindex++;?> $autoindex++;?>
<li id="list_<?php echo $item['id'];?>"> <li id="list_<?php echo $item['id'];?>" class="well well-small">
<p> <p>
<?= $autoindex ?>. <?= $autoindex ?>.
<a href="mailto:<?= $item['email']; ?>?subject=答复数据申请问题"><?= $item['username']; ?></a> | <a href="mailto:<?= $item['email']; ?>?subject=答复数据申请问题"><?= $item['username']; ?></a> |
@ -90,6 +93,7 @@
endif; ?> endif; ?>
<div class="pagenavi"><?= $this->paginator; ?></div> <div class="pagenavi"><?= $this->paginator; ?></div>
</div> </div>
</div>
</div> </div>
<div id="upload-form" class="modal hide fade" tabindex="-1" aria-hidden="true"> <div id="upload-form" class="modal hide fade" tabindex="-1" aria-hidden="true">
<div class="modal-header"> <div class="modal-header">

View File

@ -9,153 +9,224 @@ namespace Files;
*/ */
class Thumbnail { class Thumbnail {
private $maxWidth; private $maxWidth;
private $maxHeight; private $maxHeight;
private $scale; private $scale;
private $inflate; private $inflate;
private $types; private $types;
private $imgLoaders; private $imgLoaders;
private $imgCreators; private $imgCreators;
private $source; private $source;
private $sourceWidth; private $sourceWidth;
private $sourceHeight; private $sourceHeight;
private $sourceMime; private $sourceMime;
private $thumb; private $thumb;
private $thumbWidth; private $thumbWidth;
private $thumbHeight; private $thumbHeight;
public function __construct($maxWidth, $maxHeight, $scale = true, $inflate = false) { public function __construct($maxWidth, $maxHeight, $scale = true, $inflate = false) {
$this->maxWidth = $maxWidth; $this->maxWidth = $maxWidth;
$this->maxHeight = $maxHeight; $this->maxHeight = $maxHeight;
$this->scale = $scale; $this->scale = $scale;
$this->inflate = $inflate; $this->inflate = $inflate;
$this->types = array( $this->types = array(
'image/jpeg', 'image/jpeg',
'image/png', 'image/png',
'image/gif' 'image/gif'
); );
//加载MIME类型图像的函数名称 //加载MIME类型图像的函数名称
$this->imgLoaders = array( $this->imgLoaders = array(
'image/jpeg' => 'imagecreatefromjpeg', 'image/jpeg' => 'imagecreatefromjpeg',
'image/png' => 'imagecreatefrompng', 'image/png' => 'imagecreatefrompng',
'image/gif' => 'imagecreatefromgif' 'image/gif' => 'imagecreatefromgif'
); );
//储存创建MIME类型图片的函数名称 //储存创建MIME类型图片的函数名称
$this->imgCreators = array( $this->imgCreators = array(
'image/jpeg' => 'imagejpeg', 'image/jpeg' => 'imagejpeg',
'image/png' => 'imagepng', 'image/png' => 'imagepng',
'image/gif' => 'imagegif' 'image/gif' => 'imagegif'
); );
} }
/**
* 文件方式加载图片 /**
* @param string $image 源图片 * 文件方式加载图片
* @return bool * @param string $image 源图片
*/ * @return bool
public function loadFile($image){ */
if(!$dims = @getimagesize($image)){ public function loadFile($image){
trigger_error("源图片不存在"); if(!$dims = @getimagesize($image)){
} trigger_error("源图片不存在");
if(in_array($dims['mime'], $this->types)){ }
$loader = $this->imgLoaders[$dims['mime']]; if(in_array($dims['mime'], $this->types)){
$this->source = $loader($image); $loader = $this->imgLoaders[$dims['mime']];
if($dims['mime'] == 'image/png' || $dims['mime'] == 'image/gif'){ $this->source = $loader($image);
imagesavealpha($this->source, true); if($dims['mime'] == 'image/png' || $dims['mime'] == 'image/gif'){
} imagesavealpha($this->source, true);
$this->sourceWidth = $dims[0];
$this->sourceHeight = $dims[1];
$this->sourceMime = $dims['mime'];
$this->initThumb();
return TRUE;
}else{
trigger_error('不支持'.$dims['mime']."图片类型");
}
}
/**
* 字符串方式加载图片
* @param string $image 字符串
* @param string $mime 图片类型
* @return type
*/
public function loadData($image,$mime){
if(in_array($mime, $this->types)){
if($this->source = @imagecreatefromstring($image)){
$this->sourceWidth = imagesx($this->source);
$this->sourceHeight = imagesy($this->source);
$this->sourceMime = $mime;
$this->initThumb();
return TRUE;
}else{
trigger_error("不能从字符串加载图片");
}
}else{
trigger_error("不支持".$mime."图片格式");
}
}
/**
* 生成缩略图
* @param string $file 文件名。如果不为空则储存为文件,否则直接输出到浏览器
*/
public function buildThumb($file = NULL){
$creator = $this->imgCreators[$this->sourceMime];
if(isset($file) && $this->thumb !== NULL){
return $creator($this->thumb,$file);
}else{
return false;
}
}
/**
* 处理缩放
*/
public function initThumb(){
if($this->scale){
if($this->sourceWidth > $this->sourceHeight){
$this->thumbWidth = $this->maxWidth;
$this->thumbHeight = floor($this->sourceHeight*($this->maxWidth/$this->sourceWidth));
}elseif($this->sourceWidth < $this->sourceHeight){
$this->thumbHeight = $this->maxHeight;
$this->thumbWidth = floor($this->sourceWidth*($this->maxHeight/$this->sourceHeight));
}else{
$this->thumbWidth = $this->maxWidth;
$this->thumbHeight = $this->maxHeight;
}
}
if($this->sourceWidth <= $this->maxWidth && $this->sourceHeight <= $this->maxHeight && $this->inflate == FALSE){
$this->thumb = NULL;
}else{
$this->thumb = imagecreatetruecolor($this->thumbWidth, $this->thumbHeight);
if($this->sourceMime == 'image/png' || $this->sourceMime == 'image/gif')
{
imagealphablending($this->thumb, true);
imagesavealpha($this->thumb, true);
if($this->sourceMime == 'image/gif')
{
$bgcolor=imagecolorallocate($this->thumb,0,0,0);
$transparent = imagecolortransparent($this->thumb,$bgcolor) ;
}
if($this->sourceMime == 'image/png')
{
$transparent = imagecolorallocatealpha($this->thumb, 0, 0, 0, 127);
}
imagefill($this->thumb, 0, 0, $transparent);
} }
imagecopyresampled($this->thumb, $this->source, 0, 0, 0, 0, $this->thumbWidth, $this->thumbHeight, $this->sourceWidth, $this->sourceHeight); $this->sourceWidth = $dims[0];
} $this->sourceHeight = $dims[1];
} $this->sourceMime = $dims['mime'];
$this->initThumb();
public function getMine(){ return TRUE;
return $this->sourceMime; }else{
} trigger_error('不支持'.$dims['mime']."图片类型");
}
public function getThumbWidth(){ }
return $this->thumbWidth;
} /**
* 字符串方式加载图片
public function getThumbHeight(){ * @param string $image 字符串
return $this->thumbHeight; * @param string $mime 图片类型
} * @return type
*/
public function loadData($image,$mime){
if(in_array($mime, $this->types)){
if($this->source = @imagecreatefromstring($image)){
$this->sourceWidth = imagesx($this->source);
$this->sourceHeight = imagesy($this->source);
$this->sourceMime = $mime;
$this->initThumb();
return TRUE;
}else{
trigger_error("不能从字符串加载图片");
}
}else{
trigger_error("不支持".$mime."图片格式");
}
}
/**
* 生成缩略图
* @param string $file 文件名。如果不为空则储存为文件,否则直接输出到浏览器
*/
public function buildThumb($file = NULL){
$creator = $this->imgCreators[$this->sourceMime];
if(isset($file) && $this->thumb !== NULL){
return $creator($this->thumb,$file);
}else{
return false;
}
}
/**
* 处理缩放
*/
public function initThumb(){
if($this->scale){
if($this->sourceWidth > $this->sourceHeight){
$this->thumbWidth = $this->maxWidth;
$this->thumbHeight = floor($this->sourceHeight*($this->maxWidth/$this->sourceWidth));
}elseif($this->sourceWidth < $this->sourceHeight){
$this->thumbHeight = $this->maxHeight;
$this->thumbWidth = floor($this->sourceWidth*($this->maxHeight/$this->sourceHeight));
}else{
$this->thumbWidth = $this->maxWidth;
$this->thumbHeight = $this->maxHeight;
}
}
if($this->sourceWidth <= $this->maxWidth && $this->sourceHeight <= $this->maxHeight && $this->inflate == FALSE){
$this->thumb = NULL;
}else{
$this->thumb = imagecreatetruecolor($this->thumbWidth, $this->thumbHeight);
if($this->sourceMime == 'image/png' || $this->sourceMime == 'image/gif')
{
imagealphablending($this->thumb, true);
imagesavealpha($this->thumb, true);
if($this->sourceMime == 'image/gif')
{
$bgcolor=imagecolorallocate($this->thumb,0,0,0);
$transparent = imagecolortransparent($this->thumb,$bgcolor) ;
}
if($this->sourceMime == 'image/png')
{
$transparent = imagecolorallocatealpha($this->thumb, 0, 0, 0, 127);
}
imagefill($this->thumb, 0, 0, $transparent);
}
imagecopyresampled($this->thumb, $this->source, 0, 0, 0, 0, $this->thumbWidth, $this->thumbHeight, $this->sourceWidth, $this->sourceHeight);
}
}
public function getMine(){
return $this->sourceMime;
}
public function getThumbWidth(){
return $this->thumbWidth;
}
public function getThumbHeight(){
return $this->thumbHeight;
}
static function cut($source_path, $target_width, $target_height){
$source_info = getimagesize($source_path);
$source_width = $source_info[0];
$source_height = $source_info[1];
$source_mime = $source_info['mime'];
$source_ratio = $source_height / $source_width;
$target_ratio = $target_height / $target_width;
// 源图过高
if ($source_ratio > $target_ratio)
{
$cropped_width = $source_width;
$cropped_height = $source_width * $target_ratio;
$source_x = 0;
$source_y = ($source_height - $cropped_height) / 2;
}
// 源图过宽
elseif ($source_ratio < $target_ratio)
{
$cropped_width = $source_height / $target_ratio;
$cropped_height = $source_height;
$source_x = ($source_width - $cropped_width) / 2;
$source_y = 0;
}
// 源图适中
else
{
$cropped_width = $source_width;
$cropped_height = $source_height;
$source_x = 0;
$source_y = 0;
}
switch ($source_mime)
{
case 'image/gif':
$source_image = imagecreatefromgif($source_path);
break;
case 'image/jpeg':
$source_image = imagecreatefromjpeg($source_path);
break;
case 'image/png':
$source_image = imagecreatefrompng($source_path);
break;
default:
return false;
break;
}
$target_image = imagecreatetruecolor($target_width, $target_height);
$cropped_image = imagecreatetruecolor($cropped_width, $cropped_height);
// 裁剪
imagecopy($cropped_image, $source_image, 0, 0, $source_x, $source_y, $cropped_width, $cropped_height);
// 缩放
imagecopyresampled($target_image, $cropped_image, 0, 0, 0, 0, $target_width, $target_height, $cropped_width, $cropped_height);
header('Content-Type: image/jpeg');
imagejpeg($target_image);
imagedestroy($source_image);
imagedestroy($target_image);
imagedestroy($cropped_image);
}//cute
} }

View File

@ -168,6 +168,8 @@ westdc.dataservice.wsn = {
this.selects = ""; this.selects = "";
this.uls = new Array(); this.uls = new Array();
this.count = 0;
this.first = 0;
for(i in data.data) for(i in data.data)
{ {
this.input = new Array(); this.input = new Array();
@ -185,12 +187,32 @@ westdc.dataservice.wsn = {
+ '<input class="wsnctl-timeend" type="text" name="site['+i+'][endtime]" value="' + data.data[i].endtime + '" />' + '<input class="wsnctl-timeend" type="text" name="site['+i+'][endtime]" value="' + data.data[i].endtime + '" />'
+ '</div>'; + '</div>';
this.uls.push('<div class="wsnctl" rel="'+i+'" style="float:left"><h4>观测点:'+data.data[i].name+'</h4>可下载的变量: '+ this.input.join("") + this.timemap + '<hr /></div>'); this.uls.push('<div class="wsnctl" rel="'+i+'" style="float:left"><h4>观测点:'+data.data[i].name+'</h4>可下载的变量: '+ this.input.join("") + this.timemap + '<hr /></div>');
this.count++;
if(this.count == 1)
{
this.first = i;
}
} }
this.selects = this.uls.join(""); this.selects = this.uls.join("");
if(this.count > 1)
{
this.allcontrol = '<div class="wsnctl">'
+ '<div class="wsnctl-time"><div>为所有数据选择时间范围(如果某些数据的时间超出范围请单独再次修改):</div> '
+ '<input class="wsnctl-all-timestart" type="text" value="' + data.data[this.first].starttime + '" /> - '
+ '<input class="wsnctl-all-timeend" type="text" value="' + data.data[this.first].endtime + '" />'
+ '</div></div><hr />';
}else{
this.allcontrol = "";
}
this.HTML = '<div class=""><div class="modal-header"><h3>'+data.info.service_title+'</h3></div>' this.HTML = '<div class=""><div class="modal-header"><h3>'+data.info.service_title+'</h3></div>'
+ '<div class="modal-body"><form id="dataservice-wsn-form">' + '<div class="modal-body">'
+ this.allcontrol
+ '<form id="dataservice-wsn-form">'
+ '<div>' + '<div>'
+ this.selects + this.selects
+ '</div>' + '</div>'
@ -209,14 +231,17 @@ westdc.dataservice.wsn = {
siteid = $(this).attr('rel'); siteid = $(this).attr('rel');
timestart = $(this).children('.wsnctl-time').children('.wsnctl-timestart'); timestart = $(this).children('.wsnctl-time').children('.wsnctl-timestart');
timeend = $(this).children('.wsnctl-time').children('.wsnctl-timeend'); timeend = $(this).children('.wsnctl-time').children('.wsnctl-timeend');
year_start=(timestart).val().substr(0,4); if(timestart.length && timeend.length)
month_start=parseInt((timestart).val().substr(5,2))-1; {
day_start=parseInt((timestart).val().substr(8,2)); year_start=(timestart).val().substr(0,4);
year_end=(timeend.val()).substr(0,4); month_start=parseInt((timestart).val().substr(5,2))-1;
month_end=parseInt((timeend.val()).substr(5,2))-1; day_start=parseInt((timestart).val().substr(8,2));
day_end=parseInt((timeend.val()).substr(8,2)) year_end=(timeend.val()).substr(0,4);
timestart.datepicker({ minDate: new Date(year_start, month_start, day_start), maxDate: new Date(year_end, month_end, day_end) }); month_end=parseInt((timeend.val()).substr(5,2))-1;
timeend.datepicker({ minDate: new Date(year_start, month_start, day_start), maxDate: new Date(year_end, month_end, day_end) }); day_end=parseInt((timeend.val()).substr(8,2));
timestart.datepicker({ minDate: new Date(year_start, month_start, day_start), maxDate: new Date(year_end, month_end, day_end) });
timeend.datepicker({ minDate: new Date(year_start, month_start, day_start), maxDate: new Date(year_end, month_end, day_end) });
}
$(this).find('.wsnctl-select-all').click(function(e) { $(this).find('.wsnctl-select-all').click(function(e) {
if($(this).attr('checked') == 'checked') if($(this).attr('checked') == 'checked')
{ {
@ -225,6 +250,28 @@ westdc.dataservice.wsn = {
$(this).parent('label').parent('div').find('.wsnctl-select').removeAttr('disabled'); $(this).parent('label').parent('div').find('.wsnctl-select').removeAttr('disabled');
} }
}); });
alltimestart = $(this).children('.wsnctl-time').children('.wsnctl-all-timestart');
alltimeend = $(this).children('.wsnctl-time').children('.wsnctl-all-timeend');
if(alltimestart.length)
{
alltimestart.datepicker({});
alltimestart.change(function(e) {
val = $(this).val();
$('.wsnctl').each(function(index, element) {
$(this).children('.wsnctl-time').children('.wsnctl-timestart').val(val);
});
});
}
if(alltimeend.length)
{
alltimeend.datepicker({});
alltimeend.change(function(e) {
val = $(this).val();
$('.wsnctl').each(function(index, element) {
$(this).children('.wsnctl-time').children('.wsnctl-timeend').val(val);
});
});
}
}); });
} }
} }