<?php
/**
  @licence GPL 2005-2010  The osCSS developers - osCSS Open Source E-commerce
  @portion code Copyright (c) 2002 osCommerce
  @package osCSS-2 <www http://www.oscss.org>
  @version 2.1.0
  @date  09/01/11, 12:43
  @author oscim <mail aurelien@oscim.fr> <www http://www.oscim.fr>
  @encode UTF-8
*/
class ot_tax
  implements InterfaceModule, InterfaceAcaOrderTotal{
  public $title;
  public $output;

  public function __construct() {
    $this->code = __CLASS__;
    $this->title = __('module order total tax title');
    $this->description = __('module order total tax description');
    $this->sort_order = (defined('MODULE_ORDER_TOTAL_TAX_SORT_ORDER')) ? MODULE_ORDER_TOTAL_TAX_SORT_ORDER : 4 ;
    $this->enabled = true;

    $this->output = array();
  }

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

    reset($order->info['tax_groups']);
    while (list($key, $value) = each($order->info['tax_groups'])) {
      if ($value > 0) {
        $this->output[] = array('title' => 'dont '. $key . ':',
                                'text' => $currencies->format($value, true, $order->info['currency'], $order->info['currency_value']),
                                'value_ht' => 0,
                                'value' => 0/*$value*/);
      }
    }
  }

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

    return $this->_check;
  }

  public function keys() {
    return array('MODULE_ORDER_TOTAL_TAX_SORT_ORDER');
  }

  public 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 ('Ordre de tri', 'MODULE_ORDER_TOTAL_TAX_SORT_ORDER', '3', 'Ordre de tri pour l\'affichage (Le plus petit nombre est montr&eacute; en premier).', '6', '2', now())");
  }

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