@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" 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 name="num" style="margin: 0px;" class="form-control" type="text" placeholder="必填项" value="{{ $table->num }}">
                            </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>
                                    </tr>
                                    <tr>
                                        <td>姓 名</td>
                                        <td colspan="2">身份证号码</td>
                                        <td>电 话</td>
                                        <td colspan="2">违章建筑地址</td>
                                    </tr>
                                    <tr>
                                        <td><input name="bzc_name" class="form-control" type="text" placeholder="" value="{{ $table->bzc_name }}"></td>
                                        <td colspan="2"><input name="bzc_cardid" class="form-control" type="text" placeholder="" value="{{ $table->bzc_cardid }}"></td>
                                        <td><input name="bzc_tel" class="form-control" type="text" placeholder="" value="{{ $table->bzc_tel }}"></td>
                                        <td colspan="2"><input name="bzc_addr" class="form-control" type="text" placeholder="" value="{{ $table->bzc_addr }}"></td>
                                    </tr>
                                    <tr>
                                        <td>违章面积（㎡）</td>
                                        <td><input name="bzc_area" class="form-control" type="text" placeholder="" value="{{ $table->bzc_area }}"></td>
                                        <td colspan="3">拆除金额：<input disabled id="chaichuje2" class="form-control" type="text" placeholder=""></td>
                                        <td><input id="chaichuje1" name="chaichuje" class="form-control" type="text" placeholder="小写" value="{{ $table->chaichuje }}" onclick="NoToChinese(this.value)"></td>
                                    </tr>
                                    <tr>
                                        <td colspan="6"><textarea name="jisuanmx"  style="width: 95%;height: 250px;" placeholder="计算明细：">{{ $table->jisuanmx }}</textarea></td>
                                    </tr>
                                    <tr>
                                        <td colspan="2">违章建筑自拆费用申取人：</td>
                                        <td><input name="zichaiqz" class="form-control" type="text" placeholder="" value="{{ $table->zichaiqz }}"></td>
                                        <td colspan="3">时 间：<input readonly id="table_time" name="table_time" class="form-control timepicker" type="text" placeholder="" value="{{ $table->table_time }}"></td>
                                    </tr>
                                    <tr>
                                        <td colspan="3">工作小组执法人员全体：<input name="workmanallqz" class="form-control" type="text" placeholder="" value="{{ $table->workmanallqz }}">
                                            <br>时 间：<input readonly id="workmanallqz_time" name="workmanallqz_time" class="form-control timepicker" type="text" placeholder="" value="{{ $table->workmanallqz_time }}"></td>
                                        <td colspan="3">区征拆局工作人员：<input name="zcworkmanqz" class="form-control" type="text" placeholder="" value="{{ $table->zcworkmanqz }}">
                                        <br>时 间：<input readonly id="zcworkmanqz_time" name="zcworkmanqz_time" class="form-control timepicker" type="text" placeholder="" value="{{ $table->zcworkmanqz_time }}"></td>
                                    </tr>
                                    <tr>
                                        <td colspan="3">工作小组组长：<input name="workcaptainqz" class="form-control" type="text" placeholder="" value="{{ $table->workcaptainqz }}">
                                            <br>时 间：<input readonly id="workcaptainqz_time" name="workcaptainqz_time" class="form-control timepicker" type="text" placeholder="" value="{{ $table->workcaptainqz_time }}"></td>
                                        <td colspan="3">督查专员：<input name="duchaqz" class="form-control" type="text" placeholder="" value="{{ $table->duchaqz }}">
                                            <br>时 间：<input readonly id=" duchaqz_time" name="duchaqz_time" class="form-control timepicker" type="text" placeholder="" value="{{ $table->duchaqz_time }}"></td>
                                    </tr>
                                    <tr>
                                        <td colspan="3">工作组负责人：<input name="workfzqz" class="form-control" type="text" placeholder="{{ $table->workfzqz }}">
                                            <br>时 间：<input readonly id="workfzqz_time" name="workfzqz_time" class="form-control timepicker" type="text" placeholder="" value="{{ $table->workfzqz_time }}"></td>
                                        <td colspan="3">分管领导：<input name="bossqz" class="form-control" type="text" placeholder="" value="{{ $table->bossqz }}">
                                            <br>时 间：<input readonly id="bossqz_time" name="bossqz_time" class="form-control timepicker" type="text" placeholder="" value="{{ $table->bossqz_time }}"></td>
                                    </tr>
                                    <tr>
                                        <td colspan="3">工作组意见，经我们核实，该违章户已按要求自行完成违章建筑的拆除，同意<input name="ok" class="form-control" type="text" placeholder="" value="{{ $table->ok }}">发放自行拆除费用
                                            <br>时 间：<input readonly id="ok_time" name="ok_time" class="form-control timepicker" type="text" placeholder="" value="{{ $table->ok_time }}"></td>
                                        <td colspan="3">财务负责人：<input name="cwqz" class="form-control" type="text" placeholder="" value="{{ $table->cwqz }}">
                                            <br>时 间：<input readonly id="cw_time" name="cw_time" class="form-control timepicker" type="text" placeholder="" value="{{ $table->cw_time }}"></td>
                                    </tr>
                                    <tr>
                                        <td><p>发证单位审核意见</p></td>
                                        <td colspan="2"><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="2"><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" value="{{ $table->fuhe }}" placeholder=""></div>
                                    <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>
                                @else
                                    <a href="{{ url('/') }}" class="btn btn-info">返回</a>
                                    <a onclick="printed('print')" class="btn btn-success">打印</a>
                                @endif
                            </div>
                        </div>
                        </form>
                    <script type="text/javascript">

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

                            $('#chaichuje2').val(re);
                        });
                        function NoToChinese(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)];
                            }

                            $('#chaichuje').val(re);
                        }
                        $(".timepicker").datetimepicker({
                            language: 'zh',
                            format: 'yyyy年mm月dd日',
                            minView:'month'
                        }).on('changeDate',function(){
                            $(".datetimepicker").hide();
                        });
                        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