<?
session_start();
require_once "../init.php";
require_once "../authority.inc.php";

$hot="payment";


$sql = "SELECT * FROM payment_type WHERE pay_code = '$_REQUEST[pay_code]'";
$pay = $db->getRow($sql);

/* 取相应插件信息 */
$set_modules = true;
include_once(COMMON_DIR . 'payment/' . $_REQUEST['pay_code'] . '.php');
$data = $modules[0];

/* 取得配置信息 */
if (is_string($pay['pay_config']))
{
	if($pay['pay_config'])
		$store = unserialize($pay['pay_config']); 
	else
		$store = $data['config'];
	/* 取出已经设置属性的code */
	$code_list = array();
	foreach ($store as $key=>$value)
	{
		$code_list[$value['name']] = $value['value'];
	}
	$pay['pay_config'] = array();

	/* 循环插件中所有属性 */
	foreach ($data['config'] as $key => $value)
	{
		$pay['pay_config'][$key]['desc'] = (isset($_LANG[$value['name'] . '_desc'])) ? $_LANG[$value['name'] . '_desc'] : '';
		$pay['pay_config'][$key]['label'] = $_LANG[$value['name']];
		$pay['pay_config'][$key]['name'] = $value['name'];
		$pay['pay_config'][$key]['type'] = $value['type'];

		if (isset($code_list[$value['name']]))
		{
			$pay['pay_config'][$key]['value'] = $code_list[$value['name']];
		}
		else
		{
			$pay['pay_config'][$key]['value'] = $value['value'];
		}

		if ($pay['pay_config'][$key]['type'] == 'select' ||
			$pay['pay_config'][$key]['type'] == 'radiobox')
		{
			$pay['pay_config'][$key]['range'] = $_LANG[$pay['pay_config'][$key]['name'] . '_range'];
		}
	}

}

?>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<title>网上支付设置</title>
<LINK href="../share/style.css" rel="stylesheet">
<link rel="stylesheet" type="text/css" href="/admin/static/h-ui/css/H-ui.min.css" />
<link rel="stylesheet" type="text/css" href="/admin/static/h-ui.admin/css/H-ui.admin.css" />
<link rel="stylesheet" type="text/css" href="/admin/lib/Hui-iconfont/1.0.7/iconfont.css" />
<link rel="stylesheet" type="text/css" href="/admin/lib/icheck/icheck.css" />
<link rel="stylesheet" type="text/css" href="/admin/static/h-ui.admin/skin/default/skin.css" id="skin" />
<link rel="stylesheet" type="text/css" href="/admin/static/h-ui.admin/css/style.css" />



<script src="../share/global.js"></script>
</head>
<body>
<? include "../share/top.php"?>
<div id="topLink">
<div id="topInfo">
	<span class="tTitle">系统管理</span>
	<span class="sarr"> >> </span>网上支付方式设置
	<span class="sarr"> >> </span><a href="<?=$GLOBALS["parentpath"]?>">返回到管理首页</a>
</div>
</div>
<!--子导航--><div class="page-container">
<? include "nav.inc.php"?>
<form action="payment_modi.php" method="post">
<div class="main-div">
<table cellspacing="1" cellpadding="3" width="100%" id="table" class="table table-border table-bordered table-bg table-hover table-sort">
  <tr id="tr">
    <td colspan="2">网上支付方式设置:</td>
  </tr>
  <tr>
    <td align="right">支付方式名称:</td>
    <td><input name="pay_name" type="text" class="inputline" value="<?=$pay[pay_name]?>" size="40" /></td>
  </tr>
  <tr>
    <td align="right">支付方式描述:</td>
    <td><textarea name="pay_desc" cols="60" rows="8"><?=$pay[pay_desc]?></textarea></td>
  </tr>
  <? foreach($pay[pay_config] as $config){?>
  <tr>
    <td align="right">
      <span class="label"><?=$config[label]?>
    </td>
    <td>
	  <? if($config[type]=="text"){?>
      <input name="cfg_value[]" type="<?=$config[type]?>" class="inputline" value="<?=$config[value]?>" size="40" />
	  <? }elseif($config[type]=="textarea"){?>
      <textarea name="cfg_value[]" cols="80" rows="5"><?=$config[value]?></textarea>
      <? }elseif($config[type]=="select"){?>
      <select name="cfg_value[]">
			<? foreach($config[range] as $key=>$val){?>
			<option value="<?=$key?>"><?=$val?></option>
			<? }?>
	  </select>
      <? }?>
      <input name="cfg_name[]" type="hidden" value="<?=$config[name]?>" />
      <input name="cfg_type[]" type="hidden" value="<?=$config[type]?>" />
      <input name="cfg_lang[]" type="hidden" value="<?=$config[lang]?>" />
    </td>
  </tr>
  <? }?>
  <tr>
    <td align="right">排序:</td>
    <td><input name="pay_order" type="text" class="inputline" value="<?=$pay[pay_order]?>" />
    </td>
  </tr>
  <tr>
    <td align="right">默认选中:</td>
    <td>
	<select name="pay_selected">
			<option value="0">否</option>
			<option value="1"<?=$pay[pay_selected]?" selected":""?>>是</option>
	  </select>
    </td>
  </tr>
  <tr>
    <td align="right">是否启用:</td>
    <td>
	<select name="status">
			<option value="0">否</option>
			<option value="1"<?=$pay[status]?" selected":""?>>是</option>
	  </select>
    </td>
  </tr>
  <tr align="center">
    <td colspan="2">
      <input type="hidden"  name="pay_id"       value="<?=$pay[pay_id]?>" />
      <input type="hidden"  name="pay_code"     value="<?=$pay[pay_code]?>" />
      <input type="submit" class="button" name="Submit"       value="确定" />
      <input type="reset" class="button"  name="Reset"        value="重置" />
    </td>
  </tr>
</table>
</div>

</form>

</div>
<? 
$DB->close();
include "../share/bottom.php";
?>
</body>
</html>
