<?php

/* ========================================================================
 * $Id: detail.php 3092 2020-07-08 11:27:03Z onez $
 * 
 * Email: www@onez.cn
 * QQ: 6200103
 * HomePage: http://www.onez.cn
 * ========================================================================
 * Copyright 2016-2017 佳蓝科技.
 * 
 * ======================================================================== */

!defined('IN_ONEZ') && exit('Access Denied');
# edit
#请求数据
if($MODE=='$post'){
  $id=onez()->gp('id');
  $action=onez()->gp('action');
  if($action=='data'){
    
    $data=array();
    $data['title']='支付设置';
    $A['pagedata']=$data;
    $token=onez()->gp('token');
    list($Token,$_token)=explode('.',$token);
    $form=$this->load('form');
    $T=$G['this']->data()->open('bs.pay.setting')->one("token='$token'");
    
    $form->init($T);
    
    $ConFile=onez('bs.pay')->path.'/paytypes/'.$Token.'/config.php';
    $Con=include($ConFile);
    
    $Con['logo'] && $form->add(array('label'=>' ','type'=>'html','key'=>'plat_logo','value'=>'<pre><img src="'.$Con['logo'].'" style="height:60px" /></pre>','notempty'=>'','default'=>'','group'=>''));
    $form->add(array('label'=>'支付平台','type'=>'html','key'=>'plat_name','value'=>'<pre>'.$Con['name'].'</pre>','notempty'=>'','default'=>'','group'=>''));
    $Con['link'] && $form->add(array('label'=>'官网地址','type'=>'html','key'=>'plat_link','value'=>'<pre><a href="'.$Con['link'].'" target="_blank">'.$Con['link'].'</a></pre>','notempty'=>'','default'=>'','group'=>''));
    
    
    $conFile=onez('bs.pay')->path.'/paytypes/'.$Token.'/'.$_token.'/config.php';
    $con=include($conFile);
    $form->add(array('label'=>'接口名称 ','type'=>'html','key'=>'paytype_name','value'=>'<pre>'.$con['name'].'</pre>','notempty'=>'','default'=>'','group'=>''));
    
    $form->add(array('label'=>'优先级','type'=>'text','key'=>'step','hint'=>'','notempty'=>'','default'=>'','group'=>''));
    $form->add(array('label'=>'自定义名称','type'=>'text','key'=>'name','hint'=>'','notempty'=>'','default'=>$Con['name'].$con['name'],'notempty'=>'接口名称不能为空'));
    $form->add(array('label'=>'是否开通','type'=>'switch','key'=>'enabled','hint'=>'','notempty'=>'','default'=>'','group'=>''));
    $form->add(array('label'=>'借权地址','type'=>'text','key'=>'borrow','hint'=>'','notempty'=>'','default'=>'','tip'=>'当本站没有开通此支付功能，或者当前域名没有支付权限时，<br />可通过借权功能跳转到“借权地址”进行支付，<br />支付完成后返回当前页面，同时此网站无需再填写参数。<br />格式：<span style="color:red">http://www.onez.cn/</span>'));
    $settingFile=onez('bs.pay')->path.'/paytypes/'.$Token.'/'.$_token.'/setting.php';
    include($settingFile);
    
    if($onez=$form->submit()){
      $onez['index1']=$onez['enabled'];
      $onez['key3']=$onez['name'];
      if($T){
        $G['this']->data()->open('bs.pay.setting')->update($onez,"id='$T[id]'");
      }else{
        $onez['token']=$token;
        $onez['key1']=$Token;
        $onez['key2']=$_token;
        $G['this']->data()->open('bs.pay.setting')->insert($onez);
      }
      return $this->ok('提交成功','reload2');
    }
    $form->output($A);
  }
  return;
}
$this->add(array(
  'type'=>'breadcrumb',
  'name'=>'面包屑导航',
  'data'=>'pagedata',
));

$this->add(array(
  'type'=>'pageform',
  'name'=>'表单',
  'data'=>'form',
));
