PageRenderTime 24ms CodeModel.GetById 30ms RepoModel.GetById 1ms app.codeStats 0ms

/includes/modules/payment/freecharger.php

https://github.com/yama/zencart13x-ja
PHP | 133 lines | 91 code | 20 blank | 22 comment | 14 complexity | dadff431f517ffeb62329f3820a6f161 MD5 | raw file
  1. <?php
  2. //
  3. // +----------------------------------------------------------------------+
  4. // |zen-cart Open Source E-commerce |
  5. // +----------------------------------------------------------------------+
  6. // | Copyright (c) 2003 The zen-cart developers |
  7. // | |
  8. // | http://www.zen-cart.com/index.php |
  9. // | |
  10. // | Portions Copyright (c) 2003 osCommerce |
  11. // +----------------------------------------------------------------------+
  12. // | This source file is subject to version 2.0 of the GPL license, |
  13. // | that is bundled with this package in the file LICENSE, and is |
  14. // | available through the world-wide-web at the following url: |
  15. // | http://www.zen-cart.com/license/2_0.txt. |
  16. // | If you did not receive a copy of the zen-cart license and are unable |
  17. // | to obtain it through the world-wide-web, please send a note to |
  18. // | license@zen-cart.com so we can mail you a copy immediately. |
  19. // +----------------------------------------------------------------------+
  20. // $Id: freecharger.php 1105 2005-04-04 22:05:35Z birdbrain $
  21. //
  22. class freecharger {
  23. var $code, $title, $description, $enabled, $payment;
  24. // class constructor
  25. function freecharger() {
  26. global $order;
  27. $this->code = 'freecharger';
  28. $this->title = MODULE_PAYMENT_FREECHARGER_TEXT_TITLE;
  29. $this->description = MODULE_PAYMENT_FREECHARGER_TEXT_DESCRIPTION;
  30. $this->sort_order = MODULE_PAYMENT_FREECHARGER_SORT_ORDER;
  31. $this->enabled = ((MODULE_PAYMENT_FREECHARGER_STATUS == 'True') ? true : false);
  32. if ((int)MODULE_PAYMENT_FREECHARGER_ORDER_STATUS_ID > 0) {
  33. $this->order_status = MODULE_PAYMENT_FREECHARGER_ORDER_STATUS_ID;
  34. $payment='freecharger';
  35. } else {
  36. if ($payment=='freecharger') {
  37. $payment='';
  38. }
  39. }
  40. if (is_object($order)) $this->update_status();
  41. $this->email_footer = MODULE_PAYMENT_FREECHARGER_TEXT_EMAIL_FOOTER;
  42. }
  43. // class methods
  44. function update_status() {
  45. global $db;
  46. global $order;
  47. if ( ($this->enabled == true) && ((int)MODULE_PAYMENT_FREECHARGER_ZONE > 0) ) {
  48. $check_flag = false;
  49. $check = $db->Execute("select zone_id from " . TABLE_ZONES_TO_GEO_ZONES . " where geo_zone_id = '" . MODULE_PAYMENT_FREECHARGER_ZONE . "' and zone_country_id = '" . $order->billing['country']['id'] . "' order by zone_id");
  50. while (!$check->EOF) {
  51. if ($check->fields['zone_id'] < 1) {
  52. $check_flag = true;
  53. break;
  54. } elseif ($check->fields['zone_id'] == $order->billing['zone_id']) {
  55. $check_flag = true;
  56. break;
  57. }
  58. $check->MoveNext();
  59. }
  60. if ($check_flag == false) {
  61. $this->enabled = false;
  62. }
  63. }
  64. }
  65. function javascript_validation() {
  66. return false;
  67. }
  68. function selection() {
  69. return array('id' => $this->code,
  70. 'module' => $this->title);
  71. }
  72. function pre_confirmation_check() {
  73. return false;
  74. }
  75. function confirmation() {
  76. return array('title' => MODULE_PAYMENT_FREECHARGER_TEXT_DESCRIPTION);
  77. }
  78. function process_button() {
  79. return false;
  80. }
  81. function before_process() {
  82. return false;
  83. }
  84. function after_process() {
  85. return false;
  86. }
  87. function get_error() {
  88. return false;
  89. }
  90. function check() {
  91. global $db;
  92. if (!isset($this->_check)) {
  93. $check_query = $db->Execute("select configuration_value from " . TABLE_CONFIGURATION . " where configuration_key = 'MODULE_PAYMENT_FREECHARGER_STATUS'");
  94. $this->_check = $check_query->RecordCount();
  95. }
  96. return $this->_check;
  97. }
  98. function install() {
  99. global $db;
  100. $db->Execute("insert into " . TABLE_CONFIGURATION . " (configuration_title, configuration_key, configuration_value, configuration_description, configuration_group_id, sort_order, set_function, date_added) values ('Enable Free Charge Module', 'MODULE_PAYMENT_FREECHARGER_STATUS', 'False', 'Do you want to accept Free Charge payments?', '6', '1', 'zen_cfg_select_option(array(\'True\', \'False\'), ', now());");
  101. $db->Execute("insert into " . TABLE_CONFIGURATION . " (configuration_title, configuration_key, configuration_value, configuration_description, configuration_group_id, sort_order, date_added) values ('Sort order of display.', 'MODULE_PAYMENT_FREECHARGER_SORT_ORDER', '0', 'Sort order of display. Lowest is displayed first.', '6', '0', now())");
  102. $db->Execute("insert into " . TABLE_CONFIGURATION . " (configuration_title, configuration_key, configuration_value, configuration_description, configuration_group_id, sort_order, use_function, set_function, date_added) values ('Payment Zone', 'MODULE_PAYMENT_FREECHARGER_ZONE', '0', 'If a zone is selected, only enable this payment method for that zone.', '6', '2', 'zen_get_zone_class_title', 'zen_cfg_pull_down_zone_classes(', now())");
  103. $db->Execute("insert into " . TABLE_CONFIGURATION . " (configuration_title, configuration_key, configuration_value, configuration_description, configuration_group_id, sort_order, set_function, use_function, date_added) values ('Set Order Status', 'MODULE_PAYMENT_FREECHARGER_ORDER_STATUS_ID', '0', 'Set the status of orders made with this payment module to this value', '6', '0', 'zen_cfg_pull_down_order_statuses(', 'zen_get_order_status_name', now())");
  104. }
  105. function remove() {
  106. global $db;
  107. $db->Execute("delete from " . TABLE_CONFIGURATION . " where configuration_key in ('" . implode("', '", $this->keys()) . "')");
  108. }
  109. function keys() {
  110. return array('MODULE_PAYMENT_FREECHARGER_STATUS', 'MODULE_PAYMENT_FREECHARGER_ZONE', 'MODULE_PAYMENT_FREECHARGER_ORDER_STATUS_ID', 'MODULE_PAYMENT_FREECHARGER_SORT_ORDER');
  111. }
  112. }
  113. ?>