code = 'tableadv1'; if ( defined('MODULE_SHIPPING_TABLEADV1_TITLE') ) { $this->title = MODULE_SHIPPING_TABLEADV1_TITLE; } elseif ( defined('MODULE_SHIPPING_TABLEADV1_TEXT_TITLE') ) { $this->title = MODULE_SHIPPING_TABLEADV1_TEXT_TITLE; } else { $this->title = "TITRE"; } if ( defined('MODULE_SHIPPING_TABLEADV1_DESCRIPTION') ) { $this->description = MODULE_SHIPPING_TABLEADV1_DESCRIPTION; } elseif ( defined('MODULE_SHIPPING_TABLEADV1_TEXT_DESCRIPTION') ) { $this->description = MODULE_SHIPPING_TABLEADV1_TEXT_DESCRIPTION; } else { $this->description = "DESCRIPTION"; } $this->sort_order = MODULE_SHIPPING_TABLEADV1_SORT_ORDER; $this->icon = ''; $this->tax_class = MODULE_SHIPPING_TABLEADV1_TAX_CLASS; $this->enabled = ((MODULE_SHIPPING_TABLEADV1_STATUS == 'True') ? true : false); if ( ($this->enabled == true) && ((int)MODULE_SHIPPING_TABLEADV1_ZONE > 0) ) { $check_flag = false; $check_query = tep_db_query("select zone_id from " . TABLE_ZONES_TO_GEO_ZONES . " where geo_zone_id = '" . MODULE_SHIPPING_TABLEADV1_ZONE . "' and zone_country_id = '" . $order->delivery['country']['id'] . "' order by zone_id"); while ($check = tep_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; } } } // class methods function quote($method = '') { global $order, $cart, $shipping_weight, $shipping_num_boxes; if (MODULE_SHIPPING_TABLEADV1_MODE == 'montant') { $order_total = $cart->show_total(); } else { $order_total = $shipping_weight; } $table_cost = split("[:,]" , MODULE_SHIPPING_TABLEADV1_COST); $size = sizeof($table_cost); for ($i=0, $n=$size; $i<$n; $i+=2) { if ($order_total <= $table_cost[$i]) { $shipping = $table_cost[$i+1]; break; } } if (MODULE_SHIPPING_TABLEADV1_MODE == 'poids') { $shipping = $shipping * $shipping_num_boxes; } $this->quotes = array('id' => $this->code, 'module' => $this->description, 'methods' => array(array('id' => $this->code, 'title' => $this->title, 'cost' => $shipping + MODULE_SHIPPING_TABLEADV1_HANDLING))); if ($this->tax_class > 0) { $this->quotes['tax'] = tep_get_tax_rate($this->tax_class, $order->delivery['country']['id'], $order->delivery['zone_id']); } if (tep_not_null($this->icon)) $this->quotes['icon'] = tep_image($this->icon, $this->title); return $this->quotes; } function check() { if (!isset($this->_check)) { $check_query = tep_db_query("select configuration_value from " . TABLE_CONFIGURATION . " where configuration_key = 'MODULE_SHIPPING_TABLEADV1_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, set_function, date_added) VALUES ('Activer ce mode de livraison', 'MODULE_SHIPPING_TABLEADV1_STATUS', 'True', 'Voulez-vous proposer ce mode de livraison ?', '6', '0', '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 ('Titre', 'MODULE_SHIPPING_TABLEADV1_TITLE', '" . $this->title . "', 'Titre de ce mode de livraison.\nLe client verra le mode de livraison apparaître sur son bon de commande ainsi : \ndescription(titre)', '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, date_added) VALUES ('Description', 'MODULE_SHIPPING_TABLEADV1_DESCRIPTION', '" . $this->description . "', 'Description de ce mode de payment', '6', '0', '', now())"); tep_db_query("insert into " . TABLE_CONFIGURATION . " (configuration_title, configuration_key, configuration_value, configuration_description, configuration_group_id, sort_order, date_added) values ('Table des prix', 'MODULE_SHIPPING_TABLEADV1_COST', '25:8.50,50:5.50,10000:0.00', 'Les frais de livraisons sont définis à partir du poids total ou du montal de la commande. Exemple: 25:8.50,50:5.50,etc.. de 0 à 25, les frais sont de 8.50, de 25 à 50, les frais sont de 5.50, etc', '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, date_added) values ('Poids ou Montant ?', 'MODULE_SHIPPING_TABLEADV1_MODE', 'montant', 'Les frais de livraison sont-ils définis selon le poids total de la commande ou selon son montant ?', '6', '0', 'tep_cfg_select_option(array(\'poids\', \'montant\'), ', now())"); tep_db_query("insert into " . TABLE_CONFIGURATION . " (configuration_title, configuration_key, configuration_value, configuration_description, configuration_group_id, sort_order, date_added) values ('Frais Fixe', 'MODULE_SHIPPING_TABLEADV1_HANDLING', '0', 'Frais fixe pour ce mode de livraison.', '6', '0', now())"); tep_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 ('TVA', 'MODULE_SHIPPING_TABLEADV1_TAX_CLASS', '0', 'Taux de TVA à appliquer aux frais de livraison.', '6', '0', 'tep_get_tax_class_title', 'tep_cfg_pull_down_tax_classes(', now())"); tep_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 ('Zone De Livraison', 'MODULE_SHIPPING_TABLEADV1_ZONE', '0', 'Si une zone est sélectionnée, on restreint l\'utilisation de ce mode de livraison à cette zone.', '6', '0', 'tep_get_zone_class_title', 'tep_cfg_pull_down_zone_classes(', now())"); tep_db_query("insert into " . TABLE_CONFIGURATION . " (configuration_title, configuration_key, configuration_value, configuration_description, configuration_group_id, sort_order, date_added) values ('Ordre d\'affichage', 'MODULE_SHIPPING_TABLEADV1_SORT_ORDER', '0', 'Ordre d\'affichage par rapport aux autres modes de livraison.', '6', '0', now())"); } function remove() { tep_db_query("delete from " . TABLE_CONFIGURATION . " where configuration_key in ('" . implode("', '", $this->keys()) . "')"); } function keys() { return array('MODULE_SHIPPING_TABLEADV1_STATUS', 'MODULE_SHIPPING_TABLEADV1_TITLE', 'MODULE_SHIPPING_TABLEADV1_DESCRIPTION', 'MODULE_SHIPPING_TABLEADV1_COST', 'MODULE_SHIPPING_TABLEADV1_MODE', 'MODULE_SHIPPING_TABLEADV1_HANDLING', 'MODULE_SHIPPING_TABLEADV1_TAX_CLASS', 'MODULE_SHIPPING_TABLEADV1_ZONE', 'MODULE_SHIPPING_TABLEADV1_SORT_ORDER'); } } ?>