<?php
use \common\libs\MyLib;
?>
<style>
    .ml5{
        margin-top: 5px;
        margin-left: 10px;
    }
</style>
<link rel="stylesheet" href="/js/fileupload/css/jquery.fileupload.css">
<p class="ml5">新数据</p>
<table width="98%" border="0" align="center" cellpadding="2" cellspacing="1" class="table">
    <form id="theFrm">
        <tr>
            <td align="center" width="100" height="25" class="td_bg">导入类型</td>
            <td height="25" class="td_bg">新的数据</td>
        </tr>

        <tr>
            <td align="center" width="100" height="25" class="td_bg">批对日期</td>
            <td height="25" class="td_bg">
                <input type="text" name="urlfile" id="urlfile" style="width: 300px;">
                <input id="fileupload" type="file" name="file">
            </td>
        </tr>
    </form>
    <tr>
        <td height="22" colspan="2" align="center" class="td_bg">
            <input id="submit-btn" type=button class="ACT_btn" name=Submit1 value=" 提交 "/>
            &nbsp;&nbsp;
            <input type="button" class="ACT_btn" name="Submit3" value=" 刷新 " onclick="window.location.reload();">
        </td>
    </tr>
</table>
<p class="ml5">原始数据</p>

<table width="98%" border="0" align="center" cellpadding="2" cellspacing="1" class="table">
    <form id="oldFrm">
        <tr>
            <td align="center" width="100" height="25" class="td_bg">导入类型</td>
            <td height="25" class="td_bg">原始数据</td>
        </tr>

        <tr>
            <td align="center" width="100" height="25" class="td_bg">批对日期</td>
            <td height="25" class="td_bg">
                <input type="text" name="urlfile1" id="urlfile1" style="width: 300px;">
                <input id="fileupload1" type="file" name="file1">
            </td>
        </tr>
    </form>
    <tr>
        <td height="22" colspan="2" align="center" class="td_bg">
            <input id="submit-btn1" type=button class="ACT_btn" name=Submit1 value=" 提交 "/>
            &nbsp;&nbsp;
            <input type="button" class="ACT_btn" name="Submit3" value=" 刷新 " onclick="window.location.reload();">
        </td>
    </tr>
</table>


<script type="text/javascript" language="javascript" src="/js/jquery-1.8.3.js"></script>
<script type="text/javascript" language="javascript" src="/js/datepicker/WdatePicker.js"></script>
<script type="text/javascript" language="javascript" src="/js/fileupload/js/vendor/jquery.ui.widget.js"></script>
<script type="text/javascript" language="javascript" src="/js/fileupload/js/jquery.iframe-transport.js"></script>
<script type="text/javascript" language="javascript" src="/js/fileupload/js/jquery.fileupload.js"></script>
<script type="text/javascript" language="javascript" src="/js/ajax.js"></script>
<script type="text/javascript" language="javascript" src="/js/func.js"></script>
<script type="text/javascript" language="javascript">
    //编辑


    $(function () {
        //上传按钮
        $('#upload-btn').click(function(){
            $('#fileupload').click();
        });

        //提交按钮
        $("#submit-btn").click(function(){
            if(confirm('是否确认提交?')) {
                var urlfile = $("#urlfile").val();
                var import_type = $(".import_type").val();
                if(urlfile == ''){
                    alert('请先选择文件!');
                    return false;
                }
                var last_url = '/finance/carinfos';
                var params = $("#theFrm").serialize();

                $.post(last_url,params,function(obj){
                    alert(obj.msg);
                    if(obj.success){
                        $('#theFrm')[0].reset();
                        window.location.reload();
                    }
                },'json');
            }
        });
        $("#submit-btn1").click(function(){
            if(confirm('是否确认提交?')) {
                var urlfile = $("#urlfile1").val();
                var import_type = $(".import_type").val();
                if(urlfile == ''){
                    alert('请先选择文件!');
                    return false;
                }
                var last_url = '/finance/chuli-phone';
                var params = $("#oldFrm").serialize();

                $.post(last_url,params,function(obj){
                    alert(obj.msg);
                    if(obj.success){
                        $('#theFrm')[0].reset();
                        window.location.reload();
                    }
                },'json');
            }
        });
        //上传
        $('#fileupload').fileupload({
            url: '/finance/receipt-upload',
            dataType: 'json',
            done: function (e, data) {
                var file_info = data.result.files[0];
                $('#urlfile').val(file_info.url);
                $('#submit-btn').removeAttr('disabled');
            }
        });
        $('#fileupload1').fileupload({
            url: '/finance/receipt-upload1',
            dataType: 'json',
            done: function (e, data) {
                var file_info = data.result.files[0];
                $('#urlfile1').val(file_info.url);
                $('#submit-btn1').removeAttr('disabled');
            }
        });


    })
</script>
<style>
    input[type="text"] {
        width: 134px;
    }

</style>