<?php include "snippets/header.phtml"; ?>

<?php include "snippets/navbar.phtml"; ?>

<div class="container">


    <!-- Main component for a primary marketing message or call to action -->
    <div class="jumbotron">
        <h3>新建</h3><a href="/accounts/new">账号</a>
        <div class="table-responsive">
        <table class="table table-striped table-hover" style="font-size: 10px;">
            <thead>
                <tr>
                    <th width="5%">#</th>
                    <th>账号名</th>
                    <th>描述</th>
                    <th>市场</th>
                    <th>组</th>
                    <th>操作</th>
                </tr>
            </thead>
            <tbody>
                <?php foreach ($account_list as $account) { ?>
                <tr>
                    <td><?php echo $account['id'];?></td>
                    <td><?php echo $account['name'];?></td>
                    <td><?php echo $account['description'];?></td>
                    <td><?php echo $account['market_id'].'#'.$account['market_name'];?></td>
                    <td><?php echo $account['account_group_id'].'#'.$account['account_group_name'];?></td>
                    <td class="handle"><a href="/accounts/<?php echo $account['id']; ?>/edit">编辑</a> / <a href="#" class="del_a">删除</a></td>
                </tr>
                <?php } ?>
            </tbody>
            <form id="del_form" action="/accounts" method="post">
                <input id="del_id" type="hidden" name="id" value="">
                <input type="hidden" name="_method" value="delete">
            </form>
        </table>
        </div>
    </div>

</div> <!-- /container -->


<?php include "snippets/footer.phtml"; ?>
<!-- Script -->
<script>
    var a = 2;
    $(document).ready(function() {
        $('.del_a').click(function() {
            if (confirm('sure delete?')) {
                var id = $(this).parent().parent().children(1).html();
                $('#del_id').val(id);
                $('#del_form').submit();
            }
        });
    });
</script>
