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

<include file="Common/head" />

</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">Mini Game Management </strong> / <small>Golden Egg</small>  / <small>View Record</small>
                </div>
            </div>
            <hr style="margin-top:0px;">
            <div class="am-g">
                <div class="am-u-sm-12 am-u-md-12">
                    <a class="am-btn am-btn-secondary" href="javascript:;" onClick="javascript:location.href='{:U('sge_index')}'">Return to Prize List</a>
                    <select name="status" style="height: 37px;">
                        <option value="">All</option>
                        <option value="1" <if condition="$_GET['status'] eq 1">selected</if>>Shipped</option>
                        <option value="2" <if condition="$_GET['status'] eq 2">selected</if>>Winned Prize</option>
                        <option value="3" <if condition="$_GET['status'] eq 3">selected</if>>No Luck</option>
                    </select>
                    <button class="searchBtn am-btn am-btn-default" type="button">Search</button>
                </div>
            </div>
            <div class="am-g">
                <div class="am-u-sm-12">
                    <form class="am-form am-form-horizontal" action="" method="POST" enctype="multipart/form-data" id="goodsForm">
                    <table class="am-table am-table-hover table-main am-text-nowrap">
                        <thead>
                            <tr>
                                <th>Username</th>
                                <th>Prize Won</th>
                                <th>Image</th>
                                <th>Contact</th>
                                <th>Shipping Address</th>
                                <th>Status</th>
                                <th style="text-align:center" >Shipment Code</th>
                                <th>Created Date</th>
                                <th>Action</th>
                            </tr>
                        </thead>
                        <tbody>
                            <?php if (empty($list)) : ?>
                                <tr><td colspan="9" style="text-align:center" >There is no data</td></tr>
                            <?php endif;?>
                            <volist name="list" id="vo">
                                <tr>
                                    <td>{$vo.name}</td>
                                    <td>{$vo.goods_name}</td>
                                    <td><img src="__UPLOADS__/{$vo.img}" style="width: 80px; height: 60px"></td>
                                    <td>{$vo.mobile}</td>
                                    <td>{$vo.address}</td>
                                    <td>
                                        <?php if ($vo['status'] == 1) : ?>
                                            Has been shipped
                                        <?php elseif ($vo['status'] == 2) : ?>
                                            Not to deliver goods
                                        <?php elseif ($vo['status'] == 3) : ?>
                                            Not winning
                                        <?php endif;?>
                                    </td>
                                    <td style="text-align:center" >
                                        <?php if (!empty($vo['logistics_no'])) : ?>
                                            {$vo.logistics_no}
                                            <script type="text/javascript">
                                                var flag_kuaidi = false;
                                                function kuaidi(express_nu){
                                                    if(flag_kuaidi){return false;}
                                                    if(express_nu){
                                                        flag_kuaidi = true;
                                                        layer.open({
                                                            type:2, closeBtn:1, anim:0,shadeClose:true,
                                                            title:["Courier number："+express_nu, 'background-color:#fff;color:#000'],
                                                            area:['500px','85vh'],
                                                            content:"https://m.kuaidi100.com/result.jsp?nu="+express_nu
                                                        });
                                                        flag_kuaidi = false;
                                                    }
                                                  }
                                            </script>
                                            <a href="javascript:;" onclick="kuaidi('{$vo.logistics_no}')" style="font-size: 1.6rem"><span class="am-badge am-badge-primary">Click Me To Check Shipment</span></a>
                                        <?php endif;?>        
                                    </td>
                                    <td>{$vo.create_time|date="Y-m-d H:i:s", ###}</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">
                                                <?php if ($vo['status'] == 2) : ?>
                                                <li><button
                                                      type="button"
                                                      class="am-btn"
                                                      id="doc-prompt-toggle" data-id="{$vo['id']}">
                                                      Enter Shipment Code
                                                    </button>
                                                </li>
                                                <?php endif;?>
                                                <li>
                                                    <a class="del_link" type="button" class="am-btn" data-name="{$vo.name}" data-url="{:U('sge_delete_record', array('id' => $vo[id]))}" href="javascript:;">
                                                        Delete
                                                    </a>
                                                </li>
                                            </ul>
                                        </div>
                                    </td>
                                </tr>
                            </volist>
                        </tbody>
                    </table>
                </form>
                {$page}
                </div>
            </div>
        </div>
    </div>
    <!-- content end -->


    <div class="am-modal am-modal-prompt" tabindex="-1" id="my-prompt" data-id="">
      <div class="am-modal-dialog">
        <div class="am-modal-hd">Enter Shipment Code</div>
        <div class="am-modal-bd">
         Please Insert The Shipping Code Which
Stated On The Shipment Receipt
          <input type="text" class="am-modal-prompt-input" name="logistics_no" value="" placeholder="Please enter logistics number">
        </div>
        <div class="am-modal-footer">
          <span class="am-modal-btn" data-am-modal-cancel>Cancel</span>
          <span class="am-modal-btn" data-am-modal-confirm>Submit</span>
        </div>
      </div>
    </div>

</div>

<include file="Common/footer" />

<script src="__PUBLIC__/assets/js/laytpl.js" type="text/javascript" charset="utf-8" async defer></script>
<script type="text/javascript">
    $(function(){
        $(".del_link").on("click",function(){
            var name=$(this).attr("data-name");
            var the_link=$(this).attr("data-url");
            var bool = confirm("Confirm deletion?");
            if (bool) {
                location.href = the_link;
            };
        });

        // 入录物流单号
      $('#doc-prompt-toggle').on('click', function() {
        var id = $(this).attr('data-id');
        $('#my-prompt').attr('data-id', id);
        $('#my-prompt').modal({
          relatedTarget: this,
          onConfirm: function(e) {
            // alert('你输入的是：' + e.data || '')
            var id = $('#my-prompt').attr('data-id')
            var logistics_no = $('input[name=logistics_no]').val();
            if (logistics_no == undefined || logistics_no == null || logistics_no == '') {
                return false;
            }
            var data = {id: id, logistics_no: logistics_no};

            $.post('{:U(\"sge_logistics_no\")}',data,function(res){
              if (res.status == 1) {
                alert(res.msg);
                location.reload();
              } else {
                alert(res.msg)
              }
            });
          },
          onCancel: function(e) {
            alert('Please Insert The Shipment Code ASAP');
          }
        });
      });

      // 搜索
        $(".searchBtn").on("click",function(){
            var status = $("select[name='status']").val();
            var search = $("input[name='search']").val();
            var arr = new Array;
            if (status) arr.unshift("status="+status);
            if (arr.length > 0) {
                var str = "?"+arr.join("&");
            } else {
                var str = "";
            }
            location.href = "{:U('sge_winning_record')}"+str;
        });
    });
</script>
</body>
</html>