@extends('layouts.admin')
@section('content')


    {{--修改表格--}}
    <style>
        .table-bordered>tbody>tr>td,.table-bordered>thead:first-child>tr:first-child>th{
            border: 1px solid #585858;
            font-weight: bold;
            text-align: center;
            font-size: 16px;
            overflow:hidden;
            width: 12%;
            padding: 15px 0px 15px 0px;
        }
        .table>tbody>tr>td{
            padding: 15px 0px 15px 0px;
            vertical-align: middle;
        }
        .table>tbody:first-child>tr>td{
            padding: 0px;
        }
        .table>tbody>tr>td>.form-control{
            margin: 15px 0px 15px 0px;
            width: 80%;
        }
    </style>

    <!--左侧菜单栏-->
    @include('admin.left-sidebar')
            <!-- 内容 -->
    <div class="content-wrapper">
        <!-- Content Header (Page header) -->
        <section class="content-header">
            <h1>
                受理案件
                <small> </small>
            </h1>
            <ol class="breadcrumb">
                <li><a href="{{ url('/')}}"><i class="fa fa-dashboard"></i> 主页</a></li>
                <li><a href="#">项目申请</a></li>
                <li><a href="{{ url('/table') }}">受理案件</a></li>
            </ol>
        </section>
        <!-- Main content -->
        <section class="content">
            <!-- Default box -->
            <div class="box">
                <div class="box-header">

                </div>
                <!-- /.box-header -->
                <div class="box-body">
                    {{--content--}}
                    <div class="row" style="text-align: center">
                        <h3>国有土地上房屋征收与补偿核算单（产权调换）</h3><br>
                    </div>
                    <form action="" method="post">
                        {{ csrf_field() }}
                        <div id="example2_wrapper" class="dataTables_wrapper form-inline dt-bootstrap">
                            <div class="row">
                                <div class="col-sm-2">项目名称：</div>
                                <div class="col-sm-7">
                                    <select class="form-control" name="project_name">
                                        <option>请选择项目</option>
                                        @foreach($project as $data)
                                            <option value="{{ $data->project_name }}">{{ $data->project_name }}</option>
                                        @endforeach
                                    </select>                            </div>
                                <div class="col-sm-1">编号：</div>
                                <div class="col-sm-2">
                                    <input style="margin: 0px;" name="num" class="form-control" type="text" placeholder=" ">
                                </div><br><br>
                            </div>
                            <div class="row">
                                <div class="col-sm-12">
                                    <table style="border: 1px solid #585858" id="example2" class="table table-bordered">
                                        <tbody>
                                        <tr>
                                            <td></td>
                                            <td></td>
                                            <td></td>
                                            <td></td>
                                            <td></td>
                                            <td></td>
                                            <td></td>
                                            <td></td>
                                            <td></td>
                                        </tr>
                                        <tr>
                                            <td>被征收户姓名</td>
                                            <td colspan="3"><input name="bzc_name" class="form-control" type="text" placeholder="必填项"></td>
                                            <td>被征收房屋住址</td>
                                            <td colspan="4"><input name="bzc_addr" class="form-control" type="text" placeholder="必填项"></td>
                                        </tr>
                                        <tr>
                                            <td>联系电话</td>
                                            <td colspan="3"><input name="bzc_tel" class="form-control" type="text" placeholder="必填项(数字)"></td>
                                            <td>被征收人身份证号</td>
                                            <td colspan="4"><input name="bzc_cardid" class="form-control" type="text" placeholder="必填项(数字)"></td>
                                        </tr>
                                        <tr>
                                            <td colspan="2">拆迁补偿总金额</td>
                                            <td colspan="5"><input disabled id="data431" class="form-control" type="text" placeholder="大写">（元）</td>
                                            <td colspan="2"><input name="data43" class="form-control" type="text" placeholder="小写" onclick="get_change(data24,data25,data26,data27,data39_13,this)">（元）</td>
                                        </tr>
                                        <tr>
                                            <td rowspan="8">产权调换差价计算</td>
                                            <td>房屋类别</td>
                                            <td>可调换面积（㎡）</td>
                                            <td>实际调换面积（㎡）</td>
                                            <td>大于可调换面积（㎡）</td>
                                            <td>小于可调换面积（㎡）</td>
                                            <td colspan="3">可调换面积价格核算（元）</td>
                                        </tr>
                                        <tr>
                                            <td>住宅</td>
                                            <td><input name="home_area" class="form-control" type="text" placeholder=""  onclick="add(bzc_area,data5,data17,this)"></td>
                                            <td><input name="data50" class="form-control" type="text" placeholder=""></td>
                                            <td><input name="data51" class="form-control" type="text" placeholder=""></td>
                                            <td><input name="data51_1" class="form-control" type="text" placeholder=""></td>
                                            <td colspan="3"><input name="data52" class="form-control" type="text" placeholder=""></td>
                                        </tr>

                                        <tr>
                                            <td>商业</td>
                                            <td><input name="data53" class="form-control" type="text" placeholder="" onclick="add(data10,data14,data18,this)"></td>
                                            <td><input name="data54" class="form-control" type="text" placeholder=""></td>
                                            <td><input name="data55" class="form-control" type="text" placeholder=""></td>
                                            <td><input name="data55_1" class="form-control" type="text" placeholder=""></td>
                                            <td colspan="3"><input name="data56" class="form-control" type="text" placeholder=""></td>
                                        </tr>
                                        <tr>
                                            <td>房屋类别</td>
                                            <td colspan="2">大于可调换面积价格核算（元）</td>
                                            <td>调换房屋价格（元）</td>
                                            <td colspan="2">应退差额（元）</td>
                                            <td colspan="2">应缴差额（元）</td>
                                        </tr>
                                        <tr>
                                            <td rowspan="2">住宅</td>
                                            <td colspan="2"><input name="data57" class="form-control" type="text" placeholder=""></td>
                                            <td rowspan="2"><input name="data58" class="form-control" type="text" placeholder=""  onclick="add(data52,data57,data57_1,this)"></td>
                                            <td colspan="2" rowspan="3"><input name="data59" id="data59" class="form-control" type="text" onclick="jian(data43,data58,data62)"></td>
                                            <td colspan="2" rowspan="3"><input name="data60" id="data60" class="form-control" type="text"  onclick="jian(data43,data58,data62)"></td>
                                        </tr>
                                        <tr>
                                            <td colspan="2"><input name="data57_1" class="form-control" type="text" ></td>
                                        </tr>
                                        <tr>
                                            <td rowspan="2">商业</td>
                                            <td colspan="2"><input name="data61" class="form-control" type="text" placeholder=""></td>
                                            <td rowspan="2"><input name="data62" class="form-control" type="text" placeholder="" onclick="add(data56,data61,data61_1,this)"></td>
                                        </tr>
                                        <tr>
                                            <td colspan="2"><input name="data61_1" class="form-control" type="text" ></td>
                                            <td  colspan="2"><a href="{{ url('/next_table') }}">转下页</a></td>
                                            <td  colspan="2"> </td>
                                        </tr>
                                        <tr>
                                            <td>调换房屋位置</td>
                                            <td colspan="8"><input name="data63" class="form-control" type="text" value="       小区      楼号     单元      层数      室"></td>
                                        </tr>
                                        <tr>
                                            <td rowspan="2" colspan="2">征收人<br><textarea name="zc" style="width: 80%;height: 100px;"></textarea></td>
                                            <td>被征收人</td>
                                            <td colspan="2"><input name="bzc" class="form-control" type="text" placeholder=""></td>
                                            <td >代理人</td>
                                            <td colspan="3"><input name="daili" class="form-control" type="text" placeholder=""></td>
                                        </tr>
                                        <tr>
                                            <td>签约时间</td>
                                            <td colspan="7"><input readonly id="table_time" name="table_time" class="form-control form_datetime" type="text" placeholder=""></td>
                                        </tr>
                                        <tr>
                                            <td><p>发证单位审核意见</p></td>
                                            <td colspan="3"><p style="margin-top: 50%;text-align: center"> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;年 &nbsp;&nbsp;&nbsp;&nbsp;月 &nbsp;&nbsp;&nbsp;&nbsp;日</p></td>
                                            <td><p>征收实施单位审批意见</p></td>
                                            <td colspan="4"><p style="margin-top: 50%;text-align: center"> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;年 &nbsp;&nbsp;&nbsp;&nbsp;月 &nbsp;&nbsp;&nbsp;&nbsp;日</p></td>
                                        </tr>
                                        </tbody>
                                    </table>
                                    <div class="row">
                                        <div class="col-sm-4">核算：<input   name="hesuan"  style="border: none #ffffff;border-bottom: #777777 solid 1px;" type="text" placeholder=""></div>
                                        <div class="col-sm-4">初审：<input disabled style="border: none #ffffff;border-bottom: #777777 solid 1px;" ></div>
                                        <div class="col-sm-4">监审：<input disabled style="border: none #ffffff;border-bottom: #777777 solid 1px;" ></div>
                                    </div><br>
                                    <div class="row">
                                        <div class="col-sm-4">复核：<input   name="fuhe"  style="border: none #ffffff;border-bottom: #777777 solid 1px;" type="text" placeholder=""></div>
                                    </div>
                                </div>
                            </div><br>
                            <div class="row">
                                <div class="col-sm-8">
                                </div>
                                <div class="col-sm-4">
                                    @if($user->role == 0)
                                        <button id="sub" type="submit" onclick="javascript:this.form.action='{{ url('/table/save/'.$table_type_id) }}'" class="btn btn-success">
                                            保存</button>
                                        <!-- Button trigger modal -->
                                        <button type="button" class="btn btn-primary" data-toggle="modal" data-target="#myModal">提交</button>
                                    @endif
                                    <a href="{{ url('/table') }}" class="btn btn-info">返回</a>
                                </div>
                            </div>
                        </div>

                        {{--model--}}
                        <div class="modal fade" id="myModal" tabindex="-1" role="dialog" aria-labelledby="myModalLabel">
                            <div class="modal-dialog" role="document">
                                <div class="modal-content">
                                    <div class="modal-header">
                                        <button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">&times;</span></button>
                                        <h4 class="modal-title" id="myModalLabel">提交说明</h4>
                                    </div>
                                    <div class="modal-body">
                                        <div class="form-group">
                                            <textarea class="form-control" id="model_des" name="sub_description" placeholder="输入您的内容..."></textarea>
                                        </div>
                                    </div>
                                    <div class="modal-footer">
                                        <button type="button" class="btn btn-default" data-dismiss="modal">返回</button>
                                        <button id="sub" type="submit" class="btn btn-primary" onclick="javascript:this.form.action='{{ url('/table/sub/'.$table_type_id.'/create') }}'">提交</button>
                                    </div>
                                </div>
                            </div>
                        </div>
                        {{--end model--}}
                    </form>

                    <script type="text/javascript">

                        $(".form_datetime").datetimepicker({
                            language: 'zh',
                            format: 'yyyy年mm月dd日',
                            minView:'month'
                        }).on('changeDate',function(){
                            $(".datetimepicker").hide();
                        });

                        function sum(result){
                            var sum = 0;
                            $(".sum").each(function(){
                                if (this.value == '') this.value = 0;
                                sum  += parseInt(this.value);
                            });
                            result.value = sum;
                        }

                        function get_product(left,right,product){
                            var result = (left.value*right.value);
                            product.value = result.toFixed(2);
                        }
                        function add(one,two,three,add) {
                            if ($(one).val() == ''){
                                $(one).val(0);
                            }if ($(two).val() == ''){
                                $(two).val(0);
                            }if ($(three).val() == ''){
                                $(three).val(0);
                            }
                            var result = parseFloat($(one).val()) + parseFloat($(two).val()) + parseFloat($(three).val());
                            add.value= Math.round(result);
                        }
                        function adde(one,two,three,four,add) {
                            var result = parseInt($(one).val()) + parseInt($(two).val()) + parseInt($(three).val()) + parseInt($(four).val());
                            add.value= Math.round(result);
                        }
                        function added(one,two,three,four,five,add) {
                            if ($(one).val() == ''){$(one).val(0);}
                            if ($(two).val() == ''){$(two).val(0);}
                            if ($(three).val() == ''){$(three).val(0);}
                            if ($(four).val() == ''){$(four).val(0);}
                            if ($(five).val() == ''){$(five).val(0);}
                            var result = parseInt($(one).val()) + parseInt($(two).val()) + parseInt($(three).val()) + parseInt($(four).val()) + parseInt($(five).val())
                            add.value= Math.round(result);
                        }

                        function jian(I,P,Q){
                            var result = 0;
                            if ($(I).val() == ''){$(I).val(0);}
                            if ($(P).val() != ''){
                                result = parseFloat($(I).val()) - parseFloat($(P).val())
                                result = Math.round(result);
                            }
                            if ($(Q).val() != ''){
                                result = parseFloat($(I).val()) - parseFloat($(Q).val())
                                result = Math.round(result);
                            }
                            if(result >= 0){
                                $('#data59').val(result);
                                $('#data60').val('');
                            }else{
                                $('#data59').val('');
                                $('#data60').val(result*(-1));
                            }
                        }

                        function NoToChinese(num,to) {
                            if (!/^\d*(\.\d*)?$/.test(num)) { alert("Number is wrong!"); return "Number is wrong!"; }
                            var AA = new Array("零", "壹", "贰", "叁", "肆", "伍", "陆", "柒", "捌", "玖");
                            var BB = new Array("", "拾", "佰", "仟", "萬", "億", "点", "");
                            var a = ("" + num).replace(/(^0*)/g, "").split("."), k = 0, re = "";
                            for (var i = a[0].length - 1; i >= 0; i--) {
                                switch (k) {
                                    case 0: re = BB[7] + re; break;
                                    case 4: if (!new RegExp("0{4}\\d{" + (a[0].length - i - 1) + "}$").test(a[0]))
                                        re = BB[4] + re; break;
                                    case 8: re = BB[5] + re; BB[7] = BB[5]; k = 0; break;
                                }
                                if (k % 4 == 2 && a[0].charAt(i + 2) != 0 && a[0].charAt(i + 1) == 0) re = AA[0] + re;
                                if (a[0].charAt(i) != 0) re = AA[a[0].charAt(i)] + BB[k % 4] + re; k++;
                            }

                            if (a.length > 1) //加上小数部分(如果有小数部分)
                            {
                                re += BB[6];
                                for (var i = 0; i < a[1].length; i++) re += AA[a[1].charAt(i)];
                            }

                            $(to).val(re);
                        }

                        function get_change(one,two,three,four,five,add){
                            if ($(one).val() == ''){$(one).val(0);}
                            if ($(two).val() == ''){$(two).val(0);}
                            if ($(three).val() == ''){$(three).val(0);}
                            if ($(four).val() == ''){$(four).val(0);}
                            if ($(five).val() == ''){$(five).val(0);}
                            var  num = 0;
                            num = parseInt($(one).val()) + parseInt($(two).val())+ parseInt($(three).val())+ parseInt($(four).val())+ parseInt($(five).val());

                            $(add).val(num);

//                            if (!/^\d*(\.\d*)?$/.test(num)) { alert("Number is wrong!"); return "Number is wrong!"; }
                            var AA = new Array("零", "壹", "贰", "叁", "肆", "伍", "陆", "柒", "捌", "玖");
                            var BB = new Array("", "拾", "佰", "仟", "萬", "億", "点", "");
                            var a = ("" + num).replace(/(^0*)/g, "").split("."), k = 0, re = "";
                            for (var i = a[0].length - 1; i >= 0; i--) {
                                switch (k) {
                                    case 0: re = BB[7] + re; break;
                                    case 4: if (!new RegExp("0{4}\\d{" + (a[0].length - i - 1) + "}$").test(a[0]))
                                        re = BB[4] + re; break;
                                    case 8: re = BB[5] + re; BB[7] = BB[5]; k = 0; break;
                                }
                                if (k % 4 == 2 && a[0].charAt(i + 2) != 0 && a[0].charAt(i + 1) == 0) re = AA[0] + re;
                                if (a[0].charAt(i) != 0) re = AA[a[0].charAt(i)] + BB[k % 4] + re; k++;
                            }

                            if (a.length > 1) //加上小数部分(如果有小数部分)
                            {
                                re += BB[6];
                                for (var i = 0; i < a[1].length; i++) re += AA[a[1].charAt(i)];
                            }

                            $('#data431').val(re);
                        }

                    </script>
                </div>
                <!-- /.box-body -->
            </div>
            <!-- /.box -->

        </section>
        <!-- /.content -->
    </div>
    <!-- /.content-wrapper -->
@endsection