Transsmart_Shipping - Version 1.0.7

Version Notes

1.0.7

Download this release

Release Info

Developer Techtwo Webdevelopment B.V.
Extension Transsmart_Shipping
Version 1.0.7
Comparing to
See all releases


Code changes from version 1.0.2 to 1.0.7

Files changed (44) hide show
  1. app/code/community/Transsmart/Shipping/Block/Adminhtml/Sales/Order/Create/Shipping/Method/Form.php +19 -0
  2. app/code/community/Transsmart/Shipping/Block/Adminhtml/Sales/Order/Shipment/Create/Detail.php +15 -16
  3. app/code/community/Transsmart/Shipping/Block/Adminhtml/Sales/Order/Shipment/Masscreate/Form.php +12 -6
  4. app/code/community/Transsmart/Shipping/Block/Adminhtml/Sales/Order/Shipment/View/Detail.php +42 -0
  5. app/code/community/Transsmart/Shipping/Block/Adminhtml/Sales/Order/View/Detail.php +106 -0
  6. app/code/community/Transsmart/Shipping/Block/Adminhtml/Sales/Order/View/Tab/Shipments.php +5 -6
  7. app/code/community/Transsmart/Shipping/Block/Adminhtml/Shipping/Carrier/Tablerate/Grid.php +34 -0
  8. app/code/community/Transsmart/Shipping/Block/Adminhtml/System/Config/Form/Field/Locationselect.php +32 -0
  9. app/code/community/Transsmart/Shipping/Block/Checkout/Onepage/Shipping/Method/Available.php +19 -0
  10. app/code/community/Transsmart/Shipping/Helper/Data.php +99 -47
  11. app/code/community/Transsmart/Shipping/Helper/Location.php +53 -1
  12. app/code/community/Transsmart/Shipping/Helper/Shipment.php +813 -781
  13. app/code/community/Transsmart/Shipping/Model/Adminhtml/Observer.php +19 -23
  14. app/code/community/Transsmart/Shipping/Model/Carrierprofile.php +13 -19
  15. app/code/community/Transsmart/Shipping/Model/Observer.php +17 -24
  16. app/code/community/Transsmart/Shipping/Model/Resource/Carrierprofile/Collection.php +67 -49
  17. app/code/community/Transsmart/Shipping/Model/Sales/Quote/Address/Rate.php +17 -0
  18. app/code/community/Transsmart/Shipping/Model/Sales/Quote/Address/Total/Shipping.php +41 -0
  19. app/code/community/Transsmart/Shipping/Model/Sales/Resource/Order.php +8 -1
  20. app/code/community/Transsmart/Shipping/Model/Shipping/Carrier/Abstract.php +2 -0
  21. app/code/community/Transsmart/Shipping/Model/Shipping/Carrier/Tablerate.php +208 -0
  22. app/code/community/Transsmart/Shipping/Model/Shipping/Resource/Carrier/Tablerate.php +151 -0
  23. app/code/community/Transsmart/Shipping/Model/Sync.php +47 -2
  24. app/code/community/Transsmart/Shipping/controllers/Adminhtml/Transsmart/Shipping/ShipmentController.php +27 -21
  25. app/code/community/Transsmart/Shipping/etc/config.xml +31 -1
  26. app/code/community/Transsmart/Shipping/etc/system.xml +22 -10
  27. app/code/community/Transsmart/Shipping/sql/transsmart_shipping_setup/install-1.0.0.php +1 -1
  28. app/code/community/Transsmart/Shipping/sql/transsmart_shipping_setup/upgrade-1.0.2-1.0.3.php +29 -0
  29. app/code/community/Transsmart/Shipping/sql/transsmart_shipping_setup/upgrade-1.0.3-1.0.4.php +94 -0
  30. app/code/community/Transsmart/Shipping/sql/transsmart_shipping_setup/upgrade-1.0.4-1.0.5.php +120 -0
  31. app/code/community/Transsmart/Shipping/sql/transsmart_shipping_setup/upgrade-1.0.5-1.0.6.php +28 -0
  32. app/code/community/Transsmart/Shipping/sql/transsmart_shipping_setup/upgrade-1.0.6-1.0.7.php +38 -0
  33. app/design/adminhtml/base/default/layout/transsmart_shipping.xml +2 -2
  34. app/design/adminhtml/base/default/template/transsmart/shipping/location/selector.phtml +4 -2
  35. app/design/adminhtml/base/default/template/transsmart/shipping/sales/order/address/form/container.phtml +29 -15
  36. app/design/adminhtml/base/default/template/transsmart/shipping/sales/order/shipment/address/form/container.phtml +1 -1
  37. app/design/adminhtml/base/default/template/transsmart/shipping/sales/order/shipment/create/detail.phtml +13 -10
  38. app/design/adminhtml/base/default/template/transsmart/shipping/sales/order/shipment/view/detail.phtml +18 -2
  39. app/design/frontend/base/default/template/transsmart/shipping/location/selector.phtml +4 -2
  40. app/design/frontend/base/default/template/transsmart/shipping/onepage/progress/pickup.phtml +1 -2
  41. app/locale/nl_NL/Transsmart_Shipping.csv +8 -1
  42. js/transsmart/shipping/admin/pickup_selector.js +20 -33
  43. js/transsmart/shipping/pickup_selector.js +30 -43
  44. package.xml +5 -5
app/code/community/Transsmart/Shipping/Block/Adminhtml/Sales/Order/Create/Shipping/Method/Form.php ADDED
@@ -0,0 +1,19 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ /**
4
+ * @category Transsmart
5
+ * @package Transsmart_Shipping
6
+ * @copyright Copyright (c) 2016 Techtwo Webdevelopment B.V. (http://www.techtwo.nl)
7
+ */
8
+ class Transsmart_Shipping_Block_Adminhtml_Sales_Order_Create_Shipping_Method_Form
9
+ extends Mage_Adminhtml_Block_Sales_Order_Create_Shipping_Method_Form
10
+ {
11
+ /**
12
+ * @return string
13
+ */
14
+ protected function _toHtml()
15
+ {
16
+ return parent::_toHtml()
17
+ . Mage::helper('transsmart_shipping/location')->getMethodsUpdateHtml($this->getShippingRates());
18
+ }
19
+ }
app/code/community/Transsmart/Shipping/Block/Adminhtml/Sales/Order/Shipment/Create/Detail.php CHANGED
@@ -50,21 +50,14 @@ class Transsmart_Shipping_Block_Adminhtml_Sales_Order_Shipment_Create_Detail ext
50
  }
51
 
52
  /**
53
- * Returns TRUE if the carrierprofile may be changed. This is not allowed when the order has a pickup shipping
54
- * method.
55
  *
56
  * @return bool
57
  */
58
  public function getAllowChangeCarrierprofile()
59
  {
60
- $shipment = Mage::registry('current_shipment');
61
- if ($shipment) {
62
- $shippingMethod = $shipment->getOrder()->getShippingMethod(false);
63
- if (Mage::helper('transsmart_shipping')->isTranssmartPickup($shippingMethod)) {
64
- return false;
65
- }
66
- }
67
- return true;
68
  }
69
 
70
  /**
@@ -74,14 +67,20 @@ class Transsmart_Shipping_Block_Adminhtml_Sales_Order_Shipment_Create_Detail ext
74
  */
75
  public function getAvailableCarrierprofiles()
76
  {
77
- $carrierprofiles = Mage::getResourceSingleton('transsmart_shipping/carrierprofile_collection')->toOptionHash();
78
- foreach ($carrierprofiles as $_id => $_name) {
79
- $_method = Mage::getStoreConfig('transsmart_carrier_profiles/carrierprofile_' . $_id . '/method');
80
- if ($_method == Transsmart_Shipping_Model_Adminhtml_System_Config_Source_Method::PICKUP) {
81
- unset($carrierprofiles[$_id]);
 
 
 
 
 
82
  }
83
  }
84
- return $carrierprofiles;
 
85
  }
86
 
87
  /**
50
  }
51
 
52
  /**
53
+ * Returns TRUE if the carrierprofile may be changed. This is not allowed when the order has a pickup address.
 
54
  *
55
  * @return bool
56
  */
57
  public function getAllowChangeCarrierprofile()
58
  {
59
+ return Mage::helper('transsmart_shipping/shipment')
60
+ ->getAllowChangeCarrierprofile(Mage::registry('current_shipment'));
 
 
 
 
 
 
61
  }
62
 
63
  /**
67
  */
68
  public function getAvailableCarrierprofiles()
69
  {
70
+ $carrierprofiles = Mage::getResourceSingleton('transsmart_shipping/carrierprofile_collection')
71
+ ->joinCarrier()
72
+ ->joinServicelevelTime()
73
+ ->joinServicelevelOther();
74
+
75
+ $res = array();
76
+ /** @var Transsmart_Shipping_Model_Carrierprofile $_carrierprofile */
77
+ foreach ($carrierprofiles as $_carrierprofile) {
78
+ if (!$_carrierprofile->isLocationSelectEnabled()) {
79
+ $res[$_carrierprofile->getData('carrierprofile_id')] = $_carrierprofile->getName();
80
  }
81
  }
82
+
83
+ return $res;
84
  }
85
 
86
  /**
app/code/community/Transsmart/Shipping/Block/Adminhtml/Sales/Order/Shipment/Masscreate/Form.php CHANGED
@@ -123,14 +123,20 @@ class Transsmart_Shipping_Block_Adminhtml_Sales_Order_Shipment_Masscreate_Form e
123
  */
124
  public function getAvailableCarrierprofiles()
125
  {
126
- $carrierprofiles = Mage::getResourceSingleton('transsmart_shipping/carrierprofile_collection')->toOptionHash();
127
- foreach ($carrierprofiles as $_id => $_name) {
128
- $_method = Mage::getStoreConfig('transsmart_carrier_profiles/carrierprofile_' . $_id . '/method');
129
- if ($_method == Transsmart_Shipping_Model_Adminhtml_System_Config_Source_Method::PICKUP) {
130
- unset($carrierprofiles[$_id]);
 
 
 
 
 
131
  }
132
  }
133
- return $carrierprofiles;
 
134
  }
135
 
136
  /**
123
  */
124
  public function getAvailableCarrierprofiles()
125
  {
126
+ $carrierprofiles = Mage::getResourceSingleton('transsmart_shipping/carrierprofile_collection')
127
+ ->joinCarrier()
128
+ ->joinServicelevelTime()
129
+ ->joinServicelevelOther();
130
+
131
+ $res = array();
132
+ /** @var Transsmart_Shipping_Model_Carrierprofile $_carrierprofile */
133
+ foreach ($carrierprofiles as $_carrierprofile) {
134
+ if (!$_carrierprofile->isLocationSelectEnabled()) {
135
+ $res[$_carrierprofile->getData('carrierprofile_id')] = $_carrierprofile->getName();
136
  }
137
  }
138
+
139
+ return $res;
140
  }
141
 
142
  /**
app/code/community/Transsmart/Shipping/Block/Adminhtml/Sales/Order/Shipment/View/Detail.php CHANGED
@@ -56,6 +56,48 @@ class Transsmart_Shipping_Block_Adminhtml_Sales_Order_Shipment_View_Detail exten
56
  }
57
  }
58
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
59
  /**
60
  * Get name of shipment location for current shipment.
61
  *
56
  }
57
  }
58
 
59
+ /**
60
+ * Get name of carrier for current shipment.
61
+ *
62
+ * @return string
63
+ */
64
+ public function getCarrier()
65
+ {
66
+ $carrier = Mage::getResourceSingleton('transsmart_shipping/carrier_collection')
67
+ ->getItemById($this->getShipment()->getTranssmartFinalCarrierId());
68
+ if ($carrier) {
69
+ return $carrier->getName();
70
+ }
71
+ }
72
+
73
+ /**
74
+ * Get name of servicelevel time for current shipment.
75
+ *
76
+ * @return string
77
+ */
78
+ public function getServicelevelTime()
79
+ {
80
+ $servicelevelTime = Mage::getResourceSingleton('transsmart_shipping/servicelevel_time_collection')
81
+ ->getItemById($this->getShipment()->getTranssmartFinalServicelevelTimeId());
82
+ if ($servicelevelTime) {
83
+ return $servicelevelTime->getName();
84
+ }
85
+ }
86
+
87
+ /**
88
+ * Get name of servicelevel other for current shipment.
89
+ *
90
+ * @return string
91
+ */
92
+ public function getServicelevelOther()
93
+ {
94
+ $servicelevelOther = Mage::getResourceSingleton('transsmart_shipping/servicelevel_other_collection')
95
+ ->getItemById($this->getShipment()->getTranssmartFinalServicelevelOtherId());
96
+ if ($servicelevelOther) {
97
+ return $servicelevelOther->getName();
98
+ }
99
+ }
100
+
101
  /**
102
  * Get name of shipment location for current shipment.
103
  *
app/code/community/Transsmart/Shipping/Block/Adminhtml/Sales/Order/View/Detail.php ADDED
@@ -0,0 +1,106 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ /**
4
+ * @category Transsmart
5
+ * @package Transsmart_Shipping
6
+ * @copyright Copyright (c) 2016 Techtwo Webdevelopment B.V. (http://www.techtwo.nl)
7
+ */
8
+ class Transsmart_Shipping_Block_Adminhtml_Sales_Order_View_Detail extends Mage_Adminhtml_Block_Template
9
+ {
10
+ protected $_carrierprofileId;
11
+
12
+ /**
13
+ * Constructor.
14
+ */
15
+ public function _construct()
16
+ {
17
+ $this->setTemplate('transsmart/shipping/sales/order/address/form/container.phtml');
18
+ return parent::_construct();
19
+ }
20
+
21
+ /**
22
+ * Get the default carrier profile ID for the current order.
23
+ *
24
+ * @return int
25
+ */
26
+ public function getCarrierprofileId()
27
+ {
28
+ if (empty($this->_carrierprofileId)) {
29
+ $order = Mage::registry('current_order');
30
+
31
+ if (($shippingAddress = $order->getShippingAddress())) {
32
+ /** @see Transsmart_Shipping_Model_Sales_Quote_Address_Total_Shipping::collect */
33
+ $this->_carrierprofileId = $shippingAddress->getTranssmartCarrierprofileId();
34
+ }
35
+
36
+ if (empty($this->_carrierprofileId)) {
37
+ // carrierprofile based on shipping method
38
+ $shippingMethod = $order->getShippingMethod(false);
39
+ $carrierprofile = Mage::getModel('transsmart_shipping/carrierprofile')
40
+ ->loadByShippingMethodCode($shippingMethod);
41
+ $this->_carrierprofileId = $carrierprofile->getId();
42
+ }
43
+
44
+ if (!$this->_carrierprofileId) {
45
+ // default configured carrierprofile for storeview
46
+ $this->_carrierprofileId = Mage::getStoreConfig(
47
+ Transsmart_Shipping_Helper_Shipment::XML_PATH_DEFAULT_CARRIERPROFILE,
48
+ $order->getStore()
49
+ );
50
+ }
51
+ }
52
+ return $this->_carrierprofileId;
53
+ }
54
+
55
+ /**
56
+ * Get the default carrier profile for the current order.
57
+ *
58
+ * @return string
59
+ */
60
+ public function getCarrierprofile()
61
+ {
62
+ $carrierprofile = Mage::getResourceSingleton('transsmart_shipping/carrierprofile_collection')
63
+ ->joinCarrier()
64
+ ->joinServicelevelTime()
65
+ ->joinServicelevelOther()
66
+ ->getItemById($this->getCarrierprofileId());
67
+ if ($carrierprofile) {
68
+ return $carrierprofile->getName();
69
+ }
70
+ }
71
+
72
+ /**
73
+ * Retrieves the pickup address from the order.
74
+ *
75
+ * @return Mage_Sales_Model_Order_Address|null Returns the pickup address, otherwise null
76
+ */
77
+ public function getPickupAddress()
78
+ {
79
+ $order = Mage::registry('current_order');
80
+ return Mage::helper('transsmart_shipping/pickupaddress')->getPickupAddressFromOrder($order);
81
+ }
82
+
83
+ /**
84
+ * Return flag indicating whether it is allowed to change the pickup address.
85
+ *
86
+ * @return bool
87
+ */
88
+ public function allowChangePickupAddress()
89
+ {
90
+ return false;
91
+ }
92
+
93
+ /**
94
+ * Prepare html output
95
+ *
96
+ * @return string
97
+ */
98
+ protected function _toHtml()
99
+ {
100
+ if (!Mage::helper('transsmart_shipping')->isTranssmartOrder(Mage::registry('current_order'))) {
101
+ return '';
102
+ }
103
+
104
+ return parent::_toHtml();
105
+ }
106
+ }
app/code/community/Transsmart/Shipping/Block/Adminhtml/Sales/Order/View/Tab/Shipments.php CHANGED
@@ -9,14 +9,13 @@ class Transsmart_Shipping_Block_Adminhtml_Sales_Order_View_Tab_Shipments
9
  extends Mage_Adminhtml_Block_Sales_Order_View_Tab_Shipments
10
  {
11
  /**
12
- * Returns TRUE if the order uses a Transsmart shipping method.
13
  *
14
  * @return bool
15
  */
16
- public function usesTranssmartShippingMethod()
17
  {
18
- $shippingMethod = $this->getOrder()->getShippingMethod();
19
- return Mage::helper('transsmart_shipping')->isTranssmartShippingMethod($shippingMethod);
20
  }
21
 
22
  /**
@@ -27,7 +26,7 @@ class Transsmart_Shipping_Block_Adminhtml_Sales_Order_View_Tab_Shipments
27
  public function setCollection($collection)
28
  {
29
  if ($collection instanceof Mage_Sales_Model_Resource_Order_Shipment_Grid_Collection) {
30
- if ($this->usesTranssmartShippingMethod()) {
31
  $collection
32
  ->addFieldToSelect('transsmart_document_id')
33
  ->addFieldToSelect('transsmart_status')
@@ -44,7 +43,7 @@ class Transsmart_Shipping_Block_Adminhtml_Sales_Order_View_Tab_Shipments
44
  */
45
  protected function _prepareColumns()
46
  {
47
- if ($this->usesTranssmartShippingMethod()) {
48
  $this->addColumnAfter('transsmart_document_id', array(
49
  'header' => Mage::helper('sales')->__('Transsmart Document Id'),
50
  'index' => 'transsmart_document_id',
9
  extends Mage_Adminhtml_Block_Sales_Order_View_Tab_Shipments
10
  {
11
  /**
12
+ * Returns TRUE if the order is a Transsmart order.
13
  *
14
  * @return bool
15
  */
16
+ public function isTranssmartOrder()
17
  {
18
+ return Mage::helper('transsmart_shipping')->isTranssmartOrder($this->getOrder());
 
19
  }
20
 
21
  /**
26
  public function setCollection($collection)
27
  {
28
  if ($collection instanceof Mage_Sales_Model_Resource_Order_Shipment_Grid_Collection) {
29
+ if ($this->isTranssmartOrder()) {
30
  $collection
31
  ->addFieldToSelect('transsmart_document_id')
32
  ->addFieldToSelect('transsmart_status')
43
  */
44
  protected function _prepareColumns()
45
  {
46
+ if ($this->isTranssmartOrder()) {
47
  $this->addColumnAfter('transsmart_document_id', array(
48
  'header' => Mage::helper('sales')->__('Transsmart Document Id'),
49
  'index' => 'transsmart_document_id',
app/code/community/Transsmart/Shipping/Block/Adminhtml/Shipping/Carrier/Tablerate/Grid.php ADDED
@@ -0,0 +1,34 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ /**
4
+ * @category Transsmart
5
+ * @package Transsmart_Shipping
6
+ * @copyright Copyright (c) 2016 Techtwo Webdevelopment B.V. (http://www.techtwo.nl)
7
+ */
8
+ class Transsmart_Shipping_Block_Adminhtml_Shipping_Carrier_Tablerate_Grid
9
+ extends Mage_Adminhtml_Block_Shipping_Carrier_Tablerate_Grid
10
+ {
11
+ /**
12
+ * Constructor.
13
+ */
14
+ public function __construct()
15
+ {
16
+ $this->setModuleName('Mage_Adminhtml');
17
+ parent::__construct();
18
+ }
19
+
20
+ /**
21
+ * Prepare table columns
22
+ *
23
+ * @return Mage_Adminhtml_Block_Widget_Grid
24
+ */
25
+ protected function _prepareColumns()
26
+ {
27
+ $this->addColumnAfter('transsmart_carrierprofile_id', array(
28
+ 'header' => Mage::helper('transsmart_shipping')->__('Transsmart Carrier Profile Id'),
29
+ 'index' => 'transsmart_carrierprofile_id'
30
+ ), 'price');
31
+
32
+ return parent::_prepareColumns();
33
+ }
34
+ }
app/code/community/Transsmart/Shipping/Block/Adminhtml/System/Config/Form/Field/Locationselect.php ADDED
@@ -0,0 +1,32 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ /**
4
+ * @category Transsmart
5
+ * @package Transsmart_Shipping
6
+ * @copyright Copyright (c) 2016 Techtwo Webdevelopment B.V. (http://www.techtwo.nl)
7
+ */
8
+ class Transsmart_Shipping_Block_Adminhtml_System_Config_Form_Field_Locationselect
9
+ extends Mage_Adminhtml_Block_System_Config_Form_Field
10
+ {
11
+ /**
12
+ * @param Varien_Data_Form_Element_Abstract $element
13
+ * @return string
14
+ */
15
+ protected function _getElementHtml(Varien_Data_Form_Element_Abstract $element)
16
+ {
17
+ $originalData = $element->getContainer()->getOriginalData();
18
+
19
+ $value = $originalData['enable_location_select'];
20
+ if (is_null($value) || $value === '') {
21
+ $label = 'Unknown';
22
+ }
23
+ elseif ($value) {
24
+ $label = 'Enabled';
25
+ }
26
+ else {
27
+ $label = 'Disabled';
28
+ }
29
+
30
+ return '<b>' . $this->escapeHtml(Mage::helper('adminhtml')->__($label)) . '</b>';
31
+ }
32
+ }
app/code/community/Transsmart/Shipping/Block/Checkout/Onepage/Shipping/Method/Available.php ADDED
@@ -0,0 +1,19 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ /**
4
+ * @category Transsmart
5
+ * @package Transsmart_Shipping
6
+ * @copyright Copyright (c) 2016 Techtwo Webdevelopment B.V. (http://www.techtwo.nl)
7
+ */
8
+ class Transsmart_Shipping_Block_Checkout_Onepage_Shipping_Method_Available
9
+ extends Mage_Checkout_Block_Onepage_Shipping_Method_Available
10
+ {
11
+ /**
12
+ * @return string
13
+ */
14
+ protected function _toHtml()
15
+ {
16
+ return parent::_toHtml()
17
+ . Mage::helper('transsmart_shipping/location')->getMethodsUpdateHtml($this->getShippingRates());
18
+ }
19
+ }
app/code/community/Transsmart/Shipping/Helper/Data.php CHANGED
@@ -25,11 +25,11 @@ class Transsmart_Shipping_Helper_Data extends Mage_Core_Helper_Abstract
25
  */
26
  protected $_apiClient;
27
 
28
- /**
29
- * A list of carrier profiles that can use the location selector
30
  * @var array
31
  */
32
- protected $_locationSelectCarrierProfiles = array();
33
 
34
  /**
35
  * Get the Transsmart API client, and initialize it with the configured authentication details. The same instance
@@ -114,69 +114,121 @@ class Transsmart_Shipping_Helper_Data extends Mage_Core_Helper_Abstract
114
  return preg_match('/^transsmartpickup_carrierprofile_([0-9]+)$/', $shippingMethod) === 1;
115
  }
116
 
117
-
118
  /**
119
- * Retrieves carrier profiles that can have the location selector
120
- * @todo This could return (old) carrier profiles, deleted from the database, but still present in the config table.
121
- * @todo Refactor to Transsmart_Shipping_Model_Resource_Carrierprofile_Collection::addLocationSelectEnabledFilter
122
- * @param Mage_Core_Model_Store|int $store
123
- * @return array
124
  */
125
- public function getLocationSelectCarrierProfiles($store = null)
126
  {
127
- if ($store == null) {
128
- $store = Mage::app()->getStore();
129
- }
 
 
 
 
130
 
131
- // We were provided a store ID
132
- if (is_numeric($store)) {
133
- $store = Mage::app()->getStore($store);
 
134
  }
135
 
136
- if (!isset($this->_locationSelectCarrierProfiles[$store->getId()])) {
 
137
 
138
- $carrierProfiles = Mage::getModel('core/config_data')
139
- ->getCollection()
140
- ->addFieldToFilter('path', array('like' => 'transsmart_carrier_profiles/carrierprofile_%/method'))
141
- ->addFieldToFilter('value', 'transsmartpickup')
142
- ->addFieldToFilter('scope_id', array('in' => array(0, $store->getId())))
143
- ->addOrder('scope')
144
- ->load();
 
 
 
 
145
 
146
- $pickupCarrierProfileConfigs = array();
147
- $carrierProfileIds = array();
148
 
149
- if ($carrierProfiles->count() > 0) {
150
- foreach ($carrierProfiles as $carrierProfile) {
151
- preg_match('#transsmart_carrier_profiles/carrierprofile_([0-9]+)/#', $carrierProfile->getPath(), $matches);
 
 
 
 
 
 
 
 
152
 
153
- if (count($matches) == 2) {
154
- $pickupCarrierProfileConfigs [] = 'transsmart_carrier_profiles/carrierprofile_' . $matches[1] . '/location_select';
155
- }
 
 
 
 
156
  }
 
 
157
 
158
- $locationSelectProfiles = Mage::getModel('core/config_data')
159
- ->getCollection()
160
- ->addFieldToFilter('path', array('in' => $pickupCarrierProfileConfigs))
161
- ->addFieldToFilter('value', 1)
162
- ->addFieldToFilter('scope_id', array('in' => array(0, $store->getId())))
163
- ->addOrder('scope')
164
- ->load();
165
 
166
- foreach ($locationSelectProfiles as $locationSelectProfile) {
167
- preg_match('#transsmart_carrier_profiles/carrierprofile_([0-9]+)/#', $locationSelectProfile->getPath(), $matches);
 
 
 
 
 
 
 
 
 
 
 
 
 
168
 
169
- if (count($matches) == 2) {
170
- $carrierProfileIds [] = $matches[1];
171
- }
172
- }
 
173
  }
 
174
 
 
 
175
 
176
- $this->_locationSelectCarrierProfiles[$store->getId()] = $carrierProfileIds;
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
177
  }
178
 
179
- return $this->_locationSelectCarrierProfiles[$store->getId()];
180
  }
181
 
182
  /**
25
  */
26
  protected $_apiClient;
27
 
28
+ /**|
29
+ * A list of carrier profile ID's that can use the location selector
30
  * @var array
31
  */
32
+ protected $_locationSelectCarrierProfiles;
33
 
34
  /**
35
  * Get the Transsmart API client, and initialize it with the configured authentication details. The same instance
114
  return preg_match('/^transsmartpickup_carrierprofile_([0-9]+)$/', $shippingMethod) === 1;
115
  }
116
 
 
117
  /**
118
+ * Checks the shipping method of the given quote to see if it's a Transsmart shipping method. Also checks if the
119
+ * quote address has a Transsmart carrier profile.
120
+ *
121
+ * @param Mage_Sales_Model_Quote $quote
122
+ * @return bool
123
  */
124
+ public function isTranssmartQuote($quote)
125
  {
126
+ $shippingAddress = $quote->getShippingAddress();
127
+ if ($shippingAddress) {
128
+ // check shipping method
129
+ $shippingMethod = $shippingAddress->getShippingMethod();
130
+ if (Mage::helper('transsmart_shipping')->isTranssmartShippingMethod($shippingMethod)) {
131
+ return true;
132
+ }
133
 
134
+ // check shipping address carrier profile
135
+ if ($shippingAddress->getTranssmartCarrierprofileId()) {
136
+ return true;
137
+ }
138
  }
139
 
140
+ return false;
141
+ }
142
 
143
+ /**
144
+ * Check the shipping address for the given quote to see if the location selector is enabled (and thus, a pickup
145
+ * address is required).
146
+ *
147
+ * @param Mage_Sales_Model_Quote $quote
148
+ * @param bool $totalsCollected False if $quote->collectTotals() still needs to be called
149
+ * @return bool
150
+ */
151
+ public function isLocationSelectQuote($quote, $totalsCollected = true)
152
+ {
153
+ $enableLocationSelect = false;
154
 
155
+ if (($shippingAddress = $quote->getShippingAddress())) {
 
156
 
157
+ $carrierprofileId = null;
158
+ if ($totalsCollected || $quote->getTotalsCollectedFlag()) {
159
+ /** @see Transsmart_Shipping_Model_Sales_Quote_Address_Total_Shipping::collect */
160
+ $carrierprofileId = $shippingAddress->getTranssmartCarrierprofileId();
161
+ }
162
+ else {
163
+ // we can't rely on the shipping address 'transsmart_carrierprofile_id' yet, so use the shipping rate
164
+ if (($rate = $shippingAddress->getShippingRateByCode($shippingAddress->getShippingMethod()))) {
165
+ $carrierprofileId = $rate->getTranssmartCarrierprofileId();
166
+ }
167
+ }
168
 
169
+ if ($carrierprofileId) {
170
+ /** @var Transsmart_Shipping_Model_Carrierprofile $carrierprofile */
171
+ $carrierprofile = Mage::getResourceSingleton('transsmart_shipping/carrierprofile_collection')
172
+ ->joinCarrier()
173
+ ->getItemById($carrierprofileId);
174
+ if ($carrierprofile) {
175
+ $enableLocationSelect = (bool)$carrierprofile->isLocationSelectEnabled();
176
  }
177
+ }
178
+ }
179
 
180
+ return $enableLocationSelect;
181
+ }
 
 
 
 
 
182
 
183
+ /**
184
+ * Checks the shipping method of the given order to see if it's a Transsmart shipping method. Also checks if the
185
+ * order address has a Transsmart carrier profile.
186
+ * If this logic changes, also update Transsmart_Shipping_Model_Sales_Resource_Order::joinVirtualGridColumnsToSelect
187
+ *
188
+ * @param Mage_Sales_Model_Order $order
189
+ * @return bool
190
+ */
191
+ public function isTranssmartOrder($order)
192
+ {
193
+ // check shipping method
194
+ $shippingMethod = $order->getShippingMethod();
195
+ if (Mage::helper('transsmart_shipping')->isTranssmartShippingMethod($shippingMethod)) {
196
+ return true;
197
+ }
198
 
199
+ // check shipping address carrier profile
200
+ $shippingAddress = $order->getShippingAddress();
201
+ if ($shippingAddress) {
202
+ if ($shippingAddress->getTranssmartCarrierprofileId()) {
203
+ return true;
204
  }
205
+ }
206
 
207
+ return false;
208
+ }
209
 
210
+ /**
211
+ * Retrieves IDs of carrier profiles that use the location selector.
212
+ *
213
+ * @deprecated
214
+ * @param Mage_Core_Model_Store|int $store
215
+ * @return array
216
+ */
217
+ public function getLocationSelectCarrierProfiles($store = null)
218
+ {
219
+ if (is_null($this->_locationSelectCarrierProfiles)) {
220
+ $this->_locationSelectCarrierProfiles = array();
221
+
222
+ $carrierProfiles = Mage::getResourceSingleton('transsmart_shipping/carrierprofile_collection')
223
+ ->joinCarrier();
224
+ foreach ($carrierProfiles as $_carrierProfile) {
225
+ if ($_carrierProfile->isLocationSelectEnabled()) {
226
+ $this->_locationSelectCarrierProfiles[] = $_carrierProfile->getId();
227
+ }
228
+ }
229
  }
230
 
231
+ return $this->_locationSelectCarrierProfiles;
232
  }
233
 
234
  /**
app/code/community/Transsmart/Shipping/Helper/Location.php CHANGED
@@ -7,6 +7,46 @@
7
  */
8
  class Transsmart_Shipping_Helper_Location extends Mage_Core_Helper_Abstract
9
  {
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
10
  /**
11
  * Retrieve geo location from the provided details
12
  * @param $zipcode
@@ -124,6 +164,7 @@ class Transsmart_Shipping_Helper_Location extends Mage_Core_Helper_Abstract
124
  // fetch carrier parameters
125
  $carrier = $request->getParam('carrier');
126
  $shippingMethod = $request->getParam('shipping_method');
 
127
  $search = $request->getParam('search');
128
 
129
  if (strlen(trim($search)) > 0) {
@@ -135,7 +176,18 @@ class Transsmart_Shipping_Helper_Location extends Mage_Core_Helper_Abstract
135
  $housenr = isset($searchParts[3]) ? $searchParts[3] : $housenr;
136
  }
137
 
138
- if (empty($carrier) && !empty($shippingMethod)) {
 
 
 
 
 
 
 
 
 
 
 
139
  /** @var Transsmart_Shipping_Model_Carrierprofile $carrierprofile */
140
  $carrierprofile = Mage::getModel('transsmart_shipping/carrierprofile')
141
  ->loadByShippingMethodCode($shippingMethod);
7
  */
8
  class Transsmart_Shipping_Helper_Location extends Mage_Core_Helper_Abstract
9
  {
10
+ /**
11
+ * Return html snippet with a script which sends the shipping method data to the location selector object.
12
+ *
13
+ * @param array $shippingRates
14
+ * @return string
15
+ */
16
+ public function getMethodsUpdateHtml($shippingRates)
17
+ {
18
+ // collect shipping method data
19
+ $methods = array();
20
+ foreach ($shippingRates as $code => $_rates) {
21
+ /** @var Transsmart_Shipping_Model_Sales_Quote_Address_Rate $_rate */
22
+ foreach ($_rates as $_rate) {
23
+ $carrierprofileId = $_rate->getTranssmartCarrierprofileId();
24
+ if ($carrierprofileId) {
25
+ /** @var Transsmart_Shipping_Model_Carrierprofile $carrierprofile */
26
+ $carrierprofile = Mage::getResourceSingleton('transsmart_shipping/carrierprofile_collection')
27
+ ->joinCarrier()
28
+ ->getItemById($carrierprofileId);
29
+ if ($carrierprofile) {
30
+ if ($carrierprofile->isLocationSelectEnabled()) {
31
+ $methods[$_rate->getCode()] = $carrierprofileId;
32
+ }
33
+ }
34
+ }
35
+ }
36
+ }
37
+
38
+ $html = "<script type=\"text/javascript\">\n"
39
+ . "//<![CDATA[\n"
40
+ . "transsmartShippingPickupMethods = " . Zend_Json_Encoder::encode($methods) . ";\n"
41
+ . "if (typeof transsmartShippingPickup != 'undefined') {\n"
42
+ . " transsmartShippingPickup.setMethods(transsmartShippingPickupMethods);\n"
43
+ . "}\n"
44
+ . "//]]>\n"
45
+ . "</script>";
46
+
47
+ return $html;
48
+ }
49
+
50
  /**
51
  * Retrieve geo location from the provided details
52
  * @param $zipcode
164
  // fetch carrier parameters
165
  $carrier = $request->getParam('carrier');
166
  $shippingMethod = $request->getParam('shipping_method');
167
+ $carrierprofile = $request->getParam('carrierprofile');
168
  $search = $request->getParam('search');
169
 
170
  if (strlen(trim($search)) > 0) {
176
  $housenr = isset($searchParts[3]) ? $searchParts[3] : $housenr;
177
  }
178
 
179
+ if (!empty($carrierprofile)) {
180
+ /** @var Transsmart_Shipping_Model_Carrierprofile $carrierprofile */
181
+ $carrierprofile = Mage::getModel('transsmart_shipping/carrierprofile')
182
+ ->load($carrierprofile);
183
+
184
+ if (!$carrierprofile->isLocationSelectEnabled()) {
185
+ Mage::throwException($this->__('Location selector not available for this carrier profile.'));
186
+ }
187
+
188
+ $carrier = $carrierprofile->getCarrierCode();
189
+ }
190
+ elseif (empty($carrier) && !empty($shippingMethod)) {
191
  /** @var Transsmart_Shipping_Model_Carrierprofile $carrierprofile */
192
  $carrierprofile = Mage::getModel('transsmart_shipping/carrierprofile')
193
  ->loadByShippingMethodCode($shippingMethod);
app/code/community/Transsmart/Shipping/Helper/Shipment.php CHANGED
@@ -1,781 +1,813 @@
1
- <?php
2
-
3
- /**
4
- * @category Transsmart
5
- * @package Transsmart_Shipping
6
- * @copyright Copyright (c) 2016 Techtwo Webdevelopment B.V. (http://www.techtwo.nl)
7
- */
8
- class Transsmart_Shipping_Helper_Shipment extends Mage_Core_Helper_Abstract
9
- {
10
- const XML_PATH_DEFAULT_CARRIERPROFILE = 'transsmart_shipping/default_shipment/carrierprofile';
11
- const XML_PATH_DEFAULT_SHIPMENTLOCATION = 'transsmart_shipping/default_shipment/shipmentlocation';
12
- const XML_PATH_DEFAULT_EMAILTYPE = 'transsmart_shipping/default_shipment/emailtype';
13
- const XML_PATH_DEFAULT_INCOTERM = 'transsmart_shipping/default_shipment/incoterm';
14
- const XML_PATH_DEFAULT_COSTCENTER = 'transsmart_shipping/default_shipment/costcenter';
15
- const XML_PATH_DEFAULT_PACKAGETYPE = 'transsmart_shipping/default_shipment/packagetype';
16
-
17
- const XML_PATH_MAPPING_STREET = 'transsmart_shipping/mapping/street';
18
- const XML_PATH_MAPPING_STREETNO = 'transsmart_shipping/mapping/streetno';
19
- const XML_PATH_MAPPING_STREET2 = 'transsmart_shipping/mapping/street2';
20
- const XML_PATH_MAPPING_COUNTRY_OF_ORIGIN = 'transsmart_shipping/mapping/country_of_origin';
21
- const XML_PATH_MAPPING_HS_CODE = 'transsmart_shipping/mapping/hs_code';
22
- const XML_PATH_MAPPING_REASON_OF_EXPORT = 'transsmart_shipping/mapping/reason_of_export';
23
-
24
- // OR'ed values for the 'transsmart_flags' field in the shipment table
25
- const FLAG_BOOK_ON_CREATE = 1;
26
- const FLAG_BOOKANDPRINT_ON_CREATE = 2;
27
-
28
- /**
29
- * Get all possible Transsmart shipment statuses.
30
- *
31
- * @return array
32
- */
33
- public function getShipmentStatuses()
34
- {
35
- return array(
36
- 'NONE' => $this->__('NONE'),
37
- 'NEW' => $this->__('NEW'),
38
- 'BOOK' => $this->__('BOOK'),
39
- 'LABL' => $this->__('LABL'),
40
- 'MANI' => $this->__('MANI'),
41
- 'ACCEP' => $this->__('ACCEP'),
42
- 'TRNS' => $this->__('TRNS'),
43
- 'DONE' => $this->__('DONE'),
44
- 'APOD' => $this->__('APOD'),
45
- 'REFU' => $this->__('REFU'),
46
- 'ERR' => $this->__('ERR'),
47
- 'DEL' => $this->__('DEL'),
48
- 'ONHOLD' => $this->__('ONHOLD'),
49
- );
50
- }
51
-
52
- /**
53
- * Get configured default carrierprofile for the given shipment or store.
54
- *
55
- * @param Mage_Sales_Model_Order_Shipment|null $shipment
56
- * @param null $store
57
- * @return int
58
- */
59
- public function getDefaultCarrierprofileId($shipment = null, $store = null)
60
- {
61
- $defaultValue = false;
62
- if ($shipment instanceof Mage_Sales_Model_Order_Shipment) {
63
- $shippingMethod = $shipment->getOrder()->getShippingMethod(false);
64
- $carrierprofile = Mage::getModel('transsmart_shipping/carrierprofile')
65
- ->loadByShippingMethodCode($shippingMethod);
66
- $defaultValue = $carrierprofile->getId();
67
- if (!$defaultValue) {
68
- $defaultValue = Mage::getStoreConfig(self::XML_PATH_DEFAULT_CARRIERPROFILE, $shipment->getStore());
69
- }
70
- }
71
- if (!$defaultValue) {
72
- $defaultValue = Mage::getStoreConfig(self::XML_PATH_DEFAULT_CARRIERPROFILE, $store);
73
- }
74
- return $defaultValue;
75
- }
76
-
77
- /**
78
- * Get configured default shipmentlocation for the given store.
79
- *
80
- * @param null $store
81
- * @return int
82
- */
83
- public function getDefaultShipmentlocationId($store = null)
84
- {
85
- $defaultValue = Mage::getStoreConfig(self::XML_PATH_DEFAULT_SHIPMENTLOCATION, $store);
86
- if (!$defaultValue) {
87
- $ids = Mage::getResourceModel('transsmart_shipping/shipmentlocation_collection')
88
- ->addFieldToFilter('is_default', array('eq' => 1))
89
- ->setPageSize(1)
90
- ->getAllIds();
91
- if (count($ids)) {
92
- $defaultValue = $ids[0];
93
- }
94
- }
95
- return $defaultValue;
96
- }
97
-
98
- /**
99
- * Get configured default emailtype for the given store.
100
- *
101
- * @param null $store
102
- * @return int
103
- */
104
- public function getDefaultEmailtypeId($store = null)
105
- {
106
- $defaultValue = Mage::getStoreConfig(self::XML_PATH_DEFAULT_EMAILTYPE, $store);
107
- if (!$defaultValue) {
108
- $ids = Mage::getResourceModel('transsmart_shipping/emailtype_collection')
109
- ->addFieldToFilter('is_default', array('eq' => 1))
110
- ->setPageSize(1)
111
- ->getAllIds();
112
- if (count($ids)) {
113
- $defaultValue = $ids[0];
114
- }
115
- }
116
- return $defaultValue;
117
- }
118
-
119
- /**
120
- * Get configured default incoterm for the given store.
121
- *
122
- * @param null $store
123
- * @return int
124
- */
125
- public function getDefaultIncotermId($store = null)
126
- {
127
- $defaultValue = Mage::getStoreConfig(self::XML_PATH_DEFAULT_INCOTERM, $store);
128
- if (!$defaultValue) {
129
- $ids = Mage::getResourceModel('transsmart_shipping/incoterm_collection')
130
- ->addFieldToFilter('is_default', array('eq' => 1))
131
- ->setPageSize(1)
132
- ->getAllIds();
133
- if (count($ids)) {
134
- $defaultValue = $ids[0];
135
- }
136
- }
137
- return $defaultValue;
138
- }
139
-
140
- /**
141
- * Get configured default costcenter for the given store.
142
- *
143
- * @param null $store
144
- * @return int
145
- */
146
- public function getDefaultCostcenterId($store = null)
147
- {
148
- $defaultValue = Mage::getStoreConfig(self::XML_PATH_DEFAULT_COSTCENTER, $store);
149
- if (!$defaultValue) {
150
- $ids = Mage::getResourceModel('transsmart_shipping/costcenter_collection')
151
- ->addFieldToFilter('is_default', array('eq' => 1))
152
- ->setPageSize(1)
153
- ->getAllIds();
154
- if (count($ids)) {
155
- $defaultValue = $ids[0];
156
- }
157
- }
158
- return $defaultValue;
159
- }
160
-
161
- /**
162
- * Get configured default packagetype for the given store.
163
- *
164
- * @param null $store
165
- * @return int
166
- */
167
- public function getDefaultPackagetypeId($store = null)
168
- {
169
- $defaultValue = Mage::getStoreConfig(self::XML_PATH_DEFAULT_PACKAGETYPE, $store);
170
- if (!$defaultValue) {
171
- $ids = Mage::getResourceModel('transsmart_shipping/packagetype_collection')
172
- ->addFieldToFilter('is_default', array('eq' => 1))
173
- ->setPageSize(1)
174
- ->getAllIds();
175
- if (count($ids)) {
176
- $defaultValue = $ids[0];
177
- }
178
- }
179
- return $defaultValue;
180
- }
181
-
182
- /**
183
- * Get the street and housenumber from the given address. If there's only one street field, try to split it into
184
- * separate fields.
185
- *
186
- * @param Mage_Sales_Model_Order_Address $address
187
- * @param mixed $store
188
- * @return array
189
- */
190
- protected function _getStreetFields($address, $store = null)
191
- {
192
- if ($address->hasTranssmartServicepointId()) {
193
- // for addresses from the location selector, always use predetermined fields
194
- $street = $address->getStreet(1);
195
- $streetNo = $address->getStreet(2);
196
- $street2 = $address->getStreet(3);
197
- }
198
- else {
199
- // read config settings for street fields mapping
200
- $mappingStreet = Mage::getStoreConfig(self::XML_PATH_MAPPING_STREET, $store);
201
- $mappingStreetNo = Mage::getStoreConfig(self::XML_PATH_MAPPING_STREETNO, $store);
202
- $mappingStreet2 = Mage::getStoreConfig(self::XML_PATH_MAPPING_STREET2, $store);
203
-
204
- // get street value
205
- switch ($mappingStreet) {
206
- case Transsmart_Shipping_Model_Adminhtml_System_Config_Source_Mapping_Street::NONE:
207
- $street = '';
208
- break;
209
- case Transsmart_Shipping_Model_Adminhtml_System_Config_Source_Mapping_Street::FULL:
210
- $street = trim(implode(' ', $address->getStreet()));
211
- break;
212
- default:
213
- $street = $address->getStreet($mappingStreet);
214
- }
215
-
216
- // get streetno value
217
- switch ($mappingStreetNo) {
218
- case Transsmart_Shipping_Model_Adminhtml_System_Config_Source_Mapping_Street::NONE:
219
- $streetNo = '';
220
- break;
221
- case Transsmart_Shipping_Model_Adminhtml_System_Config_Source_Mapping_Street::FULL:
222
- $streetNo = trim(implode(' ', $address->getStreet()));
223
- break;
224
- default:
225
- $streetNo = $address->getStreet($mappingStreetNo);
226
- }
227
-
228
- // get street2 value
229
- switch ($mappingStreet2) {
230
- case Transsmart_Shipping_Model_Adminhtml_System_Config_Source_Mapping_Street::NONE:
231
- $street2 = '';
232
- break;
233
- case Transsmart_Shipping_Model_Adminhtml_System_Config_Source_Mapping_Street::FULL:
234
- $street2 = trim(implode(' ', $address->getStreet()));
235
- break;
236
- default:
237
- $street2 = $address->getStreet($mappingStreet2);
238
- }
239
-
240
- // automatic house number detection
241
- if ($mappingStreet == $mappingStreetNo) {
242
- $streetNo = '';
243
-
244
- if (preg_match('/^(.*) ([0-9]+ .*)$/', $street, $matches)) {
245
- $street = $matches[1];
246
- $streetNo = $matches[2];
247
- }
248
- elseif (preg_match('/^(.*) ([0-9]+.*)$/', $street, $matches)) {
249
- $street = $matches[1];
250
- $streetNo = $matches[2];
251
- }
252
- elseif (preg_match('/^(.*) ([0-9]+.*)$/', $street, $matches)) {
253
- $street = $matches[1];
254
- $streetNo = $matches[2];
255
- }
256
- }
257
- }
258
-
259
- // house number cannot be empty
260
- if ($streetNo === '') {
261
- $streetNo = '.';
262
- }
263
-
264
- return array($street, $streetNo, $street2);
265
- }
266
-
267
- /**
268
- * Export the given shipment to the Transsmart API.
269
- *
270
- * @param Mage_Sales_Model_Order_Shipment $shipment
271
- * @param bool $allowPrint
272
- */
273
- public function doExport($shipment, $allowPrint = true)
274
- {
275
- // is it already exported?
276
- if ($shipment->getTranssmartDocumentId()) {
277
- return;
278
- }
279
-
280
- /** @var Transsmart_Shipping_Model_Carrierprofile $carrierprofile */
281
- $carrierprofile = Mage::getModel('transsmart_shipping/carrierprofile')
282
- ->load($shipment->getTranssmartCarrierprofileId());
283
- if (!$carrierprofile->getId()) {
284
- return;
285
- }
286
-
287
- $store = $shipment->getStore();
288
- $address = $shipment->getShippingAddress();
289
- $invoiceAddress = $shipment->getBillingAddress();
290
-
291
- // check if the order has a pickup address (location selector is used)
292
- $pickupAddress = Mage::helper('transsmart_shipping/pickupaddress')
293
- ->getPickupAddressFromOrder($shipment->getOrder());
294
- $servicePointId = null;
295
- if ($pickupAddress) {
296
- $address = $pickupAddress;
297
- $invoiceAddress = $shipment->getShippingAddress();
298
- $servicePointId = $pickupAddress->getTranssmartServicepointId();
299
- }
300
-
301
- // determine address name and contact
302
- $addressName = $address->getCompany();
303
- $addressContact = $address->getName();
304
- if ($addressName == '') {
305
- $addressName = $addressContact;
306
- }
307
-
308
- // determine invoice address name and contact
309
- $invoiceAddressName = $invoiceAddress->getCompany();
310
- $invoiceAddressContact = $invoiceAddress->getName();
311
- if ($invoiceAddressName == '') {
312
- $invoiceAddressName = $invoiceAddressContact;
313
- }
314
-
315
- // split street fields into street and house number
316
- list($addressStreet, $addressStreetNo, $addressStreet2) =
317
- $this->_getStreetFields($address, $store);
318
- list($invoiceAddressStreet, $invoiceAddressStreetNo, $invoiceAddressStreet2) =
319
- $this->_getStreetFields($invoiceAddress, $store);
320
-
321
- /** @var Mage_Core_Helper_String $stringHelper */
322
- $stringHelper = Mage::helper('core/string');
323
-
324
- // calculate shipment value and prepare delivery note lines
325
- $shipmentValue = 0.0;
326
- $deliveryNoteInfoLines = array();
327
- /** @var Mage_Sales_Model_Order_Shipment_Item $_item */
328
- foreach ($shipment->getAllItems() as $_item) {
329
- if ($_item->getOrderItem()->getParentItem()) {
330
- continue;
331
- }
332
-
333
- $shipmentValue += $_item->getPrice() * $_item->getQty();
334
-
335
- $_line = array(
336
- 'ArticleId' => $_item->getSku(),
337
- 'ArticleName' => $stringHelper->substr($_item->getName(), 0, 45),
338
- 'Description' => $stringHelper->substr($_item->getDescription(), 0, 510),
339
- 'Price' => $_item->getPrice(),
340
- 'Currency' => $store->getCurrentCurrencyCode(),
341
- 'Quantity' => $_item->getQty(),
342
- 'QuantityBackorder' => floatval($_item->getOrderItem()->getQtyBackordered()),
343
- 'QuantityOrder' => $_item->getOrderItem()->getQtyOrdered(),
344
- 'CountryOfOrigin' => Mage::getStoreConfig('shipping/origin/country_id', $store),
345
- 'ReasonOfExport' => 'Sale',
346
- );
347
-
348
- $_additionalFields = array(
349
- 'Description' => 'description',
350
- 'CountryOfOrigin' => Mage::getStoreConfig(self::XML_PATH_MAPPING_COUNTRY_OF_ORIGIN, $store),
351
- 'HSCode' => Mage::getStoreConfig(self::XML_PATH_MAPPING_HS_CODE, $store),
352
- 'ReasonOfExport' => Mage::getStoreConfig(self::XML_PATH_MAPPING_REASON_OF_EXPORT, $store),
353
- );
354
- $_product = $_item->getOrderItem()->getProduct();
355
- foreach ($_additionalFields as $_field => $_attributeCode) {
356
- if (empty($_attributeCode)) {
357
- continue;
358
- }
359
- if ($_attribute = $_product->getResource()->getAttribute($_attributeCode)) {
360
- if ($_attribute->getBackendType() == 'int' && $_attribute->getFrontendInput() == 'select') {
361
- // dropdown or multiselect field; use the frontend label
362
- $_attribute->setStoreId($store->getId());
363
- $_value = $_attribute->getFrontend()->getValue($_product);
364
- }
365
- else {
366
- $_value = $_product->getData($_attributeCode);
367
- }
368
- if ($_value) {
369
- $_line[$_field] = $_value;
370
- }
371
- }
372
- }
373
-
374
- $deliveryNoteInfoLines[] = $_line;
375
- }
376
-
377
- // prepare the document
378
- $document = array(
379
- 'Reference' => $shipment->getIncrementId(),
380
- 'CarrierProfileId' => $carrierprofile->getId(),
381
- //'CarrierId' => $carrierprofile->getCarrierId(),
382
- //'ServiceLevelTimeId' => $carrierprofile->getServicelevelTimeId(),
383
- //'ServiceLevelOtherId' => $carrierprofile->getServicelevelOtherId(),
384
- 'ShipmentLocationId' => $shipment->getTranssmartShipmentlocationId(),
385
- 'MailTypeId' => $shipment->getTranssmartEmailtypeId(),
386
- 'IncotermId' => $shipment->getTranssmartIncotermId(),
387
- 'CostCenterId' => $shipment->getTranssmartCostcenterId(),
388
- 'RefOrder' => $shipment->getOrder()->getIncrementId(),
389
- 'RefServicePoint' => $servicePointId,
390
- 'ShipmentValue' => $shipmentValue,
391
- 'AddressEmailPickup' => Mage::getStoreConfig('trans_email/ident_general/email', $store),
392
- 'AddressName' => $addressName,
393
- 'AddressContact' => $addressContact,
394
- 'AddressStreet' => $addressStreet,
395
- 'AddressStreetNo' => $addressStreetNo,
396
- 'AddressStreet2' => $addressStreet2,
397
- 'AddressZipcode' => $address->getPostcode(),
398
- 'AddressCity' => $address->getCity(),
399
- 'AddressState' => $address->getRegionCode(),
400
- 'AddressCountry' => $address->getCountry(),
401
- 'AddressPhone' => $address->getTelephone(),
402
- 'AddressFax' => $address->getFax(),
403
- 'AddressEmail' => $shipment->getShippingAddress()->getEmail(),
404
- 'AddressCustomerNo' => $address->getCustomerId(),
405
- 'AddressNameInvoice' => $invoiceAddressName,
406
- 'AddressContactInvoice' => $invoiceAddressContact,
407
- 'AddressStreetInvoice' => $invoiceAddressStreet,
408
- 'AddressStreetNoInvoice' => $invoiceAddressStreetNo,
409
- 'AddressStreet2Invoice' => $invoiceAddressStreet2,
410
- 'AddressZipcodeInvoice' => $invoiceAddress->getPostcode(),
411
- 'AddressCityInvoice' => $invoiceAddress->getCity(),
412
- 'AddressStateInvoice' => $invoiceAddress->getRegionCode(),
413
- 'AddressCountryInvoice' => $invoiceAddress->getCountry(),
414
- 'AddressPhoneInvoice' => $invoiceAddress->getTelephone(),
415
- 'AddressFaxInvoice' => $invoiceAddress->getFax(),
416
- 'AddressEmailInvoice' => $invoiceAddress->getEmail(),
417
- 'AddressCustomerNoInvoice' => $invoiceAddress->getCustomerId(),
418
- 'AddressVatNumberInvoice' => $shipment->getOrder()->getCustomerTaxvat(),
419
- 'ColliInformation' => unserialize($shipment->getTranssmartPackages()),
420
- 'DeliveryNoteInfo' => array(
421
- array(
422
- 'DeliveryNoteInfoLines' => $deliveryNoteInfoLines
423
- )
424
- )
425
- );
426
-
427
- // dispatch event so other extensions can update the document
428
- $transport = new Varien_Object(array('document' => $document));
429
- Mage::dispatchEvent('transsmart_shipping_shipment_export_before', array(
430
- 'shipment' => $shipment,
431
- 'transport' => $transport
432
- ));
433
- $document = $transport->getDocument();
434
-
435
- // send the document to Transsmart
436
- $response = Mage::helper('transsmart_shipping')->getApiClient()->createDocument($document);
437
-
438
- // save document ID and status into shipment record
439
- if (isset($response['Id']) && isset($response['Status'])) {
440
- $shipment->setTranssmartDocumentId($response['Id']);
441
- $shipment->setTranssmartStatus($response['Status']);
442
-
443
- $shipment->getResource()->saveAttribute($shipment, array(
444
- 'transsmart_document_id',
445
- 'transsmart_status'
446
- ));
447
-
448
- // book and print if flags indicate so
449
- $flags = (int)$shipment->getTranssmartFlags();
450
- try {
451
- if (($flags & Transsmart_Shipping_Helper_Shipment::FLAG_BOOKANDPRINT_ON_CREATE)) {
452
- if ($allowPrint) {
453
- $this->doBookAndPrint($shipment);
454
- }
455
- else {
456
- $this->doBooking($shipment);
457
- }
458
- }
459
- elseif (($flags & Transsmart_Shipping_Helper_Shipment::FLAG_BOOK_ON_CREATE)) {
460
- $this->doBooking($shipment);
461
- }
462
- }
463
- catch (Exception $exception) {
464
- Mage::logException($exception);
465
- }
466
- }
467
- }
468
-
469
- /**
470
- * Create Transsmart API documents for all shipments that need to be exported.
471
- */
472
- public function doMassExport()
473
- {
474
- /** @var Mage_Sales_Model_Resource_Order_Shipment_Collection $shipmentCollection */
475
- $shipmentCollection = Mage::getResourceModel('sales/order_shipment_collection');
476
-
477
- // we need only valid Transsmart shipments without document ID
478
- $shipmentCollection
479
- ->addFieldToFilter('transsmart_carrierprofile_id', array('notnull' => true))
480
- ->addFieldToFilter('transsmart_shipmentlocation_id', array('notnull' => true))
481
- ->addFieldToFilter('transsmart_emailtype_id', array('notnull' => true))
482
- ->addFieldToFilter('transsmart_incoterm_id', array('notnull' => true))
483
- ->addFieldToFilter('transsmart_costcenter_id', array('notnull' => true))
484
- ->addFieldToFilter('transsmart_packages', array('notnull' => true))
485
- ->addFieldToFilter('transsmart_document_id', array('null' => true));
486
-
487
- /** @var Mage_Sales_Model_Order_Shipment $_shipment */
488
- foreach ($shipmentCollection as $_shipment) {
489
- // set original data manually (because we didn't call object load())
490
- $_shipment->setOrigData();
491
-
492
- $this->doExport($_shipment, false);
493
- }
494
-
495
- // group documentIds for all book-and-print shipments with the same QZ Host and Selected Printer
496
- $groupedCalls = $this->_getMassPrintGroupedCalls($shipmentCollection, true);
497
- if (count($groupedCalls) == 0) {
498
- return;
499
- }
500
-
501
- $idsToSync = array();
502
- try {
503
- // call Transsmart API doLabel method for each group (doBooking was already called in doExport)
504
- foreach ($groupedCalls as $_call) {
505
- $idsToSync += $_call['doc_ids'];
506
- Mage::helper('transsmart_shipping')->getApiClient()->doLabel(
507
- $_call['doc_ids'],
508
- Mage::getStoreConfig(Transsmart_Shipping_Helper_Data::XML_PATH_CONNECTION_USERNAME, 0),
509
- false,
510
- false,
511
- $_call['qz_host'],
512
- $_call['selected_printer']
513
- );
514
- }
515
- }
516
- catch (Exception $exception) {
517
- $this->_massSyncDocuments($shipmentCollection, $idsToSync);
518
- throw $exception;
519
- }
520
- $this->_massSyncDocuments($shipmentCollection, $idsToSync);
521
- }
522
-
523
- /**
524
- * Call doBookAndPrint for a Transsmart shipment and process the response. Returns TRUE if successful.
525
- *
526
- * @param Mage_Sales_Model_Order_Shipment $shipment
527
- * @return bool
528
- * @throws Exception
529
- */
530
- public function doBookAndPrint($shipment)
531
- {
532
- if (!$shipment->getTranssmartDocumentId()) {
533
- Mage::throwException($this->__('Transsmart document ID is not known.'));
534
- }
535
-
536
- try {
537
- // call Transsmart API doBookAndPrint method
538
- Mage::helper('transsmart_shipping')->getApiClient()->doBookAndPrint(
539
- $shipment->getTranssmartDocumentId(),
540
- Mage::getStoreConfig(Transsmart_Shipping_Helper_Data::XML_PATH_CONNECTION_USERNAME, 0),
541
- false,
542
- Mage::getStoreConfig(
543
- Transsmart_Shipping_Helper_Data::XML_PATH_PRINT_QZHOST,
544
- $shipment->getStore()
545
- ),
546
- Mage::getStoreConfig(
547
- Transsmart_Shipping_Helper_Data::XML_PATH_PRINT_SELECTEDPRINTER,
548
- $shipment->getStore()
549
- )
550
- );
551
- }
552
- catch (Exception $exception) {
553
- Mage::getSingleton('transsmart_shipping/sync')->syncShipment($shipment);
554
- throw $exception;
555
- }
556
- Mage::getSingleton('transsmart_shipping/sync')->syncShipment($shipment);
557
-
558
- return true;
559
- }
560
-
561
- /**
562
- * Call doBooking for a Transsmart shipment and process the response. Returns TRUE if successful.
563
- *
564
- * @param Mage_Sales_Model_Order_Shipment $shipment
565
- * @return bool
566
- * @throws Exception
567
- */
568
- public function doBooking($shipment)
569
- {
570
- if (!$shipment->getTranssmartDocumentId()) {
571
- Mage::throwException($this->__('Transsmart document ID is not known.'));
572
- }
573
-
574
- try {
575
- // call Transsmart API doBooking method
576
- Mage::helper('transsmart_shipping')->getApiClient()->doBooking(
577
- $shipment->getTranssmartDocumentId()
578
- );
579
- }
580
- catch (Exception $exception) {
581
- Mage::getSingleton('transsmart_shipping/sync')->syncShipment($shipment);
582
- throw $exception;
583
- }
584
- Mage::getSingleton('transsmart_shipping/sync')->syncShipment($shipment);
585
-
586
- return true;
587
- }
588
-
589
- /**
590
- * Call doLabel for a Transsmart shipment.
591
- *
592
- * @param Mage_Sales_Model_Order_Shipment $shipment
593
- * @return bool
594
- * @throws Exception
595
- */
596
- public function doLabel($shipment)
597
- {
598
- if (!$shipment->getTranssmartDocumentId()) {
599
- Mage::throwException($this->__('Transsmart document ID is not known.'));
600
- }
601
-
602
- try {
603
- // call Transsmart API doLabel method
604
- Mage::helper('transsmart_shipping')->getApiClient()->doLabel(
605
- $shipment->getTranssmartDocumentId(),
606
- Mage::getStoreConfig(Transsmart_Shipping_Helper_Data::XML_PATH_CONNECTION_USERNAME, 0),
607
- false,
608
- false,
609
- Mage::getStoreConfig(
610
- Transsmart_Shipping_Helper_Data::XML_PATH_PRINT_QZHOST,
611
- $shipment->getStore()
612
- ),
613
- Mage::getStoreConfig(
614
- Transsmart_Shipping_Helper_Data::XML_PATH_PRINT_SELECTEDPRINTER,
615
- $shipment->getStore()
616
- )
617
- );
618
- }
619
- catch (Exception $exception) {
620
- Mage::getSingleton('transsmart_shipping/sync')->syncShipment($shipment);
621
- throw $exception;
622
- }
623
- Mage::getSingleton('transsmart_shipping/sync')->syncShipment($shipment);
624
-
625
- return true;
626
- }
627
-
628
- /**
629
- * Group documentIds for shipments with the same QZ Host and Selected Printer.
630
- * Used by doMassBookAndPrint and doMassLabel
631
- *
632
- * @param Mage_Sales_Model_Resource_Order_Shipment_Collection $shipmentCollection
633
- * @param bool $onlyWithBookAndPrintFlag
634
- * @return array
635
- */
636
- protected function _getMassPrintGroupedCalls($shipmentCollection, $onlyWithBookAndPrintFlag)
637
- {
638
- // group documentIds for shipments with the same QZ Host and Selected Printer.
639
- $groupedCalls = array();
640
- foreach ($shipmentCollection as $_shipment) {
641
- if (!$_shipment->getTranssmartDocumentId()) {
642
- continue;
643
- }
644
-
645
- // do we need only shipments with the FLAG_BOOKANDPRINT_ON_CREATE flag?
646
- if ($onlyWithBookAndPrintFlag) {
647
- $_flags = (int)$_shipment->getTranssmartFlags();
648
- if (($_flags & Transsmart_Shipping_Helper_Shipment::FLAG_BOOKANDPRINT_ON_CREATE) == 0) {
649
- continue;
650
- }
651
- }
652
-
653
- $_qzHost = Mage::getStoreConfig(
654
- Transsmart_Shipping_Helper_Data::XML_PATH_PRINT_QZHOST,
655
- $_shipment->getStore()
656
- );
657
- $_selectedPrinter = Mage::getStoreConfig(
658
- Transsmart_Shipping_Helper_Data::XML_PATH_PRINT_SELECTEDPRINTER,
659
- $_shipment->getStore()
660
- );
661
-
662
- $_groupKey = $_qzHost . ':' . $_selectedPrinter;
663
- if (!isset($groupedCalls[$_groupKey])) {
664
- $groupedCalls[$_groupKey] = array(
665
- 'qz_host' => $_qzHost,
666
- 'selected_printer' => $_selectedPrinter,
667
- 'doc_ids' => array()
668
- );
669
- }
670
-
671
- $groupedCalls[$_groupKey]['doc_ids'][] = $_shipment->getTranssmartDocumentId();
672
- }
673
-
674
- return $groupedCalls;
675
- }
676
-
677
- /**
678
- * Synchronize status for the given shipments. If idsToSync array is given, only those document IDs will be synced.
679
- * Used by doMassBookAndPrint and doMassLabel
680
- *
681
- * @param Mage_Sales_Model_Resource_Order_Shipment_Collection $shipmentCollection
682
- * @param array|null $idsToSync
683
- */
684
- protected function _massSyncDocuments($shipmentCollection, $idsToSync = null)
685
- {
686
- if (!is_null($idsToSync) && count($idsToSync) == 0) {
687
- return;
688
- }
689
-
690
- foreach ($shipmentCollection as $_shipment) {
691
- $_documentId = $_shipment->getTranssmartDocumentId();
692
- if (!$_documentId || (!is_null($idsToSync) && !in_array($_documentId, $idsToSync))) {
693
- continue;
694
- }
695
-
696
- try {
697
- Mage::getSingleton('transsmart_shipping/sync')->syncShipment($_shipment);
698
- }
699
- catch (Mage_Core_Exception $exception) {
700
- Mage::logException($exception);
701
- }
702
- }
703
- }
704
-
705
- /**
706
- * Call doBookAndPrint for multiple Transsmart shipments at once.
707
- *
708
- * @param Mage_Sales_Model_Resource_Order_Shipment_Collection $shipmentCollection
709
- * @return bool
710
- * @throws Exception
711
- */
712
- public function doMassBookAndPrint($shipmentCollection)
713
- {
714
- // group documentIds for shipments with the same QZ Host and Selected Printer.
715
- $groupedCalls = $this->_getMassPrintGroupedCalls($shipmentCollection, false);
716
- if (count($groupedCalls) == 0) {
717
- return;
718
- }
719
-
720
- $idsToSync = array();
721
- try {
722
- // call Transsmart API doLabel method for each group
723
- foreach ($groupedCalls as $_call) {
724
- $idsToSync += $_call['doc_ids'];
725
- Mage::helper('transsmart_shipping')->getApiClient()->doBookAndPrint(
726
- $_call['doc_ids'],
727
- Mage::getStoreConfig(Transsmart_Shipping_Helper_Data::XML_PATH_CONNECTION_USERNAME, 0),
728
- false,
729
- $_call['qz_host'],
730
- $_call['selected_printer']
731
- );
732
- }
733
- }
734
- catch (Exception $exception) {
735
- $this->_massSyncDocuments($shipmentCollection, $idsToSync);
736
- throw $exception;
737
- }
738
- $this->_massSyncDocuments($shipmentCollection, $idsToSync);
739
-
740
- return true;
741
- }
742
-
743
- /**
744
- * Call doLabel for multiple Transsmart shipments at once.
745
- *
746
- * @param Mage_Sales_Model_Resource_Order_Shipment_Collection $shipmentCollection
747
- * @return bool
748
- * @throws Exception
749
- */
750
- public function doMassLabel($shipmentCollection)
751
- {
752
- // group documentIds for shipments with the same QZ Host and Selected Printer.
753
- $groupedCalls = $this->_getMassPrintGroupedCalls($shipmentCollection, false);
754
- if (count($groupedCalls) == 0) {
755
- return;
756
- }
757
-
758
- $idsToSync = array();
759
- try {
760
- // call Transsmart API doLabel method for each group
761
- foreach ($groupedCalls as $_call) {
762
- $idsToSync += $_call['doc_ids'];
763
- Mage::helper('transsmart_shipping')->getApiClient()->doLabel(
764
- $_call['doc_ids'],
765
- Mage::getStoreConfig(Transsmart_Shipping_Helper_Data::XML_PATH_CONNECTION_USERNAME, 0),
766
- false,
767
- false,
768
- $_call['qz_host'],
769
- $_call['selected_printer']
770
- );
771
- }
772
- }
773
- catch (Exception $exception) {
774
- $this->_massSyncDocuments($shipmentCollection, $idsToSync);
775
- throw $exception;
776
- }
777
- $this->_massSyncDocuments($shipmentCollection, $idsToSync);
778
-
779
- return true;
780
- }
781
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ /**
4
+ * @category Transsmart
5
+ * @package Transsmart_Shipping
6
+ * @copyright Copyright (c) 2016 Techtwo Webdevelopment B.V. (http://www.techtwo.nl)
7
+ */
8
+ class Transsmart_Shipping_Helper_Shipment extends Mage_Core_Helper_Abstract
9
+ {
10
+ const XML_PATH_DEFAULT_CARRIERPROFILE = 'transsmart_shipping/default_shipment/carrierprofile';
11
+ const XML_PATH_DEFAULT_SHIPMENTLOCATION = 'transsmart_shipping/default_shipment/shipmentlocation';
12
+ const XML_PATH_DEFAULT_EMAILTYPE = 'transsmart_shipping/default_shipment/emailtype';
13
+ const XML_PATH_DEFAULT_INCOTERM = 'transsmart_shipping/default_shipment/incoterm';
14
+ const XML_PATH_DEFAULT_COSTCENTER = 'transsmart_shipping/default_shipment/costcenter';
15
+ const XML_PATH_DEFAULT_PACKAGETYPE = 'transsmart_shipping/default_shipment/packagetype';
16
+
17
+ const XML_PATH_MAPPING_STREET = 'transsmart_shipping/mapping/street';
18
+ const XML_PATH_MAPPING_STREETNO = 'transsmart_shipping/mapping/streetno';
19
+ const XML_PATH_MAPPING_STREET2 = 'transsmart_shipping/mapping/street2';
20
+ const XML_PATH_MAPPING_DESCRIPTION = 'transsmart_shipping/mapping/description';
21
+ const XML_PATH_MAPPING_COUNTRY_OF_ORIGIN = 'transsmart_shipping/mapping/country_of_origin';
22
+ const XML_PATH_MAPPING_HS_CODE = 'transsmart_shipping/mapping/hs_code';
23
+ const XML_PATH_MAPPING_REASON_OF_EXPORT = 'transsmart_shipping/mapping/reason_of_export';
24
+
25
+ // OR'ed values for the 'transsmart_flags' field in the shipment table
26
+ const FLAG_BOOK_ON_CREATE = 1;
27
+ const FLAG_BOOKANDPRINT_ON_CREATE = 2;
28
+
29
+ /**
30
+ * Get all possible Transsmart shipment statuses.
31
+ *
32
+ * @return array
33
+ */
34
+ public function getShipmentStatuses()
35
+ {
36
+ return array(
37
+ 'NONE' => $this->__('NONE'),
38
+ 'NEW' => $this->__('NEW'),
39
+ 'BOOK' => $this->__('BOOK'),
40
+ 'LABL' => $this->__('LABL'),
41
+ 'MANI' => $this->__('MANI'),
42
+ 'ACCEP' => $this->__('ACCEP'),
43
+ 'TRNS' => $this->__('TRNS'),
44
+ 'DONE' => $this->__('DONE'),
45
+ 'APOD' => $this->__('APOD'),
46
+ 'REFU' => $this->__('REFU'),
47
+ 'ERR' => $this->__('ERR'),
48
+ 'DEL' => $this->__('DEL'),
49
+ 'ONHOLD' => $this->__('ONHOLD'),
50
+ );
51
+ }
52
+
53
+ /**
54
+ * Returns TRUE if the carrierprofile may be changed. This is not allowed when the location selector is enabled.
55
+ *
56
+ * @param Mage_Sales_Model_Order_Shipment $shipment
57
+ * @return bool
58
+ */
59
+ public function getAllowChangeCarrierprofile($shipment)
60
+ {
61
+ $enableLocationSelect = false;
62
+
63
+ if ($shipment) {
64
+ if (($shippingAddress = $shipment->getOrder()->getShippingAddress())) {
65
+ /** @see Transsmart_Shipping_Model_Sales_Quote_Address_Total_Shipping::collect */
66
+ if (($carrierprofileId = $shippingAddress->getTranssmartCarrierprofileId())) {
67
+ /** @var Transsmart_Shipping_Model_Carrierprofile $carrierprofile */
68
+ $carrierprofile = Mage::getResourceSingleton('transsmart_shipping/carrierprofile_collection')
69
+ ->joinCarrier()
70
+ ->getItemById($carrierprofileId);
71
+ if ($carrierprofile) {
72
+ $enableLocationSelect = $carrierprofile->isLocationSelectEnabled();
73
+ }
74
+ }
75
+ }
76
+ }
77
+
78
+ return !$enableLocationSelect;
79
+ }
80
+
81
+ /**
82
+ * Get configured default carrierprofile for the given shipment or store.
83
+ *
84
+ * @param Mage_Sales_Model_Order_Shipment|null $shipment
85
+ * @param null $store
86
+ * @return int
87
+ */
88
+ public function getDefaultCarrierprofileId($shipment = null, $store = null)
89
+ {
90
+ $defaultValue = false;
91
+ if ($shipment instanceof Mage_Sales_Model_Order_Shipment) {
92
+ // carrierprofile stored in shipping address
93
+ if (($shippingAddress = $shipment->getShippingAddress())) {
94
+ /** @see Transsmart_Shipping_Model_Sales_Quote_Address_Total_Shipping::collect */
95
+ $defaultValue = $shippingAddress->getTranssmartCarrierprofileId();
96
+ }
97
+ if (!$defaultValue) {
98
+ // carrierprofile based on shipping method
99
+ $shippingMethod = $shipment->getOrder()->getShippingMethod(false);
100
+ $carrierprofile = Mage::getModel('transsmart_shipping/carrierprofile')
101
+ ->loadByShippingMethodCode($shippingMethod);
102
+ $defaultValue = $carrierprofile->getId();
103
+ if (!$defaultValue) {
104
+ $defaultValue = Mage::getStoreConfig(self::XML_PATH_DEFAULT_CARRIERPROFILE, $shipment->getStore());
105
+ }
106
+ }
107
+ }
108
+ if (!$defaultValue) {
109
+ $defaultValue = Mage::getStoreConfig(self::XML_PATH_DEFAULT_CARRIERPROFILE, $store);
110
+ }
111
+ return $defaultValue;
112
+ }
113
+
114
+ /**
115
+ * Get configured default shipmentlocation for the given store.
116
+ *
117
+ * @param null $store
118
+ * @return int
119
+ */
120
+ public function getDefaultShipmentlocationId($store = null)
121
+ {
122
+ $defaultValue = Mage::getStoreConfig(self::XML_PATH_DEFAULT_SHIPMENTLOCATION, $store);
123
+ if (!$defaultValue) {
124
+ $ids = Mage::getResourceModel('transsmart_shipping/shipmentlocation_collection')
125
+ ->addFieldToFilter('is_default', array('eq' => 1))
126
+ ->setPageSize(1)
127
+ ->getAllIds();
128
+ if (count($ids)) {
129
+ $defaultValue = $ids[0];
130
+ }
131
+ }
132
+ return $defaultValue;
133
+ }
134
+
135
+ /**
136
+ * Get configured default emailtype for the given store.
137
+ *
138
+ * @param null $store
139
+ * @return int
140
+ */
141
+ public function getDefaultEmailtypeId($store = null)
142
+ {
143
+ $defaultValue = Mage::getStoreConfig(self::XML_PATH_DEFAULT_EMAILTYPE, $store);
144
+ if (!$defaultValue) {
145
+ $ids = Mage::getResourceModel('transsmart_shipping/emailtype_collection')
146
+ ->addFieldToFilter('is_default', array('eq' => 1))
147
+ ->setPageSize(1)
148
+ ->getAllIds();
149
+ if (count($ids)) {
150
+ $defaultValue = $ids[0];
151
+ }
152
+ }
153
+ return $defaultValue;
154
+ }
155
+
156
+ /**
157
+ * Get configured default incoterm for the given store.
158
+ *
159
+ * @param null $store
160
+ * @return int
161
+ */
162
+ public function getDefaultIncotermId($store = null)
163
+ {
164
+ $defaultValue = Mage::getStoreConfig(self::XML_PATH_DEFAULT_INCOTERM, $store);
165
+ if (!$defaultValue) {
166
+ $ids = Mage::getResourceModel('transsmart_shipping/incoterm_collection')
167
+ ->addFieldToFilter('is_default', array('eq' => 1))
168
+ ->setPageSize(1)
169
+ ->getAllIds();
170
+ if (count($ids)) {
171
+ $defaultValue = $ids[0];
172
+ }
173
+ }
174
+ return $defaultValue;
175
+ }
176
+
177
+ /**
178
+ * Get configured default costcenter for the given store.
179
+ *
180
+ * @param null $store
181
+ * @return int
182
+ */
183
+ public function getDefaultCostcenterId($store = null)
184
+ {
185
+ $defaultValue = Mage::getStoreConfig(self::XML_PATH_DEFAULT_COSTCENTER, $store);
186
+ if (!$defaultValue) {
187
+ $ids = Mage::getResourceModel('transsmart_shipping/costcenter_collection')
188
+ ->addFieldToFilter('is_default', array('eq' => 1))
189
+ ->setPageSize(1)
190
+ ->getAllIds();
191
+ if (count($ids)) {
192
+ $defaultValue = $ids[0];
193
+ }
194
+ }
195
+ return $defaultValue;
196
+ }
197
+
198
+ /**
199
+ * Get configured default packagetype for the given store.
200
+ *
201
+ * @param null $store
202
+ * @return int
203
+ */
204
+ public function getDefaultPackagetypeId($store = null)
205
+ {
206
+ $defaultValue = Mage::getStoreConfig(self::XML_PATH_DEFAULT_PACKAGETYPE, $store);
207
+ if (!$defaultValue) {
208
+ $ids = Mage::getResourceModel('transsmart_shipping/packagetype_collection')
209
+ ->addFieldToFilter('is_default', array('eq' => 1))
210
+ ->setPageSize(1)
211
+ ->getAllIds();
212
+ if (count($ids)) {
213
+ $defaultValue = $ids[0];
214
+ }
215
+ }
216
+ return $defaultValue;
217
+ }
218
+
219
+ /**
220
+ * Get the street and housenumber from the given address. If there's only one street field, try to split it into
221
+ * separate fields.
222
+ *
223
+ * @param Mage_Sales_Model_Order_Address $address
224
+ * @param mixed $store
225
+ * @return array
226
+ */
227
+ protected function _getStreetFields($address, $store = null)
228
+ {
229
+ if ($address->hasTranssmartServicepointId()) {
230
+ // for addresses from the location selector, always use predetermined fields
231
+ $street = $address->getStreet(1);
232
+ $streetNo = $address->getStreet(2);
233
+ $street2 = $address->getStreet(3);
234
+ }
235
+ else {
236
+ // read config settings for street fields mapping
237
+ $mappingStreet = Mage::getStoreConfig(self::XML_PATH_MAPPING_STREET, $store);
238
+ $mappingStreetNo = Mage::getStoreConfig(self::XML_PATH_MAPPING_STREETNO, $store);
239
+ $mappingStreet2 = Mage::getStoreConfig(self::XML_PATH_MAPPING_STREET2, $store);
240
+
241
+ // get street value
242
+ switch ($mappingStreet) {
243
+ case Transsmart_Shipping_Model_Adminhtml_System_Config_Source_Mapping_Street::NONE:
244
+ $street = '';
245
+ break;
246
+ case Transsmart_Shipping_Model_Adminhtml_System_Config_Source_Mapping_Street::FULL:
247
+ $street = trim(implode(' ', $address->getStreet()));
248
+ break;
249
+ default:
250
+ $street = $address->getStreet($mappingStreet);
251
+ }
252
+
253
+ // get streetno value
254
+ switch ($mappingStreetNo) {
255
+ case Transsmart_Shipping_Model_Adminhtml_System_Config_Source_Mapping_Street::NONE:
256
+ $streetNo = '';
257
+ break;
258
+ case Transsmart_Shipping_Model_Adminhtml_System_Config_Source_Mapping_Street::FULL:
259
+ $streetNo = trim(implode(' ', $address->getStreet()));
260
+ break;
261
+ default:
262
+ $streetNo = $address->getStreet($mappingStreetNo);
263
+ }
264
+
265
+ // get street2 value
266
+ switch ($mappingStreet2) {
267
+ case Transsmart_Shipping_Model_Adminhtml_System_Config_Source_Mapping_Street::NONE:
268
+ $street2 = '';
269
+ break;
270
+ case Transsmart_Shipping_Model_Adminhtml_System_Config_Source_Mapping_Street::FULL:
271
+ $street2 = trim(implode(' ', $address->getStreet()));
272
+ break;
273
+ default:
274
+ $street2 = $address->getStreet($mappingStreet2);
275
+ }
276
+
277
+ // automatic house number detection
278
+ if ($mappingStreet == $mappingStreetNo) {
279
+ $streetNo = '';
280
+
281
+ if (preg_match('/^(.*) ([0-9]+ .*)$/', $street, $matches)) {
282
+ $street = $matches[1];
283
+ $streetNo = $matches[2];
284
+ }
285
+ elseif (preg_match('/^(.*) ([0-9]+.*)$/', $street, $matches)) {
286
+ $street = $matches[1];
287
+ $streetNo = $matches[2];
288
+ }
289
+ elseif (preg_match('/^(.*) ([0-9]+.*)$/', $street, $matches)) {
290
+ $street = $matches[1];
291
+ $streetNo = $matches[2];
292
+ }
293
+ }
294
+ }
295
+
296
+ // house number cannot be empty
297
+ if ($streetNo === '') {
298
+ $streetNo = '.';
299
+ }
300
+
301
+ return array($street, $streetNo, $street2);
302
+ }
303
+
304
+ /**
305
+ * Export the given shipment to the Transsmart API.
306
+ *
307
+ * @param Mage_Sales_Model_Order_Shipment $shipment
308
+ * @param bool $allowPrint
309
+ */
310
+ public function doExport($shipment, $allowPrint = true)
311
+ {
312
+ // is it already exported?
313
+ if ($shipment->getTranssmartDocumentId()) {
314
+ return;
315
+ }
316
+
317
+ /** @var Transsmart_Shipping_Model_Carrierprofile $carrierprofile */
318
+ $carrierprofile = Mage::getModel('transsmart_shipping/carrierprofile')
319
+ ->load($shipment->getTranssmartCarrierprofileId());
320
+ if (!$carrierprofile->getId()) {
321
+ return;
322
+ }
323
+
324
+ $store = $shipment->getStore();
325
+ $address = $shipment->getShippingAddress();
326
+ $invoiceAddress = $shipment->getBillingAddress();
327
+
328
+ // check if the order has a pickup address (location selector is used)
329
+ $pickupAddress = Mage::helper('transsmart_shipping/pickupaddress')
330
+ ->getPickupAddressFromOrder($shipment->getOrder());
331
+ $servicePointId = null;
332
+ if ($pickupAddress) {
333
+ $address = $pickupAddress;
334
+ $invoiceAddress = $shipment->getShippingAddress();
335
+ $servicePointId = $pickupAddress->getTranssmartServicepointId();
336
+ }
337
+
338
+ // determine address name and contact
339
+ $addressName = $address->getCompany();
340
+ $addressContact = $address->getName();
341
+ if ($addressName == '') {
342
+ $addressName = $addressContact;
343
+ }
344
+
345
+ // determine invoice address name and contact
346
+ $invoiceAddressName = $invoiceAddress->getCompany();
347
+ $invoiceAddressContact = $invoiceAddress->getName();
348
+ if ($invoiceAddressName == '') {
349
+ $invoiceAddressName = $invoiceAddressContact;
350
+ }
351
+
352
+ // split street fields into street and house number
353
+ list($addressStreet, $addressStreetNo, $addressStreet2) =
354
+ $this->_getStreetFields($address, $store);
355
+ list($invoiceAddressStreet, $invoiceAddressStreetNo, $invoiceAddressStreet2) =
356
+ $this->_getStreetFields($invoiceAddress, $store);
357
+
358
+ /** @var Mage_Core_Helper_String $stringHelper */
359
+ $stringHelper = Mage::helper('core/string');
360
+
361
+ // calculate shipment value and prepare delivery note lines
362
+ $shipmentValue = 0.0;
363
+ $deliveryNoteInfoLines = array();
364
+ /** @var Mage_Sales_Model_Order_Shipment_Item $_item */
365
+ foreach ($shipment->getAllItems() as $_item) {
366
+ if ($_item->getOrderItem()->getParentItem()) {
367
+ continue;
368
+ }
369
+
370
+ $shipmentValue += $_item->getPrice() * $_item->getQty();
371
+
372
+ $_line = array(
373
+ 'ArticleId' => $stringHelper->substr($_item->getSku(), 0, 64),
374
+ 'ArticleName' => $stringHelper->substr($_item->getName(), 0, 128),
375
+ 'Description' => $stringHelper->substr($_item->getShortDescription(), 0, 256),
376
+ 'Price' => $_item->getPrice(),
377
+ 'Currency' => $store->getCurrentCurrencyCode(),
378
+ 'Quantity' => $_item->getQty(),
379
+ 'QuantityBackorder' => floatval($_item->getOrderItem()->getQtyBackordered()),
380
+ 'QuantityOrder' => $_item->getOrderItem()->getQtyOrdered(),
381
+ 'CountryOfOrigin' => Mage::getStoreConfig('shipping/origin/country_id', $store),
382
+ 'ReasonOfExport' => 'Sale',
383
+ );
384
+
385
+ $_additionalFields = array(
386
+ 'Description' => Mage::getStoreConfig(self::XML_PATH_MAPPING_DESCRIPTION, $store),
387
+ 'CountryOfOrigin' => Mage::getStoreConfig(self::XML_PATH_MAPPING_COUNTRY_OF_ORIGIN, $store),
388
+ 'HSCode' => Mage::getStoreConfig(self::XML_PATH_MAPPING_HS_CODE, $store),
389
+ 'ReasonOfExport' => Mage::getStoreConfig(self::XML_PATH_MAPPING_REASON_OF_EXPORT, $store),
390
+ );
391
+ $_product = $_item->getOrderItem()->getProduct();
392
+ foreach ($_additionalFields as $_field => $_attributeCode) {
393
+ if (empty($_attributeCode)) {
394
+ continue;
395
+ }
396
+ if ($_attribute = $_product->getResource()->getAttribute($_attributeCode)) {
397
+ if ($_attribute->getBackendType() == 'int' && $_attribute->getFrontendInput() == 'select') {
398
+ // dropdown or multiselect field; use the frontend label
399
+ $_attribute->setStoreId($store->getId());
400
+ $_value = $_attribute->getFrontend()->getValue($_product);
401
+ }
402
+ else {
403
+ $_value = $_product->getData($_attributeCode);
404
+ }
405
+ if ($_value) {
406
+ $_maxLength = ($_field == 'Description') ? 256 : 64;
407
+ $_line[$_field] = $stringHelper->substr($_value, 0, $_maxLength);
408
+ }
409
+ }
410
+ }
411
+
412
+ $deliveryNoteInfoLines[] = $_line;
413
+ }
414
+
415
+ // prepare the document
416
+ $document = array(
417
+ 'Reference' => $shipment->getIncrementId(),
418
+ 'CarrierProfileId' => $carrierprofile->getId(),
419
+ //'CarrierId' => $carrierprofile->getCarrierId(),
420
+ //'ServiceLevelTimeId' => $carrierprofile->getServicelevelTimeId(),
421
+ //'ServiceLevelOtherId' => $carrierprofile->getServicelevelOtherId(),
422
+ 'ShipmentLocationId' => $shipment->getTranssmartShipmentlocationId(),
423
+ 'MailTypeId' => $shipment->getTranssmartEmailtypeId(),
424
+ 'IncotermId' => $shipment->getTranssmartIncotermId(),
425
+ 'CostCenterId' => $shipment->getTranssmartCostcenterId(),
426
+ 'RefOrder' => $shipment->getOrder()->getIncrementId(),
427
+ 'RefServicePoint' => $servicePointId,
428
+ 'ShipmentValue' => $shipmentValue,
429
+ 'AddressEmailPickup' => Mage::getStoreConfig('trans_email/ident_general/email', $store),
430
+ 'AddressName' => $addressName,
431
+ 'AddressContact' => $addressContact,
432
+ 'AddressStreet' => $addressStreet,
433
+ 'AddressStreetNo' => $addressStreetNo,
434
+ 'AddressStreet2' => $addressStreet2,
435
+ 'AddressZipcode' => $address->getPostcode(),
436
+ 'AddressCity' => $address->getCity(),
437
+ 'AddressState' => $address->getRegionCode(),
438
+ 'AddressCountry' => $address->getCountry(),
439
+ 'AddressPhone' => $address->getTelephone(),
440
+ 'AddressFax' => $address->getFax(),
441
+ 'AddressEmail' => $shipment->getShippingAddress()->getEmail(),
442
+ 'AddressCustomerNo' => $address->getCustomerId(),
443
+ 'AddressNameInvoice' => $invoiceAddressName,
444
+ 'AddressContactInvoice' => $invoiceAddressContact,
445
+ 'AddressStreetInvoice' => $invoiceAddressStreet,
446
+ 'AddressStreetNoInvoice' => $invoiceAddressStreetNo,
447
+ 'AddressStreet2Invoice' => $invoiceAddressStreet2,
448
+ 'AddressZipcodeInvoice' => $invoiceAddress->getPostcode(),
449
+ 'AddressCityInvoice' => $invoiceAddress->getCity(),
450
+ 'AddressStateInvoice' => $invoiceAddress->getRegionCode(),
451
+ 'AddressCountryInvoice' => $invoiceAddress->getCountry(),
452
+ 'AddressPhoneInvoice' => $invoiceAddress->getTelephone(),
453
+ 'AddressFaxInvoice' => $invoiceAddress->getFax(),
454
+ 'AddressEmailInvoice' => $invoiceAddress->getEmail(),
455
+ 'AddressCustomerNoInvoice' => $invoiceAddress->getCustomerId(),
456
+ 'AddressVatNumberInvoice' => $shipment->getOrder()->getCustomerTaxvat(),
457
+ 'ColliInformation' => unserialize($shipment->getTranssmartPackages()),
458
+ 'DeliveryNoteInfo' => array(
459
+ array(
460
+ 'DeliveryNoteInfoLines' => $deliveryNoteInfoLines
461
+ )
462
+ )
463
+ );
464
+
465
+ // dispatch event so other extensions can update the document
466
+ $transport = new Varien_Object(array('document' => $document));
467
+ Mage::dispatchEvent('transsmart_shipping_shipment_export_before', array(
468
+ 'shipment' => $shipment,
469
+ 'transport' => $transport
470
+ ));
471
+ $document = $transport->getDocument();
472
+
473
+ // send the document to Transsmart
474
+ $response = Mage::helper('transsmart_shipping')->getApiClient()->createDocument($document);
475
+
476
+ // save document ID and status into shipment record
477
+ if (isset($response['Id']) && isset($response['Status'])) {
478
+ Mage::getSingleton('transsmart_shipping/sync')->syncShipment($shipment, $response);
479
+
480
+ // book and print if flags indicate so
481
+ $flags = (int)$shipment->getTranssmartFlags();
482
+ try {
483
+ if (($flags & Transsmart_Shipping_Helper_Shipment::FLAG_BOOKANDPRINT_ON_CREATE)) {
484
+ if ($allowPrint) {
485
+ $this->doBookAndPrint($shipment);
486
+ }
487
+ else {
488
+ $this->doBooking($shipment);
489
+ }
490
+ }
491
+ elseif (($flags & Transsmart_Shipping_Helper_Shipment::FLAG_BOOK_ON_CREATE)) {
492
+ $this->doBooking($shipment);
493
+ }
494
+ }
495
+ catch (Exception $exception) {
496
+ Mage::logException($exception);
497
+ }
498
+ }
499
+ }
500
+
501
+ /**
502
+ * Create Transsmart API documents for all shipments that need to be exported.
503
+ */
504
+ public function doMassExport()
505
+ {
506
+ /** @var Mage_Sales_Model_Resource_Order_Shipment_Collection $shipmentCollection */
507
+ $shipmentCollection = Mage::getResourceModel('sales/order_shipment_collection');
508
+
509
+ // we need only valid Transsmart shipments without document ID
510
+ $shipmentCollection
511
+ ->addFieldToFilter('transsmart_carrierprofile_id', array('notnull' => true))
512
+ ->addFieldToFilter('transsmart_shipmentlocation_id', array('notnull' => true))
513
+ ->addFieldToFilter('transsmart_emailtype_id', array('notnull' => true))
514
+ ->addFieldToFilter('transsmart_incoterm_id', array('notnull' => true))
515
+ ->addFieldToFilter('transsmart_costcenter_id', array('notnull' => true))
516
+ ->addFieldToFilter('transsmart_packages', array('notnull' => true))
517
+ ->addFieldToFilter('transsmart_document_id', array('null' => true));
518
+
519
+ /** @var Mage_Sales_Model_Order_Shipment $_shipment */
520
+ foreach ($shipmentCollection as $_shipment) {
521
+ // set original data manually (because we didn't call object load())
522
+ $_shipment->setOrigData();
523
+
524
+ $this->doExport($_shipment, false);
525
+ }
526
+
527
+ // group documentIds for all book-and-print shipments with the same QZ Host and Selected Printer
528
+ $groupedCalls = $this->_getMassPrintGroupedCalls($shipmentCollection, true);
529
+ if (count($groupedCalls) == 0) {
530
+ return;
531
+ }
532
+
533
+ $idsToSync = array();
534
+ try {
535
+ // call Transsmart API doLabel method for each group (doBooking was already called in doExport)
536
+ foreach ($groupedCalls as $_call) {
537
+ $idsToSync += $_call['doc_ids'];
538
+ Mage::helper('transsmart_shipping')->getApiClient()->doLabel(
539
+ $_call['doc_ids'],
540
+ Mage::getStoreConfig(Transsmart_Shipping_Helper_Data::XML_PATH_CONNECTION_USERNAME, 0),
541
+ false,
542
+ false,
543
+ $_call['qz_host'],
544
+ $_call['selected_printer']
545
+ );
546
+ }
547
+ }
548
+ catch (Exception $exception) {
549
+ $this->_massSyncDocuments($shipmentCollection, $idsToSync);
550
+ throw $exception;
551
+ }
552
+ $this->_massSyncDocuments($shipmentCollection, $idsToSync);
553
+ }
554
+
555
+ /**
556
+ * Call doBookAndPrint for a Transsmart shipment and process the response. Returns TRUE if successful.
557
+ *
558
+ * @param Mage_Sales_Model_Order_Shipment $shipment
559
+ * @return bool
560
+ * @throws Exception
561
+ */
562
+ public function doBookAndPrint($shipment)
563
+ {
564
+ if (!$shipment->getTranssmartDocumentId()) {
565
+ Mage::throwException($this->__('Transsmart document ID is not known.'));
566
+ }
567
+
568
+ try {
569
+ // call Transsmart API doBookAndPrint method
570
+ Mage::helper('transsmart_shipping')->getApiClient()->doBookAndPrint(
571
+ $shipment->getTranssmartDocumentId(),
572
+ Mage::getStoreConfig(Transsmart_Shipping_Helper_Data::XML_PATH_CONNECTION_USERNAME, 0),
573
+ false,
574
+ Mage::getStoreConfig(
575
+ Transsmart_Shipping_Helper_Data::XML_PATH_PRINT_QZHOST,
576
+ $shipment->getStore()
577
+ ),
578
+ Mage::getStoreConfig(
579
+ Transsmart_Shipping_Helper_Data::XML_PATH_PRINT_SELECTEDPRINTER,
580
+ $shipment->getStore()
581
+ )
582
+ );
583
+ }
584
+ catch (Exception $exception) {
585
+ Mage::getSingleton('transsmart_shipping/sync')->syncShipment($shipment);
586
+ throw $exception;
587
+ }
588
+ Mage::getSingleton('transsmart_shipping/sync')->syncShipment($shipment);
589
+
590
+ return true;
591
+ }
592
+
593
+ /**
594
+ * Call doBooking for a Transsmart shipment and process the response. Returns TRUE if successful.
595
+ *
596
+ * @param Mage_Sales_Model_Order_Shipment $shipment
597
+ * @return bool
598
+ * @throws Exception
599
+ */
600
+ public function doBooking($shipment)
601
+ {
602
+ if (!$shipment->getTranssmartDocumentId()) {
603
+ Mage::throwException($this->__('Transsmart document ID is not known.'));
604
+ }
605
+
606
+ try {
607
+ // call Transsmart API doBooking method
608
+ Mage::helper('transsmart_shipping')->getApiClient()->doBooking(
609
+ $shipment->getTranssmartDocumentId()
610
+ );
611
+ }
612
+ catch (Exception $exception) {
613
+ Mage::getSingleton('transsmart_shipping/sync')->syncShipment($shipment);
614
+ throw $exception;
615
+ }
616
+ Mage::getSingleton('transsmart_shipping/sync')->syncShipment($shipment);
617
+
618
+ return true;
619
+ }
620
+
621
+ /**
622
+ * Call doLabel for a Transsmart shipment.
623
+ *
624
+ * @param Mage_Sales_Model_Order_Shipment $shipment
625
+ * @return bool
626
+ * @throws Exception
627
+ */
628
+ public function doLabel($shipment)
629
+ {
630
+ if (!$shipment->getTranssmartDocumentId()) {
631
+ Mage::throwException($this->__('Transsmart document ID is not known.'));
632
+ }
633
+
634
+ try {
635
+ // call Transsmart API doLabel method
636
+ Mage::helper('transsmart_shipping')->getApiClient()->doLabel(
637
+ $shipment->getTranssmartDocumentId(),
638
+ Mage::getStoreConfig(Transsmart_Shipping_Helper_Data::XML_PATH_CONNECTION_USERNAME, 0),
639
+ false,
640
+ false,
641
+ Mage::getStoreConfig(
642
+ Transsmart_Shipping_Helper_Data::XML_PATH_PRINT_QZHOST,
643
+ $shipment->getStore()
644
+ ),
645
+ Mage::getStoreConfig(
646
+ Transsmart_Shipping_Helper_Data::XML_PATH_PRINT_SELECTEDPRINTER,
647
+ $shipment->getStore()
648
+ )
649
+ );
650
+ }
651
+ catch (Exception $exception) {
652
+ Mage::getSingleton('transsmart_shipping/sync')->syncShipment($shipment);
653
+ throw $exception;
654
+ }
655
+ Mage::getSingleton('transsmart_shipping/sync')->syncShipment($shipment);
656
+
657
+ return true;
658
+ }
659
+
660
+ /**
661
+ * Group documentIds for shipments with the same QZ Host and Selected Printer.
662
+ * Used by doMassBookAndPrint and doMassLabel
663
+ *
664
+ * @param Mage_Sales_Model_Resource_Order_Shipment_Collection $shipmentCollection
665
+ * @param bool $onlyWithBookAndPrintFlag
666
+ * @return array
667
+ */
668
+ protected function _getMassPrintGroupedCalls($shipmentCollection, $onlyWithBookAndPrintFlag)
669
+ {
670
+ // group documentIds for shipments with the same QZ Host and Selected Printer.
671
+ $groupedCalls = array();
672
+ foreach ($shipmentCollection as $_shipment) {
673
+ if (!$_shipment->getTranssmartDocumentId()) {
674
+ continue;
675
+ }
676
+
677
+ // do we need only shipments with the FLAG_BOOKANDPRINT_ON_CREATE flag?
678
+ if ($onlyWithBookAndPrintFlag) {
679
+ $_flags = (int)$_shipment->getTranssmartFlags();
680
+ if (($_flags & Transsmart_Shipping_Helper_Shipment::FLAG_BOOKANDPRINT_ON_CREATE) == 0) {
681
+ continue;
682
+ }
683
+ }
684
+
685
+ $_qzHost = Mage::getStoreConfig(
686
+ Transsmart_Shipping_Helper_Data::XML_PATH_PRINT_QZHOST,
687
+ $_shipment->getStore()
688
+ );
689
+ $_selectedPrinter = Mage::getStoreConfig(
690
+ Transsmart_Shipping_Helper_Data::XML_PATH_PRINT_SELECTEDPRINTER,
691
+ $_shipment->getStore()
692
+ );
693
+
694
+ $_groupKey = $_qzHost . ':' . $_selectedPrinter;
695
+ if (!isset($groupedCalls[$_groupKey])) {
696
+ $groupedCalls[$_groupKey] = array(
697
+ 'qz_host' => $_qzHost,
698
+ 'selected_printer' => $_selectedPrinter,
699
+ 'doc_ids' => array()
700
+ );
701
+ }
702
+
703
+ $groupedCalls[$_groupKey]['doc_ids'][] = $_shipment->getTranssmartDocumentId();
704
+ }
705
+
706
+ return $groupedCalls;
707
+ }
708
+
709
+ /**
710
+ * Synchronize status for the given shipments. If idsToSync array is given, only those document IDs will be synced.
711
+ * Used by doMassBookAndPrint and doMassLabel
712
+ *
713
+ * @param Mage_Sales_Model_Resource_Order_Shipment_Collection $shipmentCollection
714
+ * @param array|null $idsToSync
715
+ */
716
+ protected function _massSyncDocuments($shipmentCollection, $idsToSync = null)
717
+ {
718
+ if (!is_null($idsToSync) && count($idsToSync) == 0) {
719
+ return;
720
+ }
721
+
722
+ foreach ($shipmentCollection as $_shipment) {
723
+ $_documentId = $_shipment->getTranssmartDocumentId();
724
+ if (!$_documentId || (!is_null($idsToSync) && !in_array($_documentId, $idsToSync))) {
725
+ continue;
726
+ }
727
+
728
+ try {
729
+ Mage::getSingleton('transsmart_shipping/sync')->syncShipment($_shipment);
730
+ }
731
+ catch (Mage_Core_Exception $exception) {
732
+ Mage::logException($exception);
733
+ }
734
+ }
735
+ }
736
+
737
+ /**
738
+ * Call doBookAndPrint for multiple Transsmart shipments at once.
739
+ *
740
+ * @param Mage_Sales_Model_Resource_Order_Shipment_Collection $shipmentCollection
741
+ * @return bool
742
+ * @throws Exception
743
+ */
744
+ public function doMassBookAndPrint($shipmentCollection)
745
+ {
746
+ // group documentIds for shipments with the same QZ Host and Selected Printer.
747
+ $groupedCalls = $this->_getMassPrintGroupedCalls($shipmentCollection, false);
748
+ if (count($groupedCalls) == 0) {
749
+ return;
750
+ }
751
+
752
+ $idsToSync = array();
753
+ try {
754
+ // call Transsmart API doLabel method for each group
755
+ foreach ($groupedCalls as $_call) {
756
+ $idsToSync += $_call['doc_ids'];
757
+ Mage::helper('transsmart_shipping')->getApiClient()->doBookAndPrint(
758
+ $_call['doc_ids'],
759
+ Mage::getStoreConfig(Transsmart_Shipping_Helper_Data::XML_PATH_CONNECTION_USERNAME, 0),
760
+ false,
761
+ $_call['qz_host'],
762
+ $_call['selected_printer']
763
+ );
764
+ }
765
+ }
766
+ catch (Exception $exception) {
767
+ $this->_massSyncDocuments($shipmentCollection, $idsToSync);
768
+ throw $exception;
769
+ }
770
+ $this->_massSyncDocuments($shipmentCollection, $idsToSync);
771
+
772
+ return true;
773
+ }
774
+
775
+ /**
776
+ * Call doLabel for multiple Transsmart shipments at once.
777
+ *
778
+ * @param Mage_Sales_Model_Resource_Order_Shipment_Collection $shipmentCollection
779
+ * @return bool
780
+ * @throws Exception
781
+ */
782
+ public function doMassLabel($shipmentCollection)
783
+ {
784
+ // group documentIds for shipments with the same QZ Host and Selected Printer.
785
+ $groupedCalls = $this->_getMassPrintGroupedCalls($shipmentCollection, false);
786
+ if (count($groupedCalls) == 0) {
787
+ return;
788
+ }
789
+
790
+ $idsToSync = array();
791
+ try {
792
+ // call Transsmart API doLabel method for each group
793
+ foreach ($groupedCalls as $_call) {
794
+ $idsToSync += $_call['doc_ids'];
795
+ Mage::helper('transsmart_shipping')->getApiClient()->doLabel(
796
+ $_call['doc_ids'],
797
+ Mage::getStoreConfig(Transsmart_Shipping_Helper_Data::XML_PATH_CONNECTION_USERNAME, 0),
798
+ false,
799
+ false,
800
+ $_call['qz_host'],
801
+ $_call['selected_printer']
802
+ );
803
+ }
804
+ }
805
+ catch (Exception $exception) {
806
+ $this->_massSyncDocuments($shipmentCollection, $idsToSync);
807
+ throw $exception;
808
+ }
809
+ $this->_massSyncDocuments($shipmentCollection, $idsToSync);
810
+
811
+ return true;
812
+ }
813
+ }
app/code/community/Transsmart/Shipping/Model/Adminhtml/Observer.php CHANGED
@@ -45,11 +45,6 @@ class Transsmart_Shipping_Model_Adminhtml_Observer
45
  $_group->$_key = $_value;
46
  }
47
 
48
- // remove location_select if carrier does not allow location selector
49
- if (!$_carrierprofile->getCarrierLocationSelect()) {
50
- unset($_group->fields->location_select);
51
- }
52
-
53
  $groups->addChild('carrierprofile_' . $_carrierprofile->getId())
54
  ->extend($_group);
55
  }
@@ -79,10 +74,15 @@ class Transsmart_Shipping_Model_Adminhtml_Observer
79
  /** @var Mage_Sales_Model_Quote $quote */
80
  $quote = $orderCreateModel->getQuote();
81
 
82
- // try to load the carrierprofile based on the shipping method
83
- $carrierProfile = Mage::getModel('transsmart_shipping/carrierprofile')
84
- ->loadByShippingMethodCode($orderCreateModel->getShippingMethod());
85
- if (!$carrierProfile->getId() || !$carrierProfile->isLocationSelectEnabled()) {
 
 
 
 
 
86
  // location selector disabled. remove the pickup addresses, if there are any
87
  Mage::helper('transsmart_shipping/pickupaddress')->removePickupAddressFromQuote($quote);
88
  return;
@@ -118,9 +118,8 @@ class Transsmart_Shipping_Model_Adminhtml_Observer
118
  $block = $observer->getEvent()->getBlock();
119
 
120
  if ($block instanceof Mage_Adminhtml_Block_Sales_Order_Shipment_Create_Form) {
121
- // verify shipping method
122
- $shippingMethod = $block->getOrder()->getShippingMethod();
123
- if (!Mage::helper('transsmart_shipping')->isTranssmartShippingMethod($shippingMethod)) {
124
  return;
125
  }
126
 
@@ -131,9 +130,8 @@ class Transsmart_Shipping_Model_Adminhtml_Observer
131
  ));
132
  }
133
  elseif ($block instanceof Mage_Adminhtml_Block_Sales_Order_Shipment_Create_Items) {
134
- // verify shipping method
135
- $shippingMethod = $block->getOrder()->getShippingMethod();
136
- if (!Mage::helper('transsmart_shipping')->isTranssmartShippingMethod($shippingMethod)) {
137
  return;
138
  }
139
 
@@ -156,9 +154,8 @@ class Transsmart_Shipping_Model_Adminhtml_Observer
156
  $submitButton->setLabel(Mage::helper('sales')->__('Create Shipment'));
157
  }
158
  elseif ($block instanceof Mage_Adminhtml_Block_Sales_Order_Shipment_View_Form) {
159
- // verify shipping method
160
- $shippingMethod = $block->getOrder()->getShippingMethod();
161
- if (!Mage::helper('transsmart_shipping')->isTranssmartShippingMethod($shippingMethod)) {
162
  return;
163
  }
164
 
@@ -190,9 +187,8 @@ class Transsmart_Shipping_Model_Adminhtml_Observer
190
  return;
191
  }
192
 
193
- // does it use one of our shipping methods?
194
- $shippingMethod = $shipment->getOrder()->getShippingMethod();
195
- if (!Mage::helper('transsmart_shipping')->isTranssmartShippingMethod($shippingMethod)) {
196
  return;
197
  }
198
 
@@ -203,8 +199,8 @@ class Transsmart_Shipping_Model_Adminhtml_Observer
203
  $shipmentPostData = $frontController->getRequest()->getPost('shipment');
204
 
205
  // update the shipment model
206
- if (!Mage::helper('transsmart_shipping')->isTranssmartPickup($shippingMethod)) {
207
- if (!empty($shipmentPostData['transsmart_carrierprofile_id'])) {
208
  $shipment->setTranssmartCarrierprofileId($shipmentPostData['transsmart_carrierprofile_id']);
209
  }
210
  }
45
  $_group->$_key = $_value;
46
  }
47
 
 
 
 
 
 
48
  $groups->addChild('carrierprofile_' . $_carrierprofile->getId())
49
  ->extend($_group);
50
  }
74
  /** @var Mage_Sales_Model_Quote $quote */
75
  $quote = $orderCreateModel->getQuote();
76
 
77
+ // check if Mage_Adminhtml_Model_Sales_Order_Create::setShippingAsBilling resets transsmart_carrierprofile_id
78
+ $shippingAddress = $quote->getShippingAddress();
79
+ if (!$shippingAddress->getData('transsmart_carrierprofile_id') &&
80
+ $shippingAddress->getOrigData('transsmart_carrierprofile_id')) {
81
+ return;
82
+ }
83
+
84
+ // check if a pickup address is required
85
+ if (!Mage::helper('transsmart_shipping')->isLocationSelectQuote($quote)) {
86
  // location selector disabled. remove the pickup addresses, if there are any
87
  Mage::helper('transsmart_shipping/pickupaddress')->removePickupAddressFromQuote($quote);
88
  return;
118
  $block = $observer->getEvent()->getBlock();
119
 
120
  if ($block instanceof Mage_Adminhtml_Block_Sales_Order_Shipment_Create_Form) {
121
+ // is this a Transsmart order?
122
+ if (!Mage::helper('transsmart_shipping')->isTranssmartOrder($block->getOrder())) {
 
123
  return;
124
  }
125
 
130
  ));
131
  }
132
  elseif ($block instanceof Mage_Adminhtml_Block_Sales_Order_Shipment_Create_Items) {
133
+ // is this a Transsmart order?
134
+ if (!Mage::helper('transsmart_shipping')->isTranssmartOrder($block->getOrder())) {
 
135
  return;
136
  }
137
 
154
  $submitButton->setLabel(Mage::helper('sales')->__('Create Shipment'));
155
  }
156
  elseif ($block instanceof Mage_Adminhtml_Block_Sales_Order_Shipment_View_Form) {
157
+ // is this a Transsmart order?
158
+ if (!Mage::helper('transsmart_shipping')->isTranssmartOrder($block->getOrder())) {
 
159
  return;
160
  }
161
 
187
  return;
188
  }
189
 
190
+ // is this a Transsmart order?
191
+ if (!Mage::helper('transsmart_shipping')->isTranssmartOrder($shipment->getOrder())) {
 
192
  return;
193
  }
194
 
199
  $shipmentPostData = $frontController->getRequest()->getPost('shipment');
200
 
201
  // update the shipment model
202
+ if (!empty($shipmentPostData['transsmart_carrierprofile_id'])) {
203
+ if (Mage::helper('transsmart_shipping/shipment')->getAllowChangeCarrierprofile($shipment)) {
204
  $shipment->setTranssmartCarrierprofileId($shipmentPostData['transsmart_carrierprofile_id']);
205
  }
206
  }
app/code/community/Transsmart/Shipping/Model/Carrierprofile.php CHANGED
@@ -13,6 +13,8 @@
13
  * @method Transsmart_Shipping_Model_Carrierprofile setServicelevelTimeId(int $value)
14
  * @method int getServicelevelOtherId()
15
  * @method Transsmart_Shipping_Model_Carrierprofile setServicelevelOtherId(int $value)
 
 
16
  *
17
  * @method string getCarrierCode()
18
  * @method string getCarrierName()
@@ -33,10 +35,11 @@ class Transsmart_Shipping_Model_Carrierprofile extends Transsmart_Shipping_Model
33
  * @var array
34
  */
35
  protected $apiKeysMapping = array(
36
- 'Id' => 'carrierprofile_id',
37
- 'CarrierId' => 'carrier_id',
38
- 'ServiceLevelTimeId' => 'servicelevel_time_id',
39
- 'ServiceLevelOtherId' => 'servicelevel_other_id'
 
40
  );
41
 
42
  /**
@@ -78,37 +81,28 @@ class Transsmart_Shipping_Model_Carrierprofile extends Transsmart_Shipping_Model
78
  }
79
 
80
  /**
81
- * Check if the location selector is enabled for this carrier profile.
82
  *
83
- * @param mixed $store
84
  * @return bool
85
  */
86
  public function isLocationSelectEnabled($store = null)
87
  {
88
- $result = false;
89
-
90
- if ($this->getCarrierLocationSelect()) {
91
- if ($this->getConfigData('method') == Transsmart_Shipping_Model_Adminhtml_System_Config_Source_Method::PICKUP) {
92
- if ($this->getConfigData('location_select', $store)) {
93
- $result = true;
94
- }
95
- }
96
- }
97
-
98
- return $result;
99
  }
100
 
101
  /**
102
  * Return a name identifying this carrier profile. Because there is no 'name' attribute, this name is constructed
103
  * using config settings, or the carrier/servicelevel name if no name is configured.
104
  *
 
105
  * @return string
106
  */
107
- public function getName()
108
  {
109
  $id = $this->getData('carrierprofile_id');
110
 
111
- $title = Mage::getStoreConfig('transsmart_carrier_profiles/carrierprofile_' . $id . '/title', 0);
112
  if (empty($title)) {
113
  $title = sprintf(
114
  '(%s / %s / %s)',
13
  * @method Transsmart_Shipping_Model_Carrierprofile setServicelevelTimeId(int $value)
14
  * @method int getServicelevelOtherId()
15
  * @method Transsmart_Shipping_Model_Carrierprofile setServicelevelOtherId(int $value)
16
+ * @method int getEnableLocationSelect()
17
+ * @method Transsmart_Shipping_Model_Carrierprofile setEnableLocationSelect(int $value)
18
  *
19
  * @method string getCarrierCode()
20
  * @method string getCarrierName()
35
  * @var array
36
  */
37
  protected $apiKeysMapping = array(
38
+ 'Id' => 'carrierprofile_id',
39
+ 'CarrierId' => 'carrier_id',
40
+ 'ServiceLevelTimeId' => 'servicelevel_time_id',
41
+ 'ServiceLevelOtherId' => 'servicelevel_other_id',
42
+ 'EnableLocationSelect' => 'enable_location_select'
43
  );
44
 
45
  /**
81
  }
82
 
83
  /**
84
+ * Check if the location selector is enabled for this carrier profile and the carrier.
85
  *
86
+ * @param mixed $store deprecated
87
  * @return bool
88
  */
89
  public function isLocationSelectEnabled($store = null)
90
  {
91
+ return ($this->getCarrierLocationSelect() && $this->getEnableLocationSelect());
 
 
 
 
 
 
 
 
 
 
92
  }
93
 
94
  /**
95
  * Return a name identifying this carrier profile. Because there is no 'name' attribute, this name is constructed
96
  * using config settings, or the carrier/servicelevel name if no name is configured.
97
  *
98
+ * @param mixed $store
99
  * @return string
100
  */
101
+ public function getName($store = null)
102
  {
103
  $id = $this->getData('carrierprofile_id');
104
 
105
+ $title = $this->getConfigData('title', $store);
106
  if (empty($title)) {
107
  $title = sprintf(
108
  '(%s / %s / %s)',
app/code/community/Transsmart/Shipping/Model/Observer.php CHANGED
@@ -27,9 +27,8 @@ class Transsmart_Shipping_Model_Observer
27
  return;
28
  }
29
 
30
- // does it use one of our shipping methods?
31
- $shippingMethod = $shipment->getOrder()->getShippingMethod();
32
- if (!Mage::helper('transsmart_shipping')->isTranssmartShippingMethod($shippingMethod)) {
33
  return;
34
  }
35
 
@@ -122,16 +121,13 @@ class Transsmart_Shipping_Model_Observer
122
  /** @var Mage_Sales_Model_Quote $quote */
123
  $quote = $observer->getQuote();
124
 
125
- $shippingAddress = $quote->getShippingAddress();
126
- $shippingMethod = $shippingAddress->getShippingMethod();
127
-
128
  // remove the pickup addresses, if there are any
129
  Mage::helper('transsmart_shipping/pickupaddress')->removePickupAddressFromQuote($quote);
130
 
131
- // try to load the carrierprofile based on the shipping method
132
- $carrierProfile = Mage::getModel('transsmart_shipping/carrierprofile')
133
- ->loadByShippingMethodCode($shippingMethod);
134
- if (!$carrierProfile->getId() || !$carrierProfile->isLocationSelectEnabled()) {
135
  // not a Transsmart shipping method with enabled location selector
136
  return;
137
  }
@@ -187,15 +183,11 @@ class Transsmart_Shipping_Model_Observer
187
 
188
  $quote = $controllerAction->getOnepage()->getQuote();
189
 
190
- $shippingMethod = $request->getPost('shipping_method', $quote->getShippingAddress()->getShippingMethod());
191
-
192
  // remove the pickup addresses, if there are any
193
  Mage::helper('transsmart_shipping/pickupaddress')->removePickupAddressFromQuote($quote);
194
 
195
- // try to load the carrierprofile based on the shipping method
196
- $carrierProfile = Mage::getModel('transsmart_shipping/carrierprofile')
197
- ->loadByShippingMethodCode($shippingMethod);
198
- if (!$carrierProfile->getId() || !$carrierProfile->isLocationSelectEnabled()) {
199
  // not a Transsmart shipping method with enabled location selector
200
  return;
201
  }
@@ -234,10 +226,8 @@ class Transsmart_Shipping_Model_Observer
234
  /** @var Mage_Sales_Model_Quote $quote */
235
  $quote = $observer->getQuote();
236
 
237
- $shippingMethod = $quote->getShippingAddress()->getShippingMethod();
238
-
239
- // check whether this is a Transsmart shipping method
240
- if (!Mage::helper('transsmart_shipping')->isTranssmartPickup($shippingMethod)) {
241
  return;
242
  }
243
 
@@ -264,8 +254,11 @@ class Transsmart_Shipping_Model_Observer
264
  /** @var Mage_Sales_Model_Order $order */
265
  $order = $observer->getOrder();
266
 
267
- // check whether this is a Transsmart shipping method
268
- if (!Mage::helper('transsmart_shipping')->isTranssmartPickup($order->getShippingMethod())) {
 
 
 
269
  return;
270
  }
271
 
@@ -289,8 +282,8 @@ class Transsmart_Shipping_Model_Observer
289
  /** @var Mage_Sales_Model_Quote $quote */
290
  $quote = $observer->getQuote();
291
 
292
- // check whether this is a Transsmart shipping method
293
- if (!Mage::helper('transsmart_shipping')->isTranssmartPickup($order->getShippingMethod())) {
294
  return;
295
  }
296
 
27
  return;
28
  }
29
 
30
+ // is this a Transsmart order?
31
+ if (!Mage::helper('transsmart_shipping')->isTranssmartOrder($shipment->getOrder())) {
 
32
  return;
33
  }
34
 
121
  /** @var Mage_Sales_Model_Quote $quote */
122
  $quote = $observer->getQuote();
123
 
 
 
 
124
  // remove the pickup addresses, if there are any
125
  Mage::helper('transsmart_shipping/pickupaddress')->removePickupAddressFromQuote($quote);
126
 
127
+ // check if a pickup address is required
128
+ // totalsCollected is false here, because shipping method is updated but the totals are not collected yet.
129
+ /* @see Mage_Checkout_OnepageController::saveShippingMethodAction */
130
+ if (!Mage::helper('transsmart_shipping')->isLocationSelectQuote($quote, false)) {
131
  // not a Transsmart shipping method with enabled location selector
132
  return;
133
  }
183
 
184
  $quote = $controllerAction->getOnepage()->getQuote();
185
 
 
 
186
  // remove the pickup addresses, if there are any
187
  Mage::helper('transsmart_shipping/pickupaddress')->removePickupAddressFromQuote($quote);
188
 
189
+ // check if a pickup address is required
190
+ if (!Mage::helper('transsmart_shipping')->isLocationSelectQuote($quote)) {
 
 
191
  // not a Transsmart shipping method with enabled location selector
192
  return;
193
  }
226
  /** @var Mage_Sales_Model_Quote $quote */
227
  $quote = $observer->getQuote();
228
 
229
+ // check whether the quote uses a Transsmart shipping method with a pickup address
230
+ if (!Mage::helper('transsmart_shipping')->isLocationSelectQuote($quote)) {
 
 
231
  return;
232
  }
233
 
254
  /** @var Mage_Sales_Model_Order $order */
255
  $order = $observer->getOrder();
256
 
257
+ /** @var Mage_Sales_Model_Quote $quote */
258
+ $quote = $observer->getQuote();
259
+
260
+ // check whether the quote uses a Transsmart shipping method with a pickup address
261
+ if (!Mage::helper('transsmart_shipping')->isLocationSelectQuote($quote)) {
262
  return;
263
  }
264
 
282
  /** @var Mage_Sales_Model_Quote $quote */
283
  $quote = $observer->getQuote();
284
 
285
+ // check whether the quote uses a Transsmart shipping method with a pickup address
286
+ if (!Mage::helper('transsmart_shipping')->isLocationSelectQuote($quote)) {
287
  return;
288
  }
289
 
app/code/community/Transsmart/Shipping/Model/Resource/Carrierprofile/Collection.php CHANGED
@@ -7,9 +7,9 @@
7
  */
8
  class Transsmart_Shipping_Model_Resource_Carrierprofile_Collection extends Mage_Core_Model_Resource_Db_Collection_Abstract
9
  {
10
- protected $_hasJoinedCarrier = false;
11
- protected $_hasJoinedServicelevelTime = false;
12
- protected $_hasJoinedServicelevelOther = false;
13
 
14
  protected function _construct()
15
  {
@@ -29,6 +29,61 @@ class Transsmart_Shipping_Model_Resource_Carrierprofile_Collection extends Mage_
29
  return $res;
30
  }
31
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
32
  /**
33
  * Join the carrier table.
34
  *
@@ -36,23 +91,10 @@ class Transsmart_Shipping_Model_Resource_Carrierprofile_Collection extends Mage_
36
  */
37
  public function joinCarrier()
38
  {
39
- if ($this->_hasJoinedCarrier) {
40
- return $this;
 
41
  }
42
- $this->_hasJoinedCarrier = true;
43
-
44
- $this->getSelect()
45
- ->join(
46
- array(
47
- 'carrier' => $this->getTable('transsmart_shipping/carrier')
48
- ),
49
- 'carrier.carrier_id = main_table.carrier_id',
50
- array(
51
- 'carrier_code' => 'code',
52
- 'carrier_name' => 'name',
53
- 'carrier_location_select' => 'location_select',
54
- )
55
- );
56
  return $this;
57
  }
58
 
@@ -63,22 +105,10 @@ class Transsmart_Shipping_Model_Resource_Carrierprofile_Collection extends Mage_
63
  */
64
  public function joinServicelevelTime()
65
  {
66
- if ($this->_hasJoinedServicelevelTime) {
67
- return $this;
 
68
  }
69
- $this->_hasJoinedServicelevelTime = true;
70
-
71
- $this->getSelect()
72
- ->join(
73
- array(
74
- 'servicelevel_time' => $this->getTable('transsmart_shipping/servicelevel_time')
75
- ),
76
- 'servicelevel_time.servicelevel_time_id = main_table.servicelevel_time_id',
77
- array(
78
- 'servicelevel_time_code' => 'code',
79
- 'servicelevel_time_name' => 'name',
80
- )
81
- );
82
  return $this;
83
  }
84
 
@@ -89,22 +119,10 @@ class Transsmart_Shipping_Model_Resource_Carrierprofile_Collection extends Mage_
89
  */
90
  public function joinServicelevelOther()
91
  {
92
- if ($this->_hasJoinedServicelevelOther) {
93
- return $this;
 
94
  }
95
- $this->_hasJoinedServicelevelOther = true;
96
-
97
- $this->getSelect()
98
- ->join(
99
- array(
100
- 'servicelevel_other' => $this->getTable('transsmart_shipping/servicelevel_other')
101
- ),
102
- 'servicelevel_other.servicelevel_other_id = main_table.servicelevel_other_id',
103
- array(
104
- 'servicelevel_other_code' => 'code',
105
- 'servicelevel_other_name' => 'name',
106
- )
107
- );
108
  return $this;
109
  }
110
  }
7
  */
8
  class Transsmart_Shipping_Model_Resource_Carrierprofile_Collection extends Mage_Core_Model_Resource_Db_Collection_Abstract
9
  {
10
+ protected $_joinCarrier = false;
11
+ protected $_joinServicelevelTime = false;
12
+ protected $_joinServicelevelOther = false;
13
 
14
  protected function _construct()
15
  {
29
  return $res;
30
  }
31
 
32
+ /**
33
+ * Init collection select
34
+ *
35
+ * @return $this
36
+ */
37
+ public function _initSelect()
38
+ {
39
+ parent::_initSelect();
40
+
41
+ if ($this->_joinCarrier) {
42
+ $this->getSelect()
43
+ ->join(
44
+ array(
45
+ 'carrier' => $this->getTable('transsmart_shipping/carrier')
46
+ ),
47
+ 'carrier.carrier_id = main_table.carrier_id',
48
+ array(
49
+ 'carrier_code' => 'code',
50
+ 'carrier_name' => 'name',
51
+ 'carrier_location_select' => 'location_select',
52
+ )
53
+ );
54
+ }
55
+
56
+ if ($this->_joinServicelevelTime) {
57
+ $this->getSelect()
58
+ ->join(
59
+ array(
60
+ 'servicelevel_time' => $this->getTable('transsmart_shipping/servicelevel_time')
61
+ ),
62
+ 'servicelevel_time.servicelevel_time_id = main_table.servicelevel_time_id',
63
+ array(
64
+ 'servicelevel_time_code' => 'code',
65
+ 'servicelevel_time_name' => 'name',
66
+ )
67
+ );
68
+ }
69
+
70
+ if ($this->_joinServicelevelOther) {
71
+ $this->getSelect()
72
+ ->join(
73
+ array(
74
+ 'servicelevel_other' => $this->getTable('transsmart_shipping/servicelevel_other')
75
+ ),
76
+ 'servicelevel_other.servicelevel_other_id = main_table.servicelevel_other_id',
77
+ array(
78
+ 'servicelevel_other_code' => 'code',
79
+ 'servicelevel_other_name' => 'name',
80
+ )
81
+ );
82
+ }
83
+
84
+ return $this;
85
+ }
86
+
87
  /**
88
  * Join the carrier table.
89
  *
91
  */
92
  public function joinCarrier()
93
  {
94
+ if (!$this->_joinCarrier) {
95
+ $this->_joinCarrier = true;
96
+ $this->_reset();
97
  }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
98
  return $this;
99
  }
100
 
105
  */
106
  public function joinServicelevelTime()
107
  {
108
+ if (!$this->_joinServicelevelTime) {
109
+ $this->_joinServicelevelTime = true;
110
+ $this->_reset();
111
  }
 
 
 
 
 
 
 
 
 
 
 
 
 
112
  return $this;
113
  }
114
 
119
  */
120
  public function joinServicelevelOther()
121
  {
122
+ if (!$this->_joinServicelevelOther) {
123
+ $this->_joinServicelevelOther = true;
124
+ $this->_reset();
125
  }
 
 
 
 
 
 
 
 
 
 
 
 
 
126
  return $this;
127
  }
128
  }
app/code/community/Transsmart/Shipping/Model/Sales/Quote/Address/Rate.php ADDED
@@ -0,0 +1,17 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ /**
4
+ * @category Transsmart
5
+ * @package Transsmart_Shipping
6
+ * @copyright Copyright (c) 2016 Techtwo Webdevelopment B.V. (http://www.techtwo.nl)
7
+ */
8
+ class Transsmart_Shipping_Model_Sales_Quote_Address_Rate extends Mage_Sales_Model_Quote_Address_Rate
9
+ {
10
+ public function importShippingRate(Mage_Shipping_Model_Rate_Result_Abstract $rate)
11
+ {
12
+ if ($rate instanceof Mage_Shipping_Model_Rate_Result_Method) {
13
+ $this->setTranssmartCarrierprofileId($rate->getTranssmartCarrierprofileId());
14
+ }
15
+ return parent::importShippingRate($rate);
16
+ }
17
+ }
app/code/community/Transsmart/Shipping/Model/Sales/Quote/Address/Total/Shipping.php ADDED
@@ -0,0 +1,41 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ /**
4
+ * @category Transsmart
5
+ * @package Transsmart_Shipping
6
+ * @copyright Copyright (c) 2016 Techtwo Webdevelopment B.V. (http://www.techtwo.nl)
7
+ */
8
+ class Transsmart_Shipping_Model_Sales_Quote_Address_Total_Shipping extends Mage_Sales_Model_Quote_Address_Total_Shipping
9
+ {
10
+ /**
11
+ * Collect totals information about shipping
12
+ *
13
+ * @param Mage_Sales_Model_Quote_Address $address
14
+ * @return Mage_Sales_Model_Quote_Address_Total_Shipping
15
+ */
16
+ public function collect(Mage_Sales_Model_Quote_Address $address)
17
+ {
18
+ parent::collect($address);
19
+
20
+ $items = $this->_getAddressItems($address);
21
+ if (!count($items)) {
22
+ return $this;
23
+ }
24
+
25
+ $carrierprofileId = null;
26
+
27
+ $method = $address->getShippingMethod();
28
+ if ($method) {
29
+ foreach ($address->getAllShippingRates() as $rate) {
30
+ if ($rate->getCode() == $method) {
31
+ $carrierprofileId = $rate->getTranssmartCarrierprofileId();
32
+ break;
33
+ }
34
+ }
35
+ }
36
+
37
+ $address->setTranssmartCarrierprofileId($carrierprofileId);
38
+
39
+ return $this;
40
+ }
41
+ }
app/code/community/Transsmart/Shipping/Model/Sales/Resource/Order.php CHANGED
@@ -34,12 +34,19 @@ class Transsmart_Shipping_Model_Sales_Resource_Order extends Mage_Sales_Model_Re
34
  " AND transsmart_shipments_error.transsmart_status = 'ERR'",
35
  array()
36
  )
 
 
 
 
 
 
37
  ->group("$mainTableAlias.entity_id");
38
 
39
  // define the logic that determines the Transsmart order status
40
  $casesResults = array();
41
 
42
- $casesResults['main_table.shipping_method NOT LIKE \'transsmart%\_carrierprofile\_%\''] =
 
43
  Transsmart_Shipping_Helper_Data::TRANSSMART_ORDER_STATUS_NOT_APPLICABLE;
44
 
45
  $casesResults['SUM(transsmart_shipments_error.total_qty) > 0'] =
34
  " AND transsmart_shipments_error.transsmart_status = 'ERR'",
35
  array()
36
  )
37
+ ->joinLeft(
38
+ array('shipping_address' => $this->getTable('sales/order_address')),
39
+ "shipping_address.parent_id = $mainTableAlias.entity_id" .
40
+ " AND shipping_address.address_type = 'shipping'",
41
+ array()
42
+ )
43
  ->group("$mainTableAlias.entity_id");
44
 
45
  // define the logic that determines the Transsmart order status
46
  $casesResults = array();
47
 
48
+ $casesResults['main_table.shipping_method NOT LIKE \'transsmart%\_carrierprofile\_%\''
49
+ . ' AND shipping_address.transsmart_carrierprofile_id IS NULL'] =
50
  Transsmart_Shipping_Helper_Data::TRANSSMART_ORDER_STATUS_NOT_APPLICABLE;
51
 
52
  $casesResults['SUM(transsmart_shipments_error.total_qty) > 0'] =
app/code/community/Transsmart/Shipping/Model/Shipping/Carrier/Abstract.php CHANGED
@@ -78,6 +78,8 @@ class Transsmart_Shipping_Model_Shipping_Carrier_Abstract
78
  $_method->setPrice($_shippingPrice);
79
  $_method->setCost($_shippingPrice);
80
 
 
 
81
  $result->append($_method);
82
  }
83
 
78
  $_method->setPrice($_shippingPrice);
79
  $_method->setCost($_shippingPrice);
80
 
81
+ $_method->setTranssmartCarrierprofileId($_carrierprofile->getId());
82
+
83
  $result->append($_method);
84
  }
85
 
app/code/community/Transsmart/Shipping/Model/Shipping/Carrier/Tablerate.php ADDED
@@ -0,0 +1,208 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ /**
4
+ * @category Transsmart
5
+ * @package Transsmart_Shipping
6
+ * @copyright Copyright (c) 2016 Techtwo Webdevelopment B.V. (http://www.techtwo.nl)
7
+ */
8
+ class Transsmart_Shipping_Model_Shipping_Carrier_Tablerate extends Mage_Shipping_Model_Carrier_Tablerate
9
+ {
10
+ /**
11
+ * Collect and get rates. Original table rate returns only one rate. This one adds an additional field named
12
+ * transsmart_carrierprofile_id, and can return multiple rates they have the same country/region/zip/condition.
13
+ *
14
+ * @param Mage_Shipping_Model_Rate_Request $request
15
+ * @return Mage_Shipping_Model_Rate_Result
16
+ */
17
+ public function collectRates(Mage_Shipping_Model_Rate_Request $request)
18
+ {
19
+ if (!$this->getConfigFlag('active')) {
20
+ return false;
21
+ }
22
+
23
+ // exclude Virtual products price from Package value if pre-configured
24
+ if (!$this->getConfigFlag('include_virtual_price') && $request->getAllItems()) {
25
+ foreach ($request->getAllItems() as $item) {
26
+ if ($item->getParentItem()) {
27
+ continue;
28
+ }
29
+ if ($item->getHasChildren() && $item->isShipSeparately()) {
30
+ foreach ($item->getChildren() as $child) {
31
+ if ($child->getProduct()->isVirtual()) {
32
+ $request->setPackageValue($request->getPackageValue() - $child->getBaseRowTotal());
33
+ }
34
+ }
35
+ } elseif ($item->getProduct()->isVirtual()) {
36
+ $request->setPackageValue($request->getPackageValue() - $item->getBaseRowTotal());
37
+ }
38
+ }
39
+ }
40
+
41
+ // Free shipping by qty
42
+ $freeQty = 0;
43
+ if ($request->getAllItems()) {
44
+ $freePackageValue = 0;
45
+ foreach ($request->getAllItems() as $item) {
46
+ if ($item->getProduct()->isVirtual() || $item->getParentItem()) {
47
+ continue;
48
+ }
49
+
50
+ if ($item->getHasChildren() && $item->isShipSeparately()) {
51
+ foreach ($item->getChildren() as $child) {
52
+ if ($child->getFreeShipping() && !$child->getProduct()->isVirtual()) {
53
+ $freeShipping = is_numeric($child->getFreeShipping()) ? $child->getFreeShipping() : 0;
54
+ $freeQty += $item->getQty() * ($child->getQty() - $freeShipping);
55
+ }
56
+ }
57
+ } elseif ($item->getFreeShipping()) {
58
+ $freeShipping = is_numeric($item->getFreeShipping()) ? $item->getFreeShipping() : 0;
59
+ $freeQty += $item->getQty() - $freeShipping;
60
+ $freePackageValue += $item->getBaseRowTotal();
61
+ }
62
+ }
63
+ $oldValue = $request->getPackageValue();
64
+ $request->setPackageValue($oldValue - $freePackageValue);
65
+ }
66
+
67
+ if ($freePackageValue) {
68
+ $request->setPackageValue($request->getPackageValue() - $freePackageValue);
69
+ }
70
+ if (!$request->getConditionName()) {
71
+ $conditionName = $this->getConfigData('condition_name');
72
+ $request->setConditionName($conditionName ? $conditionName : $this->_default_condition_name);
73
+ }
74
+
75
+ // Package weight and qty free shipping
76
+ $oldWeight = $request->getPackageWeight();
77
+ $oldQty = $request->getPackageQty();
78
+
79
+ $request->setPackageWeight($request->getFreeMethodWeight());
80
+ $request->setPackageQty($oldQty - $freeQty);
81
+
82
+ $result = $this->_getModel('shipping/rate_result');
83
+ $rates = $this->getRates($request);
84
+
85
+ $request->setPackageWeight($oldWeight);
86
+ $request->setPackageQty($oldQty);
87
+
88
+ $count = 0;
89
+ foreach ($rates as $_rate) {
90
+ if ($_rate['price'] >= 0) {
91
+ $method = $this->_getModel('shipping/rate_result_method');
92
+
93
+ $method->setCarrier('tablerate');
94
+ $method->setCarrierTitle($this->getConfigData('title'));
95
+
96
+ $method->setMethod($this->getUniqueMethodCode($_rate['transsmart_carrierprofile_id']));
97
+ $method->setMethodTitle($this->getUniqueMethodTitle($_rate['transsmart_carrierprofile_id']));
98
+
99
+ if ($request->getFreeShipping() === true || ($request->getPackageQty() == $freeQty)) {
100
+ $shippingPrice = 0;
101
+ }
102
+ else {
103
+ $shippingPrice = $this->getFinalPriceWithHandlingFee($_rate['price']);
104
+ }
105
+
106
+ $method->setPrice($shippingPrice);
107
+ $method->setCost($_rate['cost']);
108
+
109
+ $method->setTranssmartCarrierprofileId($_rate['transsmart_carrierprofile_id']);
110
+
111
+ $result->append($method);
112
+
113
+ $count++;
114
+ }
115
+ }
116
+
117
+ if ($count == 0 && $request->getFreeShipping() === true) {
118
+ /**
119
+ * was applied promotion rule for whole cart
120
+ * other shipping methods could be switched off at all
121
+ * we must show table rate method with 0$ price, if grand_total more, than min table condition_value
122
+ * free setPackageWeight() has already was taken into account
123
+ */
124
+ $request->setPackageValue($freePackageValue);
125
+ $request->setPackageQty($freeQty);
126
+ $rates = $this->getRates($request);
127
+ foreach ($rates as $_rate) {
128
+ if ($_rate['price'] >= 0) {
129
+ $method = $this->_getModel('shipping/rate_result_method');
130
+
131
+ $method->setCarrier('tablerate');
132
+ $method->setCarrierTitle($this->getConfigData('title'));
133
+
134
+ $method->setMethod($this->getUniqueMethodCode($_rate['transsmart_carrierprofile_id']));
135
+ $method->setMethodTitle($this->getUniqueMethodTitle($_rate['transsmart_carrierprofile_id']));
136
+
137
+ $method->setPrice(0);
138
+ $method->setCost(0);
139
+
140
+ $method->setTranssmartCarrierprofileId($_rate['transsmart_carrierprofile_id']);
141
+
142
+ $result->append($method);
143
+
144
+ $count++;
145
+ }
146
+ }
147
+ }
148
+ elseif ($count == 0) {
149
+ $error = $this->_getModel('shipping/rate_result_error');
150
+ $error->setCarrier('tablerate');
151
+ $error->setCarrierTitle($this->getConfigData('title'));
152
+ $error->setErrorMessage($this->getConfigData('specificerrmsg'));
153
+ $result->append($error);
154
+ }
155
+
156
+ return $result;
157
+ }
158
+
159
+ /**
160
+ * Get Rates
161
+ *
162
+ * @param Mage_Shipping_Model_Rate_Request $request
163
+ *
164
+ * @return array
165
+ */
166
+ public function getRates(Mage_Shipping_Model_Rate_Request $request)
167
+ {
168
+ return Mage::getResourceModel('shipping/carrier_tablerate')->getRates($request);
169
+ }
170
+
171
+ /**
172
+ * Get unique method code.
173
+ *
174
+ * @param int $carrierprofileId
175
+ * @return string
176
+ */
177
+ protected function getUniqueMethodCode($carrierprofileId)
178
+ {
179
+ return 'bestway' . ($carrierprofileId ? '_' . $carrierprofileId : '');
180
+ }
181
+
182
+ /**
183
+ * Get unique method title.
184
+ *
185
+ * @param int $carrierprofileId
186
+ * @return string
187
+ */
188
+ protected function getUniqueMethodTitle($carrierprofileId)
189
+ {
190
+ $title = false;
191
+
192
+ if ($carrierprofileId) {
193
+ /** @var Transsmart_Shipping_Model_Carrierprofile $carrierprofile */
194
+ $carrierprofile = Mage::getResourceSingleton('transsmart_shipping/carrierprofile_collection')
195
+ ->getItemById($carrierprofileId);
196
+
197
+ if ($carrierprofile) {
198
+ $title = $carrierprofile->getConfigData('title', $this->getStore());
199
+ }
200
+ }
201
+
202
+ if (empty($title)) {
203
+ $title = $this->getConfigData('name');
204
+ }
205
+
206
+ return $title;
207
+ }
208
+ }
app/code/community/Transsmart/Shipping/Model/Shipping/Resource/Carrier/Tablerate.php ADDED
@@ -0,0 +1,151 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ /**
4
+ * @category Transsmart
5
+ * @package Transsmart_Shipping
6
+ * @copyright Copyright (c) 2016 Techtwo Webdevelopment B.V. (http://www.techtwo.nl)
7
+ */
8
+ class Transsmart_Shipping_Model_Shipping_Resource_Carrier_Tablerate
9
+ extends Mage_Shipping_Model_Resource_Carrier_Tablerate
10
+ {
11
+ /**
12
+ * Array of unique table rate keys to protect from duplicates
13
+ *
14
+ * @var array
15
+ */
16
+ protected $_importUniqueTranssmartHash = array();
17
+
18
+ /**
19
+ * Return table rates array. Original table rate returns only one rate. This one adds an additional field named
20
+ * transsmart_carrierprofile_id, and can return multiple rates they have the same country/region/zip/condition.
21
+ *
22
+ * @param Mage_Shipping_Model_Rate_Request $request
23
+ * @return array
24
+ */
25
+ public function getRates(Mage_Shipping_Model_Rate_Request $request)
26
+ {
27
+ $result = array();
28
+
29
+ // first find single rate
30
+ $rate = parent::getRate($request);
31
+
32
+ if ($rate) {
33
+ // now get all rates with the same country/region/zip/condition
34
+ $adapter = $this->_getReadAdapter();
35
+
36
+ $uniqueFields = array(
37
+ 'website_id',
38
+ 'dest_country_id',
39
+ 'dest_region_id',
40
+ 'dest_zip',
41
+ 'condition_name',
42
+ 'condition_value'
43
+ );
44
+
45
+ // render the select query
46
+ $select = $adapter->select()
47
+ ->from($this->getMainTable());
48
+
49
+ // add query conditions
50
+ foreach ($rate as $_field => $_value) {
51
+ if (in_array($_field, $uniqueFields)) {
52
+ if ($_field == 'dest_zip' && ($_value === '' || $_value == '*')) {
53
+ $select->where("`dest_zip` IN ('', '*')");
54
+ }
55
+ else {
56
+ $select->where($adapter->quoteIdentifier($_field) . ' = ?', $_value);
57
+ }
58
+ }
59
+ }
60
+
61
+ // run the query and process results
62
+ if (($result = $adapter->fetchAll($select))) {
63
+ foreach ($result as $_rate) {
64
+ // normalize destination zip code
65
+ if ($_rate['dest_zip'] == '*') {
66
+ $_rate['dest_zip'] = '';
67
+ }
68
+ $results[] = $_rate;
69
+ }
70
+ }
71
+ else {
72
+ // something went wrong, just return the single found rate
73
+ $result = array($rate);
74
+ }
75
+ }
76
+
77
+ return $result;
78
+ }
79
+
80
+ /**
81
+ * Validate row for import and return table rate array or false
82
+ * Error will be add to _importErrors array
83
+ *
84
+ * @param array $row
85
+ * @param int $rowNumber
86
+ * @return array|false
87
+ */
88
+ protected function _getImportRow($row, $rowNumber = 0)
89
+ {
90
+ $result = parent::_getImportRow($row, $rowNumber);
91
+
92
+ // reset original unique hash array
93
+ $this->_importUniqueHash = array();
94
+
95
+ if ($result !== false) {
96
+ $carrierprofileId = null;
97
+ if (count($row) >= 6) {
98
+ $carrierprofileId = $row[5];
99
+
100
+ // validate carrier profile id
101
+ $carrierprofileCollection = Mage::getResourceSingleton('transsmart_shipping/carrierprofile_collection');
102
+ if (!($carrierprofileCollection->getItemById($carrierprofileId))) {
103
+ $this->_importErrors[] = Mage::helper('transsmart_shipping')->__(
104
+ 'Invalid Transsmart Carrier Profile Id "%s" in the Row #%s.',
105
+ $carrierprofileId,
106
+ $rowNumber
107
+ );
108
+ return false;
109
+ }
110
+ }
111
+
112
+ $result[] = $carrierprofileId;
113
+
114
+ // protect from duplicate
115
+ $hash = sprintf("%s-%d-%s-%F-%s", $result[1], $result[2], $result[3], $result[5], $result[7]);
116
+ if (isset($this->_importUniqueTranssmartHash[$hash])) {
117
+ $this->_importErrors[] = Mage::helper('shipping')->__(
118
+ 'Duplicate Row #%s (Country "%s", Region/State "%s", Zip "%s", Value "%s" and Transsmart Carrier Profile Id "%s").',
119
+ $rowNumber,
120
+ $row[0], // dest_country_id
121
+ $row[1], // dest_region_id
122
+ $result[3], // dest_zip
123
+ $result[5], // condition_value
124
+ $result[7] // transsmart_carrierprofile_id
125
+ );
126
+ return false;
127
+ }
128
+ $this->_importUniqueTranssmartHash[$hash] = true;
129
+ }
130
+
131
+ return $result;
132
+ }
133
+
134
+ /**
135
+ * Save import data batch
136
+ *
137
+ * @param array $data
138
+ * @return Mage_Shipping_Model_Resource_Carrier_Tablerate
139
+ */
140
+ protected function _saveImportData(array $data)
141
+ {
142
+ if (!empty($data)) {
143
+ $columns = array('website_id', 'dest_country_id', 'dest_region_id', 'dest_zip',
144
+ 'condition_name', 'condition_value', 'price', 'transsmart_carrierprofile_id');
145
+ $this->_getWriteAdapter()->insertArray($this->getMainTable(), $columns, $data);
146
+ $this->_importedRows += count($data);
147
+ }
148
+
149
+ return $this;
150
+ }
151
+ }
app/code/community/Transsmart/Shipping/Model/Sync.php CHANGED
@@ -142,6 +142,11 @@ class Transsmart_Shipping_Model_Sync extends Mage_Core_Model_Abstract
142
  $model = Mage::getModel('transsmart_shipping/carrierprofile');
143
  $mappedData = $model->mapApiKeysToDbColumns($apiItem);
144
 
 
 
 
 
 
145
  $model->setData($mappedData);
146
  $model->save();
147
 
@@ -573,11 +578,11 @@ class Transsmart_Shipping_Model_Sync extends Mage_Core_Model_Abstract
573
  $queryDefinition = array(
574
  'Carriers' => array(),
575
  'CostCenters' => array(),
576
- 'SubAccounts' => array(),
577
  'DateTimeFrom' => $this->_convertGmtToCet($sinceTime),
578
  'DateTimeTo' => $this->_convertGmtToCet(Mage::getModel('core/date')->gmtDate()),
579
  'MaxResults' => 100,
580
- 'IsIncremental' => false
581
  );
582
  $response = $this->getApiClient()->getStatus($queryDefinition);
583
  foreach ($response as $_item) {
@@ -656,6 +661,14 @@ class Transsmart_Shipping_Model_Sync extends Mage_Core_Model_Abstract
656
  }
657
 
658
  if (is_array($documentData)) {
 
 
 
 
 
 
 
 
659
  if (array_key_exists('Status', $documentData)) {
660
  $value = $documentData['Status'];
661
  if ($shipment->getData('transsmart_status') != $value) {
@@ -664,6 +677,14 @@ class Transsmart_Shipping_Model_Sync extends Mage_Core_Model_Abstract
664
  }
665
  }
666
 
 
 
 
 
 
 
 
 
667
  if (array_key_exists('TrackingUrl', $documentData)) {
668
  $value = $documentData['TrackingUrl'];
669
  if ($shipment->getData('transsmart_tracking_url') != $value) {
@@ -671,6 +692,30 @@ class Transsmart_Shipping_Model_Sync extends Mage_Core_Model_Abstract
671
  $updatedAttributes[] = 'transsmart_tracking_url';
672
  }
673
  }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
674
  }
675
 
676
  if (count($updatedAttributes)) {
142
  $model = Mage::getModel('transsmart_shipping/carrierprofile');
143
  $mappedData = $model->mapApiKeysToDbColumns($apiItem);
144
 
145
+ // EnableLocationSelect is returned as Y/N from the API, Map that to 1 and 0
146
+ if (isset($mappedData['enable_location_select'])) {
147
+ $mappedData['enable_location_select'] = $mappedData['enable_location_select'] == 'Y' ? 1 : 0;
148
+ }
149
+
150
  $model->setData($mappedData);
151
  $model->save();
152
 
578
  $queryDefinition = array(
579
  'Carriers' => array(),
580
  'CostCenters' => array(),
581
+ 'SubCustomers' => array(),
582
  'DateTimeFrom' => $this->_convertGmtToCet($sinceTime),
583
  'DateTimeTo' => $this->_convertGmtToCet(Mage::getModel('core/date')->gmtDate()),
584
  'MaxResults' => 100,
585
+ 'IsIncremental' => true
586
  );
587
  $response = $this->getApiClient()->getStatus($queryDefinition);
588
  foreach ($response as $_item) {
661
  }
662
 
663
  if (is_array($documentData)) {
664
+ if (array_key_exists('Id', $documentData)) {
665
+ $value = $documentData['Id'];
666
+ if ($shipment->getData('transsmart_document_id') != $value) {
667
+ $shipment->setData('transsmart_document_id', $value);
668
+ $updatedAttributes[] = 'transsmart_document_id';
669
+ }
670
+ }
671
+
672
  if (array_key_exists('Status', $documentData)) {
673
  $value = $documentData['Status'];
674
  if ($shipment->getData('transsmart_status') != $value) {
677
  }
678
  }
679
 
680
+ if (array_key_exists('ShipmentError', $documentData)) {
681
+ $value = $documentData['ShipmentError'];
682
+ if ($shipment->getData('transsmart_shipment_error') != $value) {
683
+ $shipment->setData('transsmart_shipment_error', $value);
684
+ $updatedAttributes[] = 'transsmart_shipment_error';
685
+ }
686
+ }
687
+
688
  if (array_key_exists('TrackingUrl', $documentData)) {
689
  $value = $documentData['TrackingUrl'];
690
  if ($shipment->getData('transsmart_tracking_url') != $value) {
692
  $updatedAttributes[] = 'transsmart_tracking_url';
693
  }
694
  }
695
+
696
+ if (array_key_exists('CarrierId', $documentData)) {
697
+ $value = $documentData['CarrierId'];
698
+ if ($shipment->getData('transsmart_final_carrier_id') != $value) {
699
+ $shipment->setData('transsmart_final_carrier_id', $value);
700
+ $updatedAttributes[] = 'transsmart_final_carrier_id';
701
+ }
702
+ }
703
+
704
+ if (array_key_exists('ServiceLevelTimeId', $documentData)) {
705
+ $value = $documentData['ServiceLevelTimeId'];
706
+ if ($shipment->getData('transsmart_final_servicelevel_time_id') != $value) {
707
+ $shipment->setData('transsmart_final_servicelevel_time_id', $value);
708
+ $updatedAttributes[] = 'transsmart_final_servicelevel_time_id';
709
+ }
710
+ }
711
+
712
+ if (array_key_exists('ServiceLevelOtherId', $documentData)) {
713
+ $value = $documentData['ServiceLevelOtherId'];
714
+ if ($shipment->getData('transsmart_final_servicelevel_other_id') != $value) {
715
+ $shipment->setData('transsmart_final_servicelevel_other_id', $value);
716
+ $updatedAttributes[] = 'transsmart_final_servicelevel_other_id';
717
+ }
718
+ }
719
  }
720
 
721
  if (count($updatedAttributes)) {
app/code/community/Transsmart/Shipping/controllers/Adminhtml/Transsmart/Shipping/ShipmentController.php CHANGED
@@ -196,12 +196,17 @@ class Transsmart_Shipping_Adminhtml_Transsmart_Shipping_ShipmentController exten
196
  $successCount++;
197
  }
198
  else {
 
 
 
 
 
199
  $this->_getSession()->addError(
200
  $this->__(
201
  'Shipment #%s for order #%s could not be booked and printed: %s',
202
  $_shipment->getIncrementId(),
203
  $_shipment->getOrder()->getIncrementId(),
204
- 'Error' // TODO: use ShipmentError field
205
  )
206
  );
207
  }
@@ -333,12 +338,17 @@ class Transsmart_Shipping_Adminhtml_Transsmart_Shipping_ShipmentController exten
333
  $successCount++;
334
  }
335
  else {
 
 
 
 
 
336
  $this->_getSession()->addError(
337
  $this->__(
338
  'Shipment #%s for order #%s could not be printed: %s',
339
  $_shipment->getIncrementId(),
340
  $_shipment->getOrder()->getIncrementId(),
341
- 'Error' // TODO: use ShipmentError field
342
  )
343
  );
344
  }
@@ -394,26 +404,22 @@ class Transsmart_Shipping_Adminhtml_Transsmart_Shipping_ShipmentController exten
394
  protected function _getMassActionShipmentCollection()
395
  {
396
  $request = $this->getRequest();
397
-
398
  $shipmentCollection = null;
399
- switch ($request->getParam('massaction_prepare_key')) {
400
- case 'shipment_ids':
401
- $ids = $request->getParam('shipment_ids');
402
- array_filter($ids, 'intval');
403
- if (!empty($ids)) {
404
- $shipmentCollection = Mage::getResourceModel('sales/order_shipment_collection')
405
- ->addFieldToFilter('entity_id', array('in' => $ids));
406
- }
407
- break;
408
-
409
- case 'order_ids':
410
- $ids = $request->getParam('order_ids');
411
- array_filter($ids, 'intval');
412
- if (!empty($ids)) {
413
- $shipmentCollection = Mage::getResourceModel('sales/order_shipment_collection')
414
- ->setOrderFilter(array('in' => $ids));
415
- }
416
- break;
417
  }
418
 
419
  return $shipmentCollection;
196
  $successCount++;
197
  }
198
  else {
199
+ $_shipmentError = $_shipment->getTranssmartShipmentError();
200
+ if (empty($_shipmentError)) {
201
+ $_shipmentError = $this->__('Unknown error');
202
+ }
203
+
204
  $this->_getSession()->addError(
205
  $this->__(
206
  'Shipment #%s for order #%s could not be booked and printed: %s',
207
  $_shipment->getIncrementId(),
208
  $_shipment->getOrder()->getIncrementId(),
209
+ $_shipmentError
210
  )
211
  );
212
  }
338
  $successCount++;
339
  }
340
  else {
341
+ $_shipmentError = $_shipment->getTranssmartShipmentError();
342
+ if (empty($_shipmentError)) {
343
+ $_shipmentError = $this->__('Unknown error');
344
+ }
345
+
346
  $this->_getSession()->addError(
347
  $this->__(
348
  'Shipment #%s for order #%s could not be printed: %s',
349
  $_shipment->getIncrementId(),
350
  $_shipment->getOrder()->getIncrementId(),
351
+ $_shipmentError
352
  )
353
  );
354
  }
404
  protected function _getMassActionShipmentCollection()
405
  {
406
  $request = $this->getRequest();
 
407
  $shipmentCollection = null;
408
+ if ($request->has('shipment_ids')) {
409
+ $ids = $request->getParam('shipment_ids');
410
+ array_filter($ids, 'intval');
411
+ if (!empty($ids)) {
412
+ $shipmentCollection = Mage::getResourceModel('sales/order_shipment_collection')
413
+ ->addFieldToFilter('entity_id', array('in' => $ids));
414
+ }
415
+ }
416
+ elseif ($request->has('order_ids')) {
417
+ $ids = $request->getParam('order_ids');
418
+ array_filter($ids, 'intval');
419
+ if (!empty($ids)) {
420
+ $shipmentCollection = Mage::getResourceModel('sales/order_shipment_collection')
421
+ ->setOrderFilter(array('in' => $ids));
422
+ }
 
 
 
423
  }
424
 
425
  return $shipmentCollection;
app/code/community/Transsmart/Shipping/etc/config.xml CHANGED
@@ -9,7 +9,7 @@
9
  <config>
10
  <modules>
11
  <Transsmart_Shipping>
12
- <version>1.0.2</version>
13
  </Transsmart_Shipping>
14
  </modules>
15
  <global>
@@ -17,11 +17,18 @@
17
  <transsmart_shipping>
18
  <class>Transsmart_Shipping_Block</class>
19
  </transsmart_shipping>
 
 
 
 
 
20
  <adminhtml>
21
  <rewrite>
22
  <sales_order_grid>Transsmart_Shipping_Block_Adminhtml_Sales_Order_Grid</sales_order_grid>
 
23
  <sales_order_view_tab_shipments>Transsmart_Shipping_Block_Adminhtml_Sales_Order_View_Tab_Shipments</sales_order_view_tab_shipments>
24
  <sales_shipment_grid>Transsmart_Shipping_Block_Adminhtml_Sales_Shipment_Grid</sales_shipment_grid>
 
25
  </rewrite>
26
  </adminhtml>
27
  </blocks>
@@ -70,11 +77,27 @@
70
  </costcenter>
71
  </entities>
72
  </transsmart_shipping_resource>
 
 
 
 
 
 
73
  <sales_resource>
74
  <rewrite>
75
  <order>Transsmart_Shipping_Model_Sales_Resource_Order</order>
76
  </rewrite>
77
  </sales_resource>
 
 
 
 
 
 
 
 
 
 
78
  </models>
79
  <resources>
80
  <transsmart_shipping_setup>
@@ -154,11 +177,17 @@
154
  <transsmart_servicepoint_id>
155
  <to_order_address>*</to_order_address>
156
  </transsmart_servicepoint_id>
 
 
 
157
  </sales_convert_quote_address>
158
  <sales_convert_order_address>
159
  <transsmart_servicepoint_id>
160
  <to_quote_address>*</to_quote_address>
161
  </transsmart_servicepoint_id>
 
 
 
162
  </sales_convert_order_address>
163
  </fieldsets>
164
  </global>
@@ -283,6 +312,7 @@
283
  <street>1</street>
284
  <streetno>0</streetno>
285
  <street2>2</street2>
 
286
  <country_of_origin>country_of_manufacture</country_of_origin>
287
  </mapping>
288
  </transsmart_shipping>
9
  <config>
10
  <modules>
11
  <Transsmart_Shipping>
12
+ <version>1.0.7</version>
13
  </Transsmart_Shipping>
14
  </modules>
15
  <global>
17
  <transsmart_shipping>
18
  <class>Transsmart_Shipping_Block</class>
19
  </transsmart_shipping>
20
+ <checkout>
21
+ <rewrite>
22
+ <onepage_shipping_method_available>Transsmart_Shipping_Block_Checkout_Onepage_Shipping_Method_Available</onepage_shipping_method_available>
23
+ </rewrite>
24
+ </checkout>
25
  <adminhtml>
26
  <rewrite>
27
  <sales_order_grid>Transsmart_Shipping_Block_Adminhtml_Sales_Order_Grid</sales_order_grid>
28
+ <sales_order_create_shipping_method_form>Transsmart_Shipping_Block_Adminhtml_Sales_Order_Create_Shipping_Method_Form</sales_order_create_shipping_method_form>
29
  <sales_order_view_tab_shipments>Transsmart_Shipping_Block_Adminhtml_Sales_Order_View_Tab_Shipments</sales_order_view_tab_shipments>
30
  <sales_shipment_grid>Transsmart_Shipping_Block_Adminhtml_Sales_Shipment_Grid</sales_shipment_grid>
31
+ <shipping_carrier_tablerate_grid>Transsmart_Shipping_Block_Adminhtml_Shipping_Carrier_Tablerate_Grid</shipping_carrier_tablerate_grid>
32
  </rewrite>
33
  </adminhtml>
34
  </blocks>
77
  </costcenter>
78
  </entities>
79
  </transsmart_shipping_resource>
80
+ <sales>
81
+ <rewrite>
82
+ <quote_address_rate>Transsmart_Shipping_Model_Sales_Quote_Address_Rate</quote_address_rate>
83
+ <quote_address_total_shipping>Transsmart_Shipping_Model_Sales_Quote_Address_Total_Shipping</quote_address_total_shipping>
84
+ </rewrite>
85
+ </sales>
86
  <sales_resource>
87
  <rewrite>
88
  <order>Transsmart_Shipping_Model_Sales_Resource_Order</order>
89
  </rewrite>
90
  </sales_resource>
91
+ <shipping>
92
+ <rewrite>
93
+ <carrier_tablerate>Transsmart_Shipping_Model_Shipping_Carrier_Tablerate</carrier_tablerate>
94
+ </rewrite>
95
+ </shipping>
96
+ <shipping_resource>
97
+ <rewrite>
98
+ <carrier_tablerate>Transsmart_Shipping_Model_Shipping_Resource_Carrier_Tablerate</carrier_tablerate>
99
+ </rewrite>
100
+ </shipping_resource>
101
  </models>
102
  <resources>
103
  <transsmart_shipping_setup>
177
  <transsmart_servicepoint_id>
178
  <to_order_address>*</to_order_address>
179
  </transsmart_servicepoint_id>
180
+ <transsmart_carrierprofile_id>
181
+ <to_order_address>*</to_order_address>
182
+ </transsmart_carrierprofile_id>
183
  </sales_convert_quote_address>
184
  <sales_convert_order_address>
185
  <transsmart_servicepoint_id>
186
  <to_quote_address>*</to_quote_address>
187
  </transsmart_servicepoint_id>
188
+ <transsmart_carrierprofile_id>
189
+ <to_quote_address>*</to_quote_address>
190
+ </transsmart_carrierprofile_id>
191
  </sales_convert_order_address>
192
  </fieldsets>
193
  </global>
312
  <street>1</street>
313
  <streetno>0</streetno>
314
  <street2>2</street2>
315
+ <description>short_description</description>
316
  <country_of_origin>country_of_manufacture</country_of_origin>
317
  </mapping>
318
  </transsmart_shipping>
app/code/community/Transsmart/Shipping/etc/system.xml CHANGED
@@ -8,6 +8,13 @@
8
  -->
9
  <config>
10
  <sections>
 
 
 
 
 
 
 
11
  <transsmart_shipping translate="label">
12
  <label>Transsmart Shipping</label>
13
  <tab>sales</tab>
@@ -193,9 +200,18 @@
193
  <show_in_website>1</show_in_website>
194
  <show_in_store>1</show_in_store>
195
  </street2>
 
 
 
 
 
 
 
 
 
196
  <country_of_origin translate="label">
197
  <label>Country of Origin</label>
198
- <sort_order>40</sort_order>
199
  <frontend_type>select</frontend_type>
200
  <source_model>transsmart_shipping/adminhtml_system_config_source_mapping_attribute</source_model>
201
  <show_in_default>1</show_in_default>
@@ -204,7 +220,7 @@
204
  </country_of_origin>
205
  <hs_code translate="label">
206
  <label>HS Code</label>
207
- <sort_order>50</sort_order>
208
  <frontend_type>select</frontend_type>
209
  <source_model>transsmart_shipping/adminhtml_system_config_source_mapping_attribute</source_model>
210
  <show_in_default>1</show_in_default>
@@ -213,7 +229,7 @@
213
  </hs_code>
214
  <reason_of_export translate="label">
215
  <label>Reason of Export</label>
216
- <sort_order>60</sort_order>
217
  <frontend_type>select</frontend_type>
218
  <source_model>transsmart_shipping/adminhtml_system_config_source_mapping_attribute</source_model>
219
  <show_in_default>1</show_in_default>
@@ -304,14 +320,10 @@
304
  <location_select translate="label">
305
  <label>Use Location Selector</label>
306
  <sort_order>70</sort_order>
307
- <frontend_type>select</frontend_type>
308
- <source_model>adminhtml/system_config_source_yesno</source_model>
309
  <show_in_default>1</show_in_default>
310
- <show_in_website>1</show_in_website>
311
- <show_in_store>1</show_in_store>
312
- <depends>
313
- <method>transsmartpickup</method>
314
- </depends>
315
  </location_select>
316
  </fields>
317
  </template>
8
  -->
9
  <config>
10
  <sections>
11
+ <carriers>
12
+ <groups>
13
+ <tablerate translate="comment">
14
+ <comment>Transsmart extension enabled. This means you can use the extra column 'Transsmart Carrier Profile Id' in the CSV file, and multiple rows with the same value are allowed if they have different Carrier Profile Id's.</comment>
15
+ </tablerate>
16
+ </groups>
17
+ </carriers>
18
  <transsmart_shipping translate="label">
19
  <label>Transsmart Shipping</label>
20
  <tab>sales</tab>
200
  <show_in_website>1</show_in_website>
201
  <show_in_store>1</show_in_store>
202
  </street2>
203
+ <description translate="label">
204
+ <label>Description</label>
205
+ <sort_order>40</sort_order>
206
+ <frontend_type>select</frontend_type>
207
+ <source_model>transsmart_shipping/adminhtml_system_config_source_mapping_attribute</source_model>
208
+ <show_in_default>1</show_in_default>
209
+ <show_in_website>1</show_in_website>
210
+ <show_in_store>1</show_in_store>
211
+ </description>
212
  <country_of_origin translate="label">
213
  <label>Country of Origin</label>
214
+ <sort_order>50</sort_order>
215
  <frontend_type>select</frontend_type>
216
  <source_model>transsmart_shipping/adminhtml_system_config_source_mapping_attribute</source_model>
217
  <show_in_default>1</show_in_default>
220
  </country_of_origin>
221
  <hs_code translate="label">
222
  <label>HS Code</label>
223
+ <sort_order>60</sort_order>
224
  <frontend_type>select</frontend_type>
225
  <source_model>transsmart_shipping/adminhtml_system_config_source_mapping_attribute</source_model>
226
  <show_in_default>1</show_in_default>
229
  </hs_code>
230
  <reason_of_export translate="label">
231
  <label>Reason of Export</label>
232
+ <sort_order>70</sort_order>
233
  <frontend_type>select</frontend_type>
234
  <source_model>transsmart_shipping/adminhtml_system_config_source_mapping_attribute</source_model>
235
  <show_in_default>1</show_in_default>
320
  <location_select translate="label">
321
  <label>Use Location Selector</label>
322
  <sort_order>70</sort_order>
323
+ <frontend_model>transsmart_shipping/adminhtml_system_config_form_field_locationselect</frontend_model>
 
324
  <show_in_default>1</show_in_default>
325
+ <show_in_website>0</show_in_website>
326
+ <show_in_store>0</show_in_store>
 
 
 
327
  </location_select>
328
  </fields>
329
  </template>
app/code/community/Transsmart/Shipping/sql/transsmart_shipping_setup/install-1.0.0.php CHANGED
@@ -31,7 +31,7 @@ $table = $connection->newTable($installer->getTable('transsmart_shipping/carrier
31
  ->addColumn('location_select', Varien_Db_Ddl_Table::TYPE_SMALLINT, null, array(
32
  'nullable' => true,
33
  'unsigned' => true,
34
- ), 'Location Selector Enabled')
35
  ->setComment('Transsmart Carrier');
36
  $connection->createTable($table);
37
 
31
  ->addColumn('location_select', Varien_Db_Ddl_Table::TYPE_SMALLINT, null, array(
32
  'nullable' => true,
33
  'unsigned' => true,
34
+ ), 'Location Selector Available')
35
  ->setComment('Transsmart Carrier');
36
  $connection->createTable($table);
37
 
app/code/community/Transsmart/Shipping/sql/transsmart_shipping_setup/upgrade-1.0.2-1.0.3.php ADDED
@@ -0,0 +1,29 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * @category Transsmart
4
+ * @package Transsmart_Shipping
5
+ * @copyright Copyright (c) 2016 Techtwo Webdevelopment B.V. (http://www.techtwo.nl)
6
+ */
7
+
8
+ /** @var Mage_Core_Model_Resource_Setup $installer */
9
+ $installer = $this;
10
+
11
+ $installer->startSetup();
12
+
13
+ /** @var Magento_Db_Adapter_Pdo_Mysql $connection */
14
+ $connection = $installer->getConnection();
15
+
16
+ // add error to shipment table
17
+ $connection->addColumn(
18
+ $this->getTable('sales/shipment'),
19
+ 'transsmart_shipment_error',
20
+ array(
21
+ 'type' => Varien_Db_Ddl_Table::TYPE_TEXT,
22
+ 'length' => 1024,
23
+ 'nullable' => true,
24
+ 'comment' => 'Transsmart Shipment Error',
25
+ 'after' => 'transsmart_status'
26
+ )
27
+ );
28
+
29
+ $installer->endSetup();
app/code/community/Transsmart/Shipping/sql/transsmart_shipping_setup/upgrade-1.0.3-1.0.4.php ADDED
@@ -0,0 +1,94 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * @category Transsmart
4
+ * @package Transsmart_Shipping
5
+ * @copyright Copyright (c) 2016 Techtwo Webdevelopment B.V. (http://www.techtwo.nl)
6
+ */
7
+
8
+ /** @var Mage_Core_Model_Resource_Setup $installer */
9
+ $installer = $this;
10
+
11
+ $installer->startSetup();
12
+
13
+ /** @var Magento_Db_Adapter_Pdo_Mysql $connection */
14
+ $connection = $installer->getConnection();
15
+
16
+ // add final carrier to shipment table
17
+ $connection->addColumn(
18
+ $this->getTable('sales/shipment'),
19
+ 'transsmart_final_carrier_id',
20
+ array(
21
+ 'type' => Varien_Db_Ddl_Table::TYPE_INTEGER,
22
+ 'unsigned' => true,
23
+ 'nullable' => true,
24
+ 'comment' => 'Transsmart Final Carrier Id'
25
+ )
26
+ );
27
+ $connection->addForeignKey(
28
+ $installer->getFkName(
29
+ 'sales/shipment',
30
+ 'transsmart_final_carrier_id',
31
+ 'transsmart_shipping/carrier',
32
+ 'carrier_id'
33
+ ),
34
+ $this->getTable('sales/shipment'),
35
+ 'transsmart_final_carrier_id',
36
+ $installer->getTable('transsmart_shipping/carrier'),
37
+ 'carrier_id',
38
+ Varien_Db_Ddl_Table::ACTION_SET_NULL,
39
+ Varien_Db_Ddl_Table::ACTION_CASCADE
40
+ );
41
+
42
+ // add final servicelevel time to shipment table
43
+ $connection->addColumn(
44
+ $this->getTable('sales/shipment'),
45
+ 'transsmart_final_servicelevel_time_id',
46
+ array(
47
+ 'type' => Varien_Db_Ddl_Table::TYPE_INTEGER,
48
+ 'unsigned' => true,
49
+ 'nullable' => true,
50
+ 'comment' => 'Transsmart Final Servicelevel Time Id'
51
+ )
52
+ );
53
+ $connection->addForeignKey(
54
+ $installer->getFkName(
55
+ 'sales/shipment',
56
+ 'transsmart_final_servicelevel_time_id',
57
+ 'transsmart_shipping/servicelevel_time',
58
+ 'servicelevel_time_id'
59
+ ),
60
+ $this->getTable('sales/shipment'),
61
+ 'transsmart_final_servicelevel_time_id',
62
+ $installer->getTable('transsmart_shipping/servicelevel_time'),
63
+ 'servicelevel_time_id',
64
+ Varien_Db_Ddl_Table::ACTION_SET_NULL,
65
+ Varien_Db_Ddl_Table::ACTION_CASCADE
66
+ );
67
+
68
+ // add final servicelevel other to shipment table
69
+ $connection->addColumn(
70
+ $this->getTable('sales/shipment'),
71
+ 'transsmart_final_servicelevel_other_id',
72
+ array(
73
+ 'type' => Varien_Db_Ddl_Table::TYPE_INTEGER,
74
+ 'unsigned' => true,
75
+ 'nullable' => true,
76
+ 'comment' => 'Transsmart Final Servicelevel Other Id'
77
+ )
78
+ );
79
+ $connection->addForeignKey(
80
+ $installer->getFkName(
81
+ 'sales/shipment',
82
+ 'transsmart_final_servicelevel_other_id',
83
+ 'transsmart_shipping/servicelevel_other',
84
+ 'servicelevel_other_id'
85
+ ),
86
+ $this->getTable('sales/shipment'),
87
+ 'transsmart_final_servicelevel_other_id',
88
+ $installer->getTable('transsmart_shipping/servicelevel_other'),
89
+ 'servicelevel_other_id',
90
+ Varien_Db_Ddl_Table::ACTION_SET_NULL,
91
+ Varien_Db_Ddl_Table::ACTION_CASCADE
92
+ );
93
+
94
+ $installer->endSetup();
app/code/community/Transsmart/Shipping/sql/transsmart_shipping_setup/upgrade-1.0.4-1.0.5.php ADDED
@@ -0,0 +1,120 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * @category Transsmart
4
+ * @package Transsmart_Shipping
5
+ * @copyright Copyright (c) 2016 Techtwo Webdevelopment B.V. (http://www.techtwo.nl)
6
+ */
7
+
8
+ /** @var Mage_Core_Model_Resource_Setup $installer */
9
+ $installer = $this;
10
+
11
+ $installer->startSetup();
12
+
13
+ /** @var Magento_Db_Adapter_Pdo_Mysql $connection */
14
+ $connection = $installer->getConnection();
15
+
16
+ // add carrierprofile id to tablerate table
17
+ $connection->addColumn(
18
+ $this->getTable('shipping/tablerate'),
19
+ 'transsmart_carrierprofile_id',
20
+ array(
21
+ 'type' => Varien_Db_Ddl_Table::TYPE_INTEGER,
22
+ 'unsigned' => true,
23
+ 'nullable' => true,
24
+ 'comment' => 'Transsmart Carrierprofile Id'
25
+ )
26
+ );
27
+ $connection->addForeignKey(
28
+ $installer->getFkName(
29
+ 'shipping/tablerate',
30
+ 'transsmart_carrierprofile_id',
31
+ 'transsmart_shipping/carrier',
32
+ 'carrierprofile_id'
33
+ ),
34
+ $this->getTable('shipping/tablerate'),
35
+ 'transsmart_carrierprofile_id',
36
+ $installer->getTable('transsmart_shipping/carrierprofile'),
37
+ 'carrierprofile_id',
38
+ Varien_Db_Ddl_Table::ACTION_SET_NULL,
39
+ Varien_Db_Ddl_Table::ACTION_CASCADE
40
+ );
41
+
42
+ // add carrierprofile id to quote shipping rate table
43
+ $connection->addColumn(
44
+ $this->getTable('sales/quote_address_shipping_rate'),
45
+ 'transsmart_carrierprofile_id',
46
+ array(
47
+ 'type' => Varien_Db_Ddl_Table::TYPE_INTEGER,
48
+ 'unsigned' => true,
49
+ 'nullable' => true,
50
+ 'comment' => 'Transsmart Carrierprofile Id'
51
+ )
52
+ );
53
+ $connection->addForeignKey(
54
+ $installer->getFkName(
55
+ 'sales/quote_address_shipping_rate',
56
+ 'transsmart_carrierprofile_id',
57
+ 'transsmart_shipping/carrier',
58
+ 'carrierprofile_id'
59
+ ),
60
+ $this->getTable('sales/quote_address_shipping_rate'),
61
+ 'transsmart_carrierprofile_id',
62
+ $installer->getTable('transsmart_shipping/carrierprofile'),
63
+ 'carrierprofile_id',
64
+ Varien_Db_Ddl_Table::ACTION_SET_NULL,
65
+ Varien_Db_Ddl_Table::ACTION_CASCADE
66
+ );
67
+
68
+ // add carrierprofile id to quote address table
69
+ $connection->addColumn(
70
+ $this->getTable('sales/quote_address'),
71
+ 'transsmart_carrierprofile_id',
72
+ array(
73
+ 'type' => Varien_Db_Ddl_Table::TYPE_INTEGER,
74
+ 'unsigned' => true,
75
+ 'nullable' => true,
76
+ 'comment' => 'Transsmart Carrierprofile Id'
77
+ )
78
+ );
79
+ $connection->addForeignKey(
80
+ $installer->getFkName(
81
+ 'sales/quote_address',
82
+ 'transsmart_carrierprofile_id',
83
+ 'transsmart_shipping/carrier',
84
+ 'carrierprofile_id'
85
+ ),
86
+ $this->getTable('sales/quote_address'),
87
+ 'transsmart_carrierprofile_id',
88
+ $installer->getTable('transsmart_shipping/carrierprofile'),
89
+ 'carrierprofile_id',
90
+ Varien_Db_Ddl_Table::ACTION_SET_NULL,
91
+ Varien_Db_Ddl_Table::ACTION_CASCADE
92
+ );
93
+
94
+ // add carrierprofile id to order address table
95
+ $connection->addColumn(
96
+ $this->getTable('sales/order_address'),
97
+ 'transsmart_carrierprofile_id',
98
+ array(
99
+ 'type' => Varien_Db_Ddl_Table::TYPE_INTEGER,
100
+ 'unsigned' => true,
101
+ 'nullable' => true,
102
+ 'comment' => 'Transsmart Carrierprofile Id'
103
+ )
104
+ );
105
+ $connection->addForeignKey(
106
+ $installer->getFkName(
107
+ 'sales/order_address',
108
+ 'transsmart_carrierprofile_id',
109
+ 'transsmart_shipping/carrier',
110
+ 'carrierprofile_id'
111
+ ),
112
+ $this->getTable('sales/order_address'),
113
+ 'transsmart_carrierprofile_id',
114
+ $installer->getTable('transsmart_shipping/carrierprofile'),
115
+ 'carrierprofile_id',
116
+ Varien_Db_Ddl_Table::ACTION_SET_NULL,
117
+ Varien_Db_Ddl_Table::ACTION_CASCADE
118
+ );
119
+
120
+ $installer->endSetup();
app/code/community/Transsmart/Shipping/sql/transsmart_shipping_setup/upgrade-1.0.5-1.0.6.php ADDED
@@ -0,0 +1,28 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * @category Transsmart
4
+ * @package Transsmart_Shipping
5
+ * @copyright Copyright (c) 2016 Techtwo Webdevelopment B.V. (http://www.techtwo.nl)
6
+ */
7
+
8
+ /** @var Mage_Core_Model_Resource_Setup $installer */
9
+ $installer = $this;
10
+
11
+ $installer->startSetup();
12
+
13
+ /** @var Magento_Db_Adapter_Pdo_Mysql $connection */
14
+ $connection = $installer->getConnection();
15
+
16
+ // add enable_location_select to carrierprofile table
17
+ $connection->addColumn(
18
+ $this->getTable('transsmart_shipping/carrierprofile'),
19
+ 'enable_location_select',
20
+ array(
21
+ 'type' => Varien_Db_Ddl_Table::TYPE_SMALLINT,
22
+ 'nullable' => true,
23
+ 'unsigned' => true,
24
+ 'comment' => 'Location Selector Enabled'
25
+ )
26
+ );
27
+
28
+ $installer->endSetup();
app/code/community/Transsmart/Shipping/sql/transsmart_shipping_setup/upgrade-1.0.6-1.0.7.php ADDED
@@ -0,0 +1,38 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * @category Transsmart
4
+ * @package Transsmart_Shipping
5
+ * @copyright Copyright (c) 2016 Techtwo Webdevelopment B.V. (http://www.techtwo.nl)
6
+ */
7
+
8
+ /** @var Mage_Core_Model_Resource_Setup $installer */
9
+ $installer = $this;
10
+
11
+ $installer->startSetup();
12
+
13
+ /** @var Magento_Db_Adapter_Pdo_Mysql $connection */
14
+ $connection = $installer->getConnection();
15
+
16
+ // remove unique index from tablerate table
17
+ $connection->dropIndex(
18
+ $installer->getTable('shipping/tablerate'),
19
+ $installer->getIdxName(
20
+ 'shipping/tablerate',
21
+ array('website_id', 'dest_country_id', 'dest_region_id', 'dest_zip', 'condition_name', 'condition_value'),
22
+ Varien_Db_Adapter_Interface::INDEX_TYPE_UNIQUE
23
+ )
24
+ );
25
+
26
+ // add new unique index to tablerate table
27
+ $connection->addIndex(
28
+ $installer->getTable('shipping/tablerate'),
29
+ $installer->getIdxName(
30
+ 'shipping/tablerate',
31
+ array('website_id', 'dest_country_id', 'dest_region_id', 'dest_zip', 'condition_name', 'condition_value', 'transsmart_carrierprofile_id'),
32
+ Varien_Db_Adapter_Interface::INDEX_TYPE_UNIQUE
33
+ ),
34
+ array('website_id', 'dest_country_id', 'dest_region_id', 'dest_zip', 'condition_name', 'condition_value', 'transsmart_carrierprofile_id'),
35
+ Varien_Db_Adapter_Interface::INDEX_TYPE_UNIQUE
36
+ );
37
+
38
+ $installer->endSetup();
app/design/adminhtml/base/default/layout/transsmart_shipping.xml CHANGED
@@ -14,8 +14,8 @@
14
  </action>
15
  </reference>
16
  <reference name="content">
17
- <block type="adminhtml/template" name="transsmart_shipping.pickup.address_container"
18
- template="transsmart/shipping/sales/order/address/form/container.phtml"/>
19
  </reference>
20
  </adminhtml_sales_order_view>
21
 
14
  </action>
15
  </reference>
16
  <reference name="content">
17
+ <block type="transsmart_shipping/adminhtml_sales_order_view_detail"
18
+ name="transsmart_shipping.pickup.address_container" />
19
  </reference>
20
  </adminhtml_sales_order_view>
21
 
app/design/adminhtml/base/default/template/transsmart/shipping/location/selector.phtml CHANGED
@@ -64,9 +64,11 @@
64
  'Opening hours:', '<?php echo $this->jsQuoteEscape($this->__('Opening hours:')); ?>'
65
  ]);
66
  var transsmartShippingPickup = new Transsmart.Shipping.PickupAdmin({
67
- lookupUrl: '<?php echo $this->getUrl('*/transsmart_shipping_location/lookup'); ?>',
68
- carrierProfileIds: <?php echo Zend_Json_Encoder::encode($helper->getLocationSelectCarrierProfiles()); ?>
69
  });
 
 
 
70
  </script>
71
 
72
  <script src="https://maps.googleapis.com/maps/api/js?callback=transsmartShippingPickup.googleMapsLoaded&libraries=geometry"></script>
64
  'Opening hours:', '<?php echo $this->jsQuoteEscape($this->__('Opening hours:')); ?>'
65
  ]);
66
  var transsmartShippingPickup = new Transsmart.Shipping.PickupAdmin({
67
+ lookupUrl: '<?php echo $this->getUrl('*/transsmart_shipping_location/lookup'); ?>'
 
68
  });
69
+ if (typeof transsmartShippingPickupMethods != 'undefined') {
70
+ transsmartShippingPickup.setMethods(transsmartShippingPickupMethods);
71
+ }
72
  </script>
73
 
74
  <script src="https://maps.googleapis.com/maps/api/js?callback=transsmartShippingPickup.googleMapsLoaded&libraries=geometry"></script>
app/design/adminhtml/base/default/template/transsmart/shipping/sales/order/address/form/container.phtml CHANGED
@@ -5,45 +5,59 @@
5
  * @copyright Copyright (c) 2016 Techtwo Webdevelopment B.V. (http://www.techtwo.nl)
6
  */
7
  ?>
8
- <?php $_helper = Mage::helper('transsmart_shipping'); ?>
9
- <?php $_order = Mage::registry('current_order'); ?>
10
-
11
- <?php if (!$_helper->isTranssmartShippingMethod($_order->getShippingMethod())): ?>
12
- <?php return ''; ?>
13
- <?php endif; ?>
14
-
15
- <?php $_pickupAddress = Mage::helper('transsmart_shipping/pickupaddress')->getPickupAddressFromOrder($_order); ?>
16
- <?php if (!$_pickupAddress): ?>
17
- <?php return ''; ?>
18
- <?php endif; ?>
19
-
20
  <div class="three-column box-right" id="transsmart_pickup_address">
21
  <!--Transsmart Pickup Address-->
22
  <div class="entry-edit">
23
  <div class="entry-edit-head">
24
  <h4 class="icon-head head-transsmart-pickup-address"><?php echo $this->__('Pickup Address'); ?></h4>
 
25
  <div class="tools"><a href="<?php echo $this->getUrl('adminhtml/sales_order/address', array('address_id' => $_pickupAddress->getId())); ?>"><?php echo $this->__('Edit'); ?></a></div>
 
26
  </div>
27
  <fieldset>
28
  <address><?php echo $_pickupAddress->format('html'); ?></address>
29
  </fieldset>
30
  </div>
31
  </div>
 
 
 
 
 
 
 
 
 
 
 
 
 
32
 
33
  <script type="text/javascript">
34
  //<[CDATA[
35
  document.observe('dom:loaded', function() {
 
36
  var billingAddress = $$('#sales_order_view_tabs_order_info_content .box-left')[1];
37
  var shippingAddress = $$('#sales_order_view_tabs_order_info_content .box-right')[1];
38
 
39
  billingAddress.addClassName('three-column');
40
  shippingAddress.addClassName('three-column box-middle')
41
  .removeClassName('box-right')
42
- .insert(
43
- {
44
- after : $('transsmart_pickup_address')
45
  }
46
  );
 
 
 
 
 
 
 
 
47
  });
48
  //]]>
49
  </script>
5
  * @copyright Copyright (c) 2016 Techtwo Webdevelopment B.V. (http://www.techtwo.nl)
6
  */
7
  ?>
8
+ <?php /** @var Transsmart_Shipping_Block_Adminhtml_Sales_Order_View_Detail $this */ ?>
9
+ <?php $_pickupAddress = $this->getPickupAddress(); ?>
10
+ <?php if ($_pickupAddress): ?>
 
 
 
 
 
 
 
 
 
11
  <div class="three-column box-right" id="transsmart_pickup_address">
12
  <!--Transsmart Pickup Address-->
13
  <div class="entry-edit">
14
  <div class="entry-edit-head">
15
  <h4 class="icon-head head-transsmart-pickup-address"><?php echo $this->__('Pickup Address'); ?></h4>
16
+ <?php if ($this->allowChangePickupAddress()): ?>
17
  <div class="tools"><a href="<?php echo $this->getUrl('adminhtml/sales_order/address', array('address_id' => $_pickupAddress->getId())); ?>"><?php echo $this->__('Edit'); ?></a></div>
18
+ <?php endif; ?>
19
  </div>
20
  <fieldset>
21
  <address><?php echo $_pickupAddress->format('html'); ?></address>
22
  </fieldset>
23
  </div>
24
  </div>
25
+ <?php endif; ?>
26
+
27
+ <div id="transsmart_shipment_detail">
28
+ <table cellspacing="0" class="form-list transsmart-shipment-detail">
29
+ <tbody>
30
+ <tr>
31
+ <td class="label"><label for="tss_carrierprofile"><?php echo $this->__('Carrier Profile'); ?></label></td>
32
+ <td class="value" colspan="3">
33
+ <strong><?php echo $this->escapeHtml($this->getCarrierprofile()); ?></strong>
34
+ </td>
35
+ </tr>
36
+ </table>
37
+ </div>
38
 
39
  <script type="text/javascript">
40
  //<[CDATA[
41
  document.observe('dom:loaded', function() {
42
+ <?php if ($_pickupAddress): ?>
43
  var billingAddress = $$('#sales_order_view_tabs_order_info_content .box-left')[1];
44
  var shippingAddress = $$('#sales_order_view_tabs_order_info_content .box-right')[1];
45
 
46
  billingAddress.addClassName('three-column');
47
  shippingAddress.addClassName('three-column box-middle')
48
  .removeClassName('box-right')
49
+ .insert({
50
+ after: $('transsmart_pickup_address')
 
51
  }
52
  );
53
+ <?php endif; ?>
54
+
55
+ var shippingMethod = $$('#sales_order_view_tabs_order_info_content .head-shipping-method')[0];
56
+ if (shippingMethod) {
57
+ shippingMethod.up('.entry-edit').down('fieldset').insert({
58
+ bottom: $('transsmart_shipment_detail')
59
+ });
60
+ }
61
  });
62
  //]]>
63
  </script>
app/design/adminhtml/base/default/template/transsmart/shipping/sales/order/shipment/address/form/container.phtml CHANGED
@@ -11,7 +11,7 @@
11
  <?php $_shipment = Mage::registry('current_shipment'); ?>
12
  <?php $_order = $_shipment->getOrder(); ?>
13
 
14
- <?php if (!$_helper->isTranssmartShippingMethod($_order->getShippingMethod())): ?>
15
  <?php return ''; ?>
16
  <?php endif; ?>
17
 
11
  <?php $_shipment = Mage::registry('current_shipment'); ?>
12
  <?php $_order = $_shipment->getOrder(); ?>
13
 
14
+ <?php if (!$_helper->isTranssmartOrder($_order)): ?>
15
  <?php return ''; ?>
16
  <?php endif; ?>
17
 
app/design/adminhtml/base/default/template/transsmart/shipping/sales/order/shipment/create/detail.phtml CHANGED
@@ -73,17 +73,20 @@
73
  <script type="text/javascript">
74
  //<![CDATA[
75
  (function () {
76
- var origCarrierprofileId = $('tss_carrierprofile').value, confirmed = false;
77
- $('tss_carrierprofile').observe('change', function () {
78
- if (this.value != origCarrierprofileId && !confirmed) {
79
- if (confirm('<?php echo $this->jsQuoteEscape($this->__('Please note! The carrier profile will be changed. This change will NOT be made to the Magento order. This could affect the calculated shipping costs and tracking and tracing emails. Do you want to continue?')); ?>')) {
80
- confirmed = true;
 
 
 
 
 
 
81
  }
82
- else {
83
- this.value = origCarrierprofileId;
84
- }
85
- }
86
- });
87
  })();
88
  //]]>
89
  </script>
73
  <script type="text/javascript">
74
  //<![CDATA[
75
  (function () {
76
+ var selectCarrierprofile = $('tss_carrierprofile');
77
+ if (selectCarrierprofile) {
78
+ var origCarrierprofileId = selectCarrierprofile.value, confirmed = false;
79
+ selectCarrierprofile.observe('change', function () {
80
+ if (this.value != origCarrierprofileId && !confirmed) {
81
+ if (confirm('<?php echo $this->jsQuoteEscape($this->__('Please note! The carrier profile will be changed. This change will NOT be made to the Magento order. This could affect the calculated shipping costs and tracking and tracing emails. Do you want to continue?')); ?>')) {
82
+ confirmed = true;
83
+ }
84
+ else {
85
+ this.value = origCarrierprofileId;
86
+ }
87
  }
88
+ });
89
+ }
 
 
 
90
  })();
91
  //]]>
92
  </script>
app/design/adminhtml/base/default/template/transsmart/shipping/sales/order/shipment/view/detail.phtml CHANGED
@@ -9,8 +9,14 @@
9
  <table cellspacing="0" class="form-list transsmart-shipment-detail">
10
  <tbody>
11
  <tr>
12
- <td class="label"><label><?php echo $this->escapeHtml($this->__('Carrier Profile')); ?></label></td>
13
- <td class="value" colspan="3"><strong><?php echo $this->escapeHtml($this->getCarrierprofile()); ?></strong></td>
 
 
 
 
 
 
14
  </tr>
15
  <tr>
16
  <td class="label"><label><?php echo $this->escapeHtml($this->__('Shipment Location')); ?></label></td>
@@ -29,6 +35,16 @@
29
 
30
  <?php echo $this->getChildHtml('package'); ?>
31
 
 
 
 
 
 
 
 
 
 
 
32
  <table cellspacing="0" class="form-list transsmart-shipment-detail-extra">
33
  <tbody>
34
  <tr>
9
  <table cellspacing="0" class="form-list transsmart-shipment-detail">
10
  <tbody>
11
  <tr>
12
+ <td class="label"><label><?php echo $this->escapeHtml($this->__('Executing Carrier')); ?></label></td>
13
+ <td class="value" colspan="3"><strong><?php echo $this->escapeHtml($this->getCarrier()); ?></strong></td>
14
+ </tr>
15
+ <tr>
16
+ <td class="label"><label><?php echo $this->escapeHtml($this->__('Servicelevel Time')); ?></label></td>
17
+ <td class="value"><strong><?php echo $this->escapeHtml($this->getServicelevelTime()); ?></strong></td>
18
+ <td class="label"><label><?php echo $this->escapeHtml($this->__('Servicelevel Other')); ?></label></td>
19
+ <td class="value"><strong><?php echo $this->escapeHtml($this->getServicelevelOther()); ?></strong></td>
20
  </tr>
21
  <tr>
22
  <td class="label"><label><?php echo $this->escapeHtml($this->__('Shipment Location')); ?></label></td>
35
 
36
  <?php echo $this->getChildHtml('package'); ?>
37
 
38
+ <?php if (($shipmentError = $this->getShipment()->getTranssmartShipmentError())): ?>
39
+ <ul class="messages">
40
+ <li class="error-msg">
41
+ <ul>
42
+ <li><span><?php echo $this->escapeHtml($shipmentError); ?></span></li>
43
+ </ul>
44
+ </li>
45
+ </ul>
46
+ <?php endif; ?>
47
+
48
  <table cellspacing="0" class="form-list transsmart-shipment-detail-extra">
49
  <tbody>
50
  <tr>
app/design/frontend/base/default/template/transsmart/shipping/location/selector.phtml CHANGED
@@ -57,9 +57,11 @@
57
 
58
  <script type="text/javascript">
59
  var transsmartShippingPickup = new Transsmart.Shipping.Pickup({
60
- lookupUrl: '<?php echo $this->getUrl('transsmart_shipping/location/lookup'); ?>',
61
- carrierProfileIds: <?php echo Zend_Json_Encoder::encode($helper->getLocationSelectCarrierProfiles()); ?>
62
  });
 
 
 
63
  </script>
64
 
65
  <script src="https://maps.googleapis.com/maps/api/js?callback=transsmartShippingPickup.googleMapsLoaded&libraries=geometry"></script>
57
 
58
  <script type="text/javascript">
59
  var transsmartShippingPickup = new Transsmart.Shipping.Pickup({
60
+ lookupUrl: '<?php echo $this->getUrl('transsmart_shipping/location/lookup'); ?>'
 
61
  });
62
+ if (typeof transsmartShippingPickupMethods != 'undefined') {
63
+ transsmartShippingPickup.setMethods(transsmartShippingPickupMethods);
64
+ }
65
  </script>
66
 
67
  <script src="https://maps.googleapis.com/maps/api/js?callback=transsmartShippingPickup.googleMapsLoaded&libraries=geometry"></script>
app/design/frontend/base/default/template/transsmart/shipping/onepage/progress/pickup.phtml CHANGED
@@ -8,10 +8,9 @@
8
  <?php /** @var Mage_Checkout_Block_Onepage_Progress $this */ ?>
9
  <?php $_helper = Mage::helper('transsmart_shipping'); ?>
10
  <?php $_quote = $this->getQuote(); ?>
11
- <?php $_shippingAddress = $_quote->getShippingAddress(); ?>
12
  <?php $_pickupLocation = Mage::helper('transsmart_shipping/pickupaddress')->getPickupAddressFromQuote($_quote); ?>
13
 
14
- <?php if (!$_helper->isTranssmartShippingMethod($_shippingAddress->getShippingMethod()) || !$_pickupLocation): ?>
15
  <?php return ''; ?>
16
  <?php endif; ?>
17
 
8
  <?php /** @var Mage_Checkout_Block_Onepage_Progress $this */ ?>
9
  <?php $_helper = Mage::helper('transsmart_shipping'); ?>
10
  <?php $_quote = $this->getQuote(); ?>
 
11
  <?php $_pickupLocation = Mage::helper('transsmart_shipping/pickupaddress')->getPickupAddressFromQuote($_quote); ?>
12
 
13
+ <?php if (!$_helper->isTranssmartQuote($_quote) || !$_pickupLocation): ?>
14
  <?php return ''; ?>
15
  <?php endif; ?>
16
 
app/locale/nl_NL/Transsmart_Shipping.csv CHANGED
@@ -51,6 +51,7 @@
51
  "Use Location Selector","Gebruik locatiekiezer"
52
  "Delivery","Bezorging"
53
  "Pickup","Afhalen"
 
54
  "Location selector not available for this shipping method.","Locatiekiezer is niet beschikbaar voor deze verzendmethode."
55
  "Zipcode, city and country are required.","Postcode, plaats en land zijn vereist."
56
  "Opening hours:","Openingstijden:"
@@ -67,7 +68,8 @@
67
  "Pending","Wachtende"
68
  "Partially Exported","Gedeeltelijk geëxporteerd"
69
  "Exported","Geëxporteerd"
70
- "Error","Foutmelding"
 
71
  "Transsmart: Create Shipment(s)","Transsmart: Zending(en) aanmaken"
72
  "Transsmart: Book & Print","Transsmart: Boeken & Printen"
73
  "Transsmart: Book Shipment(s)","Transsmart: Zending(en) boeken"
@@ -117,3 +119,8 @@
117
  "Please add at lease one package.","Voeg ten minste één regel toe alstublieft."
118
  "Please note! The carrier profile will be changed. This change will NOT be made to the Magento order. This could affect the calculated shipping costs and tracking and tracing emails. Do you want to continue?","Let op! Het vervoerdersprofiel wordt nu gewijzigd. Deze wijziging wordt NIET doorgevoerd in de Magento bestelling. Dit heeft mogelijk invloed op de berekende verzendkosten en tracking en tracing mails. Wilt u doorgaan?"
119
  "This does not affect shipments using a pickup option.","Heeft geen invloed op zendingen met een afhaaloptie."
 
 
 
 
 
51
  "Use Location Selector","Gebruik locatiekiezer"
52
  "Delivery","Bezorging"
53
  "Pickup","Afhalen"
54
+ "Location selector not available for this carrier profile.","Locatiekiezer is niet beschikbaar voor deze vervoerdersprofiel."
55
  "Location selector not available for this shipping method.","Locatiekiezer is niet beschikbaar voor deze verzendmethode."
56
  "Zipcode, city and country are required.","Postcode, plaats en land zijn vereist."
57
  "Opening hours:","Openingstijden:"
68
  "Pending","Wachtende"
69
  "Partially Exported","Gedeeltelijk geëxporteerd"
70
  "Exported","Geëxporteerd"
71
+ "Error","Fout"
72
+ "Unknown error","Onbekende fout"
73
  "Transsmart: Create Shipment(s)","Transsmart: Zending(en) aanmaken"
74
  "Transsmart: Book & Print","Transsmart: Boeken & Printen"
75
  "Transsmart: Book Shipment(s)","Transsmart: Zending(en) boeken"
119
  "Please add at lease one package.","Voeg ten minste één regel toe alstublieft."
120
  "Please note! The carrier profile will be changed. This change will NOT be made to the Magento order. This could affect the calculated shipping costs and tracking and tracing emails. Do you want to continue?","Let op! Het vervoerdersprofiel wordt nu gewijzigd. Deze wijziging wordt NIET doorgevoerd in de Magento bestelling. Dit heeft mogelijk invloed op de berekende verzendkosten en tracking en tracing mails. Wilt u doorgaan?"
121
  "This does not affect shipments using a pickup option.","Heeft geen invloed op zendingen met een afhaaloptie."
122
+ "Executing Carrier","Uitvoerende vervoerder"
123
+ "Transsmart Carrier Profile Id","Transsmart Vervoerdersprofiel Id"
124
+ "Invalid Transsmart Carrier Profile Id ""%s"" in the Row #%s.","Ongeldig Transsmart vervoerdersprofiel Id ""%s"" in regel #%s."
125
+ "Duplicate Row #%s (Country ""%s"", Region/State ""%s"", Zip ""%s"", Value ""%s"" and Transsmart Carrier Profile Id ""%s"").","Dubbele regel #%s (Land ""%s"", Regio/Staat ""%s"", Postcode ""%s"", Waarde ""%s"" en Transsmart vervoerdersprofiel Id ""%s"")."
126
+ "Transsmart extension enabled. This means you can use the extra column 'Transsmart Carrier Profile Id' in the CSV file, and multiple rows with the same value are allowed if they have different Carrier Profile Id's.","Transsmart extensie ingeschakeld. Dit betekent dat u de extra kolom 'Transsmart Vervoerdersprofiel Id' in het CSV-bestand kunt gebruiken, en meerdere regels met dezelfde waarde zijn toegestaan indien ze verschillende vervoerdersprofiel Id's hebben."
js/transsmart/shipping/admin/pickup_selector.js CHANGED
@@ -22,35 +22,34 @@ Transsmart.Shipping.PickupAdmin = Class.create(Transsmart.Shipping.Pickup, {
22
 
23
  // Wait for the document to load
24
  document.observe('dom:loaded', function() {
25
- self.detectCheckedShippingMethod();
26
-
27
- // Add our customer validator
28
  self.addValidators();
29
 
30
  var parentSetShippingMethod = order.setShippingMethod.bind(order);
31
 
32
  // Override the setShippingMethod, since we need it to determine when a shipping method was clicked
33
  order.setShippingMethod = function(value) {
34
- // Check to see if this is a pickup profile that allows a location selector
35
- var valueBits = value.match(/transsmartpickup_carrierprofile_([0-9]+)/);
36
 
37
- // Nothing to attach, it doesn't match
38
- if (valueBits == null || valueBits.length != 2) {
 
 
39
  return parentSetShippingMethod(value);
40
  }
41
 
42
- // Not a carrierprofile that has location selector enabled
43
- if (self.config.carrierProfileIds.indexOf(valueBits[1]) == -1) {
44
- Transsmart.Logger.log('Carrier profile with id: ' + valueBits[1] + ' does not allow location selector');
45
- Transsmart.Logger.log('Allowed location selectors are: ', self.config.carrierProfileIds);
46
- return parentSetShippingMethod(value);
47
- }
48
 
49
- self.selectedShippingMethod = value;
50
  if (self.selectedShippingMethod != self.origShippingMethod) {
51
  $('tss-ls-admin-selected-location').update('');
52
  }
53
  self.attachPickupDiv($('s_method_' + value));
 
 
 
 
 
54
  };
55
 
56
  // We need to move the container to after the anchor-content, so it lines up correctly
@@ -62,26 +61,14 @@ Transsmart.Shipping.PickupAdmin = Class.create(Transsmart.Shipping.Pickup, {
62
  self.selectLocationAndClose();
63
  event.stop();
64
  });
65
-
66
- var parentLoadAreaResponseHandler = order.loadAreaResponseHandler.bind(order);
67
-
68
- // Override the area response handler so that we can detect which shipping method is selected
69
- order.loadAreaResponseHandler = function(response) {
70
- parentLoadAreaResponseHandler(response);
71
- self.detectCheckedShippingMethod();
72
- }
73
  });
74
  },
75
 
76
- detectCheckedShippingMethod: function() {
77
- var checkedShippingMethod = $$('input[name="order[shipping_method]"]:checked');
78
-
79
- if (checkedShippingMethod.length > 0) {
80
- var checkedShippingMethodValue = checkedShippingMethod[0].value;
81
- if (/transsmartpickup_carrierprofile_[0-9]+/.test(checkedShippingMethodValue)) {
82
- this.selectedShippingMethod = checkedShippingMethodValue;
83
- this.attachPickupDiv($('s_method_' + checkedShippingMethodValue));
84
- }
85
  }
86
  },
87
 
@@ -120,9 +107,9 @@ Transsmart.Shipping.PickupAdmin = Class.create(Transsmart.Shipping.Pickup, {
120
  Translator.translate("A pickup location has to be selected"),
121
  function(v) {
122
  return $('order-shipping-method-choose').visible() ? !Validation.get('IsEmpty').test(v) : true;
123
- });
 
124
  }
125
-
126
  });
127
 
128
  Transsmart.Shipping.PickupAdmin.prototype.parent = Transsmart.Shipping.Pickup.prototype;
22
 
23
  // Wait for the document to load
24
  document.observe('dom:loaded', function() {
25
+ // Add our custom validator
 
 
26
  self.addValidators();
27
 
28
  var parentSetShippingMethod = order.setShippingMethod.bind(order);
29
 
30
  // Override the setShippingMethod, since we need it to determine when a shipping method was clicked
31
  order.setShippingMethod = function(value) {
32
+ self.selectedShippingMethod = value;
33
+ self.selectedCarrierProfile = null;
34
 
35
+ // Does this shipping method have the location selector enabled?
36
+ if (typeof self.config.shippingMethods[self.selectedShippingMethod] == 'undefined') {
37
+ Transsmart.Logger.log('Shipping method ' + self.selectedShippingMethod + ' does not allow location selector');
38
+ Transsmart.Logger.log('Allowed location selectors are: ', self.config.shippingMethods);
39
  return parentSetShippingMethod(value);
40
  }
41
 
42
+ self.selectedCarrierProfile = self.config.shippingMethods[this.selectedShippingMethod];
 
 
 
 
 
43
 
 
44
  if (self.selectedShippingMethod != self.origShippingMethod) {
45
  $('tss-ls-admin-selected-location').update('');
46
  }
47
  self.attachPickupDiv($('s_method_' + value));
48
+
49
+ // save the selected shipping method without reloading the shipping methods block
50
+ var data = {};
51
+ data['order[shipping_method]'] = self.selectedShippingMethod;
52
+ order.loadArea(['totals', 'billing_method'], true, data);
53
  };
54
 
55
  // We need to move the container to after the anchor-content, so it lines up correctly
61
  self.selectLocationAndClose();
62
  event.stop();
63
  });
 
 
 
 
 
 
 
 
64
  });
65
  },
66
 
67
+ updateShippingMethods: function () {
68
+ // Check which shipping method has been selected
69
+ var checkedShippingMethods = $$('input[name="order[shipping_method]"]:checked');
70
+ if (checkedShippingMethods.length != 0) {
71
+ this.attachPickupDiv(checkedShippingMethods[0]);
 
 
 
 
72
  }
73
  },
74
 
107
  Translator.translate("A pickup location has to be selected"),
108
  function(v) {
109
  return $('order-shipping-method-choose').visible() ? !Validation.get('IsEmpty').test(v) : true;
110
+ }
111
+ );
112
  }
 
113
  });
114
 
115
  Transsmart.Shipping.PickupAdmin.prototype.parent = Transsmart.Shipping.Pickup.prototype;
js/transsmart/shipping/pickup_selector.js CHANGED
@@ -9,10 +9,9 @@ if (!Transsmart.Shipping) Transsmart.Shipping = { };
9
  Transsmart.Shipping.Pickup = Class.create({
10
 
11
  /**
12
- * Define configuration for the pickup shipping method
13
  */
14
  config: {
15
- shippingMethodName: 'transsmartpickup',
16
  shippingPickupContainerId: 'tss-location-selector',
17
  shippingMethodLoadDivId: 'checkout-shipping-method-load',
18
  locationsListDivId: 'tss-ls-locations',
@@ -20,12 +19,14 @@ Transsmart.Shipping.Pickup = Class.create({
20
  selectButtonId: 'tss-ls-select',
21
  closeButtonId: 'tss-ls-close',
22
  shippingPickupSelectButtonId: 'tss-ls-select-location',
23
- selectedLocationDivId: 'tss-ls-selected-location-info'
 
24
  },
25
 
26
  googleMaps: null,
27
  googleGeocoder: null,
28
  selectedShippingMethod: null,
 
29
  markers: [],
30
  infoWindow: null,
31
  selectedMarker: null,
@@ -49,14 +50,6 @@ Transsmart.Shipping.Pickup = Class.create({
49
  // Set the view url
50
  this.config.lookupUrl = config.lookupUrl;
51
 
52
- // Check whether the carrierProfileIds is provided
53
- if (typeof config == 'undefined' || typeof config.carrierProfileIds == 'undefined') {
54
- Transsmart.Logger.log('Transsmart_Shipping: Missing carrierProfileIds in the supplied config');
55
- return;
56
- }
57
-
58
- this.config.carrierProfileIds = config.carrierProfileIds;
59
-
60
  this.attachListenHandler();
61
  this.attachFilterHandlers();
62
  this.attachSearchHandler();
@@ -65,9 +58,17 @@ Transsmart.Shipping.Pickup = Class.create({
65
  document.observe('dom:loaded', function() {
66
  Event.observe(window, 'resize', this.onWindowResize.bind(this));
67
  }.bind(this));
 
68
 
69
- // observe ajax update event
70
- Ajax.Responders.register({ onComplete: this.onAjaxComplete.bind(this) });
 
 
 
 
 
 
 
71
  },
72
 
73
  /**
@@ -106,7 +107,12 @@ Transsmart.Shipping.Pickup = Class.create({
106
  }
107
 
108
  if (section == 'shipping_method') {
109
- this.updateShippingMethods();
 
 
 
 
 
110
  }
111
 
112
  parentGotoSection(section, reloadProgressBlock);
@@ -116,13 +122,6 @@ Transsmart.Shipping.Pickup = Class.create({
116
  // The shipping methods are generated dynamically
117
  // So we need to observe for dom changes and then trigger the click event based on that
118
  $(document).on('click', 'input[name=shipping_method]', function (event, element) {
119
- // Skip shipping methods that do not match the shipping method name
120
- if (element.value && element.value.indexOf(self.config.shippingMethodName) == -1) {
121
- this.removePickupDiv();
122
- return;
123
- }
124
-
125
- this.selectedShippingMethod = element.value;
126
  this.attachPickupDiv(element);
127
  }.bind(this));
128
 
@@ -135,21 +134,11 @@ Transsmart.Shipping.Pickup = Class.create({
135
  }.bind(this));
136
  },
137
 
138
- onAjaxComplete: function () {
139
- this.updateShippingMethods();
140
- },
141
-
142
  updateShippingMethods: function () {
143
  // Check which shipping method has been selected
144
  var checkedShippingMethods = $$('input[name=shipping_method]:checked');
145
-
146
  if (checkedShippingMethods.length != 0) {
147
- // The pre-selected shipping method is the pickup one.
148
- // Attach the pickup div to the radio button
149
- if (checkedShippingMethods[0].value.indexOf(this.config.shippingMethodName) != -1) {
150
- this.selectedShippingMethod = checkedShippingMethods[0].value;
151
- this.attachPickupDiv(checkedShippingMethods[0]);
152
- }
153
  }
154
  },
155
 
@@ -225,6 +214,9 @@ Transsmart.Shipping.Pickup = Class.create({
225
  * @param inputElement The input radio element that's part of a carrier
226
  */
227
  attachPickupDiv: function(inputElement) {
 
 
 
228
  var containerItem = $(this.config.shippingPickupContainerId);
229
 
230
  // Remove the shipping pickup div if it exists
@@ -232,19 +224,14 @@ Transsmart.Shipping.Pickup = Class.create({
232
  containerItem.remove();
233
  }
234
 
235
- var valueBits = inputElement.value.match(/transsmartpickup_carrierprofile_([0-9]+)/);
236
-
237
- // Nothing to attach, it doesn't match
238
- if (valueBits == null || valueBits.length != 2) {
239
  return;
240
  }
241
 
242
- // Not a carrierprofile that has location selector enabled
243
- if (this.config.carrierProfileIds.indexOf(valueBits[1]) == -1) {
244
- Transsmart.Logger.log('Carrier profile with id: ' + valueBits[1] + ' does not allow location selector');
245
- Transsmart.Logger.log('Allowed location selectors are: ', this.config.carrierProfileIds);
246
- return;
247
- }
248
 
249
  // Find the container for transsmart pickup shipping method
250
  var shippingMethodContainer = this.getButtonContainer(inputElement);
@@ -452,7 +439,7 @@ Transsmart.Shipping.Pickup = Class.create({
452
  // Attach the selected shipping method
453
  var url = this.config.lookupUrl;
454
  var params = {
455
- shipping_method: this.selectedShippingMethod,
456
  };
457
 
458
  if (searchValue != null) {
9
  Transsmart.Shipping.Pickup = Class.create({
10
 
11
  /**
12
+ * Define configuration for the location selector
13
  */
14
  config: {
 
15
  shippingPickupContainerId: 'tss-location-selector',
16
  shippingMethodLoadDivId: 'checkout-shipping-method-load',
17
  locationsListDivId: 'tss-ls-locations',
19
  selectButtonId: 'tss-ls-select',
20
  closeButtonId: 'tss-ls-close',
21
  shippingPickupSelectButtonId: 'tss-ls-select-location',
22
+ selectedLocationDivId: 'tss-ls-selected-location-info',
23
+ shippingMethods: {}
24
  },
25
 
26
  googleMaps: null,
27
  googleGeocoder: null,
28
  selectedShippingMethod: null,
29
+ selectedCarrierProfile: null,
30
  markers: [],
31
  infoWindow: null,
32
  selectedMarker: null,
50
  // Set the view url
51
  this.config.lookupUrl = config.lookupUrl;
52
 
 
 
 
 
 
 
 
 
53
  this.attachListenHandler();
54
  this.attachFilterHandlers();
55
  this.attachSearchHandler();
58
  document.observe('dom:loaded', function() {
59
  Event.observe(window, 'resize', this.onWindowResize.bind(this));
60
  }.bind(this));
61
+ },
62
 
63
+ /**
64
+ * Set shipping methods.
65
+ *
66
+ * @param array methods
67
+ */
68
+ setMethods: function (methods) {
69
+ Transsmart.Logger.log('Update shipping methods: ', methods);
70
+ this.config.shippingMethods = methods;
71
+ this.updateShippingMethods();
72
  },
73
 
74
  /**
107
  }
108
 
109
  if (section == 'shipping_method') {
110
+ try {
111
+ this.updateShippingMethods();
112
+ }
113
+ catch (error) {
114
+ Transsmart.Logger.log('Transsmart_Shipping error: ' + error);
115
+ }
116
  }
117
 
118
  parentGotoSection(section, reloadProgressBlock);
122
  // The shipping methods are generated dynamically
123
  // So we need to observe for dom changes and then trigger the click event based on that
124
  $(document).on('click', 'input[name=shipping_method]', function (event, element) {
 
 
 
 
 
 
 
125
  this.attachPickupDiv(element);
126
  }.bind(this));
127
 
134
  }.bind(this));
135
  },
136
 
 
 
 
 
137
  updateShippingMethods: function () {
138
  // Check which shipping method has been selected
139
  var checkedShippingMethods = $$('input[name=shipping_method]:checked');
 
140
  if (checkedShippingMethods.length != 0) {
141
+ this.attachPickupDiv(checkedShippingMethods[0]);
 
 
 
 
 
142
  }
143
  },
144
 
214
  * @param inputElement The input radio element that's part of a carrier
215
  */
216
  attachPickupDiv: function(inputElement) {
217
+ this.selectedShippingMethod = inputElement.value;
218
+ this.selectedCarrierProfile = null;
219
+
220
  var containerItem = $(this.config.shippingPickupContainerId);
221
 
222
  // Remove the shipping pickup div if it exists
224
  containerItem.remove();
225
  }
226
 
227
+ // Does this shipping method have the location selector enabled?
228
+ if (typeof this.config.shippingMethods[this.selectedShippingMethod] == 'undefined') {
229
+ Transsmart.Logger.log('Shipping method ' + this.selectedShippingMethod + ' does not allow location selector');
230
+ Transsmart.Logger.log('Allowed location selectors are: ', this.config.shippingMethods);
231
  return;
232
  }
233
 
234
+ this.selectedCarrierProfile = this.config.shippingMethods[this.selectedShippingMethod];
 
 
 
 
 
235
 
236
  // Find the container for transsmart pickup shipping method
237
  var shippingMethodContainer = this.getButtonContainer(inputElement);
439
  // Attach the selected shipping method
440
  var url = this.config.lookupUrl;
441
  var params = {
442
+ carrierprofile: this.selectedCarrierProfile
443
  };
444
 
445
  if (searchValue != null) {
package.xml CHANGED
@@ -1,18 +1,18 @@
1
  <?xml version="1.0"?>
2
  <package>
3
  <name>Transsmart_Shipping</name>
4
- <version>1.0.2</version>
5
  <stability>stable</stability>
6
  <license uri="http://opensource.org/licenses/osl-3.0.php">Open Software License (OSL 3.0)</license>
7
  <channel>community</channel>
8
  <extends/>
9
  <summary>Transsmart Magento connector</summary>
10
  <description>Integrates Transsmart Shipping into Magento.</description>
11
- <notes>1.0.2</notes>
12
  <authors><author><name>Techtwo Webdevelopment B.V.</name><user>techtwo</user><email>info@techtwo.nl</email></author><author><name>Bastiaan Heeren</name><user>techtwobastiaan</user><email>bastiaan@techtwo.nl</email></author></authors>
13
- <date>2016-01-22</date>
14
- <time>09:43:17</time>
15
- <contents><target name="magecommunity"><dir name="Transsmart"><dir name="Shipping"><dir name="Block"><dir name="Adminhtml"><dir name="Sales"><dir name="Order"><file name="Grid.php" hash="bafce0b64ee9545b3a355df1b0b8e18d"/><dir name="Shipment"><dir name="Create"><file name="Detail.php" hash="b8b8b391b781f5d9de8b2578ad84d540"/><file name="Package.php" hash="7054391262f4bcc78d77bbd8d7131d61"/></dir><dir name="Masscreate"><file name="Form.php" hash="1bef6372fca204ba939fca5a02f3fa3d"/></dir><file name="Masscreate.php" hash="244adc0427800e5df7ea050947cff0d5"/><dir name="View"><file name="Detail.php" hash="0c5a780a5a4095164b02b06a5cd5ec16"/><file name="Package.php" hash="ccdda1fc1a9710ff1d317575fd53baa7"/></dir></dir><dir name="View"><dir name="Tab"><file name="Shipments.php" hash="e8b2006ed7c6541ea61c309123457c7c"/></dir></dir></dir><dir name="Shipment"><dir name="Grid"><dir name="Renderer"><file name="Link.php" hash="f42b111af0b6fa7dbdd171b9ef9f5655"/></dir></dir><file name="Grid.php" hash="931e2c538a9f61c62fc838d441419c48"/></dir></dir><dir name="Shipping"><dir name="Location"><file name="Info.php" hash="fa01c870d4a5cd521ed312a447f10dda"/></dir></dir><dir name="System"><dir name="Config"><dir name="Form"><dir name="Field"><file name="Fetch.php" hash="43361767a4367c59fea55c23bb52aaed"/></dir><dir name="Fieldset"><dir name="Carrierprofile"><file name="Header.php" hash="01bda5320d4fcb5493f7fc2fd7ec01ac"/></dir><file name="Carrierprofile.php" hash="a75608f6b98458f1797d41d24a52030b"/><file name="Versioninfo.php" hash="84f740e55f0abc8fda7d95d26a638214"/></dir></dir></dir></dir></dir><dir name="Location"><file name="Selector.php" hash="f13d261827cb806fcc14c73058128653"/></dir></dir><dir name="Helper"><file name="Data.php" hash="32590b34298ed7ee39ebc011485e970e"/><file name="Location.php" hash="59dd6de96da501192e995f3688cba950"/><file name="Pickupaddress.php" hash="c71ad4ae7e2c4536a2d57c18d57b8919"/><file name="Shipment.php" hash="c2e09ac937b0187499a085ab75f4cc74"/></dir><dir name="Model"><file name="Abstract.php" hash="5b8973d5f3ce40cd641e9f16cdcd6620"/><dir name="Adminhtml"><file name="Observer.php" hash="3664f0727b0159ccdeff1cf256b5fccf"/><dir name="System"><dir name="Config"><dir name="Backend"><file name="Localized.php" hash="3f7ee8815b1f71168ba3fe2f2eb6389f"/></dir><dir name="Source"><dir name="Basedata"><file name="Abstract.php" hash="ac0c0632d16278357cc4128b3a5ef9a8"/><file name="Carrierprofile.php" hash="f01d6e81905f9481a8906253ccfc24e3"/><file name="Costcenter.php" hash="4dabd6942ab4e27e8c7e7032e3d01ca9"/><file name="Emailtype.php" hash="5d5d02c41970795f42e86ec4184a1072"/><file name="Incoterm.php" hash="8724e4b8bd9267fe843d62ffaa939b1e"/><file name="Packagetype.php" hash="6277448d89f3eeaae2dd15dd8a318af1"/><file name="Shipmentlocation.php" hash="f025e24746908e9c5aea82109f3b79fa"/></dir><file name="Environment.php" hash="4d011d8f728c3582022178da0c26ea66"/><dir name="Mapping"><file name="Attribute.php" hash="f2302357356f4c4b6f43cc63c408722a"/><file name="Street.php" hash="e42fa0ede4bc76876cf0c1f783189e87"/></dir><file name="Method.php" hash="672e247ef3764ff9294607102b152c78"/></dir></dir></dir></dir><file name="Carrier.php" hash="9aac846543c6b82cd3a06f9e307593ae"/><file name="Carrierprofile.php" hash="fb3bc266d34c00dbc10b76e89f6de20f"/><file name="Client.php" hash="9dbd3fc487adedecfc28d84eb7137842"/><file name="Costcenter.php" hash="bf6a9a5a95fa7cf1e0a609c6e0cf6365"/><file name="Emailtype.php" hash="b7128a27c6937c63f9a8ba14510dad13"/><file name="Incoterm.php" hash="8ebd437537680f375568f7873607ef87"/><file name="Observer.php" hash="e42f9c5c5a241e9ed8fef967fe194dee"/><file name="Packagetype.php" hash="d9f5012184c0e52429be7396e4081c69"/><dir name="Resource"><dir name="Carrier"><file name="Collection.php" hash="aabffe27624593ec59d489aaea12319c"/></dir><file name="Carrier.php" hash="57b812414155d31fe39977be1483ab1e"/><dir name="Carrierprofile"><file name="Collection.php" hash="59c40952ae124b257a30eebd72651df7"/></dir><file name="Carrierprofile.php" hash="53d9e49e8cf00b080f80489a476e43ef"/><dir name="Costcenter"><file name="Collection.php" hash="e338f05492a12988d3066bbc2f7569fe"/></dir><file name="Costcenter.php" hash="338db8721bcd09dabbece8e9c862ac92"/><dir name="Emailtype"><file name="Collection.php" hash="fe4ee29a8af109be50e7d928a8d5a9c3"/></dir><file name="Emailtype.php" hash="27b7d676aabf4e16891ccadee409aeba"/><dir name="Incoterm"><file name="Collection.php" hash="7490a144291e1b2a81f5c243173627e3"/></dir><file name="Incoterm.php" hash="5076d4828c71f71178d7d33213d2e735"/><dir name="Packagetype"><file name="Collection.php" hash="f20c13999570a2338feaf1f8af72c85b"/></dir><file name="Packagetype.php" hash="b8de7857c71a26be8915a67c38a1d347"/><dir name="Servicelevel"><dir name="Other"><file name="Collection.php" hash="c48542bc38fc957c97b90bcc2d0d0773"/></dir><file name="Other.php" hash="df8672bc7a5383a6a985703ece13041d"/><dir name="Time"><file name="Collection.php" hash="ee5e6e59deed414768205cc695b4cda3"/></dir><file name="Time.php" hash="2fc0d74b96cf8b7fe38593d9bdaf1a82"/></dir><dir name="Shipmentlocation"><file name="Collection.php" hash="c284bdadf29cf34160e7f8af189f5a43"/></dir><file name="Shipmentlocation.php" hash="99792ed958bffa3d333453888be4b1c4"/><dir name="Sync"><file name="Collection.php" hash="5b837d6fc0fde6c0a7ebef66132d7bcd"/></dir><file name="Sync.php" hash="a538626ff74fa096eb20c95ccf936794"/></dir><dir name="Sales"><dir name="Resource"><file name="Order.php" hash="f078ab890e8a294a75183bcbbb667f2e"/></dir></dir><dir name="Servicelevel"><file name="Other.php" hash="cf779fc0762b7e34974605256d941993"/><file name="Time.php" hash="60188779fd9cfb1e237fd915090acb53"/></dir><file name="Shipmentlocation.php" hash="38147d641e55c3b68a9cecd123081993"/><dir name="Shipping"><dir name="Carrier"><file name="Abstract.php" hash="65c5fc48da295a19c90153ac693c523f"/><file name="Delivery.php" hash="5c2faa12f798aea53343a657bd7c7010"/><file name="Pickup.php" hash="436630941a50a968cf54e929e25fd0c3"/></dir></dir><file name="Sync.php" hash="2343389f501ff24a846f2b4c6311a822"/></dir><dir name="controllers"><dir name="Adminhtml"><dir name="Transsmart"><dir name="Shipping"><file name="LocationController.php" hash="9ed198c21dd4569cc604c19d6865a74b"/><file name="ShipmentController.php" hash="67e443bfcdc4afc3478dcf3bc80282e7"/></dir></dir><file name="TranssmartController.php" hash="b5b688249bce5a74bef95319674e5698"/></dir><file name="LocationController.php" hash="f39c3a08069cefc6169c9eed12a97f63"/></dir><dir name="etc"><file name="adminhtml.xml" hash="07f3353cf1d7275e528a18b9883b206f"/><file name="config.xml" hash="c321a512326bf2adb9b8dc54f13928f3"/><file name="jstranslator.xml" hash="b50cf9cd74e37d6e34b3e360f3353313"/><file name="system.xml" hash="913acd885f5c4a1d33182f022720fe10"/></dir><dir name="sql"><dir name="transsmart_shipping_setup"><file name="install-1.0.0.php" hash="242d4b2aff6d23151dcca7c9cadab352"/></dir></dir><dir name="ssl"><file name="CARoot.crt" hash="f85d1ff17b0079709f131f3ce3f288d2"/></dir></dir></dir></target><target name="magedesign"><dir name="adminhtml"><dir name="base"><dir name="default"><dir name="layout"><file name="transsmart_shipping.xml" hash="c0578eb781adc2df96e79fe776e387da"/></dir><dir name="template"><dir name="transsmart"><dir name="shipping"><dir name="location"><file name="info.phtml" hash="74ce67c6f39c308995a478279ca1e1bc"/><file name="selector.phtml" hash="841e1d59d042c2b53c622593150675c6"/></dir><dir name="sales"><dir name="order"><dir name="address"><dir name="form"><file name="container.phtml" hash="57a3f3de61e96127659dbf53952a0b33"/></dir></dir><dir name="shipment"><dir name="address"><dir name="form"><file name="container.phtml" hash="9763785687d9f4dfa03d6d1887a3f867"/></dir></dir><dir name="create"><file name="action.phtml" hash="164c1c632265816113e8eb172762871c"/><file name="detail.phtml" hash="c12734fe34fb4a526eb29075d2b80120"/><file name="package.phtml" hash="a39776c6e5f95112e10b9dbc9e29bd14"/></dir><dir name="masscreate"><file name="form.phtml" hash="5e2a281942e88379fa28698a85e519ec"/></dir><dir name="view"><file name="detail.phtml" hash="e901e78ba712f7e99b82409a07c9dedd"/><file name="package.phtml" hash="4ba3f81ed371d87542102974566cb522"/></dir></dir></dir></dir><dir name="system"><dir name="config"><dir name="form"><dir name="field"><file name="fetch.phtml" hash="bf8377c0df88e37305d0d39b5ad72101"/></dir></dir></dir></dir></dir></dir></dir></dir></dir></dir><dir name="frontend"><dir name="base"><dir name="default"><dir name="layout"><file name="transsmart_shipping.xml" hash="99c0e35e1ef97c0251485fee9b39297e"/></dir><dir name="template"><dir name="transsmart"><dir name="shipping"><dir name="location"><file name="selector.phtml" hash="25000d2769c4e282cdb07dbdc6cb1722"/></dir><dir name="onepage"><dir name="progress"><file name="pickup.phtml" hash="e3874f42cb1d4a9629069d50c39f338e"/></dir></dir></dir></dir></dir></dir></dir></dir></target><target name="mageetc"><dir name="modules"><file name="Transsmart_Shipping.xml" hash="1f526fc89db267b44b7425e2ff645a68"/></dir></target><target name="magelocale"><dir><dir name="nl_NL"><file name="Transsmart_Shipping.csv" hash="759cb6f310ac469a52513c7eede0ce54"/></dir></dir></target><target name="mageweb"><dir name="js"><dir name="transsmart"><dir name="shipping"><dir name="admin"><file name="pickup_selector.js" hash="7da3ddbbd8e5e4adc4a134faaa7fee0b"/></dir><file name="base64.js" hash="795b1ac117d08652a3a43552c83332ac"/><file name="logger.js" hash="b852d48e077a6114ffe56bd647d1ea5c"/><file name="pickup_selector.js" hash="f01e4051c39218c8354a7f28ed1638ed"/></dir></dir></dir></target><target name="mageskin"><dir name="adminhtml"><dir name="base"><dir name="default"><dir name="transsmart"><dir name="shipping"><dir name="images"><file name="arrow.png" hash="5b0966d990b40b3510cd2bb57081812d"/><file name="checkmark.png" hash="e5cf08c5943037b8ccc3a5449febdb7b"/><file name="close-btn.png" hash="975d2b3ee2879d4e4b812df8351ccf05"/><file name="info-icon.png" hash="a6baeffe65721d6995f8f06b1669a0ad"/><file name="loader.gif" hash="c5cd7f5300576ab4c88202b42f6ded62"/><file name="radio.png" hash="f149b9aa48f1c3a9da34173c40c882dc"/></dir><file name="pickup_selector.css" hash="9e4b6c280cfd0e2dc6d2d05714b94073"/><file name="styles.css" hash="d61eebd814903f153eb2210bf5f27c5f"/></dir></dir></dir></dir></dir><dir name="frontend"><dir name="base"><dir name="default"><dir name="transsmart"><dir name="shipping"><dir name="images"><file name="arrow.png" hash="5b0966d990b40b3510cd2bb57081812d"/><file name="close-btn.png" hash="975d2b3ee2879d4e4b812df8351ccf05"/><file name="info-icon.png" hash="a6baeffe65721d6995f8f06b1669a0ad"/><file name="loader.gif" hash="c5cd7f5300576ab4c88202b42f6ded62"/><file name="radio.png" hash="f149b9aa48f1c3a9da34173c40c882dc"/></dir><file name="pickup_selector.css" hash="9e4b6c280cfd0e2dc6d2d05714b94073"/></dir></dir></dir></dir></dir></target></contents>
16
  <compatible/>
17
  <dependencies><required><php><min>5.3.29</min><max>5.9.9</max></php><extension><name>curl</name><min/><max/></extension></required></dependencies>
18
  </package>
1
  <?xml version="1.0"?>
2
  <package>
3
  <name>Transsmart_Shipping</name>
4
+ <version>1.0.7</version>
5
  <stability>stable</stability>
6
  <license uri="http://opensource.org/licenses/osl-3.0.php">Open Software License (OSL 3.0)</license>
7
  <channel>community</channel>
8
  <extends/>
9
  <summary>Transsmart Magento connector</summary>
10
  <description>Integrates Transsmart Shipping into Magento.</description>
11
+ <notes>1.0.7</notes>
12
  <authors><author><name>Techtwo Webdevelopment B.V.</name><user>techtwo</user><email>info@techtwo.nl</email></author><author><name>Bastiaan Heeren</name><user>techtwobastiaan</user><email>bastiaan@techtwo.nl</email></author></authors>
13
+ <date>2016-03-18</date>
14
+ <time>10:12:17</time>
15
+ <contents><target name="magecommunity"><dir name="Transsmart"><dir name="Shipping"><dir name="Block"><dir name="Adminhtml"><dir name="Sales"><dir name="Order"><dir name="Create"><dir name="Shipping"><dir name="Method"><file name="Form.php" hash="72689318e8ffef6153cdad321f412ceb"/></dir></dir></dir><file name="Grid.php" hash="bafce0b64ee9545b3a355df1b0b8e18d"/><dir name="Shipment"><dir name="Create"><file name="Detail.php" hash="72fc7eed3672f1fa857f543c49952f4b"/><file name="Package.php" hash="7054391262f4bcc78d77bbd8d7131d61"/></dir><dir name="Masscreate"><file name="Form.php" hash="4cecd9f1999d1846e8fe3fd4f335626d"/></dir><file name="Masscreate.php" hash="244adc0427800e5df7ea050947cff0d5"/><dir name="View"><file name="Detail.php" hash="012c5d58a8e6cbe446f00a6fcf6c0b07"/><file name="Package.php" hash="ccdda1fc1a9710ff1d317575fd53baa7"/></dir></dir><dir name="View"><file name="Detail.php" hash="bdedd7f70905b9456617ba37f00d2ee2"/><dir name="Tab"><file name="Shipments.php" hash="6d136dbe7f2e935c89c2aa299fab2b47"/></dir></dir></dir><dir name="Shipment"><dir name="Grid"><dir name="Renderer"><file name="Link.php" hash="f42b111af0b6fa7dbdd171b9ef9f5655"/></dir></dir><file name="Grid.php" hash="931e2c538a9f61c62fc838d441419c48"/></dir></dir><dir name="Shipping"><dir name="Carrier"><dir name="Tablerate"><file name="Grid.php" hash="83c3eb853a62285164d3b31607becb9b"/></dir></dir><dir name="Location"><file name="Info.php" hash="fa01c870d4a5cd521ed312a447f10dda"/></dir></dir><dir name="System"><dir name="Config"><dir name="Form"><dir name="Field"><file name="Fetch.php" hash="43361767a4367c59fea55c23bb52aaed"/><file name="Locationselect.php" hash="967db0e5009436275f56183445cef92d"/></dir><dir name="Fieldset"><dir name="Carrierprofile"><file name="Header.php" hash="01bda5320d4fcb5493f7fc2fd7ec01ac"/></dir><file name="Carrierprofile.php" hash="a75608f6b98458f1797d41d24a52030b"/><file name="Versioninfo.php" hash="84f740e55f0abc8fda7d95d26a638214"/></dir></dir></dir></dir></dir><dir name="Checkout"><dir name="Onepage"><dir name="Shipping"><dir name="Method"><file name="Available.php" hash="339e7a7ab32a0b9c3e74bb37f3383869"/></dir></dir></dir></dir><dir name="Location"><file name="Selector.php" hash="f13d261827cb806fcc14c73058128653"/></dir></dir><dir name="Helper"><file name="Data.php" hash="d187e5e96796f7c59895e85144f60f68"/><file name="Location.php" hash="bd07e95bb34d37eaec508a3fa10a434f"/><file name="Pickupaddress.php" hash="c71ad4ae7e2c4536a2d57c18d57b8919"/><file name="Shipment.php" hash="2412f4c2b8c26079a5bbfb70aeff7b8a"/></dir><dir name="Model"><file name="Abstract.php" hash="5b8973d5f3ce40cd641e9f16cdcd6620"/><dir name="Adminhtml"><file name="Observer.php" hash="e8569aa1e15030bc2bce11690bbd3d54"/><dir name="System"><dir name="Config"><dir name="Backend"><file name="Localized.php" hash="3f7ee8815b1f71168ba3fe2f2eb6389f"/></dir><dir name="Source"><dir name="Basedata"><file name="Abstract.php" hash="ac0c0632d16278357cc4128b3a5ef9a8"/><file name="Carrierprofile.php" hash="f01d6e81905f9481a8906253ccfc24e3"/><file name="Costcenter.php" hash="4dabd6942ab4e27e8c7e7032e3d01ca9"/><file name="Emailtype.php" hash="5d5d02c41970795f42e86ec4184a1072"/><file name="Incoterm.php" hash="8724e4b8bd9267fe843d62ffaa939b1e"/><file name="Packagetype.php" hash="6277448d89f3eeaae2dd15dd8a318af1"/><file name="Shipmentlocation.php" hash="f025e24746908e9c5aea82109f3b79fa"/></dir><file name="Environment.php" hash="4d011d8f728c3582022178da0c26ea66"/><dir name="Mapping"><file name="Attribute.php" hash="f2302357356f4c4b6f43cc63c408722a"/><file name="Street.php" hash="e42fa0ede4bc76876cf0c1f783189e87"/></dir><file name="Method.php" hash="672e247ef3764ff9294607102b152c78"/></dir></dir></dir></dir><file name="Carrier.php" hash="9aac846543c6b82cd3a06f9e307593ae"/><file name="Carrierprofile.php" hash="03b3c9afef64dea1c53da3968cc8d545"/><file name="Client.php" hash="9dbd3fc487adedecfc28d84eb7137842"/><file name="Costcenter.php" hash="bf6a9a5a95fa7cf1e0a609c6e0cf6365"/><file name="Emailtype.php" hash="b7128a27c6937c63f9a8ba14510dad13"/><file name="Incoterm.php" hash="8ebd437537680f375568f7873607ef87"/><file name="Observer.php" hash="a7a849e5d1baa00a6aa444d16586a3cc"/><file name="Packagetype.php" hash="d9f5012184c0e52429be7396e4081c69"/><dir name="Resource"><dir name="Carrier"><file name="Collection.php" hash="aabffe27624593ec59d489aaea12319c"/></dir><file name="Carrier.php" hash="57b812414155d31fe39977be1483ab1e"/><dir name="Carrierprofile"><file name="Collection.php" hash="a82a5f3c8291b966257f0e02fcf6f899"/></dir><file name="Carrierprofile.php" hash="53d9e49e8cf00b080f80489a476e43ef"/><dir name="Costcenter"><file name="Collection.php" hash="e338f05492a12988d3066bbc2f7569fe"/></dir><file name="Costcenter.php" hash="338db8721bcd09dabbece8e9c862ac92"/><dir name="Emailtype"><file name="Collection.php" hash="fe4ee29a8af109be50e7d928a8d5a9c3"/></dir><file name="Emailtype.php" hash="27b7d676aabf4e16891ccadee409aeba"/><dir name="Incoterm"><file name="Collection.php" hash="7490a144291e1b2a81f5c243173627e3"/></dir><file name="Incoterm.php" hash="5076d4828c71f71178d7d33213d2e735"/><dir name="Packagetype"><file name="Collection.php" hash="f20c13999570a2338feaf1f8af72c85b"/></dir><file name="Packagetype.php" hash="b8de7857c71a26be8915a67c38a1d347"/><dir name="Servicelevel"><dir name="Other"><file name="Collection.php" hash="c48542bc38fc957c97b90bcc2d0d0773"/></dir><file name="Other.php" hash="df8672bc7a5383a6a985703ece13041d"/><dir name="Time"><file name="Collection.php" hash="ee5e6e59deed414768205cc695b4cda3"/></dir><file name="Time.php" hash="2fc0d74b96cf8b7fe38593d9bdaf1a82"/></dir><dir name="Shipmentlocation"><file name="Collection.php" hash="c284bdadf29cf34160e7f8af189f5a43"/></dir><file name="Shipmentlocation.php" hash="99792ed958bffa3d333453888be4b1c4"/><dir name="Sync"><file name="Collection.php" hash="5b837d6fc0fde6c0a7ebef66132d7bcd"/></dir><file name="Sync.php" hash="a538626ff74fa096eb20c95ccf936794"/></dir><dir name="Sales"><dir name="Quote"><dir name="Address"><file name="Rate.php" hash="fa832901e51dc3ce68facb7a509cdad4"/><dir name="Total"><file name="Shipping.php" hash="7a9bc5ef3a66676fb0a7a9a7a74eba2a"/></dir></dir></dir><dir name="Resource"><file name="Order.php" hash="765157e7f2448e3f40572b858ab72085"/></dir></dir><dir name="Servicelevel"><file name="Other.php" hash="cf779fc0762b7e34974605256d941993"/><file name="Time.php" hash="60188779fd9cfb1e237fd915090acb53"/></dir><file name="Shipmentlocation.php" hash="38147d641e55c3b68a9cecd123081993"/><dir name="Shipping"><dir name="Carrier"><file name="Abstract.php" hash="870717647064f6180cc5606530361229"/><file name="Delivery.php" hash="5c2faa12f798aea53343a657bd7c7010"/><file name="Pickup.php" hash="436630941a50a968cf54e929e25fd0c3"/><file name="Tablerate.php" hash="da55646a0fdc45aefb45ca8af6fd7692"/></dir><dir name="Resource"><dir name="Carrier"><file name="Tablerate.php" hash="9744972fab3cfdd8f2d372acb0228e0c"/></dir></dir></dir><file name="Sync.php" hash="6b9674df5d0c98855ebe1c19c8aaadbf"/></dir><dir name="controllers"><dir name="Adminhtml"><dir name="Transsmart"><dir name="Shipping"><file name="LocationController.php" hash="9ed198c21dd4569cc604c19d6865a74b"/><file name="ShipmentController.php" hash="c37c3c3e345cd8d813b4129e57de412c"/></dir></dir><file name="TranssmartController.php" hash="b5b688249bce5a74bef95319674e5698"/></dir><file name="LocationController.php" hash="f39c3a08069cefc6169c9eed12a97f63"/></dir><dir name="etc"><file name="adminhtml.xml" hash="07f3353cf1d7275e528a18b9883b206f"/><file name="config.xml" hash="fdd6580a199588caeb7e86ef6c0e1688"/><file name="jstranslator.xml" hash="b50cf9cd74e37d6e34b3e360f3353313"/><file name="system.xml" hash="24799c0fa3acc2589070f7ce87d45fec"/></dir><dir name="sql"><dir name="transsmart_shipping_setup"><file name="install-1.0.0.php" hash="c705cd18b87fe6c91a7dea1f96b6b827"/><file name="upgrade-1.0.2-1.0.3.php" hash="1a579cfe3fffd404e654d69d07a751ce"/><file name="upgrade-1.0.3-1.0.4.php" hash="8bb09501b75a894bb9d3fed4d09f9daa"/><file name="upgrade-1.0.4-1.0.5.php" hash="44d2eba38f4e5eb3cc8ba3af40d66cc2"/><file name="upgrade-1.0.5-1.0.6.php" hash="e50368d2081f4a61f52e9500d2e75f65"/><file name="upgrade-1.0.6-1.0.7.php" hash="b5fb25d900205cae0300cf6659771b85"/></dir></dir><dir name="ssl"><file name="CARoot.crt" hash="f85d1ff17b0079709f131f3ce3f288d2"/></dir></dir></dir></target><target name="magedesign"><dir name="adminhtml"><dir name="base"><dir name="default"><dir name="layout"><file name="transsmart_shipping.xml" hash="11f07fb7e7cfeb0f7739bc8025010fea"/></dir><dir name="template"><dir name="transsmart"><dir name="shipping"><dir name="location"><file name="info.phtml" hash="74ce67c6f39c308995a478279ca1e1bc"/><file name="selector.phtml" hash="9f866e98900a913c5e445dcf13dc5a28"/></dir><dir name="sales"><dir name="order"><dir name="address"><dir name="form"><file name="container.phtml" hash="ddbe8b44a87697e7d4b87652529a677d"/></dir></dir><dir name="shipment"><dir name="address"><dir name="form"><file name="container.phtml" hash="5a9fb5b11bb2b86efefe6a8b331243a9"/></dir></dir><dir name="create"><file name="action.phtml" hash="164c1c632265816113e8eb172762871c"/><file name="detail.phtml" hash="ff648d21fc545615a93afd102ddb1341"/><file name="package.phtml" hash="a39776c6e5f95112e10b9dbc9e29bd14"/></dir><dir name="masscreate"><file name="form.phtml" hash="5e2a281942e88379fa28698a85e519ec"/></dir><dir name="view"><file name="detail.phtml" hash="3b6f90c0f6e6e8a1a17e67576ad947a9"/><file name="package.phtml" hash="4ba3f81ed371d87542102974566cb522"/></dir></dir></dir></dir><dir name="system"><dir name="config"><dir name="form"><dir name="field"><file name="fetch.phtml" hash="bf8377c0df88e37305d0d39b5ad72101"/></dir></dir></dir></dir></dir></dir></dir></dir></dir></dir><dir name="frontend"><dir name="base"><dir name="default"><dir name="layout"><file name="transsmart_shipping.xml" hash="99c0e35e1ef97c0251485fee9b39297e"/></dir><dir name="template"><dir name="transsmart"><dir name="shipping"><dir name="location"><file name="selector.phtml" hash="ff51b20abe4e2cfe431ed7cc34dae74a"/></dir><dir name="onepage"><dir name="progress"><file name="pickup.phtml" hash="0a2ead13642da6216e656d5cf018f9f4"/></dir></dir></dir></dir></dir></dir></dir></dir></target><target name="mageetc"><dir name="modules"><file name="Transsmart_Shipping.xml" hash="1f526fc89db267b44b7425e2ff645a68"/></dir></target><target name="magelocale"><dir><dir name="nl_NL"><file name="Transsmart_Shipping.csv" hash="3d7f703df318ad95feeb5bfc89fb13be"/></dir></dir></target><target name="mageweb"><dir name="js"><dir name="transsmart"><dir name="shipping"><dir name="admin"><file name="pickup_selector.js" hash="e8348a7447cee04c95a15528e30886f1"/></dir><file name="base64.js" hash="795b1ac117d08652a3a43552c83332ac"/><file name="logger.js" hash="b852d48e077a6114ffe56bd647d1ea5c"/><file name="pickup_selector.js" hash="cc9885329763b84e2eacfcffcb4cc31a"/></dir></dir></dir></target><target name="mageskin"><dir name="adminhtml"><dir name="base"><dir name="default"><dir name="transsmart"><dir name="shipping"><dir name="images"><file name="arrow.png" hash="5b0966d990b40b3510cd2bb57081812d"/><file name="checkmark.png" hash="e5cf08c5943037b8ccc3a5449febdb7b"/><file name="close-btn.png" hash="975d2b3ee2879d4e4b812df8351ccf05"/><file name="info-icon.png" hash="a6baeffe65721d6995f8f06b1669a0ad"/><file name="loader.gif" hash="c5cd7f5300576ab4c88202b42f6ded62"/><file name="radio.png" hash="f149b9aa48f1c3a9da34173c40c882dc"/></dir><file name="pickup_selector.css" hash="9e4b6c280cfd0e2dc6d2d05714b94073"/><file name="styles.css" hash="d61eebd814903f153eb2210bf5f27c5f"/></dir></dir></dir></dir></dir><dir name="frontend"><dir name="base"><dir name="default"><dir name="transsmart"><dir name="shipping"><dir name="images"><file name="arrow.png" hash="5b0966d990b40b3510cd2bb57081812d"/><file name="close-btn.png" hash="975d2b3ee2879d4e4b812df8351ccf05"/><file name="info-icon.png" hash="a6baeffe65721d6995f8f06b1669a0ad"/><file name="loader.gif" hash="c5cd7f5300576ab4c88202b42f6ded62"/><file name="radio.png" hash="f149b9aa48f1c3a9da34173c40c882dc"/></dir><file name="pickup_selector.css" hash="9e4b6c280cfd0e2dc6d2d05714b94073"/></dir></dir></dir></dir></dir></target></contents>
16
  <compatible/>
17
  <dependencies><required><php><min>5.3.29</min><max>5.9.9</max></php><extension><name>curl</name><min/><max/></extension></required></dependencies>
18
  </package>