<?php
/*
  ot_addition.php
  作成日：2005/2/10
　最終更新日：2005/3/5

　作成者：有限会社セカンドブレーン
　　　　　　青木隆平
　　　　　　ryuhei@secondbrain.co.jp

  Released under the GNU General Public License
*/

  class ot_addition {
    var $title, $output;

    function ot_addition() {
      $this->code = 'ot_addition';
      $this->title = MODULE_ORDER_TOTAL_ADDITION_TITLE;
      $this->description = MODULE_ORDER_TOTAL_ADDITION_DESCRIPTION;
      $this->enabled = ((MODULE_ORDER_TOTAL_ADDITION_STATUS == 'true') ? true : false);
      $this->sort_order = MODULE_ORDER_TOTAL_ADDITION_SORT_ORDER;

      $this->output = array();
    }

    function process() {
      global $order, $currencies;

      $this->output[] = array('title' => MODULE_ORDER_TOTAL_ADDITION_TITLE . ':',
                              'text'  => $currencies->format(0, true, $order->info['currency'], $order->info['currency_value']),
                              'value' => 0);

    }

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

      return $this->_check;
    }

    function keys() {
      return array('MODULE_ORDER_TOTAL_ADDITION_STATUS', 'MODULE_ORDER_TOTAL_ADDITION_SORT_ORDER');
    }

    function install() {
      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_ORDER_TOTAL_ADDITION_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_ORDER_TOTAL_ADDITION_SORT_ORDER', '3', '表示の整列順を設定できます. 数字が小さいほど上位に表示されます.', '6', '2', now())");
    }

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