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

作者: 
      
修改注释：      
NO.1      
姓名: Lilong
时间：2004-4-13
修改说明: support 16 discount ID.
*********************************************************/
require("../../inc/header.inc");
?>
<body leftmargin="15" rightmargin="10" onload="javascript:adjust();" onresize="javascript:adjust();" style="overflow:hidden;overflow-x:hidden;overflow-y:hidden;">

<?
adjust_head();
adjust_title_head();
$DEBUG = 0;

$ppsDb='PPS_DB';
$tableName='pre_bill_discount';
$listPageURL = "tariffDiscount.php?discount_id=$discount_id";
$strThisPage=$strTitleAdvanced.$strTitleSpace."Tariff plan".$strTitleSpace."Discount";

//==========================================================
//数据处理
//==========================================================
//保存修改的变量
if(strlen($set)>0){
	$setSql="UPDATE $tableName
			  SET mon = '$mon',
				  tue = '$tue',
				  wed = '$wed',
				  thu = '$thu',
				  fri = '$fri',
				  sat = '$sat',
				  sun = '$sun',
				  holiday = '$holiday'
			  WHERE hours = '$hours' AND discount_id='$discount_id'";
	if($DEBUG)  echo "<br>$setSql";
	$result= @mysqli_query($pubConn,$setSql);
	echo mysqli_error($pubConn);
	echo " <meta http-equiv=\"refresh\" content=\"0; url=$listPageURL\"> ";
}

//==========================================================
//输出并显示数据
//==========================================================
$getSql = "SELECT * 
	    FROM $tableName
		WHERE hours='$hours' AND discount_id='$discount_id'";
if($DEBUG) echo "getSql=$getSql<br>";
$result=mysqli_query($pubConn,$getSql);
$rows = mysqli_fetch_array($result); 
?>


<?php
echo "<table id=\"table_up\" border=\"0\" width=\"100%\">";
	echo "<tr>";
		echo "<td width=\"50%\">";
		echo "$strThisPage";
		echo "</td>";
		echo "<td width=\"50%\" align=\"right\">&nbsp;";

		echo "</td>";
	echo "</tr>";
echo "</table>";
  
adjust_title_tail();
adjust_content_head();
echo "<br>";
?>

<form name="editform" action="<?php echo"$PHP_SELF?hours=$hours&discount_id=$discount_id"; ?>" method="POST">
<table border="1" width="100%" cellpadding="2" cellspacing="0"  bordercolor="#666666" bordercolordark="#FFFFFF" bgcolor="#FFFFFF"  >
<tbody>
  <tr bgcolor="#E6E6E6">
	 <td align="center" colspan="9">
		<?php echo "Edit Discount ( ID: $discount_id ) "; ?>
	 </td>
  </tr>
  <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>";
//    $discount_id=$rows[discount_id];
	  $hours=$rows[hours];
	  if(strlen($hours) < 2)  $hours='0'.$hours;
	  if(strlen($hours+1) < 2)
		{
		  $next_hours='0'.($hours+1);
		}
	  else
		{
		  $next_hours=$hours+1;
		}
	  $holiday=change2point($rows[holiday]/100);
	  echo "<td align=center>$hours:00:00 - $next_hours:00:00</td>";
	  echo "<td><input type=\"text\" name=\"mon\" size=\"3\" value=\"$rows[mon]\" class=\"text\" style=\"text-align: right;\">&nbsp;/100&nbsp;</td>";
	  echo "<td><input type=\"text\" name=\"tue\" size=\"3\" value=\"$rows[tue]\" class=\"text\" style=\"text-align: right;\">&nbsp;/100&nbsp;</td>";
      echo "<td><input type=\"text\" name=\"wed\" size=\"3\" value=\"$rows[wed]\" class=\"text\" style=\"text-align: right;\">&nbsp;/100&nbsp;</td>";
      echo "<td><input type=\"text\" name=\"thu\" size=\"3\" value=\"$rows[thu]\" class=\"text\" style=\"text-align: right;\">&nbsp;/100&nbsp;</td>";
      echo "<td><input type=\"text\" name=\"fri\" size=\"3\" value=\"$rows[fri]\" class=\"text\" style=\"text-align: right;\">&nbsp;/100&nbsp;</td>";
      echo "<td><input type=\"text\" name=\"sat\" size=\"3\" value=\"$rows[sat]\" class=\"text\" style=\"text-align: right;\">&nbsp;/100&nbsp;</td>";
      echo "<td><input type=\"text\" name=\"sun\" size=\"3\" value=\"$rows[sun]\" class=\"text\" style=\"text-align: right;\">&nbsp;/100&nbsp;</td>";
      echo "<td><input type=\"text\" name=\"holiday\" size=\"3\" value=\"$rows[holiday]\" class=\"text\" style=\"text-align: right;\">&nbsp;/100&nbsp;</td>";
      echo "</tr>";
    }
  while($rows = @mysqli_fetch_array($result));
?>
</tbody>
</table>
<table  width="400">     
    <tr>     
     <td> 
	      <input type="submit" name="set" value="Set" style="width:40" class="button">&nbsp; 
		  <input type="reset" name="reset" value="Reset" class="button">&nbsp;
		  <input type="button" name="return" value="Return" onclick=jacascript:location.href="./tariffDiscount.php?discount_id=<?php echo "$discount_id"; ?>" class="button">&nbsp;
     </td>         
   </tr>           
</table>
</form>
<?php
adjust_content_tail();
?>
</body>
</html>