<?php
/*********************************************************      
 程序说明：         
    功能说明：列表显示补充服务信息
    调用关系：调用: header.inc   
              被调用:        
    变量说明
作者: 
      
修改注释：      
NO.1      
姓名：崔体存         
时间: 2004-04-14    
修改说明： OMC V7.0           
*********************************************************/
$DEBUG = 0;
require("../../inc/header.inc");
$helpId = "2.2.3.3.2"; 
$db='PPS_DB';
$moneyPara = getMoneyPara();			   //显示的货币单位是最小货币单位的倍数
$table_name='rent';
$strThisPage=$strTitleConfiguration.$strTitleSpace."PPS".$strTitleSpace.$strCurrentTariff.$strTitleSpace.$strSupplementary;

//编辑后保持对应tariff_id的页面
	$tariff_id=isset($tariff_id)?$tariff_id:'00';
 
$sql="SELECT  id,description,rent_type,charge_date,rent_amount
    	FROM $table_name
	    WHERE tariff_id=$tariff_id
 	    ORDER by id";
//echo $sql,$bill_db;
$result=@mysqli_query($pubConn,$sql);
$rows=@mysqli_fetch_array($result);
 echo mysqli_error($pubConn);
?>

<base>
<body>
<?php
	echo "<table border=\"0\" width=\"100%\">";
	echo "<tr>";
	echo "<td width=\"50%\">";
	echo "$strThisPage";
	echo "</td>";
	echo "<td width=\"50%\" align=\"right\" title=\"Help\">";
	showHelp($helpId);
	echo "</td>";
	echo "</tr>";
	echo "</table>";
?>

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

<form method="POST" name="selectform" action="<?php echo "$PHP_SELF";?>">
<table border="0" width="100%" cellpadding="1" cellspacing="2" bordercolor="#666666" bordercolordark="#FFFFFF">
  <tr>
   <td>
   <?php
   echo "<b>Rent</b>";
   ?>
   </td>
   <td align="right">
   <?php 
   echo "$strResideZone:&nbsp;"; 
   echo "<select size=\"1\" name=\"tariff_id\" onChange=\"javascript:selectTitle()\">";       
   for($i=0;$i<16;$i++){
	   $m=($i<10?"0":"").$i;       
       if($m != $tariff_id){
		   echo "<option value=\"$m\">$m</option>";       
       }else{
           echo "<option value=\"$m\" selected>$m</option>";
	   }       
   }       
   echo "</select>";
   ?>
  </td>
  </tr>
</table> 
</form>


<table border="1" width="100%" cellpadding="2" cellspacing="0"  bordercolor="#666666" bordercolordark="#FFFFFF" bgcolor="#FFFFFF"  >
  <tr bgcolor="#E6E6E6">
   <?php
	echo "<td align=\"center\">$strTariffRentID</td>";
    echo "<td align=\"center\">$strDescription</td>";
	echo "<td align=\"center\">$strTariffRentChargeType</td>"; 
    echo "<td align=\"center\">$strTariffRentChargeDate</td>";  
    echo "<td align=\"center\">$strTariffRentChargeAmount</td>";
   ?>
  </tr>
    <?php
    $i=0;
	if($rows && $result){
		do{
			$i++;
			if ($rows[description] == ''){
				echo "<tr>";
				echo "<td align=\"center\"><a>$i</a></td>";
				echo "<td align=\"center\">--</td>";
				echo "<td align=\"center\">--</td>";
				echo "<td align=\"center\">--</td>";
				echo "<td align=\"right\">--</td>";
				echo "</tr>";
			}
			else{
				echo "<tr>";
				echo "<td align=\"center\"><a>$i</a></td>";
				echo "<td align=\"center\">$rows[description]</td>";
				echo "<td align=\"center\">";
				if($rows[rent_type]=='00'){
					echo "$strTariffRentAccordingToDate";
				}else{
					echo "$strTariffRentAccordingToPeriod";
				}
				echo "</td>"; 
				echo "<td align=\"center\">";
				if($rows[rent_type]=='01'){
					echo "$rows[charge_date]";
				}else{
					echo "--";
				}
				echo "</td>"; 
				$rows[rent_amount] = $rows[rent_amount]/$moneyPara;
				if($moneyPara < 10){
					printf("<td align=\"right\">%5.0f</td>", $rows[rent_amount]);
				}
				elseif($moneyPara < 100){
					printf("<td align=\"right\">%5.1f</td>", $rows[rent_amount]);
				}
				else{
					printf("<td align=\"right\">%5.2f</td>", $rows[rent_amount]);
				} 
			}
		}while($rows=mysqli_fetch_array($result));
	}
    ?>
  </table> 

<!--- Service tariff -->
<?php
$moneyPara = getMoneyPara();			   //显示的货币单位是最小货币单位的倍数
$tableName='comm_tariff';


//编辑后保持对应tariff_id的页面
 $tariff_id2=isset($tariff_id2)?$tariff_id2:'00';

$where=" WHERE tariff_id=$tariff_id2 ";
$sql="SELECT * FROM $tableName".$where;
//echo $sql,$bill_db;
$result=@mysqli_query($pubConn,$sql);
$rows=@mysqli_fetch_array($result);
echo mysqli_error($pubConn);
?>

<script LANGUAGE="JavaScript">  
function selectTitle2(){      
	var base_url2,url_add2,url2; 
	base_url2='<?php echo "$PHP_SELF?tariff_id2=";?>';
	url_add2=document.selectform2.tariff_id2.options[document.selectform2.tariff_id2.selectedIndex].value;      
	url2=base_url2+url_add2;
	window.location=url2;
}     
</script>

<form method="POST" name="selectform2" action="<?php echo "$PHP_SELF";?>">
<table border="0" width="100%" cellpadding="1" cellspacing="2" bordercolor="#666666" bordercolordark="#FFFFFF">
  <tr>
   <td>
   <?php
    echo "<b>Service tariff</b>";
   ?>
   </td>
   <td align="right">
  <?php 
   echo "$strResideZone:&nbsp;"; 
   echo "<select size=\"1\" name=\"tariff_id2\" onChange=\"javascript:selectTitle2()\">";       
   for($i=0;$i<16;$i++){ 
	   $m=($i<10?"0":"").$i;       
       if($m != $tariff_id2){
		   echo "<option value=\"$m\">$m</option>";       
       }else{
		   echo "<option value=\"$m\" selected>$m</option>";
       }       
   }       
   echo "</select>";
   ?>
  </td>
  </tr>
</table> 
</form>
	


<table border="1" width="100%" cellpadding="2" cellspacing="0"  bordercolor="#666666" bordercolordark="#FFFFFF" bgcolor="#FFFFFF"  >
<?php
	echo "<tr bgcolor=\"#E6E6E6\">";
	echo "<td width=\"40%\">$strDescription</td>";
	echo "<td align =\"right\" width=\"30%\">$strTariffRentChargeAmount</td>";
	echo "<td align =\"right\" width=\"30%\">$strUnitChargingTimeSecond</td>";
	echo "</tr>";
    
	$arr_editfieldAmount = array("cf_charge_amount","roaming_charge_amount","cc_charge_amount","cug_charge_amount","fav_charge_amount","fav_change_charge");
	$arr_editfieldUnit = array("cf_charge_unit","roaming_charge_unit","cc_charge_unit","cug_charge_unit","fav_charge_unit","");
	$arr_description = array($strCallForwrd,$strRoaming,$strConferenceCall,$strCloseUserGroup,$strFav_call,$strFav_listedtion);
	$arr_amount = array($rows[cf_charge_amount],$rows[roaming_charge_amount],$rows[cc_charge_amount],$rows[cug_charge_amount],$rows[fav_charge_amount],$rows[fav_change_charge]);
	$arr_unit = array($rows[cf_charge_unit],$rows[roaming_charge_unit],$rows[cc_charge_unit],$rows[cug_charge_unit],$rows[fav_charge_unit],"----");
	for ($i=0;$i<6;$i++){
		echo "<tr>";
		echo "<td><a>$arr_description[$i]</a></td>";
		if($moneyPara < 10){
			printf("<td align=\"right\">%5.0f</td>", $arr_amount[$i]/$moneyPara);
		}
		elseif($moneyPara < 100){
			printf("<td align=\"right\">%5.1f</td>", $arr_amount[$i]/$moneyPara);
		}
		else{
			printf("<td align=\"right\">%5.2f</td>", $arr_amount[$i]/$moneyPara);
		}
		echo "<td align =\"right\">&nbsp;$arr_unit[$i]</td>";
		echo "</tr>";
		echo $tariffID;
	}
?>
</table> 
 
</body>  


<!-- Discount -->
<?php 
$tableName='bill_discount';
$order="hours";  //排序

if($DEBUG) echo "discount_id=$discount_id<br>";
if( FALSE == isset($discount_id) ){
	$discount_id = 00;
}
//select current discount id details from TABLE "pre_bill_discount"
$selSql = "SELECT * FROM $tableName WHERE discount_id=$discount_id ORDER BY $order";
if($DEBUG) echo "selSql=$selSql<br>";
$selRes	= mysqli_query($pubConn,$selSql);
$selRows = mysqli_fetch_array($selRes);
?>

<base>
<body>
<script LANGUAGE="JavaScript">  
function selectTitle1(){      
	var base_url1,url_add1,url1; 
	base_url1='<?php echo "$PHP_SELF?discount_id=";?>';
	url_add1=document.selectform1.discount_id.value;      
	url1=base_url1+url_add1;
	window.location=url1;
}     
</script>

<form method="POST" action="$PHP_SELF" name="selectform1">
<table border="0" width="100%"  cellpadding="1" cellspacing="2"  bordercolor="#666666" bordercolordark="#FFFFFF">
 <tr>
 <td>
 <?php
  echo "<b>Discount</b>";
 ?>
 </td>
 <td align="right">
  <?php 
   echo "Discount ID:&nbsp;"; 
   echo "<select size=\"1\" name=\"discount_id\" onChange=\"javascript:selectTitle1()\">";       
   for($i=0;$i<16;$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>";
   ?>
  </td>
  </tr>
</table> 
</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>$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>
</body>

<!--  Holiday -->
<?php
$tableName='bill_holiday';
$sql="SELECT * 
	  FROM $tableName
	  ORDER BY 'month','day'";
$result=mysqli_query($pubConn,$sql);
$rows=mysqli_fetch_array($result);
?>

<body>
<?php
    echo "<table border=\"0\" width=\"100%\">";
    echo "<tr>";
    echo "<td>";
	echo "<br>";
    echo "<b>Holiday</b>";
    echo "<br>";
	echo "</td>";
    echo "</tr>";
    echo "</table>";
?>

<table border="1" width="100%" cellpadding="2" cellspacing="0"  bordercolor="#666666" bordercolordark="#FFFFFF" bgcolor="#FFFFFF"  >
  <tr bgcolor="#E6E6E6">
    <td align="center" width="40%"><?php echo $strDate; ?>(mm-dd)</td>   
    <td align="center" width="60%"><?php echo $strDescription; ?></td>  
    </tr>
    <?php
	$i=0;
	if($rows){
		do{
			echo "<tr>";
			$id=$rows[id];
			$month=omc_keep_length($rows[month],0,2);
			$day=omc_keep_length($rows[day],0,2);
			$showDate=$month."-".$day;
			$rows[name]=$rows[name]?$rows[name]:'--';
			echo "<td align=\"center\"><a>$showDate</a></td>";  
   			echo "<td align=\"center\">$rows[name]</td>"; 
			echo "</tr>"; 
			$i++;     
		}while($rows=mysqli_fetch_array($result));
    }
	?>
  </table> 
</body>   
