<div id="centre" class="layout">
    <div class="centreInner ">
        <div class="mainInner radius5 zsbreal">
            <?=form_open(uri_string(),array('method'=>'POST','name'=>'search_form'))?>
            <input type='hidden' name='page' value='1'>
            <div class="forms functionBox mt10">
                <dl class="list ">
                    <dd class="list_item clearfix">
                        <div class="fields">
                            <div class="fgInput jsFgInput">
                                <div class="imitateSelect">
                                    <label class="labelImitate">选择查询条件</label>
                                    <input type="text" name="search_name" class="imitate imitateIe" readonly="" value="<?=$searchList[$search]?>">
                                    <input type="hidden" name="search" class="jsImitateHidden" value="<?=$search?>">
                                    <div class="listImitate" style="display: none;">
                                        <dl class="inner">
                                            <?php foreach($searchList as $k=>$v) {
                                                echo '<dd><a class="link" oid="'.$k.'" href="####">'.$v.'</a></dd>';
                                            }  ?>
                                        </dl>
                                    </div>
                                </div>
                            </div>
                            <div class="fgInput nameInput ml12">
                                <div class="fgInput jsNameInput jsFgInput">
                                    <label id="jsHouseNume" for="jsNameInputNF" class="labelPrev labelPrevN jslabelPrev"></label>
                                    <input type="text" class="input_text w170" id="jsNameInputNF" name="keyword" value="<?=$keyword?>">
                                </div>
                            </div>
                            <p class="textFg textFg2">&nbsp;</p>
                            <div class="fgInput jsFgInput">
                                <div class="imitateSelect">
                                    <label class="labelImitate">选择举报原因</label>
                                    <input type="text" name="type_name" class="imitate imitateIe" readonly="" value="<?=$typeList[$type]?>">
                                    <input type="hidden" name="type" class="jsImitateHidden" value="<?=$type?>">
                                    <div class="listImitate">
                                        <dl class="inner">
                                            <?php foreach($typeList as $k=>$v) {
                                                echo '<dd><a class="link" oid="'.$k.'" href="####">'.$v.'</a></dd>';
                                            }  ?>
                                        </dl>
                                    </div>
                                </div>
                            </div>

                            <p class="textFg textFg2">&nbsp;</p>
                            <div class="fgInput jsFgInput">
                                <div class="imitateSelect">
                                    <label class="labelImitate">选择处理结果</label>
                                    <input type="text" name="report_result_name" class="imitate imitateIe" value="<?=$reportList[$report_result]?>" readonly="">
                                    <input type="hidden" name="report_result" class="jsImitateHidden" value="<?=$report_result?>">
                                    <div class="listImitate">
                                        <dl class="inner">
                                            <?php foreach($reportList as $k=>$v) {
                                                echo '<dd><a class="link" oid="'.$k.'" href="####">'.$v.'</a></dd>';
                                            }  ?>
                                        </dl>
                                    </div>
                                </div>
                            </div>
                            <p class="textFg textFg2">&nbsp;</p>
                            <div class="fgInput jsFgInput">
                                <div class="imitateSelect">
                                    <label class="labelImitate">选择申诉状态</label>
                                    <input type="text" name="appeal_name" class="imitate imitateIe" value="<?=$appealList[$appeal]?>" readonly="">
                                    <input type="hidden" name="appeal" class="jsImitateHidden" value="<?=$appeal?>">
                                    <div class="listImitate" style="display: none;">
                                        <dl class="inner">
                                            <?php foreach($appealList as $k=>$v) {
                                                echo '<dd><a class="link" oid="'.$k.'" href="####">'.$v.'</a></dd>';
                                            }  ?>
                                        </dl>
                                    </div>
                                </div>
                            </div>
                            <p class="textFg textFg2">&nbsp;</p>
                            <div class="fgInput"> <input type="submit" value="搜索" class="btn btnCon radius5" style="cursor: pointer;"> </div>

                        </div>
                    </dd>
                </dl>
            </div>
            <?php echo form_close();?>
            <div class="branchCommon branchCommon_pay radius5 mt20">
                <div class="hd">
                    <table class="tableExpert">
                        <tr>
                            <td class="td f w160">
                                <div class="">举报时间</div>
                            </td>
                            <td class="td w160">
                                <div class="">房源编号</div>
                            </td>
                            <td class="td w110">
                                <div class="">举报原因</div>
                            </td>
                            <td class="td w70">
                                <div class="">处理结果</div>
                            </td>
                            <td class="td w70">
                                <div class="">申诉状态</div>
                            </td>
                            <td class="td w70">
                                <div class="">操作</div>
                            </td>
                        </tr>
                    </table>
                </div>
                <div class="mod">
                    <table class="tableExpert tableExpert_no">
                        <!--无记录-->
                        <?php if (empty($reportData)) {?>
                            <tr>
                                <td colspan="6">
                                    <div class="ptb30 acenter">暂无违规记录</div>
                                </td>
                            </tr>
                        <?php } else { ?>
                            <?php foreach($reportData as $item) { ?>
                                <tr>
                                    <td class="td f w160">
                                        <div class=""><?=date('Y-m-d H:i:s', $item['report_time'])?></div>
                                    </td>
                                    <td class="td w160">
                                        <div class="">
                                            <a class="blue upsee" target="_blank" href="<?=$item['page_pic']?>">
                                                <?=$item['rowid']?>
<!--                                                <div class="upbig" style="display: none;">-->
<!--                                                    <img src="--><?//=$item['page_pic']?><!--">-->
<!--                                                </div>-->
                                            </a>
                                        </div>
                                    </td>
                                    <td class="td w110">
                                        <div class=""><?=$typeList[$item['type']]?></div>
                                    </td>
                                    <td class="td w70">
                                        <div class=""><?=$reportListArr[$item['report_result']]?></div>
                                    </td>
                                    <td class="td w70">
                                        <div class=""><?=$appealList[$item['appeal']]?></div>
                                    </td>
                                    <td class="td w70">
                                        <?php if ($item['report_result'] == 0 && $item['appeal'] == 0) {?>
                                            <div class="blue appealAlter" data-tbl="<?=$item['tbl']?>" data-houseId="<?=$item['rowid']?>" style="cursor: pointer;">
                                                申诉
                                            </div>
                                        <?php } else {?>
                                            <div class="c9">申诉</div>
                                        <?php } ?>
                                    </td>
                                </tr>
                            <?php } ?>
                        <?php } ?>
                    </table>
                </div>

            </div>
            <?php if (!empty($pagination)) { ?>
                <div class="picPreviewPagBox">
                    <div class="picPreviewPag">
                        <?php echo $pagination; ?>
                    </div>
                </div>
            <?php } ?>
        </div>
    </div>
</div>
<form action="/realHouse/appeal/" accept-charset="gbk" method="POST" name="appeal_form" onsubmit="return validateAppeal();" id="appeal_form">
    <div id="jsUploadHeadPortrait" class="dialog dialog2 radius5 dialog5" >
        <div class="hd">
            <h3 class="h3">申诉</h3>
            <p class="close-win close" title="关闭">关闭 </p>
        </div>
        <div class="uploadInnerBox">
            <ul>
                <li class="clearfix">
                    <label class="fl">违规房源编号：</label>
                    <table class="fl" id="reportList">
                    </table>
                </li>
                <li class="clearfix mt10">
<!--                    <label class="fl">违规房源编号：</label>-->
<!--                    <table class="fl" id="reportList">-->
<!--                    </table>-->
                </li>
                <li class="clearfix mt10">
                    <label class="fl mt10">
                        <span class="red">*</span>申诉理由：
                    </label>
                    <div class="fl">
                        <textarea name="reason" id="reason"></textarea>
                        <div class="clear consent_box_pay aleft mt10" id="checkConsent"><label><input id="js_checkConsent" type="checkbox" class="input_c" name="checkConsent" value="1">申请实勘</label>
                        </div>
                    </div>
                </li>
                <!--<li class="clearfix mt10" style="height: 30px;">
                    <label class="fl mt10">
                        <span class="red">*</span>楼栋门牌：
                    </label>
                    <div class="fl">
                        <input id="buildingnum" type="text" value="" maxlength="5" class="input_text w42 " name="buildingnum">
                        栋
                        <input id="unitnum" type="text" value="" maxlength="5" class="input_text w42" name="unitnum" >
                        单元
                        <input id="roomnum" type="text" value="" maxlength="5" class="input_text w42" name="roomnum">
                        室
                    </div>
                </li>-->
                <style>
                    #appeal_form .input_text {
                        height: 27px;
                        line-height: 27px;
                        padding: 0 4px;
                        background: #FFF;
                        border: 1px solid #BFBFBF;
                        -moz-box-shadow: 2px 2px 2px #F0F0F0 inset;
                        -webkit-box-shadow: 2px 2px 2px #F0F0F0 inset;
                        -ms-box-shadow: 2px 2px 2px #F0F0F0 inset;
                        -o-box-shadow: 2px 2px 2px #F0F0F0 inset;
                        box-shadow: 2px 2px 2px #F0F0F0 inset;
                        width: 50px;
                    }
                    .input_style{
                        height: 27px;
                        line-height: 27px;
                    }
                    .input_style2{
                        padding-right: 20px;
                        margin-right: 10px;
                    }


                </style>
                <li class="clearfix mt10">
                    <table width="100%">
                        <tr>
                            <td>内部编号：</td>
                            <td><input id="internal_num" type="text" value="" class="input_style" name="internal_num"></td>
                            <td>丘权号：</td>
                            <td><input id="appeal_qiqaun" type="text" value="" class="input_style" name="appeal_qiqaun"></td>
                        </tr>
                        <tr>
                            <td><span class="red">*</span>业主电话：</td>
                            <td><input id="owner_phone" type="text" value="" class="input_style" name="owner_phone"></td>
                            <td>产权证号：</td>
                            <td><input id="property_rights_num" type="text" value="" class="input_style" name="property_rights_num"></td>
                        </tr>
                        <tr>
                            <td><span class="red">*</span>产权人姓名：</td>
                            <td><input id="property_rights_name" type="text" value=""  class="input_style" name="property_rights_name"></td>
                            <td>产权人身份证号：</td>
                            <td> <input id="property_rights_person_id" type="text" value="" class="input_style" name="property_rights_person_id"></td>
                        </tr>
                    </table>
                </li>

                <li class="clearfix mt15">
                    <label class="fl mt5">
                        <span class="red">*</span>上传图片：
                    </label>
                    <div class="fl">
                        <div class="bd aleft aupload">
                            <!-- <a class="btn radius5 btnCon" href="####">图片上传</a> -->
                            <div id="spanButtonPlaceholder" style="display:none;"></div>
                        </div>
                        <!--<div class="bd aleft auploadn" style="display: none;">
                            <div class="abg"></div>
                        </div>-->
                        <div class="clearfix mt10">
                            <div class="fields">
                                <div id="thumbnails"></div>
                            </div>
                        </div>
                        <div class="red mt10">申诉请上传房产证或上传独家代理合同图片，并留下房东电话，以便核实。</div>
                    </div>
                </li>

            </ul>
            <div class="bd btnFBbox ">
                <a id="saveAppeal" class="btn radius5 btnCon btnO" href="####">提交</a> <a class="btn radius5 btnCon close-win" href="####">取消</a>
            </div>
        </div>
    </div>
</form>
<script type="text/javascript">
    $(function() {
        $(".upsee").hover(function(){
            $(this).children(".upbig").filter(':not(:animated)').fadeIn();
        },function(){
            $(this).children(".upbig").fadeOut();
        })
        $("#jsWdatePicker4").focus(wp41);
        $("#jsWdatePicker3").focus(wp31);
        //2018-3-21
        $(".realpic").hover(function(){
            $(this).children("span").show();
        },function(){
            $(this).children("span").hide();
        })
        $(".realpic span").on("click",function(){
            $(this).parent(".realpic").remove();

        })
        $(".appealAlter").on("click",function(){
            var tbl = $(this).attr('data-tbl');
            var houseId = $(this).attr('data-houseId');
            $('#reportList').html('');
            //ajax获取数据
            $.ajax({
                type: "get",
                url: "/realHouse/appealAjax/",
                data: {tbl: tbl, houseId:houseId},
                dataType : 'json',
                success: function(data){
                    console.log(data)
                    if (data.status == 1) {
                        var html = '';
                        for (var p in data.data) {
                            if (p == 0) {
                                html += '<tr><td width="115">'+ data.data[p].rowid +'<input type="hidden" name="houseId" value="'+ data.data[p].rowid +'"></td><td width="239">举报时间：'+ data.data[p].report_time +'</td><td id="reason2" fors ="'+ data.data[p].reason +'">举报原因：'+ data.data[p].type +'</td></tr><input type="hidden" name="ids[]" value="'+ data.data[p].id +'">';
                            } else {
                                html += '<tr><td width="115"></td><td width="239">举报时间：'+data.data[p].report_time +'</td><td id="reason2" fors ="'+ data.data[p].reason +'">举报原因：'+ data.data[p].type +'</td></tr><input type="hidden" name="ids[]" fors ="'+ data.data[p].reason +'" value="'+ data.data[p].id +'">';
                            }
                        }
                        if (data.appealed == 1) {
                            $("#checkConsent").css('display', 'none');
                        } else {
                            $("#checkConsent").css('display', 'block');
                        }
                        $('#reportList').html(html);
                        openWin("jsUploadHeadPortrait");
                    } else {
                        alert('网络异常，请刷新页面重试');
                    }
                    $("#reason2").on("hover",function(){
                        var reason2 = $("#reason2").attr("fors");
                        $("li").eq(1).html("举报理由:"+reason2);
                    });
                }
            });
        })

        $("#saveAppeal").on("click",function(){
            $("#appeal_form").submit();
        })
    });

    var wp41 = function() {
        var region = GetDateRegion("currentDay", "jsWdatePicker3");
        if(region <= 7) {
            region = region - 2;
            xdate = $("#currentDay").val();
        } else {
            xdate = '#F{$dp.$D(\'jsWdatePicker3\',{d:31})}';
        }
        WdatePicker({
            maxDate: xdate,
            minDate: '#F{$dp.$D(\'jsWdatePicker3\')}'
        });
    }
    var wp31 = function() {
        function pick(dp) {
            $("#jsWdatePicker4").val(dp.cal.getDateStr());
        }
        WdatePicker({
            minDate: '%y-{%M-1}-{%d}',
            maxDate: '%y-%M-%d',
            onpicked: pick
        });
    }
    /*
     * 计算两个日期的间隔天数
     * BeginDate:起始日期的文本框，格式為：2012-01-01
     * EndDate:結束日期的文本框，格式為：2012-01-02
     * 返回兩個日期所差的天數
     * 調用方法：
     * alert("相差"+Computation("date1","date2")+"天");
     */
    function GetDateRegion(BeginDate, EndDate) {
        var aDate, oDate1, oDate2, iDays;
        var sDate1 = document.getElementById(BeginDate).value; //sDate1和sDate2是2008-12-13格式
        var sDate2 = document.getElementById(EndDate).value;
        aDate = sDate1.split("-");
        oDate1 = new Date(aDate[1] + '/' + aDate[2] + '/' + aDate[0]); //转换为12/13/2008格式
        aDate = sDate2.split("-");
        oDate2 = new Date(aDate[1] + '/' + aDate[2] + '/' + aDate[0]);
        //iDays = parseInt(Math.abs(oDate1 - oDate2) / 1000 / 60 / 60 /24)+1;   //把相差的毫秒数转换为天数
        var i = (oDate1 - oDate2) / 1000 / 60 / 60 / 24;
        if(i < 0) {
            i -= 1;
        } else {
            i += 1;
        }
        iDays = i; //把相差的毫秒数转换为天数
        //alert(iDays);
        return iDays;
    }
    //选择日期类型
    function select_date(type) {
        var strToday = "2018-03-21";
        var strWeekstr = "2018-03-14";
        var strMonthstr = "2018-02-21";
        if(type === 'week') {
            $('#week').addClass('btnCon_pay');
            $('#month').removeClass('btnCon_pay');
            startday = strWeekstr;
        } else {
            $('#month').addClass('btnCon_pay');
            $('#week').removeClass('btnCon_pay');
            startday = strMonthstr;
        }
        $('#select_time_tab').val(type);
        $('#jsWdatePicker3').val(startday);
        $('#jsWdatePicker4').val(strToday);
    }

    function validateAppeal(){
        var reason = $("#reason").val();
        var picNum = $(".deltextFg3Img").length;
        if (reason.length > 200 || reason.length <= 0) {
            alert('申诉理由不能为空，且最大为200字！');
            return false;
        }

        if (picNum == 0) {
            alert('请上传图片！');
            return false;
        }

        var buildingnum = $("#buildingnum").val();
        var unitnum = $("#unitnum").val();
        var roomnum = $("#roomnum").val();
        var owner_phone = $("#owner_phone").val();
        var property_rights_name = $("#property_rights_name").val();
        var phone_test  = /^1[3,4,5,7,8,9]{1}[0-9]{9}$/;
        var property_rights_person_id = $("#property_rights_person_id").val();
        /*if (buildingnum.length <= 0 || unitnum.length <= 0 || roomnum.length <= 0 ) {
            alert('请填写完整的楼栋门牌信息');
            return false;
        }*/
        if(owner_phone){
            if(!phone_test.test(owner_phone)){
                alert('请填写正确的业主电话');
                return false;
            }
        }else{
            alert('请填写业主电话');
            return false;
        }
        if(!property_rights_name){
            alert('请填写产权人姓名');
            return false;
        }
        if(property_rights_person_id){
            if(IdentityCodeValid(property_rights_person_id) == false){
                alert('请填写正确的产权人身份证号');
                return false;
            }
        }
        return true;
    }
    function IdentityCodeValid(code) {
        if (code.length == 18 || code.length == 15) {
            return true;
        }
        return false;
        var city = {
            11: "北京",
            12: "天津",
            13: "河北",
            14: "山西",
            15: "内蒙古",
            21: "辽宁",
            22: "吉林",
            23: "黑龙江 ",
            31: "上海",
            32: "江苏",
            33: "浙江",
            34: "安徽",
            35: "福建",
            36: "江西",
            37: "山东",
            41: "河南",
            42: "湖北 ",
            43: "湖南",
            44: "广东",
            45: "广西",
            46: "海南",
            50: "重庆",
            51: "四川",
            52: "贵州",
            53: "云南",
            54: "西藏 ",
            61: "陕西",
            62: "甘肃",
            63: "青海",
            64: "宁夏",
            65: "新疆",
            71: "台湾",
            81: "香港",
            82: "澳门",
            91: "国外 "
        };
        var tip = "";
        var pass = true;

        if (!code || !/^\d{6}(18|19|20)?\d{2}(0[1-9]|1[12])(0[1-9]|[12]\d|3[01])\d{3}(\d|X)$/i.test(code)) {
            tip = "身份证号格式错误";
            pass = false;
        }

        else if (!city[code.substr(0, 2)]) {
            tip = "地址编码错误";
            pass = false;
        }
        else {
            //18位身份证需要验证最后一位校验位
            if (code.length == 18) {
                code = code.split('');
                //∑(ai×Wi)(mod 11)
                //加权因子
                var factor = [7, 9, 10, 5, 8, 4, 2, 1, 6, 3, 7, 9, 10, 5, 8, 4, 2];
                //校验位
                var parity = [1, 0, 'X', 9, 8, 7, 6, 5, 4, 3, 2];
                var sum = 0;
                var ai = 0;
                var wi = 0;
                for (var i = 0; i < 17; i++) {
                    ai = code[i];
                    wi = factor[i];
                    sum += ai * wi;
                }
                var last = parity[sum % 11];
                if (parity[sum % 11] != code[17]) {
                    tip = "校验位错误";
                    pass = false;
                }
            }
        }
        // if (!pass) alert(tip);
        return pass;
    }
</script>