<extend name="Public/base" />

<block name="body">
<link rel="stylesheet" type="text/css" href="__CSS__/admin_table.css" media="all">
<script type="text/javascript" src="__STATIC__/uploadify/jquery.uploadify.min.js"></script>
<link rel="stylesheet" href="__CSS__/select2.min.css" type="text/css" />
<script type="text/javascript" src="__JS__/select2.min.js"></script>

    
    <div class="cf main-place top_nav_list navtab_list">
    <switch name='ACTION_NAME'>
        <case value="media_edit_adv">
            {:W('Index/navigation',array('value'=>'Site/media','compare'=>'Adv/media_adv_pos_lists'))}
        </case>
        <case value="wap_edit_adv">
            {:W('Index/navigation',array('value'=>'Site/wap','compare'=>'Adv/wap_adv_pos_lists'))}
        </case>
        <case value="promote_edit_adv">
            {:W('Index/navigation',array('value'=>'Site/channel','compare'=>'Adv/promote_adv_pos_lists'))}
        </case>
        <case value="app_edit_adv">
            {:W('Index/navigation',array('value'=>'Site/app','compare'=>'Adv/app_adv_pos_lists'))}
        </case>
    </switch>
        <h3 class="page_title">编辑广告</h3>
        <p class="description_text"></p>
    </div>
    
    
    
    <!-- 标签页导航 -->
<div class="tab-wrap">

    <div class="tab-content tabcon1711">
    <!-- 表单 -->
    <form id="form" action="__SELF__" method="post" class="form-horizontal">
        <!-- 基础文档模型 -->
        <div id="tab1" class="tab-pane in tab1 ">
            <table  border="0" cellspacing="0" cellpadding="0">
                <tbody>
                    <tr>
                        <td class="l">广告标题:</td>
                        <td class="r" >
                           <input type="text" class="txt " name="title" value="{$data['title']}" >
                        </td>
                    </tr>
                    <tr>
                        <td class="l">广告链接:</td>
                        <td class="r" >
                           <input type="text" class="txt " name="url" value="{$data['url']}">
                        </td>
                    </tr>
                      <if condition="($data['pos_id'] eq 16) or ($data['pos_id'] eq 22)">
                      <tr>
                      <td class="l">所属游戏:</td>
                      <td class="r">
                          <select name="game_id" class="select_gallery">
                                <option value="">选择所属游戏</option>
                                <volist name=":get_game_list()" id="vo">
                                    <option value="{$vo.id}" <if condition="$data['game_id'] eq $vo['id']">  selected="selected"</if>>{$vo.game_name}</option>
                                </volist>
                            </select>
                      </td>
                      </tr>
                    </if>
                    <tr>
                        <td class="l">开始时间:</td>
                        <td class="r">
                           <input type="text" class="txt time time1" name="start_time" value="{:set_show_time($data['start_time'],'','other')}" placeholder="默认没有时间限制">
                        </td>
                    </tr>
                    <tr>
                         <td class="l">结束时间:</td>
                        <td class="r">
                          <input type="text" class="txt time time2" name="end_time" value="{:set_show_time($data['end_time'],'','other')}" placeholder="默认没有时间限制">
                        </td>
                    </tr>
                    <tr>
                        <td class="l">广告排序:</td>
                        <td class="r">
                            <input type="text" class="txt" name="sort" value="{$data['sort']}">
                        </td>
                    </tr>
                    <tr>
                        <td class="l">打开方式:</td>
                        <td class="r">
                        <span class="form_radio">
                           <label class="inp_radio">
                                <input type="radio" class="inp_radio" value="_blank" name="target" checked="checked">新页面
                            </label>
                            <label class="inp_radio">
                                <input type="radio" class="inp_radio" value="_self" name="target" >本页面
                            </label></span>
                        </td>
                    </tr>
                    <tr class="picbox">
                        <td class="l"><span style="color:red">*</span>广告图片:</td>
                        <td class="r"><?php $setWidth=intval($advpos['width']);$setHeight=intval($advpos['height']); ?>
                            <input type="file" id="upload_picture_pic">
                            <input type="hidden" name="data" id="pic_id" data-width="{$setWidth}" data-height="{$setHeight}" value="{$data['data']}"/>
                            <div class="upload-img-box">
                            <notempty name="data['data']">
                                <div class="upload-pre-item">
																	<span class="placeholder-graphic placeholder-graphic_adv" style="<if condition='$setWidth egt $setHeight'>width:120px;height:{:intval($setHeight*120/$setWidth)}px<else />width:{:intval($setWidth*120/$setHeight)}px;height:120px;</if>"><img src="{$data['data']|get_cover='path'}"/></span>
																</div>
                            </notempty>
                            </div>
                            <span class="notice-text">({$advpos.width}*{$advpos.height})</span>
                        </td>
                    </tr>
                </tbody>
            </table>
        </div>
        <div class="form-item cf">
            <input type="hidden" name="id" value="{$data['id']}" />
            <button class="submit_btn ajax-post media_edit_adv mlspacing" id="submit" type="submit" target-form="form-horizontal">保存</button>
            <a class="submit_btn " alt="返回上一页" title="返回上一页" href="javascript:window.history.back();" >
                        返回
                    </a>
        </div>
    </form>
    </div>
</div>


<div class="common_settings">
	<span class="plus_icon"><span><img src="__IMG__/zwmimages/icon_jia.png"></span></span>
	<form class="addShortcutIcon">
		<input type="hidden" name="title" value="{$m_title}">
		<input type="hidden" name="url" value="<switch name='ACTION_NAME'><case value='media_edit_adv'>Site/media</case><case value='wap_edit_adv'>Site/wap</case><case value='promote_edit_adv'>Site/channel</case><case value='app_edit_adv'>Site/app</case></switch>">
	</form>
	<a class="ajax-post add-butn <notempty name='commonset'>addSIsetted</notempty>" href="javascript:;" target-form="addShortcutIcon" url="{:U('Think/addShortcutIcon')}"><img src="__IMG__/zwmimages/icon_jia.png"><span><notempty name='commonset'>已添加<else />添加至常用设置</notempty></span></a>
</div>

</block>

<block name="script">
<link href="__STATIC__/datetimepicker/css/datetimepicker.css" rel="stylesheet" type="text/css">
<link href="__STATIC__/datetimepicker/css/dropdown.css" rel="stylesheet" type="text/css">
<script type="text/javascript" src="__STATIC__/datetimepicker/js/bootstrap-datetimepicker.min.js"></script>
<script type="text/javascript" src="__STATIC__/datetimepicker/js/locales/bootstrap-datetimepicker.zh-CN.js" charset="UTF-8"></script>
<script type="text/javascript" src="__STATIC__/layer/layer.js"></script>
<script type="text/javascript">
//导航高亮
switch("{$Think.ACTION_NAME}"){
    case "media_edit_adv":
        highlight_subnav('{:U('Site/media')}');
        break;
    case "wap_edit_adv":
        highlight_subnav('{:U('Site/wap')}');
        break;
    case "promote_edit_adv":
        highlight_subnav('{:U('Channel/index')}');
        break;
    case "app_edit_adv":
        highlight_subnav('{:U('Site/app')}');
        break;
}
$(".select_gallery").select2();
$(function(){
    Think.setValue('target',"{$data.target}")
    $("#game_name").val($("#game_id option:selected").text());

		
		$('.time1').datetimepicker({
        format: 'yyyy-mm-dd hh:ii',
        language:"zh-CN",
        minView:0,startDate:new Date(),
        autoclose:true
    }).change(function(){
			var start = new Date($(this).val()).getTime();
			var end = new Date($('.time2').val()).getTime();
			
			if(isNaN(end)) {return false;}
			
			if(start>=end) {layer.msg('开始时间必须小于结束时间');return false;}
			
			return false;
		});
		
    $('.time2').datetimepicker({
			format: 'yyyy-mm-dd hh:ii',
        language:"zh-CN",
        minView:0,startDate:new Date(),
        autoclose:true
    }).change(function(){
			var end = new Date($(this).val()).getTime();
			var start = new Date($('.time1').val()).getTime();
			
			if(isNaN(start)) {return false;}
			
			if(start>=end) {layer.msg('开始时间必须小于结束时间');return false;}
			
			return false;
		});
		
    showTab();
});
//Think.setValue("module", {$data.module|default = 'media'});
/* 初始化上传插件 */
$("#upload_picture_pic").uploadify({
    "height"          : 30,
    "swf"             : "__STATIC__/uploadify/uploadify.swf",
    "fileObjName"     : "download",
    "buttonText"      : "上传图标",
    "uploader"        : "{:U('File/uploadPicture',array('session_id'=>session_id(),'flag'=>true))}",
    "width"           : 120,
    'removeTimeout'   : 1,
    'fileTypeExts'    : '*.jpg; *.jpeg; *.png; *.gif;',
    "onUploadSuccess" : upload_picture_pic{$field.name},
    'onFallback' : function() {
        alert('未检测到兼容版本的Flash.');
    }
});
function upload_picture_pic{$field.name}(file, data){
    var data = $.parseJSON(data);
    var src = '';
    if(data.status){
        $("#pic_id").val(data.id);
        src = data.url || '__ROOT__' + data.path;
				var setWidth = parseInt($.trim($('#pic_id').attr('data-width'))),setHeight = parseInt($.trim($('#pic_id').attr('data-height')));
				var style = '';
				if(setWidth>=setHeight) {style = 'width:120px;height:'+parseInt(setHeight*120/setWidth)+'px';} else {style = 'height:120px;width:'+parseInt(setWidth*120/setHeight)+'px';}
        $("#pic_id").parent().find('.upload-img-box').html(
            '<div class="upload-pre-item"><span class="placeholder-graphic placeholder-graphic_adv" style="'+style+'"><img src="' + src + '"/></span></div>'
        );
    } else {
        updateAlert(data.info);
        setTimeout(function(){
            $('#top-alert').find('button').click();
            $(that).removeClass('disabled').prop('disabled',false);
        },1500);
    }
}
$('#submit').click(function(){
    $('#form').submit();
});
</script>
</block>