<form id="form1" action="statics_time.manage.php" method="post" onsubmit="return ajax_list('pv');"  style="margin-bottom:0px"  >
<table width="680" border="0" cellspacing="0" cellpadding="0"  class="from_table">
  <tr>
    <th colspan="2" style="text-align:left">　　<a href="javascript:;" onclick="ajax_link();"><tpl> $langSysSOneDayFluxContrast </tpl></a> | <tpl> $langSysSManyDayFluxContrast </tpl></th>
    <td>&nbsp;</td>
    <td width="80">&nbsp;</td>
  </tr>
  <tr>
    <th width="192"><tpl> $langSysSPleaseSelectTime </tpl>：</th>
    <td width="350"><input type="text" name="time[0]" id="time_one" size="15" readonly="readonly" value="<tpl> $time_0 </tpl>" style="border:solid 1px #B0DF82;cursor:pointer; width:100px; background:url(../js/calendar/blue/cal_btn.gif) no-repeat right; height:18px; padding-right:19px; padding-bottom:0px "/></td>
    <th width="350">　
      <tpl> $langSysSPleaseSelectType </tpl>：</th>
    <td width="80"><input name="type" <tpl> if $type eq 'pv' </tpl> checked="checked" <tpl> /if </tpl> type="radio" value="pv" onclick="return ajax_list('pv');" />PV		
<input name="type" <tpl> if $type eq 'ip' </tpl> checked="checked" <tpl> /if </tpl> type="radio" value="ip" onclick="return ajax_list('ip');" />IP</td>
  </tr>
  <tr>
    <th rowspan="2"><tpl> $langSysSContrast </tpl>：</th>
    <td colspan="2"><input type="checkbox" name="time[1]" value="1" <tpl> if $time_1 neq '' </tpl> checked="checked" <tpl> /if </tpl> /><tpl> $langSysSFormerOneDay </tpl>
		<input type="checkbox" name="time[2]" value="2" <tpl> if $time_2 neq '' </tpl> checked="checked" <tpl> /if </tpl> /><tpl> $langSysSFormerOneWeekSamenessTime </tpl>
		<input type="text" name="time[3]" id="time_two" size="15" readonly="readonly" value="<tpl> $time_3 </tpl>" style="border:solid 1px #B0DF82;cursor:pointer; width:100px; background:url(../js/calendar/blue/cal_btn.gif) no-repeat right; height:18px; padding-right:19px; "/> <tpl> $langSysSTimeSpaceNotExceed </tpl></td>
    <td width="80" rowspan="2">	<span class="btn_left">
      <input type="submit" class="btn_submit" value="<tpl> $langSysSSubmit </tpl>" /></span>
      <label style="display:none;" for="f_date" class="error" metaDone="true" generated="true"></label>	  </td>
  </tr>
 
</table>	
</form>

<table width="680" border="0" cellspacing="0" cellpadding="0"  class="from_table">
    <tr style="height:6px;background-color: #E6F5FF;">
        <td colspan="3" style="height:6px;background-color: #E6F5FF;"></td>
      </tr>
  <tr>
    <th><tpl> $langSysSPeriodOfTimeContrast </tpl>
      ：</th>
    <td width="530"><tpl> $time_0 </tpl><tpl> if $time_1 neq '' </tpl> VS <tpl> $langSysSFormerOneDay </tpl> <tpl> /if </tpl>
	<tpl> if $time_2 neq '' </tpl> VS <tpl> $langSysSFormerOneWeekSamenessTime </tpl> <tpl> /if </tpl>
	<tpl> if $time_3 neq '' </tpl> VS <tpl> $time_3 </tpl> <tpl> /if </tpl></td>
  </tr>
</table>

	
	

<table class="from_table2">
<thead>
   <tpl> if $type eq 'pv' </tpl>
   <tr>
     <th width="200"><tpl> $langSysSTimeSegment </tpl></th>
      <th width="200">PV[
     <tpl> $time_0 </tpl>]</th>
		<tpl> if $time_1 neq '' </tpl>
      <th width="200">PV[
     <tpl> $langSysSFormerOneDay </tpl>]</th>
	  	<tpl> /if </tpl>
	  	<tpl> if $time_2 neq '' </tpl>
      <th width="200">PV[
     <tpl> $langSysSFormerOneWeekSamenessTime </tpl>]</th>
	  	<tpl> /if </tpl>
	  	<tpl> if $time_3 neq '' </tpl>
      <th width="200">PV[
     <tpl> $time_3 </tpl>]</th>
	  	<tpl> /if </tpl>
   </tr>
   <td width="200"></thead>
   <tr>
     <td width="200"><tpl> $langSysSTotalize </tpl></td>
      <td width="200"><tpl> $sum_one.pv_sum|default:'0' </tpl></td>
		<tpl> if $time_1 neq '' </tpl>
     <td width="200"><tpl> $sum_two.pv_sum|default:'0' </tpl></td>
	  	<tpl> /if </tpl>
	  	<tpl> if $time_2 neq '' </tpl>
     <td width="200"><tpl> $sum_thre.pv_sum|default:'0' </tpl></td>
	  	<tpl> /if </tpl>
	  	<tpl> if $time_3 neq '' </tpl>
     <td width="200"><tpl> $sum_four.pv_sum|default:'0' </tpl></td>
	  	<tpl> /if </tpl>
   </tr>
    <tpl> /if </tpl>
   <tpl> if $type eq 'ip' </tpl>
   <tr>
     <td width="200"><tpl> $langSysSTimeSegment </tpl></td>
      <td width="200">IP[
     <tpl> $time_0 </tpl>]</td>
	  	<tpl> if $time_1 neq '' </tpl>
      <td width="200">IP[
     <tpl> $langSysSFormerOneDay </tpl>]</td>
	  	<tpl> /if </tpl>
      	<tpl> if $time_2 neq '' </tpl>
      <td width="200">IP[
     <tpl> $langSysSFormerOneWeekSamenessTime </tpl>]</td>
	  	<tpl> /if </tpl>
	  	<tpl> if $time_3 neq '' </tpl>
      <td width="200">IP[
     <tpl> $time_3 </tpl>]</td>
	  	<tpl> /if </tpl>
   </tr>
   <tr>
     <td width="200"><tpl> $langSysSTotalize </tpl></td>
      <td width="200"><tpl> $sum_one.ip_sum|default:'0' </tpl></td>
		<tpl> if $time_1 neq '' </tpl>
     <td width="200"><tpl> $sum_two.ip_sum|default:'0' </tpl></td>
	  	<tpl> /if </tpl>
	  	<tpl> if $time_2 neq '' </tpl>
     <td width="200"><tpl> $sum_thre.ip_sum|default:'0' </tpl></td>
	  	<tpl> /if </tpl>
	  	<tpl> if $time_3 neq '' </tpl>
     <td width="200"><tpl> $sum_four.ip_sum|default:'0' </tpl></td>
	  	<tpl> /if </tpl>
   </tr>
   <tpl> /if </tpl>

	<tpl> section name=i loop=$array_one </tpl>
		<tr>
		  <td width="200"><tpl> $smarty.section.i.rownum-1 </tpl>:00 - <tpl> $smarty.section.i.rownum </tpl>:00</td>
			<td width="200"><tpl> $array_one[i].$type|default:'0' </tpl></td>
			<tpl> if $time_1 neq '' </tpl>
		  <td width="200"><tpl> $array_two[i].$type|default:'0' </tpl></td>
			<tpl> /if </tpl>
			<tpl> if $time_2 neq '' </tpl>
		  <td width="200"><tpl> $array_three[i].$type|default:'0' </tpl></td>
			<tpl> /if </tpl>
			<tpl> if $time_3 neq '' </tpl>
		  <td width="200"><tpl> $array_four[i].$type|default:'0' </tpl></td>
			<tpl> /if </tpl>
		</tr>
	<tpl> /section </tpl>
</table>
<script type="text/javascript" language="javascript"> 
//普通日历
$(function(){
	 //datepicker
	$("#time_one").datepicker();
	$("#time_two").datepicker();
})


function ajax_list(str){
	if($("#time_two").val() != ""){
		num = check_date($("#time_one").val(),$("#time_two").val());
		num = Math.abs(num)	;
		if(num>60){
			alert("<tpl> $langSysSTwoTimeExceed </tpl>");
			return false;
		}
	}
	/* 取表单参数 */var queryString=$("#form1").formSerialize();
	
	$.ajax({
		url: "statics_time.manage.php?action=contrast",
		data: queryString,
		type:'post',
		dataType:"html",
		beforeSubmit:  showLoading(showText),   // 提交之前执行的方法
		success: function(msg){
			$("#result_content").html(msg);
			hideLoading();
		}
	});
	return false;
}

/* 切换页面 */function ajax_link(){
	$.ajax({
		url: "statics_time.manage.php",
		data: 'action=list',
		type:'get',
		dataType:"html",
		beforeSubmit:  showLoading(showText),   // 提交之前执行的方法
		success: function(msg){
			$("#result_content").html(msg);
			hideLoading();
		}
	});
	return false;
}

/* 判断两时间相差天数，time格式为xxxx-(x)x-(x)x
time1开始时间time2结束时间
 */function check_date(time1,time2){
	line1 = time1.split('-');
	line2 = time2.split('-');
	line1[1] = line1[1]-1;
	line2[1] = line2[1]-1;
	var date1 = new Date();
	date1.setFullYear(line1[0],line1[1],line1[2]);
	var date2 = new Date();
	date2.setFullYear(line2[0],line2[1],line2[2]);
	
	line = Date.parse(date2)/1000 - Date.parse(date1)/1000;
	daynum = line/24/60/60;
	return daynum;
}
</script>
