00001 <?php
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027 class Mage_Sales_Model_Order_Shipment_Track extends Mage_Sales_Model_Abstract
00028 {
00029 const CUSTOM_CARRIER_CODE = 'custom';
00030 protected $_shipment = null;
00031
00032 protected $_eventPrefix = 'sales_order_shipment_track';
00033 protected $_eventObject = 'track';
00034
00035
00036
00037
00038 function _construct()
00039 {
00040 $this->_init('sales/order_shipment_track');
00041 }
00042
00043
00044
00045
00046
00047
00048
00049 public function setShipment(Mage_Sales_Model_Order_Shipment $shipment)
00050 {
00051 $this->_shipment = $shipment;
00052 return $this;
00053 }
00054
00055
00056
00057
00058
00059
00060 public function getShipment()
00061 {
00062 if (!($this->_shipment instanceof Mage_Sales_Model_Order_Shipment)) {
00063 $this->_shipment = Mage::getModel('sales/order_shipment')->load($this->getParentId());
00064 }
00065
00066 return $this->_shipment;
00067 }
00068
00069 public function isCustom()
00070 {
00071 return $this->getCarrierCode() == self::CUSTOM_CARRIER_CODE;
00072 }
00073
00074
00075
00076
00077
00078
00079 public function getNumberDetail()
00080 {
00081 $carrierInstance = Mage::getSingleton('shipping/config')->getCarrierInstance($this->getCarrierCode());
00082 if (!$carrierInstance) {
00083 $custom['title'] = $this->getTitle();
00084 $custom['number'] = $this->getNumber();
00085 return $custom;
00086 } else {
00087 $carrierInstance->setStore($this->getStore());
00088 }
00089
00090 if (!$trackingInfo = $carrierInstance->getTrackingInfo($this->getNumber())) {
00091 return Mage::helper('sales')->__('No detail for number "%s"', $this->getNumber());
00092 }
00093
00094 return $trackingInfo;
00095 }
00096
00097
00098
00099
00100
00101
00102 public function getStore()
00103 {
00104 if ($this->getShipment()) {
00105 return $this->getShipment()->getStore();
00106 }
00107 return Mage::app()->getStore();
00108 }
00109 }