PageRenderTime 55ms CodeModel.GetById 23ms RepoModel.GetById 0ms app.codeStats 0ms

/b2b/core/admin/controller/trading/ctl.payment.php

http://phpfor.googlecode.com/
PHP | 364 lines | 285 code | 20 blank | 59 comment | 48 complexity | 4bcf223fbfd0de43a04d30761c973cea MD5 | raw file
  1. <?php
  2. /**
  3. * ctl_payment
  4. *
  5. * @uses pageFactory
  6. * @package
  7. * @version $Id: ctl.payment.php 1867 2008-04-23 04:00:24Z flaboy $
  8. * @copyright 2003-2007 ShopEx
  9. * @author Likunpeng <leoleegood@zovatech.com>
  10. * @license Commercial
  11. */
  12. include_once('objectPage.php');
  13. class ctl_payment extends objectPage {
  14. var $name='??';
  15. var $workground ='setting';
  16. var $actionView = 'payment/finder_action.html';
  17. var $object = 'trading/paymentcfg';
  18. var $editMode = true;
  19. var $disableGridEditCols = "id";
  20. var $disableColumnEditCols = "id";
  21. var $disableGridShowCols = "id";
  22. /**
  23. * main
  24. *
  25. * @access public
  26. * @return void
  27. */
  28. function detail($id){
  29. $this->path[] = array('text'=>'??????');
  30. $oPay = $this->system->loadModel('trading/payment');
  31. $aPay = $oPay->getPaymentById($id);
  32. $this->pagedata['pay'] = $aPay;
  33. $this->pagedata['pay_info'] = $this->_getPayOpt($aPay['pay_type'], $aPay['custom_name'], $aPay['fee'], $aPay['config']);
  34. $oPlu = $oPay->loadMethod($aPay['pay_type']);
  35. if($oPlu){
  36. $this->pagedata['html'] = $oPlu->infoPad();
  37. }
  38. $this->pagedata['pay_id'] = $id;
  39. $this->pagedata['order'] = $aPay['orderlist'];
  40. $this->pagedata['old_pay_type'] = $aPay['pay_type'];
  41. $this->pagedata['pay_des'] = $aPay['des'];
  42. $this->pagedata['pay_name'] = $aPay['custom_name'];
  43. $this->pagedata['paylist'] = $oPay->getPluginsArr(true);
  44. $this->setView('payment/pay_edit.html');
  45. $this->output();
  46. }
  47. /**
  48. * main
  49. *
  50. * @access public
  51. * @return void
  52. */
  53. function getPayList(){
  54. $this->path[] = array('text'=>'????');
  55. $oPay = $this->system->loadModel('trading/payment');
  56. $this->pagedata['items'] = $oPay->getMethods();
  57. $this->page('payment/pay_list.html');
  58. }
  59. function _getHtmlString($key,$val,$rs=array()){
  60. $sJS = '';
  61. $val['desc'] and $desc = '<span class="notice_inline">'.$val['desc'].'</span>';
  62. switch($val['type']){
  63. case 'string':
  64. $sJS .= '<tr><th>'.$val['label'].'?</th><td><input type="text" name="'.$key.'"'.($rs[$key]?' value="'.$rs[$key].'"':'').' />'.$desc.'</td></tr>';
  65. break;
  66. case 'select':
  67. $sJS .= '<tr><th>'.$val['label'].'?</th><td><select name="'.$key.'">';
  68. foreach($val['options'] as $k=>$v){
  69. $sJS .= '<option value="'.$k.'" '.(($rs[$key]==$k)?'selected':'').'>'.$v.'</option>';
  70. }
  71. $sJS .= '</select>'.$desc.'</td></tr>';
  72. break;
  73. case 'number':
  74. $sJS .= '<tr><th>'.$val['label'].'?</th><td><input type="text" name="'.$key.'"'.($rs[$key]?',value="'.$rs[$key].'"':'').' />'.$desc.'</td></tr>';
  75. break;
  76. case 'file':
  77. $sJS .= '<tr><th>'.$val['label'].'?</th><td><input type="file" name="'.$key.'" />'.$desc.'</td></tr>';
  78. break;
  79. case 'box-single':
  80. $sJS .= '<tr><th>'.$val['label'].'?</th><td><input type="checkbox" name="'.$key.'" value="on" '.(($rs[$key]=='on')?'checked':'').'/>'.$desc.'</td></tr>';
  81. break;
  82. default:
  83. $sJS .= '<tr><th>'.$val['label'].'?</th><td><input type="text" name="'.$key.'"'.($rs[$key]?',value="'.$rs[$key].'"':'').' />'.$desc.'</td></tr>';
  84. break;
  85. }
  86. return $sJS;
  87. }
  88. /**
  89. * savePayment
  90. *
  91. * @access public
  92. * @return void
  93. */
  94. function savePayment(){
  95. if($_POST['pay_id']){
  96. $this->begin('index.php?ctl=trading/payment&act=detail&p[0]='.$_POST['pay_id']);
  97. }else{
  98. $this->begin('index.php?ctl=trading/payment&act=index');
  99. }
  100. $oPay = $this->system->loadModel('trading/payment');
  101. $_POST['fee'] = $_POST['fee'] / 100;
  102. if ($_FILES){//???????
  103. $file=$this->system->loadModel("system/sfile");
  104. foreach($_FILES as $key => $val){
  105. if (intval($val['size'])>0){
  106. $_POST[$key]=$val['name'];
  107. switch ($_POST['pay_type']){
  108. case "ICBC"://????
  109. if ($key=="keyFile"){//??????
  110. if(substr($val['name'],strrpos($val['name'],".")+1,strlen($val['name']))!="key"){
  111. trigger_error(__('??????????,???key????'),E_USER_ERROR);
  112. exit;
  113. }
  114. }
  115. elseif ($key == "certFile"||$key =="icbcFile"){//??????
  116. if(substr($val['name'],strrpos($val['name'],".")+1,strlen($val['name']))!="crt"){
  117. if($key=="certFile")
  118. trigger_error(__('??????????,???crt????'),E_USER_ERROR);
  119. else
  120. trigger_error(__('??????????,???crt????'),E_USER_ERROR);
  121. exit;
  122. }
  123. }
  124. break;
  125. case "HYL"://?????
  126. if ($key == "keyFile"){//????
  127. if(substr($val['name'],strrpos($val['name'],".")+1,strlen($val['name']))!="pem"){
  128. trigger_error(__('????????,???key????'),E_USER_ERROR);
  129. exit;
  130. }
  131. }
  132. elseif ($key == "certFile"){//????
  133. if(substr($val['name'],strrpos($val['name'],".")+1,strlen($val['name']))!="cer"){
  134. trigger_error(__('????????,???cer????'),E_USER_ERROR);
  135. exit;
  136. }
  137. }
  138. break;
  139. case "billpki":
  140. if ($key == "keyFile"){//????
  141. if(substr($val['name'],strrpos($val['name'],".")+1,strlen($val['name']))!="pfx"){
  142. trigger_error(__('??????,???pfx????'),E_USER_ERROR);
  143. exit;
  144. }
  145. }
  146. elseif ($key == "certFile"){//????
  147. if(substr($val['name'],strrpos($val['name'],".")+1,strlen($val['name']))!="cer"){
  148. trigger_error(__('??????,???cer????'),E_USER_ERROR);
  149. exit;
  150. }
  151. }
  152. break;
  153. default:
  154. break;
  155. }
  156. $file->UploadPaymentFile($val,$_POST['pay_type']);//????????
  157. }
  158. }
  159. }
  160. $this->end($oPay->updatePay($_POST), __('?????'));
  161. }
  162. /**
  163. * addpayment
  164. *
  165. * @access public
  166. * @return void
  167. */
  168. function addPayment(){
  169. $this->begin('index.php?ctl=trading/payment&act=index');
  170. $oPay = $this->system->loadModel('trading/payment');
  171. $_POST['fee'] = $_POST['fee'] / 100;
  172. if ($_FILES){//???????
  173. $file=$this->system->loadModel("system/sfile");
  174. foreach($_FILES as $key => $val){
  175. if (intval($val['size'])>0){
  176. $_POST[$key]=$val['name'];
  177. switch ($_POST['pay_type']){
  178. case "ICBC"://????
  179. if ($key=="keyFile"){//??????
  180. if(substr($val['name'],strrpos($val['name'],".")+1,strlen($val['name']))!="key"){
  181. trigger_error(__('??????,???key????'),E_USER_ERROR);
  182. exit;
  183. }
  184. }
  185. elseif ($key == "certFile"||$key =="icbcFile"){//??????
  186. if(substr($val['name'],strrpos($val['name'],".")+1,strlen($val['name']))!="crt"){
  187. trigger_error(__('??????,???crt????'),E_USER_ERROR);
  188. exit;
  189. }
  190. }
  191. break;
  192. case "HYL"://?????
  193. if ($key == "keyFile"){//????
  194. if(substr($val['name'],strrpos($val['name'],".")+1,strlen($val['name']))!="pem"){
  195. trigger_error(__('??????,???pem????'),E_USER_ERROR);
  196. exit;
  197. }
  198. }
  199. elseif ($key == "certFile"){//????
  200. if(substr($val['name'],strrpos($val['name'],".")+1,strlen($val['name']))!="cer"){
  201. trigger_error(__('??????,???cer????'),E_USER_ERROR);
  202. exit;
  203. }
  204. }
  205. break;
  206. case "billpki":
  207. if ($key == "keyFile"){//????
  208. if(substr($val['name'],strrpos($val['name'],".")+1,strlen($val['name']))!="pfx"){
  209. trigger_error(__('??????,???pfx????'),E_USER_ERROR);
  210. exit;
  211. }
  212. }
  213. elseif ($key == "certFile"){//????
  214. if(substr($val['name'],strrpos($val['name'],".")+1,strlen($val['name']))!="cer"){
  215. trigger_error(__('??????,???cer????'),E_USER_ERROR);
  216. exit;
  217. }
  218. }
  219. break;
  220. case "skypay":
  221. if ($key=="keyFile" || $key =="certFile"){//????
  222. if(substr($val['name'],strrpos($val['name'],".")+1,strlen($val['name']))!="key"){
  223. trigger_error(__('??????,???key????'),E_USER_ERROR);
  224. exit;
  225. }
  226. }
  227. break;
  228. default:
  229. break;
  230. }
  231. $file->UploadPaymentFile($val,$_POST['pay_type']);//????????
  232. }
  233. }
  234. }
  235. $this->end($oPay->insertPay($_POST,$msg),$msg);
  236. }
  237. /**
  238. * addpayment
  239. *
  240. * @access public
  241. * @return void
  242. */
  243. function delPayment($sId){
  244. $this->begin('index.php?ctl=trading/payment&act=index');
  245. $oPay = $this->system->loadModel('trading/payment');
  246. $this->end($oPay->deletePay($sId),__('?????'));
  247. }
  248. /**
  249. * newPayment
  250. *
  251. * @access public
  252. * @return void
  253. */
  254. function newPayment(){
  255. $this->path[] = array('text'=>'??????');
  256. $oPay = $this->system->loadModel('trading/payment');
  257. $this->pagedata['paylist'] = $oPay->getPluginsArr(true);
  258. $this->page('payment/pay_new.html');
  259. }
  260. /**
  261. * detailPayment
  262. *
  263. * @access public
  264. * @return void
  265. */
  266. function detailPayment($id){
  267. $this->path[] = array('text'=>'??????');
  268. $oPay = $this->system->loadModel('trading/payment');
  269. //$oPay->getPluginsArr(true);
  270. $aPay = $oPay->getPaymentById($id);
  271. $this->pagedata['pay'] = $aPay;
  272. $this->pagedata['pay_info'] = $this->_getPayOpt($aPay['pay_type'], $aPay['custom_name'], $aPay['fee'], $aPay['config']);
  273. $this->pagedata['pay_id'] = $id;
  274. $this->pagedata['order'] = $aPay['orderlist'];
  275. $this->pagedata['old_pay_type'] = $aPay['pay_type'];
  276. $this->pagedata['pay_des'] = $aPay['des'];
  277. $this->pagedata['pay_name'] = $aPay['custom_name'];
  278. $this->pagedata['paylist'] = $oPay->getPluginsArr(true);
  279. $this->page('payment/pay_edit.html');
  280. }
  281. /**
  282. * getPayOpt
  283. *
  284. * @access public
  285. * @return void
  286. */
  287. function getPayOpt($sType, $sPayName=''){
  288. header('Content-Type: text/html;charset=utf-8');
  289. if(!$sType){
  290. echo ' ';
  291. }else{
  292. echo $this->_getPayOpt($sType, $sPayName);
  293. }
  294. }
  295. function _getPayOpt($sType, $sPayName='', $nFee='', $config=''){
  296. $sStr = '';
  297. $sHtml = '<table width="100%" border="0" cellpadding="0" cellspacing="0"><tr><th>???????</th><td><input type="text" name="custom_name" value="'.$sPayName.'" /></td>';
  298. $oPay = $this->system->loadModel('trading/payment');
  299. $oPlu = $oPay->loadMethod($sType);
  300. if($aThisPayCur = $oPay->getSupportCur($oPlu)){
  301. if($aThisPayCur['DEFAULT']){
  302. $sStr = '??????';
  303. }else{
  304. $oCur = $this->system->loadModel('system/cur');
  305. $aCurLang = $oCur->getSysCur();
  306. if($aThisPayCur['ALL']){
  307. $aThisPayCur = $aCurLang;
  308. }
  309. foreach($aThisPayCur as $k=>$v){
  310. $sStr .= $aCurLang[$k].",&nbsp;";
  311. }
  312. }
  313. }
  314. $sHtml .= '<tr><th>???????</th><td>'.($sStr?rtrim($sStr,',&nbsp;'):'').'</td></tr>';
  315. if($oPlu){
  316. $aTemp = unserialize($config);
  317. if($aTemp){
  318. foreach($aTemp as $key=>$val){
  319. $aPay[$key]=$val;
  320. }
  321. }
  322. $aField = $oPlu->getfields();
  323. foreach($aField as $key=>$val){
  324. $sHtml .= $this->_getHtmlString($key,$val,$aPay);
  325. }
  326. }
  327. return $sHtml .='<tr><th>?????</th><td><input type="text" name="fee" style="width:50px" value="'.($nFee*100).'" />%<span class="notice_inline">??????????????????</span></td></tr></table>';
  328. }
  329. function infoPad($pid){
  330. header('Content-Type: text/html;charset=utf-8');
  331. if(!$pid){
  332. echo ' ';
  333. }else{
  334. $oPay = $this->system->loadModel('trading/payment');
  335. $oPlu = $oPay->loadMethod($pid);
  336. $infoPad = '';
  337. if($oPlu){
  338. $infoPad = $oPlu->infoPad();
  339. }
  340. echo $infoPad;
  341. }
  342. }
  343. }
  344. ?>