<?php

/**
 * 未申请小区专家的模板
 */
?>
<?php

/**
 * 正在申请小区专家的模板
 */

?>
<!---->
<div id="centre" class="layout">
	<div class="centreInner ">
		<div class="mainInner radius5 neighborhoodExpert">
			<div class=" belongBox radius3">
				<p class="title">您目前没有小区专家在职<a href="#" class="link">什么是小区专家及优势&gt;&gt;</a></p>
			</div>
			
			<!---->
			
			<div class="branchCommon radius5 "   >
				<div class="hd ">
					<table class="tableExpert">
						<tr>
							<td class="w268">小区名称</td>
							<td class="w156">在职专家数</td>
							<td class="w195">建议申请时间</td>
							<td class="w148">申请状态</td>
							<td>操作</td>
						</tr>
					</table>
				</div>
				<div class="mod">
					<table class="tableExpert">
                                            <?php  foreach ($block as $key => $value) { ?>
                                                <tr id="block_id_<?=$value['blockid']?>">
							<td class="td w268"><a class="name" target="_blank" bid ="<?=$value['blockid']?>" href="http://nj.sell.house365.com/community_id<?=$value['blockid']?>/"><?=$value['blockname']?></a></td>
							<td class="td w156"><?=$value['expert_num']?></td>
                                                        <td class="td w195"><span class="color"><?php if($value['endtime']){ echo date("Y-m-d H:i",$value['endtime']).'后'; } else { echo '立即';}?></span></td>
							<td class="td w148"><span class="color status"><?=$value['status']?></span></td>
							<td class="td">
                                                            <?php if($value['action']) { ?>
                                                            <a class="link <?=$value['action']['key']?>" href="#" ><?=$value['action']['name']?></a>
                                                            <?php } else { ?>
                                                            -
                                                            <?php } ?>
                                                        </td>
						</tr>
                                            <?php }  ?>
					</table>
				</div>
			</div>
			
			<!-- 小区专家申请说明 -->
                        <?php require APPPATH.'/views/'.TEMPLATE_NAME.'/market/infoExpert.php'; ?>
			<!----> 
			
		</div>
	</div>
</div>


<!--申请小区专家 弹出层-->
<div id="jsDialogNeighborhoodExpert" class="dialog dialog2 radius5 dialogNeighborhoodExpert" >
	<div class="hd">
		<h3 class="h3">申请小区专家</h3>
		<span title="关闭" class="close close-win">&Chi;</span> </div>
	<div class="mod">
		<form action="" >
			<div class="forms">
				<dl class="list">
					
					<!---->
					
					<dd class="list_item clearfix">
						<label class="label">申请小区：</label>
						<div class="fields nameInput ">
							<div class="fgInput jsNameInput jsFgInput">
								<div class="fgInput"> <a href="#" target="_blank" id="apply_block_name" class="popLinkName"></a> </div>
							</div>
						</div>
					</dd>
					<!---->
					
					<dd class="list_item clearfix">
						<label class="label">申请宣言：</label>
						<div class="fields">
							<div class="fgInput">
								<textarea class="textarea" id="jsExpert"></textarea>
								<div class="clearfix">
									<div class="fgInput textFgErroy">
										<label class="error" style="display:none" >输入错误</label>
									</div>
									<p class="textFg textFg6 textFgFR">剩余<span class="colorN" id="jsExpertNum">50</span>个字</p>
								</div>
							</div>
						</div>
					</dd>
					<dd class="list_item clearfix">
						<label class="label">&nbsp;</label>
						<div class="fields">
							<div class="fgInput"> <a  href="####" class="btnPopo btnCon radius5 applyBtn">提交</a> <a href="####" class="btnPopo btnCon radius5 close-win">取消</a> </div>
						</div>
					</dd>
				</dl>
			</div>
                    <input id="apply_block_id" type="hidden" name="block_id" value="" />
		</form>
	</div>
</div>
<div id="jsDialogNeighborhoodExpert1" class="dialog dialog1 radius5 dialogNeighborhoodExpert" >
    <div class="hd">
		<h3 class="h3">申请小区专家</h3>
		<span title="关闭" class="close close-win">&Chi;</span> 
    </div>
    <div class="mod">
        <dl class="list">
                <dd class="list_item clearfix">
                        <label class="label"></label>
                </dd>
        </dl>
    </div>
</div>
<script>
countFun("jsReason",50,"jsReasonNum");
countFun("jsExpert",50,"jsExpertNum");
$(function() {
    $(".apply").click(function() {
        var block_name = $(this).parents('tr').find(".name").text()
        var block_id = $(this).parents('tr').find(".name").attr("bid");
        var block_url = $(this).parents('tr').find(".name").attr('href');
        var applyWin = $("#jsDialogNeighborhoodExpert");
        applyWin.find("#apply_block_name").text(block_name);
        applyWin.find("#apply_block_name").attr('href',block_url);
        applyWin.find("#apply_block_id").val(block_id);
        openWin('jsDialogNeighborhoodExpert');
    })
    $(".applyBtn").click(function() {
        var error = $(".error");
        var cNum = parseInt($("#jsExpertNum").text());
        if(cNum===50) {error.html("输入错误！").show();return; }
        if(cNum>40&&cNum<50) {error.html("请填写10个字以上的申请宣言！").show();return;}
        error.hide();
        var url = './apply/'
        var blockid = $("#apply_block_id").val();
        var reason = $("#jsExpert").val();
        var record = $("#block_id_"+blockid);
        $.post(url,{blockid:blockid,reason:reason},function(d) {
            //console.log(d);
            if(d.status==='1') {
                closeWin("jsDialogNeighborhoodExpert");
                var applyMsgWin = $("#jsDialogNeighborhoodExpert1");
                applyMsgWin.find("label").text(d.msg)
                openWin("jsDialogNeighborhoodExpert1");
                window.location.reload();
                //record.find(".apply").text("取消").removeClass("apply").addClass("cancel");
                //record.find(".status").text("待审核")
            } else {
                error.html(d.msg).show();
            }
        },'json');
        
    })
    $(".cancel").click(function() {
        var x = confirm("是否取消？");
        if(x === true) {
            var url = './cancel/'
            var block_id = $(this).parents('tr').find(".name").attr("bid");
            $.post(url,{blockid:block_id},function(d) {
                if(d.status==='1') {
                    window.location.reload();;
                } else {
                    var applyMsgWin = $("#jsDialogNeighborhoodExpert1");
                    applyMsgWin.find("label").text(d.msg)
                    openWin("jsDialogNeighborhoodExpert1");
                }
            },'json')
        }
    })
})
function closeWin(winId){
    var winElemt = $("#"+winId);
    winElemt.hide();
    $('#gTipsCover'+winId).remove();		
}
</script>