Temando_Temando - Version 1.4.5

Version Notes

- Addition of Endpoint discovery feature

Download this release

Release Info

Developer Temando
Extension Temando_Temando
Version 1.4.5
Comparing to
See all releases


Code changes from version 1.4.1 to 1.4.5

Files changed (139) hide show
  1. app/code/community/Temando/Temando/Block/Adminhtml/Manifest.php +40 -40
  2. app/code/community/Temando/Temando/Block/Adminhtml/Manifest/Filter/Form.php +61 -56
  3. app/code/community/Temando/Temando/Block/Adminhtml/Manifest/Grid.php +158 -156
  4. app/code/community/Temando/Temando/Block/Adminhtml/Manifest/Grid/Renderer/Checkbox.php +36 -38
  5. app/code/community/Temando/Temando/Block/Adminhtml/Shipment.php +21 -21
  6. app/code/community/Temando/Temando/Block/Adminhtml/Shipment/Edit.php +247 -229
  7. app/code/community/Temando/Temando/Block/Adminhtml/Shipment/Edit/Form.php +33 -33
  8. app/code/community/Temando/Temando/Block/Adminhtml/Shipment/Edit/Tab/Abstract.php +71 -70
  9. app/code/community/Temando/Temando/Block/Adminhtml/Shipment/Edit/Tab/Form.php +41 -41
  10. app/code/community/Temando/Temando/Block/Adminhtml/Shipment/Edit/Tab/Form/Anytime.php +14 -14
  11. app/code/community/Temando/Temando/Block/Adminhtml/Shipment/Edit/Tab/Form/Anywhere.php +14 -14
  12. app/code/community/Temando/Temando/Block/Adminhtml/Shipment/Edit/Tab/Form/Boxes.php +30 -31
  13. app/code/community/Temando/Temando/Block/Adminhtml/Shipment/Edit/Tab/Form/Insurance.php +44 -44
  14. app/code/community/Temando/Temando/Block/Adminhtml/Shipment/Edit/Tab/Form/Origin.php +26 -26
  15. app/code/community/Temando/Temando/Block/Adminhtml/Shipment/Edit/Tab/Form/Products.php +23 -24
  16. app/code/community/Temando/Temando/Block/Adminhtml/Shipment/Edit/Tab/Form/Quotes.php +66 -67
  17. app/code/community/Temando/Temando/Block/Adminhtml/Shipment/Edit/Tab/Form/Status.php +31 -32
  18. app/code/community/Temando/Temando/Block/Adminhtml/Shipment/Edit/Tabs.php +20 -20
  19. app/code/community/Temando/Temando/Block/Adminhtml/Shipment/Grid.php +147 -134
  20. app/code/community/Temando/Temando/Block/Adminhtml/Shipment/Grid/Renderer/Currency.php +24 -0
  21. app/code/community/Temando/Temando/Block/Adminhtml/Shipment/Grid/Renderer/Shipcurrency.php +23 -0
  22. app/code/community/Temando/Temando/Block/Adminhtml/System/Config/Form/Button/Rule.php +23 -23
  23. app/code/community/Temando/Temando/Block/Adminhtml/System/Config/Form/Button/Update.php +23 -24
  24. app/code/community/Temando/Temando/Block/Adminhtml/System/Config/Form/Button/Warehouse.php +25 -24
  25. app/code/community/Temando/Temando/Block/Adminhtml/System/Config/Form/Field/Insurance.php +142 -93
  26. app/code/community/Temando/Temando/Block/Adminhtml/System/Config/Form/Field/Required.php +54 -53
  27. app/code/community/Temando/Temando/Block/Adminhtml/System/Config/Form/Field/Version.php +21 -0
  28. app/code/community/Temando/Temando/Block/Adminhtml/System/Config/Form/Fieldset/General.php +30 -30
  29. app/code/community/Temando/Temando/Block/Cart/Shipping.php +138 -138
  30. app/code/community/Temando/Temando/Block/Onepage/Shipping/Delivery/Options.php +89 -89
  31. app/code/community/Temando/Temando/Block/Onepage/Shipping/Method/Available.php +12 -12
  32. app/code/community/Temando/Temando/Block/Onepage/Shipping/Method/Available/Single.php +61 -60
  33. app/code/community/Temando/Temando/Block/Product/Shipping.php +83 -85
  34. app/code/community/Temando/Temando/Block/Product/Shipping/Methods.php +31 -31
  35. app/code/community/Temando/Temando/Block/Wizard/Html.php +288 -287
  36. app/code/community/Temando/Temando/Helper/Data.php +615 -533
  37. app/code/community/Temando/Temando/Helper/Functions.php +77 -76
  38. app/code/community/Temando/Temando/Helper/Wizard.php +52 -52
  39. app/code/community/Temando/Temando/Model/Api/Client.php +312 -299
  40. app/code/community/Temando/Temando/Model/Api/Request.php +214 -205
  41. app/code/community/Temando/Temando/Model/Api/Request/Anything.php +159 -130
  42. app/code/community/Temando/Temando/Model/Api/Request/Anythings.php +185 -184
  43. app/code/community/Temando/Temando/Model/Api/Request/Anytime.php +68 -70
  44. app/code/community/Temando/Temando/Model/Api/Request/Anywhere.php +84 -84
  45. app/code/community/Temando/Temando/Model/Box.php +41 -41
  46. app/code/community/Temando/Temando/Model/Carrier.php +59 -59
  47. app/code/community/Temando/Temando/Model/Checkout/Delivery/Options.php +79 -79
  48. app/code/community/Temando/Temando/Model/Endpoint.php +191 -0
  49. app/code/community/Temando/Temando/Model/Entity/Attribute/Source/Packaging.php +68 -68
  50. app/code/community/Temando/Temando/Model/Entity/Attribute/Source/Packaging/Mode.php +68 -68
  51. app/code/community/Temando/Temando/Model/Manifest.php +16 -17
  52. app/code/community/Temando/Temando/Model/Mysql4/Box.php +16 -16
  53. app/code/community/Temando/Temando/Model/Mysql4/Box/Collection.php +18 -18
  54. app/code/community/Temando/Temando/Model/Mysql4/Carrier.php +17 -17
  55. app/code/community/Temando/Temando/Model/Mysql4/Carrier/Collection.php +18 -18
  56. app/code/community/Temando/Temando/Model/Mysql4/Manifest.php +17 -17
  57. app/code/community/Temando/Temando/Model/Mysql4/Manifest/Collection.php +18 -18
  58. app/code/community/Temando/Temando/Model/Mysql4/Quote.php +16 -16
  59. app/code/community/Temando/Temando/Model/Mysql4/Quote/Collection.php +132 -132
  60. app/code/community/Temando/Temando/Model/Mysql4/Shipment.php +16 -16
  61. app/code/community/Temando/Temando/Model/Mysql4/Shipment/Collection.php +39 -36
  62. app/code/community/Temando/Temando/Model/Observer.php +195 -185
  63. app/code/community/Temando/Temando/Model/Option/Abstract.php +209 -209
  64. app/code/community/Temando/Temando/Model/Option/Action/Abstract.php +18 -18
  65. app/code/community/Temando/Temando/Model/Option/Action/Carbon.php +20 -20
  66. app/code/community/Temando/Temando/Model/Option/Action/Footprints.php +21 -21
  67. app/code/community/Temando/Temando/Model/Option/Action/Insurance.php +21 -21
  68. app/code/community/Temando/Temando/Model/Option/Action/Markup.php +131 -131
  69. app/code/community/Temando/Temando/Model/Option/Boolean.php +50 -50
  70. app/code/community/Temando/Temando/Model/Option/Carbonoffset.php +85 -83
  71. app/code/community/Temando/Temando/Model/Option/Footprints.php +63 -61
  72. app/code/community/Temando/Temando/Model/Option/Insurance.php +84 -83
  73. app/code/community/Temando/Temando/Model/Options.php +125 -123
  74. app/code/community/Temando/Temando/Model/Pcs.php +109 -111
  75. app/code/community/Temando/Temando/Model/Quote.php +336 -332
  76. app/code/community/Temando/Temando/Model/Shipment.php +437 -422
  77. app/code/community/Temando/Temando/Model/Shipping/Carrier/Temando.php +592 -567
  78. app/code/community/Temando/Temando/Model/Shipping/Carrier/Temando/Source/Method.php +81 -82
  79. app/code/community/Temando/Temando/Model/Status.php +29 -29
  80. app/code/community/Temando/Temando/Model/System/Config/Backend/Form/Field/Required/Businessresidential.php +23 -23
  81. app/code/community/Temando/Temando/Model/System/Config/Backend/Form/Field/Required/Country.php +38 -38
  82. app/code/community/Temando/Temando/Model/System/Config/Backend/Form/Field/Required/Location.php +51 -48
  83. app/code/community/Temando/Temando/Model/System/Config/Backend/Form/Field/Required/Text.php +23 -23
  84. app/code/community/Temando/Temando/Model/System/Config/Source.php +87 -87
  85. app/code/community/Temando/Temando/Model/System/Config/Source/Carbon.php +25 -25
  86. app/code/community/Temando/Temando/Model/System/Config/Source/Client/Type.php +22 -22
  87. app/code/community/Temando/Temando/Model/System/Config/Source/Country.php +23 -26
  88. app/code/community/Temando/Temando/Model/System/Config/Source/Errorprocess.php +23 -23
  89. app/code/community/Temando/Temando/Model/System/Config/Source/Footprints.php +25 -25
  90. app/code/community/Temando/Temando/Model/System/Config/Source/Insurance.php +25 -25
  91. app/code/community/Temando/Temando/Model/System/Config/Source/Labeltype.php +23 -23
  92. app/code/community/Temando/Temando/Model/System/Config/Source/Origin/Type.php +22 -22
  93. app/code/community/Temando/Temando/Model/System/Config/Source/Payment.php +22 -22
  94. app/code/community/Temando/Temando/Model/System/Config/Source/Pricing.php +32 -31
  95. app/code/community/Temando/Temando/Model/System/Config/Source/Readytime.php +23 -23
  96. app/code/community/Temando/Temando/Model/System/Config/Source/Regions.php +29 -29
  97. app/code/community/Temando/Temando/Model/System/Config/Source/Rule/Action/Adjustment/Type.php +31 -32
  98. app/code/community/Temando/Temando/Model/System/Config/Source/Rule/Action/Filter.php +25 -26
  99. app/code/community/Temando/Temando/Model/System/Config/Source/Rule/Condition/Time.php +23 -23
  100. app/code/community/Temando/Temando/Model/System/Config/Source/Rule/Condition/Type.php +23 -24
  101. app/code/community/Temando/Temando/Model/System/Config/Source/Rule/Type.php +25 -26
  102. app/code/community/Temando/Temando/Model/System/Config/Source/Sales/Order/Status.php +35 -32
  103. app/code/community/Temando/Temando/Model/System/Config/Source/Shipment/Class.php +33 -33
  104. app/code/community/Temando/Temando/Model/System/Config/Source/Shipment/Packaging.php +55 -55
  105. app/code/community/Temando/Temando/Model/System/Config/Source/Shipment/Packaging/Mode.php +22 -22
  106. app/code/community/Temando/Temando/Model/System/Config/Source/Shipment/Service.php +24 -25
  107. app/code/community/Temando/Temando/Model/System/Config/Source/Shipment/Status.php +23 -23
  108. app/code/community/Temando/Temando/Model/System/Config/Source/Unit.php +62 -62
  109. app/code/community/Temando/Temando/Model/System/Config/Source/Unit/Measure.php +36 -37
  110. app/code/community/Temando/Temando/Model/System/Config/Source/Unit/Weight.php +37 -37
  111. app/code/community/Temando/Temando/Model/System/Config/Source/Wizard.php +31 -31
  112. app/code/community/Temando/Temando/Model/Wizard.php +234 -206
  113. app/code/community/Temando/Temando/controllers/Adminhtml/CarrierController.php +101 -98
  114. app/code/community/Temando/Temando/controllers/Adminhtml/JsonController.php +72 -72
  115. app/code/community/Temando/Temando/controllers/Adminhtml/ManifestController.php +350 -317
  116. app/code/community/Temando/Temando/controllers/Adminhtml/ShipmentController.php +569 -548
  117. app/code/community/Temando/Temando/controllers/Adminhtml/WizardController.php +52 -52
  118. app/code/community/Temando/Temando/controllers/PcsController.php +257 -258
  119. app/code/community/Temando/Temando/controllers/WizardController.php +139 -120
  120. app/code/community/Temando/Temando/data/temando_setup/data-install-1.0.0.php +32 -0
  121. app/code/community/Temando/Temando/etc/config.xml +238 -234
  122. app/code/community/Temando/Temando/etc/system.xml +44 -6
  123. app/code/community/Temando/Temando/sql/temando_setup/mysql4-install-1.0.0.php +319 -303
  124. app/code/community/Temando/Temando/sql/temando_setup/mysql4-upgrade-1.3.8-1.3.9.php +72 -70
  125. app/code/community/Temando/Temando/sql/temando_setup/mysql4-upgrade-1.4.4-1.4.5.php +22 -0
  126. app/design/adminhtml/default/default/template/temando/temando/origin-avs.phtml +2 -0
  127. app/design/adminhtml/default/default/template/temando/temando/shipment/anywhere.phtml +2 -0
  128. app/design/frontend/base/default/template/temando/temando/checkout/cart/shipping.phtml +3 -1
  129. app/design/frontend/base/default/template/temando/temando/customer/address/edit.phtml +3 -1
  130. app/design/frontend/base/default/template/temando/temando/pcs.phtml +16 -14
  131. app/design/frontend/base/default/template/temando/temando/product/shipping.phtml +3 -1
  132. app/design/frontend/base/default/template/temando/temando/wizard/origin.phtml +3 -1
  133. app/etc/modules/Temando_Temando.xml +9 -9
  134. package.xml +7 -9
  135. skin/adminhtml/default/default/temando/styles.css +40 -40
  136. skin/frontend/base/default/css/temando/autocomplete.css +8 -8
  137. skin/frontend/base/default/css/temando/cart.css +18 -18
  138. skin/frontend/base/default/css/temando/product.css +38 -38
  139. skin/frontend/base/default/css/temando/styles.css +80 -80
app/code/community/Temando/Temando/Block/Adminhtml/Manifest.php CHANGED
@@ -1,40 +1,40 @@
1
- <?php
2
- /**
3
- * Admin Manifest Block
4
- *
5
- * @package Temando_Temando
6
- * @author Temando Magento Team <marketing@temando.com>
7
- */
8
- class Temando_Temando_Block_Adminhtml_Manifest
9
- extends Mage_Adminhtml_Block_Widget_Grid_Container
10
- {
11
-
12
- public function __construct()
13
- {
14
- $this->_blockGroup = 'temando';
15
- $this->_controller = 'adminhtml_manifest';
16
- $this->_headerText = Mage::helper('temando')->__('Manage Manifests');
17
- parent::__construct();
18
- $this->setTemplate('temando/temando/manifest.phtml');
19
- $this->removeButton('add');
20
-
21
- $add_button_method = 'addButton';
22
- if (!method_exists($this, $add_button_method)) {
23
- $add_button_method = '_addButton';
24
- }
25
-
26
- $this->$add_button_method('add_form_submit', array(
27
- 'label' => Mage::helper('temando')->__('Draft Manifest'),
28
- 'onclick' => 'addFormSubmit()'
29
- ));
30
- $this->$add_button_method('retrieve', array(
31
- 'label' => Mage::helper('temando')->__('Retrieve Previous Manifest'),
32
- 'onclick' => 'retrieveFormSubmit()',
33
- ));
34
- $this->$add_button_method('confirm', array(
35
- 'label' => Mage::helper('temando')->__('Confirm Manifests'),
36
- 'onclick' => 'setLocation(\'' . $this->getUrl('*/*/confirm') .'\')',
37
- ));
38
- }
39
-
40
- }
1
+ <?php
2
+ /**
3
+ * Admin Manifest Block
4
+ *
5
+ * @package Temando_Temando
6
+ * @author Temando Magento Team <marketing@temando.com>
7
+ */
8
+ class Temando_Temando_Block_Adminhtml_Manifest
9
+ extends Mage_Adminhtml_Block_Widget_Grid_Container
10
+ {
11
+
12
+ public function __construct()
13
+ {
14
+ $this->_blockGroup = 'temando';
15
+ $this->_controller = 'adminhtml_manifest';
16
+ $this->_headerText = Mage::helper('temando')->__('Manage Manifests');
17
+ parent::__construct();
18
+ $this->setTemplate('temando/temando/manifest.phtml');
19
+ $this->removeButton('add');
20
+
21
+ $add_button_method = 'addButton';
22
+ if (!method_exists($this, $add_button_method)) {
23
+ $add_button_method = '_addButton';
24
+ }
25
+
26
+ $this->$add_button_method('add_form_submit', array(
27
+ 'label' => Mage::helper('temando')->__('Draft Manifest'),
28
+ 'onclick' => 'addFormSubmit()'
29
+ ));
30
+ $this->$add_button_method('retrieve', array(
31
+ 'label' => Mage::helper('temando')->__('Retrieve Previous Manifest'),
32
+ 'onclick' => 'retrieveFormSubmit()',
33
+ ));
34
+ $this->$add_button_method('confirm', array(
35
+ 'label' => Mage::helper('temando')->__('Confirm Manifests'),
36
+ 'onclick' => 'setLocation(\'' . $this->getUrl('*/*/confirm') .'\')',
37
+ ));
38
+ }
39
+
40
+ }
app/code/community/Temando/Temando/Block/Adminhtml/Manifest/Filter/Form.php CHANGED
@@ -1,56 +1,61 @@
1
- <?php
2
- /**
3
- * Manifest Filter Form
4
- *
5
- * @package Temando_Temando
6
- * @author Temando Magento Team <marketing@temando.com>
7
- */
8
- class Temando_Temando_Block_Adminhtml_Manifest_Filter_Form extends Mage_Adminhtml_Block_Widget_Form
9
- {
10
- /**
11
- * Add fields to base fieldset which are general to sales reports
12
- *
13
- * @return Mage_Sales_Block_Adminhtml_Report_Filter_Form
14
- */
15
- protected function _prepareForm()
16
- {
17
- $actionUrl = $this->getUrl('*/*/add');
18
- $form = new Varien_Data_Form(
19
- array('id' => 'add_form', 'action' => $actionUrl, 'method' => 'post')
20
- );
21
- $htmlIdPrefix = 'add_manifest_';
22
- $form->setHtmlIdPrefix($htmlIdPrefix);
23
- $fieldset = $form->addFieldset('base_fieldset', array('legend'=>Mage::helper('temando')->__("Create New Manifest - Please note, to manifest you must have a permanent pickup.")));
24
-
25
- $dateFormatIso = Mage::app()->getLocale()->getDateFormat(Mage_Core_Model_Locale::FORMAT_TYPE_SHORT);
26
-
27
- $fieldset->addField('warehouse_id', 'select', array(
28
- 'name' => 'warehouse_id',
29
- 'options' => Mage::helper('temando')->getLocationList(),
30
- 'label' => Mage::helper('temando')->__('Location'),
31
- 'title' => Mage::helper('temando')->__('Location')
32
- ));
33
-
34
- $fieldset->addField('carrier_id', 'multiselect', array(
35
- 'name' => 'carrier_id[]',
36
- 'values' => Mage::getModel('temando/shipping_carrier_temando_source_method')->toOptionArray(),
37
- 'label' => Mage::helper('temando')->__('Carrier'),
38
- 'required' => true
39
- ));
40
-
41
- $fieldset->addField('from', 'date', array(
42
- 'name' => 'from',
43
- 'format' => $dateFormatIso,
44
- 'image' => $this->getSkinUrl('images/grid-cal.gif'),
45
- 'label' => Mage::helper('temando')->__('Date'),
46
- 'title' => Mage::helper('temando')->__('Date'),
47
- 'time' => false,
48
- 'required' => true
49
- ));
50
-
51
- $form->setUseContainer(true);
52
- $this->setForm($form);
53
-
54
- return parent::_prepareForm();
55
- }
56
- }
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Manifest Filter Form
4
+ *
5
+ * @package Temando_Temando
6
+ * @author Temando Magento Team <marketing@temando.com>
7
+ */
8
+ class Temando_Temando_Block_Adminhtml_Manifest_Filter_Form extends Mage_Adminhtml_Block_Widget_Form
9
+ {
10
+ /**
11
+ * Add fields to base fieldset which are general to sales reports
12
+ *
13
+ * @return Mage_Sales_Block_Adminhtml_Report_Filter_Form
14
+ */
15
+ protected function _prepareForm()
16
+ {
17
+ $actionUrl = $this->getUrl('*/*/add');
18
+ $form = new Varien_Data_Form(
19
+ array('id' => 'add_form', 'action' => $actionUrl, 'method' => 'post')
20
+ );
21
+ $htmlIdPrefix = 'add_manifest_';
22
+ $form->setHtmlIdPrefix($htmlIdPrefix);
23
+ $fieldset = $form->addFieldset(
24
+ 'base_fieldset',
25
+ array(
26
+ 'legend'=>Mage::helper('temando')
27
+ ->__("Create New Manifest - Please note, to manifest you must have a permanent pickup.")
28
+ )
29
+ );
30
+
31
+ $dateFormatIso = Mage::app()->getLocale()->getDateFormat(Mage_Core_Model_Locale::FORMAT_TYPE_SHORT);
32
+
33
+ $fieldset->addField('warehouse_id', 'select', array(
34
+ 'name' => 'warehouse_id',
35
+ 'options' => Mage::helper('temando')->getLocationList(),
36
+ 'label' => Mage::helper('temando')->__('Location'),
37
+ 'title' => Mage::helper('temando')->__('Location')
38
+ ));
39
+
40
+ $fieldset->addField('carrier_id', 'multiselect', array(
41
+ 'name' => 'carrier_id[]',
42
+ 'values' => Mage::getModel('temando/shipping_carrier_temando_source_method')->toOptionArray(),
43
+ 'label' => Mage::helper('temando')->__('Carrier'),
44
+ 'required' => true
45
+ ));
46
+
47
+ $fieldset->addField('from', 'date', array(
48
+ 'name' => 'from',
49
+ 'format' => $dateFormatIso,
50
+ 'image' => $this->getSkinUrl('images/grid-cal.gif'),
51
+ 'label' => Mage::helper('temando')->__('Date'),
52
+ 'title' => Mage::helper('temando')->__('Date'),
53
+ 'time' => false,
54
+ 'required' => true
55
+ ));
56
+
57
+ $form->setUseContainer(true);
58
+ $this->setForm($form);
59
+ return parent::_prepareForm();
60
+ }
61
+ }
app/code/community/Temando/Temando/Block/Adminhtml/Manifest/Grid.php CHANGED
@@ -1,156 +1,158 @@
1
- <?php
2
- /**
3
- * Manifest Grid
4
- *
5
- * @package Temando_Temando
6
- * @author Temando Magento Team <marketing@temando.com>
7
- */
8
- class Temando_Temando_Block_Adminhtml_Manifest_Grid
9
- extends Mage_Adminhtml_Block_Widget_Grid
10
- {
11
-
12
- public function __construct()
13
- {
14
- parent::__construct();
15
- $this->setDefaultSort('created_at');
16
- $this->setDefaultDir('DESC');
17
- $this->setSaveParametersInSession(true);
18
- }
19
-
20
- protected function _prepareCollection()
21
- {
22
- $collection = Mage::getModel('temando/manifest')->getCollection();
23
- /* @var $collection Temando_Temando_Model_Manifest */
24
- $this->setCollection($collection);
25
- return parent::_prepareCollection();
26
- }
27
-
28
- protected function _prepareColumns()
29
- {
30
-
31
- $this->addColumn('created_at', array(
32
- 'header' => Mage::helper('temando')->__('Created At'),
33
- 'width' => '100px',
34
- 'type' => 'datetime',
35
- 'index' => 'created_at',
36
- ));
37
-
38
- $this->addColumn('location_id', array(
39
- 'header' => Mage::helper('temando')->__('Location'),
40
- 'index' => 'location_id',
41
- 'type' => 'text',
42
- 'width' => '200px',
43
- ));
44
-
45
- $this->addColumn('carrier_id', array(
46
- 'header' => Mage::helper('temando')->__('Carrier'),
47
- 'index' => 'carrier_id',
48
- 'type' => 'options',
49
- 'width' => '100px',
50
- 'options' => Mage::getModel('temando/shipping_carrier_temando_source_method')->getOptions(),
51
- ));
52
-
53
- $this->addColumn('start_date', array(
54
- 'header' => Mage::helper('temando')->__('Date'),
55
- 'width' => '100px',
56
- 'type' => 'date',
57
- 'index' => 'start_date',
58
- ));
59
-
60
- $this->addColumn('status', array(
61
- 'header' => Mage::helper('temando')->__('Type'),
62
- 'index' => 'type',
63
- 'type' => 'options',
64
- 'width' => '100px',
65
- 'options' => array('Awaiting Confirmation' => 'Awaiting Confirmation', 'Confirmed' => 'Confirmed'),
66
- ));
67
-
68
- $this->addColumn('action_man',
69
- array(
70
- 'header' => Mage::helper('temando')->__('Manifest Document'),
71
- 'width' => '100',
72
- 'type' => 'action',
73
- 'getter' => 'getId',
74
- 'actions' => array(
75
- array(
76
- 'caption' => Mage::helper('temando')->__('Download'),
77
- 'url' => array('base'=> '*/*/manifest'),
78
- 'field' => 'id'
79
- ),
80
- ),
81
- 'filter' => false,
82
- 'sortable' => false,
83
- 'is_system' => true,
84
- ));
85
-
86
- $this->addColumn('action_lab',
87
- array(
88
- 'header' => Mage::helper('temando')->__('Label Document'),
89
- 'width' => '100',
90
- 'type' => 'action',
91
- 'getter' => 'getId',
92
- 'actions' => array(
93
- array(
94
- 'caption' => Mage::helper('temando')->__('Download'),
95
- 'url' => array('base'=> '*/*/label'),
96
- 'field' => 'id'
97
- ),
98
- ),
99
- 'filter' => false,
100
- 'sortable' => false,
101
- 'is_system' => true,
102
- ));
103
-
104
- return parent::_prepareColumns();
105
- }
106
-
107
- public function getRowUrl($row)
108
- {
109
- }
110
-
111
- protected function _prepareMassaction___()
112
- {
113
- $this->setMassactionIdField('manifest_id');
114
- $this->getMassactionBlock()->setFormFieldName('manifest');
115
-
116
- $this->getMassactionBlock()->addItem('confirm', array(
117
- 'label'=> Mage::helper('catalog')->__('Confirm'),
118
- 'url' => $this->getUrl('*/*/massConfirm'),
119
- 'confirm' => Mage::helper('temando')->__('Are you sure?')
120
- ));
121
- }
122
-
123
- /**
124
- * Prepare grid massaction column
125
- *
126
- * @return unknown
127
- */
128
- protected function _prepareMassactionColumn()
129
- {
130
- $columnId = 'massaction';
131
- $massactionColumn = $this->getLayout()->createBlock('adminhtml/widget_grid_column')
132
- ->setData(array(
133
- 'index' => $this->getMassactionIdField(),
134
- 'type' => 'massaction',
135
- 'name' => $this->getMassactionBlock()->getFormFieldName(),
136
- 'align' => 'center',
137
- 'is_system' => true,
138
- 'renderer' => 'temando/adminhtml_manifest_grid_renderer_checkbox',
139
- ));
140
-
141
- if ($this->getNoFilterMassactionColumn()) {
142
- $massactionColumn->setData('filter', false);
143
- }
144
-
145
- $massactionColumn->setSelected($this->getMassactionBlock()->getSelected())
146
- ->setGrid($this)
147
- ->setId($columnId);
148
-
149
- $oldColumns = $this->_columns;
150
- $this->_columns = array();
151
- $this->_columns[$columnId] = $massactionColumn;
152
- $this->_columns = array_merge($this->_columns, $oldColumns);
153
- return $this;
154
- }
155
-
156
- }
 
 
1
+ <?php
2
+ /**
3
+ * Manifest Grid
4
+ *
5
+ * @package Temando_Temando
6
+ * @author Temando Magento Team <marketing@temando.com>
7
+ */
8
+ class Temando_Temando_Block_Adminhtml_Manifest_Grid
9
+ extends Mage_Adminhtml_Block_Widget_Grid
10
+ {
11
+
12
+ public function __construct()
13
+ {
14
+ parent::__construct();
15
+ $this->setDefaultSort('created_at');
16
+ $this->setDefaultDir('DESC');
17
+ $this->setSaveParametersInSession(true);
18
+ }
19
+
20
+ protected function _prepareCollection()
21
+ {
22
+ $collection = Mage::getModel('temando/manifest')->getCollection();
23
+ /* @var $collection Temando_Temando_Model_Manifest */
24
+ $this->setCollection($collection);
25
+ return parent::_prepareCollection();
26
+ }
27
+
28
+ protected function _prepareColumns()
29
+ {
30
+
31
+ $this->addColumn('created_at', array(
32
+ 'header' => Mage::helper('temando')->__('Created At'),
33
+ 'width' => '100px',
34
+ 'type' => 'datetime',
35
+ 'index' => 'created_at',
36
+ ));
37
+
38
+ $this->addColumn('location_id', array(
39
+ 'header' => Mage::helper('temando')->__('Location'),
40
+ 'index' => 'location_id',
41
+ 'type' => 'text',
42
+ 'width' => '200px',
43
+ ));
44
+
45
+ $this->addColumn('carrier_id', array(
46
+ 'header' => Mage::helper('temando')->__('Carrier'),
47
+ 'index' => 'carrier_id',
48
+ 'type' => 'options',
49
+ 'width' => '100px',
50
+ 'options' => Mage::getModel('temando/shipping_carrier_temando_source_method')->getOptions(),
51
+ ));
52
+
53
+ $this->addColumn('start_date', array(
54
+ 'header' => Mage::helper('temando')->__('Date'),
55
+ 'width' => '100px',
56
+ 'type' => 'date',
57
+ 'index' => 'start_date',
58
+ ));
59
+
60
+ $this->addColumn('status', array(
61
+ 'header' => Mage::helper('temando')->__('Type'),
62
+ 'index' => 'type',
63
+ 'type' => 'options',
64
+ 'width' => '100px',
65
+ 'options' => array('Awaiting Confirmation' => 'Awaiting Confirmation', 'Confirmed' => 'Confirmed'),
66
+ ));
67
+
68
+ $this->addColumn(
69
+ 'action_man',
70
+ array(
71
+ 'header' => Mage::helper('temando')->__('Manifest Document'),
72
+ 'width' => '100',
73
+ 'type' => 'action',
74
+ 'getter' => 'getId',
75
+ 'actions' => array(
76
+ array(
77
+ 'caption' => Mage::helper('temando')->__('Download'),
78
+ 'url' => array('base'=> '*/*/manifest'),
79
+ 'field' => 'id'
80
+ ),
81
+ ),
82
+ 'filter' => false,
83
+ 'sortable' => false,
84
+ 'is_system' => true,
85
+ )
86
+ );
87
+
88
+ $this->addColumn(
89
+ 'action_lab',
90
+ array(
91
+ 'header' => Mage::helper('temando')->__('Label Document'),
92
+ 'width' => '100',
93
+ 'type' => 'action',
94
+ 'getter' => 'getId',
95
+ 'actions' => array(
96
+ array(
97
+ 'caption' => Mage::helper('temando')->__('Download'),
98
+ 'url' => array('base'=> '*/*/label'),
99
+ 'field' => 'id'
100
+ ),
101
+ ),
102
+ 'filter' => false,
103
+ 'sortable' => false,
104
+ 'is_system' => true,
105
+ )
106
+ );
107
+
108
+ return parent::_prepareColumns();
109
+ }
110
+
111
+ public function getRowUrl($row)
112
+ {
113
+ }
114
+
115
+ protected function _prepareMassaction___()
116
+ {
117
+ $this->setMassactionIdField('manifest_id');
118
+ $this->getMassactionBlock()->setFormFieldName('manifest');
119
+ $this->getMassactionBlock()->addItem('confirm', array(
120
+ 'label'=> Mage::helper('catalog')->__('Confirm'),
121
+ 'url' => $this->getUrl('*/*/massConfirm'),
122
+ 'confirm' => Mage::helper('temando')->__('Are you sure?')
123
+ ));
124
+ }
125
+
126
+ /**
127
+ * Prepare grid massaction column
128
+ *
129
+ * @return unknown
130
+ */
131
+ protected function _prepareMassactionColumn()
132
+ {
133
+ $columnId = 'massaction';
134
+ $massactionColumn = $this->getLayout()->createBlock('adminhtml/widget_grid_column')
135
+ ->setData(array(
136
+ 'index' => $this->getMassactionIdField(),
137
+ 'type' => 'massaction',
138
+ 'name' => $this->getMassactionBlock()->getFormFieldName(),
139
+ 'align' => 'center',
140
+ 'is_system' => true,
141
+ 'renderer' => 'temando/adminhtml_manifest_grid_renderer_checkbox',
142
+ ));
143
+
144
+ if ($this->getNoFilterMassactionColumn()) {
145
+ $massactionColumn->setData('filter', false);
146
+ }
147
+
148
+ $massactionColumn->setSelected($this->getMassactionBlock()->getSelected())
149
+ ->setGrid($this)
150
+ ->setId($columnId);
151
+
152
+ $oldColumns = $this->_columns;
153
+ $this->_columns = array();
154
+ $this->_columns[$columnId] = $massactionColumn;
155
+ $this->_columns = array_merge($this->_columns, $oldColumns);
156
+ return $this;
157
+ }
158
+ }
app/code/community/Temando/Temando/Block/Adminhtml/Manifest/Grid/Renderer/Checkbox.php CHANGED
@@ -1,38 +1,36 @@
1
- <?php
2
- /**
3
- * Manifest Grid Renderer Checkbox
4
- *
5
- * @package Temando_Temando
6
- * @author Temando Magento Team <marketing@temando.com>
7
- */
8
- class Temando_Temando_Block_Adminhtml_Manifest_Grid_Renderer_Checkbox extends Mage_Adminhtml_Block_Widget_Grid_Column_Renderer_Massaction
9
- {
10
-
11
- protected function _getCheckboxHtml($value, $checked)
12
- {
13
- $disabled = '';
14
- $checked = ' checked="checked"';
15
- if ($this->getDisabledRow()) {
16
- $disabled = ' disabled="disabled"';
17
- $checked = '';
18
- }
19
-
20
- return '<input type="checkbox" name="'.$this->getColumn()->getName().'" value="' . $value . '" class="massaction-checkbox"'.$checked.$disabled.' />';
21
- }
22
- /**
23
- * Renders grid column
24
- *
25
- * @param Varien_Object $row
26
- * @return string
27
- */
28
- public function render(Varien_Object $row)
29
- {
30
- if ($row->getType() == 'Confirmed') {
31
- $this->setDisabledRow(true);
32
- }
33
-
34
- return parent::render($row);
35
- }
36
-
37
- }
38
-
1
+ <?php
2
+ /**
3
+ * Manifest Grid Renderer Checkbox
4
+ *
5
+ * @package Temando_Temando
6
+ * @author Temando Magento Team <marketing@temando.com>
7
+ */
8
+ class Temando_Temando_Block_Adminhtml_Manifest_Grid_Renderer_Checkbox
9
+ extends Mage_Adminhtml_Block_Widget_Grid_Column_Renderer_Massaction
10
+ {
11
+ protected function _getCheckboxHtml($value, $checked)
12
+ {
13
+ $disabled = '';
14
+ $checked = ' checked="checked"';
15
+ if ($this->getDisabledRow()) {
16
+ $disabled = ' disabled="disabled"';
17
+ $checked = '';
18
+ }
19
+
20
+ return '<input type="checkbox" name="'.$this->getColumn()->getName().
21
+ '" value="' . $value . '" class="massaction-checkbox"'.$checked.$disabled.' />';
22
+ }
23
+ /**
24
+ * Renders grid column
25
+ *
26
+ * @param Varien_Object $row
27
+ * @return string
28
+ */
29
+ public function render(Varien_Object $row)
30
+ {
31
+ if ($row->getType() == 'Confirmed') {
32
+ $this->setDisabledRow(true);
33
+ }
34
+ return parent::render($row);
35
+ }
36
+ }
 
 
app/code/community/Temando/Temando/Block/Adminhtml/Shipment.php CHANGED
@@ -1,21 +1,21 @@
1
- <?php
2
- /**
3
- * Admin Shipment Block
4
- *
5
- * @package Temando_Temando
6
- * @author Temando Magento Team <marketing@temando.com>
7
- */
8
- class Temando_Temando_Block_Adminhtml_Shipment
9
- extends Mage_Adminhtml_Block_Widget_Grid_Container
10
- {
11
-
12
- public function __construct()
13
- {
14
- $this->_blockGroup = 'temando';
15
- $this->_controller = 'adminhtml_shipment';
16
- $this->_headerText = Mage::helper('temando')->__('Manage Shipments');
17
- parent::__construct();
18
- $this->removeButton('add');
19
- }
20
-
21
- }
1
+ <?php
2
+ /**
3
+ * Admin Shipment Block
4
+ *
5
+ * @package Temando_Temando
6
+ * @author Temando Magento Team <marketing@temando.com>
7
+ */
8
+ class Temando_Temando_Block_Adminhtml_Shipment
9
+ extends Mage_Adminhtml_Block_Widget_Grid_Container
10
+ {
11
+
12
+ public function __construct()
13
+ {
14
+ $this->_blockGroup = 'temando';
15
+ $this->_controller = 'adminhtml_shipment';
16
+ $this->_headerText = Mage::helper('temando')->__('Manage Shipments');
17
+ parent::__construct();
18
+ $this->removeButton('add');
19
+ }
20
+
21
+ }
app/code/community/Temando/Temando/Block/Adminhtml/Shipment/Edit.php CHANGED
@@ -1,229 +1,247 @@
1
- <?php
2
- /**
3
- * Shipment Edit
4
- *
5
- * @package Temando_Temando
6
- * @author Temando Magento Team <marketing@temando.com>
7
- */
8
- class Temando_Temando_Block_Adminhtml_Shipment_Edit
9
- extends Mage_Adminhtml_Block_Widget_Form_Container
10
- {
11
-
12
- protected $_shipment;
13
-
14
- public function __construct()
15
- {
16
- parent::__construct();
17
- $this->_blockGroup = 'temando';
18
- $this->_controller = 'adminhtml_shipment';
19
-
20
- $this->removeButton('save');
21
- $this->removeButton('delete');
22
-
23
- $add_button_method = 'addButton';
24
- if (!method_exists($this, $add_button_method)) {
25
- $add_button_method = '_addButton';
26
- }
27
-
28
- $this->$add_button_method('disabled_pickslip', array(
29
- 'label' => Mage::helper('temando')->__('Pick Slip'),
30
- 'id' => 'disabled_pickslip',
31
- 'onclick' => 'return false',
32
- 'class' => 'go disabled',
33
- 'title' => Mage::helper('temando')->__('Available in the Business Extension')
34
- ));
35
-
36
- if ($this->getShipment()->getStatus() == Temando_Temando_Model_System_Config_Source_Shipment_Status::PENDING) {
37
- $this->$add_button_method('getquote', array(
38
- 'label' => Mage::helper('temando')->__('Save and Get Quotes'),
39
- 'id' => 'getquote',
40
- 'onclick' => 'saveAndGetQuotes()',
41
- 'value' => '',
42
- 'class' => 'save',
43
- ));
44
- }
45
-
46
- if ($this->getShipment()->getStatus() == Temando_Temando_Model_System_Config_Source_Shipment_Status::BOOKED) {
47
- $class = 'go';
48
- $title = Mage::helper('temando')->__('View Consignment');
49
-
50
- $labelType = Mage::helper('temando')->getConfigData('options/label_type');
51
- $hasConsignment = true;
52
-
53
- if ((!$this->getShipment()->getConsignmentDocument() && $labelType == Temando_Temando_Model_System_Config_Source_Labeltype::STANDARD) ||
54
- (!$this->getShipment()->getLabelDocument() && $labelType == Temando_Temando_Model_System_Config_Source_Labeltype::THERMAL)) {
55
- $class .= ' disabled';
56
- $hasConsignment = false;
57
- $title = Mage::helper('temando')->__('No Consignment');
58
- }
59
-
60
- $this->$add_button_method('consignment', array(
61
- 'label' => $title,
62
- 'id' => 'consignment',
63
- 'onclick' => $hasConsignment ? "window.location = '" . $this->getUrl('*/*/consignment', array('id' => $this->getRequest()->getParam('id'))) . "'" : "",
64
- 'value' => '',
65
- 'class' => $class,
66
- ));
67
-
68
- $this->_removeButton('reset');
69
- }
70
-
71
- $max_boxes = 40;
72
- $script = "
73
- function saveAndGetQuotes() {
74
- editForm.submit($('edit_form').action+'and/getquotes/');
75
- }
76
-
77
- function saveAndEditNext() {
78
- editForm.submit($('edit_form').action+'and/editnext/');
79
- }
80
-
81
- function box_add() {
82
- num_boxes = $$('table#boxes tbody tr').length - 1;
83
- if (num_boxes < $max_boxes) {
84
- if (!box_add.highest_num) {
85
- box_add.highest_num = num_boxes;
86
- }
87
- // add a new box (row) to the table
88
- new_row = new Element('tr');
89
- new_row.id = 'box_row_' + ++box_add.highest_num;
90
- new_row
91
- .addClassName(box_add.highest_num % 2 ? 'odd' : 'even')
92
- .addClassName('new_box')
93
- .insert($('blank_box_row').innerHTML
94
- .replace(/@@id@@/g, box_add.highest_num)
95
- .replace(/box_blank/g, 'box'));
96
-
97
- $$('table#boxes tbody')[0].insert(new_row);
98
- return box_add.highest_num;
99
- } else {
100
- return false;
101
- }
102
- }
103
-
104
- function box_clear() {
105
- // remove all rows in the table.
106
- $$('table#boxes tr.existing_box, table#boxes tr.new_box').each(function (row) {
107
- row.remove();
108
- });
109
- }
110
-
111
- function box_remove(num) {
112
- row = $('box_row_' + num);
113
- if ($('box_' + num + '_id') && $('boxes_deleted')) {
114
- if (!$('boxes_deleted').value.length == 0) {
115
- $('boxes_deleted').value += ',';
116
- }
117
- $('boxes_deleted').value += $('box_' + num + '_id').value;
118
- }
119
- if (row) {
120
- row.remove();
121
- }
122
- }
123
-
124
- function box_import() {
125
- default_boxes = new Array();
126
- {$this->_getProductsJson('default_boxes')}
127
- for (var i = 0; i < default_boxes.length; i++) {
128
- box = default_boxes[i];
129
- num = box_add();
130
- if (num) {
131
- $('box_' + num + '_comment').value = box.comment;
132
- $('box_' + num + '_packaging').value = box.packaging;
133
- $('box_' + num + '_fragile').value = box.fragile;
134
- $('box_' + num + '_dangerous').value = box.dangerous;
135
- $('box_' + num + '_qty').value = box.qty;
136
- $('box_' + num + '_value').value = box.value;
137
- $('box_' + num + '_weight').value = box.weight;
138
- $('box_' + num + '_weight_unit').value = box.weight_unit;
139
- $('box_' + num + '_height').value = box.height;
140
- $('box_' + num + '_length').value = box.length;
141
- $('box_' + num + '_width').value = box.width;
142
- $('box_' + num + '_measure_unit').value = box.measure_unit;
143
- }
144
- }
145
- }
146
- ";
147
-
148
- $this->_formScripts[] = $script;
149
- }
150
-
151
- /**
152
- * Gets the shipment being edited.
153
- *
154
- * @return Temando_Temando_Model_Shipment
155
- */
156
- public function getShipment()
157
- {
158
- if (!$this->_shipment) {
159
- $this->_shipment = Mage::registry('temando_shipment_data');
160
- }
161
- return $this->_shipment;
162
- }
163
-
164
- /**
165
- * Gets the current order for the shipment being edited.
166
- *
167
- * @return Mage_Sales_Model_Order
168
- */
169
- public function getOrder()
170
- {
171
- if($this->getShipment()) {
172
- return $this->getShipment()->getOrder();
173
- }
174
- return null;
175
- }
176
-
177
- public function getHeaderText()
178
- {
179
- if ($this->getShipment() && $this->getShipment()->getId()) {
180
- return $foo= Mage::helper('temando')->__(
181
- 'Order # %s | %s',
182
- $this->htmlEscape($this->getShipment()->getOrder()->getRealOrderId()),
183
- $this->htmlEscape($this->formatDate($this->getShipment()->getOrder()->getCreatedAtDate(), 'medium', true))
184
- );
185
- }
186
- }
187
-
188
- protected function _getProductsJson($variable_name)
189
- {
190
- $products = '';
191
- foreach ($this->getShipment()->getOrder()->getAllItems() as $item) {
192
- if ($item->getParentItemId()) {
193
- // do not create box for child products
194
- continue;
195
- }
196
- /* @var $item Mage_Sales_Model_Order_Item */
197
- $product = Mage::getModel('catalog/product')->load($item->getProductId());
198
- /* @var $product Mage_Catalog_Model_Product */
199
- $helper = Mage::helper('temando');
200
- /* @var $helper Temando_Temando_Helper_Data */
201
- $weight = (float) $product->getWeight();
202
- $height = (float) $product->getTemandoHeight();
203
- $length = (float) $product->getTemandoLength();
204
- $width = (float) $product->getTemandoWidth();
205
- $packaging = $product->getTemandoPackaging();
206
- $fragile = $product->getTemandoFragile();
207
- $dangerous = $product->getTemandoDangerous();
208
-
209
- $products .= "
210
- $variable_name.push({
211
- 'comment': '" . addslashes($product->getName()) . "',
212
- 'packaging': '{$packaging}',
213
- 'fragile': '{$fragile}',
214
- 'dangerous': '{$dangerous}',
215
- 'qty': '{$item->getQtyToShip()}',
216
- 'value': '{$item->getRowTotal()}',
217
- 'weight': '$weight',
218
- 'weight_unit': '{$helper->getConfigData('units/weight')}',
219
- 'height': '$height',
220
- 'length': '$length',
221
- 'width': '$width',
222
- 'measure_unit': '{$helper->getConfigData('units/measure')}'
223
- });
224
- ";
225
- }
226
- return $products;
227
- }
228
-
229
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Shipment Edit
4
+ *
5
+ * @package Temando_Temando
6
+ * @author Temando Magento Team <marketing@temando.com>
7
+ */
8
+ class Temando_Temando_Block_Adminhtml_Shipment_Edit
9
+ extends Mage_Adminhtml_Block_Widget_Form_Container
10
+ {
11
+
12
+ protected $_shipment;
13
+
14
+ public function __construct()
15
+ {
16
+ parent::__construct();
17
+ $this->_blockGroup = 'temando';
18
+ $this->_controller = 'adminhtml_shipment';
19
+ $this->removeButton('save');
20
+ $this->removeButton('delete');
21
+ $add_button_method = 'addButton';
22
+ if (!method_exists($this, $add_button_method)) {
23
+ $add_button_method = '_addButton';
24
+ }
25
+
26
+ $this->$add_button_method(
27
+ 'disabled_pickslip',
28
+ array(
29
+ 'label' => Mage::helper('temando')->__('Pick Slip'),
30
+ 'id' => 'disabled_pickslip',
31
+ 'onclick' => 'return false',
32
+ 'class' => 'go disabled',
33
+ 'title' => Mage::helper('temando')->__('Available in the Business Extension')
34
+ )
35
+ );
36
+
37
+ if ($this->getShipment()->getStatus() ==
38
+ Temando_Temando_Model_System_Config_Source_Shipment_Status::PENDING) {
39
+ $this->$add_button_method(
40
+ 'getquote',
41
+ array(
42
+ 'label' => Mage::helper('temando')->__('Save and Get Quotes'),
43
+ 'id' => 'getquote',
44
+ 'onclick' => 'saveAndGetQuotes()',
45
+ 'value' => '',
46
+ 'class' => 'save',
47
+ )
48
+ );
49
+ }
50
+
51
+ if ($this->getShipment()->getStatus() == Temando_Temando_Model_System_Config_Source_Shipment_Status::BOOKED) {
52
+ $class = 'go';
53
+ $title = Mage::helper('temando')->__('View Consignment');
54
+
55
+ $labelType = Mage::helper('temando')->getConfigData('options/label_type');
56
+ $hasConsignment = true;
57
+
58
+ if ((!$this->getShipment()->getConsignmentDocument() &&
59
+ $labelType == Temando_Temando_Model_System_Config_Source_Labeltype::STANDARD) ||
60
+ (!$this->getShipment()->getLabelDocument() &&
61
+ $labelType == Temando_Temando_Model_System_Config_Source_Labeltype::THERMAL)) {
62
+ $class .= ' disabled';
63
+ $hasConsignment = false;
64
+ $title = Mage::helper('temando')->__('No Consignment');
65
+ }
66
+
67
+ $this->$add_button_method(
68
+ 'consignment',
69
+ array(
70
+ 'label' => $title,
71
+ 'id' => 'consignment',
72
+ 'onclick' => $hasConsignment ? "window.location = '" . $this->getUrl(
73
+ '*/*/consignment',
74
+ array(
75
+ 'id' => $this->getRequest()->getParam('id'))
76
+ ) . "'" : "",
77
+ 'value' => '',
78
+ 'class' => $class,
79
+ )
80
+ );
81
+ $this->_removeButton('reset');
82
+ }
83
+
84
+ $max_boxes = 40;
85
+ $script = "
86
+ function saveAndGetQuotes() {
87
+ editForm.submit($('edit_form').action+'and/getquotes/');
88
+ }
89
+
90
+ function saveAndEditNext() {
91
+ editForm.submit($('edit_form').action+'and/editnext/');
92
+ }
93
+
94
+ function box_add() {
95
+ num_boxes = $$('table#boxes tbody tr').length - 1;
96
+ if (num_boxes < $max_boxes) {
97
+ if (!box_add.highest_num) {
98
+ box_add.highest_num = num_boxes;
99
+ }
100
+ // add a new box (row) to the table
101
+ new_row = new Element('tr');
102
+ new_row.id = 'box_row_' + ++box_add.highest_num;
103
+ new_row
104
+ .addClassName(box_add.highest_num % 2 ? 'odd' : 'even')
105
+ .addClassName('new_box')
106
+ .insert($('blank_box_row').innerHTML
107
+ .replace(/@@id@@/g, box_add.highest_num)
108
+ .replace(/box_blank/g, 'box'));
109
+
110
+ $$('table#boxes tbody')[0].insert(new_row);
111
+ return box_add.highest_num;
112
+ } else {
113
+ return false;
114
+ }
115
+ }
116
+
117
+ function box_clear() {
118
+ // remove all rows in the table.
119
+ $$('table#boxes tr.existing_box, table#boxes tr.new_box').each(function (row) {
120
+ row.remove();
121
+ });
122
+ }
123
+
124
+ function box_remove(num) {
125
+ row = $('box_row_' + num);
126
+ if ($('box_' + num + '_id') && $('boxes_deleted')) {
127
+ if (!$('boxes_deleted').value.length == 0) {
128
+ $('boxes_deleted').value += ',';
129
+ }
130
+ $('boxes_deleted').value += $('box_' + num + '_id').value;
131
+ }
132
+ if (row) {
133
+ row.remove();
134
+ }
135
+ }
136
+
137
+ function box_import() {
138
+ default_boxes = new Array();
139
+ {$this->_getProductsJson('default_boxes')}
140
+ for (var i = 0; i < default_boxes.length; i++) {
141
+ box = default_boxes[i];
142
+ num = box_add();
143
+ if (num) {
144
+ $('box_' + num + '_comment').value = box.comment;
145
+ $('box_' + num + '_packaging').value = box.packaging;
146
+ $('box_' + num + '_fragile').value = box.fragile;
147
+ $('box_' + num + '_dangerous').value = box.dangerous;
148
+ $('box_' + num + '_qty').value = box.qty;
149
+ $('box_' + num + '_value').value = box.value;
150
+ $('box_' + num + '_weight').value = box.weight;
151
+ $('box_' + num + '_weight_unit').value = box.weight_unit;
152
+ $('box_' + num + '_height').value = box.height;
153
+ $('box_' + num + '_length').value = box.length;
154
+ $('box_' + num + '_width').value = box.width;
155
+ $('box_' + num + '_measure_unit').value = box.measure_unit;
156
+ }
157
+ }
158
+ }
159
+ ";
160
+
161
+ $this->_formScripts[] = $script;
162
+ }
163
+
164
+ /**
165
+ * Gets the shipment being edited.
166
+ *
167
+ * @return Temando_Temando_Model_Shipment
168
+ */
169
+ public function getShipment()
170
+ {
171
+ if (!$this->_shipment) {
172
+ $this->_shipment = Mage::registry('temando_shipment_data');
173
+ }
174
+ return $this->_shipment;
175
+ }
176
+
177
+ /**
178
+ * Gets the current order for the shipment being edited.
179
+ *
180
+ * @return Mage_Sales_Model_Order
181
+ */
182
+ public function getOrder()
183
+ {
184
+ if ($this->getShipment()) {
185
+ return $this->getShipment()->getOrder();
186
+ }
187
+ return null;
188
+ }
189
+
190
+ public function getHeaderText()
191
+ {
192
+ if ($this->getShipment() && $this->getShipment()->getId()) {
193
+ return $foo= Mage::helper('temando')->__(
194
+ 'Order # %s | %s',
195
+ $this->htmlEscape($this->getShipment()->getOrder()->getRealOrderId()),
196
+ $this->htmlEscape(
197
+ $this->formatDate(
198
+ $this->getShipment()->getOrder()->getCreatedAtDate(),
199
+ 'medium',
200
+ true
201
+ )
202
+ )
203
+ );
204
+ }
205
+ }
206
+
207
+ protected function _getProductsJson($variable_name)
208
+ {
209
+ $products = '';
210
+ foreach ($this->getShipment()->getOrder()->getAllItems() as $item) {
211
+ if ($item->getParentItemId()) {
212
+ // do not create box for child products
213
+ continue;
214
+ }
215
+ /* @var $item Mage_Sales_Model_Order_Item */
216
+ $product = Mage::getModel('catalog/product')->load($item->getProductId());
217
+ /* @var $product Mage_Catalog_Model_Product */
218
+ $helper = Mage::helper('temando');
219
+ /* @var $helper Temando_Temando_Helper_Data */
220
+ $weight = (float) $product->getWeight();
221
+ $height = (float) $product->getTemandoHeight();
222
+ $length = (float) $product->getTemandoLength();
223
+ $width = (float) $product->getTemandoWidth();
224
+ $packaging = $product->getTemandoPackaging();
225
+ $fragile = $product->getTemandoFragile();
226
+ $dangerous = $product->getTemandoDangerous();
227
+
228
+ $products .= "
229
+ $variable_name.push({
230
+ 'comment': '" . addslashes($product->getName()) . "',
231
+ 'packaging': '{$packaging}',
232
+ 'fragile': '{$fragile}',
233
+ 'dangerous': '{$dangerous}',
234
+ 'qty': '{$item->getQtyToShip()}',
235
+ 'value': '{$item->getRowTotal()}',
236
+ 'weight': '$weight',
237
+ 'weight_unit': '{$helper->getConfigData('units/weight')}',
238
+ 'height': '$height',
239
+ 'length': '$length',
240
+ 'width': '$width',
241
+ 'measure_unit': '{$helper->getConfigData('units/measure')}'
242
+ });
243
+ ";
244
+ }
245
+ return $products;
246
+ }
247
+ }
app/code/community/Temando/Temando/Block/Adminhtml/Shipment/Edit/Form.php CHANGED
@@ -1,33 +1,33 @@
1
- <?php
2
- /**
3
- * Shipment Edit Form
4
- *
5
- * @package Temando_Temando
6
- * @author Temando Magento Team <marketing@temando.com>
7
- */
8
- class Temando_Temando_Block_Adminhtml_Shipment_Edit_Form
9
- extends Mage_Adminhtml_Block_Widget_Form
10
- {
11
-
12
- /**
13
- * Prepare the form
14
- *
15
- * @return parent
16
- */
17
- protected function _prepareForm()
18
- {
19
- $form = new Varien_Data_Form(
20
- array(
21
- 'id' => 'edit_form',
22
- 'action' => $this->getUrl('*/*/save', array('id' => $this->getRequest()->getParam('id'))),
23
- 'method' => 'post',
24
- 'enctype' => 'multipart/form-data'
25
- )
26
- );
27
-
28
- $form->setUseContainer(true);
29
- $this->setForm($form);
30
- return parent::_prepareForm();
31
- }
32
-
33
- }
1
+ <?php
2
+ /**
3
+ * Shipment Edit Form
4
+ *
5
+ * @package Temando_Temando
6
+ * @author Temando Magento Team <marketing@temando.com>
7
+ */
8
+ class Temando_Temando_Block_Adminhtml_Shipment_Edit_Form
9
+ extends Mage_Adminhtml_Block_Widget_Form
10
+ {
11
+
12
+ /**
13
+ * Prepare the form
14
+ *
15
+ * @return parent
16
+ */
17
+ protected function _prepareForm()
18
+ {
19
+ $form = new Varien_Data_Form(
20
+ array(
21
+ 'id' => 'edit_form',
22
+ 'action' => $this->getUrl('*/*/save', array('id' => $this->getRequest()->getParam('id'))),
23
+ 'method' => 'post',
24
+ 'enctype' => 'multipart/form-data'
25
+ )
26
+ );
27
+
28
+ $form->setUseContainer(true);
29
+ $this->setForm($form);
30
+ return parent::_prepareForm();
31
+ }
32
+
33
+ }
app/code/community/Temando/Temando/Block/Adminhtml/Shipment/Edit/Tab/Abstract.php CHANGED
@@ -1,70 +1,71 @@
1
- <?php
2
- /**
3
- * Shipment Edit Tab Abstract
4
- *
5
- * @package Temando_Temando
6
- * @author Temando Magento Team <marketing@temando.com>
7
- */
8
- abstract class Temando_Temando_Block_Adminhtml_Shipment_Edit_Tab_Abstract
9
- extends Mage_Adminhtml_Block_Template
10
- {
11
-
12
- protected $_helper = null;
13
-
14
- public function __construct()
15
- {
16
- parent::__construct();
17
- $this->setParentBlock(Mage::getBlockSingleton('temando/adminhtml_shipment_edit'));
18
- }
19
-
20
- /**
21
- * Gets the shipment being edited.
22
- *
23
- * @return Temando_Temando_Model_Shipment
24
- */
25
- public function getShipment()
26
- {
27
- return $this->getParentBlock()->getShipment();
28
- }
29
-
30
- /**
31
- * Gets the saved Temando quotes for this order from the database.
32
- *
33
- * @return Temando_Temando_Model_Mysql4_Quote_Collection
34
- */
35
- public function getQuotes()
36
- {
37
- return $this->getShipment()->getQuotes(true);
38
- }
39
-
40
- public function formatCurrency($price)
41
- {
42
- return Mage::helper('core')->currency($price);
43
- }
44
-
45
- public function getWeightUnitText($unit = null)
46
- {
47
- if (!$unit) {
48
- $unit = $this->getTemandoHelper()->getConfigData('units/weight');
49
- }
50
- return Mage::getModel('temando/system_config_source_unit_weight')
51
- ->getBriefOptionLabel($unit);
52
- }
53
-
54
- public function getMeasureUnitText($unit = null)
55
- {
56
- if (!$unit) {
57
- $unit = $this->getTemandoHelper()->getConfigData('units/measure');
58
- }
59
- return Mage::getModel('temando/system_config_source_unit_measure')
60
- ->getBriefOptionLabel($unit);
61
- }
62
-
63
- public function getTemandoHelper() {
64
- if (!$this->_helper) {
65
- $this->_helper = Mage::helper('temando');
66
- }
67
- return $this->_helper;
68
- }
69
-
70
- }
 
1
+ <?php
2
+ /**
3
+ * Shipment Edit Tab Abstract
4
+ *
5
+ * @package Temando_Temando
6
+ * @author Temando Magento Team <marketing@temando.com>
7
+ */
8
+ abstract class Temando_Temando_Block_Adminhtml_Shipment_Edit_Tab_Abstract
9
+ extends Mage_Adminhtml_Block_Template
10
+ {
11
+
12
+ protected $_helper = null;
13
+
14
+ public function __construct()
15
+ {
16
+ parent::__construct();
17
+ $this->setParentBlock(Mage::getBlockSingleton('temando/adminhtml_shipment_edit'));
18
+ }
19
+
20
+ /**
21
+ * Gets the shipment being edited.
22
+ *
23
+ * @return Temando_Temando_Model_Shipment
24
+ */
25
+ public function getShipment()
26
+ {
27
+ return $this->getParentBlock()->getShipment();
28
+ }
29
+
30
+ /**
31
+ * Gets the saved Temando quotes for this order from the database.
32
+ *
33
+ * @return Temando_Temando_Model_Mysql4_Quote_Collection
34
+ */
35
+ public function getQuotes()
36
+ {
37
+ return $this->getShipment()->getQuotes(true);
38
+ }
39
+
40
+ public function formatCurrency($price)
41
+ {
42
+ return Mage::helper('core')->currency($price);
43
+ }
44
+
45
+ public function getWeightUnitText($unit = null)
46
+ {
47
+ if (!$unit) {
48
+ $unit = $this->getTemandoHelper()->getConfigData('units/weight');
49
+ }
50
+ return Mage::getModel('temando/system_config_source_unit_weight')
51
+ ->getBriefOptionLabel($unit);
52
+ }
53
+
54
+ public function getMeasureUnitText($unit = null)
55
+ {
56
+ if (!$unit) {
57
+ $unit = $this->getTemandoHelper()->getConfigData('units/measure');
58
+ }
59
+ return Mage::getModel('temando/system_config_source_unit_measure')
60
+ ->getBriefOptionLabel($unit);
61
+ }
62
+
63
+ public function getTemandoHelper()
64
+ {
65
+ if (!$this->_helper) {
66
+ $this->_helper = Mage::helper('temando');
67
+ }
68
+ return $this->_helper;
69
+ }
70
+
71
+ }
app/code/community/Temando/Temando/Block/Adminhtml/Shipment/Edit/Tab/Form.php CHANGED
@@ -1,41 +1,41 @@
1
- <?php
2
- /**
3
- * Shipment Edit Tab Form
4
- *
5
- * @package Temando_Temando
6
- * @author Temando Magento Team <marketing@temando.com>
7
- */
8
- class Temando_Temando_Block_Adminhtml_Shipment_Edit_Tab_Form
9
- extends Temando_Temando_Block_Adminhtml_Shipment_Edit_Tab_Abstract
10
- implements Mage_Adminhtml_Block_Widget_Tab_Interface
11
- {
12
-
13
- protected $_template = 'temando/temando/shipment.phtml';
14
-
15
- public function __construct()
16
- {
17
- parent::__construct();
18
- $this->setTemplate($this->_template);
19
- }
20
-
21
- public function getTabLabel()
22
- {
23
- return $this->__('Information');
24
- }
25
-
26
- public function getTabTitle()
27
- {
28
- return $this->__('Information');
29
- }
30
-
31
- public function canShowTab()
32
- {
33
- return true;
34
- }
35
-
36
- public function isHidden()
37
- {
38
- return false;
39
- }
40
-
41
- }
1
+ <?php
2
+ /**
3
+ * Shipment Edit Tab Form
4
+ *
5
+ * @package Temando_Temando
6
+ * @author Temando Magento Team <marketing@temando.com>
7
+ */
8
+ class Temando_Temando_Block_Adminhtml_Shipment_Edit_Tab_Form
9
+ extends Temando_Temando_Block_Adminhtml_Shipment_Edit_Tab_Abstract
10
+ implements Mage_Adminhtml_Block_Widget_Tab_Interface
11
+ {
12
+
13
+ protected $_template = 'temando/temando/shipment.phtml';
14
+
15
+ public function __construct()
16
+ {
17
+ parent::__construct();
18
+ $this->setTemplate($this->_template);
19
+ }
20
+
21
+ public function getTabLabel()
22
+ {
23
+ return $this->__('Information');
24
+ }
25
+
26
+ public function getTabTitle()
27
+ {
28
+ return $this->__('Information');
29
+ }
30
+
31
+ public function canShowTab()
32
+ {
33
+ return true;
34
+ }
35
+
36
+ public function isHidden()
37
+ {
38
+ return false;
39
+ }
40
+
41
+ }
app/code/community/Temando/Temando/Block/Adminhtml/Shipment/Edit/Tab/Form/Anytime.php CHANGED
@@ -1,14 +1,14 @@
1
- <?php
2
- /**
3
- * Shipment Edit Tab Form Anytime
4
- *
5
- * @package Temando_Temando
6
- * @author Temando Magento Team <marketing@temando.com>
7
- */
8
- class Temando_Temando_Block_Adminhtml_Shipment_Edit_Tab_Form_Anytime
9
- extends Temando_Temando_Block_Adminhtml_Shipment_Edit_Tab_Abstract
10
- {
11
-
12
-
13
-
14
- }
1
+ <?php
2
+ /**
3
+ * Shipment Edit Tab Form Anytime
4
+ *
5
+ * @package Temando_Temando
6
+ * @author Temando Magento Team <marketing@temando.com>
7
+ */
8
+ class Temando_Temando_Block_Adminhtml_Shipment_Edit_Tab_Form_Anytime
9
+ extends Temando_Temando_Block_Adminhtml_Shipment_Edit_Tab_Abstract
10
+ {
11
+
12
+
13
+
14
+ }
app/code/community/Temando/Temando/Block/Adminhtml/Shipment/Edit/Tab/Form/Anywhere.php CHANGED
@@ -1,14 +1,14 @@
1
- <?php
2
- /**
3
- * Shipment Edit Tab Form Anywhere
4
- *
5
- * @package Temando_Temando
6
- * @author Temando Magento Team <marketing@temando.com>
7
- */
8
- class Temando_Temando_Block_Adminhtml_Shipment_Edit_Tab_Form_Anywhere
9
- extends Temando_Temando_Block_Adminhtml_Shipment_Edit_Tab_Abstract
10
- {
11
-
12
-
13
-
14
- }
1
+ <?php
2
+ /**
3
+ * Shipment Edit Tab Form Anywhere
4
+ *
5
+ * @package Temando_Temando
6
+ * @author Temando Magento Team <marketing@temando.com>
7
+ */
8
+ class Temando_Temando_Block_Adminhtml_Shipment_Edit_Tab_Form_Anywhere
9
+ extends Temando_Temando_Block_Adminhtml_Shipment_Edit_Tab_Abstract
10
+ {
11
+
12
+
13
+
14
+ }
app/code/community/Temando/Temando/Block/Adminhtml/Shipment/Edit/Tab/Form/Boxes.php CHANGED
@@ -1,31 +1,30 @@
1
- <?php
2
- /**
3
- * Shipment Edit Tab Form Boxes
4
- *
5
- * @package Temando_Temando
6
- * @author Temando Magento Team <marketing@temando.com>
7
- */
8
- class Temando_Temando_Block_Adminhtml_Shipment_Edit_Tab_Form_Boxes
9
- extends Temando_Temando_Block_Adminhtml_Shipment_Edit_Tab_Abstract
10
- {
11
-
12
- /**
13
- * Array of all available packaging types (default & custom)
14
- *
15
- * @var array
16
- */
17
- protected $_packagingTypes = null;
18
-
19
- /**
20
- * Returns array of all available packaging types
21
- */
22
- public function getPackagingTypes()
23
- {
24
- if(is_null($this->_packagingTypes)) {
25
- $this->_packagingTypes = Mage::getModel('temando/system_config_source_shipment_packaging')->toOptionArray();
26
- }
27
-
28
- return $this->_packagingTypes;
29
- }
30
-
31
- }
1
+ <?php
2
+ /**
3
+ * Shipment Edit Tab Form Boxes
4
+ *
5
+ * @package Temando_Temando
6
+ * @author Temando Magento Team <marketing@temando.com>
7
+ */
8
+ class Temando_Temando_Block_Adminhtml_Shipment_Edit_Tab_Form_Boxes
9
+ extends Temando_Temando_Block_Adminhtml_Shipment_Edit_Tab_Abstract
10
+ {
11
+
12
+ /**
13
+ * Array of all available packaging types (default & custom)
14
+ *
15
+ * @var array
16
+ */
17
+ protected $_packagingTypes = null;
18
+
19
+ /**
20
+ * Returns array of all available packaging types
21
+ */
22
+ public function getPackagingTypes()
23
+ {
24
+ if (is_null($this->_packagingTypes)) {
25
+ $this->_packagingTypes = Mage::getModel('temando/system_config_source_shipment_packaging')->toOptionArray();
26
+ }
27
+ return $this->_packagingTypes;
28
+ }
29
+
30
+ }
 
app/code/community/Temando/Temando/Block/Adminhtml/Shipment/Edit/Tab/Form/Insurance.php CHANGED
@@ -1,44 +1,44 @@
1
- <?php
2
- /**
3
- * Shipment Edit Tab Form Insurance
4
- *
5
- * @package Temando_Temando
6
- * @author Temando Magento Team <marketing@temando.com>
7
- */
8
- class Temando_Temando_Block_Adminhtml_Shipment_Edit_Tab_Form_Insurance
9
- extends Temando_Temando_Block_Adminhtml_Shipment_Edit_Tab_Abstract
10
- {
11
-
12
- public function getTotalGoodsValue()
13
- {
14
- $order_id = $this->getShipment()->getOrderId();
15
- $goods_value = 0;
16
- foreach (Mage::getModel('sales/order')->load($order_id)->getAllVisibleItems() as $item) {
17
- $value = $item->getValue();
18
- if (!$value) {
19
- $value = $item->getRowTotal();
20
- }
21
- if (!$value) {
22
- $qty = $item->getQty();
23
- if (!$qty) {
24
- $qty = $item->getQtyOrdered();
25
- }
26
- $value = $item->getPrice() * $qty;
27
- }
28
-
29
- $goods_value += $value;
30
- }
31
-
32
- return $goods_value;
33
- }
34
-
35
- public function isAdminSelect()
36
- {
37
- if ($this->getShipment() && !is_null(Mage::getSingleton('adminhtml/session')->getData('insurance_' . $this->getShipment()->getId()))) {
38
- return true;
39
- }
40
-
41
- return false;
42
- }
43
-
44
- }
1
+ <?php
2
+ /**
3
+ * Shipment Edit Tab Form Insurance
4
+ *
5
+ * @package Temando_Temando
6
+ * @author Temando Magento Team <marketing@temando.com>
7
+ */
8
+ class Temando_Temando_Block_Adminhtml_Shipment_Edit_Tab_Form_Insurance
9
+ extends Temando_Temando_Block_Adminhtml_Shipment_Edit_Tab_Abstract
10
+ {
11
+
12
+ public function getTotalGoodsValue()
13
+ {
14
+ $order_id = $this->getShipment()->getOrderId();
15
+ $goods_value = 0;
16
+ foreach (Mage::getModel('sales/order')->load($order_id)->getAllVisibleItems() as $item) {
17
+ $value = $item->getValue();
18
+ if (!$value) {
19
+ $value = $item->getRowTotal();
20
+ }
21
+ if (!$value) {
22
+ $qty = $item->getQty();
23
+ if (!$qty) {
24
+ $qty = $item->getQtyOrdered();
25
+ }
26
+ $value = $item->getPrice() * $qty;
27
+ }
28
+
29
+ $goods_value += $value;
30
+ }
31
+
32
+ return $goods_value;
33
+ }
34
+
35
+ public function isAdminSelect()
36
+ {
37
+ if ($this->getShipment() && !is_null(
38
+ Mage::getSingleton('adminhtml/session')->getData('insurance_' . $this->getShipment()->getId())
39
+ )) {
40
+ return true;
41
+ }
42
+ return false;
43
+ }
44
+ }
app/code/community/Temando/Temando/Block/Adminhtml/Shipment/Edit/Tab/Form/Origin.php CHANGED
@@ -1,26 +1,26 @@
1
- <?php
2
- /**
3
- * Shipment Edit Tab Form Origin
4
- *
5
- * @package Temando_Temando
6
- * @author Temando Magento Team <marketing@temando.com>
7
- */
8
- class Temando_Temando_Block_Adminhtml_Shipment_Edit_Tab_Form_Origin
9
- extends Temando_Temando_Block_Adminhtml_Shipment_Edit_Tab_Abstract
10
- {
11
-
12
- public function getWarehouse() {
13
- $origin = new Varien_Object(array(
14
- 'name' => Temando_Temando_Helper_Data::DEFAULT_WAREHOUSE_NAME,
15
- 'street' => Mage::getStoreConfig('temando/origin/street'),
16
- 'postcode' => Mage::getStoreConfig('temando/origin/postcode'),
17
- 'city' => Mage::getStoreConfig('temando/origin/city'),
18
- 'country' => Mage::getStoreConfig('temando/origin/country'),
19
- 'type' => Mage::getStoreConfig('temando/origin/type')
20
- ));
21
-
22
- return $origin;
23
-
24
- }
25
-
26
- }
1
+ <?php
2
+ /**
3
+ * Shipment Edit Tab Form Origin
4
+ *
5
+ * @package Temando_Temando
6
+ * @author Temando Magento Team <marketing@temando.com>
7
+ */
8
+ class Temando_Temando_Block_Adminhtml_Shipment_Edit_Tab_Form_Origin
9
+ extends Temando_Temando_Block_Adminhtml_Shipment_Edit_Tab_Abstract
10
+ {
11
+
12
+ public function getWarehouse()
13
+ {
14
+ $origin = new Varien_Object(array(
15
+ 'name' => Temando_Temando_Helper_Data::DEFAULT_WAREHOUSE_NAME,
16
+ 'street' => Mage::getStoreConfig('temando/origin/street'),
17
+ 'postcode' => Mage::getStoreConfig('temando/origin/postcode'),
18
+ 'city' => Mage::getStoreConfig('temando/origin/city'),
19
+ 'country' => Mage::getStoreConfig('temando/origin/country'),
20
+ 'type' => Mage::getStoreConfig('temando/origin/type')
21
+ ));
22
+
23
+ return $origin;
24
+ }
25
+
26
+ }
app/code/community/Temando/Temando/Block/Adminhtml/Shipment/Edit/Tab/Form/Products.php CHANGED
@@ -1,24 +1,23 @@
1
- <?php
2
- /**
3
- * Shipment Edit Tab Form Products
4
- *
5
- * @package Temando_Temando
6
- * @author Temando Magento Team <marketing@temando.com>
7
- */
8
- class Temando_Temando_Block_Adminhtml_Shipment_Edit_Tab_Form_Products
9
- extends Temando_Temando_Block_Adminhtml_Shipment_Edit_Tab_Abstract
10
- {
11
-
12
- /**
13
- * Gets a Magento catalog product belonging to a Magento order item.
14
- *
15
- * @param Mage_Sales_Model_Order_Item $item the Magento order item
16
- *
17
- * @return Mage_Catalog_Model_Product
18
- */
19
- public function getProductFromItem(Mage_Sales_Model_Order_Item $item)
20
- {
21
- return Mage::getModel('catalog/product')->load($item->getProductId());
22
- }
23
-
24
- }
1
+ <?php
2
+ /**
3
+ * Shipment Edit Tab Form Products
4
+ *
5
+ * @package Temando_Temando
6
+ * @author Temando Magento Team <marketing@temando.com>
7
+ */
8
+ class Temando_Temando_Block_Adminhtml_Shipment_Edit_Tab_Form_Products
9
+ extends Temando_Temando_Block_Adminhtml_Shipment_Edit_Tab_Abstract
10
+ {
11
+ /**
12
+ * Gets a Magento catalog product belonging to a Magento order item.
13
+ *
14
+ * @param Mage_Sales_Model_Order_Item $item the Magento order item
15
+ *
16
+ * @return Mage_Catalog_Model_Product
17
+ */
18
+ public function getProductFromItem(Mage_Sales_Model_Order_Item $item)
19
+ {
20
+ return Mage::getModel('catalog/product')->load($item->getProductId());
21
+ }
22
+
23
+ }
 
app/code/community/Temando/Temando/Block/Adminhtml/Shipment/Edit/Tab/Form/Quotes.php CHANGED
@@ -1,67 +1,66 @@
1
- <?php
2
- /**
3
- * Shipment Edit Tab Form Quotes
4
- *
5
- * @package Temando_Temando
6
- * @author Temando Magento Team <marketing@temando.com>
7
- */
8
- class Temando_Temando_Block_Adminhtml_Shipment_Edit_Tab_Form_Quotes
9
- extends Temando_Temando_Block_Adminhtml_Shipment_Edit_Tab_Abstract
10
- {
11
-
12
- protected $_cheapest_quote_id;
13
- protected $_fastest_quote_id;
14
- protected $_customer_selected_quote_id;
15
-
16
- public function __construct() {
17
- parent::__construct();
18
- if (($quotes = $this->getQuotes()->load())) {
19
- if(($cheapest_quote = $quotes->getCheapest())) {
20
- $this->_cheapest_quote_id = $cheapest_quote->getId();
21
- }
22
- if(($fastest_quote = $quotes->getFastest())) {
23
- $this->_fastest_quote_id = $fastest_quote->getId();
24
- }
25
- }
26
-
27
- if ($this->getShipment()) {
28
- $this->_customer_selected_quote_id = $this->getShipment()->getCustomerSelectedQuoteId();
29
- }
30
- }
31
-
32
- public function formatQuotePrice(Temando_Temando_Model_Quote $quote)
33
- {
34
- return
35
- $quote->getCurrency() . ' ' .
36
- $this->formatCurrency($quote->getTotalPrice()) .
37
- ' (inc. ' .
38
- $this->formatCurrency($quote->getTax()) .
39
- ' tax)';
40
- }
41
-
42
- public function getQuoteNotes(Temando_Temando_Model_Quote $quote)
43
- {
44
- $text = '';
45
-
46
- if ($this->_cheapest_quote_id == $quote->getId()) {
47
- $text .= $this->__('Cheapest');
48
- }
49
-
50
- if ($this->_fastest_quote_id == $quote->getId()) {
51
- if ($text) {
52
- $text .= ', ';
53
- }
54
- $text .= $this->__('Fastest');
55
- }
56
-
57
- if ($this->_customer_selected_quote_id == $quote->getId()) {
58
- if ($text) {
59
- $text .= ', ';
60
- }
61
- $text .= $this->__('Customer Selected');
62
- }
63
-
64
- return $text;
65
- }
66
-
67
- }
1
+ <?php
2
+ /**
3
+ * Shipment Edit Tab Form Quotes
4
+ *
5
+ * @package Temando_Temando
6
+ * @author Temando Magento Team <marketing@temando.com>
7
+ */
8
+ class Temando_Temando_Block_Adminhtml_Shipment_Edit_Tab_Form_Quotes
9
+ extends Temando_Temando_Block_Adminhtml_Shipment_Edit_Tab_Abstract
10
+ {
11
+
12
+ protected $_cheapest_quote_id;
13
+ protected $_fastest_quote_id;
14
+ protected $_customer_selected_quote_id;
15
+
16
+ public function __construct()
17
+ {
18
+ parent::__construct();
19
+ if (($quotes = $this->getQuotes()->load())) {
20
+ if (($cheapest_quote = $quotes->getCheapest())) {
21
+ $this->_cheapest_quote_id = $cheapest_quote->getId();
22
+ }
23
+ if (($fastest_quote = $quotes->getFastest())) {
24
+ $this->_fastest_quote_id = $fastest_quote->getId();
25
+ }
26
+ }
27
+
28
+ if ($this->getShipment()) {
29
+ $this->_customer_selected_quote_id = $this->getShipment()->getCustomerSelectedQuoteId();
30
+ }
31
+ }
32
+
33
+ public function formatQuotePrice(Temando_Temando_Model_Quote $quote)
34
+ {
35
+ return
36
+ $quote->getCurrency() . ' ' .
37
+ $this->formatCurrency($quote->getTotalPrice()) .
38
+ ' (inc. ' .
39
+ $this->formatCurrency($quote->getTax()) .
40
+ ' tax)';
41
+ }
42
+
43
+ public function getQuoteNotes(Temando_Temando_Model_Quote $quote)
44
+ {
45
+ $text = '';
46
+
47
+ if ($this->_cheapest_quote_id == $quote->getId()) {
48
+ $text .= $this->__('Cheapest');
49
+ }
50
+
51
+ if ($this->_fastest_quote_id == $quote->getId()) {
52
+ if ($text) {
53
+ $text .= ', ';
54
+ }
55
+ $text .= $this->__('Fastest');
56
+ }
57
+
58
+ if ($this->_customer_selected_quote_id == $quote->getId()) {
59
+ if ($text) {
60
+ $text .= ', ';
61
+ }
62
+ $text .= $this->__('Customer Selected');
63
+ }
64
+ return $text;
65
+ }
66
+ }
 
app/code/community/Temando/Temando/Block/Adminhtml/Shipment/Edit/Tab/Form/Status.php CHANGED
@@ -1,32 +1,31 @@
1
- <?php
2
- /**
3
- * Shipment Edit Tab Form Status
4
- *
5
- * @package Temando_Temando
6
- * @author Temando Magento Team <marketing@temando.com>
7
- */
8
- class Temando_Temando_Block_Adminhtml_Shipment_Edit_Tab_Form_Status
9
- extends Temando_Temando_Block_Adminhtml_Shipment_Edit_Tab_Abstract
10
- {
11
- /**
12
- * @var Temando_Temando_Model_Quote
13
- */
14
- protected $_customer_selected_quote = null;
15
-
16
- /**
17
- * Gets the description of the Temando quote selected by the customer.
18
- *
19
- * @return Temando_Temando_Model_Quote
20
- */
21
- public function getCustomerSelectedQuoteDescription()
22
- {
23
- return $this->getShipment()->getCustomerSelectedQuoteDescription();
24
- }
25
-
26
- public function getShipmentStatusText()
27
- {
28
- return Mage::getModel('temando/system_config_source_shipment_status')
29
- ->getOptionLabel($this->getShipment()->getStatus());
30
- }
31
-
32
- }
1
+ <?php
2
+ /**
3
+ * Shipment Edit Tab Form Status
4
+ *
5
+ * @package Temando_Temando
6
+ * @author Temando Magento Team <marketing@temando.com>
7
+ */
8
+ class Temando_Temando_Block_Adminhtml_Shipment_Edit_Tab_Form_Status
9
+ extends Temando_Temando_Block_Adminhtml_Shipment_Edit_Tab_Abstract
10
+ {
11
+ /**
12
+ * @var Temando_Temando_Model_Quote
13
+ */
14
+ protected $_customer_selected_quote = null;
15
+
16
+ /**
17
+ * Gets the description of the Temando quote selected by the customer.
18
+ *
19
+ * @return Temando_Temando_Model_Quote
20
+ */
21
+ public function getCustomerSelectedQuoteDescription()
22
+ {
23
+ return $this->getShipment()->getCustomerSelectedQuoteDescription();
24
+ }
25
+
26
+ public function getShipmentStatusText()
27
+ {
28
+ return Mage::getModel('temando/system_config_source_shipment_status')
29
+ ->getOptionLabel($this->getShipment()->getStatus());
30
+ }
31
+ }
 
app/code/community/Temando/Temando/Block/Adminhtml/Shipment/Edit/Tabs.php CHANGED
@@ -1,20 +1,20 @@
1
- <?php
2
- /**
3
- * Shipment Edit Tabs
4
- *
5
- * @package Temando_Temando
6
- * @author Temando Magento Team <marketing@temando.com>
7
- */
8
- class Temando_Temando_Block_Adminhtml_Shipment_Edit_Tabs
9
- extends Mage_Adminhtml_Block_Widget_Tabs
10
- {
11
-
12
- public function __construct()
13
- {
14
- parent::__construct();
15
- $this->setId('temando_shipment_edit_tabs');
16
- $this->setDestElementId('edit_form');
17
- $this->setTitle(Mage::helper('temando')->__('Shipment View'));
18
- }
19
-
20
- }
1
+ <?php
2
+ /**
3
+ * Shipment Edit Tabs
4
+ *
5
+ * @package Temando_Temando
6
+ * @author Temando Magento Team <marketing@temando.com>
7
+ */
8
+ class Temando_Temando_Block_Adminhtml_Shipment_Edit_Tabs
9
+ extends Mage_Adminhtml_Block_Widget_Tabs
10
+ {
11
+
12
+ public function __construct()
13
+ {
14
+ parent::__construct();
15
+ $this->setId('temando_shipment_edit_tabs');
16
+ $this->setDestElementId('edit_form');
17
+ $this->setTitle(Mage::helper('temando')->__('Shipment View'));
18
+ }
19
+
20
+ }
app/code/community/Temando/Temando/Block/Adminhtml/Shipment/Grid.php CHANGED
@@ -1,134 +1,147 @@
1
- <?php
2
- /**
3
- * Shipment Grid
4
- *
5
- * @package Temando_Temando
6
- * @author Temando Magento Team <marketing@temando.com>
7
- */
8
- class Temando_Temando_Block_Adminhtml_Shipment_Grid
9
- extends Mage_Adminhtml_Block_Widget_Grid
10
- {
11
-
12
- public function __construct()
13
- {
14
- parent::__construct();
15
- $this->setSaveParametersInSession(true);
16
- }
17
-
18
- protected function _prepareLayout() {
19
- parent::_prepareLayout();
20
- $this->setChild('batch_button', $this->getLayout()->createBlock('adminhtml/widget_button')
21
- ->setData(array(
22
- 'label' => Mage::helper('adminhtml')->__('Batch Booking'),
23
- 'onclick' => 'return false',
24
- 'class' => 'disabled',
25
- 'title' => 'Available in the Business Extension'
26
- ))
27
- );
28
- return $this;
29
- }
30
-
31
- public function getBatchButtonHtml() {
32
- return $this->getChildHtml('batch_button');
33
- }
34
-
35
- public function getMainButtonsHtml() {
36
- $html = '';
37
- if ($this->getFilterVisibility()) {
38
- $html.= $this->getBatchButtonHtml();
39
- $html.= $this->getResetFilterButtonHtml();
40
- $html.= $this->getSearchButtonHtml();
41
- }
42
- return $html;
43
- }
44
-
45
- protected function _prepareCollection()
46
- {
47
- $collection = Mage::getModel('temando/shipment')->getCollection();
48
- $collection->join('sales/order', 'main_table.order_id=`sales/order`.entity_id', array('increment_id', 'created_at', 'shipping_amount'));
49
- /* @var $collection Temando_Temando_Model_Shipment */
50
-
51
- $collection->getSelect()->order(array(
52
- 'main_table.status ASC',
53
- 'created_at DESC'
54
- ));
55
-
56
- $this->setCollection($collection);
57
- return parent::_prepareCollection();
58
- }
59
-
60
- protected function _prepareColumns()
61
- {
62
- $this->addColumn('order_number', array(
63
- 'header' => Mage::helper('temando')->__('Order #'),
64
- 'width' => '100px',
65
- 'index' => 'increment_id',
66
- ));
67
-
68
- $this->addColumn('created_at', array(
69
- 'header' => Mage::helper('temando')->__('Purchased On'),
70
- 'width' => '160px',
71
- 'type' => 'datetime',
72
- 'index' => 'created_at',
73
- 'filter_index' => '`sales/order`.created_at',
74
- ));
75
-
76
- $this->addColumn('status', array(
77
- 'header' => Mage::helper('temando')->__('Status'),
78
- 'index' => 'status',
79
- 'type' => 'options',
80
- 'width' => '100px',
81
- 'options' => Mage::getSingleton('temando/system_config_source_shipment_status')->getOptions(),
82
- 'filter_index' => 'main_table.status',
83
- ));
84
-
85
- $this->addColumn('anticipated_cost', array(
86
- 'header' => Mage::helper('temando')->__('Anticipated Cost'),
87
- 'align' => 'left',
88
- 'type' => 'currency',
89
- 'currency_code' => Mage::helper('temando')->getDefaultCurrencyCode(),
90
- 'index' => 'anticipated_cost',
91
- ));
92
-
93
- $this->addColumn('shipping_paid', array(
94
- 'header' => Mage::helper('temando')->__('Shipping Paid'),
95
- 'align' => 'left',
96
- 'type' => 'currency',
97
- 'currency_code' => Mage::app()->getStore()->getCurrentCurrencyCode(),
98
- 'index' => 'shipping_amount',
99
- ));
100
-
101
- $this->addColumn('selected_quote_description', array(
102
- 'header' => Mage::helper('temando')->__('Customer Selected Quote'),
103
- 'align' => 'left',
104
- 'index' => 'customer_selected_quote_description',
105
- ));
106
-
107
- $this->addColumn('action', array(
108
- 'header' => Mage::helper('temando')->__('Action'),
109
- 'width' => '100',
110
- 'type' => 'action',
111
- 'getter' => 'getId',
112
- 'actions' => array(
113
- 'view' => array(
114
- 'caption' => Mage::helper('temando')->__('View'),
115
- 'url' => array('base' => '*/*/edit'),
116
- 'field' => 'id'
117
- )
118
- ),
119
- 'filter' => false,
120
- 'sortable' => false,
121
- 'index' => 'stores',
122
- 'is_system' => true,
123
- ));
124
-
125
- return parent::_prepareColumns();
126
- }
127
-
128
-
129
- public function getRowUrl($row)
130
- {
131
- return $this->getUrl('*/*/edit', array('id' => $row->getId()));
132
- }
133
-
134
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Shipment Grid
4
+ *
5
+ * @package Temando_Temando
6
+ * @author Temando Magento Team <marketing@temando.com>
7
+ */
8
+ class Temando_Temando_Block_Adminhtml_Shipment_Grid
9
+ extends Mage_Adminhtml_Block_Widget_Grid
10
+ {
11
+
12
+ public function __construct()
13
+ {
14
+ parent::__construct();
15
+ $this->setSaveParametersInSession(true);
16
+ }
17
+
18
+ protected function _prepareLayout()
19
+ {
20
+ parent::_prepareLayout();
21
+ $this->setChild(
22
+ 'batch_button',
23
+ $this->getLayout()->createBlock('adminhtml/widget_button')->setData(
24
+ array(
25
+ 'label' => Mage::helper('adminhtml')->__('Batch Booking'),
26
+ 'onclick' => 'return false',
27
+ 'class' => 'disabled',
28
+ 'title' => 'Available in the Business Extension'
29
+ )
30
+ )
31
+ );
32
+ return $this;
33
+ }
34
+
35
+ public function getBatchButtonHtml()
36
+ {
37
+ return $this->getChildHtml('batch_button');
38
+ }
39
+
40
+ public function getMainButtonsHtml()
41
+ {
42
+ $html = '';
43
+ if ($this->getFilterVisibility()) {
44
+ $html.= $this->getBatchButtonHtml();
45
+ $html.= $this->getResetFilterButtonHtml();
46
+ $html.= $this->getSearchButtonHtml();
47
+ }
48
+ return $html;
49
+ }
50
+
51
+ protected function _prepareCollection()
52
+ {
53
+ $collection = Mage::getModel('temando/shipment')->getCollection();
54
+ $collection->join(
55
+ 'sales/order',
56
+ 'main_table.order_id=`sales/order`.entity_id',
57
+ array(
58
+ 'increment_id',
59
+ 'created_at',
60
+ 'shipping_amount'
61
+ )
62
+ );
63
+ /* @var $collection Temando_Temando_Model_Shipment */
64
+
65
+ $collection->getSelect()->order(array(
66
+ 'main_table.status ASC',
67
+ 'created_at DESC'
68
+ ));
69
+
70
+ $this->setCollection($collection);
71
+ return parent::_prepareCollection();
72
+ }
73
+
74
+ protected function _prepareColumns()
75
+ {
76
+ $this->addColumn('order_number', array(
77
+ 'header' => Mage::helper('temando')->__('Order #'),
78
+ 'width' => '100px',
79
+ 'index' => 'increment_id',
80
+ ));
81
+
82
+ $this->addColumn('created_at', array(
83
+ 'header' => Mage::helper('temando')->__('Purchased On'),
84
+ 'width' => '160px',
85
+ 'type' => 'datetime',
86
+ 'index' => 'created_at',
87
+ 'filter_index' => '`sales/order`.created_at',
88
+ ));
89
+
90
+ $this->addColumn('status', array(
91
+ 'header' => Mage::helper('temando')->__('Status'),
92
+ 'index' => 'status',
93
+ 'type' => 'options',
94
+ 'width' => '100px',
95
+ 'options' => Mage::getSingleton('temando/system_config_source_shipment_status')->getOptions(),
96
+ 'filter_index' => 'main_table.status',
97
+ ));
98
+
99
+ $this->addColumn('anticipated_cost', array(
100
+ 'header' => Mage::helper('temando')->__('Anticipated Cost'),
101
+ 'align' => 'left',
102
+ 'type' => 'currency',
103
+ 'index' => 'anticipated_cost',
104
+ 'renderer' => new Temando_Temando_Block_Adminhtml_Shipment_Grid_Renderer_Currency()
105
+ ));
106
+
107
+ $this->addColumn('shipping_paid', array(
108
+ 'header' => Mage::helper('temando')->__('Shipping Paid'),
109
+ 'align' => 'left',
110
+ 'type' => 'currency',
111
+ 'index' => 'shipping_amount',
112
+ 'renderer' => new Temando_Temando_Block_Adminhtml_Shipment_Grid_Renderer_Shipcurrency()
113
+ ));
114
+
115
+ $this->addColumn('selected_quote_description', array(
116
+ 'header' => Mage::helper('temando')->__('Customer Selected Quote'),
117
+ 'align' => 'left',
118
+ 'index' => 'customer_selected_quote_description',
119
+ ));
120
+
121
+ $this->addColumn('action', array(
122
+ 'header' => Mage::helper('temando')->__('Action'),
123
+ 'width' => '100',
124
+ 'type' => 'action',
125
+ 'getter' => 'getId',
126
+ 'actions' => array(
127
+ 'view' => array(
128
+ 'caption' => Mage::helper('temando')->__('View'),
129
+ 'url' => array('base' => '*/*/edit'),
130
+ 'field' => 'id'
131
+ )
132
+ ),
133
+ 'filter' => false,
134
+ 'sortable' => false,
135
+ 'index' => 'stores',
136
+ 'is_system' => true,
137
+ ));
138
+
139
+ return parent::_prepareColumns();
140
+ }
141
+
142
+
143
+ public function getRowUrl($row)
144
+ {
145
+ return $this->getUrl('*/*/edit', array('id' => $row->getId()));
146
+ }
147
+ }
app/code/community/Temando/Temando/Block/Adminhtml/Shipment/Grid/Renderer/Currency.php ADDED
@@ -0,0 +1,24 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Custom grid renderer for shipment anticipated currency
4
+ *
5
+ * @package Temando_Temando
6
+ * @author Temando Magento Team <marketing@temando.com>
7
+ */
8
+ class Temando_Temando_Block_Adminhtml_Shipment_Grid_Renderer_Currency
9
+ extends Mage_Adminhtml_Block_Widget_Grid_Column_Renderer_Currency
10
+ {
11
+ /**
12
+ * Return the currency code
13
+ *
14
+ * @param Varien_Object $row
15
+ * @return string
16
+ */
17
+ protected function _getCurrencyCode($row)
18
+ {
19
+ if ($row->getAnticipatedCurrency()) {
20
+ return $row->getAnticipatedCurrency();
21
+ }
22
+ return Mage::helper('temando')->getDefaultCurrencyCode();
23
+ }
24
+ }
app/code/community/Temando/Temando/Block/Adminhtml/Shipment/Grid/Renderer/Shipcurrency.php ADDED
@@ -0,0 +1,23 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Custom grid renderer for shipping paid currency
4
+ *
5
+ * @package Temando_Temando
6
+ * @author Temando Magento Team <marketing@temando.com>
7
+ */
8
+ class Temando_Temando_Block_Adminhtml_Shipment_Grid_Renderer_Shipcurrency
9
+ extends Mage_Adminhtml_Block_Widget_Grid_Column_Renderer_Currency
10
+ {
11
+
12
+ /**
13
+ * Return the currency code
14
+ *
15
+ * @param Varien_Object $row
16
+ * @return string
17
+ */
18
+ protected function _getCurrencyCode($row)
19
+ {
20
+ $shipment = Mage::getModel('temando/shipment')->load($row->getId());
21
+ return $shipment->getOrder()->getStore()->getCurrentCurrencyCode();
22
+ }
23
+ }
app/code/community/Temando/Temando/Block/Adminhtml/System/Config/Form/Button/Rule.php CHANGED
@@ -1,23 +1,23 @@
1
- <?php
2
- /**
3
- * System Config Form Button Rule
4
- *
5
- * @package Temando_Temando
6
- * @author Temando Magento Team <marketing@temando.com>
7
- */
8
- class Temando_Temando_Block_Adminhtml_System_Config_Form_Button_Rule
9
- extends Mage_Adminhtml_Block_System_Config_Form_Field {
10
-
11
- protected function _getElementHtml(Varien_Data_Form_Element_Abstract $element) {
12
- $this->setElement($element);
13
- $html = $this->getLayout()
14
- ->createBlock('adminhtml/widget_button')
15
- ->setType('button')->setClass('scalable go disabled')
16
- ->setLabel('Add New Rule')
17
- ->setOnClick('return false;')
18
- ->setTitle('Available in the Business Plan')
19
- ->toHtml();
20
- return $html;
21
- }
22
-
23
- }
1
+ <?php
2
+ /**
3
+ * System Config Form Button Rule
4
+ *
5
+ * @package Temando_Temando
6
+ * @author Temando Magento Team <marketing@temando.com>
7
+ */
8
+ class Temando_Temando_Block_Adminhtml_System_Config_Form_Button_Rule
9
+ extends Mage_Adminhtml_Block_System_Config_Form_Field
10
+ {
11
+ protected function _getElementHtml(Varien_Data_Form_Element_Abstract $element)
12
+ {
13
+ $this->setElement($element);
14
+ $html = $this->getLayout()
15
+ ->createBlock('adminhtml/widget_button')
16
+ ->setType('button')->setClass('scalable go disabled')
17
+ ->setLabel('Add New Rule')
18
+ ->setOnClick('return false;')
19
+ ->setTitle('Available in the Business Plan')
20
+ ->toHtml();
21
+ return $html;
22
+ }
23
+ }
app/code/community/Temando/Temando/Block/Adminhtml/System/Config/Form/Button/Update.php CHANGED
@@ -1,24 +1,23 @@
1
- <?php
2
- /**
3
- * System Config Form Button Update
4
- *
5
- * @package Temando_Temando
6
- * @author Temando Magento Team <marketing@temando.com>
7
- */
8
- class Temando_Temando_Block_Adminhtml_System_Config_Form_Button_Update
9
- extends Mage_Adminhtml_Block_System_Config_Form_Field
10
- {
11
-
12
- protected function _getElementHtml(Varien_Data_Form_Element_Abstract $element) {
13
- $this->setElement($element);
14
- $html = $this->getLayout()
15
- ->createBlock('adminhtml/widget_button')
16
- ->setType('button')->setClass('scalable go')
17
- ->setLabel('Update Carriers')
18
- ->setOnClick('setLocation(\'' . $this->getUrl('temando/adminhtml_carrier') .'\')')
19
- ->setTitle('Update Carriers')
20
- ->toHtml();
21
- return $html;
22
- }
23
-
24
- }
1
+ <?php
2
+ /**
3
+ * System Config Form Button Update
4
+ *
5
+ * @package Temando_Temando
6
+ * @author Temando Magento Team <marketing@temando.com>
7
+ */
8
+ class Temando_Temando_Block_Adminhtml_System_Config_Form_Button_Update
9
+ extends Mage_Adminhtml_Block_System_Config_Form_Field
10
+ {
11
+ protected function _getElementHtml(Varien_Data_Form_Element_Abstract $element)
12
+ {
13
+ $this->setElement($element);
14
+ $html = $this->getLayout()
15
+ ->createBlock('adminhtml/widget_button')
16
+ ->setType('button')->setClass('scalable go')
17
+ ->setLabel('Update Carriers')
18
+ ->setOnClick('setLocation(\'' . $this->getUrl('temando/adminhtml_carrier') .'\')')
19
+ ->setTitle('Update Carriers')
20
+ ->toHtml();
21
+ return $html;
22
+ }
23
+ }
 
app/code/community/Temando/Temando/Block/Adminhtml/System/Config/Form/Button/Warehouse.php CHANGED
@@ -1,24 +1,25 @@
1
- <?php
2
- /**
3
- * System Config Form Button Warehouse
4
- *
5
- * @package Temando_Temando
6
- * @author Temando Magento Team <marketing@temando.com>
7
- */
8
- class Temando_Temando_Block_Adminhtml_System_Config_Form_Button_Warehouse
9
- extends Mage_Adminhtml_Block_System_Config_Form_Field
10
- {
11
-
12
- protected function _getElementHtml(Varien_Data_Form_Element_Abstract $element) {
13
- $this->setElement($element);
14
- $html = $this->getLayout()
15
- ->createBlock('adminhtml/widget_button')
16
- ->setType('button')->setClass('scalable go disabled')
17
- ->setLabel('Add New Warehouse')
18
- ->setOnClick('return false;')
19
- ->setTitle('Available in the Business Plan')
20
- ->toHtml();
21
- return $html;
22
- }
23
-
24
- }
 
1
+ <?php
2
+ /**
3
+ * System Config Form Button Warehouse
4
+ *
5
+ * @package Temando_Temando
6
+ * @author Temando Magento Team <marketing@temando.com>
7
+ */
8
+ class Temando_Temando_Block_Adminhtml_System_Config_Form_Button_Warehouse
9
+ extends Mage_Adminhtml_Block_System_Config_Form_Field
10
+ {
11
+
12
+ protected function _getElementHtml(Varien_Data_Form_Element_Abstract $element)
13
+ {
14
+ $this->setElement($element);
15
+ $html = $this->getLayout()
16
+ ->createBlock('adminhtml/widget_button')
17
+ ->setType('button')->setClass('scalable go disabled')
18
+ ->setLabel('Add New Warehouse')
19
+ ->setOnClick('return false;')
20
+ ->setTitle('Available in the Business Plan')
21
+ ->toHtml();
22
+ return $html;
23
+ }
24
+
25
+ }
app/code/community/Temando/Temando/Block/Adminhtml/System/Config/Form/Field/Insurance.php CHANGED
@@ -1,93 +1,142 @@
1
- <?php
2
- /**
3
- * System Config Form Field Insurance
4
- *
5
- * @package Temando_Temando
6
- * @author Temando Magento Team <marketing@temando.com>
7
- */
8
- class Temando_Temando_Block_Adminhtml_System_Config_Form_Field_Insurance
9
- extends Temando_Temando_Block_Adminhtml_System_Config_Form_Field_Required
10
- {
11
-
12
- protected $_confirm_text = array(
13
- "optional" => "<table><tr><td class='c1'>%optional_input%</td><td class='c2'>I confirm that I have read &amp; understood the terms &amp; conditions outlined in the <a href='http://www.temando.com/downloads/Product%20Disclosure%20Statement%20and%20Wording.pdf' target='_blank'>Product Disclosure Statement and wording</a>, the <a href='http://www.temando.com/downloads/Financial%20Services%20Guide.pdf' target='_blank'>Financial Services Guide</a> and the <a href='http://www.temando.com/downloads/Privacy%20Statement.pdf' target='_blank'>Privacy Statement</a> and will take advantage of this offer.</td></tr></table>",
14
- "mandatory" => "<textarea style='height: 100px; width: 100%'>Athough every care is taken by the transport company whilst transporting and storing the item being transacted, it may still become lost or damaged.
15
-
16
- In some instances, the transport company may be required to compensate you for the loss of or damage to the item. However, there are many circumstances in which they may not be required to compensate you, such as when the loss or damage is caused by an act of God, or other events beyond their control. This insurance assists to fill this gap.
17
-
18
- Whilst every effort has been made to insure your item, you should understand that the following items are not insured (this is a summary of the exclusions and you should refer to the Terms and Conditions for a complete understanding):
19
-
20
- - Money, deeds, securities, treasury notes, tickets, vouchers, stamps, duty stamps, any other cash equivalents,
21
-
22
- - Designs and/or patterns and/or plans and/or manuscripts and/or any other documents,
23
-
24
- - Electronic data or computer software stored on computers or hardware
25
-
26
- - Any living creature
27
-
28
- - Precious Metals, Precious Stones or Semi-precious Stones that are sent by themselves, i.e. this does not mean fixed items, e.g. rings, earrings),
29
-
30
- - Motor Vehicles and boats (note, this does not mean car parts, which can be covered).
31
-
32
- Please also note that the insurance only covers items where the origin address and the delivery address are both located in Australia. In other words, if you are sending your item to a country that is not Australia, then there is no insurance. Conversely, if you are resident in a country other than Australia, but sending the item to Australia the insurance will not apply either.
33
-
34
- Insurance is not currently available for clients using this extension in the US and UK regions.</textarea>
35
- <table style='padding-top: 10px;'><tr><td class='c1'>%mandatory_input%</td><td class='c2'>I confirm that I have read &amp; understood the terms &amp; conditions outlined in the <a href='http://www.temando.com/downloads/Product%20Disclosure%20Statement%20and%20Wording.pdf' target='_blank'>Product Disclosure Statement and wording</a>, the <a href='http://www.temando.com/downloads/Financial%20Services%20Guide.pdf' target='_blank'>Financial Services Guide</a> and the <a href='http://www.temando.com/downloads/Privacy%20Statement.pdf' target='_blank'>Privacy Statement</a> and will take advantage of this offer.</td></tr></table>",
36
- "disabled" => "<div class='error-msg' style='height: 35px; border: 0 !important; background-color: transparent !important; padding-left: 33px; padding-top: 9px; color: #2F2F2F !important;'>Even though Insurance will be unavailable to your buyers, you may still insure shipments as a seller.</div>
37
- <textarea style='height: 100px; width: 100%'>Athough every care is taken by the transport company whilst transporting and storing the item being transacted, it may still become lost or damaged.
38
-
39
- In some instances, the transport company may be required to compensate you for the loss of or damage to the item. However, there are many circumstances in which they may not be required to compensate you, such as when the loss or damage is caused by an act of God, or other events beyond their control. This insurance assists to fill this gap.
40
-
41
- Whilst every effort has been made to insure your item, you should understand that the following items are not insured (this is a summary of the exclusions and you should refer to the Terms and Conditions for a complete understanding):
42
-
43
- - Money, deeds, securities, treasury notes, tickets, vouchers, stamps, duty stamps, any other cash equivalents,
44
-
45
- - Designs and/or patterns and/or plans and/or manuscripts and/or any other documents,
46
-
47
- - Electronic data or computer software stored on computers or hardware
48
-
49
- - Any living creature
50
-
51
- - Precious Metals, Precious Stones or Semi-precious Stones that are sent by themselves, i.e. this does not mean fixed items, e.g. rings, earrings),
52
-
53
- - Motor Vehicles and boats (note, this does not mean car parts, which can be covered).
54
-
55
- Please also note that the insurance only covers items where the origin address and the delivery address are both located in Australia. In other words, if you are sending your item to a country that is not Australia, then there is no insurance. Conversely, if you are resident in a country other than Australia, but sending the item to Australia the insurance will not apply either.
56
-
57
- Insurance is not currently available for clients using this extension in the US and UK regions.</textarea>
58
- <table style='padding-top: 10px;'><tr><td class='c1'>%disabled_input%</td><td class='c2'>I confirm that I have read &amp; understood the terms &amp; conditions outlined in the <a href='http://www.temando.com/downloads/Product%20Disclosure%20Statement%20and%20Wording.pdf' target='_blank'>Product Disclosure Statement and wording</a>, the <a href='http://www.temando.com/downloads/Financial%20Services%20Guide.pdf' target='_blank'>Financial Services Guide</a> and the <a href='http://www.temando.com/downloads/Privacy%20Statement.pdf' target='_blank'>Privacy Statement</a> and will take advantage of this offer.</td></tr></table>",
59
- );
60
-
61
-
62
- /**
63
- * @see Mage_Adminhtml_Block_System_Config_Form_Field::render()
64
- */
65
- public function render(Varien_Data_Form_Element_Abstract $element)
66
- {
67
- $comment_confirm = $this->_getConfirmHtml($element->getValue());
68
- $element->setOnchange("$$('.confirm-insurance').each(function(control){control.style.display = 'none';}); $('insurance_'+this.value).style.display = '';");
69
- $element->setComment($element->getComment());
70
- $return = parent::render($element);
71
- $return .= "<tr><td>&nbsp;</td><td colspan='3'>" . $comment_confirm . "</td></tr>";
72
- return $return;
73
- }
74
-
75
- protected function _getConfirmHtml($value)
76
- {
77
- $return = '';
78
- foreach ($this->_confirm_text as $k => $v) {
79
- $checked = (Mage::getStoreConfig('temando/insurance/confirm_' . $k)=='Y')?true:false;
80
- if ($k != $value) {
81
- $checked = false;
82
- }
83
-
84
- $field = "<input type='hidden' name='groups[insurance][fields][confirm_" . $k . "][value]' " . ($checked?'disabled="disabled""':'') . " value='N' id='optional_confirm_no' />";
85
- $field .= "<input type='checkbox' name='groups[insurance][fields][confirm_" . $k ."][value]' value='Y' " . ($checked?'checked="checked"':'') . ' onclick="if($(\'' . $k .'_confirm_no\')){$(\'' . $k .'_confirm_no\').disabled=this.checked;}" />';
86
- $html = "<div class='confirm-insurance' id='insurance_" . $k . "'" . (($value != $k)?" style='display: none;'":"") . ">" . $v . "</div>";
87
- $html = str_replace('%' . $k . '_input%', $field, $html);
88
- $return .= $html;
89
- }
90
-
91
- return $return;
92
- }
93
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * System Config Form Field Insurance
4
+ *
5
+ * @package Temando_Temando
6
+ * @author Temando Magento Team <marketing@temando.com>
7
+ */
8
+ class Temando_Temando_Block_Adminhtml_System_Config_Form_Field_Insurance
9
+ extends Temando_Temando_Block_Adminhtml_System_Config_Form_Field_Required
10
+ {
11
+
12
+ protected $_confirm_text = array(
13
+ "optional" => "<table><tr><td class='c1'>%optional_input%</td><td class='c2'>I confirm that
14
+ I have read &amp; understood the terms &amp; conditions outlined in the
15
+ <a href='http://www.temando.com/downloads/Product%20Disclosure%20Statement%20and%20Wording.pdf'
16
+ target='_blank'>Product Disclosure Statement and wording</a>, the
17
+ <a href='http://www.temando.com/downloads/Financial%20Services%20Guide.pdf' target='_blank'>
18
+ Financial Services Guide</a> and the <a href='http://www.temando.com/downloads/Privacy%20Statement.pdf'
19
+ target='_blank'>Privacy Statement</a> and will take advantage of this offer.</td></tr></table>",
20
+ "mandatory" => "<textarea style='height: 100px; width: 100%'>Athough every care is taken by the
21
+ transport company whilst transporting and storing the item being transacted,
22
+ it may still become lost or damaged.
23
+
24
+ In some instances, the transport company may be required to compensate you for the loss of or
25
+ damage to the item. However, there are many circumstances in which they may not be required to
26
+ compensate you, such as when the loss or damage is caused by an act of God, or other events
27
+ beyond their control. This insurance assists to fill this gap.
28
+
29
+ Whilst every effort has been made to insure your item, you should understand that the following
30
+ items are not insured (this is a summary of the exclusions and you should refer to the Terms
31
+ and Conditions for a complete understanding):
32
+
33
+ - Money, deeds, securities, treasury notes, tickets, vouchers, stamps, duty stamps, any other cash equivalents,
34
+
35
+ - Designs and/or patterns and/or plans and/or manuscripts and/or any other documents,
36
+
37
+ - Electronic data or computer software stored on computers or hardware
38
+
39
+ - Any living creature
40
+
41
+ - Precious Metals, Precious Stones or Semi-precious Stones that are sent by themselves,
42
+ i.e. this does not mean fixed items, e.g. rings, earrings),
43
+
44
+ - Motor Vehicles and boats (note, this does not mean car parts, which can be covered).
45
+
46
+ Please also note that the insurance only covers items where the origin address and the
47
+ delivery address are both located in Australia. In other words, if you are sending your
48
+ item to a country that is not Australia, then there is no insurance. Conversely,
49
+ if you are resident in a country other than Australia, but sending the item to
50
+ Australia the insurance will not apply either.
51
+
52
+ Insurance is not currently available for clients using this extension in the US and UK regions.</textarea>
53
+ <table style='padding-top: 10px;'><tr><td class='c1'>%mandatory_input%</td><td class='c2'>
54
+ I confirm that I have read &amp; understood the terms &amp; conditions outlined in the
55
+ <a href='http://www.temando.com/downloads/Product%20Disclosure%20Statement%20and%20Wording.pdf'
56
+ target='_blank'>Product Disclosure Statement and wording</a>, the
57
+ <a href='http://www.temando.com/downloads/Financial%20Services%20Guide.pdf' target='_blank'>
58
+ Financial Services Guide</a> and the <a href='http://www.temando.com/downloads/Privacy%20Statement.pdf'
59
+ target='_blank'>Privacy Statement</a> and will take advantage of this offer.</td></tr></table>",
60
+ "disabled" => "<div class='error-msg' style='height: 35px; border: 0 !important;
61
+ background-color: transparent !important; padding-left: 33px; padding-top: 9px;
62
+ color: #2F2F2F !important;'>Even though Insurance will be unavailable to your buyers, you may still
63
+ insure shipments as a seller.</div>
64
+ <textarea style='height: 100px; width: 100%'>Athough every care is taken by the transport company
65
+ whilst transporting and storing the item being transacted, it may still become lost or damaged.
66
+
67
+ In some instances, the transport company may be required to compensate you for the loss of or
68
+ damage to the item. However, there are many circumstances in which they may not be required to
69
+ compensate you, such as when the loss or damage is caused by an act of God, or other events
70
+ beyond their control. This insurance assists to fill this gap.
71
+
72
+ Whilst every effort has been made to insure your item, you should understand that the following
73
+ items are not insured (this is a summary of the exclusions and you should refer to the Terms
74
+ and Conditions for a complete understanding):
75
+
76
+ - Money, deeds, securities, treasury notes, tickets, vouchers, stamps, duty stamps, any other cash equivalents,
77
+
78
+ - Designs and/or patterns and/or plans and/or manuscripts and/or any other documents,
79
+
80
+ - Electronic data or computer software stored on computers or hardware
81
+
82
+ - Any living creature
83
+
84
+ - Precious Metals, Precious Stones or Semi-precious Stones that are sent by themselves,
85
+ i.e. this does not mean fixed items, e.g. rings, earrings),
86
+
87
+ - Motor Vehicles and boats (note, this does not mean car parts, which can be covered).
88
+
89
+ Please also note that the insurance only covers items where the origin address and
90
+ the delivery address are both located in Australia. In other words, if you are sending
91
+ your item to a country that is not Australia, then there is no insurance. Conversely,
92
+ if you are resident in a country other than Australia, but sending the item to
93
+ Australia the insurance will not apply either.
94
+
95
+ Insurance is not currently available for clients using this extension in the US
96
+ and UK regions.</textarea>
97
+ <table style='padding-top: 10px;'><tr><td class='c1'>%disabled_input%</td>
98
+ <td class='c2'>I confirm that I have read &amp; understood the terms &amp;
99
+ conditions outlined in the <a href='http://www.temando.com/downloads/Product%20Disclosure%
100
+ 20Statement%20and%20Wording.pdf' target='_blank'>Product Disclosure Statement and wording</a>,
101
+ the <a href='http://www.temando.com/downloads/Financial%20Services%20Guide.pdf' target='_blank'>
102
+ Financial Services Guide</a> and the <a href='http://www.temando.com/downloads/Privacy%20Statement.pdf'
103
+ target='_blank'>Privacy Statement</a> and will take advantage of this offer.</td></tr></table>",
104
+ );
105
+
106
+
107
+ /**
108
+ * @see Mage_Adminhtml_Block_System_Config_Form_Field::render()
109
+ */
110
+ public function render(Varien_Data_Form_Element_Abstract $element)
111
+ {
112
+ $comment_confirm = $this->_getConfirmHtml($element->getValue());
113
+ $element->setOnchange("$$('.confirm-insurance').each(function(control){control.style.display =
114
+ 'none';}); $('insurance_'+this.value).style.display = '';");
115
+ $element->setComment($element->getComment());
116
+ $return = parent::render($element);
117
+ $return .= "<tr><td>&nbsp;</td><td colspan='3'>" . $comment_confirm . "</td></tr>";
118
+ return $return;
119
+ }
120
+
121
+ protected function _getConfirmHtml($value)
122
+ {
123
+ $return = '';
124
+ foreach ($this->_confirm_text as $k => $v) {
125
+ $checked = (Mage::getStoreConfig('temando/insurance/confirm_' . $k)=='Y')?true:false;
126
+ if ($k != $value) {
127
+ $checked = false;
128
+ }
129
+
130
+ $field = "<input type='hidden' name='groups[insurance][fields][confirm_" . $k . "]
131
+ [value]' " . ($checked?'disabled="disabled""':'') . " value='N' id='optional_confirm_no' />";
132
+ $field .= "<input type='checkbox' name='groups[insurance][fields][confirm_" .
133
+ $k ."][value]' value='Y' " . ($checked?'checked="checked"':'') . ' onclick="if($(\'' .
134
+ $k .'_confirm_no\')){$(\'' . $k .'_confirm_no\').disabled=this.checked;}" />';
135
+ $html = "<div class='confirm-insurance' id='insurance_" . $k . "'" .
136
+ (($value != $k)?" style='display: none;'":"") . ">" . $v . "</div>";
137
+ $html = str_replace('%' . $k . '_input%', $field, $html);
138
+ $return .= $html;
139
+ }
140
+ return $return;
141
+ }
142
+ }
app/code/community/Temando/Temando/Block/Adminhtml/System/Config/Form/Field/Required.php CHANGED
@@ -1,53 +1,54 @@
1
- <?php
2
- /**
3
- * System Config Form Field Required
4
- *
5
- * @package Temando_Temando
6
- * @author Temando Magento Team <marketing@temando.com>
7
- */
8
- class Temando_Temando_Block_Adminhtml_System_Config_Form_Field_Required
9
- extends Mage_Adminhtml_Block_System_Config_Form_Field
10
- {
11
-
12
- protected $_element;
13
-
14
- /**
15
- * (non-PHPdoc)
16
- * @see Mage_Adminhtml_Block_System_Config_Form_Field::render()
17
- *
18
- * Adds the "required" star to the form field.
19
- */
20
- public function render(Varien_Data_Form_Element_Abstract $element)
21
- {
22
- $this->_element = $element;
23
- $html = parent::render($this->_element);
24
-
25
- $html = $this->_addStar($html);
26
- $html = $this->_addRequiredClass($html);
27
-
28
- return $html;
29
- }
30
-
31
- protected function _addStar($html)
32
- {
33
- $search = '<label for="' . $this->_element->getHtmlId() . '">' . $this->_element->getLabel() . '</label>';
34
- $replacement = '<label for="' . $this->_element->getHtmlId() . '">' . $this->_element->getLabel() . ' <span class="required">*</span></label>';
35
-
36
- return str_replace($search, $replacement, $html);
37
- }
38
-
39
- protected function _addRequiredClass($html)
40
- {
41
- $search = array(
42
- '#(<input.*class=")([^<>"]*)(".*>)#',
43
- '#(<select.*class=")([^<>"]*)(".*>)#',
44
- );
45
- $replacement = array(
46
- '$1required-entry $2$3',
47
- '$1validate-select $2$3',
48
- );
49
-
50
- return preg_replace($search, $replacement, $html);
51
- }
52
-
53
- }
 
1
+ <?php
2
+ /**
3
+ * System Config Form Field Required
4
+ *
5
+ * @package Temando_Temando
6
+ * @author Temando Magento Team <marketing@temando.com>
7
+ */
8
+ class Temando_Temando_Block_Adminhtml_System_Config_Form_Field_Required
9
+ extends Mage_Adminhtml_Block_System_Config_Form_Field
10
+ {
11
+
12
+ protected $_element;
13
+
14
+ /**
15
+ * (non-PHPdoc)
16
+ * @see Mage_Adminhtml_Block_System_Config_Form_Field::render()
17
+ *
18
+ * Adds the "required" star to the form field.
19
+ */
20
+ public function render(Varien_Data_Form_Element_Abstract $element)
21
+ {
22
+ $this->_element = $element;
23
+ $html = parent::render($this->_element);
24
+
25
+ $html = $this->_addStar($html);
26
+ $html = $this->_addRequiredClass($html);
27
+
28
+ return $html;
29
+ }
30
+
31
+ protected function _addStar($html)
32
+ {
33
+ $search = '<label for="' . $this->_element->getHtmlId() . '">' . $this->_element->getLabel() . '</label>';
34
+ $replacement = '<label for="' . $this->_element->getHtmlId() . '">' . $this->_element->getLabel() .
35
+ ' <span class="required">*</span></label>';
36
+
37
+ return str_replace($search, $replacement, $html);
38
+ }
39
+
40
+ protected function _addRequiredClass($html)
41
+ {
42
+ $search = array(
43
+ '#(<input.*class=")([^<>"]*)(".*>)#',
44
+ '#(<select.*class=")([^<>"]*)(".*>)#',
45
+ );
46
+ $replacement = array(
47
+ '$1required-entry $2$3',
48
+ '$1validate-select $2$3',
49
+ );
50
+
51
+ return preg_replace($search, $replacement, $html);
52
+ }
53
+
54
+ }
app/code/community/Temando/Temando/Block/Adminhtml/System/Config/Form/Field/Version.php ADDED
@@ -0,0 +1,21 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * System Config Form Field Version
4
+ *
5
+ * @package Temando_Temando
6
+ * @author Temando Magento Team <marketing@temando.com>
7
+ */
8
+ class Temando_Temando_Block_Adminhtml_System_Config_Form_Field_Version
9
+ extends Mage_Adminhtml_Block_System_Config_Form_Field
10
+ {
11
+ /**
12
+ * Retrieve the Temando version from the node
13
+ *
14
+ * @param Varien_Data_Form_Element_Abstract $element
15
+ * @return string
16
+ */
17
+ protected function _getElementHtml(Varien_Data_Form_Element_Abstract $element)
18
+ {
19
+ return (string) Mage::getConfig()->getNode()->modules->Temando_Temando->version;
20
+ }
21
+ }
app/code/community/Temando/Temando/Block/Adminhtml/System/Config/Form/Fieldset/General.php CHANGED
@@ -1,30 +1,30 @@
1
- <?php
2
- /**
3
- * System Config Form Fieldset General
4
- *
5
- * @package Temando_Temando
6
- * @author Temando Magento Team <marketing@temando.com>
7
- */
8
- class Temando_Temando_Block_Adminhtml_System_Config_Form_Fieldset_General
9
- extends Mage_Adminhtml_Block_System_Config_Form_Fieldset
10
- {
11
-
12
- /**
13
- * @see Mage_Adminhtml_Block_System_Config_Form_Fieldset::_getHeaderHtml()
14
- *
15
- * Passes the output text through a basic replacement function to find
16
- * instances of "{{store url="..."}}" and replace these with the correct
17
- * Magento URLs.
18
- */
19
- protected function _getHeaderHtml($element)
20
- {
21
- $html = parent::_getHeaderHtml($element);
22
- $pattern = '#{{store url="(.*?)"}}#';
23
-
24
- return preg_replace_callback($pattern, create_function('$elements', '
25
- // $elements[1] is the 1st parenthesized expression
26
- return Mage::getModel("adminhtml/url")->getUrl($elements[1]);
27
- '), $html);
28
- }
29
-
30
- }
1
+ <?php
2
+ /**
3
+ * System Config Form Fieldset General
4
+ *
5
+ * @package Temando_Temando
6
+ * @author Temando Magento Team <marketing@temando.com>
7
+ */
8
+ class Temando_Temando_Block_Adminhtml_System_Config_Form_Fieldset_General
9
+ extends Mage_Adminhtml_Block_System_Config_Form_Fieldset
10
+ {
11
+
12
+ /**
13
+ * @see Mage_Adminhtml_Block_System_Config_Form_Fieldset::_getHeaderHtml()
14
+ *
15
+ * Passes the output text through a basic replacement function to find
16
+ * instances of "{{store url="..."}}" and replace these with the correct
17
+ * Magento URLs.
18
+ */
19
+ protected function _getHeaderHtml($element)
20
+ {
21
+ $html = parent::_getHeaderHtml($element);
22
+ $pattern = '#{{store url="(.*?)"}}#';
23
+
24
+ return preg_replace_callback($pattern, create_function('$elements', '
25
+ // $elements[1] is the 1st parenthesized expression
26
+ return Mage::getModel("adminhtml/url")->getUrl($elements[1]);
27
+ '), $html);
28
+ }
29
+
30
+ }
app/code/community/Temando/Temando/Block/Cart/Shipping.php CHANGED
@@ -1,138 +1,138 @@
1
- <?php
2
- /**
3
- * Cart Shipping Block
4
- *
5
- * @package Temando_Temando
6
- * @author Temando Magento Team <marketing@temando.com>
7
- */
8
- class Temando_Temando_Block_Cart_Shipping
9
- extends Mage_Checkout_Block_Cart_Shipping
10
- {
11
-
12
- /**
13
- * Check if the city is active
14
- *
15
- * @return boolean
16
- */
17
- public function getCityActive()
18
- {
19
- return (bool)Mage::getStoreConfig('carriers/temando/active') || parent::getCityActive();
20
- }
21
-
22
- /**
23
- * Check if one of carriers require state/province
24
- *
25
- * @return bool
26
- */
27
- public function isStateProvinceRequired()
28
- {
29
- return (bool)Mage::getStoreConfig('carriers/temando/active') || parent::isStateProvinceRequired();
30
- }
31
-
32
- /**
33
- * Check if one of carriers require city
34
- *
35
- * @return bool
36
- */
37
- public function isCityRequired()
38
- {
39
- return (bool)Mage::getStoreConfig('carriers/temando/active') || parent::isCityRequired();
40
- }
41
-
42
- /**
43
- * Check if one of carriers require zip code
44
- *
45
- * @return bool
46
- */
47
- public function isZipCodeRequired()
48
- {
49
- return (bool)Mage::getStoreConfig('carriers/temando/active') || parent::isZipCodeRequired();
50
- }
51
-
52
- /**
53
- * Get the estimate postcode
54
- *
55
- * @return string
56
- */
57
- public function getEstimatePostcode()
58
- {
59
- $return = parent::getEstimatePostcode();
60
- if (!$return && Mage::helper('temando')->getSessionPostcode()) {
61
- $return = Mage::helper('temando')->getSessionPostcode();
62
- }
63
-
64
- return $return;
65
- }
66
-
67
- /**
68
- * Get the estimate city
69
- *
70
- * @return string
71
- */
72
- public function getEstimateCity()
73
- {
74
- $return = parent::getEstimateCity();
75
- if (!$return && Mage::helper('temando')->getSessionCity()) {
76
- $return = Mage::helper('temando')->getSessionCity();
77
- }
78
-
79
- return $return;
80
- }
81
-
82
- /**
83
- * Get the estimate region id
84
- *
85
- * @return string
86
- */
87
- public function getEstimateRegionId()
88
- {
89
- $return = parent::getEstimateRegionId();
90
- if (!$return && Mage::helper('temando')->getSessionRegionId()) {
91
- $return = Mage::helper('temando')->getSessionRegionId();
92
- }
93
-
94
- return $return;
95
- }
96
-
97
- /**
98
- * Get the estimate region
99
- *
100
- * @return string
101
- */
102
- public function getEstimateRegion()
103
- {
104
- $return = parent::getEstimateRegion();
105
- if (!$return && Mage::helper('temando')->getSessionRegion()) {
106
- $return = Mage::helper('temando')->getSessionRegion();
107
- }
108
-
109
- return $return;
110
- }
111
-
112
- /**
113
- * Show location type selection to customer?
114
- *
115
- * @return boolean
116
- */
117
- public function showLocationType()
118
- {
119
- $options = Mage::helper('temando')->getConfigData('checkout/delivery_options');
120
- if (!$options) {
121
- return false;
122
- }
123
- return Mage::helper('temando')->getConfigData('checkout/location_type');
124
- }
125
-
126
- /**
127
- * Return saved destination type as selected by customer
128
- *
129
- * @return string
130
- */
131
- public function getDestinationType()
132
- {
133
- $destinationType = Mage::getSingleton('checkout/session')->getData('destination_type');
134
- return $destinationType ?
135
- $destinationType :
136
- Temando_Temando_Model_Checkout_Delivery_Options::DESTINATION_RESIDENCE;
137
- }
138
- }
1
+ <?php
2
+ /**
3
+ * Cart Shipping Block
4
+ *
5
+ * @package Temando_Temando
6
+ * @author Temando Magento Team <marketing@temando.com>
7
+ */
8
+ class Temando_Temando_Block_Cart_Shipping
9
+ extends Mage_Checkout_Block_Cart_Shipping
10
+ {
11
+
12
+ /**
13
+ * Check if the city is active
14
+ *
15
+ * @return boolean
16
+ */
17
+ public function getCityActive()
18
+ {
19
+ return (bool)Mage::getStoreConfig('carriers/temando/active') || parent::getCityActive();
20
+ }
21
+
22
+ /**
23
+ * Check if one of carriers require state/province
24
+ *
25
+ * @return bool
26
+ */
27
+ public function isStateProvinceRequired()
28
+ {
29
+ return (bool)Mage::getStoreConfig('carriers/temando/active') || parent::isStateProvinceRequired();
30
+ }
31
+
32
+ /**
33
+ * Check if one of carriers require city
34
+ *
35
+ * @return bool
36
+ */
37
+ public function isCityRequired()
38
+ {
39
+ return (bool)Mage::getStoreConfig('carriers/temando/active') || parent::isCityRequired();
40
+ }
41
+
42
+ /**
43
+ * Check if one of carriers require zip code
44
+ *
45
+ * @return bool
46
+ */
47
+ public function isZipCodeRequired()
48
+ {
49
+ return (bool)Mage::getStoreConfig('carriers/temando/active') || parent::isZipCodeRequired();
50
+ }
51
+
52
+ /**
53
+ * Get the estimate postcode
54
+ *
55
+ * @return string
56
+ */
57
+ public function getEstimatePostcode()
58
+ {
59
+ $return = parent::getEstimatePostcode();
60
+ if (!$return && Mage::helper('temando')->getSessionPostcode()) {
61
+ $return = Mage::helper('temando')->getSessionPostcode();
62
+ }
63
+
64
+ return $return;
65
+ }
66
+
67
+ /**
68
+ * Get the estimate city
69
+ *
70
+ * @return string
71
+ */
72
+ public function getEstimateCity()
73
+ {
74
+ $return = parent::getEstimateCity();
75
+ if (!$return && Mage::helper('temando')->getSessionCity()) {
76
+ $return = Mage::helper('temando')->getSessionCity();
77
+ }
78
+
79
+ return $return;
80
+ }
81
+
82
+ /**
83
+ * Get the estimate region id
84
+ *
85
+ * @return string
86
+ */
87
+ public function getEstimateRegionId()
88
+ {
89
+ $return = parent::getEstimateRegionId();
90
+ if (!$return && Mage::helper('temando')->getSessionRegionId()) {
91
+ $return = Mage::helper('temando')->getSessionRegionId();
92
+ }
93
+
94
+ return $return;
95
+ }
96
+
97
+ /**
98
+ * Get the estimate region
99
+ *
100
+ * @return string
101
+ */
102
+ public function getEstimateRegion()
103
+ {
104
+ $return = parent::getEstimateRegion();
105
+ if (!$return && Mage::helper('temando')->getSessionRegion()) {
106
+ $return = Mage::helper('temando')->getSessionRegion();
107
+ }
108
+
109
+ return $return;
110
+ }
111
+
112
+ /**
113
+ * Show location type selection to customer?
114
+ *
115
+ * @return boolean
116
+ */
117
+ public function showLocationType()
118
+ {
119
+ $options = Mage::helper('temando')->getConfigData('checkout/delivery_options');
120
+ if (!$options) {
121
+ return false;
122
+ }
123
+ return Mage::helper('temando')->getConfigData('checkout/location_type');
124
+ }
125
+
126
+ /**
127
+ * Return saved destination type as selected by customer
128
+ *
129
+ * @return string
130
+ */
131
+ public function getDestinationType()
132
+ {
133
+ $destinationType = Mage::getSingleton('checkout/session')->getData('destination_type');
134
+ return $destinationType ?
135
+ $destinationType :
136
+ Temando_Temando_Model_Checkout_Delivery_Options::DESTINATION_RESIDENCE;
137
+ }
138
+ }
app/code/community/Temando/Temando/Block/Onepage/Shipping/Delivery/Options.php CHANGED
@@ -1,89 +1,89 @@
1
- <?php
2
- /**
3
- * Onepage Shipping Delivery Options
4
- *
5
- * @package Temando_Temando
6
- * @author Temando Magento Team <marketing@temando.com>
7
- */
8
- class Temando_Temando_Block_Onepage_Shipping_Delivery_Options
9
- extends Mage_Checkout_Block_Onepage_Abstract
10
- {
11
-
12
- /**
13
- * Delivery options enabled in system configuration for display in checkout
14
- *
15
- * @var array
16
- */
17
- protected $_enabledOptions = null;
18
-
19
- /**
20
- * Retrieve Temando system configuration value
21
- *
22
- * @param string $field The identifier of config entry
23
- * @return mixed
24
- */
25
- public function getConfigData($field)
26
- {
27
- return Mage::helper('temando')->getConfigData($field);
28
- }
29
-
30
- /**
31
- * Show location type selection to customer?
32
- *
33
- * @return boolean
34
- */
35
- public function showLocationType()
36
- {
37
- return $this->getConfigData('checkout/location_type');
38
- }
39
-
40
- /**
41
- * Show additional delivery options to customer?
42
- *
43
- * @return boolean
44
- */
45
- public function showOptions()
46
- {
47
- return $this->getConfigData('checkout/delivery_options');
48
- }
49
-
50
- /**
51
- * Return saved destination type as selected by customer
52
- *
53
- * @return string
54
- */
55
- public function getDestinationType()
56
- {
57
- $destinationType = Mage::getSingleton('checkout/session')->getData('destination_type');
58
- return $destinationType ?
59
- $destinationType :
60
- Temando_Temando_Model_Checkout_Delivery_Options::DESTINATION_RESIDENCE;
61
- }
62
-
63
- /**
64
- * Returns enabled checkout options
65
- *
66
- * @return array
67
- */
68
- public function getEnabledOptions()
69
- {
70
- if (!$this->_enabledOptions) {
71
- $this->_enabledOptions = Mage::getModel('temando/checkout_delivery_options')->getEnabledOptions();
72
- }
73
- return $this->_enabledOptions;
74
- }
75
-
76
- /**
77
- * Returns customer selected delivery options
78
- *
79
- * @return array Customer selected options
80
- */
81
- public function getSelectedOptions()
82
- {
83
- $selected = Mage::getSingleton('checkout/session')->getData('selected_delivery_options');
84
- if (!is_array($selected)) {
85
- $selected = array();
86
- }
87
- return $selected;
88
- }
89
- }
1
+ <?php
2
+ /**
3
+ * Onepage Shipping Delivery Options
4
+ *
5
+ * @package Temando_Temando
6
+ * @author Temando Magento Team <marketing@temando.com>
7
+ */
8
+ class Temando_Temando_Block_Onepage_Shipping_Delivery_Options
9
+ extends Mage_Checkout_Block_Onepage_Abstract
10
+ {
11
+
12
+ /**
13
+ * Delivery options enabled in system configuration for display in checkout
14
+ *
15
+ * @var array
16
+ */
17
+ protected $_enabledOptions = null;
18
+
19
+ /**
20
+ * Retrieve Temando system configuration value
21
+ *
22
+ * @param string $field The identifier of config entry
23
+ * @return mixed
24
+ */
25
+ public function getConfigData($field)
26
+ {
27
+ return Mage::helper('temando')->getConfigData($field);
28
+ }
29
+
30
+ /**
31
+ * Show location type selection to customer?
32
+ *
33
+ * @return boolean
34
+ */
35
+ public function showLocationType()
36
+ {
37
+ return $this->getConfigData('checkout/location_type');
38
+ }
39
+
40
+ /**
41
+ * Show additional delivery options to customer?
42
+ *
43
+ * @return boolean
44
+ */
45
+ public function showOptions()
46
+ {
47
+ return $this->getConfigData('checkout/delivery_options');
48
+ }
49
+
50
+ /**
51
+ * Return saved destination type as selected by customer
52
+ *
53
+ * @return string
54
+ */
55
+ public function getDestinationType()
56
+ {
57
+ $destinationType = Mage::getSingleton('checkout/session')->getData('destination_type');
58
+ return $destinationType ?
59
+ $destinationType :
60
+ Temando_Temando_Model_Checkout_Delivery_Options::DESTINATION_RESIDENCE;
61
+ }
62
+
63
+ /**
64
+ * Returns enabled checkout options
65
+ *
66
+ * @return array
67
+ */
68
+ public function getEnabledOptions()
69
+ {
70
+ if (!$this->_enabledOptions) {
71
+ $this->_enabledOptions = Mage::getModel('temando/checkout_delivery_options')->getEnabledOptions();
72
+ }
73
+ return $this->_enabledOptions;
74
+ }
75
+
76
+ /**
77
+ * Returns customer selected delivery options
78
+ *
79
+ * @return array Customer selected options
80
+ */
81
+ public function getSelectedOptions()
82
+ {
83
+ $selected = Mage::getSingleton('checkout/session')->getData('selected_delivery_options');
84
+ if (!is_array($selected)) {
85
+ $selected = array();
86
+ }
87
+ return $selected;
88
+ }
89
+ }
app/code/community/Temando/Temando/Block/Onepage/Shipping/Method/Available.php CHANGED
@@ -1,12 +1,12 @@
1
- <?php
2
- /**
3
- * Onepage Shipping Method Available
4
- *
5
- * @package Temando_Temando
6
- * @author Temando Magento Team <marketing@temando.com>
7
- */
8
- class Temando_Temando_Block_Onepage_Shipping_Method_Available
9
- extends Mage_Checkout_Block_Onepage_Shipping_Method_Available
10
- {
11
-
12
- }
1
+ <?php
2
+ /**
3
+ * Onepage Shipping Method Available
4
+ *
5
+ * @package Temando_Temando
6
+ * @author Temando Magento Team <marketing@temando.com>
7
+ */
8
+ class Temando_Temando_Block_Onepage_Shipping_Method_Available
9
+ extends Mage_Checkout_Block_Onepage_Shipping_Method_Available
10
+ {
11
+
12
+ }
app/code/community/Temando/Temando/Block/Onepage/Shipping/Method/Available/Single.php CHANGED
@@ -1,60 +1,61 @@
1
- <?php
2
- /**
3
- * Onepage Shipping Method Available Single
4
- *
5
- * @package Temando_Temando
6
- * @author Temando Magento Team <marketing@temando.com>
7
- */
8
- class Temando_Temando_Block_Onepage_Shipping_Method_Available_Single
9
- extends Temando_Temando_Block_Onepage_Shipping_Method_Available
10
- {
11
- /**
12
- * One shipping method only?
13
- *
14
- * @return boolean
15
- */
16
- public function getSole()
17
- {
18
- // by default the following will return false. remove the
19
- // line below to actually check if it is the only method
20
- return false;
21
- $groups = $this->getShippingRates();
22
- if(count($groups) == 1) {
23
- $rates = array_pop($groups);
24
- if(count($rates) == 1) return true;
25
- }
26
- return false;
27
- }
28
-
29
- /**
30
- * @return Temando_Temando_Model_Options
31
- */
32
- public function getOptions()
33
- {
34
- $options = Mage::registry('temando_current_options');
35
- if(!$options) {
36
- $options = array();
37
- }
38
-
39
- return $options;
40
- }
41
-
42
-
43
- /**
44
- * Returns class for a shipping rate element (radio button)
45
- * (used in conjunction with extras tick boxes)
46
- *
47
- * @param string $code Shipping rate code
48
- * @return string
49
- */
50
- public function getClassFromRateCode($code)
51
- {
52
- $class = '';
53
- if(preg_match('/^temando_/', $code)) {
54
- preg_match_all('/(insurance|carbonoffset|footprints)_(Y|N)/', $code, $matches);
55
- $class = implode(' ', $matches[0]);
56
- }
57
- return $class;
58
- }
59
-
60
- }
 
1
+ <?php
2
+ /**
3
+ * Onepage Shipping Method Available Single
4
+ *
5
+ * @package Temando_Temando
6
+ * @author Temando Magento Team <marketing@temando.com>
7
+ */
8
+ class Temando_Temando_Block_Onepage_Shipping_Method_Available_Single
9
+ extends Temando_Temando_Block_Onepage_Shipping_Method_Available
10
+ {
11
+ /**
12
+ * One shipping method only?
13
+ *
14
+ * @return boolean
15
+ */
16
+ public function getSole()
17
+ {
18
+ // by default the following will return false. remove the
19
+ // line below to actually check if it is the only method
20
+ return false;
21
+ $groups = $this->getShippingRates();
22
+ if (count($groups) == 1) {
23
+ $rates = array_pop($groups);
24
+ if (count($rates) == 1) {
25
+ return true;
26
+ }
27
+ }
28
+ return false;
29
+ }
30
+
31
+ /**
32
+ * @return Temando_Temando_Model_Options
33
+ */
34
+ public function getOptions()
35
+ {
36
+ $options = Mage::registry('temando_current_options');
37
+ if (!$options) {
38
+ $options = array();
39
+ }
40
+
41
+ return $options;
42
+ }
43
+
44
+
45
+ /**
46
+ * Returns class for a shipping rate element (radio button)
47
+ * (used in conjunction with extras tick boxes)
48
+ *
49
+ * @param string $code Shipping rate code
50
+ * @return string
51
+ */
52
+ public function getClassFromRateCode($code)
53
+ {
54
+ $class = '';
55
+ if (preg_match('/^temando_/', $code)) {
56
+ preg_match_all('/(insurance|carbonoffset|footprints)_(Y|N)/', $code, $matches);
57
+ $class = implode(' ', $matches[0]);
58
+ }
59
+ return $class;
60
+ }
61
+ }
app/code/community/Temando/Temando/Block/Product/Shipping.php CHANGED
@@ -1,85 +1,83 @@
1
- <?php
2
- /**
3
- * Product Shipping
4
- *
5
- * @package Temando_Temando
6
- * @author Temando Magento Team <marketing@temando.com>
7
- */
8
- class Temando_Temando_Block_Product_Shipping extends Mage_Core_Block_Template
9
- {
10
-
11
- /**
12
- * Initialize block
13
- *
14
- */
15
- protected function _construct()
16
- {
17
- $this->setId('temando_shipping');
18
- }
19
-
20
- public function getCountryId()
21
- {
22
- if (Mage::getSingleton('customer/session')->getData('estimate_product_shipping')) {
23
- return Mage::getSingleton('customer/session')->getData('estimate_product_shipping')->getCountryId();
24
- }
25
-
26
- return Mage::helper('temando')->getDefaultCountryId();
27
- }
28
-
29
- public function getProductId()
30
- {
31
- if (Mage::registry('current_product')) {
32
- return Mage::registry('current_product')->getId();
33
- }
34
-
35
- return '0';
36
- }
37
-
38
- public function getRegionId()
39
- {
40
- if (Mage::getSingleton('customer/session')->getData('estimate_product_shipping')) {
41
- return Mage::getSingleton('customer/session')->getData('estimate_product_shipping')->getRegionId();
42
- }
43
-
44
- return '';
45
- }
46
-
47
- public function getCity()
48
- {
49
- if (Mage::getSingleton('customer/session')->getData('estimate_product_shipping')) {
50
- return Mage::getSingleton('customer/session')->getData('estimate_product_shipping')->getCity();
51
- }
52
-
53
- return '';
54
- }
55
-
56
- public function getPostcode()
57
- {
58
- if (Mage::getSingleton('customer/session')->getData('estimate_product_shipping')) {
59
- return Mage::getSingleton('customer/session')->getData('estimate_product_shipping')->getPostcode();
60
- }
61
-
62
- return '';
63
- }
64
-
65
- public function getPcs()
66
- {
67
- if (Mage::getSingleton('customer/session')->getData('estimate_product_shipping')) {
68
- return Mage::getSingleton('customer/session')->getData('estimate_product_shipping')->getPcs();
69
- }
70
-
71
- return '';
72
- }
73
-
74
- public function getCountryOptions()
75
- {
76
- return Mage::helper('temando')->getAllowedCountries();
77
- }
78
-
79
- public function getQty()
80
- {
81
- return '1';
82
- }
83
-
84
-
85
- }
1
+ <?php
2
+ /**
3
+ * Product Shipping
4
+ *
5
+ * @package Temando_Temando
6
+ * @author Temando Magento Team <marketing@temando.com>
7
+ */
8
+ class Temando_Temando_Block_Product_Shipping extends Mage_Core_Block_Template
9
+ {
10
+
11
+ /**
12
+ * Initialize block
13
+ *
14
+ */
15
+ protected function _construct()
16
+ {
17
+ $this->setId('temando_shipping');
18
+ }
19
+
20
+ public function getCountryId()
21
+ {
22
+ if (Mage::getSingleton('customer/session')->getData('estimate_product_shipping')) {
23
+ return Mage::getSingleton('customer/session')->getData('estimate_product_shipping')->getCountryId();
24
+ }
25
+
26
+ return Mage::helper('temando')->getDefaultCountryId();
27
+ }
28
+
29
+ public function getProductId()
30
+ {
31
+ if (Mage::registry('current_product')) {
32
+ return Mage::registry('current_product')->getId();
33
+ }
34
+
35
+ return '0';
36
+ }
37
+
38
+ public function getRegionId()
39
+ {
40
+ if (Mage::getSingleton('customer/session')->getData('estimate_product_shipping')) {
41
+ return Mage::getSingleton('customer/session')->getData('estimate_product_shipping')->getRegionId();
42
+ }
43
+
44
+ return '';
45
+ }
46
+
47
+ public function getCity()
48
+ {
49
+ if (Mage::getSingleton('customer/session')->getData('estimate_product_shipping')) {
50
+ return Mage::getSingleton('customer/session')->getData('estimate_product_shipping')->getCity();
51
+ }
52
+
53
+ return '';
54
+ }
55
+
56
+ public function getPostcode()
57
+ {
58
+ if (Mage::getSingleton('customer/session')->getData('estimate_product_shipping')) {
59
+ return Mage::getSingleton('customer/session')->getData('estimate_product_shipping')->getPostcode();
60
+ }
61
+
62
+ return '';
63
+ }
64
+
65
+ public function getPcs()
66
+ {
67
+ if (Mage::getSingleton('customer/session')->getData('estimate_product_shipping')) {
68
+ return Mage::getSingleton('customer/session')->getData('estimate_product_shipping')->getPcs();
69
+ }
70
+
71
+ return '';
72
+ }
73
+
74
+ public function getCountryOptions()
75
+ {
76
+ return Mage::helper('temando')->getAllowedCountries();
77
+ }
78
+
79
+ public function getQty()
80
+ {
81
+ return '1';
82
+ }
83
+ }
 
 
app/code/community/Temando/Temando/Block/Product/Shipping/Methods.php CHANGED
@@ -1,31 +1,31 @@
1
- <?php
2
- /**
3
- * Product Shipping Methods
4
- *
5
- * @package Temando_Temando
6
- * @author Temando Magento Team <marketing@temando.com>
7
- */
8
- class Temando_Temando_Block_Product_Shipping_Methods extends Mage_Core_Block_Template
9
- {
10
-
11
- public function getEstimateRates()
12
- {
13
- $rates = Mage::registry('product_rates');
14
- return $rates;
15
- //return Mage::registry('product_rates');
16
- }
17
-
18
-
19
- public function getCarrierName($carrierCode)
20
- {
21
- if ($name = Mage::getStoreConfig('carriers/'.$carrierCode.'/title')) {
22
- return $name;
23
- }
24
- return $carrierCode;
25
- }
26
-
27
- public function formatPrice($price)
28
- {
29
- return Mage::app()->getStore()->convertPrice($price, true);
30
- }
31
- }
1
+ <?php
2
+ /**
3
+ * Product Shipping Methods
4
+ *
5
+ * @package Temando_Temando
6
+ * @author Temando Magento Team <marketing@temando.com>
7
+ */
8
+ class Temando_Temando_Block_Product_Shipping_Methods extends Mage_Core_Block_Template
9
+ {
10
+
11
+ public function getEstimateRates()
12
+ {
13
+ $rates = Mage::registry('product_rates');
14
+ return $rates;
15
+ //return Mage::registry('product_rates');
16
+ }
17
+
18
+
19
+ public function getCarrierName($carrierCode)
20
+ {
21
+ if ($name = Mage::getStoreConfig('carriers/'.$carrierCode.'/title')) {
22
+ return $name;
23
+ }
24
+ return $carrierCode;
25
+ }
26
+
27
+ public function formatPrice($price)
28
+ {
29
+ return Mage::app()->getStore()->convertPrice($price, true);
30
+ }
31
+ }
app/code/community/Temando/Temando/Block/Wizard/Html.php CHANGED
@@ -1,287 +1,288 @@
1
- <?php
2
- /**
3
- * Wizard Html
4
- *
5
- * @package Temando_Temando
6
- * @author Temando Magento Team <marketing@temando.com>
7
- */
8
- class Temando_Temando_Block_Wizard_Html extends Mage_Install_Block_Abstract
9
- {
10
-
11
- public function __construct() {
12
- parent::__construct();
13
- }
14
-
15
- /**
16
- * Creates HTML select box that outputs to the view
17
- * @param string $type
18
- * @return string
19
- */
20
- public function getHtmlSelect($type)
21
- {
22
- $select = $this->getSelectOptions($type);
23
- $html = $this->getLayout()->createBlock('core/html_select')
24
- ->setExtraParams($select['extraParams'])
25
- ->setName($select['name'])
26
- ->setId($select['id'])
27
- ->setTitle($select['title'])
28
- ->setClass($select['html_class'])
29
- ->setValue($select['value'])
30
- ->setOptions($select['options'])
31
- ->getHtml();
32
- return $html;
33
- }
34
-
35
- /**
36
- * Gets Temando Account mode options
37
- * @return array
38
- */
39
- public function modeOptions()
40
- {
41
- $mode = array(
42
- array(
43
- 'value' => 0,
44
- 'label' => Mage::helper('temando')->__('Live')
45
- ),
46
- array(
47
- 'value' => 1,
48
- 'label' => Mage::helper('temando')->__('Sandbox')
49
- ));
50
- return $mode;
51
- }
52
-
53
- /**
54
- * Gets Temando Fragile options
55
- * @return array
56
- */
57
- public function yesNoOptions()
58
- {
59
- $yesno = array(
60
- array(
61
- 'value' => 0,
62
- 'label' => Mage::helper('temando')->__('No')
63
- ),
64
- array(
65
- 'value' => 1,
66
- 'label' => Mage::helper('temando')->__('Yes')
67
- ));
68
- return $yesno;
69
- }
70
-
71
- /**
72
- * Gets Temando Account Payment options
73
- * @return array
74
- */
75
- public function paymentOptions()
76
- {
77
- $payment = array(
78
- array(
79
- 'value' => 'Credit',
80
- 'label' => Mage::helper('temando')->__('Credit')
81
- ),
82
- array(
83
- 'value' => 'Account',
84
- 'label' => Mage::helper('temando')->__('Account')
85
- ));
86
- return $payment;
87
- }
88
-
89
- /**
90
- * Gets Allowed or Specific Country options
91
- * @return array
92
- */
93
- public function allowedCountryOptions()
94
- {
95
- $country = array(
96
- array(
97
- 'value' => 0,
98
- 'label' => Mage::helper('temando')->__('All Allowed Countries')
99
- ),
100
- array(
101
- 'value' => 1,
102
- 'label' => Mage::helper('temando')->__('Specific Countries')
103
- ));
104
- return $country;
105
- }
106
-
107
- /**
108
- * Gets Temando Rule Type options
109
- * @return string
110
- */
111
- public function ruleTypeOptions()
112
- {
113
- $options = Mage::getModel('temando/system_config_source_pricing')->getOptions();
114
- return $options;
115
- }
116
-
117
- /**
118
- * Gets the value of a name/key combination in the Temando Wizard session
119
- * @param string $name
120
- * @param string $key
121
- * @return null
122
- */
123
- public function getTmdSession($name, $key)
124
- {
125
- $session = Mage::getSingleton('core/session')->getData($name);
126
- if (is_array($session)) {
127
- if (array_key_exists($key, $session)) {
128
- return $session[$key];
129
- } else {
130
- return null;
131
- }
132
- } else {
133
- return null;
134
- }
135
- }
136
-
137
- /**
138
- * Gets Temando Carrier Data
139
- * @param string $field
140
- * @return string
141
- */
142
- public function getCarrierData($field)
143
- {
144
- $path = 'carriers/temando/' . $field;
145
- return Mage::getStoreConfig($path);
146
- }
147
-
148
- /**
149
- * Gets Temando Carrier Data in Array
150
- * @param string $field
151
- * @return string
152
- */
153
- public function getCarrierDataArray($field)
154
- {
155
- $values = explode(',', Mage::getStoreConfig('carriers/temando/' . $field));
156
- return $values;
157
- }
158
-
159
- /**
160
- * Gets current admin url
161
- * @return string
162
- */
163
- public function getCancelUrl()
164
- {
165
- return Mage::getSingleton('core/session')->getTemandoCancelUrl();
166
- }
167
-
168
- /**
169
- * Gets options for rendering the select box based on type
170
- * @param string $type
171
- * @return array
172
- */
173
- protected function getSelectOptions($type)
174
- {
175
- $types = array(
176
- 'mode' => array(
177
- 'extraParams' => '',
178
- 'name' => 'general_sandbox',
179
- 'id' => 'sandbox',
180
- 'title' => Mage::helper('temando')->__('Mode'),
181
- 'html_class' => 'required-entry',
182
- 'value' => Mage::helper('temando')->getConfigData('general/sandbox'),
183
- 'options' => $this->modeOptions()
184
- ),
185
- 'payment' => array(
186
- 'extraParams' => '',
187
- 'name' => 'general_payment_type',
188
- 'id' => 'payment_type',
189
- 'title' => Mage::helper('temando')->__('Payment'),
190
- 'html_class' => 'required-entry',
191
- 'value' => Mage::helper('temando')->getConfigData('general/payment_type'),
192
- 'options' => $this->paymentOptions()
193
- ),
194
- 'allowedCountries' => array(
195
- 'extraParams' => '',
196
- 'name' => 'temando_sallowspecific',
197
- 'id' => 'sallowspecific',
198
- 'title' => Mage::helper('temando')->__('Allow Specific Countries'),
199
- 'html_class' => 'required-entry',
200
- 'value' => $this->getCarrierData('sallowspecific'),
201
- 'options' => $this->allowedCountryOptions()
202
- ),
203
- 'specificCountries' => array(
204
- 'extraParams' => 'multiple="multiple" size="10"',
205
- 'name' => 'temando_specificcountry[]',
206
- 'id' => 'specificcountry',
207
- 'title' => Mage::helper('temando')->__('Specific Country'),
208
- 'html_class' => 'required-entry multiselect',
209
- 'value' => $this->getCarrierDataArray('specificcountry'),
210
- 'options' => Mage::getModel('temando/system_config_source_country')->getOptions()
211
- ),
212
- 'allowedCarriers' => array(
213
- 'extraParams' => 'multiple="multiple" size="10"',
214
- 'name' => 'temando_allowed_methods[]',
215
- 'id' => 'allowed_methods',
216
- 'title' => Mage::helper('temando')->__('Allowed Carriers'),
217
- 'html_class' => 'required-entry multiselect',
218
- 'value' => $this->getCarrierDataArray('allowed_methods'),
219
- 'options' => Mage::getModel('temando/shipping_carrier_temando_source_method')->getOptions()
220
- ),
221
- 'measureUnits' => array(
222
- 'extraParams' => '',
223
- 'name' => 'units_measure',
224
- 'id' => 'measure',
225
- 'title' => Mage::helper('temando')->__('Measure Unit'),
226
- 'html_class' => 'required-entry',
227
- 'value' => Mage::helper('temando')->getConfigData('units/measure'),
228
- 'options' => Mage::getModel('temando/system_config_source_unit_measure')->getOptions()
229
- ),
230
- 'weightUnits' => array(
231
- 'extraParams' => '',
232
- 'name' => 'units_weight',
233
- 'id' => 'weight',
234
- 'title' => Mage::helper('temando')->__('Weight Unit'),
235
- 'html_class' => 'required-entry',
236
- 'value' => Mage::helper('temando')->getConfigData('units/weight'),
237
- 'options' => Mage::getModel('temando/system_config_source_unit_weight')->getOptions()
238
- ),
239
- 'packagingType' => array(
240
- 'extraParams' => '',
241
- 'name' => 'defaults_packaging',
242
- 'id' => 'packaging',
243
- 'title' => Mage::helper('temando')->__('Packaging'),
244
- 'html_class' => 'required-entry',
245
- 'value' => Mage::helper('temando')->getConfigData('defaults/packaging'),
246
- 'options' => Mage::getModel('temando/system_config_source_shipment_packaging')->getOptions()
247
- ),
248
- 'fragile' => array(
249
- 'extraParams' => '',
250
- 'name' => 'defaults_fragile',
251
- 'id' => 'fragile',
252
- 'title' => Mage::helper('temando')->__('Fragile'),
253
- 'html_class' => 'required-entry',
254
- 'value' => Mage::helper('temando')->getConfigData('defaults/fragile'),
255
- 'options' => $this->yesNoOptions()
256
- ),
257
- 'countries' => array(
258
- 'extraParams' => '',
259
- 'name' => 'origin_country',
260
- 'id' => 'origin_country',
261
- 'title' => Mage::helper('temando')->__('Country'),
262
- 'html_class' => 'required-entry',
263
- 'value' => Mage::helper('temando')->getConfigData('origin/country'),
264
- 'options' => Mage::getModel('temando/system_config_source_country')->getOptions()
265
- ),
266
- 'regions' => array(
267
- 'extraParams' => '',
268
- 'name' => 'origin_region',
269
- 'id' => 'origin_region',
270
- 'title' => Mage::helper('temando')->__('Region'),
271
- 'html_class' => 'required-entry',
272
- 'value' => Mage::helper('temando')->getConfigData('origin/region'),
273
- 'options' => Mage::getModel('temando/system_config_source_regions')->getOptions(true)
274
- ),
275
- 'ruleType' => array(
276
- 'extraParams' => '',
277
- 'name' => 'pricing_method',
278
- 'id' => 'pricing_method',
279
- 'title' => Mage::helper('temando')->__('Rule Type'),
280
- 'html_class' => 'required-entry',
281
- 'value' => Mage::helper('temando')->getConfigData('pricing/method'),
282
- 'options' => $this->ruleTypeOptions()
283
- ),
284
- );
285
- return $types[$type];
286
- }
287
- }
 
1
+ <?php
2
+ /**
3
+ * Wizard Html
4
+ *
5
+ * @package Temando_Temando
6
+ * @author Temando Magento Team <marketing@temando.com>
7
+ */
8
+ class Temando_Temando_Block_Wizard_Html extends Mage_Install_Block_Abstract
9
+ {
10
+
11
+ public function __construct()
12
+ {
13
+ parent::__construct();
14
+ }
15
+
16
+ /**
17
+ * Creates HTML select box that outputs to the view
18
+ * @param string $type
19
+ * @return string
20
+ */
21
+ public function getHtmlSelect($type)
22
+ {
23
+ $select = $this->getSelectOptions($type);
24
+ $html = $this->getLayout()->createBlock('core/html_select')
25
+ ->setExtraParams($select['extraParams'])
26
+ ->setName($select['name'])
27
+ ->setId($select['id'])
28
+ ->setTitle($select['title'])
29
+ ->setClass($select['html_class'])
30
+ ->setValue($select['value'])
31
+ ->setOptions($select['options'])
32
+ ->getHtml();
33
+ return $html;
34
+ }
35
+
36
+ /**
37
+ * Gets Temando Account mode options
38
+ * @return array
39
+ */
40
+ public function modeOptions()
41
+ {
42
+ $mode = array(
43
+ array(
44
+ 'value' => 0,
45
+ 'label' => Mage::helper('temando')->__('Live')
46
+ ),
47
+ array(
48
+ 'value' => 1,
49
+ 'label' => Mage::helper('temando')->__('Sandbox')
50
+ ));
51
+ return $mode;
52
+ }
53
+
54
+ /**
55
+ * Gets Temando Fragile options
56
+ * @return array
57
+ */
58
+ public function yesNoOptions()
59
+ {
60
+ $yesno = array(
61
+ array(
62
+ 'value' => 0,
63
+ 'label' => Mage::helper('temando')->__('No')
64
+ ),
65
+ array(
66
+ 'value' => 1,
67
+ 'label' => Mage::helper('temando')->__('Yes')
68
+ ));
69
+ return $yesno;
70
+ }
71
+
72
+ /**
73
+ * Gets Temando Account Payment options
74
+ * @return array
75
+ */
76
+ public function paymentOptions()
77
+ {
78
+ $payment = array(
79
+ array(
80
+ 'value' => 'Credit',
81
+ 'label' => Mage::helper('temando')->__('Credit')
82
+ ),
83
+ array(
84
+ 'value' => 'Account',
85
+ 'label' => Mage::helper('temando')->__('Account')
86
+ ));
87
+ return $payment;
88
+ }
89
+
90
+ /**
91
+ * Gets Allowed or Specific Country options
92
+ * @return array
93
+ */
94
+ public function allowedCountryOptions()
95
+ {
96
+ $country = array(
97
+ array(
98
+ 'value' => 0,
99
+ 'label' => Mage::helper('temando')->__('All Allowed Countries')
100
+ ),
101
+ array(
102
+ 'value' => 1,
103
+ 'label' => Mage::helper('temando')->__('Specific Countries')
104
+ ));
105
+ return $country;
106
+ }
107
+
108
+ /**
109
+ * Gets Temando Rule Type options
110
+ * @return string
111
+ */
112
+ public function ruleTypeOptions()
113
+ {
114
+ $options = Mage::getModel('temando/system_config_source_pricing')->getOptions();
115
+ return $options;
116
+ }
117
+
118
+ /**
119
+ * Gets the value of a name/key combination in the Temando Wizard session
120
+ * @param string $name
121
+ * @param string $key
122
+ * @return null
123
+ */
124
+ public function getTmdSession($name, $key)
125
+ {
126
+ $session = Mage::getSingleton('core/session')->getData($name);
127
+ if (is_array($session)) {
128
+ if (array_key_exists($key, $session)) {
129
+ return $session[$key];
130
+ } else {
131
+ return null;
132
+ }
133
+ } else {
134
+ return null;
135
+ }
136
+ }
137
+
138
+ /**
139
+ * Gets Temando Carrier Data
140
+ * @param string $field
141
+ * @return string
142
+ */
143
+ public function getCarrierData($field)
144
+ {
145
+ $path = 'carriers/temando/' . $field;
146
+ return Mage::getStoreConfig($path);
147
+ }
148
+
149
+ /**
150
+ * Gets Temando Carrier Data in Array
151
+ * @param string $field
152
+ * @return string
153
+ */
154
+ public function getCarrierDataArray($field)
155
+ {
156
+ $values = explode(',', Mage::getStoreConfig('carriers/temando/' . $field));
157
+ return $values;
158
+ }
159
+
160
+ /**
161
+ * Gets current admin url
162
+ * @return string
163
+ */
164
+ public function getCancelUrl()
165
+ {
166
+ return Mage::getSingleton('core/session')->getTemandoCancelUrl();
167
+ }
168
+
169
+ /**
170
+ * Gets options for rendering the select box based on type
171
+ * @param string $type
172
+ * @return array
173
+ */
174
+ protected function getSelectOptions($type)
175
+ {
176
+ $types = array(
177
+ 'mode' => array(
178
+ 'extraParams' => '',
179
+ 'name' => 'general_sandbox',
180
+ 'id' => 'sandbox',
181
+ 'title' => Mage::helper('temando')->__('Mode'),
182
+ 'html_class' => 'required-entry',
183
+ 'value' => Mage::helper('temando')->getConfigData('general/sandbox'),
184
+ 'options' => $this->modeOptions()
185
+ ),
186
+ 'payment' => array(
187
+ 'extraParams' => '',
188
+ 'name' => 'general_payment_type',
189
+ 'id' => 'payment_type',
190
+ 'title' => Mage::helper('temando')->__('Payment'),
191
+ 'html_class' => 'required-entry',
192
+ 'value' => Mage::helper('temando')->getConfigData('general/payment_type'),
193
+ 'options' => $this->paymentOptions()
194
+ ),
195
+ 'allowedCountries' => array(
196
+ 'extraParams' => '',
197
+ 'name' => 'temando_sallowspecific',
198
+ 'id' => 'sallowspecific',
199
+ 'title' => Mage::helper('temando')->__('Allow Specific Countries'),
200
+ 'html_class' => 'required-entry',
201
+ 'value' => $this->getCarrierData('sallowspecific'),
202
+ 'options' => $this->allowedCountryOptions()
203
+ ),
204
+ 'specificCountries' => array(
205
+ 'extraParams' => 'multiple="multiple" size="10"',
206
+ 'name' => 'temando_specificcountry[]',
207
+ 'id' => 'specificcountry',
208
+ 'title' => Mage::helper('temando')->__('Specific Country'),
209
+ 'html_class' => 'required-entry multiselect',
210
+ 'value' => $this->getCarrierDataArray('specificcountry'),
211
+ 'options' => Mage::getModel('temando/system_config_source_country')->getOptions()
212
+ ),
213
+ 'allowedCarriers' => array(
214
+ 'extraParams' => 'multiple="multiple" size="10"',
215
+ 'name' => 'temando_allowed_methods[]',
216
+ 'id' => 'allowed_methods',
217
+ 'title' => Mage::helper('temando')->__('Allowed Carriers'),
218
+ 'html_class' => 'required-entry multiselect',
219
+ 'value' => $this->getCarrierDataArray('allowed_methods'),
220
+ 'options' => Mage::getModel('temando/shipping_carrier_temando_source_method')->getOptions()
221
+ ),
222
+ 'measureUnits' => array(
223
+ 'extraParams' => '',
224
+ 'name' => 'units_measure',
225
+ 'id' => 'measure',
226
+ 'title' => Mage::helper('temando')->__('Measure Unit'),
227
+ 'html_class' => 'required-entry',
228
+ 'value' => Mage::helper('temando')->getConfigData('units/measure'),
229
+ 'options' => Mage::getModel('temando/system_config_source_unit_measure')->getOptions()
230
+ ),
231
+ 'weightUnits' => array(
232
+ 'extraParams' => '',
233
+ 'name' => 'units_weight',
234
+ 'id' => 'weight',
235
+ 'title' => Mage::helper('temando')->__('Weight Unit'),
236
+ 'html_class' => 'required-entry',
237
+ 'value' => Mage::helper('temando')->getConfigData('units/weight'),
238
+ 'options' => Mage::getModel('temando/system_config_source_unit_weight')->getOptions()
239
+ ),
240
+ 'packagingType' => array(
241
+ 'extraParams' => '',
242
+ 'name' => 'defaults_packaging',
243
+ 'id' => 'packaging',
244
+ 'title' => Mage::helper('temando')->__('Packaging'),
245
+ 'html_class' => 'required-entry',
246
+ 'value' => Mage::helper('temando')->getConfigData('defaults/packaging'),
247
+ 'options' => Mage::getModel('temando/system_config_source_shipment_packaging')->getOptions()
248
+ ),
249
+ 'fragile' => array(
250
+ 'extraParams' => '',
251
+ 'name' => 'defaults_fragile',
252
+ 'id' => 'fragile',
253
+ 'title' => Mage::helper('temando')->__('Fragile'),
254
+ 'html_class' => 'required-entry',
255
+ 'value' => Mage::helper('temando')->getConfigData('defaults/fragile'),
256
+ 'options' => $this->yesNoOptions()
257
+ ),
258
+ 'countries' => array(
259
+ 'extraParams' => '',
260
+ 'name' => 'origin_country',
261
+ 'id' => 'origin_country',
262
+ 'title' => Mage::helper('temando')->__('Country'),
263
+ 'html_class' => 'required-entry',
264
+ 'value' => Mage::helper('temando')->getConfigData('origin/country'),
265
+ 'options' => Mage::getModel('temando/system_config_source_country')->getOptions()
266
+ ),
267
+ 'regions' => array(
268
+ 'extraParams' => '',
269
+ 'name' => 'origin_region',
270
+ 'id' => 'origin_region',
271
+ 'title' => Mage::helper('temando')->__('Region'),
272
+ 'html_class' => 'required-entry',
273
+ 'value' => Mage::helper('temando')->getConfigData('origin/region'),
274
+ 'options' => Mage::getModel('temando/system_config_source_regions')->getOptions(true)
275
+ ),
276
+ 'ruleType' => array(
277
+ 'extraParams' => '',
278
+ 'name' => 'pricing_method',
279
+ 'id' => 'pricing_method',
280
+ 'title' => Mage::helper('temando')->__('Rule Type'),
281
+ 'html_class' => 'required-entry',
282
+ 'value' => Mage::helper('temando')->getConfigData('pricing/method'),
283
+ 'options' => $this->ruleTypeOptions()
284
+ ),
285
+ );
286
+ return $types[$type];
287
+ }
288
+ }
app/code/community/Temando/Temando/Helper/Data.php CHANGED
@@ -1,533 +1,615 @@
1
- <?php
2
- /**
3
- * Temando Helper Data
4
- *
5
- * @package Temando_Temando
6
- * @author Temando Magento Team <marketing@temando.com>
7
- */
8
- class Temando_Temando_Helper_Data extends Mage_Core_Helper_Abstract {
9
-
10
- const DEFAULT_WAREHOUSE_NAME = 'Magento Warehouse';
11
-
12
- const DEFAULT_CURRENCY_CODE = 'AUD';
13
-
14
- const DEFAULT_COUNTRY_ID = 'AU';
15
-
16
- private $_temandoAttributes = array(
17
- 'temando_packaging_mode',
18
- 'temando_packaging',
19
- 'temando_fragile',
20
- 'temando_dangerous',
21
- 'temando_length',
22
- 'temando_width',
23
- 'temando_height'
24
- );
25
-
26
- /**
27
- * Returns default weight unit
28
- */
29
- public function getDefaultWeightUnit()
30
- {
31
- return Temando_Temando_Model_System_Config_Source_Unit_Weight::KILOGRAMS;
32
- }
33
-
34
- /**
35
- * Returns default distance unit
36
- */
37
- public function getDefaultDistanceUnit()
38
- {
39
- return Temando_Temando_Model_System_Config_Source_Unit_Measure::CENTIMETRES;
40
- }
41
-
42
- /**
43
- * Returns default currency code
44
- */
45
- public function getDefaultCurrencyCode()
46
- {
47
- return self::DEFAULT_CURRENCY_CODE;
48
- }
49
-
50
- /**
51
- * Returns default country id
52
- */
53
- public function getDefaultCountryId()
54
- {
55
- return self::DEFAULT_COUNTRY_ID;
56
- }
57
-
58
-
59
- /**
60
- * Retrieves an element from the module configuration data.
61
- *
62
- * @param string $field
63
- */
64
- public function getConfigData($field)
65
- {
66
- $path = 'temando/' . $field;
67
- return Mage::getStoreConfig($path);
68
- }
69
-
70
- /**
71
- * Returns an array of all Magento countries
72
- *
73
- * @return array
74
- */
75
- public function getAllCountries()
76
- {
77
- $countries = array();
78
- $countryCollection = Mage::getModel('directory/country')->getCollection();
79
- foreach ($countryCollection as $country) {
80
- /* @var $country Mage_Directory_Model_Country */
81
- $countries[$country->getId()] = $country->getName();
82
- }
83
- return $countries;
84
- }
85
-
86
- /**
87
- * Returns array of allowed countries based on Magento system configuration
88
- * and Temando plugin allowed countries.
89
- *
90
- * @param boolean $asJson
91
- * @return array
92
- */
93
- public function getAllowedCountries($asJson = false)
94
- {
95
- $specific = Mage::getStoreConfig('carriers/temando/sallowspecific');
96
- //check if all allowed and return selected
97
- if ($specific == 1) {
98
- $availableCountries = explode(',', Mage::getStoreConfig('carriers/temando/specificcountry'));
99
- $countries = array_intersect_key($this->getAllCountries(), array_flip($availableCountries));
100
- if ($asJson) {
101
- return Mage::helper('core')->jsonEncode($countries);
102
- } else {
103
- return $countries;
104
- }
105
- }
106
- //return all allowed
107
- $availableCountries = explode(',', Mage::getStoreConfig('general/country/allow'));
108
- $countries = array_intersect_key($this->getAllCountries(), array_flip($availableCountries));
109
- if ($asJson) {
110
- return Mage::helper('core')->jsonEncode($countries);
111
- } else {
112
- return $countries;
113
- }
114
- }
115
-
116
- /**
117
- * Applies Temando attributes to sales quote item object
118
- *
119
- * @param Mage_Sales_Model_Order_Item $item
120
- */
121
- public function applyTemandoParamsToItem($item)
122
- {
123
- $attribs = $this->getTemandoProductAttributes($item);
124
- foreach($attribs as $key => $val) {
125
- $item->setData($key, $val);
126
- }
127
- }
128
-
129
- /**
130
- * Returns values for Temando specific product attributes. Currently handles simple
131
- * and configurable products only. Default attribute values from configuration are
132
- * returned if product temando retrieval mode is set to 'Use Defaults'
133
- *
134
- * @param Mage_Sales_Model_Order_Item $item
135
- * @param Mage_Catalog_Model_Product $product
136
- * @return array Temando specific product attributes
137
- */
138
- public function getTemandoProductAttributes($item = null, $product = null)
139
- {
140
- $attribs = array();
141
- if($item) {
142
- //Mage_Sales_Model_Order_Item = need to check if configurable
143
- $product = Mage::getModel('catalog/product')->load($item->getProductId());
144
- if ($product->isConfigurable()) {
145
- //configurable product - get selected simple product
146
- $simple_product = $this->getSelectedSimpleProductFromConfigurable($item);
147
- if($simple_product->getId() && $simple_product->getTemandoPackagingMode()) {
148
- //simple product found and retrieval mode is set to 'As Defined' => Retrieve attributes
149
- foreach($this->_temandoAttributes as $attribname) {
150
- $attribs[$attribname] = $simple_product->getData($attribname);
151
- }
152
- } else if($simple_product->getId() && !$simple_product->getTemandoPackagingMode()) {
153
- //simple product found and retrieval mode set to 'Use Defaults'
154
- //try to take from configurable parent product before looking at defaults
155
- if($product->getTemandoPackagingMode()) {
156
- foreach($this->_temandoAttributes as $attribname) {
157
- $attribs[$attribname] = $product->getData($attribname);
158
- }
159
- } else {
160
- //simple and parent-configurable set to 'Use Defaults'
161
- $attribs = $this->getDefaultTemandoAttributes();
162
- }
163
- } //attribs array could be empty if there's an error retrieving simple product from configurable
164
- //apply simple product weight to parent configurable
165
- if ($simple_product->getId()) {
166
- $item->setWeight($simple_product->getWeight());
167
- }
168
- } else {
169
- //assuming simple product here ... possible bug if other product type used
170
- if($product->getTemandoPackagingMode()) {
171
- //retrieval mode set to 'As Defined' => Retrieve attributes
172
- foreach($this->_temandoAttributes as $attribname) {
173
- $attribs[$attribname] = $product->getData($attribname);
174
- }
175
- } else {
176
- $attribs = $this->getDefaultTemandoAttributes();
177
- }
178
- }
179
- } else {
180
- //Request from within admin panel direct on product object
181
- if($product instanceof Mage_Catalog_Model_Product) {
182
- foreach($this->_temandoAttributes as $attribname) {
183
- $attribs[$attribname] = $product->getData($attribname);
184
- }
185
- }
186
- }
187
- return $attribs;
188
- }
189
-
190
- /**
191
- * Gets the date when a package will be ready to ship. Adjusts dates so
192
- * that they always fall on a weekday.
193
- *
194
- * @param <type> $ready_time timestamp for when the package will be ready
195
- * to ship, defaults to 10 days from current date
196
- */
197
- public function getReadyDate($ready_time = NULL)
198
- {
199
- if (is_null($ready_time)) {
200
- $ready_time = strtotime('+10 days');
201
- }
202
- if (is_numeric($ready_time) && $ready_time >= strtotime(date('Y-m-d'))) {
203
- $weekend_days = array('6', '7');
204
- while (in_array(date('N', $ready_time), $weekend_days)) {
205
- $ready_time = strtotime('+1 day', $ready_time);
206
- }
207
- return $ready_time;
208
- }
209
- }
210
-
211
- /**
212
- * Gets selected simple product from configurable
213
- * (using the fact that getSku() on item returns selected simple product sku)
214
- *
215
- * @param Mage_Sales_Model_Order_Item $item
216
- * @return Mage_Catalog_Model_Product
217
- */
218
- public function getSelectedSimpleProductFromConfigurable($item)
219
- {
220
- $simpleProductId = Mage::getModel('catalog/product')->getIdBySku($item->getSku());
221
- return Mage::getModel('catalog/product')->load($simpleProductId);
222
- }
223
-
224
- /**
225
- * Retrieve Default Temando Product Attributes from Configuration
226
- *
227
- * @return array
228
- */
229
- public function getDefaultTemandoAttributes()
230
- {
231
- return array(
232
- 'temando_packaging_mode' => 0, //defaults
233
- 'temando_packaging' => $this->getConfigData('defaults/packaging'),
234
- 'temando_fragile' => $this->getConfigData('defaults/fragile'),
235
- 'temando_dangerous' => $this->getConfigData('defaults/dangerous'),
236
- 'temando_length' => (float)$this->getConfigData('defaults/length'),
237
- 'temando_width' => (float)$this->getConfigData('defaults/width'),
238
- 'temando_height' => (float)$this->getConfigData('defaults/height'),
239
- );
240
- }
241
-
242
- /**
243
- * Converts given weight from configured unit to grams
244
- *
245
- * @param float $value Weight to convert
246
- * @param string $currentUnit Current weight unit
247
- * @return float Converted weight in grams
248
- */
249
- public function getWeightInGrams($value, $currentUnit = null)
250
- {
251
- $value = floatval($value);
252
- $currentUnit = $currentUnit ? $currentUnit : $this->getConfigData('units/weight');
253
- //from units as specified in configuration
254
- switch($currentUnit) {
255
- case Temando_Temando_Model_System_Config_Source_Unit_Weight::KILOGRAMS:
256
- return $value * 1000; break;
257
-
258
- case Temando_Temando_Model_System_Config_Source_Unit_Weight::OUNCES:
259
- return $value * 28.3495; break;
260
-
261
- case Temando_Temando_Model_System_Config_Source_Unit_Weight::POUNDS:
262
- return $value * 453.592; break;
263
-
264
- default: return $value; break;
265
- }
266
- }
267
-
268
- /**
269
- * Converts given distance from configured unit to centimetres
270
- *
271
- * @param float $value Distance to convert
272
- * @param string $currentUnit Current measure unit
273
- * @return float Converted distance in centimetres
274
- */
275
- public function getDistanceInCentimetres($value, $currentUnit = null)
276
- {
277
- $value = floatval($value);
278
- $currentUnit = $currentUnit ? $currentUnit : $this->getConfigData('units/measure');
279
- switch($currentUnit) {
280
- case Temando_Temando_Model_System_Config_Source_Unit_Measure::METRES:
281
- return $value * 100; break;
282
-
283
- case Temando_Temando_Model_System_Config_Source_Unit_Measure::FEET:
284
- return $value * 30.48; break;
285
-
286
- case Temando_Temando_Model_System_Config_Source_Unit_Measure::INCHES:
287
- return $value * 2.54; break;
288
-
289
- default: return $value; break;
290
- }
291
- }
292
-
293
- /**
294
- * Returns Client ID from system configuration
295
- *
296
- * @return string
297
- */
298
- public function getClientId()
299
- {
300
- return $this->getConfigData('general/client');
301
- }
302
-
303
- /**
304
- * Retrieves cached address validation results
305
- *
306
- * @param string $words
307
- * @return array of results or false if no cache
308
- */
309
- public function getSuggestionsCache($words)
310
- {
311
- if (is_file($this->getFileCacheByWords($words))) {
312
- return file_get_contents($this->getFileCacheByWords($words));
313
- }
314
-
315
- return false;
316
- }
317
-
318
- /**
319
- * Returns path to the cache file
320
- *
321
- * @param string $words
322
- * @return string
323
- */
324
- public function getFileCacheByWords($words)
325
- {
326
- $key = md5(strtolower(join('_', $words)));
327
- $path = Mage::getBaseDir('cache');
328
- return $path . DS . 'temando' . DS . $key[0] . DS . $key[1] . DS . $key . '.cache';
329
- }
330
-
331
- /**
332
- * Register cached results
333
- * (saves results into a cache file or removes file if results empty)
334
- *
335
- * @param string $words
336
- * @param string $value
337
- * @return void
338
- */
339
- public function setSuggestionsCache($words, $value)
340
- {
341
- if (strlen(join(' ', $words)) > 4) {
342
- return;
343
- }
344
-
345
- $file = $this->getFileCacheByWords($words);
346
- $dir = dirname($file);
347
- if (!is_dir($dir)) {
348
- mkdir($dir, 0777, true);
349
- }
350
-
351
- $fd = @fopen($file, 'w');
352
- if (!$fd) {
353
- return;
354
- }
355
-
356
- $size = fwrite($fd, $value);
357
- fclose($fd);
358
- if ($size != strlen($value)) {
359
- unlink($file);
360
- }
361
- }
362
-
363
- /**
364
- * Returns region name saved in customers session
365
- * @return string|null
366
- */
367
- public function getSessionRegion()
368
- {
369
- $data = Mage::getSingleton('customer/session')->getData('estimate_product_shipping');
370
- if ($data) {
371
- return Mage::getModel('directory/region')->load($data['region_id'])->getName();
372
- }
373
-
374
- return null;
375
- }
376
-
377
- /**
378
- * Returns city name saved in customers session
379
- * @return string|null
380
- */
381
- public function getSessionCity()
382
- {
383
- $data = Mage::getSingleton('customer/session')->getData('estimate_product_shipping');
384
- if ($data) {
385
- return $data['city'];
386
- }
387
-
388
- return null;
389
- }
390
-
391
- /**
392
- * Returns postal code saved in customers session
393
- * @return string|null
394
- */
395
- public function getSessionPostcode()
396
- {
397
- $data = Mage::getSingleton('customer/session')->getData('estimate_product_shipping');
398
- if ($data) {
399
- return $data['postcode'];
400
- }
401
-
402
- return null;
403
- }
404
-
405
- /**
406
- * Returns id of the region saved in customers session
407
- * @return int|null
408
- */
409
- public function getSessionRegionId()
410
- {
411
- $data = Mage::getSingleton('customer/session')->getData('estimate_product_shipping');
412
- if ($data) {
413
- return $data['region_id'];
414
- }
415
-
416
- return null;
417
- }
418
-
419
- /**
420
- * Return list of available origin locations
421
- *
422
- * @return array
423
- */
424
- public function getLocationList()
425
- {
426
- return array(
427
- self::DEFAULT_WAREHOUSE_NAME => self::DEFAULT_WAREHOUSE_NAME
428
- );
429
- }
430
-
431
- /**
432
- * Returns location create/update request array
433
- *
434
- * @return array
435
- */
436
- public function getOriginRequestArray(Varien_Object $data)
437
- {
438
- return array(
439
- 'description' => self::DEFAULT_WAREHOUSE_NAME,
440
- 'type' => 'Origin',
441
- 'contactName' => $data->getContactName(),
442
- 'companyName' => $data->getCompanyName(),
443
- 'street' => $data->getStreet(),
444
- 'suburb' => $data->getCity(),
445
- 'state' => $data->getRegion(),
446
- 'code' => $data->getPostcode(),
447
- 'country' => $data->getCountry(),
448
- 'phone1' => $data->getPhone1(),
449
- 'phone2' => $data->getPhone2(),
450
- 'fax' => $data->getFax(),
451
- 'email' => $data->getEmail(),
452
- 'loadingFacilities' => $data->getLoadingFacilities() ? 'Y' : 'N',
453
- 'forklift' => $data->getForklift() ? 'Y' : 'N',
454
- 'dock' => $data->getDock() ? 'Y' : 'N',
455
- 'limitedAccess' => $data->getLimitedAccess() ? 'Y' : 'N',
456
- 'postalBox' => $data->getPobox() ? 'Y' : 'N'
457
- );
458
- }
459
-
460
- /**
461
- * Returns true if street address is a PO Box
462
- *
463
- * @param string $street
464
- * @return boolean
465
- */
466
- public function isStreetWithPO($street)
467
- {
468
- if (!is_string($street)) {
469
- return false;
470
- }
471
-
472
- if (preg_match('/p[\. ]*o[\.]*\s*?box/', strtolower($street))) {
473
- return true;
474
- }
475
-
476
- $templates = array('PO Box', 'P.O. Box', 'P.O Box', 'PO. Box', 'p o box', 'Post Office', 'Locked Bag', 'Lock Bag', 'Private Bag');
477
- foreach ($templates as $t) {
478
- if (strpos(strtolower($street), strtolower($t)) !== false) {
479
- return true;
480
- }
481
- }
482
-
483
- return false;
484
- }
485
-
486
- /**
487
- * Returns true if shipping quote is dynamic quote obtained
488
- * from Temando API
489
- *
490
- * @param int $quote_id
491
- * @return boolean
492
- */
493
- public function isQuoteDynamic($quote_id)
494
- {
495
- $fixed_carriers = array(
496
- Temando_Temando_Model_Carrier::FLAT_RATE,
497
- Temando_Temando_Model_Carrier::FREE,
498
- );
499
-
500
- if (in_array($quote_id, $fixed_carriers)) {
501
- return false;
502
- }
503
-
504
- return true;
505
- }
506
-
507
- /**
508
- * Creates a sales quote based on current ship request
509
- *
510
- * @param Mage_Shipping_Model_Rate_Request $request
511
- * @return Mage_Sales_Model_Quote
512
- */
513
- public function getDummySalesQuoteFromRequest(Mage_Shipping_Model_Rate_Request $request)
514
- {
515
- $quote = Mage::getModel('sales/quote');
516
- /* @var $quote Mage_Sales_Model_Quote */
517
- $address = Mage::getModel('sales/quote_address');
518
- /* @var $address Mage_Sales_Model_Quote_Address */
519
- $address->setCity($request->getDestCity())
520
- ->setPostcode($request->getDestPostcode())
521
- ->setCountryId($request->getDestCountryId())
522
- ->setStreet($request->getDestStreet())
523
- ->setRegion($request->getDestRegionCode())
524
- ->setRegionId($request->getDestRegionId());
525
- $quote->addShippingAddress($address);
526
- foreach($request->getAllItems() as $item) {
527
- $quote->addItem($item);
528
- }
529
- $quote->setId(100000000 + mt_rand(0, 100000));
530
- $quote->collectTotals();
531
- return $quote;
532
- }
533
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Temando Helper Data
4
+ *
5
+ * @package Temando_Temando
6
+ * @author Temando Magento Team <marketing@temando.com>
7
+ */
8
+ class Temando_Temando_Helper_Data extends Mage_Core_Helper_Abstract {
9
+
10
+ const DEFAULT_WAREHOUSE_NAME = 'Magento Warehouse';
11
+
12
+ const DEFAULT_CURRENCY_CODE = 'AUD';
13
+
14
+ const DEFAULT_COUNTRY_ID = 'AU';
15
+
16
+ private $_temandoAttributes = array(
17
+ 'temando_packaging_mode',
18
+ 'temando_packaging',
19
+ 'temando_fragile',
20
+ 'temando_dangerous',
21
+ 'temando_length',
22
+ 'temando_width',
23
+ 'temando_height'
24
+ );
25
+
26
+ /**
27
+ * Returns default weight unit
28
+ */
29
+ public function getDefaultWeightUnit()
30
+ {
31
+ return Temando_Temando_Model_System_Config_Source_Unit_Weight::KILOGRAMS;
32
+ }
33
+
34
+ /**
35
+ * Returns default distance unit
36
+ */
37
+ public function getDefaultDistanceUnit()
38
+ {
39
+ return Temando_Temando_Model_System_Config_Source_Unit_Measure::CENTIMETRES;
40
+ }
41
+
42
+ /**
43
+ * Returns default currency code
44
+ */
45
+ public function getDefaultCurrencyCode()
46
+ {
47
+ return self::DEFAULT_CURRENCY_CODE;
48
+ }
49
+
50
+ /**
51
+ * Returns default country id
52
+ */
53
+ public function getDefaultCountryId()
54
+ {
55
+ return self::DEFAULT_COUNTRY_ID;
56
+ }
57
+
58
+
59
+ /**
60
+ * Retrieves an element from the module configuration data.
61
+ *
62
+ * @param string $field
63
+ */
64
+ public function getConfigData($field)
65
+ {
66
+ $path = 'temando/' . $field;
67
+ return Mage::getStoreConfig($path);
68
+ }
69
+
70
+ /**
71
+ * Returns an array of all Magento countries
72
+ *
73
+ * @return array
74
+ */
75
+ public function getAllCountries()
76
+ {
77
+ $countries = array();
78
+ $countryCollection = Mage::getModel('directory/country')->getCollection();
79
+ foreach ($countryCollection as $country) {
80
+ /* @var $country Mage_Directory_Model_Country */
81
+ $countries[$country->getId()] = $country->getName();
82
+ }
83
+ return $countries;
84
+ }
85
+
86
+ /**
87
+ * Returns array of allowed countries based on Magento system configuration
88
+ * and Temando plugin allowed countries.
89
+ *
90
+ * @param boolean $asJson
91
+ * @return array
92
+ */
93
+ public function getAllowedCountries($asJson = false)
94
+ {
95
+ $specific = Mage::getStoreConfig('carriers/temando/sallowspecific');
96
+ //check if all allowed and return selected
97
+ if ($specific == 1) {
98
+ $availableCountries = explode(',', Mage::getStoreConfig('carriers/temando/specificcountry'));
99
+ $countries = array_intersect_key($this->getAllCountries(), array_flip($availableCountries));
100
+ if ($asJson) {
101
+ return Mage::helper('core')->jsonEncode($countries);
102
+ } else {
103
+ return $countries;
104
+ }
105
+ }
106
+ //return all allowed
107
+ $availableCountries = explode(',', Mage::getStoreConfig('general/country/allow'));
108
+ $countries = array_intersect_key($this->getAllCountries(), array_flip($availableCountries));
109
+ if ($asJson) {
110
+ return Mage::helper('core')->jsonEncode($countries);
111
+ } else {
112
+ return $countries;
113
+ }
114
+ }
115
+
116
+ /**
117
+ * Applies Temando attributes to sales quote item object
118
+ *
119
+ * @param Mage_Sales_Model_Order_Item $item
120
+ */
121
+ public function applyTemandoParamsToItem($item)
122
+ {
123
+ $attribs = $this->getTemandoProductAttributes($item);
124
+ foreach ($attribs as $key => $val) {
125
+ $item->setData($key, $val);
126
+ }
127
+ }
128
+
129
+ /**
130
+ * Returns values for Temando specific product attributes. Currently handles simple
131
+ * and configurable products only. Default attribute values from configuration are
132
+ * returned if product temando retrieval mode is set to 'Use Defaults'
133
+ *
134
+ * @param Mage_Sales_Model_Order_Item $item
135
+ * @param Mage_Catalog_Model_Product $product
136
+ * @return array Temando specific product attributes
137
+ */
138
+ public function getTemandoProductAttributes($item = null, $product = null)
139
+ {
140
+ $attribs = array();
141
+ if ($item) {
142
+ //Mage_Sales_Model_Order_Item = need to check if configurable
143
+ $product = Mage::getModel('catalog/product')->load($item->getProductId());
144
+ if ($product->isConfigurable()) {
145
+ //configurable product - get selected simple product
146
+ $simple_product = $this->getSelectedSimpleProductFromConfigurable($item);
147
+ if ($simple_product->getId() && $simple_product->getTemandoPackagingMode()) {
148
+ //simple product found and retrieval mode is set to 'As Defined' => Retrieve attributes
149
+ foreach ($this->_temandoAttributes as $attribname) {
150
+ $attribs[$attribname] = $simple_product->getData($attribname);
151
+ }
152
+ } elseif ($simple_product->getId() && !$simple_product->getTemandoPackagingMode()) {
153
+ //simple product found and retrieval mode set to 'Use Defaults'
154
+ //try to take from configurable parent product before looking at defaults
155
+ if ($product->getTemandoPackagingMode()) {
156
+ foreach ($this->_temandoAttributes as $attribname) {
157
+ $attribs[$attribname] = $product->getData($attribname);
158
+ }
159
+ } else {
160
+ //simple and parent-configurable set to 'Use Defaults'
161
+ $attribs = $this->getDefaultTemandoAttributes();
162
+ }
163
+ } //attribs array could be empty if there's an error retrieving simple product from configurable
164
+ //apply simple product weight to parent configurable
165
+ if ($simple_product->getId()) {
166
+ $item->setWeight($simple_product->getWeight());
167
+ }
168
+ } else {
169
+ //assuming simple product here ... possible bug if other product type used
170
+ if ($product->getTemandoPackagingMode()) {
171
+ //retrieval mode set to 'As Defined' => Retrieve attributes
172
+ foreach ($this->_temandoAttributes as $attribname) {
173
+ $attribs[$attribname] = $product->getData($attribname);
174
+ }
175
+ } else {
176
+ $attribs = $this->getDefaultTemandoAttributes();
177
+ }
178
+ }
179
+ } else {
180
+ //Request from within admin panel direct on product object
181
+ if ($product instanceof Mage_Catalog_Model_Product) {
182
+ foreach ($this->_temandoAttributes as $attribname) {
183
+ $attribs[$attribname] = $product->getData($attribname);
184
+ }
185
+ }
186
+ }
187
+ return $attribs;
188
+ }
189
+
190
+ /**
191
+ * Gets the date when a package will be ready to ship. Adjusts dates so
192
+ * that they always fall on a weekday.
193
+ *
194
+ * @param <type> $ready_time timestamp for when the package will be ready
195
+ * to ship, defaults to 10 days from current date
196
+ */
197
+ public function getReadyDate($ready_time = null)
198
+ {
199
+ if (is_null($ready_time)) {
200
+ $ready_time = strtotime('+10 days');
201
+ }
202
+ if (is_numeric($ready_time) && $ready_time >= strtotime(date('Y-m-d'))) {
203
+ $weekend_days = array('6', '7');
204
+ while (in_array(date('N', $ready_time), $weekend_days)) {
205
+ $ready_time = strtotime('+1 day', $ready_time);
206
+ }
207
+ return $ready_time;
208
+ }
209
+ }
210
+
211
+ /**
212
+ * Gets selected simple product from configurable
213
+ * (using the fact that getSku() on item returns selected simple product sku)
214
+ *
215
+ * @param Mage_Sales_Model_Order_Item $item
216
+ * @return Mage_Catalog_Model_Product
217
+ */
218
+ public function getSelectedSimpleProductFromConfigurable($item)
219
+ {
220
+ $simpleProductId = Mage::getModel('catalog/product')->getIdBySku($item->getSku());
221
+ return Mage::getModel('catalog/product')->load($simpleProductId);
222
+ }
223
+
224
+ /**
225
+ * Retrieve Default Temando Product Attributes from Configuration
226
+ *
227
+ * @return array
228
+ */
229
+ public function getDefaultTemandoAttributes()
230
+ {
231
+ return array(
232
+ 'temando_packaging_mode' => 0, //defaults
233
+ 'temando_packaging' => $this->getConfigData('defaults/packaging'),
234
+ 'temando_fragile' => $this->getConfigData('defaults/fragile'),
235
+ 'temando_dangerous' => $this->getConfigData('defaults/dangerous'),
236
+ 'temando_length' => (float)$this->getConfigData('defaults/length'),
237
+ 'temando_width' => (float)$this->getConfigData('defaults/width'),
238
+ 'temando_height' => (float)$this->getConfigData('defaults/height'),
239
+ );
240
+ }
241
+
242
+ /**
243
+ * Converts given weight from configured unit to grams
244
+ *
245
+ * @param float $value Weight to convert
246
+ * @param string $currentUnit Current weight unit
247
+ * @return float Converted weight in grams
248
+ */
249
+ public function getWeightInGrams($value, $currentUnit = null)
250
+ {
251
+ $value = floatval($value);
252
+ $currentUnit = $currentUnit ? $currentUnit : $this->getConfigData('units/weight');
253
+ //from units as specified in configuration
254
+ switch($currentUnit) {
255
+ case Temando_Temando_Model_System_Config_Source_Unit_Weight::KILOGRAMS:
256
+ return $value * 1000;
257
+ break;
258
+
259
+ case Temando_Temando_Model_System_Config_Source_Unit_Weight::OUNCES:
260
+ return $value * 28.3495;
261
+ break;
262
+
263
+ case Temando_Temando_Model_System_Config_Source_Unit_Weight::POUNDS:
264
+ return $value * 453.592;
265
+ break;
266
+
267
+ default:
268
+ return $value;
269
+ break;
270
+ }
271
+ }
272
+
273
+ /**
274
+ * Converts given distance from configured unit to centimetres
275
+ *
276
+ * @param float $value Distance to convert
277
+ * @param string $currentUnit Current measure unit
278
+ * @return float Converted distance in centimetres
279
+ */
280
+ public function getDistanceInCentimetres($value, $currentUnit = null)
281
+ {
282
+ $value = floatval($value);
283
+ $currentUnit = $currentUnit ? $currentUnit : $this->getConfigData('units/measure');
284
+ switch($currentUnit) {
285
+ case Temando_Temando_Model_System_Config_Source_Unit_Measure::METRES:
286
+ return $value * 100;
287
+ break;
288
+
289
+ case Temando_Temando_Model_System_Config_Source_Unit_Measure::FEET:
290
+ return $value * 30.48;
291
+ break;
292
+
293
+ case Temando_Temando_Model_System_Config_Source_Unit_Measure::INCHES:
294
+ return $value * 2.54;
295
+ break;
296
+
297
+ default:
298
+ return $value;
299
+ break;
300
+ }
301
+ }
302
+
303
+ /**
304
+ * Returns Client ID from system configuration
305
+ *
306
+ * @return string
307
+ */
308
+ public function getClientId()
309
+ {
310
+ return $this->getConfigData('general/client');
311
+ }
312
+
313
+ /**
314
+ * Retrieves cached address validation results
315
+ *
316
+ * @param string $words
317
+ * @return array of results or false if no cache
318
+ */
319
+ public function getSuggestionsCache($words)
320
+ {
321
+ if (is_file($this->getFileCacheByWords($words))) {
322
+ return file_get_contents($this->getFileCacheByWords($words));
323
+ }
324
+
325
+ return false;
326
+ }
327
+
328
+ /**
329
+ * Returns path to the cache file
330
+ *
331
+ * @param string $words
332
+ * @return string
333
+ */
334
+ public function getFileCacheByWords($words)
335
+ {
336
+ $key = md5(strtolower(join('_', $words)));
337
+ $path = Mage::getBaseDir('cache');
338
+ return $path . DS . 'temando' . DS . $key[0] . DS . $key[1] . DS . $key . '.cache';
339
+ }
340
+
341
+ /**
342
+ * Register cached results
343
+ * (saves results into a cache file or removes file if results empty)
344
+ *
345
+ * @param string $words
346
+ * @param string $value
347
+ * @return void
348
+ */
349
+ public function setSuggestionsCache($words, $value)
350
+ {
351
+ if (strlen(join(' ', $words)) > 4) {
352
+ return;
353
+ }
354
+
355
+ $file = $this->getFileCacheByWords($words);
356
+ $dir = dirname($file);
357
+ if (!is_dir($dir)) {
358
+ mkdir($dir, 0777, true);
359
+ }
360
+
361
+ $fd = @fopen($file, 'w');
362
+ if (!$fd) {
363
+ return;
364
+ }
365
+
366
+ $size = fwrite($fd, $value);
367
+ fclose($fd);
368
+ if ($size != strlen($value)) {
369
+ unlink($file);
370
+ }
371
+ }
372
+
373
+ /**
374
+ * Returns region name saved in customers session
375
+ * @return string|null
376
+ */
377
+ public function getSessionRegion()
378
+ {
379
+ $data = Mage::getSingleton('customer/session')->getData('estimate_product_shipping');
380
+ if ($data) {
381
+ return Mage::getModel('directory/region')->load($data['region_id'])->getName();
382
+ }
383
+
384
+ return null;
385
+ }
386
+
387
+ /**
388
+ * Returns city name saved in customers session
389
+ * @return string|null
390
+ */
391
+ public function getSessionCity()
392
+ {
393
+ $data = Mage::getSingleton('customer/session')->getData('estimate_product_shipping');
394
+ if ($data) {
395
+ return $data['city'];
396
+ }
397
+
398
+ return null;
399
+ }
400
+
401
+ /**
402
+ * Returns postal code saved in customers session
403
+ * @return string|null
404
+ */
405
+ public function getSessionPostcode()
406
+ {
407
+ $data = Mage::getSingleton('customer/session')->getData('estimate_product_shipping');
408
+ if ($data) {
409
+ return $data['postcode'];
410
+ }
411
+
412
+ return null;
413
+ }
414
+
415
+ /**
416
+ * Returns id of the region saved in customers session
417
+ * @return int|null
418
+ */
419
+ public function getSessionRegionId()
420
+ {
421
+ $data = Mage::getSingleton('customer/session')->getData('estimate_product_shipping');
422
+ if ($data) {
423
+ return $data['region_id'];
424
+ }
425
+
426
+ return null;
427
+ }
428
+
429
+ /**
430
+ * Return list of available origin locations
431
+ *
432
+ * @return array
433
+ */
434
+ public function getLocationList()
435
+ {
436
+ return array(
437
+ self::DEFAULT_WAREHOUSE_NAME => self::DEFAULT_WAREHOUSE_NAME
438
+ );
439
+ }
440
+
441
+ /**
442
+ * Returns location create/update request array
443
+ *
444
+ * @return array
445
+ */
446
+ public function getOriginRequestArray(Varien_Object $data)
447
+ {
448
+ return array(
449
+ 'description' => self::DEFAULT_WAREHOUSE_NAME,
450
+ 'type' => 'Origin',
451
+ 'contactName' => $data->getContactName(),
452
+ 'companyName' => $data->getCompanyName(),
453
+ 'street' => $data->getStreet(),
454
+ 'suburb' => $data->getCity(),
455
+ 'state' => $data->getRegion(),
456
+ 'code' => $data->getPostcode(),
457
+ 'country' => $data->getCountry(),
458
+ 'phone1' => $data->getPhone1(),
459
+ 'phone2' => $data->getPhone2(),
460
+ 'fax' => $data->getFax(),
461
+ 'email' => $data->getEmail(),
462
+ 'loadingFacilities' => $data->getLoadingFacilities() ? 'Y' : 'N',
463
+ 'forklift' => $data->getForklift() ? 'Y' : 'N',
464
+ 'dock' => $data->getDock() ? 'Y' : 'N',
465
+ 'limitedAccess' => $data->getLimitedAccess() ? 'Y' : 'N',
466
+ 'postalBox' => $data->getPobox() ? 'Y' : 'N'
467
+ );
468
+ }
469
+
470
+ /**
471
+ * Returns true if street address is a PO Box
472
+ *
473
+ * @param string $street
474
+ * @return boolean
475
+ */
476
+ public function isStreetWithPO($street)
477
+ {
478
+ if (!is_string($street)) {
479
+ return false;
480
+ }
481
+
482
+ if (preg_match('/p[\. ]*o[\.]*\s*?box/', strtolower($street))) {
483
+ return true;
484
+ }
485
+
486
+ $templates = array(
487
+ 'PO Box', 'P.O. Box', 'P.O Box', 'PO. Box', 'p o box',
488
+ 'Post Office', 'Locked Bag', 'Lock Bag', 'Private Bag'
489
+ );
490
+ foreach ($templates as $t) {
491
+ if (strpos(strtolower($street), strtolower($t)) !== false) {
492
+ return true;
493
+ }
494
+ }
495
+
496
+ return false;
497
+ }
498
+
499
+ /**
500
+ * Returns true if shipping quote is dynamic quote obtained
501
+ * from Temando API
502
+ *
503
+ * @param int $quote_id
504
+ * @return boolean
505
+ */
506
+ public function isQuoteDynamic($quote_id)
507
+ {
508
+ $fixed_carriers = array(
509
+ Temando_Temando_Model_Carrier::FLAT_RATE,
510
+ Temando_Temando_Model_Carrier::FREE,
511
+ );
512
+
513
+ if (in_array($quote_id, $fixed_carriers)) {
514
+ return false;
515
+ }
516
+
517
+ return true;
518
+ }
519
+
520
+ /**
521
+ * Creates a sales quote based on current ship request
522
+ *
523
+ * @param Mage_Shipping_Model_Rate_Request $request
524
+ * @return Mage_Sales_Model_Quote
525
+ */
526
+ public function getDummySalesQuoteFromRequest(Mage_Shipping_Model_Rate_Request $request)
527
+ {
528
+ $quote = Mage::getModel('sales/quote');
529
+ /* @var $quote Mage_Sales_Model_Quote */
530
+ $address = Mage::getModel('sales/quote_address');
531
+ /* @var $address Mage_Sales_Model_Quote_Address */
532
+ $address->setCity($request->getDestCity())
533
+ ->setPostcode($request->getDestPostcode())
534
+ ->setCountryId($request->getDestCountryId())
535
+ ->setStreet($request->getDestStreet())
536
+ ->setRegion($request->getDestRegionCode())
537
+ ->setRegionId($request->getDestRegionId());
538
+ $quote->addShippingAddress($address);
539
+ foreach ($request->getAllItems() as $item) {
540
+ $quote->addItem($item);
541
+ }
542
+ $quote->setId(100000000 + mt_rand(0, 100000));
543
+ $quote->collectTotals();
544
+ return $quote;
545
+ }
546
+
547
+ /**
548
+ * Return currency code from current store or default
549
+ *
550
+ * @return string
551
+ */
552
+ public function getCurrencyCode()
553
+ {
554
+ $curr = Mage::app()->getStore()->getCurrentCurrencyCode();
555
+
556
+ if (strlen($curr)) {
557
+ return $curr;
558
+ }
559
+
560
+ return self::DEFAULT_CURRENCY_CODE;
561
+ }
562
+
563
+ /**
564
+ * Get default origin data to be used with default origin setup
565
+ *
566
+ * @param string $countryCode
567
+ * @return array
568
+ */
569
+ public function getDefaultOriginData($countryCode)
570
+ {
571
+ switch ($countryCode) {
572
+ case 'US':
573
+ $warehouseData = array(
574
+ 'street' => '8852 West Sunset Boulevard',
575
+ 'city' => 'WEST HOLLYWOOD',
576
+ 'postcode' => '90069',
577
+ 'country' => $countryCode,
578
+ 'region' => 'CA',
579
+ 'phone1' => '3101234567',
580
+ );
581
+ break;
582
+ case 'GB':
583
+ $warehouseData = array(
584
+ 'street' => '188 Kirtling St',
585
+ 'city' => 'LONDON',
586
+ 'postcode' => 'SW8 5BN',
587
+ 'country' => $countryCode,
588
+ 'region' => '',
589
+ 'phone1' => '442075010123',
590
+ );
591
+ break;
592
+ case 'FR':
593
+ $warehouseData = array(
594
+ 'street' => '82 Boulevard de Clichy',
595
+ 'city' => 'PARIS',
596
+ 'postcode' => '75018',
597
+ 'country' => $countryCode,
598
+ 'region' => '',
599
+ 'phone1' => '33153091234',
600
+ );
601
+ break;
602
+ default:
603
+ $warehouseData = array(
604
+ 'street' => 'Level 4, 140 William Street',
605
+ 'city' => 'WOOLLOOMOOLOO',
606
+ 'postcode' => '2011',
607
+ 'country' => 'AU',
608
+ 'region' => 'NSW',
609
+ 'phone1' => '02 1234 5678',
610
+ );
611
+ break;
612
+ }
613
+ return $warehouseData;
614
+ }
615
+ }
app/code/community/Temando/Temando/Helper/Functions.php CHANGED
@@ -1,76 +1,77 @@
1
- <?php
2
- /**
3
- * Temando Helper Functions
4
- *
5
- * @package Temando_Temando
6
- * @author Temando Magento Team <marketing@temando.com>
7
- */
8
- class Temando_Temando_Helper_Functions extends Mage_Core_Helper_Abstract
9
- {
10
-
11
- public function getFastestQuote($quotes)
12
- {
13
- $fastest = null;
14
- foreach ($quotes as $quote) {
15
- $fastest = $this->_getFaster($quote, $fastest);
16
- }
17
- return $fastest;
18
- }
19
-
20
- protected function _getFaster($a, $b)
21
- {
22
- // if one is null, return the other.
23
- if (is_null($a)) {
24
- return $b;
25
- }
26
- if (is_null($b)) {
27
- return $a;
28
- }
29
-
30
- // average ETA
31
- $a_eta = ($a->getEtaFrom() + $a->getEtaTo()) / 2;
32
- $b_eta = ($b->getEtaFrom() + $b->getEtaTo()) / 2;
33
-
34
- if ($a_eta != $b_eta) {
35
- // different speed, return faster
36
- return $a_eta <= $b_eta ? $a : $b;
37
- } else {
38
- // same speed, return cheaper
39
- return self::_getCheaper($a, $b);
40
- }
41
- }
42
-
43
- public function getCheapestQuote($quotes)
44
- {
45
- $cheapest = null;
46
- foreach ($quotes as $quote) {
47
- $cheapest = $this->_getCheaper($quote, $cheapest);
48
- }
49
- return $cheapest;
50
- }
51
-
52
- protected function _getCheaper($a, $b)
53
- {
54
- // if one is null, return the other (if both are null, null is returned).
55
- if (is_null($a)) {
56
- return $b;
57
- }
58
- if (is_null($b)) {
59
- return $a;
60
- }
61
-
62
- return $a->getTotalPrice() <= $b->getTotalPrice() ? $a : $b;
63
- }
64
-
65
- public function getCheapestAndFastestQuotes($quotes)
66
- {
67
- $cheapest = $this->getCheapestQuote($quotes);
68
- $fastest = $this->getFastestQuote($quotes);
69
-
70
- if($cheapest->getId() === $fastest->getId())
71
- return array($cheapest);
72
-
73
- return array($cheapest, $fastest);
74
- }
75
-
76
- }
 
1
+ <?php
2
+ /**
3
+ * Temando Helper Functions
4
+ *
5
+ * @package Temando_Temando
6
+ * @author Temando Magento Team <marketing@temando.com>
7
+ */
8
+ class Temando_Temando_Helper_Functions extends Mage_Core_Helper_Abstract
9
+ {
10
+
11
+ public function getFastestQuote($quotes)
12
+ {
13
+ $fastest = null;
14
+ foreach ($quotes as $quote) {
15
+ $fastest = $this->_getFaster($quote, $fastest);
16
+ }
17
+ return $fastest;
18
+ }
19
+
20
+ protected function _getFaster($a, $b)
21
+ {
22
+ // if one is null, return the other.
23
+ if (is_null($a)) {
24
+ return $b;
25
+ }
26
+ if (is_null($b)) {
27
+ return $a;
28
+ }
29
+
30
+ // average ETA
31
+ $a_eta = ($a->getEtaFrom() + $a->getEtaTo()) / 2;
32
+ $b_eta = ($b->getEtaFrom() + $b->getEtaTo()) / 2;
33
+
34
+ if ($a_eta != $b_eta) {
35
+ // different speed, return faster
36
+ return $a_eta <= $b_eta ? $a : $b;
37
+ } else {
38
+ // same speed, return cheaper
39
+ return self::_getCheaper($a, $b);
40
+ }
41
+ }
42
+
43
+ public function getCheapestQuote($quotes)
44
+ {
45
+ $cheapest = null;
46
+ foreach ($quotes as $quote) {
47
+ $cheapest = $this->_getCheaper($quote, $cheapest);
48
+ }
49
+ return $cheapest;
50
+ }
51
+
52
+ protected function _getCheaper($a, $b)
53
+ {
54
+ // if one is null, return the other (if both are null, null is returned).
55
+ if (is_null($a)) {
56
+ return $b;
57
+ }
58
+ if (is_null($b)) {
59
+ return $a;
60
+ }
61
+
62
+ return $a->getTotalPrice() <= $b->getTotalPrice() ? $a : $b;
63
+ }
64
+
65
+ public function getCheapestAndFastestQuotes($quotes)
66
+ {
67
+ $cheapest = $this->getCheapestQuote($quotes);
68
+ $fastest = $this->getFastestQuote($quotes);
69
+
70
+ if ($cheapest->getId() === $fastest->getId()) {
71
+ return array($cheapest);
72
+ }
73
+
74
+ return array($cheapest, $fastest);
75
+ }
76
+
77
+ }
app/code/community/Temando/Temando/Helper/Wizard.php CHANGED
@@ -1,52 +1,52 @@
1
- <?php
2
- /**
3
- * Temando Helper Wizard
4
- *
5
- * @package Temando_Temando
6
- * @author Temando Magento Team <marketing@temando.com>
7
- */
8
- class Temando_Temando_Helper_Wizard extends Mage_Directory_Helper_Data {
9
-
10
- /**
11
- * Retrieve regions data json
12
- *
13
- * @return string
14
- */
15
- public function getRegionJson()
16
- {
17
-
18
- if (true/* empty($json) */) {
19
- $countryIds = array();
20
- foreach ($this->getCountryCollection() as $country) {
21
- $countryIds[] = $country->getCountryId();
22
- }
23
- $collection = Mage::getModel('directory/region')->getResourceCollection()
24
- //->addCountryFilter($countryIds)
25
- ->load();
26
- $regions = array(
27
- 'config' => array(
28
- 'show_all_regions' => $this->getShowNonRequiredState(),
29
- 'regions_required' => $this->getCountriesWithStatesRequired()
30
- )
31
- );
32
- foreach ($collection as $region) {
33
- if (!$region->getRegionId()) {
34
- continue;
35
- }
36
- $regions[$region->getCountryId()][strtoupper($region->getCode())] = array(
37
- 'code' => $this->__($region->getCode()),
38
- 'name' => $this->__($region->getName())
39
- );
40
- }
41
- if (count($regions) > 0) {
42
- array_unshift($regions, array(
43
- 'code' => '',
44
- 'name' => Mage::helper('temando')->__('-- Please select --')
45
- ));
46
- }
47
- $json = Mage::helper('core')->jsonEncode($regions);
48
- }
49
-
50
- return $json;
51
- }
52
- }
1
+ <?php
2
+ /**
3
+ * Temando Helper Wizard
4
+ *
5
+ * @package Temando_Temando
6
+ * @author Temando Magento Team <marketing@temando.com>
7
+ */
8
+ class Temando_Temando_Helper_Wizard extends Mage_Directory_Helper_Data {
9
+
10
+ /**
11
+ * Retrieve regions data json
12
+ *
13
+ * @return string
14
+ */
15
+ public function getRegionJson()
16
+ {
17
+
18
+ if (true/* empty($json) */) {
19
+ $countryIds = array();
20
+ foreach ($this->getCountryCollection() as $country) {
21
+ $countryIds[] = $country->getCountryId();
22
+ }
23
+ $collection = Mage::getModel('directory/region')->getResourceCollection()
24
+ //->addCountryFilter($countryIds)
25
+ ->load();
26
+ $regions = array(
27
+ 'config' => array(
28
+ 'show_all_regions' => $this->getShowNonRequiredState(),
29
+ 'regions_required' => $this->getCountriesWithStatesRequired()
30
+ )
31
+ );
32
+ foreach ($collection as $region) {
33
+ if (!$region->getRegionId()) {
34
+ continue;
35
+ }
36
+ $regions[$region->getCountryId()][strtoupper($region->getCode())] = array(
37
+ 'code' => $this->__($region->getCode()),
38
+ 'name' => $this->__($region->getName())
39
+ );
40
+ }
41
+ if (count($regions) > 0) {
42
+ array_unshift($regions, array(
43
+ 'code' => '',
44
+ 'name' => Mage::helper('temando')->__('-- Please select --')
45
+ ));
46
+ }
47
+ $json = Mage::helper('core')->jsonEncode($regions);
48
+ }
49
+
50
+ return $json;
51
+ }
52
+ }
app/code/community/Temando/Temando/Model/Api/Client.php CHANGED
@@ -1,299 +1,312 @@
1
- <?php
2
- /**
3
- * Debugging SoapClient
4
- * Logs request and response in var/log
5
- *
6
- * @package Temando_Temando
7
- * @author Temando Magento Team <marketing@temando.com>
8
- */
9
- class DebugSoapClient extends SoapClient
10
- {
11
-
12
- public function __doRequest($request, $location, $action, $version, $one_way = 0)
13
- {
14
- Mage::log($request, null, 'raw-request.xml', true);
15
- $response = parent::__doRequest($request, $location, $action, $version, $one_way);
16
- Mage::log($response, null, 'raw-response.xml', true);
17
- return $response;
18
- }
19
- }
20
-
21
- /**
22
- * Api Client
23
- *
24
- * @package Temando_Temando
25
- * @author Temando Magento Team <marketing@temando.com>
26
- */
27
- class Temando_Temando_Model_Api_Client extends Mage_Core_Model_Abstract
28
- {
29
-
30
- const NO_SHIP_DATE = 'Unable to send on the specified date and/or location.';
31
-
32
- protected $temandoApiSandbox = 'https://api-demo.temando.com/schema/2009_06/server.wsdl';
33
- protected $temandoApi = 'https://api.temando.com/schema/2009_06/server.wsdl';
34
-
35
- protected $_client = null;
36
- protected $_is_sand = null;
37
-
38
- public function __construct()
39
- {
40
- parent::__construct();
41
- }
42
-
43
- public function connect($username = null, $password = null, $sandbox = false)
44
- {
45
- $this->_is_sand = $sandbox;
46
- if ($sandbox) {
47
- $url = $this->temandoApiSandbox;
48
- } else {
49
- $url = $this->temandoApi;
50
- }
51
-
52
- if (!$username) {
53
- $username = Mage::helper('temando')->getConfigData('general/username');
54
- }
55
- if (!$password) {
56
- $password = Mage::helper('temando')->getConfigData('general/password');
57
- }
58
-
59
- // The WSDL cache should be set to on to prevent the WSDL being loaded everytime.
60
- ini_set("soap.wsdl_cache_enabled", "1");
61
-
62
- // Create a new SoapClient referencing the Temando WSDL file.
63
- $this->_client = new SoapClient($url, array('soap_version' => SOAP_1_2, 'trace' => TRUE, 'exceptions' => FALSE));
64
-
65
- // Define the security string that wraps your login details. Due to limitations
66
- // with the PHP language this header information can only be provided via a string.
67
- $headerSecurityStr = "<Security><UsernameToken><Username>" . htmlentities($username) . "</Username>" .
68
- "<Password>" . htmlentities($password) . "</Password></UsernameToken></Security>";
69
-
70
- // Create a new SoapVar using the header security string.
71
- $headerSecurityVar = new SoapVar($headerSecurityStr, XSD_ANYXML);
72
-
73
- // Create a new SoapHeader containing all your login details.
74
- $soapHeader = new SoapHeader('wsse:http://schemas.xmlsoap.org/ws/2002/04/secext', 'soapenv:Header', $headerSecurityVar);
75
-
76
- // Add the SoapHeader to your SoapClient.
77
- $this->_client->__setSoapHeaders(array($soapHeader));
78
-
79
- return $this;
80
- }
81
-
82
- /**
83
- * Gets quotes for a delivery.
84
- *
85
- * @param array $request the request parameters, in an array format.
86
- * @return array
87
- */
88
- public function getQuotesByRequest($request)
89
- {
90
- return $this->getQuotes($request);
91
- }
92
-
93
- public function getQuotes($request)
94
- {
95
- if (!$this->_client) {
96
- return false;
97
- }
98
-
99
- if (!$this->_is_sand) {
100
- $request['clientId'] = Mage::helper('temando')->getClientId();
101
- }
102
-
103
- $response = $this->_client->getQuotes($request);
104
- //check for no ship days - public holidays - and retry with date +1 (up to +10) days before exiting
105
- $i = 0;
106
- if (isset($request['anytime']['readyDate'])) {
107
- while(is_soap_fault($response) && $response->faultstring == self::NO_SHIP_DATE && ++$i <= 10)
108
- {
109
- $readyDate = strtotime($request['anytime']['readyDate']);
110
- while (in_array(date('N', $readyDate), array(6, 7))) {
111
- $readyDate = strtotime('+1 day', $readyDate);
112
- }
113
- $request['anytime']['readyDate'] = date('Y-m-d', strtotime('+1 day', $readyDate));
114
- $response = $this->_client->getQuotes($request);
115
- }
116
- }
117
- if (is_soap_fault($response)) {
118
- throw new Exception($response->faultstring);
119
- }
120
- //make sure we have an array
121
- if (!isset($response->quotes->quote)) {
122
- $response->quotes->quote = array();
123
- } else if (isset($response->quotes->quote) && !is_array($response->quotes->quote)) {
124
- $response->quotes->quote = array(0 => $response->quotes->quote);
125
- }
126
-
127
- $quotes = array();
128
- foreach ($response->quotes->quote as $quoteData) {
129
- $quotes[] = Mage::getModel('temando/quote')->loadResponse($quoteData);
130
- }
131
-
132
- return $quotes;
133
- }
134
-
135
- public function makeBookingByRequest($request)
136
- {
137
- return $this->makeBooking($request);
138
- }
139
-
140
- public function makeBooking($request)
141
- {
142
- if (!$this->_is_sand) {
143
- $request['clientId'] = Mage::helper('temando')->getClientId();
144
- }
145
- if (!$this->_client) {
146
- return false;
147
- }
148
-
149
- $response = $this->_client->makeBooking($request);
150
- if (is_soap_fault($response)) {
151
- throw new Exception($response->faultstring);
152
- }
153
- return $response;
154
- }
155
-
156
- public function getRequest($request)
157
- {
158
- if (!$this->_client) {
159
- return false;
160
- }
161
-
162
- $response = $this->_client->getRequest($request);
163
- if (is_soap_fault($response)) {
164
- throw new Exception($response->faultstring);
165
- }
166
- return $response;
167
- }
168
-
169
- public function confirmManifest($request)
170
- {
171
- if (!$this->_client) {
172
- return false;
173
- }
174
-
175
- $response = $this->_client->confirmManifest($request);
176
- if (is_soap_fault($response)) {
177
- throw new Exception($response->faultstring);
178
- }
179
- return $response;
180
- }
181
-
182
- public function getManifest($request)
183
- {
184
- if (!$this->_client) {
185
- return false;
186
- }
187
-
188
- $response = $this->_client->getManifest($request);
189
- if (is_soap_fault($response)) {
190
- throw new Exception($response->faultstring);
191
- }
192
- return $response;
193
- }
194
-
195
- /**
196
- * get list of location
197
- *
198
- * @param $request
199
- * @return bool
200
- */
201
- public function getLocations($request)
202
- {
203
- if (!$this->_client) {
204
- return false;
205
- }
206
-
207
- $response = $this->_client->getLocations($request);
208
- if (is_soap_fault($response)) {
209
- throw new Exception($response->faultstring);
210
- }
211
- return $response;
212
- }
213
-
214
- /**
215
- * create location
216
- *
217
- * @param $request
218
- * @return bool
219
- */
220
- public function createLocation($request)
221
- {
222
- if (!$this->_client) {
223
- return false;
224
- }
225
-
226
- $request['clientId'] = Mage::helper('temando')->getClientId();
227
-
228
- $response = $this->_client->createLocation($request);
229
- if (is_soap_fault($response)) {
230
- throw new Exception($response->faultstring);
231
- }
232
- return $response;
233
- }
234
-
235
- /**
236
- * update location
237
- *
238
- * @param $request
239
- * @return bool
240
- */
241
- public function updateLocation($request)
242
- {
243
- if (!$this->_client) {
244
- return false;
245
- }
246
-
247
- $request['clientId'] = Mage::helper('temando')->getClientId();
248
-
249
- $response = $this->_client->updateLocation($request);
250
- if(is_soap_fault($response)) {
251
- throw new Exception($response->faultstring);
252
- }
253
- return $response;
254
- }
255
-
256
- /**
257
- * get carriers
258
- *
259
- * @param $request
260
- * @return bool
261
- */
262
- public function getCarriers($request)
263
- {
264
- if (!$this->_client) {
265
- return false;
266
- }
267
-
268
- $response = $this->_client->getCarriers($request);
269
- if (is_soap_fault($response)) {
270
- throw new Exception($response->faultstring);
271
- }
272
- return $response;
273
- }
274
-
275
- /**
276
- * Gets the multiplier for insurance (currently 1%).
277
- *
278
- * To add insurance to a quote, the total price should be multiplied by
279
- * this value.
280
- */
281
- public function getInsuranceMultiplier()
282
- {
283
- return 1.01; // 1%
284
- }
285
-
286
-
287
- public function getClient($request)
288
- {
289
- if (!$this->_client) {
290
- return false;
291
- }
292
-
293
- $response = $this->_client->getClient($request);
294
- if (is_soap_fault($response)) {
295
- throw new Exception($response->faultstring);
296
- }
297
- return $response;
298
- }
299
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Debugging SoapClient
4
+ * Logs request and response in var/log
5
+ *
6
+ * @package Temando_Temando
7
+ * @author Temando Magento Team <marketing@temando.com>
8
+ */
9
+ class DebugSoapClient extends SoapClient
10
+ {
11
+
12
+ public function __doRequest($request, $location, $action, $version, $one_way = 0)
13
+ {
14
+ Mage::log($request, null, 'raw-request.xml', true);
15
+ $response = parent::__doRequest($request, $location, $action, $version, $one_way);
16
+ Mage::log($response, null, 'raw-response.xml', true);
17
+ return $response;
18
+ }
19
+ }
20
+
21
+ /**
22
+ * Api Client
23
+ *
24
+ * @package Temando_Temando
25
+ * @author Temando Magento Team <marketing@temando.com>
26
+ */
27
+ class Temando_Temando_Model_Api_Client extends Mage_Core_Model_Abstract
28
+ {
29
+
30
+ const NO_SHIP_DATE = 'Unable to send on the specified date and/or location.';
31
+
32
+ protected $temandoApiSandbox = 'https://api-demo.temando.com/schema/2009_06/server.wsdl';
33
+ protected $temandoApi = 'https://api.temando.com/schema/2009_06/server.wsdl';
34
+
35
+ protected $_client = null;
36
+ protected $_is_sand = null;
37
+
38
+ public function __construct()
39
+ {
40
+ parent::__construct();
41
+ }
42
+
43
+ public function connect($username = null, $password = null, $sandbox = false)
44
+ {
45
+ $this->_is_sand = $sandbox;
46
+
47
+ $endpoint = Mage::getModel('temando/endpoint')
48
+ ->setOriginCountry(Mage::helper('temando')->getConfigData('origin/country'));
49
+ /* @var $endpoint Temando_Temando_Model_Endpoint */
50
+
51
+ if ($sandbox) {
52
+ $url = $endpoint->getSandboxEndpoint() ? $endpoint->getSandboxEndpoint() : $this->temandoApiSandbox;
53
+ } else {
54
+ $url = $endpoint->getProductionEndpoint() ? $endpoint->getProductionEndpoint() : $this->temandoApi;
55
+ }
56
+
57
+ if (!$username) {
58
+ $username = Mage::helper('temando')->getConfigData('general/username');
59
+ }
60
+ if (!$password) {
61
+ $password = Mage::helper('temando')->getConfigData('general/password');
62
+ }
63
+
64
+ // The WSDL cache should be set to on to prevent the WSDL being loaded everytime.
65
+ ini_set("soap.wsdl_cache_enabled", "1");
66
+
67
+ // Create a new SoapClient referencing the Temando WSDL file.
68
+ $this->_client = new SoapClient(
69
+ $url,
70
+ array('soap_version' => SOAP_1_2, 'trace' => true, 'exceptions' => false
71
+ )
72
+ );
73
+
74
+ // Define the security string that wraps your login details. Due to limitations
75
+ // with the PHP language this header information can only be provided via a string.
76
+ $headerSecurityStr = "<Security><UsernameToken><Username>" .
77
+ htmlentities($username) . "</Username>" .
78
+ "<Password>" . htmlentities($password) . "</Password></UsernameToken></Security>";
79
+
80
+ // Create a new SoapVar using the header security string.
81
+ $headerSecurityVar = new SoapVar($headerSecurityStr, XSD_ANYXML);
82
+
83
+ // Create a new SoapHeader containing all your login details.
84
+ $soapHeader = new SoapHeader(
85
+ 'wsse:http://schemas.xmlsoap.org/ws/2002/04/secext',
86
+ 'soapenv:Header',
87
+ $headerSecurityVar
88
+ );
89
+
90
+ // Add the SoapHeader to your SoapClient.
91
+ $this->_client->__setSoapHeaders(array($soapHeader));
92
+
93
+ return $this;
94
+ }
95
+
96
+ /**
97
+ * Gets quotes for a delivery.
98
+ *
99
+ * @param array $request the request parameters, in an array format.
100
+ * @return array
101
+ */
102
+ public function getQuotesByRequest($request)
103
+ {
104
+ return $this->getQuotes($request);
105
+ }
106
+
107
+ public function getQuotes($request)
108
+ {
109
+ if (!$this->_client) {
110
+ return false;
111
+ }
112
+
113
+ if (!$this->_is_sand) {
114
+ $request['clientId'] = Mage::helper('temando')->getClientId();
115
+ }
116
+
117
+ $response = $this->_client->getQuotes($request);
118
+ //check for no ship days - public holidays - and retry with date +1 (up to +10) days before exiting
119
+ $i = 0;
120
+ if (isset($request['anytime']['readyDate'])) {
121
+ while (is_soap_fault($response) && $response->faultstring == self::NO_SHIP_DATE && ++$i <= 10) {
122
+ $readyDate = strtotime($request['anytime']['readyDate']);
123
+ while (in_array(date('N', $readyDate), array(6, 7))) {
124
+ $readyDate = strtotime('+1 day', $readyDate);
125
+ }
126
+ $request['anytime']['readyDate'] = date('Y-m-d', strtotime('+1 day', $readyDate));
127
+ $response = $this->_client->getQuotes($request);
128
+ }
129
+ }
130
+ if (is_soap_fault($response)) {
131
+ throw new Exception($response->faultstring);
132
+ }
133
+ //make sure we have an array
134
+ if (!isset($response->quotes->quote)) {
135
+ $response->quotes->quote = array();
136
+ } elseif (isset($response->quotes->quote) && !is_array($response->quotes->quote)) {
137
+ $response->quotes->quote = array(0 => $response->quotes->quote);
138
+ }
139
+
140
+ $quotes = array();
141
+ foreach ($response->quotes->quote as $quoteData) {
142
+ $quotes[] = Mage::getModel('temando/quote')->loadResponse($quoteData);
143
+ }
144
+
145
+ return $quotes;
146
+ }
147
+
148
+ public function makeBookingByRequest($request)
149
+ {
150
+ return $this->makeBooking($request);
151
+ }
152
+
153
+ public function makeBooking($request)
154
+ {
155
+ if (!$this->_is_sand) {
156
+ $request['clientId'] = Mage::helper('temando')->getClientId();
157
+ }
158
+ if (!$this->_client) {
159
+ return false;
160
+ }
161
+
162
+ $response = $this->_client->makeBooking($request);
163
+ if (is_soap_fault($response)) {
164
+ throw new Exception($response->faultstring);
165
+ }
166
+ return $response;
167
+ }
168
+
169
+ public function getRequest($request)
170
+ {
171
+ if (!$this->_client) {
172
+ return false;
173
+ }
174
+
175
+ $response = $this->_client->getRequest($request);
176
+ if (is_soap_fault($response)) {
177
+ throw new Exception($response->faultstring);
178
+ }
179
+ return $response;
180
+ }
181
+
182
+ public function confirmManifest($request)
183
+ {
184
+ if (!$this->_client) {
185
+ return false;
186
+ }
187
+
188
+ $response = $this->_client->confirmManifest($request);
189
+ if (is_soap_fault($response)) {
190
+ throw new Exception($response->faultstring);
191
+ }
192
+ return $response;
193
+ }
194
+
195
+ public function getManifest($request)
196
+ {
197
+ if (!$this->_client) {
198
+ return false;
199
+ }
200
+
201
+ $response = $this->_client->getManifest($request);
202
+ if (is_soap_fault($response)) {
203
+ throw new Exception($response->faultstring);
204
+ }
205
+ return $response;
206
+ }
207
+
208
+ /**
209
+ * get list of location
210
+ *
211
+ * @param $request
212
+ * @return bool
213
+ */
214
+ public function getLocations($request)
215
+ {
216
+ if (!$this->_client) {
217
+ return false;
218
+ }
219
+
220
+ $response = $this->_client->getLocations($request);
221
+ if (is_soap_fault($response)) {
222
+ throw new Exception($response->faultstring);
223
+ }
224
+ return $response;
225
+ }
226
+
227
+ /**
228
+ * create location
229
+ *
230
+ * @param $request
231
+ * @return bool
232
+ */
233
+ public function createLocation($request)
234
+ {
235
+ if (!$this->_client) {
236
+ return false;
237
+ }
238
+
239
+ $request['clientId'] = Mage::helper('temando')->getClientId();
240
+
241
+ $response = $this->_client->createLocation($request);
242
+ if (is_soap_fault($response)) {
243
+ throw new Exception($response->faultstring);
244
+ }
245
+ return $response;
246
+ }
247
+
248
+ /**
249
+ * update location
250
+ *
251
+ * @param $request
252
+ * @return bool
253
+ */
254
+ public function updateLocation($request)
255
+ {
256
+ if (!$this->_client) {
257
+ return false;
258
+ }
259
+
260
+ $request['clientId'] = Mage::helper('temando')->getClientId();
261
+
262
+ $response = $this->_client->updateLocation($request);
263
+ if (is_soap_fault($response)) {
264
+ throw new Exception($response->faultstring);
265
+ }
266
+ return $response;
267
+ }
268
+
269
+ /**
270
+ * get carriers
271
+ *
272
+ * @param $request
273
+ * @return bool
274
+ */
275
+ public function getCarriers($request)
276
+ {
277
+ if (!$this->_client) {
278
+ return false;
279
+ }
280
+
281
+ $response = $this->_client->getCarriers($request);
282
+ if (is_soap_fault($response)) {
283
+ throw new Exception($response->faultstring);
284
+ }
285
+ return $response;
286
+ }
287
+
288
+ /**
289
+ * Gets the multiplier for insurance (currently 1%).
290
+ *
291
+ * To add insurance to a quote, the total price should be multiplied by
292
+ * this value.
293
+ */
294
+ public function getInsuranceMultiplier()
295
+ {
296
+ return 1.01; // 1%
297
+ }
298
+
299
+
300
+ public function getClient($request)
301
+ {
302
+ if (!$this->_client) {
303
+ return false;
304
+ }
305
+
306
+ $response = $this->_client->getClient($request);
307
+ if (is_soap_fault($response)) {
308
+ throw new Exception($response->faultstring);
309
+ }
310
+ return $response;
311
+ }
312
+ }
app/code/community/Temando/Temando/Model/Api/Request.php CHANGED
@@ -1,205 +1,214 @@
1
- <?php
2
- /**
3
- * Api Request
4
- *
5
- * @package Temando_Temando
6
- * @author Temando Magento Team <marketing@temando.com>
7
- *
8
- * @method Temando_Temando_Model_Api_Request setDeliveryOptions($options)
9
- *
10
- * @method array getDeliveryOptions()
11
- */
12
- class Temando_Temando_Model_Api_Request extends Mage_Core_Model_Abstract
13
- {
14
- /**
15
- * @var Temando_Temando_Model_Api_Request_Anythings
16
- */
17
- protected $_anythings = null;
18
-
19
- /**
20
- * @var Temando_Temando_Model_Api_Request_Anywhere
21
- */
22
- protected $_anywhere = null;
23
-
24
- /**
25
- * @var Temando_Temando_Model_Api_Request_Anytime
26
- */
27
- protected $_anytime = null;
28
-
29
- /**
30
- * @var array
31
- */
32
- protected $_quotes = null;
33
-
34
- /**
35
- * If request includes anytime component
36
- *
37
- * @var boolean
38
- */
39
- protected $use_anytime = false;
40
-
41
-
42
- public function _construct()
43
- {
44
- parent::_construct();
45
- $this->_init('temando/api_request');
46
-
47
- $this->_anythings = Mage::getModel('temando/api_request_anythings');
48
- $this->_anywhere = Mage::getModel('temando/api_request_anywhere');
49
- $this->_anytime = Mage::getModel('temando/api_request_anytime');
50
- }
51
-
52
- public function setItems($items)
53
- {
54
- $this->_anythings->setItems($items);
55
- return $this;
56
- }
57
-
58
- public function setDestination($country, $postcode, $city, $street = null, $destinationType = Temando_Temando_Model_Checkout_Delivery_Options::DESTINATION_RESIDENCE)
59
- {
60
- $this->_anywhere
61
- ->setDestinationCountry($country)
62
- ->setDestinationPostcode($postcode)
63
- ->setDestinationCity($city)
64
- ->setDestinationStreet($street)
65
- ->setDestinationType($destinationType)
66
- ->setDeliveryOptions($this->getDeliveryOptions());
67
- return $this;
68
- }
69
-
70
- public function setReady($timestamp = null, $time_of_day = 'AM')
71
- {
72
- if (!is_null($timestamp)) {
73
- $this->use_anytime = true;
74
- }
75
-
76
- $this->_anytime
77
- ->setReadyDate($timestamp)
78
- ->setReadyTimeOfDay($time_of_day);
79
- return $this;
80
- }
81
-
82
- /**
83
- * Gets all available Temando quotes for this request.
84
- *
85
- * @return Temando_Temando_Model_Mysql4_Quote_Collection
86
- */
87
- public function getQuotes()
88
- {
89
- if (!$this->_fetchQuotes()) {
90
- // validation failed
91
- return false;
92
- }
93
-
94
- $quotes = Mage::getModel('temando/quote')->getCollection()
95
- ->addFieldToFilter('magento_quote_id', $this->getMagentoQuoteId());
96
-
97
- return $quotes;
98
- }
99
-
100
- /**
101
- * Fetches the quotes and saves them into the database.
102
- *
103
- * @throws Exception
104
- */
105
- protected function _fetchQuotes()
106
- {
107
- $request = $this->toRequestArray();
108
-
109
- if (!$request) {
110
- return false;
111
- }
112
-
113
- try {
114
- $api = Mage::getModel('temando/api_client')->connect(
115
- $this->getUsername(), $this->getPassword(), $this->getSandbox()
116
- );
117
- $quotes = $api->getQuotes($request);
118
- } catch(Exception $e) {
119
- throw $e;
120
- }
121
-
122
- // filter by allowed carriers, if the filter has been set
123
- $filtered_quotes = $quotes;
124
- if (is_array($this->getAllowedCarriers())) {
125
- $filtered_quotes = array();
126
- foreach ($quotes as $quote) {
127
- /* @var $quote Temando_Temando_Model_Quote */
128
- $quote_carrier_id = $quote->getCarrier()->getCarrierId();
129
- if (in_array($quote_carrier_id, $this->getAllowedCarriers())) {
130
- $filtered_quotes[] = $quote;
131
- }
132
- }
133
- }
134
-
135
- $this->_saveQuotes($filtered_quotes);
136
-
137
- return true;
138
- }
139
-
140
- /**
141
- * Saves an array of quotes to the database.
142
- *
143
- * @param array $quotes an array of Temando_Temando_Model_Quote objects.
144
- */
145
- protected function _saveQuotes($quotes)
146
- {
147
- // delete all old Temando quotes for this Magento quote
148
- $old_quotes = Mage::getModel('temando/quote')->getCollection()
149
- ->addFieldToFilter('magento_quote_id', $this->getMagentoQuoteId());
150
- foreach ($old_quotes as $quote) {
151
- /* @var $quote Temando_Temando_Model_Quote */
152
- $quote->delete();
153
- }
154
-
155
- // add new Temando quotes to the database
156
- foreach ($quotes as $quote) {
157
- $quote->setMagentoQuoteId($this->getMagentoQuoteId())
158
- ->save();
159
- }
160
-
161
- return $this;
162
- }
163
-
164
-
165
- public function toRequestArray()
166
- {
167
- if (!$this->validate()) {
168
- return false;
169
- }
170
-
171
- $goodsValue = $this->_anythings->getGoodsValue();
172
- $return = array(
173
- 'anythings' => $this->_anythings->toRequestArray(),
174
- 'anywhere' => $this
175
- ->_anywhere
176
- ->setDeliveryOptions($this->getDeliveryOptions())
177
- ->toRequestArray(),
178
- );
179
-
180
- if ($goodsValue) {
181
- $return['general'] = array(
182
- 'goodsValue' => round($goodsValue, 2),
183
- );
184
- }
185
-
186
- if ($this->use_anytime) {
187
- $return['anytime'] = $this->_anytime->toRequestArray();
188
- }
189
-
190
- return $return;
191
- }
192
-
193
- public function validate()
194
- {
195
- return
196
- $this->getMagentoQuoteId() &&
197
- $this->_anythings instanceof Temando_Temando_Model_Api_Request_Anythings &&
198
- $this->_anywhere instanceof Temando_Temando_Model_Api_Request_Anywhere &&
199
- $this->_anytime instanceof Temando_Temando_Model_Api_Request_Anytime &&
200
- $this->_anythings->validate() &&
201
- $this->_anywhere->validate() &&
202
- $this->_anytime->validate();
203
- }
204
-
205
- }
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Api Request
4
+ *
5
+ * @package Temando_Temando
6
+ * @author Temando Magento Team <marketing@temando.com>
7
+ *
8
+ * @method Temando_Temando_Model_Api_Request setDeliveryOptions($options)
9
+ *
10
+ * @method array getDeliveryOptions()
11
+ */
12
+ class Temando_Temando_Model_Api_Request extends Mage_Core_Model_Abstract
13
+ {
14
+ /**
15
+ * @var Temando_Temando_Model_Api_Request_Anythings
16
+ */
17
+ protected $_anythings = null;
18
+
19
+ /**
20
+ * @var Temando_Temando_Model_Api_Request_Anywhere
21
+ */
22
+ protected $_anywhere = null;
23
+
24
+ /**
25
+ * @var Temando_Temando_Model_Api_Request_Anytime
26
+ */
27
+ protected $_anytime = null;
28
+
29
+ /**
30
+ * @var array
31
+ */
32
+ protected $_quotes = null;
33
+
34
+ /**
35
+ * If request includes anytime component
36
+ *
37
+ * @var boolean
38
+ */
39
+ protected $use_anytime = false;
40
+
41
+
42
+ public function _construct()
43
+ {
44
+ parent::_construct();
45
+ $this->_init('temando/api_request');
46
+
47
+ $this->_anythings = Mage::getModel('temando/api_request_anythings');
48
+ $this->_anywhere = Mage::getModel('temando/api_request_anywhere');
49
+ $this->_anytime = Mage::getModel('temando/api_request_anytime');
50
+ $this->setGoodsCurrency(Mage::helper('temando')->getCurrencyCode());
51
+ }
52
+
53
+ public function setItems($items)
54
+ {
55
+ $this->_anythings->setItems($items);
56
+ return $this;
57
+ }
58
+
59
+ public function setDestination(
60
+ $country,
61
+ $postcode,
62
+ $city,
63
+ $street = null,
64
+ $destinationType = Temando_Temando_Model_Checkout_Delivery_Options::DESTINATION_RESIDENCE
65
+ ) {
66
+ $this->_anywhere
67
+ ->setDestinationCountry($country)
68
+ ->setDestinationPostcode($postcode)
69
+ ->setDestinationCity($city)
70
+ ->setDestinationStreet($street)
71
+ ->setDestinationType($destinationType)
72
+ ->setDeliveryOptions($this->getDeliveryOptions());
73
+ return $this;
74
+ }
75
+
76
+ public function setReady($timestamp = null, $time_of_day = 'AM')
77
+ {
78
+ if (!is_null($timestamp)) {
79
+ $this->use_anytime = true;
80
+ }
81
+
82
+ $this->_anytime
83
+ ->setReadyDate($timestamp)
84
+ ->setReadyTimeOfDay($time_of_day);
85
+ return $this;
86
+ }
87
+
88
+ /**
89
+ * Gets all available Temando quotes for this request.
90
+ *
91
+ * @return Temando_Temando_Model_Mysql4_Quote_Collection
92
+ */
93
+ public function getQuotes()
94
+ {
95
+ if (!$this->_fetchQuotes()) {
96
+ // validation failed
97
+ return false;
98
+ }
99
+
100
+ $quotes = Mage::getModel('temando/quote')->getCollection()
101
+ ->addFieldToFilter('magento_quote_id', $this->getMagentoQuoteId());
102
+
103
+ return $quotes;
104
+ }
105
+
106
+ /**
107
+ * Fetches the quotes and saves them into the database.
108
+ *
109
+ * @throws Exception
110
+ */
111
+ protected function _fetchQuotes()
112
+ {
113
+ $request = $this->toRequestArray();
114
+
115
+ if (!$request) {
116
+ return false;
117
+ }
118
+
119
+ try {
120
+ $api = Mage::getModel('temando/api_client')->connect(
121
+ $this->getUsername(),
122
+ $this->getPassword(),
123
+ $this->getSandbox()
124
+ );
125
+ $quotes = $api->getQuotes($request);
126
+ } catch (Exception $e) {
127
+ throw $e;
128
+ }
129
+
130
+ // filter by allowed carriers, if the filter has been set
131
+ $filtered_quotes = $quotes;
132
+ if (is_array($this->getAllowedCarriers())) {
133
+ $filtered_quotes = array();
134
+ foreach ($quotes as $quote) {
135
+ /* @var $quote Temando_Temando_Model_Quote */
136
+ $quote_carrier_id = $quote->getCarrier()->getCarrierId();
137
+ if (in_array($quote_carrier_id, $this->getAllowedCarriers())) {
138
+ $filtered_quotes[] = $quote;
139
+ }
140
+ }
141
+ }
142
+
143
+ $this->_saveQuotes($filtered_quotes);
144
+
145
+ return true;
146
+ }
147
+
148
+ /**
149
+ * Saves an array of quotes to the database.
150
+ *
151
+ * @param array $quotes an array of Temando_Temando_Model_Quote objects.
152
+ */
153
+ protected function _saveQuotes($quotes)
154
+ {
155
+ // delete all old Temando quotes for this Magento quote
156
+ $old_quotes = Mage::getModel('temando/quote')->getCollection()
157
+ ->addFieldToFilter('magento_quote_id', $this->getMagentoQuoteId());
158
+ foreach ($old_quotes as $quote) {
159
+ /* @var $quote Temando_Temando_Model_Quote */
160
+ $quote->delete();
161
+ }
162
+
163
+ // add new Temando quotes to the database
164
+ foreach ($quotes as $quote) {
165
+ $quote->setMagentoQuoteId($this->getMagentoQuoteId())
166
+ ->save();
167
+ }
168
+
169
+ return $this;
170
+ }
171
+
172
+
173
+ public function toRequestArray()
174
+ {
175
+ if (!$this->validate()) {
176
+ return false;
177
+ }
178
+
179
+ $goodsValue = $this->_anythings->getGoodsValue();
180
+ $return = array(
181
+ 'anythings' => $this->_anythings->toRequestArray(),
182
+ 'anywhere' => $this
183
+ ->_anywhere
184
+ ->setDeliveryOptions($this->getDeliveryOptions())
185
+ ->toRequestArray(),
186
+ );
187
+
188
+ if ($goodsValue) {
189
+ $return['general'] = array(
190
+ 'goodsValue' => round($goodsValue, 2),
191
+ 'goodsCurrency' => $this->getGoodsCurrency()
192
+ );
193
+ }
194
+
195
+ if ($this->use_anytime) {
196
+ $return['anytime'] = $this->_anytime->toRequestArray();
197
+ }
198
+
199
+ return $return;
200
+ }
201
+
202
+ public function validate()
203
+ {
204
+ return
205
+ $this->getMagentoQuoteId() &&
206
+ $this->_anythings instanceof Temando_Temando_Model_Api_Request_Anythings &&
207
+ $this->_anywhere instanceof Temando_Temando_Model_Api_Request_Anywhere &&
208
+ $this->_anytime instanceof Temando_Temando_Model_Api_Request_Anytime &&
209
+ $this->_anythings->validate() &&
210
+ $this->_anywhere->validate() &&
211
+ $this->_anytime->validate();
212
+ }
213
+
214
+ }
app/code/community/Temando/Temando/Model/Api/Request/Anything.php CHANGED
@@ -1,130 +1,159 @@
1
- <?php
2
- /**
3
- * Api Request Anything
4
- *
5
- * @package Temando_Temando
6
- * @author Temando Magento Team <marketing@temando.com>
7
- */
8
- class Temando_Temando_Model_Api_Request_Anything extends Mage_Core_Model_Abstract
9
- {
10
- const GOODS_CLASS = 'General Goods';
11
- const GOODS_SUBCLASS = 'Household Goods';
12
- const PALLET_TYPE = 'Plain';
13
- const PALLET_NATURE = 'Not Required';
14
-
15
- /**
16
- * @var Mage_Sales_Model_Order_Item
17
- */
18
- protected $_item = null;
19
-
20
- public function _construct()
21
- {
22
- parent::_construct();
23
- $this->_init('temando/api_request_anything');
24
- }
25
-
26
- public function setItem($item)
27
- {
28
- if ($item instanceof Mage_Sales_Model_Quote_Item || $item instanceof Mage_Sales_Model_Order_Item ||
29
- $item instanceof Mage_Sales_Model_Quote_Address_Item || $item instanceof Temando_Temando_Model_Box) {
30
- $this->_item = $item;
31
- }
32
- return $this;
33
- }
34
-
35
- /**
36
- * Gets the order item for this Anything object.
37
- *
38
- * @return Mage_Sales_Model_Order_Item
39
- */
40
- public function getItem()
41
- {
42
- if ($this->_item) {
43
- return $this->_item;
44
- }
45
- return false;
46
- }
47
-
48
- public function toRequestArray()
49
- {
50
- if (!$this->validate()) {
51
- return false;
52
- }
53
-
54
- if ($this->_item instanceof Temando_Temando_Model_Box) {
55
- $anything = array(
56
- 'class' => 'General Goods',
57
- 'subclass' => 'Household Goods',
58
- 'packaging' => Mage::getModel('temando/system_config_source_shipment_packaging')->getOptionLabel($this->_item->getPackaging()),
59
- 'quantity' => (int)($this->_item->getQty()),
60
- 'distanceMeasurementType' => Temando_Temando_Model_System_Config_Source_Unit_Measure::CENTIMETRES,
61
- 'weightMeasurementType' => Temando_Temando_Model_System_Config_Source_Unit_Weight::GRAMS,
62
- 'weight' => Mage::helper('temando')->getWeightInGrams($this->_item->getWeight(), $this->_item->getWeightUnit()),
63
- 'length' => Mage::helper('temando')->getDistanceInCentimetres($this->_item->getLength(), $this->_item->getMeasureUnit()),
64
- 'width' => Mage::helper('temando')->getDistanceInCentimetres($this->_item->getWidth(), $this->_item->getMeasureUnit()),
65
- 'height' => Mage::helper('temando')->getDistanceInCentimetres($this->_item->getHeight(), $this->_item->getMeasureUnit()),
66
- 'qualifierFreightGeneralFragile' => $this->_item->getFragile() == '1' ? 'Y' : 'N',
67
- 'qualifierFreightGeneralDangerousGoods' => $this->_item->getDangerous() == '1' ? 'Y' : 'N',
68
- 'description' => $this->_item->getComment()
69
- );
70
- if($this->_item->getPackaging() == Temando_Temando_Model_System_Config_Source_Shipment_Packaging::PALLET) {
71
- $anything['palletType'] = self::PALLET_TYPE;
72
- $anything['palletNature'] = self::PALLET_NATURE;
73
- }
74
-
75
- } else {
76
-
77
- Mage::helper('temando')->applyTemandoParamsToItem($this->_item);
78
- $anything = array(
79
- 'class' => 'General Goods',
80
- 'subclass' => 'Household Goods',
81
- 'packaging' => Mage::getModel('temando/system_config_source_shipment_packaging')->getOptionLabel($this->_item->getTemandoPackaging()),
82
- 'quantity' => (int)($this->_item->getQty() ? $this->_item->getQty() : $this->_item->getQtyOrdered()),
83
- 'distanceMeasurementType' => Temando_Temando_Model_System_Config_Source_Unit_Measure::CENTIMETRES,
84
- 'weightMeasurementType' => Temando_Temando_Model_System_Config_Source_Unit_Weight::GRAMS,
85
- 'weight' => Mage::helper('temando')->getWeightInGrams($this->_item->getWeight(),Mage::helper('temando')->getConfigData('units/weight')),
86
- 'length' => Mage::helper('temando')->getDistanceInCentimetres($this->_item->getTemandoLength(), Mage::helper('temando')->getConfigData('units/measure')),
87
- 'width' => Mage::helper('temando')->getDistanceInCentimetres($this->_item->getTemandoWidth(), Mage::helper('temando')->getConfigData('units/measure')),
88
- 'height' => Mage::helper('temando')->getDistanceInCentimetres($this->_item->getTemandoHeight(), Mage::helper('temando')->getConfigData('units/measure')),
89
- 'qualifierFreightGeneralFragile' => $this->_item->getTemandoFragile() == '1' ? 'Y' : 'N',
90
- 'qualifierFreightGeneralDangerousGoods' => $this->_item->getTemandoDangerous() == '1' ? 'Y' : 'N',
91
- 'description' => $this->_item->getName(),
92
- 'articles' => $this->getArticlesElement()
93
- );
94
- if($this->_item->getTemandoPackaging() == Temando_Temando_Model_System_Config_Source_Shipment_Packaging::PALLET) {
95
- $anything['palletType'] = self::PALLET_TYPE;
96
- $anything['palletNature'] = self::PALLET_NATURE;
97
- }
98
-
99
- }
100
- return $anything;
101
- }
102
-
103
- /**
104
- * Prepares articles element for this anything
105
- *
106
- * @return array
107
- */
108
- public function getArticlesElement()
109
- {
110
- $articles = array();
111
- $qty = $this->_item->getQty() ? $this->_item->getQty() : $this->_item->getQtyOrdered();
112
- for ($i = 1; $i <= $qty; $i++) {
113
- $articles[] = array(
114
- 'sku' => $this->_item->getSku(),
115
- 'description' => $this->_item->getName(),
116
- 'goodsValue' => $this->_item->getPrice()
117
- );
118
- }
119
- return $articles;
120
- }
121
-
122
- public function validate()
123
- {
124
- return $this->_item instanceof Mage_Sales_Model_Quote_Item ||
125
- $this->_item instanceof Mage_Sales_Model_Order_Item ||
126
- $this->_item instanceof Mage_Sales_Model_Quote_Address_Item ||
127
- $this->_item instanceof Temando_Temando_Model_Box;
128
- }
129
-
130
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Api Request Anything
4
+ *
5
+ * @package Temando_Temando
6
+ * @author Temando Magento Team <marketing@temando.com>
7
+ */
8
+ class Temando_Temando_Model_Api_Request_Anything extends Mage_Core_Model_Abstract
9
+ {
10
+ const GOODS_CLASS = 'General Goods';
11
+ const GOODS_SUBCLASS = 'Household Goods';
12
+ const PALLET_TYPE = 'Plain';
13
+ const PALLET_NATURE = 'Not Required';
14
+
15
+ /**
16
+ * @var Mage_Sales_Model_Order_Item
17
+ */
18
+ protected $_item = null;
19
+
20
+ public function _construct()
21
+ {
22
+ parent::_construct();
23
+ $this->_init('temando/api_request_anything');
24
+ }
25
+
26
+ public function setItem($item)
27
+ {
28
+ if ($item instanceof Mage_Sales_Model_Quote_Item || $item instanceof Mage_Sales_Model_Order_Item ||
29
+ $item instanceof Mage_Sales_Model_Quote_Address_Item || $item instanceof Temando_Temando_Model_Box) {
30
+ $this->_item = $item;
31
+ }
32
+ return $this;
33
+ }
34
+
35
+ /**
36
+ * Gets the order item for this Anything object.
37
+ *
38
+ * @return Mage_Sales_Model_Order_Item
39
+ */
40
+ public function getItem()
41
+ {
42
+ if ($this->_item) {
43
+ return $this->_item;
44
+ }
45
+ return false;
46
+ }
47
+
48
+ public function toRequestArray()
49
+ {
50
+ if (!$this->validate()) {
51
+ return false;
52
+ }
53
+
54
+ if ($this->_item instanceof Temando_Temando_Model_Box) {
55
+ $anything = array(
56
+ 'class' => 'General Goods',
57
+ 'subclass' => 'Household Goods',
58
+ 'packaging' => Mage::getModel('temando/system_config_source_shipment_packaging')
59
+ ->getOptionLabel($this->_item->getPackaging()),
60
+ 'quantity' => (int)($this->_item->getQty()),
61
+ 'distanceMeasurementType' => Temando_Temando_Model_System_Config_Source_Unit_Measure::CENTIMETRES,
62
+ 'weightMeasurementType' => Temando_Temando_Model_System_Config_Source_Unit_Weight::GRAMS,
63
+ 'weight' => Mage::helper('temando')->getWeightInGrams(
64
+ $this->_item->getWeight(),
65
+ $this->_item->getWeightUnit()
66
+ ),
67
+ 'length' => Mage::helper('temando')->getDistanceInCentimetres(
68
+ $this->_item->getLength(),
69
+ $this->_item->getMeasureUnit()
70
+ ),
71
+ 'width' => Mage::helper('temando')->getDistanceInCentimetres(
72
+ $this->_item->getWidth(),
73
+ $this->_item->getMeasureUnit()
74
+ ),
75
+ 'height' => Mage::helper('temando')->getDistanceInCentimetres(
76
+ $this->_item->getHeight(),
77
+ $this->_item->getMeasureUnit()
78
+ ),
79
+ 'qualifierFreightGeneralFragile' => $this->_item->getFragile() == '1' ? 'Y' : 'N',
80
+ 'qualifierFreightGeneralDangerousGoods' => $this->_item->getDangerous() == '1' ? 'Y' : 'N',
81
+ 'description' => $this->_item->getComment()
82
+ );
83
+
84
+ if ($this->_item->getPackaging() ==
85
+ Temando_Temando_Model_System_Config_Source_Shipment_Packaging::PALLET) {
86
+ $anything['palletType'] = self::PALLET_TYPE;
87
+ $anything['palletNature'] = self::PALLET_NATURE;
88
+ }
89
+
90
+ } else {
91
+
92
+ Mage::helper('temando')->applyTemandoParamsToItem($this->_item);
93
+ $anything = array(
94
+ 'class' => 'General Goods',
95
+ 'subclass' => 'Household Goods',
96
+ 'packaging' => Mage::getModel('temando/system_config_source_shipment_packaging')
97
+ ->getOptionLabel($this->_item->getTemandoPackaging()),
98
+ 'quantity' => (int)($this->_item->getQty() ? $this->_item->getQty() : $this->_item->getQtyOrdered()),
99
+ 'distanceMeasurementType' => Temando_Temando_Model_System_Config_Source_Unit_Measure::CENTIMETRES,
100
+ 'weightMeasurementType' => Temando_Temando_Model_System_Config_Source_Unit_Weight::GRAMS,
101
+ 'weight' => Mage::helper('temando')->getWeightInGrams(
102
+ $this->_item->getWeight(),
103
+ Mage::helper('temando')->getConfigData('units/weight')
104
+ ),
105
+ 'length' => Mage::helper('temando')->getDistanceInCentimetres(
106
+ $this->_item->getTemandoLength(),
107
+ Mage::helper('temando')->getConfigData('units/measure')
108
+ ),
109
+ 'width' => Mage::helper('temando')->getDistanceInCentimetres(
110
+ $this->_item->getTemandoWidth(),
111
+ Mage::helper('temando')->getConfigData('units/measure')
112
+ ),
113
+ 'height' => Mage::helper('temando')->getDistanceInCentimetres(
114
+ $this->_item->getTemandoHeight(),
115
+ Mage::helper('temando')->getConfigData('units/measure')
116
+ ),
117
+ 'qualifierFreightGeneralFragile' => $this->_item->getTemandoFragile() == '1' ? 'Y' : 'N',
118
+ 'qualifierFreightGeneralDangerousGoods'
119
+ => $this->_item->getTemandoDangerous() == '1' ? 'Y' : 'N',
120
+ 'description' => $this->_item->getName(),
121
+ 'articles' => $this->getArticlesElement()
122
+ );
123
+ if ($this->_item->getTemandoPackaging() ==
124
+ Temando_Temando_Model_System_Config_Source_Shipment_Packaging::PALLET) {
125
+ $anything['palletType'] = self::PALLET_TYPE;
126
+ $anything['palletNature'] = self::PALLET_NATURE;
127
+ }
128
+
129
+ }
130
+ return $anything;
131
+ }
132
+
133
+ /**
134
+ * Prepares articles element for this anything
135
+ *
136
+ * @return array
137
+ */
138
+ public function getArticlesElement()
139
+ {
140
+ $articles = array();
141
+ $qty = $this->_item->getQty() ? $this->_item->getQty() : $this->_item->getQtyOrdered();
142
+ for ($i = 1; $i <= $qty; $i++) {
143
+ $articles[] = array(
144
+ 'sku' => $this->_item->getSku(),
145
+ 'description' => $this->_item->getName(),
146
+ 'goodsValue' => $this->_item->getPrice()
147
+ );
148
+ }
149
+ return $articles;
150
+ }
151
+
152
+ public function validate()
153
+ {
154
+ return $this->_item instanceof Mage_Sales_Model_Quote_Item ||
155
+ $this->_item instanceof Mage_Sales_Model_Order_Item ||
156
+ $this->_item instanceof Mage_Sales_Model_Quote_Address_Item ||
157
+ $this->_item instanceof Temando_Temando_Model_Box;
158
+ }
159
+ }
app/code/community/Temando/Temando/Model/Api/Request/Anythings.php CHANGED
@@ -1,184 +1,185 @@
1
- <?php
2
- /**
3
- * Api Request Anythings
4
- *
5
- * @package Temando_Temando
6
- * @author Temando Magento Team <marketing@temando.com>
7
- */
8
- class Temando_Temando_Model_Api_Request_Anythings extends Mage_Core_Model_Abstract {
9
-
10
- /**
11
- * @var array
12
- */
13
- protected $_anythings;
14
- protected $_need_optimize = false;
15
-
16
- public function _construct()
17
- {
18
- parent::_construct();
19
- $this->_init('temando/api_request_anythings');
20
- $this->_anythings = array();
21
- }
22
-
23
- public function setItems($items)
24
- {
25
- $this->_anythings = array();
26
- foreach ($items as $item) {
27
- if ($item->getParentItem() || $item->getIsVirtual()) {
28
- // do not add child products or virtual items
29
- continue;
30
- }
31
-
32
- if ($item->getProduct() && $item->getProduct()->isVirtual()) {
33
- // do not add virtual product
34
- continue;
35
- }
36
-
37
- if ($item->getFreeShipping()) {
38
- continue;
39
- }
40
-
41
- $this->addItem($item);
42
- }
43
- return $this;
44
- }
45
-
46
- public function addItem($item)
47
- {
48
- if ($item instanceof Mage_Sales_Model_Quote_Item || $item instanceof Mage_Sales_Model_Order_Item || $item instanceof Mage_Sales_Model_Quote_Address_Item || $item instanceof Temando_Temando_Model_Box) {
49
- if ($item instanceof Mage_Sales_Model_Quote_Item || $item instanceof Mage_Sales_Model_Order_Item || $item instanceof Mage_Sales_Model_Quote_Address_Item) {
50
- $this->_need_optimize = true;
51
- }
52
-
53
- $this->_anythings[] = Mage::getModel('temando/api_request_anything')
54
- ->setItem($item);
55
- }
56
- return $this;
57
- }
58
-
59
- public function getItems()
60
- {
61
- return $this->_anythings;
62
- }
63
-
64
- public function validate()
65
- {
66
- if (!count($this->_anythings)) {
67
- // no child items
68
- return false;
69
- }
70
-
71
- // validate each child item
72
- foreach ($this->_anythings as $anything) {
73
- /* @var $anything Temando_Temando_Model_Api_Request_Anything */
74
- if (!$anything->validate()) {
75
- return false;
76
- }
77
- }
78
- return true;
79
- }
80
-
81
- /**
82
- * Prepares array of anythings for XML API SOAP call
83
- *
84
- * @return boolean
85
- */
86
- public function toRequestArray()
87
- {
88
- if (!$this->validate()) {
89
- return false;
90
- }
91
- $output = $this->_consolidate();
92
- return $output;
93
- }
94
-
95
- /**
96
- * Returns combined value of request items.
97
- *
98
- * @return float
99
- */
100
- public function getGoodsValue()
101
- {
102
- $goodsValue = 0;
103
- foreach($this->_anythings as $anything) {
104
- /* @var $anything Temando_Temando_Model_Api_Request_Anything */
105
- $item = $anything->getItem();
106
- if($item instanceof Temando_Temando_Model_Box) {
107
- $goodsValue += $item->getValue();
108
- } else {
109
- $goodsValue += ($item->getQty() * $item->getPrice());
110
- }
111
- }
112
- return (float) $goodsValue;
113
- }
114
-
115
- /**
116
- * Basic satchel or carton consolidation - 1x satchel or carton for items up to 5kg of weight
117
- *
118
- * @return string
119
- */
120
- protected function _consolidate()
121
- {
122
- $only_satchel_and_carton = true;
123
- $has_carton = false;
124
- $output = array();
125
- foreach ($this->_anythings as $anything) {
126
- $request = $anything->toRequestArray();
127
- if ($request && !in_array($request['packaging'], array('Satchel/Bag', 'Carton'))) {
128
- $only_satchel_and_carton = false;
129
- }
130
- if ($request && ($request['packaging'] == 'Carton')) {
131
- $has_carton = true;
132
- }
133
- if ($this->_need_optimize && $request && in_array($request['packaging'], array('Satchel/Bag', 'Parcel'))) {
134
- $grams_weight = $request['weight'];
135
- // locate all items or add new box
136
- for ($i = 0; $i < $request['quantity']; $i++) {
137
- $adding = false;
138
- $found = false;
139
- foreach ($output as $k => $v) {
140
- $cur_weight = $v['weight'];
141
- if ($v && ($v['packaging'] == $request['packaging']) && (5000 > ($grams_weight + $cur_weight))) {
142
- if ($v['quantity'] > 1) {
143
- $v['quantity']--;
144
- $adding = $v;
145
- $adding['quantity'] = 1;
146
- $adding['weight'] = $grams_weight + $cur_weight;
147
- $adding['weightMeasurementType'] = Temando_Temando_Model_System_Config_Source_Unit_Weight::GRAMS;
148
- } else {
149
- $v['weight'] = $grams_weight + $cur_weight;
150
- $v['weightMeasurementType'] = Temando_Temando_Model_System_Config_Source_Unit_Weight::GRAMS;
151
- }
152
-
153
- $found = true;
154
- $output[$k] = $v;
155
- break;
156
- }
157
- }
158
-
159
- if (!$found) {
160
- $_t = $request;
161
- $_t['quantity'] = 1;
162
- $_t['grams'] = $grams_weight;
163
- $adding = $_t;
164
- }
165
-
166
- if ($adding) {
167
- $output[] = $adding;
168
- }
169
- }
170
- } else {
171
- $output[] = $request;
172
- }
173
-
174
- if ($only_satchel_and_carton && $has_carton) {
175
- foreach ($output as $k => $v) {
176
- $v['packaging'] = 'Carton';
177
- $output[$k] = $v;
178
- }
179
- }
180
- }
181
- return $output;
182
- }
183
-
184
- }
 
1
+ <?php
2
+ /**
3
+ * Api Request Anythings
4
+ *
5
+ * @package Temando_Temando
6
+ * @author Temando Magento Team <marketing@temando.com>
7
+ */
8
+ class Temando_Temando_Model_Api_Request_Anythings extends Mage_Core_Model_Abstract {
9
+
10
+ /**
11
+ * @var array
12
+ */
13
+ protected $_anythings;
14
+ protected $_need_optimize = false;
15
+
16
+ public function _construct()
17
+ {
18
+ parent::_construct();
19
+ $this->_init('temando/api_request_anythings');
20
+ $this->_anythings = array();
21
+ }
22
+
23
+ public function setItems($items)
24
+ {
25
+ $this->_anythings = array();
26
+ foreach ($items as $item) {
27
+ if ($item->getParentItem() || $item->getIsVirtual()) {
28
+ // do not add child products or virtual items
29
+ continue;
30
+ }
31
+
32
+ if ($item->getProduct() && $item->getProduct()->isVirtual()) {
33
+ // do not add virtual product
34
+ continue;
35
+ }
36
+
37
+ if ($item->getFreeShipping()) {
38
+ continue;
39
+ }
40
+ $this->addItem($item);
41
+ }
42
+ return $this;
43
+ }
44
+
45
+ public function addItem($item)
46
+ {
47
+ if ($item instanceof Mage_Sales_Model_Quote_Item || $item instanceof Mage_Sales_Model_Order_Item ||
48
+ $item instanceof Mage_Sales_Model_Quote_Address_Item || $item instanceof Temando_Temando_Model_Box) {
49
+ if ($item instanceof Mage_Sales_Model_Quote_Item || $item instanceof Mage_Sales_Model_Order_Item
50
+ || $item instanceof Mage_Sales_Model_Quote_Address_Item) {
51
+ $this->_need_optimize = true;
52
+ }
53
+ $this->_anythings[] = Mage::getModel('temando/api_request_anything')
54
+ ->setItem($item);
55
+ }
56
+ return $this;
57
+ }
58
+
59
+ public function getItems()
60
+ {
61
+ return $this->_anythings;
62
+ }
63
+
64
+ public function validate()
65
+ {
66
+ if (!count($this->_anythings)) {
67
+ // no child items
68
+ return false;
69
+ }
70
+ // validate each child item
71
+ foreach ($this->_anythings as $anything) {
72
+ /* @var $anything Temando_Temando_Model_Api_Request_Anything */
73
+ if (!$anything->validate()) {
74
+ return false;
75
+ }
76
+ }
77
+ return true;
78
+ }
79
+
80
+ /**
81
+ * Prepares array of anythings for XML API SOAP call
82
+ *
83
+ * @return boolean
84
+ */
85
+ public function toRequestArray()
86
+ {
87
+ if (!$this->validate()) {
88
+ return false;
89
+ }
90
+ $output = $this->_consolidate();
91
+ return $output;
92
+ }
93
+
94
+ /**
95
+ * Returns combined value of request items.
96
+ *
97
+ * @return float
98
+ */
99
+ public function getGoodsValue()
100
+ {
101
+ $goodsValue = 0;
102
+ foreach ($this->_anythings as $anything) {
103
+ /* @var $anything Temando_Temando_Model_Api_Request_Anything */
104
+ $item = $anything->getItem();
105
+ if ($item instanceof Temando_Temando_Model_Box) {
106
+ $goodsValue += $item->getValue();
107
+ } else {
108
+ $goodsValue += ($item->getQty() * $item->getPrice());
109
+ }
110
+ }
111
+ return (float) $goodsValue;
112
+ }
113
+
114
+ /**
115
+ * Basic satchel or carton consolidation - 1x satchel or carton for items up to 5kg of weight
116
+ *
117
+ * @return string
118
+ */
119
+ protected function _consolidate()
120
+ {
121
+ $only_satchel_and_carton = true;
122
+ $has_carton = false;
123
+ $output = array();
124
+ foreach ($this->_anythings as $anything) {
125
+ $request = $anything->toRequestArray();
126
+ if ($request && !in_array($request['packaging'], array('Satchel/Bag', 'Carton'))) {
127
+ $only_satchel_and_carton = false;
128
+ }
129
+ if ($request && ($request['packaging'] == 'Carton')) {
130
+ $has_carton = true;
131
+ }
132
+ if ($this->_need_optimize && $request && in_array($request['packaging'], array('Satchel/Bag', 'Parcel'))) {
133
+ $grams_weight = $request['weight'];
134
+ // locate all items or add new box
135
+ for ($i = 0; $i < $request['quantity']; $i++) {
136
+ $adding = false;
137
+ $found = false;
138
+ foreach ($output as $k => $v) {
139
+ $cur_weight = $v['weight'];
140
+ if ($v && ($v['packaging'] == $request['packaging']) &&
141
+ (5000 > ($grams_weight + $cur_weight))) {
142
+ if ($v['quantity'] > 1) {
143
+ $v['quantity']--;
144
+ $adding = $v;
145
+ $adding['quantity'] = 1;
146
+ $adding['weight'] = $grams_weight + $cur_weight;
147
+ $adding['weightMeasurementType'] =
148
+ Temando_Temando_Model_System_Config_Source_Unit_Weight::GRAMS;
149
+ } else {
150
+ $v['weight'] = $grams_weight + $cur_weight;
151
+ $v['weightMeasurementType'] =
152
+ Temando_Temando_Model_System_Config_Source_Unit_Weight::GRAMS;
153
+ }
154
+
155
+ $found = true;
156
+ $output[$k] = $v;
157
+ break;
158
+ }
159
+ }
160
+
161
+ if (!$found) {
162
+ $_t = $request;
163
+ $_t['quantity'] = 1;
164
+ $_t['grams'] = $grams_weight;
165
+ $adding = $_t;
166
+ }
167
+
168
+ if ($adding) {
169
+ $output[] = $adding;
170
+ }
171
+ }
172
+ } else {
173
+ $output[] = $request;
174
+ }
175
+
176
+ if ($only_satchel_and_carton && $has_carton) {
177
+ foreach ($output as $k => $v) {
178
+ $v['packaging'] = 'Carton';
179
+ $output[$k] = $v;
180
+ }
181
+ }
182
+ }
183
+ return $output;
184
+ }
185
+ }
app/code/community/Temando/Temando/Model/Api/Request/Anytime.php CHANGED
@@ -1,70 +1,68 @@
1
- <?php
2
- /**
3
- * Api Request Anytime
4
- *
5
- * @package Temando_Temando
6
- * @author Temando Magento Team <marketing@temando.com>
7
- */
8
- class Temando_Temando_Model_Api_Request_Anytime extends Mage_Core_Model_Abstract {
9
-
10
- /**
11
- * @var string
12
- */
13
- protected $_ready_time_of_day = null;
14
-
15
- /**
16
- * @var string
17
- */
18
- protected $_ready_date = null;
19
-
20
- public function _construct()
21
- {
22
- parent::_construct();
23
- $this->_init('temando/api_request_anytime');
24
- }
25
-
26
- /**
27
- * Set the date the product will be ready (in UTC).
28
- *
29
- * If setting the ready date to a weekend, the next week day will be used instead.
30
- *
31
- * Doesn't accept timestamps in the past.
32
- *
33
- * @param <type> $timestamp The timestamp when the package will be ready
34
- * (only the date information is used, the time of day is set separately)
35
- *
36
- */
37
- public function setReadyDate($timestamp = null)
38
- {
39
- $this->_ready_date = Mage::helper('temando')->getReadyDate($timestamp);
40
- return $this;
41
- }
42
-
43
- public function setReadyTimeOfDay($time_of_day = 'AM')
44
- {
45
- if (strtoupper($time_of_day) === 'AM' || strtoupper($time_of_day) === 'PM') {
46
- $this->_ready_time_of_day = strtoupper($time_of_day);
47
- }
48
- return $this;
49
- }
50
-
51
- public function validate()
52
- {
53
- return
54
- ($this->_ready_time_of_day == 'AM' || $this->_ready_time_of_day == 'PM') &&
55
- is_numeric($this->_ready_date);
56
- }
57
-
58
- public function toRequestArray()
59
- {
60
- if (!$this->validate()) {
61
- return false;
62
- }
63
-
64
- return array(
65
- 'readyDate' => date('Y-m-d', $this->_ready_date),
66
- 'readyTime' => $this->_ready_time_of_day,
67
- );
68
- }
69
-
70
- }
1
+ <?php
2
+ /**
3
+ * Api Request Anytime
4
+ *
5
+ * @package Temando_Temando
6
+ * @author Temando Magento Team <marketing@temando.com>
7
+ */
8
+ class Temando_Temando_Model_Api_Request_Anytime extends Mage_Core_Model_Abstract {
9
+
10
+ /**
11
+ * @var string
12
+ */
13
+ protected $_ready_time_of_day = null;
14
+
15
+ /**
16
+ * @var string
17
+ */
18
+ protected $_ready_date = null;
19
+
20
+ public function _construct()
21
+ {
22
+ parent::_construct();
23
+ $this->_init('temando/api_request_anytime');
24
+ }
25
+
26
+ /**
27
+ * Set the date the product will be ready (in UTC).
28
+ *
29
+ * If setting the ready date to a weekend, the next week day will be used instead.
30
+ *
31
+ * Doesn't accept timestamps in the past.
32
+ *
33
+ * @param <type> $timestamp The timestamp when the package will be ready
34
+ * (only the date information is used, the time of day is set separately)
35
+ *
36
+ */
37
+ public function setReadyDate($timestamp = null)
38
+ {
39
+ $this->_ready_date = Mage::helper('temando')->getReadyDate($timestamp);
40
+ return $this;
41
+ }
42
+
43
+ public function setReadyTimeOfDay($time_of_day = 'AM')
44
+ {
45
+ if (strtoupper($time_of_day) === 'AM' || strtoupper($time_of_day) === 'PM') {
46
+ $this->_ready_time_of_day = strtoupper($time_of_day);
47
+ }
48
+ return $this;
49
+ }
50
+
51
+ public function validate()
52
+ {
53
+ return
54
+ ($this->_ready_time_of_day == 'AM' || $this->_ready_time_of_day == 'PM') &&
55
+ is_numeric($this->_ready_date);
56
+ }
57
+
58
+ public function toRequestArray()
59
+ {
60
+ if (!$this->validate()) {
61
+ return false;
62
+ }
63
+ return array(
64
+ 'readyDate' => date('Y-m-d', $this->_ready_date),
65
+ 'readyTime' => $this->_ready_time_of_day,
66
+ );
67
+ }
68
+ }
 
 
app/code/community/Temando/Temando/Model/Api/Request/Anywhere.php CHANGED
@@ -1,84 +1,84 @@
1
- <?php
2
- /**
3
- * Api Request Anywhere
4
- *
5
- * @package Temando_Temando
6
- * @author Temando Magento Team <marketing@temando.com>
7
- */
8
- class Temando_Temando_Model_Api_Request_Anywhere extends Mage_Core_Model_Abstract
9
- {
10
-
11
- public function _construct()
12
- {
13
- parent::_construct();
14
- $this->_init('temando/api_request_anywhere');
15
- $this->setDeliveryOptions(array());
16
- }
17
-
18
- public function toRequestArray()
19
- {
20
- if (!$this->validate()) {
21
- return false;
22
- }
23
-
24
- switch ($this->getDestinationType()) {
25
-
26
- case Temando_Temando_Model_Checkout_Delivery_Options::DESTINATION_BUSINESS:
27
-
28
- $data = array(
29
- 'itemNature' => 'Domestic',
30
- 'itemMethod' => 'Door to Door',
31
- 'destinationCountry' => $this->getDestinationCountry(),
32
- 'destinationCode' => $this->getDestinationPostcode(),
33
- 'destinationSuburb' => $this->getDestinationCity(),
34
- 'destinationIs' => ucfirst(Temando_Temando_Model_Checkout_Delivery_Options::DESTINATION_BUSINESS),
35
- 'destinationBusNotifyBefore' => 'N',
36
- 'destinationBusLimitedAccess' => 'N',
37
- 'destinationBusUnattended' => array_key_exists(
38
- 'unattended_delivery',
39
- $this->getDeliveryOptions()
40
- ) ? 'Y' : 'N',
41
- 'originBusNotifyBefore' => 'Y',
42
- 'originDescription' => Temando_Temando_Helper_Data::DEFAULT_WAREHOUSE_NAME
43
- );
44
-
45
- if (Mage::helper('temando')->isStreetWithPO($this->getDestinationStreet())) {
46
- $data['destinationBusPostalBox'] = 'Y';
47
- }
48
- break;
49
- default:
50
- $data = array(
51
- 'itemNature' => 'Domestic',
52
- 'itemMethod' => 'Door to Door',
53
- 'destinationCountry' => $this->getDestinationCountry(),
54
- 'destinationCode' => $this->getDestinationPostcode(),
55
- 'destinationSuburb' => $this->getDestinationCity(),
56
- 'destinationIs' => ucfirst(Temando_Temando_Model_Checkout_Delivery_Options::DESTINATION_RESIDENCE),
57
- 'destinationResNotifyBefore' => 'N',
58
- 'destinationResLimitedAccess' => 'N',
59
- 'destinationResUnattended' => array_key_exists(
60
- 'unattended_delivery',
61
- $this->getDeliveryOptions()
62
- ) ? 'Y' : 'N',
63
- 'originBusNotifyBefore' => 'Y',
64
- 'originDescription' => Temando_Temando_Helper_Data::DEFAULT_WAREHOUSE_NAME
65
- );
66
-
67
- if (Mage::helper('temando')->isStreetWithPO($this->getDestinationStreet())) {
68
- $data['destinationResPostalBox'] = 'Y';
69
- }
70
- break;
71
- }
72
-
73
- return $data;
74
- }
75
-
76
- public function validate()
77
- {
78
- return
79
- $this->getDestinationCountry() &&
80
- $this->getDestinationPostcode() &&
81
- $this->getDestinationCity();
82
- }
83
-
84
- }
1
+ <?php
2
+ /**
3
+ * Api Request Anywhere
4
+ *
5
+ * @package Temando_Temando
6
+ * @author Temando Magento Team <marketing@temando.com>
7
+ */
8
+ class Temando_Temando_Model_Api_Request_Anywhere extends Mage_Core_Model_Abstract
9
+ {
10
+
11
+ public function _construct()
12
+ {
13
+ parent::_construct();
14
+ $this->_init('temando/api_request_anywhere');
15
+ $this->setDeliveryOptions(array());
16
+ }
17
+
18
+ public function toRequestArray()
19
+ {
20
+ if (!$this->validate()) {
21
+ return false;
22
+ }
23
+
24
+ switch ($this->getDestinationType()) {
25
+
26
+ case Temando_Temando_Model_Checkout_Delivery_Options::DESTINATION_BUSINESS:
27
+
28
+ $data = array(
29
+ 'itemNature' => 'Domestic',
30
+ 'itemMethod' => 'Door to Door',
31
+ 'destinationCountry' => $this->getDestinationCountry(),
32
+ 'destinationCode' => $this->getDestinationPostcode(),
33
+ 'destinationSuburb' => $this->getDestinationCity(),
34
+ 'destinationIs' => ucfirst(Temando_Temando_Model_Checkout_Delivery_Options::DESTINATION_BUSINESS),
35
+ 'destinationBusNotifyBefore' => 'N',
36
+ 'destinationBusLimitedAccess' => 'N',
37
+ 'destinationBusUnattended' => array_key_exists(
38
+ 'unattended_delivery',
39
+ $this->getDeliveryOptions()
40
+ ) ? 'Y' : 'N',
41
+ 'originBusNotifyBefore' => 'Y',
42
+ 'originDescription' => Temando_Temando_Helper_Data::DEFAULT_WAREHOUSE_NAME
43
+ );
44
+
45
+ if (Mage::helper('temando')->isStreetWithPO($this->getDestinationStreet())) {
46
+ $data['destinationBusPostalBox'] = 'Y';
47
+ }
48
+ break;
49
+
50
+ default:
51
+ $data = array(
52
+ 'itemNature' => 'Domestic',
53
+ 'itemMethod' => 'Door to Door',
54
+ 'destinationCountry' => $this->getDestinationCountry(),
55
+ 'destinationCode' => $this->getDestinationPostcode(),
56
+ 'destinationSuburb' => $this->getDestinationCity(),
57
+ 'destinationIs' => ucfirst(Temando_Temando_Model_Checkout_Delivery_Options::DESTINATION_RESIDENCE),
58
+ 'destinationResNotifyBefore' => 'N',
59
+ 'destinationResLimitedAccess' => 'N',
60
+ 'destinationResUnattended' => array_key_exists(
61
+ 'unattended_delivery',
62
+ $this->getDeliveryOptions()
63
+ ) ? 'Y' : 'N',
64
+ 'originBusNotifyBefore' => 'Y',
65
+ 'originDescription' => Temando_Temando_Helper_Data::DEFAULT_WAREHOUSE_NAME
66
+ );
67
+
68
+ if (Mage::helper('temando')->isStreetWithPO($this->getDestinationStreet())) {
69
+ $data['destinationResPostalBox'] = 'Y';
70
+ }
71
+ break;
72
+ }
73
+ return $data;
74
+ }
75
+
76
+ public function validate()
77
+ {
78
+ return
79
+ $this->getDestinationCountry() &&
80
+ $this->getDestinationPostcode() &&
81
+ $this->getDestinationCity();
82
+ }
83
+
84
+ }
app/code/community/Temando/Temando/Model/Box.php CHANGED
@@ -1,41 +1,41 @@
1
- <?php
2
- /**
3
- * Box Model
4
- *
5
- * @package Temando_Temando
6
- * @author Temando Magento Team <marketing@temando.com>
7
- *
8
- * @method string getShipmentId()
9
- * @method string getComment()
10
- * @method string getQty()
11
- * @method string getLength()
12
- * @method string getWidth()
13
- * @method string getHeight()
14
- * @method string getMeasureUnit()
15
- * @method string getWeight()
16
- * @method string getWeightUnit()
17
- * @method string getFragile()
18
- * @method string getDangerous()
19
- *
20
- * @method Temando_Temando_Model_Box setShipmentId()
21
- * @method Temando_Temando_Model_Box setComment()
22
- * @method Temando_Temando_Model_Box setQty()
23
- * @method Temando_Temando_Model_Box setLength()
24
- * @method Temando_Temando_Model_Box setWidth()
25
- * @method Temando_Temando_Model_Box setHeight()
26
- * @method Temando_Temando_Model_Box setMeasureUnit()
27
- * @method Temando_Temando_Model_Box setWeight()
28
- * @method Temando_Temando_Model_Box setWeightUnit()
29
- * @method Temando_Temando_Model_Box setFragile()
30
- * @method Temando_Temando_Model_Box setDangerous()
31
- */
32
- class Temando_Temando_Model_Box extends Mage_Core_Model_Abstract
33
- {
34
-
35
- public function _construct()
36
- {
37
- parent::_construct();
38
- $this->_init('temando/box');
39
- }
40
-
41
- }
1
+ <?php
2
+ /**
3
+ * Box Model
4
+ *
5
+ * @package Temando_Temando
6
+ * @author Temando Magento Team <marketing@temando.com>
7
+ *
8
+ * @method string getShipmentId()
9
+ * @method string getComment()
10
+ * @method string getQty()
11
+ * @method string getLength()
12
+ * @method string getWidth()
13
+ * @method string getHeight()
14
+ * @method string getMeasureUnit()
15
+ * @method string getWeight()
16
+ * @method string getWeightUnit()
17
+ * @method string getFragile()
18
+ * @method string getDangerous()
19
+ *
20
+ * @method Temando_Temando_Model_Box setShipmentId()
21
+ * @method Temando_Temando_Model_Box setComment()
22
+ * @method Temando_Temando_Model_Box setQty()
23
+ * @method Temando_Temando_Model_Box setLength()
24
+ * @method Temando_Temando_Model_Box setWidth()
25
+ * @method Temando_Temando_Model_Box setHeight()
26
+ * @method Temando_Temando_Model_Box setMeasureUnit()
27
+ * @method Temando_Temando_Model_Box setWeight()
28
+ * @method Temando_Temando_Model_Box setWeightUnit()
29
+ * @method Temando_Temando_Model_Box setFragile()
30
+ * @method Temando_Temando_Model_Box setDangerous()
31
+ */
32
+ class Temando_Temando_Model_Box extends Mage_Core_Model_Abstract
33
+ {
34
+
35
+ public function _construct()
36
+ {
37
+ parent::_construct();
38
+ $this->_init('temando/box');
39
+ }
40
+
41
+ }
app/code/community/Temando/Temando/Model/Carrier.php CHANGED
@@ -1,59 +1,59 @@
1
- <?php
2
-
3
- /**
4
- * Carrier Model
5
- *
6
- * @package Temando_Temando
7
- * @author Temando Magento Team <marketing@temando.com>
8
- *
9
- * @method Temando_Temando_Model_Carrier setCarrierId()
10
- * @method Temando_Temando_Model_Carrier setCompanyName()
11
- * @method Temando_Temando_Model_Carrier setCompanyContact()
12
- * @method Temando_Temando_Model_Carrier setStreetAddress()
13
- * @method Temando_Temando_Model_Carrier setStreetSuburb()
14
- * @method Temando_Temando_Model_Carrier setStreetCity()
15
- * @method Temando_Temando_Model_Carrier setStreetState()
16
- * @method Temando_Temando_Model_Carrier setStreetPostode()
17
- * @method Temando_Temando_Model_Carrier setStreetCountry()
18
- * @method Temando_Temando_Model_Carrier setPostalAddress()
19
- * @method Temando_Temando_Model_Carrier setPostalSuburb()
20
- * @method Temando_Temando_Model_Carrier setPostalCity()
21
- * @method Temando_Temando_Model_Carrier setPostalState()
22
- * @method Temando_Temando_Model_Carrier setPostalPostcode()
23
- * @method Temando_Temando_Model_Carrier setPostalCountry()
24
- * @method Temando_Temando_Model_Carrier setPhone()
25
- * @method Temando_Temando_Model_Carrier setEmail()
26
- * @method Temando_Temando_Model_Carrier setWebsite()
27
- *
28
- * @method string getCarrierId()
29
- * @method string getCompanyName()
30
- * @method string getCompanyContact()
31
- * @method string getStreetAddress()
32
- * @method string getStreetSuburb()
33
- * @method string getStreetCity()
34
- * @method string getStreetState()
35
- * @method string getStreetPostode()
36
- * @method string getStreetCountry()
37
- * @method string getPostalAddress()
38
- * @method string getPostalSuburb()
39
- * @method string getPostalCity()
40
- * @method string getPostalState()
41
- * @method string getPostalPostcode()
42
- * @method string getPostalCountry()
43
- * @method string getPhone()
44
- * @method string getEmail()
45
- * @method string getWebsite()
46
- */
47
- class Temando_Temando_Model_Carrier extends Mage_Core_Model_Abstract
48
- {
49
-
50
- const FLAT_RATE = 'flat';
51
- const FREE = 'free';
52
-
53
- public function _construct()
54
- {
55
- parent::_construct();
56
- $this->_init('temando/carrier');
57
- }
58
-
59
- }
1
+ <?php
2
+
3
+ /**
4
+ * Carrier Model
5
+ *
6
+ * @package Temando_Temando
7
+ * @author Temando Magento Team <marketing@temando.com>
8
+ *
9
+ * @method Temando_Temando_Model_Carrier setCarrierId()
10
+ * @method Temando_Temando_Model_Carrier setCompanyName()
11
+ * @method Temando_Temando_Model_Carrier setCompanyContact()
12
+ * @method Temando_Temando_Model_Carrier setStreetAddress()
13
+ * @method Temando_Temando_Model_Carrier setStreetSuburb()
14
+ * @method Temando_Temando_Model_Carrier setStreetCity()
15
+ * @method Temando_Temando_Model_Carrier setStreetState()
16
+ * @method Temando_Temando_Model_Carrier setStreetPostode()
17
+ * @method Temando_Temando_Model_Carrier setStreetCountry()
18
+ * @method Temando_Temando_Model_Carrier setPostalAddress()
19
+ * @method Temando_Temando_Model_Carrier setPostalSuburb()
20
+ * @method Temando_Temando_Model_Carrier setPostalCity()
21
+ * @method Temando_Temando_Model_Carrier setPostalState()
22
+ * @method Temando_Temando_Model_Carrier setPostalPostcode()
23
+ * @method Temando_Temando_Model_Carrier setPostalCountry()
24
+ * @method Temando_Temando_Model_Carrier setPhone()
25
+ * @method Temando_Temando_Model_Carrier setEmail()
26
+ * @method Temando_Temando_Model_Carrier setWebsite()
27
+ *
28
+ * @method string getCarrierId()
29
+ * @method string getCompanyName()
30
+ * @method string getCompanyContact()
31
+ * @method string getStreetAddress()
32
+ * @method string getStreetSuburb()
33
+ * @method string getStreetCity()
34
+ * @method string getStreetState()
35
+ * @method string getStreetPostode()
36
+ * @method string getStreetCountry()
37
+ * @method string getPostalAddress()
38
+ * @method string getPostalSuburb()
39
+ * @method string getPostalCity()
40
+ * @method string getPostalState()
41
+ * @method string getPostalPostcode()
42
+ * @method string getPostalCountry()
43
+ * @method string getPhone()
44
+ * @method string getEmail()
45
+ * @method string getWebsite()
46
+ */
47
+ class Temando_Temando_Model_Carrier extends Mage_Core_Model_Abstract
48
+ {
49
+
50
+ const FLAT_RATE = 'flat';
51
+ const FREE = 'free';
52
+
53
+ public function _construct()
54
+ {
55
+ parent::_construct();
56
+ $this->_init('temando/carrier');
57
+ }
58
+
59
+ }
app/code/community/Temando/Temando/Model/Checkout/Delivery/Options.php CHANGED
@@ -1,79 +1,79 @@
1
- <?php
2
- /**
3
- * Checkout Delivery Options
4
- *
5
- * @package Temando_Temando
6
- * @author Temando Magento Team <marketing@temando.com>
7
- */
8
- class Temando_Temando_Model_Checkout_Delivery_Options extends Mage_Core_Model_Abstract
9
- {
10
-
11
- const DESTINATION_RESIDENCE = 'residence';
12
- const DESTINATION_BUSINESS = 'business';
13
-
14
- /**
15
- * All available delivery options
16
- * key must be the same as defined in system.xml
17
- */
18
- protected $_allOptions = array(
19
- self::DESTINATION_RESIDENCE => array(
20
- 'unattended_delivery' => 'Unattended delivery',
21
- ),
22
- self::DESTINATION_BUSINESS => array(
23
- )
24
- );
25
-
26
- /**
27
- * Delivery options enabled in system configuration
28
- *
29
- * @var array
30
- */
31
- protected $_enabledOptions = null;
32
-
33
-
34
- public function __construct()
35
- {
36
- parent::__construct();
37
- }
38
-
39
-
40
- /**
41
- * Returns enabled checkout options
42
- *
43
- * @return array
44
- */
45
- public function getEnabledOptions()
46
- {
47
- if (!$this->_enabledOptions) {
48
- foreach ($this->_allOptions as $destType => $options) {
49
- foreach ($options as $key => $description) {
50
- if ($this->getConfigData("checkout/{$key}")) {
51
- $this->_enabledOptions[$destType][$key] = $description;
52
- }
53
- }
54
- }
55
- }
56
- return $this->_enabledOptions;
57
- }
58
-
59
- /**
60
- * Return all available delivery options
61
- *
62
- * @return array
63
- */
64
- public function getAllOptions()
65
- {
66
- return $this->_allOptions;
67
- }
68
-
69
- /**
70
- * Retrieve Temando system configuration value
71
- *
72
- * @param string $field The identifier of config entry
73
- * @return mixed
74
- */
75
- public function getConfigData($field)
76
- {
77
- return Mage::helper('temando')->getConfigData($field);
78
- }
79
- }
1
+ <?php
2
+ /**
3
+ * Checkout Delivery Options
4
+ *
5
+ * @package Temando_Temando
6
+ * @author Temando Magento Team <marketing@temando.com>
7
+ */
8
+ class Temando_Temando_Model_Checkout_Delivery_Options extends Mage_Core_Model_Abstract
9
+ {
10
+
11
+ const DESTINATION_RESIDENCE = 'residence';
12
+ const DESTINATION_BUSINESS = 'business';
13
+
14
+ /**
15
+ * All available delivery options
16
+ * key must be the same as defined in system.xml
17
+ */
18
+ protected $_allOptions = array(
19
+ self::DESTINATION_RESIDENCE => array(
20
+ 'unattended_delivery' => 'Unattended delivery',
21
+ ),
22
+ self::DESTINATION_BUSINESS => array(
23
+ )
24
+ );
25
+
26
+ /**
27
+ * Delivery options enabled in system configuration
28
+ *
29
+ * @var array
30
+ */
31
+ protected $_enabledOptions = null;
32
+
33
+
34
+ public function __construct()
35
+ {
36
+ parent::__construct();
37
+ }
38
+
39
+
40
+ /**
41
+ * Returns enabled checkout options
42
+ *
43
+ * @return array
44
+ */
45
+ public function getEnabledOptions()
46
+ {
47
+ if (!$this->_enabledOptions) {
48
+ foreach ($this->_allOptions as $destType => $options) {
49
+ foreach ($options as $key => $description) {
50
+ if ($this->getConfigData("checkout/{$key}")) {
51
+ $this->_enabledOptions[$destType][$key] = $description;
52
+ }
53
+ }
54
+ }
55
+ }
56
+ return $this->_enabledOptions;
57
+ }
58
+
59
+ /**
60
+ * Return all available delivery options
61
+ *
62
+ * @return array
63
+ */
64
+ public function getAllOptions()
65
+ {
66
+ return $this->_allOptions;
67
+ }
68
+
69
+ /**
70
+ * Retrieve Temando system configuration value
71
+ *
72
+ * @param string $field The identifier of config entry
73
+ * @return mixed
74
+ */
75
+ public function getConfigData($field)
76
+ {
77
+ return Mage::helper('temando')->getConfigData($field);
78
+ }
79
+ }
app/code/community/Temando/Temando/Model/Endpoint.php ADDED
@@ -0,0 +1,191 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Endpoint Model
4
+ *
5
+ * @package Temando_Temando
6
+ * @author Temando Magento Team <marketing@temando.com>
7
+ *
8
+ * @method Temando_Temando_Model_Endpoint setOriginCountry()
9
+ *
10
+ * @method string getOriginCountry()
11
+ */
12
+
13
+ class Temando_Temando_Model_Endpoint extends Mage_Core_Model_Abstract
14
+ {
15
+ /**
16
+ * Temando Endpoint URL
17
+ */
18
+ const ENDPOINT_URL = 'https://discovery.temando.com/service/api';
19
+
20
+ /**
21
+ * Sandbox Mode
22
+ */
23
+ const ENDPOINT_MODE_SANDBOX = 'sandbox';
24
+
25
+ /**
26
+ * Staging Mode
27
+ */
28
+ const ENDPOINT_MODE_STAGING = 'staging';
29
+
30
+ /**
31
+ * Production Mode
32
+ */
33
+ const ENDPOINT_MODE_PRODUCTION = 'production';
34
+
35
+ /**
36
+ * Sandbox Wsdl
37
+ * @var string
38
+ */
39
+ protected $_apiSandbox;
40
+
41
+ /**
42
+ * Production Wsdl
43
+ * @var string
44
+ */
45
+ protected $_apiProduction;
46
+
47
+ /**
48
+ * The HTTP Client
49
+ * @var Varien_Http_Client
50
+ */
51
+ protected $_client = null;
52
+
53
+ /**
54
+ * Retrieve cache object
55
+ * @var Zend_Cache_Frontend_File
56
+ */
57
+ protected $_cache;
58
+
59
+
60
+ public function _construct()
61
+ {
62
+ parent::_construct();
63
+ $this->_prepareClient();
64
+ $this->_prepareCache();
65
+ }
66
+
67
+ /**
68
+ * Get the required sandbox endpoint
69
+ *
70
+ * @return string
71
+ */
72
+ public function getSandboxEndpoint()
73
+ {
74
+ if (!$this->_apiSandbox) {
75
+ $this->_apiSandbox = $this->getEndpoint(self::ENDPOINT_MODE_SANDBOX);
76
+ }
77
+ return $this->_apiSandbox;
78
+ }
79
+
80
+ /**
81
+ * Get the required production endpoint
82
+ *
83
+ * @return string
84
+ */
85
+ public function getProductionEndpoint()
86
+ {
87
+ if (!$this->_apiProduction) {
88
+ $this->_apiProduction = $this->getEndpoint(self::ENDPOINT_MODE_PRODUCTION);
89
+ }
90
+ return $this->_apiProduction;
91
+ }
92
+
93
+ /**
94
+ * Return the endpoint based on the mode
95
+ *
96
+ * @param string $mode
97
+ * @return string|boolean
98
+ */
99
+ public function getEndpoint($mode)
100
+ {
101
+ if (!$this->getOriginCountry()) {
102
+ return false;
103
+ }
104
+ if (!$endpoints = $this->loadEndpoints()) {
105
+ return false;
106
+ }
107
+ if (isset($endpoints[$this->getOriginCountry()][$mode])) {
108
+ return $endpoints[$this->getOriginCountry()][$mode];
109
+ }
110
+ return false;
111
+ }
112
+
113
+ /**
114
+ * Load the endpoints from the cache or api
115
+ *
116
+ * @return array|boolean
117
+ */
118
+ public function loadEndpoints()
119
+ {
120
+ if ($this->_cache->load('temando_endpoints')) {
121
+ return unserialize($this->_cache->load('temando_endpoints'));
122
+ }
123
+ $endpoints = $this->getEndpoints();
124
+ if (!empty($endpoints)) {
125
+ $this->saveEndpoints($endpoints);
126
+ return $endpoints;
127
+ }
128
+ return false;
129
+ }
130
+
131
+ /**
132
+ * Get all of the endpoints from the api
133
+ *
134
+ * @return array
135
+ */
136
+ public function getEndpoints()
137
+ {
138
+ try {
139
+ $this->_client->setUri(self::ENDPOINT_URL);
140
+ $rawBody = $this->_client->request(Varien_Http_Client::GET)->getRawBody();
141
+ return Mage::helper('core')->jsonDecode($rawBody, true);
142
+ } catch (Exception $e) {
143
+ Mage::log($e->getMessage(), null, 'temando-endpoints.log', true);
144
+ return array();
145
+ }
146
+ }
147
+
148
+ /**
149
+ * Save the endpoint array in the cache
150
+ *
151
+ * @param array $endpoints
152
+ */
153
+ protected function saveEndpoints($endpoints)
154
+ {
155
+ if (!is_array($endpoints)) {
156
+ return;
157
+ }
158
+ try {
159
+ $this->_cache->save(serialize($endpoints), 'temando_endpoints', array('temando_cache'));
160
+ } catch (Exception $e) {
161
+ Mage::log($e->getMessage(), null, 'temando-endpoints.log', true);
162
+ }
163
+ }
164
+
165
+ /**
166
+ * Initializes http client to communicate with Endpoint service
167
+ *
168
+ * @return \Temando_Temando_Model_Endpoint
169
+ */
170
+ protected function _prepareClient()
171
+ {
172
+ if (!$this->_client) {
173
+ $this->_client = new Varien_Http_Client();
174
+ $this->_client->setConfig(array('maxredirects' => 0, 'timeout' => 15));
175
+ }
176
+ return $this;
177
+ }
178
+
179
+ /**
180
+ * Initializes the cache
181
+ *
182
+ * @return \Temando_Temando_Model_Endpoint
183
+ */
184
+ protected function _prepareCache()
185
+ {
186
+ if (!$this->_cache) {
187
+ $this->_cache = Mage::app()->getCache();
188
+ }
189
+ return $this;
190
+ }
191
+ }
app/code/community/Temando/Temando/Model/Entity/Attribute/Source/Packaging.php CHANGED
@@ -1,68 +1,68 @@
1
- <?php
2
- /**
3
- * Entity Attribute Source Packaging
4
- *
5
- * @package Temando_Temando
6
- * @author Temando Magento Team <marketing@temando.com>
7
- */
8
- class Temando_Temando_Model_Entity_Attribute_Source_Packaging extends Mage_Eav_Model_Entity_Attribute_Source_Abstract
9
- {
10
-
11
- public function getAllOptions()
12
- {
13
- if (is_null($this->_options)) {
14
- $this->_options = Mage::getModel('temando/system_config_source_shipment_packaging')->toOptionArray();
15
- }
16
- return $this->_options;
17
- }
18
-
19
- /**
20
- * Retrieve Column(s) for Flat
21
- *
22
- * @return array
23
- */
24
- public function getFlatColums()
25
- {
26
- $columns = array();
27
- $columns[$this->getAttribute()->getAttributeCode()] = array(
28
- 'type' => 'int(11)',
29
- 'unsigned' => true,
30
- 'is_null' => true,
31
- 'default' => null,
32
- 'extra' => null
33
- );
34
-
35
- return $columns;
36
- }
37
-
38
- /**
39
- * Retrieve Indexes(s) for Flat
40
- *
41
- * @return array
42
- */
43
- public function getFlatIndexes()
44
- {
45
- $indexes = array();
46
-
47
- $index = 'IDX_' . strtoupper($this->getAttribute()->getAttributeCode());
48
- $indexes[$index] = array(
49
- 'type' => 'index',
50
- 'fields' => array($this->getAttribute()->getAttributeCode())
51
- );
52
-
53
- return $indexes;
54
- }
55
-
56
- /**
57
- * Retrieve Select For Flat Attribute update
58
- *
59
- * @param int $store
60
- * @return Varien_Db_Select|null
61
- */
62
- public function getFlatUpdateSelect($store)
63
- {
64
- return Mage::getResourceModel('eav/entity_attribute')
65
- ->getFlatUpdateSelect($this->getAttribute(), $store);
66
- }
67
-
68
- }
1
+ <?php
2
+ /**
3
+ * Entity Attribute Source Packaging
4
+ *
5
+ * @package Temando_Temando
6
+ * @author Temando Magento Team <marketing@temando.com>
7
+ */
8
+ class Temando_Temando_Model_Entity_Attribute_Source_Packaging extends Mage_Eav_Model_Entity_Attribute_Source_Abstract
9
+ {
10
+
11
+ public function getAllOptions()
12
+ {
13
+ if (is_null($this->_options)) {
14
+ $this->_options = Mage::getModel('temando/system_config_source_shipment_packaging')->toOptionArray();
15
+ }
16
+ return $this->_options;
17
+ }
18
+
19
+ /**
20
+ * Retrieve Column(s) for Flat
21
+ *
22
+ * @return array
23
+ */
24
+ public function getFlatColums()
25
+ {
26
+ $columns = array();
27
+ $columns[$this->getAttribute()->getAttributeCode()] = array(
28
+ 'type' => 'int(11)',
29
+ 'unsigned' => true,
30
+ 'is_null' => true,
31
+ 'default' => null,
32
+ 'extra' => null
33
+ );
34
+
35
+ return $columns;
36
+ }
37
+
38
+ /**
39
+ * Retrieve Indexes(s) for Flat
40
+ *
41
+ * @return array
42
+ */
43
+ public function getFlatIndexes()
44
+ {
45
+ $indexes = array();
46
+
47
+ $index = 'IDX_' . strtoupper($this->getAttribute()->getAttributeCode());
48
+ $indexes[$index] = array(
49
+ 'type' => 'index',
50
+ 'fields' => array($this->getAttribute()->getAttributeCode())
51
+ );
52
+
53
+ return $indexes;
54
+ }
55
+
56
+ /**
57
+ * Retrieve Select For Flat Attribute update
58
+ *
59
+ * @param int $store
60
+ * @return Varien_Db_Select|null
61
+ */
62
+ public function getFlatUpdateSelect($store)
63
+ {
64
+ return Mage::getResourceModel('eav/entity_attribute')
65
+ ->getFlatUpdateSelect($this->getAttribute(), $store);
66
+ }
67
+
68
+ }
app/code/community/Temando/Temando/Model/Entity/Attribute/Source/Packaging/Mode.php CHANGED
@@ -1,68 +1,68 @@
1
- <?php
2
- /**
3
- * Entity Attribute Source Packaging Mode
4
- *
5
- * @package Temando_Temando
6
- * @author Temando Magento Team <marketing@temando.com>
7
- */
8
- class Temando_Temando_Model_Entity_Attribute_Source_Packaging_Mode
9
- extends Mage_Eav_Model_Entity_Attribute_Source_Abstract
10
- {
11
-
12
- public function getAllOptions()
13
- {
14
- if (is_null($this->_options)) {
15
- $this->_options = Mage::getModel('temando/system_config_source_shipment_packaging_mode')->toOptionArray();
16
- }
17
- return $this->_options;
18
- }
19
-
20
- /**
21
- * Retrieve Column(s) for Flat
22
- *
23
- * @return array
24
- */
25
- public function getFlatColums()
26
- {
27
- $columns = array();
28
- $columns[$this->getAttribute()->getAttributeCode()] = array(
29
- 'type' => 'int(11)',
30
- 'unsigned' => true,
31
- 'is_null' => true,
32
- 'default' => null,
33
- 'extra' => null
34
- );
35
-
36
- return $columns;
37
- }
38
-
39
- /**
40
- * Retrieve Indexes(s) for Flat
41
- *
42
- * @return array
43
- */
44
- public function getFlatIndexes()
45
- {
46
- $indexes = array();
47
-
48
- $index = 'IDX_' . strtoupper($this->getAttribute()->getAttributeCode());
49
- $indexes[$index] = array(
50
- 'type' => 'index',
51
- 'fields' => array($this->getAttribute()->getAttributeCode())
52
- );
53
-
54
- return $indexes;
55
- }
56
-
57
- /**
58
- * Retrieve Select For Flat Attribute update
59
- *
60
- * @param int $store
61
- * @return Varien_Db_Select|null
62
- */
63
- public function getFlatUpdateSelect($store)
64
- {
65
- return Mage::getResourceModel('eav/entity_attribute')
66
- ->getFlatUpdateSelect($this->getAttribute(), $store);
67
- }
68
- }
1
+ <?php
2
+ /**
3
+ * Entity Attribute Source Packaging Mode
4
+ *
5
+ * @package Temando_Temando
6
+ * @author Temando Magento Team <marketing@temando.com>
7
+ */
8
+ class Temando_Temando_Model_Entity_Attribute_Source_Packaging_Mode
9
+ extends Mage_Eav_Model_Entity_Attribute_Source_Abstract
10
+ {
11
+
12
+ public function getAllOptions()
13
+ {
14
+ if (is_null($this->_options)) {
15
+ $this->_options = Mage::getModel('temando/system_config_source_shipment_packaging_mode')->toOptionArray();
16
+ }
17
+ return $this->_options;
18
+ }
19
+
20
+ /**
21
+ * Retrieve Column(s) for Flat
22
+ *
23
+ * @return array
24
+ */
25
+ public function getFlatColums()
26
+ {
27
+ $columns = array();
28
+ $columns[$this->getAttribute()->getAttributeCode()] = array(
29
+ 'type' => 'int(11)',
30
+ 'unsigned' => true,
31
+ 'is_null' => true,
32
+ 'default' => null,
33
+ 'extra' => null
34
+ );
35
+
36
+ return $columns;
37
+ }
38
+
39
+ /**
40
+ * Retrieve Indexes(s) for Flat
41
+ *
42
+ * @return array
43
+ */
44
+ public function getFlatIndexes()
45
+ {
46
+ $indexes = array();
47
+
48
+ $index = 'IDX_' . strtoupper($this->getAttribute()->getAttributeCode());
49
+ $indexes[$index] = array(
50
+ 'type' => 'index',
51
+ 'fields' => array($this->getAttribute()->getAttributeCode())
52
+ );
53
+
54
+ return $indexes;
55
+ }
56
+
57
+ /**
58
+ * Retrieve Select For Flat Attribute update
59
+ *
60
+ * @param int $store
61
+ * @return Varien_Db_Select|null
62
+ */
63
+ public function getFlatUpdateSelect($store)
64
+ {
65
+ return Mage::getResourceModel('eav/entity_attribute')
66
+ ->getFlatUpdateSelect($this->getAttribute(), $store);
67
+ }
68
+ }
app/code/community/Temando/Temando/Model/Manifest.php CHANGED
@@ -1,17 +1,16 @@
1
- <?php
2
- /**
3
- * Manifest Model
4
- *
5
- * @package Temando_Temando
6
- * @author Temando Magento Team <marketing@temando.com>
7
- */
8
- class Temando_Temando_Model_Manifest extends Mage_Core_Model_Abstract
9
- {
10
-
11
- public function _construct()
12
- {
13
- parent::_construct();
14
- $this->_init('temando/manifest');
15
- }
16
-
17
- }
1
+ <?php
2
+ /**
3
+ * Manifest Model
4
+ *
5
+ * @package Temando_Temando
6
+ * @author Temando Magento Team <marketing@temando.com>
7
+ */
8
+ class Temando_Temando_Model_Manifest extends Mage_Core_Model_Abstract
9
+ {
10
+
11
+ public function _construct()
12
+ {
13
+ parent::_construct();
14
+ $this->_init('temando/manifest');
15
+ }
16
+ }
 
app/code/community/Temando/Temando/Model/Mysql4/Box.php CHANGED
@@ -1,16 +1,16 @@
1
- <?php
2
- /**
3
- * Mysql4 Box
4
- *
5
- * @package Temando_Temando
6
- * @author Temando Magento Team <marketing@temando.com>
7
- */
8
- class Temando_Temando_Model_Mysql4_Box extends Mage_Core_Model_Mysql4_Abstract
9
- {
10
-
11
- public function _construct()
12
- {
13
- $this->_init('temando/box', 'id');
14
- }
15
-
16
- }
1
+ <?php
2
+ /**
3
+ * Mysql4 Box
4
+ *
5
+ * @package Temando_Temando
6
+ * @author Temando Magento Team <marketing@temando.com>
7
+ */
8
+ class Temando_Temando_Model_Mysql4_Box extends Mage_Core_Model_Mysql4_Abstract
9
+ {
10
+
11
+ public function _construct()
12
+ {
13
+ $this->_init('temando/box', 'id');
14
+ }
15
+
16
+ }
app/code/community/Temando/Temando/Model/Mysql4/Box/Collection.php CHANGED
@@ -1,18 +1,18 @@
1
- <?php
2
- /**
3
- * Mysql4 Box Collection
4
- *
5
- * @package Temando_Temando
6
- * @author Temando Magento Team <marketing@temando.com>
7
- */
8
- class Temando_Temando_Model_Mysql4_Box_Collection
9
- extends Mage_Core_Model_Mysql4_Collection_Abstract
10
- {
11
-
12
- public function _construct()
13
- {
14
- parent::_construct();
15
- $this->_init('temando/box');
16
- }
17
-
18
- }
1
+ <?php
2
+ /**
3
+ * Mysql4 Box Collection
4
+ *
5
+ * @package Temando_Temando
6
+ * @author Temando Magento Team <marketing@temando.com>
7
+ */
8
+ class Temando_Temando_Model_Mysql4_Box_Collection
9
+ extends Mage_Core_Model_Mysql4_Collection_Abstract
10
+ {
11
+
12
+ public function _construct()
13
+ {
14
+ parent::_construct();
15
+ $this->_init('temando/box');
16
+ }
17
+
18
+ }
app/code/community/Temando/Temando/Model/Mysql4/Carrier.php CHANGED
@@ -1,17 +1,17 @@
1
- <?php
2
- /**
3
- * Mysql4 Carrier
4
- *
5
- * @package Temando_Temando
6
- * @author Temando Magento Team <marketing@temando.com>
7
- */
8
- class Temando_Temando_Model_Mysql4_Carrier
9
- extends Mage_Core_Model_Mysql4_Abstract
10
- {
11
-
12
- public function _construct()
13
- {
14
- $this->_init('temando/carrier', 'id');
15
- }
16
-
17
- }
1
+ <?php
2
+ /**
3
+ * Mysql4 Carrier
4
+ *
5
+ * @package Temando_Temando
6
+ * @author Temando Magento Team <marketing@temando.com>
7
+ */
8
+ class Temando_Temando_Model_Mysql4_Carrier
9
+ extends Mage_Core_Model_Mysql4_Abstract
10
+ {
11
+
12
+ public function _construct()
13
+ {
14
+ $this->_init('temando/carrier', 'id');
15
+ }
16
+
17
+ }
app/code/community/Temando/Temando/Model/Mysql4/Carrier/Collection.php CHANGED
@@ -1,18 +1,18 @@
1
- <?php
2
- /**
3
- * Mysql4 Carrier Collection
4
- *
5
- * @package Temando_Temando
6
- * @author Temando Magento Team <marketing@temando.com>
7
- */
8
- class Temando_Temando_Model_Mysql4_Carrier_Collection
9
- extends Mage_Core_Model_Mysql4_Collection_Abstract
10
- {
11
-
12
- public function _construct()
13
- {
14
- parent::_construct();
15
- $this->_init('temando/carrier');
16
- }
17
-
18
- }
1
+ <?php
2
+ /**
3
+ * Mysql4 Carrier Collection
4
+ *
5
+ * @package Temando_Temando
6
+ * @author Temando Magento Team <marketing@temando.com>
7
+ */
8
+ class Temando_Temando_Model_Mysql4_Carrier_Collection
9
+ extends Mage_Core_Model_Mysql4_Collection_Abstract
10
+ {
11
+
12
+ public function _construct()
13
+ {
14
+ parent::_construct();
15
+ $this->_init('temando/carrier');
16
+ }
17
+
18
+ }
app/code/community/Temando/Temando/Model/Mysql4/Manifest.php CHANGED
@@ -1,17 +1,17 @@
1
- <?php
2
- /**
3
- * Mysql4 Manifest
4
- *
5
- * @package Temando_Temando
6
- * @author Temando Magento Team <marketing@temando.com>
7
- */
8
- class Temando_Temando_Model_Mysql4_Manifest
9
- extends Mage_Core_Model_Mysql4_Abstract
10
- {
11
-
12
- public function _construct()
13
- {
14
- $this->_init('temando/manifest', 'id');
15
- }
16
-
17
- }
1
+ <?php
2
+ /**
3
+ * Mysql4 Manifest
4
+ *
5
+ * @package Temando_Temando
6
+ * @author Temando Magento Team <marketing@temando.com>
7
+ */
8
+ class Temando_Temando_Model_Mysql4_Manifest
9
+ extends Mage_Core_Model_Mysql4_Abstract
10
+ {
11
+
12
+ public function _construct()
13
+ {
14
+ $this->_init('temando/manifest', 'id');
15
+ }
16
+
17
+ }
app/code/community/Temando/Temando/Model/Mysql4/Manifest/Collection.php CHANGED
@@ -1,18 +1,18 @@
1
- <?php
2
- /**
3
- * Mysql4 Manifest Collection
4
- *
5
- * @package Temando_Temando
6
- * @author Temando Magento Team <marketing@temando.com>
7
- */
8
- class Temando_Temando_Model_Mysql4_Manifest_Collection
9
- extends Mage_Core_Model_Mysql4_Collection_Abstract
10
- {
11
-
12
- public function _construct()
13
- {
14
- parent::_construct();
15
- $this->_init('temando/manifest');
16
- }
17
-
18
- }
1
+ <?php
2
+ /**
3
+ * Mysql4 Manifest Collection
4
+ *
5
+ * @package Temando_Temando
6
+ * @author Temando Magento Team <marketing@temando.com>
7
+ */
8
+ class Temando_Temando_Model_Mysql4_Manifest_Collection
9
+ extends Mage_Core_Model_Mysql4_Collection_Abstract
10
+ {
11
+
12
+ public function _construct()
13
+ {
14
+ parent::_construct();
15
+ $this->_init('temando/manifest');
16
+ }
17
+
18
+ }
app/code/community/Temando/Temando/Model/Mysql4/Quote.php CHANGED
@@ -1,16 +1,16 @@
1
- <?php
2
- /**
3
- * Mysql4 Quote
4
- *
5
- * @package Temando_Temando
6
- * @author Temando Magento Team <marketing@temando.com>
7
- */
8
- class Temando_Temando_Model_Mysql4_Quote extends Mage_Core_Model_Mysql4_Abstract
9
- {
10
-
11
- public function _construct()
12
- {
13
- $this->_init('temando/quote', 'id');
14
- }
15
-
16
- }
1
+ <?php
2
+ /**
3
+ * Mysql4 Quote
4
+ *
5
+ * @package Temando_Temando
6
+ * @author Temando Magento Team <marketing@temando.com>
7
+ */
8
+ class Temando_Temando_Model_Mysql4_Quote extends Mage_Core_Model_Mysql4_Abstract
9
+ {
10
+
11
+ public function _construct()
12
+ {
13
+ $this->_init('temando/quote', 'id');
14
+ }
15
+
16
+ }
app/code/community/Temando/Temando/Model/Mysql4/Quote/Collection.php CHANGED
@@ -1,132 +1,132 @@
1
- <?php
2
- /**
3
- * Mysql4 Quote Collection
4
- *
5
- * @package Temando_Temando
6
- * @author Temando Magento Team <marketing@temando.com>
7
- */
8
- class Temando_Temando_Model_Mysql4_Quote_Collection extends Mage_Core_Model_Mysql4_Collection_Abstract
9
- {
10
-
11
- protected $_options = null;
12
-
13
- public function _construct()
14
- {
15
- parent::_construct();
16
- $this->_init('temando/quote');
17
- }
18
-
19
- public function __clone()
20
- {
21
- $this->load();
22
- $new_items = array();
23
- foreach ($this->_items as $item) {
24
- $new_items[] = clone $item;
25
- }
26
- $this->_items = $new_items;
27
- }
28
-
29
- /**
30
- * Gets the fastest quote in the collection.
31
- *
32
- * Because quotes' ETAs are specified as a range (e.g. "1-4 days"), the
33
- * average of the range is used to make the comparison.
34
- *
35
- * @return Temando_Temando_Model_Quote
36
- */
37
- public function getFastest()
38
- {
39
- $fastest = null;
40
- foreach ($this->_items as $item) {
41
- $fastest = $this->_getFaster($item, $fastest);
42
- }
43
- return $fastest;
44
- }
45
-
46
- /**
47
- * Returns the faster of two quotes.
48
- *
49
- * Because quotes' ETAs are specified as a range (e.g. "1-4 days"), the
50
- * average of the range is used to make the comparison.
51
- *
52
- * If one is null, the other is returned. If both are the same average
53
- * speed, the first quote is returned.
54
- *
55
- * @param Temando_Temando_Model_Quote $a the first quote.
56
- * @param Temando_Temando_Model_Quote $b the second quote.
57
- *
58
- * @return Temando_Temando_Model_Quote
59
- */
60
- protected function _getFaster($a, $b)
61
- {
62
- // if one is null, return the other.
63
- if (is_null($a)) {
64
- return $b;
65
- }
66
- if (is_null($b)) {
67
- return $a;
68
- }
69
-
70
- // average ETA
71
- $a_eta = ($a->getEtaFrom() + $a->getEtaTo()) / 2;
72
- $b_eta = ($b->getEtaFrom() + $b->getEtaTo()) / 2;
73
-
74
- if ($a_eta != $b_eta) {
75
- // different speed, return faster
76
- return $a_eta <= $b_eta ? $a : $b;
77
- } else {
78
- // same speed, return cheaper
79
- return $this->_getCheaper($a, $b);
80
- }
81
- }
82
-
83
- /**
84
- * Gets the cheapest quote in the collection.
85
- *
86
- * @return Temando_Temando_Model_Quote
87
- */
88
- public function getCheapest()
89
- {
90
- $cheapest = null;
91
- foreach ($this->_items as $item) {
92
- $cheapest = $this->_getCheaper($item, $cheapest);
93
- }
94
- return $cheapest;
95
- }
96
-
97
- /**
98
- * Returns the cheaper of two quotes.
99
- *
100
- * If one is null, the other is returned. If both are the same price, the
101
- * first quote is returned.
102
- *
103
- * @param Temando_Temando_Model_Quote $a the first quote.
104
- * @param Temando_Temando_Model_Quote $b the second quote.
105
- *
106
- * @return Temando_Temando_Model_Quote
107
- */
108
- protected function _getCheaper($a, $b)
109
- {
110
- // if one is null, return the other (if both are null, null is returned).
111
- if (is_null($a)) {
112
- return $b;
113
- }
114
- if (is_null($b)) {
115
- return $a;
116
- }
117
-
118
- return $a->getTotalPrice() <= $b->getTotalPrice() ? $a : $b;
119
- }
120
-
121
- /**
122
- * Don't try to load the collection if specific items have been added.
123
- *
124
- * @see Varien_Data_Collection::addItem()
125
- */
126
- public function addItem(Varien_Object $item)
127
- {
128
- $this->_setIsLoaded();
129
- return parent::addItem($item);
130
- }
131
-
132
- }
1
+ <?php
2
+ /**
3
+ * Mysql4 Quote Collection
4
+ *
5
+ * @package Temando_Temando
6
+ * @author Temando Magento Team <marketing@temando.com>
7
+ */
8
+ class Temando_Temando_Model_Mysql4_Quote_Collection extends Mage_Core_Model_Mysql4_Collection_Abstract
9
+ {
10
+
11
+ protected $_options = null;
12
+
13
+ public function _construct()
14
+ {
15
+ parent::_construct();
16
+ $this->_init('temando/quote');
17
+ }
18
+
19
+ public function __clone()
20
+ {
21
+ $this->load();
22
+ $new_items = array();
23
+ foreach ($this->_items as $item) {
24
+ $new_items[] = clone $item;
25
+ }
26
+ $this->_items = $new_items;
27
+ }
28
+
29
+ /**
30
+ * Gets the fastest quote in the collection.
31
+ *
32
+ * Because quotes' ETAs are specified as a range (e.g. "1-4 days"), the
33
+ * average of the range is used to make the comparison.
34
+ *
35
+ * @return Temando_Temando_Model_Quote
36
+ */
37
+ public function getFastest()
38
+ {
39
+ $fastest = null;
40
+ foreach ($this->_items as $item) {
41
+ $fastest = $this->_getFaster($item, $fastest);
42
+ }
43
+ return $fastest;
44
+ }
45
+
46
+ /**
47
+ * Returns the faster of two quotes.
48
+ *
49
+ * Because quotes' ETAs are specified as a range (e.g. "1-4 days"), the
50
+ * average of the range is used to make the comparison.
51
+ *
52
+ * If one is null, the other is returned. If both are the same average
53
+ * speed, the first quote is returned.
54
+ *
55
+ * @param Temando_Temando_Model_Quote $a the first quote.
56
+ * @param Temando_Temando_Model_Quote $b the second quote.
57
+ *
58
+ * @return Temando_Temando_Model_Quote
59
+ */
60
+ protected function _getFaster($a, $b)
61
+ {
62
+ // if one is null, return the other.
63
+ if (is_null($a)) {
64
+ return $b;
65
+ }
66
+ if (is_null($b)) {
67
+ return $a;
68
+ }
69
+
70
+ // average ETA
71
+ $a_eta = ($a->getEtaFrom() + $a->getEtaTo()) / 2;
72
+ $b_eta = ($b->getEtaFrom() + $b->getEtaTo()) / 2;
73
+
74
+ if ($a_eta != $b_eta) {
75
+ // different speed, return faster
76
+ return $a_eta <= $b_eta ? $a : $b;
77
+ } else {
78
+ // same speed, return cheaper
79
+ return $this->_getCheaper($a, $b);
80
+ }
81
+ }
82
+
83
+ /**
84
+ * Gets the cheapest quote in the collection.
85
+ *
86
+ * @return Temando_Temando_Model_Quote
87
+ */
88
+ public function getCheapest()
89
+ {
90
+ $cheapest = null;
91
+ foreach ($this->_items as $item) {
92
+ $cheapest = $this->_getCheaper($item, $cheapest);
93
+ }
94
+ return $cheapest;
95
+ }
96
+
97
+ /**
98
+ * Returns the cheaper of two quotes.
99
+ *
100
+ * If one is null, the other is returned. If both are the same price, the
101
+ * first quote is returned.
102
+ *
103
+ * @param Temando_Temando_Model_Quote $a the first quote.
104
+ * @param Temando_Temando_Model_Quote $b the second quote.
105
+ *
106
+ * @return Temando_Temando_Model_Quote
107
+ */
108
+ protected function _getCheaper($a, $b)
109
+ {
110
+ // if one is null, return the other (if both are null, null is returned).
111
+ if (is_null($a)) {
112
+ return $b;
113
+ }
114
+ if (is_null($b)) {
115
+ return $a;
116
+ }
117
+
118
+ return $a->getTotalPrice() <= $b->getTotalPrice() ? $a : $b;
119
+ }
120
+
121
+ /**
122
+ * Don't try to load the collection if specific items have been added.
123
+ *
124
+ * @see Varien_Data_Collection::addItem()
125
+ */
126
+ public function addItem(Varien_Object $item)
127
+ {
128
+ $this->_setIsLoaded();
129
+ return parent::addItem($item);
130
+ }
131
+
132
+ }
app/code/community/Temando/Temando/Model/Mysql4/Shipment.php CHANGED
@@ -1,16 +1,16 @@
1
- <?php
2
- /**
3
- * Mysql4 Shipment
4
- *
5
- * @package Temando_Temando
6
- * @author Temando Magento Team <marketing@temando.com>
7
- */
8
- class Temando_Temando_Model_Mysql4_Shipment extends Mage_Core_Model_Mysql4_Abstract
9
- {
10
-
11
- public function _construct()
12
- {
13
- $this->_init('temando/shipment', 'id');
14
- }
15
-
16
- }
1
+ <?php
2
+ /**
3
+ * Mysql4 Shipment
4
+ *
5
+ * @package Temando_Temando
6
+ * @author Temando Magento Team <marketing@temando.com>
7
+ */
8
+ class Temando_Temando_Model_Mysql4_Shipment extends Mage_Core_Model_Mysql4_Abstract
9
+ {
10
+
11
+ public function _construct()
12
+ {
13
+ $this->_init('temando/shipment', 'id');
14
+ }
15
+
16
+ }
app/code/community/Temando/Temando/Model/Mysql4/Shipment/Collection.php CHANGED
@@ -1,36 +1,39 @@
1
- <?php
2
- /**
3
- * Mysql4 Shipment Collection
4
- *
5
- * @package Temando_Temando
6
- * @author Temando Magento Team <marketing@temando.com>
7
- */
8
- class Temando_Temando_Model_Mysql4_Shipment_Collection
9
- extends Mage_Core_Model_Mysql4_Collection_Abstract
10
- {
11
-
12
- public function _construct()
13
- {
14
- parent::_construct();
15
- $this->_init('temando/shipment');
16
- }
17
-
18
- /**
19
- * Returns the shipment associated to an order or null if none
20
- *
21
- * NO SUPPORT FOR PARTIAL-SHIPMENTS HERE; ONLY 1 IS RETURNED
22
- *
23
- * @param string $orderId
24
- * @return null|\Temando_Temando_Model_Shipment
25
- */
26
- public function loadByOrderId($orderId)
27
- {
28
- if(!$orderId) return false;
29
-
30
- $this->addFieldToFilter('order_id', $orderId)->load();
31
- if($this->count())
32
- return $this->getFirstItem ();
33
-
34
- return false;
35
- }
36
- }
 
 
 
1
+ <?php
2
+ /**
3
+ * Mysql4 Shipment Collection
4
+ *
5
+ * @package Temando_Temando
6
+ * @author Temando Magento Team <marketing@temando.com>
7
+ */
8
+ class Temando_Temando_Model_Mysql4_Shipment_Collection
9
+ extends Mage_Core_Model_Mysql4_Collection_Abstract
10
+ {
11
+
12
+ public function _construct()
13
+ {
14
+ parent::_construct();
15
+ $this->_init('temando/shipment');
16
+ }
17
+
18
+ /**
19
+ * Returns the shipment associated to an order or null if none
20
+ *
21
+ * NO SUPPORT FOR PARTIAL-SHIPMENTS HERE; ONLY 1 IS RETURNED
22
+ *
23
+ * @param string $orderId
24
+ * @return null|\Temando_Temando_Model_Shipment
25
+ */
26
+ public function loadByOrderId($orderId)
27
+ {
28
+ if (!$orderId) {
29
+ return false;
30
+ }
31
+
32
+ $this->addFieldToFilter('order_id', $orderId)->load();
33
+ if ($this->count()) {
34
+ return $this->getFirstItem();
35
+ }
36
+
37
+ return false;
38
+ }
39
+ }
app/code/community/Temando/Temando/Model/Observer.php CHANGED
@@ -1,185 +1,195 @@
1
- <?php
2
- /**
3
- * Temando Observer
4
- *
5
- * @package Temando_Temando
6
- * @author Temando Magento Team <marketing@temando.com>
7
- */
8
- class Temando_Temando_Model_Observer
9
- {
10
-
11
- /**
12
- * Handles sales_order_place_after event
13
- */
14
- public function createTemandoShipment(Varien_Event_Observer $observer)
15
- {
16
- $order = $observer->getOrder();
17
- /* @var $order Mage_Sales_Model_Order */
18
-
19
- $shippingMethod = $order->getShippingMethod();
20
- $__t = explode('_', $shippingMethod);
21
- if ($__t[0] != 'temando') {
22
- return;
23
- }
24
-
25
- //prepare data from request/session
26
- $destinationType = Mage::getSingleton('checkout/session')->getData('destination_type');
27
- $delivery_options = Mage::getSingleton('checkout/session')->getData('selected_delivery_options');
28
- if (!is_array($delivery_options)) {
29
- $delivery_options = array();
30
- }
31
-
32
- $selected_quote_id = preg_replace('#^[^_]*_#', '', $shippingMethod);
33
- $selected_options = preg_replace('#^([^_]*_){2}#', '', $shippingMethod);
34
-
35
- $selected_quote = Mage::getModel('temando/quote')->load($selected_quote_id);
36
- if(!$selected_quote->getId()) {
37
- //try loading cheapeast quote
38
- try {
39
- $selected_quote = $this->loadCheapestQuote($order, $delivery_options, $destinationType);
40
- /* @var $selected_quote Temando_Temando_Model_Quote */
41
- } catch (Exception $e) {
42
- $selected_quote = null;
43
- }
44
- }
45
-
46
- $temando_shipment = Mage::getModel('temando/shipment');
47
- /* @var $temando_shipment Temando_Temando_Model_Shipment */
48
-
49
- if(Mage::helper('temando')->isQuoteDynamic($selected_quote_id)) {
50
- //DYNAMIC: carrier quote selected by customer - must have at least 1 available quote
51
- $temando_shipment
52
- ->setAdminSelectedQuoteId($selected_quote->getId())
53
- ->setCustomerSelectedQuoteId($selected_quote->getId())
54
- ->setCustomerSelectedOptions($selected_options);
55
- $selected_quote = $temando_shipment->getSelectedQuotePermutation();
56
- $temando_shipment
57
- ->setCustomerSelectedQuoteDescription($selected_quote->getDescription())
58
- ->setAnticipatedCost($selected_quote->getTotalPrice());
59
-
60
- } else {
61
- //STATIC: flat rate / free shipping selected by customer
62
- $temando_shipment
63
- ->setCustomerSelectedQuoteDescription($selected_quote_id == Temando_Temando_Model_Carrier::FLAT_RATE ? Mage::helper('temando')->__('Flat Rate') : Mage::helper('temando')->__('Free Shipping'))
64
- ->setCustomerSelectedOptions('insurance_N_carbonoffset_N_footprints_N');
65
-
66
- if($selected_quote instanceof Temando_Temando_Model_Quote) {
67
- //set cheapest as admin selected
68
- $temando_shipment->setAdminSelectedQuoteId($selected_quote->getId())
69
- ->setAnticipatedCost($selected_quote->getTotalPrice());
70
- }
71
- }
72
-
73
- $email = $order->getShippingAddress()->getEmail();
74
- if(!$email) {
75
- $email = $order->getCustomerEmail();
76
- }
77
-
78
- $temando_shipment
79
- ->setOrderId($order->getId() ? $order->getId() : null)
80
- ->setStatus(Temando_Temando_Model_System_Config_Source_Shipment_Status::PENDING)
81
- ->setDestinationContactName($order->getShippingAddress()->getName())
82
- ->setDestinationCompanyName($order->getShippingAddress()->getCompany())
83
- ->setDestinationStreet(str_replace("\n", ', ', $order->getShippingAddress()->getStreetFull()))
84
- ->setDestinationRegion($order->getShippingAddress()->getRegionCode())
85
- ->setDestinationPhone($order->getShippingAddress()->getTelephone())
86
- ->setDestinationEmail($email)
87
- ->setDestinationType(
88
- $destinationType ? $destinationType :
89
- Temando_Temando_Model_Checkout_Delivery_Options::DESTINATION_RESIDENCE
90
- )
91
- ->setDestinationCountry($order->getShippingAddress()->getCountryId())
92
- ->setDestinationPostcode($order->getShippingAddress()->getPostcode())
93
- ->setDestinationCity($order->getShippingAddress()->getCity())
94
- ->setReadyTime('AM')
95
- ->setCustomerSelectedDeliveryOptions(implode(',', array_keys($delivery_options)))
96
- ->save();
97
-
98
- foreach ($order->getAllVisibleItems() as $item) {
99
- $product = Mage::getModel('catalog/product')->load($item->getProductId());
100
- if($product->isVirtual()) { continue; }
101
-
102
- Mage::helper('temando')->applyTemandoParamsToItem($item);
103
-
104
- $qty = $item->getQty() ? $item->getQty() : $item->getQtyOrdered();
105
- $box = Mage::getModel('temando/box');
106
- /* @var $box Temando_Temando_Model_Box */
107
- $box
108
- ->setShipmentId($temando_shipment->getId())
109
- ->setComment($item->getName())
110
- ->setQty($item->getQty())
111
- ->setValue($item->getRowTotalInclTax())
112
- ->setLength($item->getTemandoLength())
113
- ->setWidth($item->getTemandoWidth())
114
- ->setHeight($item->getTemandoHeight())
115
- ->setMeasureUnit(Mage::helper('temando')->getConfigData('units/measure'))
116
- ->setWeight($item->getWeight()*$qty)
117
- ->setWeightUnit(Mage::helper('temando')->getConfigData('units/weight'))
118
- ->setPackaging($item->getTemandoPackaging())
119
- ->setFragile($item->getTemandoFragile())
120
- ->setDangerous($item->getTemandoDangerous())
121
- ->save();
122
- }
123
- }
124
-
125
-
126
- protected function loadCheapestQuote($order, $delivery_options, $destinationType)
127
- {
128
- $allowed_carriers = explode(',', Mage::getStoreConfig('carriers/temando/allowed_methods'));
129
- $request = Mage::getModel('temando/api_request');
130
- /* @var $request Temando_Temando_Model_Api_Request */
131
- $request
132
- ->setUsername(Mage::helper('temando')->getConfigData('general/username'))
133
- ->setPassword(Mage::helper('temando')->getConfigData('general/password'))
134
- ->setSandbox(Mage::helper('temando')->getConfigData('general/sandbox'))
135
- ->setMagentoQuoteId($order->getQuoteId())
136
- ->setDestination(
137
- $order->getShippingAddress()->getCountry(),
138
- $order->getShippingAddress()->getPostcode(),
139
- $order->getShippingAddress()->getCity(),
140
- $order->getShippingAddress()->getStreet1(),
141
- $destinationType)
142
- ->setItems($order->getAllItems())
143
- ->setReady()
144
- ->setDeliveryOptions($delivery_options)
145
- ->setAllowedCarriers($allowed_carriers);
146
-
147
- $quotes = $request->getQuotes();
148
- if ($quotes instanceof Temando_Temando_Model_Mysql4_Quote_Collection) {
149
- return Mage::helper('temando/functions')->getCheapestQuote($quotes->getItems());
150
- }
151
- return null;
152
- }
153
-
154
-
155
- public function hookCartSaveAddress($observer)
156
- {
157
- $post = $observer->getControllerAction()->getRequest()->getPost();
158
- if (Mage::getStoreConfig('carriers/temando/active') && isset($post['country_id']) && (Mage::helper('temando')->getDefaultCountryId() == $post['country_id']) && isset($post['region_id']) && isset($post['estimate_city']) && isset($post['estimate_postcode']) && isset($post['pcs'])) {
159
- $data = array(
160
- 'country_id' => $post['country_id'],
161
- 'region_id' => $post['region_id'],
162
- 'city' => $post['estimate_city'],
163
- 'postcode' => $post['estimate_postcode'],
164
- 'pcs' => $post['pcs'],
165
- );
166
- Mage::getSingleton('customer/session')->setData('estimate_product_shipping', new Varien_Object($data));
167
- }
168
- }
169
-
170
- /**
171
- * Saves the destination type in the session if entered in the
172
- * cart page
173
- *
174
- * @return \Temando_Temando_Model_Observer
175
- */
176
- public function saveDestinationType()
177
- {
178
- $destinationType = Mage::app()->getRequest()->getParam('destination-type');
179
- if ($destinationType) {
180
- Mage::getSingleton('checkout/session')->setData(
181
- 'destination_type', $destinationType);
182
- }
183
- return $this;
184
- }
185
- }
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Temando Observer
4
+ *
5
+ * @package Temando_Temando
6
+ * @author Temando Magento Team <marketing@temando.com>
7
+ */
8
+ class Temando_Temando_Model_Observer
9
+ {
10
+
11
+ /**
12
+ * Handles sales_order_place_after event
13
+ */
14
+ public function createTemandoShipment(Varien_Event_Observer $observer)
15
+ {
16
+ $order = $observer->getOrder();
17
+ /* @var $order Mage_Sales_Model_Order */
18
+
19
+ $shippingMethod = $order->getShippingMethod();
20
+ $__t = explode('_', $shippingMethod);
21
+ if ($__t[0] != 'temando') {
22
+ return;
23
+ }
24
+
25
+ //prepare data from request/session
26
+ $destinationType = Mage::getSingleton('checkout/session')->getData('destination_type');
27
+ $delivery_options = Mage::getSingleton('checkout/session')->getData('selected_delivery_options');
28
+ if (!is_array($delivery_options)) {
29
+ $delivery_options = array();
30
+ }
31
+
32
+ $selected_quote_id = preg_replace('#^[^_]*_#', '', $shippingMethod);
33
+ $selected_options = preg_replace('#^([^_]*_){2}#', '', $shippingMethod);
34
+
35
+ $selected_quote = Mage::getModel('temando/quote')->load($selected_quote_id);
36
+ if (!$selected_quote->getId()) {
37
+ //try loading cheapeast quote
38
+ try {
39
+ $selected_quote = $this->loadCheapestQuote($order, $delivery_options, $destinationType);
40
+ /* @var $selected_quote Temando_Temando_Model_Quote */
41
+ } catch (Exception $e) {
42
+ $selected_quote = null;
43
+ }
44
+ }
45
+
46
+ $temando_shipment = Mage::getModel('temando/shipment');
47
+ /* @var $temando_shipment Temando_Temando_Model_Shipment */
48
+
49
+ if (Mage::helper('temando')->isQuoteDynamic($selected_quote_id)) {
50
+ //DYNAMIC: carrier quote selected by customer - must have at least 1 available quote
51
+ $temando_shipment
52
+ ->setAdminSelectedQuoteId($selected_quote->getId())
53
+ ->setCustomerSelectedQuoteId($selected_quote->getId())
54
+ ->setCustomerSelectedOptions($selected_options);
55
+ $selected_quote = $temando_shipment->getSelectedQuotePermutation();
56
+ $temando_shipment
57
+ ->setCustomerSelectedQuoteDescription($selected_quote->getDescription())
58
+ ->setAnticipatedCost($selected_quote->getTotalPrice())
59
+ ->setAnticipatedCurrency($selected_quote->getCurrency());
60
+
61
+ } else {
62
+ //STATIC: flat rate / free shipping selected by customer
63
+ $temando_shipment
64
+ ->setCustomerSelectedQuoteDescription(
65
+ $selected_quote_id == Temando_Temando_Model_Carrier::FLAT_RATE ? Mage::helper('temando')
66
+ ->__('Flat Rate') : Mage::helper('temando')->__('Free Shipping')
67
+ )
68
+ ->setCustomerSelectedOptions('insurance_N_carbonoffset_N_footprints_N');
69
+
70
+ if ($selected_quote instanceof Temando_Temando_Model_Quote) {
71
+ //set cheapest as admin selected
72
+ $temando_shipment->setAdminSelectedQuoteId($selected_quote->getId())
73
+ ->setAnticipatedCost($selected_quote->getTotalPrice())
74
+ ->setAnticipatedCurrency($selected_quote->getCurrency());
75
+ }
76
+ }
77
+
78
+ $email = $order->getShippingAddress()->getEmail();
79
+ if (!$email) {
80
+ $email = $order->getCustomerEmail();
81
+ }
82
+
83
+ $temando_shipment
84
+ ->setOrderId($order->getId() ? $order->getId() : null)
85
+ ->setStatus(Temando_Temando_Model_System_Config_Source_Shipment_Status::PENDING)
86
+ ->setDestinationContactName($order->getShippingAddress()->getName())
87
+ ->setDestinationCompanyName($order->getShippingAddress()->getCompany())
88
+ ->setDestinationStreet(str_replace("\n", ', ', $order->getShippingAddress()->getStreetFull()))
89
+ ->setDestinationRegion($order->getShippingAddress()->getRegionCode())
90
+ ->setDestinationPhone($order->getShippingAddress()->getTelephone())
91
+ ->setDestinationEmail($email)
92
+ ->setDestinationType(
93
+ $destinationType ? $destinationType :
94
+ Temando_Temando_Model_Checkout_Delivery_Options::DESTINATION_RESIDENCE
95
+ )
96
+ ->setDestinationCountry($order->getShippingAddress()->getCountryId())
97
+ ->setDestinationPostcode($order->getShippingAddress()->getPostcode())
98
+ ->setDestinationCity($order->getShippingAddress()->getCity())
99
+ ->setReadyTime('AM')
100
+ ->setCustomerSelectedDeliveryOptions(implode(',', array_keys($delivery_options)))
101
+ ->save();
102
+
103
+ foreach ($order->getAllVisibleItems() as $item) {
104
+ $product = Mage::getModel('catalog/product')->load($item->getProductId());
105
+ if ($product->isVirtual()) {
106
+ continue;
107
+ }
108
+
109
+ Mage::helper('temando')->applyTemandoParamsToItem($item);
110
+
111
+ $qty = $item->getQty() ? $item->getQty() : $item->getQtyOrdered();
112
+ $box = Mage::getModel('temando/box');
113
+ /* @var $box Temando_Temando_Model_Box */
114
+ $box
115
+ ->setShipmentId($temando_shipment->getId())
116
+ ->setComment($item->getName())
117
+ ->setQty($item->getQty())
118
+ ->setValue($item->getRowTotalInclTax())
119
+ ->setLength($item->getTemandoLength())
120
+ ->setWidth($item->getTemandoWidth())
121
+ ->setHeight($item->getTemandoHeight())
122
+ ->setMeasureUnit(Mage::helper('temando')->getConfigData('units/measure'))
123
+ ->setWeight($item->getWeight()*$qty)
124
+ ->setWeightUnit(Mage::helper('temando')->getConfigData('units/weight'))
125
+ ->setPackaging($item->getTemandoPackaging())
126
+ ->setFragile($item->getTemandoFragile())
127
+ ->setDangerous($item->getTemandoDangerous())
128
+ ->save();
129
+ }
130
+ }
131
+
132
+ protected function loadCheapestQuote($order, $delivery_options, $destinationType)
133
+ {
134
+ $allowed_carriers = explode(',', Mage::getStoreConfig('carriers/temando/allowed_methods'));
135
+ $request = Mage::getModel('temando/api_request');
136
+ /* @var $request Temando_Temando_Model_Api_Request */
137
+ $request
138
+ ->setUsername(Mage::helper('temando')->getConfigData('general/username'))
139
+ ->setPassword(Mage::helper('temando')->getConfigData('general/password'))
140
+ ->setSandbox(Mage::helper('temando')->getConfigData('general/sandbox'))
141
+ ->setMagentoQuoteId($order->getQuoteId())
142
+ ->setDestination(
143
+ $order->getShippingAddress()->getCountry(),
144
+ $order->getShippingAddress()->getPostcode(),
145
+ $order->getShippingAddress()->getCity(),
146
+ $order->getShippingAddress()->getStreet1(),
147
+ $destinationType
148
+ )
149
+ ->setItems($order->getAllItems())
150
+ ->setReady()
151
+ ->setDeliveryOptions($delivery_options)
152
+ ->setAllowedCarriers($allowed_carriers);
153
+
154
+ $quotes = $request->getQuotes();
155
+ if ($quotes instanceof Temando_Temando_Model_Mysql4_Quote_Collection) {
156
+ return Mage::helper('temando/functions')->getCheapestQuote($quotes->getItems());
157
+ }
158
+ return null;
159
+ }
160
+
161
+ public function hookCartSaveAddress($observer)
162
+ {
163
+ $post = $observer->getControllerAction()->getRequest()->getPost();
164
+ if (Mage::getStoreConfig('carriers/temando/active') && isset($post['country_id']) && (Mage::helper('temando')
165
+ ->getDefaultCountryId() == $post['country_id']) && isset($post['region_id']) &&
166
+ isset($post['estimate_city']) && isset($post['estimate_postcode']) && isset($post['pcs'])) {
167
+ $data = array(
168
+ 'country_id' => $post['country_id'],
169
+ 'region_id' => $post['region_id'],
170
+ 'city' => $post['estimate_city'],
171
+ 'postcode' => $post['estimate_postcode'],
172
+ 'pcs' => $post['pcs'],
173
+ );
174
+ Mage::getSingleton('customer/session')->setData('estimate_product_shipping', new Varien_Object($data));
175
+ }
176
+ }
177
+
178
+ /**
179
+ * Saves the destination type in the session if entered in the
180
+ * cart page
181
+ *
182
+ * @return \Temando_Temando_Model_Observer
183
+ */
184
+ public function saveDestinationType()
185
+ {
186
+ $destinationType = Mage::app()->getRequest()->getParam('destination-type');
187
+ if ($destinationType) {
188
+ Mage::getSingleton('checkout/session')->setData(
189
+ 'destination_type',
190
+ $destinationType
191
+ );
192
+ }
193
+ return $this;
194
+ }
195
+ }
app/code/community/Temando/Temando/Model/Option/Abstract.php CHANGED
@@ -1,209 +1,209 @@
1
- <?php
2
- /**
3
- * Option Abstract
4
- *
5
- * @package Temando_Temando
6
- * @author Temando Magento Team <marketing@temando.com>
7
- */
8
- abstract class Temando_Temando_Model_Option_Abstract extends Varien_Object
9
- {
10
-
11
- /**
12
- * The key of this option in a collection.
13
- *
14
- * @var string
15
- */
16
- protected $_id = null;
17
-
18
- /**
19
- * The name of this option as shown on the frontend.
20
- *
21
- * @var string
22
- */
23
- protected $_name = null;
24
-
25
- /**
26
- * The desc of this option as shown on the frontend.
27
- *
28
- * @var string
29
- */
30
- protected $_desc = null;
31
-
32
- /**
33
- * An associative array of the valid values for this option.
34
- *
35
- * @var array
36
- */
37
- protected $_values = array();
38
-
39
- /**
40
- * The forced value, if one exists, otherwise NULL.
41
- */
42
- protected $_forced_value = null;
43
-
44
- /**
45
- * The type of the action object that applies to this option.
46
- *
47
- * @var string
48
- */
49
- protected $_action_type = '';
50
-
51
- /**
52
- * The object that performs the action that applies to this option.
53
- *
54
- * @var Temando_Temando_Model_Option_Action_Abstract
55
- */
56
- protected $_action = null;
57
-
58
-
59
- /**
60
- * Calls the _setupValues() method to initialise the values array.
61
- *
62
- * (non-PHPdoc)
63
- *
64
- * @see Varien_Object::_construct()
65
- */
66
- protected function _construct()
67
- {
68
- parent::_construct();
69
- $this->_setupValues();
70
- $this->_setupAction();
71
- }
72
-
73
- /**
74
- * Sets up the $this->_values array.
75
- *
76
- * Called in the self::_construct() method.
77
- */
78
- abstract protected function _setupValues();
79
-
80
- /**
81
- * Sets up the action that applies to this option.
82
- *
83
- * Called in the self::_construct() method.
84
- */
85
- protected function _setupAction()
86
- {
87
- $model_name = 'temando/option_action_' . $this->_action_type;
88
- $this->_action = Mage::getModel($model_name);
89
-
90
- if (!$this->_action) {
91
- throw Mage::exception('Temando_Temando', 'Incorrect action model for option.');
92
- }
93
- }
94
-
95
- /**
96
- * Use the ID in this class, for use in collections etc.
97
- *
98
- * (non-PHPdoc)
99
- *
100
- * @see Varien_Object::getId()
101
- */
102
- public function getId()
103
- {
104
- return $this->_id;
105
- }
106
-
107
- /**
108
- * Gets the name of this option as shown on the frontend.
109
- *
110
- * @return string
111
- */
112
- public function getName()
113
- {
114
- return $this->_name;
115
- }
116
-
117
- /**
118
- * Gets the valid values for this option as an associative array.
119
- *
120
- * Format is as follows:
121
- *
122
- * array(
123
- * $value => $label,
124
- * // ...
125
- * )
126
- *
127
- * where $value is what's used internally and $label is shown on the
128
- * frontend.
129
- *
130
- * @return array
131
- */
132
- public function getValues()
133
- {
134
- return $this->_values;
135
- }
136
-
137
- /**
138
- * Gets the label for a given value of this option.
139
- */
140
- public function getLabel($value)
141
- {
142
- if (array_key_exists($value, $this->_values)) {
143
- return $this->_values[$value];
144
- }
145
- return null;
146
- }
147
-
148
- /**
149
- * Gets the description for the option
150
- */
151
- public function getDescription()
152
- {
153
- return $this->_desc;
154
- }
155
-
156
- /**
157
- * Sets one of the values for this option as the only available selection.
158
- *
159
- * The $forced_value parameter should be a key in the array returned by
160
- * $this->getValues(), otherwise no action is taken.
161
- *
162
- * @return Temando_Temando_Model_Option_Abstract
163
- */
164
- public function setForcedValue($forced_value)
165
- {
166
- if (array_key_exists($forced_value, $this->_values) || $forced_value === null) {
167
- $this->_forced_value = $forced_value;
168
- }
169
-
170
- return $this;
171
- }
172
-
173
- /**
174
- * Gets the forced value for this option (if there is one), otherwise NULL.
175
- *
176
- * A forced option is one that can't be changed by the customer.
177
- */
178
- public function getForcedValue()
179
- {
180
- return $this->_forced_value;
181
- }
182
-
183
- /**
184
- * Applies a given value of this option to a quote.
185
- *
186
- * A copy of the quote is returned, with the option's effects applied.
187
- *
188
- * @param Temando_Temando_Model_Quote $quote
189
- * @return Temando_Temando_Model_Option_Abstract
190
- */
191
- public function apply($value, &$quote)
192
- {
193
- $this->_apply($value, $quote);
194
- return $this;
195
- }
196
-
197
- /**
198
- * Does the actual applying of the quote, based on the value of the option.
199
- *
200
- * Returns true if the action was applied, or false if it wasn't.
201
- *
202
- * (Overridden in child classes)
203
- *
204
- * @param $value
205
- * @param Temando_Temando_Model_Quote $quote
206
- */
207
- abstract protected function _apply($value, &$quote);
208
-
209
- }
1
+ <?php
2
+ /**
3
+ * Option Abstract
4
+ *
5
+ * @package Temando_Temando
6
+ * @author Temando Magento Team <marketing@temando.com>
7
+ */
8
+ abstract class Temando_Temando_Model_Option_Abstract extends Varien_Object
9
+ {
10
+
11
+ /**
12
+ * The key of this option in a collection.
13
+ *
14
+ * @var string
15
+ */
16
+ protected $_id = null;
17
+
18
+ /**
19
+ * The name of this option as shown on the frontend.
20
+ *
21
+ * @var string
22
+ */
23
+ protected $_name = null;
24
+
25
+ /**
26
+ * The desc of this option as shown on the frontend.
27
+ *
28
+ * @var string
29
+ */
30
+ protected $_desc = null;
31
+
32
+ /**
33
+ * An associative array of the valid values for this option.
34
+ *
35
+ * @var array
36
+ */
37
+ protected $_values = array();
38
+
39
+ /**
40
+ * The forced value, if one exists, otherwise NULL.
41
+ */
42
+ protected $_forced_value = null;
43
+
44
+ /**
45
+ * The type of the action object that applies to this option.
46
+ *
47
+ * @var string
48
+ */
49
+ protected $_action_type = '';
50
+
51
+ /**
52
+ * The object that performs the action that applies to this option.
53
+ *
54
+ * @var Temando_Temando_Model_Option_Action_Abstract
55
+ */
56
+ protected $_action = null;
57
+
58
+
59
+ /**
60
+ * Calls the _setupValues() method to initialise the values array.
61
+ *
62
+ * (non-PHPdoc)
63
+ *
64
+ * @see Varien_Object::_construct()
65
+ */
66
+ protected function _construct()
67
+ {
68
+ parent::_construct();
69
+ $this->_setupValues();
70
+ $this->_setupAction();
71
+ }
72
+
73
+ /**
74
+ * Sets up the $this->_values array.
75
+ *
76
+ * Called in the self::_construct() method.
77
+ */
78
+ abstract protected function _setupValues();
79
+
80
+ /**
81
+ * Sets up the action that applies to this option.
82
+ *
83
+ * Called in the self::_construct() method.
84
+ */
85
+ protected function _setupAction()
86
+ {
87
+ $model_name = 'temando/option_action_' . $this->_action_type;
88
+ $this->_action = Mage::getModel($model_name);
89
+
90
+ if (!$this->_action) {
91
+ throw Mage::exception('Temando_Temando', 'Incorrect action model for option.');
92
+ }
93
+ }
94
+
95
+ /**
96
+ * Use the ID in this class, for use in collections etc.
97
+ *
98
+ * (non-PHPdoc)
99
+ *
100
+ * @see Varien_Object::getId()
101
+ */
102
+ public function getId()
103
+ {
104
+ return $this->_id;
105
+ }
106
+
107
+ /**
108
+ * Gets the name of this option as shown on the frontend.
109
+ *
110
+ * @return string
111
+ */
112
+ public function getName()
113
+ {
114
+ return $this->_name;
115
+ }
116
+
117
+ /**
118
+ * Gets the valid values for this option as an associative array.
119
+ *
120
+ * Format is as follows:
121
+ *
122
+ * array(
123
+ * $value => $label,
124
+ * // ...
125
+ * )
126
+ *
127
+ * where $value is what's used internally and $label is shown on the
128
+ * frontend.
129
+ *
130
+ * @return array
131
+ */
132
+ public function getValues()
133
+ {
134
+ return $this->_values;
135
+ }
136
+
137
+ /**
138
+ * Gets the label for a given value of this option.
139
+ */
140
+ public function getLabel($value)
141
+ {
142
+ if (array_key_exists($value, $this->_values)) {
143
+ return $this->_values[$value];
144
+ }
145
+ return null;
146
+ }
147
+
148
+ /**
149
+ * Gets the description for the option
150
+ */
151
+ public function getDescription()
152
+ {
153
+ return $this->_desc;
154
+ }
155
+
156
+ /**
157
+ * Sets one of the values for this option as the only available selection.
158
+ *
159
+ * The $forced_value parameter should be a key in the array returned by
160
+ * $this->getValues(), otherwise no action is taken.
161
+ *
162
+ * @return Temando_Temando_Model_Option_Abstract
163
+ */
164
+ public function setForcedValue($forced_value)
165
+ {
166
+ if (array_key_exists($forced_value, $this->_values) || $forced_value === null) {
167
+ $this->_forced_value = $forced_value;
168
+ }
169
+
170
+ return $this;
171
+ }
172
+
173
+ /**
174
+ * Gets the forced value for this option (if there is one), otherwise NULL.
175
+ *
176
+ * A forced option is one that can't be changed by the customer.
177
+ */
178
+ public function getForcedValue()
179
+ {
180
+ return $this->_forced_value;
181
+ }
182
+
183
+ /**
184
+ * Applies a given value of this option to a quote.
185
+ *
186
+ * A copy of the quote is returned, with the option's effects applied.
187
+ *
188
+ * @param Temando_Temando_Model_Quote $quote
189
+ * @return Temando_Temando_Model_Option_Abstract
190
+ */
191
+ public function apply($value, &$quote)
192
+ {
193
+ $this->_apply($value, $quote);
194
+ return $this;
195
+ }
196
+
197
+ /**
198
+ * Does the actual applying of the quote, based on the value of the option.
199
+ *
200
+ * Returns true if the action was applied, or false if it wasn't.
201
+ *
202
+ * (Overridden in child classes)
203
+ *
204
+ * @param $value
205
+ * @param Temando_Temando_Model_Quote $quote
206
+ */
207
+ abstract protected function _apply($value, &$quote);
208
+
209
+ }
app/code/community/Temando/Temando/Model/Option/Action/Abstract.php CHANGED
@@ -1,18 +1,18 @@
1
- <?php
2
- /**
3
- * Option Action Abstract
4
- *
5
- * @package Temando_Temando
6
- * @author Temando Magento Team <marketing@temando.com>
7
- */
8
- abstract class Temando_Temando_Model_Option_Action_Abstract extends Varien_Object
9
- {
10
-
11
- /**
12
- * Applies the action to a given quote.
13
- *
14
- * @param Temando_Temando_Model_Quote $quote
15
- */
16
- abstract public function apply(&$quote);
17
-
18
- }
1
+ <?php
2
+ /**
3
+ * Option Action Abstract
4
+ *
5
+ * @package Temando_Temando
6
+ * @author Temando Magento Team <marketing@temando.com>
7
+ */
8
+ abstract class Temando_Temando_Model_Option_Action_Abstract extends Varien_Object
9
+ {
10
+
11
+ /**
12
+ * Applies the action to a given quote.
13
+ *
14
+ * @param Temando_Temando_Model_Quote $quote
15
+ */
16
+ abstract public function apply(&$quote);
17
+
18
+ }
app/code/community/Temando/Temando/Model/Option/Action/Carbon.php CHANGED
@@ -1,20 +1,20 @@
1
- <?php
2
- /**
3
- * Option Action Carbon
4
- *
5
- * @package Temando_Temando
6
- * @author Temando Magento Team <marketing@temando.com>
7
- */
8
- class Temando_Temando_Model_Option_Action_Carbon extends Temando_Temando_Model_Option_Action_Abstract
9
- {
10
-
11
- public function apply(&$quote)
12
- {
13
- /* @var $quote Temando_Temando_Model_Quote */
14
- $price = $quote->getTotalPrice();
15
- $carbon_price = $quote->getCarbonTotalPrice();
16
-
17
- $quote->setTotalPrice($price + $carbon_price);
18
- }
19
-
20
- }
1
+ <?php
2
+ /**
3
+ * Option Action Carbon
4
+ *
5
+ * @package Temando_Temando
6
+ * @author Temando Magento Team <marketing@temando.com>
7
+ */
8
+ class Temando_Temando_Model_Option_Action_Carbon extends Temando_Temando_Model_Option_Action_Abstract
9
+ {
10
+
11
+ public function apply(&$quote)
12
+ {
13
+ /* @var $quote Temando_Temando_Model_Quote */
14
+ $price = $quote->getTotalPrice();
15
+ $carbon_price = $quote->getCarbonTotalPrice();
16
+
17
+ $quote->setTotalPrice($price + $carbon_price);
18
+ }
19
+
20
+ }
app/code/community/Temando/Temando/Model/Option/Action/Footprints.php CHANGED
@@ -1,21 +1,21 @@
1
- <?php
2
- /**
3
- * Option Action Footprints
4
- *
5
- * @package Temando_Temando
6
- * @author Temando Magento Team <marketing@temando.com>
7
- */
8
- class Temando_Temando_Model_Option_Action_Footprints
9
- extends Temando_Temando_Model_Option_Action_Abstract
10
- {
11
-
12
- public function apply(&$quote)
13
- {
14
- /* @var $quote Temando_Temando_Model_Quote */
15
- $price = $quote->getTotalPrice();
16
- $footprints_price = $quote->getFootprintsTotalPrice();
17
-
18
- $quote->setTotalPrice($price + $footprints_price);
19
- }
20
-
21
- }
1
+ <?php
2
+ /**
3
+ * Option Action Footprints
4
+ *
5
+ * @package Temando_Temando
6
+ * @author Temando Magento Team <marketing@temando.com>
7
+ */
8
+ class Temando_Temando_Model_Option_Action_Footprints
9
+ extends Temando_Temando_Model_Option_Action_Abstract
10
+ {
11
+
12
+ public function apply(&$quote)
13
+ {
14
+ /* @var $quote Temando_Temando_Model_Quote */
15
+ $price = $quote->getTotalPrice();
16
+ $footprints_price = $quote->getFootprintsTotalPrice();
17
+
18
+ $quote->setTotalPrice($price + $footprints_price);
19
+ }
20
+
21
+ }
app/code/community/Temando/Temando/Model/Option/Action/Insurance.php CHANGED
@@ -1,21 +1,21 @@
1
- <?php
2
- /**
3
- * Option Action Insurance
4
- *
5
- * @package Temando_Temando
6
- * @author Temando Magento Team <marketing@temando.com>
7
- */
8
- class Temando_Temando_Model_Option_Action_Insurance
9
- extends Temando_Temando_Model_Option_Action_Abstract
10
- {
11
-
12
- public function apply(&$quote)
13
- {
14
- /* @var $quote Temando_Temando_Model_Quote */
15
- $price = $quote->getTotalPrice();
16
- $insurance_price = $quote->getInsuranceTotalPrice();
17
-
18
- $quote->setTotalPrice($price + $insurance_price);
19
- }
20
-
21
- }
1
+ <?php
2
+ /**
3
+ * Option Action Insurance
4
+ *
5
+ * @package Temando_Temando
6
+ * @author Temando Magento Team <marketing@temando.com>
7
+ */
8
+ class Temando_Temando_Model_Option_Action_Insurance
9
+ extends Temando_Temando_Model_Option_Action_Abstract
10
+ {
11
+
12
+ public function apply(&$quote)
13
+ {
14
+ /* @var $quote Temando_Temando_Model_Quote */
15
+ $price = $quote->getTotalPrice();
16
+ $insurance_price = $quote->getInsuranceTotalPrice();
17
+
18
+ $quote->setTotalPrice($price + $insurance_price);
19
+ }
20
+
21
+ }
app/code/community/Temando/Temando/Model/Option/Action/Markup.php CHANGED
@@ -1,131 +1,131 @@
1
- <?php
2
- /**
3
- * Option Action Markup
4
- *
5
- * @package Temando_Temando
6
- * @author Temando Magento Team <marketing@temando.com>
7
- */
8
- class Temando_Temando_Model_Option_Action_Markup
9
- extends Temando_Temando_Model_Option_Action_Abstract
10
- {
11
-
12
- /**
13
- * The markup amount.
14
- *
15
- * This can be either a percentage or fixed amount (controlled
16
- * by $this->_markup_type).
17
- *
18
- * @var float
19
- */
20
- protected $_markup = self::DEFAULT_MARKUP;
21
-
22
- /**
23
- * Controls the way the markup amount ($this->_markup) is interpreted
24
- * (either a fixed amount, or percentage).
25
- *
26
- * Shold be one of:
27
- * - Mage_Shipping_Model_Carrier_Abstract::HANDLING_TYPE_FIXED // == 'F'
28
- * - Mage_Shipping_Model_Carrier_Abstract::HANDLING_TYPE_PERCENT // == 'P'
29
- *
30
- * @var unknown_type
31
- */
32
- protected $_markup_type = self::DEFAULT_MARKUP_TYPE;
33
-
34
-
35
- /**
36
- * The default markup amount.
37
- *
38
- * @var float
39
- */
40
- const DEFAULT_MARKUP = 1;
41
-
42
- /**
43
- * The default markup type.
44
- *
45
- * @var string
46
- */
47
- const DEFAULT_MARKUP_TYPE = Mage_Shipping_Model_Carrier_Abstract::HANDLING_TYPE_PERCENT;
48
-
49
- /**
50
- * Sets the markup amount.
51
- *
52
- * This can be either a percentage or a fixed amount (controlled by
53
- * $this->setMarkupType()).
54
- *
55
- * @param unknown_type $type
56
- *
57
- * @return Temando_Temando_Model_Option_Action_Markup
58
- */
59
- public function setMarkup($amount)
60
- {
61
- if (is_numeric($amount)) {
62
- $this->_markup = $amount;
63
- }
64
-
65
- return $this;
66
- }
67
-
68
- /**
69
- * Gets the markup amount.
70
- *
71
- * @return float
72
- */
73
- public function getMarkup()
74
- {
75
- return (float) $this->_markup;
76
- }
77
-
78
- /**
79
- * Controls the way the markup amount (set with $this->setMarkup()) is
80
- * interpreted (either a fixed amount, or percentage).
81
- *
82
- * Shold be one of:
83
- * - Mage_Shipping_Model_Carrier_Abstract::HANDLING_TYPE_FIXED // == 'F'
84
- * - Mage_Shipping_Model_Carrier_Abstract::HANDLING_TYPE_PERCENT // == 'P'
85
- *
86
- * @param string $type
87
- *
88
- * @return Temando_Temando_Model_Option_Action_Markup
89
- */
90
- public function setMarkupType($type)
91
- {
92
- $valid = (
93
- $type === Mage_Shipping_Model_Carrier_Abstract::HANDLING_TYPE_FIXED ||
94
- $type === Mage_Shipping_Model_Carrier_Abstract::HANDLING_TYPE_PERCENT
95
- );
96
-
97
- if ($valid) {
98
- $this->_markup_type = $type;
99
- }
100
-
101
- return $this;
102
- }
103
-
104
- /**
105
- * Gets the markup type (either a fixed amount, or percentage).
106
- *
107
- * @return string
108
- */
109
- public function getMarkupType()
110
- {
111
- return $this->_markup_type;
112
- }
113
-
114
- public function apply(&$quote)
115
- {
116
- $price = $quote->getTotalPrice();
117
-
118
- switch ($this->getMarkupType()) {
119
- case Mage_Shipping_Model_Carrier_Abstract::HANDLING_TYPE_FIXED:
120
- $price += $this->getMarkup();
121
- break;
122
-
123
- case Mage_Shipping_Model_Carrier_Abstract::HANDLING_TYPE_PERCENT:
124
- $price *= 1 + ($this->getMarkup() / 100);
125
- break;
126
- }
127
-
128
- $quote->setTotalPrice($price);
129
- }
130
-
131
- }
1
+ <?php
2
+ /**
3
+ * Option Action Markup
4
+ *
5
+ * @package Temando_Temando
6
+ * @author Temando Magento Team <marketing@temando.com>
7
+ */
8
+ class Temando_Temando_Model_Option_Action_Markup
9
+ extends Temando_Temando_Model_Option_Action_Abstract
10
+ {
11
+
12
+ /**
13
+ * The markup amount.
14
+ *
15
+ * This can be either a percentage or fixed amount (controlled
16
+ * by $this->_markup_type).
17
+ *
18
+ * @var float
19
+ */
20
+ protected $_markup = self::DEFAULT_MARKUP;
21
+
22
+ /**
23
+ * Controls the way the markup amount ($this->_markup) is interpreted
24
+ * (either a fixed amount, or percentage).
25
+ *
26
+ * Shold be one of:
27
+ * - Mage_Shipping_Model_Carrier_Abstract::HANDLING_TYPE_FIXED // == 'F'
28
+ * - Mage_Shipping_Model_Carrier_Abstract::HANDLING_TYPE_PERCENT // == 'P'
29
+ *
30
+ * @var unknown_type
31
+ */
32
+ protected $_markup_type = self::DEFAULT_MARKUP_TYPE;
33
+
34
+
35
+ /**
36
+ * The default markup amount.
37
+ *
38
+ * @var float
39
+ */
40
+ const DEFAULT_MARKUP = 1;
41
+
42
+ /**
43
+ * The default markup type.
44
+ *
45
+ * @var string
46
+ */
47
+ const DEFAULT_MARKUP_TYPE = Mage_Shipping_Model_Carrier_Abstract::HANDLING_TYPE_PERCENT;
48
+
49
+ /**
50
+ * Sets the markup amount.
51
+ *
52
+ * This can be either a percentage or a fixed amount (controlled by
53
+ * $this->setMarkupType()).
54
+ *
55
+ * @param unknown_type $type
56
+ *
57
+ * @return Temando_Temando_Model_Option_Action_Markup
58
+ */
59
+ public function setMarkup($amount)
60
+ {
61
+ if (is_numeric($amount)) {
62
+ $this->_markup = $amount;
63
+ }
64
+
65
+ return $this;
66
+ }
67
+
68
+ /**
69
+ * Gets the markup amount.
70
+ *
71
+ * @return float
72
+ */
73
+ public function getMarkup()
74
+ {
75
+ return (float) $this->_markup;
76
+ }
77
+
78
+ /**
79
+ * Controls the way the markup amount (set with $this->setMarkup()) is
80
+ * interpreted (either a fixed amount, or percentage).
81
+ *
82
+ * Shold be one of:
83
+ * - Mage_Shipping_Model_Carrier_Abstract::HANDLING_TYPE_FIXED // == 'F'
84
+ * - Mage_Shipping_Model_Carrier_Abstract::HANDLING_TYPE_PERCENT // == 'P'
85
+ *
86
+ * @param string $type
87
+ *
88
+ * @return Temando_Temando_Model_Option_Action_Markup
89
+ */
90
+ public function setMarkupType($type)
91
+ {
92
+ $valid = (
93
+ $type === Mage_Shipping_Model_Carrier_Abstract::HANDLING_TYPE_FIXED ||
94
+ $type === Mage_Shipping_Model_Carrier_Abstract::HANDLING_TYPE_PERCENT
95
+ );
96
+
97
+ if ($valid) {
98
+ $this->_markup_type = $type;
99
+ }
100
+
101
+ return $this;
102
+ }
103
+
104
+ /**
105
+ * Gets the markup type (either a fixed amount, or percentage).
106
+ *
107
+ * @return string
108
+ */
109
+ public function getMarkupType()
110
+ {
111
+ return $this->_markup_type;
112
+ }
113
+
114
+ public function apply(&$quote)
115
+ {
116
+ $price = $quote->getTotalPrice();
117
+
118
+ switch ($this->getMarkupType()) {
119
+ case Mage_Shipping_Model_Carrier_Abstract::HANDLING_TYPE_FIXED:
120
+ $price += $this->getMarkup();
121
+ break;
122
+
123
+ case Mage_Shipping_Model_Carrier_Abstract::HANDLING_TYPE_PERCENT:
124
+ $price *= 1 + ($this->getMarkup() / 100);
125
+ break;
126
+ }
127
+
128
+ $quote->setTotalPrice($price);
129
+ }
130
+
131
+ }
app/code/community/Temando/Temando/Model/Option/Boolean.php CHANGED
@@ -1,50 +1,50 @@
1
- <?php
2
- /**
3
- * Option Boolean
4
- *
5
- * @package Temando_Temando
6
- * @author Temando Magento Team <marketing@temando.com>
7
- *
8
- * A boolean (yes/no) option.
9
- *
10
- * The action (specified by $this->_action_type) is applied to quotes if the
11
- * value is self::YES, otherwise no action is taken.
12
- *
13
- * @method Temando_Temando_Model_Option_Boolean setYesAllowed
14
- * @method Temando_Temando_Model_Option_Boolean setNoAllowed
15
- * @method boolean getYesAllowed
16
- * @method boolean getNoAllowed
17
- */
18
- abstract class Temando_Temando_Model_Option_Boolean extends Temando_Temando_Model_Option_Abstract
19
- {
20
-
21
- const YES = 'Y';
22
- const NO = 'N';
23
-
24
- protected function _setupValues()
25
- {
26
- $this->_values= array(
27
- self::YES => Mage::helper('temando')->__('Yes'),
28
- self::NO => Mage::helper('temando')->__('No'),
29
- );
30
- }
31
-
32
- /**
33
- * Only apply the action if the forced value is self::YES, or the value
34
- * is self::YES (as long as the forced value isn't self::NO).
35
- *
36
- * (non-PHPdoc)
37
- *
38
- * @see Temando_Temando_Model_Option_Abstract::_apply()
39
- */
40
- protected function _apply($value, &$quote)
41
- {
42
- if (($value === self::YES && $this->getForcedValue() !== self::NO) || $this->getForcedValue() === self::YES) {
43
- $this->_action->apply($quote);
44
- return true;
45
- } else {
46
- return false;
47
- }
48
- }
49
-
50
- }
1
+ <?php
2
+ /**
3
+ * Option Boolean
4
+ *
5
+ * @package Temando_Temando
6
+ * @author Temando Magento Team <marketing@temando.com>
7
+ *
8
+ * A boolean (yes/no) option.
9
+ *
10
+ * The action (specified by $this->_action_type) is applied to quotes if the
11
+ * value is self::YES, otherwise no action is taken.
12
+ *
13
+ * @method Temando_Temando_Model_Option_Boolean setYesAllowed
14
+ * @method Temando_Temando_Model_Option_Boolean setNoAllowed
15
+ * @method boolean getYesAllowed
16
+ * @method boolean getNoAllowed
17
+ */
18
+ abstract class Temando_Temando_Model_Option_Boolean extends Temando_Temando_Model_Option_Abstract
19
+ {
20
+
21
+ const YES = 'Y';
22
+ const NO = 'N';
23
+
24
+ protected function _setupValues()
25
+ {
26
+ $this->_values= array(
27
+ self::YES => Mage::helper('temando')->__('Yes'),
28
+ self::NO => Mage::helper('temando')->__('No'),
29
+ );
30
+ }
31
+
32
+ /**
33
+ * Only apply the action if the forced value is self::YES, or the value
34
+ * is self::YES (as long as the forced value isn't self::NO).
35
+ *
36
+ * (non-PHPdoc)
37
+ *
38
+ * @see Temando_Temando_Model_Option_Abstract::_apply()
39
+ */
40
+ protected function _apply($value, &$quote)
41
+ {
42
+ if (($value === self::YES && $this->getForcedValue() !== self::NO) || $this->getForcedValue() === self::YES) {
43
+ $this->_action->apply($quote);
44
+ return true;
45
+ } else {
46
+ return false;
47
+ }
48
+ }
49
+
50
+ }
app/code/community/Temando/Temando/Model/Option/Carbonoffset.php CHANGED
@@ -1,83 +1,85 @@
1
- <?php
2
- /**
3
- * Option Carbonoffset
4
- *
5
- * @package Temando_Temando
6
- * @author Temando Magento Team <marketing@temando.com>
7
- */
8
- class Temando_Temando_Model_Option_Carbonoffset extends Temando_Temando_Model_Option_Boolean
9
- {
10
-
11
- protected $_id = 'carbonoffset';
12
- protected $_name = 'Include Carbon Offset';
13
- protected $_action_type = 'carbon';
14
- protected $_desc = "The Gaia Partnership's CO2counter calculates the carbon emissions that are attributed to your transport needs. If you do not wish to offset the carbon emissions from your transport service please unselect the tick box above.";
15
-
16
- /**
17
- * Sets the current "setting" for carbon offsets.
18
- *
19
- * This should be one of the options from the carbon offset source model
20
- * (Temando_Temando_Model_System_Config_Source_Carbon). These include
21
- * "disabled", "optional", and "mandatory". Depending on which setting is
22
- * active, the customer's choice of carbon offsets will be restricted.
23
- */
24
- public function setSetting($value)
25
- {
26
- switch ($value) {
27
- case Temando_Temando_Model_System_Config_Source_Carbon::DISABLED:
28
- $this->setForcedValue(self::NO);
29
- break;
30
-
31
- case Temando_Temando_Model_System_Config_Source_Carbon::MANDATORY:
32
- $this->setForcedValue(self::YES);
33
- break;
34
-
35
- case Temando_Temando_Model_System_Config_Source_Carbon::OPTIONAL:
36
- $this->setForcedValue(null); // no forced value
37
- break;
38
- }
39
-
40
- return $this;
41
- }
42
-
43
- /**
44
- * Sets the markup amount.
45
- *
46
- * @param float $value
47
- */
48
- public function setMarkup($value)
49
- {
50
- $this->_action->setMarkup($value);
51
- return $this;
52
- }
53
-
54
- /**
55
- * Controls the way the markup amount (set with $this->setMarkup()) is
56
- * interpreted (either a fixed amount, or percentage).
57
- *
58
- * @param string $type
59
- */
60
- public function setMarkupType($type)
61
- {
62
- $this->_action->setMarkupType($type);
63
- return $this;
64
- }
65
-
66
- /**
67
- * The parent function applies the action depending on the value, here we
68
- * also update the quote's information to indicate that it includes
69
- * the carbon offset.
70
- *
71
- * (non-PHPdoc)
72
- *
73
- * @see Temando_Temando_Model_Option_Boolean::_apply()
74
- */
75
- protected function _apply($value, &$quote)
76
- {
77
- /* @var $quote Temando_Temando_Model_Quote */
78
- if (parent::_apply($value, $quote)) {
79
- $quote->setCarbonIncluded(true);
80
- }
81
- }
82
-
83
- }
 
 
1
+ <?php
2
+ /**
3
+ * Option Carbonoffset
4
+ *
5
+ * @package Temando_Temando
6
+ * @author Temando Magento Team <marketing@temando.com>
7
+ */
8
+ class Temando_Temando_Model_Option_Carbonoffset extends Temando_Temando_Model_Option_Boolean
9
+ {
10
+
11
+ protected $_id = 'carbonoffset';
12
+ protected $_name = 'Include Carbon Offset';
13
+ protected $_action_type = 'carbon';
14
+ protected $_desc = "The Gaia Partnership's CO2counter calculates the carbon emissions that are attributed to
15
+ your transport needs. If you do not wish to offset the carbon emissions from your transport service please
16
+ unselect the tick box above.";
17
+
18
+ /**
19
+ * Sets the current "setting" for carbon offsets.
20
+ *
21
+ * This should be one of the options from the carbon offset source model
22
+ * (Temando_Temando_Model_System_Config_Source_Carbon). These include
23
+ * "disabled", "optional", and "mandatory". Depending on which setting is
24
+ * active, the customer's choice of carbon offsets will be restricted.
25
+ */
26
+ public function setSetting($value)
27
+ {
28
+ switch ($value) {
29
+ case Temando_Temando_Model_System_Config_Source_Carbon::DISABLED:
30
+ $this->setForcedValue(self::NO);
31
+ break;
32
+
33
+ case Temando_Temando_Model_System_Config_Source_Carbon::MANDATORY:
34
+ $this->setForcedValue(self::YES);
35
+ break;
36
+
37
+ case Temando_Temando_Model_System_Config_Source_Carbon::OPTIONAL:
38
+ $this->setForcedValue(null); // no forced value
39
+ break;
40
+ }
41
+
42
+ return $this;
43
+ }
44
+
45
+ /**
46
+ * Sets the markup amount.
47
+ *
48
+ * @param float $value
49
+ */
50
+ public function setMarkup($value)
51
+ {
52
+ $this->_action->setMarkup($value);
53
+ return $this;
54
+ }
55
+
56
+ /**
57
+ * Controls the way the markup amount (set with $this->setMarkup()) is
58
+ * interpreted (either a fixed amount, or percentage).
59
+ *
60
+ * @param string $type
61
+ */
62
+ public function setMarkupType($type)
63
+ {
64
+ $this->_action->setMarkupType($type);
65
+ return $this;
66
+ }
67
+
68
+ /**
69
+ * The parent function applies the action depending on the value, here we
70
+ * also update the quote's information to indicate that it includes
71
+ * the carbon offset.
72
+ *
73
+ * (non-PHPdoc)
74
+ *
75
+ * @see Temando_Temando_Model_Option_Boolean::_apply()
76
+ */
77
+ protected function _apply($value, &$quote)
78
+ {
79
+ /* @var $quote Temando_Temando_Model_Quote */
80
+ if (parent::_apply($value, $quote)) {
81
+ $quote->setCarbonIncluded(true);
82
+ }
83
+ }
84
+
85
+ }
app/code/community/Temando/Temando/Model/Option/Footprints.php CHANGED
@@ -1,61 +1,63 @@
1
- <?php
2
- /**
3
- * Option Footprints
4
- *
5
- * @package Temando_Temando
6
- * @author Temando Magento Team <marketing@temando.com>
7
- */
8
- class Temando_Temando_Model_Option_Footprints
9
- extends Temando_Temando_Model_Option_Boolean
10
- {
11
-
12
- protected $_id = 'footprints';
13
- protected $_name = 'Include Charitable Micro donation';
14
- protected $_action_type = 'footprints';
15
- protected $_desc = "Include a $1 donation to charity in your transaction. The Footprints Network aggregates thousands of donations from online transactions to fund community development projects. Visit Footprintsnetwork.org to view projects.";
16
-
17
- /**
18
- * Sets the current "setting" for footprints.
19
- *
20
- * This should be one of the options from the footprints source model
21
- * (Temando_Temando_Model_System_Config_Source_Footprints). These include
22
- * "disabled", "optional", and "mandatory". Depending on which setting is
23
- * active, the customer's choice of footprints will be restricted.
24
- */
25
- public function setSetting($value)
26
- {
27
- switch ($value) {
28
- case Temando_Temando_Model_System_Config_Source_Footprints::DISABLED:
29
- $this->setForcedValue(self::NO);
30
- break;
31
-
32
- case Temando_Temando_Model_System_Config_Source_Footprints::MANDATORY:
33
- $this->setForcedValue(self::YES);
34
- break;
35
-
36
- case Temando_Temando_Model_System_Config_Source_Footprints::OPTIONAL:
37
- $this->setForcedValue(null); // no forced value
38
- break;
39
- }
40
-
41
- return $this;
42
- }
43
-
44
- /**
45
- * The parent function applies the action depending on the value, here we
46
- * also update the quote's information to indicate that it includes
47
- * the footprints.
48
- *
49
- * (non-PHPdoc)
50
- *
51
- * @see Temando_Temando_Model_Option_Boolean::_apply()
52
- */
53
- protected function _apply($value, &$quote)
54
- {
55
- /* @var $quote Temando_Temando_Model_Quote */
56
- if (parent::_apply($value, $quote)) {
57
- $quote->setFootprintsIncluded(true);
58
- }
59
- }
60
-
61
- }
 
 
1
+ <?php
2
+ /**
3
+ * Option Footprints
4
+ *
5
+ * @package Temando_Temando
6
+ * @author Temando Magento Team <marketing@temando.com>
7
+ */
8
+ class Temando_Temando_Model_Option_Footprints
9
+ extends Temando_Temando_Model_Option_Boolean
10
+ {
11
+
12
+ protected $_id = 'footprints';
13
+ protected $_name = 'Include Charitable Micro donation';
14
+ protected $_action_type = 'footprints';
15
+ protected $_desc = "Include a $1 donation to charity in your transaction.
16
+ The Footprints Network aggregates thousands of donations from online
17
+ transactions to fund community development projects. Visit Footprintsnetwork.org to view projects.";
18
+
19
+ /**
20
+ * Sets the current "setting" for footprints.
21
+ *
22
+ * This should be one of the options from the footprints source model
23
+ * (Temando_Temando_Model_System_Config_Source_Footprints). These include
24
+ * "disabled", "optional", and "mandatory". Depending on which setting is
25
+ * active, the customer's choice of footprints will be restricted.
26
+ */
27
+ public function setSetting($value)
28
+ {
29
+ switch ($value) {
30
+ case Temando_Temando_Model_System_Config_Source_Footprints::DISABLED:
31
+ $this->setForcedValue(self::NO);
32
+ break;
33
+
34
+ case Temando_Temando_Model_System_Config_Source_Footprints::MANDATORY:
35
+ $this->setForcedValue(self::YES);
36
+ break;
37
+
38
+ case Temando_Temando_Model_System_Config_Source_Footprints::OPTIONAL:
39
+ $this->setForcedValue(null); // no forced value
40
+ break;
41
+ }
42
+
43
+ return $this;
44
+ }
45
+
46
+ /**
47
+ * The parent function applies the action depending on the value, here we
48
+ * also update the quote's information to indicate that it includes
49
+ * the footprints.
50
+ *
51
+ * (non-PHPdoc)
52
+ *
53
+ * @see Temando_Temando_Model_Option_Boolean::_apply()
54
+ */
55
+ protected function _apply($value, &$quote)
56
+ {
57
+ /* @var $quote Temando_Temando_Model_Quote */
58
+ if (parent::_apply($value, $quote)) {
59
+ $quote->setFootprintsIncluded(true);
60
+ }
61
+ }
62
+
63
+ }
app/code/community/Temando/Temando/Model/Option/Insurance.php CHANGED
@@ -1,83 +1,84 @@
1
- <?php
2
- /**
3
- * Option Insurance
4
- *
5
- * @package Temando_Temando
6
- * @author Temando Magento Team <marketing@temando.com>
7
- */
8
- class Temando_Temando_Model_Option_Insurance extends Temando_Temando_Model_Option_Boolean
9
- {
10
-
11
- protected $_id = 'insurance';
12
- protected $_name = 'Include Delivery Insurance';
13
- protected $_action_type = 'insurance';
14
- protected $_desc = 'For your convenience, the company arranging the transport of your newly purchased item provides you with insurance for a nominal fee.';
15
-
16
- /**
17
- * Sets the current "setting" for insurance.
18
- *
19
- * This should be one of the options from the Insurance source model
20
- * (Temando_Temando_Model_System_Config_Source_Insurance). These include
21
- * "disabled", "optional", and "mandatory". Depending on which setting is
22
- * active, the customer's choice of insurance will be restricted.
23
- */
24
- public function setSetting($value)
25
- {
26
- switch ($value) {
27
- case Temando_Temando_Model_System_Config_Source_Insurance::DISABLED:
28
- $this->setForcedValue(self::NO);
29
- break;
30
-
31
- case Temando_Temando_Model_System_Config_Source_Insurance::MANDATORY:
32
- $this->setForcedValue(self::YES);
33
- break;
34
-
35
- case Temando_Temando_Model_System_Config_Source_Insurance::OPTIONAL:
36
- $this->setForcedValue(null); // no forced value
37
- break;
38
- }
39
-
40
- return $this;
41
- }
42
-
43
- /**
44
- * Sets the markup amount.
45
- *
46
- * @param float $value
47
- */
48
- public function setMarkup($value)
49
- {
50
- $this->_action->setMarkup($value);
51
- return $this;
52
- }
53
-
54
- /**
55
- * Controls the way the markup amount (set with $this->setMarkup()) is
56
- * interpreted (either a fixed amount, or percentage).
57
- *
58
- * @param string $type
59
- */
60
- public function setMarkupType($type)
61
- {
62
- $this->_action->setMarkupType($type);
63
- return $this;
64
- }
65
-
66
- /**
67
- * The parent function applies the action depending on the value, here we
68
- * also update the quote's information to indicate that it includes
69
- * insurance.
70
- *
71
- * (non-PHPdoc)
72
- *
73
- * @see Temando_Temando_Model_Option_Boolean::_apply()
74
- */
75
- protected function _apply($value, &$quote)
76
- {
77
- /* @var $quote Temando_Temando_Model_Quote */
78
- if (parent::_apply($value, $quote)) {
79
- $quote->setInsuranceIncluded(true);
80
- }
81
- }
82
-
83
- }
 
1
+ <?php
2
+ /**
3
+ * Option Insurance
4
+ *
5
+ * @package Temando_Temando
6
+ * @author Temando Magento Team <marketing@temando.com>
7
+ */
8
+ class Temando_Temando_Model_Option_Insurance extends Temando_Temando_Model_Option_Boolean
9
+ {
10
+
11
+ protected $_id = 'insurance';
12
+ protected $_name = 'Include Delivery Insurance';
13
+ protected $_action_type = 'insurance';
14
+ protected $_desc = 'For your convenience, the company arranging the transport of your newly purchased item
15
+ provides you with insurance for a nominal fee.';
16
+
17
+ /**
18
+ * Sets the current "setting" for insurance.
19
+ *
20
+ * This should be one of the options from the Insurance source model
21
+ * (Temando_Temando_Model_System_Config_Source_Insurance). These include
22
+ * "disabled", "optional", and "mandatory". Depending on which setting is
23
+ * active, the customer's choice of insurance will be restricted.
24
+ */
25
+ public function setSetting($value)
26
+ {
27
+ switch ($value) {
28
+ case Temando_Temando_Model_System_Config_Source_Insurance::DISABLED:
29
+ $this->setForcedValue(self::NO);
30
+ break;
31
+
32
+ case Temando_Temando_Model_System_Config_Source_Insurance::MANDATORY:
33
+ $this->setForcedValue(self::YES);
34
+ break;
35
+
36
+ case Temando_Temando_Model_System_Config_Source_Insurance::OPTIONAL:
37
+ $this->setForcedValue(null); // no forced value
38
+ break;
39
+ }
40
+
41
+ return $this;
42
+ }
43
+
44
+ /**
45
+ * Sets the markup amount.
46
+ *
47
+ * @param float $value
48
+ */
49
+ public function setMarkup($value)
50
+ {
51
+ $this->_action->setMarkup($value);
52
+ return $this;
53
+ }
54
+
55
+ /**
56
+ * Controls the way the markup amount (set with $this->setMarkup()) is
57
+ * interpreted (either a fixed amount, or percentage).
58
+ *
59
+ * @param string $type
60
+ */
61
+ public function setMarkupType($type)
62
+ {
63
+ $this->_action->setMarkupType($type);
64
+ return $this;
65
+ }
66
+
67
+ /**
68
+ * The parent function applies the action depending on the value, here we
69
+ * also update the quote's information to indicate that it includes
70
+ * insurance.
71
+ *
72
+ * (non-PHPdoc)
73
+ *
74
+ * @see Temando_Temando_Model_Option_Boolean::_apply()
75
+ */
76
+ protected function _apply($value, &$quote)
77
+ {
78
+ /* @var $quote Temando_Temando_Model_Quote */
79
+ if (parent::_apply($value, $quote)) {
80
+ $quote->setInsuranceIncluded(true);
81
+ }
82
+ }
83
+
84
+ }
app/code/community/Temando/Temando/Model/Options.php CHANGED
@@ -1,123 +1,125 @@
1
- <?php
2
- /**
3
- * Options Model
4
- *
5
- * @package Temando_Temando
6
- * @author Temando Magento Team <marketing@temando.com>
7
- */
8
- class Temando_Temando_Model_Options extends Varien_Data_Collection
9
- {
10
-
11
- /**
12
- * Applies all options to a quote, returning a quote for every combination.
13
- *
14
- * For example, if there are three boolean options available, there will
15
- * be eight quotes returned. In general, for (n) options with (m) values,
16
- * there will be (m^n) quotes returned.
17
- *
18
- * @param Temando_Temando_Model_Quote $quote
19
- */
20
- public function applyAll($quote)
21
- {
22
- if (!($quote instanceof Temando_Temando_Model_Quote)) {
23
- return null;
24
- }
25
-
26
- /* @var $quote Temando_Temando_Model_Quote */
27
- $quotes = array();
28
- foreach ($this->_listPermutations() as $permutation) {
29
- // apply every option to the quote
30
- $permutation_id = '';
31
- $new_quote = clone $quote;
32
- $valid = true;
33
-
34
- // apply all options to the new quote
35
- foreach ($permutation as $option_id => $option_value) {
36
- $option = $this->getItemById($option_id);
37
- /* @var $option Temando_Temando_Model_Option_Abstract */
38
- $extras = $new_quote->getExtras();
39
- if ($valid) {
40
- if ($option_value == 'Y' && (!is_array($extras) || !array_key_exists($option_id, $extras))) {
41
- $valid = false;
42
- }
43
-
44
- if ($extras && isset($extras[$option_id])) {
45
- $extra_field = $extras[$option_id];
46
- if (isset($extra_field['mandatory']) && ($option_value == 'N') && ($extra_field['mandatory'] == 'Y')) {
47
- $valid = false;
48
- }
49
- }
50
- }
51
-
52
- $option->apply($option_value, $new_quote);
53
-
54
- $permutation_id .= $option_id . '_' . $option_value . '_';
55
- }
56
-
57
- // remove last underscore
58
- $permutation_id = substr($permutation_id, 0, -1);
59
-
60
- if ($valid) {
61
- $quotes[$permutation_id] = $new_quote;
62
- }
63
- }
64
-
65
- return $quotes;
66
- }
67
-
68
- /**
69
- * Works out all the possible permutations for a given set of options.
70
- *
71
- * This function works recursively to build every combination of values
72
- * for every option.
73
- *
74
- * The return value is in the following format:
75
- *
76
- * array(
77
- * array(
78
- * 'option_1_id' => 'option_1_value_a',
79
- * 'option_2_id' => 'option_2_value_a',
80
- * // ...
81
- * ),
82
- * array(
83
- * 'option_1_id' => 'option_1_value_a',
84
- * 'option_2_id' => 'option_2_value_b',
85
- * // ...
86
- * ),
87
- * // ...
88
- * );
89
- *
90
- * @param array $options
91
- * @param array $progress
92
- *
93
- * @return array
94
- */
95
- protected function _listPermutations($options = null, $progress = array())
96
- {
97
- if ($options === null) {
98
- $options = $this->_items;
99
- }
100
-
101
- if (count($options) > 0) {
102
- // remove head of list and keep it in $current_option
103
- $current_option = each($options);
104
- array_shift($options);
105
-
106
- // build up permutations
107
- $permutations = array();
108
-
109
- foreach ($current_option['value']->getValues() as $value => $label) {
110
- // only use this value if there's no forced value, or if this is the forced value.
111
- if ($current_option['value']->getForcedValue() === null || $current_option['value']->getForcedValue() == $value) {
112
- $progress[$current_option['key']] = $value;
113
- $permutations = array_merge($permutations, $this->_listPermutations($options, $progress));
114
- }
115
- }
116
-
117
- return $permutations;
118
- } else {
119
- return array($progress);
120
- }
121
- }
122
-
123
- }
 
 
1
+ <?php
2
+ /**
3
+ * Options Model
4
+ *
5
+ * @package Temando_Temando
6
+ * @author Temando Magento Team <marketing@temando.com>
7
+ */
8
+ class Temando_Temando_Model_Options extends Varien_Data_Collection
9
+ {
10
+
11
+ /**
12
+ * Applies all options to a quote, returning a quote for every combination.
13
+ *
14
+ * For example, if there are three boolean options available, there will
15
+ * be eight quotes returned. In general, for (n) options with (m) values,
16
+ * there will be (m^n) quotes returned.
17
+ *
18
+ * @param Temando_Temando_Model_Quote $quote
19
+ */
20
+ public function applyAll($quote)
21
+ {
22
+ if (!($quote instanceof Temando_Temando_Model_Quote)) {
23
+ return null;
24
+ }
25
+
26
+ /* @var $quote Temando_Temando_Model_Quote */
27
+ $quotes = array();
28
+ foreach ($this->_listPermutations() as $permutation) {
29
+ // apply every option to the quote
30
+ $permutation_id = '';
31
+ $new_quote = clone $quote;
32
+ $valid = true;
33
+
34
+ // apply all options to the new quote
35
+ foreach ($permutation as $option_id => $option_value) {
36
+ $option = $this->getItemById($option_id);
37
+ /* @var $option Temando_Temando_Model_Option_Abstract */
38
+ $extras = $new_quote->getExtras();
39
+ if ($valid) {
40
+ if ($option_value == 'Y' && (!is_array($extras) || !array_key_exists($option_id, $extras))) {
41
+ $valid = false;
42
+ }
43
+
44
+ if ($extras && isset($extras[$option_id])) {
45
+ $extra_field = $extras[$option_id];
46
+ if (isset($extra_field['mandatory'])
47
+ && ($option_value == 'N') && ($extra_field['mandatory'] == 'Y')) {
48
+ $valid = false;
49
+ }
50
+ }
51
+ }
52
+
53
+ $option->apply($option_value, $new_quote);
54
+
55
+ $permutation_id .= $option_id . '_' . $option_value . '_';
56
+ }
57
+
58
+ // remove last underscore
59
+ $permutation_id = substr($permutation_id, 0, -1);
60
+
61
+ if ($valid) {
62
+ $quotes[$permutation_id] = $new_quote;
63
+ }
64
+ }
65
+
66
+ return $quotes;
67
+ }
68
+
69
+ /**
70
+ * Works out all the possible permutations for a given set of options.
71
+ *
72
+ * This function works recursively to build every combination of values
73
+ * for every option.
74
+ *
75
+ * The return value is in the following format:
76
+ *
77
+ * array(
78
+ * array(
79
+ * 'option_1_id' => 'option_1_value_a',
80
+ * 'option_2_id' => 'option_2_value_a',
81
+ * // ...
82
+ * ),
83
+ * array(
84
+ * 'option_1_id' => 'option_1_value_a',
85
+ * 'option_2_id' => 'option_2_value_b',
86
+ * // ...
87
+ * ),
88
+ * // ...
89
+ * );
90
+ *
91
+ * @param array $options
92
+ * @param array $progress
93
+ *
94
+ * @return array
95
+ */
96
+ protected function _listPermutations($options = null, $progress = array())
97
+ {
98
+ if ($options === null) {
99
+ $options = $this->_items;
100
+ }
101
+
102
+ if (count($options) > 0) {
103
+ // remove head of list and keep it in $current_option
104
+ $current_option = each($options);
105
+ array_shift($options);
106
+
107
+ // build up permutations
108
+ $permutations = array();
109
+
110
+ foreach ($current_option['value']->getValues() as $value => $label) {
111
+ // only use this value if there's no forced value, or if this is the forced value.
112
+ if ($current_option['value']->getForcedValue() === null
113
+ || $current_option['value']->getForcedValue() == $value) {
114
+ $progress[$current_option['key']] = $value;
115
+ $permutations = array_merge($permutations, $this->_listPermutations($options, $progress));
116
+ }
117
+ }
118
+
119
+ return $permutations;
120
+ } else {
121
+ return array($progress);
122
+ }
123
+ }
124
+
125
+ }
app/code/community/Temando/Temando/Model/Pcs.php CHANGED
@@ -1,111 +1,109 @@
1
- <?php
2
- /**
3
- * Pcs Model
4
- *
5
- * @package Temando_Temando
6
- * @author Temando Magento Team <marketing@temando.com>
7
- *
8
- * @method Temando_Temando_Model_Pcs setCountry()
9
- * @method Temando_Temando_Model_Pcs setQuery()
10
- *
11
- * @method string getCountry()
12
- * @method string getQuery()
13
- */
14
-
15
- class Temando_Temando_Model_Pcs extends Mage_Core_Model_Abstract
16
- {
17
- /**
18
- * Address validation Temando AVS URL
19
- */
20
- const AVS_URL = "http://avs.temando.com/avs/search/country/%s/%s.json?limit=1000";
21
-
22
- /**
23
- * The HTTP Client
24
- * @var Varien_Http_Client
25
- */
26
- protected $_client = null;
27
-
28
- /**
29
- * Default country (only one country in allowed countries)
30
- * @var string
31
- */
32
- protected $_defaultCountry = null;
33
-
34
-
35
- public function _construct()
36
- {
37
- parent::_construct();
38
- $this->_prepareClient()->_loadDefaultCountry();
39
- }
40
-
41
- /**
42
- * Returns address postcode/country combinations as an array.
43
- * Empty array is returned if no suggestions are found.
44
- *
45
- * @return array
46
- */
47
- public function getSuggestions()
48
- {
49
- if(!$this->_validate()) {
50
- return array();
51
- }
52
-
53
- $url = sprintf(self::AVS_URL, strtoupper($this->getCountry()), rawurlencode($this->getQuery()));
54
- try {
55
- $this->_client->setUri($url);
56
- $rawBody = $this->_client->request(Varien_Http_Client::GET)->getRawBody();
57
- return Mage::helper('core')->jsonDecode($rawBody, true);
58
- } catch (Exception $e) {
59
- Mage::log($e->getMessage(), null, 'temando.log', true);
60
- return array();
61
- }
62
- }
63
-
64
- /**
65
- * Checks current request - country & query
66
- *
67
- * @return boolean
68
- */
69
- protected function _validate()
70
- {
71
- if (strlen(trim($this->getCountry())) === 0 && $this->_defaultCountry) {
72
- $this->setCountry($this->_defaultCountry);
73
- }
74
- return strlen(trim($this->getCountry())) > 0 &&
75
- strlen(trim($this->getQuery())) > 0;
76
-
77
- }
78
-
79
- /**
80
- * Initializes http client to communicate with AVS service
81
- *
82
- * @return \Temando_Temando_Model_Pcs
83
- */
84
- protected function _prepareClient()
85
- {
86
- if(!$this->_client) {
87
- $this->_client = new Varien_Http_Client();
88
- $this->_client->setConfig(array('maxredirects' => 0, 'timeout' => 15));
89
- }
90
- return $this;
91
- }
92
-
93
- /**
94
- * Loads default destination country
95
- *
96
- * @return \Temando_Temando_Model_Pcs
97
- */
98
- protected function _loadDefaultCountry()
99
- {
100
- if(is_null($this->_defaultCountry)) {
101
- $allowed = Mage::helper('temando')->getAllowedCountries();
102
- if (count($allowed) === 1) {
103
- //one allowed country - load as default
104
- reset($allowed);
105
- $this->_defaultCountry = key($allowed);
106
- }
107
- }
108
- return $this;
109
- }
110
-
111
- }
1
+ <?php
2
+ /**
3
+ * Pcs Model
4
+ *
5
+ * @package Temando_Temando
6
+ * @author Temando Magento Team <marketing@temando.com>
7
+ *
8
+ * @method Temando_Temando_Model_Pcs setCountry()
9
+ * @method Temando_Temando_Model_Pcs setQuery()
10
+ *
11
+ * @method string getCountry()
12
+ * @method string getQuery()
13
+ */
14
+
15
+ class Temando_Temando_Model_Pcs extends Mage_Core_Model_Abstract
16
+ {
17
+ /**
18
+ * Address validation Temando AVS URL
19
+ */
20
+ const AVS_URL = "http://avs.temando.com/avs/search/country/%s/%s.json?limit=1000";
21
+
22
+ /**
23
+ * The HTTP Client
24
+ * @var Varien_Http_Client
25
+ */
26
+ protected $_client = null;
27
+
28
+ /**
29
+ * Default country (only one country in allowed countries)
30
+ * @var string
31
+ */
32
+ protected $_defaultCountry = null;
33
+
34
+
35
+ public function _construct()
36
+ {
37
+ parent::_construct();
38
+ $this->_prepareClient()->_loadDefaultCountry();
39
+ }
40
+
41
+ /**
42
+ * Returns address postcode/country combinations as an array.
43
+ * Empty array is returned if no suggestions are found.
44
+ *
45
+ * @return array
46
+ */
47
+ public function getSuggestions()
48
+ {
49
+ if (!$this->_validate()) {
50
+ return array();
51
+ }
52
+
53
+ $url = sprintf(self::AVS_URL, strtoupper($this->getCountry()), rawurlencode($this->getQuery()));
54
+ try {
55
+ $this->_client->setUri($url);
56
+ $rawBody = $this->_client->request(Varien_Http_Client::GET)->getRawBody();
57
+ return Mage::helper('core')->jsonDecode($rawBody, true);
58
+ } catch (Exception $e) {
59
+ Mage::log($e->getMessage(), null, 'temando.log', true);
60
+ return array();
61
+ }
62
+ }
63
+
64
+ /**
65
+ * Checks current request - country & query
66
+ *
67
+ * @return boolean
68
+ */
69
+ protected function _validate()
70
+ {
71
+ if (strlen(trim($this->getCountry())) === 0 && $this->_defaultCountry) {
72
+ $this->setCountry($this->_defaultCountry);
73
+ }
74
+ return strlen(trim($this->getCountry())) > 0 &&
75
+ strlen(trim($this->getQuery())) > 0;
76
+ }
77
+
78
+ /**
79
+ * Initializes http client to communicate with AVS service
80
+ *
81
+ * @return \Temando_Temando_Model_Pcs
82
+ */
83
+ protected function _prepareClient()
84
+ {
85
+ if (!$this->_client) {
86
+ $this->_client = new Varien_Http_Client();
87
+ $this->_client->setConfig(array('maxredirects' => 0, 'timeout' => 15));
88
+ }
89
+ return $this;
90
+ }
91
+
92
+ /**
93
+ * Loads default destination country
94
+ *
95
+ * @return \Temando_Temando_Model_Pcs
96
+ */
97
+ protected function _loadDefaultCountry()
98
+ {
99
+ if (is_null($this->_defaultCountry)) {
100
+ $allowed = Mage::helper('temando')->getAllowedCountries();
101
+ if (count($allowed) === 1) {
102
+ //one allowed country - load as default
103
+ reset($allowed);
104
+ $this->_defaultCountry = key($allowed);
105
+ }
106
+ }
107
+ return $this;
108
+ }
109
+ }
 
 
app/code/community/Temando/Temando/Model/Quote.php CHANGED
@@ -1,332 +1,336 @@
1
- <?php
2
-
3
- /**
4
- * Quote Model
5
- *
6
- * @package Temando_Temando
7
- * @author Temando Magento Team <marketing@temando.com>
8
- *
9
- * @method Temando_Temando_Model_Quote setGenerated()
10
- * @method Temando_Temando_Model_Quote setAccepted()
11
- * @method Temando_Temando_Model_Quote setTotalPrice()
12
- * @method Temando_Temando_Model_Quote setBasePrice()
13
- * @method Temando_Temando_Model_Quote setTax()
14
- * @method Temando_Temando_Model_Quote setCurrency()
15
- * @method Temando_Temando_Model_Quote setDeliveryMethod()
16
- * @method Temando_Temando_Model_Quote setUsingGeneralRail()
17
- * @method Temando_Temando_Model_Quote setUsingGeneralRoad()
18
- * @method Temando_Temando_Model_Quote setUsingGeneralSea()
19
- * @method Temando_Temando_Model_Quote setUsingExpressAir()
20
- * @method Temando_Temando_Model_Quote setUsingExpressRoad()
21
- * @method Temando_Temando_Model_Quote setEtaFrom()
22
- * @method Temando_Temando_Model_Quote setEtaTo()
23
- * @method Temando_Temando_Model_Quote setGuaranteedEta()
24
- * @method Temando_Temando_Model_Quote setLoaded()
25
- * @method Temando_Temando_Model_Quote setInsuranceIncluded()
26
- * @method Temando_Temando_Model_Quote setCarbonIncluded()
27
- * @method Temando_Temando_Model_Quote setFootprintsIncluded()
28
- * @method Temando_Temando_Model_Quote setFootprintsTotalPrice()
29
- *
30
- * @method string getGenerated()
31
- * @method string getAccepted()
32
- * @method string getTotalPrice()
33
- * @method string getBasePrice()
34
- * @method string getTax()
35
- * @method string getCurrency()
36
- * @method string getDeliveryMethod()
37
- * @method string getUsingGeneralRail()
38
- * @method string getUsingGeneralRoad()
39
- * @method string getUsingGeneralSea()
40
- * @method string getUsingExpressAir()
41
- * @method string getUsingExpressRoad()
42
- * @method string getEtaFrom()
43
- * @method string getEtaTo()
44
- * @method string getGuaranteedEta()
45
- * @method string getLoaded()
46
- * @method boolean getInsuranceIncluded()
47
- * @method boolean getCarbonIncluded()
48
- * @method boolean getFootprintsIncluded()
49
- * @method float getFootprintsTotalPrice()
50
- */
51
- class Temando_Temando_Model_Quote extends Mage_Core_Model_Abstract
52
- {
53
-
54
- protected $_carrier = null;
55
-
56
- public function _construct()
57
- {
58
- parent::_construct();
59
- $this->_init('temando/quote');
60
- }
61
-
62
- public function __clone()
63
- {
64
- $this->_carrier = clone $this->getCarrier();
65
- }
66
-
67
- /**
68
- * Sets the carrier providing this quote.
69
- *
70
- * @param <type> $carrier_id
71
- *
72
- * @return Temando_Temando_Model_Quote
73
- */
74
- public function setCarrier($carrier_id)
75
- {
76
- $carrier = Mage::getModel('temando/carrier')
77
- ->load($carrier_id);
78
-
79
- if ($carrier->getId() == $carrier_id) {
80
- // exists in the database
81
- $this->_carrier = $carrier;
82
- $this->setData('carrier_id', $carrier_id);
83
- }
84
- return $this;
85
- }
86
-
87
- /**
88
- * Gets the carrier providing this quote.
89
- *
90
- * @return Temando_Temando_Model_Carrier
91
- */
92
- public function getCarrier()
93
- {
94
- if (!$this->_carrier) {
95
- $this->setCarrier($this->getCarrierId());
96
- }
97
- return $this->_carrier;
98
- }
99
-
100
- /**
101
- * Loads values into this object from a
102
- *
103
- * @param stdClass $response the SOAP response directly from the Temando
104
- * API.
105
- */
106
- public function loadResponse(stdClass $response)
107
- {
108
- if ($response instanceof stdClass) {
109
- $carrier = Mage::getModel('temando/carrier')->load($response->carrier->id, 'carrier_id');
110
- /* @var $carrier Temando_Temando_Model_Carrier */
111
-
112
- $carrier
113
- ->setCarrierId(isset($response->carrier->id) ? $response->carrier->id : '')
114
- ->setCompanyName(isset($response->carrier->companyName) ? $response->carrier->companyName : '')
115
- ->setCompanyContact(isset($response->carrier->companyContact) ? $response->carrier->companyContact : '')
116
- ->setStreetAddress(isset($response->carrier->streetAddress) ? $response->carrier->streetAddress : '')
117
- ->setStreetSuburb(isset($response->carrier->streetSuburb) ? $response->carrier->streetSuburb : '')
118
- ->setStreetCity(isset($response->carrier->streetCity) ? $response->carrier->streetCity : '')
119
- ->setStreetState(isset($response->carrier->streetState) ? $response->carrier->streetState : '')
120
- ->setStreetPostcode(isset($response->carrier->streetCode) ? $response->carrier->streetCode : '')
121
- ->setStreetCountry(isset($response->carrier->streetCountry) ? $response->carrier->streetCountry : '')
122
- ->setPostalAddress(isset($response->carrier->postalAddress) ? $response->carrier->postalAddress : '')
123
- ->setPostalSuburb(isset($response->carrier->postalSuburb) ? $response->carrier->postalSuburb : '')
124
- ->setPostalCity(isset($response->carrier->postalCity) ? $response->carrier->postalCity : '')
125
- ->setPostalState(isset($response->carrier->postalState) ? $response->carrier->postalState : '')
126
- ->setPostalPostcode(isset($response->carrier->postalCode) ? $response->carrier->postalCode : '')
127
- ->setPostalCountry(isset($response->carrier->postalCountry) ? $response->carrier->postalCountry : '')
128
- ->setPhone(isset($response->carrier->phone1) ? $response->carrier->phone1 : '')
129
- ->setEmail(isset($response->carrier->email) ? $response->carrier->email : '')
130
- ->setWebsite(isset($response->carrier->website) ? $response->carrier->website : '')
131
- ->save();
132
-
133
- $extras = isset($response->extras->extra) ? $response->extras->extra : array();
134
- if (!is_array($extras)) {
135
- $extras = array($extras);
136
- }
137
-
138
- $extras_array = array();
139
-
140
- foreach ($extras as $extra) {
141
- $extra_id = trim(strtolower($extra->summary));
142
- $extra_id = str_replace(' ', '', $extra_id);
143
- $extras_array[$extra_id] = array(
144
- 'summary' => $extra->summary,
145
- 'details' => $extra->details,
146
- 'totalPrice' => $extra->totalPrice,
147
- 'basePrice' => $extra->basePrice,
148
- 'tax' => $extra->tax,
149
- );
150
- }
151
-
152
- $accepted = false;
153
- if (isset($response->accepted)) {
154
- if ($response->accepted == 'Y') {
155
- $accepted = true;
156
- }
157
- }
158
-
159
- $this
160
- ->setCarrier($carrier->getId())
161
- ->setAccepted($accepted)
162
- ->setTotalPrice($response->totalPrice)
163
- ->setBasePrice($response->basePrice)
164
- ->setTax($response->tax)
165
- ->setCurrency($response->currency)
166
- ->setDeliveryMethod($response->deliveryMethod)
167
- ->setEtaFrom($response->etaFrom)
168
- ->setEtaTo($response->etaTo)
169
- ->setGuaranteedEta($response->guaranteedEta == 'Y')
170
- ->setExtras($extras_array)
171
- ->setCarbonTotalPrice(array_key_exists('carbonoffset', $extras_array) ? $extras_array['carbonoffset']['totalPrice'] : 0)
172
- ->setInsuranceTotalPrice(array_key_exists('insurance', $extras_array) ? $extras_array['insurance']['totalPrice'] : 0)
173
- ->setFootprintsTotalPrice(array_key_exists('footprints', $extras_array) ? $extras_array['footprints']['totalPrice'] : 0)
174
- ->setLoaded(true);
175
- }
176
- return $this;
177
- }
178
-
179
- public function toBookingRequestArray($options)
180
- {
181
- $extras = $this->getExtras();
182
-
183
- if (isset($options['insurance']) && ($options['insurance'] === 'Y')) {
184
- $insurance = $extras['insurance'];
185
- } else {
186
- $insurance = false;
187
- }
188
-
189
- if (isset($options['carbonoffset']) && ($options['carbonoffset'] === 'Y')) {
190
- $carbon = $extras['carbonoffset'];
191
- } else {
192
- $carbon = false;
193
- }
194
-
195
- if (isset($options['footprints']) && ($options['footprints'] === 'Y')) {
196
- $footprints = $extras['footprints'];
197
- } else {
198
- $footprints = false;
199
- }
200
-
201
- $request = array(
202
- 'totalPrice' => $this->getTotalPrice(),
203
- 'basePrice' => $this->getBasePrice(),
204
- 'tax' => $this->getTax(),
205
- 'currency' => $this->getCurrency(),
206
- 'deliveryMethod' => $this->getDeliveryMethod(),
207
- 'etaFrom' => $this->getEtaFrom(),
208
- 'etaTo' => $this->getEtaTo(),
209
- 'guaranteedEta' => $this->getGuaranteedEta() ? 'Y' : 'N',
210
- 'carrierId' => $this->getCarrier()->getCarrierId(),
211
- );
212
-
213
- if ($carbon || $insurance || $footprints) {
214
- $request['extras'] = array();
215
- $request['extras']['extra'] = array();
216
- }
217
-
218
- if ($carbon) {
219
- $request['extras']['extra'][] = $carbon;
220
- }
221
- if ($insurance) {
222
- $request['extras']['extra'][] = $insurance;
223
- }
224
- if ($footprints) {
225
- $request['extras']['extra'][] = $footprints;
226
- }
227
-
228
- return $request;
229
- }
230
-
231
- public function setExtras($extras)
232
- {
233
- $this->setData('extras', serialize($extras));
234
- return $this;
235
- }
236
-
237
- public function getExtras()
238
- {
239
- if ($this->getData('extras')) {
240
- return unserialize($this->getData('extras'));
241
- }
242
- return null;
243
- }
244
-
245
- public function getDescription($showMethod = true, $showEta = true)
246
- {
247
- $title = '';
248
- $title .= $this->getCarrier()->getCompanyName();
249
-
250
- if ($showMethod && $showEta) {
251
- $title .= ' - ' . $this->getDeliveryMethod(). ' [' . $this->getEtaDescription() . ']';
252
- } else if ($showMethod) {
253
- $title .= ' - ' . $this->getDeliveryMethod();
254
- } else if ($showEta) {
255
- $title .= ' [' . $this->getEtaDescription(). ']';
256
- }
257
-
258
- return $title . ' ' . $this->getExtraTitle();;
259
- }
260
-
261
-
262
- public function getTotalPriceIncSelectedExtras()
263
- {
264
- $price = $this->getTotalPrice();
265
- if($this->getInsuranceIncluded()) {
266
- $price += $this->getInsuranceTotalPrice();
267
- }
268
- if($this->getCarbonIncluded()) {
269
- $price += $this->getCarbonTotalPrice();
270
- }
271
- if($this->getFootprintsIncluded()) {
272
- $price += $this->getFootprintsTotalPrice();
273
- }
274
-
275
- return $price;
276
-
277
- }
278
-
279
- public function getExtraTitle()
280
- {
281
- $title = '';
282
- if ($this->getInsuranceIncluded()) {
283
- $title .= Mage::helper('temando')->__(', includes insurance');
284
- }
285
- if ($this->getCarbonIncluded()) {
286
- if ($this->getInsuranceIncluded()) {
287
- $title .= Mage::helper('temando')->__(' and ');
288
- } else {
289
- $title .= Mage::helper('temando')->__(', includes ');
290
- }
291
- $title .= Mage::helper('temando')->__(' carbon offset');
292
- }
293
- if ($this->getFootprintsIncluded()) {
294
- if ($this->getInsuranceIncluded() || $this->getCarbonIncluded()) {
295
- $title .= Mage::helper('temando')->__(' and ');
296
- } else {
297
- $title .= Mage::helper('temando')->__(', includes ');
298
- }
299
- $title .= Mage::helper('temando')->__(' footprints');
300
- }
301
-
302
- return $title;
303
- }
304
-
305
- public function getEtaDescription()
306
- {
307
- $title = $this->getEtaFrom();
308
-
309
- if ($this->getEtaFrom() != $this->getEtaTo()) {
310
- $title .= ' - ' . $this->getEtaTo();
311
- }
312
-
313
- $title .= Mage::helper('temando')->__(' day');
314
-
315
- if ($this->getEtaTo() > 1) {
316
- $title .= Mage::helper('temando')->__('s');
317
- }
318
-
319
- return $title;
320
- }
321
-
322
- /**
323
- * Returns the average ETA.
324
- *
325
- * e.g. for an ETA of 1-4 days, the average is 2.5 days.
326
- */
327
- public function getAverageEta()
328
- {
329
- return ($this->getEtaFrom() + $this->getEtaTo()) / 2;
330
- }
331
-
332
- }
 
 
 
 
1
+ <?php
2
+
3
+ /**
4
+ * Quote Model
5
+ *
6
+ * @package Temando_Temando
7
+ * @author Temando Magento Team <marketing@temando.com>
8
+ *
9
+ * @method Temando_Temando_Model_Quote setGenerated()
10
+ * @method Temando_Temando_Model_Quote setAccepted()
11
+ * @method Temando_Temando_Model_Quote setTotalPrice()
12
+ * @method Temando_Temando_Model_Quote setBasePrice()
13
+ * @method Temando_Temando_Model_Quote setTax()
14
+ * @method Temando_Temando_Model_Quote setCurrency()
15
+ * @method Temando_Temando_Model_Quote setDeliveryMethod()
16
+ * @method Temando_Temando_Model_Quote setUsingGeneralRail()
17
+ * @method Temando_Temando_Model_Quote setUsingGeneralRoad()
18
+ * @method Temando_Temando_Model_Quote setUsingGeneralSea()
19
+ * @method Temando_Temando_Model_Quote setUsingExpressAir()
20
+ * @method Temando_Temando_Model_Quote setUsingExpressRoad()
21
+ * @method Temando_Temando_Model_Quote setEtaFrom()
22
+ * @method Temando_Temando_Model_Quote setEtaTo()
23
+ * @method Temando_Temando_Model_Quote setGuaranteedEta()
24
+ * @method Temando_Temando_Model_Quote setLoaded()
25
+ * @method Temando_Temando_Model_Quote setInsuranceIncluded()
26
+ * @method Temando_Temando_Model_Quote setCarbonIncluded()
27
+ * @method Temando_Temando_Model_Quote setFootprintsIncluded()
28
+ * @method Temando_Temando_Model_Quote setFootprintsTotalPrice()
29
+ *
30
+ * @method string getGenerated()
31
+ * @method string getAccepted()
32
+ * @method string getTotalPrice()
33
+ * @method string getBasePrice()
34
+ * @method string getTax()
35
+ * @method string getCurrency()
36
+ * @method string getDeliveryMethod()
37
+ * @method string getUsingGeneralRail()
38
+ * @method string getUsingGeneralRoad()
39
+ * @method string getUsingGeneralSea()
40
+ * @method string getUsingExpressAir()
41
+ * @method string getUsingExpressRoad()
42
+ * @method string getEtaFrom()
43
+ * @method string getEtaTo()
44
+ * @method string getGuaranteedEta()
45
+ * @method string getLoaded()
46
+ * @method boolean getInsuranceIncluded()
47
+ * @method boolean getCarbonIncluded()
48
+ * @method boolean getFootprintsIncluded()
49
+ * @method float getFootprintsTotalPrice()
50
+ */
51
+ class Temando_Temando_Model_Quote extends Mage_Core_Model_Abstract
52
+ {
53
+
54
+ protected $_carrier = null;
55
+
56
+ public function _construct()
57
+ {
58
+ parent::_construct();
59
+ $this->_init('temando/quote');
60
+ }
61
+
62
+ public function __clone()
63
+ {
64
+ $this->_carrier = clone $this->getCarrier();
65
+ }
66
+
67
+ /**
68
+ * Sets the carrier providing this quote.
69
+ *
70
+ * @param <type> $carrier_id
71
+ *
72
+ * @return Temando_Temando_Model_Quote
73
+ */
74
+ public function setCarrier($carrier_id)
75
+ {
76
+ $carrier = Mage::getModel('temando/carrier')
77
+ ->load($carrier_id);
78
+
79
+ if ($carrier->getId() == $carrier_id) {
80
+ // exists in the database
81
+ $this->_carrier = $carrier;
82
+ $this->setData('carrier_id', $carrier_id);
83
+ }
84
+ return $this;
85
+ }
86
+
87
+ /**
88
+ * Gets the carrier providing this quote.
89
+ *
90
+ * @return Temando_Temando_Model_Carrier
91
+ */
92
+ public function getCarrier()
93
+ {
94
+ if (!$this->_carrier) {
95
+ $this->setCarrier($this->getCarrierId());
96
+ }
97
+ return $this->_carrier;
98
+ }
99
+
100
+ /**
101
+ * Loads values into this object from a
102
+ *
103
+ * @param stdClass $response the SOAP response directly from the Temando
104
+ * API.
105
+ */
106
+ public function loadResponse(stdClass $response)
107
+ {
108
+ if ($response instanceof stdClass) {
109
+ $carrier = Mage::getModel('temando/carrier')->load($response->carrier->id, 'carrier_id');
110
+ /* @var $carrier Temando_Temando_Model_Carrier */
111
+
112
+ $carrier
113
+ ->setCarrierId(isset($response->carrier->id) ? $response->carrier->id : '')
114
+ ->setCompanyName(isset($response->carrier->companyName) ? $response->carrier->companyName : '')
115
+ ->setCompanyContact(isset($response->carrier->companyContact) ? $response->carrier->companyContact : '')
116
+ ->setStreetAddress(isset($response->carrier->streetAddress) ? $response->carrier->streetAddress : '')
117
+ ->setStreetSuburb(isset($response->carrier->streetSuburb) ? $response->carrier->streetSuburb : '')
118
+ ->setStreetCity(isset($response->carrier->streetCity) ? $response->carrier->streetCity : '')
119
+ ->setStreetState(isset($response->carrier->streetState) ? $response->carrier->streetState : '')
120
+ ->setStreetPostcode(isset($response->carrier->streetCode) ? $response->carrier->streetCode : '')
121
+ ->setStreetCountry(isset($response->carrier->streetCountry) ? $response->carrier->streetCountry : '')
122
+ ->setPostalAddress(isset($response->carrier->postalAddress) ? $response->carrier->postalAddress : '')
123
+ ->setPostalSuburb(isset($response->carrier->postalSuburb) ? $response->carrier->postalSuburb : '')
124
+ ->setPostalCity(isset($response->carrier->postalCity) ? $response->carrier->postalCity : '')
125
+ ->setPostalState(isset($response->carrier->postalState) ? $response->carrier->postalState : '')
126
+ ->setPostalPostcode(isset($response->carrier->postalCode) ? $response->carrier->postalCode : '')
127
+ ->setPostalCountry(isset($response->carrier->postalCountry) ? $response->carrier->postalCountry : '')
128
+ ->setPhone(isset($response->carrier->phone1) ? $response->carrier->phone1 : '')
129
+ ->setEmail(isset($response->carrier->email) ? $response->carrier->email : '')
130
+ ->setWebsite(isset($response->carrier->website) ? $response->carrier->website : '')
131
+ ->save();
132
+
133
+ $extras = isset($response->extras->extra) ? $response->extras->extra : array();
134
+ if (!is_array($extras)) {
135
+ $extras = array($extras);
136
+ }
137
+
138
+ $extras_array = array();
139
+
140
+ foreach ($extras as $extra) {
141
+ $extra_id = trim(strtolower($extra->summary));
142
+ $extra_id = str_replace(' ', '', $extra_id);
143
+ $extras_array[$extra_id] = array(
144
+ 'summary' => $extra->summary,
145
+ 'details' => $extra->details,
146
+ 'totalPrice' => $extra->totalPrice,
147
+ 'basePrice' => $extra->basePrice,
148
+ 'tax' => $extra->tax,
149
+ );
150
+ }
151
+
152
+ $accepted = false;
153
+ if (isset($response->accepted)) {
154
+ if ($response->accepted == 'Y') {
155
+ $accepted = true;
156
+ }
157
+ }
158
+
159
+ $this
160
+ ->setCarrier($carrier->getId())
161
+ ->setAccepted($accepted)
162
+ ->setTotalPrice($response->totalPrice)
163
+ ->setBasePrice($response->basePrice)
164
+ ->setTax($response->tax)
165
+ ->setCurrency($response->currency)
166
+ ->setDeliveryMethod($response->deliveryMethod)
167
+ ->setEtaFrom($response->etaFrom)
168
+ ->setEtaTo($response->etaTo)
169
+ ->setGuaranteedEta($response->guaranteedEta == 'Y')
170
+ ->setExtras($extras_array)
171
+ ->setCarbonTotalPrice(
172
+ array_key_exists('carbonoffset', $extras_array) ? $extras_array['carbonoffset']['totalPrice'] : 0
173
+ )
174
+ ->setInsuranceTotalPrice(
175
+ array_key_exists('insurance', $extras_array) ? $extras_array['insurance']['totalPrice'] : 0
176
+ )
177
+ ->setFootprintsTotalPrice(
178
+ array_key_exists('footprints', $extras_array) ? $extras_array['footprints']['totalPrice'] : 0
179
+ )
180
+ ->setLoaded(true);
181
+ }
182
+ return $this;
183
+ }
184
+
185
+ public function toBookingRequestArray($options)
186
+ {
187
+ $extras = $this->getExtras();
188
+
189
+ if (isset($options['insurance']) && ($options['insurance'] === 'Y')) {
190
+ $insurance = $extras['insurance'];
191
+ } else {
192
+ $insurance = false;
193
+ }
194
+
195
+ if (isset($options['carbonoffset']) && ($options['carbonoffset'] === 'Y')) {
196
+ $carbon = $extras['carbonoffset'];
197
+ } else {
198
+ $carbon = false;
199
+ }
200
+
201
+ if (isset($options['footprints']) && ($options['footprints'] === 'Y')) {
202
+ $footprints = $extras['footprints'];
203
+ } else {
204
+ $footprints = false;
205
+ }
206
+
207
+ $request = array(
208
+ 'totalPrice' => $this->getTotalPrice(),
209
+ 'basePrice' => $this->getBasePrice(),
210
+ 'tax' => $this->getTax(),
211
+ 'currency' => $this->getCurrency(),
212
+ 'deliveryMethod' => $this->getDeliveryMethod(),
213
+ 'etaFrom' => $this->getEtaFrom(),
214
+ 'etaTo' => $this->getEtaTo(),
215
+ 'guaranteedEta' => $this->getGuaranteedEta() ? 'Y' : 'N',
216
+ 'carrierId' => $this->getCarrier()->getCarrierId(),
217
+ );
218
+
219
+ if ($carbon || $insurance || $footprints) {
220
+ $request['extras'] = array();
221
+ $request['extras']['extra'] = array();
222
+ }
223
+
224
+ if ($carbon) {
225
+ $request['extras']['extra'][] = $carbon;
226
+ }
227
+ if ($insurance) {
228
+ $request['extras']['extra'][] = $insurance;
229
+ }
230
+ if ($footprints) {
231
+ $request['extras']['extra'][] = $footprints;
232
+ }
233
+
234
+ return $request;
235
+ }
236
+
237
+ public function setExtras($extras)
238
+ {
239
+ $this->setData('extras', serialize($extras));
240
+ return $this;
241
+ }
242
+
243
+ public function getExtras()
244
+ {
245
+ if ($this->getData('extras')) {
246
+ return unserialize($this->getData('extras'));
247
+ }
248
+ return null;
249
+ }
250
+
251
+ public function getDescription($showMethod = true, $showEta = true)
252
+ {
253
+ $title = '';
254
+ $title .= $this->getCarrier()->getCompanyName();
255
+
256
+ if ($showMethod && $showEta) {
257
+ $title .= ' - ' . $this->getDeliveryMethod(). ' [' . $this->getEtaDescription() . ']';
258
+ } elseif ($showMethod) {
259
+ $title .= ' - ' . $this->getDeliveryMethod();
260
+ } elseif ($showEta) {
261
+ $title .= ' [' . $this->getEtaDescription(). ']';
262
+ }
263
+
264
+ return $title . ' ' . $this->getExtraTitle();
265
+ }
266
+
267
+
268
+ public function getTotalPriceIncSelectedExtras()
269
+ {
270
+ $price = $this->getTotalPrice();
271
+ if ($this->getInsuranceIncluded()) {
272
+ $price += $this->getInsuranceTotalPrice();
273
+ }
274
+ if ($this->getCarbonIncluded()) {
275
+ $price += $this->getCarbonTotalPrice();
276
+ }
277
+ if ($this->getFootprintsIncluded()) {
278
+ $price += $this->getFootprintsTotalPrice();
279
+ }
280
+ return $price;
281
+ }
282
+
283
+ public function getExtraTitle()
284
+ {
285
+ $title = '';
286
+ if ($this->getInsuranceIncluded()) {
287
+ $title .= Mage::helper('temando')->__(', includes insurance');
288
+ }
289
+ if ($this->getCarbonIncluded()) {
290
+ if ($this->getInsuranceIncluded()) {
291
+ $title .= Mage::helper('temando')->__(' and ');
292
+ } else {
293
+ $title .= Mage::helper('temando')->__(', includes ');
294
+ }
295
+ $title .= Mage::helper('temando')->__(' carbon offset');
296
+ }
297
+ if ($this->getFootprintsIncluded()) {
298
+ if ($this->getInsuranceIncluded() || $this->getCarbonIncluded()) {
299
+ $title .= Mage::helper('temando')->__(' and ');
300
+ } else {
301
+ $title .= Mage::helper('temando')->__(', includes ');
302
+ }
303
+ $title .= Mage::helper('temando')->__(' footprints');
304
+ }
305
+
306
+ return $title;
307
+ }
308
+
309
+ public function getEtaDescription()
310
+ {
311
+ $title = $this->getEtaFrom();
312
+
313
+ if ($this->getEtaFrom() != $this->getEtaTo()) {
314
+ $title .= ' - ' . $this->getEtaTo();
315
+ }
316
+
317
+ $title .= Mage::helper('temando')->__(' day');
318
+
319
+ if ($this->getEtaTo() > 1) {
320
+ $title .= Mage::helper('temando')->__('s');
321
+ }
322
+
323
+ return $title;
324
+ }
325
+
326
+ /**
327
+ * Returns the average ETA.
328
+ *
329
+ * e.g. for an ETA of 1-4 days, the average is 2.5 days.
330
+ */
331
+ public function getAverageEta()
332
+ {
333
+ return ($this->getEtaFrom() + $this->getEtaTo()) / 2;
334
+ }
335
+
336
+ }
app/code/community/Temando/Temando/Model/Shipment.php CHANGED
@@ -1,422 +1,437 @@
1
- <?php
2
-
3
- /**
4
- * Shipment Model
5
- *
6
- * @package Temando_Temando
7
- * @author Temando Magento Team <marketing@temando.com>
8
- *
9
- * @method int getId()
10
- * @method int getOrderId()
11
- * @method string getCustomerSelectedQuoteId()
12
- * @method string getCustomerSelectedQuoteDescription()
13
- * @method string getAdminSelectedQuoteId()
14
- * @method float getAnticipatedCost()
15
- * @method int getStatus()
16
- * @method int getBookingRequestId()
17
- * @method boolean getInsurance()
18
- * @method string getDestinationCountry()
19
- * @method string getDestinationPostcode()
20
- * @method string getDestinationCity()
21
- * @method string getReadyDate()
22
- * @method string getReadyTime()
23
- * @method string getCustomerSelectedOptions()
24
- * @method string getOrderItems()
25
- * @method string getDestinationType()
26
- *
27
- * @method Temando_Temando_Model_Shipment setId()
28
- * @method Temando_Temando_Model_Shipment setOrderId()
29
- * @method Temando_Temando_Model_Shipment setCustomerSelectedQuoteId()
30
- * @method Temando_Temando_Model_Shipment setCustomerSelectedQuoteDescription()
31
- * @method Temando_Temando_Model_Shipment setAdminSelectedQuoteId()
32
- * @method Temando_Temando_Model_Shipment setAnticipatedCost()
33
- * @method Temando_Temando_Model_Shipment setStatus()
34
- * @method Temando_Temando_Model_Shipment setBookingRequestId()
35
- * @method Temando_Temando_Model_Shipment setDestinationCountry()
36
- * @method Temando_Temando_Model_Shipment setDestinationPostcode()
37
- * @method Temando_Temando_Model_Shipment setDestinationCity()
38
- * @method Temando_Temando_Model_Shipment setReadyDate()
39
- * @method Temando_Temando_Model_Shipment setReadyTime()
40
- * @method Temando_Temando_Model_Shipment setCustomerSelectedOptions()
41
- * @method Temando_Temando_Model_Shipment setOrderItems()
42
- * @method Temando_Temando_Model_Shipment setDestinationType()
43
- *
44
- */
45
- class Temando_Temando_Model_Shipment extends Mage_Core_Model_Abstract
46
- {
47
-
48
- /**
49
- * @var Mage_Sales_Model_Order
50
- */
51
- protected $_order = null;
52
-
53
- /**
54
- * @var array
55
- */
56
- protected $_boxes = null;
57
-
58
- public function _construct()
59
- {
60
- parent::_construct();
61
- $this->_init('temando/shipment');
62
- }
63
-
64
- /**
65
- * Overridden to enforce the use of custom getters.
66
- *
67
- * Certain core functions use (e.g.) getData('created_at') instead of
68
- * getCreatedAt(). This makes sure the correct data is returned.
69
- *
70
- * Using _afterLoad() to load the Magento order and populate
71
- * $this->_data['created_at'] won't work: _afterLoad() isn't called
72
- * when objects are loaded in a collection.
73
- *
74
- * @see Varien_Object::getData()
75
- */
76
- public function getData($key = '', $index = null)
77
- {
78
- switch ($key) {
79
- case 'selected_quote_description': return $this->getSelectedQuoteDescription();
80
- case 'created_at': return $this->getCreatedAt();
81
- case 'order_number': return $this->getOrderNumber();
82
- case 'shipping_paid': return $this->getShippingPaid();
83
- default:
84
- }
85
- return parent::getData($key, $index);
86
- }
87
-
88
- /**
89
- * Gets the Magento order associated with this shipment.
90
- *
91
- * @return Mage_Sales_Model_Order
92
- */
93
- public function getOrder()
94
- {
95
- if (!$this->_order && $this->getId()) {
96
- $this->_order = Mage::getModel('sales/order')->load($this->getOrderId());
97
- }
98
- return $this->_order;
99
- }
100
-
101
- /**
102
- * Gets the creation date of this shipment.
103
- */
104
- public function getCreatedAt()
105
- {
106
- if ($this->getOrder()) {
107
- return $this->getOrder()->getCreatedAt();
108
- }
109
- return null;
110
- }
111
-
112
- /**
113
- * Gets the Magento order number (as shown to customers, e.g. 100000123)
114
- */
115
- public function getOrderNumber()
116
- {
117
- if ($this->getOrder()) {
118
- return $this->getOrder()->getIncrementId();
119
- }
120
- return null;
121
- }
122
-
123
- public function getBoxes()
124
- {
125
- return Mage::getModel('temando/box')->getCollection()
126
- ->addFieldToFilter('shipment_id', $this->getId());
127
- }
128
-
129
- /**
130
- * Gets the carrier description.
131
- *
132
- * If the Temando shipment status is Pending or Cancelled, this will be the
133
- * shipment method selected by the user during checkout. If the Temando
134
- * shipment status is Booked, then it will describe the booked quote.
135
- *
136
- * @return string
137
- */
138
- public function getSelectedQuoteDescription()
139
- {
140
- $quote = $this->getSelectedQuotePermutation();
141
- if (is_object($quote) && $quote->getId()) {
142
- return $quote->getDescription();
143
- } else {
144
- return $this->getCustomerSelectedQuoteDescription();
145
- }
146
- return null;
147
- }
148
-
149
- /**
150
- * Gets the selected quote.
151
- *
152
- * If the Temando shipment status is Pending or Cancelled, this will be the
153
- * quote selected by the user during checkout. If the Temando shipment
154
- * status is Booked, then it will be the booked quote.
155
- *
156
- * @return Temando_Temando_Model_Quote
157
- */
158
- public function getSelectedQuote()
159
- {
160
- $quote = null;
161
-
162
- switch ($this->getStatus()) {
163
- case Temando_Temando_Model_System_Config_Source_Shipment_Status::BOOKED:
164
- $quote = Mage::getModel('temando/quote')
165
- ->load($this->getAdminSelectedQuoteId());
166
- break;
167
- case Temando_Temando_Model_System_Config_Source_Shipment_Status::PENDING:
168
- default:
169
- $quote = Mage::getModel('temando/quote')
170
- ->load($this->getCustomerSelectedQuoteId());
171
- break;
172
- }
173
-
174
- return $quote;
175
- }
176
-
177
- /**
178
- * Gets the quote using $this->getQuote(), and applies the selected
179
- * options to it as well.
180
- *
181
- * @return Temando_Temando_Model_Quote
182
- */
183
- public function getSelectedQuotePermutation()
184
- {
185
- $quote = $this->getSelectedQuote();
186
-
187
- /* @var $quote Temando_Temando_Model_Quote */
188
- if ($quote !== null) {
189
- $options = Mage::getModel('temando/options');
190
- /* @var $options Temando_Temando_Model_Options */
191
-
192
- $option_array = $this->getOptions();
193
- foreach ($option_array as $option) {
194
- $options->addItem($option);
195
- }
196
-
197
- $permutations = $options->applyAll($quote);
198
-
199
- if ($permutations) {
200
- return reset($permutations);
201
- }
202
- }
203
- }
204
-
205
- /**
206
- * Gets the shipping amount the customer paid on this order.
207
- */
208
- public function getShippingPaid()
209
- {
210
- if ($this->getOrder()) {
211
- return $this->getOrder()->getShippingAmount();
212
- }
213
- return null;
214
- }
215
-
216
- /**
217
- * Fixes up database-style dates after loading.
218
- *
219
- * @see Mage_Core_Model_Abstract::_afterLoad()
220
- */
221
- public function _afterLoad()
222
- {
223
- if ($this->getData('ready_date') == '0000-00-00') {
224
- $this->unsReadyDate();
225
- }
226
- if ($this->getData('ready_time') == '') {
227
- $this->unsReadyTime();
228
- }
229
- }
230
-
231
- /**
232
- * Gets Temando quotes for this shipment.
233
- */
234
- public function fetchQuotes($username = null, $password = null, $sandbox = false)
235
- {
236
- /* @var $request Temando_Temando_Model_Api_Request */
237
-
238
- $request = Mage::getModel('temando/api_request');
239
- $request
240
- ->setUsername($username)
241
- ->setPassword($password)
242
- ->setSandbox($sandbox)
243
- ->setMagentoQuoteId($this->getOrder()->getQuoteId())
244
- ->setDestination(
245
- $this->getDestinationCountry(),
246
- $this->getDestinationPostcode(),
247
- $this->getDestinationCity(),
248
- $this->getDestinationStreet(),
249
- $this->getDestinationType())
250
- ->setDeliveryOptions($this->getDeliveryOptionsArray())
251
- ->setItems($this->getBoxes());
252
- if ($this->getReadyDate()) {
253
- $request->setReady(strtotime($this->getReadyDate()), $this->getReadyTime());
254
- } else {
255
- $request->setReady(null);
256
- }
257
-
258
- $allowed_carriers = explode(',', Mage::getStoreConfig('carriers/temando/allowed_methods'));
259
- $request->setAllowedCarriers($allowed_carriers);
260
-
261
- $request->getQuotes();
262
- }
263
-
264
- /**
265
- * Clears all quotes from the database relating to this shipment.
266
- */
267
- public function clearQuotes()
268
- {
269
- $old_quotes = Mage::getModel('temando/quote')->getCollection()
270
- ->addFieldToFilter('magento_quote_id', $this->getOrder()->getQuoteId());
271
- foreach ($old_quotes as $quote) {
272
- /* @var $quote Temando_Temando_Model_Quote */
273
- $quote->delete();
274
- }
275
- return $this;
276
- }
277
-
278
-
279
- /**
280
- * Gets the quotes for this shipment from the database
281
- *
282
- * @param boolean $use_options
283
- *
284
- * @return Temando_Temando_Model_Mysql4_Quote_Collection
285
- */
286
- public function getQuotes($use_options = false)
287
- {
288
- if ($use_options) {
289
- $option_array = $this->getOptions();
290
- $options = Mage::getModel('temando/options');
291
- /* @var $options Temando_Temando_Model_Options */
292
- foreach ($option_array as $option) {
293
- $options->addItem($option);
294
- }
295
-
296
- /* @var $quotes Temando_Temando_Model_Mysql4_Quote_Collection */
297
- $quotes = Mage::getModel('temando/quote')->getCollection();
298
- if (!$this->getQuotes()->count()) {
299
- $quotes
300
- ->addFieldToFilter('magento_quote_id', $this->getOrder()->getQuoteId());
301
- } else {
302
- foreach ($this->getQuotes() as $quote_id => $quote) {
303
- /* @var $quote Temando_Temando_Model_Quote */
304
- $permutations = $options->applyAll($quote);
305
- if ($add_quote = reset($permutations)) {
306
- $quotes->addItem($add_quote);
307
- }
308
- }
309
- }
310
-
311
- return $quotes;
312
- } else {
313
- return Mage::getModel('temando/quote')->getCollection()
314
- ->addFieldToFilter('magento_quote_id', $this->getOrder()->getQuoteId());
315
- }
316
- }
317
-
318
-
319
- /**
320
- * Gets the customer selected options as an array.
321
- *
322
- * e.g. for a options string like "insurance_0_carbon_1", this will give:
323
- *
324
- * array(
325
- * 'insurance' => 0,
326
- * 'carbon' => 1,
327
- * )
328
- *
329
- * @return array
330
- */
331
- public function getOptionsArray()
332
- {
333
- $string = $this->getCustomerSelectedOptions();
334
- $elements = explode('_', $string);
335
-
336
- $options = array();
337
-
338
- for ($i = 0; $i < count($elements); $i += 2) {
339
- $options[$elements[$i]] = $elements[$i + 1];
340
- }
341
-
342
- return $options;
343
- }
344
-
345
- /**
346
- * Gets the customer selected options as an array of Option objects.
347
- *
348
- * Each Option object will have the "forced value" set to the value that
349
- * the customer selected.
350
- *
351
- * @return array
352
- */
353
- public function getOptions()
354
- {
355
- $options = array();
356
- foreach ($this->getOptionsArray() as $id => $value) {
357
- // try to instantiate model based on option ID
358
- if ('carbon' == $id) {
359
- $id = 'carbonoffset';
360
- }
361
-
362
- if ('insurance' == $id) {
363
- $_t = $this->getData();
364
- if (isset($_t['id'])) {
365
- $i_id = $_t['id'];
366
- if (!is_null(Mage::getSingleton('adminhtml/session')->getData('insurance_' . $i_id))) {
367
- $value = Mage::getSingleton('adminhtml/session')->getData('insurance_' . $i_id);
368
- }
369
- }
370
- }
371
- try {
372
- $option = Mage::getModel('temando/option_' . $id);
373
- } catch(Exception $e) {
374
- $option = false;
375
- }
376
- if ($option) {
377
- /* @var $option Temando_Temando_Model_Option_Abstract */
378
- $option->setForcedValue($value);
379
- $options[] = $option;
380
- }
381
- }
382
-
383
- return $options;
384
- }
385
-
386
- /**
387
- * Checks wether this shipment can be shipped
388
- *
389
- * @return boolean
390
- */
391
- public function isStatusOpened()
392
- {
393
- return
394
- $this->getStatus() == Temando_Temando_Model_System_Config_Source_Shipment_Status::PENDING;
395
- }
396
-
397
- /**
398
- * Is this shipment a TZ pickup?
399
- *
400
- * @return boolean
401
- */
402
- public function isPickup()
403
- {
404
- return (boolean)$this->getPickupDescription();
405
- }
406
-
407
- /**
408
- * Transform saved delivery options to key=>val array
409
- * of customer selected options
410
- *
411
- * @return array
412
- */
413
- public function getDeliveryOptionsArray()
414
- {
415
- $arr = array();
416
- $deliveryOptions = explode(',', $this->getCustomerSelectedDeliveryOptions());
417
- foreach ($deliveryOptions as $deliveryOption) {
418
- $arr[$deliveryOption] = 'on';
419
- }
420
- return $arr;
421
- }
422
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ /**
4
+ * Shipment Model
5
+ *
6
+ * @package Temando_Temando
7
+ * @author Temando Magento Team <marketing@temando.com>
8
+ *
9
+ * @method int getId()
10
+ * @method int getOrderId()
11
+ * @method string getCustomerSelectedQuoteId()
12
+ * @method string getCustomerSelectedQuoteDescription()
13
+ * @method string getAdminSelectedQuoteId()
14
+ * @method float getAnticipatedCost()
15
+ * @method int getStatus()
16
+ * @method int getBookingRequestId()
17
+ * @method boolean getInsurance()
18
+ * @method string getDestinationCountry()
19
+ * @method string getDestinationPostcode()
20
+ * @method string getDestinationCity()
21
+ * @method string getReadyDate()
22
+ * @method string getReadyTime()
23
+ * @method string getCustomerSelectedOptions()
24
+ * @method string getOrderItems()
25
+ * @method string getDestinationType()
26
+ *
27
+ * @method Temando_Temando_Model_Shipment setId()
28
+ * @method Temando_Temando_Model_Shipment setOrderId()
29
+ * @method Temando_Temando_Model_Shipment setCustomerSelectedQuoteId()
30
+ * @method Temando_Temando_Model_Shipment setCustomerSelectedQuoteDescription()
31
+ * @method Temando_Temando_Model_Shipment setAdminSelectedQuoteId()
32
+ * @method Temando_Temando_Model_Shipment setAnticipatedCost()
33
+ * @method Temando_Temando_Model_Shipment setStatus()
34
+ * @method Temando_Temando_Model_Shipment setBookingRequestId()
35
+ * @method Temando_Temando_Model_Shipment setDestinationCountry()
36
+ * @method Temando_Temando_Model_Shipment setDestinationPostcode()
37
+ * @method Temando_Temando_Model_Shipment setDestinationCity()
38
+ * @method Temando_Temando_Model_Shipment setReadyDate()
39
+ * @method Temando_Temando_Model_Shipment setReadyTime()
40
+ * @method Temando_Temando_Model_Shipment setCustomerSelectedOptions()
41
+ * @method Temando_Temando_Model_Shipment setOrderItems()
42
+ * @method Temando_Temando_Model_Shipment setDestinationType()
43
+ *
44
+ */
45
+ class Temando_Temando_Model_Shipment extends Mage_Core_Model_Abstract
46
+ {
47
+
48
+ /**
49
+ * @var Mage_Sales_Model_Order
50
+ */
51
+ protected $_order = null;
52
+
53
+ /**
54
+ * @var array
55
+ */
56
+ protected $_boxes = null;
57
+
58
+ public function _construct()
59
+ {
60
+ parent::_construct();
61
+ $this->_init('temando/shipment');
62
+ }
63
+
64
+ /**
65
+ * Overridden to enforce the use of custom getters.
66
+ *
67
+ * Certain core functions use (e.g.) getData('created_at') instead of
68
+ * getCreatedAt(). This makes sure the correct data is returned.
69
+ *
70
+ * Using _afterLoad() to load the Magento order and populate
71
+ * $this->_data['created_at'] won't work: _afterLoad() isn't called
72
+ * when objects are loaded in a collection.
73
+ *
74
+ * @see Varien_Object::getData()
75
+ */
76
+ public function getData($key = '', $index = null)
77
+ {
78
+ switch ($key) {
79
+ case 'selected_quote_description':
80
+ return $this->getSelectedQuoteDescription();
81
+ case 'created_at':
82
+ return $this->getCreatedAt();
83
+ case 'order_number':
84
+ return $this->getOrderNumber();
85
+ case 'shipping_paid':
86
+ return $this->getShippingPaid();
87
+ default:
88
+ }
89
+ return parent::getData($key, $index);
90
+ }
91
+
92
+ /**
93
+ * Gets the Magento order associated with this shipment.
94
+ *
95
+ * @return Mage_Sales_Model_Order
96
+ */
97
+ public function getOrder()
98
+ {
99
+ if (!$this->_order && $this->getId()) {
100
+ $this->_order = Mage::getModel('sales/order')->load($this->getOrderId());
101
+ }
102
+ return $this->_order;
103
+ }
104
+
105
+ /**
106
+ * Gets the creation date of this shipment.
107
+ */
108
+ public function getCreatedAt()
109
+ {
110
+ if ($this->getOrder()) {
111
+ return $this->getOrder()->getCreatedAt();
112
+ }
113
+ return null;
114
+ }
115
+
116
+ /**
117
+ * Gets the Magento order number (as shown to customers, e.g. 100000123)
118
+ */
119
+ public function getOrderNumber()
120
+ {
121
+ if ($this->getOrder()) {
122
+ return $this->getOrder()->getIncrementId();
123
+ }
124
+ return null;
125
+ }
126
+
127
+ public function getBoxes()
128
+ {
129
+ return Mage::getModel('temando/box')->getCollection()
130
+ ->addFieldToFilter('shipment_id', $this->getId());
131
+ }
132
+
133
+ /**
134
+ * Gets the carrier description.
135
+ *
136
+ * If the Temando shipment status is Pending or Cancelled, this will be the
137
+ * shipment method selected by the user during checkout. If the Temando
138
+ * shipment status is Booked, then it will describe the booked quote.
139
+ *
140
+ * @return string
141
+ */
142
+ public function getSelectedQuoteDescription()
143
+ {
144
+ $quote = $this->getSelectedQuotePermutation();
145
+ if (is_object($quote) && $quote->getId()) {
146
+ return $quote->getDescription();
147
+ } else {
148
+ return $this->getCustomerSelectedQuoteDescription();
149
+ }
150
+ return null;
151
+ }
152
+
153
+ /**
154
+ * Gets the selected quote.
155
+ *
156
+ * If the Temando shipment status is Pending or Cancelled, this will be the
157
+ * quote selected by the user during checkout. If the Temando shipment
158
+ * status is Booked, then it will be the booked quote.
159
+ *
160
+ * @return Temando_Temando_Model_Quote
161
+ */
162
+ public function getSelectedQuote()
163
+ {
164
+ $quote = null;
165
+
166
+ switch ($this->getStatus()) {
167
+ case Temando_Temando_Model_System_Config_Source_Shipment_Status::BOOKED:
168
+ $quote = Mage::getModel('temando/quote')
169
+ ->load($this->getAdminSelectedQuoteId());
170
+ break;
171
+ case Temando_Temando_Model_System_Config_Source_Shipment_Status::PENDING:
172
+ default:
173
+ $quote = Mage::getModel('temando/quote')
174
+ ->load($this->getCustomerSelectedQuoteId());
175
+ break;
176
+ }
177
+
178
+ return $quote;
179
+ }
180
+
181
+ /**
182
+ * Gets the quote using $this->getQuote(), and applies the selected
183
+ * options to it as well.
184
+ *
185
+ * @return Temando_Temando_Model_Quote
186
+ */
187
+ public function getSelectedQuotePermutation()
188
+ {
189
+ $quote = $this->getSelectedQuote();
190
+
191
+ /* @var $quote Temando_Temando_Model_Quote */
192
+ if ($quote !== null) {
193
+ $options = Mage::getModel('temando/options');
194
+ /* @var $options Temando_Temando_Model_Options */
195
+
196
+ $option_array = $this->getOptions();
197
+ foreach ($option_array as $option) {
198
+ $options->addItem($option);
199
+ }
200
+
201
+ $permutations = $options->applyAll($quote);
202
+
203
+ if ($permutations) {
204
+ return reset($permutations);
205
+ }
206
+ }
207
+ }
208
+
209
+ /**
210
+ * Gets the shipping amount the customer paid on this order.
211
+ */
212
+ public function getShippingPaid()
213
+ {
214
+ if ($this->getOrder()) {
215
+ return $this->getOrder()->getShippingAmount();
216
+ }
217
+ return null;
218
+ }
219
+
220
+ /**
221
+ * Fixes up database-style dates after loading.
222
+ *
223
+ * @see Mage_Core_Model_Abstract::_afterLoad()
224
+ */
225
+ public function _afterLoad()
226
+ {
227
+ if ($this->getData('ready_date') == '0000-00-00') {
228
+ $this->unsReadyDate();
229
+ }
230
+ if ($this->getData('ready_time') == '') {
231
+ $this->unsReadyTime();
232
+ }
233
+ }
234
+
235
+ /**
236
+ * Gets Temando quotes for this shipment.
237
+ */
238
+ public function fetchQuotes($username = null, $password = null, $sandbox = false)
239
+ {
240
+ /* @var $request Temando_Temando_Model_Api_Request */
241
+
242
+ $request = Mage::getModel('temando/api_request');
243
+ $request
244
+ ->setUsername($username)
245
+ ->setPassword($password)
246
+ ->setSandbox($sandbox)
247
+ ->setMagentoQuoteId($this->getOrder()->getQuoteId())
248
+ ->setGoodsCurrency(Mage::app()->getStore($this->getStoreId())->getCurrentCurrencyCode())
249
+ ->setDestination(
250
+ $this->getDestinationCountry(),
251
+ $this->getDestinationPostcode(),
252
+ $this->getDestinationCity(),
253
+ $this->getDestinationStreet(),
254
+ $this->getDestinationType()
255
+ )
256
+ ->setDeliveryOptions($this->getDeliveryOptionsArray())
257
+ ->setItems($this->getBoxes());
258
+ if ($this->getReadyDate()) {
259
+ $request->setReady(strtotime($this->getReadyDate()), $this->getReadyTime());
260
+ } else {
261
+ $request->setReady(null);
262
+ }
263
+
264
+ $allowed_carriers = explode(',', Mage::getStoreConfig('carriers/temando/allowed_methods'));
265
+ $request->setAllowedCarriers($allowed_carriers);
266
+
267
+ $request->getQuotes();
268
+ }
269
+
270
+ /**
271
+ * Clears all quotes from the database relating to this shipment.
272
+ */
273
+ public function clearQuotes()
274
+ {
275
+ $old_quotes = Mage::getModel('temando/quote')->getCollection()
276
+ ->addFieldToFilter('magento_quote_id', $this->getOrder()->getQuoteId());
277
+ foreach ($old_quotes as $quote) {
278
+ /* @var $quote Temando_Temando_Model_Quote */
279
+ $quote->delete();
280
+ }
281
+ return $this;
282
+ }
283
+
284
+
285
+ /**
286
+ * Gets the quotes for this shipment from the database
287
+ *
288
+ * @param boolean $use_options
289
+ *
290
+ * @return Temando_Temando_Model_Mysql4_Quote_Collection
291
+ */
292
+ public function getQuotes($use_options = false)
293
+ {
294
+ if ($use_options) {
295
+ $option_array = $this->getOptions();
296
+ $options = Mage::getModel('temando/options');
297
+ /* @var $options Temando_Temando_Model_Options */
298
+ foreach ($option_array as $option) {
299
+ $options->addItem($option);
300
+ }
301
+
302
+ /* @var $quotes Temando_Temando_Model_Mysql4_Quote_Collection */
303
+ $quotes = Mage::getModel('temando/quote')->getCollection();
304
+ if (!$this->getQuotes()->count()) {
305
+ $quotes
306
+ ->addFieldToFilter('magento_quote_id', $this->getOrder()->getQuoteId());
307
+ } else {
308
+ foreach ($this->getQuotes() as $quote_id => $quote) {
309
+ /* @var $quote Temando_Temando_Model_Quote */
310
+ $permutations = $options->applyAll($quote);
311
+ if ($add_quote = reset($permutations)) {
312
+ $quotes->addItem($add_quote);
313
+ }
314
+ }
315
+ }
316
+
317
+ return $quotes;
318
+ } else {
319
+ return Mage::getModel('temando/quote')->getCollection()
320
+ ->addFieldToFilter('magento_quote_id', $this->getOrder()->getQuoteId());
321
+ }
322
+ }
323
+
324
+
325
+ /**
326
+ * Gets the customer selected options as an array.
327
+ *
328
+ * e.g. for a options string like "insurance_0_carbon_1", this will give:
329
+ *
330
+ * array(
331
+ * 'insurance' => 0,
332
+ * 'carbon' => 1,
333
+ * )
334
+ *
335
+ * @return array
336
+ */
337
+ public function getOptionsArray()
338
+ {
339
+ $string = $this->getCustomerSelectedOptions();
340
+ $elements = explode('_', $string);
341
+
342
+ $options = array();
343
+
344
+ for ($i = 0; $i < count($elements); $i += 2) {
345
+ $options[$elements[$i]] = $elements[$i + 1];
346
+ }
347
+
348
+ return $options;
349
+ }
350
+
351
+ /**
352
+ * Gets the customer selected options as an array of Option objects.
353
+ *
354
+ * Each Option object will have the "forced value" set to the value that
355
+ * the customer selected.
356
+ *
357
+ * @return array
358
+ */
359
+ public function getOptions()
360
+ {
361
+ $options = array();
362
+ foreach ($this->getOptionsArray() as $id => $value) {
363
+ // try to instantiate model based on option ID
364
+ if ('carbon' == $id) {
365
+ $id = 'carbonoffset';
366
+ }
367
+
368
+ if ('insurance' == $id) {
369
+ $_t = $this->getData();
370
+ if (isset($_t['id'])) {
371
+ $i_id = $_t['id'];
372
+ if (!is_null(Mage::getSingleton('adminhtml/session')->getData('insurance_' . $i_id))) {
373
+ $value = Mage::getSingleton('adminhtml/session')->getData('insurance_' . $i_id);
374
+ }
375
+ }
376
+ }
377
+ try {
378
+ $option = Mage::getModel('temando/option_' . $id);
379
+ } catch (Exception $e) {
380
+ $option = false;
381
+ }
382
+ if ($option) {
383
+ /* @var $option Temando_Temando_Model_Option_Abstract */
384
+ $option->setForcedValue($value);
385
+ $options[] = $option;
386
+ }
387
+ }
388
+
389
+ return $options;
390
+ }
391
+
392
+ /**
393
+ * Checks wether this shipment can be shipped
394
+ *
395
+ * @return boolean
396
+ */
397
+ public function isStatusOpened()
398
+ {
399
+ return $this->getStatus() == Temando_Temando_Model_System_Config_Source_Shipment_Status::PENDING;
400
+ }
401
+
402
+ /**
403
+ * Is this shipment a TZ pickup?
404
+ *
405
+ * @return boolean
406
+ */
407
+ public function isPickup()
408
+ {
409
+ return (boolean)$this->getPickupDescription();
410
+ }
411
+
412
+ /**
413
+ * Gets store ID from shipment order
414
+ *
415
+ * @return int
416
+ */
417
+ public function getStoreId()
418
+ {
419
+ return $this->getOrder()->getStoreId();
420
+ }
421
+
422
+ /**
423
+ * Transform saved delivery options to key=>val array
424
+ * of customer selected options
425
+ *
426
+ * @return array
427
+ */
428
+ public function getDeliveryOptionsArray()
429
+ {
430
+ $arr = array();
431
+ $deliveryOptions = explode(',', $this->getCustomerSelectedDeliveryOptions());
432
+ foreach ($deliveryOptions as $deliveryOption) {
433
+ $arr[$deliveryOption] = 'on';
434
+ }
435
+ return $arr;
436
+ }
437
+ }
app/code/community/Temando/Temando/Model/Shipping/Carrier/Temando.php CHANGED
@@ -1,567 +1,592 @@
1
- <?php
2
-
3
- /**
4
- * Temando Carrier
5
- *
6
- * @package Temando_Temando
7
- * @author Temando Magento Team <marketing@temando.com>
8
- *
9
- * @method Temando_Temando_Model_Shipping_Carrier_Temando setIsProductPage(boolean $flag)
10
- * @method Temando_Temando_Model_Shipping_Carrier_Temando setIsCartPage(boolean $flag)
11
- * @method Temando_Temando_Model_Shipping_Carrier_Temando setDeliveryOptions()
12
- * @method Temando_Temando_Model_Shipping_Carrier_Temando setDestinationType()
13
- * @method Temando_Temando_Model_Shipping_Carrier_Temando setUpdateDeliveryOptions(boolean $flag)
14
- *
15
- * @method boolean getIsProductPage()
16
- * @method boolean getIsCartPage()
17
- * @method array getDeliveryOptions()
18
- * @method string getDestinationType()
19
- * @method boolean getUpdateDeliveryOptions()
20
- */
21
-
22
-
23
- class Temando_Temando_Model_Shipping_Carrier_Temando
24
- extends Mage_Shipping_Model_Carrier_Abstract
25
- implements Mage_Shipping_Model_Carrier_Interface
26
- {
27
- /**
28
- * Error Constants
29
- */
30
- const ERR_INVALID_COUNTRY = 'Sorry, shipping to selected country is not available.';
31
- const ERR_INVALID_DEST = 'Please enter a delivery address to view available shipping methods';
32
- const ERR_NO_METHODS = 'No shipping methods available';
33
- const ERR_INTERNATIONAL = 'International delivery is not available at this time.';
34
-
35
- /**
36
- * Carrier's code
37
- */
38
- const CARRIER_CODE = 'temando';
39
-
40
- /**
41
- * Error Map
42
- *
43
- * @var array
44
- */
45
- protected static $_errors_map = array(
46
- "The 'destinationCountry', 'destinationCode' and 'destinationSuburb' elements (within the 'Anywhere' type) do not contain valid values. These values must match with the predefined settings in the Temando system."
47
- => "Invalid suburb / postcode combination."
48
- );
49
-
50
- /**
51
- * Carrier's code
52
- *
53
- * @var string
54
- */
55
- protected $_code = 'temando';
56
-
57
- /**
58
- * Carrier's title
59
- *
60
- * @var string
61
- */
62
- protected $_title = 'Temando';
63
-
64
- /**
65
- * Rates result
66
- *
67
- * @var array|null
68
- */
69
- protected $_rates;
70
-
71
- /**
72
- * @var Mage_Shipping_Model_Rate_Request
73
- */
74
- protected $_rate_request;
75
-
76
- /**
77
- * Current pricing method as set in Temando Settings
78
- *
79
- * @var string
80
- */
81
- protected $_pricing_method;
82
-
83
- /**
84
- * Check if carrier has shipping tracking option available
85
- *
86
- * @return boolean
87
- */
88
- public function isTrackingAvailable()
89
- {
90
- return true;
91
- }
92
-
93
- /**
94
- * Check if carrier has shipping label option available
95
- *
96
- * @return boolean
97
- */
98
- public function isShippingLabelsAvailable()
99
- {
100
- return false;
101
- }
102
-
103
-
104
- public function __construct()
105
- {
106
- parent::__construct();
107
- $this->_pricing_method = $this->getConfigData('pricing/method');
108
- $this->setIsProductPage(("etemando" == Mage::app()->getRequest()->getModuleName()) && ("pcs" == Mage::app()->getRequest()->getControllerName()));
109
- $this->setIsCartPage(("checkout" == Mage::app()->getRequest()->getModuleName()) && ("cart" == Mage::app()->getRequest()->getControllerName()));
110
-
111
- $this->setUpdateDeliveryOptions(Mage::app()->getRequest()->getParam('delivery_option_change', false));
112
-
113
- if ($this->getUpdateDeliveryOptions()) {
114
- Mage::getSingleton('checkout/session')->setData(
115
- 'selected_delivery_options',
116
- Mage::app()->getRequest()->getParam(
117
- 'delivery_options',
118
- array()
119
- )
120
- );
121
- Mage::getSingleton('checkout/session')->setData(
122
- 'destination_type',
123
- Mage::app()->getRequest()->getParam(
124
- 'destination_type',
125
- Temando_Temando_Model_Checkout_Delivery_Options::DESTINATION_RESIDENCE
126
- )
127
- );
128
- }
129
-
130
- $this->setDeliveryOptions(
131
- is_array(Mage::getSingleton('checkout/session')->getData('selected_delivery_options')) ?
132
- Mage::getSingleton('checkout/session')->getData('selected_delivery_options') :
133
- array()
134
- );
135
- $this->setDestinationType(
136
- Mage::getSingleton('checkout/session')->getData('destination_type') ?
137
- Mage::getSingleton('checkout/session')->getData('destination_type') :
138
- Temando_Temando_Model_Checkout_Delivery_Options::DESTINATION_RESIDENCE
139
- );
140
- }
141
-
142
- /**
143
- * Checks if the to address is within allowed countries
144
- *
145
- * @return boolean
146
- */
147
- protected function _canShip(Mage_Shipping_Model_Rate_Request $request)
148
- {
149
- return array_key_exists($request->getDestCountryId(), Mage::helper('temando')->getAllowedCountries());
150
- }
151
-
152
- /**
153
- * Creates a rate method based on a Temando API quote.
154
- *
155
- * @param Mage_Shipping_Model_Rate_Result_Method the quote from the
156
- * Temando API.
157
- *
158
- * @return Mage_Shipping_Model_Rate_Result_Method
159
- */
160
- protected function _getRateFromQuote($quote, $method_id)
161
- {
162
- $price = $this->getFinalPriceWithHandlingFee($quote->getTotalPrice());
163
- $title = $quote->getDescription($this->getConfigData('options/show_transit_type'), $this->getConfigData('options/show_transit_time'));
164
-
165
- $method = Mage::getModel('shipping/rate_result_method')
166
- ->setCarrier($this->_code)
167
- ->setCarrierTitle(self::getTitle())
168
- ->setMethodTitle($title)
169
- ->setMethod($method_id)
170
- ->setPrice($price)
171
- ->setCost($quote->getTotalPrice());
172
-
173
- return $method;
174
- }
175
-
176
- /**
177
- * Creates the flat rate method, with the price set in the config. An
178
- * optional parameter allows the price to be overridden.
179
- *
180
- * @return Mage_Shipping_Model_Rate_Result_Method
181
- */
182
- protected function _getFlatRateMethod($price = false, $free = false)
183
- {
184
- if ($price === false) {
185
- $cost = $this->getConfigData('pricing/shipping_fee');
186
- $price = $this->getFinalPriceWithHandlingFee($cost);
187
- } else {
188
- $cost = $price;
189
- }
190
-
191
- $title = $free ? Mage::helper('temando')->__('Free Shipping') : Mage::helper('temando')->__('Flat Rate');
192
- $method = Mage::getModel('shipping/rate_result_method')
193
- ->setCarrier($this->_code)
194
- ->setCarrierTitle(self::getTitle())
195
- ->setMethodTitle($title)
196
- ->setMethod($free ? Temando_Temando_Model_Carrier::FREE : Temando_Temando_Model_Carrier::FLAT_RATE)
197
- ->setPrice($price)
198
- ->setCost($cost);
199
-
200
- return $method;
201
- }
202
-
203
- /**
204
- * Returns shipping rate result error method
205
- *
206
- * @param string $errorText
207
- * @return Mage_Shipping_Model_Rate_Result_Error
208
- */
209
- protected function _getErrorMethod($errorText)
210
- {
211
- $error = Mage::getModel('shipping/rate_result_error');
212
- $error->setCarrier($this->_code);
213
- $error->setCarrierTitle(self::getTitle());
214
- if (isset(self::$_errors_map[$errorText])) {
215
- $errorText = self::$_errors_map[$errorText];
216
- }
217
- $error->setErrorMessage($errorText);
218
-
219
- return $error;
220
- }
221
-
222
- /**
223
- * Creates a string describing the applicable elements of a rate request.
224
- *
225
- * This is used to determine if the quotes fetched last time should be
226
- * refreshed, or if they can remain valid.
227
- *
228
- * @param Mage_Shipping_Model_Rate_Request $rate_request
229
- *
230
- * @return boolean
231
- */
232
- protected function _createRequestString(Mage_Shipping_Model_Rate_Request $request, $salesQuoteId)
233
- {
234
- $requestString = $salesQuoteId . '|';
235
- foreach ($request->getAllItems() as $item) {
236
- $requestString .= $item->getProductId() . 'x' . $item->getQty();
237
- }
238
-
239
- $requestString .= '|' . $request->getDestCity();
240
- $requestString .= '|' . $request->getDestCountryId();
241
- $requestString .= '|' . $request->getDestPostcode();
242
- $requestString .= '|' . $this->getDestinationType();
243
-
244
- return $requestString;
245
- }
246
-
247
- /**
248
- * Returns available shipping methods for current request based on pricing method
249
- * specified in Temando Settings
250
- *
251
- * @param Mage_Shipping_Model_Rate_Request $request
252
- * @return Mage_Shipping_Model_Rate_Result|Mage_Shipping_Model_Rate_Result_Error
253
- */
254
- public function collectRates(Mage_Shipping_Model_Rate_Request $request)
255
- {
256
- $result = Mage::getModel('shipping/rate_result');
257
- /* @var $result Mage_Shipping_Model_Rate_Result */
258
-
259
- //check origin/destination country
260
- if (!$this->_canShip($request)) {
261
- return;
262
- // by default no error will show. Remove the above and uncomment
263
- // the line below to enable an error in the shipping method
264
- // return $this->_getErrorMethod(self::ERR_INVALID_COUNTRY);
265
- }
266
-
267
- //OneStepCheckout inserts '-' in city/pcode if no default configured
268
- if (!$request->getDestCountryId() || !$request->getDestPostcode() || !$request->getDestCity() ||
269
- $request->getDestPostcode() == '-' || $request->getDestCity() == '-') {
270
- return $this->_getErrorMethod(self::ERR_INVALID_DEST);
271
- }
272
-
273
- //get magento sales quote & id
274
- $salesQuote = Mage::getSingleton('checkout/session')->getQuote();
275
- /* @var $salesQuote Mage_Sales_Model_Quote */
276
- if (!$salesQuote->getId() && Mage::app()->getStore()->isAdmin()) {
277
- $salesQuote = Mage::getSingleton('adminhtml/session_quote')->getQuote();
278
- }
279
- if ($this->getIsProductPage()) {
280
- $salesQuote = Mage::helper('temando')->getDummySalesQuoteFromRequest($request);
281
- }
282
- $salesQuoteId = $salesQuote->getId();
283
-
284
- //check if eligible for free shipping
285
- if ($this->isFreeShipping($salesQuote)) {
286
- $result->append($this->_getFlatRateMethod('0.00', true));
287
- return $result;
288
- }
289
-
290
- //check for flat rate
291
- if ($this->_pricing_method == Temando_Temando_Model_System_Config_Source_Pricing::FLAT_RATE) {
292
- $result->append($this->_getFlatRateMethod());
293
- return $result;
294
- }
295
-
296
- //prepare extras
297
- $insurance = Mage::getModel('temando/option_insurance')->setSetting(Mage::getStoreConfig('temando/insurance/status'));
298
- $carbon = Mage::getModel('temando/option_carbonoffset')->setSetting(Mage::getStoreConfig('temando/carbon/status'));
299
- $footprints = Mage::getModel('temando/option_footprints')->setSetting(Mage::getStoreConfig('temando/footprints/status'));
300
-
301
- if ($this->getIsProductPage() || $this->getIsCartPage())
302
- {
303
- if (!in_array($insurance->getForcedValue(), array(Temando_Temando_Model_Option_Boolean::YES, Temando_Temando_Model_Option_Boolean::NO))) {
304
- $insurance->setForcedValue(Temando_Temando_Model_Option_Boolean::NO);
305
- }
306
-
307
- if (!in_array($carbon->getForcedValue(), array(Temando_Temando_Model_Option_Boolean::YES, Temando_Temando_Model_Option_Boolean::NO))) {
308
- $carbon->setForcedValue(Temando_Temando_Model_Option_Boolean::NO);
309
- }
310
-
311
- if (!in_array($footprints->getForcedValue(), array(Temando_Temando_Model_Option_Boolean::YES, Temando_Temando_Model_Option_Boolean::NO))) {
312
- $footprints->setForcedValue(Temando_Temando_Model_Option_Boolean::NO);
313
- }
314
- }
315
- /* @var Temando_Temando_Model_Options $options */
316
- $options = Mage::getModel('temando/options')->addItem($insurance)->addItem($carbon)->addItem($footprints);
317
-
318
- //save current extras
319
- if (is_null(Mage::registry('temando_current_options'))) {
320
- Mage::register('temando_current_options', $options);
321
- }
322
-
323
- //get available shipping methods (quotes from the API)
324
- //check if request same as previous
325
- $lastRequest = Mage::getSingleton('checkout/session')->getTemandoRequestString();
326
- if ($lastRequest == $this->_createRequestString($request, $salesQuoteId) && !$this->getUpdateDeliveryOptions())
327
- {
328
- //request is the same as previous, load existing quotes from DB
329
- $quotes = Mage::getModel('temando/quote')->getCollection()
330
- ->addFieldToFilter('magento_quote_id', $salesQuoteId)
331
- ->getItems();
332
- }
333
- else
334
- {
335
- try {
336
- $apiRequest = Mage::getModel('temando/api_request');
337
- $apiRequest
338
- ->setUsername($this->getConfigData('general/username'))
339
- ->setPassword($this->getConfigData('general/password'))
340
- ->setSandbox($this->getConfigData('general/sandbox'))
341
- ->setMagentoQuoteId($salesQuoteId)
342
- ->setDestination(
343
- $request->getDestCountryId(),
344
- $request->getDestPostcode(),
345
- $request->getDestCity(),
346
- $request->getDestStreet(),
347
- $this->getDestinationType())
348
- ->setItems($request->getAllItems())
349
- ->setReady(Mage::helper('temando')->getReadyDate())
350
- ->setDeliveryOptions($this->getDeliveryOptions())
351
- ->setAllowedCarriers($this->getAllowedMethods());
352
-
353
- $coll = $apiRequest->getQuotes();
354
- if ($coll instanceof Temando_Temando_Model_Mysql4_Quote_Collection) {
355
- $quotes = $coll->getItems();
356
- }
357
- } catch (Exception $e) {
358
- switch(Mage::helper('temando')->getConfigData('pricing/error_process')) {
359
- case Temando_Temando_Model_System_Config_Source_Errorprocess::VIEW:
360
- return $this->_getErrorMethod($e->getMessage());
361
- break;
362
- case Temando_Temando_Model_System_Config_Source_Errorprocess::FLAT:
363
- $result->append($this->_getFlatRateMethod());
364
- return $result;
365
- break;
366
- }
367
- }
368
- }
369
-
370
- //process filters and apply extras
371
- if(empty($quotes)) {
372
- return $this->_getErrorMethod(self::ERR_NO_METHODS);
373
- } else {
374
- switch($this->_pricing_method) {
375
- case Temando_Temando_Model_System_Config_Source_Pricing::DYNAMIC_CHEAPEST:
376
- $quotes = Mage::helper('temando/functions')->getCheapestQuote($quotes);
377
- break;
378
- case Temando_Temando_Model_System_Config_Source_Pricing::DYNAMIC_FASTEST:
379
- $quotes = Mage::helper('temando/functions')->getFastestQuote($quotes);
380
- break;
381
- case Temando_Temando_Model_System_Config_Source_Pricing::DYNAMIC_FASTEST_AND_CHEAPEST:
382
- $quotes = Mage::helper('temando/functions')->getCheapestAndFastestQuotes($quotes);
383
- break;
384
- }
385
- if(!is_array($quotes)) { $quotes = array($quotes); }
386
- foreach($quotes as $id => $quote)
387
- {
388
- $permutations = $options->applyAll($quote);
389
- foreach($permutations as $permId => $permutation) {
390
- $result->append($this->_getRateFromQuote($permutation, $quote->getId() . '_' . $permId));
391
- }
392
- }
393
-
394
- }
395
-
396
- Mage::getSingleton('checkout/session')->setTemandoRequestString($this->_createRequestString($request, $salesQuoteId));
397
- return $result;
398
- }
399
-
400
- /**
401
- * Returns true if request is elegible for free shipping, false otherwise
402
- *
403
- * @param Mage_Sales_Model_Quote $salesQuote
404
- * @return boolean
405
- */
406
- public function isFreeShipping($salesQuote)
407
- {
408
- //check pricing method first
409
- if($this->_pricing_method == Temando_Temando_Model_System_Config_Source_Pricing::FREE) {
410
- return true;
411
- }
412
-
413
- //check if all items have free shipping or free shipping over amount enabled and valid for this request
414
- $allItemsFree = true; $total = 0;
415
- foreach ($salesQuote->getAllItems() as $item) {
416
- /* @var $item Mage_Sales_Model_Quote_Item */
417
- if ($item->getProduct()->isVirtual() || $item->getParentItem()) { continue; }
418
- if ($item->getFreeShipping()) { continue; }
419
-
420
- //not all items with free shipping if here
421
- $allItemsFree = false;
422
- }
423
-
424
- if ($allItemsFree) {
425
- return true;
426
- }
427
-
428
- return false;
429
- }
430
-
431
- /**
432
- * Return list of allowed carriers
433
- *
434
- * @return array
435
- */
436
- public function getAllowedMethods()
437
- {
438
- return explode(',', Mage::getStoreConfig('carriers/temando/allowed_methods'));
439
- }
440
-
441
- public function getTrackingInfo($tracking_number)
442
- {
443
- $api = Mage::getModel('temando/api_client');
444
- $api->connect(
445
- Mage::helper('temando')->getConfigData('general/username'),
446
- Mage::helper('temando')->getConfigData('general/password'),
447
- Mage::helper('temando')->getConfigData('general/sandbox'));
448
-
449
- $_t = explode('Request Id: ', $tracking_number);
450
- if (isset($_t[1])) {
451
- $tracking_number = $_t[1];
452
- }
453
-
454
- $status = $api->getRequest(array('requestId' => $tracking_number));
455
-
456
- $result = Mage::getModel('shipping/tracking_result_abstract')
457
- ->setTracking($tracking_number);
458
- /* @var $result Mage_Shipping_Model_Tracking_Result_Abstract */
459
- if ($status && $status->request->quotes && $status->request->quotes->quote) {
460
- if (isset($status->request->quotes->quote->carrier->companyName)) {
461
- $result->setCarrierTitle($status->request->quotes->quote->carrier->companyName);
462
- }
463
-
464
- if (isset($status->request->quotes->quote->trackingStatus)) {
465
- $result->setStatus($status->request->quotes->quote->trackingStatus);
466
- } else {
467
- $result->setStatus(Mage::helper('temando')->__('Unavailable'));
468
- }
469
-
470
- $text = '';
471
- if (isset($status->request->quotes->quote->trackingFurtherDetails)) {
472
- $text .= $status->request->quotes->quote->trackingFurtherDetails;
473
- }
474
- if (isset($status->request->quotes->quote->trackingLastChecked)) {
475
- $text .= 'Last Update: ' . date('Y-m-d h:ia', strtotime($status->request->quotes->quote->trackingLastChecked));
476
- }
477
-
478
- if ($text) {
479
- $result->setTrackSummary($text);
480
- }
481
-
482
- if (isset($status->request->quotes->quote->trackingHistories->trackingHistory)) {
483
- if (!is_array($status->request->quotes->quote->trackingHistories->trackingHistory)) {
484
- $status->request->quotes->quote->trackingHistories->trackingHistory =
485
- array(0 => $status->request->quotes->quote->trackingHistories->trackingHistory);
486
- }
487
- $trackingHistories = array();
488
- foreach ($status->request->quotes->quote->trackingHistories->trackingHistory as $trackData) {
489
- $trackingHistories[] = array(
490
- 'deliverylocation' => $trackData->trackingStatus,
491
- 'deliverydate' => date('Y-m-d', strtotime($trackData->trackingStatusOccurred)),
492
- 'deliverytime' => date('h:ia', strtotime($trackData->trackingStatusOccurred)),
493
- 'activity' => $trackData->trackingFurtherDetails
494
- );
495
- }
496
- $result->setProgressdetail($trackingHistories);
497
- }
498
- } else {
499
- $result->setErrorMessage(Mage::helper('temando')->__('An error occurred while fetching the shipment status.'));
500
- }
501
-
502
- return $result;
503
- }
504
-
505
- public function getConfigData($field)
506
- {
507
- if (in_array($field, array('handling_fee', 'handling_type'))) {
508
- $field = 'pricing/' . $field;
509
- }
510
-
511
- $parent = parent::getConfigData($field);
512
- return $parent !== null ? $parent : Mage::helper('temando')->getConfigData($field);
513
- }
514
-
515
- /**
516
- * Returns Temando carrier code
517
- *
518
- * @return string
519
- */
520
- public function getCode()
521
- {
522
- return $this->_code;
523
- }
524
-
525
- /**
526
- * Returns Temando carrier title
527
- *
528
- * @return string
529
- */
530
- static public function getTitle()
531
- {
532
- $config = Mage::getStoreConfig('carriers/temando/title');
533
- return $config ? $config : $this->_title;
534
- }
535
-
536
- /**
537
- * Is state province required
538
- *
539
- * @return bool
540
- */
541
- public function isStateProvinceRequired()
542
- {
543
- return false;
544
- }
545
-
546
- /**
547
- * Check if city option required
548
- *
549
- * @return boolean
550
- */
551
- public function isCityRequired()
552
- {
553
- return true;
554
- }
555
-
556
- /**
557
- * Determine whether zip-code is required for the country of destination
558
- *
559
- * @param string|null $countryId
560
- * @return bool
561
- */
562
- public function isZipCodeRequired($countryId = null)
563
- {
564
- return true;
565
- }
566
-
567
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ /**
4
+ * Temando Carrier
5
+ *
6
+ * @package Temando_Temando
7
+ * @author Temando Magento Team <marketing@temando.com>
8
+ *
9
+ * @method Temando_Temando_Model_Shipping_Carrier_Temando setIsProductPage(boolean $flag)
10
+ * @method Temando_Temando_Model_Shipping_Carrier_Temando setIsCartPage(boolean $flag)
11
+ * @method Temando_Temando_Model_Shipping_Carrier_Temando setDeliveryOptions()
12
+ * @method Temando_Temando_Model_Shipping_Carrier_Temando setDestinationType()
13
+ * @method Temando_Temando_Model_Shipping_Carrier_Temando setUpdateDeliveryOptions(boolean $flag)
14
+ *
15
+ * @method boolean getIsProductPage()
16
+ * @method boolean getIsCartPage()
17
+ * @method array getDeliveryOptions()
18
+ * @method string getDestinationType()
19
+ * @method boolean getUpdateDeliveryOptions()
20
+ */
21
+
22
+
23
+ class Temando_Temando_Model_Shipping_Carrier_Temando
24
+ extends Mage_Shipping_Model_Carrier_Abstract
25
+ implements Mage_Shipping_Model_Carrier_Interface
26
+ {
27
+ /**
28
+ * Error Constants
29
+ */
30
+ const ERR_INVALID_COUNTRY = 'Sorry, shipping to selected country is not available.';
31
+ const ERR_INVALID_DEST = 'Please enter a delivery address to view available shipping methods';
32
+ const ERR_NO_METHODS = 'No shipping methods available';
33
+ const ERR_INTERNATIONAL = 'International delivery is not available at this time.';
34
+
35
+ /**
36
+ * Carrier's code
37
+ */
38
+ const CARRIER_CODE = 'temando';
39
+
40
+ /**
41
+ * Error Map
42
+ *
43
+ * @var array
44
+ */
45
+ protected static $_errors_map = array(
46
+ "The 'destinationCountry', 'destinationCode' and 'destinationSuburb' elements
47
+ (within the 'Anywhere' type) do not contain valid values.
48
+ These values must match with the predefined settings in the Temando system."
49
+ => "Invalid suburb / postcode combination."
50
+ );
51
+
52
+ /**
53
+ * Carrier's code
54
+ *
55
+ * @var string
56
+ */
57
+ protected $_code = 'temando';
58
+
59
+ /**
60
+ * Carrier's title
61
+ *
62
+ * @var string
63
+ */
64
+ protected $_title = 'Temando';
65
+
66
+ /**
67
+ * Rates result
68
+ *
69
+ * @var array|null
70
+ */
71
+ protected $_rates;
72
+
73
+ /**
74
+ * @var Mage_Shipping_Model_Rate_Request
75
+ */
76
+ protected $_rate_request;
77
+
78
+ /**
79
+ * Current pricing method as set in Temando Settings
80
+ *
81
+ * @var string
82
+ */
83
+ protected $_pricing_method;
84
+
85
+ /**
86
+ * Check if carrier has shipping tracking option available
87
+ *
88
+ * @return boolean
89
+ */
90
+ public function isTrackingAvailable()
91
+ {
92
+ return true;
93
+ }
94
+
95
+ /**
96
+ * Check if carrier has shipping label option available
97
+ *
98
+ * @return boolean
99
+ */
100
+ public function isShippingLabelsAvailable()
101
+ {
102
+ return false;
103
+ }
104
+
105
+
106
+ public function __construct()
107
+ {
108
+ parent::__construct();
109
+ $this->_pricing_method = $this->getConfigData('pricing/method');
110
+ $this->setIsProductPage(
111
+ ("etemando" == Mage::app()->getRequest()->getModuleName()) &&
112
+ ("pcs" == Mage::app()->getRequest()->getControllerName())
113
+ );
114
+ $this->setIsCartPage(
115
+ ("checkout" == Mage::app()->getRequest()->getModuleName()) &&
116
+ ("cart" == Mage::app()->getRequest()->getControllerName())
117
+ );
118
+
119
+ $this->setUpdateDeliveryOptions(Mage::app()->getRequest()->getParam('delivery_option_change', false));
120
+
121
+ if ($this->getUpdateDeliveryOptions()) {
122
+ Mage::getSingleton('checkout/session')->setData(
123
+ 'selected_delivery_options',
124
+ Mage::app()->getRequest()->getParam(
125
+ 'delivery_options',
126
+ array()
127
+ )
128
+ );
129
+ Mage::getSingleton('checkout/session')->setData(
130
+ 'destination_type',
131
+ Mage::app()->getRequest()->getParam(
132
+ 'destination_type',
133
+ Temando_Temando_Model_Checkout_Delivery_Options::DESTINATION_RESIDENCE
134
+ )
135
+ );
136
+ }
137
+
138
+ $this->setDeliveryOptions(
139
+ is_array(Mage::getSingleton('checkout/session')->getData('selected_delivery_options')) ?
140
+ Mage::getSingleton('checkout/session')->getData('selected_delivery_options') :
141
+ array()
142
+ );
143
+ $this->setDestinationType(
144
+ Mage::getSingleton('checkout/session')->getData('destination_type') ?
145
+ Mage::getSingleton('checkout/session')->getData('destination_type') :
146
+ Temando_Temando_Model_Checkout_Delivery_Options::DESTINATION_RESIDENCE
147
+ );
148
+ }
149
+
150
+ /**
151
+ * Checks if the to address is within allowed countries
152
+ *
153
+ * @return boolean
154
+ */
155
+ protected function _canShip(Mage_Shipping_Model_Rate_Request $request)
156
+ {
157
+ return array_key_exists($request->getDestCountryId(), Mage::helper('temando')->getAllowedCountries());
158
+ }
159
+
160
+ /**
161
+ * Creates a rate method based on a Temando API quote.
162
+ *
163
+ * @param Mage_Shipping_Model_Rate_Result_Method the quote from the
164
+ * Temando API.
165
+ *
166
+ * @return Mage_Shipping_Model_Rate_Result_Method
167
+ */
168
+ protected function _getRateFromQuote($quote, $method_id)
169
+ {
170
+ $price = $this->getFinalPriceWithHandlingFee($quote->getTotalPrice());
171
+ $title = $quote->getDescription(
172
+ $this->getConfigData('options/show_transit_type'),
173
+ $this->getConfigData('options/show_transit_time')
174
+ );
175
+
176
+ $method = Mage::getModel('shipping/rate_result_method')
177
+ ->setCarrier($this->_code)
178
+ ->setCarrierTitle(self::getTitle())
179
+ ->setMethodTitle($title)
180
+ ->setMethod($method_id)
181
+ ->setPrice($price)
182
+ ->setCost($quote->getTotalPrice());
183
+
184
+ return $method;
185
+ }
186
+
187
+ /**
188
+ * Creates the flat rate method, with the price set in the config. An
189
+ * optional parameter allows the price to be overridden.
190
+ *
191
+ * @return Mage_Shipping_Model_Rate_Result_Method
192
+ */
193
+ protected function _getFlatRateMethod($price = false, $free = false)
194
+ {
195
+ if ($price === false) {
196
+ $cost = $this->getConfigData('pricing/shipping_fee');
197
+ $price = $this->getFinalPriceWithHandlingFee($cost);
198
+ } else {
199
+ $cost = $price;
200
+ }
201
+
202
+ $title = $free ? Mage::helper('temando')->__('Free Shipping') : Mage::helper('temando')->__('Flat Rate');
203
+ $method = Mage::getModel('shipping/rate_result_method')
204
+ ->setCarrier($this->_code)
205
+ ->setCarrierTitle(self::getTitle())
206
+ ->setMethodTitle($title)
207
+ ->setMethod($free ? Temando_Temando_Model_Carrier::FREE : Temando_Temando_Model_Carrier::FLAT_RATE)
208
+ ->setPrice($price)
209
+ ->setCost($cost);
210
+
211
+ return $method;
212
+ }
213
+
214
+ /**
215
+ * Returns shipping rate result error method
216
+ *
217
+ * @param string $errorText
218
+ * @return Mage_Shipping_Model_Rate_Result_Error
219
+ */
220
+ protected function _getErrorMethod($errorText)
221
+ {
222
+ $error = Mage::getModel('shipping/rate_result_error');
223
+ $error->setCarrier($this->_code);
224
+ $error->setCarrierTitle(self::getTitle());
225
+ if (isset(self::$_errors_map[$errorText])) {
226
+ $errorText = self::$_errors_map[$errorText];
227
+ }
228
+ $error->setErrorMessage($errorText);
229
+
230
+ return $error;
231
+ }
232
+
233
+ /**
234
+ * Creates a string describing the applicable elements of a rate request.
235
+ *
236
+ * This is used to determine if the quotes fetched last time should be
237
+ * refreshed, or if they can remain valid.
238
+ *
239
+ * @param Mage_Shipping_Model_Rate_Request $rate_request
240
+ *
241
+ * @return boolean
242
+ */
243
+ protected function _createRequestString(Mage_Shipping_Model_Rate_Request $request, $salesQuoteId)
244
+ {
245
+ $requestString = $salesQuoteId . '|';
246
+ foreach ($request->getAllItems() as $item) {
247
+ $requestString .= $item->getProductId() . 'x' . $item->getQty();
248
+ }
249
+
250
+ $requestString .= '|' . $request->getDestCity();
251
+ $requestString .= '|' . $request->getDestCountryId();
252
+ $requestString .= '|' . $request->getDestPostcode();
253
+ $requestString .= '|' . $this->getDestinationType();
254
+
255
+ return $requestString;
256
+ }
257
+
258
+ /**
259
+ * Returns available shipping methods for current request based on pricing method
260
+ * specified in Temando Settings
261
+ *
262
+ * @param Mage_Shipping_Model_Rate_Request $request
263
+ * @return Mage_Shipping_Model_Rate_Result|Mage_Shipping_Model_Rate_Result_Error
264
+ */
265
+ public function collectRates(Mage_Shipping_Model_Rate_Request $request)
266
+ {
267
+ $result = Mage::getModel('shipping/rate_result');
268
+ /* @var $result Mage_Shipping_Model_Rate_Result */
269
+
270
+ //check origin/destination country
271
+ if (!$this->_canShip($request)) {
272
+ return;
273
+ // by default no error will show. Remove the above and uncomment
274
+ // the line below to enable an error in the shipping method
275
+ // return $this->_getErrorMethod(self::ERR_INVALID_COUNTRY);
276
+ }
277
+
278
+ //OneStepCheckout inserts '-' in city/pcode if no default configured
279
+ if (!$request->getDestCountryId() || !$request->getDestPostcode() || !$request->getDestCity() ||
280
+ $request->getDestPostcode() == '-' || $request->getDestCity() == '-') {
281
+ return $this->_getErrorMethod(self::ERR_INVALID_DEST);
282
+ }
283
+
284
+ //get magento sales quote & id
285
+ $salesQuote = Mage::getSingleton('checkout/session')->getQuote();
286
+ /* @var $salesQuote Mage_Sales_Model_Quote */
287
+ if (!$salesQuote->getId() && Mage::app()->getStore()->isAdmin()) {
288
+ $salesQuote = Mage::getSingleton('adminhtml/session_quote')->getQuote();
289
+ }
290
+ if ($this->getIsProductPage()) {
291
+ $salesQuote = Mage::helper('temando')->getDummySalesQuoteFromRequest($request);
292
+ }
293
+ $salesQuoteId = $salesQuote->getId();
294
+
295
+ //check if eligible for free shipping
296
+ if ($this->isFreeShipping($salesQuote)) {
297
+ $result->append($this->_getFlatRateMethod('0.00', true));
298
+ return $result;
299
+ }
300
+
301
+ //check for flat rate
302
+ if ($this->_pricing_method == Temando_Temando_Model_System_Config_Source_Pricing::FLAT_RATE) {
303
+ $result->append($this->_getFlatRateMethod());
304
+ return $result;
305
+ }
306
+
307
+ //prepare extras
308
+ $insurance = Mage::getModel('temando/option_insurance')
309
+ ->setSetting(Mage::getStoreConfig('temando/insurance/status'));
310
+ $carbon = Mage::getModel('temando/option_carbonoffset')
311
+ ->setSetting(Mage::getStoreConfig('temando/carbon/status'));
312
+ $footprints = Mage::getModel('temando/option_footprints')
313
+ ->setSetting(Mage::getStoreConfig('temando/footprints/status'));
314
+
315
+ if ($this->getIsProductPage() || $this->getIsCartPage()) {
316
+ if (!in_array($insurance->getForcedValue(), array(Temando_Temando_Model_Option_Boolean::YES,
317
+ Temando_Temando_Model_Option_Boolean::NO))) {
318
+ $insurance->setForcedValue(Temando_Temando_Model_Option_Boolean::NO);
319
+ }
320
+
321
+ if (!in_array($carbon->getForcedValue(), array(Temando_Temando_Model_Option_Boolean::YES,
322
+ Temando_Temando_Model_Option_Boolean::NO))) {
323
+ $carbon->setForcedValue(Temando_Temando_Model_Option_Boolean::NO);
324
+ }
325
+
326
+ if (!in_array($footprints->getForcedValue(), array(Temando_Temando_Model_Option_Boolean::YES,
327
+ Temando_Temando_Model_Option_Boolean::NO))) {
328
+ $footprints->setForcedValue(Temando_Temando_Model_Option_Boolean::NO);
329
+ }
330
+ }
331
+ /* @var Temando_Temando_Model_Options $options */
332
+ $options = Mage::getModel('temando/options')->addItem($insurance)->addItem($carbon)->addItem($footprints);
333
+
334
+ //save current extras
335
+ if (is_null(Mage::registry('temando_current_options'))) {
336
+ Mage::register('temando_current_options', $options);
337
+ }
338
+
339
+ //get available shipping methods (quotes from the API)
340
+ //check if request same as previous
341
+ $lastRequest = Mage::getSingleton('checkout/session')->getTemandoRequestString();
342
+ if ($lastRequest == $this->_createRequestString($request, $salesQuoteId) &&
343
+ !$this->getUpdateDeliveryOptions()) {
344
+ //request is the same as previous, load existing quotes from DB
345
+ $quotes = Mage::getModel('temando/quote')->getCollection()
346
+ ->addFieldToFilter('magento_quote_id', $salesQuoteId)
347
+ ->getItems();
348
+ } else {
349
+ try {
350
+ $apiRequest = Mage::getModel('temando/api_request');
351
+ $apiRequest
352
+ ->setUsername($this->getConfigData('general/username'))
353
+ ->setPassword($this->getConfigData('general/password'))
354
+ ->setSandbox($this->getConfigData('general/sandbox'))
355
+ ->setMagentoQuoteId($salesQuoteId)
356
+ ->setDestination(
357
+ $request->getDestCountryId(),
358
+ $request->getDestPostcode(),
359
+ $request->getDestCity(),
360
+ $request->getDestStreet(),
361
+ $this->getDestinationType()
362
+ )
363
+ ->setItems($request->getAllItems())
364
+ ->setReady(Mage::helper('temando')->getReadyDate())
365
+ ->setDeliveryOptions($this->getDeliveryOptions())
366
+ ->setAllowedCarriers($this->getAllowedMethods());
367
+
368
+ $coll = $apiRequest->getQuotes();
369
+ if ($coll instanceof Temando_Temando_Model_Mysql4_Quote_Collection) {
370
+ $quotes = $coll->getItems();
371
+ }
372
+ } catch (Exception $e) {
373
+ switch (Mage::helper('temando')->getConfigData('pricing/error_process')) {
374
+ case Temando_Temando_Model_System_Config_Source_Errorprocess::VIEW:
375
+ return $this->_getErrorMethod($e->getMessage());
376
+ break;
377
+ case Temando_Temando_Model_System_Config_Source_Errorprocess::FLAT:
378
+ $result->append($this->_getFlatRateMethod());
379
+ return $result;
380
+ break;
381
+ }
382
+ }
383
+ }
384
+
385
+ //process filters and apply extras
386
+ if (empty($quotes)) {
387
+ return $this->_getErrorMethod(self::ERR_NO_METHODS);
388
+ } else {
389
+ switch($this->_pricing_method) {
390
+ case Temando_Temando_Model_System_Config_Source_Pricing::DYNAMIC_CHEAPEST:
391
+ $quotes = Mage::helper('temando/functions')->getCheapestQuote($quotes);
392
+ break;
393
+ case Temando_Temando_Model_System_Config_Source_Pricing::DYNAMIC_FASTEST:
394
+ $quotes = Mage::helper('temando/functions')->getFastestQuote($quotes);
395
+ break;
396
+ case Temando_Temando_Model_System_Config_Source_Pricing::DYNAMIC_FASTEST_AND_CHEAPEST:
397
+ $quotes = Mage::helper('temando/functions')->getCheapestAndFastestQuotes($quotes);
398
+ break;
399
+ }
400
+ if (!is_array($quotes)) {
401
+ $quotes = array($quotes);
402
+ }
403
+ foreach ($quotes as $id => $quote) {
404
+ $permutations = $options->applyAll($quote);
405
+ foreach ($permutations as $permId => $permutation) {
406
+ $result->append($this->_getRateFromQuote($permutation, $quote->getId() . '_' . $permId));
407
+ }
408
+ }
409
+ }
410
+ Mage::getSingleton('checkout/session')->setTemandoRequestString(
411
+ $this->_createRequestString($request, $salesQuoteId)
412
+ );
413
+ return $result;
414
+ }
415
+
416
+ /**
417
+ * Returns true if request is elegible for free shipping, false otherwise
418
+ *
419
+ * @param Mage_Sales_Model_Quote $salesQuote
420
+ * @return boolean
421
+ */
422
+ public function isFreeShipping($salesQuote)
423
+ {
424
+ //check pricing method first
425
+ if ($this->_pricing_method == Temando_Temando_Model_System_Config_Source_Pricing::FREE) {
426
+ return true;
427
+ }
428
+
429
+ //check if all items have free shipping or free shipping over amount enabled and valid for this request
430
+ $allItemsFree = true;
431
+ $total = 0;
432
+ foreach ($salesQuote->getAllItems() as $item) {
433
+ /* @var $item Mage_Sales_Model_Quote_Item */
434
+ if ($item->getProduct()->isVirtual() || $item->getParentItem()) {
435
+ continue;
436
+ }
437
+ if ($item->getFreeShipping()) {
438
+ continue;
439
+ }
440
+
441
+ //not all items with free shipping if here
442
+ $allItemsFree = false;
443
+ }
444
+
445
+ if ($allItemsFree) {
446
+ return true;
447
+ }
448
+
449
+ return false;
450
+ }
451
+
452
+ /**
453
+ * Return list of allowed carriers
454
+ *
455
+ * @return array
456
+ */
457
+ public function getAllowedMethods()
458
+ {
459
+ return explode(',', Mage::getStoreConfig('carriers/temando/allowed_methods'));
460
+ }
461
+
462
+ public function getTrackingInfo($tracking_number)
463
+ {
464
+ $api = Mage::getModel('temando/api_client');
465
+ $api->connect(
466
+ Mage::helper('temando')->getConfigData('general/username'),
467
+ Mage::helper('temando')->getConfigData('general/password'),
468
+ Mage::helper('temando')->getConfigData('general/sandbox')
469
+ );
470
+
471
+ $_t = explode('Request Id: ', $tracking_number);
472
+ if (isset($_t[1])) {
473
+ $tracking_number = $_t[1];
474
+ }
475
+
476
+ $status = $api->getRequest(array('requestId' => $tracking_number));
477
+
478
+ $result = Mage::getModel('shipping/tracking_result_abstract')
479
+ ->setTracking($tracking_number);
480
+ /* @var $result Mage_Shipping_Model_Tracking_Result_Abstract */
481
+ if ($status && $status->request->quotes && $status->request->quotes->quote) {
482
+ if (isset($status->request->quotes->quote->carrier->companyName)) {
483
+ $result->setCarrierTitle($status->request->quotes->quote->carrier->companyName);
484
+ }
485
+
486
+ if (isset($status->request->quotes->quote->trackingStatus)) {
487
+ $result->setStatus($status->request->quotes->quote->trackingStatus);
488
+ } else {
489
+ $result->setStatus(Mage::helper('temando')->__('Unavailable'));
490
+ }
491
+
492
+ $text = '';
493
+ if (isset($status->request->quotes->quote->trackingFurtherDetails)) {
494
+ $text .= $status->request->quotes->quote->trackingFurtherDetails;
495
+ }
496
+ if (isset($status->request->quotes->quote->trackingLastChecked)) {
497
+ $text .= 'Last Update: ' .
498
+ date('Y-m-d h:ia', strtotime($status->request->quotes->quote->trackingLastChecked));
499
+ }
500
+
501
+ if ($text) {
502
+ $result->setTrackSummary($text);
503
+ }
504
+
505
+ if (isset($status->request->quotes->quote->trackingHistories->trackingHistory)) {
506
+ if (!is_array($status->request->quotes->quote->trackingHistories->trackingHistory)) {
507
+ $status->request->quotes->quote->trackingHistories->trackingHistory =
508
+ array(0 => $status->request->quotes->quote->trackingHistories->trackingHistory);
509
+ }
510
+ $trackingHistories = array();
511
+ foreach ($status->request->quotes->quote->trackingHistories->trackingHistory as $trackData) {
512
+ $trackingHistories[] = array(
513
+ 'deliverylocation' => $trackData->trackingStatus,
514
+ 'deliverydate' => date('Y-m-d', strtotime($trackData->trackingStatusOccurred)),
515
+ 'deliverytime' => date('h:ia', strtotime($trackData->trackingStatusOccurred)),
516
+ 'activity' => $trackData->trackingFurtherDetails
517
+ );
518
+ }
519
+ $result->setProgressdetail($trackingHistories);
520
+ }
521
+ } else {
522
+ $result->setErrorMessage(
523
+ Mage::helper('temando')->__('An error occurred while fetching the shipment status.')
524
+ );
525
+ }
526
+
527
+ return $result;
528
+ }
529
+
530
+ public function getConfigData($field)
531
+ {
532
+ if (in_array($field, array('handling_fee', 'handling_type'))) {
533
+ $field = 'pricing/' . $field;
534
+ }
535
+
536
+ $parent = parent::getConfigData($field);
537
+ return $parent !== null ? $parent : Mage::helper('temando')->getConfigData($field);
538
+ }
539
+
540
+ /**
541
+ * Returns Temando carrier code
542
+ *
543
+ * @return string
544
+ */
545
+ public function getCode()
546
+ {
547
+ return $this->_code;
548
+ }
549
+
550
+ /**
551
+ * Returns Temando carrier title
552
+ *
553
+ * @return string
554
+ */
555
+ static public function getTitle()
556
+ {
557
+ $config = Mage::getStoreConfig('carriers/temando/title');
558
+ return $config ? $config : $this->_title;
559
+ }
560
+
561
+ /**
562
+ * Is state province required
563
+ *
564
+ * @return bool
565
+ */
566
+ public function isStateProvinceRequired()
567
+ {
568
+ return false;
569
+ }
570
+
571
+ /**
572
+ * Check if city option required
573
+ *
574
+ * @return boolean
575
+ */
576
+ public function isCityRequired()
577
+ {
578
+ return true;
579
+ }
580
+
581
+ /**
582
+ * Determine whether zip-code is required for the country of destination
583
+ *
584
+ * @param string|null $countryId
585
+ * @return bool
586
+ */
587
+ public function isZipCodeRequired($countryId = null)
588
+ {
589
+ return true;
590
+ }
591
+
592
+ }
app/code/community/Temando/Temando/Model/Shipping/Carrier/Temando/Source/Method.php CHANGED
@@ -1,82 +1,81 @@
1
- <?php
2
- /**
3
- * Shipping Carrier Temando Source Method
4
- *
5
- * @package Temando_Temando
6
- * @author Temando Magento Team <marketing@temando.com>
7
- */
8
- class Temando_Temando_Model_Shipping_Carrier_Temando_Source_Method
9
- {
10
-
11
- public function toOptionArray()
12
- {
13
- $options = array();
14
-
15
- $carriers = Mage::getModel('temando/carrier')->getCollection();
16
- $carriers->setOrder('company_name', 'ASC');
17
- foreach ($carriers as $carrier) {
18
- $options[] = array('value' => $carrier->getCarrierId(), 'label' => $carrier->getCompanyName());
19
- }
20
-
21
- return $options;
22
- }
23
-
24
-
25
- /**
26
- * Gets all the options in the key => value type array.
27
- *
28
- * @return array
29
- */
30
- public function getOptions($please_select = false)
31
- {
32
- if ($please_select) {
33
- $options = array(null => Mage::helper('temando')->__('--Please Select--'));
34
- }
35
-
36
- $carriers = Mage::getModel('temando/carrier')->getCollection();
37
- $carriers->setOrder('company_name', 'ASC');
38
- foreach ($carriers as $carrier) {
39
- if(!$carrier->getCarrierId())
40
- continue;
41
-
42
- $options[$carrier->getCarrierId()] = $carrier->getCompanyName();
43
- }
44
-
45
- return $options;
46
- }
47
-
48
- /**
49
- * Gets all the options for html form.
50
- *
51
- * @return array ( 0 => array(
52
- * 'label' = 'my label',
53
- * 'value' = 'my value'
54
- * )
55
- * );
56
- */
57
- public function getOptionsForForm($enabledOnly = false)
58
- {
59
- $options = array();
60
- $carriers = Mage::getModel('temando/carrier')->getCollection();
61
- $carriers->setOrder('company_name', 'ASC');
62
- foreach ($carriers as $carrier) {
63
- if(!$carrier->getCarrierId())
64
- continue;
65
-
66
- //skip carriers which are not allowed in config
67
- if($enabledOnly) {
68
- $allowedCarriers = explode(',', Mage::getStoreConfig('carriers/temando/allowed_methods'));
69
- if(!in_array($carrier->getCarrierId(), $allowedCarriers)) {
70
- continue;
71
- }
72
- }
73
-
74
- $options[] = array(
75
- 'label' => $carrier->getCompanyName(),
76
- 'value' => $carrier->getCarrierId()
77
- );
78
- }
79
-
80
- return $options;
81
- }
82
- }
1
+ <?php
2
+ /**
3
+ * Shipping Carrier Temando Source Method
4
+ *
5
+ * @package Temando_Temando
6
+ * @author Temando Magento Team <marketing@temando.com>
7
+ */
8
+ class Temando_Temando_Model_Shipping_Carrier_Temando_Source_Method
9
+ {
10
+
11
+ public function toOptionArray()
12
+ {
13
+ $options = array();
14
+
15
+ $carriers = Mage::getModel('temando/carrier')->getCollection();
16
+ $carriers->setOrder('company_name', 'ASC');
17
+ foreach ($carriers as $carrier) {
18
+ $options[] = array('value' => $carrier->getCarrierId(), 'label' => $carrier->getCompanyName());
19
+ }
20
+
21
+ return $options;
22
+ }
23
+
24
+
25
+ /**
26
+ * Gets all the options in the key => value type array.
27
+ *
28
+ * @return array
29
+ */
30
+ public function getOptions($please_select = false)
31
+ {
32
+ if ($please_select) {
33
+ $options = array(null => Mage::helper('temando')->__('--Please Select--'));
34
+ }
35
+
36
+ $carriers = Mage::getModel('temando/carrier')->getCollection();
37
+ $carriers->setOrder('company_name', 'ASC');
38
+ foreach ($carriers as $carrier) {
39
+ if (!$carrier->getCarrierId()) {
40
+ continue;
41
+ }
42
+ $options[$carrier->getCarrierId()] = $carrier->getCompanyName();
43
+ }
44
+ return $options;
45
+ }
46
+
47
+ /**
48
+ * Gets all the options for html form.
49
+ *
50
+ * @return array ( 0 => array(
51
+ * 'label' = 'my label',
52
+ * 'value' = 'my value'
53
+ * )
54
+ * );
55
+ */
56
+ public function getOptionsForForm($enabledOnly = false)
57
+ {
58
+ $options = array();
59
+ $carriers = Mage::getModel('temando/carrier')->getCollection();
60
+ $carriers->setOrder('company_name', 'ASC');
61
+ foreach ($carriers as $carrier) {
62
+ if (!$carrier->getCarrierId()) {
63
+ continue;
64
+ }
65
+
66
+ //skip carriers which are not allowed in config
67
+ if ($enabledOnly) {
68
+ $allowedCarriers = explode(',', Mage::getStoreConfig('carriers/temando/allowed_methods'));
69
+ if (!in_array($carrier->getCarrierId(), $allowedCarriers)) {
70
+ continue;
71
+ }
72
+ }
73
+
74
+ $options[] = array(
75
+ 'label' => $carrier->getCompanyName(),
76
+ 'value' => $carrier->getCarrierId()
77
+ );
78
+ }
79
+ return $options;
80
+ }
81
+ }
 
app/code/community/Temando/Temando/Model/Status.php CHANGED
@@ -1,29 +1,29 @@
1
- <?php
2
- /**
3
- * Module Status
4
- *
5
- * @package Temando_Temando
6
- * @author Temando Magento Team <marketing@temando.com>
7
- */
8
- class Temando_Temando_Model_Status extends Varien_Object
9
- {
10
-
11
- const STATUS_ENABLED = 1;
12
- const STATUS_DISABLED = 2;
13
-
14
- /**
15
- * Gets the available statuses.
16
- *
17
- * The results are in the format array(code => description).
18
- *
19
- * @return array
20
- */
21
- static public function getOptionArray()
22
- {
23
- return array(
24
- self::STATUS_ENABLED => Mage::helper('temando')->__('Enabled'),
25
- self::STATUS_DISABLED => Mage::helper('temando')->__('Disabled')
26
- );
27
- }
28
-
29
- }
1
+ <?php
2
+ /**
3
+ * Module Status
4
+ *
5
+ * @package Temando_Temando
6
+ * @author Temando Magento Team <marketing@temando.com>
7
+ */
8
+ class Temando_Temando_Model_Status extends Varien_Object
9
+ {
10
+
11
+ const STATUS_ENABLED = 1;
12
+ const STATUS_DISABLED = 2;
13
+
14
+ /**
15
+ * Gets the available statuses.
16
+ *
17
+ * The results are in the format array(code => description).
18
+ *
19
+ * @return array
20
+ */
21
+ static public function getOptionArray()
22
+ {
23
+ return array(
24
+ self::STATUS_ENABLED => Mage::helper('temando')->__('Enabled'),
25
+ self::STATUS_DISABLED => Mage::helper('temando')->__('Disabled')
26
+ );
27
+ }
28
+
29
+ }
app/code/community/Temando/Temando/Model/System/Config/Backend/Form/Field/Required/Businessresidential.php CHANGED
@@ -1,23 +1,23 @@
1
- <?php
2
- /**
3
- * System Config Backend Form Field Required Businessresidential
4
- *
5
- * @package Temando_Temando
6
- * @author Temando Magento Team <marketing@temando.com>
7
- */
8
- class Temando_Temando_Model_System_Config_Backend_Form_Field_Required_Businessresidential
9
- extends Mage_Core_Model_Config_Data
10
- {
11
-
12
- protected function _beforeSave()
13
- {
14
- $value = $this->getValue();
15
- $types = array('Business', 'Residence');
16
-
17
- if (!in_array($value, $types)) {
18
- Mage::throwException(Mage::helper('temando')->__('Please select a location type from the list.', $value));
19
- }
20
- return $this;
21
- }
22
-
23
- }
1
+ <?php
2
+ /**
3
+ * System Config Backend Form Field Required Businessresidential
4
+ *
5
+ * @package Temando_Temando
6
+ * @author Temando Magento Team <marketing@temando.com>
7
+ */
8
+ class Temando_Temando_Model_System_Config_Backend_Form_Field_Required_Businessresidential
9
+ extends Mage_Core_Model_Config_Data
10
+ {
11
+
12
+ protected function _beforeSave()
13
+ {
14
+ $value = $this->getValue();
15
+ $types = array('Business', 'Residence');
16
+
17
+ if (!in_array($value, $types)) {
18
+ Mage::throwException(Mage::helper('temando')->__('Please select a location type from the list.', $value));
19
+ }
20
+ return $this;
21
+ }
22
+
23
+ }
app/code/community/Temando/Temando/Model/System/Config/Backend/Form/Field/Required/Country.php CHANGED
@@ -1,38 +1,38 @@
1
- <?php
2
- /**
3
- * System Config Backend Form Field Required Country
4
- *
5
- * @package Temando_Temando
6
- * @author Temando Magento Team <marketing@temando.com>
7
- */
8
- class Temando_Temando_Model_System_Config_Backend_Form_Field_Required_Country
9
- extends Mage_Core_Model_Config_Data
10
- {
11
-
12
- protected function _beforeSave()
13
- {
14
- $value = $this->getValue();
15
- $collection = Mage::getModel('directory/country')->getCollection();
16
- if (is_callable($collection, "getAllIds")) {
17
- $countries = $collection->getAllIds();
18
-
19
- if (!in_array($value, $countries)) {
20
- Mage::throwException(Mage::helper('temando')->__('Please select a country from the list.', $value));
21
- }
22
- } else {
23
- $countries = $collection->toOptionArray();
24
- $found = false;
25
- foreach ($countries as $c) {
26
- if ($c['value'] == $value) {
27
- $found = true;
28
- }
29
- }
30
- if (!$found) {
31
- Mage::throwException(Mage::helper('temando')->__('Please select a country from the list.', $value));
32
- }
33
- }
34
-
35
- return $this;
36
- }
37
-
38
- }
1
+ <?php
2
+ /**
3
+ * System Config Backend Form Field Required Country
4
+ *
5
+ * @package Temando_Temando
6
+ * @author Temando Magento Team <marketing@temando.com>
7
+ */
8
+ class Temando_Temando_Model_System_Config_Backend_Form_Field_Required_Country
9
+ extends Mage_Core_Model_Config_Data
10
+ {
11
+
12
+ protected function _beforeSave()
13
+ {
14
+ $value = $this->getValue();
15
+ $collection = Mage::getModel('directory/country')->getCollection();
16
+ if (is_callable($collection, "getAllIds")) {
17
+ $countries = $collection->getAllIds();
18
+
19
+ if (!in_array($value, $countries)) {
20
+ Mage::throwException(Mage::helper('temando')->__('Please select a country from the list.', $value));
21
+ }
22
+ } else {
23
+ $countries = $collection->toOptionArray();
24
+ $found = false;
25
+ foreach ($countries as $c) {
26
+ if ($c['value'] == $value) {
27
+ $found = true;
28
+ }
29
+ }
30
+ if (!$found) {
31
+ Mage::throwException(Mage::helper('temando')->__('Please select a country from the list.', $value));
32
+ }
33
+ }
34
+
35
+ return $this;
36
+ }
37
+
38
+ }
app/code/community/Temando/Temando/Model/System/Config/Backend/Form/Field/Required/Location.php CHANGED
@@ -1,48 +1,51 @@
1
- <?php
2
- /**
3
- * System Config Backend Form Field Required Location
4
- *
5
- * @package Temando_Temando
6
- * @author Temando Magento Team <marketing@temando.com>
7
- */
8
- class Temando_Temando_Model_System_Config_Backend_Form_Field_Required_Location
9
- extends Temando_Temando_Model_System_Config_Backend_Form_Field_Required_Text
10
- {
11
-
12
- /**
13
- * Processing object after save data
14
- *
15
- * @return Mage_Core_Model_Abstract
16
- */
17
- protected function _afterSave()
18
- {
19
- try {
20
- $api = Mage::getModel('temando/api_client');
21
- $api->connect(
22
- Mage::helper('temando')->getConfigData('general/username'),
23
- Mage::helper('temando')->getConfigData('general/password'),
24
- Mage::helper('temando')->getConfigData('general/sandbox')
25
- );
26
-
27
- //try to update 'Magento Warehouse'
28
- $magentoWarehouse = Mage::helper('temando')->getOriginRequestArray(new Varien_Object($this->getFieldsetData()));
29
- try {
30
- $api->updateLocation(array('location' => $magentoWarehouse));
31
- } catch (Exception $e) {
32
- try {
33
- //if error updating location, location probably does not exist - try to create
34
- Mage::log($e->getMessage());
35
- $api->createLocation(array('location' => $magentoWarehouse));
36
- } catch (Exception $e) {
37
- Mage::getSingleton('adminhtml/session')->addError(Mage::helper('temando')->__('An error occured when synchronizing origin location data with temando.com. Please resave your configuration.'));
38
- Mage::log($e->getMessage());
39
- }
40
- }
41
- } catch (Exception $e) {
42
- Mage::log($e->getMessage());
43
- }
44
-
45
- return parent::_afterSave();
46
- }
47
-
48
- }
 
 
 
1
+ <?php
2
+ /**
3
+ * System Config Backend Form Field Required Location
4
+ *
5
+ * @package Temando_Temando
6
+ * @author Temando Magento Team <marketing@temando.com>
7
+ */
8
+ class Temando_Temando_Model_System_Config_Backend_Form_Field_Required_Location
9
+ extends Temando_Temando_Model_System_Config_Backend_Form_Field_Required_Text
10
+ {
11
+
12
+ /**
13
+ * Processing object after save data
14
+ *
15
+ * @return Mage_Core_Model_Abstract
16
+ */
17
+ protected function _afterSave()
18
+ {
19
+ try {
20
+ $api = Mage::getModel('temando/api_client');
21
+ $api->connect(
22
+ Mage::helper('temando')->getConfigData('general/username'),
23
+ Mage::helper('temando')->getConfigData('general/password'),
24
+ Mage::helper('temando')->getConfigData('general/sandbox')
25
+ );
26
+
27
+ //try to update 'Magento Warehouse'
28
+ $magentoWarehouse = Mage::helper('temando')
29
+ ->getOriginRequestArray(new Varien_Object($this->getFieldsetData()));
30
+
31
+ try {
32
+ $api->updateLocation(array('location' => $magentoWarehouse));
33
+ } catch (Exception $e) {
34
+ try {
35
+ //if error updating location, location probably does not exist - try to create
36
+ Mage::log($e->getMessage());
37
+ $api->createLocation(array('location' => $magentoWarehouse));
38
+ } catch (Exception $e) {
39
+ Mage::getSingleton('adminhtml/session')->addError(
40
+ Mage::helper('temando')->__('An error occured when synchronizing
41
+ origin location data with temando.com. Please resave your configuration.')
42
+ );
43
+ Mage::log($e->getMessage());
44
+ }
45
+ }
46
+ } catch (Exception $e) {
47
+ Mage::log($e->getMessage());
48
+ }
49
+ return parent::_afterSave();
50
+ }
51
+ }
app/code/community/Temando/Temando/Model/System/Config/Backend/Form/Field/Required/Text.php CHANGED
@@ -1,23 +1,23 @@
1
- <?php
2
- /**
3
- * System Config Backend Form Field Required Text
4
- *
5
- * @package Temando_Temando
6
- * @author Temando Magento Team <marketing@temando.com>
7
- */
8
- class Temando_Temando_Model_System_Config_Backend_Form_Field_Required_Text
9
- extends Mage_Core_Model_Config_Data
10
- {
11
-
12
- protected function _beforeSave()
13
- {
14
- $value = $this->getValue();
15
- $config = $this->getFieldConfig();
16
-
17
- if (!Zend_Validate::is($value, 'NotEmpty')) {
18
- Mage::throwException(Mage::helper('temando')->__('"' . $config->label . '" is a required field.', $value));
19
- }
20
- return $this;
21
- }
22
-
23
- }
1
+ <?php
2
+ /**
3
+ * System Config Backend Form Field Required Text
4
+ *
5
+ * @package Temando_Temando
6
+ * @author Temando Magento Team <marketing@temando.com>
7
+ */
8
+ class Temando_Temando_Model_System_Config_Backend_Form_Field_Required_Text
9
+ extends Mage_Core_Model_Config_Data
10
+ {
11
+
12
+ protected function _beforeSave()
13
+ {
14
+ $value = $this->getValue();
15
+ $config = $this->getFieldConfig();
16
+
17
+ if (!Zend_Validate::is($value, 'NotEmpty')) {
18
+ Mage::throwException(Mage::helper('temando')->__('"' . $config->label . '" is a required field.', $value));
19
+ }
20
+ return $this;
21
+ }
22
+
23
+ }
app/code/community/Temando/Temando/Model/System/Config/Source.php CHANGED
@@ -1,87 +1,87 @@
1
- <?php
2
- /**
3
- * System Config Source
4
- *
5
- * @package Temando_Temando
6
- * @author Temando Magento Team <marketing@temando.com>
7
- */
8
- abstract class Temando_Temando_Model_System_Config_Source
9
- {
10
-
11
- /**
12
- * The array of options in the configuration item.
13
- *
14
- * This array's keys are the values used in the database etc. and the
15
- * values of this array are used as labels on the frontend.
16
- *
17
- * @var array
18
- */
19
- protected $_options;
20
-
21
- public function __construct()
22
- {
23
- $this->_setupOptions();
24
- }
25
-
26
- /**
27
- * Sets up the $_options array with the correct values.
28
- *
29
- * This function is called in the constructor.
30
- *
31
- * @return Temando_Temando_Model_System_Config_Source_Abstract
32
- */
33
- protected abstract function _setupOptions();
34
-
35
- /**
36
- * Gets all the options in the key => value type array.
37
- *
38
- * @return array
39
- */
40
- public function getOptions($please_select = false)
41
- {
42
- $options = $this->_options;
43
- if ($please_select) {
44
- $options = array(null => Mage::helper('temando')->__('--Please Select--')) + $options;
45
- }
46
- return $options;
47
- }
48
-
49
- /**
50
- * Converts the options into a format suitable for use in the admin area.
51
- *
52
- * @return array
53
- */
54
- public function toOptionArray()
55
- {
56
- return $this->_toOptionArray($this->_options);
57
- }
58
-
59
- protected function _toOptionArray($input)
60
- {
61
- $array = array();
62
-
63
- foreach ($input as $key => $value) {
64
- $array[] = array(
65
- 'value' => $key,
66
- 'label' => $value,
67
- );
68
- }
69
-
70
- return $array;
71
- }
72
-
73
- /**
74
- * Looks up an option by key and gets the label.
75
- *
76
- * @param mixed $value
77
- * @return mixed
78
- */
79
- public function getOptionLabel($value)
80
- {
81
- if (array_key_exists($value, $this->_options)) {
82
- return $this->_options[$value];
83
- }
84
- return null;
85
- }
86
-
87
- }
1
+ <?php
2
+ /**
3
+ * System Config Source
4
+ *
5
+ * @package Temando_Temando
6
+ * @author Temando Magento Team <marketing@temando.com>
7
+ */
8
+ abstract class Temando_Temando_Model_System_Config_Source
9
+ {
10
+
11
+ /**
12
+ * The array of options in the configuration item.
13
+ *
14
+ * This array's keys are the values used in the database etc. and the
15
+ * values of this array are used as labels on the frontend.
16
+ *
17
+ * @var array
18
+ */
19
+ protected $_options;
20
+
21
+ public function __construct()
22
+ {
23
+ $this->_setupOptions();
24
+ }
25
+
26
+ /**
27
+ * Sets up the $_options array with the correct values.
28
+ *
29
+ * This function is called in the constructor.
30
+ *
31
+ * @return Temando_Temando_Model_System_Config_Source_Abstract
32
+ */
33
+ protected abstract function _setupOptions();
34
+
35
+ /**
36
+ * Gets all the options in the key => value type array.
37
+ *
38
+ * @return array
39
+ */
40
+ public function getOptions($please_select = false)
41
+ {
42
+ $options = $this->_options;
43
+ if ($please_select) {
44
+ $options = array(null => Mage::helper('temando')->__('--Please Select--')) + $options;
45
+ }
46
+ return $options;
47
+ }
48
+
49
+ /**
50
+ * Converts the options into a format suitable for use in the admin area.
51
+ *
52
+ * @return array
53
+ */
54
+ public function toOptionArray()
55
+ {
56
+ return $this->_toOptionArray($this->_options);
57
+ }
58
+
59
+ protected function _toOptionArray($input)
60
+ {
61
+ $array = array();
62
+
63
+ foreach ($input as $key => $value) {
64
+ $array[] = array(
65
+ 'value' => $key,
66
+ 'label' => $value,
67
+ );
68
+ }
69
+
70
+ return $array;
71
+ }
72
+
73
+ /**
74
+ * Looks up an option by key and gets the label.
75
+ *
76
+ * @param mixed $value
77
+ * @return mixed
78
+ */
79
+ public function getOptionLabel($value)
80
+ {
81
+ if (array_key_exists($value, $this->_options)) {
82
+ return $this->_options[$value];
83
+ }
84
+ return null;
85
+ }
86
+
87
+ }
app/code/community/Temando/Temando/Model/System/Config/Source/Carbon.php CHANGED
@@ -1,25 +1,25 @@
1
- <?php
2
- /**
3
- * System Config Source Carbon
4
- *
5
- * @package Temando_Temando
6
- * @author Temando Magento Team <marketing@temando.com>
7
- */
8
- class Temando_Temando_Model_System_Config_Source_Carbon
9
- extends Temando_Temando_Model_System_Config_Source
10
- {
11
-
12
- const DISABLED = 'disabled';
13
- const OPTIONAL = 'optional';
14
- const MANDATORY = 'mandatory';
15
-
16
- protected function _setupOptions()
17
- {
18
- $this->_options = array(
19
- self::DISABLED => Mage::helper('temando')->__('Disabled'),
20
- self::OPTIONAL => Mage::helper('temando')->__('Optional'),
21
- self::MANDATORY => Mage::helper('temando')->__('Mandatory'),
22
- );
23
- }
24
-
25
- }
1
+ <?php
2
+ /**
3
+ * System Config Source Carbon
4
+ *
5
+ * @package Temando_Temando
6
+ * @author Temando Magento Team <marketing@temando.com>
7
+ */
8
+ class Temando_Temando_Model_System_Config_Source_Carbon
9
+ extends Temando_Temando_Model_System_Config_Source
10
+ {
11
+
12
+ const DISABLED = 'disabled';
13
+ const OPTIONAL = 'optional';
14
+ const MANDATORY = 'mandatory';
15
+
16
+ protected function _setupOptions()
17
+ {
18
+ $this->_options = array(
19
+ self::DISABLED => Mage::helper('temando')->__('Disabled'),
20
+ self::OPTIONAL => Mage::helper('temando')->__('Optional'),
21
+ self::MANDATORY => Mage::helper('temando')->__('Mandatory'),
22
+ );
23
+ }
24
+
25
+ }
app/code/community/Temando/Temando/Model/System/Config/Source/Client/Type.php CHANGED
@@ -1,22 +1,22 @@
1
- <?php
2
- /**
3
- * System Config Source Client Type
4
- *
5
- * @package Temando_Temando
6
- * @author Temando Magento Team <marketing@temando.com>
7
- */
8
- class Temando_Temando_Model_System_Config_Source_Client_Type extends Temando_Temando_Model_System_Config_Source
9
- {
10
-
11
- const INDIVIDUAL = 'Individual';
12
- const COMPANY = 'Company';
13
-
14
- protected function _setupOptions()
15
- {
16
- $this->_options = array(
17
- self::INDIVIDUAL => Mage::helper('temando')->__('Individual'),
18
- self::COMPANY => Mage::helper('temando')->__('Company'),
19
- );
20
- }
21
-
22
- }
1
+ <?php
2
+ /**
3
+ * System Config Source Client Type
4
+ *
5
+ * @package Temando_Temando
6
+ * @author Temando Magento Team <marketing@temando.com>
7
+ */
8
+ class Temando_Temando_Model_System_Config_Source_Client_Type extends Temando_Temando_Model_System_Config_Source
9
+ {
10
+
11
+ const INDIVIDUAL = 'Individual';
12
+ const COMPANY = 'Company';
13
+
14
+ protected function _setupOptions()
15
+ {
16
+ $this->_options = array(
17
+ self::INDIVIDUAL => Mage::helper('temando')->__('Individual'),
18
+ self::COMPANY => Mage::helper('temando')->__('Company'),
19
+ );
20
+ }
21
+
22
+ }
app/code/community/Temando/Temando/Model/System/Config/Source/Country.php CHANGED
@@ -1,26 +1,23 @@
1
- <?php
2
- /**
3
- * System Config Source Country
4
- *
5
- * @package Temando_Temando
6
- * @author Temando Magento Team <marketing@temando.com>
7
- */
8
- class Temando_Temando_Model_System_Config_Source_Country
9
- extends Temando_Temando_Model_System_Config_Source
10
- {
11
-
12
- protected $_options;
13
-
14
- public function _setupOptions()
15
- {
16
-
17
- if (!$this->_options) {
18
- $countries = Mage::getResourceModel('directory/country_collection')->loadData()->toOptionArray(false);
19
-
20
- foreach($countries as $country => $arr) {
21
- $this->_options[$arr['value']] = $arr['label'];
22
- }
23
- }
24
- }
25
-
26
- }
1
+ <?php
2
+ /**
3
+ * System Config Source Country
4
+ *
5
+ * @package Temando_Temando
6
+ * @author Temando Magento Team <marketing@temando.com>
7
+ */
8
+ class Temando_Temando_Model_System_Config_Source_Country
9
+ extends Temando_Temando_Model_System_Config_Source
10
+ {
11
+
12
+ protected $_options;
13
+
14
+ public function _setupOptions()
15
+ {
16
+ if (!$this->_options) {
17
+ $countries = Mage::getResourceModel('directory/country_collection')->loadData()->toOptionArray(false);
18
+ foreach ($countries as $country => $arr) {
19
+ $this->_options[$arr['value']] = $arr['label'];
20
+ }
21
+ }
22
+ }
23
+ }
 
 
 
app/code/community/Temando/Temando/Model/System/Config/Source/Errorprocess.php CHANGED
@@ -1,23 +1,23 @@
1
- <?php
2
- /**
3
- * System Config Source Errorprocess
4
- *
5
- * @package Temando_Temando
6
- * @author Temando Magento Team <marketing@temando.com>
7
- */
8
- class Temando_Temando_Model_System_Config_Source_Errorprocess
9
- extends Temando_Temando_Model_System_Config_Source
10
- {
11
-
12
- const VIEW = 'view';
13
- const FLAT = 'flat';
14
-
15
- protected function _setupOptions()
16
- {
17
- $this->_options = array(
18
- self::FLAT => Mage::helper('temando')->__('Show flat rate'),
19
- self::VIEW => Mage::helper('temando')->__('Show error message'),
20
- );
21
- }
22
-
23
- }
1
+ <?php
2
+ /**
3
+ * System Config Source Errorprocess
4
+ *
5
+ * @package Temando_Temando
6
+ * @author Temando Magento Team <marketing@temando.com>
7
+ */
8
+ class Temando_Temando_Model_System_Config_Source_Errorprocess
9
+ extends Temando_Temando_Model_System_Config_Source
10
+ {
11
+
12
+ const VIEW = 'view';
13
+ const FLAT = 'flat';
14
+
15
+ protected function _setupOptions()
16
+ {
17
+ $this->_options = array(
18
+ self::FLAT => Mage::helper('temando')->__('Show flat rate'),
19
+ self::VIEW => Mage::helper('temando')->__('Show error message'),
20
+ );
21
+ }
22
+
23
+ }
app/code/community/Temando/Temando/Model/System/Config/Source/Footprints.php CHANGED
@@ -1,25 +1,25 @@
1
- <?php
2
- /**
3
- * System Config Source Footprints
4
- *
5
- * @package Temando_Temando
6
- * @author Temando Magento Team <marketing@temando.com>
7
- */
8
- class Temando_Temando_Model_System_Config_Source_Footprints
9
- extends Temando_Temando_Model_System_Config_Source
10
- {
11
-
12
- const DISABLED = 'disabled';
13
- const OPTIONAL = 'optional';
14
- const MANDATORY = 'mandatory';
15
-
16
- protected function _setupOptions()
17
- {
18
- $this->_options = array(
19
- self::DISABLED => Mage::helper('temando')->__('Disabled'),
20
- self::OPTIONAL => Mage::helper('temando')->__('Optional'),
21
- self::MANDATORY => Mage::helper('temando')->__('Mandatory'),
22
- );
23
- }
24
-
25
- }
1
+ <?php
2
+ /**
3
+ * System Config Source Footprints
4
+ *
5
+ * @package Temando_Temando
6
+ * @author Temando Magento Team <marketing@temando.com>
7
+ */
8
+ class Temando_Temando_Model_System_Config_Source_Footprints
9
+ extends Temando_Temando_Model_System_Config_Source
10
+ {
11
+
12
+ const DISABLED = 'disabled';
13
+ const OPTIONAL = 'optional';
14
+ const MANDATORY = 'mandatory';
15
+
16
+ protected function _setupOptions()
17
+ {
18
+ $this->_options = array(
19
+ self::DISABLED => Mage::helper('temando')->__('Disabled'),
20
+ self::OPTIONAL => Mage::helper('temando')->__('Optional'),
21
+ self::MANDATORY => Mage::helper('temando')->__('Mandatory'),
22
+ );
23
+ }
24
+
25
+ }
app/code/community/Temando/Temando/Model/System/Config/Source/Insurance.php CHANGED
@@ -1,25 +1,25 @@
1
- <?php
2
- /**
3
- * System Config Source Insurance
4
- *
5
- * @package Temando_Temando
6
- * @author Temando Magento Team <marketing@temando.com>
7
- */
8
- class Temando_Temando_Model_System_Config_Source_Insurance
9
- extends Temando_Temando_Model_System_Config_Source
10
- {
11
-
12
- const DISABLED = 'disabled';
13
- const OPTIONAL = 'optional';
14
- const MANDATORY = 'mandatory';
15
-
16
- protected function _setupOptions()
17
- {
18
- $this->_options = array(
19
- self::DISABLED => Mage::helper('temando')->__('Disabled'),
20
- self::OPTIONAL => Mage::helper('temando')->__('Optional'),
21
- self::MANDATORY => Mage::helper('temando')->__('Mandatory'),
22
- );
23
- }
24
-
25
- }
1
+ <?php
2
+ /**
3
+ * System Config Source Insurance
4
+ *
5
+ * @package Temando_Temando
6
+ * @author Temando Magento Team <marketing@temando.com>
7
+ */
8
+ class Temando_Temando_Model_System_Config_Source_Insurance
9
+ extends Temando_Temando_Model_System_Config_Source
10
+ {
11
+
12
+ const DISABLED = 'disabled';
13
+ const OPTIONAL = 'optional';
14
+ const MANDATORY = 'mandatory';
15
+
16
+ protected function _setupOptions()
17
+ {
18
+ $this->_options = array(
19
+ self::DISABLED => Mage::helper('temando')->__('Disabled'),
20
+ self::OPTIONAL => Mage::helper('temando')->__('Optional'),
21
+ self::MANDATORY => Mage::helper('temando')->__('Mandatory'),
22
+ );
23
+ }
24
+
25
+ }
app/code/community/Temando/Temando/Model/System/Config/Source/Labeltype.php CHANGED
@@ -1,23 +1,23 @@
1
- <?php
2
- /**
3
- * System Config Source Labeltype
4
- *
5
- * @package Temando_Temando
6
- * @author Temando Magento Team <marketing@temando.com>
7
- */
8
- class Temando_Temando_Model_System_Config_Source_Labeltype
9
- extends Temando_Temando_Model_System_Config_Source
10
- {
11
-
12
- const STANDARD = 'Standard';
13
- const THERMAL = 'Thermal';
14
-
15
- protected function _setupOptions()
16
- {
17
- $this->_options = array(
18
- self::STANDARD => Mage::helper('temando')->__('Plain Paper'),
19
- self::THERMAL => Mage::helper('temando')->__('Thermal'),
20
- );
21
- }
22
-
23
- }
1
+ <?php
2
+ /**
3
+ * System Config Source Labeltype
4
+ *
5
+ * @package Temando_Temando
6
+ * @author Temando Magento Team <marketing@temando.com>
7
+ */
8
+ class Temando_Temando_Model_System_Config_Source_Labeltype
9
+ extends Temando_Temando_Model_System_Config_Source
10
+ {
11
+
12
+ const STANDARD = 'Standard';
13
+ const THERMAL = 'Thermal';
14
+
15
+ protected function _setupOptions()
16
+ {
17
+ $this->_options = array(
18
+ self::STANDARD => Mage::helper('temando')->__('Plain Paper'),
19
+ self::THERMAL => Mage::helper('temando')->__('Thermal'),
20
+ );
21
+ }
22
+
23
+ }
app/code/community/Temando/Temando/Model/System/Config/Source/Origin/Type.php CHANGED
@@ -1,22 +1,22 @@
1
- <?php
2
- /**
3
- * System Config Source Origin Type
4
- *
5
- * @package Temando_Temando
6
- * @author Temando Magento Team <marketing@temando.com>
7
- */
8
- class Temando_Temando_Model_System_Config_Source_Origin_Type extends Temando_Temando_Model_System_Config_Source
9
- {
10
-
11
- const BUSINESS = 'Business';
12
- const RESIDENTIAL = 'Residence';
13
-
14
- public function _setupOptions()
15
- {
16
- $this->_options = array(
17
- self::BUSINESS => Mage::helper('temando')->__('Business'),
18
- self::RESIDENTIAL => Mage::helper('temando')->__('Residential'),
19
- );
20
- }
21
-
22
- }
1
+ <?php
2
+ /**
3
+ * System Config Source Origin Type
4
+ *
5
+ * @package Temando_Temando
6
+ * @author Temando Magento Team <marketing@temando.com>
7
+ */
8
+ class Temando_Temando_Model_System_Config_Source_Origin_Type extends Temando_Temando_Model_System_Config_Source
9
+ {
10
+
11
+ const BUSINESS = 'Business';
12
+ const RESIDENTIAL = 'Residence';
13
+
14
+ public function _setupOptions()
15
+ {
16
+ $this->_options = array(
17
+ self::BUSINESS => Mage::helper('temando')->__('Business'),
18
+ self::RESIDENTIAL => Mage::helper('temando')->__('Residential'),
19
+ );
20
+ }
21
+
22
+ }
app/code/community/Temando/Temando/Model/System/Config/Source/Payment.php CHANGED
@@ -1,22 +1,22 @@
1
- <?php
2
- /**
3
- * System Config Source Payment
4
- *
5
- * @package Temando_Temando
6
- * @author Temando Magento Team <marketing@temando.com>
7
- */
8
- class Temando_Temando_Model_System_Config_Source_Payment extends Temando_Temando_Model_System_Config_Source
9
- {
10
-
11
- const CREDIT = 'Credit';
12
- const ACCOUNT = 'Account';
13
-
14
- protected function _setupOptions()
15
- {
16
- $this->_options = array(
17
- self::CREDIT => Mage::helper('temando')->__('Credit'),
18
- self::ACCOUNT => Mage::helper('temando')->__('Account')
19
- );
20
- }
21
-
22
- }
1
+ <?php
2
+ /**
3
+ * System Config Source Payment
4
+ *
5
+ * @package Temando_Temando
6
+ * @author Temando Magento Team <marketing@temando.com>
7
+ */
8
+ class Temando_Temando_Model_System_Config_Source_Payment extends Temando_Temando_Model_System_Config_Source
9
+ {
10
+
11
+ const CREDIT = 'Credit';
12
+ const ACCOUNT = 'Account';
13
+
14
+ protected function _setupOptions()
15
+ {
16
+ $this->_options = array(
17
+ self::CREDIT => Mage::helper('temando')->__('Credit'),
18
+ self::ACCOUNT => Mage::helper('temando')->__('Account')
19
+ );
20
+ }
21
+
22
+ }
app/code/community/Temando/Temando/Model/System/Config/Source/Pricing.php CHANGED
@@ -1,31 +1,32 @@
1
- <?php
2
- /**
3
- * System Config Source Pricing
4
- *
5
- * @package Temando_Temando
6
- * @author Temando Magento Team <marketing@temando.com>
7
- */
8
- class Temando_Temando_Model_System_Config_Source_Pricing
9
- extends Temando_Temando_Model_System_Config_Source
10
- {
11
-
12
- const FREE = 'free';
13
- const FLAT_RATE = 'flat';
14
- const DYNAMIC = 'dynamic';
15
- const DYNAMIC_FASTEST = 'dynamicfast';
16
- const DYNAMIC_CHEAPEST = 'dynamiccheap';
17
- const DYNAMIC_FASTEST_AND_CHEAPEST = 'dynamicfastcheap';
18
-
19
- protected function _setupOptions()
20
- {
21
- $this->_options = array(
22
- self::FREE => Mage::helper('temando')->__('Free Shipping'),
23
- self::FLAT_RATE => Mage::helper('temando')->__('Fixed Price / Flat Rate'),
24
- self::DYNAMIC => Mage::helper('temando')->__('Dynamic Pricing (All)'),
25
- self::DYNAMIC_CHEAPEST => Mage::helper('temando')->__('Dynamic Pricing (Cheapest only)'),
26
- self::DYNAMIC_FASTEST => Mage::helper('temando')->__('Dynamic Pricing (Fastest only)'),
27
- self::DYNAMIC_FASTEST_AND_CHEAPEST => Mage::helper('temando')->__('Dynamic Pricing (Cheapest and Fastest only)'),
28
- );
29
- }
30
-
31
- }
 
1
+ <?php
2
+ /**
3
+ * System Config Source Pricing
4
+ *
5
+ * @package Temando_Temando
6
+ * @author Temando Magento Team <marketing@temando.com>
7
+ */
8
+ class Temando_Temando_Model_System_Config_Source_Pricing
9
+ extends Temando_Temando_Model_System_Config_Source
10
+ {
11
+
12
+ const FREE = 'free';
13
+ const FLAT_RATE = 'flat';
14
+ const DYNAMIC = 'dynamic';
15
+ const DYNAMIC_FASTEST = 'dynamicfast';
16
+ const DYNAMIC_CHEAPEST = 'dynamiccheap';
17
+ const DYNAMIC_FASTEST_AND_CHEAPEST = 'dynamicfastcheap';
18
+
19
+ protected function _setupOptions()
20
+ {
21
+ $this->_options = array(
22
+ self::FREE => Mage::helper('temando')->__('Free Shipping'),
23
+ self::FLAT_RATE => Mage::helper('temando')->__('Fixed Price / Flat Rate'),
24
+ self::DYNAMIC => Mage::helper('temando')->__('Dynamic Pricing (All)'),
25
+ self::DYNAMIC_CHEAPEST => Mage::helper('temando')->__('Dynamic Pricing (Cheapest only)'),
26
+ self::DYNAMIC_FASTEST => Mage::helper('temando')->__('Dynamic Pricing (Fastest only)'),
27
+ self::DYNAMIC_FASTEST_AND_CHEAPEST => Mage::helper('temando')
28
+ ->__('Dynamic Pricing (Cheapest and Fastest only)'),
29
+ );
30
+ }
31
+
32
+ }
app/code/community/Temando/Temando/Model/System/Config/Source/Readytime.php CHANGED
@@ -1,23 +1,23 @@
1
- <?php
2
- /**
3
- * System Config Source Readytime
4
- *
5
- * @package Temando_Temando
6
- * @author Temando Magento Team <marketing@temando.com>
7
- */
8
- class Temando_Temando_Model_System_Config_Source_Readytime
9
- extends Temando_Temando_Model_System_Config_Source
10
- {
11
-
12
- const AM = 'AM';
13
- const PM = 'PM';
14
-
15
- protected function _setupOptions()
16
- {
17
- $this->_options = array(
18
- self::AM => Mage::helper('temando')->__('AM'),
19
- self::PM => Mage::helper('temando')->__('PM'),
20
- );
21
- }
22
-
23
- }
1
+ <?php
2
+ /**
3
+ * System Config Source Readytime
4
+ *
5
+ * @package Temando_Temando
6
+ * @author Temando Magento Team <marketing@temando.com>
7
+ */
8
+ class Temando_Temando_Model_System_Config_Source_Readytime
9
+ extends Temando_Temando_Model_System_Config_Source
10
+ {
11
+
12
+ const AM = 'AM';
13
+ const PM = 'PM';
14
+
15
+ protected function _setupOptions()
16
+ {
17
+ $this->_options = array(
18
+ self::AM => Mage::helper('temando')->__('AM'),
19
+ self::PM => Mage::helper('temando')->__('PM'),
20
+ );
21
+ }
22
+
23
+ }
app/code/community/Temando/Temando/Model/System/Config/Source/Regions.php CHANGED
@@ -1,29 +1,29 @@
1
- <?php
2
- /**
3
- * System Config Source Regions
4
- *
5
- * @package Temando_Temando
6
- * @author Temando Magento Team <marketing@temando.com>
7
- */
8
- class Temando_Temando_Model_System_Config_Source_Regions
9
- extends Temando_Temando_Model_System_Config_Source
10
- {
11
-
12
- protected function _setupOptions()
13
- {
14
- $this->_options = array();
15
-
16
- $regions = Mage::getModel('directory/region')->getCollection();
17
- /* @var $regions Mage_Directory_Model_Mysql4_Region_Collection */
18
- // $option_array = $regions
19
- // ->addCountryFilter('AU');
20
-
21
- $this->_options = array();
22
-
23
- foreach ($regions as $region) {
24
- /* @var $region Mage_Directory_Model_Region */
25
- $this->_options[strtoupper($region->getCode())] = $region->getName();
26
- }
27
- }
28
-
29
- }
1
+ <?php
2
+ /**
3
+ * System Config Source Regions
4
+ *
5
+ * @package Temando_Temando
6
+ * @author Temando Magento Team <marketing@temando.com>
7
+ */
8
+ class Temando_Temando_Model_System_Config_Source_Regions
9
+ extends Temando_Temando_Model_System_Config_Source
10
+ {
11
+
12
+ protected function _setupOptions()
13
+ {
14
+ $this->_options = array();
15
+
16
+ $regions = Mage::getModel('directory/region')->getCollection();
17
+ /* @var $regions Mage_Directory_Model_Mysql4_Region_Collection */
18
+ // $option_array = $regions
19
+ // ->addCountryFilter('AU');
20
+
21
+ $this->_options = array();
22
+
23
+ foreach ($regions as $region) {
24
+ /* @var $region Mage_Directory_Model_Region */
25
+ $this->_options[strtoupper($region->getCode())] = $region->getName();
26
+ }
27
+ }
28
+
29
+ }
app/code/community/Temando/Temando/Model/System/Config/Source/Rule/Action/Adjustment/Type.php CHANGED
@@ -1,32 +1,31 @@
1
- <?php
2
- /**
3
- * System Config Source Rule Action Adjustment Type
4
- *
5
- * @package Temando_Temando
6
- * @author Temando Magento Team <marketing@temando.com>
7
- */
8
- class Temando_Temando_Model_System_Config_Source_Rule_Action_Adjustment_Type
9
- extends Temando_Temando_Model_System_Config_Source {
10
-
11
- const DO_NOT_USE = null;
12
- const MARKUP_FIXED = '1';
13
- const MARKUP_PERCENT = '2';
14
- const SUBSIDY_FIXED = '3';
15
- const SUBSIDY_PERCENT = '4';
16
- const MINMAX = '5';
17
- const CAPPED = '6';
18
-
19
-
20
- protected function _setupOptions() {
21
- $this->_options = array(
22
- self::DO_NOT_USE => Mage::helper('temando')->__(' -- '),
23
- self::MARKUP_FIXED => Mage::helper('temando')->__('Markup (fixed)'),
24
- self::MARKUP_PERCENT => Mage::helper('temando')->__('Markup (percentage)'),
25
- self::SUBSIDY_FIXED => Mage::helper('temando')->__('Subsidy (fixed)'),
26
- self::SUBSIDY_PERCENT => Mage::helper('temando')->__('Subsidy (percentage)'),
27
- self::MINMAX => Mage::helper('temando')->__('Min/Max Range'),
28
- self::CAPPED => Mage::helper('temando')->__('Override')
29
- );
30
- }
31
-
32
- }
1
+ <?php
2
+ /**
3
+ * System Config Source Rule Action Adjustment Type
4
+ *
5
+ * @package Temando_Temando
6
+ * @author Temando Magento Team <marketing@temando.com>
7
+ */
8
+ class Temando_Temando_Model_System_Config_Source_Rule_Action_Adjustment_Type
9
+ extends Temando_Temando_Model_System_Config_Source {
10
+
11
+ const DO_NOT_USE = null;
12
+ const MARKUP_FIXED = '1';
13
+ const MARKUP_PERCENT = '2';
14
+ const SUBSIDY_FIXED = '3';
15
+ const SUBSIDY_PERCENT = '4';
16
+ const MINMAX = '5';
17
+ const CAPPED = '6';
18
+
19
+ protected function _setupOptions()
20
+ {
21
+ $this->_options = array(
22
+ self::DO_NOT_USE => Mage::helper('temando')->__(' -- '),
23
+ self::MARKUP_FIXED => Mage::helper('temando')->__('Markup (fixed)'),
24
+ self::MARKUP_PERCENT => Mage::helper('temando')->__('Markup (percentage)'),
25
+ self::SUBSIDY_FIXED => Mage::helper('temando')->__('Subsidy (fixed)'),
26
+ self::SUBSIDY_PERCENT => Mage::helper('temando')->__('Subsidy (percentage)'),
27
+ self::MINMAX => Mage::helper('temando')->__('Min/Max Range'),
28
+ self::CAPPED => Mage::helper('temando')->__('Override')
29
+ );
30
+ }
31
+ }
 
app/code/community/Temando/Temando/Model/System/Config/Source/Rule/Action/Filter.php CHANGED
@@ -1,26 +1,25 @@
1
- <?php
2
- /**
3
- * System Config Source Rule Action Filter
4
- *
5
- * @package Temando_Temando
6
- * @author Temando Magento Team <marketing@temando.com>
7
- */
8
- class Temando_Temando_Model_System_Config_Source_Rule_Action_Filter
9
- extends Temando_Temando_Model_System_Config_Source {
10
-
11
- const DYNAMIC_ALL = 1;
12
- const DYNAMIC_FASTEST = 2;
13
- const DYNAMIC_CHEAPEST = 3;
14
- const DYNAMIC_FASTEST_AND_CHEAPEST = 4;
15
-
16
- protected function _setupOptions()
17
- {
18
- $this->_options = array(
19
- self::DYNAMIC_ALL => Mage::helper('temando')->__('All Quotes'),
20
- self::DYNAMIC_CHEAPEST => Mage::helper('temando')->__('Cheapest only'),
21
- self::DYNAMIC_FASTEST => Mage::helper('temando')->__('Fastest only'),
22
- self::DYNAMIC_FASTEST_AND_CHEAPEST => Mage::helper('temando')->__('Cheapest and Fastest only'),
23
- );
24
- }
25
-
26
- }
1
+ <?php
2
+ /**
3
+ * System Config Source Rule Action Filter
4
+ *
5
+ * @package Temando_Temando
6
+ * @author Temando Magento Team <marketing@temando.com>
7
+ */
8
+ class Temando_Temando_Model_System_Config_Source_Rule_Action_Filter
9
+ extends Temando_Temando_Model_System_Config_Source {
10
+
11
+ const DYNAMIC_ALL = 1;
12
+ const DYNAMIC_FASTEST = 2;
13
+ const DYNAMIC_CHEAPEST = 3;
14
+ const DYNAMIC_FASTEST_AND_CHEAPEST = 4;
15
+
16
+ protected function _setupOptions()
17
+ {
18
+ $this->_options = array(
19
+ self::DYNAMIC_ALL => Mage::helper('temando')->__('All Quotes'),
20
+ self::DYNAMIC_CHEAPEST => Mage::helper('temando')->__('Cheapest only'),
21
+ self::DYNAMIC_FASTEST => Mage::helper('temando')->__('Fastest only'),
22
+ self::DYNAMIC_FASTEST_AND_CHEAPEST => Mage::helper('temando')->__('Cheapest and Fastest only'),
23
+ );
24
+ }
25
+ }
 
app/code/community/Temando/Temando/Model/System/Config/Source/Rule/Condition/Time.php CHANGED
@@ -1,23 +1,23 @@
1
- <?php
2
- /**
3
- * System Config Source Rule Condition Time
4
- *
5
- * @package Temando_Temando
6
- * @author Temando Magento Team <marketing@temando.com>
7
- */
8
- class Temando_Temando_Model_System_Config_Source_Rule_Condition_Time
9
- extends Temando_Temando_Model_System_Config_Source {
10
-
11
- const DO_NOT_USE = null;
12
- const BEFORE = '1';
13
- const AFTER = '2';
14
-
15
- protected function _setupOptions() {
16
- $this->_options = array(
17
- self::DO_NOT_USE => Mage::helper('temando')->__(' -- '),
18
- self::BEFORE => Mage::helper('temando')->__('before'),
19
- self::AFTER => Mage::helper('temando')->__('after')
20
- );
21
- }
22
-
23
- }
1
+ <?php
2
+ /**
3
+ * System Config Source Rule Condition Time
4
+ *
5
+ * @package Temando_Temando
6
+ * @author Temando Magento Team <marketing@temando.com>
7
+ */
8
+ class Temando_Temando_Model_System_Config_Source_Rule_Condition_Time
9
+ extends Temando_Temando_Model_System_Config_Source {
10
+
11
+ const DO_NOT_USE = null;
12
+ const BEFORE = '1';
13
+ const AFTER = '2';
14
+
15
+ protected function _setupOptions()
16
+ {
17
+ $this->_options = array(
18
+ self::DO_NOT_USE => Mage::helper('temando')->__(' -- '),
19
+ self::BEFORE => Mage::helper('temando')->__('before'),
20
+ self::AFTER => Mage::helper('temando')->__('after')
21
+ );
22
+ }
23
+ }
app/code/community/Temando/Temando/Model/System/Config/Source/Rule/Condition/Type.php CHANGED
@@ -1,24 +1,23 @@
1
- <?php
2
- /**
3
- * System Config Source Rule Condition Type
4
- *
5
- * @package Temando_Temando
6
- * @author Temando Magento Team <marketing@temando.com>
7
- */
8
- class Temando_Temando_Model_System_Config_Source_Rule_Condition_Type
9
- extends Temando_Temando_Model_System_Config_Source {
10
-
11
- const WEIGHT = '1';
12
- const SUBTOTAL = '2';
13
- const ZONE = '3';
14
-
15
- protected function _setupOptions()
16
- {
17
- $this->_options = array(
18
- self::WEIGHT => Mage::helper('temando')->__('Weight'),
19
- self::SUBTOTAL => Mage::helper('temando')->__('Subtotal'),
20
- self::ZONE => Mage::helper('temando')->__('Zone')
21
- );
22
- }
23
-
24
- }
1
+ <?php
2
+ /**
3
+ * System Config Source Rule Condition Type
4
+ *
5
+ * @package Temando_Temando
6
+ * @author Temando Magento Team <marketing@temando.com>
7
+ */
8
+ class Temando_Temando_Model_System_Config_Source_Rule_Condition_Type
9
+ extends Temando_Temando_Model_System_Config_Source {
10
+
11
+ const WEIGHT = '1';
12
+ const SUBTOTAL = '2';
13
+ const ZONE = '3';
14
+
15
+ protected function _setupOptions()
16
+ {
17
+ $this->_options = array(
18
+ self::WEIGHT => Mage::helper('temando')->__('Weight'),
19
+ self::SUBTOTAL => Mage::helper('temando')->__('Subtotal'),
20
+ self::ZONE => Mage::helper('temando')->__('Zone')
21
+ );
22
+ }
23
+ }
 
app/code/community/Temando/Temando/Model/System/Config/Source/Rule/Type.php CHANGED
@@ -1,26 +1,25 @@
1
- <?php
2
- /**
3
- * System Config Source Rule Type
4
- *
5
- * @package Temando_Temando
6
- * @author Temando Magento Team <marketing@temando.com>
7
- */
8
- class Temando_Temando_Model_System_Config_Source_Rule_Type
9
- extends Temando_Temando_Model_System_Config_Source {
10
-
11
- const FLATRATE = '1';
12
- const FREE = '2';
13
- const DYNAMIC = '3';
14
- const RESTRICT = '4';
15
-
16
- protected function _setupOptions()
17
- {
18
- $this->_options = array(
19
- self::FLATRATE => Mage::helper('temando')->__('Flat Rate'),
20
- self::FREE => Mage::helper('temando')->__('Free Shipping'),
21
- self::DYNAMIC => Mage::helper('temando')->__('Dynamic'),
22
- self::RESTRICT => Mage::helper('temando')->__('Restrict'),
23
- );
24
- }
25
-
26
- }
1
+ <?php
2
+ /**
3
+ * System Config Source Rule Type
4
+ *
5
+ * @package Temando_Temando
6
+ * @author Temando Magento Team <marketing@temando.com>
7
+ */
8
+ class Temando_Temando_Model_System_Config_Source_Rule_Type
9
+ extends Temando_Temando_Model_System_Config_Source {
10
+
11
+ const FLATRATE = '1';
12
+ const FREE = '2';
13
+ const DYNAMIC = '3';
14
+ const RESTRICT = '4';
15
+
16
+ protected function _setupOptions()
17
+ {
18
+ $this->_options = array(
19
+ self::FLATRATE => Mage::helper('temando')->__('Flat Rate'),
20
+ self::FREE => Mage::helper('temando')->__('Free Shipping'),
21
+ self::DYNAMIC => Mage::helper('temando')->__('Dynamic'),
22
+ self::RESTRICT => Mage::helper('temando')->__('Restrict'),
23
+ );
24
+ }
25
+ }
 
app/code/community/Temando/Temando/Model/System/Config/Source/Sales/Order/Status.php CHANGED
@@ -1,32 +1,35 @@
1
- <?php
2
- /**
3
- * System Config Source Sales Order Status
4
- *
5
- * @package Temando_Temando
6
- * @author Temando Magento Team <marketing@temando.com>
7
- */
8
- class Temando_Temando_Model_System_Config_Source_Sales_Order_Status
9
- {
10
-
11
-
12
- public function toOptionArray($isMultiselect=false)
13
- {
14
-
15
- $statuses = Mage::getSingleton('sales/order_config')->getStatuses();
16
-
17
- $options = array();
18
-
19
- foreach ($statuses as $code => $label) {
20
- $options[] = array(
21
- 'value' => $code,
22
- 'label' => $label
23
- );
24
- }
25
- if (!$isMultiselect){
26
- array_unshift($options, array('value'=>'', 'label'=> Mage::helper('adminhtml')->__('--Please Select--')));
27
- }
28
- return $options;
29
- }
30
-
31
- }
32
-
 
 
 
1
+ <?php
2
+ /**
3
+ * System Config Source Sales Order Status
4
+ *
5
+ * @package Temando_Temando
6
+ * @author Temando Magento Team <marketing@temando.com>
7
+ */
8
+ class Temando_Temando_Model_System_Config_Source_Sales_Order_Status
9
+ {
10
+
11
+ public function toOptionArray($isMultiselect = false)
12
+ {
13
+
14
+ $statuses = Mage::getSingleton('sales/order_config')->getStatuses();
15
+ $options = array();
16
+
17
+ foreach ($statuses as $code => $label) {
18
+ $options[] = array(
19
+ 'value' => $code,
20
+ 'label' => $label
21
+ );
22
+ }
23
+ if (!$isMultiselect) {
24
+ array_unshift(
25
+ $options,
26
+ array(
27
+ 'value'=>'',
28
+ 'label'=> Mage::helper('adminhtml')->__('--Please Select--')
29
+ )
30
+ );
31
+ }
32
+ return $options;
33
+ }
34
+
35
+ }
app/code/community/Temando/Temando/Model/System/Config/Source/Shipment/Class.php CHANGED
@@ -1,33 +1,33 @@
1
- <?php
2
- /**
3
- * System Config Source Shipment Class
4
- *
5
- * @package Temando_Temando
6
- * @author Temando Magento Team <marketing@temando.com>
7
- */
8
- class Temando_Temando_Model_System_Config_Source_Shipment_Class
9
- extends Temando_Temando_Model_System_Config_Source
10
- {
11
-
12
- const GENERAL_GOODS = 0;
13
- const FREIGHT = 1;
14
- const VEHICLE = 2;
15
- const BOAT = 3;
16
- const ANIMAL = 4;
17
- const REFRIGERATED = 5;
18
- const OTHER = 6;
19
-
20
- protected function _setupOptions()
21
- {
22
- $this->_options = array(
23
- self::GENERAL_GOODS => 'General Goods',
24
- self::FREIGHT => 'Freight',
25
- self::VEHICLE => 'Vehicle',
26
- self::BOAT => 'Boat',
27
- self::ANIMAL => 'Animal',
28
- self::REFRIGERATED => 'Refrigerated',
29
- self::OTHER => 'Other',
30
- );
31
- }
32
-
33
- }
1
+ <?php
2
+ /**
3
+ * System Config Source Shipment Class
4
+ *
5
+ * @package Temando_Temando
6
+ * @author Temando Magento Team <marketing@temando.com>
7
+ */
8
+ class Temando_Temando_Model_System_Config_Source_Shipment_Class
9
+ extends Temando_Temando_Model_System_Config_Source
10
+ {
11
+
12
+ const GENERAL_GOODS = 0;
13
+ const FREIGHT = 1;
14
+ const VEHICLE = 2;
15
+ const BOAT = 3;
16
+ const ANIMAL = 4;
17
+ const REFRIGERATED = 5;
18
+ const OTHER = 6;
19
+
20
+ protected function _setupOptions()
21
+ {
22
+ $this->_options = array(
23
+ self::GENERAL_GOODS => 'General Goods',
24
+ self::FREIGHT => 'Freight',
25
+ self::VEHICLE => 'Vehicle',
26
+ self::BOAT => 'Boat',
27
+ self::ANIMAL => 'Animal',
28
+ self::REFRIGERATED => 'Refrigerated',
29
+ self::OTHER => 'Other',
30
+ );
31
+ }
32
+
33
+ }
app/code/community/Temando/Temando/Model/System/Config/Source/Shipment/Packaging.php CHANGED
@@ -1,55 +1,55 @@
1
- <?php
2
- /**
3
- * System Config Source Shipment Packaging
4
- *
5
- * @package Temando_Temando
6
- * @author Temando Magento Team <marketing@temando.com>
7
- */
8
- class Temando_Temando_Model_System_Config_Source_Shipment_Packaging
9
- extends Temando_Temando_Model_System_Config_Source
10
- {
11
- const BOX = 0;
12
- const CARTON = 1;
13
- const CRATE = 2;
14
- const CYLINDER = 3;
15
- const DOCUMENT_ENVELOPE = 4;
16
- const FLAT_PACK = 5;
17
- const LETTER = 6;
18
- const PALLET = 7;
19
- const PARCEL = 8;
20
- const SATCHEL_OR_BAG = 9;
21
- const SKID = 10;
22
- const UNPACKAGED_OR_NA = 11;
23
- const WHEEL_OR_TYRE = 12;
24
-
25
- protected function _setupOptions()
26
- {
27
- $this->_options = array(
28
- self::BOX => 'Box',
29
- self::CARTON => 'Carton',
30
- self::CRATE => 'Crate',
31
- self::CYLINDER => 'Cylinder',
32
- self::DOCUMENT_ENVELOPE => 'Document Envelope',
33
- self::FLAT_PACK => 'Flat Pack',
34
- self::LETTER => 'Letter',
35
- self::PALLET => 'Pallet',
36
- self::PARCEL => 'Parcel',
37
- self::SATCHEL_OR_BAG => 'Satchel/Bag',
38
- self::SKID => 'Skid',
39
- self::UNPACKAGED_OR_NA => 'Unpackaged or N/A',
40
- self::WHEEL_OR_TYRE => 'Wheel/Tyre'
41
- );
42
- }
43
-
44
- /**
45
- * Returns the option key by its label
46
- *
47
- * @param string $label
48
- * @return int
49
- */
50
- public function getOptionId($label)
51
- {
52
- return array_search(strtolower(trim($label)), array_map('strtolower', $this->getOptions()));
53
- }
54
-
55
- }
1
+ <?php
2
+ /**
3
+ * System Config Source Shipment Packaging
4
+ *
5
+ * @package Temando_Temando
6
+ * @author Temando Magento Team <marketing@temando.com>
7
+ */
8
+ class Temando_Temando_Model_System_Config_Source_Shipment_Packaging
9
+ extends Temando_Temando_Model_System_Config_Source
10
+ {
11
+ const BOX = 0;
12
+ const CARTON = 1;
13
+ const CRATE = 2;
14
+ const CYLINDER = 3;
15
+ const DOCUMENT_ENVELOPE = 4;
16
+ const FLAT_PACK = 5;
17
+ const LETTER = 6;
18
+ const PALLET = 7;
19
+ const PARCEL = 8;
20
+ const SATCHEL_OR_BAG = 9;
21
+ const SKID = 10;
22
+ const UNPACKAGED_OR_NA = 11;
23
+ const WHEEL_OR_TYRE = 12;
24
+
25
+ protected function _setupOptions()
26
+ {
27
+ $this->_options = array(
28
+ self::BOX => 'Box',
29
+ self::CARTON => 'Carton',
30
+ self::CRATE => 'Crate',
31
+ self::CYLINDER => 'Cylinder',
32
+ self::DOCUMENT_ENVELOPE => 'Document Envelope',
33
+ self::FLAT_PACK => 'Flat Pack',
34
+ self::LETTER => 'Letter',
35
+ self::PALLET => 'Pallet',
36
+ self::PARCEL => 'Parcel',
37
+ self::SATCHEL_OR_BAG => 'Satchel/Bag',
38
+ self::SKID => 'Skid',
39
+ self::UNPACKAGED_OR_NA => 'Unpackaged or N/A',
40
+ self::WHEEL_OR_TYRE => 'Wheel/Tyre'
41
+ );
42
+ }
43
+
44
+ /**
45
+ * Returns the option key by its label
46
+ *
47
+ * @param string $label
48
+ * @return int
49
+ */
50
+ public function getOptionId($label)
51
+ {
52
+ return array_search(strtolower(trim($label)), array_map('strtolower', $this->getOptions()));
53
+ }
54
+
55
+ }
app/code/community/Temando/Temando/Model/System/Config/Source/Shipment/Packaging/Mode.php CHANGED
@@ -1,22 +1,22 @@
1
- <?php
2
- /**
3
- * System Config Source Shipment Packaging Mode
4
- *
5
- * @package Temando_Temando
6
- * @author Temando Magento Team <marketing@temando.com>
7
- */
8
- class Temando_Temando_Model_System_Config_Source_Shipment_Packaging_Mode
9
- extends Temando_Temando_Model_System_Config_Source
10
- {
11
- const USE_DEFAULTS = 0;
12
- const AS_DEFINED = 1;
13
-
14
- protected function _setupOptions()
15
- {
16
- $this->_options = array(
17
- self::USE_DEFAULTS => Mage::helper('temando')->__('Use Defaults'),
18
- self::AS_DEFINED => Mage::helper('temando')->__('As Defined'),
19
- );
20
- }
21
-
22
- }
1
+ <?php
2
+ /**
3
+ * System Config Source Shipment Packaging Mode
4
+ *
5
+ * @package Temando_Temando
6
+ * @author Temando Magento Team <marketing@temando.com>
7
+ */
8
+ class Temando_Temando_Model_System_Config_Source_Shipment_Packaging_Mode
9
+ extends Temando_Temando_Model_System_Config_Source
10
+ {
11
+ const USE_DEFAULTS = 0;
12
+ const AS_DEFINED = 1;
13
+
14
+ protected function _setupOptions()
15
+ {
16
+ $this->_options = array(
17
+ self::USE_DEFAULTS => Mage::helper('temando')->__('Use Defaults'),
18
+ self::AS_DEFINED => Mage::helper('temando')->__('As Defined'),
19
+ );
20
+ }
21
+
22
+ }
app/code/community/Temando/Temando/Model/System/Config/Source/Shipment/Service.php CHANGED
@@ -1,25 +1,24 @@
1
- <?php
2
- /**
3
- * System Config Source Shipment Service
4
- *
5
- * @package Temando_Temando
6
- * @author Temando Magento Team <marketing@temando.com>
7
- */
8
- class Temando_Temando_Model_System_Config_Source_Shipment_Service
9
- extends Temando_Temando_Model_System_Config_Source
10
- {
11
-
12
- const SAME_DAY = 1;
13
- const EXPRESS = 2;
14
- const STANDARD = 3;
15
-
16
- protected function _setupOptions()
17
- {
18
- $this->_options = array(
19
- self::SAME_DAY => Mage::helper('temando')->__('Same Day'),
20
- self::EXPRESS => Mage::helper('temando')->__('Express'),
21
- self::STANDARD => Mage::helper('temando')->__('Standard'),
22
- );
23
- }
24
-
25
- }
1
+ <?php
2
+ /**
3
+ * System Config Source Shipment Service
4
+ *
5
+ * @package Temando_Temando
6
+ * @author Temando Magento Team <marketing@temando.com>
7
+ */
8
+ class Temando_Temando_Model_System_Config_Source_Shipment_Service
9
+ extends Temando_Temando_Model_System_Config_Source
10
+ {
11
+
12
+ const SAME_DAY = 1;
13
+ const EXPRESS = 2;
14
+ const STANDARD = 3;
15
+
16
+ protected function _setupOptions()
17
+ {
18
+ $this->_options = array(
19
+ self::SAME_DAY => Mage::helper('temando')->__('Same Day'),
20
+ self::EXPRESS => Mage::helper('temando')->__('Express'),
21
+ self::STANDARD => Mage::helper('temando')->__('Standard'),
22
+ );
23
+ }
24
+ }
 
app/code/community/Temando/Temando/Model/System/Config/Source/Shipment/Status.php CHANGED
@@ -1,23 +1,23 @@
1
- <?php
2
- /**
3
- * System Config Source Shipment Status
4
- *
5
- * @package Temando_Temando
6
- * @author Temando Magento Team <marketing@temando.com>
7
- */
8
- class Temando_Temando_Model_System_Config_Source_Shipment_Status
9
- extends Temando_Temando_Model_System_Config_Source
10
- {
11
-
12
- const PENDING = '0';
13
- const BOOKED = '1';
14
-
15
- protected function _setupOptions()
16
- {
17
- $this->_options = array(
18
- self::PENDING => Mage::helper('temando')->__('Pending'),
19
- self::BOOKED => Mage::helper('temando')->__('Booked'),
20
- );
21
- }
22
-
23
- }
1
+ <?php
2
+ /**
3
+ * System Config Source Shipment Status
4
+ *
5
+ * @package Temando_Temando
6
+ * @author Temando Magento Team <marketing@temando.com>
7
+ */
8
+ class Temando_Temando_Model_System_Config_Source_Shipment_Status
9
+ extends Temando_Temando_Model_System_Config_Source
10
+ {
11
+
12
+ const PENDING = '0';
13
+ const BOOKED = '1';
14
+
15
+ protected function _setupOptions()
16
+ {
17
+ $this->_options = array(
18
+ self::PENDING => Mage::helper('temando')->__('Pending'),
19
+ self::BOOKED => Mage::helper('temando')->__('Booked'),
20
+ );
21
+ }
22
+
23
+ }
app/code/community/Temando/Temando/Model/System/Config/Source/Unit.php CHANGED
@@ -1,62 +1,62 @@
1
- <?php
2
- /**
3
- * System Config Source Unit
4
- *
5
- * @package Temando_Temando
6
- * @author Temando Magento Team <marketing@temando.com>
7
- */
8
- abstract class Temando_Temando_Model_System_Config_Source_Unit
9
- extends Temando_Temando_Model_System_Config_Source
10
- {
11
-
12
- /**
13
- * Same as the parent::_options array, except with brief labels as values.
14
- *
15
- * As the $_options array will contain the name of the unit (e.g. "Metres",
16
- * "Inches"), this will contain a shorter description e.g. the units when
17
- * used after a measurement ("m.", "in.", etc).
18
- *
19
- * @var array
20
- */
21
- protected $_brief_options;
22
-
23
- public function __construct()
24
- {
25
- parent::__construct();
26
- $this->_setupBriefOptions();
27
- }
28
-
29
- /**
30
- * Sets up the $_brief_options array with the correct values.
31
- *
32
- * This function is called in the constructor.
33
- *
34
- * @return Temando_Temando_Model_System_Config_Source_Abstract
35
- */
36
- protected abstract function _setupBriefOptions();
37
-
38
- /**
39
- * Looks up an option by key and gets the label.
40
- *
41
- * @param mixed $value
42
- * @return mixed
43
- */
44
- public function getBriefOptionLabel($value)
45
- {
46
- if (array_key_exists($value, $this->_brief_options)) {
47
- return $this->_brief_options[$value];
48
- }
49
- return null;
50
- }
51
-
52
- public function toBriefOptionArray()
53
- {
54
- return $this->_toOptionArray($this->_brief_options);
55
- }
56
-
57
- public function getOptionValue($value)
58
- {
59
- return array_search($value, array_flip($this->_brief_options));
60
- }
61
-
62
- }
1
+ <?php
2
+ /**
3
+ * System Config Source Unit
4
+ *
5
+ * @package Temando_Temando
6
+ * @author Temando Magento Team <marketing@temando.com>
7
+ */
8
+ abstract class Temando_Temando_Model_System_Config_Source_Unit
9
+ extends Temando_Temando_Model_System_Config_Source
10
+ {
11
+
12
+ /**
13
+ * Same as the parent::_options array, except with brief labels as values.
14
+ *
15
+ * As the $_options array will contain the name of the unit (e.g. "Metres",
16
+ * "Inches"), this will contain a shorter description e.g. the units when
17
+ * used after a measurement ("m.", "in.", etc).
18
+ *
19
+ * @var array
20
+ */
21
+ protected $_brief_options;
22
+
23
+ public function __construct()
24
+ {
25
+ parent::__construct();
26
+ $this->_setupBriefOptions();
27
+ }
28
+
29
+ /**
30
+ * Sets up the $_brief_options array with the correct values.
31
+ *
32
+ * This function is called in the constructor.
33
+ *
34
+ * @return Temando_Temando_Model_System_Config_Source_Abstract
35
+ */
36
+ protected abstract function _setupBriefOptions();
37
+
38
+ /**
39
+ * Looks up an option by key and gets the label.
40
+ *
41
+ * @param mixed $value
42
+ * @return mixed
43
+ */
44
+ public function getBriefOptionLabel($value)
45
+ {
46
+ if (array_key_exists($value, $this->_brief_options)) {
47
+ return $this->_brief_options[$value];
48
+ }
49
+ return null;
50
+ }
51
+
52
+ public function toBriefOptionArray()
53
+ {
54
+ return $this->_toOptionArray($this->_brief_options);
55
+ }
56
+
57
+ public function getOptionValue($value)
58
+ {
59
+ return array_search($value, array_flip($this->_brief_options));
60
+ }
61
+
62
+ }
app/code/community/Temando/Temando/Model/System/Config/Source/Unit/Measure.php CHANGED
@@ -1,37 +1,36 @@
1
- <?php
2
- /**
3
- * System Config Source Unit Measure
4
- *
5
- * @package Temando_Temando
6
- * @author Temando Magento Team <marketing@temando.com>
7
- */
8
- class Temando_Temando_Model_System_Config_Source_Unit_Measure
9
- extends Temando_Temando_Model_System_Config_Source_Unit
10
- {
11
-
12
- const CENTIMETRES = 'Centimetres';
13
- const METRES = 'Metres';
14
- const INCHES = 'Inches';
15
- const FEET = 'Feet';
16
-
17
- protected function _setupOptions()
18
- {
19
- $this->_options = array(
20
- self::CENTIMETRES => 'Centimetres',
21
- self::METRES => 'Metres',
22
- self::INCHES => 'Inches',
23
- self::FEET => 'Feet',
24
- );
25
- }
26
-
27
- protected function _setupBriefOptions()
28
- {
29
- $this->_brief_options = array(
30
- self::CENTIMETRES => 'cm',
31
- self::METRES => 'm',
32
- self::INCHES => 'in.',
33
- self::FEET => 'ft.',
34
- );
35
- }
36
-
37
- }
1
+ <?php
2
+ /**
3
+ * System Config Source Unit Measure
4
+ *
5
+ * @package Temando_Temando
6
+ * @author Temando Magento Team <marketing@temando.com>
7
+ */
8
+ class Temando_Temando_Model_System_Config_Source_Unit_Measure
9
+ extends Temando_Temando_Model_System_Config_Source_Unit
10
+ {
11
+
12
+ const CENTIMETRES = 'Centimetres';
13
+ const METRES = 'Metres';
14
+ const INCHES = 'Inches';
15
+ const FEET = 'Feet';
16
+
17
+ protected function _setupOptions()
18
+ {
19
+ $this->_options = array(
20
+ self::CENTIMETRES => 'Centimetres',
21
+ self::METRES => 'Metres',
22
+ self::INCHES => 'Inches',
23
+ self::FEET => 'Feet',
24
+ );
25
+ }
26
+
27
+ protected function _setupBriefOptions()
28
+ {
29
+ $this->_brief_options = array(
30
+ self::CENTIMETRES => 'cm',
31
+ self::METRES => 'm',
32
+ self::INCHES => 'in.',
33
+ self::FEET => 'ft.',
34
+ );
35
+ }
36
+ }
 
app/code/community/Temando/Temando/Model/System/Config/Source/Unit/Weight.php CHANGED
@@ -1,37 +1,37 @@
1
- <?php
2
- /**
3
- * System Config Source Unit Weight
4
- *
5
- * @package Temando_Temando
6
- * @author Temando Magento Team <marketing@temando.com>
7
- */
8
- class Temando_Temando_Model_System_Config_Source_Unit_Weight
9
- extends Temando_Temando_Model_System_Config_Source_Unit
10
- {
11
-
12
- const GRAMS = 'Grams';
13
- const KILOGRAMS = 'Kilograms';
14
- const OUNCES = 'Ounces';
15
- const POUNDS = 'Pounds';
16
-
17
- protected function _setupOptions()
18
- {
19
- $this->_options = array(
20
- self::GRAMS => 'Grams',
21
- self::KILOGRAMS => 'Kilograms',
22
- self::OUNCES => 'Ounces',
23
- self::POUNDS => 'Pounds',
24
- );
25
- }
26
-
27
- protected function _setupBriefOptions()
28
- {
29
- $this->_brief_options = array(
30
- self::GRAMS => 'g',
31
- self::KILOGRAMS => 'kg',
32
- self::OUNCES => 'oz.',
33
- self::POUNDS => 'lb.',
34
- );
35
- }
36
-
37
- }
1
+ <?php
2
+ /**
3
+ * System Config Source Unit Weight
4
+ *
5
+ * @package Temando_Temando
6
+ * @author Temando Magento Team <marketing@temando.com>
7
+ */
8
+ class Temando_Temando_Model_System_Config_Source_Unit_Weight
9
+ extends Temando_Temando_Model_System_Config_Source_Unit
10
+ {
11
+
12
+ const GRAMS = 'Grams';
13
+ const KILOGRAMS = 'Kilograms';
14
+ const OUNCES = 'Ounces';
15
+ const POUNDS = 'Pounds';
16
+
17
+ protected function _setupOptions()
18
+ {
19
+ $this->_options = array(
20
+ self::GRAMS => 'Grams',
21
+ self::KILOGRAMS => 'Kilograms',
22
+ self::OUNCES => 'Ounces',
23
+ self::POUNDS => 'Pounds',
24
+ );
25
+ }
26
+
27
+ protected function _setupBriefOptions()
28
+ {
29
+ $this->_brief_options = array(
30
+ self::GRAMS => 'g',
31
+ self::KILOGRAMS => 'kg',
32
+ self::OUNCES => 'oz.',
33
+ self::POUNDS => 'lb.',
34
+ );
35
+ }
36
+
37
+ }
app/code/community/Temando/Temando/Model/System/Config/Source/Wizard.php CHANGED
@@ -1,31 +1,31 @@
1
- <?php
2
- /**
3
- * System Config Source Wizard
4
- *
5
- * @package Temando_Temando
6
- * @author Temando Magento Team <marketing@temando.com>
7
- */
8
- class Temando_Temando_Model_System_Config_Source_Wizard
9
- extends Temando_Temando_Model_System_Config_Source
10
- {
11
-
12
- const ACCOUNT = 1;
13
- const CARRIERS = 2;
14
- const CATALOG_PRODUCT = 3;
15
- const ORIGIN = 4;
16
- const RULE = 5;
17
- const END = 6;
18
-
19
- protected function _setupOptions()
20
- {
21
- $this->_options = array(
22
- self::ACCOUNT => 'temando/temando/wizard/account.phtml',
23
- self::CARRIERS => 'temando/temando/wizard/carriers.phtml',
24
- self::CATALOG_PRODUCT => 'temando/temando/wizard/catalog_product.phtml',
25
- self::ORIGIN => 'temando/temando/wizard/origin.phtml',
26
- self::RULE => 'temando/temando/wizard/rule.phtml',
27
- self::END => 'temando/temando/wizard/end.phtml'
28
- );
29
- }
30
-
31
- }
1
+ <?php
2
+ /**
3
+ * System Config Source Wizard
4
+ *
5
+ * @package Temando_Temando
6
+ * @author Temando Magento Team <marketing@temando.com>
7
+ */
8
+ class Temando_Temando_Model_System_Config_Source_Wizard
9
+ extends Temando_Temando_Model_System_Config_Source
10
+ {
11
+
12
+ const ACCOUNT = 1;
13
+ const CARRIERS = 2;
14
+ const CATALOG_PRODUCT = 3;
15
+ const ORIGIN = 4;
16
+ const RULE = 5;
17
+ const END = 6;
18
+
19
+ protected function _setupOptions()
20
+ {
21
+ $this->_options = array(
22
+ self::ACCOUNT => 'temando/temando/wizard/account.phtml',
23
+ self::CARRIERS => 'temando/temando/wizard/carriers.phtml',
24
+ self::CATALOG_PRODUCT => 'temando/temando/wizard/catalog_product.phtml',
25
+ self::ORIGIN => 'temando/temando/wizard/origin.phtml',
26
+ self::RULE => 'temando/temando/wizard/rule.phtml',
27
+ self::END => 'temando/temando/wizard/end.phtml'
28
+ );
29
+ }
30
+
31
+ }
app/code/community/Temando/Temando/Model/Wizard.php CHANGED
@@ -1,206 +1,234 @@
1
- <?php
2
- /**
3
- * Wizard Model
4
- *
5
- * @package Temando_Temando
6
- * @author Temando Magento Team <marketing@temando.com>
7
- */
8
- class Temando_Temando_Model_Wizard extends Mage_Core_Model_Abstract
9
- {
10
-
11
- const ERR_WHS_SYNC = 'An error occured when synchronizing with temando.com. Origin location not saved on temando.com.';
12
- const SUC_WHS_SYNC = 'Origin location saved on temando.com.';
13
-
14
- public function _construct() {
15
- parent::_construct();
16
- }
17
-
18
- /**
19
- * Creates the cancel url from the current admin url
20
- */
21
- public function createCancelUrl() {
22
- $url = Mage::getBaseUrl() . Mage::getConfig()->getNode('admin/routers/adminhtml/args/frontName');
23
- Mage::getSingleton('core/session')->setTemandoCancelUrl($url);
24
- }
25
-
26
- /**
27
- * Checks the user details with the api
28
- * @param type $params
29
- * @return boolean
30
- */
31
- public function checkAccount($params) {
32
- try {
33
- $api = Mage::getModel('temando/api_client');
34
- /* @var $api Temando_Temando_Model_Api_Client */
35
- $api->connect(
36
- $params['general_username'], $params['general_password'], $params['general_sandbox']);
37
- $result = $api->getLocations(array('clientId' => $params['general_client']));
38
- if (!$result) {
39
- Mage::getSingleton('core/session')->addError(self::ERR_NO_CONNECT);
40
- return false;
41
- }
42
- } catch (Exception $e) {
43
- Mage::getSingleton('core/session')->addError($e->getMessage());
44
- return false;
45
- }
46
- return true;
47
- }
48
-
49
- /**
50
- * Saves Temando data in core resource
51
- * @param type $params
52
- * @return \Temando_Temando_Model_Wizard
53
- */
54
- public function _saveTemando($params) {
55
- foreach ($params as $key => $value) {
56
- if (strstr($key, '_', TRUE) != 'region') {
57
- $this->setTmdConfig('temando/' . $key, $value);
58
- }
59
- }
60
-
61
- return $this;
62
- }
63
-
64
- /**
65
- * Saves carrier data in core resource
66
- * @param type $params
67
- * @return \Temando_Temando_Model_Wizard
68
- */
69
- public function _saveCarrier($params) {
70
- foreach ($params as $key => $value) {
71
- if (strstr($key, '_', TRUE) != 'email') {
72
- $this->setTmdConfig('carriers/' . $key, $value);
73
- }
74
- }
75
- return $this;
76
- }
77
-
78
- /**
79
- * Sync origin data with Temando
80
- * @return \Temando_Temando_Model_Wizard
81
- */
82
- public function _syncOrigin() {
83
-
84
- try {
85
- $api = Mage::getModel('temando/api_client');
86
- $api->connect(
87
- Mage::helper('temando')->getConfigData('general/username'),
88
- Mage::helper('temando')->getConfigData('general/password'),
89
- Mage::helper('temando')->getConfigData('general/sandbox')
90
- );
91
-
92
- //try to update 'Magento Warehouse'
93
- $magentoWarehouse = Mage::helper('temando')->getOriginRequestArray(new Varien_Object($this->getFieldsetData()));
94
- try {
95
- $api->updateLocation(array('location' => $magentoWarehouse));
96
- } catch (Exception $e) {
97
- try {
98
- //if error updating location, location probably does not exist - try to create
99
- Mage::log($e->getMessage());
100
- $api->createLocation(array('location' => $magentoWarehouse));
101
- Mage::getSingleton('core/session')->addSuccess(self::SUC_WHS_SYNC);
102
- } catch (Exception $e) {
103
- Mage::getSingleton('core/session')->addError(self::ERR_WHS_SYNC);
104
- Mage::log($e->getMessage());
105
- }
106
- }
107
- } catch (Exception $e) {
108
- Mage::log($e->getMessage());
109
- }
110
-
111
- return $this;
112
- }
113
-
114
- /**
115
- * Sets parameters in Temando session
116
- * @param type $name
117
- * @param type $params
118
- * @return \Temando_Temando_Model_Wizard
119
- */
120
- public function setTmdSession($name, $params) {
121
- Mage::getSingleton('core/session')->setData($name, $params);
122
- return $this;
123
- }
124
-
125
- /**
126
- * Gets parameters from Temando session
127
- * @param type $name
128
- * @return type
129
- */
130
- protected function getTmdSession($name) {
131
- $session = Mage::getSingleton('core/session')->getData($name);
132
- return $session;
133
- }
134
-
135
- /**
136
- * Sets the current wizard step in the session
137
- * @param type $step
138
- * @return \Temando_Temando_Model_Wizard
139
- */
140
- public function setTmdStep($step) {
141
- Mage::getSingleton('core/session')->setTemandoWizardStep($step);
142
- return $this;
143
- }
144
-
145
- /**
146
- * Unsets step data from the session
147
- * @return \Temando_Temando_Model_Wizard
148
- */
149
- public function unsetTmdStep() {
150
- Mage::getSingleton('core/session')->unsetTemandoWizardStep();
151
- return $this;
152
- }
153
-
154
- /**
155
- * Saves data in core resource
156
- * @param type $key
157
- * @param type $value
158
- */
159
- protected function setTmdConfig($key, $value) {
160
- $path = strstr($key, '_', TRUE);
161
- $key = substr(strstr($key, '_'), 1);
162
- if (is_array($value)) {
163
- $value = implode(',', $value);
164
- }
165
-
166
- Mage::getModel('core/config')->saveConfig($path . '/' . $key, $value);
167
- }
168
-
169
- /**
170
- * Sends an email if customer wants more information
171
- */
172
- public function sendEmail() {
173
-
174
- $email = $this->getTmdSession('temando_wizard_carriers');
175
-
176
- if (!empty($email['email_checkbox'])) {
177
-
178
- if (array_key_exists('email_checkbox', $email)) {
179
-
180
- $line = '--------------------------------';
181
- $body = 'Temando Carrier Enquiry Submitted<br>' . $line . '<br>';
182
- $body .= 'Name: ' . $email['email_full_name'] . '<br>';
183
- $body .= 'Email address: ' . $email['email_email_address'] . '<br>';
184
- $body .= 'Phone: ' . $email['email_phone'] . '<br><br>';
185
- $body .= 'Current Magento Details<br>' . $line . '<br>';
186
- $body .= 'Client ID: ' . Mage::helper('temando')->getConfigData('general/client') . '<br>';
187
- $body .= 'Login ID: ' . Mage::helper('temando')->getConfigData('general/username') . '<br>';
188
- $body .= 'Payment Type: ' . Mage::helper('temando')->getConfigData('general/payment_type') . '<br>';
189
-
190
- try {
191
- $mail = new Zend_Mail();
192
- $mail->setFrom("temando_bronze@temando.com", "Temando Bronze - Starter");
193
- $mail->addTo("sales@temando.com", "Sales");
194
- $mail->setSubject("Temando Carrier Enquiry");
195
- $mail->setBodyHtml($body);
196
- $mail->send();
197
- Mage::getSingleton('core/session')->unsetData('temando_wizard_carriers');
198
- } catch (Exception $e) {
199
- //echo $e->getMessage();
200
- }
201
- }
202
- }
203
- return $this;
204
- }
205
-
206
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Wizard Model
4
+ *
5
+ * @package Temando_Temando
6
+ * @author Temando Magento Team <marketing@temando.com>
7
+ */
8
+ class Temando_Temando_Model_Wizard extends Mage_Core_Model_Abstract
9
+ {
10
+
11
+ const ERR_WHS_SYNC = 'An error occured when synchronizing with temando.com.
12
+ Origin location not saved on temando.com.';
13
+ const SUC_WHS_SYNC = 'Origin location saved on temando.com.';
14
+
15
+ public function _construct()
16
+ {
17
+ parent::_construct();
18
+ }
19
+
20
+ /**
21
+ * Creates the cancel url from the current admin url
22
+ */
23
+
24
+ public function createCancelUrl()
25
+ {
26
+ $url = Mage::getBaseUrl() . Mage::getConfig()->getNode('admin/routers/adminhtml/args/frontName');
27
+ Mage::getSingleton('core/session')->setTemandoCancelUrl($url);
28
+ }
29
+
30
+ /**
31
+ * Checks the user details with the api
32
+ * @param type $params
33
+ * @return boolean
34
+ */
35
+
36
+ public function checkAccount($params)
37
+ {
38
+ try {
39
+
40
+ $api = Mage::getModel('temando/api_client');
41
+ /* @var $api Temando_Temando_Model_Api_Client */
42
+ $api->connect($params['general_username'], $params['general_password'], $params['general_sandbox']);
43
+ $result = $api->getLocations(array('clientId' => $params['general_client']));
44
+ if (!$result) {
45
+ Mage::getSingleton('core/session')->addError(self::ERR_NO_CONNECT);
46
+ return false;
47
+ }
48
+ } catch (Exception $e) {
49
+ Mage::getSingleton('core/session')->addError($e->getMessage());
50
+ return false;
51
+ }
52
+ return true;
53
+ }
54
+
55
+ /**
56
+ * Saves Temando data in core resource
57
+ * @param type $params
58
+ * @return \Temando_Temando_Model_Wizard
59
+ */
60
+ public function _saveTemando($params)
61
+ {
62
+
63
+ foreach ($params as $key => $value) {
64
+ if (strstr($key, '_', true) != 'region') {
65
+ $this->setTmdConfig('temando/' . $key, $value);
66
+ }
67
+ }
68
+ return $this;
69
+ }
70
+
71
+ /**
72
+ * Saves carrier data in core resource
73
+ * @param type $params
74
+ * @return \Temando_Temando_Model_Wizard
75
+ */
76
+ public function _saveCarrier($params)
77
+ {
78
+
79
+ foreach ($params as $key => $value) {
80
+ if (strstr($key, '_', true) != 'email') {
81
+ $this->setTmdConfig('carriers/' . $key, $value);
82
+ }
83
+ }
84
+ return $this;
85
+ }
86
+
87
+ /**
88
+ * Sync origin data with Temando
89
+ * @return \Temando_Temando_Model_Wizard
90
+ */
91
+ public function _syncOrigin()
92
+ {
93
+
94
+ try {
95
+ $api = Mage::getModel('temando/api_client');
96
+ $api->connect(
97
+ Mage::helper('temando')->getConfigData('general/username'),
98
+ Mage::helper('temando')->getConfigData('general/password'),
99
+ Mage::helper('temando')->getConfigData('general/sandbox')
100
+ );
101
+
102
+ //try to update 'Magento Warehouse'
103
+ $magentoWarehouse = Mage::helper('temando')->
104
+ getOriginRequestArray(new Varien_Object($this->getFieldsetData()));
105
+ try {
106
+ $api->updateLocation(array('location' => $magentoWarehouse));
107
+ } catch (Exception $e) {
108
+ try {
109
+ //if error updating location, location probably does not exist - try to create
110
+ Mage::log($e->getMessage());
111
+ $api->createLocation(array('location' => $magentoWarehouse));
112
+ Mage::getSingleton('core/session')->addSuccess(self::SUC_WHS_SYNC);
113
+ } catch (Exception $e) {
114
+ Mage::getSingleton('core/session')->addError(self::ERR_WHS_SYNC);
115
+ Mage::log($e->getMessage());
116
+ }
117
+ }
118
+ } catch (Exception $e) {
119
+ Mage::log($e->getMessage());
120
+ }
121
+
122
+ return $this;
123
+ }
124
+
125
+ /**
126
+ * Sets parameters in Temando session
127
+ * @param type $name
128
+ * @param type $params
129
+ * @return \Temando_Temando_Model_Wizard
130
+ */
131
+
132
+ public function setTmdSession($name, $params)
133
+ {
134
+
135
+ Mage::getSingleton('core/session')->setData($name, $params);
136
+ return $this;
137
+ }
138
+
139
+ /**
140
+ * Gets parameters from Temando session
141
+ * @param type $name
142
+ * @return type
143
+ */
144
+
145
+ protected function getTmdSession($name)
146
+ {
147
+
148
+ $session = Mage::getSingleton('core/session')->getData($name);
149
+ return $session;
150
+ }
151
+
152
+ /**
153
+ * Sets the current wizard step in the session
154
+ * @param type $step
155
+ * @return \Temando_Temando_Model_Wizard
156
+ */
157
+
158
+ public function setTmdStep($step)
159
+ {
160
+
161
+ Mage::getSingleton('core/session')->setTemandoWizardStep($step);
162
+ return $this;
163
+ }
164
+
165
+ /**
166
+ * Unsets step data from the session
167
+ * @return \Temando_Temando_Model_Wizard
168
+ */
169
+
170
+ public function unsetTmdStep()
171
+ {
172
+
173
+ Mage::getSingleton('core/session')->unsetTemandoWizardStep();
174
+ return $this;
175
+ }
176
+
177
+ /**
178
+ * Saves data in core resource
179
+ * @param type $key
180
+ * @param type $value
181
+ */
182
+
183
+ protected function setTmdConfig($key, $value)
184
+ {
185
+
186
+ $path = strstr($key, '_', true);
187
+ $key = substr(strstr($key, '_'), 1);
188
+ if (is_array($value)) {
189
+ $value = implode(',', $value);
190
+ }
191
+
192
+ Mage::getModel('core/config')->saveConfig($path . '/' . $key, $value);
193
+ }
194
+
195
+ /**
196
+ * Sends an email if customer wants more information
197
+ */
198
+
199
+ public function sendEmail()
200
+ {
201
+
202
+ $email = $this->getTmdSession('temando_wizard_carriers');
203
+
204
+ if (!empty($email['email_checkbox'])) {
205
+
206
+ if (array_key_exists('email_checkbox', $email)) {
207
+
208
+ $line = '--------------------------------';
209
+ $body = 'Temando Carrier Enquiry Submitted<br>' . $line . '<br>';
210
+ $body .= 'Name: ' . $email['email_full_name'] . '<br>';
211
+ $body .= 'Email address: ' . $email['email_email_address'] . '<br>';
212
+ $body .= 'Phone: ' . $email['email_phone'] . '<br><br>';
213
+ $body .= 'Current Magento Details<br>' . $line . '<br>';
214
+ $body .= 'Client ID: ' . Mage::helper('temando')->getConfigData('general/client') . '<br>';
215
+ $body .= 'Login ID: ' . Mage::helper('temando')->getConfigData('general/username') . '<br>';
216
+ $body .= 'Payment Type: ' . Mage::helper('temando')->getConfigData('general/payment_type') . '<br>';
217
+
218
+ try {
219
+ $mail = new Zend_Mail();
220
+ $mail->setFrom("temando_bronze@temando.com", "Temando Bronze - Starter");
221
+ $mail->addTo("sales@temando.com", "Sales");
222
+ $mail->setSubject("Temando Carrier Enquiry");
223
+ $mail->setBodyHtml($body);
224
+ $mail->send();
225
+ Mage::getSingleton('core/session')->unsetData('temando_wizard_carriers');
226
+ } catch (Exception $e) {
227
+ //echo $e->getMessage();
228
+ }
229
+ }
230
+ }
231
+ return $this;
232
+ }
233
+
234
+ }
app/code/community/Temando/Temando/controllers/Adminhtml/CarrierController.php CHANGED
@@ -1,98 +1,101 @@
1
- <?php
2
- /**
3
- * Carrier Controller
4
- *
5
- * @package Temando_Temando
6
- * @author Temando Magento Team <marketing@temando.com>
7
- */
8
- class Temando_Temando_Adminhtml_CarrierController extends Mage_Adminhtml_Controller_Action
9
- {
10
-
11
- const CARRIER_ERROR = 'An error occured when synchronizing carriers with temando.com';
12
- const CARRIER_SUCCESS = 'Synchronized carriers';
13
-
14
- /**
15
- * Check admin permissions for this controller
16
- * Add a comment to this line
17
- *
18
- * @return boolean
19
- */
20
- protected function _isAllowed()
21
- {
22
- return Mage::getSingleton('admin/session')
23
- ->isAllowed('temando');
24
- }
25
-
26
- /**
27
- * Adminhtml controller that refreshes carriers in the temando_carrier table.
28
- * @return
29
- */
30
- public function indexAction()
31
- {
32
-
33
- try {
34
- $api = Mage::getModel('temando/api_client');
35
- /* @var $api Temando_Temando_Model_Api_Client */
36
- $api->connect(
37
- Mage::helper('temando')->getConfigData('general/username'),
38
- Mage::helper('temando')->getConfigData('general/password'),
39
- Mage::helper('temando')->getConfigData('general/sandbox')
40
- );
41
- $response = $api->getCarriers(array('clientId' => Mage::helper('temando')->getClientId(), 'showAdhoc' => 'Y'));
42
- //make sure we have an array
43
- if (!isset($response->linked->carrier)) {
44
- $response->linked->carrier = array();
45
- } else if (isset($response->linked->carrier) && !is_array($response->linked->carrier)) {
46
- $response->linked->carrier = array(0 => $response->linked->carrier);
47
- }
48
- if (!isset($response->adhoc->carrier)) {
49
- $response->adhoc->carrier = array();
50
- } else if (isset($response->adhoc->carrier) && !is_array($response->adhoc->carrier)) {
51
- $response->adhoc->carrier = array(0 => $response->adhoc->carrier);
52
- }
53
- foreach ($response->linked->carrier as $carrierResponse) {
54
- $this->loadResponse($carrierResponse);
55
- }
56
- foreach ($response->adhoc->carrier as $carrierResponse) {
57
- $this->loadResponse($carrierResponse);
58
- }
59
-
60
- Mage::getSingleton('adminhtml/session')->addSuccess(Mage::helper('temando')->__(self::CARRIER_SUCCESS));
61
- } catch (Exception $e) {
62
- Mage::getSingleton('adminhtml/session')->addError(Mage::helper('temando')->__(self::CARRIER_ERROR));
63
- }
64
-
65
- return $this->getResponse()->setRedirect($this->getRequest()->getServer('HTTP_REFERER'));
66
- }
67
-
68
- protected function loadResponse($response)
69
- {
70
- if ($response instanceof stdClass) {
71
- $carrier = Mage::getModel('temando/carrier')->load($response->id, 'carrier_id');
72
- /* @var $carrier Temando_Temando_Model_Carrier */
73
-
74
- $carrier
75
- ->setCarrierId(isset($response->id) ? $response->id : '')
76
- ->setCompanyName(isset($response->companyName) ? $response->companyName : '')
77
- ->setCompanyContact(isset($response->companyContact) ? $response->companyContact : '')
78
- ->setStreetAddress(isset($response->streetAddress) ? $response->streetAddress : '')
79
- ->setStreetSuburb(isset($response->streetSuburb) ? $response->streetSuburb : '')
80
- ->setStreetCity(isset($response->streetCity) ? $response->streetCity : '')
81
- ->setStreetState(isset($response->streetState) ? $response->streetState : '')
82
- ->setStreetPostcode(isset($response->streetCode) ? $response->streetCode : '')
83
- ->setStreetCountry(isset($response->streetCountry) ? $response->streetCountry : '')
84
- ->setPostalAddress(isset($response->postalAddress) ? $response->postalAddress : '')
85
- ->setPostalSuburb(isset($response->postalSuburb) ? $response->postalSuburb : '')
86
- ->setPostalCity(isset($response->postalCity) ? $response->postalCity : '')
87
- ->setPostalState(isset($response->postalState) ? $response->postalState : '')
88
- ->setPostalPostcode(isset($response->postalCode) ? $response->postalCode : '')
89
- ->setPostalCountry(isset($response->postalCountry) ? $response->postalCountry : '')
90
- ->setPhone(isset($response->phone1) ? $response->phone1 : '')
91
- ->setEmail(isset($response->email) ? $response->email : '')
92
- ->setWebsite(isset($response->website) ? $response->website : '')
93
- ->save();
94
- }
95
- }
96
-
97
- }
98
-
 
 
 
1
+ <?php
2
+ /**
3
+ * Carrier Controller
4
+ *
5
+ * @package Temando_Temando
6
+ * @author Temando Magento Team <marketing@temando.com>
7
+ */
8
+ class Temando_Temando_Adminhtml_CarrierController extends Mage_Adminhtml_Controller_Action
9
+ {
10
+
11
+ const CARRIER_ERROR = 'An error occured when synchronizing carriers with temando.com';
12
+ const CARRIER_SUCCESS = 'Synchronized carriers';
13
+
14
+ /**
15
+ * Check admin permissions for this controller
16
+ * Add a comment to this line
17
+ *
18
+ * @return boolean
19
+ */
20
+ protected function _isAllowed()
21
+ {
22
+ return Mage::getSingleton('admin/session')
23
+ ->isAllowed('temando');
24
+ }
25
+
26
+ /**
27
+ * Adminhtml controller that refreshes carriers in the temando_carrier table.
28
+ * @return
29
+ */
30
+ public function indexAction()
31
+ {
32
+ $showAdhoc = false;
33
+ try {
34
+ $api = Mage::getModel('temando/api_client');
35
+ /* @var $api Temando_Temando_Model_Api_Client */
36
+ $api->connect(
37
+ Mage::helper('temando')->getConfigData('general/username'),
38
+ Mage::helper('temando')->getConfigData('general/password'),
39
+ Mage::helper('temando')->getConfigData('general/sandbox')
40
+ );
41
+ $response = $api->getCarriers(array(
42
+ 'clientId' => Mage::helper('temando')->getClientId(),
43
+ 'showAdhoc' => $showAdhoc ? 'Y' : 'N'
44
+ ));
45
+ //make sure we have an array
46
+ if (!isset($response->linked->carrier)) {
47
+ $response->linked->carrier = array();
48
+ } elseif (isset($response->linked->carrier) && !is_array($response->linked->carrier)) {
49
+ $response->linked->carrier = array(0 => $response->linked->carrier);
50
+ }
51
+ foreach ($response->linked->carrier as $carrierResponse) {
52
+ $this->loadResponse($carrierResponse);
53
+ }
54
+ //process adhoc carriers
55
+ if ($showAdhoc) {
56
+ if (!isset($response->adhoc->carrier)) {
57
+ $response->adhoc->carrier = array();
58
+ } elseif (isset($response->adhoc->carrier) && !is_array($response->adhoc->carrier)) {
59
+ $response->adhoc->carrier = array(0 => $response->adhoc->carrier);
60
+ }
61
+ foreach ($response->adhoc->carrier as $carrierResponse) {
62
+ $this->loadResponse($carrierResponse);
63
+ }
64
+ }
65
+ Mage::getSingleton('adminhtml/session')->addSuccess(Mage::helper('temando')->__(self::CARRIER_SUCCESS));
66
+ } catch (Exception $e) {
67
+ Mage::getSingleton('adminhtml/session')->addError(Mage::helper('temando')->__(self::CARRIER_ERROR));
68
+ }
69
+
70
+ return $this->getResponse()->setRedirect($this->getRequest()->getServer('HTTP_REFERER'));
71
+ }
72
+
73
+ protected function loadResponse($response)
74
+ {
75
+ if ($response instanceof stdClass) {
76
+ $carrier = Mage::getModel('temando/carrier')->load($response->id, 'carrier_id');
77
+ /* @var $carrier Temando_Temando_Model_Carrier */
78
+
79
+ $carrier
80
+ ->setCarrierId(isset($response->id) ? $response->id : '')
81
+ ->setCompanyName(isset($response->companyName) ? $response->companyName : '')
82
+ ->setCompanyContact(isset($response->companyContact) ? $response->companyContact : '')
83
+ ->setStreetAddress(isset($response->streetAddress) ? $response->streetAddress : '')
84
+ ->setStreetSuburb(isset($response->streetSuburb) ? $response->streetSuburb : '')
85
+ ->setStreetCity(isset($response->streetCity) ? $response->streetCity : '')
86
+ ->setStreetState(isset($response->streetState) ? $response->streetState : '')
87
+ ->setStreetPostcode(isset($response->streetCode) ? $response->streetCode : '')
88
+ ->setStreetCountry(isset($response->streetCountry) ? $response->streetCountry : '')
89
+ ->setPostalAddress(isset($response->postalAddress) ? $response->postalAddress : '')
90
+ ->setPostalSuburb(isset($response->postalSuburb) ? $response->postalSuburb : '')
91
+ ->setPostalCity(isset($response->postalCity) ? $response->postalCity : '')
92
+ ->setPostalState(isset($response->postalState) ? $response->postalState : '')
93
+ ->setPostalPostcode(isset($response->postalCode) ? $response->postalCode : '')
94
+ ->setPostalCountry(isset($response->postalCountry) ? $response->postalCountry : '')
95
+ ->setPhone(isset($response->phone1) ? $response->phone1 : '')
96
+ ->setEmail(isset($response->email) ? $response->email : '')
97
+ ->setWebsite(isset($response->website) ? $response->website : '')
98
+ ->save();
99
+ }
100
+ }
101
+ }
app/code/community/Temando/Temando/controllers/Adminhtml/JsonController.php CHANGED
@@ -1,72 +1,72 @@
1
- <?php
2
- /**
3
- * Json Controller
4
- *
5
- * @package Temando_Temando
6
- * @author Temando Magento Team <marketing@temando.com>
7
- */
8
- class Temando_Temando_Adminhtml_JsonController extends Mage_Adminhtml_Controller_Action {
9
-
10
- /**
11
- * Check admin permissions for this controller
12
- * Add a comment to this line
13
- *
14
- * @return boolean
15
- */
16
- protected function _isAllowed()
17
- {
18
- return Mage::getSingleton('admin/session')
19
- ->isAllowed('temando');
20
- }
21
-
22
- /**
23
- * Return JSON-encoded array of country regions
24
- *
25
- * @return string
26
- */
27
- public function countryRegionAction()
28
- {
29
- $arrRes = array();
30
-
31
- $countryId = $this->getRequest()->getParam('parent');
32
- $colRegions = Mage::getResourceModel('directory/region_collection')
33
- ->addCountryFilter($countryId)
34
- ->load();
35
-
36
- $arrRegions = $this->_toOptionArray($colRegions);
37
- if (!empty($arrRegions)) {
38
- foreach ($arrRegions as $region) {
39
- $arrRes[] = $region;
40
- }
41
- }
42
-
43
- $this->getResponse()->setBody(Mage::helper('core')->jsonEncode($arrRes));
44
- }
45
-
46
- private function _toOptionArray(Mage_Directory_Model_Resource_Region_Collection $collection)
47
- {
48
- $options = array();
49
- if(!empty($collection)) {
50
- foreach($collection->getItems() as $region) {
51
- $options[$region->getRegionId()] = array(
52
- 'title' => $region->getDefaultName(),
53
- 'value' => $region->getCode(),
54
- 'label' => Mage::helper('temando')->__($region->getDefaultName())
55
- );
56
- }
57
- }
58
-
59
- if (count($options) > 0) {
60
- array_unshift($options, array(
61
- 'title '=> null,
62
- 'value' => '',
63
- 'label' => Mage::helper('temando')->__('-- Please select --')
64
- ));
65
- }
66
-
67
- return $options;
68
- }
69
-
70
- }
71
-
72
-
1
+ <?php
2
+ /**
3
+ * Json Controller
4
+ *
5
+ * @package Temando_Temando
6
+ * @author Temando Magento Team <marketing@temando.com>
7
+ */
8
+ class Temando_Temando_Adminhtml_JsonController extends Mage_Adminhtml_Controller_Action {
9
+
10
+ /**
11
+ * Check admin permissions for this controller
12
+ * Add a comment to this line
13
+ *
14
+ * @return boolean
15
+ */
16
+ protected function _isAllowed()
17
+ {
18
+ return Mage::getSingleton('admin/session')
19
+ ->isAllowed('temando');
20
+ }
21
+
22
+ /**
23
+ * Return JSON-encoded array of country regions
24
+ *
25
+ * @return string
26
+ */
27
+ public function countryRegionAction()
28
+ {
29
+ $arrRes = array();
30
+
31
+ $countryId = $this->getRequest()->getParam('parent');
32
+ $colRegions = Mage::getResourceModel('directory/region_collection')
33
+ ->addCountryFilter($countryId)
34
+ ->load();
35
+
36
+ $arrRegions = $this->_toOptionArray($colRegions);
37
+ if (!empty($arrRegions)) {
38
+ foreach ($arrRegions as $region) {
39
+ $arrRes[] = $region;
40
+ }
41
+ }
42
+
43
+ $this->getResponse()->setBody(Mage::helper('core')->jsonEncode($arrRes));
44
+ }
45
+
46
+ private function _toOptionArray(Mage_Directory_Model_Resource_Region_Collection $collection)
47
+ {
48
+ $options = array();
49
+ if (!empty($collection)) {
50
+ foreach ($collection->getItems() as $region) {
51
+ $options[$region->getRegionId()] = array(
52
+ 'title' => $region->getDefaultName(),
53
+ 'value' => $region->getCode(),
54
+ 'label' => Mage::helper('temando')->__($region->getDefaultName())
55
+ );
56
+ }
57
+ }
58
+
59
+ if (count($options) > 0) {
60
+ array_unshift(
61
+ $options,
62
+ array(
63
+ 'title '=> null,
64
+ 'value' => '',
65
+ 'label' => Mage::helper('temando')->__('-- Please select --')
66
+ )
67
+ );
68
+ }
69
+
70
+ return $options;
71
+ }
72
+ }
app/code/community/Temando/Temando/controllers/Adminhtml/ManifestController.php CHANGED
@@ -1,317 +1,350 @@
1
- <?php
2
- /**
3
- * Manifest Controller
4
- *
5
- * @package Temando_Temando
6
- * @author Temando Magento Team <marketing@temando.com>
7
- */
8
- class Temando_Temando_Adminhtml_ManifestController extends Mage_Adminhtml_Controller_Action
9
- {
10
-
11
- /**
12
- * Check admin permissions for this controller
13
- * Add a comment to this line
14
- *
15
- * @return boolean
16
- */
17
- protected function _isAllowed()
18
- {
19
- return Mage::getSingleton('admin/session')
20
- ->isAllowed('temando/manifest');
21
- }
22
-
23
- public function indexAction()
24
- {
25
- $this->loadLayout()
26
- ->_setActiveMenu('temando/manifest')
27
- ->_addBreadcrumb(Mage::helper('adminhtml')->__('Manage Manifests'), Mage::helper('adminhtml')->__('Manage Manifests'))
28
- ->renderLayout();
29
- }
30
-
31
- /**
32
- * Convert dates in array from localized to internal format
33
- *
34
- * @param array $array
35
- * @param array $dateFields
36
- * @return array
37
- */
38
- protected function _filterDates($array, $dateFields)
39
- {
40
- if (empty($dateFields)) {
41
- return $array;
42
- }
43
- $filterInput = new Zend_Filter_LocalizedToNormalized(array(
44
- 'date_format' => Mage::app()->getLocale()->getDateFormat(Mage_Core_Model_Locale::FORMAT_TYPE_SHORT)
45
- ));
46
- $filterInternal = new Zend_Filter_NormalizedToLocalized(array(
47
- 'date_format' => Varien_Date::DATE_INTERNAL_FORMAT
48
- ));
49
-
50
- foreach ($dateFields as $dateField) {
51
- if (array_key_exists($dateField, $array) && !empty($dateField)) {
52
- $array[$dateField] = $filterInput->filter($array[$dateField]);
53
- $array[$dateField] = $filterInternal->filter($array[$dateField]);
54
- }
55
- }
56
- return $array;
57
- }
58
-
59
- public function addAction()
60
- {
61
- $postData = $this->getRequest()->getPost();
62
- $post = $this->_filterDates($postData, array('from', 'to'));
63
- $carriers = $this->getRequest()->getParam('carrier_id');
64
- if (!is_array($carriers)) {
65
- $carriers = array($carriers);
66
- }
67
-
68
- $carriers_options = Mage::getModel('temando/shipping_carrier_temando_source_method')->getOptions();
69
- foreach ($carriers as $carrierId) {
70
-
71
- if(!$carrierId)
72
- continue;
73
-
74
- $request = array(
75
- 'carrierId' => $carrierId,
76
- 'location' => $this->getRequest()->getParam('warehouse_id'),
77
- 'readyDate' => isset($post['from'])?$post['from']:'',
78
- 'type' => 'Awaiting Confirmation',
79
- 'labelPrinterType' => Mage::helper('temando')->getConfigData('options/label_type')
80
- );
81
-
82
- try {
83
- $api = Mage::getModel('temando/api_client');
84
- /* @var $api Temando_Temando_Model_Api_Client */
85
- $api->connect(
86
- Mage::helper('temando')->getConfigData('general/username'),
87
- Mage::helper('temando')->getConfigData('general/password'),
88
- Mage::helper('temando')->getConfigData('general/sandbox'));
89
- $result = $api->getManifest($request);
90
- if (!$result) {
91
- throw new Exception('Cannot send request');
92
- }
93
-
94
- $model = Mage::getModel('temando/manifest')
95
- ->setData('location_id', $this->getRequest()->getParam('warehouse_id'))
96
- ->setData('carrier_id', $carrierId)
97
- ->setData('start_date', isset($post['from'])?$post['from']:'')
98
- ->setData('end_date', isset($post['from'])?$post['from']:'')
99
- ->setData('manifest_document_type', '')
100
- ->setData('manifest_document', '')
101
- ->setData('label_document_type', '')
102
- ->setData('type', 'Awaiting Confirmation')
103
- ->setData('label_document', '')
104
- ;
105
-
106
- $carrier_name = $carriers_options[$carrierId];
107
- if (!isset($result->manifestDocument) || !((string)$result->manifestDocument)) {
108
- throw new Exception('No data for carrier: ' . $carrier_name);
109
- }
110
-
111
- if (isset($result->manifestDocumentType)) {
112
- $model->setData('manifest_document_type', (string)$result->manifestDocumentType);
113
- }
114
- if (isset($result->manifestDocument)) {
115
- $model->setData('manifest_document', (string)$result->manifestDocument);
116
- }
117
- if (isset($result->labelDocumentType)) {
118
- $model->setData('label_document_type', (string)$result->labelDocumentType);
119
- }
120
- if (isset($result->labelDocument)) {
121
- $model->setData('label_document', (string)$result->labelDocument);
122
- }
123
-
124
- $model->save();
125
- $this->_getSession()
126
- ->addSuccess($this->__('Manifest successful added for carrier: ') . $carrier_name);
127
- } catch (Exception $e) {
128
- $this->_getSession()
129
- ->addError($e->getMessage());
130
- }
131
- }
132
-
133
- $this->_redirect('*/*/');
134
- }
135
-
136
- public function retrieveAction()
137
- {
138
- $postData = $this->getRequest()->getPost();
139
- $post = $this->_filterDates($postData, array('from', 'to'));
140
- $carriers = $this->getRequest()->getParam('carrier_id');
141
- if (!is_array($carriers)) {
142
- $carriers = array($carriers);
143
- }
144
-
145
- if (count($carriers) != 1) {
146
- $this->_getSession()->addError($this->__('Please only select one carrier at a time to retrieve a previous manifest.'));
147
- $this->_redirect('*/*/');
148
- } else {
149
- $carriers_options = Mage::getModel('temando/shipping_carrier_temando_source_method')->getOptions();
150
- $carrierId = $carriers[0];
151
-
152
- $request = array(
153
- 'carrierId' => $carrierId,
154
- 'location' => $this->getRequest()->getParam('warehouse_id'),
155
- 'readyDate' => isset($post['from'])?$post['from']:'',
156
- 'type' => 'Confirmed',
157
- 'labelPrinterType' => Mage::helper('temando')->getConfigData('options/label_type')
158
- );
159
- try {
160
- $api = Mage::getModel('temando/api_client');
161
- /* @var $api Temando_Temando_Model_Api_Client */
162
- $api->connect(
163
- Mage::helper('temando')->getConfigData('general/username'),
164
- Mage::helper('temando')->getConfigData('general/password'),
165
- Mage::helper('temando')->getConfigData('general/sandbox'));
166
- $result = $api->getManifest($request);
167
- if (!$result) {
168
- throw new Exception('Cannot send request');
169
- }
170
- $carrier_name = $carriers_options[$carrierId];
171
- if (!isset($result->manifestDocument) || !((string)$result->manifestDocument)) {
172
- throw new Exception('No data for carrier: ' . $carrier_name);
173
- }
174
-
175
- $doc = base64_decode($result->manifestDocument);
176
- $length = strlen($doc);
177
- if ($length) {
178
- $this->getResponse()
179
- ->setHttpResponseCode(200)
180
- ->setHeader('Pragma', 'public', true)
181
- ->setHeader('Cache-Control', 'must-revalidate, post-check=0, pre-check=0', true)
182
- ->setHeader('Content-type', $result->manifestDocumentType, true)
183
- ->setHeader('Content-Length', $length)
184
- ->setHeader('Content-Disposition', 'attachment; filename="manifest-' . $carrierId . '-' . $post['from'] . '.pdf"')
185
- ->setHeader('Last-Modified', date('r'));
186
- $this->getResponse()->clearBody();
187
- $this->getResponse()->sendHeaders();
188
- print $doc;
189
- }
190
- } catch (Exception $e) {
191
- $this->_getSession()
192
- ->addError($e->getMessage());
193
- $this->_redirect('*/*/');
194
- }
195
- }
196
- }
197
-
198
- public function manifestAction()
199
- {
200
- $manifest = Mage::getModel('temando/manifest')
201
- ->load($this->getRequest()->getParam('id'));
202
- /* @var $manifest Temando_Temando_Model_Manifest */
203
- if ($manifest->getId()) {
204
- $document = base64_decode($manifest->getManifestDocument());
205
- $document_length = strlen($document);
206
- $extension = '.pdf';
207
- $_t = explode('/', $manifest->getManifestDocumentType());
208
- if (isset($_t[1])) {
209
- $extension = "." . $_t[1];
210
- }
211
-
212
- if ($document_length) {
213
- $this->getResponse()
214
- ->setHttpResponseCode(200)
215
- ->setHeader('Pragma', 'public', true)
216
- ->setHeader('Cache-Control', 'must-revalidate, post-check=0, pre-check=0', true)
217
- ->setHeader('Content-type', $manifest->getManifestDocumentType(), true)
218
- ->setHeader('Content-Length', $document_length)
219
- ->setHeader('Content-Disposition', 'attachment; filename="manifest-'.$manifest->getId().$extension.'"')
220
- ->setHeader('Last-Modified', date('r'));
221
- $this->getResponse()->clearBody();
222
- $this->getResponse()->sendHeaders();
223
- print $document;
224
- }
225
- }
226
- }
227
-
228
- public function labelAction()
229
- {
230
- $manifest = Mage::getModel('temando/manifest')
231
- ->load($this->getRequest()->getParam('id'));
232
- /* @var $manifest Temando_Temando_Model_Manifest */
233
- if ($manifest->getId()) {
234
- $document = base64_decode($manifest->getLabelDocument());
235
- $document_length = strlen($document);
236
- $extension = '.pdf';
237
- $_t = explode('/', $manifest->getLabelDocumentType());
238
- if (isset($_t[1])) {
239
- $extension = "." . $_t[1];
240
- }
241
-
242
- if ($document_length) {
243
- $this->getResponse()
244
- ->setHttpResponseCode(200)
245
- ->setHeader('Pragma', 'public', true)
246
- ->setHeader('Cache-Control', 'must-revalidate, post-check=0, pre-check=0', true)
247
- ->setHeader('Content-type', $manifest->getLabelDocumentType(), true)
248
- ->setHeader('Content-Length', $document_length)
249
- ->setHeader('Content-Disposition', 'attachment; filename="label-'.$manifest->getId().$extension.'"')
250
- ->setHeader('Last-Modified', date('r'));
251
- $this->getResponse()->clearBody();
252
- $this->getResponse()->sendHeaders();
253
- print $document;
254
- }
255
- }
256
- }
257
-
258
- public function confirmAction()
259
- {
260
- $manifests = Mage::getModel('temando/manifest')
261
- ->getCollection()->addFieldToFilter('type', 'Awaiting Confirmation')->getItems();
262
- $carriers_options = Mage::getModel('temando/shipping_carrier_temando_source_method')->getOptions();
263
- foreach ($manifests as $manifest) {
264
- $request = array(
265
- 'carrierId' => $manifest->getCarrierId(),
266
- 'location' => $manifest->getLocationId(),
267
- 'startReadyDate' => $manifest->getStartDate(),
268
- 'endReadyDate' => $manifest->getStartDate(),
269
- /* @todo use store date, not server date */
270
- 'confirmedReadyDate' => now(true),
271
- 'labelPrinterType' => Mage::helper('temando')->getConfigData('options/label_type')
272
- );
273
-
274
- try {
275
- $api = Mage::getModel('temando/api_client');
276
- $api->connect(
277
- Mage::helper('temando')->getConfigData('general/username'),
278
- Mage::helper('temando')->getConfigData('general/password'),
279
- Mage::helper('temando')->getConfigData('general/sandbox'),
280
- true);
281
- $result = $api->confirmManifest($request);
282
- if (!$result) {
283
- throw new Exception('Cannot send request');
284
- }
285
-
286
- $carrier_name = $carriers_options[$manifest->getCarrierId()];
287
- if (!isset($result->manifestDocument) || !((string)$result->manifestDocument)) {
288
- throw new Exception('No data for carrier: ' . $carrier_name . 'and date ' . $manifest->getStartDate());
289
- }
290
-
291
- if (isset($result->manifestDocumentType)) {
292
- $manifest->setData('manifest_document_type', (string)$result->manifestDocumentType);
293
- }
294
- if (isset($result->manifestDocument)) {
295
- $manifest->setData('manifest_document', (string)$result->manifestDocument);
296
- }
297
- if (isset($result->labelDocumentType)) {
298
- $manifest->setData('label_document_type', (string)$result->labelDocumentType);
299
- }
300
- if (isset($result->labelDocument)) {
301
- $manifest->setData('label_document', (string)$result->labelDocument);
302
- }
303
-
304
- $manifest->setData('type', 'Confirmed');
305
- $manifest->save();
306
- $this->_getSession()
307
- ->addSuccess($this->__('Manifest successful confirmed for carrier: ' . $carrier_name . ' and date ' . $manifest->getStartDate()));
308
- } catch (Exception $e) {
309
- $this->_getSession()
310
- ->addError($e->getMessage());
311
- }
312
- }
313
-
314
- $this->_redirect('*/*/');
315
- }
316
-
317
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Manifest Controller
4
+ *
5
+ * @package Temando_Temando
6
+ * @author Temando Magento Team <marketing@temando.com>
7
+ */
8
+ class Temando_Temando_Adminhtml_ManifestController extends Mage_Adminhtml_Controller_Action
9
+ {
10
+
11
+ /**
12
+ * Check admin permissions for this controller
13
+ * Add a comment to this line
14
+ *
15
+ * @return boolean
16
+ */
17
+ protected function _isAllowed()
18
+ {
19
+ return Mage::getSingleton('admin/session')
20
+ ->isAllowed('temando/manifest');
21
+ }
22
+
23
+ public function indexAction()
24
+ {
25
+ $this->loadLayout()
26
+ ->_setActiveMenu('temando/manifest')
27
+ ->_addBreadcrumb(
28
+ Mage::helper('adminhtml')->__('Manage Manifests'),
29
+ Mage::helper('adminhtml')->__('Manage Manifests')
30
+ )
31
+ ->renderLayout();
32
+ }
33
+
34
+ /**
35
+ * Convert dates in array from localized to internal format
36
+ *
37
+ * @param array $array
38
+ * @param array $dateFields
39
+ * @return array
40
+ */
41
+ protected function _filterDates($array, $dateFields)
42
+ {
43
+ if (empty($dateFields)) {
44
+ return $array;
45
+ }
46
+ $filterInput = new Zend_Filter_LocalizedToNormalized(array(
47
+ 'date_format' => Mage::app()->getLocale()->getDateFormat(Mage_Core_Model_Locale::FORMAT_TYPE_SHORT)
48
+ ));
49
+ $filterInternal = new Zend_Filter_NormalizedToLocalized(array(
50
+ 'date_format' => Varien_Date::DATE_INTERNAL_FORMAT
51
+ ));
52
+
53
+ foreach ($dateFields as $dateField) {
54
+ if (array_key_exists($dateField, $array) && !empty($dateField)) {
55
+ $array[$dateField] = $filterInput->filter($array[$dateField]);
56
+ $array[$dateField] = $filterInternal->filter($array[$dateField]);
57
+ }
58
+ }
59
+ return $array;
60
+ }
61
+
62
+ public function addAction()
63
+ {
64
+ $postData = $this->getRequest()->getPost();
65
+ $post = $this->_filterDates($postData, array('from', 'to'));
66
+ $carriers = $this->getRequest()->getParam('carrier_id');
67
+ if (!is_array($carriers)) {
68
+ $carriers = array($carriers);
69
+ }
70
+
71
+ $carriers_options = Mage::getModel('temando/shipping_carrier_temando_source_method')->getOptions();
72
+ foreach ($carriers as $carrierId) {
73
+
74
+ if (!$carrierId) {
75
+ continue;
76
+ }
77
+ $request = array(
78
+ 'carrierId' => $carrierId,
79
+ 'location' => $this->getRequest()->getParam('warehouse_id'),
80
+ 'readyDate' => isset($post['from'])?$post['from']:'',
81
+ 'type' => 'Awaiting Confirmation',
82
+ 'labelPrinterType' => Mage::helper('temando')->getConfigData('options/label_type')
83
+ );
84
+
85
+ try {
86
+ $api = Mage::getModel('temando/api_client');
87
+ /* @var $api Temando_Temando_Model_Api_Client */
88
+ $api->connect(
89
+ Mage::helper('temando')->getConfigData('general/username'),
90
+ Mage::helper('temando')->getConfigData('general/password'),
91
+ Mage::helper('temando')->getConfigData('general/sandbox')
92
+ );
93
+
94
+ $result = $api->getManifest($request);
95
+
96
+ if (!$result) {
97
+ throw new Exception('Cannot send request');
98
+ }
99
+
100
+ $model = Mage::getModel('temando/manifest')
101
+ ->setData('location_id', $this->getRequest()->getParam('warehouse_id'))
102
+ ->setData('carrier_id', $carrierId)
103
+ ->setData('start_date', isset($post['from'])?$post['from']:'')
104
+ ->setData('end_date', isset($post['from'])?$post['from']:'')
105
+ ->setData('manifest_document_type', '')
106
+ ->setData('manifest_document', '')
107
+ ->setData('label_document_type', '')
108
+ ->setData('type', 'Awaiting Confirmation')
109
+ ->setData('label_document', '')
110
+ ;
111
+
112
+ $carrier_name = $carriers_options[$carrierId];
113
+ if (!isset($result->manifestDocument) || !((string)$result->manifestDocument)) {
114
+ throw new Exception('No data for carrier: ' . $carrier_name);
115
+ }
116
+
117
+ if (isset($result->manifestDocumentType)) {
118
+ $model->setData('manifest_document_type', (string)$result->manifestDocumentType);
119
+ }
120
+ if (isset($result->manifestDocument)) {
121
+ $model->setData('manifest_document', (string)$result->manifestDocument);
122
+ }
123
+ if (isset($result->labelDocumentType)) {
124
+ $model->setData('label_document_type', (string)$result->labelDocumentType);
125
+ }
126
+ if (isset($result->labelDocument)) {
127
+ $model->setData('label_document', (string)$result->labelDocument);
128
+ }
129
+
130
+ $model->save();
131
+ $this->_getSession()
132
+ ->addSuccess($this->__('Manifest successful added for carrier: ') . $carrier_name);
133
+ } catch (Exception $e) {
134
+ $this->_getSession()
135
+ ->addError($e->getMessage());
136
+ }
137
+ }
138
+
139
+ $this->_redirect('*/*/');
140
+ }
141
+
142
+ public function retrieveAction()
143
+ {
144
+ $postData = $this->getRequest()->getPost();
145
+ $post = $this->_filterDates($postData, array('from', 'to'));
146
+ $carriers = $this->getRequest()->getParam('carrier_id');
147
+ if (!is_array($carriers)) {
148
+ $carriers = array($carriers);
149
+ }
150
+
151
+ if (count($carriers) != 1) {
152
+ $this->_getSession()->addError(
153
+ $this->__('Please only select one carrier at a time to retrieve a previous manifest.')
154
+ );
155
+ $this->_redirect('*/*/');
156
+ } else {
157
+ $carriers_options = Mage::getModel('temando/shipping_carrier_temando_source_method')->getOptions();
158
+ $carrierId = $carriers[0];
159
+
160
+ $request = array(
161
+ 'carrierId' => $carrierId,
162
+ 'location' => $this->getRequest()->getParam('warehouse_id'),
163
+ 'readyDate' => isset($post['from'])?$post['from']:'',
164
+ 'type' => 'Confirmed',
165
+ 'labelPrinterType' => Mage::helper('temando')->getConfigData('options/label_type')
166
+ );
167
+ try {
168
+ $api = Mage::getModel('temando/api_client');
169
+ /* @var $api Temando_Temando_Model_Api_Client */
170
+ $api->connect(
171
+ Mage::helper('temando')->getConfigData('general/username'),
172
+ Mage::helper('temando')->getConfigData('general/password'),
173
+ Mage::helper('temando')->getConfigData('general/sandbox')
174
+ );
175
+
176
+ $result = $api->getManifest($request);
177
+ if (!$result) {
178
+ throw new Exception('Cannot send request');
179
+ }
180
+ $carrier_name = $carriers_options[$carrierId];
181
+ if (!isset($result->manifestDocument) || !((string)$result->manifestDocument)) {
182
+ throw new Exception('No data for carrier: ' . $carrier_name);
183
+ }
184
+
185
+ $doc = base64_decode($result->manifestDocument);
186
+ $length = strlen($doc);
187
+ if ($length) {
188
+ $this->getResponse()
189
+ ->setHttpResponseCode(200)
190
+ ->setHeader('Pragma', 'public', true)
191
+ ->setHeader('Cache-Control', 'must-revalidate, post-check=0, pre-check=0', true)
192
+ ->setHeader('Content-type', $result->manifestDocumentType, true)
193
+ ->setHeader('Content-Length', $length)
194
+ ->setHeader(
195
+ 'Content-Disposition',
196
+ 'attachment; filename="manifest-' .
197
+ $carrierId . '-' . $post['from'] . '.pdf"'
198
+ )
199
+ ->setHeader(
200
+ 'Last-Modified',
201
+ date('r')
202
+ );
203
+ $this->getResponse()->clearBody();
204
+ $this->getResponse()->sendHeaders();
205
+ print $doc;
206
+ }
207
+ } catch (Exception $e) {
208
+ $this->_getSession()
209
+ ->addError($e->getMessage());
210
+ $this->_redirect('*/*/');
211
+ }
212
+ }
213
+ }
214
+
215
+ public function manifestAction()
216
+ {
217
+ $manifest = Mage::getModel('temando/manifest')
218
+ ->load($this->getRequest()->getParam('id'));
219
+ /* @var $manifest Temando_Temando_Model_Manifest */
220
+ if ($manifest->getId()) {
221
+ $document = base64_decode($manifest->getManifestDocument());
222
+ $document_length = strlen($document);
223
+ $extension = '.pdf';
224
+ $_t = explode('/', $manifest->getManifestDocumentType());
225
+ if (isset($_t[1])) {
226
+ $extension = "." . $_t[1];
227
+ }
228
+
229
+ if ($document_length) {
230
+ $this->getResponse()
231
+ ->setHttpResponseCode(200)
232
+ ->setHeader('Pragma', 'public', true)
233
+ ->setHeader('Cache-Control', 'must-revalidate, post-check=0, pre-check=0', true)
234
+ ->setHeader(
235
+ 'Content-type',
236
+ $manifest->getManifestDocumentType(),
237
+ true
238
+ )
239
+ ->setHeader('Content-Length', $document_length)
240
+ ->setHeader(
241
+ 'Content-Disposition',
242
+ 'attachment; filename="manifest-'.$manifest->getId().$extension.'"'
243
+ )
244
+ ->setHeader('Last-Modified', date('r'));
245
+ $this->getResponse()->clearBody();
246
+ $this->getResponse()->sendHeaders();
247
+ print $document;
248
+ }
249
+ }
250
+ }
251
+
252
+ public function labelAction()
253
+ {
254
+ $manifest = Mage::getModel('temando/manifest')
255
+ ->load($this->getRequest()->getParam('id'));
256
+ /* @var $manifest Temando_Temando_Model_Manifest */
257
+ if ($manifest->getId()) {
258
+ $document = base64_decode($manifest->getLabelDocument());
259
+ $document_length = strlen($document);
260
+ $extension = '.pdf';
261
+ $_t = explode('/', $manifest->getLabelDocumentType());
262
+ if (isset($_t[1])) {
263
+ $extension = "." . $_t[1];
264
+ }
265
+
266
+ if ($document_length) {
267
+ $this->getResponse()
268
+ ->setHttpResponseCode(200)
269
+ ->setHeader('Pragma', 'public', true)
270
+ ->setHeader('Cache-Control', 'must-revalidate, post-check=0, pre-check=0', true)
271
+ ->setHeader('Content-type', $manifest->getLabelDocumentType(), true)
272
+ ->setHeader('Content-Length', $document_length)
273
+ ->setHeader('Content-Disposition', 'attachment; filename="label-'.$manifest->getId().$extension.'"')
274
+ ->setHeader('Last-Modified', date('r'));
275
+ $this->getResponse()->clearBody();
276
+ $this->getResponse()->sendHeaders();
277
+ print $document;
278
+ }
279
+ }
280
+ }
281
+
282
+ public function confirmAction()
283
+ {
284
+ $manifests = Mage::getModel('temando/manifest')
285
+ ->getCollection()->addFieldToFilter('type', 'Awaiting Confirmation')->getItems();
286
+ $carriers_options = Mage::getModel('temando/shipping_carrier_temando_source_method')->getOptions();
287
+ foreach ($manifests as $manifest) {
288
+ $request = array(
289
+ 'carrierId' => $manifest->getCarrierId(),
290
+ 'location' => $manifest->getLocationId(),
291
+ 'startReadyDate' => $manifest->getStartDate(),
292
+ 'endReadyDate' => $manifest->getStartDate(),
293
+ /* @todo use store date, not server date */
294
+ 'confirmedReadyDate' => now(true),
295
+ 'labelPrinterType' => Mage::helper('temando')->getConfigData('options/label_type')
296
+ );
297
+
298
+ try {
299
+ $api = Mage::getModel('temando/api_client');
300
+ $api->connect(
301
+ Mage::helper('temando')->getConfigData('general/username'),
302
+ Mage::helper('temando')->getConfigData('general/password'),
303
+ Mage::helper('temando')->getConfigData('general/sandbox'),
304
+ true
305
+ );
306
+ $result = $api->confirmManifest($request);
307
+ if (!$result) {
308
+ throw new Exception('Cannot send request');
309
+ }
310
+
311
+ $carrier_name = $carriers_options[$manifest->getCarrierId()];
312
+ if (!isset($result->manifestDocument) || !((string)$result->manifestDocument)) {
313
+ throw new Exception(
314
+ 'No data for carrier: ' .
315
+ $carrier_name . 'and date ' .
316
+ $manifest->getStartDate()
317
+ );
318
+ }
319
+
320
+ if (isset($result->manifestDocumentType)) {
321
+ $manifest->setData('manifest_document_type', (string)$result->manifestDocumentType);
322
+ }
323
+ if (isset($result->manifestDocument)) {
324
+ $manifest->setData('manifest_document', (string)$result->manifestDocument);
325
+ }
326
+ if (isset($result->labelDocumentType)) {
327
+ $manifest->setData('label_document_type', (string)$result->labelDocumentType);
328
+ }
329
+ if (isset($result->labelDocument)) {
330
+ $manifest->setData('label_document', (string)$result->labelDocument);
331
+ }
332
+
333
+ $manifest->setData('type', 'Confirmed');
334
+ $manifest->save();
335
+ $this->_getSession()
336
+ ->addSuccess(
337
+ $this->__(
338
+ 'Manifest successful confirmed for carrier: ' .
339
+ $carrier_name . ' and date ' . $manifest->getStartDate()
340
+ )
341
+ );
342
+ } catch (Exception $e) {
343
+ $this->_getSession()
344
+ ->addError($e->getMessage());
345
+ }
346
+ }
347
+
348
+ $this->_redirect('*/*/');
349
+ }
350
+ }
app/code/community/Temando/Temando/controllers/Adminhtml/ShipmentController.php CHANGED
@@ -1,548 +1,569 @@
1
- <?php
2
- /**
3
- * Shipment Controller
4
- *
5
- * @package Temando_Temando
6
- * @author Temando Magento Team <marketing@temando.com>
7
- */
8
- class Temando_Temando_Adminhtml_ShipmentController extends Mage_Adminhtml_Controller_Action
9
- {
10
-
11
- /**
12
- * Check admin permissions for this controller
13
- * Add a comment to this line
14
- *
15
- * @return boolean
16
- */
17
- protected function _isAllowed()
18
- {
19
- return Mage::getSingleton('admin/session')
20
- ->isAllowed('temando/shipment');
21
- }
22
-
23
- public function indexAction()
24
- {
25
- $this->loadLayout()
26
- ->_setActiveMenu('temando/shipment')
27
- ->_addBreadcrumb(Mage::helper('adminhtml')->__('Shipment Manager'), Mage::helper('adminhtml')->__('Shipment Manager'))
28
- ->renderLayout();
29
- }
30
-
31
- public function editAction()
32
- {
33
- $id = $this->getRequest()->getParam('id');
34
- $shipment = Mage::getModel('temando/shipment')->load($id);
35
- /* @var $shipment Temando_Temando_Model_Shipment */
36
-
37
- if ($shipment->getId()) {
38
- $notices = array();
39
-
40
- if (!count($shipment->getBoxes())) {
41
- $notices[] = Mage::helper('temando')->__('Quotes cannot be refreshed until at least one box is added to the shipment.');
42
- }
43
-
44
- foreach ($notices as $notice) {
45
- $this->_getSession()->addNotice($this->__($notice));
46
- }
47
-
48
- $data = Mage::getSingleton('adminhtml/session')->getFormData(true);
49
- if (!empty($data)) {
50
- $shipment->addData($data);
51
- }
52
-
53
- Mage::register('temando_shipment_data', $shipment);
54
-
55
- $this->loadLayout()
56
- ->_setActiveMenu('temando/shipment');
57
-
58
- $this->getLayout()->getBlock('head')->setCanLoadExtJs(true);
59
-
60
- $this->renderLayout();
61
- } else {
62
- Mage::getSingleton('adminhtml/session')->addError($this->__('Shipment does not exist.'));
63
- $this->_redirect('*/*/');
64
- }
65
- }
66
-
67
- public function saveAction()
68
- {
69
- if ($data = $this->getRequest()->getPost()) {
70
- $shipment = Mage::getModel('temando/shipment');
71
- /* @var $shipment Temando_Temando_Model_Shipment */
72
-
73
- $result = $this->_validateFormData($data);
74
- if (isset($data['insurance'])) {
75
- Mage::getSingleton('adminhtml/session')->setData('insurance_' . $this->getRequest()->getParam('id'), $data['insurance']);
76
- } else {
77
- Mage::getSingleton('adminhtml/session')->unsetData('insurance_' . $this->getRequest()->getParam('id'));
78
- }
79
-
80
- foreach ($result['notices'] as $notice) {
81
- $this->_getSession()->addNotice($notice);
82
- }
83
-
84
- if ($result['errors']) {
85
- $this->_getSession()
86
- ->addError(Mage::helper('temando')->__('Validation errors:'))
87
- ->setFormData($data);
88
- foreach ($result['errors'] as $error) {
89
- $this->_getSession()->addError($error);
90
- }
91
- $this->_redirect('*/*/edit', array('id' => $this->getRequest()->getParam('id')));
92
- return;
93
- }
94
-
95
- try {
96
- if (!$data['ready']) {
97
- $data['ready_date'] = null;
98
- }
99
- $shipment->setId($this->getRequest()->getParam('id'))
100
- ->addData($data);
101
-
102
- if ($data['boxes_deleted']) {
103
- $box_ids = explode(',', $data['boxes_deleted']);
104
- foreach ($box_ids as $box_id) {
105
- $box = Mage::getModel('temando/box');
106
- /* @var $box Temando_Temando_Model_Box */
107
- $box->load($box_id);
108
- if ($box->getId()) {
109
- $box->delete();
110
- }
111
- }
112
- }
113
-
114
- if (isset($data['box']) && is_array($data['box'])) {
115
- foreach ($data['box'] as $box_data) {
116
- if (preg_match('/^custom_(\d+)/', $box_data['packaging'], $matches)) {
117
- $customBox = Mage::getModel('temando/package')->load($matches[1]);
118
- $box_data['packaging'] = $customBox->getPackaging();
119
- }
120
- $box = Mage::getModel('temando/box');
121
- /* @var $box Temando_Temando_Model_Box */
122
- if (isset($box_data['id'])) {
123
- $box->load($box_data['id']);
124
- }
125
-
126
- $box->setShipmentId($shipment->getId())
127
- ->addData($box_data)
128
- ->save();
129
- }
130
- }
131
-
132
- $shipment->clearQuotes()->save();
133
- $shipment = Mage::getModel('temando/shipment')->load($shipment->getId());
134
-
135
- if ($shipment->getBoxes()) {
136
- $shipment->fetchQuotes(
137
- Mage::helper('temando')->getConfigData('general/username'),
138
- Mage::helper('temando')->getConfigData('general/password'),
139
- Mage::helper('temando')->getConfigData('general/sandbox')
140
- );
141
- }
142
-
143
- $this->_getSession()->addSuccess($this->__('The shipment data has been saved.'));
144
-
145
- switch ($this->getRequest()->getParam('and')) {
146
- case 'getquotes':
147
- $this->_redirect('*/*/edit', array('id' => $shipment->getId()));
148
- break;
149
- case 'next':
150
- // TODO: save and next
151
- default:
152
- $this->_redirect('*/*/');
153
- break;
154
- }
155
- } catch (Exception $ex) {
156
- $this->_getSession()->addError($ex->getMessage())->setFormData($data);
157
- $this->_redirect('*/*/edit', array('id' => $this->getRequest()->getParam('id')));
158
- }
159
- return;
160
- }
161
-
162
- // nothing to save
163
- $this->_redirect('*/*/');
164
- }
165
-
166
- protected function _validateFormData(&$data)
167
- {
168
- $return = array(
169
- 'notices' => array(),
170
- 'errors' => array(),
171
- );
172
- if ($data['ready_date']) {
173
- $timestamp = strtotime($data['ready_date']);
174
- if ($timestamp) {
175
- $data['ready_date'] = date('Y-m-d', $timestamp);
176
- } else {
177
- $return['errors'][] = Mage::helper('temando')->__('Pick-up date is not a valid date.');
178
- }
179
- }
180
- if (strtotime($data['ready_date'] . ' + 1 day') < date('U')) {
181
- $return['notices'][] = Mage::helper('temando')->__('Pick-up date is in the past.');
182
- unset($data['ready_date']);
183
- }
184
- if (!in_array($data['ready_time'], array('AM', 'PM', ''))) {
185
- $return['errors'][] = Mage::helper('temando')->__('Pick-up time is not a valid selection.');
186
- }
187
-
188
- return $return;
189
- }
190
-
191
- public function bookAction()
192
- {
193
- $shipment_id = $this->getRequest()->getParam('shipment');
194
- $shipment = Mage::getModel('temando/shipment')
195
- ->load($shipment_id);
196
- /* @var $shipment Temando_Temando_Model_Shipment */
197
-
198
- $quote_id = $this->getRequest()->getParam('quote');
199
- $quote = Mage::getModel('temando/quote')
200
- ->load($quote_id);
201
- /* @var $quote Temando_Temando_Model_Quote */
202
-
203
- $error = null;
204
-
205
- if (!$shipment->getId()) {
206
- $error = Mage::helper('temando')->__('Shipment does not exist.');
207
- } else {
208
- if (!$quote->getId()) {
209
- $error = Mage::helper('temando')->__('Selected quote does not exist.');
210
- } else {
211
- foreach ($shipment->getOptions() as $o) {
212
- if (("insurance" == $o->getId()) && ('Y' == $o->getForcedValue())) {
213
- if ('Y' != Mage::helper('temando')->getConfigData('insurance/confirm_' . Mage::helper('temando')->getConfigData('insurance/status'))) {
214
- $error = Mage::helper('temando')->__('Please agree to the insurance terms & conditions at System -> Configuration -> Temando Settings -> Insurance.');
215
- }
216
- }
217
- }
218
-
219
- if (!$error) {
220
- // try to make booking
221
- try {
222
- $booking_result = $this->_makeBooking($shipment, $quote);
223
- } catch (Exception $ex) {
224
- $error = $ex->getMessage();
225
- }
226
- }
227
- }
228
- }
229
-
230
- if (!$error && $booking_result) {
231
-
232
- if (!isset($booking_result->bookingNumber)) {
233
- $booking_result->bookingNumber = null;
234
- }
235
- if (!isset($booking_result->consignmentNumber)) {
236
- $booking_result->consignmentNumber = null;
237
- }
238
- if (!isset($booking_result->consignmentDocument)) {
239
- $booking_result->consignmentDocument = null;
240
- }
241
- if (!isset($booking_result->consignmentDocumentType)) {
242
- $booking_result->consignmentDocumentType = null;
243
- }
244
- if (!isset($booking_result->requestId)) {
245
- $booking_result->requestId = null;
246
- }
247
- if (!isset($booking_result->labelDocument)) {
248
- $booking_result->labelDocument = null;
249
- }
250
- if (!isset($booking_result->labelDocumentType)) {
251
- $booking_result->labelDocumentType = '';
252
- }
253
- if (isset($booking_result->anytime)) {
254
- $shipment->setReadyDate((string) $booking_result->anytime->readyDate);
255
- $shipment->setReadyTime((string) $booking_result->anytime->readyTime);
256
- }
257
-
258
- $shipment
259
- ->setAdminSelectedQuoteId($quote_id)
260
- ->setBookingRequestId($booking_result->requestId)
261
- ->setBookingNumber($booking_result->bookingNumber)
262
- ->setConsignmentNumber($booking_result->consignmentNumber)
263
- ->setConsignmentDocument($booking_result->consignmentDocument)
264
- ->setConsignmentDocumentType($booking_result->consignmentDocumentType)
265
- ->setLabelDocument($booking_result->labelDocument)
266
- ->setLabelDocumentType($booking_result->labelDocumentType)
267
- ->setStatus(Temando_Temando_Model_System_Config_Source_Shipment_Status::BOOKED)
268
- ->setAnticipatedCost($shipment->getSelectedQuotePermutation()->getTotalPrice())
269
- ->save();
270
-
271
- $magento_shipment = Mage::getModel('sales/convert_order')
272
- ->toShipment($shipment->getOrder());
273
- /* @var $magento_shipment Mage_Sales_Model_Order_Shipment */
274
-
275
- $totalQty = 0;
276
- foreach ($shipment->getOrder()->getAllItems() as $item) {
277
- if ($item->getQtyToShip() && !$item->getIsVirtual()) {
278
- $magento_shipment_item = Mage::getModel('sales/convert_order')
279
- ->itemToShipmentItem($item);
280
-
281
- $qty = $item->getQtyToShip();
282
-
283
- $magento_shipment_item->setQty($qty);
284
- $magento_shipment->addItem($magento_shipment_item);
285
-
286
- $totalQty += $qty;
287
- }
288
- }
289
-
290
- $magento_shipment->setTotalQty($totalQty);
291
-
292
- $track = Mage::getModel('sales/order_shipment_track');
293
- /* @var Mage_Sales_Model_Order_Shipment_Track */
294
- $number = '';
295
- if ($booking_result->consignmentNumber) {
296
- $number .= Mage::helper('temando')->__('Consignment Number: ') . $booking_result->consignmentNumber;
297
- }
298
-
299
- if ($booking_result->requestId) {
300
- if ($number) {
301
- $number .= "\n<br />";
302
- }
303
-
304
- $number .= Mage::helper('temando')->__('Request Id: ') . $booking_result->requestId;
305
- }
306
-
307
- $track
308
- ->setCarrierCode(Mage::getModel('temando/shipping_carrier_temando')->getCarrierCode())
309
- ->setTitle($quote->getCarrier()->getCompanyName())
310
- ->setNumber($number);
311
-
312
- $magento_shipment->addTrack($track)->register();
313
-
314
- try {
315
- $magento_shipment->getOrder()->setIsInProcess(true)->setCustomerNoteNotify(true);
316
- Mage::getModel('core/resource_transaction')
317
- ->addObject($shipment)
318
- ->addObject($magento_shipment)
319
- ->addObject($magento_shipment->getOrder())
320
- ->save();
321
- $magento_shipment->sendEmail()->setEmailSent(true)->save();
322
- } catch (Mage_Core_Exception $e) {
323
- $error = $e->getMessage();
324
- }
325
-
326
- $this->_getSession()->addSuccess($this->__('Shipment booked.'));
327
- }
328
-
329
- if ($error) {
330
- $this->_getSession()
331
- ->addError($this->__($error))
332
- /* ->setFormData($data) */;
333
- }
334
- $this->_redirect('*/*/edit', array('id' => $shipment_id));
335
- }
336
-
337
- protected function _makeBooking(Temando_Temando_Model_Shipment $shipment, Temando_Temando_Model_Quote $quote)
338
- {
339
- $order = $shipment->getOrder();
340
- /* @var $order Mage_Sales_Model_Order */
341
-
342
- $request = Mage::getModel('temando/api_request');
343
- /* @var $request Temando_Temando_Model_Api_Request */
344
- $request
345
- ->setMagentoQuoteId($order->getQuoteId())
346
- ->setDestination(
347
- $shipment->getDestinationCountry(),
348
- $shipment->getDestinationPostcode(),
349
- $shipment->getDestinationCity(),
350
- $shipment->getDestinationStreet(),
351
- $shipment->getDestinationType())
352
- ->setDeliveryOptions($shipment->getDeliveryOptionsArray())
353
- ->setItems($shipment->getBoxes()->getItems());
354
- if ($shipment->getReadyDate()) {
355
- $request->setReady(strtotime($shipment->getReadyDate()), $shipment->getReadyTime());
356
- } else {
357
- $request->setReady(null);
358
- }
359
-
360
- $request_array = $request->toRequestArray();
361
- $request_array['origin'] = array(
362
- 'description' => Temando_Temando_Helper_Data::DEFAULT_WAREHOUSE_NAME
363
- );
364
-
365
- $request_array['destination'] = array(
366
- 'contactName' => $shipment->getDestinationContactName(),
367
- 'companyName' => $shipment->getDestinationCompanyName(),
368
- 'street' => $shipment->getDestinationStreet(),
369
- 'suburb' => $shipment->getDestinationCity(),
370
- 'code' => $shipment->getDestinationPostcode(),
371
- 'country' => $shipment->getDestinationCountry(),
372
- 'phone1' => $shipment->getDestinationPhone(),
373
- 'phone2' => '',
374
- 'fax' => '',
375
- 'email' => $shipment->getDestinationEmail(),
376
- );
377
-
378
- $option_array = $shipment->getOptionsArray();
379
- if (!is_null(Mage::getSingleton('adminhtml/session')->getData('insurance_' . $shipment->getId()))) {
380
- $option_array['insurance'] = Mage::getSingleton('adminhtml/session')->getData('insurance_' . $shipment->getId());
381
- }
382
-
383
- $request_array['quote'] = $quote->toBookingRequestArray($option_array);
384
-
385
- $request_array['payment'] = array(
386
- 'paymentType' => Mage::helper('temando')->getConfigData('general/payment_type'),
387
- );
388
-
389
- if (Mage::helper('temando')->getConfigData('options/label_type')) {
390
- $request_array['labelPrinterType'] = Mage::helper('temando')->getConfigData('options/label_type');
391
- }
392
-
393
- $request_array['reference'] = $order->getIncrementId();
394
-
395
- $api = Mage::getModel('temando/api_client');
396
- /* @var $api Temando_Temando_Model_Api_Client */
397
- $api->connect(
398
- Mage::helper('temando')->getConfigData('general/username'),
399
- Mage::helper('temando')->getConfigData('general/password'),
400
- Mage::helper('temando')->getConfigData('general/sandbox')
401
- );
402
- return $api->makeBooking($request_array);
403
- }
404
-
405
- protected function _processBookingResult($booking_result, Temando_Temando_Model_Shipment $shipment, Temando_Temando_Model_Quote $quote)
406
- {
407
- if ($booking_result) {
408
-
409
- if (!isset($booking_result->bookingNumber)) {
410
- $booking_result->bookingNumber = null;
411
- }
412
- if (!isset($booking_result->consignmentNumber)) {
413
- $booking_result->consignmentNumber = null;
414
- }
415
- if (!isset($booking_result->consignmentDocument)) {
416
- $booking_result->consignmentDocument = null;
417
- }
418
- if (!isset($booking_result->consignmentDocumentType)) {
419
- $booking_result->consignmentDocumentType = null;
420
- }
421
- if (!isset($booking_result->requestId)) {
422
- $booking_result->requestId = null;
423
- }
424
- if (!isset($booking_result->labelDocument)) {
425
- $booking_result->labelDocument = null;
426
- }
427
- if (!isset($booking_result->labelDocumentType)) {
428
- $booking_result->labelDocumentType = '';
429
- }
430
- if (isset($booking_result->anytime)) {
431
- $shipment->setReadyDate((string) $booking_result->anytime->readyDate);
432
- $shipment->setReadyTime((string) $booking_result->anytime->readyTime);
433
- }
434
-
435
- $shipment
436
- ->setBookingRequestId($booking_result->requestId)
437
- ->setBookingNumber($booking_result->bookingNumber)
438
- ->setConsignmentNumber($booking_result->consignmentNumber)
439
- ->setConsignmentDocument($booking_result->consignmentDocument)
440
- ->setConsignmentDocumentType($booking_result->consignmentDocumentType)
441
- ->setLabelDocument($booking_result->labelDocument)
442
- ->setLabelDocumentType($booking_result->labelDocumentType)
443
- ->setStatus(Temando_Temando_Model_System_Config_Source_Shipment_Status::BOOKED)
444
- ->setAnticipatedCost($shipment->getSelectedQuotePermutation()->getTotalPrice())
445
- ->save();
446
-
447
- $magento_shipment = Mage::getModel('sales/convert_order')
448
- ->toShipment($shipment->getOrder());
449
- /* @var $magento_shipment Mage_Sales_Model_Order_Shipment */
450
-
451
- $totalQty = 0;
452
- foreach ($shipment->getOrder()->getAllItems() as $item) {
453
- if ($item->getQtyToShip() && !$item->getIsVirtual()) {
454
- $magento_shipment_item = Mage::getModel('sales/convert_order')
455
- ->itemToShipmentItem($item);
456
-
457
- $qty = $item->getQtyToShip();
458
-
459
- $magento_shipment_item->setQty($qty);
460
- $magento_shipment->addItem($magento_shipment_item);
461
-
462
- $totalQty += $qty;
463
- }
464
- }
465
-
466
- $magento_shipment->setTotalQty($totalQty);
467
-
468
- $track = Mage::getModel('sales/order_shipment_track');
469
- /* @var Mage_Sales_Model_Order_Shipment_Track */
470
- $number = '';
471
- if ($booking_result->consignmentNumber) {
472
- $number .= Mage::helper('temando')->__('Consignment Number: ') . $booking_result->consignmentNumber;
473
- }
474
-
475
- if ($booking_result->requestId) {
476
- if ($number) {
477
- $number .= "\n<br />";
478
- }
479
-
480
- $number .= Mage::helper('temando')->__('Request Id: ') . $booking_result->requestId;
481
- }
482
-
483
- $track
484
- ->setCarrierCode(Mage::getModel('temando/shipping_carrier_temando')->getCarrierCode())
485
- ->setTitle($quote->getCarrier()->getCompanyName())
486
- ->setNumber($number);
487
-
488
- $magento_shipment
489
- ->addTrack($track)
490
- ->register();
491
-
492
- try {
493
- $magento_shipment->getOrder()->setIsInProcess(true)->setCustomerNoteNotify(true);
494
- Mage::getModel('core/resource_transaction')
495
- ->addObject($shipment)
496
- ->addObject($magento_shipment)
497
- ->addObject($magento_shipment->getOrder())
498
- ->save();
499
- $magento_shipment->sendEmail();
500
- } catch (Mage_Core_Exception $e) {
501
- $error = $e->getMessage();
502
- }
503
- }
504
-
505
- return;
506
- }
507
-
508
- /**
509
- * Serve shipping labels
510
- */
511
- public function consignmentAction()
512
- {
513
- $shipment = Mage::getModel('temando/shipment')->load($this->getRequest()->getParam('id'));
514
- /* @var $shipment Temando_Temando_Model_Shipment */
515
-
516
- if ($shipment->getId()) {
517
- $document = '';
518
-
519
- $labelType = Mage::helper('temando')->getConfigData('options/label_type');
520
- switch ($labelType) {
521
- case Temando_Temando_Model_System_Config_Source_Labeltype::STANDARD:
522
- if ($shipment->getConsignmentDocument())
523
- $document = base64_decode($shipment->getConsignmentDocument());
524
- break;
525
- case Temando_Temando_Model_System_Config_Source_Labeltype::THERMAL:
526
- if ($shipment->getLabelDocument())
527
- $document = base64_decode($shipment->getLabelDocument());
528
- break;
529
- }
530
-
531
- $document_length = strlen($document);
532
-
533
- if ($document_length) {
534
- $this->getResponse()
535
- ->setHttpResponseCode(200)
536
- ->setHeader('Pragma', 'public', true)
537
- ->setHeader('Cache-Control', 'must-revalidate, post-check=0, pre-check=0', true)
538
- ->setHeader('Content-type', $shipment->getConsignmentDocumentType(), true)
539
- ->setHeader('Content-Length', $document_length, true)
540
- ->setHeader('Content-Disposition', 'attachment; filename="order-' . $shipment->getOrderNumber() . '.pdf"', true)
541
- ->setHeader('Last-Modified', date('r'), true);
542
- $this->getResponse()->clearBody();
543
- $this->getResponse()->sendHeaders();
544
- print $document;
545
- }
546
- }
547
- }
548
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Shipment Controller
4
+ *
5
+ * @package Temando_Temando
6
+ * @author Temando Magento Team <marketing@temando.com>
7
+ */
8
+ class Temando_Temando_Adminhtml_ShipmentController extends Mage_Adminhtml_Controller_Action
9
+ {
10
+
11
+ /**
12
+ * Check admin permissions for this controller
13
+ * Add a comment to this line
14
+ *
15
+ * @return boolean
16
+ */
17
+ protected function _isAllowed()
18
+ {
19
+ return Mage::getSingleton('admin/session')
20
+ ->isAllowed('temando/shipment');
21
+ }
22
+
23
+ public function indexAction()
24
+ {
25
+ $this->loadLayout()
26
+ ->_setActiveMenu('temando/shipment')
27
+ ->_addBreadcrumb(
28
+ Mage::helper('adminhtml')->__('Shipment Manager'),
29
+ Mage::helper('adminhtml')->__('Shipment Manager')
30
+ )
31
+ ->renderLayout();
32
+ }
33
+
34
+ public function editAction()
35
+ {
36
+ $id = $this->getRequest()->getParam('id');
37
+ $shipment = Mage::getModel('temando/shipment')->load($id);
38
+ /* @var $shipment Temando_Temando_Model_Shipment */
39
+
40
+ if ($shipment->getId()) {
41
+ $notices = array();
42
+
43
+ if (!count($shipment->getBoxes())) {
44
+ $notices[] = Mage::helper('temando')
45
+ ->__('Quotes cannot be refreshed until at least one box is added to the shipment.');
46
+ }
47
+
48
+ foreach ($notices as $notice) {
49
+ $this->_getSession()->addNotice($this->__($notice));
50
+ }
51
+
52
+ $data = Mage::getSingleton('adminhtml/session')->getFormData(true);
53
+ if (!empty($data)) {
54
+ $shipment->addData($data);
55
+ }
56
+
57
+ Mage::register('temando_shipment_data', $shipment);
58
+
59
+ $this->loadLayout()
60
+ ->_setActiveMenu('temando/shipment');
61
+
62
+ $this->getLayout()->getBlock('head')->setCanLoadExtJs(true);
63
+
64
+ $this->renderLayout();
65
+ } else {
66
+ Mage::getSingleton('adminhtml/session')->addError($this->__('Shipment does not exist.'));
67
+ $this->_redirect('*/*/');
68
+ }
69
+ }
70
+
71
+ public function saveAction()
72
+ {
73
+ if ($data = $this->getRequest()->getPost()) {
74
+ $shipment = Mage::getModel('temando/shipment');
75
+ /* @var $shipment Temando_Temando_Model_Shipment */
76
+
77
+ $result = $this->_validateFormData($data);
78
+ if (isset($data['insurance'])) {
79
+ Mage::getSingleton('adminhtml/session')->setData(
80
+ 'insurance_' . $this->getRequest()->getParam('id'),
81
+ $data['insurance']
82
+ );
83
+ } else {
84
+ Mage::getSingleton('adminhtml/session')->unsetData('insurance_' . $this->getRequest()->getParam('id'));
85
+ }
86
+
87
+ foreach ($result['notices'] as $notice) {
88
+ $this->_getSession()->addNotice($notice);
89
+ }
90
+
91
+ if ($result['errors']) {
92
+ $this->_getSession()
93
+ ->addError(Mage::helper('temando')->__('Validation errors:'))
94
+ ->setFormData($data);
95
+ foreach ($result['errors'] as $error) {
96
+ $this->_getSession()->addError($error);
97
+ }
98
+ $this->_redirect('*/*/edit', array('id' => $this->getRequest()->getParam('id')));
99
+ return;
100
+ }
101
+
102
+ try {
103
+ if (!$data['ready']) {
104
+ $data['ready_date'] = null;
105
+ }
106
+ $shipment->setId($this->getRequest()->getParam('id'))
107
+ ->addData($data);
108
+
109
+ if ($data['boxes_deleted']) {
110
+ $box_ids = explode(',', $data['boxes_deleted']);
111
+ foreach ($box_ids as $box_id) {
112
+ $box = Mage::getModel('temando/box');
113
+ /* @var $box Temando_Temando_Model_Box */
114
+ $box->load($box_id);
115
+ if ($box->getId()) {
116
+ $box->delete();
117
+ }
118
+ }
119
+ }
120
+
121
+ if (isset($data['box']) && is_array($data['box'])) {
122
+ foreach ($data['box'] as $box_data) {
123
+ if (preg_match('/^custom_(\d+)/', $box_data['packaging'], $matches)) {
124
+ $customBox = Mage::getModel('temando/package')->load($matches[1]);
125
+ $box_data['packaging'] = $customBox->getPackaging();
126
+ }
127
+ $box = Mage::getModel('temando/box');
128
+ /* @var $box Temando_Temando_Model_Box */
129
+ if (isset($box_data['id'])) {
130
+ $box->load($box_data['id']);
131
+ }
132
+
133
+ $box->setShipmentId($shipment->getId())
134
+ ->addData($box_data)
135
+ ->save();
136
+ }
137
+ }
138
+
139
+ $shipment->clearQuotes()->save();
140
+ $shipment = Mage::getModel('temando/shipment')->load($shipment->getId());
141
+
142
+ if ($shipment->getBoxes()) {
143
+ $shipment->fetchQuotes(
144
+ Mage::helper('temando')->getConfigData('general/username'),
145
+ Mage::helper('temando')->getConfigData('general/password'),
146
+ Mage::helper('temando')->getConfigData('general/sandbox')
147
+ );
148
+ }
149
+
150
+ $this->_getSession()->addSuccess($this->__('The shipment data has been saved.'));
151
+
152
+ switch ($this->getRequest()->getParam('and')) {
153
+ case 'getquotes':
154
+ $this->_redirect('*/*/edit', array('id' => $shipment->getId()));
155
+ break;
156
+ case 'next':
157
+ // TODO: save and next
158
+ default:
159
+ $this->_redirect('*/*/');
160
+ break;
161
+ }
162
+ } catch (Exception $ex) {
163
+ $this->_getSession()->addError($ex->getMessage())->setFormData($data);
164
+ $this->_redirect('*/*/edit', array('id' => $this->getRequest()->getParam('id')));
165
+ }
166
+ return;
167
+ }
168
+
169
+ // nothing to save
170
+ $this->_redirect('*/*/');
171
+ }
172
+
173
+ protected function _validateFormData(&$data)
174
+ {
175
+ $return = array(
176
+ 'notices' => array(),
177
+ 'errors' => array(),
178
+ );
179
+ if ($data['ready_date']) {
180
+ $timestamp = strtotime($data['ready_date']);
181
+ if ($timestamp) {
182
+ $data['ready_date'] = date('Y-m-d', $timestamp);
183
+ } else {
184
+ $return['errors'][] = Mage::helper('temando')->__('Pick-up date is not a valid date.');
185
+ }
186
+ }
187
+ if (strtotime($data['ready_date'] . ' + 1 day') < date('U')) {
188
+ $return['notices'][] = Mage::helper('temando')->__('Pick-up date is in the past.');
189
+ unset($data['ready_date']);
190
+ }
191
+ if (!in_array($data['ready_time'], array('AM', 'PM', ''))) {
192
+ $return['errors'][] = Mage::helper('temando')->__('Pick-up time is not a valid selection.');
193
+ }
194
+
195
+ return $return;
196
+ }
197
+
198
+ public function bookAction()
199
+ {
200
+ $shipment_id = $this->getRequest()->getParam('shipment');
201
+ $shipment = Mage::getModel('temando/shipment')
202
+ ->load($shipment_id);
203
+ /* @var $shipment Temando_Temando_Model_Shipment */
204
+
205
+ $quote_id = $this->getRequest()->getParam('quote');
206
+ $quote = Mage::getModel('temando/quote')
207
+ ->load($quote_id);
208
+ /* @var $quote Temando_Temando_Model_Quote */
209
+
210
+ $error = null;
211
+
212
+ if (!$shipment->getId()) {
213
+ $error = Mage::helper('temando')->__('Shipment does not exist.');
214
+ } else {
215
+ if (!$quote->getId()) {
216
+ $error = Mage::helper('temando')->__('Selected quote does not exist.');
217
+ } else {
218
+ foreach ($shipment->getOptions() as $o) {
219
+ if (("insurance" == $o->getId()) && ('Y' == $o->getForcedValue())) {
220
+ if (
221
+ 'Y' != Mage::helper('temando')->getConfigData(
222
+ 'insurance/confirm_' . Mage::helper('temando')->getConfigData('insurance/status')
223
+ )) {
224
+ $error = Mage::helper('temando')->__('Please agree to the insurance
225
+ terms & conditions at System -> Configuration -> Temando Settings -> Insurance.');
226
+ }
227
+ }
228
+ }
229
+
230
+ if (!$error) {
231
+ // try to make booking
232
+ try {
233
+ $booking_result = $this->_makeBooking($shipment, $quote);
234
+ } catch (Exception $ex) {
235
+ $error = $ex->getMessage();
236
+ }
237
+ }
238
+ }
239
+ }
240
+
241
+ if (!$error && $booking_result) {
242
+
243
+ if (!isset($booking_result->bookingNumber)) {
244
+ $booking_result->bookingNumber = null;
245
+ }
246
+ if (!isset($booking_result->consignmentNumber)) {
247
+ $booking_result->consignmentNumber = null;
248
+ }
249
+ if (!isset($booking_result->consignmentDocument)) {
250
+ $booking_result->consignmentDocument = null;
251
+ }
252
+ if (!isset($booking_result->consignmentDocumentType)) {
253
+ $booking_result->consignmentDocumentType = null;
254
+ }
255
+ if (!isset($booking_result->requestId)) {
256
+ $booking_result->requestId = null;
257
+ }
258
+ if (!isset($booking_result->labelDocument)) {
259
+ $booking_result->labelDocument = null;
260
+ }
261
+ if (!isset($booking_result->labelDocumentType)) {
262
+ $booking_result->labelDocumentType = '';
263
+ }
264
+ if (isset($booking_result->anytime)) {
265
+ $shipment->setReadyDate((string) $booking_result->anytime->readyDate);
266
+ $shipment->setReadyTime((string) $booking_result->anytime->readyTime);
267
+ }
268
+
269
+ $shipment
270
+ ->setAdminSelectedQuoteId($quote_id)
271
+ ->setBookingRequestId($booking_result->requestId)
272
+ ->setBookingNumber($booking_result->bookingNumber)
273
+ ->setConsignmentNumber($booking_result->consignmentNumber)
274
+ ->setConsignmentDocument($booking_result->consignmentDocument)
275
+ ->setConsignmentDocumentType($booking_result->consignmentDocumentType)
276
+ ->setLabelDocument($booking_result->labelDocument)
277
+ ->setLabelDocumentType($booking_result->labelDocumentType)
278
+ ->setStatus(Temando_Temando_Model_System_Config_Source_Shipment_Status::BOOKED)
279
+ ->setAnticipatedCost($shipment->getSelectedQuotePermutation()->getTotalPrice())
280
+ ->setAnticipatedCurrency($shipment->getSelectedQuotePermutation()->getCurrency())
281
+ ->save();
282
+
283
+ $magento_shipment = Mage::getModel('sales/convert_order')
284
+ ->toShipment($shipment->getOrder());
285
+ /* @var $magento_shipment Mage_Sales_Model_Order_Shipment */
286
+
287
+ $totalQty = 0;
288
+ foreach ($shipment->getOrder()->getAllItems() as $item) {
289
+ if ($item->getQtyToShip() && !$item->getIsVirtual()) {
290
+ $magento_shipment_item = Mage::getModel('sales/convert_order')
291
+ ->itemToShipmentItem($item);
292
+
293
+ $qty = $item->getQtyToShip();
294
+
295
+ $magento_shipment_item->setQty($qty);
296
+ $magento_shipment->addItem($magento_shipment_item);
297
+
298
+ $totalQty += $qty;
299
+ }
300
+ }
301
+
302
+ $magento_shipment->setTotalQty($totalQty);
303
+
304
+ $track = Mage::getModel('sales/order_shipment_track');
305
+ /* @var Mage_Sales_Model_Order_Shipment_Track */
306
+ $number = '';
307
+ if ($booking_result->consignmentNumber) {
308
+ $number .= Mage::helper('temando')->__('Consignment Number: ') . $booking_result->consignmentNumber;
309
+ }
310
+
311
+ if ($booking_result->requestId) {
312
+ if ($number) {
313
+ $number .= "\n<br />";
314
+ }
315
+
316
+ $number .= Mage::helper('temando')->__('Request Id: ') . $booking_result->requestId;
317
+ }
318
+
319
+ $track
320
+ ->setCarrierCode(Mage::getModel('temando/shipping_carrier_temando')->getCarrierCode())
321
+ ->setTitle($quote->getCarrier()->getCompanyName())
322
+ ->setNumber($number);
323
+
324
+ $magento_shipment->addTrack($track)->register();
325
+
326
+ try {
327
+ $magento_shipment->getOrder()->setIsInProcess(true)->setCustomerNoteNotify(true);
328
+ Mage::getModel('core/resource_transaction')
329
+ ->addObject($shipment)
330
+ ->addObject($magento_shipment)
331
+ ->addObject($magento_shipment->getOrder())
332
+ ->save();
333
+ $magento_shipment->sendEmail()->setEmailSent(true)->save();
334
+ } catch (Mage_Core_Exception $e) {
335
+ $error = $e->getMessage();
336
+ }
337
+
338
+ $this->_getSession()->addSuccess($this->__('Shipment booked.'));
339
+ }
340
+
341
+ if ($error) {
342
+ $this->_getSession()
343
+ ->addError($this->__($error))
344
+ /* ->setFormData($data) */;
345
+ }
346
+ $this->_redirect('*/*/edit', array('id' => $shipment_id));
347
+ }
348
+
349
+ protected function _makeBooking(Temando_Temando_Model_Shipment $shipment, Temando_Temando_Model_Quote $quote)
350
+ {
351
+ $order = $shipment->getOrder();
352
+ /* @var $order Mage_Sales_Model_Order */
353
+
354
+ $request = Mage::getModel('temando/api_request');
355
+ /* @var $request Temando_Temando_Model_Api_Request */
356
+ $request
357
+ ->setMagentoQuoteId($order->getQuoteId())
358
+ ->setDestination(
359
+ $shipment->getDestinationCountry(),
360
+ $shipment->getDestinationPostcode(),
361
+ $shipment->getDestinationCity(),
362
+ $shipment->getDestinationStreet(),
363
+ $shipment->getDestinationType()
364
+ )
365
+ ->setGoodsCurrency(Mage::app()->getStore($shipment->getStoreId())->getCurrentCurrencyCode())
366
+ ->setDeliveryOptions($shipment->getDeliveryOptionsArray())
367
+ ->setItems($shipment->getBoxes()->getItems());
368
+ if ($shipment->getReadyDate()) {
369
+ $request->setReady(strtotime($shipment->getReadyDate()), $shipment->getReadyTime());
370
+ } else {
371
+ $request->setReady(null);
372
+ }
373
+
374
+ $request_array = $request->toRequestArray();
375
+ $request_array['origin'] = array(
376
+ 'description' => Temando_Temando_Helper_Data::DEFAULT_WAREHOUSE_NAME
377
+ );
378
+
379
+ $request_array['destination'] = array(
380
+ 'contactName' => $shipment->getDestinationContactName(),
381
+ 'companyName' => $shipment->getDestinationCompanyName(),
382
+ 'street' => $shipment->getDestinationStreet(),
383
+ 'suburb' => $shipment->getDestinationCity(),
384
+ 'code' => $shipment->getDestinationPostcode(),
385
+ 'country' => $shipment->getDestinationCountry(),
386
+ 'phone1' => $shipment->getDestinationPhone(),
387
+ 'phone2' => '',
388
+ 'fax' => '',
389
+ 'email' => $shipment->getDestinationEmail(),
390
+ );
391
+
392
+ $option_array = $shipment->getOptionsArray();
393
+ if (!is_null(Mage::getSingleton('adminhtml/session')->getData('insurance_' . $shipment->getId()))) {
394
+ $option_array['insurance'] =
395
+ Mage::getSingleton('adminhtml/session')->getData('insurance_' . $shipment->getId());
396
+ }
397
+
398
+ $request_array['quote'] = $quote->toBookingRequestArray($option_array);
399
+ $request_array['payment'] = array(
400
+ 'paymentType' => Mage::helper('temando')->getConfigData('general/payment_type'),
401
+ );
402
+
403
+ if (Mage::helper('temando')->getConfigData('options/label_type')) {
404
+ $request_array['labelPrinterType'] = Mage::helper('temando')->getConfigData('options/label_type');
405
+ }
406
+
407
+ $request_array['reference'] = $order->getIncrementId();
408
+
409
+ $api = Mage::getModel('temando/api_client');
410
+ /* @var $api Temando_Temando_Model_Api_Client */
411
+ $api->connect(
412
+ Mage::helper('temando')->getConfigData('general/username'),
413
+ Mage::helper('temando')->getConfigData('general/password'),
414
+ Mage::helper('temando')->getConfigData('general/sandbox')
415
+ );
416
+ return $api->makeBooking($request_array);
417
+ }
418
+
419
+ protected function _processBookingResult(
420
+ $booking_result,
421
+ Temando_Temando_Model_Shipment $shipment,
422
+ Temando_Temando_Model_Quote $quote
423
+ ) {
424
+ if ($booking_result) {
425
+
426
+ if (!isset($booking_result->bookingNumber)) {
427
+ $booking_result->bookingNumber = null;
428
+ }
429
+ if (!isset($booking_result->consignmentNumber)) {
430
+ $booking_result->consignmentNumber = null;
431
+ }
432
+ if (!isset($booking_result->consignmentDocument)) {
433
+ $booking_result->consignmentDocument = null;
434
+ }
435
+ if (!isset($booking_result->consignmentDocumentType)) {
436
+ $booking_result->consignmentDocumentType = null;
437
+ }
438
+ if (!isset($booking_result->requestId)) {
439
+ $booking_result->requestId = null;
440
+ }
441
+ if (!isset($booking_result->labelDocument)) {
442
+ $booking_result->labelDocument = null;
443
+ }
444
+ if (!isset($booking_result->labelDocumentType)) {
445
+ $booking_result->labelDocumentType = '';
446
+ }
447
+ if (isset($booking_result->anytime)) {
448
+ $shipment->setReadyDate((string) $booking_result->anytime->readyDate);
449
+ $shipment->setReadyTime((string) $booking_result->anytime->readyTime);
450
+ }
451
+
452
+ $shipment
453
+ ->setBookingRequestId($booking_result->requestId)
454
+ ->setBookingNumber($booking_result->bookingNumber)
455
+ ->setConsignmentNumber($booking_result->consignmentNumber)
456
+ ->setConsignmentDocument($booking_result->consignmentDocument)
457
+ ->setConsignmentDocumentType($booking_result->consignmentDocumentType)
458
+ ->setLabelDocument($booking_result->labelDocument)
459
+ ->setLabelDocumentType($booking_result->labelDocumentType)
460
+ ->setStatus(Temando_Temando_Model_System_Config_Source_Shipment_Status::BOOKED)
461
+ ->setAnticipatedCost($shipment->getSelectedQuotePermutation()->getTotalPrice())
462
+ ->setAnticipatedCurrency($shipment->getSelectedQuotePermutation()->getCurrency())
463
+ ->save();
464
+
465
+ $magento_shipment = Mage::getModel('sales/convert_order')
466
+ ->toShipment($shipment->getOrder());
467
+ /* @var $magento_shipment Mage_Sales_Model_Order_Shipment */
468
+
469
+ $totalQty = 0;
470
+ foreach ($shipment->getOrder()->getAllItems() as $item) {
471
+ if ($item->getQtyToShip() && !$item->getIsVirtual()) {
472
+ $magento_shipment_item = Mage::getModel('sales/convert_order')
473
+ ->itemToShipmentItem($item);
474
+ $qty = $item->getQtyToShip();
475
+ $magento_shipment_item->setQty($qty);
476
+ $magento_shipment->addItem($magento_shipment_item);
477
+ $totalQty += $qty;
478
+ }
479
+ }
480
+
481
+ $magento_shipment->setTotalQty($totalQty);
482
+
483
+ $track = Mage::getModel('sales/order_shipment_track');
484
+ /* @var Mage_Sales_Model_Order_Shipment_Track */
485
+ $number = '';
486
+ if ($booking_result->consignmentNumber) {
487
+ $number .= Mage::helper('temando')->__('Consignment Number: ') . $booking_result->consignmentNumber;
488
+ }
489
+
490
+ if ($booking_result->requestId) {
491
+ if ($number) {
492
+ $number .= "\n<br />";
493
+ }
494
+
495
+ $number .= Mage::helper('temando')->__('Request Id: ') . $booking_result->requestId;
496
+ }
497
+
498
+ $track
499
+ ->setCarrierCode(Mage::getModel('temando/shipping_carrier_temando')->getCarrierCode())
500
+ ->setTitle($quote->getCarrier()->getCompanyName())
501
+ ->setNumber($number);
502
+
503
+ $magento_shipment
504
+ ->addTrack($track)
505
+ ->register();
506
+
507
+ try {
508
+ $magento_shipment->getOrder()->setIsInProcess(true)->setCustomerNoteNotify(true);
509
+ Mage::getModel('core/resource_transaction')
510
+ ->addObject($shipment)
511
+ ->addObject($magento_shipment)
512
+ ->addObject($magento_shipment->getOrder())
513
+ ->save();
514
+ $magento_shipment->sendEmail();
515
+ } catch (Mage_Core_Exception $e) {
516
+ $error = $e->getMessage();
517
+ }
518
+ }
519
+
520
+ return;
521
+ }
522
+
523
+ /**
524
+ * Serve shipping labels
525
+ */
526
+ public function consignmentAction()
527
+ {
528
+ $shipment = Mage::getModel('temando/shipment')->load($this->getRequest()->getParam('id'));
529
+ /* @var $shipment Temando_Temando_Model_Shipment */
530
+
531
+ if ($shipment->getId()) {
532
+ $document = '';
533
+
534
+ $labelType = Mage::helper('temando')->getConfigData('options/label_type');
535
+ switch ($labelType) {
536
+ case Temando_Temando_Model_System_Config_Source_Labeltype::STANDARD:
537
+ if ($shipment->getConsignmentDocument()) {
538
+ $document = base64_decode($shipment->getConsignmentDocument());
539
+ }
540
+ break;
541
+ case Temando_Temando_Model_System_Config_Source_Labeltype::THERMAL:
542
+ if ($shipment->getLabelDocument()) {
543
+ $document = base64_decode($shipment->getLabelDocument());
544
+ }
545
+ break;
546
+ }
547
+
548
+ $document_length = strlen($document);
549
+
550
+ if ($document_length) {
551
+ $this->getResponse()
552
+ ->setHttpResponseCode(200)
553
+ ->setHeader('Pragma', 'public', true)
554
+ ->setHeader('Cache-Control', 'must-revalidate, post-check=0, pre-check=0', true)
555
+ ->setHeader('Content-type', $shipment->getConsignmentDocumentType(), true)
556
+ ->setHeader('Content-Length', $document_length, true)
557
+ ->setHeader(
558
+ 'Content-Disposition',
559
+ 'attachment; filename="order-' . $shipment->getOrderNumber() . '.pdf"',
560
+ true
561
+ )
562
+ ->setHeader('Last-Modified', date('r'), true);
563
+ $this->getResponse()->clearBody();
564
+ $this->getResponse()->sendHeaders();
565
+ print $document;
566
+ }
567
+ }
568
+ }
569
+ }
app/code/community/Temando/Temando/controllers/Adminhtml/WizardController.php CHANGED
@@ -1,52 +1,52 @@
1
- <?php
2
- /**
3
- * Wizard Controller
4
- *
5
- * @package Temando_Temando
6
- * @author Temando Magento Team <marketing@temando.com>
7
- */
8
- class Temando_Temando_Adminhtml_WizardController extends Mage_Adminhtml_Controller_Action
9
- {
10
-
11
- const ERR_NO_SOAP = 'SOAP is not enabled on this server. Please enable SOAP to use the Temando plugin.';
12
-
13
- /**
14
- * Check admin permissions for this controller
15
- * Add a comment to this line
16
- *
17
- * @return boolean
18
- */
19
- protected function _isAllowed()
20
- {
21
- return Mage::getSingleton('admin/session')
22
- ->isAllowed('temando/configuration/wizard');
23
- }
24
-
25
- /**
26
- * Adminhtml controller that redirects to the front end view and starts the wizard.
27
- * @return type
28
- */
29
- public function indexAction() {
30
- $params = array('id' => md5(Mage::getSingleton('core/session')->getSessionId()));
31
- if ($this->checkSoap()) {
32
- Mage::getSingleton('adminhtml/session')->addError(self::ERR_NO_SOAP);
33
- return $this->getResponse()->setRedirect($this->getRequest()->getServer('HTTP_REFERER'));
34
- } else {
35
- $this->_redirect('etemando/wizard/index', $params);
36
- }
37
- }
38
-
39
- /**
40
- * Checks to see if the SOAP extension is loaded
41
- * @return boolean
42
- */
43
- public function checkSoap() {
44
- if (!extension_loaded('soap')) {
45
- return true;
46
- } else {
47
- return false;
48
- }
49
- }
50
-
51
- }
52
-
1
+ <?php
2
+ /**
3
+ * Wizard Controller
4
+ *
5
+ * @package Temando_Temando
6
+ * @author Temando Magento Team <marketing@temando.com>
7
+ */
8
+ class Temando_Temando_Adminhtml_WizardController extends Mage_Adminhtml_Controller_Action
9
+ {
10
+
11
+ const ERR_NO_SOAP = 'SOAP is not enabled on this server. Please enable SOAP to use the Temando plugin.';
12
+
13
+ /**
14
+ * Check admin permissions for this controller
15
+ * Add a comment to this line
16
+ *
17
+ * @return boolean
18
+ */
19
+ protected function _isAllowed()
20
+ {
21
+ return Mage::getSingleton('admin/session')
22
+ ->isAllowed('temando/configuration/wizard');
23
+ }
24
+
25
+ /**
26
+ * Adminhtml controller that redirects to the front end view and starts the wizard.
27
+ * @return type
28
+ */
29
+ public function indexAction()
30
+ {
31
+ $params = array('id' => md5(Mage::getSingleton('core/session')->getSessionId()));
32
+ if ($this->checkSoap()) {
33
+ Mage::getSingleton('adminhtml/session')->addError(self::ERR_NO_SOAP);
34
+ return $this->getResponse()->setRedirect($this->getRequest()->getServer('HTTP_REFERER'));
35
+ } else {
36
+ $this->_redirect('etemando/wizard/index', $params);
37
+ }
38
+ }
39
+
40
+ /**
41
+ * Checks to see if the SOAP extension is loaded
42
+ * @return boolean
43
+ */
44
+ public function checkSoap()
45
+ {
46
+ if (!extension_loaded('soap')) {
47
+ return true;
48
+ } else {
49
+ return false;
50
+ }
51
+ }
52
+ }
app/code/community/Temando/Temando/controllers/PcsController.php CHANGED
@@ -1,258 +1,257 @@
1
- <?php
2
- /**
3
- * Pcs Controller
4
- *
5
- * @package Temando_Temando
6
- * @author Temando Magento Team <marketing@temando.com>
7
- */
8
- class Temando_Temando_PcsController extends Mage_Core_Controller_Front_Action
9
- {
10
- /**
11
- * @var Temando_Temando_Model_Pcs
12
- */
13
- protected $_validator = null;
14
-
15
- public function testAction()
16
- {
17
- $shippingMethod = 'temando_flat';
18
- $selected_quote_id = preg_replace('#^[^_]*_#', '', $shippingMethod);
19
-
20
- echo Mage::helper('temando')->isQuoteDynamic($selected_quote_id) ?
21
- 'DYNAMIC' : 'FREE/FLAT';
22
- }
23
-
24
- private $_result = array (
25
- 'query' => '',
26
- 'suggestions' => array(),
27
- 'data' => array(
28
- 0 => array (
29
- 0 => array(
30
- 'city' => '',
31
- 'region_id' => '',
32
- 'postcode' => ''
33
- )
34
- )
35
- )
36
- );
37
-
38
- public function construct() {
39
- parent:: construct();
40
-
41
- $this->loadLayout();
42
- $this->renderLayout();
43
- }
44
-
45
- protected function _makeAutocomplete($query, $country = null)
46
- {
47
- $country = $country ? $country : Mage::helper('temando')->getDefaultCountryId();
48
- $this->_result['query'] = Mage::helper('core')->escapeHtml($query);
49
-
50
- $this->_getValidator();
51
- $this->_validator->setCountry($country)->setQuery($query);
52
-
53
- $suggestions = $this->_validator->getSuggestions();
54
-
55
- $i = -1;
56
- if(!empty($suggestions)) {
57
- //have results - load into result array
58
- $this->_result['data'] = array();
59
- foreach($suggestions as $item)
60
- {
61
- $fulltext = $item['name'] .', ';
62
- $fulltext.= array_key_exists('postcodes', $item) && !empty($item['postcodes']) ? $item['postcodes'][0]['code'].' ' : ' ';
63
- $fulltext.= $item['country']['iso_code2'];
64
-
65
- if (!in_array($fulltext, $this->_result['suggestions'])) {
66
- $i++; $this->_result['suggestions'][$i] = $fulltext;
67
- }
68
- $this->_result['data'][$i][] = array(
69
- 'postcode' => array_key_exists('postcodes', $item) && !empty($item['postcodes']) ? $item['postcodes'][0]['code'] : '',
70
- 'city' => $item['name'],
71
- 'country_id'=> $item['country']['iso_code2'],
72
- 'fulltext' => $fulltext
73
- );
74
- }
75
- }
76
- $core_helper = Mage::helper('core');
77
- if (method_exists($core_helper, "jsonEncode")) {
78
- $result = Mage::helper('core')->jsonEncode($this->_result);
79
- } else {
80
- $result = Zend_Json::encode($this->_result);
81
- }
82
-
83
- return $result;
84
- }
85
-
86
- public function autocompletecartAction() {
87
-
88
- $query = $this->getRequest()->getParam('query');
89
- $country = $this->getRequest()->getParam('country', Mage::helper('temando')->getDefaultCountryId());
90
-
91
- echo $this->_makeAutocomplete($query, $country);
92
- exit;
93
- }
94
-
95
- public function generateAction()
96
- {
97
- $array1 = array('0', '1', '2', '3', '4', '5', '6', '7', '8', '9');
98
- $array2 = array('a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j',
99
- 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's', 't',
100
- 'u', 'v', 'w', 'x', 'y', 'z');
101
-
102
- foreach ($array1 as $c) {
103
- $this->_makeAutocomplete($c);
104
- }
105
-
106
- foreach ($array1 as $c1) {
107
- foreach ($array1 as $c2) {
108
- $this->_makeAutocomplete($c1 . $c2);
109
- }
110
- }
111
-
112
- foreach ($array2 as $c) {
113
- $this->_makeAutocomplete($c);
114
- }
115
-
116
- /*foreach ($array2 as $c1) {
117
- foreach ($array2 as $c2) {
118
- $this->_makeAutocomplete($c1 . $c2);
119
- }
120
- }*/
121
-
122
- echo 'done'; exit;
123
- }
124
-
125
-
126
- public function productAction()
127
- {
128
- try {
129
- $data = array(
130
- 'country_id' => $this->getRequest()->getParam('country_id'),
131
- 'city' => $this->getRequest()->getParam('city'),
132
- 'postcode' => $this->getRequest()->getParam('postcode'),
133
- );
134
- Mage::getSingleton('customer/session')->setData('estimate_product_shipping', new Varien_Object($data));
135
- $product_id = $this->getRequest()->getParam('product_id');
136
- $product = Mage::getModel('catalog/product')->load($product_id);
137
- $options = array();
138
- foreach (explode(';', $this->getRequest()->getParam('options')) as $o) {
139
- if (!$o) {
140
- continue;
141
- }
142
-
143
- $_t = explode(':', $o);
144
- if (isset($_t[1])) {
145
- $options[$_t[0]] = $_t[1];
146
- }
147
- }
148
- $quote = Mage::getModel('sales/quote');
149
- $request = array('qty' => $this->getRequest()->getParam('qty'));
150
- if (count($options)) {
151
- $request['super_attribute'] = $options;
152
- }
153
-
154
- $options = array();
155
- foreach (explode(';', $this->getRequest()->getParam('pr_options')) as $o) {
156
- if (!$o) {
157
- continue;
158
- }
159
-
160
- $_t = explode(':', $o);
161
- if (isset($_t[1])) {
162
- $options[$_t[0]] = $_t[1];
163
- }
164
- }
165
-
166
- //get bundle products options
167
- $bundle_options = array();
168
- if($product->getTypeId() == Mage_Catalog_Model_Product_Type::TYPE_BUNDLE)
169
- {
170
- foreach (explode(';', $this->getRequest()->getParam('bl_options')) as $o) {
171
- if (!$o) {
172
- continue;
173
- }
174
-
175
- $_t = explode(':', $o);
176
- if (isset($_t[1])) {
177
- $bundle_options[$_t[0]] = $_t[1];
178
- }
179
- }
180
- if(empty($bundle_options)) { //assign default values
181
- $selectionCollection = $product->getTypeInstance(true)->getSelectionsCollection(
182
- $product->getTypeInstance(true)->getOptionsIds($product), $product
183
- );
184
-
185
- foreach($selectionCollection as $option) {
186
- if($option->getIsDefault() == true) {
187
- $bundle_options[$option->getOptionId()] = $option->getSelectionId();
188
- }
189
- }
190
- }
191
- }
192
-
193
- if (count($options)) {
194
- $request['options'] = $options;
195
- }
196
-
197
- if(count($bundle_options)) {
198
- $request['bundle_option'] = $bundle_options;
199
- }
200
-
201
- $item = $quote->addProduct($product, new Varien_Object($request));
202
- if (!is_object($item)) {
203
- throw new Exception(Mage::helper('temando')->__('Cannot calculate shipping cost for separate item'));
204
- }
205
- $item->setStoreId(Mage::app()->getStore()->getId());
206
- $item->setQty($this->getRequest()->getParam('qty'));
207
- $item->setPrice($product->getFinalPrice());
208
- $request = Mage::getModel('shipping/rate_request');
209
- foreach ($quote->getAllItems() as $i) {
210
- if (!$i->getPrice()) {
211
- $i->setPrice($product->getFinalPrice());
212
- }
213
- }
214
-
215
- $request->setAllItems($quote->getAllItems());
216
- $request->setDestCountryId($this->getRequest()->getParam('country_id'));
217
- $request->setDestStreet('');
218
- $request->setDestCity($this->getRequest()->getParam('city'));
219
- $request->setDestPostcode($this->getRequest()->getParam('postcode'));
220
- $request->setPackageValue($item->getTotal());
221
- $request->setPackageValueWithDiscount($item->getTotal());
222
- $request->setPackageWeight($this->getRequest()->getParam('qty')*$product->getWeight());
223
- $request->setPackageQty($this->getRequest()->getParam('qty'));
224
-
225
- /**
226
- * Need for shipping methods that use insurance based on price of physical products
227
- */
228
- $request->setPackagePhysicalValue($item->getTotal());
229
-
230
- $request->setFreeMethodWeight($item);
231
- $request->setStoreId(Mage::app()->getStore()->getId());
232
- $request->setWebsiteId(Mage::app()->getStore()->getWebsiteId());
233
- $request->setFreeShipping(null);
234
- /**
235
- * Currencies need to convert in free shipping
236
- */
237
- $request->setBaseCurrency(Mage::app()->getStore()->getBaseCurrency());
238
- $request->setPackageCurrency(Mage::app()->getStore()->getCurrentCurrency());
239
- $request->setLimitCarrier(null);
240
- $request->setOrig(false);
241
- $result = Mage::getModel('shipping/shipping')->collectCarrierRates('temando', $request)->getResult();
242
- Mage::register('product_rates', array('temando' => $result));
243
- $this->loadLayout();
244
- $this->renderLayout();
245
- } catch (Exception $e) {
246
- die($e->getMessage());
247
- }
248
- }
249
-
250
- protected function _getValidator()
251
- {
252
- if(!$this->_validator) {
253
- $this->_validator = Mage::getModel('temando/pcs');
254
- }
255
- return $this;
256
- }
257
-
258
- }
1
+ <?php
2
+ /**
3
+ * Pcs Controller
4
+ *
5
+ * @package Temando_Temando
6
+ * @author Temando Magento Team <marketing@temando.com>
7
+ */
8
+ class Temando_Temando_PcsController extends Mage_Core_Controller_Front_Action
9
+ {
10
+ /**
11
+ * @var Temando_Temando_Model_Pcs
12
+ */
13
+ protected $_validator = null;
14
+
15
+ public function testAction()
16
+ {
17
+ $shippingMethod = 'temando_flat';
18
+ $selected_quote_id = preg_replace('#^[^_]*_#', '', $shippingMethod);
19
+ echo Mage::helper('temando')->isQuoteDynamic($selected_quote_id) ?
20
+ 'DYNAMIC' : 'FREE/FLAT';
21
+ }
22
+
23
+ private $_result = array (
24
+ 'query' => '',
25
+ 'suggestions' => array(),
26
+ 'data' => array(
27
+ 0 => array (
28
+ 0 => array(
29
+ 'city' => '',
30
+ 'region_id' => '',
31
+ 'postcode' => ''
32
+ )
33
+ )
34
+ )
35
+ );
36
+
37
+ public function construct()
38
+ {
39
+ parent:: construct();
40
+ $this->loadLayout();
41
+ $this->renderLayout();
42
+ }
43
+
44
+ protected function _makeAutocomplete($query, $country = null)
45
+ {
46
+ $country = $country ? $country : Mage::helper('temando')->getDefaultCountryId();
47
+ $this->_result['query'] = Mage::helper('core')->escapeHtml($query);
48
+
49
+ $this->_getValidator();
50
+ $this->_validator->setCountry($country)->setQuery($query);
51
+
52
+ $suggestions = $this->_validator->getSuggestions();
53
+
54
+ $i = -1;
55
+ if (!empty($suggestions)) {
56
+ //have results - load into result array
57
+ $this->_result['data'] = array();
58
+ foreach ($suggestions as $item) {
59
+ $fulltext = $item['name'] .', ';
60
+ $fulltext.= array_key_exists('postcodes', $item) &&
61
+ !empty($item['postcodes']) ? $item['postcodes'][0]['code'].' ' : ' ';
62
+ $fulltext.= $item['country']['iso_code2'];
63
+
64
+ if (!in_array($fulltext, $this->_result['suggestions'])) {
65
+ $i++;
66
+ $this->_result['suggestions'][$i] = $fulltext;
67
+ }
68
+ $this->_result['data'][$i][] = array(
69
+ 'postcode' => array_key_exists('postcodes', $item) &&
70
+ !empty($item['postcodes']) ? $item['postcodes'][0]['code'] : '',
71
+ 'city' => $item['name'],
72
+ 'country_id'=> $item['country']['iso_code2'],
73
+ 'fulltext' => $fulltext
74
+ );
75
+ }
76
+ }
77
+ $core_helper = Mage::helper('core');
78
+ if (method_exists($core_helper, "jsonEncode")) {
79
+ $result = Mage::helper('core')->jsonEncode($this->_result);
80
+ } else {
81
+ $result = Zend_Json::encode($this->_result);
82
+ }
83
+ return $result;
84
+ }
85
+
86
+ public function autocompletecartAction()
87
+ {
88
+
89
+ $query = $this->getRequest()->getParam('query');
90
+ $country = $this->getRequest()->getParam('country', Mage::helper('temando')->getDefaultCountryId());
91
+ echo $this->_makeAutocomplete($query, $country);
92
+ exit;
93
+ }
94
+
95
+ public function generateAction()
96
+ {
97
+ $array1 = array('0', '1', '2', '3', '4', '5', '6', '7', '8', '9');
98
+ $array2 = array('a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j',
99
+ 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's', 't',
100
+ 'u', 'v', 'w', 'x', 'y', 'z');
101
+
102
+ foreach ($array1 as $c) {
103
+ $this->_makeAutocomplete($c);
104
+ }
105
+
106
+ foreach ($array1 as $c1) {
107
+ foreach ($array1 as $c2) {
108
+ $this->_makeAutocomplete($c1 . $c2);
109
+ }
110
+ }
111
+
112
+ foreach ($array2 as $c) {
113
+ $this->_makeAutocomplete($c);
114
+ }
115
+
116
+ /*foreach ($array2 as $c1) {
117
+ foreach ($array2 as $c2) {
118
+ $this->_makeAutocomplete($c1 . $c2);
119
+ }
120
+ }*/
121
+
122
+ echo 'done';
123
+ exit;
124
+ }
125
+
126
+ public function productAction()
127
+ {
128
+ try {
129
+ $data = array(
130
+ 'country_id' => $this->getRequest()->getParam('country_id'),
131
+ 'city' => $this->getRequest()->getParam('city'),
132
+ 'postcode' => $this->getRequest()->getParam('postcode'),
133
+ );
134
+ Mage::getSingleton('customer/session')->setData('estimate_product_shipping', new Varien_Object($data));
135
+ $product_id = $this->getRequest()->getParam('product_id');
136
+ $product = Mage::getModel('catalog/product')->load($product_id);
137
+ $options = array();
138
+ foreach (explode(';', $this->getRequest()->getParam('options')) as $o) {
139
+ if (!$o) {
140
+ continue;
141
+ }
142
+
143
+ $_t = explode(':', $o);
144
+ if (isset($_t[1])) {
145
+ $options[$_t[0]] = $_t[1];
146
+ }
147
+ }
148
+ $quote = Mage::getModel('sales/quote');
149
+ $request = array('qty' => $this->getRequest()->getParam('qty'));
150
+ if (count($options)) {
151
+ $request['super_attribute'] = $options;
152
+ }
153
+
154
+ $options = array();
155
+ foreach (explode(';', $this->getRequest()->getParam('pr_options')) as $o) {
156
+ if (!$o) {
157
+ continue;
158
+ }
159
+
160
+ $_t = explode(':', $o);
161
+ if (isset($_t[1])) {
162
+ $options[$_t[0]] = $_t[1];
163
+ }
164
+ }
165
+
166
+ //get bundle products options
167
+ $bundle_options = array();
168
+ if ($product->getTypeId() == Mage_Catalog_Model_Product_Type::TYPE_BUNDLE) {
169
+ foreach (explode(';', $this->getRequest()->getParam('bl_options')) as $o) {
170
+ if (!$o) {
171
+ continue;
172
+ }
173
+
174
+ $_t = explode(':', $o);
175
+ if (isset($_t[1])) {
176
+ $bundle_options[$_t[0]] = $_t[1];
177
+ }
178
+ }
179
+ if (empty($bundle_options)) { //assign default values
180
+ $selectionCollection = $product->getTypeInstance(true)->getSelectionsCollection(
181
+ $product->getTypeInstance(true)->getOptionsIds($product),
182
+ $product
183
+ );
184
+
185
+ foreach ($selectionCollection as $option) {
186
+ if ($option->getIsDefault() == true) {
187
+ $bundle_options[$option->getOptionId()] = $option->getSelectionId();
188
+ }
189
+ }
190
+ }
191
+ }
192
+
193
+ if (count($options)) {
194
+ $request['options'] = $options;
195
+ }
196
+
197
+ if (count($bundle_options)) {
198
+ $request['bundle_option'] = $bundle_options;
199
+ }
200
+
201
+ $item = $quote->addProduct($product, new Varien_Object($request));
202
+ if (!is_object($item)) {
203
+ throw new Exception(Mage::helper('temando')->__('Cannot calculate shipping cost for separate item'));
204
+ }
205
+ $item->setStoreId(Mage::app()->getStore()->getId());
206
+ $item->setQty($this->getRequest()->getParam('qty'));
207
+ $item->setPrice($product->getFinalPrice());
208
+ $request = Mage::getModel('shipping/rate_request');
209
+ foreach ($quote->getAllItems() as $i) {
210
+ if (!$i->getPrice()) {
211
+ $i->setPrice($product->getFinalPrice());
212
+ }
213
+ }
214
+
215
+ $request->setAllItems($quote->getAllItems());
216
+ $request->setDestCountryId($this->getRequest()->getParam('country_id'));
217
+ $request->setDestStreet('');
218
+ $request->setDestCity($this->getRequest()->getParam('city'));
219
+ $request->setDestPostcode($this->getRequest()->getParam('postcode'));
220
+ $request->setPackageValue($item->getTotal());
221
+ $request->setPackageValueWithDiscount($item->getTotal());
222
+ $request->setPackageWeight($this->getRequest()->getParam('qty')*$product->getWeight());
223
+ $request->setPackageQty($this->getRequest()->getParam('qty'));
224
+
225
+ /**
226
+ * Need for shipping methods that use insurance based on price of physical products
227
+ */
228
+ $request->setPackagePhysicalValue($item->getTotal());
229
+
230
+ $request->setFreeMethodWeight($item);
231
+ $request->setStoreId(Mage::app()->getStore()->getId());
232
+ $request->setWebsiteId(Mage::app()->getStore()->getWebsiteId());
233
+ $request->setFreeShipping(null);
234
+ /**
235
+ * Currencies need to convert in free shipping
236
+ */
237
+ $request->setBaseCurrency(Mage::app()->getStore()->getBaseCurrency());
238
+ $request->setPackageCurrency(Mage::app()->getStore()->getCurrentCurrency());
239
+ $request->setLimitCarrier(null);
240
+ $request->setOrig(false);
241
+ $result = Mage::getModel('shipping/shipping')->collectCarrierRates('temando', $request)->getResult();
242
+ Mage::register('product_rates', array('temando' => $result));
243
+ $this->loadLayout();
244
+ $this->renderLayout();
245
+ } catch (Exception $e) {
246
+ die($e->getMessage());
247
+ }
248
+ }
249
+
250
+ protected function _getValidator()
251
+ {
252
+ if (!$this->_validator) {
253
+ $this->_validator = Mage::getModel('temando/pcs');
254
+ }
255
+ return $this;
256
+ }
257
+ }
 
app/code/community/Temando/Temando/controllers/WizardController.php CHANGED
@@ -1,120 +1,139 @@
1
- <?php
2
- /**
3
- * Wizard Controller
4
- *
5
- * @package Temando_Temando
6
- * @author Temando Magento Team <marketing@temando.com>
7
- */
8
- class Temando_Temando_WizardController extends Mage_Core_Controller_Front_Action
9
- {
10
-
11
- const ERR_ORIGIN_EXISTS = 'This warehouse already exists. Please select another name.';
12
- const ERR_NO_CONNECT = 'Cannot connect to the api. Please check your connection and try again.';
13
-
14
- public function construct() {
15
- parent:: construct();
16
-
17
- $this->loadLayout();
18
- $this->renderLayout();
19
- }
20
-
21
- /**
22
- * Main index
23
- */
24
- public function indexAction() {
25
- $params = $this->getRequest()->getParams();
26
- if ($params) {
27
- if ($params['key'] && $params['id'] == md5(Mage::getSingleton('admin/session')->getCookie()->get('adminhtml'))) {
28
- Mage::getModel('temando/wizard')->setTmdStep(1);
29
- Mage::getModel('temando/wizard')->createCancelUrl();
30
- $this->_redirect('*/*/index');
31
- }
32
- }
33
- $step = Mage::getSingleton('core/session')->getTemandoWizardStep();
34
- $this->setControllerLayout($step);
35
- }
36
-
37
- /**
38
- * Save action to save data
39
- */
40
- public function saveAction() {
41
- $params = $this->getRequest()->getPost();
42
- $step = (Mage::getSingleton('core/session')->getTemandoWizardStep());
43
- $wizard = Mage::getModel('temando/wizard');
44
- /* @var $wizard Temando_Temando_Model_Wizard */
45
-
46
- if ($step == Temando_Temando_Model_System_Config_Source_Wizard::ACCOUNT) {
47
- if (!$wizard->checkAccount($params)) {
48
- $step = 0;
49
- $wizard->_saveTemando($params);
50
- };
51
- }
52
- if ($step == Temando_Temando_Model_System_Config_Source_Wizard::CARRIERS) {
53
- $wizard->setTmdSession('temando_wizard_carriers', $params);
54
- }
55
- if ($step == Temando_Temando_Model_System_Config_Source_Wizard::ACCOUNT || $step == Temando_Temando_Model_System_Config_Source_Wizard::CATALOG_PRODUCT) {
56
- $wizard->_saveTemando($params);
57
- } else if ($step == Temando_Temando_Model_System_Config_Source_Wizard::CARRIERS) {
58
- $wizard->_saveCarrier($params);
59
- } else if ($step == Temando_Temando_Model_System_Config_Source_Wizard::ORIGIN) {
60
- $wizard->_saveTemando($params)->_syncOrigin();
61
- } else if ($step == Temando_Temando_Model_System_Config_Source_Wizard::RULE) {
62
- $wizard->_saveTemando($params)->sendEmail();
63
- }
64
- Mage::getSingleton('core/session')->setTemandoWizardStep($step + 1);
65
- Mage::app()->cleanCache(array('CONFIG'));
66
- $this->_redirect('*/*/index');
67
- }
68
-
69
- /**
70
- * Goes back to the previous step
71
- */
72
- public function backAction() {
73
- $step = (Mage::getSingleton('core/session')->getTemandoWizardStep() - 1);
74
- Mage::getSingleton('core/session')->setTemandoWizardStep($step);
75
- $this->_redirect('*/*/index');
76
- }
77
-
78
- /**
79
- * Skips the save function and goes to the next step
80
- */
81
- public function skipAction() {
82
- $step = (Mage::getSingleton('core/session')->getTemandoWizardStep() + 1);
83
- if ($step == Temando_Temando_Model_System_Config_Source_Wizard::END) {
84
- Mage::getModel('temando/wizard')->sendEmail();
85
- }
86
- Mage::getSingleton('core/session')->setTemandoWizardStep($step);
87
- $this->_redirect('*/*/index');
88
- }
89
-
90
- /**
91
- * Sets the layout based on the current step saved in the session
92
- * @param type $step
93
- */
94
- protected function setControllerLayout($step) {
95
-
96
- $wizard = Mage::getModel('temando/system_config_source_wizard');
97
- /* @var $wizard Temando_Temando_Model_System_Config_Source_Wizard */
98
-
99
- if ($step) {
100
-
101
- $this->loadLayout();
102
- if ($step == Temando_Temando_Model_System_Config_Source_Wizard::ACCOUNT) {
103
- $this->getLayout()->getBlock('root')->getChild('content')->setTemplate($wizard->getOptionLabel(Temando_Temando_Model_System_Config_Source_Wizard::ACCOUNT));
104
- } elseif ($step == Temando_Temando_Model_System_Config_Source_Wizard::CARRIERS) {
105
- $this->getLayout()->getBlock('root')->getChild('content')->setTemplate($wizard->getOptionLabel(Temando_Temando_Model_System_Config_Source_Wizard::CARRIERS));
106
- } elseif ($step == Temando_Temando_Model_System_Config_Source_Wizard::CATALOG_PRODUCT) {
107
- $this->getLayout()->getBlock('root')->getChild('content')->setTemplate($wizard->getOptionLabel(Temando_Temando_Model_System_Config_Source_Wizard::CATALOG_PRODUCT));
108
- } elseif ($step == Temando_Temando_Model_System_Config_Source_Wizard::ORIGIN) {
109
- $this->getLayout()->getBlock('root')->getChild('content')->setTemplate($wizard->getOptionLabel(Temando_Temando_Model_System_Config_Source_Wizard::ORIGIN));
110
- } elseif ($step == Temando_Temando_Model_System_Config_Source_Wizard::RULE) {
111
- $this->getLayout()->getBlock('root')->getChild('content')->setTemplate($wizard->getOptionLabel(Temando_Temando_Model_System_Config_Source_Wizard::RULE));
112
- } else {
113
- $this->getLayout()->getBlock('root')->getChild('content')->setTemplate($wizard->getOptionLabel(Temando_Temando_Model_System_Config_Source_Wizard::END));
114
- Mage::getModel('temando/wizard')->unsetTmdStep();
115
- }
116
- $this->renderLayout();
117
- }
118
- }
119
-
120
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Wizard Controller
4
+ *
5
+ * @package Temando_Temando
6
+ * @author Temando Magento Team <marketing@temando.com>
7
+ */
8
+ class Temando_Temando_WizardController extends Mage_Core_Controller_Front_Action
9
+ {
10
+
11
+ const ERR_ORIGIN_EXISTS = 'This warehouse already exists. Please select another name.';
12
+ const ERR_NO_CONNECT = 'Cannot connect to the api. Please check your connection and try again.';
13
+
14
+ public function construct()
15
+ {
16
+ parent:: construct();
17
+
18
+ $this->loadLayout();
19
+ $this->renderLayout();
20
+ }
21
+
22
+ /**
23
+ * Main index
24
+ */
25
+ public function indexAction()
26
+ {
27
+ $params = $this->getRequest()->getParams();
28
+ if ($params) {
29
+ if ($params['key'] && $params['id'] ==
30
+ md5(Mage::getSingleton('admin/session')->getCookie()->get('adminhtml'))) {
31
+ Mage::getModel('temando/wizard')->setTmdStep(1);
32
+ Mage::getModel('temando/wizard')->createCancelUrl();
33
+ $this->_redirect('*/*/index');
34
+ }
35
+ }
36
+ $step = Mage::getSingleton('core/session')->getTemandoWizardStep();
37
+ $this->setControllerLayout($step);
38
+ }
39
+
40
+ /**
41
+ * Save action to save data
42
+ */
43
+ public function saveAction()
44
+ {
45
+ $params = $this->getRequest()->getPost();
46
+ $step = (Mage::getSingleton('core/session')->getTemandoWizardStep());
47
+ $wizard = Mage::getModel('temando/wizard');
48
+ /* @var $wizard Temando_Temando_Model_Wizard */
49
+
50
+ if ($step == Temando_Temando_Model_System_Config_Source_Wizard::ACCOUNT) {
51
+ if (!$wizard->checkAccount($params)) {
52
+ $step = 0;
53
+ $wizard->_saveTemando($params);
54
+ };
55
+ }
56
+ if ($step == Temando_Temando_Model_System_Config_Source_Wizard::CARRIERS) {
57
+ $wizard->setTmdSession('temando_wizard_carriers', $params);
58
+ }
59
+ if ($step == Temando_Temando_Model_System_Config_Source_Wizard::ACCOUNT ||
60
+ $step == Temando_Temando_Model_System_Config_Source_Wizard::CATALOG_PRODUCT) {
61
+ $wizard->_saveTemando($params);
62
+ } elseif ($step == Temando_Temando_Model_System_Config_Source_Wizard::CARRIERS) {
63
+ $wizard->_saveCarrier($params);
64
+ } elseif ($step == Temando_Temando_Model_System_Config_Source_Wizard::ORIGIN) {
65
+ $wizard->_saveTemando($params)->_syncOrigin();
66
+ } elseif ($step == Temando_Temando_Model_System_Config_Source_Wizard::RULE) {
67
+ $wizard->_saveTemando($params)->sendEmail();
68
+ }
69
+ Mage::getSingleton('core/session')->setTemandoWizardStep($step + 1);
70
+ Mage::app()->cleanCache(array('CONFIG'));
71
+ $this->_redirect('*/*/index');
72
+ }
73
+
74
+ /**
75
+ * Goes back to the previous step
76
+ */
77
+ public function backAction()
78
+ {
79
+ $step = (Mage::getSingleton('core/session')->getTemandoWizardStep() - 1);
80
+ Mage::getSingleton('core/session')->setTemandoWizardStep($step);
81
+ $this->_redirect('*/*/index');
82
+ }
83
+
84
+ /**
85
+ * Skips the save function and goes to the next step
86
+ */
87
+ public function skipAction()
88
+ {
89
+ $step = (Mage::getSingleton('core/session')->getTemandoWizardStep() + 1);
90
+ if ($step == Temando_Temando_Model_System_Config_Source_Wizard::END) {
91
+ Mage::getModel('temando/wizard')->sendEmail();
92
+ }
93
+ Mage::getSingleton('core/session')->setTemandoWizardStep($step);
94
+ $this->_redirect('*/*/index');
95
+ }
96
+
97
+ /**
98
+ * Sets the layout based on the current step saved in the session
99
+ * @param type $step
100
+ */
101
+ protected function setControllerLayout($step)
102
+ {
103
+
104
+ $wizard = Mage::getModel('temando/system_config_source_wizard');
105
+ /* @var $wizard Temando_Temando_Model_System_Config_Source_Wizard */
106
+
107
+ if ($step) {
108
+
109
+ $this->loadLayout();
110
+ if ($step == Temando_Temando_Model_System_Config_Source_Wizard::ACCOUNT) {
111
+ $this->getLayout()->getBlock('root')->getChild('content')->setTemplate(
112
+ $wizard->getOptionLabel(Temando_Temando_Model_System_Config_Source_Wizard::ACCOUNT)
113
+ );
114
+ } elseif ($step == Temando_Temando_Model_System_Config_Source_Wizard::CARRIERS) {
115
+ $this->getLayout()->getBlock('root')->getChild('content')->setTemplate(
116
+ $wizard->getOptionLabel(Temando_Temando_Model_System_Config_Source_Wizard::CARRIERS)
117
+ );
118
+ } elseif ($step == Temando_Temando_Model_System_Config_Source_Wizard::CATALOG_PRODUCT) {
119
+ $this->getLayout()->getBlock('root')->getChild('content')->setTemplate(
120
+ $wizard->getOptionLabel(Temando_Temando_Model_System_Config_Source_Wizard::CATALOG_PRODUCT)
121
+ );
122
+ } elseif ($step == Temando_Temando_Model_System_Config_Source_Wizard::ORIGIN) {
123
+ $this->getLayout()->getBlock('root')->getChild('content')->setTemplate(
124
+ $wizard->getOptionLabel(Temando_Temando_Model_System_Config_Source_Wizard::ORIGIN)
125
+ );
126
+ } elseif ($step == Temando_Temando_Model_System_Config_Source_Wizard::RULE) {
127
+ $this->getLayout()->getBlock('root')->getChild('content')->setTemplate(
128
+ $wizard->getOptionLabel(Temando_Temando_Model_System_Config_Source_Wizard::RULE)
129
+ );
130
+ } else {
131
+ $this->getLayout()->getBlock('root')->getChild('content')->setTemplate(
132
+ $wizard->getOptionLabel(Temando_Temando_Model_System_Config_Source_Wizard::END)
133
+ );
134
+ Mage::getModel('temando/wizard')->unsetTmdStep();
135
+ }
136
+ $this->renderLayout();
137
+ }
138
+ }
139
+ }
app/code/community/Temando/Temando/data/temando_setup/data-install-1.0.0.php ADDED
@@ -0,0 +1,32 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ set_time_limit(0);
4
+
5
+ /* @var $this Mage_Eav_Model_Entity_Setup */
6
+ /* @var $installer Mage_Eav_Model_Entity_Setup */
7
+ $installer = $this;
8
+ $installer->startSetup();
9
+
10
+ /*
11
+ * Set the current specific country based on the default country
12
+ */
13
+ $countryCode = Mage::getStoreConfig('general/country/default');
14
+
15
+ $coreConfig = new Mage_Core_Model_Config();
16
+ $coreConfig->saveConfig('carriers/temando/specificcountry', $countryCode, 'default', 0);
17
+
18
+ /*
19
+ * Set default origin data
20
+ */
21
+ $warehouseData = Mage::helper('temando')->getDefaultOriginData($countryCode);
22
+
23
+ if (!empty($warehouseData)) {
24
+ $coreConfig->saveConfig('temando/origin/street', $warehouseData['street'], 'default', 0);
25
+ $coreConfig->saveConfig('temando/origin/city', $warehouseData['city'], 'default', 0);
26
+ $coreConfig->saveConfig('temando/origin/postcode', $warehouseData['postcode'], 'default', 0);
27
+ $coreConfig->saveConfig('temando/origin/country', $warehouseData['country'], 'default', 0);
28
+ $coreConfig->saveConfig('temando/origin/region', $warehouseData['region'], 'default', 0);
29
+ $coreConfig->saveConfig('temando/origin/phone1', $warehouseData['phone1'], 'default', 0);
30
+ }
31
+
32
+ $installer->endSetup();
app/code/community/Temando/Temando/etc/config.xml CHANGED
@@ -1,234 +1,238 @@
1
- <?xml version="1.0" encoding="UTF-8"?>
2
- <config>
3
- <modules>
4
- <Temando_Temando>
5
- <version>1.4.1</version>
6
- </Temando_Temando>
7
- </modules>
8
- <global>
9
- <models>
10
- <temando>
11
- <class>Temando_Temando_Model</class>
12
- <resourceModel>temando_mysql4</resourceModel>
13
- </temando>
14
- <temando_mysql4>
15
- <class>Temando_Temando_Model_Mysql4</class>
16
- <entities>
17
- <box><table>temando_box</table></box>
18
- <quote><table>temando_quote</table></quote>
19
- <shipment><table>temando_shipment</table></shipment>
20
- <manifest><table>temando_manifest</table></manifest>
21
- <carrier><table>temando_carrier</table></carrier>
22
- </entities>
23
- </temando_mysql4>
24
- </models>
25
- <blocks>
26
- <temando>
27
- <class>Temando_Temando_Block</class>
28
- </temando>
29
- <checkout>
30
- <rewrite>
31
- <cart_shipping>Temando_Temando_Block_Cart_Shipping</cart_shipping>
32
- </rewrite>
33
- </checkout>
34
- </blocks>
35
- <helpers>
36
- <temando>
37
- <class>Temando_Temando_Helper</class>
38
- </temando>
39
- </helpers>
40
- <resources>
41
- <temando_setup>
42
- <setup>
43
- <module>Temando_Temando</module>
44
- <class>Mage_Eav_Model_Entity_Setup</class>
45
- </setup>
46
- <connection>
47
- <use>core_setup</use>
48
- </connection>
49
- </temando_setup>
50
- <temando_write>
51
- <connection>
52
- <use>core_write</use>
53
- </connection>
54
- </temando_write>
55
- <temando_read>
56
- <connection>
57
- <use>core_read</use>
58
- </connection>
59
- </temando_read>
60
- </resources>
61
- <sales>
62
- <shipping>
63
- <carriers>
64
- <temando>
65
- <class>Temando_Temando_Model_Shipping_Carrier_Temando</class>
66
- </temando>
67
- </carriers>
68
- </shipping>
69
- </sales>
70
- <events>
71
- <sales_order_place_after>
72
- <observers>
73
- <temando_sales_order_place_after_handler>
74
- <type>model</type>
75
- <class>Temando_Temando_Model_Observer</class>
76
- <method>createTemandoShipment</method>
77
- <args></args>
78
- </temando_sales_order_place_after_handler>
79
- </observers>
80
- </sales_order_place_after>
81
- <controller_action_predispatch_checkout_cart_estimatePost>
82
- <observers>
83
- <retail_product_view>
84
- <type>singleton</type>
85
- <class>Temando_Temando_Model_Observer</class>
86
- <method>hookCartSaveAddress</method>
87
- </retail_product_view>
88
- </observers>
89
- </controller_action_predispatch_checkout_cart_estimatePost>
90
- <sales_quote_save_after>
91
- <observers>
92
- <temando_sales_quote_save_after_handler>
93
- <class>Temando_Temando_Model_Observer</class>
94
- <method>saveDestinationType</method>
95
- <args></args>
96
- </temando_sales_quote_save_after_handler>
97
- </observers>
98
- </sales_quote_save_after>
99
- </events>
100
- </global>
101
- <frontend>
102
- <routers>
103
- <etemando>
104
- <use>standard</use>
105
- <args>
106
- <module>Temando_Temando</module>
107
- <frontName>etemando</frontName>
108
- </args>
109
- </etemando>
110
- </routers>
111
- <layout>
112
- <updates>
113
- <temando>
114
- <file>temando.xml</file>
115
- </temando>
116
- </updates>
117
- </layout>
118
- <translate>
119
- <modules>
120
- <Temando_Temando>
121
- <files>
122
- <default>Temando_Temando.csv</default>
123
- </files>
124
- </Temando_Temando>
125
- </modules>
126
- </translate>
127
- </frontend>
128
- <admin>
129
- <routers>
130
- <temando>
131
- <use>admin</use>
132
- <args>
133
- <module>Temando_Temando</module>
134
- <frontName>temando</frontName>
135
- </args>
136
- </temando>
137
- </routers>
138
- </admin>
139
- <adminhtml>
140
- <layout>
141
- <updates>
142
- <temando>
143
- <file>temando.xml</file>
144
- </temando>
145
- </updates>
146
- </layout>
147
- <translate>
148
- <modules>
149
- <Temando_Temando>
150
- <files>
151
- <default>Temando_Temando.csv</default>
152
- </files>
153
- </Temando_Temando>
154
- </modules>
155
- </translate>
156
- </adminhtml>
157
- <default>
158
- <temando>
159
- <general>
160
- <active><![CDATA[0]]></active>
161
- <sandbox><![CDATA[1]]></sandbox>
162
- <client><![CDATA[20420]]></client>
163
- <username><![CDATA[TEMANDOTEST]]></username>
164
- <password><![CDATA[temandopass1]]></password>
165
- <title><![CDATA[Temando]]></title>
166
- <payment_type><![CDATA[Account]]></payment_type>
167
- </general>
168
- <options>
169
- <show_product_estimate><![CDATA[1]]></show_product_estimate>
170
- <label_type><![CDATA[Standard]]></label_type>
171
- <show_transit_type><![CDATA[1]]></show_transit_type>
172
- <show_transit_time><![CDATA[1]]></show_transit_time>
173
- </options>
174
- <insurance>
175
- <status><![CDATA[optional]]></status>
176
- </insurance>
177
- <carbon>
178
- <status><![CDATA[optional]]></status>
179
- </carbon>
180
- <footprints>
181
- <status><![CDATA[optional]]></status>
182
- </footprints>
183
- <pricing>
184
- <error_process><![CDATA[view]]></error_process>
185
- <method><![CDATA[dynamic]]></method>
186
- <shipping_fee><![CDATA[0]]></shipping_fee>
187
- <handling_fee><![CDATA[0]]></handling_fee>
188
- <handling_type><![CDATA[F]]></handling_type>
189
- </pricing>
190
- <units>
191
- <measure><![CDATA[Centimetres]]></measure>
192
- <weight><![CDATA[Kilograms]]></weight>
193
- </units>
194
- <defaults>
195
- <class><![CDATA[General Goods]]></class>
196
- <subclass><![CDATA[Household Goods]]></subclass>
197
- <packaging><![CDATA[0]]></packaging>
198
- <fragile><![CDATA[0]]></fragile>
199
- <dangerous><![CDATA[0]]></dangerous>
200
- <length><![CDATA[10]]></length>
201
- <width><![CDATA[10]]></width>
202
- <height><![CDATA[10]]></height>
203
- </defaults>
204
- <origin>
205
- <contact_name><![CDATA[Temando User]]></contact_name>
206
- <company_name><![CDATA[Temando]]></company_name>
207
- <street><![CDATA[Level 4, 140 William Street]]></street>
208
- <city><![CDATA[WOOLLOOMOOLOO]]></city>
209
- <postcode><![CDATA[2011]]></postcode>
210
- <country><![CDATA[AU]]></country>
211
- <region><![CDATA[NSW]]></region>
212
- <type><![CDATA[Business]]></type>
213
- <phone1><![CDATA[02 1234 5678]]></phone1>
214
- <email><![CDATA[sales@temando.com]]></email>
215
- </origin>
216
- </temando>
217
- <carriers>
218
- <temando>
219
- <active>0</active>
220
- <model>temando/shipping_carrier_temando</model>
221
- <allowed_methods>54381,54426,54359,54396,54360,54429,54433,54432,54425,54343,54430,54431,54427,54428,54344,54398,54358,54410</allowed_methods>
222
- <weightunit>Grams</weightunit>
223
- <name>Temando</name>
224
- <title>Shipping Options</title>
225
- <always_use_defaults>0</always_use_defaults>
226
- <specificerrmsg>This shipping method is currently unavailable. If you would like to ship using this shipping method, please contact us.</specificerrmsg>
227
- <sallowspecific>1</sallowspecific>
228
- <specificcountry>AU</specificcountry>
229
- <showmethod></showmethod>
230
- <sort_order>0</sort_order>
231
- </temando>
232
- </carriers>
233
- </default>
234
- </config>
 
 
 
 
1
+ <?xml version="1.0" encoding="UTF-8"?>
2
+ <config>
3
+ <modules>
4
+ <Temando_Temando>
5
+ <version>1.4.5</version>
6
+ </Temando_Temando>
7
+ </modules>
8
+ <global>
9
+ <models>
10
+ <temando>
11
+ <class>Temando_Temando_Model</class>
12
+ <resourceModel>temando_mysql4</resourceModel>
13
+ </temando>
14
+ <temando_mysql4>
15
+ <class>Temando_Temando_Model_Mysql4</class>
16
+ <entities>
17
+ <box><table>temando_box</table></box>
18
+ <quote><table>temando_quote</table></quote>
19
+ <shipment><table>temando_shipment</table></shipment>
20
+ <manifest><table>temando_manifest</table></manifest>
21
+ <carrier><table>temando_carrier</table></carrier>
22
+ </entities>
23
+ </temando_mysql4>
24
+ </models>
25
+ <blocks>
26
+ <temando>
27
+ <class>Temando_Temando_Block</class>
28
+ </temando>
29
+ <checkout>
30
+ <rewrite>
31
+ <cart_shipping>Temando_Temando_Block_Cart_Shipping</cart_shipping>
32
+ </rewrite>
33
+ </checkout>
34
+ </blocks>
35
+ <helpers>
36
+ <temando>
37
+ <class>Temando_Temando_Helper</class>
38
+ </temando>
39
+ </helpers>
40
+ <resources>
41
+ <temando_setup>
42
+ <setup>
43
+ <module>Temando_Temando</module>
44
+ <class>Mage_Eav_Model_Entity_Setup</class>
45
+ </setup>
46
+ <connection>
47
+ <use>core_setup</use>
48
+ </connection>
49
+ </temando_setup>
50
+ <temando_write>
51
+ <connection>
52
+ <use>core_write</use>
53
+ </connection>
54
+ </temando_write>
55
+ <temando_read>
56
+ <connection>
57
+ <use>core_read</use>
58
+ </connection>
59
+ </temando_read>
60
+ </resources>
61
+ <sales>
62
+ <shipping>
63
+ <carriers>
64
+ <temando>
65
+ <class>Temando_Temando_Model_Shipping_Carrier_Temando</class>
66
+ </temando>
67
+ </carriers>
68
+ </shipping>
69
+ </sales>
70
+ <events>
71
+ <sales_order_place_after>
72
+ <observers>
73
+ <temando_sales_order_place_after_handler>
74
+ <type>model</type>
75
+ <class>Temando_Temando_Model_Observer</class>
76
+ <method>createTemandoShipment</method>
77
+ <args></args>
78
+ </temando_sales_order_place_after_handler>
79
+ </observers>
80
+ </sales_order_place_after>
81
+ <controller_action_predispatch_checkout_cart_estimatePost>
82
+ <observers>
83
+ <retail_product_view>
84
+ <type>singleton</type>
85
+ <class>Temando_Temando_Model_Observer</class>
86
+ <method>hookCartSaveAddress</method>
87
+ </retail_product_view>
88
+ </observers>
89
+ </controller_action_predispatch_checkout_cart_estimatePost>
90
+ <sales_quote_save_after>
91
+ <observers>
92
+ <temando_sales_quote_save_after_handler>
93
+ <class>Temando_Temando_Model_Observer</class>
94
+ <method>saveDestinationType</method>
95
+ <args></args>
96
+ </temando_sales_quote_save_after_handler>
97
+ </observers>
98
+ </sales_quote_save_after>
99
+ </events>
100
+ </global>
101
+ <frontend>
102
+ <routers>
103
+ <etemando>
104
+ <use>standard</use>
105
+ <args>
106
+ <module>Temando_Temando</module>
107
+ <frontName>etemando</frontName>
108
+ </args>
109
+ </etemando>
110
+ </routers>
111
+ <layout>
112
+ <updates>
113
+ <temando>
114
+ <file>temando.xml</file>
115
+ </temando>
116
+ </updates>
117
+ </layout>
118
+ <translate>
119
+ <modules>
120
+ <Temando_Temando>
121
+ <files>
122
+ <default>Temando_Temando.csv</default>
123
+ </files>
124
+ </Temando_Temando>
125
+ </modules>
126
+ </translate>
127
+ </frontend>
128
+ <admin>
129
+ <routers>
130
+ <temando>
131
+ <use>admin</use>
132
+ <args>
133
+ <module>Temando_Temando</module>
134
+ <frontName>temando</frontName>
135
+ </args>
136
+ </temando>
137
+ </routers>
138
+ </admin>
139
+ <adminhtml>
140
+ <layout>
141
+ <updates>
142
+ <temando>
143
+ <file>temando.xml</file>
144
+ </temando>
145
+ </updates>
146
+ </layout>
147
+ <translate>
148
+ <modules>
149
+ <Temando_Temando>
150
+ <files>
151
+ <default>Temando_Temando.csv</default>
152
+ </files>
153
+ </Temando_Temando>
154
+ </modules>
155
+ </translate>
156
+ </adminhtml>
157
+ <default>
158
+ <temando>
159
+ <general>
160
+ <active><![CDATA[0]]></active>
161
+ <sandbox><![CDATA[1]]></sandbox>
162
+ <client><![CDATA[20420]]></client>
163
+ <username><![CDATA[TEMANDOTEST]]></username>
164
+ <password><![CDATA[temandopass1]]></password>
165
+ <title><![CDATA[Temando]]></title>
166
+ <payment_type><![CDATA[Account]]></payment_type>
167
+ </general>
168
+ <options>
169
+ <show_product_estimate><![CDATA[1]]></show_product_estimate>
170
+ <label_type><![CDATA[Standard]]></label_type>
171
+ <show_transit_type><![CDATA[1]]></show_transit_type>
172
+ <show_transit_time><![CDATA[1]]></show_transit_time>
173
+ </options>
174
+ <insurance>
175
+ <status><![CDATA[optional]]></status>
176
+ </insurance>
177
+ <carbon>
178
+ <status><![CDATA[optional]]></status>
179
+ </carbon>
180
+ <footprints>
181
+ <status><![CDATA[optional]]></status>
182
+ </footprints>
183
+ <pricing>
184
+ <error_process><![CDATA[view]]></error_process>
185
+ <method><![CDATA[dynamic]]></method>
186
+ <shipping_fee><![CDATA[0]]></shipping_fee>
187
+ <handling_fee><![CDATA[0]]></handling_fee>
188
+ <handling_type><![CDATA[F]]></handling_type>
189
+ </pricing>
190
+ <units>
191
+ <measure><![CDATA[Centimetres]]></measure>
192
+ <weight><![CDATA[Kilograms]]></weight>
193
+ </units>
194
+ <defaults>
195
+ <class><![CDATA[General Goods]]></class>
196
+ <subclass><![CDATA[Household Goods]]></subclass>
197
+ <packaging><![CDATA[0]]></packaging>
198
+ <fragile><![CDATA[0]]></fragile>
199
+ <dangerous><![CDATA[0]]></dangerous>
200
+ <length><![CDATA[10]]></length>
201
+ <width><![CDATA[10]]></width>
202
+ <height><![CDATA[10]]></height>
203
+ </defaults>
204
+ <origin>
205
+ <contact_name><![CDATA[Temando User]]></contact_name>
206
+ <company_name><![CDATA[Temando]]></company_name>
207
+ <street><![CDATA[Level 4, 140 William Street]]></street>
208
+ <city><![CDATA[WOOLLOOMOOLOO]]></city>
209
+ <postcode><![CDATA[2011]]></postcode>
210
+ <country><![CDATA[AU]]></country>
211
+ <region><![CDATA[NSW]]></region>
212
+ <type><![CDATA[Business]]></type>
213
+ <phone1><![CDATA[02 1234 5678]]></phone1>
214
+ <email><![CDATA[sales@temando.com]]></email>
215
+ </origin>
216
+ <avs>
217
+ <frontend><![CDATA[1]]></frontend>
218
+ <backend><![CDATA[1]]></backend>
219
+ </avs>
220
+ </temando>
221
+ <carriers>
222
+ <temando>
223
+ <active>0</active>
224
+ <model>temando/shipping_carrier_temando</model>
225
+ <allowed_methods>54381,54426,54359,54396,54360,54429,54433,54432,54425,54343,54430,54431,54427,54428,54344,54398,54358,54410</allowed_methods>
226
+ <weightunit>Grams</weightunit>
227
+ <name>Temando</name>
228
+ <title>Shipping Options</title>
229
+ <always_use_defaults>0</always_use_defaults>
230
+ <specificerrmsg>This shipping method is currently unavailable. If you would like to ship using this shipping method, please contact us.</specificerrmsg>
231
+ <sallowspecific>1</sallowspecific>
232
+ <specificcountry>AU</specificcountry>
233
+ <showmethod></showmethod>
234
+ <sort_order>0</sort_order>
235
+ </temando>
236
+ </carriers>
237
+ </default>
238
+ </config>
app/code/community/Temando/Temando/etc/system.xml CHANGED
@@ -19,10 +19,19 @@
19
  <show_in_store>1</show_in_store>
20
  <comment><![CDATA[<div style="padding:10px;background-color:#fff;border:1px solid #ddd;margin-bottom:7px;">If you don't have a Temando account, you can <a href="https://www.temando.com/register/" target="_blank">Sign Up</a> immediately.</div>]]></comment>
21
  <fields>
 
 
 
 
 
 
 
 
 
22
  <sandbox translate="label">
23
  <label>Sandbox</label>
24
  <frontend_type>select</frontend_type>
25
- <sort_order>20</sort_order>
26
  <source_model>adminhtml/system_config_source_yesno</source_model>
27
  <show_in_default>1</show_in_default>
28
  <show_in_website>1</show_in_website>
@@ -32,7 +41,7 @@
32
  <client>
33
  <label>Client ID</label>
34
  <frontend_type>text</frontend_type>
35
- <sort_order>30</sort_order>
36
  <frontend_model>temando/adminhtml_system_config_form_field_required</frontend_model>
37
  <backend_model>temando/system_config_backend_form_field_required_text</backend_model>
38
  <show_in_default>1</show_in_default>
@@ -44,7 +53,7 @@
44
  <frontend_type>text</frontend_type>
45
  <frontend_model>temando/adminhtml_system_config_form_field_required</frontend_model>
46
  <backend_model>temando/system_config_backend_form_field_required_text</backend_model>
47
- <sort_order>40</sort_order>
48
  <show_in_default>1</show_in_default>
49
  <show_in_website>1</show_in_website>
50
  <show_in_store>1</show_in_store>
@@ -54,7 +63,7 @@
54
  <frontend_type>password</frontend_type>
55
  <frontend_model>temando/adminhtml_system_config_form_field_required</frontend_model>
56
  <backend_model>temando/system_config_backend_form_field_required_text</backend_model>
57
- <sort_order>50</sort_order>
58
  <show_in_default>1</show_in_default>
59
  <show_in_website>1</show_in_website>
60
  <show_in_store>1</show_in_store>
@@ -63,7 +72,7 @@
63
  <label>Payment Type</label>
64
  <frontend_type>select</frontend_type>
65
  <source_model>temando/system_config_source_payment</source_model>
66
- <sort_order>60</sort_order>
67
  <show_in_default>1</show_in_default>
68
  <show_in_website>1</show_in_website>
69
  <show_in_store>1</show_in_store>
@@ -454,7 +463,6 @@
454
  <region translate="label">
455
  <label>Region/State</label>
456
  <frontend_type>text</frontend_type>
457
- <frontend_model>temando/adminhtml_system_config_form_field_required</frontend_model>
458
  <sort_order>70</sort_order>
459
  <show_in_default>1</show_in_default>
460
  <show_in_website>0</show_in_website>
@@ -548,6 +556,36 @@
548
  </warehouse_button>
549
  </fields>
550
  </origin>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
551
  </groups>
552
  </temando>
553
  <carriers>
19
  <show_in_store>1</show_in_store>
20
  <comment><![CDATA[<div style="padding:10px;background-color:#fff;border:1px solid #ddd;margin-bottom:7px;">If you don't have a Temando account, you can <a href="https://www.temando.com/register/" target="_blank">Sign Up</a> immediately.</div>]]></comment>
21
  <fields>
22
+ <version translate="label">
23
+ <label>Version</label>
24
+ <frontend_type>text</frontend_type>
25
+ <frontend_model>temando/adminhtml_system_config_form_field_version</frontend_model>
26
+ <sort_order>20</sort_order>
27
+ <show_in_default>1</show_in_default>
28
+ <show_in_website>0</show_in_website>
29
+ <show_in_store>0</show_in_store>
30
+ </version>
31
  <sandbox translate="label">
32
  <label>Sandbox</label>
33
  <frontend_type>select</frontend_type>
34
+ <sort_order>30</sort_order>
35
  <source_model>adminhtml/system_config_source_yesno</source_model>
36
  <show_in_default>1</show_in_default>
37
  <show_in_website>1</show_in_website>
41
  <client>
42
  <label>Client ID</label>
43
  <frontend_type>text</frontend_type>
44
+ <sort_order>40</sort_order>
45
  <frontend_model>temando/adminhtml_system_config_form_field_required</frontend_model>
46
  <backend_model>temando/system_config_backend_form_field_required_text</backend_model>
47
  <show_in_default>1</show_in_default>
53
  <frontend_type>text</frontend_type>
54
  <frontend_model>temando/adminhtml_system_config_form_field_required</frontend_model>
55
  <backend_model>temando/system_config_backend_form_field_required_text</backend_model>
56
+ <sort_order>50</sort_order>
57
  <show_in_default>1</show_in_default>
58
  <show_in_website>1</show_in_website>
59
  <show_in_store>1</show_in_store>
63
  <frontend_type>password</frontend_type>
64
  <frontend_model>temando/adminhtml_system_config_form_field_required</frontend_model>
65
  <backend_model>temando/system_config_backend_form_field_required_text</backend_model>
66
+ <sort_order>60</sort_order>
67
  <show_in_default>1</show_in_default>
68
  <show_in_website>1</show_in_website>
69
  <show_in_store>1</show_in_store>
72
  <label>Payment Type</label>
73
  <frontend_type>select</frontend_type>
74
  <source_model>temando/system_config_source_payment</source_model>
75
+ <sort_order>70</sort_order>
76
  <show_in_default>1</show_in_default>
77
  <show_in_website>1</show_in_website>
78
  <show_in_store>1</show_in_store>
463
  <region translate="label">
464
  <label>Region/State</label>
465
  <frontend_type>text</frontend_type>
 
466
  <sort_order>70</sort_order>
467
  <show_in_default>1</show_in_default>
468
  <show_in_website>0</show_in_website>
556
  </warehouse_button>
557
  </fields>
558
  </origin>
559
+ <avs translate="label">
560
+ <label>Address Validation System</label>
561
+ <frontend_model>temando/adminhtml_system_config_form_fieldset_general</frontend_model>
562
+ <sort_order>150</sort_order>
563
+ <show_in_default>1</show_in_default>
564
+ <show_in_website>1</show_in_website>
565
+ <show_in_store>1</show_in_store>
566
+ <fields>
567
+ <frontend translate="label">
568
+ <label>Enabled on Front-end</label>
569
+ <frontend_type>select</frontend_type>
570
+ <source_model>adminhtml/system_config_source_yesno</source_model>
571
+ <sort_order>10</sort_order>
572
+ <show_in_default>1</show_in_default>
573
+ <show_in_website>1</show_in_website>
574
+ <show_in_store>1</show_in_store>
575
+ <comment><![CDATA[Use JavaScript Address Validation System on Frontend]]></comment>
576
+ </frontend>
577
+ <backend translate="label">
578
+ <label>Enabled on Back-end</label>
579
+ <frontend_type>select</frontend_type>
580
+ <source_model>adminhtml/system_config_source_yesno</source_model>
581
+ <sort_order>20</sort_order>
582
+ <show_in_default>1</show_in_default>
583
+ <show_in_website>0</show_in_website>
584
+ <show_in_store>0</show_in_store>
585
+ <comment><![CDATA[Use JavaScript Address Validation System on Backend]]></comment>
586
+ </backend>
587
+ </fields>
588
+ </avs>
589
  </groups>
590
  </temando>
591
  <carriers>
app/code/community/Temando/Temando/sql/temando_setup/mysql4-install-1.0.0.php CHANGED
@@ -1,303 +1,319 @@
1
- <?php
2
-
3
- set_time_limit(0);
4
-
5
- /* @var $this Mage_Eav_Model_Entity_Setup */
6
- /* @var $installer Mage_Eav_Model_Entity_Setup */
7
-
8
- $installer = $this;
9
- $installer->startSetup();
10
-
11
- // Add custom Temando attributes
12
- $installer->addAttributeGroup('catalog_product', 'Default', 'Temando', 90);
13
- $installer->addAttribute('catalog_product', 'temando_packaging_mode',
14
- array(
15
- 'type' => 'int',
16
- 'label' => 'Packaging Mode',
17
- 'group' => 'Temando',
18
- 'global' => Mage_Catalog_Model_Resource_Eav_Attribute::SCOPE_GLOBAL,
19
- 'source' => 'temando/entity_attribute_source_packaging_mode',
20
- 'input' => 'select',
21
- 'default' => false,
22
- 'visible' => true,
23
- 'required' => false,
24
- 'user_defined' => false,
25
- 'searchable' => true,
26
- 'filterable' => true,
27
- 'comparable' => false,
28
- 'visible_on_front' => false,
29
- 'unique' => false
30
- )
31
- );
32
-
33
- $installer->addAttribute('catalog_product', 'temando_packaging',
34
- array(
35
- 'type' => 'varchar',
36
- 'label' => 'Packaging',
37
- 'group' => 'Temando',
38
- 'global' => Mage_Catalog_Model_Resource_Eav_Attribute::SCOPE_GLOBAL,
39
- 'source' => 'temando/entity_attribute_source_packaging',
40
- 'input' => 'select',
41
- 'visible' => true,
42
- 'required' => false,
43
- 'user_defined' => false,
44
- 'searchable' => false,
45
- 'filterable' => false,
46
- 'comparable' => false,
47
- 'visible_on_front' => false,
48
- 'unique' => false
49
- )
50
- );
51
-
52
- $installer->addAttribute('catalog_product', 'temando_fragile',
53
- array(
54
- 'type' => 'int',
55
- 'label' => 'Fragile',
56
- 'group' => 'Temando',
57
- 'global' => Mage_Catalog_Model_Resource_Eav_Attribute::SCOPE_GLOBAL,
58
- 'source' => 'eav/entity_attribute_source_boolean',
59
- 'input' => 'select',
60
- 'default' => false,
61
- 'visible' => true,
62
- 'required' => false,
63
- 'user_defined' => false,
64
- 'searchable' => false,
65
- 'filterable' => false,
66
- 'comparable' => false,
67
- 'visible_on_front' => false,
68
- 'unique' => false
69
- )
70
- );
71
-
72
- $installer->addAttribute('catalog_product', 'temando_length',
73
- array(
74
- 'type' => 'decimal',
75
- 'label' => 'Length',
76
- 'group' => 'Temando',
77
- 'global' => Mage_Catalog_Model_Resource_Eav_Attribute::SCOPE_GLOBAL,
78
- 'visible' => true,
79
- 'required' => false,
80
- 'user_defined' => false,
81
- 'searchable' => false,
82
- 'filterable' => false,
83
- 'comparable' => false,
84
- 'visible_on_front' => false,
85
- 'unique' => false
86
- )
87
- );
88
-
89
- $installer->addAttribute('catalog_product', 'temando_width',
90
- array(
91
- 'type' => 'decimal',
92
- 'label' => 'Width',
93
- 'group' => 'Temando',
94
- 'global' => Mage_Catalog_Model_Resource_Eav_Attribute::SCOPE_GLOBAL,
95
- 'visible' => true,
96
- 'required' => false,
97
- 'user_defined' => false,
98
- 'searchable' => false,
99
- 'filterable' => false,
100
- 'comparable' => false,
101
- 'visible_on_front' => false,
102
- 'unique' => false
103
- )
104
- );
105
-
106
- $installer->addAttribute('catalog_product', 'temando_height',
107
- array(
108
- 'type' => 'decimal',
109
- 'label' => 'Height',
110
- 'group' => 'Temando',
111
- 'global' => Mage_Catalog_Model_Resource_Eav_Attribute::SCOPE_GLOBAL,
112
- 'visible' => true,
113
- 'required' => false,
114
- 'user_defined' => false,
115
- 'searchable' => false,
116
- 'filterable' => false,
117
- 'comparable' => false,
118
- 'visible_on_front' => false,
119
- 'unique' => false
120
- )
121
- );
122
-
123
- // Create custom tables
124
- $installer->run("
125
- DROP TABLE IF EXISTS {$this->getTable('temando_carrier')};
126
- CREATE TABLE {$this->getTable('temando_carrier')} (
127
- `id` int(13) UNSIGNED NOT NULL AUTO_INCREMENT,
128
- `carrier_id` bigint(20) NOT NULL,
129
- `company_name` varchar(250) NOT NULL,
130
- `company_contact` text NOT NULL,
131
- `street_address` text NOT NULL,
132
- `street_suburb` varchar(255) NOT NULL,
133
- `street_city` varchar(255) NOT NULL,
134
- `street_state` varchar(255) NOT NULL,
135
- `street_postcode` varchar(255) NOT NULL,
136
- `street_country` varchar(255) NOT NULL,
137
- `postal_address` text NOT NULL,
138
- `postal_suburb` varchar(255) NOT NULL,
139
- `postal_city` varchar(255) NOT NULL,
140
- `postal_state` varchar(255) NOT NULL,
141
- `postal_postcode` varchar(255) NOT NULL,
142
- `postal_country` varchar(255) NOT NULL,
143
- `phone` varchar(255) NOT NULL,
144
- `email` varchar(255) NOT NULL,
145
- `website` varchar(255) NOT NULL,
146
- PRIMARY KEY (`id`)
147
- ) ENGINE=InnoDB DEFAULT CHARSET=utf8;
148
-
149
- INSERT INTO {$this->getTable('temando_carrier')} (`id`, `carrier_id`, `company_name`) VALUES
150
- (1, 54381, 'Allied Express'),
151
- (2, 54426, 'Allied Express (Bulk)'),
152
- (3, 54359, 'Startrack'),
153
- (4, 54396, 'Startrack - Auth To Leave'),
154
- (5, 54360, 'Bluestar Logistics'),
155
- (6, 54429, 'Bluestar Logistics Bulk'),
156
- (7, 54433, 'Capital Transport Courier'),
157
- (8, 54432, 'Capital Transport HDS'),
158
- (9, 54425, 'Couriers Please'),
159
- (10, 54343, 'DHL'),
160
- (11, 54430, 'DHL MultiZone'),
161
- (12, 54431, 'DHL SingleZone'),
162
- (13, 54427, 'Fastway Couriers Adhoc'),
163
- (14, 54428, 'Fastway Couriers Bulk'),
164
- (15, 54344, 'Hunter Express'),
165
- (16, 54398, 'Hunter Express (bulk)'),
166
- (17, 54358, 'Mainfreight'),
167
- (18, 54410, 'Northline');
168
- ");
169
-
170
- $installer->run("
171
- DROP TABLE IF EXISTS {$this->getTable('temando_quote')};
172
- CREATE TABLE {$this->getTable('temando_quote')} (
173
- `id` bigint(20) UNSIGNED NOT NULL AUTO_INCREMENT,
174
- `magento_quote_id` int(10) UNSIGNED NOT NULL,
175
- `carrier_id` int(13) UNSIGNED NOT NULL,
176
- `accepted` boolean NOT NULL DEFAULT '0',
177
- `total_price` decimal(12, 4) NOT NULL,
178
- `base_price` decimal(12, 4) NOT NULL,
179
- `tax` decimal(12, 4) NOT NULL,
180
- `insurance_total_price` decimal(12, 4) NOT NULL,
181
- `carbon_total_price` decimal(12, 4) NOT NULL,
182
- `footprints_total_price` decimal(12, 4) NOT NULL,
183
- `currency` varchar(10) NOT NULL,
184
- `delivery_method` text NOT NULL,
185
- `eta_from` int(10) UNSIGNED NOT NULL DEFAULT '0',
186
- `eta_to` int(10) UNSIGNED NOT NULL DEFAULT '0',
187
- `guaranteed_eta` boolean NOT NULL DEFAULT '0',
188
- `extras` TEXT NOT NULL,
189
- PRIMARY KEY (`id`),
190
- INDEX (`carrier_id`),
191
- CONSTRAINT `fk_carrier_id`
192
- FOREIGN KEY (`carrier_id`)
193
- REFERENCES {$this->getTable('temando_carrier')} (`id`)
194
- ON DELETE CASCADE
195
- ON UPDATE CASCADE
196
- ) ENGINE=InnoDB DEFAULT CHARSET=utf8;
197
- ");
198
-
199
- $installer->run("
200
- DROP TABLE IF EXISTS {$this->getTable('temando_shipment')};
201
- CREATE TABLE {$this->getTable('temando_shipment')} (
202
- `id` bigint(20) UNSIGNED NOT NULL AUTO_INCREMENT,
203
- `order_id` int(10) UNSIGNED NOT NULL,
204
- `customer_selected_quote_id` bigint(20) UNSIGNED NULL DEFAULT NULL,
205
- `customer_selected_options` TEXT NOT NULL,
206
- `customer_selected_quote_description` TEXT NOT NULL,
207
- `admin_selected_quote_id` bigint(20) UNSIGNED NULL DEFAULT NULL,
208
- `anticipated_cost` decimal(12,4) UNSIGNED NOT NULL,
209
- `status` int(10) NOT NULL DEFAULT '0',
210
- `booking_request_id` int(13) UNSIGNED NOT NULL,
211
- `booking_number` varchar(255) NOT NULL,
212
- `consignment_number` varchar(255) NOT NULL,
213
- `consignment_document` longtext NOT NULL,
214
- `consignment_document_type` varchar(32) NOT NULL,
215
- `label_document` longtext not null,
216
- `label_document_type` varchar(32) NOT NULL,
217
- `destination_contact_name` varchar(255) NOT NULL,
218
- `destination_company_name` varchar(255) NOT NULL,
219
- `destination_street` varchar(255) NOT NULL,
220
- `destination_city` varchar(255) NOT NULL,
221
- `destination_postcode` varchar(255) NOT NULL,
222
- `destination_region` varchar(255) NOT NULL,
223
- `destination_country` varchar(255) NOT NULL,
224
- `destination_phone` varchar(255) NOT NULL,
225
- `destination_email` varchar(255) NOT NULL,
226
- `ready_date` DATE NULL DEFAULT NULL,
227
- `ready_time` VARCHAR(2) NOT NULL,
228
- PRIMARY KEY (`id`)
229
- ) ENGINE=InnoDB DEFAULT CHARSET=utf8;
230
- ");
231
-
232
-
233
- $installer->run("
234
- DROP TABLE IF EXISTS {$this->getTable('temando_box')};
235
- CREATE TABLE {$this->getTable('temando_box')} (
236
- `id` bigint(20) unsigned NOT NULL AUTO_INCREMENT,
237
- `shipment_id` int(13) NOT NULL,
238
- `comment` text NOT NULL,
239
- `qty` int(11) NOT NULL DEFAULT '1',
240
- `value` decimal(12,4) NOT NULL,
241
- `length` decimal(12,4) NOT NULL,
242
- `width` decimal(12,4) NOT NULL,
243
- `height` decimal(12,4) NOT NULL,
244
- `measure_unit` varchar(255) NOT NULL,
245
- `weight` decimal(12,4) NOT NULL,
246
- `weight_unit` varchar(255) NOT NULL,
247
- `fragile` tinyint(1) NOT NULL DEFAULT '0',
248
- `packaging` int(255) NOT NULL,
249
- PRIMARY KEY (`id`),
250
- KEY `shipment_id` (`shipment_id`)
251
- ) ENGINE=InnoDB DEFAULT CHARSET=utf8;
252
- ");
253
-
254
- $installer->run("
255
- DROP TABLE IF EXISTS {$this->getTable('temando_manifest')};
256
- CREATE TABLE {$this->getTable('temando_manifest')} (
257
- `id` int(11) NOT NULL AUTO_INCREMENT,
258
- `location_id` varchar(255) NOT NULL DEFAULT '',
259
- `carrier_id` int(10) NOT NULL DEFAULT 0,
260
- `start_date` date NOT NULL,
261
- `end_date` date NOT NULL,
262
- `manifest_document_type` varchar(250) NOT NULL DEFAULT '',
263
- `manifest_document` longtext NOT NULL,
264
- `label_document_type` varchar(250) NOT NULL DEFAULT '',
265
- `label_document` longtext NOT NULL,
266
- `type` varchar(255) NOT NULL DEFAULT 'Awaiting Confirmation',
267
- `created_at` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
268
- PRIMARY KEY (`id`),
269
- INDEX (`type`)
270
- ) ENGINE=InnoDB DEFAULT CHARSET=utf8;
271
- ;");
272
-
273
-
274
- // Insert a list of states into the regions database. Magento will then pick
275
- // these up when displaying addresses and allow the user to select from a drop-down
276
- // list, rather than having to type them in manually.
277
- $regions = array(
278
- array('code' => 'ACT', 'name' => 'Australia Capital Territory'),
279
- array('code' => 'NSW', 'name' => 'New South Wales'),
280
- array('code' => 'NT', 'name' => 'Northern Territory'),
281
- array('code' => 'QLD', 'name' => 'Queensland'),
282
- array('code' => 'SA', 'name' => 'South Australia'),
283
- array('code' => 'TAS', 'name' => 'Tasmania'),
284
- array('code' => 'VIC', 'name' => 'Victoria'),
285
- array('code' => 'WA', 'name' => 'Western Australia')
286
- );
287
-
288
- $db = Mage::getSingleton('core/resource')->getConnection('core_read');
289
-
290
- foreach ($regions as $region) {
291
- // Check if this region has already been added
292
- $result = $db->fetchOne("SELECT code FROM " . $this->getTable('directory_country_region') . " WHERE `country_id` = 'AU' AND `code` = '" . $region['code'] . "'");
293
- if ($result != $region['code']) {
294
- $installer->run(
295
- "INSERT INTO `{$this->getTable('directory_country_region')}` (`country_id`, `code`, `default_name`) VALUES
296
- ('AU', '" . $region['code'] . "', '" . $region['name'] . "');
297
- INSERT INTO `{$this->getTable('directory_country_region_name')}` (`locale`, `region_id`, `name`) VALUES
298
- ('en_US', LAST_INSERT_ID(), '" . $region['name'] . "'), ('en_AU', LAST_INSERT_ID(), '" . $region['name'] . "');"
299
- );
300
- }
301
- }
302
-
303
- $installer->endSetup();
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ set_time_limit(0);
4
+
5
+ /* @var $this Mage_Eav_Model_Entity_Setup */
6
+ /* @var $installer Mage_Eav_Model_Entity_Setup */
7
+
8
+ $installer = $this;
9
+ $installer->startSetup();
10
+
11
+ // Add custom Temando attributes
12
+ $installer->addAttributeGroup('catalog_product', 'Default', 'Temando', 90);
13
+ $installer->addAttribute(
14
+ 'catalog_product',
15
+ 'temando_packaging_mode',
16
+ array(
17
+ 'type' => 'int',
18
+ 'label' => 'Packaging Mode',
19
+ 'group' => 'Temando',
20
+ 'global' => Mage_Catalog_Model_Resource_Eav_Attribute::SCOPE_GLOBAL,
21
+ 'source' => 'temando/entity_attribute_source_packaging_mode',
22
+ 'input' => 'select',
23
+ 'default' => false,
24
+ 'visible' => true,
25
+ 'required' => false,
26
+ 'user_defined' => false,
27
+ 'searchable' => true,
28
+ 'filterable' => true,
29
+ 'comparable' => false,
30
+ 'visible_on_front' => false,
31
+ 'unique' => false
32
+ )
33
+ );
34
+
35
+ $installer->addAttribute(
36
+ 'catalog_product',
37
+ 'temando_packaging',
38
+ array(
39
+ 'type' => 'varchar',
40
+ 'label' => 'Packaging',
41
+ 'group' => 'Temando',
42
+ 'global' => Mage_Catalog_Model_Resource_Eav_Attribute::SCOPE_GLOBAL,
43
+ 'source' => 'temando/entity_attribute_source_packaging',
44
+ 'input' => 'select',
45
+ 'visible' => true,
46
+ 'required' => false,
47
+ 'user_defined' => false,
48
+ 'searchable' => false,
49
+ 'filterable' => false,
50
+ 'comparable' => false,
51
+ 'visible_on_front' => false,
52
+ 'unique' => false
53
+ )
54
+ );
55
+
56
+ $installer->addAttribute(
57
+ 'catalog_product',
58
+ 'temando_fragile',
59
+ array(
60
+ 'type' => 'int',
61
+ 'label' => 'Fragile',
62
+ 'group' => 'Temando',
63
+ 'global' => Mage_Catalog_Model_Resource_Eav_Attribute::SCOPE_GLOBAL,
64
+ 'source' => 'eav/entity_attribute_source_boolean',
65
+ 'input' => 'select',
66
+ 'default' => false,
67
+ 'visible' => true,
68
+ 'required' => false,
69
+ 'user_defined' => false,
70
+ 'searchable' => false,
71
+ 'filterable' => false,
72
+ 'comparable' => false,
73
+ 'visible_on_front' => false,
74
+ 'unique' => false
75
+ )
76
+ );
77
+
78
+ $installer->addAttribute(
79
+ 'catalog_product',
80
+ 'temando_length',
81
+ array(
82
+ 'type' => 'decimal',
83
+ 'label' => 'Length',
84
+ 'group' => 'Temando',
85
+ 'global' => Mage_Catalog_Model_Resource_Eav_Attribute::SCOPE_GLOBAL,
86
+ 'visible' => true,
87
+ 'required' => false,
88
+ 'user_defined' => false,
89
+ 'searchable' => false,
90
+ 'filterable' => false,
91
+ 'comparable' => false,
92
+ 'visible_on_front' => false,
93
+ 'unique' => false
94
+ )
95
+ );
96
+
97
+ $installer->addAttribute(
98
+ 'catalog_product',
99
+ 'temando_width',
100
+ array(
101
+ 'type' => 'decimal',
102
+ 'label' => 'Width',
103
+ 'group' => 'Temando',
104
+ 'global' => Mage_Catalog_Model_Resource_Eav_Attribute::SCOPE_GLOBAL,
105
+ 'visible' => true,
106
+ 'required' => false,
107
+ 'user_defined' => false,
108
+ 'searchable' => false,
109
+ 'filterable' => false,
110
+ 'comparable' => false,
111
+ 'visible_on_front' => false,
112
+ 'unique' => false
113
+ )
114
+ );
115
+
116
+ $installer->addAttribute(
117
+ 'catalog_product',
118
+ 'temando_height',
119
+ array(
120
+ 'type' => 'decimal',
121
+ 'label' => 'Height',
122
+ 'group' => 'Temando',
123
+ 'global' => Mage_Catalog_Model_Resource_Eav_Attribute::SCOPE_GLOBAL,
124
+ 'visible' => true,
125
+ 'required' => false,
126
+ 'user_defined' => false,
127
+ 'searchable' => false,
128
+ 'filterable' => false,
129
+ 'comparable' => false,
130
+ 'visible_on_front' => false,
131
+ 'unique' => false
132
+ )
133
+ );
134
+
135
+ // Create custom tables
136
+ $installer->run(
137
+ "DROP TABLE IF EXISTS {$this->getTable('temando_carrier')};
138
+ CREATE TABLE {$this->getTable('temando_carrier')} (
139
+ `id` int(13) UNSIGNED NOT NULL AUTO_INCREMENT,
140
+ `carrier_id` bigint(20) NOT NULL,
141
+ `company_name` varchar(250) NOT NULL,
142
+ `company_contact` text NOT NULL,
143
+ `street_address` text NOT NULL,
144
+ `street_suburb` varchar(255) NOT NULL,
145
+ `street_city` varchar(255) NOT NULL,
146
+ `street_state` varchar(255) NOT NULL,
147
+ `street_postcode` varchar(255) NOT NULL,
148
+ `street_country` varchar(255) NOT NULL,
149
+ `postal_address` text NOT NULL,
150
+ `postal_suburb` varchar(255) NOT NULL,
151
+ `postal_city` varchar(255) NOT NULL,
152
+ `postal_state` varchar(255) NOT NULL,
153
+ `postal_postcode` varchar(255) NOT NULL,
154
+ `postal_country` varchar(255) NOT NULL,
155
+ `phone` varchar(255) NOT NULL,
156
+ `email` varchar(255) NOT NULL,
157
+ `website` varchar(255) NOT NULL,
158
+ PRIMARY KEY (`id`)
159
+ ) ENGINE=InnoDB DEFAULT CHARSET=utf8;
160
+
161
+ INSERT INTO {$this->getTable('temando_carrier')} (`id`, `carrier_id`, `company_name`) VALUES
162
+ (1, 54381, 'Allied Express'),
163
+ (2, 54426, 'Allied Express (Bulk)'),
164
+ (3, 54359, 'Startrack'),
165
+ (4, 54396, 'Startrack - Auth To Leave'),
166
+ (5, 54360, 'Bluestar Logistics'),
167
+ (6, 54429, 'Bluestar Logistics Bulk'),
168
+ (7, 54433, 'Capital Transport Courier'),
169
+ (8, 54432, 'Capital Transport HDS'),
170
+ (9, 54425, 'Couriers Please'),
171
+ (10, 54343, 'DHL'),
172
+ (11, 54430, 'DHL MultiZone'),
173
+ (12, 54431, 'DHL SingleZone'),
174
+ (13, 54427, 'Fastway Couriers Adhoc'),
175
+ (14, 54428, 'Fastway Couriers Bulk'),
176
+ (15, 54344, 'Hunter Express'),
177
+ (16, 54398, 'Hunter Express (bulk)'),
178
+ (17, 54358, 'Mainfreight'),
179
+ (18, 54410, 'Northline');"
180
+ );
181
+
182
+ $installer->run(
183
+ "DROP TABLE IF EXISTS {$this->getTable('temando_quote')};
184
+ CREATE TABLE {$this->getTable('temando_quote')} (
185
+ `id` bigint(20) UNSIGNED NOT NULL AUTO_INCREMENT,
186
+ `magento_quote_id` int(10) UNSIGNED NOT NULL,
187
+ `carrier_id` int(13) UNSIGNED NOT NULL,
188
+ `accepted` boolean NOT NULL DEFAULT '0',
189
+ `total_price` decimal(12, 4) NOT NULL,
190
+ `base_price` decimal(12, 4) NOT NULL,
191
+ `tax` decimal(12, 4) NOT NULL,
192
+ `insurance_total_price` decimal(12, 4) NOT NULL,
193
+ `carbon_total_price` decimal(12, 4) NOT NULL,
194
+ `footprints_total_price` decimal(12, 4) NOT NULL,
195
+ `currency` varchar(10) NOT NULL,
196
+ `delivery_method` text NOT NULL,
197
+ `eta_from` int(10) UNSIGNED NOT NULL DEFAULT '0',
198
+ `eta_to` int(10) UNSIGNED NOT NULL DEFAULT '0',
199
+ `guaranteed_eta` boolean NOT NULL DEFAULT '0',
200
+ `extras` TEXT NOT NULL,
201
+ PRIMARY KEY (`id`),
202
+ INDEX (`carrier_id`),
203
+ CONSTRAINT `fk_carrier_id`
204
+ FOREIGN KEY (`carrier_id`)
205
+ REFERENCES {$this->getTable('temando_carrier')} (`id`)
206
+ ON DELETE CASCADE
207
+ ON UPDATE CASCADE
208
+ ) ENGINE=InnoDB DEFAULT CHARSET=utf8;"
209
+ );
210
+
211
+ $installer->run(
212
+ "DROP TABLE IF EXISTS {$this->getTable('temando_shipment')};
213
+ CREATE TABLE {$this->getTable('temando_shipment')} (
214
+ `id` bigint(20) UNSIGNED NOT NULL AUTO_INCREMENT,
215
+ `order_id` int(10) UNSIGNED NOT NULL,
216
+ `customer_selected_quote_id` bigint(20) UNSIGNED NULL DEFAULT NULL,
217
+ `customer_selected_options` TEXT NOT NULL,
218
+ `customer_selected_quote_description` TEXT NOT NULL,
219
+ `admin_selected_quote_id` bigint(20) UNSIGNED NULL DEFAULT NULL,
220
+ `anticipated_cost` decimal(12,4) UNSIGNED NOT NULL,
221
+ `status` int(10) NOT NULL DEFAULT '0',
222
+ `booking_request_id` int(13) UNSIGNED NOT NULL,
223
+ `booking_number` varchar(255) NOT NULL,
224
+ `consignment_number` varchar(255) NOT NULL,
225
+ `consignment_document` longtext NOT NULL,
226
+ `consignment_document_type` varchar(32) NOT NULL,
227
+ `label_document` longtext not null,
228
+ `label_document_type` varchar(32) NOT NULL,
229
+ `destination_contact_name` varchar(255) NOT NULL,
230
+ `destination_company_name` varchar(255) NOT NULL,
231
+ `destination_street` varchar(255) NOT NULL,
232
+ `destination_city` varchar(255) NOT NULL,
233
+ `destination_postcode` varchar(255) NOT NULL,
234
+ `destination_region` varchar(255) NOT NULL,
235
+ `destination_country` varchar(255) NOT NULL,
236
+ `destination_phone` varchar(255) NOT NULL,
237
+ `destination_email` varchar(255) NOT NULL,
238
+ `ready_date` DATE NULL DEFAULT NULL,
239
+ `ready_time` VARCHAR(2) NOT NULL,
240
+ PRIMARY KEY (`id`)
241
+ ) ENGINE=InnoDB DEFAULT CHARSET=utf8;"
242
+ );
243
+
244
+
245
+ $installer->run(
246
+ "DROP TABLE IF EXISTS {$this->getTable('temando_box')};
247
+ CREATE TABLE {$this->getTable('temando_box')} (
248
+ `id` bigint(20) unsigned NOT NULL AUTO_INCREMENT,
249
+ `shipment_id` int(13) NOT NULL,
250
+ `comment` text NOT NULL,
251
+ `qty` int(11) NOT NULL DEFAULT '1',
252
+ `value` decimal(12,4) NOT NULL,
253
+ `length` decimal(12,4) NOT NULL,
254
+ `width` decimal(12,4) NOT NULL,
255
+ `height` decimal(12,4) NOT NULL,
256
+ `measure_unit` varchar(255) NOT NULL,
257
+ `weight` decimal(12,4) NOT NULL,
258
+ `weight_unit` varchar(255) NOT NULL,
259
+ `fragile` tinyint(1) NOT NULL DEFAULT '0',
260
+ `packaging` int(255) NOT NULL,
261
+ PRIMARY KEY (`id`),
262
+ KEY `shipment_id` (`shipment_id`)
263
+ ) ENGINE=InnoDB DEFAULT CHARSET=utf8;"
264
+ );
265
+
266
+ $installer->run(
267
+ "DROP TABLE IF EXISTS {$this->getTable('temando_manifest')};
268
+ CREATE TABLE {$this->getTable('temando_manifest')} (
269
+ `id` int(11) NOT NULL AUTO_INCREMENT,
270
+ `location_id` varchar(255) NOT NULL DEFAULT '',
271
+ `carrier_id` int(10) NOT NULL DEFAULT 0,
272
+ `start_date` date NOT NULL,
273
+ `end_date` date NOT NULL,
274
+ `manifest_document_type` varchar(250) NOT NULL DEFAULT '',
275
+ `manifest_document` longtext NOT NULL,
276
+ `label_document_type` varchar(250) NOT NULL DEFAULT '',
277
+ `label_document` longtext NOT NULL,
278
+ `type` varchar(255) NOT NULL DEFAULT 'Awaiting Confirmation',
279
+ `created_at` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
280
+ PRIMARY KEY (`id`),
281
+ INDEX (`type`)
282
+ ) ENGINE=InnoDB DEFAULT CHARSET=utf8;;"
283
+ );
284
+
285
+
286
+ // Insert a list of states into the regions database. Magento will then pick
287
+ // these up when displaying addresses and allow the user to select from a drop-down
288
+ // list, rather than having to type them in manually.
289
+ $regions = array(
290
+ array('code' => 'ACT', 'name' => 'Australia Capital Territory'),
291
+ array('code' => 'NSW', 'name' => 'New South Wales'),
292
+ array('code' => 'NT', 'name' => 'Northern Territory'),
293
+ array('code' => 'QLD', 'name' => 'Queensland'),
294
+ array('code' => 'SA', 'name' => 'South Australia'),
295
+ array('code' => 'TAS', 'name' => 'Tasmania'),
296
+ array('code' => 'VIC', 'name' => 'Victoria'),
297
+ array('code' => 'WA', 'name' => 'Western Australia')
298
+ );
299
+
300
+ $db = Mage::getSingleton('core/resource')->getConnection('core_read');
301
+
302
+ foreach ($regions as $region) {
303
+ // Check if this region has already been added
304
+ $result = $db->fetchOne(
305
+ "SELECT code FROM " . $this->getTable('directory_country_region') .
306
+ " WHERE `country_id` = 'AU' AND `code` = '" . $region['code'] . "'"
307
+ );
308
+ if ($result != $region['code']) {
309
+ $installer->run(
310
+ "INSERT INTO `{$this->getTable('directory_country_region')}` (`country_id`, `code`, `default_name`)
311
+ VALUES ('AU', '" . $region['code'] . "', '" . $region['name'] . "');
312
+ INSERT INTO `{$this->getTable('directory_country_region_name')}` (`locale`, `region_id`, `name`) VALUES
313
+ ('en_US', LAST_INSERT_ID(), '" . $region['name'] . "'), ('en_AU', LAST_INSERT_ID(), '" .
314
+ $region['name'] . "');"
315
+ );
316
+ }
317
+ }
318
+
319
+ $installer->endSetup();
app/code/community/Temando/Temando/sql/temando_setup/mysql4-upgrade-1.3.8-1.3.9.php CHANGED
@@ -1,70 +1,72 @@
1
- <?php
2
-
3
- set_time_limit(0);
4
-
5
- /* @var $this Mage_Eav_Model_Entity_Setup */
6
- /* @var $installer Mage_Eav_Model_Entity_Setup */
7
-
8
- $installer = $this;
9
- $installer->startSetup();
10
-
11
- /**
12
- * Remove free shipping option in Temando shipping method
13
- */
14
- $installer->deleteConfigData('carriers/temando/free_shipping_enable');
15
- $installer->deleteConfigData('carriers/temando/free_shipping_subtotal');
16
-
17
- /**
18
- * Remove limited access and pobox from warehouse options
19
- */
20
- $installer->deleteConfigData('temando/origin/limited_access');
21
- $installer->deleteConfigData('temando/origin/pobox');
22
-
23
- /**
24
- * Dangerous Goods Support
25
- */
26
- $installer
27
- ->getConnection()
28
- ->addColumn(
29
- $this->getTable('temando_box'),
30
- 'dangerous',
31
- 'tinyint(1) NOT NULL DEFAULT 0 AFTER `fragile`'
32
- );
33
-
34
- $installer->addAttribute('catalog_product', 'temando_dangerous',
35
- array(
36
- 'type' => 'int',
37
- 'label' => 'Dangerous',
38
- 'group' => 'Temando',
39
- 'global' => Mage_Catalog_Model_Resource_Eav_Attribute::SCOPE_GLOBAL,
40
- 'source' => 'eav/entity_attribute_source_boolean',
41
- 'input' => 'select',
42
- 'default' => false,
43
- 'visible' => true,
44
- 'required' => false,
45
- 'user_defined' => false,
46
- 'searchable' => false,
47
- 'filterable' => false,
48
- 'comparable' => false,
49
- 'visible_on_front' => false,
50
- 'unique' => false
51
- )
52
- );
53
-
54
- $installer
55
- ->getConnection()
56
- ->addColumn(
57
- $this->getTable('temando_shipment'),
58
- 'customer_selected_delivery_options',
59
- 'varchar(500) NULL after `customer_selected_options`'
60
- );
61
-
62
- $installer
63
- ->getConnection()
64
- ->addColumn(
65
- $this->getTable('temando_shipment'),
66
- 'destination_type',
67
- "varchar(30) NOT NULL DEFAULT 'residence' AFTER `destination_email`"
68
- );
69
-
70
- $installer->endSetup();
 
 
1
+ <?php
2
+
3
+ set_time_limit(0);
4
+
5
+ /* @var $this Mage_Eav_Model_Entity_Setup */
6
+ /* @var $installer Mage_Eav_Model_Entity_Setup */
7
+
8
+ $installer = $this;
9
+ $installer->startSetup();
10
+
11
+ /**
12
+ * Remove free shipping option in Temando shipping method
13
+ */
14
+ $installer->deleteConfigData('carriers/temando/free_shipping_enable');
15
+ $installer->deleteConfigData('carriers/temando/free_shipping_subtotal');
16
+
17
+ /**
18
+ * Remove limited access and pobox from warehouse options
19
+ */
20
+ $installer->deleteConfigData('temando/origin/limited_access');
21
+ $installer->deleteConfigData('temando/origin/pobox');
22
+
23
+ /**
24
+ * Dangerous Goods Support
25
+ */
26
+ $installer
27
+ ->getConnection()
28
+ ->addColumn(
29
+ $this->getTable('temando_box'),
30
+ 'dangerous',
31
+ 'tinyint(1) NOT NULL DEFAULT 0 AFTER `fragile`'
32
+ );
33
+
34
+ $installer->addAttribute(
35
+ 'catalog_product',
36
+ 'temando_dangerous',
37
+ array(
38
+ 'type' => 'int',
39
+ 'label' => 'Dangerous',
40
+ 'group' => 'Temando',
41
+ 'global' => Mage_Catalog_Model_Resource_Eav_Attribute::SCOPE_GLOBAL,
42
+ 'source' => 'eav/entity_attribute_source_boolean',
43
+ 'input' => 'select',
44
+ 'default' => false,
45
+ 'visible' => true,
46
+ 'required' => false,
47
+ 'user_defined' => false,
48
+ 'searchable' => false,
49
+ 'filterable' => false,
50
+ 'comparable' => false,
51
+ 'visible_on_front' => false,
52
+ 'unique' => false
53
+ )
54
+ );
55
+
56
+ $installer
57
+ ->getConnection()
58
+ ->addColumn(
59
+ $this->getTable('temando_shipment'),
60
+ 'customer_selected_delivery_options',
61
+ 'varchar(500) NULL after `customer_selected_options`'
62
+ );
63
+
64
+ $installer
65
+ ->getConnection()
66
+ ->addColumn(
67
+ $this->getTable('temando_shipment'),
68
+ 'destination_type',
69
+ "varchar(30) NOT NULL DEFAULT 'residence' AFTER `destination_email`"
70
+ );
71
+
72
+ $installer->endSetup();
app/code/community/Temando/Temando/sql/temando_setup/mysql4-upgrade-1.4.4-1.4.5.php ADDED
@@ -0,0 +1,22 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ set_time_limit(0);
4
+
5
+ /* @var $this Mage_Eav_Model_Entity_Setup */
6
+ /* @var $installer Mage_Eav_Model_Entity_Setup */
7
+ $installer = $this;
8
+ $installer->startSetup();
9
+
10
+ /**
11
+ * Support for anticipated cost currency
12
+ */
13
+
14
+ $installer
15
+ ->getConnection()
16
+ ->addColumn(
17
+ $this->getTable('temando_shipment'),
18
+ 'anticipated_currency',
19
+ 'varchar(3) DEFAULT NULL AFTER `anticipated_cost`'
20
+ );
21
+
22
+ $installer->endSetup();
app/design/adminhtml/default/default/template/temando/temando/origin-avs.phtml CHANGED
@@ -1,3 +1,4 @@
 
1
  <script type="text/javascript">
2
  //<![CDATA[
3
  var address_validation_url = '<?php echo $this->getUrl('etemando/pcs/autocompletecart', array('_secure' => Mage::app()->getStore()->isCurrentlySecure())); ?>';
@@ -9,3 +10,4 @@
9
  );
10
  //]]
11
  </script>
 
1
+ <?php if(Mage::helper('temando')->getConfigData('avs/backend')):?>
2
  <script type="text/javascript">
3
  //<![CDATA[
4
  var address_validation_url = '<?php echo $this->getUrl('etemando/pcs/autocompletecart', array('_secure' => Mage::app()->getStore()->isCurrentlySecure())); ?>';
10
  );
11
  //]]
12
  </script>
13
+ <?php endif;?>
app/design/adminhtml/default/default/template/temando/temando/shipment/anywhere.phtml CHANGED
@@ -103,6 +103,7 @@ $_shipment = $this->getShipment();
103
  </table>
104
  </div>
105
  </div>
 
106
  <script type="text/javascript">
107
  //<[CDATA[
108
  var shipping_estimator_url = '<?php echo $this->getUrl('etemando/pcs/autocompletecart', array('_secure' => Mage::app()->getStore()->isCurrentlySecure())); ?>';
@@ -114,3 +115,4 @@ var avs = new Avs(
114
  );
115
  //]]>
116
  </script>
 
103
  </table>
104
  </div>
105
  </div>
106
+ <?php if(Mage::helper('temando')->getConfigData('avs/backend')):?>
107
  <script type="text/javascript">
108
  //<[CDATA[
109
  var shipping_estimator_url = '<?php echo $this->getUrl('etemando/pcs/autocompletecart', array('_secure' => Mage::app()->getStore()->isCurrentlySecure())); ?>';
115
  );
116
  //]]>
117
  </script>
118
+ <?php endif;?>
app/design/frontend/base/default/template/temando/temando/checkout/cart/shipping.phtml CHANGED
@@ -137,6 +137,7 @@ $business = Temando_Temando_Model_Checkout_Delivery_Options::DESTINATION_BUSINES
137
  </script>
138
  </div>
139
  </div>
 
140
  <script type="text/javascript">
141
  //<[CDATA[
142
  var shipping_estimator_url = '<?php echo $this->getUrl('etemando/pcs/autocompletecart', array('_secure' => Mage::app()->getStore()->isCurrentlySecure())); ?>';
@@ -147,4 +148,5 @@ var avs = new Avs(
147
  'country'
148
  );
149
  //]]>
150
- </script>
 
137
  </script>
138
  </div>
139
  </div>
140
+ <?php if(Mage::helper('temando')->getConfigData('avs/frontend')):?>
141
  <script type="text/javascript">
142
  //<[CDATA[
143
  var shipping_estimator_url = '<?php echo $this->getUrl('etemando/pcs/autocompletecart', array('_secure' => Mage::app()->getStore()->isCurrentlySecure())); ?>';
148
  'country'
149
  );
150
  //]]>
151
+ </script>
152
+ <?php endif;?>
app/design/frontend/base/default/template/temando/temando/customer/address/edit.phtml CHANGED
@@ -163,6 +163,7 @@
163
  new RegionUpdater('country', 'region', 'region_id', <?php echo $this->helper('directory')->getRegionJson() ?>, undefined, 'zip');
164
  //]]>
165
  </script>
 
166
  <script type="text/javascript">
167
  //<![CDATA[
168
  new Avs(
@@ -172,4 +173,5 @@ new Avs(
172
  'country'
173
  );
174
  //]]>
175
- </script>
 
163
  new RegionUpdater('country', 'region', 'region_id', <?php echo $this->helper('directory')->getRegionJson() ?>, undefined, 'zip');
164
  //]]>
165
  </script>
166
+ <?php if(Mage::helper('temando')->getConfigData('avs/frontend')):?>
167
  <script type="text/javascript">
168
  //<![CDATA[
169
  new Avs(
173
  'country'
174
  );
175
  //]]>
176
+ </script>
177
+ <?php endif;?>
app/design/frontend/base/default/template/temando/temando/pcs.phtml CHANGED
@@ -1,19 +1,21 @@
 
1
  <script type="text/javascript">
2
 
3
- <?php if (Mage::getStoreConfig('carriers/temando/active')): ?>
4
- new Avs(
5
- "<?php echo $this->getUrl('etemando/pcs/autocompletecart', array('_secure' => Mage::app()->getStore()->isCurrentlySecure())); ?>",
6
- 'billing:postcode',
7
- 'billing:city',
8
- 'billing:country_id'
9
- );
10
 
11
- new Avs(
12
- "<?php echo $this->getUrl('etemando/pcs/autocompletecart', array('_secure' => Mage::app()->getStore()->isCurrentlySecure())); ?>",
13
- 'shipping:postcode',
14
- 'shipping:city',
15
- 'shipping:country_id'
16
- );
17
- <?php endif;?>
18
 
19
  </script>
 
1
+ <?php if(Mage::helper('temando')->getConfigData('avs/frontend')):?>
2
  <script type="text/javascript">
3
 
4
+ <?php if (Mage::getStoreConfig('carriers/temando/active')): ?>
5
+ new Avs(
6
+ "<?php echo $this->getUrl('etemando/pcs/autocompletecart', array('_secure' => Mage::app()->getStore()->isCurrentlySecure())); ?>",
7
+ 'billing:postcode',
8
+ 'billing:city',
9
+ 'billing:country_id'
10
+ );
11
 
12
+ new Avs(
13
+ "<?php echo $this->getUrl('etemando/pcs/autocompletecart', array('_secure' => Mage::app()->getStore()->isCurrentlySecure())); ?>",
14
+ 'shipping:postcode',
15
+ 'shipping:city',
16
+ 'shipping:country_id'
17
+ );
18
+ <?php endif;?>
19
 
20
  </script>
21
+ <?php endif;?>
app/design/frontend/base/default/template/temando/temando/product/shipping.phtml CHANGED
@@ -43,6 +43,7 @@
43
  </div>
44
  </div>
45
  </div>
 
46
  <script type="text/javascript">
47
  //<![CDATA[
48
  var shipping_estimator_url = '<?php echo $this->getUrl('etemando/pcs/product', array('_secure' => Mage::app()->getStore()->isCurrentlySecure())); ?>';
@@ -50,4 +51,5 @@ var avs_url = '<?php echo $this->getUrl('etemando/pcs/autocompletecart', array('
50
  var avs = new Avs( avs_url, 'postcode', 'city', 'country_id');
51
  //]]>
52
  </script>
53
- <?php endif; ?>
 
43
  </div>
44
  </div>
45
  </div>
46
+ <?php if(Mage::helper('temando')->getConfigData('avs/frontend')):?>
47
  <script type="text/javascript">
48
  //<![CDATA[
49
  var shipping_estimator_url = '<?php echo $this->getUrl('etemando/pcs/product', array('_secure' => Mage::app()->getStore()->isCurrentlySecure())); ?>';
51
  var avs = new Avs( avs_url, 'postcode', 'city', 'country_id');
52
  //]]>
53
  </script>
54
+ <?php endif; ?>
55
+ <?php endif;?>
app/design/frontend/base/default/template/temando/temando/wizard/origin.phtml CHANGED
@@ -127,6 +127,7 @@
127
  var dataForm = new VarienForm('form-validate');
128
  var OriginRegionUpdater = new RegionUpdater('origin_country', 'region_name', 'origin_region', <?php echo $this->helper('temando/wizard')->getRegionJson() ?>, undefined, 'origin_postcode');
129
  </script>
 
130
  <script type="text/javascript">
131
  //<[CDATA[
132
  var shipping_estimator_url = '<?php echo $this->getUrl('etemando/pcs/autocompletecart', array('_secure' => Mage::app()->getStore()->isCurrentlySecure())); ?>';
@@ -137,4 +138,5 @@
137
  'origin_country'
138
  );
139
  //]]>
140
- </script>
 
127
  var dataForm = new VarienForm('form-validate');
128
  var OriginRegionUpdater = new RegionUpdater('origin_country', 'region_name', 'origin_region', <?php echo $this->helper('temando/wizard')->getRegionJson() ?>, undefined, 'origin_postcode');
129
  </script>
130
+ <?php if(Mage::helper('temando')->getConfigData('avs/backend')):?>
131
  <script type="text/javascript">
132
  //<[CDATA[
133
  var shipping_estimator_url = '<?php echo $this->getUrl('etemando/pcs/autocompletecart', array('_secure' => Mage::app()->getStore()->isCurrentlySecure())); ?>';
138
  'origin_country'
139
  );
140
  //]]>
141
+ </script>
142
+ <?php endif;?>
app/etc/modules/Temando_Temando.xml CHANGED
@@ -1,9 +1,9 @@
1
- <?xml version="1.0"?>
2
- <config>
3
- <modules>
4
- <Temando_Temando>
5
- <active>true</active>
6
- <codePool>community</codePool>
7
- </Temando_Temando>
8
- </modules>
9
- </config>
1
+ <?xml version="1.0"?>
2
+ <config>
3
+ <modules>
4
+ <Temando_Temando>
5
+ <active>true</active>
6
+ <codePool>community</codePool>
7
+ </Temando_Temando>
8
+ </modules>
9
+ </config>
package.xml CHANGED
@@ -1,7 +1,7 @@
1
  <?xml version="1.0"?>
2
  <package>
3
  <name>Temando_Temando</name>
4
- <version>1.4.1</version>
5
  <stability>stable</stability>
6
  <license uri="http://opensource.org/licenses/osl-3.0.php">Open Software Licence</license>
7
  <channel>community</channel>
@@ -24,14 +24,12 @@ The Temando Magento shipping extension is more than just shipping software. Adva
24
  &#x2022; Insurance option at check out&#xD;
25
  &#x2022; Carbon offset option at check out&#xD;
26
  &#x2022; Process multiple bookings in batches&#xD;
27
- &#x2022; Packaging logic to predict box sizes&#xD;
28
- </description>
29
- <notes>Temando Shipping Extension &#x2013; Starter Version&#xD;
30
- &#x2022; Bug Fix: Fixed Access Denied problem for admin users without full admin permissions - introduced with Magento patch SUPEE-6285 </notes>
31
  <authors><author><name>Temando</name><user>Temando</user><email>marketing@temando.com</email></author></authors>
32
- <date>2015-07-09</date>
33
- <time>02:21:32</time>
34
- <contents><target name="mageetc"><dir name="modules"><file name="Temando_Temando.xml" hash="61802a5dcba43fb186bf8c0ffac6950f"/></dir></target><target name="magecommunity"><dir name="Temando"><dir name="Temando"><dir name="Block"><dir name="Adminhtml"><dir name="Manifest"><dir name="Filter"><file name="Form.php" hash="b50d9538dc14b713e05e81b106d01e8d"/></dir><dir name="Grid"><dir name="Renderer"><file name="Checkbox.php" hash="aea0559a83dcf57cd3746700e0b154bc"/></dir></dir><file name="Grid.php" hash="883505cf6119ddd650023b103a6f5dd0"/></dir><file name="Manifest.php" hash="54fadcde4fc1eef4bfc3342fd753aa1b"/><dir name="Shipment"><dir name="Edit"><file name="Form.php" hash="f463cfd5a68fbcbbc39b411fd68c6658"/><dir name="Tab"><file name="Abstract.php" hash="40098655ffda3b1889af1c5776c72243"/><dir name="Form"><file name="Anytime.php" hash="356009570dc97be1405c1f7bde1055cf"/><file name="Anywhere.php" hash="cc6f0e2994f71a605dbd971ba280477b"/><file name="Boxes.php" hash="2814eb94147bdc8e6ceef3b56a5842f5"/><file name="Insurance.php" hash="0756ddbb577ff982e5cc048232d6cf0a"/><file name="Origin.php" hash="9b9fcbb04ce032f613e9f6cb8aad42de"/><file name="Products.php" hash="87e3bc8154bb6709185ee9c916d0c930"/><file name="Quotes.php" hash="1010634b24617ed25f5ddf1328d1f5f2"/><file name="Status.php" hash="c0781098106ac38b9aa3e9b2d07bbc48"/></dir><file name="Form.php" hash="bb67f340fdbb39634a3f018fa9955d87"/></dir><file name="Tabs.php" hash="aca2cc202217011258d18386fd07e1d0"/></dir><file name="Edit.php" hash="15a363348caf71ac5df906ec521ed172"/><file name="Grid.php" hash="f19927970dfad99e0a74d03950b68627"/></dir><file name="Shipment.php" hash="cdd48f2b3a19502bd6497ed9684a88be"/><dir name="System"><dir name="Config"><dir name="Form"><dir name="Button"><file name="Rule.php" hash="480867b8f34def26ce2674d4e1453e29"/><file name="Update.php" hash="337722ca578208b389b358b25abef90a"/><file name="Warehouse.php" hash="7b97f8cb48d60c9ff5f92c57f164a72f"/></dir><dir name="Field"><file name="Insurance.php" hash="023112e260cd46ae7754905573a0e367"/><file name="Required.php" hash="ec11ae46b3eeb3ea26c6939279d1b6e9"/></dir><dir name="Fieldset"><file name="General.php" hash="ea8cbf0459c07fc05016354a5d6241c9"/></dir></dir></dir></dir></dir><dir name="Cart"><file name="Shipping.php" hash="9e14409aeabaa093c58e74e3157f4213"/></dir><dir name="Onepage"><dir name="Shipping"><dir name="Delivery"><file name="Options.php" hash="70542d028386dae168367f49e0ddf640"/></dir><dir name="Method"><dir name="Available"><file name="Single.php" hash="de8cdd692a3e5e3ca69e692c42b9f04f"/></dir><file name="Available.php" hash="bcadbfa218104266209452b860375f4f"/></dir></dir></dir><dir name="Product"><dir name="Shipping"><file name="Methods.php" hash="783981474bafb42e55b4f0d7a32d9c7a"/></dir><file name="Shipping.php" hash="e565c0fdc0463b7f0911d38e16a53869"/></dir><dir name="Wizard"><file name="Html.php" hash="47bf2dc61bdd8f0ef67f239c7d762f7b"/></dir></dir><dir name="Helper"><file name="Data.php" hash="416763e81599edea5e90b007640368f6"/><file name="Functions.php" hash="c38f2b99d9dedc090ecb27456519f30a"/><file name="Wizard.php" hash="087b24ad159480f93f12a66d867a76cf"/></dir><dir name="Model"><dir name="Api"><file name="Client.php" hash="c42494d74bad73eab7d6227ccbc87447"/><dir name="Request"><file name="Anything.php" hash="2c131340da62725650c3e030524e2366"/><file name="Anythings.php" hash="54f0e75a03012f593f10849f1e055025"/><file name="Anytime.php" hash="887460ca033594de365b272802c4b059"/><file name="Anywhere.php" hash="e62fcfd8158a030b9acf5e2495662e85"/></dir><file name="Request.php" hash="e0c7ef938d1779f150671255592375a0"/></dir><file name="Box.php" hash="e4ddd66d649d493b6ad594499fb57c71"/><file name="Carrier.php" hash="8bf261a034342beefc1f043e8abf2f28"/><dir name="Checkout"><dir name="Delivery"><file name="Options.php" hash="dc384fcc84d9616ff6898a33280fb792"/></dir></dir><dir name="Entity"><dir name="Attribute"><dir name="Source"><dir name="Packaging"><file name="Mode.php" hash="aa511a6ea13320cec67902be65e4896a"/></dir><file name="Packaging.php" hash="51fab970661c20939397401ee92e0f58"/></dir></dir></dir><file name="Manifest.php" hash="e9a2eecb24647dd51209e6022d92dc97"/><dir name="Mysql4"><dir name="Box"><file name="Collection.php" hash="f2e414a79ed7b3b3e43a486030efb559"/></dir><file name="Box.php" hash="872126d53b4716b3efd6a9cec4c04272"/><dir name="Carrier"><file name="Collection.php" hash="4731b77ae10423967476d5e368a75f80"/></dir><file name="Carrier.php" hash="cd62eda71a2c6c07081aa187b0c35c2f"/><dir name="Manifest"><file name="Collection.php" hash="899f782ab34d6c008972296f59c9cde6"/></dir><file name="Manifest.php" hash="e5e474e5074d4f7b5405f7002add1602"/><dir name="Quote"><file name="Collection.php" hash="90fecb1146d26107773571eab8a3bb6b"/></dir><file name="Quote.php" hash="ca1c40896cdf2e91f1a4e40bd48e0158"/><dir name="Shipment"><file name="Collection.php" hash="bd6034947f6c67b1cc80936138890dfc"/></dir><file name="Shipment.php" hash="1b647da4d0a63b6a0a4e0eb7edac6a06"/></dir><file name="Observer.php" hash="d8657be32220dae140999112db280963"/><dir name="Option"><file name="Abstract.php" hash="eaba5ae86cba4a8232b5e64d4ff98e38"/><dir name="Action"><file name="Abstract.php" hash="8635b58b91e772f78effa3e15e95650f"/><file name="Carbon.php" hash="0df49140f10610b7bb4a23d48cbf51ec"/><file name="Footprints.php" hash="500bbb332a64729415bcb2a6a193abd6"/><file name="Insurance.php" hash="d1e70eac253aa071d9c1ef7a2943c8f5"/><file name="Markup.php" hash="6091ad03e12aeaf13561883d16f1c63d"/></dir><file name="Boolean.php" hash="fef69fd21c5de9f135342428e13e69d7"/><file name="Carbonoffset.php" hash="17c91c83e93c364a01eb63a72e0c9a74"/><file name="Footprints.php" hash="b57c2de2cc392fb48f76d61b99ad4c59"/><file name="Insurance.php" hash="74f421a73ed6363ce720f5af3c20ee5d"/></dir><file name="Options.php" hash="4834b4b722c5ba1eaee6c50651395659"/><file name="Pcs.php" hash="f0a03601d765f6772abc74f7e94c7ce0"/><file name="Quote.php" hash="72b6743ac693b4074cf904de3c928b95"/><file name="Shipment.php" hash="6b57bd421ac95f249db09feaca8c7f79"/><dir name="Shipping"><dir name="Carrier"><dir name="Temando"><dir name="Source"><file name="Method.php" hash="c3e22169434a20d6acbf93e5757714fd"/></dir></dir><file name="Temando.php" hash="7c7fbed312dd495cd1070f165e00b743"/></dir></dir><file name="Status.php" hash="6a9d2783a09b28eccbee278cf487d77f"/><dir name="System"><dir name="Config"><dir name="Backend"><dir name="Form"><dir name="Field"><dir name="Required"><file name="Businessresidential.php" hash="e910070a9cf896e63e50dcc20135d9b4"/><file name="Country.php" hash="281aa176fa9c8deead10427d68f89fc8"/><file name="Location.php" hash="a6176f8aa745e45983ecafe54a5c62cc"/><file name="Text.php" hash="9a27ecf932ad86fdcbe6b9338a0ad766"/></dir></dir></dir></dir><dir name="Source"><file name="Carbon.php" hash="f7fdf1cb68cd462cc24dc79f3e9e937c"/><dir name="Client"><file name="Type.php" hash="8c7bc6cfc61db303d6521dcbfccca586"/></dir><file name="Country.php" hash="9f78a067c6a5bfb1f09cbe13e2a8f783"/><file name="Errorprocess.php" hash="de73413369a2d2576e9beceddcb67de9"/><file name="Footprints.php" hash="93581fe36831c12cde3aa9c921182ee5"/><file name="Insurance.php" hash="e4e86feec2d63927751eeef1f79639cf"/><file name="Labeltype.php" hash="84a96263fe91c34e949163e644e213bb"/><dir name="Origin"><file name="Type.php" hash="ef152aed2dca36860b78263c2488d418"/></dir><file name="Payment.php" hash="b7596b3675425b9b990567bfad88a019"/><file name="Pricing.php" hash="f0a2ca789be1a988631e5bbad24b07a9"/><file name="Readytime.php" hash="6840fffc73e10104977e54d512b4584a"/><file name="Regions.php" hash="9c85df73d0fa9c3e5e40428a5168134f"/><dir name="Rule"><dir name="Action"><dir name="Adjustment"><file name="Type.php" hash="d9db67d7452d9b6a89d84dbe41505d9b"/></dir><file name="Filter.php" hash="f2ddffbdc87a58c57a91d4822261f32b"/></dir><dir name="Condition"><file name="Time.php" hash="fecf942aed7ee0bd2e1acf2303b71ce3"/><file name="Type.php" hash="958e1516c33888917a945a444a8f79ba"/></dir><file name="Type.php" hash="69e2510c398c18c4851458b835c685f2"/></dir><dir name="Sales"><dir name="Order"><file name="Status.php" hash="ed15d292094826482ad4e8882794702d"/></dir></dir><dir name="Shipment"><file name="Class.php" hash="973bb5839634b28124213272a7b5dbb9"/><dir name="Packaging"><file name="Mode.php" hash="b4e1ca265e860c7b144579f128d28a5c"/></dir><file name="Packaging.php" hash="9cf1e7eda9275fe8c96ec4882918e02e"/><file name="Service.php" hash="0e4e5bf85eb70a26d25c0fbec1519926"/><file name="Status.php" hash="344d11d97aab4c1f977b9193a10ee105"/></dir><dir name="Unit"><file name="Measure.php" hash="d5a66b68d43dabd2475e9509608b3278"/><file name="Weight.php" hash="33507ff6d892989c2949de63922a247d"/></dir><file name="Unit.php" hash="0c8b786b4012a535339a39f4f86ec669"/><file name="Wizard.php" hash="fd1f7d1dea8e807f8cc9ecfe2c2dc830"/></dir><file name="Source.php" hash="c1e2741547a1a81d0926fdc0db710de4"/></dir></dir><file name="Wizard.php" hash="178e3a566708da82a1e408a1a0f4878b"/></dir><dir name="controllers"><dir name="Adminhtml"><file name="CarrierController.php" hash="1abae5c185e766a5467d10c271291002"/><file name="JsonController.php" hash="29e155de5321e0409b0eef01afd4e048"/><file name="ManifestController.php" hash="80cbadab1ed57a77f1a8c513ff72219b"/><file name="ShipmentController.php" hash="aaa9e1a37043a86e7cb12694001e450f"/><file name="WizardController.php" hash="63e55be4089b4f1764e62c66ed757d31"/></dir><file name="PcsController.php" hash="96561d4ae3f9bb44f1ffef779a6dce4c"/><file name="WizardController.php" hash="db44aa485493fab61b509f6e8fae3560"/></dir><dir name="etc"><file name="adminhtml.xml" hash="c780097d8cc5f57af5c63361f984cc53"/><file name="config.xml" hash="be064b98ee2519dd14629b6c40cd2744"/><file name="system.xml" hash="754c7128e8ef862fe3ad171eaa091474"/></dir><dir name="sql"><dir name="temando_setup"><file name="mysql4-install-1.0.0.php" hash="8f22dad6cc2162119422a468b8af9941"/><file name="mysql4-upgrade-1.3.8-1.3.9.php" hash="6196267c6a1fe09161659e11505c9815"/></dir></dir></dir></dir></target><target name="magedesign"><dir name="adminhtml"><dir name="default"><dir name="default"><dir name="layout"><file name="temando.xml" hash="237fb894c1c1c043252b09169bb3b112"/></dir><dir name="template"><dir name="temando"><dir name="temando"><file name="manifest.phtml" hash="8f16e0754f30696597318aa83055e8e6"/><file name="menu.phtml" hash="bc78fd42ac729ba19b4219018c052e21"/><file name="origin-avs.phtml" hash="2da4326466b0c2f581c6ecd4ffdf84a8"/><file name="region.phtml" hash="f2e8cbfbc57ef74a6b29925574de5cb1"/><dir name="shipment"><file name="anytime.phtml" hash="c4fcc5734b8740361df38f269231d606"/><file name="anywhere.phtml" hash="fcd32d682c06b12daddbc67405f3cf02"/><file name="boxes.phtml" hash="d2a8758ab1f7ff600b3eee0b4785552d"/><file name="insurance.phtml" hash="f3879be513ccc3e187d77156456b8033"/><file name="origin.phtml" hash="c53de035c9508d81c078501edcb70ef2"/><file name="products.phtml" hash="50a8ea7f8c1a26957222b031c19574ad"/><file name="quotes.phtml" hash="f7269534550b5b316da2e77ca23db5cc"/><file name="status.phtml" hash="3d54c1e6fd9f141fcf656e7e1d6faa98"/></dir><file name="shipment.phtml" hash="1241671844d42046b21240a2c38bb11d"/></dir></dir></dir></dir></dir></dir><dir name="frontend"><dir name="base"><dir name="default"><dir name="layout"><file name="temando.xml" hash="a73e4d56a1aac7198c0362a15822b937"/></dir><dir name="template"><dir name="temando"><dir name="temando"><dir name="checkout"><dir name="cart"><file name="shipping.phtml" hash="d501bc1ece10de7a9a3dccde68757dbf"/></dir><dir name="onepage"><dir name="delivery"><file name="options.phtml" hash="ad38b14142150612a0983849ed4238e9"/></dir></dir></dir><dir name="customer"><dir name="address"><file name="edit.phtml" hash="eff5b6cb90507e045b8ee51dae663052"/></dir></dir><dir name="onestep"><file name="options.phtml" hash="98531ee392e6978bf89dddcc3455937c"/><file name="shipping_method.phtml" hash="99c92bbdc269c1725762de538d43bc4c"/></dir><file name="pcs.phtml" hash="b7e3f5628f846afe259380be460a8d0b"/><dir name="product"><dir name="shipping"><file name="methods.phtml" hash="36c3f21e81bcd80c2406fffb6e72025c"/></dir><file name="shipping.phtml" hash="d639fe215ebb11d446477fcbece6a643"/></dir><dir name="shipping_method"><dir name="available"><file name="options_single.phtml" hash="72416b76aa5da5213a59dd8cc5b3dc0e"/></dir><file name="available.phtml" hash="9b35684046cb14d660a59697414a9197"/></dir><dir name="wizard"><file name="account.phtml" hash="72f40a25e1f4d3919ac359d70ed0ea20"/><file name="carriers.phtml" hash="50f59b8dc44524555bc70f1ed4713a7c"/><file name="catalog_product.phtml" hash="db9530c3756488f0052f1fe6ab76d1bb"/><file name="countries.phtml" hash="f2bb5321ec71f85f34e64adb70f714b9"/><file name="end.phtml" hash="0e15bfc374029c9c088d423a313fd405"/><file name="left.phtml" hash="415f16cc0434db85e8b5b19aaa2bf087"/><file name="origin.phtml" hash="a97ef2c7fe6ecf034c5649ea9c46492b"/><file name="rule.phtml" hash="bea3961cb3feacab76623ca4df95a4b4"/></dir><file name="wizard.phtml" hash="c7f8d13602b5b68374290b62a04ce97d"/></dir></dir></dir></dir></dir></dir></target><target name="mage"><dir name="js"><dir name="temando"><file name="autocomplete.js" hash="401e3126c3421cafeaadf67613b40d51"/><file name="avs.js" hash="18b7b8a01b945767842a25dbf4e21acd"/><file name="menu.js" hash="61c1ee9d0c9aec2161e85cc926d44c11"/></dir></dir></target><target name="mageskin"><dir name="adminhtml"><dir name="default"><dir name="default"><dir name="js"><file name="temando.js" hash="dd7f5c8137271c814a0a25d1db951879"/></dir><dir name="temando"><dir name="images"><file name="ajax-s-load.gif" hash="0ea8ba3fe3e60b73eda7d6de57fd8e01"/><file name="bg_notifications.gif" hash="d2a0489d0c3714bed22f9b06f4b81d43"/><file name="shadow.png" hash="b5b27e0dd88d44d4a5d8e63bb61a1239"/><file name="temando_logo.jpg" hash="04d2dbd664ff68a4be7364113f30572f"/></dir><file name="styles.css" hash="2d9c985c31622016db01e966974d70be"/></dir></dir></dir></dir><dir name="frontend"><dir name="base"><dir name="default"><dir name="css"><dir name="temando"><file name="autocomplete.css" hash="90387e5610631653a4bd97c7af3d444e"/><file name="cart.css" hash="f4456c3fe147244a12a7b68d7f4d0bc7"/><dir name="images"><file name="ajax-s-load.gif" hash="0ea8ba3fe3e60b73eda7d6de57fd8e01"/><file name="find_ext.png" hash="a6ba701a9256a2c775255965df1918c7"/><file name="i_shipping.gif" hash="91a0d2cc2eb2391f90ec8a75c04b3183"/><file name="shadow.png" hash="b5b27e0dd88d44d4a5d8e63bb61a1239"/></dir><file name="product.css" hash="d1679e756012f66391758a09d0918986"/><file name="styles.css" hash="271bd9dd967c0eb83c6e10e9bfdee952"/></dir></dir><dir name="js"><dir name="temando"><file name="checkout.js" hash="5425f09ae3da50b0ac49e768b8b607d0"/><file name="product.js" hash="989198862c7674f23adbed4d3bfa3de5"/></dir></dir></dir></dir></dir></target><target name="magelocale"><dir name="en_US"><file name="Temando_Temando.csv" hash="a12b7b049f65fdcd451e6be7b50b6133"/></dir></target></contents>
35
  <compatible/>
36
- <dependencies><required><php><min>5.2.13</min><max>6.0.0</max></php><extension><name>soap</name><min>1.2</min><max/></extension></required></dependencies>
37
  </package>
1
  <?xml version="1.0"?>
2
  <package>
3
  <name>Temando_Temando</name>
4
+ <version>1.4.5</version>
5
  <stability>stable</stability>
6
  <license uri="http://opensource.org/licenses/osl-3.0.php">Open Software Licence</license>
7
  <channel>community</channel>
24
  &#x2022; Insurance option at check out&#xD;
25
  &#x2022; Carbon offset option at check out&#xD;
26
  &#x2022; Process multiple bookings in batches&#xD;
27
+ &#x2022; Packaging logic to predict box sizes</description>
28
+ <notes>- Addition of Endpoint discovery feature</notes>
 
 
29
  <authors><author><name>Temando</name><user>Temando</user><email>marketing@temando.com</email></author></authors>
30
+ <date>2015-10-02</date>
31
+ <time>05:18:53</time>
32
+ <contents><target name="mageetc"><dir name="modules"><file name="Temando_Temando.xml" hash="5bcf129ec4955186ed97d4b57def464b"/></dir></target><target name="magecommunity"><dir name="Temando"><dir name="Temando"><dir name="Block"><dir name="Adminhtml"><dir name="Manifest"><dir name="Filter"><file name="Form.php" hash="b4099c92733f53d820d674751821ed50"/></dir><dir name="Grid"><dir name="Renderer"><file name="Checkbox.php" hash="217498b6e4951477f7fe937dfff5015b"/></dir></dir><file name="Grid.php" hash="955ab9844fdf6968a147bfac4fd881c4"/></dir><file name="Manifest.php" hash="bdde7c777b07041e635fcfbb067d87d0"/><dir name="Shipment"><dir name="Edit"><file name="Form.php" hash="a4a6e578956f3ecc0ec1d908457def97"/><dir name="Tab"><file name="Abstract.php" hash="6a22660970c74e1ae21344a1f34fa482"/><dir name="Form"><file name="Anytime.php" hash="30f898d8371235ac81cdf22fd0a63251"/><file name="Anywhere.php" hash="98e963ed9904be787b4c36e853cb10d7"/><file name="Boxes.php" hash="3b582024e18c4d1d830d9ee4af2a2b01"/><file name="Insurance.php" hash="2cc31e9bedba914af185c044281f0bfa"/><file name="Origin.php" hash="381d09855ff408689f873412370b7dec"/><file name="Products.php" hash="337102c6b05a52e30cc85b8d6466efb0"/><file name="Quotes.php" hash="513472712f8c1cd3669da6e720d7295d"/><file name="Status.php" hash="d721e9b0596eff46d5f3d60885099473"/></dir><file name="Form.php" hash="6ef64516535ec548c72022808ee4abf4"/></dir><file name="Tabs.php" hash="86b0f050fe082948d8f088ba3109b234"/></dir><file name="Edit.php" hash="3a719afcc913c8ee9de60bf134ef3274"/><dir name="Grid"><dir name="Renderer"><file name="Currency.php" hash="dded58be451dc45b276101939a512ea1"/><file name="Shipcurrency.php" hash="cd5a12f46310451b1210b9450563cabb"/></dir></dir><file name="Grid.php" hash="555b577c21ca59cd6fbd55b13448fc6f"/></dir><file name="Shipment.php" hash="9e927b92d2aaab787b8cf15550f55c4f"/><dir name="System"><dir name="Config"><dir name="Form"><dir name="Button"><file name="Rule.php" hash="79929244671d5cb4d4229224bd37aa3f"/><file name="Update.php" hash="45e9a3ba22a655a2dce37f265df49f85"/><file name="Warehouse.php" hash="a6ae893ad1f15d4c11c7427ca0cdadff"/></dir><dir name="Field"><file name="Insurance.php" hash="3536f821eeed9efe8c64770211d50939"/><file name="Required.php" hash="92f906de32edd12d44a3d4c0b121b561"/><file name="Version.php" hash="b5391581a30a43b84132d3f72f6ae42e"/></dir><dir name="Fieldset"><file name="General.php" hash="81e44d49ad87344fcbc2adb444869214"/></dir></dir></dir></dir></dir><dir name="Cart"><file name="Shipping.php" hash="65c89df6d1a2e275fa3f9ca81019a49e"/></dir><dir name="Onepage"><dir name="Shipping"><dir name="Delivery"><file name="Options.php" hash="8751f908c161e9fb73601121b17f4147"/></dir><dir name="Method"><dir name="Available"><file name="Single.php" hash="adb3ad540f075bd7957250584e0d00cd"/></dir><file name="Available.php" hash="6e869628992bbbbd6274fdca2ab2b1c6"/></dir></dir></dir><dir name="Product"><dir name="Shipping"><file name="Methods.php" hash="44012e32d5054a085fb13855bb251728"/></dir><file name="Shipping.php" hash="a3d2cc4acd8495a290d6af3f92c3a97b"/></dir><dir name="Wizard"><file name="Html.php" hash="1a5361fcfba0b9b89fd29dde80adb438"/></dir></dir><dir name="Helper"><file name="Data.php" hash="39ffa31157b53b700e9267fc29ba022f"/><file name="Functions.php" hash="076522b041c4363dd0c69819ba5d1574"/><file name="Wizard.php" hash="5ef1464356d4c69a4c35bfce0b4107ed"/></dir><dir name="Model"><dir name="Api"><file name="Client.php" hash="a2841b7e74e7836b0939906161c41bea"/><dir name="Request"><file name="Anything.php" hash="9871fcc98da5682a55ae8be59e006cfa"/><file name="Anythings.php" hash="e21b4fe3de12b1752fbafb2a34259c07"/><file name="Anytime.php" hash="f9c4254cb804760a028edce316e4c2dd"/><file name="Anywhere.php" hash="52d7b281e644da8bdd9f742092ecf6a6"/></dir><file name="Request.php" hash="fe07aa6663322f18c4bbfc815f098f68"/></dir><file name="Box.php" hash="55b7fd5d1a051ed1bd78098c0eedbc2d"/><file name="Carrier.php" hash="b29a4514596c6995b3014be1cab74660"/><dir name="Checkout"><dir name="Delivery"><file name="Options.php" hash="11d197c6869c3cfdea9711399089c20a"/></dir></dir><file name="Endpoint.php" hash="bcd593aeb58f0979c18c5de9e5c517db"/><dir name="Entity"><dir name="Attribute"><dir name="Source"><dir name="Packaging"><file name="Mode.php" hash="00f91acea3c1538f38eac43b0a61808f"/></dir><file name="Packaging.php" hash="0e1515ef265feabeb21d41d256cf56fb"/></dir></dir></dir><file name="Manifest.php" hash="65341ccbb893f3de5b501731c28653f3"/><dir name="Mysql4"><dir name="Box"><file name="Collection.php" hash="f4ee29b57cb687eb5cc433679f62a34d"/></dir><file name="Box.php" hash="1a8f32b28511de74774063ed74bd7613"/><dir name="Carrier"><file name="Collection.php" hash="237b6318eedaaa0605ec48438746a050"/></dir><file name="Carrier.php" hash="08066dea72c4accf12ef85a38661446f"/><dir name="Manifest"><file name="Collection.php" hash="257bf750af05735ce1869fbe9cfd154c"/></dir><file name="Manifest.php" hash="caf4fc41dda2972b3837cfce8b3ae436"/><dir name="Quote"><file name="Collection.php" hash="c45c53acd87fed8680669ff23ae6a414"/></dir><file name="Quote.php" hash="01664270d15b0f4e7e91df44cdbb289a"/><dir name="Shipment"><file name="Collection.php" hash="6b7ebecc9011f8d3d0784785e73b5bbd"/></dir><file name="Shipment.php" hash="a12d35e6b58aa54b999f87638a21626b"/></dir><file name="Observer.php" hash="e52190345973e8f5ba2196709983cedf"/><dir name="Option"><file name="Abstract.php" hash="b5bcbebc1ff5b381d2a325778a816e18"/><dir name="Action"><file name="Abstract.php" hash="a03ac320b292f17f0e7a2a61adb72cfc"/><file name="Carbon.php" hash="0a133a233dd667b67210d6d0d39f252d"/><file name="Footprints.php" hash="28a811eccf1d62c27864e9380d5bb447"/><file name="Insurance.php" hash="834927be6b15022b4f965b87e7d7005d"/><file name="Markup.php" hash="96936f7648d17f817b8ca6d7c9178b39"/></dir><file name="Boolean.php" hash="412a452f85fa619d0ef02d0229d25b5f"/><file name="Carbonoffset.php" hash="c2af6029b91563ae683897f010b07b06"/><file name="Footprints.php" hash="0fdc246a692684411bf4b987f80a09c0"/><file name="Insurance.php" hash="1a6721284b3eb7ef4ec8c1dda2ee4a12"/></dir><file name="Options.php" hash="8be48b6afdc8d6199a94ad9691e3ad33"/><file name="Pcs.php" hash="70059b2125cc719516eb3d7469fa1bb7"/><file name="Quote.php" hash="6ed0633efb8be6626040859567a8c4f3"/><file name="Shipment.php" hash="84f71471a15ce88e442cc1ce6fe3e498"/><dir name="Shipping"><dir name="Carrier"><dir name="Temando"><dir name="Source"><file name="Method.php" hash="4306449e0af3fa11972cdc975232ee43"/></dir></dir><file name="Temando.php" hash="3163d863b327b11d34ea5ee3ce20d513"/></dir></dir><file name="Status.php" hash="6fd47721ecd852de869302f0671adeb1"/><dir name="System"><dir name="Config"><dir name="Backend"><dir name="Form"><dir name="Field"><dir name="Required"><file name="Businessresidential.php" hash="c0a16a75babacdfc5244049c1a2e4601"/><file name="Country.php" hash="7e5f0157eed174b354d9e59872a55a84"/><file name="Location.php" hash="8e1db9cf2d4d229ee829479c5dca3d8b"/><file name="Text.php" hash="5bf808fb574b1d68b72a5e2ef8da530a"/></dir></dir></dir></dir><dir name="Source"><file name="Carbon.php" hash="ff86a2975abd26cbc568a9ccfc17546b"/><dir name="Client"><file name="Type.php" hash="f645147cfe160bf91d60ad76dd86819d"/></dir><file name="Country.php" hash="c8451aaf0d0a5edcbb0e5137cd21f762"/><file name="Errorprocess.php" hash="92188011e13dcfab1b14d20b136dd253"/><file name="Footprints.php" hash="5f7178778645c2aa130035858f7ed085"/><file name="Insurance.php" hash="8dea632b9bab12bd1cdef6f6d7cd697c"/><file name="Labeltype.php" hash="909f23b083f12ec54ede7504796e7bb4"/><dir name="Origin"><file name="Type.php" hash="49facb949edf7421cd6ad13b009f2667"/></dir><file name="Payment.php" hash="15ff39042e67bd73511e7201f98296b6"/><file name="Pricing.php" hash="afcf7f5b21f55fe4adf1328093a868a3"/><file name="Readytime.php" hash="c257c155db65c590d28e045fd213dc4c"/><file name="Regions.php" hash="4d929facfa548ac08549e9d58b574393"/><dir name="Rule"><dir name="Action"><dir name="Adjustment"><file name="Type.php" hash="06bb09099de19a37a96e7f0a588cd122"/></dir><file name="Filter.php" hash="d2078b79264106013e271302150a62f4"/></dir><dir name="Condition"><file name="Time.php" hash="5624250da9928d342ab05871129b341c"/><file name="Type.php" hash="fde22f55181c77579b428ae9cede1266"/></dir><file name="Type.php" hash="5b1f84f27965e47c9e898cce98d6a892"/></dir><dir name="Sales"><dir name="Order"><file name="Status.php" hash="bdd27644573ac47c66c68b9b6ff45ef1"/></dir></dir><dir name="Shipment"><file name="Class.php" hash="0b73a6ab458f5f566c021b5f7ff55fc4"/><dir name="Packaging"><file name="Mode.php" hash="3c5477cf10225caed1a5e29ec47ba8f7"/></dir><file name="Packaging.php" hash="0293b19be6bd1b58d091c540bfaf24e7"/><file name="Service.php" hash="bc229ad1c347cf6167cd3790e1e63865"/><file name="Status.php" hash="6544c35752b80213db37ce7bd09f30e3"/></dir><dir name="Unit"><file name="Measure.php" hash="7b33ae53b2047929aaa0dc00055f758d"/><file name="Weight.php" hash="665b892faee780de0fb3a04f848eb15f"/></dir><file name="Unit.php" hash="3a6bf2b0b9e60e0503db0937522f8bf9"/><file name="Wizard.php" hash="ba40886a79c559414bf1d9cc45c37211"/></dir><file name="Source.php" hash="a8123560ccda65b97b727435fb66b830"/></dir></dir><file name="Wizard.php" hash="ceef8c4ca0075276e249fb0e7544fc85"/></dir><dir name="controllers"><dir name="Adminhtml"><file name="CarrierController.php" hash="86f818000a9ce8d457955b23a3f037d7"/><file name="JsonController.php" hash="eb4c880ed815a78c582504dc4a842a14"/><file name="ManifestController.php" hash="d6985509a278ed10ff65db35488ba059"/><file name="ShipmentController.php" hash="7c39e777cb73ed01bac212b3a6628dbb"/><file name="WizardController.php" hash="660d3ae254cf6ca18794b92805ba499d"/></dir><file name="PcsController.php" hash="b71c416e404b640c6a8381842159c31c"/><file name="WizardController.php" hash="9077d49ebf4c1dad739b82b3b8f61071"/></dir><dir name="data"><dir name="temando_setup"><file name="data-install-1.0.0.php" hash="450948bf01fb2312514c651f0d46bd32"/></dir></dir><dir name="etc"><file name="adminhtml.xml" hash="c780097d8cc5f57af5c63361f984cc53"/><file name="config.xml" hash="c3613c32c16eb2542339513b57adbebc"/><file name="system.xml" hash="accccfbcae89a2daee5f15967a749ba0"/></dir><dir name="sql"><dir name="temando_setup"><file name="mysql4-install-1.0.0.php" hash="fc4888035b7b7333193c47ba6e1d6473"/><file name="mysql4-upgrade-1.3.8-1.3.9.php" hash="0cd1a96dc61c7a28db7ea1ee1dcb0f33"/><file name="mysql4-upgrade-1.4.4-1.4.5.php" hash="36955fdfc4578530582ed1b32b87b812"/></dir></dir></dir></dir></target><target name="magedesign"><dir name="adminhtml"><dir name="default"><dir name="default"><dir name="layout"><file name="temando.xml" hash="237fb894c1c1c043252b09169bb3b112"/></dir><dir name="template"><dir name="temando"><dir name="temando"><file name="manifest.phtml" hash="8f16e0754f30696597318aa83055e8e6"/><file name="menu.phtml" hash="bc78fd42ac729ba19b4219018c052e21"/><file name="origin-avs.phtml" hash="09976c75c01e5bf61aa93ca513f5fb9a"/><file name="region.phtml" hash="f2e8cbfbc57ef74a6b29925574de5cb1"/><dir name="shipment"><file name="anytime.phtml" hash="c4fcc5734b8740361df38f269231d606"/><file name="anywhere.phtml" hash="78dc2673ade4e5f70bf8e672f83fcb88"/><file name="boxes.phtml" hash="d2a8758ab1f7ff600b3eee0b4785552d"/><file name="insurance.phtml" hash="f3879be513ccc3e187d77156456b8033"/><file name="origin.phtml" hash="c53de035c9508d81c078501edcb70ef2"/><file name="products.phtml" hash="50a8ea7f8c1a26957222b031c19574ad"/><file name="quotes.phtml" hash="f7269534550b5b316da2e77ca23db5cc"/><file name="status.phtml" hash="3d54c1e6fd9f141fcf656e7e1d6faa98"/></dir><file name="shipment.phtml" hash="1241671844d42046b21240a2c38bb11d"/></dir></dir></dir></dir></dir></dir><dir name="frontend"><dir name="base"><dir name="default"><dir name="layout"><file name="temando.xml" hash="a73e4d56a1aac7198c0362a15822b937"/></dir><dir name="template"><dir name="temando"><dir name="temando"><dir name="checkout"><dir name="cart"><file name="shipping.phtml" hash="2bf09b291d2537a66b6eb5ef3eb97f2b"/></dir><dir name="onepage"><dir name="delivery"><file name="options.phtml" hash="ad38b14142150612a0983849ed4238e9"/></dir></dir></dir><dir name="customer"><dir name="address"><file name="edit.phtml" hash="1785250ab5a19f0739934bd67c0c1c03"/></dir></dir><dir name="onestep"><file name="options.phtml" hash="98531ee392e6978bf89dddcc3455937c"/><file name="shipping_method.phtml" hash="99c92bbdc269c1725762de538d43bc4c"/></dir><file name="pcs.phtml" hash="b81098c2840a07b1ac6f286670961286"/><dir name="product"><dir name="shipping"><file name="methods.phtml" hash="36c3f21e81bcd80c2406fffb6e72025c"/></dir><file name="shipping.phtml" hash="d6b3811e198422184d3f7fab1df27685"/></dir><dir name="shipping_method"><dir name="available"><file name="options_single.phtml" hash="72416b76aa5da5213a59dd8cc5b3dc0e"/></dir><file name="available.phtml" hash="9b35684046cb14d660a59697414a9197"/></dir><dir name="wizard"><file name="account.phtml" hash="72f40a25e1f4d3919ac359d70ed0ea20"/><file name="carriers.phtml" hash="50f59b8dc44524555bc70f1ed4713a7c"/><file name="catalog_product.phtml" hash="db9530c3756488f0052f1fe6ab76d1bb"/><file name="countries.phtml" hash="f2bb5321ec71f85f34e64adb70f714b9"/><file name="end.phtml" hash="0e15bfc374029c9c088d423a313fd405"/><file name="left.phtml" hash="415f16cc0434db85e8b5b19aaa2bf087"/><file name="origin.phtml" hash="6ac4c9b3e28adcdecf811f7d4ee2577d"/><file name="rule.phtml" hash="bea3961cb3feacab76623ca4df95a4b4"/></dir><file name="wizard.phtml" hash="c7f8d13602b5b68374290b62a04ce97d"/></dir></dir></dir></dir></dir></dir></target><target name="mage"><dir name="js"><dir name="temando"><file name="autocomplete.js" hash="401e3126c3421cafeaadf67613b40d51"/><file name="avs.js" hash="18b7b8a01b945767842a25dbf4e21acd"/><file name="menu.js" hash="61c1ee9d0c9aec2161e85cc926d44c11"/></dir></dir></target><target name="mageskin"><dir name="adminhtml"><dir name="default"><dir name="default"><dir name="js"><file name="temando.js" hash="dd7f5c8137271c814a0a25d1db951879"/></dir><dir name="temando"><dir name="images"><file name="ajax-s-load.gif" hash="0ea8ba3fe3e60b73eda7d6de57fd8e01"/><file name="bg_notifications.gif" hash="d2a0489d0c3714bed22f9b06f4b81d43"/><file name="shadow.png" hash="b5b27e0dd88d44d4a5d8e63bb61a1239"/><file name="temando_logo.jpg" hash="04d2dbd664ff68a4be7364113f30572f"/></dir><file name="styles.css" hash="42dcafadbff5752447bde79396030ed2"/></dir></dir></dir></dir><dir name="frontend"><dir name="base"><dir name="default"><dir name="css"><dir name="temando"><file name="autocomplete.css" hash="d6b9a9535fd6e2a0917881c14f515f26"/><file name="cart.css" hash="19ba5c44fbc1afaf8c2777349f4df11d"/><dir name="images"><file name="ajax-s-load.gif" hash="0ea8ba3fe3e60b73eda7d6de57fd8e01"/><file name="find_ext.png" hash="a6ba701a9256a2c775255965df1918c7"/><file name="i_shipping.gif" hash="91a0d2cc2eb2391f90ec8a75c04b3183"/><file name="shadow.png" hash="b5b27e0dd88d44d4a5d8e63bb61a1239"/></dir><file name="product.css" hash="d2b9d94b11400324e42c5b93e8d68b3c"/><file name="styles.css" hash="62ba085bde155573ea994df46b9a2507"/></dir></dir><dir name="js"><dir name="temando"><file name="checkout.js" hash="5425f09ae3da50b0ac49e768b8b607d0"/><file name="product.js" hash="989198862c7674f23adbed4d3bfa3de5"/></dir></dir></dir></dir></dir></target><target name="magelocale"><dir name="en_US"><file name="Temando_Temando.csv" hash="a12b7b049f65fdcd451e6be7b50b6133"/></dir></target></contents>
33
  <compatible/>
34
+ <dependencies><required><php><min>5.2.13</min><max>6.0.0</max></php><extension><name>soap</name><min>1.2</min><max></max></extension></required></dependencies>
35
  </package>
skin/adminhtml/default/default/temando/styles.css CHANGED
@@ -1,41 +1,41 @@
1
- div.confirm-insurance {
2
-
3
- }
4
-
5
- div.confirm-insurance {
6
- border-spacing: 10px;
7
- background: none repeat scroll 0 0 #F9F3E3;
8
- border: 1px solid #BBAFA0;
9
- margin: 10px;
10
- padding: 10px;
11
- }
12
-
13
- div.confirm-insurance td.c2 {
14
- padding-left: 15px;
15
- font-size: 12px;
16
- font-style: italic;
17
- }
18
-
19
- .tmd-grid-severity-critical,
20
- .tmd-grid-severity-critical span,
21
- .tmd-grid-severity-major,
22
- .tmd-grid-severity-major span,
23
- .tmd-grid-severity-minor,
24
- .tmd-grid-severity-minor span,
25
- .tmd-grid-severity-notice,
26
- .tmd-grid-severity-notice span { display:block; height:16px; background-image:url(images/bg_notifications.gif); background-repeat:no-repeat; font:bold 10px/16px Arial, Helvetica, sans-serif; text-transform:uppercase; text-align:center; padding:0 0 0 7px; margin:1px 0; white-space:nowrap; color:#fff; }
27
- .tmd-grid-severity-critical { background-position:0 0; }
28
- .tmd-grid-severity-critical span { background-position:100% 0; padding:0 7px 0 0; }
29
- .tmd-grid-severity-major { background-position:0 -16px; }
30
- .tmd-grid-severity-major span { background-position:100% -16px; padding:0 7px 0 0; }
31
- .tmd-grid-severity-minor { background-position:0 -32px; }
32
- .tmd-grid-severity-minor span { background-position:100% -32px; padding:0 7px 0 0; }
33
- .tmd-grid-severity-notice { background-position:0 -48px; }
34
- .tmd-grid-severity-notice span { background-position:100% -48px; padding:0 7px 0 0; }
35
-
36
- .autocomplete-w1 { background:url(images/shadow.png) no-repeat bottom right; position:absolute; z-index: 1000; top:4px; left:3px; /* IE6 fix: */ _background:none; _top:1px; }
37
- .autocomplete-w2 { padding:0 6px 6px 0; }
38
- .autocomplete { width:300px; border:1px solid #999; background:#FFF; cursor:default; text-align:left; max-height:350px; overflow:auto; margin:-6px 6px 6px -6px; /* IE specific: */ _height:350px; _margin:0px 6px 6px 0; overflow-x:hidden; }
39
- .autocomplete .selected { background:#F0F0F0; }
40
- .autocomplete div { padding:2px 5px; white-space:nowrap; }
41
  .autocomplete strong { font-weight:normal; color:#3399FF; }
1
+ div.confirm-insurance {
2
+
3
+ }
4
+
5
+ div.confirm-insurance {
6
+ border-spacing: 10px;
7
+ background: none repeat scroll 0 0 #F9F3E3;
8
+ border: 1px solid #BBAFA0;
9
+ margin: 10px;
10
+ padding: 10px;
11
+ }
12
+
13
+ div.confirm-insurance td.c2 {
14
+ padding-left: 15px;
15
+ font-size: 12px;
16
+ font-style: italic;
17
+ }
18
+
19
+ .tmd-grid-severity-critical,
20
+ .tmd-grid-severity-critical span,
21
+ .tmd-grid-severity-major,
22
+ .tmd-grid-severity-major span,
23
+ .tmd-grid-severity-minor,
24
+ .tmd-grid-severity-minor span,
25
+ .tmd-grid-severity-notice,
26
+ .tmd-grid-severity-notice span { display:block; height:16px; background-image:url(images/bg_notifications.gif); background-repeat:no-repeat; font:bold 10px/16px Arial, Helvetica, sans-serif; text-transform:uppercase; text-align:center; padding:0 0 0 7px; margin:1px 0; white-space:nowrap; color:#fff; }
27
+ .tmd-grid-severity-critical { background-position:0 0; }
28
+ .tmd-grid-severity-critical span { background-position:100% 0; padding:0 7px 0 0; }
29
+ .tmd-grid-severity-major { background-position:0 -16px; }
30
+ .tmd-grid-severity-major span { background-position:100% -16px; padding:0 7px 0 0; }
31
+ .tmd-grid-severity-minor { background-position:0 -32px; }
32
+ .tmd-grid-severity-minor span { background-position:100% -32px; padding:0 7px 0 0; }
33
+ .tmd-grid-severity-notice { background-position:0 -48px; }
34
+ .tmd-grid-severity-notice span { background-position:100% -48px; padding:0 7px 0 0; }
35
+
36
+ .autocomplete-w1 { background:url(images/shadow.png) no-repeat bottom right; position:absolute; z-index: 1000; top:4px; left:3px; /* IE6 fix: */ _background:none; _top:1px; }
37
+ .autocomplete-w2 { padding:0 6px 6px 0; }
38
+ .autocomplete { width:300px; border:1px solid #999; background:#FFF; cursor:default; text-align:left; max-height:350px; overflow:auto; margin:-6px 6px 6px -6px; /* IE specific: */ _height:350px; _margin:0px 6px 6px 0; overflow-x:hidden; }
39
+ .autocomplete .selected { background:#F0F0F0; }
40
+ .autocomplete div { padding:2px 5px; white-space:nowrap; }
41
  .autocomplete strong { font-weight:normal; color:#3399FF; }
skin/frontend/base/default/css/temando/autocomplete.css CHANGED
@@ -1,8 +1,8 @@
1
- .autocomplete-w1 { background:url(images/shadow.png) no-repeat bottom right; position:absolute; z-index: 1000; top:4px; left:3px; /* IE6 fix: */ _background:none; _top:1px; }
2
- .autocomplete-w2 { padding:0 6px 6px 0; }
3
- .autocomplete { width:300px; border:1px solid #999; background:#FFF; cursor:default; text-align:left; max-height:350px; overflow:auto; margin:-6px 6px 6px -6px; /* IE specific: */ _height:350px; _margin:0px 6px 6px 0; overflow-x:hidden; }
4
- .autocomplete .selected { background:#F0F0F0; }
5
- .autocomplete div { padding:2px 5px; white-space:nowrap; }
6
- .autocomplete strong { font-weight:normal; color:#3399FF; }
7
-
8
- .avs-active { background: url("images/ajax-s-load.gif") no-repeat scroll right center transparent !important; }
1
+ .autocomplete-w1 { background:url(images/shadow.png) no-repeat bottom right; position:absolute; z-index: 1000; top:4px; left:3px; /* IE6 fix: */ _background:none; _top:1px; }
2
+ .autocomplete-w2 { padding:0 6px 6px 0; }
3
+ .autocomplete { width:300px; border:1px solid #999; background:#FFF; cursor:default; text-align:left; max-height:350px; overflow:auto; margin:-6px 6px 6px -6px; /* IE specific: */ _height:350px; _margin:0px 6px 6px 0; overflow-x:hidden; }
4
+ .autocomplete .selected { background:#F0F0F0; }
5
+ .autocomplete div { padding:2px 5px; white-space:nowrap; }
6
+ .autocomplete strong { font-weight:normal; color:#3399FF; }
7
+
8
+ .avs-active { background: url("images/ajax-s-load.gif") no-repeat scroll right center transparent !important; }
skin/frontend/base/default/css/temando/cart.css CHANGED
@@ -1,19 +1,19 @@
1
- /* Cart page */
2
-
3
- .checkout-cart-index #postcode {
4
- width: 365px !important;
5
- max-width: 100% !important;
6
- }
7
-
8
- .destination-type li {
9
- margin-top: 0px !important;
10
- margin-bottom: 0px !important;
11
- }
12
-
13
- .destination-type label {
14
- margin-top: 3px !important;
15
- }
16
-
17
- .destination-type input {
18
- height: 20px !important;
19
  }
1
+ /* Cart page */
2
+
3
+ .checkout-cart-index #postcode {
4
+ width: 365px !important;
5
+ max-width: 100% !important;
6
+ }
7
+
8
+ .destination-type li {
9
+ margin-top: 0px !important;
10
+ margin-bottom: 0px !important;
11
+ }
12
+
13
+ .destination-type label {
14
+ margin-top: 3px !important;
15
+ }
16
+
17
+ .destination-type input {
18
+ height: 20px !important;
19
  }
skin/frontend/base/default/css/temando/product.css CHANGED
@@ -1,39 +1,39 @@
1
- /* Product page */
2
- .block-shipping .block-title strong {
3
- background-image: url("./images/i_shipping.gif");
4
- background-position: 0 0;
5
- background-repeat: no-repeat;
6
- padding-left: 21px;
7
- }
8
- .estimate-form {
9
- padding: 7px;
10
- }
11
- .estimate-form #pcs {
12
- width: 150px;
13
- padding: 4px;
14
- padding-right: 26px;
15
- /*border-radius: 4px 4px 4px 4px;
16
- box-shadow: 0 0 10px #EEEEEE inset;*/
17
- background-color: transparent;
18
- }
19
- .estimate-form .estimate-button {
20
- padding-top:5px;
21
- width: 100%;
22
- text-align: right;
23
- }
24
- .estimate-form select {
25
- margin-bottom: 5px;
26
- width: 182px;
27
- }
28
-
29
- .postcode-container input, .city-container input {
30
- margin: 2px 0px;
31
- width: 176px;
32
- }
33
-
34
- .postcode-container label .city-container label{
35
- background-color: #FAEBE7;
36
- background-image: url("../images/i_msg-error.gif");
37
- border-color: #F16048;
38
- color: #DF280A;
39
  }
1
+ /* Product page */
2
+ .block-shipping .block-title strong {
3
+ background-image: url("./images/i_shipping.gif");
4
+ background-position: 0 0;
5
+ background-repeat: no-repeat;
6
+ padding-left: 21px;
7
+ }
8
+ .estimate-form {
9
+ padding: 7px;
10
+ }
11
+ .estimate-form #pcs {
12
+ width: 150px;
13
+ padding: 4px;
14
+ padding-right: 26px;
15
+ /*border-radius: 4px 4px 4px 4px;
16
+ box-shadow: 0 0 10px #EEEEEE inset;*/
17
+ background-color: transparent;
18
+ }
19
+ .estimate-form .estimate-button {
20
+ padding-top:5px;
21
+ width: 100%;
22
+ text-align: right;
23
+ }
24
+ .estimate-form select {
25
+ margin-bottom: 5px;
26
+ width: 182px;
27
+ }
28
+
29
+ .postcode-container input, .city-container input {
30
+ margin: 2px 0px;
31
+ width: 176px;
32
+ }
33
+
34
+ .postcode-container label .city-container label{
35
+ background-color: #FAEBE7;
36
+ background-image: url("../images/i_msg-error.gif");
37
+ border-color: #F16048;
38
+ color: #DF280A;
39
  }
skin/frontend/base/default/css/temando/styles.css CHANGED
@@ -1,81 +1,81 @@
1
- table.insurance {
2
- border-spacing: 10px;
3
- }
4
-
5
- table.insurance td.c1 {
6
- background: none repeat scroll 0 0 #F9F3E3;
7
- border: 1px solid #BBAFA0;
8
- margin: 10px;
9
- padding: 10px;
10
- }
11
-
12
- table.insurance td.c2 {
13
- font-size: 11px;
14
- font-style: italic;
15
- padding-right: 8px;
16
- }
17
-
18
- table.insurance td label {
19
- color: #F18200;
20
- }
21
-
22
- div.customer-instructions, div.customer-comment, div.destination-type {
23
- background: none repeat scroll 0 0 #F9F3E3;
24
- border: 1px solid #BBAFA0;
25
- margin: 10px;
26
- padding: 15px;
27
- width: 92%;
28
- }
29
- table.delivery-options-table {
30
- background: none repeat scroll 0 0 #F9F3E3;
31
- border: 1px solid #BBAFA0;
32
- margin: 10px;
33
- padding: 15px;
34
- width: 97%;
35
- }
36
-
37
- table.delivery-options-table th, table.delivery-options-table-onestep th {
38
- font-weight: bold;
39
- color: #F18200;
40
- }
41
- table.delivery-options-table td, table.delivery-options-table-onestep td {
42
- border-right: none;
43
- width: auto;
44
- }
45
-
46
- div.customer-instructions-onestep, div.deliverby-onestep, div.customer-comment-onestep, div.destination-type-onestep {
47
- background: none repeat scroll 0 0 #F9F3E3;
48
- border: 1px solid #BBAFA0;
49
- margin: 5px 0;
50
- padding: 14px;
51
- width: 90%;
52
- }
53
-
54
- table.delivery-options-table-onestep {
55
- background: none repeat scroll 0 0 #F9F3E3;
56
- border: 1px solid #BBAFA0;
57
- margin: 5px 0;
58
- padding: 14px;
59
- width: 100%;
60
- }
61
-
62
- span.destination-type-header {
63
- font-weight: bold;
64
- color: #F18200;
65
- display: block;
66
- }
67
-
68
- .note {
69
- float: right;
70
- clear: both;
71
- font-style: italic;
72
- font-size: x-small;
73
- }
74
-
75
- textarea.comment {
76
- width: 100%;
77
- }
78
-
79
- input.instructions {
80
- width: 100%;
81
  }
1
+ table.insurance {
2
+ border-spacing: 10px;
3
+ }
4
+
5
+ table.insurance td.c1 {
6
+ background: none repeat scroll 0 0 #F9F3E3;
7
+ border: 1px solid #BBAFA0;
8
+ margin: 10px;
9
+ padding: 10px;
10
+ }
11
+
12
+ table.insurance td.c2 {
13
+ font-size: 11px;
14
+ font-style: italic;
15
+ padding-right: 8px;
16
+ }
17
+
18
+ table.insurance td label {
19
+ color: #F18200;
20
+ }
21
+
22
+ div.customer-instructions, div.customer-comment, div.destination-type {
23
+ background: none repeat scroll 0 0 #F9F3E3;
24
+ border: 1px solid #BBAFA0;
25
+ margin: 10px;
26
+ padding: 15px;
27
+ width: 92%;
28
+ }
29
+ table.delivery-options-table {
30
+ background: none repeat scroll 0 0 #F9F3E3;
31
+ border: 1px solid #BBAFA0;
32
+ margin: 10px;
33
+ padding: 15px;
34
+ width: 97%;
35
+ }
36
+
37
+ table.delivery-options-table th, table.delivery-options-table-onestep th {
38
+ font-weight: bold;
39
+ color: #F18200;
40
+ }
41
+ table.delivery-options-table td, table.delivery-options-table-onestep td {
42
+ border-right: none;
43
+ width: auto;
44
+ }
45
+
46
+ div.customer-instructions-onestep, div.deliverby-onestep, div.customer-comment-onestep, div.destination-type-onestep {
47
+ background: none repeat scroll 0 0 #F9F3E3;
48
+ border: 1px solid #BBAFA0;
49
+ margin: 5px 0;
50
+ padding: 14px;
51
+ width: 90%;
52
+ }
53
+
54
+ table.delivery-options-table-onestep {
55
+ background: none repeat scroll 0 0 #F9F3E3;
56
+ border: 1px solid #BBAFA0;
57
+ margin: 5px 0;
58
+ padding: 14px;
59
+ width: 100%;
60
+ }
61
+
62
+ span.destination-type-header {
63
+ font-weight: bold;
64
+ color: #F18200;
65
+ display: block;
66
+ }
67
+
68
+ .note {
69
+ float: right;
70
+ clear: both;
71
+ font-style: italic;
72
+ font-size: x-small;
73
+ }
74
+
75
+ textarea.comment {
76
+ width: 100%;
77
+ }
78
+
79
+ input.instructions {
80
+ width: 100%;
81
  }