<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>添加活动</title>
    <!-- 最新版本的 Bootstrap 核心 CSS 文件 -->
    <link rel="stylesheet" href="<?php echo base_url();?>public/js/bootstrap/bootstrap.min.css" >
    <link rel="stylesheet" href="<?php echo base_url();?>public/js/vendor/bootstrap-datepicker/css/bootstrap-datepicker.standalone.min.css">
    <link rel="stylesheet" href="<?php echo base_url();?>public/css/jquery.timepicker.min.css">
    <!-- Select2 -->
    <link rel="stylesheet" href="<?php echo base_url();?>public/js/vendor/select2/select2.min.css">
    <style type="text/css">
        .thumbnail {
            margin:10px;
        }

        .lang-name {
            margin-left:42px;
        }

        .upimg {
            cursor: pointer;
        }

    </style>
</head>
<body>
<div id="msg-tip">

</div>
<div class="container-fluid">
    <div class="row">
        <div class="col-sm-12">
            <aside>
                <header><i class="fa fa-fw fa-file"></i>添加活动</header>
                <hr/>
                <section>
                    <div class="container-fluid">
                        <div class="row">
                            <div class="col-sm-12">
                                <input type="hidden" value="<?php echo $url;?>" id="uploadUrl"/>
                                <input type="hidden" value="<?php echo $baseUrl;?>" id="baseUrl"/>
                                <form class="form-horizontal" role="form" method="post" enctype="multipart/form-data"  id="uploadForm" action="#">

                                    <div class="form-group" id="uploadImg">
                                        <label class="col-sm-2 control-label">活动图片</label>
                                        <?php foreach ($langList as $k => $v){ ?>
                                            <div class="col-sm-1 thumbnail div-<?php echo $k;?>" >
                                                <!--                                                        <input type="file">-->
                                                <img src="<?php echo '/images/default_img.png';?>" class="upimg default-img" name="<?php echo $k;?>" alt=""  style="height: 90px;width: 90px;"  />
                                                <img src="" class="upimg  uploaded-img hide" alt=""  name="<?php echo $k;?>" id="<?php echo $k;?>" style="height: 90px;width: 90px;" />
                                                <input type="file" name="imgfile_<?php echo $k;?>" id="imgfile_<?php echo $k;?>" class="imgfile hide"/>
                                                <span class="lang-name"><?php echo $v;?></span>
                                            </div>
                                        <?php }?>

                                    </div>

                                </form>

                                <form class="form-horizontal" role="form" method="post"  enctype="multipart/form-data" id="addForm">
                                    <?php foreach ($langList as $k => $v) { ?>
                                        <input type="hidden" value="" id="uplang_<?php echo $k;?>" name="uplang[<?php echo $k;?>]"/>
                                    <?php }?>
                                    <div class="form-group">
                                        <label class="col-sm-2 control-label">活动ID*: </label>
                                        <div class="col-sm-2">
                                            <input type="text" readonly class="form-control"  name="id" value="<?php echo $id;?>">
                                        </div>
                                    </div>

                                    <div class="form-group">
                                        <label class="col-sm-2 control-label" style="line-height: 7px;">包:</label>
                                        <div class="an-checkbox-div col-sm-9 android-package">
                                            <label>
                                                <input type="checkbox" id="android-checkall"> 【全选】
                                            </label>
                                            <?php foreach ($androidPackageList as $k => $v) { ?>
                                                <label>
                                                    <input type="checkbox" class="android-check" name="package[]" value="<?php echo $k;?>"> <?php echo $v;?>
                                                </label>
                                            <?php }?>
                                            <br/>
                                            <br/>
                                            &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
                                            <?php foreach ($iosPackageList as $k => $v) { ?>
                                                <label>
                                                    <input type="checkbox" class="android-check" name="package[]" value="<?php echo $k;?>"> <?php echo '苹果'.$v;?>
                                                </label>
                                            <?php }?>
                                        </div>

                                    </div>

                                    <div class="form-group">
                                        <label class="col-sm-2 control-label">标题*: </label>

                                        <?php
                                        $tNum = 0;
                                        foreach ($langList as $k => $v) {
                                        if($tNum != 0 && $tNum % 4 == 0) {?><!--标题第二行和第一行对齐-->
                                        <label class="col-sm-2 control-label"> </label>
                                        <?php }
                                        ?>
                                        <div class="col-sm-2">
                                            <input type="text" class="form-control" placeholder="<?php echo $v?>" name="title[<?php echo $k;?>]" value="">
                                        </div>
                                        <?php
                                        $tNum++;
                                        }?>
                                    </div>

                                    <div class="form-group">
                                        <label class="col-sm-2 control-label">是否显示按钮*:</label>
                                        <div class="col-sm-2">
                                            <label class="radio-inline">
                                                <input type="radio" name="actType"  value="1" checked /> 显示
                                            </label>
                                            <label class="radio-inline">
                                                <input type="radio" name="actType"  value="0"  /> 隐藏
                                            </label>

                                        </div>
                                    </div>

                                    <div class="form-group btn-show">
                                        <label class="col-sm-2 control-label">按钮名称*: </label>
                                        <?php
                                        $bNum = 0;
                                        foreach ($langList as $k => $v) {
                                            if($bNum != 0 && $bNum % 4 == 0){?>按钮名称第二行和第一行对齐
                                                <label class="col-sm-2 control-label"></label>
                                            <?php }
                                            ?>
                                            <div class="col-sm-2">
                                                <input type="text" class="form-control" placeholder="<?php echo $v?>" name="bname[<?php echo $k;?>]" value="">
                                            </div>
                                            <?php
                                            $bNum++;
                                        }?>
                                    </div>


                                    <div class="form-group btn-show">
                                        <label class="col-sm-2 control-label">按钮颜色:</label>
                                        <div class="col-sm-1">
                                           <select class="form-control" name="bcolor" id="bcolor">
                                                <option value="2"> 绿色</option>
                                                <option value="1">蓝色</option>
                                                <option value="3">黄色</option>
                                            </select>
                                        </div>
                                    </div>

                                    <div class="form-group">
                                        <label class="col-sm-2 control-label">活动时间(天):</label>
                                        <div class="col-sm-2">
                                            <input type="text" class="form-control  stime" value="" placeholder="开始时间" name="stime" />
                                        </div>
                                        <div class="col-sm-2">
                                            <input type="text" class="form-control datetimepicker stime-hour" value="" placeholder="开始时间" name="stimeHour" />
                                        </div>
                                    </div>

                                    <div class="form-group date-hour">
                                        <label class="col-sm-2 control-label">活动时间段(小时):</label>
                                        <div class="col-sm-2">
                                            <input type="text" class="form-control  etime" value="" placeholder="结束时间" name="etime" />
                                        </div>

                                        <div class="col-sm-2">
                                            <input type="text" class="form-control datetimepicker etime-hour" value="" placeholder="结束时间" name="etimeHour" />
                                        </div>
                                    </div>

                                    <div class="form-group">
                                        <label class="col-sm-2 control-label">显示排序<span class="fa fa-question-circle "   data-toggle="tooltip" title="数字越大顺序越后"></span>:</label>
                                        <div class="col-sm-1">
                                            <input type="text" class="form-control" placeholder="显示排序" name="sort" value="">
                                        </div>
                                    </div>

                                    <div class="form-group">
                                        <label class="col-sm-2 control-label">最低开放等级<span class="fa fa-question-circle "   data-toggle="tooltip" title=""></span>:</label>
                                        <div class="col-sm-1">
                                            <input type="text" class="form-control" placeholder="最低开放等级" name="openlv" value="">
                                        </div>
                                    </div>

                                    <div class="form-group">
                                        <label class="col-sm-2 control-label">活动状态*:</label>
                                        <div class="col-sm-2">
                                            <label class="radio-inline">
                                                <input type="radio" name="online"  value="1" checked /> 上线
                                            </label>
                                            <label class="radio-inline">
                                                <input type="radio" name="online"  value="0"  /> 下线
                                            </label>
                                        </div>
                                    </div>

                                    <div class="form-group">
                                        <label class="col-sm-2 control-label">概率调整:</label>
                                        <div class="col-sm-8">
                                            <div class="col-sm-1" style="text-align: center">
                                                <span>攻击</span>
                                                <input type="text" class="form-control" name="pro[1]" value="0">
                                            </div>
                                            <div class="col-sm-1" style="text-align: center">
                                                <span>偷袭</span>
                                                <input type="text" class="form-control" name="pro[2]" value="0">
                                            </div>
                                            <div class="col-sm-1" style="text-align: center">
                                                <span>体力</span>
                                                <input type="text" class="form-control" name="pro[3]" value="0">
                                            </div>
                                            <div class="col-sm-1" style="text-align: center">
                                                <span>护盾</span>
                                                <input type="text" class="form-control" name="pro[4]" value="0">
                                            </div>
                                            <div class="col-sm-1" style="text-align: center">
                                                <span>1个金币</span>
                                                <input type="text" class="form-control" name="pro[5]" value="0">
                                            </div>
                                            <div class="col-sm-1" style="text-align: center">
                                                <span>2个金币</span>
                                                <input type="text" class="form-control" name="pro[6]" value="0">
                                            </div>
                                            <div class="col-sm-1" style="text-align: center">
                                                <span>3个金币</span>
                                                <input type="text" class="form-control" name="pro[7]" value="0">
                                            </div>
                                            <div class="col-sm-1" style="text-align: center">
                                                <span>1个钱袋</span>
                                                <input type="text" class="form-control" name="pro[8]" value="0">
                                            </div>
                                            <div class="col-sm-1" style="text-align: center">
                                                <span>2个钱袋</span>
                                                <input type="text" class="form-control" name="pro[9]" value="0">
                                            </div>
                                            <div class="col-sm-1" style="text-align: center">
                                                <span>3个钱袋</span>
                                                <input type="text" class="form-control" name="pro[10]" value="0">
                                            </div>
                                            <div class="col-sm-1" style="text-align: center">
                                                <span>没有奖励</span>
                                                <input type="text" class="form-control" name="pro[11]" value="0">
                                            </div>
                                            <div class="col-sm-1" style="text-align: center">
                                                <span>活动</span>
                                                <input type="text" class="form-control" name="pro[12]" value="0">
                                            </div>
                                        </div>
                                    </div>

                                    <div class="form-group">
                                        <div class="col-sm-offset-2 col-sm-3">
                                            <button type="button" class="btn btn-info goback">返回</button>
                                            <button type="button" class="btn btn-primary" id="submitBtn">提交</button>
                                        </div>
                                    </div>
                                </form>
                            </div>
                        </div>
                    </div>
                </section>
            </aside>
        </div>
    </div>
</div>

</body>
<script src="<?php echo base_url();?>public/js/vendor/bootstrap-datepicker/js/bootstrap-datepicker.min.js"></script>
<script src="<?php echo base_url();?>public/js/vendor/bootstrap-datepicker/locales/bootstrap-datepicker.zh-CN.min.js"></script>
<script src="<?php echo base_url();?>public/plugins/validate/jquery.validate-1.15.0.min.js"></script>
<script src="<?php echo base_url();?>public/plugins/validate/jaquery.validate.messages_zh.js"></script>
<script src="<?php echo base_url();?>public/js/common.js"></script>
<script src="<?php echo base_url();?>public/js/activity/add.js"></script>
<script src="<?php echo base_url();?>public/js/vendor/timepicker/timepicker.min.js"></script>
<!-- Select2 -->
<script src="<?php echo base_url();?>public/js/vendor/select2/select2.full.min.js"></script>

</html>
<script type="text/javascript">
    var time = '<?php echo time();?>';
    //初始化包全选
    $('.android-check').prop('checked', true);
    $('#android-checkall').prop('checked', true);

    //选择日期
    $('.stime,.etime').datepicker({
        language:'zh-CN',
        format:'yyyy-mm-dd',
        zIndexOffset:906  //控制z-index
    });

    //Initialize Select2 Elements
    $(".select2").select2();

    //选择时间段
    $('.datetimepicker').timepicker({
        timeFormat:'HH:mm'
    });

    $('.goback').click(function(){
        history.go(-1);
    });

    //跳转链接
    $('#goto').change(function () {
        var value = $('#goto option:selected').val();
        var gotoLevel = $('.goto-level');
        if(value == 5) {//跳转到指定场次
            gotoLevel.removeClass('hide');
        }else {
            gotoLevel.addClass('hide');
        }

        var goodsType = $('.goods-type'),
            payType = $('.pay-type');
        if(value == 12) {//打开商城3
            goodsType.removeClass('hide');
            payType.removeClass('hide');
        }else {
            goodsType.addClass('hide');
            payType.addClass('hide');
        }
    });

    //添加玩牌盲注
    $('#addPlayPoker').click(function () {
        var  maxBlindId = $(this) .attr('data-max-blind');
        var html = ' <div class="play-poker">'+
            ' <div class="form-group">'+
            '<label class="col-sm-2 control-label">盲注:</label>'+
            '<div class="col-sm-6">'+
            '   <select class="form-control select2"  data-placeholder="全部" name="blindList['+maxBlindId+']" style="width: 100%;">'+
            ' <option value="999">--全部--</option>'+
            ' <?php foreach ($blindList as $blind){ ?>'+
            ' <option value="<?php echo $blind;?>"><?php echo $blind;?></option>'+
            '<?php } ?>'+
            ' </select>'+
            '</div>'+

            ' </div>'+

            '<div class="play-card">'+
            '<div class="form-group" >'+
            '<label class="col-sm-2 control-label">玩牌奖励<span style="color:red" class="fa fa-question-circle "   data-toggle="tooltip" title="添加玩牌奖励后，要提醒PHP重启后台服务"></span>:</label>'+

            '<div class="col-sm-1">'+
            '<input type="text" class="form-control" placeholder="局数" name="reward['+maxBlindId+'][0][playnum]" value="">'+
            '</div>'+
            '<?php foreach ($rewardList as $k => $v) {?>'+
            '<div class="col-sm-1">'+
            ' <input type="text" class="form-control" placeholder="<?php echo $v;?>" name="reward['+maxBlindId+'][0][<?php echo $k;?>]" value="">'+
            '</div>'+
            '<?php }?>'+
            '</div>'+
            '</div>'+

            '<div class="form-group">'+
            '<label class="col-sm-2 control-label"></label>'+
            '<div class="col-sm-1">'+
            '<button type="button" class="btn btn-success btn-sm add-reward"  data-max="1" cur-data-max-blind="'+maxBlindId+'"><i class="fa fa-plus-square"></i>添加奖励</button>'+
            '</div>'+
            '</div>'+
            '</div>'+

            '<label class="col-sm-2 control-label"></label>'+
            '<div class="col-sm-9">'+
            '<hr>'+
            '</div>';

        $('#pokerList').prepend(html);
        $(this).attr('data-max-blind', parseInt(maxBlindId) + 1);//更新盲注maxid
    });




    //添加奖励
    $('#pokerList ').on('click','.add-reward',function () {

        var _this = $(this),
            maxBlindId =_this.attr('cur-data-max-blind'),
            maxid = _this.attr('data-max');//设置添加的奖励数组key
        _this.attr('data-max', parseInt(maxid) + 1);//更新maxid

        var html = ' <div class="form-group play-reward">'+
            '<label class="col-sm-2 control-label"></label>'+

            '<div class="col-sm-1">'+
            '<input type="text" class="form-control" placeholder="局数" name="reward['+maxBlindId+']['+maxid+'][playnum]" value="">'+
            '</div>'+
            '<?php foreach ($rewardList as $k => $v) {?>'+
            '<div class="col-sm-1">'+
            '<input type="text" class="form-control" placeholder="<?php echo $v;?>" name="reward['+maxBlindId+']['+maxid+'][<?php echo $k;?>]" value="">'+
            '</div>'+
            '<?php }?>'+
            '<div class="col-sm-1">'+
            ' <button type="button" class="btn-danger btn btn-sm delete-reward"><i class="fa fa-minus-square"></i>删除</button>'+
            '</div>'+
            '</div>';

        _this.parent().parent().siblings(".play-card").append(html);//追加奖励项
    });

    //删除该行奖励
    $('#pokerList').on('click','.delete-reward',function () {
        var parentDiv = $(this).parent().parent();
        parentDiv.remove();
    });



    //是否选择时间段
    $('#isChooseDateHour').change(function () {
        var state = $(this).val();
        console.log(state);
        if(state === '1'){
            $('.date-hour').removeClass('hide');
        }else {
            $('.date-hour').addClass('hide');
        }
    });

    //全选/全不选
    $('#android-checkall').change(function () {
        if($(this).is(':checked')) {//已经是全选的状态
            $('.android-check').prop('checked', true);
        }else {
            $('.android-check').prop('checked', false);
        }
    });

</script>