PHP Code:
<?php
/*
$Id: tcat.php,v 1.1 2003/10/19 08:27:22 nickle Exp $
osCommerce, Open Source E-Commerce Solutions
http://www.oscommerce.com
Copyright (c) 2003 osCommerce
Released under the GNU General Public License
*/
class tcat {
var $code, $title, $description, $icon, $enabled;
// class constructor
function tcat() {
global $order;
$this->code = 'tcat';
$this->title = MODULE_SHIPPING_TCAT_TEXT_TITLE;
$this->description = MODULE_SHIPPING_TCAT_TEXT_DESCRIPTION;
$this->sort_order = MODULE_SHIPPING_TCAT_SORT_ORDER;
$this->icon = DIR_WS_ICONS . 'tcat.gif';
$this->tax_class = MODULE_SHIPPING_TCAT_TAX_CLASS;
$this->enabled = ((MODULE_SHIPPING_TCAT_STATUS == 'True') ? true : false);
if ( ($this->enabled == true) && ((int)MODULE_SHIPPING_TCAT_ZONE > 0) ) {
$check_flag = false;
$check_query = zen_db_query("select zone_id from " . TABLE_ZONES_TO_GEO_ZONES . " where geo_zone_id = '" . MODULE_SHIPPING_TCAT_ZONE . "' and zone_country_id = '" . $order->delivery['country']['id'] . "' order by zone_id");
while ($check = zen_db_fetch_array($check_query)) {
if ($check['zone_id'] < 1) {
$check_flag = true;
break;
} elseif ($check['zone_id'] == $order->delivery['zone_id']) {
$check_flag = true;
break;
}
}
if ($check_flag == false) {
$this->enabled = false;
}
}
$this->types = array('TIME0'=>'上午送達 08:00-12:00',
'TIME1'=>'下午送達 12:00-17:00',
'TIME2'=>'夜間送達 17:00-20:00'
);
}
// class methods
function quote($method = '') {
global $_POST, $order, $total_count;
$this->quotes = array('id' => $this->code,
'module' => MODULE_SHIPPING_TCAT_TEXT_TITLE);
$methods = array();
if ($method) {
$i = substr($method,strlen($method)-1) ;
$methods[] = array('id' => 'TIME'.$i,
'title' => $this->types['TIME'.$i],
'cost' => MODULE_SHIPPING_TCAT_COST + MODULE_SHIPPING_TCAT_HANDLING);
} else {
$qsize = sizeof($this->types);
for ($i=0; $i<$qsize; $i++) {
//list($type, $time) = each($this->types[$i]);
$methods[] = array('id' => 'TIME'.$i,
'title' => $this->types['TIME'.$i],
'cost' => MODULE_SHIPPING_TCAT_COST + MODULE_SHIPPING_TCAT_HANDLING);
}
}
$this->quotes['methods'] = $methods;
if ($this->tax_class > 0) {
$this->quotes['tax'] = zen_get_tax_rate($this->tax_class, $order->delivery['country']['id'], $order->delivery['zone_id']);
}
if (zen_not_null($this->icon)) $this->quotes['icon'] = zen_image($this->icon, $this->title);
return $this->quotes;
}
function check() {
if (!isset($this->_check)) {
$check_query = zen_db_query("select configuration_value from " . TABLE_CONFIGURATION . " where configuration_key = 'MODULE_SHIPPING_TCAT_STATUS'");
$this->_check = zen_db_num_rows($check_query);
}
return $this->_check;
}
function install() {
zen_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_SHIPPING_TCAT_STATUS', 'True', '確定要啟動宅急便模組?', '6', '0', 'tep_cfg_select_option(array(\'True\', \'False\'), ', now())");
zen_db_query("insert into " . TABLE_CONFIGURATION . " (configuration_title, configuration_key, configuration_value, configuration_description, configuration_group_id, sort_order, date_added) values ('運費', 'MODULE_SHIPPING_TCAT_COST', '120', '宅急便不分縣市每件統一收費', '6', '0', now())");
zen_db_query("insert into " . TABLE_CONFIGURATION . " (configuration_title, configuration_key, configuration_value, configuration_description, configuration_group_id, sort_order, date_added) values ('處理費', 'MODULE_SHIPPING_TCAT_HANDLING', '40', '宅急便每件處理費用', '6', '0', now())");
zen_db_query("insert into " . TABLE_CONFIGURATION . " (configuration_title, configuration_key, configuration_value, configuration_description, configuration_group_id, sort_order, use_function, set_function, date_added) values ('稅別', 'MODULE_SHIPPING_TCAT_TAX_CLASS', '0', '使用下列稅別', '6', '0', 'tep_get_tax_class_title', 'tep_cfg_pull_down_tax_classes(', now())");
zen_db_query("insert into " . TABLE_CONFIGURATION . " (configuration_title, configuration_key, configuration_value, configuration_description, configuration_group_id, sort_order, use_function, set_function, date_added) values ('運送地區', 'MODULE_SHIPPING_TCAT_ZONE', '0', '如果選擇地區,則只有該地區可以使用這個運送模組', '6', '0', 'tep_get_zone_class_title', 'tep_cfg_pull_down_zone_classes(', now())");
zen_db_query("insert into " . TABLE_CONFIGURATION . " (configuration_title, configuration_key, configuration_value, configuration_description, configuration_group_id, sort_order, date_added) values ('顯示順序', 'MODULE_SHIPPING_TCAT_SORT_ORDER', '0', '顯示順序,數字越小順序在前', '6', '0', now())");
}
function remove() {
zen_db_query("delete from " . TABLE_CONFIGURATION . " where configuration_key in ('" . implode("', '", $this->keys()) . "')");
}
function keys() {
return array('MODULE_SHIPPING_TCAT_STATUS', 'MODULE_SHIPPING_TCAT_COST', 'MODULE_SHIPPING_TCAT_HANDLING', 'MODULE_SHIPPING_TCAT_TAX_CLASS', 'MODULE_SHIPPING_TCAT_ZONE', 'MODULE_SHIPPING_TCAT_SORT_ORDER');
}
}
?>
Bookmarks