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


    {{--修改表格--}}
@include('admin.table.style')

    <!--左侧菜单栏-->
@include('admin.left-sidebar')
    <!-- 内容 -->
<div class="content-wrapper" xmlns="http://www.w3.org/1999/html">
        <!-- 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" id="print">
                    {{--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 name="project_name" class="form-control">
                                    <option value=" "></option>
                                    @foreach($project as $data)
                                        <option value="{{ $data->project_name }}"
                                                @if($table->project_name == $data->project_name) selected @endif
                                        >{{ $data->project_name }}</option>
                                    @endforeach
                                </select>                            </div>
                            <div class="col-sm-1">编号：</div>
                            <div class="col-sm-2">
                                <input style="margin: 0px;" name="num" value="{{ $table->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><input name="bzc_name" value="{{ $table->bzc_name }}" class="form-control" type="text" placeholder=""></td>
                                        <td>被征收房屋住址</td>
                                        <td colspan="2"><input name="bzc_addr" value="{{ $table->bzc_addr }}" class="form-control" type="text" placeholder=""></td>
                                    </tr>
                                    <tr>
                                        <td>联系电话</td>
                                        <td><input name="bzc_tel" value="{{ $table->bzc_tel }}" class="form-control" type="text" placeholder=""></td>
                                        <td>被征收人身份证号</td>
                                        <td colspan="2"><input name="bzc_cardid" value="{{ $table->bzc_cardid }}" class="form-control" type="text" placeholder=""></td>
                                    </tr>
                                    <tr>
                                        <td>逾期开始时间</td>
                                        <td>逾期结束时间</td>
                                        <td>逾期月数</td>
                                        <td>补助标准</td>
                                        <td>合 计</td>
                                    </tr>
                                    <tr>
                                        <td><input name="yuqi_time1" id="yuqi_time1" class="form-control" type="hidden" placeholder="">
                                            <input readonly id="yuqi_time1_1" value="{{ $table->yuqi_time1 }}" class="form-control form_datetime" type="text"></td>
                                        <td><input readonly id="yuqi_time1_2" value="{{ $table->yuqi_time2 }}" class="form-control form_datetime" type="text"></td>
                                        <td><input name="yuqi_mothe1" value="{{ $table->yuqi_mothe1 }}" class="form-control" type="text" placeholder=""></td>
                                        <td><input name="buzu1" value="{{ $table->buzu1 }}" class="form-control" type="text" placeholder=""></td>
                                        <td><input name="total1" value="{{ $table->total1 }}" class="form-control" type="text" placeholder=""></td>
                                    </tr>
                                    <tr>
                                        <td><input name="yuqi_time2" id="yuqi_time2" value="{{ $table->yuqi_time2 }}" class="form-control" type="hidden" placeholder="">
                                            <input value="<?php echo substr($table->yuqi_time2,0,8);?>" readonly id="yuqi_time2_1" class="form-control form_datetime" type="text"></td>
                                        <td><input value="<?php echo substr($table->yuqi_time2,8,16);?>" readonly id="yuqi_time2_2" class="form-control form_datetime" type="text"></td>
                                        <td><input name="yuqi_mothe2" value="{{ $table->yuqi_mothe2 }}" class="form-control" type="text" placeholder=""></td>
                                        <td><input name="buzu2" value="{{ $table->buzu2 }}" class="form-control" type="text" placeholder=""></td>
                                        <td><input name="total2" value="{{ $table->total2 }}" class="form-control" type="text" placeholder=""></td>
                                    </tr>
                                    <tr>
                                        <td><input name="yuqi_time3" id="yuqi_time3" value="{{ $table->yuqi_time3 }}" class="form-control" type="hidden" placeholder="">
                                            <input value="<?php echo substr($table->yuqi_time3,0,8);?>" readonly id="yuqi_time3_1" class="form-control form_datetime" type="text"></td>
                                        <td><input value="<?php echo substr($table->yuqi_time3,8,16);?>" readonly id="yuqi_time3_2" class="form-control form_datetime" type="text"></td>
                                        <td><input name="yuqi_mothe3" value="{{ $table->yuqi_mothe3 }}" class="form-control" type="text" placeholder=""></td>
                                        <td><input name="buzu3" value="{{ $table->buzu3 }}" class="form-control" type="text" placeholder=""></td>
                                        <td><input name="total3" value="{{ $table->total3 }}" class="form-control" type="text" placeholder=""></td>
                                    </tr>
                                    <tr>
                                        <td><input name="yuqi_time4" id="yuqi_time4" value="{{ $table->yuqi_time4 }}" class="form-control" type="hidden" placeholder="">
                                            <input value="<?php echo substr($table->yuqi_time4,0,8);?>" readonly id="yuqi_time4_1" class="form-control form_datetime" type="text"></td>
                                        <td><input value="<?php echo substr($table->yuqi_time4,8,16);?>" readonly id="yuqi_time4_2" class="form-control form_datetime" type="text"></td>
                                        <td><input name="yuqi_mothe4" value="{{ $table->yuqi_mothe4 }}" class="form-control" type="text" placeholder=""></td>
                                        <td><input name="buzu4" value="{{ $table->buzu4 }}" class="form-control" type="text" placeholder=""></td>
                                        <td><input name="total4" value="{{ $table->total4 }}" class="form-control" type="text" placeholder=""></td>
                                    </tr>
                                    <tr>
                                        <td>逾期补偿金额</td>
                                        <td colspan="3">￥：<input id="yuqij2"  class="form-control" type="text" placeholder="">（元）</td>
                                        <td> <input name="yuqij" id="yuqij1" value="{{ $table->yuqij }}" class="form-control" type="text" placeholder="" onclick="add(total1,total2,total3,total4,yuqij)"> </td>
                                    </tr>
                                    <tr>
                                        <td>约定</td>
                                        <td colspan="4">1.待回迁楼建成交钥匙时，征收当事人根据双方实际逾期月数，据实结算安置过渡补助费差价。
                                        <br><input name="yueding" value="{{ $table->yueding }}" class="form-control" type="text" placeholder=""></td>
                                    </tr>
                                    <tr>
                                        <td rowspan="2" style="height: 90px;">征收实施单位（章）</td>
                                        <td>被征收人（签字）</td>
                                        <td ></td>
                                        <td >代理人（签字）</td>
                                        <td ></td>
                                    </tr>
                                    <tr>
                                        <td >签约时间</td>
                                        <td colspan="3"><input readonly id="table_time" name="table_time" class="form-control form_datetime" type="hidden" placeholder=""></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" value="{{ $table->fuhe }}" placeholder=""></div>
                                    <div class="col-sm-4">初审（签字）：<input style="border: none #ffffff;border-bottom: #777777 solid 1px;" ></div>
                                    <div class="col-sm-4">监审（签字）：<input style="border: none #ffffff;border-bottom: #777777 solid 1px;" ></div>
                                </div><br>
                                <div class="row">
                                    <div class="col-sm-8">
                                        提交说明 : <label id="sub_description">{{ $table->sub_description }}</label>
                                    </div>
                                </div>
                            </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_id) }}'">提交</button>
                                    </div>
                                </div>
                            </div>
                        </div>
                        {{--end model--}}
                        <div class="row" id="bottom_button">
                            <div class="col-sm-8"></div>
                            <div class="col-sm-4">
                                @if($table->status == null  || $table->status<3)
                                    @if($user->role == 0 && $table->status == 0)
                                        <button id="sub" type="submit" onclick="javascript:this.form.action='{{ url('/table/save/'.$table_id.'/update') }}'" class="btn btn-success">
                                            保存</button>
                                    @endif
                                    @if($user->role == $table->status)
                                        @if($table->status == 0)
                                            <button type="button" class="btn btn-primary" data-toggle="modal" data-target="#myModal">提交</button>
                                        @else
                                            <button id="sub" type="submit" onclick="javascript:this.form.action='{{ url('/table/sub/'.$table_id) }}'" class="btn btn-primary">
                                                提交</button>
                                        @endif
                                    @endif
                                    <a href="{{ url('/on_table') }}" class="btn btn-info">返回</a>
                                        <a href="{{ url('/print/'.$table_id) }}"  target="_blank"  class="btn btn-success">打印</a>
                                @else
                                    <a href="{{ url('/') }}" class="btn btn-info">返回</a>
                                    <a href="{{ url('/print/'.$table_id) }}"  target="_blank"  class="btn btn-success">打印</a>
                                @endif
                            </div>
                        </div>
                        </form>
                    <script type="text/javascript">

                        $(function(){
                            var num = $('#yuqij1').val();
                            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)];
                            }

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

                        $(".form_datetime").datetimepicker({
                            language: 'zh',
                            format: 'yyyy年mm月dd日',
                            minView:'month'
                        }).on('changeDate',function(){
                            $(".datetimepicker").hide();
                        });
                        function add(one,two,three,four,add){
                            var num = parseFloat($(one).val()) + parseFloat($(two).val())+ parseFloat($(three).val())+ parseFloat($(four).val());
                            num = Math.round(num);
                            $(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)];
                            }
                            $('#yuqij2').val(re);
                        }
                        function printed(printpage)
                        {
                            $('#bottom_button').hide();
                            var headstr = "<html><head><title></title></head><body>";
                            var footstr = "</body>";
                            var newstr = document.all.item(printpage).innerHTML;
                            var oldstr = document.body.innerHTML;
                            document.body.innerHTML = headstr+newstr+footstr;
                            window.print();
                            document.body.innerHTML = oldstr;
                            $('#bottom_button').show();

                            return false;
                        }
                    </script>
                </div>
                <!-- /.box-body -->
            </div>
            <!-- /.box -->
        </section>
        <!-- /.content -->
    </div>
    <!-- /.content-wrapper -->
@endsection