<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<link href="{$BASE_V}layout.css" rel="stylesheet" type="text/css" />
<title>TBlog博客系统</title>
<script language="javascript">var webpath='{$BASE}'</script>
<script language="javascript">var php_self='{PHP_SELF}'</script>
<script type="text/javascript" src="{$BASE}js/calendar/jquery.min.js"></script>
<script type="text/javascript" src="{$BASE_V}updatehotel.js"></script>
<style>
em{ color:#F00; font-size:14px}
.msgs{ width:600px; height:300px; overflow:auto; margin-left:16px; margin-top:10px}
</style>
</head>
<body>
<div id="main" style="list-style:none;">
    <div class="main_box" style="margin-bottom:20px;">
        <h2>酒店数据更新</h2>
    </div>
	<!--{if $action == 'updateone' }-->    
    <form method="post" action="{PHP_SELF}?m=updatehotel.updatehotelbyid">
        <table align="left" widht="500">
            <tr>
                <td>&nbsp;酒店id:<input type="text" size="35" name="ids" value=""></td>
                <td><input type="submit" value="提交" class="btn02" name="Submit">&nbsp;多个酒店请用"|"隔开。</td>
            </tr>
        </table>
    </form>
	<!--{/if}--> 
	<!--{if $action == 'index' }-->    
    <div style="padding:10px;margin:10px 10px 0px 10px; ">
        <span style="font-size:14px;">当前住哪网酒店分销联盟共有酒店：<b>$remotenum</b> 家，联盟程序共有酒店 <b>$local['hotelnum']</b> 家。</b></span>
		<li><div class="indiv" style="margin:10px 0 10px 0;"><input style='width:100px;' type="button" value="检查更新" class="btn02" id="update" onmouseover="this.className='btn03'" onmouseout="this.className='btn02'" onclick="syncdata()"></div></li>
	</div>
	<li id="msg" style="padding-left:20px;padding-bottom:20px;"><!--{if $remotenum==0}-->请求失败请重试！<!--{/if}--> </li>
    <li id="update_html" style="padding-left:20px;padding-bottom:20px;"></li>    
    <li style="padding-left:20px; height:100%; color:#F00; font-weight:bold; font-family:'微软雅黑'; font-size:12px"> 
	关于数据更新的说明
	<div>由于数据更新需要较长时间，请您耐心等待。</div>
	</li>
    <li id="loading" class="msgs" style="height:13px"></li>
    <li id="syscmsg" class="msgs"></li>
<script type="text/javascript">

function syncdata()
{
    var url = "{PHP_SELF}?m=updatehotel.find";  
    $.ajax({
            url : url,
            type : 'GET',
            dataType: "html",
            beforeSend : function(data){$("#msg").html('<img src="{$BASE_V}/images/loadings.gif"><br>正在检查酒店信息...');},
            success : 
                function(data)
                {
                    var json = eval('['+data+']');      
                    var msg = json[0]['msg'];
                    var del_arr = json[0]['del_arr'];
                    var insert_arr = json[0]['insert_arr'];
                    var update_arr = json[0]['update_arr'];
                    var update_html = json[0]['update_html'];
                    $("#msg").html(msg);
                    if(update_html!=''){
                        $("#update_html").html(update_html);        
                            $("#update3").click(function(){
                            if (confirm('确定要执行这次操作吗？')) {
                                var update2_html = $("#update2").html();
                                $("#update2").html(update2_html+'&nbsp;&nbsp;<input type="button" value="取消更新" id="update_none" onclick="location.href=\'{PHP_SELF}?m=updatehotel\'" class="btn02">');
                                $("#update").attr("disabled",true); 
                                $("#update").attr("class",'btn03'); 
                                $("#update3").attr("disabled",true); 
                                $("#update3").attr("class",'btn03');                                
                                $('#loading').html('<img src="{$BASE_V}/images/loading.gif">');
                                sysc('del',del_arr,update_arr,insert_arr);
                            }
                            }); 
                    }
                }
            ,
            error: 
                function () {
                    alert("请求超时请重试!");
                }
    }); 
}
</script>
<!--{/if}-->  
</div>
</div>
</div>

</body>
</html>
