tig_postnl - Version 1.1.4

Version Notes

==== v1.1.4 =====

==== New features ====
- Added a default test account to the extension. New installation will automatically have a PostNL test account pre-configured.
- Added the option to undo a confirmation as long as the shipment has not been received by PostNL.
- Added the option to delete shipping labels. This allows you to correct an address after a shipping label has been printed. Before this change if you noticed an error in the address after you had already printed a shipping label, you had to place en entire new order to correct it. Now you can simply delete the shipping label, edit the address and print a new shipping label with the new address.

==== Minor change ====
- The validate settings button in the extension’s configuration page now also validates settings while the extension is set to test mode.
- Removed the 'EU Pack Standard (Belgium only, no signature)' product option. If you use this option, please contact the Total Internet Group servicedesk.
- The extension's test mode is now available by default. In earlier versions you had to allow test mode through a setting under advanced options.
- When a confirmation expires, the barcode's track & trace link will now also be removed.
- Improved various texts and translations.

==== Bug fixes ====
- Solved an issue where certain configurations of the PostNL shipping method would only appear if the Magento tablerates shipping method was also active.
- Solved an issue where filtering the order and shipment grids in the Magento backend on certain columns would cause an error.
- Solved an issue where the shipment status cron would stop as soon as it encountered an error, rather than continue processing the remaining shipments.
- Solved an issue where you could not confirm a shipment without a barcode due to process locking when developer mode is active.
- Solved issue in Safari where labels would be printed as .pdf.html, rather than just .pdf files.

==== v1.1.3 ====

- FIxed an issue with the extension's activation procedure.

==== v1.1.2 ====

- Updated manual.

==== v1.1.1 ====

- Fixed issue where filtering the first column of the shipment grid could cause errors.
- Removed PHP extension dependencies from the PostNL extension packages. Magento connect would sometimes falsely report a PHP extension as missing preventing the PostNL extension from being installed.

==== v1.1.0 ====

- First public release.

==== v1.0.8 ====

- Improved compatibility with Magento 1.6 and 1.11.

==== v1.0.7 ====

- Improved configuration fields.
- Improved translations.

==== v1.0.6 ====

- Improved shipment grid interface. It shoulod now be more clear which shipments have been confirmed and when they should be handed over to PostNL.
- Improved PostNL Checkout payment method handling. The Checkout summary page should now remember your chosen bank when you attempt to pay using iDEAL. 100% support for all payment methods is not guaranteed.

==== v1.0.5 ====

- Several bug fixes.
- Improved configuration interface.

==== v1.0.4 ====

- Several minor bug fixes.
- Improved Dutch translations.
- Added additional information to several fields in system/config.

==== v1.0.3 ====

- Several bug fixes. Including an issue preventing the extension from functioning properly with the compiler active.
- Several improvements to the Dutch translations.
- Improved the extension's system > config interface
- Added the Klarna payment method to PostNL Checkout

==== v1.0.2 ====

- A large number of bug fixes and general improvements
- Improved error handling. Almost all errors will now automatically provide you with a link where you can find more information and a possible solution.

==== v1.0.1 ====

- Added a filter to the possible product options you may select, based on the selected orders when mass-creating shipments from the order grid.
- Improved several translations.
- Fixed several minor bugs.

==== v1.0.0 ====

This is the initial beta release of the extension. If you have any questions, please contact the Total Internet Group Servicedesk

Download this release

Release Info

Developer TIG
Extension tig_postnl
Version 1.1.4
Comparing to
See all releases


Code changes from version 1.1.3 to 1.1.4

Files changed (30) hide show
  1. app/code/community/TIG/PostNL/Block/Adminhtml/System/Config/Form/Field/ConfigCheck.php +66 -49
  2. app/code/community/TIG/PostNL/Helper/Data.php +264 -252
  3. app/code/community/TIG/PostNL/Model/Adminhtml/Observer/OrderGrid.php +187 -120
  4. app/code/community/TIG/PostNL/Model/Adminhtml/Observer/ShipmentGrid.php +170 -172
  5. app/code/community/TIG/PostNL/Model/Adminhtml/Observer/ShipmentView.php +137 -55
  6. app/code/community/TIG/PostNL/Model/Carrier/Postnl.php +54 -55
  7. app/code/community/TIG/PostNL/Model/Core/Label.php +140 -141
  8. app/code/community/TIG/PostNL/Model/Core/Observer/Cron.php +147 -143
  9. app/code/community/TIG/PostNL/Model/Core/Shipment.php +554 -496
  10. app/code/community/TIG/PostNL/Model/Core/Shipment/Process.php +45 -43
  11. app/code/community/TIG/PostNL/Model/Core/System/Config/Source/AllProductOptions.php +19 -5
  12. app/code/community/TIG/PostNL/Model/Core/System/Config/Source/EuProductOptions.php +17 -5
  13. app/code/community/TIG/PostNL/Model/Resource/Setup.php +148 -88
  14. app/code/community/TIG/PostNL/controllers/Adminhtml/ConfigController.php +77 -54
  15. app/code/community/TIG/PostNL/controllers/Adminhtml/ShipmentController.php +314 -175
  16. app/code/community/TIG/PostNL/data/postnl_setup/data-install-1.1.4.php +53 -0
  17. app/code/community/TIG/PostNL/etc/config.xml +23 -18
  18. app/code/community/TIG/PostNL/etc/system.xml +32 -62
  19. app/design/adminhtml/default/default/layout/TIG/postnl.xml +26 -20
  20. app/design/adminhtml/default/default/template/TIG/PostNL/sales/shipment/testmode_warning.phtml +53 -0
  21. app/design/adminhtml/default/default/template/TIG/PostNL/system/config/form/field/config_check.phtml +38 -24
  22. app/design/adminhtml/default/default/template/TIG/PostNL/system/config/form/field/js.phtml +63 -54
  23. app/design/adminhtml/default/default/template/TIG/PostNL/system/config/form/field/support_tab.phtml +21 -20
  24. app/locale/en_US/TIG_PostNL.csv +21 -9
  25. app/locale/nl_NL/TIG_PostNL.csv +30 -18
  26. package.xml +38 -17
  27. skin/adminhtml/default/default/css/TIG/PostNL/messages.css +9 -0
  28. skin/adminhtml/default/default/css/TIG/PostNL/system_config_edit_postnl.css +0 -9
  29. skin/adminhtml/default/default/js/TIG/PostNL/validate.js +17 -18
  30. skin/adminhtml/default/default/media/TIG/PostNL/manual.pdf +0 -0
app/code/community/TIG/PostNL/Block/Adminhtml/System/Config/Form/Field/ConfigCheck.php CHANGED
@@ -1,28 +1,28 @@
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@totalinternetgroup.nl so we can send you a copy immediately.
@@ -35,25 +35,29 @@
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
- class TIG_PostNL_Block_Adminhtml_System_Config_Form_Field_ConfigCheck extends TIG_PostNL_Block_Adminhtml_System_Config_Form_Field_TextBox_Abstract
 
40
  {
41
  /**
42
  * XML paths to use GlobalPack/Checkout settings
43
  */
44
  const XML_PATH_USE_GLOBALPACK = 'postnl/cif/use_globalpack';
45
  const XML_PATH_USE_CHECKOUT = 'postnl/cif/use_checkout';
46
-
47
  /**
48
  * Template file used by this element
49
- *
50
  * @var string
51
  */
52
  protected $_template = 'TIG/PostNL/system/config/form/field/config_check.phtml';
53
-
54
  /**
55
  * Get the postnl helper
56
- *
57
  * @return TIG_PostNL_Helper_Data
58
  */
59
  public function getPostnlHelper()
@@ -61,28 +65,28 @@ class TIG_PostNL_Block_Adminhtml_System_Config_Form_Field_ConfigCheck extends TI
61
  if ($this->hasPostnlHelper()) {
62
  return $this->getData('postnl_helper');
63
  }
64
-
65
  $helper = Mage::helper('postnl');
66
-
67
  $this->setPostnlHelper($helper);
68
  return $helper;
69
  }
70
-
71
  /**
72
  * Check if live mode is enabled
73
- *
74
  * @return boolean
75
  */
76
  public function isLiveEnabled()
77
  {
78
  $helper = $this->getPostnlHelper();
79
-
80
  return $helper->isEnabled(false, false, false);
81
  }
82
-
83
  /**
84
  * gets config errors from the registry
85
- *
86
  * @return array|null
87
  */
88
  public function getLiveConfigErrors()
@@ -91,25 +95,25 @@ class TIG_PostNL_Block_Adminhtml_System_Config_Form_Field_ConfigCheck extends TI
91
  if (is_null($configErrors)) {
92
  $configErrors = Mage::registry('postnl_enabled_errors');
93
  }
94
-
95
  return $configErrors;
96
  }
97
-
98
  /**
99
  * Check if test mode is enabled
100
- *
101
  * @return boolean
102
  */
103
  public function isTestEnabled()
104
  {
105
  $helper = $this->getPostnlHelper();
106
-
107
  return $helper->isEnabled(false, false, true);
108
  }
109
-
110
  /**
111
  * gets config errors from the registry
112
- *
113
  * @return array|null
114
  */
115
  public function getTestConfigErrors()
@@ -118,13 +122,26 @@ class TIG_PostNL_Block_Adminhtml_System_Config_Form_Field_ConfigCheck extends TI
118
  if (is_null($configErrors)) {
119
  $configErrors = Mage::registry('postnl_enabled_test_errors');
120
  }
121
-
122
  return $configErrors;
123
  }
124
-
 
 
 
 
 
 
 
 
 
 
 
 
 
125
  /**
126
  * Check if global shipments are
127
- *
128
  * @return boolean
129
  */
130
  public function isGlobalEnabled()
@@ -133,15 +150,15 @@ class TIG_PostNL_Block_Adminhtml_System_Config_Form_Field_ConfigCheck extends TI
133
  if (!$globalEnabled) {
134
  return true;
135
  }
136
-
137
  $helper = $this->getPostnlHelper();
138
-
139
- return $helper->isEnabled(false, true, false);
140
  }
141
-
142
  /**
143
  * gets config errors from the registry
144
- *
145
  * @return array|null
146
  */
147
  public function getGlobalConfigErrors()
@@ -150,13 +167,13 @@ class TIG_PostNL_Block_Adminhtml_System_Config_Form_Field_ConfigCheck extends TI
150
  if (is_null($configErrors)) {
151
  $configErrors = Mage::registry('postnl_enabled_global_errors');
152
  }
153
-
154
  return $configErrors;
155
  }
156
-
157
  /**
158
  * Check if checkout is enabled
159
- *
160
  * @return boolean
161
  */
162
  public function isCheckoutEnabled()
@@ -165,15 +182,15 @@ class TIG_PostNL_Block_Adminhtml_System_Config_Form_Field_ConfigCheck extends TI
165
  if (!$checkoutEnabled) {
166
  return true;
167
  }
168
-
169
  $helper = Mage::helper('postnl/checkout');
170
-
171
  return $helper->isCheckoutEnabled(false);
172
  }
173
-
174
  /**
175
  * gets config errors from the registry
176
- *
177
  * @return array|null
178
  */
179
  public function getCheckoutConfigErrors()
@@ -182,7 +199,7 @@ class TIG_PostNL_Block_Adminhtml_System_Config_Form_Field_ConfigCheck extends TI
182
  if (is_null($configErrors)) {
183
  $configErrors = Mage::registry('postnl_enabled_checkout_errors');
184
  }
185
-
186
  return $configErrors;
187
  }
188
  }
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@totalinternetgroup.nl so we can send you a copy immediately.
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
+ * @method boolean hasPostnlHelper()
40
+ * @method TIG_PostNL_Block_Adminhtml_System_Config_Form_Field_ConfigCheck setPostnlHelper(TIG_PostnL_Helper_Data $value)
41
  */
42
+ class TIG_PostNL_Block_Adminhtml_System_Config_Form_Field_ConfigCheck
43
+ extends TIG_PostNL_Block_Adminhtml_System_Config_Form_Field_TextBox_Abstract
44
  {
45
  /**
46
  * XML paths to use GlobalPack/Checkout settings
47
  */
48
  const XML_PATH_USE_GLOBALPACK = 'postnl/cif/use_globalpack';
49
  const XML_PATH_USE_CHECKOUT = 'postnl/cif/use_checkout';
50
+
51
  /**
52
  * Template file used by this element
53
+ *
54
  * @var string
55
  */
56
  protected $_template = 'TIG/PostNL/system/config/form/field/config_check.phtml';
57
+
58
  /**
59
  * Get the postnl helper
60
+ *
61
  * @return TIG_PostNL_Helper_Data
62
  */
63
  public function getPostnlHelper()
65
  if ($this->hasPostnlHelper()) {
66
  return $this->getData('postnl_helper');
67
  }
68
+
69
  $helper = Mage::helper('postnl');
70
+
71
  $this->setPostnlHelper($helper);
72
  return $helper;
73
  }
74
+
75
  /**
76
  * Check if live mode is enabled
77
+ *
78
  * @return boolean
79
  */
80
  public function isLiveEnabled()
81
  {
82
  $helper = $this->getPostnlHelper();
83
+
84
  return $helper->isEnabled(false, false, false);
85
  }
86
+
87
  /**
88
  * gets config errors from the registry
89
+ *
90
  * @return array|null
91
  */
92
  public function getLiveConfigErrors()
95
  if (is_null($configErrors)) {
96
  $configErrors = Mage::registry('postnl_enabled_errors');
97
  }
98
+
99
  return $configErrors;
100
  }
101
+
102
  /**
103
  * Check if test mode is enabled
104
+ *
105
  * @return boolean
106
  */
107
  public function isTestEnabled()
108
  {
109
  $helper = $this->getPostnlHelper();
110
+
111
  return $helper->isEnabled(false, false, true);
112
  }
113
+
114
  /**
115
  * gets config errors from the registry
116
+ *
117
  * @return array|null
118
  */
119
  public function getTestConfigErrors()
122
  if (is_null($configErrors)) {
123
  $configErrors = Mage::registry('postnl_enabled_test_errors');
124
  }
125
+
126
  return $configErrors;
127
  }
128
+
129
+ /**
130
+ * Check if the extension is currently set to test mode.
131
+ *
132
+ * @return boolean
133
+ */
134
+ public function isTestModeActive()
135
+ {
136
+ $helper = $this->getPostnlHelper();
137
+
138
+ $isTestMode = $helper->isTestMode();
139
+ return $isTestMode;
140
+ }
141
+
142
  /**
143
  * Check if global shipments are
144
+ *
145
  * @return boolean
146
  */
147
  public function isGlobalEnabled()
150
  if (!$globalEnabled) {
151
  return true;
152
  }
153
+
154
  $helper = $this->getPostnlHelper();
155
+
156
+ return $helper->isEnabled(false, true, $this->isTestModeActive());
157
  }
158
+
159
  /**
160
  * gets config errors from the registry
161
+ *
162
  * @return array|null
163
  */
164
  public function getGlobalConfigErrors()
167
  if (is_null($configErrors)) {
168
  $configErrors = Mage::registry('postnl_enabled_global_errors');
169
  }
170
+
171
  return $configErrors;
172
  }
173
+
174
  /**
175
  * Check if checkout is enabled
176
+ *
177
  * @return boolean
178
  */
179
  public function isCheckoutEnabled()
182
  if (!$checkoutEnabled) {
183
  return true;
184
  }
185
+
186
  $helper = Mage::helper('postnl/checkout');
187
+
188
  return $helper->isCheckoutEnabled(false);
189
  }
190
+
191
  /**
192
  * gets config errors from the registry
193
+ *
194
  * @return array|null
195
  */
196
  public function getCheckoutConfigErrors()
199
  if (is_null($configErrors)) {
200
  $configErrors = Mage::registry('postnl_enabled_checkout_errors');
201
  }
202
+
203
  return $configErrors;
204
  }
205
  }
app/code/community/TIG/PostNL/Helper/Data.php CHANGED
@@ -1,28 +1,28 @@
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@totalinternetgroup.nl so we can send you a copy immediately.
@@ -42,65 +42,70 @@ class TIG_PostNL_Helper_Data extends Mage_Core_Helper_Abstract
42
  * Log filename to log all non-specific PostNL exceptions
43
  */
44
  const POSTNL_EXCEPTION_LOG_FILE = 'TIG_PostNL_Exception.log';
45
-
46
  /**
47
  * Log filename to log all non-specific PostNL debug messages
48
  */
49
  const POSTNL_DEBUG_LOG_FILE = 'TIG_PostNL_Debug.log';
50
-
51
  /**
52
  * Directory inside var/log where PostNL log files will be logged
53
  */
54
  const POSTNL_LOG_DIRECTORY = 'TIG_PostNL';
55
-
56
  /**
57
  * Log filename to log all cron log messages
58
  */
59
  const POSTNL_CRON_DEBUG_LOG_FILE = 'TIG_PostNL_Cron_Debug.log';
60
-
61
  /**
62
  * XML path to postnl general active/inactive setting
63
  */
64
  const XML_PATH_EXTENSION_ACTIVE = 'postnl/general/active';
65
-
66
  /**
67
  * XML path to postnl carier active/inactive setting
68
  */
69
  const XML_PATH_CARRIER_ACTIVE = 'carriers/postnl/active';
70
-
71
  /**
72
  * XML path to test/live mode config option
73
  */
74
  const XML_PATH_TEST_MODE = 'postnl/cif_labels_and_confirming/mode';
75
-
76
  /**
77
  * XML path to the test mode allowed config option
78
  */
79
  const XML_PATH_TEST_MODE_ALLOWED = 'postnl/advanced/allow_test_mode';
80
-
81
  /**
82
  * XML path to debug mode config option
83
  */
84
  const XML_PATH_DEBUG_MODE = 'postnl/advanced/debug_mode';
85
-
86
  /**
87
  * XML path to 'is_activated' flag
88
  */
89
  const XML_PATH_IS_ACTIVATED = 'postnl/general/is_activated';
90
-
91
  /**
92
  * XML path to 'show_error_details_in_frontend' flag
93
  */
94
  const XML_PATH_SHOW_ERROR_DETAILS_IN_FRONTEND = 'postnl/advanced/show_error_details_in_frontend';
95
-
96
  /**
97
  * XML path to use_globalpack settings
98
  */
99
  const XML_PATH_USE_GLOBALPACK = 'postnl/cif/use_globalpack';
100
-
 
 
 
 
 
101
  /**
102
  * Required configuration fields
103
- *
104
  * @var array
105
  */
106
  protected $_requiredFields = array(
@@ -115,30 +120,30 @@ class TIG_PostNL_Helper_Data extends Mage_Core_Helper_Abstract
115
  'postnl/cif_sender_address/postcode',
116
  'postnl/cif_sender_address/city',
117
  );
118
-
119
  /**
120
  * Required configuration fields for live mode
121
- *
122
  * @var array
123
  */
124
  protected $_liveModeRequiredFields = array(
125
  'postnl/cif/live_username',
126
  'postnl/cif/live_password',
127
  );
128
-
129
  /**
130
  * Required configuration fields for test mode
131
- *
132
  * @var array
133
  */
134
  protected $_testModeRequiredFields = array(
135
  'postnl/cif/test_username',
136
  'postnl/cif/test_password',
137
  );
138
-
139
  /**
140
  * Required configuration fields when using global shipments
141
- *
142
  * @var array
143
  */
144
  protected $_globalShipmentRequiredFields = array(
@@ -149,50 +154,50 @@ class TIG_PostNL_Helper_Data extends Mage_Core_Helper_Abstract
149
  'postnl/cif_globalpack_settings/country_of_origin_attribute',
150
  'postnl/cif_globalpack_settings/description_attribute',
151
  );
152
-
153
  /**
154
  * Get required fields array
155
- *
156
  * @return array
157
  */
158
  public function getRequiredFields()
159
  {
160
  return $this->_requiredFields;
161
  }
162
-
163
  /**
164
  * Get required fields for live mode array
165
- *
166
  * @return array
167
  */
168
  public function getLiveModeRequiredFields()
169
  {
170
  return $this->_liveModeRequiredFields;
171
  }
172
-
173
  /**
174
  * Get required fields for test mode array
175
- *
176
  * @return array
177
  */
178
  public function getTestModeRequiredFields()
179
  {
180
  return $this->_testModeRequiredFields;
181
  }
182
-
183
  /**
184
  * Get required fields for global shipments array
185
- *
186
  * @return array
187
  */
188
  public function getGlobalShipmentsRequiredFields()
189
  {
190
  return $this->_globalShipmentRequiredFields;
191
  }
192
-
193
  /**
194
  * Get debug mode config setting
195
- *
196
  * @return int
197
  */
198
  public function getDebugMode()
@@ -200,18 +205,18 @@ class TIG_PostNL_Helper_Data extends Mage_Core_Helper_Abstract
200
  if (Mage::registry('postnl_debug_mode') !== null) {
201
  return Mage::registry('postnl_debug_mode');
202
  }
203
-
204
  $debugMode = (int) Mage::getStoreConfig(self::XML_PATH_DEBUG_MODE, Mage_Core_Model_App::ADMIN_STORE_ID);
205
-
206
  Mage::register('postnl_debug_mode', $debugMode);
207
  return $debugMode;
208
  }
209
 
210
  /**
211
  * Checks to see if the module may ship to the Netherlands using PostNL standard shipments
212
- *
213
  * @param boolean|int $storeId
214
- *
215
  * @return boolean
216
  */
217
  public function canUseStandard($storeId = false)
@@ -219,21 +224,21 @@ class TIG_PostNL_Helper_Data extends Mage_Core_Helper_Abstract
219
  if ($storeId === false) {
220
  $storeId = Mage::app()->getStore()->getId();
221
  }
222
-
223
  $standardProductOptions = Mage::getModel('postnl_core/system_config_source_standardProductOptions')
224
  ->getAvailableOptions($storeId);
225
  if (empty($standardProductOptions)) {
226
  return false;
227
  }
228
-
229
  return true;
230
  }
231
 
232
  /**
233
  * Checks to see if the module may ship using PakjeGemak
234
- *
235
  * @param boolean|int $storeId
236
- *
237
  * @return boolean
238
  */
239
  public function canUsePakjeGemak($storeId = false)
@@ -241,22 +246,22 @@ class TIG_PostNL_Helper_Data extends Mage_Core_Helper_Abstract
241
  if ($storeId === false) {
242
  $storeId = Mage::app()->getStore()->getId();
243
  }
244
-
245
  $pakjeGemakProductoptions = Mage::getModel('postnl_core/system_config_source_pakjeGemakProductOptions')
246
  ->getAvailableOptions($storeId);
247
-
248
  if (empty($pakjeGemakProductoptions)) {
249
  return false;
250
  }
251
-
252
  return true;
253
  }
254
 
255
  /**
256
  * Checks to see if the module may ship to EU countries using EPS
257
- *
258
  * @param boolean|int $storeId
259
- *
260
  * @return boolean
261
  */
262
  public function canUseEps($storeId = false)
@@ -264,22 +269,22 @@ class TIG_PostNL_Helper_Data extends Mage_Core_Helper_Abstract
264
  if ($storeId === false) {
265
  $storeId = Mage::app()->getStore()->getId();
266
  }
267
-
268
  $euProductOptions = Mage::getModel('postnl_core/system_config_source_euProductOptions')
269
- ->getAvailableOptions($storeId);
270
-
271
  if (empty($euProductOptions)) {
272
  return false;
273
  }
274
-
275
  return true;
276
  }
277
 
278
  /**
279
  * Checks to see if the module may ship to countries outside the EU using GlobalPack
280
- *
281
  * @param boolean|int $storeId
282
- *
283
  * @return boolean
284
  */
285
  public function canUseGlobalPack($storeId = false)
@@ -287,28 +292,46 @@ class TIG_PostNL_Helper_Data extends Mage_Core_Helper_Abstract
287
  if ($storeId === false) {
288
  $storeId = Mage::app()->getStore()->getId();
289
  }
290
-
291
  if (!$this->isGlobalAllowed()) {
292
  return false;
293
  }
294
-
295
  $globalProductOptions = Mage::getModel('postnl_core/system_config_source_globalProductOptions')
296
  ->getAvailableOptions($storeId);
297
-
298
  if (empty($globalProductOptions)) {
299
  return false;
300
  }
301
-
302
  return true;
303
  }
304
-
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
305
  /**
306
  * Save state of configuration field sets
307
  *
308
  * @param array $configState
309
- *
310
  * @return bool
311
- *
312
  * @see Mage_Adminhtml_System_ConfigController::_saveState()
313
  */
314
  public function saveConfigState($configState = array())
@@ -317,46 +340,48 @@ class TIG_PostNL_Helper_Data extends Mage_Core_Helper_Abstract
317
  if (!$adminUser) {
318
  return false;
319
  }
320
-
321
  if (!is_array($configState)) {
322
  return false;
323
  }
324
-
325
  $extra = $adminUser->getExtra();
326
  if (!is_array($extra)) {
327
  $extra = array();
328
  }
329
-
330
  if (!isset($extra['configState'])) {
331
  $extra['configState'] = array();
332
  }
333
-
334
  foreach ($configState as $fieldset => $state) {
335
  $extra['configState'][$fieldset] = $state;
336
  }
337
-
338
  $adminUser->setExtra($extra)
339
  ->saveExtra($extra);
340
 
341
  return true;
342
  }
343
-
344
  /**
345
  * Checks if GlobalPack may be used.
346
- *
347
  * @return boolean
348
  */
349
  public function isGlobalAllowed()
350
  {
351
  $storeId = Mage_Core_Model_App::ADMIN_STORE_ID;
352
-
353
  $useGlobal = Mage::getStoreConfigFlag(self::XML_PATH_USE_GLOBALPACK, $storeId);
354
  return $useGlobal;
355
  }
356
-
357
  /**
358
  * Check if the module is set to test mode
359
- *
 
 
360
  * @return boolean
361
  */
362
  public function isTestMode($storeId = false)
@@ -364,65 +389,52 @@ class TIG_PostNL_Helper_Data extends Mage_Core_Helper_Abstract
364
  if (Mage::registry('postnl_test_mode') !== null) {
365
  return Mage::registry('postnl_test_mode');
366
  }
367
-
368
  if ($storeId === false) {
369
  $storeId = Mage::app()->getStore()->getId();
370
  }
371
-
372
- $testModeAllowed = $this->isTestModeAllowed();
373
- if (!$testModeAllowed) {
374
- Mage::register('postnl_test_mode', false);
375
- return false;
376
- }
377
-
378
  $testMode = Mage::getStoreConfigFlag(self::XML_PATH_TEST_MODE, $storeId);
379
-
380
  Mage::register('postnl_test_mode', $testMode);
381
  return $testMode;
382
  }
383
-
384
  /**
385
  * Checks if test mode is currently allowed
386
- *
 
 
387
  * @return boolean
388
  */
389
  public function isTestModeAllowed()
390
  {
391
- if (Mage::registry('postnl_test_mode_allowed') !== null) {
392
- return Mage::registry('postnl_test_mode_allowed');
393
- }
394
-
395
- $storeId = Mage_Core_Model_App::ADMIN_STORE_ID;
396
-
397
- $testModeAllowed = Mage::getStoreConfigFlag(self::XML_PATH_TEST_MODE_ALLOWED, $storeId);
398
-
399
- Mage::register('postnl_test_mode_allowed', $testModeAllowed);
400
- return $testModeAllowed;
401
  }
402
-
403
  /**
404
  * Alias for isEnabled()
405
- *
406
  * @param int | bool $storeId
407
  * @param boolean $checkGlobal
408
  * @param null|boolean $forceTestMode
409
- *
410
  * @return boolean
411
- *
412
  * @see TIG_PostNL_Helper_Data::isEnabled()
413
  */
414
  public function isActive($storeId = false, $checkGlobal = false, $forceTestMode = null)
415
  {
416
  return $this->isEnabled($storeId, $checkGlobal, $forceTestMode);
417
  }
418
-
419
  /**
420
  * Determines if the extension is active
421
- *
422
  * @param int | bool $storeId
423
  * @param boolean $checkGlobal
424
  * @param null|boolean $forceTestMode
425
- *
426
  * @return boolean
427
  */
428
  public function isEnabled($storeId = false, $checkGlobal = false, $forceTestMode = null)
@@ -432,7 +444,7 @@ class TIG_PostNL_Helper_Data extends Mage_Core_Helper_Abstract
432
  } else {
433
  $testMode = $forceTestMode;
434
  }
435
-
436
  $registryKey = 'postnl_enabled';
437
  if ($checkGlobal) {
438
  $registryKey .= '_global';
@@ -440,33 +452,33 @@ class TIG_PostNL_Helper_Data extends Mage_Core_Helper_Abstract
440
  if ($testMode) {
441
  $registryKey .= '_test';
442
  }
443
-
444
  if (Mage::registry($registryKey) !== null) {
445
  return Mage::registry($registryKey);
446
  }
447
-
448
  if ($storeId === false) {
449
  $storeId = Mage_Core_Model_App::ADMIN_STORE_ID;
450
  }
451
-
452
  /**
453
  * Check if the module has been enabled
454
  */
455
  $enabled = Mage::getStoreConfigFlag(self::XML_PATH_EXTENSION_ACTIVE, $storeId);
456
  if ($enabled === false) {
457
  Mage::register($registryKey, false);
458
-
459
  $errors = array(
460
  array(
461
  'code' => 'POSTNL-0030',
462
  'message' => $this->__('You have not yet enabled the extension.'),
463
  )
464
  );
465
-
466
  Mage::register($registryKey . '_errors', $errors);
467
  return false;
468
  }
469
-
470
  /**
471
  * Check if the module's required configuration options have been filled
472
  */
@@ -475,14 +487,14 @@ class TIG_PostNL_Helper_Data extends Mage_Core_Helper_Abstract
475
  Mage::register($registryKey, false);
476
  return false;
477
  }
478
-
479
  /**
480
  * Check if the PostNL shipping method is active
481
  */
482
  $postnlShippingMethodEnabled = Mage::getStoreConfigFlag(self::XML_PATH_CARRIER_ACTIVE, $storeId);
483
  if ($postnlShippingMethodEnabled === false) {
484
  Mage::register($registryKey, false);
485
-
486
  $shippingMethodSectionurl = Mage::helper("adminhtml")->getUrl(
487
  'adminhtml/system_config/edit',
488
  array(
@@ -490,13 +502,13 @@ class TIG_PostNL_Helper_Data extends Mage_Core_Helper_Abstract
490
  'section' => 'carriers',
491
  )
492
  );
493
-
494
  $errorMessage = $this->__(
495
  'The PostNL shipping method has not been enabled. You can enable the PostNL shipping method under %sSystem > Config > Shipping Methods%s.',
496
  '<a href="' . $shippingMethodSectionurl . '" target="_blank" title="' . $this->__('Shipping Methods') . '">',
497
  '</a>'
498
  );
499
-
500
  $errors = array(
501
  array(
502
  'code' => 'POSTNL-0031',
@@ -506,14 +518,14 @@ class TIG_PostNL_Helper_Data extends Mage_Core_Helper_Abstract
506
  Mage::register($registryKey . '_errors', $errors);
507
  return false;
508
  }
509
-
510
  /**
511
  * The PostNL module only works with EUR as the shop's base currency
512
  */
513
  $baseCurrencyCode = Mage::getModel('core/store')->load($storeId)->getBaseCurrencyCode();
514
  if ($baseCurrencyCode != 'EUR') {
515
  Mage::register($registryKey, false);
516
-
517
  $errors = array(
518
  array(
519
  'code' => 'POSTNL-0032',
@@ -523,21 +535,21 @@ class TIG_PostNL_Helper_Data extends Mage_Core_Helper_Abstract
523
  Mage::register($registryKey . '_errors', $errors);
524
  return false;
525
  }
526
-
527
  Mage::register($registryKey, true);
528
  return true;
529
  }
530
-
531
  /**
532
  * Check if the modules has been confgured.
533
  * The required fields will only be checked to see if they're not empty. The values entered will not be validated
534
- *
535
  * @param int | boolean $storeId
536
  * @param boolean $checkGlobal
537
  * @param null|boolean $forceTestMode
538
- *
539
  * @return boolean
540
- *
541
  * @todo properly implement global check
542
  */
543
  public function isConfigured($storeId = false, $checkGlobal = false, $forceTestMode = null)
@@ -547,7 +559,7 @@ class TIG_PostNL_Helper_Data extends Mage_Core_Helper_Abstract
547
  } else {
548
  $testMode = $forceTestMode;
549
  }
550
-
551
  $registryKey = 'postnl_is_configured';
552
  if ($checkGlobal) {
553
  $registryKey .= '_global';
@@ -555,13 +567,13 @@ class TIG_PostNL_Helper_Data extends Mage_Core_Helper_Abstract
555
  if ($testMode) {
556
  $registryKey .= '_test';
557
  }
558
-
559
  if (Mage::registry($registryKey) !== null) {
560
  return Mage::registry($registryKey);
561
  }
562
-
563
  $errors = array();
564
-
565
  /**
566
  * Check if the module has been activated
567
  */
@@ -572,16 +584,16 @@ class TIG_PostNL_Helper_Data extends Mage_Core_Helper_Abstract
572
  'message' => $this->__('The extension has not been activated.'),
573
  );
574
  }
575
-
576
  if ($storeId === false) {
577
  $storeId = Mage::app()->getStore()->getId();
578
  }
579
-
580
  /**
581
  * Get the bse required fields. These are always required.
582
  */
583
  $baseFields = $this->getRequiredFields();
584
-
585
  /**
586
  * Get either the live mode or test mode required fields
587
  */
@@ -591,7 +603,7 @@ class TIG_PostNL_Helper_Data extends Mage_Core_Helper_Abstract
591
  $modeFields = $this->getLiveModeRequiredFields();
592
  }
593
  $requiredFields = array_merge($modeFields, $baseFields);
594
-
595
  /**
596
  * If this check pertains to a global shipment, get the global shipments required fields as well
597
  */
@@ -599,7 +611,7 @@ class TIG_PostNL_Helper_Data extends Mage_Core_Helper_Abstract
599
  $globalFields = $this->getGlobalShipmentsRequiredFields();
600
  $requiredFields = array_merge($requiredFields, $globalFields);
601
  }
602
-
603
  /**
604
  * Check if each required field is filled. If not add the field's label to an array of missing fields so we can later
605
  * inform the merchant which fields exactly are missing.
@@ -609,25 +621,25 @@ class TIG_PostNL_Helper_Data extends Mage_Core_Helper_Abstract
609
  $section = $sections->postnl;
610
  foreach ($requiredFields as $requiredField) {
611
  $value = Mage::getStoreConfig($requiredField, $storeId);
612
-
613
  if ($value === null || $value === '') {
614
  $fieldParts = explode('/', $requiredField);
615
  $field = $fieldParts[2];
616
  $group = $fieldParts[1];
617
-
618
  $label = (string) $section->groups->$group->fields->$field->label;
619
  $groupLabel = (string) $section->groups->$group->label;
620
  $groupName = $section->groups->$group->getName();
621
-
622
  $errors[] = array(
623
  'code' => 'POSTNL-0034',
624
  'message' => $this->__('%s > %s is required.', $this->__($groupLabel), $this->__($label)),
625
  );
626
-
627
  $this->saveConfigState(array('postnl_' . $groupName => 1));
628
  }
629
  }
630
-
631
  /**
632
  * If any errors were detected, add them to the registry and return false
633
  */
@@ -636,14 +648,14 @@ class TIG_PostNL_Helper_Data extends Mage_Core_Helper_Abstract
636
  Mage::register($registryKey . '_errors', $errors);
637
  return false;
638
  }
639
-
640
  Mage::register($registryKey, true);
641
  return true;
642
  }
643
-
644
  /**
645
  * Check if debug logging is enabled
646
- *
647
  * @return boolean
648
  */
649
  public function isLoggingEnabled()
@@ -652,13 +664,13 @@ class TIG_PostNL_Helper_Data extends Mage_Core_Helper_Abstract
652
  if ($debugMode > 1) {
653
  return true;
654
  }
655
-
656
  return false;
657
  }
658
-
659
  /**
660
  * Check if exception logging is enabled
661
- *
662
  * @return boolean
663
  */
664
  public function isExceptionLoggingEnabled()
@@ -667,26 +679,26 @@ class TIG_PostNL_Helper_Data extends Mage_Core_Helper_Abstract
667
  if ($debugMode > 0) {
668
  return true;
669
  }
670
-
671
  return false;
672
  }
673
-
674
  /**
675
  * Returns path to specified directory for specified module.
676
- *
677
  * Based on Mage_Core_Model_Config::getModuleDir()
678
- *
679
  * @param string $dir The directory in question
680
  * @param string $module The module for which the directory is needed
681
- *
682
  * @return string
683
- *
684
  * @see Mage_Core_Model_Config::getModuleDir()
685
  */
686
  public function getModuleDir($dir, $moduleName = 'TIG_PostNL')
687
  {
688
  $config = Mage::app()->getConfig();
689
-
690
  $codePool = (string)$config->getModuleConfig($moduleName)->codePool;
691
  $path = $config->getOptions()->getCodeDir()
692
  . DS
@@ -697,15 +709,15 @@ class TIG_PostNL_Helper_Data extends Mage_Core_Helper_Abstract
697
  $path .= DS . $dir;
698
 
699
  $path = str_replace('/', DS, $path);
700
-
701
  return $path;
702
  }
703
-
704
  /**
705
  * formats input XML string to improve readability
706
- *
707
  * @param string $xml
708
- *
709
  * @return string
710
  */
711
  public function formatXML($xml)
@@ -713,7 +725,7 @@ class TIG_PostNL_Helper_Data extends Mage_Core_Helper_Abstract
713
  if (empty($xml)) {
714
  return '';
715
  }
716
-
717
  $dom = new DOMDocument();
718
  $dom->loadXML($xml);
719
  $dom->preserveWhiteSpace = false;
@@ -721,18 +733,18 @@ class TIG_PostNL_Helper_Data extends Mage_Core_Helper_Abstract
721
 
722
  return $dom->saveXML();
723
  }
724
-
725
  /**
726
  * Logs a debug message. Based on Mage::log
727
- *
728
  * @param string $message
729
  * @param int | null $level
730
  * @param string | null $file
731
  * @param boolean $forced
732
  * @param boolean $isError
733
- *
734
  * @return TIG_PostNL_Helper_Data
735
- *
736
  * @see Mage::log
737
  */
738
  public function log($message, $level = null, $file = null, $forced = false, $isError = false)
@@ -742,48 +754,48 @@ class TIG_PostNL_Helper_Data extends Mage_Core_Helper_Abstract
742
  } elseif ($isError !== true && !$this->isLoggingEnabled()) {
743
  return $this;
744
  }
745
-
746
  if (is_null($level)) {
747
  $level = Zend_Log::DEBUG;
748
  }
749
-
750
  if (is_null($file)) {
751
  $file = static::POSTNL_LOG_DIRECTORY . DS . static::POSTNL_DEBUG_LOG_FILE;
752
  }
753
-
754
  $this->createLogDir();
755
-
756
  Mage::log($message, $level, $file, $forced);
757
-
758
  return $this;
759
  }
760
-
761
  /**
762
  * Logs a cron debug messageto a seperate file in order to differentiate it from other debug messages
763
- *
764
  * @param string $message
765
  * @param int | int $level
766
- *
767
  * @return TIG_PostNL_Helper_Data
768
- *
769
  * @see Mage::log
770
  */
771
  public function cronLog($message, $level = null)
772
  {
773
  $file = self::POSTNL_LOG_DIRECTORY . DS . self::POSTNL_CRON_DEBUG_LOG_FILE;
774
-
775
  return $this->log($message, $level, $file);
776
  }
777
-
778
  /**
779
  * Logs a PostNL Exception. Based on Mage::logException
780
- *
781
  * N.B. this uses forced logging
782
- *
783
  * @param string|Exception $exception
784
- *
785
  * @return TIG_PostNL_Helper_Data
786
- *
787
  * @see Mage::logException
788
  */
789
  public function logException($exception)
@@ -791,25 +803,25 @@ class TIG_PostNL_Helper_Data extends Mage_Core_Helper_Abstract
791
  if (!$this->isExceptionLoggingEnabled()) {
792
  return $this;
793
  }
794
-
795
  if (is_object($exception)) {
796
  $message = "\n" . $exception->__toString();
797
  } else {
798
  $message = $exception;
799
  }
800
-
801
  $file = self::POSTNL_LOG_DIRECTORY . DS . self::POSTNL_EXCEPTION_LOG_FILE;
802
-
803
  $this->log($message, Zend_Log::ERR, $file, false, true);
804
-
805
  return $this;
806
  }
807
-
808
  /**
809
  * Checks if the current edition of Magento is enterprise. Uses Mage::getEdition if available or version_compare if it is not
810
- *
811
  * @return boolean
812
- *
813
  * @throws TIG_PostNL_Exception
814
  */
815
  public function isEnterprise()
@@ -822,11 +834,11 @@ class TIG_PostNL_Helper_Data extends Mage_Core_Helper_Abstract
822
  if ($edition == Mage::EDITION_ENTERPRISE) {
823
  return true;
824
  }
825
-
826
  if ($edition == Mage::EDITION_COMMUNITY) {
827
  return false;
828
  }
829
-
830
  /**
831
  * If the edition is not community or enterprise, it is not supported
832
  */
@@ -835,7 +847,7 @@ class TIG_PostNL_Helper_Data extends Mage_Core_Helper_Abstract
835
  'POSTNL-0035'
836
  );
837
  }
838
-
839
  /**
840
  * Do a version check instead
841
  */
@@ -843,13 +855,13 @@ class TIG_PostNL_Helper_Data extends Mage_Core_Helper_Abstract
843
  if (version_compare($version, '1.9.0.0', '>=')) { //1.9.0.0 was the first Magento Enterprise version
844
  return true;
845
  }
846
-
847
  return false;
848
  }
849
-
850
  /**
851
  * Checks if the current environment is in the shop's admin area.
852
- *
853
  * @return boolean
854
  */
855
  public function isAdmin()
@@ -867,30 +879,30 @@ class TIG_PostNL_Helper_Data extends Mage_Core_Helper_Abstract
867
 
868
  return false;
869
  }
870
-
871
  /**
872
  * Creates a seperate dir to log PostNL log files. Does nothing if the dir already exists
873
- *
874
  * @return TIG_PostNL_Exception
875
  */
876
  public function createLogDir()
877
  {
878
  $logDir = Mage::getBaseDir('var') . DS . 'log' . DS . self::POSTNL_LOG_DIRECTORY;
879
-
880
  if (!is_dir($logDir)) {
881
  mkdir($logDir, 0777, true);
882
  chmod($logDir, 0777);
883
  }
884
-
885
  return $this;
886
  }
887
-
888
  /**
889
  * Gets the knowledge base URL for a specified error code. First we check to see if we have an entry in config.xml for this
890
  * error code and if so, if it has an associated URL.
891
- *
892
  * @param string $errorCode The error code (for example: POSTNL-0001)
893
- *
894
  * @return string The URL or an empty string if no URL could be found
895
  */
896
  public function getErrorUrl($errorCode)
@@ -899,20 +911,20 @@ class TIG_PostNL_Helper_Data extends Mage_Core_Helper_Abstract
899
  if ($error !== false && $error->url) {
900
  return (string) $error->url;
901
  }
902
-
903
  return '';
904
  }
905
-
906
  /**
907
  * Adds an error message to the specified session based on an exception. The exception should contain a valid error code
908
- * in order to properly process the error. Exceptions without a (valid) error code will behave like a regular
909
  * $session->addError() call.
910
- *
911
  * @param string|Mage_Core_Model_Session_Abstract $session The session to which the messages will be added.
912
  * @param Exception $exception
913
- *
914
  * @return TIG_PostNL_Helper_Data
915
- *
916
  * @see TIG_PostNL_Helper_Data::addSessionMessage()
917
  */
918
  public function addExceptionSessionMessage($session, Exception $exception)
@@ -927,16 +939,16 @@ class TIG_PostNL_Helper_Data extends Mage_Core_Helper_Abstract
927
  if (empty($code)) {
928
  $code = $this->getErrorCodeByMessage($exceptionMessage);
929
  }
930
-
931
  return $this->addSessionMessage($session, $code, $messageType, $message);
932
  }
933
-
934
  /**
935
  * Gets an error code by looping through all known errors and if the specified message can be matched, returning the
936
  * associated code.
937
- *
938
  * @param string $message
939
- *
940
  * @return string|null
941
  */
942
  public function getErrorCodeByMessage($message)
@@ -945,13 +957,13 @@ class TIG_PostNL_Helper_Data extends Mage_Core_Helper_Abstract
945
  * Get an array of all known errors
946
  */
947
  $errors = Mage::getConfig()->getNode('tig/errors')->asArray();
948
-
949
  /**
950
  * Loop through each error and compare it's message
951
  */
952
  foreach ($errors as $code => $error) {
953
  $errorMessage = (string) $error['message'];
954
-
955
  /**
956
  * If a the error's message and the specified message match, return the error code
957
  */
@@ -959,26 +971,26 @@ class TIG_PostNL_Helper_Data extends Mage_Core_Helper_Abstract
959
  return $code;
960
  }
961
  }
962
-
963
  return null;
964
  }
965
-
966
  /**
967
  * Add a message to the specified session. Message can be an error, a success message, an info message or a warning.
968
  * If a valid error code is supplied, the message will be prepended with the error code and a link to a knowledgebase article
969
  * will be appended.
970
- *
971
  * If no $code is specified, $messageType and $message will be required
972
- *
973
  * @param string|Mage_Core_Model_Session_Abstract $session The session to which the messages will be added.
974
  * @param string|null $code
975
  * @param string|null $messageType
976
  * @param string|null $message
977
- *
978
  * @return TIG_PostNL_Helper_Data
979
- *
980
  * @see Mage_Core_Model_Session_Abstract::addMessage()
981
- *
982
  * @throws InvalidArgumentException
983
  * @throws TIG_PostNL_Exception
984
  */
@@ -987,31 +999,31 @@ class TIG_PostNL_Helper_Data extends Mage_Core_Helper_Abstract
987
  /************************************************************************************************************************
988
  * Check that the required arguments are available and valid
989
  ***********************************************************************************************************************/
990
-
991
  /**
992
  * If $code is null or 0, $messageType and $message are required
993
  */
994
  if (
995
- (is_null($code) || $code === 0)
996
  && (is_null($messageType) || is_null($message))
997
  ) {
998
  throw new InvalidArgumentException(
999
  "Warning: Missing argument for addSessionMessage method: 'messageType' and 'message' are required."
1000
  );
1001
  }
1002
-
1003
  /**
1004
  * If the session is a string, treat it as a class name and instantiate it
1005
  */
1006
  if (is_string($session)) {
1007
  $session = Mage::getSingleton($session);
1008
  }
1009
-
1010
  /**
1011
  * If the session could not be loaded or is not of the corect type, throw an exception
1012
  */
1013
- if (!$session
1014
- || !is_object($session)
1015
  || !($session instanceof Mage_Core_Model_Session_Abstract)
1016
  ) {
1017
  throw new TIG_PostNL_Exception(
@@ -1019,15 +1031,15 @@ class TIG_PostNL_Helper_Data extends Mage_Core_Helper_Abstract
1019
  'POSTNL-0088'
1020
  );
1021
  }
1022
-
1023
  /************************************************************************************************************************
1024
  * Get the actual error from config.xml if it's available
1025
  ***********************************************************************************************************************/
1026
-
1027
  $error = false;
1028
  $link = false;
1029
-
1030
- if (!is_null($code) && $code !== 0) {
1031
  /**
1032
  * get the requested code and if possible, the knowledgebase link
1033
  */
@@ -1036,19 +1048,19 @@ class TIG_PostNL_Helper_Data extends Mage_Core_Helper_Abstract
1036
  $link = (string) $error->url;
1037
  }
1038
  }
1039
-
1040
  /************************************************************************************************************************
1041
  * Check that the required 'message' and 'messageType' components are available. If they are not yet available, we'll try
1042
  * to read them from the error itself.
1043
  ***********************************************************************************************************************/
1044
-
1045
  /**
1046
  * If the specified error was found and no message was supplied, get the error's default message
1047
  */
1048
  if ($error && !$message) {
1049
  $message = (string) $error->message;
1050
  }
1051
-
1052
  /**
1053
  * If we still don't have a valid message, throw an exception
1054
  */
@@ -1058,15 +1070,15 @@ class TIG_PostNL_Helper_Data extends Mage_Core_Helper_Abstract
1058
  'POSTNL-0089'
1059
  );
1060
  }
1061
-
1062
  /**
1063
  * If the specified error was found and no message type was supplied, get the error's default type
1064
  */
1065
  if ($error && !$messageType) {
1066
  $messageType = (string) $error->type;
1067
  }
1068
-
1069
-
1070
  /**
1071
  * If we still don't have a valid message type, throw an exception
1072
  */
@@ -1076,54 +1088,54 @@ class TIG_PostNL_Helper_Data extends Mage_Core_Helper_Abstract
1076
  'POSTNL-0090'
1077
  );
1078
  }
1079
-
1080
  /************************************************************************************************************************
1081
  * Build the actual message we're going to add. The message will consist of the error code, followed by the actual
1082
  * message and finally a link to the knowledge base. Only the message part is required.
1083
  ***********************************************************************************************************************/
1084
-
1085
  /**
1086
- * Flag that determines whether the error code and knowledgebase link will be included in the error message
1087
  * (if available)
1088
  */
1089
  $canShowErrorDetails = $this->_canShowErrorDetails();
1090
-
1091
  /**
1092
  * Lets start with the error code if it's present. It will be formatted as "[POSTNL-0001]".
1093
  */
1094
  $errorMessage = '';
1095
- if ($canShowErrorDetails
1096
- && !is_null($code)
1097
  && $code !== 0
1098
  ) {
1099
  $errorMessage .= "[{$code}] ";
1100
  }
1101
-
1102
  /**
1103
  * Add the actual message. This is the only required part. The code and link are optional
1104
  */
1105
  $errorMessage .= $this->__($message);
1106
-
1107
  /**
1108
  * Add the link to the knowledgebase if we have one
1109
  */
1110
  if ($canShowErrorDetails && $link) {
1111
- $errorMessage .= ' <a href="'
1112
- . $link
1113
- . '" target="_blank" class="postnl-message">'
1114
- . $this->__('Click here for more information from the TiG knowledgebase.')
1115
  . '</a>';
1116
  }
1117
-
1118
  /************************************************************************************************************************
1119
  * Finally, let's add the error to the session
1120
  ***********************************************************************************************************************/
1121
-
1122
  /**
1123
  * The method we'll use to add the message to the session has to be built first
1124
  */
1125
  $addMethod = 'add' . ucfirst($messageType);
1126
-
1127
  /**
1128
  * If the method doesn't exist, throw an exception
1129
  */
@@ -1133,18 +1145,18 @@ class TIG_PostNL_Helper_Data extends Mage_Core_Helper_Abstract
1133
  'POSTNL-0094'
1134
  );
1135
  }
1136
-
1137
  /**
1138
  * Add the message to the session
1139
  */
1140
  $session->$addMethod($errorMessage);
1141
-
1142
  return $this;
1143
  }
1144
-
1145
  /**
1146
  * Checks to see if we can show error details (error code and knowledgebase link) in the frontend when an error occurs.
1147
- *
1148
  * @return boolean
1149
  */
1150
  protected function _canShowErrorDetails()
@@ -1155,7 +1167,7 @@ class TIG_PostNL_Helper_Data extends Mage_Core_Helper_Abstract
1155
  if ($this->isAdmin()) {
1156
  return true;
1157
  }
1158
-
1159
  /**
1160
  * Check if the show_error_details_in_frontend setting is set to true
1161
  */
@@ -1163,7 +1175,7 @@ class TIG_PostNL_Helper_Data extends Mage_Core_Helper_Abstract
1163
  if (Mage::getStoreConfigFlag(self::XML_PATH_SHOW_ERROR_DETAILS_IN_FRONTEND, $storeId)) {
1164
  return true;
1165
  }
1166
-
1167
  return false;
1168
  }
1169
  }
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@totalinternetgroup.nl so we can send you a copy immediately.
42
  * Log filename to log all non-specific PostNL exceptions
43
  */
44
  const POSTNL_EXCEPTION_LOG_FILE = 'TIG_PostNL_Exception.log';
45
+
46
  /**
47
  * Log filename to log all non-specific PostNL debug messages
48
  */
49
  const POSTNL_DEBUG_LOG_FILE = 'TIG_PostNL_Debug.log';
50
+
51
  /**
52
  * Directory inside var/log where PostNL log files will be logged
53
  */
54
  const POSTNL_LOG_DIRECTORY = 'TIG_PostNL';
55
+
56
  /**
57
  * Log filename to log all cron log messages
58
  */
59
  const POSTNL_CRON_DEBUG_LOG_FILE = 'TIG_PostNL_Cron_Debug.log';
60
+
61
  /**
62
  * XML path to postnl general active/inactive setting
63
  */
64
  const XML_PATH_EXTENSION_ACTIVE = 'postnl/general/active';
65
+
66
  /**
67
  * XML path to postnl carier active/inactive setting
68
  */
69
  const XML_PATH_CARRIER_ACTIVE = 'carriers/postnl/active';
70
+
71
  /**
72
  * XML path to test/live mode config option
73
  */
74
  const XML_PATH_TEST_MODE = 'postnl/cif_labels_and_confirming/mode';
75
+
76
  /**
77
  * XML path to the test mode allowed config option
78
  */
79
  const XML_PATH_TEST_MODE_ALLOWED = 'postnl/advanced/allow_test_mode';
80
+
81
  /**
82
  * XML path to debug mode config option
83
  */
84
  const XML_PATH_DEBUG_MODE = 'postnl/advanced/debug_mode';
85
+
86
  /**
87
  * XML path to 'is_activated' flag
88
  */
89
  const XML_PATH_IS_ACTIVATED = 'postnl/general/is_activated';
90
+
91
  /**
92
  * XML path to 'show_error_details_in_frontend' flag
93
  */
94
  const XML_PATH_SHOW_ERROR_DETAILS_IN_FRONTEND = 'postnl/advanced/show_error_details_in_frontend';
95
+
96
  /**
97
  * XML path to use_globalpack settings
98
  */
99
  const XML_PATH_USE_GLOBALPACK = 'postnl/cif/use_globalpack';
100
+
101
+ /**
102
+ * XPATH to allow EPS BE only product option setting.
103
+ */
104
+ const XPATH_ALLOW_EPS_BE_ONLY_OPTION = 'postnl/cif_product_options/allow_eps_be_only_options';
105
+
106
  /**
107
  * Required configuration fields
108
+ *
109
  * @var array
110
  */
111
  protected $_requiredFields = array(
120
  'postnl/cif_sender_address/postcode',
121
  'postnl/cif_sender_address/city',
122
  );
123
+
124
  /**
125
  * Required configuration fields for live mode
126
+ *
127
  * @var array
128
  */
129
  protected $_liveModeRequiredFields = array(
130
  'postnl/cif/live_username',
131
  'postnl/cif/live_password',
132
  );
133
+
134
  /**
135
  * Required configuration fields for test mode
136
+ *
137
  * @var array
138
  */
139
  protected $_testModeRequiredFields = array(
140
  'postnl/cif/test_username',
141
  'postnl/cif/test_password',
142
  );
143
+
144
  /**
145
  * Required configuration fields when using global shipments
146
+ *
147
  * @var array
148
  */
149
  protected $_globalShipmentRequiredFields = array(
154
  'postnl/cif_globalpack_settings/country_of_origin_attribute',
155
  'postnl/cif_globalpack_settings/description_attribute',
156
  );
157
+
158
  /**
159
  * Get required fields array
160
+ *
161
  * @return array
162
  */
163
  public function getRequiredFields()
164
  {
165
  return $this->_requiredFields;
166
  }
167
+
168
  /**
169
  * Get required fields for live mode array
170
+ *
171
  * @return array
172
  */
173
  public function getLiveModeRequiredFields()
174
  {
175
  return $this->_liveModeRequiredFields;
176
  }
177
+
178
  /**
179
  * Get required fields for test mode array
180
+ *
181
  * @return array
182
  */
183
  public function getTestModeRequiredFields()
184
  {
185
  return $this->_testModeRequiredFields;
186
  }
187
+
188
  /**
189
  * Get required fields for global shipments array
190
+ *
191
  * @return array
192
  */
193
  public function getGlobalShipmentsRequiredFields()
194
  {
195
  return $this->_globalShipmentRequiredFields;
196
  }
197
+
198
  /**
199
  * Get debug mode config setting
200
+ *
201
  * @return int
202
  */
203
  public function getDebugMode()
205
  if (Mage::registry('postnl_debug_mode') !== null) {
206
  return Mage::registry('postnl_debug_mode');
207
  }
208
+
209
  $debugMode = (int) Mage::getStoreConfig(self::XML_PATH_DEBUG_MODE, Mage_Core_Model_App::ADMIN_STORE_ID);
210
+
211
  Mage::register('postnl_debug_mode', $debugMode);
212
  return $debugMode;
213
  }
214
 
215
  /**
216
  * Checks to see if the module may ship to the Netherlands using PostNL standard shipments
217
+ *
218
  * @param boolean|int $storeId
219
+ *
220
  * @return boolean
221
  */
222
  public function canUseStandard($storeId = false)
224
  if ($storeId === false) {
225
  $storeId = Mage::app()->getStore()->getId();
226
  }
227
+
228
  $standardProductOptions = Mage::getModel('postnl_core/system_config_source_standardProductOptions')
229
  ->getAvailableOptions($storeId);
230
  if (empty($standardProductOptions)) {
231
  return false;
232
  }
233
+
234
  return true;
235
  }
236
 
237
  /**
238
  * Checks to see if the module may ship using PakjeGemak
239
+ *
240
  * @param boolean|int $storeId
241
+ *
242
  * @return boolean
243
  */
244
  public function canUsePakjeGemak($storeId = false)
246
  if ($storeId === false) {
247
  $storeId = Mage::app()->getStore()->getId();
248
  }
249
+
250
  $pakjeGemakProductoptions = Mage::getModel('postnl_core/system_config_source_pakjeGemakProductOptions')
251
  ->getAvailableOptions($storeId);
252
+
253
  if (empty($pakjeGemakProductoptions)) {
254
  return false;
255
  }
256
+
257
  return true;
258
  }
259
 
260
  /**
261
  * Checks to see if the module may ship to EU countries using EPS
262
+ *
263
  * @param boolean|int $storeId
264
+ *
265
  * @return boolean
266
  */
267
  public function canUseEps($storeId = false)
269
  if ($storeId === false) {
270
  $storeId = Mage::app()->getStore()->getId();
271
  }
272
+
273
  $euProductOptions = Mage::getModel('postnl_core/system_config_source_euProductOptions')
274
+ ->getAvailableOptions($storeId);
275
+
276
  if (empty($euProductOptions)) {
277
  return false;
278
  }
279
+
280
  return true;
281
  }
282
 
283
  /**
284
  * Checks to see if the module may ship to countries outside the EU using GlobalPack
285
+ *
286
  * @param boolean|int $storeId
287
+ *
288
  * @return boolean
289
  */
290
  public function canUseGlobalPack($storeId = false)
292
  if ($storeId === false) {
293
  $storeId = Mage::app()->getStore()->getId();
294
  }
295
+
296
  if (!$this->isGlobalAllowed()) {
297
  return false;
298
  }
299
+
300
  $globalProductOptions = Mage::getModel('postnl_core/system_config_source_globalProductOptions')
301
  ->getAvailableOptions($storeId);
302
+
303
  if (empty($globalProductOptions)) {
304
  return false;
305
  }
306
+
307
  return true;
308
  }
309
+
310
+ /**
311
+ * Checks whether the EPS BE only product option is allowed.
312
+ *
313
+ * @param bool|int $storeId
314
+ *
315
+ * @return bool
316
+ */
317
+ public function canUseEpsBEOnlyOption($storeId = false)
318
+ {
319
+ if ($storeId === false) {
320
+ $storeId = Mage::app()->getStore()->getId();
321
+ }
322
+
323
+ $epsBeOnlyOptionAllowed = Mage::getStoreConfigFlag(self::XPATH_ALLOW_EPS_BE_ONLY_OPTION, $storeId);
324
+
325
+ return $epsBeOnlyOptionAllowed;
326
+ }
327
+
328
  /**
329
  * Save state of configuration field sets
330
  *
331
  * @param array $configState
332
+ *
333
  * @return bool
334
+ *
335
  * @see Mage_Adminhtml_System_ConfigController::_saveState()
336
  */
337
  public function saveConfigState($configState = array())
340
  if (!$adminUser) {
341
  return false;
342
  }
343
+
344
  if (!is_array($configState)) {
345
  return false;
346
  }
347
+
348
  $extra = $adminUser->getExtra();
349
  if (!is_array($extra)) {
350
  $extra = array();
351
  }
352
+
353
  if (!isset($extra['configState'])) {
354
  $extra['configState'] = array();
355
  }
356
+
357
  foreach ($configState as $fieldset => $state) {
358
  $extra['configState'][$fieldset] = $state;
359
  }
360
+
361
  $adminUser->setExtra($extra)
362
  ->saveExtra($extra);
363
 
364
  return true;
365
  }
366
+
367
  /**
368
  * Checks if GlobalPack may be used.
369
+ *
370
  * @return boolean
371
  */
372
  public function isGlobalAllowed()
373
  {
374
  $storeId = Mage_Core_Model_App::ADMIN_STORE_ID;
375
+
376
  $useGlobal = Mage::getStoreConfigFlag(self::XML_PATH_USE_GLOBALPACK, $storeId);
377
  return $useGlobal;
378
  }
379
+
380
  /**
381
  * Check if the module is set to test mode
382
+ *
383
+ * @param bool|int $storeId
384
+ *
385
  * @return boolean
386
  */
387
  public function isTestMode($storeId = false)
389
  if (Mage::registry('postnl_test_mode') !== null) {
390
  return Mage::registry('postnl_test_mode');
391
  }
392
+
393
  if ($storeId === false) {
394
  $storeId = Mage::app()->getStore()->getId();
395
  }
396
+
 
 
 
 
 
 
397
  $testMode = Mage::getStoreConfigFlag(self::XML_PATH_TEST_MODE, $storeId);
398
+
399
  Mage::register('postnl_test_mode', $testMode);
400
  return $testMode;
401
  }
402
+
403
  /**
404
  * Checks if test mode is currently allowed
405
+ *
406
+ * @deprecated v1.1.4 Will now always return true.
407
+ *
408
  * @return boolean
409
  */
410
  public function isTestModeAllowed()
411
  {
412
+ return true;
 
 
 
 
 
 
 
 
 
413
  }
414
+
415
  /**
416
  * Alias for isEnabled()
417
+ *
418
  * @param int | bool $storeId
419
  * @param boolean $checkGlobal
420
  * @param null|boolean $forceTestMode
421
+ *
422
  * @return boolean
423
+ *
424
  * @see TIG_PostNL_Helper_Data::isEnabled()
425
  */
426
  public function isActive($storeId = false, $checkGlobal = false, $forceTestMode = null)
427
  {
428
  return $this->isEnabled($storeId, $checkGlobal, $forceTestMode);
429
  }
430
+
431
  /**
432
  * Determines if the extension is active
433
+ *
434
  * @param int | bool $storeId
435
  * @param boolean $checkGlobal
436
  * @param null|boolean $forceTestMode
437
+ *
438
  * @return boolean
439
  */
440
  public function isEnabled($storeId = false, $checkGlobal = false, $forceTestMode = null)
444
  } else {
445
  $testMode = $forceTestMode;
446
  }
447
+
448
  $registryKey = 'postnl_enabled';
449
  if ($checkGlobal) {
450
  $registryKey .= '_global';
452
  if ($testMode) {
453
  $registryKey .= '_test';
454
  }
455
+
456
  if (Mage::registry($registryKey) !== null) {
457
  return Mage::registry($registryKey);
458
  }
459
+
460
  if ($storeId === false) {
461
  $storeId = Mage_Core_Model_App::ADMIN_STORE_ID;
462
  }
463
+
464
  /**
465
  * Check if the module has been enabled
466
  */
467
  $enabled = Mage::getStoreConfigFlag(self::XML_PATH_EXTENSION_ACTIVE, $storeId);
468
  if ($enabled === false) {
469
  Mage::register($registryKey, false);
470
+
471
  $errors = array(
472
  array(
473
  'code' => 'POSTNL-0030',
474
  'message' => $this->__('You have not yet enabled the extension.'),
475
  )
476
  );
477
+
478
  Mage::register($registryKey . '_errors', $errors);
479
  return false;
480
  }
481
+
482
  /**
483
  * Check if the module's required configuration options have been filled
484
  */
487
  Mage::register($registryKey, false);
488
  return false;
489
  }
490
+
491
  /**
492
  * Check if the PostNL shipping method is active
493
  */
494
  $postnlShippingMethodEnabled = Mage::getStoreConfigFlag(self::XML_PATH_CARRIER_ACTIVE, $storeId);
495
  if ($postnlShippingMethodEnabled === false) {
496
  Mage::register($registryKey, false);
497
+
498
  $shippingMethodSectionurl = Mage::helper("adminhtml")->getUrl(
499
  'adminhtml/system_config/edit',
500
  array(
502
  'section' => 'carriers',
503
  )
504
  );
505
+
506
  $errorMessage = $this->__(
507
  'The PostNL shipping method has not been enabled. You can enable the PostNL shipping method under %sSystem > Config > Shipping Methods%s.',
508
  '<a href="' . $shippingMethodSectionurl . '" target="_blank" title="' . $this->__('Shipping Methods') . '">',
509
  '</a>'
510
  );
511
+
512
  $errors = array(
513
  array(
514
  'code' => 'POSTNL-0031',
518
  Mage::register($registryKey . '_errors', $errors);
519
  return false;
520
  }
521
+
522
  /**
523
  * The PostNL module only works with EUR as the shop's base currency
524
  */
525
  $baseCurrencyCode = Mage::getModel('core/store')->load($storeId)->getBaseCurrencyCode();
526
  if ($baseCurrencyCode != 'EUR') {
527
  Mage::register($registryKey, false);
528
+
529
  $errors = array(
530
  array(
531
  'code' => 'POSTNL-0032',
535
  Mage::register($registryKey . '_errors', $errors);
536
  return false;
537
  }
538
+
539
  Mage::register($registryKey, true);
540
  return true;
541
  }
542
+
543
  /**
544
  * Check if the modules has been confgured.
545
  * The required fields will only be checked to see if they're not empty. The values entered will not be validated
546
+ *
547
  * @param int | boolean $storeId
548
  * @param boolean $checkGlobal
549
  * @param null|boolean $forceTestMode
550
+ *
551
  * @return boolean
552
+ *
553
  * @todo properly implement global check
554
  */
555
  public function isConfigured($storeId = false, $checkGlobal = false, $forceTestMode = null)
559
  } else {
560
  $testMode = $forceTestMode;
561
  }
562
+
563
  $registryKey = 'postnl_is_configured';
564
  if ($checkGlobal) {
565
  $registryKey .= '_global';
567
  if ($testMode) {
568
  $registryKey .= '_test';
569
  }
570
+
571
  if (Mage::registry($registryKey) !== null) {
572
  return Mage::registry($registryKey);
573
  }
574
+
575
  $errors = array();
576
+
577
  /**
578
  * Check if the module has been activated
579
  */
584
  'message' => $this->__('The extension has not been activated.'),
585
  );
586
  }
587
+
588
  if ($storeId === false) {
589
  $storeId = Mage::app()->getStore()->getId();
590
  }
591
+
592
  /**
593
  * Get the bse required fields. These are always required.
594
  */
595
  $baseFields = $this->getRequiredFields();
596
+
597
  /**
598
  * Get either the live mode or test mode required fields
599
  */
603
  $modeFields = $this->getLiveModeRequiredFields();
604
  }
605
  $requiredFields = array_merge($modeFields, $baseFields);
606
+
607
  /**
608
  * If this check pertains to a global shipment, get the global shipments required fields as well
609
  */
611
  $globalFields = $this->getGlobalShipmentsRequiredFields();
612
  $requiredFields = array_merge($requiredFields, $globalFields);
613
  }
614
+
615
  /**
616
  * Check if each required field is filled. If not add the field's label to an array of missing fields so we can later
617
  * inform the merchant which fields exactly are missing.
621
  $section = $sections->postnl;
622
  foreach ($requiredFields as $requiredField) {
623
  $value = Mage::getStoreConfig($requiredField, $storeId);
624
+
625
  if ($value === null || $value === '') {
626
  $fieldParts = explode('/', $requiredField);
627
  $field = $fieldParts[2];
628
  $group = $fieldParts[1];
629
+
630
  $label = (string) $section->groups->$group->fields->$field->label;
631
  $groupLabel = (string) $section->groups->$group->label;
632
  $groupName = $section->groups->$group->getName();
633
+
634
  $errors[] = array(
635
  'code' => 'POSTNL-0034',
636
  'message' => $this->__('%s > %s is required.', $this->__($groupLabel), $this->__($label)),
637
  );
638
+
639
  $this->saveConfigState(array('postnl_' . $groupName => 1));
640
  }
641
  }
642
+
643
  /**
644
  * If any errors were detected, add them to the registry and return false
645
  */
648
  Mage::register($registryKey . '_errors', $errors);
649
  return false;
650
  }
651
+
652
  Mage::register($registryKey, true);
653
  return true;
654
  }
655
+
656
  /**
657
  * Check if debug logging is enabled
658
+ *
659
  * @return boolean
660
  */
661
  public function isLoggingEnabled()
664
  if ($debugMode > 1) {
665
  return true;
666
  }
667
+
668
  return false;
669
  }
670
+
671
  /**
672
  * Check if exception logging is enabled
673
+ *
674
  * @return boolean
675
  */
676
  public function isExceptionLoggingEnabled()
679
  if ($debugMode > 0) {
680
  return true;
681
  }
682
+
683
  return false;
684
  }
685
+
686
  /**
687
  * Returns path to specified directory for specified module.
688
+ *
689
  * Based on Mage_Core_Model_Config::getModuleDir()
690
+ *
691
  * @param string $dir The directory in question
692
  * @param string $module The module for which the directory is needed
693
+ *
694
  * @return string
695
+ *
696
  * @see Mage_Core_Model_Config::getModuleDir()
697
  */
698
  public function getModuleDir($dir, $moduleName = 'TIG_PostNL')
699
  {
700
  $config = Mage::app()->getConfig();
701
+
702
  $codePool = (string)$config->getModuleConfig($moduleName)->codePool;
703
  $path = $config->getOptions()->getCodeDir()
704
  . DS
709
  $path .= DS . $dir;
710
 
711
  $path = str_replace('/', DS, $path);
712
+
713
  return $path;
714
  }
715
+
716
  /**
717
  * formats input XML string to improve readability
718
+ *
719
  * @param string $xml
720
+ *
721
  * @return string
722
  */
723
  public function formatXML($xml)
725
  if (empty($xml)) {
726
  return '';
727
  }
728
+
729
  $dom = new DOMDocument();
730
  $dom->loadXML($xml);
731
  $dom->preserveWhiteSpace = false;
733
 
734
  return $dom->saveXML();
735
  }
736
+
737
  /**
738
  * Logs a debug message. Based on Mage::log
739
+ *
740
  * @param string $message
741
  * @param int | null $level
742
  * @param string | null $file
743
  * @param boolean $forced
744
  * @param boolean $isError
745
+ *
746
  * @return TIG_PostNL_Helper_Data
747
+ *
748
  * @see Mage::log
749
  */
750
  public function log($message, $level = null, $file = null, $forced = false, $isError = false)
754
  } elseif ($isError !== true && !$this->isLoggingEnabled()) {
755
  return $this;
756
  }
757
+
758
  if (is_null($level)) {
759
  $level = Zend_Log::DEBUG;
760
  }
761
+
762
  if (is_null($file)) {
763
  $file = static::POSTNL_LOG_DIRECTORY . DS . static::POSTNL_DEBUG_LOG_FILE;
764
  }
765
+
766
  $this->createLogDir();
767
+
768
  Mage::log($message, $level, $file, $forced);
769
+
770
  return $this;
771
  }
772
+
773
  /**
774
  * Logs a cron debug messageto a seperate file in order to differentiate it from other debug messages
775
+ *
776
  * @param string $message
777
  * @param int | int $level
778
+ *
779
  * @return TIG_PostNL_Helper_Data
780
+ *
781
  * @see Mage::log
782
  */
783
  public function cronLog($message, $level = null)
784
  {
785
  $file = self::POSTNL_LOG_DIRECTORY . DS . self::POSTNL_CRON_DEBUG_LOG_FILE;
786
+
787
  return $this->log($message, $level, $file);
788
  }
789
+
790
  /**
791
  * Logs a PostNL Exception. Based on Mage::logException
792
+ *
793
  * N.B. this uses forced logging
794
+ *
795
  * @param string|Exception $exception
796
+ *
797
  * @return TIG_PostNL_Helper_Data
798
+ *
799
  * @see Mage::logException
800
  */
801
  public function logException($exception)
803
  if (!$this->isExceptionLoggingEnabled()) {
804
  return $this;
805
  }
806
+
807
  if (is_object($exception)) {
808
  $message = "\n" . $exception->__toString();
809
  } else {
810
  $message = $exception;
811
  }
812
+
813
  $file = self::POSTNL_LOG_DIRECTORY . DS . self::POSTNL_EXCEPTION_LOG_FILE;
814
+
815
  $this->log($message, Zend_Log::ERR, $file, false, true);
816
+
817
  return $this;
818
  }
819
+
820
  /**
821
  * Checks if the current edition of Magento is enterprise. Uses Mage::getEdition if available or version_compare if it is not
822
+ *
823
  * @return boolean
824
+ *
825
  * @throws TIG_PostNL_Exception
826
  */
827
  public function isEnterprise()
834
  if ($edition == Mage::EDITION_ENTERPRISE) {
835
  return true;
836
  }
837
+
838
  if ($edition == Mage::EDITION_COMMUNITY) {
839
  return false;
840
  }
841
+
842
  /**
843
  * If the edition is not community or enterprise, it is not supported
844
  */
847
  'POSTNL-0035'
848
  );
849
  }
850
+
851
  /**
852
  * Do a version check instead
853
  */
855
  if (version_compare($version, '1.9.0.0', '>=')) { //1.9.0.0 was the first Magento Enterprise version
856
  return true;
857
  }
858
+
859
  return false;
860
  }
861
+
862
  /**
863
  * Checks if the current environment is in the shop's admin area.
864
+ *
865
  * @return boolean
866
  */
867
  public function isAdmin()
879
 
880
  return false;
881
  }
882
+
883
  /**
884
  * Creates a seperate dir to log PostNL log files. Does nothing if the dir already exists
885
+ *
886
  * @return TIG_PostNL_Exception
887
  */
888
  public function createLogDir()
889
  {
890
  $logDir = Mage::getBaseDir('var') . DS . 'log' . DS . self::POSTNL_LOG_DIRECTORY;
891
+
892
  if (!is_dir($logDir)) {
893
  mkdir($logDir, 0777, true);
894
  chmod($logDir, 0777);
895
  }
896
+
897
  return $this;
898
  }
899
+
900
  /**
901
  * Gets the knowledge base URL for a specified error code. First we check to see if we have an entry in config.xml for this
902
  * error code and if so, if it has an associated URL.
903
+ *
904
  * @param string $errorCode The error code (for example: POSTNL-0001)
905
+ *
906
  * @return string The URL or an empty string if no URL could be found
907
  */
908
  public function getErrorUrl($errorCode)
911
  if ($error !== false && $error->url) {
912
  return (string) $error->url;
913
  }
914
+
915
  return '';
916
  }
917
+
918
  /**
919
  * Adds an error message to the specified session based on an exception. The exception should contain a valid error code
920
+ * in order to properly process the error. Exceptions without a (valid) error code will behave like a regular
921
  * $session->addError() call.
922
+ *
923
  * @param string|Mage_Core_Model_Session_Abstract $session The session to which the messages will be added.
924
  * @param Exception $exception
925
+ *
926
  * @return TIG_PostNL_Helper_Data
927
+ *
928
  * @see TIG_PostNL_Helper_Data::addSessionMessage()
929
  */
930
  public function addExceptionSessionMessage($session, Exception $exception)
939
  if (empty($code)) {
940
  $code = $this->getErrorCodeByMessage($exceptionMessage);
941
  }
942
+
943
  return $this->addSessionMessage($session, $code, $messageType, $message);
944
  }
945
+
946
  /**
947
  * Gets an error code by looping through all known errors and if the specified message can be matched, returning the
948
  * associated code.
949
+ *
950
  * @param string $message
951
+ *
952
  * @return string|null
953
  */
954
  public function getErrorCodeByMessage($message)
957
  * Get an array of all known errors
958
  */
959
  $errors = Mage::getConfig()->getNode('tig/errors')->asArray();
960
+
961
  /**
962
  * Loop through each error and compare it's message
963
  */
964
  foreach ($errors as $code => $error) {
965
  $errorMessage = (string) $error['message'];
966
+
967
  /**
968
  * If a the error's message and the specified message match, return the error code
969
  */
971
  return $code;
972
  }
973
  }
974
+
975
  return null;
976
  }
977
+
978
  /**
979
  * Add a message to the specified session. Message can be an error, a success message, an info message or a warning.
980
  * If a valid error code is supplied, the message will be prepended with the error code and a link to a knowledgebase article
981
  * will be appended.
982
+ *
983
  * If no $code is specified, $messageType and $message will be required
984
+ *
985
  * @param string|Mage_Core_Model_Session_Abstract $session The session to which the messages will be added.
986
  * @param string|null $code
987
  * @param string|null $messageType
988
  * @param string|null $message
989
+ *
990
  * @return TIG_PostNL_Helper_Data
991
+ *
992
  * @see Mage_Core_Model_Session_Abstract::addMessage()
993
+ *
994
  * @throws InvalidArgumentException
995
  * @throws TIG_PostNL_Exception
996
  */
999
  /************************************************************************************************************************
1000
  * Check that the required arguments are available and valid
1001
  ***********************************************************************************************************************/
1002
+
1003
  /**
1004
  * If $code is null or 0, $messageType and $message are required
1005
  */
1006
  if (
1007
+ (is_null($code) || $code === 0)
1008
  && (is_null($messageType) || is_null($message))
1009
  ) {
1010
  throw new InvalidArgumentException(
1011
  "Warning: Missing argument for addSessionMessage method: 'messageType' and 'message' are required."
1012
  );
1013
  }
1014
+
1015
  /**
1016
  * If the session is a string, treat it as a class name and instantiate it
1017
  */
1018
  if (is_string($session)) {
1019
  $session = Mage::getSingleton($session);
1020
  }
1021
+
1022
  /**
1023
  * If the session could not be loaded or is not of the corect type, throw an exception
1024
  */
1025
+ if (!$session
1026
+ || !is_object($session)
1027
  || !($session instanceof Mage_Core_Model_Session_Abstract)
1028
  ) {
1029
  throw new TIG_PostNL_Exception(
1031
  'POSTNL-0088'
1032
  );
1033
  }
1034
+
1035
  /************************************************************************************************************************
1036
  * Get the actual error from config.xml if it's available
1037
  ***********************************************************************************************************************/
1038
+
1039
  $error = false;
1040
  $link = false;
1041
+
1042
+ if (!is_null($code) && $code !== 0) {
1043
  /**
1044
  * get the requested code and if possible, the knowledgebase link
1045
  */
1048
  $link = (string) $error->url;
1049
  }
1050
  }
1051
+
1052
  /************************************************************************************************************************
1053
  * Check that the required 'message' and 'messageType' components are available. If they are not yet available, we'll try
1054
  * to read them from the error itself.
1055
  ***********************************************************************************************************************/
1056
+
1057
  /**
1058
  * If the specified error was found and no message was supplied, get the error's default message
1059
  */
1060
  if ($error && !$message) {
1061
  $message = (string) $error->message;
1062
  }
1063
+
1064
  /**
1065
  * If we still don't have a valid message, throw an exception
1066
  */
1070
  'POSTNL-0089'
1071
  );
1072
  }
1073
+
1074
  /**
1075
  * If the specified error was found and no message type was supplied, get the error's default type
1076
  */
1077
  if ($error && !$messageType) {
1078
  $messageType = (string) $error->type;
1079
  }
1080
+
1081
+
1082
  /**
1083
  * If we still don't have a valid message type, throw an exception
1084
  */
1088
  'POSTNL-0090'
1089
  );
1090
  }
1091
+
1092
  /************************************************************************************************************************
1093
  * Build the actual message we're going to add. The message will consist of the error code, followed by the actual
1094
  * message and finally a link to the knowledge base. Only the message part is required.
1095
  ***********************************************************************************************************************/
1096
+
1097
  /**
1098
+ * Flag that determines whether the error code and knowledgebase link will be included in the error message
1099
  * (if available)
1100
  */
1101
  $canShowErrorDetails = $this->_canShowErrorDetails();
1102
+
1103
  /**
1104
  * Lets start with the error code if it's present. It will be formatted as "[POSTNL-0001]".
1105
  */
1106
  $errorMessage = '';
1107
+ if ($canShowErrorDetails
1108
+ && !is_null($code)
1109
  && $code !== 0
1110
  ) {
1111
  $errorMessage .= "[{$code}] ";
1112
  }
1113
+
1114
  /**
1115
  * Add the actual message. This is the only required part. The code and link are optional
1116
  */
1117
  $errorMessage .= $this->__($message);
1118
+
1119
  /**
1120
  * Add the link to the knowledgebase if we have one
1121
  */
1122
  if ($canShowErrorDetails && $link) {
1123
+ $errorMessage .= ' <a href="'
1124
+ . $link
1125
+ . '" target="_blank" class="postnl-message">'
1126
+ . $this->__('Click here for more information from the TiG knowledgebase.')
1127
  . '</a>';
1128
  }
1129
+
1130
  /************************************************************************************************************************
1131
  * Finally, let's add the error to the session
1132
  ***********************************************************************************************************************/
1133
+
1134
  /**
1135
  * The method we'll use to add the message to the session has to be built first
1136
  */
1137
  $addMethod = 'add' . ucfirst($messageType);
1138
+
1139
  /**
1140
  * If the method doesn't exist, throw an exception
1141
  */
1145
  'POSTNL-0094'
1146
  );
1147
  }
1148
+
1149
  /**
1150
  * Add the message to the session
1151
  */
1152
  $session->$addMethod($errorMessage);
1153
+
1154
  return $this;
1155
  }
1156
+
1157
  /**
1158
  * Checks to see if we can show error details (error code and knowledgebase link) in the frontend when an error occurs.
1159
+ *
1160
  * @return boolean
1161
  */
1162
  protected function _canShowErrorDetails()
1167
  if ($this->isAdmin()) {
1168
  return true;
1169
  }
1170
+
1171
  /**
1172
  * Check if the show_error_details_in_frontend setting is set to true
1173
  */
1175
  if (Mage::getStoreConfigFlag(self::XML_PATH_SHOW_ERROR_DETAILS_IN_FRONTEND, $storeId)) {
1176
  return true;
1177
  }
1178
+
1179
  return false;
1180
  }
1181
  }
app/code/community/TIG/PostNL/Model/Adminhtml/Observer/OrderGrid.php CHANGED
@@ -1,28 +1,28 @@
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@totalinternetgroup.nl so we can send you a copy immediately.
@@ -35,10 +35,13 @@
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
  * Observer to edit the sales > order grid
 
 
 
 
 
42
  */
43
  class TIG_PostNL_Model_Adminhtml_Observer_OrderGrid extends Varien_Object
44
  {
@@ -46,41 +49,41 @@ class TIG_PostNL_Model_Adminhtml_Observer_OrderGrid extends Varien_Object
46
  * The block we want to edit
47
  */
48
  const ORDER_GRID_BLOCK_NAME = 'adminhtml/sales_order_grid';
49
-
50
  /**
51
  * variable name for order grid filter
52
  */
53
  const ORDER_GRID_FILTER_VAR_NAME = 'sales_order_gridfilter';
54
-
55
  /**
56
  * variable name for order grid sorting
57
  */
58
  const ORDER_GRID_SORT_VAR_NAME = 'sales_order_gridsort';
59
-
60
  /**
61
  * variable name for order grid sorting direction
62
  */
63
  const ORDER_GRID_DIR_VAR_NAME = 'sales_order_griddir';
64
-
65
  /**
66
  * XML path to show_grid_options setting
67
  */
68
  const XML_PATH_SHOW_OPTIONS = 'postnl/cif_labels_and_confirming/show_grid_options';
69
-
70
  /**
71
  * XML path to show shipment type column setting
72
  */
73
  const XML_PATH_SHOW_SHIPMENT_TYPE_COLUMN = 'postnl/cif_labels_and_confirming/show_shipment_type_column';
74
-
75
  /**
76
  * Edits the sales order grid by adding a mass action to create shipments for selected orders
77
- *
78
  * @param Varien_Event_Observer $observer
79
- *
80
- * @return TIG_PostNL_Model_Adminhtml_OrderGridObserver
81
- *
82
  * @event adminhtml_block_html_before
83
- *
84
  * @observer postnl_adminhtml_ordergrid
85
  */
86
  public function modifyGrid(Varien_Event_Observer $observer)
@@ -91,59 +94,63 @@ class TIG_PostNL_Model_Adminhtml_Observer_OrderGrid extends Varien_Object
91
  if (!Mage::helper('postnl')->isEnabled()) {
92
  return $this;
93
  }
94
-
95
  /**
96
  * Checks if the current block is the one we want to edit.
97
- *
98
- * Unfortunately there is no unique event for this block
99
  */
100
  $block = $observer->getBlock();
101
  $orderGridClass = Mage::getConfig()->getBlockClassName(self::ORDER_GRID_BLOCK_NAME);
102
-
103
- if (get_class($block) !== $orderGridClass) {
104
  return $this;
105
  }
106
-
 
 
 
 
107
  $currentCollection = $block->getCollection();
108
-
109
- $select = $currentCollection->getSelect();
110
-
111
  /**
112
  * replace the collection, as the default collection has a bug preventing it from being reset.
113
  * Without being able to reset it, we can't edit it. Therefore we are forced to replace it altogether
114
- *
115
  * TODO see if this can be avoided in any way
116
  */
117
  $collection = Mage::getResourceModel('postnl/order_grid_collection');
118
  $collection->setSelect($select)
119
  ->setPageSize($currentCollection->getPageSize())
120
  ->setCurPage($currentCollection->getCurPage());
121
-
122
  $this->setCollection($collection);
123
  $this->setBlock($block);
124
-
125
  $this->_joinCollection($collection);
 
126
  $this->_addColumns($block);
127
  $this->_applySortAndFilter($collection);
128
  $this->_addMassaction($block);
129
-
130
  $block->setCollection($this->getCollection());
131
  return $this;
132
  }
133
-
134
  /**
135
  * Adds additional joins to the collection that will be used by newly added columns
136
- *
137
- * @param TIG_PostNL_Model_Resource_Order_Shipment_Grid_Collection $collection
138
- *
139
- * @return TIG_PostNL_Model_Adminhtml_Observer_OrderGrid
140
  */
141
  protected function _joinCollection($collection)
142
  {
143
  $resource = Mage::getSingleton('core/resource');
144
-
145
  $select = $collection->getSelect();
146
-
147
  /**
148
  * Join sales_flat_order table
149
  */
@@ -154,7 +161,7 @@ class TIG_PostNL_Model_Adminhtml_Observer_OrderGrid extends Varien_Object
154
  'shipping_method' => 'order.shipping_method',
155
  )
156
  );
157
-
158
  /**
159
  * Join sales_flat_order_address table
160
  */
@@ -165,7 +172,7 @@ class TIG_PostNL_Model_Adminhtml_Observer_OrderGrid extends Varien_Object
165
  'country_id' => 'shipping_address.country_id',
166
  )
167
  );
168
-
169
  /**
170
  * Join tig_postnl_order table
171
  */
@@ -176,21 +183,81 @@ class TIG_PostNL_Model_Adminhtml_Observer_OrderGrid extends Varien_Object
176
  'is_pakje_gemak' => 'postnl_order.is_pakje_gemak',
177
  )
178
  );
179
-
180
  return $this;
181
  }
182
-
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
183
  /**
184
  * Adds additional columns to the grid
185
- *
186
  * @param Mage_Adminhtml_Block_Sales_Order_Grid $block
187
- *
188
- * @return TIG_PostNL_Model_Adminhtml_Observer_OrderGrid
189
  */
190
  protected function _addColumns($block)
191
  {
192
  $helper = Mage::helper('postnl');
193
-
194
  $columnAttributes = array(
195
  'header' => $helper->__('Shipment type'),
196
  'align' => 'left',
@@ -207,12 +274,12 @@ class TIG_PostNL_Model_Adminhtml_Observer_OrderGrid extends Varien_Object
207
  'global' => $helper->__('GlobalPack'),
208
  ),
209
  );
210
-
211
  $showShipmentTypeColumn = Mage::getStoreConfigFlag(
212
- self::XML_PATH_SHOW_SHIPMENT_TYPE_COLUMN,
213
  Mage_Core_Model_App::ADMIN_STORE_ID
214
  );
215
-
216
  /**
217
  * If we don't need to display the shipment type column, hide it. We'll still need it for some javascript functionality
218
  */
@@ -221,24 +288,24 @@ class TIG_PostNL_Model_Adminhtml_Observer_OrderGrid extends Varien_Object
221
  $columnAttributes['header_css_class'] = 'no-display';
222
  $columnAttributes['display'] = 'none';
223
  }
224
-
225
  $block->addColumnAfter(
226
  'country_id',
227
  $columnAttributes,
228
  'shipping_name'
229
  );
230
-
231
  $block->sortColumnsByOrder();
232
-
233
  return $this;
234
  }
235
 
236
  /**
237
  * Adds a massaction to confirm the order and print the shipping labels
238
- *
239
  * @param Mage_Adminhtml_Block_Sales_Order_Grid $block
240
- *
241
- * @return TIG_PostNL_Model_Adminhtml_Observer_OrderGrid
242
  */
243
  protected function _addMassaction($block)
244
  {
@@ -249,9 +316,9 @@ class TIG_PostNL_Model_Adminhtml_Observer_OrderGrid extends Varien_Object
249
  'label'=> Mage::helper('postnl')->__('PostNL - Create Shipments'),
250
  'url' => Mage::helper('adminhtml')->getUrl('postnl/adminhtml_shipment/massCreateShipments'),
251
  );
252
-
253
  $showOptions = Mage::getStoreConfig(self::XML_PATH_SHOW_OPTIONS, Mage_Core_Model_App::ADMIN_STORE_ID);
254
-
255
  if ($showOptions) {
256
  /**
257
  * Add another dropdown containing the possible product options
@@ -267,166 +334,166 @@ class TIG_PostNL_Model_Adminhtml_Observer_OrderGrid extends Varien_Object
267
  ),
268
  );
269
  }
270
-
271
  /**
272
  * Add the massaction
273
  */
274
  $block->getMassactionBlock()
275
  ->addItem(
276
- 'create_shipments',
277
  $massActionData
278
  );
279
-
280
  return $this;
281
  }
282
-
283
  /**
284
  * Applies sorting and filtering to the collection
285
- *
286
  * @param TIG_PostNL_Model_Resource_Order_Shipment_Grid_Collection $collection
287
- *
288
- * @return TIG_PostNL_Model_Adminhtml_Observer_OrderGrid
289
  */
290
  protected function _applySortAndFilter($collection)
291
  {
292
  $session = Mage::getSingleton('adminhtml/session');
293
-
294
  $filter = $session->getData(self::ORDER_GRID_FILTER_VAR_NAME);
295
  $filter = Mage::helper('adminhtml')->prepareFilterString($filter);
296
-
297
  if ($filter) {
298
  $this->_filterCollection($collection, $filter);
299
  }
300
-
301
  $sort = $session->getData(self::ORDER_GRID_SORT_VAR_NAME);
302
-
303
  if ($sort) {
304
  $dir = $session->getData(self::ORDER_GRID_DIR_VAR_NAME);
305
-
306
  $this->_sortCollection($collection, $sort, $dir);
307
  }
308
-
309
  return $this;
310
  }
311
-
312
  /**
313
  * Adds new filters to the collection if these filters are based on columns added by this observer
314
- *
315
  * @param TIG_PostNL_Model_Resource_Order_Shipment_Grid_Collection $collection
316
  * @param array $filter Array of filters to be added
317
- *
318
- * @return TIG_PostNL_Model_Adminhtml_Observer_OrderGrid
319
  */
320
  protected function _filterCollection($collection, $filter)
321
  {
322
  $block = $this->getBlock();
323
-
324
  foreach ($filter as $columnName => $value) {
325
  $column = $block->getColumn($columnName);
326
-
327
  $column->getFilter()->setValue($value);
328
  $this->_addColumnFilterToCollection($column);
329
  }
330
-
331
  return $this;
332
  }
333
-
334
  /**
335
  * Filters the collection by the 'shipment_type' column. Th column has 3 options: domestic, EPS and GlobalPack.
336
- *
337
  * @param TIG_PostNL_Model_Resource_Order_Shipment_Grid_Collection $collection
338
  * @param Mage_Adminhtml_Block_Widget_Grid_Column $column
339
- *
340
- * @return TIG_PostNL_Model_Adminhtml_Observer_OrderGrid
341
  */
342
  protected function _filterShipmentType($collection, $column)
343
  {
344
  $cond = $column->getFilter()->getCondition();
345
  $filterCond = $cond['eq'];
346
-
347
  /**
348
  * First filter out all non-postnl orders
349
  */
350
  $postnlShippingMethods = Mage::helper('postnl/carrier')->getPostnlShippingMethods();
351
  $collection->addFieldToFilter('order.shipping_method', array('in' => $postnlShippingMethods));
352
-
353
  /**
354
  * If the filter condition is PakjeGemak, filter out all non-PakjeGemak orders
355
  */
356
  if ($filterCond == 'pakje_gemak') {
357
  $collection->addFieldToFilter('is_pakje_gemak', array('eq' => 1));
358
-
359
  return $this;
360
  }
361
-
362
  /**
363
  * If the filter condition is NL, filter out all orders not being shipped to the Netherlands
364
  */
365
  if ($filterCond == 'nl') {
366
  $collection->addFieldToFilter('country_id', $cond);
367
-
368
  return $this;
369
  }
370
-
371
  /**
372
- * If the filter condition is EU, filter out all orders not being shipped to the EU and those being shipped to
373
  * the Netherlands
374
  */
375
  $euCountries = Mage::helper('postnl/cif')->getEuCountries();
376
  if ($filterCond == 'eu') {
377
  $collection->addFieldToFilter('country_id', array('neq' => 'NL'));
378
  $collection->addFieldToFilter('country_id', array('in', $euCountries));
379
-
380
  return $this;
381
  }
382
-
383
  /**
384
  * Lastly, filter out all orders who are being shipped to the Netherlands or other EU countries
385
  */
386
  $collection->addFieldToFilter('country_id', array('neq' => 'NL'));
387
  $collection->addFieldToFilter('country_id', array('nin' => $euCountries));
388
-
389
  return $this;
390
  }
391
-
392
  /**
393
  * Based on Mage_Adminhtml_Block_Widget_Grid::_addColumnFilterToCollection()
394
- *
395
  * Adds a filter condition to the collection for a specified column
396
- *
397
  * @param Mage_Adminhtml_Block_Widget_Grid_Column $column
398
- *
399
- * @return TIG_PostNL_Model_Adminhtml_Observer_OrderGrid
400
  */
401
  protected function _addColumnFilterToCollection($column)
402
  {
403
  if (!$this->getCollection()) {
404
  return $this;
405
  }
406
-
407
  $field = ($column->getFilterIndex()) ? $column->getFilterIndex() : $column->getIndex();
408
  if ($column->getFilterConditionCallback()) {
409
  call_user_func($column->getFilterConditionCallback(), $this->getCollection(), $column);
410
-
411
  return $this;
412
  }
413
-
414
  $cond = $column->getFilter()->getCondition();
415
  if ($field && isset($cond)) {
416
  $this->getCollection()->addFieldToFilter($field , $cond);
417
  }
418
-
419
  return $this;
420
  }
421
-
422
  /**
423
  * Sorts the collection by a specified column in a specified direction
424
- *
425
  * @param TIG_PostNL_Model_Resource_Order_Shipment_Grid_Collection $collection
426
  * @param string $sort The column that the collection is sorted by
427
  * @param string $dir The direction that is used to sort the collection
428
- *
429
- * @return TIG_PostNL_Model_Adminhtml_Observer_OrderGrid
430
  */
431
  protected function _sortCollection($collection, $sort, $dir)
432
  {
@@ -435,19 +502,19 @@ class TIG_PostNL_Model_Adminhtml_Observer_OrderGrid extends Varien_Object
435
  if (!$column) {
436
  return $this;
437
  }
438
-
439
  $column->setDir($dir);
440
  $this->_setCollectionOrder($column);
441
-
442
  return $this;
443
  }
444
-
445
  /**
446
  * Sets sorting order by some column
447
  *
448
  * @param Mage_Adminhtml_Block_Widget_Grid_Column $column
449
- *
450
- * @return TIG_PostNL_Model_Adminhtml_Observer_OrderGrid
451
  */
452
  protected function _setCollectionOrder($column)
453
  {
@@ -455,7 +522,7 @@ class TIG_PostNL_Model_Adminhtml_Observer_OrderGrid extends Varien_Object
455
  if (!$collection) {
456
  return $this;
457
  }
458
-
459
  $columnIndex = $column->getFilterIndex() ? $column->getFilterIndex() : $column->getIndex();
460
  $collection->setOrder($columnIndex, strtoupper($column->getDir()));
461
  return $this;
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@totalinternetgroup.nl so we can send you a copy immediately.
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
  * Observer to edit the sales > order grid
40
+ *
41
+ * @method TIG_PostNL_Model_Adminhtml_Observer_OrderGrid setCollection(Varien_Data_Collection $value)
42
+ * @method Varien_Data_Collection getCollection()
43
+ * @method TIG_PostNL_Model_Adminhtml_Observer_OrderGrid setBlock(Mage_Core_Block_Abstract $value)
44
+ * @method Mage_Core_Block_Abstract getBlock()
45
  */
46
  class TIG_PostNL_Model_Adminhtml_Observer_OrderGrid extends Varien_Object
47
  {
49
  * The block we want to edit
50
  */
51
  const ORDER_GRID_BLOCK_NAME = 'adminhtml/sales_order_grid';
52
+
53
  /**
54
  * variable name for order grid filter
55
  */
56
  const ORDER_GRID_FILTER_VAR_NAME = 'sales_order_gridfilter';
57
+
58
  /**
59
  * variable name for order grid sorting
60
  */
61
  const ORDER_GRID_SORT_VAR_NAME = 'sales_order_gridsort';
62
+
63
  /**
64
  * variable name for order grid sorting direction
65
  */
66
  const ORDER_GRID_DIR_VAR_NAME = 'sales_order_griddir';
67
+
68
  /**
69
  * XML path to show_grid_options setting
70
  */
71
  const XML_PATH_SHOW_OPTIONS = 'postnl/cif_labels_and_confirming/show_grid_options';
72
+
73
  /**
74
  * XML path to show shipment type column setting
75
  */
76
  const XML_PATH_SHOW_SHIPMENT_TYPE_COLUMN = 'postnl/cif_labels_and_confirming/show_shipment_type_column';
77
+
78
  /**
79
  * Edits the sales order grid by adding a mass action to create shipments for selected orders
80
+ *
81
  * @param Varien_Event_Observer $observer
82
+ *
83
+ * @return $this
84
+ *
85
  * @event adminhtml_block_html_before
86
+ *
87
  * @observer postnl_adminhtml_ordergrid
88
  */
89
  public function modifyGrid(Varien_Event_Observer $observer)
94
  if (!Mage::helper('postnl')->isEnabled()) {
95
  return $this;
96
  }
97
+
98
  /**
99
  * Checks if the current block is the one we want to edit.
100
+ *
101
+ * Unfortunately there is no unique event for this block.
102
  */
103
  $block = $observer->getBlock();
104
  $orderGridClass = Mage::getConfig()->getBlockClassName(self::ORDER_GRID_BLOCK_NAME);
105
+
106
+ if (!($block instanceof $orderGridClass)) {
107
  return $this;
108
  }
109
+
110
+ /**
111
+ * @var Mage_Adminhtml_Block_Sales_Order_Grid $block
112
+ * @var Mage_Sales_Model_Resource_Order_Collection $currentCollection
113
+ */
114
  $currentCollection = $block->getCollection();
115
+ $select = $currentCollection->getSelect()->reset(Zend_Db_Select::WHERE);
116
+
 
117
  /**
118
  * replace the collection, as the default collection has a bug preventing it from being reset.
119
  * Without being able to reset it, we can't edit it. Therefore we are forced to replace it altogether
120
+ *
121
  * TODO see if this can be avoided in any way
122
  */
123
  $collection = Mage::getResourceModel('postnl/order_grid_collection');
124
  $collection->setSelect($select)
125
  ->setPageSize($currentCollection->getPageSize())
126
  ->setCurPage($currentCollection->getCurPage());
127
+
128
  $this->setCollection($collection);
129
  $this->setBlock($block);
130
+
131
  $this->_joinCollection($collection);
132
+ $this->_modifyColumns($block);
133
  $this->_addColumns($block);
134
  $this->_applySortAndFilter($collection);
135
  $this->_addMassaction($block);
136
+
137
  $block->setCollection($this->getCollection());
138
  return $this;
139
  }
140
+
141
  /**
142
  * Adds additional joins to the collection that will be used by newly added columns
143
+ *
144
+ * @param TIG_PostNL_Model_Resource_Order_Grid_Collection $collection
145
+ *
146
+ * @return $this
147
  */
148
  protected function _joinCollection($collection)
149
  {
150
  $resource = Mage::getSingleton('core/resource');
151
+
152
  $select = $collection->getSelect();
153
+
154
  /**
155
  * Join sales_flat_order table
156
  */
161
  'shipping_method' => 'order.shipping_method',
162
  )
163
  );
164
+
165
  /**
166
  * Join sales_flat_order_address table
167
  */
172
  'country_id' => 'shipping_address.country_id',
173
  )
174
  );
175
+
176
  /**
177
  * Join tig_postnl_order table
178
  */
183
  'is_pakje_gemak' => 'postnl_order.is_pakje_gemak',
184
  )
185
  );
186
+
187
  return $this;
188
  }
189
+
190
+ /**
191
+ * Modifies existing columns to prevent issues with the new collections.
192
+ *
193
+ * @param Mage_Adminhtml_Block_Sales_Order_Grid $block
194
+ *
195
+ * @return $this
196
+ */
197
+ protected function _modifyColumns($block)
198
+ {
199
+ /**
200
+ * @var Mage_Adminhtml_Block_Widget_Grid_Column $incrementIdColumn
201
+ */
202
+ $incrementIdColumn = $block->getColumn('real_order_id');
203
+ if ($incrementIdColumn) {
204
+ $incrementIdColumn->setFilterIndex('main_table.increment_id');
205
+ }
206
+
207
+ /**
208
+ * @var Mage_Adminhtml_Block_Widget_Grid_Column $massactionColumn
209
+ */
210
+ $massactionColumn = $block->getColumn('massaction');
211
+ if ($incrementIdColumn) {
212
+ $massactionColumn->setFilterIndex('main_table.entity_id');
213
+ }
214
+
215
+ /**
216
+ * @var Mage_Adminhtml_Block_Widget_Grid_Column $statusColumn
217
+ */
218
+ $statusColumn = $block->getColumn('status');
219
+ if ($incrementIdColumn) {
220
+ $statusColumn->setFilterIndex('main_table.status');
221
+ }
222
+
223
+ /**
224
+ * @var Mage_Adminhtml_Block_Widget_Grid_Column $createdAtColumn
225
+ */
226
+ $createdAtColumn = $block->getColumn('created_at');
227
+ if ($incrementIdColumn) {
228
+ $createdAtColumn->setFilterIndex('main_table.created_at');
229
+ }
230
+
231
+ /**
232
+ * @var Mage_Adminhtml_Block_Widget_Grid_Column $baseGrandTotalColumn
233
+ */
234
+ $baseGrandTotalColumn = $block->getColumn('base_grand_total');
235
+ if ($incrementIdColumn) {
236
+ $baseGrandTotalColumn->setFilterIndex('main_table.base_grand_total');
237
+ }
238
+
239
+ /**
240
+ * @var Mage_Adminhtml_Block_Widget_Grid_Column $grandTotalColumn
241
+ */
242
+ $grandTotalColumn = $block->getColumn('grand_total');
243
+ if ($incrementIdColumn) {
244
+ $grandTotalColumn->setFilterIndex('main_table.grand_total');
245
+ }
246
+
247
+ return $this;
248
+ }
249
+
250
  /**
251
  * Adds additional columns to the grid
252
+ *
253
  * @param Mage_Adminhtml_Block_Sales_Order_Grid $block
254
+ *
255
+ * @return $this
256
  */
257
  protected function _addColumns($block)
258
  {
259
  $helper = Mage::helper('postnl');
260
+
261
  $columnAttributes = array(
262
  'header' => $helper->__('Shipment type'),
263
  'align' => 'left',
274
  'global' => $helper->__('GlobalPack'),
275
  ),
276
  );
277
+
278
  $showShipmentTypeColumn = Mage::getStoreConfigFlag(
279
+ self::XML_PATH_SHOW_SHIPMENT_TYPE_COLUMN,
280
  Mage_Core_Model_App::ADMIN_STORE_ID
281
  );
282
+
283
  /**
284
  * If we don't need to display the shipment type column, hide it. We'll still need it for some javascript functionality
285
  */
288
  $columnAttributes['header_css_class'] = 'no-display';
289
  $columnAttributes['display'] = 'none';
290
  }
291
+
292
  $block->addColumnAfter(
293
  'country_id',
294
  $columnAttributes,
295
  'shipping_name'
296
  );
297
+
298
  $block->sortColumnsByOrder();
299
+
300
  return $this;
301
  }
302
 
303
  /**
304
  * Adds a massaction to confirm the order and print the shipping labels
305
+ *
306
  * @param Mage_Adminhtml_Block_Sales_Order_Grid $block
307
+ *
308
+ * @return $this
309
  */
310
  protected function _addMassaction($block)
311
  {
316
  'label'=> Mage::helper('postnl')->__('PostNL - Create Shipments'),
317
  'url' => Mage::helper('adminhtml')->getUrl('postnl/adminhtml_shipment/massCreateShipments'),
318
  );
319
+
320
  $showOptions = Mage::getStoreConfig(self::XML_PATH_SHOW_OPTIONS, Mage_Core_Model_App::ADMIN_STORE_ID);
321
+
322
  if ($showOptions) {
323
  /**
324
  * Add another dropdown containing the possible product options
334
  ),
335
  );
336
  }
337
+
338
  /**
339
  * Add the massaction
340
  */
341
  $block->getMassactionBlock()
342
  ->addItem(
343
+ 'create_shipments',
344
  $massActionData
345
  );
346
+
347
  return $this;
348
  }
349
+
350
  /**
351
  * Applies sorting and filtering to the collection
352
+ *
353
  * @param TIG_PostNL_Model_Resource_Order_Shipment_Grid_Collection $collection
354
+ *
355
+ * @return $this
356
  */
357
  protected function _applySortAndFilter($collection)
358
  {
359
  $session = Mage::getSingleton('adminhtml/session');
360
+
361
  $filter = $session->getData(self::ORDER_GRID_FILTER_VAR_NAME);
362
  $filter = Mage::helper('adminhtml')->prepareFilterString($filter);
363
+
364
  if ($filter) {
365
  $this->_filterCollection($collection, $filter);
366
  }
367
+
368
  $sort = $session->getData(self::ORDER_GRID_SORT_VAR_NAME);
369
+
370
  if ($sort) {
371
  $dir = $session->getData(self::ORDER_GRID_DIR_VAR_NAME);
372
+
373
  $this->_sortCollection($collection, $sort, $dir);
374
  }
375
+
376
  return $this;
377
  }
378
+
379
  /**
380
  * Adds new filters to the collection if these filters are based on columns added by this observer
381
+ *
382
  * @param TIG_PostNL_Model_Resource_Order_Shipment_Grid_Collection $collection
383
  * @param array $filter Array of filters to be added
384
+ *
385
+ * @return $this
386
  */
387
  protected function _filterCollection($collection, $filter)
388
  {
389
  $block = $this->getBlock();
390
+
391
  foreach ($filter as $columnName => $value) {
392
  $column = $block->getColumn($columnName);
393
+
394
  $column->getFilter()->setValue($value);
395
  $this->_addColumnFilterToCollection($column);
396
  }
397
+
398
  return $this;
399
  }
400
+
401
  /**
402
  * Filters the collection by the 'shipment_type' column. Th column has 3 options: domestic, EPS and GlobalPack.
403
+ *
404
  * @param TIG_PostNL_Model_Resource_Order_Shipment_Grid_Collection $collection
405
  * @param Mage_Adminhtml_Block_Widget_Grid_Column $column
406
+ *
407
+ * @return $this
408
  */
409
  protected function _filterShipmentType($collection, $column)
410
  {
411
  $cond = $column->getFilter()->getCondition();
412
  $filterCond = $cond['eq'];
413
+
414
  /**
415
  * First filter out all non-postnl orders
416
  */
417
  $postnlShippingMethods = Mage::helper('postnl/carrier')->getPostnlShippingMethods();
418
  $collection->addFieldToFilter('order.shipping_method', array('in' => $postnlShippingMethods));
419
+
420
  /**
421
  * If the filter condition is PakjeGemak, filter out all non-PakjeGemak orders
422
  */
423
  if ($filterCond == 'pakje_gemak') {
424
  $collection->addFieldToFilter('is_pakje_gemak', array('eq' => 1));
425
+
426
  return $this;
427
  }
428
+
429
  /**
430
  * If the filter condition is NL, filter out all orders not being shipped to the Netherlands
431
  */
432
  if ($filterCond == 'nl') {
433
  $collection->addFieldToFilter('country_id', $cond);
434
+
435
  return $this;
436
  }
437
+
438
  /**
439
+ * If the filter condition is EU, filter out all orders not being shipped to the EU and those being shipped to
440
  * the Netherlands
441
  */
442
  $euCountries = Mage::helper('postnl/cif')->getEuCountries();
443
  if ($filterCond == 'eu') {
444
  $collection->addFieldToFilter('country_id', array('neq' => 'NL'));
445
  $collection->addFieldToFilter('country_id', array('in', $euCountries));
446
+
447
  return $this;
448
  }
449
+
450
  /**
451
  * Lastly, filter out all orders who are being shipped to the Netherlands or other EU countries
452
  */
453
  $collection->addFieldToFilter('country_id', array('neq' => 'NL'));
454
  $collection->addFieldToFilter('country_id', array('nin' => $euCountries));
455
+
456
  return $this;
457
  }
458
+
459
  /**
460
  * Based on Mage_Adminhtml_Block_Widget_Grid::_addColumnFilterToCollection()
461
+ *
462
  * Adds a filter condition to the collection for a specified column
463
+ *
464
  * @param Mage_Adminhtml_Block_Widget_Grid_Column $column
465
+ *
466
+ * @return $this
467
  */
468
  protected function _addColumnFilterToCollection($column)
469
  {
470
  if (!$this->getCollection()) {
471
  return $this;
472
  }
473
+
474
  $field = ($column->getFilterIndex()) ? $column->getFilterIndex() : $column->getIndex();
475
  if ($column->getFilterConditionCallback()) {
476
  call_user_func($column->getFilterConditionCallback(), $this->getCollection(), $column);
477
+
478
  return $this;
479
  }
480
+
481
  $cond = $column->getFilter()->getCondition();
482
  if ($field && isset($cond)) {
483
  $this->getCollection()->addFieldToFilter($field , $cond);
484
  }
485
+
486
  return $this;
487
  }
488
+
489
  /**
490
  * Sorts the collection by a specified column in a specified direction
491
+ *
492
  * @param TIG_PostNL_Model_Resource_Order_Shipment_Grid_Collection $collection
493
  * @param string $sort The column that the collection is sorted by
494
  * @param string $dir The direction that is used to sort the collection
495
+ *
496
+ * @return $this
497
  */
498
  protected function _sortCollection($collection, $sort, $dir)
499
  {
502
  if (!$column) {
503
  return $this;
504
  }
505
+
506
  $column->setDir($dir);
507
  $this->_setCollectionOrder($column);
508
+
509
  return $this;
510
  }
511
+
512
  /**
513
  * Sets sorting order by some column
514
  *
515
  * @param Mage_Adminhtml_Block_Widget_Grid_Column $column
516
+ *
517
+ * @return $this
518
  */
519
  protected function _setCollectionOrder($column)
520
  {
522
  if (!$collection) {
523
  return $this;
524
  }
525
+
526
  $columnIndex = $column->getFilterIndex() ? $column->getFilterIndex() : $column->getIndex();
527
  $collection->setOrder($columnIndex, strtoupper($column->getDir()));
528
  return $this;
app/code/community/TIG/PostNL/Model/Adminhtml/Observer/ShipmentGrid.php CHANGED
@@ -1,28 +1,28 @@
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@totalinternetgroup.nl so we can send you a copy immediately.
@@ -35,9 +35,7 @@
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
  * Observer to edit the sales > shipments grid
42
  */
43
  class TIG_PostNL_Model_Adminhtml_Observer_ShipmentGrid extends Varien_Object
@@ -46,58 +44,58 @@ class TIG_PostNL_Model_Adminhtml_Observer_ShipmentGrid extends Varien_Object
46
  * The block we want to edit
47
  */
48
  const SHIPMENT_GRID_BLOCK_NAME = 'adminhtml/sales_shipment_grid';
49
-
50
  /**
51
  * variable name for shipment grid filter
52
  */
53
  const SHIPMENT_GRID_FILTER_VAR_NAME = 'sales_shipment_gridfilter';
54
-
55
  /**
56
  * variable name for shipment grid sorting
57
  */
58
  const SHIPMENT_GRID_SORT_VAR_NAME = 'sales_shipment_gridsort';
59
-
60
  /**
61
  * variable name for shipment grid sorting direction
62
  */
63
  const SHIPMENT_GRID_DIR_VAR_NAME = 'sales_shipment_griddir';
64
-
65
  /**
66
  * XML path to 'shipping grid columns' setting
67
  */
68
  const XML_PATH_SHIPPING_GRID_COLUMNS = 'postnl/cif_labels_and_confirming/shipping_grid_columns';
69
-
70
  /**
71
  * XML path to default selected mass action setting
72
  */
73
  const XML_PATH_SHIPPING_GRID_MASSACTION_DEFAULT = 'postnl/cif_labels_and_confirming/shipping_grid_massaction_default';
74
-
75
  /**
76
  * Gets an array of optional columns to display
77
- *
78
  * @return boolean
79
  */
80
  public function getOptionalColumnsToDisplay()
81
  {
82
  $storeId = Mage_Core_Model_App::ADMIN_STORE_ID;
83
  $columnsToDisplay = Mage::getStoreConfig(self::XML_PATH_SHIPPING_GRID_COLUMNS, $storeId);
84
-
85
  $columnsToDisplay = explode(',', $columnsToDisplay);
86
-
87
  return $columnsToDisplay;
88
  }
89
-
90
  /**
91
  * Observer that adds columns to the grid and allows these to be sorted and filtered properly
92
- *
93
  * @param Varien_Event_Observer $observer
94
- *
95
- * @return TIG_PostNL_Model_Adminhtml_ShipmentGridObserver
96
- *
97
  * @event adminhtml_block_html_before
98
- *
99
  * @observer postnl_adminhtml_shipmentgrid
100
- *
101
  * @todo see if replacing the collection can be avoided
102
  */
103
  public function modifyGrid(Varien_Event_Observer $observer)
@@ -108,59 +106,59 @@ class TIG_PostNL_Model_Adminhtml_Observer_ShipmentGrid extends Varien_Object
108
  if (!Mage::helper('postnl')->isEnabled()) {
109
  return $this;
110
  }
111
-
112
  /**
113
  * Checks if the current block is the one we want to edit.
114
- *
115
  * Unfortunately there is no unique event for this block
116
  */
117
  $block = $observer->getBlock();
118
  $shipmentGridClass = Mage::getConfig()->getBlockClassName(self::SHIPMENT_GRID_BLOCK_NAME);
119
-
120
  if (get_class($block) !== $shipmentGridClass) {
121
  return $this;
122
  }
123
-
124
  $currentCollection = $block->getCollection();
125
  $select = $currentCollection->getSelect()->reset(Zend_Db_Select::WHERE);
126
-
127
  /**
128
  * replace the collection as the default collection has a bug preventing it from being reset.
129
  * Without being able to reset it, we can't edit it. Therefore we are forced to replace it altogether
130
- *
131
  * TODO see if this can be avoided in any way
132
  */
133
  $collection = Mage::getResourceModel('postnl/order_shipment_grid_collection');
134
  $collection->setSelect($select)
135
  ->setPageSize($currentCollection->getPageSize())
136
  ->setCurPage($currentCollection->getCurPage());
137
-
138
  $this->setCollection($collection);
139
  $this->setBlock($block);
140
-
141
  $this->_joinCollection($collection);
142
  $this->_modifyColumns($block);
143
  $this->_addColumns($block);
144
  $this->_applySortAndFilter($collection);
145
  $this->_addMassaction($block);
146
-
147
  $block->setCollection($this->getCollection());
148
  return $this;
149
  }
150
-
151
  /**
152
  * Adds additional joins to the collection that will be used by newly added columns
153
- *
154
  * @param TIG_PostNL_Model_Resource_Order_Shipment_Grid_Collection $collection
155
- *
156
- * @return TIG_PostNL_Model_Adminhtml_ShipmentGridObserver
157
  */
158
  protected function _joinCollection($collection)
159
  {
160
  $resource = Mage::getSingleton('core/resource');
161
-
162
  $select = $collection->getSelect();
163
-
164
  /**
165
  * Join sales_flat_order table
166
  */
@@ -172,7 +170,7 @@ class TIG_PostNL_Model_Adminhtml_Observer_ShipmentGrid extends Varien_Object
172
  'shipping_description' => 'order.shipping_description',
173
  )
174
  );
175
-
176
  /**
177
  * join sales_flat_order_address table
178
  */
@@ -184,7 +182,7 @@ class TIG_PostNL_Model_Adminhtml_Observer_ShipmentGrid extends Varien_Object
184
  'country_id' => 'shipping_address.country_id',
185
  )
186
  );
187
-
188
  /**
189
  * Join tig_postnl_shipment table
190
  */
@@ -200,7 +198,7 @@ class TIG_PostNL_Model_Adminhtml_Observer_ShipmentGrid extends Varien_Object
200
  'parcel_count' => 'postnl_shipment.parcel_count',
201
  )
202
  );
203
-
204
  /**
205
  * Join tig_postnl_order table
206
  */
@@ -211,47 +209,47 @@ class TIG_PostNL_Model_Adminhtml_Observer_ShipmentGrid extends Varien_Object
211
  'is_pakje_gemak' => 'postnl_order.is_pakje_gemak',
212
  )
213
  );
214
-
215
  return $this;
216
  }
217
-
218
  /**
219
  * Modifies existing columns to prevent issues with the new collections
220
- *
221
  * @param Mage_Adminhtml_Block_Sales_Shipment_Grid $block
222
- *
223
- * @return TIG_PostNL_Model_Adminhtml_ShipmentGridObserver
224
  */
225
  protected function _modifyColumns($block)
226
  {
227
  $incrementIdColumn = $block->getColumn('increment_id');
228
  $incrementIdColumn->setFilterIndex('main_table.increment_id');
229
-
230
  $createdAtColumn = $block->getColumn('created_at');
231
  $createdAtColumn->setFilterIndex('main_table.created_at');
232
-
233
  $massactionColumn = $block->getColumn('massaction');
234
  $massactionColumn->setFilterIndex('main_table.entity_id');
235
-
236
  return $this;
237
  }
238
-
239
  /**
240
  * Adds additional columns to the grid
241
- *
242
  * @param Mage_Adminhtml_Block_Sales_Shipment_Grid $block
243
- *
244
- * @return TIG_PostNL_Model_Adminhtml_ShipmentGridObserver
245
  */
246
  protected function _addColumns($block)
247
  {
248
  $helper = Mage::helper('postnl');
249
-
250
  /**
251
  * Get an array of which optional columns should be shown
252
  */
253
  $columnsToDisplay = $this->getOptionalColumnsToDisplay();
254
-
255
  /**
256
  * This variable is the column ID of each column that the next column will follow.
257
  * By changing this variable after each column is added we guarantee the correct
@@ -270,10 +268,10 @@ class TIG_PostNL_Model_Adminhtml_Observer_ShipmentGrid extends Varien_Object
270
  ),
271
  $after
272
  );
273
-
274
  $after = 'parcel_count';
275
  }
276
-
277
  if (in_array('shipping_description', $columnsToDisplay)) {
278
  $block->addColumnAfter(
279
  'shipping_description',
@@ -284,10 +282,10 @@ class TIG_PostNL_Model_Adminhtml_Observer_ShipmentGrid extends Varien_Object
284
  ),
285
  $after
286
  );
287
-
288
  $after = 'shipping_description';
289
  }
290
-
291
  if (in_array('shipment_type', $columnsToDisplay)) {
292
  $block->addColumnAfter(
293
  'shipment_type',
@@ -309,10 +307,10 @@ class TIG_PostNL_Model_Adminhtml_Observer_ShipmentGrid extends Varien_Object
309
  ),
310
  $after
311
  );
312
-
313
  $after = 'shipment_type';
314
  }
315
-
316
  if (in_array('confirm_date', $columnsToDisplay)) {
317
  $block->addColumnAfter(
318
  'confirm_date',
@@ -327,13 +325,13 @@ class TIG_PostNL_Model_Adminhtml_Observer_ShipmentGrid extends Varien_Object
327
  ),
328
  $after
329
  );
330
-
331
  $after = 'confirm_date';
332
  }
333
-
334
  if (in_array('confirm_status', $columnsToDisplay)) {
335
  $postnlShipmentClass = Mage::app()->getConfig()->getModelClassName('postnl_core/shipment');
336
-
337
  $block->addColumnAfter(
338
  'confirm_status',
339
  array(
@@ -350,10 +348,10 @@ class TIG_PostNL_Model_Adminhtml_Observer_ShipmentGrid extends Varien_Object
350
  ),
351
  $after
352
  );
353
-
354
  $after = 'confirm_status';
355
  }
356
-
357
  if (in_array('labels_printed', $columnsToDisplay)) {
358
  $block->addColumnAfter(
359
  'labels_printed',
@@ -370,10 +368,10 @@ class TIG_PostNL_Model_Adminhtml_Observer_ShipmentGrid extends Varien_Object
370
  ),
371
  $after
372
  );
373
-
374
  $after = 'labels_printed';
375
  }
376
-
377
  if (in_array('barcode', $columnsToDisplay)) {
378
  $block->addColumnAfter(
379
  'barcode',
@@ -385,10 +383,10 @@ class TIG_PostNL_Model_Adminhtml_Observer_ShipmentGrid extends Varien_Object
385
  ),
386
  $after
387
  );
388
-
389
  $after = 'barcode';
390
  }
391
-
392
  if (in_array('shipping_phase', $columnsToDisplay)) {
393
  $block->addColumnAfter(
394
  'shipping_phase',
@@ -403,44 +401,44 @@ class TIG_PostNL_Model_Adminhtml_Observer_ShipmentGrid extends Varien_Object
403
  ),
404
  $after
405
  );
406
-
407
  $after = 'shipping_phase';
408
  }
409
-
410
  $actionColumn = $block->getColumn('action');
411
  $actions = $actionColumn->getActions();
412
-
413
  $actions[] = array(
414
  'caption' => $helper->__('Print label'),
415
  'url' => array('base' => 'postnl/adminhtml_shipment/printLabel'),
416
  'field' => 'shipment_id',
417
  'is_postnl' => true, //custom flag for renderer
418
  );
419
-
420
  $actions[] = array(
421
  'caption' => $helper->__('Confirm'),
422
  'url' => array('base' => 'postnl/adminhtml_shipment/confirm'),
423
  'field' => 'shipment_id',
424
  'is_postnl' => true, //custom flag for renderer
425
  );
426
-
427
  $actionColumn->setActions($actions)
428
  ->setWidth('150px')
429
  ->setData('renderer', 'postnl_adminhtml/widget_grid_column_renderer_action');
430
-
431
  $block->sortColumnsByOrder();
432
-
433
  return $this;
434
  }
435
 
436
  /**
437
  * Decorates the confirm_sate column
438
- *
439
  * @param string | null $value
440
  * @param Mage_Sales_Model_Order_Shipment $row
441
  * @param Mage_Adminhtml_Block_Widget_Grid_Column $column
442
  * @param boolean $isExport
443
- *
444
  * @return string
445
  */
446
  public function decorateConfirmDate($value, $row, $column, $isExport)
@@ -448,20 +446,20 @@ class TIG_PostNL_Model_Adminhtml_Observer_ShipmentGrid extends Varien_Object
448
  if ($isExport) {
449
  return $value;
450
  }
451
-
452
  $origValue = $row->getData($column->getIndex());
453
-
454
  $postnlShipmentClass = Mage::getConfig()->getModelClassName('postnl_core/shipment');
455
-
456
  $class = '';
457
  if ($row->getData('confirm_status') == $postnlShipmentClass::CONFIRM_STATUS_CONFIRMED) {
458
  $class = 'grid-severity-notice';
459
  }
460
-
461
  if ($row->getData('confirm_status') == $postnlShipmentClass::CONFIRM_STATUS_CONFIRM_EXPIRED) {
462
  $class = 'grid-severity-critical';
463
  }
464
-
465
  if ($row->getData('confirm_status') == $postnlShipmentClass::CONFIRM_STATUS_UNCONFIRMED
466
  && date('Ymd', Mage::getModel('core/date')->gmtTimestamp()) == date('Ymd', strtotime($origValue))
467
  ) {
@@ -473,18 +471,18 @@ class TIG_PostNL_Model_Adminhtml_Observer_ShipmentGrid extends Varien_Object
473
  } elseif ($row->getData('confirm_status') == $postnlShipmentClass::CONFIRM_STATUS_UNCONFIRMED) {
474
  $class = 'grid-severity-minor';
475
  }
476
-
477
  return '<span class="'.$class.'"><span>'.$value.'</span></span>';
478
  }
479
-
480
  /**
481
  * Decorates the confirm_status column
482
- *
483
  * @param string | null $value
484
  * @param Mage_Sales_Model_Order_Shipment $row
485
  * @param Mage_Adminhtml_Block_Widget_Grid_Column $column
486
  * @param boolean $isExport
487
- *
488
  * @return string
489
  */
490
  public function decorateConfirmStatus($value, $row, $column, $isExport)
@@ -492,7 +490,7 @@ class TIG_PostNL_Model_Adminhtml_Observer_ShipmentGrid extends Varien_Object
492
  if ($isExport) {
493
  return $value;
494
  }
495
-
496
  $postnlShipmentClass = Mage::getConfig()->getModelClassName('postnl_core/shipment');
497
  switch ($row->getData($column->getIndex())) {
498
  case null: //rows with no value (non-PostNL shipments)
@@ -511,15 +509,15 @@ class TIG_PostNL_Model_Adminhtml_Observer_ShipmentGrid extends Varien_Object
511
  }
512
  return '<span class="'.$class.'"><span>'.$value.'</span></span>';
513
  }
514
-
515
  /**
516
  * Decorates the labels_printed column
517
- *
518
  * @param string | null $value
519
  * @param Mage_Sales_Model_Order_Shipment $row
520
  * @param Mage_Adminhtml_Block_Widget_Grid_Column $column
521
  * @param boolean $isExport
522
- *
523
  * @return string
524
  */
525
  public function decorateLabelsPrinted($value, $row, $column, $isExport)
@@ -527,7 +525,7 @@ class TIG_PostNL_Model_Adminhtml_Observer_ShipmentGrid extends Varien_Object
527
  if ($isExport) {
528
  return $value;
529
  }
530
-
531
  switch ($row->getData($column->getIndex())) {
532
  case null: //rows with no value (non-PostNL shipments)
533
  $class = '';
@@ -544,15 +542,15 @@ class TIG_PostNL_Model_Adminhtml_Observer_ShipmentGrid extends Varien_Object
544
  }
545
  return '<span class="'.$class.'"><span>'.$value.'</span></span>';
546
  }
547
-
548
  /**
549
  * Decorates the shipping_phase column
550
- *
551
  * @param string | null $value
552
  * @param Mage_Sales_Model_Order_Shipment $row
553
  * @param Mage_Adminhtml_Block_Widget_Grid_Column $column
554
  * @param boolean $isExport
555
- *
556
  * @return string
557
  */
558
  public function decorateShippingPhase($value, $row, $column, $isExport)
@@ -560,9 +558,9 @@ class TIG_PostNL_Model_Adminhtml_Observer_ShipmentGrid extends Varien_Object
560
  if ($isExport) {
561
  return $value;
562
  }
563
-
564
  $postnlShipmentClass = Mage::getConfig()->getModelClassName('postnl_core/shipment');
565
-
566
  $class = '';
567
  switch ($row->getData($column->getIndex())) {
568
  case null: //rows with no value (non-PostNL shipments) or unconfirmed shipments
@@ -588,15 +586,15 @@ class TIG_PostNL_Model_Adminhtml_Observer_ShipmentGrid extends Varien_Object
588
 
589
  /**
590
  * Adds a massaction to confirm the order and print the shipping labels
591
- *
592
  * @param Mage_Adminhtml_Block_Sales_Shipment_Grid $block
593
- *
594
- * @return TIG_PostNL_Model_Adminhtml_ShipmentGridObserver
595
  */
596
  protected function _addMassaction($block)
597
  {
598
  $massactionBlock = $block->getMassactionBlock();
599
-
600
  /**
601
  * Build all the mass action option arrays
602
  */
@@ -604,25 +602,25 @@ class TIG_PostNL_Model_Adminhtml_Observer_ShipmentGrid extends Varien_Object
604
  'label'=> Mage::helper('postnl')->__('PostNL - Print shipping labels & confirm shipment'),
605
  'url' => Mage::helper('adminhtml')->getUrl('postnl/adminhtml_shipment/massPrintLabelsAndConfirm'),
606
  );
607
-
608
  $printOptions = array(
609
  'label'=> Mage::helper('postnl')->__('PostNL - Print shipping labels'),
610
  'url' => Mage::helper('adminhtml')->getUrl('postnl/adminhtml_shipment/massPrintLabels'),
611
  );
612
-
613
  $confirmOptions = array(
614
  'label'=> Mage::helper('postnl')->__('PostNL - Confirm shipments'),
615
  'url' => Mage::helper('adminhtml')->getUrl('postnl/adminhtml_shipment/massConfirm'),
616
  );
617
-
618
  /**
619
  * Check which mass action should be selected by default
620
  */
621
  $defaultSelectedOption = Mage::getStoreConfig(
622
- self::XML_PATH_SHIPPING_GRID_MASSACTION_DEFAULT,
623
  Mage_Core_Model_App::ADMIN_STORE_ID
624
  );
625
-
626
  /**
627
  * Add the additional 'selected' parameter to the chosen mass action
628
  */
@@ -638,7 +636,7 @@ class TIG_PostNL_Model_Adminhtml_Observer_ShipmentGrid extends Varien_Object
638
  break;
639
  // no default
640
  }
641
-
642
  /**
643
  * Add the mass actions to the grid
644
  */
@@ -646,170 +644,170 @@ class TIG_PostNL_Model_Adminhtml_Observer_ShipmentGrid extends Varien_Object
646
  'postnl_print_labels_and_confirm',
647
  $printAndConfirmOptions
648
  );
649
-
650
  $massactionBlock->addItem(
651
  'postnl_print_labels',
652
  $printOptions
653
  );
654
-
655
  $massactionBlock->addItem(
656
  'postnl_confirm_shipments',
657
  $confirmOptions
658
  );
659
-
660
  return $this;
661
  }
662
-
663
  /**
664
  * Applies sorting and filtering to the collection
665
- *
666
  * @param TIG_PostNL_Model_Resource_Order_Shipment_Grid_Collection $collection
667
- *
668
- * @return TIG_PostNL_Model_Adminhtml_ShipmentGridObserver
669
  */
670
  protected function _applySortAndFilter($collection)
671
  {
672
  $session = Mage::getSingleton('adminhtml/session');
673
-
674
  $filter = $session->getData(self::SHIPMENT_GRID_FILTER_VAR_NAME);
675
  $filter = Mage::helper('adminhtml')->prepareFilterString($filter);
676
-
677
  if ($filter) {
678
  $this->_filterCollection($collection, $filter);
679
  }
680
-
681
  $sort = $session->getData(self::SHIPMENT_GRID_SORT_VAR_NAME);
682
-
683
  if ($sort) {
684
  $dir = $session->getData(self::SHIPMENT_GRID_DIR_VAR_NAME);
685
-
686
  $this->_sortCollection($collection, $sort, $dir);
687
  }
688
-
689
  return $this;
690
  }
691
-
692
  /**
693
  * Adds new filters to the collection if these filters are based on columns added by this observer
694
- *
695
  * @param TIG_PostNL_Model_Resource_Order_Shipment_Grid_Collection $collection
696
  * @param array $filter Array of filters to be added
697
- *
698
- * @return TIG_PostNL_Model_Adminhtml_ShipmentGridObserver
699
  */
700
  protected function _filterCollection($collection, $filter)
701
  {
702
  $block = $this->getBlock();
703
-
704
  foreach ($filter as $columnName => $value) {
705
  $column = $block->getColumn($columnName);
706
  if (!$column) {
707
  continue;
708
  }
709
-
710
  $column->getFilter()->setValue($value);
711
  $this->_addColumnFilterToCollection($column);
712
  }
713
-
714
  return $this;
715
  }
716
-
717
  /**
718
  * Filters the collection by the 'shipment_type' column. Th column has 3 options: domestic, EPS and GlobalPack.
719
- *
720
  * @param TIG_PostNL_Model_Resource_Order_Shipment_Grid_Collection $collection
721
  * @param Mage_Adminhtml_Block_Widget_Grid_Column $column
722
- *
723
  * @return TIG_PostNL_Model_Adminhtml_Observer_OrderGrid
724
  */
725
  protected function _filterShipmentType($collection, $column)
726
  {
727
  $cond = $column->getFilter()->getCondition();
728
  $filterCond = $cond['eq'];
729
-
730
  /**
731
  * First filter out all non-postnl orders
732
  */
733
  $postnlShippingMethods = Mage::helper('postnl/carrier')->getPostnlShippingMethods();
734
  $collection->addFieldToFilter('order.shipping_method', array('in' => $postnlShippingMethods));
735
-
736
  /**
737
  * If the filter condition is PakjeGemak, filter out all non-PakjeGemak orders
738
  */
739
  if ($filterCond == 'pakje_gemak') {
740
  $collection->addFieldToFilter('postnl_shipment.is_pakje_gemak', array('eq' => 1));
741
-
742
  return $this;
743
  }
744
-
745
  /**
746
  * If the filter condition is NL, filter out all orders not being shipped to the Netherlands
747
  */
748
  if ($filterCond == 'nl') {
749
  $collection->addFieldToFilter('country_id', $cond);
750
-
751
  return $this;
752
  }
753
-
754
  /**
755
- * If the filter condition is EU, filter out all orders not being shipped to the EU and those being shipped to
756
  * the Netherlands
757
  */
758
  $euCountries = Mage::helper('postnl/cif')->getEuCountries();
759
  if ($filterCond == 'eu') {
760
  $collection->addFieldToFilter('country_id', array('neq' => 'NL'));
761
  $collection->addFieldToFilter('country_id', array('in', $euCountries));
762
-
763
  return $this;
764
  }
765
-
766
  /**
767
  * Lastly, filter out all orders that are being shipped to the Netherlands or other EU countries
768
  */
769
  $collection->addFieldToFilter('country_id', array('neq' => 'NL'));
770
  $collection->addFieldToFilter('country_id', array('nin' => $euCountries));
771
-
772
  return $this;
773
  }
774
-
775
  /**
776
  * Based on Mage_Adminhtml_Block_Widget_Grid::_addColumnFilterToCollection()
777
- *
778
  * Adds a filter condition to the collection for a specified column
779
- *
780
  * @param Mage_Adminhtml_Block_Widget_Grid_Column $column
781
- *
782
- * @return TIG_PostNL_Model_Adminhtml_ShipmentGridObserver
783
  */
784
  protected function _addColumnFilterToCollection($column)
785
  {
786
  if (!$this->getCollection()) {
787
  return $this;
788
  }
789
-
790
  if ($column->getFilterConditionCallback()) {
791
  call_user_func($column->getFilterConditionCallback(), $this->getCollection(), $column);
792
-
793
  return $this;
794
  }
795
-
796
- $field = ($column->getFilterIndex()) ? $column->getFilterIndex() : $column->getIndex();
797
  $cond = $column->getFilter()->getCondition();
798
  if ($field && isset($cond)) {
799
  $this->getCollection()->addFieldToFilter($field , $cond);
800
  }
801
-
802
  return $this;
803
  }
804
-
805
  /**
806
  * Sorts the collection by a specified column in a specified direction
807
- *
808
  * @param TIG_PostNL_Model_Resource_Order_Shipment_Grid_Collection $collection
809
  * @param string $sort The column that the collection is sorted by
810
  * @param string $dir The direction that is used to sort the collection
811
- *
812
- * @return TIG_PostNL_Model_Adminhtml_ShipmentGridObserver
813
  */
814
  protected function _sortCollection($collection, $sort, $dir)
815
  {
@@ -818,19 +816,19 @@ class TIG_PostNL_Model_Adminhtml_Observer_ShipmentGrid extends Varien_Object
818
  if (!$column) {
819
  return $this;
820
  }
821
-
822
  $column->setDir($dir);
823
  $this->_setCollectionOrder($column);
824
-
825
  return $this;
826
  }
827
-
828
  /**
829
  * Sets sorting order by some column
830
  *
831
  * @param Mage_Adminhtml_Block_Widget_Grid_Column $column
832
- *
833
- * @return TIG_PostNL_Model_Adminhtml_ShipmentGridObserver
834
  */
835
  protected function _setCollectionOrder($column)
836
  {
@@ -838,9 +836,9 @@ class TIG_PostNL_Model_Adminhtml_Observer_ShipmentGrid extends Varien_Object
838
  if (!$collection) {
839
  return $this;
840
  }
841
-
842
  $columnIndex = $column->getFilterIndex() ? $column->getFilterIndex() : $column->getIndex();
843
-
844
  $collection->setOrder($columnIndex, strtoupper($column->getDir()));
845
  return $this;
846
  }
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@totalinternetgroup.nl so we can send you a copy immediately.
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
  * Observer to edit the sales > shipments grid
40
  */
41
  class TIG_PostNL_Model_Adminhtml_Observer_ShipmentGrid extends Varien_Object
44
  * The block we want to edit
45
  */
46
  const SHIPMENT_GRID_BLOCK_NAME = 'adminhtml/sales_shipment_grid';
47
+
48
  /**
49
  * variable name for shipment grid filter
50
  */
51
  const SHIPMENT_GRID_FILTER_VAR_NAME = 'sales_shipment_gridfilter';
52
+
53
  /**
54
  * variable name for shipment grid sorting
55
  */
56
  const SHIPMENT_GRID_SORT_VAR_NAME = 'sales_shipment_gridsort';
57
+
58
  /**
59
  * variable name for shipment grid sorting direction
60
  */
61
  const SHIPMENT_GRID_DIR_VAR_NAME = 'sales_shipment_griddir';
62
+
63
  /**
64
  * XML path to 'shipping grid columns' setting
65
  */
66
  const XML_PATH_SHIPPING_GRID_COLUMNS = 'postnl/cif_labels_and_confirming/shipping_grid_columns';
67
+
68
  /**
69
  * XML path to default selected mass action setting
70
  */
71
  const XML_PATH_SHIPPING_GRID_MASSACTION_DEFAULT = 'postnl/cif_labels_and_confirming/shipping_grid_massaction_default';
72
+
73
  /**
74
  * Gets an array of optional columns to display
75
+ *
76
  * @return boolean
77
  */
78
  public function getOptionalColumnsToDisplay()
79
  {
80
  $storeId = Mage_Core_Model_App::ADMIN_STORE_ID;
81
  $columnsToDisplay = Mage::getStoreConfig(self::XML_PATH_SHIPPING_GRID_COLUMNS, $storeId);
82
+
83
  $columnsToDisplay = explode(',', $columnsToDisplay);
84
+
85
  return $columnsToDisplay;
86
  }
87
+
88
  /**
89
  * Observer that adds columns to the grid and allows these to be sorted and filtered properly
90
+ *
91
  * @param Varien_Event_Observer $observer
92
+ *
93
+ * @return $this
94
+ *
95
  * @event adminhtml_block_html_before
96
+ *
97
  * @observer postnl_adminhtml_shipmentgrid
98
+ *
99
  * @todo see if replacing the collection can be avoided
100
  */
101
  public function modifyGrid(Varien_Event_Observer $observer)
106
  if (!Mage::helper('postnl')->isEnabled()) {
107
  return $this;
108
  }
109
+
110
  /**
111
  * Checks if the current block is the one we want to edit.
112
+ *
113
  * Unfortunately there is no unique event for this block
114
  */
115
  $block = $observer->getBlock();
116
  $shipmentGridClass = Mage::getConfig()->getBlockClassName(self::SHIPMENT_GRID_BLOCK_NAME);
117
+
118
  if (get_class($block) !== $shipmentGridClass) {
119
  return $this;
120
  }
121
+
122
  $currentCollection = $block->getCollection();
123
  $select = $currentCollection->getSelect()->reset(Zend_Db_Select::WHERE);
124
+
125
  /**
126
  * replace the collection as the default collection has a bug preventing it from being reset.
127
  * Without being able to reset it, we can't edit it. Therefore we are forced to replace it altogether
128
+ *
129
  * TODO see if this can be avoided in any way
130
  */
131
  $collection = Mage::getResourceModel('postnl/order_shipment_grid_collection');
132
  $collection->setSelect($select)
133
  ->setPageSize($currentCollection->getPageSize())
134
  ->setCurPage($currentCollection->getCurPage());
135
+
136
  $this->setCollection($collection);
137
  $this->setBlock($block);
138
+
139
  $this->_joinCollection($collection);
140
  $this->_modifyColumns($block);
141
  $this->_addColumns($block);
142
  $this->_applySortAndFilter($collection);
143
  $this->_addMassaction($block);
144
+
145
  $block->setCollection($this->getCollection());
146
  return $this;
147
  }
148
+
149
  /**
150
  * Adds additional joins to the collection that will be used by newly added columns
151
+ *
152
  * @param TIG_PostNL_Model_Resource_Order_Shipment_Grid_Collection $collection
153
+ *
154
+ * @return $this
155
  */
156
  protected function _joinCollection($collection)
157
  {
158
  $resource = Mage::getSingleton('core/resource');
159
+
160
  $select = $collection->getSelect();
161
+
162
  /**
163
  * Join sales_flat_order table
164
  */
170
  'shipping_description' => 'order.shipping_description',
171
  )
172
  );
173
+
174
  /**
175
  * join sales_flat_order_address table
176
  */
182
  'country_id' => 'shipping_address.country_id',
183
  )
184
  );
185
+
186
  /**
187
  * Join tig_postnl_shipment table
188
  */
198
  'parcel_count' => 'postnl_shipment.parcel_count',
199
  )
200
  );
201
+
202
  /**
203
  * Join tig_postnl_order table
204
  */
209
  'is_pakje_gemak' => 'postnl_order.is_pakje_gemak',
210
  )
211
  );
212
+
213
  return $this;
214
  }
215
+
216
  /**
217
  * Modifies existing columns to prevent issues with the new collections
218
+ *
219
  * @param Mage_Adminhtml_Block_Sales_Shipment_Grid $block
220
+ *
221
+ * @return $this
222
  */
223
  protected function _modifyColumns($block)
224
  {
225
  $incrementIdColumn = $block->getColumn('increment_id');
226
  $incrementIdColumn->setFilterIndex('main_table.increment_id');
227
+
228
  $createdAtColumn = $block->getColumn('created_at');
229
  $createdAtColumn->setFilterIndex('main_table.created_at');
230
+
231
  $massactionColumn = $block->getColumn('massaction');
232
  $massactionColumn->setFilterIndex('main_table.entity_id');
233
+
234
  return $this;
235
  }
236
+
237
  /**
238
  * Adds additional columns to the grid
239
+ *
240
  * @param Mage_Adminhtml_Block_Sales_Shipment_Grid $block
241
+ *
242
+ * @return $this
243
  */
244
  protected function _addColumns($block)
245
  {
246
  $helper = Mage::helper('postnl');
247
+
248
  /**
249
  * Get an array of which optional columns should be shown
250
  */
251
  $columnsToDisplay = $this->getOptionalColumnsToDisplay();
252
+
253
  /**
254
  * This variable is the column ID of each column that the next column will follow.
255
  * By changing this variable after each column is added we guarantee the correct
268
  ),
269
  $after
270
  );
271
+
272
  $after = 'parcel_count';
273
  }
274
+
275
  if (in_array('shipping_description', $columnsToDisplay)) {
276
  $block->addColumnAfter(
277
  'shipping_description',
282
  ),
283
  $after
284
  );
285
+
286
  $after = 'shipping_description';
287
  }
288
+
289
  if (in_array('shipment_type', $columnsToDisplay)) {
290
  $block->addColumnAfter(
291
  'shipment_type',
307
  ),
308
  $after
309
  );
310
+
311
  $after = 'shipment_type';
312
  }
313
+
314
  if (in_array('confirm_date', $columnsToDisplay)) {
315
  $block->addColumnAfter(
316
  'confirm_date',
325
  ),
326
  $after
327
  );
328
+
329
  $after = 'confirm_date';
330
  }
331
+
332
  if (in_array('confirm_status', $columnsToDisplay)) {
333
  $postnlShipmentClass = Mage::app()->getConfig()->getModelClassName('postnl_core/shipment');
334
+
335
  $block->addColumnAfter(
336
  'confirm_status',
337
  array(
348
  ),
349
  $after
350
  );
351
+
352
  $after = 'confirm_status';
353
  }
354
+
355
  if (in_array('labels_printed', $columnsToDisplay)) {
356
  $block->addColumnAfter(
357
  'labels_printed',
368
  ),
369
  $after
370
  );
371
+
372
  $after = 'labels_printed';
373
  }
374
+
375
  if (in_array('barcode', $columnsToDisplay)) {
376
  $block->addColumnAfter(
377
  'barcode',
383
  ),
384
  $after
385
  );
386
+
387
  $after = 'barcode';
388
  }
389
+
390
  if (in_array('shipping_phase', $columnsToDisplay)) {
391
  $block->addColumnAfter(
392
  'shipping_phase',
401
  ),
402
  $after
403
  );
404
+
405
  $after = 'shipping_phase';
406
  }
407
+
408
  $actionColumn = $block->getColumn('action');
409
  $actions = $actionColumn->getActions();
410
+
411
  $actions[] = array(
412
  'caption' => $helper->__('Print label'),
413
  'url' => array('base' => 'postnl/adminhtml_shipment/printLabel'),
414
  'field' => 'shipment_id',
415
  'is_postnl' => true, //custom flag for renderer
416
  );
417
+
418
  $actions[] = array(
419
  'caption' => $helper->__('Confirm'),
420
  'url' => array('base' => 'postnl/adminhtml_shipment/confirm'),
421
  'field' => 'shipment_id',
422
  'is_postnl' => true, //custom flag for renderer
423
  );
424
+
425
  $actionColumn->setActions($actions)
426
  ->setWidth('150px')
427
  ->setData('renderer', 'postnl_adminhtml/widget_grid_column_renderer_action');
428
+
429
  $block->sortColumnsByOrder();
430
+
431
  return $this;
432
  }
433
 
434
  /**
435
  * Decorates the confirm_sate column
436
+ *
437
  * @param string | null $value
438
  * @param Mage_Sales_Model_Order_Shipment $row
439
  * @param Mage_Adminhtml_Block_Widget_Grid_Column $column
440
  * @param boolean $isExport
441
+ *
442
  * @return string
443
  */
444
  public function decorateConfirmDate($value, $row, $column, $isExport)
446
  if ($isExport) {
447
  return $value;
448
  }
449
+
450
  $origValue = $row->getData($column->getIndex());
451
+
452
  $postnlShipmentClass = Mage::getConfig()->getModelClassName('postnl_core/shipment');
453
+
454
  $class = '';
455
  if ($row->getData('confirm_status') == $postnlShipmentClass::CONFIRM_STATUS_CONFIRMED) {
456
  $class = 'grid-severity-notice';
457
  }
458
+
459
  if ($row->getData('confirm_status') == $postnlShipmentClass::CONFIRM_STATUS_CONFIRM_EXPIRED) {
460
  $class = 'grid-severity-critical';
461
  }
462
+
463
  if ($row->getData('confirm_status') == $postnlShipmentClass::CONFIRM_STATUS_UNCONFIRMED
464
  && date('Ymd', Mage::getModel('core/date')->gmtTimestamp()) == date('Ymd', strtotime($origValue))
465
  ) {
471
  } elseif ($row->getData('confirm_status') == $postnlShipmentClass::CONFIRM_STATUS_UNCONFIRMED) {
472
  $class = 'grid-severity-minor';
473
  }
474
+
475
  return '<span class="'.$class.'"><span>'.$value.'</span></span>';
476
  }
477
+
478
  /**
479
  * Decorates the confirm_status column
480
+ *
481
  * @param string | null $value
482
  * @param Mage_Sales_Model_Order_Shipment $row
483
  * @param Mage_Adminhtml_Block_Widget_Grid_Column $column
484
  * @param boolean $isExport
485
+ *
486
  * @return string
487
  */
488
  public function decorateConfirmStatus($value, $row, $column, $isExport)
490
  if ($isExport) {
491
  return $value;
492
  }
493
+
494
  $postnlShipmentClass = Mage::getConfig()->getModelClassName('postnl_core/shipment');
495
  switch ($row->getData($column->getIndex())) {
496
  case null: //rows with no value (non-PostNL shipments)
509
  }
510
  return '<span class="'.$class.'"><span>'.$value.'</span></span>';
511
  }
512
+
513
  /**
514
  * Decorates the labels_printed column
515
+ *
516
  * @param string | null $value
517
  * @param Mage_Sales_Model_Order_Shipment $row
518
  * @param Mage_Adminhtml_Block_Widget_Grid_Column $column
519
  * @param boolean $isExport
520
+ *
521
  * @return string
522
  */
523
  public function decorateLabelsPrinted($value, $row, $column, $isExport)
525
  if ($isExport) {
526
  return $value;
527
  }
528
+
529
  switch ($row->getData($column->getIndex())) {
530
  case null: //rows with no value (non-PostNL shipments)
531
  $class = '';
542
  }
543
  return '<span class="'.$class.'"><span>'.$value.'</span></span>';
544
  }
545
+
546
  /**
547
  * Decorates the shipping_phase column
548
+ *
549
  * @param string | null $value
550
  * @param Mage_Sales_Model_Order_Shipment $row
551
  * @param Mage_Adminhtml_Block_Widget_Grid_Column $column
552
  * @param boolean $isExport
553
+ *
554
  * @return string
555
  */
556
  public function decorateShippingPhase($value, $row, $column, $isExport)
558
  if ($isExport) {
559
  return $value;
560
  }
561
+
562
  $postnlShipmentClass = Mage::getConfig()->getModelClassName('postnl_core/shipment');
563
+
564
  $class = '';
565
  switch ($row->getData($column->getIndex())) {
566
  case null: //rows with no value (non-PostNL shipments) or unconfirmed shipments
586
 
587
  /**
588
  * Adds a massaction to confirm the order and print the shipping labels
589
+ *
590
  * @param Mage_Adminhtml_Block_Sales_Shipment_Grid $block
591
+ *
592
+ * @return $this
593
  */
594
  protected function _addMassaction($block)
595
  {
596
  $massactionBlock = $block->getMassactionBlock();
597
+
598
  /**
599
  * Build all the mass action option arrays
600
  */
602
  'label'=> Mage::helper('postnl')->__('PostNL - Print shipping labels & confirm shipment'),
603
  'url' => Mage::helper('adminhtml')->getUrl('postnl/adminhtml_shipment/massPrintLabelsAndConfirm'),
604
  );
605
+
606
  $printOptions = array(
607
  'label'=> Mage::helper('postnl')->__('PostNL - Print shipping labels'),
608
  'url' => Mage::helper('adminhtml')->getUrl('postnl/adminhtml_shipment/massPrintLabels'),
609
  );
610
+
611
  $confirmOptions = array(
612
  'label'=> Mage::helper('postnl')->__('PostNL - Confirm shipments'),
613
  'url' => Mage::helper('adminhtml')->getUrl('postnl/adminhtml_shipment/massConfirm'),
614
  );
615
+
616
  /**
617
  * Check which mass action should be selected by default
618
  */
619
  $defaultSelectedOption = Mage::getStoreConfig(
620
+ self::XML_PATH_SHIPPING_GRID_MASSACTION_DEFAULT,
621
  Mage_Core_Model_App::ADMIN_STORE_ID
622
  );
623
+
624
  /**
625
  * Add the additional 'selected' parameter to the chosen mass action
626
  */
636
  break;
637
  // no default
638
  }
639
+
640
  /**
641
  * Add the mass actions to the grid
642
  */
644
  'postnl_print_labels_and_confirm',
645
  $printAndConfirmOptions
646
  );
647
+
648
  $massactionBlock->addItem(
649
  'postnl_print_labels',
650
  $printOptions
651
  );
652
+
653
  $massactionBlock->addItem(
654
  'postnl_confirm_shipments',
655
  $confirmOptions
656
  );
657
+
658
  return $this;
659
  }
660
+
661
  /**
662
  * Applies sorting and filtering to the collection
663
+ *
664
  * @param TIG_PostNL_Model_Resource_Order_Shipment_Grid_Collection $collection
665
+ *
666
+ * @return $this
667
  */
668
  protected function _applySortAndFilter($collection)
669
  {
670
  $session = Mage::getSingleton('adminhtml/session');
671
+
672
  $filter = $session->getData(self::SHIPMENT_GRID_FILTER_VAR_NAME);
673
  $filter = Mage::helper('adminhtml')->prepareFilterString($filter);
674
+
675
  if ($filter) {
676
  $this->_filterCollection($collection, $filter);
677
  }
678
+
679
  $sort = $session->getData(self::SHIPMENT_GRID_SORT_VAR_NAME);
680
+
681
  if ($sort) {
682
  $dir = $session->getData(self::SHIPMENT_GRID_DIR_VAR_NAME);
683
+
684
  $this->_sortCollection($collection, $sort, $dir);
685
  }
686
+
687
  return $this;
688
  }
689
+
690
  /**
691
  * Adds new filters to the collection if these filters are based on columns added by this observer
692
+ *
693
  * @param TIG_PostNL_Model_Resource_Order_Shipment_Grid_Collection $collection
694
  * @param array $filter Array of filters to be added
695
+ *
696
+ * @return $this
697
  */
698
  protected function _filterCollection($collection, $filter)
699
  {
700
  $block = $this->getBlock();
701
+
702
  foreach ($filter as $columnName => $value) {
703
  $column = $block->getColumn($columnName);
704
  if (!$column) {
705
  continue;
706
  }
707
+
708
  $column->getFilter()->setValue($value);
709
  $this->_addColumnFilterToCollection($column);
710
  }
711
+
712
  return $this;
713
  }
714
+
715
  /**
716
  * Filters the collection by the 'shipment_type' column. Th column has 3 options: domestic, EPS and GlobalPack.
717
+ *
718
  * @param TIG_PostNL_Model_Resource_Order_Shipment_Grid_Collection $collection
719
  * @param Mage_Adminhtml_Block_Widget_Grid_Column $column
720
+ *
721
  * @return TIG_PostNL_Model_Adminhtml_Observer_OrderGrid
722
  */
723
  protected function _filterShipmentType($collection, $column)
724
  {
725
  $cond = $column->getFilter()->getCondition();
726
  $filterCond = $cond['eq'];
727
+
728
  /**
729
  * First filter out all non-postnl orders
730
  */
731
  $postnlShippingMethods = Mage::helper('postnl/carrier')->getPostnlShippingMethods();
732
  $collection->addFieldToFilter('order.shipping_method', array('in' => $postnlShippingMethods));
733
+
734
  /**
735
  * If the filter condition is PakjeGemak, filter out all non-PakjeGemak orders
736
  */
737
  if ($filterCond == 'pakje_gemak') {
738
  $collection->addFieldToFilter('postnl_shipment.is_pakje_gemak', array('eq' => 1));
739
+
740
  return $this;
741
  }
742
+
743
  /**
744
  * If the filter condition is NL, filter out all orders not being shipped to the Netherlands
745
  */
746
  if ($filterCond == 'nl') {
747
  $collection->addFieldToFilter('country_id', $cond);
748
+
749
  return $this;
750
  }
751
+
752
  /**
753
+ * If the filter condition is EU, filter out all orders not being shipped to the EU and those being shipped to
754
  * the Netherlands
755
  */
756
  $euCountries = Mage::helper('postnl/cif')->getEuCountries();
757
  if ($filterCond == 'eu') {
758
  $collection->addFieldToFilter('country_id', array('neq' => 'NL'));
759
  $collection->addFieldToFilter('country_id', array('in', $euCountries));
760
+
761
  return $this;
762
  }
763
+
764
  /**
765
  * Lastly, filter out all orders that are being shipped to the Netherlands or other EU countries
766
  */
767
  $collection->addFieldToFilter('country_id', array('neq' => 'NL'));
768
  $collection->addFieldToFilter('country_id', array('nin' => $euCountries));
769
+
770
  return $this;
771
  }
772
+
773
  /**
774
  * Based on Mage_Adminhtml_Block_Widget_Grid::_addColumnFilterToCollection()
775
+ *
776
  * Adds a filter condition to the collection for a specified column
777
+ *
778
  * @param Mage_Adminhtml_Block_Widget_Grid_Column $column
779
+ *
780
+ * @return $this
781
  */
782
  protected function _addColumnFilterToCollection($column)
783
  {
784
  if (!$this->getCollection()) {
785
  return $this;
786
  }
787
+
788
  if ($column->getFilterConditionCallback()) {
789
  call_user_func($column->getFilterConditionCallback(), $this->getCollection(), $column);
790
+
791
  return $this;
792
  }
793
+
794
+ $field = ($column->getFilterIndex()) ? $column->getFilterIndex() : $column->getIndex();
795
  $cond = $column->getFilter()->getCondition();
796
  if ($field && isset($cond)) {
797
  $this->getCollection()->addFieldToFilter($field , $cond);
798
  }
799
+
800
  return $this;
801
  }
802
+
803
  /**
804
  * Sorts the collection by a specified column in a specified direction
805
+ *
806
  * @param TIG_PostNL_Model_Resource_Order_Shipment_Grid_Collection $collection
807
  * @param string $sort The column that the collection is sorted by
808
  * @param string $dir The direction that is used to sort the collection
809
+ *
810
+ * @return $this
811
  */
812
  protected function _sortCollection($collection, $sort, $dir)
813
  {
816
  if (!$column) {
817
  return $this;
818
  }
819
+
820
  $column->setDir($dir);
821
  $this->_setCollectionOrder($column);
822
+
823
  return $this;
824
  }
825
+
826
  /**
827
  * Sets sorting order by some column
828
  *
829
  * @param Mage_Adminhtml_Block_Widget_Grid_Column $column
830
+ *
831
+ * @return $this
832
  */
833
  protected function _setCollectionOrder($column)
834
  {
836
  if (!$collection) {
837
  return $this;
838
  }
839
+
840
  $columnIndex = $column->getFilterIndex() ? $column->getFilterIndex() : $column->getIndex();
841
+
842
  $collection->setOrder($columnIndex, strtoupper($column->getDir()));
843
  return $this;
844
  }
app/code/community/TIG/PostNL/Model/Adminhtml/Observer/ShipmentView.php CHANGED
@@ -1,28 +1,28 @@
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@totalinternetgroup.nl so we can send you a copy immediately.
@@ -35,9 +35,7 @@
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
  * Observer to edit the shipment view
42
  */
43
  class TIG_PostNL_Model_Adminhtml_Observer_ShipmentView
@@ -46,108 +44,192 @@ class TIG_PostNL_Model_Adminhtml_Observer_ShipmentView
46
  * The block we want to edit
47
  */
48
  const SHIPMENT_VIEW_BLOCK_NAME = 'adminhtml/sales_order_shipment_view';
49
-
50
  /**
51
  * Observer that adds a print label button to the shipment view page
52
- *
53
  * @param Varien_Event_Observer $observer
54
- *
55
  * @return TIG_PostNL_Model_Adminhtml_Observer_ShipmentView
56
- *
57
  * @event adminhtml_block_html_before
58
- *
59
  * @observer postnl_adminhtml_shipmentview
60
  */
61
  public function addPrintLabelButton(Varien_Event_Observer $observer)
62
  {
 
 
63
  /**
64
  * check if the extension is active
65
  */
66
- if (!Mage::helper('postnl')->isEnabled()) {
67
  return $this;
68
  }
69
-
70
  /**
71
  * Checks if the current block is the one we want to edit.
72
- *
73
  * Unfortunately there is no unique event for this block
74
  */
75
  $block = $observer->getBlock();
76
  $shipmentViewClass = Mage::getConfig()->getBlockClassName(self::SHIPMENT_VIEW_BLOCK_NAME);
77
-
78
- if (get_class($block) !== $shipmentViewClass) {
 
 
 
79
  return $this;
80
  }
81
-
82
  /**
83
  * Check if the current shipment was placed with PostNL
84
  */
85
  $shipment = Mage::registry('current_shipment');
86
  $postnlShippingMethods = Mage::helper('postnl/carrier')->getPostnlShippingMethods();
87
- if (!in_array($shipment->getOrder()->getShippingMethod(), $postnlShippingMethods)) {
88
- return $this;
89
- }
90
-
91
  /**
92
  * Add a button to print this shipment's shipping labels
93
  */
94
  $printShippingLabelUrl = $this->getPrintShippingLabelUrl($shipment->getId());
95
  $block->addButton('print_shipping_label', array(
96
- 'label' => Mage::helper('postnl')->__('PostNL - Print Shipping Label'),
97
  'onclick' => "setLocation('{$printShippingLabelUrl}')",
98
  'class' => 'download',
99
  ));
100
-
 
 
 
101
  $postnlShipment = Mage::getModel('postnl_core/shipment')->load($shipment->getId(), 'shipment_id');
102
- if (!$postnlShipment->isConfirmed()) {
103
- return $this;
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
104
  }
105
-
106
  /**
107
  * Update the send tracking info button so that it sends our info, instead of the default
108
  */
109
- $resendTrackAndTraceUrl = $this->getResendTrackAndTraceUrl($shipment->getId());
110
- $block->updateButton('save', 'label', Mage::helper('postnl')->__('PostNL - Send Tracking Information'));
111
- $block->updateButton('save', 'onclick',
112
- "deleteConfirm('"
113
- . Mage::helper('sales')->__('Are you sure you want to send PostNL tracking information to the customer?')
114
- . "', '" . $resendTrackAndTraceUrl . "')"
115
- );
116
-
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
117
  return $this;
118
  }
119
-
120
  /**
121
  * Get adminhtml url for PostNL print shipping label action
122
- *
123
  * @param int $shipmentId The ID of the current shipment
124
- *
125
  * @return string
126
  */
127
  public function getPrintShippingLabelUrl($shipmentId)
128
  {
129
  $url = Mage::helper('adminhtml')->getUrl(
130
- 'postnl/adminhtml_shipment/printLabel',
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
131
  array('shipment_id' => $shipmentId)
132
  );
133
-
134
  return $url;
135
  }
136
-
137
  /**
138
  * Get adminhtml url for PostNL re-send track and trace action
139
- *
140
  * @param int $shipmentId The ID of the current shipment
141
- *
142
  * @return string
143
  */
144
  public function getResendTrackAndTraceUrl($shipmentId)
145
  {
146
  $url = Mage::helper('adminhtml')->getUrl(
147
- 'postnl/adminhtml_shipment/sendTrackAndTrace',
148
  array('shipment_id' => $shipmentId)
149
  );
150
-
151
  return $url;
152
  }
153
  }
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@totalinternetgroup.nl so we can send you a copy immediately.
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
  * Observer to edit the shipment view
40
  */
41
  class TIG_PostNL_Model_Adminhtml_Observer_ShipmentView
44
  * The block we want to edit
45
  */
46
  const SHIPMENT_VIEW_BLOCK_NAME = 'adminhtml/sales_order_shipment_view';
47
+
48
  /**
49
  * Observer that adds a print label button to the shipment view page
50
+ *
51
  * @param Varien_Event_Observer $observer
52
+ *
53
  * @return TIG_PostNL_Model_Adminhtml_Observer_ShipmentView
54
+ *
55
  * @event adminhtml_block_html_before
56
+ *
57
  * @observer postnl_adminhtml_shipmentview
58
  */
59
  public function addPrintLabelButton(Varien_Event_Observer $observer)
60
  {
61
+ $helper = Mage::helper('postnl');
62
+
63
  /**
64
  * check if the extension is active
65
  */
66
+ if (!$helper->isEnabled()) {
67
  return $this;
68
  }
69
+
70
  /**
71
  * Checks if the current block is the one we want to edit.
72
+ *
73
  * Unfortunately there is no unique event for this block
74
  */
75
  $block = $observer->getBlock();
76
  $shipmentViewClass = Mage::getConfig()->getBlockClassName(self::SHIPMENT_VIEW_BLOCK_NAME);
77
+
78
+ /**
79
+ * @var Mage_Adminhtml_BLock_Sales_Order_Shipment_View $block
80
+ */
81
+ if (!($block instanceof $shipmentViewClass)) {
82
  return $this;
83
  }
84
+
85
  /**
86
  * Check if the current shipment was placed with PostNL
87
  */
88
  $shipment = Mage::registry('current_shipment');
89
  $postnlShippingMethods = Mage::helper('postnl/carrier')->getPostnlShippingMethods();
90
+ if (!in_array($shipment->getOrder()->getShippingMethod(), $postnlShippingMethods)) {
91
+ return $this;
92
+ }
93
+
94
  /**
95
  * Add a button to print this shipment's shipping labels
96
  */
97
  $printShippingLabelUrl = $this->getPrintShippingLabelUrl($shipment->getId());
98
  $block->addButton('print_shipping_label', array(
99
+ 'label' => $helper->__('PostNL - Print Shipping Label'),
100
  'onclick' => "setLocation('{$printShippingLabelUrl}')",
101
  'class' => 'download',
102
  ));
103
+
104
+ /**
105
+ * @var TIG_PostNL_Model_Core_Shipment $postnlShipment
106
+ */
107
  $postnlShipment = Mage::getModel('postnl_core/shipment')->load($shipment->getId(), 'shipment_id');
108
+
109
+ /**
110
+ * Add a button to reset the shipment's confirmation status
111
+ */
112
+ if ($postnlShipment->canResetConfirmation()) {
113
+ $resetConfirmationUrl = $this->getResetConfirmationUrl($shipment->getId());
114
+ $resetWarningMessage = $helper->__(
115
+ 'Are you sure that you wish to reset the confirmation status of this shipment? You will need to '
116
+ . 'confirm this shipment with PostNL again before you can send it. This action will remove all barcodes'
117
+ . ' and labels associated with this shipment. You can not undo this action.'
118
+ );
119
+
120
+ $block->addButton('reset_confirmation', array(
121
+ 'label' => $helper->__('PostNL - Change Confirmation'),
122
+ 'onclick' => "deleteConfirm('"
123
+ . $resetWarningMessage
124
+ . "', '"
125
+ . $resetConfirmationUrl
126
+ . "')",
127
+ 'class' => 'delete',
128
+ ));
129
  }
130
+
131
  /**
132
  * Update the send tracking info button so that it sends our info, instead of the default
133
  */
134
+ if ($postnlShipment->isConfirmed()) {
135
+ $resendTrackAndTraceUrl = $this->getResendTrackAndTraceUrl($shipment->getId());
136
+ $block->updateButton('save', 'label', $helper->__('PostNL - Send Tracking Information'));
137
+ $block->updateButton('save', 'onclick',
138
+ "deleteConfirm('"
139
+ . $helper->__('Are you sure you want to send PostNL tracking information to the customer?')
140
+ . "', '" . $resendTrackAndTraceUrl . "')"
141
+ );
142
+ }
143
+
144
+ /**
145
+ * Add a button to remove any stored shipping labels for this shipment.
146
+ */
147
+ if ($postnlShipment->hasLabels() && !$postnlShipment->isConfirmed()) {
148
+ $removeLabelsUrl = $this->getRemoveLabelsUrl($shipment->getId());
149
+ $removeLabelsWarningMessage = $helper->__(
150
+ "Are you sure that you wish to remove this shipment\'s shipping label? You will need to print a new "
151
+ . "shipping label before you can send this shipment."
152
+ );
153
+
154
+ $block->addButton('remove_shipping_labels', array(
155
+ 'label' => $helper->__('PostNL - Remove Shipping Label'),
156
+ 'onclick' => "deleteConfirm('"
157
+ . $removeLabelsWarningMessage
158
+ . "', '"
159
+ . $removeLabelsUrl
160
+ . "')",
161
+ 'class' => 'delete',
162
+ ));
163
+ }
164
+
165
  return $this;
166
  }
167
+
168
  /**
169
  * Get adminhtml url for PostNL print shipping label action
170
+ *
171
  * @param int $shipmentId The ID of the current shipment
172
+ *
173
  * @return string
174
  */
175
  public function getPrintShippingLabelUrl($shipmentId)
176
  {
177
  $url = Mage::helper('adminhtml')->getUrl(
178
+ 'postnl/adminhtml_shipment/printLabel',
179
+ array('shipment_id' => $shipmentId)
180
+ );
181
+
182
+ return $url;
183
+ }
184
+
185
+ /**
186
+ * Get adminhtml url for PostNL reset confirmation action
187
+ *
188
+ * @param int $shipmentId The ID of the current shipment
189
+ *
190
+ * @return string
191
+ */
192
+ public function getResetConfirmationUrl($shipmentId)
193
+ {
194
+ $url = Mage::helper('adminhtml')->getUrl(
195
+ 'postnl/adminhtml_shipment/resetConfirmation',
196
+ array('shipment_id' => $shipmentId)
197
+ );
198
+
199
+ return $url;
200
+ }
201
+
202
+ /**
203
+ * Get adminhtml url for PostNL remove labels action
204
+ *
205
+ * @param int $shipmentId The ID of the current shipment
206
+ *
207
+ * @return string
208
+ */
209
+ public function getRemoveLabelsUrl($shipmentId)
210
+ {
211
+ $url = Mage::helper('adminhtml')->getUrl(
212
+ 'postnl/adminhtml_shipment/removeLabels',
213
  array('shipment_id' => $shipmentId)
214
  );
215
+
216
  return $url;
217
  }
218
+
219
  /**
220
  * Get adminhtml url for PostNL re-send track and trace action
221
+ *
222
  * @param int $shipmentId The ID of the current shipment
223
+ *
224
  * @return string
225
  */
226
  public function getResendTrackAndTraceUrl($shipmentId)
227
  {
228
  $url = Mage::helper('adminhtml')->getUrl(
229
+ 'postnl/adminhtml_shipment/sendTrackAndTrace',
230
  array('shipment_id' => $shipmentId)
231
  );
232
+
233
  return $url;
234
  }
235
  }
app/code/community/TIG/PostNL/Model/Carrier/Postnl.php CHANGED
@@ -1,28 +1,28 @@
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@totalinternetgroup.nl so we can send you a copy immediately.
@@ -36,10 +36,10 @@
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
  * PostNL shipping method model
42
- *
43
  * @todo check code for inconsistency and conventions. Copied from flat_rate method
44
  */
45
  class TIG_PostNL_Model_Carrier_Postnl
@@ -47,17 +47,17 @@ class TIG_PostNL_Model_Carrier_Postnl
47
  implements Mage_Shipping_Model_Carrier_Interface
48
  {
49
  const XML_PATH_RATE_TYPE = 'carriers/postnl/rate_type';
50
-
51
  /**
52
  * PostNL carrier code
53
- *
54
  * @var string
55
  */
56
  protected $_code = 'postnl';
57
-
58
  /**
59
  * Fixed price flag
60
- *
61
  * @var boolean
62
  */
63
  protected $_isFixed = true;
@@ -75,7 +75,7 @@ class TIG_PostNL_Model_Carrier_Postnl
75
 
76
  /**
77
  * get PostNL Carrier helper
78
- *
79
  * @return TIG_PostNL_Helper_Carrier
80
  */
81
  public function getHelper()
@@ -83,9 +83,9 @@ class TIG_PostNL_Model_Carrier_Postnl
83
  if ($this->getData('helper')) {
84
  return $this->getData('helper');
85
  }
86
-
87
  $helper = Mage::helper('postnl/carrier');
88
-
89
  $this->setHelper($helper);
90
  return $helper;
91
  }
@@ -99,12 +99,12 @@ class TIG_PostNL_Model_Carrier_Postnl
99
  {
100
  return true;
101
  }
102
-
103
  /**
104
  * Collect shipping rate
105
  *
106
  * @param Mage_Shipping_Model_Rate_Request $data
107
- *
108
  * @return Mage_Shipping_Model_Rate_Result|void
109
  */
110
  public function collectRates(Mage_Shipping_Model_Rate_Request $request)
@@ -112,7 +112,7 @@ class TIG_PostNL_Model_Carrier_Postnl
112
  if (!$this->getConfigFlag('active')) {
113
  return false;
114
  }
115
-
116
  /**
117
  * Several checks to see if shipping to the selected country is allowed based on the supported PostNL shipping products
118
  */
@@ -120,19 +120,19 @@ class TIG_PostNL_Model_Carrier_Postnl
120
  $helper = $this->getHelper();
121
  if ($countryId) {
122
  $euCountries = Mage::helper('postnl/cif')->getEuCountries();
123
-
124
  if ($countryId == 'NL'
125
  && !$helper->canUseStandard()
126
  ) {
127
  return false;
128
  }
129
-
130
  if (in_array($countryId, $euCountries)
131
  && !$helper->canUseEps()
132
  ) {
133
  return false;
134
  }
135
-
136
  if ($countryId != 'NL'
137
  && !in_array($countryId, $euCountries)
138
  && !$helper->canUseGlobalPack()
@@ -140,7 +140,7 @@ class TIG_PostNL_Model_Carrier_Postnl
140
  return false;
141
  }
142
  }
143
-
144
 
145
  $rateType = Mage::getStoreConfig(self::XML_PATH_RATE_TYPE, Mage::app()->getStore()->getId());
146
 
@@ -148,18 +148,18 @@ class TIG_PostNL_Model_Carrier_Postnl
148
  $result = $this->_getFlatRate($request);
149
  return $result;
150
  }
151
-
152
  if ($rateType == 'table') {
153
  $result = $this->_getTableRate($request);
154
  return $result;
155
  }
156
-
157
  throw new TIG_PostNL_Exception(
158
  $helper->__('Invalid rate type requested: %s', $rateType),
159
  'POSTNL-0036'
160
  );
161
  }
162
-
163
  protected function _getFlatRate($request)
164
  {
165
  $freeBoxes = 0;
@@ -266,10 +266,9 @@ class TIG_PostNL_Model_Carrier_Postnl
266
  if ($freePackageValue) {
267
  $request->setPackageValue($request->getPackageValue() - $freePackageValue);
268
  }
269
- if (!$request->getConditionName()) {
270
- $conditionName = $this->getConfigData('conditi on_name');
271
- $request->setConditionName($conditionName ? $conditionName : $this->_default_condition_name);
272
- }
273
 
274
  // Package weight and qty free shipping
275
  $oldWeight = $request->getPackageWeight();
@@ -375,27 +374,27 @@ class TIG_PostNL_Model_Carrier_Postnl
375
 
376
  return $codes[$type][$code];
377
  }
378
-
379
  /**
380
  * Get array of allowed methods
381
- *
382
  * @return array
383
  */
384
  public function getAllowedMethods()
385
  {
386
  return array(
387
- 'flatrate' => $this->getConfigData('name') . ' flat',
388
  'tablerate' => $this->getConfigData('name') . ' table'
389
  );
390
  }
391
 
392
  /**
393
  * Get tracking information
394
- *
395
  * @param string $tracking
396
- *
397
  * @return Mage_Shipping_Model_Tracking_Result_Status
398
- *
399
  * @todo check code and docblock
400
  */
401
  public function getTrackingInfo($tracking)
@@ -403,43 +402,43 @@ class TIG_PostNL_Model_Carrier_Postnl
403
  $statusModel = Mage::getModel('shipping/tracking_result_status');
404
  $track = $this->_getTrackByNumber($tracking);
405
  $shipment = $track->getShipment();
406
-
407
  $locale = Mage::getStoreConfig('general/locale/code', $shipment->getStoreId());
408
  $lang = substr($locale, 0, 2);
409
-
410
  $shippingAddress = $shipment->getShippingAddress();
411
-
412
  $statusModel->setCarrier($track->getCarrierCode())
413
  ->setCarrierTitle($this->getConfigData('name'))
414
  ->setTracking($track->getTrackNumber())
415
  ->setPopup(1)
416
  ->setUrl($this->getHelper()->getBarcodeUrl($track->getTrackNumber(), $shippingAddress, $lang, false));
417
-
418
  return $statusModel;
419
  }
420
-
421
  /**
422
  * Load track object by tracking number
423
- *
424
  * @param string $number
425
- *
426
  * @return Mage_Sales_Model_Order_Shipment_Track
427
- *
428
  * @todo check code and docblock
429
  */
430
  protected function _getTrackByNumber($number)
431
  {
432
  $coreResource = Mage::getSingleton('core/resource');
433
  $readConn = $coreResource->getConnection('core_read');
434
-
435
  $trackSelect = $readConn->select();
436
  $trackSelect->from($coreResource->getTableName('sales/shipment_track'), array('entity_id'));
437
  $trackSelect->where('track_number = ?', $number);
438
-
439
  $trackId = $readConn->fetchOne($trackSelect);
440
-
441
  $track = Mage::getModel('sales/order_shipment_track')->load($trackId);
442
-
443
  return $track;
444
  }
445
  }
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@totalinternetgroup.nl so we can send you a copy immediately.
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
  * PostNL shipping method model
42
+ *
43
  * @todo check code for inconsistency and conventions. Copied from flat_rate method
44
  */
45
  class TIG_PostNL_Model_Carrier_Postnl
47
  implements Mage_Shipping_Model_Carrier_Interface
48
  {
49
  const XML_PATH_RATE_TYPE = 'carriers/postnl/rate_type';
50
+
51
  /**
52
  * PostNL carrier code
53
+ *
54
  * @var string
55
  */
56
  protected $_code = 'postnl';
57
+
58
  /**
59
  * Fixed price flag
60
+ *
61
  * @var boolean
62
  */
63
  protected $_isFixed = true;
75
 
76
  /**
77
  * get PostNL Carrier helper
78
+ *
79
  * @return TIG_PostNL_Helper_Carrier
80
  */
81
  public function getHelper()
83
  if ($this->getData('helper')) {
84
  return $this->getData('helper');
85
  }
86
+
87
  $helper = Mage::helper('postnl/carrier');
88
+
89
  $this->setHelper($helper);
90
  return $helper;
91
  }
99
  {
100
  return true;
101
  }
102
+
103
  /**
104
  * Collect shipping rate
105
  *
106
  * @param Mage_Shipping_Model_Rate_Request $data
107
+ *
108
  * @return Mage_Shipping_Model_Rate_Result|void
109
  */
110
  public function collectRates(Mage_Shipping_Model_Rate_Request $request)
112
  if (!$this->getConfigFlag('active')) {
113
  return false;
114
  }
115
+
116
  /**
117
  * Several checks to see if shipping to the selected country is allowed based on the supported PostNL shipping products
118
  */
120
  $helper = $this->getHelper();
121
  if ($countryId) {
122
  $euCountries = Mage::helper('postnl/cif')->getEuCountries();
123
+
124
  if ($countryId == 'NL'
125
  && !$helper->canUseStandard()
126
  ) {
127
  return false;
128
  }
129
+
130
  if (in_array($countryId, $euCountries)
131
  && !$helper->canUseEps()
132
  ) {
133
  return false;
134
  }
135
+
136
  if ($countryId != 'NL'
137
  && !in_array($countryId, $euCountries)
138
  && !$helper->canUseGlobalPack()
140
  return false;
141
  }
142
  }
143
+
144
 
145
  $rateType = Mage::getStoreConfig(self::XML_PATH_RATE_TYPE, Mage::app()->getStore()->getId());
146
 
148
  $result = $this->_getFlatRate($request);
149
  return $result;
150
  }
151
+
152
  if ($rateType == 'table') {
153
  $result = $this->_getTableRate($request);
154
  return $result;
155
  }
156
+
157
  throw new TIG_PostNL_Exception(
158
  $helper->__('Invalid rate type requested: %s', $rateType),
159
  'POSTNL-0036'
160
  );
161
  }
162
+
163
  protected function _getFlatRate($request)
164
  {
165
  $freeBoxes = 0;
266
  if ($freePackageValue) {
267
  $request->setPackageValue($request->getPackageValue() - $freePackageValue);
268
  }
269
+
270
+ $conditionName = $this->getConfigData('condition_name');
271
+ $request->setConditionName($conditionName ? $conditionName : $this->_default_condition_name);
 
272
 
273
  // Package weight and qty free shipping
274
  $oldWeight = $request->getPackageWeight();
374
 
375
  return $codes[$type][$code];
376
  }
377
+
378
  /**
379
  * Get array of allowed methods
380
+ *
381
  * @return array
382
  */
383
  public function getAllowedMethods()
384
  {
385
  return array(
386
+ 'flatrate' => $this->getConfigData('name') . ' flat',
387
  'tablerate' => $this->getConfigData('name') . ' table'
388
  );
389
  }
390
 
391
  /**
392
  * Get tracking information
393
+ *
394
  * @param string $tracking
395
+ *
396
  * @return Mage_Shipping_Model_Tracking_Result_Status
397
+ *
398
  * @todo check code and docblock
399
  */
400
  public function getTrackingInfo($tracking)
402
  $statusModel = Mage::getModel('shipping/tracking_result_status');
403
  $track = $this->_getTrackByNumber($tracking);
404
  $shipment = $track->getShipment();
405
+
406
  $locale = Mage::getStoreConfig('general/locale/code', $shipment->getStoreId());
407
  $lang = substr($locale, 0, 2);
408
+
409
  $shippingAddress = $shipment->getShippingAddress();
410
+
411
  $statusModel->setCarrier($track->getCarrierCode())
412
  ->setCarrierTitle($this->getConfigData('name'))
413
  ->setTracking($track->getTrackNumber())
414
  ->setPopup(1)
415
  ->setUrl($this->getHelper()->getBarcodeUrl($track->getTrackNumber(), $shippingAddress, $lang, false));
416
+
417
  return $statusModel;
418
  }
419
+
420
  /**
421
  * Load track object by tracking number
422
+ *
423
  * @param string $number
424
+ *
425
  * @return Mage_Sales_Model_Order_Shipment_Track
426
+ *
427
  * @todo check code and docblock
428
  */
429
  protected function _getTrackByNumber($number)
430
  {
431
  $coreResource = Mage::getSingleton('core/resource');
432
  $readConn = $coreResource->getConnection('core_read');
433
+
434
  $trackSelect = $readConn->select();
435
  $trackSelect->from($coreResource->getTableName('sales/shipment_track'), array('entity_id'));
436
  $trackSelect->where('track_number = ?', $number);
437
+
438
  $trackId = $readConn->fetchOne($trackSelect);
439
+
440
  $track = Mage::getModel('sales/order_shipment_track')->load($trackId);
441
+
442
  return $track;
443
  }
444
  }
app/code/community/TIG/PostNL/Model/Core/Label.php CHANGED
@@ -1,28 +1,28 @@
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@totalinternetgroup.nl so we can send you a copy immediately.
@@ -42,79 +42,79 @@ class TIG_PostNL_Model_Core_Label extends Varien_Object
42
  * base name of temporary pdf files. An md5 hash will be prepended to this name in order to make each filename unique
43
  */
44
  const TEMP_LABEL_FILENAME = 'TIG_PostNL_temp.pdf';
45
-
46
  /**
47
  * XML path to label size setting
48
- *
49
  * This setting is ignored for GlobalPack labels and single Dutch or EPS labels
50
  */
51
  const XML_PATH_LABEL_SIZE = 'postnl/cif_labels_and_confirming/label_size';
52
-
53
  /**
54
  * An array of temporary files that have been created. these files will be destroyed at the end of the script.
55
- *
56
  * @var array
57
  */
58
  protected $_tempFilesSaved = array();
59
-
60
  /**
61
  * Counter to determine position of labels
62
- *
63
  * @var null | int
64
  */
65
  protected $_labelCounter = null;
66
-
67
  /**
68
  * Get the array of saved temporary labels
69
- *
70
  * @return array
71
  */
72
  public function getTempFilesSaved()
73
  {
74
  return $this->_tempFilesUsed;
75
  }
76
-
77
  /**
78
  * Set the array of saved temporary labels
79
- *
80
  * @param array $tempFilesUsed
81
- *
82
  * @return TIG_PostNL_Model_Core_Label
83
  */
84
  public function setTempFilesSaved($tempFilesUsed)
85
  {
86
  $this->_tempFilesUsed = $tempFilesUsed;
87
-
88
  return $this;
89
  }
90
-
91
  /**
92
  * Get the current label counter
93
- *
94
  * @return null | int
95
  */
96
  public function getLabelCounter()
97
  {
98
  return $this->_labelCounter;
99
  }
100
-
101
  /**
102
  * Set the current label counter
103
- *
104
  * @param int $counter
105
- *
106
  * @return TIG_PostNL_Model_Core_Label
107
  */
108
  public function setLabelCounter($counter)
109
  {
110
  $this->_labelCounter = $counter;
111
-
112
  return $this;
113
  }
114
-
115
  /**
116
  * get the configured label size
117
- *
118
  * @return string
119
  */
120
  public function getLabelSize()
@@ -122,77 +122,77 @@ class TIG_PostNL_Model_Core_Label extends Varien_Object
122
  if ($this->getData('label_size')) {
123
  return $this->getData('label_size');
124
  }
125
-
126
  $labelSize = Mage::getStoreConfig(self::XML_PATH_LABEL_SIZE, Mage_Core_Model_App::ADMIN_STORE_ID);
127
-
128
  $this->setLabelSeize($labelSize);
129
  return $labelSize;
130
  }
131
-
132
  /**
133
  * Reset the counter to 0
134
- *
135
  * @return TIG_PostNL_Model_Core_Label
136
  */
137
  public function resetLabelCounter()
138
  {
139
  $this->setLabelCounter(1);
140
-
141
  return $this;
142
  }
143
-
144
  /**
145
  * increase the label counter by a given amount
146
- *
147
  * @param int $increase
148
- *
149
  * @return TIG_PostNL_Model_Core_Label
150
  */
151
  public function increaseLabelCounter($increase = 1)
152
  {
153
  $counter = $this->getLabelCounter();
154
  $newCounter = $counter + $increase;
155
-
156
  $this->setLabelCounter($newCounter);
157
-
158
  return $this;
159
  }
160
-
161
  /**
162
  * Add a temporary pdf filename to the array so we can destroy it later
163
- *
164
  * @param string $tempFile
165
- *
166
  * @return TIG_PostNL_Model_Core_Label
167
  */
168
  public function addTempFileSaved($tempFile)
169
  {
170
  $tempFilesSaved = $this->getTempFilesSaved();
171
  $tempFilesSaved[] = $tempFile;
172
-
173
  $this->setTempFilesSaved($tempFilesSaved);
174
-
175
  return $this;
176
  }
177
-
178
  /**
179
  * Creates a pdf containing shipping labels using FPDF and FPDI libraries.
180
  * Four labels will be printed on each page in a vertical position. All labels will be rotated 90 degrees counter-clockwise
181
- *
182
  * @param mixed $labels May be an array of labels or a single label string
183
- *
184
  * @return TIG_PostNL_Model_Core_Label
185
- *
186
  * @see TIG_PostNL_Fpdf
187
  * @see TIG_PostNL_Fpdi
188
- *
189
  * @link http://www.fpdf.org/ Fpdf library documentation
190
  * @link http://www.setasign.de/products/pdf-php-solutions/fpdi/ Fpdi library
191
  */
192
  public function createPdf($labels)
193
  {
194
  Varien_Profiler::start('tig::postnl::core::label_createpdf');
195
-
196
  /**
197
  * Open a new pdf object and assign some basic values
198
  */
@@ -204,7 +204,7 @@ class TIG_PostNL_Model_Core_Label extends Varien_Object
204
  $pdf->SetTitle('PostNL Shipping Labels');
205
  $pdf->SetAuthor('PostNL');
206
  $pdf->SetCreator('PostNL');
207
-
208
  if (is_array($labels) && count($labels) > 1) {
209
  /**
210
  * Create a pdf containing multiple labels
@@ -218,42 +218,41 @@ class TIG_PostNL_Model_Core_Label extends Varien_Object
218
  if (is_array($labels)) {
219
  $labels = current($labels);
220
  }
221
-
222
  $this->setLabelSize('A6'); //single Dutch labels always use A6
223
  $pdf = $this->_addPdfTemplate($pdf, $labels);
224
  }
225
-
226
  /**
227
  * Destroy the temporary labels as they are no longer needed
228
  */
229
  $this->_destroyTempLabels();
230
-
231
  /**
232
  * Output the label as a download response
233
  */
234
  $pdf->Output('PostNL Shipping Labels.pdf', 'D');
235
-
236
  Varien_Profiler::stop('tig::postnl::core::label_createpdf');
237
-
238
  return $this;
239
  }
240
 
241
  /**
242
  * Adds multiple labels to the pdf
243
- *
244
  * @param TIG_PostNL_Fpdi $pdf
245
  * @param array $labels
246
- *
247
  * @return TIG_PostNL_Fpdi $pdf
248
- *
249
  * @throws TIG_PostNL_Exception
250
  */
251
  protected function _createMultiLabelPdf($pdf, $labels)
252
  {
253
  /**
254
  * Check if printing the required number of labels is allowed.
255
- *
256
- * This is limited to 200 by default to prevent out of memory errors.
257
  * On a clean Magento install with 256 MB of memory, several thousands of
258
  * labels can be printed at once. However, for safety reasons a limit
259
  * of 200 is used. By default you shouldn't be able to select more than 200
@@ -268,7 +267,7 @@ class TIG_PostNL_Model_Core_Label extends Varien_Object
268
  'POSTNL-0064'
269
  );
270
  }
271
-
272
  $labels = $this->_sortLabels($labels);
273
  foreach ($labels as $label) {
274
  $pdf = $this->_addPdfTemplate($pdf, $label);
@@ -276,14 +275,14 @@ class TIG_PostNL_Model_Core_Label extends Varien_Object
276
 
277
  return $pdf;
278
  }
279
-
280
  /**
281
  * Adds a lebl to the pdf by storing it in a temporary pdf file and then adding it to the master pdf object
282
- *
283
  * @param TIG_PostNL_Fpdi $pdf
284
  * @param string $label
285
  * @param int $labelCounter A counter used to determine the position of the next label to be added.
286
- *
287
  * @return TIG_PostNL_Fpdi $pdf
288
  */
289
  protected function _addPdfTemplate($pdf, $label)
@@ -292,7 +291,7 @@ class TIG_PostNL_Model_Core_Label extends Varien_Object
292
  * Fpdi requires labels to be provided as files. Therefore the label will be saved as a temporary file in var/TIG/PostNL/temp_labels/
293
  */
294
  $tempFilename = $this->_saveTempLabel($label->getLabel());
295
-
296
  switch ($label->getLabelType()) {
297
  case 'Label-combi':
298
  $this->_convertTempLabelToCombi($tempFilename); //NO BREAK
@@ -306,7 +305,7 @@ class TIG_PostNL_Model_Core_Label extends Varien_Object
306
  $pdf->addOrientedPage('L', 'A4');
307
  $this->resetLabelCounter();
308
  }
309
-
310
  /**
311
  * If the configured label size is A6, add a new page every label
312
  */
@@ -314,17 +313,17 @@ class TIG_PostNL_Model_Core_Label extends Varien_Object
314
  $this->setLabelCounter(3); //used to calculate the top left position
315
  $pdf->addOrientedPage('L', 'A6');
316
  }
317
-
318
  /**
319
  * Calculate the position of the next label to be printed
320
  */
321
  $position = $this->_getPosition($this->getLabelCounter());
322
  $position['w'] = $this->pix2pt(538);
323
-
324
  $this->increaseLabelCounter();
325
  break;
326
-
327
-
328
  /**
329
  * If the configured label size is A4, add a new page every 4 labels and reset the counter
330
  */
@@ -334,7 +333,7 @@ class TIG_PostNL_Model_Core_Label extends Varien_Object
334
  $pdf->addOrientedPage('L', 'A4');
335
  $this->resetLabelCounter();
336
  }
337
-
338
  /**
339
  * If the configured label size is A6, add a new page every label
340
  */
@@ -342,13 +341,13 @@ class TIG_PostNL_Model_Core_Label extends Varien_Object
342
  $this->setLabelCounter(3); //used to calculate the top left position
343
  $pdf->addOrientedPage('L', 'A6');
344
  }
345
-
346
  /**
347
  * Calculate the position of the next label to be printed
348
  */
349
  $position = $this->_getPosition($this->getLabelCounter());
350
  $position['w'] = $this->pix2pt(538);
351
-
352
  $this->increaseLabelCounter();
353
  break;
354
  case 'CN23':
@@ -357,16 +356,16 @@ class TIG_PostNL_Model_Core_Label extends Varien_Object
357
  * International shipping labels are larger and need to be printed on seperate pages
358
  */
359
  $pdf->addOrientedPage('P', 'A4');
360
-
361
  /**
362
  * Calculate the position of the next label to be printed
363
  */
364
  $position = array(
365
- 'x' => $this->pix2pt(15),
366
- 'y' => $this->pix2pt(17),
367
  'w' => $this->pix2pt(776)
368
  );
369
-
370
  /**
371
  * increase the label counter to above 4. This will prompt the creation of a new page
372
  */
@@ -377,11 +376,11 @@ class TIG_PostNL_Model_Core_Label extends Varien_Object
377
  * Calculate the position of the next label to be printed
378
  */
379
  $position = array(
380
- 'x' => $this->pix2pt(15),
381
- 'y' => $this->pix2pt(578),
382
  'w' => $this->pix2pt(776)
383
  );
384
-
385
  /**
386
  * increase the label counter to above 4. This will prompt the creation of a new page
387
  */
@@ -392,16 +391,16 @@ class TIG_PostNL_Model_Core_Label extends Varien_Object
392
  * COD cards are larger and need to be printed on seperate pages
393
  */
394
  $pdf->addOrientedPage('P', 'A4');
395
-
396
  /**
397
  * Calculate the position of the next label to be printed
398
  */
399
  $position = array(
400
- 'x' => $this->pix2pt(15),
401
- 'y' => $this->pix2pt(17),
402
  'w' => $this->pix2pt(776)
403
  );
404
-
405
  /**
406
  * increase the label counter to above 4. This will prompt the creation of a new page
407
  */
@@ -418,15 +417,15 @@ class TIG_PostNL_Model_Core_Label extends Varien_Object
418
  * Add the next label to the pdf
419
  */
420
  $pdf->insertTemplate($tempFilename, $position['x'], $position['y'], $position['w']);
421
-
422
  return $pdf;
423
  }
424
-
425
  /**
426
  * Save a label to a temporary pdf file. Temporary pdf files are stored in var/TIG/PostNL/temp_label/
427
- *
428
  * @param string $label
429
- *
430
  * @return string
431
  */
432
  protected function _saveTempLabel($label)
@@ -441,30 +440,30 @@ class TIG_PostNL_Model_Core_Label extends Varien_Object
441
  . time()
442
  . '-'
443
  . self::TEMP_LABEL_FILENAME;
444
-
445
  if (file_exists($tempFilePath)) {
446
  throw new TIG_PostNL_Exception(
447
  Mage::helper('postnl')->__('Temporary template file already exists: %s', $tempFilePath),
448
  'POSTNL-0066'
449
  );
450
  }
451
-
452
  /**
453
  * Add the base64 decoded label to the file
454
  */
455
  file_put_contents($tempFilePath, base64_decode($label));
456
-
457
  /**
458
  * Save the name of the temp file so itcan be destroyed later
459
  */
460
  $this->addTempFileSaved($tempFilePath);
461
-
462
  return $tempFilePath;
463
  }
464
-
465
  /**
466
  * Destroy all temporary pdf files
467
- *
468
  * @return TIG_PostNL_Model_Core_Label
469
  */
470
  protected function _destroyTempLabels()
@@ -473,18 +472,18 @@ class TIG_PostNL_Model_Core_Label extends Varien_Object
473
  foreach ($tempFilesSaved as $tempFile) {
474
  unlink($tempFile);
475
  }
476
-
477
  return $this;
478
  }
479
-
480
  /**
481
- * Sorts labels by label type. First all labels of the 'Label' type. Then all other labels in the
482
  * order of 'CN23' > 'CP71' > 'CommercialInvoice' grouped by shipments
483
- *
484
  * @param array $labels
485
- *
486
  * @return array
487
- *
488
  * @todo expand with cod labels
489
  */
490
  protected function _sortLabels($labels)
@@ -500,7 +499,7 @@ class TIG_PostNL_Model_Core_Label extends Varien_Object
500
  $generalLabels[] = $label;
501
  continue;
502
  }
503
-
504
  /**
505
  * Seperate COD cards
506
  */
@@ -508,7 +507,7 @@ class TIG_PostNL_Model_Core_Label extends Varien_Object
508
  $codCards[] = $label;
509
  continue;
510
  }
511
-
512
  /**
513
  * Group other labels by shipment id (parent_id attribute)
514
  */
@@ -518,7 +517,7 @@ class TIG_PostNL_Model_Core_Label extends Varien_Object
518
  $globalLabels[$label->getParentId()] = array($label->getlabelType() => $label);
519
  }
520
  }
521
-
522
  /**
523
  * Sort all non-standard labels
524
  */
@@ -527,63 +526,63 @@ class TIG_PostNL_Model_Core_Label extends Varien_Object
527
  if (isset($shipmentLabels['CN23'])) {
528
  $sortedGlobalLabels[] = $shipmentLabels['CN23'];
529
  }
530
-
531
  if (isset($shipmentLabels['CP71'])) {
532
  $sortedGlobalLabels[] = $shipmentLabels['CP71'];
533
  }
534
-
535
  if (isset($shipmentLabels['CommercialInvoice'])) {
536
  $sortedGlobalLabels[] = $shipmentLabels['CommercialInvoice'];
537
  }
538
  }
539
-
540
  /**
541
  * merge all labels back into a single array
542
  */
543
  $labels = array_merge($generalLabels, $sortedGlobalLabels, $codCards);
544
  return $labels;
545
  }
546
-
547
  /**
548
  * Convert a regular label to a rotated combi-label
549
- *
550
  * @param string $tempFilename The location of the regular temp label
551
- *
552
  * @return TIG_PostNL_Model_Core_Label
553
  */
554
- protected function _convertTempLabelToCombi($tempFilename)
555
  {
556
  /**
557
  * Calculate the position of the next label to be printed
558
  */
559
  $position = array(
560
- 'x' => $this->pix2pt(0),
561
- 'y' => $this->pix2pt(-483),
562
  'w' => $this->pix2pt(400)
563
  );
564
-
565
  /**
566
  * Create a new temporary FPDI object
567
  */
568
  $tempPdf = new TIG_PostNL_Fpdi(); //lib/TIG/PostNL/Fpdi
569
  $tempPdf->open();
570
  $tempPdf->addOrientedPage('L', 'A6');
571
-
572
  /**
573
  * Rotate the pdf, add the template and rotate it back
574
  */
575
  $tempPdf->Rotate('-90');
576
  $tempPdf->insertTemplate($tempFilename, $position['x'], $position['y'], $position['w']);
577
  $tempPdf->Rotate('0');
578
-
579
  /**
580
  * Overwrite the default temp file with the new one
581
  */
582
  $tempPdf->Output($tempFilename, 'F');
583
-
584
  return $this;
585
  }
586
-
587
  /**
588
  * Calculates the position of the requested label using a counter system.
589
  * The labels will be positioned accordingly:
@@ -591,33 +590,33 @@ class TIG_PostNL_Model_Core_Label extends Varien_Object
591
  * second: top right
592
  * third: bottom left
593
  * fourth: bottom right
594
- *
595
  * @param int $counter
596
- *
597
  * @return array
598
- *
599
  * @throws TIG_PostNL_Exception
600
  */
601
  protected function _getPosition($counter = false)
602
  {
603
  if ($counter === false) {
604
  $position = array('x' => 0, 'y' => 0);
605
-
606
  return $position;
607
  }
608
-
609
  switch($counter) {
610
- case 1:
611
- $position = array('x' => $this->pix2pt(579), 'y' => $this->pix2pt(15));
612
  break;
613
- case 2:
614
- $position = array('x' => $this->pix2pt(579), 'y' => $this->pix2pt(414));
615
  break;
616
- case 3:
617
- $position = array('x' => $this->pix2pt(15), 'y' => $this->pix2pt(15));
618
  break;
619
- case 4:
620
- $position = array('x' => $this->pix2pt(15), 'y' => $this->pix2pt(414));
621
  break;
622
  default:
623
  throw new TIG_PostNL_Exception(
@@ -625,15 +624,15 @@ class TIG_PostNL_Model_Core_Label extends Varien_Object
625
  'POSTNL-0067'
626
  );
627
  }
628
-
629
  return $position;
630
  }
631
-
632
  /**
633
  * Converts pixels to points. 3.8 pixels is 1 pt in pdfs
634
- *
635
  * @param float $input
636
- *
637
  * @return int
638
  */
639
  public function pix2pt($pixels = 0)
@@ -642,7 +641,7 @@ class TIG_PostNL_Model_Core_Label extends Varien_Object
642
  $points = round($pixels / 3.8, 1);
643
  return $points;
644
  }
645
-
646
  return 0;
647
  }
648
  }
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@totalinternetgroup.nl so we can send you a copy immediately.
42
  * base name of temporary pdf files. An md5 hash will be prepended to this name in order to make each filename unique
43
  */
44
  const TEMP_LABEL_FILENAME = 'TIG_PostNL_temp.pdf';
45
+
46
  /**
47
  * XML path to label size setting
48
+ *
49
  * This setting is ignored for GlobalPack labels and single Dutch or EPS labels
50
  */
51
  const XML_PATH_LABEL_SIZE = 'postnl/cif_labels_and_confirming/label_size';
52
+
53
  /**
54
  * An array of temporary files that have been created. these files will be destroyed at the end of the script.
55
+ *
56
  * @var array
57
  */
58
  protected $_tempFilesSaved = array();
59
+
60
  /**
61
  * Counter to determine position of labels
62
+ *
63
  * @var null | int
64
  */
65
  protected $_labelCounter = null;
66
+
67
  /**
68
  * Get the array of saved temporary labels
69
+ *
70
  * @return array
71
  */
72
  public function getTempFilesSaved()
73
  {
74
  return $this->_tempFilesUsed;
75
  }
76
+
77
  /**
78
  * Set the array of saved temporary labels
79
+ *
80
  * @param array $tempFilesUsed
81
+ *
82
  * @return TIG_PostNL_Model_Core_Label
83
  */
84
  public function setTempFilesSaved($tempFilesUsed)
85
  {
86
  $this->_tempFilesUsed = $tempFilesUsed;
87
+
88
  return $this;
89
  }
90
+
91
  /**
92
  * Get the current label counter
93
+ *
94
  * @return null | int
95
  */
96
  public function getLabelCounter()
97
  {
98
  return $this->_labelCounter;
99
  }
100
+
101
  /**
102
  * Set the current label counter
103
+ *
104
  * @param int $counter
105
+ *
106
  * @return TIG_PostNL_Model_Core_Label
107
  */
108
  public function setLabelCounter($counter)
109
  {
110
  $this->_labelCounter = $counter;
111
+
112
  return $this;
113
  }
114
+
115
  /**
116
  * get the configured label size
117
+ *
118
  * @return string
119
  */
120
  public function getLabelSize()
122
  if ($this->getData('label_size')) {
123
  return $this->getData('label_size');
124
  }
125
+
126
  $labelSize = Mage::getStoreConfig(self::XML_PATH_LABEL_SIZE, Mage_Core_Model_App::ADMIN_STORE_ID);
127
+
128
  $this->setLabelSeize($labelSize);
129
  return $labelSize;
130
  }
131
+
132
  /**
133
  * Reset the counter to 0
134
+ *
135
  * @return TIG_PostNL_Model_Core_Label
136
  */
137
  public function resetLabelCounter()
138
  {
139
  $this->setLabelCounter(1);
140
+
141
  return $this;
142
  }
143
+
144
  /**
145
  * increase the label counter by a given amount
146
+ *
147
  * @param int $increase
148
+ *
149
  * @return TIG_PostNL_Model_Core_Label
150
  */
151
  public function increaseLabelCounter($increase = 1)
152
  {
153
  $counter = $this->getLabelCounter();
154
  $newCounter = $counter + $increase;
155
+
156
  $this->setLabelCounter($newCounter);
157
+
158
  return $this;
159
  }
160
+
161
  /**
162
  * Add a temporary pdf filename to the array so we can destroy it later
163
+ *
164
  * @param string $tempFile
165
+ *
166
  * @return TIG_PostNL_Model_Core_Label
167
  */
168
  public function addTempFileSaved($tempFile)
169
  {
170
  $tempFilesSaved = $this->getTempFilesSaved();
171
  $tempFilesSaved[] = $tempFile;
172
+
173
  $this->setTempFilesSaved($tempFilesSaved);
174
+
175
  return $this;
176
  }
177
+
178
  /**
179
  * Creates a pdf containing shipping labels using FPDF and FPDI libraries.
180
  * Four labels will be printed on each page in a vertical position. All labels will be rotated 90 degrees counter-clockwise
181
+ *
182
  * @param mixed $labels May be an array of labels or a single label string
183
+ *
184
  * @return TIG_PostNL_Model_Core_Label
185
+ *
186
  * @see TIG_PostNL_Fpdf
187
  * @see TIG_PostNL_Fpdi
188
+ *
189
  * @link http://www.fpdf.org/ Fpdf library documentation
190
  * @link http://www.setasign.de/products/pdf-php-solutions/fpdi/ Fpdi library
191
  */
192
  public function createPdf($labels)
193
  {
194
  Varien_Profiler::start('tig::postnl::core::label_createpdf');
195
+
196
  /**
197
  * Open a new pdf object and assign some basic values
198
  */
204
  $pdf->SetTitle('PostNL Shipping Labels');
205
  $pdf->SetAuthor('PostNL');
206
  $pdf->SetCreator('PostNL');
207
+
208
  if (is_array($labels) && count($labels) > 1) {
209
  /**
210
  * Create a pdf containing multiple labels
218
  if (is_array($labels)) {
219
  $labels = current($labels);
220
  }
221
+
222
  $this->setLabelSize('A6'); //single Dutch labels always use A6
223
  $pdf = $this->_addPdfTemplate($pdf, $labels);
224
  }
225
+
226
  /**
227
  * Destroy the temporary labels as they are no longer needed
228
  */
229
  $this->_destroyTempLabels();
230
+
231
  /**
232
  * Output the label as a download response
233
  */
234
  $pdf->Output('PostNL Shipping Labels.pdf', 'D');
235
+
236
  Varien_Profiler::stop('tig::postnl::core::label_createpdf');
 
237
  return $this;
238
  }
239
 
240
  /**
241
  * Adds multiple labels to the pdf
242
+ *
243
  * @param TIG_PostNL_Fpdi $pdf
244
  * @param array $labels
245
+ *
246
  * @return TIG_PostNL_Fpdi $pdf
247
+ *
248
  * @throws TIG_PostNL_Exception
249
  */
250
  protected function _createMultiLabelPdf($pdf, $labels)
251
  {
252
  /**
253
  * Check if printing the required number of labels is allowed.
254
+ *
255
+ * This is limited to 200 by default to prevent out of memory errors.
256
  * On a clean Magento install with 256 MB of memory, several thousands of
257
  * labels can be printed at once. However, for safety reasons a limit
258
  * of 200 is used. By default you shouldn't be able to select more than 200
267
  'POSTNL-0064'
268
  );
269
  }
270
+
271
  $labels = $this->_sortLabels($labels);
272
  foreach ($labels as $label) {
273
  $pdf = $this->_addPdfTemplate($pdf, $label);
275
 
276
  return $pdf;
277
  }
278
+
279
  /**
280
  * Adds a lebl to the pdf by storing it in a temporary pdf file and then adding it to the master pdf object
281
+ *
282
  * @param TIG_PostNL_Fpdi $pdf
283
  * @param string $label
284
  * @param int $labelCounter A counter used to determine the position of the next label to be added.
285
+ *
286
  * @return TIG_PostNL_Fpdi $pdf
287
  */
288
  protected function _addPdfTemplate($pdf, $label)
291
  * Fpdi requires labels to be provided as files. Therefore the label will be saved as a temporary file in var/TIG/PostNL/temp_labels/
292
  */
293
  $tempFilename = $this->_saveTempLabel($label->getLabel());
294
+
295
  switch ($label->getLabelType()) {
296
  case 'Label-combi':
297
  $this->_convertTempLabelToCombi($tempFilename); //NO BREAK
305
  $pdf->addOrientedPage('L', 'A4');
306
  $this->resetLabelCounter();
307
  }
308
+
309
  /**
310
  * If the configured label size is A6, add a new page every label
311
  */
313
  $this->setLabelCounter(3); //used to calculate the top left position
314
  $pdf->addOrientedPage('L', 'A6');
315
  }
316
+
317
  /**
318
  * Calculate the position of the next label to be printed
319
  */
320
  $position = $this->_getPosition($this->getLabelCounter());
321
  $position['w'] = $this->pix2pt(538);
322
+
323
  $this->increaseLabelCounter();
324
  break;
325
+
326
+
327
  /**
328
  * If the configured label size is A4, add a new page every 4 labels and reset the counter
329
  */
333
  $pdf->addOrientedPage('L', 'A4');
334
  $this->resetLabelCounter();
335
  }
336
+
337
  /**
338
  * If the configured label size is A6, add a new page every label
339
  */
341
  $this->setLabelCounter(3); //used to calculate the top left position
342
  $pdf->addOrientedPage('L', 'A6');
343
  }
344
+
345
  /**
346
  * Calculate the position of the next label to be printed
347
  */
348
  $position = $this->_getPosition($this->getLabelCounter());
349
  $position['w'] = $this->pix2pt(538);
350
+
351
  $this->increaseLabelCounter();
352
  break;
353
  case 'CN23':
356
  * International shipping labels are larger and need to be printed on seperate pages
357
  */
358
  $pdf->addOrientedPage('P', 'A4');
359
+
360
  /**
361
  * Calculate the position of the next label to be printed
362
  */
363
  $position = array(
364
+ 'x' => $this->pix2pt(15),
365
+ 'y' => $this->pix2pt(17),
366
  'w' => $this->pix2pt(776)
367
  );
368
+
369
  /**
370
  * increase the label counter to above 4. This will prompt the creation of a new page
371
  */
376
  * Calculate the position of the next label to be printed
377
  */
378
  $position = array(
379
+ 'x' => $this->pix2pt(15),
380
+ 'y' => $this->pix2pt(578),
381
  'w' => $this->pix2pt(776)
382
  );
383
+
384
  /**
385
  * increase the label counter to above 4. This will prompt the creation of a new page
386
  */
391
  * COD cards are larger and need to be printed on seperate pages
392
  */
393
  $pdf->addOrientedPage('P', 'A4');
394
+
395
  /**
396
  * Calculate the position of the next label to be printed
397
  */
398
  $position = array(
399
+ 'x' => $this->pix2pt(15),
400
+ 'y' => $this->pix2pt(17),
401
  'w' => $this->pix2pt(776)
402
  );
403
+
404
  /**
405
  * increase the label counter to above 4. This will prompt the creation of a new page
406
  */
417
  * Add the next label to the pdf
418
  */
419
  $pdf->insertTemplate($tempFilename, $position['x'], $position['y'], $position['w']);
420
+
421
  return $pdf;
422
  }
423
+
424
  /**
425
  * Save a label to a temporary pdf file. Temporary pdf files are stored in var/TIG/PostNL/temp_label/
426
+ *
427
  * @param string $label
428
+ *
429
  * @return string
430
  */
431
  protected function _saveTempLabel($label)
440
  . time()
441
  . '-'
442
  . self::TEMP_LABEL_FILENAME;
443
+
444
  if (file_exists($tempFilePath)) {
445
  throw new TIG_PostNL_Exception(
446
  Mage::helper('postnl')->__('Temporary template file already exists: %s', $tempFilePath),
447
  'POSTNL-0066'
448
  );
449
  }
450
+
451
  /**
452
  * Add the base64 decoded label to the file
453
  */
454
  file_put_contents($tempFilePath, base64_decode($label));
455
+
456
  /**
457
  * Save the name of the temp file so itcan be destroyed later
458
  */
459
  $this->addTempFileSaved($tempFilePath);
460
+
461
  return $tempFilePath;
462
  }
463
+
464
  /**
465
  * Destroy all temporary pdf files
466
+ *
467
  * @return TIG_PostNL_Model_Core_Label
468
  */
469
  protected function _destroyTempLabels()
472
  foreach ($tempFilesSaved as $tempFile) {
473
  unlink($tempFile);
474
  }
475
+
476
  return $this;
477
  }
478
+
479
  /**
480
+ * Sorts labels by label type. First all labels of the 'Label' type. Then all other labels in the
481
  * order of 'CN23' > 'CP71' > 'CommercialInvoice' grouped by shipments
482
+ *
483
  * @param array $labels
484
+ *
485
  * @return array
486
+ *
487
  * @todo expand with cod labels
488
  */
489
  protected function _sortLabels($labels)
499
  $generalLabels[] = $label;
500
  continue;
501
  }
502
+
503
  /**
504
  * Seperate COD cards
505
  */
507
  $codCards[] = $label;
508
  continue;
509
  }
510
+
511
  /**
512
  * Group other labels by shipment id (parent_id attribute)
513
  */
517
  $globalLabels[$label->getParentId()] = array($label->getlabelType() => $label);
518
  }
519
  }
520
+
521
  /**
522
  * Sort all non-standard labels
523
  */
526
  if (isset($shipmentLabels['CN23'])) {
527
  $sortedGlobalLabels[] = $shipmentLabels['CN23'];
528
  }
529
+
530
  if (isset($shipmentLabels['CP71'])) {
531
  $sortedGlobalLabels[] = $shipmentLabels['CP71'];
532
  }
533
+
534
  if (isset($shipmentLabels['CommercialInvoice'])) {
535
  $sortedGlobalLabels[] = $shipmentLabels['CommercialInvoice'];
536
  }
537
  }
538
+
539
  /**
540
  * merge all labels back into a single array
541
  */
542
  $labels = array_merge($generalLabels, $sortedGlobalLabels, $codCards);
543
  return $labels;
544
  }
545
+
546
  /**
547
  * Convert a regular label to a rotated combi-label
548
+ *
549
  * @param string $tempFilename The location of the regular temp label
550
+ *
551
  * @return TIG_PostNL_Model_Core_Label
552
  */
553
+ protected function _convertTempLabelToCombi($tempFilename)
554
  {
555
  /**
556
  * Calculate the position of the next label to be printed
557
  */
558
  $position = array(
559
+ 'x' => $this->pix2pt(0),
560
+ 'y' => $this->pix2pt(-483),
561
  'w' => $this->pix2pt(400)
562
  );
563
+
564
  /**
565
  * Create a new temporary FPDI object
566
  */
567
  $tempPdf = new TIG_PostNL_Fpdi(); //lib/TIG/PostNL/Fpdi
568
  $tempPdf->open();
569
  $tempPdf->addOrientedPage('L', 'A6');
570
+
571
  /**
572
  * Rotate the pdf, add the template and rotate it back
573
  */
574
  $tempPdf->Rotate('-90');
575
  $tempPdf->insertTemplate($tempFilename, $position['x'], $position['y'], $position['w']);
576
  $tempPdf->Rotate('0');
577
+
578
  /**
579
  * Overwrite the default temp file with the new one
580
  */
581
  $tempPdf->Output($tempFilename, 'F');
582
+
583
  return $this;
584
  }
585
+
586
  /**
587
  * Calculates the position of the requested label using a counter system.
588
  * The labels will be positioned accordingly:
590
  * second: top right
591
  * third: bottom left
592
  * fourth: bottom right
593
+ *
594
  * @param int $counter
595
+ *
596
  * @return array
597
+ *
598
  * @throws TIG_PostNL_Exception
599
  */
600
  protected function _getPosition($counter = false)
601
  {
602
  if ($counter === false) {
603
  $position = array('x' => 0, 'y' => 0);
604
+
605
  return $position;
606
  }
607
+
608
  switch($counter) {
609
+ case 1:
610
+ $position = array('x' => $this->pix2pt(579), 'y' => $this->pix2pt(15));
611
  break;
612
+ case 2:
613
+ $position = array('x' => $this->pix2pt(579), 'y' => $this->pix2pt(414));
614
  break;
615
+ case 3:
616
+ $position = array('x' => $this->pix2pt(15), 'y' => $this->pix2pt(15));
617
  break;
618
+ case 4:
619
+ $position = array('x' => $this->pix2pt(15), 'y' => $this->pix2pt(414));
620
  break;
621
  default:
622
  throw new TIG_PostNL_Exception(
624
  'POSTNL-0067'
625
  );
626
  }
627
+
628
  return $position;
629
  }
630
+
631
  /**
632
  * Converts pixels to points. 3.8 pixels is 1 pt in pdfs
633
+ *
634
  * @param float $input
635
+ *
636
  * @return int
637
  */
638
  public function pix2pt($pixels = 0)
641
  $points = round($pixels / 3.8, 1);
642
  return $points;
643
  }
644
+
645
  return 0;
646
  }
647
  }
app/code/community/TIG/PostNL/Model/Core/Observer/Cron.php CHANGED
@@ -1,28 +1,28 @@
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@totalinternetgroup.nl so we can send you a copy immediately.
@@ -42,45 +42,45 @@ class TIG_PostNL_Model_Core_Observer_Cron
42
  * Xml path to maximum file storage setting in system/config
43
  */
44
  const XML_PATH_MAX_FILE_STORAGE = 'postnl/advanced/max_temp_file_storage_time';
45
-
46
  /**
47
  * XML path to confirmation expire time setting
48
  */
49
  const XML_PATH_CONFIRM_EXPIRE_DAYS = 'postnl/advanced/confirm_expire_days';
50
-
51
  /**
52
  * XML path to setting that determines whether or not to send track and trace emails
53
  */
54
  const XML_PATH_SEND_TRACK_AND_TRACE_EMAIL = 'postnl/cif_labels_and_confirming/send_track_and_trace_email';
55
-
56
  /**
57
  * Method to destroy temporary label files that have been stored for too long.
58
- *
59
  * By default the PostNL module creates temporary label files in order to merge them into
60
  * a single shipping label. These files are then destroyed. However, sometimes these files
61
  * may survive the script if the script has encountered an error. This method will make
62
  * sure these files will not survive indefinitiely, which may lead to the file system
63
  * being overburdoned or the server running out of harddrive space.
64
- *
65
  * @return TIG_PostNL_Model_Core_Observer_Cron
66
- *
67
  * @throws TIG_PostNL_Exception
68
  */
69
  public function cleanTempLabels()
70
  {
71
  $helper = Mage::helper('postnl');
72
-
73
  /**
74
  * Check if the PostNL module is active
75
  */
76
  if (!$helper->isEnabled()) {
77
  return $this;
78
  }
79
-
80
  $helper->cronLog('CleanTempLabels cron starting...');
81
-
82
  /**
83
- * Directory where all temporary labels are stored.
84
  * If this directory does not exist, end the script.
85
  */
86
  $tempLabelsDirectory = Mage::getConfig()->getVarDir('TIG' . DS . 'PostNL' . DS . 'temp_label');
@@ -88,7 +88,7 @@ class TIG_PostNL_Model_Core_Observer_Cron
88
  $helper->cronLog('Temp labels directory not found. Exiting cron.');
89
  return $this;
90
  }
91
-
92
  /**
93
  * Check the maximum amount of time a temp file may be stored. By default this is 300s (5m).
94
  * If this settings is empty, end the script.
@@ -98,19 +98,19 @@ class TIG_PostNL_Model_Core_Observer_Cron
98
  $helper->cronLog('No max file storage time defined. Exiting cron.');
99
  return $this;
100
  }
101
-
102
  /**
103
  * Get the temporary label filename constant. This is used to construct the fgilename together with
104
  * an md5 hash of the content and a timestamp.
105
  */
106
  $labelModel = Mage::app()->getConfig()->getModelClassName('postnl_core/label');
107
  $tempLabelName = $labelModel::TEMP_LABEL_FILENAME;
108
-
109
  /**
110
  * Get all temporary label files in the directory
111
  */
112
  $files = glob($tempLabelsDirectory . DS . '*' . $tempLabelName);
113
-
114
  /**
115
  * If the directory cannot be read, throw an exception.
116
  */
@@ -121,13 +121,13 @@ class TIG_PostNL_Model_Core_Observer_Cron
121
  'POSTNL-0096'
122
  );
123
  }
124
-
125
  $fileCount = count($files);
126
  if ($fileCount < 1) {
127
  $helper->cronLog('No temporary labels found. Exiting cron.');
128
  return $this;
129
  }
130
-
131
  $helper->cronLog("{$fileCount} temporary labels found.");
132
  foreach ($files as $path) {
133
  /**
@@ -139,7 +139,7 @@ class TIG_PostNL_Model_Core_Observer_Cron
139
  $helper->cronLog("Invalid file found: {$filename}.");
140
  continue;
141
  }
142
-
143
  /**
144
  * Check if the timestamp is older than the maximum storage time
145
  */
@@ -148,38 +148,38 @@ class TIG_PostNL_Model_Core_Observer_Cron
148
  $helper->cronLog("File {$filename} is less than {$maxFileStorageTime}s old. Continuing with the next file.");
149
  continue;
150
  }
151
-
152
  /**
153
  * Delete the file
154
  */
155
  $helper->cronLog("Deleting file: {$filename}.");
156
  unlink($path);
157
  }
158
-
159
  $helper->cronLog('CleanTempLabels cron has finished.');
160
  return $this;
161
  }
162
 
163
  /**
164
  * Method to destroy old lock files.
165
- *
166
  * @return TIG_PostNL_Model_Core_Observer_Cron
167
- *
168
  * @throws TIG_PostNL_Exception
169
  */
170
  public function cleanOldLocks()
171
  {
172
  $helper = Mage::helper('postnl');
173
-
174
  /**
175
  * Check if the PostNL module is active
176
  */
177
  if (!$helper->isEnabled()) {
178
  return $this;
179
  }
180
-
181
  $helper->cronLog('CleanOldLocks cron starting...');
182
-
183
  /**
184
  * Directory where all lock files are stored
185
  */
@@ -188,12 +188,12 @@ class TIG_PostNL_Model_Core_Observer_Cron
188
  $helper->cronLog('Locks directory not found. Exiting cron.');
189
  return $this;
190
  }
191
-
192
  /**
193
  * Get all PostNL lock files in the directory
194
  */
195
  $files = glob($locksDirectory . DS . 'postnl_process_*');
196
-
197
  /**
198
  * If the directory cannot be read, throw an exception.
199
  */
@@ -204,38 +204,38 @@ class TIG_PostNL_Model_Core_Observer_Cron
204
  'POSTNL-0096'
205
  );
206
  }
207
-
208
  $fileCount = count($files);
209
  if ($fileCount < 1) {
210
  $helper->cronLog('No PostNL locks found. Exiting cron.');
211
  return $this;
212
  }
213
-
214
  /**
215
  * Locks may only exist for 3600 seconds (1 hour) before being removed
216
  */
217
  $maxFileStorageTime = 3600;
218
  $now = Mage::getModel('core/date')->gmtTimestamp();
219
  $maxTimestamp = $now - $maxFileStorageTime; //1 hour ago
220
-
221
  $helper->cronLog("{$fileCount} locks found.");
222
  foreach ($files as $path) {
223
  if (!is_file($path)) {
224
  continue;
225
  }
226
-
227
  /**
228
  * First we must open and unlock the file
229
  */
230
  $file = fopen($path, 'r+');
231
  flock($file, LOCK_UN);
232
  fclose($file);
233
-
234
  /**
235
  * The file should contain a date
236
  */
237
  $timestamp = strtotime(file_get_contents($path));
238
-
239
  /**
240
  * If the file is more than 1 hour old, delete it
241
  */
@@ -244,42 +244,42 @@ class TIG_PostNL_Model_Core_Observer_Cron
244
  @unlink($path);
245
  }
246
  }
247
-
248
  $helper->cronLog('CleanOldLocks cron has finished.');
249
  return $this;
250
  }
251
 
252
  /**
253
  * Retrieve barcodes for postnl shipments that do not have one.
254
- *
255
  * @return TIG_PostNL_Model_Core_Observer_Cron
256
  */
257
  public function getBarcodes()
258
  {
259
  $helper = Mage::helper('postnl');
260
-
261
  /**
262
  * Check if the PostNL module is active
263
  */
264
  if (!$helper->isEnabled()) {
265
  return $this;
266
  }
267
-
268
  $helper->cronLog('GetBarcodes cron starting...');
269
-
270
  /**
271
  * Get all postnl shipments without a barcode
272
  */
273
  $postnlShipmentCollection = Mage::getResourceModel('postnl_core/shipment_collection');
274
  $postnlShipmentCollection->addFieldToFilter('main_barcode', array('null' => true));
275
-
276
  if ($postnlShipmentCollection->getSize() < 1) {
277
  $helper->cronLog('No valid shipments found. Exiting cron.');
278
  return $this;
279
  }
280
-
281
  $helper->cronLog("Getting barcodes for {$postnlShipmentCollection->getSize()} shipments.");
282
-
283
  $n = 1000;
284
  foreach ($postnlShipmentCollection as $postnlShipment) {
285
  /**
@@ -289,7 +289,7 @@ class TIG_PostNL_Model_Core_Observer_Cron
289
  if ($n < 1) {
290
  break;
291
  }
292
-
293
  /**
294
  * Attempt to generate a barcode. Continue with the next one if it fails.
295
  */
@@ -297,67 +297,67 @@ class TIG_PostNL_Model_Core_Observer_Cron
297
  $helper->cronLog("Getting barcodes for shipment #{$postnlShipment->getId()}.");
298
  $postnlShipment->generateBarcodes()
299
  ->save();
300
-
301
  $n--;
302
  } catch (Exception $e) {
303
  Mage::helper('postnl')->logException($e);
304
  }
305
  }
306
-
307
  $helper->cronLog('GetBarcodes cron has finished.');
308
-
309
  return $this;
310
  }
311
-
312
  /**
313
  * Update shipping status for all confirmed, but undelivered shipments.
314
- *
315
  * @return TIG_PostNL_Model_Core_Observer_Cron
316
  */
317
  public function updateShippingStatus()
318
  {
319
  $helper = Mage::helper('postnl');
320
-
321
  /**
322
  * Check if the PostNL module is active
323
  */
324
  if (!$helper->isEnabled()) {
325
  return $this;
326
  }
327
-
328
  $helper->cronLog('UpdateShippingStatus cron starting...');
329
-
330
  $postnlShipmentModelClass = Mage::getConfig()->getModelClassName('postnl_core/shipment');
331
  $confirmedStatus = $postnlShipmentModelClass::CONFIRM_STATUS_CONFIRMED;
332
  $deliveredStatus = $postnlShipmentModelClass::SHIPPING_PHASE_DELIVERED;
333
-
334
  /**
335
  * Get all postnl shipments with a barcode, that are confirmed and are not yet delivered.
336
  */
337
  $postnlShipmentCollection = Mage::getResourceModel('postnl_core/shipment_collection');
338
  $postnlShipmentCollection->addFieldToFilter(
339
- 'main_barcode',
340
  array('notnull' => true)
341
  )
342
  ->addFieldToFilter(
343
- 'confirm_status',
344
  array('eq' => $confirmedStatus)
345
  )
346
  ->addFieldToFilter(
347
- 'shipping_phase',
348
  array(
349
- array('neq' => $deliveredStatus),
350
  array('null' => true)
351
  )
352
  );
353
-
354
  if ($postnlShipmentCollection->getSize() < 1) {
355
  $helper->cronLog('No valid shipments found. Exiting cron.');
356
  return $this;
357
  }
358
-
359
  $helper->cronLog("Shipping status will be updated for {$postnlShipmentCollection->getSize()} shipments.");
360
-
361
  /**
362
  * Request a shipping status update
363
  */
@@ -366,77 +366,81 @@ class TIG_PostNL_Model_Core_Observer_Cron
366
  * Attempt to update the shipping status. Continue with the next one if it fails.
367
  */
368
  try{
 
 
 
 
369
  $helper->cronLog("Updating shipping status for shipment #{$postnlShipment->getShipment()->getId()}");
370
-
371
  if (!$postnlShipment->canUpdateShippingStatus()) {
372
  $helper->cronLog("Updating shipment #{$postnlShipment->getShipment()->getId()} is not allowed. Continuing with next shipment.");
373
  continue;
374
  }
375
-
376
  $postnlShipment->updateShippingStatus()
377
  ->save();
378
  } catch (TIG_PostNL_Model_Core_Cif_Exception $e) {
379
  $postnlShipment->unlock();
380
-
381
  $this->_parseErrorCodes($e, $postnlShipment);
382
  } catch (Exception $e) {
383
  $postnlShipment->unlock();
384
-
385
  Mage::helper('postnl')->logException($e);
386
  }
387
  }
388
-
389
  $helper->cronLog('UpdateShippingStatus cron has finished.');
390
-
391
  return $this;
392
  }
393
-
394
  /**
395
  * Parses an TIG_PostNL_Model_Core_Cif_Exception exception in order to process cpecific error codes
396
- *
397
  * @param TIG_PostNL_Model_Core_Cif_Exception $e
398
  * @param TIG_PostNL_Model_Core_Shipment $postnlShipment
399
- *
400
  * @return TIG_PostNL_Model_Core_Observer_Cron
401
  */
402
  protected function _parseErrorCodes($e, $postnlShipment)
403
  {
404
  $helper = Mage::helper('postnl');
405
-
406
  /**
407
  * Certain error numbers are processed differently
408
  */
409
  $errorNumbers = $e->getErrorNumbers();
410
-
411
  if (!$errorNumbers) {
412
- $helper->logException($e);
413
  return $this;
414
  }
415
-
416
  foreach ($errorNumbers as $errorNumber) {
417
  if ($errorNumber != '13') { // Collo not found error
418
- $helper->logException($e);
419
  return $this;
420
  }
421
-
422
  /**
423
  * If the shipment's shipping phase has already been set to 'shipment not found' there is no need to proceed
424
  */
425
  if ($postnlShipment->getShippingPhase() == $postnlShipment::SHIPPING_PHASE_NOT_APPLICABLE) {
426
  return $this;
427
  }
428
-
429
  /**
430
  * Check if the shipment was confirmed more than a day ago
431
  */
432
  $confirmedAt = strtotime($postnlShipment->getConfirmedAt());
433
  $now = Mage::getModel('core/date')->gmtTimestamp();
434
  $yesterday = strtotime('-1 day', $now);
435
-
436
  if ($confirmedAt > $yesterday) {
437
  return $this;
438
  }
439
-
440
  /**
441
  * Set 'shipment not found' status
442
  */
@@ -445,66 +449,66 @@ class TIG_PostNL_Model_Core_Observer_Cron
445
  );
446
  $postnlShipment->setShippingPhase($postnlShipment::SHIPPING_PHASE_NOT_APPLICABLE)
447
  ->save();
448
-
449
  return $this;
450
  }
451
-
452
  $helper->logException($e);
453
  return $this;
454
  }
455
-
456
  /**
457
  * Removes expired confirmations by resetting the postnl shipment to a pre-confirm state
458
- *
459
  * @return TIG_PostNL_Model_Core_Observer_Cron
460
  */
461
  public function expireConfirmation()
462
  {
463
  $helper = Mage::helper('postnl');
464
-
465
  /**
466
  * Check if the PostNL module is active
467
  */
468
  if (!$helper->isEnabled()) {
469
  return $this;
470
  }
471
-
472
  $helper->cronLog('ExpireConfirmation cron starting...');
473
-
474
  $postnlShipmentModelClass = Mage::getConfig()->getModelClassName('postnl_core/shipment');
475
  $confirmedStatus = $postnlShipmentModelClass::CONFIRM_STATUS_CONFIRMED;
476
  $collectionPhase = $postnlShipmentModelClass::SHIPPING_PHASE_COLLECTION;
477
-
478
  $confirmationExpireDays = Mage::getStoreConfig(self::XML_PATH_CONFIRM_EXPIRE_DAYS, Mage_Core_Model_App::ADMIN_STORE_ID);
479
  $expireTimestamp = strtotime("-{$confirmationExpireDays} days", Mage::getModel('core/date')->gmtTimestamp());
480
  $expireDate = date('Y-m-d H:i:s', $expireTimestamp);
481
-
482
  $helper->cronLog("All confirmation placed before {$expireDate} will be expired.");
483
-
484
  /**
485
  * Get all postnl shipments that have been confirmed over X days ago and who have not yet been shipped (shipping_phase
486
  * other than 'collection')
487
  */
488
  $postnlShipmentCollection = Mage::getResourceModel('postnl_core/shipment_collection');
489
  $postnlShipmentCollection->addFieldToFilter(
490
- 'confirm_status',
491
  array('eq' => $confirmedStatus)
492
  )
493
  ->addFieldToFilter(
494
- 'shipping_phase',
495
  array(
496
- array('eq' => $collectionPhase),
497
  array('null' => true)
498
  )
499
  )
500
  ->addFieldToFilter(
501
- 'confirmed_at',
502
  array(
503
- array('lt' => $expireDate),
504
  array('null' => true)
505
  )
506
  );
507
-
508
  /**
509
  * Check to see if there are any results
510
  */
@@ -512,9 +516,9 @@ class TIG_PostNL_Model_Core_Observer_Cron
512
  $helper->cronLog('No expired confirmations found. Exiting cron.');
513
  return $this;
514
  }
515
-
516
  $helper->cronLog("Number of expired confirmations found: {$postnlShipmentCollection->getSize()}");
517
-
518
  /**
519
  * Reset the shipments to 'unconfirmed' status
520
  */
@@ -533,28 +537,28 @@ class TIG_PostNL_Model_Core_Observer_Cron
533
  }
534
  }
535
  $helper->cronLog('ExpireConfirmation cron has finished.');
536
-
537
  return $this;
538
  }
539
-
540
  /**
541
  * Send a track & trace e-mail to the customer
542
- *
543
  * @return TIG_PostNL_Model_Core_Observer_Cron
544
  */
545
  public function sendTrackAndTraceEmail()
546
  {
547
  $helper = Mage::helper('postnl');
548
-
549
  /**
550
  * Check if the PostNL module is active
551
  */
552
  if (!$helper->isEnabled()) {
553
  return $this;
554
  }
555
-
556
  $helper->cronLog('SendTrackAndTraceEmail cron starting...');
557
-
558
  /**
559
  * Check each storeview if sending track & trace emails is allowed
560
  */
@@ -564,34 +568,34 @@ class TIG_PostNL_Model_Core_Observer_Cron
564
  $allowedStoreIds[] = $storeId;
565
  }
566
  }
567
-
568
  if (empty($allowedStoreIds)) {
569
  $helper->cronLog('Sending track & trace emails is disabled in all stores. Exiting cron.');
570
  return $this;
571
  }
572
-
573
  $postnlShipmentModelClass = Mage::getConfig()->getModelClassName('postnl_core/shipment');
574
  $confirmedStatus = $postnlShipmentModelClass::CONFIRM_STATUS_CONFIRMED;
575
-
576
  $twentyMinutesAgo = strtotime("-20 minutes", Mage::getModel('core/date')->gmtTimestamp());
577
  $twentyMinutesAgo = date('Y-m-d H:i:s', $twentyMinutesAgo);
578
-
579
  $helper->cronLog("Track and trace email will be sent for all shipments that were confirmed on or before {$twentyMinutesAgo}.");
580
-
581
  /**
582
  * Get all postnl shipments that have been confirmed over 20 minutes ago whose track & trace e-mail has not yet been sent
583
  */
584
  $postnlShipmentCollection = Mage::getResourceModel('postnl_core/shipment_collection');
585
  $postnlShipmentCollection->addFieldToFilter(
586
- 'confirm_status',
587
  array('eq' => $confirmedStatus)
588
  )
589
  ->addFieldToFilter(
590
- 'labels_printed',
591
  array('eq' => 1)
592
  )
593
  ->addFieldToFilter(
594
- 'confirmed_at',
595
  array('lteq' => $twentyMinutesAgo)
596
  )
597
  ->addFieldToFilter(
@@ -601,7 +605,7 @@ class TIG_PostNL_Model_Core_Observer_Cron
601
  array('eq' => '0')
602
  )
603
  );
604
-
605
  /**
606
  * Check to see if there are any results
607
  */
@@ -609,9 +613,9 @@ class TIG_PostNL_Model_Core_Observer_Cron
609
  $helper->cronLog('No valid shipments found. Exiting cron.');
610
  return $this;
611
  }
612
-
613
  $helper->cronLog("Track & trace emails will be sent for {$postnlShipmentCollection->getSize()} shipments.");
614
-
615
  /**
616
  * Send the track and trace email for all shipments
617
  */
@@ -622,9 +626,9 @@ class TIG_PostNL_Model_Core_Observer_Cron
622
  $storeId = $postnlShipment->getStoreId();
623
  if (!in_array($storeId, $allowedStoreIds) || !$postnlShipment->canSendTrackAndTraceEmail()) {
624
  $helper->cronLog("Sending the track and trace email is not allowed for shipment #{$postnlShipment->getId()}.");
625
- return $this;
626
  }
627
-
628
  /**
629
  * Attempt to send the email
630
  */
@@ -638,47 +642,47 @@ class TIG_PostNL_Model_Core_Observer_Cron
638
  }
639
  }
640
  $helper->cronLog('SendTrackAndTraceEmail cron has finished.');
641
-
642
  return $this;
643
  }
644
-
645
  /**
646
  * Deletes labels belonging to shipments that have been delievered as well as labels who have no associated shipments.
647
- *
648
  * @return TIG_PostNL_Model_Core_Observer_Cron
649
  */
650
  public function removeOldLabels()
651
  {
652
  $helper = Mage::helper('postnl');
653
-
654
  /**
655
  * Check if the PostNL module is active
656
  */
657
  if (!$helper->isEnabled()) {
658
  return $this;
659
  }
660
-
661
  $helper->cronLog('RemoveOldLabels cron starting...');
662
-
663
  /**
664
  * Get the PostNL Shipment classname for later use
665
  */
666
  $postnlShipmentClass = Mage::getConfig()->getModelClassName('postnl_core/shipment');
667
-
668
  /**
669
  * Get the label collection
670
  */
671
  $labelsCollection = Mage::getResourceModel('postnl_core/shipment_label_collection');
672
-
673
  /**
674
  * We only need the label IDs
675
  */
676
  $labelsCollection->addFieldToSelect('label_id');
677
-
678
  $resource = Mage::getSingleton('core/resource');
679
-
680
  $select = $labelsCollection->getSelect();
681
-
682
  /**
683
  * Join the collection with the postnl shipments collection
684
  */
@@ -689,10 +693,10 @@ class TIG_PostNL_Model_Core_Observer_Cron
689
  'shipping_phase' => 'postnl_shipment.shipping_phase',
690
  )
691
  );
692
-
693
  /**
694
  * Filter the collection by the lack of a parent_id OR shipping_phase being 'delivered'
695
- *
696
  * Resulting query:
697
  * SELECT `main_table`.`label_id` , `postnl_shipment`.`shipping_phase`
698
  * FROM `tig_postnl_shipment_label` AS `main_table`
@@ -713,15 +717,15 @@ class TIG_PostNL_Model_Core_Observer_Cron
713
  array('eq' => $postnlShipmentClass::SHIPPING_PHASE_DELIVERED),
714
  )
715
  );
716
-
717
  $labelCollectionSize = $labelsCollection->getSize();
718
  if ($labelCollectionSize < 1) {
719
  $helper->cronLog('No labels need to be removed. Exiting cron.');
720
  return $this;
721
  }
722
-
723
  $helper->cronLog("{$labelCollectionSize} labels will be removed.");
724
-
725
  /**
726
  * Delete the labels
727
  */
@@ -730,7 +734,7 @@ class TIG_PostNL_Model_Core_Observer_Cron
730
  $label->delete()->save();
731
  }
732
  $helper->cronLog('RemoveOldLabels cron has finished.');
733
-
734
  return $this;
735
  }
736
  }
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@totalinternetgroup.nl so we can send you a copy immediately.
42
  * Xml path to maximum file storage setting in system/config
43
  */
44
  const XML_PATH_MAX_FILE_STORAGE = 'postnl/advanced/max_temp_file_storage_time';
45
+
46
  /**
47
  * XML path to confirmation expire time setting
48
  */
49
  const XML_PATH_CONFIRM_EXPIRE_DAYS = 'postnl/advanced/confirm_expire_days';
50
+
51
  /**
52
  * XML path to setting that determines whether or not to send track and trace emails
53
  */
54
  const XML_PATH_SEND_TRACK_AND_TRACE_EMAIL = 'postnl/cif_labels_and_confirming/send_track_and_trace_email';
55
+
56
  /**
57
  * Method to destroy temporary label files that have been stored for too long.
58
+ *
59
  * By default the PostNL module creates temporary label files in order to merge them into
60
  * a single shipping label. These files are then destroyed. However, sometimes these files
61
  * may survive the script if the script has encountered an error. This method will make
62
  * sure these files will not survive indefinitiely, which may lead to the file system
63
  * being overburdoned or the server running out of harddrive space.
64
+ *
65
  * @return TIG_PostNL_Model_Core_Observer_Cron
66
+ *
67
  * @throws TIG_PostNL_Exception
68
  */
69
  public function cleanTempLabels()
70
  {
71
  $helper = Mage::helper('postnl');
72
+
73
  /**
74
  * Check if the PostNL module is active
75
  */
76
  if (!$helper->isEnabled()) {
77
  return $this;
78
  }
79
+
80
  $helper->cronLog('CleanTempLabels cron starting...');
81
+
82
  /**
83
+ * Directory where all temporary labels are stored.
84
  * If this directory does not exist, end the script.
85
  */
86
  $tempLabelsDirectory = Mage::getConfig()->getVarDir('TIG' . DS . 'PostNL' . DS . 'temp_label');
88
  $helper->cronLog('Temp labels directory not found. Exiting cron.');
89
  return $this;
90
  }
91
+
92
  /**
93
  * Check the maximum amount of time a temp file may be stored. By default this is 300s (5m).
94
  * If this settings is empty, end the script.
98
  $helper->cronLog('No max file storage time defined. Exiting cron.');
99
  return $this;
100
  }
101
+
102
  /**
103
  * Get the temporary label filename constant. This is used to construct the fgilename together with
104
  * an md5 hash of the content and a timestamp.
105
  */
106
  $labelModel = Mage::app()->getConfig()->getModelClassName('postnl_core/label');
107
  $tempLabelName = $labelModel::TEMP_LABEL_FILENAME;
108
+
109
  /**
110
  * Get all temporary label files in the directory
111
  */
112
  $files = glob($tempLabelsDirectory . DS . '*' . $tempLabelName);
113
+
114
  /**
115
  * If the directory cannot be read, throw an exception.
116
  */
121
  'POSTNL-0096'
122
  );
123
  }
124
+
125
  $fileCount = count($files);
126
  if ($fileCount < 1) {
127
  $helper->cronLog('No temporary labels found. Exiting cron.');
128
  return $this;
129
  }
130
+
131
  $helper->cronLog("{$fileCount} temporary labels found.");
132
  foreach ($files as $path) {
133
  /**
139
  $helper->cronLog("Invalid file found: {$filename}.");
140
  continue;
141
  }
142
+
143
  /**
144
  * Check if the timestamp is older than the maximum storage time
145
  */
148
  $helper->cronLog("File {$filename} is less than {$maxFileStorageTime}s old. Continuing with the next file.");
149
  continue;
150
  }
151
+
152
  /**
153
  * Delete the file
154
  */
155
  $helper->cronLog("Deleting file: {$filename}.");
156
  unlink($path);
157
  }
158
+
159
  $helper->cronLog('CleanTempLabels cron has finished.');
160
  return $this;
161
  }
162
 
163
  /**
164
  * Method to destroy old lock files.
165
+ *
166
  * @return TIG_PostNL_Model_Core_Observer_Cron
167
+ *
168
  * @throws TIG_PostNL_Exception
169
  */
170
  public function cleanOldLocks()
171
  {
172
  $helper = Mage::helper('postnl');
173
+
174
  /**
175
  * Check if the PostNL module is active
176
  */
177
  if (!$helper->isEnabled()) {
178
  return $this;
179
  }
180
+
181
  $helper->cronLog('CleanOldLocks cron starting...');
182
+
183
  /**
184
  * Directory where all lock files are stored
185
  */
188
  $helper->cronLog('Locks directory not found. Exiting cron.');
189
  return $this;
190
  }
191
+
192
  /**
193
  * Get all PostNL lock files in the directory
194
  */
195
  $files = glob($locksDirectory . DS . 'postnl_process_*');
196
+
197
  /**
198
  * If the directory cannot be read, throw an exception.
199
  */
204
  'POSTNL-0096'
205
  );
206
  }
207
+
208
  $fileCount = count($files);
209
  if ($fileCount < 1) {
210
  $helper->cronLog('No PostNL locks found. Exiting cron.');
211
  return $this;
212
  }
213
+
214
  /**
215
  * Locks may only exist for 3600 seconds (1 hour) before being removed
216
  */
217
  $maxFileStorageTime = 3600;
218
  $now = Mage::getModel('core/date')->gmtTimestamp();
219
  $maxTimestamp = $now - $maxFileStorageTime; //1 hour ago
220
+
221
  $helper->cronLog("{$fileCount} locks found.");
222
  foreach ($files as $path) {
223
  if (!is_file($path)) {
224
  continue;
225
  }
226
+
227
  /**
228
  * First we must open and unlock the file
229
  */
230
  $file = fopen($path, 'r+');
231
  flock($file, LOCK_UN);
232
  fclose($file);
233
+
234
  /**
235
  * The file should contain a date
236
  */
237
  $timestamp = strtotime(file_get_contents($path));
238
+
239
  /**
240
  * If the file is more than 1 hour old, delete it
241
  */
244
  @unlink($path);
245
  }
246
  }
247
+
248
  $helper->cronLog('CleanOldLocks cron has finished.');
249
  return $this;
250
  }
251
 
252
  /**
253
  * Retrieve barcodes for postnl shipments that do not have one.
254
+ *
255
  * @return TIG_PostNL_Model_Core_Observer_Cron
256
  */
257
  public function getBarcodes()
258
  {
259
  $helper = Mage::helper('postnl');
260
+
261
  /**
262
  * Check if the PostNL module is active
263
  */
264
  if (!$helper->isEnabled()) {
265
  return $this;
266
  }
267
+
268
  $helper->cronLog('GetBarcodes cron starting...');
269
+
270
  /**
271
  * Get all postnl shipments without a barcode
272
  */
273
  $postnlShipmentCollection = Mage::getResourceModel('postnl_core/shipment_collection');
274
  $postnlShipmentCollection->addFieldToFilter('main_barcode', array('null' => true));
275
+
276
  if ($postnlShipmentCollection->getSize() < 1) {
277
  $helper->cronLog('No valid shipments found. Exiting cron.');
278
  return $this;
279
  }
280
+
281
  $helper->cronLog("Getting barcodes for {$postnlShipmentCollection->getSize()} shipments.");
282
+
283
  $n = 1000;
284
  foreach ($postnlShipmentCollection as $postnlShipment) {
285
  /**
289
  if ($n < 1) {
290
  break;
291
  }
292
+
293
  /**
294
  * Attempt to generate a barcode. Continue with the next one if it fails.
295
  */
297
  $helper->cronLog("Getting barcodes for shipment #{$postnlShipment->getId()}.");
298
  $postnlShipment->generateBarcodes()
299
  ->save();
300
+
301
  $n--;
302
  } catch (Exception $e) {
303
  Mage::helper('postnl')->logException($e);
304
  }
305
  }
306
+
307
  $helper->cronLog('GetBarcodes cron has finished.');
308
+
309
  return $this;
310
  }
311
+
312
  /**
313
  * Update shipping status for all confirmed, but undelivered shipments.
314
+ *
315
  * @return TIG_PostNL_Model_Core_Observer_Cron
316
  */
317
  public function updateShippingStatus()
318
  {
319
  $helper = Mage::helper('postnl');
320
+
321
  /**
322
  * Check if the PostNL module is active
323
  */
324
  if (!$helper->isEnabled()) {
325
  return $this;
326
  }
327
+
328
  $helper->cronLog('UpdateShippingStatus cron starting...');
329
+
330
  $postnlShipmentModelClass = Mage::getConfig()->getModelClassName('postnl_core/shipment');
331
  $confirmedStatus = $postnlShipmentModelClass::CONFIRM_STATUS_CONFIRMED;
332
  $deliveredStatus = $postnlShipmentModelClass::SHIPPING_PHASE_DELIVERED;
333
+
334
  /**
335
  * Get all postnl shipments with a barcode, that are confirmed and are not yet delivered.
336
  */
337
  $postnlShipmentCollection = Mage::getResourceModel('postnl_core/shipment_collection');
338
  $postnlShipmentCollection->addFieldToFilter(
339
+ 'main_barcode',
340
  array('notnull' => true)
341
  )
342
  ->addFieldToFilter(
343
+ 'confirm_status',
344
  array('eq' => $confirmedStatus)
345
  )
346
  ->addFieldToFilter(
347
+ 'shipping_phase',
348
  array(
349
+ array('neq' => $deliveredStatus),
350
  array('null' => true)
351
  )
352
  );
353
+
354
  if ($postnlShipmentCollection->getSize() < 1) {
355
  $helper->cronLog('No valid shipments found. Exiting cron.');
356
  return $this;
357
  }
358
+
359
  $helper->cronLog("Shipping status will be updated for {$postnlShipmentCollection->getSize()} shipments.");
360
+
361
  /**
362
  * Request a shipping status update
363
  */
366
  * Attempt to update the shipping status. Continue with the next one if it fails.
367
  */
368
  try{
369
+ if (!$postnlShipment->getShipment()) {
370
+ continue;
371
+ }
372
+
373
  $helper->cronLog("Updating shipping status for shipment #{$postnlShipment->getShipment()->getId()}");
374
+
375
  if (!$postnlShipment->canUpdateShippingStatus()) {
376
  $helper->cronLog("Updating shipment #{$postnlShipment->getShipment()->getId()} is not allowed. Continuing with next shipment.");
377
  continue;
378
  }
379
+
380
  $postnlShipment->updateShippingStatus()
381
  ->save();
382
  } catch (TIG_PostNL_Model_Core_Cif_Exception $e) {
383
  $postnlShipment->unlock();
384
+
385
  $this->_parseErrorCodes($e, $postnlShipment);
386
  } catch (Exception $e) {
387
  $postnlShipment->unlock();
388
+
389
  Mage::helper('postnl')->logException($e);
390
  }
391
  }
392
+
393
  $helper->cronLog('UpdateShippingStatus cron has finished.');
394
+
395
  return $this;
396
  }
397
+
398
  /**
399
  * Parses an TIG_PostNL_Model_Core_Cif_Exception exception in order to process cpecific error codes
400
+ *
401
  * @param TIG_PostNL_Model_Core_Cif_Exception $e
402
  * @param TIG_PostNL_Model_Core_Shipment $postnlShipment
403
+ *
404
  * @return TIG_PostNL_Model_Core_Observer_Cron
405
  */
406
  protected function _parseErrorCodes($e, $postnlShipment)
407
  {
408
  $helper = Mage::helper('postnl');
409
+
410
  /**
411
  * Certain error numbers are processed differently
412
  */
413
  $errorNumbers = $e->getErrorNumbers();
414
+
415
  if (!$errorNumbers) {
416
+ $helper->logException($e);
417
  return $this;
418
  }
419
+
420
  foreach ($errorNumbers as $errorNumber) {
421
  if ($errorNumber != '13') { // Collo not found error
422
+ $helper->logException($e);
423
  return $this;
424
  }
425
+
426
  /**
427
  * If the shipment's shipping phase has already been set to 'shipment not found' there is no need to proceed
428
  */
429
  if ($postnlShipment->getShippingPhase() == $postnlShipment::SHIPPING_PHASE_NOT_APPLICABLE) {
430
  return $this;
431
  }
432
+
433
  /**
434
  * Check if the shipment was confirmed more than a day ago
435
  */
436
  $confirmedAt = strtotime($postnlShipment->getConfirmedAt());
437
  $now = Mage::getModel('core/date')->gmtTimestamp();
438
  $yesterday = strtotime('-1 day', $now);
439
+
440
  if ($confirmedAt > $yesterday) {
441
  return $this;
442
  }
443
+
444
  /**
445
  * Set 'shipment not found' status
446
  */
449
  );
450
  $postnlShipment->setShippingPhase($postnlShipment::SHIPPING_PHASE_NOT_APPLICABLE)
451
  ->save();
452
+
453
  return $this;
454
  }
455
+
456
  $helper->logException($e);
457
  return $this;
458
  }
459
+
460
  /**
461
  * Removes expired confirmations by resetting the postnl shipment to a pre-confirm state
462
+ *
463
  * @return TIG_PostNL_Model_Core_Observer_Cron
464
  */
465
  public function expireConfirmation()
466
  {
467
  $helper = Mage::helper('postnl');
468
+
469
  /**
470
  * Check if the PostNL module is active
471
  */
472
  if (!$helper->isEnabled()) {
473
  return $this;
474
  }
475
+
476
  $helper->cronLog('ExpireConfirmation cron starting...');
477
+
478
  $postnlShipmentModelClass = Mage::getConfig()->getModelClassName('postnl_core/shipment');
479
  $confirmedStatus = $postnlShipmentModelClass::CONFIRM_STATUS_CONFIRMED;
480
  $collectionPhase = $postnlShipmentModelClass::SHIPPING_PHASE_COLLECTION;
481
+
482
  $confirmationExpireDays = Mage::getStoreConfig(self::XML_PATH_CONFIRM_EXPIRE_DAYS, Mage_Core_Model_App::ADMIN_STORE_ID);
483
  $expireTimestamp = strtotime("-{$confirmationExpireDays} days", Mage::getModel('core/date')->gmtTimestamp());
484
  $expireDate = date('Y-m-d H:i:s', $expireTimestamp);
485
+
486
  $helper->cronLog("All confirmation placed before {$expireDate} will be expired.");
487
+
488
  /**
489
  * Get all postnl shipments that have been confirmed over X days ago and who have not yet been shipped (shipping_phase
490
  * other than 'collection')
491
  */
492
  $postnlShipmentCollection = Mage::getResourceModel('postnl_core/shipment_collection');
493
  $postnlShipmentCollection->addFieldToFilter(
494
+ 'confirm_status',
495
  array('eq' => $confirmedStatus)
496
  )
497
  ->addFieldToFilter(
498
+ 'shipping_phase',
499
  array(
500
+ array('eq' => $collectionPhase),
501
  array('null' => true)
502
  )
503
  )
504
  ->addFieldToFilter(
505
+ 'confirmed_at',
506
  array(
507
+ array('lt' => $expireDate),
508
  array('null' => true)
509
  )
510
  );
511
+
512
  /**
513
  * Check to see if there are any results
514
  */
516
  $helper->cronLog('No expired confirmations found. Exiting cron.');
517
  return $this;
518
  }
519
+
520
  $helper->cronLog("Number of expired confirmations found: {$postnlShipmentCollection->getSize()}");
521
+
522
  /**
523
  * Reset the shipments to 'unconfirmed' status
524
  */
537
  }
538
  }
539
  $helper->cronLog('ExpireConfirmation cron has finished.');
540
+
541
  return $this;
542
  }
543
+
544
  /**
545
  * Send a track & trace e-mail to the customer
546
+ *
547
  * @return TIG_PostNL_Model_Core_Observer_Cron
548
  */
549
  public function sendTrackAndTraceEmail()
550
  {
551
  $helper = Mage::helper('postnl');
552
+
553
  /**
554
  * Check if the PostNL module is active
555
  */
556
  if (!$helper->isEnabled()) {
557
  return $this;
558
  }
559
+
560
  $helper->cronLog('SendTrackAndTraceEmail cron starting...');
561
+
562
  /**
563
  * Check each storeview if sending track & trace emails is allowed
564
  */
568
  $allowedStoreIds[] = $storeId;
569
  }
570
  }
571
+
572
  if (empty($allowedStoreIds)) {
573
  $helper->cronLog('Sending track & trace emails is disabled in all stores. Exiting cron.');
574
  return $this;
575
  }
576
+
577
  $postnlShipmentModelClass = Mage::getConfig()->getModelClassName('postnl_core/shipment');
578
  $confirmedStatus = $postnlShipmentModelClass::CONFIRM_STATUS_CONFIRMED;
579
+
580
  $twentyMinutesAgo = strtotime("-20 minutes", Mage::getModel('core/date')->gmtTimestamp());
581
  $twentyMinutesAgo = date('Y-m-d H:i:s', $twentyMinutesAgo);
582
+
583
  $helper->cronLog("Track and trace email will be sent for all shipments that were confirmed on or before {$twentyMinutesAgo}.");
584
+
585
  /**
586
  * Get all postnl shipments that have been confirmed over 20 minutes ago whose track & trace e-mail has not yet been sent
587
  */
588
  $postnlShipmentCollection = Mage::getResourceModel('postnl_core/shipment_collection');
589
  $postnlShipmentCollection->addFieldToFilter(
590
+ 'confirm_status',
591
  array('eq' => $confirmedStatus)
592
  )
593
  ->addFieldToFilter(
594
+ 'labels_printed',
595
  array('eq' => 1)
596
  )
597
  ->addFieldToFilter(
598
+ 'confirmed_at',
599
  array('lteq' => $twentyMinutesAgo)
600
  )
601
  ->addFieldToFilter(
605
  array('eq' => '0')
606
  )
607
  );
608
+
609
  /**
610
  * Check to see if there are any results
611
  */
613
  $helper->cronLog('No valid shipments found. Exiting cron.');
614
  return $this;
615
  }
616
+
617
  $helper->cronLog("Track & trace emails will be sent for {$postnlShipmentCollection->getSize()} shipments.");
618
+
619
  /**
620
  * Send the track and trace email for all shipments
621
  */
626
  $storeId = $postnlShipment->getStoreId();
627
  if (!in_array($storeId, $allowedStoreIds) || !$postnlShipment->canSendTrackAndTraceEmail()) {
628
  $helper->cronLog("Sending the track and trace email is not allowed for shipment #{$postnlShipment->getId()}.");
629
+ continue;
630
  }
631
+
632
  /**
633
  * Attempt to send the email
634
  */
642
  }
643
  }
644
  $helper->cronLog('SendTrackAndTraceEmail cron has finished.');
645
+
646
  return $this;
647
  }
648
+
649
  /**
650
  * Deletes labels belonging to shipments that have been delievered as well as labels who have no associated shipments.
651
+ *
652
  * @return TIG_PostNL_Model_Core_Observer_Cron
653
  */
654
  public function removeOldLabels()
655
  {
656
  $helper = Mage::helper('postnl');
657
+
658
  /**
659
  * Check if the PostNL module is active
660
  */
661
  if (!$helper->isEnabled()) {
662
  return $this;
663
  }
664
+
665
  $helper->cronLog('RemoveOldLabels cron starting...');
666
+
667
  /**
668
  * Get the PostNL Shipment classname for later use
669
  */
670
  $postnlShipmentClass = Mage::getConfig()->getModelClassName('postnl_core/shipment');
671
+
672
  /**
673
  * Get the label collection
674
  */
675
  $labelsCollection = Mage::getResourceModel('postnl_core/shipment_label_collection');
676
+
677
  /**
678
  * We only need the label IDs
679
  */
680
  $labelsCollection->addFieldToSelect('label_id');
681
+
682
  $resource = Mage::getSingleton('core/resource');
683
+
684
  $select = $labelsCollection->getSelect();
685
+
686
  /**
687
  * Join the collection with the postnl shipments collection
688
  */
693
  'shipping_phase' => 'postnl_shipment.shipping_phase',
694
  )
695
  );
696
+
697
  /**
698
  * Filter the collection by the lack of a parent_id OR shipping_phase being 'delivered'
699
+ *
700
  * Resulting query:
701
  * SELECT `main_table`.`label_id` , `postnl_shipment`.`shipping_phase`
702
  * FROM `tig_postnl_shipment_label` AS `main_table`
717
  array('eq' => $postnlShipmentClass::SHIPPING_PHASE_DELIVERED),
718
  )
719
  );
720
+
721
  $labelCollectionSize = $labelsCollection->getSize();
722
  if ($labelCollectionSize < 1) {
723
  $helper->cronLog('No labels need to be removed. Exiting cron.');
724
  return $this;
725
  }
726
+
727
  $helper->cronLog("{$labelCollectionSize} labels will be removed.");
728
+
729
  /**
730
  * Delete the labels
731
  */
734
  $label->delete()->save();
735
  }
736
  $helper->cronLog('RemoveOldLabels cron has finished.');
737
+
738
  return $this;
739
  }
740
  }
app/code/community/TIG/PostNL/Model/Core/Shipment.php CHANGED
@@ -1,28 +1,28 @@
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@totalinternetgroup.nl so we can send you a copy immediately.
@@ -36,7 +36,7 @@
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
  * PostNL Shipment base class. Contains majority of PostNL shipping functionality
42
  */
@@ -48,19 +48,19 @@ class TIG_PostNL_Model_Core_Shipment extends Mage_Core_Model_Abstract
48
  * @var string
49
  */
50
  protected $_eventPrefix = 'postnl_shipment';
51
-
52
  /**
53
  * Carrier code used by postnl
54
  */
55
  const POSTNL_CARRIER_CODE = 'postnl';
56
-
57
  /**
58
  * Possible confirm statusses
59
  */
60
  const CONFIRM_STATUS_CONFIRMED = 'confirmed';
61
  const CONFIRM_STATUS_UNCONFIRMED = 'unconfirmed';
62
  const CONFIRM_STATUS_CONFIRM_EXPIRED = 'confirm_expired';
63
-
64
  /**
65
  * Possible shipping phases
66
  */
@@ -69,7 +69,7 @@ class TIG_PostNL_Model_Core_Shipment extends Mage_Core_Model_Abstract
69
  const SHIPPING_PHASE_DISTRIBUTION = '3';
70
  const SHIPPING_PHASE_DELIVERED = '4';
71
  const SHIPPING_PHASE_NOT_APPLICABLE = '99';
72
-
73
  /**
74
  * XML paths to default product options settings
75
  */
@@ -80,40 +80,40 @@ class TIG_PostNL_Model_Core_Shipment extends Mage_Core_Model_Abstract
80
  const XML_PATH_USE_ALTERNATIVE_DEFAULT = 'postnl/cif_product_options/use_alternative_default';
81
  const XML_PATH_ALTERNATIVE_DEFAULT_MAX_AMOUNT = 'postnl/cif_product_options/alternative_default_max_amount';
82
  const XML_PATH_ALTERNATIVE_DEFAULT_OPTION = 'postnl/cif_product_options/alternative_default_option';
83
-
84
  /**
85
  * XML path to weight per parcel config setting
86
  */
87
- const XML_PATH_WEIGHT_PER_PARCEL = 'postnl/cif_labels_and_confirming/weight_per_parcel';
88
-
89
  /**
90
  * XML path to setting that determines whether or not to send track and trace emails
91
  */
92
  const XML_PATH_SEND_TRACK_AND_TRACE_EMAIL = 'postnl/cif_labels_and_confirming/send_track_and_trace_email';
93
-
94
  /**
95
  * XML path to track and trace email template setting
96
  */
97
  const XML_PATH_TRACK_AND_TRACE_EMAIL_TEMPLATE = 'postnl/cif_labels_and_confirming/track_and_trace_email_template';
98
-
99
  /**
100
  * XML path to maximum allowed parcel count settings
101
  */
102
  const XML_PATH_MAX_PARCEL_COUNT = 'postnl/advanced/max_parcel_count';
103
-
104
  /**
105
  * CIF warning code returned when an EPS combi label is not available
106
  */
107
  const EPS_COMBI_LABEL_WARNING_CODE = 'LIRS_0';
108
-
109
  /**
110
  * Newly added 'pakje_gemak' address type
111
  */
112
  const ADDRESS_TYPE_PAKJEGEMAK = 'pakje_gemak';
113
-
114
  /**
115
  * Array of product codes that have extra cover
116
- *
117
  * @var array
118
  */
119
  protected $_extraCoverProductCodes = array(
@@ -127,21 +127,21 @@ class TIG_PostNL_Model_Core_Shipment extends Mage_Core_Model_Abstract
127
  '3544',
128
  '4945',
129
  );
130
-
131
  /**
132
  * Array of labels that need to be saved all at once.
133
- *
134
  * @var array
135
  */
136
  protected $_labelsToSave = array();
137
-
138
  /**
139
  * Contains an instance of TIG_PostNL_Model_Core_Shipment_Process which locks a shipment and prevents it from being modified
140
- *
141
  * @var void | TIG_PostNL_Model_Core_Shipment_Process
142
  */
143
  protected $_process;
144
-
145
  /**
146
  * Initialize the shipment
147
  */
@@ -149,14 +149,14 @@ class TIG_PostNL_Model_Core_Shipment extends Mage_Core_Model_Abstract
149
  {
150
  $this->_init('postnl_core/shipment');
151
  }
152
-
153
  /****************************************************************************************************************************
154
  * GETTER AND SETTER METHODS
155
  ***************************************************************************************************************************/
156
-
157
  /**
158
  * Retrieves a Mage_Sales_Model_Order_Shipment entity linked to the postnl shipment.
159
- *
160
  * @return Mage_Sales_Model_Order_Shipment | null
161
  */
162
  public function getShipment()
@@ -164,21 +164,21 @@ class TIG_PostNL_Model_Core_Shipment extends Mage_Core_Model_Abstract
164
  if ($this->getData('shipment')) {
165
  return $this->getData('shipment');
166
  }
167
-
168
  $shipmentId = $this->getShipmentId();
169
  if (!$shipmentId) {
170
  return null;
171
  }
172
-
173
  $shipment = Mage::getModel('sales/order_shipment')->load($shipmentId);
174
-
175
  $this->setShipment($shipment);
176
  return $shipment;
177
  }
178
-
179
  /**
180
  * Retrieves the linked Shipment's shipping address
181
- *
182
  * @return Mage_Sales_Model_Order_Address | null
183
  */
184
  public function getShippingAddress()
@@ -186,21 +186,21 @@ class TIG_PostNL_Model_Core_Shipment extends Mage_Core_Model_Abstract
186
  if ($this->getData('shipping_address')) {
187
  return $this->getData('shipping_address');
188
  }
189
-
190
  $shipmentId = $this->getShipmentId();
191
  if (!$shipmentId && !$this->getShipment()) {
192
  return null;
193
  }
194
-
195
  $shippingAddress = $this->getShipment()->getShippingAddress();
196
-
197
  $this->setShippingAddress($shippingAddress);
198
  return $shippingAddress;
199
  }
200
-
201
  /**
202
  * Gets an optional address with the pakje_gemak address type
203
- *
204
  * @return boolean | Mage_Sales_Model_Order_Address
205
  */
206
  public function getPakjeGemakAddress()
@@ -208,12 +208,12 @@ class TIG_PostNL_Model_Core_Shipment extends Mage_Core_Model_Abstract
208
  if ($this->getData('pakje_gemak_address')) {
209
  return $this->getData('pakje_gemak_address');
210
  }
211
-
212
  $shipmentId = $this->getShipmentId();
213
  if (!$shipmentId && !$this->getShipment()) {
214
  return null;
215
  }
216
-
217
  $addresses = $this->getShipment()->getOrder()->getAddressesCollection();
218
  foreach ($addresses as $address) {
219
  if ($address->getAddressType() == self::ADDRESS_TYPE_PAKJEGEMAK) {
@@ -221,15 +221,15 @@ class TIG_PostNL_Model_Core_Shipment extends Mage_Core_Model_Abstract
221
  return $address;
222
  }
223
  }
224
-
225
  return false;
226
  }
227
-
228
  /**
229
- * Get the set store ID. If no store ID is set and a shipment is available,
230
- * that shipment's store ID will be returned. Otherwise the current store
231
  * ID is returned.
232
- *
233
  * @return int
234
  */
235
  public function getStoreId()
@@ -237,23 +237,23 @@ class TIG_PostNL_Model_Core_Shipment extends Mage_Core_Model_Abstract
237
  if ($this->getData('store_id')) {
238
  return $this->getData('store_id');
239
  }
240
-
241
  if ($this->getShipment()) {
242
  $storeId = $this->getShipment()->getStoreId();
243
-
244
  $this->setStoreId($storeId);
245
  return $storeId;
246
  }
247
-
248
  $storeId = Mage::app()->getStore()->getId();
249
-
250
  $this->setStoreId($storeId);
251
  return $storeId;
252
  }
253
-
254
  /**
255
  * Gets the order ID from the associated Mage_Sales_Model_Order_Shipment object
256
- *
257
  * @return int
258
  */
259
  public function getOrderId()
@@ -261,21 +261,21 @@ class TIG_PostNL_Model_Core_Shipment extends Mage_Core_Model_Abstract
261
  if ($this->getData('order_id')) {
262
  return $this->getData('order_id');
263
  }
264
-
265
  $shipment = $this->getShipment();
266
  if (!$shipment || !$shipment->getOrderId()) {
267
  return null;
268
  }
269
-
270
  $orderId = $shipment->getOrderId();
271
-
272
  $this->setOrderId($orderId);
273
  return $orderId;
274
  }
275
-
276
  /**
277
  * Gets a PostNL helper object
278
- *
279
  * @return TIG_PostNL_Helper_Data
280
  */
281
  public function getHelper($type = 'data')
@@ -283,16 +283,16 @@ class TIG_PostNL_Model_Core_Shipment extends Mage_Core_Model_Abstract
283
  if ($this->getData('helper_' . $type)) {
284
  return $this->getData('helper_' . $type);
285
  }
286
-
287
  $helper = Mage::helper('postnl/' . $type);
288
-
289
  $this->setDataUsingMethod('helper_' . $type, $helper);
290
  return $helper;
291
  }
292
-
293
  /**
294
  * Gets the process used for locking and unlocking this shipment
295
- *
296
  * @return TIG_PostNL_Model_Core_Shipment_Process
297
  */
298
  public function getProcess()
@@ -306,44 +306,44 @@ class TIG_PostNL_Model_Core_Shipment extends Mage_Core_Model_Abstract
306
 
307
  return $process;
308
  }
309
-
310
  /**
311
  * Sets the process used for locking and unlocking this shipment
312
- *
313
  * @param TIG_PostNL_Model_Core_Shipment_Process
314
- *
315
  * @return TIG_PostNL_Model_Core_Shipment
316
  */
317
  public function setProcess(TIG_PostNL_Model_Core_Shipment_Process $process)
318
  {
319
  $this->_process = $process;
320
-
321
  return $this;
322
  }
323
-
324
  /**
325
  * Get an array of labels that have to be saved together
326
- *
327
  * @return array
328
  */
329
  public function getlabelsToSave()
330
  {
331
  return $this->_labelsToSave;
332
  }
333
-
334
  /**
335
  * Get all product codes that have extra cover
336
- *
337
  * @return array
338
  */
339
  public function getExtraCoverProductCodes()
340
  {
341
  return $this->_extraCoverProductCodes;
342
  }
343
-
344
  /**
345
  * Get this shipment's product code. If no code is available, generate the code.
346
- *
347
  * @return int
348
  */
349
  public function getProductCode()
@@ -351,23 +351,23 @@ class TIG_PostNL_Model_Core_Shipment extends Mage_Core_Model_Abstract
351
  if ($this->getData('product_code')) {
352
  return $this->getData('product_code');
353
  }
354
-
355
  $productCode = $this->_getProductCode();
356
-
357
  $this->setProductCode($productCode);
358
  return $productCode;
359
  }
360
-
361
  /**
362
  * gets all shipping labels associated with this shipment
363
- *
364
  * @return array Array of TIG_PostNL_Model_Core_Shipment_Label objects
365
  */
366
  public function getLabels()
367
  {
368
  $labelCollection = Mage::getResourceModel('postnl_core/shipment_label_collection');
369
  $labelCollection->addFieldToFilter('parent_id', array('eq' => $this->getid()));
370
-
371
  /**
372
  * If the 'labels_printed' flag is false, yet there are labels present something has gone wrong.
373
  * Delete the labels so the module will generate new ones.
@@ -376,14 +376,14 @@ class TIG_PostNL_Model_Core_Shipment extends Mage_Core_Model_Abstract
376
  $this->deleteLabels();
377
  return array();
378
  }
379
-
380
  $labels = $labelCollection->getItems();
381
  return $labels;
382
  }
383
-
384
  /**
385
  * Get the amount of extra cover this shipment has.
386
- *
387
  * @return int | float
388
  */
389
  public function getExtraCoverAmount()
@@ -391,16 +391,16 @@ class TIG_PostNL_Model_Core_Shipment extends Mage_Core_Model_Abstract
391
  if ($this->hasData('extra_cover_amount')) {
392
  return $this->getData('extra_cover_amount');
393
  }
394
-
395
  return 0;
396
  }
397
-
398
  /**
399
  * Calculates the total weight of this shipment
400
- *
401
  * @param boolean $standardize Whether or not to convert the weight to kg
402
  * @param boolean $toGrams whether or not to convert the standardized weight to g
403
- *
404
  * @return float | int
405
  */
406
  public function getTotalWeight($standardize = false, $toGrams = false)
@@ -409,7 +409,7 @@ class TIG_PostNL_Model_Core_Shipment extends Mage_Core_Model_Abstract
409
  * get all items in the shipment
410
  */
411
  $items = $this->getShipment()->getAllItems();
412
-
413
  /**
414
  * calculate the total weight
415
  */
@@ -417,26 +417,26 @@ class TIG_PostNL_Model_Core_Shipment extends Mage_Core_Model_Abstract
417
  foreach ($items as $item) {
418
  $weight += ($item->getWeight() * $item->getQty());
419
  }
420
-
421
  if ($standardize !== true) {
422
  return $weight;
423
  }
424
-
425
  /**
426
  * standardize the weight to kg or g
427
  */
428
  $weight = $this->getHelper('cif')->standardizeWeight(
429
- $weight,
430
  $this->getStoreId(),
431
  $toGrams
432
  );
433
-
434
  return $weight;
435
  }
436
-
437
  /**
438
  * Calculates a shipment's base grand total based on it's shipment items
439
- *
440
  * @return float | null
441
  */
442
  public function getShipmentBaseGrandTotal()
@@ -444,7 +444,7 @@ class TIG_PostNL_Model_Core_Shipment extends Mage_Core_Model_Abstract
444
  if ($this->getData('shipment_base_grand_total')) {
445
  return $this->getData('shipment_base_grand_total');
446
  }
447
-
448
  /**
449
  * Check if this PostNL shipment has a linked Mage_Sales_Model_Order_Shipment object
450
  */
@@ -452,7 +452,7 @@ class TIG_PostNL_Model_Core_Shipment extends Mage_Core_Model_Abstract
452
  if (!$shipment) {
453
  return null;
454
  }
455
-
456
  /**
457
  * Loop through all associated shipment items and add each item's row total to the shipment's total
458
  */
@@ -464,7 +464,7 @@ class TIG_PostNL_Model_Core_Shipment extends Mage_Core_Model_Abstract
464
  * The base price of a shipment item is only available through it's associated order item
465
  */
466
  $basePrice = $shipmentItem->getOrderItem()->getBasePrice();
467
-
468
  /**
469
  * Calculate and add the shipment item's row total
470
  */
@@ -475,14 +475,14 @@ class TIG_PostNL_Model_Core_Shipment extends Mage_Core_Model_Abstract
475
  $this->setShipmentBaseGrandTotal($baseGrandTotal);
476
  return $baseGrandTotal;
477
  }
478
-
479
  /**
480
  * Gets the url for this shipment's main barcode
481
- *
482
  * @param boolean $forceNl
483
- *
484
  * @return string
485
- *
486
  * @see TIG_PostNL_Helper_Carrier::getBarcodeUrl()
487
  */
488
  public function getBarcodeUrl($forceNl = false)
@@ -490,27 +490,27 @@ class TIG_PostNL_Model_Core_Shipment extends Mage_Core_Model_Abstract
490
  if ($this->hasBarcodeUrl()) {
491
  return $this->getData('barcode_url');
492
  }
493
-
494
  $barcode = $this->getMainBarcode();
495
  if (!$barcode) {
496
  return false;
497
  }
498
-
499
  $helper = $this->getHelper('carrier');
500
-
501
  $locale = Mage::getStoreConfig('general/locale/code', $this->getStoreId());
502
  $lang = substr($locale, 0, 2);
503
-
504
  $url = $helper->getBarcodeUrl($barcode, $this->getShippingAddress(), $lang, $forceNl);
505
-
506
  $this->setBarcodeUrl($url);
507
  return $url;
508
  }
509
-
510
  /**
511
  * Gets the shipment's shipment type for intrnational shipments.
512
  * If no shipment type is defined, use the default 'commercial goods'.
513
- *
514
  * @return string | null
515
  */
516
  public function getShipmentType()
@@ -518,60 +518,60 @@ class TIG_PostNL_Model_Core_Shipment extends Mage_Core_Model_Abstract
518
  if ($this->getData('shipment_type')) {
519
  return $this->getData('shipment_type');
520
  }
521
-
522
  if (!$this->isGlobalShipment()) {
523
  return null;
524
  }
525
-
526
  $shipmentType = 'Commercial Goods';
527
  return $shipmentType;
528
  }
529
-
530
  /**
531
  * Gets the default product code for this shipment from the module's configuration
532
- *
533
  * @return string
534
- *
535
  * @todo implement pakjegemak
536
  */
537
  public function getDefaultProductCode()
538
  {
539
  $storeId = $this->getStoreId();
540
-
541
  if ($this->isPakjeGemakShipment()) {
542
  /**
543
  * PakjeGemak default option
544
  */
545
  $productCode = Mage::getStoreConfig(self::XML_PATH_DEFAULT_PAKJEGEMAK_PRODUCT_OPTION, $storeId);
546
  $this->_checkProductCodeAllowed($productCode);
547
-
548
  return $productCode;
549
  }
550
-
551
  if ($this->isEuShipment()) {
552
  /**
553
  * EU default option
554
  */
555
  $productCode = Mage::getStoreConfig(self::XML_PATH_DEFAULT_EU_PRODUCT_OPTION, $storeId);
556
  $this->_checkProductCodeAllowed($productCode);
557
-
558
  return $productCode;
559
  }
560
-
561
  if ($this->isGlobalShipment()) {
562
  /**
563
  * Global default option
564
  */
565
  $productCode = Mage::getStoreConfig(self::XML_PATH_DEFAULT_GLOBAL_PRODUCT_OPTION, $storeId);
566
  $this->_checkProductCodeAllowed($productCode);
567
-
568
  return $productCode;
569
  }
570
-
571
  /**
572
  * If the shipment is not EU or global, it's dutch (AKA a 'standard' shipment)
573
  */
574
-
575
  /**
576
  * Dutch shipments may use an alternative default option when the shipment's base grandtotal exceeds a specified amount
577
  */
@@ -587,25 +587,25 @@ class TIG_PostNL_Model_Core_Shipment extends Mage_Core_Model_Abstract
587
  */
588
  $productCode = Mage::getStoreConfig(self::XML_PATH_ALTERNATIVE_DEFAULT_OPTION, $storeId);
589
  $this->_checkProductCodeAllowed($productCode);
590
-
591
  return $productCode;
592
  }
593
  }
594
-
595
  /**
596
  * standard default option
597
  */
598
  $productCode = Mage::getStoreConfig(self::XML_PATH_DEFAULT_STANDARD_PRODUCT_OPTION, $storeId);
599
  $this->_checkProductCodeAllowed($productCode);
600
-
601
  return $productCode;
602
  }
603
-
604
  /**
605
  * Get a specific barcode for this shipment
606
- *
607
  * @param int | null $barcodeNumber Which barcode to get
608
- *
609
  * @return string | null
610
  */
611
  public function getBarcode($barcodeNumber = null)
@@ -614,18 +614,18 @@ class TIG_PostNL_Model_Core_Shipment extends Mage_Core_Model_Abstract
614
  $barcode = $this->getMainBarcode();
615
  return $barcode;
616
  }
617
-
618
  $barcode = Mage::getModel('postnl_core/shipment_barcode')
619
  ->loadByParentAndBarcodeNumber($this->getId(), $barcodeNumber);
620
-
621
  return $barcode->getBarcode();
622
  }
623
-
624
  /**
625
  * Get all barcodes associated with this shipment
626
- *
627
  * @param $asObject boolean Optional value to get the barcodes as entities, rather than an array of values
628
- *
629
  * @return array
630
  */
631
  public function getBarcodes($asObject = false)
@@ -633,52 +633,52 @@ class TIG_PostNL_Model_Core_Shipment extends Mage_Core_Model_Abstract
633
  $barcodeCollection = Mage::getResourceModel('postnl_core/shipment_barcode_collection');
634
  $barcodeCollection->addFieldToSelect(array('barcode', 'barcode_number'))
635
  ->addFieldToFilter('parent_id', array('eq' => $this->getId()));
636
-
637
  $barcodeCollection->getSelect()->order('barcode_number ASC');
638
-
639
  if ($asObject === false) {
640
  $barcodeNumbers = $barcodeCollection->getColumnValues('barcode_number');
641
  $barcodes = $barcodeCollection->getColumnValues('barcode');
642
-
643
  /**
644
  * Combine the arrays so that the barcode numbers are the keys and the barcodes themselves are the values
645
  */
646
  $barcodeArray = array_combine($barcodeNumbers, $barcodes);
647
  $barcodeArray[0] = $this->getMainBarcode();
648
-
649
  return $barcodeArray;
650
  }
651
-
652
  /**
653
  * Return all barcode entities.
654
  * N.B. Does not contain the main barcode as it is not part of the collection
655
  */
656
  return $barcodeCollection->getItems();
657
  }
658
-
659
  /****************************************************************************************************************************
660
  * SETTER METHODS
661
  ***************************************************************************************************************************/
662
-
663
  /**
664
  * Set an array of labels that are to be saved together
665
- *
666
  * @param array $labels
667
- *
668
  * @return TIG_PostNL_Model_Core_Shipment
669
  */
670
  public function setLabelsToSave($labels)
671
  {
672
  $this->_labelsToSave = $labels;
673
-
674
  return $this;
675
  }
676
-
677
  /**
678
  * Set an extra cover amount
679
- *
680
  * @param int $amount
681
- *
682
  * @return TIG_PostNL_Model_Core_Shipment
683
  */
684
  public function setExtraCoverAmount($amount)
@@ -691,17 +691,17 @@ class TIG_PostNL_Model_Core_Shipment extends Mage_Core_Model_Abstract
691
  if (!in_array($productCode, $extraCoverProductCodes)) {
692
  return $this;
693
  }
694
-
695
  $this->setData('extra_cover_amount', $amount);
696
-
697
  return $this;
698
  }
699
-
700
  /**
701
  * Sets a shipment's shipment type. This is required for GlobalPack shipments
702
- *
703
  * @param string $type
704
- *
705
  * @return TIG_PostNL_Model_Core_Shipment
706
  */
707
  public function setShipmentType($type)
@@ -712,22 +712,22 @@ class TIG_PostNL_Model_Core_Shipment extends Mage_Core_Model_Abstract
712
  if (!$this->isGlobalShipment()) {
713
  return $this;
714
  }
715
-
716
  /**
717
  * Convert shipment type to CIF-compatible version
718
  */
719
  $shipmentType = str_replace('_', ' ', $type);
720
  $shipmentType = ucwords($shipmentType);
721
-
722
  $this->setData('shipment_type', $shipmentType);
723
  return $this;
724
  }
725
-
726
  /**
727
  * Set this shipment's parcel count. Verifies that the requested amount does not exceed the maximum allowed.
728
- *
729
  * @param int $count
730
- *
731
  * @return TIG_PostNL_Model_Core_Shipment
732
  */
733
  public function setParcelCount($count)
@@ -737,7 +737,7 @@ class TIG_PostNL_Model_Core_Shipment extends Mage_Core_Model_Abstract
737
  $this->setData('parcel_count', $count);
738
  return $this;
739
  }
740
-
741
  if ($count > $maxParcelCount) {
742
  throw new TIG_PostNL_Exception(
743
  Mage::helper('postnl')->__(
@@ -748,175 +748,175 @@ class TIG_PostNL_Model_Core_Shipment extends Mage_Core_Model_Abstract
748
  'POSTNL-0068'
749
  );
750
  }
751
-
752
  $this->setData('parcel_count', $count);
753
  return $this;
754
  }
755
-
756
  /****************************************************************************************************************************
757
  * SHIPMENT LOCKING AND UNLOCKING FUNCTIONS
758
  ***************************************************************************************************************************/
759
-
760
  /**
761
  * Lock this shipment to prevent simultaneous execution
762
- *
763
  * @return TIG_PostNL_Model_Core_Shipment
764
  */
765
  public function lock()
766
  {
767
  $process = $this->getProcess();
768
  $process->lockAndBlock();
769
-
770
  return $this;
771
  }
772
-
773
  /**
774
  * Unlock this shipment
775
- *
776
  * @return TIG_PostNL_Model_Core_Shipment
777
  */
778
  public function unlock()
779
  {
780
  $process = $this->getProcess();
781
  $process->unlock();
782
-
783
  return $this;
784
  }
785
-
786
  /**
787
  * Check if this shipment is locked
788
- *
789
  * @return boolean
790
  */
791
  public function isLocked()
792
  {
793
  $process = $this->getProcess();
794
  $isLocked = $process->isLocked();
795
-
796
  return $isLocked;
797
  }
798
-
799
  /****************************************************************************************************************************
800
  * HAS- METHODS
801
  ***************************************************************************************************************************/
802
-
803
  /**
804
  * Check if the shipment has any associated labels
805
- *
806
  * @return boolean
807
  */
808
  public function hasLabels()
809
  {
810
  $labelCollection = Mage::getResourceModel('postnl_core/shipment_label_collection');
811
  $labelCollection->addFieldToFilter('parent_id', array('eq' => $this->getid()));
812
-
813
  if ($labelCollection->getSize() > 0) {
814
  return true;
815
  }
816
-
817
  return false;
818
  }
819
-
820
  /**
821
  * Checks if this shipment has extra cover
822
- *
823
  * @return boolean
824
  */
825
  public function hasExtraCover()
826
  {
827
  $productCode = $this->getProductCode();
828
  $extraCoverProductCodes = $this->getExtraCoverProductCodes();
829
-
830
  if (!in_array($productCode, $extraCoverProductCodes)) {
831
  return false;
832
  }
833
-
834
  if ($this->getExtraCoverAmount() < 1) {
835
  return false;
836
  }
837
-
838
  return true;
839
  }
840
-
841
  /**
842
  * Check if this shipment has a label of a given type
843
- *
844
  * @param string $labelType
845
- *
846
  * @return boolean
847
  */
848
  public function hasLabelType($labelType)
849
  {
850
  $coreResource = Mage::getSingleton('core/resource');
851
  $readConn = $coreResource->getConnection('core/read');
852
-
853
  $select = $readConn->select();
854
  $select->from($coreResource->getTableName('postnl_core/shipment_label', array('label_id')))
855
  ->where('`label_type` = ?', $labelType)
856
  ->where('`parent_id` = ?', $this->getId());
857
-
858
  $label = $readConn->fetchOne($select);
859
-
860
  if ($label === false) {
861
  return false;
862
  }
863
-
864
  return true;
865
  }
866
-
867
  /****************************************************************************************************************************
868
  * IS- AND CAN- METHODS
869
  ***************************************************************************************************************************/
870
-
871
  /**
872
  * Alias for magic getIsPakjeGemak()
873
- *
874
  * Please note the difference between this method and TIG_PostNL_Model_Core_Shipment::isPakjeGemakShipment
875
- *
876
  * @return integer
877
  */
878
  public function isPakjeGemak()
879
  {
880
  return $this->getIsPakjeGemak();
881
  }
882
-
883
  /**
884
  * Check if the shipping destination of this shipment is NL
885
- *
886
  * @return boolean
887
  */
888
  public function isDutchShipment()
889
  {
890
  $shippingDestination = $this->getShippingAddress()->getCountryId();
891
-
892
  if ($shippingDestination == 'NL') {
893
  return true;
894
  }
895
-
896
  return false;
897
  }
898
-
899
  /**
900
  * Check if the shipping destination of this shipment is a EU country
901
- *
902
  * @return boolean
903
  */
904
  public function isEuShipment()
905
  {
906
  $shippingDestination = $this->getShippingAddress()->getCountryId();
907
-
908
  $euCountries = $this->getHelper('cif')->getEuCountries();
909
-
910
  if (in_array($shippingDestination, $euCountries)) {
911
  return true;
912
  }
913
-
914
  return false;
915
  }
916
-
917
  /**
918
  * Check if the shipping destination of this shipment is global (not NL or EU)
919
- *
920
  * @return boolean
921
  */
922
  public function isGlobalShipment()
@@ -924,13 +924,13 @@ class TIG_PostNL_Model_Core_Shipment extends Mage_Core_Model_Abstract
924
  if (!$this->isDutchShipment() && !$this->isEuShipment()) {
925
  return true;
926
  }
927
-
928
  return false;
929
  }
930
-
931
  /**
932
  * Check if the currrent shipment is a PakjeGemak shipment.
933
- *
934
  * @return boolean
935
  */
936
  public function isPakjeGemakShipment()
@@ -938,42 +938,42 @@ class TIG_PostNL_Model_Core_Shipment extends Mage_Core_Model_Abstract
938
  if ($this->getIsPakjeGemak()) {
939
  return true;
940
  }
941
-
942
  $postnlOrder = Mage::getModel('postnl_checkout/order')->load($this->getOrderId(), 'order_id');
943
  if ($postnlOrder->getId() && $postnlOrder->getIsPakjeGemak()) {
944
  return true;
945
  }
946
-
947
  $pakjeGemakProductCodes = $this->getHelper('cif')->getPakjeGemakProductCodes();
948
  $productCode = $this->getData('product_code');
949
-
950
  if (!$productCode) {
951
  return false;
952
  }
953
-
954
  if (in_array($productCode, $pakjeGemakProductCodes)) {
955
  $this->setIsPakjeGemak(true);
956
  return true;
957
  }
958
-
959
  return false;
960
  }
961
-
962
  /**
963
  * Checks if this shipment is a COD shipment
964
- *
965
  * @return boolean
966
- *
967
  * @todo implement this method
968
  */
969
  public function isCod()
970
  {
971
  return false; //TODO implement this method
972
  }
973
-
974
  /**
975
  * Checks if this shipment is confirmed
976
- *
977
  * @return boolean
978
  */
979
  public function isConfirmed()
@@ -982,13 +982,13 @@ class TIG_PostNL_Model_Core_Shipment extends Mage_Core_Model_Abstract
982
  if ($confirmedStatus === self::CONFIRM_STATUS_CONFIRMED) {
983
  return true;
984
  }
985
-
986
  return false;
987
  }
988
-
989
  /**
990
  * Checks if the current entity may generate a barcode.
991
- *
992
  * @return boolean
993
  */
994
  public function canGenerateBarcode()
@@ -996,13 +996,13 @@ class TIG_PostNL_Model_Core_Shipment extends Mage_Core_Model_Abstract
996
  if (!$this->getShipmentId() && !$this->getShipment()) {
997
  return false;
998
  }
999
-
1000
  return true;
1001
  }
1002
-
1003
  /**
1004
  * Checks if the current entity can be confirmed.
1005
- *
1006
  * @return boolean
1007
  */
1008
  public function canConfirm($skipEuCheck = false)
@@ -1010,33 +1010,33 @@ class TIG_PostNL_Model_Core_Shipment extends Mage_Core_Model_Abstract
1010
  if ($this->isLocked()) {
1011
  return false;
1012
  }
1013
-
1014
  if ($this->getConfirmStatus() == self::CONFIRM_STATUS_CONFIRMED) {
1015
  return false;
1016
  }
1017
-
1018
  if (!$this->getShipmentId() && !$this->getShipment()) {
1019
  return false;
1020
  }
1021
-
1022
  if (!$this->getMainBarcode()) {
1023
  return false;
1024
  }
1025
-
1026
  if ($skipEuCheck === false
1027
- && $this->isEuShipment()
1028
  && !$this->getLabelsPrinted()
1029
  ) {
1030
  return false;
1031
  }
1032
-
1033
  return true;
1034
  }
1035
-
1036
  /**
1037
  * Checks if the current shipment is eligible for a shipping status update.
1038
  * Unconfirmed shipments, shipments whose labels are not yet printed or shipments that are already delivered are inelligible.
1039
- *
1040
  * @return boolean
1041
  */
1042
  public function canUpdateShippingStatus()
@@ -1044,48 +1044,48 @@ class TIG_PostNL_Model_Core_Shipment extends Mage_Core_Model_Abstract
1044
  if ($this->isLocked()) {
1045
  return false;
1046
  }
1047
-
1048
  if (self::CONFIRM_STATUS_CONFIRMED != $this->getConfirmStatus()) {
1049
  return false;
1050
  }
1051
-
1052
  if (self::SHIPPING_PHASE_DELIVERED == $this->getShippingPhase()) {
1053
  return false;
1054
  }
1055
-
1056
  if (!$this->getLabelsPrinted()) {
1057
  return false;
1058
  }
1059
-
1060
  if (!$this->hasLabels()) {
1061
  return false;
1062
  }
1063
-
1064
  if (!$this->getMainBarcode()) {
1065
  return false;
1066
  }
1067
-
1068
  return true;
1069
  }
1070
-
1071
  /**
1072
  * Checks if the current shipment is eligible for a complete shipping status update.
1073
  * For now the same conditions apply as a regular status update. This may change in a future update of the extension.
1074
- *
1075
  * @return boolean
1076
- *
1077
  * @see TIG_PostNL_Model_Core_Shipment::canUpdateShippingStatus()
1078
  */
1079
  public function canUpdateCompleteShippingStatus()
1080
  {
1081
  return $this->canUpdateShippingStatus();
1082
  }
1083
-
1084
  /**
1085
  * Checks if the current shipment can send a track & trace email to the customer.
1086
- *
1087
  * @param boolean $ignoreAlreadySent Flag to ignore the 'already sent' check
1088
- *
1089
  * @return boolean
1090
  */
1091
  public function canSendTrackAndTraceEmail($ignoreAlreadySent = false)
@@ -1093,30 +1093,58 @@ class TIG_PostNL_Model_Core_Shipment extends Mage_Core_Model_Abstract
1093
  if ($this->isLocked()) {
1094
  return false;
1095
  }
1096
-
1097
  if ($ignoreAlreadySent !== true && $this->getTrackAndTraceEmailSent()) {
1098
  return false;
1099
  }
1100
-
1101
  $storeId = $this->getStoreId();
1102
  $canSendTrackAndTrace = Mage::getStoreConfig(self::XML_PATH_SEND_TRACK_AND_TRACE_EMAIL, $storeId);
1103
  if (!$canSendTrackAndTrace) {
1104
  return false;
1105
  }
1106
-
1107
  return true;
1108
  }
1109
-
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1110
  /****************************************************************************************************************************
1111
  * CIF FUNCTIONALITY METHODS
1112
  ***************************************************************************************************************************/
1113
-
1114
  /**
1115
  * Generates barcodes for this postnl shipment.
1116
  * Barcodes are the basis for all CIF functionality and must therefore be generated before any further action is possible.
1117
- *
1118
  * @return TIG_PostNL_Model_Core_Shipment
1119
- *
1120
  * @throws TIG_PostNL_Exception
1121
  */
1122
  public function generateBarcodes()
@@ -1127,32 +1155,32 @@ class TIG_PostNL_Model_Core_Shipment extends Mage_Core_Model_Abstract
1127
  'POSTNL-0069'
1128
  );
1129
  }
1130
-
1131
  $this->lock();
1132
-
1133
  Mage::dispatchEvent('postnl_shipment_generatebarcode_before', array('shipment' => $this));
1134
-
1135
  /**
1136
  * Generate and save the main barcode
1137
  */
1138
  $mainBarcode = $this->_generateBarcode();
1139
  $this->setMainBarcode($mainBarcode);
1140
-
1141
  $parcelCount = $this->getParcelCount();
1142
  if (!$parcelCount) {
1143
  $parcelCount = $this->_calculateParcelCount();
1144
  }
1145
-
1146
  /**
1147
  * If this shipment consists of a single parcel or if it's an international shipment we only need the main barcode
1148
  */
1149
  if ($parcelCount < 2 || $this->isGlobalShipment()) {
1150
  Mage::dispatchEvent('postnl_shipment_generatebarcode_after', array('shipment' => $this));
1151
  $this->unlock();
1152
-
1153
  return $this;
1154
  }
1155
-
1156
  /**
1157
  * Generate a barcode for each parcel and save it
1158
  */
@@ -1160,78 +1188,78 @@ class TIG_PostNL_Model_Core_Shipment extends Mage_Core_Model_Abstract
1160
  $barcode = $this->_generateBarcode();
1161
  $this->_addBarcode($barcode, $i);
1162
  }
1163
-
1164
  Mage::dispatchEvent('postnl_shipment_generatebarcode_after', array('shipment' => $this));
1165
  $this->unlock();
1166
  return $this;
1167
  }
1168
-
1169
  /**
1170
  * Generates a single barcode for this postnl shipment.
1171
- *
1172
  * @return string
1173
- *
1174
  * @throws TIG_PostNL_Exception
1175
  */
1176
  protected function _generateBarcode()
1177
  {
1178
  $shipment = $this->getShipment();
1179
-
1180
  $cif = Mage::getModel('postnl_core/cif');
1181
  $barcodeType = $this->getHelper('cif')->getBarcodeTypeForShipment($this);
1182
-
1183
  $barcode = $cif->generateBarcode($shipment, $barcodeType);
1184
-
1185
  if (!$barcode) {
1186
  throw new TIG_PostNL_Exception(
1187
  Mage::helper('postnl')->__('Unable to generate barcode for this shipment: %s', $shipment->getId()),
1188
  'POSTNL-0070'
1189
  );
1190
  }
1191
-
1192
  /**
1193
  * If the generated barcode already exists a new one needs to be generated.
1194
  */
1195
  if ($this->getHelper('cif')->barcodeExists($barcode)) {
1196
  return $this->_generateBarcode();
1197
  }
1198
-
1199
  return $barcode;
1200
  }
1201
-
1202
  /**
1203
  * Generates a shipping labels for a shipment without confirming it with PostNL.
1204
- *
1205
  * @return TIG_PostNL_Model_Core_Shipment
1206
- *
1207
  * @throws TIG_PostNL_Exception
1208
  */
1209
  public function generateLabel()
1210
  {
1211
  $this->lock();
1212
-
1213
  Mage::dispatchEvent('postnl_shipment_generatelabel_before', array('shipment' => $this));
1214
-
1215
  $parcelCount = $this->getparcelCount();
1216
  if (!$parcelCount) {
1217
  $parcelCount = $this->_calculateParcelCount();
1218
  }
1219
-
1220
  /**
1221
  * Generate labels purely for the main shipment
1222
  */
1223
  if ($parcelCount < 2) {
1224
  $labels = $this->_generateLabel();
1225
  $this->addLabels($labels);
1226
-
1227
  $this->_saveLabels();
1228
-
1229
  Mage::dispatchEvent('postnl_shipment_generatelabel_after', array('shipment' => $this));
1230
-
1231
  $this->unlock();
1232
  return $this;
1233
  }
1234
-
1235
  /**
1236
  * Generate labels for each parcel in the shipment
1237
  */
@@ -1239,27 +1267,27 @@ class TIG_PostNL_Model_Core_Shipment extends Mage_Core_Model_Abstract
1239
  $labels = $this->_generateLabel(false, $i);
1240
  $this->addLabels($labels);
1241
  }
1242
-
1243
  $this->_saveLabels();
1244
-
1245
  Mage::dispatchEvent('postnl_shipment_generatelabel_after', array('shipment' => $this));
1246
-
1247
  $this->unlock();
1248
  return $this;
1249
  }
1250
-
1251
  /**
1252
  * Get a shipping label from PostNL for a single parcel or a whole shipment
1253
- *
1254
  * @param boolean $confirm Whether or not to also confirm the shipment
1255
  * @param int | null $barcodeNumber An optional barcode number. If this parameter is null, the main barcode will be used
1256
- *
1257
  * @return array
1258
  */
1259
  protected function _generateLabel($confirm = false, $barcodeNumber = false)
1260
  {
1261
  $mainBarcode = $this->getMainBarcode();
1262
-
1263
  /**
1264
  * if $barcodeNumber is false, this is a single parcel shipment
1265
  */
@@ -1270,41 +1298,41 @@ class TIG_PostNL_Model_Core_Shipment extends Mage_Core_Model_Abstract
1270
  $barcode = $this->getBarcode($barcodeNumber);
1271
  $barcodeNumber++; //while barcode numbers start at 0, shipment numbers start at 1
1272
  }
1273
-
1274
  $cif = Mage::getModel('postnl_core/cif');
1275
-
1276
  if ($confirm === false) {
1277
  $result = $cif->generateLabelsWithoutConfirm($this, $barcode, $mainBarcode, $barcodeNumber);
1278
  } else {
1279
  $result = $cif->generateLabels($this, $barcode, $mainBarcode, $barcodeNumber);
1280
  }
1281
-
1282
  if (!isset($result->Labels) || !isset($result->Labels->Label)) {
1283
  throw new TIG_PostNL_Exception(
1284
  Mage::helper('postnl')->__(
1285
- 'The confirmAndPrintLabel action returned an invalid response: %s',
1286
  var_export($response, true)
1287
  ),
1288
  'POSTNL-0071'
1289
  );
1290
  }
1291
  $labels = $result->Labels->Label;
1292
-
1293
  /**
1294
  * If this is an EU shipment and a non-combi label was returned, the product code needs to be updated
1295
  */
1296
  if ($this->isEuShipment() && !$this->_isCombiLabel()) {
1297
  $this->setProductCode($result->ProductCodeDelivery);
1298
  }
1299
-
1300
  return $labels;
1301
  }
1302
-
1303
  /**
1304
  * Confirm the shipment with PostNL without generating new labels
1305
- *
1306
  * @return TIG_PostNL_Model_Core_Shipment
1307
- *
1308
  * @throws TIG_PostNL_Exception
1309
  */
1310
  public function confirm()
@@ -1315,16 +1343,16 @@ class TIG_PostNL_Model_Core_Shipment extends Mage_Core_Model_Abstract
1315
  'POSTNL-0109'
1316
  );
1317
  }
1318
-
1319
  $this->lock();
1320
-
1321
  Mage::dispatchEvent('postnl_shipment_confirm_before', array('shipment' => $this));
1322
-
1323
  $parcelCount = $this->getparcelCount();
1324
  if (!$parcelCount) {
1325
  $parcelCount = $this->_calculateParcelCount();
1326
  }
1327
-
1328
  /**
1329
  * Only confirm the main shipment
1330
  */
@@ -1333,13 +1361,13 @@ class TIG_PostNL_Model_Core_Shipment extends Mage_Core_Model_Abstract
1333
 
1334
  $this->setConfirmStatus(self::CONFIRM_STATUS_CONFIRMED)
1335
  ->setConfirmedAt(Mage::getModel('core/date')->gmtTimestamp());
1336
-
1337
  Mage::dispatchEvent('postnl_shipment_confirm_after', array('shipment' => $this));
1338
-
1339
  $this->unlock();
1340
  return $this;
1341
  }
1342
-
1343
  /**
1344
  * onfirm each parcel in the shipment seperately
1345
  */
@@ -1349,26 +1377,26 @@ class TIG_PostNL_Model_Core_Shipment extends Mage_Core_Model_Abstract
1349
 
1350
  $this->setConfirmStatus(self::CONFIRM_STATUS_CONFIRMED)
1351
  ->setConfirmedAt(Mage::getModel('core/date')->gmtTimestamp());
1352
-
1353
  Mage::dispatchEvent('postnl_shipment_confirm_after', array('shipment' => $this));
1354
-
1355
  $this->unlock();
1356
  return $this;
1357
  }
1358
-
1359
  /**
1360
  * Confirms the shipment using CIF
1361
- *
1362
  * @param int | null $barcodeNumber
1363
- *
1364
  * @return TIG_PostNL_Model_Core_Shipment
1365
- *
1366
  * @throws TIG_PostNL_Exception
1367
  */
1368
  protected function _confirm($barcodeNumber = false)
1369
  {
1370
  $mainBarcode = $this->getMainBarcode();
1371
-
1372
  /**
1373
  * if $barcodeNumber is false, this is a single parcel shipment
1374
  */
@@ -1379,38 +1407,38 @@ class TIG_PostNL_Model_Core_Shipment extends Mage_Core_Model_Abstract
1379
  $barcode = $this->getBarcode($barcodeNumber);
1380
  $barcodeNumber++; //while barcode numbers start at 0, shipment numbers start at 1
1381
  }
1382
-
1383
  $cif = Mage::getModel('postnl_core/cif');
1384
  $result = $cif->confirmShipment($this, $barcode, $mainBarcode, $barcodeNumber);
1385
-
1386
  $responseShipment = $result->ConfirmingResponseShipment;
1387
-
1388
  /**
1389
  * If the ConfirmingResponseShipment is an object, it means only one shipment was confirmed and the returned barcode
1390
  * has to be the shipment's main barcode.
1391
  */
1392
- if (is_object($responseShipment)
1393
  && isset($responseShipment->Barcode)
1394
  && $responseShipment->Barcode == $barcode
1395
  ) {
1396
  return $this;
1397
  }
1398
-
1399
  /**
1400
  * If the ConfirmingResponseShipment is an array, it may indicate multiple shipments were confirmed. We need to check the
1401
  * first shipment's barcode to see if it matches the main bartcode.
1402
  */
1403
  if (is_array($responseShipment)) {
1404
  $mainResponseShipment = $responseShipment[0];
1405
-
1406
- if (is_object($mainResponseShipment)
1407
  && isset($mainResponseShipment->Barcode)
1408
  && $mainResponseShipment->Barcode == $barcode
1409
  ) {
1410
  return $this;
1411
  }
1412
  }
1413
-
1414
  /**
1415
  * The response was not valid; throw an exception
1416
  */
@@ -1419,12 +1447,12 @@ class TIG_PostNL_Model_Core_Shipment extends Mage_Core_Model_Abstract
1419
  'POSTNL-0072'
1420
  );
1421
  }
1422
-
1423
  /**
1424
  * Generates a shipping label and confirms the shipment with postNL.
1425
- *
1426
  * @return TIG_PostNL_Model_Core_Shipment
1427
- *
1428
  * @throws TIG_PostNL_Exception
1429
  */
1430
  public function confirmAndGenerateLabel()
@@ -1435,36 +1463,36 @@ class TIG_PostNL_Model_Core_Shipment extends Mage_Core_Model_Abstract
1435
  'POSTNL-0110'
1436
  );
1437
  }
1438
-
1439
  $this->lock();
1440
-
1441
  Mage::dispatchEvent('postnl_shipment_confirm_before', array('shipment' => $this));
1442
  Mage::dispatchEvent('postnl_shipment_confirmandgeneratelabel_before', array('shipment' => $this));
1443
-
1444
  $parcelCount = $this->getparcelCount();
1445
  if (!$parcelCount) {
1446
  $parcelCount = $this->_calculateParcelCount();
1447
  }
1448
-
1449
  /**
1450
  * Confirm and generate labels purely for the main shipment
1451
  */
1452
  if ($parcelCount < 2) {
1453
  $labels = $this->_generateLabel(true);
1454
  $this->addLabels($labels);
1455
-
1456
  $this->setConfirmStatus(self::CONFIRM_STATUS_CONFIRMED)
1457
  ->setConfirmedAt(Mage::getModel('core/date')->gmtTimestamp());
1458
-
1459
  $this->_saveLabels();
1460
-
1461
  Mage::dispatchEvent('postnl_shipment_confirm_after', array('shipment' => $this));
1462
  Mage::dispatchEvent('postnl_shipment_confirmandgeneratelabel_after', array('shipment' => $this));
1463
-
1464
  $this->unlock();
1465
  return $this;
1466
  }
1467
-
1468
  /**
1469
  * Confirm and generate labels for each parcel in the shipment
1470
  */
@@ -1472,24 +1500,24 @@ class TIG_PostNL_Model_Core_Shipment extends Mage_Core_Model_Abstract
1472
  $labels = $this->_generateLabel(true, $i);
1473
  $this->addLabels($labels);
1474
  }
1475
-
1476
  $this->setConfirmStatus(self::CONFIRM_STATUS_CONFIRMED)
1477
  ->setConfirmedAt(Mage::getModel('core/date')->gmtTimestamp());
1478
-
1479
  $this->_saveLabels();
1480
-
1481
  Mage::dispatchEvent('postnl_shipment_confirm_after', array('shipment' => $this));
1482
  Mage::dispatchEvent('postnl_shipment_confirmandgeneratelabel_after', array('shipment' => $this));
1483
-
1484
  $this->unlock();
1485
  return $this;
1486
  }
1487
-
1488
  /**
1489
  * Requests a shipping status update for this shipment
1490
- *
1491
  * @return TIG_PostNL_Model_Core_Shipment
1492
- *
1493
  * @throws TIG_PostNL_Exception
1494
  */
1495
  public function updateShippingStatus()
@@ -1500,33 +1528,33 @@ class TIG_PostNL_Model_Core_Shipment extends Mage_Core_Model_Abstract
1500
  'POSTNL-0073'
1501
  );
1502
  }
1503
-
1504
  $this->lock();
1505
-
1506
  Mage::dispatchEvent('postnl_shipment_updateshippingstatus_before', array('shipment' => $this));
1507
-
1508
  $cif = Mage::getModel('postnl_core/cif');
1509
  $result = $cif->getShipmentStatus($this);
1510
-
1511
  $currentPhase = $result->Status->CurrentPhaseCode;
1512
-
1513
  if (!$currentPhase) {
1514
  return $this;
1515
  }
1516
-
1517
  $this->setShippingPhase($currentPhase);
1518
-
1519
  Mage::dispatchEvent('postnl_shipment_updateshippingstatus_after', array('shipment' => $this));
1520
-
1521
  $this->unlock();
1522
  return $this;
1523
  }
1524
-
1525
  /**
1526
  * Update this shipment's status history
1527
- *
1528
  * @param StdClass $oldStatuses
1529
- *
1530
  * @return TIG_PostNL_Model_Core_Shipment
1531
  */
1532
  public function updateCompleteShippingStatus()
@@ -1537,37 +1565,37 @@ class TIG_PostNL_Model_Core_Shipment extends Mage_Core_Model_Abstract
1537
  'POSTNL-0074'
1538
  );
1539
  }
1540
-
1541
  $this->lock();
1542
-
1543
  Mage::dispatchEvent('postnl_shipment_updatecompleteshippingstatus_before', array('shipment' => $this));
1544
-
1545
  $cif = Mage::getModel('postnl_core/cif');
1546
  $result = $cif->getCompleteShipmentStatus($this);
1547
-
1548
  /**
1549
  * Update the shipment's shipping phase
1550
  */
1551
  $currentPhase = $result->Status->CurrentPhaseCode;
1552
  $this->setShippingPhase($currentPhase);
1553
-
1554
  if (!isset($result->Events->CompleteStatusResponseEvent)) {
1555
  $this->unlock();
1556
  return $this;
1557
  }
1558
-
1559
  /**
1560
  * get the complete event history
1561
  */
1562
  $completeStatusHistory = $result->Events->CompleteStatusResponseEvent;
1563
  $completeStatusHistory = $this->_sortStatusHistory($completeStatusHistory);
1564
-
1565
  /**
1566
  * Update the shipments status history
1567
  */
1568
  foreach ($completeStatusHistory as $status) {
1569
  $statusHistory = Mage::getModel('postnl_core/shipment_status_history');
1570
-
1571
  /**
1572
  * Check if a status history item exists for the given code and shipment id.
1573
  * If not, create a new one
@@ -1575,7 +1603,7 @@ class TIG_PostNL_Model_Core_Shipment extends Mage_Core_Model_Abstract
1575
  if (!$statusHistory->statusHistoryIsNew($this->getId(), $status)) {
1576
  continue;
1577
  }
1578
-
1579
  $timestamp = Mage::getModel('core/date')->gmtTimestamp($status->TimeStamp);
1580
  $statusHistory->setParentId($this->getId())
1581
  ->setCode($status->Code)
@@ -1587,51 +1615,51 @@ class TIG_PostNL_Model_Core_Shipment extends Mage_Core_Model_Abstract
1587
  ->setTimestamp($timestamp)
1588
  ->save();
1589
  }
1590
-
1591
  $this->setStatusHistoryUpdatedAt(Mage::getModel('core/date')->gmtTimestamp());
1592
-
1593
  Mage::dispatchEvent('postnl_shipment_updatecompleteshippingstatus_after', array('shipment' => $this));
1594
-
1595
  $this->unlock();
1596
-
1597
  return $this;
1598
  }
1599
-
1600
  /****************************************************************************************************************************
1601
  * TRACKING METHODS
1602
  ***************************************************************************************************************************/
1603
-
1604
  /**
1605
  * Adds Magento tracking information to the order containing the previously retrieved barcode
1606
- *
1607
  * @return TIG_PostNL_Model_Core_Shipment
1608
- *
1609
  * @throws TIG_PostNL_Exception
1610
  */
1611
  public function addTrackingCodeToShipment()
1612
  {
1613
  $shipment = $this->getShipment();
1614
  $barcode = $this->getMainBarcode();
1615
-
1616
  if (!$shipment || !$barcode) {
1617
  throw new TIG_PostNL_Exception(
1618
  Mage::helper('postnl')->__('Unable to add tracking info: no barcode or shipment available.'),
1619
  'POSTNL-0075'
1620
  );
1621
  }
1622
-
1623
  $carrierCode = self::POSTNL_CARRIER_CODE;
1624
  $carrierTitle = Mage::getStoreConfig('carriers/' . $carrierCode . '/name', $shipment->getStoreId());
1625
-
1626
  $data = array(
1627
  'carrier_code' => $carrierCode,
1628
  'title' => $carrierTitle,
1629
  'number' => $barcode,
1630
  );
1631
-
1632
  $track = Mage::getModel('sales/order_shipment_track')->addData($data);
1633
  $shipment->addTrack($track);
1634
-
1635
  /**
1636
  * Save the Mage_Sales_Order_Shipment object and the TIG_PostNL_Model_Core_Shipment objects simultaneously
1637
  */
@@ -1639,16 +1667,16 @@ class TIG_PostNL_Model_Core_Shipment extends Mage_Core_Model_Abstract
1639
  ->addObject($this)
1640
  ->addObject($shipment)
1641
  ->save();
1642
-
1643
  return $this;
1644
  }
1645
 
1646
  /**
1647
  * Send a track & trace email to the customer containing a link to the 'mijnpakket' environment where they
1648
  * can track their shipment.
1649
- *
1650
  * @param boolean $ignoreAlreadySent Flag to ignore the 'already sent' check
1651
- *
1652
  * @return TIG_PostNL_Model_Core_Shipment
1653
  */
1654
  public function sendTrackAndTraceEmail($ignoreAlreadySent = false)
@@ -1659,26 +1687,26 @@ class TIG_PostNL_Model_Core_Shipment extends Mage_Core_Model_Abstract
1659
  'POSTNL-0076'
1660
  );
1661
  }
1662
-
1663
  $oldStoreId = Mage::app()->getStore()->getId();
1664
  $storeId = $this->getStoreId();
1665
-
1666
  $template = Mage::getStoreConfig(self::XML_PATH_TRACK_AND_TRACE_EMAIL_TEMPLATE, $storeId);
1667
  $mailTemplate = Mage::getModel('core/email_template');
1668
-
1669
  $shippingAddress = $this->getShippingAddress();
1670
  $recipient = array(
1671
  'email' => $this->getShipment()->getOrder()->getCustomerEmail(),
1672
  'name' => $shippingAddress->getFirstname() . ' ' . $shippingAddress->getLastname(),
1673
  );
1674
-
1675
  $mailTemplate->setDesignConfig(
1676
  array(
1677
- 'area' => 'frontend',
1678
  'store' => $storeId
1679
  )
1680
  );
1681
-
1682
  $shipment = $this->getShipment();
1683
  $order = $shipment->getOrder();
1684
  $templateVariables = array(
@@ -1690,7 +1718,7 @@ class TIG_PostNL_Model_Core_Shipment extends Mage_Core_Model_Abstract
1690
  'customer' => $order->getCustomer(),
1691
  'quote' => $order->getQuote(),
1692
  );
1693
-
1694
  $orderModel = Mage::getConfig()->getModelClassName('sales/order');
1695
  $success = $mailTemplate->sendTransactional(
1696
  $template,
@@ -1699,27 +1727,27 @@ class TIG_PostNL_Model_Core_Shipment extends Mage_Core_Model_Abstract
1699
  $recipient['name'],
1700
  $templateVariables
1701
  );
1702
-
1703
  if ($success === false) {
1704
  throw new TIG_PostNL_Exception(
1705
  Mage::helper('postnl')->__('Unable to send track and trace email for shipment #', $this->getShipmentId()),
1706
  'POSTNL-0077'
1707
  );
1708
  }
1709
-
1710
  return $this;
1711
  }
1712
-
1713
  /****************************************************************************************************************************
1714
  * BARCODE PROCESSING METHODS
1715
  ***************************************************************************************************************************/
1716
-
1717
  /**
1718
  * Add a barcode to this shipment's barcode collection
1719
- *
1720
  * @param string $barcode The barcode to add
1721
  * @param int $barcodeNumber The number of this barcode
1722
- *
1723
  * @return TIG_PostNL_Model_Core_Shipment
1724
  */
1725
  protected function _addBarcode($barcode, $barcodeNumber)
@@ -1729,19 +1757,19 @@ class TIG_PostNL_Model_Core_Shipment extends Mage_Core_Model_Abstract
1729
  ->setBarcode($barcode)
1730
  ->setBarcodeNumber($barcodeNumber)
1731
  ->save();
1732
-
1733
  return $this;
1734
  }
1735
-
1736
  /****************************************************************************************************************************
1737
  * LABEL PROCESSING METHODS
1738
  ***************************************************************************************************************************/
1739
-
1740
  /**
1741
  * Add labels to this shipment
1742
- *
1743
  * @param mixed $labels An array of labels or a single label object
1744
- *
1745
  * @return TIG_PostNL_Model_Core_Shipment
1746
  */
1747
  public function addLabels($labels)
@@ -1753,95 +1781,95 @@ class TIG_PostNL_Model_Core_Shipment extends Mage_Core_Model_Abstract
1753
  $this->_addLabel($labels);
1754
  return $this;
1755
  }
1756
-
1757
  /**
1758
  * Add multiple labels
1759
  */
1760
  foreach ($labels as $label) {
1761
  $this->_addLabel($label);
1762
  }
1763
-
1764
  return $this;
1765
  }
1766
-
1767
  /**
1768
  * Add a label to this shipment
1769
- *
1770
  * @param stdClass $label
1771
- *
1772
  * @return TIG_PostNL_Model_Core_Shipment
1773
  */
1774
  protected function _addLabel($label)
1775
  {
1776
  $labelType = $label->Labeltype;
1777
-
1778
  if ($this->_isCombiLabel()) {
1779
  $labelType = 'Label-combi';
1780
  }
1781
-
1782
  $postnlLabel = Mage::getModel('postnl_core/shipment_label');
1783
  $postnlLabel->setParentId($this->getId())
1784
  ->setLabel(base64_encode($label->Content))
1785
  ->setLabelType($labelType);
1786
-
1787
  $this->_addLabelToSave($postnlLabel);
1788
-
1789
  return $this;
1790
  }
1791
-
1792
  /**
1793
  * Store the label in an array to be saved later
1794
- *
1795
  * @param TIG_PostNL_Model_Core_Shipment_Label $label
1796
- *
1797
  * @return TIG_PostNL_Model_Core_Shipment
1798
  */
1799
  protected function _addLabelToSave($label)
1800
  {
1801
  $labelsToSave = $this->getlabelsToSave();
1802
-
1803
  $labelsToSave[] = $label;
1804
-
1805
  $this->setLabelsToSave($labelsToSave);
1806
-
1807
  return $this;
1808
  }
1809
-
1810
  /**
1811
  * Save all newly added labels at once
1812
- *
1813
  * @return TIG_PostNL_Model_Core_Shipment
1814
  */
1815
  protected function _saveLabels()
1816
  {
1817
  $transactionSave = Mage::getModel('core/resource_transaction');
1818
-
1819
  /**
1820
  * Add all labels to the transaction
1821
  */
1822
  $labelsToSave = $this->getLabelsToSave();
1823
-
1824
  Mage::dispatchEvent('postnl_shipment_savelabels_before', array('shipment' => $this, 'labels' => $labelsToSave));
1825
-
1826
  foreach ($labelsToSave as $label) {
1827
  $transactionSave->addObject($label);
1828
  }
1829
-
1830
  /**
1831
  * Save the transaction
1832
  */
1833
  $transactionSave->save();
1834
-
1835
  Mage::dispatchEvent('postnl_shipment_savelabels_after', array('shipment' => $this, 'labels' => $labelsToSave));
1836
-
1837
  return $this;
1838
  }
1839
-
1840
  /**
1841
  * Check if the returned label is a combi-label
1842
- *
1843
  * @param TIG_PostNL_Model_Core_Shipment_label
1844
- *
1845
  * @return boolean
1846
  */
1847
  protected function _isCombiLabel()
@@ -1849,7 +1877,7 @@ class TIG_PostNL_Model_Core_Shipment extends Mage_Core_Model_Abstract
1849
  if (!$this->isEuShipment()) {
1850
  return false;
1851
  }
1852
-
1853
  /**
1854
  * All EU shipments will by default request a combi label. If no warnings were sent by CIF it means everything
1855
  * went as expected and a combi-label was returned.
@@ -1858,7 +1886,7 @@ class TIG_PostNL_Model_Core_Shipment extends Mage_Core_Model_Abstract
1858
  if (!$warnings) {
1859
  return true;
1860
  }
1861
-
1862
  /**
1863
  * Check each warning if the code matches the EPS combi label warning code
1864
  */
@@ -1867,19 +1895,19 @@ class TIG_PostNL_Model_Core_Shipment extends Mage_Core_Model_Abstract
1867
  return false;
1868
  }
1869
  }
1870
-
1871
  return true;
1872
  }
1873
-
1874
  /****************************************************************************************************************************
1875
  * STATUS PROCESSING METHODS
1876
  ***************************************************************************************************************************/
1877
-
1878
  /**
1879
  * Sort a status history array based on the time the status was assigned
1880
- *
1881
  * @param array $statusHistory
1882
- *
1883
  * @return array
1884
  */
1885
  protected function _sortStatusHistory($statusHistory)
@@ -1891,21 +1919,21 @@ class TIG_PostNL_Model_Core_Shipment extends Mage_Core_Model_Abstract
1891
  foreach ($statusHistory as $status) {
1892
  $timestamp = $status->TimeStamp;
1893
  $timestamp = strtotime($timestamp);
1894
-
1895
  $sortedHistory[$timestamp] = $status;
1896
  }
1897
-
1898
  /**
1899
  * Sort the array based on the timestamps
1900
  */
1901
  ksort($sortedHistory);
1902
-
1903
  /**
1904
  * Return only the values (the statusses) of the array
1905
  */
1906
  return array_values($sortedHistory);
1907
  }
1908
-
1909
  /****************************************************************************************************************************
1910
  * PRODUCT CODE METHODS
1911
  ***************************************************************************************************************************/
@@ -1913,7 +1941,7 @@ class TIG_PostNL_Model_Core_Shipment extends Mage_Core_Model_Abstract
1913
  /**
1914
  * Gets the product code for this shipment. If specific options have been selected
1915
  * those will be used. Otherwise the default options will be used from system/config
1916
- *
1917
  * @return int
1918
  */
1919
  protected function _getProductCode()
@@ -1924,51 +1952,51 @@ class TIG_PostNL_Model_Core_Shipment extends Mage_Core_Model_Abstract
1924
  if (Mage::registry('postnl_product_option')) {
1925
  $productCode = Mage::registry('postnl_product_option');
1926
  $this->_checkProductCodeAllowed($productCode);
1927
-
1928
  return $productCode;
1929
  }
1930
-
1931
  /**
1932
  * Use default options
1933
  */
1934
  $productCode = $this->getDefaultProductCode();
1935
-
1936
  return $productCode;
1937
  }
1938
-
1939
  /**
1940
  * Checks if a given product code is allowed for the current shipments. Throws an exception if not.
1941
- *
1942
  * @param string $productCode
1943
- *
1944
  * @return boolean
1945
- *
1946
  * @throws TIG_PostNL_Exception
1947
  */
1948
  protected function _checkProductCodeAllowed($productCode)
1949
  {
1950
  $cifHelper = $this->getHelper('cif');
1951
  $allowedProductCodes = array();
1952
-
1953
  /**
1954
  * PakjeGemak shipments are also dutch shipments
1955
  */
1956
  if ($this->isDutchShipment() && $this->isPakjeGemakShipment()) {
1957
  $allowedProductCodes = $cifHelper->getPakjeGemakProductCodes();
1958
  }
1959
-
1960
  /**
1961
  * Here we specifically want shipments that are dutch, but not PakjeGemak
1962
  */
1963
  if ($this->isDutchShipment() && !$this->isPakjeGemakShipment()) {
1964
  $allowedProductCodes = $cifHelper->getStandardProductCodes();
1965
  }
1966
-
1967
  if ($this->isEuShipment()) {
1968
  $allowedProductCodes = $cifHelper->getEuProductCodes();
1969
-
1970
  }
1971
-
1972
  if ($this->isGlobalShipment()) {
1973
  if (!$cifHelper->isGlobalAllowed()) {
1974
  throw new TIG_PostNL_Exception(
@@ -1976,10 +2004,10 @@ class TIG_PostNL_Model_Core_Shipment extends Mage_Core_Model_Abstract
1976
  'POSTNL-0078'
1977
  );
1978
  }
1979
-
1980
  $allowedProductCodes = $cifHelper->getGlobalProductCodes();
1981
  }
1982
-
1983
  /**
1984
  * Check if the product code is allowed
1985
  */
@@ -1989,7 +2017,7 @@ class TIG_PostNL_Model_Core_Shipment extends Mage_Core_Model_Abstract
1989
  'POSTNL-0078'
1990
  );
1991
  }
1992
-
1993
  /**
1994
  * Check if the product code is restricted to certain countries
1995
  */
@@ -1997,7 +2025,7 @@ class TIG_PostNL_Model_Core_Shipment extends Mage_Core_Model_Abstract
1997
  if ($allowedCountries === false) {
1998
  return true;
1999
  }
2000
-
2001
  /**
2002
  * Check if the destination country of this shipment is allowed
2003
  */
@@ -2008,52 +2036,52 @@ class TIG_PostNL_Model_Core_Shipment extends Mage_Core_Model_Abstract
2008
  'POSTNL-0078'
2009
  );
2010
  }
2011
-
2012
  return true;
2013
  }
2014
 
2015
  /**
2016
  * Checks if a given product code is only allowed for a specific country
2017
- *
2018
  * @return boolean|array Either false if the code is not restricted, or otherwise an array of allowed country IDs
2019
  */
2020
  protected function _isCodeRestricted($code)
2021
  {
2022
  $countryRestrictedCodes = $this->getHelper('cif')->getCountryRestrictedProductCodes();
2023
-
2024
  /**
2025
  * Check if the supplied code is restricted
2026
  */
2027
  if (!array_key_exists($code, $countryRestrictedCodes)) {
2028
  return false;
2029
  }
2030
-
2031
  /**
2032
  * Get the countries that are allowed
2033
  */
2034
  $allowedCountries = $countryRestrictedCodes[$code];
2035
  return $allowedCountries;
2036
  }
2037
-
2038
  /****************************************************************************************************************************
2039
  * ADDITIONAL SHIPMENT OPTIONS
2040
  ***************************************************************************************************************************/
2041
-
2042
  /**
2043
  * Public alias for _saveAdditionalShippingOptions()
2044
- *
2045
  * @return TIG_PostNL_Model_Core_Shipment
2046
- *
2047
  * @see TIG_PostNL_Model_Core_Shipment::_saveAdditionalShippingOptions()
2048
  */
2049
  public function saveAdditionalShippingOptions()
2050
  {
2051
  return $this->_saveAdditionalShippingOptions();
2052
  }
2053
-
2054
  /**
2055
  * Stores additionally selected shipping options
2056
- *
2057
  * @return TIG_PostNL_Model_Core_Shipment
2058
  */
2059
  protected function _saveAdditionalShippingOptions()
@@ -2062,27 +2090,27 @@ class TIG_PostNL_Model_Core_Shipment extends Mage_Core_Model_Abstract
2062
  if (!$additionalOptions || !is_array($additionalOptions)) {
2063
  return $this;
2064
  }
2065
-
2066
  foreach($additionalOptions as $option => $value) {
2067
  $this->setDataUsingMethod($option, $value);
2068
  }
2069
-
2070
  Mage::dispatchEvent(
2071
- 'postnl_shipment_saveadditionaloptions_after',
2072
  array(
2073
- 'shipment' => $this,
2074
  'options' => $additionalOptions
2075
  )
2076
  );
2077
-
2078
  Mage::unRegister('postnl_additional_options');
2079
-
2080
  return $this;
2081
  }
2082
-
2083
  /**
2084
  * Get the number of parcels in this shipment
2085
- *
2086
  * @return int
2087
  */
2088
  protected function _calculateParcelCount()
@@ -2093,132 +2121,162 @@ class TIG_PostNL_Model_Core_Shipment extends Mage_Core_Model_Abstract
2093
  if (!$this->isDutchShipment()) {
2094
  return 1;
2095
  }
2096
-
2097
  /**
2098
  * get this shipment's total weight
2099
  */
2100
  $weight = $this->getTotalWeight(true);
2101
-
2102
  /**
2103
  * get the weight per parcel
2104
  */
2105
  $weightPerParcel = Mage::getStoreConfig(self::XML_PATH_WEIGHT_PER_PARCEL, $this->getStoreId());
2106
  $weightPerParcel = $this->getHelper('cif')->standardizeWeight($weightPerParcel, $this->getStoreId());
2107
-
2108
  /**
2109
  * calculate the number of parcels needed to ship the total weight of this shipment
2110
  */
2111
  $parcelCount = ceil($weight / $weightPerParcel);
2112
-
2113
  return $parcelCount;
2114
  }
2115
-
2116
  /****************************************************************************************************************************
2117
  * RESET AND DELETE METHODS
2118
  ***************************************************************************************************************************/
2119
-
2120
  /**
2121
  * Resets this shipment to a pre-confirmed state
2122
- *
2123
- * @return TIG_PostNL_Model_Core_Shipment
 
 
 
2124
  */
2125
- public function resetConfirmation()
2126
  {
2127
  $this->setConfirmStatus(self::CONFIRM_STATUS_UNCONFIRMED) //set status to unconfirmed
2128
  ->setShippingPhase(false) //delete current shipping phase
2129
  ->setConfirmedAt(false) //delete 'confirmed at' date
2130
- ->setlabelsPrinted(0) //labels have not been printed
2131
- ->deleteLabels() //delete all associated labels
2132
  ->deleteBarcodes() //delete all associated barcodes
2133
  ->deleteStatusHistory(); //delete all associated status history items
2134
-
 
 
 
 
 
 
 
 
 
2135
  return $this;
2136
  }
2137
-
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
2138
  /**
2139
  * Removes all labels associated with this shipment
2140
- *
2141
  * @return TIG_PostNL_Model_Core_Shipment
2142
  */
2143
  public function deleteLabels()
2144
  {
2145
  $labelCollection = Mage::getResourceModel('postnl_core/shipment_label_collection');
2146
  $labelCollection->addFieldToFilter('parent_id', array('eq' => $this->getid()));
2147
-
2148
  $labels = $labelCollection->getItems();
2149
-
2150
  foreach ($labels as $label) {
2151
  $label->delete()
2152
  ->save();
2153
  }
2154
-
2155
  return $this;
2156
  }
2157
-
2158
  /**
2159
  * Removes all barcodes associated with this shipment
2160
- *
2161
  * @return TIG_PostNL_Model_Core_Shipment
2162
  */
2163
  public function deleteBarcodes()
2164
  {
2165
  $barcodes = $this->getBarcodes(true);
2166
-
2167
  foreach ($barcodes as $barcode) {
2168
  $barcode->delete()
2169
  ->save();
2170
  }
2171
-
2172
  $this->setMainBarcode(false);
2173
-
2174
  return $this;
2175
  }
2176
-
2177
  /**
2178
  * Deletes all status history items associated with this shipment
2179
- *
2180
  * @return TIG_PostNL_Model_Core_Shipment
2181
  */
2182
  public function deleteStatusHistory()
2183
  {
2184
  $statusHistoryCollection = Mage::getResourceModel('postnl_core/shipment_status_history_collection');
2185
  $statusHistoryCollection->addFieldToFilter('parent_id', array('eq' => $this->getid()));
2186
-
2187
  foreach ($statusHistoryCollection as $status) {
2188
  $status->delete()
2189
  ->save();
2190
  }
2191
-
2192
  return $this;
2193
  }
2194
-
2195
  /****************************************************************************************************************************
2196
  * BEFORE- AND AFTERSAVE METHODS
2197
  ***************************************************************************************************************************/
2198
-
2199
  /**
2200
  * Updates the shipment's attributes before saving this shipment
2201
- *
2202
  * @return Mage_Core_Model_Abstract::_beforeSave
2203
  */
2204
  protected function _beforeSave()
2205
  {
2206
  $currentTimestamp = Mage::getModel('core/date')->gmtTimestamp();
2207
-
2208
  /**
2209
  * Store any shipment options that have been saved in the registry
2210
  */
2211
  if (Mage::registry('postnl_additional_options')) {
2212
  $this->_saveAdditionalShippingOptions();
2213
  }
2214
-
2215
  /**
2216
  * Set confirm status
2217
  */
2218
  if ($this->getConfirmStatus() === null) {
2219
  $this->setConfirmStatus(self::CONFIRM_STATUS_UNCONFIRMED);
2220
  }
2221
-
2222
  /**
2223
  * Set confrirmed at
2224
  */
@@ -2227,14 +2285,14 @@ class TIG_PostNL_Model_Core_Shipment extends Mage_Core_Model_Abstract
2227
  ) {
2228
  $this->setConfirmedAt($currentTimestamp);
2229
  }
2230
-
2231
  /**
2232
  * Set whether labels have printed or not
2233
  */
2234
  if ($this->getlabelsPrinted() == 0 && $this->hasLabels()) {
2235
  $this->setLabelsPrinted(1);
2236
  }
2237
-
2238
  /**
2239
  * Set a product code
2240
  */
@@ -2242,7 +2300,7 @@ class TIG_PostNL_Model_Core_Shipment extends Mage_Core_Model_Abstract
2242
  $productCode = $this->_getProductCode();
2243
  $this->setProductCode($productCode);
2244
  }
2245
-
2246
  /**
2247
  * Set the parcel count
2248
  */
@@ -2250,26 +2308,26 @@ class TIG_PostNL_Model_Core_Shipment extends Mage_Core_Model_Abstract
2250
  $parcelCount = $this->_calculateParcelCount();
2251
  $this->setParcelCount($parcelCount);
2252
  }
2253
-
2254
  /**
2255
  * Set the confirm date
2256
  */
2257
  if (!$this->getConfirmDate()) {
2258
  $this->setConfirmDate($currentTimestamp);
2259
  }
2260
-
2261
  /**
2262
  * If this shipment is new, set it's created at date to the current timestamp
2263
  */
2264
  if (!$this->getId()) {
2265
  $this->setCreatedAt($currentTimestamp);
2266
  }
2267
-
2268
  /**
2269
  * Always update the updated at timestamp to the current timestamp
2270
  */
2271
  $this->setUpdatedAt($currentTimestamp);
2272
-
2273
  return parent::_beforeSave();
2274
  }
2275
  }
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@totalinternetgroup.nl so we can send you a copy immediately.
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
  * PostNL Shipment base class. Contains majority of PostNL shipping functionality
42
  */
48
  * @var string
49
  */
50
  protected $_eventPrefix = 'postnl_shipment';
51
+
52
  /**
53
  * Carrier code used by postnl
54
  */
55
  const POSTNL_CARRIER_CODE = 'postnl';
56
+
57
  /**
58
  * Possible confirm statusses
59
  */
60
  const CONFIRM_STATUS_CONFIRMED = 'confirmed';
61
  const CONFIRM_STATUS_UNCONFIRMED = 'unconfirmed';
62
  const CONFIRM_STATUS_CONFIRM_EXPIRED = 'confirm_expired';
63
+
64
  /**
65
  * Possible shipping phases
66
  */
69
  const SHIPPING_PHASE_DISTRIBUTION = '3';
70
  const SHIPPING_PHASE_DELIVERED = '4';
71
  const SHIPPING_PHASE_NOT_APPLICABLE = '99';
72
+
73
  /**
74
  * XML paths to default product options settings
75
  */
80
  const XML_PATH_USE_ALTERNATIVE_DEFAULT = 'postnl/cif_product_options/use_alternative_default';
81
  const XML_PATH_ALTERNATIVE_DEFAULT_MAX_AMOUNT = 'postnl/cif_product_options/alternative_default_max_amount';
82
  const XML_PATH_ALTERNATIVE_DEFAULT_OPTION = 'postnl/cif_product_options/alternative_default_option';
83
+
84
  /**
85
  * XML path to weight per parcel config setting
86
  */
87
+ const XML_PATH_WEIGHT_PER_PARCEL = 'postnl/cif_labels_and_confirming/weight_per_parcel';
88
+
89
  /**
90
  * XML path to setting that determines whether or not to send track and trace emails
91
  */
92
  const XML_PATH_SEND_TRACK_AND_TRACE_EMAIL = 'postnl/cif_labels_and_confirming/send_track_and_trace_email';
93
+
94
  /**
95
  * XML path to track and trace email template setting
96
  */
97
  const XML_PATH_TRACK_AND_TRACE_EMAIL_TEMPLATE = 'postnl/cif_labels_and_confirming/track_and_trace_email_template';
98
+
99
  /**
100
  * XML path to maximum allowed parcel count settings
101
  */
102
  const XML_PATH_MAX_PARCEL_COUNT = 'postnl/advanced/max_parcel_count';
103
+
104
  /**
105
  * CIF warning code returned when an EPS combi label is not available
106
  */
107
  const EPS_COMBI_LABEL_WARNING_CODE = 'LIRS_0';
108
+
109
  /**
110
  * Newly added 'pakje_gemak' address type
111
  */
112
  const ADDRESS_TYPE_PAKJEGEMAK = 'pakje_gemak';
113
+
114
  /**
115
  * Array of product codes that have extra cover
116
+ *
117
  * @var array
118
  */
119
  protected $_extraCoverProductCodes = array(
127
  '3544',
128
  '4945',
129
  );
130
+
131
  /**
132
  * Array of labels that need to be saved all at once.
133
+ *
134
  * @var array
135
  */
136
  protected $_labelsToSave = array();
137
+
138
  /**
139
  * Contains an instance of TIG_PostNL_Model_Core_Shipment_Process which locks a shipment and prevents it from being modified
140
+ *
141
  * @var void | TIG_PostNL_Model_Core_Shipment_Process
142
  */
143
  protected $_process;
144
+
145
  /**
146
  * Initialize the shipment
147
  */
149
  {
150
  $this->_init('postnl_core/shipment');
151
  }
152
+
153
  /****************************************************************************************************************************
154
  * GETTER AND SETTER METHODS
155
  ***************************************************************************************************************************/
156
+
157
  /**
158
  * Retrieves a Mage_Sales_Model_Order_Shipment entity linked to the postnl shipment.
159
+ *
160
  * @return Mage_Sales_Model_Order_Shipment | null
161
  */
162
  public function getShipment()
164
  if ($this->getData('shipment')) {
165
  return $this->getData('shipment');
166
  }
167
+
168
  $shipmentId = $this->getShipmentId();
169
  if (!$shipmentId) {
170
  return null;
171
  }
172
+
173
  $shipment = Mage::getModel('sales/order_shipment')->load($shipmentId);
174
+
175
  $this->setShipment($shipment);
176
  return $shipment;
177
  }
178
+
179
  /**
180
  * Retrieves the linked Shipment's shipping address
181
+ *
182
  * @return Mage_Sales_Model_Order_Address | null
183
  */
184
  public function getShippingAddress()
186
  if ($this->getData('shipping_address')) {
187
  return $this->getData('shipping_address');
188
  }
189
+
190
  $shipmentId = $this->getShipmentId();
191
  if (!$shipmentId && !$this->getShipment()) {
192
  return null;
193
  }
194
+
195
  $shippingAddress = $this->getShipment()->getShippingAddress();
196
+
197
  $this->setShippingAddress($shippingAddress);
198
  return $shippingAddress;
199
  }
200
+
201
  /**
202
  * Gets an optional address with the pakje_gemak address type
203
+ *
204
  * @return boolean | Mage_Sales_Model_Order_Address
205
  */
206
  public function getPakjeGemakAddress()
208
  if ($this->getData('pakje_gemak_address')) {
209
  return $this->getData('pakje_gemak_address');
210
  }
211
+
212
  $shipmentId = $this->getShipmentId();
213
  if (!$shipmentId && !$this->getShipment()) {
214
  return null;
215
  }
216
+
217
  $addresses = $this->getShipment()->getOrder()->getAddressesCollection();
218
  foreach ($addresses as $address) {
219
  if ($address->getAddressType() == self::ADDRESS_TYPE_PAKJEGEMAK) {
221
  return $address;
222
  }
223
  }
224
+
225
  return false;
226
  }
227
+
228
  /**
229
+ * Get the set store ID. If no store ID is set and a shipment is available,
230
+ * that shipment's store ID will be returned. Otherwise the current store
231
  * ID is returned.
232
+ *
233
  * @return int
234
  */
235
  public function getStoreId()
237
  if ($this->getData('store_id')) {
238
  return $this->getData('store_id');
239
  }
240
+
241
  if ($this->getShipment()) {
242
  $storeId = $this->getShipment()->getStoreId();
243
+
244
  $this->setStoreId($storeId);
245
  return $storeId;
246
  }
247
+
248
  $storeId = Mage::app()->getStore()->getId();
249
+
250
  $this->setStoreId($storeId);
251
  return $storeId;
252
  }
253
+
254
  /**
255
  * Gets the order ID from the associated Mage_Sales_Model_Order_Shipment object
256
+ *
257
  * @return int
258
  */
259
  public function getOrderId()
261
  if ($this->getData('order_id')) {
262
  return $this->getData('order_id');
263
  }
264
+
265
  $shipment = $this->getShipment();
266
  if (!$shipment || !$shipment->getOrderId()) {
267
  return null;
268
  }
269
+
270
  $orderId = $shipment->getOrderId();
271
+
272
  $this->setOrderId($orderId);
273
  return $orderId;
274
  }
275
+
276
  /**
277
  * Gets a PostNL helper object
278
+ *
279
  * @return TIG_PostNL_Helper_Data
280
  */
281
  public function getHelper($type = 'data')
283
  if ($this->getData('helper_' . $type)) {
284
  return $this->getData('helper_' . $type);
285
  }
286
+
287
  $helper = Mage::helper('postnl/' . $type);
288
+
289
  $this->setDataUsingMethod('helper_' . $type, $helper);
290
  return $helper;
291
  }
292
+
293
  /**
294
  * Gets the process used for locking and unlocking this shipment
295
+ *
296
  * @return TIG_PostNL_Model_Core_Shipment_Process
297
  */
298
  public function getProcess()
306
 
307
  return $process;
308
  }
309
+
310
  /**
311
  * Sets the process used for locking and unlocking this shipment
312
+ *
313
  * @param TIG_PostNL_Model_Core_Shipment_Process
314
+ *
315
  * @return TIG_PostNL_Model_Core_Shipment
316
  */
317
  public function setProcess(TIG_PostNL_Model_Core_Shipment_Process $process)
318
  {
319
  $this->_process = $process;
320
+
321
  return $this;
322
  }
323
+
324
  /**
325
  * Get an array of labels that have to be saved together
326
+ *
327
  * @return array
328
  */
329
  public function getlabelsToSave()
330
  {
331
  return $this->_labelsToSave;
332
  }
333
+
334
  /**
335
  * Get all product codes that have extra cover
336
+ *
337
  * @return array
338
  */
339
  public function getExtraCoverProductCodes()
340
  {
341
  return $this->_extraCoverProductCodes;
342
  }
343
+
344
  /**
345
  * Get this shipment's product code. If no code is available, generate the code.
346
+ *
347
  * @return int
348
  */
349
  public function getProductCode()
351
  if ($this->getData('product_code')) {
352
  return $this->getData('product_code');
353
  }
354
+
355
  $productCode = $this->_getProductCode();
356
+
357
  $this->setProductCode($productCode);
358
  return $productCode;
359
  }
360
+
361
  /**
362
  * gets all shipping labels associated with this shipment
363
+ *
364
  * @return array Array of TIG_PostNL_Model_Core_Shipment_Label objects
365
  */
366
  public function getLabels()
367
  {
368
  $labelCollection = Mage::getResourceModel('postnl_core/shipment_label_collection');
369
  $labelCollection->addFieldToFilter('parent_id', array('eq' => $this->getid()));
370
+
371
  /**
372
  * If the 'labels_printed' flag is false, yet there are labels present something has gone wrong.
373
  * Delete the labels so the module will generate new ones.
376
  $this->deleteLabels();
377
  return array();
378
  }
379
+
380
  $labels = $labelCollection->getItems();
381
  return $labels;
382
  }
383
+
384
  /**
385
  * Get the amount of extra cover this shipment has.
386
+ *
387
  * @return int | float
388
  */
389
  public function getExtraCoverAmount()
391
  if ($this->hasData('extra_cover_amount')) {
392
  return $this->getData('extra_cover_amount');
393
  }
394
+
395
  return 0;
396
  }
397
+
398
  /**
399
  * Calculates the total weight of this shipment
400
+ *
401
  * @param boolean $standardize Whether or not to convert the weight to kg
402
  * @param boolean $toGrams whether or not to convert the standardized weight to g
403
+ *
404
  * @return float | int
405
  */
406
  public function getTotalWeight($standardize = false, $toGrams = false)
409
  * get all items in the shipment
410
  */
411
  $items = $this->getShipment()->getAllItems();
412
+
413
  /**
414
  * calculate the total weight
415
  */
417
  foreach ($items as $item) {
418
  $weight += ($item->getWeight() * $item->getQty());
419
  }
420
+
421
  if ($standardize !== true) {
422
  return $weight;
423
  }
424
+
425
  /**
426
  * standardize the weight to kg or g
427
  */
428
  $weight = $this->getHelper('cif')->standardizeWeight(
429
+ $weight,
430
  $this->getStoreId(),
431
  $toGrams
432
  );
433
+
434
  return $weight;
435
  }
436
+
437
  /**
438
  * Calculates a shipment's base grand total based on it's shipment items
439
+ *
440
  * @return float | null
441
  */
442
  public function getShipmentBaseGrandTotal()
444
  if ($this->getData('shipment_base_grand_total')) {
445
  return $this->getData('shipment_base_grand_total');
446
  }
447
+
448
  /**
449
  * Check if this PostNL shipment has a linked Mage_Sales_Model_Order_Shipment object
450
  */
452
  if (!$shipment) {
453
  return null;
454
  }
455
+
456
  /**
457
  * Loop through all associated shipment items and add each item's row total to the shipment's total
458
  */
464
  * The base price of a shipment item is only available through it's associated order item
465
  */
466
  $basePrice = $shipmentItem->getOrderItem()->getBasePrice();
467
+
468
  /**
469
  * Calculate and add the shipment item's row total
470
  */
475
  $this->setShipmentBaseGrandTotal($baseGrandTotal);
476
  return $baseGrandTotal;
477
  }
478
+
479
  /**
480
  * Gets the url for this shipment's main barcode
481
+ *
482
  * @param boolean $forceNl
483
+ *
484
  * @return string
485
+ *
486
  * @see TIG_PostNL_Helper_Carrier::getBarcodeUrl()
487
  */
488
  public function getBarcodeUrl($forceNl = false)
490
  if ($this->hasBarcodeUrl()) {
491
  return $this->getData('barcode_url');
492
  }
493
+
494
  $barcode = $this->getMainBarcode();
495
  if (!$barcode) {
496
  return false;
497
  }
498
+
499
  $helper = $this->getHelper('carrier');
500
+
501
  $locale = Mage::getStoreConfig('general/locale/code', $this->getStoreId());
502
  $lang = substr($locale, 0, 2);
503
+
504
  $url = $helper->getBarcodeUrl($barcode, $this->getShippingAddress(), $lang, $forceNl);
505
+
506
  $this->setBarcodeUrl($url);
507
  return $url;
508
  }
509
+
510
  /**
511
  * Gets the shipment's shipment type for intrnational shipments.
512
  * If no shipment type is defined, use the default 'commercial goods'.
513
+ *
514
  * @return string | null
515
  */
516
  public function getShipmentType()
518
  if ($this->getData('shipment_type')) {
519
  return $this->getData('shipment_type');
520
  }
521
+
522
  if (!$this->isGlobalShipment()) {
523
  return null;
524
  }
525
+
526
  $shipmentType = 'Commercial Goods';
527
  return $shipmentType;
528
  }
529
+
530
  /**
531
  * Gets the default product code for this shipment from the module's configuration
532
+ *
533
  * @return string
534
+ *
535
  * @todo implement pakjegemak
536
  */
537
  public function getDefaultProductCode()
538
  {
539
  $storeId = $this->getStoreId();
540
+
541
  if ($this->isPakjeGemakShipment()) {
542
  /**
543
  * PakjeGemak default option
544
  */
545
  $productCode = Mage::getStoreConfig(self::XML_PATH_DEFAULT_PAKJEGEMAK_PRODUCT_OPTION, $storeId);
546
  $this->_checkProductCodeAllowed($productCode);
547
+
548
  return $productCode;
549
  }
550
+
551
  if ($this->isEuShipment()) {
552
  /**
553
  * EU default option
554
  */
555
  $productCode = Mage::getStoreConfig(self::XML_PATH_DEFAULT_EU_PRODUCT_OPTION, $storeId);
556
  $this->_checkProductCodeAllowed($productCode);
557
+
558
  return $productCode;
559
  }
560
+
561
  if ($this->isGlobalShipment()) {
562
  /**
563
  * Global default option
564
  */
565
  $productCode = Mage::getStoreConfig(self::XML_PATH_DEFAULT_GLOBAL_PRODUCT_OPTION, $storeId);
566
  $this->_checkProductCodeAllowed($productCode);
567
+
568
  return $productCode;
569
  }
570
+
571
  /**
572
  * If the shipment is not EU or global, it's dutch (AKA a 'standard' shipment)
573
  */
574
+
575
  /**
576
  * Dutch shipments may use an alternative default option when the shipment's base grandtotal exceeds a specified amount
577
  */
587
  */
588
  $productCode = Mage::getStoreConfig(self::XML_PATH_ALTERNATIVE_DEFAULT_OPTION, $storeId);
589
  $this->_checkProductCodeAllowed($productCode);
590
+
591
  return $productCode;
592
  }
593
  }
594
+
595
  /**
596
  * standard default option
597
  */
598
  $productCode = Mage::getStoreConfig(self::XML_PATH_DEFAULT_STANDARD_PRODUCT_OPTION, $storeId);
599
  $this->_checkProductCodeAllowed($productCode);
600
+
601
  return $productCode;
602
  }
603
+
604
  /**
605
  * Get a specific barcode for this shipment
606
+ *
607
  * @param int | null $barcodeNumber Which barcode to get
608
+ *
609
  * @return string | null
610
  */
611
  public function getBarcode($barcodeNumber = null)
614
  $barcode = $this->getMainBarcode();
615
  return $barcode;
616
  }
617
+
618
  $barcode = Mage::getModel('postnl_core/shipment_barcode')
619
  ->loadByParentAndBarcodeNumber($this->getId(), $barcodeNumber);
620
+
621
  return $barcode->getBarcode();
622
  }
623
+
624
  /**
625
  * Get all barcodes associated with this shipment
626
+ *
627
  * @param $asObject boolean Optional value to get the barcodes as entities, rather than an array of values
628
+ *
629
  * @return array
630
  */
631
  public function getBarcodes($asObject = false)
633
  $barcodeCollection = Mage::getResourceModel('postnl_core/shipment_barcode_collection');
634
  $barcodeCollection->addFieldToSelect(array('barcode', 'barcode_number'))
635
  ->addFieldToFilter('parent_id', array('eq' => $this->getId()));
636
+
637
  $barcodeCollection->getSelect()->order('barcode_number ASC');
638
+
639
  if ($asObject === false) {
640
  $barcodeNumbers = $barcodeCollection->getColumnValues('barcode_number');
641
  $barcodes = $barcodeCollection->getColumnValues('barcode');
642
+
643
  /**
644
  * Combine the arrays so that the barcode numbers are the keys and the barcodes themselves are the values
645
  */
646
  $barcodeArray = array_combine($barcodeNumbers, $barcodes);
647
  $barcodeArray[0] = $this->getMainBarcode();
648
+
649
  return $barcodeArray;
650
  }
651
+
652
  /**
653
  * Return all barcode entities.
654
  * N.B. Does not contain the main barcode as it is not part of the collection
655
  */
656
  return $barcodeCollection->getItems();
657
  }
658
+
659
  /****************************************************************************************************************************
660
  * SETTER METHODS
661
  ***************************************************************************************************************************/
662
+
663
  /**
664
  * Set an array of labels that are to be saved together
665
+ *
666
  * @param array $labels
667
+ *
668
  * @return TIG_PostNL_Model_Core_Shipment
669
  */
670
  public function setLabelsToSave($labels)
671
  {
672
  $this->_labelsToSave = $labels;
673
+
674
  return $this;
675
  }
676
+
677
  /**
678
  * Set an extra cover amount
679
+ *
680
  * @param int $amount
681
+ *
682
  * @return TIG_PostNL_Model_Core_Shipment
683
  */
684
  public function setExtraCoverAmount($amount)
691
  if (!in_array($productCode, $extraCoverProductCodes)) {
692
  return $this;
693
  }
694
+
695
  $this->setData('extra_cover_amount', $amount);
696
+
697
  return $this;
698
  }
699
+
700
  /**
701
  * Sets a shipment's shipment type. This is required for GlobalPack shipments
702
+ *
703
  * @param string $type
704
+ *
705
  * @return TIG_PostNL_Model_Core_Shipment
706
  */
707
  public function setShipmentType($type)
712
  if (!$this->isGlobalShipment()) {
713
  return $this;
714
  }
715
+
716
  /**
717
  * Convert shipment type to CIF-compatible version
718
  */
719
  $shipmentType = str_replace('_', ' ', $type);
720
  $shipmentType = ucwords($shipmentType);
721
+
722
  $this->setData('shipment_type', $shipmentType);
723
  return $this;
724
  }
725
+
726
  /**
727
  * Set this shipment's parcel count. Verifies that the requested amount does not exceed the maximum allowed.
728
+ *
729
  * @param int $count
730
+ *
731
  * @return TIG_PostNL_Model_Core_Shipment
732
  */
733
  public function setParcelCount($count)
737
  $this->setData('parcel_count', $count);
738
  return $this;
739
  }
740
+
741
  if ($count > $maxParcelCount) {
742
  throw new TIG_PostNL_Exception(
743
  Mage::helper('postnl')->__(
748
  'POSTNL-0068'
749
  );
750
  }
751
+
752
  $this->setData('parcel_count', $count);
753
  return $this;
754
  }
755
+
756
  /****************************************************************************************************************************
757
  * SHIPMENT LOCKING AND UNLOCKING FUNCTIONS
758
  ***************************************************************************************************************************/
759
+
760
  /**
761
  * Lock this shipment to prevent simultaneous execution
762
+ *
763
  * @return TIG_PostNL_Model_Core_Shipment
764
  */
765
  public function lock()
766
  {
767
  $process = $this->getProcess();
768
  $process->lockAndBlock();
769
+
770
  return $this;
771
  }
772
+
773
  /**
774
  * Unlock this shipment
775
+ *
776
  * @return TIG_PostNL_Model_Core_Shipment
777
  */
778
  public function unlock()
779
  {
780
  $process = $this->getProcess();
781
  $process->unlock();
782
+
783
  return $this;
784
  }
785
+
786
  /**
787
  * Check if this shipment is locked
788
+ *
789
  * @return boolean
790
  */
791
  public function isLocked()
792
  {
793
  $process = $this->getProcess();
794
  $isLocked = $process->isLocked();
795
+
796
  return $isLocked;
797
  }
798
+
799
  /****************************************************************************************************************************
800
  * HAS- METHODS
801
  ***************************************************************************************************************************/
802
+
803
  /**
804
  * Check if the shipment has any associated labels
805
+ *
806
  * @return boolean
807
  */
808
  public function hasLabels()
809
  {
810
  $labelCollection = Mage::getResourceModel('postnl_core/shipment_label_collection');
811
  $labelCollection->addFieldToFilter('parent_id', array('eq' => $this->getid()));
812
+
813
  if ($labelCollection->getSize() > 0) {
814
  return true;
815
  }
816
+
817
  return false;
818
  }
819
+
820
  /**
821
  * Checks if this shipment has extra cover
822
+ *
823
  * @return boolean
824
  */
825
  public function hasExtraCover()
826
  {
827
  $productCode = $this->getProductCode();
828
  $extraCoverProductCodes = $this->getExtraCoverProductCodes();
829
+
830
  if (!in_array($productCode, $extraCoverProductCodes)) {
831
  return false;
832
  }
833
+
834
  if ($this->getExtraCoverAmount() < 1) {
835
  return false;
836
  }
837
+
838
  return true;
839
  }
840
+
841
  /**
842
  * Check if this shipment has a label of a given type
843
+ *
844
  * @param string $labelType
845
+ *
846
  * @return boolean
847
  */
848
  public function hasLabelType($labelType)
849
  {
850
  $coreResource = Mage::getSingleton('core/resource');
851
  $readConn = $coreResource->getConnection('core/read');
852
+
853
  $select = $readConn->select();
854
  $select->from($coreResource->getTableName('postnl_core/shipment_label', array('label_id')))
855
  ->where('`label_type` = ?', $labelType)
856
  ->where('`parent_id` = ?', $this->getId());
857
+
858
  $label = $readConn->fetchOne($select);
859
+
860
  if ($label === false) {
861
  return false;
862
  }
863
+
864
  return true;
865
  }
866
+
867
  /****************************************************************************************************************************
868
  * IS- AND CAN- METHODS
869
  ***************************************************************************************************************************/
870
+
871
  /**
872
  * Alias for magic getIsPakjeGemak()
873
+ *
874
  * Please note the difference between this method and TIG_PostNL_Model_Core_Shipment::isPakjeGemakShipment
875
+ *
876
  * @return integer
877
  */
878
  public function isPakjeGemak()
879
  {
880
  return $this->getIsPakjeGemak();
881
  }
882
+
883
  /**
884
  * Check if the shipping destination of this shipment is NL
885
+ *
886
  * @return boolean
887
  */
888
  public function isDutchShipment()
889
  {
890
  $shippingDestination = $this->getShippingAddress()->getCountryId();
891
+
892
  if ($shippingDestination == 'NL') {
893
  return true;
894
  }
895
+
896
  return false;
897
  }
898
+
899
  /**
900
  * Check if the shipping destination of this shipment is a EU country
901
+ *
902
  * @return boolean
903
  */
904
  public function isEuShipment()
905
  {
906
  $shippingDestination = $this->getShippingAddress()->getCountryId();
907
+
908
  $euCountries = $this->getHelper('cif')->getEuCountries();
909
+
910
  if (in_array($shippingDestination, $euCountries)) {
911
  return true;
912
  }
913
+
914
  return false;
915
  }
916
+
917
  /**
918
  * Check if the shipping destination of this shipment is global (not NL or EU)
919
+ *
920
  * @return boolean
921
  */
922
  public function isGlobalShipment()
924
  if (!$this->isDutchShipment() && !$this->isEuShipment()) {
925
  return true;
926
  }
927
+
928
  return false;
929
  }
930
+
931
  /**
932
  * Check if the currrent shipment is a PakjeGemak shipment.
933
+ *
934
  * @return boolean
935
  */
936
  public function isPakjeGemakShipment()
938
  if ($this->getIsPakjeGemak()) {
939
  return true;
940
  }
941
+
942
  $postnlOrder = Mage::getModel('postnl_checkout/order')->load($this->getOrderId(), 'order_id');
943
  if ($postnlOrder->getId() && $postnlOrder->getIsPakjeGemak()) {
944
  return true;
945
  }
946
+
947
  $pakjeGemakProductCodes = $this->getHelper('cif')->getPakjeGemakProductCodes();
948
  $productCode = $this->getData('product_code');
949
+
950
  if (!$productCode) {
951
  return false;
952
  }
953
+
954
  if (in_array($productCode, $pakjeGemakProductCodes)) {
955
  $this->setIsPakjeGemak(true);
956
  return true;
957
  }
958
+
959
  return false;
960
  }
961
+
962
  /**
963
  * Checks if this shipment is a COD shipment
964
+ *
965
  * @return boolean
966
+ *
967
  * @todo implement this method
968
  */
969
  public function isCod()
970
  {
971
  return false; //TODO implement this method
972
  }
973
+
974
  /**
975
  * Checks if this shipment is confirmed
976
+ *
977
  * @return boolean
978
  */
979
  public function isConfirmed()
982
  if ($confirmedStatus === self::CONFIRM_STATUS_CONFIRMED) {
983
  return true;
984
  }
985
+
986
  return false;
987
  }
988
+
989
  /**
990
  * Checks if the current entity may generate a barcode.
991
+ *
992
  * @return boolean
993
  */
994
  public function canGenerateBarcode()
996
  if (!$this->getShipmentId() && !$this->getShipment()) {
997
  return false;
998
  }
999
+
1000
  return true;
1001
  }
1002
+
1003
  /**
1004
  * Checks if the current entity can be confirmed.
1005
+ *
1006
  * @return boolean
1007
  */
1008
  public function canConfirm($skipEuCheck = false)
1010
  if ($this->isLocked()) {
1011
  return false;
1012
  }
1013
+
1014
  if ($this->getConfirmStatus() == self::CONFIRM_STATUS_CONFIRMED) {
1015
  return false;
1016
  }
1017
+
1018
  if (!$this->getShipmentId() && !$this->getShipment()) {
1019
  return false;
1020
  }
1021
+
1022
  if (!$this->getMainBarcode()) {
1023
  return false;
1024
  }
1025
+
1026
  if ($skipEuCheck === false
1027
+ && $this->isEuShipment()
1028
  && !$this->getLabelsPrinted()
1029
  ) {
1030
  return false;
1031
  }
1032
+
1033
  return true;
1034
  }
1035
+
1036
  /**
1037
  * Checks if the current shipment is eligible for a shipping status update.
1038
  * Unconfirmed shipments, shipments whose labels are not yet printed or shipments that are already delivered are inelligible.
1039
+ *
1040
  * @return boolean
1041
  */
1042
  public function canUpdateShippingStatus()
1044
  if ($this->isLocked()) {
1045
  return false;
1046
  }
1047
+
1048
  if (self::CONFIRM_STATUS_CONFIRMED != $this->getConfirmStatus()) {
1049
  return false;
1050
  }
1051
+
1052
  if (self::SHIPPING_PHASE_DELIVERED == $this->getShippingPhase()) {
1053
  return false;
1054
  }
1055
+
1056
  if (!$this->getLabelsPrinted()) {
1057
  return false;
1058
  }
1059
+
1060
  if (!$this->hasLabels()) {
1061
  return false;
1062
  }
1063
+
1064
  if (!$this->getMainBarcode()) {
1065
  return false;
1066
  }
1067
+
1068
  return true;
1069
  }
1070
+
1071
  /**
1072
  * Checks if the current shipment is eligible for a complete shipping status update.
1073
  * For now the same conditions apply as a regular status update. This may change in a future update of the extension.
1074
+ *
1075
  * @return boolean
1076
+ *
1077
  * @see TIG_PostNL_Model_Core_Shipment::canUpdateShippingStatus()
1078
  */
1079
  public function canUpdateCompleteShippingStatus()
1080
  {
1081
  return $this->canUpdateShippingStatus();
1082
  }
1083
+
1084
  /**
1085
  * Checks if the current shipment can send a track & trace email to the customer.
1086
+ *
1087
  * @param boolean $ignoreAlreadySent Flag to ignore the 'already sent' check
1088
+ *
1089
  * @return boolean
1090
  */
1091
  public function canSendTrackAndTraceEmail($ignoreAlreadySent = false)
1093
  if ($this->isLocked()) {
1094
  return false;
1095
  }
1096
+
1097
  if ($ignoreAlreadySent !== true && $this->getTrackAndTraceEmailSent()) {
1098
  return false;
1099
  }
1100
+
1101
  $storeId = $this->getStoreId();
1102
  $canSendTrackAndTrace = Mage::getStoreConfig(self::XML_PATH_SEND_TRACK_AND_TRACE_EMAIL, $storeId);
1103
  if (!$canSendTrackAndTrace) {
1104
  return false;
1105
  }
1106
+
1107
  return true;
1108
  }
1109
+
1110
+ /**
1111
+ * Checks if this shipment's confirmation status can be reset.
1112
+ *
1113
+ * @return boolean
1114
+ */
1115
+ public function canResetConfirmation()
1116
+ {
1117
+ $confirmStatus = $this->getConfirmStatus();
1118
+ if ($confirmStatus == self::CONFIRM_STATUS_CONFIRM_EXPIRED) {
1119
+ return false;
1120
+ }
1121
+
1122
+ if ($confirmStatus == self::CONFIRM_STATUS_UNCONFIRMED) {
1123
+ return false;
1124
+ }
1125
+
1126
+ $shippingPhase = $this->getShippingPhase();
1127
+ if ($shippingPhase == self::SHIPPING_PHASE_COLLECTION
1128
+ || $shippingPhase == self::SHIPPING_PHASE_DELIVERED
1129
+ || $shippingPhase == self::SHIPPING_PHASE_DISTRIBUTION
1130
+ || $shippingPhase == self::SHIPPING_PHASE_SORTING
1131
+ ) {
1132
+ return false;
1133
+ }
1134
+
1135
+ return true;
1136
+ }
1137
+
1138
  /****************************************************************************************************************************
1139
  * CIF FUNCTIONALITY METHODS
1140
  ***************************************************************************************************************************/
1141
+
1142
  /**
1143
  * Generates barcodes for this postnl shipment.
1144
  * Barcodes are the basis for all CIF functionality and must therefore be generated before any further action is possible.
1145
+ *
1146
  * @return TIG_PostNL_Model_Core_Shipment
1147
+ *
1148
  * @throws TIG_PostNL_Exception
1149
  */
1150
  public function generateBarcodes()
1155
  'POSTNL-0069'
1156
  );
1157
  }
1158
+
1159
  $this->lock();
1160
+
1161
  Mage::dispatchEvent('postnl_shipment_generatebarcode_before', array('shipment' => $this));
1162
+
1163
  /**
1164
  * Generate and save the main barcode
1165
  */
1166
  $mainBarcode = $this->_generateBarcode();
1167
  $this->setMainBarcode($mainBarcode);
1168
+
1169
  $parcelCount = $this->getParcelCount();
1170
  if (!$parcelCount) {
1171
  $parcelCount = $this->_calculateParcelCount();
1172
  }
1173
+
1174
  /**
1175
  * If this shipment consists of a single parcel or if it's an international shipment we only need the main barcode
1176
  */
1177
  if ($parcelCount < 2 || $this->isGlobalShipment()) {
1178
  Mage::dispatchEvent('postnl_shipment_generatebarcode_after', array('shipment' => $this));
1179
  $this->unlock();
1180
+
1181
  return $this;
1182
  }
1183
+
1184
  /**
1185
  * Generate a barcode for each parcel and save it
1186
  */
1188
  $barcode = $this->_generateBarcode();
1189
  $this->_addBarcode($barcode, $i);
1190
  }
1191
+
1192
  Mage::dispatchEvent('postnl_shipment_generatebarcode_after', array('shipment' => $this));
1193
  $this->unlock();
1194
  return $this;
1195
  }
1196
+
1197
  /**
1198
  * Generates a single barcode for this postnl shipment.
1199
+ *
1200
  * @return string
1201
+ *
1202
  * @throws TIG_PostNL_Exception
1203
  */
1204
  protected function _generateBarcode()
1205
  {
1206
  $shipment = $this->getShipment();
1207
+
1208
  $cif = Mage::getModel('postnl_core/cif');
1209
  $barcodeType = $this->getHelper('cif')->getBarcodeTypeForShipment($this);
1210
+
1211
  $barcode = $cif->generateBarcode($shipment, $barcodeType);
1212
+
1213
  if (!$barcode) {
1214
  throw new TIG_PostNL_Exception(
1215
  Mage::helper('postnl')->__('Unable to generate barcode for this shipment: %s', $shipment->getId()),
1216
  'POSTNL-0070'
1217
  );
1218
  }
1219
+
1220
  /**
1221
  * If the generated barcode already exists a new one needs to be generated.
1222
  */
1223
  if ($this->getHelper('cif')->barcodeExists($barcode)) {
1224
  return $this->_generateBarcode();
1225
  }
1226
+
1227
  return $barcode;
1228
  }
1229
+
1230
  /**
1231
  * Generates a shipping labels for a shipment without confirming it with PostNL.
1232
+ *
1233
  * @return TIG_PostNL_Model_Core_Shipment
1234
+ *
1235
  * @throws TIG_PostNL_Exception
1236
  */
1237
  public function generateLabel()
1238
  {
1239
  $this->lock();
1240
+
1241
  Mage::dispatchEvent('postnl_shipment_generatelabel_before', array('shipment' => $this));
1242
+
1243
  $parcelCount = $this->getparcelCount();
1244
  if (!$parcelCount) {
1245
  $parcelCount = $this->_calculateParcelCount();
1246
  }
1247
+
1248
  /**
1249
  * Generate labels purely for the main shipment
1250
  */
1251
  if ($parcelCount < 2) {
1252
  $labels = $this->_generateLabel();
1253
  $this->addLabels($labels);
1254
+
1255
  $this->_saveLabels();
1256
+
1257
  Mage::dispatchEvent('postnl_shipment_generatelabel_after', array('shipment' => $this));
1258
+
1259
  $this->unlock();
1260
  return $this;
1261
  }
1262
+
1263
  /**
1264
  * Generate labels for each parcel in the shipment
1265
  */
1267
  $labels = $this->_generateLabel(false, $i);
1268
  $this->addLabels($labels);
1269
  }
1270
+
1271
  $this->_saveLabels();
1272
+
1273
  Mage::dispatchEvent('postnl_shipment_generatelabel_after', array('shipment' => $this));
1274
+
1275
  $this->unlock();
1276
  return $this;
1277
  }
1278
+
1279
  /**
1280
  * Get a shipping label from PostNL for a single parcel or a whole shipment
1281
+ *
1282
  * @param boolean $confirm Whether or not to also confirm the shipment
1283
  * @param int | null $barcodeNumber An optional barcode number. If this parameter is null, the main barcode will be used
1284
+ *
1285
  * @return array
1286
  */
1287
  protected function _generateLabel($confirm = false, $barcodeNumber = false)
1288
  {
1289
  $mainBarcode = $this->getMainBarcode();
1290
+
1291
  /**
1292
  * if $barcodeNumber is false, this is a single parcel shipment
1293
  */
1298
  $barcode = $this->getBarcode($barcodeNumber);
1299
  $barcodeNumber++; //while barcode numbers start at 0, shipment numbers start at 1
1300
  }
1301
+
1302
  $cif = Mage::getModel('postnl_core/cif');
1303
+
1304
  if ($confirm === false) {
1305
  $result = $cif->generateLabelsWithoutConfirm($this, $barcode, $mainBarcode, $barcodeNumber);
1306
  } else {
1307
  $result = $cif->generateLabels($this, $barcode, $mainBarcode, $barcodeNumber);
1308
  }
1309
+
1310
  if (!isset($result->Labels) || !isset($result->Labels->Label)) {
1311
  throw new TIG_PostNL_Exception(
1312
  Mage::helper('postnl')->__(
1313
+ 'The confirmAndPrintLabel action returned an invalid response: %s',
1314
  var_export($response, true)
1315
  ),
1316
  'POSTNL-0071'
1317
  );
1318
  }
1319
  $labels = $result->Labels->Label;
1320
+
1321
  /**
1322
  * If this is an EU shipment and a non-combi label was returned, the product code needs to be updated
1323
  */
1324
  if ($this->isEuShipment() && !$this->_isCombiLabel()) {
1325
  $this->setProductCode($result->ProductCodeDelivery);
1326
  }
1327
+
1328
  return $labels;
1329
  }
1330
+
1331
  /**
1332
  * Confirm the shipment with PostNL without generating new labels
1333
+ *
1334
  * @return TIG_PostNL_Model_Core_Shipment
1335
+ *
1336
  * @throws TIG_PostNL_Exception
1337
  */
1338
  public function confirm()
1343
  'POSTNL-0109'
1344
  );
1345
  }
1346
+
1347
  $this->lock();
1348
+
1349
  Mage::dispatchEvent('postnl_shipment_confirm_before', array('shipment' => $this));
1350
+
1351
  $parcelCount = $this->getparcelCount();
1352
  if (!$parcelCount) {
1353
  $parcelCount = $this->_calculateParcelCount();
1354
  }
1355
+
1356
  /**
1357
  * Only confirm the main shipment
1358
  */
1361
 
1362
  $this->setConfirmStatus(self::CONFIRM_STATUS_CONFIRMED)
1363
  ->setConfirmedAt(Mage::getModel('core/date')->gmtTimestamp());
1364
+
1365
  Mage::dispatchEvent('postnl_shipment_confirm_after', array('shipment' => $this));
1366
+
1367
  $this->unlock();
1368
  return $this;
1369
  }
1370
+
1371
  /**
1372
  * onfirm each parcel in the shipment seperately
1373
  */
1377
 
1378
  $this->setConfirmStatus(self::CONFIRM_STATUS_CONFIRMED)
1379
  ->setConfirmedAt(Mage::getModel('core/date')->gmtTimestamp());
1380
+
1381
  Mage::dispatchEvent('postnl_shipment_confirm_after', array('shipment' => $this));
1382
+
1383
  $this->unlock();
1384
  return $this;
1385
  }
1386
+
1387
  /**
1388
  * Confirms the shipment using CIF
1389
+ *
1390
  * @param int | null $barcodeNumber
1391
+ *
1392
  * @return TIG_PostNL_Model_Core_Shipment
1393
+ *
1394
  * @throws TIG_PostNL_Exception
1395
  */
1396
  protected function _confirm($barcodeNumber = false)
1397
  {
1398
  $mainBarcode = $this->getMainBarcode();
1399
+
1400
  /**
1401
  * if $barcodeNumber is false, this is a single parcel shipment
1402
  */
1407
  $barcode = $this->getBarcode($barcodeNumber);
1408
  $barcodeNumber++; //while barcode numbers start at 0, shipment numbers start at 1
1409
  }
1410
+
1411
  $cif = Mage::getModel('postnl_core/cif');
1412
  $result = $cif->confirmShipment($this, $barcode, $mainBarcode, $barcodeNumber);
1413
+
1414
  $responseShipment = $result->ConfirmingResponseShipment;
1415
+
1416
  /**
1417
  * If the ConfirmingResponseShipment is an object, it means only one shipment was confirmed and the returned barcode
1418
  * has to be the shipment's main barcode.
1419
  */
1420
+ if (is_object($responseShipment)
1421
  && isset($responseShipment->Barcode)
1422
  && $responseShipment->Barcode == $barcode
1423
  ) {
1424
  return $this;
1425
  }
1426
+
1427
  /**
1428
  * If the ConfirmingResponseShipment is an array, it may indicate multiple shipments were confirmed. We need to check the
1429
  * first shipment's barcode to see if it matches the main bartcode.
1430
  */
1431
  if (is_array($responseShipment)) {
1432
  $mainResponseShipment = $responseShipment[0];
1433
+
1434
+ if (is_object($mainResponseShipment)
1435
  && isset($mainResponseShipment->Barcode)
1436
  && $mainResponseShipment->Barcode == $barcode
1437
  ) {
1438
  return $this;
1439
  }
1440
  }
1441
+
1442
  /**
1443
  * The response was not valid; throw an exception
1444
  */
1447
  'POSTNL-0072'
1448
  );
1449
  }
1450
+
1451
  /**
1452
  * Generates a shipping label and confirms the shipment with postNL.
1453
+ *
1454
  * @return TIG_PostNL_Model_Core_Shipment
1455
+ *
1456
  * @throws TIG_PostNL_Exception
1457
  */
1458
  public function confirmAndGenerateLabel()
1463
  'POSTNL-0110'
1464
  );
1465
  }
1466
+
1467
  $this->lock();
1468
+
1469
  Mage::dispatchEvent('postnl_shipment_confirm_before', array('shipment' => $this));
1470
  Mage::dispatchEvent('postnl_shipment_confirmandgeneratelabel_before', array('shipment' => $this));
1471
+
1472
  $parcelCount = $this->getparcelCount();
1473
  if (!$parcelCount) {
1474
  $parcelCount = $this->_calculateParcelCount();
1475
  }
1476
+
1477
  /**
1478
  * Confirm and generate labels purely for the main shipment
1479
  */
1480
  if ($parcelCount < 2) {
1481
  $labels = $this->_generateLabel(true);
1482
  $this->addLabels($labels);
1483
+
1484
  $this->setConfirmStatus(self::CONFIRM_STATUS_CONFIRMED)
1485
  ->setConfirmedAt(Mage::getModel('core/date')->gmtTimestamp());
1486
+
1487
  $this->_saveLabels();
1488
+
1489
  Mage::dispatchEvent('postnl_shipment_confirm_after', array('shipment' => $this));
1490
  Mage::dispatchEvent('postnl_shipment_confirmandgeneratelabel_after', array('shipment' => $this));
1491
+
1492
  $this->unlock();
1493
  return $this;
1494
  }
1495
+
1496
  /**
1497
  * Confirm and generate labels for each parcel in the shipment
1498
  */
1500
  $labels = $this->_generateLabel(true, $i);
1501
  $this->addLabels($labels);
1502
  }
1503
+
1504
  $this->setConfirmStatus(self::CONFIRM_STATUS_CONFIRMED)
1505
  ->setConfirmedAt(Mage::getModel('core/date')->gmtTimestamp());
1506
+
1507
  $this->_saveLabels();
1508
+
1509
  Mage::dispatchEvent('postnl_shipment_confirm_after', array('shipment' => $this));
1510
  Mage::dispatchEvent('postnl_shipment_confirmandgeneratelabel_after', array('shipment' => $this));
1511
+
1512
  $this->unlock();
1513
  return $this;
1514
  }
1515
+
1516
  /**
1517
  * Requests a shipping status update for this shipment
1518
+ *
1519
  * @return TIG_PostNL_Model_Core_Shipment
1520
+ *
1521
  * @throws TIG_PostNL_Exception
1522
  */
1523
  public function updateShippingStatus()
1528
  'POSTNL-0073'
1529
  );
1530
  }
1531
+
1532
  $this->lock();
1533
+
1534
  Mage::dispatchEvent('postnl_shipment_updateshippingstatus_before', array('shipment' => $this));
1535
+
1536
  $cif = Mage::getModel('postnl_core/cif');
1537
  $result = $cif->getShipmentStatus($this);
1538
+
1539
  $currentPhase = $result->Status->CurrentPhaseCode;
1540
+
1541
  if (!$currentPhase) {
1542
  return $this;
1543
  }
1544
+
1545
  $this->setShippingPhase($currentPhase);
1546
+
1547
  Mage::dispatchEvent('postnl_shipment_updateshippingstatus_after', array('shipment' => $this));
1548
+
1549
  $this->unlock();
1550
  return $this;
1551
  }
1552
+
1553
  /**
1554
  * Update this shipment's status history
1555
+ *
1556
  * @param StdClass $oldStatuses
1557
+ *
1558
  * @return TIG_PostNL_Model_Core_Shipment
1559
  */
1560
  public function updateCompleteShippingStatus()
1565
  'POSTNL-0074'
1566
  );
1567
  }
1568
+
1569
  $this->lock();
1570
+
1571
  Mage::dispatchEvent('postnl_shipment_updatecompleteshippingstatus_before', array('shipment' => $this));
1572
+
1573
  $cif = Mage::getModel('postnl_core/cif');
1574
  $result = $cif->getCompleteShipmentStatus($this);
1575
+
1576
  /**
1577
  * Update the shipment's shipping phase
1578
  */
1579
  $currentPhase = $result->Status->CurrentPhaseCode;
1580
  $this->setShippingPhase($currentPhase);
1581
+
1582
  if (!isset($result->Events->CompleteStatusResponseEvent)) {
1583
  $this->unlock();
1584
  return $this;
1585
  }
1586
+
1587
  /**
1588
  * get the complete event history
1589
  */
1590
  $completeStatusHistory = $result->Events->CompleteStatusResponseEvent;
1591
  $completeStatusHistory = $this->_sortStatusHistory($completeStatusHistory);
1592
+
1593
  /**
1594
  * Update the shipments status history
1595
  */
1596
  foreach ($completeStatusHistory as $status) {
1597
  $statusHistory = Mage::getModel('postnl_core/shipment_status_history');
1598
+
1599
  /**
1600
  * Check if a status history item exists for the given code and shipment id.
1601
  * If not, create a new one
1603
  if (!$statusHistory->statusHistoryIsNew($this->getId(), $status)) {
1604
  continue;
1605
  }
1606
+
1607
  $timestamp = Mage::getModel('core/date')->gmtTimestamp($status->TimeStamp);
1608
  $statusHistory->setParentId($this->getId())
1609
  ->setCode($status->Code)
1615
  ->setTimestamp($timestamp)
1616
  ->save();
1617
  }
1618
+
1619
  $this->setStatusHistoryUpdatedAt(Mage::getModel('core/date')->gmtTimestamp());
1620
+
1621
  Mage::dispatchEvent('postnl_shipment_updatecompleteshippingstatus_after', array('shipment' => $this));
1622
+
1623
  $this->unlock();
1624
+
1625
  return $this;
1626
  }
1627
+
1628
  /****************************************************************************************************************************
1629
  * TRACKING METHODS
1630
  ***************************************************************************************************************************/
1631
+
1632
  /**
1633
  * Adds Magento tracking information to the order containing the previously retrieved barcode
1634
+ *
1635
  * @return TIG_PostNL_Model_Core_Shipment
1636
+ *
1637
  * @throws TIG_PostNL_Exception
1638
  */
1639
  public function addTrackingCodeToShipment()
1640
  {
1641
  $shipment = $this->getShipment();
1642
  $barcode = $this->getMainBarcode();
1643
+
1644
  if (!$shipment || !$barcode) {
1645
  throw new TIG_PostNL_Exception(
1646
  Mage::helper('postnl')->__('Unable to add tracking info: no barcode or shipment available.'),
1647
  'POSTNL-0075'
1648
  );
1649
  }
1650
+
1651
  $carrierCode = self::POSTNL_CARRIER_CODE;
1652
  $carrierTitle = Mage::getStoreConfig('carriers/' . $carrierCode . '/name', $shipment->getStoreId());
1653
+
1654
  $data = array(
1655
  'carrier_code' => $carrierCode,
1656
  'title' => $carrierTitle,
1657
  'number' => $barcode,
1658
  );
1659
+
1660
  $track = Mage::getModel('sales/order_shipment_track')->addData($data);
1661
  $shipment->addTrack($track);
1662
+
1663
  /**
1664
  * Save the Mage_Sales_Order_Shipment object and the TIG_PostNL_Model_Core_Shipment objects simultaneously
1665
  */
1667
  ->addObject($this)
1668
  ->addObject($shipment)
1669
  ->save();
1670
+
1671
  return $this;
1672
  }
1673
 
1674
  /**
1675
  * Send a track & trace email to the customer containing a link to the 'mijnpakket' environment where they
1676
  * can track their shipment.
1677
+ *
1678
  * @param boolean $ignoreAlreadySent Flag to ignore the 'already sent' check
1679
+ *
1680
  * @return TIG_PostNL_Model_Core_Shipment
1681
  */
1682
  public function sendTrackAndTraceEmail($ignoreAlreadySent = false)
1687
  'POSTNL-0076'
1688
  );
1689
  }
1690
+
1691
  $oldStoreId = Mage::app()->getStore()->getId();
1692
  $storeId = $this->getStoreId();
1693
+
1694
  $template = Mage::getStoreConfig(self::XML_PATH_TRACK_AND_TRACE_EMAIL_TEMPLATE, $storeId);
1695
  $mailTemplate = Mage::getModel('core/email_template');
1696
+
1697
  $shippingAddress = $this->getShippingAddress();
1698
  $recipient = array(
1699
  'email' => $this->getShipment()->getOrder()->getCustomerEmail(),
1700
  'name' => $shippingAddress->getFirstname() . ' ' . $shippingAddress->getLastname(),
1701
  );
1702
+
1703
  $mailTemplate->setDesignConfig(
1704
  array(
1705
+ 'area' => 'frontend',
1706
  'store' => $storeId
1707
  )
1708
  );
1709
+
1710
  $shipment = $this->getShipment();
1711
  $order = $shipment->getOrder();
1712
  $templateVariables = array(
1718
  'customer' => $order->getCustomer(),
1719
  'quote' => $order->getQuote(),
1720
  );
1721
+
1722
  $orderModel = Mage::getConfig()->getModelClassName('sales/order');
1723
  $success = $mailTemplate->sendTransactional(
1724
  $template,
1727
  $recipient['name'],
1728
  $templateVariables
1729
  );
1730
+
1731
  if ($success === false) {
1732
  throw new TIG_PostNL_Exception(
1733
  Mage::helper('postnl')->__('Unable to send track and trace email for shipment #', $this->getShipmentId()),
1734
  'POSTNL-0077'
1735
  );
1736
  }
1737
+
1738
  return $this;
1739
  }
1740
+
1741
  /****************************************************************************************************************************
1742
  * BARCODE PROCESSING METHODS
1743
  ***************************************************************************************************************************/
1744
+
1745
  /**
1746
  * Add a barcode to this shipment's barcode collection
1747
+ *
1748
  * @param string $barcode The barcode to add
1749
  * @param int $barcodeNumber The number of this barcode
1750
+ *
1751
  * @return TIG_PostNL_Model_Core_Shipment
1752
  */
1753
  protected function _addBarcode($barcode, $barcodeNumber)
1757
  ->setBarcode($barcode)
1758
  ->setBarcodeNumber($barcodeNumber)
1759
  ->save();
1760
+
1761
  return $this;
1762
  }
1763
+
1764
  /****************************************************************************************************************************
1765
  * LABEL PROCESSING METHODS
1766
  ***************************************************************************************************************************/
1767
+
1768
  /**
1769
  * Add labels to this shipment
1770
+ *
1771
  * @param mixed $labels An array of labels or a single label object
1772
+ *
1773
  * @return TIG_PostNL_Model_Core_Shipment
1774
  */
1775
  public function addLabels($labels)
1781
  $this->_addLabel($labels);
1782
  return $this;
1783
  }
1784
+
1785
  /**
1786
  * Add multiple labels
1787
  */
1788
  foreach ($labels as $label) {
1789
  $this->_addLabel($label);
1790
  }
1791
+
1792
  return $this;
1793
  }
1794
+
1795
  /**
1796
  * Add a label to this shipment
1797
+ *
1798
  * @param stdClass $label
1799
+ *
1800
  * @return TIG_PostNL_Model_Core_Shipment
1801
  */
1802
  protected function _addLabel($label)
1803
  {
1804
  $labelType = $label->Labeltype;
1805
+
1806
  if ($this->_isCombiLabel()) {
1807
  $labelType = 'Label-combi';
1808
  }
1809
+
1810
  $postnlLabel = Mage::getModel('postnl_core/shipment_label');
1811
  $postnlLabel->setParentId($this->getId())
1812
  ->setLabel(base64_encode($label->Content))
1813
  ->setLabelType($labelType);
1814
+
1815
  $this->_addLabelToSave($postnlLabel);
1816
+
1817
  return $this;
1818
  }
1819
+
1820
  /**
1821
  * Store the label in an array to be saved later
1822
+ *
1823
  * @param TIG_PostNL_Model_Core_Shipment_Label $label
1824
+ *
1825
  * @return TIG_PostNL_Model_Core_Shipment
1826
  */
1827
  protected function _addLabelToSave($label)
1828
  {
1829
  $labelsToSave = $this->getlabelsToSave();
1830
+
1831
  $labelsToSave[] = $label;
1832
+
1833
  $this->setLabelsToSave($labelsToSave);
1834
+
1835
  return $this;
1836
  }
1837
+
1838
  /**
1839
  * Save all newly added labels at once
1840
+ *
1841
  * @return TIG_PostNL_Model_Core_Shipment
1842
  */
1843
  protected function _saveLabels()
1844
  {
1845
  $transactionSave = Mage::getModel('core/resource_transaction');
1846
+
1847
  /**
1848
  * Add all labels to the transaction
1849
  */
1850
  $labelsToSave = $this->getLabelsToSave();
1851
+
1852
  Mage::dispatchEvent('postnl_shipment_savelabels_before', array('shipment' => $this, 'labels' => $labelsToSave));
1853
+
1854
  foreach ($labelsToSave as $label) {
1855
  $transactionSave->addObject($label);
1856
  }
1857
+
1858
  /**
1859
  * Save the transaction
1860
  */
1861
  $transactionSave->save();
1862
+
1863
  Mage::dispatchEvent('postnl_shipment_savelabels_after', array('shipment' => $this, 'labels' => $labelsToSave));
1864
+
1865
  return $this;
1866
  }
1867
+
1868
  /**
1869
  * Check if the returned label is a combi-label
1870
+ *
1871
  * @param TIG_PostNL_Model_Core_Shipment_label
1872
+ *
1873
  * @return boolean
1874
  */
1875
  protected function _isCombiLabel()
1877
  if (!$this->isEuShipment()) {
1878
  return false;
1879
  }
1880
+
1881
  /**
1882
  * All EU shipments will by default request a combi label. If no warnings were sent by CIF it means everything
1883
  * went as expected and a combi-label was returned.
1886
  if (!$warnings) {
1887
  return true;
1888
  }
1889
+
1890
  /**
1891
  * Check each warning if the code matches the EPS combi label warning code
1892
  */
1895
  return false;
1896
  }
1897
  }
1898
+
1899
  return true;
1900
  }
1901
+
1902
  /****************************************************************************************************************************
1903
  * STATUS PROCESSING METHODS
1904
  ***************************************************************************************************************************/
1905
+
1906
  /**
1907
  * Sort a status history array based on the time the status was assigned
1908
+ *
1909
  * @param array $statusHistory
1910
+ *
1911
  * @return array
1912
  */
1913
  protected function _sortStatusHistory($statusHistory)
1919
  foreach ($statusHistory as $status) {
1920
  $timestamp = $status->TimeStamp;
1921
  $timestamp = strtotime($timestamp);
1922
+
1923
  $sortedHistory[$timestamp] = $status;
1924
  }
1925
+
1926
  /**
1927
  * Sort the array based on the timestamps
1928
  */
1929
  ksort($sortedHistory);
1930
+
1931
  /**
1932
  * Return only the values (the statusses) of the array
1933
  */
1934
  return array_values($sortedHistory);
1935
  }
1936
+
1937
  /****************************************************************************************************************************
1938
  * PRODUCT CODE METHODS
1939
  ***************************************************************************************************************************/
1941
  /**
1942
  * Gets the product code for this shipment. If specific options have been selected
1943
  * those will be used. Otherwise the default options will be used from system/config
1944
+ *
1945
  * @return int
1946
  */
1947
  protected function _getProductCode()
1952
  if (Mage::registry('postnl_product_option')) {
1953
  $productCode = Mage::registry('postnl_product_option');
1954
  $this->_checkProductCodeAllowed($productCode);
1955
+
1956
  return $productCode;
1957
  }
1958
+
1959
  /**
1960
  * Use default options
1961
  */
1962
  $productCode = $this->getDefaultProductCode();
1963
+
1964
  return $productCode;
1965
  }
1966
+
1967
  /**
1968
  * Checks if a given product code is allowed for the current shipments. Throws an exception if not.
1969
+ *
1970
  * @param string $productCode
1971
+ *
1972
  * @return boolean
1973
+ *
1974
  * @throws TIG_PostNL_Exception
1975
  */
1976
  protected function _checkProductCodeAllowed($productCode)
1977
  {
1978
  $cifHelper = $this->getHelper('cif');
1979
  $allowedProductCodes = array();
1980
+
1981
  /**
1982
  * PakjeGemak shipments are also dutch shipments
1983
  */
1984
  if ($this->isDutchShipment() && $this->isPakjeGemakShipment()) {
1985
  $allowedProductCodes = $cifHelper->getPakjeGemakProductCodes();
1986
  }
1987
+
1988
  /**
1989
  * Here we specifically want shipments that are dutch, but not PakjeGemak
1990
  */
1991
  if ($this->isDutchShipment() && !$this->isPakjeGemakShipment()) {
1992
  $allowedProductCodes = $cifHelper->getStandardProductCodes();
1993
  }
1994
+
1995
  if ($this->isEuShipment()) {
1996
  $allowedProductCodes = $cifHelper->getEuProductCodes();
1997
+
1998
  }
1999
+
2000
  if ($this->isGlobalShipment()) {
2001
  if (!$cifHelper->isGlobalAllowed()) {
2002
  throw new TIG_PostNL_Exception(
2004
  'POSTNL-0078'
2005
  );
2006
  }
2007
+
2008
  $allowedProductCodes = $cifHelper->getGlobalProductCodes();
2009
  }
2010
+
2011
  /**
2012
  * Check if the product code is allowed
2013
  */
2017
  'POSTNL-0078'
2018
  );
2019
  }
2020
+
2021
  /**
2022
  * Check if the product code is restricted to certain countries
2023
  */
2025
  if ($allowedCountries === false) {
2026
  return true;
2027
  }
2028
+
2029
  /**
2030
  * Check if the destination country of this shipment is allowed
2031
  */
2036
  'POSTNL-0078'
2037
  );
2038
  }
2039
+
2040
  return true;
2041
  }
2042
 
2043
  /**
2044
  * Checks if a given product code is only allowed for a specific country
2045
+ *
2046
  * @return boolean|array Either false if the code is not restricted, or otherwise an array of allowed country IDs
2047
  */
2048
  protected function _isCodeRestricted($code)
2049
  {
2050
  $countryRestrictedCodes = $this->getHelper('cif')->getCountryRestrictedProductCodes();
2051
+
2052
  /**
2053
  * Check if the supplied code is restricted
2054
  */
2055
  if (!array_key_exists($code, $countryRestrictedCodes)) {
2056
  return false;
2057
  }
2058
+
2059
  /**
2060
  * Get the countries that are allowed
2061
  */
2062
  $allowedCountries = $countryRestrictedCodes[$code];
2063
  return $allowedCountries;
2064
  }
2065
+
2066
  /****************************************************************************************************************************
2067
  * ADDITIONAL SHIPMENT OPTIONS
2068
  ***************************************************************************************************************************/
2069
+
2070
  /**
2071
  * Public alias for _saveAdditionalShippingOptions()
2072
+ *
2073
  * @return TIG_PostNL_Model_Core_Shipment
2074
+ *
2075
  * @see TIG_PostNL_Model_Core_Shipment::_saveAdditionalShippingOptions()
2076
  */
2077
  public function saveAdditionalShippingOptions()
2078
  {
2079
  return $this->_saveAdditionalShippingOptions();
2080
  }
2081
+
2082
  /**
2083
  * Stores additionally selected shipping options
2084
+ *
2085
  * @return TIG_PostNL_Model_Core_Shipment
2086
  */
2087
  protected function _saveAdditionalShippingOptions()
2090
  if (!$additionalOptions || !is_array($additionalOptions)) {
2091
  return $this;
2092
  }
2093
+
2094
  foreach($additionalOptions as $option => $value) {
2095
  $this->setDataUsingMethod($option, $value);
2096
  }
2097
+
2098
  Mage::dispatchEvent(
2099
+ 'postnl_shipment_saveadditionaloptions_after',
2100
  array(
2101
+ 'shipment' => $this,
2102
  'options' => $additionalOptions
2103
  )
2104
  );
2105
+
2106
  Mage::unRegister('postnl_additional_options');
2107
+
2108
  return $this;
2109
  }
2110
+
2111
  /**
2112
  * Get the number of parcels in this shipment
2113
+ *
2114
  * @return int
2115
  */
2116
  protected function _calculateParcelCount()
2121
  if (!$this->isDutchShipment()) {
2122
  return 1;
2123
  }
2124
+
2125
  /**
2126
  * get this shipment's total weight
2127
  */
2128
  $weight = $this->getTotalWeight(true);
2129
+
2130
  /**
2131
  * get the weight per parcel
2132
  */
2133
  $weightPerParcel = Mage::getStoreConfig(self::XML_PATH_WEIGHT_PER_PARCEL, $this->getStoreId());
2134
  $weightPerParcel = $this->getHelper('cif')->standardizeWeight($weightPerParcel, $this->getStoreId());
2135
+
2136
  /**
2137
  * calculate the number of parcels needed to ship the total weight of this shipment
2138
  */
2139
  $parcelCount = ceil($weight / $weightPerParcel);
2140
+
2141
  return $parcelCount;
2142
  }
2143
+
2144
  /****************************************************************************************************************************
2145
  * RESET AND DELETE METHODS
2146
  ***************************************************************************************************************************/
2147
+
2148
  /**
2149
  * Resets this shipment to a pre-confirmed state
2150
+ *
2151
+ * @param boolean $deleteLabels
2152
+ * @param boolean $deleteTracks
2153
+ *
2154
+ * @return $this
2155
  */
2156
+ public function resetConfirmation($deleteLabels = true, $deleteTracks = true)
2157
  {
2158
  $this->setConfirmStatus(self::CONFIRM_STATUS_UNCONFIRMED) //set status to unconfirmed
2159
  ->setShippingPhase(false) //delete current shipping phase
2160
  ->setConfirmedAt(false) //delete 'confirmed at' date
 
 
2161
  ->deleteBarcodes() //delete all associated barcodes
2162
  ->deleteStatusHistory(); //delete all associated status history items
2163
+
2164
+ if ($deleteLabels) {
2165
+ $this->setlabelsPrinted(false) //labels have not been printed
2166
+ ->deleteLabels(); //delete all associated labels
2167
+ }
2168
+
2169
+ if ($deleteTracks) {
2170
+ $this->deleteShipmentTracks(); //delete ale addociated tracks
2171
+ }
2172
+
2173
  return $this;
2174
  }
2175
+
2176
+ /**
2177
+ * Delete alle tracks for this shipment.
2178
+ *
2179
+ * @return $this
2180
+ */
2181
+ public function deleteShipmentTracks()
2182
+ {
2183
+ $shipment = $this->getShipment();
2184
+
2185
+ /**
2186
+ * @var Mage_Sales_Model_Order_Shipment_Track $track
2187
+ */
2188
+ $tracksCollection = $shipment->getTracksCollection();
2189
+ foreach($tracksCollection as $track) {
2190
+ $track->delete();
2191
+ }
2192
+
2193
+ return $this;
2194
+ }
2195
+
2196
  /**
2197
  * Removes all labels associated with this shipment
2198
+ *
2199
  * @return TIG_PostNL_Model_Core_Shipment
2200
  */
2201
  public function deleteLabels()
2202
  {
2203
  $labelCollection = Mage::getResourceModel('postnl_core/shipment_label_collection');
2204
  $labelCollection->addFieldToFilter('parent_id', array('eq' => $this->getid()));
2205
+
2206
  $labels = $labelCollection->getItems();
2207
+
2208
  foreach ($labels as $label) {
2209
  $label->delete()
2210
  ->save();
2211
  }
2212
+
2213
  return $this;
2214
  }
2215
+
2216
  /**
2217
  * Removes all barcodes associated with this shipment
2218
+ *
2219
  * @return TIG_PostNL_Model_Core_Shipment
2220
  */
2221
  public function deleteBarcodes()
2222
  {
2223
  $barcodes = $this->getBarcodes(true);
2224
+
2225
  foreach ($barcodes as $barcode) {
2226
  $barcode->delete()
2227
  ->save();
2228
  }
2229
+
2230
  $this->setMainBarcode(false);
2231
+
2232
  return $this;
2233
  }
2234
+
2235
  /**
2236
  * Deletes all status history items associated with this shipment
2237
+ *
2238
  * @return TIG_PostNL_Model_Core_Shipment
2239
  */
2240
  public function deleteStatusHistory()
2241
  {
2242
  $statusHistoryCollection = Mage::getResourceModel('postnl_core/shipment_status_history_collection');
2243
  $statusHistoryCollection->addFieldToFilter('parent_id', array('eq' => $this->getid()));
2244
+
2245
  foreach ($statusHistoryCollection as $status) {
2246
  $status->delete()
2247
  ->save();
2248
  }
2249
+
2250
  return $this;
2251
  }
2252
+
2253
  /****************************************************************************************************************************
2254
  * BEFORE- AND AFTERSAVE METHODS
2255
  ***************************************************************************************************************************/
2256
+
2257
  /**
2258
  * Updates the shipment's attributes before saving this shipment
2259
+ *
2260
  * @return Mage_Core_Model_Abstract::_beforeSave
2261
  */
2262
  protected function _beforeSave()
2263
  {
2264
  $currentTimestamp = Mage::getModel('core/date')->gmtTimestamp();
2265
+
2266
  /**
2267
  * Store any shipment options that have been saved in the registry
2268
  */
2269
  if (Mage::registry('postnl_additional_options')) {
2270
  $this->_saveAdditionalShippingOptions();
2271
  }
2272
+
2273
  /**
2274
  * Set confirm status
2275
  */
2276
  if ($this->getConfirmStatus() === null) {
2277
  $this->setConfirmStatus(self::CONFIRM_STATUS_UNCONFIRMED);
2278
  }
2279
+
2280
  /**
2281
  * Set confrirmed at
2282
  */
2285
  ) {
2286
  $this->setConfirmedAt($currentTimestamp);
2287
  }
2288
+
2289
  /**
2290
  * Set whether labels have printed or not
2291
  */
2292
  if ($this->getlabelsPrinted() == 0 && $this->hasLabels()) {
2293
  $this->setLabelsPrinted(1);
2294
  }
2295
+
2296
  /**
2297
  * Set a product code
2298
  */
2300
  $productCode = $this->_getProductCode();
2301
  $this->setProductCode($productCode);
2302
  }
2303
+
2304
  /**
2305
  * Set the parcel count
2306
  */
2308
  $parcelCount = $this->_calculateParcelCount();
2309
  $this->setParcelCount($parcelCount);
2310
  }
2311
+
2312
  /**
2313
  * Set the confirm date
2314
  */
2315
  if (!$this->getConfirmDate()) {
2316
  $this->setConfirmDate($currentTimestamp);
2317
  }
2318
+
2319
  /**
2320
  * If this shipment is new, set it's created at date to the current timestamp
2321
  */
2322
  if (!$this->getId()) {
2323
  $this->setCreatedAt($currentTimestamp);
2324
  }
2325
+
2326
  /**
2327
  * Always update the updated at timestamp to the current timestamp
2328
  */
2329
  $this->setUpdatedAt($currentTimestamp);
2330
+
2331
  return parent::_beforeSave();
2332
  }
2333
  }
app/code/community/TIG/PostNL/Model/Core/Shipment/Process.php CHANGED
@@ -1,28 +1,28 @@
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@totalinternetgroup.nl so we can send you a copy immediately.
@@ -40,16 +40,16 @@ class TIG_PostNL_Model_Core_Shipment_Process extends Mage_Index_Model_Process
40
  {
41
  /**
42
  * Flag to dtermine if the process is locked
43
- *
44
  * @var null | boolean
45
  */
46
  protected $_isLocked = null;
47
-
48
  /**
49
  * Get lock file resource
50
  *
51
  * @param boolean $asFile
52
- *
53
  * @return resource | TIG_PostNL_Model_Core_Shipment_Process
54
  */
55
  protected function _getLockFile($asPath = false)
@@ -57,22 +57,22 @@ class TIG_PostNL_Model_Core_Shipment_Process extends Mage_Index_Model_Process
57
  if ($this->_lockFile !== null) {
58
  return $this->_lockFile;
59
  }
60
-
61
  $varDir = Mage::getConfig()->getVarDir('locks');
62
  $file = $varDir . DS . 'postnl_process_' . $this->getId() . '.lock';
63
-
64
  $this->_lockFile = fopen($file, 'w');
65
-
66
  $timestamp = Mage::getModel('core/date')->gmtTimestamp();
67
  fwrite($this->_lockFile, date('r', $timestamp));
68
-
69
  if ($asPath === true) {
70
  return $file;
71
  }
72
-
73
  return $this->_lockFile;
74
  }
75
-
76
  /**
77
  * Lock process without blocking.
78
  * This method allow protect multiple process running and fast lock validation.
@@ -82,27 +82,27 @@ class TIG_PostNL_Model_Core_Shipment_Process extends Mage_Index_Model_Process
82
  public function lock()
83
  {
84
  $this->_isLocked = true;
85
-
86
  flock($this->_getLockFile(), LOCK_EX | LOCK_NB);
87
 
88
  return $this;
89
  }
90
-
91
  /**
92
  * Lock and block process
93
- *
94
  * @return TIG_PostNL_Model_Core_Shipment_Process
95
  */
96
  public function lockAndBlock()
97
  {
98
  $this->_isLocked = true;
99
  $file = $this->_getLockFile();
100
-
101
  flock($this->_getLockFile(), LOCK_EX);
102
-
103
  return $this;
104
  }
105
-
106
  /**
107
  * Unlock process
108
  *
@@ -112,15 +112,17 @@ class TIG_PostNL_Model_Core_Shipment_Process extends Mage_Index_Model_Process
112
  {
113
  $this->_isLocked = false;
114
  $file = $this->_getLockFile();
115
-
116
  flock($file, LOCK_UN);
117
  fclose($file);
118
-
119
  //remove lockfile
120
  $varDir = Mage::getConfig()->getVarDir('locks');
121
  $lockFile = $varDir . DS . 'postnl_process_' . $this->getId() . '.lock';
122
  @unlink($lockFile);
123
-
 
 
124
  return $this;
125
  }
126
 
@@ -134,47 +136,47 @@ class TIG_PostNL_Model_Core_Shipment_Process extends Mage_Index_Model_Process
134
  if ($this->_isLocked !== null) {
135
  return $this->_isLocked;
136
  }
137
-
138
  $fp = $this->_getLockFile();
139
  if (flock($fp, LOCK_EX | LOCK_NB)) {
140
  flock($fp, LOCK_UN);
141
  return false;
142
  }
143
  fclose($fp);
144
-
145
  //if the lock exists and exists for longer then 5minutes then remove lock & return false
146
  if($this->_lockIsExpired()){
147
  $varDir = Mage::getConfig()->getVarDir('locks');
148
  $lockFile = $varDir . DS . 'postnl_process_' . $this->getId() . '.lock';
149
  @unlink($lockFile);
150
-
151
  $this->_getLockFile();//create new lock file
152
  return false;
153
  }
154
-
155
  return true;
156
  }
157
-
158
  /**
159
  * Checks if the lock has expired
160
- *
161
  * @return bool
162
  */
163
  protected function _lockIsExpired()
164
  {
165
  $file = $this->_getLockFile(true);
166
-
167
  if(!is_file($file)){
168
  $fp = fopen($file, 'x');
169
  fwrite($fp, date('r'));
170
  fclose($fp);
171
  return false;
172
  }
173
-
174
  $fiveMinAgo = time() - 300;//300
175
  $contents = file_get_contents($file);
176
  $time = strtotime($contents);
177
-
178
  if($time <= $fiveMinAgo){
179
  $fp = fopen($file,'w');
180
  flock($fp, LOCK_UN);
@@ -182,12 +184,12 @@ class TIG_PostNL_Model_Core_Shipment_Process extends Mage_Index_Model_Process
182
  @unlink($file);
183
  return true;
184
  }
185
-
186
  return false;
187
  }
188
 
189
  public function __destruct()
190
  {
191
-
192
  }
193
  }
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@totalinternetgroup.nl so we can send you a copy immediately.
40
  {
41
  /**
42
  * Flag to dtermine if the process is locked
43
+ *
44
  * @var null | boolean
45
  */
46
  protected $_isLocked = null;
47
+
48
  /**
49
  * Get lock file resource
50
  *
51
  * @param boolean $asFile
52
+ *
53
  * @return resource | TIG_PostNL_Model_Core_Shipment_Process
54
  */
55
  protected function _getLockFile($asPath = false)
57
  if ($this->_lockFile !== null) {
58
  return $this->_lockFile;
59
  }
60
+
61
  $varDir = Mage::getConfig()->getVarDir('locks');
62
  $file = $varDir . DS . 'postnl_process_' . $this->getId() . '.lock';
63
+
64
  $this->_lockFile = fopen($file, 'w');
65
+
66
  $timestamp = Mage::getModel('core/date')->gmtTimestamp();
67
  fwrite($this->_lockFile, date('r', $timestamp));
68
+
69
  if ($asPath === true) {
70
  return $file;
71
  }
72
+
73
  return $this->_lockFile;
74
  }
75
+
76
  /**
77
  * Lock process without blocking.
78
  * This method allow protect multiple process running and fast lock validation.
82
  public function lock()
83
  {
84
  $this->_isLocked = true;
85
+
86
  flock($this->_getLockFile(), LOCK_EX | LOCK_NB);
87
 
88
  return $this;
89
  }
90
+
91
  /**
92
  * Lock and block process
93
+ *
94
  * @return TIG_PostNL_Model_Core_Shipment_Process
95
  */
96
  public function lockAndBlock()
97
  {
98
  $this->_isLocked = true;
99
  $file = $this->_getLockFile();
100
+
101
  flock($this->_getLockFile(), LOCK_EX);
102
+
103
  return $this;
104
  }
105
+
106
  /**
107
  * Unlock process
108
  *
112
  {
113
  $this->_isLocked = false;
114
  $file = $this->_getLockFile();
115
+
116
  flock($file, LOCK_UN);
117
  fclose($file);
118
+
119
  //remove lockfile
120
  $varDir = Mage::getConfig()->getVarDir('locks');
121
  $lockFile = $varDir . DS . 'postnl_process_' . $this->getId() . '.lock';
122
  @unlink($lockFile);
123
+
124
+ $this->_lockFile = null;
125
+
126
  return $this;
127
  }
128
 
136
  if ($this->_isLocked !== null) {
137
  return $this->_isLocked;
138
  }
139
+
140
  $fp = $this->_getLockFile();
141
  if (flock($fp, LOCK_EX | LOCK_NB)) {
142
  flock($fp, LOCK_UN);
143
  return false;
144
  }
145
  fclose($fp);
146
+
147
  //if the lock exists and exists for longer then 5minutes then remove lock & return false
148
  if($this->_lockIsExpired()){
149
  $varDir = Mage::getConfig()->getVarDir('locks');
150
  $lockFile = $varDir . DS . 'postnl_process_' . $this->getId() . '.lock';
151
  @unlink($lockFile);
152
+
153
  $this->_getLockFile();//create new lock file
154
  return false;
155
  }
156
+
157
  return true;
158
  }
159
+
160
  /**
161
  * Checks if the lock has expired
162
+ *
163
  * @return bool
164
  */
165
  protected function _lockIsExpired()
166
  {
167
  $file = $this->_getLockFile(true);
168
+
169
  if(!is_file($file)){
170
  $fp = fopen($file, 'x');
171
  fwrite($fp, date('r'));
172
  fclose($fp);
173
  return false;
174
  }
175
+
176
  $fiveMinAgo = time() - 300;//300
177
  $contents = file_get_contents($file);
178
  $time = strtotime($contents);
179
+
180
  if($time <= $fiveMinAgo){
181
  $fp = fopen($file,'w');
182
  flock($fp, LOCK_UN);
184
  @unlink($file);
185
  return true;
186
  }
187
+
188
  return false;
189
  }
190
 
191
  public function __destruct()
192
  {
193
+
194
  }
195
  }
app/code/community/TIG/PostNL/Model/Core/System/Config/Source/AllProductOptions.php CHANGED
@@ -174,15 +174,16 @@ class TIG_PostNL_Model_Core_System_Config_Source_AllProductOptions
174
  'label' => $helper->__('EU Pack Special Consumer (incl. signature)'),
175
  ),
176
  /**
177
- * This option will be removed in v1.2.0
178
  *
179
  * @deprecated v1.1.2
180
  */
 
181
  '4955' => array(
182
  'value' => '4955',
183
  'label' => $helper->__('EU Pack Standard (Belgium only, no signature)'),
184
  'isBelgiumOnly' => true,
185
- ),
186
  /**
187
  * These are not currently implemented
188
  *
@@ -210,6 +211,14 @@ class TIG_PostNL_Model_Core_System_Config_Source_AllProductOptions
210
  ),
211
  );
212
 
 
 
 
 
 
 
 
 
213
  $this->_markDefault($availableOptions);
214
 
215
  return $availableOptions;
@@ -218,10 +227,10 @@ class TIG_PostNL_Model_Core_System_Config_Source_AllProductOptions
218
  /**
219
  * Get a list of available options. This is a filtered/modified version of the array supplied by toOptionArray();
220
  *
221
- * @param boolean $withDefault Determines whether or not a 'default' option is prepended to the array
222
- * @param boolean $witHExtraCover Flag whether or not to include extra cover options
223
  * @param boolean|int $storeId
224
- * @param boolean $codesOnly
225
  *
226
  * @return array
227
  */
@@ -232,6 +241,8 @@ class TIG_PostNL_Model_Core_System_Config_Source_AllProductOptions
232
  }
233
 
234
  $helper = Mage::helper('postnl');
 
 
235
  $options = $this->toOptionArray();
236
 
237
  /**
@@ -254,6 +265,9 @@ class TIG_PostNL_Model_Core_System_Config_Source_AllProductOptions
254
  */
255
  $supportedOptions = Mage::getStoreConfig(self::XML_PATH_SUPPORTED_PRODUCT_OPTIONS, $storeId);
256
  $supportedOptionsArray = explode(',', $supportedOptions);
 
 
 
257
 
258
  /**
259
  * Check each standard option to see if it's supprted
174
  'label' => $helper->__('EU Pack Special Consumer (incl. signature)'),
175
  ),
176
  /**
177
+ * This option has been removed since v1.1.4.
178
  *
179
  * @deprecated v1.1.2
180
  */
181
+ /*
182
  '4955' => array(
183
  'value' => '4955',
184
  'label' => $helper->__('EU Pack Standard (Belgium only, no signature)'),
185
  'isBelgiumOnly' => true,
186
+ ),*/
187
  /**
188
  * These are not currently implemented
189
  *
211
  ),
212
  );
213
 
214
+ if ($helper->canUseEpsBEOnlyOption()) {
215
+ $availableOptions['eu_options']['value']['4955'] = array(
216
+ 'value' => '4955',
217
+ 'label' => $helper->__('EU Pack Standard (Belgium only, no signature)'),
218
+ 'isBelgiumOnly' => true,
219
+ );
220
+ }
221
+
222
  $this->_markDefault($availableOptions);
223
 
224
  return $availableOptions;
227
  /**
228
  * Get a list of available options. This is a filtered/modified version of the array supplied by toOptionArray();
229
  *
230
+ * @param boolean $withDefault Determines whether or not a 'default' option is prepended to the array
231
+ * @param bool $withExtraCover
232
  * @param boolean|int $storeId
233
+ * @param boolean $codesOnly
234
  *
235
  * @return array
236
  */
241
  }
242
 
243
  $helper = Mage::helper('postnl');
244
+ $canUseEpsBEOnly = $helper->canUseEpsBEOnlyOption();
245
+
246
  $options = $this->toOptionArray();
247
 
248
  /**
265
  */
266
  $supportedOptions = Mage::getStoreConfig(self::XML_PATH_SUPPORTED_PRODUCT_OPTIONS, $storeId);
267
  $supportedOptionsArray = explode(',', $supportedOptions);
268
+ if ($canUseEpsBEOnly) {
269
+ $supportedOptionsArray[] = '4955';
270
+ }
271
 
272
  /**
273
  * Check each standard option to see if it's supprted
app/code/community/TIG/PostNL/Model/Core/System/Config/Source/EuProductOptions.php CHANGED
@@ -59,15 +59,15 @@ class TIG_PostNL_Model_Core_System_Config_Source_EuProductOptions
59
  'label' => $helper->__('EU Pack Special Consumer (incl. signature)'),
60
  ),
61
  /**
62
- * This option will be removed in v1.2.0
63
  *
64
  * @deprecated v1.1.2
65
  */
66
- array(
67
  'value' => '4955',
68
  'label' => $helper->__('EU Pack Standard (Belgium only, no signature)'),
69
  'isBelgiumOnly' => true,
70
- ),
71
  /**
72
  * These are not currently implemented
73
  *
@@ -84,6 +84,14 @@ class TIG_PostNL_Model_Core_System_Config_Source_EuProductOptions
84
  ),*/
85
  );
86
 
 
 
 
 
 
 
 
 
87
  return $availableOptions;
88
  }
89
 
@@ -91,7 +99,7 @@ class TIG_PostNL_Model_Core_System_Config_Source_EuProductOptions
91
  * Get a list of available options. This is a filtered/modified version of the array supplied by toOptionArray();
92
  *
93
  * @param boolean|int $storeId
94
- * @param boolean $codesOnly
95
  *
96
  * @return array
97
  */
@@ -102,6 +110,8 @@ class TIG_PostNL_Model_Core_System_Config_Source_EuProductOptions
102
  }
103
 
104
  $helper = Mage::helper('postnl');
 
 
105
  $options = $this->toOptionArray();
106
 
107
  /**
@@ -114,11 +124,13 @@ class TIG_PostNL_Model_Core_System_Config_Source_EuProductOptions
114
  */
115
  $supportedOptions = Mage::getStoreConfig(self::XML_PATH_SUPPORTED_PRODUCT_OPTIONS, $storeId);
116
  $supportedOptionsArray = explode(',', $supportedOptions);
 
 
 
117
 
118
  /**
119
  * Check each standard option to see if it's supprted
120
  */
121
- $availableStandardOptions = array();
122
  foreach ($options as $option) {
123
  if (!in_array($option['value'], $supportedOptionsArray)) {
124
  continue;
59
  'label' => $helper->__('EU Pack Special Consumer (incl. signature)'),
60
  ),
61
  /**
62
+ * This option has been removed in v1.1.4
63
  *
64
  * @deprecated v1.1.2
65
  */
66
+ /*array(
67
  'value' => '4955',
68
  'label' => $helper->__('EU Pack Standard (Belgium only, no signature)'),
69
  'isBelgiumOnly' => true,
70
+ ),*/
71
  /**
72
  * These are not currently implemented
73
  *
84
  ),*/
85
  );
86
 
87
+ if ($helper->canUseEpsBEOnlyOption()) {
88
+ $availableOptions['4955'] = array(
89
+ 'value' => '4955',
90
+ 'label' => $helper->__('EU Pack Standard (Belgium only, no signature)'),
91
+ 'isBelgiumOnly' => true,
92
+ );
93
+ }
94
+
95
  return $availableOptions;
96
  }
97
 
99
  * Get a list of available options. This is a filtered/modified version of the array supplied by toOptionArray();
100
  *
101
  * @param boolean|int $storeId
102
+ * @param boolean $codesOnly
103
  *
104
  * @return array
105
  */
110
  }
111
 
112
  $helper = Mage::helper('postnl');
113
+ $canUseEpsBEOnly = $helper->canUseEpsBEOnlyOption();
114
+
115
  $options = $this->toOptionArray();
116
 
117
  /**
124
  */
125
  $supportedOptions = Mage::getStoreConfig(self::XML_PATH_SUPPORTED_PRODUCT_OPTIONS, $storeId);
126
  $supportedOptionsArray = explode(',', $supportedOptions);
127
+ if ($canUseEpsBEOnly) {
128
+ $supportedOptionsArray[] = '4955';
129
+ }
130
 
131
  /**
132
  * Check each standard option to see if it's supprted
133
  */
 
134
  foreach ($options as $option) {
135
  if (!in_array($option['value'], $supportedOptionsArray)) {
136
  continue;
app/code/community/TIG/PostNL/Model/Resource/Setup.php CHANGED
@@ -1,28 +1,28 @@
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@totalinternetgroup.nl so we can send you a copy immediately.
@@ -43,139 +43,151 @@ class TIG_PostNL_Model_Resource_Setup extends Mage_Core_Model_Resource_Setup
43
  */
44
  const SHIPPING_STATUS_CRON_STRING_PATH = 'crontab/jobs/postnl_update_shipping_status/schedule/cron_expr';
45
  const SHIPPING_STATUS_CRON_MODEL_PATH = 'crontab/jobs/postnl_update_shipping_status/run/model';
46
-
47
  /**
48
  * Cron expression and cron model definitions for statistics update cron
49
  */
50
  const UPDATE_STATISTICS_CRON_STRING_PATH = 'crontab/jobs/postnl_update_statistics/schedule/cron_expr';
51
  const UPDATE_STATISTICS_CRON_MODEL_PATH = 'crontab/jobs/postnl_update_statistics/run/model';
52
-
53
  /**
54
  * XML path to the supporttab_expanded setting
55
  */
56
  const EXPAND_SUPPORT_PATH = 'postnl/support/expanded';
57
-
 
 
 
 
 
 
 
 
 
 
 
 
58
  /**
59
  * callAfterApplyAllUpdates flag. Causes applyAFterUpdates() to be called.
60
- *
61
  * @var boolean
62
  */
63
  protected $_callAfterApplyAllUpdates = true;
64
-
65
  /**
66
  * Module version as stored in the db at the time of the update
67
- *
68
  * @var string
69
  */
70
  protected $_dbVer;
71
-
72
  /**
73
  * Module version as specified in the module's configuration at the time of the update
74
- *
75
  * @var string
76
  */
77
  protected $_configVer;
78
-
79
  /**
80
  * Set the stored DB version to the specified value
81
- *
82
  * @param string $dbVer
83
- *
84
- * @return TIG_PostNL_Model_Resource_Setup
85
  */
86
  public function setDbVer($dbVer)
87
  {
88
  $this->_dbVer = $dbVer;
89
-
90
  return $this;
91
  }
92
-
93
  /**
94
  * Set the stored config version to the specified value
95
- *
96
  * @param string $configVer
97
- *
98
- * @return TIG_PostNL_Model_Resource_Setup
99
  */
100
  public function setConfigVer($configVer)
101
  {
102
  $this->_configVer = $configVer;
103
-
104
  return $this;
105
  }
106
-
107
  /**
108
  * Get the stored DB version
109
- *
110
  * @return string
111
  */
112
  public function getDbVer()
113
  {
114
  return $this->_dbVer;
115
  }
116
-
117
  /**
118
  * get the stored config version
119
- *
120
  * @return string
121
  */
122
  public function getConfigVer()
123
  {
124
  return $this->_configVer;
125
  }
126
-
127
  /**
128
  * Store the applied update versions
129
- *
130
  * @return parent::applyUpdates()
131
  */
132
  public function applyUpdates()
133
  {
134
  $dbVer = $this->_getResource()->getDbVersion($this->_resourceName);
135
  $configVer = (string)$this->_moduleConfig->version;
136
-
137
  $this->setDbVer($dbVer);
138
  $this->setConfigVer($configVer);
139
-
140
  return parent::applyUpdates();
141
  }
142
 
143
  /**
144
  * Check if the PostNL module has been updated. If so, add an admin notification to the inbox.
145
  *
146
- * @return TIG_PostNL_Model_Resource_Setup
147
- *
148
- * @todo prevent window from being shown after every login
149
  */
150
  public function afterApplyAllUpdates()
151
  {
152
  $dbVer = $this->getDbVer();
153
  $configVer = $this->getConfigVer();
154
-
155
  $this->_checkVersionCompatibility();
156
-
157
  if (version_compare($configVer, $dbVer) != self::VERSION_COMPARE_GREATER) {
158
  return $this;
159
  }
160
-
161
  $helper = Mage::helper('postnl');
162
-
163
  $inbox = Mage::getModel('postnl/inbox');
164
  $inbox->addNotice(
165
  '[POSTNL-0083] ' . $helper->__('PostNL extension has been successfully updated to version %s.', $configVer),
166
  '[POSTNL-0083] ' . $helper->__('PostNL extension has been successfully updated to version %s.', $configVer),
167
- 'http://kb.totalinternetgroup.nl/topic/31921907',
168
  true
169
  )
170
  ->save();
171
-
172
  return $this;
173
  }
174
-
175
  /**
176
  * Generate a random cron expression for the status update cron for this merchant and store it in the database
177
- *
178
- * @return TIG_PostNL_Model_Resource_Setup
 
 
179
  */
180
  public function generateShippingStatusCronExpr()
181
  {
@@ -184,15 +196,15 @@ class TIG_PostNL_Model_Resource_Setup extends Mage_Core_Model_Resource_Setup
184
  */
185
  $cronMorningHour = mt_rand(10, 12);
186
  $cronMorningHour += Mage::getModel('core/date')->getGmtOffset('hours');
187
-
188
  $cronAfternoonHour = $cronMorningHour + 4; //4 hours after the morning update
189
  $cronMinute = mt_rand(0, 59);
190
-
191
  /**
192
  * Generate a cron expr that runs on a specified minute on a specified hour between 10 and 12 AM, and between 14 and 16 PM.
193
  */
194
  $cronExpr = "{$cronMinute} {$cronMorningHour},{$cronAfternoonHour} * * *";
195
-
196
  /**
197
  * Store the cron expression in core_config_data
198
  */
@@ -214,15 +226,17 @@ class TIG_PostNL_Model_Resource_Setup extends Mage_Core_Model_Resource_Setup
214
  $e
215
  );
216
  }
217
-
218
  return $this;
219
  }
220
-
221
  /**
222
  * Generates a semi-random cron expression for the update statistics cron. This is done to spread out the number of calls
223
  * across each day.
224
- *
225
- * @return TIG_PostNL_Model_Resource_Setup
 
 
226
  */
227
  public function generateUpdateStatisticsCronExpr()
228
  {
@@ -232,12 +246,12 @@ class TIG_PostNL_Model_Resource_Setup extends Mage_Core_Model_Resource_Setup
232
  $cronMorningHour = mt_rand(0, 11);
233
  $cronAfternoonHour = $cronMorningHour + 12; //half a day after the morning update
234
  $cronMinute = mt_rand(0, 59);
235
-
236
  /**
237
  * Generate a cron expr that runs on a specified minute on a specified hour twice per day.
238
  */
239
  $cronExpr = "{$cronMinute} {$cronMorningHour},{$cronAfternoonHour} * * *";
240
-
241
  /**
242
  * Store the cron expression in core_config_data
243
  */
@@ -259,15 +273,15 @@ class TIG_PostNL_Model_Resource_Setup extends Mage_Core_Model_Resource_Setup
259
  $e
260
  );
261
  }
262
-
263
  return $this;
264
  }
265
 
266
  /**
267
  * Checks the store's config to see if the extension is compatible with the installed Magento version. If not, a message will
268
  * be added to Mage_Adminnotification.
269
- *
270
- * @return TIG_PostNL_Model_Resource_Setup
271
  */
272
  public function _checkVersionCompatibility()
273
  {
@@ -277,39 +291,39 @@ class TIG_PostNL_Model_Resource_Setup extends Mage_Core_Model_Resource_Setup
277
  } else {
278
  $edition = 'community';
279
  }
280
-
281
  $inbox = Mage::getModel('postnl/inbox');
282
-
283
  $supportedVersions = Mage::getConfig()->getNode('tig/compatibility/postnl/' . $edition);
284
  if ($supportedVersions === false) {
285
- $message = '[POSTNL-0086] '
286
  . $helper->__(
287
  'The PostNL extension is not compatible with your Magento version! This may cause unexpected behaviour.'
288
  );
289
-
290
  $inbox->addCritical(
291
  $message,
292
  $message,
293
- 'http://kb.totalinternetgroup.nl/topic/31925577',
294
  true
295
  )
296
  ->save();
297
-
298
  return $this;
299
  }
300
-
301
  $supportedVersions = (string) $supportedVersions;
302
  $supportedVersionArray = explode(',', $supportedVersions);
303
-
304
  $installedMagentoVersionInfo = Mage::getVersionInfo();
305
  $installedMagentoVersion = $installedMagentoVersionInfo['major'] . '.' . $installedMagentoVersionInfo['minor'];
306
-
307
  if (!in_array($installedMagentoVersion, $supportedVersionArray)) {
308
- $message = '[POSTNL-0086] '
309
  . $helper->__(
310
  'The PostNL extension is not compatible with your Magento version! This may cause unexpected behaviour.'
311
  );
312
-
313
  $inbox->addCritical(
314
  $message,
315
  $message,
@@ -317,27 +331,27 @@ class TIG_PostNL_Model_Resource_Setup extends Mage_Core_Model_Resource_Setup
317
  true
318
  )
319
  ->save();
320
-
321
  return $this;
322
  }
323
-
324
  return $this;
325
  }
326
 
327
  /**
328
  * Makes sure the PostNL support tab is expanded the first time an adin visits the PostNL system/config/edit page.
329
- *
330
- * @return TIG_PostNL_Model_Resource_Setup
331
  */
332
  public function expandSupportTab()
333
  {
334
  $configState = array(
335
  'postnl_support' => 1,
336
  );
337
-
338
  /**
339
  * Get all admin users and save the PostNL support tab's state as being expanded for each one.
340
- *
341
  * This has the same effect as having every admin log in, go to system/config/edit/section/postnl and manually click on
342
  * the 'Version & Support' tab before saving the section.
343
  */
@@ -345,7 +359,7 @@ class TIG_PostNL_Model_Resource_Setup extends Mage_Core_Model_Resource_Setup
345
  foreach ($adminUsers as $adminUser) {
346
  $this->_saveState($adminUser, $configState);
347
  }
348
-
349
  return $this;
350
  }
351
 
@@ -355,9 +369,9 @@ class TIG_PostNL_Model_Resource_Setup extends Mage_Core_Model_Resource_Setup
355
  *
356
  * @param Mage_Admin_Model_User $adminUser
357
  * @param array $configState
358
- *
359
- * @return TIG_PostNL_Model_Resource_Setup
360
- *
361
  * @see Mage_Adminhtml_System_ConfigController::_saveState()
362
  */
363
  protected function _saveState(Mage_Admin_Model_User $adminUser, $configState = array())
@@ -365,12 +379,12 @@ class TIG_PostNL_Model_Resource_Setup extends Mage_Core_Model_Resource_Setup
365
  if (!is_array($configState)) {
366
  return $this;
367
  }
368
-
369
  $extra = $adminUser->getExtra();
370
  if (!is_array($extra)) {
371
  $extra = array();
372
  }
373
-
374
  if (!isset($extra['configState'])) {
375
  $extra['configState'] = array();
376
  }
@@ -378,7 +392,7 @@ class TIG_PostNL_Model_Resource_Setup extends Mage_Core_Model_Resource_Setup
378
  foreach ($configState as $fieldset => $state) {
379
  $extra['configState'][$fieldset] = $state;
380
  }
381
-
382
  try {
383
  $adminUser->saveExtra($extra);
384
  } catch (Exception $e) {
@@ -387,4 +401,50 @@ class TIG_PostNL_Model_Resource_Setup extends Mage_Core_Model_Resource_Setup
387
 
388
  return $this;
389
  }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
390
  }
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@totalinternetgroup.nl so we can send you a copy immediately.
43
  */
44
  const SHIPPING_STATUS_CRON_STRING_PATH = 'crontab/jobs/postnl_update_shipping_status/schedule/cron_expr';
45
  const SHIPPING_STATUS_CRON_MODEL_PATH = 'crontab/jobs/postnl_update_shipping_status/run/model';
46
+
47
  /**
48
  * Cron expression and cron model definitions for statistics update cron
49
  */
50
  const UPDATE_STATISTICS_CRON_STRING_PATH = 'crontab/jobs/postnl_update_statistics/schedule/cron_expr';
51
  const UPDATE_STATISTICS_CRON_MODEL_PATH = 'crontab/jobs/postnl_update_statistics/run/model';
52
+
53
  /**
54
  * XML path to the supporttab_expanded setting
55
  */
56
  const EXPAND_SUPPORT_PATH = 'postnl/support/expanded';
57
+
58
+ /**
59
+ * Test data.
60
+ */
61
+ const DEFAULT_TEST_PASSWORD = 'z9A4LpFd53Z';
62
+ const DEFAULT_WEBSHOP_ID = '853f9d2a4c5242f097daeaf61637609c';
63
+
64
+ /**
65
+ * Xpaths for test data.
66
+ */
67
+ const XPATH_TEST_PASSWORD = 'postnl/cif/test_password';
68
+ const XPATH_WEBSHOP_ID = 'postnl/cif/webshop_id';
69
+
70
  /**
71
  * callAfterApplyAllUpdates flag. Causes applyAFterUpdates() to be called.
72
+ *
73
  * @var boolean
74
  */
75
  protected $_callAfterApplyAllUpdates = true;
76
+
77
  /**
78
  * Module version as stored in the db at the time of the update
79
+ *
80
  * @var string
81
  */
82
  protected $_dbVer;
83
+
84
  /**
85
  * Module version as specified in the module's configuration at the time of the update
86
+ *
87
  * @var string
88
  */
89
  protected $_configVer;
90
+
91
  /**
92
  * Set the stored DB version to the specified value
93
+ *
94
  * @param string $dbVer
95
+ *
96
+ * @return $this
97
  */
98
  public function setDbVer($dbVer)
99
  {
100
  $this->_dbVer = $dbVer;
101
+
102
  return $this;
103
  }
104
+
105
  /**
106
  * Set the stored config version to the specified value
107
+ *
108
  * @param string $configVer
109
+ *
110
+ * @return $this
111
  */
112
  public function setConfigVer($configVer)
113
  {
114
  $this->_configVer = $configVer;
115
+
116
  return $this;
117
  }
118
+
119
  /**
120
  * Get the stored DB version
121
+ *
122
  * @return string
123
  */
124
  public function getDbVer()
125
  {
126
  return $this->_dbVer;
127
  }
128
+
129
  /**
130
  * get the stored config version
131
+ *
132
  * @return string
133
  */
134
  public function getConfigVer()
135
  {
136
  return $this->_configVer;
137
  }
138
+
139
  /**
140
  * Store the applied update versions
141
+ *
142
  * @return parent::applyUpdates()
143
  */
144
  public function applyUpdates()
145
  {
146
  $dbVer = $this->_getResource()->getDbVersion($this->_resourceName);
147
  $configVer = (string)$this->_moduleConfig->version;
148
+
149
  $this->setDbVer($dbVer);
150
  $this->setConfigVer($configVer);
151
+
152
  return parent::applyUpdates();
153
  }
154
 
155
  /**
156
  * Check if the PostNL module has been updated. If so, add an admin notification to the inbox.
157
  *
158
+ * @return $this
 
 
159
  */
160
  public function afterApplyAllUpdates()
161
  {
162
  $dbVer = $this->getDbVer();
163
  $configVer = $this->getConfigVer();
164
+
165
  $this->_checkVersionCompatibility();
166
+
167
  if (version_compare($configVer, $dbVer) != self::VERSION_COMPARE_GREATER) {
168
  return $this;
169
  }
170
+
171
  $helper = Mage::helper('postnl');
172
+
173
  $inbox = Mage::getModel('postnl/inbox');
174
  $inbox->addNotice(
175
  '[POSTNL-0083] ' . $helper->__('PostNL extension has been successfully updated to version %s.', $configVer),
176
  '[POSTNL-0083] ' . $helper->__('PostNL extension has been successfully updated to version %s.', $configVer),
177
+ 'http://kb.totalinternetgroup.nl/topic/31921907',
178
  true
179
  )
180
  ->save();
181
+
182
  return $this;
183
  }
184
+
185
  /**
186
  * Generate a random cron expression for the status update cron for this merchant and store it in the database
187
+ *
188
+ * @throws TIG_PostNL_Exception
189
+ *
190
+ * @return $this
191
  */
192
  public function generateShippingStatusCronExpr()
193
  {
196
  */
197
  $cronMorningHour = mt_rand(10, 12);
198
  $cronMorningHour += Mage::getModel('core/date')->getGmtOffset('hours');
199
+
200
  $cronAfternoonHour = $cronMorningHour + 4; //4 hours after the morning update
201
  $cronMinute = mt_rand(0, 59);
202
+
203
  /**
204
  * Generate a cron expr that runs on a specified minute on a specified hour between 10 and 12 AM, and between 14 and 16 PM.
205
  */
206
  $cronExpr = "{$cronMinute} {$cronMorningHour},{$cronAfternoonHour} * * *";
207
+
208
  /**
209
  * Store the cron expression in core_config_data
210
  */
226
  $e
227
  );
228
  }
229
+
230
  return $this;
231
  }
232
+
233
  /**
234
  * Generates a semi-random cron expression for the update statistics cron. This is done to spread out the number of calls
235
  * across each day.
236
+ *
237
+ * @throws TIG_PostNL_Exception
238
+ *
239
+ * @return $this
240
  */
241
  public function generateUpdateStatisticsCronExpr()
242
  {
246
  $cronMorningHour = mt_rand(0, 11);
247
  $cronAfternoonHour = $cronMorningHour + 12; //half a day after the morning update
248
  $cronMinute = mt_rand(0, 59);
249
+
250
  /**
251
  * Generate a cron expr that runs on a specified minute on a specified hour twice per day.
252
  */
253
  $cronExpr = "{$cronMinute} {$cronMorningHour},{$cronAfternoonHour} * * *";
254
+
255
  /**
256
  * Store the cron expression in core_config_data
257
  */
273
  $e
274
  );
275
  }
276
+
277
  return $this;
278
  }
279
 
280
  /**
281
  * Checks the store's config to see if the extension is compatible with the installed Magento version. If not, a message will
282
  * be added to Mage_Adminnotification.
283
+ *
284
+ * @return $this
285
  */
286
  public function _checkVersionCompatibility()
287
  {
291
  } else {
292
  $edition = 'community';
293
  }
294
+
295
  $inbox = Mage::getModel('postnl/inbox');
296
+
297
  $supportedVersions = Mage::getConfig()->getNode('tig/compatibility/postnl/' . $edition);
298
  if ($supportedVersions === false) {
299
+ $message = '[POSTNL-0086] '
300
  . $helper->__(
301
  'The PostNL extension is not compatible with your Magento version! This may cause unexpected behaviour.'
302
  );
303
+
304
  $inbox->addCritical(
305
  $message,
306
  $message,
307
+ 'http://kb.totalinternetgroup.nl/topic/31925577',
308
  true
309
  )
310
  ->save();
311
+
312
  return $this;
313
  }
314
+
315
  $supportedVersions = (string) $supportedVersions;
316
  $supportedVersionArray = explode(',', $supportedVersions);
317
+
318
  $installedMagentoVersionInfo = Mage::getVersionInfo();
319
  $installedMagentoVersion = $installedMagentoVersionInfo['major'] . '.' . $installedMagentoVersionInfo['minor'];
320
+
321
  if (!in_array($installedMagentoVersion, $supportedVersionArray)) {
322
+ $message = '[POSTNL-0086] '
323
  . $helper->__(
324
  'The PostNL extension is not compatible with your Magento version! This may cause unexpected behaviour.'
325
  );
326
+
327
  $inbox->addCritical(
328
  $message,
329
  $message,
331
  true
332
  )
333
  ->save();
334
+
335
  return $this;
336
  }
337
+
338
  return $this;
339
  }
340
 
341
  /**
342
  * Makes sure the PostNL support tab is expanded the first time an adin visits the PostNL system/config/edit page.
343
+ *
344
+ * @return $this
345
  */
346
  public function expandSupportTab()
347
  {
348
  $configState = array(
349
  'postnl_support' => 1,
350
  );
351
+
352
  /**
353
  * Get all admin users and save the PostNL support tab's state as being expanded for each one.
354
+ *
355
  * This has the same effect as having every admin log in, go to system/config/edit/section/postnl and manually click on
356
  * the 'Version & Support' tab before saving the section.
357
  */
359
  foreach ($adminUsers as $adminUser) {
360
  $this->_saveState($adminUser, $configState);
361
  }
362
+
363
  return $this;
364
  }
365
 
369
  *
370
  * @param Mage_Admin_Model_User $adminUser
371
  * @param array $configState
372
+ *
373
+ * @return $this
374
+ *
375
  * @see Mage_Adminhtml_System_ConfigController::_saveState()
376
  */
377
  protected function _saveState(Mage_Admin_Model_User $adminUser, $configState = array())
379
  if (!is_array($configState)) {
380
  return $this;
381
  }
382
+
383
  $extra = $adminUser->getExtra();
384
  if (!is_array($extra)) {
385
  $extra = array();
386
  }
387
+
388
  if (!isset($extra['configState'])) {
389
  $extra['configState'] = array();
390
  }
392
  foreach ($configState as $fieldset => $state) {
393
  $extra['configState'][$fieldset] = $state;
394
  }
395
+
396
  try {
397
  $adminUser->saveExtra($extra);
398
  } catch (Exception $e) {
401
 
402
  return $this;
403
  }
404
+
405
+ /**
406
+ * Saves the default test password in the database as an encrypted string.
407
+ *
408
+ * @return $this
409
+ */
410
+ public function installTestPassword()
411
+ {
412
+ $testPassword = self::DEFAULT_TEST_PASSWORD;
413
+ $encryptedPassword = Mage::helper('core')->encrypt($testPassword);
414
+
415
+ /**
416
+ * @var Mage_Core_Model_Config $config
417
+ */
418
+ $config = Mage::getModel('core/config_data')
419
+ ->load(self::XPATH_TEST_PASSWORD, 'path');
420
+
421
+ $config->setValue($encryptedPassword)
422
+ ->setPath(self::XPATH_TEST_PASSWORD)
423
+ ->save();
424
+
425
+ return $this;
426
+ }
427
+
428
+ /**
429
+ * Saves the default test webshop ID as an encrypted string.
430
+ *
431
+ * @return $this
432
+ */
433
+ public function installWebshopId()
434
+ {
435
+ $testWebshopId = self::DEFAULT_WEBSHOP_ID;
436
+ $encryptedWebshopId = Mage::helper('core')->encrypt($testWebshopId);
437
+
438
+ /**
439
+ * @var Mage_Core_Model_Config $config
440
+ */
441
+ $config = Mage::getModel('core/config_data')
442
+ ->load(self::XPATH_WEBSHOP_ID, 'path');
443
+
444
+ $config->setValue($encryptedWebshopId)
445
+ ->setPath(self::XPATH_WEBSHOP_ID)
446
+ ->save();
447
+
448
+ return $this;
449
+ }
450
  }
app/code/community/TIG/PostNL/controllers/Adminhtml/ConfigController.php CHANGED
@@ -1,28 +1,28 @@
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@totalinternetgroup.nl so we can send you a copy immediately.
@@ -42,16 +42,22 @@ class TIG_PostNL_Adminhtml_ConfigController extends Mage_Adminhtml_Controller_Ac
42
  * Base XML path of config settings taht will be checked
43
  */
44
  const XML_BASE_PATH = 'postnl/cif';
45
-
46
  /**
47
  * XML path to password
48
- */
49
  const XML_PATH_LIVE_PASSWORD = 'postnl/cif/live_password';
50
-
 
 
 
 
 
 
51
  /**
52
  * Validate the extension's account settings.
53
- *
54
- * @return TIG_PostNL_Adminhtml_ConfigController
55
  */
56
  public function validateAccountAction()
57
  {
@@ -63,20 +69,23 @@ class TIG_PostNL_Adminhtml_ConfigController extends Mage_Adminhtml_Controller_Ac
63
  /**
64
  * Validate that all required fields are entered
65
  */
66
- if (empty($data['customerNumber'])
67
- || empty($data['customerCode'])
68
- || empty($data['username'])
69
- || empty($data['password'])
70
- || empty($data['locationCode'])
 
71
  ) {
72
  $this->getResponse()
73
  ->setBody('missing_data');
74
-
75
  return $this;
76
  }
77
-
78
  $data = $this->_getInheritedValues($data);
79
-
 
 
80
  /**
81
  * If the password field has not been edited since the last time it was saved, it will contain 6 asteriscs for security
82
  * reasons. In that case, we need to read and decrypt the password from the database.
@@ -86,18 +95,20 @@ class TIG_PostNL_Adminhtml_ConfigController extends Mage_Adminhtml_Controller_Ac
86
  } elseif ($data['password'] == 'inherit') {
87
  $data['password'] = $this->_getPassword(true);
88
  }
89
-
90
  /**
91
  * Hash the password
92
  */
93
  $data['password'] = sha1($data['password']);
94
-
95
  /**
96
  * Load the CIF model and set to test mode to false
 
 
97
  */
98
  $cif = Mage::getModel('postnl_core/cif')
99
- ->setTestMode(false);
100
-
101
  /**
102
  * Attempt to generate a barcode to test the account settings. This will result in an exception if the settings are
103
  * invalid.
@@ -107,89 +118,101 @@ class TIG_PostNL_Adminhtml_ConfigController extends Mage_Adminhtml_Controller_Ac
107
  } catch (Exception $e) {
108
  $this->getResponse()
109
  ->setBody('error');
110
-
111
  return $this;
112
  }
113
-
114
  /**
115
  * A positive result would be a string, namely a barcode.
116
  */
117
  if (!is_string($response)) {
118
  $this->getResponse()
119
  ->setBody('invalid_response');
120
-
121
  return $this;
122
  }
123
-
124
  $this->getResponse()
125
  ->setBody('ok');
126
-
127
  return $this;
128
  }
129
-
130
  /**
131
  * Checks each field to see if it has used the 'use default checkbox'. If so, get the default value from the database.
132
- *
133
  * @param array $data
134
- *
135
  * @return array
136
  */
137
  protected function _getInheritedValues($data)
138
  {
139
  $storeId = Mage_Core_Model_App::ADMIN_STORE_ID;
140
-
 
 
 
 
 
 
 
141
  foreach ($data as $key => &$value) {
142
  if ($value != 'inherit') {
143
  continue;
144
  }
145
-
146
  switch ($key) {
147
  case 'customerNumber':
148
- $value = Mage::getStoreConfig(self::XML_BASE_PATH . '/customer_number', $storeId);
149
  break;
150
  case 'customerCode':
151
- $value = Mage::getStoreConfig(self::XML_BASE_PATH . '/customer_code', $storeId);
152
  break;
153
  case 'username':
154
- $value = Mage::getStoreConfig(self::XML_BASE_PATH . '/live_username', $storeId);
155
  break;
156
  case 'locationCode':
157
- $value = Mage::getStoreConfig(self::XML_BASE_PATH . '/collection_location', $storeId);
158
  break;
159
  //No default
160
  //Note that the password field is not checked. That field has it's own check later on.
161
  }
162
  }
163
-
164
  return $data;
165
  }
166
-
167
  /**
168
  * Gets the password from system/config.
169
  * Passwords will be decrypted using Magento's encryption key and then hashed using sha1
170
- *
171
  * @param boolean $inherit
172
- *
173
  * @return string
174
  */
175
  protected function _getPassword($inherit = false)
176
  {
177
  $storeId = Mage_Core_Model_App::ADMIN_STORE_ID;
178
-
 
 
 
 
 
179
  try {
180
  $websiteCode = $this->getRequest()->getParam('website');
181
  if (!$inherit && !empty($websiteCode)) {
182
  $website = Mage::getModel('core/website')->load($websiteCode, 'code');
183
- $password = $website->getConfig(self::XML_PATH_LIVE_PASSWORD);
184
  } else {
185
- $password = Mage::getStoreConfig(self::XML_PATH_LIVE_PASSWORD, $storeId);
186
  }
187
-
188
  $password = Mage::helper('core')->decrypt($password);
189
  } catch (Exception $e) {
190
  return '';
191
  }
192
-
193
  return trim($password);
194
  }
195
  }
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@totalinternetgroup.nl so we can send you a copy immediately.
42
  * Base XML path of config settings taht will be checked
43
  */
44
  const XML_BASE_PATH = 'postnl/cif';
45
+
46
  /**
47
  * XML path to password
48
+ */
49
  const XML_PATH_LIVE_PASSWORD = 'postnl/cif/live_password';
50
+ const XML_PATH_TEST_PASSWORD = 'postnl/cif/test_password';
51
+
52
+ /**
53
+ * @var boolean
54
+ */
55
+ protected $_isTestMode;
56
+
57
  /**
58
  * Validate the extension's account settings.
59
+ *
60
+ * @return $this
61
  */
62
  public function validateAccountAction()
63
  {
69
  /**
70
  * Validate that all required fields are entered
71
  */
72
+ if (!isset($data['customerNumber'])
73
+ || !isset($data['customerCode'])
74
+ || !isset($data['username'])
75
+ || !isset($data['password'])
76
+ || !isset($data['locationCode'])
77
+ || !isset($data['isTestMode'])
78
  ) {
79
  $this->getResponse()
80
  ->setBody('missing_data');
81
+
82
  return $this;
83
  }
84
+
85
  $data = $this->_getInheritedValues($data);
86
+
87
+ $this->_isTestMode = (bool) $data['isTestMode'];
88
+
89
  /**
90
  * If the password field has not been edited since the last time it was saved, it will contain 6 asteriscs for security
91
  * reasons. In that case, we need to read and decrypt the password from the database.
95
  } elseif ($data['password'] == 'inherit') {
96
  $data['password'] = $this->_getPassword(true);
97
  }
98
+
99
  /**
100
  * Hash the password
101
  */
102
  $data['password'] = sha1($data['password']);
103
+
104
  /**
105
  * Load the CIF model and set to test mode to false
106
+ *
107
+ * @var TIG_PostNL_Model_Core_Cif $cif
108
  */
109
  $cif = Mage::getModel('postnl_core/cif')
110
+ ->setTestMode($this->_isTestMode);
111
+
112
  /**
113
  * Attempt to generate a barcode to test the account settings. This will result in an exception if the settings are
114
  * invalid.
118
  } catch (Exception $e) {
119
  $this->getResponse()
120
  ->setBody('error');
121
+
122
  return $this;
123
  }
124
+
125
  /**
126
  * A positive result would be a string, namely a barcode.
127
  */
128
  if (!is_string($response)) {
129
  $this->getResponse()
130
  ->setBody('invalid_response');
131
+
132
  return $this;
133
  }
134
+
135
  $this->getResponse()
136
  ->setBody('ok');
137
+
138
  return $this;
139
  }
140
+
141
  /**
142
  * Checks each field to see if it has used the 'use default checkbox'. If so, get the default value from the database.
143
+ *
144
  * @param array $data
145
+ *
146
  * @return array
147
  */
148
  protected function _getInheritedValues($data)
149
  {
150
  $storeId = Mage_Core_Model_App::ADMIN_STORE_ID;
151
+
152
+ $baseXpath = self::XML_BASE_PATH;
153
+
154
+ $usernameXpath = $baseXpath . '/live_username';
155
+ if ($this->_isTestMode) {
156
+ $usernameXpath = $baseXpath . '/test_username';
157
+ }
158
+
159
  foreach ($data as $key => &$value) {
160
  if ($value != 'inherit') {
161
  continue;
162
  }
163
+
164
  switch ($key) {
165
  case 'customerNumber':
166
+ $value = Mage::getStoreConfig($baseXpath . '/customer_number', $storeId);
167
  break;
168
  case 'customerCode':
169
+ $value = Mage::getStoreConfig($baseXpath . '/customer_code', $storeId);
170
  break;
171
  case 'username':
172
+ $value = Mage::getStoreConfig($usernameXpath, $storeId);
173
  break;
174
  case 'locationCode':
175
+ $value = Mage::getStoreConfig($baseXpath . '/collection_location', $storeId);
176
  break;
177
  //No default
178
  //Note that the password field is not checked. That field has it's own check later on.
179
  }
180
  }
181
+
182
  return $data;
183
  }
184
+
185
  /**
186
  * Gets the password from system/config.
187
  * Passwords will be decrypted using Magento's encryption key and then hashed using sha1
188
+ *
189
  * @param boolean $inherit
190
+ *
191
  * @return string
192
  */
193
  protected function _getPassword($inherit = false)
194
  {
195
  $storeId = Mage_Core_Model_App::ADMIN_STORE_ID;
196
+
197
+ $xpath = self::XML_PATH_LIVE_PASSWORD;
198
+ if ($this->_isTestMode) {
199
+ $xpath = self::XML_PATH_TEST_PASSWORD;
200
+ }
201
+
202
  try {
203
  $websiteCode = $this->getRequest()->getParam('website');
204
  if (!$inherit && !empty($websiteCode)) {
205
  $website = Mage::getModel('core/website')->load($websiteCode, 'code');
206
+ $password = $website->getConfig($xpath);
207
  } else {
208
+ $password = Mage::getStoreConfig($xpath, $storeId);
209
  }
210
+
211
  $password = Mage::helper('core')->decrypt($password);
212
  } catch (Exception $e) {
213
  return '';
214
  }
215
+
216
  return trim($password);
217
  }
218
  }
app/code/community/TIG/PostNL/controllers/Adminhtml/ShipmentController.php CHANGED
@@ -1,28 +1,28 @@
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@totalinternetgroup.nl so we can send you a copy immediately.
@@ -40,14 +40,14 @@ class TIG_PostNL_Adminhtml_ShipmentController extends Mage_Adminhtml_Controller_
40
  {
41
  /**
42
  * Print a shipping label for a single shipment
43
- *
44
  * @return TIG_PostNL_Adminhtml_ShipmentController
45
  */
46
  public function printLabelAction()
47
  {
48
  $shipmentId = $this->getRequest()->getParam('shipment_id');
49
  $helper = Mage::helper('postnl');
50
-
51
  /**
52
  * If no shipment was selected, cause an error
53
  */
@@ -58,7 +58,7 @@ class TIG_PostNL_Adminhtml_ShipmentController extends Mage_Adminhtml_Controller_
58
  $this->_redirect('adminhtml/sales_shipment/index');
59
  return $this;
60
  }
61
-
62
  try {
63
  /**
64
  * Load the shipment and check if it exists and is valid
@@ -68,51 +68,56 @@ class TIG_PostNL_Adminhtml_ShipmentController extends Mage_Adminhtml_Controller_
68
  if (!in_array($shipment->getOrder()->getShippingMethod(), $postnlShippingMethods)) {
69
  throw new TIG_PostNL_Exception($this->__('This action cannot be used on non-PostNL shipments.'), 'POSTNL-0009');
70
  }
71
-
72
  /**
73
  * get the labels from CIF
74
  */
75
  $labels = $this->_printLabels($shipment);
76
-
77
  /**
78
  * We need to check for warnings before the label download response
79
  */
80
  $this->_checkForWarnings();
81
-
82
  /**
83
  * merge the labels and print them
84
  */
85
  $labelModel = Mage::getModel('postnl_core/label');
86
  $labelModel->createPdf($labels);
 
 
 
 
 
87
  } catch (TIG_PostNL_Exception $e) {
88
  $helper->logException($e);
89
  $helper->addExceptionSessionMessage('adminhtml/session', $e);
90
-
91
  $this->_redirect('adminhtml/sales_shipment/index');
92
  return $this;
93
  } catch (Exception $e) {
94
  $helper->logException($e);
95
- $helper->addSessionMessage('adminhtml/session', 'POSTNL-0010', 'error',
96
  $this->__('An error occurred while processing this action.')
97
  );
98
-
99
  $this->_redirect('adminhtml/sales_shipment/index');
100
  return $this;
101
  }
102
-
103
  return $this;
104
  }
105
 
106
  /**
107
  * Confirm a PosTNL shipment without printing a label
108
- *
109
  * @return TIG_PostNL_Adminhtml_ShipmentController
110
  */
111
  public function confirmAction()
112
  {
113
  $shipmentId = $this->getRequest()->getParam('shipment_id');
114
  $helper = Mage::helper('postnl');
115
-
116
  /**
117
  * If no shipment was selected, cause an error
118
  */
@@ -123,7 +128,7 @@ class TIG_PostNL_Adminhtml_ShipmentController extends Mage_Adminhtml_Controller_
123
  $this->_redirect('adminhtml/sales_shipment/index');
124
  return $this;
125
  }
126
-
127
  try {
128
  /**
129
  * Load the shipment and check if it exists and is valid
@@ -133,7 +138,7 @@ class TIG_PostNL_Adminhtml_ShipmentController extends Mage_Adminhtml_Controller_
133
  if (!in_array($shipment->getOrder()->getShippingMethod(), $postnlShippingMethods)) {
134
  throw new TIG_PostNL_Exception($this->__('This action cannot be used on non-PostNL shipments.'), 'POSTNL-0009');
135
  }
136
-
137
  /**
138
  * Confirm the shipment
139
  */
@@ -141,32 +146,32 @@ class TIG_PostNL_Adminhtml_ShipmentController extends Mage_Adminhtml_Controller_
141
  } catch (TIG_PostNL_Exception $e) {
142
  $helper->logException($e);
143
  $helper->addExceptionSessionMessage('adminhtml/session', $e);
144
-
145
  $this->_redirect('adminhtml/sales_shipment/index');
146
  return $this;
147
  } catch (Exception $e) {
148
  $helper->logException($e);
149
- $helper->addSessionMessage('adminhtml/session', 'POSTNL-0010', 'error',
150
  $this->__('An error occurred while processing this action.')
151
  );
152
-
153
  $this->_redirect('adminhtml/sales_shipment/index');
154
  return $this;
155
  }
156
-
157
  $this->_checkForWarnings();
158
-
159
  $helper->addSessionMessage('adminhtml/session', null, 'success',
160
  $this->__('The shipment has been successfully confirmed')
161
  );
162
-
163
  $this->_redirect('adminhtml/sales_shipment/index');
164
  return $this;
165
  }
166
-
167
  /**
168
  * Loads the status history tab on the shipment view page
169
- *
170
  * @return TIG_PostNL_Adminhtml_ShipmentController
171
  */
172
  public function statusHistoryAction()
@@ -174,14 +179,14 @@ class TIG_PostNL_Adminhtml_ShipmentController extends Mage_Adminhtml_Controller_
174
  $shipmentId = $this->getRequest()->getParam('shipment_id');
175
  $postnlShipment = $this->_getPostnlShipment($shipmentId);
176
  Mage::register('current_postnl_shipment', $postnlShipment);
177
-
178
  /**
179
  * Get the postnl shipments' status history updated at timestamp and a reference timestamp of 15 minutes ago
180
  */
181
  $currentTimestamp = Mage::getModel('core/date')->gmtTimestamp();
182
  $fifteenMinutesAgo = strtotime("-15 minutes", $currentTimestamp);
183
  $statusHistoryUpdatedAt = $postnlShipment->getStatusHistoryUpdatedAt();
184
-
185
  /**
186
  * If this shipment's status history has not been updated in the last 15 minutes (if ever) update it
187
  */
@@ -200,18 +205,21 @@ class TIG_PostNL_Adminhtml_ShipmentController extends Mage_Adminhtml_Controller_
200
  Mage::helper('postnl')->logException($e);
201
  }
202
  }
203
-
204
  $this->loadLayout();
205
  $this->renderLayout();
206
-
207
  return $this;
208
  }
209
-
 
 
 
210
  public function sendTrackAndTraceAction()
211
  {
212
  $shipmentId = $this->getRequest()->getParam('shipment_id');
213
  $helper = Mage::helper('postnl');
214
-
215
  /**
216
  * If no shipment was selected, cause an error
217
  */
@@ -222,7 +230,7 @@ class TIG_PostNL_Adminhtml_ShipmentController extends Mage_Adminhtml_Controller_
222
  $this->_redirect('adminhtml/sales_shipment/view', array('shipment_id' => $shipmentId));
223
  return $this;
224
  }
225
-
226
  try {
227
  /**
228
  * Load the shipment and check if it exists and is valid
@@ -232,70 +240,192 @@ class TIG_PostNL_Adminhtml_ShipmentController extends Mage_Adminhtml_Controller_
232
  if (!in_array($shipment->getOrder()->getShippingMethod(), $postnlShippingMethods)) {
233
  throw new TIG_PostNL_Exception($this->__('This action cannot be used on non-PostNL shipments.'), 'POSTNL-0009');
234
  }
235
-
236
  $postnlShipment = $this->_getPostnlShipment($shipmentId);
237
  $postnlShipment->sendTrackAndTraceEmail(true);
238
  } catch (TIG_PostNL_Exception $e) {
239
  $helper->logException($e);
240
  $helper->addExceptionSessionMessage('adminhtml/session', $e);
241
-
242
  $this->_redirect('adminhtml/sales_shipment/view', array('shipment_id' => $shipmentId));
243
  return $this;
244
  } catch (Exception $e) {
245
  $helper->logException($e);
246
- $helper->addSessionMessage('adminhtml/session', 'POSTNL-0010', 'error',
247
  $this->__('An error occurred while processing this action.')
248
  );
249
-
250
  $this->_redirect('adminhtml/sales_shipment/view', array('shipment_id' => $shipmentId));
251
  return $this;
252
  }
253
-
254
  $helper->addSessionMessage('adminhtml/session', null, 'success',
255
  $this->__('The track & trace email was sent.')
256
  );
257
-
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
258
  $this->_redirect('adminhtml/sales_shipment/view', array('shipment_id' => $shipmentId));
259
  return $this;
260
  }
261
-
262
  /**
263
  * Gets the postnl shipment associated with a shipment
264
- *
265
  * @param int $shipmentId
266
- *
267
  * @return TIG_PostNL_Model_Core_Shipment
268
  */
269
  protected function _getPostnlShipment($shipmentId)
270
  {
271
  $postnlShipment = Mage::getModel('postnl_core/shipment')->load($shipmentId, 'shipment_id');
272
-
273
  return $postnlShipment;
274
  }
275
-
276
  /**
277
  * Refreshes the status history grid after a filter or sorting request
278
- *
279
  * @return TIG_PostNL_Adminhtml_ShipmentController
280
  */
281
  public function statusHistoryGridAction()
282
  {
283
  $this->loadLayout(false);
284
  $this->renderLayout();
285
-
286
  return $this;
287
  }
288
-
289
  /**
290
  * Creates shipments for a supplied array of orders. This action is triggered by a massaction in the sales > order grid
291
- *
292
  * @return TIG_PostNL_Adminhtml_ShipmentController
293
  */
294
  public function massCreateShipmentsAction()
295
  {
296
  $orderIds = $this->getRequest()->getParam('order_ids');
297
  $helper = Mage::helper('postnl');
298
-
299
  /**
300
  * Check if an order was selected
301
  */
@@ -306,9 +436,9 @@ class TIG_PostNL_Adminhtml_ShipmentController extends Mage_Adminhtml_Controller_
306
  $this->_redirect('adminhtml/sales_order/index');
307
  return $this;
308
  }
309
-
310
  $extraOptions = array();
311
-
312
  /**
313
  * Check if any options were selected. If not, the default will be used
314
  */
@@ -316,7 +446,7 @@ class TIG_PostNL_Adminhtml_ShipmentController extends Mage_Adminhtml_Controller_
316
  if ($chosenOptions && $chosenOptions != 'default') {
317
  Mage::register('postnl_product_option', $chosenOptions);
318
  }
319
-
320
  /**
321
  * Check if an extra cover amount was entered
322
  */
@@ -324,7 +454,7 @@ class TIG_PostNL_Adminhtml_ShipmentController extends Mage_Adminhtml_Controller_
324
  if ($extraCoverValue) {
325
  $extraOptions['extra_cover_amount'] = $extraCoverValue;
326
  }
327
-
328
  /**
329
  * Check if a shipment type was specified
330
  */
@@ -332,7 +462,7 @@ class TIG_PostNL_Adminhtml_ShipmentController extends Mage_Adminhtml_Controller_
332
  if ($shipmentType) {
333
  $extraOptions['shipment_type'] = $shipmentType;
334
  }
335
-
336
  /**
337
  * Check if a shipment should be treated as abandoned when it can't be delivered
338
  */
@@ -340,13 +470,13 @@ class TIG_PostNL_Adminhtml_ShipmentController extends Mage_Adminhtml_Controller_
340
  if ($treatAsAbandoned) {
341
  $extraOptions['treat_as_abandoned'] = $treatAsAbandoned;
342
  }
343
-
344
  /**
345
  * Register the extra options
346
  */
347
  if (!empty($extraOptions)) {
348
  Mage::register('postnl_additional_options', $extraOptions);
349
-
350
  }
351
  try {
352
  /**
@@ -358,41 +488,41 @@ class TIG_PostNL_Adminhtml_ShipmentController extends Mage_Adminhtml_Controller_
358
  } catch (TIG_PostNL_Exception $e) {
359
  $helper->logException($e);
360
  $helper->addExceptionSessionMessage('adminhtml/session', $e);
361
-
362
  $this->_redirect('adminhtml/sales_order/index');
363
  return $this;
364
  } catch (Exception $e) {
365
  $helper->logException($e);
366
- $helper->addSessionMessage('adminhtml/session', 'POSTNL-0010', 'error',
367
  $this->__('An error occurred while processing this action.')
368
  );
369
-
370
  $this->_redirect('adminhtml/sales_order/index');
371
  return $this;
372
  }
373
-
374
  $helper->addSessionMessage('adminhtml/session', null, 'success',
375
  $this->__('The shipments were successfully created.')
376
  );
377
-
378
  $this->_checkForWarnings();
379
-
380
  $this->_redirect('adminhtml/sales_shipment/index');
381
  return $this;
382
  }
383
-
384
  /**
385
  * Prints shipping labels and confirms selected shipments.
386
- *
387
  * Please note that if you use a different label than the default 'GraphicFile|PDF' you must overload the 'postnl_core/label' model
388
- *
389
  * @return TIG_PostNL_Adminhtml_ShipmentController
390
  */
391
  public function massPrintLabelsAndConfirmAction()
392
  {
393
  $shipmentIds = $this->getRequest()->getParam('shipment_ids');
394
  $helper = Mage::helper('postnl');
395
-
396
  /**
397
  * Check if a shipment was selected
398
  */
@@ -403,7 +533,7 @@ class TIG_PostNL_Adminhtml_ShipmentController extends Mage_Adminhtml_Controller_
403
  $this->_redirect('adminhtml/sales_shipment/index');
404
  return $this;
405
  }
406
-
407
  /**
408
  * Validate the numer of labels to be printed. Every shipment has at least 1 label. So if we have more than 200 shipments
409
  * we can stop the process right here.
@@ -414,14 +544,14 @@ class TIG_PostNL_Adminhtml_ShipmentController extends Mage_Adminhtml_Controller_
414
  );
415
  $this->_redirect('adminhtml/sales_shipment/index');
416
  }
417
-
418
  $labels = array();
419
  try {
420
  /**
421
  * Load the shipments and check if they are valid
422
  */
423
  $shipments = $this->_loadAndCheckShipments($shipmentIds, true);
424
-
425
  /**
426
  * Get the labels from CIF
427
  */
@@ -429,48 +559,53 @@ class TIG_PostNL_Adminhtml_ShipmentController extends Mage_Adminhtml_Controller_
429
  $shipmentLabels = $this->_printLabels($shipment, true);
430
  $labels = array_merge($labels, $shipmentLabels);
431
  }
432
-
433
  /**
434
  * We need to check for warnings before the label download response
435
  */
436
  $this->_checkForWarnings();
437
-
438
  /**
439
  * The label wills be base64 encoded strings. Convert these to a single pdf
440
  */
441
  $label = Mage::getModel('postnl_core/label');
442
  $label->createPdf($labels);
 
 
 
 
 
443
  } catch (TIG_PostNL_Exception $e) {
444
  $helper->logException($e);
445
  $helper->addExceptionSessionMessage('adminhtml/session', $e);
446
-
447
  $this->_redirect('adminhtml/sales_shipment/index');
448
  return $this;
449
  } catch (Exception $e) {
450
  $helper->logException($e);
451
- $helper->addSessionMessage('adminhtml/session', 'POSTNL-0010', 'error',
452
  $this->__('An error occurred while processing this action.')
453
  );
454
-
455
  $this->_redirect('adminhtml/sales_shipment/index');
456
  return $this;
457
  }
458
-
459
  return $this;
460
  }
461
-
462
  /**
463
  * Prints shipping labels for selected shipments.
464
- *
465
  * Please note that if you use a different label than the default 'GraphicFile|PDF' you must overload the 'postnl_core/label' model
466
- *
467
  * @return TIG_PostNL_Adminhtml_ShipmentController
468
  */
469
  public function massPrintLabelsAction()
470
  {
471
  $shipmentIds = $this->getRequest()->getParam('shipment_ids');
472
  $helper = Mage::helper('postnl');
473
-
474
  /**
475
  * Check if a shipment was selected
476
  */
@@ -481,69 +616,74 @@ class TIG_PostNL_Adminhtml_ShipmentController extends Mage_Adminhtml_Controller_
481
  $this->_redirect('adminhtml/sales_shipment/index');
482
  return $this;
483
  }
484
-
485
  if(count($shipmentIds) > 200 && !Mage::helper('postnl/cif')->allowInfinitePrinting()) {
486
  $helper->addSessionMessage('adminhtml/session', 'POSTNL-0014', 'error',
487
  $this->__('You can print a maximum of 200 labels at once.')
488
  );
489
  $this->_redirect('adminhtml/sales_shipment/index');
490
  }
491
-
492
  $labels = array();
493
  try {
494
  /**
495
  * Load the shipments and check if they are valid
496
  */
497
  $shipments = $this->_loadAndCheckShipments($shipmentIds, true);
498
-
499
  /**
500
  * Get the labels from CIF
501
  */
502
  foreach ($shipments as $shipment) {
503
  $labels = array_merge($labels, $this->_printLabels($shipment, false));
504
  }
505
-
506
  /**
507
  * We need to check for warnings before the label download response
508
  */
509
  $this->_checkForWarnings();
510
-
511
  /**
512
  * The label wills be base64 encoded strings. Convert these to a single pdf
513
  */
514
  $label = Mage::getModel('postnl_core/label');
515
  $label->createPdf($labels);
 
 
 
 
 
516
  } catch (TIG_PostNL_Exception $e) {
517
  $helper->logException($e);
518
  $helper->addExceptionSessionMessage('adminhtml/session', $e);
519
-
520
  $this->_redirect('adminhtml/sales_shipment/index');
521
  return $this;
522
  } catch (Exception $e) {
523
  $helper->logException($e);
524
- $helper->addSessionMessage('adminhtml/session', 'POSTNL-0010', 'error',
525
  $this->__('An error occurred while processing this action.')
526
  );
527
-
528
  $this->_redirect('adminhtml/sales_shipment/index');
529
  return $this;
530
  }
531
-
532
  return $this;
533
  }
534
-
535
  /**
536
  * Prints shipping labels and confirms selected shipments.
537
- *
538
  * Please note that if you use a different label than the default 'GraphicFile|PDF' you must overload the 'postnl_core/label' model
539
- *
540
  * @return TIG_PostNL_Adminhtml_ShipmentController
541
  */
542
  public function massConfirmAction()
543
  {
544
  $shipmentIds = $this->getRequest()->getParam('shipment_ids');
545
  $helper = Mage::helper('postnl');
546
-
547
  /**
548
  * Check if a shipment was selected
549
  */
@@ -554,13 +694,13 @@ class TIG_PostNL_Adminhtml_ShipmentController extends Mage_Adminhtml_Controller_
554
  $this->_redirect('adminhtml/sales_shipment/index');
555
  return $this;
556
  }
557
-
558
  try {
559
  /**
560
  * Load the shipments and check if they are valid
561
  */
562
  $shipments = $this->_loadAndCheckShipments($shipmentIds, true);
563
-
564
  /**
565
  * Confirm the shipments
566
  */
@@ -570,85 +710,85 @@ class TIG_PostNL_Adminhtml_ShipmentController extends Mage_Adminhtml_Controller_
570
  } catch (TIG_PostNL_Exception $e) {
571
  $helper->logException($e);
572
  $helper->addExceptionSessionMessage('adminhtml/session', $e);
573
-
574
  $this->_redirect('adminhtml/sales_shipment/index');
575
  return $this;
576
  } catch (Exception $e) {
577
  $helper->logException($e);
578
- $helper->addSessionMessage('adminhtml/session', 'POSTNL-0010', 'error',
579
  $this->__('An error occurred while processing this action.')
580
  );
581
-
582
  $this->_redirect('adminhtml/sales_shipment/index');
583
  return $this;
584
  }
585
-
586
  $this->_checkForWarnings();
587
-
588
  $helper->addSessionMessage('adminhtml/session', null, 'success',
589
  $this->__('The shipments have been confirmed successfully.')
590
  );
591
-
592
  $this->_redirect('adminhtml/sales_shipment/index');
593
  return $this;
594
  }
595
-
596
  /**
597
  * Creates a shipment of an order containing all available items
598
- *
599
  * @param int $orderId
600
- *
601
  * @return TIG_PostNL_Adminhtml_ShipmentController
602
  */
603
  protected function _createShipment($orderId)
604
  {
605
  $order = Mage::getModel('sales/order')->load($orderId);
606
-
607
  if (!$order->canShip()) {
608
  throw new TIG_PostNL_Exception(
609
  $this->__("Order #%s cannot be shipped at this time.", $order->getIncrementId()),
610
- 'POSTNL-0015'
611
  );
612
  }
613
-
614
  $shipment = Mage::getModel('sales/service_order', $order)
615
  ->prepareShipment($this->_getItemQtys($order));
616
-
617
  $shipment->register();
618
  $this->_saveShipment($shipment);
619
-
620
  return $this;
621
  }
622
-
623
  /**
624
  * Initialize shipment items QTY
625
- *
626
  * @param Mage_Sales_Model_Order $order
627
- *
628
  * @return array
629
  */
630
  protected function _getItemQtys($order)
631
  {
632
  $itemQtys = array();
633
-
634
  $items = $order->getAllVisibleItems();
635
  foreach ($items as $item) {
636
  /**
637
- * the qty to ship is the total remaining (not yet shipped) qty of every item
638
  */
639
  $itemQty = $item->getQtyOrdered() - $item->getQtyShipped();
640
-
641
  $itemQtys[$item->getId()] = $itemQty;
642
  }
643
-
644
  return $itemQtys;
645
  }
646
-
647
  /**
648
  * Save shipment and order in one transaction
649
  *
650
  * @param Mage_Sales_Model_Order_Shipment $shipment
651
- *
652
  * @return Mage_Adminhtml_Sales_Order_ShipmentController
653
  */
654
  protected function _saveShipment($shipment)
@@ -661,17 +801,17 @@ class TIG_PostNL_Adminhtml_ShipmentController extends Mage_Adminhtml_Controller_
661
 
662
  return $this;
663
  }
664
-
665
  /**
666
  * Retrieves the shipping label for a given shipment ID.
667
- *
668
  * If the shipment has a stored label, it is returned. Otherwise a new one is generated.
669
- *
670
  * @param Mage_Sales_Model_Order_Shipment|TIG_PostNL_Model_Core_Shipment $shipment
671
  * @param boolean $confirm Optional parameter to also confirm the shipment
672
- *
673
  * @return string The encoded label
674
- *
675
  * @throws TIG_PostNL_Exception
676
  */
677
  protected function _printLabels($shipment, $confirm = false)
@@ -684,7 +824,7 @@ class TIG_PostNL_Adminhtml_ShipmentController extends Mage_Adminhtml_Controller_
684
  } else {
685
  $postnlShipment = $shipment;
686
  }
687
-
688
  /**
689
  * Check if the shipment already has any labels. If so, return those. If we also need to confirm the shipment, do that
690
  * first.
@@ -696,27 +836,26 @@ class TIG_PostNL_Adminhtml_ShipmentController extends Mage_Adminhtml_Controller_
696
  $this->_confirmShipment($postnlShipment);
697
  return $postnlShipment->getlabels();
698
  }
699
-
700
  if ($postnlShipment->hasLabels()) {
701
  return $postnlShipment->getlabels();
702
  }
703
-
704
  /**
705
  * If the PostNL shipment is new, set the magento shipment ID
706
  */
707
  if (!$postnlShipment->getShipmentId()) {
708
  $postnlShipment->setShipmentId($shipment->getId());
709
  }
710
-
711
  /**
712
  * If the shipment does not have a barcode, generate one
713
  */
714
  if (!$postnlShipment->getMainBarcode()) {
715
- $postnlShipment->generateBarcodes()
716
- ->addTrackingCodeToShipment();
717
  }
718
-
719
- if ($confirm === true
720
  && !$postnlShipment->hasLabels()
721
  && !$postnlShipment->isConfirmed()
722
  ) {
@@ -733,18 +872,18 @@ class TIG_PostNL_Adminhtml_ShipmentController extends Mage_Adminhtml_Controller_
733
  $postnlShipment->generateLabel()
734
  ->save();
735
  }
736
-
737
  $labels = $postnlShipment->getLabels();
738
  return $labels;
739
  }
740
-
741
  /**
742
  * Confirms the shipment without printing labels
743
- *
744
  * @param Mage_Sales_Model_Order_Shipment|TIG_PostNL_Model_Core_Shipment $shipment
745
- *
746
  * @return TIG_PostNL_Adminhtml_ShipmentController
747
- *
748
  * @throws TIG_PostNL_Exception
749
  */
750
  protected function _confirmShipment($shipment)
@@ -757,38 +896,38 @@ class TIG_PostNL_Adminhtml_ShipmentController extends Mage_Adminhtml_Controller_
757
  } else {
758
  $postnlShipment = $shipment;
759
  }
760
-
761
  /**
762
  * Prevent EU shipments from being confirmed if their labels are not yet printed
763
  */
764
  if ($postnlShipment->isEuShipment() && !$postnlShipment->getLabelsPrinted()) {
765
  throw new TIG_PostNL_Exception(
766
- $this->__("For EU shipments you may only confirm a shipment after it's labels have been printed."),
767
  'POSTNL-0016'
768
  );
769
  }
770
-
771
  /**
772
  * If the PostNL shipment is new, set the magento shipment ID
773
  */
774
  if (!$postnlShipment->getShipmentId()) {
775
  $postnlShipment->setShipmentId($shipment->getId());
776
  }
777
-
778
  /**
779
  * If the shipment does not have a main barcode, generate new barcodes
780
  */
781
  if (!$postnlShipment->getMainBarcode()) {
782
  $postnlShipment->generateBarcodes();
783
  }
784
-
785
  if ($postnlShipment->getConfirmStatus() === $postnlShipment::CONFIRM_STATUS_CONFIRMED) {
786
  /**
787
  * The shipment is already confirmed
788
  */
789
  throw new TIG_PostNL_Exception($this->__('This shipment has already been confirmed.'), 'POSTNL-00017');
790
  }
791
-
792
  if (!$postnlShipment->canConfirm()) {
793
  /**
794
  * The shipment cannot be confirmed at this time
@@ -802,18 +941,18 @@ class TIG_PostNL_Adminhtml_ShipmentController extends Mage_Adminhtml_Controller_
802
  $postnlShipment->confirm()
803
  ->addTrackingCodeToShipment()
804
  ->save();
805
-
806
  $labels = $postnlShipment->getLabels();
807
  return $labels;
808
  }
809
-
810
  /**
811
  * Load an array of shipments based on an array of shipmentIds and check if they're shipped using PostNL
812
- *
813
  * @param array $shipmentIds
814
- *
815
  * @return array
816
- *
817
  * @throws TIG_PostNL_Exception
818
  */
819
  protected function _loadAndCheckShipments($shipmentIds, $loadPostnlShipments = false)
@@ -821,7 +960,7 @@ class TIG_PostNL_Adminhtml_ShipmentController extends Mage_Adminhtml_Controller_
821
  if (!is_array($shipmentIds)) {
822
  $shipmentIds = array($shipmentIds);
823
  }
824
-
825
  $shipments = array();
826
  $postnlShippingMethods = Mage::helper('postnl/carrier')->getPostnlShippingMethods();
827
  foreach ($shipmentIds as $shipmentId) {
@@ -835,24 +974,24 @@ class TIG_PostNL_Adminhtml_ShipmentController extends Mage_Adminhtml_Controller_
835
  $shipment = Mage::getModel('postnl_core/shipment')->load($shipmentId, 'shipment_id');
836
  $shippingMethod = $shipment->getShipment()->getOrder()->getShippingMethod();
837
  }
838
-
839
  /**
840
  * Check if the shipping method used is allowed
841
  */
842
  if (!in_array($shippingMethod, $postnlShippingMethods)) {
843
  throw new TIG_PostNL_Exception($this->__('This action cannot be used on non-PostNL shipments.'), 'POSTNL-0009');
844
  }
845
-
846
  $shipments[] = $shipment;
847
  }
848
-
849
  return $shipments;
850
  }
851
-
852
  /**
853
  * Checks if any warnings were received while processing the action in CIF. If any warnings are found they are
854
  * added to the adminhtml session as a notice.
855
- *
856
  * @return TIG_PostNL_Adminhtml_ShipmentController
857
  */
858
  protected function _checkForWarnings()
@@ -861,17 +1000,17 @@ class TIG_PostNL_Adminhtml_ShipmentController extends Mage_Adminhtml_Controller_
861
  * Check if any warnings were registered
862
  */
863
  $warnings = Mage::registry('postnl_cif_warnings');
864
-
865
  if (!is_array($warnings)) {
866
  return $this;
867
  }
868
-
869
  /**
870
  * Create a warning message to display to the merchant
871
  */
872
  $warningMessage = $this->__('PostNL replied with the following warnings:');
873
  $warningMessage .= '<ul>';
874
-
875
  /**
876
  * Add each warning to the message
877
  */
@@ -884,36 +1023,36 @@ class TIG_PostNL_Adminhtml_ShipmentController extends Mage_Adminhtml_Controller_
884
  if ($error !== false) {
885
  $link = (string) $error->url;
886
  }
887
-
888
  /**
889
  * Build the message proper
890
  */
891
- $warningMessage .= '<li>'
892
  . '[' . $warning['code'] . '] '
893
  . $this->__($warning['description']);
894
  /**
895
  * Add the link if it's available
896
  */
897
  if ($link) {
898
- $warningMessage .= ' <a href="'
899
- . $link
900
- . '" target="_blank" class="postnl-message">'
901
- . $this->__('Click here for more information from the TiG knowledgebase.')
902
  . '</a>';
903
  }
904
-
905
  $warningMessage .= '</li>';
906
  }
907
-
908
  $warningMessage .= '</ul>';
909
-
910
  /**
911
  * Add the warnings to the session
912
  */
913
  Mage::helper('postnl')->addSessionMessage('adminhtml/session', null, 'notice',
914
  $warningMessage
915
  );
916
-
917
  return $this;
918
  }
919
  }
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@totalinternetgroup.nl so we can send you a copy immediately.
40
  {
41
  /**
42
  * Print a shipping label for a single shipment
43
+ *
44
  * @return TIG_PostNL_Adminhtml_ShipmentController
45
  */
46
  public function printLabelAction()
47
  {
48
  $shipmentId = $this->getRequest()->getParam('shipment_id');
49
  $helper = Mage::helper('postnl');
50
+
51
  /**
52
  * If no shipment was selected, cause an error
53
  */
58
  $this->_redirect('adminhtml/sales_shipment/index');
59
  return $this;
60
  }
61
+
62
  try {
63
  /**
64
  * Load the shipment and check if it exists and is valid
68
  if (!in_array($shipment->getOrder()->getShippingMethod(), $postnlShippingMethods)) {
69
  throw new TIG_PostNL_Exception($this->__('This action cannot be used on non-PostNL shipments.'), 'POSTNL-0009');
70
  }
71
+
72
  /**
73
  * get the labels from CIF
74
  */
75
  $labels = $this->_printLabels($shipment);
76
+
77
  /**
78
  * We need to check for warnings before the label download response
79
  */
80
  $this->_checkForWarnings();
81
+
82
  /**
83
  * merge the labels and print them
84
  */
85
  $labelModel = Mage::getModel('postnl_core/label');
86
  $labelModel->createPdf($labels);
87
+
88
+ /**
89
+ * Prevent Magento from sending additional headers.
90
+ */
91
+ $this->getResponse()->setHttpResponseCode(200)->clearRawHeaders()->clearHeaders();
92
  } catch (TIG_PostNL_Exception $e) {
93
  $helper->logException($e);
94
  $helper->addExceptionSessionMessage('adminhtml/session', $e);
95
+
96
  $this->_redirect('adminhtml/sales_shipment/index');
97
  return $this;
98
  } catch (Exception $e) {
99
  $helper->logException($e);
100
+ $helper->addSessionMessage('adminhtml/session', 'POSTNL-0010', 'error',
101
  $this->__('An error occurred while processing this action.')
102
  );
103
+
104
  $this->_redirect('adminhtml/sales_shipment/index');
105
  return $this;
106
  }
107
+
108
  return $this;
109
  }
110
 
111
  /**
112
  * Confirm a PosTNL shipment without printing a label
113
+ *
114
  * @return TIG_PostNL_Adminhtml_ShipmentController
115
  */
116
  public function confirmAction()
117
  {
118
  $shipmentId = $this->getRequest()->getParam('shipment_id');
119
  $helper = Mage::helper('postnl');
120
+
121
  /**
122
  * If no shipment was selected, cause an error
123
  */
128
  $this->_redirect('adminhtml/sales_shipment/index');
129
  return $this;
130
  }
131
+
132
  try {
133
  /**
134
  * Load the shipment and check if it exists and is valid
138
  if (!in_array($shipment->getOrder()->getShippingMethod(), $postnlShippingMethods)) {
139
  throw new TIG_PostNL_Exception($this->__('This action cannot be used on non-PostNL shipments.'), 'POSTNL-0009');
140
  }
141
+
142
  /**
143
  * Confirm the shipment
144
  */
146
  } catch (TIG_PostNL_Exception $e) {
147
  $helper->logException($e);
148
  $helper->addExceptionSessionMessage('adminhtml/session', $e);
149
+
150
  $this->_redirect('adminhtml/sales_shipment/index');
151
  return $this;
152
  } catch (Exception $e) {
153
  $helper->logException($e);
154
+ $helper->addSessionMessage('adminhtml/session', 'POSTNL-0010', 'error',
155
  $this->__('An error occurred while processing this action.')
156
  );
157
+
158
  $this->_redirect('adminhtml/sales_shipment/index');
159
  return $this;
160
  }
161
+
162
  $this->_checkForWarnings();
163
+
164
  $helper->addSessionMessage('adminhtml/session', null, 'success',
165
  $this->__('The shipment has been successfully confirmed')
166
  );
167
+
168
  $this->_redirect('adminhtml/sales_shipment/index');
169
  return $this;
170
  }
171
+
172
  /**
173
  * Loads the status history tab on the shipment view page
174
+ *
175
  * @return TIG_PostNL_Adminhtml_ShipmentController
176
  */
177
  public function statusHistoryAction()
179
  $shipmentId = $this->getRequest()->getParam('shipment_id');
180
  $postnlShipment = $this->_getPostnlShipment($shipmentId);
181
  Mage::register('current_postnl_shipment', $postnlShipment);
182
+
183
  /**
184
  * Get the postnl shipments' status history updated at timestamp and a reference timestamp of 15 minutes ago
185
  */
186
  $currentTimestamp = Mage::getModel('core/date')->gmtTimestamp();
187
  $fifteenMinutesAgo = strtotime("-15 minutes", $currentTimestamp);
188
  $statusHistoryUpdatedAt = $postnlShipment->getStatusHistoryUpdatedAt();
189
+
190
  /**
191
  * If this shipment's status history has not been updated in the last 15 minutes (if ever) update it
192
  */
205
  Mage::helper('postnl')->logException($e);
206
  }
207
  }
208
+
209
  $this->loadLayout();
210
  $this->renderLayout();
211
+
212
  return $this;
213
  }
214
+
215
+ /**
216
+ * @return $this
217
+ */
218
  public function sendTrackAndTraceAction()
219
  {
220
  $shipmentId = $this->getRequest()->getParam('shipment_id');
221
  $helper = Mage::helper('postnl');
222
+
223
  /**
224
  * If no shipment was selected, cause an error
225
  */
230
  $this->_redirect('adminhtml/sales_shipment/view', array('shipment_id' => $shipmentId));
231
  return $this;
232
  }
233
+
234
  try {
235
  /**
236
  * Load the shipment and check if it exists and is valid
240
  if (!in_array($shipment->getOrder()->getShippingMethod(), $postnlShippingMethods)) {
241
  throw new TIG_PostNL_Exception($this->__('This action cannot be used on non-PostNL shipments.'), 'POSTNL-0009');
242
  }
243
+
244
  $postnlShipment = $this->_getPostnlShipment($shipmentId);
245
  $postnlShipment->sendTrackAndTraceEmail(true);
246
  } catch (TIG_PostNL_Exception $e) {
247
  $helper->logException($e);
248
  $helper->addExceptionSessionMessage('adminhtml/session', $e);
249
+
250
  $this->_redirect('adminhtml/sales_shipment/view', array('shipment_id' => $shipmentId));
251
  return $this;
252
  } catch (Exception $e) {
253
  $helper->logException($e);
254
+ $helper->addSessionMessage('adminhtml/session', 'POSTNL-0010', 'error',
255
  $this->__('An error occurred while processing this action.')
256
  );
257
+
258
  $this->_redirect('adminhtml/sales_shipment/view', array('shipment_id' => $shipmentId));
259
  return $this;
260
  }
261
+
262
  $helper->addSessionMessage('adminhtml/session', null, 'success',
263
  $this->__('The track & trace email was sent.')
264
  );
265
+
266
+ $this->_redirect('adminhtml/sales_shipment/view', array('shipment_id' => $shipmentId));
267
+ return $this;
268
+ }
269
+
270
+ /**
271
+ * Resets a single shipment's confirmation status.
272
+ *
273
+ * @return $this
274
+ */
275
+ public function resetConfirmationAction()
276
+ {
277
+ $shipmentId = $this->getRequest()->getParam('shipment_id');
278
+ $helper = Mage::helper('postnl');
279
+
280
+ /**
281
+ * If no shipment was selected, cause an error
282
+ */
283
+ if (is_null($shipmentId)) {
284
+ $helper->addSessionMessage('adminhtml/session', null, 'error',
285
+ $this->__('Shipment not found.')
286
+ );
287
+ $this->_redirect('adminhtml/sales_shipment/view', array('shipment_id' => $shipmentId));
288
+ return $this;
289
+ }
290
+
291
+ try {
292
+ /**
293
+ * Load the shipment and check if it exists and is valid
294
+ */
295
+ $shipment = Mage::getModel('sales/order_shipment')->load($shipmentId);
296
+ $postnlShippingMethods = Mage::helper('postnl/carrier')->getPostnlShippingMethods();
297
+ if (!in_array($shipment->getOrder()->getShippingMethod(), $postnlShippingMethods)) {
298
+ throw new TIG_PostNL_Exception(
299
+ $this->__('This action cannot be used on non-PostNL shipments.'),
300
+ 'POSTNL-0009'
301
+ );
302
+ }
303
+
304
+ $postnlShipment = $this->_getPostnlShipment($shipmentId);
305
+ $postnlShipment->resetConfirmation(true, true)->save();
306
+ } catch (TIG_PostNL_Exception $e) {
307
+ $helper->logException($e);
308
+ $helper->addExceptionSessionMessage('adminhtml/session', $e);
309
+
310
+ $this->_redirect('adminhtml/sales_shipment/view', array('shipment_id' => $shipmentId));
311
+ return $this;
312
+ } catch (Exception $e) {
313
+ $helper->logException($e);
314
+ $helper->addSessionMessage('adminhtml/session', 'POSTNL-0010', 'error',
315
+ $this->__('An error occurred while processing this action.')
316
+ );
317
+
318
+ $this->_redirect('adminhtml/sales_shipment/view', array('shipment_id' => $shipmentId));
319
+ return $this;
320
+ }
321
+
322
+ $helper->addSessionMessage('adminhtml/session', null, 'success',
323
+ $this->__("The shipment's confirmation has been undone.")
324
+ );
325
+
326
+ $this->_redirect('adminhtml/sales_shipment/view', array('shipment_id' => $shipmentId));
327
+ return $this;
328
+ }
329
+
330
+ /**
331
+ * Remove a shipment's shipping labels.
332
+ *
333
+ * @return $this
334
+ */
335
+ public function removeLabelsAction()
336
+ {
337
+ $shipmentId = $this->getRequest()->getParam('shipment_id');
338
+ $helper = Mage::helper('postnl');
339
+
340
+ /**
341
+ * If no shipment was selected, cause an error
342
+ */
343
+ if (is_null($shipmentId)) {
344
+ $helper->addSessionMessage('adminhtml/session', null, 'error',
345
+ $this->__('Shipment not found.')
346
+ );
347
+ $this->_redirect('adminhtml/sales_shipment/view', array('shipment_id' => $shipmentId));
348
+ return $this;
349
+ }
350
+
351
+ try {
352
+ /**
353
+ * Load the shipment and check if it exists and is valid
354
+ */
355
+ $shipment = Mage::getModel('sales/order_shipment')->load($shipmentId);
356
+ $postnlShippingMethods = Mage::helper('postnl/carrier')->getPostnlShippingMethods();
357
+ if (!in_array($shipment->getOrder()->getShippingMethod(), $postnlShippingMethods)) {
358
+ throw new TIG_PostNL_Exception(
359
+ $this->__('This action cannot be used on non-PostNL shipments.'),
360
+ 'POSTNL-0009'
361
+ );
362
+ }
363
+
364
+ $postnlShipment = $this->_getPostnlShipment($shipmentId);
365
+ $postnlShipment->deleteLabels()
366
+ ->setLabelsPrinted(false)
367
+ ->save();
368
+ } catch (TIG_PostNL_Exception $e) {
369
+ $helper->logException($e);
370
+ $helper->addExceptionSessionMessage('adminhtml/session', $e);
371
+
372
+ $this->_redirect('adminhtml/sales_shipment/view', array('shipment_id' => $shipmentId));
373
+ return $this;
374
+ } catch (Exception $e) {
375
+ $helper->logException($e);
376
+ $helper->addSessionMessage('adminhtml/session', 'POSTNL-0010', 'error',
377
+ $this->__('An error occurred while processing this action.')
378
+ );
379
+
380
+ $this->_redirect('adminhtml/sales_shipment/view', array('shipment_id' => $shipmentId));
381
+ return $this;
382
+ }
383
+
384
+ $helper->addSessionMessage('adminhtml/session', null, 'success',
385
+ $this->__("The shipment's shipping labels have been deleted.")
386
+ );
387
+
388
  $this->_redirect('adminhtml/sales_shipment/view', array('shipment_id' => $shipmentId));
389
  return $this;
390
  }
391
+
392
  /**
393
  * Gets the postnl shipment associated with a shipment
394
+ *
395
  * @param int $shipmentId
396
+ *
397
  * @return TIG_PostNL_Model_Core_Shipment
398
  */
399
  protected function _getPostnlShipment($shipmentId)
400
  {
401
  $postnlShipment = Mage::getModel('postnl_core/shipment')->load($shipmentId, 'shipment_id');
402
+
403
  return $postnlShipment;
404
  }
405
+
406
  /**
407
  * Refreshes the status history grid after a filter or sorting request
408
+ *
409
  * @return TIG_PostNL_Adminhtml_ShipmentController
410
  */
411
  public function statusHistoryGridAction()
412
  {
413
  $this->loadLayout(false);
414
  $this->renderLayout();
415
+
416
  return $this;
417
  }
418
+
419
  /**
420
  * Creates shipments for a supplied array of orders. This action is triggered by a massaction in the sales > order grid
421
+ *
422
  * @return TIG_PostNL_Adminhtml_ShipmentController
423
  */
424
  public function massCreateShipmentsAction()
425
  {
426
  $orderIds = $this->getRequest()->getParam('order_ids');
427
  $helper = Mage::helper('postnl');
428
+
429
  /**
430
  * Check if an order was selected
431
  */
436
  $this->_redirect('adminhtml/sales_order/index');
437
  return $this;
438
  }
439
+
440
  $extraOptions = array();
441
+
442
  /**
443
  * Check if any options were selected. If not, the default will be used
444
  */
446
  if ($chosenOptions && $chosenOptions != 'default') {
447
  Mage::register('postnl_product_option', $chosenOptions);
448
  }
449
+
450
  /**
451
  * Check if an extra cover amount was entered
452
  */
454
  if ($extraCoverValue) {
455
  $extraOptions['extra_cover_amount'] = $extraCoverValue;
456
  }
457
+
458
  /**
459
  * Check if a shipment type was specified
460
  */
462
  if ($shipmentType) {
463
  $extraOptions['shipment_type'] = $shipmentType;
464
  }
465
+
466
  /**
467
  * Check if a shipment should be treated as abandoned when it can't be delivered
468
  */
470
  if ($treatAsAbandoned) {
471
  $extraOptions['treat_as_abandoned'] = $treatAsAbandoned;
472
  }
473
+
474
  /**
475
  * Register the extra options
476
  */
477
  if (!empty($extraOptions)) {
478
  Mage::register('postnl_additional_options', $extraOptions);
479
+
480
  }
481
  try {
482
  /**
488
  } catch (TIG_PostNL_Exception $e) {
489
  $helper->logException($e);
490
  $helper->addExceptionSessionMessage('adminhtml/session', $e);
491
+
492
  $this->_redirect('adminhtml/sales_order/index');
493
  return $this;
494
  } catch (Exception $e) {
495
  $helper->logException($e);
496
+ $helper->addSessionMessage('adminhtml/session', 'POSTNL-0010', 'error',
497
  $this->__('An error occurred while processing this action.')
498
  );
499
+
500
  $this->_redirect('adminhtml/sales_order/index');
501
  return $this;
502
  }
503
+
504
  $helper->addSessionMessage('adminhtml/session', null, 'success',
505
  $this->__('The shipments were successfully created.')
506
  );
507
+
508
  $this->_checkForWarnings();
509
+
510
  $this->_redirect('adminhtml/sales_shipment/index');
511
  return $this;
512
  }
513
+
514
  /**
515
  * Prints shipping labels and confirms selected shipments.
516
+ *
517
  * Please note that if you use a different label than the default 'GraphicFile|PDF' you must overload the 'postnl_core/label' model
518
+ *
519
  * @return TIG_PostNL_Adminhtml_ShipmentController
520
  */
521
  public function massPrintLabelsAndConfirmAction()
522
  {
523
  $shipmentIds = $this->getRequest()->getParam('shipment_ids');
524
  $helper = Mage::helper('postnl');
525
+
526
  /**
527
  * Check if a shipment was selected
528
  */
533
  $this->_redirect('adminhtml/sales_shipment/index');
534
  return $this;
535
  }
536
+
537
  /**
538
  * Validate the numer of labels to be printed. Every shipment has at least 1 label. So if we have more than 200 shipments
539
  * we can stop the process right here.
544
  );
545
  $this->_redirect('adminhtml/sales_shipment/index');
546
  }
547
+
548
  $labels = array();
549
  try {
550
  /**
551
  * Load the shipments and check if they are valid
552
  */
553
  $shipments = $this->_loadAndCheckShipments($shipmentIds, true);
554
+
555
  /**
556
  * Get the labels from CIF
557
  */
559
  $shipmentLabels = $this->_printLabels($shipment, true);
560
  $labels = array_merge($labels, $shipmentLabels);
561
  }
562
+
563
  /**
564
  * We need to check for warnings before the label download response
565
  */
566
  $this->_checkForWarnings();
567
+
568
  /**
569
  * The label wills be base64 encoded strings. Convert these to a single pdf
570
  */
571
  $label = Mage::getModel('postnl_core/label');
572
  $label->createPdf($labels);
573
+
574
+ /**
575
+ * Prevent Magento from sending additional headers.
576
+ */
577
+ $this->getResponse()->setHttpResponseCode(200)->clearRawHeaders()->clearHeaders();
578
  } catch (TIG_PostNL_Exception $e) {
579
  $helper->logException($e);
580
  $helper->addExceptionSessionMessage('adminhtml/session', $e);
581
+
582
  $this->_redirect('adminhtml/sales_shipment/index');
583
  return $this;
584
  } catch (Exception $e) {
585
  $helper->logException($e);
586
+ $helper->addSessionMessage('adminhtml/session', 'POSTNL-0010', 'error',
587
  $this->__('An error occurred while processing this action.')
588
  );
589
+
590
  $this->_redirect('adminhtml/sales_shipment/index');
591
  return $this;
592
  }
593
+
594
  return $this;
595
  }
596
+
597
  /**
598
  * Prints shipping labels for selected shipments.
599
+ *
600
  * Please note that if you use a different label than the default 'GraphicFile|PDF' you must overload the 'postnl_core/label' model
601
+ *
602
  * @return TIG_PostNL_Adminhtml_ShipmentController
603
  */
604
  public function massPrintLabelsAction()
605
  {
606
  $shipmentIds = $this->getRequest()->getParam('shipment_ids');
607
  $helper = Mage::helper('postnl');
608
+
609
  /**
610
  * Check if a shipment was selected
611
  */
616
  $this->_redirect('adminhtml/sales_shipment/index');
617
  return $this;
618
  }
619
+
620
  if(count($shipmentIds) > 200 && !Mage::helper('postnl/cif')->allowInfinitePrinting()) {
621
  $helper->addSessionMessage('adminhtml/session', 'POSTNL-0014', 'error',
622
  $this->__('You can print a maximum of 200 labels at once.')
623
  );
624
  $this->_redirect('adminhtml/sales_shipment/index');
625
  }
626
+
627
  $labels = array();
628
  try {
629
  /**
630
  * Load the shipments and check if they are valid
631
  */
632
  $shipments = $this->_loadAndCheckShipments($shipmentIds, true);
633
+
634
  /**
635
  * Get the labels from CIF
636
  */
637
  foreach ($shipments as $shipment) {
638
  $labels = array_merge($labels, $this->_printLabels($shipment, false));
639
  }
640
+
641
  /**
642
  * We need to check for warnings before the label download response
643
  */
644
  $this->_checkForWarnings();
645
+
646
  /**
647
  * The label wills be base64 encoded strings. Convert these to a single pdf
648
  */
649
  $label = Mage::getModel('postnl_core/label');
650
  $label->createPdf($labels);
651
+
652
+ /**
653
+ * Prevent Magento from sending additional headers.
654
+ */
655
+ $this->getResponse()->setHttpResponseCode(200)->clearRawHeaders()->clearHeaders();
656
  } catch (TIG_PostNL_Exception $e) {
657
  $helper->logException($e);
658
  $helper->addExceptionSessionMessage('adminhtml/session', $e);
659
+
660
  $this->_redirect('adminhtml/sales_shipment/index');
661
  return $this;
662
  } catch (Exception $e) {
663
  $helper->logException($e);
664
+ $helper->addSessionMessage('adminhtml/session', 'POSTNL-0010', 'error',
665
  $this->__('An error occurred while processing this action.')
666
  );
667
+
668
  $this->_redirect('adminhtml/sales_shipment/index');
669
  return $this;
670
  }
671
+
672
  return $this;
673
  }
674
+
675
  /**
676
  * Prints shipping labels and confirms selected shipments.
677
+ *
678
  * Please note that if you use a different label than the default 'GraphicFile|PDF' you must overload the 'postnl_core/label' model
679
+ *
680
  * @return TIG_PostNL_Adminhtml_ShipmentController
681
  */
682
  public function massConfirmAction()
683
  {
684
  $shipmentIds = $this->getRequest()->getParam('shipment_ids');
685
  $helper = Mage::helper('postnl');
686
+
687
  /**
688
  * Check if a shipment was selected
689
  */
694
  $this->_redirect('adminhtml/sales_shipment/index');
695
  return $this;
696
  }
697
+
698
  try {
699
  /**
700
  * Load the shipments and check if they are valid
701
  */
702
  $shipments = $this->_loadAndCheckShipments($shipmentIds, true);
703
+
704
  /**
705
  * Confirm the shipments
706
  */
710
  } catch (TIG_PostNL_Exception $e) {
711
  $helper->logException($e);
712
  $helper->addExceptionSessionMessage('adminhtml/session', $e);
713
+
714
  $this->_redirect('adminhtml/sales_shipment/index');
715
  return $this;
716
  } catch (Exception $e) {
717
  $helper->logException($e);
718
+ $helper->addSessionMessage('adminhtml/session', 'POSTNL-0010', 'error',
719
  $this->__('An error occurred while processing this action.')
720
  );
721
+
722
  $this->_redirect('adminhtml/sales_shipment/index');
723
  return $this;
724
  }
725
+
726
  $this->_checkForWarnings();
727
+
728
  $helper->addSessionMessage('adminhtml/session', null, 'success',
729
  $this->__('The shipments have been confirmed successfully.')
730
  );
731
+
732
  $this->_redirect('adminhtml/sales_shipment/index');
733
  return $this;
734
  }
735
+
736
  /**
737
  * Creates a shipment of an order containing all available items
738
+ *
739
  * @param int $orderId
740
+ *
741
  * @return TIG_PostNL_Adminhtml_ShipmentController
742
  */
743
  protected function _createShipment($orderId)
744
  {
745
  $order = Mage::getModel('sales/order')->load($orderId);
746
+
747
  if (!$order->canShip()) {
748
  throw new TIG_PostNL_Exception(
749
  $this->__("Order #%s cannot be shipped at this time.", $order->getIncrementId()),
750
+ 'POSTNL-0015'
751
  );
752
  }
753
+
754
  $shipment = Mage::getModel('sales/service_order', $order)
755
  ->prepareShipment($this->_getItemQtys($order));
756
+
757
  $shipment->register();
758
  $this->_saveShipment($shipment);
759
+
760
  return $this;
761
  }
762
+
763
  /**
764
  * Initialize shipment items QTY
765
+ *
766
  * @param Mage_Sales_Model_Order $order
767
+ *
768
  * @return array
769
  */
770
  protected function _getItemQtys($order)
771
  {
772
  $itemQtys = array();
773
+
774
  $items = $order->getAllVisibleItems();
775
  foreach ($items as $item) {
776
  /**
777
+ * the qty to ship is the total remaining (not yet shipped) qty of every item
778
  */
779
  $itemQty = $item->getQtyOrdered() - $item->getQtyShipped();
780
+
781
  $itemQtys[$item->getId()] = $itemQty;
782
  }
783
+
784
  return $itemQtys;
785
  }
786
+
787
  /**
788
  * Save shipment and order in one transaction
789
  *
790
  * @param Mage_Sales_Model_Order_Shipment $shipment
791
+ *
792
  * @return Mage_Adminhtml_Sales_Order_ShipmentController
793
  */
794
  protected function _saveShipment($shipment)
801
 
802
  return $this;
803
  }
804
+
805
  /**
806
  * Retrieves the shipping label for a given shipment ID.
807
+ *
808
  * If the shipment has a stored label, it is returned. Otherwise a new one is generated.
809
+ *
810
  * @param Mage_Sales_Model_Order_Shipment|TIG_PostNL_Model_Core_Shipment $shipment
811
  * @param boolean $confirm Optional parameter to also confirm the shipment
812
+ *
813
  * @return string The encoded label
814
+ *
815
  * @throws TIG_PostNL_Exception
816
  */
817
  protected function _printLabels($shipment, $confirm = false)
824
  } else {
825
  $postnlShipment = $shipment;
826
  }
827
+
828
  /**
829
  * Check if the shipment already has any labels. If so, return those. If we also need to confirm the shipment, do that
830
  * first.
836
  $this->_confirmShipment($postnlShipment);
837
  return $postnlShipment->getlabels();
838
  }
839
+
840
  if ($postnlShipment->hasLabels()) {
841
  return $postnlShipment->getlabels();
842
  }
843
+
844
  /**
845
  * If the PostNL shipment is new, set the magento shipment ID
846
  */
847
  if (!$postnlShipment->getShipmentId()) {
848
  $postnlShipment->setShipmentId($shipment->getId());
849
  }
850
+
851
  /**
852
  * If the shipment does not have a barcode, generate one
853
  */
854
  if (!$postnlShipment->getMainBarcode()) {
855
+ $postnlShipment->generateBarcodes();
 
856
  }
857
+
858
+ if ($confirm === true
859
  && !$postnlShipment->hasLabels()
860
  && !$postnlShipment->isConfirmed()
861
  ) {
872
  $postnlShipment->generateLabel()
873
  ->save();
874
  }
875
+
876
  $labels = $postnlShipment->getLabels();
877
  return $labels;
878
  }
879
+
880
  /**
881
  * Confirms the shipment without printing labels
882
+ *
883
  * @param Mage_Sales_Model_Order_Shipment|TIG_PostNL_Model_Core_Shipment $shipment
884
+ *
885
  * @return TIG_PostNL_Adminhtml_ShipmentController
886
+ *
887
  * @throws TIG_PostNL_Exception
888
  */
889
  protected function _confirmShipment($shipment)
896
  } else {
897
  $postnlShipment = $shipment;
898
  }
899
+
900
  /**
901
  * Prevent EU shipments from being confirmed if their labels are not yet printed
902
  */
903
  if ($postnlShipment->isEuShipment() && !$postnlShipment->getLabelsPrinted()) {
904
  throw new TIG_PostNL_Exception(
905
+ $this->__("For EU shipments you may only confirm a shipment after it's labels have been printed."),
906
  'POSTNL-0016'
907
  );
908
  }
909
+
910
  /**
911
  * If the PostNL shipment is new, set the magento shipment ID
912
  */
913
  if (!$postnlShipment->getShipmentId()) {
914
  $postnlShipment->setShipmentId($shipment->getId());
915
  }
916
+
917
  /**
918
  * If the shipment does not have a main barcode, generate new barcodes
919
  */
920
  if (!$postnlShipment->getMainBarcode()) {
921
  $postnlShipment->generateBarcodes();
922
  }
923
+
924
  if ($postnlShipment->getConfirmStatus() === $postnlShipment::CONFIRM_STATUS_CONFIRMED) {
925
  /**
926
  * The shipment is already confirmed
927
  */
928
  throw new TIG_PostNL_Exception($this->__('This shipment has already been confirmed.'), 'POSTNL-00017');
929
  }
930
+
931
  if (!$postnlShipment->canConfirm()) {
932
  /**
933
  * The shipment cannot be confirmed at this time
941
  $postnlShipment->confirm()
942
  ->addTrackingCodeToShipment()
943
  ->save();
944
+
945
  $labels = $postnlShipment->getLabels();
946
  return $labels;
947
  }
948
+
949
  /**
950
  * Load an array of shipments based on an array of shipmentIds and check if they're shipped using PostNL
951
+ *
952
  * @param array $shipmentIds
953
+ *
954
  * @return array
955
+ *
956
  * @throws TIG_PostNL_Exception
957
  */
958
  protected function _loadAndCheckShipments($shipmentIds, $loadPostnlShipments = false)
960
  if (!is_array($shipmentIds)) {
961
  $shipmentIds = array($shipmentIds);
962
  }
963
+
964
  $shipments = array();
965
  $postnlShippingMethods = Mage::helper('postnl/carrier')->getPostnlShippingMethods();
966
  foreach ($shipmentIds as $shipmentId) {
974
  $shipment = Mage::getModel('postnl_core/shipment')->load($shipmentId, 'shipment_id');
975
  $shippingMethod = $shipment->getShipment()->getOrder()->getShippingMethod();
976
  }
977
+
978
  /**
979
  * Check if the shipping method used is allowed
980
  */
981
  if (!in_array($shippingMethod, $postnlShippingMethods)) {
982
  throw new TIG_PostNL_Exception($this->__('This action cannot be used on non-PostNL shipments.'), 'POSTNL-0009');
983
  }
984
+
985
  $shipments[] = $shipment;
986
  }
987
+
988
  return $shipments;
989
  }
990
+
991
  /**
992
  * Checks if any warnings were received while processing the action in CIF. If any warnings are found they are
993
  * added to the adminhtml session as a notice.
994
+ *
995
  * @return TIG_PostNL_Adminhtml_ShipmentController
996
  */
997
  protected function _checkForWarnings()
1000
  * Check if any warnings were registered
1001
  */
1002
  $warnings = Mage::registry('postnl_cif_warnings');
1003
+
1004
  if (!is_array($warnings)) {
1005
  return $this;
1006
  }
1007
+
1008
  /**
1009
  * Create a warning message to display to the merchant
1010
  */
1011
  $warningMessage = $this->__('PostNL replied with the following warnings:');
1012
  $warningMessage .= '<ul>';
1013
+
1014
  /**
1015
  * Add each warning to the message
1016
  */
1023
  if ($error !== false) {
1024
  $link = (string) $error->url;
1025
  }
1026
+
1027
  /**
1028
  * Build the message proper
1029
  */
1030
+ $warningMessage .= '<li>'
1031
  . '[' . $warning['code'] . '] '
1032
  . $this->__($warning['description']);
1033
  /**
1034
  * Add the link if it's available
1035
  */
1036
  if ($link) {
1037
+ $warningMessage .= ' <a href="'
1038
+ . $link
1039
+ . '" target="_blank" class="postnl-message">'
1040
+ . $this->__('Click here for more information from the TiG knowledgebase.')
1041
  . '</a>';
1042
  }
1043
+
1044
  $warningMessage .= '</li>';
1045
  }
1046
+
1047
  $warningMessage .= '</ul>';
1048
+
1049
  /**
1050
  * Add the warnings to the session
1051
  */
1052
  Mage::helper('postnl')->addSessionMessage('adminhtml/session', null, 'notice',
1053
  $warningMessage
1054
  );
1055
+
1056
  return $this;
1057
  }
1058
  }
app/code/community/TIG/PostNL/data/postnl_setup/data-install-1.1.4.php ADDED
@@ -0,0 +1,53 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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@totalinternetgroup.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@totalinternetgroup.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
+ /**
41
+ * @var TIG_PostNL_Model_Resource_Setup $installer
42
+ */
43
+ $installer = $this;
44
+
45
+ $installer->startSetup();
46
+
47
+ $installer->generateShippingStatusCronExpr()
48
+ ->generateUpdateStatisticsCronExpr()
49
+ ->expandSupportTab()
50
+ ->installTestPassword()
51
+ ->installWebshopId();
52
+
53
+ $installer->endSetup();
app/code/community/TIG/PostNL/etc/config.xml CHANGED
@@ -41,7 +41,7 @@
41
  <config>
42
  <modules>
43
  <TIG_PostNL>
44
- <version>1.1.3</version>
45
  </TIG_PostNL>
46
  </modules>
47
 
@@ -373,29 +373,29 @@
373
  </carriers>
374
  <postnl>
375
  <general>
376
- <active>0</active> <!-- inactive -->
377
  <is_activated>0</is_activated> <!-- Not activated -->
378
  <email/>
379
  <unique_key/>
380
  <private_key/>
381
  </general>
382
  <cif>
383
- <customer_number/>
384
- <customer_code/>
385
  <live_username/>
386
  <live_password/>
387
- <test_username/>
388
- <test_password/>
389
- <collection_location/>
390
  <use_globalpack>0</use_globalpack> <!-- Do not use GlobalPack -->
391
- <global_barcode_type/>
392
- <global_barcode_range/>
393
  <use_checkout>0</use_checkout> <!-- Do not use PostNL Checkout -->
394
- <webshop_id/>
395
- <public_webshop_id/>
396
  </cif>
397
  <cif_labels_and_confirming>
398
- <mode>0</mode> <!-- Live mode -->
399
  <label_size>A4</label_size> <!-- A4 size labels -->
400
  <weight_per_parcel>20000</weight_per_parcel> <!-- 20 kg -->
401
  <weight_unit>gram</weight_unit> <!-- gram -->
@@ -447,7 +447,8 @@
447
  <country>NL</country> <!-- All return addresses must be located in the Netherlands -->
448
  </cif_return_address>
449
  <cif_product_options>
450
- <supported_product_options>3085,3086,3091,3093,3097,3087,3094,3189,3089,3389,3096,3090,3385,3390,3534,3544,3533,3543,3535,3545,3536,3546,3534,3544,3533,3543,4952,4955,4945</supported_product_options> <!-- all possible options -->
 
451
  <default_product_option>3085</default_product_option> <!-- standard shipment -->
452
  <use_alternative_default>0</use_alternative_default> <!-- Do not use an alternative default -->
453
  <alternative_default_max_amount>100</alternative_default_max_amount> <!-- 100 EUR -->
@@ -469,7 +470,7 @@
469
  </cif_globalpack_settings>
470
  <checkout>
471
  <active>0</active> <!-- PostNL Checkout is inactive -->
472
- <mode>0</mode> <!-- Live mode -->
473
  <instruction_cms_page/>
474
  <show_checkout_for_letter>0</show_checkout_for_letter> <!-- Do not show the PostNL Checkout button for orders under 2 kg -->
475
  <show_checkout_for_backorders>0</show_checkout_for_backorders> <!-- Do not show the PostNL Checkout button if the order contains out-of-stock products -->
@@ -512,7 +513,6 @@
512
  <afterpay_method/>
513
  </checkout_payment_methods>
514
  <advanced>
515
- <allow_test_mode>0</allow_test_mode>
516
  <debug_mode>1</debug_mode> <!-- Exception logging only -->
517
  <infinite_label_printing>0</infinite_label_printing> <!-- do not allow infinite printing -->
518
  <max_parcel_count>200</max_parcel_count> <!-- Maximum of 200 parcels per shipment allowed -->
@@ -583,7 +583,7 @@
583
  </POSTNL-0006>
584
  <POSTNL-0007>
585
  <message>An error occurred whilst processing your request: </message>
586
- <url></url>
587
  <type>error</type>
588
  </POSTNL-0007>
589
  <POSTNL-0008>
@@ -608,7 +608,7 @@
608
  </POSTNL-0011>
609
  <POSTNL-0012>
610
  <message>An error occurred whilst creating processing the shipment(s): </message>
611
- <url></url>
612
  <type>error</type>
613
  </POSTNL-0012>
614
  <POSTNL-0013>
@@ -1036,8 +1036,13 @@
1036
  <url>http://kb.totalinternetgroup.nl/topic/33064418</url>
1037
  <type>error</type>
1038
  </POSTNL-0097>
 
 
 
 
 
1039
 
1040
- <!-- Note: errors 0098 and 0099 are missing. They will be added later. They have no special significance, we just forgot them :) -->
1041
 
1042
  <POSTNL-0100>
1043
  <!-- This error is generated by CIF, however we have designated it an error code -->
41
  <config>
42
  <modules>
43
  <TIG_PostNL>
44
+ <version>1.1.4</version>
45
  </TIG_PostNL>
46
  </modules>
47
 
373
  </carriers>
374
  <postnl>
375
  <general>
376
+ <active>0</active> <!-- Inactive -->
377
  <is_activated>0</is_activated> <!-- Not activated -->
378
  <email/>
379
  <unique_key/>
380
  <private_key/>
381
  </general>
382
  <cif>
383
+ <customer_number>11223344</customer_number> <!-- Demo customer number -->
384
+ <customer_code>TOTA</customer_code> <!-- Demo customer doe -->
385
  <live_username/>
386
  <live_password/>
387
+ <test_username>Dem0#Magnt01</test_username> <!-- Demo username -->
388
+ <test_password/> <!-- The demo password will be generated on install -->
389
+ <collection_location>103861</collection_location> <!-- Demo collection location -->
390
  <use_globalpack>0</use_globalpack> <!-- Do not use GlobalPack -->
391
+ <global_barcode_type>CD</global_barcode_type> <!-- Demo barcode type -->
392
+ <global_barcode_range>1660</global_barcode_range> <!-- Demo barcode range -->
393
  <use_checkout>0</use_checkout> <!-- Do not use PostNL Checkout -->
394
+ <webshop_id/> <!-- The demo webshop ID will be generated on install -->
395
+ <public_webshop_id>a98e0769d6bf40a8b49d85e7aff41d7a</public_webshop_id> <!-- Demo public webshop ID -->
396
  </cif>
397
  <cif_labels_and_confirming>
398
+ <mode>1</mode> <!-- Test mode -->
399
  <label_size>A4</label_size> <!-- A4 size labels -->
400
  <weight_per_parcel>20000</weight_per_parcel> <!-- 20 kg -->
401
  <weight_unit>gram</weight_unit> <!-- gram -->
447
  <country>NL</country> <!-- All return addresses must be located in the Netherlands -->
448
  </cif_return_address>
449
  <cif_product_options>
450
+ <supported_product_options>3085,3086,3091,3093,3097,3087,3094,3189,3089,3389,3096,3090,3385,3390,3534,3544,3533,3543,3535,3545,3536,3546,3534,3544,3533,3543,4952,4945</supported_product_options> <!-- all possible options -->
451
+ <allow_eps_be_only_options>0</allow_eps_be_only_options> <!-- Do not allow the EPS BE only product option -->
452
  <default_product_option>3085</default_product_option> <!-- standard shipment -->
453
  <use_alternative_default>0</use_alternative_default> <!-- Do not use an alternative default -->
454
  <alternative_default_max_amount>100</alternative_default_max_amount> <!-- 100 EUR -->
470
  </cif_globalpack_settings>
471
  <checkout>
472
  <active>0</active> <!-- PostNL Checkout is inactive -->
473
+ <mode>1</mode> <!-- Test mode -->
474
  <instruction_cms_page/>
475
  <show_checkout_for_letter>0</show_checkout_for_letter> <!-- Do not show the PostNL Checkout button for orders under 2 kg -->
476
  <show_checkout_for_backorders>0</show_checkout_for_backorders> <!-- Do not show the PostNL Checkout button if the order contains out-of-stock products -->
513
  <afterpay_method/>
514
  </checkout_payment_methods>
515
  <advanced>
 
516
  <debug_mode>1</debug_mode> <!-- Exception logging only -->
517
  <infinite_label_printing>0</infinite_label_printing> <!-- do not allow infinite printing -->
518
  <max_parcel_count>200</max_parcel_count> <!-- Maximum of 200 parcels per shipment allowed -->
583
  </POSTNL-0006>
584
  <POSTNL-0007>
585
  <message>An error occurred whilst processing your request: </message>
586
+ <url/>
587
  <type>error</type>
588
  </POSTNL-0007>
589
  <POSTNL-0008>
608
  </POSTNL-0011>
609
  <POSTNL-0012>
610
  <message>An error occurred whilst creating processing the shipment(s): </message>
611
+ <url/>
612
  <type>error</type>
613
  </POSTNL-0012>
614
  <POSTNL-0013>
1036
  <url>http://kb.totalinternetgroup.nl/topic/33064418</url>
1037
  <type>error</type>
1038
  </POSTNL-0097>
1039
+ <POSTNL-0098>
1040
+ <message>'The PostNL Extension is currently configured in test mode.</message>
1041
+ <url>http://kb.totalinternetgroup.nl/topic/46536473</url>
1042
+ <type>warning</type>
1043
+ </POSTNL-0098>
1044
 
1045
+ <!-- Note: errors 0099 is missing missing. It may be added later. -->
1046
 
1047
  <POSTNL-0100>
1048
  <!-- This error is generated by CIF, however we have designated it an error code -->
app/code/community/TIG/PostNL/etc/system.xml CHANGED
@@ -1,29 +1,29 @@
1
  <?xml version="1.0" encoding="UTF-8"?>
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@totalinternetgroup.nl so we can send you a copy immediately.
@@ -36,7 +36,7 @@
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
  <config>
42
  <sections>
@@ -367,7 +367,7 @@
367
  <validate>validate-alpha validate-length minimum-length-3 maximum-length-4 postnl-validate-empty</validate>
368
  </customer_code>
369
  <live_username translate="label tooltip" module="postnl">
370
- <label>Username</label>
371
  <tooltip>If you are a contract customer of PostNL, you will have received an email containing this setting. If you cannot find this email, please contact PostNL support at 058-2333343</tooltip>
372
  <frontend_type>text</frontend_type>
373
  <sort_order>30</sort_order>
@@ -377,7 +377,7 @@
377
  <validate>postnl-validate-empty</validate>
378
  </live_username>
379
  <live_password translate="label tooltip" module="postnl">
380
- <label>Password</label>
381
  <tooltip>If you are a contract customer of PostNL, you will have received an email containing this setting. If you cannot find this email, please contact PostNL support at 058-2333343</tooltip>
382
  <frontend_type>obscure</frontend_type>
383
  <backend_model>adminhtml/system_config_backend_encrypted</backend_model>
@@ -396,10 +396,6 @@
396
  <show_in_store>0</show_in_store>
397
  <validate>postnl-validate-empty</validate>
398
  <depends>
399
- <allow_test_mode>
400
- <fieldset>advanced</fieldset>
401
- <value>1</value>
402
- </allow_test_mode>
403
  </depends>
404
  </test_username>
405
  <test_password translate="label" module="postnl">
@@ -412,10 +408,6 @@
412
  <show_in_store>0</show_in_store>
413
  <validate>postnl-validate-empty</validate>
414
  <depends>
415
- <allow_test_mode>
416
- <fieldset>advanced</fieldset>
417
- <value>1</value>
418
- </allow_test_mode>
419
  </depends>
420
  </test_password>
421
  <collection_location translate="label comment tooltip" module="postnl">
@@ -550,12 +542,6 @@
550
  <show_in_website>1</show_in_website>
551
  <show_in_store>0</show_in_store>
552
  <validate>validate-select</validate>
553
- <depends>
554
- <allow_test_mode>
555
- <fieldset>advanced</fieldset>
556
- <value>1</value>
557
- </allow_test_mode>
558
- </depends>
559
  </mode>
560
  <label_size translate="label comment" module="postnl">
561
  <label>Label size</label>
@@ -1410,10 +1396,6 @@
1410
  <validate>validate-select</validate>
1411
  <depends>
1412
  <active>1</active>
1413
- <allow_test_mode>
1414
- <fieldset>advanced</fieldset>
1415
- <value>1</value>
1416
- </allow_test_mode>
1417
  <use_checkout>
1418
  <fieldset>cif</fieldset>
1419
  <value>1</value>
@@ -2513,25 +2495,13 @@
2513
  <show_in_website>0</show_in_website>
2514
  <show_in_store>0</show_in_store>
2515
  <fields>
2516
- <allow_test_mode translate="label comment tooltip" module ="postnl">
2517
- <label>Allow test mode</label>
2518
- <comment>If enabled new fields will appear allowing you to configure the extension for test mode.</comment>
2519
- <tooltip>By default the extension will always function in 'live' mode. If you are a developer you may be interested in using test (sandbox) mode instead.</tooltip>
2520
- <frontend_type>select</frontend_type>
2521
- <source_model>adminhtml/system_config_source_yesno</source_model>
2522
- <sort_order>10</sort_order>
2523
- <show_in_default>1</show_in_default>
2524
- <show_in_website>0</show_in_website>
2525
- <show_in_store>0</show_in_store>
2526
- <validate>validate-select</validate>
2527
- </allow_test_mode>
2528
  <debug_mode translate="label comment tooltip" module="postnl">
2529
  <label>Debug mode</label>
2530
  <comment>If enabled, debug logs will be created in the var/logs/TIG_PostNL/ directory.</comment>
2531
  <tooltip>Full logging will log various debugging messages as well as errors. N.B.: these log files may become very large in a short amount of time.</tooltip>
2532
  <frontend_type>select</frontend_type>
2533
  <source_model>postnl_core/system_config_source_debugMode</source_model>
2534
- <sort_order>20</sort_order>
2535
  <show_in_default>1</show_in_default>
2536
  <show_in_website>0</show_in_website>
2537
  <show_in_store>0</show_in_store>
@@ -2542,7 +2512,7 @@
2542
  <comment>By default a maximum of 200 labels can be printed at once. Enable this to remove this limitation. Beware: enabling this may lead to server instability.</comment>
2543
  <frontend_type>select</frontend_type>
2544
  <source_model>adminhtml/system_config_source_yesno</source_model>
2545
- <sort_order>30</sort_order>
2546
  <show_in_default>1</show_in_default>
2547
  <show_in_website>0</show_in_website>
2548
  <show_in_store>0</show_in_store>
@@ -2552,7 +2522,7 @@
2552
  <label>Maximum number of parcels per shipment</label>
2553
  <comment><![CDATA[Leave empty to allow an infinite amount of parcels per shipment.<br/>If this value is empty or exceeds 200, you need to set 'Allow infinite label printing' to yes in order to be able to print the shipment's labels.]]></comment>
2554
  <frontend_type>text</frontend_type>
2555
- <sort_order>40</sort_order>
2556
  <show_in_default>1</show_in_default>
2557
  <show_in_website>0</show_in_website>
2558
  <show_in_store>0</show_in_store>
@@ -2561,7 +2531,7 @@
2561
  <label>Maximum temporary file storage time</label>
2562
  <comment>In seconds. After this time, temporary files will be deleted. Only increase this if you use custom functionality to create a very large amount of labels at once.</comment>
2563
  <frontend_type>text</frontend_type>
2564
- <sort_order>50</sort_order>
2565
  <show_in_default>1</show_in_default>
2566
  <show_in_website>0</show_in_website>
2567
  <show_in_store>0</show_in_store>
@@ -2572,7 +2542,7 @@
2572
  <comment>In order to continuously improve the PostNL extension, the extension sends usage statistics to a secure PostNL server.</comment>
2573
  <frontend_type>select</frontend_type>
2574
  <source_model>adminhtml/system_config_source_yesno</source_model>
2575
- <sort_order>60</sort_order>
2576
  <show_in_default>1</show_in_default>
2577
  <show_in_website>1</show_in_website>
2578
  <show_in_store>0</show_in_store>
@@ -2583,7 +2553,7 @@
2583
  <comment>PostNL may periodically send important updates regarding new versions of the PostNL extension or important security updates in the same manner as Magento. Disable this setting to no longer ecieve these notifications.</comment>
2584
  <frontend_type>select</frontend_type>
2585
  <source_model>adminhtml/system_config_source_yesno</source_model>
2586
- <sort_order>70</sort_order>
2587
  <show_in_default>1</show_in_default>
2588
  <show_in_website>0</show_in_website>
2589
  <show_in_store>0</show_in_store>
@@ -2594,7 +2564,7 @@
2594
  <comment>If set to 'yes', error details will be shown in the frontend when an error occurs. Error details include the error code as well as a link to the TiG knowledgebase article concerning the error. This is useful for debugging purposes, but should be disabled in a production environment.</comment>
2595
  <frontend_type>select</frontend_type>
2596
  <source_model>adminhtml/system_config_source_yesno</source_model>
2597
- <sort_order>80</sort_order>
2598
  <show_in_default>1</show_in_default>
2599
  <show_in_website>1</show_in_website>
2600
  <show_in_store>1</show_in_store>
@@ -2603,7 +2573,7 @@
2603
  <cif_versions_header translate="label" module="postnl">
2604
  <label>The following fields determine the CIF version used by each service. Tampering with these settings may result in unexpected behaviour or it may disable the extension altogether.</label>
2605
  <frontend_model>adminhtml/system_config_form_field_heading</frontend_model>
2606
- <sort_order>90</sort_order>
2607
  <show_in_default>1</show_in_default>
2608
  <show_in_website>0</show_in_website>
2609
  <show_in_store>0</show_in_store>
@@ -2611,7 +2581,7 @@
2611
  <cif_versions_infobox translate="comment" module="postnl">
2612
  <comment>ONLY CHANGE THESE SETTINGS WITH DIRECT INSTRUCTION FROM POSTNL OR TOTAL INTERNET GROUP</comment>
2613
  <frontend_model>postnl_adminhtml/system_config_form_field_warningBox</frontend_model>
2614
- <sort_order>100</sort_order>
2615
  <show_in_default>1</show_in_default>
2616
  <show_in_website>1</show_in_website>
2617
  <show_in_store>0</show_in_store>
@@ -2619,7 +2589,7 @@
2619
  <cif_version_shippingstatus translate="label" module="postnl">
2620
  <label>ShippingStatus Webservice version</label>
2621
  <frontend_type>text</frontend_type>
2622
- <sort_order>110</sort_order>
2623
  <show_in_default>1</show_in_default>
2624
  <show_in_website>0</show_in_website>
2625
  <show_in_store>0</show_in_store>
@@ -2627,7 +2597,7 @@
2627
  <cif_version_confirming translate="label" module="postnl">
2628
  <label>Confirming Webservice version</label>
2629
  <frontend_type>text</frontend_type>
2630
- <sort_order>120</sort_order>
2631
  <show_in_default>1</show_in_default>
2632
  <show_in_website>0</show_in_website>
2633
  <show_in_store>0</show_in_store>
@@ -2635,7 +2605,7 @@
2635
  <cif_version_labelling translate="label" module="postnl">
2636
  <label>Labelling Webservice version</label>
2637
  <frontend_type>text</frontend_type>
2638
- <sort_order>130</sort_order>
2639
  <show_in_default>1</show_in_default>
2640
  <show_in_website>0</show_in_website>
2641
  <show_in_store>0</show_in_store>
@@ -2643,7 +2613,7 @@
2643
  <cif_version_barcode translate="label" module="postnl">
2644
  <label>Barcode Webservice version</label>
2645
  <frontend_type>text</frontend_type>
2646
- <sort_order>140</sort_order>
2647
  <show_in_default>1</show_in_default>
2648
  <show_in_website>0</show_in_website>
2649
  <show_in_store>0</show_in_store>
@@ -2651,7 +2621,7 @@
2651
  <cif_version_checkout translate="label" module="postnl">
2652
  <label>Checkout Webservice version</label>
2653
  <frontend_type>text</frontend_type>
2654
- <sort_order>150</sort_order>
2655
  <show_in_default>1</show_in_default>
2656
  <show_in_website>0</show_in_website>
2657
  <show_in_store>0</show_in_store>
1
  <?xml version="1.0" encoding="UTF-8"?>
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@totalinternetgroup.nl so we can send you a copy immediately.
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
  <config>
42
  <sections>
367
  <validate>validate-alpha validate-length minimum-length-3 maximum-length-4 postnl-validate-empty</validate>
368
  </customer_code>
369
  <live_username translate="label tooltip" module="postnl">
370
+ <label>Live Username</label>
371
  <tooltip>If you are a contract customer of PostNL, you will have received an email containing this setting. If you cannot find this email, please contact PostNL support at 058-2333343</tooltip>
372
  <frontend_type>text</frontend_type>
373
  <sort_order>30</sort_order>
377
  <validate>postnl-validate-empty</validate>
378
  </live_username>
379
  <live_password translate="label tooltip" module="postnl">
380
+ <label>Live Password</label>
381
  <tooltip>If you are a contract customer of PostNL, you will have received an email containing this setting. If you cannot find this email, please contact PostNL support at 058-2333343</tooltip>
382
  <frontend_type>obscure</frontend_type>
383
  <backend_model>adminhtml/system_config_backend_encrypted</backend_model>
396
  <show_in_store>0</show_in_store>
397
  <validate>postnl-validate-empty</validate>
398
  <depends>
 
 
 
 
399
  </depends>
400
  </test_username>
401
  <test_password translate="label" module="postnl">
408
  <show_in_store>0</show_in_store>
409
  <validate>postnl-validate-empty</validate>
410
  <depends>
 
 
 
 
411
  </depends>
412
  </test_password>
413
  <collection_location translate="label comment tooltip" module="postnl">
542
  <show_in_website>1</show_in_website>
543
  <show_in_store>0</show_in_store>
544
  <validate>validate-select</validate>
 
 
 
 
 
 
545
  </mode>
546
  <label_size translate="label comment" module="postnl">
547
  <label>Label size</label>
1396
  <validate>validate-select</validate>
1397
  <depends>
1398
  <active>1</active>
 
 
 
 
1399
  <use_checkout>
1400
  <fieldset>cif</fieldset>
1401
  <value>1</value>
2495
  <show_in_website>0</show_in_website>
2496
  <show_in_store>0</show_in_store>
2497
  <fields>
 
 
 
 
 
 
 
 
 
 
 
 
2498
  <debug_mode translate="label comment tooltip" module="postnl">
2499
  <label>Debug mode</label>
2500
  <comment>If enabled, debug logs will be created in the var/logs/TIG_PostNL/ directory.</comment>
2501
  <tooltip>Full logging will log various debugging messages as well as errors. N.B.: these log files may become very large in a short amount of time.</tooltip>
2502
  <frontend_type>select</frontend_type>
2503
  <source_model>postnl_core/system_config_source_debugMode</source_model>
2504
+ <sort_order>10</sort_order>
2505
  <show_in_default>1</show_in_default>
2506
  <show_in_website>0</show_in_website>
2507
  <show_in_store>0</show_in_store>
2512
  <comment>By default a maximum of 200 labels can be printed at once. Enable this to remove this limitation. Beware: enabling this may lead to server instability.</comment>
2513
  <frontend_type>select</frontend_type>
2514
  <source_model>adminhtml/system_config_source_yesno</source_model>
2515
+ <sort_order>20</sort_order>
2516
  <show_in_default>1</show_in_default>
2517
  <show_in_website>0</show_in_website>
2518
  <show_in_store>0</show_in_store>
2522
  <label>Maximum number of parcels per shipment</label>
2523
  <comment><![CDATA[Leave empty to allow an infinite amount of parcels per shipment.<br/>If this value is empty or exceeds 200, you need to set 'Allow infinite label printing' to yes in order to be able to print the shipment's labels.]]></comment>
2524
  <frontend_type>text</frontend_type>
2525
+ <sort_order>30</sort_order>
2526
  <show_in_default>1</show_in_default>
2527
  <show_in_website>0</show_in_website>
2528
  <show_in_store>0</show_in_store>
2531
  <label>Maximum temporary file storage time</label>
2532
  <comment>In seconds. After this time, temporary files will be deleted. Only increase this if you use custom functionality to create a very large amount of labels at once.</comment>
2533
  <frontend_type>text</frontend_type>
2534
+ <sort_order>40</sort_order>
2535
  <show_in_default>1</show_in_default>
2536
  <show_in_website>0</show_in_website>
2537
  <show_in_store>0</show_in_store>
2542
  <comment>In order to continuously improve the PostNL extension, the extension sends usage statistics to a secure PostNL server.</comment>
2543
  <frontend_type>select</frontend_type>
2544
  <source_model>adminhtml/system_config_source_yesno</source_model>
2545
+ <sort_order>50</sort_order>
2546
  <show_in_default>1</show_in_default>
2547
  <show_in_website>1</show_in_website>
2548
  <show_in_store>0</show_in_store>
2553
  <comment>PostNL may periodically send important updates regarding new versions of the PostNL extension or important security updates in the same manner as Magento. Disable this setting to no longer ecieve these notifications.</comment>
2554
  <frontend_type>select</frontend_type>
2555
  <source_model>adminhtml/system_config_source_yesno</source_model>
2556
+ <sort_order>60</sort_order>
2557
  <show_in_default>1</show_in_default>
2558
  <show_in_website>0</show_in_website>
2559
  <show_in_store>0</show_in_store>
2564
  <comment>If set to 'yes', error details will be shown in the frontend when an error occurs. Error details include the error code as well as a link to the TiG knowledgebase article concerning the error. This is useful for debugging purposes, but should be disabled in a production environment.</comment>
2565
  <frontend_type>select</frontend_type>
2566
  <source_model>adminhtml/system_config_source_yesno</source_model>
2567
+ <sort_order>70</sort_order>
2568
  <show_in_default>1</show_in_default>
2569
  <show_in_website>1</show_in_website>
2570
  <show_in_store>1</show_in_store>
2573
  <cif_versions_header translate="label" module="postnl">
2574
  <label>The following fields determine the CIF version used by each service. Tampering with these settings may result in unexpected behaviour or it may disable the extension altogether.</label>
2575
  <frontend_model>adminhtml/system_config_form_field_heading</frontend_model>
2576
+ <sort_order>80</sort_order>
2577
  <show_in_default>1</show_in_default>
2578
  <show_in_website>0</show_in_website>
2579
  <show_in_store>0</show_in_store>
2581
  <cif_versions_infobox translate="comment" module="postnl">
2582
  <comment>ONLY CHANGE THESE SETTINGS WITH DIRECT INSTRUCTION FROM POSTNL OR TOTAL INTERNET GROUP</comment>
2583
  <frontend_model>postnl_adminhtml/system_config_form_field_warningBox</frontend_model>
2584
+ <sort_order>90</sort_order>
2585
  <show_in_default>1</show_in_default>
2586
  <show_in_website>1</show_in_website>
2587
  <show_in_store>0</show_in_store>
2589
  <cif_version_shippingstatus translate="label" module="postnl">
2590
  <label>ShippingStatus Webservice version</label>
2591
  <frontend_type>text</frontend_type>
2592
+ <sort_order>100</sort_order>
2593
  <show_in_default>1</show_in_default>
2594
  <show_in_website>0</show_in_website>
2595
  <show_in_store>0</show_in_store>
2597
  <cif_version_confirming translate="label" module="postnl">
2598
  <label>Confirming Webservice version</label>
2599
  <frontend_type>text</frontend_type>
2600
+ <sort_order>110</sort_order>
2601
  <show_in_default>1</show_in_default>
2602
  <show_in_website>0</show_in_website>
2603
  <show_in_store>0</show_in_store>
2605
  <cif_version_labelling translate="label" module="postnl">
2606
  <label>Labelling Webservice version</label>
2607
  <frontend_type>text</frontend_type>
2608
+ <sort_order>120</sort_order>
2609
  <show_in_default>1</show_in_default>
2610
  <show_in_website>0</show_in_website>
2611
  <show_in_store>0</show_in_store>
2613
  <cif_version_barcode translate="label" module="postnl">
2614
  <label>Barcode Webservice version</label>
2615
  <frontend_type>text</frontend_type>
2616
+ <sort_order>130</sort_order>
2617
  <show_in_default>1</show_in_default>
2618
  <show_in_website>0</show_in_website>
2619
  <show_in_store>0</show_in_store>
2621
  <cif_version_checkout translate="label" module="postnl">
2622
  <label>Checkout Webservice version</label>
2623
  <frontend_type>text</frontend_type>
2624
+ <sort_order>140</sort_order>
2625
  <show_in_default>1</show_in_default>
2626
  <show_in_website>0</show_in_website>
2627
  <show_in_store>0</show_in_store>
app/design/adminhtml/default/default/layout/TIG/postnl.xml CHANGED
@@ -1,29 +1,29 @@
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@totalinternetgroup.nl so we can send you a copy immediately.
@@ -36,7 +36,7 @@
36
  *
37
  * @copyright Copyright (c) 2013 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
  <default>
@@ -50,7 +50,7 @@
50
  <block type="postnl/adminhtml_cronNotification" name="postnl_cron_notification" template="TIG/PostNL/cron_notification.phtml"/>
51
  </reference>
52
  </default>
53
-
54
  <adminhtml_system_config_edit>
55
  <reference name="head">
56
  <action method="addItem">
@@ -65,7 +65,7 @@
65
  </reference>
66
  <remove name="form"/>
67
  </adminhtml_system_config_edit>
68
-
69
  <adminhtml_sales_order_index>
70
  <reference name="head">
71
  <action method="addItem">
@@ -83,7 +83,13 @@
83
  <block type="adminhtml/abstract" name="postnl_filter_massaction" template="TIG/PostNL/sales/order/filter_massaction.phtml"/>
84
  </reference>
85
  </adminhtml_sales_order_index>
86
-
 
 
 
 
 
 
87
  <adminhtml_sales_order_shipment_new>
88
  <reference name="head">
89
  <action method="addItem">
@@ -95,7 +101,7 @@
95
  <block type="postnl_adminhtml/sales_order_shipment_create_shipmentOptions" name="postnl_shipment_create_shipment_options" template="TIG/PostNL/sales/order/shipment/create/shipment_options.phtml" />
96
  </reference>
97
  </adminhtml_sales_order_shipment_new>
98
-
99
  <!-- Add a shipping status bar to the shipment view page as well as adding tabs to the page -->
100
  <adminhtml_sales_order_shipment_view>
101
  <reference name="head">
@@ -138,7 +144,7 @@
138
  </block>
139
  </reference>
140
  </adminhtml_sales_order_shipment_view>
141
-
142
  <postnl_adminhtml_shipment_statushistory>
143
  <block type="core/text_list" name="root" output="toHtml">
144
  <block type="postnl_adminhtml/sales_order_shipment_view_tab_statusHistory" name="sales_order_shipment_status_history" template="TIG/PostNL/sales/order/shipment/view/tab/status_history.phtml"/>
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@totalinternetgroup.nl so we can send you a copy immediately.
36
  *
37
  * @copyright Copyright (c) 2013 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
  <default>
50
  <block type="postnl/adminhtml_cronNotification" name="postnl_cron_notification" template="TIG/PostNL/cron_notification.phtml"/>
51
  </reference>
52
  </default>
53
+
54
  <adminhtml_system_config_edit>
55
  <reference name="head">
56
  <action method="addItem">
65
  </reference>
66
  <remove name="form"/>
67
  </adminhtml_system_config_edit>
68
+
69
  <adminhtml_sales_order_index>
70
  <reference name="head">
71
  <action method="addItem">
83
  <block type="adminhtml/abstract" name="postnl_filter_massaction" template="TIG/PostNL/sales/order/filter_massaction.phtml"/>
84
  </reference>
85
  </adminhtml_sales_order_index>
86
+
87
+ <adminhtml_sales_shipment_index>
88
+ <reference name="content">
89
+ <block type="postnl_adminhtml/system_config_form_field_configCheck" name="postnl-testmode-warning" template="TIG/PostNL/sales/shipment/testmode_warning.phtml"/>
90
+ </reference>
91
+ </adminhtml_sales_shipment_index>
92
+
93
  <adminhtml_sales_order_shipment_new>
94
  <reference name="head">
95
  <action method="addItem">
101
  <block type="postnl_adminhtml/sales_order_shipment_create_shipmentOptions" name="postnl_shipment_create_shipment_options" template="TIG/PostNL/sales/order/shipment/create/shipment_options.phtml" />
102
  </reference>
103
  </adminhtml_sales_order_shipment_new>
104
+
105
  <!-- Add a shipping status bar to the shipment view page as well as adding tabs to the page -->
106
  <adminhtml_sales_order_shipment_view>
107
  <reference name="head">
144
  </block>
145
  </reference>
146
  </adminhtml_sales_order_shipment_view>
147
+
148
  <postnl_adminhtml_shipment_statushistory>
149
  <block type="core/text_list" name="root" output="toHtml">
150
  <block type="postnl_adminhtml/sales_order_shipment_view_tab_statusHistory" name="sales_order_shipment_status_history" template="TIG/PostNL/sales/order/shipment/view/tab/status_history.phtml"/>
app/design/adminhtml/default/default/template/TIG/PostNL/sales/shipment/testmode_warning.phtml ADDED
@@ -0,0 +1,53 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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@totalinternetgroup.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@totalinternetgroup.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_PostNL_Block_Adminhtml_System_Config_Form_Field_ConfigCheck $this
40
+ */
41
+ ?>
42
+ <?php $_testEnabled = $this->isTestEnabled(); ?>
43
+ <?php $_isTestMode = $this->isTestModeActive(); ?>
44
+ <?php $_helper = Mage::helper('postnl'); ?>
45
+ <?php if (!$_testEnabled || !$_isTestMode): ?>
46
+ <?php return ''; ?>
47
+ <?php endif; ?>
48
+
49
+ <div class="module-message warning" id="postnl_testmode_warning">
50
+ <h4>[POSTNL-0098] <?php echo $this->__('The PostNL Extension is currently configured in test mode.')?> <a href="<?php echo $_helper->getErrorUrl('POSTNL-0098'); ?>" target="blank"><?php echo $this->__('Click here for more information from the TiG knowledgebase.') ?></a></h4>
51
+ <p><?php echo $this->__('You may test the extension, however you cannot send any shipments in this mode. Any shipments that you confirm or whose labels you print while in this mode will be registered as test shipments and may not be physically shipped. If you attempt to do so, you may incur fines from PostNL. To use the extension in live mode you first need to enter your PostNL account credentials and set the extension to live mode. You can then send shipments using the PostNL extension.'); ?></p>
52
+ <p><?php echo $this->__("You can enter your live username and password in the 'Account Settings' tab of the PostNL extension configuration. Don't forget to also update your customer number, customer code and BLS (location) code. You can then set the extension to live mode in the 'Confirming and Label Printing Settings' tab. If you use PostNL Checkout you also need to set PostNL Checkout to live mode in the 'PostNL Checkout Settings' tab."); ?></p>
53
+ </div>
app/design/adminhtml/default/default/template/TIG/PostNL/system/config/form/field/config_check.phtml CHANGED
@@ -1,28 +1,28 @@
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@totalinternetgroup.nl so we can send you a copy immediately.
@@ -35,21 +35,35 @@
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
- <?php $_liveEnabled = $this->isLiveEnabled(); ?>
41
- <?php $_testEnabled = $this->isTestEnabled(); ?>
42
- <?php $_globalEnabled = $this->isGlobalEnabled(); ?>
 
43
  <?php $_checkoutEnabled = $this->isCheckoutEnabled(); ?>
44
- <?php $_helper = Mage::helper('postnl'); ?>
 
 
 
 
 
 
 
 
45
 
46
- <?php if (!$_liveEnabled): ?>
47
- <?php $_liveConfigErrors = $this->getLiveConfigErrors(); ?>
 
 
 
48
  <div class="module-message error">
49
  <h4>[POSTNL-0002] <?php echo $this->__('You have not yet fully configured the extension. You must complete this process before you can use it.')?> <a href="<?php echo $_helper->getErrorUrl('POSTNL-0002'); ?>" target="blank"><?php echo $this->__('Click here for more information from the TiG knowledgebase.') ?></a></h4>
50
- <?php if ($_liveConfigErrors): ?>
51
  <ul class="postnl-errors">
52
- <?php foreach ($_liveConfigErrors as $_errorData): ?>
53
  <li>
54
  <?php $_code = $_errorData['code']; ?>
55
  <?php $_error = $_errorData['message']; ?>
@@ -65,7 +79,7 @@
65
  </div>
66
  <?php endif; ?>
67
 
68
- <?php if (!$_globalEnabled && ($_liveEnabled || $_testEnabled)): ?>
69
  <?php $_globalConfigErrors = $this->getGlobalConfigErrors(); ?>
70
  <div class="module-message warning">
71
  <h4>[POSTNL-0003] <?php echo $this->__('You have not yet configured the extension to use GlobalPack shipments. Please complete this process if you wish to ship parcels to outside the EU.')?> <a href="<?php echo $_helper->getErrorUrl('POSTNL-0003'); ?>" target="blank"><?php echo $this->__('Click here for more information from the TiG knowledgebase.') ?></a></h4>
@@ -87,7 +101,7 @@
87
  </div>
88
  <?php endif; ?>
89
 
90
- <?php if (!$_checkoutEnabled && ($_liveEnabled || $_testEnabled)): ?>
91
  <?php $_checkoutConfigErrors = $this->getCheckoutConfigErrors(); ?>
92
  <div class="module-message warning">
93
  <h4>[POSTNL-0004] <?php echo $this->__('You have not yet configured PostNL Checkout. Please complete this process if you wish to use PostNL Checkout.')?> <a href="<?php echo $_helper->getErrorUrl('POSTNL-0004'); ?>" target="blank"><?php echo $this->__('Click here for more information from the TiG knowledgebase.') ?></a></h4>
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@totalinternetgroup.nl so we can send you a copy immediately.
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_PostNL_Block_Adminhtml_System_Config_Form_Field_ConfigCheck $this
40
  */
41
  ?>
42
+ <?php $_liveEnabled = $this->isLiveEnabled(); ?>
43
+ <?php $_testEnabled = $this->isTestEnabled(); ?>
44
+ <?php $_isTestMode = $this->isTestModeActive(); ?>
45
+ <?php $_globalEnabled = $this->isGlobalEnabled(); ?>
46
  <?php $_checkoutEnabled = $this->isCheckoutEnabled(); ?>
47
+ <?php $_helper = Mage::helper('postnl'); ?>
48
+
49
+ <?php if ($_testEnabled && $_isTestMode): ?>
50
+ <div class="module-message warning">
51
+ <h4>[POSTNL-0098] <?php echo $this->__('The PostNL Extension is currently configured in test mode.')?> <a href="<?php echo $_helper->getErrorUrl('POSTNL-0098'); ?>" target="blank"><?php echo $this->__('Click here for more information from the TiG knowledgebase.') ?></a></h4>
52
+ <p><?php echo $this->__('You may test the extension, however you cannot send any shipments in this mode. Any shipments that you confirm or whose labels you print while in this mode will be registered as test shipments and may not be physically shipped. If you attempt to do so, you may incur fines from PostNL. To use the extension in live mode you first need to enter your PostNL account credentials and set the extension to live mode. You can then send shipments using the PostNL extension.'); ?></p>
53
+ <p><?php echo $this->__("You can enter your live username and password in the 'Account Settings' tab. Don't forget to also update your customer number, customer code and BLS (location) code. You can then set the extension to live mode in the 'Confirming and Label Printing Settings' tab. If you use PostNL Checkout you also need to set PostNL Checkout to live mode in the 'PostNL Checkout Settings' tab."); ?></p>
54
+ </div>
55
+ <?php endif; ?>
56
 
57
+ <?php if ((!$_liveEnabled && !$_isTestMode) || (!$_testEnabled && $_isTestMode)): ?>
58
+ <?php $_errorArray = $this->getLiveConfigErrors(); ?>
59
+ <?php if ($_isTestMode): ?>
60
+ <?php $_errorArray = $this->getTestConfigErrors(); ?>
61
+ <?php endif; ?>
62
  <div class="module-message error">
63
  <h4>[POSTNL-0002] <?php echo $this->__('You have not yet fully configured the extension. You must complete this process before you can use it.')?> <a href="<?php echo $_helper->getErrorUrl('POSTNL-0002'); ?>" target="blank"><?php echo $this->__('Click here for more information from the TiG knowledgebase.') ?></a></h4>
64
+ <?php if ($_errorArray): ?>
65
  <ul class="postnl-errors">
66
+ <?php foreach ($_errorArray as $_errorData): ?>
67
  <li>
68
  <?php $_code = $_errorData['code']; ?>
69
  <?php $_error = $_errorData['message']; ?>
79
  </div>
80
  <?php endif; ?>
81
 
82
+ <?php if (!$_globalEnabled && (($_liveEnabled && !$_isTestMode) || ($_testEnabled && $_isTestMode))): ?>
83
  <?php $_globalConfigErrors = $this->getGlobalConfigErrors(); ?>
84
  <div class="module-message warning">
85
  <h4>[POSTNL-0003] <?php echo $this->__('You have not yet configured the extension to use GlobalPack shipments. Please complete this process if you wish to ship parcels to outside the EU.')?> <a href="<?php echo $_helper->getErrorUrl('POSTNL-0003'); ?>" target="blank"><?php echo $this->__('Click here for more information from the TiG knowledgebase.') ?></a></h4>
101
  </div>
102
  <?php endif; ?>
103
 
104
+ <?php if (!$_checkoutEnabled && (($_liveEnabled && !$_isTestMode) || ($_testEnabled && $_isTestMode))): ?>
105
  <?php $_checkoutConfigErrors = $this->getCheckoutConfigErrors(); ?>
106
  <div class="module-message warning">
107
  <h4>[POSTNL-0004] <?php echo $this->__('You have not yet configured PostNL Checkout. Please complete this process if you wish to use PostNL Checkout.')?> <a href="<?php echo $_helper->getErrorUrl('POSTNL-0004'); ?>" target="blank"><?php echo $this->__('Click here for more information from the TiG knowledgebase.') ?></a></h4>
app/design/adminhtml/default/default/template/TIG/PostNL/system/config/form/field/js.phtml CHANGED
@@ -1,28 +1,28 @@
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@totalinternetgroup.nl so we can send you a copy immediately.
@@ -40,52 +40,61 @@
40
  <?php $_activateUrl = $this->getUrl('postnl/adminhtml_extensionControl/activate', array('_secure' => true)); ?>
41
  <?php $_validateUrl = $this->getUrl('postnl/adminhtml_config/validateAccount', array('_secure' => true)); ?>
42
  <?php $_website = Mage::app()->getRequest()->getParam('website'); ?>
 
43
  <script type="text/javascript">
44
  //<![CDATA[
45
- var postnlActivationUrl = '<?php echo $_activateUrl; ?>';
46
- function activatePostNL() {
47
- $('config_edit_form').action = postnlActivationUrl;
48
- configForm.submit();
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
49
  }
50
-
51
- function validateAccountSettings() {
52
- new Ajax.Request('<?php echo $_validateUrl; ?>',{
53
- method: 'post',
54
- parameters: {
55
- customerNumber: getConfigValue('postnl_cif_customer_number'),
56
- customerCode: getConfigValue('postnl_cif_customer_code'),
57
- username: getConfigValue('postnl_cif_live_username'),
58
- password: getConfigValue('postnl_cif_live_password'),
59
- locationCode: getConfigValue('postnl_cif_collection_location'),
60
- website: '<?php echo $_website; ?>'
61
- },
62
- onComplete: function(response) {
63
- response = response.responseText;
64
- if (response == 'ok') {
65
- alert('<?php echo $this->__('Account settings have been succesfully validated. Please save this page to keep these settings.'); ?>');
66
- return;
67
- }
68
-
69
- if (response == 'missing_data') {
70
- alert('<?php echo $this->__('One or more fields are missing. Please fill these fields and try again.'); ?>');
71
- return;
72
- }
73
-
74
- alert('<?php echo $this->__('Your account settings are incorrect. Please check all fields and try again. If this error persists, please contact PostNL.'); ?>');
75
  return;
76
  }
77
- });
78
- }
79
-
80
- function getConfigValue(fieldName) {
81
- var inheritName = fieldName + '_inherit';
82
-
83
- if ($(inheritName) && $(inheritName).checked) {
84
- return 'inherit';
85
  }
86
-
87
- var value = $(fieldName).getValue();
88
- return value;
 
 
 
 
 
89
  }
 
 
 
90
  //]]>
91
  </script>
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@totalinternetgroup.nl so we can send you a copy immediately.
40
  <?php $_activateUrl = $this->getUrl('postnl/adminhtml_extensionControl/activate', array('_secure' => true)); ?>
41
  <?php $_validateUrl = $this->getUrl('postnl/adminhtml_config/validateAccount', array('_secure' => true)); ?>
42
  <?php $_website = Mage::app()->getRequest()->getParam('website'); ?>
43
+ <?php $_isTestMode = Mage::helper('postnl')->isTestMode(Mage_Core_Model_App::ADMIN_STORE_ID); ?>
44
  <script type="text/javascript">
45
  //<![CDATA[
46
+ var postnlActivationUrl = '<?php echo $_activateUrl; ?>';
47
+ var isTestMode = <?php echo $_isTestMode ? 'true' : 'false'; ?>;
48
+ function activatePostNL() {
49
+ $('config_edit_form').action = postnlActivationUrl;
50
+ configForm.submit();
51
+ }
52
+
53
+ function validateAccountSettings() {
54
+ var params = {
55
+ customerNumber : getConfigValue('postnl_cif_customer_number'),
56
+ customerCode : getConfigValue('postnl_cif_customer_code'),
57
+ locationCode : getConfigValue('postnl_cif_collection_location'),
58
+ website : '<?php echo $_website; ?>',
59
+ isTestMode : isTestMode
60
+ };
61
+
62
+ if (isTestMode) {
63
+ params['username'] = getConfigValue('postnl_cif_test_username');
64
+ params['password'] = getConfigValue('postnl_cif_test_password');
65
+ } else {
66
+ params['username'] = getConfigValue('postnl_cif_live_username');
67
+ params['password'] = getConfigValue('postnl_cif_live_password');
68
  }
69
+
70
+ new Ajax.Request('<?php echo $_validateUrl; ?>',{
71
+ method: 'post',
72
+ parameters: params,
73
+ onComplete: function(response) {
74
+ response = response.responseText;
75
+ if (response == 'ok') {
76
+ alert('<?php echo $this->__('Account settings have been succesfully validated. Please save this page to keep these settings.'); ?>');
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
77
  return;
78
  }
79
+
80
+ if (response == 'missing_data') {
81
+ alert('<?php echo $this->__('One or more fields are missing. Please fill these fields and try again.'); ?>');
82
+ return;
83
+ }
84
+
85
+ alert('<?php echo $this->__('Your account settings are incorrect. Please check all fields and try again. If this error persists, please contact PostNL.'); ?>');
 
86
  }
87
+ });
88
+ }
89
+
90
+ function getConfigValue(fieldName) {
91
+ var inheritName = fieldName + '_inherit';
92
+
93
+ if ($(inheritName) && $(inheritName).checked) {
94
+ return 'inherit';
95
  }
96
+
97
+ return $(fieldName).getValue();
98
+ }
99
  //]]>
100
  </script>
app/design/adminhtml/default/default/template/TIG/PostNL/system/config/form/field/support_tab.phtml CHANGED
@@ -1,28 +1,28 @@
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@totalinternetgroup.nl so we can send you a copy immediately.
@@ -77,6 +77,7 @@
77
  </li>
78
  <li><strong><?php echo $this->__('Configure your PostNL account');?></strong>
79
  <ol>
 
80
  <li><?php echo $this->__("Make sure you have your PostNL account info with you. You will need the following info: username & password, customer number, customer code, and BLS code. You need to enter these in the 'Account Settings' tab.");?></li>
81
  <li><?php echo $this->__("First enter your username and password. Depending on the status of your account, you may either enter the 'test' or 'live' version of these fields. Please note: if you do not enter the 'live' fields, you will only be able to create test shipments.");?></li>
82
  <li><?php echo $this->__('Next enter your customer number, customer code and BLS code. If you are unsure about which information to enter here, please contact PostNL.'); ?></li>
@@ -101,23 +102,23 @@
101
  <ol>
102
  <li><?php echo $this->__('If you wish to send orders to outside the EU, you need to configure your GlobalPack settings.');?></li>
103
  <li><?php echo $this->__("Go to the 'Account Settings' tab and fill in the 'Global Barcode Type' and 'Global Barcode Range' fields.");?></li>
104
- <li><?php echo $this->__("Go to the 'GlobalPack Settings' tab and specify your preferences. Be aware, that if you do not configure these settings correctly, international shipments may be refused by either PostNL or the customs office.");?></li>
105
  </ol>
106
  </li>
107
  <li><strong><?php echo $this->__('Configure your PostNL Checkout settings');?></strong>
108
  <ol>
109
  <li><?php echo $this->__('If you wish to use PostNL Checkout in your webshop, you need to configure your PostNl Checkout settings.');?></li>
110
  <li><?php echo $this->__("Go to the 'Account Settings' tab and fill in the 'Webshop ID' and 'Public Webshop ID' fields.");?></li>
111
- <li><?php echo $this->__("Go to the 'PostNL Checkout' tab and specify your preferences.");?></li>
112
- <li><?php echo $this->__("Go to the 'PostNL Checkout Paymen Settings' tab and specify which payment methods PostNL Checkout supports. Here you must also link the PostNL Checkout payment methods to the payment methods you use in Magento. If you do not configure this properly, customers may be forced to pay with a different payment method than the one they selected.");?></li>
113
  </ol>
114
  </li>
115
  </ol>
116
  </div>
117
  </td>
118
-
119
  <td class="col-faux"></td>
120
-
121
  <td class="col-right">
122
  <div class="text-box">
123
  <h3><?php echo $this->__('Magento &amp; 3rd party version compatibility');?></h3>
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@totalinternetgroup.nl so we can send you a copy immediately.
77
  </li>
78
  <li><strong><?php echo $this->__('Configure your PostNL account');?></strong>
79
  <ol>
80
+ <li><?php echo $this->__('By default the extension is pre-configured using a test account. If you already have your PostNL account credentials, you can enter them using the steps below. If you have not yet received these credentials you may keep using the extensions in test mode. In this case you can continue to step 3.'); ?></li>
81
  <li><?php echo $this->__("Make sure you have your PostNL account info with you. You will need the following info: username & password, customer number, customer code, and BLS code. You need to enter these in the 'Account Settings' tab.");?></li>
82
  <li><?php echo $this->__("First enter your username and password. Depending on the status of your account, you may either enter the 'test' or 'live' version of these fields. Please note: if you do not enter the 'live' fields, you will only be able to create test shipments.");?></li>
83
  <li><?php echo $this->__('Next enter your customer number, customer code and BLS code. If you are unsure about which information to enter here, please contact PostNL.'); ?></li>
102
  <ol>
103
  <li><?php echo $this->__('If you wish to send orders to outside the EU, you need to configure your GlobalPack settings.');?></li>
104
  <li><?php echo $this->__("Go to the 'Account Settings' tab and fill in the 'Global Barcode Type' and 'Global Barcode Range' fields.");?></li>
105
+ <li><?php echo $this->__("Go to the 'GlobalPack Settings' tab and specify your preferences. Be aware, that if you do not configure these settings correctly, international shipments may be refused by either PostNL or the customs office.");?></li>
106
  </ol>
107
  </li>
108
  <li><strong><?php echo $this->__('Configure your PostNL Checkout settings');?></strong>
109
  <ol>
110
  <li><?php echo $this->__('If you wish to use PostNL Checkout in your webshop, you need to configure your PostNl Checkout settings.');?></li>
111
  <li><?php echo $this->__("Go to the 'Account Settings' tab and fill in the 'Webshop ID' and 'Public Webshop ID' fields.");?></li>
112
+ <li><?php echo $this->__("Go to the 'PostNL Checkout' tab and specify your preferences.");?></li>
113
+ <li><?php echo $this->__("Go to the 'PostNL Checkout Paymen Settings' tab and specify which payment methods PostNL Checkout supports. Here you must also link the PostNL Checkout payment methods to the payment methods you use in Magento. If you do not configure this properly, customers may be forced to pay with a different payment method than the one they selected.");?></li>
114
  </ol>
115
  </li>
116
  </ol>
117
  </div>
118
  </td>
119
+
120
  <td class="col-faux"></td>
121
+
122
  <td class="col-right">
123
  <div class="text-box">
124
  <h3><?php echo $this->__('Magento &amp; 3rd party version compatibility');?></h3>
app/locale/en_US/TIG_PostNL.csv CHANGED
@@ -22,8 +22,8 @@ During activation 2 secure keys will be sent to this email address.,During activ
22
  Unique key,Unique key
23
  Private key,Private key
24
  Account Settings,Account Settings
25
- Username,Username
26
- Password,Password
27
  Test Username,Test Username
28
  Test Password,Test Password
29
  Customer Number,Customer Number
@@ -37,7 +37,7 @@ The current global barcode type as supplied by PostNL. Must contain 2 letters.,T
37
  Global Barcode Range,Global Barcode Range
38
  Your global barcode range as supplied by PostNL. Must contain 4 digits.,Your global barcode range as supplied by PostNL. Must contain 4 digits.
39
  These fields are only required if you wish to use PostNL Checkout.,These fields are only required if you wish to use PostNL Checkout.
40
- Webshop External ID,Webshop External ID
41
  Public Webshop ID,Public Webshop ID
42
  These fields contain your contact information for PostNL.,These fields contain your contact information for PostNL.
43
  Company Name,Company Name
@@ -223,10 +223,10 @@ Please select one or more shipments.,Please select one or more shipments.
223
  You can print a maximum of 200 labels at once.,You can print a maximum of 200 labels at once.
224
  The shipments have been confirmed successfully.,The shipments have been confirmed successfully.
225
  Order #%s cannot be shipped at this time.,Order #%s cannot be shipped at this time.
226
- PostNL replied with the following warnings:,PostNL replied with the following warnings:
227
  Error code %s:,Error code %s:
228
  An error occurred whilst processing your request:,An error occurred whilst processing your request:
229
- Your webshop has been registered. You should receive an email on the email address you specify shortly. ,Your webshop has been registered. You should receive an email on the email address you specify shortly.
230
  Please read this email carefully as it contains instructions on how to finish the extension activation procedure.,Please read this email carefully as it contains instructions on how to finish the extension activation procedure.
231
  Please fill in your unique and private keys and try again.,Please fill in your unique and private keys and try again.
232
  The extension has been successfully activated!,The extension has been successfully activated!
@@ -435,7 +435,7 @@ Documents,Documents
435
  Commercial Goods,Commercial Goods
436
  Commercial Sample,Commercial Sample
437
  Returned Goods,Returned Goods
438
- An error occurred while processing your request: ,An error occurred while processing your request:
439
  OrderToken missing for quote #%s,OrderToken missing for quote #%s
440
  Unable to create an order for quote #%s,Unable to create an order for quote #%s
441
  Invalid quote supplied.,Invalid quote supplied.
@@ -461,7 +461,7 @@ Before you proceed to use this extension it is very important that you have prop
461
  "You should properly configure your checkout process. PostNL needs to be able to retrieve a properly formatted address from the checkout process in order to guarantee the order is delivered at the correct address. In order to do so, you need to enable the appropriate number of street lines in your checkout flow and make sure these have correct labels and validation settings. More info on how to do this, can be found <a href='%s' target='_blank'>here</a>.","You should properly configure your checkout process. PostNL needs to be able to retrieve a properly formatted address from the checkout process in order to guarantee the order is delivered at the correct address. In order to do so, you need to enable the appropriate number of street lines in your checkout flow and make sure these have correct labels and validation settings. More info on how to do this, can be found <a href='%s' target='_blank'>here</a>."
462
  Register the extension for use,Register the extension for use
463
  Open the 'General Settings' tab and enter your email address.,Open the 'General Settings' tab and enter your email address.
464
- Press the 'Activate the extension' button. You will now receive an email at the address you specified containing 2 secure keys.,Press the 'Activate the extension' button. You will now receive an email at the address you specified containing 2 secure keys.
465
  Copy the keys and enter them in the 'Unique-' and 'Private key' fields that are now available.,Copy the keys and enter them in the 'Unique-' and 'Private key' fields that are now available.
466
  Press the 'Finish activation' button.,Press the 'Finish activation' button.
467
  Set the 'Active' field to 'Yes' and save the configuration. Your extension is now registered.,Set the 'Active' field to 'Yes' and save the configuration. Your extension is now registered.
@@ -483,7 +483,7 @@ Configure your GlobalPack settings,Configure your GlobalPack settings
483
  Go to the 'Account Settings' tab and fill in the 'Global Barcode Type' and 'Global Barcode Range' fields.,Go to the 'Account Settings' tab and fill in the 'Global Barcode Type' and 'Global Barcode Range' fields.
484
  "Go to the 'GlobalPack Settings' tab and specify your preferences. Be aware, that if you do not configure these settings correctly, international shipments may be refused by either PostNL or the customs office.","Go to the 'GlobalPack Settings' tab and specify your preferences. Be aware, that if you do not configure these settings correctly, international shipments may be refused by either PostNL or the customs office."
485
  Configure your PostNL Checkout settings,Configure your PostNL Checkout settings
486
- "If you wish to use PostNL Checkout in your webshop, you need to configure your PostNL Checkout settings.","If you wish to use PostNL Checkout in your webshop, you need to configure your PostNL Checkout settings."
487
  Go to the 'Account Settings' tab and fill in the 'Webshop ID' and 'Public Webshop ID' fields.,Go to the 'Account Settings' tab and fill in the 'Webshop ID' and 'Public Webshop ID' fields.
488
  Go to the 'PostNL Checkout' tab and specify your preferences.,Go to the 'PostNL Checkout' tab and specify your preferences.
489
  "Go to the 'PostNL Checkout Paymen Settings' tab and specify which payment methods PostNL Checkout supports. Here you must also link the PostNL Checkout payment methods to the payment methods you use in Magento. If you do not configure this properly, customers may be forced to pay with a different payment method than the one they selected.","Go to the 'PostNL Checkout Paymen Settings' tab and specify which payment methods PostNL Checkout supports. Here you must also link the PostNL Checkout payment methods to the payment methods you use in Magento. If you do not configure this properly, customers may be forced to pay with a different payment method than the one they selected."
@@ -578,4 +578,16 @@ A6,A6
578
  PostNL - Print Shipping Label,PostNL - Print Shipping Label
579
  PostNL - Send Tracking Information,PostNL - Send Tracking Information
580
  No status history available.,No status history available.
581
- Your webshop has been registered. Within a few minutes you will recieve an email at the emailaddress you specified. Please read this email carefully as it contains instructions on how to finish the extension activation procedure.,Your webshop has been registered. Within a few minutes you will recieve an email at the emailaddress you specified. Please read this email carefully as it contains instructions on how to finish the extension activation procedure.
 
 
 
 
 
 
 
 
 
 
 
 
22
  Unique key,Unique key
23
  Private key,Private key
24
  Account Settings,Account Settings
25
+ Live Username,Live Username
26
+ Live Password,Live Password
27
  Test Username,Test Username
28
  Test Password,Test Password
29
  Customer Number,Customer Number
37
  Global Barcode Range,Global Barcode Range
38
  Your global barcode range as supplied by PostNL. Must contain 4 digits.,Your global barcode range as supplied by PostNL. Must contain 4 digits.
39
  These fields are only required if you wish to use PostNL Checkout.,These fields are only required if you wish to use PostNL Checkout.
40
+ Webshop ID,Webshop ID
41
  Public Webshop ID,Public Webshop ID
42
  These fields contain your contact information for PostNL.,These fields contain your contact information for PostNL.
43
  Company Name,Company Name
223
  You can print a maximum of 200 labels at once.,You can print a maximum of 200 labels at once.
224
  The shipments have been confirmed successfully.,The shipments have been confirmed successfully.
225
  Order #%s cannot be shipped at this time.,Order #%s cannot be shipped at this time.
226
+ PostNL replied with the following warning(s):,PostNL replied with the following warning(s):
227
  Error code %s:,Error code %s:
228
  An error occurred whilst processing your request:,An error occurred whilst processing your request:
229
+ Your webshop has been registered. You should receive an email on the email address you specify shortly. ,Your webshop has been registered. You should receive an email on the email address you specify shortly.
230
  Please read this email carefully as it contains instructions on how to finish the extension activation procedure.,Please read this email carefully as it contains instructions on how to finish the extension activation procedure.
231
  Please fill in your unique and private keys and try again.,Please fill in your unique and private keys and try again.
232
  The extension has been successfully activated!,The extension has been successfully activated!
435
  Commercial Goods,Commercial Goods
436
  Commercial Sample,Commercial Sample
437
  Returned Goods,Returned Goods
438
+ An error occurred while processing your request: ,An error occurred while processing your request:
439
  OrderToken missing for quote #%s,OrderToken missing for quote #%s
440
  Unable to create an order for quote #%s,Unable to create an order for quote #%s
441
  Invalid quote supplied.,Invalid quote supplied.
461
  "You should properly configure your checkout process. PostNL needs to be able to retrieve a properly formatted address from the checkout process in order to guarantee the order is delivered at the correct address. In order to do so, you need to enable the appropriate number of street lines in your checkout flow and make sure these have correct labels and validation settings. More info on how to do this, can be found <a href='%s' target='_blank'>here</a>.","You should properly configure your checkout process. PostNL needs to be able to retrieve a properly formatted address from the checkout process in order to guarantee the order is delivered at the correct address. In order to do so, you need to enable the appropriate number of street lines in your checkout flow and make sure these have correct labels and validation settings. More info on how to do this, can be found <a href='%s' target='_blank'>here</a>."
462
  Register the extension for use,Register the extension for use
463
  Open the 'General Settings' tab and enter your email address.,Open the 'General Settings' tab and enter your email address.
464
+ Press the 'Activate the extension' button. You will now recieve an email at the address you specified containing 2 secure keys.,Press the 'Activate the extension' button. You will now recieve an email at the address you specified containing 2 secure keys.
465
  Copy the keys and enter them in the 'Unique-' and 'Private key' fields that are now available.,Copy the keys and enter them in the 'Unique-' and 'Private key' fields that are now available.
466
  Press the 'Finish activation' button.,Press the 'Finish activation' button.
467
  Set the 'Active' field to 'Yes' and save the configuration. Your extension is now registered.,Set the 'Active' field to 'Yes' and save the configuration. Your extension is now registered.
483
  Go to the 'Account Settings' tab and fill in the 'Global Barcode Type' and 'Global Barcode Range' fields.,Go to the 'Account Settings' tab and fill in the 'Global Barcode Type' and 'Global Barcode Range' fields.
484
  "Go to the 'GlobalPack Settings' tab and specify your preferences. Be aware, that if you do not configure these settings correctly, international shipments may be refused by either PostNL or the customs office.","Go to the 'GlobalPack Settings' tab and specify your preferences. Be aware, that if you do not configure these settings correctly, international shipments may be refused by either PostNL or the customs office."
485
  Configure your PostNL Checkout settings,Configure your PostNL Checkout settings
486
+ "If you wish to use PostNL Checkout in your webshop, you need to configure your PostNl Checkout settings.","If you wish to use PostNL Checkout in your webshop, you need to configure your PostNl Checkout settings."
487
  Go to the 'Account Settings' tab and fill in the 'Webshop ID' and 'Public Webshop ID' fields.,Go to the 'Account Settings' tab and fill in the 'Webshop ID' and 'Public Webshop ID' fields.
488
  Go to the 'PostNL Checkout' tab and specify your preferences.,Go to the 'PostNL Checkout' tab and specify your preferences.
489
  "Go to the 'PostNL Checkout Paymen Settings' tab and specify which payment methods PostNL Checkout supports. Here you must also link the PostNL Checkout payment methods to the payment methods you use in Magento. If you do not configure this properly, customers may be forced to pay with a different payment method than the one they selected.","Go to the 'PostNL Checkout Paymen Settings' tab and specify which payment methods PostNL Checkout supports. Here you must also link the PostNL Checkout payment methods to the payment methods you use in Magento. If you do not configure this properly, customers may be forced to pay with a different payment method than the one they selected."
578
  PostNL - Print Shipping Label,PostNL - Print Shipping Label
579
  PostNL - Send Tracking Information,PostNL - Send Tracking Information
580
  No status history available.,No status history available.
581
+ Your webshop has been registered. Within a few minutes you will recieve an email at the emailaddress you specified. Please read this email carefully as it contains instructions on how to finish the extension activation procedure.,Your webshop has been registered. Within a few minutes you will recieve an email at the emailaddress you specified. Please read this email carefully as it contains instructions on how to finish the extension activation procedure.
582
+ Confirmation Expired,Confirmation Expired
583
+ The PostNL Extension is currently configured in test mode.,The PostNL Extension is currently configured in test mode.
584
+ "You can enter your live username and password in the 'Account Settings' tab. Don't forget to also update your customer number, customer code and BLS (location) code. You can then set the extension to live mode in the 'Confirming and Label Printing Settings' tab. If you use PostNL Checkout you also need to set PostNL Checkout to live mode in the 'PostNL Checkout Settings' tab.","You can enter your live username and password in the 'Account Settings' tab. Don't forget to also update your customer number, customer code and BLS (location) code. You can then set the extension to live mode in the 'Confirming and Label Printing Settings' tab. If you use PostNL Checkout you also need to set PostNL Checkout to live mode in the 'PostNL Checkout Settings' tab."
585
+ "You may test the extension, however you cannot send any shipments in this mode. Any shipments that you confirm or whose labels you print while in this mode will be registered as test shipments and may not be physically shipped. If you attempt to do so, you may incur fines from PostNL. To use the extension in live mode you first need to enter your PostNL account credentials and set the extension to live mode. You can then send shipments using the PostNL extension.","You may test the extension, however you cannot send any shipments in this mode. Any shipments that you confirm or whose labels you print while in this mode will be registered as test shipments and may not be physically shipped. If you attempt to do so, you may incur fines from PostNL. To use the extension in live mode you first need to enter your PostNL account credentials and set the extension to live mode. You can then send shipments using the PostNL extension."
586
+ "You can enter your live username and password in the 'Account Settings' tab of the PostNL extension configuration. Don't forget to also update your customer number, customer code and BLS (location) code. You can then set the extension to live mode in the 'Confirming and Label Printing Settings' tab. If you use PostNL Checkout you also need to set PostNL Checkout to live mode in the 'PostNL Checkout Settings' tab.","You can enter your live username and password in the 'Account Settings' tab of the PostNL extension configuration. Don't forget to also update your customer number, customer code and BLS (location) code. You can then set the extension to live mode in the 'Confirming and Label Printing Settings' tab. If you use PostNL Checkout you also need to set PostNL Checkout to live mode in the 'PostNL Checkout Settings' tab."
587
+ PostNL - Remove Shipping Label,PostNL - Remove Shipping Label
588
+ Are you sure that you wish to remove this shipment\'s shipping label? You will need to print a new shipping label before you can send this shipment.,Are you sure that you wish to remove this shipment\'s shipping label? You will need to print a new shipping label before you can send this shipment.
589
+ PostNL - Change Confirmation,PostNL - Change Confirmation
590
+ Are you sure that you wish to reset the confirmation status of this shipment? You will need to confirm this shipment with PostNL again before you can send it. This action will remove all barcodes and labels associated with this shipment. You can not undo this action.,Are you sure that you wish to reset the confirmation status of this shipment? You will need to confirm this shipment with PostNL again before you can send it. This action will remove all barcodes and labels associated with this shipment. You can not undo this action.
591
+ The shipment's shipping labels have been deleted.,The shipment's shipping labels have been deleted.
592
+ The shipment's confirmation has been undone.,The shipment's confirmation has been undone.
593
+ "By default the extension is pre-configured using a test account. If you already have your PostNL account credentials, you can enter them using the steps below. If you have not yet received these credentials you may keep using the extensions in test mode. In this case you can continue to step 3.","By default the extension is pre-configured using a test account. If you already have your PostNL account credentials, you can enter them using the steps below. If you have not yet received these credentials you may keep using the extensions in test mode. In this case you can continue to step 3."
app/locale/nl_NL/TIG_PostNL.csv CHANGED
@@ -12,7 +12,7 @@ Ship to Specific Countries,Verzend naar specifieke landen
12
  Show Method if Not Applicable,Toon methode indien niet beschikbaar
13
  Displayed Error Message,Getoonde foutmelding indien niet beschikbaar
14
  Condition,Voorwaarde
15
- Include Virtual Products in Price Calculation,Neem de virtuele prodcten mee in de prijsberekening
16
  Version & Support,Versie & Ondersteuning
17
  General Settings,Algemene Instellingen
18
  Active,Actief
@@ -22,8 +22,8 @@ During activation 2 secure keys will be sent to this email address.,Tijdens de a
22
  Unique key,Unieke sleutel
23
  Private key,Prive sleutel
24
  Account Settings,Account Instellingen
25
- Username,Gebruikersnaam
26
- Password,Wachtwoord
27
  Test Username,Test gebruikersnaam
28
  Test Password,Test wachtwoord
29
  Customer Number,Klantnummer
@@ -37,7 +37,7 @@ The current global barcode type as supplied by PostNL. Must contain 2 letters.,D
37
  Global Barcode Range,Globaal barcode bereik
38
  Your global barcode range as supplied by PostNL. Must contain 4 digits.,Uw globaal barcode bereik zoals aangeleverd door PostNL. Moet bestaan uit 4 cijfers
39
  These fields are only required if you wish to use PostNL Checkout.,Deze velden zijn alleen verplicht als u gebruik wenst te maken van PostNL Checkout.
40
- Webshop External ID,Webwinkel extern ID
41
  Public Webshop ID,Publiek Webshop ID
42
  These fields contain your contact information for PostNL.,Deze velden bevatten uw contact informatie voor PostNL
43
  Company Name,Bedrijfsnaam
@@ -116,7 +116,7 @@ Use HS Tariff,Gebruik het HS tarief
116
  Enable this field to specify a product attribute to use as the product's HS tariff.,Activeer dit veld om de atributen te specificeren om als HS tarief te gebruiken
117
  HS Tariff attribute,HS tarief
118
  The product attribute used to determine the product's HS tariff.,Het productattribuut wat gebruikt wordt om het HS tarief van het product te bepalen
119
- Customs value attribute,Douane waarde
120
  The product attribute used to determine product's customs value.,Het productattribuut wat gebruikt wordt om de waarde voor de douane van het product te bepalen
121
  Country of origin attribute,Land van herkomst
122
  The product attribute used to determine the product's country of origin.,Het productattribuut wat gebruikt wordt om het land van herkomst van het product te bepalen
@@ -223,7 +223,7 @@ Please select one or more shipments.,Selecteer a.u.b. een of meer zendingen
223
  You can print a maximum of 200 labels at once.,U kunt maximaal 200 labels printen
224
  The shipments have been confirmed successfully.,De zendingen zijn succesvol voorgemeld.
225
  Order #%s cannot be shipped at this time.,Order #%s kan niet worden verzonden
226
- PostNL replied with the following warnings:,PostNL komt met de volgende waarschuwing:
227
  Error code %s:,Foutcode %s:
228
  An error occurred whilst processing your request:,Een fout is opgetreden tijdensn het verwerken van uw aanvraag
229
  Your webshop has been registered. You should receive an email on the email address you specify shortly. ,Uw webshop is geregistreerd. U ontvangt een e-mail op het door u opgegeven adres
@@ -390,7 +390,7 @@ PostNL Checkout is not available due to the following reasons:,PostNL Checkout i
390
  Click here for more information from the TiG knowledgebase.,Klik hier voor meer informatie in de TiG knowledgebase.
391
  This action cannot be used on non-PostNL shipments.,Deze actie kan niet gedaan worden op niet-PostNL zendingen.
392
  This shipment cannot be confirmed at this time.,Deze zending kan niet voorgemeld worden.
393
- For EU shipments you may only confirm a shipment after it's labels have been printed.,Europese verzendingen kunnen alleen voorgemeld worden als de labels zijn uitgeprint.
394
  Show error details in the frontend,Toon error details in de frontend
395
  "If set to 'yes', error details will be shown in the frontend when an error occurs. Error details include the error code as well as a link to the TiG knowledgebase article concerning the error. This is useful for debugging purposes, but should be disabled in a production environment.","Indien deze instelling op 'ja' staat, zullen ook in de frontend bij de meeste errors een foutcode en link naar de TiG knowledgebase getoond worden. Dit is nuttig wanneer u de extensie moet debuggen, echter zou nooit aan mogen staan in een productie omgeving."
396
  The PostNL extension is not compatible with your Magento version! This may cause unexpected behaviour.,De PostNL extensie is niet compatibel met uw Magento versie! Dit kan onverwachtte problemen veroorzaken.
@@ -435,7 +435,7 @@ Documents,Documenten
435
  Commercial Goods,Commerciële Goederen
436
  Commercial Sample,Commercieel Monster
437
  Returned Goods,Geretourneerde Goederen
438
- An error occurred while processing your request: ,Er is een fout opgetreden tijdens het verwerken van uw verzoek:
439
  OrderToken missing for quote #%s,OrderToken is niet aanwezig voor quote #%s
440
  Unable to create an order for quote #%s,Kan geen order creëren voor quote #%s
441
  Invalid quote supplied.,Ongeldige quote meegeleverd.
@@ -458,10 +458,10 @@ Date,Datum
458
  Before you proceed to use this extension it is very important that you have properly configured certain elements of your Magento webshop.,"Voordat u de extensie in gebruik neemt, is het belangrijk dat u enkele onderdelen van uw webshop correct ingesteld heeft."
459
  "You should make sure that each product you intend to ship using PostNL has a correct value for it's weight attribute. You can select a unit of measurement for this attribute in the 'Confirming & Label Settings' tab below. If you do not do this, PostNL may charge you extra when a parcel turns out to weigh significantly more than expected or they may even refuse your shipment.","U moet er zeker van zijn dat elk product dat u wilt versturen met PostNL een correcte waarde heeft in het 'gewicht' attribuut. De eenheid waarin u dit gewicht heeft ingevuld, kunt u instellen in het 'Voormelden en Labels Printen Settings' tabje hieronder. Indien u dit niet correct instelt, loopt u het risico dat PostNL extra kosten in rekening brengt of de zending weigert wanneer blijkt dat het opgegeven gewicht van een zending significant ver afwijkt van wat de webshop heeft opgegeven bij het voormelden."
460
  "Make sure the PostNL shipping method is configured under system > config > shipping methods > PostNL. Only shipments made using this shipping method will be able to use PostNL's services. You may choose to charge either a flat rate or a table rate-based shipping fee. In the case of the latter, the table rates you have added under the Table Rate shipping method will be used. More info on how to setup the Table Rate shipping method can be found <a href='%s' target='_blank'>here</a>.","Wees er zeker van dat de PostNL verzendmethode correct geconfigureerd is in systeem > configuratie > verzendmethodes > PostNL. Enkel bestellingen die met deze verzendmethode geplaatst zijn, kunnen verwerkt worden door de extensie. U kunt kiezen om een plat tarief of een tabel tarief in rekening brengen voor het gebruik van PostNL. Indien u kiest voor tabel tarieven, dan kunt u deze instellen bij de 'Tabel Tarieven' verzendmethode. De PostNL verzendmethode zal deze tarieven overnemen. Voor meer informatie over hoe u de tabel tarieven kunt instellen, kunt u <a href='%s' target='_blank'>hier</a> kijken."
461
- "You should properly configure your checkout process. PostNL needs to be able to retrieve a properly formatted address from the checkout process in order to guarantee the order is delivered at the correct address. In order to do so, you need to enable the appropriate number of street lines in your checkout flow and make sure these have correct labels and validation settings. More info on how to do this, can be found <a href='%s' target='_blank'>here</a>.",U moet uw afreken process goed inrichten. PostNL moet uit het afreken proces een correct opgemaakt adres kunnen lezen om er zeker van te zijn dat de zending ook echt naar het gekozen adres verstuurd wordt. Om hier zeker van te zijn moet u het juiste aantal straat regels aanzetten en deze voorzien van duidelijk labels an validatie. U kunt <a href='%s' target='_blank'>hier</a> meer lezen over hoe u dit juist kunt configureren.
462
  Register the extension for use,Registreer de extensie voor gebruik
463
  Open the 'General Settings' tab and enter your email address.,Open het 'Algemene Instellingen' tabje en vul uw e-mailadres in.
464
- Press the 'Activate the extension' button. You will now receive an email at the address you specified containing 2 secure keys.,Klik op de 'Activeer de extensie' knop. U ontvangt nu twee beveiligingssleutels op het door u ingevulde e-mailadres.
465
  Copy the keys and enter them in the 'Unique-' and 'Private key' fields that are now available.,Kopieer de sleutels en vul deze in in de 'Unieke-' en 'Prive sleutel' velden die nu zichtbaar zullen zijn.
466
  Press the 'Finish activation' button.,Klik op de 'Rond activatie af' knop.
467
  Set the 'Active' field to 'Yes' and save the configuration. Your extension is now registered.,Zet het 'Actief' veld op 'Ja' en sla de configuratie op. De extensie is nu geregistreerd.
@@ -477,14 +477,14 @@ Enter a sender and return address,Vul een afzender- en retouradres in
477
  "Configure your address settings, your confirming & label printing preferences and your preferred product options","Configureer nu uw adres instellingen, uw voormelden en labels printen voorkeuren, en uw product optie voorkeuren."
478
  "Go to the 'Address Settings' tab and configure this section based on which fields you use in your checkout process. If this does not precisely match your checkout process, orders may not be shipped to the correct address.",Ga nu naar het 'Adres Instellingen' tabje en configureer deze velden op basis van welke velden u gebruikt in uw afreken proces. Indien deze configuratie niet exact overeenkomt met de velden die u gebruikt in uw afrekenproces kan het voorkomen dat bestellingen naar het verkeerde adres verstuurd worden.
479
  Go to the 'Confirming & Label Printing Settings' tab and change your preferences. You may want to tweak these and then test them repeatedly before deciding on a final configuration.,Ga naar het 'Voormelden & Labels Printen Instellingen' tabje en pas uw voorkeuren aan. Het is verstandig om met deze instellingen te experimenteren en telkens te testen voordat u uw definitieve voorkeuren vastlegt.
480
- "Go to the 'Product Options' tab and select your supported and preferred product options. If you have questions regarding each product option and which would be most suitable to you, please contact PostNL.","Ga naar het 'Product Opties' tabje en selecteer welke PostNL preoducten u ondersteunt en welke u als standaard wilt aanhouden. Indien u vragen heeft met betrekking tot de mogelijke product opties of als u niet zeker bent welke product opties het beste bij u passen, neem dan contact op met PostNL."
481
  Configure your GlobalPack settings,Configureer uw GlobalPack instellingen
482
  "If you wish to send orders to outside the EU, you need to configure your GlobalPack settings.",Indien u bestellingen wilt versturen naar buiten de EU moet u uw GlobalPack instellingen configureren.
483
  Go to the 'Account Settings' tab and fill in the 'Global Barcode Type' and 'Global Barcode Range' fields.,Ga naar het 'Account Instellingen' tabje en vul de 'Globaal barcode type' en 'Globaal barcode bereik' velden in.
484
  "Go to the 'GlobalPack Settings' tab and specify your preferences. Be aware, that if you do not configure these settings correctly, international shipments may be refused by either PostNL or the customs office.","Ga naar het 'GlobalPack Instellingen' tabje en vul uw voorkeuren in. Let op: als u deze instellingen niet correct configureerd, kan het voorkomen dat PostNL of de douane de zending weigert."
485
  Configure your PostNL Checkout settings,Configureer uw PostNL Checkout instellingen
486
- "If you wish to use PostNL Checkout in your webshop, you need to configure your PostNL Checkout settings.",Indien u gebruik wilt maken van PostNL Checkout moet u uw PostNL Checkout instellingen configureren.
487
- Go to the 'Account Settings' tab and fill in the 'Webshop ID' and 'Public Webshop ID' fields.,Ga naar het 'Account Instellingen' tabje en vul de 'Webshop ID' en 'Publieke webshop ID' velden ini
488
  Go to the 'PostNL Checkout' tab and specify your preferences.,Ga naar het 'PostNL Checkout' tabje en vul uw voorkeuren in.
489
  "Go to the 'PostNL Checkout Paymen Settings' tab and specify which payment methods PostNL Checkout supports. Here you must also link the PostNL Checkout payment methods to the payment methods you use in Magento. If you do not configure this properly, customers may be forced to pay with a different payment method than the one they selected.","Ga naar het 'PostNL Checkout Betalingsinstellingen' tabje en kies welke betaalmethode u wilt aanbieden in PostNL Checkout. Hier moet u ook iedere PostNL Checkout betaalmethode die u ondersteunt, koppelen aan een Magento betaalmethode. Als u dit niet goed instelt, kan het voorkomen dat een klant uiteindelijk met een andere betaalmethode moet afrekenen dan hij of zij heeft gekozen in PostNL Checkout."
490
  "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 PostNL 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 ondersteunt wordt, kunnen wij niet garanderen dat de PostNL extensie feilloos zal functioneren. Voor vragen kunt u contact op nemen met de Total Internet Group servicedesk."
@@ -532,14 +532,14 @@ The confirmAndGenerateLabel action is currently unavailable.,De confirmAndGenera
532
  Invalid message type requested: %s,Ongeldig bericht type gekozen: %s
533
  Unable to read directory: %s,Kan folder niet lezen: %s
534
  Invalid UpdateOrder response: %s,Ongeldige UpdateOrder ontvangen: %s
535
- "Here you can configure your PostNL account.</p><p>In order to use this extension you need to <a href='http://www.postnl.nl/zakelijk/e-commerce/flexibele-bezorgopties/contactformulier' target='_blank' title='Register'>register</a> yourself with PostNL. You will then receive all necessary information in order to configure the extension. If you cannot find the email containing this information, please contact your PostNL account manager.","Hier kunt u uw PostNL account gegevens invullen.</p><p>Voor het gebruik van de extensie dient u zich <a
536
- href='http://www.postnl.nl/zakelijk/e-commerce/flexibele-bezorgopties/contactformulier' target='_blank'
537
  title='Aanmelden'>aan te melden</a> bij PostNL. U ontvangt vervolgens de benodigde gegevens voor uw instellingen. Indien u de e-mail die deze gegevens bevat niet meer kunt vinden, neem dan contact op met uw PostNL account manager."
538
  "You will find these settings in your <a href='https://checkout.postnl.nl/' target='_blank' title='PostNL'>PostNL Checkout account</a>.</p><p><a href='https://checkout.postnl.nl/' target='_blank' title='PostNL Checkout'>PostNL Checkout</a> is a free service, however you do need to <a href='https://checkout.postnl.nl/Consumer/Register?utm_source=magento&utm_medium=referral&utm_campaign=2014' target='_blank' title='Register'>register</a> yourself with PostNL. You will then receive all necessary information in order to configure this feature.","Deze gegevens vindt u in uw <a href='https://checkout.postnl.nl/' target='_blank' title='PostNL'>Checkout instellingen</a> bij PostNL.</p><p><a href='https://checkout.postnl.nl/' target='_blank' title='PostNL Checkout'>PostNL Checkout</a> is een gratis service, wel dient u zich <a href='https://checkout.postnl.nl/Consumer/Register?utm_source=magento&utm_medium=referral&utm_campaign=2014' target='_blank' title='Aanmelden'>aan te melden</a> bij PostNL. U ontvangt vervolgens de benodigde gegevens voor uw instellingen."
539
  ONLY CHANGE THESE SETTINGS WITH DIRECT INSTRUCTION FROM POSTNL OR TOTAL INTERNET GROUP,PAS DEZE INSTELLINGEN ENKEL AAN MET DIRECTE INSTRUCTIES VAN POSTNL OF TOTAL INTERNET GROUP
540
  "Customers who use this feature will subscribe to your webshop's newsletter, not PostNL's newsletter. Please note that 3rd party extensions that alter the Magento newsletter functionality may conflict with this feature.","Klanten die gebruik maken van deze feature zullen ingeschreven worden op de nieuwsbrief van uw webshop, niet op de nieuwsbrief van PostNL. Houd er rekenen mee dat extensies van derden die de Magento nieuwsbrief functionaliteit aanpassen mogelijk zullen conflicteren met deze feature."
541
  Doorcodes are often used in foreign addresses such as those used in France and Singapore.,Deurcodes worden veelal gebruikt in buitenlandse addressen zoals addressen uit Frankrijk en Singapore.
542
- "Here you can enable or disable PostNL Checkout as well as completely customize all of it's facets.</p><p>By using PostNL Checkout you can offer your customers the option to easily choose their desired delivery date. They will be able to choose when and where they want their order delivered. They may choose to have the order delivered to their home (on a specific day at a specific time) or to have it delivered to their nearest post office.</p><p><a href='https://checkout.postnl.nl/' target='_blank' title='PostNL Checkout'>PostNL Checkout</a> is a free service, however you do need to <a href='https://checkout.postnl.nl/Consumer/Register?utm_source=magento&utm_medium=referral&utm_campaign=2014' target='_blank' title='Register'>register</a> yourself with PostNL. You will then receive all necessary information in order to configure this feature.","Hier kunt u PostNL Checkout activeren of deactiveren en alle onderdelen van PostNL Checkout configureren</p><p>Met de PostNL Checkout kunt u uw klanten tijdens hun bestelling eenvoudig de gewenste bezorging laten kiezen. Zijn kunnen dan zélf kiezen waar en wanneer zij hun bestelling willen ontvangen, bijv thuis (dagkeuze en tijdvak) of zelf ophalen op een Postkantoor.</p><p><a href='https://checkout.postnl.nl/' target='_blank' title='PostNL Checkout'>PostNL Checkout</a> is een gratis service, wel dient u zich <a
543
  href='https://checkout.postnl.nl/Consumer/Register?utm_source=magento&utm_medium=referral&utm_campaign=2014'
544
  target='_blank' title='Aanmelden'>aan te melden</a> bij PostNL. U ontvangt vervolgens de benodigde gegevens voor uw instellingen.
545
  "
@@ -573,7 +573,7 @@ You have not enabled PostNL Checkout. Please enable PostNL Checkout under 'Accou
573
  "If you are a contract customer of PostNL, you will have received an email containing this setting. If you cannot find this email, please contact PostNL support at 058-2333343","Als u een contractklant bent van PostNL heeft u een e-mail ontvangen met deze informatie. Indien u deze e-mail niet kan vinden, neem dan contact op met PostNL support op 058-2333343"
574
  Account settings have been succesfully validated. Please save this page to keep these settings.,De account instellingen zijn succesvol gevalideerd. Sla deze pagina op om deze instellingen te bewaren.
575
  One or more fields are missing. Please fill these fields and try again.,Eén of meerdere velden zijn niet ingevuld. Vul deze velden a.u.b. alsnog in en probeer het dan nog eens.
576
- "Your account settings are incorrect. Please check all fields and try again. If this error persists, please contact PostNL.","De account stellingen zijn incorrect. Controleer alle velden a.u.b. zorgvuldig en probeer het dan nog eens. Als deze melding zich blijft voordoen, kunt u het beste contact opnemen met PostNL."
577
  "This will send a 'test' request to PostNL. If the above fields are not entered correctly, this will result in an error.","Dit zal een 'test' verzoek sturen naar PostNL. Indien bovenstaande velden niet correct ingevuld zijn, zal dit resulteren in een foutmelding."
578
  Validate account settings,Valideer account instellingen
579
  Unconfirmed,Niet Voorgemeld
@@ -583,4 +583,16 @@ A6,A6
583
  PostNL - Print Shipping Label,PostNL - Print Verzendlabel
584
  PostNL - Send Tracking Information,PostNL - Verstuur Track & Trace Informatie
585
  No status history available.,Geen status geschiedenis informatie beschikbaar.
586
- Your webshop has been registered. Within a few minutes you will recieve an email at the emailaddress you specified. Please read this email carefully as it contains instructions on how to finish the extension activation procedure.,Uw webshop is geregistreerd. U ontvangt binnen enkele minuten een e-mail op het opgegeven e-mailadres. Lees deze e-mail s.v.p. aandachtig. Hierin staat aangegeven hoe u de activatieprocedure kunt afronden.
 
 
 
 
 
 
 
 
 
 
 
 
12
  Show Method if Not Applicable,Toon methode indien niet beschikbaar
13
  Displayed Error Message,Getoonde foutmelding indien niet beschikbaar
14
  Condition,Voorwaarde
15
+ Include Virtual Products in Price Calculation,Neem de virtuele producten mee in de prijsberekening
16
  Version & Support,Versie & Ondersteuning
17
  General Settings,Algemene Instellingen
18
  Active,Actief
22
  Unique key,Unieke sleutel
23
  Private key,Prive sleutel
24
  Account Settings,Account Instellingen
25
+ Live Username,Live Gebruikersnaam
26
+ Live Password,Live Wachtwoord
27
  Test Username,Test gebruikersnaam
28
  Test Password,Test wachtwoord
29
  Customer Number,Klantnummer
37
  Global Barcode Range,Globaal barcode bereik
38
  Your global barcode range as supplied by PostNL. Must contain 4 digits.,Uw globaal barcode bereik zoals aangeleverd door PostNL. Moet bestaan uit 4 cijfers
39
  These fields are only required if you wish to use PostNL Checkout.,Deze velden zijn alleen verplicht als u gebruik wenst te maken van PostNL Checkout.
40
+ Webshop ID,Webshop ID
41
  Public Webshop ID,Publiek Webshop ID
42
  These fields contain your contact information for PostNL.,Deze velden bevatten uw contact informatie voor PostNL
43
  Company Name,Bedrijfsnaam
116
  Enable this field to specify a product attribute to use as the product's HS tariff.,Activeer dit veld om de atributen te specificeren om als HS tarief te gebruiken
117
  HS Tariff attribute,HS tarief
118
  The product attribute used to determine the product's HS tariff.,Het productattribuut wat gebruikt wordt om het HS tarief van het product te bepalen
119
+ Customs value attribute,Douane waarde
120
  The product attribute used to determine product's customs value.,Het productattribuut wat gebruikt wordt om de waarde voor de douane van het product te bepalen
121
  Country of origin attribute,Land van herkomst
122
  The product attribute used to determine the product's country of origin.,Het productattribuut wat gebruikt wordt om het land van herkomst van het product te bepalen
223
  You can print a maximum of 200 labels at once.,U kunt maximaal 200 labels printen
224
  The shipments have been confirmed successfully.,De zendingen zijn succesvol voorgemeld.
225
  Order #%s cannot be shipped at this time.,Order #%s kan niet worden verzonden
226
+ PostNL replied with the following warning(s):,PostNL geeft de volgende waarschuwing(en):
227
  Error code %s:,Foutcode %s:
228
  An error occurred whilst processing your request:,Een fout is opgetreden tijdensn het verwerken van uw aanvraag
229
  Your webshop has been registered. You should receive an email on the email address you specify shortly. ,Uw webshop is geregistreerd. U ontvangt een e-mail op het door u opgegeven adres
390
  Click here for more information from the TiG knowledgebase.,Klik hier voor meer informatie in de TiG knowledgebase.
391
  This action cannot be used on non-PostNL shipments.,Deze actie kan niet gedaan worden op niet-PostNL zendingen.
392
  This shipment cannot be confirmed at this time.,Deze zending kan niet voorgemeld worden.
393
+ For EU shipments you may only confirm a shipment after it's labels have been printed.,Europese verzendingen kunnen alleen voorgemeld worden als de labels zijn uitgeprint.
394
  Show error details in the frontend,Toon error details in de frontend
395
  "If set to 'yes', error details will be shown in the frontend when an error occurs. Error details include the error code as well as a link to the TiG knowledgebase article concerning the error. This is useful for debugging purposes, but should be disabled in a production environment.","Indien deze instelling op 'ja' staat, zullen ook in de frontend bij de meeste errors een foutcode en link naar de TiG knowledgebase getoond worden. Dit is nuttig wanneer u de extensie moet debuggen, echter zou nooit aan mogen staan in een productie omgeving."
396
  The PostNL extension is not compatible with your Magento version! This may cause unexpected behaviour.,De PostNL extensie is niet compatibel met uw Magento versie! Dit kan onverwachtte problemen veroorzaken.
435
  Commercial Goods,Commerciële Goederen
436
  Commercial Sample,Commercieel Monster
437
  Returned Goods,Geretourneerde Goederen
438
+ An error occurred while processing your request: ,Er is een fout opgetreden tijdens het verwerken van uw verzoek:
439
  OrderToken missing for quote #%s,OrderToken is niet aanwezig voor quote #%s
440
  Unable to create an order for quote #%s,Kan geen order creëren voor quote #%s
441
  Invalid quote supplied.,Ongeldige quote meegeleverd.
458
  Before you proceed to use this extension it is very important that you have properly configured certain elements of your Magento webshop.,"Voordat u de extensie in gebruik neemt, is het belangrijk dat u enkele onderdelen van uw webshop correct ingesteld heeft."
459
  "You should make sure that each product you intend to ship using PostNL has a correct value for it's weight attribute. You can select a unit of measurement for this attribute in the 'Confirming & Label Settings' tab below. If you do not do this, PostNL may charge you extra when a parcel turns out to weigh significantly more than expected or they may even refuse your shipment.","U moet er zeker van zijn dat elk product dat u wilt versturen met PostNL een correcte waarde heeft in het 'gewicht' attribuut. De eenheid waarin u dit gewicht heeft ingevuld, kunt u instellen in het 'Voormelden en Labels Printen Settings' tabje hieronder. Indien u dit niet correct instelt, loopt u het risico dat PostNL extra kosten in rekening brengt of de zending weigert wanneer blijkt dat het opgegeven gewicht van een zending significant ver afwijkt van wat de webshop heeft opgegeven bij het voormelden."
460
  "Make sure the PostNL shipping method is configured under system > config > shipping methods > PostNL. Only shipments made using this shipping method will be able to use PostNL's services. You may choose to charge either a flat rate or a table rate-based shipping fee. In the case of the latter, the table rates you have added under the Table Rate shipping method will be used. More info on how to setup the Table Rate shipping method can be found <a href='%s' target='_blank'>here</a>.","Wees er zeker van dat de PostNL verzendmethode correct geconfigureerd is in systeem > configuratie > verzendmethodes > PostNL. Enkel bestellingen die met deze verzendmethode geplaatst zijn, kunnen verwerkt worden door de extensie. U kunt kiezen om een plat tarief of een tabel tarief in rekening brengen voor het gebruik van PostNL. Indien u kiest voor tabel tarieven, dan kunt u deze instellen bij de 'Tabel Tarieven' verzendmethode. De PostNL verzendmethode zal deze tarieven overnemen. Voor meer informatie over hoe u de tabel tarieven kunt instellen, kunt u <a href='%s' target='_blank'>hier</a> kijken."
461
+ "You should properly configure your checkout process. PostNL needs to be able to retrieve a properly formatted address from the checkout process in order to guarantee the order is delivered at the correct address. In order to do so, you need to enable the appropriate number of street lines in your checkout flow and make sure these have correct labels and validation settings. More info on how to do this, can be found <a href='%s' target='_blank'>here</a>.",U moet uw afreken process goed inrichten. PostNL moet uit het afreken proces een correct opgemaakt adres kunnen lezen om er zeker van te zijn dat de zending ook echt naar het gekozen adres verstuurd wordt. Om hier zeker van te zijn moet u het juiste aantal straat regels aanzetten en deze voorzien van duidelijke labels en validatie. U kunt <a href='%s' target='_blank'>hier</a> meer lezen over hoe u dit juist kunt configureren.
462
  Register the extension for use,Registreer de extensie voor gebruik
463
  Open the 'General Settings' tab and enter your email address.,Open het 'Algemene Instellingen' tabje en vul uw e-mailadres in.
464
+ Press the 'Activate the extension' button. You will now recieve an email at the address you specified containing 2 secure keys.,Klik op de 'Activeer de extensie' knop. U ontvangt nu twee beveiligingssleutels op het door u ingevulde e-mailadres.
465
  Copy the keys and enter them in the 'Unique-' and 'Private key' fields that are now available.,Kopieer de sleutels en vul deze in in de 'Unieke-' en 'Prive sleutel' velden die nu zichtbaar zullen zijn.
466
  Press the 'Finish activation' button.,Klik op de 'Rond activatie af' knop.
467
  Set the 'Active' field to 'Yes' and save the configuration. Your extension is now registered.,Zet het 'Actief' veld op 'Ja' en sla de configuratie op. De extensie is nu geregistreerd.
477
  "Configure your address settings, your confirming & label printing preferences and your preferred product options","Configureer nu uw adres instellingen, uw voormelden en labels printen voorkeuren, en uw product optie voorkeuren."
478
  "Go to the 'Address Settings' tab and configure this section based on which fields you use in your checkout process. If this does not precisely match your checkout process, orders may not be shipped to the correct address.",Ga nu naar het 'Adres Instellingen' tabje en configureer deze velden op basis van welke velden u gebruikt in uw afreken proces. Indien deze configuratie niet exact overeenkomt met de velden die u gebruikt in uw afrekenproces kan het voorkomen dat bestellingen naar het verkeerde adres verstuurd worden.
479
  Go to the 'Confirming & Label Printing Settings' tab and change your preferences. You may want to tweak these and then test them repeatedly before deciding on a final configuration.,Ga naar het 'Voormelden & Labels Printen Instellingen' tabje en pas uw voorkeuren aan. Het is verstandig om met deze instellingen te experimenteren en telkens te testen voordat u uw definitieve voorkeuren vastlegt.
480
+ "Go to the 'Product Options' tab and select your supported and preferred product options. If you have questions regarding each product option and which would be most suitable to you, please contact PostNL.","Ga naar het 'Product Opties' tabje en selecteer welke PostNL producten u ondersteunt en welke u als standaard wilt aanhouden. Indien u vragen heeft met betrekking tot de mogelijke product opties of als u niet zeker bent welke product opties het beste bij u passen, neem dan contact op met PostNL."
481
  Configure your GlobalPack settings,Configureer uw GlobalPack instellingen
482
  "If you wish to send orders to outside the EU, you need to configure your GlobalPack settings.",Indien u bestellingen wilt versturen naar buiten de EU moet u uw GlobalPack instellingen configureren.
483
  Go to the 'Account Settings' tab and fill in the 'Global Barcode Type' and 'Global Barcode Range' fields.,Ga naar het 'Account Instellingen' tabje en vul de 'Globaal barcode type' en 'Globaal barcode bereik' velden in.
484
  "Go to the 'GlobalPack Settings' tab and specify your preferences. Be aware, that if you do not configure these settings correctly, international shipments may be refused by either PostNL or the customs office.","Ga naar het 'GlobalPack Instellingen' tabje en vul uw voorkeuren in. Let op: als u deze instellingen niet correct configureerd, kan het voorkomen dat PostNL of de douane de zending weigert."
485
  Configure your PostNL Checkout settings,Configureer uw PostNL Checkout instellingen
486
+ "If you wish to use PostNL Checkout in your webshop, you need to configure your PostNl Checkout settings.",Indien u gebruik wilt maken van PostNL Checkout moet u uw PostNL Checkout instellingen configureren.
487
+ Go to the 'Account Settings' tab and fill in the 'Webshop ID' and 'Public Webshop ID' fields.,Ga naar het 'Account Instellingen' tabje en vul de 'Webshop ID' en 'Publieke webshop ID' velden in.
488
  Go to the 'PostNL Checkout' tab and specify your preferences.,Ga naar het 'PostNL Checkout' tabje en vul uw voorkeuren in.
489
  "Go to the 'PostNL Checkout Paymen Settings' tab and specify which payment methods PostNL Checkout supports. Here you must also link the PostNL Checkout payment methods to the payment methods you use in Magento. If you do not configure this properly, customers may be forced to pay with a different payment method than the one they selected.","Ga naar het 'PostNL Checkout Betalingsinstellingen' tabje en kies welke betaalmethode u wilt aanbieden in PostNL Checkout. Hier moet u ook iedere PostNL Checkout betaalmethode die u ondersteunt, koppelen aan een Magento betaalmethode. Als u dit niet goed instelt, kan het voorkomen dat een klant uiteindelijk met een andere betaalmethode moet afrekenen dan hij of zij heeft gekozen in PostNL Checkout."
490
  "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 PostNL 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 ondersteunt wordt, kunnen wij niet garanderen dat de PostNL extensie feilloos zal functioneren. Voor vragen kunt u contact op nemen met de Total Internet Group servicedesk."
532
  Invalid message type requested: %s,Ongeldig bericht type gekozen: %s
533
  Unable to read directory: %s,Kan folder niet lezen: %s
534
  Invalid UpdateOrder response: %s,Ongeldige UpdateOrder ontvangen: %s
535
+ "Here you can configure your PostNL account.</p><p>In order to use this extension you need to <a href='http://www.postnl.nl/zakelijk/e-commerce/flexibele-bezorgopties/contactformulier' target='_blank' title='Register'>register</a> yourself with PostNL. You will then receive all necessary information in order to configure the extension. If you cannot find the email containing this information, please contact your PostNL account manager.","Hier kunt u uw PostNL account gegevens invullen.</p><p>Voor het gebruik van de extensie dient u zich <a
536
+ href='http://www.postnl.nl/zakelijk/e-commerce/flexibele-bezorgopties/contactformulier' target='_blank'
537
  title='Aanmelden'>aan te melden</a> bij PostNL. U ontvangt vervolgens de benodigde gegevens voor uw instellingen. Indien u de e-mail die deze gegevens bevat niet meer kunt vinden, neem dan contact op met uw PostNL account manager."
538
  "You will find these settings in your <a href='https://checkout.postnl.nl/' target='_blank' title='PostNL'>PostNL Checkout account</a>.</p><p><a href='https://checkout.postnl.nl/' target='_blank' title='PostNL Checkout'>PostNL Checkout</a> is a free service, however you do need to <a href='https://checkout.postnl.nl/Consumer/Register?utm_source=magento&utm_medium=referral&utm_campaign=2014' target='_blank' title='Register'>register</a> yourself with PostNL. You will then receive all necessary information in order to configure this feature.","Deze gegevens vindt u in uw <a href='https://checkout.postnl.nl/' target='_blank' title='PostNL'>Checkout instellingen</a> bij PostNL.</p><p><a href='https://checkout.postnl.nl/' target='_blank' title='PostNL Checkout'>PostNL Checkout</a> is een gratis service, wel dient u zich <a href='https://checkout.postnl.nl/Consumer/Register?utm_source=magento&utm_medium=referral&utm_campaign=2014' target='_blank' title='Aanmelden'>aan te melden</a> bij PostNL. U ontvangt vervolgens de benodigde gegevens voor uw instellingen."
539
  ONLY CHANGE THESE SETTINGS WITH DIRECT INSTRUCTION FROM POSTNL OR TOTAL INTERNET GROUP,PAS DEZE INSTELLINGEN ENKEL AAN MET DIRECTE INSTRUCTIES VAN POSTNL OF TOTAL INTERNET GROUP
540
  "Customers who use this feature will subscribe to your webshop's newsletter, not PostNL's newsletter. Please note that 3rd party extensions that alter the Magento newsletter functionality may conflict with this feature.","Klanten die gebruik maken van deze feature zullen ingeschreven worden op de nieuwsbrief van uw webshop, niet op de nieuwsbrief van PostNL. Houd er rekenen mee dat extensies van derden die de Magento nieuwsbrief functionaliteit aanpassen mogelijk zullen conflicteren met deze feature."
541
  Doorcodes are often used in foreign addresses such as those used in France and Singapore.,Deurcodes worden veelal gebruikt in buitenlandse addressen zoals addressen uit Frankrijk en Singapore.
542
+ "Here you can enable or disable PostNL Checkout as well as completely customize all of it's facets.</p><p>By using PostNL Checkout you can offer your customers the option to easily choose their desired delivery date. They will be able to choose when and where they want their order delivered. They may choose to have the order delivered to their home (on a specific day at a specific time) or to have it delivered to their nearest post office.</p><p><a href='https://checkout.postnl.nl/' target='_blank' title='PostNL Checkout'>PostNL Checkout</a> is a free service, however you do need to <a href='https://checkout.postnl.nl/Consumer/Register?utm_source=magento&utm_medium=referral&utm_campaign=2014' target='_blank' title='Register'>register</a> yourself with PostNL. You will then receive all necessary information in order to configure this feature.","Hier kunt u PostNL Checkout activeren of deactiveren en alle onderdelen van PostNL Checkout configureren</p><p>Met de PostNL Checkout kunt u uw klanten tijdens hun bestelling eenvoudig de gewenste bezorging laten kiezen. Zijn kunnen dan zélf kiezen waar en wanneer zij hun bestelling willen ontvangen, bijv thuis (dagkeuze en tijdvak) of zelf ophalen op een Postkantoor.</p><p><a href='https://checkout.postnl.nl/' target='_blank' title='PostNL Checkout'>PostNL Checkout</a> is een gratis service, wel dient u zich <a
543
  href='https://checkout.postnl.nl/Consumer/Register?utm_source=magento&utm_medium=referral&utm_campaign=2014'
544
  target='_blank' title='Aanmelden'>aan te melden</a> bij PostNL. U ontvangt vervolgens de benodigde gegevens voor uw instellingen.
545
  "
573
  "If you are a contract customer of PostNL, you will have received an email containing this setting. If you cannot find this email, please contact PostNL support at 058-2333343","Als u een contractklant bent van PostNL heeft u een e-mail ontvangen met deze informatie. Indien u deze e-mail niet kan vinden, neem dan contact op met PostNL support op 058-2333343"
574
  Account settings have been succesfully validated. Please save this page to keep these settings.,De account instellingen zijn succesvol gevalideerd. Sla deze pagina op om deze instellingen te bewaren.
575
  One or more fields are missing. Please fill these fields and try again.,Eén of meerdere velden zijn niet ingevuld. Vul deze velden a.u.b. alsnog in en probeer het dan nog eens.
576
+ "Your account settings are incorrect. Please check all fields and try again. If this error persists, please contact PostNL.","De account instellingen zijn incorrect. Controleer alle velden a.u.b. zorgvuldig en probeer het dan nog eens. Als deze melding zich blijft voordoen, kunt u het beste contact opnemen met PostNL."
577
  "This will send a 'test' request to PostNL. If the above fields are not entered correctly, this will result in an error.","Dit zal een 'test' verzoek sturen naar PostNL. Indien bovenstaande velden niet correct ingevuld zijn, zal dit resulteren in een foutmelding."
578
  Validate account settings,Valideer account instellingen
579
  Unconfirmed,Niet Voorgemeld
583
  PostNL - Print Shipping Label,PostNL - Print Verzendlabel
584
  PostNL - Send Tracking Information,PostNL - Verstuur Track & Trace Informatie
585
  No status history available.,Geen status geschiedenis informatie beschikbaar.
586
+ Your webshop has been registered. Within a few minutes you will recieve an email at the emailaddress you specified. Please read this email carefully as it contains instructions on how to finish the extension activation procedure.,Uw webshop is geregistreerd. U ontvangt binnen enkele minuten een e-mail op het opgegeven e-mailadres. Lees deze e-mail s.v.p. aandachtig. Hierin staat aangegeven hoe u de activatieprocedure kunt afronden.
587
+ Confirmation Expired,Voormelding Verlopen
588
+ The PostNL Extension is currently configured in test mode.,De PostNL extensie is momenteel geconfigureerd in test modus.
589
+ "You can enter your live username and password in the 'Account Settings' tab. Don't forget to also update your customer number, customer code and BLS (location) code. You can then set the extension to live mode in the 'Confirming and Label Printing Settings' tab. If you use PostNL Checkout you also need to set PostNL Checkout to live mode in the 'PostNL Checkout Settings' tab.","U kunt uw live gebruikersnaam en wachtwoord invullen onder het 'Account Instellingen' tabje. Vergeet hier niet ook uw klantnummer, klantcode en BLS (locatie) code in te vullen. U kunt vervolgens de extensie op live modus zetten onder het 'Voormelden en Labels Printen Instellingen' tabje. Indien u gebruik maakt van PostNL Checkout dient u ook PostNL Checkout op live modus te zetten. Dit kunt u doen onder het 'PostNL Checkout Instellingen' tabje."
590
+ "You may test the extension, however you cannot send any shipments in this mode. Any shipments that you confirm or whose labels you print while in this mode will be registered as test shipments and may not be physically shipped. If you attempt to do so, you may incur fines from PostNL. To use the extension in live mode you first need to enter your PostNL account credentials and set the extension to live mode. You can then send shipments using the PostNL extension.","U kunt de extensie testen, maar u kunt geen zendingen versturen in test modus. Als u een zending voormeldt of de labels print van een zending terwijl de extensie in test modus staat, zullen deze zendingen gemarkeerd worden als test zendingen. Deze testzendingen kunt u niet versturen. Indien u deze wel verzendt, kunt u mogelijk boetes oplopen bij PostNL. Om de extensie in livemodus te gebruiken dient u eerst uw PostNL accountgegevens in te voeren en de configuratie op livemodus in te stellen. Vervolgens kunt u zendingen versturen met de PostNL extensie."
591
+ "You can enter your live username and password in the 'Account Settings' tab of the PostNL extension configuration. Don't forget to also update your customer number, customer code and BLS (location) code. You can then set the extension to live mode in the 'Confirming and Label Printing Settings' tab. If you use PostNL Checkout you also need to set PostNL Checkout to live mode in the 'PostNL Checkout Settings' tab.","U kunt uw live gebruikersnaam en wachtwoord invullen onder het 'Account Instellingen' tabje in het configuratiescherm van de PostNL extensie. Vergeet hier niet ook uw klantnummer, klantcode en BLS (locatie) code in te vullen. U kunt vervolgens de extensie op live modus zetten onder het 'Voormelden en Labels Printen Instellingen' tabje. Indien u gebruik maakt van PostNL Checkout dient u ook PostNL Checkout op live modus te zetten. Dit kunt u doen onder het 'PostNL Checkout Instellingen' tabje."
592
+ PostNL - Remove Shipping Label,PostNL - Verzendlabels Verwijderen
593
+ Are you sure that you wish to remove this shipment\'s shipping label? You will need to print a new shipping label before you can send this shipment.,Weet u zeker dat u het verzendlabel van deze zending wilt verwijderen? U zult een nieuw label moeten printen voor u de zending kunt versturen.
594
+ PostNL - Change Confirmation,PostNL - Voormelding Wijzigen
595
+ Are you sure that you wish to reset the confirmation status of this shipment? You will need to confirm this shipment with PostNL again before you can send it. This action will remove all barcodes and labels associated with this shipment. You can not undo this action.,Weet u zeker dat u de voormelding van deze zending wilt wijzigen? U zult deze zending opnieuw moeten voormelden alvorens u de zending kunt versturen. Deze actie zal alle verzendlabels en barcodes van deze zending verwijderen. U kunt deze actie niet ongedaan maken.
596
+ The shipment's shipping labels have been deleted.,De verzendlabels van deze zending zijn verwijderd.
597
+ The shipment's confirmation has been undone.,De voormelding van deze zending is ongedaan gemaakt.
598
+ "By default the extension is pre-configured using a test account. If you already have your PostNL account credentials, you can enter them using the steps below. If you have not yet received these credentials you may keep using the extensions in test mode. In this case you can continue to step 3.","De extensie is standaard voorgeconfigureerd met een PostNL test account. Indien u al uw PostNL account gegevens hebt ontvangen, kunt u deze invullen volgens de onderstaande stappen. Indien u deze gegevens nog niet heeft ontvangen, kunt u de extensie blijven gebruiken in test modus. In dit geval kunt u door gaan naar stap 3."
package.xml CHANGED
@@ -1,7 +1,7 @@
1
  <?xml version="1.0"?>
2
  <package>
3
  <name>tig_postnl</name>
4
- <version>1.1.3</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>
@@ -20,73 +20,94 @@ Services included:&#xD;
20
  - Viewing detailed shipping status information&#xD;
21
  - PostNL Checkout&#xD;
22
  - Emailing customers track &amp; trace information, allowing them to track their shipment from the moment you confirm it to the moment it arrives at their doorstep</description>
23
- <notes>v1.1.3&#xD;
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
24
  &#xD;
25
  - FIxed an issue with the extension's activation procedure.&#xD;
26
  &#xD;
27
- v1.1.2&#xD;
28
  &#xD;
29
  - Updated manual.&#xD;
30
  &#xD;
31
- v1.1.1&#xD;
32
  &#xD;
33
  - Fixed issue where filtering the first column of the shipment grid could cause errors.&#xD;
34
  - Removed PHP extension dependencies from the PostNL extension packages. Magento connect would sometimes falsely report a PHP extension as missing preventing the PostNL extension from being installed.&#xD;
35
  &#xD;
36
- v1.1.0&#xD;
37
  &#xD;
38
  - First public release.&#xD;
39
  &#xD;
40
- v1.0.8&#xD;
41
  &#xD;
42
  - Improved compatibility with Magento 1.6 and 1.11.&#xD;
43
  &#xD;
44
- v1.0.7&#xD;
45
  &#xD;
46
  - Improved configuration fields.&#xD;
47
  - Improved translations.&#xD;
48
  &#xD;
49
- v1.0.6&#xD;
50
  &#xD;
51
  - Improved shipment grid interface. It shoulod now be more clear which shipments have been confirmed and when they should be handed over to PostNL.&#xD;
52
  - Improved PostNL Checkout payment method handling. The Checkout summary page should now remember your chosen bank when you attempt to pay using iDEAL. 100% support for all payment methods is not guaranteed.&#xD;
53
  &#xD;
54
- v1.0.5&#xD;
55
  &#xD;
56
  - Several bug fixes.&#xD;
57
  - Improved configuration interface.&#xD;
58
  &#xD;
59
- v1.0.4&#xD;
60
  &#xD;
61
  - Several minor bug fixes.&#xD;
62
  - Improved Dutch translations.&#xD;
63
  - Added additional information to several fields in system/config.&#xD;
64
  &#xD;
65
- v1.0.3&#xD;
66
  &#xD;
67
  - Several bug fixes. Including an issue preventing the extension from functioning properly with the compiler active.&#xD;
68
  - Several improvements to the Dutch translations.&#xD;
69
  - Improved the extension's system &gt; config interface&#xD;
70
  - Added the Klarna payment method to PostNL Checkout&#xD;
71
  &#xD;
72
- v1.0.2&#xD;
73
  &#xD;
74
  - A large number of bug fixes and general improvements&#xD;
75
  - Improved error handling. Almost all errors will now automatically provide you with a link where you can find more information and a possible solution.&#xD;
76
  &#xD;
77
- v1.0.1&#xD;
78
  &#xD;
79
  - Added a filter to the possible product options you may select, based on the selected orders when mass-creating shipments from the order grid.&#xD;
80
  - Improved several translations.&#xD;
81
  - Fixed several minor bugs.&#xD;
82
  &#xD;
83
- v1.0.0&#xD;
84
  &#xD;
85
  This is the initial beta release of the extension. If you have any questions, please contact the Total Internet Group Servicedesk</notes>
86
  <authors><author><name>TiG</name><user>supporttotal</user><email>servicedesk@totalinternetgroup.nl</email></author></authors>
87
- <date>2014-02-13</date>
88
- <time>15:25:07</time>
89
- <contents><target name="magecommunity"><dir name="TIG"><dir name="PostNL"><dir name="Block"><dir name="Adminhtml"><file name="CronNotification.php" hash="ec6263ed9fca94273bbc5d5493cac0ce"/><dir name="Sales"><dir name="Order"><file name="ProductOptions.php" hash="f46f9e9ba1a37ceff2db6d3131a21ebb"/><dir name="Shipment"><dir name="Create"><file name="ShipmentOptions.php" hash="6a63d89143a8b310f93ef73385f3eda0"/></dir><dir name="View"><file name="ShippingStatus.php" hash="297af21cb49e6b2cdfee192dfbf5f239"/><dir name="Tab"><file name="StatusHistory.php" hash="7b6bd52216822f7dc71fc998e8056376"/></dir><file name="Tabs.php" hash="a213c367f78e84fafd05d9d6310db5f5"/></dir></dir></dir></dir><dir name="System"><dir name="Config"><dir name="Form"><dir name="Field"><file name="ActivateButton.php" hash="2f57922bb9347b0b9d21a1a82529ffb4"/><file name="ActivatedFieldHeader.php" hash="4af748c827c108c2d72f12d1e9de0681"/><file name="ConfigCheck.php" hash="e967c3a4782fbb2ba4accef38a8a2373"/><file name="InfoBox.php" hash="4b93fd3c1e44230c4d8c3fb93ec581f3"/><file name="SplitAddressCheck.php" hash="cc8509b1f1fee9d825980382dc0833c2"/><file name="SupportTab.php" hash="e34f2bf7e87060698e0560894319b3b0"/><dir name="TextBox"><file name="Abstract.php" hash="423c2b84db587309a8a6d90dabc4de4f"/></dir><file name="ValidateButton.php" hash="5a30e6615a96e05cf3600855c15544de"/><file name="WarningBox.php" hash="36dce34841f2252f466e78dc2eddf1ba"/></dir><file name="Fieldset.php" hash="1bc60b1e6644802198c62666b50d3acf"/></dir><file name="Form.php" hash="a4fe68b2216fdccafb1bfecfa3f8e1a1"/></dir></dir><dir name="Widget"><dir name="Grid"><dir name="Column"><dir name="Renderer"><file name="Action.php" hash="9fc6e2f204f2238ab29699b614589134"/><file name="Barcode.php" hash="74858ac29b17c675cb2d8f55b8cba3fc"/><file name="ConfirmDate.php" hash="3d6692b46faaeedf55ab74e4b239790f"/><file name="ConfirmStatus.php" hash="db96b519fa025bb9f5f5737bb0e80bf2"/><file name="ShipmentType.php" hash="2a817a37ab1ccdc8a7e836f0443d012f"/><file name="ShippingPhase.php" hash="9ee0fc92ee2cc623edb3df86247d2d06"/><file name="Time.php" hash="dbf5b70742e0877eff7f01ec65319e3b"/><file name="Translate.php" hash="46d83e4013d6ab1d14d39f303703e5c4"/><file name="YesNo.php" hash="1bdb10008eecb146fd185040e24d48e5"/></dir></dir></dir></dir></dir><dir name="Checkout"><dir name="Cart"><file name="CheckoutLink.php" hash="b0c3e048cfcbb6d91000ab4df4b502cc"/><file name="Js.php" hash="acb7f5ad743ca311153b639f6ea33c75"/></dir><dir name="Summary"><file name="Totals.php" hash="bbe4ec0aaf15ecc40bff8504d67aa1e4"/></dir><file name="Summary.php" hash="a2b997d74cee541fd570327a496e30fb"/></dir><dir name="Core"><file name="ShippingStatus.php" hash="c92beeec25228692afcc2f64ed44dd01"/></dir></dir><file name="Exception.php" hash="5b9f750676440653abfee244727aa29f"/><dir name="Helper"><file name="Carrier.php" hash="9625f891a86da6b84c4bdf5f1ff37597"/><file name="Checkout.php" hash="cf0907c1d9601c137c2fd8b3c1d3487d"/><file name="Cif.php" hash="0285a984fe853a189081a4aa9e4db057"/><file name="Data.php" hash="64255e95c4ff036ce3ab692a9f6913c3"/><file name="Webservices.php" hash="0cc54fac78af257b2740d9519e9570d3"/></dir><dir name="Model"><dir name="Adminhtml"><dir name="Observer"><file name="OrderGrid.php" hash="bd693cf00644091cf5bedf31d6447f14"/><file name="ShipmentGrid.php" hash="4096699dc53864b85806a07fbc0f6d7a"/><file name="ShipmentView.php" hash="d9d86d31fdc9ca1126ba3296054db733"/></dir><dir name="System"><dir name="Config"><dir name="Source"><file name="ShipmentGridColumns.php" hash="fec7db9a0c5ba79c6a0987ddec42e4cc"/></dir></dir></dir></dir><dir name="Carrier"><file name="Postnl.php" hash="4555895c5ec8d0b0f7a4d259ac1dc818"/><dir name="System"><dir name="Config"><dir name="Source"><file name="RateType.php" hash="940bf2381b879188d6e4aa756d0d0dce"/></dir></dir></dir></dir><dir name="Checkout"><file name="Cif.php" hash="9ab1f1c983f5b3ba41a9019e723ec1c3"/><dir name="Observer"><file name="Order.php" hash="5cf7b700b2286a6916f23e72e3346beb"/><file name="Shipment.php" hash="217a3bf9d730f1061e9d3117edc6c2a3"/></dir><file name="Order.php" hash="619b8f385b29357449644def665f58c0"/><dir name="Resource"><dir name="Order"><file name="Collection.php" hash="fe0751975beca120d547a2a6db7eb9a8"/></dir><file name="Order.php" hash="d821477695f495031b62eb85b383f981"/></dir><file name="Service.php" hash="6ff1b8c9d595b14059c6422c3472c90a"/><dir name="System"><dir name="Config"><dir name="Source"><file name="ActivePaymentMethods.php" hash="7e9ff249f3ca3ca28e8e4831e2a9b4cb"/><file name="CmsPage.php" hash="0ed3351761c49cad9f3611704f61aa5e"/></dir></dir></dir></dir><dir name="Core"><dir name="Cif"><file name="Abstract.php" hash="e85f0bd137fcc02c01c47995cb03325d"/><file name="Exception.php" hash="c448a27c6ecd9c2886344f13c9e58ac1"/></dir><file name="Cif.php" hash="0bc0de043cb254dd20b17759d8fb2484"/><file name="Label.php" hash="cc3b3f254fcf2708234b8ef2a7b6e4e3"/><dir name="Observer"><file name="Barcode.php" hash="49eb5448e784f9d2d2a74bb317002b95"/><file name="Cron.php" hash="43b912ce1cf5a152b39f9c0fb0b25813"/><file name="SaveShipment.php" hash="ea2a8ee51d856075e9beec7e5c71dbf0"/></dir><dir name="Resource"><dir name="Shipment"><dir name="Barcode"><file name="Collection.php" hash="cba086559e46ab05eb745820cb674940"/></dir><file name="Barcode.php" hash="3fababe4d418342d5b69a153bd366017"/><file name="Collection.php" hash="f2dab6fa63764c98a2ab06871f68fefe"/><dir name="Label"><file name="Collection.php" hash="178f85ee761975231fc5d8a51c6ae466"/></dir><file name="Label.php" hash="c73b399ac5562259d0f1fd142be9fee0"/><dir name="Status"><dir name="History"><file name="Collection.php" hash="07cdf9dd45423e5d315e31b2dd7f951a"/></dir><file name="History.php" hash="cf483a122ebc9aca139a13bcb730e85c"/></dir></dir><file name="Shipment.php" hash="221e5c5728908f15d7558f8e6fe1103e"/></dir><dir name="Shipment"><file name="Barcode.php" hash="89aa40330448be2ceb79d052e1aa6e9b"/><file name="Label.php" hash="791fb2ff0dc51e5a72c2982c01bd9f9d"/><file name="Process.php" hash="6503c1ef414556459c732125fbc054f9"/><dir name="Status"><file name="History.php" hash="bc1e67b513e58e6373d122eb6b1e5eea"/></dir></dir><file name="Shipment.php" hash="28c0629ca659d4585c6d5569ea73419b"/><dir name="System"><dir name="Config"><dir name="Source"><file name="AllProductOptions.php" hash="925712e7f23305aa080849911b5be057"/><file name="Attributes.php" hash="a8384fbf1524c432f7b087dad9a7c813"/><file name="DebugMode.php" hash="0bbcbc4f0c771723b2031eb95dc7ca13"/><file name="Direction.php" hash="a93d5436ed8e231261217af00b799c92"/><file name="EuProductOptions.php" hash="ddf1c4a3ab7b1215a2b7163a474c6008"/><file name="GlobalProductOptions.php" hash="5f211b4b8d96a9b7d34d1960c142a43d"/><file name="LabelSize.php" hash="88e3cf3ca607dca603e4b5b42a563912"/><file name="PakjeGemakProductOptions.php" hash="12d97c5b30c2d587fb6e8ce078a6b582"/><file name="ReferenceType.php" hash="559bfab1b5fc1ff7b42eed0a3654708a"/><file name="ShipmentGridMassaction.php" hash="77b9b2c30aa82eea994faade8add6714"/><file name="StandardProductOptions.php" hash="9ebac04faa76287a1c349bf97c5c3b6d"/><file name="StreetField.php" hash="eb5c59b91a92c64189f239469a8472bb"/><file name="StreetFieldWithDefault.php" hash="336dbc8571b59d5d1970d5a13efa5954"/><file name="WeightUnit.php" hash="b3f1ccc564b64f8874e5b3dfd4a2e456"/></dir></dir></dir></dir><dir name="ExtensionControl"><file name="Feed.php" hash="edf1fa5590f6f39bf5082a20e20a8408"/><dir name="Observer"><file name="Cron.php" hash="0e38a6072f2ecc2423ac360a3eb4d5d8"/></dir><dir name="Webservices"><file name="Abstract.php" hash="35bb7474364056366434734b42536a47"/></dir><file name="Webservices.php" hash="708433a4f84fe645c482bebb256e0ea8"/></dir><file name="Inbox.php" hash="9e3067d0e9b3137e33bcc99eea829a22"/><dir name="Resource"><dir name="Db"><dir name="Collection"><file name="Postnl.php" hash="a337c73f47df77a3de420ad13198dcfa"/></dir></dir><dir name="Order"><dir name="Grid"><file name="Collection.php" hash="6cd139d824f9fba6ec6205f0a9aed54e"/></dir><dir name="Shipment"><dir name="Grid"><file name="Collection.php" hash="abaf6d8cdd36d96778a8341afd01a48e"/></dir></dir></dir><file name="Setup.php" hash="761f73bb791e54b5d8b3c47ee73ac81f"/></dir><dir name="System"><dir name="Config"><dir name="Source"><file name="Testlive.php" hash="ba607caaa1e297cb91f20a840daa3ea8"/></dir></dir></dir></dir><dir name="controllers"><dir name="Adminhtml"><file name="ConfigController.php" hash="b85e4c509d62378cca7dcb6235971250"/><file name="ExtensionControlController.php" hash="73b172250955a15b531ff9fb43fdc003"/><file name="ShipmentController.php" hash="10456dfb49ac9732163215ef6d06608e"/></dir><file name="CheckoutController.php" hash="4ca43ba622a2e0cbc9a1459b43bd6687"/></dir><dir name="data"><dir name="postnl_setup"><file name="data-install-1.0.0.php" hash="5d24b54be571e8c1ee6e7a74afe99113"/><file name="data-install-1.0.3.php" hash="b42e23def5a1d5f2759e069b70e0b617"/></dir></dir><dir name="etc"><file name="adminhtml.xml" hash="8686744c313445cf0a79087b63ab31db"/><file name="config.xml" hash="c7bdd580d83f99263dfcf5a8ecb925d8"/><file name="system.xml" hash="3225afbcb250f60763791732b8f88687"/></dir><dir name="sql"><dir name="postnl_setup"><file name="install-1.0.0.php" hash="97b8584781e5e7cf6abe204387578fa0"/></dir></dir></dir></dir></target><target name="magedesign"><dir name="frontend"><dir name="base"><dir name="default"><dir name="layout"><dir name="TIG"><file name="postnl.xml" hash="ec012e0f62047ecfcd40db5e28fb717b"/></dir></dir><dir name="template"><dir name="TIG"><dir name="PostNL"><dir name="checkout"><dir name="cart"><file name="js.phtml" hash="d3a53229d6838ab254a5749dcb475a21"/><file name="link.phtml" hash="9f783975ca668d2a2dbb6ee4d9d6f9be"/><file name="spinner.phtml" hash="0f66e5018bb120753e349c9206deac3b"/></dir><dir name="summary"><file name="totals.phtml" hash="05be26ff83cb33b0af5231b07e7bbe10"/></dir><file name="summary.phtml" hash="d6dc6f0614868e4f9f3fee48473c95d3"/></dir><dir name="sales"><dir name="order"><dir name="shipment"><file name="shipping_status.phtml" hash="02e80c01ca12ac4bd3040ca5f7916c47"/></dir></dir></dir></dir></dir></dir></dir></dir></dir><dir name="adminhtml"><dir name="default"><dir name="default"><dir name="layout"><dir name="TIG"><file name="postnl.xml" hash="34a22f8d10063eef27959da796d0c822"/></dir></dir><dir name="template"><dir name="TIG"><dir name="PostNL"><file name="cron_notification.phtml" hash="aa24f6b3473640c44f47a0f49081fc59"/><dir name="sales"><dir name="order"><file name="filter_massaction.phtml" hash="92c5c6ad1a8b4fcbd5cd3b955c12c6ec"/><file name="product_options.phtml" hash="7635dff53db6ad6d6f43e0bb96804f65"/><dir name="shipment"><dir name="create"><file name="shipment_options.phtml" hash="5027b8f14937190623f6b6febbe167dd"/></dir><dir name="view"><file name="shipping_status.phtml" hash="704b07c07c84783d9342f54d2789e3e9"/><dir name="tab"><file name="status_history.phtml" hash="2e64eb69b6e3dc90713d41496dcdd642"/></dir></dir><file name="view.phtml" hash="c767d27a2b1fa0bae476eaa3cb879f47"/></dir></dir></dir><dir name="system"><dir name="config"><dir name="form"><dir name="field"><file name="config_check.phtml" hash="95e18888da58a4a8b7ad307d522c0f2e"/><file name="field_header.phtml" hash="806634be75eea5a462ec8df61e0acaee"/><file name="info_box.phtml" hash="da355f0ea45558343880ed5ae54c3b1c"/><file name="js.phtml" hash="52b17b09fcd7777c506ec7f4a9703dd4"/><file name="split_address_check.phtml" hash="d9bf074af0f6b7dafb235008fc908312"/><file name="support_tab.phtml" hash="74671dbfd89f32aeddf06372e493eda0"/><file name="warning_box.phtml" hash="344231e59acd6740f4ad5df742a16a4a"/></dir></dir></dir></dir></dir></dir></dir></dir></dir></dir></target><target name="mageetc"><dir name="modules"><file name="TIG_PostNL.xml" hash="4868726d0f27d7d2c11fd6c2a5deb22d"/></dir></target><target name="mageskin"><dir name="frontend"><dir name="base"><dir name="default"><dir name="css"><dir name="TIG"><dir name="PostNL"><file name="cart.css" hash="3e0ba5de132ddfac90f0e7bb834f4361"/><file name="messages.css" hash="19d03101c862b45535bc08344c12716a"/><file name="shipping_status.css" hash="0162a5c3dcd72eb01a8b4c6bb0ee075d"/></dir></dir></dir><dir name="images"><dir name="TIG"><dir name="PostNL"><file name="bkg_progress_small.png" hash="fc6c9f28b6a6aae6f0096d504c0952df"/><file name="overlay.png" hash="f08feb852288bea420ba3af68ae34a1f"/><file name="postnl_email_logo.png" hash="8bd358b514e04e7ceca03efb38f8fded"/><file name="postnl_spinner.gif" hash="cef321b68ab934932ee317986823db67"/></dir></dir></dir></dir></dir><dir name="enterprise"><dir name="default"><dir name="images"><dir name="TIG"><dir name="PostNL"><file name="overlay.png" hash="f08feb852288bea420ba3af68ae34a1f"/><file name="postnl_spinner.gif" hash="c97d0bd9ccc8fa0b460c07caeb63c293"/></dir></dir></dir><dir name="css"><dir name="TIG"><dir name="PostNL"><file name="cart.css" hash="4f8b417defed03e6ae8c4ec292b2e2c3"/></dir></dir></dir></dir></dir></dir><dir name="adminhtml"><dir name="default"><dir name="default"><dir name="css"><dir name="TIG"><dir name="PostNL"><file name="messages.css" hash="19d03101c862b45535bc08344c12716a"/><file name="shipping_status.css" hash="46f19403af66e08fe5182bac5a6a20fe"/><file name="system_config_edit.css" hash="b4c897ee8801ed42f6c83754fb2abb08"/><file name="system_config_edit_postnl.css" hash="acc03eb19a74a4f5995fc0736642fc4f"/></dir></dir></dir><dir name="images"><dir name="TIG"><dir name="PostNL"><file name="bkg_progress_grey.png" hash="8d4d5144292b98a23475367ede717b17"/><file name="bkg_progress_grey_begin.png" hash="6815c9264e78f8f9d2805c595f8800c4"/><file name="bkg_progress_grey_end.png" hash="dae90fdb38adf65e6ccc209b6a80372c"/><file name="bkg_progress_grey_seperator.png" hash="10178e12fd14fb783b4ae0fbd55a4a81"/><file name="bkg_progress_orange.png" hash="8a59f76e36ee0492f5341b8e5e7ee79b"/><file name="bkg_progress_orange_begin.png" hash="ecc84d5252e397f4a783ee7e0c426d63"/><file name="bkg_progress_orange_end.png" hash="d0a81dfea1a3eddc699482a62af01fc9"/><file name="bkg_progress_orange_grey_seperator.png" hash="ab558953ec4c40ef44653ab481084345"/><file name="bkg_progress_orange_seperator.png" hash="a774eb89763d95f2e60d03f8702fba86"/><file name="bkg_progress_sprite.png" hash="3230379a4544f85062a6ba91fa8083e2"/><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="legend.gif" hash="d8fb0642901868d489d31b426f3e3406"/><file name="logo_postnl.png" hash="10b9ae4ad2c5365312c257dcdac1fc64"/><file name="tig_logo_medium.gif" hash="3e1071908cfdb7b472438482c3331ac7"/></dir></dir></dir><dir name="js"><dir name="TIG"><dir name="PostNL"><file name="shipment_options.js" hash="35383a85422ca0c2b740f438b62c250e"/><file name="validate.js" hash="a5cf42de4e12a96eafc67796c0fd9fe2"/></dir></dir></dir><dir name="media"><dir name="TIG"><dir name="PostNL"><file name="manual.pdf" hash="699b26571bb20f05d8c523138fc25129"/></dir></dir></dir></dir></dir></dir></target><target name="magelib"><dir name="TIG"><dir name="PostNL"><dir name="Fpdf"><dir name="font"><file name="courier.php" hash="ca6fb483549604fb4a675f9e28a73b02"/><file name="courierb.php" hash="a58d7dadf3cf564ca5d5138cea76a3a9"/><file name="courierbi.php" hash="c0e416771dc56cb2397390978d112dc2"/><file name="courieri.php" hash="419961dbeeb20f08da780dccb427dec8"/><file name="helvetica.php" hash="fc53162b924ddd522bd6cfe86fab48f4"/><file name="helveticab.php" hash="4e9ffda682a131fef2e04ccd94aa342d"/><file name="helveticabi.php" hash="6db8943bd91bf13514b82872cf160d45"/><file name="helveticai.php" hash="13b795df0c33eb93c48621792f2ea12d"/><file name="symbol.php" hash="fbd9250c21af99f6398d6f817511f91f"/><file name="times.php" hash="82bc100f1f3bd8b2d9b7fb5ee8f44b3a"/><file name="timesb.php" hash="3a241a1658bf9ea2062e63f464166c31"/><file name="timesbi.php" hash="bfdd0235a71793becefff778c2b16243"/><file name="timesi.php" hash="17fd69f176915a2113fe28057b43a75e"/><file name="zapfdingbats.php" hash="2848ab2daf3128f310b5cf713ca4acee"/></dir><file name="fpdf.css" hash="84befac49464a9aac54aa511bc1fd754"/><file name="fpdf.php" hash="f9228af7ef1c18691cba2ad075bc5858"/><file name="helvetica.php" hash="fc53162b924ddd522bd6cfe86fab48f4"/><file name="license.txt" hash="fb784726cfe3615da38bc23a3cac445b"/></dir><file name="Fpdf.php" hash="a0d54e6259621bb9d4c4801c53740340"/><dir name="Fpdi"><dir name="filters"><file name="FilterASCII85.php" hash="fe706bbd320881c300ec1a9f71e4eb2b"/><file name="FilterASCII85_FPDI.php" hash="1240e0c64602864401f886546e09fe7b"/><file name="FilterLZW.php" hash="35644f48b6b65c8726fc71cfad6c0478"/><file name="FilterLZW_FPDI.php" hash="b11c50e66e20744ad20f176cae4af284"/></dir><file name="fpdf_tpl.php" hash="3966b13c398c94509e2fb6199593b104"/><file name="fpdi.php" hash="abb524d17a2cbdd3c3b7e89184aad443"/><file name="fpdi2tcpdf_bridge.php" hash="8cc7fc486b015f1e17e75d1e5d585902"/><file name="fpdi_pdf_parser.php" hash="d7a3bf0153ae9ad57976afb0be5d195d"/><file name="pdf_context.php" hash="0b69a25dbb830f3b68c054c2e43b876e"/><file name="pdf_parser.php" hash="5ff22a8c1ce5b1eee82c8017311a797e"/></dir><file name="Fpdi.php" hash="fdf663915f3930bc0dc00db46cc20944"/></dir></dir></target><target name="magelocale"><dir name="en_US"><dir name="template"><dir name="email"><dir name="TIG"><dir name="PostNL"><file name="track_and_trace.html" hash="7ace8a754b0ea35775e0a3b66ad96b19"/></dir></dir></dir></dir><file name="TIG_PostNL.csv" hash="67bc681837594087cd55e67e763d8f89"/></dir><dir name="nl_NL"><dir name="template"><dir name="email"><dir name="TIG"><dir name="PostNL"><file name="track_and_trace.html" hash="122c60807ec59834e3445fe40540e8c9"/></dir></dir></dir></dir><file name="TIG_PostNL.csv" hash="8b874b5742146a4411228012d8ebdaad"/></dir></target></contents>
90
  <compatible/>
91
  <dependencies><required><php><min>5.3.0</min><max>6.0.0</max></php></required></dependencies>
92
  </package>
1
  <?xml version="1.0"?>
2
  <package>
3
  <name>tig_postnl</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>
20
  - Viewing detailed shipping status information&#xD;
21
  - PostNL Checkout&#xD;
22
  - Emailing customers track &amp; trace information, allowing them to track their shipment from the moment you confirm it to the moment it arrives at their doorstep</description>
23
+ <notes>==== v1.1.4 =====&#xD;
24
+ &#xD;
25
+ ==== New features ====&#xD;
26
+ - Added a default test account to the extension. New installation will automatically have a PostNL test account pre-configured.&#xD;
27
+ - Added the option to undo a confirmation as long as the shipment has not been received by PostNL.&#xD;
28
+ - Added the option to delete shipping labels. This allows you to correct an address after a shipping label has been printed. Before this change if you noticed an error in the address after you had already printed a shipping label, you had to place en entire new order to correct it. Now you can simply delete the shipping label, edit the address and print a new shipping label with the new address.&#xD;
29
+ &#xD;
30
+ ==== Minor change ====&#xD;
31
+ - The validate settings button in the extension&#x2019;s configuration page now also validates settings while the extension is set to test mode.&#xD;
32
+ - Removed the 'EU Pack Standard (Belgium only, no signature)' product option. If you use this option, please contact the Total Internet Group servicedesk.&#xD;
33
+ - The extension's test mode is now available by default. In earlier versions you had to allow test mode through a setting under advanced options.&#xD;
34
+ - When a confirmation expires, the barcode's track &amp; trace link will now also be removed.&#xD;
35
+ - Improved various texts and translations.&#xD;
36
+ &#xD;
37
+ ==== Bug fixes ====&#xD;
38
+ - Solved an issue where certain configurations of the PostNL shipping method would only appear if the Magento tablerates shipping method was also active.&#xD;
39
+ - Solved an issue where filtering the order and shipment grids in the Magento backend on certain columns would cause an error.&#xD;
40
+ - Solved an issue where the shipment status cron would stop as soon as it encountered an error, rather than continue processing the remaining shipments.&#xD;
41
+ - Solved an issue where you could not confirm a shipment without a barcode due to process locking when developer mode is active.&#xD;
42
+ - Solved issue in Safari where labels would be printed as .pdf.html, rather than just .pdf files.&#xD;
43
+ &#xD;
44
+ ==== v1.1.3 ====&#xD;
45
  &#xD;
46
  - FIxed an issue with the extension's activation procedure.&#xD;
47
  &#xD;
48
+ ==== v1.1.2 ====&#xD;
49
  &#xD;
50
  - Updated manual.&#xD;
51
  &#xD;
52
+ ==== v1.1.1 ====&#xD;
53
  &#xD;
54
  - Fixed issue where filtering the first column of the shipment grid could cause errors.&#xD;
55
  - Removed PHP extension dependencies from the PostNL extension packages. Magento connect would sometimes falsely report a PHP extension as missing preventing the PostNL extension from being installed.&#xD;
56
  &#xD;
57
+ ==== v1.1.0 ====&#xD;
58
  &#xD;
59
  - First public release.&#xD;
60
  &#xD;
61
+ ==== v1.0.8 ====&#xD;
62
  &#xD;
63
  - Improved compatibility with Magento 1.6 and 1.11.&#xD;
64
  &#xD;
65
+ ==== v1.0.7 ====&#xD;
66
  &#xD;
67
  - Improved configuration fields.&#xD;
68
  - Improved translations.&#xD;
69
  &#xD;
70
+ ==== v1.0.6 ====&#xD;
71
  &#xD;
72
  - Improved shipment grid interface. It shoulod now be more clear which shipments have been confirmed and when they should be handed over to PostNL.&#xD;
73
  - Improved PostNL Checkout payment method handling. The Checkout summary page should now remember your chosen bank when you attempt to pay using iDEAL. 100% support for all payment methods is not guaranteed.&#xD;
74
  &#xD;
75
+ ==== v1.0.5 ====&#xD;
76
  &#xD;
77
  - Several bug fixes.&#xD;
78
  - Improved configuration interface.&#xD;
79
  &#xD;
80
+ ==== v1.0.4 ====&#xD;
81
  &#xD;
82
  - Several minor bug fixes.&#xD;
83
  - Improved Dutch translations.&#xD;
84
  - Added additional information to several fields in system/config.&#xD;
85
  &#xD;
86
+ ==== v1.0.3 ====&#xD;
87
  &#xD;
88
  - Several bug fixes. Including an issue preventing the extension from functioning properly with the compiler active.&#xD;
89
  - Several improvements to the Dutch translations.&#xD;
90
  - Improved the extension's system &gt; config interface&#xD;
91
  - Added the Klarna payment method to PostNL Checkout&#xD;
92
  &#xD;
93
+ ==== v1.0.2 ====&#xD;
94
  &#xD;
95
  - A large number of bug fixes and general improvements&#xD;
96
  - Improved error handling. Almost all errors will now automatically provide you with a link where you can find more information and a possible solution.&#xD;
97
  &#xD;
98
+ ==== v1.0.1 ====&#xD;
99
  &#xD;
100
  - Added a filter to the possible product options you may select, based on the selected orders when mass-creating shipments from the order grid.&#xD;
101
  - Improved several translations.&#xD;
102
  - Fixed several minor bugs.&#xD;
103
  &#xD;
104
+ ==== v1.0.0 ====&#xD;
105
  &#xD;
106
  This is the initial beta release of the extension. If you have any questions, please contact the Total Internet Group Servicedesk</notes>
107
  <authors><author><name>TiG</name><user>supporttotal</user><email>servicedesk@totalinternetgroup.nl</email></author></authors>
108
+ <date>2014-03-31</date>
109
+ <time>14:18:28</time>
110
+ <contents><target name="magecommunity"><dir name="TIG"><dir name="PostNL"><dir name="Block"><dir name="Adminhtml"><file name="CronNotification.php" hash="ec6263ed9fca94273bbc5d5493cac0ce"/><dir name="Sales"><dir name="Order"><file name="ProductOptions.php" hash="f46f9e9ba1a37ceff2db6d3131a21ebb"/><dir name="Shipment"><dir name="Create"><file name="ShipmentOptions.php" hash="6a63d89143a8b310f93ef73385f3eda0"/></dir><dir name="View"><file name="ShippingStatus.php" hash="297af21cb49e6b2cdfee192dfbf5f239"/><dir name="Tab"><file name="StatusHistory.php" hash="7b6bd52216822f7dc71fc998e8056376"/></dir><file name="Tabs.php" hash="a213c367f78e84fafd05d9d6310db5f5"/></dir></dir></dir></dir><dir name="System"><dir name="Config"><dir name="Form"><dir name="Field"><file name="ActivateButton.php" hash="2f57922bb9347b0b9d21a1a82529ffb4"/><file name="ActivatedFieldHeader.php" hash="4af748c827c108c2d72f12d1e9de0681"/><file name="ConfigCheck.php" hash="37dab6f23c95abb7d3b65fc4a5a89a00"/><file name="InfoBox.php" hash="4b93fd3c1e44230c4d8c3fb93ec581f3"/><file name="SplitAddressCheck.php" hash="cc8509b1f1fee9d825980382dc0833c2"/><file name="SupportTab.php" hash="e34f2bf7e87060698e0560894319b3b0"/><dir name="TextBox"><file name="Abstract.php" hash="423c2b84db587309a8a6d90dabc4de4f"/></dir><file name="ValidateButton.php" hash="5a30e6615a96e05cf3600855c15544de"/><file name="WarningBox.php" hash="36dce34841f2252f466e78dc2eddf1ba"/></dir><file name="Fieldset.php" hash="1bc60b1e6644802198c62666b50d3acf"/></dir><file name="Form.php" hash="a4fe68b2216fdccafb1bfecfa3f8e1a1"/></dir></dir><dir name="Widget"><dir name="Grid"><dir name="Column"><dir name="Renderer"><file name="Action.php" hash="9fc6e2f204f2238ab29699b614589134"/><file name="Barcode.php" hash="74858ac29b17c675cb2d8f55b8cba3fc"/><file name="ConfirmDate.php" hash="3d6692b46faaeedf55ab74e4b239790f"/><file name="ConfirmStatus.php" hash="db96b519fa025bb9f5f5737bb0e80bf2"/><file name="ShipmentType.php" hash="2a817a37ab1ccdc8a7e836f0443d012f"/><file name="ShippingPhase.php" hash="9ee0fc92ee2cc623edb3df86247d2d06"/><file name="Time.php" hash="dbf5b70742e0877eff7f01ec65319e3b"/><file name="Translate.php" hash="46d83e4013d6ab1d14d39f303703e5c4"/><file name="YesNo.php" hash="1bdb10008eecb146fd185040e24d48e5"/></dir></dir></dir></dir></dir><dir name="Checkout"><dir name="Cart"><file name="CheckoutLink.php" hash="b0c3e048cfcbb6d91000ab4df4b502cc"/><file name="Js.php" hash="acb7f5ad743ca311153b639f6ea33c75"/></dir><dir name="Summary"><file name="Totals.php" hash="bbe4ec0aaf15ecc40bff8504d67aa1e4"/></dir><file name="Summary.php" hash="a2b997d74cee541fd570327a496e30fb"/></dir><dir name="Core"><file name="ShippingStatus.php" hash="c92beeec25228692afcc2f64ed44dd01"/></dir></dir><file name="Exception.php" hash="5b9f750676440653abfee244727aa29f"/><dir name="Helper"><file name="Carrier.php" hash="9625f891a86da6b84c4bdf5f1ff37597"/><file name="Checkout.php" hash="cf0907c1d9601c137c2fd8b3c1d3487d"/><file name="Cif.php" hash="0285a984fe853a189081a4aa9e4db057"/><file name="Data.php" hash="dd3ecac31d13ecabc4bf2e4d17d1cdad"/><file name="Webservices.php" hash="0cc54fac78af257b2740d9519e9570d3"/></dir><dir name="Model"><dir name="Adminhtml"><dir name="Observer"><file name="OrderGrid.php" hash="f0b59f8fcf1293ff1fafb464c4e05d2f"/><file name="ShipmentGrid.php" hash="6d6acc13423d2b9cb954c8aae681ebac"/><file name="ShipmentView.php" hash="208a690d8a09658dfc8f0dfcb2696b77"/></dir><dir name="System"><dir name="Config"><dir name="Source"><file name="ShipmentGridColumns.php" hash="fec7db9a0c5ba79c6a0987ddec42e4cc"/></dir></dir></dir></dir><dir name="Carrier"><file name="Postnl.php" hash="f0143161e67fcd16e6739015c776d0f9"/><dir name="System"><dir name="Config"><dir name="Source"><file name="RateType.php" hash="940bf2381b879188d6e4aa756d0d0dce"/></dir></dir></dir></dir><dir name="Checkout"><file name="Cif.php" hash="9ab1f1c983f5b3ba41a9019e723ec1c3"/><dir name="Observer"><file name="Order.php" hash="5cf7b700b2286a6916f23e72e3346beb"/><file name="Shipment.php" hash="217a3bf9d730f1061e9d3117edc6c2a3"/></dir><file name="Order.php" hash="619b8f385b29357449644def665f58c0"/><dir name="Resource"><dir name="Order"><file name="Collection.php" hash="fe0751975beca120d547a2a6db7eb9a8"/></dir><file name="Order.php" hash="d821477695f495031b62eb85b383f981"/></dir><file name="Service.php" hash="6ff1b8c9d595b14059c6422c3472c90a"/><dir name="System"><dir name="Config"><dir name="Source"><file name="ActivePaymentMethods.php" hash="7e9ff249f3ca3ca28e8e4831e2a9b4cb"/><file name="CmsPage.php" hash="0ed3351761c49cad9f3611704f61aa5e"/></dir></dir></dir></dir><dir name="Core"><dir name="Cif"><file name="Abstract.php" hash="e85f0bd137fcc02c01c47995cb03325d"/><file name="Exception.php" hash="c448a27c6ecd9c2886344f13c9e58ac1"/></dir><file name="Cif.php" hash="0bc0de043cb254dd20b17759d8fb2484"/><file name="Label.php" hash="ae592a2943250e840f9d6ba2b3553c6c"/><dir name="Observer"><file name="Barcode.php" hash="49eb5448e784f9d2d2a74bb317002b95"/><file name="Cron.php" hash="cd9ae8fd4f38c22dbeca892bad7cd6a7"/><file name="SaveShipment.php" hash="ea2a8ee51d856075e9beec7e5c71dbf0"/></dir><dir name="Resource"><dir name="Shipment"><dir name="Barcode"><file name="Collection.php" hash="cba086559e46ab05eb745820cb674940"/></dir><file name="Barcode.php" hash="3fababe4d418342d5b69a153bd366017"/><file name="Collection.php" hash="f2dab6fa63764c98a2ab06871f68fefe"/><dir name="Label"><file name="Collection.php" hash="178f85ee761975231fc5d8a51c6ae466"/></dir><file name="Label.php" hash="c73b399ac5562259d0f1fd142be9fee0"/><dir name="Status"><dir name="History"><file name="Collection.php" hash="07cdf9dd45423e5d315e31b2dd7f951a"/></dir><file name="History.php" hash="cf483a122ebc9aca139a13bcb730e85c"/></dir></dir><file name="Shipment.php" hash="221e5c5728908f15d7558f8e6fe1103e"/></dir><dir name="Shipment"><file name="Barcode.php" hash="89aa40330448be2ceb79d052e1aa6e9b"/><file name="Label.php" hash="791fb2ff0dc51e5a72c2982c01bd9f9d"/><file name="Process.php" hash="752a7cf14a23f3389e2f19fa7419605e"/><dir name="Status"><file name="History.php" hash="bc1e67b513e58e6373d122eb6b1e5eea"/></dir></dir><file name="Shipment.php" hash="4f605ac483c26aa255fe000212bbdc7c"/><dir name="System"><dir name="Config"><dir name="Source"><file name="AllProductOptions.php" hash="6be78f115cc735069f1fe6c07cf70271"/><file name="Attributes.php" hash="a8384fbf1524c432f7b087dad9a7c813"/><file name="DebugMode.php" hash="0bbcbc4f0c771723b2031eb95dc7ca13"/><file name="Direction.php" hash="a93d5436ed8e231261217af00b799c92"/><file name="EuProductOptions.php" hash="2694e91d9c3f5c736b86ec44a1c2a101"/><file name="GlobalProductOptions.php" hash="5f211b4b8d96a9b7d34d1960c142a43d"/><file name="LabelSize.php" hash="88e3cf3ca607dca603e4b5b42a563912"/><file name="PakjeGemakProductOptions.php" hash="12d97c5b30c2d587fb6e8ce078a6b582"/><file name="ReferenceType.php" hash="559bfab1b5fc1ff7b42eed0a3654708a"/><file name="ShipmentGridMassaction.php" hash="77b9b2c30aa82eea994faade8add6714"/><file name="StandardProductOptions.php" hash="9ebac04faa76287a1c349bf97c5c3b6d"/><file name="StreetField.php" hash="eb5c59b91a92c64189f239469a8472bb"/><file name="StreetFieldWithDefault.php" hash="336dbc8571b59d5d1970d5a13efa5954"/><file name="WeightUnit.php" hash="b3f1ccc564b64f8874e5b3dfd4a2e456"/></dir></dir></dir></dir><dir name="ExtensionControl"><file name="Feed.php" hash="edf1fa5590f6f39bf5082a20e20a8408"/><dir name="Observer"><file name="Cron.php" hash="0e38a6072f2ecc2423ac360a3eb4d5d8"/></dir><dir name="Webservices"><file name="Abstract.php" hash="35bb7474364056366434734b42536a47"/></dir><file name="Webservices.php" hash="708433a4f84fe645c482bebb256e0ea8"/></dir><file name="Inbox.php" hash="9e3067d0e9b3137e33bcc99eea829a22"/><dir name="Resource"><dir name="Db"><dir name="Collection"><file name="Postnl.php" hash="a337c73f47df77a3de420ad13198dcfa"/></dir></dir><dir name="Order"><dir name="Grid"><file name="Collection.php" hash="6cd139d824f9fba6ec6205f0a9aed54e"/></dir><dir name="Shipment"><dir name="Grid"><file name="Collection.php" hash="abaf6d8cdd36d96778a8341afd01a48e"/></dir></dir></dir><file name="Setup.php" hash="77d7d376e08fb007c3af925cee5c8f7a"/></dir><dir name="System"><dir name="Config"><dir name="Source"><file name="Testlive.php" hash="ba607caaa1e297cb91f20a840daa3ea8"/></dir></dir></dir></dir><dir name="controllers"><dir name="Adminhtml"><file name="ConfigController.php" hash="2f97c4694df8aad70bcb4a44e6385495"/><file name="ExtensionControlController.php" hash="73b172250955a15b531ff9fb43fdc003"/><file name="ShipmentController.php" hash="d57adbc99d486f4114e4fb747b682e66"/></dir><file name="CheckoutController.php" hash="4ca43ba622a2e0cbc9a1459b43bd6687"/></dir><dir name="data"><dir name="postnl_setup"><file name="data-install-1.0.0.php" hash="5d24b54be571e8c1ee6e7a74afe99113"/><file name="data-install-1.0.3.php" hash="b42e23def5a1d5f2759e069b70e0b617"/><file name="data-install-1.1.4.php" hash="f01176a445496a73dbd16c617f753c77"/></dir></dir><dir name="etc"><file name="adminhtml.xml" hash="8686744c313445cf0a79087b63ab31db"/><file name="config.xml" hash="bc6912a4ce005c9831492327bdf976d7"/><file name="system.xml" hash="2a421c973efc6df275eeede260966eeb"/></dir><dir name="sql"><dir name="postnl_setup"><file name="install-1.0.0.php" hash="97b8584781e5e7cf6abe204387578fa0"/></dir></dir></dir></dir></target><target name="magedesign"><dir name="frontend"><dir name="base"><dir name="default"><dir name="layout"><dir name="TIG"><file name="postnl.xml" hash="ec012e0f62047ecfcd40db5e28fb717b"/></dir></dir><dir name="template"><dir name="TIG"><dir name="PostNL"><dir name="checkout"><dir name="cart"><file name="js.phtml" hash="d3a53229d6838ab254a5749dcb475a21"/><file name="link.phtml" hash="9f783975ca668d2a2dbb6ee4d9d6f9be"/><file name="spinner.phtml" hash="0f66e5018bb120753e349c9206deac3b"/></dir><dir name="summary"><file name="totals.phtml" hash="05be26ff83cb33b0af5231b07e7bbe10"/></dir><file name="summary.phtml" hash="d6dc6f0614868e4f9f3fee48473c95d3"/></dir><dir name="sales"><dir name="order"><dir name="shipment"><file name="shipping_status.phtml" hash="02e80c01ca12ac4bd3040ca5f7916c47"/></dir></dir></dir></dir></dir></dir></dir></dir></dir><dir name="adminhtml"><dir name="default"><dir name="default"><dir name="layout"><dir name="TIG"><file name="postnl.xml" hash="ef6de7a094b85cf296beb996d8d0d3ca"/></dir></dir><dir name="template"><dir name="TIG"><dir name="PostNL"><file name="cron_notification.phtml" hash="aa24f6b3473640c44f47a0f49081fc59"/><dir name="sales"><dir name="order"><file name="filter_massaction.phtml" hash="92c5c6ad1a8b4fcbd5cd3b955c12c6ec"/><file name="product_options.phtml" hash="7635dff53db6ad6d6f43e0bb96804f65"/><dir name="shipment"><dir name="create"><file name="shipment_options.phtml" hash="5027b8f14937190623f6b6febbe167dd"/></dir><dir name="view"><file name="shipping_status.phtml" hash="704b07c07c84783d9342f54d2789e3e9"/><dir name="tab"><file name="status_history.phtml" hash="2e64eb69b6e3dc90713d41496dcdd642"/></dir></dir><file name="view.phtml" hash="c767d27a2b1fa0bae476eaa3cb879f47"/></dir></dir><dir name="shipment"><file name="testmode_warning.phtml" hash="e9d2d3cf738a464eec67e4798a161903"/></dir></dir><dir name="system"><dir name="config"><dir name="form"><dir name="field"><file name="config_check.phtml" hash="93574dfe0c836e205138dcdc647991de"/><file name="field_header.phtml" hash="806634be75eea5a462ec8df61e0acaee"/><file name="info_box.phtml" hash="da355f0ea45558343880ed5ae54c3b1c"/><file name="js.phtml" hash="53c1fb76b4fed4125248f03c5c4a3e1e"/><file name="split_address_check.phtml" hash="d9bf074af0f6b7dafb235008fc908312"/><file name="support_tab.phtml" hash="4431ec65a8c299e9721cf4223b351b86"/><file name="warning_box.phtml" hash="344231e59acd6740f4ad5df742a16a4a"/></dir></dir></dir></dir></dir></dir></dir></dir></dir></dir></target><target name="mageetc"><dir name="modules"><file name="TIG_PostNL.xml" hash="4868726d0f27d7d2c11fd6c2a5deb22d"/></dir></target><target name="mageskin"><dir name="frontend"><dir name="base"><dir name="default"><dir name="css"><dir name="TIG"><dir name="PostNL"><file name="cart.css" hash="3e0ba5de132ddfac90f0e7bb834f4361"/><file name="messages.css" hash="19d03101c862b45535bc08344c12716a"/><file name="shipping_status.css" hash="0162a5c3dcd72eb01a8b4c6bb0ee075d"/></dir></dir></dir><dir name="images"><dir name="TIG"><dir name="PostNL"><file name="bkg_progress_small.png" hash="fc6c9f28b6a6aae6f0096d504c0952df"/><file name="overlay.png" hash="f08feb852288bea420ba3af68ae34a1f"/><file name="postnl_email_logo.png" hash="8bd358b514e04e7ceca03efb38f8fded"/><file name="postnl_spinner.gif" hash="cef321b68ab934932ee317986823db67"/></dir></dir></dir></dir></dir><dir name="enterprise"><dir name="default"><dir name="images"><dir name="TIG"><dir name="PostNL"><file name="overlay.png" hash="f08feb852288bea420ba3af68ae34a1f"/><file name="postnl_spinner.gif" hash="c97d0bd9ccc8fa0b460c07caeb63c293"/></dir></dir></dir><dir name="css"><dir name="TIG"><dir name="PostNL"><file name="cart.css" hash="4f8b417defed03e6ae8c4ec292b2e2c3"/></dir></dir></dir></dir></dir></dir><dir name="adminhtml"><dir name="default"><dir name="default"><dir name="css"><dir name="TIG"><dir name="PostNL"><file name="messages.css" hash="524a400b943a4504303b0646440648f1"/><file name="shipping_status.css" hash="46f19403af66e08fe5182bac5a6a20fe"/><file name="system_config_edit.css" hash="b4c897ee8801ed42f6c83754fb2abb08"/><file name="system_config_edit_postnl.css" hash="ace354fced0cf01b004e3f681118c2bb"/></dir></dir></dir><dir name="images"><dir name="TIG"><dir name="PostNL"><file name="bkg_progress_grey.png" hash="8d4d5144292b98a23475367ede717b17"/><file name="bkg_progress_grey_begin.png" hash="6815c9264e78f8f9d2805c595f8800c4"/><file name="bkg_progress_grey_end.png" hash="dae90fdb38adf65e6ccc209b6a80372c"/><file name="bkg_progress_grey_seperator.png" hash="10178e12fd14fb783b4ae0fbd55a4a81"/><file name="bkg_progress_orange.png" hash="8a59f76e36ee0492f5341b8e5e7ee79b"/><file name="bkg_progress_orange_begin.png" hash="ecc84d5252e397f4a783ee7e0c426d63"/><file name="bkg_progress_orange_end.png" hash="d0a81dfea1a3eddc699482a62af01fc9"/><file name="bkg_progress_orange_grey_seperator.png" hash="ab558953ec4c40ef44653ab481084345"/><file name="bkg_progress_orange_seperator.png" hash="a774eb89763d95f2e60d03f8702fba86"/><file name="bkg_progress_sprite.png" hash="3230379a4544f85062a6ba91fa8083e2"/><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="legend.gif" hash="d8fb0642901868d489d31b426f3e3406"/><file name="logo_postnl.png" hash="10b9ae4ad2c5365312c257dcdac1fc64"/><file name="tig_logo_medium.gif" hash="3e1071908cfdb7b472438482c3331ac7"/></dir></dir></dir><dir name="js"><dir name="TIG"><dir name="PostNL"><file name="shipment_options.js" hash="35383a85422ca0c2b740f438b62c250e"/><file name="validate.js" hash="729162d483749fd229c7f0f30b2e2df2"/></dir></dir></dir><dir name="media"><dir name="TIG"><dir name="PostNL"><file name="manual.pdf" hash="449de1cfa1449ac51ab19b0142f8cae9"/></dir></dir></dir></dir></dir></dir></target><target name="magelib"><dir name="TIG"><dir name="PostNL"><dir name="Fpdf"><dir name="font"><file name="courier.php" hash="ca6fb483549604fb4a675f9e28a73b02"/><file name="courierb.php" hash="a58d7dadf3cf564ca5d5138cea76a3a9"/><file name="courierbi.php" hash="c0e416771dc56cb2397390978d112dc2"/><file name="courieri.php" hash="419961dbeeb20f08da780dccb427dec8"/><file name="helvetica.php" hash="fc53162b924ddd522bd6cfe86fab48f4"/><file name="helveticab.php" hash="4e9ffda682a131fef2e04ccd94aa342d"/><file name="helveticabi.php" hash="6db8943bd91bf13514b82872cf160d45"/><file name="helveticai.php" hash="13b795df0c33eb93c48621792f2ea12d"/><file name="symbol.php" hash="fbd9250c21af99f6398d6f817511f91f"/><file name="times.php" hash="82bc100f1f3bd8b2d9b7fb5ee8f44b3a"/><file name="timesb.php" hash="3a241a1658bf9ea2062e63f464166c31"/><file name="timesbi.php" hash="bfdd0235a71793becefff778c2b16243"/><file name="timesi.php" hash="17fd69f176915a2113fe28057b43a75e"/><file name="zapfdingbats.php" hash="2848ab2daf3128f310b5cf713ca4acee"/></dir><file name="fpdf.css" hash="84befac49464a9aac54aa511bc1fd754"/><file name="fpdf.php" hash="f9228af7ef1c18691cba2ad075bc5858"/><file name="helvetica.php" hash="fc53162b924ddd522bd6cfe86fab48f4"/><file name="license.txt" hash="fb784726cfe3615da38bc23a3cac445b"/></dir><file name="Fpdf.php" hash="a0d54e6259621bb9d4c4801c53740340"/><dir name="Fpdi"><dir name="filters"><file name="FilterASCII85.php" hash="fe706bbd320881c300ec1a9f71e4eb2b"/><file name="FilterASCII85_FPDI.php" hash="1240e0c64602864401f886546e09fe7b"/><file name="FilterLZW.php" hash="35644f48b6b65c8726fc71cfad6c0478"/><file name="FilterLZW_FPDI.php" hash="b11c50e66e20744ad20f176cae4af284"/></dir><file name="fpdf_tpl.php" hash="3966b13c398c94509e2fb6199593b104"/><file name="fpdi.php" hash="abb524d17a2cbdd3c3b7e89184aad443"/><file name="fpdi2tcpdf_bridge.php" hash="8cc7fc486b015f1e17e75d1e5d585902"/><file name="fpdi_pdf_parser.php" hash="d7a3bf0153ae9ad57976afb0be5d195d"/><file name="pdf_context.php" hash="0b69a25dbb830f3b68c054c2e43b876e"/><file name="pdf_parser.php" hash="5ff22a8c1ce5b1eee82c8017311a797e"/></dir><file name="Fpdi.php" hash="fdf663915f3930bc0dc00db46cc20944"/></dir></dir></target><target name="magelocale"><dir name="en_US"><dir name="template"><dir name="email"><dir name="TIG"><dir name="PostNL"><file name="track_and_trace.html" hash="7ace8a754b0ea35775e0a3b66ad96b19"/></dir></dir></dir></dir><file name="TIG_PostNL.csv" hash="0b8ce0311a509ad6733ec60a0bc98e96"/></dir><dir name="nl_NL"><dir name="template"><dir name="email"><dir name="TIG"><dir name="PostNL"><file name="track_and_trace.html" hash="122c60807ec59834e3445fe40540e8c9"/></dir></dir></dir></dir><file name="TIG_PostNL.csv" hash="be7d58fd353e5812f3468caee7d6da0b"/></dir></target></contents>
111
  <compatible/>
112
  <dependencies><required><php><min>5.3.0</min><max>6.0.0</max></php></required></dependencies>
113
  </package>
skin/adminhtml/default/default/css/TIG/PostNL/messages.css CHANGED
@@ -1 +1,10 @@
1
  a.postnl-message {color:#EA7601 !important; text-decoration:underline;}
 
 
 
 
 
 
 
 
 
1
  a.postnl-message {color:#EA7601 !important; text-decoration:underline;}
2
+
3
+ /* Messages */
4
+ .module-message { padding:9px 9px 2px 30px; margin-bottom:20px; border:1px solid #ccc; color:#2f2f2f !important; font-weight:normal !important; }
5
+ .module-message li { margin-bottom:4px; }
6
+ .module-message.success { background:#edf7eb url(../../../images/TIG/PostNL/glyph_success.gif) 9px 9px no-repeat; border-color:#22731f; }
7
+ .module-message.info { background:#e6eef8 url(../../../images/TIG/PostNL/glyph_info.gif) 9px 9px no-repeat; border-color:#264697; }
8
+ .module-message.warning { background:#fff7bd url(../../../images/TIG/PostNL/glyph_warning.gif) 9px 9px no-repeat; border-color:#c68c05; }
9
+ .module-message.error { background:#fdece4 url(../../../images/TIG/PostNL/glyph_error.gif) 9px 9px no-repeat; border-color:#c63625; }
10
+ .module-message ul.postnl-errors {list-style:disc inside; }
skin/adminhtml/default/default/css/TIG/PostNL/system_config_edit_postnl.css CHANGED
@@ -29,15 +29,6 @@
29
  #postnl_support #supportWrap .col-right { width:50%; }
30
  #postnl_support #supportWrap .col-faux { padding:0 5px; }
31
 
32
- /* Messages */
33
- .module-message { padding:9px 9px 2px 30px; margin-bottom:20px; border:1px solid #ccc; color:#2f2f2f !important; font-weight:normal !important; }
34
- .module-message li { margin-bottom:4px; }
35
- .module-message.success { background:#edf7eb url(../../../images/TIG/PostNL/glyph_success.gif) 9px 9px no-repeat; border-color:#22731f; }
36
- .module-message.info { background:#e6eef8 url(../../../images/TIG/PostNL/glyph_info.gif) 9px 9px no-repeat; border-color:#264697; }
37
- .module-message.warning { background:#fff7bd url(../../../images/TIG/PostNL/glyph_warning.gif) 9px 9px no-repeat; border-color:#c68c05; }
38
- .module-message.error { background:#fdece4 url(../../../images/TIG/PostNL/glyph_error.gif) 9px 9px no-repeat; border-color:#c63625; }
39
- .module-message ul.postnl-errors {list-style:disc inside; }
40
-
41
  /* Config Header */
42
  .content-header h3 { background:transparent url(../../../images/TIG/PostNL/logo_postnl.png) 0 0 no-repeat !important; height:25px; padding-left:31px; line-height:24px; }
43
 
29
  #postnl_support #supportWrap .col-right { width:50%; }
30
  #postnl_support #supportWrap .col-faux { padding:0 5px; }
31
 
 
 
 
 
 
 
 
 
 
32
  /* Config Header */
33
  .content-header h3 { background:transparent url(../../../images/TIG/PostNL/logo_postnl.png) 0 0 no-repeat !important; height:25px; padding-left:31px; line-height:24px; }
34
 
skin/adminhtml/default/default/js/TIG/PostNL/validate.js CHANGED
@@ -1,27 +1,27 @@
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@totalinternetgroup.nl so we can send you a copy immediately.
@@ -41,12 +41,12 @@ document.observe('dom:loaded', function() {
41
  if (!element.value.empty()) {
42
  element.removeClassName('postnl-validate-empty');
43
  }
44
-
45
  element.observe('change', function(event) {
46
  var eventElement = Event.element(event);
47
  checkEmpty(eventElement);
48
  });
49
-
50
  element.observe('keyup', function(event) {
51
  var eventElement = Event.element(event);
52
  checkEmpty(eventElement);
@@ -59,9 +59,8 @@ function checkEmpty(eventElement) {
59
  eventElement.addClassName('postnl-validate-empty');
60
  return;
61
  }
62
-
63
  if (!eventElement.value.empty() && eventElement.hasClassName('postnl-validate-empty')) {
64
  eventElement.removeClassName('postnl-validate-empty');
65
- return;
66
  }
67
  }
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@totalinternetgroup.nl so we can send you a copy immediately.
41
  if (!element.value.empty()) {
42
  element.removeClassName('postnl-validate-empty');
43
  }
44
+
45
  element.observe('change', function(event) {
46
  var eventElement = Event.element(event);
47
  checkEmpty(eventElement);
48
  });
49
+
50
  element.observe('keyup', function(event) {
51
  var eventElement = Event.element(event);
52
  checkEmpty(eventElement);
59
  eventElement.addClassName('postnl-validate-empty');
60
  return;
61
  }
62
+
63
  if (!eventElement.value.empty() && eventElement.hasClassName('postnl-validate-empty')) {
64
  eventElement.removeClassName('postnl-validate-empty');
 
65
  }
66
  }
skin/adminhtml/default/default/media/TIG/PostNL/manual.pdf CHANGED
Binary file