<?php
/*
  $Id: public_money.php,v 1.1 2006/06/12 09:31:31 ryu Exp $

  osCommerce, Open Source E-Commerce Solutions
  http://www.oscommerce.com

  Copyright (c) 2002 osCommerce

  Released under the GNU General Public License
*/

  class public_money {
    var $code, $title, $description, $enabled;

// class constructor
    function public_money() {
      global $order;

      $this->code = 'public_money';
      $this->title = MODULE_PAYMENT_PUBLIC_MONEY_TEXT_TITLE;
      $this->description = MODULE_PAYMENT_PUBLIC_MONEY_TEXT_DESCRIPTION;
      $this->sort_order = MODULE_PAYMENT_PUBLIC_MONEY_SORT_ORDER;
      $this->enabled = ((MODULE_PAYMENT_PUBLIC_MONEY_STATUS == 'True') ? true : false);

      if ((int)MODULE_PAYMENT_PUBLIC_MONEY_ORDER_STATUS_ID > 0) {
        $this->order_status = MODULE_PAYMENT_PUBLIC_MONEY_ORDER_STATUS_ID;
      }

      if (is_object($order)) $this->update_status();
    
      $this->email_footer = MODULE_PAYMENT_PUBLIC_MONEY_TEXT_EMAIL_FOOTER;
    }

// class methods
    function update_status() {
      return false;
    }

    function javascript_validation() {
      return false;
    }

    function selection() {
      return array('id' => $this->code,
                   'module' => $this->title,
                   'fields' => array(array('title' => nl2br(MODULE_PAYMENT_PUBLIC_MONEY_TEXT_PROCESS), 'field' => '')));
    }

    function pre_confirmation_check() {
      return false;
    }

    function confirmation() {
      return array('title' => nl2br(MODULE_PAYMENT_PUBLIC_MONEY_TEXT_PROCESS));
    }

    function process_button() {
      return false;
    }

    function before_process() {
      return false;
    }

    function after_process() {
      return false;
    }

    function get_error() {
      return false;
    }

    function check() {
      if (!isset($this->_check)) {
        $check_query = tep_db_query("select configuration_value from " . TABLE_CONFIGURATION . " where configuration_key = 'MODULE_PAYMENT_PUBLIC_MONEY_STATUS'");
        $this->_check = tep_db_num_rows($check_query);
      }
      return $this->_check;
    }

    function install() {
      tep_db_query("insert into " . TABLE_CONFIGURATION . " (configuration_title, configuration_key, configuration_value, configuration_description, configuration_group_id, sort_order, date_added) values ('支払い方法', 'MODULE_PAYMENT_PUBLIC_MONEY_TEXT_TITLE', '公費', '支払い方法の名前', '6', '11' , now())");
      tep_db_query("insert into " . TABLE_CONFIGURATION . " (configuration_title, configuration_key, configuration_value, configuration_description, configuration_group_id, sort_order, set_function, date_added) values ('公費によるお支払いを有効にする', 'MODULE_PAYMENT_PUBLIC_MONEY_STATUS', 'True', '公費による支払いを受け付けますか?', '6', '1', 'tep_cfg_select_option(array(\'True\', \'False\'), ', now());");
      tep_db_query("insert into " . TABLE_CONFIGURATION . " (configuration_title, configuration_key, configuration_value, configuration_description, configuration_group_id, sort_order, date_added) values ('表示の整列順', 'MODULE_PAYMENT_PUBLIC_MONEY_SORT_ORDER', '0', '表示の整列順を設定できます。数字が小さいほど上位に表示されます.', '6', '0', now())");
      tep_db_query("insert into " . TABLE_CONFIGURATION . " (configuration_title, configuration_key, configuration_value, configuration_description, configuration_group_id, sort_order, set_function, use_function, date_added) values ('初期注文ステータス', 'MODULE_PAYMENT_PUBLIC_MONEY_ORDER_STATUS_ID', '0', '設定したステータスが受注時に適用されます.', '6', '0', 'tep_cfg_pull_down_order_statuses(', 'tep_get_order_status_name', now())");
      tep_db_query("insert into " . TABLE_CONFIGURATION . " (configuration_title, configuration_key, configuration_value, configuration_description, configuration_group_id, sort_order, set_function, date_added) values ('支払い方法選択時の注釈', 'MODULE_PAYMENT_PUBLIC_MONEY_TEXT_PROCESS', '下記コメント欄に必要書類等のお手続き方法について、ご記入をお願いいたします。', 'レジの支払い方法選択画面で表示する注釈です。', '6', '12' , 'tep_cfg_textarea(', now())");
      tep_db_query("insert into " . TABLE_CONFIGURATION . " (configuration_title, configuration_key, configuration_value, configuration_description, configuration_group_id, sort_order, set_function, date_added) values ('メールへの注釈', 'MODULE_PAYMENT_PUBLIC_MONEY_TEXT_EMAIL_FOOTER', '', '注文確認メールに追記する文面です。', '6', '13', 'tep_cfg_textarea(', now())");
    }

    function remove() {
      tep_db_query("delete from " . TABLE_CONFIGURATION . " where configuration_key in ('" . implode("', '", $this->keys()) . "')");
    }

    function keys() {
      return array('MODULE_PAYMENT_PUBLIC_MONEY_TEXT_TITLE', 'MODULE_PAYMENT_PUBLIC_MONEY_STATUS', 'MODULE_PAYMENT_PUBLIC_MONEY_SORT_ORDER', 'MODULE_PAYMENT_PUBLIC_MONEY_ORDER_STATUS_ID', 'MODULE_PAYMENT_PUBLIC_MONEY_TEXT_PROCESS', 'MODULE_PAYMENT_PUBLIC_MONEY_TEXT_EMAIL_FOOTER');
    }
  }
?>
