<extend name="Public/base" />
<!-- 管理员用户组新增和编辑页面 -->
<block name="body">
    <form action="{:U('Article/pop_rule_edit')}" enctype="application/x-www-form-urlencoded" method="POST"
            class="form-horizontal form_info_ml">
        <div class="formtitle"><span>编辑平台规则</span></div>
        <ul class="form_info ">
            <input type="hidden" name="id" value="{$rule.id}" />
            <li>
                <label>标题</label>
                <input name="title" type="text" class="" placeholder="标题" value="{$rule.title}" />
            </li>
            <li>
                <label>描述</label>
                <textarea name="desc" class="" placeholder="描述" >{$rule.desc}</textarea>
            </li>
  
            <li>
                <label>规则性质</label>
                <span class="form_radio"><label><input type="radio" name="belongs" value="1"  <?php if ($rule['belongs'] == 1):?>checked<?php endif;?>> 外团</label>
                    <label><input type="radio" name="belongs" value="2" <?php if ($rule['belongs'] == 2):?>checked<?php endif;?>> 内团</label></span>
                        <span class="notice-text"></span>
            </li>

            <li>
                    
                <label>上传文档</label>
                <input type="file" name="upfile" id="file_doc"  style="width:200px"/> 
                <input type="button" onclick="suba({$rule['id']})" style="background: #3E96C9;color:white;border:none;outline: none;width:70px;height:30px;border-radius: 3px;" value="上传" />
                <span class="notice-text" id="aa" style="color:green;margin-left:10px;display: block;">当前文档:{$doc}</span>
                <span class="notice-text" id="uploadstatus" style="color:red;margin-left:10px;display: none;">上传成功</span>
                <span class="notice-text" id="uploadstatus1" style="color:red;margin-left:10px;display: none;">上传失败,当前文档:{$doc}</span>
            </li>

            <li>
                <label>排序</label>
                <input name="sort" type="text" class="txt" placeholder="排序" value="{$rule.sort}" />
                <span style="font-size: small;color: red;">*排序越小越靠前</span>
            </li>
            <li>
                <label>类型</label>
                <select id="type" name="type" class="select_gallery" onchange="checkPopTime(0);">
                    <option value="0" <?php if ($rule['type'] == 0):?>selected<?php endif;?>>不弹窗</option>
                    <option value="1" <?php if ($rule['type'] == 1):?>selected<?php endif;?>>单次弹窗</option>
                    <option value="2" <?php if ($rule['type'] == 2):?>selected<?php endif;?>>循环弹窗</option>
                </select>
            </li>
            <li id="li-pop-time"></li>
            <li>
                <label>内容</label>            
                <span class="form_textarea">
                <textarea name="content">{$rule.content}</textarea>
                {:hook('adminArticleEdit', array('name'=>'content','value'=>$rule['content']))}
                </span>
            </li>
            <li>
                <label>&nbsp;</label><input type="submit" id="submit" value="确认保存" target-form="form-horizontal" class="form_btn ajax-post">
                <input type="button"  value="返 回" target-form="form-horizontal" class="form_btn ajax-post" onclick="javascript:void(window.history.go(-1))">
            </li>
        </ul>
    </form>
		
		<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="AuthManager/index">
			</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">
    <php>if(C('COLOR_STYLE')=='blue_color') echo '
        <link href="__STATIC__/datetimepicker/css/datetimepicker_blue.css" rel="stylesheet" type="text/css">
        ';
    </php>
    <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 src="__STATIC__/layer/layer.js" type="text/javascript"></script>
    <script type="text/javascript">
    </script>
    <script>
        function suba(id) {
              var file_excel = $('#file_doc')[0].files[0]
              var formData = new FormData(); 
               formData.append("file",file_excel);
               formData.append("id",id)
                  $.ajax({
                      url:"{:U('Article/uploadDoc')}",
                      dataType:'json',
                      type:'POST',
                      async:false,
                      data:formData,
                      processData : false, // 使数据不做处理
                      contentType : false, // 不要设置Content-Type请求头
                      success:function(res) {
                        res = JSON.parse(res)
                         if (res.code == 10000) {
                             document.getElementById('uploadstatus').style.display = 'block'
                             document.getElementById('uploadstatus1').style.display = 'none'
                             document.getElementById('aa').style.display = 'none'
                         }else {
                            document.getElementById('uploadstatus1').style.display = 'block'
                             document.getElementById('uploadstatus').style.display = 'none'
                             document.getElementById('aa').style.display = 'none'
                         }
                     
                      }
              })
          }
    </script>
    <script type="text/javascript">
    highlight_subnav('{:U('Article/pop_rules')}');
    function checkPopTime(first)
    {
        $("#li-pop-time").html("");
        $('#pop_time').val('');
        var type_val = $("#type").val();
        if (type_val == 0) {
            //$('#li-pop-time').hide();
            
        } else if (type_val == 1) {
            if (first || '{$rule["type"]}' == 1) {
                $("#li-pop-time").html('<label>弹窗时间</label><input type="text" id="pop_time" readonly name="pop_time" class="" value="{$rule.pop_time}" placeholder="弹窗时间" />');
            } else {
                $("#li-pop-time").html('<label>弹窗时间</label><input type="text" id="pop_time" readonly name="pop_time" class="" value="" placeholder="弹窗时间" />');
            }
            $('#pop_time').datetimepicker({
                format: 'yyyy-mm-dd',
                language:"zh-CN",
                minView:2,
                autoclose:true
            });
            
        } else if (type_val == 2) {
            //$('#li-pop-time').show();
            $("#li-pop-time").html('<label>弹窗时间</label><select id="pop_time" name="pop_time" class="select_gallery"><option value="8" <?php if ($rule["pop_time"] == 8):?>selected<?php endif;?>>每周第一次登陆</option><option value="1" <?php if ($rule["pop_time"] == 1):?>selected<?php endif;?>>周一</option><option value="2" <?php if ($rule["pop_time"] == 2):?>selected<?php endif;?> >周二</option><option value="3" <?php if ($rule["pop_time"] == 3):?>selected<?php endif;?> >周三</option><option value="4" <?php if ($rule["pop_time"] == 4):?>selected<?php endif;?> >周四</option><option value="5" <?php if ($rule["pop_time"] == 5):?>selected<?php endif;?> >周五</option><option value="6" <?php if ($rule["pop_time"] == 6):?>selected<?php endif;?> >周六</option><option value="7" <?php if ($rule["pop_time"] == 7):?>selected<?php endif;?> >周日</option></select>');
        }
    }
    checkPopTime(1);
    </script>
</block>