<?php
/**
 * Created by PhpStorm.
 * User: Administrator
 * Date: 2018/1/5/005
 * Time: 17:43
 */
?>
<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>
    <img src="<?= STATIC_URL ?>/ui/img/gangtanhao1.png" style="text-align: center"/>
    <div class="modal-body">
        <div class="modal-attention">
        <?php if ($data['type'] == 1 || $data['type'] == 2) {?>
            <h3>确定审核通过?</h3>
        <?php } else { ?>
            <h3>确定审核不通过?</h3>
            <div>
                <span>不通过原因:</span>
                <textarea id="reason" name="reason" style="height:100px;width:300px;"></textarea>
            </div>
        <?php } ?>
        </div>
    </div>
    <div class="modal-footer" style="text-align: center">
        <button type="button" class="btn btn-white" data-dismiss="modal">取消</button>
        &nbsp;&nbsp;
        <button id="submit" type="button" class="btn btn-primary">确定</button>
    </div>
</div>

<script type="text/javascript">
    $("#submit").on("click", function () {
        var batchNo = "<?= $data['batch_no'] ?>";
        var type = "<?= $data['type'] ?>";
        var reason = $("#reason").val();
        var url = "";
        if (type == 1 || type == 3) {
            url = "<?= \yii\helpers\Url::to(['/admin/finance-remit/batch-audit']) ?>"
        } else if (type == 2 || type == 4) {
            url = "<?= \yii\helpers\Url::to(['/admin/finance-remit/batch-re-audit']) ?>"
        }
        $.ajax({
            type: "POST",
            url: url,
            data: {
                batch_no:batchNo,
                type:type,
                reason:reason
            },
            dataType: "json",
            beforeSend: function () {
            },
            success: function (data) {
                if (data.code == 1) {
                    toastr.success(data.message, "提示");
                    $("#modal").modal("hide");
                    table.ajax.reload();
                } else {
                    toastr.error(data.message, "提示");
                }
            },
            complete: function (XMLHttpRequest, textStatus) {
            },
            error: function () {
            }
        });
    });
</script>
