tig_myparcel - Version 1.1.4

Version Notes

== v1.1.4 ==

- Pakjegemak extra address-validation on order detail page

known bugs:
None. Please contact us if you find a bug.

== v1.1.3 ==

- Print-position overlay optimised
- New translations
- Extended logging functionality

Download this release

Release Info

Developer TIG
Extension tig_myparcel
Version 1.1.4
Comparing to
See all releases


Version 1.1.4

Files changed (72) hide show
  1. app/code/community/TIG/MyParcel2014/Block/Adminhtml/Sales/Order/Shipment/Create/ConsignmentOptions.php +241 -0
  2. app/code/community/TIG/MyParcel2014/Block/Adminhtml/Sales/Order/Shipment/ShippingInfo.php +119 -0
  3. app/code/community/TIG/MyParcel2014/Block/Adminhtml/Sales/Order/View/ShippingInfo.php +88 -0
  4. app/code/community/TIG/MyParcel2014/Block/Adminhtml/System/Config/SupportTab.php +99 -0
  5. app/code/community/TIG/MyParcel2014/Block/Adminhtml/Widget/Grid/Column/Renderer/ShippingStatus.php +103 -0
  6. app/code/community/TIG/MyParcel2014/Block/Checkout/PgAddress.php +54 -0
  7. app/code/community/TIG/MyParcel2014/Block/Pakjegemak.php +5 -0
  8. app/code/community/TIG/MyParcel2014/Exception.php +100 -0
  9. app/code/community/TIG/MyParcel2014/Helper/AddressValidation.php +152 -0
  10. app/code/community/TIG/MyParcel2014/Helper/Data.php +986 -0
  11. app/code/community/TIG/MyParcel2014/Model/Adminhtml/Observer/OrderGrid.php +476 -0
  12. app/code/community/TIG/MyParcel2014/Model/Adminhtml/Observer/SystemConfig.php +96 -0
  13. app/code/community/TIG/MyParcel2014/Model/Adminhtml/Support/Logs.php +172 -0
  14. app/code/community/TIG/MyParcel2014/Model/Api/MyParcel.php +666 -0
  15. app/code/community/TIG/MyParcel2014/Model/Carrier/MyParcel.php +308 -0
  16. app/code/community/TIG/MyParcel2014/Model/Carrier/System/Config/Source/RateType.php +62 -0
  17. app/code/community/TIG/MyParcel2014/Model/Observer/Cron.php +103 -0
  18. app/code/community/TIG/MyParcel2014/Model/Observer/SaveConfig.php +79 -0
  19. app/code/community/TIG/MyParcel2014/Model/Observer/SavePgAddress.php +440 -0
  20. app/code/community/TIG/MyParcel2014/Model/Observer/SaveShipment.php +90 -0
  21. app/code/community/TIG/MyParcel2014/Model/Resource/Order/Grid/Collection.php +97 -0
  22. app/code/community/TIG/MyParcel2014/Model/Resource/Setup.php +91 -0
  23. app/code/community/TIG/MyParcel2014/Model/Resource/Shipment.php +30 -0
  24. app/code/community/TIG/MyParcel2014/Model/Resource/Shipment/Collection.php +9 -0
  25. app/code/community/TIG/MyParcel2014/Model/Shipment.php +606 -0
  26. app/code/community/TIG/MyParcel2014/Model/System/Config/Source/A4a6.php +63 -0
  27. app/code/community/TIG/MyParcel2014/Model/System/Config/Source/Customs.php +75 -0
  28. app/code/community/TIG/MyParcel2014/Model/System/Config/Source/StreetField.php +144 -0
  29. app/code/community/TIG/MyParcel2014/Model/System/Config/Source/Yesno.php +63 -0
  30. app/code/community/TIG/MyParcel2014/controllers/Adminhtml/ConfigController.php +147 -0
  31. app/code/community/TIG/MyParcel2014/controllers/Adminhtml/ShipmentController.php +689 -0
  32. app/code/community/TIG/MyParcel2014/controllers/IndexController.php +46 -0
  33. app/code/community/TIG/MyParcel2014/data/tig_myparcel_setup/data-upgrade-0.1.0-1.1.1.php +45 -0
  34. app/code/community/TIG/MyParcel2014/etc/adminhtml.xml +26 -0
  35. app/code/community/TIG/MyParcel2014/etc/config.xml +367 -0
  36. app/code/community/TIG/MyParcel2014/etc/system.xml +425 -0
  37. app/code/community/TIG/MyParcel2014/sql/tig_myparcel_setup/install-0.1.0.php +181 -0
  38. app/design/adminhtml/default/default/layout/TIG/tig_myparcel.xml +99 -0
  39. app/design/adminhtml/default/default/template/TIG/MyParcel2014/sales/order/address/warning.phtml +50 -0
  40. app/design/adminhtml/default/default/template/TIG/MyParcel2014/sales/order/mass_actions.phtml +127 -0
  41. app/design/adminhtml/default/default/template/TIG/MyParcel2014/sales/order/shipment/create/consignment_options.phtml +131 -0
  42. app/design/adminhtml/default/default/template/TIG/MyParcel2014/sales/order/shipment/shipping_info.phtml +86 -0
  43. app/design/adminhtml/default/default/template/TIG/MyParcel2014/sales/order/view/shipping_info.phtml +51 -0
  44. app/design/adminhtml/default/default/template/TIG/MyParcel2014/system/config/edit.phtml +346 -0
  45. app/design/adminhtml/default/default/template/TIG/MyParcel2014/system/config/supportTab.phtml +151 -0
  46. app/design/frontend/base/default/layout/TIG/tig_myparcel.xml +80 -0
  47. app/design/frontend/base/default/template/TIG/MyParcel2014/checkout/pg_address.phtml +103 -0
  48. app/design/frontend/base/default/template/TIG/MyParcel2014/onestepcheckout/shipping_method.phtml +86 -0
  49. app/design/frontend/base/default/template/TIG/MyParcel2014/pakjegemak.phtml +88 -0
  50. app/etc/modules/TIG_MyParcel2014.xml +14 -0
  51. app/locale/en_US/TIG_MyParcel2014.csv +149 -0
  52. app/locale/nl_NL/TIG_MyParcel2014.csv +149 -0
  53. package.xml +42 -0
  54. skin/adminhtml/default/default/css/TIG/MyParcel2014/styles.css +0 -0
  55. skin/adminhtml/default/default/css/TIG/MyParcel2014/system_config_edit.css +5 -0
  56. skin/adminhtml/default/default/css/TIG/MyParcel2014/system_config_edit_myparcel.css +34 -0
  57. skin/adminhtml/default/default/css/TIG/MyParcel2014/system_config_edit_myparcel_magento16.css +2 -0
  58. skin/adminhtml/default/default/images/TIG/MyParcel2014/bkg_tooltip.png +0 -0
  59. skin/adminhtml/default/default/images/TIG/MyParcel2014/btn_download_icon.png +0 -0
  60. skin/adminhtml/default/default/images/TIG/MyParcel2014/glyph_error.gif +0 -0
  61. skin/adminhtml/default/default/images/TIG/MyParcel2014/glyph_info.gif +0 -0
  62. skin/adminhtml/default/default/images/TIG/MyParcel2014/glyph_manual.png +0 -0
  63. skin/adminhtml/default/default/images/TIG/MyParcel2014/glyph_pdf.png +0 -0
  64. skin/adminhtml/default/default/images/TIG/MyParcel2014/glyph_success.gif +0 -0
  65. skin/adminhtml/default/default/images/TIG/MyParcel2014/glyph_warning.gif +0 -0
  66. skin/adminhtml/default/default/images/TIG/MyParcel2014/icon-tooltip.png +0 -0
  67. skin/adminhtml/default/default/images/TIG/MyParcel2014/legend.gif +0 -0
  68. skin/adminhtml/default/default/images/TIG/MyParcel2014/logo_myparcel.png +0 -0
  69. skin/adminhtml/default/default/images/TIG/MyParcel2014/logo_myparcel_19.png +0 -0
  70. skin/adminhtml/default/default/images/TIG/MyParcel2014/logo_myparcel_38.png +0 -0
  71. skin/adminhtml/default/default/images/TIG/MyParcel2014/tig_logo_medium.gif +0 -0
  72. skin/frontend/base/default/js/TIG/MyParcel2014/pg_address.js +157 -0
app/code/community/TIG/MyParcel2014/Block/Adminhtml/Sales/Order/Shipment/Create/ConsignmentOptions.php ADDED
@@ -0,0 +1,241 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * ___________ __ __
4
+ * \__ ___/____ _/ |_ _____ | |
5
+ * | | / _ \\ __\\__ \ | |
6
+ * | | | |_| || | / __ \_| |__
7
+ * |____| \____/ |__| (____ /|____/
8
+ * \/
9
+ * ___ __ __
10
+ * | | ____ _/ |_ ____ _______ ____ ____ _/ |_
11
+ * | | / \\ __\_/ __ \\_ __ \ / \ _/ __ \\ __\
12
+ * | || | \| | \ ___/ | | \/| | \\ ___/ | |
13
+ * |___||___| /|__| \_____>|__| |___| / \_____>|__|
14
+ * \/ \/
15
+ * ________
16
+ * / _____/_______ ____ __ __ ______
17
+ * / \ ___\_ __ \ / _ \ | | \\____ \
18
+ * \ \_\ \| | \/| |_| || | /| |_| |
19
+ * \______ /|__| \____/ |____/ | __/
20
+ * \/ |__|
21
+ *
22
+ * NOTICE OF LICENSE
23
+ *
24
+ * This source file is subject to the Creative Commons License.
25
+ * It is available through the world-wide-web at this URL:
26
+ * http://creativecommons.org/licenses/by-nc-nd/3.0/nl/deed.en_US
27
+ * If you are unable to obtain it through the world-wide-web, please send an email
28
+ * to servicedesk@tig.nl so we can send you a copy immediately.
29
+ *
30
+ * DISCLAIMER
31
+ *
32
+ * Do not edit or add to this file if you wish to upgrade this module to newer
33
+ * versions in the future. If you wish to customize this module for your
34
+ * needs please contact servicedesk@tig.nl for more information.
35
+ *
36
+ * @copyright Copyright (c) 2014 Total Internet Group B.V. (http://www.tig.nl)
37
+ * @license http://creativecommons.org/licenses/by-nc-nd/3.0/nl/deed.en_US
38
+ *
39
+ * @method boolean hasShipment()
40
+ * @method boolean hasShipmentBaseGrandTotal()
41
+ *
42
+ * @method TIG_MyParcel2014_Block_Adminhtml_Sales_Order_Shipment_Create_ConsignmentOptions setShipment(Mage_Sales_Model_Order_Shipment $value)
43
+ * @method TIG_MyParcel2014_Block_Adminhtml_Sales_Order_Shipment_Create_ConsignmentOptions setShipmentBaseGrandTotal(float $value)
44
+ *
45
+ */
46
+ class TIG_MyParcel2014_Block_Adminhtml_Sales_Order_Shipment_Create_ConsignmentOptions extends Mage_Adminhtml_Block_Abstract
47
+ {
48
+ /**
49
+ * Do a few checks to see if the template should be rendered before actually rendering it.
50
+ *
51
+ * @return string
52
+ *
53
+ * @see Mage_Adminhtml_Block_Abstract::_toHtml()
54
+ */
55
+ protected function _toHtml()
56
+ {
57
+ $shipment = Mage::registry('current_shipment');
58
+
59
+ $helper = Mage::helper('tig_myparcel');
60
+ if (!$helper->isEnabled()
61
+ || !$shipment
62
+ || !$helper->shippingMethodIsMyParcel($shipment->getOrder()->getShippingMethod())
63
+ ) {
64
+ return '';
65
+ }
66
+
67
+ return parent::_toHtml();
68
+ }
69
+
70
+ /**
71
+ * Get current shipment
72
+ *
73
+ * @return Mage_Sales_Model_Order_Shipment.
74
+ */
75
+ public function getShipment()
76
+ {
77
+ if ($this->hasShipment()) {
78
+ return $this->_getData('shipment');
79
+ }
80
+
81
+ $shipment = Mage::registry('current_shipment');
82
+
83
+ $this->setShipment($shipment);
84
+ return $shipment;
85
+ }
86
+
87
+ /**
88
+ * Calculates a shipment's base grand total based on it's shipment items
89
+ *
90
+ * @return float|null
91
+ */
92
+ public function getOrderTotal()
93
+ {
94
+ if ($this->hasShipmentBaseGrandTotal()) {
95
+ return $this->_getData('shipment_base_grand_total');
96
+ }
97
+
98
+ /**
99
+ * Check if this Myparcel shipment has a linked Mage_Sales_Model_Order_Shipment object
100
+ */
101
+ $shipment = $this->getShipment();
102
+ if (!$shipment) {
103
+ return null;
104
+ }
105
+
106
+ /**
107
+ * Loop through all associated shipment items and add each item's row total to the shipment's total
108
+ */
109
+ $baseGrandTotal = 0;
110
+ $shipmentItems = $shipment->getAllItems();
111
+
112
+ /**
113
+ * @var Mage_Sales_Model_Order_Shipment_Item $shipmentItem
114
+ */
115
+ foreach ($shipmentItems as $shipmentItem) {
116
+ $qty = $shipmentItem->getQty();
117
+
118
+ /**
119
+ * The base price of a shipment item is only available through it's associated order item
120
+ */
121
+ $basePrice = $shipmentItem->getOrderItem()->getBasePrice();
122
+
123
+ /**
124
+ * Calculate and add the shipment item's row total
125
+ */
126
+ $totalBasePrice = $basePrice * $qty;
127
+ $baseGrandTotal += $totalBasePrice;
128
+ }
129
+
130
+ $this->setShipmentBaseGrandTotal($baseGrandTotal);
131
+ return $baseGrandTotal;
132
+ }
133
+
134
+ /**
135
+ * Check if shipment country needs customs
136
+ *
137
+ * @return bool
138
+ */
139
+ public function countryNeedsCustoms()
140
+ {
141
+ $shipment = $this->getShipment();
142
+ $helper = Mage::helper('tig_myparcel');
143
+
144
+ $shippingAddress = $shipment->getShippingAddress();
145
+
146
+ $countryCode = $shippingAddress->getCountry();
147
+
148
+ return $helper->countryNeedsCustoms($countryCode);
149
+
150
+ }
151
+
152
+ /**
153
+ * get storeid from where the order was placed
154
+ *
155
+ * @return int
156
+ */
157
+ public function getOrderStoreId()
158
+ {
159
+ $shipment = $this->getShipment();
160
+
161
+ return $shipment->getOrder()->getStoreId();
162
+ }
163
+
164
+ /**
165
+ * get the customs type array
166
+ *
167
+ * @return array
168
+ */
169
+ public function getCustomsTypeOptions()
170
+ {
171
+ return Mage::getModel('tig_myparcel/system_config_source_customs')->toOptionArray();
172
+ }
173
+
174
+ public function getIsSelected($shipmentOption)
175
+ {
176
+ $helper = Mage::helper('tig_myparcel');
177
+ $storeId = $this->getOrderStoreId();
178
+ $orderTotalShipped = $this->getOrderTotal();
179
+
180
+ $configValue = $helper->getConfig($shipmentOption,'shipment',$storeId);
181
+ if(!empty($configValue) && $configValue > 0){
182
+ if($orderTotalShipped >= $configValue){
183
+ return 'checked="checked"';
184
+ }
185
+ }
186
+ return '';
187
+ }
188
+
189
+ /**
190
+ * @return string
191
+ */
192
+ public function getIsHomeSelected()
193
+ {
194
+ return $this->getIsSelected('home_address_only');
195
+
196
+ }
197
+
198
+ /**
199
+ * @return string
200
+ */
201
+ public function getIsSignatureOnReceipt()
202
+ {
203
+ return $this->getIsSelected('signature_on_receipt');
204
+ }
205
+
206
+ /**
207
+ * @return string
208
+ */
209
+ public function getIsReturnOnNoAnswer()
210
+ {
211
+ return $this->getIsSelected('return_if_no_answer');
212
+ }
213
+
214
+ /**
215
+ * @return string
216
+ */
217
+ public function getIsInsured()
218
+ {
219
+ $helper = Mage::helper('tig_myparcel');
220
+ $storeId = $this->getOrderStoreId();
221
+ $orderTotalShipped = $this->getOrderTotal();
222
+ $insuredType = 'insured_50';
223
+ if($orderTotalShipped > 50 && $orderTotalShipped < 250){
224
+ $insuredType = 'insured_250';
225
+ }elseif($orderTotalShipped > 250){
226
+ $insuredType = 'insured_500';
227
+ }
228
+
229
+ $configValue = $helper->getConfig($insuredType,'shipment',$storeId);
230
+ if(!empty($configValue) && $configValue > 0){
231
+ if($orderTotalShipped < $configValue){
232
+ return array(
233
+ 'selected' => 'checked="checked"',
234
+ 'insuredAmount' => $configValue,
235
+ );
236
+ }
237
+ }
238
+
239
+ return '';
240
+ }
241
+ }
app/code/community/TIG/MyParcel2014/Block/Adminhtml/Sales/Order/Shipment/ShippingInfo.php ADDED
@@ -0,0 +1,119 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * ___________ __ __
4
+ * \__ ___/____ _/ |_ _____ | |
5
+ * | | / _ \\ __\\__ \ | |
6
+ * | | | |_| || | / __ \_| |__
7
+ * |____| \____/ |__| (____ /|____/
8
+ * \/
9
+ * ___ __ __
10
+ * | | ____ _/ |_ ____ _______ ____ ____ _/ |_
11
+ * | | / \\ __\_/ __ \\_ __ \ / \ _/ __ \\ __\
12
+ * | || | \| | \ ___/ | | \/| | \\ ___/ | |
13
+ * |___||___| /|__| \_____>|__| |___| / \_____>|__|
14
+ * \/ \/
15
+ * ________
16
+ * / _____/_______ ____ __ __ ______
17
+ * / \ ___\_ __ \ / _ \ | | \\____ \
18
+ * \ \_\ \| | \/| |_| || | /| |_| |
19
+ * \______ /|__| \____/ |____/ | __/
20
+ * \/ |__|
21
+ *
22
+ * NOTICE OF LICENSE
23
+ *
24
+ * This source file is subject to the Creative Commons License.
25
+ * It is available through the world-wide-web at this URL:
26
+ * http://creativecommons.org/licenses/by-nc-nd/3.0/nl/deed.en_US
27
+ * If you are unable to obtain it through the world-wide-web, please send an email
28
+ * to servicedesk@tig.nl so we can send you a copy immediately.
29
+ *
30
+ * DISCLAIMER
31
+ *
32
+ * Do not edit or add to this file if you wish to upgrade this module to newer
33
+ * versions in the future. If you wish to customize this module for your
34
+ * needs please contact servicedesk@tig.nl for more information.
35
+ *
36
+ * @copyright Copyright (c) 2014 Total Internet Group B.V. (http://www.tig.nl)
37
+ * @license http://creativecommons.org/licenses/by-nc-nd/3.0/nl/deed.en_US
38
+ */
39
+ class TIG_MyParcel2014_Block_Adminhtml_Sales_Order_Shipment_ShippingInfo extends Mage_Adminhtml_Block_Abstract
40
+ {
41
+ protected $_shipment;
42
+
43
+ public function __construct()
44
+ {
45
+ $shipmentId = $this->getRequest()->getParam('shipment_id');
46
+ $this->_shipment = Mage::getModel('sales/order_shipment')->load($shipmentId);
47
+
48
+ $myParcelShipment = Mage::getModel('tig_myparcel/shipment')->load($shipmentId, 'shipment_id');
49
+ Mage::log($myParcelShipment);
50
+ }
51
+
52
+ public function getPgAddressHtml()
53
+ {
54
+ $res = array();
55
+ $pgAddress = Mage::helper('tig_myparcel')->getPgAddress($this->_shipment->getOrder());
56
+
57
+ if($pgAddress)
58
+ {
59
+ $res = array(
60
+ $pgAddress->getCompany(),
61
+ implode(' ', $pgAddress->getStreet()),
62
+ $pgAddress->getPostcode() . ' ' . $pgAddress->getCity() . ' (' . $pgAddress->getCountry() . ')',
63
+ );
64
+ }
65
+
66
+ return empty($res) ? '' : '<p>' . implode('<br/>', $res) . '</p>';
67
+ }
68
+
69
+ public function isCredited()
70
+ {
71
+ return false;
72
+ //return $sdjdsajk->asdasdsad == 1;
73
+ }
74
+
75
+
76
+ public function getCreditText()
77
+ {
78
+ $helper = Mage::helper('tig_myparcel');
79
+ return $helper->__('Credit Consignment');
80
+ }
81
+
82
+ public function getRetourlinkText()
83
+ {
84
+ $helper = Mage::helper('tig_myparcel');
85
+ return $helper->__('Generate Retourlink');
86
+ }
87
+
88
+ public function getRetourlinkUrl()
89
+ {
90
+ $shipmentId = $this->getRequest()->getParam('shipment_id');
91
+ return $this->getUrl('myparcel_admin/adminhtml_config/generateRetourlink',array('shipment_id'=>$shipmentId));
92
+ }
93
+
94
+ public function getCreditUrl()
95
+ {
96
+ $shipmentId = $this->getRequest()->getParam('shipment_id');
97
+ return $this->getUrl('myparcel_admin/adminhtml_config/creditConsignment',array('shipment_id'=>$shipmentId));
98
+ }
99
+
100
+ /**
101
+ * Do a few checks to see if the template should be rendered before actually rendering it.
102
+ *
103
+ * @return string
104
+ *
105
+ * @see Mage_Adminhtml_Block_Abstract::_toHtml()
106
+ */
107
+ protected function _toHtml()
108
+ {
109
+ $helper = Mage::helper('tig_myparcel');
110
+
111
+ if (!$helper->isEnabled()
112
+ || !$this->_shipment
113
+ || !$helper->shippingMethodIsMyParcel($this->_shipment->getOrder()->getShippingMethod())
114
+ ) {
115
+ return '';
116
+ }
117
+ return parent::_toHtml();
118
+ }
119
+ }
app/code/community/TIG/MyParcel2014/Block/Adminhtml/Sales/Order/View/ShippingInfo.php ADDED
@@ -0,0 +1,88 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * ___________ __ __
4
+ * \__ ___/____ _/ |_ _____ | |
5
+ * | | / _ \\ __\\__ \ | |
6
+ * | | | |_| || | / __ \_| |__
7
+ * |____| \____/ |__| (____ /|____/
8
+ * \/
9
+ * ___ __ __
10
+ * | | ____ _/ |_ ____ _______ ____ ____ _/ |_
11
+ * | | / \\ __\_/ __ \\_ __ \ / \ _/ __ \\ __\
12
+ * | || | \| | \ ___/ | | \/| | \\ ___/ | |
13
+ * |___||___| /|__| \_____>|__| |___| / \_____>|__|
14
+ * \/ \/
15
+ * ________
16
+ * / _____/_______ ____ __ __ ______
17
+ * / \ ___\_ __ \ / _ \ | | \\____ \
18
+ * \ \_\ \| | \/| |_| || | /| |_| |
19
+ * \______ /|__| \____/ |____/ | __/
20
+ * \/ |__|
21
+ *
22
+ * NOTICE OF LICENSE
23
+ *
24
+ * This source file is subject to the Creative Commons License.
25
+ * It is available through the world-wide-web at this URL:
26
+ * http://creativecommons.org/licenses/by-nc-nd/3.0/nl/deed.en_US
27
+ * If you are unable to obtain it through the world-wide-web, please send an email
28
+ * to servicedesk@tig.nl so we can send you a copy immediately.
29
+ *
30
+ * DISCLAIMER
31
+ *
32
+ * Do not edit or add to this file if you wish to upgrade this module to newer
33
+ * versions in the future. If you wish to customize this module for your
34
+ * needs please contact servicedesk@tig.nl for more information.
35
+ *
36
+ * @copyright Copyright (c) 2014 Total Internet Group B.V. (http://www.tig.nl)
37
+ * @license http://creativecommons.org/licenses/by-nc-nd/3.0/nl/deed.en_US
38
+ */
39
+ class TIG_MyParcel2014_Block_Adminhtml_Sales_Order_View_ShippingInfo extends Mage_Adminhtml_Block_Abstract
40
+ {
41
+ protected $_order;
42
+
43
+ public function __construct()
44
+ {
45
+ $orderId = $this->getRequest()->getParam('order_id');
46
+ $this->_order = Mage::getModel('sales/order')->load($orderId);
47
+ }
48
+
49
+ public function getPgAddressHtml()
50
+ {
51
+ $res = array();
52
+ $pgAddress = Mage::helper('tig_myparcel')->getPgAddress($this->_order);
53
+ $shippingMethod = $this->_order->getShippingMethod();
54
+
55
+ if ($pgAddress && Mage::helper('tig_myparcel')->shippingMethodIsPakjegemak($shippingMethod))
56
+ {
57
+ $res = array(
58
+ $pgAddress->getCompany(),
59
+ implode(' ', $pgAddress->getStreet()),
60
+ $pgAddress->getPostcode() . ' ' . $pgAddress->getCity() . ' (' . $pgAddress->getCountry() . ')',
61
+ );
62
+ }
63
+
64
+ return empty($res) ? '' : '<p>' . implode('<br/>', $res) . '</p>';
65
+ }
66
+
67
+ /**
68
+ * Do a few checks to see if the template should be rendered before actually rendering it.
69
+ *
70
+ * @return string
71
+ *
72
+ * @see Mage_Adminhtml_Block_Abstract::_toHtml()
73
+ */
74
+ protected function _toHtml()
75
+ {
76
+ $helper = Mage::helper('tig_myparcel');
77
+ $shippingMethod = $this->_order->getShippingMethod();
78
+
79
+ if (!$helper->isEnabled()
80
+ || !$this->_order
81
+ || !$helper->shippingMethodIsMyParcel($shippingMethod)
82
+ ) {
83
+ return '';
84
+ }
85
+
86
+ return parent::_toHtml();
87
+ }
88
+ }
app/code/community/TIG/MyParcel2014/Block/Adminhtml/System/Config/SupportTab.php ADDED
@@ -0,0 +1,99 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * ___________ __ __
4
+ * \__ ___/____ _/ |_ _____ | |
5
+ * | | / _ \\ __\\__ \ | |
6
+ * | | | |_| || | / __ \_| |__
7
+ * |____| \____/ |__| (____ /|____/
8
+ * \/
9
+ * ___ __ __
10
+ * | | ____ _/ |_ ____ _______ ____ ____ _/ |_
11
+ * | | / \\ __\_/ __ \\_ __ \ / \ _/ __ \\ __\
12
+ * | || | \| | \ ___/ | | \/| | \\ ___/ | |
13
+ * |___||___| /|__| \_____>|__| |___| / \_____>|__|
14
+ * \/ \/
15
+ * ________
16
+ * / _____/_______ ____ __ __ ______
17
+ * / \ ___\_ __ \ / _ \ | | \\____ \
18
+ * \ \_\ \| | \/| |_| || | /| |_| |
19
+ * \______ /|__| \____/ |____/ | __/
20
+ * \/ |__|
21
+ *
22
+ * NOTICE OF LICENSE
23
+ *
24
+ * This source file is subject to the Creative Commons License.
25
+ * It is available through the world-wide-web at this URL:
26
+ * http://creativecommons.org/licenses/by-nc-nd/3.0/nl/deed.en_US
27
+ * If you are unable to obtain it through the world-wide-web, please send an email
28
+ * to servicedesk@tig.nl so we can send you a copy immediately.
29
+ *
30
+ * DISCLAIMER
31
+ *
32
+ * Do not edit or add to this file if you wish to upgrade this module to newer
33
+ * versions in the future. If you wish to customize this module for your
34
+ * needs please contact servicedesk@tig.nl for more information.
35
+ *
36
+ * @copyright Copyright (c) 2014 Total Internet Group B.V. (http://www.tig.nl)
37
+ * @license http://creativecommons.org/licenses/by-nc-nd/3.0/nl/deed.en_US
38
+ */
39
+ class TIG_MyParcel2014_Block_Adminhtml_System_Config_SupportTab
40
+ extends Mage_Adminhtml_Block_Abstract
41
+ implements Varien_Data_Form_Element_Renderer_Interface
42
+ {
43
+
44
+ /**
45
+ * Css files loaded for MyParcel's system > config section
46
+ */
47
+ const SYSTEM_CONFIG_EDIT_CSS_FILE = 'css/TIG/MyParcel2014/system_config_edit_myparcel.css';
48
+ const MAGENTO_16_CSS_FILE = 'css/TIG/MyParcel2014/system_config_edit_myparcel_magento16.css';
49
+
50
+ /**
51
+ * @var string
52
+ */
53
+ protected $_template = 'TIG/MyParcel2014/system/config/supportTab.phtml';
54
+
55
+ protected function _prepareLayout()
56
+ {
57
+ $this->getLayout()
58
+ ->getBlock('head')
59
+ ->addCss(self::SYSTEM_CONFIG_EDIT_CSS_FILE);
60
+
61
+ /**
62
+ * For Magento 1.6 and 1.11 we need to add another css file.
63
+ */
64
+ $helper = Mage::helper('tig_myparcel');
65
+ $isEnterprise = $helper->isEnterprise();
66
+
67
+ /**
68
+ * Get the minimum version requirement for the current Magento edition.
69
+ */
70
+ if($isEnterprise) {
71
+ $minimumVersion = '1.12.0.0';
72
+ } else {
73
+ $minimumVersion = '1.7.0.0';
74
+ }
75
+
76
+ /**
77
+ * Check if the current version is below the minimum version requirement.
78
+ */
79
+ $isBelowMinimumVersion = version_compare(Mage::getVersion(), $minimumVersion, '<');
80
+ if ($isBelowMinimumVersion) {
81
+ $this->getLayout()
82
+ ->getBlock('head')
83
+ ->addCss(self::MAGENTO_16_CSS_FILE);
84
+ }
85
+
86
+ return parent::_prepareLayout();
87
+ }
88
+
89
+ /**
90
+ * Render fieldset html
91
+ *
92
+ * @param Varien_Data_Form_Element_Abstract $element
93
+ * @return string
94
+ */
95
+ public function render(Varien_Data_Form_Element_Abstract $element)
96
+ {
97
+ return $this->toHtml();
98
+ }
99
+ }
app/code/community/TIG/MyParcel2014/Block/Adminhtml/Widget/Grid/Column/Renderer/ShippingStatus.php ADDED
@@ -0,0 +1,103 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * ___________ __ __
4
+ * \__ ___/____ _/ |_ _____ | |
5
+ * | | / _ \\ __\\__ \ | |
6
+ * | | | |_| || | / __ \_| |__
7
+ * |____| \____/ |__| (____ /|____/
8
+ * \/
9
+ * ___ __ __
10
+ * | | ____ _/ |_ ____ _______ ____ ____ _/ |_
11
+ * | | / \\ __\_/ __ \\_ __ \ / \ _/ __ \\ __\
12
+ * | || | \| | \ ___/ | | \/| | \\ ___/ | |
13
+ * |___||___| /|__| \_____>|__| |___| / \_____>|__|
14
+ * \/ \/
15
+ * ________
16
+ * / _____/_______ ____ __ __ ______
17
+ * / \ ___\_ __ \ / _ \ | | \\____ \
18
+ * \ \_\ \| | \/| |_| || | /| |_| |
19
+ * \______ /|__| \____/ |____/ | __/
20
+ * \/ |__|
21
+ *
22
+ * NOTICE OF LICENSE
23
+ *
24
+ * This source file is subject to the Creative Commons License.
25
+ * It is available through the world-wide-web at this URL:
26
+ * http://creativecommons.org/licenses/by-nc-nd/3.0/nl/deed.en_US
27
+ * If you are unable to obtain it through the world-wide-web, please send an email
28
+ * to servicedesk@tig.nl so we can send you a copy immediately.
29
+ *
30
+ * DISCLAIMER
31
+ *
32
+ * Do not edit or add to this file if you wish to upgrade this module to newer
33
+ * versions in the future. If you wish to customize this module for your
34
+ * needs please contact servicedesk@tig.nl for more information.
35
+ *
36
+ * @copyright Copyright (c) 2014 Total Internet Group B.V. (http://www.tig.nl)
37
+ * @license http://creativecommons.org/licenses/by-nc-nd/3.0/nl/deed.en_US
38
+ */
39
+ class TIG_MyParcel2014_Block_Adminhtml_Widget_Grid_Column_Renderer_ShippingStatus
40
+ extends Mage_Adminhtml_Block_Widget_Grid_Column_Renderer_Text
41
+ {
42
+ /**
43
+ * Additional column names used
44
+ */
45
+ const SHIPPING_METHOD_COLUMN = 'shipping_method';
46
+ const POSTCODE_COLUMN = 'postcode';
47
+ const COUNTRY_ID_COLUMN = 'country_id';
48
+ const BARCODE_COLUMN = 'barcode';
49
+
50
+ /**
51
+ * Renders the barcode column. This column will be empty for non-MyParcel shipments.
52
+ * If the shipment has been confirmed, it will be displayed as a track& trace URL.
53
+ * Otherwise the bare code will be displayed.
54
+ *
55
+ * @param Varien_Object $row
56
+ *
57
+ * @return string
58
+ */
59
+ public function render(Varien_Object $row)
60
+ {
61
+ /**
62
+ * The shipment was not shipped using MyParcel
63
+ */
64
+ $shippingMethod = $row->getData(self::SHIPPING_METHOD_COLUMN);
65
+ if (!Mage::helper('tig_myparcel')->shippingMethodIsMyParcel($shippingMethod)) {
66
+ return '';
67
+ }
68
+
69
+ /**
70
+ * Check if any data is available.
71
+ */
72
+ $value = $row->getData($this->getColumn()->getIndex());
73
+ if (!$value) {
74
+ return '';
75
+ }
76
+
77
+ /**
78
+ * Create a track & trace URL based on shipping destination
79
+ */
80
+ $countryCode = $row->getData(self::COUNTRY_ID_COLUMN);
81
+ $postcode = $row->getData(self::POSTCODE_COLUMN);
82
+ $destinationData = array(
83
+ 'countryCode' => $countryCode,
84
+ 'postcode' => $postcode,
85
+ );
86
+
87
+ $barcodeData = array();
88
+ $barcodes = explode(',', $row->getData(self::BARCODE_COLUMN));
89
+ $statusses = explode(',', $value);
90
+ foreach ($statusses as $key => $status) {
91
+ if (!empty($barcodes[$key])) {
92
+ $barcodeUrl = Mage::helper('tig_myparcel')->getBarcodeUrl($barcodes[$key], $destinationData, false, true);
93
+
94
+ $barcodeData[] = "<small>{$status}</small> - <a href='{$barcodeUrl}' target='_blank'>{$barcodes[$key]}</a>";
95
+ } else {
96
+ $barcodeData[] = $status;
97
+ }
98
+ }
99
+
100
+ $barcodeHtml = implode('<br />', $barcodeData);
101
+ return $barcodeHtml;
102
+ }
103
+ }
app/code/community/TIG/MyParcel2014/Block/Checkout/PgAddress.php ADDED
@@ -0,0 +1,54 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * ___________ __ __
4
+ * \__ ___/____ _/ |_ _____ | |
5
+ * | | / _ \\ __\\__ \ | |
6
+ * | | | |_| || | / __ \_| |__
7
+ * |____| \____/ |__| (____ /|____/
8
+ * \/
9
+ * ___ __ __
10
+ * | | ____ _/ |_ ____ _______ ____ ____ _/ |_
11
+ * | | / \\ __\_/ __ \\_ __ \ / \ _/ __ \\ __\
12
+ * | || | \| | \ ___/ | | \/| | \\ ___/ | |
13
+ * |___||___| /|__| \_____>|__| |___| / \_____>|__|
14
+ * \/ \/
15
+ * ________
16
+ * / _____/_______ ____ __ __ ______
17
+ * / \ ___\_ __ \ / _ \ | | \\____ \
18
+ * \ \_\ \| | \/| |_| || | /| |_| |
19
+ * \______ /|__| \____/ |____/ | __/
20
+ * \/ |__|
21
+ *
22
+ * NOTICE OF LICENSE
23
+ *
24
+ * This source file is subject to the Creative Commons License.
25
+ * It is available through the world-wide-web at this URL:
26
+ * http://creativecommons.org/licenses/by-nc-nd/3.0/nl/deed.en_US
27
+ * If you are unable to obtain it through the world-wide-web, please send an email
28
+ * to servicedesk@tig.nl so we can send you a copy immediately.
29
+ *
30
+ * DISCLAIMER
31
+ *
32
+ * Do not edit or add to this file if you wish to upgrade this module to newer
33
+ * versions in the future. If you wish to customize this module for your
34
+ * needs please contact servicedesk@tig.nl for more information.
35
+ *
36
+ * @copyright Copyright (c) 2014 Total Internet Group B.V. (http://www.tig.nl)
37
+ * @license http://creativecommons.org/licenses/by-nc-nd/3.0/nl/deed.en_US
38
+ */
39
+ class TIG_MyParcel2014_Block_Checkout_PgAddress extends Mage_Core_Block_Template
40
+ {
41
+ /**
42
+ * Check if MyParcel is enabled before rendering the template.
43
+ *
44
+ * @return string
45
+ */
46
+ protected function _toHtml()
47
+ {
48
+ if (!Mage::helper('tig_myparcel')->isEnabled() && false) {
49
+ return '';
50
+ }
51
+
52
+ return parent::_toHtml();
53
+ }
54
+ }
app/code/community/TIG/MyParcel2014/Block/Pakjegemak.php ADDED
@@ -0,0 +1,5 @@
 
 
 
 
 
1
+ <?php
2
+ class TIG_MyParcel2014_Block_Pakjegemak extends Mage_Core_Block_Template
3
+ {
4
+ protected $_template = 'TIG/MyParcel2014/pakjegemak.phtml';
5
+ }
app/code/community/TIG/MyParcel2014/Exception.php ADDED
@@ -0,0 +1,100 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * ___________ __ __
4
+ * \__ ___/____ _/ |_ _____ | |
5
+ * | | / _ \\ __\\__ \ | |
6
+ * | | | |_| || | / __ \_| |__
7
+ * |____| \____/ |__| (____ /|____/
8
+ * \/
9
+ * ___ __ __
10
+ * | | ____ _/ |_ ____ _______ ____ ____ _/ |_
11
+ * | | / \\ __\_/ __ \\_ __ \ / \ _/ __ \\ __\
12
+ * | || | \| | \ ___/ | | \/| | \\ ___/ | |
13
+ * |___||___| /|__| \_____>|__| |___| / \_____>|__|
14
+ * \/ \/
15
+ * ________
16
+ * / _____/_______ ____ __ __ ______
17
+ * / \ ___\_ __ \ / _ \ | | \\____ \
18
+ * \ \_\ \| | \/| |_| || | /| |_| |
19
+ * \______ /|__| \____/ |____/ | __/
20
+ * \/ |__|
21
+ *
22
+ * NOTICE OF LICENSE
23
+ *
24
+ * This source file is subject to the Creative Commons License.
25
+ * It is available through the world-wide-web at this URL:
26
+ * http://creativecommons.org/licenses/by-nc-nd/3.0/nl/deed.en_US
27
+ * If you are unable to obtain it through the world-wide-web, please send an email
28
+ * to servicedesk@tig.nl so we can send you a copy immediately.
29
+ *
30
+ * DISCLAIMER
31
+ *
32
+ * Do not edit or add to this file if you wish to upgrade this module to newer
33
+ * versions in the future. If you wish to customize this module for your
34
+ * needs please contact servicedesk@tig.nl for more information.
35
+ *
36
+ * @copyright Copyright (c) 2014 Total Internet Group B.V. (http://www.tig.nl)
37
+ * @license http://creativecommons.org/licenses/by-nc-nd/3.0/nl/deed.en_US
38
+ */
39
+ class TIG_MyParcel2014_Exception extends Mage_Core_Exception
40
+ {
41
+ /**
42
+ * Our error codes are strings, however the core Exception class only accepts integers, so we need to overload it.
43
+ *
44
+ * @param string $message
45
+ * @param mixed $code
46
+ * @param Exception|null $previous
47
+ *
48
+ * @see Exception::__construct()
49
+ *
50
+ * @link http://www.php.net/manual/en/exception.construct.php
51
+ */
52
+ public function __construct($message, $code = 0, Exception $previous = null)
53
+ {
54
+ parent::__construct($message, 0, $previous);
55
+
56
+ /**
57
+ * Replace the code with the actual, non-integer code.
58
+ */
59
+ if ($code !== 0) {
60
+ $code = (string) $code;
61
+ $this->code = $code;
62
+ }
63
+ }
64
+
65
+ /**
66
+ * Custom __toString method that includes the error code, if present.
67
+ *
68
+ * @return string
69
+ *
70
+ * @see Exception::__toString()
71
+ *
72
+ * @link http://www.php.net/manual/en/exception.tostring.php
73
+ */
74
+ public function __toString()
75
+ {
76
+ $string = "exception '"
77
+ . __CLASS__
78
+ . "' with message '"
79
+ . $this->getMessage()
80
+ . "'";
81
+
82
+ $code = $this->getCode();
83
+ if ($code !== 0 && !empty($code)) {
84
+ $string .= " and code '"
85
+ . $this->getCode()
86
+ . "'";
87
+ }
88
+
89
+ $string .= " in "
90
+ . $this->getFile()
91
+ . ':'
92
+ . $this->getLine()
93
+ . PHP_EOL
94
+ . 'Stack trace:'
95
+ . PHP_EOL
96
+ . $this->getTraceAsString();
97
+
98
+ return $string;
99
+ }
100
+ }
app/code/community/TIG/MyParcel2014/Helper/AddressValidation.php ADDED
@@ -0,0 +1,152 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * ___________ __ __
4
+ * \__ ___/____ _/ |_ _____ | |
5
+ * | | / _ \\ __\\__ \ | |
6
+ * | | | |_| || | / __ \_| |__
7
+ * |____| \____/ |__| (____ /|____/
8
+ * \/
9
+ * ___ __ __
10
+ * | | ____ _/ |_ ____ _______ ____ ____ _/ |_
11
+ * | | / \\ __\_/ __ \\_ __ \ / \ _/ __ \\ __\
12
+ * | || | \| | \ ___/ | | \/| | \\ ___/ | |
13
+ * |___||___| /|__| \_____>|__| |___| / \_____>|__|
14
+ * \/ \/
15
+ * ________
16
+ * / _____/_______ ____ __ __ ______
17
+ * / \ ___\_ __ \ / _ \ | | \\____ \
18
+ * \ \_\ \| | \/| |_| || | /| |_| |
19
+ * \______ /|__| \____/ |____/ | __/
20
+ * \/ |__|
21
+ *
22
+ * NOTICE OF LICENSE
23
+ *
24
+ * This source file is subject to the Creative Commons License.
25
+ * It is available through the world-wide-web at this URL:
26
+ * http://creativecommons.org/licenses/by-nc-nd/3.0/nl/deed.en_US
27
+ * If you are unable to obtain it through the world-wide-web, please send an email
28
+ * to servicedesk@tig.nl so we can send you a copy immediately.
29
+ *
30
+ * DISCLAIMER
31
+ *
32
+ * Do not edit or add to this file if you wish to upgrade this module to newer
33
+ * versions in the future. If you wish to customize this module for your
34
+ * needs please contact servicedesk@tig.nl for more information.
35
+ *
36
+ * @copyright Copyright (c) 2014 Total Internet Group B.V. (http://www.tig.nl)
37
+ * @license http://creativecommons.org/licenses/by-nc-nd/3.0/nl/deed.en_US
38
+ */
39
+ class TIG_MyParcel2014_Helper_AddressValidation extends TIG_MyParcel2014_Helper_Data
40
+ {
41
+ /**
42
+ * Constants containing XML paths to cif address configuration options
43
+ */
44
+ const XPATH_SPLIT_STREET = 'tig_myparcel/shipment/split_street';
45
+ const XPATH_STREETNAME_FIELD = 'tig_myparcel/shipment/streetname_field';
46
+ const XPATH_HOUSENUMBER_FIELD = 'tig_myparcel/shipment/housenr_field';
47
+ const XPATH_SPLIT_HOUSENUMBER = 'tig_myparcel/shipment/split_housenr';
48
+ const XPATH_HOUSENUMBER_EXTENSION_FIELD = 'tig_myparcel/shipment/housenr_extension_field';
49
+
50
+ /**
51
+ * Checks whether the given store uses split address lines.
52
+ *
53
+ * @param int|null $storeId
54
+ *
55
+ * @return boolean
56
+ */
57
+ public function useSplitStreet($storeId = null)
58
+ {
59
+ if (is_null($storeId)) {
60
+ $storeId = Mage::app()->getStore()->getId();
61
+ }
62
+
63
+ $useSplitStreet = Mage::getStoreConfigFlag(self::XPATH_SPLIT_STREET, $storeId);
64
+ return $useSplitStreet;
65
+ }
66
+
67
+ /**
68
+ * Checks whether the given store uses split housenumber values.
69
+ *
70
+ * @param int|null $storeId
71
+ *
72
+ * @return boolean
73
+ */
74
+ public function useSplitHousenumber($storeId = null)
75
+ {
76
+ if (is_null($storeId)) {
77
+ $storeId = Mage::app()->getStore()->getId();
78
+ }
79
+
80
+ $useSplitStreet = Mage::getStoreConfigFlag(self::XPATH_SPLIT_HOUSENUMBER, $storeId);
81
+ return $useSplitStreet;
82
+ }
83
+
84
+ /**
85
+ * Gets the address field number used for the streetname field.
86
+ *
87
+ * @param int|null $storeId
88
+ *
89
+ * @return int
90
+ */
91
+ public function getStreetnameField($storeId = null)
92
+ {
93
+ if (is_null($storeId)) {
94
+ $storeId = Mage::app()->getStore()->getId();
95
+ }
96
+
97
+ $streetnameField = (int) Mage::getStoreConfig(self::XPATH_STREETNAME_FIELD, $storeId);
98
+ return $streetnameField;
99
+ }
100
+
101
+ /**
102
+ * Gets the address field number used for the housenumber field.
103
+ *
104
+ * @param int|null $storeId
105
+ *
106
+ * @return int
107
+ */
108
+
109
+ public function getHousenumberField($storeId = null)
110
+ {
111
+ if (is_null($storeId)) {
112
+ $storeId = Mage::app()->getStore()->getId();
113
+ }
114
+
115
+ $housenumberField = (int) Mage::getStoreConfig(self::XPATH_HOUSENUMBER_FIELD, $storeId);
116
+ return $housenumberField;
117
+ }
118
+
119
+ /**
120
+ * Gets the address field number used for the housenumber extension field.
121
+ *
122
+ * @param int|null $storeId
123
+ *
124
+ * @return int
125
+ */
126
+ public function getHousenumberExtensionField($storeId = null)
127
+ {
128
+ if (is_null($storeId)) {
129
+ $storeId = Mage::app()->getStore()->getId();
130
+ }
131
+
132
+ $housenumberExtensionField = (int) Mage::getStoreConfig(self::XPATH_HOUSENUMBER_EXTENSION_FIELD, $storeId);
133
+ return $housenumberExtensionField;
134
+ }
135
+
136
+ /**
137
+ * Wrapper for the getAttributeValidationClass method to prevent errors in Magento 1.6.
138
+ *
139
+ * @param $attribute
140
+ *
141
+ * @return string
142
+ */
143
+ public function getAttributeValidationClass($attribute)
144
+ {
145
+ $addressHelper = Mage::helper('customer/address');
146
+ if (is_callable(array($addressHelper, 'getAttributeValidationClass'))) {
147
+ return $addressHelper->getAttributeValidationClass($attribute);
148
+ }
149
+
150
+ return '';
151
+ }
152
+ }
app/code/community/TIG/MyParcel2014/Helper/Data.php ADDED
@@ -0,0 +1,986 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * ___________ __ __
4
+ * \__ ___/____ _/ |_ _____ | |
5
+ * | | / _ \\ __\\__ \ | |
6
+ * | | | |_| || | / __ \_| |__
7
+ * |____| \____/ |__| (____ /|____/
8
+ * \/
9
+ * ___ __ __
10
+ * | | ____ _/ |_ ____ _______ ____ ____ _/ |_
11
+ * | | / \\ __\_/ __ \\_ __ \ / \ _/ __ \\ __\
12
+ * | || | \| | \ ___/ | | \/| | \\ ___/ | |
13
+ * |___||___| /|__| \_____>|__| |___| / \_____>|__|
14
+ * \/ \/
15
+ * ________
16
+ * / _____/_______ ____ __ __ ______
17
+ * / \ ___\_ __ \ / _ \ | | \\____ \
18
+ * \ \_\ \| | \/| |_| || | /| |_| |
19
+ * \______ /|__| \____/ |____/ | __/
20
+ * \/ |__|
21
+ *
22
+ * NOTICE OF LICENSE
23
+ *
24
+ * This source file is subject to the Creative Commons License.
25
+ * It is available through the world-wide-web at this URL:
26
+ * http://creativecommons.org/licenses/by-nc-nd/3.0/nl/deed.en_US
27
+ * If you are unable to obtain it through the world-wide-web, please send an email
28
+ * to servicedesk@tig.nl so we can send you a copy immediately.
29
+ *
30
+ * DISCLAIMER
31
+ *
32
+ * Do not edit or add to this file if you wish to upgrade this module to newer
33
+ * versions in the future. If you wish to customize this module for your
34
+ * needs please contact servicedesk@tig.nl for more information.
35
+ *
36
+ * @copyright Copyright (c) 2013 Total Internet Group B.V. (http://www.tig.nl)
37
+ * @license http://creativecommons.org/licenses/by-nc-nd/3.0/nl/deed.en_US
38
+ */
39
+
40
+ class TIG_MyParcel2014_Helper_Data extends Mage_Core_Helper_Abstract {
41
+
42
+ const XPATH_MYPARCEL_CONFIG_ACTIVE = 'tig_myparcel/general/active';
43
+
44
+ /**
45
+ * Address type used by PakjeGemak addresses.
46
+ */
47
+ const PG_ADDRESS_TYPE = 'pakje_gemak';
48
+
49
+ /**
50
+ * Regular expression used to split street name from house number. This regex works well for dutch addresses, but
51
+ * may fail for international addresses. We strongly recommend using split address lines instead.
52
+ */
53
+ const SPLIT_STREET_REGEX = '#\A(.*?)\s+(\d+[a-zA-Z]{0,1}\s{0,1}[-]{1}\s{0,1}\d*[a-zA-Z]{0,1}|\d+[a-zA-Z-]{0,1}\d*[a-zA-Z]{0,1})#';
54
+
55
+ /**
56
+ * Regular expression used to split house number and house number extension
57
+ */
58
+ const SPLIT_HOUSENUMBER_REGEX = '#^([\d]+)(.*)#s';
59
+
60
+ /**
61
+ * Log filename to log all non-specific MyParcel exceptions.
62
+ */
63
+ const MYPARCEL_EXCEPTION_LOG_FILE = 'TIG_MyParcel2014_Exception.log';
64
+
65
+ /**
66
+ * Log filename to log all non-specific MyParcel debug messages.
67
+ */
68
+ const MYPARCEL_DEBUG_LOG_FILE = 'TIG_MyParcel2014_Debug.log';
69
+
70
+ /**
71
+ * email addres of the shop owner
72
+ */
73
+ const XML_PATH_EMAIL_IDENTITY = 'sales_email/order/identity';
74
+ /**
75
+ * Localised track and trace base URL's
76
+ */
77
+ const POSTNL_TRACK_AND_TRACE_NL_BASE_URL = 'https://mijnpakket.postnl.nl/Inbox/Search?';
78
+ const POSTNL_TRACK_AND_TRACE_GB_BASE_URL = 'http://parcels-uk.tntpost.com/mytrackandtrace/trackandtrace.aspx?';
79
+ const POSTNL_TRACK_AND_TRACE_DE_BASE_URL = 'http://parcels-de.tntpost.com/de/mytrackandtrace/TrackAndTrace.aspx?';
80
+ const POSTNL_TRACK_AND_TRACE_FR_BASE_URL = 'http://parcels-fr.tntpost.com/fr/mytrackandtrace/TrackAndTrace.aspx?';
81
+ const POSTNL_TRACK_AND_TRACE_INT_BASE_URL = 'http://www.postnlpakketten.nl/klantenservice/tracktrace/basicsearch.aspx?';
82
+
83
+ /**
84
+ * List of MyParcel shipping methods.
85
+ *
86
+ * @var null|array
87
+ */
88
+ protected $_myParcelShippingMethods = null;
89
+
90
+ /**
91
+ * Gets a config value for this module, automatically selecting the current store.
92
+ *
93
+ * @param string $value
94
+ * @param string $group
95
+ * @param int $storeId to use in the backend, e.g. $order->getStoreId()
96
+ * @param bool $decrypt
97
+ *
98
+ * @return string
99
+ */
100
+ public function getConfig($value, $group = 'general', $storeId = null, $decrypt = false)
101
+ {
102
+ if(empty($storeId)) // in case of frontend calls
103
+ {
104
+ $storeId = Mage::app()->getStore()->getId();
105
+ }
106
+ $config = Mage::getStoreConfig('tig_myparcel/' . $group . '/' . $value, $storeId);
107
+
108
+ if($decrypt)
109
+ {
110
+ $config = Mage::helper('core')->decrypt($config);
111
+ }
112
+
113
+ if(Mage::app()->getStore()->isCurrentlySecure())
114
+ {
115
+ $config = str_replace('http://', 'https://', $config);
116
+ }
117
+
118
+ return trim($config);
119
+ }
120
+
121
+ /**
122
+ * Gets a PakjeGemak address for either a quote or an order object.
123
+ *
124
+ * @param Mage_Sales_Model_Quote|Mage_Sales_Model_Order $object
125
+ *
126
+ * @return false|Mage_Sales_Model_Order_Address|Mage_Sales_Model_Quote_Address|TIG_MyParcel2014_Model_Shipment
127
+ */
128
+ public function getPgAddress($object)
129
+ {
130
+ /**
131
+ * Get all addresses for the specified object.
132
+ */
133
+ if ($object instanceof Mage_Sales_Model_Quote) {
134
+ $addressCollection = $object->getAllAddresses();
135
+ } elseif ($object instanceof Mage_Sales_Model_Order) {
136
+ $addressCollection = $object->getAddressesCollection();
137
+ } elseif ($object instanceof TIG_MyParcel2014_Model_Shipment) {
138
+ $order = $object->getOrder();
139
+
140
+ if (!$order) {
141
+ return false;
142
+ }
143
+
144
+ $addressCollection = $order->getAddressesCollection();
145
+ } else {
146
+ return false;
147
+ }
148
+
149
+ /**
150
+ * Go through each address and check if it's a PakjeGemak address.
151
+ *
152
+ * @var Mage_Sales_Model_Quote_Address|Mage_Sales_Model_Order_Address $address
153
+ */
154
+ $pgAddress = false;
155
+ foreach ($addressCollection as $address) {
156
+ if ($address->getAddressType() == self::PG_ADDRESS_TYPE) {
157
+ $pgAddress = $address;
158
+ break;
159
+ }
160
+ }
161
+
162
+ /**
163
+ * Return the PakjeGemak address or false if none was found.
164
+ */
165
+
166
+ return $pgAddress;
167
+ }
168
+
169
+ /**
170
+ * Gets a list of MyParcel shipping methods.
171
+ *
172
+ * @return array
173
+ */
174
+ public function getMyParcelShippingMethods()
175
+ {
176
+ if ($this->_myParcelShippingMethods != null) {
177
+ return $this->_myParcelShippingMethods;
178
+ }
179
+
180
+ /**
181
+ * Get the MyParcel carrier code and all it's methods.
182
+ */
183
+ $myParcelCarrier = Mage::getModel('tig_myparcel/carrier_myParcel');
184
+ $myParcelCode = $myParcelCarrier->getCarrierCode();
185
+ $myParcelMethods = $myParcelCarrier->getAllowedMethods();
186
+
187
+ /**
188
+ * Form an array of shipping methods.
189
+ */
190
+ $methods = array();
191
+ foreach (array_keys($myParcelMethods) as $method) {
192
+ $methods[] = $myParcelCode . '_' . $method;
193
+ }
194
+
195
+ $this->_myParcelShippingMethods = $methods;
196
+ return $methods;
197
+ }
198
+
199
+ /**
200
+ * Checks if a given shipping method is MyParcel.
201
+ *
202
+ * @param string $method
203
+ *
204
+ * @return boolean
205
+ */
206
+ public function shippingMethodIsMyParcel($method)
207
+ {
208
+ $myParcelShippingMethods = $this->getMyParcelShippingMethods();
209
+
210
+ if (in_array($method, $myParcelShippingMethods)) {
211
+ return true;
212
+ }
213
+
214
+ return false;
215
+ }
216
+
217
+ /**
218
+ * Checks if the given shipping method is Pakjegemak
219
+ *
220
+ * @param $method
221
+ * @return bool
222
+ */
223
+ public function shippingMethodIsPakjegemak($method)
224
+ {
225
+ $myParcelCarrier = Mage::getModel('tig_myparcel/carrier_myParcel');
226
+ $myParcelCode = $myParcelCarrier->getCarrierCode();
227
+
228
+ if($method == $myParcelCode.'_pakjegemak'){
229
+ return true;
230
+ }
231
+
232
+ return false;
233
+ }
234
+
235
+ /**
236
+ * Checks if country needs to have customs
237
+ *
238
+ * @param $countryCode
239
+ * @return bool
240
+ */
241
+ public function countryNeedsCustoms($countryCode)
242
+ {
243
+ $whitelist = array(
244
+ 'NL','BE','BG','DK','DE','EE','FI','FR','HU','IE',
245
+ 'IT','LV','LT','LU','MC','AT','PL','PT','RO','SI',
246
+ 'SK','ES','CZ','GB','SE',
247
+ );
248
+ $whitelisted = in_array($countryCode, $whitelist);
249
+
250
+ return (!$whitelisted);
251
+ }
252
+
253
+ /**
254
+ * Constructs a track & trace url based on a barcode and the destination of the package (country and zipcode)
255
+ *
256
+ * @param string $barcode
257
+ * @param mixed $destination An array or object containing the shipment's destination data
258
+ * @param boolean | string $lang
259
+ * @param boolean $forceNl
260
+ *
261
+ * @return string
262
+ */
263
+ public function getBarcodeUrl($barcode, $destination = false, $lang = false, $forceNl = false)
264
+ {
265
+ $countryCode = null;
266
+ $postcode = null;
267
+ if (is_array($destination)) {
268
+ $countryCode = $destination['countryCode'];
269
+ $postcode = $destination['postcode'];
270
+ }
271
+
272
+ if (is_object($destination) && $destination instanceof Varien_Object) {
273
+ $countryCode = $destination->getCountry();
274
+ $postcode = str_replace(' ', '', $destination->getPostcode());
275
+ }
276
+
277
+ /**
278
+ * Get the dutch track & trace URL for dutch shipments or for the admin
279
+ */
280
+ if ($forceNl
281
+ || (!empty($countryCode)
282
+ && $countryCode == 'NL'
283
+ )
284
+ ) {
285
+ $barcodeUrl = self::POSTNL_TRACK_AND_TRACE_NL_BASE_URL
286
+ . '&b=' . $barcode;
287
+ /**
288
+ * For dutch shipments add the postcode. For international shipments add an 'international' flag
289
+ */
290
+ if (!empty($postcode)
291
+ && !empty($countryCode)
292
+ && $countryCode == 'NL'
293
+ ) {
294
+ $barcodeUrl .= '&p=' . $postcode;
295
+ } else {
296
+ $barcodeUrl .= '&i=true';
297
+ }
298
+
299
+ return $barcodeUrl;
300
+ }
301
+
302
+ /**
303
+ * Get localized track & trace URLs for UK, DE and FR shipments
304
+ */
305
+ if (isset($countryCode)
306
+ && ($countryCode == 'UK'
307
+ || $countryCode == 'GB'
308
+ )
309
+ ) {
310
+ $barcodeUrl = self::POSTNL_TRACK_AND_TRACE_GB_BASE_URL
311
+ . '&B=' . $barcode
312
+ . '&D=GB'
313
+ . '&lang=en';
314
+
315
+ return $barcodeUrl;
316
+ }
317
+
318
+ if (isset($countryCode) && $countryCode == 'DE') {
319
+ $barcodeUrl = self::POSTNL_TRACK_AND_TRACE_DE_BASE_URL
320
+ . '&B=' . $barcode
321
+ . '&D=DE'
322
+ . '&lang=de';
323
+
324
+ return $barcodeUrl;
325
+ }
326
+
327
+ if (isset($countryCode) && $countryCode == 'FR') {
328
+ $barcodeUrl = self::POSTNL_TRACK_AND_TRACE_FR_BASE_URL
329
+ . '&B=' . $barcode
330
+ . '&D=FR'
331
+ . '&lang=fr';
332
+
333
+ return $barcodeUrl;
334
+ }
335
+
336
+ /**
337
+ * Get a general track & trace URL for all other destinations
338
+ */
339
+ $barcodeUrl = self::POSTNL_TRACK_AND_TRACE_INT_BASE_URL
340
+ . '&B=' . $barcode
341
+ . '&I=true';
342
+
343
+ if ($lang) {
344
+ $barcodeUrl .= '&lang=' . strtolower($lang);
345
+ }
346
+
347
+ if ($countryCode) {
348
+ $barcodeUrl .= '&D=' . $countryCode;
349
+ }
350
+
351
+ return $barcodeUrl;
352
+ }
353
+
354
+ /**
355
+ * Retrieves street name, house number and house number extension from the shipping address.
356
+ * The shipping address may be in multiple street lines configuration or single line configuration. In the case of
357
+ * multi-line, each part of the street data will be in a separate field. In the single line configuration, each part
358
+ * will be in the same field and will have to be split using PREG.
359
+ *
360
+ * PREG cannot be relied on as it is impossible to create a regex that can filter all possible street syntaxes.
361
+ * Therefore we strongly recommend to use multiple street lines. This can be enabled in Magento community in
362
+ * system > config > customer configuration. Or if you use Enterprise, in customers > attributes > manage customer
363
+ * address attributes.
364
+ *
365
+ * @param Mage_Customer_Model_Address_Abstract $address
366
+ * @param null|int $storeId
367
+ *
368
+ * @return array
369
+ */
370
+ public function getStreetData($address,$storeId = null)
371
+ {
372
+ if(is_null($storeId)){
373
+ $storeId = Mage::app()->getStore()->getId();
374
+ }
375
+
376
+ $splitStreet = Mage::helper('tig_myparcel/addressValidation')->useSplitStreet($storeId);
377
+
378
+ /**
379
+ * Website uses multi-line address mode
380
+ */
381
+ if ($splitStreet) {
382
+ $streetData = $this->_getMultiLineStreetData($address);
383
+
384
+ /**
385
+ * If $streetData is false it means a required field was missing. In this
386
+ * case the alternative methods are used to obtain the address data.
387
+ */
388
+ if ($streetData !== false) {
389
+ return $streetData;
390
+ }
391
+ }
392
+
393
+ $fullStreet = $address->getStreetFull();
394
+
395
+ /**
396
+ * Split the address using PREG.
397
+ */
398
+ $streetData = $this->_getSplitStreetData($fullStreet);
399
+
400
+ return $streetData;
401
+ }
402
+
403
+ /**
404
+ * Retrieves street name, house number and hous enumber extension from the shipping address in the multiple street
405
+ * lines configuration.
406
+ *
407
+ * @param Mage_Sales_Model_Order_Address $address
408
+ *
409
+ * @return array
410
+ */
411
+ protected function _getMultiLineStreetData($address)
412
+ {
413
+ $addressHelper = Mage::helper('tig_myparcel/addressValidation');
414
+
415
+ $streetnameField = $addressHelper->getStreetnameField();
416
+ $housenumberField = $addressHelper->getHousenumberField();
417
+
418
+ $streetname = $address->getStreet($streetnameField);
419
+ $housenumber = $address->getStreet($housenumberField);
420
+ $housenumber = trim($housenumber);
421
+
422
+ /**
423
+ * If street or house number fields are empty, use alternative options to obtain the address data
424
+ */
425
+ if (empty($streetname) || empty($housenumber)) {
426
+ return false;
427
+ }
428
+
429
+ /**
430
+ * Split the house number into a number and an extension
431
+ */
432
+ $splitHouseNumber = $addressHelper->useSplitHousenumber();
433
+ if ($splitHouseNumber) {
434
+ $housenumberExtensionField = $addressHelper->getHousenumberExtensionField();
435
+ $housenumberExtension = $address->getStreet($housenumberExtensionField);
436
+
437
+ /**
438
+ * Make sure the house number is actually split.
439
+ */
440
+ if (!$housenumberExtension && !is_numeric($housenumber)) {
441
+ $housenumberParts = $this->_splitHousenumber($housenumber);
442
+ $housenumber = $housenumberParts['number'];
443
+ $housenumberExtension = $housenumberParts['extension'];
444
+ }
445
+ } else {
446
+ $housenumberParts = $this->_splitHousenumber($housenumber);
447
+ $housenumber = $housenumberParts['number'];
448
+ $housenumberExtension = $housenumberParts['extension'];
449
+ }
450
+
451
+ if (empty($housenumber)) {
452
+ return false;
453
+ }
454
+
455
+ $streetData = array(
456
+ 'streetname' => $streetname,
457
+ 'housenumber' => $housenumber,
458
+ 'housenumberExtension' => $housenumberExtension,
459
+ 'fullStreet' => '',
460
+ );
461
+
462
+ return $streetData;
463
+ }
464
+
465
+ /**
466
+ * Splits street data into separate parts for street name, housen umber and extension.
467
+ *
468
+ * @param string $fullStreet The full street name including all parts
469
+ *
470
+ * @return array
471
+ *
472
+ * @throws TIG_MyParcel2014_Exception
473
+ */
474
+ protected function _getSplitStreetData($fullStreet)
475
+ {
476
+ $result = preg_match(self::SPLIT_STREET_REGEX, $fullStreet, $matches);
477
+ if (!$result || !is_array($matches)) {
478
+ throw new TIG_MyParcel2014_Exception(
479
+ $this->__('Invalid full street supplied: %s.', $fullStreet),
480
+ 'MYPA-0005'
481
+ );
482
+ }
483
+
484
+ $streetname = '';
485
+ $housenumber = '';
486
+ if (isset($matches[1])) {
487
+ $streetname = $matches[1];
488
+ }
489
+
490
+ if (isset($matches[2])) {
491
+ $housenumber = $matches[2];
492
+ }
493
+
494
+ $housenumberParts = $this->_splitHousenumber($housenumber);
495
+ $housenumber = $housenumberParts['number'];
496
+ $housenumberExtension = $housenumberParts['extension'];
497
+
498
+ $streetData = array(
499
+ 'streetname' => $streetname,
500
+ 'housenumber' => $housenumber,
501
+ 'housenumberExtension' => $housenumberExtension,
502
+ 'fullStreet' => '',
503
+ );
504
+
505
+ return $streetData;
506
+ }
507
+
508
+ /**
509
+ * Splits a supplier house number into a number and an extension.
510
+ *
511
+ * @param string $housenumber
512
+ *
513
+ * @return array
514
+ *
515
+ * @throws TIG_MyParcel2014_Exception
516
+ */
517
+ protected function _splitHousenumber($housenumber)
518
+ {
519
+ $housenumber = trim($housenumber);
520
+ $result = preg_match(self::SPLIT_HOUSENUMBER_REGEX, $housenumber, $matches);
521
+ if (!$result || !is_array($matches)) {
522
+ throw new TIG_MyParcel2014_Exception(
523
+ $this->__('Invalid housnumber supplied: %s.', $housenumber),
524
+ 'MYPA-0006'
525
+ );
526
+ }
527
+
528
+ $extension = '';
529
+ $number = '';
530
+ if (isset($matches[1])) {
531
+ $number = $matches[1];
532
+ }
533
+
534
+ if (isset($matches[2])) {
535
+ $extension = trim($matches[2]);
536
+ }
537
+
538
+ $housenumberParts = array(
539
+ 'number' => $number,
540
+ 'extension' => $extension,
541
+ );
542
+
543
+ return $housenumberParts;
544
+ }
545
+
546
+ /**
547
+ * Checks if the current edition of Magento is enterprise. Uses Mage::getEdition if available. If not, look for the
548
+ * Enterprise_Enterprise extension. Finally, check the version number.
549
+ *
550
+ * @return boolean
551
+ */
552
+ public function isEnterprise()
553
+ {
554
+ /**
555
+ * Use Mage::getEdition, which is available since CE 1.7 and EE 1.12.
556
+ */
557
+ if (method_exists('Mage', 'getEdition')) {
558
+ $edition = Mage::getEdition();
559
+ if ($edition == Mage::EDITION_ENTERPRISE) {
560
+ return true;
561
+ }
562
+
563
+ return false;
564
+ }
565
+
566
+ /**
567
+ * Check if the Enterprise_Enterprise extension is installed.
568
+ */
569
+ if (Mage::getConfig()->getNode('modules')->Enterprise_Enterprise) {
570
+ return true;
571
+ }
572
+
573
+ return false;
574
+ }
575
+
576
+ /**
577
+ * Checks if the current environment is in the shop's admin area.
578
+ *
579
+ * @return boolean
580
+ */
581
+ public function isAdmin()
582
+ {
583
+ if (Mage::app()->getStore()->isAdmin()) {
584
+ return true;
585
+ }
586
+
587
+ /**
588
+ * Fallback check in case the previous check returns a false negative.
589
+ */
590
+ if (Mage::getDesign()->getArea() == 'adminhtml') {
591
+ return true;
592
+ }
593
+
594
+ return false;
595
+ }
596
+
597
+ /**
598
+ * various checks if the extension is enabled
599
+ * @param bool $storeId
600
+ * @return bool
601
+ */
602
+ public function isEnabled($storeId = false)
603
+ {
604
+ if(!$storeId){
605
+ $storeId = Mage::app()->getStore()->getId();
606
+ }
607
+
608
+ return Mage::getStoreConfigFlag(self::XPATH_MYPARCEL_CONFIG_ACTIVE,$storeId);
609
+ }
610
+
611
+ /**
612
+ * Logs a debug message. Based on Mage::log.
613
+ *
614
+ * @param string $message
615
+ * @param int|null $level
616
+ * @param string|null $file
617
+ * @param boolean $forced
618
+ * @param boolean $isError
619
+ *
620
+ * @return $this
621
+ *
622
+ * @see Mage::log
623
+ */
624
+ public function log($message, $level = null, $file = null, $forced = false, $isError = false)
625
+ {
626
+ if (is_null($level)) {
627
+ $level = Zend_Log::DEBUG;
628
+ }
629
+
630
+ if (is_null($file)) {
631
+ $file = self::MYPARCEL_DEBUG_LOG_FILE;
632
+ }
633
+
634
+ Mage::log($message, $level, $file, $forced);
635
+
636
+ return $this;
637
+ }
638
+
639
+ /**
640
+ * Logs a MyParcel Exception. Based on Mage::logException.
641
+ *
642
+ * @param string|Exception $exception
643
+ *
644
+ * @return $this
645
+ *
646
+ * @see Mage::logException
647
+ */
648
+ public function logException($exception)
649
+ {
650
+ if (is_object($exception)) {
651
+ $message = "\n" . $exception->__toString();
652
+ } else {
653
+ $message = $exception;
654
+ }
655
+
656
+ $file = self::MYPARCEL_EXCEPTION_LOG_FILE;
657
+
658
+ $this->log($message, Zend_Log::ERR, $file, false, true);
659
+
660
+ return $this;
661
+ }
662
+
663
+ /**
664
+ * Add a message to the specified session. Message can be an error, a success message, an info message or a warning.
665
+ * If a valid error code is supplied, the message will be prepended with the error code and a link to a
666
+ * knowledgebase article will be appended.
667
+ *
668
+ * If no $code is specified, $messageType and $message will be required
669
+ *
670
+ * @param string|Mage_Core_Model_Session_Abstract $session The session to which the messages will be added.
671
+ * @param string|null $code
672
+ * @param string|null $messageType
673
+ * @param string|null $message
674
+ *
675
+ * @return $this
676
+ *
677
+ * @see Mage_Core_Model_Session_Abstract::addMessage()
678
+ *
679
+ * @throws InvalidArgumentException
680
+ * @throws TIG_MyParcel2014_Exception
681
+ */
682
+ public function addSessionMessage($session, $code = null, $messageType = null, $message = null)
683
+ {
684
+ /***************************************************************************************************************
685
+ * Check that the required arguments are available and valid.
686
+ **************************************************************************************************************/
687
+
688
+ /**
689
+ * If $code is null or 0, $messageType and $message are required.
690
+ */
691
+ if (
692
+ (is_null($code) || $code === 0)
693
+ && (is_null($messageType) || is_null($message))
694
+ ) {
695
+ throw new InvalidArgumentException(
696
+ "Warning: Missing argument for addSessionMessage method: 'messageType' and 'message' are required."
697
+ );
698
+ }
699
+
700
+ /**
701
+ * If the session is a string, treat it as a class name and instantiate it.
702
+ */
703
+ if (is_string($session) && strpos($session, '/') !== false) {
704
+ $session = Mage::getSingleton($session);
705
+ } elseif (is_string($session)) {
706
+ $session = Mage::getSingleton($session . '/session');
707
+ }
708
+
709
+ /**
710
+ * If the session could not be loaded or is not of the correct type, throw an exception.
711
+ */
712
+ if (!$session
713
+ || !is_object($session)
714
+ || !($session instanceof Mage_Core_Model_Session_Abstract)
715
+ ) {
716
+ throw new TIG_MyParcel2014_Exception(
717
+ $this->__('Invalid session requested.'),
718
+ 'MYPA-0007'
719
+ );
720
+ }
721
+
722
+ $errorMessage = $this->getSessionMessage($code, $messageType, $message);
723
+
724
+ /***************************************************************************************************************
725
+ * Add the error to the session.
726
+ **************************************************************************************************************/
727
+
728
+ /**
729
+ * The method we'll use to add the message to the session has to be built first.
730
+ */
731
+ $addMethod = 'add' . ucfirst($messageType);
732
+
733
+ /**
734
+ * If the method doesn't exist, throw an exception.
735
+ */
736
+ if (!method_exists($session, $addMethod)) {
737
+ throw new TIG_MyParcel2014_Exception(
738
+ $this->__('Invalid message type requested: %s.', $messageType),
739
+ 'MYPA-0008'
740
+ );
741
+ }
742
+
743
+ /**
744
+ * Add the message to the session.
745
+ */
746
+ $session->$addMethod($errorMessage);
747
+
748
+ return $this;
749
+ }
750
+
751
+ /**
752
+ * Formats a message string so it can be added as a session message.
753
+ *
754
+ * @param null|string $code
755
+ * @param null|string $messageType
756
+ * @param null|string $message
757
+ *
758
+ * @return string
759
+ *
760
+ * @throws TIG_MyParcel2014_Exception
761
+ * @throws InvalidArgumentException
762
+ */
763
+ public function getSessionMessage($code = null, $messageType = null, $message = null)
764
+ {
765
+ /**
766
+ * If $code is null or 0, $messageType and $message are required.
767
+ */
768
+ if (
769
+ (is_null($code) || $code === 0)
770
+ && (is_null($messageType) || is_null($message))
771
+ ) {
772
+ throw new InvalidArgumentException(
773
+ "Warning: Missing argument for addSessionMessage method: 'messageType' and 'message' are required."
774
+ );
775
+ }
776
+
777
+ /***************************************************************************************************************
778
+ * Get the actual error from config.xml if it's available.
779
+ **************************************************************************************************************/
780
+
781
+ $error = false;
782
+ $link = false;
783
+
784
+ if (!is_null($code) && $code !== 0) {
785
+ /**
786
+ * get the requested code and if possible, the knowledgebase link
787
+ */
788
+ $error = Mage::getConfig()->getNode('tig/errors/' . $code);
789
+ if ($error !== false) {
790
+ $link = (string) $error->url;
791
+ }
792
+ }
793
+
794
+ /***************************************************************************************************************
795
+ * Check that the required 'message' and 'messageType' components are available. If they are not yet available,
796
+ * we'll try to read them from the error itself.
797
+ **************************************************************************************************************/
798
+
799
+ /**
800
+ * If the specified error was found and no message was supplied, get the error's default message.
801
+ */
802
+ if ($error && !$message) {
803
+ $message = (string) $error->message;
804
+ }
805
+
806
+ /**
807
+ * If we still don't have a valid message, throw an exception.
808
+ */
809
+ if (!$message) {
810
+ throw new TIG_MyParcel2014_Exception(
811
+ $this->__('No message supplied.'),
812
+ 'MYPA-0009'
813
+ );
814
+ }
815
+
816
+ /**
817
+ * If the specified error was found and no message type was supplied, get the error's default type.
818
+ */
819
+ if ($error && !$messageType) {
820
+ $messageType = (string) $error->type;
821
+ }
822
+
823
+
824
+ /**
825
+ * If we still don't have a valid message type, throw an exception.
826
+ */
827
+ if (!$messageType) {
828
+ throw new TIG_MyParcel2014_Exception(
829
+ $this->__('No message type supplied.'),
830
+ 'MYPA-0010'
831
+ );
832
+ }
833
+
834
+ /***************************************************************************************************************
835
+ * Build the actual message we're going to add. The message will consist of the error code, followed by the
836
+ * actual message and finally a link to the knowledge base. Only the message part is required.
837
+ **************************************************************************************************************/
838
+
839
+ /**
840
+ * Lets start with the error code if it's present. It will be formatted as "[MYPARCEL-0001]".
841
+ */
842
+ $errorMessage = '';
843
+ if (!is_null($code)
844
+ && $code !== 0
845
+ ) {
846
+ $errorMessage .= "[{$code}] ";
847
+ }
848
+
849
+ /**
850
+ * Add the actual message. This is the only required part. The code and link are optional.
851
+ */
852
+ $errorMessage .= $this->__($message);
853
+
854
+ /**
855
+ * Add the link to the knowledgebase if we have one.
856
+ */
857
+ if ($link) {
858
+ $errorMessage .= ' <a href="'
859
+ . $link
860
+ . '" target="_blank" class="myparcel-message">'
861
+ . $this->__('Click here for more information from the TiG knowledgebase.')
862
+ . '</a>';
863
+ }
864
+
865
+ return $errorMessage;
866
+ }
867
+
868
+ /**
869
+ * Adds an error message to the specified session based on an exception. The exception should contain a valid error
870
+ * code in order to properly process the error. Exceptions without a (valid) error code will behave like a regular
871
+ * $session->addError() call.
872
+ *
873
+ * @param string|Mage_Core_Model_Session_Abstract $session The session to which the messages will be added.
874
+ * @param Exception $exception
875
+ *
876
+ * @return $this
877
+ */
878
+ public function addExceptionSessionMessage($session, Exception $exception)
879
+ {
880
+ /**
881
+ * Get the error code, message type (hardcoded as 'error') and the message of the exception
882
+ */
883
+ $messageType = 'error';
884
+ $exceptionMessage = trim($exception->getMessage());
885
+ $message = $this->__('An error occurred while processing your request: ') . $exceptionMessage;
886
+ $code = $exception->getCode();
887
+ if (empty($code)) {
888
+ $code = $this->getErrorCodeByMessage($exceptionMessage);
889
+ }
890
+
891
+ return $this->addSessionMessage($session, $code, $messageType, $message);
892
+ }
893
+
894
+ /**
895
+ * Gets an error code by looping through all known errors and if the specified message can be matched, returning the
896
+ * associated code.
897
+ *
898
+ * @param string $message
899
+ *
900
+ * @return string|null
901
+ */
902
+ public function getErrorCodeByMessage($message)
903
+ {
904
+ /**
905
+ * Get an array of all known errors
906
+ */
907
+ $errors = Mage::getConfig()->getNode('tig/errors')->asArray();
908
+
909
+ /**
910
+ * Loop through each error and compare it's message
911
+ */
912
+ foreach ($errors as $code => $error) {
913
+ $errorMessage = (string) $error['message'];
914
+
915
+ /**
916
+ * If a the error's message and the specified message match, return the error code
917
+ */
918
+ if (strcasecmp($message, $errorMessage) === 0) {
919
+ return $code;
920
+ }
921
+ }
922
+
923
+ return null;
924
+ }
925
+
926
+ /**
927
+ * @param string $barcode
928
+ * @param TIG_MyParcel2014_Model_Shipment $myParcelShipment
929
+ * @return bool
930
+ * @throws TIG_MyParcel2014_Exception
931
+ */
932
+ public function sendBarcodeEmail($barcode='', $myParcelShipment)
933
+ {
934
+ if(empty($barcode)){
935
+ return false;
936
+ }
937
+
938
+ if(!$myParcelShipment instanceof TIG_MyParcel2014_Model_Shipment){
939
+ return false;
940
+ }
941
+
942
+ $store = $myParcelShipment->getOrder()->getStoreId();
943
+ $templateId = $this->getConfig('tracktrace_template','general',$store);
944
+
945
+ //if no template is set, return false: tracktrace should be send by MyParcel
946
+ if($templateId === null || $templateId == 'tig_myparcel_general_tracktrace_template'){
947
+ return false;
948
+ }
949
+
950
+ $shippingAddress = $myParcelShipment->getShippingAddress();
951
+ $barcodeUrl = $this->getBarcodeUrl($barcode,$shippingAddress);
952
+ $templateVariables = array(
953
+ 'tracktrace_url' => $barcodeUrl,
954
+ );
955
+
956
+ try {
957
+ $mailer = Mage::getModel('core/email_template_mailer');
958
+ $emailInfo = Mage::getModel('core/email_info');
959
+ $emailInfo->addTo($myParcelShipment->getOrder()->getCustomerEmail(), $shippingAddress->getName());
960
+
961
+ $mailer->addEmailInfo($emailInfo);
962
+
963
+ // Set all required params and send emails.
964
+ $mailer->setSender(Mage::getStoreConfig(self::XML_PATH_EMAIL_IDENTITY, $store));
965
+ $mailer->setStoreId($store);
966
+ $mailer->setTemplateId($templateId);
967
+ $mailer->setTemplateParams($templateVariables);
968
+ $mailer->send();
969
+ }catch(Exception $e) {
970
+ $this->logException($e);
971
+ return false;
972
+ }
973
+
974
+ return true;
975
+ }
976
+
977
+ public function hasMyParcelShipment($shipmentId)
978
+ {
979
+ $myParcelShipment = Mage::getModel('tig_myparcel/shipment')->load($shipmentId,'shipment_id');
980
+
981
+ if($myParcelShipment->getId() != 0){
982
+ return true;
983
+ }
984
+ return false;
985
+ }
986
+ }
app/code/community/TIG/MyParcel2014/Model/Adminhtml/Observer/OrderGrid.php ADDED
@@ -0,0 +1,476 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * ___________ __ __
4
+ * \__ ___/____ _/ |_ _____ | |
5
+ * | | / _ \\ __\\__ \ | |
6
+ * | | | |_| || | / __ \_| |__
7
+ * |____| \____/ |__| (____ /|____/
8
+ * \/
9
+ * ___ __ __
10
+ * | | ____ _/ |_ ____ _______ ____ ____ _/ |_
11
+ * | | / \\ __\_/ __ \\_ __ \ / \ _/ __ \\ __\
12
+ * | || | \| | \ ___/ | | \/| | \\ ___/ | |
13
+ * |___||___| /|__| \_____>|__| |___| / \_____>|__|
14
+ * \/ \/
15
+ * ________
16
+ * / _____/_______ ____ __ __ ______
17
+ * / \ ___\_ __ \ / _ \ | | \\____ \
18
+ * \ \_\ \| | \/| |_| || | /| |_| |
19
+ * \______ /|__| \____/ |____/ | __/
20
+ * \/ |__|
21
+ *
22
+ * NOTICE OF LICENSE
23
+ *
24
+ * This source file is subject to the Creative Commons License.
25
+ * It is available through the world-wide-web at this URL:
26
+ * http://creativecommons.org/licenses/by-nc-nd/3.0/nl/deed.en_US
27
+ * If you are unable to obtain it through the world-wide-web, please send an email
28
+ * to servicedesk@tig.nl so we can send you a copy immediately.
29
+ *
30
+ * DISCLAIMER
31
+ *
32
+ * Do not edit or add to this file if you wish to upgrade this module to newer
33
+ * versions in the future. If you wish to customize this module for your
34
+ * needs please contact servicedesk@tig.nl for more information.
35
+ *
36
+ * @copyright Copyright (c) 2014 Total Internet Group B.V. (http://www.tig.nl)
37
+ * @license http://creativecommons.org/licenses/by-nc-nd/3.0/nl/deed.en_US
38
+ *
39
+ * @method TIG_MyParcel2014_Model_Adminhtml_Observer_OrderGrid setCollection(TIG_MyParcel2014_Model_Resource_Order_Grid_Collection $value)
40
+ * @method TIG_MyParcel2014_Model_Resource_Order_Grid_Collection getCollection()
41
+ * @method TIG_MyParcel2014_Model_Adminhtml_Observer_OrderGrid setBlock(Mage_Adminhtml_Block_Sales_Order_Grid $value)
42
+ * @method Mage_Adminhtml_Block_Sales_Order_Grid getBlock()
43
+ */
44
+ class TIG_MyParcel2014_Model_Adminhtml_Observer_OrderGrid extends Varien_Object
45
+ {
46
+ /**
47
+ * The block we want to edit.
48
+ */
49
+ const ORDER_GRID_BLOCK_NAME = 'adminhtml/sales_order_grid';
50
+
51
+ /**
52
+ * variable name for order grid filter.
53
+ */
54
+ const ORDER_GRID_FILTER_VAR_NAME = 'sales_order_gridfilter';
55
+
56
+ /**
57
+ * variable name for order grid sorting.
58
+ */
59
+ const ORDER_GRID_SORT_VAR_NAME = 'sales_order_gridsort';
60
+
61
+ /**
62
+ * variable name for order grid sorting direction.
63
+ */
64
+ const ORDER_GRID_DIR_VAR_NAME = 'sales_order_griddir';
65
+
66
+ /**
67
+ * Edits the sales order grid by adding a mass action to create shipments for selected orders.
68
+ *
69
+ * @param Varien_Event_Observer $observer
70
+ *
71
+ * @return $this
72
+ *
73
+ * @event adminhtml_block_html_before
74
+ *
75
+ * @observer tig_myparcel_adminhtml_ordergrid
76
+ */
77
+ public function modifyGrid(Varien_Event_Observer $observer)
78
+ {
79
+ /**
80
+ * Checks if the current block is the one we want to edit.
81
+ *
82
+ * Unfortunately there is no unique event for this block.
83
+ */
84
+ $block = $observer->getBlock();
85
+ $orderGridClass = Mage::getConfig()->getBlockClassName(self::ORDER_GRID_BLOCK_NAME);
86
+
87
+ if (!($block instanceof $orderGridClass)) {
88
+ return $this;
89
+ }
90
+
91
+ /**
92
+ * check if the extension is active
93
+ */
94
+ if (!Mage::helper('tig_myparcel')->isEnabled()) {
95
+ return $this;
96
+ }
97
+
98
+ /**
99
+ * @var Mage_Adminhtml_Block_Sales_Order_Grid $block
100
+ * @var Mage_Sales_Model_Resource_Order_Collection $currentCollection
101
+ */
102
+ $currentCollection = $block->getCollection();
103
+ $select = $currentCollection->getSelect()->reset(Zend_Db_Select::WHERE);
104
+
105
+ /**
106
+ * replace the collection, as the default collection has a bug preventing it from being reset.
107
+ * Without being able to reset it, we can't edit it. Therefore we are forced to replace it altogether.
108
+ */
109
+ $collection = Mage::getResourceModel('tig_myparcel/order_grid_collection');
110
+ $collection->setSelect($select)
111
+ ->setPageSize($currentCollection->getPageSize())
112
+ ->setCurPage($currentCollection->getCurPage());
113
+
114
+ $this->setCollection($collection);
115
+ $this->setBlock($block);
116
+
117
+ $this->_joinCollection($collection);
118
+ $this->_modifyColumns($block);
119
+ $this->_addColumns($block);
120
+ $this->_applySortAndFilter();
121
+ $this->_addMassaction($block);
122
+
123
+ $block->setCollection($collection);
124
+ return $this;
125
+ }
126
+
127
+ /**
128
+ * Adds additional joins to the collection that will be used by newly added columns.
129
+ *
130
+ * @param TIG_MyParcel2014_Model_Resource_Order_Grid_Collection $collection
131
+ *
132
+ * @return $this
133
+ */
134
+ protected function _joinCollection($collection)
135
+ {
136
+ $resource = Mage::getSingleton('core/resource');
137
+
138
+ $collection->addExpressionFieldToSelect(
139
+ 'country_id',
140
+ 'IF({{pakjegemak_parent_id}}, {{pakjegemak_country_id}}, {{shipping_country_id}})',
141
+ array(
142
+ 'pakjegemak_parent_id' => '`pakjegemak_address`.`parent_id`',
143
+ 'pakjegemak_country_id' => '`pakjegemak_address`.`country_id`',
144
+ 'shipping_country_id' => '`shipping_address`.`country_id`',
145
+ )
146
+ );
147
+ $collection->addExpressionFieldToSelect(
148
+ 'postcode',
149
+ 'IF({{pakjegemak_parent_id}}, {{pakjegemak_postcode}}, {{shipping_postcode}})',
150
+ array(
151
+ 'pakjegemak_parent_id' => '`pakjegemak_address`.`parent_id`',
152
+ 'pakjegemak_postcode' => '`pakjegemak_address`.`postcode`',
153
+ 'shipping_postcode' => '`shipping_address`.`postcode`',
154
+ )
155
+ );
156
+
157
+ $select = $collection->getSelect();
158
+
159
+ /**
160
+ * Join sales_flat_order table.
161
+ */
162
+ $select->joinInner(
163
+ array('order' => $resource->getTableName('sales/order')),
164
+ '`main_table`.`entity_id`=`order`.`entity_id`',
165
+ array(
166
+ 'shipping_method' => 'order.shipping_method',
167
+ )
168
+ );
169
+
170
+ /**
171
+ * Join sales_flat_order_address table.
172
+ */
173
+ $select->joinLeft(
174
+ array('shipping_address' => $resource->getTableName('sales/order_address')),
175
+ "`main_table`.`entity_id`=`shipping_address`.`parent_id` AND `shipping_address`.`address_type`='shipping'",
176
+ array()
177
+ );
178
+ $select->joinLeft(
179
+ array('pakjegemak_address' => $resource->getTableName('sales/order_address')),
180
+ "`main_table`.`entity_id`=`pakjegemak_address`.`parent_id` " .
181
+ "AND `pakjegemak_address`.`address_type`='pakje_gemak'",
182
+ array()
183
+ );
184
+
185
+ /**
186
+ * Join tig_myparcel_shipment table.
187
+ */
188
+ $select->joinLeft(
189
+ array('tig_myparcel_shipment' => $resource->getTableName('tig_myparcel/shipment')),
190
+ '`main_table`.`entity_id`=`tig_myparcel_shipment`.`order_id`',
191
+ array(
192
+ 'shipping_status' => new Zend_Db_Expr(
193
+ 'group_concat(`tig_myparcel_shipment`.`status` ORDER BY '
194
+ . '`tig_myparcel_shipment`.`created_at` DESC SEPARATOR ",")'
195
+ ),
196
+ 'barcode' => new Zend_Db_Expr(
197
+ 'group_concat(`tig_myparcel_shipment`.`barcode` ORDER BY '
198
+ . '`tig_myparcel_shipment`.`created_at` DESC SEPARATOR ",")'
199
+ ),
200
+ )
201
+ );
202
+
203
+ /**
204
+ * Group the results by the ID column.
205
+ */
206
+ $select->group('main_table.entity_id');
207
+
208
+ return $this;
209
+ }
210
+
211
+ /**
212
+ * Modifies existing columns to prevent issues with the new collections.
213
+ *
214
+ * @param Mage_Adminhtml_Block_Sales_Order_Grid $block
215
+ *
216
+ * @return $this
217
+ */
218
+ protected function _modifyColumns($block)
219
+ {
220
+ /**
221
+ * @var Mage_Adminhtml_Block_Widget_Grid_Column $incrementIdColumn
222
+ */
223
+ $incrementIdColumn = $block->getColumn('real_order_id');
224
+ if ($incrementIdColumn) {
225
+ $incrementIdColumn->setFilterIndex('main_table.increment_id');
226
+ }
227
+
228
+ /**
229
+ * @var Mage_Adminhtml_Block_Widget_Grid_Column $massactionColumn
230
+ */
231
+ $massactionColumn = $block->getColumn('massaction');
232
+ if ($massactionColumn) {
233
+ $massactionColumn->setFilterIndex('main_table.entity_id');
234
+ }
235
+
236
+ /**
237
+ * @var Mage_Adminhtml_Block_Widget_Grid_Column $statusColumn
238
+ */
239
+ $statusColumn = $block->getColumn('status');
240
+ if ($statusColumn) {
241
+ $statusColumn->setFilterIndex('main_table.status');
242
+ }
243
+
244
+ /**
245
+ * @var Mage_Adminhtml_Block_Widget_Grid_Column $createdAtColumn
246
+ */
247
+ $createdAtColumn = $block->getColumn('created_at');
248
+ if ($createdAtColumn) {
249
+ $createdAtColumn->setFilterIndex('main_table.created_at');
250
+ }
251
+
252
+ /**
253
+ * @var Mage_Adminhtml_Block_Widget_Grid_Column $baseGrandTotalColumn
254
+ */
255
+ $baseGrandTotalColumn = $block->getColumn('base_grand_total');
256
+ if ($baseGrandTotalColumn) {
257
+ $baseGrandTotalColumn->setFilterIndex('main_table.base_grand_total');
258
+ }
259
+
260
+ /**
261
+ * @var Mage_Adminhtml_Block_Widget_Grid_Column $grandTotalColumn
262
+ */
263
+ $grandTotalColumn = $block->getColumn('grand_total');
264
+ if ($grandTotalColumn) {
265
+ $grandTotalColumn->setFilterIndex('main_table.grand_total');
266
+ }
267
+
268
+ /**
269
+ * @var Mage_Adminhtml_Block_Widget_Grid_Column $storeIdColumn
270
+ */
271
+ $storeIdColumn = $block->getColumn('store_id');
272
+ if ($storeIdColumn) {
273
+ $storeIdColumn->setFilterIndex('main_table.store_id');
274
+ }
275
+
276
+ return $this;
277
+ }
278
+
279
+ /**
280
+ * Adds additional columns to the grid
281
+ *
282
+ * @param Mage_Adminhtml_Block_Sales_Order_Grid $block
283
+ *
284
+ * @return $this
285
+ */
286
+ protected function _addColumns($block)
287
+ {
288
+ $helper = Mage::helper('tig_myparcel');
289
+
290
+ /**
291
+ * Add the confirm status column.
292
+ */
293
+ $block->addColumnAfter(
294
+ 'shipping_status',
295
+ array(
296
+ 'header' => $helper->__('Shipping status'),
297
+ 'type' => 'text',
298
+ 'index' => 'shipping_status',
299
+ 'sortable' => false,
300
+ 'filter' => false,
301
+ 'renderer' => 'tig_myparcel/adminhtml_widget_grid_column_renderer_shippingStatus',
302
+ ),
303
+ 'shipping_name'
304
+ );
305
+
306
+ $block->sortColumnsByOrder();
307
+
308
+ return $this;
309
+ }
310
+
311
+ /**
312
+ * Adds a massaction print the shipping labels
313
+ *
314
+ * @param Mage_Adminhtml_Block_Sales_Order_Grid $block
315
+ *
316
+ * @return $this
317
+ */
318
+ protected function _addMassaction($block)
319
+ {
320
+ $helper = Mage::helper('tig_myparcel');
321
+ $adminhtmlHelper = Mage::helper('adminhtml');
322
+
323
+ /**
324
+ * Add the create shipments mass action
325
+ */
326
+ /*$block->getMassactionBlock()
327
+ ->addItem(
328
+ 'myparcel_create_shipments',
329
+ array(
330
+ 'label'=> $helper->__('MyParcel - Create Shipments'),
331
+ 'url' => $adminhtmlHelper->getUrl('myparcel_admin/adminhtml_shipment/massCreateShipments'),
332
+ )
333
+ );*/
334
+
335
+ /**
336
+ * Add the print labels mass action.
337
+ */
338
+ $block->getMassactionBlock()
339
+ ->addItem(
340
+ 'myparcel_print_labels',
341
+ array(
342
+ 'label' => $helper->__('MyParcel - Create &amp; Print shipping labels'),
343
+ 'url' => $adminhtmlHelper->getUrl('myparcel_admin/adminhtml_shipment/massPrintLabels'),
344
+ )
345
+ );
346
+
347
+ return $this;
348
+ }
349
+
350
+ /**
351
+ * Applies sorting and filtering to the collection
352
+ *
353
+ * @return $this
354
+ */
355
+ protected function _applySortAndFilter()
356
+ {
357
+ $session = Mage::getSingleton('adminhtml/session');
358
+
359
+ $filter = $session->getData(self::ORDER_GRID_FILTER_VAR_NAME);
360
+ $filter = Mage::helper('adminhtml')->prepareFilterString($filter);
361
+
362
+ if ($filter) {
363
+ $this->_filterCollection($filter);
364
+ }
365
+
366
+ $sort = $session->getData(self::ORDER_GRID_SORT_VAR_NAME);
367
+
368
+ if ($sort) {
369
+ $dir = $session->getData(self::ORDER_GRID_DIR_VAR_NAME);
370
+
371
+ $this->_sortCollection($sort, $dir);
372
+ }
373
+
374
+ return $this;
375
+ }
376
+
377
+ /**
378
+ * Adds new filters to the collection if these filters are based on columns added by this observer
379
+ *
380
+ * @param array $filter Array of filters to be added
381
+ *
382
+ * @return $this
383
+ */
384
+ protected function _filterCollection($filter)
385
+ {
386
+ $block = $this->getBlock();
387
+
388
+ foreach ($filter as $columnName => $value) {
389
+ $column = $block->getColumn($columnName);
390
+
391
+ if (!$column) {
392
+ continue;
393
+ }
394
+
395
+ $column->getFilter()->setValue($value);
396
+ $this->_addColumnFilterToCollection($column);
397
+ }
398
+
399
+ return $this;
400
+ }
401
+
402
+ /**
403
+ * Based on Mage_Adminhtml_Block_Widget_Grid::_addColumnFilterToCollection()
404
+ *
405
+ * Adds a filter condition to the collection for a specified column
406
+ *
407
+ * @param Mage_Adminhtml_Block_Widget_Grid_Column $column
408
+ *
409
+ * @return $this
410
+ */
411
+ protected function _addColumnFilterToCollection($column)
412
+ {
413
+ if (!$this->getCollection()) {
414
+ return $this;
415
+ }
416
+
417
+ $field = ($column->getFilterIndex()) ? $column->getFilterIndex() : $column->getIndex();
418
+ if ($column->getFilterConditionCallback()) {
419
+ call_user_func($column->getFilterConditionCallback(), $this->getCollection(), $column);
420
+
421
+ return $this;
422
+ }
423
+
424
+ $cond = $column->getFilter()->getCondition();
425
+ if ($field && isset($cond)) {
426
+ /**
427
+ * @var TIG_MyParcel2014_Model_Resource_Order_Grid_Collection $collection
428
+ */
429
+ $collection = $this->getCollection();
430
+ $collection->addFieldToFilter($field , $cond);
431
+ }
432
+
433
+ return $this;
434
+ }
435
+
436
+ /**
437
+ * Sorts the collection by a specified column in a specified direction
438
+ *
439
+ * @param string $sort The column that the collection is sorted by
440
+ * @param string $dir The direction that is used to sort the collection
441
+ *
442
+ * @return $this
443
+ */
444
+ protected function _sortCollection($sort, $dir)
445
+ {
446
+ $block = $this->getBlock();
447
+ $column = $block->getColumn($sort);
448
+ if (!$column) {
449
+ return $this;
450
+ }
451
+
452
+ $column->setDir($dir);
453
+ $this->_setCollectionOrder($column);
454
+
455
+ return $this;
456
+ }
457
+
458
+ /**
459
+ * Sets sorting order by some column
460
+ *
461
+ * @param Mage_Adminhtml_Block_Widget_Grid_Column $column
462
+ *
463
+ * @return $this
464
+ */
465
+ protected function _setCollectionOrder($column)
466
+ {
467
+ $collection = $this->getCollection();
468
+ if (!$collection) {
469
+ return $this;
470
+ }
471
+
472
+ $columnIndex = $column->getFilterIndex() ? $column->getFilterIndex() : $column->getIndex();
473
+ $collection->setOrder($columnIndex, strtoupper($column->getDir()));
474
+ return $this;
475
+ }
476
+ }
app/code/community/TIG/MyParcel2014/Model/Adminhtml/Observer/SystemConfig.php ADDED
@@ -0,0 +1,96 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * ___________ __ __
4
+ * \__ ___/____ _/ |_ _____ | |
5
+ * | | / _ \\ __\\__ \ | |
6
+ * | | | |_| || | / __ \_| |__
7
+ * |____| \____/ |__| (____ /|____/
8
+ * \/
9
+ * ___ __ __
10
+ * | | ____ _/ |_ ____ _______ ____ ____ _/ |_
11
+ * | | / \\ __\_/ __ \\_ __ \ / \ _/ __ \\ __\
12
+ * | || | \| | \ ___/ | | \/| | \\ ___/ | |
13
+ * |___||___| /|__| \_____>|__| |___| / \_____>|__|
14
+ * \/ \/
15
+ * ________
16
+ * / _____/_______ ____ __ __ ______
17
+ * / \ ___\_ __ \ / _ \ | | \\____ \
18
+ * \ \_\ \| | \/| |_| || | /| |_| |
19
+ * \______ /|__| \____/ |____/ | __/
20
+ * \/ |__|
21
+ *
22
+ * NOTICE OF LICENSE
23
+ *
24
+ * This source file is subject to the Creative Commons License.
25
+ * It is available through the world-wide-web at this URL:
26
+ * http://creativecommons.org/licenses/by-nc-nd/3.0/nl/deed.en_US
27
+ * If you are unable to obtain it through the world-wide-web, please send an email
28
+ * to servicedesk@tig.nl so we can send you a copy immediately.
29
+ *
30
+ * DISCLAIMER
31
+ *
32
+ * Do not edit or add to this file if you wish to upgrade this module to newer
33
+ * versions in the future. If you wish to customize this module for your
34
+ * needs please contact servicedesk@tig.nl for more information.
35
+ *
36
+ * @copyright Copyright (c) 2014 Total Internet Group B.V. (http://www.tig.nl)
37
+ * @license http://creativecommons.org/licenses/by-nc-nd/3.0/nl/deed.en_US
38
+ */
39
+ class TIG_MyParcel2014_Model_Adminhtml_Observer_SystemConfig
40
+ {
41
+ /**
42
+ * Adds a button to the system > config page for the MyParcel section, allowing the admin to download all Myparcel
43
+ * debug logs.
44
+ *
45
+ * @param Varien_Event_Observer $observer
46
+ *
47
+ * @return $this
48
+ *
49
+ * @event controller_action_layout_render_before_adminhtml_system_config_edit
50
+ *
51
+ * @observer myparcel_add_download_log_button
52
+ */
53
+ public function addDownloadLogButton(Varien_Event_Observer $observer)
54
+ {
55
+ $section = Mage::app()->getRequest()->getParam('section');
56
+ if ($section !== 'tig_myparcel') {
57
+ return $this;
58
+ }
59
+
60
+ $configEditBlock = false;
61
+ $contentBlocks = Mage::getSingleton('core/layout')->getBlock('content')->getChild();
62
+
63
+ /**
64
+ * @var Mage_Core_Block_Abstract $block
65
+ */
66
+ foreach ($contentBlocks as $block) {
67
+ if ($block instanceof Mage_Adminhtml_Block_System_Config_Edit) {
68
+ $configEditBlock = $block;
69
+ break;
70
+ }
71
+ }
72
+
73
+ if (!$configEditBlock) {
74
+ return $this;
75
+ }
76
+
77
+ $helper = Mage::helper('tig_myparcel');
78
+
79
+ $onClickUrl = $configEditBlock->getUrl('myparcel_admin/adminhtml_config/downloadLogs');
80
+ $onClick = "setLocation('{$onClickUrl}')";
81
+
82
+ $button = $configEditBlock->getLayout()->createBlock('adminhtml/widget_button');
83
+ $button->setData(
84
+ array(
85
+ 'label' => $helper->__('Download log files'),
86
+ 'onclick' => $onClick,
87
+ 'class' => 'download',
88
+ )
89
+ );
90
+
91
+ $configEditBlock->setChild('download_logs_button', $button);
92
+ $configEditBlock->setTemplate('TIG/MyParcel2014/system/config/edit.phtml');
93
+
94
+ return $this;
95
+ }
96
+ }
app/code/community/TIG/MyParcel2014/Model/Adminhtml/Support/Logs.php ADDED
@@ -0,0 +1,172 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * ___________ __ __
4
+ * \__ ___/____ _/ |_ _____ | |
5
+ * | | / _ \\ __\\__ \ | |
6
+ * | | | |_| || | / __ \_| |__
7
+ * |____| \____/ |__| (____ /|____/
8
+ * \/
9
+ * ___ __ __
10
+ * | | ____ _/ |_ ____ _______ ____ ____ _/ |_
11
+ * | | / \\ __\_/ __ \\_ __ \ / \ _/ __ \\ __\
12
+ * | || | \| | \ ___/ | | \/| | \\ ___/ | |
13
+ * |___||___| /|__| \_____>|__| |___| / \_____>|__|
14
+ * \/ \/
15
+ * ________
16
+ * / _____/_______ ____ __ __ ______
17
+ * / \ ___\_ __ \ / _ \ | | \\____ \
18
+ * \ \_\ \| | \/| |_| || | /| |_| |
19
+ * \______ /|__| \____/ |____/ | __/
20
+ * \/ |__|
21
+ *
22
+ * NOTICE OF LICENSE
23
+ *
24
+ * This source file is subject to the Creative Commons License.
25
+ * It is available through the world-wide-web at this URL:
26
+ * http://creativecommons.org/licenses/by-nc-nd/3.0/nl/deed.en_US
27
+ * If you are unable to obtain it through the world-wide-web, please send an email
28
+ * to servicedesk@tig.nl so we can send you a copy immediately.
29
+ *
30
+ * DISCLAIMER
31
+ *
32
+ * Do not edit or add to this file if you wish to upgrade this module to newer
33
+ * versions in the future. If you wish to customize this module for your
34
+ * needs please contact servicedesk@tig.nl for more information.
35
+ *
36
+ * @copyright Copyright (c) 2014 Total Internet Group B.V. (http://www.tig.nl)
37
+ * @license http://creativecommons.org/licenses/by-nc-nd/3.0/nl/deed.en_US
38
+ */
39
+ class TIG_MyParcel2014_Model_Adminhtml_Support_Logs
40
+ {
41
+ /**
42
+ * Max size for individual log files and the total size of all logs (in bytes).
43
+ */
44
+ const LOG_MAX_SIZE = '104857600'; //100MB
45
+ const LOG_MAX_TOTAL_SIZE = '1073741824'; //1GB
46
+
47
+ /**
48
+ * @var array
49
+ */
50
+ protected $logFiles = array(
51
+ 'exception.log',
52
+ 'system.log',
53
+ );
54
+
55
+ /**
56
+ * Get all MyParcel log files, merge these into a zip file and return the path to said zip file.
57
+ *
58
+ * @return string
59
+ *
60
+ */
61
+ public function downloadLogs()
62
+ {
63
+ $helper = Mage::helper('tig_myparcel');
64
+
65
+ /**
66
+ * Get the log folder and check if there are log files in it.
67
+ */
68
+ $logFolder = Mage::getBaseDir('var') . DS . 'log';
69
+ if ((!is_readable($logFolder)) || ( count( array_diff(scandir($logFolder), array('..', '.')) ) < 1 ) ) {
70
+ return false;
71
+ }
72
+
73
+ /**
74
+ * Get all log files in the log folder and a list of all logs that are allowed for this download.
75
+ */
76
+ $logs = glob($logFolder . DS . '*.log');
77
+
78
+ $allowedLogs = $this->getLogFileNames();
79
+
80
+ /**
81
+ * Make sure each log is valid and put the valid logs in an array with the log's filename as the key. We need
82
+ * this later on to prevent the entire directory structure from being included in the zip file.
83
+ */
84
+ $logsWithNames = array();
85
+ $totalSize = 0;
86
+ foreach ($logs as $log) {
87
+ $logName = explode(DS, $log);
88
+ $logName = end($logName);
89
+
90
+ /**
91
+ * Make sure this log is allowed.
92
+ */
93
+ if (!in_array($logName, $allowedLogs)) {
94
+ continue;
95
+ }
96
+
97
+ /**
98
+ * Make sure the log is a file and is readable.
99
+ */
100
+ if (!is_file($log) || !is_readable($log)) {
101
+ continue;
102
+ }
103
+
104
+ /**
105
+ * Make sure the log is not too large. Otherwise we won't be able to read it anyway.
106
+ */
107
+ $fileSize = filesize($log);
108
+ if ($fileSize > self::LOG_MAX_SIZE) {
109
+
110
+ continue;
111
+ }
112
+
113
+ /**
114
+ * Add the log's filesize to the total size of all valid logs and add the log to the array.
115
+ */
116
+ $totalSize += $fileSize;
117
+ $logsWithNames[$logName] = $log;
118
+ }
119
+
120
+
121
+ if (empty($logsWithNames)) {
122
+ return false;
123
+ }
124
+
125
+ if ($totalSize > self::LOG_MAX_TOTAL_SIZE) {
126
+ return false;
127
+ }
128
+
129
+ /**
130
+ * Creating the zip file for large logs may take a while, so disable the PHP time limit.
131
+ */
132
+ set_time_limit(0);
133
+
134
+
135
+ $zipPath = $logFolder
136
+ . 'TIG_MyParcel2014-logs-'
137
+ . date('Ymd-His', Mage::getSingleton('core/date')->timestamp())
138
+ . '.zip';
139
+
140
+ /**
141
+ * Open the zip file. Overwriting the previous file if it exists.
142
+ */
143
+ $zip = new ZipArchive();
144
+ $zip->open($zipPath, ZipArchive::OVERWRITE);
145
+
146
+ foreach ($logsWithNames as $name => $log) {
147
+ $zip->addFile($log, $name);
148
+ }
149
+
150
+ $zip->close();
151
+
152
+ return $zipPath;
153
+ }
154
+
155
+ /**
156
+ * get the logfiles for the MyParcel extension &
157
+ * @return array
158
+ */
159
+ protected function getLogFileNames()
160
+ {
161
+ $helper = Mage::helper('tig_myparcel');
162
+
163
+ if(!in_array($helper::MYPARCEL_EXCEPTION_LOG_FILE, $this->logFiles)
164
+ && !in_array($helper::MYPARCEL_DEBUG_LOG_FILE, $this->logFiles)
165
+ ){
166
+ $this->logFiles[] = $helper::MYPARCEL_EXCEPTION_LOG_FILE;
167
+ $this->logFiles[] = $helper::MYPARCEL_DEBUG_LOG_FILE;
168
+ }
169
+
170
+ return $this->logFiles;
171
+ }
172
+ }
app/code/community/TIG/MyParcel2014/Model/Api/MyParcel.php ADDED
@@ -0,0 +1,666 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * ___________ __ __
4
+ * \__ ___/____ _/ |_ _____ | |
5
+ * | | / _ \\ __\\__ \ | |
6
+ * | | | |_| || | / __ \_| |__
7
+ * |____| \____/ |__| (____ /|____/
8
+ * \/
9
+ * ___ __ __
10
+ * | | ____ _/ |_ ____ _______ ____ ____ _/ |_
11
+ * | | / \\ __\_/ __ \\_ __ \ / \ _/ __ \\ __\
12
+ * | || | \| | \ ___/ | | \/| | \\ ___/ | |
13
+ * |___||___| /|__| \_____>|__| |___| / \_____>|__|
14
+ * \/ \/
15
+ * ________
16
+ * / _____/_______ ____ __ __ ______
17
+ * / \ ___\_ __ \ / _ \ | | \\____ \
18
+ * \ \_\ \| | \/| |_| || | /| |_| |
19
+ * \______ /|__| \____/ |____/ | __/
20
+ * \/ |__|
21
+ *
22
+ * NOTICE OF LICENSE
23
+ *
24
+ * This source file is subject to the Creative Commons License.
25
+ * It is available through the world-wide-web at this URL:
26
+ * http://creativecommons.org/licenses/by-nc-nd/3.0/nl/deed.en_US
27
+ * If you are unable to obtain it through the world-wide-web, please send an email
28
+ * to servicedesk@tig.nl so we can send you a copy immediately.
29
+ *
30
+ * DISCLAIMER
31
+ *
32
+ * Do not edit or add to this file if you wish to upgrade this module to newer
33
+ * versions in the future. If you wish to customize this module for your
34
+ * needs please contact servicedesk@tig.nl for more information.
35
+ *
36
+ * @copyright Copyright (c) 2014 Total Internet Group B.V. (http://www.tig.nl)
37
+ * @license http://creativecommons.org/licenses/by-nc-nd/3.0/nl/deed.en_US
38
+ *
39
+ *
40
+ * Myparcel API class. Contains all the functionality to connect to Myparcel and get information or create consignments
41
+ *
42
+ * @method TIG_MyParcel2014_Model_Api_MyParcel setStoreId(int $value)
43
+ * @method bool hasStoreId()
44
+ */
45
+ class TIG_MyParcel2014_Model_Api_MyParcel extends Varien_Object
46
+ {
47
+ /**
48
+ * Supported request types.
49
+ */
50
+ const REQUEST_TYPE_CREATE_CONSIGNMENT = 'create-consignment';
51
+ const REQUEST_TYPE_CREATE_CONSIGNMENTS = 'create-consignments';
52
+ const REQUEST_TYPE_REGISTER_CONFIG = 'register-config';
53
+ const REQUEST_TYPE_RETRIEVE_PDF = 'retrieve-pdf';
54
+ const REQUEST_TYPE_RETRIEVE_PDFS = 'retrieve-pdfs';
55
+ const REQUEST_TYPE_RETRIEVE_STATUS = 'retrieve-status';
56
+ const REQUEST_TYPE_CONSIGNMENT_CREDIT = 'consignment-credit';
57
+ const REQUEST_TYPE_CREATE_RETOURLINK = 'create-retourlink';
58
+
59
+ /**
60
+ * @var string
61
+ */
62
+ protected $apiUsername = '';
63
+
64
+ /**
65
+ * @var string
66
+ */
67
+ protected $apiKey = '';
68
+
69
+ /**
70
+ * @var string
71
+ */
72
+ protected $apiUrl = '';
73
+
74
+ /**
75
+ * @var string
76
+ */
77
+ protected $requestString = '';
78
+
79
+ /**
80
+ * @var string
81
+ */
82
+ protected $requestHash = '';
83
+
84
+ /**
85
+ * @var string
86
+ */
87
+ protected $requestType = '';
88
+
89
+ /**
90
+ * @var string
91
+ */
92
+ protected $requestResult = false;
93
+
94
+ /**
95
+ * @var string
96
+ */
97
+ protected $requestError = false;
98
+
99
+ /**
100
+ * @var string
101
+ */
102
+ protected $requestErrorDetail = false;
103
+
104
+ /**
105
+ * sets the api username and api key on construct.
106
+ *
107
+ * @return void
108
+ */
109
+ protected function _construct()
110
+ {
111
+ $storeId = $this->getStoreId();
112
+ $helper = Mage::helper('tig_myparcel');
113
+ $username = $helper->getConfig('username', 'api', $storeId);
114
+ $key = $helper->getConfig('key', 'api', $storeId, true);
115
+
116
+ if (empty($username) && empty($key)) {
117
+ return;
118
+ }
119
+
120
+ $this->apiUrl = $helper->getConfig('url') . '/api/';
121
+ $this->apiUsername = $username;
122
+ $this->apiKey = $key;
123
+ }
124
+
125
+ /**
126
+ * @return int
127
+ */
128
+ public function getStoreId()
129
+ {
130
+ if ($this->hasStoreId()) {
131
+ return $this->_getData('store_id');
132
+ }
133
+
134
+ $storeId = Mage::app()->getStore()->getId();
135
+
136
+ $this->setStoreId($storeId);
137
+ return $storeId;
138
+ }
139
+
140
+ /**
141
+ * returns the response as an array, when an error occurs it will return the error message as a string
142
+ * @return array
143
+ */
144
+ public function getRequestResponse()
145
+ {
146
+ if(!empty($this->requestError)){
147
+ return $this->requestError;
148
+ }
149
+
150
+ return $this->requestResult;
151
+ }
152
+
153
+ public function getRequestErrorDetail()
154
+ {
155
+ $errorDetail = $this->requestErrorDetail;
156
+
157
+ if(!$errorDetail){
158
+ return false;
159
+ }
160
+
161
+ if(is_string($errorDetail))
162
+ {
163
+ return $errorDetail;
164
+ }
165
+
166
+ if(is_array($errorDetail) && !empty($errorDetail))
167
+ {
168
+ $return = $this->requestError.' - ';
169
+ foreach($errorDetail as $key => $errorMessage)
170
+ {
171
+ $return .= $key;
172
+ if(is_string($errorMessage))
173
+ {
174
+ $return .= ': '.$errorMessage;
175
+ }
176
+
177
+ if(is_array($errorMessage) && !empty($errorMessage))
178
+ {
179
+ $return .= ':<br/>'."\n";
180
+ foreach($errorMessage as $key => $value)
181
+ {
182
+ $return .= $key .' - '.$value[0];
183
+ }
184
+ }
185
+ }
186
+
187
+ if($return == '')
188
+ {
189
+ return false;
190
+ }
191
+
192
+ return $return;
193
+ }
194
+ return false;
195
+ }
196
+
197
+ /**
198
+ * send the created request to MyParcel
199
+ *
200
+ * @return $this|false|array|string
201
+ */
202
+ public function sendRequest()
203
+ {
204
+ if (!$this->_checkConfigForRequest()) {
205
+ return false;
206
+ }
207
+
208
+ $body = $this->requestString . '&signature=' . $this->requestHash;
209
+
210
+ $options = array(
211
+ CURLOPT_POST => true,
212
+ CURLOPT_FOLLOWLOCATION => true,
213
+ CURLOPT_AUTOREFERER => true,
214
+ );
215
+
216
+ $config = array(
217
+ 'header' => 0,
218
+ 'timeout' => 60,
219
+ );
220
+
221
+ $url = $this->apiUrl . $this->requestType;
222
+
223
+ $helper = Mage::helper('tig_myparcel');
224
+
225
+ $helper->log($url);
226
+
227
+ parse_str(urldecode($body), $bodyArray);
228
+ $bodyArray['json'] = json_decode($bodyArray['json']);
229
+
230
+ $helper->log($bodyArray['json']);
231
+
232
+ $request = new Varien_Http_Adapter_Curl();
233
+ foreach($options as $option => $value)
234
+ {
235
+ $request->addOption($option, $value);
236
+ }
237
+ $request->setConfig($config)
238
+ ->write(Zend_Http_Client::POST, $url, '1.1', array(), $body);
239
+
240
+ $response = $request->read();
241
+ $helper->log(json_decode($response, true));
242
+
243
+ if ($response === false) {
244
+ $error = $request->getError();
245
+ $this->requestError = $error;
246
+
247
+ return $this;
248
+ }
249
+
250
+ $result = json_decode($response, true);
251
+
252
+ if(isset($result['error'])){
253
+ $this->requestError = $result['error'];
254
+ unset($result['error']);
255
+ $this->requestErrorDetail = $result;
256
+ $request->close();
257
+
258
+ return $this;
259
+ }
260
+
261
+ $this->requestResult = $result;
262
+
263
+ $request->close();
264
+
265
+ return $this;
266
+ }
267
+
268
+ /**
269
+ * Checks if all the requirements are set to send a request to MyParcel
270
+ * @return bool
271
+ */
272
+ protected function _checkConfigForRequest()
273
+ {
274
+ if(empty($this->apiUsername) || empty($this->apiKey)){
275
+ return false;
276
+ }
277
+
278
+ if(empty($this->requestType)){
279
+ return false;
280
+ }
281
+
282
+ if(empty($this->requestString)){
283
+ return false;
284
+ }
285
+
286
+ if(empty($this->requestHash)){
287
+ return false;
288
+ }
289
+
290
+ return true;
291
+ }
292
+
293
+ /**
294
+ * Prepares the API for processing a create consignment request.
295
+ *
296
+ * @param TIG_MyParcel2014_Model_Shipment $myParcelShipment
297
+ *
298
+ * @return $this
299
+ */
300
+ public function createConsignmentRequest(TIG_MyParcel2014_Model_Shipment $myParcelShipment)
301
+ {
302
+ $data = array(
303
+ 'process' => 1,
304
+ 'consignment' => $this->_getConsignmentData($myParcelShipment),
305
+ );
306
+
307
+ $requestString = $this->_createRequestString($data);
308
+
309
+ $this->_setRequestParameters($requestString, self::REQUEST_TYPE_CREATE_CONSIGNMENT);
310
+
311
+ return $this;
312
+ }
313
+
314
+ /**
315
+ * @TODO for use in massaction
316
+ * @param array $shippingIds
317
+ */
318
+ public function createConsignmentsRequest($shippingIds = array()){}
319
+
320
+ /**
321
+ * Prepares the API for retrieving pdf's for a consignment ID.
322
+ *
323
+ * @param array $consignmentId
324
+ *
325
+ * @return $this
326
+ */
327
+ public function createRetrievePdfRequest($consignmentId)
328
+ {
329
+ $data = array(
330
+ 'consignment_id' => $consignmentId,
331
+ 'format' => 'json',
332
+ );
333
+
334
+ $requestString = $this->_createRequestString($data);
335
+
336
+ $this->_setRequestParameters($requestString, self::REQUEST_TYPE_RETRIEVE_PDF);
337
+
338
+ return $this;
339
+ }
340
+
341
+ /**
342
+ * Prepares the API for retrieving pdf's for an array of consignment IDs.
343
+ *
344
+ * @param array $consignmentIds
345
+ * @param int|string $start
346
+ * @param string $perpage
347
+ *
348
+ * @return $this
349
+ */
350
+ public function createRetrievePdfsRequest($consignmentIds = array(), $start = 1, $perpage = 'A4')
351
+ {
352
+ $data = array(
353
+ 'consignments' => $consignmentIds,
354
+ 'start' => intval($start),
355
+ 'perpage' => strtoupper($perpage),
356
+ 'format' => 'json',
357
+ );
358
+
359
+ $requestString = $this->_createRequestString($data);
360
+
361
+ $this->_setRequestParameters($requestString, self::REQUEST_TYPE_RETRIEVE_PDFS);
362
+
363
+ return $this;
364
+ }
365
+
366
+ /**
367
+ * Prepares the API for retrieving pdf's for a consignment ID.
368
+ *
369
+ * @return $this
370
+ */
371
+ public function createRegisterConfigRequest()
372
+ {
373
+ $data = array(
374
+ 'webshop_version' => 'Magento ' . Mage::getVersion(),
375
+ 'plugin_version' => (string) Mage::getConfig()->getModuleConfig('TIG_MyParcel2014')->version,
376
+ 'php_version' => phpversion(),
377
+ );
378
+
379
+ $requestString = $this->_createRequestString($data);
380
+
381
+ $this->_setRequestParameters($requestString, self::REQUEST_TYPE_REGISTER_CONFIG);
382
+
383
+ return $this;
384
+ }
385
+
386
+ /**
387
+ * @param $consignmentId
388
+ * @return $this
389
+ */
390
+ public function createRetrieveStatusRequest($consignmentId)
391
+ {
392
+ $data = array(
393
+ 'consignment_id' => $consignmentId,
394
+ );
395
+
396
+ $requestString = $this->_createRequestString($data);
397
+
398
+ $this->_setRequestParameters($requestString, self::REQUEST_TYPE_RETRIEVE_STATUS);
399
+
400
+ return $this;
401
+ }
402
+
403
+ /**
404
+ * @param $consignmentId
405
+ * @return $this
406
+ */
407
+ public function createConsignmentCreditRequest($consignmentId)
408
+ {
409
+ $data = array(
410
+ 'consignment_id' => $consignmentId,
411
+ );
412
+
413
+ $requestString = $this->_createRequestString($data);
414
+
415
+ $this->_setRequestParameters($requestString, self::REQUEST_TYPE_CONSIGNMENT_CREDIT);
416
+
417
+ return $this;
418
+ }
419
+
420
+ /**
421
+ * @param $consignmentId
422
+ * @return $this
423
+ */
424
+ public function createRetourlinkRequest($consignmentId)
425
+ {
426
+ $data = array(
427
+ 'consignment_id' => $consignmentId,
428
+ );
429
+
430
+ $requestString = $this->_createRequestString($data);
431
+
432
+ $this->_setRequestParameters($requestString, self::REQUEST_TYPE_CREATE_RETOURLINK);
433
+
434
+ return $this;
435
+ }
436
+
437
+ /**
438
+ * Gets the shipping address and product code data for this shipment.
439
+ *
440
+ * @param TIG_MyParcel2014_Model_Shipment $myParcelShipment
441
+ *
442
+ * @return array
443
+ */
444
+ protected function _getConsignmentData(TIG_MyParcel2014_Model_Shipment $myParcelShipment)
445
+ {
446
+ $helper = Mage::helper('tig_myparcel');
447
+ $order = $myParcelShipment->getOrder();
448
+ $storeId = $order->getStore()->getId();
449
+
450
+ $shippingAddress = $myParcelShipment->getShippingAddress();
451
+ $streetData = $helper->getStreetData($shippingAddress,$storeId);
452
+ $email = $myParcelShipment->getOrder()->getCustomerEmail();
453
+
454
+ $data = array(
455
+ 'ToAddress' => array(
456
+ 'country_code' => $shippingAddress->getCountry(),
457
+ 'name' => $shippingAddress->getName(),
458
+ 'business' => $shippingAddress->getCompany(),
459
+ 'postcode' => $shippingAddress->getPostcode(),
460
+ 'street' => $streetData['streetname'],
461
+ 'house_number' => $streetData['housenumber'],
462
+ 'number_addition' => $streetData['housenumberExtension'],
463
+ 'town' => $shippingAddress->getCity(),
464
+ 'email' => $email,
465
+ ),
466
+ 'ProductCode' => $this->_getProductCodeData($myParcelShipment),
467
+ 'insured_amount' => $this->_getInsuredAmount($myParcelShipment),
468
+ 'custom_id' => $order->getIncrementId(),
469
+ 'comments' => '',
470
+ );
471
+
472
+ if($shippingAddress->getCountry() != 'NL')
473
+ {
474
+ $data['ToAddress']['eps_postcode'] = $data['ToAddress']['postcode'];
475
+ $data['ToAddress']['street'] = trim(str_replace(' ', ' ', implode(' ', $streetData)));
476
+ unset($data['ToAddress']['postcode']);
477
+ unset($data['ToAddress']['house_number']);
478
+ unset($data['ToAddress']['number_addition']);
479
+ }
480
+
481
+ // add customs data for EUR3 and World shipments
482
+ if($helper->countryNeedsCustoms($shippingAddress->getCountry()))
483
+ {
484
+ $data['customs_shipment_type'] = $helper->getConfig('customs_type', 'shipment', $storeId);
485
+ $data['customs_invoice'] = $order->getIncrementId();
486
+ $data['CustomsContent'] = array();
487
+
488
+ $customsContentType = $helper->getConfig('customs_hstariffnr', 'shipment', $storeId);
489
+ if($myParcelShipment->getCustomsContentType()){
490
+ $customsContentType = $myParcelShipment->getCustomsContentType();
491
+ }
492
+
493
+ $totalWeight = 0;
494
+ $items = $myParcelShipment->getOrder()->getAllItems();
495
+ $i = 0;
496
+ foreach($items as $item)
497
+ {
498
+ if($item->getProductType() == 'simple')
499
+ {
500
+ $parentId = $item->getParentItemId();
501
+ $weight = floatval($item->getWeight());
502
+ $price = floatval($item->getPrice());
503
+ $qty = intval($item->getQtyOrdered());
504
+
505
+ if(!empty($parentId))
506
+ {
507
+ $parent = Mage::getModel('sales/order_item')->load($parentId);
508
+
509
+ // TODO: check for multiple test cases with configurable and bundled products
510
+ if(empty($weight))
511
+ {
512
+ $weight = $parent->getWeight();
513
+ }
514
+ if(empty($price))
515
+ {
516
+ $price = $parent->getPrice();
517
+ }
518
+ }
519
+
520
+ $weight *= $qty;
521
+ $weight = max(array(1, $weight));
522
+ $totalWeight += $weight;
523
+
524
+ $price *= $qty;
525
+
526
+ $data['CustomsContent'][$i] = array(
527
+ 'Description' => $item->getName(),
528
+ 'Quantity' => $qty,
529
+ 'Weight' => $weight,
530
+ 'Value' => $price,
531
+ 'HSTariffNr' => $customsContentType,
532
+ 'CountryOfOrigin' => Mage::getStoreConfig('general/country/default', $storeId),
533
+ );
534
+
535
+ if(++$i >= 5) {
536
+ break; // max 5 entries
537
+ }
538
+ }
539
+ }
540
+ $data['weight'] = $totalWeight;
541
+ }
542
+
543
+ /**
544
+ * If the customer has chosen to pick up their order at a PakjeGemak location, add the PakjeGemak address.
545
+ */
546
+ $pgAddress = $helper->getPgAddress($myParcelShipment);
547
+ $shippingMethod = $order->getShippingMethod();
548
+
549
+ if ($pgAddress && $helper->shippingMethodIsPakjegemak($shippingMethod)) {
550
+ $pgStreetData = $helper->getStreetData($pgAddress,$storeId);
551
+ $data['PgAddress'] = array(
552
+ 'country_code' => $pgAddress->getCountry(),
553
+ 'name' => $pgAddress->getName(),
554
+ 'business' => $pgAddress->getCompany(),
555
+ 'postcode' => $pgAddress->getPostcode(),
556
+ 'street' => $pgStreetData['streetname'],
557
+ 'house_number' => $pgStreetData['housenumber'],
558
+ 'number_addition' => $pgStreetData['housenumberExtension'],
559
+ 'town' => $pgAddress->getCity(),
560
+ 'email' => $email,
561
+ );
562
+ }
563
+
564
+ return $data;
565
+ }
566
+
567
+ /**
568
+ * Gets the product code parameters for this shipment.
569
+ *
570
+ * @param TIG_MyParcel2014_Model_Shipment $myParcelShipment
571
+ *
572
+ * @return array
573
+ */
574
+ protected function _getProductCodeData(TIG_MyParcel2014_Model_Shipment $myParcelShipment)
575
+ {
576
+ $data = array(
577
+ 'extra_size' => 0,
578
+ 'home_address_only' => $myParcelShipment->getHomeAddressOnly(),
579
+ 'signature_on_receipt' => $myParcelShipment->getSignatureOnReceipt(),
580
+ 'return_if_no_answer' => $myParcelShipment->getReturnIfNoAnswer(),
581
+ 'insured' => $myParcelShipment->getInsured(),
582
+ );
583
+ if($myParcelShipment->getShippingAddress()->getCountry() != 'NL')
584
+ {
585
+ // strip all Dutch domestic options if shipment is not NL
586
+ unset($data['home_address_only']);
587
+ unset($data['signature_on_receipt']);
588
+ unset($data['return_if_no_answer']);
589
+ unset($data['insured']);
590
+ }
591
+
592
+ return $data;
593
+ }
594
+
595
+ /**
596
+ * Get the insured amount for this shipment.
597
+ *
598
+ * @param TIG_MyParcel2014_Model_Shipment $myParcelShipment
599
+ *
600
+ * @return int
601
+ */
602
+ protected function _getInsuredAmount(TIG_MyParcel2014_Model_Shipment $myParcelShipment)
603
+ {
604
+ if ($myParcelShipment->getInsured()) {
605
+ return (int) $myParcelShipment->getInsuredAmount();
606
+ }
607
+
608
+ return 0;
609
+ }
610
+
611
+ /**
612
+ * Creates a url-encoded request string.
613
+ *
614
+ * @param array $data
615
+ *
616
+ * @return string
617
+ */
618
+ protected function _createRequestString(array $data)
619
+ {
620
+ $json = json_encode($data);
621
+
622
+ $string = http_build_query(
623
+ array(
624
+ 'json' => $json,
625
+ 'nonce' => 0, // @TODO What are we supposed to do with this parameter
626
+ 'test' => 0,
627
+ 'timestamp' => time(),
628
+ 'username' => $this->apiUsername,
629
+ )
630
+ );
631
+
632
+ return $string;
633
+ }
634
+
635
+ /**
636
+ * Sets the parameters for an API call based on a string with all required request parameters and the requested API
637
+ * method.
638
+ *
639
+ * @param string $requestString
640
+ * @param string $requestType
641
+ *
642
+ * @return $this
643
+ */
644
+ protected function _setRequestParameters($requestString, $requestType)
645
+ {
646
+ $this->requestString = $requestString;
647
+ $this->requestType = $requestType;
648
+
649
+ $this->_hashRequest();
650
+
651
+ return $this;
652
+ }
653
+
654
+ /**
655
+ * Creates a hash to ensure security, sets the $requestHash class-variable
656
+ *
657
+ * @return $this
658
+ */
659
+ protected function _hashRequest()
660
+ {
661
+ //generate hash
662
+ $this->requestHash = hash_hmac('sha1', 'POST&' . urlencode($this->requestString), $this->apiKey);
663
+
664
+ return $this;
665
+ }
666
+ }
app/code/community/TIG/MyParcel2014/Model/Carrier/MyParcel.php ADDED
@@ -0,0 +1,308 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class TIG_MyParcel2014_Model_Carrier_MyParcel extends Mage_Shipping_Model_Carrier_Abstract
4
+ implements Mage_Shipping_Model_Carrier_Interface
5
+ {
6
+ /**
7
+ * Rate type (tablerate or flatrate).
8
+ */
9
+ const XML_PATH_RATE_TYPE = 'carriers/tig_myparcel/rate_type';
10
+
11
+ /**
12
+ * MyParcel Carrier code
13
+ *
14
+ * @var string
15
+ */
16
+ protected $_code = 'tig_myparcel';
17
+
18
+ /**
19
+ * Fixed price flag
20
+ *
21
+ * @var boolean
22
+ */
23
+ protected $_isFixed = true;
24
+
25
+ /**
26
+ * @var string
27
+ */
28
+ protected $_default_condition_name = 'package_weight';
29
+
30
+ /**
31
+ * Class constructor.
32
+ */
33
+ public function __construct()
34
+ {
35
+ parent::__construct();
36
+ }
37
+
38
+ /**
39
+ * Collect and get rates
40
+ *
41
+ * @param Mage_Shipping_Model_Rate_Request $request
42
+ * @return bool|Mage_Shipping_Model_Rate_Result|mixed|null
43
+ * @throws TIG_MyParcel2014_Exception
44
+ */
45
+ public function collectRates(Mage_Shipping_Model_Rate_Request $request)
46
+ {
47
+ if (!$this->getConfigFlag('active')) {
48
+ return false;
49
+ }
50
+
51
+ $helper = Mage::helper('tig_myparcel');
52
+
53
+ /**
54
+ * @todo Change this so it also works when creating orders in the backend.
55
+ */
56
+ $rateType = Mage::getStoreConfig(self::XML_PATH_RATE_TYPE, Mage::app()->getStore()->getId());
57
+
58
+ $result = false;
59
+
60
+ if ($rateType == 'flat') {
61
+ $result = $this->_getFlatRate($request);
62
+ }
63
+
64
+ if ($rateType == 'table') {
65
+ $result = $this->_getTableRate($request);
66
+ }
67
+
68
+ if (!$result) {
69
+ throw new TIG_MyParcel2014_Exception(
70
+ $helper->__('Unknown rate type specified: %s.', $rateType),
71
+ 'MYPA-0014'
72
+ );
73
+ }
74
+
75
+ // add PakjeGemak if country is NL and not in admin
76
+ if(!$helper->isAdmin()){
77
+ if($request->getDestCountryId() == 'NL' && $this->getConfigData('pakjegemak_active') == 1)
78
+ {
79
+ $currentRate = current($result->getRatesByCarrier($this->_code));
80
+
81
+ if($currentRate)
82
+ {
83
+ $currentPrice = $currentRate->getPrice();
84
+ $pakjegemakPrice = floatval($this->getConfigData('pakjegemak_fee'));
85
+
86
+ // use a modified clone of the configured shipping rate
87
+ $pakjegemakRate = clone $currentRate;
88
+
89
+ $pakjegemakRate->setMethod('pakjegemak');
90
+ $pakjegemakRate->setMethodTitle('Pakjegemak');
91
+ $pakjegemakRate->setPrice($currentPrice + $pakjegemakPrice);
92
+
93
+ $result->append($pakjegemakRate);
94
+ }
95
+ }
96
+ }
97
+
98
+
99
+ return $result;
100
+ }
101
+
102
+ /**
103
+ * Get allowed shipping methods
104
+ *
105
+ * @return array
106
+ */
107
+ public function getAllowedMethods()
108
+ {
109
+ return array(
110
+ 'flatrate' => $this->getConfigData('name') . ' flat',
111
+ 'tablerate' => $this->getConfigData('name') . ' table',
112
+ 'pakjegemak' => $this->getConfigData('name') . ' pakjegemak',
113
+ );
114
+ }
115
+
116
+ /**
117
+ * @param Mage_Shipping_Model_Rate_Request $request
118
+ * @return Mage_Shipping_Model_Rate_Result
119
+ */
120
+ protected function _getFlatRate(Mage_Shipping_Model_Rate_Request $request)
121
+ {
122
+ $freeBoxes = 0;
123
+ if ($request->getAllItems()) {
124
+ foreach ($request->getAllItems() as $item) {
125
+
126
+ if ($item->getProduct()->isVirtual() || $item->getParentItem()) {
127
+ continue;
128
+ }
129
+
130
+ if ($item->getHasChildren() && $item->isShipSeparately()) {
131
+ foreach ($item->getChildren() as $child) {
132
+ if ($child->getFreeShipping() && !$child->getProduct()->isVirtual()) {
133
+ $freeBoxes += $item->getQty() * $child->getQty();
134
+ }
135
+ }
136
+ } elseif ($item->getFreeShipping()) {
137
+ $freeBoxes += $item->getQty();
138
+ }
139
+ }
140
+ }
141
+ $this->setFreeBoxes($freeBoxes);
142
+
143
+ $result = Mage::getModel('shipping/rate_result');
144
+ if ($this->getConfigData('type') == 'O') { // per order
145
+ $shippingPrice = $this->getConfigData('price');
146
+ } elseif ($this->getConfigData('type') == 'I') { // per item
147
+ $shippingPrice = ($request->getPackageQty() * $this->getConfigData('price')) - ($this->getFreeBoxes() * $this->getConfigData('price'));
148
+ } else {
149
+ $shippingPrice = false;
150
+ }
151
+
152
+ $shippingPrice = $this->getFinalPriceWithHandlingFee($shippingPrice);
153
+
154
+ if ($shippingPrice !== false) {
155
+ $method = Mage::getModel('shipping/rate_result_method');
156
+
157
+ $method->setCarrier($this->_code);
158
+ $method->setCarrierTitle($this->getConfigData('title'));
159
+
160
+ $method->setMethod('flatrate');
161
+ $method->setMethodTitle($this->getConfigData('name'));
162
+
163
+ if ($request->getFreeShipping() === true || $request->getPackageQty() == $this->getFreeBoxes()) {
164
+ $shippingPrice = '0.00';
165
+ }
166
+
167
+ $method->setPrice($shippingPrice);
168
+ $method->setCost($shippingPrice);
169
+
170
+ $result->append($method);
171
+ }
172
+
173
+ return $result;
174
+ }
175
+
176
+ /**
177
+ * @param Mage_Shipping_Model_Rate_Request $request
178
+ * @return mixed
179
+ */
180
+ protected function _getTableRate(Mage_Shipping_Model_Rate_Request $request)
181
+ {
182
+ // exclude Virtual products price from Package value if pre-configured
183
+ if (!$this->getConfigFlag('include_virtual_price') && $request->getAllItems()) {
184
+ foreach ($request->getAllItems() as $item) {
185
+ if ($item->getParentItem()) {
186
+ continue;
187
+ }
188
+ if ($item->getHasChildren() && $item->isShipSeparately()) {
189
+ foreach ($item->getChildren() as $child) {
190
+ if ($child->getProduct()->isVirtual()) {
191
+ $request->setPackageValue($request->getPackageValue() - $child->getBaseRowTotal());
192
+ }
193
+ }
194
+ } elseif ($item->getProduct()->isVirtual()) {
195
+ $request->setPackageValue($request->getPackageValue() - $item->getBaseRowTotal());
196
+ }
197
+ }
198
+ }
199
+
200
+ // Free shipping by qty
201
+ $freeQty = 0;
202
+ $freePackageValue = false;
203
+ if ($request->getAllItems()) {
204
+ $freePackageValue = 0;
205
+ foreach ($request->getAllItems() as $item) {
206
+ if ($item->getProduct()->isVirtual() || $item->getParentItem()) {
207
+ continue;
208
+ }
209
+
210
+ if ($item->getHasChildren() && $item->isShipSeparately()) {
211
+ foreach ($item->getChildren() as $child) {
212
+ if ($child->getFreeShipping() && !$child->getProduct()->isVirtual()) {
213
+ $freeShipping = is_numeric($child->getFreeShipping()) ? $child->getFreeShipping() : 0;
214
+ $freeQty += $item->getQty() * ($child->getQty() - $freeShipping);
215
+ }
216
+ }
217
+ } elseif ($item->getFreeShipping()) {
218
+ $freeShipping = is_numeric($item->getFreeShipping()) ? $item->getFreeShipping() : 0;
219
+ $freeQty += $item->getQty() - $freeShipping;
220
+ $freePackageValue += $item->getBaseRowTotal();
221
+ }
222
+ }
223
+ $oldValue = $request->getPackageValue();
224
+ $request->setPackageValue($oldValue - $freePackageValue);
225
+ }
226
+
227
+ if ($freePackageValue) {
228
+ $request->setPackageValue($request->getPackageValue() - $freePackageValue);
229
+ }
230
+
231
+ $conditionName = $this->getConfigData('condition_name');
232
+ $request->setConditionName($conditionName ? $conditionName : $this->_default_condition_name);
233
+
234
+ // Package weight and qty free shipping
235
+ $oldWeight = $request->getPackageWeight();
236
+ $oldQty = $request->getPackageQty();
237
+
238
+ $request->setPackageWeight($request->getFreeMethodWeight());
239
+ $request->setPackageQty($oldQty - $freeQty);
240
+
241
+ $result = Mage::getModel('shipping/rate_result');
242
+ $rate = $this->getRate($request);
243
+
244
+ $request->setPackageWeight($oldWeight);
245
+ $request->setPackageQty($oldQty);
246
+
247
+ $method = Mage::getModel('shipping/rate_result_method');
248
+ if (!empty($rate) && $rate['price'] >= 0) {
249
+ if ($request->getFreeShipping() === true || ($request->getPackageQty() == $freeQty)) {
250
+ $shippingPrice = 0;
251
+ } else {
252
+ $shippingPrice = $this->getFinalPriceWithHandlingFee($rate['price']);
253
+ }
254
+
255
+ $price = $shippingPrice;
256
+ $cost = $rate['cost'];
257
+ } elseif (empty($rate) && $request->getFreeShipping() === true) {
258
+ /**
259
+ * was applied promotion rule for whole cart
260
+ * other shipping methods could be switched off at all
261
+ * we must show table rate method with 0$ price, if grand_total more, than min table condition_value
262
+ * free setPackageWeight() has already was taken into account
263
+ */
264
+ $request->setPackageValue($freePackageValue);
265
+ $request->setPackageQty($freeQty);
266
+ $rate = $this->getRate($request);
267
+ if (!empty($rate) && $rate['price'] >= 0) {
268
+ $method = Mage::getModel('shipping/rate_result_method');
269
+ }
270
+
271
+ $price = 0;
272
+ $cost = 0;
273
+ } else {
274
+ $error = Mage::getModel('shipping/rate_result_error');
275
+ $error->setCarrier('tablerate');
276
+ $error->setCarrierTitle($this->getConfigData('title'));
277
+ $error->setErrorMessage($this->getConfigData('specificerrmsg'));
278
+ $result->append($error);
279
+ return $result;
280
+ }
281
+
282
+ $method->setCarrier($this->_code);
283
+ $method->setCarrierTitle($this->getConfigData('title'));
284
+
285
+ $method->setMethod('tablerate');
286
+ $method->setMethodTitle($this->getConfigData('name'));
287
+
288
+ $method->setPrice($price);
289
+ $method->setCost($cost);
290
+
291
+ $result->append($method);
292
+
293
+ return $result;
294
+ }
295
+
296
+ /**
297
+ * @param Mage_Shipping_Model_Rate_Request $request
298
+ *
299
+ * @return array|bool
300
+ */
301
+ public function getRate(Mage_Shipping_Model_Rate_Request $request)
302
+ {
303
+ //$websiteId = $request->getWebsiteId();
304
+ //$website = Mage::getModel('core/website')->load($websiteId);
305
+
306
+ return Mage::getResourceModel('shipping/carrier_tablerate')->getRate($request);
307
+ }
308
+ }
app/code/community/TIG/MyParcel2014/Model/Carrier/System/Config/Source/RateType.php ADDED
@@ -0,0 +1,62 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * ___________ __ __
4
+ * \__ ___/____ _/ |_ _____ | |
5
+ * | | / _ \\ __\\__ \ | |
6
+ * | | | |_| || | / __ \_| |__
7
+ * |____| \____/ |__| (____ /|____/
8
+ * \/
9
+ * ___ __ __
10
+ * | | ____ _/ |_ ____ _______ ____ ____ _/ |_
11
+ * | | / \\ __\_/ __ \\_ __ \ / \ _/ __ \\ __\
12
+ * | || | \| | \ ___/ | | \/| | \\ ___/ | |
13
+ * |___||___| /|__| \_____>|__| |___| / \_____>|__|
14
+ * \/ \/
15
+ * ________
16
+ * / _____/_______ ____ __ __ ______
17
+ * / \ ___\_ __ \ / _ \ | | \\____ \
18
+ * \ \_\ \| | \/| |_| || | /| |_| |
19
+ * \______ /|__| \____/ |____/ | __/
20
+ * \/ |__|
21
+ *
22
+ * NOTICE OF LICENSE
23
+ *
24
+ * This source file is subject to the Creative Commons License.
25
+ * It is available through the world-wide-web at this URL:
26
+ * http://creativecommons.org/licenses/by-nc-nd/3.0/nl/deed.en_US
27
+ * If you are unable to obtain it through the world-wide-web, please send an email
28
+ * to servicedesk@tig.nl so we can send you a copy immediately.
29
+ *
30
+ * DISCLAIMER
31
+ *
32
+ * Do not edit or add to this file if you wish to upgrade this module to newer
33
+ * versions in the future. If you wish to customize this module for your
34
+ * needs please contact servicedesk@tig.nl for more information.
35
+ *
36
+ * @copyright Copyright (c) 2014 Total Internet Group B.V. (http://www.tig.nl)
37
+ * @license http://creativecommons.org/licenses/by-nc-nd/3.0/nl/deed.en_US
38
+ */
39
+ class TIG_MyParcel2014_Model_Carrier_System_Config_Source_RateType
40
+ {
41
+ /**
42
+ * Returns an option array for rate type options
43
+ *
44
+ * @return array
45
+ */
46
+ public function toOptionArray()
47
+ {
48
+ $helper = Mage::helper('tig_myparcel');
49
+ $options = array(
50
+ array(
51
+ 'value' => 'flat',
52
+ 'label' => $helper->__('Flat'),
53
+ ),
54
+ array(
55
+ 'value' => 'table',
56
+ 'label' => $helper->__('Table'),
57
+ ),
58
+ );
59
+
60
+ return $options;
61
+ }
62
+ }
app/code/community/TIG/MyParcel2014/Model/Observer/Cron.php ADDED
@@ -0,0 +1,103 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * ___________ __ __
4
+ * \__ ___/____ _/ |_ _____ | |
5
+ * | | / _ \\ __\\__ \ | |
6
+ * | | | |_| || | / __ \_| |__
7
+ * |____| \____/ |__| (____ /|____/
8
+ * \/
9
+ * ___ __ __
10
+ * | | ____ _/ |_ ____ _______ ____ ____ _/ |_
11
+ * | | / \\ __\_/ __ \\_ __ \ / \ _/ __ \\ __\
12
+ * | || | \| | \ ___/ | | \/| | \\ ___/ | |
13
+ * |___||___| /|__| \_____>|__| |___| / \_____>|__|
14
+ * \/ \/
15
+ * ________
16
+ * / _____/_______ ____ __ __ ______
17
+ * / \ ___\_ __ \ / _ \ | | \\____ \
18
+ * \ \_\ \| | \/| |_| || | /| |_| |
19
+ * \______ /|__| \____/ |____/ | __/
20
+ * \/ |__|
21
+ *
22
+ * NOTICE OF LICENSE
23
+ *
24
+ * This source file is subject to the Creative Commons License.
25
+ * It is available through the world-wide-web at this URL:
26
+ * http://creativecommons.org/licenses/by-nc-nd/3.0/nl/deed.en_US
27
+ * If you are unable to obtain it through the world-wide-web, please send an email
28
+ * to servicedesk@tig.nl so we can send you a copy immediately.
29
+ *
30
+ * DISCLAIMER
31
+ *
32
+ * Do not edit or add to this file if you wish to upgrade this module to newer
33
+ * versions in the future. If you wish to customize this module for your
34
+ * needs please contact servicedesk@tig.nl for more information.
35
+ *
36
+ * @copyright Copyright (c) 2014 Total Internet Group B.V. (http://www.tig.nl)
37
+ * @license http://creativecommons.org/licenses/by-nc-nd/3.0/nl/deed.en_US
38
+ *
39
+ *
40
+ */
41
+
42
+ class TIG_MyParcel2014_Model_Observer_Cron
43
+ {
44
+ public function checkStatus()
45
+ {
46
+ $helper = Mage::helper('tig_myparcel');
47
+
48
+ if(!$helper->isEnabled()){
49
+ return $this;
50
+ }
51
+
52
+ //$helper->log('MyParcel checkStatus cron is started!');
53
+
54
+ //get all MyParcel shipments with no final status
55
+ $myparcelShipmentCollection = Mage::getResourceModel('tig_myparcel/shipment_collection');
56
+ $myparcelShipmentCollection->addFieldToFilter('is_final', array('eq' => '0'));
57
+
58
+ foreach ($myparcelShipmentCollection as $shipment) {
59
+ $api = Mage::getModel('tig_myparcel/api_myParcel');
60
+ $consignmentId = $shipment->getConsignmentId();
61
+ $barcode = $shipment->getBarcode();
62
+ $status = $shipment->getStatus();
63
+
64
+ $response = $api->createRetrieveStatusRequest($consignmentId)
65
+ ->sendRequest()
66
+ ->getRequestResponse();
67
+
68
+ if (is_array($response)) {
69
+ if($response['tracktrace'] != $barcode){
70
+ $helper->log('new barcode: '.$response['tracktrace']);
71
+
72
+ //check if e-mailtemplate isset
73
+ $isSend = $helper->sendBarcodeEmail($response['tracktrace'],$shipment);
74
+ if($isSend){
75
+ //add comment to order-comment history
76
+ $comment = $helper->__('Track&amp;Trace e-mail is send: %s',$barcode);
77
+ $order = $shipment->getOrder();
78
+ $order->addStatusHistoryComment($comment);
79
+ $order->setEmailSent(true);
80
+ $order->save();
81
+ }
82
+ $shipment->setBarcode($response['tracktrace']);
83
+ }
84
+
85
+ if($response['status'] != $status){
86
+ $shipment->setStatus($response['status']);
87
+ }
88
+
89
+ if($response['final'] == '1'){
90
+ $shipment->setIsFinal('1');
91
+ }
92
+
93
+ if($shipment->hasDataChanges()){
94
+ $shipment->save();
95
+ }
96
+ } else {
97
+ $helper->log($api->getRequestErrorDetail(),Zend_Log::ERR);
98
+ }
99
+ }
100
+
101
+ return $this;
102
+ }
103
+ }
app/code/community/TIG/MyParcel2014/Model/Observer/SaveConfig.php ADDED
@@ -0,0 +1,79 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * ___________ __ __
4
+ * \__ ___/____ _/ |_ _____ | |
5
+ * | | / _ \\ __\\__ \ | |
6
+ * | | | |_| || | / __ \_| |__
7
+ * |____| \____/ |__| (____ /|____/
8
+ * \/
9
+ * ___ __ __
10
+ * | | ____ _/ |_ ____ _______ ____ ____ _/ |_
11
+ * | | / \\ __\_/ __ \\_ __ \ / \ _/ __ \\ __\
12
+ * | || | \| | \ ___/ | | \/| | \\ ___/ | |
13
+ * |___||___| /|__| \_____>|__| |___| / \_____>|__|
14
+ * \/ \/
15
+ * ________
16
+ * / _____/_______ ____ __ __ ______
17
+ * / \ ___\_ __ \ / _ \ | | \\____ \
18
+ * \ \_\ \| | \/| |_| || | /| |_| |
19
+ * \______ /|__| \____/ |____/ | __/
20
+ * \/ |__|
21
+ *
22
+ * NOTICE OF LICENSE
23
+ *
24
+ * This source file is subject to the Creative Commons License.
25
+ * It is available through the world-wide-web at this URL:
26
+ * http://creativecommons.org/licenses/by-nc-nd/3.0/nl/deed.en_US
27
+ * If you are unable to obtain it through the world-wide-web, please send an email
28
+ * to servicedesk@tig.nl so we can send you a copy immediately.
29
+ *
30
+ * DISCLAIMER
31
+ *
32
+ * Do not edit or add to this file if you wish to upgrade this module to newer
33
+ * versions in the future. If you wish to customize this module for your
34
+ * needs please contact servicedesk@tig.nl for more information.
35
+ *
36
+ * @copyright Copyright (c) 2014 Total Internet Group B.V. (http://www.tig.nl)
37
+ * @license http://creativecommons.org/licenses/by-nc-nd/3.0/nl/deed.en_US
38
+ *
39
+ * @method boolean hasQuote()
40
+ * @method TIG_MyParcel2014_Model_Observer_SavePgAddress setQuote(Mage_Sales_Model_Quote $quote)
41
+ */
42
+ class TIG_MyParcel2014_Model_Observer_SaveConfig extends Varien_Object
43
+ {
44
+ /**
45
+ * Saves the verssion numbers of the extension, store and php
46
+ *
47
+ * @param Varien_Event_Observer $observer
48
+ *
49
+ * @return $this
50
+ *
51
+ * @event controller_action_postdispatch_adminhtml_system_config_save
52
+ *
53
+ * @observer tig_myparcel_save_config
54
+ */
55
+ public function registerConfig(Varien_Event_Observer $observer)
56
+ {
57
+ /**
58
+ * Check if the MyParcel extension is enabled.
59
+ */
60
+ if (!Mage::helper('tig_myparcel')->isEnabled()) {
61
+ return $this;
62
+ }
63
+
64
+ /**
65
+ * @var Mage_Core_Controller_Varien_Front $controller
66
+ */
67
+ $controller = $observer->getControllerAction();
68
+ $section = $controller->getRequest()->getParam('section');
69
+
70
+ if($section == 'tig_myparcel')
71
+ {
72
+ $api = Mage::getModel('tig_myparcel/api_myParcel');
73
+
74
+ $response = $api->createRegisterConfigRequest()->sendRequest(); // no getRequestResponse()
75
+ }
76
+
77
+ return $this;
78
+ }
79
+ }
app/code/community/TIG/MyParcel2014/Model/Observer/SavePgAddress.php ADDED
@@ -0,0 +1,440 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * ___________ __ __
4
+ * \__ ___/____ _/ |_ _____ | |
5
+ * | | / _ \\ __\\__ \ | |
6
+ * | | | |_| || | / __ \_| |__
7
+ * |____| \____/ |__| (____ /|____/
8
+ * \/
9
+ * ___ __ __
10
+ * | | ____ _/ |_ ____ _______ ____ ____ _/ |_
11
+ * | | / \\ __\_/ __ \\_ __ \ / \ _/ __ \\ __\
12
+ * | || | \| | \ ___/ | | \/| | \\ ___/ | |
13
+ * |___||___| /|__| \_____>|__| |___| / \_____>|__|
14
+ * \/ \/
15
+ * ________
16
+ * / _____/_______ ____ __ __ ______
17
+ * / \ ___\_ __ \ / _ \ | | \\____ \
18
+ * \ \_\ \| | \/| |_| || | /| |_| |
19
+ * \______ /|__| \____/ |____/ | __/
20
+ * \/ |__|
21
+ *
22
+ * NOTICE OF LICENSE
23
+ *
24
+ * This source file is subject to the Creative Commons License.
25
+ * It is available through the world-wide-web at this URL:
26
+ * http://creativecommons.org/licenses/by-nc-nd/3.0/nl/deed.en_US
27
+ * If you are unable to obtain it through the world-wide-web, please send an email
28
+ * to servicedesk@tig.nl so we can send you a copy immediately.
29
+ *
30
+ * DISCLAIMER
31
+ *
32
+ * Do not edit or add to this file if you wish to upgrade this module to newer
33
+ * versions in the future. If you wish to customize this module for your
34
+ * needs please contact servicedesk@tig.nl for more information.
35
+ *
36
+ * @copyright Copyright (c) 2014 Total Internet Group B.V. (http://www.tig.nl)
37
+ * @license http://creativecommons.org/licenses/by-nc-nd/3.0/nl/deed.en_US
38
+ *
39
+ * @method boolean hasQuote()
40
+ * @method TIG_MyParcel2014_Model_Observer_SavePgAddress setQuote(Mage_Sales_Model_Quote $quote)
41
+ */
42
+ class TIG_MyParcel2014_Model_Observer_SavePgAddress extends Varien_Object
43
+ {
44
+ /**
45
+ * Regular expressions to validate various address fields.
46
+ */
47
+ const CITY_NAME_REGEX = '#^[a-zA-Z]+(?:(?:\\s+|-)[a-zA-Z]+)*$#';
48
+ const STREET_NAME_REGEX = "#^[a-zA-Z0-9\s,'-]*$#";
49
+ const HOUSENR_EXT_REGEX = "#^[a-zA-Z0-9\s,'-]*$#";
50
+ const NAME_REGEX = "#^[a-zA-Z0-9\s,'-]*$#";
51
+
52
+ /**
53
+ * Regular expression to validate dutch phone number.
54
+ */
55
+ const PHONE_NUMBER_REGEX = '#^(((\+31|0|0031)){1}[1-9]{1}[0-9]{8})$#i';
56
+
57
+ /**
58
+ * Get the current quote.
59
+ *
60
+ * @return Mage_Sales_Model_Quote
61
+ */
62
+ public function getQuote()
63
+ {
64
+ if ($this->hasQuote()) {
65
+ return $this->_getData('quote');
66
+ }
67
+
68
+ $quote = Mage::getSingleton('checkout/session')->getQuote();
69
+
70
+ $this->setQuote($quote);
71
+ return $quote;
72
+ }
73
+
74
+ /**
75
+ * Saves a selected MyParcel address.
76
+ *
77
+ * @param Varien_Event_Observer $observer
78
+ *
79
+ * @return $this
80
+ *
81
+ * @event controller_action_postdispatch_checkout_onepage_saveShippingMethod
82
+ * |controller_action_postdispatch_onestepcheckout_index_index
83
+ *
84
+ * @observer tig_myparcel_save_pg_address
85
+ */
86
+ public function savePgAddress(Varien_Event_Observer $observer)
87
+ {
88
+ /**
89
+ * Check if the MyParcel extension is enabled.
90
+ */
91
+ if (!Mage::helper('tig_myparcel')->isEnabled()) {
92
+ return $this;
93
+ }
94
+
95
+ /**
96
+ * @var Mage_Core_Controller_Varien_Front $controller
97
+ *
98
+ * Get the selected PG address from the controller if available.
99
+ */
100
+ $controller = $observer->getControllerAction();
101
+ $pgAddressData = $controller->getRequest()->getParam('tig_myparcel_pg_address', array());
102
+
103
+ /**
104
+ * Delete any existing pakjeGemak addresses.
105
+ */
106
+ $this->_removePgAddress();
107
+ if (!$this->_isAddressEmpty($pgAddressData)) {
108
+ /**
109
+ * Save the selected address.
110
+ */
111
+ $this->_savePgAddress($pgAddressData);
112
+ }
113
+
114
+ return $this;
115
+ }
116
+
117
+ /**
118
+ * Copies a PakjeGemak address from the quote to the newly placed order.
119
+ *
120
+ * @param Varien_Event_Observer $observer
121
+ *
122
+ * @return $this
123
+ *
124
+ * @throws Exception
125
+ */
126
+ public function copyAddressToOrder(Varien_Event_Observer $observer)
127
+ {
128
+ /**
129
+ * @var Mage_Sales_Model_Order $order
130
+ */
131
+ $order = $observer->getOrder();
132
+ $helper = Mage::helper('tig_myparcel');
133
+
134
+ /**
135
+ * @var Mage_Sales_Model_Quote $quote
136
+ */
137
+ $quote = Mage::getModel('sales/quote')->load($order->getQuoteId());
138
+ if (!$quote || !$quote->getId()) {
139
+ $quote = $order->getQuote();
140
+ }
141
+
142
+ if (!$quote || !$quote->getId()) {
143
+ return $this;
144
+ }
145
+
146
+ $this->setQuote($quote);
147
+
148
+ /**
149
+ * Check if the order is shipped using MyParcel.
150
+ */
151
+ $shippingMethod = $order->getShippingMethod();
152
+ if (!$helper->shippingMethodIsMyParcel($shippingMethod)) {
153
+ $this->_removePgAddress();
154
+ return $this;
155
+ }
156
+
157
+ /**
158
+ * Get the PakjeGemak address for this quote.
159
+ */
160
+ $pakjeGemakAddress = $helper->getPgAddress($quote);
161
+
162
+ /**
163
+ * If no PakjeGemak address was found we don't need to do anything else.
164
+ */
165
+ if (!$pakjeGemakAddress) {
166
+ return $this;
167
+ }
168
+
169
+ $this->_copyAddressToOrder($order, $pakjeGemakAddress);
170
+ return $this;
171
+ }
172
+
173
+ /**
174
+ * Check if an array is considered empty.
175
+ *
176
+ * @param array $pgAddressData
177
+ *
178
+ * @return bool
179
+ */
180
+ protected function _isAddressEmpty($pgAddressData)
181
+ {
182
+ foreach ($pgAddressData as $key => $value) {
183
+ /**
184
+ * If the value is an array, check recursively if the value is empty and continue with the next item.
185
+ */
186
+ if (is_array($value)) {
187
+ $isEmpty = $this->_isAddressEmpty($value);
188
+ if (!$isEmpty) {
189
+ return false;
190
+ }
191
+
192
+ continue;
193
+ }
194
+
195
+ /**
196
+ * Check if the value is empty or contains a single dash.
197
+ */
198
+ if (!empty($value) && $value !== '-') {
199
+ return false;
200
+ }
201
+ }
202
+
203
+ return true;
204
+ }
205
+
206
+ /**
207
+ * Removes a PakjeGemak address from the quote.
208
+ *
209
+ * @return $this
210
+ *
211
+ * @throws Exception
212
+ */
213
+ protected function _removePgAddress()
214
+ {
215
+ $quote = $this->getQuote();
216
+
217
+ /**
218
+ * Get the PakjeGemak address if it exists.
219
+ */
220
+ $pgAddress = Mage::helper('tig_myparcel')->getPgAddress($quote);
221
+ if (!$pgAddress) {
222
+ return $this;
223
+ }
224
+
225
+ /**
226
+ * Delete the address.
227
+ */
228
+ $pgAddress->delete();
229
+ return $this;
230
+ }
231
+
232
+ /**
233
+ * Saves or updates a PakjeGemak address for the quote.
234
+ *
235
+ * @param array $pgAddressData
236
+ *
237
+ * @return $this
238
+ *
239
+ * @throws Exception
240
+ */
241
+ protected function _savePgAddress($pgAddressData)
242
+ {
243
+ $helper = Mage::helper('tig_myparcel');
244
+ $quote = $this->getQuote();
245
+
246
+ /**
247
+ * Check if the quote's shipping method is MyParcel.
248
+ */
249
+ $shippingMethod = $quote->getShippingAddress()->getShippingMethod();
250
+ if (!$helper->shippingMethodIsMyParcel($shippingMethod)) {
251
+ return $this;
252
+ }
253
+
254
+ /**
255
+ * Create a new address and add the address data.
256
+ */
257
+ $pgAddress = Mage::getModel('sales/quote_address');
258
+ $pgAddress->setAddressType($helper::PG_ADDRESS_TYPE)
259
+ ->setCity($pgAddressData['city'])
260
+ ->setCountryId($pgAddressData['country_id'])
261
+ ->setPostcode($pgAddressData['postcode'])
262
+ ->setCompany($pgAddressData['company'])
263
+ ->setFirstname('-')
264
+ ->setLastname('-')
265
+ ->setTelephone($pgAddressData['telephone'])
266
+ ->setStreet($pgAddressData['street']);
267
+
268
+ /**
269
+ * Add the address to the quote and save the quote.
270
+ */
271
+ $quote->addAddress($pgAddress)
272
+ ->save();
273
+
274
+ /**
275
+ * Save the address.
276
+ * This should not be required, but we've encountered a few cases where this was not done automatically by
277
+ * saving the quote.
278
+ */
279
+ $pgAddress->save();
280
+
281
+ /**
282
+ * If this quote has been deactivated, check if it has an order.
283
+ *
284
+ * This is required for OneStepCheckout.
285
+ */
286
+ if (!$quote->getIsActive()) {
287
+ /**
288
+ * @var Mage_Sales_Model_Order $order
289
+ */
290
+ $order = Mage::getModel('sales/order')->load($quote->getId(), 'quote_id');
291
+ if ($order && $order->getId()) {
292
+ /**
293
+ * Save the PakjeGemak address to the order.
294
+ */
295
+ $this->_copyAddressToOrder($order, $pgAddress);
296
+ }
297
+ }
298
+
299
+ return $this;
300
+ }
301
+
302
+ /**
303
+ * Copies a given address to the order.
304
+ *
305
+ * @param Mage_Sales_Model_Order $order
306
+ * @param Mage_Sales_Model_Quote_Address $address
307
+ *
308
+ * @return $this
309
+ *
310
+ * @throws Exception
311
+ */
312
+ protected function _copyAddressToOrder(Mage_Sales_Model_Order $order, Mage_Sales_Model_Quote_Address $address)
313
+ {
314
+ /**
315
+ * Convert the quote address to an order address and add it to the order.
316
+ */
317
+ $orderAddress = Mage::getModel('sales/convert_quote')->addressToOrderAddress($address);
318
+
319
+ $order->addAddress($orderAddress)
320
+ ->save();
321
+
322
+ /**
323
+ * This is a fix for the order address missing a parent ID.
324
+ */
325
+ if (!$orderAddress->getParentId()) {
326
+ $orderAddress->setParentId($order->getId());
327
+ }
328
+
329
+ /**
330
+ * This is required for some PSP extensions which will not save the PakjeGemak address otherwise.
331
+ */
332
+ $orderAddress->save();
333
+
334
+ return $this;
335
+ }
336
+
337
+ /**
338
+ * Validates an address and returns the validated data.
339
+ *
340
+ * @param array $address
341
+ *
342
+ * @return array
343
+ *
344
+ * @throws TIG_MyParcel2014_Exception
345
+ */
346
+ protected function _validateAddress($address)
347
+ {
348
+ if (!isset($address['city'])
349
+ || !isset($address['country_id'])
350
+ || !isset($address['street'])
351
+ || !is_array($address['street'])
352
+ || !isset($address['postcode'])
353
+ || !isset($address['company'])
354
+ ) {
355
+ throw new TIG_MyParcel2014_Exception(
356
+ Mage::helper('tig_myparcel')->__(
357
+ 'Invalid argument supplied. A valid PakjeGemak address must contain at least a company name, city, '
358
+ . 'country code, street and zipcode.'
359
+ ),
360
+ 'MYPA-0015'
361
+ );
362
+ }
363
+
364
+ $city = $address['city'];
365
+ $countryCode = $address['country_id'];
366
+ $street = $address['street'][1];
367
+ $houseNumber = $address['street'][2];
368
+ $postcode = str_replace(' ', '', $address['postcode']);
369
+ $name = $address['company'];
370
+
371
+ $countryCodes = Mage::getResourceModel('directory/country_collection')->getColumnValues('iso2_code');
372
+
373
+ $cityValidator = new Zend_Validate_Regex(array('pattern' => self::CITY_NAME_REGEX));
374
+ $countryCodeValidator = new Zend_Validate_InArray(array('haystack' => $countryCodes));
375
+ $streetValidator = new Zend_Validate_Regex(array('pattern' => self::STREET_NAME_REGEX));
376
+ $housenumberValidator = new Zend_Validate_Digits();
377
+ $postcodeValidator = new Zend_Validate_PostCode('nl_NL');
378
+ $nameValidator = new Zend_Validate_Regex(array('pattern' => self::NAME_REGEX));
379
+
380
+ if (!$cityValidator->isValid($city)
381
+ || !$countryCodeValidator->isValid($countryCode)
382
+ || !$streetValidator->isValid($street)
383
+ || !$housenumberValidator->isValid($houseNumber)
384
+ || !$postcodeValidator->isValid($postcode)
385
+ || !$nameValidator->isValid($name)
386
+ ) {
387
+ throw new TIG_MyParcel2014_Exception(
388
+ Mage::helper('tig_myparcel')->__('Invalid PakjeGemak address.'),
389
+ 'MYPA-0016'
390
+ );
391
+ }
392
+
393
+ $data = array(
394
+ 'city' => $city,
395
+ 'countryCode' => $countryCode,
396
+ 'street' => array(
397
+ 1 => $street,
398
+ 2 => $houseNumber,
399
+ 3 => '',
400
+ ),
401
+ 'postcode' => $postcode,
402
+ 'name' => $name,
403
+ 'telephone' => '-'
404
+ );
405
+
406
+ if (isset($address['telephone']) && !empty($address['telephone'])) {
407
+ $phoneNumber = $address['telephone'];
408
+ $phoneNumber = str_replace(array('-', ' '), '', $phoneNumber);
409
+ $phoneNumberValidator = new Zend_Validate_Regex(array('pattern' => self::PHONE_NUMBER_REGEX));
410
+
411
+ if (!$phoneNumberValidator->isValid($phoneNumber)) {
412
+ throw new TIG_MyParcel2014_Exception(
413
+ Mage::helper('tig_myparcel')->__('Invalid phone number.'),
414
+ 'MYPA-0017'
415
+ );
416
+ }
417
+
418
+ $data['telephone'] = $phoneNumber;
419
+ }
420
+
421
+ if (!isset($address['street'][3])) {
422
+ return $data;
423
+ }
424
+
425
+ $houseNumberExtension = $address['street'][3];
426
+
427
+ $houseNumberExtensionValidator = new Zend_Validate_Regex(array('pattern' => self::HOUSENR_EXT_REGEX));
428
+
429
+ if (!$houseNumberExtensionValidator->isValid($houseNumberExtension)) {
430
+ throw new TIG_MyParcel2014_Exception(
431
+ Mage::helper('tig_myparcel')->__('Invalid housenumber extension.'),
432
+ 'MYPA-0018'
433
+ );
434
+ }
435
+
436
+ $data['street'][3] = $houseNumberExtension;
437
+
438
+ return $data;
439
+ }
440
+ }
app/code/community/TIG/MyParcel2014/Model/Observer/SaveShipment.php ADDED
@@ -0,0 +1,90 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class TIG_MyParcel2014_Model_Observer_SaveShipment
4
+ {
5
+ /**
6
+ * @param Varien_Event_Observer $observer
7
+ * @return $this
8
+ * @event controller_action_predispatch_adminhtml_sales_order_shipment_save
9
+ * @observer tig_myparcel_shipment_save
10
+ */
11
+ public function registerConsignmentOption(Varien_Event_Observer $observer)
12
+ {
13
+ if (!Mage::helper('tig_myparcel')->isEnabled()) {
14
+ return $this;
15
+ }
16
+
17
+ /**
18
+ * Retrieve and register the chosen option, if any.
19
+ *
20
+ * @var Mage_Core_Controller_Varien_Front $controller
21
+ */
22
+ $controller = $observer->getControllerAction();
23
+ $selectedConsignmentOptions = $controller->getRequest()->getParam('tig_myparcel');
24
+
25
+ /**
26
+ * Add the selected options to the registry.
27
+ *
28
+ * This registry value will be checked when the MyParcel shipment entity is saved.
29
+ */
30
+ if (!empty($selectedConsignmentOptions)) {
31
+ Mage::register('tig_myparcel_consignment_options', $selectedConsignmentOptions);
32
+ }
33
+
34
+ return $this;
35
+ }
36
+
37
+ /**
38
+ * Saves the chosen consignment options and creates a MyParcel shipment for the current shipment.
39
+ *
40
+ * @param Varien_Event_Observer $observer
41
+ *
42
+ * @return $this
43
+ * @throws Exception
44
+ * @event sales_order_shipment_save_after
45
+ * @observer tig_myparcel_shipment_save_after
46
+ */
47
+ public function saveConsignmentOption(Varien_Event_Observer $observer)
48
+ {
49
+ $helper = Mage::helper('tig_myparcel');
50
+
51
+ /**
52
+ * check if extension is enabled
53
+ */
54
+ if (!$helper->isEnabled()) {
55
+ return $this;
56
+ }
57
+
58
+ /**
59
+ * @var Mage_Sales_Model_Order_Shipment $shipment
60
+ */
61
+ $shipment = $observer->getShipment();
62
+
63
+ /**
64
+ * check if order is placed with Myparcel
65
+ */
66
+ $shippingMethod = $shipment->getOrder()->getShippingMethod();
67
+ if (!$helper->shippingMethodIsMyParcel($shippingMethod)) {
68
+ return $this;
69
+ }
70
+
71
+ /**
72
+ * check if the current shipment already has a myparcel shipment
73
+ */
74
+ if($helper->hasMyParcelShipment($shipment->getId())){
75
+ return $this;
76
+ }
77
+
78
+ /**
79
+ * @var TIG_MyParcel2014_Model_Shipment $myParcelShipment
80
+ */
81
+ $myParcelShipment = Mage::getModel('tig_myparcel/shipment')->load($shipment->getId());
82
+ $myParcelShipment->setShipmentId($shipment->getId())
83
+ ->setConsignmentOptions()
84
+ ->createConsignment()
85
+ ->save();
86
+
87
+ return $this;
88
+ }
89
+
90
+ }
app/code/community/TIG/MyParcel2014/Model/Resource/Order/Grid/Collection.php ADDED
@@ -0,0 +1,97 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * ___________ __ __
4
+ * \__ ___/____ _/ |_ _____ | |
5
+ * | | / _ \\ __\\__ \ | |
6
+ * | | | |_| || | / __ \_| |__
7
+ * |____| \____/ |__| (____ /|____/
8
+ * \/
9
+ * ___ __ __
10
+ * | | ____ _/ |_ ____ _______ ____ ____ _/ |_
11
+ * | | / \\ __\_/ __ \\_ __ \ / \ _/ __ \\ __\
12
+ * | || | \| | \ ___/ | | \/| | \\ ___/ | |
13
+ * |___||___| /|__| \_____>|__| |___| / \_____>|__|
14
+ * \/ \/
15
+ * ________
16
+ * / _____/_______ ____ __ __ ______
17
+ * / \ ___\_ __ \ / _ \ | | \\____ \
18
+ * \ \_\ \| | \/| |_| || | /| |_| |
19
+ * \______ /|__| \____/ |____/ | __/
20
+ * \/ |__|
21
+ *
22
+ * NOTICE OF LICENSE
23
+ *
24
+ * This source file is subject to the Creative Commons License.
25
+ * It is available through the world-wide-web at this URL:
26
+ * http://creativecommons.org/licenses/by-nc-nd/3.0/nl/deed.en_US
27
+ * If you are unable to obtain it through the world-wide-web, please send an email
28
+ * to servicedesk@tig.nl so we can send you a copy immediately.
29
+ *
30
+ * DISCLAIMER
31
+ *
32
+ * Do not edit or add to this file if you wish to upgrade this module to newer
33
+ * versions in the future. If you wish to customize this module for your
34
+ * needs please contact servicedesk@tig.nl for more information.
35
+ *
36
+ * @copyright Copyright (c) 2014 Total Internet Group B.V. (http://www.totalinternetgroup.nl)
37
+ * @license http://creativecommons.org/licenses/by-nc-nd/3.0/nl/deed.en_US
38
+ */
39
+ class TIG_MyParcel2014_Model_Resource_Order_Grid_Collection extends Mage_Sales_Model_Resource_Order_Grid_Collection
40
+ {
41
+ /**
42
+ * Fix for grid pager count believing there is only 1 item when $collection->getSelect()->groupBy() has been used
43
+ *
44
+ * @see Mage_Core_Model_Resource_Db_Collection_Abstract::getSelectCountSql()
45
+ *
46
+ * @return Zend_Db_Select
47
+ */
48
+ public function getSelectCountSql()
49
+ {
50
+ $this->_renderFilters();
51
+
52
+ $countSelect = clone $this->getSelect();
53
+ $countSelect->reset(Zend_Db_Select::ORDER);
54
+ $countSelect->reset(Zend_Db_Select::LIMIT_COUNT);
55
+ $countSelect->reset(Zend_Db_Select::LIMIT_OFFSET);
56
+ $countSelect->reset(Zend_Db_Select::COLUMNS);
57
+
58
+ if(count($this->getSelect()->getPart(Zend_Db_Select::GROUP)) > 0) {
59
+ $countSelect->reset(Zend_Db_Select::GROUP);
60
+ $countSelect->distinct(true);
61
+ $group = $this->getSelect()->getPart(Zend_Db_Select::GROUP);
62
+ $countSelect->columns("COUNT(DISTINCT ".implode(", ", $group).")");
63
+ } else {
64
+ $countSelect->columns('COUNT(*)');
65
+ }
66
+ return $countSelect;
67
+ }
68
+
69
+ /**
70
+ * Fix for getSize not re-counting the number of records in a collection after clear() had been called
71
+ *
72
+ * @return $this
73
+ */
74
+ public function clear()
75
+ {
76
+ $this->_setIsLoaded(false);
77
+ $this->_totalRecords = null;
78
+
79
+ $this->_items = array();
80
+ return $this;
81
+ }
82
+
83
+ /**
84
+ * Replace the select by a given select object.
85
+ * This effectively copies another collection (not entirely, but close enough for our purposes).
86
+ *
87
+ * @param Varien_db_Select $select
88
+ *
89
+ * @return $this
90
+ */
91
+ public function setSelect($select)
92
+ {
93
+ $this->_select = $select;
94
+
95
+ return $this;
96
+ }
97
+ }
app/code/community/TIG/MyParcel2014/Model/Resource/Setup.php ADDED
@@ -0,0 +1,91 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * ___________ __ __
4
+ * \__ ___/____ _/ |_ _____ | |
5
+ * | | / _ \\ __\\__ \ | |
6
+ * | | | |_| || | / __ \_| |__
7
+ * |____| \____/ |__| (____ /|____/
8
+ * \/
9
+ * ___ __ __
10
+ * | | ____ _/ |_ ____ _______ ____ ____ _/ |_
11
+ * | | / \\ __\_/ __ \\_ __ \ / \ _/ __ \\ __\
12
+ * | || | \| | \ ___/ | | \/| | \\ ___/ | |
13
+ * |___||___| /|__| \_____>|__| |___| / \_____>|__|
14
+ * \/ \/
15
+ * ________
16
+ * / _____/_______ ____ __ __ ______
17
+ * / \ ___\_ __ \ / _ \ | | \\____ \
18
+ * \ \_\ \| | \/| |_| || | /| |_| |
19
+ * \______ /|__| \____/ |____/ | __/
20
+ * \/ |__|
21
+ *
22
+ * NOTICE OF LICENSE
23
+ *
24
+ * This source file is subject to the Creative Commons License.
25
+ * It is available through the world-wide-web at this URL:
26
+ * http://creativecommons.org/licenses/by-nc-nd/3.0/nl/deed.en_US
27
+ * If you are unable to obtain it through the world-wide-web, please send an email
28
+ * to servicedesk@tig.nl so we can send you a copy immediately.
29
+ *
30
+ * DISCLAIMER
31
+ *
32
+ * Do not edit or add to this file if you wish to upgrade this module to newer
33
+ * versions in the future. If you wish to customize this module for your
34
+ * needs please contact servicedesk@tig.nl for more information.
35
+ *
36
+ * @copyright Copyright (c) 2014 Total Internet Group B.V. (http://www.totalinternetgroup.nl)
37
+ * @license http://creativecommons.org/licenses/by-nc-nd/3.0/nl/deed.en_US
38
+ */
39
+ class TIG_MyParcel2014_Model_Resource_Setup extends Mage_Catalog_Model_Resource_Setup
40
+ {
41
+ /**
42
+ * Cron expression and cron model definitions for statistics update cron
43
+ */
44
+ const UPDATE_STATISTICS_CRON_STRING_PATH = 'crontab/jobs/tig_myparcel_check_status/schedule/cron_expr';
45
+ const UPDATE_STATISTICS_CRON_MODEL_PATH = 'crontab/jobs/tig_myparcel_check_status/run/model';
46
+
47
+ /**
48
+ * Generates a semi-random cron expression for the update statistics cron. This is done to spread out the number of
49
+ * calls across each day.
50
+ *
51
+ * @throws TIG_MyParcel2014_Exception
52
+ *
53
+ * @return $this
54
+ */
55
+ public function generateCheckStatusExpr()
56
+ {
57
+ /**
58
+ * Generate random minute for the cron expression
59
+ */
60
+ $cronMinute = mt_rand(0, 59);
61
+
62
+ /**
63
+ * Generate a cron expr that runs on a specified minute on a specified hour twice per day.
64
+ */
65
+ $cronExpr = "{$cronMinute} */6 * * *";
66
+
67
+ /**
68
+ * Store the cron expression in core_config_data
69
+ */
70
+ try {
71
+ Mage::getModel('core/config_data')
72
+ ->load(self::UPDATE_STATISTICS_CRON_STRING_PATH, 'path')
73
+ ->setValue($cronExpr)
74
+ ->setPath(self::UPDATE_STATISTICS_CRON_STRING_PATH)
75
+ ->save();
76
+ Mage::getModel('core/config_data')
77
+ ->load(self::UPDATE_STATISTICS_CRON_MODEL_PATH, 'path')
78
+ ->setValue((string) Mage::getConfig()->getNode(self::UPDATE_STATISTICS_CRON_MODEL_PATH))
79
+ ->setPath(self::UPDATE_STATISTICS_CRON_MODEL_PATH)
80
+ ->save();
81
+ } catch (Exception $e) {
82
+ throw new TIG_MyParcel2014_Exception(
83
+ Mage::helper('tig_myparcel')->__('Unable to save check_status cron expression: %s', $cronExpr),
84
+ 'MYPA-0022',
85
+ $e
86
+ );
87
+ }
88
+
89
+ return $this;
90
+ }
91
+ }
app/code/community/TIG/MyParcel2014/Model/Resource/Shipment.php ADDED
@@ -0,0 +1,30 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class TIG_MyParcel2014_Model_Resource_Shipment extends Mage_Core_Model_Resource_Db_Abstract
4
+ {
5
+ public function _construct()
6
+ {
7
+ $this->_init('tig_myparcel/shipment','entity_id');
8
+ }
9
+
10
+ /**
11
+ * Prepare data for save.
12
+ *
13
+ * @param Mage_Core_Model_Abstract $object
14
+ *
15
+ * @return array
16
+ */
17
+ protected function _prepareDataForSave(Mage_Core_Model_Abstract $object)
18
+ {
19
+ $currentTime = Varien_Date::now();
20
+ if ((!$object->getId() || $object->isObjectNew()) && !$object->getCreatedAt()) {
21
+ $object->setCreatedAt($currentTime);
22
+ }
23
+
24
+ $object->setUpdatedAt($currentTime);
25
+
26
+ $data = parent::_prepareDataForSave($object);
27
+
28
+ return $data;
29
+ }
30
+ }
app/code/community/TIG/MyParcel2014/Model/Resource/Shipment/Collection.php ADDED
@@ -0,0 +1,9 @@
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class TIG_MyParcel2014_Model_Resource_Shipment_Collection extends Mage_Core_Model_Resource_Db_Collection_Abstract
4
+ {
5
+ public function _construct()
6
+ {
7
+ $this->_init('tig_myparcel/shipment');
8
+ }
9
+ }
app/code/community/TIG/MyParcel2014/Model/Shipment.php ADDED
@@ -0,0 +1,606 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * ___________ __ __
4
+ * \__ ___/____ _/ |_ _____ | |
5
+ * | | / _ \\ __\\__ \ | |
6
+ * | | | |_| || | / __ \_| |__
7
+ * |____| \____/ |__| (____ /|____/
8
+ * \/
9
+ * ___ __ __
10
+ * | | ____ _/ |_ ____ _______ ____ ____ _/ |_
11
+ * | | / \\ __\_/ __ \\_ __ \ / \ _/ __ \\ __\
12
+ * | || | \| | \ ___/ | | \/| | \\ ___/ | |
13
+ * |___||___| /|__| \_____>|__| |___| / \_____>|__|
14
+ * \/ \/
15
+ * ________
16
+ * / _____/_______ ____ __ __ ______
17
+ * / \ ___\_ __ \ / _ \ | | \\____ \
18
+ * \ \_\ \| | \/| |_| || | /| |_| |
19
+ * \______ /|__| \____/ |____/ | __/
20
+ * \/ |__|
21
+ *
22
+ * NOTICE OF LICENSE
23
+ *
24
+ * This source file is subject to the Creative Commons License.
25
+ * It is available through the world-wide-web at this URL:
26
+ * http://creativecommons.org/licenses/by-nc-nd/3.0/nl/deed.en_US
27
+ * If you are unable to obtain it through the world-wide-web, please send an email
28
+ * to servicedesk@tig.nl so we can send you a copy immediately.
29
+ *
30
+ * DISCLAIMER
31
+ *
32
+ * Do not edit or add to this file if you wish to upgrade this module to newer
33
+ * versions in the future. If you wish to customize this module for your
34
+ * needs please contact servicedesk@tig.nl for more information.
35
+ *
36
+ * @copyright Copyright (c) 2014 Total Internet Group B.V. (http://www.tig.nl)
37
+ * @license http://creativecommons.org/licenses/by-nc-nd/3.0/nl/deed.en_US
38
+ *
39
+ * @method boolean hasShipmentId()
40
+ * @method boolean hasOrderId()
41
+ * @method boolean hasConsignmentId()
42
+ * @method boolean hasCreatedAt()
43
+ * @method boolean hasUpdatedAt()
44
+ * @method boolean hasStatus()
45
+ * @method boolean hasBarcode()
46
+ * @method boolean hasIsFinal()
47
+ * @method boolean hasShipment()
48
+ * @method boolean hasOrder()
49
+ * @method boolean hasShippingAddress()
50
+ * @method boolean hasApi()
51
+ * @method boolean hasShipmentIncrementId()
52
+ * @method boolean hasBarcodeSend()
53
+ *
54
+ * @method string getShipmentId()
55
+ * @method string getConsignmentId()
56
+ * @method string getCreatedAt()
57
+ * @method string getUpdatedAt()
58
+ * @method string getStatus()
59
+ * @method string getBarcode()
60
+ * @method string getIsFinal()
61
+ * @method int getHomeAddressOnly()
62
+ * @method int getSignatureOnReceipt()
63
+ * @method int getReturnIfNoAnswer()
64
+ * @method int getInsured()
65
+ * @method int getInsuredAmount()
66
+ * @method int getBarcodeSend()
67
+ * @method int getCustomsContentType()
68
+ *
69
+ * @method TIG_MyParcel2014_Model_Shipment setShipmentId(int $value)
70
+ * @method TIG_MyParcel2014_Model_Shipment setOrderId(int $value)
71
+ * @method TIG_MyParcel2014_Model_Shipment setConsignmentId(int $value)
72
+ * @method TIG_MyParcel2014_Model_Shipment setCreatedAt(string $value)
73
+ * @method TIG_MyParcel2014_Model_Shipment setUpdatedAt(string $value)
74
+ * @method TIG_MyParcel2014_Model_Shipment setStatus(string $value)
75
+ * @method TIG_MyParcel2014_Model_Shipment setBarcode(string $value)
76
+ * @method TIG_MyParcel2014_Model_Shipment setIsFinal(int $value)
77
+ * @method TIG_MyParcel2014_Model_Shipment setShipment(Mage_Sales_Model_Order_Shipment $value)
78
+ * @method TIG_MyParcel2014_Model_Shipment setOrder(Mage_Sales_Model_Order $value)
79
+ * @method TIG_MyParcel2014_Model_Shipment setShippingAddress(Mage_Sales_Model_Order_Address $value)
80
+ * @method TIG_MyParcel2014_Model_Shipment setApi(TIG_MyParcel2014_Model_Api_MyParcel $value)
81
+ * @method TIG_MyParcel2014_Model_Shipment setShipmentIncrementId(string $value)
82
+ * @method TIG_MyParcel2014_Model_Shipment setBarcodeSend(int $value)
83
+ * @method TIG_MyParcel2014_Model_Shipment setRetourlink(string $value)
84
+ * @method TIG_MyParcel2014_Model_Shipment setIsCredit(int $value)
85
+ * @method TIG_MyParcel2014_Model_Shipment setCustomsContentType(int $value)
86
+ *
87
+ */
88
+ class TIG_MyParcel2014_Model_Shipment extends Mage_Core_Model_Abstract
89
+ {
90
+ /**
91
+ * Carrier code used by MyParcel.
92
+ */
93
+ const MYPARCEL_CARRIER_CODE = 'myparcel';
94
+
95
+ /**
96
+ * Statusses used by MyParcel shipments.
97
+ */
98
+ const STATUS_NEW = 'new';
99
+ const STATUS_CONFIRMED = 'Aangemeld';
100
+
101
+ /**
102
+ * Initialize the shipment
103
+ */
104
+ public function _construct()
105
+ {
106
+ $this->_init('tig_myparcel/shipment');
107
+ }
108
+
109
+ /**
110
+ * Gets the Magento shipment associated with this MyParcel shipment.
111
+ *
112
+ * @return Mage_Sales_Model_Order_Shipment
113
+ */
114
+ public function getShipment()
115
+ {
116
+ if ($this->hasShipment()) {
117
+ return $this->_getData('shipment');
118
+ }
119
+
120
+ /**
121
+ * @var Mage_Sales_Model_Order_Shipment $shipment
122
+ */
123
+ $shipmentId = $this->getShipmentId();
124
+ $shipment = Mage::getModel('sales/order_shipment')->load($shipmentId);
125
+
126
+ $this->setShipment($shipment);
127
+ return $shipment;
128
+ }
129
+
130
+ /**
131
+ * Gets this shipment's order ID.
132
+ *
133
+ * @return mixed
134
+ */
135
+ public function getOrderId()
136
+ {
137
+ if ($this->hasOrderId()) {
138
+ return $this->_getData('order_id');
139
+ }
140
+
141
+ $orderId = $this->getShipment()->getOrderId();
142
+
143
+ $this->setOrderId($orderId);
144
+ return $orderId;
145
+ }
146
+
147
+ /**
148
+ * Gets the Magento order associated with this MyParcel shipment.
149
+ *
150
+ * @return Mage_Sales_Model_Order
151
+ */
152
+ public function getOrder()
153
+ {
154
+ if ($this->hasOrder()) {
155
+ return $this->_getData('order');
156
+ }
157
+
158
+ /**
159
+ * @var Mage_Sales_Model_Order $order
160
+ */
161
+ $orderId = $this->getOrderId();
162
+ $order = Mage::getModel('sales/order')->load($orderId);
163
+
164
+ $this->setOrder($order);
165
+ return $order;
166
+ }
167
+
168
+ /**
169
+ * Gets the shipping address of this shipment.
170
+ *
171
+ * @return Mage_Sales_Model_Order_Address
172
+ */
173
+ public function getShippingAddress()
174
+ {
175
+ if ($this->hasShippingAddress()) {
176
+ return $this->_getData('shipping_address');
177
+ }
178
+
179
+ $shipment = $this->getShipment();
180
+ $shippingAddress = $shipment->getShippingAddress();
181
+
182
+ $this->setShippingAddress($shippingAddress);
183
+ return $shippingAddress;
184
+ }
185
+
186
+ /**
187
+ * Gets the increment ID of this shipment's Magento shipment if available.
188
+ *
189
+ * @return null|string
190
+ */
191
+ public function getShipmentIncrementId()
192
+ {
193
+ if ($this->hasShipmentIncrementId()) {
194
+ return $this->_getData('shipment_increment_id');
195
+ }
196
+
197
+ $shipment = $this->getShipment(false);
198
+ if (!$shipment || !$shipment->getIncrementId()) {
199
+ return null;
200
+ }
201
+
202
+ $incrementId = $shipment->getIncrementId();
203
+
204
+ $this->setShipmentIncrementId($incrementId);
205
+ return $incrementId;
206
+ }
207
+
208
+ /**
209
+ * Calculates a shipment's base grand total based on it's shipment items
210
+ *
211
+ * @return float|null
212
+ */
213
+ public function getOrderTotal()
214
+ {
215
+ /**
216
+ * Check if this MyParcel shipment has a linked Mage_Sales_Model_Order_Shipment object
217
+ */
218
+ $shipment = $this->getShipment();
219
+ if (!$shipment) {
220
+ return null;
221
+ }
222
+
223
+ /**
224
+ * Loop through all associated shipment items and add each item's row total to the shipment's total
225
+ */
226
+ $baseGrandTotal = 0;
227
+ $shipmentItems = $shipment->getAllItems();
228
+
229
+ /**
230
+ * @var Mage_Sales_Model_Order_Shipment_Item $shipmentItem
231
+ */
232
+ foreach ($shipmentItems as $shipmentItem) {
233
+ $qty = $shipmentItem->getQty();
234
+
235
+ /**
236
+ * The base price of a shipment item is only available through it's associated order item
237
+ */
238
+ $basePrice = $shipmentItem->getOrderItem()->getBasePrice();
239
+
240
+ /**
241
+ * Calculate and add the shipment item's row total
242
+ */
243
+ $totalBasePrice = $basePrice * $qty;
244
+ $baseGrandTotal += $totalBasePrice;
245
+ }
246
+ return $baseGrandTotal;
247
+ }
248
+
249
+ /**
250
+ * Gets the MyParcel API object.
251
+ *
252
+ * @return TIG_MyParcel2014_Model_Api_MyParcel
253
+ */
254
+ public function getApi()
255
+ {
256
+ if ($this->hasApi()) {
257
+ return $this->_getData('api');
258
+ }
259
+
260
+ $storeId = $this->getShipment()->getStoreId();
261
+ $api = Mage::getModel('tig_myparcel/api_myParcel',array('store_id' => $storeId));
262
+
263
+ $this->setApi($api);
264
+ return $api;
265
+ }
266
+
267
+ /**
268
+ * @return array
269
+ */
270
+ public function getHomeAddressOnlyOption()
271
+ {
272
+ $consignmentOption = 'home_address_only';
273
+
274
+ $helper = Mage::helper('tig_myparcel');
275
+ $storeId = $this->getOrder()->getStoreId();
276
+ $orderTotalShipped = $this->getOrderTotal();
277
+
278
+ $configValue = $helper->getConfig($consignmentOption,'shipment',$storeId);
279
+ if(!empty($configValue) && $configValue > 0){
280
+ if($orderTotalShipped >= $configValue){
281
+ return array(
282
+ 'option' => $consignmentOption,
283
+ 'selected' => 1,
284
+ );
285
+ }
286
+ }
287
+ return array(
288
+ 'option' => $consignmentOption,
289
+ 'selected' => 0,
290
+ );
291
+
292
+ }
293
+
294
+ /**
295
+ * @return array
296
+ */
297
+ public function getSignatureOnReceiptOption()
298
+ {
299
+ $consignmentOption = 'signature_on_receipt';
300
+
301
+ $helper = Mage::helper('tig_myparcel');
302
+ $storeId = $this->getOrder()->getStoreId();
303
+ $orderTotalShipped = $this->getOrderTotal();
304
+
305
+ $configValue = $helper->getConfig($consignmentOption,'shipment',$storeId);
306
+ if(!empty($configValue) && $configValue > 0){
307
+ if($orderTotalShipped >= $configValue){
308
+ return array(
309
+ 'option' => $consignmentOption,
310
+ 'selected' => 1,
311
+ );
312
+ }
313
+ }
314
+ return array(
315
+ 'option' => $consignmentOption,
316
+ 'selected' => 0,
317
+ );
318
+ }
319
+
320
+ /**
321
+ * @return array
322
+ */
323
+ public function getReturnIfNoAnswerOption()
324
+ {
325
+ $consignmentOption = 'return_if_no_answer';
326
+
327
+ $helper = Mage::helper('tig_myparcel');
328
+ $storeId = $this->getOrder()->getStoreId();
329
+ $orderTotalShipped = $this->getOrderTotal();
330
+
331
+ $configValue = $helper->getConfig($consignmentOption,'shipment',$storeId);
332
+ if(!empty($configValue) && $configValue > 0){
333
+ if($orderTotalShipped >= $configValue){
334
+ return array(
335
+ 'option' => $consignmentOption,
336
+ 'selected' => 1,
337
+ );
338
+ }
339
+ }
340
+ return array(
341
+ 'option' => $consignmentOption,
342
+ 'selected' => 0,
343
+ );
344
+ }
345
+
346
+ /**
347
+ * @return array
348
+ */
349
+ public function getInsuredOption()
350
+ {
351
+ $helper = Mage::helper('tig_myparcel');
352
+ $storeId = $this->getOrderStoreId();
353
+ $orderTotalShipped = $this->getOrderTotal();
354
+ $insuredType = 'insured_50';
355
+ if($orderTotalShipped > 50 && $orderTotalShipped < 250){
356
+ $insuredType = 'insured_250';
357
+ }elseif($orderTotalShipped > 250){
358
+ $insuredType = 'insured_500';
359
+ }
360
+
361
+ $configValue = $helper->getConfig($insuredType,'shipment',$storeId);
362
+ if(!empty($configValue) && $configValue > 0){
363
+ if($orderTotalShipped < $configValue){
364
+ return array(
365
+ 'option' => 'insured',
366
+ 'selected' => 1,
367
+ 'insured_amount' => $configValue,
368
+ );
369
+ }
370
+ }
371
+
372
+ return array(
373
+ 'option' => 'insured',
374
+ 'selected' => 0,
375
+ 'insured_amount' => 0,
376
+ );
377
+ }
378
+
379
+ /**
380
+ * @return $this
381
+ */
382
+ public function calculateConsignmentOptions()
383
+ {
384
+ $homeAddressOnly = $this->getHomeAddressOnlyOption();
385
+ $signtatureOnReceipt = $this->getSignatureOnReceiptOption();
386
+ $returnIfNoAnswer = $this->getReturnIfNoAnswerOption();
387
+ $insured = $this->getInsuredOption();
388
+
389
+ $this->setDataUsingMethod($homeAddressOnly['option'], $homeAddressOnly['selected']);
390
+ $this->setDataUsingMethod($signtatureOnReceipt['option'], $signtatureOnReceipt['selected']);
391
+ $this->setDataUsingMethod($returnIfNoAnswer['option'], $returnIfNoAnswer['selected']);
392
+ $this->setDataUsingMethod($insured['option'], $insured['selected']);
393
+ $this->setDataUsingMethod('insured_amount', $insured['insured_amount']);
394
+
395
+ return $this;
396
+ }
397
+
398
+ /**
399
+ * Sets an array of consignment options. If any options were set in the registry, those will be used as well.
400
+ *
401
+ * @param array $consignmentOptions
402
+ *
403
+ * @return $this
404
+ */
405
+ public function setConsignmentOptions($consignmentOptions = array())
406
+ {
407
+ /**
408
+ * If any consignment options were set in the registry, those will be added as well.
409
+ */
410
+ $registryOptions = Mage::registry('tig_myparcel_consignment_options');
411
+ if (!empty($registryOptions) && is_array($registryOptions)) {
412
+ $consignmentOptions = array_merge($consignmentOptions, $registryOptions);
413
+ }
414
+
415
+ /**
416
+ * is only empty and null when the myparcel shipment is created in a mass-action
417
+ */
418
+ if(empty($consignmentOptions) && is_null($registryOptions)){
419
+ $this->calculateConsignmentOptions();
420
+ return $this;
421
+ }
422
+
423
+
424
+ /**
425
+ * Add the options.
426
+ */
427
+ foreach ($consignmentOptions as $option => $value) {
428
+ /**
429
+ * The insured_amount option is dependant on the 'insured' option.
430
+ */
431
+ if ($option == 'insured_amount'
432
+ && (!isset($registryOptions['insured'])
433
+ || $registryOptions['insured'] != '1'
434
+ )
435
+ ) {
436
+ continue;
437
+ }
438
+
439
+ $this->setDataUsingMethod($option, $value);
440
+ }
441
+
442
+ return $this;
443
+ }
444
+
445
+ /**
446
+ * Checks if a consignment can be created for this current shipment.
447
+ *
448
+ * @return bool
449
+ */
450
+ public function canCreateConsignment()
451
+ {
452
+
453
+ if ($this->hasConsignmentId()) {
454
+ return false;
455
+ }
456
+
457
+ if ($this->hasStatus() && $this->getStatus() != self::STATUS_NEW) {
458
+ return false;
459
+ }
460
+
461
+ return true;
462
+ }
463
+
464
+ /**
465
+ * Create a consignment using the MyParcel API.
466
+ *
467
+ * @returns $this
468
+ *
469
+ * @throws TIG_MyParcel2014_Exception
470
+ */
471
+ public function createConsignment()
472
+ {
473
+ $helper = Mage::helper('tig_myparcel');
474
+
475
+ if (!$this->canCreateConsignment()) {
476
+ throw new TIG_MyParcel2014_Exception(
477
+ $helper->__('The createConsignment action is currently unavailable.'),
478
+ 'MYPA-0011'
479
+ );
480
+ }
481
+
482
+ /**
483
+ * Send the createConsignment request using the MyParcel API.
484
+ */
485
+ $api = $this->getApi();
486
+ $response = $api->createConsignmentRequest($this)
487
+ ->sendRequest()
488
+ ->getRequestResponse();
489
+
490
+ /**
491
+ * Validate the response.
492
+ */
493
+ if (!is_array($response)
494
+ || !isset($response['consignment_id'])
495
+ || !is_numeric($response['consignment_id'])
496
+ ) {
497
+ throw new TIG_MyParcel2014_Exception(
498
+ $helper->__('Invalid createConsignment response: %s', $api->getRequestErrorDetail()),
499
+ 'MYPA-0012'
500
+ );
501
+ }
502
+
503
+ $status = self::STATUS_NEW;
504
+
505
+ /**
506
+ * check if barcode is available
507
+ */
508
+ if(isset($response['tracktrace']) && !empty($response['tracktrace'])){
509
+ $barcode = $response['tracktrace'];
510
+ $shipment = $this;
511
+ $isSend = $helper->sendBarcodeEmail($barcode,$shipment);
512
+ $this->setBarcode($barcode);
513
+ $status = self::STATUS_CONFIRMED;
514
+ if($isSend){
515
+ //add comment to order-comment history
516
+ $comment = $helper->__('Track&amp;Trace e-mail is send: %s',$helper->getBarcodeUrl($barcode));
517
+ $helper->log($comment);
518
+ $order = $shipment->getOrder();
519
+ $order->addStatusHistoryComment($comment);
520
+ $order->setEmailSent(true);
521
+ $order->save();
522
+
523
+ //flag the myparcel shipment that barcode
524
+ $this->setBarcodeSend(true);
525
+ }
526
+ }
527
+
528
+ /**
529
+ * set status (new or confirmed)
530
+ */
531
+ $this->setStatus($status);
532
+
533
+ /**
534
+ * Get the consignment ID and set it.
535
+ */
536
+ $consignmentId = (int) $response['consignment_id'];
537
+
538
+ $this->setConsignmentId($consignmentId);
539
+ return $this;
540
+ }
541
+
542
+ /**
543
+ * Adds Magento tracking information to the order containing the previously retrieved barcode.
544
+ *
545
+ * @param string $trackAndTraceCode
546
+ *
547
+ * @return $this
548
+ *
549
+ * @throws TIG_MyParcel2014_Exception
550
+ */
551
+ public function addTrackingCodeToShipment($trackAndTraceCode)
552
+ {
553
+ $helper = Mage::helper('tig_myparcel');
554
+ $shipment = $this->getShipment();
555
+
556
+ if (!$shipment || !$trackAndTraceCode) {
557
+ throw new TIG_MyParcel2014_Exception(
558
+ $helper->__(
559
+ 'Unable to add tracking info: no track&amp;trace code or shipment available.'
560
+ ),
561
+ 'MYPA-0013'
562
+ );
563
+ }
564
+
565
+ $carrierCode = self::MYPARCEL_CARRIER_CODE;
566
+ $carrierTitle = Mage::getStoreConfig('carriers/tig_myparcel/name', $shipment->getStoreId());
567
+
568
+ $data = array(
569
+ 'carrier_code' => $carrierCode,
570
+ 'title' => $carrierTitle,
571
+ 'number' => $trackAndTraceCode,
572
+ );
573
+
574
+ /**
575
+ * @var Mage_Sales_Model_Order_Shipment_Track $track
576
+ */
577
+ $track = Mage::getModel('sales/order_shipment_track')->addData($data);
578
+ $shipment->addTrack($track);
579
+
580
+ /**
581
+ * Save the Mage_Sales_Order_Shipment object
582
+ *
583
+ * @var Mage_Core_Model_Resource_Transaction $transaction
584
+ */
585
+ $transaction = Mage::getModel('core/resource_transaction');
586
+ $transaction->addObject($shipment)
587
+ ->save();
588
+
589
+ return $this;
590
+ }
591
+
592
+ /**
593
+ * @return $this
594
+ */
595
+ protected function _beforeSave()
596
+ {
597
+ /**
598
+ * If this object is new and does not yet have a status, set the 'new' status.
599
+ */
600
+ if (!$this->getId() && $this->isObjectNew() && !$this->hasStatus()) {
601
+ $this->setStatus(self::STATUS_NEW);
602
+ }
603
+
604
+ return parent::_beforeSave();
605
+ }
606
+ }
app/code/community/TIG/MyParcel2014/Model/System/Config/Source/A4a6.php ADDED
@@ -0,0 +1,63 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * ___________ __ __
4
+ * \__ ___/____ _/ |_ _____ | |
5
+ * | | / _ \\ __\\__ \ | |
6
+ * | | | |_| || | / __ \_| |__
7
+ * |____| \____/ |__| (____ /|____/
8
+ * \/
9
+ * ___ __ __
10
+ * | | ____ _/ |_ ____ _______ ____ ____ _/ |_
11
+ * | | / \\ __\_/ __ \\_ __ \ / \ _/ __ \\ __\
12
+ * | || | \| | \ ___/ | | \/| | \\ ___/ | |
13
+ * |___||___| /|__| \_____>|__| |___| / \_____>|__|
14
+ * \/ \/
15
+ * ________
16
+ * / _____/_______ ____ __ __ ______
17
+ * / \ ___\_ __ \ / _ \ | | \\____ \
18
+ * \ \_\ \| | \/| |_| || | /| |_| |
19
+ * \______ /|__| \____/ |____/ | __/
20
+ * \/ |__|
21
+ *
22
+ * NOTICE OF LICENSE
23
+ *
24
+ * This source file is subject to the Creative Commons License.
25
+ * It is available through the world-wide-web at this URL:
26
+ * http://creativecommons.org/licenses/by-nc-nd/3.0/nl/deed.en_US
27
+ * If you are unable to obtain it through the world-wide-web, please send an email
28
+ * to servicedesk@tig.nl so we can send you a copy immediately.
29
+ *
30
+ * DISCLAIMER
31
+ *
32
+ * Do not edit or add to this file if you wish to upgrade this module to newer
33
+ * versions in the future. If you wish to customize this module for your
34
+ * needs please contact servicedesk@tig.nl for more information.
35
+ *
36
+ * @copyright Copyright (c) 2014 Total Internet Group B.V. (http://www.totalinternetgroup.nl)
37
+ * @license http://creativecommons.org/licenses/by-nc-nd/3.0/nl/deed.en_US
38
+ */
39
+
40
+ class TIG_MyParcel2014_Model_System_Config_Source_A4a6
41
+ {
42
+ /**
43
+ * Source model for A4 / A6 setting.
44
+ *
45
+ * @return array
46
+ */
47
+ public function toOptionArray()
48
+ {
49
+ $helper = Mage::helper('tig_myparcel');
50
+
51
+ $array = array(
52
+ array(
53
+ 'value' => 'A4',
54
+ 'label' => $helper->__('A4'),
55
+ ),
56
+ array(
57
+ 'value' => 'A6',
58
+ 'label' => $helper->__('A6'),
59
+ ),
60
+ );
61
+ return $array;
62
+ }
63
+ }
app/code/community/TIG/MyParcel2014/Model/System/Config/Source/Customs.php ADDED
@@ -0,0 +1,75 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * ___________ __ __
4
+ * \__ ___/____ _/ |_ _____ | |
5
+ * | | / _ \\ __\\__ \ | |
6
+ * | | | |_| || | / __ \_| |__
7
+ * |____| \____/ |__| (____ /|____/
8
+ * \/
9
+ * ___ __ __
10
+ * | | ____ _/ |_ ____ _______ ____ ____ _/ |_
11
+ * | | / \\ __\_/ __ \\_ __ \ / \ _/ __ \\ __\
12
+ * | || | \| | \ ___/ | | \/| | \\ ___/ | |
13
+ * |___||___| /|__| \_____>|__| |___| / \_____>|__|
14
+ * \/ \/
15
+ * ________
16
+ * / _____/_______ ____ __ __ ______
17
+ * / \ ___\_ __ \ / _ \ | | \\____ \
18
+ * \ \_\ \| | \/| |_| || | /| |_| |
19
+ * \______ /|__| \____/ |____/ | __/
20
+ * \/ |__|
21
+ *
22
+ * NOTICE OF LICENSE
23
+ *
24
+ * This source file is subject to the Creative Commons License.
25
+ * It is available through the world-wide-web at this URL:
26
+ * http://creativecommons.org/licenses/by-nc-nd/3.0/nl/deed.en_US
27
+ * If you are unable to obtain it through the world-wide-web, please send an email
28
+ * to servicedesk@tig.nl so we can send you a copy immediately.
29
+ *
30
+ * DISCLAIMER
31
+ *
32
+ * Do not edit or add to this file if you wish to upgrade this module to newer
33
+ * versions in the future. If you wish to customize this module for your
34
+ * needs please contact servicedesk@tig.nl for more information.
35
+ *
36
+ * @copyright Copyright (c) 2014 Total Internet Group B.V. (http://www.totalinternetgroup.nl)
37
+ * @license http://creativecommons.org/licenses/by-nc-nd/3.0/nl/deed.en_US
38
+ */
39
+
40
+ class TIG_MyParcel2014_Model_System_Config_Source_Customs
41
+ {
42
+ /**
43
+ * Source model for customs setting.
44
+ *
45
+ * @return array
46
+ */
47
+ public function toOptionArray()
48
+ {
49
+ $helper = Mage::helper('tig_myparcel');
50
+
51
+ $array = array(
52
+ array(
53
+ 'value' => 'Commercial Goods',
54
+ 'label' => $helper->__('Commercial Goods'),
55
+ ),
56
+ array(
57
+ 'value' => 'Commercial Sample',
58
+ 'label' => $helper->__('Commercial Sample'),
59
+ ),
60
+ array(
61
+ 'value' => 'Documents',
62
+ 'label' => $helper->__('Documents'),
63
+ ),
64
+ array(
65
+ 'value' => 'Gift',
66
+ 'label' => $helper->__('Gift'),
67
+ ),
68
+ array(
69
+ 'value' => 'Returned Goods',
70
+ 'label' => $helper->__('Returned Goods'),
71
+ ),
72
+ );
73
+ return $array;
74
+ }
75
+ }
app/code/community/TIG/MyParcel2014/Model/System/Config/Source/StreetField.php ADDED
@@ -0,0 +1,144 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * ___________ __ __
4
+ * \__ ___/____ _/ |_ _____ | |
5
+ * | | / _ \\ __\\__ \ | |
6
+ * | | | |_| || | / __ \_| |__
7
+ * |____| \____/ |__| (____ /|____/
8
+ * \/
9
+ * ___ __ __
10
+ * | | ____ _/ |_ ____ _______ ____ ____ _/ |_
11
+ * | | / \\ __\_/ __ \\_ __ \ / \ _/ __ \\ __\
12
+ * | || | \| | \ ___/ | | \/| | \\ ___/ | |
13
+ * |___||___| /|__| \_____>|__| |___| / \_____>|__|
14
+ * \/ \/
15
+ * ________
16
+ * / _____/_______ ____ __ __ ______
17
+ * / \ ___\_ __ \ / _ \ | | \\____ \
18
+ * \ \_\ \| | \/| |_| || | /| |_| |
19
+ * \______ /|__| \____/ |____/ | __/
20
+ * \/ |__|
21
+ *
22
+ * NOTICE OF LICENSE
23
+ *
24
+ * This source file is subject to the Creative Commons License.
25
+ * It is available through the world-wide-web at this URL:
26
+ * http://creativecommons.org/licenses/by-nc-nd/3.0/nl/deed.en_US
27
+ * If you are unable to obtain it through the world-wide-web, please send an email
28
+ * to servicedesk@tig.nl so we can send you a copy immediately.
29
+ *
30
+ * DISCLAIMER
31
+ *
32
+ * Do not edit or add to this file if you wish to upgrade this module to newer
33
+ * versions in the future. If you wish to customize this module for your
34
+ * needs please contact servicedesk@tig.nl for more information.
35
+ *
36
+ * @copyright Copyright (c) 2014 Total Internet Group B.V. (http://www.totalinternetgroup.nl)
37
+ * @license http://creativecommons.org/licenses/by-nc-nd/3.0/nl/deed.en_US
38
+ */
39
+ class TIG_MyParcel2014_Model_System_Config_Source_StreetField
40
+ {
41
+ /**
42
+ * XML path to community edition address lines configuration option
43
+ */
44
+ const XPATH_COMMUNITY_STREET_LINES = 'customer/address/street_lines';
45
+
46
+ /**
47
+ * @var null|array The resulting product option array
48
+ */
49
+ protected $_options = null;
50
+
51
+ /**
52
+ * Source model for street line settings
53
+ *
54
+ * @return array
55
+ */
56
+ public function toOptionArray()
57
+ {
58
+ if ($this->_options !== null) {
59
+ return $this->_options;
60
+ }
61
+
62
+ if (Mage::helper('tig_myparcel')->isEnterprise()) {
63
+ $array = $this->_getEnterpriseOptions();
64
+
65
+ $this->_options = $array;
66
+ return $array;
67
+ }
68
+
69
+ $array = $this->_getCommunityOptions();
70
+
71
+ $this->_options = $array;
72
+ return $array;
73
+ }
74
+
75
+ /**
76
+ * Gets options for community edition shops
77
+ *
78
+ * @return array
79
+ */
80
+ protected function _getCommunityOptions()
81
+ {
82
+ $request = Mage::app()->getRequest();
83
+ $helper = Mage::helper('tig_myparcel');
84
+
85
+ /**
86
+ * Get the allowed number of address lines based on the current scope
87
+ */
88
+ if ($request->getParam('store')) {
89
+ $lineCount = Mage::getStoreConfig(self::XPATH_COMMUNITY_STREET_LINES, $request->getParam('store'));
90
+ } elseif ($request->getParam('website')) {
91
+ $website = Mage::getModel('core/website')->load($request->getParam('website'), 'code');
92
+ $lineCount = $website->getConfig(self::XPATH_COMMUNITY_STREET_LINES, $website->getId());
93
+ } else {
94
+ $lineCount = Mage::getStoreConfig(
95
+ self::XPATH_COMMUNITY_STREET_LINES,
96
+ Mage_Core_Model_App::ADMIN_STORE_ID
97
+ );
98
+ }
99
+
100
+ /**
101
+ * It's possible to leave the streetfield empty in community. In that case, the default value of 2 will be used.
102
+ */
103
+ if (!$lineCount) {
104
+ $lineCount = 2;
105
+ }
106
+
107
+ /**
108
+ * Build the option array
109
+ */
110
+ $array = array();
111
+ for ($n = 1; $n <= $lineCount; $n++) {
112
+ $array[] = array(
113
+ 'value' => $n,
114
+ 'label' => $helper->__('Street line #%s', $n),
115
+ );
116
+ }
117
+
118
+ return $array;
119
+ }
120
+
121
+ /**
122
+ * Gets options for enterprise edition shops
123
+ *
124
+ * @return array
125
+ */
126
+ protected function _getEnterpriseOptions()
127
+ {
128
+ $helper = Mage::helper('tig_myparcel');
129
+ $lineCount = Mage::helper('customer/address')->getStreetLines();
130
+
131
+ /**
132
+ * Build the option array
133
+ */
134
+ $array = array();
135
+ for ($n = 1; $n <= $lineCount; $n++) {
136
+ $array[] = array(
137
+ 'value' => $n,
138
+ 'label' => $helper->__('Street line #%s', $n),
139
+ );
140
+ }
141
+
142
+ return $array;
143
+ }
144
+ }
app/code/community/TIG/MyParcel2014/Model/System/Config/Source/Yesno.php ADDED
@@ -0,0 +1,63 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * ___________ __ __
4
+ * \__ ___/____ _/ |_ _____ | |
5
+ * | | / _ \\ __\\__ \ | |
6
+ * | | | |_| || | / __ \_| |__
7
+ * |____| \____/ |__| (____ /|____/
8
+ * \/
9
+ * ___ __ __
10
+ * | | ____ _/ |_ ____ _______ ____ ____ _/ |_
11
+ * | | / \\ __\_/ __ \\_ __ \ / \ _/ __ \\ __\
12
+ * | || | \| | \ ___/ | | \/| | \\ ___/ | |
13
+ * |___||___| /|__| \_____>|__| |___| / \_____>|__|
14
+ * \/ \/
15
+ * ________
16
+ * / _____/_______ ____ __ __ ______
17
+ * / \ ___\_ __ \ / _ \ | | \\____ \
18
+ * \ \_\ \| | \/| |_| || | /| |_| |
19
+ * \______ /|__| \____/ |____/ | __/
20
+ * \/ |__|
21
+ *
22
+ * NOTICE OF LICENSE
23
+ *
24
+ * This source file is subject to the Creative Commons License.
25
+ * It is available through the world-wide-web at this URL:
26
+ * http://creativecommons.org/licenses/by-nc-nd/3.0/nl/deed.en_US
27
+ * If you are unable to obtain it through the world-wide-web, please send an email
28
+ * to servicedesk@tig.nl so we can send you a copy immediately.
29
+ *
30
+ * DISCLAIMER
31
+ *
32
+ * Do not edit or add to this file if you wish to upgrade this module to newer
33
+ * versions in the future. If you wish to customize this module for your
34
+ * needs please contact servicedesk@tig.nl for more information.
35
+ *
36
+ * @copyright Copyright (c) 2014 Total Internet Group B.V. (http://www.totalinternetgroup.nl)
37
+ * @license http://creativecommons.org/licenses/by-nc-nd/3.0/nl/deed.en_US
38
+ */
39
+
40
+ class TIG_MyParcel2014_Model_System_Config_Source_Yesno
41
+ {
42
+ /**
43
+ * Source model for yes / no setting.
44
+ *
45
+ * @return array
46
+ */
47
+ public function toOptionArray()
48
+ {
49
+ $helper = Mage::helper('tig_myparcel');
50
+
51
+ $array = array(
52
+ array(
53
+ 'value' => '1',
54
+ 'label' => $helper->__('Yes'),
55
+ ),
56
+ array(
57
+ 'value' => '0',
58
+ 'label' => $helper->__('No'),
59
+ ),
60
+ );
61
+ return $array;
62
+ }
63
+ }
app/code/community/TIG/MyParcel2014/controllers/Adminhtml/ConfigController.php ADDED
@@ -0,0 +1,147 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class TIG_MyParcel2014_Adminhtml_ConfigController extends Mage_Adminhtml_Controller_Action
4
+ {
5
+ /**
6
+ * Download all MyParcel log files as a zip file.
7
+ *
8
+ * @return $this
9
+ */
10
+ public function downloadLogsAction()
11
+ {
12
+ $helper = Mage::helper('tig_myparcel');
13
+
14
+ /**
15
+ * Get a zip file containing all valid MyParcel logs.
16
+ */
17
+ try
18
+ {
19
+ $zip = Mage::getModel('tig_myparcel/adminhtml_support_logs')->downloadLogs();
20
+ }
21
+ catch (Exception $e)
22
+ {
23
+ Mage::getSingleton('core/session')->addError($helper->__('The log files cannot be downloaded.'));
24
+
25
+ $this->_redirect('adminhtml/system_config/edit', array('section' => 'tig_myparcel'));
26
+ return $this;
27
+ }
28
+ if(empty($zip))
29
+ {
30
+ Mage::getSingleton('core/session')->addError($helper->__('There are no log files to be downloaded.'));
31
+
32
+ $this->_redirect('adminhtml/system_config/edit', array('section' => 'tig_myparcel'));
33
+ return $this;
34
+ }
35
+
36
+ $zipName = explode(DS, $zip);
37
+ $zipName = end($zipName);
38
+
39
+ /**
40
+ * Offer the zip file as a download response. The 'rm' key will cause Magento to remove the zip file from the
41
+ * server after it's finished.
42
+ */
43
+ $content = array(
44
+ 'type' => 'filename',
45
+ 'value' => $zip,
46
+ 'rm' => true,
47
+ );
48
+ $this->_prepareDownloadResponse($zipName, $content);
49
+
50
+ return $this;
51
+ }
52
+
53
+ public function generateRetourlinkAction()
54
+ {
55
+ $helper = Mage::helper('tig_myparcel');
56
+
57
+ //get Params
58
+ $shipmentId = $this->getRequest()->getParam('shipment_id');
59
+
60
+ /**
61
+ * @var TIG_MyParcel2014_Model_Shipment $myparcelShipment
62
+ * @var Mage_Sales_Model_Order_Shipment $shipment
63
+ */
64
+ $myparcelShipment = Mage::getModel('tig_myparcel/shipment')->load($shipmentId, 'shipment_id');
65
+ $shipment = Mage::getModel('sales/order_shipment')->load($shipmentId);
66
+
67
+
68
+ $consignmentId = $myparcelShipment->getConsignmentId();
69
+
70
+ /**
71
+ * @var TIG_MyParcel2014_Model_Api_MyParcel $api
72
+ */
73
+ $api = $myparcelShipment->getApi();
74
+ $response = $api->createRetourlinkRequest($consignmentId)
75
+ ->sendRequest()
76
+ ->getRequestResponse();
77
+
78
+ /**
79
+ * Validate the response.
80
+ */
81
+ if(!is_array($response) || empty($response['retourlink'])){
82
+ $message = $helper->__('Retourlink is not created, check the log files for details.');
83
+ $helper->addSessionMessage('adminhtml/session','MYPA-0020', 'warning');
84
+ $helper->logException($message);
85
+ }
86
+
87
+ //save retourlink by myparcel shipment
88
+ $myparcelShipment->setRetourlink($response['retourlink']);
89
+ $myparcelShipment->save();
90
+
91
+ //set shipment comment
92
+ $comment = $helper->__('Retourlink generated: %s',$response['retourlink']);
93
+ $shipment->addComment($comment,0,1);
94
+ $shipment->save();
95
+
96
+ //redirect to previous screen
97
+ $this->_redirectReferer();
98
+ }
99
+
100
+ public function creditConsignmentAction()
101
+ {
102
+ $helper = Mage::helper('tig_myparcel');
103
+ //get Params
104
+ $shipmentId = $this->getRequest()->getParam('shipment_id');
105
+
106
+ /**
107
+ * @var TIG_MyParcel2014_Model_Shipment $myparcelShipment
108
+ * @var Mage_Sales_Model_Order_Shipment $shipment
109
+ */
110
+ $myparcelShipment = Mage::getModel('tig_myparcel/shipment')->load($shipmentId, 'shipment_id');
111
+ $shipment = Mage::getModel('sales/order_shipment')->load($shipmentId);
112
+
113
+
114
+ $consignmentId = $myparcelShipment->getConsignmentId();
115
+
116
+ /**
117
+ * @var TIG_MyParcel2014_Model_Api_MyParcel $api
118
+ */
119
+ $api = $myparcelShipment->getApi();
120
+ $response = $api->createConsignmentCreditRequest($consignmentId)
121
+ ->sendRequest()
122
+ ->getRequestResponse();
123
+
124
+ /**
125
+ * Validate the response.
126
+ */
127
+ if(!is_array($response) || $response['success'] == false){
128
+
129
+ $message = $helper->__('Credit has not been created, check MyParcel backend for details');
130
+ $helper->addSessionMessage('adminhtml/session','MYPA-0021', 'warning');
131
+ $helper->logException($message);
132
+ }
133
+
134
+ //save retourlink by myparcel shipment
135
+ $myparcelShipment->setIsCredit(true);
136
+ $myparcelShipment->setStatus($response['status']);
137
+ $myparcelShipment->save();
138
+
139
+ //set shipment comment
140
+ $comment = $helper->__('Consignment %s is credited at MyParcel',$consignmentId);
141
+ $shipment->addComment($comment);
142
+ $shipment->save();
143
+
144
+ //redirect to previous screen
145
+ $this->_redirectReferer();
146
+ }
147
+ }
app/code/community/TIG/MyParcel2014/controllers/Adminhtml/ShipmentController.php ADDED
@@ -0,0 +1,689 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * ___________ __ __
4
+ * \__ ___/____ _/ |_ _____ | |
5
+ * | | / _ \\ __\\__ \ | |
6
+ * | | | |_| || | / __ \_| |__
7
+ * |____| \____/ |__| (____ /|____/
8
+ * \/
9
+ * ___ __ __
10
+ * | | ____ _/ |_ ____ _______ ____ ____ _/ |_
11
+ * | | / \\ __\_/ __ \\_ __ \ / \ _/ __ \\ __\
12
+ * | || | \| | \ ___/ | | \/| | \\ ___/ | |
13
+ * |___||___| /|__| \_____>|__| |___| / \_____>|__|
14
+ * \/ \/
15
+ * ________
16
+ * / _____/_______ ____ __ __ ______
17
+ * / \ ___\_ __ \ / _ \ | | \\____ \
18
+ * \ \_\ \| | \/| |_| || | /| |_| |
19
+ * \______ /|__| \____/ |____/ | __/
20
+ * \/ |__|
21
+ *
22
+ * NOTICE OF LICENSE
23
+ *
24
+ * This source file is subject to the Creative Commons License.
25
+ * It is available through the world-wide-web at this URL:
26
+ * http://creativecommons.org/licenses/by-nc-nd/3.0/nl/deed.en_US
27
+ * If you are unable to obtain it through the world-wide-web, please send an email
28
+ * to servicedesk@tig.nl so we can send you a copy immediately.
29
+ *
30
+ * DISCLAIMER
31
+ *
32
+ * Do not edit or add to this file if you wish to upgrade this module to newer
33
+ * versions in the future. If you wish to customize this module for your
34
+ * needs please contact servicedesk@tig.nl for more information.
35
+ *
36
+ * @copyright Copyright (c) 2014 Total Internet Group B.V. (http://www.totalinternetgroup.nl)
37
+ * @license http://creativecommons.org/licenses/by-nc-nd/3.0/nl/deed.en_US
38
+ */
39
+ class TIG_MyParcel2014_Adminhtml_ShipmentController extends Mage_Adminhtml_Controller_Action
40
+ {
41
+ /**
42
+ * Used module name in current adminhtml controller.
43
+ */
44
+ protected $_usedModuleName = 'TIG_MyParcel2014';
45
+
46
+ /**
47
+ * @var array
48
+ */
49
+ protected $_warnings = array();
50
+
51
+ /**
52
+ * @return array
53
+ */
54
+ public function getWarnings()
55
+ {
56
+ return $this->_warnings;
57
+ }
58
+
59
+ /**
60
+ * @param array $warnings
61
+ *
62
+ * @return $this
63
+ */
64
+ public function setWarnings(array $warnings)
65
+ {
66
+ $this->_warnings = $warnings;
67
+
68
+ return $this;
69
+ }
70
+
71
+ /**
72
+ * @param array|string $warning
73
+ *
74
+ * @return $this
75
+ */
76
+ public function addWarning($warning)
77
+ {
78
+ if (!is_array($warning)) {
79
+ $warning = array(
80
+ 'entity_id' => null,
81
+ 'code' => null,
82
+ 'description' => $warning,
83
+ );
84
+ }
85
+
86
+ $warnings = $this->getWarnings();
87
+ $warnings[] = $warning;
88
+
89
+ $this->setWarnings($warnings);
90
+ return $this;
91
+ }
92
+
93
+ /**
94
+ * Creates shipments for a supplied array of orders. This action is triggered by a massaction in the sales > order
95
+ * grid.
96
+ *
97
+ * @return $this
98
+ */
99
+ public function massCreateShipmentsAction()
100
+ {
101
+ $helper = Mage::helper('tig_myparcel');
102
+
103
+ try {
104
+ $orderIds = $this->_getOrderIds();
105
+
106
+ /**
107
+ * Create the shipments.
108
+ */
109
+ $errors = 0;
110
+ foreach ($orderIds as $orderId) {
111
+ try {
112
+ $this->_createShipment($orderId);
113
+ } catch (TIG_MyParcel2014_Exception $e) {
114
+ $helper->logException($e);
115
+ $this->addWarning(
116
+ array(
117
+ 'entity_id' => Mage::getResourceModel('sales/order')->getIncrementId($orderId),
118
+ 'code' => $e->getCode(),
119
+ 'description' => $e->getMessage(),
120
+ )
121
+ );
122
+ $errors++;
123
+ } catch (Exception $e) {
124
+ $helper->logException($e);
125
+ $this->addWarning(
126
+ array(
127
+ 'entity_id' => Mage::getResourceModel('sales/order')->getIncrementId($orderId),
128
+ 'code' => null,
129
+ 'description' => $e->getMessage(),
130
+ )
131
+ );
132
+ $errors++;
133
+ }
134
+ }
135
+ } catch (TIG_MyParcel2014_Exception $e) {
136
+ $helper->logException($e);
137
+ $helper->addExceptionSessionMessage('adminhtml/session', $e);
138
+
139
+ $this->_redirect('adminhtml/sales_order/index');
140
+ return $this;
141
+ } catch (Exception $e) {
142
+ $helper->logException($e);
143
+ $helper->addSessionMessage(
144
+ 'adminhtml/session',
145
+ null,
146
+ 'error',
147
+ $this->__('An error occurred while processing this action.')
148
+ );
149
+
150
+ $this->_redirect('adminhtml/sales_order/index');
151
+ return $this;
152
+ }
153
+
154
+ /**
155
+ * Check for warnings.
156
+ */
157
+ $this->_checkForWarnings();
158
+
159
+ /**
160
+ * Add either a success or failure message and redirect the user accordingly.
161
+ */
162
+ if ($errors < count($orderIds)) {
163
+ $helper->addSessionMessage(
164
+ 'adminhtml/session', null, 'success',
165
+ $this->__('The shipments were successfully created.')
166
+ );
167
+
168
+ $this->_redirect('adminhtml/sales_order/index');
169
+ } else {
170
+ $helper->addSessionMessage(
171
+ 'adminhtml/session', null, 'error',
172
+ $this->__('None of the shipments could be created. Please check the error messages for more details.')
173
+ );
174
+
175
+ $this->_redirect('adminhtml/sales_order/index');
176
+ }
177
+
178
+ return $this;
179
+ }
180
+
181
+ /**
182
+ * Print shipping labels for all selected orders.
183
+ *
184
+ * @return $this
185
+ *
186
+ * @throws TIG_MyParcel2014_Exception
187
+ */
188
+ public function massPrintLabelsAction()
189
+ {
190
+ $helper = Mage::helper('tig_myparcel');
191
+ $orderIds = $this->_getOrderIds();
192
+
193
+ $shipmentCollection = Mage::getResourceModel('sales/order_shipment_collection')
194
+ ->addFieldToSelect(array('entity_id','order_id'))
195
+ ->addFieldToFilter('order_id', array('in', $orderIds));
196
+
197
+ $shipmentIds = $shipmentCollection->getColumnValues('entity_id');
198
+ $orderIds2 = $shipmentCollection->getColumnValues('order_id');
199
+
200
+ /**
201
+ * create new shipments if not yet created
202
+ */
203
+ $hasNoShipments = array_diff($orderIds, $orderIds2);
204
+ $newShipments = array();
205
+ if(!empty($hasNoShipments)){
206
+ $errors = 0;
207
+ foreach($hasNoShipments as $orderId)
208
+ {
209
+ /**
210
+ * returns a shipment object
211
+ */
212
+ try {
213
+ $newShipments[] = $this->_createShipment($orderId, true);
214
+ } catch (TIG_MyParcel2014_Exception $e) {
215
+ $helper->logException($e);
216
+ $this->addWarning(
217
+ array(
218
+ 'entity_id' => Mage::getResourceModel('sales/order')->getIncrementId($orderId),
219
+ 'code' => $e->getCode(),
220
+ 'description' => $e->getMessage(),
221
+ )
222
+ );
223
+ $errors++;
224
+ } catch (Exception $e) {
225
+ $helper->logException($e);
226
+ $this->addWarning(
227
+ array(
228
+ 'entity_id' => Mage::getResourceModel('sales/order')->getIncrementId($orderId),
229
+ 'code' => null,
230
+ 'description' => $e->getMessage(),
231
+ )
232
+ );
233
+ $errors++;
234
+ }
235
+ }
236
+ }
237
+
238
+ if($errors > 0){
239
+ $helper->addSessionMessage(
240
+ 'adminhtml/session', null, 'error',
241
+ $this->__('Some of the shipments could not be created or could not be created at MyParcel from the selected orders. See below for detailed information.')
242
+ );
243
+
244
+ $this->_redirect('adminhtml/sales_order/index');
245
+ }
246
+
247
+ // if new shipments are created, refresh the collection of shipments for the orders
248
+ if(!empty($newShipments))
249
+ {
250
+ $shipmentCollection = Mage::getResourceModel('sales/order_shipment_collection')
251
+ ->addFieldToSelect(array('entity_id','order_id'))
252
+ ->addFieldToFilter('order_id', array('in', $orderIds));
253
+
254
+ $shipmentIds = $shipmentCollection->getColumnValues('entity_id');
255
+ }
256
+
257
+ /**
258
+ * Load the shipments and check if they are valid.
259
+ * returns an array with shipment objects
260
+ */
261
+ $shipments = $this->_loadAndCheckShipments($shipmentIds, true, false);
262
+
263
+ /**
264
+ * Get the labels from CIF.
265
+ *
266
+ * @var TIG_MyParcel2014_Model_Shipment $shipment
267
+ */
268
+ $consignmentIds = array();
269
+ foreach ($shipments as $shipment) {
270
+ try {
271
+ if (!$shipment->hasConsignmentId()) {
272
+ $shipment->createConsignment();
273
+ }
274
+
275
+ $consignmentIds[] = $shipment->getConsignmentId();
276
+ } catch (Exception $e) {
277
+ $helper->logException($e);
278
+ $this->addWarning(
279
+ array(
280
+ 'entity_id' => $shipment->getShipmentIncrementId(),
281
+ 'code' => null,
282
+ 'description' => $e->getMessage(),
283
+ )
284
+ );
285
+ }
286
+ }
287
+
288
+ if (!$consignmentIds) {
289
+ $helper->addSessionMessage(
290
+ 'adminhtml/session',
291
+ null,
292
+ 'error',
293
+ $this->__(
294
+ 'Unfortunately no shipments could be processed. Please check the error messages for more details.'
295
+ )
296
+ );
297
+
298
+ $this->_redirect('adminhtml/sales_order/index');
299
+ return $this;
300
+ }
301
+
302
+ $api = Mage::getModel('tig_myparcel/api_myParcel');
303
+ $start = $this->getRequest()->getParam('myparcel_print_labels_start', 1);
304
+ $perpage = $helper->getConfig('print_orientation');
305
+ $pdfData = $api->createRetrievePdfsRequest($consignmentIds, $start, $perpage)
306
+ ->sendRequest()
307
+ ->getRequestResponse();
308
+
309
+ $fileName = 'MyParcel Shipping Labels '
310
+ . date('Ymd-His', Mage::getSingleton('core/date')->timestamp())
311
+ . '.pdf';
312
+
313
+ $this->_preparePdfResponse($fileName, urldecode($pdfData['pdf']));
314
+
315
+ /**
316
+ * We need to check for warnings before the label download response.
317
+ */
318
+ $this->_checkForWarnings();
319
+
320
+ return $this;
321
+ }
322
+
323
+ /**
324
+ * Get shipment Ids from the request.
325
+ *
326
+ * @return array
327
+ *
328
+ * @throws TIG_MyParcel2014_Exception
329
+ */
330
+ protected function _getShipmentIds()
331
+ {
332
+ $shipmentIds = $this->getRequest()->getParam('shipment_ids', array());
333
+
334
+ /**
335
+ * Check if a shipment was selected.
336
+ */
337
+ if (!is_array($shipmentIds) || empty($shipmentIds)) {
338
+ throw new TIG_MyParcel2014_Exception(
339
+ $this->__('Please select one or more shipments.'),
340
+ 'MYPA-0001'
341
+ );
342
+ }
343
+
344
+ return $shipmentIds;
345
+ }
346
+
347
+ /**
348
+ * Get order Ids from the request.
349
+ *
350
+ * @return array
351
+ *
352
+ * @throws TIG_MyParcel2014_Exception
353
+ */
354
+ protected function _getOrderIds()
355
+ {
356
+ $orderIds = $this->getRequest()->getParam('order_ids', array());
357
+
358
+ /**
359
+ * Check if an order was selected.
360
+ */
361
+ if (!is_array($orderIds) || empty($orderIds)) {
362
+ throw new TIG_MyParcel2014_Exception(
363
+ $this->__('Please select one or more orders.'),
364
+ 'MYPA-0002'
365
+ );
366
+ }
367
+
368
+ return $orderIds;
369
+ }
370
+
371
+ /**
372
+ * Load an array of shipments based on an array of shipmentIds and check if they're shipped using MyParcel
373
+ *
374
+ * @param array|int $shipmentIds
375
+ * @param boolean $loadMyParcelShipments Flag that determines whether the shipments will be loaded as
376
+ * Mage_Sales_Model_Shipment or TIG_MyParcel2014_Model_Shipment objects.
377
+ * @param boolean $throwException Flag whether an exception should be thrown when loading the shipment fails.
378
+ *
379
+ * @return array
380
+ *
381
+ * @throws TIG_MyParcel2014_Exception
382
+ */
383
+ protected function _loadAndCheckShipments($shipmentIds, $loadMyParcelShipments = false, $throwException = true)
384
+ {
385
+ if (!is_array($shipmentIds)) {
386
+ $shipmentIds = array($shipmentIds);
387
+ }
388
+
389
+ $shipments = array();
390
+ foreach ($shipmentIds as $shipmentId) {
391
+ /**
392
+ * Load the shipment.
393
+ *
394
+ * @var Mage_Sales_Model_Order_Shipment|TIG_MyParcel2014_Model_Shipment|boolean $shipment
395
+ */
396
+ $shipment = $this->_loadShipment($shipmentId, $loadMyParcelShipments);
397
+
398
+ if (!$shipment && $throwException) {
399
+ throw new TIG_MyParcel2014_Exception(
400
+ $this->__(
401
+ 'This action is not available for shipment #%s, because it was not shipped using MyParcel.',
402
+ $shipmentId
403
+ ),
404
+ 'MYPA-0003'
405
+ );
406
+ } elseif (!$shipment) {
407
+ $this->addWarning(
408
+ array(
409
+ 'entity_id' => $shipmentId,
410
+ 'code' => 'MYPA-0003',
411
+ 'description' => $this->__(
412
+ 'This action is not available for shipment #%s, because it was not shipped using MyParcel.',
413
+ $shipmentId
414
+ ),
415
+ )
416
+ );
417
+
418
+ continue;
419
+ }
420
+
421
+ $shipments[] = $shipment;
422
+ }
423
+
424
+ return $shipments;
425
+ }
426
+
427
+ /**
428
+ * Load a shipment based on a shipment ID.
429
+ *
430
+ * @param int $shipmentId
431
+ * @param boolean $loadMyParcelShipment
432
+ *
433
+ * @return boolean|Mage_Sales_Model_Order_Shipment|TIG_MyParcel2014_Model_Shipment
434
+ */
435
+ protected function _loadShipment($shipmentId, $loadMyParcelShipment)
436
+ {
437
+ if ($loadMyParcelShipment === false) {
438
+ /**
439
+ * @var Mage_Sales_Model_Order_Shipment $shipment
440
+ */
441
+ $shipment = Mage::getModel('sales/order_shipment')->load($shipmentId);
442
+ if (!$shipment || !$shipment->getId()) {
443
+ return false;
444
+ }
445
+
446
+ $shippingMethod = $shipment->getOrder()->getShippingMethod();
447
+ } else {
448
+ /**
449
+ * @var TIG_MyParcel2014_Model_Shipment $shipment
450
+ */
451
+ $shipment = $this->_getMyParcelShipment($shipmentId);
452
+ if (!$shipment || !$shipment->getId()) {
453
+ return false;
454
+ }
455
+
456
+ $shippingMethod = $shipment->getShipment()->getOrder()->getShippingMethod();
457
+ }
458
+
459
+ /**
460
+ * Check if the shipping method used is allowed
461
+ */
462
+ if (!Mage::helper('tig_myparcel')->shippingMethodIsMyParcel($shippingMethod)) {
463
+ return false;
464
+ }
465
+
466
+ return $shipment;
467
+ }
468
+
469
+ /**
470
+ * Gets the MyParcel shipment associated with a Magento shipment.
471
+ *
472
+ * @param int $shipmentId
473
+ *
474
+ * @return TIG_MyParcel2014_Model_Shipment
475
+ */
476
+ protected function _getMyParcelShipment($shipmentId)
477
+ {
478
+ $myParcelShipment = Mage::getModel('tig_myparcel/shipment')->load($shipmentId, 'shipment_id');
479
+
480
+ return $myParcelShipment;
481
+ }
482
+
483
+ /**
484
+ * Checks if any warnings were received while processing the shipments and/or orders. If any warnings are found they
485
+ * are added to the adminhtml session as a notice.
486
+ *
487
+ * @return $this
488
+ */
489
+ protected function _checkForWarnings()
490
+ {
491
+ /**
492
+ * Check if any warnings were registered
493
+ */
494
+ $cifWarnings = Mage::registry('myparcel_api_warnings');
495
+
496
+ if (is_array($cifWarnings) && !empty($cifWarnings)) {
497
+ $this->_addWarningMessages($cifWarnings, $this->__('MyParcel replied with the following warnings:'));
498
+ }
499
+
500
+ $warnings = $this->getWarnings();
501
+
502
+ if (!empty($warnings)) {
503
+ $this->_addWarningMessages(
504
+ $warnings,
505
+ $this->__('The following shipments or orders could not be processed:')
506
+ );
507
+ }
508
+
509
+ return $this;
510
+ }
511
+
512
+ /**
513
+ * Add an array of warning messages to the adminhtml session.
514
+ *
515
+ * @param $warnings
516
+ * @param string $headerText
517
+ *
518
+ * @return $this
519
+ * @throws TIG_MyParcel2014_Exception
520
+ */
521
+ protected function _addWarningMessages($warnings, $headerText = '')
522
+ {
523
+ $helper = Mage::helper('tig_myparcel');
524
+
525
+ /**
526
+ * Create a warning message to display to the merchant.
527
+ */
528
+ $warningMessage = $headerText;
529
+ $warningMessage .= '<ul class="myparcel-warning">';
530
+
531
+ /**
532
+ * Add each warning to the message.
533
+ */
534
+ foreach ($warnings as $warning) {
535
+ /**
536
+ * Warnings must have a description.
537
+ */
538
+ if (!array_key_exists('description', $warning)) {
539
+ continue;
540
+ }
541
+
542
+ /**
543
+ * Codes are optional for warnings, but must be present in the array. If no code is found in the warning we
544
+ * add an empty one.
545
+ */
546
+ if (!array_key_exists('code', $warning)) {
547
+ $warning['code'] = null;
548
+ }
549
+
550
+ /**
551
+ * Get the formatted warning message.
552
+ */
553
+ $warningText = $helper->getSessionMessage(
554
+ $warning['code'],
555
+ 'warning',
556
+ $this->__($warning['description'])
557
+ );
558
+
559
+ /**
560
+ * Prepend the warning's entity ID if present.
561
+ */
562
+ if (!empty($warning['entity_id'])) {
563
+ $warningText = $warning['entity_id'] . ': ' . $warningText;
564
+ }
565
+
566
+ /**
567
+ * Build the message proper.
568
+ */
569
+ $warningMessage .= '<li>' . $warningText . '</li>';
570
+ }
571
+
572
+ $warningMessage .= '</ul>';
573
+
574
+ /**
575
+ * Add the warnings to the session.
576
+ */
577
+ $helper->addSessionMessage('adminhtml/session', null, 'notice',
578
+ $warningMessage
579
+ );
580
+
581
+ return $this;
582
+ }
583
+
584
+ /**
585
+ * Output the specified string as a pdf.
586
+ *
587
+ * @param string $filename
588
+ * @param string $output
589
+ *
590
+ * @return $this
591
+ * @throws Zend_Controller_Response_Exception
592
+ */
593
+ protected function _preparePdfResponse($filename, $output)
594
+ {
595
+ $this->getResponse()
596
+ ->setHttpResponseCode(200)
597
+ ->setHeader('Pragma', 'public', true)
598
+ ->setHeader('Cache-Control', 'private, max-age=0, must-revalidate', true)
599
+ ->setHeader('Content-type', 'application/pdf', true)
600
+ ->setHeader('Content-Disposition', 'attachment; filename="' . $filename . '"')
601
+ ->setHeader('Last-Modified', date('r'))
602
+ ->setBody($output);
603
+
604
+ return $this;
605
+ }
606
+
607
+ /**
608
+ * Creates a shipment of an order containing all available items
609
+ *
610
+ * @param int $orderId
611
+ * @param boolean $returnShipment
612
+ *
613
+ * @return int|TIG_MyParcel2014_Exception
614
+ *
615
+ *
616
+ * @throws TIG_MyParcel2014_Exception
617
+ */
618
+ protected function _createShipment($orderId, $returnShipment = false)
619
+ {
620
+ /**
621
+ * @var Mage_Sales_Model_Order $order
622
+ */
623
+ $order = Mage::getModel('sales/order')->load($orderId);
624
+
625
+ if (!$order->canShip()) {
626
+ throw new TIG_MyParcel2014_Exception(
627
+ $this->__('Order #%s cannot be shipped at this time.', $order->getIncrementId()),
628
+ 'MYPA-0004'
629
+ );
630
+ }
631
+
632
+ $shipment = Mage::getModel('sales/service_order', $order)
633
+ ->prepareShipment($this->_getItemQtys($order));
634
+
635
+ $shipment->register();
636
+ $this->_saveShipment($shipment);
637
+
638
+ if($returnShipment){
639
+ return $shipment;
640
+ }
641
+
642
+ return $shipment->getId();
643
+ }
644
+
645
+ /**
646
+ * Initialize shipment items QTY
647
+ *
648
+ * @param Mage_Sales_Model_Order $order
649
+ *
650
+ * @return array
651
+ */
652
+ protected function _getItemQtys($order)
653
+ {
654
+ $itemQtys = array();
655
+
656
+ /**
657
+ * @var Mage_Sales_Model_Order_Item $item
658
+ */
659
+ $items = $order->getAllVisibleItems();
660
+ foreach ($items as $item) {
661
+ /**
662
+ * the qty to ship is the total remaining (not yet shipped) qty of every item
663
+ */
664
+ $itemQty = $item->getQtyOrdered() - $item->getQtyShipped();
665
+
666
+ $itemQtys[$item->getId()] = $itemQty;
667
+ }
668
+
669
+ return $itemQtys;
670
+ }
671
+
672
+ /**
673
+ * Save shipment and order in one transaction
674
+ *
675
+ * @param Mage_Sales_Model_Order_Shipment $shipment
676
+ *
677
+ * @return $this
678
+ */
679
+ protected function _saveShipment($shipment)
680
+ {
681
+ $shipment->getOrder()->setIsInProcess(true);
682
+ Mage::getModel('core/resource_transaction')
683
+ ->addObject($shipment)
684
+ ->addObject($shipment->getOrder())
685
+ ->save();
686
+
687
+ return $this;
688
+ }
689
+ }
app/code/community/TIG/MyParcel2014/controllers/IndexController.php ADDED
@@ -0,0 +1,46 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * ___________ __ __
4
+ * \__ ___/____ _/ |_ _____ | |
5
+ * | | / _ \\ __\\__ \ | |
6
+ * | | | |_| || | / __ \_| |__
7
+ * |____| \____/ |__| (____ /|____/
8
+ * \/
9
+ * ___ __ __
10
+ * | | ____ _/ |_ ____ _______ ____ ____ _/ |_
11
+ * | | / \\ __\_/ __ \\_ __ \ / \ _/ __ \\ __\
12
+ * | || | \| | \ ___/ | | \/| | \\ ___/ | |
13
+ * |___||___| /|__| \_____>|__| |___| / \_____>|__|
14
+ * \/ \/
15
+ * ________
16
+ * / _____/_______ ____ __ __ ______
17
+ * / \ ___\_ __ \ / _ \ | | \\____ \
18
+ * \ \_\ \| | \/| |_| || | /| |_| |
19
+ * \______ /|__| \____/ |____/ | __/
20
+ * \/ |__|
21
+ *
22
+ * NOTICE OF LICENSE
23
+ *
24
+ * This source file is subject to the Creative Commons License.
25
+ * It is available through the world-wide-web at this URL:
26
+ * http://creativecommons.org/licenses/by-nc-nd/3.0/nl/deed.en_US
27
+ * If you are unable to obtain it through the world-wide-web, please send an email
28
+ * to servicedesk@tig.nl so we can send you a copy immediately.
29
+ *
30
+ * DISCLAIMER
31
+ *
32
+ * Do not edit or add to this file if you wish to upgrade this module to newer
33
+ * versions in the future. If you wish to customize this module for your
34
+ * needs please contact servicedesk@tig.nl for more information.
35
+ *
36
+ * @copyright Copyright (c) 2014 Total Internet Group B.V. (http://www.totalinternetgroup.nl)
37
+ * @license http://creativecommons.org/licenses/by-nc-nd/3.0/nl/deed.en_US
38
+ */
39
+ class TIG_MyParcel2014_IndexController extends Mage_Core_Controller_Front_Action
40
+ {
41
+ public function pakjegemakAction()
42
+ {
43
+ echo $this->getLayout()->createBlock('tig_myparcel/pakjegemak')->toHTML();
44
+ exit;
45
+ }
46
+ }
app/code/community/TIG/MyParcel2014/data/tig_myparcel_setup/data-upgrade-0.1.0-1.1.1.php ADDED
@@ -0,0 +1,45 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * ___________ __ __
4
+ * \__ ___/____ _/ |_ _____ | |
5
+ * | | / _ \\ __\\__ \ | |
6
+ * | | | |_| || | / __ \_| |__
7
+ * |____| \____/ |__| (____ /|____/
8
+ * \/
9
+ * ___ __ __
10
+ * | | ____ _/ |_ ____ _______ ____ ____ _/ |_
11
+ * | | / \\ __\_/ __ \\_ __ \ / \ _/ __ \\ __\
12
+ * | || | \| | \ ___/ | | \/| | \\ ___/ | |
13
+ * |___||___| /|__| \_____>|__| |___| / \_____>|__|
14
+ * \/ \/
15
+ * ________
16
+ * / _____/_______ ____ __ __ ______
17
+ * / \ ___\_ __ \ / _ \ | | \\____ \
18
+ * \ \_\ \| | \/| |_| || | /| |_| |
19
+ * \______ /|__| \____/ |____/ | __/
20
+ * \/ |__|
21
+ *
22
+ * NOTICE OF LICENSE
23
+ *
24
+ * This source file is subject to the Creative Commons License.
25
+ * It is available through the world-wide-web at this URL:
26
+ * http://creativecommons.org/licenses/by-nc-nd/3.0/nl/deed.en_US
27
+ * If you are unable to obtain it through the world-wide-web, please send an email
28
+ * to servicedesk@tig.nl so we can send you a copy immediately.
29
+ *
30
+ * DISCLAIMER
31
+ *
32
+ * Do not edit or add to this file if you wish to upgrade this module to newer
33
+ * versions in the future. If you wish to customize this module for your
34
+ * needs please contact servicedesk@tig.nl for more information.
35
+ *
36
+ * @copyright Copyright (c) 2013 Total Internet Group B.V. (http://www.totalinternetgroup.nl)
37
+ * @license http://creativecommons.org/licenses/by-nc-nd/3.0/nl/deed.en_US
38
+ */
39
+
40
+ /**
41
+ * @var TIG_MyParcel2014_Model_Resource_Setup $installer
42
+ */
43
+ $installer = $this;
44
+
45
+ $installer->generateCheckStatusExpr();
app/code/community/TIG/MyParcel2014/etc/adminhtml.xml ADDED
@@ -0,0 +1,26 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0"?>
2
+ <config>
3
+ <acl>
4
+ <resources>
5
+ <all>
6
+ <title>Allow Everything</title>
7
+ </all>
8
+ <admin>
9
+ <children>
10
+ <system>
11
+ <children>
12
+ <config>
13
+ <children>
14
+ <tig_myparcel translate="title">
15
+ <title>MyParcel</title>
16
+ <sort_order>0</sort_order>
17
+ </tig_myparcel>
18
+ </children>
19
+ </config>
20
+ </children>
21
+ </system>
22
+ </children>
23
+ </admin>
24
+ </resources>
25
+ </acl>
26
+ </config>
app/code/community/TIG/MyParcel2014/etc/config.xml ADDED
@@ -0,0 +1,367 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0"?>
2
+ <config>
3
+ <modules>
4
+ <TIG_MyParcel2014>
5
+ <version>1.1.4</version>
6
+ </TIG_MyParcel2014>
7
+ </modules>
8
+ <global>
9
+ <models>
10
+ <tig_myparcel>
11
+ <class>TIG_MyParcel2014_Model</class>
12
+ <resourceModel>tig_myparcel_resource</resourceModel>
13
+ </tig_myparcel>
14
+ <tig_myparcel_resource>
15
+ <class>TIG_MyParcel2014_Model_Resource</class>
16
+ <entities>
17
+ <shipment>
18
+ <table>tig_myparcel_shipment</table>
19
+ </shipment>
20
+ </entities>
21
+ </tig_myparcel_resource>
22
+ </models>
23
+ <blocks>
24
+ <tig_myparcel>
25
+ <class>TIG_MyParcel2014_Block</class>
26
+ </tig_myparcel>
27
+ </blocks>
28
+ <helpers>
29
+ <tig_myparcel>
30
+ <class>TIG_MyParcel2014_Helper</class>
31
+ </tig_myparcel>
32
+ </helpers>
33
+ <resources>
34
+ <tig_myparcel_setup>
35
+ <setup>
36
+ <module>TIG_MyParcel2014</module>
37
+ <class>TIG_MyParcel2014_Model_Resource_Setup</class>
38
+ </setup>
39
+ </tig_myparcel_setup>
40
+ </resources>
41
+ <events>
42
+ <sales_order_shipment_save_after>
43
+ <observers>
44
+ <tig_myparcel_shipment_save_after>
45
+ <type>model</type>
46
+ <class>tig_myparcel/observer_saveShipment</class>
47
+ <method>saveConsignmentOption</method>
48
+ </tig_myparcel_shipment_save_after>
49
+ </observers>
50
+ </sales_order_shipment_save_after>
51
+ <sales_order_place_after>
52
+ <observers>
53
+ <!-- Copy a PakjeGemak address to the order. -->
54
+ <tig_myparcel_copy_pg_address>
55
+ <type>model</type>
56
+ <class>tig_myparcel/observer_savePgAddress</class>
57
+ <method>copyAddressToOrder</method>
58
+ </tig_myparcel_copy_pg_address>
59
+ </observers>
60
+ </sales_order_place_after>
61
+ <controller_action_postdispatch_adminhtml_system_config_save>
62
+ <observers>
63
+ <tig_myparcel_save_config>
64
+ <type>model</type>
65
+ <class>tig_myparcel/observer_saveConfig</class>
66
+ <method>registerConfig</method>
67
+ </tig_myparcel_save_config>
68
+ </observers>
69
+ </controller_action_postdispatch_adminhtml_system_config_save>
70
+ </events>
71
+ </global>
72
+ <admin>
73
+ <routers>
74
+ <myparcel_admin>
75
+ <use>admin</use>
76
+ <args>
77
+ <module>TIG_MyParcel2014</module>
78
+ <frontName>myparcel2014_admin</frontName>
79
+ </args>
80
+ </myparcel_admin>
81
+ </routers>
82
+ </admin>
83
+ <adminhtml>
84
+ <layout>
85
+ <updates>
86
+ <tig_myparcel>
87
+ <file>TIG/tig_myparcel.xml</file>
88
+ </tig_myparcel>
89
+ </updates>
90
+ </layout>
91
+ <translate>
92
+ <modules>
93
+ <TIG_MyParcel2014>
94
+ <files>
95
+ <default>TIG_MyParcel2014.csv</default>
96
+ </files>
97
+ </TIG_MyParcel2014>
98
+ </modules>
99
+ </translate>
100
+ <events>
101
+ <controller_action_layout_render_before_adminhtml_system_config_edit>
102
+ <observers>
103
+ <!-- Add 'download logs' button to system > config -->
104
+ <myparcel_add_download_log_button>
105
+ <type>model</type>
106
+ <class>tig_myparcel/adminhtml_observer_systemConfig</class>
107
+ <method>addDownloadLogButton</method>
108
+ </myparcel_add_download_log_button>
109
+ </observers>
110
+ </controller_action_layout_render_before_adminhtml_system_config_edit>
111
+ <controller_action_predispatch_adminhtml_sales_order_shipment_save>
112
+ <observers>
113
+ <!-- Registers the myparcel consignment options the user selected on the sales_order_shipment_new page -->
114
+ <tig_myparcel_shipment_save>
115
+ <type>model</type>
116
+ <class>tig_myparcel/observer_saveShipment</class>
117
+ <method>registerConsignmentOption</method>
118
+ </tig_myparcel_shipment_save>
119
+ </observers>
120
+ </controller_action_predispatch_adminhtml_sales_order_shipment_save>
121
+ <adminhtml_block_html_before>
122
+ <observers>
123
+ <!-- Adds a massaction the grid that allows merchants to print shipping labels for selected orders-->
124
+ <tig_myparcel_adminhtml_ordergrid>
125
+ <type>singleton</type>
126
+ <class>tig_myparcel/adminhtml_observer_orderGrid</class>
127
+ <method>modifyGrid</method>
128
+ </tig_myparcel_adminhtml_ordergrid>
129
+ </observers>
130
+ </adminhtml_block_html_before>
131
+ </events>
132
+ </adminhtml>
133
+ <frontend>
134
+ <routers>
135
+ <tig_myparcel>
136
+ <use>standard</use>
137
+ <args>
138
+ <module>TIG_MyParcel2014</module>
139
+ <frontName>myparcel2014</frontName>
140
+ </args>
141
+ </tig_myparcel>
142
+ </routers>
143
+ <layout>
144
+ <updates>
145
+ <tig_myparcel>
146
+ <file>TIG/tig_myparcel.xml</file>
147
+ </tig_myparcel>
148
+ </updates>
149
+ </layout>
150
+ <translate>
151
+ <modules>
152
+ <TIG_MyParcel2014>
153
+ <files>
154
+ <default>TIG_MyParcel2014.csv</default>
155
+ </files>
156
+ </TIG_MyParcel2014>
157
+ </modules>
158
+ </translate>
159
+ <events>
160
+ <controller_action_postdispatch_checkout_onepage_saveShippingMethod>
161
+ <observers>
162
+ <!-- Saves a selected PG address for Onepage checkout. -->
163
+ <tig_myparcel_save_pg_address>
164
+ <type>singleton</type>
165
+ <class>tig_myparcel/observer_savePgAddress</class>
166
+ <method>savePgAddress</method>
167
+ </tig_myparcel_save_pg_address>
168
+ </observers>
169
+ </controller_action_postdispatch_checkout_onepage_saveShippingMethod>
170
+ <controller_action_postdispatch_onestepcheckout_index_index>
171
+ <observers>
172
+ <!-- Saves a selected PG address for OneStepCheckout. -->
173
+ <tig_myparcel_save_pg_address>
174
+ <type>singleton</type>
175
+ <class>tig_myparcel/observer_savePgAddress</class>
176
+ <method>savePgAddress</method>
177
+ </tig_myparcel_save_pg_address>
178
+ </observers>
179
+ </controller_action_postdispatch_onestepcheckout_index_index>
180
+ </events>
181
+ </frontend>
182
+
183
+ <crontab>
184
+ <jobs>
185
+ <!-- checks the statusses of all consignments that do not have the status "is_final" -->
186
+ <tig_myparcel_check_status>
187
+ <!-- the cron expression is generated at installation -->
188
+ <run>
189
+ <model>tig_myparcel/observer_cron::checkStatus</model>
190
+ </run>
191
+ </tig_myparcel_check_status>
192
+ </jobs>
193
+ </crontab>
194
+
195
+ <default>
196
+ <carriers>
197
+ <tig_myparcel>
198
+ <active>0</active>
199
+ <model>tig_myparcel/carrier_myParcel</model>
200
+ <title>MyParcel Shipping</title>
201
+ <rate_type>flat</rate_type>
202
+ <pakjegemak_active>0</pakjegemak_active>
203
+ <pakjegemak_fee>0</pakjegemak_fee>
204
+ <sort_order>10</sort_order>
205
+ <sallowspecific>0</sallowspecific>
206
+ </tig_myparcel>
207
+ </carriers>
208
+ <tig_myparcel>
209
+ <api>
210
+ <username/>
211
+ <key/>
212
+ </api>
213
+ <general>
214
+ <url>http://www.myparcel.nl</url>
215
+ <active>0</active>
216
+ <test>0</test>
217
+ <print_orientation>A4</print_orientation>
218
+ </general>
219
+ <shipment>
220
+ <home_address_only>0</home_address_only>
221
+ <signature_on_receipt>0</signature_on_receipt>
222
+ <return_if_no_answer>0</return_if_no_answer>
223
+ <insured_50>0</insured_50>
224
+ <insured_250>0</insured_250>
225
+ <insured_500>0</insured_500>
226
+ <customs_type>Commercial Goods</customs_type>
227
+ <customs_hstariffnr></customs_hstariffnr>
228
+ <split_street>1</split_street> <!-- split street -->
229
+ <streetname_field>1</streetname_field> <!-- first address line -->
230
+ <housenr_field>2</housenr_field> <!-- second address line -->
231
+ <split_housenr>0</split_housenr> <!-- do not split housenumber and houndenumber extension -->
232
+ <housenr_extension_field>3</housenr_extension_field> <!-- third address line (not used, since split_housenr is disabled) -->
233
+ </shipment>
234
+ </tig_myparcel>
235
+ </default>
236
+
237
+ <!-- Custom TiG config values -->
238
+ <tig>
239
+ <!-- Version compatibility per Magento edition as well as PHP version compatibility -->
240
+ <compatibility>
241
+ <tig_myparcel>
242
+ <community>1.6,1.7,1.8,1.9</community>
243
+ <php>5.3,5.4</php>
244
+ </tig_myparcel>
245
+ </compatibility>
246
+
247
+ <!-- Stability of this release -->
248
+ <stability>
249
+ <tig_myparcel>stable</tig_myparcel>
250
+ </stability>
251
+
252
+ <!-- A list of possible error codes recognized by this extension. Each error has a default message, a link to
253
+ the associated knowledge base article and a 'type' (whether it's an error, warning or notice) -->
254
+ <errors>
255
+ <MYPA-0001>
256
+ <message>Please select one or more shipments.</message>
257
+ <url/>
258
+ <type>error</type>
259
+ </MYPA-0001>
260
+ <MYPA-0002>
261
+ <message>Please select one or more orders.</message>
262
+ <url/>
263
+ <type>error</type>
264
+ </MYPA-0002>
265
+ <MYPA-0003>
266
+ <message>This action is not available for shipment #%s, because it was not shipped using MyParcel.</message>
267
+ <url/>
268
+ <type>error</type>
269
+ </MYPA-0003>
270
+ <MYPA-0004>
271
+ <message>Order #%s cannot be shipped at this time.</message>
272
+ <url/>
273
+ <type>error</type>
274
+ </MYPA-0004>
275
+ <MYPA-0005>
276
+ <message>Invalid full street supplied: %s.</message>
277
+ <url/>
278
+ <type>error</type>
279
+ </MYPA-0005>
280
+ <MYPA-0006>
281
+ <message>Invalid housnumber supplied: %s.</message>
282
+ <url/>
283
+ <type>error</type>
284
+ </MYPA-0006>
285
+ <MYPA-0007>
286
+ <message>Invalid session requested.</message>
287
+ <url/>
288
+ <type>error</type>
289
+ </MYPA-0007>
290
+ <MYPA-0008>
291
+ <message>Invalid message type requested: %s.</message>
292
+ <url/>
293
+ <type>error</type>
294
+ </MYPA-0008>
295
+ <MYPA-0009>
296
+ <message>No message supplied.</message>
297
+ <url/>
298
+ <type>error</type>
299
+ </MYPA-0009>
300
+ <MYPA-0010>
301
+ <message>No message type supplied.</message>
302
+ <url/>
303
+ <type>error</type>
304
+ </MYPA-0010>
305
+ <MYPA-0011>
306
+ <message>The createConsignment action is currently unavailable.</message>
307
+ <url/>
308
+ <type>error</type>
309
+ </MYPA-0011>
310
+ <MYPA-0012>
311
+ <message>Invalid createConsignment response.</message>
312
+ <url/>
313
+ <type>error</type>
314
+ </MYPA-0012>
315
+ <MYPA-0013>
316
+ <message>Unable to add tracking info: no track&amp;trace code or shipment available.</message>
317
+ <url/>
318
+ <type>error</type>
319
+ </MYPA-0013>
320
+ <MYPA-0014>
321
+ <message>Unknown rate type specified: %s.</message>
322
+ <url/>
323
+ <type>error</type>
324
+ </MYPA-0014>
325
+ <MYPA-0015>
326
+ <message>Invalid argument supplied. A valid PakjeGemak address must contain at least a company name, city, country code, street and zipcode.</message>
327
+ <url/>
328
+ <type>error</type>
329
+ </MYPA-0015>
330
+ <MYPA-0016>
331
+ <message>Invalid PakjeGemak address.</message>
332
+ <url/>
333
+ <type>error</type>
334
+ </MYPA-0016>
335
+ <MYPA-0017>
336
+ <message>Invalid phone number.</message>
337
+ <url/>
338
+ <type>error</type>
339
+ </MYPA-0017>
340
+ <MYPA-0018>
341
+ <message>Invalid housenumber extension.</message>
342
+ <url/>
343
+ <type>error</type>
344
+ </MYPA-0018>
345
+ <MYPA-0019>
346
+ <message>Unable to send track and trace email for shipment #%s</message>
347
+ <url/>
348
+ <type>error</type>
349
+ </MYPA-0019>
350
+ <MYPA-0020>
351
+ <message>Retourlink is not created, check the log files for details.</message>
352
+ <url/>
353
+ <type>error</type>
354
+ </MYPA-0020>
355
+ <MYPA-0021>
356
+ <message>Credit has not been created, check MyParcel backend for details</message>
357
+ <url/>
358
+ <type>notice</type>
359
+ </MYPA-0021>
360
+ <MYPA-0022>
361
+ <message>Unable to save check_status cron expression: %s</message>
362
+ <url/>
363
+ <type>error</type>
364
+ </MYPA-0022>
365
+ </errors>
366
+ </tig>
367
+ </config>
app/code/community/TIG/MyParcel2014/etc/system.xml ADDED
@@ -0,0 +1,425 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0" encoding="UTF-8"?>
2
+ <config>
3
+ <sections>
4
+ <!-- add MyParcel shipping method to the shipping-methods list -->
5
+ <carriers translate="label" module="shipping">
6
+ <groups>
7
+ <tig_myparcel translate="label">
8
+ <label>MyParcel</label>
9
+ <frontend_type>text</frontend_type>
10
+ <sort_order>0</sort_order>
11
+ <show_in_default>1</show_in_default>
12
+ <show_in_website>1</show_in_website>
13
+ <show_in_store>1</show_in_store>
14
+ <fields>
15
+ <active translate="label" module="tig_myparcel">
16
+ <label>Enabled</label>
17
+ <frontend_type>select</frontend_type>
18
+ <source_model>tig_myparcel/system_config_source_yesno</source_model>
19
+ <sort_order>10</sort_order>
20
+ <show_in_default>1</show_in_default>
21
+ <show_in_website>1</show_in_website>
22
+ <show_in_store>0</show_in_store>
23
+ </active>
24
+ <title translate="label" module="tig_myparcel">
25
+ <label>Title</label>
26
+ <frontend_type>text</frontend_type>
27
+ <sort_order>20</sort_order>
28
+ <show_in_default>1</show_in_default>
29
+ <show_in_website>1</show_in_website>
30
+ <show_in_store>1</show_in_store>
31
+ </title>
32
+ <name translate="label" module="tig_myparcel">
33
+ <label>Method Name</label>
34
+ <frontend_type>text</frontend_type>
35
+ <sort_order>30</sort_order>
36
+ <show_in_default>1</show_in_default>
37
+ <show_in_website>1</show_in_website>
38
+ <show_in_store>1</show_in_store>
39
+ </name>
40
+ <rate_type translate="label" module="tig_myparcel">
41
+ <label>Rate Type</label>
42
+ <frontend_type>select</frontend_type>
43
+ <source_model>tig_myparcel/carrier_system_config_source_rateType</source_model>
44
+ <sort_order>40</sort_order>
45
+ <show_in_default>1</show_in_default>
46
+ <show_in_website>1</show_in_website>
47
+ <show_in_store>0</show_in_store>
48
+ </rate_type>
49
+ <!-- flat rate settings -->
50
+ <type translate="label" module="tig_myparcel">
51
+ <label>Type</label>
52
+ <frontend_type>select</frontend_type>
53
+ <source_model>adminhtml/system_config_source_shipping_flatrate</source_model>
54
+ <sort_order>50</sort_order>
55
+ <show_in_default>1</show_in_default>
56
+ <show_in_website>1</show_in_website>
57
+ <show_in_store>0</show_in_store>
58
+ <depends>
59
+ <rate_type>flat</rate_type>
60
+ </depends>
61
+ </type>
62
+ <price translate="label" module="tig_myparcel">
63
+ <label>Price</label>
64
+ <frontend_type>text</frontend_type>
65
+ <validate>validate-number validate-zero-or-greater</validate>
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>0</show_in_store>
70
+ <depends>
71
+ <rate_type>flat</rate_type>
72
+ </depends>
73
+ </price>
74
+ <!-- tablerates settings -->
75
+ <condition_name translate="label" module="tig_myparcel">
76
+ <label>Condition</label>
77
+ <frontend_type>select</frontend_type>
78
+ <source_model>adminhtml/system_config_source_shipping_tablerate</source_model>
79
+ <sort_order>70</sort_order>
80
+ <show_in_default>1</show_in_default>
81
+ <show_in_website>1</show_in_website>
82
+ <show_in_store>0</show_in_store>
83
+ <depends>
84
+ <rate_type>table</rate_type>
85
+ </depends>
86
+ </condition_name>
87
+ <!-- handling fee's -->
88
+ <handling_type translate="label" module="tig_myparcel">
89
+ <label>Calculate Handling Fee</label>
90
+ <frontend_type>select</frontend_type>
91
+ <source_model>shipping/source_handlingType</source_model>
92
+ <sort_order>80</sort_order>
93
+ <show_in_default>1</show_in_default>
94
+ <show_in_website>1</show_in_website>
95
+ <show_in_store>0</show_in_store>
96
+ </handling_type>
97
+ <handling_fee translate="label" module="tig_myparcel">
98
+ <label>Handling Fee</label>
99
+ <frontend_type>text</frontend_type>
100
+ <validate>validate-number validate-zero-or-greater</validate>
101
+ <sort_order>90</sort_order>
102
+ <show_in_default>1</show_in_default>
103
+ <show_in_website>1</show_in_website>
104
+ <show_in_store>0</show_in_store>
105
+ </handling_fee>
106
+ <!-- pakjegemak settings -->
107
+ <pakjegemak_active translate="label" module="tig_myparcel">
108
+ <label>Pakjegemak active</label>
109
+ <frontend_type>select</frontend_type>
110
+ <source_model>tig_myparcel/system_config_source_yesno</source_model>
111
+ <sort_order>100</sort_order>
112
+ <show_in_default>1</show_in_default>
113
+ <show_in_website>1</show_in_website>
114
+ <show_in_store>0</show_in_store>
115
+ </pakjegemak_active>
116
+ <pakjegemak_fee translate="label" module="tig_myparcel">
117
+ <label>Pakjegemak fee</label>
118
+ <comment>This will be added to the regular shipping price</comment>
119
+ <frontend_type>text</frontend_type>
120
+ <validate>validate-number validate-zero-or-greater</validate>
121
+ <sort_order>110</sort_order>
122
+ <show_in_default>1</show_in_default>
123
+ <show_in_website>1</show_in_website>
124
+ <show_in_store>0</show_in_store>
125
+ <depends>
126
+ <pakjegemak_active>1</pakjegemak_active>
127
+ </depends>
128
+ </pakjegemak_fee>
129
+ <!-- allow specific countries -->
130
+ <sallowspecific translate="label" module="tig_myparcel">
131
+ <label>Ship to Applicable Countries</label>
132
+ <frontend_type>select</frontend_type>
133
+ <sort_order>120</sort_order>
134
+ <frontend_class>shipping-applicable-country</frontend_class>
135
+ <source_model>adminhtml/system_config_source_shipping_allspecificcountries</source_model>
136
+ <show_in_default>1</show_in_default>
137
+ <show_in_website>1</show_in_website>
138
+ <show_in_store>0</show_in_store>
139
+ </sallowspecific>
140
+ <specificcountry translate="label" module="tig_myparcel">
141
+ <label>Ship to Specific Countries</label>
142
+ <frontend_type>multiselect</frontend_type>
143
+ <sort_order>130</sort_order>
144
+ <source_model>adminhtml/system_config_source_country</source_model>
145
+ <show_in_default>1</show_in_default>
146
+ <show_in_website>1</show_in_website>
147
+ <show_in_store>0</show_in_store>
148
+ <can_be_empty>1</can_be_empty>
149
+ </specificcountry>
150
+ <sort_order translate="label" module="tig_myparcel">
151
+ <label>Sort Order</label>
152
+ <frontend_type>text</frontend_type>
153
+ <sort_order>140</sort_order>
154
+ <show_in_default>1</show_in_default>
155
+ <show_in_website>1</show_in_website>
156
+ <show_in_store>0</show_in_store>
157
+ </sort_order>
158
+ </fields>
159
+ </tig_myparcel>
160
+ </groups>
161
+ </carriers>
162
+ <!-- add the configuration page as seperate page to the backend -->
163
+ <tig_myparcel translate="label" module="tig_myparcel">
164
+ <label>MyParcel</label>
165
+ <tab>sales</tab>
166
+ <frontend_type>text</frontend_type>
167
+ <class>tig_myparcel-tab</class>
168
+ <sort_order>330</sort_order>
169
+ <show_in_default>1</show_in_default>
170
+ <show_in_website>1</show_in_website>
171
+ <show_in_store>1</show_in_store>
172
+ <groups>
173
+ <myparcel_support translate="label" module="tig_myparcel">
174
+ <label><![CDATA[Version &amp; Support]]></label>
175
+ <sort_order>10</sort_order>
176
+ <show_in_default>1</show_in_default>
177
+ <show_in_website>1</show_in_website>
178
+ <show_in_store>1</show_in_store>
179
+ <fields>
180
+ <support>
181
+ <sort_order>10</sort_order>
182
+ <frontend_model>tig_myparcel/adminhtml_system_config_supportTab</frontend_model>
183
+ <show_in_default>1</show_in_default>
184
+ <show_in_website>1</show_in_website>
185
+ <show_in_store>1</show_in_store>
186
+ </support>
187
+ </fields>
188
+ </myparcel_support>
189
+ <api translate="label comment" module="tig_myparcel">
190
+ <label>API settings</label>
191
+ <sort_order>20</sort_order>
192
+ <show_in_default>1</show_in_default>
193
+ <show_in_website>1</show_in_website>
194
+ <show_in_store>1</show_in_store>
195
+ <comment>To get your personal API credentials you should contact MyParcel.</comment>
196
+ <fields>
197
+ <username translate="label comment">
198
+ <label>API Username</label>
199
+ <comment>Your MyParcel username.</comment>
200
+ <frontend_type>text</frontend_type>
201
+ <sort_order>10</sort_order>
202
+ <show_in_default>1</show_in_default>
203
+ <show_in_website>1</show_in_website>
204
+ <show_in_store>1</show_in_store>
205
+ </username>
206
+ <key translate="label comment">
207
+ <label>API Key</label>
208
+ <comment>The API Key given by MyParcel.</comment>
209
+ <frontend_type>obscure</frontend_type>
210
+ <backend_model>adminhtml/system_config_backend_encrypted</backend_model>
211
+ <sort_order>20</sort_order>
212
+ <show_in_default>1</show_in_default>
213
+ <show_in_website>1</show_in_website>
214
+ <show_in_store>1</show_in_store>
215
+ </key>
216
+ </fields>
217
+ </api>
218
+ <general translate="label" module="tig_myparcel">
219
+ <label>General Settings</label>
220
+ <sort_order>30</sort_order>
221
+ <show_in_default>1</show_in_default>
222
+ <show_in_website>1</show_in_website>
223
+ <show_in_store>1</show_in_store>
224
+ <fields>
225
+ <!--
226
+ <url translate="label comment">
227
+ <label>Service url</label>
228
+ <frontend_type>text</frontend_type>
229
+ <sort_order>1</sort_order>
230
+ <show_in_default>1</show_in_default>
231
+ <show_in_website>1</show_in_website>
232
+ <show_in_store>1</show_in_store>
233
+ </url>
234
+ -->
235
+ <active translate="label comment tooltip">
236
+ <label>Enable Myparcel Extension</label>
237
+ <comment>Enable or disable the MyParcel module.</comment>
238
+ <tooltip>Selecting 'No' will overrule all individual settings.</tooltip>
239
+ <frontend_type>select</frontend_type>
240
+ <source_model>tig_myparcel/system_config_source_yesno</source_model>
241
+ <sort_order>10</sort_order>
242
+ <show_in_default>1</show_in_default>
243
+ <show_in_website>1</show_in_website>
244
+ <show_in_store>1</show_in_store>
245
+ </active>
246
+ <print_orientation translate="label comment">
247
+ <label>Print Orientation</label>
248
+ <comment>Select a standard orientation for printing labels.</comment>
249
+ <frontend_type>select</frontend_type>
250
+ <source_model>tig_myparcel/system_config_source_a4a6</source_model>
251
+ <sort_order>30</sort_order>
252
+ <show_in_default>1</show_in_default>
253
+ <show_in_website>1</show_in_website>
254
+ <show_in_store>1</show_in_store>
255
+ </print_orientation>
256
+ <tracktrace_template translate="label comment tooltip">
257
+ <label>Track&amp;Trace email template</label>
258
+ <comment>You can create a new transactional e-mail where the variables {{var tracktrace_url}} and {{var retourlabel_url}} are available. TIP: You can base them on the Order Update template, because {{var order}} is also available.</comment>
259
+ <tooltip>Select a transactional e-mail template to send the barcode</tooltip>
260
+ <frontend_type>select</frontend_type>
261
+ <source_model>adminhtml/system_config_source_email_template</source_model>
262
+ <sort_order>50</sort_order>
263
+ <show_in_default>1</show_in_default>
264
+ <show_in_website>1</show_in_website>
265
+ <show_in_store>1</show_in_store>
266
+ </tracktrace_template>
267
+ </fields>
268
+ </general>
269
+ <shipment translate="label comment" module="tig_myparcel">
270
+ <label>Default Shipment Settings</label>
271
+ <sort_order>40</sort_order>
272
+ <show_in_default>1</show_in_default>
273
+ <show_in_website>1</show_in_website>
274
+ <show_in_store>1</show_in_store>
275
+ <comment><![CDATA[Fill in your preferences for a shipment. These settings will only apply for the mass actions in the order grid. When creating a single shipment, these settings can be changed manually.<br/>These settings will activate based on the order total amount. When shipping outside of the EU you can set default values for customs type and customs goods HS code.]]></comment>
276
+ <fields>
277
+ <home_address_only translate="label comment">
278
+ <label>Home address only</label>
279
+ <comment>Shipments will not be delivered at the neighbours, only on house address.</comment>
280
+ <frontend_type>text</frontend_type>
281
+ <validate>validate-number validate-zero-or-greater</validate>
282
+ <sort_order>10</sort_order>
283
+ <show_in_default>1</show_in_default>
284
+ <show_in_website>1</show_in_website>
285
+ <show_in_store>1</show_in_store>
286
+ </home_address_only>
287
+ <signature_on_receipt translate="label comment">
288
+ <label>Signature on receipt</label>
289
+ <frontend_type>text</frontend_type>
290
+ <validate>validate-number validate-zero-or-greater</validate>
291
+ <sort_order>20</sort_order>
292
+ <show_in_default>1</show_in_default>
293
+ <show_in_website>1</show_in_website>
294
+ <show_in_store>1</show_in_store>
295
+ </signature_on_receipt>
296
+ <return_if_no_answer translate="label comment">
297
+ <label>Return if no answer</label>
298
+ <comment>Shipments will not go the a pickup point but will be returned directly after multiple delivery attempts.</comment>
299
+ <frontend_type>text</frontend_type>
300
+ <validate>validate-number validate-zero-or-greater</validate>
301
+ <sort_order>30</sort_order>
302
+ <show_in_default>1</show_in_default>
303
+ <show_in_website>1</show_in_website>
304
+ <show_in_store>1</show_in_store>
305
+ </return_if_no_answer>
306
+ <insured_50 translate="label comment">
307
+ <label><![CDATA[Insured up to &euro; 50]]></label>
308
+ <comment>For NL shipping only</comment>
309
+ <frontend_type>text</frontend_type>
310
+ <validate>validate-number validate-zero-or-greater</validate>
311
+ <sort_order>40</sort_order>
312
+ <show_in_default>1</show_in_default>
313
+ <show_in_website>1</show_in_website>
314
+ <show_in_store>1</show_in_store>
315
+ </insured_50>
316
+ <insured_250 translate="label comment">
317
+ <label><![CDATA[Insured up to &euro; 250]]></label>
318
+ <comment><![CDATA[For NL shipping only, shipments outside the EU insured default is &euro; 200]]></comment>
319
+ <frontend_type>text</frontend_type>
320
+ <validate>validate-number validate-zero-or-greater</validate>
321
+ <sort_order>50</sort_order>
322
+ <show_in_default>1</show_in_default>
323
+ <show_in_website>1</show_in_website>
324
+ <show_in_store>1</show_in_store>
325
+ </insured_250>
326
+ <insured_500 translate="label comment">
327
+ <label><![CDATA[Insured up to &euro; 500]]></label>
328
+ <comment><![CDATA[For NL shipping only, shipments inside the EU insured default is &euro; 500]]></comment>
329
+ <frontend_type>text</frontend_type>
330
+ <validate>validate-number validate-zero-or-greater</validate>
331
+ <sort_order>60</sort_order>
332
+ <show_in_default>1</show_in_default>
333
+ <show_in_website>1</show_in_website>
334
+ <show_in_store>1</show_in_store>
335
+ </insured_500>
336
+ <customs_type translate="label comment">
337
+ <label>Customs Shipment Type</label>
338
+ <comment>Default shipment type for Cross Domestic shipments</comment>
339
+ <frontend_type>select</frontend_type>
340
+ <source_model>tig_myparcel/system_config_source_customs</source_model>
341
+ <sort_order>70</sort_order>
342
+ <show_in_default>1</show_in_default>
343
+ <show_in_website>1</show_in_website>
344
+ <show_in_store>1</show_in_store>
345
+ </customs_type>
346
+ <customs_hstariffnr translate="label comment">
347
+ <label>Customs Content HS Code</label>
348
+ <comment><![CDATA[Default content type for Cross Domestic products, see <a href="http://gebruikstarief.douane.nl" target="_blank">http://gebruikstarief.douane.nl</a>]]></comment>
349
+ <frontend_type>text</frontend_type>
350
+ <validate>validate-number validate-zero-or-greater</validate>
351
+ <sort_order>80</sort_order>
352
+ <show_in_default>1</show_in_default>
353
+ <show_in_website>1</show_in_website>
354
+ <show_in_store>1</show_in_store>
355
+ </customs_hstariffnr>
356
+ <split_street translate="label comment">
357
+ <label>Split street parts</label>
358
+ <comment>If you do not use split street lines and you wish to ship to outside the EU, there is a strong possibility that MyParcel will be unable to properly parse the address. This may result in the shipment being refused or it may even lead to the shipment being delivered at the wrong address!</comment>
359
+ <frontend_type>select</frontend_type>
360
+ <source_model>tig_myparcel/system_config_source_yesno</source_model>
361
+ <sort_order>90</sort_order>
362
+ <show_in_default>1</show_in_default>
363
+ <show_in_website>1</show_in_website>
364
+ <show_in_store>0</show_in_store>
365
+ <validate>validate-select</validate>
366
+ </split_street>
367
+ <streetname_field translate="label">
368
+ <label>Streetname field</label>
369
+ <frontend_type>select</frontend_type>
370
+ <source_model>tig_myparcel/system_config_source_streetField</source_model>
371
+ <sort_order>100</sort_order>
372
+ <show_in_default>1</show_in_default>
373
+ <show_in_website>1</show_in_website>
374
+ <show_in_store>0</show_in_store>
375
+ <depends>
376
+ <split_street>1</split_street>
377
+ </depends>
378
+ <validate>validate-select</validate>
379
+ </streetname_field>
380
+ <housenr_field translate="label">
381
+ <label>Housenr. field</label>
382
+ <frontend_type>select</frontend_type>
383
+ <source_model>tig_myparcel/system_config_source_streetField</source_model>
384
+ <sort_order>110</sort_order>
385
+ <show_in_default>1</show_in_default>
386
+ <show_in_website>1</show_in_website>
387
+ <show_in_store>0</show_in_store>
388
+ <depends>
389
+ <split_street>1</split_street>
390
+ </depends>
391
+ <validate>validate-select</validate>
392
+ </housenr_field>
393
+ <split_housenr translate="label">
394
+ <label>Split house number parts</label>
395
+ <frontend_type>select</frontend_type>
396
+ <source_model>tig_myparcel/system_config_source_yesno</source_model>
397
+ <sort_order>120</sort_order>
398
+ <show_in_default>1</show_in_default>
399
+ <show_in_website>1</show_in_website>
400
+ <show_in_store>0</show_in_store>
401
+ <depends>
402
+ <split_street>1</split_street>
403
+ </depends>
404
+ <validate>validate-select</validate>
405
+ </split_housenr>
406
+ <housenr_extension_field translate="label">
407
+ <label>Housenr. extension field</label>
408
+ <frontend_type>select</frontend_type>
409
+ <source_model>tig_myparcel/system_config_source_streetField</source_model>
410
+ <sort_order>130</sort_order>
411
+ <show_in_default>1</show_in_default>
412
+ <show_in_website>1</show_in_website>
413
+ <show_in_store>0</show_in_store>
414
+ <depends>
415
+ <split_street>1</split_street>
416
+ <split_housenr>1</split_housenr>
417
+ </depends>
418
+ <validate>validate-select</validate>
419
+ </housenr_extension_field>
420
+ </fields>
421
+ </shipment>
422
+ </groups>
423
+ </tig_myparcel>
424
+ </sections>
425
+ </config>
app/code/community/TIG/MyParcel2014/sql/tig_myparcel_setup/install-0.1.0.php ADDED
@@ -0,0 +1,181 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * ___________ __ __
4
+ * \__ ___/____ _/ |_ _____ | |
5
+ * | | / _ \\ __\\__ \ | |
6
+ * | | | |_| || | / __ \_| |__
7
+ * |____| \____/ |__| (____ /|____/
8
+ * \/
9
+ * ___ __ __
10
+ * | | ____ _/ |_ ____ _______ ____ ____ _/ |_
11
+ * | | / \\ __\_/ __ \\_ __ \ / \ _/ __ \\ __\
12
+ * | || | \| | \ ___/ | | \/| | \\ ___/ | |
13
+ * |___||___| /|__| \_____>|__| |___| / \_____>|__|
14
+ * \/ \/
15
+ * ________
16
+ * / _____/_______ ____ __ __ ______
17
+ * / \ ___\_ __ \ / _ \ | | \\____ \
18
+ * \ \_\ \| | \/| |_| || | /| |_| |
19
+ * \______ /|__| \____/ |____/ | __/
20
+ * \/ |__|
21
+ *
22
+ * NOTICE OF LICENSE
23
+ *
24
+ * This source file is subject to the Creative Commons License.
25
+ * It is available through the world-wide-web at this URL:
26
+ * http://creativecommons.org/licenses/by-nc-nd/3.0/nl/deed.en_US
27
+ * If you are unable to obtain it through the world-wide-web, please send an email
28
+ * to servicedesk@tig.nl so we can send you a copy immediately.
29
+ *
30
+ * DISCLAIMER
31
+ *
32
+ * Do not edit or add to this file if you wish to upgrade this module to newer
33
+ * versions in the future. If you wish to customize this module for your
34
+ * needs please contact servicedesk@tig.nl for more information.
35
+ *
36
+ * @copyright Copyright (c) 2013 Total Internet Group B.V. (http://www.totalinternetgroup.nl)
37
+ * @license http://creativecommons.org/licenses/by-nc-nd/3.0/nl/deed.en_US
38
+ */
39
+
40
+ /* @var $installer Mage_Core_Model_Resource_Setup */
41
+ $installer = $this;
42
+
43
+ $installer->startSetup();
44
+
45
+ //add tables
46
+ $tableName = $installer->getTable('tig_myparcel/shipment');
47
+
48
+ if (!$conn->isTableExists($tableName)) {
49
+ $tigMyparcelShipmentTable = $installer->getConnection()
50
+ ->newTable($tableName)
51
+ /**
52
+ * Entity ID
53
+ */
54
+ ->addColumn('entity_id', Varien_Db_Ddl_Table::TYPE_INTEGER, 10, array(
55
+ 'identity' => true,
56
+ 'unsigned' => true,
57
+ 'nullable' => false,
58
+ 'primary' => true,
59
+ ), 'Entity Id')
60
+ /**
61
+ * Mage_Sales_Model_Order_Shipment ID
62
+ */
63
+ ->addColumn('shipment_id', Varien_Db_Ddl_Table::TYPE_INTEGER, 10, array(
64
+ 'unsigned' => true,
65
+ 'nullable' => true,
66
+ ), 'Shipment Id')
67
+ /**
68
+ * Mage_Sales_Model_Order ID
69
+ */
70
+ ->addColumn('order_id', Varien_Db_Ddl_Table::TYPE_INTEGER, 10, array(
71
+ 'unsigned' => true,
72
+ 'nullable' => true,
73
+ ), 'Order Id')
74
+ /**
75
+ * MyParcel consignment ID
76
+ */
77
+ ->addColumn('consignment_id', Varien_Db_Ddl_Table::TYPE_INTEGER, 10, array(
78
+ 'unsigned' => true,
79
+ 'nullable' => true,
80
+ ), 'Consignment Id')
81
+ /**
82
+ * Created at timestamp
83
+ */
84
+ ->addColumn('created_at', Varien_Db_Ddl_Table::TYPE_TIMESTAMP, null, array(
85
+ 'nullable' => false,
86
+ ), 'Created At')
87
+ /**
88
+ * Updated at timestamp
89
+ */
90
+ ->addColumn('updated_at', Varien_Db_Ddl_Table::TYPE_TIMESTAMP, null, array(
91
+ 'nullable' => false,
92
+ ), 'Updated At')
93
+ /**
94
+ * the shipment's current confirm status
95
+ */
96
+ ->addColumn('status', Varien_Db_Ddl_Table::TYPE_TEXT, 64, array(
97
+ ), 'Status')
98
+ /**
99
+ * the track and trace code from MyParcel
100
+ */
101
+ ->addColumn('barcode', Varien_Db_Ddl_Table::TYPE_TEXT, 64, array(
102
+ ), 'Barcode')
103
+ /**
104
+ * Whether the shipment should only be delivered to the stated address.
105
+ */
106
+ ->addColumn('home_address_only', Varien_Db_Ddl_Table::TYPE_BOOLEAN, false, array(
107
+ 'unsigned' => true,
108
+ 'default' => '0',
109
+ ), 'Home address only')
110
+ /**
111
+ * Whether a signature is required on delivery.
112
+ */
113
+ ->addColumn('signature_on_receipt', Varien_Db_Ddl_Table::TYPE_BOOLEAN, false, array(
114
+ 'unsigned' => true,
115
+ 'default' => '0',
116
+ ), 'Signature on receipt')
117
+ /**
118
+ * Whether the shipment should be returned if no one is home.
119
+ */
120
+ ->addColumn('return_if_no_answer', Varien_Db_Ddl_Table::TYPE_BOOLEAN, false, array(
121
+ 'unsigned' => true,
122
+ 'default' => '0',
123
+ ), 'Return if no answer')
124
+ /**
125
+ * Whether the shipment is insured.
126
+ */
127
+ ->addColumn('insured', Varien_Db_Ddl_Table::TYPE_BOOLEAN, false, array(
128
+ 'unsigned' => true,
129
+ 'default' => '0',
130
+ ), 'Insured')
131
+ /**
132
+ * The amount for which the shipment is insured.
133
+ */
134
+ ->addColumn('insured_amount', Varien_Db_Ddl_Table::TYPE_INTEGER, 12, array(
135
+ 'unsigned' => true,
136
+ 'default' => '0',
137
+ ), 'Insured amount')
138
+ /**
139
+ * Whether the shipments is final
140
+ */
141
+ ->addColumn('is_final', Varien_Db_Ddl_Table::TYPE_BOOLEAN, false, array(
142
+ 'unsigned' => true,
143
+ 'default' => 0,
144
+ ), 'Is Final')
145
+ /**
146
+ * Whether the barcode-email is send
147
+ */
148
+ ->addColumn('barcode_send', Varien_Db_Ddl_Table::TYPE_BOOLEAN, false, array(
149
+ 'unsigned' => true,
150
+ 'default' => '0',
151
+ ), 'Barcode Send')
152
+ /**
153
+ * The retourlink
154
+ */
155
+ ->addColumn('retourlink', Varien_Db_Ddl_Table::TYPE_TEXT, 255, array(
156
+ ), 'Retourlink')
157
+ /**
158
+ * Whether the consignment is credited
159
+ */
160
+ ->addColumn('is_credit', Varien_Db_Ddl_Table::TYPE_BOOLEAN, false, array(
161
+ 'unsigned' => true,
162
+ 'default' => 0,
163
+ ), 'Is Credit')
164
+ ->addIndex($installer->getIdxName('tig_myparcel/shipment', array('shipment_id'), Varien_Db_Adapter_Interface::INDEX_TYPE_UNIQUE),
165
+ array('shipment_id'),
166
+ array('type' => Varien_Db_Adapter_Interface::INDEX_TYPE_UNIQUE))
167
+ ->addIndex($installer->getIdxName('tig_myparcel/shipment', array('order_id'), Varien_Db_Adapter_Interface::INDEX_TYPE_UNIQUE),
168
+ array('order_id'),
169
+ array('type' => Varien_Db_Adapter_Interface::INDEX_TYPE_INDEX))
170
+ ->addForeignKey($installer->getFkName('tig_myparcel/shipment', 'shipment_id', 'sales/shipment', 'entity_id'),
171
+ 'shipment_id', $installer->getTable('sales/shipment'), 'entity_id',
172
+ Varien_Db_Ddl_Table::ACTION_SET_NULL, Varien_Db_Ddl_Table::ACTION_CASCADE)
173
+ ->addForeignKey($installer->getFkName('tig_myparcel/shipment', 'order_id', 'sales/order', 'entity_id'),
174
+ 'order_id', $installer->getTable('sales/order'), 'entity_id',
175
+ Varien_Db_Ddl_Table::ACTION_SET_NULL, Varien_Db_Ddl_Table::ACTION_CASCADE)
176
+ ->setComment('TIG MyParcel Shipment');
177
+
178
+ $installer->getConnection()->createTable($tigMyparcelShipmentTable);
179
+ }
180
+
181
+ $installer->endSetup();
app/design/adminhtml/default/default/layout/TIG/tig_myparcel.xml ADDED
@@ -0,0 +1,99 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0"?>
2
+ <!--
3
+ /**
4
+ * ___________ __ __
5
+ * \__ ___/____ _/ |_ _____ | |
6
+ * | | / _ \\ __\\__ \ | |
7
+ * | | | |_| || | / __ \_| |__
8
+ * |____| \____/ |__| (____ /|____/
9
+ * \/
10
+ * ___ __ __
11
+ * | | ____ _/ |_ ____ _______ ____ ____ _/ |_
12
+ * | | / \\ __\_/ __ \\_ __ \ / \ _/ __ \\ __\
13
+ * | || | \| | \ ___/ | | \/| | \\ ___/ | |
14
+ * |___||___| /|__| \_____>|__| |___| / \_____>|__|
15
+ * \/ \/
16
+ * ________
17
+ * / _____/_______ ____ __ __ ______
18
+ * / \ ___\_ __ \ / _ \ | | \\____ \
19
+ * \ \_\ \| | \/| |_| || | /| |_| |
20
+ * \______ /|__| \____/ |____/ | __/
21
+ * \/ |__|
22
+ *
23
+ * NOTICE OF LICENSE
24
+ *
25
+ * This source file is subject to the Creative Commons License.
26
+ * It is available through the world-wide-web at this URL:
27
+ * http://creativecommons.org/licenses/by-nc-nd/3.0/nl/deed.en_US
28
+ * If you are unable to obtain it through the world-wide-web, please send an email
29
+ * to servicedesk@tig.nl so we can send you a copy immediately.
30
+ *
31
+ * DISCLAIMER
32
+ *
33
+ * Do not edit or add to this file if you wish to upgrade this module to newer
34
+ * versions in the future. If you wish to customize this module for your
35
+ * needs please contact servicedesk@tig.nl for more information.
36
+ *
37
+ * @copyright Copyright (c) 2014 Total Internet Group B.V. (http://www.totalinternetgroup.nl)
38
+ * @license http://creativecommons.org/licenses/by-nc-nd/3.0/nl/deed.en_US
39
+ */
40
+ -->
41
+ <layout>
42
+ <adminhtml_system_config_edit>
43
+ <reference name="head">
44
+ <action method="addItem">
45
+ <type>skin_css</type>
46
+ <name>css/TIG/MyParcel2014/system_config_edit.css</name>
47
+ </action>
48
+ </reference>
49
+ </adminhtml_system_config_edit>
50
+
51
+ <adminhtml_sales_order_address>
52
+ <reference name="content">
53
+ <block type="core/template"
54
+ name="tig_myparcel_address_warning"
55
+ template="TIG/MyParcel2014/sales/order/address/warning.phtml" />
56
+ </reference>
57
+ </adminhtml_sales_order_address>
58
+
59
+ <adminhtml_sales_order_index>
60
+ <reference name="head">
61
+ <action method="addItem">
62
+ <type>js_css</type>
63
+ <name>prototype/windows/themes/default.css</name>
64
+ </action>
65
+ <action method="addCss">
66
+ <name>lib/prototype/windows/themes/magento.css</name>
67
+ </action>
68
+ </reference>
69
+ <reference name="before_body_end">
70
+ <block type="core/template"
71
+ name="tig_myparcel_order_index"
72
+ template="TIG/MyParcel2014/sales/order/mass_actions.phtml"/>
73
+ </reference>
74
+ </adminhtml_sales_order_index>
75
+
76
+ <adminhtml_sales_order_view>
77
+ <reference name="before_body_end">
78
+ <block type="tig_myparcel/adminhtml_sales_order_view_shippingInfo"
79
+ name="tig_myparcel_order_view_shipping_info"
80
+ template="TIG/MyParcel2014/sales/order/view/shipping_info.phtml"/>
81
+ </reference>
82
+ </adminhtml_sales_order_view>
83
+
84
+ <adminhtml_sales_order_shipment_new>
85
+ <reference name="before_body_end">
86
+ <block type="tig_myparcel/adminhtml_sales_order_shipment_create_consignmentOptions"
87
+ name="tig_myparcel_shipment_create_consignment_options"
88
+ template="TIG/MyParcel2014/sales/order/shipment/create/consignment_options.phtml"/>
89
+ </reference>
90
+ </adminhtml_sales_order_shipment_new>
91
+
92
+ <adminhtml_sales_order_shipment_view>
93
+ <reference name="before_body_end">
94
+ <block type="tig_myparcel/adminhtml_sales_order_shipment_shippingInfo"
95
+ name="tig_myparcel_order_shipment_shipping_info"
96
+ template="TIG/MyParcel2014/sales/order/shipment/shipping_info.phtml"/>
97
+ </reference>
98
+ </adminhtml_sales_order_shipment_view>
99
+ </layout>
app/design/adminhtml/default/default/template/TIG/MyParcel2014/sales/order/address/warning.phtml ADDED
@@ -0,0 +1,50 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * ___________ __ __
4
+ * \__ ___/____ _/ |_ _____ | |
5
+ * | | / _ \\ __\\__ \ | |
6
+ * | | | |_| || | / __ \_| |__
7
+ * |____| \____/ |__| (____ /|____/
8
+ * \/
9
+ * ___ __ __
10
+ * | | ____ _/ |_ ____ _______ ____ ____ _/ |_
11
+ * | | / \\ __\_/ __ \\_ __ \ / \ _/ __ \\ __\
12
+ * | || | \| | \ ___/ | | \/| | \\ ___/ | |
13
+ * |___||___| /|__| \_____>|__| |___| / \_____>|__|
14
+ * \/ \/
15
+ * ________
16
+ * / _____/_______ ____ __ __ ______
17
+ * / \ ___\_ __ \ / _ \ | | \\____ \
18
+ * \ \_\ \| | \/| |_| || | /| |_| |
19
+ * \______ /|__| \____/ |____/ | __/
20
+ * \/ |__|
21
+ *
22
+ * NOTICE OF LICENSE
23
+ *
24
+ * This source file is subject to the Creative Commons License.
25
+ * It is available through the world-wide-web at this URL:
26
+ * http://creativecommons.org/licenses/by-nc-nd/3.0/nl/deed.en_US
27
+ * If you are unable to obtain it through the world-wide-web, please send an email
28
+ * to servicedesk@tig.nl so we can send you a copy immediately.
29
+ *
30
+ * DISCLAIMER
31
+ *
32
+ * Do not edit or add to this file if you wish to upgrade this module to newer
33
+ * versions in the future. If you wish to customize this module for your
34
+ * needs please contact servicedesk@tig.nl for more information.
35
+ *
36
+ * @copyright Copyright (c) 2014 Total Internet Group B.V. (http://www.totalinternetgroup.nl)
37
+ * @license http://creativecommons.org/licenses/by-nc-nd/3.0/nl/deed.en_US
38
+ *
39
+ * @var TIG_MyParcel2014_Block_Adminhtml_Sales_Order_Shipment_ShippingInfo $this
40
+ */
41
+ ?>
42
+ <?php $_helper = Mage::helper('tig_myparcel'); ?>
43
+ <li id="tig_myparcel_address_warning"><?php echo $_helper->__('When changing the address, you need to cancel the current MyParcel shipment(s) linked to this order and create new MyParcel shipments.');?></li>
44
+ <script type="text/javascript">
45
+ //<![CDATA[
46
+ $$('ul.messages li.notice-msg ul')[0].insert({
47
+ bottom: $('tig_myparcel_address_warning')
48
+ });
49
+ //]]>
50
+ </script>
app/design/adminhtml/default/default/template/TIG/MyParcel2014/sales/order/mass_actions.phtml ADDED
@@ -0,0 +1,127 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * ___________ __ __
4
+ * \__ ___/____ _/ |_ _____ | |
5
+ * | | / _ \\ __\\__ \ | |
6
+ * | | | |_| || | / __ \_| |__
7
+ * |____| \____/ |__| (____ /|____/
8
+ * \/
9
+ * ___ __ __
10
+ * | | ____ _/ |_ ____ _______ ____ ____ _/ |_
11
+ * | | / \\ __\_/ __ \\_ __ \ / \ _/ __ \\ __\
12
+ * | || | \| | \ ___/ | | \/| | \\ ___/ | |
13
+ * |___||___| /|__| \_____>|__| |___| / \_____>|__|
14
+ * \/ \/
15
+ * ________
16
+ * / _____/_______ ____ __ __ ______
17
+ * / \ ___\_ __ \ / _ \ | | \\____ \
18
+ * \ \_\ \| | \/| |_| || | /| |_| |
19
+ * \______ /|__| \____/ |____/ | __/
20
+ * \/ |__|
21
+ *
22
+ * NOTICE OF LICENSE
23
+ *
24
+ * This source file is subject to the Creative Commons License.
25
+ * It is available through the world-wide-web at this URL:
26
+ * http://creativecommons.org/licenses/by-nc-nd/3.0/nl/deed.en_US
27
+ * If you are unable to obtain it through the world-wide-web, please send an email
28
+ * to servicedesk@tig.nl so we can send you a copy immediately.
29
+ *
30
+ * DISCLAIMER
31
+ *
32
+ * Do not edit or add to this file if you wish to upgrade this module to newer
33
+ * versions in the future. If you wish to customize this module for your
34
+ * needs please contact servicedesk@tig.nl for more information.
35
+ *
36
+ * @copyright Copyright (c) 2014 Total Internet Group B.V. (http://www.tig.nl)
37
+ * @license http://creativecommons.org/licenses/by-nc-nd/3.0/nl/deed.en_US
38
+ *
39
+ * @var TIG_MyParcel2014_Block_Adminhtml_Sales_Order_Shipment_ShippingInfo $this
40
+ */
41
+ ?>
42
+ <?php if(Mage::helper('tig_myparcel')->getConfig('print_orientation') == 'A4'): ?>
43
+ <div id="print_container" style="display:none;">
44
+ <div id="print_pages">
45
+ <div class="print_page">1</div>
46
+ <div class="print_page">2</div>
47
+ <div class="print_page">3</div>
48
+ <div class="print_page">4</div>
49
+ </div>
50
+ </div>
51
+ <style type="text/css">
52
+ #myparcel_popup_window .magento_w,
53
+ #myparcel_popup_window .magento_e { width:0; }
54
+ #myparcel_popup_window .magento_content { background-image:none; }
55
+ #print_pages { width:200px; height:280px; float:left; }
56
+ #print_pages .print_page { width:90px; height:130px; background:#dfdfdf; margin:10px 0 0 10px; float:left; cursor:pointer; text-indent:-1337px; overflow:hidden; }
57
+ #print_pages .print_page:hover { background:#eb5e00; }
58
+ </style>
59
+ <script type="text/javascript">
60
+ //<![CDATA[
61
+ (function(){
62
+ // create hidden input to store the chosen option
63
+ var inputstart = document.createElement('input');
64
+ inputstart.id = 'myparcel_print_labels_start';
65
+ inputstart.type = 'hidden';
66
+ inputstart.name = 'myparcel_print_labels_start';
67
+ inputstart.value = 1;
68
+ document.getElementById('sales_order_grid_massaction-form').appendChild(inputstart);
69
+
70
+ // monitor the print option and show A4 positions
71
+ $('sales_order_grid_massaction-select').observe('change', function(e, el){
72
+ if($(this).value == 'myparcel_print_labels')
73
+ {
74
+ Dialog.info(null, {
75
+ closable:true,
76
+ resizable:false,
77
+ draggable:true,
78
+ className:'magento',
79
+ windowClassName:'myparcel-popup-window',
80
+ title:'<?php echo $this->__('Select A4 print start position'); ?>',
81
+ top:100,
82
+ width:200,
83
+ height:290,
84
+ zIndex:1337,
85
+ recenterAuto:true,
86
+ hideEffect:Element.hide,
87
+ showEffect:Element.show,
88
+ id:'myparcel_popup_window'
89
+ });
90
+ Dialog.setInfoMessage($('print_container').innerHTML);
91
+
92
+ $('print_pages').show();
93
+
94
+ var printChildren = $('print_pages').childElements();
95
+ for(var i = 0, j = printChildren.length; i < j; i++)
96
+ {
97
+ printChildren[i].observe('mouseover', function(){
98
+ $(this).toggleClassName('hover');
99
+ });
100
+ printChildren[i].observe('mouseout', function(){
101
+ $(this).toggleClassName('hover');
102
+ });
103
+ printChildren[i].observe('click', function(){
104
+ $('myparcel_print_labels_start').value = $(this).innerHTML;
105
+ Windows.close('myparcel_popup_window');
106
+ $$('#sales_order_grid_massaction-form button')[0].click();
107
+ $('sales_order_grid_massaction-select').value = '';
108
+ });
109
+ }
110
+
111
+ $('myparcel_popup_window_close').observe('click', function(){
112
+ $('sales_order_grid_massaction-select')[0].selected = true;
113
+ });
114
+
115
+ // close popup when clicked outside
116
+ setTimeout(function(){
117
+ $('overlay_modal').observe('click', function(){
118
+ $('myparcel_popup_window_close').click();
119
+ $('sales_order_grid_massaction-select')[0].selected = true;
120
+ });
121
+ }, 337);
122
+ }
123
+ });
124
+ })();
125
+ //]]>
126
+ </script>
127
+ <?php endif; ?>
app/design/adminhtml/default/default/template/TIG/MyParcel2014/sales/order/shipment/create/consignment_options.phtml ADDED
@@ -0,0 +1,131 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * ___________ __ __
4
+ * \__ ___/____ _/ |_ _____ | |
5
+ * | | / _ \\ __\\__ \ | |
6
+ * | | | |_| || | / __ \_| |__
7
+ * |____| \____/ |__| (____ /|____/
8
+ * \/
9
+ * ___ __ __
10
+ * | | ____ _/ |_ ____ _______ ____ ____ _/ |_
11
+ * | | / \\ __\_/ __ \\_ __ \ / \ _/ __ \\ __\
12
+ * | || | \| | \ ___/ | | \/| | \\ ___/ | |
13
+ * |___||___| /|__| \_____>|__| |___| / \_____>|__|
14
+ * \/ \/
15
+ * ________
16
+ * / _____/_______ ____ __ __ ______
17
+ * / \ ___\_ __ \ / _ \ | | \\____ \
18
+ * \ \_\ \| | \/| |_| || | /| |_| |
19
+ * \______ /|__| \____/ |____/ | __/
20
+ * \/ |__|
21
+ *
22
+ * NOTICE OF LICENSE
23
+ *
24
+ * This source file is subject to the Creative Commons License.
25
+ * It is available through the world-wide-web at this URL:
26
+ * http://creativecommons.org/licenses/by-nc-nd/3.0/nl/deed.en_US
27
+ * If you are unable to obtain it through the world-wide-web, please send an email
28
+ * to servicedesk@tig.nl so we can send you a copy immediately.
29
+ *
30
+ * DISCLAIMER
31
+ *
32
+ * Do not edit or add to this file if you wish to upgrade this module to newer
33
+ * versions in the future. If you wish to customize this module for your
34
+ * needs please contact servicedesk@tig.nl for more information.
35
+ *
36
+ * @copyright Copyright (c) 2014 Total Internet Group B.V. (http://www.totalinternetgroup.nl)
37
+ * @license http://creativecommons.org/licenses/by-nc-nd/3.0/nl/deed.en_US
38
+ *
39
+ * @var TIG_MyParcel2014_Block_Adminhtml_Sales_Order_Shipment_Create_ConsignmentOptions $this
40
+ */
41
+
42
+ $_countryNeedsCustoms = $this->countryNeedsCustoms();
43
+ $_storeId = $this->getOrderStoreId();
44
+ $_helper = Mage::helper('tig_myparcel');
45
+ $_customsTypeOptions = $this->getCustomsTypeOptions();
46
+ $_defaultCustomsCode = $_helper->getConfig('customs_type', 'shipment', $_storeId);
47
+ $_defaultCustomsContentCode = $_helper->getConfig('customs_hstariffnr', 'shipment', $_storeId);
48
+ $_homeSelected = $this->getIsHomeSelected();
49
+ $_signatureSelected = $this->getIsSignatureOnReceipt();
50
+ $_returnNoAnswerSelected = $this->getIsReturnOnNoAnswer();
51
+ $_insured = $this->getIsInsured();
52
+ $_insuredSelected = '';
53
+ $_insuredAmount = 0;
54
+ if(is_array($_insured)){
55
+ $_insuredAmount = $_insured['insuredAmount'];
56
+ $_insuredSelected = $_insured['selected'];
57
+ }
58
+
59
+ ?>
60
+ <div id="tig_myparcel_consignment_options">
61
+ <p class="normal"><strong><?php echo $this->__('Myparcel Consignment Options');?></strong></p>
62
+ <div id="tig_myparcel_form_container">
63
+ <?php if(!$_countryNeedsCustoms):?>
64
+ <p>
65
+ <label for="tig_myparcel_home_address_only" class="normal"><?php echo $this->__('Home address only');?></label>
66
+ <input id="tig_myparcel_home_address_only" type="checkbox" value="1" name="tig_myparcel[home_address_only]" <?php echo $_homeSelected;?> />
67
+ </p>
68
+ <p>
69
+ <label for="tig_myparcel_signature_on_receipt" class="normal"><?php echo $this->__('Signature on receipt');?></label>
70
+ <input id="tig_myparcel_signature_on_receipt" type="checkbox" value="1" name="tig_myparcel[signature_on_receipt]" <?php echo $_signatureSelected;?> />
71
+ </p>
72
+ <p>
73
+ <label for="tig_myparcel_return_if_no_answer" class="normal"><?php echo $this->__('Return if no answer');?></label>
74
+ <input id="tig_myparcel_return_if_no_answer" type="checkbox" value="1" name="tig_myparcel[return_if_no_answer]" <?php echo $_returnNoAnswerSelected;?> />
75
+ </p>
76
+ <p>
77
+ <label for="tig_myparcel_insured" class="normal"><?php echo $this->__('Insured');?></label>
78
+ <input id="tig_myparcel_insured" type="checkbox" value="1" name="tig_myparcel[insured]" <?php echo $_insuredSelected;?> />
79
+ </p>
80
+ <p style="display:none;">
81
+ <label for="tig_myparcel_insured_amount" class="normal"><?php echo $this->__('Insured amount');?></label>
82
+ <input id="tig_myparcel_insured_amount" class="validate-digits validate-digits-range digits-range-0-5000" type="text" value="<?php echo $_insuredAmount;?>" name="tig_myparcel[insured_amount]" />
83
+ </p>
84
+ <?php endif;?>
85
+ <?php if($_countryNeedsCustoms):?>
86
+ <p>
87
+ <label for="tig_myparcel_customs_type" class="normal"><?php echo $this->__('Customs Shipment Type');?></label>
88
+ <select id="tig_myparcel_customs_type" class="select required-entry" name="tig_myparcel[customs_type]">
89
+ <?php foreach($_customsTypeOptions as $_option):?>
90
+ <?php $_selected = ''; ?>
91
+ <?php if ($_option['value'] == $_defaultCustomsCode): ?>
92
+ <?php $_selected = 'selected="selected"'; ?>
93
+ <?php endif; ?>
94
+
95
+ <option value="<?php echo $_option['value']; ?>" <?php echo $_selected ?>>
96
+ <?php echo $this->__($_option['label']); ?>
97
+ </option>
98
+ <?php endforeach;?>
99
+ </select>
100
+ </p>
101
+ <p>
102
+ <label for="tig_myparcel_customs_content_code" class="normal"><?php echo $this->__('Customs Content HS Code');?></label>
103
+ <input id="tig_myparcel_customs_content_code" type="text" value="<?php echo $_defaultCustomsContentCode;?>" name="tig_myparcel[customs_content_type]" />
104
+ </p>
105
+ <p><small><?php echo $this->__('Select content type for Cross Domestic products, see <a href="http://gebruikstarief.douane.nl" target="_blank">http://gebruikstarief.douane.nl</a>');?></small></p>
106
+ <?php endif;?>
107
+ </div>
108
+ </div>
109
+ <script type ="text/javascript">
110
+ //<![CDATA[
111
+ document.observe('dom:loaded', function() {
112
+ $$('.order-totals-bottom div.a-right')[0].insert({
113
+ before: $('tig_myparcel_consignment_options')
114
+ });
115
+
116
+ var insuredCheckbox = $('tig_myparcel_insured');
117
+ var insuredAmountField = $('tig_myparcel_insured_amount').up();
118
+ if (insuredCheckbox.checked) {
119
+ insuredAmountField.show();
120
+ }
121
+
122
+ insuredCheckbox.observe('click', function() {
123
+ if (insuredCheckbox.checked) {
124
+ insuredAmountField.show();
125
+ } else {
126
+ insuredAmountField.hide();
127
+ }
128
+ });
129
+ });
130
+ //]]>
131
+ </script>
app/design/adminhtml/default/default/template/TIG/MyParcel2014/sales/order/shipment/shipping_info.phtml ADDED
@@ -0,0 +1,86 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * ___________ __ __
4
+ * \__ ___/____ _/ |_ _____ | |
5
+ * | | / _ \\ __\\__ \ | |
6
+ * | | | |_| || | / __ \_| |__
7
+ * |____| \____/ |__| (____ /|____/
8
+ * \/
9
+ * ___ __ __
10
+ * | | ____ _/ |_ ____ _______ ____ ____ _/ |_
11
+ * | | / \\ __\_/ __ \\_ __ \ / \ _/ __ \\ __\
12
+ * | || | \| | \ ___/ | | \/| | \\ ___/ | |
13
+ * |___||___| /|__| \_____>|__| |___| / \_____>|__|
14
+ * \/ \/
15
+ * ________
16
+ * / _____/_______ ____ __ __ ______
17
+ * / \ ___\_ __ \ / _ \ | | \\____ \
18
+ * \ \_\ \| | \/| |_| || | /| |_| |
19
+ * \______ /|__| \____/ |____/ | __/
20
+ * \/ |__|
21
+ *
22
+ * NOTICE OF LICENSE
23
+ *
24
+ * This source file is subject to the Creative Commons License.
25
+ * It is available through the world-wide-web at this URL:
26
+ * http://creativecommons.org/licenses/by-nc-nd/3.0/nl/deed.en_US
27
+ * If you are unable to obtain it through the world-wide-web, please send an email
28
+ * to servicedesk@tig.nl so we can send you a copy immediately.
29
+ *
30
+ * DISCLAIMER
31
+ *
32
+ * Do not edit or add to this file if you wish to upgrade this module to newer
33
+ * versions in the future. If you wish to customize this module for your
34
+ * needs please contact servicedesk@tig.nl for more information.
35
+ *
36
+ * @copyright Copyright (c) 2014 Total Internet Group B.V. (http://www.totalinternetgroup.nl)
37
+ * @license http://creativecommons.org/licenses/by-nc-nd/3.0/nl/deed.en_US
38
+ *
39
+ * @var TIG_MyParcel2014_Block_Adminhtml_Sales_Order_Shipment_ShippingInfo $this
40
+ */
41
+ ?>
42
+ <script type ="text/javascript">
43
+ //<![CDATA[
44
+ document.observe('dom:loaded', function(){
45
+ var pgaddress = document.createElement('div');
46
+ pgaddress.innerHTML = '<?php echo $this->getPgAddressHtml(); ?>';
47
+
48
+ var target = document.getElementById('shipment_tracking_info').parentNode;
49
+ target.parentNode.insertBefore(pgaddress, target);
50
+
51
+ //retourlink button
52
+ var retourText = '<?php echo $this->getRetourlinkText();?>';
53
+ var retourUrl = '<?php echo $this->getRetourlinkUrl();?>';
54
+ retourUrl = 'setLocation(\''+retourUrl+'\')';
55
+
56
+ var retourlinkButton = document.createElement('button');
57
+ retourlinkButton.setAttribute('onclick',retourUrl);
58
+ retourlinkButton.setAttribute('class','scalable save');
59
+ retourlinkButton.setAttribute('type','button');
60
+ retourlinkButton.setAttribute('title',retourText);
61
+ retourlinkButton.setAttribute('id','');
62
+ retourlinkButton.innerHTML = '<span><span><span>'+retourText+'</span></span></span>';
63
+
64
+
65
+
66
+ //credit button
67
+ var creditText = '<?php echo $this->getCreditText();?>';
68
+ var creditUrl = '<?php echo $this->getCreditUrl();?>';
69
+ creditUrl = 'setLocation(\''+creditUrl+'\')';
70
+
71
+ var creditButton = document.createElement('button');
72
+ creditButton.setAttribute('onclick',creditUrl);
73
+ creditButton.setAttribute('class','scalable save');
74
+ creditButton.setAttribute('type','button');
75
+ creditButton.setAttribute('title',creditText);
76
+ creditButton.setAttribute('id','');
77
+ creditButton.innerHTML = '<span><span><span>'+creditText+'</span></span></span>';
78
+
79
+
80
+ var shippingButtons = $$('h3.head-sales-order-shipment')[0].next();
81
+ shippingButtons.appendChild(retourlinkButton);
82
+ shippingButtons.appendChild(creditButton);
83
+
84
+ });
85
+ //]]>
86
+ </script>
app/design/adminhtml/default/default/template/TIG/MyParcel2014/sales/order/view/shipping_info.phtml ADDED
@@ -0,0 +1,51 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * ___________ __ __
4
+ * \__ ___/____ _/ |_ _____ | |
5
+ * | | / _ \\ __\\__ \ | |
6
+ * | | | |_| || | / __ \_| |__
7
+ * |____| \____/ |__| (____ /|____/
8
+ * \/
9
+ * ___ __ __
10
+ * | | ____ _/ |_ ____ _______ ____ ____ _/ |_
11
+ * | | / \\ __\_/ __ \\_ __ \ / \ _/ __ \\ __\
12
+ * | || | \| | \ ___/ | | \/| | \\ ___/ | |
13
+ * |___||___| /|__| \_____>|__| |___| / \_____>|__|
14
+ * \/ \/
15
+ * ________
16
+ * / _____/_______ ____ __ __ ______
17
+ * / \ ___\_ __ \ / _ \ | | \\____ \
18
+ * \ \_\ \| | \/| |_| || | /| |_| |
19
+ * \______ /|__| \____/ |____/ | __/
20
+ * \/ |__|
21
+ *
22
+ * NOTICE OF LICENSE
23
+ *
24
+ * This source file is subject to the Creative Commons License.
25
+ * It is available through the world-wide-web at this URL:
26
+ * http://creativecommons.org/licenses/by-nc-nd/3.0/nl/deed.en_US
27
+ * If you are unable to obtain it through the world-wide-web, please send an email
28
+ * to servicedesk@tig.nl so we can send you a copy immediately.
29
+ *
30
+ * DISCLAIMER
31
+ *
32
+ * Do not edit or add to this file if you wish to upgrade this module to newer
33
+ * versions in the future. If you wish to customize this module for your
34
+ * needs please contact servicedesk@tig.nl for more information.
35
+ *
36
+ * @copyright Copyright (c) 2014 Total Internet Group B.V. (http://www.totalinternetgroup.nl)
37
+ * @license http://creativecommons.org/licenses/by-nc-nd/3.0/nl/deed.en_US
38
+ *
39
+ * @var TIG_MyParcel2014_Block_Adminhtml_Sales_Order_Shipment_Create_ConsignmentOptions $this
40
+ */
41
+ ?>
42
+ <script type ="text/javascript">
43
+ //<![CDATA[
44
+ document.observe('dom:loaded', function(){
45
+ var pgaddress = '<?php echo $this->getPgAddressHtml(); ?>';
46
+ var target = document.getElementsByClassName('head-shipping-method')[0].parentNode.parentNode;
47
+
48
+ target.innerHTML = target.innerHTML.replace('</fieldset>', pgaddress + '</fieldset>');
49
+ });
50
+ //]]>
51
+ </script>
app/design/adminhtml/default/default/template/TIG/MyParcel2014/system/config/edit.phtml ADDED
@@ -0,0 +1,346 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Magento Enterprise Edition
4
+ *
5
+ * NOTICE OF LICENSE
6
+ *
7
+ * This source file is subject to the Magento Enterprise Edition License
8
+ * that is bundled with this package in the file LICENSE_EE.txt.
9
+ * It is also available through the world-wide-web at this URL:
10
+ * http://www.magentocommerce.com/license/enterprise-edition
11
+ * If you did not receive a copy of the license and are unable to
12
+ * obtain it through the world-wide-web, please send an email
13
+ * to license@magentocommerce.com so we can send you a copy immediately.
14
+ *
15
+ * DISCLAIMER
16
+ *
17
+ * Do not edit or add to this file if you wish to upgrade Magento to newer
18
+ * versions in the future. If you wish to customize Magento for your
19
+ * needs please refer to http://www.magentocommerce.com for more information.
20
+ *
21
+ * @category design
22
+ * @package default_default
23
+ * @copyright Copyright (c) 2014 Magento Inc. (http://www.magentocommerce.com)
24
+ * @license http://www.magentocommerce.com/license/enterprise-edition
25
+ */
26
+ ?>
27
+ <?php
28
+ /**
29
+ * @methods
30
+ * getTitle() - string
31
+ * getSaveUrl() - string
32
+ * getSections() - array
33
+ * getForm() - html
34
+ */
35
+ ?>
36
+
37
+ <div class="content-header">
38
+ <table cellspacing="0">
39
+ <tr>
40
+ <td>
41
+ <h3<?php if($this->getHeaderCss()): ?> class="<?php echo $this->getHeaderCss()?>"<?php endif; ?>><?php echo Mage::helper('adminhtml')->__($this->getTitle()) ?></h3>
42
+ </td>
43
+ <td class="form-buttons">
44
+ <?php echo $this->getChildHtml('download_logs_button') ?>
45
+ <?php echo $this->getSaveButtonHtml() ?>
46
+ </td>
47
+ </tr>
48
+ </table>
49
+ </div>
50
+ <form action="<?php echo $this->getSaveUrl() ?>" method="post" id="config_edit_form" enctype="multipart/form-data">
51
+ <?php echo $this->getBlockHtml('formkey')?>
52
+ <?php echo $this->getChildHtml('form') ?>
53
+ </form>
54
+ <script type="text/javascript">
55
+ //<![CDATA[
56
+ var configForm = new varienForm('config_edit_form');
57
+ configForm.validator.options.onFormValidate = function(result, form) {
58
+ if (result) {
59
+ $$('.requires').each(function(element) {
60
+ var scopeElement = adminSystemConfig.getScopeElement(element);
61
+ if (!scopeElement || !scopeElement.checked) {
62
+ $(element).disabled = false;
63
+ }
64
+ });
65
+ }
66
+ };
67
+
68
+ var adminSystemConfig = {
69
+ getUp: function (element, tag) {
70
+ var $element = $(element);
71
+ if (typeof $element.upTag == 'undefined') {
72
+ $element.upTag = {};
73
+ }
74
+ if (typeof $element.upTag[tag] == 'undefined') {
75
+ $element.upTag[tag] = $($element.up(tag));
76
+ }
77
+ return $element.upTag[tag];
78
+ },
79
+ getUpTd: function (element) {
80
+ return this.getUp(element, 'td');
81
+ },
82
+ getUpTr: function (element) {
83
+ return this.getUp(element, 'tr');
84
+ },
85
+ getScopeElement: function(element) {
86
+ var $element = $(element);
87
+ if (typeof $element.scopeElement == 'undefined') {
88
+ var scopeElementName = element.getAttribute('name').replace(/\[value\]$/, '[inherit]');
89
+ $element.scopeElement = this.getUpTr(element).select('input[name="' + scopeElementName + '"]')[0];
90
+ if (typeof $element.scopeElement == 'undefined') {
91
+ $element.scopeElement = false;
92
+ }
93
+ }
94
+ return $element.scopeElement;
95
+ },
96
+ getDeleteElement: function(element) {
97
+ var $element = $(element);
98
+ if (typeof $element.deleteElement == 'undefined') {
99
+ $element.deleteElement = this.getUpTd(element)
100
+ .select('input[name="'+ element.getAttribute('name') + '[delete]"]')[0];
101
+ if (typeof $element.deleteElement == 'undefined') {
102
+ $element.deleteElement = false;
103
+ }
104
+ }
105
+ return $element.deleteElement;
106
+ },
107
+ mapClasses: function(element, full, callback, classPrefix) {
108
+ if (typeof classPrefix == 'undefined') {
109
+ classPrefix = 'shared'
110
+ }
111
+ element.classNames().each(function(className) {
112
+ if (className.indexOf(classPrefix + '-') == 0
113
+ || (full && className.indexOf(classPrefix + '_') == 0)
114
+ ) {
115
+ callback(className);
116
+ }
117
+ });
118
+ },
119
+ getRegisteredEvents: function(element) {
120
+ var events = [];
121
+ var registry = Element.retrieve($(element), 'prototype_event_registry');
122
+ if (!registry) {
123
+ return events;
124
+ }
125
+ registry.each(function(pair) {
126
+ var eventName = pair.key;
127
+ if (!eventName) {
128
+ return;
129
+ }
130
+ var responders = registry.get(eventName);
131
+ if (!responders) {
132
+ return;
133
+ }
134
+ responders.each(function(responder) {
135
+ if (!responder.handler) {
136
+ return;
137
+ }
138
+ events.push({
139
+ 'eventName': eventName,
140
+ 'handler': responder.handler
141
+ });
142
+ });
143
+ });
144
+ return events;
145
+ },
146
+ onchangeSharedElement: function(event) {
147
+ var element = $(Event.element(event));
148
+ adminSystemConfig.mapClasses(element, true, function(className) {
149
+ $$('.' + className).each(function(el) {
150
+ if (element == el) {
151
+ return;
152
+ }
153
+
154
+ var tagName = el.tagName.toLowerCase();
155
+ if (tagName == 'input' && el.getAttribute('type') == 'file') {
156
+ var $el = $(el);
157
+ var events = adminSystemConfig.getRegisteredEvents(el);
158
+ $el.stopObserving('change');
159
+ var elId = $el.id;
160
+ $el.replace($el.outerHTML);
161
+ events.each(function(event) {
162
+ Event.observe($(elId), event.eventName, event.handler);
163
+ });
164
+ } else {
165
+ el.stopObserving('change', adminSystemConfig.onchangeSharedElement);
166
+ if (tagName == 'input' && el.getAttribute('type') == 'checkbox') {
167
+ if (el.checked != element.checked) {
168
+ $(el).click();
169
+ }
170
+ } else if (tagName == 'select') {
171
+ var $el = $(el);
172
+ $(element).select('option').each(function(option) {
173
+ var relatedOption = $el.select('option[value="' + option.value + '"]')[0];
174
+ if (typeof relatedOption != 'undefined') {
175
+ relatedOption.selected = option.selected;
176
+ }
177
+ });
178
+ } else {
179
+ el.value = element.getValue();
180
+ }
181
+ if ($(el).requiresObj) {
182
+ $(el).requiresObj.indicateEnabled();
183
+ }
184
+ fireEvent(el, 'change');
185
+ Event.observe(el, 'change', adminSystemConfig.onchangeSharedElement);
186
+ }
187
+ });
188
+ });
189
+ },
190
+ checkRequired: function(element, callback) {
191
+ var tagName = this.tagName.toLowerCase();
192
+ if (tagName != 'fieldset') {
193
+ if (adminSystemConfig.getUpTr(this).visible()) {
194
+
195
+ if (this.hasClassName('not-required')) {
196
+ return;
197
+ }
198
+
199
+ var typeAttr = null;
200
+ if (tagName == 'input') {
201
+ typeAttr = this.getAttribute('type').toLowerCase();
202
+ }
203
+ var valueIsEmpty = false;
204
+ var scopeElement = adminSystemConfig.getScopeElement(this);
205
+ if (!scopeElement || !scopeElement.checked) {
206
+ if (typeAttr == 'file') {
207
+ var deleteUploadedElement = adminSystemConfig.getDeleteElement(this);
208
+ valueIsEmpty = !deleteUploadedElement && this.value == ''
209
+ || deleteUploadedElement && deleteUploadedElement.checked;
210
+ }
211
+ valueIsEmpty = valueIsEmpty
212
+ || (typeAttr == 'text' || typeAttr == 'password') && this.value == ''
213
+ || (tagName == 'select') && (this.getAttribute('multiple') != null)
214
+ && this.getValue().length == 0
215
+ || (tagName == 'select') && (this.getAttribute('multiple') == null)
216
+ && this.getValue() == null;
217
+ }
218
+
219
+ if (valueIsEmpty) {
220
+ if (element.value != 0) {
221
+ element.value = 0;
222
+ fireEvent(element, 'change');
223
+ }
224
+ element.disable();
225
+ }
226
+ }
227
+ } else {
228
+ this.select('input,select').each(function(inputElement) {
229
+ adminSystemConfig.checkRequired.call($(inputElement), element, callback);
230
+ });
231
+ }
232
+ callback(this);
233
+ }
234
+ };
235
+
236
+ $$('.shared').each(function(element){
237
+ Event.observe(element, 'change', adminSystemConfig.onchangeSharedElement);
238
+
239
+ // scope should be shared together with the field
240
+ var scopeElement = adminSystemConfig.getScopeElement(element);
241
+ if (scopeElement) {
242
+ adminSystemConfig.mapClasses(element, false, function(className) {
243
+ scopeElement.addClassName('shared_scope-' + className.substr(7));
244
+ });
245
+ Event.observe(scopeElement, 'change', adminSystemConfig.onchangeSharedElement);
246
+ }
247
+
248
+ // file fields should share deletion
249
+ if (element.tagName.toLowerCase() == 'input' && element.getAttribute('type') == 'file') {
250
+ var deleteUploadedElement = adminSystemConfig.getDeleteElement(element);
251
+ if (deleteUploadedElement) {
252
+ adminSystemConfig.mapClasses(element, false, function(className) {
253
+ deleteUploadedElement.addClassName('shared_delete-' + className.substr(7));
254
+ });
255
+ Event.observe(deleteUploadedElement, 'change', adminSystemConfig.onchangeSharedElement);
256
+ }
257
+ }
258
+
259
+ // process situation, when control is complex
260
+ adminSystemConfig.mapClasses(element, true, function(className) {
261
+ var controls = adminSystemConfig.getUpTd(element).select('.' + className);
262
+ if (controls.length < 2) {
263
+ return;
264
+ }
265
+
266
+ var counter = 0;
267
+ controls.each(function(controlElement) {
268
+ controlElement.removeClassName(className);
269
+ controlElement.addClassName('shared_' + counter + className.substr(6));
270
+ counter++;
271
+ });
272
+ });
273
+ });
274
+
275
+ $$('.requires').each(function(element) {
276
+ var eventObj = {
277
+ 'element': $(element),
278
+ 'requires': [],
279
+ 'callback': function(required) {},
280
+ checkRequirements: function() {
281
+ var scopeElement = adminSystemConfig.getScopeElement(eventObj.element);
282
+ if (!scopeElement || !scopeElement.checked) {
283
+ eventObj.element.enable();
284
+ eventObj.requires.each(function(required) {
285
+ adminSystemConfig.checkRequired.call($(required), eventObj.element, eventObj.callback);
286
+ }.bind(this));
287
+ }
288
+ },
289
+ keydownCheckRequirements: function() {
290
+ window.setTimeout(eventObj.checkRequirements, 1);
291
+ },
292
+ bindCheckingObserver: function(element) {
293
+ if (element.tagName.toLowerCase() == 'fieldset') {
294
+ $(element).select('input,select').each(function(subElement) {
295
+ eventObj.bindCheckingObserver(subElement);
296
+ })
297
+ } else {
298
+ var scopeElement = adminSystemConfig.getScopeElement(element);
299
+ if (scopeElement) {
300
+ Event.observe(scopeElement, 'click', eventObj.checkRequirements);
301
+ }
302
+ Event.observe(element, 'change', eventObj.checkRequirements);
303
+ Event.observe(element, 'keydown', eventObj.keydownCheckRequirements);
304
+ }
305
+ },
306
+ indicateEnabled: function() {
307
+ var labelElement = adminSystemConfig.getUpTr(eventObj.element).select('td.label label')[0];
308
+ if (typeof labelElement != 'undefined') {
309
+ if (eventObj.element.value == 1) {
310
+ labelElement.addClassName('enabled');
311
+ } else {
312
+ labelElement.removeClassName('enabled');
313
+ }
314
+ }
315
+ }
316
+ };
317
+
318
+ // fill eventObj with required elements
319
+ adminSystemConfig.mapClasses(element, false, function(className) {
320
+ var requiredElement = $(className.substr(9));
321
+ if (typeof requiredElement != 'undefined') {
322
+ eventObj.requires.push(requiredElement);
323
+ }
324
+ }, 'requires');
325
+ $(element).requiresObj = eventObj;
326
+
327
+ // replacing "Use Default" action with checking requirements
328
+ var scopeElement = adminSystemConfig.getScopeElement(element);
329
+ if (scopeElement) {
330
+ Event.stopObserving(scopeElement, 'click');
331
+ Event.observe(scopeElement, 'click', function(event) {
332
+ toggleValueElements(scopeElement, Element.previous(scopeElement.parentNode));
333
+ eventObj.checkRequirements();
334
+ });
335
+ }
336
+
337
+ // binding events
338
+ eventObj.requires.each(function(required) {
339
+ eventObj.bindCheckingObserver(required);
340
+ });
341
+ Event.observe(eventObj.element, 'change', eventObj.indicateEnabled);
342
+ eventObj.checkRequirements();
343
+ eventObj.indicateEnabled();
344
+ });
345
+ //]]>
346
+ </script>
app/design/adminhtml/default/default/template/TIG/MyParcel2014/system/config/supportTab.phtml ADDED
@@ -0,0 +1,151 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * ___________ __ __
4
+ * \__ ___/____ _/ |_ _____ | |
5
+ * | | / _ \\ __\\__ \ | |
6
+ * | | | |_| || | / __ \_| |__
7
+ * |____| \____/ |__| (____ /|____/
8
+ * \/
9
+ * ___ __ __
10
+ * | | ____ _/ |_ ____ _______ ____ ____ _/ |_
11
+ * | | / \\ __\_/ __ \\_ __ \ / \ _/ __ \\ __\
12
+ * | || | \| | \ ___/ | | \/| | \\ ___/ | |
13
+ * |___||___| /|__| \_____>|__| |___| / \_____>|__|
14
+ * \/ \/
15
+ * ________
16
+ * / _____/_______ ____ __ __ ______
17
+ * / \ ___\_ __ \ / _ \ | | \\____ \
18
+ * \ \_\ \| | \/| |_| || | /| |_| |
19
+ * \______ /|__| \____/ |____/ | __/
20
+ * \/ |__|
21
+ *
22
+ * NOTICE OF LICENSE
23
+ *
24
+ * This source file is subject to the Creative Commons License.
25
+ * It is available through the world-wide-web at this URL:
26
+ * http://creativecommons.org/licenses/by-nc-nd/3.0/nl/deed.en_US
27
+ * If you are unable to obtain it through the world-wide-web, please send an email
28
+ * to servicedesk@tig.nl so we can send you a copy immediately.
29
+ *
30
+ * DISCLAIMER
31
+ *
32
+ * Do not edit or add to this file if you wish to upgrade this module to newer
33
+ * versions in the future. If you wish to customize this module for your
34
+ * needs please contact servicedesk@tig.nl for more information.
35
+ *
36
+ * @copyright Copyright (c) 2014 Total Internet Group B.V. (http://www.totalinternetgroup.nl)
37
+ * @lictig.nlivecommons.org/licenses/by-nc-nd/3.0/nl/deed.en_US
38
+ */
39
+ ?>
40
+ <?php $_helper = Mage::helper('tig_myparcel'); ?>
41
+ <?php $_version = (string) Mage::getConfig()->getModuleConfig("TIG_MyParcel2014")->version; ?>
42
+ <tr>
43
+ <td>
44
+ <h2 class="content-heading"><?php echo $_helper->__('MyParcel version %s', $_version);?></h2>
45
+ <table id="supportWrap" cellpadding="0" cellspacing="0">
46
+ <tr>
47
+ <td colspan="3">
48
+ <div class="text-box">
49
+ <?php $url = 'http://kb.totalinternetgroup.nl/topic/99829566';?>
50
+ <h4><?php echo $_helper->__('To download the instructions for the MyParcel Magento extension, click <a target="_blank" href="%s">here</a>.',$url); ?></h4>
51
+ </div>
52
+ </td>
53
+ </tr>
54
+
55
+ <tr>
56
+ <td class="col-left">
57
+ <div class="text-box">
58
+ <h3><?php echo $_helper->__('When using the extension please note:');?></h3>
59
+ <ol>
60
+ <li>
61
+ <?php echo $_helper->__('To be able to configure the extension you need to possess and use an active MyParcel account.');?>
62
+ </li>
63
+ <li>
64
+ <?php echo $_helper->__('During the transition phase the old Magento MyParcel extension can remain active. However, you do need to turn off PakjeGemak in the old MyParcel extension.');?>
65
+ </li>
66
+ </ol>
67
+ </div>
68
+ <div class="text-box">
69
+ <h3><?php echo $_helper->__('Magento &amp; 3rd party version compatibility');?></h3>
70
+ <ul>
71
+ <li><?php echo $_helper->__('Magento Community Edition version');?> v1.6, v1.7, v1.8 &amp; v1.9</li>
72
+ </ul>
73
+ <ul>
74
+ <li><?php echo $_helper->__("Idev's OneStepCheckout version");?> v4.0 &amp; v4.1</li>
75
+ </ul>
76
+ <ul>
77
+ <li><?php echo $_helper->__('We cannot guarantee perfect functionality of the MyParcel extension when you intend to use the extension on a version of Magento that is not supported or when you intend to use the extension together with a 3rd part extension that is not supported. If you have any questions please contact MyParcel.'); ?></li>
78
+ </ul>
79
+ </div>
80
+ </td>
81
+
82
+ <td class="col-faux"></td>
83
+
84
+ <td class="col-right">
85
+ <div class="text-box">
86
+ <h3><?php echo $_helper->__('Support');?></h3>
87
+ <h4><?php echo $_helper->__('Questions and information about your MyParcel account');?></h4>
88
+ <p><?php echo $_helper->__('For questions related to your MyParcel account,please contact MyParcel.');?></p>
89
+ <p><a href="http://www.myparcel.nl" target="_blank"><img src="<?php echo $this->getSkinUrl('images/TIG/MyParcel2014/logo_myparcel.png'); ?>" alt="" /></a></p>
90
+ <table class="contact">
91
+ <tr>
92
+ <td class="first"><?php echo $_helper->__('MyParcel');?>:</td>
93
+ <td class="last">
94
+ <a target="_blank" href="http://www.myparcel.nl">www.myparcel.nl</a>
95
+ </td>
96
+ </tr>
97
+ <tr>
98
+ <td class="first"><?php echo $_helper->__('Phone');?>:</td>
99
+ <td class="last">023 - 30 30 315</td>
100
+
101
+ </tr>
102
+ <tr>
103
+ <td>
104
+ <?php echo $_helper->__('Email');?>:
105
+ </td>
106
+ <td class="last"><a href="mailto:info@myparcel.nl">info@myparcel.nl</a></td>
107
+ </tr>
108
+ </table>
109
+ <h4><?php echo $_helper->__('Extension support and configuration questions');?></h4>
110
+ <p><?php echo $_helper->__('For configuration problems, extension conflicts or bugs, please contact Total Internet Group.');?></p>
111
+ <p>
112
+ <a href="http://www.totalinternetgroup.nl" target="_blank">
113
+ <img src="<?php echo $this->getSkinUrl('images/TIG/MyParcel2014/tig_logo_medium.gif'); ?>" alt="" />
114
+ </a>
115
+ </p>
116
+ <table class="contact">
117
+ <tr>
118
+ <td class="first"><?php echo $_helper->__('Phone');?>:</td>
119
+ <td class="last">020 - 2181 001</td>
120
+
121
+ </tr>
122
+ <tr>
123
+ <td><?php echo $_helper->__('Email');?>:</td>
124
+ <td class="last"><a href="mailto:servicedesk@tig.nl">servicedesk@tig.nl</a></td>
125
+ </tr>
126
+ </table>
127
+ <h3><?php echo $_helper->__('Documents');?></h3>
128
+ <ul>
129
+ <li>
130
+ <a class="link" target="_blank" href="http://kb.totalinternetgroup.nl/topic/99829566" title="<?php echo $_helper->__('Installation and configuration instructions');?>">
131
+ <?php echo $_helper->__('Installation and configuration instructions');?>
132
+ </a>
133
+ </li>
134
+ <li>
135
+ <a class="link" target="_blank" href="http://kb.totalinternetgroup.nl/topic/99831236" title="<?php echo $_helper->__('Full changelog');?>">
136
+ <?php echo $_helper->__('Full changelog');?>
137
+ </a>
138
+ </li>
139
+ <li>
140
+ <a class="link" target="_blank" href="http://kb.totalinternetgroup.nl/forum/23053573" title="<?php echo $_helper->__('Overview articles in knowledge base');?>">
141
+ <?php echo $_helper->__('Overview articles in knowledge base');?>
142
+ </a>
143
+ </li>
144
+ </ul>
145
+ <p><?php echo $_helper->__('This extension has been developed by Total Internet Group.');?></p>
146
+ </div>
147
+ </td>
148
+ </tr>
149
+ </table>
150
+ </td>
151
+ </tr>
app/design/frontend/base/default/layout/TIG/tig_myparcel.xml ADDED
@@ -0,0 +1,80 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0"?>
2
+ <!--
3
+ /**
4
+ * ___________ __ __
5
+ * \__ ___/____ _/ |_ _____ | |
6
+ * | | / _ \\ __\\__ \ | |
7
+ * | | | |_| || | / __ \_| |__
8
+ * |____| \____/ |__| (____ /|____/
9
+ * \/
10
+ * ___ __ __
11
+ * | | ____ _/ |_ ____ _______ ____ ____ _/ |_
12
+ * | | / \\ __\_/ __ \\_ __ \ / \ _/ __ \\ __\
13
+ * | || | \| | \ ___/ | | \/| | \\ ___/ | |
14
+ * |___||___| /|__| \_____>|__| |___| / \_____>|__|
15
+ * \/ \/
16
+ * ________
17
+ * / _____/_______ ____ __ __ ______
18
+ * / \ ___\_ __ \ / _ \ | | \\____ \
19
+ * \ \_\ \| | \/| |_| || | /| |_| |
20
+ * \______ /|__| \____/ |____/ | __/
21
+ * \/ |__|
22
+ *
23
+ * NOTICE OF LICENSE
24
+ *
25
+ * This source file is subject to the Creative Commons License.
26
+ * It is available through the world-wide-web at this URL:
27
+ * http://creativecommons.org/licenses/by-nc-nd/3.0/nl/deed.en_US
28
+ * If you are unable to obtain it through the world-wide-web, please send an email
29
+ * to servicedesk@tig.nl so we can send you a copy immediately.
30
+ *
31
+ * DISCLAIMER
32
+ *
33
+ * Do not edit or add to this file if you wish to upgrade this module to newer
34
+ * versions in the future. If you wish to customize this module for your
35
+ * needs please contact servicedesk@tig.nl for more information.
36
+ *
37
+ * @copyright Copyright (c) 2014 Total Internet Group B.V. (http://www.totalinternetgroup.nl)
38
+ * @license http://creativecommons.org/licenses/by-nc-nd/3.0/nl/deed.en_US
39
+ */
40
+ -->
41
+ <layout version="0.1.0">
42
+ <checkout_onepage_index>
43
+ <reference name="head">
44
+ <action method="addItem">
45
+ <type>skin_js</type>
46
+ <file>js/TIG/MyParcel2014/pg_address.js</file>
47
+ </action>
48
+ </reference>
49
+ </checkout_onepage_index>
50
+
51
+ <checkout_onepage_shippingmethod>
52
+ <reference name="root">
53
+ <block type="tig_myparcel/checkout_pgAddress" name="myparcel.pg_address" template="TIG/MyParcel2014/checkout/pg_address.phtml" output="toHtml"/>
54
+ </reference>
55
+ </checkout_onepage_shippingmethod>
56
+
57
+ <onestepcheckout_index_index>
58
+ <reference name="head">
59
+ <action method="addItem">
60
+ <type>skin_js</type>
61
+ <file>js/TIG/MyParcel2014/pg_address.js</file>
62
+ </action>
63
+ </reference>
64
+ <reference name="choose-shipping-method">
65
+ <action method="setTemplate">
66
+ <template>TIG/MyParcel2014/onestepcheckout/shipping_method.phtml</template>
67
+ </action>
68
+ <block type="tig_myparcel/checkout_pgAddress" name="myparcel.pg_address" template="TIG/MyParcel2014/checkout/pg_address.phtml"/>
69
+ </reference>
70
+ </onestepcheckout_index_index>
71
+
72
+ <onestepcheckout_ajax_save_billing>
73
+ <reference name="choose-shipping-method">
74
+ <action method="setTemplate">
75
+ <template>TIG/MyParcel2014/onestepcheckout/shipping_method.phtml</template>
76
+ </action>
77
+ <block type="tig_myparcel/checkout_pgAddress" name="myparcel.pg_address" template="TIG/MyParcel2014/checkout/pg_address.phtml"/>
78
+ </reference>
79
+ </onestepcheckout_ajax_save_billing>
80
+ </layout>
app/design/frontend/base/default/template/TIG/MyParcel2014/checkout/pg_address.phtml ADDED
@@ -0,0 +1,103 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * ___________ __ __
4
+ * \__ ___/____ _/ |_ _____ | |
5
+ * | | / _ \\ __\\__ \ | |
6
+ * | | | |_| || | / __ \_| |__
7
+ * |____| \____/ |__| (____ /|____/
8
+ * \/
9
+ * ___ __ __
10
+ * | | ____ _/ |_ ____ _______ ____ ____ _/ |_
11
+ * | | / \\ __\_/ __ \\_ __ \ / \ _/ __ \\ __\
12
+ * | || | \| | \ ___/ | | \/| | \\ ___/ | |
13
+ * |___||___| /|__| \_____>|__| |___| / \_____>|__|
14
+ * \/ \/
15
+ * ________
16
+ * / _____/_______ ____ __ __ ______
17
+ * / \ ___\_ __ \ / _ \ | | \\____ \
18
+ * \ \_\ \| | \/| |_| || | /| |_| |
19
+ * \______ /|__| \____/ |____/ | __/
20
+ * \/ |__|
21
+ *
22
+ * NOTICE OF LICENSE
23
+ *
24
+ * This source file is subject to the Creative Commons License.
25
+ * It is available through the world-wide-web at this URL:
26
+ * http://creativecommons.org/licenses/by-nc-nd/3.0/nl/deed.en_US
27
+ * If you are unable to obtain it through the world-wide-web, please send an email
28
+ * to servicedesk@tig.nl so we can send you a copy immediately.
29
+ *
30
+ * DISCLAIMER
31
+ *
32
+ * Do not edit or add to this file if you wish to upgrade this module to newer
33
+ * versions in the future. If you wish to customize this module for your
34
+ * needs please contact servicedesk@tig.nl for more information.
35
+ *
36
+ * @copyright Copyright (c) 2014 Total Internet Group B.V. (http://www.totalinternetgroup.nl)
37
+ * @license http://creativecommons.org/licenses/by-nc-nd/3.0/nl/deed.en_US
38
+ */
39
+
40
+ $_helper = Mage::helper('tig_myparcel');
41
+ $_user = $_helper->getConfig('username', 'api');
42
+ $_apiKey = $_helper->getConfig('key', 'api', null, true);
43
+ $_shop = $this->getUrl('myparcel2014/index/pakjegemak', array('_secure' => true));
44
+ $_hash = hash_hmac('sha1', $_user . 'MyParcel' . $_shop, $_apiKey);
45
+ ?>
46
+ <div id="tig_myparcel_pg_container" style="display:none;">
47
+ <fieldset id="tig_myparcel_pg_address">
48
+ <input type="hidden" name="tig_myparcel_pg_address[firstname]" data-tig-myparcel-address-key="firstname" />
49
+ <input type="hidden" name="tig_myparcel_pg_address[lastname]" data-tig-myparcel-address-key="lastname" />
50
+ <input type="hidden" name="tig_myparcel_pg_address[company]" data-tig-myparcel-address-key="name" />
51
+ <input type="hidden" name="tig_myparcel_pg_address[street][1]" data-tig-myparcel-address-key="street" />
52
+ <input type="hidden" name="tig_myparcel_pg_address[street][2]" data-tig-myparcel-address-key="housenumber" />
53
+ <input type="hidden" name="tig_myparcel_pg_address[street][3]" data-tig-myparcel-address-key="housenumberadd" />
54
+ <input type="hidden" name="tig_myparcel_pg_address[postcode]" data-tig-myparcel-address-key="postalcode" />
55
+ <input type="hidden" name="tig_myparcel_pg_address[city]" data-tig-myparcel-address-key="city" />
56
+ <input type="hidden" name="tig_myparcel_pg_address[country_id]" data-tig-myparcel-address-key="country" />
57
+ <input type="hidden" name="tig_myparcel_pg_address[telephone]" data-tig-myparcel-address-key="phone" />
58
+ </fieldset>
59
+ </div>
60
+ <script type="text/javascript">
61
+ //<![CDATA[
62
+ if (typeof MyParcelPgAddress == 'undefined') {
63
+ console.error('<?php echo $_helper->__('MyParcel PgAddress class missing.');?>');
64
+ }
65
+
66
+ window.myParcelPgAddress = new MyParcelPgAddress($('tig_myparcel_pg_address'), {debug: false});
67
+
68
+ var pg_popup;
69
+ document.observe('click', function(e, el){
70
+ if(el = e.findElement('#s_method_tig_myparcel_pakjegemak'))
71
+ {
72
+ if(!pg_popup || pg_popup.closed)
73
+ {
74
+ var viewport = document.viewport.getDimensions();
75
+ var width = viewport.width;
76
+ var height = viewport.height;
77
+
78
+ pg_popup = window.open(
79
+ '<?php echo $_helper->getConfig('url'); ?>/pakjegemak-locatie?hash=<?php echo $_hash; ?>&webshop=<?php echo urlencode($_shop); ?>&user=<?php echo $_user; ?>',
80
+ 'tig_myparcel_pakjegemak',
81
+ 'width=' + width + ',height=' + height + ',dependent,resizable,scrollbars'
82
+ );
83
+ if(window.focus) { pg_popup.focus(); }
84
+ }
85
+ else
86
+ {
87
+ pg_popup.focus();
88
+ }
89
+ // refresh info div placeholder
90
+ var pginfo = $('pginfodiv');
91
+ if(pginfo) {
92
+ pginfo.remove();
93
+ }
94
+ pginfo = document.createElement('div');
95
+ pginfo.id = 'pginfodiv'
96
+ el.parentNode.appendChild(pginfo);
97
+
98
+ return false;
99
+ }
100
+ });
101
+
102
+ //]]>
103
+ </script>
app/design/frontend/base/default/template/TIG/MyParcel2014/onestepcheckout/shipping_method.phtml ADDED
@@ -0,0 +1,86 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Magento
4
+ *
5
+ * NOTICE OF LICENSE
6
+ *
7
+ * This source file is subject to the Academic Free License (AFL 3.0)
8
+ * that is bundled with this package in the file LICENSE_AFL.txt.
9
+ * It is also available through the world-wide-web at this URL:
10
+ * http://opensource.org/licenses/afl-3.0.php
11
+ * If you did not receive a copy of the license and are unable to
12
+ * obtain it through the world-wide-web, please send an email
13
+ * to license@magentocommerce.com so we can send you a copy immediately.
14
+ *
15
+ * DISCLAIMER
16
+ *
17
+ * Do not edit or add to this file if you wish to upgrade Magento to newer
18
+ * versions in the future. If you wish to customize Magento for your
19
+ * needs please refer to http://www.magentocommerce.com for more information.
20
+ *
21
+ * @category design_default
22
+ * @package Mage
23
+ * @copyright Copyright (c) 2008 Irubin Consulting Inc. DBA Varien (http://www.varien.com)
24
+ * @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0)
25
+ */
26
+ ?>
27
+ <?php if (!($_shippingRateGroups = $this->getShippingRates())): ?>
28
+ <strong><?php echo $this->__('Sorry, no quotes are available for this order at this time.') ?></strong>
29
+ <?php else: ?>
30
+ <?php if (count($_shippingRateGroups)=='1' && Mage::getStoreConfig('onestepcheckout/general/hide_shipping_method')):?>
31
+ <dl class="shipment-methods" style="display: none">
32
+ <?php foreach ($_shippingRateGroups as $code => $_rates): ?>
33
+ <dd><?php echo $this->getCarrierName($code) ?></dd>
34
+ <?php foreach ($_rates as $_rate): ?>
35
+ <dt style="margin-bottom: 5px;">
36
+ <?php if ($_rate->getErrorMessage()): ?>
37
+ <ul class="messages"><li class="error-msg"><ul><li><?php echo $_rate->getErrorMessage() ?></li></ul></li></ul>
38
+ <?php else: ?>
39
+ <input name="shipping_method" type="radio" value="<?php echo $_rate->getCode() ?>" id="s_method_<?php echo $_rate->getCode() ?>" checked="checked" />
40
+ <label for="s_method_<?php echo $_rate->getCode() ?>"><!--<b><?php echo $this->getCarrierName($code) ?>:</b>--> <?php echo $_rate->getMethodTitle() ?>
41
+ <strong>
42
+ <?php $_excl = $this->getShippingPrice($_rate->getPrice(), $this->helper('tax')->displayShippingPriceIncludingTax()); ?>
43
+ <?php $_incl = $this->getShippingPrice($_rate->getPrice(), true); ?>
44
+ <?php echo $_excl; ?>
45
+ <?php if ($this->helper('tax')->displayShippingBothPrices() && $_incl != $_excl): ?>
46
+ (<?php echo $this->__('Incl. Tax'); ?> <?php echo $_incl; ?>)
47
+ <?php endif; ?>
48
+ </strong>
49
+ </label>
50
+ <?php endif ?>
51
+ </dt>
52
+ <?php endforeach; ?>
53
+ <?php endforeach; ?>
54
+ </dl>
55
+ <?php else: ?>
56
+ <dl class="shipment-methods">
57
+ <?php foreach ($_shippingRateGroups as $code => $_rates): ?>
58
+ <dd><?php echo $this->getCarrierName($code) ?></dd>
59
+ <?php foreach ($_rates as $_rate): ?>
60
+ <dt style="margin-bottom: 5px;">
61
+
62
+ <?php if ($_rate->getErrorMessage()): ?>
63
+ <ul class="messages"><li class="error-msg"><ul><li><?php echo $_rate->getErrorMessage() ?></li></ul></li></ul>
64
+ <?php else: ?>
65
+ <input name="shipping_method" type="radio" class="validate-one-required-by-name" value="<?php echo $_rate->getCode() ?>" id="s_method_<?php echo $_rate->getCode() ?>"<?php if($_rate->getCode()===$this->getAddressShippingMethod()) echo ' checked="checked"' ?> />
66
+ <label for="s_method_<?php echo $_rate->getCode() ?>"><!--<b><?php echo $this->getCarrierName($code) ?>:</b>--> <?php echo $_rate->getMethodTitle() ?>
67
+ <strong>
68
+ <?php $_excl = $this->getShippingPrice($_rate->getPrice(), $this->helper('tax')->displayShippingPriceIncludingTax()); ?>
69
+ <?php $_incl = $this->getShippingPrice($_rate->getPrice(), true); ?>
70
+
71
+ <?php echo $_excl; ?>
72
+ <?php if ($this->helper('tax')->displayShippingBothPrices() && $_incl != $_excl): ?>
73
+ (<?php echo $this->__('Incl. Tax'); ?> <?php echo $_incl; ?>)
74
+ <?php endif; ?>
75
+ </strong>
76
+ </label>
77
+ <?php endif ?>
78
+ </dt>
79
+ <?php endforeach; ?>
80
+ <?php endforeach; ?>
81
+ </dl>
82
+ <?php endif; ?>
83
+ <?php endif; ?>
84
+ <?php if ($this->getChild('myparcel.pg_address')): ?>
85
+ <?php echo $this->getChildHtml('myparcel.pg_address'); ?>
86
+ <?php endif; ?>
app/design/frontend/base/default/template/TIG/MyParcel2014/pakjegemak.phtml ADDED
@@ -0,0 +1,88 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
2
+ <html xmlns="http://www.w3.org/1999/xhtml" >
3
+ <head>
4
+ <title>MyParcel - Magento - Passdata from PostNL through MyParcel</title>
5
+ </head>
6
+ <body>
7
+ <script type="text/javascript">
8
+ /* Querystring.js ******************************************************************************/
9
+ function Querystring(qs) { // optionally pass a querystring to parse
10
+ this.params = new Object()
11
+ this.get=Querystring_get
12
+
13
+ if (qs == null)
14
+ qs=location.search.substring(1,location.search.length)
15
+
16
+ if (qs.length == 0) return
17
+
18
+ qs = qs.replace(/\+/g, ' ')
19
+ var args = qs.split('&') // parse out name/value pairs separated via &
20
+
21
+
22
+ for (var i=0;i<args.length;i++) {
23
+ var value;
24
+ var pair = args[i].split('=')
25
+ var name = unescape(pair[0])
26
+
27
+ if (pair.length == 2)
28
+ value = unescape(pair[1])
29
+ else
30
+ value = name
31
+
32
+ this.params[name] = value
33
+ }
34
+ }
35
+
36
+ function Querystring_get(key, default_) {
37
+ // This silly looking line changes UNDEFINED to NULL
38
+ if (default_ == null) default_ = null;
39
+
40
+ var value=this.params[key]
41
+ if (value==null) value=default_;
42
+
43
+ return value
44
+ }
45
+
46
+ window.onload = passData;
47
+ function passData()
48
+ {
49
+ var name;
50
+ var street;
51
+ var houseNr;
52
+ var houseNrAdd;
53
+ var postalCodeNum;
54
+ var postalCodeAlpha;
55
+ var city;
56
+
57
+ var qs = new Querystring();
58
+ if (qs.get("action") == "confirm")
59
+ {
60
+ name = qs.get('name');
61
+ street = qs.get('street');
62
+ houseNr = qs.get('housenumber');
63
+ houseNrAdd = qs.get('housenumberadd');
64
+ postalCodeNum = qs.get('postalcodenum');
65
+ postalCodeAlpha = qs.get('postalcodealpha');
66
+ city = qs.get('city');
67
+
68
+ if(parent.parent.window.opener)
69
+ {
70
+ var shopname = name.split('&nbsp;&nbsp;');
71
+ if(shopname.length == 2) shopname = shopname[1];
72
+
73
+ parent.parent.window.opener.myParcelPgAddress.setAddress({
74
+ name : shopname,
75
+ street : street,
76
+ housenumber : houseNr,
77
+ housenumberadd : houseNrAdd,
78
+ postalcode : postalCodeNum + postalCodeAlpha,
79
+ city : city,
80
+ country : 'NL',
81
+ }).updateFieldset();
82
+ }
83
+ }
84
+ parent.parent.window.close();
85
+ }
86
+ </script>
87
+ </body>
88
+ </html>
app/etc/modules/TIG_MyParcel2014.xml ADDED
@@ -0,0 +1,14 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0"?>
2
+ <config>
3
+ <modules>
4
+ <TIG_MyParcel2014>
5
+ <active>true</active>
6
+ <codePool>community</codePool>
7
+ <depends>
8
+ <Mage_Sales/>
9
+ <Mage_Shipping/>
10
+ <Mage_Adminhtml/>
11
+ </depends>
12
+ </TIG_MyParcel2014>
13
+ </modules>
14
+ </config>
app/locale/en_US/TIG_MyParcel2014.csv ADDED
@@ -0,0 +1,149 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ TIG_MyParcel2014::Enabled,Enabled
2
+ TIG_MyParcel2014::Title,Title
3
+ TIG_MyParcel2014::Method Name,Method Name
4
+ TIG_MyParcel2014::Rate Type,Rate Type
5
+ TIG_MyParcel2014::Type,Type
6
+ TIG_MyParcel2014::Price,Price
7
+ TIG_MyParcel2014::Pakjegemak active,Pakjegemak active
8
+ TIG_MyParcel2014::Pakjegemak fee,Pakjegemak fee
9
+ TIG_MyParcel2014::Condition,Condition
10
+ TIG_MyParcel2014::Calculate Handling Fee,Calculate Handling Fee
11
+ TIG_MyParcel2014::Handling Fee,Handling Fee
12
+ TIG_MyParcel2014::Ship to Applicable Countries,Ship to Applicable Countries
13
+ TIG_MyParcel2014::Ship to Specific Countries,Ship to Specific Countries
14
+ TIG_MyParcel2014::Sort Order,Sort Order
15
+ TIG_MyParcel2014::Default Shipment Settings,Default Shipment Settings
16
+ TIG_MyParcel2014::Home address only,Home address only
17
+ TIG_MyParcel2014::Signature on receipt,Signature on receipt
18
+ TIG_MyParcel2014::Return if no answer,Return if no answer
19
+ TIG_MyParcel2014::Insured up to &euro; 50,Insured up to &euro; 50
20
+ TIG_MyParcel2014::For NL shipping only,For NL shipping only
21
+ TIG_MyParcel2014::Insured up to &euro; 250,Insured up to &euro; 250
22
+ "TIG_MyParcel2014::For NL shipping only, shipments outside the EU insured default is &euro; 200","For NL shipping only, shipments outside the EU insured default is &euro; 200"
23
+ TIG_MyParcel2014::Insured up to &euro; 500,Insured up to &euro; 500
24
+ "TIG_MyParcel2014::For NL shipping only, shipments inside the EU insured default is &euro; 500","For NL shipping only, shipments inside the EU insured default is &euro; 500"
25
+ TIG_MyParcel2014::Customs Shipment Type,Customs Shipment Type
26
+ TIG_MyParcel2014::Customs Content HS Code,Customs Content HS Code
27
+ "TIG_MyParcel2014::Default content type for Cross Domestic products, see <a href=""http://gebruikstarief.douane.nl"" target=""_blank"">http://gebruikstarief.douane.nl</a>","Default content type for Cross Domestic products, see <a href=""http://gebruikstarief.douane.nl"" target=""_blank"">http://gebruikstarief.douane.nl</a>"
28
+ "TIG_MyParcel2014::Fill in your preferences for a shipment. These settings will only apply for the mass actions in the order grid. When creating a single shipment, these settings can be changed manually.<br/>These settings will activate based on the order total amount. When shipping outside of the EU you can set default values for customs type and customs goods HS code.","Fill in your preferences for a shipment. These settings will only apply for the mass actions in the order grid. When creating a single shipment, these settings can be changed manually.<br/>These settings will activate based on the order total amount. When shipping outside of the EU you can set default values for customs type and customs goods HS code."
29
+ TIG_MyParcel2014::Retourlink e-mail Template,Retourlink e-mail Template
30
+ TIG_MyParcel2014::PLACEHOLDER,PLACEHOLDER
31
+ TIG_MyParcel2014::Track&amp;Trace email template,Track&amp;Trace email template
32
+ "TIG_MyParcel2014::You can create a new transactional e-mail where the variables {{var tracktrace_url}} and {{var retourlabel_url}} are available. TIP: You can base them on the Order Update template, because {{var order}} is also available.","You can create a new transactional e-mail where the variables {{var tracktrace_url}} and {{var retourlabel_url}} are available. TIP: You can base them on the Order Update template, because {{var order}} is also available."
33
+ TIG_MyParcel2014::Print Orientation,Print Orientation
34
+ TIG_MyParcel2014::Select a standard orientation for printing labels.,Select a standard orientation for printing labels.
35
+ TIG_MyParcel2014::Enable test modus,Enable test modus
36
+ TIG_MyParcel2014::Enable to test the extension,Enable to test the extension
37
+ TIG_MyParcel2014::Enable Myparcel Extension,Enable Myparcel Extension
38
+ TIG_MyParcel2014::Enable or disable the MyParcel module.,Enable or disable the MyParcel module.
39
+ TIG_MyParcel2014::Selecting 'No' will overrule all individual settings.,Selecting 'No' will overrule all individual settings.
40
+ TIG_MyParcel2014::General Settings,General Settings
41
+ TIG_MyParcel2014::API Key,API Key
42
+ TIG_MyParcel2014::The API Key given by MyParcel.,The API Key given by MyParcel.
43
+ TIG_MyParcel2014::API Username,API Username
44
+ TIG_MyParcel2014::Your MyParcel username.,Your MyParcel username.
45
+ TIG_MyParcel2014::To get your personal API credentials you should contact MyParcel.,To get your personal API credentials you should contact MyParcel.
46
+ TIG_MyParcel2014::API settings,API settings
47
+ TIG_MyParcel2014::Version &amp; Support,Version &amp; Support
48
+ TIG_MyParcel2014::The log files cannot be downloaded.,The log files cannot be downloaded.
49
+ TIG_MyParcel2014::An error occurred while processing this action.,An error occurred while processing this action.
50
+ TIG_MyParcel2014::The shipments were successfully created.,The shipments were successfully created.
51
+ TIG_MyParcel2014::None of the shipments could be created. Please check the error messages for more details.,None of the shipments could be created. Please check the error messages for more details.
52
+ TIG_MyParcel2014::Please select one or more shipments.,Please select one or more shipments.
53
+ TIG_MyParcel2014::Please select one or more orders.,Please select one or more orders.
54
+ TIG_MyParcel2014::MyParcel replied with the following warnings:,MyParcel replied with the following warnings:
55
+ TIG_MyParcel2014::The following shipments or orders could not be processed:,The following shipments or orders could not be processed:
56
+ TIG_MyParcel2014::Order #%s cannot be shipped at this time.,Order #%s cannot be shipped at this time.
57
+ TIG_MyParcel2014::Invalid full street supplied: %s.,Invalid full street supplied: %s.
58
+ TIG_MyParcel2014::Invalid housnumber supplied: %s.,Invalid housnumber supplied: %s.
59
+ TIG_MyParcel2014::Invalid session requested.,Invalid session requested.
60
+ TIG_MyParcel2014::Invalid message type requested: %s.,Invalid message type requested: %s.
61
+ TIG_MyParcel2014::No message supplied.,No message supplied.
62
+ TIG_MyParcel2014::No message type supplied.,No message type supplied.
63
+ TIG_MyParcel2014::Click here for more information from the TiG knowledgebase.,Click here for more information from the TiG knowledgebase.
64
+ TIG_MyParcel2014::An error occurred while processing your request: ,An error occurred while processing your request:
65
+ TIG_MyParcel2014::The createConsignment action is currently unavailable.,The createConsignment action is currently unavailable.
66
+ TIG_MyParcel2014::Invalid createConsignment response.,Invalid createConsignment response.
67
+ TIG_MyParcel2014::Shipping status,Shipping status
68
+ TIG_MyParcel2014::MyParcel - Create Shipments,MyParcel - Create Shipments
69
+ TIG_MyParcel2014::MyParcel - Print shipping labels,MyParcel - Print shipping labels
70
+ TIG_MyParcel2014::Download log files,Download log files
71
+ TIG_MyParcel2014::Unknown rate type specified: %s.,Unknown rate type specified: %s.
72
+ TIG_MyParcel2014::Flat,Flat
73
+ TIG_MyParcel2014::Table,Table
74
+ TIG_MyParcel2014::Invalid PakjeGemak address.,Invalid PakjeGemak address.
75
+ TIG_MyParcel2014::Invalid phone number.,Invalid phone number.
76
+ TIG_MyParcel2014::Invalid housenumber extension.,Invalid housenumber extension.
77
+ TIG_MyParcel2014::A4,A4
78
+ TIG_MyParcel2014::A6,A6
79
+ TIG_MyParcel2014::Commercial Goods,Commercial Goods
80
+ TIG_MyParcel2014::Commercial Sample,Commercial Sample
81
+ TIG_MyParcel2014::Documents,Documents
82
+ TIG_MyParcel2014::Gift,Gift
83
+ TIG_MyParcel2014::Returned Goods,Returned Goods
84
+ TIG_MyParcel2014::Yes,Yes
85
+ TIG_MyParcel2014::No,No
86
+ TIG_MyParcel2014::Myparcel Consignment Options,Myparcel Consignment Options
87
+ TIG_MyParcel2014::Insured amount,Insured amount
88
+ TIG_MyParcel2014::Insured,Insured
89
+ TIG_MyParcel2014::MyParcel version %s,MyParcel version %s
90
+ TIG_MyParcel2014::Magento &amp; 3rd party version compatibility,Magento &amp; 3rd party version compatibility
91
+ TIG_MyParcel2014::Magento Community Edition version,Magento Community Edition version
92
+ TIG_MyParcel2014::Magento Enterprise Edition version,Magento Enterprise Edition version
93
+ TIG_MyParcel2014::Idev's OneStepCheckout version,Idev's OneStepCheckout version
94
+ "TIG_MyParcel2014::If you wish to use this extension on an unsupported Magento version or edition, or in combination with an unsupported 3rd party extension, we cannot guarantee the MyParcel extension will function as expected. For questions please contact the Total Internet Group servicedesk.","If you wish to use this extension on an unsupported Magento version or edition, or in combination with an unsupported 3rd party extension, we cannot guarantee the MyParcel extension will function as expected. For questions please contact the Total Internet Group servicedesk."
95
+ TIG_MyParcel2014::Support,Support
96
+ TIG_MyParcel2014::The extension is developed by Total Internet Group.,The extension is developed by Total Internet Group.
97
+ TIG_MyParcel2014::MyParcel account questions and information,MyParcel account questions and information
98
+ "TIG_MyParcel2014::For questions related to your MyParcel account,please contact MyParcel.","For questions related to your MyParcel account,please contact MyParcel."
99
+ TIG_MyParcel2014::Phone,Phone
100
+ TIG_MyParcel2014::Extension support and configuration questions,Extension support and configuration questions
101
+ "TIG_MyParcel2014::For configuration problems, extension conflicts and bugs contact Total Internet Group.","For configuration problems, extension conflicts and bugs contact Total Internet Group."
102
+ TIG_MyParcel2014::Online knowledgebase,Online knowledgebase
103
+ TIG_MyParcel2014::Request help directly,Request help directly
104
+ TIG_MyParcel2014::Email,Email
105
+ TIG_MyParcel2014::Documentation,Documentation
106
+ TIG_MyParcel2014::A list of documents regarding the extension.,A list of documents regarding the extension.
107
+ TIG_MyParcel2014::View the installation and configuration manual.,View the installation and configuration manual.
108
+ TIG_MyParcel2014::Installation and configuration manual,Installation and configuration manual
109
+ TIG_MyParcel2014::View the user manual.,View the user manual.
110
+ TIG_MyParcel2014::User manual,User manual
111
+ TIG_MyParcel2014::View the complete changelog of the extension.,View the complete changelog of the extension.
112
+ TIG_MyParcel2014::Full changelog,Full changelog
113
+ TIG_MyParcel2014::MyParcel PgAddress class missing.,MyParcel PgAddress class missing.
114
+ TIG_MyParcel2014::Select a transactional e-mail template to send the retourlink,Select a transactional e-mail template to send the retourlink
115
+ TIG_MyParcel2014::Select a transactional e-mail template to send the barcode,Select a transactional e-mail template to send the barcode
116
+ TIG_MyParcel2014::You can create a new transactional e-mail where the variables {{var retourlink}} is available.,You can create a new transactional e-mail where the variables {{var retourlink}} is available.
117
+ TIG_MyParcel2014::Unable to send track and trace email for shipment #,Unable to send track and trace email for shipment #
118
+ TIG_MyParcel2014::Track&amp;Trace e-mail is send: %s,Track&amp;Trace e-mail is send: %s
119
+ TIG_MyParcel2014::Credit Consignment,Credit Consignment
120
+ TIG_MyParcel2014::Generate Retourlink,Generate Retourlink
121
+ TIG_MyParcel2014::Retourlink generated: %s,Retourlink generated: %s
122
+ "TIG_MyParcel2014::Credit has not been created, check MyParcel backend for details","Credit has not been created, check MyParcel backend for details"
123
+ TIG_MyParcel2014::Consignment %s is credited at MyParcel,Consignment %s is credited at MyParcel
124
+ "TIG_MyParcel2014::If you do not use split street lines and you wish to ship to outside the EU, there is a strong possibility that MyParcel will be unable to properly parse the address. This may result in the shipment being refused or it may even lead to the shipment being delivered at the wrong address!","If you do not use split street lines and you wish to ship to outside the EU, there is a strong possibility that MyParcel will be unable to properly parse the address. This may result in the shipment being refused or it may even lead to the shipment being delivered at the wrong address!"
125
+ TIG_MyParcel2014::Split street parts,Split street parts
126
+ TIG_MyParcel2014::Streetname field,Streetname field
127
+ TIG_MyParcel2014::Housenr. field,Housenr. field
128
+ TIG_MyParcel2014::Split house number parts,Split house number parts
129
+ TIG_MyParcel2014::Housenr. extension field,Housenr. extension field
130
+ TIG_MyParcel2014::Street line #%s,Street line #%s
131
+ TIG_MyParcel2014::This will be added to the regular shipping price,This will be added to the regular shipping price
132
+ TIG_MyParcel2014::Default shipment type for Cross Domestic shipments,Default shipment type for Cross Domestic shipments
133
+ "TIG_MyParcel2014::When changing the address, you need to cancel the current MyParcel shipment(s) linked to this order and create new MyParcel shipments.","When changing the address, you need to cancel the current MyParcel shipment(s) linked to this order and create new MyParcel shipments."
134
+ "TIG_MyParcel2014::To download the instructions for the MyParcel Magento extension, click <a target=""_blank"" href=""%s"">here</a>.","To download the instructions for the MyParcel Magento extension, click <a target=""_blank"" href=""%s"">here</a>."
135
+ TIG_MyParcel2014::When using the extension please note:,When using the extension please note:
136
+ TIG_MyParcel2014::To be able to configure the extension you need to possess and use an active MyParcel account.,To be able to configure the extension you need to possess and use an active MyParcel account.
137
+ "TIG_MyParcel2014::During the transition phase the old Magento MyParcel extension can remain active. However, you do need to turn off PakjeGemak in the old MyParcel extension.","During the transition phase the old Magento MyParcel extension can remain active. However, you do need to turn off PakjeGemak in the old MyParcel extension."
138
+ TIG_MyParcel2014::We cannot guarantee perfect functionality of the MyParcel extension when you intend to use the extension on a version of Magento that is not supported or when you intend to use the extension together with a 3rd part extension that is not supported. If you have any questions please contact MyParcel.,We cannot guarantee perfect functionality of the MyParcel extension when you intend to use the extension on a version of Magento that is not supported or when you intend to use the extension together with a 3rd part extension that is not supported. If you have any questions please contact MyParcel.
139
+ TIG_MyParcel2014::Installation and configuration instructions,Installation and configuration instructions
140
+ TIG_MyParcel2014::Overview articles in knowledge base,View all articles in the knowledgebase
141
+ TIG_MyParcel2014::This extension has been developed by Total Internet Group.,This extension has been developed by Total Internet Group.
142
+ TIG_MyParcel2014::Questions and information about your MyParcel account,Questions and information about your MyParcel account
143
+ "TIG_MyParcel2014::For configuration problems, extension conflicts or bugs, please contact Total Internet Group.","For configuration problems, extension conflicts or bugs, please contact Total Internet Group."
144
+ "TIG_MyParcel2014::Shipments will not be delivered at the neighbours, only on house address.","Shipments will not be delivered at the neighbours, only on house address."
145
+ TIG_MyParcel2014::Shipments will not go the a pickup point but will be returned directly after multiple delivery attempts.,Shipments will not go the a pickup point but will be returned directly after multiple delivery attempts.
146
+ TIG_MyParcel2014::Unable to save check_status cron expression: %s,Unable to save check_status cron expression: %s
147
+ TIG_MyParcel2014::Some of the shipments could not be created or could not be created at MyParcel from the selected orders. See below for detailed information.,Some of the shipments could not be created or could not be created at MyParcel from the selected orders. See below for detailed information.
148
+ TIG_MyParcel2014::Select A4 print start position,Select A4 print start position
149
+ "TIG_MyParcel2014::Select content type for Cross Domestic products, see <a href=""http://gebruikstarief.douane.nl"" target=""_blank"">http://gebruikstarief.douane.nl</a>","Select content type for Cross Domestic products, see <a href=""http://gebruikstarief.douane.nl"" target=""_blank"">http://gebruikstarief.douane.nl</a>"
app/locale/nl_NL/TIG_MyParcel2014.csv ADDED
@@ -0,0 +1,149 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ TIG_MyParcel2014::Enabled,Geactiveerd
2
+ TIG_MyParcel2014::Title,Titel
3
+ TIG_MyParcel2014::Method Name,Methode naam
4
+ TIG_MyParcel2014::Rate Type,Tarief type
5
+ TIG_MyParcel2014::Type,Type
6
+ TIG_MyParcel2014::Price,Prijs
7
+ TIG_MyParcel2014::Pakjegemak active,Pakjegemak actief
8
+ TIG_MyParcel2014::Pakjegemak fee,Pakjegemak afhandelingskosten
9
+ TIG_MyParcel2014::Condition,Voorwaarde
10
+ TIG_MyParcel2014::Calculate Handling Fee,Verzendkosten berekeningswijze
11
+ TIG_MyParcel2014::Handling Fee,Afhandelingskosten
12
+ TIG_MyParcel2014::Ship to Applicable Countries,Verzend naar beschikbare landen
13
+ TIG_MyParcel2014::Ship to Specific Countries,Verzend naar specifieke landen
14
+ TIG_MyParcel2014::Sort Order,Sorteer bestelling
15
+ TIG_MyParcel2014::Default Shipment Settings,Standaard verzend instellingen
16
+ TIG_MyParcel2014::Home address only,Alleen huisadres
17
+ TIG_MyParcel2014::Signature on receipt,Handtekening bij ontvangst
18
+ TIG_MyParcel2014::Return if no answer,Retour bij niet aanwezig
19
+ TIG_MyParcel2014::Insured up to &euro; 50,Verzekerd tot &euro; 50
20
+ TIG_MyParcel2014::For NL shipping only,Alleen voor Nederlandse verzendingen
21
+ TIG_MyParcel2014::Insured up to &euro; 250,Verzekerd tot &euro; 250
22
+ "TIG_MyParcel2014::For NL shipping only, shipments outside the EU insured default is &euro; 200","Alleen voor Nederlandse verzendingen, zendingen naar landen buiten de EU zijn standaard verzekerd tot &euro; 200"
23
+ TIG_MyParcel2014::Insured up to &euro; 500,Verzekerd tot &euro; 500
24
+ "TIG_MyParcel2014::For NL shipping only, shipments inside the EU insured default is &euro; 500","Alleen voor Nederlandse verzendingen, zendingen naar landen binnen de EU zijn standaard verzekerd tot &euro; 500"
25
+ TIG_MyParcel2014::Customs Shipment Type,Douane verzend type
26
+ TIG_MyParcel2014::Customs Content HS Code,Douane goederen HS code
27
+ "TIG_MyParcel2014::Default content type for Cross Domestic products, see <a href=""http://gebruikstarief.douane.nl"" target=""_blank"">http://gebruikstarief.douane.nl</a>","Standaard goederen type voor Cross Domestic producten, zie <a href=""http://gebruikstarief.douane.nl"" target=""_blank"">http://gebruikstarief.douane.nl</a>"
28
+ "TIG_MyParcel2014::Fill in your preferences for a shipment. These settings will only apply for the mass actions in the order grid. When creating a single shipment, these settings can be changed manually.<br/>These settings will activate based on the order total amount. When shipping outside of the EU you can set default values for customs type and customs goods HS code.","Vul hier uw voorkeuren in voor een verzending. Dit is later per zending uiteraard nog per zending aan te passen. De verzekeringsopties worden actief op basis van het order totaal bedrag. <br/> Indien u zendingen naar landen buiten de EU verstuurt, kunt u optioneel voor deze zendingen een standaard waarde invullen bij het Douane verzendtype en de Douane goederen HS code."
29
+ TIG_MyParcel2014::Retourlink e-mail Template,Retourlink e-mail Template
30
+ TIG_MyParcel2014::PLACEHOLDER,PLACEHOLDER
31
+ TIG_MyParcel2014::Track&amp;Trace email template,Track&amp;Trace e-mail Template
32
+ "TIG_MyParcel2014::You can create a new transactional e-mail where the variables {{var tracktrace_url}} and {{var retourlabel_url}} are available. TIP: You can base them on the Order Update template, because {{var order}} is also available.","U kunt een nieuwe transactionele email aanmaken en daarin {{var tracktrace_url}} en {{var retourlabel_url}} gebruiken. Zie voor details de <a target=""_blank"" href=""http://kb.totalinternetgroup.nl/topic/98526863"">KB</a>"
33
+ TIG_MyParcel2014::Print Orientation,Print ori&euml;ntatie
34
+ TIG_MyParcel2014::Select a standard orientation for printing labels.,Selecteer een standaard print ori&euml;ntatie voor het printen van labels.
35
+ TIG_MyParcel2014::Enable test modus,Activeer test modus
36
+ TIG_MyParcel2014::Enable to test the extension,Activeer om test verzendingen te kunnen maken
37
+ TIG_MyParcel2014::Enable Myparcel Extension,Activeer MyParcel extensie
38
+ TIG_MyParcel2014::Enable or disable the MyParcel module.,Activeer of deactiveer de MyParcel extensie
39
+ TIG_MyParcel2014::Selecting 'No' will overrule all individual settings.,"Wanneer ""nee"" is geselecteerd worden alle individuele instellingen overruled."
40
+ TIG_MyParcel2014::General Settings,Algemene instellingen
41
+ TIG_MyParcel2014::API Key,API Key
42
+ TIG_MyParcel2014::The API Key given by MyParcel.,Stel hier de API key in die is ontvangen vanuit MyParcel
43
+ TIG_MyParcel2014::API Username,API Gebruikersnaam
44
+ TIG_MyParcel2014::Your MyParcel username.,Vul hier de gebruikersnaam in voor het MyParcel platform
45
+ TIG_MyParcel2014::To get your personal API credentials you should contact MyParcel.,Neem contact op met MyParcel om de API gegevens te ontvangen.
46
+ TIG_MyParcel2014::API settings,API Instellingen
47
+ TIG_MyParcel2014::Version &amp; Support,Versie &amp; Support
48
+ TIG_MyParcel2014::The log files cannot be downloaded.,De logbestanden kunnen niet gedownload worden.
49
+ TIG_MyParcel2014::An error occurred while processing this action.,Er is een fout opgetreden tijdens het verwerken van deze actie.
50
+ TIG_MyParcel2014::The shipments were successfully created.,De verzendingen zijn succesvol aangemaakt
51
+ TIG_MyParcel2014::None of the shipments could be created. Please check the error messages for more details.,Geen van de verzendingen konden aangemaakt worden. Controleer de foutmeldingen in de logbestanden voor details.
52
+ TIG_MyParcel2014::Please select one or more shipments.,Selecteer &eacute;&eacute;n of meerdere verzendingen.
53
+ TIG_MyParcel2014::Please select one or more orders.,Selecteer &eacute;&eacute;n of meerdere orders.
54
+ TIG_MyParcel2014::MyParcel replied with the following warnings:,MyParcel heeft geantwoord met de volgende waarschuwingen:
55
+ TIG_MyParcel2014::The following shipments or orders could not be processed:,De volgende verzendingen konden niet verwerkt worden:
56
+ TIG_MyParcel2014::Order #%s cannot be shipped at this time.,Order #%s kan niet verzonden worden op dit moment
57
+ TIG_MyParcel2014::Invalid full street supplied: %s.,Invalide volledige straatnaam opgegeven: %s
58
+ TIG_MyParcel2014::Invalid housnumber supplied: %s.,Invalide huisnummer opgegeven: %s
59
+ TIG_MyParcel2014::Invalid session requested.,Invalide sessie opgevraagd
60
+ TIG_MyParcel2014::Invalid message type requested: %s.,Invalide bericht-type opgevraagd: %s
61
+ TIG_MyParcel2014::No message supplied.,Geen bericht meegegeven
62
+ TIG_MyParcel2014::No message type supplied.,Geen bericht-type meegegeven
63
+ TIG_MyParcel2014::Click here for more information from the TiG knowledgebase.,Klik hier voor meer informatie van de TIG kennisbank.
64
+ TIG_MyParcel2014::An error occurred while processing your request: ,Er is een fout opgetreden tijdens het verwerken van dit verzoek:
65
+ TIG_MyParcel2014::The createConsignment action is currently unavailable.,De createConsigment actie is tijdelijk niet beschikbaar
66
+ TIG_MyParcel2014::Invalid createConsignment response.,Invalide createConsignment antwoord
67
+ TIG_MyParcel2014::Shipping status,Verzend status
68
+ TIG_MyParcel2014::MyParcel - Create Shipments,MyParcel - Cre&euml;er verzendingen
69
+ TIG_MyParcel2014::MyParcel - Print shipping labels,MyParcel - Print verzend labels
70
+ TIG_MyParcel2014::Download log files,Download log bestanden
71
+ TIG_MyParcel2014::Unknown rate type specified: %s.,Onbekend tarief type opgegeven: %s.
72
+ TIG_MyParcel2014::Flat,Plat
73
+ TIG_MyParcel2014::Table,Tabel
74
+ TIG_MyParcel2014::Invalid PakjeGemak address.,Invalide PakjeGemak adres.
75
+ TIG_MyParcel2014::Invalid phone number.,Invalide telefoonnummer.
76
+ TIG_MyParcel2014::Invalid housenumber extension.,Invalide huisnummer extensie.
77
+ TIG_MyParcel2014::A4,A4
78
+ TIG_MyParcel2014::A6,A6
79
+ TIG_MyParcel2014::Commercial Goods,Commerciele goederen
80
+ TIG_MyParcel2014::Commercial Sample,Commercieel Proef
81
+ TIG_MyParcel2014::Documents,Documenten
82
+ TIG_MyParcel2014::Gift,Gift
83
+ TIG_MyParcel2014::Returned Goods,Retour goederen
84
+ TIG_MyParcel2014::Yes,Ja
85
+ TIG_MyParcel2014::No,Nee
86
+ TIG_MyParcel2014::Myparcel Consignment Options,MyParcel Verzend Opties
87
+ TIG_MyParcel2014::Insured amount,Verzekerd bedrag
88
+ TIG_MyParcel2014::Insured,Verzekerd
89
+ TIG_MyParcel2014::MyParcel version %s,MyParcel versie %s
90
+ TIG_MyParcel2014::Magento &amp; 3rd party version compatibility,Magento &amp; derde partijen ondersteuning
91
+ TIG_MyParcel2014::Magento Community Edition version,Magento Community Edition versie
92
+ TIG_MyParcel2014::Magento Enterprise Edition version,Magento Enterprise Edition versie
93
+ TIG_MyParcel2014::Idev's OneStepCheckout version,Idev's OneStepCheckout versie
94
+ "TIG_MyParcel2014::If you wish to use this extension on an unsupported Magento version or edition, or in combination with an unsupported 3rd party extension, we cannot guarantee the MyParcel extension will function as expected. For questions please contact the Total Internet Group servicedesk.","Indien u de extensie wilt gebruiken op een niet-ondersteunde versie of editie van Magento, of als u de extensie wilt gebruiken samen met een 3rd party extensie die niet ondersteund wordt, kunnen wij niet garanderen dat de MyParcel extensie feilloos zal functioneren. Voor vragen kunt u contact opnemen met MyParcel."
95
+ TIG_MyParcel2014::Support,Ondersteuning
96
+ TIG_MyParcel2014::The extension is developed by Total Internet Group.,Deze extensie is ontwikkeld door Total Internet Group.
97
+ TIG_MyParcel2014::MyParcel account questions and information,MyParcel account vragen en informatie
98
+ "TIG_MyParcel2014::For questions related to your MyParcel account,please contact MyParcel.","Voor vragen gerelateerd aan uw MyParcel account, neemt u contact op met MyParcel."
99
+ TIG_MyParcel2014::Phone,Telefoon
100
+ TIG_MyParcel2014::Extension support and configuration questions,Extensie ondersteuning en configuratie vragen
101
+ "TIG_MyParcel2014::For configuration problems, extension conflicts and bugs contact Total Internet Group.","Voor configuratie problemen, extensie conflicten en bugs, neem contact op met Total Internet Group."
102
+ TIG_MyParcel2014::Online knowledgebase,Online kennisbank
103
+ TIG_MyParcel2014::Request help directly,Vraag direct hulp
104
+ TIG_MyParcel2014::Email,E-mail
105
+ TIG_MyParcel2014::Documentation,Documentatie
106
+ TIG_MyParcel2014::A list of documents regarding the extension.,Een lijst met document aangaande de extensie.
107
+ TIG_MyParcel2014::View the installation and configuration manual.,Bekijk de installatie en configuratie handleiding.
108
+ TIG_MyParcel2014::Installation and configuration manual,Installatie en configuratie handleiding
109
+ TIG_MyParcel2014::View the user manual.,Bekijk de gebruikers handleiding
110
+ TIG_MyParcel2014::User manual,Gebruikers handleiding
111
+ TIG_MyParcel2014::View the complete changelog of the extension.,Bekijk de volledige release notes van de extensie
112
+ TIG_MyParcel2014::Full changelog,Volledige release notes
113
+ TIG_MyParcel2014::MyParcel PgAddress class missing.,MyParcel PgAddress class mist
114
+ TIG_MyParcel2014::Select a transactional e-mail template to send the retourlink,Selecteer een transactionele e-mail template om de retourlink te verzenden.
115
+ TIG_MyParcel2014::Select a transactional e-mail template to send the barcode,Selecteer een transactionele e-mail template om de Track&amp;Trace code te versturen
116
+ TIG_MyParcel2014::You can create a new transactional e-mail where the variables {{var retourlink}} is available.,"Maak een transactionele e-mail aan, daarin zal de variabele {{var retourlink}} beschikbaar zijn om te retourlink te verzenden."
117
+ TIG_MyParcel2014::Unable to send track and trace email for shipment #,Versturen van track & trace e-mail mislukt voor zending #
118
+ TIG_MyParcel2014::Track&amp;Trace e-mail is send: %s,Track & Trace e-mail is verzonden: %s
119
+ TIG_MyParcel2014::Credit Consignment,Crediteer zending
120
+ TIG_MyParcel2014::Generate Retourlink,Genereer Retourlabel
121
+ TIG_MyParcel2014::Retourlink generated: %s,Retourlink aangemaakt: %s
122
+ "TIG_MyParcel2014::Credit has not been created, check MyParcel backend for details","Credit is niet aangemaakt, zie MyParcel backend voor meer informatie."
123
+ TIG_MyParcel2014::Consignment %s is credited at MyParcel,Zending %s is gecrediteerd bij MyParcel.
124
+ "TIG_MyParcel2014::If you do not use split street lines and you wish to ship to outside the EU, there is a strong possibility that MyParcel will be unable to properly parse the address. This may result in the shipment being refused or it may even lead to the shipment being delivered at the wrong address!","Als je adresgegevens niet opsplitst en je stuurt zendingen naar buiten de EU, dan is er een mogelijkheid dat MyParcel het adres niet kan omzetten. Dit kan leiden tot zendingen die geweigerd worden of zelfs niet afgeleverd kunnen worden."
125
+ TIG_MyParcel2014::Split street parts,Deel straatnaam velden op
126
+ TIG_MyParcel2014::Streetname field,Straatnaam veld
127
+ TIG_MyParcel2014::Housenr. field,Huisnummer veld
128
+ TIG_MyParcel2014::Split house number parts,Deel huisnummervelden op
129
+ TIG_MyParcel2014::Housenr. extension field,Huisnr. extensie veld
130
+ TIG_MyParcel2014::Street line #%s,Adresregel #%s
131
+ TIG_MyParcel2014::This will be added to the regular shipping price,Dit zal bij de normale verzendkosten worden opgeteld
132
+ TIG_MyParcel2014::Default shipment type for Cross Domestic shipments,Standaard verzend inhoud voor Cross Domestic verzendingen
133
+ "TIG_MyParcel2014::When changing the address, you need to cancel the current MyParcel shipment(s) linked to this order and create new MyParcel shipments.","Wanneer het adres gewijzigd wordt, bent u genoodzaakt om de gekoppelde MyParcel verzendingen te crediteren en nieuwe MyParcel verzendingen aan te maken."
134
+ "TIG_MyParcel2014::To download the instructions for the MyParcel Magento extension, click <a target=""_blank"" href=""%s"">here</a>.","Klik <a target=""_blank"" href=""%s"">hier</a> om de handleiding van de MyParcel Magento extensie te downloaden."
135
+ TIG_MyParcel2014::When using the extension please note:,Aandachtspunten bij het gebruik van deze extensie:
136
+ TIG_MyParcel2014::To be able to configure the extension you need to possess and use an active MyParcel account.,U dient een actief MyParcel account te hebben om de extensie te kunnen configureren.
137
+ "TIG_MyParcel2014::During the transition phase the old Magento MyParcel extension can remain active. However, you do need to turn off PakjeGemak in the old MyParcel extension.",Indien u de oude MyParcel extensie gebruikt kan deze actief blijven in de overgangsfase. Wel dient u PakjeGemak in de oude MyParcel extensie uit te schakelen.
138
+ TIG_MyParcel2014::We cannot guarantee perfect functionality of the MyParcel extension when you intend to use the extension on a version of Magento that is not supported or when you intend to use the extension together with a 3rd part extension that is not supported. If you have any questions please contact MyParcel.,"Indien u de extensie wilt gebruiken op een niet-ondersteunde versie of editie van Magento, of als u de extensie wilt gebruiken samen met een 3rd party extensie die niet ondersteund wordt, kunnen wij niet garanderen dat de MyParcel extensie feilloos zal functioneren. Voor vragen kunt u contact opnemen met MyParcel."
139
+ TIG_MyParcel2014::Installation and configuration instructions,Installatie en configuratie handleiding
140
+ TIG_MyParcel2014::Overview articles in knowledge base,Bekijk alle kennisbank artikelen
141
+ TIG_MyParcel2014::This extension has been developed by Total Internet Group.,Deze extensie is ontwikkeld door Total Internet Group.
142
+ TIG_MyParcel2014::Questions and information about your MyParcel account,MyParcel account vragen en informatie
143
+ "TIG_MyParcel2014::For configuration problems, extension conflicts or bugs, please contact Total Internet Group.","Voor configuratie problemen, extensie conflicten en bugs, neem contact op met Total Internet Group."
144
+ "TIG_MyParcel2014::Shipments will not be delivered at the neighbours, only on house address.","Zendingen worden niet bij de buren aangeboden, alleen op huisadres."
145
+ TIG_MyParcel2014::Shipments will not go the a pickup point but will be returned directly after multiple delivery attempts.,Zendingen gaan niet naar een afhaallocatie en komen direct retour na bezorgpogingen.
146
+ TIG_MyParcel2014::Unable to save check_status cron expression: %s,Het is niet gelukt om de check_status cron expressie op te slaan: %s
147
+ TIG_MyParcel2014::Some of the shipments could not be created or could not be created at MyParcel from the selected orders. See below for detailed information.,Een aantal van de geselecteerde orders is een foutmelding opgetreden tijdens het aanmaken van de verzending. Zie hieronder voor gedetailleerde informatie.
148
+ TIG_MyParcel2014::Select A4 print start position,Selecteer de A4 print start positie
149
+ "TIG_MyParcel2014::Select content type for Cross Domestic products, see <a href=""http://gebruikstarief.douane.nl"" target=""_blank"">http://gebruikstarief.douane.nl</a>","Vul de goederen code voor zendingen buiten de EU in, zie <a href=""http://gebruikstarief.douane.nl"" target=""_blank"">http://gebruikstarief.douane.nl</a> voor de bestaande codes."
package.xml ADDED
@@ -0,0 +1,42 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0"?>
2
+ <package>
3
+ <name>tig_myparcel</name>
4
+ <version>1.1.4</version>
5
+ <stability>stable</stability>
6
+ <license uri="http://creativecommons.org/licenses/by-nc-nd/3.0/nl/deed.en_US">Creative Commons License</license>
7
+ <channel>community</channel>
8
+ <extends/>
9
+ <summary>The official shipping extension for MyParcel</summary>
10
+ <description>Dit is de offici&#xEB;le Magento extensie uitgevoerd in opdracht van MyParcel en ontwikkeld door de Total Internet Group. Met MyParcel extensie is het nu nog eenvoudiger om het verzendproces direct vanuit Magento te organiseren.&#xD;
11
+ &#xD;
12
+ The official MyParcel extension for Magento.&#xD;
13
+ &#xD;
14
+ This extension allows you to ship your MyParcel shipments right from Magento. &#xD;
15
+ With this extension you can:&#xD;
16
+ - ship&#xD;
17
+ MyParcel shippingmethod (flat rate and table rate)&#xD;
18
+ - create shipments from the order-grid and directly print the shipping-lables &#xD;
19
+ - create shipments with specific MyParcel options&#xD;
20
+ - Generate return-links for a shipment&#xD;
21
+ - Ship world-wide with MyParcel&#xD;
22
+ - Send Track&amp;Trace information</description>
23
+ <notes>== v1.1.4 ==&#xD;
24
+ &#xD;
25
+ - Pakjegemak extra address-validation on order detail page&#xD;
26
+ &#xD;
27
+ known bugs:&#xD;
28
+ None. Please contact us if you find a bug. &#xD;
29
+ &#xD;
30
+ == v1.1.3 ==&#xD;
31
+ &#xD;
32
+ - Print-position overlay optimised &#xD;
33
+ - New translations&#xD;
34
+ - Extended logging functionality&#xD;
35
+ </notes>
36
+ <authors><author><name>TIG</name><user>supporttotal</user><email>servicedesk@totalinternetgroup.nl</email></author></authors>
37
+ <date>2014-11-14</date>
38
+ <time>11:11:14</time>
39
+ <contents><target name="magecommunity"><dir name="TIG"><dir name="MyParcel2014"><dir name="Block"><dir name="Adminhtml"><dir name="Sales"><dir name="Order"><dir name="Shipment"><dir name="Create"><file name="ConsignmentOptions.php" hash="5bfc4f8b4167f0ecf8c892734b2eda4f"/></dir><file name="ShippingInfo.php" hash="7accd0b9bc08db64370f3ecee51f9ceb"/></dir><dir name="View"><file name="ShippingInfo.php" hash="2419c6171fa1a79d941dc70cb1d5a6aa"/></dir></dir></dir><dir name="System"><dir name="Config"><file name="SupportTab.php" hash="3ed95adf1523bd5a21c1fe19d61813dc"/></dir></dir><dir name="Widget"><dir name="Grid"><dir name="Column"><dir name="Renderer"><file name="ShippingStatus.php" hash="cbc45c122811852bd84534d79eb2aafb"/></dir></dir></dir></dir></dir><dir name="Checkout"><file name="PgAddress.php" hash="b1a9ac7d2219b3b4f85cab5996f8c531"/></dir><file name="Pakjegemak.php" hash="9383ed277b713c5cb17c3b0ce8f343d0"/></dir><dir name="controllers"><dir name="Adminhtml"><file name="ConfigController.php" hash="999f4c9d5ee7189858836c80a754ee8e"/><file name="ShipmentController.php" hash="7fdbe522ebe44fdabe89c168539f2f8c"/></dir><file name="IndexController.php" hash="080a26652af41c2c58c42c586ad63aa5"/></dir><dir name="data"><dir name="tig_myparcel_setup"><file name="data-upgrade-0.1.0-1.1.1.php" hash="04cd4a74b8e7a2374586f2352c6716c4"/></dir></dir><dir name="etc"><file name="adminhtml.xml" hash="48f98ab56dba89e6b2479b9a4cebb628"/><file name="config.xml" hash="fe75d6b65cdff273abb4d8d61cb0385f"/><file name="system.xml" hash="11af62b575e8b99fb218782bec2aa3a4"/></dir><dir name="Helper"><file name="AddressValidation.php" hash="a85c4dda15b569c42f5ba51e74fa5726"/><file name="Data.php" hash="f36a078844a4d2660392ff3e1ac300ae"/></dir><dir name="Model"><dir name="Adminhtml"><dir name="Observer"><file name="OrderGrid.php" hash="d507f9afa01ba674c7b2a78d7dfd619a"/><file name="SystemConfig.php" hash="71e86b1d78a3a9f7667fa3370735b0e3"/></dir><dir name="Support"><file name="Logs.php" hash="aa893e95915c5366661ce456ca32c0a3"/></dir></dir><dir name="Api"><file name="MyParcel.php" hash="cca5627cfb099eb5e9e3b89762d88a41"/></dir><dir name="Carrier"><file name="MyParcel.php" hash="e45050890417ce8c3e1ca761a1157b29"/><dir name="System"><dir name="Config"><dir name="Source"><file name="RateType.php" hash="d0e2b78dc1040b1265e35d60ae2de76b"/></dir></dir></dir></dir><dir name="Observer"><file name="Cron.php" hash="ea790b89e5bd5379b0711415623b3e1d"/><file name="SaveConfig.php" hash="fe0d9d218f656b25008ae1964460528e"/><file name="SavePgAddress.php" hash="de0c427e8c3fc0dc59d028085d8b9674"/><file name="SaveShipment.php" hash="8e26215a9c690385263b0a8d704502e3"/></dir><dir name="Resource"><dir name="Order"><dir name="Grid"><file name="Collection.php" hash="48fc092078dcdbcca40788c486ca0987"/></dir></dir><file name="Setup.php" hash="300815f89f12c143a5fa2cb1f3c2b765"/><dir name="Shipment"><file name="Collection.php" hash="6af521845d88a214d283cfd3fecfbd2d"/></dir><file name="Shipment.php" hash="7c7bb4b4349da9504015a279b9ff8a4f"/></dir><file name="Shipment.php" hash="d5580552df3d49c8924238acb3536ac2"/><dir name="System"><dir name="Config"><dir name="Source"><file name="A4a6.php" hash="9233248742c79824ea8408577a9b4f2e"/><file name="Customs.php" hash="9b5c4fd3a866fdabf44a7b532b9c3501"/><file name="StreetField.php" hash="f171261f2d8785ebf41f19d2bfeb7d58"/><file name="Yesno.php" hash="0c49e0c17e933924d25ffe823e2dab16"/></dir></dir></dir></dir><dir name="sql"><dir name="tig_myparcel_setup"><file name="install-0.1.0.php" hash="6f0adc84b58a049b000997cec80946a3"/></dir></dir><file name="Exception.php" hash="17fbabfc37a1872da197dda8ae31eaad"/></dir></dir></target><target name="magedesign"><dir name="adminhtml"><dir name="default"><dir name="default"><dir name="layout"><dir name="TIG"><file name="tig_myparcel.xml" hash="8a2005f2eee524a02af7bc523b868965"/></dir></dir><dir name="template"><dir name="TIG"><dir name="MyParcel2014"><dir name="sales"><dir name="order"><dir name="address"><file name="warning.phtml" hash="fd5bf39bc5bf1ff6e79c41cad00de14b"/></dir><file name="mass_actions.phtml" hash="59eaa0ffec5b3eaf528a6101d1b4f6f1"/><dir name="shipment"><dir name="create"><file name="consignment_options.phtml" hash="88fcdcea5734d77ec6318b2d77fe74a1"/></dir><file name="shipping_info.phtml" hash="f34cbcc5f5ff2b65de6cc8f1473df530"/></dir><dir name="view"><file name="shipping_info.phtml" hash="e6e8ca0fa33e940b00c5c4c138c55bac"/></dir></dir></dir><dir name="system"><dir name="config"><file name="edit.phtml" hash="3b3728e61a547322258ee4fd0026b271"/><file name="supportTab.phtml" hash="24145a6786819ec62e52df469bfb5fc6"/></dir></dir></dir></dir></dir></dir></dir></dir><dir name="frontend"><dir name="base"><dir name="default"><dir name="layout"><dir name="TIG"><file name="tig_myparcel.xml" hash="a42a9dc6a24fe8572c8e1038cea3c630"/></dir></dir><dir name="template"><dir name="TIG"><dir name="MyParcel2014"><dir name="checkout"><file name="pg_address.phtml" hash="91808db0c3bdd7c1c3ce5c04c04dd04c"/></dir><dir name="onestepcheckout"><file name="shipping_method.phtml" hash="ec8cf315f3ca86dd4d97750fd04af42a"/></dir><file name="pakjegemak.phtml" hash="2bf073793e34ec86a6ab523ef1a5507b"/></dir></dir></dir></dir></dir></dir></target><target name="mageetc"><dir name="modules"><file name="TIG_MyParcel2014.xml" hash="ea5b922031b3e792a2b381903077e66f"/></dir></target><target name="magelocale"><dir name="en_US"><file name="TIG_MyParcel2014.csv" hash="fa60245119132612d19229349ab10e1c"/></dir><dir name="nl_NL"><file name="TIG_MyParcel2014.csv" hash="c7519311efa10f64d6437801c4ff4050"/></dir></target><target name="mageskin"><dir name="adminhtml"><dir name="default"><dir name="default"><dir name="css"><dir name="TIG"><dir name="MyParcel2014"><file name="styles.css" hash="d41d8cd98f00b204e9800998ecf8427e"/><file name="system_config_edit.css" hash="429c1a64ac62e62ab80915236e6400cf"/><file name="system_config_edit_myparcel.css" hash="8845190193d237aaacfdf8963a4e572b"/><file name="system_config_edit_myparcel_magento16.css" hash="f9a8479639e2fe8d0da9cf602b1607c3"/></dir></dir></dir><dir name="images"><dir name="TIG"><dir name="MyParcel2014"><file name="bkg_tooltip.png" hash="56cfed3ed8a65b19f8de88946d1a0a01"/><file name="btn_download_icon.png" hash="142d5ebbe43ad09dde97cd32e1ef4303"/><file name="glyph_error.gif" hash="a138b803d772f552aa2e49e1c506edbd"/><file name="glyph_info.gif" hash="40f72d28be63ecf2b6ef44c7ea730104"/><file name="glyph_manual.png" hash="771db63b6ffc9de1c06da564796adc6e"/><file name="glyph_pdf.png" hash="a5ea929f4014a88d7320d0293913ace3"/><file name="glyph_success.gif" hash="465a056a3ba3d94367f51c3c0b751391"/><file name="glyph_warning.gif" hash="fa817cb6d49efb9855942ef2b739fc6c"/><file name="icon-tooltip.png" hash="5767601cd66b23d0b6fe8defc10dd48d"/><file name="legend.gif" hash="d8fb0642901868d489d31b426f3e3406"/><file name="logo_myparcel.png" hash="73b50ec4d9d63d1b4ee4822b8b5f4964"/><file name="logo_myparcel_19.png" hash="8b7463a2911050419d97b24890732472"/><file name="logo_myparcel_38.png" hash="20e50f897cd8a4133e15629a10a1fea2"/><file name="tig_logo_medium.gif" hash="3e1071908cfdb7b472438482c3331ac7"/></dir></dir></dir></dir></dir></dir><dir name="frontend"><dir name="base"><dir name="default"><dir name="js"><dir name="TIG"><dir name="MyParcel2014"><file name="pg_address.js" hash="0d1120a7b62b2456f67a4b6ebb0254ba"/></dir></dir></dir></dir></dir></dir></target></contents>
40
+ <compatible/>
41
+ <dependencies><required><php><min>5.3.0</min><max>6.0.0</max></php></required></dependencies>
42
+ </package>
skin/adminhtml/default/default/css/TIG/MyParcel2014/styles.css ADDED
File without changes
skin/adminhtml/default/default/css/TIG/MyParcel2014/system_config_edit.css ADDED
@@ -0,0 +1,5 @@
 
 
 
 
 
1
+ #system_config_tabs .tig_myparcel-tab { background:transparent url(../../../images/TIG/MyParcel2014/logo_myparcel_19.png) 18px 3px no-repeat !important; display:block; }
2
+ #system_config_tabs .tig_myparcel-tab:hover { background-color:#d8e6e6 !important; border-right:1px solid #8aa5a6; }
3
+ #system_config_tabs .tig_myparcel-tab.active { background-color:#fff !important; border-right:none !important; }
4
+ #system_config_tabs .tig_myparcel-tab span { padding-left:44px; display:block; }
5
+ #system_config_tabs .tig_myparcel-tab.active span { background:none; }
skin/adminhtml/default/default/css/TIG/MyParcel2014/system_config_edit_myparcel.css ADDED
@@ -0,0 +1,34 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ /* General */
2
+ #tig_myparcel_myparcel_support p,
3
+ #tig_myparcel_myparcel_support ul,
4
+ #tig_myparcel_myparcel_support ol { padding:6px 0 10px; }
5
+ #tig_myparcel_myparcel_support ul.myparcel-config-warning {list-style:disc inside none; }
6
+ #tig_myparcel_myparcel_support ol { list-style:decimal inside; }
7
+ #tig_myparcel_myparcel_support ol ol { list-style:lower-alpha inside; padding:0 0 10px 12px; }
8
+ #tig_myparcel_myparcel_support ul ul { list-style:none; padding:0 0 10px 12px; }
9
+ #tig_myparcel_myparcel_support h2.content-heading { color:#ea7601; border-bottom:4px solid #dfdfdf; }
10
+ #tig_myparcel_myparcel_support h4,
11
+ #tig_myparcel_myparcel_support p { margin:0;}
12
+ #tig_myparcel_myparcel_support a.pdf { display:inline-block; height:16px; line-height:16px; padding:0 0 0 21px; background:url(../../../images/TIG/MyParcel2014/glyph_pdf.png) no-repeat; }
13
+ #tig_myparcel_myparcel_support a.link { display: inline-block; height: 16px; line-height: 16px; padding: 0 0 0 21px; background:url(../../../images/btn_go.gif) no-repeat 0 40%; }
14
+ #tig_myparcel_myparcel_support .text-box { background:#fff; padding:9px 16px; margin:6px 0 10px; border:1px solid #ccc; }
15
+ #tig_myparcel_myparcel_support table.contact { margin:0 0 25px -1px; }
16
+ #tig_myparcel_myparcel_support table.contact td { padding:0; }
17
+ #tig_myparcel_myparcel_support table.contact td.first { width:150px; padding-right:5px; }
18
+
19
+ /* Legend */
20
+ #tig_myparcel_myparcel_support #legend li { background:url(../../../images/TIG/MyParcel2014/legend.gif) 0 0 no-repeat; padding-left:14px; }
21
+ #tig_myparcel_myparcel_support #legend li.disabled { background-position:0 4px; }
22
+ #tig_myparcel_myparcel_support #legend li.test { background-position:0 -25px; }
23
+ #tig_myparcel_myparcel_support #legend li.live { background-position:0 -54px; }
24
+ #tig_myparcel_myparcel_support #legend li.advanced { background-position:0 -83px; }
25
+
26
+ /* Structure */
27
+ #tig_myparcel_myparcel_support .form-list,
28
+ #tig_myparcel_myparcel_support #supportWrap { width:100% !important; }
29
+ #tig_myparcel_myparcel_support #supportWrap .col-left,
30
+ #tig_myparcel_myparcel_support #supportWrap .col-right { width:50%; }
31
+ #tig_myparcel_myparcel_support #supportWrap .col-faux { padding:0 5px; }
32
+
33
+ /* Config Header */
34
+ .content-header h3 { background:transparent url(../../../images/TIG/MyParcel2014/logo_myparcel_38.png) 0 0 no-repeat !important; height:38px; padding-left:44px; line-height:38px; }
skin/adminhtml/default/default/css/TIG/MyParcel2014/system_config_edit_myparcel_magento16.css ADDED
@@ -0,0 +1,2 @@
 
 
1
+ /* General */
2
+ .system-fieldset-sub-head h4 { width:565px; }
skin/adminhtml/default/default/images/TIG/MyParcel2014/bkg_tooltip.png ADDED
Binary file
skin/adminhtml/default/default/images/TIG/MyParcel2014/btn_download_icon.png ADDED
Binary file
skin/adminhtml/default/default/images/TIG/MyParcel2014/glyph_error.gif ADDED
Binary file
skin/adminhtml/default/default/images/TIG/MyParcel2014/glyph_info.gif ADDED
Binary file
skin/adminhtml/default/default/images/TIG/MyParcel2014/glyph_manual.png ADDED
Binary file
skin/adminhtml/default/default/images/TIG/MyParcel2014/glyph_pdf.png ADDED
Binary file
skin/adminhtml/default/default/images/TIG/MyParcel2014/glyph_success.gif ADDED
Binary file
skin/adminhtml/default/default/images/TIG/MyParcel2014/glyph_warning.gif ADDED
Binary file
skin/adminhtml/default/default/images/TIG/MyParcel2014/icon-tooltip.png ADDED
Binary file
skin/adminhtml/default/default/images/TIG/MyParcel2014/legend.gif ADDED
Binary file
skin/adminhtml/default/default/images/TIG/MyParcel2014/logo_myparcel.png ADDED
Binary file
skin/adminhtml/default/default/images/TIG/MyParcel2014/logo_myparcel_19.png ADDED
Binary file
skin/adminhtml/default/default/images/TIG/MyParcel2014/logo_myparcel_38.png ADDED
Binary file
skin/adminhtml/default/default/images/TIG/MyParcel2014/tig_logo_medium.gif ADDED
Binary file
skin/frontend/base/default/js/TIG/MyParcel2014/pg_address.js ADDED
@@ -0,0 +1,157 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ /**
2
+ * ___________ __ __
3
+ * \__ ___/____ _/ |_ _____ | |
4
+ * | | / _ \\ __\\__ \ | |
5
+ * | | | |_| || | / __ \_| |__
6
+ * |____| \____/ |__| (____ /|____/
7
+ * \/
8
+ * ___ __ __
9
+ * | | ____ _/ |_ ____ _______ ____ ____ _/ |_
10
+ * | | / \\ __\_/ __ \\_ __ \ / \ _/ __ \\ __\
11
+ * | || | \| | \ ___/ | | \/| | \\ ___/ | |
12
+ * |___||___| /|__| \_____>|__| |___| / \_____>|__|
13
+ * \/ \/
14
+ * ________
15
+ * / _____/_______ ____ __ __ ______
16
+ * / \ ___\_ __ \ / _ \ | | \\____ \
17
+ * \ \_\ \| | \/| |_| || | /| |_| |
18
+ * \______ /|__| \____/ |____/ | __/
19
+ * \/ |__|
20
+ *
21
+ * NOTICE OF LICENSE
22
+ *
23
+ * This source file is subject to the Creative Commons License.
24
+ * It is available through the world-wide-web at this URL:
25
+ * http://creativecommons.org/licenses/by-nc-nd/3.0/nl/deed.en_US
26
+ * If you are unable to obtain it through the world-wide-web, please send an email
27
+ * to servicedesk@tig.nl so we can send you a copy immediately.
28
+ *
29
+ * DISCLAIMER
30
+ *
31
+ * Do not edit or add to this file if you wish to upgrade this module to newer
32
+ * versions in the future. If you wish to customize this module for your
33
+ * needs please contact servicedesk@tig.nl for more information.
34
+ *
35
+ * @copyright Copyright (c) 2014 Total Internet Group B.V. (http://www.tig.nl)
36
+ * @license http://creativecommons.org/licenses/by-nc-nd/3.0/nl/deed.en_US
37
+ */
38
+
39
+ var MyParcelPgAddress = new Class.create();
40
+ MyParcelPgAddress.prototype = {
41
+ options : null,
42
+ fieldset : null,
43
+ address : false,
44
+ _isDebug : null,
45
+
46
+ /**
47
+ * @constructor
48
+ */
49
+ initialize : function (fieldset, options) {
50
+ options = Object.extend({
51
+ debug : false
52
+ }, options || {});
53
+
54
+ this.setOptions(options);
55
+ this.setFieldset(fieldset);
56
+ },
57
+
58
+ setOptions : function(options) {
59
+ this.options = options;
60
+
61
+ return this;
62
+ },
63
+
64
+ getOptions : function() {
65
+ return this.options;
66
+ },
67
+
68
+ setFieldset : function(fieldset) {
69
+ this.fieldset = fieldset;
70
+
71
+ return this;
72
+ },
73
+
74
+ getFieldset : function() {
75
+ return this.fieldset;
76
+ },
77
+
78
+ setAddress : function(address) {
79
+ address = Object.extend({
80
+ firstname : '-',
81
+ lastname : '-',
82
+ name : '-',
83
+ street : '-',
84
+ housenumber : '-',
85
+ housenumberadd : '-',
86
+ postalcode : '-',
87
+ city : '-',
88
+ country : '-',
89
+ phone : '-'
90
+ }, address || {});
91
+
92
+ if (address['postalcodenum'] && address['postalcodealpha']) {
93
+ address.postalcode = address['postalcodenum'] + address['postalcodealpha'];
94
+ }
95
+
96
+ this.address = address;
97
+
98
+ return this;
99
+ },
100
+
101
+ getAddress : function() {
102
+ return this.address;
103
+ },
104
+
105
+ isDebug : function() {
106
+ if (this._isDebug !== null) {
107
+ return this._isDebug;
108
+ }
109
+
110
+ var options = this.getOptions();
111
+ if (options.debug == true) {
112
+ this._isDebug = true;
113
+ return true;
114
+ }
115
+
116
+ this._isDebug = false;
117
+ return false;
118
+ },
119
+
120
+ updateFieldset : function() {
121
+ var address = this.getAddress();
122
+ if (!address) {
123
+ if (this.isDebug()) {
124
+ console.error('Missing address data');
125
+ }
126
+ return this;
127
+ }
128
+
129
+ var fieldset = this.getFieldset();
130
+ var addressValue;
131
+ fieldset.select('input').each(function(element) {
132
+ var addressKey = element.readAttribute('data-tig-myparcel-address-key');
133
+ if (!addressKey) {
134
+ return;
135
+ }
136
+
137
+ addressValue = address[addressKey];
138
+ if (!addressValue) {
139
+ if (this.isDebug()) {
140
+ console.error('No data for field ' + addressKey);
141
+ }
142
+ addressValue = '-';
143
+ }
144
+ element.setValue(addressValue)
145
+ }.bind(this));
146
+
147
+ // populate info div placeholder
148
+ var pginfo = $('pginfodiv');
149
+ if(pginfo) {
150
+ var pgstreet1 = address['street'] + ' ' + address['housenumber'] + address['housenumberadd'];
151
+ var pgstreet2 = address['postalcode'] + ' ' + address['city'] + ' (' + address['country'] + ')';
152
+ pginfo.innerHTML = '<p>' + address['name'] + '<br/>' + pgstreet1 + '<br/>' + pgstreet2 + '</p>';
153
+ }
154
+
155
+ return this;
156
+ }
157
+ };