<?php
/**
 * [LJCMS] (C)2012-2099 LJdev,Inc.
 * <E-Mail：aspcms@qq.com>
 * Url http://www.liangjing.org
 *     http://www.8CMS.com
 * Update 2013.11.19
*/

class control extends adminbase {

	
  public function action_run() {
    //  echo 123;die;
        $model = parent::model('aplipay', 'am');
        $data = $model->getData();
            $var_array = array(
                'aplipay'=>$data,
            );
        TPL::assign($var_array);
        TPL::display($this->cptpl . 'aplipay.tpl');
    }
   public function action_wx() {
    //  echo 123;die;
        $model = parent::model('aplipay', 'am');
        $data = $model->getData_wx();
            $var_array = array(
                'aplipay'=>$data,
            );
        TPL::assign($var_array);
        TPL::display($this->cptpl . 'wxpay.tpl');
    }   
    public function action_saveedit(){  
        $this->checkAuth('aplipay_edit');
        $args = array(
            'app_id'=>XRequest::recArgs('app_id'),
//            'notify_url'=>XRequest::recArgs('notify_url'),
            'notify_url'=> trim($_POST['notify_url']),
            'return_url'=>XRequest::recArgs('return_url'),
            'charset'=>XRequest::recArgs('charset'),
            'sign_type'=>XRequest::recArgs('sign_type'),
            'gatewayUrl'=>XRequest::recArgs('gatewayUrl'),
            'merchant_private_key'=>XRequest::recArgs('merchant_private_key'),
            'alipay_public_key'=>XRequest::recArgs('alipay_public_key'),
             'partner'=>XRequest::recArgs('partner'),
             '`key`'=>XRequest::recArgs('key'),
        );
        $model = parent::model('aplipay', 'am');
        $result = $model->doEdit(1, $args);
        if (true === $result) {
            $this->log('aplipay_edit', "重新修改支付宝配置", 1);
             XHandle::halt('编辑成功。', $this->cpfile.'?c=aplipay&a=run', 0);
        }
        else {
            $this->log('aplipay', "id=1", 0);
            XHandle::halt('编辑失败', '', 1);
        }
        unset($model);
    }
        public function action_saveedit_wx(){  
        $this->checkAuth('aplipay_edit');
        $args = array(
            'app_id'=>XRequest::recArgs('app_id'),
            'charset'=>XRequest::recArgs('charset'),
             'partner'=>XRequest::recArgs('partner'),
             '`key`'=>XRequest::recArgs('key'),
        );
        $model = parent::model('aplipay', 'am');
        $result = $model->doEdit(2, $args);
        if (true === $result) {
            $this->log('aplipay_edit', "重新修改微信配置", 1);
             XHandle::halt('编辑成功。', $this->cpfile.'?c=aplipay&a=wx', 0);
        }
        else {
            $this->log('aplipay', "id=2", 0);
            XHandle::halt('编辑失败', '', 1);
        }
        unset($model);
    }
         public function action_ajax_get_action()
     {     
     	$advContrl = get_class_methods('control');
   
        
     	$html = '';
     	foreach ($advContrl as $val){
            if(strpos($val,'action') !== false){
                   
               $html .= "<option value='".$val."'>".$val."</option>";
                    
            } else {
               
            }
     		
     	}
     	exit($html);
     }
}
?>
