<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>销售数据</title>
    <link rel="stylesheet" href="/static/css/base.css?123">
    <link rel="stylesheet" href="/static/css/index.css">
    <link rel="stylesheet" href="/static/css/bootstrap.min.css">
    <link rel="stylesheet" href="/static/css/bootstrap-select.min.css">
    <script src="/static/js/jquery.min.js"></script>
    <script src="/static/js/bootstrap.min.js"></script>
    <script src="/static/js/myfun.js"></script>
    <script src="/static/js/bootstrap-select.min.js"></script>
    <style>
        .table thead tr th {
            text-align: center;
            /* height: 30px;
            line-height: 30px; */
        }

        td.text-l {
            text-align: left;
        }

        td.td-manager {
            text-align: center;
        }

        .td-manager a {
            display: inline;
            line-height: 20px;
        }

        div.bj {
            display: none;
        }

        div.active {
            display: block;
        }

        .market-container {
            margin-left: 20px;
        }
    </style>
</head>

<body>
    <div class="market-container">
        <div class="header">
            <span><img src="../img/logo.jpg" alt=""></span>
            <span>北京赛亿科技有限公司</span>
        </div>
        <div class="aside">
            <div class="col-md-12 lin-height text_center"><a href="/index.php">提成汇总</a></div>
            <div class="col-md-12 lin-height text_center"><a href="javascript:;">计提数据录入</a></div>
            <div class="col-md-12 lin-height text_center"><a href="/seller.php">销售员管理</a></div>
            <div class="col-md-12 lin-height text_center"><a href="/company.php">销售单位管理</a></div>
        </div>
        <div class="content" style="width: 1400px;">
            <div class="time row">
                <div class="col-md-3">
                    请选择月份 :
                    <select name="select_time" id="select_time">
                        <?php
                        foreach ($maonth_picker->monarr as $value) {
                            if ($maonth_picker->cur_month == $value) {
                                echo "<option value='$value' selected>$value</option>";
                            } else {
                                echo "<option value='$value'>$value</option>";
                            }
                        }
                        ?>
                    </select>
                </div>
                <div class="col-md-5 text_center">
                    <h4><?php echo $maonth_picker->cur_month; ?>份销售提成表</h4>
                </div>
                <div class="col-md-3 " style="text-align:right;">
                    <div class="btn-group ">
                        <button type="button" class="btn btn-primary btn-lg" data-toggle="modal" data-target="#myModal">数据录入</button>
                    </div>
                </div>
            </div>
        </div>
        <!-- <div style="text-align:right;">
            <ul class="pagination">
                <li><a href=" #">&laquo;</a></li>
                <li><a href="#">1</a></li>
                <li><a href="#">2</a></li>
                <li><a href="#">3</a></li>
                <li><a href="#">4</a></li>
                <li><a href="#">5</a></li>
                <li><a href="#">&raquo;</a></li>
            </ul>
        </div> -->
        <!-- <div class="footer" style="width: 1600px;">
            <div class="row text_center" style="margin:0 auto;">
                <div class="col-md-2" style="line-height: 40px;">制表:</div>
                <div class="col-md-2" style="line-height: 40px;">复核:</div>
                <div class="col-md-2" style="line-height: 40px;">审批:</div>
                <div class="col-md-2" style="line-height: 40px;">制表:</div>
                <div class="col-md-2" style="line-height: 40px;">日期:</div>
                <div class="col-md-2" style="line-height: 40px;">日期:</div>
                <div class="col-md-2" style="line-height: 40px;">日期:</div>
                <div class="col-md-2" style="line-height: 40px;">日期:</div>
            </div>
        </div> -->
        <?php include_once(__DIR__ . DS . 'input.php');?>
    </div>

    <script>
        function changUrl() {
            select_time = $("#select_time").val();
            c_type = $("#c_type").val();
            // console.log(select_time);
            // console.log(c_type);
            window.location.href = "/market.php?select_time=" + select_time+"&c_type=" + c_type;
        }

        $("#select_time").change(function() {
            changUrl()
        })

        $("#c_type").change(function(){
            changUrl()
        })

        
        function edit(obj) {
            let data = $(obj).data('val');
            // console.log(data);
            $("#id").val(data.id);
            $('#company').selectpicker('val', data.company);
            // $("#company").append('<option value="'+data.company+'" selected>'+data.company+'</option>').selectpicker('refresh');
            $("#contract_no").html('<option value="' + data.contract_no + '" selected>' + data.contract_no + '</option>');
            $("#goods_category").html('<option  value=' + data.goods_category + ' selected>' + data.goods_category + '</option>');
            $("#goods_type").html('<option ' + data.goods_type + ' selected>' + data.goods_type + '</option>');
            $("#amount").val(data.amount);
            $("#price").val(data.price);
            $("#contract_value").val(data.contract_value);
            $("#receive_money").val(data.receive_money);
            $("#period_balance").val(data.period_balance);
            $("#actual_money").val(data.actual_money);
            $("#agency").val(data.agency);
            $("#shipping").val(data.shipping);
            $("#current_balance").val(data.current_balance);
            let type = data.type;
            // console.log(type)
            $('input[name="type"]').prop('checked', false);
            $("#type" + type).prop('checked', true);
            if (type != 0) {
                $("#base_price2").val(data.base_price);
                $("#actual_value").val(data.actual_value);
                $("#price_rate").val(data.price_rate);
                $("#commission_rate").val(data.c_rate);
                $("#commission_money").val(data.commission_money);
                $('#yiban').removeClass('active');
                $('#tepi').addClass('active');
            } else {
                $("#base_price").val(data.base_price);
                $("#base_value").val(data.base_value);
                $("#project").val(data.project);
                $("#total_profit").val(data.total_profit);
                $('#tepi').removeClass('active');
                $('#yiban').addClass('active');
            }

            $("#seller").val(data.seller);
            $("#remark").val(data.remark);
            $('#myModal').modal('show');
            return false;
        }

        function del(id, obj) {
            $.ajax({
                url: "/domarket.php?action=delete",
                type: "POST",
                data: {
                    "id": id
                },
                dataType: 'json',
                success: function(data) {
                    // console.log(data.code);
                    if (data.code == 0) {
                        $(obj).parents("tr").remove();
                    } else {
                        alert(data.msg);
                    }
                    return false;
                }
            });
        }
    </script>
</body>

</html>