PageRenderTime 68ms CodeModel.GetById 34ms RepoModel.GetById 1ms app.codeStats 0ms

/modules/shop/classes/model/paymethods/moneyua.php

https://bitbucket.org/seyar/ari100krat.local
PHP | 153 lines | 128 code | 12 blank | 13 comment | 10 complexity | bda49bdd483d8bacb0518389f4868036 MD5 | raw file
Possible License(s): BSD-3-Clause, LGPL-2.1
  1. <?php defined('SYSPATH') OR die('No direct access allowed.');
  2. /* @version $Id: v 0.1 ${date} - ${time} Exp $
  3. *
  4. * Project: ${project.name}
  5. * File: ${nameAndExt} *
  6. *
  7. * This library is commercial distributed software; you can't
  8. * redistribute it and/or modify it without owner (or author) approval.
  9. *
  10. * @link http://bestartdesign.com
  11. * @Best IT Solutions (C) 2010
  12. *
  13. * @author ${fullName} ${email}
  14. */
  15. class Model_Paymethods_moneyua extends Model_Paymethods
  16. {
  17. private $_method = 'Moneyua';
  18. function getItem( $where = NULL, $as_array = TRUE )
  19. {
  20. $query = DB::select()
  21. ->from('paymethod_'.strtolower($this->_method))
  22. ;
  23. if($where)
  24. {
  25. foreach($where as $key => $item)
  26. $query->where($key,'=', $item);
  27. }
  28. $result = $query->execute();
  29. if( $result->count() == 0 ) return array();
  30. else{
  31. if( $as_array ) return $result->as_array();
  32. else{
  33. $return = $result->current();
  34. $return['fields'] = array(
  35. 'PAYMENT_AMOUNT' => '',
  36. 'PAYMENT_INFO' => '',
  37. 'PAYMENT_DELIVER' => '',
  38. 'PAYMENT_ORDER' => '',
  39. 'PAYMENT_TYPE' => $return['payment_type'],
  40. 'MERCHANT_INFO' => $return['merchant_info'],
  41. 'SECRETCODE' => $return['secretcode'],
  42. 'PAYMENT_ADDVALUE' => str_replace(' ', '_', $return['payment_addvalue']),
  43. 'PAYMENT_RULE' => $return['payment_rule'],
  44. 'PAYMENT_RETURNRES' => Kohana::config('shop')->PAYMENT_RETURNRES,
  45. 'PAYMENT_RETURN' => Kohana::config('shop')->PAYMENT_RETURN,
  46. 'PAYMENT_RETURNFAIL' => Kohana::config('shop')->PAYMENT_RETURNFAIL,
  47. 'PAYMENT_RETURNMET' => 1,
  48. 'PAYMENT_TESTMODE' => $return['payment_testmode'],
  49. 'PAYMENT_HASH' => '',
  50. );
  51. return $return;
  52. }
  53. }
  54. }
  55. public function delete($id = NULL)
  56. {
  57. $query = DB::delete('paymethod_'.strtolower($this->_method));
  58. if (is_numeric($id))
  59. {
  60. $query->where('id', '=', $id); // ->limit(1)
  61. $total_rows = $query->execute();
  62. }
  63. }
  64. public function delete_list($array)
  65. {
  66. $query = DB::delete('paymethod_'.strtolower($this->_method));
  67. if (count($array))
  68. {
  69. $query->where('id', 'IN', DB::expr('('.implode(',', $array).')') ); // ->limit(1)
  70. $total_rows = $query->execute();
  71. }
  72. return true;
  73. }
  74. public function getCost($obj,$sum = 0,$weight = 0 )
  75. {
  76. return (float)$sum * (float)$obj['percent'] / 100;
  77. }
  78. function add( $data )
  79. {
  80. list($insert_id, $total_rows) = DB::insert('paymethod_'.strtolower($this->_method),
  81. array (
  82. 'merchant_info',
  83. 'payment_testmode',
  84. 'percent',
  85. 'payment_rule',
  86. 'secretcode',
  87. 'payment_addvalue',
  88. 'invoice',
  89. 'ordersendmail',
  90. 'letter_description',
  91. 'action_url',
  92. 'payment_type',
  93. 'postavshik',
  94. )
  95. )
  96. ->values(
  97. array (
  98. $data['merchant_info'],
  99. (isset($data['payment_testmode']) && !empty($data['payment_testmode']) ? 1 : 0 ),
  100. $data['percent'],
  101. (isset($data['plusToOrder']) && !empty($data['plusToOrder']) ? 1 : 2 ),
  102. $data['secretcode'],
  103. $data['payment_addvalue'],
  104. $data['invoice'],
  105. $data['ordersendmail'],
  106. $data['letter_description'],
  107. $data['action_url'],
  108. $data['payment_type'],
  109. $data['postavshik'],
  110. )
  111. )
  112. ->execute()
  113. ;
  114. return $insert_id;
  115. }
  116. function save( $id, $data )
  117. {
  118. DB::update('paymethod_'.strtolower($this->_method))
  119. ->set(
  120. array (
  121. 'merchant_info' => $data['merchant_info'],
  122. 'payment_testmode' => (isset($data['payment_testmode']) && !empty($data['payment_testmode']) ? 1 : 0 ),
  123. 'percent' => $data['percent'],
  124. 'payment_rule' => (isset($data['payment_rule']) && !empty($data['payment_rule']) ? 1 : 2 ),
  125. 'invoice' => $data['invoice'],
  126. 'secretcode' => $data['secretcode'],
  127. 'payment_addvalue' => $data['payment_addvalue'],
  128. 'ordersendmail' => $data['ordersendmail'],
  129. 'letter_description' => $data['letter_description'],
  130. 'action_url' => $data['action_url'],
  131. 'payment_type' => $data['payment_type'],
  132. 'postavshik' => $data['postavshik'],
  133. )
  134. )
  135. ->where('id','=',$id)
  136. ->execute()
  137. ;
  138. return true;
  139. }
  140. }
  141. ?>