<extend name="Public/base" />

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

  <style>
    .tabcon1711 input.time {
      width: 150px;
    }
    #form .txt_area {
      width: 300px;
      height: 150px;
    }
    .tabcon1711 .form_unit {
      margin-left: 2px;
    }
    .tabcon1711 .mustmark {
      margin-left:-7px;
    }
    .list-ratio {
      display: table;
    }
    .list-ratio .li-ratio {
      display: flex;
      margin-bottom: 20px;
      align-items: center;
    }
    .list-ratio .li-ratio .turnover, .list-ratio .li-ratio .turnover-ratio {
      position: relative;
    }
    .list-ratio .li-ratio .turnover span, .list-ratio .li-ratio .turnover-ratio .error-message {
      color: red;
      position: absolute;
      left: 0;
      top: 30px;
      white-space: nowrap;
      display: none;
    }
    .iconfont-btn {
      cursor: pointer;
    }
    .iconfont-style {
      font-size: 18px;
      color: #fff;
      border-radius: 4px;
      border: 0;
      padding: 5px;
      margin-left: 10px;
    }
    .iconfont-selected {
      background-color: #0A9AF2;
    }
    .iconfont-selected:hover {
      background-color: #03a9f4;
    }
    .iconfont-unselected {
      background-color: #999;
    }
    .iconfont-unselected:hover {
      background-color: #ababab;
    }
    .tabcon1711 .submit_btn.small-btn {
        float: none;
        line-height: 25px;
        width: 50px;
        height: 25px;
        font-size: 12px;
        padding: 0px 8px 0px 0px;
    }
    .select2-container--default .select2-selection--multiple {
      line-height: 22px;
    }
    .select2-container .select2-search--inline {
        float: left;
        height: 29px;
        line-height: 29px;
    }
    .select2-container--default .select2-search--inline .select2-search__field {
      height: 22px;
    }
    .select2-container--default .select2-selection--multiple .select2-selection__choice {
      height: 22px;
      line-height: 22px;
    }
  </style>
  <div class="cf main-place top_nav_list navtab_list">
    <h3 class="page_title">{$meta_title}</h3>
<!--    <p class="description_text">说明:此功是创建推广员时所需填写信息</p>-->
  </div>

  <!-- 标签页导航 -->
  <div class="tab-wrap">
    <div class="tab-content tabcon1711">
      <!-- 表单 -->
      <form id="form" action="{:U('modifyRule')}" 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"><i class="mustmark">*</i>公司类型:</td>
              <td class="r">
                <select name="company_belong" id="company-belong-select" class="select_gallery" disabled>
                  <option value="-1">所有公司类型</option>
                  <?php foreach($companyBelongs as $key => $name):?>
                  <option value="<?=$key?>" <?php if($record['company_belong']==$key):?>selected<?php endif;?>><?=$name?></option>
                  <?php endforeach;?>
                </select>
              </td>
            </tr>
            <tr>
              <td class="l"><i class="mustmark">*</i>推广公司:</td>
              <td class="r">
                <select name="company_id[]" id="company-select" class="select_gallery" style="width: 500px;" disabled>
                  <option value="0">所有公司</option>
                  <?php foreach($companies as $company):?>
                  <option value="<?=$company['id']?>" <?php if($record['company_id']==$company['id']):?>selected<?php endif;?>><?=$company['company_name']?></option>
                  <?php endforeach;?>
                </select>
              </td>
            </tr>
            <tr>
              <td class="l"><i class="mustmark">*</i>游戏类型:</td>
              <td class="r">
                <select name="game_type_id" id="game-type-select" class="select_gallery" disabled>
                  <option value="0">所有游戏类型</option>
                  <?php foreach($gameTypes as $gameType):?>
                  <option value="<?=$gameType['id']?>" <?php if($record['game_type_id']==$gameType['id']):?>selected<?php endif;?>><?=$gameType['type_name']?></option>
                  <?php endforeach;?>
                </select>
              </td>
            </tr>
            <tr>
              <td class="l"><i class="mustmark">*</i>游戏:</td>
              <td class="r">
                <select name="game_id" id="game-select" class="select_gallery" style="width: 500px;" disabled>
                  <option value="0">所有择游戏</option>
                  <?php foreach($games as $game):?>
                  <option value="<?=$game['id']?>" <?php if($record['game_id']==$game['id']):?>selected<?php endif;?>><?=$game['name']?></option>
                  <?php endforeach;?>
                </select>
              </td>
            </tr>
            <tr>
              <td class="l"><i class="mustmark">*</i>支付宝支付配置:</td>
              <td class="r">
                <select name="alipay_merchant_id" id="alipay-merchant-select" class="select_gallery">
                  <option value="0">跟随系统默认商户</option>
                  <?php foreach($aliMerchants as $merchant):?>
                  <option value="<?=$merchant['id']?>" <?php if($record['alipay_merchant_id']==$merchant['id']):?>selected<?php endif;?>><?=$merchant['name']?></option>
                  <?php endforeach;?>
                </select>
              </td>
            </tr>
            <tr>
              <td class="l"><i class="mustmark">*</i>微信支付配置:</td>
              <td class="r">
                <select name="weixin_merchant_id" id="weixin-merchant-select" class="select_gallery">
                  <option value="0">跟随系统默认商户</option>
                  <?php foreach($weixinMerchants as $merchant):?>
                  <option value="<?=$merchant['id']?>" <?php if($record['weixin_merchant_id']==$merchant['id']):?>selected<?php endif;?>><?=$merchant['name']?></option>
                  <?php endforeach;?>
                </select>
              </td>
            </tr>
            <tr>
              <td class="l"><i class="mustmark">*</i>快捷支付配置:</td>
              <td class="r">
                <select name="express_merchant_id" id="express-merchant-select" class="select_gallery">
                  <option value="0">跟随系统默认商户</option>
                  <?php foreach($expressMerchants as $merchant):?>
                  <option value="<?=$merchant['id']?>" <?php if($record['express_merchant_id']==$merchant['id']):?>selected<?php endif;?>><?=$merchant['name']?></option>
                  <?php endforeach;?>
                </select>
              </td>
            </tr>
            <tr>
              <td class="l">生效时间(开始):</td>
              <td class="r">
                <input type="text" id="start_time" name="start_time" class="time" value="<?=$record['start_time']?>" autocomplete="off" placeholder="请选择生效时间(开始)" style="width: 200px"/>
              </td>
            </tr>
            <tr>
              <td class="l">生效时间(结束):</td>
              <td class="r">
                <input type="text" id="end_time" name="end_time" class="time" value="<?=$record['end_time']?>" autocomplete="off" placeholder="请选择生效时间(开始)" style="width: 200px"/>
              </td>
            </tr>
            </tbody>
          </table>
        </div>
        <input type="hidden" name="id" id="id" value="{$record.id}" />
        <div class="form-item cf">
            <button class="submit_btn 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="Promote/lists/type/1">
    </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 type="text/javascript">
//导航高亮
highlight_subnav("{:U('PaymentMerchant/rules')}");
$(".select_gallery").select2();

$(function(){
    $('.time').datetimepicker({
        format: 'yyyy-mm-dd',
        language: "zh-CN",
        autoclose: true,
        scrollMonth: false,
        scrollTime: false,
        scrollInput: false,
        startView: 'month',
        minView:'month',
        maxView:'month',
    });
    showTab();
    $('#company-belong-select').on({
      change: function() {
        var companyBelong = $(this).val()
        getCompaniesByBelong(companyBelong, function(companies) {
          var html = '<option value="0">所有推广公司</option>'
          for (var key in companies) {
            html += '<option value="' +
              companies[key].id +
              '">' + companies[key].company_name + '</option>'
          }
          $('#company-select').html(html)
          $('#company-select').select2()
        })
      }
    })
    $('#game-type-select').on({
      change: function() {
        var gameTypeId = $(this).val()
        getGamesByType(gameTypeId, function(games) {
          var html = '<option value="0">所有游戏</option>'
          for (var key in games) {
            html += '<option value="' +
            games[key].id +
              '">' + games[key].name + '</option>'
          }
          $('#game-select').html(html)
          $('#game-select').select2()
        })
      }
    })
    function getCompaniesByBelong(companyBelong, callback) {
      $.ajax({
        url: '{:U("getCompaniesByBelong")}',
        type: 'get',
        dataType: 'json',
        data: {company_belong: companyBelong},
        success: function(result) {
          if (result.status == 1) {
            callback(result.data.companies)
          } else {
            layer.msg(result.message)
          }
        }
      })
    }
    function getGamesByType(gameTypeId, callback) {
      $.ajax({
        url: '{:U("getGamesByType")}',
        type: 'get',
        dataType: 'json',
        data: {game_type_id: gameTypeId},
        success: function(result) {
          if (result.status == 1) {
            callback(result.data.games)
          } else {
            layer.msg(result.message)
          }
        }
      })
    }

    $('#submit').click(function (e) {
        var target = $('form').get(0).action;
        var query = $('form').serialize();
        var that = this;
        $(that).addClass('disabled').attr('autocomplete','off').prop('disabled',true);
        $.post(target,query).success(function(result){
          if(layer) { layer.closeAll('loading'); }
          if (result.status == 1) {
            layer.msg(result.message)
            setTimeout(function() {
              window.location.href = '{:U("rules")}'
            }, 200)
          } else {
            $(that).removeClass('disabled').attr('autocomplete','on').prop('disabled',false);
            layer.msg(result.message)
          }
        });
    });
});
</script>
</block>