<div class="content_wrapper">
<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>
                    <section>
                        <div class="container-fluid">
                            <div class="row">
                                <div class="col-sm-12">
                                    <div class="table-responsive">
                                        <table id="configTable" class="table table-striped table-bordered table-hover" cellspacing="0" width="100%">
                                            <thead>
                                            <tr>
                                                <th>场次</th>
                                                <th>游戏类型</th>
                                                <th>小盲</th>
                                                <th>发一张牌时间<span style="color: red;">(百毫秒)</span></th>
                                                <th>下注时间</th>
                                                <th>播放奖池时间(收筹码)</th>
                                                <th>延时结算时间</th>
                                                <th>座位数</th>
                                                <th>台费</th>
                                                <th>进场最小携带</th>
                                                <th>进场最大携带</th>
                                                <th>进场玩家最少拥有多少钱</th>
                                                <th>进场玩家最多拥有多少钱</th>
                                                <th>播放结算动画时间</th>
                                                <th>几局不操作站起</th>
                                                <th>桌子名字</th>
                                                <th>检查机器人状态时间</th>
                                                <th>机器人数量</th>
                                                <th>机器人最少多少秒进入</th>
                                                <th>机器人最多多少秒进入</th>
                                                <th>机器人最少多少秒退出</th>
                                                <th>机器人最多多少秒退出</th>
                                                <th>新手前多少局享受新手好牌</th>
                                                <th>新手好牌概率</th>
                                                <th>操作</th>
                                            </tr>
                                            </thead>
                                            <tbody>
                                            <?php 
                                                if(is_array($list)){
                                                    foreach ($list as $key => $val) {
                                            ?>
                                            <tr>
                                                <td name="level_<?php echo $val['level'];?>"><?php echo $val['level'];?></td>
                                                <td>
                                                    <?php
                                                    if($val['level'] >= 101 && $val['level'] <= 336) {
                                                        echo "德州普通场";
                                                    }elseif ($val['level'] >= 500) {
                                                        echo '奥马哈';
                                                    }elseif ($val['level'] >= 11 && $val['level'] <= 17) {
                                                        echo '比赛场';
                                                    }elseif ($val['level'] == 100) {
                                                        echo '私人房';
                                                    }else{
                                                        echo '其他';
                                                    }
                                                    ?>
                                                </td>
                                                <td name="SmallBlind_<?php echo $val['level'];?>"><?php echo $val['SmallBlind'];?></td>
                                                <td name="one_card_time_<?php echo $val['level'];?>"><?php echo $val['one_card_time'];?></td>
                                                <td name="BET_TIME_<?php echo $val['level'];?>"><?php echo $val['BET_TIME'];?></td>
                                                <td name="show_pool_time_<?php echo $val['level'];?>"><?php echo $val['show_pool_time'];?></td>
                                                <td name="delaystop_time_<?php echo $val['level'];?>"><?php echo $val['delaystop_time'];?></td>
                                                <td name="MAX_SIT_USER_<?php echo $val['level'];?>"><?php echo $val['MAX_SIT_USER'];?></td>
                                                <td name="FEE_<?php echo $val['level'];?>"><?php echo $val['FEE'];?></td>
                                                <td name="MIN_ANTE_<?php echo $val['level'];?>"><?php echo $val['MIN_ANTE'];?></td>
                                                <td name="MAX_ANTE_<?php echo $val['level'];?>"><?php echo $val['MAX_ANTE'];?></td>
                                                <td name="MIN_IN_<?php echo $val['level'];?>"><?php echo $val['MIN_IN'];?></td>
                                                <td name="MAX_IN_<?php echo $val['level'];?>"><?php echo $val['MAX_IN'];?></td>
                                                <td name="ANIMATION_TIME_<?php echo $val['level'];?>"><?php echo $val['ANIMATION_TIME'];?></td>
                                                <td name="NO_OPER_STAND_ROUND_<?php echo $val['level'];?>"><?php echo $val['NO_OPER_STAND_ROUND'];?></td>
                                                <td name="table_name_<?php echo $val['level'];?>"><?php echo $val['table_name'];?></td>
                                                <td name="robot_check_time_<?php echo $val['level'];?>"><?php echo $val['robot_check_time'];?></td>
                                                <td name="robot_num_<?php echo $val['level'];?>"><?php echo $val['robot_num'];?></td>
                                                <td name="robot_in_min_time_<?php echo $val['level'];?>"><?php echo $val['robot_in_min_time'];?></td>
                                                <td name="robot_in_max_time_<?php echo $val['level'];?>"><?php echo $val['robot_in_max_time'];?></td>
                                                <td name="robot_out_min_time_<?php echo $val['level'];?>"><?php echo $val['robot_out_min_time'];?></td>
                                                <td name="robot_out_max_time_<?php echo $val['level'];?>"><?php echo $val['robot_out_max_time'];?></td>
                                                <td name="newplayer_rounds_<?php echo $val['level'];?>"><?php echo $val['newplayer_rounds'];?></td>
                                                <td name="newplayer_probability_<?php echo $val['level'];?>"><?php echo $val['newplayer_probability'];?></td>
                                                <td><button type="button" class="btn btn-primary btnedit" data-toggle="modal" data-target="#myModal" levelid="<?php echo $val['level'];?>">编辑</button></td>
                                            </tr>
                                            <?php } } else{?>
                                            <tr>
                                                <td colspan="10">暂无数据</td>
                                            </tr>
                                            <?php } ?>
                                            </tbody>
                                        </table>
                                    </div>
                                </div>
                            </div>
                        </div>
                    </section>
                </aside>
            </div>
        </div>
    </div>

</div>
<!-- Modal -->
<div class="modal fade" id="myModal" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
    <div class="modal-dialog">
        <div class="modal-content">
            <div class="modal-header">
                <button type="button" class="close" data-dismiss="modal"><span aria-hidden="true">&times;</span><span class="sr-only">Close</span></button>
                <h4 class="modal-title" id="myModalLabel">编辑桌子配置</h4>
            </div>
            <form class="form-horizontal J_ajaxForm" role="form" method="post" action="config/edittable">
                <div class="modal-body">
                    <div class="form-group">
                        <label class="col-sm-3 control-label">场次:</label>
                        <div class="col-sm-9">
                            <input type="text" class="form-control" placeholder="场次" name="level">
                        </div>
                    </div><div class="form-group">
                        <label class="col-sm-3 control-label">小盲:</label>
                        <div class="col-sm-9">
                            <input type="text" class="form-control" placeholder="小盲" name="SmallBlind">
                        </div>
                    </div><div class="form-group">
                        <label class="col-sm-3 control-label">发一张牌时间<span style="color: red;">(百毫秒)</span>:</label>
                        <div class="col-sm-9">
                            <input type="text" class="form-control" placeholder="发一张牌时间" name="one_card_time">
                        </div>
                    </div><div class="form-group">
                        <label class="col-sm-3 control-label">下注时间:</label>
                        <div class="col-sm-9">
                            <input type="text" class="form-control" placeholder="下注时间" name="BET_TIME">
                        </div>
                    </div>
                    <div class="form-group">
                        <label class="col-sm-3 control-label">播放奖池时间(收筹码):</label>
                        <div class="col-sm-9">
                            <input type="text" class="form-control" placeholder="播放奖池时间(收筹码)" name="show_pool_time">
                        </div>
                    </div>
                    <div class="form-group">
                        <label class="col-sm-3 control-label">延时结算时间:</label>
                        <div class="col-sm-9">
                            <input type="text" class="form-control" placeholder="延时结算时间" name="delaystop_time">
                        </div>
                    </div>
                    <div class="form-group">
                        <label class="col-sm-3 control-label">座位数:</label>
                        <div class="col-sm-9">
                            <input type="text" class="form-control" placeholder="座位数" name="MAX_SIT_USER">
                        </div>
                    </div><div class="form-group">
                        <label class="col-sm-3 control-label">台费:</label>
                        <div class="col-sm-9">
                            <input type="text" class="form-control" placeholder="台费" name="FEE">
                        </div>
                    </div><div class="form-group">
                        <label class="col-sm-3 control-label">进场最小携带:</label>
                        <div class="col-sm-9">
                            <input type="text" class="form-control" placeholder="进场最小携带" name="MIN_ANTE">
                        </div>
                    </div><div class="form-group">
                        <label class="col-sm-3 control-label">进场最大携带:</label>
                        <div class="col-sm-9">
                            <input type="text" class="form-control" placeholder="进场最大携带" name="MAX_ANTE">
                        </div>
                    </div><div class="form-group">
                        <label class="col-sm-3 control-label">进场玩家最少拥有多少钱:</label>
                        <div class="col-sm-9">
                            <input type="text" class="form-control" placeholder="进场玩家最少拥有多少钱" name="MIN_IN">
                        </div>
                    </div><div class="form-group">
                        <label class="col-sm-3 control-label">进场玩家最多拥有多少钱:</label>
                        <div class="col-sm-9">
                            <input type="text" class="form-control" placeholder="进场玩家最多拥有多少钱" name="MAX_IN">
                        </div>
                    </div><div class="form-group">
                        <label class="col-sm-3 control-label">播放结算动画时间:</label>
                        <div class="col-sm-9">
                            <input type="text" class="form-control" placeholder="播放结算动画时间" name="ANIMATION_TIME">
                        </div>
                    </div><div class="form-group">
                        <label class="col-sm-3 control-label">几局不操作站起:</label>
                        <div class="col-sm-9">
                            <input type="text" class="form-control" placeholder="几局不操作站起" name="NO_OPER_STAND_ROUND">
                        </div>
                    </div><div class="form-group">
                        <label class="col-sm-3 control-label">桌子名字:</label>
                        <div class="col-sm-9">
                            <input type="text" class="form-control" placeholder="桌子名字" name="table_name">
                        </div>
                    </div><div class="form-group">
                        <label class="col-sm-3 control-label">检查机器人状态时间:</label>
                        <div class="col-sm-9">
                            <input type="text" class="form-control" placeholder="检查机器人状态时间" name="robot_check_time">
                        </div>
                    </div><div class="form-group">
                        <label class="col-sm-3 control-label">机器人数量:</label>
                        <div class="col-sm-9">
                            <input type="text" class="form-control" placeholder="机器人数量" name="robot_num">
                        </div>
                    </div><div class="form-group">
                        <label class="col-sm-3 control-label">机器人最少多少秒进入:</label>
                        <div class="col-sm-9">
                            <input type="text" class="form-control" placeholder="机器人最少多少秒进入" name="robot_in_min_time">
                        </div>
                    </div><div class="form-group">
                        <label class="col-sm-3 control-label">机器人最多多少秒进入:</label>
                        <div class="col-sm-9">
                            <input type="text" class="form-control" placeholder="机器人最多多少秒进入" name="robot_in_max_time">
                        </div>
                    </div><div class="form-group">
                        <label class="col-sm-3 control-label">机器人最少多少秒退出:</label>
                        <div class="col-sm-9">
                            <input type="text" class="form-control" placeholder="机器人最少多少秒退出" name="robot_out_min_time">
                        </div>
                    </div><div class="form-group">
                        <label class="col-sm-3 control-label">机器人最多多少秒退出:</label>
                        <div class="col-sm-9">
                            <input type="text" class="form-control" placeholder="机器人最多多少秒退出" name="robot_out_max_time">
                        </div>
                    </div><div class="form-group">
                        <label class="col-sm-3 control-label">新手前多少局享受新手好牌:</label>
                        <div class="col-sm-9">
                            <input type="text" class="form-control" placeholder="新手前多少局享受新手好牌" name="newplayer_rounds">
                        </div>
                    </div><div class="form-group">
                        <label class="col-sm-3 control-label">新手好牌概率:</label>
                        <div class="col-sm-9">
                            <input type="text" class="form-control" placeholder="新手好牌概率" name="newplayer_probability">
                        </div>
                    </div>
                </div>
                <div class="modal-footer">
                    <button type="button" class="btn btn-default" data-dismiss="modal">关闭</button>
                    <button type="button" class="btn btn-primary J_ajaxSubmitBtn">提交</button>
                </div>
            </form>
        </div>
    </div>
</div>
<script src="<?php echo base_url();?>public/js/common.js"></script>

<script>
    $(function () {
        $(".btnedit").click(function(){
            var tb_level = $(this).attr('levelid');
            $("input[name='level']").val($("td[name='level_"+tb_level+"']").text());
            $("input[name='SmallBlind']").val($("td[name='SmallBlind_"+tb_level+"']").text());
            $("input[name='one_card_time']").val($("td[name='one_card_time_"+tb_level+"']").text());
            $("input[name='BET_TIME']").val($("td[name='BET_TIME_"+tb_level+"']").text());
            $("input[name='show_pool_time']").val($("td[name='show_pool_time_"+tb_level+"']").text());
            $("input[name='delaystop_time']").val($("td[name='delaystop_time_"+tb_level+"']").text());
            $("input[name='MAX_SIT_USER']").val($("td[name='MAX_SIT_USER_"+tb_level+"']").text());
            $("input[name='FEE']").val($("td[name='FEE_"+tb_level+"']").text());
            $("input[name='MIN_ANTE']").val($("td[name='MIN_ANTE_"+tb_level+"']").text());
            $("input[name='MAX_ANTE']").val($("td[name='MAX_ANTE_"+tb_level+"']").text());
            $("input[name='MIN_IN']").val($("td[name='MIN_IN_"+tb_level+"']").text());
            $("input[name='MAX_IN']").val($("td[name='MAX_IN_"+tb_level+"']").text());
            $("input[name='ANIMATION_TIME']").val($("td[name='ANIMATION_TIME_"+tb_level+"']").text());
            $("input[name='NO_OPER_STAND_ROUND']").val($("td[name='NO_OPER_STAND_ROUND_"+tb_level+"']").text());
            $("input[name='table_name']").val($("td[name='table_name_"+tb_level+"']").text());
            $("input[name='robot_check_time']").val($("td[name='robot_check_time_"+tb_level+"']").text());
            $("input[name='robot_num']").val($("td[name='robot_num_"+tb_level+"']").text());
            $("input[name='robot_in_min_time']").val($("td[name='robot_in_min_time_"+tb_level+"']").text());
            $("input[name='robot_in_max_time']").val($("td[name='robot_in_max_time_"+tb_level+"']").text());
            $("input[name='robot_out_min_time']").val($("td[name='robot_out_min_time_"+tb_level+"']").text());
            $("input[name='robot_out_max_time']").val($("td[name='robot_out_max_time_"+tb_level+"']").text());
            $("input[name='newplayer_rounds']").val($("td[name='newplayer_rounds_"+tb_level+"']").text());
            $("input[name='newplayer_probability']").val($("td[name='newplayer_probability_"+tb_level+"']").text());
        });


            $('#configTable td').dblclick(function(){
                var _this = $(this),//保存td
                    msgTip = $('#msg-tip'),
                    tdText = _this.text(),
                    cellIndex =  _this[0].cellIndex;
                    if(cellIndex < 2) {return false;} //点击前两列不可编辑

                if(!_this.is('.input')){
                    _this.addClass('input').html('<input type="text" value="'+ tdText +'" />').find('input').focus().blur(function(){
                        var thisid = $(this).parent().siblings("td:eq(0)").text();
                        var thisvalue = $(this).val();
                        var paramName = _this.attr('name');
                        var _input = $(this); //保存input对象

                        if(tdText == thisvalue) {
                            _input.parent().removeClass('input').html(tdText || 0);
                            return ;
                        }
                         //ajax将修改后的数据提交到后台
                         $.ajax({
                             type: 'POST',
                             url: rootPath + 'config/editTableAjax',
                             dataType: 'json',
                             data: {
                                 "level": thisid,
                                 "paramName": paramName ,
                                 "value": thisvalue
                             },
                             success: function (data) {
                                 if(data.ret == 0) {
                                     _this.removeClass('text-red');
                                     _input.parent().removeClass('input').html(thisvalue || 0);
                                 }else {
                                     msgTip.messager().error(data.msg);
                                     _this.addClass('text-red');
                                 }
                             },
                             error: function () {
                                 msgTip.messager().error('网络错误，请刷新后重试');
                             }
                         });

                    });
                }
            });


    });



</script>