<?php 
  /*********************************************************      
 程序说明：         
    功能说明：列表显示折扣表信息
              
    调用关系：调用: header.inc    
              被调用:        
 
    变量说明：

作者:
      
修改注释：      
NO.1      
姓名: Lilong
时间：2004-4-13
修改说明: support 16 discount ID.
*********************************************************/
require("../../inc/header.inc");
?>
<base>
<body leftmargin="15" rightmargin="10" onload="javascript:adjust();" onresize="javascript:adjust();" style="overflow:hidden;overflow-x:hidden;overflow-y:hidden;">
<form method="POST" action="$PHP_SELF" name="selectform">
<?php
adjust_head();
adjust_title_head();
$helpId = "2.2.3.3"; 
$DEBUG = 0;

$ppsDb='PPS_DB';
$tbName='pre_bill_discount';
$strThisPage=$strTitleAdvanced.$strTitleSpace.$strTariffPlan.$strTitleSpace.$strDiscount;
$order="hours";  //排序

if($DEBUG) echo "discount_id=$discount_id<br>";
if( FALSE == isset($discount_id) ){
	$discount_id = 00;
}
/*
//insert discount to table while the time segment is NULL
$countSql = "SELECT count(*) as total FROM $tbName WHERE discount_id=$discount_id";
if($DEBUG) echo "countSql=$countSql<br>";
$countRes	= mysqli_query($pubConn,$countSql);
$countRows = mysqli_fetch_array($countRes);
echo "countRows[total]=$countRows[total]<br>";
if($countRows[total]<24){
}
exit();
*/
//select current discount id details from TABLE "pre_bill_discount"
$selSql = "SELECT * FROM $tbName WHERE discount_id=$discount_id ORDER BY $order";
if($DEBUG) echo "selSql=$selSql<br>";
$selRes	= mysqli_query($pubConn,$selSql);
$selRows = mysqli_fetch_array($selRes);

?>

<?php
	echo "<table id=\"table_up\" border=\"0\" width=\"100%\">";
	echo "<tr>";
	echo "<td width=\"50%\" align=\"left\">";
	echo "$strThisPage";
	echo "</td>";
	echo "<td width=\"50%\" align=\"right\" title=\"Help\">";
	showHelp($helpId);
	echo "</td>";
	echo "</tr>";
	echo "<tr>";
	echo "<td align=\"left\">";
	echo "&nbsp;";
	echo "</td>";
	echo "<td align=\"right\">";
	
	 echo "Discount ID:&nbsp;"; 
   echo "<select size=\"1\" name=\"discount_id\" onChange=\"javascript:selectTitle()\">";       
   for($i=0;$i<32;$i++){   
         $m=($i<10?"0":"").$i;       
         if($m != $discount_id){     
			 echo "<option value=\"$m\">$m</option>";       
		 }else{
			 echo "<option value=\"$m\" selected>$m</option>";
         }       
   }       
   echo "</select>";
   
	echo "</td>";
	echo "</tr>";
	echo "</table>";
adjust_title_tail();
adjust_content_head();
echo "<br>";
?>

<script LANGUAGE="JavaScript">  
function selectTitle(){      
	var base_url,url_add,url; 
	base_url='<?php echo "$PHP_SELF?discount_id=";?>';
	url_add=document.selectform.discount_id.value;      
	url=base_url+url_add;
	window.location=url;
}     
</script>



</form>   

<table border="1" width="100%" cellpadding="2" cellspacing="0"  bordercolor="#666666" bordercolordark="#FFFFFF" bgcolor="#FFFFFF"  >
  <tr bgcolor="#E6E6E6">
     <td align="center"><?php echo "$strTariffDiscountTimeSection"; ?></td>
     <td align="center"><?php echo $strMonday; ?></td>
     <td align="center"><?php echo $strTuesday; ?></td>
     <td align="center"><?php echo $strWednesday; ?></td>
     <td align="center"><?php echo $strThursday; ?></td>
     <td align="center"><?php echo $strFriday; ?></td>
     <td align="center"><?php echo $strSaturday; ?></td>
     <td align="center"><?php echo $strSunday; ?></td>
     <td align="center"><?php echo $strSpecialDay; ?></td>
  </tr>

<?php
  do{
      echo "<tr>";
	  $hours=$selRows[hours];
	  if(strlen($hours) < 2)  $hours='0'.$hours;
	  if(strlen($hours+1) < 2){
		  $next_hours='0'.($hours+1);
	  }else{
		  $next_hours=$hours+1;
	  }
	  $mon=change2point($selRows[mon]/100);
	  $tue=change2point($selRows[tue]/100);
	  $wed=change2point($selRows[wed]/100);
	  $thu=change2point($selRows[thu]/100);
      $fri=change2point($selRows[fri]/100);
	  $sat=change2point($selRows[sat]/100);
	  $sun=change2point($selRows[sun]/100);
	  $holiday=change2point($selRows[holiday]/100);
	  echo "<td align=center><a href=\"./tariffDiscountEdit.php?hours=$hours&discount_id=$discount_id\">$hours:00:00 - $next_hours:00:00</a></td>";
	  echo "<td align=center>$mon</td>";
	  echo "<td align=center>$tue</td>";
      echo "<td align=center>$wed</td>";
      echo "<td align=center>$thu</td>";
      echo "<td align=center>$fri</td>";
      echo "<td align=center>$sat</td>";
      echo "<td align=center>$sun</td>";
      echo "<td align=center>$holiday</td>";
      echo "</tr>";
    }while($selRows = @mysqli_fetch_array($selRes));
?>
</table>
<?php
adjust_content_tail();
?>
</body>
</html>
