shipping Class Reference

Inherits AbstractAcaModule.

List of all members.

Public Member Functions

Static Public Member Functions

  • static getInstance ($module='')
  • static resetInstance ()
  • static getGeoZoneID ($country_id, $zone_id)
    Necessaire dans les module enfants Control $zone_id && $country_id.
  • static get_icon ($path, $title)
    display icon if exist

Public Attributes

Static Public Attributes

Static Protected Attributes

Private Member Functions


Detailed Description

Definition at line 17 of file shipping.php.


Constructor & Destructor Documentation

shipping::__construct ( module = ''  ) 

Definition at line 28 of file shipping.php.

00028                                    {
00029     self::initialise($module);
00030   }


Member Function Documentation

shipping::cheapest (  ) 

Meilleur methode (la moins chere).

Definition at line 131 of file shipping.php.

00131                              {
00132     if (is_array($this->modules)) {
00133       $rates = array();
00134 
00135       reset($this->modules);
00136       foreach($this->modules as $class=>$s){
00137         if ($GLOBALS[$class]->enabled && (($quotes = $GLOBALS[$class]->quotes) !=false) ) {
00138           for ($i=0, $n=sizeof($quotes['methods']); $i<$n; $i++) {
00139             if (isset($quotes['methods'][$i]['cost']) && tep_not_null($quotes['methods'][$i]['cost'])) {
00140               $rates[] = array('id' => $quotes['id'] . '_' . $quotes['methods'][$i]['id'],
00141                                 'title' => $quotes['module'] . ' (' . $quotes['methods'][$i]['title'] . ')',
00142                                 'cost_ht' => @$quotes['methods'][$i]['cost_ht'],
00143                                 'cost' => $quotes['methods'][$i]['cost']);
00144             }
00145           }
00146         }
00147       }
00148 
00149       $cheapest = false;
00150       for ($i=0, $n=sizeof($rates); $i<$n; $i++) {
00151         if (is_array($cheapest)) {
00152           if ($rates[$i]['cost'] < $cheapest['cost']) {
00153             $cheapest = $rates[$i];
00154           }
00155         } else {
00156           $cheapest = $rates[$i];
00157         }
00158       }
00159 
00160       return $cheapest;
00161     }
00162   }

shipping::get_icon ( path,
title 
) [static]

display icon if exist

Parameters:
$path 
$title 

Definition at line 203 of file shipping.php.

Referenced by spu::quote(), mzmt::quote(), item::quote(), and flat::quote().

00203                                                  {
00204     return tep_image( (strpos($path,DIR_WS_CATALOG) ==false )
00205                         ? substr(str_replace('//','/',$path), strlen(DIR_WS_CATALOG) )
00206                         :  $path,
00207                       $title);
00208   }

shipping::getGeoZoneID ( country_id,
zone_id 
) [static]

Necessaire dans les module enfants Control $zone_id && $country_id.

Si false module desactivé

Parameters:
$country_id int de customers venant de order
$zone_id int de customers venant de order

Definition at line 171 of file shipping.php.

Referenced by spu::update_status(), mzmt::update_status(), item::update_status(), and flat::update_status().

00171                                                              {
00172     $cache=array();
00173     static $cache;
00174 
00175     $key = 'country_'.(int)$country_id.'zone_'.(int)$zone_id;
00176     if(isset($cache[$key])) return $cache[$key];
00177 
00178     $DB=Database::getInstance();
00179     // First, check for a Geo Zone that explicity includes the country & specific zone (useful for splitting countries with zones up)
00180     $zone_query = $DB->query("select gz.geo_zone_id from " . TABLE_GEO_ZONES . " gz left join " . TABLE_ZONES_TO_GEO_ZONES . " ztgz on (gz.geo_zone_id = ztgz.geo_zone_id) where ztgz.zone_country_id = '" . (int)$country_id . "' and ztgz.zone_id = '" . (int)$zone_id . "' and LOWER(gz.geo_zone_name) like 'shp%'");
00181 
00182     if ($zone_query->__get('numRows')) {
00183       $zone = $zone_query->fetchAssoc();
00184       return $cache[$key]=$zone['geo_zone_id'];
00185     } else {
00186       // No luck…  Now check for a Geo Zone for the country and "All Zones" of the country.
00187       $zone_query = $DB->query("select gz.geo_zone_id from " . TABLE_GEO_ZONES . " gz left join " . TABLE_ZONES_TO_GEO_ZONES . " ztgz on (gz.geo_zone_id = ztgz.geo_zone_id) where ztgz.zone_country_id = '" . (int)$country_id . "' and (ztgz.zone_id = '0' or ztgz.zone_id is NULL) and LOWER(gz.geo_zone_name) like 'shp%'");
00188 
00189       if ($zone_query->__get('numRows')) {
00190         $zone = $zone_query->fetchAssoc();
00191         return $cache[$key]=$zone['geo_zone_id'];
00192       }
00193     }
00194     return $cache[$key]=false;
00195   }

static shipping::getInstance ( module = ''  )  [static]

Definition at line 32 of file shipping.php.

00032                                                  {
00033       if(self::$_instance == null) {
00034           self::$_instance = new self($module);
00035       }
00036       return self::$_instance;
00037   }

shipping::initialise ( module = ''  )  [private]

class constructor

Parameters:
$module string/empty le nom du module, passé apres choix

Definition at line 49 of file shipping.php.

Referenced by __construct().

00049                                             {
00050     global $language, $customer_id,$PHP_SELF, $page ,$lang;
00051 
00052     $include_modules = array();
00053     if (tep_not_null($module) && is_array($module)) {
00054       $mod=substr($module["id"], strpos($module["id"],'_')+1);
00055       $this->selected_module = $module;
00056       if(($path=$page->fix_file(DIR_WS_INCLUDES .'languages/'. $language . '/modules/shipment/' . $mod . '.php',true)) !=false) require($path);
00057       if(($path=$page->fix_file(DIR_WS_MODULES . 'shipment/' . $mod . '.php')) !=false) require($path);
00058       $include_modules[] = array_merge($module, array('class' =>$mod) );
00059     } else {
00060       foreach(parent::initialise_type('MODULE_SHIPPING_INSTALLED','shipping') as $class){
00061         $include_modules[] = array('class' => $class, 'file' => $class . '.php');
00062       }
00063     }
00064 
00065     if (isset($_SESSION['sppc_customer_group_id']) && $_SESSION['sppc_customer_group_id'] != '0') $customer_group_id = $_SESSION['sppc_customer_group_id'];
00066     else  $customer_group_id = '0';
00067 
00068     $customer_shipment_query = tep_db_query("select IF(c.customers_shipment_allowed <> '', c.customers_shipment_allowed, cg.group_shipment_allowed) as shipment_allowed from " . TABLE_CUSTOMERS . " c, " . TABLE_CUSTOMERS_GROUPS . " cg where c.customers_id = '" . $customer_id . "' and cg.customers_group_id =  '" . $customer_group_id . "'");
00069     $customer_ot = tep_db_fetch_array($customer_shipment_query);
00070     $temp_ot_array= (tep_not_null($customer_ot['shipment_allowed']) )  ? explode(';', $customer_ot['shipment_allowed']) : array() ;
00071 
00072     foreach($include_modules as $imod){
00073       if( ( count($temp_ot_array)==0 || in_array($imod['file'], $temp_ot_array ) ) ){
00074         if(!empty($imod['class']) && !class_exists($imod['class'])) break;
00075         $this->modules[$imod['class']]=$GLOBALS[$imod['class']] = new $imod['class'];
00076       }
00077     }
00078   }

shipping::quote ( method = '',
module = '' 
)
Parameters:
$method 
$module 

Definition at line 85 of file shipping.php.

00085                                                     {
00086     global $total_weight, $shipping_weight, $shipping_quoted/*, $shipping_num_boxes*/;
00087 
00088     $quotes_array = array();
00089 
00090     if (is_array($this->modules)) {
00091       $shipping_quoted = '';
00092 //       self::$shipping_num_boxes = 1;
00093       $shipping_weight = $total_weight;
00094 
00095       if (SHIPPING_BOX_WEIGHT >= $shipping_weight*SHIPPING_BOX_PADDING/100) {
00096         $shipping_weight = $shipping_weight+SHIPPING_BOX_WEIGHT;
00097       } else {
00098         $shipping_weight = $shipping_weight + ($shipping_weight*SHIPPING_BOX_PADDING/100);
00099       }
00100 
00101       if ($shipping_weight > SHIPPING_MAX_WEIGHT) { // Split into many boxes
00102         self::$shipping_num_boxes = ceil($shipping_weight/SHIPPING_MAX_WEIGHT);
00103         $shipping_weight = $shipping_weight/self::$shipping_num_boxes;
00104       }
00105 
00106       $include_quotes = array();
00107 
00108       reset($this->modules);
00109 
00110       foreach($this->modules as $class=>$s){
00111         if (tep_not_null($module)) {
00112           if ( ($module == $class) && ($GLOBALS[$class]->enabled) ) $include_quotes[] = $class;
00113         }
00114         elseif ($GLOBALS[$class]->enabled)  $include_quotes[] = $class;
00115       }
00116 
00117       $size = sizeof($include_quotes);
00118       for ($i=0; $i<$size; $i++) {
00119         $quotes = $GLOBALS[$include_quotes[$i]]->quote($method);
00120         if (is_array($quotes)) $quotes_array[] = $quotes;
00121       }
00122     }
00123 
00124     return $quotes_array;
00125   }

static shipping::resetInstance (  )  [static]

Definition at line 39 of file shipping.php.

00039                                          {
00040       self::$_instance = null;
00041       return self::getInstance();
00042   }


Member Data Documentation

shipping::$_instance [static, protected]

Reimplemented from page.

Definition at line 26 of file shipping.php.

shipping::$modules

Definition at line 19 of file shipping.php.

shipping::$shipping_num_boxes = 1 [static]

int nombre colis

Definition at line 24 of file shipping.php.

Referenced by mzmt::determineShipping(), and mzmt::quote().


The documentation for this class was generated from the following file: