<?php 
defined('IN_TS') or die('Access Denied.');


switch($ts){
	case "":
	    $adcontent=$db->fetch_all_assoc("select * from ".dbprefix."pay_options");
		$adops=array();
	    if($adcontent){
		   foreach($adcontent as $ackey=>$acitem){
			  $adops[$acitem[code]]= $acitem;
		    }
          }
		include template("pay_options");
	break;
	
	case "Alipay":
	 $adcontent=$db->fetch_all_assoc("select * from ".dbprefix."pay_options");
		$adops=array();
	    if($adcontent){
		   foreach($adcontent as $ackey=>$acitem){
			   if($acitem['code']=='Alipay'){
				  $adops= $acitem;  
			   }
		    }
          }
		 
	   include template("Alipay");
	break;
	
	case "bill":
	 $adcontent=$db->fetch_all_assoc("select * from ".dbprefix."pay_options");
		$adops=array();
	    if($adcontent){
		   foreach($adcontent as $ackey=>$acitem){
			   if($acitem['code']=='bill'){
				  $adops= $acitem;  
			   }
		    }
          }
	   include template("admin/bill");
	break;
	
	case "bank":
	 $adcontent=$db->fetch_all_assoc("select * from ".dbprefix."pay_options");
		$adops=array();
	    if($adcontent){
		   foreach($adcontent as $ackey=>$acitem){
			   if($acitem['code']=='bank'){
				  $adops= $acitem;  
			   }
		    }
          }
	   include template("admin/bank");
	break;
	
	case "deloptions":
	 $code = $_REQUEST['code'];
	$ad=$db->query("delete  from ".dbprefix."pay_options where code='".$code."'");
	 qiMsg("广告位删除成功","点击返回>>","index.php?app=system&ac=pay_options");
	
	break;
	
	case "Alipaysave":
	
		$name = $_REQUEST['name'];
		$account = $_REQUEST['alipay_account'];
		$key = $_REQUEST['alipay_key'];
		$parterid = $_REQUEST['alipay_parterid'];
		$service_type = $_REQUEST['service_type']?$_REQUEST['service_type']:0;
		$description = $_REQUEST['description'];
		$pay_method = $_REQUEST['pay_method'];
		$pay_rate = $_REQUEST['pay_rate'];
		$pay_fix = $_REQUEST['pay_fix'];
		$code = "Alipay";
		$adcoptions=$db->fetch_all_assoc("select * from ".dbprefix."pay_options where code='Alipay'");
		if($adcoptions){
		$adcontent=$db->query("update  ".dbprefix."pay_options set name='".$name."', account='".$account."', alipay_key='".$key."' , parterid='".$parterid."', service_type='".$service_type."',description='".$description."',pay_method='".$pay_method."',pay_rate='".$pay_rate."',pay_fix='".$pay_fix."' where code='Alipay'");	
		}else{
		$adcontent=$db->query("insert into  ".dbprefix."pay_options (name,account,alipay_key,parterid,service_type,description,pay_method,pay_rate,pay_fix,code) values ('".$name."','".$account."','".$key."','".$parterid."','".intval($service_type)."','".$description."','".$pay_method."','".$pay_rate."','".$pay_fix."','Alipay') ");	
		}
		qiMsg("设置成功","点击返回>>","index.php?app=system&ac=pay_options");
	break;
}