form.html
<style> .clear{width:100%;height:0;clear:both;} .alert{margin:1px 0;padding:10px 15px;background:#F5F5F5;} .item-show .reply-news-list-cover{width:30%;height:100px;float:right;overflow:hidden;} .item-show .reply-news-list-cover img{width:100%;height:auto;} .item-show .reply-news-list-detail{width:65%;float:left;overflow:hidden;height:auto} .item-show .reply-news-list-detail .help-block{margin:5px 0} .item-list-first .reply-news-list-cover{width:100%;height:200px;;overflow:hidden;} .item-list-first .reply-news-list-cover img{width:100%;height:auto;} .item-list-first .reply-news-list-detail{width:100%;position:absolute;bottom:0;left:0;overflow:hidden;height:50px;color:#FFF;filter:Alpha(opacity=70);background:#000;background:rgba(0, 0, 0, 0.7);text-shadow:none;font-family:arial,宋体b8b\4f53,sans-serif;} .item-list-first .help-block{padding:0 10px} .item-list-first .pull-right{position:absolute;bottom:10px;right:0}</style>
</head>
<div class="panel panel-default">
<div class="panel-heading">
选择要邀请的活动
</div>
<div class="panel-body">
<div id="new-reply" class="row {if empty($activity)}hide{/if}">
<div class="reply-item">
<input type="hidden" name="activity" value="{$activity['activityid']}" />
<div class="col-sm-12 item-show item-list-first">
<div class="alert">
<div style="position:relative">
<div class="reply-news-list-cover">
<img src="{$_W['attachurl']}{$activity['thumb']}" />
</div>
<div class="reply-news-list-detail">
<span class="help-block title"><strong>{$activity['title']}</strong></span>
<span class="help-block content">{php echo cutstr(strip_tags($activity['description']), 50)}</span>
</div>
<div class="clear"></div>
</div>
</div>
</div>
</div>
</div>
<div class="col-sm-12">
<div class="alert" style="text-align:center;">
<a href="javascript:;" class="btn btn-default" οnclick="$('#modal-module-menus').modal();"><i class="fa fa-plus"></i> 选择要展示的项目</a>
</div>
</div>
</div>
</div>
<div id="modal-module-menus" class="modal fade" tabindex="-1">
<div class="modal-dialog" style="width: 920px;">
<div class="modal-content">
<div class="modal-header">
<button aria-hidden="true" data-dismiss="modal" class="close" type="button">×</button>
<h3>选择要展示的项目</h3>
</div>
<div class="modal-body">
<div class="row">
<div class="input-group">
<input type="text" class="form-control" name="keyword" value="" id="search-kwd" placeholder="请输入活动名称" />
<span class="input-group-btn"><button type="button" class="btn btn-default" οnclick="search_entries();">搜索</button></span>
</div>
</div>
<div id="module-menus" style="padding-top:5px;"></div>
</div>
<div class="modal-footer">
<a href="#" class="btn btn-default" data-dismiss="modal" aria-hidden="true">关闭</a>
</div>
</div>
</div>
</div>
<script type="text/javascript"> function search_entries() { var kwd = $.trim($('#search-kwd').val()); $.post('{php echo $this->createWebUrl('query');}', {keyword: kwd}, function(dat){ $('#module-menus').html(dat); }); } function select_entry(data) { $('.reply-news-list-cover img').attr('src', '{$_W['attachurl']}' + data.thumb); $('.reply-news-list-detail .title').html("<strong>"+ data.title + "</strong>"); $('.reply-news-list-detail .content').html(data.description); $('#new-reply').removeClass('hide'); $(':hidden[name="activity"]').val(data.activityid); }</script>
</body>
</html>
query.html
<table class="table table-hover">
<tbody>
{loop $ds $item}
<tr>
<td title="{php echo strip_tags($activity['description'])}">{$item['title']}</td>
<td style="width:80px;"><a href="javascript:;" οnclick='select_entry({php echo json_encode($item['entry']);})'>添加</a></td>
</tr>
{/loop}
</tbody>
</table>
module.php
class weisrc_invitativeModule extends WeModule
{
public $name = 'weisrc_invitativeModule';
public $title = '邀请函';
public $ability = '';
public $tablename = 'weisrc_invitative_reply';
public $action = 'detail'; //方法
public $modulename = 'weisrc_invitative'; //模块标识
public function fieldsFormDisplay($rid = 0)
{
global $_W;
if ($rid) {
$reply = pdo_fetch("SELECT * FROM " . tablename($this->modulename . '_reply') . " WHERE rid = :rid", array(':rid' => $rid));
$sql = 'SELECT * FROM ' . tablename($this->modulename . '_activity') . ' WHERE `weid`=:weid AND `id`=:id';
$activity = pdo_fetch($sql, array(':weid' => $_W['uniacid'], ':id' => $reply['activityid']));
}
include $this->template('form');
}
public function fieldsFormSubmit($rid = 0)
{
global $_GPC;
$activityid = intval($_GPC['activity']);
$record = array();
$record['activityid'] = $activityid;
$record['rid'] = $rid;
$reply = pdo_fetch("SELECT * FROM " . tablename($this->modulename . '_reply') . " WHERE rid = :rid", array(':rid' => $rid));
if ($reply) {
pdo_update($this->modulename . '_reply', $record, array('id' => $reply['id']));
} else {
pdo_insert($this->modulename . '_reply', $record);
}
}
}