<?php if(!defined('IN_DISCUZ')) exit('Access Denied'); ?><?php
$return = <<<EOF

<style>
.labeltitle {
font-weight: bold;
}

.xjmenu {
height: 32px;
}

.xjmenu_a {
width: 80px;
line-height: 32px;
float: left;
height: 32px;
text-align: center;
border-top: #c2d5e3 1px dashed;
border-left: #c2d5e3 1px dashed;
border-right: #c2d5e3 1px dashed;
background-color: #e5edf2;
margin-left: 10px;
font-weight: bold;
cursor: pointer;
}

.xjmenu_b {
width: 80px;
line-height: 32px;
float: left;
height: 32px;
text-align: center;
margin-left: 10px;
cursor: pointer;
}

.xjmain {
border: #c2d5e3 1px dashed;
background-color: #e5edf2;
padding: 15px;
margin-bottom: 10px;
}

.xjmain label {
font-weight: bold;
width: 80px;
display: inline-block;
height: 30px;
}

.xjmain i {
color: #FF0000;
float: right;
}

.xjmain span {
color: #999999;
}
</style>
<script language="javascript">
function getmb(selObj) {
//ʵ����Ajax
var ajax = null;
if(window.XMLHttpRequest) {
ajax = new XMLHttpRequest();
} else if(window.ActiveXObject) {
ajax = new ActiveXObject("Microsoft.XMLHTTP");
} else {
return;
}
if(selObj.options[selObj.selectedIndex].value != '') {
//��ҪPOST��ֵ����ÿ��������ͨ��&������ 
var postStr = "file=" + selObj.options[selObj.selectedIndex].value;
//ͨ��Get��ʽ������
ajax.open("POST", "plugin.php?id=xj_event:event_template", true);
//ajax.setRequestHeader("Content-Type","text/html;charset=gb2312");
ajax.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
ajax.send(postStr);
//�������ݵĴ�����
ajax.onreadystatechange = function() {
if(ajax.readyState == 4 && ajax.status == 200) {
var gainstr = ajax.responseText;
gainstr = bbcode2html(gainstr);
//if(BROWSER.ie) {
insertText(gainstr, gainstr.length, 0);
//}
}
}
}
}

</script>

<ul class="xjmenu">
<li class="xjmenu_a" onclick="remenu(1)" id="xjmenu1">线下活动</li>
<li class="xjmenu_b" onclick="remenu(2)" id="xjmenu2">线上活动</li>

EOF;
if($module_eventurl) {
    $return .= <<<EOF
<li class="xjmenu_b" onclick="remenu(3)" id="xjmenu3">外链活动</li>
EOF;
}
$return .= <<<EOF

</ul>
<input type="hidden" name="postclass" id="postclass" value="1" />
<div class="xjmain" id="event1">
<dd>
<label>活动时间:<i>*</i></label>
<input type="text" name="starttime" id="starttime" class="px" onclick="showcalendar(event, this, true)" autocomplete="off" value="" tabindex="1" /> ~
<input type="text" name="endtime" id="endtime" class="px" onclick="showcalendar(event, this, true)" autocomplete="off" value="" tabindex="2" />
</dd>
<dd id="offlineclass_dd">
<label>活动类型:<i>*</i></label>
<select name="offlineclass" id="offlineclass" class="ps">
EOF;
if(is_array($offlineclass)) foreach($offlineclass as $key => $value) {
    $return .= <<<EOF
<option value="{$value['0']}">{$value['1']}</option>

EOF;
}
$return .= <<<EOF

</select>
</dd>
<dd id="onlineclass_dd" style="display:none;">
<label>活动类型:<i>*</i></label>
<select name="onlineclass" id="onlineclass" class="ps">
EOF;
if(is_array($onlineclass)) foreach($onlineclass as $key => $value) {
    $return .= <<<EOF
<option value="{$value['0']}">{$value['1']}</option>

EOF;
}
$return .= <<<EOF

</select>
</dd>


EOF;
if(!$_G['cache']['plugin']['xj_event']['event_city']) {
    $return .= <<<EOF

<dd id="citys_dd">
<label>活动地区:</label>
<select name="citys" id="citys" class="ps">
EOF;
    if(is_array($citys)) foreach($citys as $key => $value) {
        $return .= <<<EOF
<option value="{$value}">{$value}</option>

EOF;
    }
    $return .= <<<EOF

</select>
</dd>

EOF;
} else {
    $return .= <<<EOF

<dd id="citys_dd">
<label>活动地区:</label>

<select id="shen" onChange="goGo(this.options.selectedIndex);">
<option value="" selected>{$lang_province}</option>
EOF;
    if(is_array($province)) foreach($province as $key => $value) {
        $return .= <<<EOF
<option value="{$value['name']}">{$value['name']}</option>

EOF;
    }
    $return .= <<<EOF

</select>

<select id="city" name="citys">
<option value="" selected>{$lang_city}</option>
</select>

</dd>
    
    <script>
var groups = document.getElementById("shen").options.length;
var group = new Array(groups);
for(i = 0; i < groups; i++){
group[i] = new Array();
}
group[0][0] = new Option("{$lang_city}", "");
EOF;
    if(is_array($city)) foreach($city as $key => $value) {
        $return .= <<<EOF
group[{$value['upid']}][{$value['displayorder']}] = new Option("{$value['name']}", "{$value['name']}");

EOF;
    }
    $return .= <<<EOF

function goGo(x) {
var tempff = document.getElementById("city");
for(m = tempff.options.length - 1; m > 0; m--)
tempff.options[m] = null;
for(i = 0; i < group[x].length; i++) {
tempff.options[i] = new Option(group[x][i].text, group[x][i].value);
}
tempff.options[0].selected = true;
}
</script>

EOF;
}
$return .= <<<EOF


<dd id="event_address_dd">
<label>活动地点:<i>*</i></label>
<input type="text" name="event_address" id="event_address" value="" class="px" />
<span>填写活动的详细地址</span></dd>
<dd id="event_number_dd">
<label>活动人数:</label>
<input name="event_number" type="text" class="px" id="event_number" value="0" size="10" />
</dd>
<dd id="event_number_max_dd">
<label>最多可报:</label>
<input name="event_number_max" type="text" class="px" id="event_number_max" value="1" size="10" />
<span>指报名者可一次最多报名的人数</span></dd>
<dd id="use_extcredits_num_dd">
<label>积分支付:</label>
<input type="text" name="use_extcredits_num" id="use_extcredits_num" value="" class="px" />
<select name="use_extcredits" id="use_extcredits" class="ps">
<option value=""> 请选择 </option>
EOF;
if(is_array($extcredits)) foreach($extcredits as $key => $value) {
    $return .= <<<EOF
<option value="{$key}">{$value['title']}</option>

EOF;
}
$return .= <<<EOF

</select>
<span>报名活动需要支付的积分，不可与人民币组合支付</span></dd>
<dd id="use_cost_dd">
<label>每人费用:</label>
<input type="text" name="use_cost" id="use_cost" value="0" class="px" /> <span>免费请填0</span> <input type="checkbox" name="eventpay" id="eventpay" class="pc" value="1" /> 启用在线支付 <input type="checkbox" name="eventaa" id="eventaa" class="pc" value="1" 
EOF;
if($setting['eventaa']) {
    $return .= <<<EOF
checked

EOF;
}
$return .= <<<EOF
/> AA (费用不确定时选择)
</dd>

<script>
function addcost() {
$('gengduofeiyong').outerHTML = '<p style=" padding:5px 0px;">名称：<input type="text" name="cost_name[]" value="" class="px"/> 费用:<input type="text" name="cost_price[]" value="0" style="width:40px;"/>元 积分:<input type="text" name="cost_credits[]" value="0" style="width:40px;"/> VIP优惠:<input type="text" name="cost_youhui[]" value="" style="width:40px;"/>元 <a href="javascript:;" class="winfloor_d" onclick="delitem(this)">删除</a></p>' + $('gengduofeiyong').outerHTML;
}
</script>
<dd id="morecost_dd">
<label>多种报名收费:</label>
<a href="javascript:;" onclick="addcost()" style="padding:3px 10px; background-color: #06C; color:#FFF;">+ 增加一项</a> (如：儿童费用、老人费用等)
<div id="gengduofeiyong" style="padding-bottom:10px;">

</div>
</dd>

<dd id="vip_discount_dd">
<label>优惠方式:</label>VIP优惠<input name="vip_discount" type="text" class="px" id="vip_discount" value="{$setting['vip_discount']}" size="10" />元 ,手机app报名优惠 <input type="text" name="app_benefit" value="" class="px" size="10" />元
</dd>

<dd id="baomingshijing_dd">
<label>报名截止:<i>*</i></label>
<input type="text" name="activitybegin" id="activitybegin" class="px" onclick="showcalendar(event, this, true)" autocomplete="off" value="" tabindex="1" /> ~
<input type="text" name="activityexpiration" id="activityexpiration" class="px" onclick="showcalendar(event, this, true)" autocomplete="off" value="" tabindex="1" />
<span>活动报名时间段，在时间段以外就无法报名</span></dd>


EOF;
if($_G['groupid']==1 ) {
    $return .= <<<EOF

<dd id="">
<label>活动排序:<i>*</i></label>
<input type="text" name="eventorder" id="eventorder" class="px" value="0" />
<span>数值越大越靠前</span>
</dd>

EOF;
}
$return .= <<<EOF


<dd id="userfield_dd">
<label>必填资料项:</label>
EOF;
if(is_array($userfield)) foreach($userfield as $key => $val) {
    $return .= <<<EOF
<input type="checkbox" name="userfield[]" id="userfield_{$key}" class="pc" value="{$key}" 
EOF;
    if($activity[ 'ufield'][ 'userfield'] && in_array($key, $activity[ 'ufield'][ 'userfield'])) {
        $return .= <<<EOF
 checked="checked" 
EOF;
    }
    $return .= <<<EOF
 /> {$val}

EOF;
} if(is_array($myuserfield)) foreach($myuserfield as $val) {
    $return .= <<<EOF
<input type="checkbox" name="myuserfield[]" id="myuserfield_{$val['id']}" class="pc" value="{$val['id']}" />{$val['title']}

EOF;
}
$return .= <<<EOF


<input type="checkbox" name="userfield[]" checked="checked" id="userfield_message" class="pc" value="bmmessage" /> 留言 </dd>
<dd id="setting_dd">
<label>设置选项:</label>
<input type="checkbox" name="noverify" id="noverify" class="pc" value="1" />报名不审核
<input type="checkbox" name="statements" id="statements" class="pc" value="1" />报名显示活动声明
<input type="checkbox" name="seccode" id="seccode" class="pc" value="1" />报名验证码
<input type="checkbox" name="reply" id="reply" class="pc" value="1" />回复才可报名
<input type="checkbox" name="nodaibaoming" id="nodaibaoming" class="pc" value="1" />代报名无需填资料
<input type="checkbox" name="success_sms" id="success_sms" class="pc" value="1" />报名成功短信
</dd>
<dd id="event_template_dd">
<label>活动模板:</label>
<select name="event_template" id="event_template" class="ps" onchange="getmb(this);">
<option value="">选择模板</option>
EOF;
if(is_array($event_template)) foreach($event_template as $key => $value) {
    $return .= <<<EOF
<option value="{$value['1']}">{$value['0']}</option>

EOF;
}
$return .= <<<EOF

</select>

EOF;
if($_G['groupid']==1) {
    $return .= <<<EOF

<a href="plugin.php?id=xj_event:event_template&amp;act=manage" target="_blank" style="color:#0066CC;">模板管理</a>

EOF;
}
$return .= <<<EOF

</dd>
<dd id="eventzy_enable_dd">
<label>活动作业:</label>
<input type="checkbox" name="eventzy_enable" id="eventzy_enable" class="pc" value="1" onclick="showblock('eventzy','eventzy_enable');" checked="checked" /> 启用
<div style="padding:0px 10px 10px 10px;" id="eventzy">
显示名称:
<select name="eventzy_name" id="eventzy_name" class="ps">
<option value="作业" selected="selected">作业</option>
<option value="作品">作品</option>
<option value="分享">分享</option>
<option value="记录">记录</option>
</select>

EOF;
if($_G['cache']['plugin']['xj_event']['homeword_forum']) {
    $return .= <<<EOF

<input name="eventzy_fid" type="hidden" value="{$_G['cache']['plugin']['xj_event']['homeword_forum']}" />

EOF;
} else {
    $return .= <<<EOF

发表版块:
<select name="eventzy_fid" id="eventzy_fid" class="ps">
<option value="0" selected="selected">选择版块...</option>
{$forumlist}
</select>

EOF;
}
$return .= <<<EOF


用户发表作业数限制:<input type="text" name="eventzy_xz" class="px" id="eventzy_xz" size="5" />
</div>
</dd>
<dd id="event_admin_dd">
<label>活动管理员:</label>
<input type="text" name="event_admin" class="px" id="event_admin" /> <span>请输入用户名，多个用户请用“,”号分开</span> <input type="text" name="tel" value="" placeholder="活动联系电话" />
</dd>
<dd id="sessionstr_dd">
<label>活动场次:</label>
<textarea name="sessionstr" id="sessionstr" style="width:300px; height:100px;"></textarea>
<span>格式如 <a href="javascript:" onclick="$('sessionstr').value='1=上午场\\r\\n2=下午场';">[范例]</a></span>
</dd>
<dd id="activityaid_url_dd">
<label>活动封面图:</label>
<input type="text" name="activityaid_url" id="activityaid_url" class="px" />
<button type="button" class="pn" onclick="uploadWindow(function (aid, url){activityaid_upload(aid, url)})"><span>上传</span></button>
<span>添加一张好看的图片，让活动更吸引人，建议大小900*500</span>
<input type="hidden" name="activityaid" id="activityaid" />

</dd>
<div id="activityattach_image"> </div>
<dd id="additem_dd">
<label>更多说明项目:</label>
<a href="javascript:;" onclick="additem()" style="padding:3px 10px; background-color: #06C; color:#FFF;">+ 新增一项</a>
</dd>
<dd id="item_hidden_dd">
<p id="item_hidden" style="display:none;">
项目名称:<input name="setting_itemname[]" type="text" class="px" value="" /> 项目内容:<input name="setting_itemcontent[]" type="text" class="px" value="" />
<a href="javascript:;" class="winfloor_d" onclick="delitem(this)">删除</a>
</p>
<span id="item_new"></span>
</dd>
<dd id="event_url_dd">
<label>活动链接:</label>
<input type="text" name="event_url" id="event_url" class="px" />
</dd>
</div>
<div class="xjmain" id="event2"> </div>
<script type="text/javascript" reload="1">
function additem() {
$('item_new').outerHTML = '<p>' + $('item_hidden').innerHTML + '</p>' + $('item_new').outerHTML;
}

function delitem(obj) {
obj.parentNode.parentNode.removeChild(obj.parentNode);
}
additem();

document.getElementById("event2").style.display = "none";
//document.getElementById("sexxzdiv").style.display="none";
document.getElementById("onlineclass_dd").style.display = "none";
var tabindex = 1;

function remenu(a) {
tabindex = a;
for(i = 1; i <= 3; i++) {
if(i == a) {
document.getElementById('xjmenu' + i).className = 'xjmenu_a';
document.getElementById('postclass').value = i;
} else {
document.getElementById('xjmenu' + i).className = 'xjmenu_b';
}
}
if(a == 2) {
document.getElementById("onlineclass_dd").style.display = "block";
document.getElementById("offlineclass_dd").style.display = "none";
document.getElementById("event_address_dd").style.display = "none";
document.getElementById("event_number_max_dd").style.display = "none";

document.getElementById("citys_dd").style.display = "block";
document.getElementById("event_address_dd").style.display = "block";
document.getElementById("event_number_dd").style.display = "block";
document.getElementById("event_number_max_dd").style.display = "block";
document.getElementById("use_extcredits_num_dd").style.display = "block";
document.getElementById("morecost_dd").style.display = "block";
document.getElementById("vip_discount_dd").style.display = "block";
document.getElementById("baomingshijing_dd").style.display = "block";
document.getElementById("userfield_dd").style.display = "block";
document.getElementById("setting_dd").style.display = "block";
document.getElementById("event_template_dd").style.display = "block";
document.getElementById("eventzy_enable_dd").style.display = "block";
document.getElementById("event_admin_dd").style.display = "block";
document.getElementById("sessionstr_dd").style.display = "block";
document.getElementById("additem_dd").style.display = "block";
document.getElementById("item_hidden_dd").style.display = "block";	
}
if(a == 1) {
document.getElementById("onlineclass_dd").style.display = "none";
document.getElementById("offlineclass_dd").style.display = "block";
document.getElementById("event_address_dd").style.display = "block";
document.getElementById("event_number_max_dd").style.display = "block";

document.getElementById("citys_dd").style.display = "block";
document.getElementById("event_address_dd").style.display = "block";
document.getElementById("event_number_dd").style.display = "block";
document.getElementById("event_number_max_dd").style.display = "block";
document.getElementById("use_extcredits_num_dd").style.display = "block";
document.getElementById("morecost_dd").style.display = "block";
document.getElementById("vip_discount_dd").style.display = "block";
document.getElementById("baomingshijing_dd").style.display = "block";
document.getElementById("userfield_dd").style.display = "block";
document.getElementById("setting_dd").style.display = "block";
document.getElementById("event_template_dd").style.display = "block";
document.getElementById("eventzy_enable_dd").style.display = "block";
document.getElementById("event_admin_dd").style.display = "block";
document.getElementById("sessionstr_dd").style.display = "block";
document.getElementById("additem_dd").style.display = "block";
document.getElementById("item_hidden_dd").style.display = "block";	
}
if(a == 3){
document.getElementById("offlineclass_dd").style.display = "block";
document.getElementById("onlineclass_dd").style.display="none";
document.getElementById("citys_dd").style.display = "none";
document.getElementById("event_address_dd").style.display = "none";
document.getElementById("event_number_dd").style.display = "none";
document.getElementById("event_number_max_dd").style.display = "none";
document.getElementById("use_extcredits_num_dd").style.display = "none";
document.getElementById("morecost_dd").style.display = "none";
document.getElementById("vip_discount_dd").style.display = "none";
document.getElementById("baomingshijing_dd").style.display = "none";
document.getElementById("userfield_dd").style.display = "none";
document.getElementById("setting_dd").style.display = "none";
document.getElementById("event_template_dd").style.display = "none";
document.getElementById("eventzy_enable_dd").style.display = "none";
document.getElementById("event_admin_dd").style.display = "none";
document.getElementById("sessionstr_dd").style.display = "none";
document.getElementById("additem_dd").style.display = "none";
document.getElementById("item_hidden_dd").style.display = "none";
}

}

function showsexxz() {
if(document.getElementById("sexxz").checked) {
document.getElementById("sexxzdiv").style.display = "block";
} else {
document.getElementById("sexxzdiv").style.display = "none";
}
}

function showblock(divname, checkname) {
if(document.getElementById(checkname).checked) {
document.getElementById(divname).style.display = "block";
} else {
document.getElementById(divname).style.display = "none";
}
}

function updatecinemaattach(aid, url, attachurl) {
$('activityaid').value = aid;
$('activityattach_image').innerHTML = '<img src="' + attachurl + '/' + url + '" class="spimg" />';
ATTACHORIMAGE = 1;
}

function activityaid_upload(aid, url) {
$('activityaid_url').value = url;

updatecinemaattach(aid, url, 'data/attachment/forum');
}
EXTRAFUNC['validator']['special'] = 'validateextra';

function validateextra() {

if($('postform').activitybegin.value == '' && tabindex != 3) {
showDialog('请填写报名时间', 'alert', '', function() {
$('postform').activitybegin.focus()
});
return false;
}
if($('postform').activityexpiration.value == '' && tabindex != 3) {
showDialog('请填写报名时间', 'alert', '', function() {
$('postform').activityexpiration.focus()
});
return false;
}

if($('postform').starttime.value == '') {
showDialog('抱歉，请输入活动开始时间', 'alert', '', function() {
$('postform').starttime.focus()
});
return false;
}
if($('postform').endtime.value == '') {
showDialog('抱歉，请输入活动结束时间', 'alert', '', function() {
$('postform').endtime.focus()
});
return false;
}
if($('postform').event_address.value == '' && $('postform').postclass.value == '1' && tabindex != 3) {
showDialog('抱歉，请输入活动地点', 'alert', '', function() {
$('postform').event_address.focus()
});
return false;
}
return true;
}


EOF;
if($_GET['postclass']==2) {
    $return .= <<<EOF

remenu(2);

EOF;
}
$return .= <<<EOF

</script>


EOF;
?>