<?php
/*
  $Id: ups.php,v 1.54 2003/04/08 23:23:42 dgw_ Exp $

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

  Copyright (c) 2003 osCommerce

  Released under the GNU General Public License
*/
  class freeamount {
   var $code, $title, $description, $icon, $enabled;
// class constructor
   function freeamount() {
     $this->code = 'freeamount';
     $this->title = MODULE_SHIPPING_FREECOUNT_TEXT_TITLE;
     $this->description = MODULE_SHIPPING_FREECOUNT_TEXT_DESCRIPTION;
     $this->icon ='';   // change $this->icon =  DIR_WS_ICONS . 'shipping_ups.gif'; to some freeshipping icon
     $this->sort_order = MODULE_SHIPPING_FREECOUNT_SORT_ORDER;
     $this->enabled = MODULE_SHIPPING_FREECOUNT_STATUS;
   }
    function quote($method = '') {
     global $cart;
  
  if (( $cart->show_total() < MODULE_SHIPPING_FREECOUNT_AMOUNT ) && MODULE_SHIPPING_FREECOUNT_DISPLAY == 'False')
  return;
      $this->quotes = array('id' => $this->code,
                           'module' => MODULE_SHIPPING_FREECOUNT_TEXT_TITLE);
      if ( $cart->show_total() < MODULE_SHIPPING_FREECOUNT_AMOUNT )
       $this->quotes['error'] = MODULE_SHIPPING_FREECOUNT_TEXT_WAY;
     else
	$this->quotes['methods'] = array(array('id'    => $this->code,
                                              'title' => MODULE_SHIPPING_FREECOUNT_TEXT_WAY,
                                              'cost'  => 0));
      if (tep_not_null($this->icon)) $this->quotes['icon'] = tep_image($this->icon, $this->title);
      return $this->quotes;
   }
    function check() {
     $check = tep_db_query("select configuration_value from " . TABLE_CONFIGURATION . " where configuration_key = 'MODULE_SHIPPING_FREECOUNT_STATUS'");
     $check = tep_db_num_rows($check);
      return $check;
   }
    // Traducción al español por Ronald Hernández (Venezuela)
    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 ('Permitir el envío gratuito con la compra mínima', 'MODULE_SHIPPING_FREECOUNT_STATUS', 'True', '¿Usted desea ofrecer el envío gratuito?', '6', '7', '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, set_function, date_added) values ('Mostrar ', 'MODULE_SHIPPING_FREECOUNT_DISPLAY', 'True', '¿Desea de todos modos mostrar el texto si el monto mínimo no se alcanza?', '6', '7', '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 ('Mínimo', 'MODULE_SHIPPING_FREECOUNT_AMOUNT', '500000.00', 'Monto mínimo de la orden para activar el envío gratuito', '6', '8', now())");
     tep_db_query("insert into " . TABLE_CONFIGURATION . " (configuration_title, configuration_key, configuration_value, configuration_description, configuration_group_id, sort_order, date_added) values ('Secuencia del aviso', 'MODULE_SHIPPING_FREECOUNT_SORT_ORDER', '0', 'Preferiblemente visualizar de primero', '6', '4', now())");
   }
    function remove() {
     tep_db_query("delete from " . TABLE_CONFIGURATION . " where configuration_key in ('" . implode("', '", $this->keys()) . "')");
   }
    function keys() {
     return array('MODULE_SHIPPING_FREECOUNT_STATUS', 'MODULE_SHIPPING_FREECOUNT_DISPLAY', 'MODULE_SHIPPING_FREECOUNT_AMOUNT','MODULE_SHIPPING_FREECOUNT_SORT_ORDER');
   }
 }
?>
