<!doctype html>
<html class="no-js">
<head>

<include file="Common/head" />

    <style type="text/css">
        a.am-text-secondary:visited{color:#3bb4f2;}
        a.am-text-danger:visited{color:#dd514c;}
        .am-btn-default {background-color: #fff;}
        th {text-align:center;}
        tr td{text-align:center;}
        select{padding: 4px;border: 1px solid #ccc;}
        .am-popup-bd {background:#fff;}
        .am-popup-bd img {max-width: 100%}
        .am-u-sm-2 {border-top: 1px solid #ddd;margin-top: 10px;}
        .am-u-sm-10 {border-left: 1px solid #ddd;margin-top: 10px;}
    </style>
</head>
<body>

<include file="Common/header" />

<div class="am-cf admin">

    <!-- sidebar start -->
    <include file="Common/sidebar" nav="$nav"/>
    <!-- sidebar end -->

    <!-- Start right Content here -->
        <div class="content-page" style="background: white;">
            <!-- Start content -->
            <div class="content">
            <div class="am-cf am-padding am-padding-bottom-0">
                <div class="am-fl am-cf">
                    <strong class="am-text-primary am-text-lg">Setting</strong> / <small>Table Management</small>
                </div>
            </div>

            <?php foreach ($layer as $vo) : ?>
            <a href="{:U('index_seats', ['id' => $vo['id']])}" type="button" class="am-btn am-btn-primary btn-loading-example" data-id="{$vo.id}">{$vo.name}</a>
            <?php endforeach;?>
            <a type="button" class="am-btn am-btn-default" href="{:U('layer_list')}">Add Floor</a>
            <a type="button" class="am-btn am-btn-default" href="{:U('add_seat')}">Add Table</a>

            <div class="am-g">
                <div class="am-u-sm-12">
                    <table class="am-table am-table-hover table-main am-text-nowrap">
                        <thead>
                            <tr>
                            <th>Table No.</th>
                            <th>Floor</th>
                            <th>Table QR Code</th>
                            <th>Action</th>
                            </tr>
                        </thead>
                        <tbody>
                            <?php foreach ($table as $vo) : ?>
                                <tr>
                                    <td>{$vo.name}</td>
                                    <td>{$vo.layer}</td>
                                    <!-- <td><a href="{$vo.ercode_url}">点我生成二维码</a></td> -->
                                    <td><a href="{$vo.ercode_url}"><img src="{$vo.ercode_url}" style="width:100px;height:100px"></a></td>
                                    <td>
                                        <div class="am-dropdown" data-am-dropdown>
                                            <button class="am-btn am-btn-default am-btn-xs am-dropdown-toggle" data-am-dropdown-toggle>
                                                <span class="am-icon-cog"></span>
                                                <span class="am-icon-caret-down"></span>
                                            </button>
                                            <ul class="am-dropdown-content">
                                                <li><a href="{:U('edit_seat',array('id' => $vo['id']))}">Edit</a></li>
                                                <li>
                                                    <a class="del_link" data-name="{$vo.name}" data-url="{:U('delete', array('id' => $vo[id]))}" href="javascript:;">
                                                       Delete
                                                    </a>
                                                </li>
                                            </ul>
                                        </div>
                                    </td>
                                </tr>
                            <?php endforeach; ?>
                        </tbody>
                    </table>
                    {$page}
                    </fieldset>
                    </form>
                </div>
            </div>
        </div>
    </div>
    <!-- content end -->
</div>

<include file="Common/footer" />

</body>
<script type="text/javascript">
    $(function() {
        $('.btn-loading-example').click(function() {
          var $btn = $(this);
          $btn.button('loading');

            setTimeout(function(){
              $btn.button('reset');
          }, 1000);

        });


         $(".del_link").on("click",function(){
            var name=$(this).attr("data-name");
            var the_link=$(this).attr("data-url");
            var bool = confirm("Are you sure to delete the table?");
            if (bool) {
                location.href = the_link;
            };
        });
    });
</script>
</html>